Back to index

openldap  2.4.31
Defines | Functions | Variables
netgroup.c File Reference
#include "nssov.h"
#include <ac/ctype.h>

Go to the source code of this file.

Defines

#define WRITE_STRING_STRIPSPACE_LEN(fp, str, len)
#define WRITE_STRING_STRIPSPACE(fp, str)   WRITE_STRING_STRIPSPACE_LEN(fp,str,strlen(str))

Functions

 NSSOV_CBPRIV (netgroup, char buf[256];struct berval name;)
static int write_string_stripspace_len (TFILE *fp, const char *str, int len)
static int write_netgroup_triple (TFILE *fp, const char *triple)
static int write_netgroup (nssov_netgroup_cbp *cbp, Entry *entry)

Variables

static struct berval = BER_BVC("(objectClass=nisNetgroup)")

Define Documentation

#define WRITE_STRING_STRIPSPACE (   fp,
  str 
)    WRITE_STRING_STRIPSPACE_LEN(fp,str,strlen(str))

Definition at line 82 of file netgroup.c.

#define WRITE_STRING_STRIPSPACE_LEN (   fp,
  str,
  len 
)
Value:
if (write_string_stripspace_len(fp,str,len)) \
              return -1;

Definition at line 78 of file netgroup.c.


Function Documentation

NSSOV_CBPRIV ( netgroup  ,
char buf;struct berval name [256] 
)
static int write_netgroup ( nssov_netgroup_cbp *  cbp,
Entry entry 
) [static]

Definition at line 152 of file netgroup.c.

{
       int32_t tmpint32;
       int i;
       Attribute *a;

       /* get the netgroup triples and member */
       a = attr_find(entry->e_attrs,cbp->mi->mi_attrs[1].an_desc);
       if ( a ) {
       /* write the netgroup triples */
              for (i=0;i<a->a_numvals;i++)
              {
                     if (write_netgroup_triple(cbp->fp, a->a_vals[i].bv_val))
                            return -1;
              }
       }
       a = attr_find(entry->e_attrs,cbp->mi->mi_attrs[2].an_desc);
       if ( a ) {
       /* write netgroup members */
              for (i=0;i<a->a_numvals;i++)
              {
                     /* write the result code */
                     WRITE_INT32(cbp->fp,NSLCD_RESULT_BEGIN);
                     /* write triple indicator */
                     WRITE_INT32(cbp->fp,NSLCD_NETGROUP_TYPE_NETGROUP);
                     /* write netgroup name */
                     if (write_string_stripspace_len(cbp->fp,a->a_vals[i].bv_val,a->a_vals[i].bv_len))
                            return -1;
              }
       }
       /* we're done */
       return 0;
}

Here is the call graph for this function:

static int write_netgroup_triple ( TFILE *  fp,
const char *  triple 
) [static]

Definition at line 85 of file netgroup.c.

{
       int32_t tmpint32;
       int i;
       int hostb,hoste,userb,usere,domainb,domaine;
       /* skip leading spaces */
       for (i=0;(triple[i]!='\0')&&(isspace(triple[i]));i++)
              /* nothing else to do */ ;
       /* we should have a bracket now */
       if (triple[i]!='(')
       {
              Debug(LDAP_DEBUG_ANY,"write_netgroup_triple(): entry does not begin with '(' (entry skipped)\n",0,0,0);
              return 0;
       }
       i++;
       hostb=i;
       /* find comma (end of host string) */
       for (;(triple[i]!='\0')&&(triple[i]!=',');i++)
              /* nothing else to do */ ;
       if (triple[i]!=',')
       {
              Debug(LDAP_DEBUG_ANY,"write_netgroup_triple(): missing ',' (entry skipped)\n",0,0,0);
              return 0;
       }
       hoste=i;
       i++;
       userb=i;
       /* find comma (end of user string) */
       for (;(triple[i]!='\0')&&(triple[i]!=',');i++)
              /* nothing else to do */ ;
       if (triple[i]!=',')
       {
              Debug(LDAP_DEBUG_ANY,"write_netgroup_triple(): missing ',' (entry skipped)\n",0,0,0);
              return 0;
       }
       usere=i;
       i++;
       domainb=i;
       /* find closing bracket (end of domain string) */
       for (;(triple[i]!='\0')&&(triple[i]!=')');i++)
              /* nothing else to do */ ;
       if (triple[i]!=')')
       {
              Debug(LDAP_DEBUG_ANY,"write_netgroup_triple(): missing ')' (entry skipped)\n",0,0,0);
              return 0;
       }
       domaine=i;
       i++;
       /* skip trailing spaces */
       for (;(triple[i]!='\0')&&(isspace(triple[i]));i++)
              /* nothing else to do */ ;
       /* if anything is left in the string we have a problem */
       if (triple[i]!='\0')
       {
              Debug(LDAP_DEBUG_ANY,"write_netgroup_triple(): string contains trailing data (entry skipped)\n",0,0,0);
              return 0;
       }
       /* write strings */
       WRITE_INT32(fp,NSLCD_RESULT_BEGIN);
       WRITE_INT32(fp,NSLCD_NETGROUP_TYPE_TRIPLE);
       WRITE_STRING_STRIPSPACE_LEN(fp,triple+hostb,hoste-hostb)
       WRITE_STRING_STRIPSPACE_LEN(fp,triple+userb,usere-userb)
       WRITE_STRING_STRIPSPACE_LEN(fp,triple+domainb,domaine-domainb)
       /* we're done */
       return 0;
}

Here is the caller graph for this function:

static int write_string_stripspace_len ( TFILE *  fp,
const char *  str,
int  len 
) [static]

Definition at line 49 of file netgroup.c.

{
       int32_t tmpint32;
       int i,j;
       DEBUG_PRINT("WRITE_STRING: var="__STRING(str)" string=\"%s\"",str);
       if (str==NULL)
       {
              WRITE_INT32(fp,0);
       }
       else
       {
              /* skip leading spaces */
              for (i=0;(str[i]!='\0')&&(isspace(str[i]));i++)
                     /* nothing else to do */ ;
              /* skip trailing spaces */
              for (j=len;(j>i)&&(isspace(str[j-1]));j--)
                     /* nothing else to do */ ;
              /* write length of string */
              WRITE_INT32(fp,j-i);
              /* write string itself */
              if (j>i)
              {
                     WRITE(fp,str+i,j-i);
              }
       }
       /* we're done */
       return 0;
}

Here is the caller graph for this function:


Variable Documentation

static struct berval = BER_BVC("(objectClass=nisNetgroup)") [static]

Definition at line 33 of file netgroup.c.