]>
git.ipfire.org Git - thirdparty/cups.git/blob - ppdc/ppdpo.cxx
5ebfeaf999ff1b7829da14c6675734d4253970df
2 // PPD file message catalog program for the CUPS PPD Compiler.
4 // Copyright 2007-2015 by Apple Inc.
5 // Copyright 2002-2005 by Easy Software Products.
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 // file is missing or damaged, see the license at "http://www.cups.org/".
15 // Include necessary headers...
18 #include "ppdc-private.h"
20 #include <sys/types.h>
27 static void add_ui_strings(ppdcDriver
*d
, ppdcCatalog
*catalog
);
28 static void usage(void);
32 // 'main()' - Main entry for the PPD compiler.
35 int // O - Exit status
36 main(int argc
, // I - Number of command-line arguments
37 char *argv
[]) // I - Command-line arguments
40 ppdcCatalog
*catalog
; // Message catalog
41 ppdcSource
*src
; // PPD source file data
42 ppdcDriver
*d
; // Current driver
43 char *opt
; // Current option
44 int verbose
; // Verbosity
45 const char *outfile
; // Output file
46 char *value
; // Value in option
51 // Scan the command-line...
52 catalog
= new ppdcCatalog("en");
53 src
= new ppdcSource();
57 for (i
= 1; i
< argc
; i
++)
58 if (argv
[i
][0] == '-')
60 for (opt
= argv
[i
] + 1; *opt
; opt
++)
63 case 'D' : // Define variable
68 if ((value
= strchr(argv
[i
], '=')) != NULL
)
72 src
->set_variable(argv
[i
], value
);
75 src
->set_variable(argv
[i
], "1");
78 case 'I' : // Include directory...
84 _cupsLangPrintf(stdout
,
85 _("ppdc: Adding include directory \"%s\"."),
88 ppdcSource::add_include(argv
[i
]);
91 case 'o' : // Output file...
93 if (i
>= argc
|| outfile
)
98 catalog
->load_messages(outfile
);
101 case 'v' : // Be verbose...
112 // Open and load the driver info file...
114 _cupsLangPrintf(stdout
,
115 _("ppdc: Loading driver information file \"%s\"."),
118 src
->read_file(argv
[i
]);
121 // If no drivers have been loaded, display the program usage message.
122 if ((d
= (ppdcDriver
*)src
->drivers
->first()) != NULL
)
128 _cupsLangPrintf(stderr
, _("ppdc: Adding/updating UI text from %s."), argv
[i
]);
130 add_ui_strings(d
, catalog
);
132 d
= (ppdcDriver
*)src
->drivers
->next();
138 // Delete the printer driver information...
141 // Write the message catalog...
145 catalog
->save_messages(outfile
);
149 // Return with no errors.
155 // 'add_ui_strings()' - Add all UI strings from the driver.
159 add_ui_strings(ppdcDriver
*d
, // I - Driver data
160 ppdcCatalog
*catalog
) // I - Message catalog
162 // Add the make/model/language strings...
163 catalog
->add_message(d
->manufacturer
->value
);
164 catalog
->add_message(d
->model_name
->value
);
166 // Add the media size strings...
167 ppdcMediaSize
*m
; // Current media size
169 for (m
= (ppdcMediaSize
*)d
->sizes
->first();
171 m
= (ppdcMediaSize
*)d
->sizes
->next())
172 catalog
->add_message(m
->text
->value
);
174 // Add the group/option/choice strings...
175 ppdcGroup
*g
; // Current group
176 ppdcOption
*o
; // Current option
177 ppdcChoice
*c
; // Current choice
179 for (g
= (ppdcGroup
*)d
->groups
->first();
181 g
= (ppdcGroup
*)d
->groups
->next())
183 if (!g
->options
->count
)
186 if (_cups_strcasecmp(g
->name
->value
, "General"))
187 catalog
->add_message(g
->text
->value
);
189 for (o
= (ppdcOption
*)g
->options
->first();
191 o
= (ppdcOption
*)g
->options
->next())
193 if (!o
->choices
->count
)
197 catalog
->add_message(o
->text
->value
);
199 catalog
->add_message(o
->name
->value
);
201 for (c
= (ppdcChoice
*)o
->choices
->first();
203 c
= (ppdcChoice
*)o
->choices
->next())
205 catalog
->add_message(c
->text
->value
);
207 catalog
->add_message(c
->name
->value
);
211 // Add profile and preset strings...
212 ppdcAttr
*a
; // Current attribute
213 for (a
= (ppdcAttr
*)d
->attrs
->first();
215 a
= (ppdcAttr
*)d
->attrs
->next())
216 if (a
->text
->value
&& a
->text
->value
[0] &&
218 !strncmp(a
->name
->value
, "Custom", 6) ||
219 !strncmp(a
->name
->value
, "ParamCustom", 11) ||
220 !strcmp(a
->name
->value
, "APCustomColorMatchingName") ||
221 !strcmp(a
->name
->value
, "APPrinterPreset") ||
222 !strcmp(a
->name
->value
, "cupsICCProfile") ||
223 !strcmp(a
->name
->value
, "cupsIPPReason") ||
224 !strcmp(a
->name
->value
, "cupsMarkerName")))
226 catalog
->add_message(a
->text
->value
);
228 if ((a
->localizable
&& a
->value
->value
[0]) ||
229 !strcmp(a
->name
->value
, "cupsIPPReason"))
230 catalog
->add_message(a
->value
->value
);
232 else if (!strncmp(a
->name
->value
, "Custom", 6) ||
233 !strncmp(a
->name
->value
, "ParamCustom", 11))
234 catalog
->add_message(a
->name
->value
);
239 // 'usage()' - Show usage and exit.
245 _cupsLangPuts(stdout
, _("Usage: ppdpo [options] -o filename.po filename.drv "
246 "[ ... filenameN.drv ]"));
247 _cupsLangPuts(stdout
, _("Options:"));
248 _cupsLangPuts(stdout
, _(" -D name=value Set named variable to "
250 _cupsLangPuts(stdout
, _(" -I include-dir Add include directory to "
252 _cupsLangPuts(stdout
, _(" -v Be verbose."));