From owner-freebsd-ipfw Mon Feb 28 9:12:24 2000 Delivered-To: freebsd-ipfw@freebsd.org Received: from reyim.ne.mediaone.net (reyim.ne.mediaone.net [24.218.251.241]) by hub.freebsd.org (Postfix) with ESMTP id B396537B8F8 for ; Mon, 28 Feb 2000 09:12:09 -0800 (PST) (envelope-from bloom@acm.org) Received: from acm.org (localhost [127.0.0.1]) by reyim.ne.mediaone.net (8.9.3/8.9.3) with ESMTP id MAA01180; Mon, 28 Feb 2000 12:09:32 -0500 (EST) (envelope-from bloom@acm.org) Message-ID: <38BAABCC.BCA300AB@acm.org> Date: Mon, 28 Feb 2000 12:09:32 -0500 From: Jim Bloom Reply-To: bloom@acm.org X-Mailer: Mozilla 4.7 [en] (X11; U; FreeBSD 4.0-CURRENT i386) X-Accept-Language: en MIME-Version: 1.0 To: Ruslan Ermilov Cc: jsegovia@cnc.una.py, freebsd-ipfw@FreeBSD.org Subject: [PATCH] Re: cpp change breaks ipfw References: <200002271345.JAA29398@alpha.cnc.una.py> <38B98413.CB910261@acm.org> <20000227221631.A70300@relay.ucb.crimea.ua> Content-Type: multipart/mixed; boundary="------------901026C53DF8383680A7EA79" Sender: owner-freebsd-ipfw@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG This is a multi-part message in MIME format. --------------901026C53DF8383680A7EA79 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To provide an easy workaround for the problem with cpp putting spaces around expanded macros which causes problems for ipfw, i modified ipfw to take arbitrary parameter and pass them to the preprocessor. With cpp, -traditional may be passed on the command line. This patch also allows for a much wider range of preprocessors since it allows for arbitrary syntax in the arguments. I'm sure several people will have problems with ipfw when 4.0 is released because of the change to cpp. Will someone please test this patch again and commit it. Thanks. Jim Bloom bloom@acm.org --------------901026C53DF8383680A7EA79 Content-Type: text/plain; charset=us-ascii; name="ipfw.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="ipfw.patch" Index: ipfw.8 =================================================================== RCS file: /users/ncvs/src/sbin/ipfw/ipfw.8,v retrieving revision 1.63 diff -u -r1.63 ipfw.8 --- ipfw.8 2000/02/28 15:21:12 1.63 +++ ipfw.8 2000/02/28 16:35:26 @@ -12,14 +12,8 @@ .Op Fl q .Oo .Fl p Ar preproc -.Oo Fl D -.Sm off -.Ar macro -.Op = Ar value -.Sm on +.Op Ar preproc-options .Oc -.Op Fl U Ar macro -.Oc .Ar file .Nm ipfw .Op Fl f | q @@ -225,11 +219,8 @@ is being run (e.g. when they are mounted over NFS). Once .Fl p -has been specified, optional -.Fl D -and -.Fl U -specifications can follow and will be passed on to the preprocessor. +has been specified, optional arguments for the preprocessor +can follow and will be passed on to the preprocessor. This allows for flexible configuration files (like conditionalizing them on the local hostname) and the use of macros to centralize frequently required arguments like IP addresses. Index: ipfw.c =================================================================== RCS file: /users/ncvs/src/sbin/ipfw/ipfw.c,v retrieving revision 1.80 diff -u -r1.80 ipfw.c --- ipfw.c 2000/02/13 11:46:59 1.80 +++ ipfw.c 2000/02/28 16:26:16 @@ -1917,28 +1917,8 @@ qflag = pflag = i = 0; lineno = 0; - while ((c = getopt(ac, av, "D:U:p:q")) != -1) + while (!pflag && (c = getopt(ac, av, "p:q")) != -1) switch(c) { - case 'D': - if (!pflag) - errx(EX_USAGE, "-D requires -p"); - if (i > MAX_ARGS - 2) - errx(EX_USAGE, - "too many -D or -U options"); - args[i++] = "-D"; - args[i++] = optarg; - break; - - case 'U': - if (!pflag) - errx(EX_USAGE, "-U requires -p"); - if (i > MAX_ARGS - 2) - errx(EX_USAGE, - "too many -D or -U options"); - args[i++] = "-U"; - args[i++] = optarg; - break; - case 'p': pflag = 1; cmd = optarg; @@ -1956,8 +1936,15 @@ av += optind; ac -= optind; - if (ac != 1) - show_usage("extraneous filename arguments"); + + if (pflag) { + while (--ac > 0 && i < MAX_ARGS) { + args[i++] = *av++; + } + if (i >= MAX_ARGS) + errx(EX_USAGE, + "too many arguments to preprocessor"); + } if ((f = fopen(av[0], "r")) == NULL) err(EX_UNAVAILABLE, "fopen: %s", av[0]); --------------901026C53DF8383680A7EA79-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ipfw" in the body of the message