From: mike Date: Thu, 12 May 2011 04:24:17 +0000 (+0000) Subject: Add INCLUDE-IF[-NOT]-DEFINED and DEFINE-DEFAULT directives (STR #3821) X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0be42c796713ee6f048a5c4d26e73ccfb94f5f30;p=thirdparty%2Fcups.git Add INCLUDE-IF[-NOT]-DEFINED and DEFINE-DEFAULT directives (STR #3821) git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@9769 7a7537e8-13f0-0310-91df-b6672ffda945 --- diff --git a/man/ipptoolfile.man b/man/ipptoolfile.man index 15ae814d18..c677d9817b 100644 --- a/man/ipptoolfile.man +++ b/man/ipptoolfile.man @@ -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 +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 +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$". .\" diff --git a/test/ipptool.c b/test/ipptool.c index 848833a285..d8cf66bfda 100644 --- a/test/ipptool.c +++ b/test/ipptool.c @@ -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 + */ + + 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 + */ + + 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;