From 63e9063a660809385fd17edb94da044c7c884e02 Mon Sep 17 00:00:00 2001 From: Illes Marci Date: Mon, 3 Mar 2003 08:08:37 +0000 Subject: make iptables-restore print the line number in case of an error (Illes Marci ) --- iptables.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'iptables.c') diff --git a/iptables.c b/iptables.c index a0a1dd22..37539953 100644 --- a/iptables.c +++ b/iptables.c @@ -141,6 +141,12 @@ static struct option original_opts[] = { { 0 } }; +/* we need this for iptables-restore. iptables-restore.c sets line to the + * current line of the input file, in order to give a more precise error + * message. iptables itself doesn't need this, so it is initialized to the + * magic number of -1 */ +int line = -1; + #ifndef __OPTIMIZE__ struct ipt_entry_target * ipt_get_target(struct ipt_entry *e) @@ -330,6 +336,8 @@ exit_error(enum exittype status, char *msg, ...) void exit_tryhelp(int status) { + if (line =! -1) + fprintf(stderr, "Error occured at line: %d\n", line); fprintf(stderr, "Try `%s -h' or '%s --help' for more information.\n", program_name, program_name ); exit(status); -- cgit v1.2.3