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

Function _ppdCacheGetInputSlot

cups/ppd-cache.c:2381–2435  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2379 */
2380
2381const char * /* O - PPD InputSlot or NULL */
2382_ppdCacheGetInputSlot(
2383 _ppd_cache_t *pc, /* I - PPD cache and mapping data */
2384 ipp_t *job, /* I - Job attributes or NULL */
2385 const char *keyword) /* I - Keyword string or NULL */
2386{
2387 /*
2388 * Range check input...
2389 */
2390
2391 if (!pc || pc->num_sources == 0 || (!job && !keyword))
2392 return (NULL);
2393
2394 if (job && !keyword)
2395 {
2396 /*
2397 * Lookup the media-col attribute and any media-source found there...
2398 */
2399
2400 ipp_attribute_t *media_col, /* media-col attribute */
2401 *media_source; /* media-source attribute */
2402 pwg_size_t size; /* Dimensional size */
2403 int margins_set; /* Were the margins set? */
2404
2405 media_col = ippFindAttribute(job, "media-col", IPP_TAG_BEGIN_COLLECTION);
2406 if (media_col &&
2407 (media_source = ippFindAttribute(ippGetCollection(media_col, 0),
2408 "media-source",
2409 IPP_TAG_KEYWORD)) != NULL)
2410 {
2411 /*
2412 * Use the media-source value from media-col...
2413 */
2414
2415 keyword = ippGetString(media_source, 0, NULL);
2416 }
2417 else if (pwgInitSize(&size, job, &margins_set))
2418 {
2419 /*
2420 * For media <= 5x7, try to ask for automatic selection so the printer can
2421 * pick the photo tray. If auto isn't available, fall back to explicitly
2422 * asking for the photo tray.
2423 */
2424
2425 if (size.width <= (5 * 2540) && size.length <= (7 * 2540)) {
2426 const char* match;
2427 if ((match = ppd_inputslot_for_keyword(pc, "auto")) != NULL)
2428 return (match);
2429 keyword = "photo";
2430 }
2431 }
2432 }
2433
2434 return (ppd_inputslot_for_keyword(pc, keyword));
2435}
2436
2437
2438/*

Callers 3

get_optionsFunction · 0.85
get_optionsFunction · 0.85
cupsMarkOptionsFunction · 0.85

Calls 5

ippFindAttributeFunction · 0.85
ippGetCollectionFunction · 0.85
ippGetStringFunction · 0.85
pwgInitSizeFunction · 0.85

Tested by

no test coverage detected