/* dtest.c - lber decoding test program */
+/* $OpenLDAP$ */
/*
* Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
* COPYING RESTRICTIONS APPLY, see COPYRIGHT file
#include "portable.h"
#include <stdio.h>
-#include <stdlib.h>
+#include <ac/stdlib.h>
#include <ac/string.h>
#include <ac/socket.h>
#include <ac/unistd.h>
#ifdef HAVE_CONSOLE_H
#include <console.h>
-#endif /* MACOS */
+#endif
-#include "lber-int.h"
+#include <lber.h>
static void usage( char *name )
{
char *s;
int rc;
- unsigned long tag, len;
+ ber_tag_t tag;
+ ber_len_t len;
BerElement *ber;
Sockbuf *sb;
/* enable debugging */
- ber_int_debug = -1;
+ int ival = -1;
+ ber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &ival );
if ( argc < 2 ) {
usage( argv[0] );
#ifdef HAVE_CONSOLE_H
ccommand( &argv );
cshow( stdout );
-#endif /* MACOS */
+#endif
sb = ber_sockbuf_alloc_fd( fileno(stdin) );
}
printf("decode: message tag 0x%lx and length %ld\n",
- tag, len );
+ (unsigned long) tag, (long) len );
for( s = argv[1]; *s; s++ ) {
char buf[128];
fmt[1] = '\0';
printf("decode: format %s\n", fmt );
+ len = sizeof(buf);
rc = ber_scanf( ber, fmt, &buf[0], &len );
if( rc == LBER_ERROR ) {
}
}
- if(( tag = ber_get_next( sb, &len, ber) ) == LBER_ERROR ) {
- perror( "ber_get_next" );
- return( EXIT_FAILURE );
- }
-
- printf("decode: message tag 0x%lx and length %ld\n",
- tag, len );
-
ber_sockbuf_free( sb );
return( EXIT_SUCCESS );
}