openldap/libraries/liblber/dtest.c

65 lines
1.4 KiB
C
Raw Normal View History

1998-08-09 08:43:13 +08:00
/* dtest.c - lber decoding test program */
/*
* Copyright (c) 1990 Regents of the University of Michigan.
* All rights reserved.
*
* Redistribution and use in source and binary forms are permitted
* provided that this notice is preserved and that due credit is given
* to the University of Michigan at Ann Arbor. The name of the University
* may not be used to endorse or promote products derived from this
* software without specific prior written permission. This software
* is provided ``as is'' without express or implied warranty.
*/
1998-10-25 09:41:42 +08:00
#include "portable.h"
1998-08-09 08:43:13 +08:00
#include <stdio.h>
#include <stdlib.h>
1998-10-25 09:41:42 +08:00
#include <ac/string.h>
#include <ac/socket.h>
#ifdef HAVE_CONSOLE_H
1998-08-09 08:43:13 +08:00
#include <console.h>
#endif /* MACOS */
1998-10-25 09:41:42 +08:00
1998-08-09 08:43:13 +08:00
#include "lber.h"
1998-10-25 09:41:42 +08:00
static void usage( char *name )
1998-08-09 08:43:13 +08:00
{
fprintf( stderr, "usage: %s fmt\n", name );
}
main( int argc, char **argv )
{
1998-10-25 09:41:42 +08:00
long i;
1998-08-09 08:43:13 +08:00
unsigned long len;
int tag;
BerElement ber;
Sockbuf sb;
extern char *optarg;
1998-10-25 09:41:42 +08:00
#ifdef HAVE_CONSOLE_H
1998-08-09 08:43:13 +08:00
ccommand( &argv );
cshow( stdout );
#endif /* MACOS */
1998-10-25 09:41:42 +08:00
memset( &sb, 0, sizeof(sb) );
1998-08-09 08:43:13 +08:00
sb.sb_sd = 0;
sb.sb_ber.ber_buf = NULL;
1998-10-25 09:41:42 +08:00
1998-08-09 08:43:13 +08:00
if ( (tag = ber_get_next( &sb, &len, &ber )) == -1 ) {
perror( "ber_get_next" );
exit( 1 );
}
printf( "message has tag 0x%x and length %ld\n", tag, len );
if ( ber_scanf( &ber, "i", &i ) == -1 ) {
fprintf( stderr, "ber_scanf returns -1\n" );
exit( 1 );
}
printf( "got int %d\n", i );
return( 0 );
}