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