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

Function monitor_printer

cups/testclient.c:621–751  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

619 */
620
621static void * /* O - Thread exit code */
622monitor_printer(
623 _client_data_t *data) /* I - Client data */
624{
625 http_t *http; /* Connection to printer */
626 ipp_t *request, /* IPP request */
627 *response; /* IPP response */
628 ipp_attribute_t *attr; /* Attribute in response */
629 ipp_pstate_t printer_state; /* Printer state */
630 char printer_state_reasons[1024];
631 /* Printer state reasons */
632 ipp_jstate_t job_state; /* Job state */
633 char job_state_reasons[1024];/* Printer state reasons */
634 static const char * const jattrs[] = /* Job attributes we want */
635 {
636 "job-state",
637 "job-state-reasons"
638 };
639 static const char * const pattrs[] = /* Printer attributes we want */
640 {
641 "printer-state",
642 "printer-state-reasons"
643 };
644
645
646 /*
647 * Open a connection to the printer...
648 */
649
650 http = httpConnect2(data->hostname, data->port, NULL, AF_UNSPEC, data->encryption, 1, 0, NULL);
651
652 /*
653 * Loop until the job is canceled, aborted, or completed.
654 */
655
656 printer_state = (ipp_pstate_t)0;
657 printer_state_reasons[0] = '\0';
658
659 job_state = (ipp_jstate_t)0;
660 job_state_reasons[0] = '\0';
661
662 while (data->job_state < IPP_JSTATE_CANCELED)
663 {
664 /*
665 * Reconnect to the printer as needed...
666 */
667
668 if (httpGetFd(http) < 0)
669 httpReconnect2(http, 30000, NULL);
670
671 if (httpGetFd(http) >= 0)
672 {
673 /*
674 * Connected, so check on the printer state...
675 */
676
677 request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
678 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, data->uri);

Callers

nothing calls this directly

Calls 15

httpConnect2Function · 0.85
httpGetFdFunction · 0.85
httpReconnect2Function · 0.85
ippNewRequestFunction · 0.85
ippAddStringFunction · 0.85
cupsUserFunction · 0.85
ippAddStringsFunction · 0.85
cupsDoRequestFunction · 0.85
ippFindAttributeFunction · 0.85
ippGetIntegerFunction · 0.85
ippAttributeStringFunction · 0.85
ippEnumStringFunction · 0.85

Tested by

no test coverage detected