xref: /onnv-gate/usr/src/cmd/ldap/common/dtest.c (revision 3857:21b9b714e4ab)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  *
3*3857Sstevel  * Portions Copyright 1998 Sun Microsystems, Inc.  All rights reserved.
4*3857Sstevel  * Use is subject to license terms.
50Sstevel@tonic-gate  *
60Sstevel@tonic-gate  */
70Sstevel@tonic-gate 
80Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
90Sstevel@tonic-gate /* dtest.c - lber decoding test program */
100Sstevel@tonic-gate /*
110Sstevel@tonic-gate  * Copyright (c) 1990 Regents of the University of Michigan.
120Sstevel@tonic-gate  * All rights reserved.
130Sstevel@tonic-gate  *
140Sstevel@tonic-gate  * Redistribution and use in source and binary forms are permitted
150Sstevel@tonic-gate  * provided that this notice is preserved and that due credit is given
160Sstevel@tonic-gate  * to the University of Michigan at Ann Arbor. The name of the University
170Sstevel@tonic-gate  * may not be used to endorse or promote products derived from this
180Sstevel@tonic-gate  * software without specific prior written permission. This software
190Sstevel@tonic-gate  * is provided ``as is'' without express or implied warranty.
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate 
220Sstevel@tonic-gate #include <stdio.h>
230Sstevel@tonic-gate #include <string.h>
240Sstevel@tonic-gate #ifdef MACOS
250Sstevel@tonic-gate #include <stdlib.h>
260Sstevel@tonic-gate #include <console.h>
270Sstevel@tonic-gate #else /* MACOS */
280Sstevel@tonic-gate #include <sys/types.h>
290Sstevel@tonic-gate #include <sys/socket.h>
300Sstevel@tonic-gate #endif /* MACOS */
310Sstevel@tonic-gate #include "lber.h"
320Sstevel@tonic-gate 
usage(char * name)330Sstevel@tonic-gate static usage( char *name )
340Sstevel@tonic-gate {
350Sstevel@tonic-gate 	fprintf( stderr, "usage: %s fmt\n", name );
360Sstevel@tonic-gate }
370Sstevel@tonic-gate 
main(int argc,char ** argv)380Sstevel@tonic-gate main( int argc, char **argv )
390Sstevel@tonic-gate {
400Sstevel@tonic-gate 	long		i, i2, num;
410Sstevel@tonic-gate 	unsigned long	len;
420Sstevel@tonic-gate 	int		tag;
430Sstevel@tonic-gate 	char		*str, *s1, *s2;
440Sstevel@tonic-gate 	BerElement	ber;
450Sstevel@tonic-gate 	Sockbuf		sb;
460Sstevel@tonic-gate 	extern char	*optarg;
470Sstevel@tonic-gate 
480Sstevel@tonic-gate #ifdef MACOS
490Sstevel@tonic-gate 	ccommand( &argv );
500Sstevel@tonic-gate 	cshow( stdout );
510Sstevel@tonic-gate #endif /* MACOS */
520Sstevel@tonic-gate 
530Sstevel@tonic-gate 	bzero( &sb, sizeof(sb) );
540Sstevel@tonic-gate 	sb.sb_sd = 0;
550Sstevel@tonic-gate 	sb.sb_ber.ber_buf = NULL;
560Sstevel@tonic-gate 	if ( (tag = ber_get_next( &sb, &len, &ber )) == -1 ) {
570Sstevel@tonic-gate 		perror( "ber_get_next" );
580Sstevel@tonic-gate 		exit( 1 );
590Sstevel@tonic-gate 	}
600Sstevel@tonic-gate 	printf( "message has tag 0x%x and length %ld\n", tag, len );
610Sstevel@tonic-gate 
620Sstevel@tonic-gate 	if ( ber_scanf( &ber, "i", &i ) == -1 ) {
630Sstevel@tonic-gate 		fprintf( stderr, "ber_scanf returns -1\n" );
640Sstevel@tonic-gate 		exit( 1 );
650Sstevel@tonic-gate 	}
660Sstevel@tonic-gate 	printf( "got int %d\n", i );
670Sstevel@tonic-gate 
680Sstevel@tonic-gate 	return( 0 );
690Sstevel@tonic-gate }
70