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