2 * This is simply a filter that converts Citadel binary message format
3 * to readable, formatted output.
5 * If the -q (quiet or qwk) flag is used, only the message text prints, and
6 * then it stops at the end of the first message it prints.
8 * This utility isn't very useful anymore.
20 #if TIME_WITH_SYS_TIME
21 # include <sys/time.h>
25 # include <sys/time.h>
32 #include <libcitadel.h>
36 int fpgetfield(FILE * fp, char *string);
37 int fmout(int width, FILE * fp);
42 * replacement strerror() for systems that don't have it
48 snprintf(buf, sizeof buf, "errno = %d", e);
53 int main(int argc, char **argv)
56 int a, b, e, mtype, aflag;
63 if (!strcmp(argv[1], "-q"))
67 if (strcmp(argv[1], "-q")) {
68 fp = fopen(argv[1], "r");
70 fprintf(stderr, "%s: cannot open %s: %s\n",
71 argv[0], argv[1], strerror(errno));
92 if (!IsEmptyStr(subject))
93 printf("Subject: %s\n", subject);
98 while (a = getc(fp), a > 0) {
105 if ((b != 'M') && (b > 0))
108 strcpy(subject, bbb);
111 printf("from %s ", bbb);
115 printf("in %s> ", bbb);
117 printf("to %s ", bbb);
120 localtime_r(&now, &tm);
121 strcpy(bbb, asctime(&tm));
122 bbb[strlen(bbb) - 1] = 0;
123 printf("%s ", &bbb[4]);
126 } while ((b != 'M') && (b > 0));
134 int fpgetfield(FILE * fp, char *string)
136 { /* level-2 break out next null-terminated string */
152 int fmout(int width, FILE * fp)
161 c = 1; /* c is the current pos */
168 if (((a == 13) || (a == 10)) && (old != 13) && (old != 10))
170 if (((old == 13) || (old == 10)) && (isspace(real))) {
178 if (((strlen(aaa) + c) > (width - 5))
179 && (strlen(aaa) > (width - 5))) {
189 if ((strlen(aaa) + c) > (width - 5)) {
199 if ((a == 13) || (a == 10)) {
207 FMTEND: printf("\n");