]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/ldapsync.c
allow backwards compatibility for 'T' option (single char)
[openldap] / servers / slapd / ldapsync.c
index c4f45627eb440985cd37a1913c8f18d4c354eb51..27da812abd8ea2d786bebbb97f16d486932caa99 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2003 The OpenLDAP Foundation.
+ * Copyright 2003-2004 The OpenLDAP Foundation.
  * Portions Copyright 2003 IBM Corporation.
  * All rights reserved.
  *
 #include "ldap_pvt.h"
 #include "lutil.h"
 #include "slap.h"
+#include "../../libraries/liblber/lber-int.h" /* get ber_strndup() */
 #include "lutil_ldap.h"
 
+#if 0
+struct sync_cookie *slap_sync_cookie = NULL;
+#else
+struct slap_sync_cookie_s slap_sync_cookie =
+       LDAP_STAILQ_HEAD_INITIALIZER( slap_sync_cookie );
+#endif
+
 int
 slap_build_sync_state_ctrl(
        Operation       *op,
@@ -46,7 +54,7 @@ slap_build_sync_state_ctrl(
        BerElementBuffer berbuf;
        BerElement *ber = (BerElement *)&berbuf;
 
-       struct berval entryuuid_bv      = { 0, NULL };
+       struct berval entryuuid_bv      = BER_BVNULL;
 
        ber_init2( ber, 0, LBER_USE_DER );
        ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
@@ -165,7 +173,7 @@ slap_build_sync_state_ctrl_from_slog(
        BerElementBuffer berbuf;
        BerElement *ber = (BerElement *)&berbuf;
 
-       struct berval entryuuid_bv      = { 0, NULL };
+       struct berval entryuuid_bv      = BER_BVNULL;
 
        ber_init2( ber, NULL, LBER_USE_DER );
        ber_set_option( ber, LBER_OPT_BER_MEMCTX, &op->o_tmpmemctx );
@@ -386,8 +394,8 @@ slap_parse_sync_cookie(
                return -1;
 
        if (( csn_ptr = strstr( cookie->octet_str[0].bv_val, "csn=" )) != NULL ) {
-               csn_str = (char *) SLAP_STRNDUP( csn_ptr, LDAP_LUTIL_CSNSTR_BUFSIZE );
-               if ( cval = strchr( csn_str, ',' )) {
+               csn_str = SLAP_STRNDUP( csn_ptr, LDAP_LUTIL_CSNSTR_BUFSIZE );
+               if ( (cval = strchr( csn_str, ',' )) != NULL ) {
                        *cval = '\0';
                        csn_str_len = cval - csn_str - (sizeof("csn=") - 1);
                } else {
@@ -405,9 +413,9 @@ slap_parse_sync_cookie(
        }
 
        if (( sid_ptr = strstr( cookie->octet_str->bv_val, "sid=" )) != NULL ) {
-               sid_str = (char *) SLAP_STRNDUP( sid_ptr,
+               sid_str = SLAP_STRNDUP( sid_ptr,
                                                        SLAP_SYNC_SID_SIZE + sizeof("sid=") - 1 );
-               if ( cval = strchr( sid_str, ',' )) {
+               if ( (cval = strchr( sid_str, ',' )) != NULL ) {
                        *cval = '\0';
                }
                cookie->sid = atoi( sid_str + sizeof("sid=") - 1 );
@@ -417,9 +425,9 @@ slap_parse_sync_cookie(
        }
 
        if (( rid_ptr = strstr( cookie->octet_str->bv_val, "rid=" )) != NULL ) {
-               rid_str = (char *) SLAP_STRNDUP( rid_ptr,
+               rid_str = SLAP_STRNDUP( rid_ptr,
                                                        SLAP_SYNC_RID_SIZE + sizeof("rid=") - 1 );
-               if ( cval = strchr( rid_str, ',' )) {
+               if ( (cval = strchr( rid_str, ',' )) != NULL ) {
                        *cval = '\0';
                }
                cookie->rid = atoi( rid_str + sizeof("rid=") - 1 );
@@ -427,6 +435,7 @@ slap_parse_sync_cookie(
        } else {
                cookie->rid = -1;
        }
+       return 0;
 }
 
 int
@@ -435,9 +444,9 @@ slap_init_sync_cookie_ctxcsn(
 )
 {
        char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE + 4 ];
-       struct berval octet_str = { 0, NULL };
-       struct berval ctxcsn = { 0, NULL };
-       struct berval ctxcsn_dup = { 0, NULL };
+       struct berval octet_str = BER_BVNULL;
+       struct berval ctxcsn = BER_BVNULL;
+       struct berval ctxcsn_dup = BER_BVNULL;
        struct berval slap_syncCookie;
 
        if ( cookie == NULL )
@@ -514,7 +523,7 @@ slap_build_syncUUID_set(
        int ret;
        Attribute* a;
 
-       struct berval entryuuid_bv      = { 0, NULL };
+       struct berval entryuuid_bv      = BER_BVNULL;
 
        for ( a = e->e_attrs; a != NULL; a = a->a_next ) {
                AttributeDescription *desc = a->a_desc;