Skip to content

Commit

Permalink
CUPS_PRINTER_xxx -> CUPS_PTYPE_xxx with source compatibility changes.
Browse files Browse the repository at this point in the history
Add CUPS_PTYPE_FOLD to support fold finishing.
  • Loading branch information
michaelrsweet committed Oct 5, 2023
1 parent 3f11865 commit 9f177b7
Show file tree
Hide file tree
Showing 10 changed files with 256 additions and 225 deletions.
87 changes: 59 additions & 28 deletions cups/cups.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,35 +211,66 @@ typedef unsigned cups_media_flags_t; // Combined flags for @link cupsGetDestMedi

enum cups_ptype_e // Printer type/capability flags
{
CUPS_PRINTER_LOCAL = 0x0000, // Local printer or class
CUPS_PRINTER_CLASS = 0x0001, // Printer class
CUPS_PRINTER_REMOTE = 0x0002, // Remote printer or class
CUPS_PRINTER_BW = 0x0004, // Can do B&W printing
CUPS_PRINTER_COLOR = 0x0008, // Can do color printing
CUPS_PRINTER_DUPLEX = 0x0010, // Can do two-sided printing
CUPS_PRINTER_STAPLE = 0x0020, // Can staple output
CUPS_PRINTER_COPIES = 0x0040, // Can do copies in hardware
CUPS_PRINTER_COLLATE = 0x0080, // Can quickly collate copies
CUPS_PRINTER_PUNCH = 0x0100, // Can punch output
CUPS_PRINTER_COVER = 0x0200, // Can cover output
CUPS_PRINTER_BIND = 0x0400, // Can bind output
CUPS_PRINTER_SORT = 0x0800, // Can sort output
CUPS_PRINTER_SMALL = 0x1000, // Can print on Letter/Legal/A4-size media
CUPS_PRINTER_MEDIUM = 0x2000, // Can print on Tabloid/B/C/A3/A2-size media
CUPS_PRINTER_LARGE = 0x4000, // Can print on D/E/A1/A0-size media
CUPS_PRINTER_VARIABLE = 0x8000, // Can print on rolls and custom-size media
CUPS_PRINTER_DEFAULT = 0x20000, // Default printer on network
CUPS_PRINTER_FAX = 0x40000, // Fax queue
CUPS_PRINTER_REJECTING = 0x80000, // Printer is rejecting jobs
CUPS_PRINTER_NOT_SHARED = 0x200000, // Printer is not shared
CUPS_PRINTER_AUTHENTICATED = 0x400000, // Printer requires authentication
CUPS_PRINTER_COMMANDS = 0x800000, // Printer supports maintenance commands
CUPS_PRINTER_DISCOVERED = 0x1000000, // Printer was discovered
CUPS_PRINTER_SCANNER = 0x2000000, // Scanner-only device
CUPS_PRINTER_MFP = 0x4000000, // Printer with scanning capabilities
CUPS_PRINTER_3D = 0x8000000, // Printer with 3D capabilities @exclude all@ @private@ @deprecated@
CUPS_PRINTER_OPTIONS = 0x6fffc // ~(CLASS | REMOTE | IMPLICIT | DEFAULT | FAX | REJECTING | DELETE | NOT_SHARED | AUTHENTICATED | COMMANDS | DISCOVERED) @private@
CUPS_PTYPE_LOCAL = 0x0000, // Local printer or class
CUPS_PTYPE_CLASS = 0x0001, // Printer class
CUPS_PTYPE_REMOTE = 0x0002, // Remote printer or class
CUPS_PTYPE_BW = 0x0004, // Can do B&W printing
CUPS_PTYPE_COLOR = 0x0008, // Can do color printing
CUPS_PTYPE_DUPLEX = 0x0010, // Can do two-sided printing
CUPS_PTYPE_STAPLE = 0x0020, // Can staple output
CUPS_PTYPE_COPIES = 0x0040, // Can do copies in hardware
CUPS_PTYPE_COLLATE = 0x0080, // Can quickly collate copies
CUPS_PTYPE_PUNCH = 0x0100, // Can punch output
CUPS_PTYPE_COVER = 0x0200, // Can cover output
CUPS_PTYPE_BIND = 0x0400, // Can bind output
CUPS_PTYPE_SORT = 0x0800, // Can sort output
CUPS_PTYPE_SMALL = 0x1000, // Can print on Letter/Legal/A4-size media
CUPS_PTYPE_MEDIUM = 0x2000, // Can print on Tabloid/B/C/A3/A2-size media
CUPS_PTYPE_LARGE = 0x4000, // Can print on D/E/A1/A0-size media
CUPS_PTYPE_VARIABLE = 0x8000, // Can print on rolls and custom-size media
CUPS_PTYPE_DEFAULT = 0x20000, // Default printer on network
CUPS_PTYPE_FAX = 0x40000, // Fax queue
CUPS_PTYPE_REJECTING = 0x80000, // Printer is rejecting jobs
CUPS_PTYPE_NOT_SHARED = 0x200000, // Printer is not shared
CUPS_PTYPE_AUTHENTICATED = 0x400000, // Printer requires authentication
CUPS_PTYPE_COMMANDS = 0x800000, // Printer supports maintenance commands
CUPS_PTYPE_DISCOVERED = 0x1000000, // Printer was discovered
CUPS_PTYPE_SCANNER = 0x2000000, // Scanner-only device
CUPS_PTYPE_MFP = 0x4000000, // Printer with scanning capabilities
CUPS_PTYPE_3D = 0x8000000, // Printer with 3D capabilities @exclude all@ @private@ @deprecated@
CUPS_PTYPE_FOLD = 0x10000000, // Can fold output @since CUPS 2.5@
CUPS_PTYPE_OPTIONS = 0x1006fffc // ~(CLASS | REMOTE | IMPLICIT | DEFAULT | FAX | REJECTING | DELETE | NOT_SHARED | AUTHENTICATED | COMMANDS | DISCOVERED) @private@
};
# ifndef _CUPS_NO_DEPRECATED
# define CUPS_PRINTER_LOCAL CUPS_PTYPE_LOCAL
# define CUPS_PRINTER_CLASS CUPS_PTYPE_CLASS
# define CUPS_PRINTER_REMOTE CUPS_PTYPE_REMOTE
# define CUPS_PRINTER_BW CUPS_PTYPE_BW
# define CUPS_PRINTER_COLOR CUPS_PTYPE_COLOR
# define CUPS_PRINTER_DUPLEX CUPS_PTYPE_DUPLEX
# define CUPS_PRINTER_STAPLE CUPS_PTYPE_STAPLE
# define CUPS_PRINTER_COPIES CUPS_PTYPE_COPIES
# define CUPS_PRINTER_COLLATE CUPS_PTYPE_COLLATE
# define CUPS_PRINTER_PUNCH CUPS_PTYPE_PUNCH
# define CUPS_PRINTER_COVER CUPS_PTYPE_COVER
# define CUPS_PRINTER_BIND CUPS_PTYPE_BIND
# define CUPS_PRINTER_SORT CUPS_PTYPE_SORT
# define CUPS_PRINTER_SMALL CUPS_PTYPE_SMALL
# define CUPS_PRINTER_MEDIUM CUPS_PTYPE_MEDIUM
# define CUPS_PRINTER_LARGE CUPS_PTYPE_LARGE
# define CUPS_PRINTER_VARIABLE CUPS_PTYPE_VARIABLE
# define CUPS_PRINTER_DEFAULT CUPS_PTYPE_DEFAULT
# define CUPS_PRINTER_FAX CUPS_PTYPE_FAX
# define CUPS_PRINTER_REJECTING CUPS_PTYPE_REJECTING
# define CUPS_PRINTER_NOT CUPS_PTYPE_NOT
# define CUPS_PRINTER_AUTHENTICATED CUPS_PTYPE_AUTHENTICATED
# define CUPS_PRINTER_COMMANDS CUPS_PTYPE_COMMANDS
# define CUPS_PRINTER_DISCOVERED CUPS_PTYPE_DISCOVERED
# define CUPS_PRINTER_SCANNER CUPS_PTYPE_SCANNER
# define CUPS_PRINTER_MFP CUPS_PTYPE_MFP
# define CUPS_PRINTER_3D CUPS_PTYPE_3D
# define CUPS_PRINTER_OPTIONS CUPS_PTYPE_OPTIONS
# endif // !_CUPS_NO_DEPRECATED
typedef unsigned cups_ptype_t; // Combined printer type/capability flags

