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

Function cupsGetDestMediaDefault

cups/dest-options.c:1322–1377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1320 */
1321
1322int /* O - 1 on success, 0 on failure */
1323cupsGetDestMediaDefault(
1324 http_t *http, /* I - Connection to destination */
1325 cups_dest_t *dest, /* I - Destination */
1326 cups_dinfo_t *dinfo, /* I - Destination information */
1327 unsigned flags, /* I - Media flags */
1328 cups_size_t *size) /* O - Media size information */
1329{
1330 const char *media; /* Default media size */
1331
1332
1333 /*
1334 * Get the default connection as needed...
1335 */
1336
1337 if (!http)
1338 http = _cupsConnect();
1339
1340 /*
1341 * Range check input...
1342 */
1343
1344 if (size)
1345 memset(size, 0, sizeof(cups_size_t));
1346
1347 if (!http || !dest || !dinfo || !size)
1348 {
1349 _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
1350 return (0);
1351 }
1352
1353 /*
1354 * Get the default media size, if any...
1355 */
1356
1357 if ((media = cupsGetOption("media", dest->num_options, dest->options)) == NULL)
1358 media = "na_letter_8.5x11in";
1359
1360 if (cupsGetDestMediaByName(http, dest, dinfo, media, flags, size))
1361 return (1);
1362
1363 if (strcmp(media, "na_letter_8.5x11in") && cupsGetDestMediaByName(http, dest, dinfo, "iso_a4_210x297mm", flags, size))
1364 return (1);
1365
1366 if (strcmp(media, "iso_a4_210x297mm") && cupsGetDestMediaByName(http, dest, dinfo, "na_letter_8.5x11in", flags, size))
1367 return (1);
1368
1369 if ((flags & CUPS_MEDIA_FLAGS_BORDERLESS) && cupsGetDestMediaByName(http, dest, dinfo, "na_index_4x6in", flags, size))
1370 return (1);
1371
1372 /*
1373 * Fall back to the first matching media size...
1374 */
1375
1376 return (cupsGetDestMediaByIndex(http, dest, dinfo, 0, flags, size));
1377}
1378
1379

Callers 1

show_defaultFunction · 0.85

Calls 5

_cupsConnectFunction · 0.85
_cupsSetErrorFunction · 0.85
cupsGetOptionFunction · 0.85
cupsGetDestMediaByNameFunction · 0.85
cupsGetDestMediaByIndexFunction · 0.85

Tested by 1

show_defaultFunction · 0.68