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