1 /* $NetBSD: recdump.c,v 1.1.1.1 2009/06/23 10:08:47 tron Exp $ */ 2 3 /*++ 4 /* NAME 5 /* recdump 1 6 /* SUMMARY 7 /* convert record stream to printable form 8 /* SYNOPSIS 9 /* recdump 10 /* DESCRIPTION 11 /* recdump reads a record stream from standard input and 12 /* writes the content to standard output in printable form. 13 /* DIAGNOSTICS 14 /* Problems are reported to the standard error stream. 15 /* LICENSE 16 /* .ad 17 /* .fi 18 /* The Secure Mailer license must be distributed with this software. 19 /* AUTHOR(S) 20 /* Wietse Venema 21 /* IBM T.J. Watson Research 22 /* P.O. Box 704 23 /* Yorktown Heights, NY 10598, USA 24 /*--*/ 25 26 /* System library. */ 27 28 #include <sys_defs.h> 29 #include <stdlib.h> 30 31 /* Utility library. */ 32 33 #include <msg_vstream.h> 34 35 /* Global library. */ 36 37 #include <record.h> 38 #include <rec_streamlf.h> 39 #include <rec_type.h> 40 41 int main(int unused_argc, char **argv) 42 { 43 VSTRING *buf = vstring_alloc(100); 44 long offset; 45 int type; 46 47 msg_vstream_init(argv[0], VSTREAM_OUT); 48 49 while (offset = vstream_ftell(VSTREAM_IN), 50 ((type = rec_get(VSTREAM_IN, buf, 0)) != REC_TYPE_EOF 51 && type != REC_TYPE_ERROR)) { 52 vstream_fprintf(VSTREAM_OUT, "%15s|%4ld|%3ld|%s\n", 53 rec_type_name(type), offset, 54 (long) VSTRING_LEN(buf), vstring_str(buf)); 55 } 56 vstream_fflush(VSTREAM_OUT); 57 vstring_free(buf); 58 exit(0); 59 } 60