0

Anyone know to get a printer URI using CUPS API?

If not, does anyone know where I can find a list of allowable options that can be passed to cupsGetOption function.

Right now I can only find printer-info, printer-location, printer-make-and-model.

trueinViso
  • 1,354
  • 3
  • 18
  • 30

1 Answers1

2

What your probably looking for is a the "device-uri". This is the uri to the remote device i.e lpd/socket/server address. If you're looking for the local uri it would be "printer-uri-supported" which would result in ipp://localhost:631/printers/printername. Here's how to get the remote uri...

#import <cups/cups.h>

const char * printer = "name_of_printer";
int num_dests;
cups_dest_t *dest,
            *dests;

const char *value;

num_dests = cupsGetDests(&dests);
dest = cupsGetDest(printer, NULL, num_dests, dests);
if( dest == NULL){
    return 0;
};
value = NULL;

if (dest->instance == NULL)
{
    value = cupsGetOption("device-uri", dest->num_options, dest->options);
}

cupsFreeDests(num_dests, dests);
printf("uri - %s",value);
The Pulsing Eye
  • 161
  • 3
  • 11