void internal_endnetgrent (struct __netgrent *datap) { endnetgrent_hook (datap); /* Now free list of all netgroup names from last run. */ free_memory (datap); }
static int internal_function __internal_setnetgrent_reuse (const char *group, struct __netgrent *datap, int *errnop) { union { enum nss_status (*f) (const char *, struct __netgrent *); void *ptr; } fct; enum nss_status status = NSS_STATUS_UNAVAIL; struct name_list *new_elem; /* Free data from previous service. */ endnetgrent_hook (datap); /* Cycle through all the services and run their setnetgrent functions. */ int no_more = setup (&fct.ptr, &datap->nip); while (! no_more) { assert (datap->data == NULL); /* Ignore status, we force check in `__nss_next2'. */ status = DL_CALL_FCT (*fct.f, (group, datap)); service_user *old_nip = datap->nip; no_more = __nss_next2 (&datap->nip, "setnetgrent", NULL, &fct.ptr, status, 0); if (status == NSS_STATUS_SUCCESS && ! no_more) { enum nss_status (*endfct) (struct __netgrent *); endfct = __nss_lookup_function (old_nip, "endnetgrent"); if (endfct != NULL) (void) DL_CALL_FCT (*endfct, (datap)); } } /* Add the current group to the list of known groups. */ size_t group_len = strlen (group) + 1; new_elem = (struct name_list *) malloc (sizeof (struct name_list) + group_len); if (new_elem == NULL) { *errnop = errno; status = NSS_STATUS_TRYAGAIN; } else { new_elem->next = datap->known_groups; memcpy (new_elem->name, group, group_len); datap->known_groups = new_elem; } return status == NSS_STATUS_SUCCESS; }