diff options
author | Matt A. Tobin <email@mattatobin.com> | 2019-11-03 00:17:46 -0400 |
---|---|---|
committer | Matt A. Tobin <email@mattatobin.com> | 2019-11-03 00:17:46 -0400 |
commit | 302bf1b523012e11b60425d6eee1221ebc2724eb (patch) | |
tree | b191a895f8716efcbe42f454f37597a545a6f421 /ldap/c-sdk/include | |
parent | 21b3f6247403c06f85e1f45d219f87549862198f (diff) | |
download | UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.tar UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.tar.gz UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.tar.lz UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.tar.xz UXP-302bf1b523012e11b60425d6eee1221ebc2724eb.zip |
Issue #1258 - Part 1: Import mailnews, ldap, and mork from comm-esr52.9.1
Diffstat (limited to 'ldap/c-sdk/include')
-rw-r--r-- | ldap/c-sdk/include/disptmpl.h | 379 | ||||
-rw-r--r-- | ldap/c-sdk/include/iutil.h | 72 | ||||
-rw-r--r-- | ldap/c-sdk/include/lber.h | 339 | ||||
-rw-r--r-- | ldap/c-sdk/include/lcache.h | 94 | ||||
-rw-r--r-- | ldap/c-sdk/include/ldap-deprecated.h | 201 | ||||
-rw-r--r-- | ldap/c-sdk/include/ldap-extension.h | 853 | ||||
-rw-r--r-- | ldap/c-sdk/include/ldap-platform.h | 91 | ||||
-rw-r--r-- | ldap/c-sdk/include/ldap-standard.h | 457 | ||||
-rw-r--r-- | ldap/c-sdk/include/ldap-to-be-deprecated.h | 193 | ||||
-rw-r--r-- | ldap/c-sdk/include/ldap.h | 62 | ||||
-rw-r--r-- | ldap/c-sdk/include/ldap_ssl.h | 254 | ||||
-rw-r--r-- | ldap/c-sdk/include/ldaplog.h | 106 | ||||
-rw-r--r-- | ldap/c-sdk/include/ldappr.h | 273 | ||||
-rw-r--r-- | ldap/c-sdk/include/ldaprot.h | 203 | ||||
-rw-r--r-- | ldap/c-sdk/include/ldif.h | 114 | ||||
-rw-r--r-- | ldap/c-sdk/include/portable.h | 462 | ||||
-rw-r--r-- | ldap/c-sdk/include/proto-ntutil.h | 99 | ||||
-rw-r--r-- | ldap/c-sdk/include/regex.h | 95 | ||||
-rw-r--r-- | ldap/c-sdk/include/srchpref.h | 154 |
19 files changed, 4501 insertions, 0 deletions
diff --git a/ldap/c-sdk/include/disptmpl.h b/ldap/c-sdk/include/disptmpl.h new file mode 100644 index 000000000..b287e3f95 --- /dev/null +++ b/ldap/c-sdk/include/disptmpl.h @@ -0,0 +1,379 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Copyright (c) 1993, 1994 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. + * + * disptmpl.h: display template library defines + */ + +#ifndef _DISPTMPL_H +#define _DISPTMPL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* calling conventions used by library */ +#ifndef LDAP_CALL +#if defined( _WINDOWS ) || defined( _WIN32 ) +#define LDAP_C __cdecl +#ifndef _WIN32 +#define __stdcall _far _pascal +#define LDAP_CALLBACK _loadds +#else +#define LDAP_CALLBACK +#endif /* _WIN32 */ +#define LDAP_PASCAL __stdcall +#define LDAP_CALL LDAP_PASCAL +#else /* _WINDOWS */ +#define LDAP_C +#define LDAP_CALLBACK +#define LDAP_PASCAL +#define LDAP_CALL +#endif /* _WINDOWS */ +#endif /* LDAP_CALL */ + +#define LDAP_TEMPLATE_VERSION 1 + +/* + * general types of items (confined to most significant byte) + */ +#define LDAP_SYN_TYPE_TEXT 0x01000000L +#define LDAP_SYN_TYPE_IMAGE 0x02000000L +#define LDAP_SYN_TYPE_BOOLEAN 0x04000000L +#define LDAP_SYN_TYPE_BUTTON 0x08000000L +#define LDAP_SYN_TYPE_ACTION 0x10000000L + + +/* + * syntax options (confined to second most significant byte) + */ +#define LDAP_SYN_OPT_DEFER 0x00010000L + + +/* + * display template item syntax ids (defined by common agreement) + * these are the valid values for the ti_syntaxid of the tmplitem + * struct (defined below). A general type is encoded in the + * most-significant 8 bits, and some options are encoded in the next + * 8 bits. The lower 16 bits are reserved for the distinct types. + */ +#define LDAP_SYN_CASEIGNORESTR ( 1 | LDAP_SYN_TYPE_TEXT ) +#define LDAP_SYN_MULTILINESTR ( 2 | LDAP_SYN_TYPE_TEXT ) +#define LDAP_SYN_DN ( 3 | LDAP_SYN_TYPE_TEXT ) +#define LDAP_SYN_BOOLEAN ( 4 | LDAP_SYN_TYPE_BOOLEAN ) +#define LDAP_SYN_JPEGIMAGE ( 5 | LDAP_SYN_TYPE_IMAGE ) +#define LDAP_SYN_JPEGBUTTON ( 6 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER ) +#define LDAP_SYN_FAXIMAGE ( 7 | LDAP_SYN_TYPE_IMAGE ) +#define LDAP_SYN_FAXBUTTON ( 8 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER ) +#define LDAP_SYN_AUDIOBUTTON ( 9 | LDAP_SYN_TYPE_BUTTON | LDAP_SYN_OPT_DEFER ) +#define LDAP_SYN_TIME ( 10 | LDAP_SYN_TYPE_TEXT ) +#define LDAP_SYN_DATE ( 11 | LDAP_SYN_TYPE_TEXT ) +#define LDAP_SYN_LABELEDURL ( 12 | LDAP_SYN_TYPE_TEXT ) +#define LDAP_SYN_SEARCHACTION ( 13 | LDAP_SYN_TYPE_ACTION ) +#define LDAP_SYN_LINKACTION ( 14 | LDAP_SYN_TYPE_ACTION ) +#define LDAP_SYN_ADDDNACTION ( 15 | LDAP_SYN_TYPE_ACTION ) +#define LDAP_SYN_VERIFYDNACTION ( 16 | LDAP_SYN_TYPE_ACTION ) +#define LDAP_SYN_RFC822ADDR ( 17 | LDAP_SYN_TYPE_TEXT ) + + +/* + * handy macros + */ +#define LDAP_GET_SYN_TYPE( syid ) ((syid) & 0xFF000000UL ) +#define LDAP_GET_SYN_OPTIONS( syid ) ((syid) & 0x00FF0000UL ) + + +/* + * display options for output routines (used by entry2text and friends) + */ +/* + * use calculated label width (based on length of longest label in + * template) instead of contant width + */ +#define LDAP_DISP_OPT_AUTOLABELWIDTH 0x00000001L +#define LDAP_DISP_OPT_HTMLBODYONLY 0x00000002L + +/* + * perform search actions (applies to ldap_entry2text_search only) + */ +#define LDAP_DISP_OPT_DOSEARCHACTIONS 0x00000002L + +/* + * include additional info. relevant to "non leaf" entries only + * used by ldap_entry2html and ldap_entry2html_search to include "Browse" + * and "Move Up" HREFs + */ +#define LDAP_DISP_OPT_NONLEAF 0x00000004L + + +/* + * display template item options (may not apply to all types) + * if this bit is set in ti_options, it applies. + */ +#define LDAP_DITEM_OPT_READONLY 0x00000001L +#define LDAP_DITEM_OPT_SORTVALUES 0x00000002L +#define LDAP_DITEM_OPT_SINGLEVALUED 0x00000004L +#define LDAP_DITEM_OPT_HIDEIFEMPTY 0x00000008L +#define LDAP_DITEM_OPT_VALUEREQUIRED 0x00000010L +#define LDAP_DITEM_OPT_HIDEIFFALSE 0x00000020L /* booleans only */ + + + +/* + * display template item structure + */ +struct ldap_tmplitem { + unsigned long ti_syntaxid; + unsigned long ti_options; + char *ti_attrname; + char *ti_label; + char **ti_args; + struct ldap_tmplitem *ti_next_in_row; + struct ldap_tmplitem *ti_next_in_col; + void *ti_appdata; +}; + + +#define NULLTMPLITEM ((struct ldap_tmplitem *)0) + +#define LDAP_SET_TMPLITEM_APPDATA( ti, datap ) \ + (ti)->ti_appdata = (void *)(datap) + +#define LDAP_GET_TMPLITEM_APPDATA( ti, type ) \ + (type)((ti)->ti_appdata) + +#define LDAP_IS_TMPLITEM_OPTION_SET( ti, option ) \ + (((ti)->ti_options & option ) != 0 ) + + +/* + * object class array structure + */ +struct ldap_oclist { + char **oc_objclasses; + struct ldap_oclist *oc_next; +}; + +#define NULLOCLIST ((struct ldap_oclist *)0) + + +/* + * add defaults list + */ +struct ldap_adddeflist { + int ad_source; +#define LDAP_ADSRC_CONSTANTVALUE 1 +#define LDAP_ADSRC_ADDERSDN 2 + char *ad_attrname; + char *ad_value; + struct ldap_adddeflist *ad_next; +}; + +#define NULLADLIST ((struct ldap_adddeflist *)0) + + +/* + * display template global options + * if this bit is set in dt_options, it applies. + */ +/* + * users should be allowed to try to add objects of these entries + */ +#define LDAP_DTMPL_OPT_ADDABLE 0x00000001L + +/* + * users should be allowed to do "modify RDN" operation of these entries + */ +#define LDAP_DTMPL_OPT_ALLOWMODRDN 0x00000002L + +/* + * this template is an alternate view, not a primary view + */ +#define LDAP_DTMPL_OPT_ALTVIEW 0x00000004L + + +/* + * display template structure + */ +struct ldap_disptmpl { + char *dt_name; + char *dt_pluralname; + char *dt_iconname; + unsigned long dt_options; + char *dt_authattrname; + char *dt_defrdnattrname; + char *dt_defaddlocation; + struct ldap_oclist *dt_oclist; + struct ldap_adddeflist *dt_adddeflist; + struct ldap_tmplitem *dt_items; + void *dt_appdata; + struct ldap_disptmpl *dt_next; +}; + +#define NULLDISPTMPL ((struct ldap_disptmpl *)0) + +#define LDAP_SET_DISPTMPL_APPDATA( dt, datap ) \ + (dt)->dt_appdata = (void *)(datap) + +#define LDAP_GET_DISPTMPL_APPDATA( dt, type ) \ + (type)((dt)->dt_appdata) + +#define LDAP_IS_DISPTMPL_OPTION_SET( dt, option ) \ + (((dt)->dt_options & option ) != 0 ) + +#define LDAP_TMPL_ERR_VERSION 1 +#define LDAP_TMPL_ERR_MEM 2 +#define LDAP_TMPL_ERR_SYNTAX 3 +#define LDAP_TMPL_ERR_FILE 4 + +/* + * buffer size needed for entry2text and vals2text + */ +#define LDAP_DTMPL_BUFSIZ 8192 + +typedef int (*writeptype)( void *writeparm, char *p, int len ); + +LDAP_API(int) +LDAP_CALL +ldap_init_templates( char *file, struct ldap_disptmpl **tmpllistp ); + +LDAP_API(int) +LDAP_CALL +ldap_init_templates_buf( char *buf, long buflen, + struct ldap_disptmpl **tmpllistp ); + +LDAP_API(void) +LDAP_CALL +ldap_free_templates( struct ldap_disptmpl *tmpllist ); + +LDAP_API(struct ldap_disptmpl *) +LDAP_CALL +ldap_first_disptmpl( struct ldap_disptmpl *tmpllist ); + +LDAP_API(struct ldap_disptmpl *) +LDAP_CALL +ldap_next_disptmpl( struct ldap_disptmpl *tmpllist, + struct ldap_disptmpl *tmpl ); + +LDAP_API(struct ldap_disptmpl *) +LDAP_CALL +ldap_name2template( char *name, struct ldap_disptmpl *tmpllist ); + +LDAP_API(struct ldap_disptmpl *) +LDAP_CALL +ldap_oc2template( char **oclist, struct ldap_disptmpl *tmpllist ); + +LDAP_API(char **) +LDAP_CALL +ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs, int exclude, + unsigned long syntaxmask ); + +LDAP_API(struct ldap_tmplitem *) +LDAP_CALL +ldap_first_tmplrow( struct ldap_disptmpl *tmpl ); + +LDAP_API(struct ldap_tmplitem *) +LDAP_CALL +ldap_next_tmplrow( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row ); + +LDAP_API(struct ldap_tmplitem *) +LDAP_CALL +ldap_first_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row ); + +LDAP_API(struct ldap_tmplitem *) +LDAP_CALL +ldap_next_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row, + struct ldap_tmplitem *col ); + +LDAP_API(int) +LDAP_CALL +ldap_entry2text( LDAP *ld, char *buf, LDAPMessage *entry, + struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals, + writeptype writeproc, void *writeparm, char *eol, int rdncount, + unsigned long opts ); + +LDAP_API(int) +LDAP_CALL +ldap_vals2text( LDAP *ld, char *buf, char **vals, char *label, int labelwidth, + unsigned long syntaxid, writeptype writeproc, void *writeparm, + char *eol, int rdncount ); + +LDAP_API(int) +LDAP_CALL +ldap_entry2text_search( LDAP *ld, char *dn, char *base, LDAPMessage *entry, + struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals, + writeptype writeproc, void *writeparm, char *eol, int rdncount, + unsigned long opts ); + +LDAP_API(int) +LDAP_CALL +ldap_entry2html( LDAP *ld, char *buf, LDAPMessage *entry, + struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals, + writeptype writeproc, void *writeparm, char *eol, int rdncount, + unsigned long opts, char *urlprefix, char *base ); + +LDAP_API(int) +LDAP_CALL +ldap_vals2html( LDAP *ld, char *buf, char **vals, char *label, int labelwidth, + unsigned long syntaxid, writeptype writeproc, void *writeparm, + char *eol, int rdncount, char *urlprefix ); + +LDAP_API(int) +LDAP_CALL +ldap_entry2html_search( LDAP *ld, char *dn, char *base, LDAPMessage *entry, + struct ldap_disptmpl *tmpllist, char **defattrs, char ***defvals, + writeptype writeproc, void *writeparm, char *eol, int rdncount, + unsigned long opts, char *urlprefix ); + +LDAP_API(char *) +LDAP_CALL +ldap_tmplerr2string( int err ); + +#ifdef __cplusplus +} +#endif +#endif /* _DISPTMPL_H */ diff --git a/ldap/c-sdk/include/iutil.h b/ldap/c-sdk/include/iutil.h new file mode 100644 index 000000000..a87a800d2 --- /dev/null +++ b/ldap/c-sdk/include/iutil.h @@ -0,0 +1,72 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Interface for libiutil the innosoft migration library + * + */ + +#ifndef _IUTIL_H +#define _IUTIL_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/* from iutil-lock.c */ + +#ifdef _WINDOWS +#define LDAP_MUTEX_T HANDLE + +extern char *ldap_strdup(); +extern unsigned char *ldap_utf8_nextchar(); +extern char **ldap_explode_ava(); +extern int ldap_utf8_toupper(); + +int pthread_mutex_init( LDAP_MUTEX_T *mp, void *attr); +static void * pthread_mutex_alloc( void ); +int pthread_mutex_destroy( LDAP_MUTEX_T *mp ); +static void pthread_mutex_free( void *mutexp ); +int pthread_mutex_lock( LDAP_MUTEX_T *mp ); +int pthread_mutex_unlock( LDAP_MUTEX_T *mp ); + +#endif /* _WINDOWS */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /* _IUTIL_H */ diff --git a/ldap/c-sdk/include/lber.h b/ldap/c-sdk/include/lber.h new file mode 100644 index 000000000..4ad1daafd --- /dev/null +++ b/ldap/c-sdk/include/lber.h @@ -0,0 +1,339 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ +/* lber.h - header file for ber_* functions */ +#ifndef _LBER_H +#define _LBER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdlib.h> /* to pick up size_t typedef */ + +/* + * 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 ((ber_tag_t) -1) /* 0xffffffffU */ +#define LBER_DEFAULT ((ber_tag_t) -1) /* 0xffffffffU */ +#define LBER_END_OF_SEQORSET ((ber_tag_t) -2) /* 0xfffffffeU */ +#define LBER_OVERFLOW ((ber_tag_t) -3) /* 0xfffffffdU */ + +/* 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 + +/* 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 +#define LBER_SEQUENCE 0x30 +#define LBER_SET 0x31 + +/* BerElement set/get options */ +#define LBER_OPT_REMAINING_BYTES 0x01 +#define LBER_OPT_TOTAL_BYTES 0x02 +#define LBER_OPT_USE_DER 0x04 +#define LBER_OPT_TRANSLATE_STRINGS 0x08 +#define LBER_OPT_BYTES_TO_WRITE 0x10 +#define LBER_OPT_MEMALLOC_FN_PTRS 0x20 +#define LBER_OPT_DEBUG_LEVEL 0x40 +#define LBER_OPT_BUFSIZE 0x80 + +/* + * LBER_USE_DER is defined for compatibility with the C LDAP API RFC. + * In our implementation, we recognize it (instead of the numerically + * identical LBER_OPT_REMAINING_BYTES) in calls to ber_alloc_t() and + * ber_init_w_nullchar() only. Callers of ber_set_option() or + * ber_get_option() must use LBER_OPT_USE_DER instead. Sorry! + */ +#define LBER_USE_DER 0x01 + +/* Sockbuf set/get options */ +#define LBER_SOCKBUF_OPT_TO_FILE 0x001 +#define LBER_SOCKBUF_OPT_TO_FILE_ONLY 0x002 +#define LBER_SOCKBUF_OPT_MAX_INCOMING_SIZE 0x004 +#define LBER_SOCKBUF_OPT_NO_READ_AHEAD 0x008 +#define LBER_SOCKBUF_OPT_DESC 0x010 +#define LBER_SOCKBUF_OPT_COPYDESC 0x020 +#define LBER_SOCKBUF_OPT_READ_FN 0x040 +#define LBER_SOCKBUF_OPT_WRITE_FN 0x080 +#define LBER_SOCKBUF_OPT_EXT_IO_FNS 0x100 +#define LBER_SOCKBUF_OPT_VALID_TAG 0x200 +#define LBER_SOCKBUF_OPT_SOCK_ARG 0x400 + +#define LBER_OPT_ON ((void *) 1) +#define LBER_OPT_OFF ((void *) 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 */ + +typedef struct berval { + ber_len_t bv_len; + char *bv_val; +} BerValue; + +typedef struct berelement BerElement; +typedef struct sockbuf Sockbuf; +typedef int (*BERTranslateProc)( char **bufp, ber_uint_t *buflenp, + int free_input ); +#ifndef macintosh +#if defined( _WINDOWS ) || defined( _WIN32) || defined( _CONSOLE ) +#include <winsock.h> /* for SOCKET */ +typedef SOCKET LBER_SOCKET; +#else +typedef long LBER_SOCKET; +#endif /* _WINDOWS */ +#else /* macintosh */ +typedef void *LBER_SOCKET; +#endif /* macintosh */ + +/* calling conventions used by library */ +#ifndef LDAP_CALL +#if defined( _WINDOWS ) || defined( _WIN32 ) +#define LDAP_C __cdecl +#ifndef _WIN32 +#define __stdcall _far _pascal +#define LDAP_CALLBACK _loadds +#else +#define LDAP_CALLBACK +#endif /* _WIN32 */ +#define LDAP_PASCAL __stdcall +#define LDAP_CALL LDAP_PASCAL +#else /* _WINDOWS */ +#define LDAP_C +#define LDAP_CALLBACK +#define LDAP_PASCAL +#define LDAP_CALL +#endif /* _WINDOWS */ +#endif /* LDAP_CALL */ + +/* + * function prototypes for lber library + */ + +#ifndef LDAP_API +#if defined( _WINDOWS ) || defined( _WIN32 ) +#define LDAP_API(rt) rt +#else /* _WINDOWS */ +#define LDAP_API(rt) rt +#endif /* _WINDOWS */ +#endif /* LDAP_API */ + +struct lextiof_socket_private; /* Defined by the extended I/O */ + /* callback functions */ +struct lextiof_session_private; /* Defined by the extended I/O */ + /* callback functions */ + +/* This is modeled after the PRIOVec that is passed to the NSPR + writev function! The void* is a char* in that struct */ +typedef struct ldap_x_iovec { + char *ldapiov_base; + int ldapiov_len; +} ldap_x_iovec; + +/* + * libldap read and write I/O function callbacks. The rest of the I/O callback + * types are defined in ldap.h + */ +typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_READ_CALLBACK)( LBER_SOCKET s, + void *buf, int bufsize ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_WRITE_CALLBACK)( LBER_SOCKET s, + const void *buf, int len ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_READ_CALLBACK)( int s, + void *buf, int bufsize, struct lextiof_socket_private *socketarg ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_WRITE_CALLBACK)( int s, + const void *buf, int len, struct lextiof_socket_private *socketarg ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_WRITEV_CALLBACK)(int s, + const ldap_x_iovec iov[], int iovcnt, struct lextiof_socket_private *socketarg); + + +/* + * Structure for use with LBER_SOCKBUF_OPT_EXT_IO_FNS: + */ +struct lber_x_ext_io_fns { + /* lbextiofn_size should always be set to LBER_X_EXTIO_FNS_SIZE */ + int lbextiofn_size; + LDAP_X_EXTIOF_READ_CALLBACK *lbextiofn_read; + LDAP_X_EXTIOF_WRITE_CALLBACK *lbextiofn_write; + struct lextiof_socket_private *lbextiofn_socket_arg; + LDAP_X_EXTIOF_WRITEV_CALLBACK *lbextiofn_writev; +}; +#define LBER_X_EXTIO_FNS_SIZE sizeof(struct lber_x_ext_io_fns) + +/* + * liblber memory allocation callback functions. These are global to all + * Sockbufs and BerElements. Install your own functions by using a call + * like this: ber_set_option( NULL, LBER_OPT_MEMALLOC_FN_PTRS, &memalloc_fns ); + */ +typedef void * (LDAP_C LDAP_CALLBACK LDAP_MALLOC_CALLBACK)( size_t size ); +typedef void * (LDAP_C LDAP_CALLBACK LDAP_CALLOC_CALLBACK)( size_t nelem, + size_t elsize ); +typedef void * (LDAP_C LDAP_CALLBACK LDAP_REALLOC_CALLBACK)( void *ptr, + size_t size ); +typedef void (LDAP_C LDAP_CALLBACK LDAP_FREE_CALLBACK)( void *ptr ); + +struct lber_memalloc_fns { + LDAP_MALLOC_CALLBACK *lbermem_malloc; + LDAP_CALLOC_CALLBACK *lbermem_calloc; + LDAP_REALLOC_CALLBACK *lbermem_realloc; + LDAP_FREE_CALLBACK *lbermem_free; +}; + +/* + * decode routines + */ +LDAP_API(ber_tag_t) LDAP_CALL ber_get_tag( BerElement *ber ); +LDAP_API(ber_tag_t) LDAP_CALL ber_skip_tag( BerElement *ber, + ber_len_t *len ); +LDAP_API(ber_tag_t) LDAP_CALL ber_peek_tag( BerElement *ber, + ber_len_t *len ); +LDAP_API(ber_tag_t) LDAP_CALL ber_get_int( BerElement *ber, ber_int_t *num ); +LDAP_API(ber_tag_t) LDAP_CALL ber_get_stringb( BerElement *ber, char *buf, + ber_len_t *len ); +LDAP_API(ber_tag_t) LDAP_CALL ber_get_stringa( BerElement *ber, + char **buf ); +LDAP_API(ber_tag_t) LDAP_CALL ber_get_stringal( BerElement *ber, + struct berval **bv ); +LDAP_API(ber_tag_t) LDAP_CALL ber_get_bitstringa( BerElement *ber, + char **buf, ber_len_t *len ); +LDAP_API(ber_tag_t) LDAP_CALL ber_get_null( BerElement *ber ); +LDAP_API(ber_tag_t) LDAP_CALL ber_get_boolean( BerElement *ber, + ber_int_t *boolval ); +LDAP_API(ber_tag_t) LDAP_CALL ber_first_element( BerElement *ber, + ber_len_t *len, char **last ); +LDAP_API(ber_tag_t) LDAP_CALL ber_next_element( BerElement *ber, + ber_len_t *len, char *last ); +LDAP_API(ber_tag_t) LDAP_C ber_scanf( BerElement *ber, const char *fmt, + ... ); +LDAP_API(void) LDAP_CALL ber_bvfree( struct berval *bv ); +LDAP_API(void) LDAP_CALL ber_bvecfree( struct berval **bv ); +LDAP_API(void) LDAP_CALL ber_svecfree( char **vals ); +LDAP_API(struct berval *) LDAP_CALL ber_bvdup( const struct berval *bv ); +LDAP_API(void) LDAP_CALL ber_set_string_translators( BerElement *ber, + BERTranslateProc encode_proc, BERTranslateProc decode_proc ); +LDAP_API(BerElement *) LDAP_CALL ber_init( const struct berval *bv ); + +/* + * encoding routines + */ +LDAP_API(int) LDAP_CALL ber_put_enum( BerElement *ber, ber_int_t num, + ber_tag_t tag ); +LDAP_API(int) LDAP_CALL ber_put_int( BerElement *ber, ber_int_t num, + ber_tag_t tag ); +LDAP_API(int) LDAP_CALL ber_put_ostring( BerElement *ber, char *str, + ber_len_t len, ber_tag_t tag ); +LDAP_API(int) LDAP_CALL ber_put_string( BerElement *ber, char *str, + ber_tag_t tag ); +LDAP_API(int) LDAP_CALL ber_put_bitstring( BerElement *ber, char *str, + ber_len_t bitlen, ber_tag_t tag ); +LDAP_API(int) LDAP_CALL ber_put_null( BerElement *ber, ber_tag_t tag ); +LDAP_API(int) LDAP_CALL ber_put_boolean( BerElement *ber, + ber_int_t boolval, ber_tag_t tag ); +LDAP_API(int) LDAP_CALL ber_start_seq( BerElement *ber, ber_tag_t tag ); +LDAP_API(int) LDAP_CALL ber_start_set( BerElement *ber, ber_tag_t tag ); +LDAP_API(int) LDAP_CALL ber_put_seq( BerElement *ber ); +LDAP_API(int) LDAP_CALL ber_put_set( BerElement *ber ); +LDAP_API(int) LDAP_C ber_printf( BerElement *ber, const char *fmt, ... ); +LDAP_API(int) LDAP_CALL ber_flatten( BerElement *ber, + struct berval **bvPtr ); + +/* + * miscellaneous routines + */ +LDAP_API(void) LDAP_CALL ber_free( BerElement *ber, int freebuf ); +LDAP_API(void) LDAP_CALL ber_special_free(void* buf, BerElement *ber); +LDAP_API(int) LDAP_CALL ber_flush( Sockbuf *sb, BerElement *ber, int freeit ); +LDAP_API(BerElement*) LDAP_CALL ber_alloc( void ); +LDAP_API(BerElement*) LDAP_CALL der_alloc( void ); +LDAP_API(BerElement*) LDAP_CALL ber_alloc_t( int options ); +LDAP_API(void*) LDAP_CALL ber_special_alloc(size_t size, BerElement **ppBer); +LDAP_API(BerElement*) LDAP_CALL ber_dup( BerElement *ber ); +LDAP_API(ber_tag_t) LDAP_CALL ber_get_next( Sockbuf *sb, ber_len_t *len, + BerElement *ber ); +LDAP_API(ber_tag_t) LDAP_CALL ber_get_next_buffer( void *buffer, + size_t buffer_size, ber_len_t *len, BerElement *ber, + ber_len_t *Bytes_Scanned ); +LDAP_API(ber_tag_t) LDAP_CALL ber_get_next_buffer_ext( void *buffer, + size_t buffer_size, ber_len_t *len, BerElement *ber, + ber_len_t *Bytes_Scanned, Sockbuf *sb ); +LDAP_API(ber_int_t) LDAP_CALL ber_read( BerElement *ber, char *buf, + ber_len_t len ); +LDAP_API(ber_int_t) LDAP_CALL ber_write( BerElement *ber, char *buf, + ber_len_t len, int nosos ); +LDAP_API(void) LDAP_CALL ber_init_w_nullchar( BerElement *ber, int options ); +LDAP_API(void) LDAP_CALL ber_reset( BerElement *ber, int was_writing ); +LDAP_API(size_t) LDAP_CALL ber_get_buf_datalen( BerElement *ber ); +LDAP_API(int) LDAP_CALL ber_stack_init(BerElement *ber, int options, + char * buf, size_t size); +LDAP_API(char*) LDAP_CALL ber_get_buf_databegin (BerElement * ber); +LDAP_API(void) LDAP_CALL ber_sockbuf_free_data(Sockbuf *p); +LDAP_API(int) LDAP_CALL ber_set_option( BerElement *ber, int option, + void *value ); +LDAP_API(int) LDAP_CALL ber_get_option( BerElement *ber, int option, + void *value ); +LDAP_API(Sockbuf*) LDAP_CALL ber_sockbuf_alloc( void ); +LDAP_API(void) LDAP_CALL ber_sockbuf_free( Sockbuf* p ); +LDAP_API(int) LDAP_CALL ber_sockbuf_set_option( Sockbuf *sb, int option, + void *value ); +LDAP_API(int) LDAP_CALL ber_sockbuf_get_option( Sockbuf *sb, int option, + void *value ); + +#ifdef __cplusplus +} +#endif +#endif /* _LBER_H */ + diff --git a/ldap/c-sdk/include/lcache.h b/ldap/c-sdk/include/lcache.h new file mode 100644 index 000000000..b070bd652 --- /dev/null +++ b/ldap/c-sdk/include/lcache.h @@ -0,0 +1,94 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* lcache.h - ldap persistent cache */ +#ifndef _LCACHE_H +#define _LCACHE_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* calling conventions used by library */ +#ifndef LDAP_CALL +#if defined( _WINDOWS ) || defined( _WIN32 ) +#define LDAP_C __cdecl +#ifndef _WIN32 +#define __stdcall _far _pascal +#define LDAP_CALLBACK _loadds +#else +#define LDAP_CALLBACK +#endif /* _WIN32 */ +#define LDAP_PASCAL __stdcall +#define LDAP_CALL LDAP_PASCAL +#else /* _WINDOWS */ +#define LDAP_C +#define LDAP_CALLBACK +#define LDAP_PASCAL +#define LDAP_CALL +#endif /* _WINDOWS */ +#endif /* LDAP_CALL */ + +LDAP_API(int) LDAP_C lcache_init( LDAP *ld, void *arg ); +LDAP_API(int) LDAP_C lcache_bind( LDAP *ld, int msgid, unsigned long tag, + const char *dn, struct berval *cred, int method ); +LDAP_API(int) LDAP_C lcache_unbind( LDAP *ld, int msgid, unsigned long tag ); +LDAP_API(int) LDAP_C lcache_search( LDAP *ld, int msgid, unsigned long tag, + const char *dn, int scope, const char *filter, char **attrs, + int attrsonly ); +LDAP_API(int) LDAP_C lcache_compare( LDAP *ld, int msgid, unsigned long tag, + const char *dn, const char *attr, struct berval *val ); +LDAP_API(int) LDAP_C lcache_add( LDAP *ld, int msgid, unsigned long tag, + const char *dn, LDAPMod **entry ); +LDAP_API(int) LDAP_C lcache_delete( LDAP *ld, int msgid, unsigned long tag, + const char *dn ); +LDAP_API(int) LDAP_C lcache_rename( LDAP *ld, int msgid, unsigned long tag, + const char *dn, const char *newrdn, const char *newparent, + int deleteoldrdn ); +LDAP_API(int) LDAP_C lcache_modify( LDAP *ld, int msgid, unsigned long tag, + const char *dn, LDAPMod **mods ); +LDAP_API(int) LDAP_C lcache_modrdn( LDAP *ld, int msgid, unsigned long tag, + const char *dn, const char *newrdn, int deleteoldrdn ); +LDAP_API(int) LDAP_C lcache_result( LDAP *ld, int msgid, int all, + struct timeval *timeout, LDAPMessage **result ); +LDAP_API(int) LDAP_C lcache_flush( LDAP *ld, char *dn, char *filter ); + +#ifdef __cplusplus +} +#endif + +#endif /* _LCACHE_H */ diff --git a/ldap/c-sdk/include/ldap-deprecated.h b/ldap/c-sdk/include/ldap-deprecated.h new file mode 100644 index 000000000..4b219844e --- /dev/null +++ b/ldap/c-sdk/include/ldap-deprecated.h @@ -0,0 +1,201 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* ldap-deprecated.h - deprecated functions and declarations + * + * A deprecated API is an API that we recommend you no longer use, + * due to improvements in the LDAP C SDK. While deprecated APIs are + * currently still implemented, they may be removed in future + * implementations, and we recommend using other APIs. + * + * This file contain functions and declarations which have + * outlived their usefullness and have been deprecated. In many + * cases functions and declarations have been replaced with newer + * extended functions. In no way should applications rely on the + * declarations and defines within this files as they can and will + * disappear without any notice. + */ + +#ifndef _LDAP_DEPRECATED_H +#define _LDAP_DEPRECATED_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * establish an ldap session + */ +LDAP_API(LDAP *) LDAP_CALL ldap_open( const char *host, int port ); + +/* + * Authentication methods: + */ +#define LDAP_AUTH_NONE 0x00L +#define LDAP_AUTH_SIMPLE 0x80L +#define LDAP_AUTH_SASL 0xa3L +LDAP_API(int) LDAP_CALL ldap_bind( LDAP *ld, const char *who, + const char *passwd, int authmethod ); +LDAP_API(int) LDAP_CALL ldap_bind_s( LDAP *ld, const char *who, + const char *cred, int method ); + +LDAP_API(int) LDAP_CALL ldap_modrdn( LDAP *ld, const char *dn, + const char *newrdn ); +LDAP_API(int) LDAP_CALL ldap_modrdn_s( LDAP *ld, const char *dn, + const char *newrdn ); +LDAP_API(int) LDAP_CALL ldap_modrdn2( LDAP *ld, const char *dn, + const char *newrdn, int deleteoldrdn ); +LDAP_API(int) LDAP_CALL ldap_modrdn2_s( LDAP *ld, const char *dn, + const char *newrdn, int deleteoldrdn); + +LDAP_API(void) LDAP_CALL ldap_perror( LDAP *ld, const char *s ); +LDAP_API(int) LDAP_CALL ldap_result2error( LDAP *ld, LDAPMessage *r, + int freeit ); + +/* + * Preferred language and get_lang_values (an API extension -- + * LDAP_API_FEATURE_X_GETLANGVALUES) + * + * The following two APIs are deprecated + */ + +#define LDAP_OPT_PREFERRED_LANGUAGE 0x14 /* 20 - API extension */ +LDAP_API(char **) LDAP_CALL ldap_get_lang_values( LDAP *ld, LDAPMessage *entry, + const char *target, char **type ); +LDAP_API(struct berval **) LDAP_CALL ldap_get_lang_values_len( LDAP *ld, + LDAPMessage *entry, const char *target, char **type ); + +/* + * Asynchronous I/O (an API extension). + */ +/* + * This option enables completely asynchronous IO. It works by using ioctl() + * on the fd, (or tlook()) + */ +#define LDAP_OPT_ASYNC_CONNECT 0x63 /* 99 - API extension */ + +/* + * functions and definitions that have been replaced by new improved ones + */ +/* + * Use ldap_get_option() with LDAP_OPT_API_INFO and an LDAPAPIInfo structure + * instead of ldap_version(). + */ +typedef struct _LDAPVersion { + int sdk_version; /* Version of the SDK, * 100 */ + int protocol_version; /* Highest protocol version supported, * 100 */ + int SSL_version; /* SSL version if this SDK supports it, * 100 */ + int security_level; /* highest level available */ + int reserved[4]; +} LDAPVersion; +#define LDAP_SECURITY_NONE 0 +LDAP_API(int) LDAP_CALL ldap_version( LDAPVersion *ver ); + +/* use ldap_create_filter() instead of ldap_build_filter() */ +LDAP_API(void) LDAP_CALL ldap_build_filter( char *buf, unsigned long buflen, + char *pattern, char *prefix, char *suffix, char *attr, + char *value, char **valwords ); +/* use ldap_set_filter_additions() instead of ldap_setfilteraffixes() */ +LDAP_API(void) LDAP_CALL ldap_setfilteraffixes( LDAPFiltDesc *lfdp, + char *prefix, char *suffix ); + +/* older result types a server can return -- use LDAP_RES_MODDN instead */ +#define LDAP_RES_MODRDN LDAP_RES_MODDN +#define LDAP_RES_RENAME LDAP_RES_MODDN + +/* older error messages */ +#define LDAP_AUTH_METHOD_NOT_SUPPORTED LDAP_STRONG_AUTH_NOT_SUPPORTED + +/* + * Generalized cache callback interface: + */ +#define LDAP_OPT_CACHE_FN_PTRS 0x0D /* 13 - API extension */ +#define LDAP_OPT_CACHE_STRATEGY 0x0E /* 14 - API extension */ +#define LDAP_OPT_CACHE_ENABLE 0x0F /* 15 - API extension */ + +/* cache strategies */ +#define LDAP_CACHE_CHECK 0 +#define LDAP_CACHE_POPULATE 1 +#define LDAP_CACHE_LOCALDB 2 + +typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_BIND_CALLBACK)( LDAP *ld, int msgid, + unsigned long tag, const char *dn, const struct berval *creds, + int method); +typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_UNBIND_CALLBACK)( LDAP *ld, + int unused0, unsigned long unused1 ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_SEARCH_CALLBACK)( LDAP *ld, + int msgid, unsigned long tag, const char *base, int scope, + const char LDAP_CALLBACK *filter, char **attrs, int attrsonly ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_COMPARE_CALLBACK)( LDAP *ld, + int msgid, unsigned long tag, const char *dn, const char *attr, + const struct berval *value ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_ADD_CALLBACK)( LDAP *ld, + int msgid, unsigned long tag, const char *dn, LDAPMod **attrs ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_DELETE_CALLBACK)( LDAP *ld, + int msgid, unsigned long tag, const char *dn ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_MODIFY_CALLBACK)( LDAP *ld, + int msgid, unsigned long tag, const char *dn, LDAPMod **mods ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_MODRDN_CALLBACK)( LDAP *ld, + int msgid, unsigned long tag, const char *dn, const char *newrdn, + int deleteoldrdn ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_RESULT_CALLBACK)( LDAP *ld, + int msgid, int all, struct timeval *timeout, LDAPMessage **result ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_CF_FLUSH_CALLBACK)( LDAP *ld, + const char *dn, const char *filter ); + +struct ldap_cache_fns { + void *lcf_private; + LDAP_CF_BIND_CALLBACK *lcf_bind; + LDAP_CF_UNBIND_CALLBACK *lcf_unbind; + LDAP_CF_SEARCH_CALLBACK *lcf_search; + LDAP_CF_COMPARE_CALLBACK *lcf_compare; + LDAP_CF_ADD_CALLBACK *lcf_add; + LDAP_CF_DELETE_CALLBACK *lcf_delete; + LDAP_CF_MODIFY_CALLBACK *lcf_modify; + LDAP_CF_MODRDN_CALLBACK *lcf_modrdn; + LDAP_CF_RESULT_CALLBACK *lcf_result; + LDAP_CF_FLUSH_CALLBACK *lcf_flush; +}; + +LDAP_API(int) LDAP_CALL ldap_cache_flush( LDAP *ld, const char *dn, + const char *filter ); + + +#ifdef __cplusplus +} +#endif +#endif /* _LDAP_DEPRECATED_H */ diff --git a/ldap/c-sdk/include/ldap-extension.h b/ldap/c-sdk/include/ldap-extension.h new file mode 100644 index 000000000..7bbefdfb2 --- /dev/null +++ b/ldap/c-sdk/include/ldap-extension.h @@ -0,0 +1,853 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* ldap-extension.h - extensions to the ldap c api specification */ + +#ifndef _LDAP_EXTENSION_H +#define _LDAP_EXTENSION_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define LDAP_PORT_MAX 65535 /* API extension */ +#define LDAP_VERSION1 1 /* API extension */ +#define LDAP_VERSION LDAP_VERSION3 /* API extension */ + +/* + * C LDAP features we support that are not (yet) part of the LDAP C API + * Internet Draft. Use the ldap_get_option() call with an option value of + * LDAP_OPT_API_FEATURE_INFO to retrieve information about a feature. + * + * Note that this list is incomplete; it includes only the most widely + * used extensions. Also, the version is 1 for all of these for now. + */ +#define LDAP_API_FEATURE_SERVER_SIDE_SORT 1 +#define LDAP_API_FEATURE_VIRTUAL_LIST_VIEW 1 +#define LDAP_API_FEATURE_PERSISTENT_SEARCH 1 +#define LDAP_API_FEATURE_PROXY_AUTHORIZATION 1 +#define LDAP_API_FEATURE_X_LDERRNO 1 +#define LDAP_API_FEATURE_X_MEMCACHE 1 +#define LDAP_API_FEATURE_X_IO_FUNCTIONS 1 +#define LDAP_API_FEATURE_X_EXTIO_FUNCTIONS 1 +#define LDAP_API_FEATURE_X_DNS_FUNCTIONS 1 +#define LDAP_API_FEATURE_X_MEMALLOC_FUNCTIONS 1 +#define LDAP_API_FEATURE_X_THREAD_FUNCTIONS 1 +#define LDAP_API_FEATURE_X_EXTHREAD_FUNCTIONS 1 +#define LDAP_API_FEATURE_X_GETLANGVALUES 1 +#define LDAP_API_FEATURE_X_CLIENT_SIDE_SORT 1 +#define LDAP_API_FEATURE_X_URL_FUNCTIONS 1 +#define LDAP_API_FEATURE_X_FILTER_FUNCTIONS 1 + +#define LDAP_ROOT_DSE "" /* API extension */ + +#define LDAP_OPT_DESC 0x01 /* 1 */ + +#define NULLMSG ((LDAPMessage *)0) + +/*built-in SASL methods */ +#define LDAP_SASL_EXTERNAL "EXTERNAL" /* TLS/SSL extension */ + +/* possible error codes we can be returned */ +#define LDAP_PARTIAL_RESULTS 0x09 /* 9 (UMich LDAPv2 extn) */ +#define NAME_ERROR(n) ((n & 0xf0) == 0x20) + +#define LDAP_SORT_CONTROL_MISSING 0x3C /* 60 (server side sort extn) */ +#define LDAP_INDEX_RANGE_ERROR 0x3D /* 61 (VLV extn) */ + +/* + * LDAPv3 server controls we know about + */ +#define LDAP_CONTROL_MANAGEDSAIT "2.16.840.1.113730.3.4.2" +#define LDAP_CONTROL_SORTREQUEST "1.2.840.113556.1.4.473" +#define LDAP_CONTROL_SORTRESPONSE "1.2.840.113556.1.4.474" +#define LDAP_CONTROL_PERSISTENTSEARCH "2.16.840.1.113730.3.4.3" +#define LDAP_CONTROL_ENTRYCHANGE "2.16.840.1.113730.3.4.7" +#define LDAP_CONTROL_VLVREQUEST "2.16.840.1.113730.3.4.9" +#define LDAP_CONTROL_VLVRESPONSE "2.16.840.1.113730.3.4.10" +#define LDAP_CONTROL_PROXYAUTH "2.16.840.1.113730.3.4.12" /* version 1 +*/ +#define LDAP_CONTROL_PROXIEDAUTH "2.16.840.1.113730.3.4.18" /* version 2 +*/ + +/* Authorization Identity Request and Response Controls */ +#define LDAP_CONTROL_AUTHZID_REQ "2.16.840.1.113730.3.4.16" +#define LDAP_CONTROL_AUTHZID_RES "2.16.840.1.113730.3.4.15" + +/* Authentication request and response controls */ +#define LDAP_CONTROL_AUTH_REQUEST LDAP_CONTROL_AUTHZID_REQ +#define LDAP_CONTROL_AUTH_RESPONSE LDAP_CONTROL_AUTHZID_RES + +/* Password information sent back to client */ +#define LDAP_CONTROL_PWEXPIRED "2.16.840.1.113730.3.4.4" +#define LDAP_CONTROL_PWEXPIRING "2.16.840.1.113730.3.4.5" + +/* Password Policy Control */ +#define LDAP_CONTROL_PASSWD_POLICY "1.3.6.1.4.1.42.2.27.8.5.1" + +/* Password Policy Control compatibility macros */ +#define LDAP_X_CONTROL_PWPOLICY_REQUEST LDAP_CONTROL_PASSWD_POLICY +#define LDAP_X_CONTROL_PWPOLICY_RESPONSE LDAP_CONTROL_PASSWD_POLICY +#define LDAP_CONTROL_PASSWORDPOLICYREQUEST LDAP_CONTROL_PASSWD_POLICY +#define LDAP_CONTROL_PASSWORDPOLICYRESPONSE LDAP_CONTROL_PASSWD_POLICY + +/* Password Modify Extended Operation */ +#define LDAP_EXOP_MODIFY_PASSWD "1.3.6.1.4.1.4203.1.11.1" + +/* Suppress virtual/inherited attribute values */ +#define LDAP_CONTROL_REAL_ATTRS_ONLY "2.16.840.1.113730.3.4.17" + +/* Only return virtual/inherited attribute values */ +#define LDAP_CONTROL_VIRTUAL_ATTRS_ONLY "2.16.840.1.113730.3.4.19" + +/* getEffectiveRights request */ +#define LDAP_CONTROL_GETEFFECTIVERIGHTS_REQUEST "1.3.6.1.4.1.42.2.27.9.5.2" + +/* Password Policy Control to get account availability */ +#define LDAP_CONTROL_ACCOUNT_USABLE "1.3.6.1.4.1.42.2.27.9.5.8" + +/* "Who am I?" Extended Operation */ +#define LDAP_EXOP_WHO_AM_I "1.3.6.1.4.1.4203.1.11.3" + +LDAP_API(void) LDAP_CALL ldap_ber_free( BerElement *ber, int freebuf ); + +LDAP_API(LDAPControl *) LDAP_CALL ldap_find_control( const char *oid, + LDAPControl **ctrls ); + +/* + * Server side sorting of search results (an LDAPv3 extension -- + * LDAP_API_FEATURE_SERVER_SIDE_SORT) + */ +typedef struct LDAPsortkey { /* structure for a sort-key */ + char * sk_attrtype; + char * sk_matchruleoid; + int sk_reverseorder; +} LDAPsortkey; + +/* where LDAP_CONTROL_ACCOUNT_USABLE control parse results */ +typedef struct LDAPuserstatus { /* user account availability */ + unsigned int us_available; /* availability status */ +#define LDAP_US_ACCOUNT_USABLE 1 +#define LDAP_US_ACCOUNT_NOT_USABLE 0 + int us_expire; /* will expire in seconds */ + int us_inactive; /* boolean inactivation status */ +#define LDAP_US_ACCOUNT_ACTIVE 0 +#define LDAP_US_ACCOUNT_INACTIVE 1 + int us_reset; /* boolean password reset */ +#define LDAP_US_ACCOUNT_NOT_RESET 0 +#define LDAP_US_ACCOUNT_RESET 1 + int us_expired; /* boolean password expired */ +#define LDAP_US_ACCOUNT_NOT_EXPIRED 0 +#define LDAP_US_ACCOUNT_EXPIRED 1 + int us_remaining; /* remaining logins */ + int us_seconds; /* will unlock in seconds */ +} LDAPuserstatus; + +/* LDAP_CONTROL_PASSWD_POLICY results */ +typedef enum passpolicyerror_enum { + PP_passwordExpired = 0, + PP_accountLocked = 1, + PP_changeAfterReset = 2, + PP_passwordModNotAllowed = 3, + PP_mustSupplyOldPassword = 4, + PP_insufficientPasswordQuality = 5, + PP_passwordTooShort = 6, + PP_passwordTooYoung = 7, + PP_passwordInHistory = 8, + PP_noError = 65535 +} LDAPPasswordPolicyError; + +LDAP_API(int) LDAP_CALL ldap_create_sort_control( LDAP *ld, + LDAPsortkey **sortKeyList, const char ctl_iscritical, + LDAPControl **ctrlp ); +LDAP_API(int) LDAP_CALL ldap_parse_sort_control( LDAP *ld, + LDAPControl **ctrls, ber_int_t *result, char **attribute ); + +LDAP_API(void) LDAP_CALL ldap_free_sort_keylist( LDAPsortkey **sortKeyList ); +LDAP_API(int) LDAP_CALL ldap_create_sort_keylist( LDAPsortkey ***sortKeyList, + const char *string_rep ); + +LDAP_API(int) LDAP_CALL ldap_create_userstatus_control( + LDAP *ld, const char ctl_iscritical, LDAPControl **ctrlp ); +LDAP_API(int) LDAP_CALL ldap_parse_userstatus_control( LDAP *ld, + LDAPControl **ctrlp, LDAPuserstatus *us ); + +LDAP_API(int) LDAP_CALL ldap_create_passwordpolicy_control( LDAP *ld, + LDAPControl **ctrlp ); +LDAP_API(int) LDAP_CALL ldap_create_passwordpolicy_control_ext( LDAP *ld, + const char ctl_iscritical, LDAPControl **ctrlp ); +LDAP_API(int) LDAP_CALL ldap_parse_passwordpolicy_control( LDAP *ld, + LDAPControl *ctrlp, ber_int_t *expirep, ber_int_t *gracep, + LDAPPasswordPolicyError *errorp ); +LDAP_API(int) LDAP_CALL ldap_parse_passwordpolicy_control_ext ( LDAP *ld, + LDAPControl **ctrlp, ber_int_t *expirep, ber_int_t *gracep, + LDAPPasswordPolicyError *errorp ); +LDAP_API(const char *) LDAP_CALL ldap_passwordpolicy_err2txt( + LDAPPasswordPolicyError err ); + +LDAP_API(int) LDAP_CALL ldap_create_authzid_control( LDAP *ld, + const char ctl_iscritical, LDAPControl **ctrlp ); +LDAP_API(int) LDAP_CALL ldap_parse_authzid_control( LDAP *ld, + LDAPControl **ctrlp, char **authzid ); + +LDAP_API(int) LDAP_CALL ldap_whoami( LDAP *ld, LDAPControl **serverctrls, + LDAPControl **clientctrls, int *msgidp ); +LDAP_API(int) LDAP_CALL ldap_whoami_s( LDAP *ld, struct berval **authzid, + LDAPControl **serverctrls, LDAPControl **clientctrls ); +LDAP_API(int) LDAP_CALL ldap_parse_whoami( LDAP *ld, LDAPMessage *result, + struct berval **authzid ); + +LDAP_API(int) LDAP_CALL ldap_create_geteffectiveRights_control( LDAP *ld, + const char *authzid, const char **attrlist, const char ctl_iscritical, + LDAPControl **ctrlp ); + +/* + * Virtual list view (an LDAPv3 extension -- LDAP_API_FEATURE_VIRTUAL_LIST_VIEW) + */ +/* + * structure that describes a VirtualListViewRequest control. + * note that ldvlist_index and ldvlist_size are only relevant to + * ldap_create_virtuallist_control() if ldvlist_attrvalue is NULL. + */ +typedef struct ldapvirtuallist { + ber_int_t ldvlist_before_count; /* # entries before target */ + ber_int_t ldvlist_after_count; /* # entries after target */ + char *ldvlist_attrvalue; /* jump to this value */ + ber_int_t ldvlist_index; /* list offset */ + ber_int_t ldvlist_size; /* number of items in vlist */ + void *ldvlist_extradata; /* for use by application */ +} LDAPVirtualList; + +/* + * VLV functions: + */ +LDAP_API(int) LDAP_CALL ldap_create_virtuallist_control( LDAP *ld, + LDAPVirtualList *ldvlistp, LDAPControl **ctrlp ); + +LDAP_API(int) LDAP_CALL ldap_parse_virtuallist_control( LDAP *ld, + LDAPControl **ctrls, ber_int_t *target_posp, + ber_int_t *list_sizep, int *errcodep ); + +/* + * Routines for creating persistent search controls and for handling + * "entry changed notification" controls (an LDAPv3 extension -- + * LDAP_API_FEATURE_PERSISTENT_SEARCH) + */ +#define LDAP_CHANGETYPE_ADD 1 +#define LDAP_CHANGETYPE_DELETE 2 +#define LDAP_CHANGETYPE_MODIFY 4 +#define LDAP_CHANGETYPE_MODDN 8 +#define LDAP_CHANGETYPE_ANY (1|2|4|8) +LDAP_API(int) LDAP_CALL ldap_create_persistentsearch_control( LDAP *ld, + int changetypes, int changesonly, int return_echg_ctls, + char ctl_iscritical, LDAPControl **ctrlp ); +LDAP_API(int) LDAP_CALL ldap_parse_entrychange_control( LDAP *ld, + LDAPControl **ctrls, ber_int_t *chgtypep, char **prevdnp, + int *chgnumpresentp, ber_int_t *chgnump ); + +/* + * Routines for creating Proxied Authorization controls (an LDAPv3 + * extension -- LDAP_API_FEATURE_PROXY_AUTHORIZATION) + * ldap_create_proxyauth_control() is for the old (version 1) control. + * ldap_create_proxiedauth_control() is for the newer (version 2) control. + */ +LDAP_API(int) LDAP_CALL ldap_create_proxyauth_control( LDAP *ld, + const char *dn, const char ctl_iscritical, LDAPControl **ctrlp ); +LDAP_API(int) LDAP_CALL ldap_create_proxiedauth_control( LDAP *ld, + const char *authzid, LDAPControl **ctrlp ); + +/* + * Functions to get and set LDAP error information (API extension -- + * LDAP_API_FEATURE_X_LDERRNO ) + * + * By using LDAP_OPT_THREAD_FN_PTRS, you can arrange for the error info. to + * be thread-specific. + */ +LDAP_API(int) LDAP_CALL ldap_get_lderrno( LDAP *ld, char **m, char **s ); +LDAP_API(int) LDAP_CALL ldap_set_lderrno( LDAP *ld, int e, char *m, char *s ); + + +/* + * LDAP URL functions and definitions (an API extension -- + * LDAP_API_FEATURE_X_URL_FUNCTIONS) + */ +/* + * types for ldap URL handling + */ +typedef struct ldap_url_desc { + char *lud_host; + int lud_port; + char *lud_dn; + char **lud_attrs; + int lud_scope; + char *lud_filter; + unsigned long lud_options; +#define LDAP_URL_OPT_SECURE 0x01 + char *lud_string; /* for internal use only */ +} LDAPURLDesc; + +#define NULLLDAPURLDESC ((LDAPURLDesc *)NULL) + +/* + * possible errors returned by ldap_url_parse() + */ +#define LDAP_URL_ERR_NOTLDAP 1 /* URL doesn't begin with "ldap://" */ +#define LDAP_URL_ERR_NODN 2 /* URL has no DN (required) */ +#define LDAP_URL_ERR_BADSCOPE 3 /* URL scope string is invalid */ +#define LDAP_URL_ERR_MEM 4 /* can't allocate memory space */ +#define LDAP_URL_ERR_PARAM 5 /* bad parameter to an URL function */ +#define LDAP_URL_UNRECOGNIZED_CRITICAL_EXTENSION 6 + +/* + * URL functions: + */ +LDAP_API(int) LDAP_CALL ldap_is_ldap_url( const char *url ); +LDAP_API(int) LDAP_CALL ldap_url_parse( const char *url, LDAPURLDesc **ludpp ); +LDAP_API(int) LDAP_CALL ldap_url_parse_no_defaults( const char *url, + LDAPURLDesc **ludpp, int dn_required); +LDAP_API(void) LDAP_CALL ldap_free_urldesc( LDAPURLDesc *ludp ); +LDAP_API(int) LDAP_CALL ldap_url_search( LDAP *ld, const char *url, + int attrsonly ); +LDAP_API(int) LDAP_CALL ldap_url_search_s( LDAP *ld, const char *url, + int attrsonly, LDAPMessage **res ); +LDAP_API(int) LDAP_CALL ldap_url_search_st( LDAP *ld, const char *url, + int attrsonly, struct timeval *timeout, LDAPMessage **res ); + + +/* + * Function to dispose of an array of LDAPMod structures (an API extension). + * Warning: don't use this unless the mods array was allocated using the + * same memory allocator as is being used by libldap. + */ +LDAP_API(void) LDAP_CALL ldap_mods_free( LDAPMod **mods, int freemods ); + +/* + * SSL option (an API extension): + */ +#define LDAP_OPT_SSL 0x0A /* 10 - API extension */ + +/* + * Referral hop limit (an API extension): + */ +#define LDAP_OPT_REFERRAL_HOP_LIMIT 0x10 /* 16 - API extension */ + +/* + * Rebind callback function (an API extension) + */ +#define LDAP_OPT_REBIND_FN 0x06 /* 6 - API extension */ +#define LDAP_OPT_REBIND_ARG 0x07 /* 7 - API extension */ +typedef int (LDAP_CALL LDAP_CALLBACK LDAP_REBINDPROC_CALLBACK)( LDAP *ld, + char **dnp, char **passwdp, int *authmethodp, int freeit, void *arg); +LDAP_API(void) LDAP_CALL ldap_set_rebind_proc( LDAP *ld, + LDAP_REBINDPROC_CALLBACK *rebindproc, void *arg ); + +/* + * Thread function callbacks (an API extension -- + * LDAP_API_FEATURE_X_THREAD_FUNCTIONS). + */ +#define LDAP_OPT_THREAD_FN_PTRS 0x05 /* 5 - API extension */ + +/* + * Thread callback functions: + */ +typedef void *(LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_ALLOC_CALLBACK)( void ); +typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_FREE_CALLBACK)( void *m ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_LOCK_CALLBACK)( void *m ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_UNLOCK_CALLBACK)( void *m ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_GET_ERRNO_CALLBACK)( void ); +typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_SET_ERRNO_CALLBACK)( int e ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_GET_LDERRNO_CALLBACK)( + char **matchedp, char **errmsgp, void *arg ); +typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_SET_LDERRNO_CALLBACK)( int err, + char *matched, char *errmsg, void *arg ); + +/* + * Structure to hold thread function pointers: + */ +struct ldap_thread_fns { + LDAP_TF_MUTEX_ALLOC_CALLBACK *ltf_mutex_alloc; + LDAP_TF_MUTEX_FREE_CALLBACK *ltf_mutex_free; + LDAP_TF_MUTEX_LOCK_CALLBACK *ltf_mutex_lock; + LDAP_TF_MUTEX_UNLOCK_CALLBACK *ltf_mutex_unlock; + LDAP_TF_GET_ERRNO_CALLBACK *ltf_get_errno; + LDAP_TF_SET_ERRNO_CALLBACK *ltf_set_errno; + LDAP_TF_GET_LDERRNO_CALLBACK *ltf_get_lderrno; + LDAP_TF_SET_LDERRNO_CALLBACK *ltf_set_lderrno; + void *ltf_lderrno_arg; +}; + +/* + * Extended I/O function callbacks option (an API extension -- + * LDAP_API_FEATURE_X_EXTIO_FUNCTIONS). + */ +#define LDAP_X_OPT_EXTIO_FN_PTRS (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F00) + /* 0x4000 + 0x0F00 = 0x4F00 = 20224 - API extension */ + +/* Additional Extended I/O function callback option (for Extended Socket Arg callback) */ +#define LDAP_X_OPT_SOCKETARG (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F02) + /* 0x4000 + 0x0F02 = 0x4F02 = 20226 - API extension */ + +/* + * These extended I/O function callbacks echo the BSD socket API but accept + * an extra pointer parameter at the end of their argument list that can + * be used by client applications for their own needs. For some of the calls, + * the pointer is a session argument of type struct lextiof_session_private * + * that is associated with the LDAP session handle (LDAP *). For others, the + * pointer is a socket specific struct lextiof_socket_private * argument that + * is associated with a particular socket (a TCP connection). + * + * The lextiof_session_private and lextiof_socket_private structures are not + * defined by the LDAP C API; users of this extended I/O interface should + * define these themselves. + * + * The combination of the integer socket number (i.e., lpoll_fd, which is + * the value returned by the CONNECT callback) and the application specific + * socket argument (i.e., lpoll_socketarg, which is the value set in *sockargpp + * by the CONNECT callback) must be unique. + * + * The types for the extended READ and WRITE callbacks are actually in lber.h. + * + * The CONNECT callback gets passed both the session argument (sessionarg) + * and a pointer to a socket argument (socketargp) so it has the + * opportunity to set the socket-specific argument. The CONNECT callback + * also takes a timeout parameter whose value can be set by calling + * ldap_set_option( ld, LDAP_X_OPT_..., &val ). The units used for the + * timeout parameter are milliseconds. + * + * A POLL interface is provided instead of a select() one. The timeout is + * in milliseconds. + * + * A NEWHANDLE callback function is also provided. It is called right + * after the LDAP session handle is created, e.g., during ldap_init(). + * If the NEWHANDLE callback returns anything other than LDAP_SUCCESS, + * the session handle allocation fails. + * + * A DISPOSEHANDLE callback function is also provided. It is called right + * before the LDAP session handle and its contents are destroyed, e.g., + * during ldap_unbind(). + */ + +/* + * Special timeout values for poll and connect: + */ +#define LDAP_X_IO_TIMEOUT_NO_WAIT 0 /* return immediately */ +#define LDAP_X_IO_TIMEOUT_NO_TIMEOUT (-1) /* block indefinitely */ + +/* LDAP poll()-like descriptor: + */ +typedef struct ldap_x_pollfd { /* used by LDAP_X_EXTIOF_POLL_CALLBACK */ + int lpoll_fd; /* integer file descriptor / socket */ + struct lextiof_socket_private + *lpoll_socketarg; + /* pointer socket and for use by */ + /* application */ + short lpoll_events; /* requested event */ + short lpoll_revents; /* returned event */ +} LDAP_X_PollFD; + +/* Event flags for lpoll_events and lpoll_revents: + */ +#define LDAP_X_POLLIN 0x01 /* regular data ready for reading */ +#define LDAP_X_POLLPRI 0x02 /* high priority data available */ +#define LDAP_X_POLLOUT 0x04 /* ready for writing */ +#define LDAP_X_POLLERR 0x08 /* error occurred -- only in lpoll_revents */ +#define LDAP_X_POLLHUP 0x10 /* connection closed -- only in lpoll_revents */ +#define LDAP_X_POLLNVAL 0x20 /* invalid lpoll_fd -- only in lpoll_revents */ + +/* Options passed to LDAP_X_EXTIOF_CONNECT_CALLBACK to modify socket behavior: + */ +#define LDAP_X_EXTIOF_OPT_NONBLOCKING 0x01 /* turn on non-blocking mode */ +#define LDAP_X_EXTIOF_OPT_SECURE 0x02 /* turn on 'secure' mode */ + + +/* extended I/O callback function prototypes: + */ +typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_CONNECT_CALLBACK )( + const char *hostlist, int port, /* host byte order */ + int timeout /* milliseconds */, + unsigned long options, /* bitmapped options */ + struct lextiof_session_private *sessionarg, + struct lextiof_socket_private **socketargp ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_CLOSE_CALLBACK )( + int s, struct lextiof_socket_private *socketarg ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_POLL_CALLBACK)( + LDAP_X_PollFD fds[], int nfds, int timeout /* milliseconds */, + struct lextiof_session_private *sessionarg ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_NEWHANDLE_CALLBACK)( + LDAP *ld, struct lextiof_session_private *sessionarg ); +typedef void (LDAP_C LDAP_CALLBACK LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK)( + LDAP *ld, struct lextiof_session_private *sessionarg ); + + +/* Structure to hold extended I/O function pointers: + */ +struct ldap_x_ext_io_fns { + /* lextiof_size should always be set to LDAP_X_EXTIO_FNS_SIZE */ + int lextiof_size; + LDAP_X_EXTIOF_CONNECT_CALLBACK *lextiof_connect; + LDAP_X_EXTIOF_CLOSE_CALLBACK *lextiof_close; + LDAP_X_EXTIOF_READ_CALLBACK *lextiof_read; + LDAP_X_EXTIOF_WRITE_CALLBACK *lextiof_write; + LDAP_X_EXTIOF_POLL_CALLBACK *lextiof_poll; + LDAP_X_EXTIOF_NEWHANDLE_CALLBACK *lextiof_newhandle; + LDAP_X_EXTIOF_DISPOSEHANDLE_CALLBACK *lextiof_disposehandle; + void *lextiof_session_arg; + LDAP_X_EXTIOF_WRITEV_CALLBACK *lextiof_writev; +}; +#define LDAP_X_EXTIO_FNS_SIZE sizeof(struct ldap_x_ext_io_fns) + +/* + * Utility functions for parsing space-separated host lists (useful for + * implementing an extended I/O CONNECT callback function). + */ +struct ldap_x_hostlist_status; +LDAP_API(int) LDAP_CALL ldap_x_hostlist_first( const char *hostlist, + int defport, char **hostp, int *portp /* host byte order */, + struct ldap_x_hostlist_status **statusp ); +LDAP_API(int) LDAP_CALL ldap_x_hostlist_next( char **hostp, + int *portp /* host byte order */, struct ldap_x_hostlist_status *status +); +LDAP_API(void) LDAP_CALL ldap_x_hostlist_statusfree( + struct ldap_x_hostlist_status *status ); + +/* + * Client side sorting of entries (an API extension -- + * LDAP_API_FEATURE_X_CLIENT_SIDE_SORT) + */ +/* + * Client side sorting callback functions: + */ +typedef const struct berval* (LDAP_C LDAP_CALLBACK + LDAP_KEYGEN_CALLBACK)( void *arg, LDAP *ld, LDAPMessage *entry ); +typedef int (LDAP_C LDAP_CALLBACK + LDAP_KEYCMP_CALLBACK)( void *arg, const struct berval*, + const struct berval* ); +typedef void (LDAP_C LDAP_CALLBACK + LDAP_KEYFREE_CALLBACK)( void *arg, const struct berval* ); +typedef int (LDAP_C LDAP_CALLBACK + LDAP_CMP_CALLBACK)(const char *val1, const char *val2); +typedef int (LDAP_C LDAP_CALLBACK + LDAP_VALCMP_CALLBACK)(const char **val1p, const char **val2p); + +/* + * Client side sorting functions: + */ +LDAP_API(int) LDAP_CALL ldap_keysort_entries( LDAP *ld, LDAPMessage **chain, + void *arg, LDAP_KEYGEN_CALLBACK *gen, LDAP_KEYCMP_CALLBACK *cmp, + LDAP_KEYFREE_CALLBACK *fre ); +LDAP_API(int) LDAP_CALL ldap_multisort_entries( LDAP *ld, LDAPMessage **chain, + char **attr, LDAP_CMP_CALLBACK *cmp ); +LDAP_API(int) LDAP_CALL ldap_sort_entries( LDAP *ld, LDAPMessage **chain, + char *attr, LDAP_CMP_CALLBACK *cmp ); +LDAP_API(int) LDAP_CALL ldap_sort_values( LDAP *ld, char **vals, + LDAP_VALCMP_CALLBACK *cmp ); +LDAP_API(int) LDAP_C LDAP_CALLBACK ldap_sort_strcasecmp( const char **a, + const char **b ); + + +/* + * Filter functions and definitions (an API extension -- + * LDAP_API_FEATURE_X_FILTER_FUNCTIONS) + */ +/* + * Structures, constants, and types for filter utility routines: + */ +typedef struct ldap_filt_info { + char *lfi_filter; + char *lfi_desc; + int lfi_scope; /* LDAP_SCOPE_BASE, etc */ + int lfi_isexact; /* exact match filter? */ + struct ldap_filt_info *lfi_next; +} LDAPFiltInfo; + +#define LDAP_FILT_MAXSIZ 1024 + +typedef struct ldap_filt_list LDAPFiltList; /* opaque filter list handle */ +typedef struct ldap_filt_desc LDAPFiltDesc; /* opaque filter desc handle */ + +/* + * Filter utility functions: + */ +LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_init_getfilter( char *fname ); +LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_init_getfilter_buf( char *buf, + long buflen ); +LDAP_API(LDAPFiltInfo *) LDAP_CALL ldap_getfirstfilter( LDAPFiltDesc *lfdp, + char *tagpat, char *value ); +LDAP_API(LDAPFiltInfo *) LDAP_CALL ldap_getnextfilter( LDAPFiltDesc *lfdp ); +LDAP_API(int) LDAP_CALL ldap_set_filter_additions( LDAPFiltDesc *lfdp, + char *prefix, char *suffix ); +LDAP_API(int) LDAP_CALL ldap_create_filter( char *buf, unsigned long buflen, + char *pattern, char *prefix, char *suffix, char *attr, + char *value, char **valwords ); +LDAP_API(void) LDAP_CALL ldap_getfilter_free( LDAPFiltDesc *lfdp ); + +/* + * Friendly mapping structure and routines (an API extension) + */ +typedef struct friendly { + char *f_unfriendly; + char *f_friendly; +} *FriendlyMap; +LDAP_API(char *) LDAP_CALL ldap_friendly_name( char *filename, char *name, + FriendlyMap *map ); +LDAP_API(void) LDAP_CALL ldap_free_friendlymap( FriendlyMap *map ); + +/* + * In Memory Cache (an API extension -- LDAP_API_FEATURE_X_MEMCACHE) + */ +typedef struct ldapmemcache LDAPMemCache; /* opaque in-memory cache handle */ + +LDAP_API(int) LDAP_CALL ldap_memcache_init( unsigned long ttl, + unsigned long size, char **baseDNs, struct ldap_thread_fns *thread_fns, + LDAPMemCache **cachep ); +LDAP_API(int) LDAP_CALL ldap_memcache_set( LDAP *ld, LDAPMemCache *cache ); +LDAP_API(int) LDAP_CALL ldap_memcache_get( LDAP *ld, LDAPMemCache **cachep ); +LDAP_API(void) LDAP_CALL ldap_memcache_flush( LDAPMemCache *cache, char *dn, + int scope ); +LDAP_API(void) LDAP_CALL ldap_memcache_flush_results( LDAPMemCache *cache, + char *dn, int scope ); +LDAP_API(void) LDAP_CALL ldap_memcache_destroy( LDAPMemCache *cache ); +LDAP_API(void) LDAP_CALL ldap_memcache_update( LDAPMemCache *cache ); + +/* + * Timeout value for nonblocking connect call + */ +#define LDAP_X_OPT_CONNECT_TIMEOUT (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F01) + /* 0x4000 + 0x0F01 = 0x4F01 = 20225 - API extension */ + +/* + * Socket buffer structure associated to the LDAP connection + */ +#define LDAP_X_OPT_SOCKBUF (LDAP_OPT_PRIVATE_EXTENSION_BASE + 0x0F03) + /* 0x4000 + 0x0F03 = 0x4F03 = 20227 - API extension */ + +/* + * Memory allocation callback functions (an API extension -- + * LDAP_API_FEATURE_X_MEMALLOC_FUNCTIONS). These are global and can + * not be set on a per-LDAP session handle basis. Install your own + * functions by making a call like this: + * ldap_set_option( NULL, LDAP_OPT_MEMALLOC_FN_PTRS, &memalloc_fns ); + * + * look in lber.h for the function typedefs themselves. + */ +#define LDAP_OPT_MEMALLOC_FN_PTRS 0x61 /* 97 - API extension */ + +struct ldap_memalloc_fns { + LDAP_MALLOC_CALLBACK *ldapmem_malloc; + LDAP_CALLOC_CALLBACK *ldapmem_calloc; + LDAP_REALLOC_CALLBACK *ldapmem_realloc; + LDAP_FREE_CALLBACK *ldapmem_free; +}; + + +/* + * Memory allocation functions (an API extension) + */ +void *ldap_x_malloc( size_t size ); +void *ldap_x_calloc( size_t nelem, size_t elsize ); +void *ldap_x_realloc( void *ptr, size_t size ); +void ldap_x_free( void *ptr ); + +/* + * Server reconnect (an API extension). + */ +#define LDAP_OPT_RECONNECT 0x62 /* 98 - API extension */ + + +/* + * Extra thread callback functions (an API extension -- + * LDAP_API_FEATURE_X_EXTHREAD_FUNCTIONS) + */ +#define LDAP_OPT_EXTRA_THREAD_FN_PTRS 0x65 /* 101 - API extension */ + +/* + * When bind is called, don't bind if there's a connection open with the same DN + */ +#define LDAP_OPT_NOREBIND 0x66 /* 102 - API extension */ + +typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_MUTEX_TRYLOCK_CALLBACK)( void *m ); +typedef void *(LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_ALLOC_CALLBACK)( void ); +typedef void (LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_FREE_CALLBACK)( void *s ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_WAIT_CALLBACK)( void *s ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_TF_SEMA_POST_CALLBACK)( void *s ); +typedef void *(LDAP_C LDAP_CALLBACK LDAP_TF_THREADID_CALLBACK)(void); + +struct ldap_extra_thread_fns { + LDAP_TF_MUTEX_TRYLOCK_CALLBACK *ltf_mutex_trylock; + LDAP_TF_SEMA_ALLOC_CALLBACK *ltf_sema_alloc; + LDAP_TF_SEMA_FREE_CALLBACK *ltf_sema_free; + LDAP_TF_SEMA_WAIT_CALLBACK *ltf_sema_wait; + LDAP_TF_SEMA_POST_CALLBACK *ltf_sema_post; + LDAP_TF_THREADID_CALLBACK *ltf_threadid_fn; +}; + +/* + * Debugging level (an API extension) + */ +#define LDAP_OPT_DEBUG_LEVEL 0x6E /* 110 - API extension */ +/* On UNIX, there's only one copy of ldap_debug */ +/* On NT, each dll keeps its own module_ldap_debug, which */ +/* points to the process' ldap_debug and needs initializing after load */ +#ifdef _WIN32 +extern int *module_ldap_debug; +typedef void (*set_debug_level_fn_t)(int*); +#endif + +#ifdef LDAP_DNS +#define LDAP_OPT_DNS 0x0C /* 12 - API extension */ +#endif + +/* + * UTF-8 routines (should these move into libnls?) + */ +/* number of bytes in character */ +LDAP_API(int) LDAP_CALL ldap_utf8len( const char* ); +/* find next character */ +LDAP_API(char*) LDAP_CALL ldap_utf8next( char* ); +/* find previous character */ +LDAP_API(char*) LDAP_CALL ldap_utf8prev( char* ); +/* copy one character */ +LDAP_API(int) LDAP_CALL ldap_utf8copy( char* dst, const char* src ); +/* total number of characters */ +LDAP_API(size_t) LDAP_CALL ldap_utf8characters( const char* ); +/* get one UCS-4 character, and move *src to the next character */ +LDAP_API(unsigned long) LDAP_CALL ldap_utf8getcc( const char** src ); +/* UTF-8 aware strtok_r() */ +LDAP_API(char*) LDAP_CALL ldap_utf8strtok_r( char* src, const char* brk, char** +next); + +/* like isalnum(*s) in the C locale */ +LDAP_API(int) LDAP_CALL ldap_utf8isalnum( char* s ); +/* like isalpha(*s) in the C locale */ +LDAP_API(int) LDAP_CALL ldap_utf8isalpha( char* s ); +/* like isdigit(*s) in the C locale */ +LDAP_API(int) LDAP_CALL ldap_utf8isdigit( char* s ); +/* like isxdigit(*s) in the C locale */ +LDAP_API(int) LDAP_CALL ldap_utf8isxdigit(char* s ); +/* like isspace(*s) in the C locale */ +LDAP_API(int) LDAP_CALL ldap_utf8isspace( char* s ); + +#define LDAP_UTF8LEN(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8len (s) : 1) +#define LDAP_UTF8NEXT(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8next(s) : ( s)+1) +#define LDAP_UTF8INC(s) ((0x80 & *(unsigned char*)(s)) ? s=ldap_utf8next(s) : ++s) + +#define LDAP_UTF8PREV(s) ldap_utf8prev(s) +#define LDAP_UTF8DEC(s) (s=ldap_utf8prev(s)) + +#define LDAP_UTF8COPY(d,s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8copy(d,s) : ((*(d) = *(s)), 1)) +#define LDAP_UTF8GETCC(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8getcc (&s) : *s++) +#define LDAP_UTF8GETC(s) ((0x80 & *(unsigned char*)(s)) ? ldap_utf8getcc ((const char**)&s) : *s++) + +/* SASL options */ +#define LDAP_OPT_X_SASL_MECH 0x6100 +#define LDAP_OPT_X_SASL_REALM 0x6101 +#define LDAP_OPT_X_SASL_AUTHCID 0x6102 +#define LDAP_OPT_X_SASL_AUTHZID 0x6103 +#define LDAP_OPT_X_SASL_SSF 0x6104 /* read-only */ +#define LDAP_OPT_X_SASL_SSF_EXTERNAL 0x6105 /* write-only */ +#define LDAP_OPT_X_SASL_SECPROPS 0x6106 /* write-only */ +#define LDAP_OPT_X_SASL_SSF_MIN 0x6107 +#define LDAP_OPT_X_SASL_SSF_MAX 0x6108 +#define LDAP_OPT_X_SASL_MAXBUFSIZE 0x6109 + +/* ldap_interactive_bind_s Interaction flags + * Interactive: prompt always - REQUIRED + */ +#define LDAP_SASL_AUTOMATIC 0U /* only prompt for missing items not supplied as defaults */ +#define LDAP_SASL_INTERACTIVE 1U /* prompt for everything and print defaults, if any */ +#define LDAP_SASL_QUIET 2U /* no prompts - only use defaults (e.g. for non-interactive apps) */ + +/* + * V3 SASL Interaction Function Callback Prototype + * when using Cyrus SASL, interact is pointer to sasl_interact_t + * should likely passed in a control (and provided controls) + */ +typedef int (LDAP_SASL_INTERACT_PROC) + (LDAP *ld, unsigned flags, void* defaults, void *interact ); + +LDAP_API(int) LDAP_CALL ldap_sasl_interactive_bind_s ( + LDAP *ld, + const char *dn, /* usually NULL */ + const char *saslMechanism, + LDAPControl **serverControls, + LDAPControl **clientControls, + + /* should be client controls */ + unsigned flags, + LDAP_SASL_INTERACT_PROC *proc, + void *defaults ); + +LDAP_API(int) LDAP_CALL ldap_sasl_interactive_bind_ext_s ( + LDAP *ld, + const char *dn, /* usually NULL */ + const char *saslMechanism, + LDAPControl **serverControls, + LDAPControl **clientControls, + + /* should be client controls */ + unsigned flags, + LDAP_SASL_INTERACT_PROC *proc, + void *defaults, + LDAPControl ***responseControls ); + +/* + * Password modify functions + */ +LDAP_API(int) LDAP_CALL ldap_passwd( LDAP *ld, struct berval *userid, + struct berval *oldpasswd, struct berval *newpasswd, + LDAPControl **serverctrls, LDAPControl **clientctrls, + int *msgidp ); + +LDAP_API(int) LDAP_CALL ldap_passwd_s( LDAP *ld, struct berval *userid, + struct berval *oldpasswd, struct berval *newpasswd, + struct berval *genpasswd, LDAPControl **serverctrls, + LDAPControl **clientctrls ); + +LDAP_API(int) LDAP_CALL ldap_parse_passwd( LDAP *ld, LDAPMessage *result, + struct berval *genpasswd ); + +/* + * in reslist.c + */ +LDAP_API(LDAPMessage *) LDAP_CALL ldap_delete_result_entry( LDAPMessage **list, LDAPMessage *e ); +LDAP_API(void) LDAP_CALL ldap_add_result_entry( LDAPMessage **list, LDAPMessage *e ); + +#ifdef __cplusplus +} +#endif +#endif /* _LDAP_EXTENSION_H */ + diff --git a/ldap/c-sdk/include/ldap-platform.h b/ldap/c-sdk/include/ldap-platform.h new file mode 100644 index 000000000..fee8fcf66 --- /dev/null +++ b/ldap/c-sdk/include/ldap-platform.h @@ -0,0 +1,91 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* ldap-platform.h - platform transparency */ + +#ifndef _LDAP_PLATFORM_H +#define _LDAP_PLATFORM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined (WIN32) || defined (_WIN32) || defined( _CONSOLE ) +#include <windows.h> +# if defined( _WINDOWS ) +# include <winsock.h> +# endif +#elif defined(macintosh) +#ifndef LDAP_TYPE_TIMEVAL_DEFINED +#include <utime.h> +#endif +#ifndef LDAP_TYPE_SOCKET_DEFINED /* API extension */ +#include "macsocket.h" +#endif +#else /* everything else, e.g., Unix */ +#ifndef LDAP_TYPE_TIMEVAL_DEFINED +#include <sys/time.h> +#endif +#ifndef LDAP_TYPE_SOCKET_DEFINED /* API extension */ +#include <sys/types.h> +#include <sys/socket.h> +#endif +#endif + +#ifdef _AIX +#include <sys/select.h> +#endif /* _AIX */ + +#ifdef XP_OS2 +#include <sys/select.h> +#endif /* XP_OS2 */ + +/* + * LDAP_API macro definition: + */ +#ifndef LDAP_API +#if defined( _WINDOWS ) || defined( _WIN32 ) +#define LDAP_API(rt) rt +#else /* _WINDOWS */ +#define LDAP_API(rt) rt +#endif /* _WINDOWS */ +#endif /* LDAP_API */ + +#ifdef __cplusplus +} +#endif +#endif /* _LDAP_PLATFORM_H */ diff --git a/ldap/c-sdk/include/ldap-standard.h b/ldap/c-sdk/include/ldap-standard.h new file mode 100644 index 000000000..7e632cb1e --- /dev/null +++ b/ldap/c-sdk/include/ldap-standard.h @@ -0,0 +1,457 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* ldap-standard.h - standards base header file for libldap */ +/* This file contain the defines and function prototypes matching */ +/* very closely to the latest LDAP C API draft */ + +#ifndef _LDAP_STANDARD_H +#define _LDAP_STANDARD_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ldap-platform.h" + +#include "lber.h" + +#define LDAP_PORT 389 +#define LDAPS_PORT 636 +#define LDAP_VERSION2 2 +#define LDAP_VERSION3 3 +#define LDAP_VERSION_MIN LDAP_VERSION1 +#define LDAP_VERSION_MAX LDAP_VERSION3 + +#define LDAP_VENDOR_VERSION 607 /* version # * 100 */ +#define LDAP_VENDOR_NAME "mozilla.org" +/* + * The following will be an RFC number once the LDAP C API Internet Draft + * is published as a Proposed Standard RFC. For now we use 2000 + the + * draft revision number (currently 5) since we are close to compliance + * with revision 5 of the draft. + */ +#define LDAP_API_VERSION 2005 + +/* special values that may appear in the attributes field of a SearchRequest. + */ +#define LDAP_NO_ATTRS "1.1" +#define LDAP_ALL_USER_ATTRS "*" + +/* + * Standard options (used with ldap_set_option() and ldap_get_option): + */ +#define LDAP_OPT_API_INFO 0x00 /* 0 */ +#define LDAP_OPT_DEREF 0x02 /* 2 */ +#define LDAP_OPT_SIZELIMIT 0x03 /* 3 */ +#define LDAP_OPT_TIMELIMIT 0x04 /* 4 */ +#define LDAP_OPT_REFERRALS 0x08 /* 8 */ +#define LDAP_OPT_RESTART 0x09 /* 9 */ +#define LDAP_OPT_PROTOCOL_VERSION 0x11 /* 17 */ +#define LDAP_OPT_SERVER_CONTROLS 0x12 /* 18 */ +#define LDAP_OPT_CLIENT_CONTROLS 0x13 /* 19 */ +#define LDAP_OPT_API_FEATURE_INFO 0x15 /* 21 */ +#define LDAP_OPT_HOST_NAME 0x30 /* 48 */ +#define LDAP_OPT_ERROR_NUMBER 0x31 /* 49 */ +#define LDAP_OPT_ERROR_STRING 0x32 /* 50 */ +#define LDAP_OPT_MATCHED_DN 0x33 /* 51 */ + +/* + * Well-behaved private and experimental extensions will use option values + * between 0x4000 (16384) and 0x7FFF (32767) inclusive. + */ +#define LDAP_OPT_PRIVATE_EXTENSION_BASE 0x4000 /* to 0x7FFF inclusive */ + +/* for on/off options */ +#define LDAP_OPT_ON ((void *)1) +#define LDAP_OPT_OFF ((void *)0) + +typedef struct ldap LDAP; /* opaque connection handle */ +typedef struct ldapmsg LDAPMessage; /* opaque result/entry handle */ + +/* structure representing an LDAP modification */ +typedef struct ldapmod { + int mod_op; /* kind of mod + form of values*/ +#define LDAP_MOD_ADD 0x00 +#define LDAP_MOD_DELETE 0x01 +#define LDAP_MOD_REPLACE 0x02 +#define LDAP_MOD_BVALUES 0x80 + char *mod_type; /* attribute name to modify */ + union mod_vals_u { + char **modv_strvals; + struct berval **modv_bvals; + } mod_vals; /* values to add/delete/replace */ +#define mod_values mod_vals.modv_strvals +#define mod_bvalues mod_vals.modv_bvals +} LDAPMod; + + +/* + * structure for holding ldapv3 controls + */ +typedef struct ldapcontrol { + char *ldctl_oid; + struct berval ldctl_value; + char ldctl_iscritical; +} LDAPControl; + + +/* + * LDAP API information. Can be retrieved by using a sequence like: + * + * LDAPAPIInfo ldai; + * ldai.ldapai_info_version = LDAP_API_INFO_VERSION; + * if ( ldap_get_option( NULL, LDAP_OPT_API_INFO, &ldia ) == 0 ) ... + */ +#define LDAP_API_INFO_VERSION 1 +typedef struct ldapapiinfo { + int ldapai_info_version; /* version of this struct (1) */ + int ldapai_api_version; /* revision of API supported */ + int ldapai_protocol_version; /* highest LDAP version supported */ + char **ldapai_extensions; /* names of API extensions */ + char *ldapai_vendor_name; /* name of supplier */ + int ldapai_vendor_version; /* supplier-specific version times 100 */ +} LDAPAPIInfo; + + +/* + * LDAP API extended features info. Can be retrieved by using a sequence like: + * + * LDAPAPIFeatureInfo ldfi; + * ldfi.ldapaif_info_version = LDAP_FEATURE_INFO_VERSION; + * ldfi.ldapaif_name = "VIRTUAL_LIST_VIEW"; + * if ( ldap_get_option( NULL, LDAP_OPT_API_FEATURE_INFO, &ldfi ) == 0 ) ... + */ +#define LDAP_FEATURE_INFO_VERSION 1 +typedef struct ldap_apifeature_info { + int ldapaif_info_version; /* version of this struct (1) */ + char *ldapaif_name; /* name of supported feature */ + int ldapaif_version; /* revision of supported feature */ +} LDAPAPIFeatureInfo; + + +/* possible result types a server can return */ +#define LDAP_RES_BIND 0x61L /* 97 */ +#define LDAP_RES_SEARCH_ENTRY 0x64L /* 100 */ +#define LDAP_RES_SEARCH_RESULT 0x65L /* 101 */ +#define LDAP_RES_MODIFY 0x67L /* 103 */ +#define LDAP_RES_ADD 0x69L /* 105 */ +#define LDAP_RES_DELETE 0x6BL /* 107 */ +#define LDAP_RES_MODDN 0x6DL /* 109 */ +#define LDAP_RES_COMPARE 0x6FL /* 111 */ +#define LDAP_RES_SEARCH_REFERENCE 0x73L /* 115 */ +#define LDAP_RES_EXTENDED 0x78L /* 120 */ + +/* Special values for ldap_result() "msgid" parameter */ +#define LDAP_RES_ANY (-1) +#define LDAP_RES_UNSOLICITED 0 + +/* built-in SASL methods */ +#define LDAP_SASL_SIMPLE 0 /* special value used for simple bind */ + +/* search scopes */ +#define LDAP_SCOPE_BASE 0x00 +#define LDAP_SCOPE_ONELEVEL 0x01 +#define LDAP_SCOPE_SUBTREE 0x02 + +/* alias dereferencing */ +#define LDAP_DEREF_NEVER 0x00 +#define LDAP_DEREF_SEARCHING 0x01 +#define LDAP_DEREF_FINDING 0x02 +#define LDAP_DEREF_ALWAYS 0x03 + +/* predefined size/time limits */ +#define LDAP_NO_LIMIT 0 + +/* allowed values for "all" ldap_result() parameter */ +#define LDAP_MSG_ONE 0x00 +#define LDAP_MSG_ALL 0x01 +#define LDAP_MSG_RECEIVED 0x02 + +/* possible error codes we can be returned */ +#define LDAP_SUCCESS 0x00 /* 0 */ +#define LDAP_OPERATIONS_ERROR 0x01 /* 1 */ +#define LDAP_PROTOCOL_ERROR 0x02 /* 2 */ +#define LDAP_TIMELIMIT_EXCEEDED 0x03 /* 3 */ +#define LDAP_SIZELIMIT_EXCEEDED 0x04 /* 4 */ +#define LDAP_COMPARE_FALSE 0x05 /* 5 */ +#define LDAP_COMPARE_TRUE 0x06 /* 6 */ +#define LDAP_STRONG_AUTH_NOT_SUPPORTED 0x07 /* 7 */ +#define LDAP_STRONG_AUTH_REQUIRED 0x08 /* 8 */ +#define LDAP_REFERRAL 0x0a /* 10 - LDAPv3 */ +#define LDAP_ADMINLIMIT_EXCEEDED 0x0b /* 11 - LDAPv3 */ +#define LDAP_UNAVAILABLE_CRITICAL_EXTENSION 0x0c /* 12 - LDAPv3 */ +#define LDAP_CONFIDENTIALITY_REQUIRED 0x0d /* 13 */ +#define LDAP_SASL_BIND_IN_PROGRESS 0x0e /* 14 - LDAPv3 */ + +#define LDAP_NO_SUCH_ATTRIBUTE 0x10 /* 16 */ +#define LDAP_UNDEFINED_TYPE 0x11 /* 17 */ +#define LDAP_INAPPROPRIATE_MATCHING 0x12 /* 18 */ +#define LDAP_CONSTRAINT_VIOLATION 0x13 /* 19 */ +#define LDAP_TYPE_OR_VALUE_EXISTS 0x14 /* 20 */ +#define LDAP_INVALID_SYNTAX 0x15 /* 21 */ + +#define LDAP_NO_SUCH_OBJECT 0x20 /* 32 */ +#define LDAP_ALIAS_PROBLEM 0x21 /* 33 */ +#define LDAP_INVALID_DN_SYNTAX 0x22 /* 34 */ +#define LDAP_IS_LEAF 0x23 /* 35 (not used in LDAPv3) */ +#define LDAP_ALIAS_DEREF_PROBLEM 0x24 /* 36 */ + +#define LDAP_INAPPROPRIATE_AUTH 0x30 /* 48 */ +#define LDAP_INVALID_CREDENTIALS 0x31 /* 49 */ +#define LDAP_INSUFFICIENT_ACCESS 0x32 /* 50 */ +#define LDAP_BUSY 0x33 /* 51 */ +#define LDAP_UNAVAILABLE 0x34 /* 52 */ +#define LDAP_UNWILLING_TO_PERFORM 0x35 /* 53 */ +#define LDAP_LOOP_DETECT 0x36 /* 54 */ + +#define LDAP_NAMING_VIOLATION 0x40 /* 64 */ +#define LDAP_OBJECT_CLASS_VIOLATION 0x41 /* 65 */ +#define LDAP_NOT_ALLOWED_ON_NONLEAF 0x42 /* 66 */ +#define LDAP_NOT_ALLOWED_ON_RDN 0x43 /* 67 */ +#define LDAP_ALREADY_EXISTS 0x44 /* 68 */ +#define LDAP_NO_OBJECT_CLASS_MODS 0x45 /* 69 */ +#define LDAP_RESULTS_TOO_LARGE 0x46 /* 70 - CLDAP */ +#define LDAP_AFFECTS_MULTIPLE_DSAS 0x47 /* 71 */ + +#define LDAP_OTHER 0x50 /* 80 */ +#define LDAP_SERVER_DOWN 0x51 /* 81 */ +#define LDAP_LOCAL_ERROR 0x52 /* 82 */ +#define LDAP_ENCODING_ERROR 0x53 /* 83 */ +#define LDAP_DECODING_ERROR 0x54 /* 84 */ +#define LDAP_TIMEOUT 0x55 /* 85 */ +#define LDAP_AUTH_UNKNOWN 0x56 /* 86 */ +#define LDAP_FILTER_ERROR 0x57 /* 87 */ +#define LDAP_USER_CANCELLED 0x58 /* 88 */ +#define LDAP_PARAM_ERROR 0x59 /* 89 */ +#define LDAP_NO_MEMORY 0x5a /* 90 */ +#define LDAP_CONNECT_ERROR 0x5b /* 91 */ +#define LDAP_NOT_SUPPORTED 0x5c /* 92 - LDAPv3 */ +#define LDAP_CONTROL_NOT_FOUND 0x5d /* 93 - LDAPv3 */ +#define LDAP_NO_RESULTS_RETURNED 0x5e /* 94 - LDAPv3 */ +#define LDAP_MORE_RESULTS_TO_RETURN 0x5f /* 95 - LDAPv3 */ +#define LDAP_CLIENT_LOOP 0x60 /* 96 - LDAPv3 */ +#define LDAP_REFERRAL_LIMIT_EXCEEDED 0x61 /* 97 - LDAPv3 */ + +/* + * LDAPv3 unsolicited notification messages we know about + */ +#define LDAP_NOTICE_OF_DISCONNECTION "1.3.6.1.4.1.1466.20036" + +/* + * Client controls we know about + */ +#define LDAP_CONTROL_REFERRALS "1.2.840.113556.1.4.616" + +/* + * Initializing an ldap sesssion, set session handle options, and + * closing an ldap session functions + * + * NOTE: If you want to use IPv6, you must use prldap creating a LDAP handle + * with prldap_init instead of ldap_init. Or install the NSPR functions + * by calling prldap_install_routines. (See the nspr samples in examples) + */ +LDAP_API(LDAP *) LDAP_CALL ldap_init( const char *defhost, int defport ); +LDAP_API(int) LDAP_CALL ldap_set_option( LDAP *ld, int option, + const void *optdata ); +LDAP_API(int) LDAP_CALL ldap_get_option( LDAP *ld, int option, void *optdata ); +LDAP_API(int) LDAP_CALL ldap_unbind( LDAP *ld ); +LDAP_API(int) LDAP_CALL ldap_unbind_s( LDAP *ld ); + +/* + * perform ldap operations + */ +LDAP_API(int) LDAP_CALL ldap_abandon( LDAP *ld, int msgid ); +LDAP_API(int) LDAP_CALL ldap_add( LDAP *ld, const char *dn, LDAPMod **attrs ); +LDAP_API(int) LDAP_CALL ldap_add_s( LDAP *ld, const char *dn, LDAPMod **attrs ); +LDAP_API(int) LDAP_CALL ldap_simple_bind( LDAP *ld, const char *who, + const char *passwd ); +LDAP_API(int) LDAP_CALL ldap_simple_bind_s( LDAP *ld, const char *who, + const char *passwd ); +LDAP_API(int) LDAP_CALL ldap_modify( LDAP *ld, const char *dn, LDAPMod **mods ); +LDAP_API(int) LDAP_CALL ldap_modify_s( LDAP *ld, const char *dn, + LDAPMod **mods ); +LDAP_API(int) LDAP_CALL ldap_compare( LDAP *ld, const char *dn, + const char *attr, const char *value ); +LDAP_API(int) LDAP_CALL ldap_compare_s( LDAP *ld, const char *dn, + const char *attr, const char *value ); +LDAP_API(int) LDAP_CALL ldap_delete( LDAP *ld, const char *dn ); +LDAP_API(int) LDAP_CALL ldap_delete_s( LDAP *ld, const char *dn ); +LDAP_API(int) LDAP_CALL ldap_search( LDAP *ld, const char *base, int scope, + const char *filter, char **attrs, int attrsonly ); +LDAP_API(int) LDAP_CALL ldap_search_s( LDAP *ld, const char *base, int scope, + const char *filter, char **attrs, int attrsonly, LDAPMessage **res ); +LDAP_API(int) LDAP_CALL ldap_search_st( LDAP *ld, const char *base, int scope, + const char *filter, char **attrs, int attrsonly, + struct timeval *timeout, LDAPMessage **res ); + +/* + * obtain result from ldap operation + */ +LDAP_API(int) LDAP_CALL ldap_result( LDAP *ld, int msgid, int all, + struct timeval *timeout, LDAPMessage **result ); + +/* + * peeking inside LDAP Messages and deallocating LDAP Messages + */ +LDAP_API(int) LDAP_CALL ldap_msgfree( LDAPMessage *lm ); +LDAP_API(int) LDAP_CALL ldap_msgid( LDAPMessage *lm ); +LDAP_API(int) LDAP_CALL ldap_msgtype( LDAPMessage *lm ); + + +/* + * Routines to parse/deal with results and errors returned + */ +LDAP_API(char *) LDAP_CALL ldap_err2string( int err ); +LDAP_API(LDAPMessage *) LDAP_CALL ldap_first_entry( LDAP *ld, + LDAPMessage *chain ); +LDAP_API(LDAPMessage *) LDAP_CALL ldap_next_entry( LDAP *ld, + LDAPMessage *entry ); +LDAP_API(int) LDAP_CALL ldap_count_entries( LDAP *ld, LDAPMessage *chain ); +LDAP_API(char *) LDAP_CALL ldap_get_dn( LDAP *ld, LDAPMessage *entry ); +LDAP_API(char *) LDAP_CALL ldap_dn2ufn( const char *dn ); +LDAP_API(char **) LDAP_CALL ldap_explode_dn( const char *dn, + const int notypes ); +LDAP_API(char **) LDAP_CALL ldap_explode_rdn( const char *rdn, + const int notypes ); +LDAP_API(char *) LDAP_CALL ldap_first_attribute( LDAP *ld, LDAPMessage *entry, + BerElement **ber ); +LDAP_API(char *) LDAP_CALL ldap_next_attribute( LDAP *ld, LDAPMessage *entry, + BerElement *ber ); +LDAP_API(char **) LDAP_CALL ldap_get_values( LDAP *ld, LDAPMessage *entry, + const char *target ); +LDAP_API(struct berval **) LDAP_CALL ldap_get_values_len( LDAP *ld, + LDAPMessage *entry, const char *target ); +LDAP_API(int) LDAP_CALL ldap_count_values( char **vals ); +LDAP_API(int) LDAP_CALL ldap_count_values_len( struct berval **vals ); +LDAP_API(void) LDAP_CALL ldap_value_free( char **vals ); +LDAP_API(void) LDAP_CALL ldap_value_free_len( struct berval **vals ); +LDAP_API(void) LDAP_CALL ldap_memfree( void *p ); + + +/* + * LDAPv3 extended operation calls + */ +/* + * Note: all of the new asynchronous calls return an LDAP error code, + * not a message id. A message id is returned via the int *msgidp + * parameter (usually the last parameter) if appropriate. + */ +LDAP_API(int) LDAP_CALL ldap_abandon_ext( LDAP *ld, int msgid, + LDAPControl **serverctrls, LDAPControl **clientctrls ); +LDAP_API(int) LDAP_CALL ldap_add_ext( LDAP *ld, const char *dn, LDAPMod **attrs, + LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp ); +LDAP_API(int) LDAP_CALL ldap_add_ext_s( LDAP *ld, const char *dn, + LDAPMod **attrs, LDAPControl **serverctrls, LDAPControl **clientctrls ); +LDAP_API(int) LDAP_CALL ldap_sasl_bind( LDAP *ld, const char *dn, + const char *mechanism, const struct berval *cred, + LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp ); +LDAP_API(int) LDAP_CALL ldap_sasl_bind_s( LDAP *ld, const char *dn, + const char *mechanism, const struct berval *cred, + LDAPControl **serverctrls, LDAPControl **clientctrls, + struct berval **servercredp ); +LDAP_API(int) LDAP_CALL ldap_modify_ext( LDAP *ld, const char *dn, + LDAPMod **mods, LDAPControl **serverctrls, LDAPControl **clientctrls, + int *msgidp ); +LDAP_API(int) LDAP_CALL ldap_modify_ext_s( LDAP *ld, const char *dn, + LDAPMod **mods, LDAPControl **serverctrls, LDAPControl **clientctrls ); +LDAP_API(int) LDAP_CALL ldap_rename( LDAP *ld, const char *dn, + const char *newrdn, const char *newparent, int deleteoldrdn, + LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp ); +LDAP_API(int) LDAP_CALL ldap_rename_s( LDAP *ld, const char *dn, + const char *newrdn, const char *newparent, int deleteoldrdn, + LDAPControl **serverctrls, LDAPControl **clientctrls ); +LDAP_API(int) LDAP_CALL ldap_compare_ext( LDAP *ld, const char *dn, + const char *attr, const struct berval *bvalue, + LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp ); +LDAP_API(int) LDAP_CALL ldap_compare_ext_s( LDAP *ld, const char *dn, + const char *attr, const struct berval *bvalue, + LDAPControl **serverctrls, LDAPControl **clientctrls ); +LDAP_API(int) LDAP_CALL ldap_delete_ext( LDAP *ld, const char *dn, + LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp ); +LDAP_API(int) LDAP_CALL ldap_delete_ext_s( LDAP *ld, const char *dn, + LDAPControl **serverctrls, LDAPControl **clientctrls ); +LDAP_API(int) LDAP_CALL ldap_search_ext( LDAP *ld, const char *base, + int scope, const char *filter, char **attrs, int attrsonly, + LDAPControl **serverctrls, LDAPControl **clientctrls, + struct timeval *timeoutp, int sizelimit, int *msgidp ); +LDAP_API(int) LDAP_CALL ldap_search_ext_s( LDAP *ld, const char *base, + int scope, const char *filter, char **attrs, int attrsonly, + LDAPControl **serverctrls, LDAPControl **clientctrls, + struct timeval *timeoutp, int sizelimit, LDAPMessage **res ); +LDAP_API(int) LDAP_CALL ldap_extended_operation( LDAP *ld, + const char *requestoid, const struct berval *requestdata, + LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp ); +LDAP_API(int) LDAP_CALL ldap_extended_operation_s( LDAP *ld, + const char *requestoid, const struct berval *requestdata, + LDAPControl **serverctrls, LDAPControl **clientctrls, + char **retoidp, struct berval **retdatap ); +LDAP_API(int) LDAP_CALL ldap_unbind_ext( LDAP *ld, LDAPControl **serverctrls, + LDAPControl **clientctrls ); + + +/* + * LDAPv3 extended parsing / result handling calls + */ +LDAP_API(int) LDAP_CALL ldap_parse_sasl_bind_result( LDAP *ld, + LDAPMessage *res, struct berval **servercredp, int freeit ); +LDAP_API(int) LDAP_CALL ldap_parse_result( LDAP *ld, LDAPMessage *res, + int *errcodep, char **matcheddnp, char **errmsgp, char ***referralsp, + LDAPControl ***serverctrlsp, int freeit ); +LDAP_API(int) LDAP_CALL ldap_parse_extended_result( LDAP *ld, LDAPMessage *res, + char **retoidp, struct berval **retdatap, int freeit ); +LDAP_API(LDAPMessage *) LDAP_CALL ldap_first_message( LDAP *ld, + LDAPMessage *res ); +LDAP_API(LDAPMessage *) LDAP_CALL ldap_next_message( LDAP *ld, + LDAPMessage *msg ); +LDAP_API(int) LDAP_CALL ldap_count_messages( LDAP *ld, LDAPMessage *res ); +LDAP_API(LDAPMessage *) LDAP_CALL ldap_first_reference( LDAP *ld, + LDAPMessage *res ); +LDAP_API(LDAPMessage *) LDAP_CALL ldap_next_reference( LDAP *ld, + LDAPMessage *ref ); +LDAP_API(int) LDAP_CALL ldap_count_references( LDAP *ld, LDAPMessage *res ); +LDAP_API(int) LDAP_CALL ldap_parse_reference( LDAP *ld, LDAPMessage *ref, + char ***referralsp, LDAPControl ***serverctrlsp, int freeit ); +LDAP_API(int) LDAP_CALL ldap_get_entry_controls( LDAP *ld, LDAPMessage *entry, + LDAPControl ***serverctrlsp ); +LDAP_API(void) LDAP_CALL ldap_control_free( LDAPControl *ctrl ); +LDAP_API(void) LDAP_CALL ldap_controls_free( LDAPControl **ctrls ); + +#ifdef __cplusplus +} +#endif +#endif /* _LDAP_STANDARD_H */ diff --git a/ldap/c-sdk/include/ldap-to-be-deprecated.h b/ldap/c-sdk/include/ldap-to-be-deprecated.h new file mode 100644 index 000000000..73404da0f --- /dev/null +++ b/ldap/c-sdk/include/ldap-to-be-deprecated.h @@ -0,0 +1,193 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* ldap-to-be-deprecated.h - functions and declaration which will be + * deprecated in a future release. + * + * A deprecated API is an API that we recommend you no longer use, + * due to improvements in the LDAP C SDK. While deprecated APIs are + * currently still implemented, they may be removed in future + * implementations, and we recommend using other APIs. + * + * This header file will act as a first warning before moving functions + * into an unsupported/deprecated state. If your favorite application + * depend on any declaration and defines, and there is a good reason + * for not porting to new functions, Speak up now or they may disappear + * in a future release + */ + +#ifndef _LDAP_TOBE_DEPRECATED_H +#define _LDAP_TOBE_DEPRECATED_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * I/O function callbacks option (an API extension -- + * LDAP_API_FEATURE_X_IO_FUNCTIONS). + * Use of the extended I/O functions instead is recommended + */ +#define LDAP_OPT_IO_FN_PTRS 0x0B /* 11 - API extension */ + +/* + * I/O callback functions (note that types for the read and write callbacks + * are actually in lber.h): + */ +typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_SELECT_CALLBACK)( int nfds, + fd_set *readfds, fd_set *writefds, fd_set *errorfds, + struct timeval *timeout ); +typedef LBER_SOCKET (LDAP_C LDAP_CALLBACK LDAP_IOF_SOCKET_CALLBACK)( + int domain, int type, int protocol ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_IOCTL_CALLBACK)( LBER_SOCKET s, + int option, ... ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_CONNECT_CALLBACK )( + LBER_SOCKET s, struct sockaddr *name, int namelen ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_CLOSE_CALLBACK )( + LBER_SOCKET s ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_IOF_SSL_ENABLE_CALLBACK )( + LBER_SOCKET s ); + +/* + * Structure to hold I/O function pointers: + */ +struct ldap_io_fns { + LDAP_IOF_READ_CALLBACK *liof_read; + LDAP_IOF_WRITE_CALLBACK *liof_write; + LDAP_IOF_SELECT_CALLBACK *liof_select; + LDAP_IOF_SOCKET_CALLBACK *liof_socket; + LDAP_IOF_IOCTL_CALLBACK *liof_ioctl; + LDAP_IOF_CONNECT_CALLBACK *liof_connect; + LDAP_IOF_CLOSE_CALLBACK *liof_close; + LDAP_IOF_SSL_ENABLE_CALLBACK *liof_ssl_enable; +}; + +/* + * DNS resolver callbacks (an API extension --LDAP_API_FEATURE_X_DNS_FUNCTIONS). + * Note that gethostbyaddr() is not currently used. + */ +#define LDAP_OPT_DNS_FN_PTRS 0x60 /* 96 - API extension */ + +typedef struct LDAPHostEnt { + char *ldaphe_name; /* official name of host */ + char **ldaphe_aliases; /* alias list */ + int ldaphe_addrtype; /* host address type */ + int ldaphe_length; /* length of address */ + char **ldaphe_addr_list; /* list of addresses from name server */ +} LDAPHostEnt; + +typedef LDAPHostEnt * (LDAP_C LDAP_CALLBACK LDAP_DNSFN_GETHOSTBYNAME)( + const char *name, LDAPHostEnt *result, char *buffer, + int buflen, int *statusp, void *extradata ); +typedef LDAPHostEnt * (LDAP_C LDAP_CALLBACK LDAP_DNSFN_GETHOSTBYADDR)( + const char *addr, int length, int type, LDAPHostEnt *result, + char *buffer, int buflen, int *statusp, void *extradata ); +typedef int (LDAP_C LDAP_CALLBACK LDAP_DNSFN_GETPEERNAME)( + LDAP *ld, struct sockaddr *netaddr, char *buffer, int buflen); + +struct ldap_dns_fns { + void *lddnsfn_extradata; + int lddnsfn_bufsize; + LDAP_DNSFN_GETHOSTBYNAME *lddnsfn_gethostbyname; + LDAP_DNSFN_GETHOSTBYADDR *lddnsfn_gethostbyaddr; + LDAP_DNSFN_GETPEERNAME *lddnsfn_getpeername; +}; + +/* + * experimental DN format support + */ +LDAP_API(char **) LDAP_CALL ldap_explode_dns( const char *dn ); +LDAP_API(int) LDAP_CALL ldap_is_dns_dn( const char *dn ); + + +/* + * user friendly naming/searching routines + */ +typedef int (LDAP_C LDAP_CALLBACK LDAP_CANCELPROC_CALLBACK)( void *cl ); +LDAP_API(int) LDAP_CALL ldap_ufn_search_c( LDAP *ld, char *ufn, + char **attrs, int attrsonly, LDAPMessage **res, + LDAP_CANCELPROC_CALLBACK *cancelproc, void *cancelparm ); +LDAP_API(int) LDAP_CALL ldap_ufn_search_ct( LDAP *ld, char *ufn, + char **attrs, int attrsonly, LDAPMessage **res, + LDAP_CANCELPROC_CALLBACK *cancelproc, void *cancelparm, + char *tag1, char *tag2, char *tag3 ); +LDAP_API(int) LDAP_CALL ldap_ufn_search_s( LDAP *ld, char *ufn, + char **attrs, int attrsonly, LDAPMessage **res ); +LDAP_API(LDAPFiltDesc *) LDAP_CALL ldap_ufn_setfilter( LDAP *ld, char *fname ); +LDAP_API(void) LDAP_CALL ldap_ufn_setprefix( LDAP *ld, char *prefix ); +LDAP_API(int) LDAP_C ldap_ufn_timeout( void *tvparam ); + +/* + * utility routines + */ +LDAP_API(int) LDAP_CALL ldap_charray_add( char ***a, char *s ); +LDAP_API(int) LDAP_CALL ldap_charray_merge( char ***a, char **s ); +LDAP_API(void) LDAP_CALL ldap_charray_free( char **array ); +LDAP_API(int) LDAP_CALL ldap_charray_inlist( char **a, char *s ); +LDAP_API(char **) LDAP_CALL ldap_charray_dup( char **a ); +LDAP_API(char **) LDAP_CALL ldap_str2charray( char *str, char *brkstr ); +LDAP_API(int) LDAP_CALL ldap_charray_position( char **a, char *s ); + +/* from ldap_ssl.h - the pkcs function and declaration */ +typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_TOKEN_CALLBACK)(void *context, char **tokenname); +typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_PIN_CALLBACK)(void *context, const char *tokenname, char **tokenpin); +typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_CERTPATH_CALLBACK)(void *context, char **certpath); +typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_KEYPATH_CALLBACK)(void *context,char **keypath); +typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_MODPATH_CALLBACK)(void *context, char **modulepath); +typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_CERTNAME_CALLBACK)(void *context, char **certname); +typedef int (LDAP_C LDAP_CALLBACK LDAP_PKCS_GET_DONGLEFILENAME_CALLBACK)(void *context, char **filename); + +#define PKCS_STRUCTURE_ID 1 +struct ldapssl_pkcs_fns { + int local_structure_id; + void *local_data; + LDAP_PKCS_GET_CERTPATH_CALLBACK *pkcs_getcertpath; + LDAP_PKCS_GET_CERTNAME_CALLBACK *pkcs_getcertname; + LDAP_PKCS_GET_KEYPATH_CALLBACK *pkcs_getkeypath; + LDAP_PKCS_GET_MODPATH_CALLBACK *pkcs_getmodpath; + LDAP_PKCS_GET_PIN_CALLBACK *pkcs_getpin; + LDAP_PKCS_GET_TOKEN_CALLBACK *pkcs_gettokenname; + LDAP_PKCS_GET_DONGLEFILENAME_CALLBACK *pkcs_getdonglefilename; + +}; + +LDAP_API(int) LDAP_CALL ldapssl_pkcs_init( const struct ldapssl_pkcs_fns *pfns); + +#ifdef __cplusplus +} +#endif +#endif /* _LDAP_TOBE_DEPRECATED_H */ diff --git a/ldap/c-sdk/include/ldap.h b/ldap/c-sdk/include/ldap.h new file mode 100644 index 000000000..2eea7ada6 --- /dev/null +++ b/ldap/c-sdk/include/ldap.h @@ -0,0 +1,62 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* ldap.h - general header file for libldap */ + +#ifndef _LDAP_H +#define _LDAP_H + +/* Standard LDAP API functions and declarations */ +#include "ldap-standard.h" + +/* Extensions to the LDAP standard */ +#include "ldap-extension.h" + +/* A deprecated API is an API that we recommend you no longer use, + * due to improvements in the LDAP C SDK. While deprecated APIs are + * currently still implemented, they may be removed in future + * implementations, and we recommend using other APIs. + */ + +/* Soon-to-be deprecated functions and declarations */ +#include "ldap-to-be-deprecated.h" + +/* Deprecated functions and declarations */ +#include "ldap-deprecated.h" + +#endif /* _LDAP_H */ + diff --git a/ldap/c-sdk/include/ldap_ssl.h b/ldap/c-sdk/include/ldap_ssl.h new file mode 100644 index 000000000..5c786a908 --- /dev/null +++ b/ldap/c-sdk/include/ldap_ssl.h @@ -0,0 +1,254 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#if !defined(LDAP_SSL_H) +#define LDAP_SSL_H + +/* ldap_ssl.h - prototypes for LDAP over SSL functions */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * these three defines resolve the SSL strength + * setting auth weak, diables all cert checking + * the CNCHECK tests for the man in the middle hack + */ +#define LDAPSSL_AUTH_WEAK 0 +#define LDAPSSL_AUTH_CERT 1 +#define LDAPSSL_AUTH_CNCHECK 2 + +/* + * an ExtendedRequest [LDAPv3] specifying the OID for the + * Start TLS operation: RFC 2830 + */ +#define LDAP_EXOP_START_TLS "1.3.6.1.4.1.1466.20037" + +/* + * Initialize LDAP library for SSL + */ +LDAP * LDAP_CALL ldapssl_init( const char *defhost, int defport, + int defsecure ); + +/* + * Shutdown LDAP library for SSL : + * Perform necessary cleanup and attempt to shutdown NSS. All existing + * ld session handles should be ldap_unbind(ld) prior to calling this. + */ +int LDAP_CALL ldapssl_shutdown(); + +/* Initialize LDAP library for TLS(SSL) and sends StartTLS extended + * operation to the Directory Server. + * Returns LDAP_SUCCESS if all goes well. + */ +int LDAP_CALL ldap_start_tls_s( LDAP *ld, LDAPControl **serverctrls, + LDAPControl **clientctrls ); +/* + * Install I/O routines to make SSL over LDAP possible. + * Use this after ldap_init() or just use ldapssl_init() instead. + * Returns 0 if all goes well. + */ +int LDAP_CALL ldapssl_install_routines( LDAP *ld ); + + +/* The next four functions initialize the security code for SSL + * The first one ldapssl_client_init() does initialization for SSL only + * The next one supports server authentication using clientauth_init() + * and allows the caller to specify the ssl strength to use in order to + * verify the servers's certificate. + * The next one supports ldapssl_clientauth_init() intializes security + * for SSL for client authentication. The third function initializes + * security for doing SSL with client authentication, and PKCS, that is, + * the third function initializes the security module database (secmod.db). + * The parameters are as follows: + * const char *certdbpath - path to the cert file. This can be a shortcut + * to the directory name, if so cert7.db will be postfixed to the string. + * void *certdbhandle - Normally this is NULL. This memory will need + * to be freed. + * int needkeydb - boolean. Must be !=0 if client Authentification + * is required + * char *keydbpath - path to the key database. This can be a shortcut + * to the directory name, if so key3.db will be postfixed to the string. + * void *keydbhandle - Normally this is NULL, This memory will need + * to be freed + * int needsecmoddb - boolean. Must be !=0 to assure that the correct + * security module is loaded into memory + * char *secmodpath - path to the secmod. This can be a shortcut to the + * directory name, if so secmod.db will be postfixed to the string. + * + * These three functions are mutually exclusive. You can only call + * one. This means that, for a given process, you must call the + * appropriate initialization function for the life of the process. + */ + + +/* + * Initialize the secure parts (Security and SSL) of the runtime for use + * by a client application. This is only called once. + * Returns 0 if all goes well. + */ + +int LDAP_CALL ldapssl_client_init( + const char *certdbpath, void *certdbhandle ); + +/* + * Initialize the secure parts (Security and SSL) of the runtime for use + * by a client application using server authentication. This is only + * called once. + * + * ldapssl_serverauth_init() is a server-authentication only version of + * ldapssl_clientauth_init(). This function allows the sslstrength + * to be passed in. The sslstrength can take one of the following + * values: + * + * LDAPSSL_AUTH_WEAK: indicate that you accept the server's + * certificate without checking the CA who + * issued the certificate + * LDAPSSL_AUTH_CERT: indicates that you accept the server's + * certificate only if you trust the CA who + * issued the certificate + * LDAPSSL_AUTH_CNCHECK: + * indicates that you accept the server's + * certificate only if you trust the CA who + * issued the certificate and if the value + * of the cn attribute is the DNS hostname + * of the server. If this option is selected, + * please ensure that the "defhost" parameter + * passed to ldapssl_init() consist of only + * one hostname and not a list of hosts. + * Furthermore, the port number must be passed + * via the "defport" parameter, and cannot + * be passed via a host:port option. + * + * Returns 0 if all goes well. + */ + +int LDAP_CALL ldapssl_serverauth_init( + const char *certdbpath, void *certdbhandle, const int sslstrength ); + +/* + * Initialize the secure parts (Security and SSL) of the runtime for use + * by a client application that may want to do SSL client authentication. + * Returns 0 if all goes well. + */ + +int LDAP_CALL ldapssl_clientauth_init( + const char *certdbpath, void *certdbhandle, + const int needkeydb, const char *keydbpath, void *keydbhandle ); + +/* + * Initialize the secure parts (Security and SSL) of the runtime for use + * by a client application that may want to do SSL client authentication. + * + * Please see the description of the sslstrength value in the + * ldapssl_serverauth_init() function above and note the potential + * problems which can be caused by passing in wrong host & portname + * values. The same warning applies to the ldapssl_advclientauth_init() + * function. + * + * Returns 0 if all goes well. + */ + +int LDAP_CALL ldapssl_advclientauth_init( + const char *certdbpath, void *certdbhandle, + const int needkeydb, const char *keydbpath, void *keydbhandle, + const int needsecmoddb, const char *secmoddbpath, + const int sslstrength ); + + + +/* + * get a meaningful error string back from the security library + * this function should be called, if ldap_err2string doesn't + * identify the error code. + */ +const char * LDAP_CALL ldapssl_err2string( const int prerrno ); + + +/* + * Enable SSL client authentication on the given ld. + * Returns 0 if all goes well. + */ +int LDAP_CALL ldapssl_enable_clientauth( LDAP *ld, char *keynickname, + char *keypasswd, char *certnickname ); + +/* + * Set the SSL strength for an existing SSL-enabled LDAP session handle. + * + * See the description of ldapssl_serverauth_init() above for valid + * sslstrength values. If ld is NULL, the default for new LDAP session + * handles is set. + * + * Returns 0 if all goes well. + */ +int LDAP_CALL ldapssl_set_strength( LDAP *ld, int sslstrength ); + + +/* + * Set or get SSL options for an existing SSL-enabled LDAP session handle. + * If ld is NULL, the default options used for all future LDAP SSL sessions + * are the ones affected. The option values are specific to the underlying + * SSL provider; see ssl.h within the Network Security Services (NSS) + * distribution for the options supported by NSS (the default SSL provider). + * + * The ldapssl_set_option() function should be called before any LDAP + * connections are created. + * + * Both functions return 0 if all goes well. + */ +int LDAP_CALL ldapssl_set_option( LDAP *ld, int option, int on ); +int LDAP_CALL ldapssl_get_option( LDAP *ld, int option, int *onp ); + +/* + * Import the file descriptor corresponding to the socket of an already + * open LDAP connection into SSL, and update the socket and session + * information accordingly. Returns 0 if all goes well. + */ +int LDAP_CALL ldapssl_import_fd ( LDAP *ld, int secure ); + +/* + * Reset an LDAP session from SSL to a non-secure status. Basically, + * this function undoes the work done by ldapssl_install_routines. + * Returns 0 if all goes well. + */ +int LDAP_CALL ldapssl_reset_to_nonsecure ( LDAP *ld ); + +#ifdef __cplusplus +} +#endif +#endif /* !defined(LDAP_SSL_H) */ diff --git a/ldap/c-sdk/include/ldaplog.h b/ldap/c-sdk/include/ldaplog.h new file mode 100644 index 000000000..9f3f12e13 --- /dev/null +++ b/ldap/c-sdk/include/ldaplog.h @@ -0,0 +1,106 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef _LDAPLOG_H +#define _LDAPLOG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define LDAP_DEBUG_TRACE 0x00001 +#define LDAP_DEBUG_PACKETS 0x00002 +#define LDAP_DEBUG_ARGS 0x00004 +#define LDAP_DEBUG_CONNS 0x00008 +#define LDAP_DEBUG_BER 0x00010 +#define LDAP_DEBUG_FILTER 0x00020 +#define LDAP_DEBUG_CONFIG 0x00040 +#define LDAP_DEBUG_ACL 0x00080 +#define LDAP_DEBUG_STATS 0x00100 +#define LDAP_DEBUG_STATS2 0x00200 +#define LDAP_DEBUG_SHELL 0x00400 +#define LDAP_DEBUG_PARSE 0x00800 +#define LDAP_DEBUG_HOUSE 0x01000 +#define LDAP_DEBUG_REPL 0x02000 +#define LDAP_DEBUG_ANY 0x04000 +#define LDAP_DEBUG_CACHE 0x08000 +#define LDAP_DEBUG_PLUGIN 0x10000 + +/* debugging stuff */ +/* Disable by default */ +#define LDAPDebug( level, fmt, arg1, arg2, arg3 ) + +#ifdef LDAP_DEBUG +# undef LDAPDebug + +/* SLAPD_LOGGING should not be on for WINSOCK (16-bit Windows) */ +# if defined(SLAPD_LOGGING) +# ifdef _WIN32 + extern int *module_ldap_debug; +# define LDAPDebug( level, fmt, arg1, arg2, arg3 ) \ + { \ + if ( *module_ldap_debug & level ) { \ + slapd_log_error_proc( NULL, fmt, arg1, arg2, arg3 ); \ + } \ + } +# else /* _WIN32 */ + extern int ldap_debug; +# define LDAPDebug( level, fmt, arg1, arg2, arg3 ) \ + { \ + if ( ldap_debug & level ) { \ + slapd_log_error_proc( NULL, fmt, arg1, arg2, arg3 ); \ + } \ + } +# endif /* Win32 */ +# else /* no SLAPD_LOGGING */ + extern void ber_err_print( char * ); + extern int ldap_debug; +# define LDAPDebug( level, fmt, arg1, arg2, arg3 ) \ + if ( ldap_debug & level ) { \ + char msg[1024]; \ + snprintf( msg, sizeof(msg), fmt, arg1, arg2, arg3 ); \ + msg[sizeof(msg)-1] = '\0'; \ + ber_err_print( msg ); \ + } +# endif /* SLAPD_LOGGING */ +#endif /* LDAP_DEBUG */ + +#ifdef __cplusplus +} +#endif + +#endif /* _LDAP_H */ diff --git a/ldap/c-sdk/include/ldappr.h b/ldap/c-sdk/include/ldappr.h new file mode 100644 index 000000000..04e710e1a --- /dev/null +++ b/ldap/c-sdk/include/ldappr.h @@ -0,0 +1,273 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef LDAP_PR_H +#define LDAP_PR_H + +#include "nspr.h" + +/* + * ldappr.h - prototypes for functions that tie libldap into NSPR (Netscape + * Portable Runtime). + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Function: prldap_init(). + * + * Create a new LDAP session handle, but with NSPR I/O, threading, and DNS + * functions installed. + * + * Pass a non-zero value for the 'shared' parameter if you plan to use + * this LDAP * handle from more than one thread. + * + * Returns an LDAP session handle (or NULL if an error occurs). + * + * NOTE: If you want to use IPv6, you must use prldap creating a LDAP handle + * with this function prldap_init. Prldap_init installs the appropriate + * set of NSPR functions and prevents calling deprecated functions accidentally. + */ +LDAP * LDAP_CALL prldap_init( const char *defhost, int defport, int shared ); + + +/* + * Function: prldap_install_routines(). + * + * Install NSPR I/O, threading, and DNS functions so they will be used by + * 'ld'. + * + * If 'ld' is NULL, the functions are installed as the default functions + * for all new LDAP * handles). + * + * Pass a non-zero value for the 'shared' parameter if you plan to use + * this LDAP * handle from more than one thread. + * + * Returns an LDAP API error code (LDAP_SUCCESS if all goes well). + */ +int LDAP_CALL prldap_install_routines( LDAP *ld, int shared ); + + +/* + * Function: prldap_set_session_option(). + * + * Given an LDAP session handle or a session argument such is passed to + * CONNECT, POLL, NEWHANDLE, or DISPOSEHANDLE extended I/O callbacks, set + * an option that affects the prldap layer. + * + * If 'ld' and 'session" are both NULL, the option is set as the default + * for all new prldap sessions. + * + * Returns an LDAP API error code (LDAP_SUCCESS if all goes well). + */ +int LDAP_CALL prldap_set_session_option( LDAP *ld, void *sessionarg, + int option, ... ); + + +/* + * Function: prldap_get_session_option(). + * + * Given an LDAP session handle or a session argument such is passed to + * CONNECT, POLL, NEWHANDLE, or DISPOSEHANDLE extended I/O callbacks, retrieve + * the setting for an option that affects the prldap layer. + * + * If 'ld' and 'session" are both NULL, the default option value for all new + * new prldap sessions is retrieved. + * + * Returns an LDAP API error code (LDAP_SUCCESS if all goes well). + */ +int LDAP_CALL prldap_get_session_option( LDAP *ld, void *sessionarg, + int option, ... ); + + +/* + * Available options. + */ +/* + * PRLDAP_OPT_IO_MAX_TIMEOUT: the maximum time in milliseconds to + * block waiting for a network I/O operation to complete. + * + * Data type: int. + * + * These two special values from ldap-extension.h can also be used; + * + * LDAP_X_IO_TIMEOUT_NO_TIMEOUT + * LDAP_X_IO_TIMEOUT_NO_WAIT + */ +#define PRLDAP_OPT_IO_MAX_TIMEOUT 1 + + +/** + ** Note: the types and functions below are only useful for developers + ** who need to layer one or more custom extended I/O functions on top of + ** the standard NSPR I/O functions installed by a call to prldap_init() + ** or prldap_install_routines(). Layering can be accomplished after + ** prldap_init() or prldap_install_routines() has completed successfully + ** by: + ** + ** 1) Calling ldap_get_option( ..., LDAP_X_OPT_EXTIO_FN_PTRS, ... ). + ** + ** 2) Saving the function pointer of one or more of the standard functions. + ** + ** 3) Replacing one or more standard functions in the ldap_x_ext_io_fns + ** struct with new functions that optionally do some preliminary work, + ** call the standard function (via the function pointer saved in step 2), + ** and optionally do some followup work. + */ + +/* + * Data structure for session information. + * seinfo_size should be set to PRLDAP_SESSIONINFO_SIZE before use. + */ +struct prldap_session_private; + +typedef struct prldap_session_info { + int seinfo_size; + struct prldap_session_private *seinfo_appdata; +} PRLDAPSessionInfo; +#define PRLDAP_SESSIONINFO_SIZE sizeof( PRLDAPSessionInfo ) + + +/* + * Function: prldap_set_session_info(). + * + * Given an LDAP session handle or a session argument such is passed to + * CONNECT, POLL, NEWHANDLE, or DISPOSEHANDLE extended I/O callbacks, + * set some application-specific data. If ld is NULL, arg is used. If + * both ld and arg are NULL, LDAP_PARAM_ERROR is returned. + * + * Returns an LDAP API error code (LDAP_SUCCESS if all goes well). + */ +int LDAP_CALL prldap_set_session_info( LDAP *ld, void *sessionarg, + PRLDAPSessionInfo *seip ); + + +/* + * Function: prldap_get_session_info(). + * + * Given an LDAP session handle or a session argument such is passed to + * CONNECT, POLL, NEWHANDLE, or DISPOSEHANDLE extended I/O callbacks, + * retrieve some application-specific data. If ld is NULL, arg is used. If + * both ld and arg are NULL, LDAP_PARAM_ERROR is returned. + * + * Returns an LDAP API error code (LDAP_SUCCESS if all goes well, in + * which case the fields in the structure that seip points to are filled in). + */ +int LDAP_CALL prldap_get_session_info( LDAP *ld, void *sessionarg, + PRLDAPSessionInfo *seip ); + + +/* + * Data structure for socket specific information. + * Note: soinfo_size should be set to PRLDAP_SOCKETINFO_SIZE before use. + */ +struct prldap_socket_private; +typedef struct prldap_socket_info { + int soinfo_size; + PRFileDesc *soinfo_prfd; + struct prldap_socket_private *soinfo_appdata; +} PRLDAPSocketInfo; +#define PRLDAP_SOCKETINFO_SIZE sizeof( PRLDAPSocketInfo ) + + +/* + * Function: prldap_set_socket_info(). + * + * Given an integer fd and a socket argument such as those passed to the + * extended I/O callback functions, set socket specific information. + * + * Returns an LDAP API error code (LDAP_SUCCESS if all goes well). + * + * Note: it is only safe to change soinfo_prfd from within the CONNECT + * extended I/O callback function. + */ +int LDAP_CALL prldap_set_socket_info( int fd, void *socketarg, + PRLDAPSocketInfo *soip ); + +/* + * Function: prldap_get_socket_info(). + * + * Given an integer fd and a socket argument such as those passed to the + * extended I/O callback functions, retrieve socket specific information. + * + * Returns an LDAP API error code (LDAP_SUCCESS if all goes well, in + * which case the fields in the structure that soip points to are filled in). + */ +int LDAP_CALL prldap_get_socket_info( int fd, void *socketarg, + PRLDAPSocketInfo *soip ); + +/* + * Function: prldap_get_default_socket_info(). + * + * Given an LDAP session handle, retrieve socket specific information. + * If ld is NULL, LDAP_PARAM_ERROR is returned. + * + * Returns an LDAP API error code (LDAP_SUCCESS if all goes well, in + * which case the fields in the structure that soip points to are filled in). + */ +int LDAP_CALL prldap_get_default_socket_info( LDAP *ld, PRLDAPSocketInfo *soip ); + +/* + * Function: prldap_set_default_socket_info(). + * + * Given an LDAP session handle, set socket specific information. + * If ld is NULL, LDAP_PARAM_ERROR is returned. + * + * Returns an LDAP API error code (LDAP_SUCCESS if all goes well, in + * which case the fields in the structure that soip points to are filled in). + */ +int LDAP_CALL prldap_set_default_socket_info( LDAP *ld, PRLDAPSocketInfo *soip ); + +/* Function: prldap_is_installed() + * Check if NSPR routine is installed + */ +PRBool prldap_is_installed( LDAP *ld ); + +/* Function: prldap_import_connection(). + * Given a ldap handle with connection already done with ldap_init() + * installs NSPR routines and imports the original connection info. + * + * Returns an LDAP API error code (LDAP_SUCCESS if all goes well). + */ +int LDAP_CALL prldap_import_connection (LDAP *ld); + +#ifdef __cplusplus +} +#endif +#endif /* !defined(LDAP_PR_H) */ diff --git a/ldap/c-sdk/include/ldaprot.h b/ldap/c-sdk/include/ldaprot.h new file mode 100644 index 000000000..98aec13c8 --- /dev/null +++ b/ldap/c-sdk/include/ldaprot.h @@ -0,0 +1,203 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#ifndef _LDAPROT_H +#define _LDAPROT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define LDAP_VERSION1 1 +#define LDAP_VERSION2 2 +#define LDAP_VERSION3 3 +#define LDAP_VERSION LDAP_VERSION3 + +#define COMPAT20 +#define COMPAT30 +#if defined(COMPAT20) || defined(COMPAT30) +#define COMPAT +#endif + +#define LDAP_URL_PREFIX "ldap://" +#define LDAP_URL_PREFIX_LEN 7 +#define LDAPS_URL_PREFIX "ldaps://" +#define LDAPS_URL_PREFIX_LEN 8 +#define LDAP_REF_STR "Referral:\n" +#define LDAP_REF_STR_LEN 10 + +/* + * specific LDAP instantiations of BER types we know about + */ + +/* general stuff */ +#define LDAP_TAG_MESSAGE 0x30L /* tag is 16 + constructed bit */ +#define OLD_LDAP_TAG_MESSAGE 0x10L /* forgot the constructed bit */ +#define LDAP_TAG_MSGID 0x02L /* INTEGER */ +#define LDAP_TAG_LDAPDN 0x04L /* OCTET STRING */ +#define LDAP_TAG_CONTROLS 0xa0L /* context specific + constructed + 0 */ +#define LDAP_TAG_REFERRAL 0xa3L /* context specific + constructed + 3 */ +#define LDAP_TAG_NEWSUPERIOR 0x80L /* context specific + primitive + 0 */ +#define LDAP_TAG_MRA_OID 0x81L /* context specific + primitive + 1 */ +#define LDAP_TAG_MRA_TYPE 0x82L /* context specific + primitive + 2 */ +#define LDAP_TAG_MRA_VALUE 0x83L /* context specific + primitive + 3 */ +#define LDAP_TAG_MRA_DNATTRS 0x84L /* context specific + primitive + 4 */ +#define LDAP_TAG_EXOP_REQ_OID 0x80L /* context specific + primitive + 0 */ +#define LDAP_TAG_EXOP_REQ_VALUE 0x81L /* context specific + primitive + 1 */ +#define LDAP_TAG_EXOP_RES_OID 0x8aL /* context specific + primitive + 10 */ +#define LDAP_TAG_EXOP_RES_VALUE 0x8bL /* context specific + primitive + 11 */ +#define LDAP_TAG_SK_MATCHRULE 0x80L /* context specific + primitive + 0 */ +#define LDAP_TAG_SK_REVERSE 0x81L /* context specific + primitive + 1 */ +#define LDAP_TAG_SR_ATTRTYPE 0x80L /* context specific + primitive + 0 */ +#define LDAP_TAG_SASL_RES_CREDS 0x87L /* context specific + primitive + 7 */ +#define LDAP_TAG_VLV_BY_INDEX 0xa0L /* context specific + constructed + 0 */ +#define LDAP_TAG_VLV_BY_VALUE 0x81L /* context specific + primitive + 1 */ +#define LDAP_TAG_PWP_WARNING 0xA0L /* context specific + constructed */ +#define LDAP_TAG_PWP_SECSLEFT 0x80L /* context specific + primitive */ +#define LDAP_TAG_PWP_GRCLOGINS 0x81L /* context specific + primitive + 1 */ +#define LDAP_TAG_PWP_ERROR 0x81L /* context specific + primitive + 1 */ +#define LDAP_TAG_PWDMOD_REQ_ID 0x80L /* context specific + primitive + 0 */ +#define LDAP_TAG_PWDMOD_REQ_OLD 0x81L /* context specific + primitive + 1 */ +#define LDAP_TAG_PWDMOD_REQ_NEW 0x82L /* context specific + primitive + 2 */ +#define LDAP_TAG_PWDMOD_RES_GEN 0x80L /* context specific + primitive + 0 */ + +/* possible operations a client can invoke */ +#define LDAP_REQ_BIND 0x60L /* application + constructed + 0 */ +#define LDAP_REQ_UNBIND 0x42L /* application + primitive + 2 */ +#define LDAP_REQ_SEARCH 0x63L /* application + constructed + 3 */ +#define LDAP_REQ_MODIFY 0x66L /* application + constructed + 6 */ +#define LDAP_REQ_ADD 0x68L /* application + constructed + 8 */ +#define LDAP_REQ_DELETE 0x4aL /* application + primitive + 10 */ +#define LDAP_REQ_MODRDN 0x6cL /* application + constructed + 12 */ +#define LDAP_REQ_MODDN 0x6cL /* application + constructed + 12 */ +#define LDAP_REQ_RENAME 0x6cL /* application + constructed + 12 */ +#define LDAP_REQ_COMPARE 0x6eL /* application + constructed + 14 */ +#define LDAP_REQ_ABANDON 0x50L /* application + primitive + 16 */ +#define LDAP_REQ_EXTENDED 0x77L /* application + constructed + 23 */ + +/* U-M LDAP release 3.0 compatibility stuff */ +#define LDAP_REQ_UNBIND_30 0x62L +#define LDAP_REQ_DELETE_30 0x6aL +#define LDAP_REQ_ABANDON_30 0x70L + +/* + * old broken stuff for backwards compatibility - forgot application tag + * and constructed/primitive bit + */ +#define OLD_LDAP_REQ_BIND 0x00L +#define OLD_LDAP_REQ_UNBIND 0x02L +#define OLD_LDAP_REQ_SEARCH 0x03L +#define OLD_LDAP_REQ_MODIFY 0x06L +#define OLD_LDAP_REQ_ADD 0x08L +#define OLD_LDAP_REQ_DELETE 0x0aL +#define OLD_LDAP_REQ_MODRDN 0x0cL +#define OLD_LDAP_REQ_MODDN 0x0cL +#define OLD_LDAP_REQ_COMPARE 0x0eL +#define OLD_LDAP_REQ_ABANDON 0x10L + +/* old broken stuff for backwards compatibility */ +#define OLD_LDAP_RES_BIND 0x01L +#define OLD_LDAP_RES_SEARCH_ENTRY 0x04L +#define OLD_LDAP_RES_SEARCH_RESULT 0x05L +#define OLD_LDAP_RES_MODIFY 0x07L +#define OLD_LDAP_RES_ADD 0x09L +#define OLD_LDAP_RES_DELETE 0x0bL +#define OLD_LDAP_RES_MODRDN 0x0dL +#define OLD_LDAP_RES_MODDN 0x0dL +#define OLD_LDAP_RES_COMPARE 0x0fL + +/* U-M LDAP 3.0 compatibility auth methods */ +#define LDAP_AUTH_SIMPLE_30 0xa0L /* context specific + constructed */ +#define LDAP_AUTH_KRBV41_30 0xa1L /* context specific + constructed */ +#define LDAP_AUTH_KRBV42_30 0xa2L /* context specific + constructed */ + +/* old broken stuff */ +#define OLD_LDAP_AUTH_SIMPLE 0x00L +#define OLD_LDAP_AUTH_KRBV4 0x01L +#define OLD_LDAP_AUTH_KRBV42 0x02L + +/* U-M LDAP 3.0 compatibility filter types */ +#define LDAP_FILTER_PRESENT_30 0xa7L /* context specific + constructed */ + +/* filter types */ +#define LDAP_FILTER_AND 0xa0L /* context specific + constructed + 0 */ +#define LDAP_FILTER_OR 0xa1L /* context specific + constructed + 1 */ +#define LDAP_FILTER_NOT 0xa2L /* context specific + constructed + 2 */ +#define LDAP_FILTER_EQUALITY 0xa3L /* context specific + constructed + 3 */ +#define LDAP_FILTER_SUBSTRINGS 0xa4L /* context specific + constructed + 4 */ +#define LDAP_FILTER_GE 0xa5L /* context specific + constructed + 5 */ +#define LDAP_FILTER_LE 0xa6L /* context specific + constructed + 6 */ +#define LDAP_FILTER_PRESENT 0x87L /* context specific + primitive + 7 */ +#define LDAP_FILTER_APPROX 0xa8L /* context specific + constructed + 8 */ +#define LDAP_FILTER_EXTENDED 0xa9L /* context specific + constructed + 0 */ + +/* old broken stuff */ +#define OLD_LDAP_FILTER_AND 0x00L +#define OLD_LDAP_FILTER_OR 0x01L +#define OLD_LDAP_FILTER_NOT 0x02L +#define OLD_LDAP_FILTER_EQUALITY 0x03L +#define OLD_LDAP_FILTER_SUBSTRINGS 0x04L +#define OLD_LDAP_FILTER_GE 0x05L +#define OLD_LDAP_FILTER_LE 0x06L +#define OLD_LDAP_FILTER_PRESENT 0x07L +#define OLD_LDAP_FILTER_APPROX 0x08L + +/* substring filter component types */ +#define LDAP_SUBSTRING_INITIAL 0x80L /* context specific + primitive + 0 */ +#define LDAP_SUBSTRING_ANY 0x81L /* context specific + primitive + 1 */ +#define LDAP_SUBSTRING_FINAL 0x82L /* context specific + primitive + 2 */ + +/* extended filter component types */ +#define LDAP_FILTER_EXTENDED_OID 0x81L /* context spec. + prim. + 1 */ +#define LDAP_FILTER_EXTENDED_TYPE 0x82L /* context spec. + prim. + 2 */ +#define LDAP_FILTER_EXTENDED_VALUE 0x83L /* context spec. + prim. + 3 */ +#define LDAP_FILTER_EXTENDED_DNATTRS 0x84L /* context spec. + prim. + 4 */ + +/* U-M LDAP 3.0 compatibility substring filter component types */ +#define LDAP_SUBSTRING_INITIAL_30 0xa0L /* context specific */ +#define LDAP_SUBSTRING_ANY_30 0xa1L /* context specific */ +#define LDAP_SUBSTRING_FINAL_30 0xa2L /* context specific */ + +/* old broken stuff */ +#define OLD_LDAP_SUBSTRING_INITIAL 0x00L +#define OLD_LDAP_SUBSTRING_ANY 0x01L +#define OLD_LDAP_SUBSTRING_FINAL 0x02L + +#ifdef __cplusplus +} +#endif +#endif /* _LDAPROT_H */ diff --git a/ldap/c-sdk/include/ldif.h b/ldap/c-sdk/include/ldif.h new file mode 100644 index 000000000..87ce19e94 --- /dev/null +++ b/ldap/c-sdk/include/ldif.h @@ -0,0 +1,114 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Copyright (c) 1996 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. + */ + +/* NOTE: As of mozldap version 6.0.1 the LDIF functions are now + publicly usable. The LDIF functions were originally designed for + "internal use only" purposes and as such the APIs are not very modern + or safe. For example, the caller needs to be careful to provide + adequately sized buffers and so on. +*/ + +#ifndef _LDIF_H +#define _LDIF_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define LDIF_VERSION_ONE 1 /* LDIF standard version */ + +#define LDIF_MAX_LINE_WIDTH 76 /* maximum length of LDIF lines */ + +/* + * Macro to calculate maximum number of bytes that the base64 equivalent + * of an item that is "vlen" bytes long will take up. Base64 encoding + * uses one byte for every six bits in the value plus up to two pad bytes. + */ +#define LDIF_BASE64_LEN(vlen) (((vlen) * 4 / 3 ) + 3) + +/* + * Macro to calculate maximum size that an LDIF-encoded type (length + * tlen) and value (length vlen) will take up: room for type + ":: " + + * first newline + base64 value + continued lines. Each continued line + * needs room for a newline and a leading space character. + */ +#define LDIF_SIZE_NEEDED(tlen,vlen) \ + ((tlen) + 4 + LDIF_BASE64_LEN(vlen) \ + + ((LDIF_BASE64_LEN(vlen) + tlen + 3) / LDIF_MAX_LINE_WIDTH * 2 )) + +/* + * Options for ldif_put_type_and_value_with_options() and + * ldif_type_and_value_with_options(). + */ +#define LDIF_OPT_NOWRAP 0x01UL +#define LDIF_OPT_VALUE_IS_URL 0x02UL +#define LDIF_OPT_MINIMAL_ENCODING 0x04UL + +int ldif_parse_line( char *line, char **type, char **value, int *vlen); +char * ldif_getline( char **next ); +void ldif_put_type_and_value( char **out, char *t, char *val, int vlen ); +void ldif_put_type_and_value_nowrap( char **out, char *t, char *val, int vlen ); +void ldif_put_type_and_value_with_options( char **out, char *t, char *val, + int vlen, unsigned long options ); +char *ldif_type_and_value( char *type, char *val, int vlen ); +char *ldif_type_and_value_nowrap( char *type, char *val, int vlen ); +char *ldif_type_and_value_with_options( char *type, char *val, int vlen, + unsigned long options ); +int ldif_base64_decode( char *src, unsigned char *dst ); +int ldif_base64_encode( unsigned char *src, char *dst, int srclen, + int lenused ); +int ldif_base64_encode_nowrap( unsigned char *src, char *dst, int srclen, + int lenused ); +char *ldif_get_entry( FILE *fp, int *lineno ); + +#ifdef __cplusplus +} +#endif + +#endif /* _LDIF_H */ diff --git a/ldap/c-sdk/include/portable.h b/ldap/c-sdk/include/portable.h new file mode 100644 index 000000000..52698867f --- /dev/null +++ b/ldap/c-sdk/include/portable.h @@ -0,0 +1,462 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Copyright (c) 1994 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 _PORTABLE_H +#define _PORTABLE_H + +/* + * portable.h for LDAP -- this is where we define common stuff to make + * life easier on various Unix systems. + * + * Unless you are porting LDAP to a new platform, you should not need to + * edit this file. + */ + +#ifndef SYSV +#if defined( hpux ) || defined( SOLARIS ) || defined ( sgi ) || defined( SVR4 ) +#define SYSV +#endif +#endif + +/* + * under System V, use sysconf() instead of getdtablesize + */ +#if !defined( USE_SYSCONF ) && defined( SYSV ) +#define USE_SYSCONF +#endif + +/* + * under System V, daemons should use setsid() instead of detaching from their + * tty themselves + */ +#if !defined( USE_SETSID ) && defined( SYSV ) +#define USE_SETSID +#endif + +/* + * System V has socket options in filio.h + */ +#if !defined( NEED_FILIO ) && defined( SYSV ) && !defined( hpux ) && !defined( AIX ) +#define NEED_FILIO +#endif + +/* + * use lockf() under System V + */ +#if !defined( USE_LOCKF ) && ( defined( SYSV ) || defined( aix )) +#define USE_LOCKF +#endif + +/* + * on many systems, we should use waitpid() instead of waitN() + */ +#if !defined( USE_WAITPID ) && ( defined( SYSV ) || defined( sunos4 ) || defined( ultrix ) || defined( aix )) +#define USE_WAITPID +#endif + +/* + * define the wait status argument type + */ +#if ( defined( SunOS ) && SunOS < 40 ) || defined( nextstep ) +#define WAITSTATUSTYPE union wait +#else +#define WAITSTATUSTYPE int +#endif + +/* + * defined the options for openlog (syslog) + */ +#ifdef ultrix +#define OPENLOG_OPTIONS LOG_PID +#else +#define OPENLOG_OPTIONS ( LOG_PID | LOG_NOWAIT ) +#endif + +/* + * some systems don't have the BSD re_comp and re_exec routines + */ +#ifndef NEED_BSDREGEX +#if ( defined( SYSV ) || defined( NETBSD ) || defined( FREEBSD ) || defined(__OpenBSD__) || defined( linux ) || defined( DARWIN )) && !defined(sgi) +#define NEED_BSDREGEX +#endif +#endif + +/* + * many systems do not have the setpwfile() library routine... we just + * enable use for those systems we know have it. + */ +#ifndef HAVE_SETPWFILE +#if defined( sunos4 ) || defined( ultrix ) || defined( OSF1 ) +#define HAVE_SETPWFILE +#endif +#endif + +/* + * Are sys_errlist and sys_nerr declared in stdio.h? + */ +#ifndef SYSERRLIST_IN_STDIO +#if defined( freebsd ) +#define SYSERRLIST_IN_STDIO +#endif +#endif + + +/* + * Is snprintf() part of the standard C runtime library? + */ +#if defined(_WINDOWS) +#define snprintf _snprintf +#endif + + +/* + * Async IO. Use a non blocking implementation of connect() and + * dns functions + */ +#if !defined(LDAP_ASYNC_IO) +#if !defined(_WINDOWS) && !defined(macintosh) +#define LDAP_ASYNC_IO +#endif /* _WINDOWS */ +#endif + +/* + * for select() + */ +#if !defined(WINSOCK) && !defined(_WINDOWS) && !defined(macintosh) && !defined(XP_OS2) +#if defined(hpux) || defined(LINUX) || defined(SUNOS4) || defined(XP_BEOS) +#include <sys/time.h> +#else +#include <sys/select.h> +#endif +#if !defined(FD_SET) +#define NFDBITS 32 +#define FD_SETSIZE 32 +#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS))) +#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS))) +#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS))) +#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p))) +#endif /* !FD_SET */ +#endif /* !WINSOCK && !_WINDOWS && !macintosh */ + + +/* + * for connect() -- must we block signals when calling connect()? This + * is necessary on some buggy UNIXes. + */ +#if !defined(NSLDAPI_CONNECT_MUST_NOT_BE_INTERRUPTED) && \ + ( defined(AIX) || defined(IRIX) || defined(HPUX) || defined(SUNOS4) \ + || defined(SOLARIS) || defined(OSF1) ||defined(freebsd)) +#define NSLDAPI_CONNECT_MUST_NOT_BE_INTERRUPTED +#endif + +/* + * On most platforms, sigprocmask() works fine even in multithreaded code. + * But not everywhere. + */ +#ifdef AIX +#define NSLDAPI_MT_SAFE_SIGPROCMASK(h,s,o) sigthreadmask(h,s,o) +#else +#define NSLDAPI_MT_SAFE_SIGPROCMASK(h,s,o) sigprocmask(h,s,o) +#endif + +/* + * toupper and tolower macros are different under bsd and sys v + */ +#if defined( SYSV ) && !defined( hpux ) +#define TOUPPER(c) (isascii(c) && islower(c) ? _toupper(c) : c) +#define TOLOWER(c) (isascii(c) && isupper(c) ? _tolower(c) : c) +#else +#define TOUPPER(c) (isascii(c) && islower(c) ? toupper(c) : c) +#define TOLOWER(c) (isascii(c) && isupper(c) ? tolower(c) : c) +#endif + +/* + * put a cover on the tty-related ioctl calls we need to use + */ +#if defined( NeXT ) || (defined(SunOS) && SunOS < 40) +#define TERMIO_TYPE struct sgttyb +#define TERMFLAG_TYPE int +#define GETATTR( fd, tiop ) ioctl((fd), TIOCGETP, (caddr_t)(tiop)) +#define SETATTR( fd, tiop ) ioctl((fd), TIOCSETP, (caddr_t)(tiop)) +#define GETFLAGS( tio ) (tio).sg_flags +#define SETFLAGS( tio, flags ) (tio).sg_flags = (flags) +#else +#define USE_TERMIOS +#define TERMIO_TYPE struct termios +#define TERMFLAG_TYPE tcflag_t +#define GETATTR( fd, tiop ) tcgetattr((fd), (tiop)) +#define SETATTR( fd, tiop ) tcsetattr((fd), TCSANOW /* 0 */, (tiop)) +#define GETFLAGS( tio ) (tio).c_lflag +#define SETFLAGS( tio, flags ) (tio).c_lflag = (flags) +#endif + +#if ( !defined( HPUX9 )) && ( !defined( sunos4 )) && ( !defined( SNI )) && \ + ( !defined( HAVE_TIME_R )) +#define HAVE_TIME_R +#endif + +#if defined(SNI) || defined(LINUX1_2) +int strcasecmp(const char *, const char *); +#ifdef SNI +int strncasecmp(const char *, const char *, int); +#endif /* SNI */ +#ifdef LINUX1_2 +int strncasecmp(const char *, const char *, size_t); +#endif /* LINUX1_2 */ +#endif /* SNI || LINUX1_2 */ + +#if defined(_WINDOWS) || defined(macintosh) || defined(XP_OS2) || defined(DARWIN) +#define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname( n ) +#define NSLDAPI_CTIME( c, b, l ) ctime( c ) +#define STRTOK( s1, s2, l ) strtok( s1, s2 ) +#elif defined(XP_BEOS) +#define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname( n ) +#define NSLDAPI_CTIME( c, b, l ) ctime_r( c, b ) +#define STRTOK( s1, s2, l ) strtok_r( s1, s2, l ) +#define HAVE_STRTOK_R +#else /* UNIX */ +#if (defined(AIX) && defined(_THREAD_SAFE)) || defined(OSF1) +#define NSLDAPI_NETDB_BUF_SIZE sizeof(struct protoent_data) +#else +#define NSLDAPI_NETDB_BUF_SIZE 1024 +#endif + +#if defined(sgi) || defined(HPUX9) || defined(SCOOS) || \ + defined(UNIXWARE) || defined(SUNOS4) || defined(SNI) || defined(BSDI) || \ + defined(NCR) || defined(OSF1) || defined(NEC) || defined(VMS) || \ + ( defined(HPUX10) && !defined(_REENTRANT)) || defined(HPUX11) || \ + defined(UnixWare) || defined(NETBSD) || \ + defined(FREEBSD) || defined(OPENBSD) || \ + (defined(LINUX) && __GLIBC__ < 2) || \ + (defined(AIX) && !defined(USE_REENTRANT_LIBC)) +#define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname( n ) +#elif defined(AIX) +/* Maybe this is for another version of AIX? + Commenting out for AIX 4.1 for Nova + Replaced with following to lines, stolen from the #else below +#define GETHOSTBYNAME_BUF_T struct hostent_data +*/ +typedef char GETHOSTBYNAME_buf_t [NSLDAPI_NETDB_BUF_SIZE]; +#define GETHOSTBYNAME_BUF_T GETHOSTBYNAME_buf_t +#define GETHOSTBYNAME( n, r, b, l, e ) \ + (memset (&b, 0, l), gethostbyname_r (n, r, &b) ? NULL : r) +#elif defined(HPUX10) +#define GETHOSTBYNAME_BUF_T struct hostent_data +#define GETHOSTBYNAME( n, r, b, l, e ) nsldapi_compat_gethostbyname_r( n, r, (char *)&b, l, e ) +#elif defined(LINUX) || defined(DRAGONFLY) +typedef char GETHOSTBYNAME_buf_t [NSLDAPI_NETDB_BUF_SIZE]; +#define GETHOSTBYNAME_BUF_T GETHOSTBYNAME_buf_t +#define GETHOSTBYNAME( n, r, b, l, rp, e ) gethostbyname_r( n, r, b, l, rp, e ) +#define GETHOSTBYNAME_R_RETURNS_INT +#else +typedef char GETHOSTBYNAME_buf_t [NSLDAPI_NETDB_BUF_SIZE]; +#define GETHOSTBYNAME_BUF_T GETHOSTBYNAME_buf_t +#define GETHOSTBYNAME( n, r, b, l, e ) gethostbyname_r( n, r, b, l, e ) +#endif +#if defined(HPUX9) || defined(LINUX1_2) || defined(LINUX2_0) || \ + defined(LINUX2_1) || defined(SUNOS4) || defined(SNI) || \ + defined(SCOOS) || defined(BSDI) || defined(NCR) || \ + defined(NEC) || ( defined(HPUX10) && !defined(_REENTRANT)) || \ + (defined(AIX) && !defined(USE_REENTRANT_LIBC)) +#define NSLDAPI_CTIME( c, b, l ) ctime( c ) +#elif defined(HPUX10) && defined(_REENTRANT) && !defined(HPUX11) +#define NSLDAPI_CTIME( c, b, l ) nsldapi_compat_ctime_r( c, b, l ) +#elif defined( IRIX6_2 ) || defined( IRIX6_3 ) || defined(UNIXWARE) \ + || defined(OSF1V4) || defined(AIX) || defined(UnixWare) \ + || defined(hpux) || defined(HPUX11) || defined(NETBSD) \ + || defined(IRIX6) || defined(FREEBSD) || defined(VMS) \ + || defined(NTO) || defined(OPENBSD) || defined(DRAGONFLY) +#define NSLDAPI_CTIME( c, b, l ) ctime_r( c, b ) +#elif defined( OSF1V3 ) +#define NSLDAPI_CTIME( c, b, l ) (ctime_r( c, b, l ) ? NULL : b) +#else +#define NSLDAPI_CTIME( c, b, l ) ctime_r( c, b, l ) +#endif +#if defined(hpux9) || defined(SUNOS4) || defined(SNI) || \ + defined(SCOOS) || defined(BSDI) || defined(NCR) || defined(VMS) || \ + defined(NEC) || (defined(LINUX) && __GNU_LIBRARY__ != 6) || \ + (defined(AIX) && !defined(USE_REENTRANT_LIBC)) +#define STRTOK( s1, s2, l ) strtok( s1, s2 ) +#else +#define HAVE_STRTOK_R +#ifndef strtok_r +char *strtok_r(char *, const char *, char **); +#endif +#define STRTOK( s1, s2, l ) (char *)strtok_r( s1, s2, l ) +#endif /* STRTOK */ +#endif /* UNIX */ + +#if defined( ultrix ) || defined( nextstep ) +extern char *strdup(); +#endif /* ultrix || nextstep */ + +#if defined( sunos4 ) || defined( OSF1 ) +#define BSD_TIME 1 /* for servers/slapd/log.h */ +#endif /* sunos4 || osf */ + +#if defined(XP_OS2) +#include <machine/endian.h> /* for htonl, et.al. */ +#include <arpa/inet.h> /* for inet_addr() */ +#elif !defined(_WINDOWS) && !defined(macintosh) +#include <netinet/in.h> +#if !defined(XP_BEOS) +#include <arpa/inet.h> /* for inet_addr() */ +#endif +#endif + + +/* + * Define portable 32-bit integral types. + */ +#include <limits.h> +#if UINT_MAX >= 0xffffffffU /* an int holds at least 32 bits */ + typedef signed int nsldapi_int_32; + typedef unsigned int nsldapi_uint_32; +#else /* ints are < 32 bits; use long instead */ + typedef signed long nsldapi_int_32; + typedef unsigned long nsldapi_uint_32; +#endif + +/* + * Define a portable type for IPv4 style Internet addresses (32 bits): + */ +#if defined(_IN_ADDR_T) || defined(aix) || defined(HPUX11) || defined(OSF1) +typedef in_addr_t nsldapi_in_addr_t; +#else +typedef nsldapi_uint_32 nsldapi_in_addr_t; +#endif + +#ifdef SUNOS4 +#include <pcfs/pc_dir.h> /* for toupper() */ +int fprintf(FILE *, char *, ...); +int fseek(FILE *, long, int); +int fread(char *, int, int, FILE *); +int fclose(FILE *); +int fflush(FILE *); +int rewind(FILE *); +void *memmove(void *, const void *, size_t); +int strcasecmp(char *, char *); +int strncasecmp(char *, char *, int); +time_t time(time_t *); +void perror(char *); +int fputc(char, FILE *); +int fputs(char *, FILE *); +int re_exec(char *); +int socket(int, int, int); +void bzero(char *, int); +unsigned long inet_addr(char *); +char * inet_ntoa(struct in_addr); +int getdtablesize(); +int connect(int, struct sockaddr *, int); +#endif /* SUNOS4 */ + +/* #if defined(SUNOS4) || defined(SNI) */ +#if defined(SUNOS4) +int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); +#endif /* SUNOS4 || SNI */ + +/* + * SAFEMEMCPY is an overlap-safe copy from s to d of n bytes + */ +#ifdef macintosh +#define SAFEMEMCPY( d, s, n ) BlockMoveData( (Ptr)s, (Ptr)d, n ) +#else /* macintosh */ +#ifdef sunos4 +#define SAFEMEMCPY( d, s, n ) bcopy( s, d, n ) +#else /* sunos4 */ +#define SAFEMEMCPY( d, s, n ) memmove( d, s, n ) +#endif /* sunos4 */ +#endif /* macintosh */ + +#ifdef _WINDOWS + +#define strcasecmp strcmpi +#define strncasecmp _strnicmp +#define bzero(a, b) memset( a, 0, b ) +#define getpid _getpid +#define ioctl ioctlsocket +#define sleep(a) Sleep( a*1000 ) + +#define EMSGSIZE WSAEMSGSIZE +#define EWOULDBLOCK WSAEWOULDBLOCK +#define EHOSTUNREACH WSAEHOSTUNREACH + +#ifndef MAXPATHLEN +#define MAXPATHLEN _MAX_PATH +#endif + +/* We'd like this number to be prime for the hash + * into the Connection table */ +#define DS_MAX_NT_SOCKET_CONNECTIONS 2003 + +#elif defined(XP_OS2) + +#define strcasecmp stricmp +#define strncasecmp strnicmp +#define bzero(a, b) memset( a, 0, b ) +#include <string.h> /*for strcmpi()*/ +#include <time.h> /*for ctime()*/ + +#endif /* XP_OS2 */ + +/* Define a macro to support large files */ +#ifdef _LARGEFILE64_SOURCE +#define NSLDAPI_FOPEN( filename, mode ) fopen64( filename, mode ) +#else +#define NSLDAPI_FOPEN( filename, mode ) fopen( filename, mode ) +#endif + +#if defined(LINUX) || defined(AIX) || defined(HPUX) || defined(_WINDOWS) +size_t nsldapi_compat_strlcpy(char *dst, const char *src, size_t len); +#define STRLCPY nsldapi_compat_strlcpy +#else +#define STRLCPY strlcpy +#endif + +#endif /* _PORTABLE_H */ diff --git a/ldap/c-sdk/include/proto-ntutil.h b/ldap/c-sdk/include/proto-ntutil.h new file mode 100644 index 000000000..616f46897 --- /dev/null +++ b/ldap/c-sdk/include/proto-ntutil.h @@ -0,0 +1,99 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/****************************************************** + * + * proto-ntutil.h - Prototypes for utility functions used + * throughout slapd on NT. + * + ******************************************************/ +#if defined( _WINDOWS ) + +#ifndef _PROTO_NTUTIL +#define _PROTO_NTUTIL + +/* + * + * ntreg.c + * + */ +extern int SlapdGetRegSZ( LPTSTR lpszRegKey, LPSTR lpszValueName, LPTSTR lpszValue ); + +/* + * + * getopt.c + * + */ +extern int getopt (int argc, char *const *argv, const char *optstring); + +/* + * + * ntevent.c + * + */ +extern BOOL MultipleInstances(); +extern BOOL SlapdIsAService(); +extern void InitializeSlapdLogging( LPTSTR lpszRegLocation, LPTSTR lpszEventLogName, LPTSTR lpszMessageFile ); +extern void ReportSlapdEvent(WORD wEventType, DWORD dwIdEvent, WORD wNumInsertStrings, + char *pszStrings); +extern BOOL ReportSlapdStatusToSCMgr( + SERVICE_STATUS *serviceStatus, + SERVICE_STATUS_HANDLE serviceStatusHandle, + HANDLE Event, + DWORD dwCurrentState, + DWORD dwWin32ExitCode, + DWORD dwCheckPoint, + DWORD dwWaitHint); +extern void WINAPI SlapdServiceCtrlHandler(DWORD dwOpcode); +extern BOOL SlapdGetServerNameFromCmdline(char *szServerName, char *szCmdLine); + +/* + * + * ntgetpassword.c + * + */ +#ifdef NET_SSL +extern char *Slapd_GetPassword(); +#ifdef FORTEZZA +extern char *Slapd_GetFortezzaPIN(); +#endif +extern void CenterDialog(HWND hwndParent, HWND hwndDialog); +#endif /* NET_SSL */ + +#endif /* _PROTO_NTUTIL */ + +#endif /* _WINDOWS */ diff --git a/ldap/c-sdk/include/regex.h b/ldap/c-sdk/include/regex.h new file mode 100644 index 000000000..8d2c60962 --- /dev/null +++ b/ldap/c-sdk/include/regex.h @@ -0,0 +1,95 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#if defined( macintosh ) || defined( DOS ) || defined( _WINDOWS ) || defined( NEED_BSDREGEX ) || defined( XP_OS2 ) +/* + * Copyright (c) 1993 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. + */ +/* + * regex.h -- includes for regular expression matching routines + * 13 August 1993 Mark C Smith + */ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "ldap.h" + +#if !defined( NEEDPROTOS ) && defined( __STDC__ ) +#define NEEDPROTOS +#endif + +#ifdef _SLDAPD_H_ /* server build: no need to use LDAP_CALL stuff */ +#ifdef LDAP_CALL +#undef LDAP_CALL +#define LDAP_CALL +#endif +#endif + +#ifdef NEEDPROTOS +int re_init( void ); +void re_lock( void ); +int re_unlock( void ); +char * LDAP_CALL re_comp( const char *pat ); +int LDAP_CALL re_exec( const char *lp ); +void LDAP_CALL re_modw( char *s ); +int LDAP_CALL re_subs( char *src, char *dst ); +#else /* NEEDPROTOS */ +int re_init(); +void re_lock(); +int re_unlock(); +char * LDAP_CALL re_comp(); +int LDAP_CALL re_exec(); +void LDAP_CALL re_modw(); +int LDAP_CALL re_subs(); +#endif /* NEEDPROTOS */ + +#define re_fail( m, p ) + +#ifdef __cplusplus +} +#endif +#endif /* macintosh or DOS or or _WIN32 or NEED_BSDREGEX */ diff --git a/ldap/c-sdk/include/srchpref.h b/ldap/c-sdk/include/srchpref.h new file mode 100644 index 000000000..1e28a5dc9 --- /dev/null +++ b/ldap/c-sdk/include/srchpref.h @@ -0,0 +1,154 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is Mozilla Communicator client code, released + * March 31, 1998. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corporation. + * Portions created by the Initial Developer are Copyright (C) 1998-1999 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * + * Alternatively, the contents of this file may be used under the terms of + * either of the GNU General Public License Version 2 or later (the "GPL"), + * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Copyright (c) 1993, 1994 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. + * + * searchpref.h: display template library defines + */ + + +#ifndef _SRCHPREF_H +#define _SRCHPREF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* calling conventions used by library */ +#ifndef LDAP_CALL +#if defined( _WINDOWS ) || defined( _WIN32 ) +#define LDAP_C __cdecl +#ifndef _WIN32 +#define __stdcall _far _pascal +#define LDAP_CALLBACK _loadds +#else +#define LDAP_CALLBACK +#endif /* _WIN32 */ +#define LDAP_PASCAL __stdcall +#define LDAP_CALL LDAP_PASCAL +#else /* _WINDOWS */ +#define LDAP_C +#define LDAP_CALLBACK +#define LDAP_PASCAL +#define LDAP_CALL +#endif /* _WINDOWS */ +#endif /* LDAP_CALL */ + +struct ldap_searchattr { + char *sa_attrlabel; + char *sa_attr; + /* max 32 matchtypes for now */ + unsigned long sa_matchtypebitmap; + char *sa_selectattr; + char *sa_selecttext; + struct ldap_searchattr *sa_next; +}; + +struct ldap_searchmatch { + char *sm_matchprompt; + char *sm_filter; + struct ldap_searchmatch *sm_next; +}; + +struct ldap_searchobj { + char *so_objtypeprompt; + unsigned long so_options; + char *so_prompt; + short so_defaultscope; + char *so_filterprefix; + char *so_filtertag; + char *so_defaultselectattr; + char *so_defaultselecttext; + struct ldap_searchattr *so_salist; + struct ldap_searchmatch *so_smlist; + struct ldap_searchobj *so_next; +}; + +#define NULLSEARCHOBJ ((struct ldap_searchobj *)0) + +/* + * global search object options + */ +#define LDAP_SEARCHOBJ_OPT_INTERNAL 0x00000001 + +#define LDAP_IS_SEARCHOBJ_OPTION_SET( so, option ) \ + (((so)->so_options & option ) != 0 ) + +#define LDAP_SEARCHPREF_VERSION_ZERO 0 +#define LDAP_SEARCHPREF_VERSION 1 + +#define LDAP_SEARCHPREF_ERR_VERSION 1 +#define LDAP_SEARCHPREF_ERR_MEM 2 +#define LDAP_SEARCHPREF_ERR_SYNTAX 3 +#define LDAP_SEARCHPREF_ERR_FILE 4 + + +LDAP_API(int) +LDAP_CALL +ldap_init_searchprefs( char *file, struct ldap_searchobj **solistp ); + +LDAP_API(int) +LDAP_CALL +ldap_init_searchprefs_buf( char *buf, long buflen, + struct ldap_searchobj **solistp ); + +LDAP_API(void) +LDAP_CALL +ldap_free_searchprefs( struct ldap_searchobj *solist ); + +LDAP_API(struct ldap_searchobj *) +LDAP_CALL +ldap_first_searchobj( struct ldap_searchobj *solist ); + +LDAP_API(struct ldap_searchobj *) +LDAP_CALL +ldap_next_searchobj( struct ldap_searchobj *sollist, + struct ldap_searchobj *so ); + +#ifdef __cplusplus +} +#endif +#endif /* _SRCHPREF_H */ |