mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-03-07 14:18:15 +08:00
constify use of invalue in <ber/ldap>_set_option()
This commit is contained in:
parent
2cc187ffbf
commit
96e8fafb51
@ -76,7 +76,8 @@ ber_set_option(
|
|||||||
&& ( option == LBER_OPT_MEMORY_FNS )
|
&& ( option == LBER_OPT_MEMORY_FNS )
|
||||||
&& ( invalue != NULL ))
|
&& ( invalue != NULL ))
|
||||||
{
|
{
|
||||||
BerMemoryFunctions *f = (BerMemoryFunctions *) invalue;
|
const BerMemoryFunctions *f =
|
||||||
|
(const BerMemoryFunctions *) invalue;
|
||||||
|
|
||||||
/* make sure all functions are provided */
|
/* make sure all functions are provided */
|
||||||
if(!( f->bmf_malloc && f->bmf_calloc
|
if(!( f->bmf_malloc && f->bmf_calloc
|
||||||
@ -107,7 +108,7 @@ ber_set_option(
|
|||||||
|
|
||||||
if(item == NULL) {
|
if(item == NULL) {
|
||||||
if(option == LBER_OPT_BER_DEBUG) {
|
if(option == LBER_OPT_BER_DEBUG) {
|
||||||
ber_int_debug = * (int *) invalue;
|
ber_int_debug = * (const int *) invalue;
|
||||||
return LBER_OPT_SUCCESS;
|
return LBER_OPT_SUCCESS;
|
||||||
|
|
||||||
} else if(option == LBER_OPT_LOG_PRINT_FN) {
|
} else if(option == LBER_OPT_LOG_PRINT_FN) {
|
||||||
@ -124,12 +125,12 @@ ber_set_option(
|
|||||||
switch(option) {
|
switch(option) {
|
||||||
case LBER_OPT_BER_OPTIONS:
|
case LBER_OPT_BER_OPTIONS:
|
||||||
assert( BER_VALID( ber ) );
|
assert( BER_VALID( ber ) );
|
||||||
ber->ber_options = * (int *) invalue;
|
ber->ber_options = * (const int *) invalue;
|
||||||
return LBER_OPT_SUCCESS;
|
return LBER_OPT_SUCCESS;
|
||||||
|
|
||||||
case LBER_OPT_BER_DEBUG:
|
case LBER_OPT_BER_DEBUG:
|
||||||
assert( BER_VALID( ber ) );
|
assert( BER_VALID( ber ) );
|
||||||
ber->ber_debug = * (int *) invalue;
|
ber->ber_debug = * (const int *) invalue;
|
||||||
return LBER_OPT_SUCCESS;
|
return LBER_OPT_SUCCESS;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -330,19 +330,19 @@ ldap_set_option(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LDAP_OPT_DEREF:
|
case LDAP_OPT_DEREF:
|
||||||
lo->ldo_deref = * (int *) invalue;
|
lo->ldo_deref = * (const int *) invalue;
|
||||||
return LDAP_OPT_SUCCESS;
|
return LDAP_OPT_SUCCESS;
|
||||||
|
|
||||||
case LDAP_OPT_SIZELIMIT:
|
case LDAP_OPT_SIZELIMIT:
|
||||||
lo->ldo_sizelimit = * (int *) invalue;
|
lo->ldo_sizelimit = * (const int *) invalue;
|
||||||
return LDAP_OPT_SUCCESS;
|
return LDAP_OPT_SUCCESS;
|
||||||
|
|
||||||
case LDAP_OPT_TIMELIMIT:
|
case LDAP_OPT_TIMELIMIT:
|
||||||
lo->ldo_timelimit = * (int *) invalue;
|
lo->ldo_timelimit = * (const int *) invalue;
|
||||||
return LDAP_OPT_SUCCESS;
|
return LDAP_OPT_SUCCESS;
|
||||||
|
|
||||||
case LDAP_OPT_PROTOCOL_VERSION: {
|
case LDAP_OPT_PROTOCOL_VERSION: {
|
||||||
int vers = * (int *) invalue;
|
int vers = * (const int *) invalue;
|
||||||
if (vers < LDAP_VERSION_MIN || vers > LDAP_VERSION_MAX) {
|
if (vers < LDAP_VERSION_MIN || vers > LDAP_VERSION_MAX) {
|
||||||
/* not supported */
|
/* not supported */
|
||||||
break;
|
break;
|
||||||
@ -351,7 +351,8 @@ ldap_set_option(
|
|||||||
} return LDAP_OPT_SUCCESS;
|
} return LDAP_OPT_SUCCESS;
|
||||||
|
|
||||||
case LDAP_OPT_SERVER_CONTROLS: {
|
case LDAP_OPT_SERVER_CONTROLS: {
|
||||||
LDAPControl **controls = (LDAPControl **) invalue;
|
LDAPControl *const *controls =
|
||||||
|
(LDAPControl *const *) invalue;
|
||||||
|
|
||||||
ldap_controls_free( lo->ldo_sctrls );
|
ldap_controls_free( lo->ldo_sctrls );
|
||||||
|
|
||||||
@ -360,8 +361,7 @@ ldap_set_option(
|
|||||||
return LDAP_OPT_SUCCESS;
|
return LDAP_OPT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
lo->ldo_sctrls =
|
lo->ldo_sctrls = ldap_controls_dup( controls );
|
||||||
ldap_controls_dup( (LDAPControl **) invalue );
|
|
||||||
|
|
||||||
if(lo->ldo_sctrls == NULL) {
|
if(lo->ldo_sctrls == NULL) {
|
||||||
/* memory allocation error ? */
|
/* memory allocation error ? */
|
||||||
@ -370,7 +370,8 @@ ldap_set_option(
|
|||||||
} return LDAP_OPT_SUCCESS;
|
} return LDAP_OPT_SUCCESS;
|
||||||
|
|
||||||
case LDAP_OPT_CLIENT_CONTROLS: {
|
case LDAP_OPT_CLIENT_CONTROLS: {
|
||||||
LDAPControl **controls = (LDAPControl **) invalue;
|
LDAPControl *const *controls =
|
||||||
|
(LDAPControl *const *) invalue;
|
||||||
|
|
||||||
ldap_controls_free( lo->ldo_cctrls );
|
ldap_controls_free( lo->ldo_cctrls );
|
||||||
|
|
||||||
@ -379,8 +380,7 @@ ldap_set_option(
|
|||||||
return LDAP_OPT_SUCCESS;
|
return LDAP_OPT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
lo->ldo_cctrls =
|
lo->ldo_cctrls = ldap_controls_dup( controls );
|
||||||
ldap_controls_dup( (LDAPControl **) invalue );
|
|
||||||
|
|
||||||
if(lo->ldo_cctrls == NULL) {
|
if(lo->ldo_cctrls == NULL) {
|
||||||
/* memory allocation error ? */
|
/* memory allocation error ? */
|
||||||
@ -389,7 +389,7 @@ ldap_set_option(
|
|||||||
} return LDAP_OPT_SUCCESS;
|
} return LDAP_OPT_SUCCESS;
|
||||||
|
|
||||||
case LDAP_OPT_HOST_NAME: {
|
case LDAP_OPT_HOST_NAME: {
|
||||||
char* host = (char *) invalue;
|
const char *host = (const char *) invalue;
|
||||||
|
|
||||||
if(lo->ldo_defhost != NULL) {
|
if(lo->ldo_defhost != NULL) {
|
||||||
LDAP_FREE(lo->ldo_defhost);
|
LDAP_FREE(lo->ldo_defhost);
|
||||||
@ -419,7 +419,7 @@ ldap_set_option(
|
|||||||
} return LDAP_OPT_SUCCESS;
|
} return LDAP_OPT_SUCCESS;
|
||||||
|
|
||||||
case LDAP_OPT_ERROR_NUMBER: {
|
case LDAP_OPT_ERROR_NUMBER: {
|
||||||
int err = * (int *) invalue;
|
int err = * (const int *) invalue;
|
||||||
|
|
||||||
if(ld == NULL) {
|
if(ld == NULL) {
|
||||||
/* need a struct ldap */
|
/* need a struct ldap */
|
||||||
@ -430,7 +430,7 @@ ldap_set_option(
|
|||||||
} return LDAP_OPT_SUCCESS;
|
} return LDAP_OPT_SUCCESS;
|
||||||
|
|
||||||
case LDAP_OPT_ERROR_STRING: {
|
case LDAP_OPT_ERROR_STRING: {
|
||||||
char* err = (char *) invalue;
|
const char *err = (const char *) invalue;
|
||||||
|
|
||||||
if(ld == NULL) {
|
if(ld == NULL) {
|
||||||
/* need a struct ldap */
|
/* need a struct ldap */
|
||||||
@ -445,7 +445,7 @@ ldap_set_option(
|
|||||||
} return LDAP_OPT_SUCCESS;
|
} return LDAP_OPT_SUCCESS;
|
||||||
|
|
||||||
case LDAP_OPT_MATCHED_DN: {
|
case LDAP_OPT_MATCHED_DN: {
|
||||||
char* err = (char *) invalue;
|
const char *err = (const char *) invalue;
|
||||||
|
|
||||||
if(ld == NULL) {
|
if(ld == NULL) {
|
||||||
/* need a struct ldap */
|
/* need a struct ldap */
|
||||||
@ -464,7 +464,7 @@ ldap_set_option(
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case LDAP_OPT_DEBUG_LEVEL:
|
case LDAP_OPT_DEBUG_LEVEL:
|
||||||
lo->ldo_debug = * (int *) invalue;
|
lo->ldo_debug = * (const int *) invalue;
|
||||||
return LDAP_OPT_SUCCESS;
|
return LDAP_OPT_SUCCESS;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
Loading…
Reference in New Issue
Block a user