]> git.sur5r.net Git - openldap/blob - libraries/liblber/dtest.c
04cd27d2b2b2a8796d732056baa9e60061cc5691
[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 #define DISABLE_BRIDGE
15 #include "portable.h"
16
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include <ac/string.h>
20
21 #ifdef MACOS
22 #include <console.h>
23 #else /* MACOS */
24 #include <sys/types.h>
25 #include <sys/socket.h>
26 #endif /* MACOS */
27
28 #include "lber.h"
29
30 static usage( char *name )
31 {
32         fprintf( stderr, "usage: %s fmt\n", name );
33 }
34
35 main( int argc, char **argv )
36 {
37         long            i, i2, num;
38         unsigned long   len;
39         int             tag;
40         char            *str, *s1, *s2;
41         BerElement      ber;
42         Sockbuf         sb;
43         extern char     *optarg;
44
45 #ifdef MACOS
46         ccommand( &argv );
47         cshow( stdout );
48 #endif /* MACOS */
49
50         bzero( &sb, sizeof(sb) );
51         sb.sb_sd = 0;
52         sb.sb_ber.ber_buf = NULL;
53         if ( (tag = ber_get_next( &sb, &len, &ber )) == -1 ) {
54                 perror( "ber_get_next" );
55                 exit( 1 );
56         }
57         printf( "message has tag 0x%x and length %ld\n", tag, len );
58
59         if ( ber_scanf( &ber, "i", &i ) == -1 ) {
60                 fprintf( stderr, "ber_scanf returns -1\n" );
61                 exit( 1 );
62         }
63         printf( "got int %d\n", i );
64
65         return( 0 );
66 }