typedef enum cups_whichjobs_e // Which jobs for @link cupsGetJobs@
Expand Down
44 changes: 22 additions & 22 deletions cups/dest.c
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ _cupsCreateDest(const char *name, // I - Printer name
//
// The @code type@ and @code mask@ arguments allow the caller to filter the
// destinations that are enumerated. Passing 0 for both will enumerate all
// printers. The constant @code CUPS_PRINTER_DISCOVERED@ is used to filter on
// printers. The constant @code CUPS_PTYPE_DISCOVERED@ is used to filter on
// destinations that are available but have not yet been added locally.
//
// Enumeration happens on the current thread and does not return until all
Expand Down Expand Up @@ -897,7 +897,7 @@ cupsEnumDests(
//
// The @code type@ and @code mask@ arguments allow the caller to filter the
// destinations that are enumerated. Passing 0 for both will enumerate all
// printers. The constant @code CUPS_PRINTER_DISCOVERED@ is used to filter on
// printers. The constant @code CUPS_PTYPE_DISCOVERED@ is used to filter on
// destinations that are available but have not yet been added locally.
//
// Enumeration happens on the current thread and does not return until all
Expand Down Expand Up @@ -1599,7 +1599,7 @@ cupsGetDests2(http_t *http, // I - Connection to server or @code CUPS_HTTP_
* cupsd.
*/

cups_enum_dests(http, 0, _CUPS_DNSSD_GET_DESTS, NULL, 0, CUPS_PRINTER_DISCOVERED, (cups_dest_cb_t)cups_get_cb, &data);
cups_enum_dests(http, 0, _CUPS_DNSSD_GET_DESTS, NULL, 0, CUPS_PTYPE_DISCOVERED, (cups_dest_cb_t)cups_get_cb, &data);
}
else
{
Expand Down Expand Up @@ -2698,7 +2698,7 @@ cups_dest_query_cb(
model[256], // Model
uriname[1024], // Name for URI
uri[1024]; // Printer URI
cups_ptype_t type = CUPS_PRINTER_DISCOVERED | CUPS_PRINTER_BW;
cups_ptype_t type = CUPS_PTYPE_DISCOVERED | CUPS_PTYPE_BW;
// Printer type
bool saw_printer_type = false;
// Did we see a printer-type key?
Expand Down Expand Up @@ -2805,66 +2805,66 @@ cups_dest_query_cb(
{
// Value is either NNNN or 0xXXXX
saw_printer_type = true;
type = (cups_ptype_t)strtol(value, NULL, 0) | CUPS_PRINTER_DISCOVERED;
type = (cups_ptype_t)strtol(value, NULL, 0) | CUPS_PTYPE_DISCOVERED;
}
else if (!saw_printer_type)
{
if (!_cups_strcasecmp(key, "air") && !_cups_strcasecmp(value, "t"))
{
type |= CUPS_PRINTER_AUTHENTICATED;
type |= CUPS_PTYPE_AUTHENTICATED;
}
else if (!_cups_strcasecmp(key, "bind") && !_cups_strcasecmp(value, "t"))
{
type |= CUPS_PRINTER_BIND;
type |= CUPS_PTYPE_BIND;
}
else if (!_cups_strcasecmp(key, "collate") && !_cups_strcasecmp(value, "t"))
{
type |= CUPS_PRINTER_COLLATE;
type |= CUPS_PTYPE_COLLATE;
}
else if (!_cups_strcasecmp(key, "color") && !_cups_strcasecmp(value, "t"))
{
type |= CUPS_PRINTER_COLOR;
type |= CUPS_PTYPE_COLOR;
}
else if (!_cups_strcasecmp(key, "copies") && !_cups_strcasecmp(value, "t"))
{
type |= CUPS_PRINTER_COPIES;
type |= CUPS_PTYPE_COPIES;
}
else if (!_cups_strcasecmp(key, "duplex") && !_cups_strcasecmp(value, "t"))
{
type |= CUPS_PRINTER_DUPLEX;
type |= CUPS_PTYPE_DUPLEX;
}
else if (!_cups_strcasecmp(key, "fax") && !_cups_strcasecmp(value, "t"))
{
type |= CUPS_PRINTER_MFP;
type |= CUPS_PTYPE_MFP;
}
else if (!_cups_strcasecmp(key, "papercustom") && !_cups_strcasecmp(value, "t"))
{
type |= CUPS_PRINTER_VARIABLE;
type |= CUPS_PTYPE_VARIABLE;
}
else if (!_cups_strcasecmp(key, "papermax"))
{
if (!_cups_strcasecmp(value, "legal-a4"))
type |= CUPS_PRINTER_SMALL;
type |= CUPS_PTYPE_SMALL;
else if (!_cups_strcasecmp(value, "isoc-a2"))
type |= CUPS_PRINTER_MEDIUM;
type |= CUPS_PTYPE_MEDIUM;
else if (!_cups_strcasecmp(value, ">isoc-a2"))
type |= CUPS_PRINTER_LARGE;
type |= CUPS_PTYPE_LARGE;
}
else if (!_cups_strcasecmp(key, "punch") && !_cups_strcasecmp(value, "t"))
{
type |= CUPS_PRINTER_PUNCH;
type |= CUPS_PTYPE_PUNCH;
}
else if (!_cups_strcasecmp(key, "scan") && !_cups_strcasecmp(value, "t"))
{
type |= CUPS_PRINTER_MFP;
type |= CUPS_PTYPE_MFP;
}
else if (!_cups_strcasecmp(key, "sort") && !_cups_strcasecmp(value, "t"))
{
type |= CUPS_PRINTER_SORT;
type |= CUPS_PTYPE_SORT;
}
else if (!_cups_strcasecmp(key, "staple") && !_cups_strcasecmp(value, "t"))
{
type |= CUPS_PRINTER_STAPLE;
type |= CUPS_PTYPE_STAPLE;
}
}
}
Expand Down Expand Up @@ -3139,7 +3139,7 @@ cups_enum_dests(
data.user_data = user_data;
data.devices = cupsArrayNew3((cups_array_func_t)cups_dnssd_compare_devices, NULL, NULL, 0, NULL, (cups_afree_func_t)cups_dnssd_free_device);

if (!(mask & CUPS_PRINTER_DISCOVERED) || !(type & CUPS_PRINTER_DISCOVERED))
if (!(mask & CUPS_PTYPE_DISCOVERED) || !(type & CUPS_PTYPE_DISCOVERED))
{
// Get the list of local printers and pass them to the callback function...
num_dests = _cupsGetDests(http, IPP_OP_CUPS_GET_PRINTERS, NULL, &dests, type, mask);
Expand Down Expand Up @@ -3225,7 +3225,7 @@ cups_enum_dests(
}

// Return early if the caller doesn't want to do discovery...
if ((mask & CUPS_PRINTER_DISCOVERED) && !(type & CUPS_PRINTER_DISCOVERED))
if ((mask & CUPS_PTYPE_DISCOVERED) && !(type & CUPS_PTYPE_DISCOVERED))
goto enum_finished;

// Get DNS-SD printers...
Expand Down
66 changes: 33 additions & 33 deletions cups/testcups.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ main(int argc, /* I - Number of command-line arguments */
{
if (!strcmp(argv[1], "enum"))
{
cups_ptype_t mask = CUPS_PRINTER_LOCAL,
cups_ptype_t mask = CUPS_PTYPE_LOCAL,
/* Printer type mask */
type = CUPS_PRINTER_LOCAL;
type = CUPS_PTYPE_LOCAL;
/* Printer type */
int msec = 0; /* Timeout in milliseconds */

Expand All @@ -66,85 +66,85 @@ main(int argc, /* I - Number of command-line arguments */
msec = (int)(atof(argv[i]) * 1000);
else if (!_cups_strcasecmp(argv[i], "bw"))
{
mask |= CUPS_PRINTER_BW;
type |= CUPS_PRINTER_BW;
mask |= CUPS_PTYPE_BW;
type |= CUPS_PTYPE_BW;
}
else if (!_cups_strcasecmp(argv[i], "color"))
{
mask |= CUPS_PRINTER_COLOR;
type |= CUPS_PRINTER_COLOR;
mask |= CUPS_PTYPE_COLOR;
type |= CUPS_PTYPE_COLOR;
}
else if (!_cups_strcasecmp(argv[i], "mono"))
{
mask |= CUPS_PRINTER_COLOR;
mask |= CUPS_PTYPE_COLOR;
}
else if (!_cups_strcasecmp(argv[i], "duplex"))
{
mask |= CUPS_PRINTER_DUPLEX;
type |= CUPS_PRINTER_DUPLEX;
mask |= CUPS_PTYPE_DUPLEX;
type |= CUPS_PTYPE_DUPLEX;
}
else if (!_cups_strcasecmp(argv[i], "simplex"))
{
mask |= CUPS_PRINTER_DUPLEX;
mask |= CUPS_PTYPE_DUPLEX;
}
else if (!_cups_strcasecmp(argv[i], "staple"))
{
mask |= CUPS_PRINTER_STAPLE;
type |= CUPS_PRINTER_STAPLE;
mask |= CUPS_PTYPE_STAPLE;
type |= CUPS_PTYPE_STAPLE;
}
else if (!_cups_strcasecmp(argv[i], "copies"))
{
mask |= CUPS_PRINTER_COPIES;
type |= CUPS_PRINTER_COPIES;
mask |= CUPS_PTYPE_COPIES;
type |= CUPS_PTYPE_COPIES;
}
else if (!_cups_strcasecmp(argv[i], "collate"))
{
mask |= CUPS_PRINTER_COLLATE;
type |= CUPS_PRINTER_COLLATE;
mask |= CUPS_PTYPE_COLLATE;
type |= CUPS_PTYPE_COLLATE;
}
else if (!_cups_strcasecmp(argv[i], "punch"))
{
mask |= CUPS_PRINTER_PUNCH;
type |= CUPS_PRINTER_PUNCH;
mask |= CUPS_PTYPE_PUNCH;
type |= CUPS_PTYPE_PUNCH;
}
else if (!_cups_strcasecmp(argv[i], "cover"))
{
mask |= CUPS_PRINTER_COVER;
type |= CUPS_PRINTER_COVER;
mask |= CUPS_PTYPE_COVER;
type |= CUPS_PTYPE_COVER;
}
else if (!_cups_strcasecmp(argv[i], "bind"))
{
mask |= CUPS_PRINTER_BIND;
type |= CUPS_PRINTER_BIND;
mask |= CUPS_PTYPE_BIND;
type |= CUPS_PTYPE_BIND;
}
else if (!_cups_strcasecmp(argv[i], "sort"))
{
mask |= CUPS_PRINTER_SORT;
type |= CUPS_PRINTER_SORT;
mask |= CUPS_PTYPE_SORT;
type |= CUPS_PTYPE_SORT;
}
else if (!_cups_strcasecmp(argv[i], "mfp"))
{
mask |= CUPS_PRINTER_MFP;
type |= CUPS_PRINTER_MFP;
mask |= CUPS_PTYPE_MFP;
type |= CUPS_PTYPE_MFP;
}
else if (!_cups_strcasecmp(argv[i], "printer"))
{
mask |= CUPS_PRINTER_MFP;
mask |= CUPS_PTYPE_MFP;
}
else if (!_cups_strcasecmp(argv[i], "large"))
{
mask |= CUPS_PRINTER_LARGE;
type |= CUPS_PRINTER_LARGE;
mask |= CUPS_PTYPE_LARGE;
type |= CUPS_PTYPE_LARGE;
}
else if (!_cups_strcasecmp(argv[i], "medium"))
{
mask |= CUPS_PRINTER_MEDIUM;
type |= CUPS_PRINTER_MEDIUM;
mask |= CUPS_PTYPE_MEDIUM;
type |= CUPS_PTYPE_MEDIUM;
}
else if (!_cups_strcasecmp(argv[i], "small"))
{
mask |= CUPS_PRINTER_SMALL;
type |= CUPS_PRINTER_SMALL;
mask |= CUPS_PTYPE_SMALL;
type |= CUPS_PTYPE_SMALL;
}
else
fprintf(stderr, "Unknown argument \"%s\" ignored...\n", argv[i]);
Expand Down
Loading

0 comments on commit 9f177b7

Please sign in to comment.