openldap/libraries/liblber/lber-int.h
Kurt Zeilenga dc07e765f2 Vienna Bulk Commit
This commit includes many changes.  All changes compile under NT but
have not been tested under UNIX.

A Summary of changes (likely incomplete):

NT changes:
	Removed lint.
	Clean up configuration support for "Debug", "Release", "SDebug",
		and "SRelease" configurations.
	Share output directories for clients, libraries,
		and slapd.  (maybe they should be combined further
		and moved to build/{,S}{Debug,Release}).
	Enable threading when _MT is defined.
	Enable debuging when _DEBUG is defined.
	Disable setting of NDEBUG under Release/SRelease.  Asserts
		are disabled in <ac/assert.h> when LDAP_DEBUG is not
		defined.
	Added 'build/main.dsp' Master project.
	Removed non-slapd projects from slapd.dsp (see main.dsp).
	Removed replaced many uses of _WIN32 macro with feature based
		macros.

ldap_cdefs.h changes
	#define LDAP_CONST const
		(see below)
	#define LDAP_F(type) LDAP_F_PRE type LDAP_F_POST
		To allow specifiers to be added before and after
		the type declaration.  (For DLL handling)

LBER/LDAP changes
	Namespace changes:
		s/lber_/ber_/ for here and there.
		s/NAME_ERROR/LDAP_NAME_ERROR/g
	Deleted NULLMSG and other NULL* macros for namespace reasons.
	"const" libraries.  Installed headers (ie: lber.h, ldap.h)
		use LDAP_CONST macro.  Normally set to 'const' when
		__STDC__.  Can be set externally to enable/disable
		'constification' of external interface.  Internal
		interface always uses 'const'.  Did not fix warnings
		in -lldif (in lieu of new LDIF parser).

	Added _ext API implementations (excepting search and bind).
		Need to implement ldap_int_get_controls() for reponses
		with controls.

	Added numberous assert() checks.

LDAP_R
	_MT defines HAVE_NT_THREADS
	Added numberous assert() checks.
	Changed ldap_pthread_t back to unsigned long.  Used cast
	to HANDLE in _join().

LDBM
	Replaced _WIN32 with HAVE_SYSLOG

ud
	Added version string if MKVERSION is not defined.  (MKVERSION
		needs to be set under UNIX).

slapd
	Made connection sockbuf field a pointer to a sockbuf.  This
		removed slap.h dependency on lber-int.h.  lber-int.h now only
		included by those files needing to mess with the sockbuf.
	Used ber_* functions/macros to access sockbuf internals whenever
		possible.
	Added version string if MKVERSION is not defined.  (MKVERSION
		needs to be set under UNIX).
	Removed FD_SET unsigned lint

slapd/tools
	Used EXEEXT to added ".exe" to routines.  Need to define EXEEXT
		under UNIX.

ldappasswd
	Added ldappasswd.dsp.  Ported to NT.  Used getpid() to seed rand().

