xref: /titanic_52/usr/src/cmd/ldap/common/idtest.c (revision 7aec1d6e253b21f9e9b7ef68b4d81ab9859b51fe)
1 /*
2  *
3  * Portions Copyright %G% Sun Microsystems, Inc. All Rights Reserved
4  *
5  */
6 #pragma ident	"%Z%%M%	%I%	%E% SMI"
7 /* idtest.c - ber decoding test program using isode libraries */
8 /*
9  * Copyright (c) 1990 Regents of the University of Michigan.
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms are permitted
13  * provided that this notice is preserved and that due credit is given
14  * to the University of Michigan at Ann Arbor. The name of the University
15  * may not be used to endorse or promote products derived from this
16  * software without specific prior written permission. This software
17  * is provided ``as is'' without express or implied warranty.
18  */
19 
20 #include <stdio.h>
21 #include <psap.h>
22 #include <quipu/attr.h>
23 
24 static usage( char *name )
25 {
26 	fprintf( stderr, "usage: %s\n", name );
27 }
28 
29 main( int argc, char **argv )
30 {
31 	PE	pe;
32 	PS	psin, psout, pserr;
33 
34 	/* read the pe from standard in */
35 	if ( (psin = ps_alloc( std_open )) == NULLPS ) {
36 		perror( "ps_alloc" );
37 		exit( 1 );
38 	}
39 	if ( std_setup( psin, stdin ) == NOTOK ) {
40 		perror( "std_setup" );
41 		exit( 1 );
42 	}
43 	/* write the pe to standard out */
44 	if ( (psout = ps_alloc( std_open )) == NULLPS ) {
45 		perror( "ps_alloc" );
46 		exit( 1 );
47 	}
48 	if ( std_setup( psout, stdout ) == NOTOK ) {
49 		perror( "std_setup" );
50 		exit( 1 );
51 	}
52 	/* pretty print it to standard error */
53 	if ( (pserr = ps_alloc( std_open )) == NULLPS ) {
54 		perror( "ps_alloc" );
55 		exit( 1 );
56 	}
57 	if ( std_setup( pserr, stderr ) == NOTOK ) {
58 		perror( "std_setup" );
59 		exit( 1 );
60 	}
61 
62 	while ( (pe = ps2pe( psin )) != NULLPE ) {
63 		pe2pl( pserr, pe );
64 		pe2ps( psout, pe );
65 	}
66 
67 	exit( 0 );
68 }
69