From 7ef67830affb375ab193e9693b06809092d04e4f Mon Sep 17 00:00:00 2001
From: Kurt Zeilenga <kurt@openldap.org>
Date: Tue, 19 Oct 1999 18:57:38 +0000
Subject: [PATCH] Minor adjustments based upon initial read of
 draft-ietf-ldapext-ldap-c-api-04.txt.

---
 include/lber.h               | 18 +++++++++---------
 include/ldap.h               | 30 +++++++++++++++++-------------
 libraries/liblber/bprint.c   |  8 ++++----
 libraries/liblber/decode.c   |  2 +-
 libraries/liblber/io.c       |  4 ++--
 libraries/liblber/lber-int.h |  4 ++--
 libraries/libldap/options.c  |  4 ++--
 7 files changed, 37 insertions(+), 33 deletions(-)

diff --git a/include/lber.h b/include/lber.h
index 229e97e55c..56eaa24e55 100644
--- a/include/lber.h
+++ b/include/lber.h
@@ -28,7 +28,7 @@
 
 LDAP_BEGIN_DECL
 
-/* boolean, enumerations, and integers */
+/* booleans, enumerations, and integers */
 typedef LBER_INT_T ber_int_t;
 
 /* signed and unsigned versions */
@@ -36,7 +36,7 @@ typedef signed LBER_INT_T ber_sint_t;
 typedef unsigned LBER_INT_T ber_uint_t;
 
 /* tags */
-typedef LBER_TAG_T ber_tag_t;
+typedef unsigned LBER_TAG_T ber_tag_t;
 
 /* "socket" descriptors */
 typedef LBER_SOCKET_T ber_socket_t;
@@ -45,7 +45,7 @@ typedef LBER_SOCKET_T ber_socket_t;
 typedef unsigned LBER_LEN_T ber_len_t;
 
 /* signed lengths */
-typedef LBER_LEN_T ber_slen_t;
+typedef signed LBER_LEN_T ber_slen_t;
 
 
 /* Overview of LBER tag construction
@@ -176,11 +176,11 @@ ber_bprint LDAP_P((
 
 LDAP_F( void )
 ber_dump LDAP_P((
-	LDAP_CONST BerElement *ber, int inout ));
+	BerElement *ber, int inout ));
 
 LDAP_F( void )
 ber_sos_dump LDAP_P((
-	LDAP_CONST Seqorset *sos ));
+	Seqorset *sos ));
 
 
 /*
@@ -202,7 +202,7 @@ ber_skip_tag LDAP_P((
 
 LDAP_F( ber_tag_t )
 ber_peek_tag LDAP_P((
-	LDAP_CONST BerElement *ber,
+	BerElement *ber,
 	ber_len_t *len ));
 
 LDAP_F( ber_tag_t )
@@ -386,7 +386,7 @@ ber_alloc_t LDAP_P((
 
 LDAP_F( BerElement * )
 ber_dup LDAP_P((
-	LDAP_CONST BerElement *ber ));
+	BerElement *ber ));
 
 LDAP_F( ber_tag_t )
 ber_get_next LDAP_P((
@@ -410,7 +410,7 @@ ber_init LDAP_P((
 
 LDAP_F( int )
 ber_flatten LDAP_P((
-	LDAP_CONST BerElement *ber,
+	BerElement *ber,
 	struct berval **bvPtr ));
 
 /*
@@ -419,7 +419,7 @@ ber_flatten LDAP_P((
 
 LDAP_F( int )
 ber_get_option LDAP_P((
-	LDAP_CONST void *item,
+	void *item,
 	int option,
 	void *outvalue));
 
diff --git a/include/ldap.h b/include/ldap.h
index c6da1e7f9e..ff3a22a2c5 100644
--- a/include/ldap.h
+++ b/include/ldap.h
@@ -43,10 +43,10 @@ LDAP_BEGIN_DECL
  * As such, the number will be above the old RFC but below 
  * whatever number does finally get assigned
  */
-#define LDAP_API_VERSION	2003
+#define LDAP_API_VERSION	2004
 #define LDAP_VENDOR_NAME	"OpenLDAP"
 /* We'll eventually release as 200 */
-#define LDAP_VENDOR_VERSION	192
+#define LDAP_VENDOR_VERSION	193
 
 /* OpenLDAP API Features */
 #define LDAP_API_FEATURE_X_OPENLDAP LDAP_VENDOR_VERSION
