Title: Patch for flow-nfilter to using DOS formatted cfg file

Hi All,

I have recently begun using flow-tools via Cygwin on Windows again and have come across a problem when reading filter files written with DOS CR/LF line endings. 

The error I get on both Cygwin and Unix using a DOS style cfg file is below.

% flow-cat -m ft-v07.2006-03-29.000000+0000 | flow-nfilter -f ~/test.dos -F f-test
flow-nfilter: /home/flows/test.dos line 2: Unrecognized type.
flow-nfilter: ftfil_load(): failed
%

I believe this error is due the string being "ip-address-mask\r" rather than "ip-address-mask".

I have had a crack at trying to fix this but my "c"-foo is 10 years too far gone.  Hence I would like to ask the list if considering the "\r" character as another form of whitespace is all I need to do? This seems to work on my test files but would like someone who knows the code better to check the logic of this tweak.

$ diff  -b lib/ftfil.c ../orig/flow-tools-0.68/lib/ftfil.c
467c467
<     B = strsep(A, " \t\r");\
---
>     B = strsep(A, " \t");\
5002c5002
<   while ((*p == ' ') || (*p == '\t') || (*p == '\r')) ++p;
---
>   while ((*p == ' ') || (*p == '\t')) ++p;
5013c5013
<     for (q = p; *q && (*q == ' ' || *q == '\t' || *q == '\r') ; ++q);
---
>     for (q = p; *q && (*q == ' ' || *q == '\t'); ++q);
5057c5057
<       for (q = p; *q && (*q == ' ' || *q == '\t' || *q == '\r'); ++q);
---
>       for (q = p; *q && (*q == ' ' || *q == '\t'); ++q)


I note that several other files contain similar constructs. Should I fix these too? 

lib\ftmap.c(371): c = strsep(&buf2, " \t\n");
lib\ftmap.c(494): c = strsep(buf2, " \t");
lib\ftmap.c(506): c = strsep(buf2, " \t");
lib\ftmap.c(518): c = strsep(buf2, " \t\n");
lib\ftmap.c(553): c = strsep(buf2, " \t");
lib\ftmap.c(565): c = strsep(buf2, " \t");
lib\ftmap.c(577): c = strsep(buf2, " \t\n");
lib\ftmask.c(87): B = strsep(A, " \t");\
lib\ftstat.c(396): B = strsep(A, " \t");\
lib\ftsym.c(161): for (; *buf && ((*buf == ' ') || (*buf == '\t')); ++buf);
lib\fttag.c(141): B = strsep(A, " \t");\
lib\ftxlate.c(231): B = strsep(A, " \t");\
lib\getdate.c(2037): (void) printf ("Enter date, or blank line to exit.\n\t> ");
lib\getdate.c(2048): (void) printf ("\t> ");
lib\support.c(109): while ((*p == ' ') || (*p == '\t')) ++p;
lib\support.c(325): while (*s && (*s != '.') && (*s != ' ') && (*s != '\t'))
lib\support.c(334): if ((!*s) || (*s == ' ') || (*s == '\t'))
src\flow-dscan.c(845): for (c = buf1; *c && ((*c == ' ') || (*c == '\t')); ++c);
src\flow-dscan.c(854): for (; *c && ((*c != ' ') && (*c != '\t')); ++c);
src\flow-dscan.c(855): for (; *c && ((*c == ' ') || (*c == '\t')); ++c);
src\flow-dscan.c(858): for (; *c && ((*c != ' ') && (*c != '\t')); ++c);
src\flow-dscan.c(859): for (; *c && ((*c == ' ') || (*c == '\t')); ++c);
src\flow-dscan.c(862): for (; *c && ((*c != ' ') && (*c != '\t')); ++c);
src\flow-dscan.c(863): for (; *c && ((*c == ' ') || (*c == '\t')); ++c);


Cheers

Alistair




**********************************************************************

Registered Office:

Marks and Spencer plc

Waterside House

35 North Wharf Road

London

W2 1NW

Registered No. 214436 in England and Wales.

Telephone (020) 7935 4422

Facsimile (020) 7487 2670

<<www.marksandspencer.com>>

Please note that electronic mail may be monitored.

This e-mail is confidential. If you received it by mistake, please let us know and then delete it from your system; you should not copy, disclose, or distribute its contents to anyone nor act in reliance on this e-mail, as this is prohibited and may be unlawful.

2005

_______________________________________________
Flow-tools mailing list
[EMAIL PROTECTED]
http://mailman.splintered.net/mailman/listinfo/flow-tools

Reply via email to