1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * 3*7c478bd9Sstevel@tonic-gate * Portions Copyright %G% Sun Microsystems, Inc. All Rights Reserved 4*7c478bd9Sstevel@tonic-gate * 5*7c478bd9Sstevel@tonic-gate */ 6*7c478bd9Sstevel@tonic-gate 7*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 8*7c478bd9Sstevel@tonic-gate /* dtest.c - lber decoding test program */ 9*7c478bd9Sstevel@tonic-gate /* 10*7c478bd9Sstevel@tonic-gate * Copyright (c) 1990 Regents of the University of Michigan. 11*7c478bd9Sstevel@tonic-gate * All rights reserved. 12*7c478bd9Sstevel@tonic-gate * 13*7c478bd9Sstevel@tonic-gate * Redistribution and use in source and binary forms are permitted 14*7c478bd9Sstevel@tonic-gate * provided that this notice is preserved and that due credit is given 15*7c478bd9Sstevel@tonic-gate * to the University of Michigan at Ann Arbor. The name of the University 16*7c478bd9Sstevel@tonic-gate * may not be used to endorse or promote products derived from this 17*7c478bd9Sstevel@tonic-gate * software without specific prior written permission. This software 18*7c478bd9Sstevel@tonic-gate * is provided ``as is'' without express or implied warranty. 19*7c478bd9Sstevel@tonic-gate */ 20*7c478bd9Sstevel@tonic-gate 21*7c478bd9Sstevel@tonic-gate #include <stdio.h> 22*7c478bd9Sstevel@tonic-gate #include <string.h> 23*7c478bd9Sstevel@tonic-gate #ifdef MACOS 24*7c478bd9Sstevel@tonic-gate #include <stdlib.h> 25*7c478bd9Sstevel@tonic-gate #include <console.h> 26*7c478bd9Sstevel@tonic-gate #else /* MACOS */ 27*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 28*7c478bd9Sstevel@tonic-gate #include <sys/socket.h> 29*7c478bd9Sstevel@tonic-gate #endif /* MACOS */ 30*7c478bd9Sstevel@tonic-gate #include "lber.h" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate static usage( char *name ) 33*7c478bd9Sstevel@tonic-gate { 34*7c478bd9Sstevel@tonic-gate fprintf( stderr, "usage: %s fmt\n", name ); 35*7c478bd9Sstevel@tonic-gate } 36*7c478bd9Sstevel@tonic-gate 37*7c478bd9Sstevel@tonic-gate main( int argc, char **argv ) 38*7c478bd9Sstevel@tonic-gate { 39*7c478bd9Sstevel@tonic-gate long i, i2, num; 40*7c478bd9Sstevel@tonic-gate unsigned long len; 41*7c478bd9Sstevel@tonic-gate int tag; 42*7c478bd9Sstevel@tonic-gate char *str, *s1, *s2; 43*7c478bd9Sstevel@tonic-gate BerElement ber; 44*7c478bd9Sstevel@tonic-gate Sockbuf sb; 45*7c478bd9Sstevel@tonic-gate extern char *optarg; 46*7c478bd9Sstevel@tonic-gate 47*7c478bd9Sstevel@tonic-gate #ifdef MACOS 48*7c478bd9Sstevel@tonic-gate ccommand( &argv ); 49*7c478bd9Sstevel@tonic-gate cshow( stdout ); 50*7c478bd9Sstevel@tonic-gate #endif /* MACOS */ 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gate bzero( &sb, sizeof(sb) ); 53*7c478bd9Sstevel@tonic-gate sb.sb_sd = 0; 54*7c478bd9Sstevel@tonic-gate sb.sb_ber.ber_buf = NULL; 55*7c478bd9Sstevel@tonic-gate if ( (tag = ber_get_next( &sb, &len, &ber )) == -1 ) { 56*7c478bd9Sstevel@tonic-gate perror( "ber_get_next" ); 57*7c478bd9Sstevel@tonic-gate exit( 1 ); 58*7c478bd9Sstevel@tonic-gate } 59*7c478bd9Sstevel@tonic-gate printf( "message has tag 0x%x and length %ld\n", tag, len ); 60*7c478bd9Sstevel@tonic-gate 61*7c478bd9Sstevel@tonic-gate if ( ber_scanf( &ber, "i", &i ) == -1 ) { 62*7c478bd9Sstevel@tonic-gate fprintf( stderr, "ber_scanf returns -1\n" ); 63*7c478bd9Sstevel@tonic-gate exit( 1 ); 64*7c478bd9Sstevel@tonic-gate } 65*7c478bd9Sstevel@tonic-gate printf( "got int %d\n", i ); 66*7c478bd9Sstevel@tonic-gate 67*7c478bd9Sstevel@tonic-gate return( 0 ); 68*7c478bd9Sstevel@tonic-gate } 69