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