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