MCPcopy Create free account
hub / github.com/OpenPrinting/cups / do_monitor_printer_state

Function do_monitor_printer_state

tools/ipptool.c:926–1158  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

924 */
925
926static void * // O - Thread exit status
927do_monitor_printer_state(
928 ipptool_test_t *data) // I - Test data
929{
930 int i, j; // Looping vars
931 char scheme[32], // URI scheme
932 userpass[32], // URI username:password
933 host[256], // URI hostname/IP address
934 resource[256]; // URI resource path
935 int port; // URI port number
936 http_encryption_t encryption; // Encryption to use
937 http_t *http; // Connection to printer
938 ipp_t *request, // IPP request
939 *response = NULL; // IPP response
940 http_status_t status; // Request status
941 ipp_attribute_t *found; // Found attribute
942 ipptool_expect_t *expect; // Current EXPECT test
943 char buffer[131072]; // Copy buffer
944 int num_pattrs; // Number of printer attributes
945 const char *pattrs[100]; // Printer attributes we care about
946
947
948 // Connect to the printer...
949 if (httpSeparateURI(HTTP_URI_CODING_ALL, data->monitor_uri, scheme, sizeof(scheme), userpass, sizeof(userpass), host, sizeof(host), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
950 {
951 print_fatal_error(data, "Bad printer URI \"%s\".", data->monitor_uri);
952 return (NULL);
953 }
954
955 if (!_cups_strcasecmp(scheme, "https") || !_cups_strcasecmp(scheme, "ipps") || port == 443)
956 encryption = HTTP_ENCRYPTION_ALWAYS;
957 else
958 encryption = data->encryption;
959
960 if ((http = httpConnect2(host, port, NULL, data->family, encryption, 1, 30000, NULL)) == NULL)
961 {
962 print_fatal_error(data, "Unable to connect to \"%s\" on port %d - %s", host, port, cupsLastErrorString());
963 return (0);
964 }
965
966#ifdef HAVE_LIBZ
967 httpSetDefaultField(http, HTTP_FIELD_ACCEPT_ENCODING, "deflate, gzip, identity");
968#else
969 httpSetDefaultField(http, HTTP_FIELD_ACCEPT_ENCODING, "identity");
970#endif /* HAVE_LIBZ */
971
972 if (data->timeout > 0.0)
973 httpSetTimeout(http, data->timeout, timeout_cb, NULL);
974
975 // Wait for the initial delay as needed...
976 if (data->monitor_delay)
977 usleep(data->monitor_delay);
978
979 // Create a query request that we'll reuse...
980 request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
981 ippSetRequestId(request, data->request_id * 100 - 1);
982 ippSetVersion(request, data->version / 10, data->version % 10);
983 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, data->monitor_uri);

Callers

nothing calls this directly

Calls 15

httpSeparateURIFunction · 0.85
print_fatal_errorFunction · 0.85
_cups_strcasecmpFunction · 0.85
httpConnect2Function · 0.85
cupsLastErrorStringFunction · 0.85
httpSetDefaultFieldFunction · 0.85
httpSetTimeoutFunction · 0.85
ippNewRequestFunction · 0.85
ippSetRequestIdFunction · 0.85
ippSetVersionFunction · 0.85
ippAddStringFunction · 0.85
cupsUserFunction · 0.85

Tested by

no test coverage detected