3 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
12 #define LDAP_F_PRE LDAP_F_EXPORT
16 struct lber_options ber_int_options = {
17 LBER_UNINITIALIZED, 0, 0 };
21 LDAP_CONST void *item,
25 LDAP_CONST BerElement *ber;
26 LDAP_CONST Sockbuf *sb;
28 ber_int_options.lbo_valid = LBER_INITIALIZED;
30 if(outvalue == NULL) {
31 /* no place to get to */
32 return LBER_OPT_ERROR;
36 if(option == LBER_OPT_BER_DEBUG) {
37 * (int *) outvalue = ber_int_debug;
38 return LBER_OPT_SUCCESS;
41 return LBER_OPT_ERROR;
48 case LBER_OPT_BER_OPTIONS:
49 assert( BER_VALID( ber ) );
50 * (int *) outvalue = ber->ber_options;
51 return LBER_OPT_SUCCESS;
53 case LBER_OPT_BER_DEBUG:
54 assert( BER_VALID( ber ) );
55 * (int *) outvalue = ber->ber_debug;
56 return LBER_OPT_SUCCESS;
63 return LBER_OPT_ERROR;
70 LDAP_CONST void *invalue)
75 if( (ber_int_options.lbo_valid == LBER_UNINITIALIZED)
76 && ( ber_int_memory_fns == NULL )
77 && ( option == LBER_OPT_MEMORY_FNS )
78 && ( invalue != NULL ))
80 const BerMemoryFunctions *f =
81 (const BerMemoryFunctions *) invalue;
83 /* make sure all functions are provided */
84 if(!( f->bmf_malloc && f->bmf_calloc
85 && f->bmf_realloc && f->bmf_free ))
87 return LBER_OPT_ERROR;
90 ber_int_memory_fns = (BerMemoryFunctions *)
91 (*(f->bmf_malloc))(sizeof(BerMemoryFunctions));
93 if ( ber_int_memory_fns == NULL ) {
94 return LBER_OPT_ERROR;
97 memcpy(ber_int_memory_fns, f, sizeof(BerMemoryFunctions));
99 ber_int_options.lbo_valid = LBER_INITIALIZED;
100 return LBER_OPT_SUCCESS;
103 ber_int_options.lbo_valid = LBER_INITIALIZED;
105 if(invalue == NULL) {
106 /* no place to set from */
107 return LBER_OPT_ERROR;
111 if(option == LBER_OPT_BER_DEBUG) {
112 ber_int_debug = * (const int *) invalue;
113 return LBER_OPT_SUCCESS;
115 } else if(option == LBER_OPT_LOG_PRINT_FN) {
116 ber_pvt_log_print = (BER_LOG_PRINT_FN) invalue;
117 return LBER_OPT_SUCCESS;
120 return LBER_OPT_ERROR;
127 case LBER_OPT_BER_OPTIONS:
128 assert( BER_VALID( ber ) );
129 ber->ber_options = * (const int *) invalue;
130 return LBER_OPT_SUCCESS;
132 case LBER_OPT_BER_DEBUG:
133 assert( BER_VALID( ber ) );
134 ber->ber_debug = * (const int *) invalue;
135 return LBER_OPT_SUCCESS;
142 return LBER_OPT_ERROR;