]>
Commit | Line | Data |
---|---|---|
54afec33 MS |
1 | /* |
2 | * "$Id$" | |
3 | * | |
71e16022 | 4 | * Private PWG media API definitions for CUPS. |
54afec33 MS |
5 | * |
6 | * Copyright 2009-2010 by Apple Inc. | |
7 | * | |
8 | * These coded instructions, statements, and computer programs are the | |
9 | * property of Apple Inc. and are protected by Federal copyright | |
10 | * law. Distribution and use rights are outlined in the file "LICENSE.txt" | |
11 | * which should have been included with this file. If this file is | |
12 | * file is missing or damaged, see the license at "http://www.cups.org/". | |
13 | * | |
14 | * This file is subject to the Apple OS-Developed Software exception. | |
15 | */ | |
16 | ||
17 | #ifndef _CUPS_PWG_PRIVATE_H_ | |
18 | # define _CUPS_PWG_PRIVATE_H_ | |
19 | ||
20 | ||
21 | /* | |
22 | * Include necessary headers... | |
23 | */ | |
24 | ||
25 | # include <cups/cups.h> | |
26 | ||
27 | ||
28 | /* | |
29 | * C++ magic... | |
30 | */ | |
31 | ||
32 | # ifdef __cplusplus | |
33 | extern "C" { | |
34 | # endif /* __cplusplus */ | |
35 | ||
36 | ||
37 | /* | |
38 | * Macros... | |
39 | */ | |
40 | ||
41 | /* Convert from points to 2540ths */ | |
42 | # define _PWG_FROMPTS(n) (int)((n) * 2540 / 72) | |
43 | /* Convert from 2540ths to points */ | |
44 | # define _PWG_TOPTS(n) ((n) * 72.0 / 2540.0) | |
45 | ||
46 | ||
47 | /* | |
48 | * Types and structures... | |
49 | */ | |
50 | ||
51 | typedef struct _pwg_media_s /**** Common media size data ****/ | |
52 | { | |
53 | const char *pwg, /* PWG 5101.1 "self describing" name */ | |
54 | *legacy, /* IPP/ISO legacy name */ | |
55 | *ppd; /* Standard Adobe PPD name */ | |
56 | int width, /* Width in 2540ths */ | |
57 | length; /* Length in 2540ths */ | |
58 | } _pwg_media_t; | |
59 | ||
60 | typedef struct _pwg_map_s /**** Map element - PPD to/from PWG */ | |
61 | { | |
62 | char *pwg, /* PWG media keyword */ | |
63 | *ppd; /* PPD option keyword */ | |
64 | } _pwg_map_t; | |
65 | ||
66 | typedef struct _pwg_size_s /**** Size element - PPD to/from PWG */ | |
67 | { | |
68 | _pwg_map_t map; /* Map element */ | |
69 | int width, /* Width in 2540ths */ | |
70 | length, /* Length in 2540ths */ | |
71 | left, /* Left margin in 2540ths */ | |
72 | bottom, /* Bottom margin in 2540ths */ | |
73 | right, /* Right margin in 2540ths */ | |
74 | top; /* Top margin in 2540ths */ | |
75 | } _pwg_size_t; | |
76 | ||
77 | typedef struct _pwg_s /**** PWG-PPD conversion data ****/ | |
78 | { | |
79 | int num_sizes; /* Number of media sizes */ | |
80 | _pwg_size_t *sizes; /* Media sizes */ | |
81 | int custom_max_width, /* Maximum custom width in 2540ths */ | |
82 | custom_max_length, /* Maximum custom length in 2540ths */ | |
83 | custom_min_width, /* Minimum custom width in 2540ths */ | |
84 | custom_min_length; /* Minimum custom length in 2540ths */ | |
85 | char *custom_max_keyword, /* Maximum custom size PWG keyword */ | |
86 | *custom_min_keyword, /* Minimum custom size PWG keyword */ | |
87 | custom_ppd_size[PPD_MAX_NAME]; | |
88 | /* Custom PPD size name */ | |
89 | _pwg_size_t custom_size; /* Custom size record */ | |
90 | int num_sources; /* Number of media sources */ | |
91 | _pwg_map_t *sources; /* Media sources */ | |
92 | int num_types; /* Number of media types */ | |
93 | _pwg_map_t *types; /* Media types */ | |
94 | } _pwg_t; | |
95 | ||
96 | ||
97 | /* | |
98 | * Functions... | |
99 | */ | |
100 | ||
101 | extern _pwg_t *_pwgCreateWithFile(const char *filename); | |
102 | extern _pwg_t *_pwgCreateWithPPD(ppd_file_t *ppd); | |
103 | extern void _pwgDestroy(_pwg_t *pwg); | |
104 | extern void _pwgGenerateSize(char *keyword, size_t keysize, | |
105 | const char *prefix, | |
106 | const char *ppdname, | |
107 | int width, int length); | |
108 | extern const char *_pwgGetInputSlot(_pwg_t *pwg, ipp_t *job, | |
109 | const char *keyword); | |
110 | extern const char *_pwgGetMediaType(_pwg_t *pwg, ipp_t *job, | |
111 | const char *keyword); | |
112 | extern const char *_pwgGetPageSize(_pwg_t *pwg, ipp_t *job, | |
113 | const char *keyword, int *exact); | |
114 | extern _pwg_size_t *_pwgGetSize(_pwg_t *pwg, const char *page_size); | |
115 | extern const char *_pwgGetSource(_pwg_t *pwg, const char *input_slot); | |
116 | extern const char *_pwgGetType(_pwg_t *pwg, const char *media_type); | |
117 | extern int _pwgInitSize(_pwg_size_t *size, ipp_t *job, | |
118 | int *margins_set); | |
119 | extern const char *_pwgInputSlotForSource(const char *media_source, | |
120 | char *name, size_t namesize); | |
121 | extern _pwg_media_t *_pwgMediaForLegacy(const char *legacy); | |
122 | extern _pwg_media_t *_pwgMediaForPPD(const char *ppd); | |
123 | extern _pwg_media_t *_pwgMediaForPWG(const char *pwg); | |
124 | extern _pwg_media_t *_pwgMediaForSize(int width, int length); | |
125 | extern const char *_pwgMediaTypeForType(const char *media_source, | |
126 | char *name, size_t namesize); | |
127 | extern const char *_pwgPageSizeForMedia(_pwg_media_t *media, | |
128 | char *name, size_t namesize); | |
129 | extern int _pwgWriteFile(_pwg_t *pwg, const char *filename); | |
130 | ||
131 | ||
132 | # ifdef __cplusplus | |
133 | } | |
134 | # endif /* __cplusplus */ | |
135 | ||
136 | #endif /* !_CUPS_PWG_PRIVATE_H_ */ | |
137 | ||
138 | /* | |
139 | * End of "$Id$". | |
140 | */ |