Back to index

openldap  2.4.31
Defines | Functions
nslcd-prot.h File Reference
#include "tio.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define DEBUG_PRINT(fmt, arg)
#define DEBUG_DUMP(ptr, size)
#define WRITE(fp, ptr, size)
#define WRITE_TYPE(fp, field, type)   WRITE(fp,&(field),sizeof(type))
#define WRITE_INT32(fp, i)
#define WRITE_STRING(fp, str)
#define WRITE_STRINGLIST(fp, arr)
#define WRITE_STRINGLIST_EXCEPT(fp, arr, not)
#define READ(fp, ptr, size)
#define READ_TYPE(fp, field, type)   READ(fp,&(field),sizeof(type))
#define READ_INT32(fp, i)
#define READ_STRING(fp, buffer)
#define BUF_CUR   (buffer+bufptr)
#define BUF_CHECK(fp, sz)
#define BUF_SKIP(sz)   bufptr+=(size_t)(sz);
#define BUF_ALIGN(fp, type)
#define BUF_ALLOC(fp, ptr, type, num)
#define READ_BUF(fp, ptr, sz)
#define READ_BUF_STRING(fp, field)
#define READ_BUF_STRINGLIST(fp, arr)
#define SKIP(fp, sz)
#define SKIP_STRING(fp)
#define SKIP_STRINGLIST(fp)
#define NSLCD_REQUEST(fp, action, writefn)
#define READ_RESPONSE_CODE(fp)

Functions

TFILE * nslcd_client_open (void) MUST_USE

Define Documentation

#define BUF_ALIGN (   fp,
  type 
)
Value:
/* figure out number of bytes to skip foreward */ \
  tmp2int32=(sizeof(type)-((BUF_CUR-(char *)NULL)%sizeof(type)))%sizeof(type); \
  /* check and skip */ \
  BUF_CHECK(fp,tmp2int32); \
  BUF_SKIP(tmp2int32);

Definition at line 222 of file nslcd-prot.h.

#define BUF_ALLOC (   fp,
  ptr,
  type,
  num 
)
Value:
/* align to the specified type width */ \
  BUF_ALIGN(fp,type); \
  /* check that we have enough room */ \
  BUF_CHECK(fp,(size_t)(num)*sizeof(type)); \
  /* store the pointer */ \
  (ptr)=(type *)BUF_CUR; \
  /* reserve the space */ \
  BUF_SKIP((size_t)(num)*sizeof(type));

Definition at line 230 of file nslcd-prot.h.

#define BUF_CHECK (   fp,
  sz 
)
Value:
if ((bufptr+(size_t)(sz))>buflen) \
  { \
    /* will not fit */ \
    DEBUG_PRINT("READ       : buffer error: %d bytes too small",(bufptr+(sz)-(buflen))); \
    ERROR_OUT_BUFERROR(fp); \
  }

Definition at line 208 of file nslcd-prot.h.

#define BUF_CUR   (buffer+bufptr)

Definition at line 204 of file nslcd-prot.h.

#define BUF_SKIP (   sz)    bufptr+=(size_t)(sz);

Definition at line 217 of file nslcd-prot.h.

#define DEBUG_DUMP (   ptr,
  size 
)

Definition at line 69 of file nslcd-prot.h.

#define DEBUG_PRINT (   fmt,
  arg 
)

Definition at line 49 of file nslcd-prot.h.

#define NSLCD_REQUEST (   fp,
  action,
  writefn 
)
Value:
/* open a client socket */ \
  if ((fp=nslcd_client_open())==NULL) \
    { ERROR_OUT_OPENERROR } \
  /* write a request header with a request code */ \
  WRITE_INT32(fp,(int32_t)NSLCD_VERSION) \
  WRITE_INT32(fp,(int32_t)action) \
  /* write the request parameters (if any) */ \
  writefn; \
  /* flush the stream */ \
  if (tio_flush(fp)<0) \
  { \
    DEBUG_PRINT("WRITE_FLUSH : error: %s",strerror(errno)); \
    ERROR_OUT_WRITEERROR(fp); \
  } \
  /* read and check response version number */ \
  READ_TYPE(fp,tmpint32,int32_t); \
  if (tmpint32!=(int32_t)NSLCD_VERSION) \
    { ERROR_OUT_READERROR(fp) } \
  /* read and check response request number */ \
  READ_TYPE(fp,tmpint32,int32_t); \
  if (tmpint32!=(int32_t)(action)) \
    { ERROR_OUT_READERROR(fp) }

Definition at line 325 of file nslcd-prot.h.

