Patrick Welche <prlw1@cam.ac.uk>
[netbsd-mini2440.git] / external / ibm-public / postfix / dist / src / global / recdump.c
blob47e46452d49eff46e0fde0e629db084ea270e33c
1 /* $NetBSD$ */
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 /*--*/
26 /* System library. */
28 #include <sys_defs.h>
29 #include <stdlib.h>
31 /* Utility library. */
33 #include <msg_vstream.h>
35 /* Global library. */
37 #include <record.h>
38 #include <rec_streamlf.h>
39 #include <rec_type.h>
41 int main(int unused_argc, char **argv)
43 VSTRING *buf = vstring_alloc(100);
44 long offset;
45 int type;
47 msg_vstream_init(argv[0], VSTREAM_OUT);
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));
56 vstream_fflush(VSTREAM_OUT);
57 vstring_free(buf);
58 exit(0);