"Fossies" - the Fresh Open Source Software Archive

Member "nss_ldap-265/irs-proto.c" (6 Nov 2009, 2982 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 
   21 #ifdef HAVE_IRS_H
   22 
   23 #include <errno.h>
   24 #include "irs-nss.h"
   25 
   26 /* $Id: irs-proto.c,v 2.23 2005/05/20 05:30:40 lukeh Exp $ */
   27 
   28 #ifdef HAVE_USERSEC_H
   29 void *pr_pvtinit (void);
   30 #endif
   31 IRS_EXPORT void pr_close (struct irs_pr *);
   32 IRS_EXPORT struct protoent *pr_byname (struct irs_pr *, const char *);
   33 IRS_EXPORT struct protoent *pr_bynumber (struct irs_pr *, int);
   34 IRS_EXPORT struct protoent *pr_next (struct irs_pr *);
   35 IRS_EXPORT void pr_rewind (struct irs_pr *);
   36 IRS_EXPORT void pr_minimize (struct irs_pr *);
   37 
   38 struct pvt
   39 {
   40   struct protoent result;
   41   char buffer[NSS_BUFLEN_PROTOCOLS];
   42   ent_context_t *state;
   43 };
   44 
   45 IRS_EXPORT struct protoent *
   46 pr_byname (struct irs_pr *this, const char *name)
   47 {
   48   LOOKUP_NAME (name, this, _nss_ldap_filt_getprotobyname, LM_PROTOCOLS,
   49            _nss_ldap_parse_proto, LDAP_NSS_BUFLEN_DEFAULT);
   50 }
   51 
   52 IRS_EXPORT struct protoent *
   53 pr_bynumber (struct irs_pr *this, int num)
   54 {
   55   LOOKUP_NUMBER (num, this, _nss_ldap_filt_getprotobynumber, LM_PROTOCOLS,
   56          _nss_ldap_parse_proto, LDAP_NSS_BUFLEN_DEFAULT);
   57 }
   58 
   59 IRS_EXPORT void
   60 pr_close (struct irs_pr *this)
   61 {
   62   LOOKUP_ENDENT (this);
   63 #ifdef HAVE_USERSEC_H
   64   free (this->private);
   65   free (this);
   66 #endif
   67 }
   68 
   69 IRS_EXPORT struct protoent *
   70 pr_next (struct irs_pr *this)
   71 {
   72   LOOKUP_GETENT (this, _nss_ldap_filt_getprotoent, LM_PROTOCOLS,
   73          _nss_ldap_parse_proto, LDAP_NSS_BUFLEN_DEFAULT);
   74 }
   75 
   76 IRS_EXPORT void
   77 pr_rewind (struct irs_pr *this)
   78 {
   79   LOOKUP_SETENT (this);
   80 }
   81 
   82 IRS_EXPORT void
   83 pr_minimize (struct irs_pr *this)
   84 {
   85 }
   86 
   87 #ifdef HAVE_USERSEC_H
   88 void *
   89 pr_pvtinit (void)
   90 #else
   91 struct irs_pr *
   92 irs_ldap_pr (struct irs_acc *this)
   93 #endif
   94 {
   95   struct irs_pr *pr;
   96   struct pvt *pvt;
   97 
   98   pr = calloc (1, sizeof (*pr));
   99   if (pr == NULL)
  100     return NULL;
  101 
  102   pvt = calloc (1, sizeof (*pvt));
  103   if (pvt == NULL)
  104     {
  105       free (pr);
  106       return NULL;
  107     }
  108 
  109   pvt->state = NULL;
  110   pr->private = pvt;
  111   pr->close = pr_close;
  112   pr->next = pr_next;
  113   pr->byname = pr_byname;
  114   pr->bynumber = pr_bynumber;
  115   pr->rewind = pr_rewind;
  116   pr->minimize = pr_minimize;
  117   return pr;
  118 }
  119 
  120 #endif /*HAVE_IRS_H */