openldap/libraries/liblber/dtest.c
Kurt Zeilenga b5494457d8 Remove extern declarations of library functions from source.c.
This could cause problems on odd systems.  The generic
  headers should be extended as needed to include necessary
  system headers or, if necessary, make explicit declarations.
Extended ac/string.h header to look for string.h/strings.h if
  STDC_HEADERS is not defined.  Also provide basic declarations for
  str*() functions.  This could cause problems on odd systems.
Extended ac/unistd.h header to define basic declaration for misc
  functions that might be missing from headers.   This includes
  externs for getenv(), getopt(), mktemp(), tempname().
Protect fax500.h from multiple inclusion.  Moved includes of
  system/generic headers back to source files.
Made mail500 helper functions static.
Fixed includes of ctype.h, signal.h, etc. to use generics.
lutil/tempname.c: was including stdlib.h twice, one should stdio.h.
Wrapped <sys/resource.h> with HAVE_SYS_RESOURCE_H.
lber/io.c/ber_get_next(): Changed noctets back to signed.
  Used with BerRead which expects signed int as second arg and
  returns signed int.
1998-11-16 05:07:27 +00:00

66 lines
1.4 KiB
C

/* 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.
*/
#include "portable.h"
#include <stdio.h>
#include <stdlib.h>
#include <ac/string.h>
#include <ac/socket.h>
#include <ac/unistd.h>
#ifdef HAVE_CONSOLE_H
#include <console.h>
#endif /* MACOS */
#include "lber-int.h"
static void usage( char *name )
{
fprintf( stderr, "usage: %s fmt\n", name );
}
int
main( int argc, char **argv )
{
long i;
unsigned long len;
int tag;
BerElement ber;
Sockbuf sb;
#ifdef HAVE_CONSOLE_H
ccommand( &argv );
cshow( stdout );
#endif /* MACOS */
memset( &sb, 0, sizeof(sb) );
sb.sb_sd = 0;
sb.sb_ber.ber_buf = NULL;
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 );
}