Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions | Variables
lber-int.h File Reference
#include <stdio.h>
#include <ctype.h>
#include <stdarg.h>
#include <stdlib.h>
#include <malloc.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <unistd.h>
#include <memory.h>
#include <string.h>
#include "portable.h"
#include "lber.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  seqorset
struct  berelement
struct  nslberi_io_fns
struct  lber_x_ext_io_fns_rev0
struct  sockbuf

Defines

#define OLD_LBER_SEQUENCE   0x10L /* w/o constructed bit - broken */
#define OLD_LBER_SET   0x11L /* w/o constructed bit - broken */
#define _IFP
#define NULLSEQORSET   ((Seqorset *) 0)
#define SOS_STACK_SIZE   8 /* depth of the pre-allocated sos structure stack */
#define MAX_TAG_SIZE   (1 + sizeof(long)) /* One byte for the length of the tag */
#define MAX_LEN_SIZE   (1 + sizeof(long)) /* One byte for the length of the length */
#define MAX_VALUE_PREFIX_SIZE   (2 + sizeof(long)) /* 1 byte for the tag and 1 for the len (msgid) */
#define BER_ARRAY_QUANTITY   7 /* 0:Tag 1:Length 2:Value-prefix 3:Value 4:Value-suffix */
#define BER_STRUCT_TAG   0 /* 5:ControlA 6:ControlB */
#define BER_STRUCT_LEN   1
#define BER_STRUCT_PRE   2
#define BER_STRUCT_VAL   3
#define BER_STRUCT_SUF   4
#define BER_STRUCT_CO1   5
#define BER_STRUCT_CO2   6
#define LBER_FLAG_NO_FREE_BUFFER   1 /* don't free ber_buf */
#define BER_CONTENTS_STRUCT_SIZE   (sizeof(ldap_x_iovec) * BER_ARRAY_QUANTITY)
#define NULLBER   ((BerElement *)NULL)
#define LBER_X_EXTIO_FNS_SIZE_REV0   sizeof(struct lber_x_ext_io_fns_rev0)
#define NULLSOCKBUF   ((Sockbuf *)NULL)
#define READBUFSIZ   8192
#define NSLBERI_VALID_BERELEMENT_POINTER(ber)   ( (ber) != NULLBER )
#define NSLBERI_VALID_SOCKBUF_POINTER(sb)   ( (sb) != NULLSOCKBUF )
#define LBER_HTONL(l)   htonl( l )
#define LBER_NTOHL(l)   ntohl( l )
#define THEMEMCPY(d, s, n)   memmove( d, s, n )
#define NSLBERI_MALLOC(size)   nslberi_malloc( size )
#define NSLBERI_CALLOC(nelem, elsize)   nslberi_calloc( nelem, elsize )
#define NSLBERI_REALLOC(ptr, size)   nslberi_realloc( ptr, size )
#define NSLBERI_FREE(ptr)   nslberi_free( ptr )

Typedefs

typedef struct seqorset Seqorset

Functions

typedef int (LDAP_C LDAP_CALLBACK *IFP)()
void ber_err_print (char *data)
voidnslberi_malloc (size_t size)
voidnslberi_calloc (size_t nelem, size_t elsize)
voidnslberi_realloc (void *ptr, size_t size)
void nslberi_free (void *ptr)
int nslberi_ber_realloc (BerElement *ber, unsigned long len)

Variables

int lber_debug

Class Documentation

struct seqorset

Definition at line 124 of file lber-int.h.

Collaboration diagram for seqorset:
Class Members
unsigned long sos_clen
char * sos_first
struct seqorset * sos_next
char * sos_ptr
unsigned long sos_tag
struct berelement

Definition at line 148 of file lber-int.h.

Collaboration diagram for berelement:
Class Members
char * ber_buf
BERTranslateProc ber_decode_translate_proc
BERTranslateProc ber_encode_translate_proc
char * ber_end
int ber_flags
unsigned long ber_len
char ber_len_contents
char ber_options
char ber_pre_contents
char * ber_ptr
char * ber_rwptr
struct seqorset * ber_sos
Seqorset ber_sos_stack
int ber_sos_stack_posn
ldap_x_iovec ber_struct
char ber_suf_contents
unsigned long ber_tag
char ber_tag_contents
int ber_usertag
struct nslberi_io_fns

