Postfix3.3.1
recdump.c
[詳解]
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 
39 int 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  }
55  vstring_free(buf);
56  exit(0);
57 }
#define vstring_str(vp)
Definition: vstring.h:71
off_t vstream_ftell(VSTREAM *stream)
Definition: vstream.c:1157
#define VSTREAM_OUT
Definition: vstream.h:67
const char * rec_type_name(int type)
Definition: rec_type.c:79
#define VSTREAM_IN
Definition: vstream.h:66
#define VSTRING_LEN(vp)
Definition: vstring.h:72
#define REC_TYPE_EOF
Definition: rec_type.h:23
int main(int unused_argc, char **argv)
Definition: recdump.c:39
VSTREAM * vstream_fprintf(VSTREAM *stream, const char *fmt,...)
Definition: vstream.c:1348
VSTRING * vstring_alloc(ssize_t len)
Definition: vstring.c:353
int vstream_fflush(VSTREAM *stream)
Definition: vstream.c:1257
VSTRING * vstring_free(VSTRING *vp)
Definition: vstring.c:380
void msg_vstream_init(const char *name, VSTREAM *vp)
Definition: msg_vstream.c:77
#define REC_TYPE_ERROR
Definition: rec_type.h:24
#define rec_get(fp, buf, limit)
Definition: record.h:56