]> git.sur5r.net Git - openldap/blob - libraries/liblber/dtest.c
5b60292ceeaedd559f7b06d36811fc9a2fa8a988
[openldap] / libraries / liblber / dtest.c
1 /* dtest.c - lber decoding test program */
2 /*
3  * Copyright (c) 1990 Regents of the University of Michigan.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms are permitted
7  * provided that this notice is preserved and that due credit is given
8  * to the University of Michigan at Ann Arbor. The name of the University
9  * may not be used to endorse or promote products derived from this
10  * software without specific prior written permission. This software
11  * is provided ``as is'' without express or implied warranty.
12  */
13
14 #include "portable.h"
15
16 #include <stdio.h>
17 #include <stdlib.h>
18
19 #include <ac/string.h>
20 #include <ac/socket.h>
21
22 #ifdef MACOS
23 #include <console.h>
24 #endif /* MACOS */
25
26 #include "lber.h"
27
28 static void usage( char *name )
29 {
30         fprintf( stderr, "usage: %s fmt\n", name );
31 }
32
33 main( int argc, char **argv )
34 {
35         long            i;
36         unsigned long   len;
37         int             tag;
38         BerElement      ber;
39         Sockbuf         sb;
40         extern char     *optarg;
41
42 #ifdef MACOS
43         ccommand( &argv );
44         cshow( stdout );
45 #endif /* MACOS */
46
47         memset( &sb, 0, sizeof(sb) );
48         sb.sb_sd = 0;
49         sb.sb_ber.ber_buf = NULL;
50
51         if ( (tag = ber_get_next( &sb, &len, &ber )) == -1 ) {
52                 perror( "ber_get_next" );
53                 exit( 1 );
54         }
55         printf( "message has tag 0x%x and length %ld\n", tag, len );
56
57         if ( ber_scanf( &ber, "i", &i ) == -1 ) {
58                 fprintf( stderr, "ber_scanf returns -1\n" );
59                 exit( 1 );
60         }
61         printf( "got int %d\n", i );
62
63         return( 0 );
64 }