Definition at line 186 of file lber-int.h.

Class Members
LDAP_IOF_READ_CALLBACK * lbiof_read
LDAP_IOF_WRITE_CALLBACK * lbiof_write
struct lber_x_ext_io_fns_rev0

Definition at line 195 of file lber-int.h.

Collaboration diagram for lber_x_ext_io_fns_rev0:
Class Members
LDAP_X_EXTIOF_READ_CALLBACK * lbextiofn_read
int lbextiofn_size
struct lextiof_socket_private * lbextiofn_socket_arg
LDAP_X_EXTIOF_WRITE_CALLBACK * lbextiofn_write
struct sockbuf

Definition at line 206 of file lber-int.h.

Collaboration diagram for sockbuf:
Class Members
void ** sb_addrs
BerElement sb_ber
LBER_SOCKET sb_copyfd
void * sb_fromaddr
unsigned long sb_max_incoming
int sb_naddr
int sb_options
LBER_SOCKET sb_sd
void * sb_useaddr
unsigned long sb_valid_tag

Define Documentation

Definition at line 120 of file lber-int.h.

#define BER_ARRAY_QUANTITY   7 /* 0:Tag 1:Length 2:Value-prefix 3:Value 4:Value-suffix */

Definition at line 139 of file lber-int.h.

Definition at line 173 of file lber-int.h.

Definition at line 145 of file lber-int.h.

Definition at line 146 of file lber-int.h.

Definition at line 141 of file lber-int.h.

Definition at line 142 of file lber-int.h.

Definition at line 144 of file lber-int.h.

#define BER_STRUCT_TAG   0 /* 5:ControlA 6:ControlB */

Definition at line 140 of file lber-int.h.

Definition at line 143 of file lber-int.h.

#define LBER_FLAG_NO_FREE_BUFFER   1 /* don't free ber_buf */

Definition at line 168 of file lber-int.h.

#define LBER_HTONL (   l)    htonl( l )

Definition at line 256 of file lber-int.h.

#define LBER_NTOHL (   l)    ntohl( l )

Definition at line 257 of file lber-int.h.

Definition at line 202 of file lber-int.h.

#define MAX_LEN_SIZE   (1 + sizeof(long)) /* One byte for the length of the length */

Definition at line 137 of file lber-int.h.

#define MAX_TAG_SIZE   (1 + sizeof(long)) /* One byte for the length of the tag */

Definition at line 136 of file lber-int.h.

#define MAX_VALUE_PREFIX_SIZE   (2 + sizeof(long)) /* 1 byte for the tag and 1 for the len (msgid) */

Definition at line 138 of file lber-int.h.

#define NSLBERI_CALLOC (   nelem,
  elsize 
)    nslberi_calloc( nelem, elsize )

Definition at line 308 of file lber-int.h.

Definition at line 310 of file lber-int.h.

Definition at line 307 of file lber-int.h.

Definition at line 309 of file lber-int.h.

Definition at line 241 of file lber-int.h.

Definition at line 244 of file lber-int.h.

#define NULLBER   ((BerElement *)NULL)

Definition at line 175 of file lber-int.h.

#define NULLSEQORSET   ((Seqorset *) 0)

Definition at line 131 of file lber-int.h.

#define NULLSOCKBUF   ((Sockbuf *)NULL)

Definition at line 225 of file lber-int.h.

#define OLD_LBER_SEQUENCE   0x10L /* w/o constructed bit - broken */

Definition at line 116 of file lber-int.h.

#define OLD_LBER_SET   0x11L /* w/o constructed bit - broken */

Definition at line 117 of file lber-int.h.

#define READBUFSIZ   8192

Definition at line 236 of file lber-int.h.

#define SOS_STACK_SIZE   8 /* depth of the pre-allocated sos structure stack */

Definition at line 133 of file lber-int.h.

#define THEMEMCPY (   d,
  s,
  n 
)    memmove( d, s, n )

