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

Function cupsLocalizeDestMedia

cups/dest-localization.c:36–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34 */
35
36const char * /* O - Localized string */
37cupsLocalizeDestMedia(
38 http_t *http, /* I - Connection to destination */
39 cups_dest_t *dest, /* I - Destination */
40 cups_dinfo_t *dinfo, /* I - Destination information */
41 unsigned flags, /* I - Media flags */
42 cups_size_t *size) /* I - Media size */
43{
44 cups_lang_t *lang; /* Standard localizations */
45 _cups_message_t key, /* Search key */
46 *match; /* Matching entry */
47 pwg_media_t *pwg; /* PWG media information */
48 cups_array_t *db; /* Media database */
49 _cups_media_db_t *mdb; /* Media database entry */
50 char lstr[1024], /* Localized size name */
51 temp[256]; /* Temporary string */
52 const char *lsize, /* Localized media size */
53 *lsource, /* Localized media source */
54 *ltype; /* Localized media type */
55
56
57 DEBUG_printf(("cupsLocalizeDestMedia(http=%p, dest=%p, dinfo=%p, flags=%x, size=%p(\"%s\"))", (void *)http, (void *)dest, (void *)dinfo, flags, (void *)size, size ? size->media : "(null)"));
58
59 /*
60 * Range check input...
61 */
62
63 if (!http || !dest || !dinfo || !size)
64 {
65 DEBUG_puts("1cupsLocalizeDestMedia: Returning NULL.");
66 _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
67 return (NULL);
68 }
69
70 /*
71 * Find the matching media database entry...
72 */
73
74 if (flags & CUPS_MEDIA_FLAGS_READY)
75 db = dinfo->ready_db;
76 else
77 db = dinfo->media_db;
78
79 DEBUG_printf(("1cupsLocalizeDestMedia: size->media=\"%s\"", size->media));
80
81 for (mdb = (_cups_media_db_t *)cupsArrayFirst(db); mdb; mdb = (_cups_media_db_t *)cupsArrayNext(db))
82 {
83 if (mdb->key && !strcmp(mdb->key, size->media))
84 break;
85 else if (mdb->size_name && !strcmp(mdb->size_name, size->media))
86 break;
87 }
88
89 if (!mdb)
90 {
91 for (mdb = (_cups_media_db_t *)cupsArrayFirst(db); mdb; mdb = (_cups_media_db_t *)cupsArrayNext(db))
92 {
93 if (mdb->width == size->width && mdb->length == size->length && mdb->bottom == size->bottom && mdb->left == size->left && mdb->right == size->right && mdb->top == size->top)

Callers 2

show_mediaFunction · 0.85
cupsLocalizeDestValueFunction · 0.85

Calls 10

_cupsSetErrorFunction · 0.85
cupsArrayFirstFunction · 0.85
cupsArrayNextFunction · 0.85
cupsLangDefaultFunction · 0.85
cupsArrayFindFunction · 0.85
pwgMediaForSizeFunction · 0.85
_cupsLangStringFunction · 0.85
cupsLocalizeDestValueFunction · 0.85
cupsArrayAddFunction · 0.85

Tested by 1

show_mediaFunction · 0.68