Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Jul 1999 20:57:16 +0300
From:      Ruslan Ermilov <ru@FreeBSD.org>
To:        joerg@FreeBSD.org
Cc:        FreeBSD Hackers <hackers@FreeBSD.org>
Subject:   [PATCH] Preprocessor support for ipfw
Message-ID:  <19990703205716.A98500@relay.ucb.crimea.ua>

next in thread | raw e-mail | index | archive | help

--Kj7319i9nmIyA2yE
Content-Type: text/plain; charset=us-ascii

Hi!

There is one problem with ``preprocessor support for ipfw''.

relay# ls -l 100
ls: 100: No such file or directory
relay# ipfw list 100
00100 allow ip from any to any via lo0
relay# touch 100
relay# ipfw list 100
ipfw: error: extraneous filename arguments
[...]

Please review the attached patch.

Thanks,
-- 
Ruslan Ermilov		Sysadmin and DBA of the
ru@ucb.crimea.ua	United Commercial Bank,
ru@FreeBSD.org		FreeBSD committer,
+380.652.247.647	Simferopol, Ukraine

http://www.FreeBSD.org	The Power To Serve
http://www.oracle.com	Enabling The Information Age

--Kj7319i9nmIyA2yE
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=p

Index: ipfw.8
===================================================================
RCS file: /usr/FreeBSD-CVS/src/sbin/ipfw/ipfw.8,v
retrieving revision 1.54
diff -c -r1.54 ipfw.8
*** ipfw.8	1999/06/19 18:43:18	1.54
--- ipfw.8	1999/07/03 17:35:18
***************
*** 15,21 ****
  .Op Fl D Ar macro Ns Op Ns =value
  .Op Fl U Ar macro
  .Oc
! .Ar file
  .Nm ipfw
  .Oo
  .Fl f
--- 15,21 ----
  .Op Fl D Ar macro Ns Op Ns =value
  .Op Fl U Ar macro
  .Oc
! .Fl F Ar file
  .Nm ipfw
  .Oo
  .Fl f
Index: ipfw.c
===================================================================
RCS file: /usr/FreeBSD-CVS/src/sbin/ipfw/ipfw.c,v
retrieving revision 1.71
diff -c -r1.71 ipfw.c
*** ipfw.c	1999/06/19 18:43:15	1.71
--- ipfw.c	1999/07/03 17:35:18
***************
*** 58,65 ****
  #include <netinet/tcp.h>
  #include <arpa/inet.h>
  
- int 		lineno = -1;
- 
  int 		s;				/* main RAW socket 	   */
  int 		do_resolv=0;			/* Would try to resolve all */
  int		do_acct=0;			/* Show packet/byte count  */
--- 58,63 ----
***************
*** 1549,1556 ****
  #define WHITESP		" \t\f\v\n\r"
  	char	buf[BUFSIZ];
  	char	*a, *p, *args[MAX_ARGS], *cmd = NULL;
! 	char	linename[10];
! 	int 	i, c, qflag, pflag, status;
  	FILE	*f = NULL;
  	pid_t	preproc = 0;
  
--- 1547,1556 ----
  #define WHITESP		" \t\f\v\n\r"
  	char	buf[BUFSIZ];
  	char	*a, *p, *args[MAX_ARGS], *cmd = NULL;
! 	char	linename[11];
! 	int 	i = 0, c, qflag = 0, pflag = 0, status;
! 	int 	lineno = 0;
! 	char	*file = NULL;
  	FILE	*f = NULL;
  	pid_t	preproc = 0;
  
***************
*** 1558,1613 ****
  	if ( s < 0 )
  		err(EX_UNAVAILABLE, "socket");
  
! 	setbuf(stdout,0);
  
! 	if (ac > 1 && access(av[ac - 1], R_OK) == 0) {
! 		qflag = pflag = i = 0;
! 		lineno = 0;
! 
! 		while ((c = getopt(ac, av, "D:U: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;
! 				args[0] = cmd;
! 				i = 1;
! 				break;
  
! 			case 'q':
! 				qflag = 1;
! 				break;
  
! 			default:
! 				show_usage(NULL);
! 			}
  
! 		av += optind;
! 		ac -= optind;
! 		if (ac != 1)
  			show_usage("extraneous filename arguments");
  
! 		if ((f = fopen(av[0], "r")) == NULL)
! 			err(EX_UNAVAILABLE, "fopen: %s", av[0]);
  
  		if (pflag) {
  			/* pipe through preprocessor (cpp or m4) */
--- 1558,1614 ----
  	if ( s < 0 )
  		err(EX_UNAVAILABLE, "socket");
  
! 	setbuf(stdout, NULL);
  
! 	while ((c = getopt(ac, av, "F:D:U:p:q")) != -1)
! 		switch(c) {
! 		case 'F':
! 			if (file)
! 				errx(EX_USAGE, "only one -F allowed");
! 			file = optarg;
! 			break;
  
! 		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;
! 			args[0] = cmd;
! 			i = 1;
! 			break;
  
! 		case 'q':
! 			qflag = 1;
! 			break;
! 
! 		default:
! 			show_usage(NULL);
! 		}
  
! 	if (file) {
! 		if (ac - optind)
  			show_usage("extraneous filename arguments");
  
! 		if ((f = fopen(file, "r")) == NULL)
! 			err(EX_UNAVAILABLE, "fopen: %s", file);
  
  		if (pflag) {
  			/* pipe through preprocessor (cpp or m4) */
***************
*** 1648,1655 ****
  		}
  
  		while (fgets(buf, BUFSIZ, f)) {
! 			lineno++;
! 			sprintf(linename, "Line %d", lineno);
  			args[0] = linename;
  
  			if (*buf == '#')
--- 1649,1655 ----
  		}
  
  		while (fgets(buf, BUFSIZ, f)) {
! 			snprintf(linename, sizeof(linename), "Line %d", ++lineno);
  			args[0] = linename;
  
  			if (*buf == '#')

--Kj7319i9nmIyA2yE--


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990703205716.A98500>