Definition at line 294 of file lber-int.h.


Typedef Documentation

typedef struct seqorset Seqorset

Function Documentation

void ber_err_print ( char *  data)

Definition at line 94 of file bprint.c.

{
#ifdef USE_DEBUG_WIN
       OutputDebugString( data );
#else
       fputs( data, stderr );
       fflush( stderr );
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

typedef int ( LDAP_C LDAP_CALLBACK IFP)
int nslberi_ber_realloc ( BerElement *  ber,
unsigned long  len 
)

Definition at line 227 of file io.c.

{
       unsigned long need, have, total;
       size_t        have_bytes;
       Seqorset      *s;
       long          off;
       char          *oldbuf;

       have_bytes = ber->ber_end - ber->ber_buf;
       have = have_bytes / EXBUFSIZ;
       need = (len < EXBUFSIZ ? 1 : (len + (EXBUFSIZ - 1)) / EXBUFSIZ);
       total = have * EXBUFSIZ + need * EXBUFSIZ;

       oldbuf = ber->ber_buf;

       if (ber->ber_buf == NULL) {
              if ( (ber->ber_buf = (char *)NSLBERI_MALLOC( (size_t)total ))
                  == NULL ) {
                     return( -1 );
              }
              ber->ber_flags &= ~LBER_FLAG_NO_FREE_BUFFER;
       } else {
              if ( ber->ber_flags & LBER_FLAG_NO_FREE_BUFFER ) {
                     /* transition to malloc'd buffer */
                     if ( (ber->ber_buf = (char *)NSLBERI_MALLOC(
                         (size_t)total )) == NULL ) {
                            return( -1 );
                     }
                     ber->ber_flags &= ~LBER_FLAG_NO_FREE_BUFFER;
                     /* copy existing data into new malloc'd buffer */
                     SAFEMEMCPY( ber->ber_buf, oldbuf, have_bytes );
              } else {
                     if ( (ber->ber_buf = (char *)NSLBERI_REALLOC(
                         ber->ber_buf,(size_t)total )) == NULL ) {
                            return( -1 );
                     }
              }
       }

       ber->ber_end = ber->ber_buf + total;

       /*
        * If the stinking thing was moved, we need to go through and
        * reset all the sos and ber pointers.  Offsets would've been
        * a better idea... oh well.
        */

       if ( ber->ber_buf != oldbuf ) {    
              ber->ber_ptr = ber->ber_buf + (ber->ber_ptr - oldbuf);

              for ( s = ber->ber_sos; s != NULLSEQORSET; s = s->sos_next ) {
                     off = s->sos_first - oldbuf;
                     s->sos_first = ber->ber_buf + off;

                     off = s->sos_ptr - oldbuf;
                     s->sos_ptr = ber->ber_buf + off;
              }
       }

       return( 0 );
}

Here is the caller graph for this function:

void* nslberi_calloc ( size_t  nelem,
size_t  elsize 
)

Definition at line 1403 of file io.c.

{
       return( nslberi_memalloc_fns.lbermem_calloc == NULL ?
           calloc(  nelem, elsize ) :
           nslberi_memalloc_fns.lbermem_calloc( nelem, elsize ));
}

Here is the call graph for this function:

void nslberi_free ( void ptr)

Definition at line 1421 of file io.c.

{
       if ( nslberi_memalloc_fns.lbermem_free == NULL ) {
              free( ptr );
       } else {
              nslberi_memalloc_fns.lbermem_free( ptr );
       }
}
void* nslberi_malloc ( size_t  size)

Definition at line 1394 of file io.c.

{
       return( nslberi_memalloc_fns.lbermem_malloc == NULL ?
           malloc( size ) :
           nslberi_memalloc_fns.lbermem_malloc( size ));
}
void* nslberi_realloc ( void ptr,
size_t  size 
)

Definition at line 1412 of file io.c.

{
       return( nslberi_memalloc_fns.lbermem_realloc == NULL ?
           realloc( ptr, size ) :
           nslberi_memalloc_fns.lbermem_realloc( ptr, size ));
}

Here is the call graph for this function:


Variable Documentation