#define READ (   fp,
  ptr,
  size 
)
Value:
if (tio_read(fp,ptr,(size_t)size)) \
  { \
    DEBUG_PRINT("READ       : var="__STRING(ptr)" error: %s",strerror(errno)); \
    ERROR_OUT_READERROR(fp); \
  } \
  DEBUG_PRINT("READ       : var="__STRING(ptr)" size=%d",(int)size); \
  DEBUG_DUMP(ptr,size);

Definition at line 157 of file nslcd-prot.h.

#define READ_BUF (   fp,
  ptr,
  sz 
)
Value:
/* check that there is enough room and read */ \
  BUF_CHECK(fp,sz); \
  READ(fp,BUF_CUR,(size_t)sz); \
  /* store pointer and skip */ \
  (ptr)=BUF_CUR; \
  BUF_SKIP(sz);

Definition at line 241 of file nslcd-prot.h.

#define READ_BUF_STRING (   fp,
  field 
)
Value:
/* read the size of the string */ \
  READ_TYPE(fp,tmpint32,int32_t); \
  DEBUG_PRINT("READ_BUF_STRING: var="__STRING(field)" strlen=%d",tmpint32); \
  /* check if read would fit */ \
  BUF_CHECK(fp,tmpint32+1); \
  /* read string from the stream */ \
  if (tmpint32>0) \
    { READ(fp,BUF_CUR,(size_t)tmpint32); } \
  /* null-terminate string in buffer */ \
  BUF_CUR[tmpint32]='\0'; \
  DEBUG_PRINT("READ_BUF_STRING: var="__STRING(field)" string=\"%s\"",BUF_CUR); \
  /* prepare result */ \
  (field)=BUF_CUR; \
  BUF_SKIP(tmpint32+1);

Definition at line 251 of file nslcd-prot.h.

#define READ_BUF_STRINGLIST (   fp,
  arr 
)
Value:
/* read the number of entries */ \
  READ_TYPE(fp,tmp3int32,int32_t); \
  DEBUG_PRINT("READ_STRLST: var="__STRING(arr)" num=%d",(int)tmp3int32); \
  /* allocate room for *char[num+1] */ \
  BUF_ALLOC(fp,arr,char *,tmp3int32+1); \
  /* read all entries */ \
  for (tmp2int32=0;tmp2int32<tmp3int32;tmp2int32++) \
  { \
    READ_BUF_STRING(fp,(arr)[tmp2int32]); \
  } \
  /* set last entry to NULL */ \
  (arr)[tmp2int32]=NULL;

Definition at line 269 of file nslcd-prot.h.

#define READ_INT32 (   fp,
 
)
Value:
READ_TYPE(fp,tmpint32,int32_t); \
  i=tmpint32; \
  DEBUG_PRINT("READ_INT32 : var="__STRING(i)" int32=%d",(int)i);

Definition at line 169 of file nslcd-prot.h.

#define READ_RESPONSE_CODE (   fp)
Value:
READ_TYPE(fp,tmpint32,int32_t); \
  if (tmpint32!=(int32_t)NSLCD_RESULT_BEGIN) \
    { ERROR_OUT_NOSUCCESS(fp) }

Definition at line 351 of file nslcd-prot.h.

#define READ_STRING (   fp,
  buffer 
)
Value:
/* read the size of the string */ \
  READ_TYPE(fp,tmpint32,int32_t); \
  DEBUG_PRINT("READ_STRING: var="__STRING(buffer)" strlen=%d",tmpint32); \
  /* check if read would fit */ \
  if (((size_t)tmpint32)>=sizeof(buffer)) \
  { \
    /* will not fit */ \
    DEBUG_PRINT("READ       : buffer error: %d bytes too large",(tmpint32-sizeof(buffer))+1); \
    ERROR_OUT_BUFERROR(fp); \
  } \
  /* read string from the stream */ \
  if (tmpint32>0) \
    { READ(fp,buffer,(size_t)tmpint32); } \
  /* null-terminate string in buffer */ \
  buffer[tmpint32]='\0'; \
  DEBUG_PRINT("READ_STRING: var="__STRING(buffer)" string=\"%s\"",buffer);

Definition at line 175 of file nslcd-prot.h.

#define READ_TYPE (   fp,
  field,
  type 
)    READ(fp,&(field),sizeof(type))

Definition at line 166 of file nslcd-prot.h.

#define SKIP (   fp,
  sz 
)
Value:
DEBUG_PRINT("READ       : skip %d bytes",(int)(sz)); \
  /* read (skip) the specified number of bytes */ \
  if (tio_skip(fp,sz)) \
  { \
    DEBUG_PRINT("READ       : skip error: %s",strerror(errno)); \
    ERROR_OUT_READERROR(fp); \
  }

