xref: /titanic_51/usr/src/cmd/ldap/common/dtest.c (revision 5e45752a44935a6b2445ae1c763867d868fa3fbb)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  *
3*5e45752aSstevel  * Portions Copyright 1998 Sun Microsystems, Inc.  All rights reserved.
4*5e45752aSstevel  * Use is subject to license terms.
57c478bd9Sstevel@tonic-gate  *
67c478bd9Sstevel@tonic-gate  */
77c478bd9Sstevel@tonic-gate 
87c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
97c478bd9Sstevel@tonic-gate /* dtest.c - lber decoding test program */
107c478bd9Sstevel@tonic-gate /*
117c478bd9Sstevel@tonic-gate  * Copyright (c) 1990 Regents of the University of Michigan.
127c478bd9Sstevel@tonic-gate  * All rights reserved.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * Redistribution and use in source and binary forms are permitted
157c478bd9Sstevel@tonic-gate  * provided that this notice is preserved and that due credit is given
167c478bd9Sstevel@tonic-gate  * to the University of Michigan at Ann Arbor. The name of the University
177c478bd9Sstevel@tonic-gate  * may not be used to endorse or promote products derived from this
187c478bd9Sstevel@tonic-gate  * software without specific prior written permission. This software
197c478bd9Sstevel@tonic-gate  * is provided ``as is'' without express or implied warranty.
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate 
227c478bd9Sstevel@tonic-gate #include <stdio.h>
237c478bd9Sstevel@tonic-gate #include <string.h>
247c478bd9Sstevel@tonic-gate #ifdef MACOS
257c478bd9Sstevel@tonic-gate #include <stdlib.h>
267c478bd9Sstevel@tonic-gate #include <console.h>
277c478bd9Sstevel@tonic-gate #else /* MACOS */
287c478bd9Sstevel@tonic-gate #include <sys/types.h>
297c478bd9Sstevel@tonic-gate #include <sys/socket.h>
307c478bd9Sstevel@tonic-gate #endif /* MACOS */
317c478bd9Sstevel@tonic-gate #include "lber.h"
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate static usage( char *name )
347c478bd9Sstevel@tonic-gate {
357c478bd9Sstevel@tonic-gate 	fprintf( stderr, "usage: %s fmt\n", name );
367c478bd9Sstevel@tonic-gate }
377c478bd9Sstevel@tonic-gate 
387c478bd9Sstevel@tonic-gate main( int argc, char **argv )
397c478bd9Sstevel@tonic-gate {
407c478bd9Sstevel@tonic-gate 	long		i, i2, num;
417c478bd9Sstevel@tonic-gate 	unsigned long	len;
427c478bd9Sstevel@tonic-gate 	int		tag;
437c478bd9Sstevel@tonic-gate 	char		*str, *s1, *s2;
447c478bd9Sstevel@tonic-gate 	BerElement	ber;
457c478bd9Sstevel@tonic-gate 	Sockbuf		sb;
467c478bd9Sstevel@tonic-gate 	extern char	*optarg;
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate #ifdef MACOS
497c478bd9Sstevel@tonic-gate 	ccommand( &argv );
507c478bd9Sstevel@tonic-gate 	cshow( stdout );
517c478bd9Sstevel@tonic-gate #endif /* MACOS */
527c478bd9Sstevel@tonic-gate 
537c478bd9Sstevel@tonic-gate 	bzero( &sb, sizeof(sb) );
547c478bd9Sstevel@tonic-gate 	sb.sb_sd = 0;
557c478bd9Sstevel@tonic-gate 	sb.sb_ber.ber_buf = NULL;
567c478bd9Sstevel@tonic-gate 	if ( (tag = ber_get_next( &sb, &len, &ber )) == -1 ) {
577c478bd9Sstevel@tonic-gate 		perror( "ber_get_next" );
587c478bd9Sstevel@tonic-gate 		exit( 1 );
597c478bd9Sstevel@tonic-gate 	}
607c478bd9Sstevel@tonic-gate 	printf( "message has tag 0x%x and length %ld\n", tag, len );
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate 	if ( ber_scanf( &ber, "i", &i ) == -1 ) {
637c478bd9Sstevel@tonic-gate 		fprintf( stderr, "ber_scanf returns -1\n" );
647c478bd9Sstevel@tonic-gate 		exit( 1 );
657c478bd9Sstevel@tonic-gate 	}
667c478bd9Sstevel@tonic-gate 	printf( "got int %d\n", i );
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate 	return( 0 );
697c478bd9Sstevel@tonic-gate }
70