]>
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...
26 #include "ppdc-private.h"
28 #include <sys/types.h>
35 static void add_ui_strings(ppdcDriver
*d
, ppdcCatalog
*catalog
);
36 static void usage(void);
40 // 'main()' - Main entry for the PPD compiler.
43 int // O - Exit status
44 main(int argc
, // I - Number of command-line arguments
45 char *argv
[]) // I - Command-line arguments
48 ppdcCatalog
*catalog
; // Message catalog
49 ppdcSource
*src
; // PPD source file data
50 ppdcDriver
*d
; // Current driver
51 char *opt
; // Current option
52 int verbose
; // Verbosity
53 const char *outfile
; // Output file
54 char *value
; // Value in option
59 // Scan the command-line...
60 catalog
= new ppdcCatalog("en");
65 for (i
= 1; i
< argc
; i
++)
66 if (argv
[i
][0] == '-')
68 for (opt
= argv
[i
] + 1; *opt
; opt
++)
71 case 'D' : // Define variable
76 if ((value
= strchr(argv
[i
], '=')) != NULL
)
80 src
->set_variable(argv
[i
], value
);
83 src
->set_variable(argv
[i
], "1");
86 case 'I' : // Include directory...
92 _cupsLangPrintf(stdout
,
93 _("ppdc: Adding include directory \"%s\"...\n"),
96 ppdcSource::add_include(argv
[i
]);
99 case 'o' : // Output file...
101 if (i
>= argc
|| outfile
)
106 catalog
->load_messages(outfile
);
109 case 'v' : // Be verbose...
120 // Open and load the driver info file...
122 _cupsLangPrintf(stdout
,
123 _("ppdc: Loading driver information file \"%s\"...\n"),
126 src
= new ppdcSource(argv
[i
]);
129 for (d
= (ppdcDriver
*)src
->drivers
->first();
131 d
= (ppdcDriver
*)src
->drivers
->next())
134 _cupsLangPrintf(stderr
,
135 _("ppdc: Adding/updating UI text from %s...\n"),
138 add_ui_strings(d
, catalog
);
141 // Delete the printer driver information...
145 // Write the message catalog...
149 catalog
->save_messages(outfile
);
153 // If no drivers have been loaded, display the program usage message.
157 // Return with no errors.
163 // 'add_ui_strings()' - Add all UI strings from the driver.
167 add_ui_strings(ppdcDriver
*d
, // I - Driver data
168 ppdcCatalog
*catalog
) // I - Message catalog
170 // Add the make/model/language strings...
171 catalog
->add_message(d
->manufacturer
->value
);
172 catalog
->add_message(d
->model_name
->value
);
174 // Add the media size strings...
175 ppdcMediaSize
*m
; // Current media size
177 for (m
= (ppdcMediaSize
*)d
->sizes
->first();
179 m
= (ppdcMediaSize
*)d
->sizes
->next())
180 catalog
->add_message(m
->text
->value
);
182 // Add the group/option/choice strings...
183 ppdcGroup
*g
; // Current group
184 ppdcOption
*o
; // Current option
185 ppdcChoice
*c
; // Current choice
187 for (g
= (ppdcGroup
*)d
->groups
->first();
189 g
= (ppdcGroup
*)d
->groups
->next())
191 if (!g
->options
->count
)
194 if (strcasecmp(g
->name
->value
, "General"))
195 catalog
->add_message(g
->text
->value
);
197 for (o
= (ppdcOption
*)g
->options
->first();
199 o
= (ppdcOption
*)g
->options
->next())
201 if (!o
->choices
->count
)
205 catalog
->add_message(o
->text
->value
);
207 catalog
->add_message(o
->name
->value
);
209 for (c
= (ppdcChoice
*)o
->choices
->first();
211 c
= (ppdcChoice
*)o
->choices
->next())
213 catalog
->add_message(c
->text
->value
);
215 catalog
->add_message(c
->name
->value
);
219 // Add profile and preset strings...
220 ppdcAttr
*a
; // Current attribute
221 for (a
= (ppdcAttr
*)d
->attrs
->first();
223 a
= (ppdcAttr
*)d
->attrs
->next())
224 if (a
->text
->value
&& a
->text
->value
[0] &&
226 !strncmp(a
->name
->value
, "Custom", 6) ||
227 !strncmp(a
->name
->value
, "ParamCustom", 11) ||
228 !strcmp(a
->name
->value
, "APCustomColorMatchingName") ||
229 !strcmp(a
->name
->value
, "APPrinterPreset") ||
230 !strcmp(a
->name
->value
, "cupsICCProfile") ||
231 !strcmp(a
->name
->value
, "cupsIPPReason") ||
232 !strcmp(a
->name
->value
, "cupsMarkerName")))
234 catalog
->add_message(a
->text
->value
);
236 if ((a
->localizable
&& a
->value
->value
[0]) ||
237 !strcmp(a
->name
->value
, "cupsIPPReason"))
238 catalog
->add_message(a
->value
->value
);
240 else if (!strncmp(a
->name
->value
, "Custom", 6) ||
241 !strncmp(a
->name
->value
, "ParamCustom", 11))
242 catalog
->add_message(a
->name
->value
);
247 // 'usage()' - Show usage and exit.
253 _cupsLangPuts(stdout
,
254 _("Usage: ppdpo [options] -o filename.po filename.drv [ ... "
257 " -D name=value Set named variable to value.\n"
258 " -I include-dir Add include directory to search path.\n"
259 " -v Be verbose (more v's for more "