]>
git.ipfire.org Git - thirdparty/cups.git/blob - ppdc/ppdpo.cxx
4 // PPD file message catalog program for the CUPS PPD Compiler.
6 // Copyright 2007-2008 by Apple Inc.
7 // Copyright 2002-2005 by Easy Software Products.
9 // These coded instructions, statements, and computer programs are the
10 // property of Apple Inc. and are protected by Federal copyright
11 // law. Distribution and use rights are outlined in the file "LICENSE.txt"
12 // which should have been included with this file. If this file is
13 // file is missing or damaged, see the license at "http://www.cups.org/".
17 // main() - Main entry for the PPD compiler.
18 // add_ui_strings() - Add all UI strings from the driver.
19 // usage() - Show usage and exit.
23 // Include necessary headers...
28 #include <sys/types.h>
29 #include <cups/i18n.h>
36 static void add_ui_strings(ppdcDriver
*d
, ppdcCatalog
*catalog
);
37 static void usage(void);
41 // 'main()' - Main entry for the PPD compiler.
44 int // O - Exit status
45 main(int argc
, // I - Number of command-line arguments
46 char *argv
[]) // I - Command-line arguments
49 ppdcCatalog
*catalog
; // Message catalog
50 ppdcSource
*src
; // PPD source file data
51 ppdcDriver
*d
; // Current driver
52 char *opt
; // Current option
53 int verbose
; // Verbosity
54 const char *outfile
; // Output file
55 char *value
; // Value in option
60 // Scan the command-line...
61 catalog
= new ppdcCatalog("en");
66 for (i
= 1; i
< argc
; i
++)
67 if (argv
[i
][0] == '-')
69 for (opt
= argv
[i
] + 1; *opt
; opt
++)
72 case 'D' : // Define variable
77 if ((value
= strchr(argv
[i
], '=')) != NULL
)
81 src
->set_variable(argv
[i
], value
);
84 src
->set_variable(argv
[i
], "1");
87 case 'I' : // Include directory...
93 _cupsLangPrintf(stdout
,
94 _("ppdc: Adding include directory \"%s\"...\n"),
97 ppdcSource::add_include(argv
[i
]);
100 case 'o' : // Output file...
102 if (i
>= argc
|| outfile
)
107 catalog
->load_messages(outfile
);
110 case 'v' : // Be verbose...
121 // Open and load the driver info file...
123 _cupsLangPrintf(stdout
,
124 _("ppdc: Loading driver information file \"%s\"...\n"),
127 src
= new ppdcSource(argv
[i
]);
130 for (d
= (ppdcDriver
*)src
->drivers
->first();
132 d
= (ppdcDriver
*)src
->drivers
->next())
135 _cupsLangPrintf(stderr
,
136 _("ppdc: Adding/updating UI text from %s...\n"),
139 add_ui_strings(d
, catalog
);
142 // Delete the printer driver information...
146 // Write the message catalog...
150 catalog
->save_messages(outfile
);
154 // If no drivers have been loaded, display the program usage message.
158 // Return with no errors.
164 // 'add_ui_strings()' - Add all UI strings from the driver.
168 add_ui_strings(ppdcDriver
*d
, // I - Driver data
169 ppdcCatalog
*catalog
) // I - Message catalog
171 // Add the make/model/language strings...
172 catalog
->add_message(d
->manufacturer
->value
);
173 catalog
->add_message(d
->model_name
->value
);
175 // Add the media size strings...
176 ppdcMediaSize
*m
; // Current media size
178 for (m
= (ppdcMediaSize
*)d
->sizes
->first();
180 m
= (ppdcMediaSize
*)d
->sizes
->next())
181 catalog
->add_message(m
->text
->value
);
183 // Add the group/option/choice strings...
184 ppdcGroup
*g
; // Current group
185 ppdcOption
*o
; // Current option
186 ppdcChoice
*c
; // Current choice
188 for (g
= (ppdcGroup
*)d
->groups
->first();
190 g
= (ppdcGroup
*)d
->groups
->next())
192 if (!g
->options
->count
)
195 if (strcasecmp(g
->name
->value
, "General"))
196 catalog
->add_message(g
->text
->value
);
198 for (o
= (ppdcOption
*)g
->options
->first();
200 o
= (ppdcOption
*)g
->options
->next())
202 if (!o
->choices
->count
)
205 if (o
->text
->value
&& strcmp(o
->name
->value
, o
->text
->value
))
206 catalog
->add_message(o
->text
->value
);
208 catalog
->add_message(o
->name
->value
);
210 for (c
= (ppdcChoice
*)o
->choices
->first();
212 c
= (ppdcChoice
*)o
->choices
->next())
213 if (c
->text
->value
&& strcmp(c
->name
->value
, c
->text
->value
))
214 catalog
->add_message(c
->text
->value
);
216 catalog
->add_message(c
->name
->value
);
220 // Add profile and preset strings...
221 ppdcAttr
*a
; // Current attribute
222 for (a
= (ppdcAttr
*)d
->attrs
->first();
224 a
= (ppdcAttr
*)d
->attrs
->next())
225 if (a
->text
->value
&& a
->text
->value
[0] &&
227 !strncmp(a
->name
->value
, "Custom", 6) ||
228 !strncmp(a
->name
->value
, "ParamCustom", 11) ||
229 !strcmp(a
->name
->value
, "APCustomColorMatchingName") ||
230 !strcmp(a
->name
->value
, "APPrinterPreset") ||
231 !strcmp(a
->name
->value
, "cupsICCProfile") ||
232 !strcmp(a
->name
->value
, "cupsIPPReason") ||
233 !strcmp(a
->name
->value
, "cupsMarkerName")))
235 catalog
->add_message(a
->text
->value
);
237 if ((a
->localizable
&& a
->value
->value
[0]) ||
238 !strcmp(a
->name
->value
, "cupsIPPReason"))
239 catalog
->add_message(a
->value
->value
);
241 else if (!strncmp(a
->name
->value
, "Custom", 6) ||
242 !strncmp(a
->name
->value
, "ParamCustom", 11))
243 catalog
->add_message(a
->name
->value
);
248 // 'usage()' - Show usage and exit.
254 _cupsLangPuts(stdout
,
255 _("Usage: ppdpo [options] -o filename.po filename.drv [ ... "
258 " -D name=value Set named variable to value.\n"
259 " -I include-dir Add include directory to search path.\n"
260 " -v Be verbose (more v's for more "