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