xref: /netbsd-src/external/bsd/openldap/dist/libraries/liblber/idtest.c (revision 549b59ed3ccf0d36d3097190a0db27b770f3a839)
1*549b59edSchristos /*	$NetBSD: idtest.c,v 1.3 2021/08/14 16:14:55 christos Exp $	*/
24e6df137Slukem 
32de962bdSlukem /* idtest.c - ber decoding test program using isode libraries */
4d11b170bStron /* $OpenLDAP$ */
52de962bdSlukem /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
62de962bdSlukem  *
7*549b59edSchristos  * Copyright 1998-2021 The OpenLDAP Foundation.
82de962bdSlukem  * All rights reserved.
92de962bdSlukem  *
102de962bdSlukem  * Redistribution and use in source and binary forms, with or without
112de962bdSlukem  * modification, are permitted only as authorized by the OpenLDAP
122de962bdSlukem  * Public License.
132de962bdSlukem  *
142de962bdSlukem  * A copy of this license is available in the file LICENSE in the
152de962bdSlukem  * top-level directory of the distribution or, alternatively, at
162de962bdSlukem  * <http://www.OpenLDAP.org/license.html>.
172de962bdSlukem  */
182de962bdSlukem /* Portions Copyright (c) 1990 Regents of the University of Michigan.
192de962bdSlukem  * All rights reserved.
202de962bdSlukem  *
212de962bdSlukem  * Redistribution and use in source and binary forms are permitted
222de962bdSlukem  * provided that this notice is preserved and that due credit is given
232de962bdSlukem  * to the University of Michigan at Ann Arbor. The name of the University
242de962bdSlukem  * may not be used to endorse or promote products derived from this
252de962bdSlukem  * software without specific prior written permission. This software
262de962bdSlukem  * is provided ``as is'' without express or implied warranty.
272de962bdSlukem  */
282de962bdSlukem /* ACKNOWLEDGEMENTS:
292de962bdSlukem  * This work was originally developed by the University of Michigan
302de962bdSlukem  * (as part of U-MICH LDAP).
312de962bdSlukem  */
322de962bdSlukem 
33376af7d7Schristos #include <sys/cdefs.h>
34*549b59edSchristos __RCSID("$NetBSD: idtest.c,v 1.3 2021/08/14 16:14:55 christos Exp $");
35376af7d7Schristos 
362de962bdSlukem #include "portable.h"
372de962bdSlukem 
382de962bdSlukem #include <stdio.h>
392de962bdSlukem 
402de962bdSlukem #include <ac/stdlib.h>
412de962bdSlukem 
422de962bdSlukem #ifdef HAVE_PSAP_H
432de962bdSlukem #include <psap.h>
442de962bdSlukem #include <quipu/attr.h>
452de962bdSlukem #endif
462de962bdSlukem 
472de962bdSlukem int
main(int argc,char ** argv)482de962bdSlukem main( int argc, char **argv )
492de962bdSlukem {
502de962bdSlukem #ifdef HAVE_PSAP_H
512de962bdSlukem 	PE	pe;
522de962bdSlukem 	PS	psin, psout, pserr;
532de962bdSlukem 
542de962bdSlukem 	/* read the pe from standard in */
552de962bdSlukem 	if ( (psin = ps_alloc( std_open )) == NULLPS ) {
562de962bdSlukem 		perror( "ps_alloc" );
572de962bdSlukem 		exit( EXIT_FAILURE );
582de962bdSlukem 	}
592de962bdSlukem 	if ( std_setup( psin, stdin ) == NOTOK ) {
602de962bdSlukem 		perror( "std_setup" );
612de962bdSlukem 		exit( EXIT_FAILURE );
622de962bdSlukem 	}
632de962bdSlukem 	/* write the pe to standard out */
642de962bdSlukem 	if ( (psout = ps_alloc( std_open )) == NULLPS ) {
652de962bdSlukem 		perror( "ps_alloc" );
662de962bdSlukem 		exit( EXIT_FAILURE );
672de962bdSlukem 	}
682de962bdSlukem 	if ( std_setup( psout, stdout ) == NOTOK ) {
692de962bdSlukem 		perror( "std_setup" );
702de962bdSlukem 		exit( EXIT_FAILURE );
712de962bdSlukem 	}
722de962bdSlukem 	/* pretty print it to standard error */
732de962bdSlukem 	if ( (pserr = ps_alloc( std_open )) == NULLPS ) {
742de962bdSlukem 		perror( "ps_alloc" );
752de962bdSlukem 		exit( EXIT_FAILURE );
762de962bdSlukem 	}
772de962bdSlukem 	if ( std_setup( pserr, stderr ) == NOTOK ) {
782de962bdSlukem 		perror( "std_setup" );
792de962bdSlukem 		exit( EXIT_FAILURE );
802de962bdSlukem 	}
812de962bdSlukem 
822de962bdSlukem 	while ( (pe = ps2pe( psin )) != NULLPE ) {
832de962bdSlukem 		pe2pl( pserr, pe );
842de962bdSlukem 		pe2ps( psout, pe );
852de962bdSlukem 	}
862de962bdSlukem 
872de962bdSlukem 	exit( EXIT_SUCCESS );
882de962bdSlukem #else
892de962bdSlukem 	fprintf(stderr, "requires ISODE X.500 distribution.\n");
902de962bdSlukem 	return( EXIT_FAILURE );
912de962bdSlukem #endif
922de962bdSlukem }
93