summaryrefslogtreecommitdiff
path: root/cups/dest-options.c
diff options
context:
space:
mode:
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2014-05-16 21:02:15 +0000
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>2014-05-16 21:02:15 +0000
commitae26bf708c7cc06c8dce6d672c2d79b87168a113 (patch)
treee18c8309752de67d3db878d6c37c92ad76c91df0 /cups/dest-options.c
parent003390944879c2cd552a93eaeeec82c27d0b0039 (diff)
More changes for STR #4414 to fix cupsGetDestMediaByIndex - wasn't copying the
size data over correctly (two different structs...) git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11882 a1ca3aef-8c08-0410-bb20-df032aa958be
Diffstat (limited to 'cups/dest-options.c')
-rw-r--r--cups/dest-options.c68
1 files changed, 53 insertions, 15 deletions
diff --git a/cups/dest-options.c b/cups/dest-options.c
index 9f041a16d..442ca5dc6 100644
--- a/cups/dest-options.c
+++ b/cups/dest-options.c
@@ -848,7 +848,8 @@ cupsGetDestMediaByIndex(
unsigned flags, /* I - Media flags */
cups_size_t *size) /* O - Media size information */
{
- cups_size_t *nsize; /* Size for N */
+ _cups_media_db_t *nsize; /* Size for N */
+ pwg_media_t *pwg; /* PWG media name for size */
/*
@@ -878,13 +879,30 @@ cupsGetDestMediaByIndex(
* Copy the size over and return...
*/
- if ((nsize = (cups_size_t *)cupsArrayIndex(dinfo->cached_db, n)) == NULL)
+ if ((nsize = (_cups_media_db_t *)cupsArrayIndex(dinfo->cached_db, n)) == NULL)
+ {
+ _cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
+ return (0);
+ }
+
+ if (nsize->size_name)
+ strlcpy(size->media, nsize->size_name, sizeof(size->media));
+ else if (nsize->key)
+ strlcpy(size->media, nsize->key, sizeof(size->media));
+ else if ((pwg = pwgMediaForSize(nsize->width, nsize->length)) != NULL)
+ strlcpy(size->media, pwg->pwg, sizeof(size->media));
+ else
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, strerror(EINVAL), 0);
return (0);
}
- memcpy(size, nsize, sizeof(cups_size_t));
+ size->width = nsize->width;
+ size->length = nsize->length;
+ size->bottom = nsize->bottom;
+ size->left = nsize->left;
+ size->right = nsize->right;
+ size->top = nsize->top;
return (1);
}
@@ -1243,6 +1261,8 @@ cups_create_cached(http_t *http, /* I - Connection to destination */
*first; /* First entry this size */
+ DEBUG_printf(("3cups_create_cached(http=%p, dinfo=%p, flags=%u)", http, dinfo, flags));
+
if (dinfo->cached_db)
cupsArrayDelete(dinfo->cached_db);
@@ -1251,11 +1271,15 @@ cups_create_cached(http_t *http, /* I - Connection to destination */
if (flags & CUPS_MEDIA_FLAGS_READY)
{
+ DEBUG_puts("4cups_create_cached: ready media");
+
cups_update_ready(http, dinfo);
db = dinfo->ready_db;
}
else
{
+ DEBUG_puts("4cups_create_cached: supported media");
+
if (!dinfo->media_db)
cups_create_media_db(dinfo, CUPS_MEDIA_FLAGS_DEFAULT);
@@ -1266,28 +1290,40 @@ cups_create_cached(http_t *http, /* I - Connection to destination */
mdb;
mdb = (_cups_media_db_t *)cupsArrayNext(db))
{
+ DEBUG_printf(("4cups_create_cached: %p key=\"%s\", type=\"%s\", %dx%d, B%d L%d R%d T%d", mdb, mdb->key, mdb->type, mdb->width, mdb->length, mdb->bottom, mdb->left, mdb->right, mdb->top));
+
if (flags & CUPS_MEDIA_FLAGS_BORDERLESS)
{
if (!mdb->left && !mdb->right && !mdb->top && !mdb->bottom)
+ {
+ DEBUG_printf(("4cups_create_cached: add %p", mdb));
cupsArrayAdd(dinfo->cached_db, mdb);
+ }
}
else if (flags & CUPS_MEDIA_FLAGS_DUPLEX)
{
if (first->width != mdb->width || first->length != mdb->length)
{
+ DEBUG_printf(("4cups_create_cached: add %p", first));
cupsArrayAdd(dinfo->cached_db, first);
first = mdb;
}
- else if (mdb->left >= first->left && mdb->right >= first->right &&
- mdb->top >= first->top && mdb->bottom >= first->bottom)
+ else if (mdb->left >= first->left && mdb->right >= first->right && mdb->top >= first->top && mdb->bottom >= first->bottom &&
+ (mdb->left != first->left || mdb->right != first->right || mdb->top != first->top || mdb->bottom != first->bottom))
first = mdb;
}
else
+ {
+ DEBUG_printf(("4cups_create_cached: add %p", mdb));
cupsArrayAdd(dinfo->cached_db, mdb);
+ }
}
if (flags & CUPS_MEDIA_FLAGS_DUPLEX)
+ {
+ DEBUG_printf(("4cups_create_cached: add %p", first));
cupsArrayAdd(dinfo->cached_db, first);
+ }
}
@@ -1721,8 +1757,7 @@ cups_get_media_db(http_t *http, /* I - Connection to destination */
* Look for the smallest margins...
*/
- if (best->left != 0 || best->right != 0 || best->top != 0 ||
- best->bottom != 0)
+ if (best->left != 0 || best->right != 0 || best->top != 0 || best->bottom != 0)
{
for (mdb = (_cups_media_db_t *)cupsArrayNext(db);
mdb && !cups_compare_media_db(mdb, &key);
@@ -1759,7 +1794,8 @@ cups_get_media_db(http_t *http, /* I - Connection to destination */
mdb = (_cups_media_db_t *)cupsArrayNext(db))
{
if (mdb->left >= best->left && mdb->right >= best->right &&
- mdb->top >= best->top && mdb->bottom >= best->bottom)
+ mdb->top >= best->top && mdb->bottom >= best->bottom &&
+ (mdb->bottom != best->bottom || mdb->left != best->left || mdb->right != best->right || mdb->top != best->top))
best = mdb;
}
}
@@ -1774,11 +1810,10 @@ cups_get_media_db(http_t *http, /* I - Connection to destination */
mdb = (_cups_media_db_t *)cupsArrayNext(db))
{
if (((mdb->left > 0 && mdb->left <= best->left) || best->left == 0) &&
- ((mdb->right > 0 && mdb->right <= best->right) ||
- best->right == 0) &&
+ ((mdb->right > 0 && mdb->right <= best->right) || best->right == 0) &&
((mdb->top > 0 && mdb->top <= best->top) || best->top == 0) &&
- ((mdb->bottom > 0 && mdb->bottom <= best->bottom) ||
- best->bottom == 0))
+ ((mdb->bottom > 0 && mdb->bottom <= best->bottom) || best->bottom == 0) &&
+ (mdb->bottom != best->bottom || mdb->left != best->left || mdb->right != best->right || mdb->top != best->top))
best = mdb;
}
}
@@ -1856,7 +1891,8 @@ cups_get_media_db(http_t *http, /* I - Connection to destination */
mdb = (_cups_media_db_t *)cupsArrayNext(db))
{
if (mdb->left <= best->left && mdb->right <= best->right &&
- mdb->top <= best->top && mdb->bottom <= best->bottom)
+ mdb->top <= best->top && mdb->bottom <= best->bottom &&
+ (mdb->bottom != best->bottom || mdb->left != best->left || mdb->right != best->right || mdb->top != best->top))
{
best = mdb;
if (mdb->left == 0 && mdb->right == 0 && mdb->bottom == 0 &&
@@ -1877,7 +1913,8 @@ cups_get_media_db(http_t *http, /* I - Connection to destination */
mdb = (_cups_media_db_t *)cupsArrayNext(db))
{
if (mdb->left >= best->left && mdb->right >= best->right &&
- mdb->top >= best->top && mdb->bottom >= best->bottom)
+ mdb->top >= best->top && mdb->bottom >= best->bottom &&
+ (mdb->bottom != best->bottom || mdb->left != best->left || mdb->right != best->right || mdb->top != best->top))
best = mdb;
}
}
@@ -1896,7 +1933,8 @@ cups_get_media_db(http_t *http, /* I - Connection to destination */
best->right == 0) &&
((mdb->top > 0 && mdb->top <= best->top) || best->top == 0) &&
((mdb->bottom > 0 && mdb->bottom <= best->bottom) ||
- best->bottom == 0))
+ best->bottom == 0) &&
+ (mdb->bottom != best->bottom || mdb->left != best->left || mdb->right != best->right || mdb->top != best->top))
best = mdb;
}
}