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

Function _ppdCacheGetSize

cups/ppd-cache.c:2769–2899  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2767 */
2768
2769pwg_size_t * /* O - PWG size or NULL */
2770_ppdCacheGetSize(
2771 _ppd_cache_t *pc, /* I - PPD cache and mapping data */
2772 const char *page_size, /* I - PPD PageSize */
2773 ppd_size_t *ppd_size) /* I - PPD page size information */
2774{
2775 int i; /* Looping var */
2776 pwg_media_t *media; /* Media */
2777 pwg_size_t *size; /* Current size */
2778
2779
2780 /*
2781 * Range check input...
2782 */
2783
2784 if (!pc || !page_size)
2785 return (NULL);
2786
2787 if (!_cups_strcasecmp(page_size, "Custom") || !_cups_strncasecmp(page_size, "Custom.", 7))
2788 {
2789 /*
2790 * Custom size; size name can be one of the following:
2791 *
2792 * Custom.WIDTHxLENGTHin - Size in inches
2793 * Custom.WIDTHxLENGTHft - Size in feet
2794 * Custom.WIDTHxLENGTHcm - Size in centimeters
2795 * Custom.WIDTHxLENGTHmm - Size in millimeters
2796 * Custom.WIDTHxLENGTHm - Size in meters
2797 * Custom.WIDTHxLENGTH[pt] - Size in points
2798 */
2799
2800 double w, l; /* Width and length of page */
2801 char *ptr; /* Pointer into PageSize */
2802 struct lconv *loc; /* Locale data */
2803
2804 if (page_size[6])
2805 {
2806 loc = localeconv();
2807 w = (float)_cupsStrScand(page_size + 7, &ptr, loc);
2808 if (!ptr || *ptr != 'x')
2809 return (NULL);
2810
2811 l = (float)_cupsStrScand(ptr + 1, &ptr, loc);
2812 if (!ptr)
2813 return (NULL);
2814
2815 if (!_cups_strcasecmp(ptr, "in"))
2816 {
2817 w *= 2540.0;
2818 l *= 2540.0;
2819 }
2820 else if (!_cups_strcasecmp(ptr, "ft"))
2821 {
2822 w *= 12.0 * 2540.0;
2823 l *= 12.0 * 2540.0;
2824 }
2825 else if (!_cups_strcasecmp(ptr, "mm"))
2826 {

Callers 4

load_ppdFunction · 0.85
mainFunction · 0.85
_cupsConvertOptionsFunction · 0.85
mainFunction · 0.85

Calls 7

_cups_strcasecmpFunction · 0.85
_cups_strncasecmpFunction · 0.85
_cupsStrScandFunction · 0.85
pwgMediaForSizeFunction · 0.85
pwgMediaForPPDFunction · 0.85
pwgMediaForLegacyFunction · 0.85
pwgMediaForPWGFunction · 0.85

Tested by 1

mainFunction · 0.68