source: branches/fc15-dev/server/common/oursrc/nss_nonlocal/walk_nss.h @ 1878

Last change on this file since 1878 was 1878, checked in by achernya, 13 years ago
Merge r1803-1877 from trunk to branches/fc15-dev
File size: 1.3 KB
Line 
1{
2    static service_user *startp = NULL;
3    static void *fct_start = NULL;
4
5    service_user *nip;
6    union {
7        __typeof__(self) l;
8        void *ptr;
9    } fct;
10    int old_errno = errno;
11
12    if (fct_start == NULL &&
13        w.lookup(&startp, w.fct_name, &fct_start) != 0) {
14        *w.status = NSS_STATUS_UNAVAIL;
15        goto walk_nss_out;
16    }
17
18    nip = startp;
19    fct.ptr = fct_start;
20
21    if (w.buf != NULL) {
22        *w.buf = malloc(*w.buflen);
23        errno = old_errno;
24        if (*w.buf == NULL) {
25            *w.status = NSS_STATUS_TRYAGAIN;
26            *w.errnop = ENOMEM;
27            goto walk_nss_out;
28        }
29    }
30
31    do {
32    walk_nss_morebuf:
33        if (fct.ptr == NULL)
34            *w.status = NSS_STATUS_UNAVAIL;
35        else if (self != NULL && fct.l == self)
36            *w.status = NSS_STATUS_NOTFOUND;
37        else
38            *w.status = DL_CALL_FCT(fct.l, args);
39        if (*w.status == NSS_STATUS_TRYAGAIN &&
40            w.errnop != NULL && *w.errnop == ERANGE) {
41            if (w.buf == NULL)
42                break;
43            free(*w.buf);
44            *w.buflen *= 2;
45            *w.buf = malloc(*w.buflen);
46            errno = old_errno;
47            if (*w.buf == NULL) {
48                *w.errnop = ENOMEM;
49                goto walk_nss_out;
50            }
51            goto walk_nss_morebuf;
52        }
53    } while (__nss_next(&nip, w.fct_name, &fct.ptr, *w.status, 0) == 0);
54
55    if (w.buf != NULL && *w.status != NSS_STATUS_SUCCESS) {
56        free(*w.buf);
57        *w.buf = NULL;
58    }
59
60 walk_nss_out:
61    ;
62}
Note: See TracBrowser for help on using the repository browser.