+/* --- @name__scan@ --- *
+ *
+ * Arguments: @netg *n@ = the netgroup handle we're scanning
+ * @const char *host@ = the host name
+ * @const char *user@ = the user name
+ * @const char *domain@ = the (NIS?) domain name
+ * @void *ctx@ = some context pointer
+ *
+ * Returns: Zero to continue scanning.
+ *
+ * Use: Scans a netgroup, adding items to the name table.
+ */
+
+/* --- A data type --- */
+
+typedef struct name__scanctx {
+ char *name; /* Netgroup name prefixed with `?_'*/
+ unsigned f; /* Various interesting flags */
+ name *h; /* Name entry for hosts */
+ name *u; /* Name entry for users */
+} name__scanctx;
+
+enum { f_host = 1, f_user = 2 };
+
+/* --- And now for the real code --- */
+
+static int name__scan(netg *n, const char *host, const char *user,
+ const char *domain, void *ctx)
+{
+ name__scanctx *sc = ctx;
+
+ /* --- Add the host to the hosts class --- */
+
+ if (sc->f & f_host && host) {
+ struct hostent *h;
+ struct in_addr in;
+ const char *a;
+
+ /* --- First ensure that I have a host class --- */
+
+ if (!sc->h) {
+ sc->name[0] = 'h';
+ sc->h = name__get(sc->name, clType_host);
+ if (!sc->h) {
+ sc->f &= ~f_host;
+ goto done_host;
+ }
+ }
+
+ /* --- Now that I've done that, try to add the host --- *
+ *
+ * I'll turn it into an IP address. There's less chance of confusion
+ * that way.
+ */
+
+ if ((h = gethostbyname(host)) == 0)
+ goto done_host;
+ memcpy(&in, h->h_addr, sizeof(in));
+ if ((a = inet_ntoa(in)) == 0)
+ goto done_host;
+ sym_find(sc->h->c->t, a, -1, sizeof(sym_base), 0);
+ done_host:;
+ }
+
+ /* --- Add the user to the users class --- */