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

Function check_printer_state

backend/ipp.c:2437–2492  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2435 */
2436
2437static ipp_pstate_t /* O - Current printer-state */
2438check_printer_state(
2439 http_t *http, /* I - HTTP connection */
2440 const char *uri, /* I - Printer URI */
2441 const char *resource, /* I - Resource path */
2442 const char *user, /* I - Username, if any */
2443 int version) /* I - IPP version */
2444 {
2445 ipp_t *request, /* IPP request */
2446 *response; /* IPP response */
2447 ipp_attribute_t *attr; /* Attribute in response */
2448 ipp_pstate_t printer_state = IPP_PSTATE_STOPPED;
2449 /* Current printer-state */
2450
2451
2452 /*
2453 * Send a Get-Printer-Attributes request and log the results...
2454 */
2455
2456 request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
2457 ippSetVersion(request, version / 10, version % 10);
2458
2459 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri",
2460 NULL, uri);
2461
2462 if (user && user[0])
2463 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_NAME,
2464 "requesting-user-name", NULL, user);
2465
2466 ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD,
2467 "requested-attributes",
2468 (int)(sizeof(pattrs) / sizeof(pattrs[0])), NULL, pattrs);
2469
2470 fprintf(stderr, "DEBUG: IPP/%d.%d %s #%d\n", version / 10, version % 10, ippOpString(ippGetOperation(request)), ippGetRequestId(request));
2471 debug_attributes(request);
2472
2473 if ((response = cupsDoRequest(http, request, resource)) != NULL)
2474 {
2475 report_printer_state(response);
2476
2477 if ((attr = ippFindAttribute(response, "printer-state",
2478 IPP_TAG_ENUM)) != NULL)
2479 printer_state = (ipp_pstate_t)attr->values[0].integer;
2480 }
2481
2482 fprintf(stderr, "DEBUG: Get-Printer-Attributes: %s (%s)\n",
2483 ippErrorString(cupsLastError()), cupsLastErrorString());
2484 debug_attributes(response);
2485 ippDelete(response);
2486
2487 /*
2488 * Return the printer-state value...
2489 */
2490
2491 return (printer_state);
2492}
2493
2494

Callers 2

mainFunction · 0.85
monitor_printerFunction · 0.85

Calls 15

ippNewRequestFunction · 0.85
ippSetVersionFunction · 0.85
ippAddStringFunction · 0.85
ippAddStringsFunction · 0.85
ippOpStringFunction · 0.85
ippGetOperationFunction · 0.85
ippGetRequestIdFunction · 0.85
cupsDoRequestFunction · 0.85
report_printer_stateFunction · 0.85
ippFindAttributeFunction · 0.85
ippErrorStringFunction · 0.85
cupsLastErrorFunction · 0.85

Tested by

no test coverage detected