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 BerMemoryFunctions *f = (BerMemoryFunctions *) invalue;
81 /* make sure all functions are provided */
82 if(!( f->bmf_malloc && f->bmf_calloc
83 && f->bmf_realloc && f->bmf_free ))
85 return LBER_OPT_ERROR;
88 ber_int_memory_fns = (BerMemoryFunctions *)
89 (*(f->bmf_malloc))(sizeof(BerMemoryFunctions));
91 if ( ber_int_memory_fns == NULL ) {
92 return LBER_OPT_ERROR;
95 memcpy(ber_int_memory_fns, f, sizeof(BerMemoryFunctions));
97 ber_int_options.lbo_valid = LBER_INITIALIZED;
98 return LBER_OPT_SUCCESS;
101 ber_int_options.lbo_valid = LBER_INITIALIZED;
103 if(invalue == NULL) {
104 /* no place to set from */
105 return LBER_OPT_ERROR;
109 if(option == LBER_OPT_BER_DEBUG) {
110 ber_int_debug = * (int *) invalue;
111 return LBER_OPT_SUCCESS;
113 } else if(option == LBER_OPT_LOG_PRINT_FN) {
114 ber_pvt_log_print = (BER_LOG_PRINT_FN) invalue;
115 return LBER_OPT_SUCCESS;
118 return LBER_OPT_ERROR;
125 case LBER_OPT_BER_OPTIONS:
126 assert( BER_VALID( ber ) );
127 ber->ber_options = * (int *) invalue;
128 return LBER_OPT_SUCCESS;
130 case LBER_OPT_BER_DEBUG:
131 assert( BER_VALID( ber ) );
132 ber->ber_debug = * (int *) invalue;
133 return LBER_OPT_SUCCESS;
140 return LBER_OPT_ERROR;