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