]> git.sur5r.net Git - openldap/blob - libraries/liblber/dtest.c
Update for Alpha3 from -devel as of OPENLDAP_DEVEL_981116.
[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 #include <ac/unistd.h>
22
23 #ifdef HAVE_CONSOLE_H
24 #include <console.h>
25 #endif /* MACOS */
26
27 #include "lber-int.h"
28
29 static void usage( char *name )
30 {
31         fprintf( stderr, "usage: %s fmt\n", name );
32 }
33
34 int
35 main( int argc, char **argv )
36 {
37         long            i;
38         unsigned long   len;
39         int             tag;
40         BerElement      ber;
41         Sockbuf         sb;
42
43 #ifdef HAVE_CONSOLE_H
44         ccommand( &argv );
45         cshow( stdout );
46 #endif /* MACOS */
47
48         memset( &sb, 0, sizeof(sb) );
49         sb.sb_sd = 0;
50         sb.sb_ber.ber_buf = NULL;
51
52         if ( (tag = ber_get_next( &sb, &len, &ber )) == -1 ) {
53                 perror( "ber_get_next" );
54                 exit( 1 );
55         }
56         printf( "message has tag 0x%x and length %ld\n", tag, len );
57
58         if ( ber_scanf( &ber, "i", &i ) == -1 ) {
59                 fprintf( stderr, "ber_scanf returns -1\n" );
60                 exit( 1 );
61         }
62         printf( "got int %d\n", i );
63
64         return( 0 );
65 }