text
stringlengths
0
2.08k
slapi_ch_free((void **)&cookiestr);
} else {
rc = ber_printf(ber, "}");
}
}
if (rc != -1) {
rc = ber_flatten(ber, &bvp);
}
ber_free(ber, 1);
slapi_ch_free((void **)&uuid);
if (rc == -1) {
return (LDAP_OPERATIONS_ERROR);
}
*ctrlp = (LDAPControl *)slapi_ch_malloc(sizeof(LDAPControl));
(*ctrlp)->ldctl_iscritical = 0;
(*ctrlp)->ldctl_oid = slapi_ch_strdup(LDAP_CONTROL_SYNC_STATE);
(*ctrlp)->ldctl_value = *bvp; /* struct copy */
bvp->bv_val = NULL;
ber_bvfree(bvp);
return (LDAP_SUCCESS);
}
/*
* syncDoneValue ::= SEQUENCE {
* cookie syncCookie OPTIONAL
* refreshDeletes BOOLEAN DEFAULT FALSE
* }
*
*/
int
sync_create_sync_done_control(LDAPControl **ctrlp, int refresh, char *cookie)
{
int rc;
BerElement *ber;
struct berval *bvp;
if (ctrlp == NULL || (ber = der_alloc()) == NULL) {
return (LDAP_OPERATIONS_ERROR);
}
*ctrlp = NULL;
if (cookie) {
if ((rc = ber_printf(ber, "{s", cookie)) != -1) {
if (refresh) {
rc = ber_printf(ber, "b}", refresh);
} else {
rc = ber_printf(ber, "}");
}
}
} else {
if (refresh) {
rc = ber_printf(ber, "{b}", refresh);
} else {
rc = ber_printf(ber, "{}");
}
}
if (rc != -1) {
rc = ber_flatten(ber, &bvp);
}
ber_free(ber, 1);
if (rc == -1) {
return (LDAP_OPERATIONS_ERROR);
}
*ctrlp = (LDAPControl *)slapi_ch_malloc(sizeof(LDAPControl));
(*ctrlp)->ldctl_iscritical = 0;
(*ctrlp)->ldctl_oid = slapi_ch_strdup(LDAP_CONTROL_SYNC_DONE);
(*ctrlp)->ldctl_value = *bvp; /* struct copy */
bvp->bv_val = NULL;
ber_bvfree(bvp);
return (LDAP_SUCCESS);
}
char *
sync_cookie2str(Sync_Cookie *cookie)
{
char *cookiestr = NULL;
if (cookie) {
if (cookie->openldap_compat) {
char buf[16] = {0};
sync_ulong2olcsn(cookie->cookie_change_info, buf);
cookiestr = slapi_ch_smprintf("%s,csn=%s.000000Z#000000#000#000000",
cookie->cookie_client_signature,
buf);
} else {
cookiestr = slapi_ch_smprintf("%s#%s#%lu",
cookie->cookie_server_signature,
cookie->cookie_client_signature,
cookie->cookie_change_info);
}
}