• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Private PPD definitions for CUPS.
3  *
4  * Copyright © 2020-2024 by OpenPrinting.
5  * Copyright © 2007-2019 by Apple Inc.
6  * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
7  *
8  * Licensed under Apache License v2.0.  See the file "LICENSE" for more
9  * information.
10  *
11  * PostScript is a trademark of Adobe Systems, Inc.
12  */
13 
14 #ifndef _CUPS_PPD_PRIVATE_H_
15 #  define _CUPS_PPD_PRIVATE_H_
16 
17 /*
18  * Include necessary headers...
19  */
20 
21 #  include <cups/cups.h>
22 #  include <cups/ppd.h>
23 #  include "pwg-private.h"
24 
25 
26 /*
27  * C++ magic...
28  */
29 
30 #  ifdef __cplusplus
31 extern "C" {
32 #  endif /* __cplusplus */
33 
34 
35 /*
36  * Constants...
37  */
38 
39 #  define _PPD_CACHE_VERSION	11	/* Version number in cache file */
40 
41 
42 /*
43  * Types and structures...
44  */
45 
46 typedef struct _ppd_globals_s		/**** CUPS PPD global state data ****/
47 {
48   /* ppd.c */
49   ppd_status_t		ppd_status;	/* Status of last ppdOpen*() */
50   int			ppd_line;	/* Current line number */
51   ppd_conform_t		ppd_conform;	/* Level of conformance required */
52 
53   /* ppd-util.c */
54   char			ppd_filename[HTTP_MAX_URI];
55 					/* PPD filename */
56 } _ppd_globals_t;
57 
58 typedef enum _ppd_localization_e	/**** Selector for _ppdOpen ****/
59 {
60   _PPD_LOCALIZATION_DEFAULT,		/* Load only the default localization */
61   _PPD_LOCALIZATION_ICC_PROFILES,	/* Load only the color profile localization */
62   _PPD_LOCALIZATION_NONE,		/* Load no localizations */
63   _PPD_LOCALIZATION_ALL			/* Load all localizations */
64 } _ppd_localization_t;
65 
66 typedef enum _ppd_parse_e		/**** Selector for _ppdParseOptions ****/
67 {
68   _PPD_PARSE_OPTIONS,			/* Parse only the options */
69   _PPD_PARSE_PROPERTIES,		/* Parse only the properties */
70   _PPD_PARSE_ALL			/* Parse everything */
71 } _ppd_parse_t;
72 
73 typedef struct _ppd_cups_uiconst_s	/**** Constraint from cupsUIConstraints ****/
74 {
75   ppd_option_t	*option;		/* Constrained option */
76   ppd_choice_t	*choice;		/* Constrained choice or @code NULL@ */
77   int		installable;		/* Installable option? */
78 } _ppd_cups_uiconst_t;
79 
80 typedef struct _ppd_cups_uiconsts_s	/**** cupsUIConstraints ****/
81 {
82   char		resolver[PPD_MAX_NAME];	/* Resolver name */
83   int		installable,		/* Constrained against any installable options? */
84 		num_constraints;	/* Number of constraints */
85   _ppd_cups_uiconst_t *constraints;	/* Constraints */
86 } _ppd_cups_uiconsts_t;
87 
88 typedef enum _pwg_print_color_mode_e	/**** PWG print-color-mode indices ****/
89 {
90   _PWG_PRINT_COLOR_MODE_MONOCHROME = 0,	/* print-color-mode=monochrome */
91   _PWG_PRINT_COLOR_MODE_COLOR,		/* print-color-mode=color */
92   /* Other values are not supported by CUPS yet. */
93   _PWG_PRINT_COLOR_MODE_MAX
94 } _pwg_print_color_mode_t;
95 
96 typedef enum _pwg_print_quality_e	/**** PWG print-quality values ****/
97 {
98   _PWG_PRINT_QUALITY_DRAFT = 0,		/* print-quality=3 */
99   _PWG_PRINT_QUALITY_NORMAL,		/* print-quality=4 */
100   _PWG_PRINT_QUALITY_HIGH,		/* print-quality=5 */
101   _PWG_PRINT_QUALITY_MAX
102 } _pwg_print_quality_t;
103 
104 typedef struct _pwg_finishings_s	/**** PWG finishings mapping data ****/
105 {
106   ipp_finishings_t	value;		/* finishings value */
107   int			num_options;	/* Number of options to apply */
108   cups_option_t		*options;	/* Options to apply */
109 } _pwg_finishings_t;
110 
111 struct _ppd_cache_s			/**** PPD cache and PWG conversion data ****/
112 {
113   int		num_bins;		/* Number of output bins */
114   pwg_map_t	*bins;			/* Output bins */
115   int		num_sizes;		/* Number of media sizes */
116   pwg_size_t	*sizes;			/* Media sizes */
117   int		custom_max_width,	/* Maximum custom width in 2540ths */
118 		custom_max_length,	/* Maximum custom length in 2540ths */
119 		custom_min_width,	/* Minimum custom width in 2540ths */
120 		custom_min_length;	/* Minimum custom length in 2540ths */
121   char		*custom_max_keyword,	/* Maximum custom size PWG keyword */
122 		*custom_min_keyword,	/* Minimum custom size PWG keyword */
123 		custom_ppd_size[41];	/* Custom PPD size name */
124   pwg_size_t	custom_size;		/* Custom size record */
125   char		*source_option;		/* PPD option for media source */
126   int		num_sources;		/* Number of media sources */
127   pwg_map_t	*sources;		/* Media sources */
128   int		num_types;		/* Number of media types */
129   pwg_map_t	*types;			/* Media types */
130   int		num_presets[_PWG_PRINT_COLOR_MODE_MAX][_PWG_PRINT_QUALITY_MAX];
131 					/* Number of print-color-mode/print-quality options */
132   cups_option_t	*presets[_PWG_PRINT_COLOR_MODE_MAX][_PWG_PRINT_QUALITY_MAX];
133 					/* print-color-mode/print-quality options */
134   char		*sides_option,		/* PPD option for sides */
135 		*sides_1sided,		/* Choice for one-sided */
136 		*sides_2sided_long,	/* Choice for two-sided-long-edge */
137 		*sides_2sided_short;	/* Choice for two-sided-short-edge */
138   char		*product;		/* Product value */
139   cups_array_t	*filters,		/* cupsFilter/cupsFilter2 values */
140 		*prefilters;		/* cupsPreFilter values */
141   int		single_file;		/* cupsSingleFile value */
142   cups_array_t	*finishings;		/* cupsIPPFinishings values */
143   cups_array_t	*templates;		/* cupsFinishingTemplate values */
144   int		max_copies,		/* cupsMaxCopies value */
145 		account_id,		/* cupsJobAccountId value */
146 		accounting_user_id;	/* cupsJobAccountingUserId value */
147   char		*password;		/* cupsJobPassword value */
148   cups_array_t	*mandatory;		/* cupsMandatory value */
149   char		*charge_info_uri;	/* cupsChargeInfoURI value */
150   cups_array_t	*strings;		/* Localization strings */
151   cups_array_t	*support_files;		/* Support files - ICC profiles, etc. */
152 };
153 
154 
155 /*
156  * Prototypes...
157  */
158 
159 extern int		_cupsConvertOptions(ipp_t *request, ppd_file_t *ppd, _ppd_cache_t *pc, ipp_attribute_t *media_col_sup, ipp_attribute_t *doc_handling_sup, ipp_attribute_t *print_color_mode_sup, const char *user, const char *format, int copies, int num_options, cups_option_t *options) _CUPS_PRIVATE;
160 extern int		_cupsRasterExecPS(cups_page_header2_t *h, int *preferred_bits, const char *code) _CUPS_NONNULL(3) _CUPS_PRIVATE;
161 extern int		_cupsRasterInterpretPPD(cups_page_header2_t *h, ppd_file_t *ppd, int num_options, cups_option_t *options, cups_interpret_cb_t func) _CUPS_PRIVATE;
162 
163 extern _ppd_cache_t	*_ppdCacheCreateWithFile(const char *filename,
164 			                         ipp_t **attrs) _CUPS_PRIVATE;
165 extern _ppd_cache_t	*_ppdCacheCreateWithPPD(ppd_file_t *ppd) _CUPS_PRIVATE;
166 extern void		_ppdCacheDestroy(_ppd_cache_t *pc) _CUPS_PRIVATE;
167 extern const char	*_ppdCacheGetBin(_ppd_cache_t *pc,
168 			                 const char *output_bin) _CUPS_PRIVATE;
169 extern int		_ppdCacheGetFinishingOptions(_ppd_cache_t *pc,
170 			                             ipp_t *job,
171 			                             ipp_finishings_t value,
172 			                             int num_options,
173 			                             cups_option_t **options) _CUPS_PRIVATE;
174 extern int		_ppdCacheGetFinishingValues(ppd_file_t *ppd, _ppd_cache_t *pc, int max_values, int *values) _CUPS_PRIVATE;
175 extern const char	*_ppdCacheGetInputSlot(_ppd_cache_t *pc, ipp_t *job,
176 			                       const char *keyword) _CUPS_PRIVATE;
177 extern const char	*_ppdCacheGetMediaType(_ppd_cache_t *pc, ipp_t *job,
178 			                       const char *keyword) _CUPS_PRIVATE;
179 extern const char	*_ppdCacheGetOutputBin(_ppd_cache_t *pc,
180 			                       const char *keyword) _CUPS_PRIVATE;
181 extern const char	*_ppdCacheGetPageSize(_ppd_cache_t *pc, ipp_t *job,
182 			                      const char *keyword, int *exact) _CUPS_PRIVATE;
183 extern pwg_size_t	*_ppdCacheGetSize(_ppd_cache_t *pc,
184 			                  const char *page_size) _CUPS_PRIVATE;
185 extern const char	*_ppdCacheGetSource(_ppd_cache_t *pc,
186 			                    const char *input_slot) _CUPS_PRIVATE;
187 extern const char	*_ppdCacheGetType(_ppd_cache_t *pc,
188 			                  const char *media_type) _CUPS_PRIVATE;
189 extern int		_ppdCacheWriteFile(_ppd_cache_t *pc,
190 			                   const char *filename, ipp_t *attrs) _CUPS_PRIVATE;
191 extern char		*_ppdCreateFromIPP(char *buffer, size_t bufsize, ipp_t *response) _CUPS_PRIVATE;
192 extern char		*_ppdCreateFromIPP2(char *buffer, size_t bufsize, ipp_t *response, cups_lang_t *lang) _CUPS_PRIVATE;
193 extern void		_ppdFreeLanguages(cups_array_t *languages) _CUPS_PRIVATE;
194 extern cups_encoding_t	_ppdGetEncoding(const char *name) _CUPS_PRIVATE;
195 extern cups_array_t	*_ppdGetLanguages(ppd_file_t *ppd) _CUPS_PRIVATE;
196 extern _ppd_globals_t	*_ppdGlobals(void) _CUPS_PRIVATE;
197 extern unsigned		_ppdHashName(const char *name) _CUPS_PRIVATE;
198 extern ppd_attr_t	*_ppdLocalizedAttr(ppd_file_t *ppd, const char *keyword,
199 			                   const char *spec, const char *ll_CC) _CUPS_PRIVATE;
200 extern char		*_ppdNormalizeMakeAndModel(const char *make_and_model,
201 			                           char *buffer,
202 						   size_t bufsize) _CUPS_PRIVATE;
203 extern ppd_file_t	*_ppdOpen(cups_file_t *fp,
204 				  _ppd_localization_t localization) _CUPS_PRIVATE;
205 extern ppd_file_t	*_ppdOpenFile(const char *filename,
206 				      _ppd_localization_t localization) _CUPS_PRIVATE;
207 extern int		_ppdParseOptions(const char *s, int num_options,
208 			                 cups_option_t **options,
209 					 _ppd_parse_t which) _CUPS_PRIVATE;
210 extern const char	*_pwgInputSlotForSource(const char *media_source,
211 			                        char *name, size_t namesize) _CUPS_PRIVATE;
212 extern const char	*_pwgMediaTypeForType(const char *media_type,
213 					      char *name, size_t namesize) _CUPS_PRIVATE;
214 extern const char	*_pwgPageSizeForMedia(pwg_media_t *media,
215 			                      char *name, size_t namesize) _CUPS_PRIVATE;
216 
217 
218 /*
219  * C++ magic...
220  */
221 
222 #  ifdef __cplusplus
223 }
224 #  endif /* __cplusplus */
225 #endif /* !_CUPS_PPD_PRIVATE_H_ */
226