"Fossies" - the Fresh Open Source Software Archive

Member "nss_ldap-265/ldap-parse.h" (6 Nov 2009, 6245 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-parse.h,v 2.22 2009/11/06 10:15:26 lukeh Exp $
   21  */
   22 
   23 
   24 #ifndef _LDAP_NSS_LDAP_LDAP_PARSE_H
   25 #define _LDAP_NSS_LDAP_LDAP_PARSE_H
   26 
   27 #if defined(HAVE_NSSWITCH_H)
   28 #define NSS_ARGS(args)  ((nss_XbyY_args_t *)args)
   29 
   30 #define LOOKUP_NAME(args, filter, selector, parser, req_buflen) \
   31     ldap_args_t a; \
   32     NSS_STATUS s; \
   33     if (NSS_ARGS(args)->buf.buflen < req_buflen) { \
   34         NSS_ARGS(args)->erange = 1; \
   35         return NSS_TRYAGAIN; \
   36     } \
   37     LA_INIT(a); \
   38     LA_STRING(a) = NSS_ARGS(args)->key.name; \
   39     LA_TYPE(a) = LA_TYPE_STRING; \
   40     s = _nss_ldap_getbyname(&a, \
   41         NSS_ARGS(args)->buf.result, \
   42         NSS_ARGS(args)->buf.buffer, \
   43         NSS_ARGS(args)->buf.buflen, \
   44         &NSS_ARGS(args)->erange, \
   45         filter, \
   46         selector, \
   47         parser); \
   48     if (s == NSS_SUCCESS) { \
   49         NSS_ARGS(args)->returnval = NSS_ARGS(args)->buf.result; \
   50     } \
   51     return s
   52 #define LOOKUP_NUMBER(args, field, filter, selector, parser, req_buflen) \
   53     ldap_args_t a; \
   54     NSS_STATUS s; \
   55     if (NSS_ARGS(args)->buf.buflen < req_buflen) { \
   56         NSS_ARGS(args)->erange = 1; \
   57         return NSS_TRYAGAIN; \
   58     } \
   59     LA_INIT(a); \
   60     LA_NUMBER(a) = NSS_ARGS(args)->field; \
   61     LA_TYPE(a) = LA_TYPE_NUMBER; \
   62     s = _nss_ldap_getbyname(&a, \
   63         NSS_ARGS(args)->buf.result, \
   64         NSS_ARGS(args)->buf.buffer, \
   65         NSS_ARGS(args)->buf.buflen, \
   66         &NSS_ARGS(args)->erange, \
   67         filter, \
   68         selector, \
   69         parser); \
   70     if (s == NSS_SUCCESS) { \
   71         NSS_ARGS(args)->returnval = NSS_ARGS(args)->buf.result; \
   72     } \
   73     return s
   74 #define LOOKUP_GETENT(args, be, filter, selector, parser, req_buflen) \
   75     NSS_STATUS s; \
   76     if (NSS_ARGS(args)->buf.buflen < req_buflen) { \
   77         NSS_ARGS(args)->erange = 1; \
   78         return NSS_TRYAGAIN; \
   79     } \
   80     s = _nss_ldap_getent(&((nss_ldap_backend_t *)be)->state, \
   81         NSS_ARGS(args)->buf.result, \
   82         NSS_ARGS(args)->buf.buffer, \
   83         NSS_ARGS(args)->buf.buflen, \
   84         &NSS_ARGS(args)->erange, \
   85         filter, \
   86         selector, \
   87         parser); \
   88     if (s == NSS_SUCCESS) { \
   89         NSS_ARGS(args)->returnval = NSS_ARGS(args)->buf.result; \
   90     } \
   91     return s
   92 
   93 #elif defined(HAVE_NSS_H)
   94 
   95 #define LOOKUP_NAME(name, result, buffer, buflen, errnop, filter, selector, parser, req_buflen) \
   96     ldap_args_t a; \
   97     if (buflen < req_buflen) { \
   98         *errnop = ERANGE; \
   99         return NSS_TRYAGAIN; \
  100     } \
  101     LA_INIT(a); \
  102     LA_STRING(a) = name; \
  103     LA_TYPE(a) = LA_TYPE_STRING; \
  104     return _nss_ldap_getbyname(&a, result, buffer, buflen, errnop, filter, selector, parser);
  105 #define LOOKUP_NUMBER(number, result, buffer, buflen, errnop, filter, selector, parser, req_buflen) \
  106     ldap_args_t a; \
  107     if (buflen < req_buflen) { \
  108         *errnop = ERANGE; \
  109         return NSS_TRYAGAIN; \
  110     } \
  111     LA_INIT(a); \
  112     LA_NUMBER(a) = number; \
  113     LA_TYPE(a) = LA_TYPE_NUMBER; \
  114     return _nss_ldap_getbyname(&a, result, buffer, buflen, errnop, filter, selector, parser)
  115 #define LOOKUP_GETENT(key, result, buffer, buflen, errnop, filter, selector, parser, req_buflen) \
  116     if (buflen < req_buflen) { \
  117         *errnop = ERANGE; \
  118         return NSS_TRYAGAIN; \
  119     } \
  120     return _nss_ldap_getent(&key, result, buffer, buflen, errnop, filter, selector, parser)
  121 
  122 #elif defined(HAVE_IRS_H)
  123 
  124 #define LOOKUP_NAME(name, this, filter, selector, parser, req_buflen) \
  125     ldap_args_t a; \
  126     struct pvt *pvt = (struct pvt *)this->private; \
  127     NSS_STATUS s; \
  128     LA_INIT(a); \
  129     LA_STRING(a) = name; \
  130     LA_TYPE(a) = LA_TYPE_STRING; \
  131     s = _nss_ldap_getbyname(&a, &pvt->result, pvt->buffer, sizeof(pvt->buffer), &errno, filter, \
  132         selector, parser); \
  133     if (s != NSS_SUCCESS) { \
  134         MAP_ERRNO(s, errno); \
  135         return NULL; \
  136     } \
  137     return &pvt->result;
  138 #define LOOKUP_NUMBER(number, this, filter, selector, parser, req_buflen) \
  139     ldap_args_t a; \
  140     struct pvt *pvt = (struct pvt *)this->private; \
  141     NSS_STATUS s; \
  142     LA_INIT(a); \
  143     LA_NUMBER(a) = number; \
  144     LA_TYPE(a) = LA_TYPE_NUMBER; \
  145     s = _nss_ldap_getbyname(&a, &pvt->result, pvt->buffer, sizeof(pvt->buffer), &errno, filter, \
  146         selector, parser); \
  147     if (s != NSS_SUCCESS) { \
  148         MAP_ERRNO(s, errno); \
  149         return NULL; \
  150     } \
  151     return &pvt->result;
  152 #define LOOKUP_GETENT(this, filter, selector, parser, req_buflen) \
  153     struct pvt *pvt = (struct pvt *)this->private; \
  154     NSS_STATUS s; \
  155     s = _nss_ldap_getent(&pvt->state, &pvt->result, pvt->buffer, \
  156         sizeof(pvt->buffer), &errno, filter, \
  157         selector, parser); \
  158     if (s != NSS_SUCCESS) { \
  159         MAP_ERRNO(s, errno); \
  160         return NULL; \
  161     } \
  162     return &pvt->result;
  163 #endif /* HAVE_NSSWITCH_H */
  164 
  165 #if defined(HAVE_NSSWITCH_H)
  166 
  167 #define LOOKUP_SETENT(key) \
  168     if (_nss_ldap_ent_context_init(&((nss_ldap_backend_t *)key)->state) == NULL) \
  169         return NSS_UNAVAIL; \
  170     return NSS_SUCCESS
  171 #define LOOKUP_ENDENT(key) \
  172     _nss_ldap_enter(); \
  173     _nss_ldap_ent_context_release(&(((nss_ldap_backend_t *)key)->state)); \
  174     _nss_ldap_leave(); \
  175     return NSS_SUCCESS
  176 
  177 #elif defined(HAVE_NSS_H)
  178 
  179 #define LOOKUP_SETENT(key) \
  180     if (_nss_ldap_ent_context_init(&key) == NULL) \
  181         return NSS_UNAVAIL; \
  182     return NSS_SUCCESS
  183 #define LOOKUP_ENDENT(key) \
  184     _nss_ldap_enter(); \
  185     _nss_ldap_ent_context_release(&key); \
  186     _nss_ldap_leave(); \
  187     return NSS_SUCCESS
  188 
  189 #elif defined(HAVE_IRS_H)
  190 
  191 #define LOOKUP_SETENT(this) \
  192     struct pvt *pvt = (struct pvt *)this->private; \
  193     (void) _nss_ldap_ent_context_init(&pvt->state)
  194 #define LOOKUP_ENDENT(this) \
  195     struct pvt *pvt = (struct pvt *)this->private; \
  196     _nss_ldap_enter(); \
  197     _nss_ldap_ent_context_release(&(pvt->state)); \
  198     _nss_ldap_leave();
  199 
  200 #endif /* HAVE_NSSWITCH_H */
  201 
  202 #endif /* _LDAP_NSS_LDAP_LDAP_PARSE_H */