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