nt_debug
	Minor cleanup.  Added "portable.h" include and used <ac/*.h> where
	appropriate.  Added const to char* format argument.
1999-05-19 01:12:33 +00:00

224 lines
4.9 KiB
C

/*
* Copyright 1998 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
*/
/* Portions
* Copyright (c) 1990 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*/
#ifndef _LBER_INT_H
#define _LBER_INT_H
#include "lber.h"
#include "ldap_log.h"
#include "lber_pvt.h"
LDAP_BEGIN_DECL
extern int ber_int_debug;
#define ber_log_printf ber_pvt_log_printf
struct lber_options {
short lbo_item_type;
#define LBER_ITEM_BERELEMENT 1
#define LBER_ITEM_SOCKBUF 2
short lbo_options;
int lbo_debug;
};
struct berelement {
struct lber_options ber_opts;
#define ber_item_type ber_opts.lbo_item_type
#define ber_options ber_opts.lbo_options
#define ber_debug ber_opts.lbo_debug
int ber_usertag;
unsigned long ber_tag;
unsigned long ber_len;
char *ber_buf;
char *ber_ptr;
char *ber_end;
struct seqorset *ber_sos;
char *ber_rwptr;
BERTranslateProc ber_encode_translate_proc;
BERTranslateProc ber_decode_translate_proc;
};
#define NULLBER ((BerElement *) 0)
struct sockbuf;
struct sockbuf_io {
int (*sbi_setup)( struct sockbuf * sb, void *arg );
int (*sbi_remove)( struct sockbuf *sb );
long (*sbi_read)( struct sockbuf *sb, void *buf, long len );
long (*sbi_write)( struct sockbuf *sb, void *buf, long len );
int (*sbi_close)( struct sockbuf *sb );
};
struct sockbuf_sec {
int (*sbs_setup)( struct sockbuf * sb, void *arg );
int (*sbs_remove)( struct sockbuf *sb );
long (*sbs_protect)( struct sockbuf *sb, char *in, long *ilen,
char *out, long olen );
long (*sbs_release)( struct sockbuf *sb, char *in, long ilen,
char *out0, long olen0, char *out1, long olen1 );
};
struct sockbuf_buf {
long buf_size;
long buf_ptr;
long buf_end;
char *buf_base;
};
typedef struct sockbuf_io Sockbuf_IO;
typedef struct sockbuf_sec Sockbuf_Sec;
typedef struct sockbuf_buf Sockbuf_Buf;
#define ber_pvt_sb_get_desc( sb ) ((sb)->sb_sd)
#define ber_pvt_sb_set_desc( sb, val ) ((sb)->sb_sd =(val))
#define ber_pvt_sb_in_use( sb ) ((sb)->sb_sd!=-1)
#ifdef USE_SASL
#define ber_pvt_sb_data_ready( sb ) \
(((sb)->sb_buf_ready) || ((sb)->sb_trans_ready) || ((sb)->sb_sec_ready))
#else
#define ber_pvt_sb_data_ready( sb ) \
(((sb)->sb_buf_ready) || ((sb)->sb_trans_ready))
#endif
struct sockbuf {
struct lber_options sb_opts;
#define sb_item_type sb_opts.lbo_item_type
#define sb_options sb_opts.lbo_options
#define sb_debug sb_opts.lbo_debug
int sb_non_block:1;
int sb_read_ahead:1;
int sb_buf_ready:1;
int sb_trans_ready:1;
int sb_sec_ready:1;
int sb_fd;
void *sb_iodata; /* transport-layer data pointer */
Sockbuf_IO *sb_io; /* I/O functions */
#ifdef LDAP_SASL
void *sb_sdata; /* security-layer data pointer */
Sockbuf_Sec *sb_sec;
#endif
#ifndef MACOS
int sb_sd;
#else /* MACOS */
void *sb_sd;
#endif /* MACOS */
#ifdef DEADWOOD
long sb_max_incoming;
#endif
Sockbuf_Buf sb_buf;
#ifdef LDAP_SASL
Sockbuf_Buf sb_sec_buf_in;
Sockbuf_Buf sb_sec_buf_out;
long sb_sec_prev_len;
#endif
};
#define READBUFSIZ 8192
struct seqorset {
BerElement *sos_ber;
unsigned long sos_clen;
unsigned long sos_tag;
char *sos_first;
char *sos_ptr;
struct seqorset *sos_next;
};
#define NULLSEQORSET ((Seqorset *) 0)
/*
* bprint.c
*/
LDAP_F( int )
ber_log_bprint LDAP_P((
int errlvl,
int loglvl,
const char *data,
int len ));
LDAP_F( int )
ber_log_dump LDAP_P((
int errlvl,
int loglvl,
const BerElement *ber,
int inout ));
LDAP_F( int )
ber_log_sos_dump LDAP_P((
int errlvl,
int loglvl,
const Seqorset *sos ));
/* sockbuf.c */
LDAP_F( int )
ber_pvt_sb_init LDAP_P(( Sockbuf *sb ));
LDAP_F( int )
ber_pvt_sb_destroy LDAP_P(( Sockbuf *sb ));
#ifdef USE_SASL
LDAP_F( int )
ber_pvt_sb_set_sec LDAP_P(( Sockbuf *sb, Sockbuf_Sec *sec, void *arg ));
LDAP_F( int )
ber_pvt_sb_clear_sec LDAP_P(( Sockbuf *sb ));
#endif
LDAP_F( int )
ber_pvt_sb_set_io LDAP_P(( Sockbuf *sb, Sockbuf_IO *layer, void *arg ));
LDAP_F( int )
ber_pvt_sb_clear_io LDAP_P(( Sockbuf *sb ));
LDAP_F( int )
ber_pvt_sb_close LDAP_P((Sockbuf *sb ));
LDAP_F( int )
ber_pvt_sb_set_nonblock LDAP_P(( Sockbuf *sb, int nb ));
LDAP_F( int )
ber_pvt_sb_set_readahead LDAP_P(( Sockbuf *sb, int rh ));
LDAP_F( long )
ber_pvt_sb_read LDAP_P(( Sockbuf *sb, void *buf, long len ));
LDAP_F( long )
ber_pvt_sb_write LDAP_P(( Sockbuf *sb, void *buf, long len ));
LDAP_F( int )
ber_pvt_sb_udp_set_dst LDAP_P((Sockbuf *sb, void *addr ));
LDAP_F( void * )
ber_pvt_sb_udp_get_src LDAP_P((Sockbuf *sb ));
extern Sockbuf_IO ber_pvt_sb_io_tcp;
extern Sockbuf_IO ber_pvt_sb_io_udp;
#endif /* _LBER_INT_H */