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

Function cups_get_printer_uri

cups/ppd-util.c:544–668  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

542 */
543
544static int /* O - 1 on success, 0 on failure */
545cups_get_printer_uri(
546 http_t *http, /* I - Connection to server */
547 const char *name, /* I - Name of printer or class */
548 char *host, /* I - Hostname buffer */
549 int hostsize, /* I - Size of hostname buffer */
550 int *port, /* O - Port number */
551 char *resource, /* I - Resource buffer */
552 int resourcesize) /* I - Size of resource buffer */
553{
554 int i; /* Looping var */
555 ipp_t *request, /* IPP request */
556 *response; /* IPP response */
557 ipp_attribute_t *attr; /* Current attribute */
558 char uri[HTTP_MAX_URI], /* printer-uri attribute */
559 scheme[HTTP_MAX_URI], /* Scheme name */
560 username[HTTP_MAX_URI]; /* Username:password */
561 static const char * const requested_attrs[] =
562 { /* Requested attributes */
563 "member-uris",
564 "printer-uri-supported"
565 };
566
567
568 DEBUG_printf(("4cups_get_printer_uri(http=%p, name=\"%s\", host=%p, hostsize=%d, resource=%p, resourcesize=%d)", http, name, host, hostsize, resource, resourcesize));
569
570 /*
571 * Setup the printer URI...
572 */
573
574 if (httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, "localhost", 0, "/printers/%s", name) < HTTP_URI_STATUS_OK)
575 {
576 _cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Unable to create printer-uri"), 1);
577
578 *host = '\0';
579 *resource = '\0';
580
581 return (0);
582 }
583
584 DEBUG_printf(("5cups_get_printer_uri: printer-uri=\"%s\"", uri));
585
586 /*
587 * Build an IPP_GET_PRINTER_ATTRIBUTES request, which requires the following
588 * attributes:
589 *
590 * attributes-charset
591 * attributes-natural-language
592 * printer-uri
593 * requested-attributes
594 */
595
596 request = ippNewRequest(IPP_OP_GET_PRINTER_ATTRIBUTES);
597
598 ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, uri);
599
600 ippAddStrings(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", sizeof(requested_attrs) / sizeof(requested_attrs[0]), NULL, requested_attrs);
601

Callers 1

cupsGetPPD3Function · 0.85

Calls 12

httpAssembleURIfFunction · 0.85
_cupsSetErrorFunction · 0.85
ippNewRequestFunction · 0.85
ippAddStringFunction · 0.85
ippAddStringsFunction · 0.85
cupsDoRequestFunction · 0.85
ippFindAttributeFunction · 0.85
ippGetCountFunction · 0.85
ippGetStringFunction · 0.85
httpSeparateURIFunction · 0.85
ippDeleteFunction · 0.85
cupsLastErrorFunction · 0.85

Tested by

no test coverage detected