]> git.sur5r.net Git - openldap/blobdiff - libraries/liblber/dtest.c
Fix text2time to handle 4 digit years. Fix YEAR() to handle
[openldap] / libraries / liblber / dtest.c
index 04cd27d2b2b2a8796d732056baa9e60061cc5691..93b1966894b922f106eaeb0cb13c986a3ecdd1f2 100644 (file)
@@ -1,5 +1,9 @@
 /* dtest.c - lber decoding test program */
 /*
+ * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
+ * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+ */
+/* Portions
  * Copyright (c) 1990 Regents of the University of Michigan.
  * All rights reserved.
  *
  * is provided ``as is'' without express or implied warranty.
  */
 
-#define DISABLE_BRIDGE
 #include "portable.h"
 
 #include <stdio.h>
 #include <stdlib.h>
+
 #include <ac/string.h>
+#include <ac/socket.h>
+#include <ac/unistd.h>
 
-#ifdef MACOS
+#ifdef HAVE_CONSOLE_H
 #include <console.h>
-#else /* MACOS */
-#include <sys/types.h>
-#include <sys/socket.h>
 #endif /* MACOS */
 
-#include "lber.h"
+#include <lber.h>
 
-static usage( char *name )
+static void usage( char *name )
 {
        fprintf( stderr, "usage: %s fmt\n", name );
 }
 
+int
 main( int argc, char **argv )
 {
-       long            i, i2, num;
+       long            i;
        unsigned long   len;
        int             tag;
-       char            *str, *s1, *s2;
-       BerElement      ber;
-       Sockbuf         sb;
-       extern char     *optarg;
+       BerElement      *ber;
+       Sockbuf         *sb;
 
-#ifdef MACOS
+#ifdef HAVE_CONSOLE_H
        ccommand( &argv );
        cshow( stdout );
 #endif /* MACOS */
 
-       bzero( &sb, sizeof(sb) );
-       sb.sb_sd = 0;
-       sb.sb_ber.ber_buf = NULL;
-       if ( (tag = ber_get_next( &sb, &len, &ber )) == -1 ) {
+       sb = lber_sockbuf_alloc_fd( fileno(stdin) );
+
+       if( (ber = ber_alloc_t(LBER_USE_DER)) == NULL ) {
+               perror( "ber_alloc_t" );
+               exit( 1 );
+       }
+
+       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 ) {
+       if ( ber_scanf( ber, "i", &i ) == -1 ) {
                fprintf( stderr, "ber_scanf returns -1\n" );
                exit( 1 );
        }
-       printf( "got int %d\n", i );
+       printf( "got int %ld\n", i );
 
+       lber_sockbuf_free( sb );
        return( 0 );
 }