]> git.sur5r.net Git - openldap/blob - libraries/liblber/idtest.c
a35e09826214a8e8c3e703ac532d3887e325400b
[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 "portable.h"
15
16 #include <stdio.h>
17
18 #ifdef HAVE_PSAP_H
19 #include <psap.h>
20 #include <quipu/attr.h>
21 #endif
22
23 static usage( char *name )
24 {
25         fprintf( stderr, "usage: %s\n", name );
26 }
27
28 main( int argc, char **argv )
29 {
30 #ifdef HAVE_PSAP_H
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 #else
69         fprintf(stderr, "requires ISODE X.500 distribution.\n");
70         exit( 1 );
71 #endif
72 }