Definition at line 287 of file nslcd-prot.h.

#define SKIP_STRING (   fp)
Value:
/* read the size of the string */ \
  READ_TYPE(fp,tmpint32,int32_t); \
  DEBUG_PRINT("READ_STRING: skip %d bytes",(int)tmpint32); \
  /* read (skip) the specified number of bytes */ \
  SKIP(fp,tmpint32);

Definition at line 297 of file nslcd-prot.h.

#define SKIP_STRINGLIST (   fp)
Value:
/* read the number of entries */ \
  READ_TYPE(fp,tmp3int32,int32_t); \
  DEBUG_PRINT("READ_STRLST: skip %d strings",(int)tmp3int32); \
  /* read all entries */ \
  for (tmp2int32=0;tmp2int32<tmp3int32;tmp2int32++) \
  { \
    SKIP_STRING(fp); \
  }

Definition at line 305 of file nslcd-prot.h.

#define WRITE (   fp,
  ptr,
  size 
)
Value:
DEBUG_PRINT("WRITE       : var="__STRING(ptr)" size=%d",(int)size); \
  DEBUG_DUMP(ptr,size); \
  if (tio_write(fp,ptr,(size_t)size)) \
  { \
    DEBUG_PRINT("WRITE       : var="__STRING(ptr)" error: %s",strerror(errno)); \
    ERROR_OUT_WRITEERROR(fp); \
  }

Definition at line 80 of file nslcd-prot.h.

#define WRITE_INT32 (   fp,
 
)
Value:
DEBUG_PRINT("WRITE_INT32 : var="__STRING(i)" int32=%d",(int)i); \
  tmpint32=(int32_t)(i); \
  WRITE_TYPE(fp,tmpint32,int32_t)

Definition at line 92 of file nslcd-prot.h.

#define WRITE_STRING (   fp,
  str 
)
Value:
DEBUG_PRINT("WRITE_STRING: var="__STRING(str)" string=\"%s\"",(str)); \
  if ((str)==NULL) \
  { \
    WRITE_INT32(fp,0); \
  } \
  else \
  { \
    WRITE_INT32(fp,strlen(str)); \
    if (tmpint32>0) \
      { WRITE(fp,(str),tmpint32); } \
  }

Definition at line 97 of file nslcd-prot.h.

#define WRITE_STRINGLIST (   fp,
  arr 
)
Value:
if ((arr)==NULL) \
  { \
    DEBUG_PRINT("WRITE_STRLST: var="__STRING(arr)" num=%d",0); \
    WRITE_INT32(fp,0); \
  } \
  else \
  { \
    /* first determin length of array */ \
    for (tmp3int32=0;(arr)[tmp3int32]!=NULL;tmp3int32++) \
      /*noting*/ ; \
    /* write number of strings */ \
    DEBUG_PRINT("WRITE_STRLST: var="__STRING(arr)" num=%d",(int)tmp3int32); \
    WRITE_TYPE(fp,tmp3int32,int32_t); \
    /* write strings */ \
    for (tmp2int32=0;tmp2int32<tmp3int32;tmp2int32++) \
    { \
      WRITE_STRING(fp,(arr)[tmp2int32]); \
    } \
  }

Definition at line 110 of file nslcd-prot.h.

#define WRITE_STRINGLIST_EXCEPT (   fp,
  arr,
  not 
)
Value:
/* first determin length of array */ \
  tmp3int32=0; \
  for (tmp2int32=0;(arr)[tmp2int32]!=NULL;tmp2int32++) \
    if (strcmp((arr)[tmp2int32],(not))!=0) \
      tmp3int32++; \
  /* write number of strings (mius one because we intend to skip one) */ \
  DEBUG_PRINT("WRITE_STRLST: var="__STRING(arr)" num=%d",(int)tmp3int32); \
  WRITE_TYPE(fp,tmp3int32,int32_t); \
  /* write strings */ \
  for (tmp2int32=0;(arr)[tmp2int32]!=NULL;tmp2int32++) \
  { \
    if (strcmp((arr)[tmp2int32],(not))!=0) \
    { \
      WRITE_STRING(fp,(arr)[tmp2int32]); \
    } \
  }

Definition at line 131 of file nslcd-prot.h.

#define WRITE_TYPE (   fp,
  field,
  type 
)    WRITE(fp,&(field),sizeof(type))

Definition at line 89 of file nslcd-prot.h.


Function Documentation

TFILE* nslcd_client_open ( void  )