1999-09-09 03:06:24 +08:00
|
|
|
/* $OpenLDAP$ */
|
1998-12-29 04:38:04 +08:00
|
|
|
/*
|
2000-05-13 10:36:07 +08:00
|
|
|
* Copyright 1998-2000 The OpenLDAP Foundation, All Rights Reserved.
|
1998-12-29 04:38:04 +08:00
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
*/
|
1998-12-29 04:46:13 +08:00
|
|
|
/* Portions
|
1998-10-26 09:18:41 +08:00
|
|
|
* 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"
|
1998-12-22 09:34:01 +08:00
|
|
|
#include "ldap_log.h"
|
1999-01-26 09:21:35 +08:00
|
|
|
#include "lber_pvt.h"
|
2002-01-03 08:49:52 +08:00
|
|
|
#include "ldap_queue.h"
|
1998-10-26 09:18:41 +08:00
|
|
|
|
|
|
|
LDAP_BEGIN_DECL
|
|
|
|
|
2001-12-20 05:22:04 +08:00
|
|
|
typedef void (*BER_LOG_FN)(FILE *file,
|
2001-12-20 05:46:34 +08:00
|
|
|
const char *subsys, int level, const char *fmt, ... );
|
2001-12-20 05:22:04 +08:00
|
|
|
|
2001-12-07 12:03:25 +08:00
|
|
|
LBER_V (BER_ERRNO_FN) ber_int_errno_fn;
|
1999-11-08 23:38:59 +08:00
|
|
|
|
1999-03-06 10:36:21 +08:00
|
|
|
struct lber_options {
|
1999-05-29 03:33:05 +08:00
|
|
|
short lbo_valid;
|
2000-06-02 04:59:21 +08:00
|
|
|
unsigned short lbo_options;
|
|
|
|
int lbo_debug;
|
2000-07-05 02:47:06 +08:00
|
|
|
long lbo_meminuse;
|
2000-06-02 04:59:21 +08:00
|
|
|
};
|
|
|
|
|
2000-10-26 00:47:17 +08:00
|
|
|
#ifdef NEW_LOGGING
|
|
|
|
# ifdef LDAP_DEBUG
|
|
|
|
# ifdef LDAP_LOG
|
|
|
|
# undef LDAP_LOG
|
|
|
|
# endif
|
|
|
|
# define LDAP_LOG(a) ber_pvt_log_output a
|
|
|
|
# define BER_DUMP(a) ber_output_dump a
|
|
|
|
# else
|
|
|
|
# define LDAP_LOG(a)
|
|
|
|
# define BER_DUMP(a)
|
|
|
|
# endif
|
2000-10-13 05:02:58 +08:00
|
|
|
#endif
|
2000-10-13 04:01:12 +08:00
|
|
|
|
2001-12-20 05:22:04 +08:00
|
|
|
LBER_F( int ) ber_pvt_log_output(
|
|
|
|
const char *subsystem,
|
|
|
|
int level,
|
|
|
|
const char *fmt, ... );
|
|
|
|
|
1999-05-29 03:33:05 +08:00
|
|
|
#define LBER_UNINITIALIZED 0x0
|
|
|
|
#define LBER_INITIALIZED 0x1
|
|
|
|
#define LBER_VALID_BERELEMENT 0x2
|
|
|
|
#define LBER_VALID_SOCKBUF 0x3
|
|
|
|
|
2001-12-07 12:03:25 +08:00
|
|
|
LBER_V (struct lber_options) ber_int_options;
|
1999-05-29 03:33:05 +08:00
|
|
|
#define ber_int_debug ber_int_options.lbo_debug
|
|
|
|
|
1998-10-26 09:49:56 +08:00
|
|
|
struct berelement {
|
1999-03-06 10:36:21 +08:00
|
|
|
struct lber_options ber_opts;
|
1999-05-29 03:33:05 +08:00
|
|
|
#define ber_valid ber_opts.lbo_valid
|
1999-03-06 10:36:21 +08:00
|
|
|
#define ber_options ber_opts.lbo_options
|
|
|
|
#define ber_debug ber_opts.lbo_debug
|
1998-12-22 09:34:01 +08:00
|
|
|
|
1999-06-19 07:53:05 +08:00
|
|
|
ber_tag_t ber_usertag;
|
1998-12-22 09:34:01 +08:00
|
|
|
|
1999-06-19 07:53:05 +08:00
|
|
|
ber_tag_t ber_tag;
|
|
|
|
ber_len_t ber_len;
|
1998-12-22 09:34:01 +08:00
|
|
|
|
1998-10-26 09:18:41 +08:00
|
|
|
char *ber_buf;
|
|
|
|
char *ber_ptr;
|
|
|
|
char *ber_end;
|
1998-12-22 09:34:01 +08:00
|
|
|
|
1998-10-26 09:18:41 +08:00
|
|
|
struct seqorset *ber_sos;
|
|
|
|
char *ber_rwptr;
|
1998-10-26 09:49:56 +08:00
|
|
|
};
|
2001-07-22 07:13:04 +08:00
|
|
|
#define LBER_VALID(ber) ((ber)->ber_valid==LBER_VALID_BERELEMENT)
|
1999-06-19 07:53:05 +08:00
|
|
|
|
1999-05-29 03:33:05 +08:00
|
|
|
#define ber_pvt_ber_remaining(ber) ((ber)->ber_end - (ber)->ber_ptr)
|
2000-09-15 13:56:37 +08:00
|
|
|
#define ber_pvt_ber_total(ber) ((ber)->ber_end - (ber)->ber_buf)
|
|
|
|
#define ber_pvt_ber_write(ber) ((ber)->ber_ptr - (ber)->ber_buf)
|
1999-05-29 03:33:05 +08:00
|
|
|
|
1998-10-26 09:49:56 +08:00
|
|
|
struct sockbuf {
|
1999-03-06 10:36:21 +08:00
|
|
|
struct lber_options sb_opts;
|
2000-06-02 04:59:21 +08:00
|
|
|
Sockbuf_IO_Desc *sb_iod; /* I/O functions */
|
1999-05-29 03:33:05 +08:00
|
|
|
#define sb_valid sb_opts.lbo_valid
|
1999-03-06 10:36:21 +08:00
|
|
|
#define sb_options sb_opts.lbo_options
|
|
|
|
#define sb_debug sb_opts.lbo_debug
|
2000-06-02 04:59:21 +08:00
|
|
|
ber_socket_t sb_fd;
|
2000-07-21 03:50:40 +08:00
|
|
|
unsigned int sb_trans_needs_read:1;
|
|
|
|
unsigned int sb_trans_needs_write:1;
|
2001-05-05 05:15:09 +08:00
|
|
|
ber_len_t sb_max_incoming;
|
1998-10-26 09:49:56 +08:00
|
|
|
};
|
1999-05-29 03:33:05 +08:00
|
|
|
|
2000-06-02 04:59:21 +08:00
|
|
|
#define SOCKBUF_VALID( sb ) ( (sb)->sb_valid == LBER_VALID_SOCKBUF )
|
1999-03-03 04:23:14 +08:00
|
|
|
|
1998-10-26 09:49:56 +08:00
|
|
|
struct seqorset {
|
1998-10-26 09:18:41 +08:00
|
|
|
BerElement *sos_ber;
|
1999-06-19 07:53:05 +08:00
|
|
|
ber_len_t sos_clen;
|
|
|
|
ber_tag_t sos_tag;
|
1998-10-26 09:18:41 +08:00
|
|
|
char *sos_first;
|
|
|
|
char *sos_ptr;
|
|
|
|
struct seqorset *sos_next;
|
1998-10-26 09:49:56 +08:00
|
|
|
};
|
1999-06-19 07:53:05 +08:00
|
|
|
|
1998-10-26 09:18:41 +08:00
|
|
|
|
2000-03-16 03:47:22 +08:00
|
|
|
/*
|
|
|
|
* io.c
|
|
|
|
*/
|
2001-12-07 12:03:25 +08:00
|
|
|
LBER_F( int )
|
|
|
|
ber_realloc LDAP_P((
|
2000-03-16 03:47:22 +08:00
|
|
|
BerElement *ber,
|
|
|
|
ber_len_t len ));
|
|
|
|
|
1998-12-22 09:34:01 +08:00
|
|
|
/*
|
|
|
|
* bprint.c
|
|
|
|
*/
|
1999-05-29 03:33:05 +08:00
|
|
|
#define ber_log_printf ber_pvt_log_printf
|
|
|
|
|
2000-10-26 00:47:17 +08:00
|
|
|
#ifdef NEW_LOGGING
|
|
|
|
LBER_F( int )
|
|
|
|
ber_output_dump LDAP_P((
|
2001-05-07 11:50:53 +08:00
|
|
|
const char *subsys,
|
|
|
|
int level,
|
|
|
|
BerElement *ber,
|
|
|
|
int inout ));
|
2000-10-26 00:47:17 +08:00
|
|
|
#endif
|
|
|
|
|
2000-06-19 03:48:07 +08:00
|
|
|
LBER_F( int )
|
1999-05-19 09:12:33 +08:00
|
|
|
ber_log_bprint LDAP_P((
|
1998-12-22 09:34:01 +08:00
|
|
|
int errlvl,
|
|
|
|
int loglvl,
|
1999-05-19 09:12:33 +08:00
|
|
|
const char *data,
|
1999-06-19 07:53:05 +08:00
|
|
|
ber_len_t len ));
|
1998-12-22 09:34:01 +08:00
|
|
|
|
2000-06-19 03:48:07 +08:00
|
|
|
LBER_F( int )
|
1999-05-19 09:12:33 +08:00
|
|
|
ber_log_dump LDAP_P((
|
1998-12-22 09:34:01 +08:00
|
|
|
int errlvl,
|
|
|
|
int loglvl,
|
1999-10-20 02:57:38 +08:00
|
|
|
BerElement *ber,
|
1998-12-22 09:34:01 +08:00
|
|
|
int inout ));
|
|
|
|
|
2000-06-19 03:48:07 +08:00
|
|
|
LBER_F( int )
|
1999-05-19 09:12:33 +08:00
|
|
|
ber_log_sos_dump LDAP_P((
|
1998-12-22 09:34:01 +08:00
|
|
|
int errlvl,
|
|
|
|
int loglvl,
|
1999-10-20 02:57:38 +08:00
|
|
|
Seqorset *sos ));
|
1998-12-22 09:34:01 +08:00
|
|
|
|
2002-01-03 05:19:45 +08:00
|
|
|
LBER_V (BER_LOG_FN) ber_int_log_proc;
|
|
|
|
LBER_V (FILE *) ber_pvt_err_file;
|
1999-05-29 13:16:31 +08:00
|
|
|
|
1999-05-29 09:19:14 +08:00
|
|
|
/* memory.c */
|
|
|
|
/* simple macros to realloc for now */
|
2001-12-07 12:03:25 +08:00
|
|
|
LBER_V (BerMemoryFunctions *) ber_int_memory_fns;
|
2001-10-19 03:00:07 +08:00
|
|
|
LBER_F (char *) ber_strndup( LDAP_CONST char *, ber_len_t );
|
|
|
|
LBER_F (char *) ber_strndup__( LDAP_CONST char *, size_t );
|
1999-05-29 13:16:31 +08:00
|
|
|
|
1999-08-20 02:48:17 +08:00
|
|
|
#ifdef CSRIMALLOC
|
|
|
|
#define LBER_INT_MALLOC malloc
|
|
|
|
#define LBER_INT_CALLOC calloc
|
|
|
|
#define LBER_INT_REALLOC realloc
|
|
|
|
#define LBER_INT_FREE free
|
|
|
|
#define LBER_INT_VFREE ber_memvfree
|
|
|
|
#define LBER_INT_STRDUP strdup
|
|
|
|
|
|
|
|
#define LBER_MALLOC malloc
|
|
|
|
#define LBER_CALLOC calloc
|
|
|
|
#define LBER_REALLOC realloc
|
|
|
|
#define LBER_FREE free
|
|
|
|
#define LBER_VFREE ber_memvfree
|
|
|
|
#define LBER_STRDUP strdup
|
2001-10-19 03:00:07 +08:00
|
|
|
#define LBER_STRNDUP ber_strndup__
|
1999-08-20 02:48:17 +08:00
|
|
|
|
|
|
|
#else
|
1999-05-31 07:00:52 +08:00
|
|
|
#define LBER_INT_MALLOC(s) ber_memalloc((s))
|
|
|
|
#define LBER_INT_CALLOC(n,s) ber_memcalloc((n),(s))
|
|
|
|
#define LBER_INT_REALLOC(p,s) ber_memrealloc((p),(s))
|
|
|
|
#define LBER_INT_FREE(p) ber_memfree((p))
|
1999-06-02 03:25:17 +08:00
|
|
|
#define LBER_INT_VFREE(v) ber_memvfree((void**)(v))
|
1999-06-03 06:28:22 +08:00
|
|
|
#define LBER_INT_STRDUP(s) ber_strdup((s))
|
1999-06-08 02:48:22 +08:00
|
|
|
|
1999-05-31 07:00:52 +08:00
|
|
|
#define LBER_MALLOC(s) ber_memalloc((s))
|
|
|
|
#define LBER_CALLOC(n,s) ber_memcalloc((n),(s))
|
|
|
|
#define LBER_REALLOC(p,s) ber_memrealloc((p),(s))
|
|
|
|
#define LBER_FREE(p) ber_memfree((p))
|
1999-06-02 03:25:17 +08:00
|
|
|
#define LBER_VFREE(v) ber_memvfree((void**)(v))
|
1999-06-03 06:28:22 +08:00
|
|
|
#define LBER_STRDUP(s) ber_strdup((s))
|
2001-10-19 03:00:07 +08:00
|
|
|
#define LBER_STRNDUP(s,l) ber_strndup((s),(l))
|
1999-08-20 02:48:17 +08:00
|
|
|
#endif
|
1999-05-29 09:19:14 +08:00
|
|
|
|
1999-03-03 04:23:14 +08:00
|
|
|
/* sockbuf.c */
|
|
|
|
|
2000-06-19 03:48:07 +08:00
|
|
|
LBER_F( int )
|
2000-06-02 04:59:21 +08:00
|
|
|
ber_int_sb_init LDAP_P(( Sockbuf *sb ));
|
1999-05-19 09:12:33 +08:00
|
|
|
|
2000-06-19 03:48:07 +08:00
|
|
|
LBER_F( int )
|
2000-06-02 04:59:21 +08:00
|
|
|
ber_int_sb_close LDAP_P(( Sockbuf *sb ));
|
1999-05-19 09:12:33 +08:00
|
|
|
|
2000-06-19 03:48:07 +08:00
|
|
|
LBER_F( int )
|
2000-06-02 04:59:21 +08:00
|
|
|
ber_int_sb_destroy LDAP_P(( Sockbuf *sb ));
|
1999-05-19 09:12:33 +08:00
|
|
|
|
2000-06-19 03:48:07 +08:00
|
|
|
LBER_F( ber_slen_t )
|
2000-06-02 04:59:21 +08:00
|
|
|
ber_int_sb_read LDAP_P(( Sockbuf *sb, void *buf, ber_len_t len ));
|
1999-05-19 09:12:33 +08:00
|
|
|
|
2000-06-19 03:48:07 +08:00
|
|
|
LBER_F( ber_slen_t )
|
2000-06-02 04:59:21 +08:00
|
|
|
ber_int_sb_write LDAP_P(( Sockbuf *sb, void *buf, ber_len_t len ));
|
1999-03-03 04:23:14 +08:00
|
|
|
|
1999-12-22 08:42:05 +08:00
|
|
|
LDAP_END_DECL
|
|
|
|
|
1998-10-26 09:18:41 +08:00
|
|
|
#endif /* _LBER_INT_H */
|