]> git.sur5r.net Git - openldap/blob - contrib/slapd-modules/nssov/nss-ldapd/nss/rpc.c
nss overlay
[openldap] / contrib / slapd-modules / nssov / nss-ldapd / nss / rpc.c
1 /*
2    rpc.c - NSS lookup functions for rpc database
3
4    Copyright (C) 2006 West Consulting
5    Copyright (C) 2006, 2007, 2008 Arthur de Jong
6
7    This library is free software; you can redistribute it and/or
8    modify it under the terms of the GNU Lesser General Public
9    License as published by the Free Software Foundation; either
10    version 2.1 of the License, or (at your option) any later version.
11
12    This library is distributed in the hope that it will be useful,
13    but WITHOUT ANY WARRANTY; without even the implied warranty of
14    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15    Lesser General Public License for more details.
16
17    You should have received a copy of the GNU Lesser General Public
18    License along with this library; if not, write to the Free Software
19    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20    02110-1301 USA
21 */
22
23 #include "config.h"
24
25 #include <string.h>
26 #include <nss.h>
27 #include <errno.h>
28
29 #include "prototypes.h"
30 #include "common.h"
31 #include "compat/attrs.h"
32
33 static enum nss_status read_rpcent(
34         TFILE *fp,struct rpcent *result,
35         char *buffer,size_t buflen,int *errnop)
36 {
37   int32_t tmpint32,tmp2int32,tmp3int32;
38   size_t bufptr=0;
39   READ_STRING_BUF(fp,result->r_name);
40   READ_STRINGLIST_NULLTERM(fp,result->r_aliases);
41   READ_INT32(fp,result->r_number);
42   return NSS_STATUS_SUCCESS;
43 }
44
45 enum nss_status _nss_ldap_getrpcbyname_r(const char *name,struct rpcent *result,char *buffer,size_t buflen,int *errnop)
46 {
47   NSS_BYNAME(NSLCD_ACTION_RPC_BYNAME,
48              name,
49              read_rpcent(fp,result,buffer,buflen,errnop));
50 }
51
52 enum nss_status _nss_ldap_getrpcbynumber_r(int number,struct rpcent *result,char *buffer,size_t buflen,int *errnop)
53 {
54   NSS_BYINT32(NSLCD_ACTION_RPC_BYNUMBER,
55               number,
56               read_rpcent(fp,result,buffer,buflen,errnop));
57 }
58
59 /* thread-local file pointer to an ongoing request */
60 static __thread TFILE *protoentfp;
61
62 enum nss_status _nss_ldap_setrpcent(int UNUSED(stayopen))
63 {
64   NSS_SETENT(protoentfp);
65 }
66
67 enum nss_status _nss_ldap_getrpcent_r(struct rpcent *result,char *buffer,size_t buflen,int *errnop)
68 {
69   NSS_GETENT(protoentfp,NSLCD_ACTION_RPC_ALL,
70              read_rpcent(protoentfp,result,buffer,buflen,errnop));
71 }
72
73 enum nss_status _nss_ldap_endrpcent(void)
74 {
75   NSS_ENDENT(protoentfp);
76 }