diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2010-12-16 21:50:51 +0000 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2010-12-16 21:50:51 +0000 |
commit | f67d6f67b84daa6acd33dd8f4192a72bc46c3a63 (patch) | |
tree | 5a2a84e90cbf80cd3f2ca1616a2d27b694c51d91 /nss/protocols.c | |
parent | 08f01639626bb2ec2537df7d9f8c5459867c0afb (diff) |
switch to a common back-end with a common constructor and destructor and put file pointer shared between {set,get,end}ent() calls in there
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd-solaris@1333 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'nss/protocols.c')
-rw-r--r-- | nss/protocols.c | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/nss/protocols.c b/nss/protocols.c index 5d61576..c641eaa 100644 --- a/nss/protocols.c +++ b/nss/protocols.c @@ -156,33 +156,24 @@ static nss_status_t protocols_getprotobynumber(nss_backend_t UNUSED(*be),void *a READ_RESULT(fp)); } -/* thread-local file pointer to an ongoing request */ -static __thread TFILE *protoentfp; - -static nss_status_t protocols_setprotoent(nss_backend_t UNUSED(*be),void UNUSED(*args)) -{ - NSS_SETENT(protoentfp); -} - -static nss_status_t protocols_getprotoent(nss_backend_t UNUSED(*be),void *args) +static nss_status_t protocols_setprotoent(nss_backend_t *be,void UNUSED(*args)) { - NSS_GETENT(protoentfp,NSLCD_ACTION_PROTOCOL_ALL, - READ_RESULT(protoentfp)); + NSS_SETENT(LDAP_BE(be)->fp); } -static nss_status_t protocols_endprotoent(nss_backend_t UNUSED(*be),void UNUSED(*args)) +static nss_status_t protocols_getprotoent(nss_backend_t *be,void *args) { - NSS_ENDENT(protoentfp); + NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_PROTOCOL_ALL, + READ_RESULT(LDAP_BE(be)->fp)); } -static nss_status_t protocols_destructor(nss_backend_t *be,void UNUSED(*args)) +static nss_status_t protocols_endprotoent(nss_backend_t *be,void UNUSED(*args)) { - free(be); - return NSS_STATUS_SUCCESS; + NSS_ENDENT(LDAP_BE(be)->fp); } -static nss_backend_op_t proto_ops[]={ - protocols_destructor, +static nss_backend_op_t protocols_ops[]={ + nss_ldap_destructor, protocols_endprotoent, protocols_setprotoent, protocols_getprotoent, @@ -193,13 +184,7 @@ static nss_backend_op_t proto_ops[]={ nss_backend_t *_nss_ldap_protocols_constr(const char UNUSED(*db_name), const char UNUSED(*src_name),const char UNUSED(*cfg_args)) { - nss_backend_t *be; - be=(nss_backend_t *)malloc(sizeof(*be)); - if (be==NULL) - return NULL; - be->ops=proto_ops; - be->n_ops=sizeof(proto_ops)/sizeof(nss_backend_op_t); - return (nss_backend_t *)be; + return nss_ldap_constructor(protocols_ops,sizeof(protocols_ops)); } #endif /* NSS_FLAVOUR_SOLARIS */ |