@@ -73,7 +73,7 @@ LDAP_BEGIN_DECL
 #define LDAP_ROOT_DSE				""
 #define LDAP_NO_ATTRS				"1.1"
 #define LDAP_ALL_USER_ATTRIBUTES	"*"
-#define LDAP_ALL_OPERATIONAL_ATTRIBUTES	"+"
+#define LDAP_ALL_OPERATIONAL_ATTRIBUTES	"+" /* OpenLDAP extension */
 
 /*
  * LDAP_OPTions defined by draft-ldapext-ldap-c-api-02
@@ -82,7 +82,7 @@ LDAP_BEGIN_DECL
  * 0x4000 - 0x7fff reserved for private and experimental options
  */
 #define LDAP_OPT_API_INFO			0x0000
-#define LDAP_OPT_DESC				0x0001
+#define LDAP_OPT_DESC				0x0001 /* deprecated */
 #define LDAP_OPT_DEREF				0x0002
 #define LDAP_OPT_SIZELIMIT			0x0003
 #define LDAP_OPT_TIMELIMIT			0x0004
@@ -100,8 +100,9 @@ LDAP_BEGIN_DECL
 #define LDAP_OPT_HOST_NAME			0x0030
 #define	LDAP_OPT_ERROR_NUMBER		0x0031
 #define LDAP_OPT_ERROR_STRING		0x0032
+#define LDAP_OPT_MATCHED_DN			0x0033
 
-/* 0x33 - 0x0fff not defined by current draft */
+/* 0x34 - 0x0fff not defined by current draft */
 
 /* extended options - none */
 
@@ -112,7 +113,6 @@ LDAP_BEGIN_DECL
 #define LDAP_OPT_DEBUG_LEVEL		0x5001	/* debug level */
 #define LDAP_OPT_TIMEOUT			0x5002	/* default timeout */
 #define LDAP_OPT_REFHOPLIMIT		0x5003	/* ref hop limit */
-#define LDAP_OPT_MATCHED_DN			0x5004	/* should have been in draft */
 #define LDAP_OPT_NETWORK_TIMEOUT        0x5005  /* socket level timeout */
 
 /* TLS options */
