"Fossies" - the Fresh Open Source Software Archive 
Member "nss_ldap-265/ldap-alias.c" (6 Nov 2009, 2984 Bytes) of package /linux/privat/old/nss_ldap-265.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 /* Copyright (C) 1997-2005 Luke Howard.
2 This file is part of the nss_ldap library.
3 Contributed by Luke Howard, <lukeh@padl.com>, 1997.
4
5 The nss_ldap library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public License as
7 published by the Free Software Foundation; either version 2 of the
8 License, or (at your option) any later version.
9
10 The nss_ldap library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public
16 License along with the nss_ldap library; see the file COPYING.LIB. If not,
17 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA.
19
20 $Id: ldap-alias.c,v 2.31 2006/01/11 18:03:48 lukeh Exp $
21 */
22
23
24 static char rcsId[] =
25 "$Id: ldap-alias.c,v 2.31 2006/01/11 18:03:48 lukeh Exp $";
26
27 #include "config.h"
28
29 #ifdef HAVE_PORT_BEFORE_H
30 #include <port_before.h>
31 #endif
32
33 #if defined(HAVE_THREAD_H) && !defined(_AIX)
34 #include <thread.h>
35 #elif defined(HAVE_PTHREAD_H)
36 #include <pthread.h>
37 #endif
38
39 #include <stdio.h>
40 #include <stdlib.h>
41 #include <string.h>
42 #include <lber.h>
43 #include <ldap.h>
44
45 #ifdef HAVE_ALIASES_H
46 #include <aliases.h>
47
48 #include "ldap-nss.h"
49 #include "ldap-alias.h"
50 #include "util.h"
51
52 #ifdef HAVE_PORT_AFTER_H
53 #include <port_after.h>
54 #endif
55
56 #ifdef HAVE_NSS_H
57 static ent_context_t *alias_context = NULL;
58
59 static NSS_STATUS
60 _nss_ldap_parse_alias (LDAPMessage * e,
61 ldap_state_t * pvt,
62 void *result, char *buffer, size_t buflen)
63 {
64
65 struct aliasent *alias = (struct aliasent *) result;
66 NSS_STATUS stat;
67
68 stat =
69 _nss_ldap_getrdnvalue (e, ATM (LM_ALIASES, cn), &alias->alias_name,
70 &buffer, &buflen);
71 if (stat != NSS_SUCCESS)
72 return stat;
73
74 stat =
75 _nss_ldap_assign_attrvals (e, AT (rfc822MailMember), NULL,
76 &alias->alias_members, &buffer, &buflen,
77 &alias->alias_members_len);
78
79 alias->alias_local = 0;
80
81 return stat;
82 }
83
84 NSS_STATUS
85 _nss_ldap_getaliasbyname_r (const char *name, struct aliasent * result,
86 char *buffer, size_t buflen, int *errnop)
87 {
88 LOOKUP_NAME (name, result, buffer, buflen, errnop,
89 _nss_ldap_filt_getaliasbyname, LM_ALIASES,
90 _nss_ldap_parse_alias, LDAP_NSS_BUFLEN_DEFAULT);
91 }
92
93 NSS_STATUS _nss_ldap_setaliasent (void)
94 {
95 LOOKUP_SETENT (alias_context);
96 }
97
98 NSS_STATUS _nss_ldap_endaliasent (void)
99 {
100 LOOKUP_ENDENT (alias_context);
101 }
102
103 NSS_STATUS
104 _nss_ldap_getaliasent_r (struct aliasent *result, char *buffer, size_t buflen,
105 int *errnop)
106 {
107 LOOKUP_GETENT (alias_context, result, buffer, buflen, errnop,
108 _nss_ldap_filt_getaliasent, LM_ALIASES,
109 _nss_ldap_parse_alias, LDAP_NSS_BUFLEN_DEFAULT);
110 }
111
112 #endif /* HAVE_NSS_H */
113 #endif /* HAVE_ALIASES_H */