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