]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
make iptables-restore print the line number in case of an error
authorIlles Marci <marci@balabit.hu>
Mon, 3 Mar 2003 08:08:37 +0000 (08:08 +0000)
committerHarald Welte <laforge@gnumonks.org>
Mon, 3 Mar 2003 08:08:37 +0000 (08:08 +0000)
(Illes Marci <marci@balabit.hu>)

include/iptables.h
iptables-restore.c
iptables.c

index 858bbdc793ad8764709aba0699a4ad0331681384..205984eb500261d5a5df1a64c7a26e0910972901 100644 (file)
@@ -106,6 +106,8 @@ struct iptables_target
 #endif
 };
 
+extern int line;
+
 /* Your shared library should call one of these. */
 extern void register_match(struct iptables_match *me);
 extern void register_target(struct iptables_target *me);
index 13dcd259262ad1312d7bfcb3734c98b052ce6110..8e1938990f3f4647f985aecb882230e3ff0121c0 100644 (file)
@@ -4,7 +4,7 @@
  *
  * This code is distributed under the terms of GNU GPL v2
  *
- * $Id: iptables-restore.c,v 1.22 2002/08/07 09:07:41 laforge Exp $
+ * $Id: iptables-restore.c,v 1.23 2003/03/03 08:05:07 laforge Exp $
  */
 
 #include <getopt.h>
@@ -101,7 +101,6 @@ int main(int argc, char *argv[])
 {
        iptc_handle_t handle;
        char buffer[10240];
-       unsigned int line = 0;
        int c;
        char curtable[IPT_TABLE_MAXNAMELEN + 1];
        FILE *in;
@@ -110,6 +109,7 @@ int main(int argc, char *argv[])
 
        program_name = "iptables-restore";
        program_version = IPTABLES_VERSION;
+       line = 0;
 
 #ifdef NO_SHARED_LIBS
        init_extensions();
index a0a1dd229eabb5c4689d58d5317af5bd3590e950..37539953b636d0587ba9b7d0d70e127fb011bcaf 100644 (file)
@@ -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);