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);
31 * replacement strerror() for systems that don't have it
37 snprintf(buf, sizeof buf, "errno = %d", e);
42 int main(int argc, char **argv)
52 if (!strcmp(argv[1], "-q"))
56 if (strcmp(argv[1], "-q")) {
57 fp = fopen(argv[1], "r");
59 fprintf(stderr, "%s: cannot open %s: %s\n",
60 argv[0], argv[1], strerror(errno));
81 if (!IsEmptyStr(subject))
82 printf("Subject: %s\n", subject);
87 while (a = getc(fp), a > 0) {
94 if ((b != 'M') && (b > 0))
100 printf("from %s ", bbb);
104 printf("in %s> ", bbb);
106 printf("to %s ", bbb);
109 localtime_r(&now, &tm);
110 strcpy(bbb, asctime(&tm));
111 bbb[strlen(bbb) - 1] = 0;
112 printf("%s ", &bbb[4]);
115 } while ((b != 'M') && (b > 0));
123 int fpgetfield(FILE * fp, char *string)
125 { /* level-2 break out next null-terminated string */
141 int fmout(int width, FILE * fp)
150 c = 1; /* c is the current pos */
157 if (((a == 13) || (a == 10)) && (old != 13) && (old != 10))
159 if (((old == 13) || (old == 10)) && (isspace(real))) {
167 if (((strlen(aaa) + c) > (width - 5))
168 && (strlen(aaa) > (width - 5))) {
178 if ((strlen(aaa) + c) > (width - 5)) {
188 if ((a == 13) || (a == 10)) {
196 FMTEND: printf("\n");