Lines Matching +full:- +full:- +full:match +full:- +full:filename
6 * Copyright © 2007-2021 by Apple Inc.
7 * Copyright © 1997-2007 by Easy Software Products.
17 #include <cups/cups-private.h>
40 #define MAX_MONITOR 10 // Maximum number of MONITOR-PRINTER-STATE EXPECT directives
61 IPPTOOL_OUTPUT_CSV /* Comma-separated values output */
66 IPPTOOL_WITH_LITERAL = 0, /* Match string is a literal value */
67 IPPTOOL_WITH_ALL = 1, /* Must match all values */
68 IPPTOOL_WITH_REGEX = 2, /* Match string is a regular expression */
69 IPPTOOL_WITH_HOSTNAME = 4, /* Match string is a URI hostname */
70 IPPTOOL_WITH_RESOURCE = 8, /* Match string is a URI resource */
71 IPPTOOL_WITH_SCHEME = 16 /* Match string is a URI scheme */
78 expect_all; /* Expect all attributes to match/not match */
86 *define_match, /* Variable to define on match */
87 *define_no_match, /* Variable to define on no-match */
89 *display_match; /* Message to display on a match */
91 repeat_match, /* Repeat test on match */
92 repeat_no_match, /* Repeat test on no match */
93 with_distinct, /* WITH-DISTINCT-VALUES? */
96 ipp_tag_t in_group; /* IN-GROUP value */
104 *define_match, /* Variable to define on match */
105 *define_no_match, /* Variable to define on no-match */
108 repeat_match, /* Repeat the test when it does not match */
119 int repeat_on_busy; /* Repeat tests on server-error-busy */
127 int def_ignore_errors; /* Default IGNORE-ERRORS value */
142 /* Per-Test State */
154 char file[1024], /* Data filename */
172 char *monitor_uri; /* MONITOR-PRINTER-STATE URI */
173 useconds_t monitor_delay, /* MONITOR-PRINTER-STATE DELAY value, if any */
174 monitor_interval; /* MONITOR-PRINTER-STATE DELAY interval */
175 int num_monitor_expects; /* Number MONITOR-PRINTER-STATE EXPECTs */
177 /* MONITOR-PRINTER-STATE EXPECTs */
228 * 'main()' - Parse options and do tests.
231 int /* O - Exit status */
232 main(int argc, /* I - Number of command-line args */ in main()
233 char *argv[]) /* I - Command-line arguments */ in main()
240 filename[1024], /* Real filename */ in main() local
241 testname[1024]; /* Real test filename */ in main()
242 const char *ext, /* Extension on filename */ in main()
272 _ippVarsSet(data.vars, "date-start", iso_date(ippTimeToDate(time(NULL)))); in main()
287 if (!strcmp(argv[i], "--help")) in main()
291 else if (!strcmp(argv[i], "--ippserver")) in main()
297 _cupsLangPuts(stderr, _("ipptool: Missing filename for \"--ippserver\".")); in main()
312 else if (!strcmp(argv[i], "--stop-after-include-error")) in main()
316 else if (!strcmp(argv[i], "--version")) in main()
321 else if (argv[i][0] == '-') in main()
363 _cupsLangPrintf(stderr, _("%s: Missing filename for \"-P\"."), "ipptool"); in main()
380 … _cupsLangPuts(stderr, _("ipptool: \"-i\" and \"-n\" are incompatible with \"-P\" and \"-X\".")); in main()
385 case 'R' : /* Repeat on server-error-busy */ in main()
402 _cupsLangPrintf(stderr, _("%s: Missing timeout for \"-T\"."), "ipptool"); in main()
414 _cupsLangPrintf(stderr, _("%s: Missing version for \"-V\"."), "ipptool"); in main()
440 _cupsLangPrintf(stderr, _("%s: Bad version %s for \"-V\"."), "ipptool", argv[i]); in main()
450 … _cupsLangPuts(stderr, _("ipptool: \"-i\" and \"-n\" are incompatible with \"-P\" and \"-X\".")); in main()
464 _cupsLangPuts(stderr, _("ipptool: Missing name=value for \"-d\".")); in main()
477 case 'f' : /* Set the default test filename */ in main()
482 _cupsLangPuts(stderr, _("ipptool: Missing filename for \"-f\".")); in main()
489 * Try filename.gz... in main()
492 snprintf(filename, sizeof(filename), "%s.gz", argv[i]); in main()
493 if (access(filename, 0) && filename[0] != '/' in main()
495 && (!isalpha(filename[0] & 255) || filename[1] != ':') in main()
499 snprintf(filename, sizeof(filename), "%s/ipptool/%s", cg->cups_datadir, argv[i]); in main()
500 if (access(filename, 0)) in main()
502 snprintf(filename, sizeof(filename), "%s/ipptool/%s.gz", cg->cups_datadir, argv[i]); in main()
503 if (access(filename, 0)) in main()
504 strlcpy(filename, argv[i], sizeof(filename)); in main()
509 strlcpy(filename, argv[i], sizeof(filename)); in main()
511 _ippVarsSet(data.vars, "filename", filename); in main()
513 if ((ext = strrchr(filename, '.')) != NULL) in main()
531 _ippVarsSet(data.vars, "filetype", "application/vnd.hp-PCL"); in main()
543 _ippVarsSet(data.vars, "filetype", "image/pwg-raster"); in main()
556 _ippVarsSet(data.vars, "filetype", "application/octet-stream"); in main()
561 * Use the "auto-type" MIME media type... in main()
564 _ippVarsSet(data.vars, "filetype", "application/octet-stream"); in main()
577 _cupsLangPuts(stderr, _("ipptool: Missing seconds for \"-i\".")); in main()
585 _cupsLangPuts(stderr, _("ipptool: Invalid seconds for \"-i\".")); in main()
592 …_cupsLangPuts(stderr, _("ipptool: \"-i\" and \"-n\" are incompatible with \"--ippserver\", \"-P\",… in main()
606 _cupsLangPuts(stderr, _("ipptool: Missing count for \"-n\".")); in main()
614 …_cupsLangPuts(stderr, _("ipptool: \"-i\" and \"-n\" are incompatible with \"--ippserver\", \"-P\",… in main()
632 _cupsLangPrintf(stderr, _("%s: Unknown option \"-%c\"."), "ipptool", *opt); in main()
647 if (data.vars->uri) in main()
664 if (data.vars->username[0] && data.vars->password) in main()
673 if (!data.vars->uri) in main()
686 snprintf(testname, sizeof(testname), "%s/ipptool/%s", cg->cups_datadir, argv[i]); in main()
705 if (!data.vars->uri || !testfile) in main()
720 repeat --; in main()
752 * 'add_stringf()' - Add a formatted string to an array.
756 add_stringf(cups_array_t *a, /* I - Array */ in add_stringf()
757 const char *s, /* I - Printf-style format string */ in add_stringf()
758 ...) /* I - Additional args as needed */ in add_stringf()
788 * 'compare_uris()' - Compare two URIs...
791 static int /* O - Result of comparison */
792 compare_uris(const char *a, /* I - First URI */ in compare_uris()
793 const char *b) /* I - Second URI */ in compare_uris()
814 return (-1); in compare_uris()
817 return (-1); in compare_uris()
823 if ((ptr = ahost + strlen(ahost) - 1) > ahost && *ptr == '.') in compare_uris()
826 if ((ptr = bhost + strlen(bhost) - 1) > bhost && *ptr == '.') in compare_uris()
843 return (aport - bport); in compare_uris()
853 * 'copy_hex_string()' - Copy an octetString to a C string and encode as hex if
858 copy_hex_string(char *buffer, /* I - String buffer */ in copy_hex_string()
859 unsigned char *data, /* I - octetString data */ in copy_hex_string()
860 int datalen, /* I - octetString length */ in copy_hex_string()
861 size_t bufsize) /* I - Size of string buffer */ in copy_hex_string()
864 *bufend = buffer + bufsize - 2; in copy_hex_string()
874 * First see if there are any non-ASCII bytes in the octetString... in copy_hex_string()
907 datalen = (int)bufsize - 1; in copy_hex_string()
916 * 'do_monitor_printer_state()' - Do the MONITOR-PRINTER-STATE tests in the background.
919 static void * // O - Thread exit status
921 ipptool_test_t *data) // I - Test data in do_monitor_printer_state()
942 …if (httpSeparateURI(HTTP_URI_CODING_ALL, data->monitor_uri, scheme, sizeof(scheme), userpass, size… in do_monitor_printer_state()
944 print_fatal_error(data, "Bad printer URI \"%s\".", data->monitor_uri); in do_monitor_printer_state()
951 encryption = data->encryption; in do_monitor_printer_state()
953 if ((http = httpConnect2(host, port, NULL, data->family, encryption, 1, 30000, NULL)) == NULL) in do_monitor_printer_state()
955 …print_fatal_error(data, "Unable to connect to \"%s\" on port %d - %s", host, port, cupsLastErrorSt… in do_monitor_printer_state()
965 if (data->timeout > 0.0) in do_monitor_printer_state()
966 httpSetTimeout(http, data->timeout, timeout_cb, NULL); in do_monitor_printer_state()
969 if (data->monitor_delay) in do_monitor_printer_state()
970 usleep(data->monitor_delay); in do_monitor_printer_state()
974 ippSetRequestId(request, data->request_id * 100 - 1); in do_monitor_printer_state()
975 ippSetVersion(request, data->version / 10, data->version % 10); in do_monitor_printer_state()
976 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, data->monitor_uri); in do_monitor_printer_state()
977 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser()); in do_monitor_printer_state()
979 …for (i = data->num_monitor_expects, expect = data->monitor_expects, num_pattrs = 0; i > 0; i --, e… in do_monitor_printer_state()
984 if (!strcmp(expect->name, pattrs[j])) in do_monitor_printer_state()
989 pattrs[num_pattrs ++] = expect->name; in do_monitor_printer_state()
993 …ippAddStrings(request, IPP_TAG_OPERATION, IPP_CONST_TAG(IPP_TAG_KEYWORD), "requested-attributes", … in do_monitor_printer_state()
996 while (!data->monitor_done && !Cancel) in do_monitor_printer_state()
1007 …if (!data->monitor_done && !Cancel && status == HTTP_STATUS_ERROR && httpError(data->http) != EINV… in do_monitor_printer_state()
1009 httpError(data->http) != WSAETIMEDOUT) in do_monitor_printer_state()
1011 httpError(data->http) != ETIMEDOUT) in do_monitor_printer_state()
1031 for (i = data->num_monitor_expects, expect = data->monitor_expects; i > 0; i --, expect ++) in do_monitor_printer_state()
1033 if (expect->if_defined && !_ippVarsGet(data->vars, expect->if_defined)) in do_monitor_printer_state()
1036 if (expect->if_not_defined && _ippVarsGet(data->vars, expect->if_not_defined)) in do_monitor_printer_state()
1039 found = ippFindAttribute(response, expect->name, IPP_TAG_ZERO); in do_monitor_printer_state()
1041 if ((found && expect->not_expect) || in do_monitor_printer_state()
1042 (!found && !(expect->not_expect || expect->optional)) || in do_monitor_printer_state()
1044 (expect->in_group && ippGetGroupTag(found) != expect->in_group) || in do_monitor_printer_state()
1045 (expect->with_distinct && !with_distinct_values(NULL, found))) in do_monitor_printer_state()
1047 if (expect->define_no_match) in do_monitor_printer_state()
1049 _ippVarsSet(data->vars, expect->define_no_match, "1"); in do_monitor_printer_state()
1050 data->monitor_done = 1; in do_monitor_printer_state()
1058 …if (found && !with_value(data, NULL, expect->with_value, expect->with_flags, found, buffer, sizeof… in do_monitor_printer_state()
1060 if (expect->define_no_match) in do_monitor_printer_state()
1062 _ippVarsSet(data->vars, expect->define_no_match, "1"); in do_monitor_printer_state()
1063 data->monitor_done = 1; in do_monitor_printer_state()
1068 if (found && expect->count > 0 && ippGetCount(found) != expect->count) in do_monitor_printer_state()
1070 if (expect->define_no_match) in do_monitor_printer_state()
1072 _ippVarsSet(data->vars, expect->define_no_match, "1"); in do_monitor_printer_state()
1073 data->monitor_done = 1; in do_monitor_printer_state()
1078 …if (found && expect->display_match && (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPP… in do_monitor_printer_state()
1079 …cupsFilePrintf(cupsFileStdout(), "CONT]\n\n%s\n\n %-68.68s [", expect->display_match, data->nam… in do_monitor_printer_state()
1081 if (found && expect->define_match) in do_monitor_printer_state()
1083 _ippVarsSet(data->vars, expect->define_match, "1"); in do_monitor_printer_state()
1084 data->monitor_done = 1; in do_monitor_printer_state()
1087 if (found && expect->define_value) in do_monitor_printer_state()
1089 if (!expect->with_value) in do_monitor_printer_state()
1091 int last = ippGetCount(found) - 1; in do_monitor_printer_state()
1127 _ippVarsSet(data->vars, expect->define_value, buffer); in do_monitor_printer_state()
1128 data->monitor_done = 1; in do_monitor_printer_state()
1133 data->monitor_done = 1; // All tests passed in do_monitor_printer_state()
1139 if (data->monitor_done || Cancel) in do_monitor_printer_state()
1142 usleep(data->monitor_interval); in do_monitor_printer_state()
1155 * 'do_test()' - Do a single test from the test file.
1158 static int /* O - 1 on success, 0 on failure */
1159 do_test(_ipp_file_t *f, /* I - IPP data file */ in do_test()
1160 ipptool_test_t *data) /* I - Test data */ in do_test()
1191 if (data->pause[0]) in do_test()
1193 if (!data->skip_test && !data->pass_test) in do_test()
1194 pause_message(data->pause); in do_test()
1196 data->pause[0] = '\0'; in do_test()
1203 if (data->monitor_uri) in do_test()
1205 data->monitor_done = 0; in do_test()
1206 data->monitor_thread = _cupsThreadCreate((_cups_thread_func_t)do_monitor_printer_state, data); in do_test()
1213 request = f->attrs; in do_test()
1214 f->attrs = NULL; in do_test()
1220 data->test_count ++; in do_test()
1222 ippSetVersion(request, data->version / 10, data->version % 10); in do_test()
1223 ippSetRequestId(request, data->request_id); in do_test()
1225 if (data->output == IPPTOOL_OUTPUT_PLIST) in do_test()
1227 cupsFilePuts(data->outfile, "<dict>\n"); in do_test()
1228 cupsFilePuts(data->outfile, "<key>Name</key>\n"); in do_test()
1229 print_xml_string(data->outfile, "string", data->name); in do_test()
1230 if (data->file_id[0]) in do_test()
1232 cupsFilePuts(data->outfile, "<key>FileId</key>\n"); in do_test()
1233 print_xml_string(data->outfile, "string", data->file_id); in do_test()
1235 if (data->test_id[0]) in do_test()
1237 cupsFilePuts(data->outfile, "<key>TestId</key>\n"); in do_test()
1238 print_xml_string(data->outfile, "string", data->test_id); in do_test()
1240 cupsFilePuts(data->outfile, "<key>Version</key>\n"); in do_test()
1241 … cupsFilePrintf(data->outfile, "<string>%d.%d</string>\n", data->version / 10, data->version % 10); in do_test()
1242 cupsFilePuts(data->outfile, "<key>Operation</key>\n"); in do_test()
1243 print_xml_string(data->outfile, "string", ippOpString(ippGetOperation(request))); in do_test()
1244 cupsFilePuts(data->outfile, "<key>RequestId</key>\n"); in do_test()
1245 cupsFilePrintf(data->outfile, "<integer>%d</integer>\n", data->request_id); in do_test()
1246 cupsFilePuts(data->outfile, "<key>RequestAttributes</key>\n"); in do_test()
1247 cupsFilePuts(data->outfile, "<array>\n"); in do_test()
1250 cupsFilePuts(data->outfile, "<dict>\n"); in do_test()
1252 print_attr(data->outfile, data->output, attrptr, &group); in do_test()
1253 cupsFilePuts(data->outfile, "</dict>\n"); in do_test()
1255 cupsFilePuts(data->outfile, "</array>\n"); in do_test()
1258 …if (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPPTOOL_OUTPUT_PLIST && data->outfile … in do_test()
1260 if (data->verbosity) in do_test()
1268 cupsFilePrintf(cupsFileStdout(), " %-68.68s [", data->name); in do_test()
1271 if ((data->skip_previous && !data->prev_pass) || data->skip_test || data->pass_test) in do_test()
1273 if (!data->pass_test) in do_test()
1274 data->skip_count ++; in do_test()
1280 if (data->output == IPPTOOL_OUTPUT_PLIST) in do_test()
1282 cupsFilePuts(data->outfile, "<key>Successful</key>\n"); in do_test()
1283 cupsFilePuts(data->outfile, "<true />\n"); in do_test()
1284 cupsFilePuts(data->outfile, "<key>Skipped</key>\n"); in do_test()
1285 if (data->pass_test) in do_test()
1286 cupsFilePuts(data->outfile, "<false />\n"); in do_test()
1288 cupsFilePuts(data->outfile, "<true />\n"); in do_test()
1289 cupsFilePuts(data->outfile, "<key>StatusCode</key>\n"); in do_test()
1290 if (data->pass_test) in do_test()
1291 print_xml_string(data->outfile, "string", "pass"); in do_test()
1293 print_xml_string(data->outfile, "string", "skip"); in do_test()
1294 cupsFilePuts(data->outfile, "<key>ResponseAttributes</key>\n"); in do_test()
1295 cupsFilePuts(data->outfile, "<dict />\n"); in do_test()
1298 …if (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPPTOOL_OUTPUT_PLIST && data->outfile … in do_test()
1300 if (data->pass_test) in do_test()
1309 data->vars->password_tries = 0; in do_test()
1313 if (data->delay > 0) in do_test()
1314 usleep(data->delay); in do_test()
1316 data->delay = data->repeat_interval; in do_test()
1321 …if (data->transfer == IPPTOOL_TRANSFER_CHUNKED || (data->transfer == IPPTOOL_TRANSFER_AUTO && data… in do_test()
1324 * Send request using chunking - a 0 length means "chunk". in do_test()
1337 if (data->file[0] && (reqfile = cupsFileOpen(data->file, "r")) != NULL) in do_test()
1354 data->prev_pass = 1; in do_test()
1360 while (!response && !Cancel && data->prev_pass) in do_test()
1362 ippSetRequestId(request, ++ data->request_id); in do_test()
1364 status = cupsSendRequest(data->http, request, data->resource, length); in do_test()
1367 if (data->compression[0]) in do_test()
1368 httpSetField(data->http, HTTP_FIELD_CONTENT_ENCODING, data->compression); in do_test()
1371 if (!Cancel && status == HTTP_STATUS_CONTINUE && ippGetState(request) == IPP_DATA && data->file[0]) in do_test()
1373 if ((reqfile = cupsFileOpen(data->file, "r")) != NULL) in do_test()
1377 … if ((status = cupsWriteRequestData(data->http, buffer, (size_t)bytes)) != HTTP_STATUS_CONTINUE) in do_test()
1385 snprintf(buffer, sizeof(buffer), "%s: %s", data->file, strerror(errno)); in do_test()
1398 response = cupsGetResponse(data->http, data->resource); in do_test()
1399 status = httpGetStatus(data->http); in do_test()
1402 if (!Cancel && status == HTTP_STATUS_ERROR && httpError(data->http) != EINVAL && in do_test()
1404 httpError(data->http) != WSAETIMEDOUT) in do_test()
1406 httpError(data->http) != ETIMEDOUT) in do_test()
1409 if (httpReconnect2(data->http, 30000, NULL)) in do_test()
1410 data->prev_pass = 0; in do_test()
1414 data->prev_pass = 0; in do_test()
1419 httpFlush(data->http); in do_test()
1429 if (!Cancel && status == HTTP_STATUS_ERROR && httpError(data->http) != EINVAL && in do_test()
1431 httpError(data->http) != WSAETIMEDOUT) in do_test()
1433 httpError(data->http) != ETIMEDOUT) in do_test()
1436 if (httpReconnect2(data->http, 30000, NULL)) in do_test()
1437 data->prev_pass = 0; in do_test()
1442 httpReconnect2(data->http, 30000, NULL); in do_test()
1444 data->prev_pass = 0; in do_test()
1448 httpFlush(data->http); in do_test()
1449 data->prev_pass = 0; in do_test()
1456 cupsArrayClear(data->errors); in do_test()
1458 if (httpGetVersion(data->http) != HTTP_1_1) in do_test()
1460 int version = (int)httpGetVersion(data->http); in do_test()
1462 add_stringf(data->errors, "Bad HTTP version (%d.%d)", version / 100, version % 100); in do_test()
1465 if (data->validate_headers) in do_test()
1469 …if ((header = httpGetField(data->http, HTTP_FIELD_CONTENT_TYPE)) == NULL || _cups_strcasecmp(heade… in do_test()
1470 …add_stringf(data->errors, "Bad HTTP Content-Type in response (%s)", header && *header ? header : "… in do_test()
1472 …if ((header = httpGetField(data->http, HTTP_FIELD_DATE)) != NULL && *header && httpGetDateTime(hea… in do_test()
1473 add_stringf(data->errors, "Bad HTTP Date in response (%s)", header); in do_test()
1482 …add_stringf(data->errors, "IPP request failed with status %s (%s)", ippErrorString(cupsLastError()… in do_test()
1490 if ((attrptr = ippFindAttribute(response, "job-id", IPP_TAG_INTEGER)) != NULL) in do_test()
1493 _ippVarsSet(data->vars, "job-id", temp); in do_test()
1496 if ((attrptr = ippFindAttribute(response, "job-uri", IPP_TAG_URI)) != NULL) in do_test()
1497 _ippVarsSet(data->vars, "job-uri", ippGetString(attrptr, 0, NULL)); in do_test()
1499 if ((attrptr = ippFindAttribute(response, "notify-subscription-id", IPP_TAG_INTEGER)) != NULL) in do_test()
1502 _ippVarsSet(data->vars, "notify-subscription-id", temp); in do_test()
1511 add_stringf(data->errors, "Missing end-of-attributes-tag in response (RFC 2910 section 3.5.1)"); in do_test()
1513 if (data->version) in do_test()
1519 if (major != (data->version / 10) || minor != (data->version % 10)) in do_test()
1520 …d_stringf(data->errors, "Bad version %d.%d in response - expected %d.%d (RFC 8011 section 4.1.8)."… in do_test()
1523 if (ippGetRequestId(response) != data->request_id) in do_test()
1524 …add_stringf(data->errors, "Bad request ID %d in response - expected %d (RFC 8011 section 4.1.1)", … in do_test()
1529 …add_stringf(data->errors, "Missing first attribute \"attributes-charset (charset)\" in group opera… in do_test()
1533 …IPP_TAG_OPERATION || ippGetCount(attrptr) != 1 ||strcmp(ippGetName(attrptr), "attributes-charset")) in do_test()
1534 …tringf(data->errors, "Bad first attribute \"%s (%s%s)\" in group %s, expected \"attributes-charset… in do_test()
1538 …add_stringf(data->errors, "Missing second attribute \"attributes-natural-language (naturalLanguage… in do_test()
1539 …ERATION || ippGetCount(attrptr) != 1 || strcmp(ippGetName(attrptr), "attributes-natural-language")) in do_test()
1540 …ata->errors, "Bad first attribute \"%s (%s%s)\" in group %s, expected \"attributes-natural-languag… in do_test()
1543 if ((attrptr = ippFindAttribute(response, "status-message", IPP_TAG_ZERO)) != NULL) in do_test()
1549 …add_stringf(data->errors, "status-message (text(255)) has wrong value tag %s (RFC 8011 section 4.1… in do_test()
1551 …add_stringf(data->errors, "status-message (text(255)) has wrong group tag %s (RFC 8011 section 4.1… in do_test()
1553 …add_stringf(data->errors, "status-message (text(255)) has %d values (RFC 8011 section 4.1.6.2).", … in do_test()
1555 …add_stringf(data->errors, "status-message (text(255)) has bad length %d (RFC 8011 section 4.1.6.2)… in do_test()
1558 if ((attrptr = ippFindAttribute(response, "detailed-status-message", in do_test()
1565 …add_stringf(data->errors, "detailed-status-message (text(MAX)) has wrong value tag %s (RFC 8011 se… in do_test()
1567 …add_stringf(data->errors, "detailed-status-message (text(MAX)) has wrong group tag %s (RFC 8011 se… in do_test()
1569 …add_stringf(data->errors, "detailed-status-message (text(MAX)) has %d values (RFC 8011 section 4.1… in do_test()
1571 …add_stringf(data->errors, "detailed-status-message (text(MAX)) has bad length %d (RFC 8011 section… in do_test()
1582 int out_of_order = 0; /* Are attribute groups out-of-order? */ in do_test()
1617 …add_stringf(data->errors, "Attribute groups out of order (%s < %s)", ippTagString(ippGetGroupTag(a… in do_test()
1624 cupsArrayAdd(data->errors, (void *)cupsLastErrorString()); in do_test()
1628 if (cupsArrayFind(a, (void *)ippGetName(attrptr)) && data->output < IPPTOOL_OUTPUT_LIST) in do_test()
1629 …add_stringf(data->errors, "Duplicate \"%s\" attribute in %s group", ippGetName(attrptr), ippTagStr… in do_test()
1638 * Now check the test-defined expected status-code and attribute in do_test()
1642 if (ippGetStatusCode(response) == IPP_STATUS_ERROR_BUSY && data->repeat_on_busy) in do_test()
1644 // Repeat on a server-error-busy status code... in do_test()
1649 for (i = 0, status_ok = 0; i < data->num_statuses; i ++) in do_test()
1651 if (data->statuses[i].if_defined && in do_test()
1652 !_ippVarsGet(data->vars, data->statuses[i].if_defined)) in do_test()
1655 if (data->statuses[i].if_not_defined && in do_test()
1656 _ippVarsGet(data->vars, data->statuses[i].if_not_defined)) in do_test()
1659 if (ippGetStatusCode(response) == data->statuses[i].status) in do_test()
1663 if (data->statuses[i].repeat_match && repeat_count < data->statuses[i].repeat_limit) in do_test()
1666 if (data->statuses[i].define_match) in do_test()
1667 _ippVarsSet(data->vars, data->statuses[i].define_match, "1"); in do_test()
1671 if (data->statuses[i].repeat_no_match && repeat_count < data->statuses[i].repeat_limit) in do_test()
1674 if (data->statuses[i].define_no_match) in do_test()
1676 _ippVarsSet(data->vars, data->statuses[i].define_no_match, "1"); in do_test()
1682 if (!status_ok && data->num_statuses > 0) in do_test()
1684 for (i = 0; i < data->num_statuses; i ++) in do_test()
1686 if (data->statuses[i].if_defined && in do_test()
1687 !_ippVarsGet(data->vars, data->statuses[i].if_defined)) in do_test()
1690 if (data->statuses[i].if_not_defined && in do_test()
1691 _ippVarsGet(data->vars, data->statuses[i].if_not_defined)) in do_test()
1694 if (!data->statuses[i].repeat_match || repeat_count >= data->statuses[i].repeat_limit) in do_test()
1695 …add_stringf(data->errors, "EXPECTED: STATUS %s (got %s)", ippErrorString(data->statuses[i].status)… in do_test()
1698 if ((attrptr = ippFindAttribute(response, "status-message", IPP_TAG_TEXT)) != NULL) in do_test()
1699 add_stringf(data->errors, "status-message=\"%s\"", ippGetString(attrptr, 0, NULL)); in do_test()
1702 for (i = data->num_expects, expect = data->expects; i > 0; i --, expect ++) in do_test()
1706 if (expect->if_defined && !_ippVarsGet(data->vars, expect->if_defined)) in do_test()
1709 if (expect->if_not_defined && in do_test()
1710 _ippVarsGet(data->vars, expect->if_not_defined)) in do_test()
1713 …if ((found = ippFindAttribute(response, expect->name, IPP_TAG_ZERO)) != NULL && expect->in_group &… in do_test()
1715 while ((found = ippFindNextAttribute(response, expect->name, IPP_TAG_ZERO)) != NULL) in do_test()
1716 if (expect->in_group == ippGetGroupTag(found)) in do_test()
1724 if (expect->in_group && strchr(expect->name, '/')) in do_test()
1729 strlcpy(group_name, expect->name, sizeof(group_name)); in do_test()
1736 if ((found && expect->not_expect) || in do_test()
1737 (!found && !(expect->not_expect || expect->optional)) || in do_test()
1739 (group_found && expect->in_group && ippGetGroupTag(group_found) != expect->in_group) || in do_test()
1740 (expect->with_distinct && !with_distinct_values(NULL, found))) in do_test()
1742 if (expect->define_no_match) in do_test()
1743 _ippVarsSet(data->vars, expect->define_no_match, "1"); in do_test()
1744 else if (!expect->define_match && !expect->define_value) in do_test()
1746 if (found && expect->not_expect && !expect->with_value && !expect->with_value_from) in do_test()
1747 add_stringf(data->errors, "NOT EXPECTED: %s", expect->name); in do_test()
1748 else if (!found && !(expect->not_expect || expect->optional)) in do_test()
1749 add_stringf(data->errors, "EXPECTED: %s", expect->name); in do_test()
1753 add_stringf(data->errors, "EXPECTED: %s OF-TYPE %s (got %s)", in do_test()
1754 expect->name, expect->of_type, in do_test()
1757 if (expect->in_group && ippGetGroupTag(group_found) != expect->in_group) in do_test()
1758 add_stringf(data->errors, "EXPECTED: %s IN-GROUP %s (got %s).", in do_test()
1759 expect->name, ippTagString(expect->in_group), in do_test()
1762 if (expect->with_distinct) in do_test()
1763 with_distinct_values(data->errors, found); in do_test()
1767 if (expect->repeat_no_match && repeat_count < expect->repeat_limit) in do_test()
1775 …if (found && expect->with_value_from && !with_value_from(NULL, ippFindAttribute(response, expect->… in do_test()
1777 if (expect->define_no_match) in do_test()
1778 _ippVarsSet(data->vars, expect->define_no_match, "1"); in do_test()
1779 …lse if (!expect->define_match && !expect->define_value && ((!expect->repeat_match && !expect->repe… in do_test()
1781 …add_stringf(data->errors, "EXPECTED: %s WITH-VALUES-FROM %s", expect->name, expect->with_value_fro… in do_test()
1783 …with_value_from(data->errors, ippFindAttribute(response, expect->with_value_from, IPP_TAG_ZERO), f… in do_test()
1786 if (expect->repeat_no_match && repeat_count < expect->repeat_limit) in do_test()
1791 …else if (found && !with_value(data, NULL, expect->with_value, expect->with_flags, found, buffer, s… in do_test()
1793 if (expect->define_no_match) in do_test()
1794 _ippVarsSet(data->vars, expect->define_no_match, "1"); in do_test()
1795 else if (!expect->define_match && !expect->define_value && in do_test()
1796 !expect->repeat_match && (!expect->repeat_no_match || repeat_count >= expect->repeat_limit)) in do_test()
1798 if (expect->with_flags & IPPTOOL_WITH_REGEX) in do_test()
1799 …add_stringf(data->errors, "EXPECTED: %s %s /%s/", expect->name, with_flags_string(expect->with_fla… in do_test()
1801 …add_stringf(data->errors, "EXPECTED: %s %s \"%s\"", expect->name, with_flags_string(expect->with_f… in do_test()
1803 …with_value(data, data->errors, expect->with_value, expect->with_flags, found, buffer, sizeof(buffe… in do_test()
1806 if (expect->repeat_no_match && in do_test()
1807 repeat_count < expect->repeat_limit) in do_test()
1813 if (found && expect->count > 0 && ippGetCount(found) != expect->count) in do_test()
1815 if (expect->define_no_match) in do_test()
1816 _ippVarsSet(data->vars, expect->define_no_match, "1"); in do_test()
1817 else if (!expect->define_match && !expect->define_value) in do_test()
1819 …add_stringf(data->errors, "EXPECTED: %s COUNT %d (got %d)", expect->name, expect->count, ippGetCou… in do_test()
1822 if (expect->repeat_no_match && in do_test()
1823 repeat_count < expect->repeat_limit) in do_test()
1829 if (found && expect->same_count_as) in do_test()
1831 attrptr = ippFindAttribute(response, expect->same_count_as, in do_test()
1836 if (expect->define_no_match) in do_test()
1837 _ippVarsSet(data->vars, expect->define_no_match, "1"); in do_test()
1838 else if (!expect->define_match && !expect->define_value) in do_test()
1841 …add_stringf(data->errors, "EXPECTED: %s (%d values) SAME-COUNT-AS %s (not returned)", expect->name… in do_test()
1843 …add_stringf(data->errors, "EXPECTED: %s (%d values) SAME-COUNT-AS %s (%d values)", expect->name, i… in do_test()
1846 if (expect->repeat_no_match && in do_test()
1847 repeat_count < expect->repeat_limit) in do_test()
1854 …if (found && expect->display_match && (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPP… in do_test()
1855 cupsFilePrintf(cupsFileStdout(), "\n%s\n\n", expect->display_match); in do_test()
1857 if (found && expect->define_match) in do_test()
1858 _ippVarsSet(data->vars, expect->define_match, "1"); in do_test()
1860 if (found && expect->define_value) in do_test()
1862 if (!expect->with_value) in do_test()
1864 int last = ippGetCount(found) - 1; in do_test()
1915 _ippVarsSet(data->vars, expect->define_value, buffer); in do_test()
1918 if (found && expect->repeat_match && in do_test()
1919 repeat_count < expect->repeat_limit) in do_test()
1922 …while (expect->expect_all && (found = ippFindNextAttribute(response, expect->name, IPP_TAG_ZERO)) … in do_test()
1932 …if (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPPTOOL_OUTPUT_PLIST && data->outfile … in do_test()
1936 if (data->num_displayed > 0) in do_test()
1943 for (i = 0; i < data->num_displayed; i ++) in do_test()
1945 if (!strcmp(data->displayed[i], attrname)) in do_test()
1956 …if (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPPTOOL_OUTPUT_PLIST && data->outfile … in do_test()
1958 cupsFilePrintf(cupsFileStdout(), " %-68.68s [", data->name); in do_test()
1971 if (cupsArrayCount(data->errors) > 0) in do_test()
1972 data->prev_pass = data->pass = 0; in do_test()
1974 if (data->prev_pass) in do_test()
1975 data->pass_count ++; in do_test()
1977 data->fail_count ++; in do_test()
1979 if (data->output == IPPTOOL_OUTPUT_PLIST) in do_test()
1981 cupsFilePuts(data->outfile, "<key>Successful</key>\n"); in do_test()
1982 cupsFilePuts(data->outfile, data->prev_pass ? "<true />\n" : "<false />\n"); in do_test()
1983 cupsFilePuts(data->outfile, "<key>StatusCode</key>\n"); in do_test()
1984 print_xml_string(data->outfile, "string", ippErrorString(cupsLastError())); in do_test()
1985 cupsFilePuts(data->outfile, "<key>ResponseAttributes</key>\n"); in do_test()
1986 cupsFilePuts(data->outfile, "<array>\n"); in do_test()
1987 cupsFilePuts(data->outfile, "<dict>\n"); in do_test()
1991 print_attr(data->outfile, data->output, attrptr, &group); in do_test()
1992 cupsFilePuts(data->outfile, "</dict>\n"); in do_test()
1993 cupsFilePuts(data->outfile, "</array>\n"); in do_test()
1995 else if (data->output == IPPTOOL_OUTPUT_IPPSERVER && response) in do_test()
2006 …if (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPPTOOL_OUTPUT_PLIST && data->outfile … in do_test()
2008 cupsFilePuts(cupsFileStdout(), data->prev_pass ? "PASS]\n" : "FAIL]\n"); in do_test()
2010 if (!data->prev_pass || (data->verbosity && response)) in do_test()
2013 …cupsFilePrintf(cupsFileStdout(), " status-code = %s (%s)\n", ippErrorString(cupsLastError()… in do_test()
2015 if (data->verbosity && response) in do_test()
2022 else if (!data->prev_pass && data->output != IPPTOOL_OUTPUT_QUIET) in do_test()
2025 …if (data->prev_pass && data->output >= IPPTOOL_OUTPUT_LIST && !data->verbosity && data->num_displa… in do_test()
2029 for (i = 0; i < data->num_displayed; i ++) in do_test()
2031 widths[i] = strlen(data->displayed[i]); in do_test()
2033 for (attrptr = ippFindAttribute(response, data->displayed[i], IPP_TAG_ZERO); in do_test()
2035 attrptr = ippFindNextAttribute(response, data->displayed[i], IPP_TAG_ZERO)) in do_test()
2043 if (data->output == IPPTOOL_OUTPUT_CSV) in do_test()
2044 print_csv(data, NULL, NULL, data->num_displayed, data->displayed, widths); in do_test()
2046 print_line(data, NULL, NULL, data->num_displayed, data->displayed, widths); in do_test()
2057 if (data->output == IPPTOOL_OUTPUT_CSV) in do_test()
2058 attrptr = print_csv(data, response, attrptr, data->num_displayed, data->displayed, widths); in do_test()
2060 attrptr = print_line(data, response, attrptr, data->num_displayed, data->displayed, widths); in do_test()
2067 else if (!data->prev_pass) in do_test()
2069 if (data->output == IPPTOOL_OUTPUT_PLIST) in do_test()
2071 cupsFilePuts(data->outfile, "<key>Errors</key>\n"); in do_test()
2072 cupsFilePuts(data->outfile, "<array>\n"); in do_test()
2074 for (error = (char *)cupsArrayFirst(data->errors); in do_test()
2076 error = (char *)cupsArrayNext(data->errors)) in do_test()
2077 print_xml_string(data->outfile, "string", error); in do_test()
2079 cupsFilePuts(data->outfile, "</array>\n"); in do_test()
2082 …if (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPPTOOL_OUTPUT_PLIST && data->outfile … in do_test()
2084 for (error = (char *)cupsArrayFirst(data->errors); in do_test()
2086 error = (char *)cupsArrayNext(data->errors)) in do_test()
2091 … (data->num_displayed > 0 && !data->verbosity && response && (data->output == IPPTOOL_OUTPUT_TEST … in do_test()
2097 for (i = 0; i < data->num_displayed; i ++) in do_test()
2099 if (!strcmp(data->displayed[i], ippGetName(attrptr))) in do_test()
2101 print_attr(data->outfile, data->output, attrptr, NULL); in do_test()
2111 if (data->monitor_thread) in do_test()
2113 data->monitor_done = 1; in do_test()
2114 _cupsThreadWait(data->monitor_thread); in do_test()
2117 if (data->output == IPPTOOL_OUTPUT_PLIST) in do_test()
2118 cupsFilePuts(data->outfile, "</dict>\n"); in do_test()
2123 for (i = 0; i < data->num_statuses; i ++) in do_test()
2125 free(data->statuses[i].if_defined); in do_test()
2126 free(data->statuses[i].if_not_defined); in do_test()
2127 free(data->statuses[i].define_match); in do_test()
2128 free(data->statuses[i].define_no_match); in do_test()
2130 data->num_statuses = 0; in do_test()
2132 for (i = data->num_expects, expect = data->expects; i > 0; i --, expect ++) in do_test()
2134 free(expect->name); in do_test()
2135 free(expect->of_type); in do_test()
2136 free(expect->same_count_as); in do_test()
2137 free(expect->if_defined); in do_test()
2138 free(expect->if_not_defined); in do_test()
2139 free(expect->with_value); in do_test()
2140 free(expect->define_match); in do_test()
2141 free(expect->define_no_match); in do_test()
2142 free(expect->define_value); in do_test()
2143 free(expect->display_match); in do_test()
2145 data->num_expects = 0; in do_test()
2147 for (i = 0; i < data->num_displayed; i ++) in do_test()
2148 free(data->displayed[i]); in do_test()
2149 data->num_displayed = 0; in do_test()
2151 free(data->monitor_uri); in do_test()
2152 data->monitor_uri = NULL; in do_test()
2154 for (i = data->num_monitor_expects, expect = data->monitor_expects; i > 0; i --, expect ++) in do_test()
2156 free(expect->name); in do_test()
2157 free(expect->of_type); in do_test()
2158 free(expect->same_count_as); in do_test()
2159 free(expect->if_defined); in do_test()
2160 free(expect->if_not_defined); in do_test()
2161 free(expect->with_value); in do_test()
2162 free(expect->define_match); in do_test()
2163 free(expect->define_no_match); in do_test()
2164 free(expect->define_value); in do_test()
2165 free(expect->display_match); in do_test()
2167 data->num_monitor_expects = 0; in do_test()
2169 return (data->ignore_errors || data->prev_pass); in do_test()
2174 * 'do_tests()' - Do tests as specified in the test file.
2177 static int /* O - 1 on success, 0 on failure */
2178 do_tests(const char *testfile, /* I - Test file to use */ in do_tests()
2179 ipptool_test_t *data) /* I - Test data */ in do_tests()
2188 …if (!_cups_strcasecmp(data->vars->scheme, "https") || !_cups_strcasecmp(data->vars->scheme, "ipps"… in do_tests()
2191 encryption = data->encryption; in do_tests()
2193 …if ((data->http = httpConnect2(data->vars->host, data->vars->port, NULL, data->family, encryption,… in do_tests()
2195 …fatal_error(data, "Unable to connect to \"%s\" on port %d - %s", data->vars->host, data->vars->por… in do_tests()
2200 httpSetDefaultField(data->http, HTTP_FIELD_ACCEPT_ENCODING, "deflate, gzip, identity"); in do_tests()
2202 httpSetDefaultField(data->http, HTTP_FIELD_ACCEPT_ENCODING, "identity"); in do_tests()
2205 if (data->timeout > 0.0) in do_tests()
2206 httpSetTimeout(data->http, data->timeout, timeout_cb, NULL); in do_tests()
2212 _ippFileParse(data->vars, testfile, (void *)data); in do_tests()
2218 httpClose(data->http); in do_tests()
2219 data->http = NULL; in do_tests()
2221 return (data->pass); in do_tests()
2226 * 'error_cb()' - Print/add an error message.
2229 static int /* O - 1 to continue, 0 to stop */
2230 error_cb(_ipp_file_t *f, /* I - IPP file data */ in error_cb()
2231 ipptool_test_t *data, /* I - Test data */ in error_cb()
2232 const char *error) /* I - Error message */ in error_cb()
2243 * 'expect_matches()' - Return true if the tag matches the specification.
2246 static int /* O - 1 if matches, 0 otherwise */
2248 ipptool_expect_t *expect, /* I - Expected attribute */ in expect_matches()
2249 ipp_attribute_t *attr) /* I - Attribute */ in expect_matches()
2253 match; /* Match? */ in expect_matches() local
2254 char *of_type, /* Type name to match */ in expect_matches()
2256 *next, /* Next name to match */ in expect_matches()
2266 if (!expect->of_type) in expect_matches()
2277 for (of_type = expect->of_type, match = 0; !match && *of_type; of_type = next) in expect_matches()
2289 * Support some meta-types to make it easier to write the test file. in expect_matches()
2337 match = (i == count); in expect_matches()
2353 match = (i == count); in expect_matches()
2358 match = value_tag == IPP_TAG_BEGIN_COLLECTION; in expect_matches()
2380 match = (i == count); in expect_matches()
2397 match = (i == count); in expect_matches()
2410 match = (i == count); in expect_matches()
2423 match = (i == count); in expect_matches()
2427 // No other constraints, so this is a match in expect_matches()
2428 match = 1; in expect_matches()
2444 return (match); in expect_matches()
2449 * 'get_filename()' - Get a filename based on the current test file.
2452 static char * /* O - Filename */
2453 get_filename(const char *testfile, /* I - Current test file */ in get_filename()
2454 char *dst, /* I - Destination filename */ in get_filename()
2455 const char *src, /* I - Source filename */ in get_filename()
2456 size_t dstsize) /* I - Size of destination buffer */ in get_filename()
2463 if (*src == '<' && src[strlen(src) - 1] == '>') in get_filename()
2466 * Map <filename> to CUPS_DATADIR/ipptool/filename... in get_filename()
2469 snprintf(dst, dstsize, "%s/ipptool/%s", cg->cups_datadir, src + 1); in get_filename()
2470 dstptr = dst + strlen(dst) - 1; in get_filename()
2481 * Use the path as-is... in get_filename()
2498 strlcpy(dstptr, src, dstsize - (size_t)(dstptr - dst)); in get_filename()
2521 * 'get_string()' - Get a pointer to a string value or the portion of interest.
2524 static const char * /* O - Pointer to string */
2525 get_string(ipp_attribute_t *attr, /* I - IPP attribute */ in get_string()
2526 int element, /* I - Element to fetch */ in get_string()
2527 int flags, /* I - Value ("with") flags */ in get_string()
2528 char *buffer, /* I - Temporary buffer */ in get_string()
2529 size_t bufsize) /* I - Size of temporary buffer */ in get_string()
2547 ptr = buffer + strlen(buffer) - 1; in get_string()
2585 if ((ptr = hostname + strlen(hostname) - 1) >= hostname && *ptr == '.') in get_string()
2599 * 'init_data()' - Initialize test data.
2603 init_data(ipptool_test_t *data) /* I - Data */ in init_data()
2607 data->output = IPPTOOL_OUTPUT_LIST; in init_data()
2608 data->outfile = cupsFileStdout(); in init_data()
2609 data->family = AF_UNSPEC; in init_data()
2610 data->def_transfer = IPPTOOL_TRANSFER_AUTO; in init_data()
2611 data->def_version = 11; in init_data()
2612 …data->errors = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_fun… in init_data()
2613 data->pass = 1; in init_data()
2614 data->prev_pass = 1; in init_data()
2615 data->request_id = (CUPS_RAND() % 1000) * 137; in init_data()
2616 data->show_header = 1; in init_data()
2621 * 'iso_date()' - Return an ISO 8601 date/time string for the given IPP dateTime
2625 static char * /* O - ISO 8601 date/time string */
2626 iso_date(const ipp_uchar_t *date) /* I - IPP (RFC 1903) date/time value */ in iso_date()
2636 snprintf(buffer, sizeof(buffer), "%04d-%02d-%02dT%02d:%02d:%02dZ", in iso_date()
2645 * 'parse_monitor_printer_state()' - Parse the MONITOR-PRINTER-STATE directive.
2647 * MONITOR-PRINTER-STATE [printer-uri] {
2649 * EXPECT attribute-name ...
2653 static int /* O - 1 to continue, 0 to stop */
2655 _ipp_file_t *f, /* I - IPP file data */ in parse_monitor_printer_state()
2656 ipptool_test_t *data) /* I - Test data */ in parse_monitor_printer_state()
2667 print_fatal_error(data, "Missing printer URI on line %d of \"%s\".", f->linenum, f->filename); in parse_monitor_printer_state()
2674 _ippVarsExpand(data->vars, value, temp, sizeof(value)); in parse_monitor_printer_state()
2675 data->monitor_uri = strdup(value); in parse_monitor_printer_state()
2680 … print_fatal_error(data, "Missing opening brace on line %d of \"%s\".", f->linenum, f->filename); in parse_monitor_printer_state()
2687 data->monitor_uri = strdup(data->vars->uri); in parse_monitor_printer_state()
2694 _cups_strcasecmp(token, "DEFINE-MATCH") && in parse_monitor_printer_state()
2695 _cups_strcasecmp(token, "DEFINE-NO-MATCH") && in parse_monitor_printer_state()
2696 _cups_strcasecmp(token, "DEFINE-VALUE") && in parse_monitor_printer_state()
2697 _cups_strcasecmp(token, "DISPLAY-MATCH") && in parse_monitor_printer_state()
2698 _cups_strcasecmp(token, "IF-DEFINED") && in parse_monitor_printer_state()
2699 _cups_strcasecmp(token, "IF-NOT-DEFINED") && in parse_monitor_printer_state()
2700 _cups_strcasecmp(token, "IN-GROUP") && in parse_monitor_printer_state()
2701 _cups_strcasecmp(token, "OF-TYPE") && in parse_monitor_printer_state()
2702 _cups_strcasecmp(token, "WITH-DISTINCT-VALUES") && in parse_monitor_printer_state()
2703 _cups_strcasecmp(token, "WITH-VALUE")) in parse_monitor_printer_state()
2704 data->last_expect = NULL; in parse_monitor_printer_state()
2714 …if (data->num_monitor_expects >= (int)(sizeof(data->monitor_expects) / sizeof(data->monitor_expect… in parse_monitor_printer_state()
2716 print_fatal_error(data, "Too many EXPECT's on line %d of \"%s\".", f->linenum, f->filename); in parse_monitor_printer_state()
2722 print_fatal_error(data, "Missing EXPECT name on line %d of \"%s\".", f->linenum, f->filename); in parse_monitor_printer_state()
2726 data->last_expect = data->monitor_expects + data->num_monitor_expects; in parse_monitor_printer_state()
2727 data->num_monitor_expects ++; in parse_monitor_printer_state()
2729 memset(data->last_expect, 0, sizeof(ipptool_expect_t)); in parse_monitor_printer_state()
2730 data->last_expect->repeat_limit = 1000; in parse_monitor_printer_state()
2734 data->last_expect->not_expect = 1; in parse_monitor_printer_state()
2735 data->last_expect->name = strdup(name + 1); in parse_monitor_printer_state()
2739 data->last_expect->optional = 1; in parse_monitor_printer_state()
2740 data->last_expect->name = strdup(name + 1); in parse_monitor_printer_state()
2743 data->last_expect->name = strdup(name); in parse_monitor_printer_state()
2751 print_fatal_error(data, "Missing COUNT number on line %d of \"%s\".", f->linenum, f->filename); in parse_monitor_printer_state()
2757 print_fatal_error(data, "Bad COUNT \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename); in parse_monitor_printer_state()
2761 if (data->last_expect) in parse_monitor_printer_state()
2763 data->last_expect->count = count; in parse_monitor_printer_state()
2767 …tal_error(data, "COUNT without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename); in parse_monitor_printer_state()
2771 else if (!_cups_strcasecmp(token, "DEFINE-MATCH")) in parse_monitor_printer_state()
2775 …print_fatal_error(data, "Missing DEFINE-MATCH variable on line %d of \"%s\".", f->linenum, f->file… in parse_monitor_printer_state()
2779 if (data->last_expect) in parse_monitor_printer_state()
2781 data->last_expect->define_match = strdup(temp); in parse_monitor_printer_state()
2785 …print_fatal_error(data, "DEFINE-MATCH without a preceding EXPECT on line %d of \"%s\".", f->linenu… in parse_monitor_printer_state()
2789 else if (!_cups_strcasecmp(token, "DEFINE-NO-MATCH")) in parse_monitor_printer_state()
2793 …print_fatal_error(data, "Missing DEFINE-NO-MATCH variable on line %d of \"%s\".", f->linenum, f->f… in parse_monitor_printer_state()
2797 if (data->last_expect) in parse_monitor_printer_state()
2799 data->last_expect->define_no_match = strdup(temp); in parse_monitor_printer_state()
2803 …print_fatal_error(data, "DEFINE-NO-MATCH without a preceding EXPECT on line %d of \"%s\".", f->lin… in parse_monitor_printer_state()
2807 else if (!_cups_strcasecmp(token, "DEFINE-VALUE")) in parse_monitor_printer_state()
2811 …print_fatal_error(data, "Missing DEFINE-VALUE variable on line %d of \"%s\".", f->linenum, f->file… in parse_monitor_printer_state()
2815 if (data->last_expect) in parse_monitor_printer_state()
2817 data->last_expect->define_value = strdup(temp); in parse_monitor_printer_state()
2821 …print_fatal_error(data, "DEFINE-VALUE without a preceding EXPECT on line %d of \"%s\".", f->linenu… in parse_monitor_printer_state()
2825 else if (!_cups_strcasecmp(token, "DISPLAY-MATCH")) in parse_monitor_printer_state()
2829 …print_fatal_error(data, "Missing DISPLAY-MATCH message on line %d of \"%s\".", f->linenum, f->file… in parse_monitor_printer_state()
2833 if (data->last_expect) in parse_monitor_printer_state()
2835 data->last_expect->display_match = strdup(temp); in parse_monitor_printer_state()
2839 …print_fatal_error(data, "DISPLAY-MATCH without a preceding EXPECT on line %d of \"%s\".", f->linen… in parse_monitor_printer_state()
2853 print_fatal_error(data, "Missing DELAY value on line %d of \"%s\".", f->linenum, f->filename); in parse_monitor_printer_state()
2857 _ippVarsExpand(data->vars, value, temp, sizeof(value)); in parse_monitor_printer_state()
2861 …_fatal_error(data, "Bad DELAY value \"%s\" on line %d of \"%s\".", value, f->linenum, f->filename); in parse_monitor_printer_state()
2865 data->monitor_delay = (useconds_t)(1000000.0 * dval); in parse_monitor_printer_state()
2871 …_fatal_error(data, "Bad DELAY value \"%s\" on line %d of \"%s\".", value, f->linenum, f->filename); in parse_monitor_printer_state()
2875 data->monitor_interval = (useconds_t)(1000000.0 * dval); in parse_monitor_printer_state()
2878 data->monitor_interval = data->monitor_delay; in parse_monitor_printer_state()
2880 else if (!_cups_strcasecmp(token, "OF-TYPE")) in parse_monitor_printer_state()
2884 …print_fatal_error(data, "Missing OF-TYPE value tag(s) on line %d of \"%s\".", f->linenum, f->filen… in parse_monitor_printer_state()
2888 if (data->last_expect) in parse_monitor_printer_state()
2890 data->last_expect->of_type = strdup(temp); in parse_monitor_printer_state()
2894 …print_fatal_error(data, "OF-TYPE without a preceding EXPECT on line %d of \"%s\".", f->linenum, f-… in parse_monitor_printer_state()
2898 else if (!_cups_strcasecmp(token, "IN-GROUP")) in parse_monitor_printer_state()
2900 ipp_tag_t in_group; /* IN-GROUP value */ in parse_monitor_printer_state()
2904 …print_fatal_error(data, "Missing IN-GROUP group tag on line %d of \"%s\".", f->linenum, f->filenam… in parse_monitor_printer_state()
2910 …print_fatal_error(data, "Bad IN-GROUP group tag \"%s\" on line %d of \"%s\".", temp, f->linenum, f… in parse_monitor_printer_state()
2913 else if (data->last_expect) in parse_monitor_printer_state()
2915 data->last_expect->in_group = in_group; in parse_monitor_printer_state()
2919 …print_fatal_error(data, "IN-GROUP without a preceding EXPECT on line %d of \"%s\".", f->linenum, f… in parse_monitor_printer_state()
2923 else if (!_cups_strcasecmp(token, "IF-DEFINED")) in parse_monitor_printer_state()
2927 print_fatal_error(data, "Missing IF-DEFINED name on line %d of \"%s\".", f->linenum, f->filename); in parse_monitor_printer_state()
2931 if (data->last_expect) in parse_monitor_printer_state()
2933 data->last_expect->if_defined = strdup(temp); in parse_monitor_printer_state()
2937 …print_fatal_error(data, "IF-DEFINED without a preceding EXPECT on line %d of \"%s\".", f->linenum,… in parse_monitor_printer_state()
2941 else if (!_cups_strcasecmp(token, "IF-NOT-DEFINED")) in parse_monitor_printer_state()
2945 …print_fatal_error(data, "Missing IF-NOT-DEFINED name on line %d of \"%s\".", f->linenum, f->filena… in parse_monitor_printer_state()
2949 if (data->last_expect) in parse_monitor_printer_state()
2951 data->last_expect->if_not_defined = strdup(temp); in parse_monitor_printer_state()
2955 …print_fatal_error(data, "IF-NOT-DEFINED without a preceding EXPECT on line %d of \"%s\".", f->line… in parse_monitor_printer_state()
2959 else if (!_cups_strcasecmp(token, "WITH-DISTINCT-VALUES")) in parse_monitor_printer_state()
2961 if (data->last_expect) in parse_monitor_printer_state()
2963 data->last_expect->with_distinct = 1; in parse_monitor_printer_state()
2967 …error(data, "%s without a preceding EXPECT on line %d of \"%s\".", token, f->linenum, f->filename); in parse_monitor_printer_state()
2971 else if (!_cups_strcasecmp(token, "WITH-VALUE")) in parse_monitor_printer_state()
2978 print_fatal_error(data, "Missing %s value on line %d of \"%s\".", token, f->linenum, f->filename); in parse_monitor_printer_state()
2983 * Read additional comma-delimited values - needed since legacy test files in parse_monitor_printer_state()
2984 * will have unquoted WITH-VALUE values with commas... in parse_monitor_printer_state()
2991 lastpos = cupsFileTell(f->fp); in parse_monitor_printer_state()
2992 lastline = f->linenum; in parse_monitor_printer_state()
2995 if (!_ippFileReadToken(f, ptr, (sizeof(temp) - (size_t)(ptr - temp)))) in parse_monitor_printer_state()
3006 if (!_ippFileReadToken(f, ptr, (sizeof(temp) - (size_t)(ptr - temp)))) in parse_monitor_printer_state()
3015 cupsFileSeek(f->fp, lastpos); in parse_monitor_printer_state()
3016 f->linenum = lastline; in parse_monitor_printer_state()
3022 if (data->last_expect) in parse_monitor_printer_state()
3028 _ippVarsExpand(data->vars, value, temp, sizeof(value)); in parse_monitor_printer_state()
3030 ptr = value + strlen(value) - 1; in parse_monitor_printer_state()
3035 * WITH-VALUE is a POSIX extended regular expression. in parse_monitor_printer_state()
3038 data->last_expect->with_value = calloc(1, (size_t)(ptr - value)); in parse_monitor_printer_state()
3039 data->last_expect->with_flags |= IPPTOOL_WITH_REGEX; in parse_monitor_printer_state()
3041 if (data->last_expect->with_value) in parse_monitor_printer_state()
3042 memcpy(data->last_expect->with_value, value + 1, (size_t)(ptr - value - 1)); in parse_monitor_printer_state()
3047 * WITH-VALUE is a literal value... in parse_monitor_printer_state()
3062 data->last_expect->with_value = strdup(value); in parse_monitor_printer_state()
3063 data->last_expect->with_flags |= IPPTOOL_WITH_LITERAL; in parse_monitor_printer_state()
3068 …error(data, "%s without a preceding EXPECT on line %d of \"%s\".", token, f->linenum, f->filename); in parse_monitor_printer_state()
3074 print_fatal_error(data, "Missing closing brace on line %d of \"%s\".", f->linenum, f->filename); in parse_monitor_printer_state()
3081 * 'pause_message()' - Display the message and pause until the user presses a key.
3085 pause_message(const char *message) /* I - Message */ in pause_message()
3108 int tty; /* /dev/tty - never read from stdin */ in pause_message()
3141 cupsFilePrintf(cupsFileStdout(), "\n%s\n\n---- PRESS ANY KEY ----", message); in pause_message()
3180 * 'print_attr()' - Print an attribute on the screen.
3184 print_attr(cups_file_t *outfile, /* I - Output file */ in print_attr()
3185 ipptool_output_t output, /* I - Output format */ in print_attr()
3186 ipp_attribute_t *attr, /* I - Attribute to print */ in print_attr()
3187 ipp_tag_t *group) /* IO - Current group */ in print_attr()
3324 cupsFilePuts(outfile, " -- separator --\n"); in print_attr()
3338 * 'print_csv()' - Print a line of CSV text.
3341 static ipp_attribute_t * /* O - Next attribute */
3343 ipptool_test_t *data, /* I - Test data */ in print_csv()
3344 ipp_t *ipp, /* I - Response message */ in print_csv()
3345 ipp_attribute_t *attr, /* I - First attribute for line */ in print_csv()
3346 int num_displayed, /* I - Number of attributes to display */ in print_csv()
3347 char **displayed, /* I - Attributes to display */ in print_csv()
3348 size_t *widths) /* I - Column widths */ in print_csv()
3395 cupsFilePutChar(data->outfile, ','); in print_csv()
3403 cupsFilePutChar(data->outfile, '\"'); in print_csv()
3407 cupsFilePutChar(data->outfile, '\\'); in print_csv()
3408 cupsFilePutChar(data->outfile, *valptr); in print_csv()
3410 cupsFilePutChar(data->outfile, '\"'); in print_csv()
3415 cupsFilePuts(data->outfile, values[i]); in print_csv()
3420 cupsFilePutChar(data->outfile, '\n'); in print_csv()
3428 cupsFilePutChar(data->outfile, ','); in print_csv()
3430 cupsFilePuts(data->outfile, displayed[i]); in print_csv()
3432 cupsFilePutChar(data->outfile, '\n'); in print_csv()
3440 * 'print_fatal_error()' - Print a fatal error message.
3445 ipptool_test_t *data, /* I - Test data */ in print_fatal_error()
3446 const char *s, /* I - Printf-style format string */ in print_fatal_error()
3447 ...) /* I - Additional arguments as needed */ in print_fatal_error()
3465 if (data->output == IPPTOOL_OUTPUT_PLIST) in print_fatal_error()
3476 * 'print_ippserver_attr()' - Print a attribute suitable for use by ippserver.
3481 ipptool_test_t *data, /* I - Test data */ in print_ippserver_attr()
3482 ipp_attribute_t *attr, /* I - Attribute to print */ in print_ippserver_attr()
3483 int indent) /* I - Indentation level */ in print_ippserver_attr()
3492 … cupsFilePrintf(data->outfile, "ATTR %s %s", ippTagString(ippGetValueTag(attr)), ippGetName(attr)); in print_ippserver_attr()
3494 …cupsFilePrintf(data->outfile, "%*sMEMBER %s %s", indent, "", ippTagString(ippGetValueTag(attr)), i… in print_ippserver_attr()
3501 cupsFilePrintf(data->outfile, "%s%d", i ? "," : " ", ippGetInteger(attr, i)); in print_ippserver_attr()
3505 cupsFilePuts(data->outfile, ippGetBoolean(attr, 0) ? " true" : " false"); in print_ippserver_attr()
3508 cupsFilePuts(data->outfile, ippGetBoolean(attr, 1) ? ",true" : ",false"); in print_ippserver_attr()
3516 cupsFilePrintf(data->outfile, "%s%d-%d", i ? "," : " ", lower, upper); in print_ippserver_attr()
3526 …cupsFilePrintf(data->outfile, "%s%dx%d%s", i ? "," : " ", xres, yres, units == IPP_RES_PER_INCH ? … in print_ippserver_attr()
3532 cupsFilePrintf(data->outfile, "%s%s", i ? "," : " ", iso_date(ippGetDate(attr, i))); in print_ippserver_attr()
3541 cupsFilePuts(data->outfile, i ? "," : " "); in print_ippserver_attr()
3560 cupsFilePuts(data->outfile, i ? "," : " "); in print_ippserver_attr()
3570 cupsFilePuts(data->outfile, i ? ",{\n" : " {\n"); in print_ippserver_attr()
3573 cupsFilePrintf(data->outfile, "%*s}", indent, ""); in print_ippserver_attr()
3578 /* Out-of-band value */ in print_ippserver_attr()
3582 cupsFilePuts(data->outfile, "\n"); in print_ippserver_attr()
3587 * 'print_ippserver_string()' - Print a string suitable for use by ippserver.
3592 ipptool_test_t *data, /* I - Test data */ in print_ippserver_string()
3593 const char *s, /* I - String to print */ in print_ippserver_string()
3594 size_t len) /* I - Length of string */ in print_ippserver_string()
3596 cupsFilePutChar(data->outfile, '\"'); in print_ippserver_string()
3600 cupsFilePutChar(data->outfile, '\\'); in print_ippserver_string()
3601 cupsFilePutChar(data->outfile, *s); in print_ippserver_string()
3604 len --; in print_ippserver_string()
3606 cupsFilePutChar(data->outfile, '\"'); in print_ippserver_string()
3611 * 'print_line()' - Print a line of formatted or CSV text.
3614 static ipp_attribute_t * /* O - Next attribute */
3616 ipptool_test_t *data, /* I - Test data */ in print_line()
3617 ipp_t *ipp, /* I - Response message */ in print_line()
3618 ipp_attribute_t *attr, /* I - First attribute for line */ in print_line()
3619 int num_displayed, /* I - Number of attributes to display */ in print_line()
3620 char **displayed, /* I - Attributes to display */ in print_line()
3621 size_t *widths) /* I - Column widths */ in print_line()
3668 cupsFilePutChar(data->outfile, ' '); in print_line()
3670 cupsFilePrintf(data->outfile, "%*s", (int)-widths[i], values[i] ? values[i] : ""); in print_line()
3673 cupsFilePutChar(data->outfile, '\n'); in print_line()
3687 cupsFilePutChar(data->outfile, ' '); in print_line()
3689 cupsFilePrintf(data->outfile, "%*s", (int)-widths[i], displayed[i]); in print_line()
3691 cupsFilePutChar(data->outfile, '\n'); in print_line()
3696 cupsFilePutChar(data->outfile, ' '); in print_line()
3698 memset(buffer, '-', widths[i]); in print_line()
3700 cupsFilePuts(data->outfile, buffer); in print_line()
3702 cupsFilePutChar(data->outfile, '\n'); in print_line()
3711 * 'print_xml_header()' - Print a standard XML plist header.
3715 print_xml_header(ipptool_test_t *data)/* I - Test data */ in print_xml_header()
3717 if (!data->xml_header) in print_xml_header()
3719 cupsFilePuts(data->outfile, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); in print_xml_header()
3720 …cupsFilePuts(data->outfile, "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"htt… in print_xml_header()
3721 cupsFilePuts(data->outfile, "<plist version=\"1.0\">\n"); in print_xml_header()
3722 cupsFilePuts(data->outfile, "<dict>\n"); in print_xml_header()
3723 cupsFilePuts(data->outfile, "<key>ipptoolVersion</key>\n"); in print_xml_header()
3724 cupsFilePuts(data->outfile, "<string>" CUPS_SVERSION "</string>\n"); in print_xml_header()
3725 cupsFilePuts(data->outfile, "<key>Transfer</key>\n"); in print_xml_header()
3726 …cupsFilePrintf(data->outfile, "<string>%s</string>\n", data->transfer == IPPTOOL_TRANSFER_AUTO ? "… in print_xml_header()
3727 cupsFilePuts(data->outfile, "<key>Tests</key>\n"); in print_xml_header()
3728 cupsFilePuts(data->outfile, "<array>\n"); in print_xml_header()
3730 data->xml_header = 1; in print_xml_header()
3736 * 'print_xml_string()' - Print an XML string with escaping.
3740 print_xml_string(cups_file_t *outfile, /* I - Test data */ in print_xml_string()
3741 const char *element, /* I - Element name or NULL */ in print_xml_string()
3742 const char *s) /* I - String to print */ in print_xml_string()
3758 * Validate UTF-8 two-byte sequence... in print_xml_string()
3775 * Validate UTF-8 three-byte sequence... in print_xml_string()
3793 * Validate UTF-8 four-byte sequence... in print_xml_string()
3830 * 'print_xml_trailer()' - Print the XML trailer with success/fail value.
3835 ipptool_test_t *data, /* I - Test data */ in print_xml_trailer()
3836 int success, /* I - 1 on success, 0 on failure */ in print_xml_trailer()
3837 const char *message) /* I - Error message or NULL */ in print_xml_trailer()
3839 if (data->xml_header) in print_xml_trailer()
3841 cupsFilePuts(data->outfile, "</array>\n"); in print_xml_trailer()
3842 cupsFilePuts(data->outfile, "<key>Successful</key>\n"); in print_xml_trailer()
3843 cupsFilePuts(data->outfile, success ? "<true />\n" : "<false />\n"); in print_xml_trailer()
3846 cupsFilePuts(data->outfile, "<key>ErrorMessage</key>\n"); in print_xml_trailer()
3847 print_xml_string(data->outfile, "string", message); in print_xml_trailer()
3849 cupsFilePuts(data->outfile, "</dict>\n"); in print_xml_trailer()
3850 cupsFilePuts(data->outfile, "</plist>\n"); in print_xml_trailer()
3852 data->xml_header = 0; in print_xml_trailer()
3859 * 'sigterm_handler()' - Handle SIGINT and SIGTERM.
3863 sigterm_handler(int sig) /* I - Signal number (unused) */ in sigterm_handler()
3876 * 'timeout_cb()' - Handle HTTP timeouts.
3879 static int /* O - 1 to continue, 0 to cancel */
3880 timeout_cb(http_t *http, /* I - Connection to server */ in timeout_cb()
3881 void *user_data) /* I - User data (unused) */ in timeout_cb()
3913 * 'token_cb()' - Parse test file-specific tokens and run tests.
3916 static int /* O - 1 to continue, 0 to stop */
3917 token_cb(_ipp_file_t *f, /* I - IPP file data */ in token_cb()
3918 _ipp_vars_t *vars, /* I - IPP variables */ in token_cb()
3919 ipptool_test_t *data, /* I - Test data */ in token_cb()
3920 const char *token) /* I - Current token */ in token_cb()
3936 else if (f->attrs) in token_cb()
3943 _cups_strcasecmp(token, "DEFINE-MATCH") && in token_cb()
3944 _cups_strcasecmp(token, "DEFINE-NO-MATCH") && in token_cb()
3945 _cups_strcasecmp(token, "DEFINE-VALUE") && in token_cb()
3946 _cups_strcasecmp(token, "DISPLAY-MATCH") && in token_cb()
3947 _cups_strcasecmp(token, "IF-DEFINED") && in token_cb()
3948 _cups_strcasecmp(token, "IF-NOT-DEFINED") && in token_cb()
3949 _cups_strcasecmp(token, "IN-GROUP") && in token_cb()
3950 _cups_strcasecmp(token, "OF-TYPE") && in token_cb()
3951 _cups_strcasecmp(token, "REPEAT-LIMIT") && in token_cb()
3952 _cups_strcasecmp(token, "REPEAT-MATCH") && in token_cb()
3953 _cups_strcasecmp(token, "REPEAT-NO-MATCH") && in token_cb()
3954 _cups_strcasecmp(token, "SAME-COUNT-AS") && in token_cb()
3955 _cups_strcasecmp(token, "WITH-ALL-VALUES") && in token_cb()
3956 _cups_strcasecmp(token, "WITH-ALL-HOSTNAMES") && in token_cb()
3957 _cups_strcasecmp(token, "WITH-ALL-RESOURCES") && in token_cb()
3958 _cups_strcasecmp(token, "WITH-ALL-SCHEMES") && in token_cb()
3959 _cups_strcasecmp(token, "WITH-DISTINCT-VALUES") && in token_cb()
3960 _cups_strcasecmp(token, "WITH-HOSTNAME") && in token_cb()
3961 _cups_strcasecmp(token, "WITH-RESOURCE") && in token_cb()
3962 _cups_strcasecmp(token, "WITH-SCHEME") && in token_cb()
3963 _cups_strcasecmp(token, "WITH-VALUE") && in token_cb()
3964 _cups_strcasecmp(token, "WITH-VALUE-FROM")) in token_cb()
3965 data->last_expect = NULL; in token_cb()
3967 if (_cups_strcasecmp(token, "DEFINE-MATCH") && in token_cb()
3968 _cups_strcasecmp(token, "DEFINE-NO-MATCH") && in token_cb()
3969 _cups_strcasecmp(token, "IF-DEFINED") && in token_cb()
3970 _cups_strcasecmp(token, "IF-NOT-DEFINED") && in token_cb()
3971 _cups_strcasecmp(token, "REPEAT-LIMIT") && in token_cb()
3972 _cups_strcasecmp(token, "REPEAT-MATCH") && in token_cb()
3973 _cups_strcasecmp(token, "REPEAT-NO-MATCH")) in token_cb()
3974 data->last_status = NULL; in token_cb()
3980 else if (!strcmp(token, "MONITOR-PRINTER-STATE")) in token_cb()
3982 if (data->monitor_uri) in token_cb()
3984 …print_fatal_error(data, "Extra MONITOR-PRINTER-STATE seen on line %d of \"%s\".", f->linenum, f->f… in token_cb()
4000 _ippVarsExpand(vars, data->compression, temp, sizeof(data->compression)); in token_cb()
4002 if (strcmp(data->compression, "none") && strcmp(data->compression, "deflate") && in token_cb()
4003 strcmp(data->compression, "gzip")) in token_cb()
4005 if (strcmp(data->compression, "none")) in token_cb()
4008 …orted COMPRESSION value \"%s\" on line %d of \"%s\".", data->compression, f->linenum, f->filename); in token_cb()
4012 if (!strcmp(data->compression, "none")) in token_cb()
4013 data->compression[0] = '\0'; in token_cb()
4017 …print_fatal_error(data, "Missing COMPRESSION value on line %d of \"%s\".", f->linenum, f->filename… in token_cb()
4034 …tal_error(data, "Missing DEFINE name and/or value on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4038 else if (!strcmp(token, "IGNORE-ERRORS")) in token_cb()
4041 * IGNORE-ERRORS yes in token_cb()
4042 * IGNORE-ERRORS no in token_cb()
4047 data->ignore_errors = !_cups_strcasecmp(temp, "yes"); in token_cb()
4051 …print_fatal_error(data, "Missing IGNORE-ERRORS value on line %d of \"%s\".", f->linenum, f->filena… in token_cb()
4062 _ippVarsExpand(vars, data->name, temp, sizeof(data->name)); in token_cb()
4072 strlcpy(data->pause, temp, sizeof(data->pause)); in token_cb()
4076 print_fatal_error(data, "Missing PAUSE message on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4080 else if (!strcmp(token, "REQUEST-ID")) in token_cb()
4083 * REQUEST-ID # in token_cb()
4084 * REQUEST-ID random in token_cb()
4091 data->request_id = atoi(temp) - 1; in token_cb()
4095 data->request_id = (CUPS_RAND() % 1000) * 137; in token_cb()
4099 …print_fatal_error(data, "Bad REQUEST-ID value \"%s\" on line %d of \"%s\".", temp, f->linenum, f->… in token_cb()
4105 print_fatal_error(data, "Missing REQUEST-ID value on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4109 else if (!strcmp(token, "PASS-IF-DEFINED")) in token_cb()
4112 * PASS-IF-DEFINED variable in token_cb()
4118 data->pass_test = 1; in token_cb()
4122 …print_fatal_error(data, "Missing PASS-IF-DEFINED value on line %d of \"%s\".", f->linenum, f->file… in token_cb()
4126 else if (!strcmp(token, "PASS-IF-NOT-DEFINED")) in token_cb()
4129 * PASS-IF-NOT-DEFINED variable in token_cb()
4135 data->pass_test = 1; in token_cb()
4139 …print_fatal_error(data, "Missing PASS-IF-NOT-DEFINED value on line %d of \"%s\".", f->linenum, f->… in token_cb()
4143 else if (!strcmp(token, "SKIP-IF-DEFINED")) in token_cb()
4146 * SKIP-IF-DEFINED variable in token_cb()
4152 data->skip_test = 1; in token_cb()
4156 …print_fatal_error(data, "Missing SKIP-IF-DEFINED value on line %d of \"%s\".", f->linenum, f->file… in token_cb()
4160 else if (!strcmp(token, "SKIP-IF-MISSING")) in token_cb()
4163 * SKIP-IF-MISSING filename in token_cb()
4168 char filename[1024]; /* Filename */ in token_cb() local
4171 get_filename(f->filename, filename, temp, sizeof(filename)); in token_cb()
4173 if (access(filename, R_OK)) in token_cb()
4174 data->skip_test = 1; in token_cb()
4178 …print_fatal_error(data, "Missing SKIP-IF-MISSING filename on line %d of \"%s\".", f->linenum, f->f… in token_cb()
4182 else if (!strcmp(token, "SKIP-IF-NOT-DEFINED")) in token_cb()
4185 * SKIP-IF-NOT-DEFINED variable in token_cb()
4191 data->skip_test = 1; in token_cb()
4195 …print_fatal_error(data, "Missing SKIP-IF-NOT-DEFINED value on line %d of \"%s\".", f->linenum, f->… in token_cb()
4199 else if (!strcmp(token, "SKIP-PREVIOUS-ERROR")) in token_cb()
4202 * SKIP-PREVIOUS-ERROR yes in token_cb()
4203 * SKIP-PREVIOUS-ERROR no in token_cb()
4208 data->skip_previous = !_cups_strcasecmp(temp, "yes"); in token_cb()
4212 …print_fatal_error(data, "Missing SKIP-PREVIOUS-ERROR value on line %d of \"%s\".", f->linenum, f->… in token_cb()
4216 else if (!strcmp(token, "TEST-ID")) in token_cb()
4219 * TEST-ID "string" in token_cb()
4224 _ippVarsExpand(vars, data->test_id, temp, sizeof(data->test_id)); in token_cb()
4228 print_fatal_error(data, "Missing TEST-ID value on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4244 data->transfer = IPPTOOL_TRANSFER_AUTO; in token_cb()
4248 data->transfer = IPPTOOL_TRANSFER_CHUNKED; in token_cb()
4252 data->transfer = IPPTOOL_TRANSFER_LENGTH; in token_cb()
4256 …atal_error(data, "Bad TRANSFER value \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename); in token_cb()
4262 print_fatal_error(data, "Missing TRANSFER value on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4272 data->version = 0; in token_cb()
4276 data->version = 10; in token_cb()
4280 data->version = 11; in token_cb()
4284 data->version = 20; in token_cb()
4288 data->version = 21; in token_cb()
4292 data->version = 22; in token_cb()
4296 …print_fatal_error(data, "Bad VERSION \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename); in token_cb()
4302 print_fatal_error(data, "Missing VERSION number on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4312 if (!_ippFileReadToken(f, data->resource, sizeof(data->resource))) in token_cb()
4314 print_fatal_error(data, "Missing RESOURCE path on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4328 print_fatal_error(data, "Missing OPERATION code on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4334 if ((op = ippOpValue(value)) == (ipp_op_t)-1 && (op = (ipp_op_t)strtol(value, NULL, 0)) == 0) in token_cb()
4336 …atal_error(data, "Bad OPERATION code \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename); in token_cb()
4340 ippSetOperation(f->attrs, op); in token_cb()
4352 print_fatal_error(data, "Missing GROUP tag on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4358 …int_fatal_error(data, "Bad GROUP tag \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename); in token_cb()
4362 if (group_tag == f->group_tag) in token_cb()
4363 ippAddSeparator(f->attrs); in token_cb()
4365 f->group_tag = group_tag; in token_cb()
4377 print_fatal_error(data, "Missing DELAY value on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4385 …_fatal_error(data, "Bad DELAY value \"%s\" on line %d of \"%s\".", value, f->linenum, f->filename); in token_cb()
4389 data->delay = (useconds_t)(1000000.0 * dval); in token_cb()
4395 …_fatal_error(data, "Bad DELAY value \"%s\" on line %d of \"%s\".", value, f->linenum, f->filename); in token_cb()
4399 data->repeat_interval = (useconds_t)(1000000.0 * dval); in token_cb()
4402 data->repeat_interval = data->delay; in token_cb()
4412 print_fatal_error(data, "Missing FILE filename on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4417 get_filename(f->filename, data->file, value, sizeof(data->file)); in token_cb()
4419 if (access(data->file, R_OK)) in token_cb()
4421 …atal_error(data, "Filename \"%s\" (mapped to \"%s\") on line %d of \"%s\" cannot be read.", value,… in token_cb()
4431 if (data->num_statuses >= (int)(sizeof(data->statuses) / sizeof(data->statuses[0]))) in token_cb()
4433 print_fatal_error(data, "Too many STATUS's on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4439 print_fatal_error(data, "Missing STATUS code on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4443 …if ((data->statuses[data->num_statuses].status = ippErrorValue(temp)) == (ipp_status_t)-1 && (data… in token_cb()
4445 …t_fatal_error(data, "Bad STATUS code \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename); in token_cb()
4449 data->last_status = data->statuses + data->num_statuses; in token_cb()
4450 data->num_statuses ++; in token_cb()
4452 data->last_status->define_match = NULL; in token_cb()
4453 data->last_status->define_no_match = NULL; in token_cb()
4454 data->last_status->if_defined = NULL; in token_cb()
4455 data->last_status->if_not_defined = NULL; in token_cb()
4456 data->last_status->repeat_limit = 1000; in token_cb()
4457 data->last_status->repeat_match = 0; in token_cb()
4458 data->last_status->repeat_no_match = 0; in token_cb()
4460 else if (!_cups_strcasecmp(token, "EXPECT") || !_cups_strcasecmp(token, "EXPECT-ALL")) in token_cb()
4466 int expect_all = !_cups_strcasecmp(token, "EXPECT-ALL"); in token_cb()
4468 if (data->num_expects >= (int)(sizeof(data->expects) / sizeof(data->expects[0]))) in token_cb()
4470 print_fatal_error(data, "Too many EXPECT's on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4476 print_fatal_error(data, "Missing EXPECT name on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4480 data->last_expect = data->expects + data->num_expects; in token_cb()
4481 data->num_expects ++; in token_cb()
4483 memset(data->last_expect, 0, sizeof(ipptool_expect_t)); in token_cb()
4484 data->last_expect->repeat_limit = 1000; in token_cb()
4485 data->last_expect->expect_all = expect_all; in token_cb()
4489 data->last_expect->not_expect = 1; in token_cb()
4490 data->last_expect->name = strdup(name + 1); in token_cb()
4494 data->last_expect->optional = 1; in token_cb()
4495 data->last_expect->name = strdup(name + 1); in token_cb()
4498 data->last_expect->name = strdup(name); in token_cb()
4506 print_fatal_error(data, "Missing COUNT number on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4512 print_fatal_error(data, "Bad COUNT \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename); in token_cb()
4516 if (data->last_expect) in token_cb()
4518 data->last_expect->count = count; in token_cb()
4522 …tal_error(data, "COUNT without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4526 else if (!_cups_strcasecmp(token, "DEFINE-MATCH")) in token_cb()
4530 …print_fatal_error(data, "Missing DEFINE-MATCH variable on line %d of \"%s\".", f->linenum, f->file… in token_cb()
4534 if (data->last_expect) in token_cb()
4536 data->last_expect->define_match = strdup(temp); in token_cb()
4538 else if (data->last_status) in token_cb()
4540 data->last_status->define_match = strdup(temp); in token_cb()
4544 …print_fatal_error(data, "DEFINE-MATCH without a preceding EXPECT or STATUS on line %d of \"%s\".",… in token_cb()
4548 else if (!_cups_strcasecmp(token, "DEFINE-NO-MATCH")) in token_cb()
4552 …print_fatal_error(data, "Missing DEFINE-NO-MATCH variable on line %d of \"%s\".", f->linenum, f->f… in token_cb()
4556 if (data->last_expect) in token_cb()
4558 data->last_expect->define_no_match = strdup(temp); in token_cb()
4560 else if (data->last_status) in token_cb()
4562 data->last_status->define_no_match = strdup(temp); in token_cb()
4566 …int_fatal_error(data, "DEFINE-NO-MATCH without a preceding EXPECT or STATUS on line %d of \"%s\"."… in token_cb()
4570 else if (!_cups_strcasecmp(token, "DEFINE-VALUE")) in token_cb()
4574 …print_fatal_error(data, "Missing DEFINE-VALUE variable on line %d of \"%s\".", f->linenum, f->file… in token_cb()
4578 if (data->last_expect) in token_cb()
4580 data->last_expect->define_value = strdup(temp); in token_cb()
4584 …print_fatal_error(data, "DEFINE-VALUE without a preceding EXPECT on line %d of \"%s\".", f->linenu… in token_cb()
4588 else if (!_cups_strcasecmp(token, "DISPLAY-MATCH")) in token_cb()
4592 …print_fatal_error(data, "Missing DISPLAY-MATCH mesaage on line %d of \"%s\".", f->linenum, f->file… in token_cb()
4596 if (data->last_expect) in token_cb()
4598 data->last_expect->display_match = strdup(temp); in token_cb()
4602 …print_fatal_error(data, "DISPLAY-MATCH without a preceding EXPECT on line %d of \"%s\".", f->linen… in token_cb()
4606 else if (!_cups_strcasecmp(token, "OF-TYPE")) in token_cb()
4610 …print_fatal_error(data, "Missing OF-TYPE value tag(s) on line %d of \"%s\".", f->linenum, f->filen… in token_cb()
4614 if (data->last_expect) in token_cb()
4616 data->last_expect->of_type = strdup(temp); in token_cb()
4620 …print_fatal_error(data, "OF-TYPE without a preceding EXPECT on line %d of \"%s\".", f->linenum, f-… in token_cb()
4624 else if (!_cups_strcasecmp(token, "IN-GROUP")) in token_cb()
4626 ipp_tag_t in_group; /* IN-GROUP value */ in token_cb()
4630 …print_fatal_error(data, "Missing IN-GROUP group tag on line %d of \"%s\".", f->linenum, f->filenam… in token_cb()
4636 …print_fatal_error(data, "Bad IN-GROUP group tag \"%s\" on line %d of \"%s\".", temp, f->linenum, f… in token_cb()
4639 else if (data->last_expect) in token_cb()
4641 data->last_expect->in_group = in_group; in token_cb()
4645 …print_fatal_error(data, "IN-GROUP without a preceding EXPECT on line %d of \"%s\".", f->linenum, f… in token_cb()
4649 else if (!_cups_strcasecmp(token, "REPEAT-LIMIT")) in token_cb()
4653 …print_fatal_error(data, "Missing REPEAT-LIMIT value on line %d of \"%s\".", f->linenum, f->filenam… in token_cb()
4658 print_fatal_error(data, "Bad REPEAT-LIMIT value on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4662 if (data->last_status) in token_cb()
4664 data->last_status->repeat_limit = atoi(temp); in token_cb()
4666 else if (data->last_expect) in token_cb()
4668 data->last_expect->repeat_limit = atoi(temp); in token_cb()
4672 …print_fatal_error(data, "REPEAT-LIMIT without a preceding EXPECT or STATUS on line %d of \"%s\".",… in token_cb()
4676 else if (!_cups_strcasecmp(token, "REPEAT-MATCH")) in token_cb()
4678 if (data->last_status) in token_cb()
4680 data->last_status->repeat_match = 1; in token_cb()
4682 else if (data->last_expect) in token_cb()
4684 data->last_expect->repeat_match = 1; in token_cb()
4688 …print_fatal_error(data, "REPEAT-MATCH without a preceding EXPECT or STATUS on line %d of \"%s\".",… in token_cb()
4692 else if (!_cups_strcasecmp(token, "REPEAT-NO-MATCH")) in token_cb()
4694 if (data->last_status) in token_cb()
4696 data->last_status->repeat_no_match = 1; in token_cb()
4698 else if (data->last_expect) in token_cb()
4700 data->last_expect->repeat_no_match = 1; in token_cb()
4704 …int_fatal_error(data, "REPEAT-NO-MATCH without a preceding EXPECT or STATUS on line %d of \"%s\"."… in token_cb()
4708 else if (!_cups_strcasecmp(token, "SAME-COUNT-AS")) in token_cb()
4712 …print_fatal_error(data, "Missing SAME-COUNT-AS name on line %d of \"%s\".", f->linenum, f->filenam… in token_cb()
4716 if (data->last_expect) in token_cb()
4718 data->last_expect->same_count_as = strdup(temp); in token_cb()
4722 …print_fatal_error(data, "SAME-COUNT-AS without a preceding EXPECT on line %d of \"%s\".", f->linen… in token_cb()
4726 else if (!_cups_strcasecmp(token, "IF-DEFINED")) in token_cb()
4730 print_fatal_error(data, "Missing IF-DEFINED name on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4734 if (data->last_expect) in token_cb()
4736 data->last_expect->if_defined = strdup(temp); in token_cb()
4738 else if (data->last_status) in token_cb()
4740 data->last_status->if_defined = strdup(temp); in token_cb()
4744 …print_fatal_error(data, "IF-DEFINED without a preceding EXPECT or STATUS on line %d of \"%s\".", f… in token_cb()
4748 else if (!_cups_strcasecmp(token, "IF-NOT-DEFINED")) in token_cb()
4752 …print_fatal_error(data, "Missing IF-NOT-DEFINED name on line %d of \"%s\".", f->linenum, f->filena… in token_cb()
4756 if (data->last_expect) in token_cb()
4758 data->last_expect->if_not_defined = strdup(temp); in token_cb()
4760 else if (data->last_status) in token_cb()
4762 data->last_status->if_not_defined = strdup(temp); in token_cb()
4766 …print_fatal_error(data, "IF-NOT-DEFINED without a preceding EXPECT or STATUS on line %d of \"%s\".… in token_cb()
4770 else if (!_cups_strcasecmp(token, "WITH-DISTINCT-VALUES")) in token_cb()
4772 if (data->last_expect) in token_cb()
4774 data->last_expect->with_distinct = 1; in token_cb()
4778 …error(data, "%s without a preceding EXPECT on line %d of \"%s\".", token, f->linenum, f->filename); in token_cb()
4782 else if (!_cups_strcasecmp(token, "WITH-ALL-VALUES") || in token_cb()
4783 !_cups_strcasecmp(token, "WITH-ALL-HOSTNAMES") || in token_cb()
4784 !_cups_strcasecmp(token, "WITH-ALL-RESOURCES") || in token_cb()
4785 !_cups_strcasecmp(token, "WITH-ALL-SCHEMES") || in token_cb()
4786 !_cups_strcasecmp(token, "WITH-HOSTNAME") || in token_cb()
4787 !_cups_strcasecmp(token, "WITH-RESOURCE") || in token_cb()
4788 !_cups_strcasecmp(token, "WITH-SCHEME") || in token_cb()
4789 !_cups_strcasecmp(token, "WITH-VALUE")) in token_cb()
4794 if (data->last_expect) in token_cb()
4796 if (!_cups_strcasecmp(token, "WITH-ALL-HOSTNAMES") || !_cups_strcasecmp(token, "WITH-HOSTNAME")) in token_cb()
4797 data->last_expect->with_flags = IPPTOOL_WITH_HOSTNAME; in token_cb()
4798 …else if (!_cups_strcasecmp(token, "WITH-ALL-RESOURCES") || !_cups_strcasecmp(token, "WITH-RESOURCE… in token_cb()
4799 data->last_expect->with_flags = IPPTOOL_WITH_RESOURCE; in token_cb()
4800 else if (!_cups_strcasecmp(token, "WITH-ALL-SCHEMES") || !_cups_strcasecmp(token, "WITH-SCHEME")) in token_cb()
4801 data->last_expect->with_flags = IPPTOOL_WITH_SCHEME; in token_cb()
4803 if (!_cups_strncasecmp(token, "WITH-ALL-", 9)) in token_cb()
4804 data->last_expect->with_flags |= IPPTOOL_WITH_ALL; in token_cb()
4809 print_fatal_error(data, "Missing %s value on line %d of \"%s\".", token, f->linenum, f->filename); in token_cb()
4814 * Read additional comma-delimited values - needed since legacy test files in token_cb()
4815 * will have unquoted WITH-VALUE values with commas... in token_cb()
4822 lastpos = cupsFileTell(f->fp); in token_cb()
4823 lastline = f->linenum; in token_cb()
4826 if (!_ippFileReadToken(f, ptr, (sizeof(temp) - (size_t)(ptr - temp)))) in token_cb()
4837 if (!_ippFileReadToken(f, ptr, (sizeof(temp) - (size_t)(ptr - temp)))) in token_cb()
4846 cupsFileSeek(f->fp, lastpos); in token_cb()
4847 f->linenum = lastline; in token_cb()
4853 if (data->last_expect) in token_cb()
4861 ptr = value + strlen(value) - 1; in token_cb()
4866 * WITH-VALUE is a POSIX extended regular expression. in token_cb()
4869 data->last_expect->with_value = calloc(1, (size_t)(ptr - value)); in token_cb()
4870 data->last_expect->with_flags |= IPPTOOL_WITH_REGEX; in token_cb()
4872 if (data->last_expect->with_value) in token_cb()
4873 memcpy(data->last_expect->with_value, value + 1, (size_t)(ptr - value - 1)); in token_cb()
4878 * WITH-VALUE is a literal value... in token_cb()
4893 data->last_expect->with_value = strdup(value); in token_cb()
4894 data->last_expect->with_flags |= IPPTOOL_WITH_LITERAL; in token_cb()
4899 …error(data, "%s without a preceding EXPECT on line %d of \"%s\".", token, f->linenum, f->filename); in token_cb()
4903 else if (!_cups_strcasecmp(token, "WITH-VALUE-FROM")) in token_cb()
4907 print_fatal_error(data, "Missing %s value on line %d of \"%s\".", token, f->linenum, f->filename); in token_cb()
4911 if (data->last_expect) in token_cb()
4919 data->last_expect->with_value_from = strdup(value); in token_cb()
4920 data->last_expect->with_flags = IPPTOOL_WITH_LITERAL; in token_cb()
4924 …error(data, "%s without a preceding EXPECT on line %d of \"%s\".", token, f->linenum, f->filename); in token_cb()
4934 if (data->num_displayed >= (int)(sizeof(data->displayed) / sizeof(data->displayed[0]))) in token_cb()
4936 print_fatal_error(data, "Too many DISPLAY's on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4942 print_fatal_error(data, "Missing DISPLAY name on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4946 data->displayed[data->num_displayed] = strdup(temp); in token_cb()
4947 data->num_displayed ++; in token_cb()
4951 …atal_error(data, "Unexpected token %s seen on line %d of \"%s\".", token, f->linenum, f->filename); in token_cb()
4967 if (data->show_header) in token_cb()
4969 if (data->output == IPPTOOL_OUTPUT_PLIST) in token_cb()
4972 …if (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPPTOOL_OUTPUT_PLIST && data->outfile … in token_cb()
4973 cupsFilePrintf(cupsFileStdout(), "\"%s\":\n", f->filename); in token_cb()
4975 data->show_header = 0; in token_cb()
4978 data->compression[0] = '\0'; in token_cb()
4979 data->delay = 0; in token_cb()
4980 data->num_expects = 0; in token_cb()
4981 data->last_expect = NULL; in token_cb()
4982 data->file[0] = '\0'; in token_cb()
4983 data->ignore_errors = data->def_ignore_errors; in token_cb()
4984 strlcpy(data->name, f->filename, sizeof(data->name)); in token_cb()
4985 if ((ptr = strrchr(data->name, '.')) != NULL) in token_cb()
4987 data->repeat_interval = 5000000; in token_cb()
4988 strlcpy(data->resource, data->vars->resource, sizeof(data->resource)); in token_cb()
4989 data->skip_previous = 0; in token_cb()
4990 data->pass_test = 0; in token_cb()
4991 data->skip_test = 0; in token_cb()
4992 data->num_statuses = 0; in token_cb()
4993 data->last_status = NULL; in token_cb()
4994 data->test_id[0] = '\0'; in token_cb()
4995 data->transfer = data->def_transfer; in token_cb()
4996 data->version = data->def_version; in token_cb()
4998 free(data->monitor_uri); in token_cb()
4999 data->monitor_uri = NULL; in token_cb()
5000 data->monitor_delay = 0; in token_cb()
5001 data->monitor_interval = 5000000; in token_cb()
5002 data->num_monitor_expects = 0; in token_cb()
5004 _ippVarsSet(vars, "date-current", iso_date(ippTimeToDate(time(NULL)))); in token_cb()
5006 f->attrs = ippNew(); in token_cb()
5007 f->group_tag = IPP_TAG_ZERO; in token_cb()
5017 _ippVarsSet(vars, "date-current", iso_date(ippTimeToDate(time(NULL)))); in token_cb()
5023 …tal_error(data, "Missing DEFINE name and/or value on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
5027 else if (!strcmp(token, "DEFINE-DEFAULT")) in token_cb()
5030 * DEFINE-DEFAULT name value in token_cb()
5037 _ippVarsSet(vars, "date-current", iso_date(ippTimeToDate(time(NULL)))); in token_cb()
5044 …print_fatal_error(data, "Missing DEFINE-DEFAULT name and/or value on line %d of \"%s\".", f->linen… in token_cb()
5048 else if (!strcmp(token, "FILE-ID")) in token_cb()
5051 * FILE-ID "string" in token_cb()
5056 _ippVarsSet(vars, "date-current", iso_date(ippTimeToDate(time(NULL)))); in token_cb()
5057 _ippVarsExpand(vars, data->file_id, temp, sizeof(data->file_id)); in token_cb()
5061 … print_fatal_error(data, "Missing FILE-ID value on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
5065 else if (!strcmp(token, "IGNORE-ERRORS")) in token_cb()
5068 * IGNORE-ERRORS yes in token_cb()
5069 * IGNORE-ERRORS no in token_cb()
5074 data->def_ignore_errors = !_cups_strcasecmp(temp, "yes"); in token_cb()
5078 …print_fatal_error(data, "Missing IGNORE-ERRORS value on line %d of \"%s\".", f->linenum, f->filena… in token_cb()
5085 * INCLUDE "filename" in token_cb()
5086 * INCLUDE <filename> in token_cb()
5092 * Map the filename to and then run the tests... in token_cb()
5096 char filename[1024]; /* Mapped filename */ in token_cb() local
5104 …if (!do_tests(get_filename(f->filename, filename, temp, sizeof(filename)), &inc_data) && data->sto… in token_cb()
5106 data->pass = data->prev_pass = 0; in token_cb()
5112 …print_fatal_error(data, "Missing INCLUDE filename on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
5116 data->show_header = 1; in token_cb()
5118 else if (!strcmp(token, "INCLUDE-IF-DEFINED")) in token_cb()
5121 * INCLUDE-IF-DEFINED name "filename" in token_cb()
5122 * INCLUDE-IF-DEFINED name <filename> in token_cb()
5128 * Map the filename to and then run the tests... in token_cb()
5132 char filename[1024]; /* Mapped filename */ in token_cb() local
5140 …if (!do_tests(get_filename(f->filename, filename, temp, sizeof(filename)), &inc_data) && data->sto… in token_cb()
5142 data->pass = data->prev_pass = 0; in token_cb()
5148 …int_fatal_error(data, "Missing INCLUDE-IF-DEFINED name or filename on line %d of \"%s\".", f->line… in token_cb()
5152 data->show_header = 1; in token_cb()
5154 else if (!strcmp(token, "INCLUDE-IF-NOT-DEFINED")) in token_cb()
5157 * INCLUDE-IF-NOT-DEFINED name "filename" in token_cb()
5158 * INCLUDE-IF-NOT-DEFINED name <filename> in token_cb()
5164 * Map the filename to and then run the tests... in token_cb()
5168 char filename[1024]; /* Mapped filename */ in token_cb() local
5176 …if (!do_tests(get_filename(f->filename, filename, temp, sizeof(filename)), &inc_data) && data->sto… in token_cb()
5178 data->pass = data->prev_pass = 0; in token_cb()
5184 …t_fatal_error(data, "Missing INCLUDE-IF-NOT-DEFINED name or filename on line %d of \"%s\".", f->li… in token_cb()
5188 data->show_header = 1; in token_cb()
5190 else if (!strcmp(token, "SKIP-IF-DEFINED")) in token_cb()
5193 * SKIP-IF-DEFINED variable in token_cb()
5199 data->skip_test = 1; in token_cb()
5203 …print_fatal_error(data, "Missing SKIP-IF-DEFINED variable on line %d of \"%s\".", f->linenum, f->f… in token_cb()
5207 else if (!strcmp(token, "SKIP-IF-NOT-DEFINED")) in token_cb()
5210 * SKIP-IF-NOT-DEFINED variable in token_cb()
5216 data->skip_test = 1; in token_cb()
5220 …print_fatal_error(data, "Missing SKIP-IF-NOT-DEFINED variable on line %d of \"%s\".", f->linenum, … in token_cb()
5224 else if (!strcmp(token, "STOP-AFTER-INCLUDE-ERROR")) in token_cb()
5227 * STOP-AFTER-INCLUDE-ERROR yes in token_cb()
5228 * STOP-AFTER-INCLUDE-ERROR no in token_cb()
5233 data->stop_after_include_error = !_cups_strcasecmp(temp, "yes"); in token_cb()
5237 …print_fatal_error(data, "Missing STOP-AFTER-INCLUDE-ERROR value on line %d of \"%s\".", f->linenum… in token_cb()
5252 data->def_transfer = IPPTOOL_TRANSFER_AUTO; in token_cb()
5254 data->def_transfer = IPPTOOL_TRANSFER_CHUNKED; in token_cb()
5256 data->def_transfer = IPPTOOL_TRANSFER_LENGTH; in token_cb()
5259 …atal_error(data, "Bad TRANSFER value \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename); in token_cb()
5265 … print_fatal_error(data, "Missing TRANSFER value on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
5274 data->def_version = 10; in token_cb()
5276 data->def_version = 11; in token_cb()
5278 data->def_version = 20; in token_cb()
5280 data->def_version = 21; in token_cb()
5282 data->def_version = 22; in token_cb()
5285 …print_fatal_error(data, "Bad VERSION \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename); in token_cb()
5291 … print_fatal_error(data, "Missing VERSION number on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
5297 …atal_error(data, "Unexpected token %s seen on line %d of \"%s\".", token, f->linenum, f->filename); in token_cb()
5307 * 'usage()' - Show program usage.
5313 _cupsLangPuts(stderr, _("Usage: ipptool [options] URI filename [ ... filenameN ]")); in usage()
5315 _cupsLangPuts(stderr, _("--ippserver filename Produce ippserver attribute file")); in usage()
5316 _cupsLangPuts(stderr, _("--stop-after-include-error\n" in usage()
5318 _cupsLangPuts(stderr, _("--version Show version")); in usage()
5319 _cupsLangPuts(stderr, _("-4 Connect using IPv4")); in usage()
5320 _cupsLangPuts(stderr, _("-6 Connect using IPv6")); in usage()
5321 _cupsLangPuts(stderr, _("-C Send requests using chunking (default)")); in usage()
5322 …_cupsLangPuts(stderr, _("-E Test with encryption using HTTP Upgrade to TLS")); in usage()
5323 _cupsLangPuts(stderr, _("-I Ignore errors")); in usage()
5324 _cupsLangPuts(stderr, _("-L Send requests using content-length")); in usage()
5325 …_cupsLangPuts(stderr, _("-P filename.plist Produce XML plist to a file and test report to st… in usage()
5326 _cupsLangPuts(stderr, _("-R Repeat tests on server-error-busy")); in usage()
5327 _cupsLangPuts(stderr, _("-S Test with encryption using HTTPS")); in usage()
5328 _cupsLangPuts(stderr, _("-T seconds Set the receive/send timeout in seconds")); in usage()
5329 _cupsLangPuts(stderr, _("-V version Set default IPP version")); in usage()
5330 _cupsLangPuts(stderr, _("-X Produce XML plist instead of plain text")); in usage()
5331 _cupsLangPuts(stderr, _("-c Produce CSV output")); in usage()
5332 _cupsLangPuts(stderr, _("-d name=value Set named variable to value")); in usage()
5333 _cupsLangPuts(stderr, _("-f filename Set default request filename")); in usage()
5334 _cupsLangPuts(stderr, _("-h Validate HTTP response headers")); in usage()
5335 …_cupsLangPuts(stderr, _("-i seconds Repeat the last file with the given time interval… in usage()
5336 _cupsLangPuts(stderr, _("-l Produce plain text output")); in usage()
5337 …_cupsLangPuts(stderr, _("-n count Repeat the last file the given number of times")); in usage()
5338 _cupsLangPuts(stderr, _("-q Run silently")); in usage()
5339 _cupsLangPuts(stderr, _("-t Produce a test report")); in usage()
5340 _cupsLangPuts(stderr, _("-v Be verbose")); in usage()
5347 * 'with_distinct_values()' - Verify that an attribute contains unique values.
5350 static int // O - 1 if distinct, 0 if duplicate
5352 cups_array_t *errors, // I - Array of errors in with_distinct_values()
5353 ipp_attribute_t *attr) // I - Attribute to test in with_distinct_values()
5367 // Only check integers, enums, rangeOfInteger, resolution, and nul-terminated in with_distinct_values()
5384 …add_stringf(errors, "WITH-DISTINCT-VALUES %s not supported for 1setOf %s", ippGetName(attr), ippTa… in with_distinct_values()
5405 snprintf(buffer, sizeof(buffer), "%d-%d", lower, upper); in with_distinct_values()
5438 …for (prefix = '{', bufptr = buffer, bufend = buffer + sizeof(buffer) - 2, member = ippFirstAttribu… in with_distinct_values()
5443 ippAttributeString(member, bufptr, (size_t)(bufend - bufptr)); in with_distinct_values()
5472 * 'with_flags_string()' - Return the "WITH-xxx" predicate that corresponds to
5476 static const char * /* O - WITH-xxx string */
5477 with_flags_string(int flags) /* I - WITH flags */ in with_flags_string()
5482 return ("WITH-ALL-HOSTNAMES"); in with_flags_string()
5484 return ("WITH-ALL-RESOURCES"); in with_flags_string()
5486 return ("WITH-ALL-SCHEMES"); in with_flags_string()
5488 return ("WITH-ALL-VALUES"); in with_flags_string()
5491 return ("WITH-HOSTNAME"); in with_flags_string()
5493 return ("WITH-RESOURCE"); in with_flags_string()
5495 return ("WITH-SCHEME"); in with_flags_string()
5497 return ("WITH-VALUE"); in with_flags_string()
5502 * 'with_value()' - Test a WITH-VALUE predicate.
5505 static int /* O - 1 on match, 0 on non-match */
5506 with_value(ipptool_test_t *data, /* I - Test data */ in with_value()
5507 cups_array_t *errors, /* I - Errors array */ in with_value()
5508 char *value, /* I - Value string */ in with_value()
5509 int flags, /* I - Flags for match */ in with_value()
5510 ipp_attribute_t *attr, /* I - Attribute to compare */ in with_value()
5511 char *matchbuf, /* I - Buffer to hold matching value */ in with_value()
5512 size_t matchlen) /* I - Length of match buffer */ in with_value()
5516 match; /* Match? */ in with_value() local
5523 match = (flags & IPPTOOL_WITH_ALL) ? 1 : 0; in with_value()
5550 valmatch = 0; /* Does the current value match? */ in with_value()
5555 *valptr == '-' || *valptr == ',' || *valptr == '<' || in with_value()
5559 while (*valptr && !isdigit(*valptr & 255) && *valptr != '-') in with_value()
5590 match = 0; in with_value()
5596 match = 1; in with_value()
5601 if (!match && errors) in with_value()
5604 add_stringf(data->errors, "GOT: %s=%d", name, ippGetInteger(attr, i)); in with_value()
5616 valmatch = 0; /* Does the current value match? */ in with_value()
5622 *valptr == '-' || *valptr == ',' || *valptr == '<' || in with_value()
5626 while (*valptr && !isdigit(*valptr & 255) && *valptr != '-') in with_value()
5646 snprintf(matchbuf, matchlen, "%d-%d", lower, upper); in with_value()
5657 match = 0; in with_value()
5663 match = 1; in with_value()
5668 if (!match && errors) in with_value()
5675 add_stringf(data->errors, "GOT: %s=%d-%d", name, lower, upper); in with_value()
5690 match = 1; in with_value()
5696 match = 0; in with_value()
5701 if (!match && errors) in with_value()
5704 add_stringf(data->errors, "GOT: %s=%s", name, ippGetBoolean(attr, i) ? "true" : "false"); in with_value()
5727 match = 1; in with_value()
5733 match = 0; in with_value()
5738 if (!match && errors) in with_value()
5752 add_stringf(data->errors, "GOT: %s=%s", name, temp); in with_value()
5774 * Value is an extended, case-sensitive POSIX regular expression... in with_value()
5783 …print_fatal_error(data, "Unable to compile WITH-VALUE regular expression \"%s\" - %s", value, temp… in with_value()
5788 * See if ALL of the values match the given regular expression. in with_value()
5801 match = 1; in with_value()
5807 match = 0; in with_value()
5817 * Value is a literal URI string, see if the value(s) match... in with_value()
5829 match = 1; in with_value()
5835 match = 0; in with_value()
5843 * Value is a literal string, see if the value(s) match... in with_value()
5854 * Some URI components are case-sensitive, some not... in with_value()
5871 * be case-insensitive strings... in with_value()
5880 * case-sensitive comparisons to catch problems... in with_value()
5894 match = 1; in with_value()
5900 match = 0; in with_value()
5906 if (!match && errors) in with_value()
5909 add_stringf(data->errors, "GOT: %s=\"%s\"", name, ippGetString(attr, i, NULL)); in with_value()
5917 * Value is an extended, case-sensitive POSIX regular expression... in with_value()
5928 …print_fatal_error(data, "Unable to compile WITH-VALUE regular expression \"%s\" - %s", value, temp… in with_value()
5933 * See if ALL of the values match the given regular expression. in with_value()
5940 match = 0; in with_value()
5953 match = 1; in with_value()
5959 match = 0; in with_value()
5966 if (!match && errors) in with_value()
5972 add_stringf(data->errors, "GOT: %s=\"%s\"", name, temp); in with_value()
5979 * Value is a literal or hex-encoded string... in with_value()
5982 unsigned char withdata[1023], /* WITH-VALUE data */ in with_value()
5984 int withlen, /* Length of WITH-VALUE data */ in with_value()
5990 * Grab hex-encoded value... in with_value()
5995 print_fatal_error(data, "Bad WITH-VALUE hex value."); in with_value()
5999 withlen = withlen / 2 - 1; in with_value()
6006 ch = (valptr[0] - '0') << 4; in with_value()
6008 ch = (tolower(valptr[0]) - 'a' + 10) << 4; in with_value()
6013 ch |= valptr[1] - '0'; in with_value()
6015 ch |= tolower(valptr[1]) - 'a' + 10; in with_value()
6024 print_fatal_error(data, "Bad WITH-VALUE hex value."); in with_value()
6050 match = 1; in with_value()
6056 match = 0; in with_value()
6061 if (!match && errors) in with_value()
6067 add_stringf(data->errors, "GOT: %s=\"%s\"", name, temp); in with_value()
6077 return (match); in with_value()
6082 * 'with_value_from()' - Test a WITH-VALUE-FROM predicate.
6085 static int /* O - 1 on match, 0 on non-match */
6087 cups_array_t *errors, /* I - Errors array */ in with_value_from()
6088 ipp_attribute_t *fromattr, /* I - "From" attribute */ in with_value_from()
6089 ipp_attribute_t *attr, /* I - Attribute to compare */ in with_value_from()
6090 char *matchbuf, /* I - Buffer to hold matching value */ in with_value_from()
6091 size_t matchlen) /* I - Length of match buffer */ in with_value_from()
6095 match = 1; /* Match? */ in with_value_from() local
6123 match = 0; in with_value_from()
6145 match = 0; in with_value_from()
6188 match = 0; in with_value_from()
6219 match = 0; in with_value_from()
6244 match = 0; in with_value_from()
6250 match = 0; in with_value_from()
6254 return (match); in with_value_from()
6259 add_stringf(errors, "GOT: %s OF-TYPE %s", ippGetName(attr), ippTagString(ippGetValueTag(attr))); in with_value_from()