• Home
  • Raw
  • Download

Lines Matching +full:getsockopt +full:- +full:timeouts

4  * Copyright © 2021-2024 by OpenPrinting.
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 */
88 *define_no_match, /* Variable to define on no-match */
94 with_distinct, /* WITH-DISTINCT-VALUES? */
97 ipp_tag_t in_group; /* IN-GROUP value */
106 *define_no_match, /* Variable to define on no-match */
120 int repeat_on_busy; /* Repeat tests on server-error-busy */
128 int def_ignore_errors; /* Default IGNORE-ERRORS value */
143 /* Per-Test State */
173 char *monitor_uri; /* MONITOR-PRINTER-STATE URI */
174 useconds_t monitor_delay, /* MONITOR-PRINTER-STATE DELAY value, if any */
175 monitor_interval; /* MONITOR-PRINTER-STATE DELAY interval */
176 int num_monitor_expects; /* Number MONITOR-PRINTER-STATE EXPECTs */
178 /* MONITOR-PRINTER-STATE EXPECTs */
231 * 'main()' - Parse options and do tests.
234 int /* O - Exit status */
235 main(int argc, /* I - Number of command-line args */ in main()
236 char *argv[]) /* I - Command-line arguments */ in main()
275 _ippVarsSet(data.vars, "date-start", iso_date(ippTimeToDate(time(NULL)))); in main()
290 if (!strcmp(argv[i], "--help")) in main()
294 else if (!strcmp(argv[i], "--ippserver")) in main()
300 _cupsLangPuts(stderr, _("ipptool: Missing filename for \"--ippserver\".")); in main()
315 else if (!strcmp(argv[i], "--stop-after-include-error")) in main()
319 else if (!strcmp(argv[i], "--version")) in main()
324 else if (argv[i][0] == '-') in main()
366 _cupsLangPrintf(stderr, _("%s: Missing filename for \"-P\"."), "ipptool"); in main()
383 … _cupsLangPuts(stderr, _("ipptool: \"-i\" and \"-n\" are incompatible with \"-P\" and \"-X\".")); in main()
388 case 'R' : /* Repeat on server-error-busy */ in main()
405 _cupsLangPrintf(stderr, _("%s: Missing timeout for \"-T\"."), "ipptool"); in main()
417 _cupsLangPrintf(stderr, _("%s: Missing version for \"-V\"."), "ipptool"); in main()
443 _cupsLangPrintf(stderr, _("%s: Bad version %s for \"-V\"."), "ipptool", argv[i]); in main()
453 … _cupsLangPuts(stderr, _("ipptool: \"-i\" and \"-n\" are incompatible with \"-P\" and \"-X\".")); in main()
467 _cupsLangPuts(stderr, _("ipptool: Missing name=value for \"-d\".")); in main()
485 _cupsLangPuts(stderr, _("ipptool: Missing filename for \"-f\".")); in main()
502 snprintf(filename, sizeof(filename), "%s/ipptool/%s", cg->cups_datadir, argv[i]); in main()
505 snprintf(filename, sizeof(filename), "%s/ipptool/%s.gz", cg->cups_datadir, argv[i]); in main()
534 _ippVarsSet(data.vars, "filetype", "application/vnd.hp-PCL"); in main()
546 _ippVarsSet(data.vars, "filetype", "image/pwg-raster"); in main()
559 _ippVarsSet(data.vars, "filetype", "application/octet-stream"); in main()
564 * Use the "auto-type" MIME media type... in main()
567 _ippVarsSet(data.vars, "filetype", "application/octet-stream"); in main()
580 _cupsLangPuts(stderr, _("ipptool: Missing seconds for \"-i\".")); in main()
588 _cupsLangPuts(stderr, _("ipptool: Invalid seconds for \"-i\".")); in main()
595 …_cupsLangPuts(stderr, _("ipptool: \"-i\" and \"-n\" are incompatible with \"--ippserver\", \"-P\",… in main()
613 _cupsLangPuts(stderr, _("ipptool: Missing count for \"-n\".")); in main()
621 …_cupsLangPuts(stderr, _("ipptool: \"-i\" and \"-n\" are incompatible with \"--ippserver\", \"-P\",… in main()
639 _cupsLangPrintf(stderr, _("%s: Unknown option \"-%c\"."), "ipptool", *opt); in main()
654 if (data.vars->uri) in main()
671 if (data.vars->username[0] && data.vars->password) in main()
680 if (!data.vars->uri) in main()
693 snprintf(testname, sizeof(testname), "%s/ipptool/%s", cg->cups_datadir, argv[i]); in main()
712 if (!data.vars->uri || !testfile) in main()
727 repeat --; in main()
759 * 'add_stringf()' - Add a formatted string to an array.
763 add_stringf(cups_array_t *a, /* I - Array */ in add_stringf()
764 const char *s, /* I - Printf-style format string */ in add_stringf()
765 ...) /* I - Additional args as needed */ in add_stringf()
795 * 'compare_uris()' - Compare two URIs...
798 static int /* O - Result of comparison */
799 compare_uris(const char *a, /* I - First URI */ in compare_uris()
800 const char *b) /* I - Second URI */ in compare_uris()
821 return (-1); in compare_uris()
824 return (-1); in compare_uris()
830 if ((ptr = ahost + strlen(ahost) - 1) > ahost && *ptr == '.') in compare_uris()
833 if ((ptr = bhost + strlen(bhost) - 1) > bhost && *ptr == '.') in compare_uris()
850 return (aport - bport); in compare_uris()
860 * 'copy_hex_string()' - Copy an octetString to a C string and encode as hex if
865 copy_hex_string(char *buffer, /* I - String buffer */ in copy_hex_string()
866 unsigned char *data, /* I - octetString data */ in copy_hex_string()
867 int datalen, /* I - octetString length */ in copy_hex_string()
868 size_t bufsize) /* I - Size of string buffer */ in copy_hex_string()
871 *bufend = buffer + bufsize - 2; in copy_hex_string()
881 * First see if there are any non-ASCII bytes in the octetString... in copy_hex_string()
914 datalen = (int)bufsize - 1; in copy_hex_string()
923 * 'do_monitor_printer_state()' - Do the MONITOR-PRINTER-STATE tests in the background.
926 static void * // O - Thread exit status
928 ipptool_test_t *data) // I - Test data in do_monitor_printer_state()
949 …if (httpSeparateURI(HTTP_URI_CODING_ALL, data->monitor_uri, scheme, sizeof(scheme), userpass, size… in do_monitor_printer_state()
951 print_fatal_error(data, "Bad printer URI \"%s\".", data->monitor_uri); in do_monitor_printer_state()
958 encryption = data->encryption; in do_monitor_printer_state()
960 if ((http = httpConnect2(host, port, NULL, data->family, encryption, 1, 30000, NULL)) == NULL) in do_monitor_printer_state()
962 …print_fatal_error(data, "Unable to connect to \"%s\" on port %d - %s", host, port, cupsLastErrorSt… in do_monitor_printer_state()
972 if (data->timeout > 0.0) in do_monitor_printer_state()
973 httpSetTimeout(http, data->timeout, timeout_cb, NULL); in do_monitor_printer_state()
976 if (data->monitor_delay) in do_monitor_printer_state()
977 usleep(data->monitor_delay); in do_monitor_printer_state()
981 ippSetRequestId(request, data->request_id * 100 - 1); in do_monitor_printer_state()
982 ippSetVersion(request, data->version / 10, data->version % 10); in do_monitor_printer_state()
983 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, data->monitor_uri); in do_monitor_printer_state()
984 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME, "requesting-user-name", NULL, cupsUser()); in do_monitor_printer_state()
986 …for (i = data->num_monitor_expects, expect = data->monitor_expects, num_pattrs = 0; i > 0; i --, e… in do_monitor_printer_state()
991 if (!strcmp(expect->name, pattrs[j])) in do_monitor_printer_state()
996 pattrs[num_pattrs ++] = expect->name; in do_monitor_printer_state()
1000 …ippAddStrings(request, IPP_TAG_OPERATION, IPP_CONST_TAG(IPP_TAG_KEYWORD), "requested-attributes", … in do_monitor_printer_state()
1003 while (!data->monitor_done && !Cancel) in do_monitor_printer_state()
1014 …if (!data->monitor_done && !Cancel && status == HTTP_STATUS_ERROR && httpError(data->http) != EINV… in do_monitor_printer_state()
1016 httpError(data->http) != WSAETIMEDOUT) in do_monitor_printer_state()
1018 httpError(data->http) != ETIMEDOUT) in do_monitor_printer_state()
1038 for (i = data->num_monitor_expects, expect = data->monitor_expects; i > 0; i --, expect ++) in do_monitor_printer_state()
1040 if (expect->if_defined && !_ippVarsGet(data->vars, expect->if_defined)) in do_monitor_printer_state()
1043 if (expect->if_not_defined && _ippVarsGet(data->vars, expect->if_not_defined)) in do_monitor_printer_state()
1046 found = ippFindAttribute(response, expect->name, IPP_TAG_ZERO); in do_monitor_printer_state()
1048 if ((found && expect->not_expect) || in do_monitor_printer_state()
1049 (!found && !(expect->not_expect || expect->optional)) || in do_monitor_printer_state()
1051 (expect->in_group && ippGetGroupTag(found) != expect->in_group) || in do_monitor_printer_state()
1052 (expect->with_distinct && !with_distinct_values(NULL, found))) in do_monitor_printer_state()
1054 if (expect->define_no_match) in do_monitor_printer_state()
1056 _ippVarsSet(data->vars, expect->define_no_match, "1"); in do_monitor_printer_state()
1057 data->monitor_done = 1; in do_monitor_printer_state()
1065 …if (found && !with_value(data, NULL, expect->with_value, expect->with_flags, found, buffer, sizeof… in do_monitor_printer_state()
1067 if (expect->define_no_match) in do_monitor_printer_state()
1069 _ippVarsSet(data->vars, expect->define_no_match, "1"); in do_monitor_printer_state()
1070 data->monitor_done = 1; in do_monitor_printer_state()
1075 if (found && expect->count > 0 && ippGetCount(found) != expect->count) in do_monitor_printer_state()
1077 if (expect->define_no_match) in do_monitor_printer_state()
1079 _ippVarsSet(data->vars, expect->define_no_match, "1"); in do_monitor_printer_state()
1080 data->monitor_done = 1; in do_monitor_printer_state()
1085 …if (found && expect->display_match && (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPP… in do_monitor_printer_state()
1086 …cupsFilePrintf(cupsFileStdout(), "CONT]\n\n%s\n\n %-68.68s [", expect->display_match, data->nam… in do_monitor_printer_state()
1088 if (found && expect->define_match) in do_monitor_printer_state()
1090 _ippVarsSet(data->vars, expect->define_match, "1"); in do_monitor_printer_state()
1091 data->monitor_done = 1; in do_monitor_printer_state()
1094 if (found && expect->define_value) in do_monitor_printer_state()
1096 if (!expect->with_value) in do_monitor_printer_state()
1098 int last = ippGetCount(found) - 1; in do_monitor_printer_state()
1134 _ippVarsSet(data->vars, expect->define_value, buffer); in do_monitor_printer_state()
1135 data->monitor_done = 1; in do_monitor_printer_state()
1140 data->monitor_done = 1; // All tests passed in do_monitor_printer_state()
1146 if (data->monitor_done || Cancel) in do_monitor_printer_state()
1149 usleep(data->monitor_interval); in do_monitor_printer_state()
1162 * 'do_test()' - Do a single test from the test file.
1165 static int /* O - 1 on success, 0 on failure */
1166 do_test(_ipp_file_t *f, /* I - IPP data file */ in do_test()
1167 ipptool_test_t *data) /* I - Test data */ in do_test()
1198 if (data->pause[0]) in do_test()
1200 if (!data->skip_test && !data->pass_test) in do_test()
1201 pause_message(data->pause); in do_test()
1203 data->pause[0] = '\0'; in do_test()
1210 if (data->monitor_uri) in do_test()
1212 data->monitor_done = 0; in do_test()
1213 data->monitor_thread = _cupsThreadCreate((_cups_thread_func_t)do_monitor_printer_state, data); in do_test()
1220 request = f->attrs; in do_test()
1221 f->attrs = NULL; in do_test()
1227 data->test_count ++; in do_test()
1229 ippSetVersion(request, data->version / 10, data->version % 10); in do_test()
1230 ippSetRequestId(request, data->request_id); in do_test()
1232 if (data->output == IPPTOOL_OUTPUT_PLIST) in do_test()
1234 cupsFilePuts(data->outfile, "<dict>\n"); in do_test()
1235 cupsFilePuts(data->outfile, "<key>Name</key>\n"); in do_test()
1236 print_xml_string(data->outfile, "string", data->name); in do_test()
1237 if (data->file_id[0]) in do_test()
1239 cupsFilePuts(data->outfile, "<key>FileId</key>\n"); in do_test()
1240 print_xml_string(data->outfile, "string", data->file_id); in do_test()
1242 if (data->test_id[0]) in do_test()
1244 cupsFilePuts(data->outfile, "<key>TestId</key>\n"); in do_test()
1245 print_xml_string(data->outfile, "string", data->test_id); in do_test()
1247 cupsFilePuts(data->outfile, "<key>Version</key>\n"); in do_test()
1248 … cupsFilePrintf(data->outfile, "<string>%d.%d</string>\n", data->version / 10, data->version % 10); in do_test()
1249 cupsFilePuts(data->outfile, "<key>Operation</key>\n"); in do_test()
1250 print_xml_string(data->outfile, "string", ippOpString(ippGetOperation(request))); in do_test()
1251 cupsFilePuts(data->outfile, "<key>RequestId</key>\n"); in do_test()
1252 cupsFilePrintf(data->outfile, "<integer>%d</integer>\n", data->request_id); in do_test()
1253 cupsFilePuts(data->outfile, "<key>RequestAttributes</key>\n"); in do_test()
1254 cupsFilePuts(data->outfile, "<array>\n"); in do_test()
1257 cupsFilePuts(data->outfile, "<dict>\n"); in do_test()
1259 print_attr(data->outfile, data->output, attrptr, &group); in do_test()
1260 cupsFilePuts(data->outfile, "</dict>\n"); in do_test()
1262 cupsFilePuts(data->outfile, "</array>\n"); in do_test()
1265 …if (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPPTOOL_OUTPUT_PLIST && data->outfile … in do_test()
1267 if (data->verbosity) in do_test()
1275 cupsFilePrintf(cupsFileStdout(), " %-68.68s [", data->name); in do_test()
1278 if ((data->skip_previous && !data->prev_pass) || data->skip_test || data->pass_test) in do_test()
1280 if (!data->pass_test) in do_test()
1281 data->skip_count ++; in do_test()
1287 if (data->output == IPPTOOL_OUTPUT_PLIST) in do_test()
1289 cupsFilePuts(data->outfile, "<key>Successful</key>\n"); in do_test()
1290 cupsFilePuts(data->outfile, "<true />\n"); in do_test()
1291 cupsFilePuts(data->outfile, "<key>Skipped</key>\n"); in do_test()
1292 if (data->pass_test) in do_test()
1293 cupsFilePuts(data->outfile, "<false />\n"); in do_test()
1295 cupsFilePuts(data->outfile, "<true />\n"); in do_test()
1296 cupsFilePuts(data->outfile, "<key>StatusCode</key>\n"); in do_test()
1297 if (data->pass_test) in do_test()
1298 print_xml_string(data->outfile, "string", "pass"); in do_test()
1300 print_xml_string(data->outfile, "string", "skip"); in do_test()
1301 cupsFilePuts(data->outfile, "<key>ResponseAttributes</key>\n"); in do_test()
1302 cupsFilePuts(data->outfile, "<dict />\n"); in do_test()
1305 …if (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPPTOOL_OUTPUT_PLIST && data->outfile … in do_test()
1307 if (data->pass_test) in do_test()
1316 data->vars->password_tries = 0; in do_test()
1320 if (data->delay > 0) in do_test()
1321 usleep(data->delay); in do_test()
1323 data->delay = data->repeat_interval; in do_test()
1328 …if (data->transfer == IPPTOOL_TRANSFER_CHUNKED || (data->transfer == IPPTOOL_TRANSFER_AUTO && data in do_test()
1331 * Send request using chunking - a 0 length means "chunk". in do_test()
1344 if (data->file[0] && (reqfile = cupsFileOpen(data->file, "r")) != NULL) in do_test()
1361 data->prev_pass = 1; in do_test()
1367 while (!response && !Cancel && data->prev_pass) in do_test()
1369 ippSetRequestId(request, ++ data->request_id); in do_test()
1371 status = cupsSendRequest(data->http, request, data->resource, length); in do_test()
1374 if (data->compression[0]) in do_test()
1375 httpSetField(data->http, HTTP_FIELD_CONTENT_ENCODING, data->compression); in do_test()
1378 if (!Cancel && status == HTTP_STATUS_CONTINUE && ippGetState(request) == IPP_DATA && data->file[0]) in do_test()
1380 if ((reqfile = cupsFileOpen(data->file, "r")) != NULL) in do_test()
1384 … if ((status = cupsWriteRequestData(data->http, buffer, (size_t)bytes)) != HTTP_STATUS_CONTINUE) in do_test()
1392 snprintf(buffer, sizeof(buffer), "%s: %s", data->file, strerror(errno)); in do_test()
1405 response = cupsGetResponse(data->http, data->resource); in do_test()
1406 status = httpGetStatus(data->http); in do_test()
1409 if (!Cancel && status == HTTP_STATUS_ERROR && httpError(data->http) != EINVAL && in do_test()
1411 httpError(data->http) != WSAETIMEDOUT) in do_test()
1413 httpError(data->http) != ETIMEDOUT) in do_test()
1416 if (httpReconnect2(data->http, 30000, NULL)) in do_test()
1417 data->prev_pass = 0; in do_test()
1421 data->prev_pass = 0; in do_test()
1426 httpFlush(data->http); in do_test()
1436 if (!Cancel && status == HTTP_STATUS_ERROR && httpError(data->http) != EINVAL && in do_test()
1438 httpError(data->http) != WSAETIMEDOUT) in do_test()
1440 httpError(data->http) != ETIMEDOUT) in do_test()
1443 if (httpReconnect2(data->http, 30000, NULL)) in do_test()
1444 data->prev_pass = 0; in do_test()
1449 httpReconnect2(data->http, 30000, NULL); in do_test()
1451 data->prev_pass = 0; in do_test()
1455 httpFlush(data->http); in do_test()
1456 data->prev_pass = 0; in do_test()
1463 cupsArrayClear(data->errors); in do_test()
1465 if (httpGetVersion(data->http) != HTTP_1_1) in do_test()
1467 int version = (int)httpGetVersion(data->http); in do_test()
1469 add_stringf(data->errors, "Bad HTTP version (%d.%d)", version / 100, version % 100); in do_test()
1472 if (data->validate_headers) in do_test()
1476 …if ((header = httpGetField(data->http, HTTP_FIELD_CONTENT_TYPE)) == NULL || _cups_strcasecmp(heade… in do_test()
1477 …add_stringf(data->errors, "Bad HTTP Content-Type in response (%s)", header && *header ? header : "… in do_test()
1479 …if ((header = httpGetField(data->http, HTTP_FIELD_DATE)) != NULL && *header && httpGetDateTime(hea… in do_test()
1480 add_stringf(data->errors, "Bad HTTP Date in response (%s)", header); in do_test()
1489 …add_stringf(data->errors, "IPP request failed with status %s (%s)", ippErrorString(cupsLastError()… in do_test()
1497 if ((attrptr = ippFindAttribute(response, "job-id", IPP_TAG_INTEGER)) != NULL) in do_test()
1500 _ippVarsSet(data->vars, "job-id", temp); in do_test()
1503 if ((attrptr = ippFindAttribute(response, "job-uri", IPP_TAG_URI)) != NULL) in do_test()
1504 _ippVarsSet(data->vars, "job-uri", ippGetString(attrptr, 0, NULL)); in do_test()
1506 if ((attrptr = ippFindAttribute(response, "notify-subscription-id", IPP_TAG_INTEGER)) != NULL) in do_test()
1509 _ippVarsSet(data->vars, "notify-subscription-id", temp); in do_test()
1518 add_stringf(data->errors, "Missing end-of-attributes-tag in response (RFC 2910 section 3.5.1)"); in do_test()
1520 if (data->version) in do_test()
1526 if (major != (data->version / 10) || minor != (data->version % 10)) in do_test()
1527 …d_stringf(data->errors, "Bad version %d.%d in response - expected %d.%d (RFC 8011 section 4.1.8)."… in do_test()
1530 if (ippGetRequestId(response) != data->request_id) in do_test()
1531 …add_stringf(data->errors, "Bad request ID %d in response - expected %d (RFC 8011 section 4.1.1)", … in do_test()
1536 …add_stringf(data->errors, "Missing first attribute \"attributes-charset (charset)\" in group opera… in do_test()
1540 …IPP_TAG_OPERATION || ippGetCount(attrptr) != 1 ||strcmp(ippGetName(attrptr), "attributes-charset")) in do_test()
1541 …tringf(data->errors, "Bad first attribute \"%s (%s%s)\" in group %s, expected \"attributes-charset… in do_test()
1545 …add_stringf(data->errors, "Missing second attribute \"attributes-natural-language (naturalLanguage… in do_test()
1546 …ERATION || ippGetCount(attrptr) != 1 || strcmp(ippGetName(attrptr), "attributes-natural-language")) in do_test()
1547 …ata->errors, "Bad first attribute \"%s (%s%s)\" in group %s, expected \"attributes-natural-languag… in do_test()
1550 if ((attrptr = ippFindAttribute(response, "status-message", IPP_TAG_ZERO)) != NULL) in do_test()
1556 …add_stringf(data->errors, "status-message (text(255)) has wrong value tag %s (RFC 8011 section 4.1… in do_test()
1558 …add_stringf(data->errors, "status-message (text(255)) has wrong group tag %s (RFC 8011 section 4.1… in do_test()
1560 …add_stringf(data->errors, "status-message (text(255)) has %d values (RFC 8011 section 4.1.6.2).", … in do_test()
1562 …add_stringf(data->errors, "status-message (text(255)) has bad length %d (RFC 8011 section 4.1.6.2)… in do_test()
1565 if ((attrptr = ippFindAttribute(response, "detailed-status-message", in do_test()
1572 …add_stringf(data->errors, "detailed-status-message (text(MAX)) has wrong value tag %s (RFC 8011 se… in do_test()
1574 …add_stringf(data->errors, "detailed-status-message (text(MAX)) has wrong group tag %s (RFC 8011 se… in do_test()
1576 …add_stringf(data->errors, "detailed-status-message (text(MAX)) has %d values (RFC 8011 section 4.1… in do_test()
1578 …add_stringf(data->errors, "detailed-status-message (text(MAX)) has bad length %d (RFC 8011 section… in do_test()
1589 int out_of_order = 0; /* Are attribute groups out-of-order? */ in do_test()
1624 …add_stringf(data->errors, "Attribute groups out of order (%s < %s)", ippTagString(ippGetGroupTag(a… in do_test()
1631 cupsArrayAdd(data->errors, (void *)cupsLastErrorString()); in do_test()
1635 if (cupsArrayFind(a, (void *)ippGetName(attrptr)) && data->output < IPPTOOL_OUTPUT_LIST) in do_test()
1636 …add_stringf(data->errors, "Duplicate \"%s\" attribute in %s group", ippGetName(attrptr), ippTagStr… in do_test()
1645 * Now check the test-defined expected status-code and attribute in do_test()
1649 if (ippGetStatusCode(response) == IPP_STATUS_ERROR_BUSY && data->repeat_on_busy) in do_test()
1651 // Repeat on a server-error-busy status code... in do_test()
1657 for (i = 0, status_ok = 0; i < data->num_statuses; i ++) in do_test()
1659 if (data->statuses[i].if_defined && in do_test()
1660 !_ippVarsGet(data->vars, data->statuses[i].if_defined)) in do_test()
1663 if (data->statuses[i].if_not_defined && in do_test()
1664 _ippVarsGet(data->vars, data->statuses[i].if_not_defined)) in do_test()
1667 if (ippGetStatusCode(response) == data->statuses[i].status) in do_test()
1671 if (data->statuses[i].repeat_match && repeat_count < data->statuses[i].repeat_limit) in do_test()
1674 if (data->statuses[i].define_match) in do_test()
1675 _ippVarsSet(data->vars, data->statuses[i].define_match, "1"); in do_test()
1679 if (data->statuses[i].repeat_no_match && repeat_count < data->statuses[i].repeat_limit) in do_test()
1682 if (data->statuses[i].define_no_match) in do_test()
1684 _ippVarsSet(data->vars, data->statuses[i].define_no_match, "1"); in do_test()
1691 if (!status_ok && data->num_statuses > 0) in do_test()
1693 for (i = 0; i < data->num_statuses; i ++) in do_test()
1695 if (data->statuses[i].if_defined && in do_test()
1696 !_ippVarsGet(data->vars, data->statuses[i].if_defined)) in do_test()
1699 if (data->statuses[i].if_not_defined && in do_test()
1700 _ippVarsGet(data->vars, data->statuses[i].if_not_defined)) in do_test()
1703 if (!data->statuses[i].repeat_match || repeat_count >= data->statuses[i].repeat_limit) in do_test()
1704 …add_stringf(data->errors, "EXPECTED: STATUS %s (got %s)", ippErrorString(data->statuses[i].status)… in do_test()
1707 if ((attrptr = ippFindAttribute(response, "status-message", IPP_TAG_TEXT)) != NULL) in do_test()
1708 add_stringf(data->errors, "status-message=\"%s\"", ippGetString(attrptr, 0, NULL)); in do_test()
1711 for (i = data->num_expects, expect = data->expects; i > 0; i --, expect ++) in do_test()
1715 if (expect->if_defined && !_ippVarsGet(data->vars, expect->if_defined)) in do_test()
1718 if (expect->if_not_defined && in do_test()
1719 _ippVarsGet(data->vars, expect->if_not_defined)) in do_test()
1722 …if ((found = ippFindAttribute(response, expect->name, IPP_TAG_ZERO)) != NULL && expect->in_group &… in do_test()
1724 while ((found = ippFindNextAttribute(response, expect->name, IPP_TAG_ZERO)) != NULL) in do_test()
1725 if (expect->in_group == ippGetGroupTag(found)) in do_test()
1733 if (expect->in_group && strchr(expect->name, '/')) in do_test()
1738 strlcpy(group_name, expect->name, sizeof(group_name)); in do_test()
1745 if ((found && expect->not_expect) || in do_test()
1746 (!found && !(expect->not_expect || expect->optional)) || in do_test()
1748 (group_found && expect->in_group && ippGetGroupTag(group_found) != expect->in_group) || in do_test()
1749 (expect->with_distinct && !with_distinct_values(NULL, found))) in do_test()
1751 if (expect->define_no_match) in do_test()
1752 _ippVarsSet(data->vars, expect->define_no_match, "1"); in do_test()
1753 else if (!expect->define_match && !expect->define_value) in do_test()
1755 if (found && expect->not_expect && !expect->with_value && !expect->with_value_from) in do_test()
1756 add_stringf(data->errors, "NOT EXPECTED: %s", expect->name); in do_test()
1757 else if (!found && !(expect->not_expect || expect->optional)) in do_test()
1758 add_stringf(data->errors, "EXPECTED: %s", expect->name); in do_test()
1762 add_stringf(data->errors, "EXPECTED: %s OF-TYPE %s (got %s)", in do_test()
1763 expect->name, expect->of_type, in do_test()
1766 if (expect->in_group && ippGetGroupTag(group_found) != expect->in_group) in do_test()
1767 add_stringf(data->errors, "EXPECTED: %s IN-GROUP %s (got %s).", in do_test()
1768 expect->name, ippTagString(expect->in_group), in do_test()
1771 if (expect->with_distinct) in do_test()
1772 with_distinct_values(data->errors, found); in do_test()
1776 if (expect->repeat_no_match && repeat_count < expect->repeat_limit) in do_test()
1784 …if (found && expect->with_value_from && !with_value_from(NULL, ippFindAttribute(response, expect->… in do_test()
1786 if (expect->define_no_match) in do_test()
1787 _ippVarsSet(data->vars, expect->define_no_match, "1"); in do_test()
1788 …lse if (!expect->define_match && !expect->define_value && ((!expect->repeat_match && !expect->repe… in do_test()
1790 …add_stringf(data->errors, "EXPECTED: %s WITH-VALUES-FROM %s", expect->name, expect->with_value_fro… in do_test()
1792 …with_value_from(data->errors, ippFindAttribute(response, expect->with_value_from, IPP_TAG_ZERO), f… in do_test()
1795 if (expect->repeat_no_match && repeat_count < expect->repeat_limit) in do_test()
1800 …else if (found && !with_value(data, NULL, expect->with_value, expect->with_flags, found, buffer, s… in do_test()
1802 if (expect->define_no_match) in do_test()
1803 _ippVarsSet(data->vars, expect->define_no_match, "1"); in do_test()
1804 else if (!expect->define_match && !expect->define_value && in do_test()
1805 !expect->repeat_match && (!expect->repeat_no_match || repeat_count >= expect->repeat_limit)) in do_test()
1807 if (expect->with_flags & IPPTOOL_WITH_REGEX) in do_test()
1808 …add_stringf(data->errors, "EXPECTED: %s %s /%s/", expect->name, with_flags_string(expect->with_fla… in do_test()
1810 …add_stringf(data->errors, "EXPECTED: %s %s \"%s\"", expect->name, with_flags_string(expect->with_f… in do_test()
1812 …with_value(data, data->errors, expect->with_value, expect->with_flags, found, buffer, sizeof(buffe… in do_test()
1815 if (expect->repeat_no_match && in do_test()
1816 repeat_count < expect->repeat_limit) in do_test()
1822 if (found && expect->count > 0 && ippGetCount(found) != expect->count) in do_test()
1824 if (expect->define_no_match) in do_test()
1825 _ippVarsSet(data->vars, expect->define_no_match, "1"); in do_test()
1826 else if (!expect->define_match && !expect->define_value) in do_test()
1828 …add_stringf(data->errors, "EXPECTED: %s COUNT %d (got %d)", expect->name, expect->count, ippGetCou… in do_test()
1831 if (expect->repeat_no_match && in do_test()
1832 repeat_count < expect->repeat_limit) in do_test()
1838 if (found && expect->same_count_as) in do_test()
1840 attrptr = ippFindAttribute(response, expect->same_count_as, in do_test()
1845 if (expect->define_no_match) in do_test()
1846 _ippVarsSet(data->vars, expect->define_no_match, "1"); in do_test()
1847 else if (!expect->define_match && !expect->define_value) in do_test()
1850 …add_stringf(data->errors, "EXPECTED: %s (%d values) SAME-COUNT-AS %s (not returned)", expect->name… in do_test()
1852 …add_stringf(data->errors, "EXPECTED: %s (%d values) SAME-COUNT-AS %s (%d values)", expect->name, i… in do_test()
1855 if (expect->repeat_no_match && in do_test()
1856 repeat_count < expect->repeat_limit) in do_test()
1863 …if (found && expect->display_match && (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPP… in do_test()
1864 cupsFilePrintf(cupsFileStdout(), "\n%s\n\n", expect->display_match); in do_test()
1866 if (found && expect->define_match) in do_test()
1867 _ippVarsSet(data->vars, expect->define_match, "1"); in do_test()
1869 if (found && expect->define_value) in do_test()
1871 if (!expect->with_value) in do_test()
1873 int last = ippGetCount(found) - 1; in do_test()
1924 _ippVarsSet(data->vars, expect->define_value, buffer); in do_test()
1927 if (found && expect->repeat_match && in do_test()
1928 repeat_count < expect->repeat_limit) in do_test()
1931 …while (expect->expect_all && (found = ippFindNextAttribute(response, expect->name, IPP_TAG_ZERO)) … in do_test()
1941 …if (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPPTOOL_OUTPUT_PLIST && data->outfile … in do_test()
1945 if (data->num_displayed > 0) in do_test()
1952 for (i = 0; i < data->num_displayed; i ++) in do_test()
1954 if (!strcmp(data->displayed[i], attrname)) in do_test()
1965 …if (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPPTOOL_OUTPUT_PLIST && data->outfile … in do_test()
1967 cupsFilePrintf(cupsFileStdout(), " %-68.68s [", data->name); in do_test()
1980 if (cupsArrayCount(data->errors) > 0) in do_test()
1981 data->prev_pass = data->pass = 0; in do_test()
1983 if (data->prev_pass) in do_test()
1984 data->pass_count ++; in do_test()
1986 data->fail_count ++; in do_test()
1988 if (data->output == IPPTOOL_OUTPUT_PLIST) in do_test()
1990 cupsFilePuts(data->outfile, "<key>Successful</key>\n"); in do_test()
1991 cupsFilePuts(data->outfile, data->prev_pass ? "<true />\n" : "<false />\n"); in do_test()
1992 cupsFilePuts(data->outfile, "<key>StatusCode</key>\n"); in do_test()
1993 print_xml_string(data->outfile, "string", ippErrorString(cupsLastError())); in do_test()
1994 cupsFilePuts(data->outfile, "<key>ResponseAttributes</key>\n"); in do_test()
1995 cupsFilePuts(data->outfile, "<array>\n"); in do_test()
1996 cupsFilePuts(data->outfile, "<dict>\n"); in do_test()
2000 print_attr(data->outfile, data->output, attrptr, &group); in do_test()
2001 cupsFilePuts(data->outfile, "</dict>\n"); in do_test()
2002 cupsFilePuts(data->outfile, "</array>\n"); in do_test()
2004 else if (data->output == IPPTOOL_OUTPUT_IPPSERVER && response) in do_test()
2014 else if (data->output == IPPTOOL_OUTPUT_JSON && response) in do_test()
2019 cupsFilePuts(data->outfile, "[\n"); in do_test()
2030 cupsFilePuts(data->outfile, " },\n"); in do_test()
2032 … cupsFilePrintf(data->outfile, " {\n \"group-tag\": \"%s\",\n", ippTagString(group_tag)); in do_test()
2038 …cupsFilePuts(data->outfile, ippGetName(attrptr) && ippGetGroupTag(attrptr) == cur_tag ? ",\n" : "\… in do_test()
2047 cupsFilePuts(data->outfile, " }\n"); in do_test()
2048 cupsFilePuts(data->outfile, "]\n"); in do_test()
2051 …if (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPPTOOL_OUTPUT_PLIST && data->outfile … in do_test()
2053 cupsFilePuts(cupsFileStdout(), data->prev_pass ? "PASS]\n" : "FAIL]\n"); in do_test()
2055 if (!data->prev_pass || (data->verbosity && response)) in do_test()
2058 …cupsFilePrintf(cupsFileStdout(), " status-code = %s (%s)\n", ippErrorString(cupsLastError()… in do_test()
2060 if (data->verbosity && response) in do_test()
2067 else if (!data->prev_pass && data->output != IPPTOOL_OUTPUT_QUIET) in do_test()
2070 …if (data->prev_pass && data->output >= IPPTOOL_OUTPUT_LIST && !data->verbosity && data->num_displa… in do_test()
2074 for (i = 0; i < data->num_displayed; i ++) in do_test()
2076 widths[i] = strlen(data->displayed[i]); in do_test()
2078 for (attrptr = ippFindAttribute(response, data->displayed[i], IPP_TAG_ZERO); in do_test()
2080 attrptr = ippFindNextAttribute(response, data->displayed[i], IPP_TAG_ZERO)) in do_test()
2088 if (data->output == IPPTOOL_OUTPUT_CSV) in do_test()
2089 print_csv(data, NULL, NULL, data->num_displayed, data->displayed, widths); in do_test()
2091 print_line(data, NULL, NULL, data->num_displayed, data->displayed, widths); in do_test()
2102 if (data->output == IPPTOOL_OUTPUT_CSV) in do_test()
2103 attrptr = print_csv(data, response, attrptr, data->num_displayed, data->displayed, widths); in do_test()
2105 attrptr = print_line(data, response, attrptr, data->num_displayed, data->displayed, widths); in do_test()
2112 else if (!data->prev_pass) in do_test()
2114 if (data->output == IPPTOOL_OUTPUT_PLIST) in do_test()
2116 cupsFilePuts(data->outfile, "<key>Errors</key>\n"); in do_test()
2117 cupsFilePuts(data->outfile, "<array>\n"); in do_test()
2119 for (error = (char *)cupsArrayFirst(data->errors); in do_test()
2121 error = (char *)cupsArrayNext(data->errors)) in do_test()
2122 print_xml_string(data->outfile, "string", error); in do_test()
2124 cupsFilePuts(data->outfile, "</array>\n"); in do_test()
2127 …if (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPPTOOL_OUTPUT_PLIST && data->outfile … in do_test()
2129 for (error = (char *)cupsArrayFirst(data->errors); in do_test()
2131 error = (char *)cupsArrayNext(data->errors)) in do_test()
2136 … (data->num_displayed > 0 && !data->verbosity && response && (data->output == IPPTOOL_OUTPUT_TEST … in do_test()
2142 for (i = 0; i < data->num_displayed; i ++) in do_test()
2144 if (!strcmp(data->displayed[i], ippGetName(attrptr))) in do_test()
2146 print_attr(data->outfile, data->output, attrptr, NULL); in do_test()
2156 if (data->monitor_thread) in do_test()
2158 data->monitor_done = 1; in do_test()
2159 _cupsThreadWait(data->monitor_thread); in do_test()
2162 if (data->output == IPPTOOL_OUTPUT_PLIST) in do_test()
2163 cupsFilePuts(data->outfile, "</dict>\n"); in do_test()
2168 for (i = 0; i < data->num_statuses; i ++) in do_test()
2170 free(data->statuses[i].if_defined); in do_test()
2171 free(data->statuses[i].if_not_defined); in do_test()
2172 free(data->statuses[i].define_match); in do_test()
2173 free(data->statuses[i].define_no_match); in do_test()
2175 data->num_statuses = 0; in do_test()
2177 for (i = data->num_expects, expect = data->expects; i > 0; i --, expect ++) in do_test()
2179 free(expect->name); in do_test()
2180 free(expect->of_type); in do_test()
2181 free(expect->same_count_as); in do_test()
2182 free(expect->if_defined); in do_test()
2183 free(expect->if_not_defined); in do_test()
2184 free(expect->with_value); in do_test()
2185 free(expect->define_match); in do_test()
2186 free(expect->define_no_match); in do_test()
2187 free(expect->define_value); in do_test()
2188 free(expect->display_match); in do_test()
2190 data->num_expects = 0; in do_test()
2192 for (i = 0; i < data->num_displayed; i ++) in do_test()
2193 free(data->displayed[i]); in do_test()
2194 data->num_displayed = 0; in do_test()
2196 free(data->monitor_uri); in do_test()
2197 data->monitor_uri = NULL; in do_test()
2199 for (i = data->num_monitor_expects, expect = data->monitor_expects; i > 0; i --, expect ++) in do_test()
2201 free(expect->name); in do_test()
2202 free(expect->of_type); in do_test()
2203 free(expect->same_count_as); in do_test()
2204 free(expect->if_defined); in do_test()
2205 free(expect->if_not_defined); in do_test()
2206 free(expect->with_value); in do_test()
2207 free(expect->define_match); in do_test()
2208 free(expect->define_no_match); in do_test()
2209 free(expect->define_value); in do_test()
2210 free(expect->display_match); in do_test()
2212 data->num_monitor_expects = 0; in do_test()
2214 return (data->ignore_errors || data->prev_pass); in do_test()
2219 * 'do_tests()' - Do tests as specified in the test file.
2222 static int /* O - 1 on success, 0 on failure */
2223 do_tests(const char *testfile, /* I - Test file to use */ in do_tests()
2224 ipptool_test_t *data) /* I - Test data */ in do_tests()
2233 …if (!_cups_strcasecmp(data->vars->scheme, "https") || !_cups_strcasecmp(data->vars->scheme, "ipps"… in do_tests()
2236 encryption = data->encryption; in do_tests()
2238 …if ((data->http = httpConnect2(data->vars->host, data->vars->port, NULL, data->family, encryption,… in do_tests()
2240 …fatal_error(data, "Unable to connect to \"%s\" on port %d - %s", data->vars->host, data->vars->por… in do_tests()
2245 httpSetDefaultField(data->http, HTTP_FIELD_ACCEPT_ENCODING, "deflate, gzip, identity"); in do_tests()
2247 httpSetDefaultField(data->http, HTTP_FIELD_ACCEPT_ENCODING, "identity"); in do_tests()
2250 if (data->timeout > 0.0) in do_tests()
2251 httpSetTimeout(data->http, data->timeout, timeout_cb, NULL); in do_tests()
2257 _ippFileParse(data->vars, testfile, (void *)data); in do_tests()
2263 httpClose(data->http); in do_tests()
2264 data->http = NULL; in do_tests()
2266 return (data->pass); in do_tests()
2271 * 'error_cb()' - Print/add an error message.
2274 static int /* O - 1 to continue, 0 to stop */
2275 error_cb(_ipp_file_t *f, /* I - IPP file data */ in error_cb()
2276 ipptool_test_t *data, /* I - Test data */ in error_cb()
2277 const char *error) /* I - Error message */ in error_cb()
2288 * 'expect_matches()' - Return true if the tag matches the specification.
2291 static int /* O - 1 if matches, 0 otherwise */
2293 ipptool_expect_t *expect, /* I - Expected attribute */ in expect_matches()
2294 ipp_attribute_t *attr) /* I - Attribute */ in expect_matches()
2311 if (!expect->of_type) in expect_matches()
2322 for (of_type = expect->of_type, match = 0; !match && *of_type; of_type = next) in expect_matches()
2334 * Support some meta-types to make it easier to write the test file. in expect_matches()
2494 * 'get_filename()' - Get a filename based on the current test file.
2497 static char * /* O - Filename */
2498 get_filename(const char *testfile, /* I - Current test file */ in get_filename()
2499 char *dst, /* I - Destination filename */ in get_filename()
2500 const char *src, /* I - Source filename */ in get_filename()
2501 size_t dstsize) /* I - Size of destination buffer */ in get_filename()
2508 if (*src == '<' && src[strlen(src) - 1] == '>') in get_filename()
2514 snprintf(dst, dstsize, "%s/ipptool/%s", cg->cups_datadir, src + 1); in get_filename()
2515 dstptr = dst + strlen(dst) - 1; in get_filename()
2526 * Use the path as-is... in get_filename()
2543 strlcpy(dstptr, src, dstsize - (size_t)(dstptr - dst)); in get_filename()
2566 * 'get_string()' - Get a pointer to a string value or the portion of interest.
2569 static const char * /* O - Pointer to string */
2570 get_string(ipp_attribute_t *attr, /* I - IPP attribute */ in get_string()
2571 int element, /* I - Element to fetch */ in get_string()
2572 int flags, /* I - Value ("with") flags */ in get_string()
2573 char *buffer, /* I - Temporary buffer */ in get_string()
2574 size_t bufsize) /* I - Size of temporary buffer */ in get_string()
2592 ptr = buffer + strlen(buffer) - 1; in get_string()
2630 if ((ptr = hostname + strlen(hostname) - 1) >= hostname && *ptr == '.') in get_string()
2644 * 'init_data()' - Initialize test data.
2648 init_data(ipptool_test_t *data) /* I - Data */ in init_data()
2652 data->output = IPPTOOL_OUTPUT_LIST; in init_data()
2653 data->outfile = cupsFileStdout(); in init_data()
2654 data->family = AF_UNSPEC; in init_data()
2655 data->def_transfer = IPPTOOL_TRANSFER_AUTO; in init_data()
2656 data->def_version = 11; in init_data()
2657 …data->errors = cupsArrayNew3(NULL, NULL, NULL, 0, (cups_acopy_func_t)strdup, (cups_afree_fun… in init_data()
2658 data->pass = 1; in init_data()
2659 data->prev_pass = 1; in init_data()
2660 data->request_id = (CUPS_RAND() % 1000) * 137; in init_data()
2661 data->show_header = 1; in init_data()
2666 * 'iso_date()' - Return an ISO 8601 date/time string for the given IPP dateTime
2670 static char * /* O - ISO 8601 date/time string */
2671 iso_date(const ipp_uchar_t *date) /* I - IPP (RFC 1903) date/time value */ in iso_date()
2681 snprintf(buffer, sizeof(buffer), "%04d-%02d-%02dT%02d:%02d:%02dZ", in iso_date()
2690 * 'parse_monitor_printer_state()' - Parse the MONITOR-PRINTER-STATE directive.
2692 * MONITOR-PRINTER-STATE [printer-uri] {
2694 * EXPECT attribute-name ...
2698 static int /* O - 1 to continue, 0 to stop */
2700 _ipp_file_t *f, /* I - IPP file data */ in parse_monitor_printer_state()
2701 ipptool_test_t *data) /* I - Test data */ in parse_monitor_printer_state()
2712 print_fatal_error(data, "Missing printer URI on line %d of \"%s\".", f->linenum, f->filename); in parse_monitor_printer_state()
2719 _ippVarsExpand(data->vars, value, temp, sizeof(value)); in parse_monitor_printer_state()
2720 data->monitor_uri = strdup(value); in parse_monitor_printer_state()
2725 … print_fatal_error(data, "Missing opening brace on line %d of \"%s\".", f->linenum, f->filename); in parse_monitor_printer_state()
2732 data->monitor_uri = strdup(data->vars->uri); in parse_monitor_printer_state()
2739 _cups_strcasecmp(token, "DEFINE-MATCH") && in parse_monitor_printer_state()
2740 _cups_strcasecmp(token, "DEFINE-NO-MATCH") && in parse_monitor_printer_state()
2741 _cups_strcasecmp(token, "DEFINE-VALUE") && in parse_monitor_printer_state()
2742 _cups_strcasecmp(token, "DISPLAY-MATCH") && in parse_monitor_printer_state()
2743 _cups_strcasecmp(token, "IF-DEFINED") && in parse_monitor_printer_state()
2744 _cups_strcasecmp(token, "IF-NOT-DEFINED") && in parse_monitor_printer_state()
2745 _cups_strcasecmp(token, "IN-GROUP") && in parse_monitor_printer_state()
2746 _cups_strcasecmp(token, "OF-TYPE") && in parse_monitor_printer_state()
2747 _cups_strcasecmp(token, "WITH-DISTINCT-VALUES") && in parse_monitor_printer_state()
2748 _cups_strcasecmp(token, "WITH-VALUE")) in parse_monitor_printer_state()
2749 data->last_expect = NULL; in parse_monitor_printer_state()
2759 …if (data->num_monitor_expects >= (int)(sizeof(data->monitor_expects) / sizeof(data->monitor_expect… in parse_monitor_printer_state()
2761 print_fatal_error(data, "Too many EXPECT's on line %d of \"%s\".", f->linenum, f->filename); in parse_monitor_printer_state()
2767 print_fatal_error(data, "Missing EXPECT name on line %d of \"%s\".", f->linenum, f->filename); in parse_monitor_printer_state()
2771 data->last_expect = data->monitor_expects + data->num_monitor_expects; in parse_monitor_printer_state()
2772 data->num_monitor_expects ++; in parse_monitor_printer_state()
2774 memset(data->last_expect, 0, sizeof(ipptool_expect_t)); in parse_monitor_printer_state()
2775 data->last_expect->repeat_limit = 1000; in parse_monitor_printer_state()
2779 data->last_expect->not_expect = 1; in parse_monitor_printer_state()
2780 data->last_expect->name = strdup(name + 1); in parse_monitor_printer_state()
2784 data->last_expect->optional = 1; in parse_monitor_printer_state()
2785 data->last_expect->name = strdup(name + 1); in parse_monitor_printer_state()
2788 data->last_expect->name = strdup(name); in parse_monitor_printer_state()
2796 print_fatal_error(data, "Missing COUNT number on line %d of \"%s\".", f->linenum, f->filename); in parse_monitor_printer_state()
2802 print_fatal_error(data, "Bad COUNT \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename); in parse_monitor_printer_state()
2806 if (data->last_expect) in parse_monitor_printer_state()
2808 data->last_expect->count = count; in parse_monitor_printer_state()
2812 …print_fatal_error(data, "COUNT without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->f… in parse_monitor_printer_state()
2816 else if (!_cups_strcasecmp(token, "DEFINE-MATCH")) in parse_monitor_printer_state()
2820 …print_fatal_error(data, "Missing DEFINE-MATCH variable on line %d of \"%s\".", f->linenum, f->file… in parse_monitor_printer_state()
2824 if (data->last_expect) in parse_monitor_printer_state()
2826 data->last_expect->define_match = strdup(temp); in parse_monitor_printer_state()
2830 …print_fatal_error(data, "DEFINE-MATCH without a preceding EXPECT on line %d of \"%s\".", f->linenu… in parse_monitor_printer_state()
2834 else if (!_cups_strcasecmp(token, "DEFINE-NO-MATCH")) in parse_monitor_printer_state()
2838 …print_fatal_error(data, "Missing DEFINE-NO-MATCH variable on line %d of \"%s\".", f->linenum, f->f… in parse_monitor_printer_state()
2842 if (data->last_expect) in parse_monitor_printer_state()
2844 data->last_expect->define_no_match = strdup(temp); in parse_monitor_printer_state()
2848 …print_fatal_error(data, "DEFINE-NO-MATCH without a preceding EXPECT on line %d of \"%s\".", f->lin… in parse_monitor_printer_state()
2852 else if (!_cups_strcasecmp(token, "DEFINE-VALUE")) in parse_monitor_printer_state()
2856 …print_fatal_error(data, "Missing DEFINE-VALUE variable on line %d of \"%s\".", f->linenum, f->file… in parse_monitor_printer_state()
2860 if (data->last_expect) in parse_monitor_printer_state()
2862 data->last_expect->define_value = strdup(temp); in parse_monitor_printer_state()
2866 …print_fatal_error(data, "DEFINE-VALUE without a preceding EXPECT on line %d of \"%s\".", f->linenu… in parse_monitor_printer_state()
2870 else if (!_cups_strcasecmp(token, "DISPLAY-MATCH")) in parse_monitor_printer_state()
2874 …print_fatal_error(data, "Missing DISPLAY-MATCH message on line %d of \"%s\".", f->linenum, f->file… in parse_monitor_printer_state()
2878 if (data->last_expect) in parse_monitor_printer_state()
2880 data->last_expect->display_match = strdup(temp); in parse_monitor_printer_state()
2884 …print_fatal_error(data, "DISPLAY-MATCH without a preceding EXPECT on line %d of \"%s\".", f->linen… in parse_monitor_printer_state()
2898 print_fatal_error(data, "Missing DELAY value on line %d of \"%s\".", f->linenum, f->filename); in parse_monitor_printer_state()
2902 _ippVarsExpand(data->vars, value, temp, sizeof(value)); in parse_monitor_printer_state()
2906 …print_fatal_error(data, "Bad DELAY value \"%s\" on line %d of \"%s\".", value, f->linenum, f->file… in parse_monitor_printer_state()
2910 data->monitor_delay = (useconds_t)(1000000.0 * dval); in parse_monitor_printer_state()
2916 …print_fatal_error(data, "Bad DELAY value \"%s\" on line %d of \"%s\".", value, f->linenum, f->file… in parse_monitor_printer_state()
2920 data->monitor_interval = (useconds_t)(1000000.0 * dval); in parse_monitor_printer_state()
2923 data->monitor_interval = data->monitor_delay; in parse_monitor_printer_state()
2925 else if (!_cups_strcasecmp(token, "OF-TYPE")) in parse_monitor_printer_state()
2929 …print_fatal_error(data, "Missing OF-TYPE value tag(s) on line %d of \"%s\".", f->linenum, f->filen… in parse_monitor_printer_state()
2933 if (data->last_expect) in parse_monitor_printer_state()
2935 data->last_expect->of_type = strdup(temp); in parse_monitor_printer_state()
2939 …print_fatal_error(data, "OF-TYPE without a preceding EXPECT on line %d of \"%s\".", f->linenum, f- in parse_monitor_printer_state()
2943 else if (!_cups_strcasecmp(token, "IN-GROUP")) in parse_monitor_printer_state()
2945 ipp_tag_t in_group; /* IN-GROUP value */ in parse_monitor_printer_state()
2949 …print_fatal_error(data, "Missing IN-GROUP group tag on line %d of \"%s\".", f->linenum, f->filenam… in parse_monitor_printer_state()
2955 …print_fatal_error(data, "Bad IN-GROUP group tag \"%s\" on line %d of \"%s\".", temp, f->linenum, f in parse_monitor_printer_state()
2958 else if (data->last_expect) in parse_monitor_printer_state()
2960 data->last_expect->in_group = in_group; in parse_monitor_printer_state()
2964 …print_fatal_error(data, "IN-GROUP without a preceding EXPECT on line %d of \"%s\".", f->linenum, f in parse_monitor_printer_state()
2968 else if (!_cups_strcasecmp(token, "IF-DEFINED")) in parse_monitor_printer_state()
2972 print_fatal_error(data, "Missing IF-DEFINED name on line %d of \"%s\".", f->linenum, f->filename); in parse_monitor_printer_state()
2976 if (data->last_expect) in parse_monitor_printer_state()
2978 data->last_expect->if_defined = strdup(temp); in parse_monitor_printer_state()
2982 …print_fatal_error(data, "IF-DEFINED without a preceding EXPECT on line %d of \"%s\".", f->linenum,… in parse_monitor_printer_state()
2986 else if (!_cups_strcasecmp(token, "IF-NOT-DEFINED")) in parse_monitor_printer_state()
2990 …print_fatal_error(data, "Missing IF-NOT-DEFINED name on line %d of \"%s\".", f->linenum, f->filena… in parse_monitor_printer_state()
2994 if (data->last_expect) in parse_monitor_printer_state()
2996 data->last_expect->if_not_defined = strdup(temp); in parse_monitor_printer_state()
3000 …print_fatal_error(data, "IF-NOT-DEFINED without a preceding EXPECT on line %d of \"%s\".", f->line… in parse_monitor_printer_state()
3004 else if (!_cups_strcasecmp(token, "WITH-DISTINCT-VALUES")) in parse_monitor_printer_state()
3006 if (data->last_expect) in parse_monitor_printer_state()
3008 data->last_expect->with_distinct = 1; in parse_monitor_printer_state()
3012 …error(data, "%s without a preceding EXPECT on line %d of \"%s\".", token, f->linenum, f->filename); in parse_monitor_printer_state()
3016 else if (!_cups_strcasecmp(token, "WITH-VALUE")) in parse_monitor_printer_state()
3023 print_fatal_error(data, "Missing %s value on line %d of \"%s\".", token, f->linenum, f->filename); in parse_monitor_printer_state()
3028 * Read additional comma-delimited values - needed since legacy test files in parse_monitor_printer_state()
3029 * will have unquoted WITH-VALUE values with commas... in parse_monitor_printer_state()
3036 lastpos = cupsFileTell(f->fp); in parse_monitor_printer_state()
3037 lastline = f->linenum; in parse_monitor_printer_state()
3040 if (!_ippFileReadToken(f, ptr, (sizeof(temp) - (size_t)(ptr - temp)))) in parse_monitor_printer_state()
3051 if (!_ippFileReadToken(f, ptr, (sizeof(temp) - (size_t)(ptr - temp)))) in parse_monitor_printer_state()
3060 cupsFileSeek(f->fp, lastpos); in parse_monitor_printer_state()
3061 f->linenum = lastline; in parse_monitor_printer_state()
3067 if (data->last_expect) in parse_monitor_printer_state()
3073 _ippVarsExpand(data->vars, value, temp, sizeof(value)); in parse_monitor_printer_state()
3075 ptr = value + strlen(value) - 1; in parse_monitor_printer_state()
3080 * WITH-VALUE is a POSIX extended regular expression. in parse_monitor_printer_state()
3083 data->last_expect->with_value = calloc(1, (size_t)(ptr - value)); in parse_monitor_printer_state()
3084 data->last_expect->with_flags |= IPPTOOL_WITH_REGEX; in parse_monitor_printer_state()
3086 if (data->last_expect->with_value) in parse_monitor_printer_state()
3087 memcpy(data->last_expect->with_value, value + 1, (size_t)(ptr - value - 1)); in parse_monitor_printer_state()
3092 * WITH-VALUE is a literal value... in parse_monitor_printer_state()
3107 data->last_expect->with_value = strdup(value); in parse_monitor_printer_state()
3108 data->last_expect->with_flags |= IPPTOOL_WITH_LITERAL; in parse_monitor_printer_state()
3113 …error(data, "%s without a preceding EXPECT on line %d of \"%s\".", token, f->linenum, f->filename); in parse_monitor_printer_state()
3119 print_fatal_error(data, "Missing closing brace on line %d of \"%s\".", f->linenum, f->filename); in parse_monitor_printer_state()
3126 * 'pause_message()' - Display the message and pause until the user presses a key.
3130 pause_message(const char *message) /* I - Message */ in pause_message()
3153 int tty; /* /dev/tty - never read from stdin */ in pause_message()
3186 cupsFilePrintf(cupsFileStdout(), "\n%s\n\n---- PRESS ANY KEY ----", message); in pause_message()
3225 * 'print_attr()' - Print an attribute on the screen.
3229 print_attr(cups_file_t *outfile, /* I - Output file */ in print_attr()
3230 ipptool_output_t output, /* I - Output format */ in print_attr()
3231 ipp_attribute_t *attr, /* I - Attribute to print */ in print_attr()
3232 ipp_tag_t *group) /* IO - Current group */ in print_attr()
3369 cupsFilePuts(outfile, " -- separator --\n"); in print_attr()
3383 * 'print_csv()' - Print a line of CSV text.
3386 static ipp_attribute_t * /* O - Next attribute */
3388 ipptool_test_t *data, /* I - Test data */ in print_csv()
3389 ipp_t *ipp, /* I - Response message */ in print_csv()
3390 ipp_attribute_t *attr, /* I - First attribute for line */ in print_csv()
3391 int num_displayed, /* I - Number of attributes to display */ in print_csv()
3392 char **displayed, /* I - Attributes to display */ in print_csv()
3393 size_t *widths) /* I - Column widths */ in print_csv()
3440 cupsFilePutChar(data->outfile, ','); in print_csv()
3448 cupsFilePutChar(data->outfile, '\"'); in print_csv()
3452 cupsFilePutChar(data->outfile, '\\'); in print_csv()
3453 cupsFilePutChar(data->outfile, *valptr); in print_csv()
3455 cupsFilePutChar(data->outfile, '\"'); in print_csv()
3460 cupsFilePuts(data->outfile, values[i]); in print_csv()
3465 cupsFilePutChar(data->outfile, '\n'); in print_csv()
3473 cupsFilePutChar(data->outfile, ','); in print_csv()
3475 cupsFilePuts(data->outfile, displayed[i]); in print_csv()
3477 cupsFilePutChar(data->outfile, '\n'); in print_csv()
3485 * 'print_fatal_error()' - Print a fatal error message.
3490 ipptool_test_t *data, /* I - Test data */ in print_fatal_error()
3491 const char *s, /* I - Printf-style format string */ in print_fatal_error()
3492 ...) /* I - Additional arguments as needed */ in print_fatal_error()
3510 if (data->output == IPPTOOL_OUTPUT_PLIST) in print_fatal_error()
3521 * 'print_ippserver_attr()' - Print an attribute suitable for use by ippserver.
3526 ipptool_test_t *data, /* I - Test data */ in print_ippserver_attr()
3527 ipp_attribute_t *attr, /* I - Attribute to print */ in print_ippserver_attr()
3528 int indent) /* I - Indentation level */ in print_ippserver_attr()
3537 … cupsFilePrintf(data->outfile, "ATTR %s %s", ippTagString(ippGetValueTag(attr)), ippGetName(attr)); in print_ippserver_attr()
3539 …cupsFilePrintf(data->outfile, "%*sMEMBER %s %s", indent, "", ippTagString(ippGetValueTag(attr)), i… in print_ippserver_attr()
3546 cupsFilePrintf(data->outfile, "%s%d", i ? "," : " ", ippGetInteger(attr, i)); in print_ippserver_attr()
3550 cupsFilePuts(data->outfile, ippGetBoolean(attr, 0) ? " true" : " false"); in print_ippserver_attr()
3553 cupsFilePuts(data->outfile, ippGetBoolean(attr, 1) ? ",true" : ",false"); in print_ippserver_attr()
3561 cupsFilePrintf(data->outfile, "%s%d-%d", i ? "," : " ", lower, upper); in print_ippserver_attr()
3571 …cupsFilePrintf(data->outfile, "%s%dx%d%s", i ? "," : " ", xres, yres, units == IPP_RES_PER_INCH ? … in print_ippserver_attr()
3577 cupsFilePrintf(data->outfile, "%s%s", i ? "," : " ", iso_date(ippGetDate(attr, i))); in print_ippserver_attr()
3586 cupsFilePuts(data->outfile, i ? "," : " "); in print_ippserver_attr()
3605 cupsFilePuts(data->outfile, i ? "," : " "); in print_ippserver_attr()
3615 cupsFilePuts(data->outfile, i ? ",{\n" : " {\n"); in print_ippserver_attr()
3618 cupsFilePrintf(data->outfile, "%*s}", indent, ""); in print_ippserver_attr()
3623 /* Out-of-band value */ in print_ippserver_attr()
3627 cupsFilePuts(data->outfile, "\n"); in print_ippserver_attr()
3632 * 'print_ippserver_string()' - Print a string suitable for use by ippserver.
3637 ipptool_test_t *data, /* I - Test data */ in print_ippserver_string()
3638 const char *s, /* I - String to print */ in print_ippserver_string()
3639 size_t len) /* I - Length of string */ in print_ippserver_string()
3641 cupsFilePutChar(data->outfile, '\"'); in print_ippserver_string()
3645 cupsFilePutChar(data->outfile, '\\'); in print_ippserver_string()
3646 cupsFilePutChar(data->outfile, *s); in print_ippserver_string()
3649 len --; in print_ippserver_string()
3651 cupsFilePutChar(data->outfile, '\"'); in print_ippserver_string()
3656 * 'print_json_attr()' - Print an attribute in JSON format.
3661 ipptool_test_t *data, /* I - Test data */ in print_json_attr()
3662 ipp_attribute_t *attr, /* I - IPP attribute */ in print_json_attr()
3663 int indent) /* I - Indentation */ in print_json_attr()
3673 cupsFilePrintf(data->outfile, "%*s", indent, ""); in print_json_attr()
3682 cupsFilePrintf(data->outfile, ": %d", ippGetInteger(attr, 0)); in print_json_attr()
3686 cupsFilePuts(data->outfile, ": [\n"); in print_json_attr()
3688 …cupsFilePrintf(data->outfile, "%*s%d%s", indent + 4, "", ippGetInteger(attr, i), (i + 1) < count ?… in print_json_attr()
3689 cupsFilePrintf(data->outfile, "%*s]", indent, ""); in print_json_attr()
3696 cupsFilePrintf(data->outfile, ": %s", ippGetBoolean(attr, 0) ? "true" : "false"); in print_json_attr()
3700 cupsFilePuts(data->outfile, ": [\n"); in print_json_attr()
3702 …cupsFilePrintf(data->outfile, "%*s%s%s", indent + 4, "", ippGetBoolean(attr, i) ? "true" : "false"… in print_json_attr()
3703 cupsFilePrintf(data->outfile, "%*s]", indent, ""); in print_json_attr()
3712 …cupsFilePrintf(data->outfile, ": {\n%*s\"lower\": %d,\n%*s\"upper\":%d\n%*s}", indent + 4, "", low… in print_json_attr()
3716 cupsFilePuts(data->outfile, ": [\n"); in print_json_attr()
3721 …cupsFilePrintf(data->outfile, "%*s{\n%*s\"lower\": %d,\n%*s\"upper\":%d\n%*s},\n", indent + 4, "",… in print_json_attr()
3723 cupsFilePrintf(data->outfile, "%*s]", indent, ""); in print_json_attr()
3733 …cupsFilePrintf(data->outfile, ": {\n%*s\"units\": \"%s\",\n%*s\"xres\": %d,\n%*s\"yres\":%d\n%*s}"… in print_json_attr()
3737 cupsFilePuts(data->outfile, ": [\n"); in print_json_attr()
3743 …cupsFilePrintf(data->outfile, "%*s{\n%*s\"units\": \"%s\",\n%*s\"xres\": %d,\n%*s\"yres\":%d\n%*s}… in print_json_attr()
3745 cupsFilePrintf(data->outfile, "%*s]", indent, ""); in print_json_attr()
3752 cupsFilePrintf(data->outfile, ": \"%s\"", iso_date(ippGetDate(attr, 0))); in print_json_attr()
3756 cupsFilePuts(data->outfile, ": [\n"); in print_json_attr()
3758 …cupsFilePrintf(data->outfile, "%*s\"%s\"%s", indent + 4, "", iso_date(ippGetDate(attr, i)), (i + 1… in print_json_attr()
3759 cupsFilePrintf(data->outfile, "%*s]", indent, ""); in print_json_attr()
3769 cupsFilePuts(data->outfile, ": \""); in print_json_attr()
3772 cupsFilePrintf(data->outfile, "%02X", *s++ & 255); in print_json_attr()
3773 len --; in print_json_attr()
3775 cupsFilePuts(data->outfile, "\""); in print_json_attr()
3779 cupsFilePuts(data->outfile, ": [\n"); in print_json_attr()
3785 cupsFilePrintf(data->outfile, "%*s\"", indent + 4, ""); in print_json_attr()
3788 cupsFilePrintf(data->outfile, "%02X", *s++ & 255); in print_json_attr()
3789 len --; in print_json_attr()
3791 cupsFilePuts(data->outfile, (i + 1) < count ? "\",\n" : "\"\n"); in print_json_attr()
3793 cupsFilePrintf(data->outfile, "%*s]", indent, ""); in print_json_attr()
3811 cupsFilePuts(data->outfile, ": "); in print_json_attr()
3816 cupsFilePuts(data->outfile, ": [\n"); in print_json_attr()
3821 cupsFilePrintf(data->outfile, "%*s", indent + 4, ""); in print_json_attr()
3823 cupsFilePuts(data->outfile, (i + 1) < count ? ",\n" : "\n"); in print_json_attr()
3825 cupsFilePrintf(data->outfile, "%*s]", indent, ""); in print_json_attr()
3834 cupsFilePuts(data->outfile, ": {\n"); in print_json_attr()
3840 cupsFilePuts(data->outfile, colattr ? ",\n" : "\n"); in print_json_attr()
3842 cupsFilePrintf(data->outfile, "%*s}", indent, ""); in print_json_attr()
3846 cupsFilePuts(data->outfile, ": [\n"); in print_json_attr()
3851 cupsFilePrintf(data->outfile, "%*s{\n", indent + 4, ""); in print_json_attr()
3857 cupsFilePuts(data->outfile, colattr ? ",\n" : "\n"); in print_json_attr()
3859 cupsFilePrintf(data->outfile, "%*s}%s", indent + 4, "", (i + 1) < count ? ",\n" : "\n"); in print_json_attr()
3861 cupsFilePrintf(data->outfile, "%*s]", indent, ""); in print_json_attr()
3866 /* Out-of-band value */ in print_json_attr()
3867 cupsFilePrintf(data->outfile, ": null"); in print_json_attr()
3874 * 'print_json_string()' - Print a string in JSON format.
3879 ipptool_test_t *data, /* I - Test data */ in print_json_string()
3880 const char *s, /* I - String to print */ in print_json_string()
3881 size_t len) /* I - Length of string */ in print_json_string()
3883 cupsFilePutChar(data->outfile, '\"'); in print_json_string()
3890 cupsFilePutChar(data->outfile, '\\'); in print_json_string()
3891 cupsFilePutChar(data->outfile, *s); in print_json_string()
3895 cupsFilePuts(data->outfile, "\\n"); in print_json_string()
3899 cupsFilePuts(data->outfile, "\\r"); in print_json_string()
3903 cupsFilePuts(data->outfile, "\\t"); in print_json_string()
3908 cupsFilePrintf(data->outfile, "\\%03o", *s); in print_json_string()
3910 cupsFilePutChar(data->outfile, *s); in print_json_string()
3915 len --; in print_json_string()
3917 cupsFilePutChar(data->outfile, '\"'); in print_json_string()
3922 * 'print_line()' - Print a line of formatted or CSV text.
3925 static ipp_attribute_t * /* O - Next attribute */
3927 ipptool_test_t *data, /* I - Test data */ in print_line()
3928 ipp_t *ipp, /* I - Response message */ in print_line()
3929 ipp_attribute_t *attr, /* I - First attribute for line */ in print_line()
3930 int num_displayed, /* I - Number of attributes to display */ in print_line()
3931 char **displayed, /* I - Attributes to display */ in print_line()
3932 size_t *widths) /* I - Column widths */ in print_line()
3979 cupsFilePutChar(data->outfile, ' '); in print_line()
3981 cupsFilePrintf(data->outfile, "%*s", (int)-widths[i], values[i] ? values[i] : ""); in print_line()
3984 cupsFilePutChar(data->outfile, '\n'); in print_line()
3998 cupsFilePutChar(data->outfile, ' '); in print_line()
4000 cupsFilePrintf(data->outfile, "%*s", (int)-widths[i], displayed[i]); in print_line()
4002 cupsFilePutChar(data->outfile, '\n'); in print_line()
4007 cupsFilePutChar(data->outfile, ' '); in print_line()
4009 memset(buffer, '-', widths[i]); in print_line()
4011 cupsFilePuts(data->outfile, buffer); in print_line()
4013 cupsFilePutChar(data->outfile, '\n'); in print_line()
4022 * 'print_xml_header()' - Print a standard XML plist header.
4026 print_xml_header(ipptool_test_t *data)/* I - Test data */ in print_xml_header()
4028 if (!data->xml_header) in print_xml_header()
4030 cupsFilePuts(data->outfile, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); in print_xml_header()
4031 …cupsFilePuts(data->outfile, "<!DOCTYPE plist PUBLIC \"-//Apple Computer//DTD PLIST 1.0//EN\" \"htt… in print_xml_header()
4032 cupsFilePuts(data->outfile, "<plist version=\"1.0\">\n"); in print_xml_header()
4033 cupsFilePuts(data->outfile, "<dict>\n"); in print_xml_header()
4034 cupsFilePuts(data->outfile, "<key>ipptoolVersion</key>\n"); in print_xml_header()
4035 cupsFilePuts(data->outfile, "<string>" CUPS_SVERSION "</string>\n"); in print_xml_header()
4036 cupsFilePuts(data->outfile, "<key>Transfer</key>\n"); in print_xml_header()
4037 …cupsFilePrintf(data->outfile, "<string>%s</string>\n", data->transfer == IPPTOOL_TRANSFER_AUTO ? "… in print_xml_header()
4038 cupsFilePuts(data->outfile, "<key>Tests</key>\n"); in print_xml_header()
4039 cupsFilePuts(data->outfile, "<array>\n"); in print_xml_header()
4041 data->xml_header = 1; in print_xml_header()
4047 * 'print_xml_string()' - Print an XML string with escaping.
4051 print_xml_string(cups_file_t *outfile, /* I - Test data */ in print_xml_string()
4052 const char *element, /* I - Element name or NULL */ in print_xml_string()
4053 const char *s) /* I - String to print */ in print_xml_string()
4069 * Validate UTF-8 two-byte sequence... in print_xml_string()
4086 * Validate UTF-8 three-byte sequence... in print_xml_string()
4104 * Validate UTF-8 four-byte sequence... in print_xml_string()
4141 * 'print_xml_trailer()' - Print the XML trailer with success/fail value.
4146 ipptool_test_t *data, /* I - Test data */ in print_xml_trailer()
4147 int success, /* I - 1 on success, 0 on failure */ in print_xml_trailer()
4148 const char *message) /* I - Error message or NULL */ in print_xml_trailer()
4150 if (data->xml_header) in print_xml_trailer()
4152 cupsFilePuts(data->outfile, "</array>\n"); in print_xml_trailer()
4153 cupsFilePuts(data->outfile, "<key>Successful</key>\n"); in print_xml_trailer()
4154 cupsFilePuts(data->outfile, success ? "<true />\n" : "<false />\n"); in print_xml_trailer()
4157 cupsFilePuts(data->outfile, "<key>ErrorMessage</key>\n"); in print_xml_trailer()
4158 print_xml_string(data->outfile, "string", message); in print_xml_trailer()
4160 cupsFilePuts(data->outfile, "</dict>\n"); in print_xml_trailer()
4161 cupsFilePuts(data->outfile, "</plist>\n"); in print_xml_trailer()
4163 data->xml_header = 0; in print_xml_trailer()
4170 * 'sigterm_handler()' - Handle SIGINT and SIGTERM.
4174 sigterm_handler(int sig) /* I - Signal number (unused) */ in sigterm_handler()
4187 * 'timeout_cb()' - Handle HTTP timeouts.
4190 static int /* O - 1 to continue, 0 to cancel */
4191 timeout_cb(http_t *http, /* I - Connection to server */ in timeout_cb()
4192 void *user_data) /* I - User data (unused) */ in timeout_cb()
4208 if (getsockopt(httpGetFd(http), SOL_SOCKET, SO_NWRITE, &buffered, &len)) in timeout_cb()
4224 * 'token_cb()' - Parse test file-specific tokens and run tests.
4227 static int /* O - 1 to continue, 0 to stop */
4228 token_cb(_ipp_file_t *f, /* I - IPP file data */ in token_cb()
4229 _ipp_vars_t *vars, /* I - IPP variables */ in token_cb()
4230 ipptool_test_t *data, /* I - Test data */ in token_cb()
4231 const char *token) /* I - Current token */ in token_cb()
4247 else if (f->attrs) in token_cb()
4254 _cups_strcasecmp(token, "DEFINE-MATCH") && in token_cb()
4255 _cups_strcasecmp(token, "DEFINE-NO-MATCH") && in token_cb()
4256 _cups_strcasecmp(token, "DEFINE-VALUE") && in token_cb()
4257 _cups_strcasecmp(token, "DISPLAY-MATCH") && in token_cb()
4258 _cups_strcasecmp(token, "IF-DEFINED") && in token_cb()
4259 _cups_strcasecmp(token, "IF-NOT-DEFINED") && in token_cb()
4260 _cups_strcasecmp(token, "IN-GROUP") && in token_cb()
4261 _cups_strcasecmp(token, "OF-TYPE") && in token_cb()
4262 _cups_strcasecmp(token, "REPEAT-LIMIT") && in token_cb()
4263 _cups_strcasecmp(token, "REPEAT-MATCH") && in token_cb()
4264 _cups_strcasecmp(token, "REPEAT-NO-MATCH") && in token_cb()
4265 _cups_strcasecmp(token, "SAME-COUNT-AS") && in token_cb()
4266 _cups_strcasecmp(token, "WITH-ALL-VALUES") && in token_cb()
4267 _cups_strcasecmp(token, "WITH-ALL-HOSTNAMES") && in token_cb()
4268 _cups_strcasecmp(token, "WITH-ALL-RESOURCES") && in token_cb()
4269 _cups_strcasecmp(token, "WITH-ALL-SCHEMES") && in token_cb()
4270 _cups_strcasecmp(token, "WITH-DISTINCT-VALUES") && in token_cb()
4271 _cups_strcasecmp(token, "WITH-HOSTNAME") && in token_cb()
4272 _cups_strcasecmp(token, "WITH-RESOURCE") && in token_cb()
4273 _cups_strcasecmp(token, "WITH-SCHEME") && in token_cb()
4274 _cups_strcasecmp(token, "WITH-VALUE") && in token_cb()
4275 _cups_strcasecmp(token, "WITH-VALUE-FROM")) in token_cb()
4276 data->last_expect = NULL; in token_cb()
4278 if (_cups_strcasecmp(token, "DEFINE-MATCH") && in token_cb()
4279 _cups_strcasecmp(token, "DEFINE-NO-MATCH") && in token_cb()
4280 _cups_strcasecmp(token, "IF-DEFINED") && in token_cb()
4281 _cups_strcasecmp(token, "IF-NOT-DEFINED") && in token_cb()
4282 _cups_strcasecmp(token, "REPEAT-LIMIT") && in token_cb()
4283 _cups_strcasecmp(token, "REPEAT-MATCH") && in token_cb()
4284 _cups_strcasecmp(token, "REPEAT-NO-MATCH")) in token_cb()
4285 data->last_status = NULL; in token_cb()
4291 else if (!strcmp(token, "MONITOR-PRINTER-STATE")) in token_cb()
4293 if (data->monitor_uri) in token_cb()
4295 …print_fatal_error(data, "Extra MONITOR-PRINTER-STATE seen on line %d of \"%s\".", f->linenum, f->f… in token_cb()
4311 _ippVarsExpand(vars, data->compression, temp, sizeof(data->compression)); in token_cb()
4313 if (strcmp(data->compression, "none") && strcmp(data->compression, "deflate") && in token_cb()
4314 strcmp(data->compression, "gzip")) in token_cb()
4316 if (strcmp(data->compression, "none")) in token_cb()
4319 …upported COMPRESSION value \"%s\" on line %d of \"%s\".", data->compression, f->linenum, f->filena… in token_cb()
4323 if (!strcmp(data->compression, "none")) in token_cb()
4324 data->compression[0] = '\0'; in token_cb()
4328 …print_fatal_error(data, "Missing COMPRESSION value on line %d of \"%s\".", f->linenum, f->filename… in token_cb()
4345 …print_fatal_error(data, "Missing DEFINE name and/or value on line %d of \"%s\".", f->linenum, f->f… in token_cb()
4349 else if (!strcmp(token, "IGNORE-ERRORS")) in token_cb()
4352 * IGNORE-ERRORS yes in token_cb()
4353 * IGNORE-ERRORS no in token_cb()
4358 data->ignore_errors = !_cups_strcasecmp(temp, "yes"); in token_cb()
4362 …print_fatal_error(data, "Missing IGNORE-ERRORS value on line %d of \"%s\".", f->linenum, f->filena… in token_cb()
4374 _ippVarsExpand(vars, data->name, temp, sizeof(data->name)); in token_cb()
4378 print_fatal_error(data, "Missing NAME string on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4390 strlcpy(data->pause, temp, sizeof(data->pause)); in token_cb()
4394 print_fatal_error(data, "Missing PAUSE message on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4398 else if (!strcmp(token, "REQUEST-ID")) in token_cb()
4401 * REQUEST-ID # in token_cb()
4402 * REQUEST-ID random in token_cb()
4409 data->request_id = atoi(temp) - 1; in token_cb()
4413 data->request_id = (CUPS_RAND() % 1000) * 137; in token_cb()
4417 …print_fatal_error(data, "Bad REQUEST-ID value \"%s\" on line %d of \"%s\".", temp, f->linenum, f->… in token_cb()
4423 print_fatal_error(data, "Missing REQUEST-ID value on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4427 else if (!strcmp(token, "PASS-IF-DEFINED")) in token_cb()
4430 * PASS-IF-DEFINED variable in token_cb()
4436 data->pass_test = 1; in token_cb()
4440 …print_fatal_error(data, "Missing PASS-IF-DEFINED value on line %d of \"%s\".", f->linenum, f->file… in token_cb()
4444 else if (!strcmp(token, "PASS-IF-NOT-DEFINED")) in token_cb()
4447 * PASS-IF-NOT-DEFINED variable in token_cb()
4453 data->pass_test = 1; in token_cb()
4457 …print_fatal_error(data, "Missing PASS-IF-NOT-DEFINED value on line %d of \"%s\".", f->linenum, f->… in token_cb()
4461 else if (!strcmp(token, "SKIP-IF-DEFINED")) in token_cb()
4464 * SKIP-IF-DEFINED variable in token_cb()
4470 data->skip_test = 1; in token_cb()
4474 …print_fatal_error(data, "Missing SKIP-IF-DEFINED value on line %d of \"%s\".", f->linenum, f->file… in token_cb()
4478 else if (!strcmp(token, "SKIP-IF-MISSING")) in token_cb()
4481 * SKIP-IF-MISSING filename in token_cb()
4489 get_filename(f->filename, filename, temp, sizeof(filename)); in token_cb()
4492 data->skip_test = 1; in token_cb()
4496 …print_fatal_error(data, "Missing SKIP-IF-MISSING filename on line %d of \"%s\".", f->linenum, f->f… in token_cb()
4500 else if (!strcmp(token, "SKIP-IF-NOT-DEFINED")) in token_cb()
4503 * SKIP-IF-NOT-DEFINED variable in token_cb()
4509 data->skip_test = 1; in token_cb()
4513 …print_fatal_error(data, "Missing SKIP-IF-NOT-DEFINED value on line %d of \"%s\".", f->linenum, f->… in token_cb()
4517 else if (!strcmp(token, "SKIP-PREVIOUS-ERROR")) in token_cb()
4520 * SKIP-PREVIOUS-ERROR yes in token_cb()
4521 * SKIP-PREVIOUS-ERROR no in token_cb()
4526 data->skip_previous = !_cups_strcasecmp(temp, "yes"); in token_cb()
4530 …print_fatal_error(data, "Missing SKIP-PREVIOUS-ERROR value on line %d of \"%s\".", f->linenum, f->… in token_cb()
4534 else if (!strcmp(token, "TEST-ID")) in token_cb()
4537 * TEST-ID "string" in token_cb()
4542 _ippVarsExpand(vars, data->test_id, temp, sizeof(data->test_id)); in token_cb()
4546 print_fatal_error(data, "Missing TEST-ID value on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4562 data->transfer = IPPTOOL_TRANSFER_AUTO; in token_cb()
4566 data->transfer = IPPTOOL_TRANSFER_CHUNKED; in token_cb()
4570 data->transfer = IPPTOOL_TRANSFER_LENGTH; in token_cb()
4574 …print_fatal_error(data, "Bad TRANSFER value \"%s\" on line %d of \"%s\".", temp, f->linenum, f->fi… in token_cb()
4580 print_fatal_error(data, "Missing TRANSFER value on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4590 data->version = 0; in token_cb()
4594 data->version = 10; in token_cb()
4598 data->version = 11; in token_cb()
4602 data->version = 20; in token_cb()
4606 data->version = 21; in token_cb()
4610 data->version = 22; in token_cb()
4614 …print_fatal_error(data, "Bad VERSION \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename); in token_cb()
4620 print_fatal_error(data, "Missing VERSION number on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4630 if (!_ippFileReadToken(f, data->resource, sizeof(data->resource))) in token_cb()
4632 print_fatal_error(data, "Missing RESOURCE path on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4646 print_fatal_error(data, "Missing OPERATION code on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4652 if ((op = ippOpValue(value)) == (ipp_op_t)-1 && (op = (ipp_op_t)strtol(value, NULL, 0)) == 0) in token_cb()
4654 …print_fatal_error(data, "Bad OPERATION code \"%s\" on line %d of \"%s\".", temp, f->linenum, f->fi… in token_cb()
4658 ippSetOperation(f->attrs, op); in token_cb()
4670 print_fatal_error(data, "Missing GROUP tag on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4676 …print_fatal_error(data, "Bad GROUP tag \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filenam… in token_cb()
4680 if (group_tag == f->group_tag) in token_cb()
4681 ippAddSeparator(f->attrs); in token_cb()
4683 f->group_tag = group_tag; in token_cb()
4695 print_fatal_error(data, "Missing DELAY value on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4703 …print_fatal_error(data, "Bad DELAY value \"%s\" on line %d of \"%s\".", value, f->linenum, f->file… in token_cb()
4707 data->delay = (useconds_t)(1000000.0 * dval); in token_cb()
4713 …print_fatal_error(data, "Bad DELAY value \"%s\" on line %d of \"%s\".", value, f->linenum, f->file… in token_cb()
4717 data->repeat_interval = (useconds_t)(1000000.0 * dval); in token_cb()
4720 data->repeat_interval = data->delay; in token_cb()
4730 print_fatal_error(data, "Missing FILE filename on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4735 get_filename(f->filename, data->file, value, sizeof(data->file)); in token_cb()
4737 if (access(data->file, R_OK)) in token_cb()
4739 …pped to \"%s\") on line %d of \"%s\" cannot be read.", value, data->file, f->linenum, f->filename); in token_cb()
4749 if (data->num_statuses >= (int)(sizeof(data->statuses) / sizeof(data->statuses[0]))) in token_cb()
4751 print_fatal_error(data, "Too many STATUS's on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4757 print_fatal_error(data, "Missing STATUS code on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4761 …if ((data->statuses[data->num_statuses].status = ippErrorValue(temp)) == (ipp_status_t)-1 && (data in token_cb()
4763 …print_fatal_error(data, "Bad STATUS code \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filen… in token_cb()
4767 data->last_status = data->statuses + data->num_statuses; in token_cb()
4768 data->num_statuses ++; in token_cb()
4770 data->last_status->define_match = NULL; in token_cb()
4771 data->last_status->define_no_match = NULL; in token_cb()
4772 data->last_status->if_defined = NULL; in token_cb()
4773 data->last_status->if_not_defined = NULL; in token_cb()
4774 data->last_status->repeat_limit = 1000; in token_cb()
4775 data->last_status->repeat_match = 0; in token_cb()
4776 data->last_status->repeat_no_match = 0; in token_cb()
4778 else if (!_cups_strcasecmp(token, "EXPECT") || !_cups_strcasecmp(token, "EXPECT-ALL")) in token_cb()
4784 int expect_all = !_cups_strcasecmp(token, "EXPECT-ALL"); in token_cb()
4786 if (data->num_expects >= (int)(sizeof(data->expects) / sizeof(data->expects[0]))) in token_cb()
4788 print_fatal_error(data, "Too many EXPECT's on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4794 print_fatal_error(data, "Missing EXPECT name on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4798 data->last_expect = data->expects + data->num_expects; in token_cb()
4799 data->num_expects ++; in token_cb()
4801 memset(data->last_expect, 0, sizeof(ipptool_expect_t)); in token_cb()
4802 data->last_expect->repeat_limit = 1000; in token_cb()
4803 data->last_expect->expect_all = expect_all; in token_cb()
4807 data->last_expect->not_expect = 1; in token_cb()
4808 data->last_expect->name = strdup(name + 1); in token_cb()
4812 data->last_expect->optional = 1; in token_cb()
4813 data->last_expect->name = strdup(name + 1); in token_cb()
4816 data->last_expect->name = strdup(name); in token_cb()
4824 print_fatal_error(data, "Missing COUNT number on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4830 print_fatal_error(data, "Bad COUNT \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename); in token_cb()
4834 if (data->last_expect) in token_cb()
4836 data->last_expect->count = count; in token_cb()
4840 …print_fatal_error(data, "COUNT without a preceding EXPECT on line %d of \"%s\".", f->linenum, f->f… in token_cb()
4844 else if (!_cups_strcasecmp(token, "DEFINE-MATCH")) in token_cb()
4848 …print_fatal_error(data, "Missing DEFINE-MATCH variable on line %d of \"%s\".", f->linenum, f->file… in token_cb()
4852 if (data->last_expect) in token_cb()
4854 data->last_expect->define_match = strdup(temp); in token_cb()
4856 else if (data->last_status) in token_cb()
4858 data->last_status->define_match = strdup(temp); in token_cb()
4862 …print_fatal_error(data, "DEFINE-MATCH without a preceding EXPECT or STATUS on line %d of \"%s\".",… in token_cb()
4866 else if (!_cups_strcasecmp(token, "DEFINE-NO-MATCH")) in token_cb()
4870 …print_fatal_error(data, "Missing DEFINE-NO-MATCH variable on line %d of \"%s\".", f->linenum, f->f… in token_cb()
4874 if (data->last_expect) in token_cb()
4876 data->last_expect->define_no_match = strdup(temp); in token_cb()
4878 else if (data->last_status) in token_cb()
4880 data->last_status->define_no_match = strdup(temp); in token_cb()
4884 …print_fatal_error(data, "DEFINE-NO-MATCH without a preceding EXPECT or STATUS on line %d of \"%s\"… in token_cb()
4888 else if (!_cups_strcasecmp(token, "DEFINE-VALUE")) in token_cb()
4892 …print_fatal_error(data, "Missing DEFINE-VALUE variable on line %d of \"%s\".", f->linenum, f->file… in token_cb()
4896 if (data->last_expect) in token_cb()
4898 data->last_expect->define_value = strdup(temp); in token_cb()
4902 …print_fatal_error(data, "DEFINE-VALUE without a preceding EXPECT on line %d of \"%s\".", f->linenu… in token_cb()
4906 else if (!_cups_strcasecmp(token, "DISPLAY-MATCH")) in token_cb()
4910 …print_fatal_error(data, "Missing DISPLAY-MATCH mesaage on line %d of \"%s\".", f->linenum, f->file… in token_cb()
4914 if (data->last_expect) in token_cb()
4916 data->last_expect->display_match = strdup(temp); in token_cb()
4920 …print_fatal_error(data, "DISPLAY-MATCH without a preceding EXPECT on line %d of \"%s\".", f->linen… in token_cb()
4924 else if (!_cups_strcasecmp(token, "OF-TYPE")) in token_cb()
4928 …print_fatal_error(data, "Missing OF-TYPE value tag(s) on line %d of \"%s\".", f->linenum, f->filen… in token_cb()
4932 if (data->last_expect) in token_cb()
4934 data->last_expect->of_type = strdup(temp); in token_cb()
4938 …print_fatal_error(data, "OF-TYPE without a preceding EXPECT on line %d of \"%s\".", f->linenum, f- in token_cb()
4942 else if (!_cups_strcasecmp(token, "IN-GROUP")) in token_cb()
4944 ipp_tag_t in_group; /* IN-GROUP value */ in token_cb()
4948 …print_fatal_error(data, "Missing IN-GROUP group tag on line %d of \"%s\".", f->linenum, f->filenam… in token_cb()
4954 …print_fatal_error(data, "Bad IN-GROUP group tag \"%s\" on line %d of \"%s\".", temp, f->linenum, f in token_cb()
4957 else if (data->last_expect) in token_cb()
4959 data->last_expect->in_group = in_group; in token_cb()
4963 …print_fatal_error(data, "IN-GROUP without a preceding EXPECT on line %d of \"%s\".", f->linenum, f in token_cb()
4967 else if (!_cups_strcasecmp(token, "REPEAT-LIMIT")) in token_cb()
4971 …print_fatal_error(data, "Missing REPEAT-LIMIT value on line %d of \"%s\".", f->linenum, f->filenam… in token_cb()
4976 print_fatal_error(data, "Bad REPEAT-LIMIT value on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
4980 if (data->last_status) in token_cb()
4982 data->last_status->repeat_limit = atoi(temp); in token_cb()
4984 else if (data->last_expect) in token_cb()
4986 data->last_expect->repeat_limit = atoi(temp); in token_cb()
4990 …print_fatal_error(data, "REPEAT-LIMIT without a preceding EXPECT or STATUS on line %d of \"%s\".",… in token_cb()
4994 else if (!_cups_strcasecmp(token, "REPEAT-MATCH")) in token_cb()
4996 if (data->last_status) in token_cb()
4998 data->last_status->repeat_match = 1; in token_cb()
5000 else if (data->last_expect) in token_cb()
5002 data->last_expect->repeat_match = 1; in token_cb()
5006 …print_fatal_error(data, "REPEAT-MATCH without a preceding EXPECT or STATUS on line %d of \"%s\".",… in token_cb()
5010 else if (!_cups_strcasecmp(token, "REPEAT-NO-MATCH")) in token_cb()
5012 if (data->last_status) in token_cb()
5014 data->last_status->repeat_no_match = 1; in token_cb()
5016 else if (data->last_expect) in token_cb()
5018 data->last_expect->repeat_no_match = 1; in token_cb()
5022 …print_fatal_error(data, "REPEAT-NO-MATCH without a preceding EXPECT or STATUS on line %d of \"%s\"… in token_cb()
5026 else if (!_cups_strcasecmp(token, "SAME-COUNT-AS")) in token_cb()
5030 …print_fatal_error(data, "Missing SAME-COUNT-AS name on line %d of \"%s\".", f->linenum, f->filenam… in token_cb()
5034 if (data->last_expect) in token_cb()
5036 data->last_expect->same_count_as = strdup(temp); in token_cb()
5040 …print_fatal_error(data, "SAME-COUNT-AS without a preceding EXPECT on line %d of \"%s\".", f->linen… in token_cb()
5044 else if (!_cups_strcasecmp(token, "IF-DEFINED")) in token_cb()
5048 print_fatal_error(data, "Missing IF-DEFINED name on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
5052 if (data->last_expect) in token_cb()
5054 data->last_expect->if_defined = strdup(temp); in token_cb()
5056 else if (data->last_status) in token_cb()
5058 data->last_status->if_defined = strdup(temp); in token_cb()
5062 …print_fatal_error(data, "IF-DEFINED without a preceding EXPECT or STATUS on line %d of \"%s\".", f in token_cb()
5066 else if (!_cups_strcasecmp(token, "IF-NOT-DEFINED")) in token_cb()
5070 …print_fatal_error(data, "Missing IF-NOT-DEFINED name on line %d of \"%s\".", f->linenum, f->filena… in token_cb()
5074 if (data->last_expect) in token_cb()
5076 data->last_expect->if_not_defined = strdup(temp); in token_cb()
5078 else if (data->last_status) in token_cb()
5080 data->last_status->if_not_defined = strdup(temp); in token_cb()
5084 …print_fatal_error(data, "IF-NOT-DEFINED without a preceding EXPECT or STATUS on line %d of \"%s\".… in token_cb()
5088 else if (!_cups_strcasecmp(token, "WITH-DISTINCT-VALUES")) in token_cb()
5090 if (data->last_expect) in token_cb()
5092 data->last_expect->with_distinct = 1; in token_cb()
5096 …error(data, "%s without a preceding EXPECT on line %d of \"%s\".", token, f->linenum, f->filename); in token_cb()
5100 else if (!_cups_strcasecmp(token, "WITH-ALL-VALUES") || in token_cb()
5101 !_cups_strcasecmp(token, "WITH-ALL-HOSTNAMES") || in token_cb()
5102 !_cups_strcasecmp(token, "WITH-ALL-RESOURCES") || in token_cb()
5103 !_cups_strcasecmp(token, "WITH-ALL-SCHEMES") || in token_cb()
5104 !_cups_strcasecmp(token, "WITH-HOSTNAME") || in token_cb()
5105 !_cups_strcasecmp(token, "WITH-RESOURCE") || in token_cb()
5106 !_cups_strcasecmp(token, "WITH-SCHEME") || in token_cb()
5107 !_cups_strcasecmp(token, "WITH-VALUE")) in token_cb()
5112 if (data->last_expect) in token_cb()
5114 if (!_cups_strcasecmp(token, "WITH-ALL-HOSTNAMES") || !_cups_strcasecmp(token, "WITH-HOSTNAME")) in token_cb()
5115 data->last_expect->with_flags = IPPTOOL_WITH_HOSTNAME; in token_cb()
5116 …else if (!_cups_strcasecmp(token, "WITH-ALL-RESOURCES") || !_cups_strcasecmp(token, "WITH-RESOURCE… in token_cb()
5117 data->last_expect->with_flags = IPPTOOL_WITH_RESOURCE; in token_cb()
5118 else if (!_cups_strcasecmp(token, "WITH-ALL-SCHEMES") || !_cups_strcasecmp(token, "WITH-SCHEME")) in token_cb()
5119 data->last_expect->with_flags = IPPTOOL_WITH_SCHEME; in token_cb()
5121 if (!_cups_strncasecmp(token, "WITH-ALL-", 9)) in token_cb()
5122 data->last_expect->with_flags |= IPPTOOL_WITH_ALL; in token_cb()
5127 print_fatal_error(data, "Missing %s value on line %d of \"%s\".", token, f->linenum, f->filename); in token_cb()
5132 * Read additional comma-delimited values - needed since legacy test files in token_cb()
5133 * will have unquoted WITH-VALUE values with commas... in token_cb()
5140 lastpos = cupsFileTell(f->fp); in token_cb()
5141 lastline = f->linenum; in token_cb()
5144 if (!_ippFileReadToken(f, ptr, (sizeof(temp) - (size_t)(ptr - temp)))) in token_cb()
5155 if (!_ippFileReadToken(f, ptr, (sizeof(temp) - (size_t)(ptr - temp)))) in token_cb()
5164 cupsFileSeek(f->fp, lastpos); in token_cb()
5165 f->linenum = lastline; in token_cb()
5171 if (data->last_expect) in token_cb()
5179 ptr = value + strlen(value) - 1; in token_cb()
5184 * WITH-VALUE is a POSIX extended regular expression. in token_cb()
5187 data->last_expect->with_value = calloc(1, (size_t)(ptr - value)); in token_cb()
5188 data->last_expect->with_flags |= IPPTOOL_WITH_REGEX; in token_cb()
5190 if (data->last_expect->with_value) in token_cb()
5191 memcpy(data->last_expect->with_value, value + 1, (size_t)(ptr - value - 1)); in token_cb()
5196 * WITH-VALUE is a literal value... in token_cb()
5211 data->last_expect->with_value = strdup(value); in token_cb()
5212 data->last_expect->with_flags |= IPPTOOL_WITH_LITERAL; in token_cb()
5217 …error(data, "%s without a preceding EXPECT on line %d of \"%s\".", token, f->linenum, f->filename); in token_cb()
5221 else if (!_cups_strcasecmp(token, "WITH-VALUE-FROM")) in token_cb()
5225 print_fatal_error(data, "Missing %s value on line %d of \"%s\".", token, f->linenum, f->filename); in token_cb()
5229 if (data->last_expect) in token_cb()
5237 data->last_expect->with_value_from = strdup(value); in token_cb()
5238 data->last_expect->with_flags = IPPTOOL_WITH_LITERAL; in token_cb()
5242 …error(data, "%s without a preceding EXPECT on line %d of \"%s\".", token, f->linenum, f->filename); in token_cb()
5252 if (data->num_displayed >= (int)(sizeof(data->displayed) / sizeof(data->displayed[0]))) in token_cb()
5254 print_fatal_error(data, "Too many DISPLAY's on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
5260 print_fatal_error(data, "Missing DISPLAY name on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
5264 data->displayed[data->num_displayed] = strdup(temp); in token_cb()
5265 data->num_displayed ++; in token_cb()
5269 …atal_error(data, "Unexpected token %s seen on line %d of \"%s\".", token, f->linenum, f->filename); in token_cb()
5285 if (data->show_header) in token_cb()
5287 if (data->output == IPPTOOL_OUTPUT_PLIST) in token_cb()
5290 …if (data->output == IPPTOOL_OUTPUT_TEST || (data->output == IPPTOOL_OUTPUT_PLIST && data->outfile … in token_cb()
5291 cupsFilePrintf(cupsFileStdout(), "\"%s\":\n", f->filename); in token_cb()
5293 data->show_header = 0; in token_cb()
5296 data->compression[0] = '\0'; in token_cb()
5297 data->delay = 0; in token_cb()
5298 data->num_expects = 0; in token_cb()
5299 data->last_expect = NULL; in token_cb()
5300 data->file[0] = '\0'; in token_cb()
5301 data->ignore_errors = data->def_ignore_errors; in token_cb()
5302 strlcpy(data->name, f->filename, sizeof(data->name)); in token_cb()
5303 if ((ptr = strrchr(data->name, '.')) != NULL) in token_cb()
5305 data->repeat_interval = 5000000; in token_cb()
5306 strlcpy(data->resource, data->vars->resource, sizeof(data->resource)); in token_cb()
5307 data->skip_previous = 0; in token_cb()
5308 data->pass_test = 0; in token_cb()
5309 data->skip_test = 0; in token_cb()
5310 data->num_statuses = 0; in token_cb()
5311 data->last_status = NULL; in token_cb()
5312 data->test_id[0] = '\0'; in token_cb()
5313 data->transfer = data->def_transfer; in token_cb()
5314 data->version = data->def_version; in token_cb()
5316 free(data->monitor_uri); in token_cb()
5317 data->monitor_uri = NULL; in token_cb()
5318 data->monitor_delay = 0; in token_cb()
5319 data->monitor_interval = 5000000; in token_cb()
5320 data->num_monitor_expects = 0; in token_cb()
5322 _ippVarsSet(vars, "date-current", iso_date(ippTimeToDate(time(NULL)))); in token_cb()
5324 f->attrs = ippNew(); in token_cb()
5325 f->group_tag = IPP_TAG_ZERO; in token_cb()
5335 _ippVarsSet(vars, "date-current", iso_date(ippTimeToDate(time(NULL)))); in token_cb()
5341 …tal_error(data, "Missing DEFINE name and/or value on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
5345 else if (!strcmp(token, "DEFINE-DEFAULT")) in token_cb()
5348 * DEFINE-DEFAULT name value in token_cb()
5355 _ippVarsSet(vars, "date-current", iso_date(ippTimeToDate(time(NULL)))); in token_cb()
5362 …print_fatal_error(data, "Missing DEFINE-DEFAULT name and/or value on line %d of \"%s\".", f->linen… in token_cb()
5366 else if (!strcmp(token, "FILE-ID")) in token_cb()
5369 * FILE-ID "string" in token_cb()
5374 _ippVarsSet(vars, "date-current", iso_date(ippTimeToDate(time(NULL)))); in token_cb()
5375 _ippVarsExpand(vars, data->file_id, temp, sizeof(data->file_id)); in token_cb()
5379 … print_fatal_error(data, "Missing FILE-ID value on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
5383 else if (!strcmp(token, "IGNORE-ERRORS")) in token_cb()
5386 * IGNORE-ERRORS yes in token_cb()
5387 * IGNORE-ERRORS no in token_cb()
5392 data->def_ignore_errors = !_cups_strcasecmp(temp, "yes"); in token_cb()
5396 …print_fatal_error(data, "Missing IGNORE-ERRORS value on line %d of \"%s\".", f->linenum, f->filena… in token_cb()
5422 …if (!do_tests(get_filename(f->filename, filename, temp, sizeof(filename)), &inc_data) && data->sto… in token_cb()
5424 data->pass = data->prev_pass = 0; in token_cb()
5430 …print_fatal_error(data, "Missing INCLUDE filename on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
5434 data->show_header = 1; in token_cb()
5436 else if (!strcmp(token, "INCLUDE-IF-DEFINED")) in token_cb()
5439 * INCLUDE-IF-DEFINED name "filename" in token_cb()
5440 * INCLUDE-IF-DEFINED name <filename> in token_cb()
5458 …if (!do_tests(get_filename(f->filename, filename, temp, sizeof(filename)), &inc_data) && data->sto… in token_cb()
5460 data->pass = data->prev_pass = 0; in token_cb()
5466 …print_fatal_error(data, "Missing INCLUDE-IF-DEFINED name or filename on line %d of \"%s\".", f->li… in token_cb()
5470 data->show_header = 1; in token_cb()
5472 else if (!strcmp(token, "INCLUDE-IF-NOT-DEFINED")) in token_cb()
5475 * INCLUDE-IF-NOT-DEFINED name "filename" in token_cb()
5476 * INCLUDE-IF-NOT-DEFINED name <filename> in token_cb()
5494 …if (!do_tests(get_filename(f->filename, filename, temp, sizeof(filename)), &inc_data) && data->sto… in token_cb()
5496 data->pass = data->prev_pass = 0; in token_cb()
5502 …print_fatal_error(data, "Missing INCLUDE-IF-NOT-DEFINED name or filename on line %d of \"%s\".", f in token_cb()
5506 data->show_header = 1; in token_cb()
5508 else if (!strcmp(token, "SKIP-IF-DEFINED")) in token_cb()
5511 * SKIP-IF-DEFINED variable in token_cb()
5517 data->skip_test = 1; in token_cb()
5521 …print_fatal_error(data, "Missing SKIP-IF-DEFINED variable on line %d of \"%s\".", f->linenum, f->f… in token_cb()
5525 else if (!strcmp(token, "SKIP-IF-NOT-DEFINED")) in token_cb()
5528 * SKIP-IF-NOT-DEFINED variable in token_cb()
5534 data->skip_test = 1; in token_cb()
5538 …print_fatal_error(data, "Missing SKIP-IF-NOT-DEFINED variable on line %d of \"%s\".", f->linenum, … in token_cb()
5542 else if (!strcmp(token, "STOP-AFTER-INCLUDE-ERROR")) in token_cb()
5545 * STOP-AFTER-INCLUDE-ERROR yes in token_cb()
5546 * STOP-AFTER-INCLUDE-ERROR no in token_cb()
5551 data->stop_after_include_error = !_cups_strcasecmp(temp, "yes"); in token_cb()
5555 …print_fatal_error(data, "Missing STOP-AFTER-INCLUDE-ERROR value on line %d of \"%s\".", f->linenum… in token_cb()
5570 data->def_transfer = IPPTOOL_TRANSFER_AUTO; in token_cb()
5572 data->def_transfer = IPPTOOL_TRANSFER_CHUNKED; in token_cb()
5574 data->def_transfer = IPPTOOL_TRANSFER_LENGTH; in token_cb()
5577 …print_fatal_error(data, "Bad TRANSFER value \"%s\" on line %d of \"%s\".", temp, f->linenum, f->fi… in token_cb()
5583 … print_fatal_error(data, "Missing TRANSFER value on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
5592 data->def_version = 10; in token_cb()
5594 data->def_version = 11; in token_cb()
5596 data->def_version = 20; in token_cb()
5598 data->def_version = 21; in token_cb()
5600 data->def_version = 22; in token_cb()
5603 …print_fatal_error(data, "Bad VERSION \"%s\" on line %d of \"%s\".", temp, f->linenum, f->filename); in token_cb()
5609 … print_fatal_error(data, "Missing VERSION number on line %d of \"%s\".", f->linenum, f->filename); in token_cb()
5615 …atal_error(data, "Unexpected token %s seen on line %d of \"%s\".", token, f->linenum, f->filename); in token_cb()
5625 * 'usage()' - Show program usage.
5633 _cupsLangPuts(stderr, _("--ippserver filename Produce ippserver attribute file")); in usage()
5634 _cupsLangPuts(stderr, _("--stop-after-include-error\n" in usage()
5636 _cupsLangPuts(stderr, _("--version Show version")); in usage()
5637 _cupsLangPuts(stderr, _("-4 Connect using IPv4")); in usage()
5638 _cupsLangPuts(stderr, _("-6 Connect using IPv6")); in usage()
5639 _cupsLangPuts(stderr, _("-C Send requests using chunking (default)")); in usage()
5640 …_cupsLangPuts(stderr, _("-E Test with encryption using HTTP Upgrade to TLS")); in usage()
5641 _cupsLangPuts(stderr, _("-I Ignore errors")); in usage()
5642 _cupsLangPuts(stderr, _("-L Send requests using content-length")); in usage()
5643 …_cupsLangPuts(stderr, _("-P filename.plist Produce XML plist to a file and test report to st… in usage()
5644 _cupsLangPuts(stderr, _("-R Repeat tests on server-error-busy")); in usage()
5645 _cupsLangPuts(stderr, _("-S Test with encryption using HTTPS")); in usage()
5646 _cupsLangPuts(stderr, _("-T seconds Set the receive/send timeout in seconds")); in usage()
5647 _cupsLangPuts(stderr, _("-V version Set default IPP version")); in usage()
5648 _cupsLangPuts(stderr, _("-X Produce XML plist instead of plain text")); in usage()
5649 _cupsLangPuts(stderr, _("-c Produce CSV output")); in usage()
5650 _cupsLangPuts(stderr, _("-d name=value Set named variable to value")); in usage()
5651 _cupsLangPuts(stderr, _("-f filename Set default request filename")); in usage()
5652 _cupsLangPuts(stderr, _("-h Validate HTTP response headers")); in usage()
5653 …_cupsLangPuts(stderr, _("-i seconds Repeat the last file with the given time interval… in usage()
5654 _cupsLangPuts(stderr, _("-l Produce plain text output")); in usage()
5655 …_cupsLangPuts(stderr, _("-n count Repeat the last file the given number of times")); in usage()
5656 _cupsLangPuts(stderr, _("-q Run silently")); in usage()
5657 _cupsLangPuts(stderr, _("-t Produce a test report")); in usage()
5658 _cupsLangPuts(stderr, _("-v Be verbose")); in usage()
5665 * 'with_distinct_values()' - Verify that an attribute contains unique values.
5668 static int // O - 1 if distinct, 0 if duplicate
5670 cups_array_t *errors, // I - Array of errors in with_distinct_values()
5671 ipp_attribute_t *attr) // I - Attribute to test in with_distinct_values()
5685 // Only check integers, enums, rangeOfInteger, resolution, and nul-terminated in with_distinct_values()
5702 …add_stringf(errors, "WITH-DISTINCT-VALUES %s not supported for 1setOf %s", ippGetName(attr), ippTa… in with_distinct_values()
5723 snprintf(buffer, sizeof(buffer), "%d-%d", lower, upper); in with_distinct_values()
5756 …for (prefix = '{', bufptr = buffer, bufend = buffer + sizeof(buffer) - 2, member = ippFirstAttribu… in with_distinct_values()
5761 ippAttributeString(member, bufptr, (size_t)(bufend - bufptr)); in with_distinct_values()
5790 * 'with_flags_string()' - Return the "WITH-xxx" predicate that corresponds to
5794 static const char * /* O - WITH-xxx string */
5795 with_flags_string(int flags) /* I - WITH flags */ in with_flags_string()
5800 return ("WITH-ALL-HOSTNAMES"); in with_flags_string()
5802 return ("WITH-ALL-RESOURCES"); in with_flags_string()
5804 return ("WITH-ALL-SCHEMES"); in with_flags_string()
5806 return ("WITH-ALL-VALUES"); in with_flags_string()
5809 return ("WITH-HOSTNAME"); in with_flags_string()
5811 return ("WITH-RESOURCE"); in with_flags_string()
5813 return ("WITH-SCHEME"); in with_flags_string()
5815 return ("WITH-VALUE"); in with_flags_string()
5820 * 'with_value()' - Test a WITH-VALUE predicate.
5823 static int /* O - 1 on match, 0 on non-match */
5824 with_value(ipptool_test_t *data, /* I - Test data */ in with_value()
5825 cups_array_t *errors, /* I - Errors array */ in with_value()
5826 char *value, /* I - Value string */ in with_value()
5827 int flags, /* I - Flags for match */ in with_value()
5828 ipp_attribute_t *attr, /* I - Attribute to compare */ in with_value()
5829 char *matchbuf, /* I - Buffer to hold matching value */ in with_value()
5830 size_t matchlen) /* I - Length of match buffer */ in with_value()
5873 *valptr == '-' || *valptr == ',' || *valptr == '<' || in with_value()
5877 while (*valptr && !isdigit(*valptr & 255) && *valptr != '-') in with_value()
5922 add_stringf(data->errors, "GOT: %s=%d", name, ippGetInteger(attr, i)); in with_value()
5940 *valptr == '-' || *valptr == ',' || *valptr == '<' || in with_value()
5944 while (*valptr && !isdigit(*valptr & 255) && *valptr != '-') in with_value()
5964 snprintf(matchbuf, matchlen, "%d-%d", lower, upper); in with_value()
5993 add_stringf(data->errors, "GOT: %s=%d-%d", name, lower, upper); in with_value()
6022 add_stringf(data->errors, "GOT: %s=%s", name, ippGetBoolean(attr, i) ? "true" : "false"); in with_value()
6070 add_stringf(data->errors, "GOT: %s=%s", name, temp); in with_value()
6092 * Value is an extended, case-sensitive POSIX regular expression... in with_value()
6101 …print_fatal_error(data, "Unable to compile WITH-VALUE regular expression \"%s\" - %s", value, temp… in with_value()
6172 * Some URI components are case-sensitive, some not... in with_value()
6189 * be case-insensitive strings... in with_value()
6198 * case-sensitive comparisons to catch problems... in with_value()
6227 add_stringf(data->errors, "GOT: %s=\"%s\"", name, ippGetString(attr, i, NULL)); in with_value()
6235 * Value is an extended, case-sensitive POSIX regular expression... in with_value()
6246 …print_fatal_error(data, "Unable to compile WITH-VALUE regular expression \"%s\" - %s", value, temp… in with_value()
6290 add_stringf(data->errors, "GOT: %s=\"%s\"", name, temp); in with_value()
6297 * Value is a literal or hex-encoded string... in with_value()
6300 unsigned char withdata[1023], /* WITH-VALUE data */ in with_value()
6302 int withlen, /* Length of WITH-VALUE data */ in with_value()
6308 * Grab hex-encoded value... in with_value()
6313 print_fatal_error(data, "Bad WITH-VALUE hex value."); in with_value()
6317 withlen = withlen / 2 - 1; in with_value()
6324 ch = (valptr[0] - '0') << 4; in with_value()
6326 ch = (tolower(valptr[0]) - 'a' + 10) << 4; in with_value()
6331 ch |= valptr[1] - '0'; in with_value()
6333 ch |= tolower(valptr[1]) - 'a' + 10; in with_value()
6342 print_fatal_error(data, "Bad WITH-VALUE hex value."); in with_value()
6385 add_stringf(data->errors, "GOT: %s=\"%s\"", name, temp); in with_value()
6400 * 'with_value_from()' - Test a WITH-VALUE-FROM predicate.
6403 static int /* O - 1 on match, 0 on non-match */
6405 cups_array_t *errors, /* I - Errors array */ in with_value_from()
6406 ipp_attribute_t *fromattr, /* I - "From" attribute */ in with_value_from()
6407 ipp_attribute_t *attr, /* I - Attribute to compare */ in with_value_from()
6408 char *matchbuf, /* I - Buffer to hold matching value */ in with_value_from()
6409 size_t matchlen) /* I - Length of match buffer */ in with_value_from()
6577 add_stringf(errors, "GOT: %s OF-TYPE %s", ippGetName(attr), ippTagString(ippGetValueTag(attr))); in with_value_from()