1 /* dtest.c - lber decoding test program */
3 * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
4 * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
7 * Copyright (c) 1990 Regents of the University of Michigan.
10 * Redistribution and use in source and binary forms are permitted
11 * provided that this notice is preserved and that due credit is given
12 * to the University of Michigan at Ann Arbor. The name of the University
13 * may not be used to endorse or promote products derived from this
14 * software without specific prior written permission. This software
15 * is provided ``as is'' without express or implied warranty.
22 #include <ac/stdlib.h>
23 #include <ac/string.h>
24 #include <ac/socket.h>
25 #include <ac/unistd.h>
33 static void usage( char *name )
35 fprintf( stderr, "usage: %s fmt\n", name );
39 main( int argc, char **argv )
44 unsigned long tag, len;
49 /* enable debugging */
51 ber_set_option( NULL, LBER_OPT_DEBUG_LEVEL, &ival );
55 return( EXIT_FAILURE );
63 sb = ber_sockbuf_alloc_fd( fileno(stdin) );
65 if( (ber = ber_alloc_t(LBER_USE_DER)) == NULL ) {
66 perror( "ber_alloc_t" );
67 return( EXIT_FAILURE );
70 if(( tag = ber_get_next( sb, &len, ber) ) == LBER_ERROR ) {
71 perror( "ber_get_next" );
72 return( EXIT_FAILURE );
75 printf("decode: message tag 0x%lx and length %ld\n",
78 for( s = argv[1]; *s; s++ ) {
84 printf("decode: format %s\n", fmt );
86 rc = ber_scanf( ber, fmt, &buf[0], &len );
88 if( rc == LBER_ERROR ) {
89 perror( "ber_scanf" );
90 return( EXIT_FAILURE );
94 ber_sockbuf_free( sb );
95 return( EXIT_SUCCESS );