/* Set up NIP to run through the services. Return nonzero if there are no services (left). */ static int setup (void **fctp, service_user **nipp) { /* Remember the first service_entry, it's always the same. */ static bool startp_initialized; static service_user *startp; int no_more; if (!startp_initialized) { /* Executing this more than once at the same time must yield the same result every time. So we need no locking. */ no_more = __nss_netgroup_lookup (nipp, "setnetgrent", fctp); startp = no_more ? (service_user *) -1 : *nipp; PTR_MANGLE (startp); atomic_write_barrier (); startp_initialized = true; } else { service_user *nip = startp; PTR_DEMANGLE (nip); if (nip == (service_user *) -1) /* No services at all. */ return 1; /* Reset to the beginning of the service list. */ *nipp = nip; /* Look up the first function. */ no_more = __nss_lookup (nipp, "setnetgrent", NULL, fctp); } return no_more; }
/* Set up NIP to run through the services. If ALL is zero, use NIP's current location if it's not nil. Return nonzero if there are no services (left). */ static enum nss_status setup (void **fctp, const char *func_name, int all, service_user **nipp) { /* Remember the first service_entry, it's always the same. */ static service_user *startp; int no_more; if (startp == NULL) { /* Executing this more than once at the same time must yield the same result every time. So we need no locking. */ no_more = __nss_netgroup_lookup (nipp, func_name, fctp); startp = no_more ? (service_user *) -1 : *nipp; } else if (startp == (service_user *) -1) /* No services at all. */ return 1; else { if (all || *nipp == NULL) /* Reset to the beginning of the service list. */ *nipp = startp; /* Look up the first function. */ no_more = __nss_lookup (nipp, func_name, fctp); } return no_more; }