Commit de42fb23 authored by rswindell's avatar rswindell
Browse files

Add '-c' option to dump control lines only. -b implies -c.

Also converts Ctrl-A chars to '@", so behaves similar to fmsgdump now.
SEEN-BY's and AREA lines aren't dumped with -c because they don't begin with
a Ctrl-A.
parent 41ed7a56
......@@ -11,6 +11,7 @@
FILE* nulfp;
FILE* bodyfp;
FILE* ctrlfp;
/****************************************************************************/
/* Returns an ASCII string for FidoNet address 'addr' */
......@@ -214,7 +215,18 @@ int pktdump(FILE* fp, const char* fname, FILE* good, FILE* bad)
fprintf(bodyfp,"\n-start of message text-\n");
size_t count = 0;
while((ch=fgetc(fp))!=EOF && ch!=0) {
count++;
if((count == 1 || lastch == '\r') && ch == 1) {
fputc('@', ctrlfp);
while((ch = fgetc(fp)) != EOF && ch != 0 && ch != '\r')
fputc(ch, ctrlfp);
fputc('\n', ctrlfp);
if(ch == 0)
break;
continue;
}
if(lastch=='\r' && ch!='\n')
fputc('\n',bodyfp);
fputc(lastch=ch,bodyfp);
......@@ -238,7 +250,7 @@ int pktdump(FILE* fp, const char* fname, FILE* good, FILE* bad)
return(0);
}
char* usage = "usage: pktdump [-body] [-recover | -split] <file1.pkt> [file2.pkt] [...]\n";
char* usage = "usage: pktdump [-body | -ctrl] [-recover | -split] <file1.pkt> [file2.pkt] [...]\n";
int main(int argc, char** argv)
{
......@@ -264,6 +276,7 @@ int main(int argc, char** argv)
return -1;
}
bodyfp=nulfp;
ctrlfp=nulfp;
if(sizeof(fpkthdr_t)!=FIDO_PACKET_HDR_LEN) {
printf("sizeof(fpkthdr_t)=%" XP_PRIsize_t "u, expected: %d\n",sizeof(fpkthdr_t),FIDO_PACKET_HDR_LEN);
......@@ -283,6 +296,9 @@ int main(int argc, char** argv)
switch(tolower(argv[i][1])) {
case 'b':
bodyfp=stdout;
/* fall-through */
case 'c':
ctrlfp = stdout;
break;
case 'r':
recover=true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment