Date: Thu, 4 Dec 1997 22:06:37 -0800 (PST) From: Dmitry Kohmanyuk <dk@dog.farm.org> To: archie@whistle.com (Archie Cobbs) Cc: freebsd-hackers@freebsd.org Subject: Re: Teeny-weeny /usr/src/sbin/ipfw/ipfw.c patch Message-ID: <199712050606.WAA23987@dog.farm.org>
next in thread | raw e-mail | index | archive | help
In article <199712050142.RAA11543@bubba.whistle.com> you wrote: > Jos Backus writes: > > *** ipfw.c.dist Fri Dec 5 01:29:49 1997 > > --- ipfw.c Fri Dec 5 01:30:20 1997 > > *************** > > *** 1197,1202 **** > > --- 1197,1203 ---- > > while (fgets(buf, BUFSIZ, f)) { > > > > lineno++; > > + if (buf[0]=='#'||buf[0]=='\n') continue; > > sprintf(linename, "Line %d", lineno); > > args[0] = linename; > > > > This allows comments/empty lines in a firewall rule file (when using the > > ``ipfw rulefile'' syntax), which seems pretty handy (at least to me -- > > documenting rules and all that). > Good idea! But may I suggest this tweak? So a blank line with extra > white space is OK too... > *** ipfw.c.orig Fri Dec 5 01:39:35 1997 > --- ipfw.c Fri Dec 5 01:40:33 1997 > *************** > *** 1200,1208 **** > --- 1200,1212 ---- > sprintf(linename, "Line %d", lineno); > args[0] = linename; > > + if (*buf == '#') > + continue; should probably become char *p; if ((p = strchr(buf, '#') != NULL) *p = 0; to handle lines like #indented comment or ipfw deny .... ... #end-of-line comment > for (i = 1, a = strtok(buf, WHITESP); > a && i < MAX_ARGS; a = strtok(NULL, WHITESP), i++) > args[i] = a; > + if (i == 1) > + continue; > if (i == MAX_ARGS) > errx(1, "%s: too many arguments", linename); > args[i] = NULL; -- "'Programming' is a four-letter word." --Craig Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199712050606.WAA23987>