Back to index

openldap  2.4.31
idtest.c
Go to the documentation of this file.
00001 /* idtest.c - ber decoding test program using isode libraries */
00002 /* $OpenLDAP$ */
00003 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
00004  *
00005  * Copyright 1998-2012 The OpenLDAP Foundation.
00006  * All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted only as authorized by the OpenLDAP
00010  * Public License.
00011  *
00012  * A copy of this license is available in the file LICENSE in the
00013  * top-level directory of the distribution or, alternatively, at
00014  * <http://www.OpenLDAP.org/license.html>.
00015  */
00016 /* Portions Copyright (c) 1990 Regents of the University of Michigan.
00017  * All rights reserved.
00018  *
00019  * Redistribution and use in source and binary forms are permitted
00020  * provided that this notice is preserved and that due credit is given
00021  * to the University of Michigan at Ann Arbor. The name of the University
00022  * may not be used to endorse or promote products derived from this
00023  * software without specific prior written permission. This software
00024  * is provided ``as is'' without express or implied warranty.
00025  */
00026 /* ACKNOWLEDGEMENTS:
00027  * This work was originally developed by the University of Michigan
00028  * (as part of U-MICH LDAP).
00029  */
00030 
00031 #include "portable.h"
00032 
00033 #include <stdio.h>
00034 
00035 #include <ac/stdlib.h>
00036 
00037 #ifdef HAVE_PSAP_H
00038 #include <psap.h>
00039 #include <quipu/attr.h>
00040 #endif
00041 
00042 int
00043 main( int argc, char **argv )
00044 {
00045 #ifdef HAVE_PSAP_H
00046        PE     pe;
00047        PS     psin, psout, pserr;
00048 
00049        /* read the pe from standard in */
00050        if ( (psin = ps_alloc( std_open )) == NULLPS ) {
00051               perror( "ps_alloc" );
00052               exit( EXIT_FAILURE );
00053        }
00054        if ( std_setup( psin, stdin ) == NOTOK ) {
00055               perror( "std_setup" );
00056               exit( EXIT_FAILURE );
00057        }
00058        /* write the pe to standard out */
00059        if ( (psout = ps_alloc( std_open )) == NULLPS ) {
00060               perror( "ps_alloc" );
00061               exit( EXIT_FAILURE );
00062        }
00063        if ( std_setup( psout, stdout ) == NOTOK ) {
00064               perror( "std_setup" );
00065               exit( EXIT_FAILURE );
00066        }
00067        /* pretty print it to standard error */
00068        if ( (pserr = ps_alloc( std_open )) == NULLPS ) {
00069               perror( "ps_alloc" );
00070               exit( EXIT_FAILURE );
00071        }
00072        if ( std_setup( pserr, stderr ) == NOTOK ) {
00073               perror( "std_setup" );
00074               exit( EXIT_FAILURE );
00075        }
00076 
00077        while ( (pe = ps2pe( psin )) != NULLPE ) {
00078               pe2pl( pserr, pe );
00079               pe2ps( psout, pe );
00080        }
00081 
00082        exit( EXIT_SUCCESS );
00083 #else
00084        fprintf(stderr, "requires ISODE X.500 distribution.\n");
00085        return( EXIT_FAILURE );
00086 #endif
00087 }