]> git.sur5r.net Git - openldap/blob - libraries/liblber/dtest.c
Update copyright of build environment, includes, and liblber/libldap.
[openldap] / libraries / liblber / dtest.c
1 /* dtest.c - lber decoding test program */
2 /*
3  * Copyright 1998-1999 The OpenLDAP Foundation, All Rights Reserved.
4  * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
5  */
6 /* Portions
7  * Copyright (c) 1990 Regents of the University of Michigan.
8  * All rights reserved.
9  *
10  * Redistribution and use in source and binary forms are permitted
11  * provided that this notice is preserved and that due credit is given
12  * to the University of Michigan at Ann Arbor. The name of the University
13  * may not be used to endorse or promote products derived from this
14  * software without specific prior written permission. This software
15  * is provided ``as is'' without express or implied warranty.
16  */
17
18 #include "portable.h"
19
20 #include <stdio.h>
21 #include <stdlib.h>
22
23 #include <ac/string.h>
24 #include <ac/socket.h>
25 #include <ac/unistd.h>
26
27 #ifdef HAVE_CONSOLE_H
28 #include <console.h>
29 #endif /* MACOS */
30
31 #include "lber.h"
32
33 static void usage( char *name )
34 {
35         fprintf( stderr, "usage: %s fmt\n", name );
36 }
37
38 int
39 main( int argc, char **argv )
40 {
41         long            i;
42         unsigned long   len;
43         int             tag;
44         BerElement      ber;
45         Sockbuf         sb;
46
47 #ifdef HAVE_CONSOLE_H
48         ccommand( &argv );
49         cshow( stdout );
50 #endif /* MACOS */
51
52         memset( &sb, 0, sizeof(sb) );
53         sb.sb_sd = 0;
54         sb.sb_ber.ber_buf = NULL;
55
56         if ( (tag = ber_get_next( &sb, &len, &ber )) == -1 ) {
57                 perror( "ber_get_next" );
58                 exit( 1 );
59         }
60         printf( "message has tag 0x%x and length %ld\n", tag, len );
61
62         if ( ber_scanf( &ber, "i", &i ) == -1 ) {
63                 fprintf( stderr, "ber_scanf returns -1\n" );
64                 exit( 1 );
65         }
66         printf( "got int %ld\n", i );
67
68         return( 0 );
69 }