clean, indent

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@13885 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2004-05-28 11:34:32 +00:00
parent c2ac17b82e
commit 31a565d11c

View File

@@ -152,7 +152,7 @@ LDAP_no_size_limit(krb5_context context, LDAP *lp)
static krb5_error_code static krb5_error_code
LDAP__setmod(LDAPMod *** modlist, int modop, const char *attribute, LDAP__setmod(LDAPMod *** modlist, int modop, const char *attribute,
int *pIndex) int *pIndex)
{ {
int cMods; int cMods;
@@ -210,39 +210,36 @@ static krb5_error_code
LDAP_addmod_len(LDAPMod *** modlist, int modop, const char *attribute, LDAP_addmod_len(LDAPMod *** modlist, int modop, const char *attribute,
unsigned char *value, size_t len) unsigned char *value, size_t len)
{ {
int cMods, cValues = 0;
krb5_error_code ret; krb5_error_code ret;
int cMods, i = 0;
ret = LDAP__setmod(modlist, modop | LDAP_MOD_BVALUES, attribute, &cMods); ret = LDAP__setmod(modlist, modop | LDAP_MOD_BVALUES, attribute, &cMods);
if (ret != 0) { if (ret)
return ret; return ret;
}
if (value != NULL) { if (value != NULL) {
struct berval *bValue; struct berval **bv;
struct berval ***pbValues = &((*modlist)[cMods]->mod_bvalues);
if (*pbValues != NULL) { bv = (*modlist)[cMods]->mod_bvalues;
for (cValues = 0; (*pbValues)[cValues] != NULL; cValues++) if (bv != NULL) {
for (i = 0; bv[i] != NULL; i++)
; ;
*pbValues = (struct berval **)ber_memrealloc(*pbValues, (cValues + 2) bv = ber_memrealloc(bv, (i + 2) * sizeof(*bv));
* sizeof(struct berval *)); } else
} else { bv = ber_memalloc(2 * sizeof(*bv));
*pbValues = (struct berval **)ber_memalloc(2 * sizeof(struct berval *)); if (bv == NULL)
}
if (*pbValues == NULL) {
return ENOMEM; return ENOMEM;
}
(*pbValues)[cValues] = (struct berval *)ber_memalloc(sizeof(struct berval));; (*modlist)[cMods]->mod_bvalues = bv;
if ((*pbValues)[cValues] == NULL) {
bv[i] = ber_memalloc(sizeof(*bv));;
if (bv[i] == NULL)
return ENOMEM; return ENOMEM;
}
bValue = (*pbValues)[cValues]; bv[i]->bv_val = value;
bValue->bv_val = value; bv[i]->bv_len = len;
bValue->bv_len = len;
(*pbValues)[cValues + 1] = NULL; bv[i + 1] = NULL;
} }
return 0; return 0;
@@ -252,32 +249,33 @@ static krb5_error_code
LDAP_addmod(LDAPMod *** modlist, int modop, const char *attribute, LDAP_addmod(LDAPMod *** modlist, int modop, const char *attribute,
const char *value) const char *value)
{ {
int cMods, cValues = 0; int cMods, i = 0;
krb5_error_code ret; krb5_error_code ret;
ret = LDAP__setmod(modlist, modop, attribute, &cMods); ret = LDAP__setmod(modlist, modop, attribute, &cMods);
if (ret != 0) { if (ret != 0)
return ret; return ret;
}
if (value != NULL) { if (value != NULL) {
char ***pValues = &((*modlist)[cMods]->mod_values); char **bv;
if (*pValues != NULL) { bv = (*modlist)[cMods]->mod_values;
for (cValues = 0; (*pValues)[cValues] != NULL; cValues++) if (bv != NULL) {
for (i = 0; bv[i] != NULL; i++)
; ;
*pValues = (char **)ber_memrealloc(*pValues, (cValues + 2) * sizeof(char *)); bv = ber_memrealloc(bv, (i + 2) * sizeof(*bv));
} else { } else
*pValues = (char **)ber_memalloc(2 * sizeof(char *)); bv = ber_memalloc(2 * sizeof(*bv));
} if (bv == NULL)
if (*pValues == NULL) {
return ENOMEM; return ENOMEM;
}
(*pValues)[cValues] = ber_strdup(value); (*modlist)[cMods]->mod_values = bv;
if ((*pValues)[cValues] == NULL) {
bv[i] = ber_strdup(value);
if (bv[i] == NULL)
return ENOMEM; return ENOMEM;
}
(*pValues)[cValues + 1] = NULL; bv[i + 1] = NULL;
} }
return 0; return 0;
@@ -488,10 +486,9 @@ LDAP_entry2mods(krb5_context context, HDB * db, hdb_entry * ent,
if (is_heimdal_entry && ent->valid_start) { if (is_heimdal_entry && ent->valid_start) {
if (orig.valid_end == NULL if (orig.valid_end == NULL
|| (*(ent->valid_start) != *(orig.valid_start))) { || (*(ent->valid_start) != *(orig.valid_start))) {
ret = ret = LDAP_addmod_generalized_time(&mods, LDAP_MOD_REPLACE,
LDAP_addmod_generalized_time(&mods, LDAP_MOD_REPLACE, "krb5ValidStart",
"krb5ValidStart", ent->valid_start);
ent->valid_start);
if (ret != 0) { if (ret != 0) {
goto out; goto out;
} }
@@ -501,10 +498,9 @@ LDAP_entry2mods(krb5_context context, HDB * db, hdb_entry * ent,
if (is_heimdal_entry && ent->valid_end) { if (is_heimdal_entry && ent->valid_end) {
if (orig.valid_end == NULL if (orig.valid_end == NULL
|| (*(ent->valid_end) != *(orig.valid_end))) { || (*(ent->valid_end) != *(orig.valid_end))) {
ret = ret = LDAP_addmod_generalized_time(&mods, LDAP_MOD_REPLACE,
LDAP_addmod_generalized_time(&mods, LDAP_MOD_REPLACE, "krb5ValidEnd",
"krb5ValidEnd", ent->valid_end);
ent->valid_end);
if (ret != 0) { if (ret != 0) {
goto out; goto out;
} }
@@ -514,10 +510,9 @@ LDAP_entry2mods(krb5_context context, HDB * db, hdb_entry * ent,
if (ent->pw_end) { if (ent->pw_end) {
if (orig.pw_end == NULL || (*(ent->pw_end) != *(orig.pw_end))) { if (orig.pw_end == NULL || (*(ent->pw_end) != *(orig.pw_end))) {
if (is_heimdal_entry) { if (is_heimdal_entry) {
ret = ret = LDAP_addmod_generalized_time(&mods, LDAP_MOD_REPLACE,
LDAP_addmod_generalized_time(&mods, LDAP_MOD_REPLACE, "krb5PasswordEnd",
"krb5PasswordEnd", ent->pw_end);
ent->pw_end);
if (ret != 0) { if (ret != 0) {
goto out; goto out;
} }
@@ -530,7 +525,8 @@ LDAP_entry2mods(krb5_context context, HDB * db, hdb_entry * ent,
ret = ENOMEM; ret = ENOMEM;
goto out; goto out;
} }
ret = LDAP_addmod(&mods, LDAP_MOD_REPLACE, "sambaPwdMustChange", tmp); ret = LDAP_addmod(&mods, LDAP_MOD_REPLACE,
"sambaPwdMustChange", tmp);
free(tmp); free(tmp);
if (ret != 0) { if (ret != 0) {
goto out; goto out;