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

Function _ppdCacheGetPageSize

cups/ppd-cache.c:2530–2762  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2528 */
2529
2530const char * /* O - PPD PageSize or NULL */
2531_ppdCacheGetPageSize(
2532 _ppd_cache_t *pc, /* I - PPD cache and mapping data */
2533 ipp_t *job, /* I - Job attributes or NULL */
2534 const char *keyword, /* I - Keyword string or NULL */
2535 int *exact) /* O - 1 if exact match, 0 otherwise */
2536{
2537 int i; /* Looping var */
2538 pwg_size_t *size, /* Current size */
2539 *closest, /* Closest size */
2540 jobsize; /* Size data from job */
2541 int margins_set, /* Were the margins set? */
2542 dwidth, /* Difference in width */
2543 dlength, /* Difference in length */
2544 dleft, /* Difference in left margins */
2545 dright, /* Difference in right margins */
2546 dbottom, /* Difference in bottom margins */
2547 dtop, /* Difference in top margins */
2548 dmin, /* Minimum difference */
2549 dclosest; /* Closest difference */
2550 const char *ppd_name; /* PPD media name */
2551
2552
2553 DEBUG_printf(("_ppdCacheGetPageSize(pc=%p, job=%p, keyword=\"%s\", exact=%p)",
2554 pc, job, keyword, exact));
2555
2556 /*
2557 * Range check input...
2558 */
2559
2560 if (!pc || (!job && !keyword))
2561 return (NULL);
2562
2563 if (exact)
2564 *exact = 0;
2565
2566 ppd_name = keyword;
2567
2568 if (job)
2569 {
2570 /*
2571 * Try getting the PPD media name from the job attributes...
2572 */
2573
2574 ipp_attribute_t *attr; /* Job attribute */
2575
2576 if ((attr = ippFindAttribute(job, "PageSize", IPP_TAG_ZERO)) == NULL)
2577 if ((attr = ippFindAttribute(job, "PageRegion", IPP_TAG_ZERO)) == NULL)
2578 attr = ippFindAttribute(job, "media", IPP_TAG_ZERO);
2579
2580#ifdef DEBUG
2581 if (attr)
2582 DEBUG_printf(("1_ppdCacheGetPageSize: Found attribute %s (%s)",
2583 attr->name, ippTagString(attr->value_tag)));
2584 else
2585 DEBUG_puts("1_ppdCacheGetPageSize: Did not find media attribute.");
2586#endif /* DEBUG */
2587

Callers 5

add_jobFunction · 0.85
get_optionsFunction · 0.85
cupsMarkOptionsFunction · 0.85
mainFunction · 0.85
test_pagesizeFunction · 0.85

Calls 8

ippFindAttributeFunction · 0.85
ippTagStringFunction · 0.85
_cups_strcasecmpFunction · 0.85
pwgInitSizeFunction · 0.85
pwgMediaForPWGFunction · 0.85
pwgMediaForLegacyFunction · 0.85
pwgMediaForPPDFunction · 0.85
_cups_strncasecmpFunction · 0.85

Tested by 2

mainFunction · 0.68
test_pagesizeFunction · 0.68