]> git.sur5r.net Git - openldap/blob - libraries/liblber/idtest.c
cc747152c3376878f2b9d69757c1401506e0bed6
[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 #include <stdlib.h>
22
23 #ifdef HAVE_PSAP_H
24 #include <psap.h>
25 #include <quipu/attr.h>
26 #endif
27
28 int
29 main( int argc, char **argv )
30 {
31 #ifdef HAVE_PSAP_H
32         PE      pe;
33         PS      psin, psout, pserr;
34
35         /* read the pe from standard in */
36         if ( (psin = ps_alloc( std_open )) == NULLPS ) {
37                 perror( "ps_alloc" );
38                 exit( 1 );
39         }
40         if ( std_setup( psin, stdin ) == NOTOK ) {
41                 perror( "std_setup" );
42                 exit( 1 );
43         }
44         /* write the pe to standard out */
45         if ( (psout = ps_alloc( std_open )) == NULLPS ) {
46                 perror( "ps_alloc" );
47                 exit( 1 );
48         }
49         if ( std_setup( psout, stdout ) == NOTOK ) {
50                 perror( "std_setup" );
51                 exit( 1 );
52         }
53         /* pretty print it to standard error */
54         if ( (pserr = ps_alloc( std_open )) == NULLPS ) {
55                 perror( "ps_alloc" );
56                 exit( 1 );
57         }
58         if ( std_setup( pserr, stderr ) == NOTOK ) {
59                 perror( "std_setup" );
60                 exit( 1 );
61         }
62
63         while ( (pe = ps2pe( psin )) != NULLPE ) {
64                 pe2pl( pserr, pe );
65                 pe2ps( psout, pe );
66         }
67
68         exit( 0 );
69 #else
70         fprintf(stderr, "requires ISODE X.500 distribution.\n");
71         return( EXIT_FAILURE );
72 #endif
73 }