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