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

Function _cupsUserDefault

cups/dest.c:2290–2336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2288 */
2289
2290char * /* O - Default printer or NULL */
2291_cupsUserDefault(char *name, /* I - Name buffer */
2292 size_t namesize) /* I - Size of name buffer */
2293{
2294 const char *env; /* LPDEST or PRINTER env variable */
2295#ifdef __APPLE__
2296 CFStringRef locprinter; /* Last printer as this location */
2297#endif /* __APPLE__ */
2298
2299
2300 if ((env = getenv("LPDEST")) == NULL)
2301 if ((env = getenv("PRINTER")) != NULL && !strcmp(env, "lp"))
2302 env = NULL;
2303
2304 if (env)
2305 {
2306 strlcpy(name, env, namesize);
2307 return (name);
2308 }
2309
2310#ifdef __APPLE__
2311 /*
2312 * Use location-based defaults if "use last printer" is selected in the
2313 * system preferences...
2314 */
2315
2316 if (!getenv("CUPS_NO_APPLE_DEFAULT") && (locprinter = _cupsAppleCopyDefaultPrinter()) != NULL)
2317 {
2318 CFStringGetCString(locprinter, name, (CFIndex)namesize, kCFStringEncodingUTF8);
2319 CFRelease(locprinter);
2320 }
2321 else
2322 name[0] = '\0';
2323
2324 DEBUG_printf(("1_cupsUserDefault: Returning \"%s\".", name));
2325
2326 return (*name ? name : NULL);
2327
2328#else
2329 /*
2330 * No location-based defaults on this platform...
2331 */
2332
2333 name[0] = '\0';
2334 return (NULL);
2335#endif /* __APPLE__ */
2336}
2337
2338
2339#if _CUPS_LOCATION_DEFAULTS

Callers 3

cupsGetNamedDestFunction · 0.85
cups_enum_destsFunction · 0.85
cupsGetDefault2Function · 0.85

Calls 1

Tested by

no test coverage detected