4 * This is simply a filter that converts Citadel binary message format
5 * to readable, formatted output.
7 * If the -q (quiet or qwk) flag is used, only the message text prints, and
8 * then it stops at the end of the first message it prints.
10 * This utility isn't very useful anymore.
22 #if TIME_WITH_SYS_TIME
23 # include <sys/time.h>
27 # include <sys/time.h>
34 #include <libcitadel.h>
38 int fpgetfield(FILE * fp
, char *string
);
39 int fmout(int width
, FILE * fp
);
44 * replacement strerror() for systems that don't have it
50 snprintf(buf
, sizeof buf
, "errno = %d", e
);
55 int main(int argc
, char **argv
)
58 int a
, b
, e
, mtype
, aflag
;
65 if (!strcmp(argv
[1], "-q"))
69 if (strcmp(argv
[1], "-q")) {
70 fp
= fopen(argv
[1], "r");
72 fprintf(stderr
, "%s: cannot open %s: %s\n",
73 argv
[0], argv
[1], strerror(errno
));
94 if (!IsEmptyStr(subject
))
95 printf("Subject: %s\n", subject
);
100 while (a
= getc(fp
), a
> 0) {
107 if ((b
!= 'M') && (b
> 0))
110 strcpy(subject
, bbb
);
113 printf("from %s ", bbb
);
117 printf("in %s> ", bbb
);
119 printf("to %s ", bbb
);
122 localtime_r(&now
, &tm
);
123 strcpy(bbb
, asctime(&tm
));
124 bbb
[strlen(bbb
) - 1] = 0;
125 printf("%s ", &bbb
[4]);
128 } while ((b
!= 'M') && (b
> 0));
136 int fpgetfield(FILE * fp
, char *string
)
138 { /* level-2 break out next null-terminated string */
154 int fmout(int width
, FILE * fp
)
163 c
= 1; /* c is the current pos */
170 if (((a
== 13) || (a
== 10)) && (old
!= 13) && (old
!= 10))
172 if (((old
== 13) || (old
== 10)) && (isspace(real
))) {
180 if (((strlen(aaa
) + c
) > (width
- 5))
181 && (strlen(aaa
) > (width
- 5))) {
191 if ((strlen(aaa
) + c
) > (width
- 5)) {
201 if ((a
== 13) || (a
== 10)) {
209 FMTEND
: printf("\n");