1998-12-29 04:38:04 +08:00
|
|
|
/*
|
|
|
|
* Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
|
|
|
|
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
|
|
|
|
*/
|
1998-12-22 09:34:01 +08:00
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "lber-int.h"
|
|
|
|
|
1999-05-29 03:33:05 +08:00
|
|
|
struct lber_options ber_int_options = {
|
|
|
|
LBER_UNINITIALIZED, 0, 0 };
|
1998-12-22 09:34:01 +08:00
|
|
|
|
|
|
|
int
|
1999-05-19 09:12:33 +08:00
|
|
|
ber_get_option(
|
1998-12-22 09:34:01 +08:00
|
|
|
void *item,
|
|
|
|
int option,
|
|
|
|
void *outvalue)
|
|
|
|
{
|
|
|
|
BerElement *ber;
|
|
|
|
Sockbuf *sb;
|
|
|
|
|
|
|
|
if(outvalue == NULL) {
|
|
|
|
/* no place to get to */
|
|
|
|
return LBER_OPT_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(item == NULL) {
|
|
|
|
if(option == LBER_OPT_BER_DEBUG) {
|
1999-05-19 09:12:33 +08:00
|
|
|
* (int *) outvalue = ber_int_debug;
|
1998-12-22 09:34:01 +08:00
|
|
|
return LBER_OPT_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
return LBER_OPT_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
ber = (BerElement *) item;
|
|
|
|
sb = (Sockbuf *) item;
|
|
|
|
|
|
|
|
switch(option) {
|
|
|
|
case LBER_OPT_BER_OPTIONS:
|
1999-05-29 03:33:05 +08:00
|
|
|
assert( BER_VALID( ber ) );
|
1998-12-22 09:34:01 +08:00
|
|
|
* (int *) outvalue = ber->ber_options;
|
|
|
|
return LBER_OPT_SUCCESS;
|
|
|
|
|
|
|
|
case LBER_OPT_BER_DEBUG:
|
1999-05-29 03:33:05 +08:00
|
|
|
assert( BER_VALID( ber ) );
|
1998-12-22 09:34:01 +08:00
|
|
|
* (int *) outvalue = ber->ber_debug;
|
|
|
|
return LBER_OPT_SUCCESS;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* bad param */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return LBER_OPT_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
1999-05-19 09:12:33 +08:00
|
|
|
ber_set_option(
|
1998-12-22 09:34:01 +08:00
|
|
|
void *item,
|
|
|
|
int option,
|
1999-05-19 09:42:29 +08:00
|
|
|
LDAP_CONST void *invalue)
|
1998-12-22 09:34:01 +08:00
|
|
|
{
|
|
|
|
BerElement *ber;
|
|
|
|
Sockbuf *sb;
|
|
|
|
|
|
|
|
if(invalue == NULL) {
|
|
|
|
/* no place to set from */
|
|
|
|
return LBER_OPT_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(item == NULL) {
|
|
|
|
if(option == LBER_OPT_BER_DEBUG) {
|
1999-05-19 09:12:33 +08:00
|
|
|
ber_int_debug = * (int *) invalue;
|
1998-12-22 09:34:01 +08:00
|
|
|
return LBER_OPT_SUCCESS;
|
1999-01-26 06:55:00 +08:00
|
|
|
|
|
|
|
} else if(option == LBER_OPT_LOG_PRINT_FN) {
|
1999-05-19 09:12:33 +08:00
|
|
|
ber_pvt_log_print = (BER_LOG_PRINT_FN) invalue;
|
1999-01-26 06:55:00 +08:00
|
|
|
return LBER_OPT_SUCCESS;
|
1998-12-22 09:34:01 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
return LBER_OPT_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
ber = (BerElement *) item;
|
|
|
|
sb = (Sockbuf *) item;
|
|
|
|
|
|
|
|
switch(option) {
|
|
|
|
case LBER_OPT_BER_OPTIONS:
|
1999-05-29 03:33:05 +08:00
|
|
|
assert( BER_VALID( ber ) );
|
1998-12-22 09:34:01 +08:00
|
|
|
ber->ber_options = * (int *) invalue;
|
|
|
|
return LBER_OPT_SUCCESS;
|
|
|
|
|
|
|
|
case LBER_OPT_BER_DEBUG:
|
1999-05-29 03:33:05 +08:00
|
|
|
assert( BER_VALID( ber ) );
|
1998-12-22 09:34:01 +08:00
|
|
|
ber->ber_debug = * (int *) invalue;
|
|
|
|
return LBER_OPT_SUCCESS;
|
|
|
|
|
|
|
|
default:
|
|
|
|
/* bad param */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return LBER_OPT_ERROR;
|
|
|
|
}
|