xref: /illumos-gate/usr/src/cmd/ldap/common/idtest.c (revision 2a8bcb4e)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  *
35e45752aSstevel  * Portions Copyright 1998 Sun Microsystems, Inc.  All rights reserved.
45e45752aSstevel  * Use is subject to license terms.
57c478bd9Sstevel@tonic-gate  *
67c478bd9Sstevel@tonic-gate  */
7*2a8bcb4eSToomas Soome 
87c478bd9Sstevel@tonic-gate /* idtest.c - ber decoding test program using isode libraries */
97c478bd9Sstevel@tonic-gate /*
107c478bd9Sstevel@tonic-gate  * Copyright (c) 1990 Regents of the University of Michigan.
117c478bd9Sstevel@tonic-gate  * All rights reserved.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * Redistribution and use in source and binary forms are permitted
147c478bd9Sstevel@tonic-gate  * provided that this notice is preserved and that due credit is given
157c478bd9Sstevel@tonic-gate  * to the University of Michigan at Ann Arbor. The name of the University
167c478bd9Sstevel@tonic-gate  * may not be used to endorse or promote products derived from this
177c478bd9Sstevel@tonic-gate  * software without specific prior written permission. This software
187c478bd9Sstevel@tonic-gate  * is provided ``as is'' without express or implied warranty.
197c478bd9Sstevel@tonic-gate  */
207c478bd9Sstevel@tonic-gate 
217c478bd9Sstevel@tonic-gate #include <stdio.h>
227c478bd9Sstevel@tonic-gate #include <psap.h>
237c478bd9Sstevel@tonic-gate #include <quipu/attr.h>
247c478bd9Sstevel@tonic-gate 
usage(char * name)257c478bd9Sstevel@tonic-gate static usage( char *name )
267c478bd9Sstevel@tonic-gate {
277c478bd9Sstevel@tonic-gate 	fprintf( stderr, "usage: %s\n", name );
287c478bd9Sstevel@tonic-gate }
297c478bd9Sstevel@tonic-gate 
main(int argc,char ** argv)307c478bd9Sstevel@tonic-gate main( int argc, char **argv )
317c478bd9Sstevel@tonic-gate {
327c478bd9Sstevel@tonic-gate 	PE	pe;
337c478bd9Sstevel@tonic-gate 	PS	psin, psout, pserr;
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate 	/* read the pe from standard in */
367c478bd9Sstevel@tonic-gate 	if ( (psin = ps_alloc( std_open )) == NULLPS ) {
377c478bd9Sstevel@tonic-gate 		perror( "ps_alloc" );
387c478bd9Sstevel@tonic-gate 		exit( 1 );
397c478bd9Sstevel@tonic-gate 	}
407c478bd9Sstevel@tonic-gate 	if ( std_setup( psin, stdin ) == NOTOK ) {
417c478bd9Sstevel@tonic-gate 		perror( "std_setup" );
427c478bd9Sstevel@tonic-gate 		exit( 1 );
437c478bd9Sstevel@tonic-gate 	}
447c478bd9Sstevel@tonic-gate 	/* write the pe to standard out */
457c478bd9Sstevel@tonic-gate 	if ( (psout = ps_alloc( std_open )) == NULLPS ) {
467c478bd9Sstevel@tonic-gate 		perror( "ps_alloc" );
477c478bd9Sstevel@tonic-gate 		exit( 1 );
487c478bd9Sstevel@tonic-gate 	}
497c478bd9Sstevel@tonic-gate 	if ( std_setup( psout, stdout ) == NOTOK ) {
507c478bd9Sstevel@tonic-gate 		perror( "std_setup" );
517c478bd9Sstevel@tonic-gate 		exit( 1 );
527c478bd9Sstevel@tonic-gate 	}
537c478bd9Sstevel@tonic-gate 	/* pretty print it to standard error */
547c478bd9Sstevel@tonic-gate 	if ( (pserr = ps_alloc( std_open )) == NULLPS ) {
557c478bd9Sstevel@tonic-gate 		perror( "ps_alloc" );
567c478bd9Sstevel@tonic-gate 		exit( 1 );
577c478bd9Sstevel@tonic-gate 	}
587c478bd9Sstevel@tonic-gate 	if ( std_setup( pserr, stderr ) == NOTOK ) {
597c478bd9Sstevel@tonic-gate 		perror( "std_setup" );
607c478bd9Sstevel@tonic-gate 		exit( 1 );
617c478bd9Sstevel@tonic-gate 	}
627c478bd9Sstevel@tonic-gate 
637c478bd9Sstevel@tonic-gate 	while ( (pe = ps2pe( psin )) != NULLPE ) {
647c478bd9Sstevel@tonic-gate 		pe2pl( pserr, pe );
657c478bd9Sstevel@tonic-gate 		pe2ps( psout, pe );
667c478bd9Sstevel@tonic-gate 	}
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate 	exit( 0 );
697c478bd9Sstevel@tonic-gate }
70