lber.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* 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_H
#define _LBER_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#if !defined(NEEDPROTOS) && defined(__STDC__)
#define NEEDPROTOS 1
#endif
/* BER classes and mask */
#define LBER_CLASS_UNIVERSAL 0x00
#define LBER_CLASS_APPLICATION 0x40
#define LBER_CLASS_CONTEXT 0x80
#define LBER_CLASS_PRIVATE 0xc0
#define LBER_CLASS_MASK 0xc0
/* BER encoding type and mask */
#define LBER_PRIMITIVE 0x00
#define LBER_CONSTRUCTED 0x20
#define LBER_ENCODING_MASK 0x20
#define LBER_BIG_TAG_MASK 0x1f
#define LBER_MORE_TAG_MASK 0x80
/*
* Note that LBER_ERROR and LBER_DEFAULT are values that can never appear
* as valid BER tags, and so it is safe to use them to report errors. In
* fact, any tag for which the following is true is invalid:
* (( tag & 0x00000080 ) != 0 ) && (( tag & 0xFFFFFF00 ) != 0 )
*/
#define LBER_ERROR 0xffffffff
#define LBER_DEFAULT 0xffffffff
/* general BER types we know about */
#define LBER_BOOLEAN 0x01
#define LBER_INTEGER 0x02
#define LBER_BITSTRING 0x03
#define LBER_OCTETSTRING 0x04
#define LBER_NULL 0x05
#define LBER_ENUMERATED 0x0a
#ifdef NEEDPROTOS
int free_input);
#else /* NEEDPROTOS */
typedef int (*BERTranslateProc)();
#endif /* NEEDPROTOS */
#define NULLBER ((BerElement *) 0)
#ifdef LDAP_SSL
#endif /* LDAP_SSL */
/*
* Structure Sockbuf which used to be defined in this header file, is
* removed since the c-api draft does not define the structure and it
* is only used internal to the library
*/
typedef struct seqorset {
unsigned int sos_clen;
unsigned int sos_tag;
char *sos_first;
char *sos_ptr;
} Seqorset;
#define NULLSEQORSET ((Seqorset *) 0)
typedef unsigned int ber_len_t; /* for BER len */
typedef unsigned int ber_tag_t; /* for BER tags */
typedef int ber_int_t; /* for BER ints, enums, and Booleans */
typedef unsigned int ber_uint_t; /* unsigned equivalent of ber_int_t */
typedef int ber_slen_t; /* signed equivalent of ber_len_t */
/* structure for returning a sequence of octet strings + length */
typedef struct berval {
char *bv_val;
} BerValue;
#ifndef NEEDPROTOS
extern BerElement *ber_alloc();
extern BerElement *der_alloc();
extern BerElement *ber_alloc_t();
extern BerElement *ber_dup();
extern BerElement *ber_init();
extern int lber_debug;
extern void ber_bvfree();
extern void ber_bvecfree();
extern void ber_dump();
extern void ber_sos_dump();
extern void lber_bprint();
extern void ber_reset();
extern void ber_zero_init();
#else /* NEEDPROTOS */
/*
* in bprint.c:
*/
/*
* in decode.c:
*/
char **last);
char *last);
#else
#endif
#ifdef STR_TRANSLATION
#endif /* STR_TRANSLATION */
/*
* in encode.c
*/
#else
int ber_printf();
#endif
/*
* in io.c:
*
* ber_flush() and ber_get_next() functions are obsolete and removed
*/
BerElement *ber_alloc(void);
BerElement *der_alloc(void);
#ifdef NEEDGETOPT
/*
* in getopt.c
*/
#endif /* NEEDGETOPT */
#endif /* NEEDPROTOS */
#define LBER_HTONL(l) htonl(l)
#define LBER_NTOHL(l) ntohl(l)
/*
* SAFEMEMCPY is an overlap-safe copy from s to d of n bytes
*/
#ifdef sunos4
#define SAFEMEMCPY(d, s, n) bcopy(s, d, n)
#else /* sunos4 */
#define SAFEMEMCPY(d, s, n) memmove(d, s, n)
#endif /* sunos4 */
#ifdef SUN
/* I18N support */
#include <locale.h>
#include <nl_types.h>
extern void i18n_catopen(char *);
#endif
#ifdef __cplusplus
}
#endif
#endif /* _LBER_H */