#include <ac/stdlib.h>
#include <ac/string.h>
-
+#include <ac/stdarg.h>
#include "lber-int.h"
-extern void * ber_pvt_err_file; /* bprint.c */
+/* bprint.c */
+typedef void (*BER_LOG_FN) LDAP_P((FILE *file, char *subsys, int level, const char *fmt, va_list vl));
+extern void * ber_pvt_err_file;
+extern BER_LOG_FN ber_int_log_proc;
struct lber_options ber_int_options = {
LBER_UNINITIALIZED, 0, 0 };
#else
return LBER_OPT_ERROR;
#endif
+ } else if(option == LBER_OPT_LOG_PRINT_FILE) {
+ *((FILE**)outvalue) = (FILE*)ber_pvt_err_file;
+ return LBER_OPT_SUCCESS;
}
ber_errno = LBER_ERROR_PARAM;
return LBER_OPT_SUCCESS;
case LBER_OPT_BER_REMAINING_BYTES:
- *((ber_len_t *) outvalue) = ber->ber_end - ber->ber_ptr;
+ assert( BER_VALID( ber ) );
+ *((ber_len_t *) outvalue) = ber_pvt_ber_remaining(ber);
return LBER_OPT_SUCCESS;
case LBER_OPT_BER_TOTAL_BYTES:
- *((ber_len_t *) outvalue) = ber->ber_end - ber->ber_buf;
+ assert( BER_VALID( ber ) );
+ *((ber_len_t *) outvalue) = ber_pvt_ber_total(ber);
return LBER_OPT_SUCCESS;
case LBER_OPT_BER_BYTES_TO_WRITE:
- *((ber_len_t *) outvalue) = ber->ber_ptr - ber->ber_buf;
+ assert( BER_VALID( ber ) );
+ *((ber_len_t *) outvalue) = ber_pvt_ber_write(ber);
return LBER_OPT_SUCCESS;
default:
#else
return LBER_OPT_ERROR;
#endif
+ } else if(option == LBER_OPT_LOG_PROC) {
+ ber_int_log_proc = (BER_LOG_FN)invalue;
}
ber_errno = LBER_ERROR_PARAM;
return LBER_OPT_SUCCESS;
case LBER_OPT_BER_REMAINING_BYTES:
+ assert( BER_VALID( ber ) );
ber->ber_end = &ber->ber_ptr[* (const ber_len_t *) invalue];
return LBER_OPT_SUCCESS;
case LBER_OPT_BER_TOTAL_BYTES:
+ assert( BER_VALID( ber ) );
ber->ber_end = &ber->ber_buf[* (const ber_len_t *) invalue];
return LBER_OPT_SUCCESS;
case LBER_OPT_BER_BYTES_TO_WRITE:
+ assert( BER_VALID( ber ) );
ber->ber_ptr = &ber->ber_buf[* (const ber_len_t *) invalue];
return LBER_OPT_SUCCESS;