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