2 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 struct lber_options ber_int_options = {
13 LBER_UNINITIALIZED, 0, 0 };
17 LDAP_CONST void *item,
21 LDAP_CONST BerElement *ber;
22 LDAP_CONST Sockbuf *sb;
24 ber_int_options.lbo_valid = LBER_INITIALIZED;
26 if(outvalue == NULL) {
27 /* no place to get to */
28 return LBER_OPT_ERROR;
32 if(option == LBER_OPT_BER_DEBUG) {
33 * (int *) outvalue = ber_int_debug;
34 return LBER_OPT_SUCCESS;
37 return LBER_OPT_ERROR;
44 case LBER_OPT_BER_OPTIONS:
45 assert( BER_VALID( ber ) );
46 * (int *) outvalue = ber->ber_options;
47 return LBER_OPT_SUCCESS;
49 case LBER_OPT_BER_DEBUG:
50 assert( BER_VALID( ber ) );
51 * (int *) outvalue = ber->ber_debug;
52 return LBER_OPT_SUCCESS;
59 return LBER_OPT_ERROR;
66 LDAP_CONST void *invalue)
71 if( (ber_int_options.lbo_valid == LBER_UNINITIALIZED)
72 && ( ber_int_memory_fns == NULL )
73 && ( option == LBER_OPT_MEMORY_FNS )
74 && ( invalue != NULL ))
76 BerMemoryFunctions *f = (BerMemoryFunctions *) invalue;
78 /* make sure all functions are provided */
79 if(!( f->bmf_malloc && f->bmf_calloc
80 && f->bmf_realloc && f->bmf_free ))
82 return LBER_OPT_ERROR;
85 ber_int_memory_fns = (BerMemoryFunctions *)
86 (*(f->bmf_malloc))(sizeof(BerMemoryFunctions));
88 if ( ber_int_memory_fns == NULL ) {
89 return LBER_OPT_ERROR;
92 memcpy(ber_int_memory_fns, f, sizeof(BerMemoryFunctions));
94 ber_int_options.lbo_valid = LBER_INITIALIZED;
95 return LBER_OPT_SUCCESS;
98 ber_int_options.lbo_valid = LBER_INITIALIZED;
100 if(invalue == NULL) {
101 /* no place to set from */
102 return LBER_OPT_ERROR;
106 if(option == LBER_OPT_BER_DEBUG) {
107 ber_int_debug = * (int *) invalue;
108 return LBER_OPT_SUCCESS;
110 } else if(option == LBER_OPT_LOG_PRINT_FN) {
111 ber_pvt_log_print = (BER_LOG_PRINT_FN) invalue;
112 return LBER_OPT_SUCCESS;
115 return LBER_OPT_ERROR;
122 case LBER_OPT_BER_OPTIONS:
123 assert( BER_VALID( ber ) );
124 ber->ber_options = * (int *) invalue;
125 return LBER_OPT_SUCCESS;
127 case LBER_OPT_BER_DEBUG:
128 assert( BER_VALID( ber ) );
129 ber->ber_debug = * (int *) invalue;
130 return LBER_OPT_SUCCESS;
137 return LBER_OPT_ERROR;