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.
21 #include <libcitadel.h>
25 int fpgetfield(FILE * fp, char *string);
26 int fmout(int width, FILE * fp);
30 int main(int argc, char **argv)
40 if (!strcmp(argv[1], "-q"))
44 if (strcmp(argv[1], "-q")) {
45 fp = fopen(argv[1], "r");
47 fprintf(stderr, "%s: cannot open %s: %s\n",
48 argv[0], argv[1], strerror(errno));
69 if (!IsEmptyStr(subject))
70 printf("Subject: %s\n", subject);
75 while (a = getc(fp), a > 0) {
82 if ((b != 'M') && (b > 0))
88 printf("from %s ", bbb);
92 printf("in %s> ", bbb);
94 printf("to %s ", bbb);
97 localtime_r(&now, &tm);
98 strcpy(bbb, asctime(&tm));
99 bbb[strlen(bbb) - 1] = 0;
100 printf("%s ", &bbb[4]);
103 } while ((b != 'M') && (b > 0));
111 int fpgetfield(FILE * fp, char *string)
113 { /* level-2 break out next null-terminated string */
129 int fmout(int width, FILE * fp)
138 c = 1; /* c is the current pos */
145 if (((a == 13) || (a == 10)) && (old != 13) && (old != 10))
147 if (((old == 13) || (old == 10)) && (isspace(real))) {
155 if (((strlen(aaa) + c) > (width - 5))
156 && (strlen(aaa) > (width - 5))) {
166 if ((strlen(aaa) + c) > (width - 5)) {
176 if ((a == 13) || (a == 10)) {
184 FMTEND: printf("\n");