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