]> git.sur5r.net Git - openldap/blobdiff - libraries/liblber/etest.c
NT port
[openldap] / libraries / liblber / etest.c
index 71c7ee31cfd87510a8fd4de2daea613dc83dcaed..3e8ff55ced81b6f1540e07b81d9be23b86813e92 100644 (file)
@@ -1,61 +1,65 @@
 /* test.c - lber encoding 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.
  */
 
-#define DISABLE_BRIDGE
 #include "portable.h"
 
 #include <stdio.h>
+
+#include <ac/socket.h>
 #include <ac/string.h>
+#include <ac/unistd.h>
 
-#ifdef MACOS
-#include <stdlib.h>
-#include <unix.h>
-#include <fcntl.h>
+#ifdef HAVE_CONSOLE_H
 #include <console.h>
-#else /* MACOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* MACOS */
+#endif /* HAVE_CONSOLE_H */
 
-#include "lber.h"
+#include <lber.h>
 
-static usage( char *name )
+static void usage( char *name )
 {
        fprintf( stderr, "usage: %s fmtstring\n", name );
 }
 
+int
 main( int argc, char **argv )
 {
-       int             i, num, len;
-       char            *s, *p;
+#ifdef notdef
+       int             i, len;
+       char    *s, *p;
+#endif
+       int                     fd, num;
        Seqorset        *sos = NULLSEQORSET;
        BerElement      *ber;
-       Sockbuf         sb;
-       extern char     *optarg;
+       Sockbuf         *sb;
 
        if ( argc < 2 ) {
                usage( argv[0] );
                exit( 1 );
        }
 
-       bzero( &sb, sizeof(sb) );
-       sb.sb_sd = 1;
-       sb.sb_ber.ber_buf = NULL;
 
-#ifdef MACOS
+#ifdef HAVE_CONSOLE_H
        ccommand( &argv );
        cshow( stdout );
 
-       if (( sb.sb_sd = open( "lber-test", O_WRONLY|O_CREAT|O_TRUNC|O_BINARY ))
+       if (( fd = open( "lber-test", O_WRONLY|O_CREAT|O_TRUNC|O_BINARY ))
                < 0 ) {
            perror( "open" );
            exit( 1 );
        }
+#else
+       fd = fileno(stdout);
 #endif /* MACOS */
 
+       sb = lber_pvt_sb_alloc_fd( fd );
+
        if ( (ber = ber_alloc()) == NULLBER ) {
                perror( "ber_alloc" );
                exit( 1 );
@@ -67,7 +71,7 @@ main( int argc, char **argv )
                exit( 1 );
        }
 
-       if ( ber_flush( &sb, ber, 1 ) == -1 ) {
+       if ( ber_flush( sb, ber, 1 ) == -1 ) {
                perror( "ber_flush" );
                exit( 1 );
        }
@@ -156,9 +160,9 @@ main( int argc, char **argv )
                        break;
 
                default:
-#ifndef NO_USERINTERFACE
+#ifdef LDAP_LIBUI
                        fprintf( stderr, "unknown fmt %c\n", *fmt );
-#endif /* NO_USERINTERFACE */
+#endif /* LDAP_LIBUI */
                        rc = -1;
                        break;
                }
@@ -167,5 +171,6 @@ main( int argc, char **argv )
 
 #endif
 
+       lber_pvt_sb_free( sb );
        return( 0 );
 }