17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate *
3*5e45752aSstevel * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
4*5e45752aSstevel * Use is subject to license terms.
57c478bd9Sstevel@tonic-gate *
67c478bd9Sstevel@tonic-gate */
77c478bd9Sstevel@tonic-gate
87c478bd9Sstevel@tonic-gate /* dtest.c - lber decoding test program */
97c478bd9Sstevel@tonic-gate /*
107c478bd9Sstevel@tonic-gate * Copyright (c) 1990 Regents of the University of Michigan.
117c478bd9Sstevel@tonic-gate * All rights reserved.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * Redistribution and use in source and binary forms are permitted
147c478bd9Sstevel@tonic-gate * provided that this notice is preserved and that due credit is given
157c478bd9Sstevel@tonic-gate * to the University of Michigan at Ann Arbor. The name of the University
167c478bd9Sstevel@tonic-gate * may not be used to endorse or promote products derived from this
177c478bd9Sstevel@tonic-gate * software without specific prior written permission. This software
187c478bd9Sstevel@tonic-gate * is provided ``as is'' without express or implied warranty.
197c478bd9Sstevel@tonic-gate */
207c478bd9Sstevel@tonic-gate
217c478bd9Sstevel@tonic-gate #include <stdio.h>
227c478bd9Sstevel@tonic-gate #include <string.h>
237c478bd9Sstevel@tonic-gate #ifdef MACOS
247c478bd9Sstevel@tonic-gate #include <stdlib.h>
257c478bd9Sstevel@tonic-gate #include <console.h>
267c478bd9Sstevel@tonic-gate #else /* MACOS */
277c478bd9Sstevel@tonic-gate #include <sys/types.h>
287c478bd9Sstevel@tonic-gate #include <sys/socket.h>
297c478bd9Sstevel@tonic-gate #endif /* MACOS */
307c478bd9Sstevel@tonic-gate #include "lber.h"
317c478bd9Sstevel@tonic-gate
usage(char * name)327c478bd9Sstevel@tonic-gate static usage( char *name )
337c478bd9Sstevel@tonic-gate {
347c478bd9Sstevel@tonic-gate fprintf( stderr, "usage: %s fmt\n", name );
357c478bd9Sstevel@tonic-gate }
367c478bd9Sstevel@tonic-gate
main(int argc,char ** argv)377c478bd9Sstevel@tonic-gate main( int argc, char **argv )
387c478bd9Sstevel@tonic-gate {
397c478bd9Sstevel@tonic-gate long i, i2, num;
407c478bd9Sstevel@tonic-gate unsigned long len;
417c478bd9Sstevel@tonic-gate int tag;
427c478bd9Sstevel@tonic-gate char *str, *s1, *s2;
437c478bd9Sstevel@tonic-gate BerElement ber;
447c478bd9Sstevel@tonic-gate Sockbuf sb;
457c478bd9Sstevel@tonic-gate extern char *optarg;
467c478bd9Sstevel@tonic-gate
477c478bd9Sstevel@tonic-gate #ifdef MACOS
487c478bd9Sstevel@tonic-gate ccommand( &argv );
497c478bd9Sstevel@tonic-gate cshow( stdout );
507c478bd9Sstevel@tonic-gate #endif /* MACOS */
517c478bd9Sstevel@tonic-gate
527c478bd9Sstevel@tonic-gate bzero( &sb, sizeof(sb) );
537c478bd9Sstevel@tonic-gate sb.sb_sd = 0;
547c478bd9Sstevel@tonic-gate sb.sb_ber.ber_buf = NULL;
557c478bd9Sstevel@tonic-gate if ( (tag = ber_get_next( &sb, &len, &ber )) == -1 ) {
567c478bd9Sstevel@tonic-gate perror( "ber_get_next" );
577c478bd9Sstevel@tonic-gate exit( 1 );
587c478bd9Sstevel@tonic-gate }
597c478bd9Sstevel@tonic-gate printf( "message has tag 0x%x and length %ld\n", tag, len );
607c478bd9Sstevel@tonic-gate
617c478bd9Sstevel@tonic-gate if ( ber_scanf( &ber, "i", &i ) == -1 ) {
627c478bd9Sstevel@tonic-gate fprintf( stderr, "ber_scanf returns -1\n" );
637c478bd9Sstevel@tonic-gate exit( 1 );
647c478bd9Sstevel@tonic-gate }
657c478bd9Sstevel@tonic-gate printf( "got int %d\n", i );
667c478bd9Sstevel@tonic-gate
677c478bd9Sstevel@tonic-gate return( 0 );
687c478bd9Sstevel@tonic-gate }
69