@@ -165,13 +165,14 @@ typedef struct ldapcontrol {
 /* LDAP Controls */
 	/* chase referrals controls */
 #define LDAP_CONTROL_REFERRALS	"1.2.840.113666.1.4.616"
-#define LDAP_CHASE_SUBORDINATE_REFERRALS	0x0020
-#define LDAP_CHASE_EXTERNAL_REFERRALS	0x0040
+#define LDAP_CHASE_SUBORDINATE_REFERRALS	0x0020U
+#define LDAP_CHASE_EXTERNAL_REFERRALS	0x0040U
 
 #define LDAP_CONTROL_MANAGEDSAIT "2.16.840.1.113730.3.4.2"
 
 /* LDAP Unsolicited Notifications */
-#define	LDAP_NOTICE_DISCONNECT	"1.3.6.1.4.1.1466.20036"
+#define	LDAP_NOTICE_OF_DISCONNECTION	"1.3.6.1.4.1.1466.20036"
+#define LDAP_NOTICE_DISCONNECT LDAP_NOTICE_OF_DISCONNECTION
 
 /* LDAP Extended Operations */
 
@@ -244,7 +245,9 @@ typedef struct ldapcontrol {
 #define LDAP_RES_RENAME			LDAP_RES_MODRDN	/* application + constructed */
 #define LDAP_RES_COMPARE		(ber_tag_t) 0x6fU	/* application + constructed */
 #define LDAP_RES_EXTENDED		(ber_tag_t) 0x78U	/* V3: application + constructed */
-#define LDAP_RES_ANY			((ber_tag_t)(~0))
+
+#define LDAP_RES_ANY			((ber_tag_t)(-1))
+#define LDAP_RES_UNSOLICITED	((ber_tag_t)(0))
 
 
 /* sasl methods */
@@ -290,6 +293,7 @@ typedef struct ldapcontrol {
 /* for modifications */
 typedef struct ldapmod {
 	int		mod_op;
+
 #define LDAP_MOD_ADD		(ber_int_t) 0x0000
 #define LDAP_MOD_DELETE		(ber_int_t) 0x0001
 #define LDAP_MOD_REPLACE	(ber_int_t) 0x0002
@@ -297,8 +301,8 @@ typedef struct ldapmod {
 /* IMPORTANT: do not use code 0x1000 (or above),
  * it is used internally by the backends!
  * (see ldap/servers/slapd/slap.h)
- * JCG 05/1999 (gomez@engr.sgi.com)
  */
+
 	char		*mod_type;
 	union mod_vals_u {
 		char		**modv_strvals;
@@ -496,7 +500,7 @@ typedef struct ldap_url_desc {
 
 /*
  * The API draft spec says we should declare (or cause to be declared)
- * 'struct timeval'.   We don't.  See LDAPext discussions.
+ * 'struct timeval'.   We don't.  See IETF LDAPext discussions.
  */
 struct timeval;
 
@@ -505,7 +509,7 @@ struct timeval;
  */
 LDAP_F( int )
 ldap_get_option LDAP_P((
-	LDAP_CONST LDAP *ld,
+	LDAP *ld,
 	int option,
 	void *outvalue));
 
diff --git a/libraries/liblber/bprint.c b/libraries/liblber/bprint.c
index eb8808563c..6492f975d2 100644
--- a/libraries/liblber/bprint.c
+++ b/libraries/liblber/bprint.c
@@ -153,7 +153,7 @@ int
 ber_log_dump(
 	int errlvl,
 	int loglvl,
-	const BerElement *ber,
+	BerElement *ber,
 	int inout )
 {
 	assert( ber != NULL );
@@ -169,7 +169,7 @@ ber_log_dump(
 
 void
 ber_dump(
-	LDAP_CONST BerElement *ber,
+	BerElement *ber,
 	int inout )
 {
 	char buf[132];
@@ -201,7 +201,7 @@ int
 ber_log_sos_dump(
 	int errlvl,
 	int loglvl,
-	const Seqorset *sos )
+	Seqorset *sos )
 {
 	assert( sos != NULL );
 
@@ -215,7 +215,7 @@ ber_log_sos_dump(
 
 void
 ber_sos_dump(
-	LDAP_CONST Seqorset *sos )
+	Seqorset *sos )
 {
 	char buf[132];
 
diff --git a/libraries/liblber/decode.c b/libraries/liblber/decode.c
index e2c204d793..ee2bd49a7a 100644
--- a/libraries/liblber/decode.c
+++ b/libraries/liblber/decode.c
@@ -132,7 +132,7 @@ ber_skip_tag( BerElement *ber, ber_len_t *len )
 
 ber_tag_t
 ber_peek_tag(
-	LDAP_CONST BerElement *ber_in,
+	BerElement *ber_in,
 	ber_len_t *len )
 {
 	ber_tag_t	tag;
diff --git a/libraries/liblber/io.c b/libraries/liblber/io.c
index 830c16e5f0..cbcbb84ba3 100644
--- a/libraries/liblber/io.c
+++ b/libraries/liblber/io.c
@@ -299,7 +299,7 @@ der_alloc( void )	/* deprecated */
 }
 
 BerElement *
-ber_dup( LDAP_CONST BerElement *ber )
+ber_dup( BerElement *ber )
 {
 	BerElement	*new;
 
@@ -376,7 +376,7 @@ ber_init( struct berval *bv )
 ** the returned berval.
 */
 int ber_flatten(
-	LDAP_CONST BerElement *ber,
+	BerElement *ber,
 	struct berval **bvPtr)
 {
 	struct berval *bv;
diff --git a/libraries/liblber/lber-int.h b/libraries/liblber/lber-int.h
index 7d080349f5..8a6cd6b0e9 100644
--- a/libraries/liblber/lber-int.h
+++ b/libraries/liblber/lber-int.h
@@ -198,14 +198,14 @@ LDAP_F( int )
 ber_log_dump LDAP_P((
 	int errlvl,
 	int loglvl,
-	const BerElement *ber,
+	BerElement *ber,
 	int inout ));
 
 LDAP_F( int )
 ber_log_sos_dump LDAP_P((
 	int errlvl,
 	int loglvl,
-	const Seqorset *sos ));
+	Seqorset *sos ));
 
 
 /* memory.c */
diff --git a/libraries/libldap/options.c b/libraries/libldap/options.c
index 12edf629fc..27d7c2db3a 100644
--- a/libraries/libldap/options.c
+++ b/libraries/libldap/options.c
@@ -80,11 +80,11 @@ static const LDAPAPIFeatureInfo features[] = {
 
 int
 ldap_get_option(
-	LDAP_CONST LDAP	*ld,
+	LDAP	*ld,
 	int		option,
 	void	*outvalue)
 {
-	LDAP_CONST struct ldapoptions *lo;
+	const struct ldapoptions *lo;
 
 	if( ldap_int_global_options.ldo_valid != LDAP_INITIALIZED ) {
 		ldap_int_initialize();
-- 
GitLab