]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Add INCLUDE-IF[-NOT]-DEFINED and DEFINE-DEFAULT directives (STR #3821)
authormike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 12 May 2011 04:24:17 +0000 (04:24 +0000)
committermike <mike@7a7537e8-13f0-0310-91df-b6672ffda945>
Thu, 12 May 2011 04:24:17 +0000 (04:24 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@9769 7a7537e8-13f0-0310-91df-b6672ffda945

man/ipptoolfile.man
test/ipptool.c

index 15ae814d18182f44dda1611e289ab5fb4384c434..c677d9817b61a7f0961c6aba3e32a61601e4baeb 100644 (file)
@@ -3,7 +3,7 @@
 .\"
 .\"   ipptoolfile man page for CUPS.
 .\"
-.\"   Copyright 2010 by Apple Inc.
+.\"   Copyright 2010-2011 by Apple Inc.
 .\"
 .\"   These coded instructions, statements, and computer programs are the
 .\"   property of Apple Inc. and are protected by Federal copyright
@@ -11,7 +11,7 @@
 .\"   which should have been included with this file.  If this file is
 .\"   file is missing or damaged, see the license at "http://www.cups.org/".
 .\"
-.TH ipptoolfile 5 "CUPS" "6 August 2010" "Apple Inc."
+.TH ipptoolfile 5 "CUPS" "11 May 2011" "Apple Inc."
 .SH NAME
 ipptoolfile \- ipptool file format
 
@@ -74,6 +74,10 @@ DEFINE variable-name value
 Defines the named variable to the given value. This is equivalent to specifying
 "-d variable-name=value" on the \fIipptool\fR command-line.
 .TP 5
+DEFINE-DEFAULT variable-name value
+Defines the named variable to the given value if it does not already have a
+value.
+.TP 5
 IGNORE-ERRORS yes
 .TP 5
 IGNORE-ERRORS no
@@ -87,6 +91,20 @@ Includes another test file. The first form includes a file relative to the
 current test file, while the second form includes a file from the \fIipptool\fR
 include directory.
 .TP 5
+INCLUDE-IF-DEFINED name "filename"
+.TP 5
+INCLUDE-IF-DEFINED name <filename>
+Includes another test file if the named variable is defined. The first form
+includes a file relative to the current test file, while the second form
+includes a file from the \fIipptool\fR include directory.
+.TP 5
+INCLUDE-IF-NOT-DEFINED name "filename"
+.TP 5
+INCLUDE-IF-NOT-DEFINED name <filename>
+Includes another test file if the named variable is not defined. The first form
+includes a file relative to the current test file, while the second form
+includes a file from the \fIipptool\fR include directory.
+.TP 5
 SKIP-IF-DEFINED variable-name
 .TP 5
 SKIP-IF-NOT-DEFINED variable-name
@@ -487,7 +505,7 @@ Inserts the username from the URI provided to \fIipptool\fR, if any.
 http://localhost:631/help
 
 .SH COPYRIGHT
-Copyright 2007-2010 by Apple Inc.
+Copyright 2007-2011 by Apple Inc.
 .\"
 .\" End of "$Id$".
 .\"
index 848833a28583e6b4e5095dbf9ff646efbda545a7..d8cf66bfda91ea8a7303b16c1668952669d71822 100644 (file)
@@ -714,6 +714,29 @@ do_tests(_cups_vars_t *vars,               /* I - Variables */
 
       continue;
     }
+    else if (!strcmp(token, "DEFINE-DEFAULT"))
+    {
+     /*
+      * DEFINE-DEFAULT name value
+      */
+
+      if (get_token(fp, attr, sizeof(attr), &linenum) &&
+          get_token(fp, temp, sizeof(temp), &linenum))
+      {
+        expand_variables(vars, token, temp, sizeof(token));
+       if (!get_variable(vars, attr))
+         set_variable(vars, attr, token);
+      }
+      else
+      {
+        print_fatal_error("Missing DEFINE-DEFAULT name and/or value on line "
+                         "%d.", linenum);
+       pass = 0;
+       goto test_exit;
+      }
+
+      continue;
+    }
     else if (!strcmp(token, "IGNORE-ERRORS"))
     {
      /*
@@ -767,6 +790,76 @@ do_tests(_cups_vars_t *vars,               /* I - Variables */
       show_header = 1;
       continue;
     }
+    else if (!strcmp(token, "INCLUDE-IF-DEFINED"))
+    {
+     /*
+      * INCLUDE-IF-DEFINED name "filename"
+      * INCLUDE-IF-DEFINED name <filename>
+      */
+
+      if (get_token(fp, attr, sizeof(attr), &linenum) &&
+          get_token(fp, temp, sizeof(temp), &linenum))
+      {
+       /*
+        * Map the filename to and then run the tests...
+       */
+
+        if (get_variable(vars, attr) &&
+           !do_tests(vars, get_filename(testfile, filename, temp,
+                                        sizeof(filename))))
+       {
+         pass = 0;
+
+         if (!IgnoreErrors)
+           goto test_exit;
+       }
+      }
+      else
+      {
+        print_fatal_error("Missing INCLUDE-IF-DEFINED name or filename on line "
+                         "%d.", linenum);
+       pass = 0;
+       goto test_exit;
+      }
+
+      show_header = 1;
+      continue;
+    }
+    else if (!strcmp(token, "INCLUDE-IF-NOT-DEFINED"))
+    {
+     /*
+      * INCLUDE-IF-NOT-DEFINED name "filename"
+      * INCLUDE-IF-NOT-DEFINED name <filename>
+      */
+
+      if (get_token(fp, attr, sizeof(attr), &linenum) &&
+          get_token(fp, temp, sizeof(temp), &linenum))
+      {
+       /*
+        * Map the filename to and then run the tests...
+       */
+
+        if (!get_variable(vars, attr) &&
+           !do_tests(vars, get_filename(testfile, filename, temp,
+                                        sizeof(filename))))
+       {
+         pass = 0;
+
+         if (!IgnoreErrors)
+           goto test_exit;
+       }
+      }
+      else
+      {
+        print_fatal_error("Missing INCLUDE-IF-NOT-DEFINED name or filename on "
+                         "line %d.", linenum);
+       pass = 0;
+       goto test_exit;
+      }
+
+      show_header = 1;
+      continue;
+    }
     else if (!strcmp(token, "SKIP-IF-DEFINED"))
     {
      /*
@@ -780,7 +873,8 @@ do_tests(_cups_vars_t *vars,                /* I - Variables */
       }
       else
       {
-        print_fatal_error("Missing SKIP-IF-DEFINED value on line %d.", linenum);
+        print_fatal_error("Missing SKIP-IF-DEFINED variable on line %d.",
+                         linenum);
        pass = 0;
        goto test_exit;
       }
@@ -798,7 +892,7 @@ do_tests(_cups_vars_t *vars,                /* I - Variables */
       }
       else
       {
-        print_fatal_error("Missing SKIP-IF-NOT-DEFINED value on line %d.",
+        print_fatal_error("Missing SKIP-IF-NOT-DEFINED variable on line %d.",
                          linenum);
        pass = 0;
        goto test_exit;