[cups.development] Device Uri

Michael Sweet msweet at apple.com
Thu Jan 27 08:02:15 PST 2011


On Jan 27, 2011, at 5:45 AM, Naa Nu wrote:
> Hello,
> 
> How can i get the Device URI using any CUPS method  or any subscription attribute method.

The device URI of an existing print queue? Use the IPP_GET_PRINTER_ATTRIBUTES request like so:

    #include <cups/cups.h>

    const char *printer; /* printer name */
    ipp_t *request, *response;
    ipp_attribute_t *device_uri;
    char printer_uri[1024];

    httpAssembleURIf(HTTP_URI_CODING_ALL, printer_uri, sizeof(printer_uri), "ipp", NULL, "localhost", 0, "/printers/%s", printer);

    request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES);
    ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", NULL, printer_uri);
    ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_KEYWORD, "requested-attributes", NULL, "device-uri");

    response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/");

    device_uri = ippFindAttribute(response, "device-uri", IPP_TAG_URI);
    /* device-uri string is in device_uri->values[0].string.text */

________________________________________________________________________
Michael Sweet, Senior Printing System Engineer, PWG Chair





More information about the cups-devel mailing list