static void list_options(cups_dest_t *dest) /* I - Destination to list */ { http_t *http; /* Connection to destination */ char resource[1024]; /* Resource path */ int i; /* Looping var */ const char *filename; /* PPD filename */ ppd_file_t *ppd; /* PPD data */ ppd_group_t *group; /* Current group */ if ((http = cupsConnectDest(dest, CUPS_DEST_FLAGS_NONE, 30000, NULL, resource, sizeof(resource), NULL, NULL)) == NULL) { _cupsLangPrintf(stderr, _("lpoptions: Unable to get PPD file for %s: %s"), dest->name, cupsLastErrorString()); return; } if ((filename = cupsGetPPD2(http, dest->name)) == NULL) { httpClose(http); _cupsLangPrintf(stderr, _("lpoptions: Unable to get PPD file for %s: %s"), dest->name, cupsLastErrorString()); return; } httpClose(http); if ((ppd = ppdOpenFile(filename)) == NULL) { unlink(filename); _cupsLangPrintf(stderr, _("lpoptions: Unable to open PPD file for %s."), dest->name); return; } ppdMarkDefaults(ppd); cupsMarkOptions(ppd, dest->num_options, dest->options); for (i = ppd->num_groups, group = ppd->groups; i > 0; i --, group ++) list_group(ppd, group); ppdClose(ppd); unlink(filename); }
const char * /* O - Filename for PPD file */ cupsGetPPD(const char *name) /* I - Printer name */ { _cups_globals_t *cg = _cupsGlobals(); /* Pointer to library globals */ /* * See if we can connect to the server... */ if (!cups_connect(name, NULL, NULL)) { DEBUG_puts("Unable to connect to server!"); return (NULL); } /* * Return the PPD file... */ return (cupsGetPPD2(cg->http, name)); }