2 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
3 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
11 #define LDAP_F_PRE LDAP_F_EXPORT
15 struct lber_options ber_int_options = {
16 LBER_UNINITIALIZED, 0, 0 };
20 LDAP_CONST void *item,
24 LDAP_CONST BerElement *ber;
25 LDAP_CONST Sockbuf *sb;
27 ber_int_options.lbo_valid = LBER_INITIALIZED;
29 if(outvalue == NULL) {
30 /* no place to get to */
31 return LBER_OPT_ERROR;
35 if(option == LBER_OPT_BER_DEBUG) {
36 * (int *) outvalue = ber_int_debug;
37 return LBER_OPT_SUCCESS;
40 return LBER_OPT_ERROR;
47 case LBER_OPT_BER_OPTIONS:
48 assert( BER_VALID( ber ) );
49 * (int *) outvalue = ber->ber_options;
50 return LBER_OPT_SUCCESS;
52 case LBER_OPT_BER_DEBUG:
53 assert( BER_VALID( ber ) );
54 * (int *) outvalue = ber->ber_debug;
55 return LBER_OPT_SUCCESS;
62 return LBER_OPT_ERROR;
69 LDAP_CONST void *invalue)
74 if( (ber_int_options.lbo_valid == LBER_UNINITIALIZED)
75 && ( ber_int_memory_fns == NULL )
76 && ( option == LBER_OPT_MEMORY_FNS )
77 && ( invalue != NULL ))
79 const BerMemoryFunctions *f =
80 (const BerMemoryFunctions *) invalue;
82 /* make sure all functions are provided */
83 if(!( f->bmf_malloc && f->bmf_calloc
84 && f->bmf_realloc && f->bmf_free ))
86 return LBER_OPT_ERROR;
89 ber_int_memory_fns = (BerMemoryFunctions *)
90 (*(f->bmf_malloc))(sizeof(BerMemoryFunctions));
92 if ( ber_int_memory_fns == NULL ) {
93 return LBER_OPT_ERROR;
96 memcpy(ber_int_memory_fns, f, sizeof(BerMemoryFunctions));
98 ber_int_options.lbo_valid = LBER_INITIALIZED;
99 return LBER_OPT_SUCCESS;
102 ber_int_options.lbo_valid = LBER_INITIALIZED;
104 if(invalue == NULL) {
105 /* no place to set from */
106 return LBER_OPT_ERROR;
110 if(option == LBER_OPT_BER_DEBUG) {
111 ber_int_debug = * (const int *) invalue;
112 return LBER_OPT_SUCCESS;
114 } else if(option == LBER_OPT_LOG_PRINT_FN) {
115 ber_pvt_log_print = (BER_LOG_PRINT_FN) invalue;
116 return LBER_OPT_SUCCESS;
119 return LBER_OPT_ERROR;
126 case LBER_OPT_BER_OPTIONS:
127 assert( BER_VALID( ber ) );
128 ber->ber_options = * (const int *) invalue;
129 return LBER_OPT_SUCCESS;
131 case LBER_OPT_BER_DEBUG:
132 assert( BER_VALID( ber ) );
133 ber->ber_debug = * (const int *) invalue;
134 return LBER_OPT_SUCCESS;
141 return LBER_OPT_ERROR;