Skip to content

Commit

Permalink
Update libcups.
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelrsweet committed Sep 18, 2023
1 parent 5ecf445 commit f79b579
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 44 deletions.
16 changes: 8 additions & 8 deletions tools/ipp-options.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static int compare_overrides(ippopt_override_t *a, ippopt_override_t *b);
static ippopt_insert_sheet_t *copy_insert_sheet(ippopt_insert_sheet_t *is);
static ippopt_override_t *copy_override(ippopt_override_t *is);
static const char *get_option(const char *name, size_t num_options, cups_option_t *options);
static bool parse_media(const char *value, cups_size_t *media);
static bool parse_media(const char *value, cups_media_t *media);


//
Expand Down Expand Up @@ -120,7 +120,7 @@ ippOptionGetOverrides(
ipp_options_t *ippo, // I - IPP options
int document, // I - Document number (starting at 1)
int page, // I - Page number (starting at 1)
cups_size_t *media) // O - "media"/"media-col" value
cups_media_t *media) // O - "media"/"media-col" value
{
ippopt_override_t *override; // "overrides" value
ipp_orient_t orient; // "orientation-requested" value
Expand All @@ -130,9 +130,9 @@ ippOptionGetOverrides(
if (media)
{
if (ippo)
memcpy(media, &ippo->media, sizeof(cups_size_t));
memcpy(media, &ippo->media, sizeof(cups_media_t));
else
memset(media, 0, sizeof(cups_size_t));
memset(media, 0, sizeof(cups_media_t));
}

orient = ippo ? ippo->orientation_requested : IPP_ORIENT_NONE;
Expand All @@ -156,7 +156,7 @@ ippOptionGetOverrides(
break; // Stop

// Found a match, copy the override...
memcpy(media, &override->media, sizeof(cups_size_t));
memcpy(media, &override->media, sizeof(cups_media_t));
orient = override->orientation_requested;
break;
}
Expand Down Expand Up @@ -643,16 +643,16 @@ get_option(const char *name, // I - Attribute name
//

static bool // O - `true` on success, `false` on error
parse_media(const char *value, // I - "media" or "media-col" value
cups_size_t *media) // O - Media value
parse_media(const char *value, // I - "media" or "media-col" value
cups_media_t *media) // O - Media value
{
bool margins_set = false, // Have margins been set?
ret = true; // Return value
pwg_media_t *pwg = NULL; // PWG media values


// Initialize media
memset(media, 0, sizeof(cups_size_t));
memset(media, 0, sizeof(cups_media_t));

if (*value == '{')
{
Expand Down
14 changes: 7 additions & 7 deletions tools/ipp-options.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ typedef enum ippopt_error_report_e // Combination of "job-error-sheet-type" and
typedef struct ippopt_error_sheet_s // "job-error-sheet" value
{
ippopt_error_report_t report; // "job-error-sheet-type/when" value
cups_size_t media; // "media" or "media-col" value, if any
cups_media_t media; // "media" or "media-col" value, if any
} ippopt_error_sheet_t;

typedef struct ippopt_insert_sheet_s // "insert-sheet" value
{
int after_page, // Where to insert the sheet (0 for before page 1)
count; // Number of sheets to insert
cups_size_t media; // "media" or "media-col" value, if any
cups_media_t media; // "media" or "media-col" value, if any
} ippopt_insert_sheet_t;

typedef enum ippopt_handling_e // "multiple-document-handling" values
Expand All @@ -59,7 +59,7 @@ typedef struct ippopt_override_s // "overrides" value
last_document, // Upper document-numbers value
first_page, // Lower page-numbers value
last_page; // Upper page-numbers value
cups_size_t media; // "media" or "media-col" value, if any
cups_media_t media; // "media" or "media-col" value, if any
ipp_orient_t orientation_requested; // "orientation-requested" value, if any
} ippopt_override_t;

Expand Down Expand Up @@ -111,8 +111,8 @@ typedef struct ipp_options_s // All IPP options in one structure
int job_pages_per_set; // "job-pages-per-set" value
char job_sheet_message[1024];// "job-sheet-message" value
char job_sheets[128]; // "job-sheets" value
cups_size_t job_sheets_media; // "job-sheets-col" "media" or "media-col" value
cups_size_t media; // "media" or "media-col" value
cups_media_t job_sheets_media; // "job-sheets-col" "media" or "media-col" value
cups_media_t media; // "media" or "media-col" value
ippopt_handling_t multiple_document_handling;
// "multiple-document-handling" value
int number_up; // "number-up" value
Expand All @@ -131,7 +131,7 @@ typedef struct ipp_options_s // All IPP options in one structure
ippopt_scaling_t print_scaling; // "print-scaling" value
int printer_resolution[2]; // "printer-resolution" values (DPI)
ippopt_septype_t separator_type; // "separator-sheets-type" value
cups_size_t separator_media; // "separator-sheets" "media" or "media-col" value
cups_media_t separator_media; // "separator-sheets" "media" or "media-col" value
char sides[128]; // "sides" value
ippopt_imgpos_t x_image_position; // "x-image-position" value
int x_side1_image_shift, // "x-side1-image-shift" or "x-image-shift" value
Expand All @@ -150,7 +150,7 @@ extern bool ippOptionsCheckPage(ipp_options_t *ippo, int page);
extern void ippOptionsDelete(ipp_options_t *ippo);
extern int ippOptionsGetFirstPage(ipp_options_t *ippo);
extern int ippOptionsGetLastPage(ipp_options_t *ippo);
extern ipp_orient_t ippOptionGetOverrides(ipp_options_t *ippo, int document, int page, cups_size_t *media);
extern ipp_orient_t ippOptionGetOverrides(ipp_options_t *ippo, int document, int page, cups_media_t *media);
extern ipp_options_t *ippOptionsNew(size_t num_options, cups_option_t *options);


Expand Down
56 changes: 28 additions & 28 deletions tools/ipptransform.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//
// Utility for converting PDF and JPEG files to raster data or HP PCL.
//
// Copyright © 2016-2022 by the Printer Working Group.
// Copyright © 2016-2023 by the Printer Working Group.
// Copyright © 2016-2019 by Apple Inc.
//
// Licensed under Apache License v2.0. See the file "LICENSE" for more
Expand Down Expand Up @@ -147,6 +147,7 @@ static bool convert_text(xform_prepare_t *p, xform_document_t *d, int document);
static void copy_page(xform_prepare_t *p, xform_page_t *outpage, size_t layout);
static bool generate_job_error_sheet(xform_prepare_t *p);
static bool generate_job_sheets(xform_prepare_t *p);
static void media_to_rect(cups_media_t *size, pdfio_rect_t *media, pdfio_rect_t *crop);
static void *monitor_ipp(const char *device_uri);
#ifdef HAVE_COREGRAPHICS
static void pack_rgba(unsigned char *row, size_t num_pixels);
Expand Down Expand Up @@ -175,7 +176,6 @@ static void raster_start_job(xform_raster_t *ras, xform_write_cb_t cb, void *ctx
static void raster_start_page(xform_raster_t *ras, unsigned page, xform_write_cb_t cb, void *ctx);
static void raster_write_line(xform_raster_t *ras, unsigned y, const unsigned char *line, xform_write_cb_t cb, void *ctx);
static bool resource_dict_cb(pdfio_dict_t *dict, const char *key, xform_page_t *outpage);
static void size_to_rect(cups_size_t *size, pdfio_rect_t *media, pdfio_rect_t *crop);
static void usage(int status) _CUPS_NORETURN;
static ssize_t write_fd(int *fd, const unsigned char *buffer, size_t bytes);
static bool xform_document(const char *filename, unsigned pages, ipp_options_t *options, const char *outformat, const char *resolutions, const char *sheet_back, const char *types, xform_write_cb_t cb, void *ctx);
Expand Down Expand Up @@ -1663,6 +1663,28 @@ generate_job_sheets(
}


//
// 'media_to_rect()' - Convert `cups_media_t` to `pdfio_rect_t` for media and crop boxes.
//

static void
media_to_rect(cups_media_t *size, // I - CUPS media (size) information
pdfio_rect_t *media, // O - PDF MediaBox value
pdfio_rect_t *crop) // O - PDF CropBox value
{
// cups_media_t uses hundredths of millimeters, pdf_rect_t uses points...
media->x1 = 0.0;
media->y1 = 0.0;
media->x2 = 72.0 * size->width / 2540.0;
media->y2 = 72.0 * size->length / 2540.0;

crop->x1 = 72.0 * size->left / 2540.0;
crop->y1 = 72.0 * size->bottom / 2540.0;
crop->x2 = 72.0 * (size->width - size->right) / 2540.0;
crop->y2 = 72.0 * (size->length - size->top) / 2540.0;
}


//
// 'monitor_ipp()' - Monitor IPP printer status.
//
Expand Down Expand Up @@ -2471,7 +2493,7 @@ prepare_documents(
p.options = options;
p.errors = cupsArrayNew(NULL, NULL, NULL, 0, (cups_acopy_cb_t)strdup, (cups_afree_cb_t)free);

size_to_rect(&options->media, &p.media, &p.crop);
media_to_rect(&options->media, &p.media, &p.crop);
prepare_number_up(&p);

if (!strncmp(options->sides, "two-sided-", 10) && sheet_back && strcmp(sheet_back, "normal"))
Expand Down Expand Up @@ -3265,28 +3287,6 @@ resource_dict_cb(
}


//
// 'size_to_rect()' - Convert `cups_size_t` to `pdfio_rect_t` for media and crop boxes.
//

static void
size_to_rect(cups_size_t *size, // I - CUPS media size information
pdfio_rect_t *media, // O - PDF MediaBox value
pdfio_rect_t *crop) // O - PDF CropBox value
{
// cups_size_t uses hundredths of millimeters, pdf_rect_t uses points...
media->x1 = 0.0;
media->y1 = 0.0;
media->x2 = 72.0 * size->width / 2540.0;
media->y2 = 72.0 * size->length / 2540.0;

crop->x1 = 72.0 * size->left / 2540.0;
crop->y1 = 72.0 * size->bottom / 2540.0;
crop->x2 = 72.0 * (size->width - size->right) / 2540.0;
crop->y2 = 72.0 * (size->length - size->top) / 2540.0;
}


//
// 'usage()' - Show program usage.
//
Expand Down Expand Up @@ -4192,15 +4192,15 @@ xform_setup(xform_raster_t *ras, // I - Raster information

if (!cupsRasterInitHeader(&ras->header, &options->media, options->print_content_optimize, options->print_quality, options->print_rendering_intent, options->orientation_requested, sides, type, options->printer_resolution[0], options->printer_resolution[1], NULL))
{
fprintf(stderr, "ERROR: Unable to initialize raster context: %s\n", cupsRasterErrorString());
fprintf(stderr, "ERROR: Unable to initialize raster context: %s\n", cupsRasterGetErrorString());
return (false);
}

if (options->separator_type != IPPOPT_SEPTYPE_NONE)
{
if (!cupsRasterInitHeader(&ras->sep_header, &options->separator_media, options->print_content_optimize, options->print_quality, options->print_rendering_intent, options->orientation_requested, sides, type, options->printer_resolution[0], options->printer_resolution[1], NULL))
{
fprintf(stderr, "ERROR: Unable to initialize separator raster context: %s\n", cupsRasterErrorString());
fprintf(stderr, "ERROR: Unable to initialize separator raster context: %s\n", cupsRasterGetErrorString());
return (false);
}
}
Expand All @@ -4209,7 +4209,7 @@ xform_setup(xform_raster_t *ras, // I - Raster information
{
if (!cupsRasterInitHeader(&ras->back_header, &options->media, options->print_content_optimize, options->print_quality, options->print_rendering_intent, options->orientation_requested, sides, type, options->printer_resolution[0], options->printer_resolution[1], sheet_back))
{
fprintf(stderr, "ERROR: Unable to initialize back side raster context: %s\n", cupsRasterErrorString());
fprintf(stderr, "ERROR: Unable to initialize back side raster context: %s\n", cupsRasterGetErrorString());
return (false);
}
}
Expand Down

0 comments on commit f79b579

Please sign in to comment.