]>
git.ipfire.org Git - thirdparty/cups.git/blob - ppdc/ppdpo.cxx
2 // "$Id: ppdpo.cxx 12634 2015-05-15 19:17:07Z msweet $"
4 // PPD file message catalog program for the CUPS PPD Compiler.
6 // Copyright 2007-2015 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 // Include necessary headers...
20 #include "ppdc-private.h"
22 #include <sys/types.h>
29 static void add_ui_strings(ppdcDriver
*d
, ppdcCatalog
*catalog
);
30 static void usage(void);
34 // 'main()' - Main entry for the PPD compiler.
37 int // O - Exit status
38 main(int argc
, // I - Number of command-line arguments
39 char *argv
[]) // I - Command-line arguments
42 ppdcCatalog
*catalog
; // Message catalog
43 ppdcSource
*src
; // PPD source file data
44 ppdcDriver
*d
; // Current driver
45 char *opt
; // Current option
46 int verbose
; // Verbosity
47 const char *outfile
; // Output file
48 char *value
; // Value in option
53 // Scan the command-line...
54 catalog
= new ppdcCatalog("en");
55 src
= new ppdcSource();
59 for (i
= 1; i
< argc
; i
++)
60 if (argv
[i
][0] == '-')
62 for (opt
= argv
[i
] + 1; *opt
; opt
++)
65 case 'D' : // Define variable
70 if ((value
= strchr(argv
[i
], '=')) != NULL
)
74 src
->set_variable(argv
[i
], value
);
77 src
->set_variable(argv
[i
], "1");
80 case 'I' : // Include directory...
86 _cupsLangPrintf(stdout
,
87 _("ppdc: Adding include directory \"%s\"."),
90 ppdcSource::add_include(argv
[i
]);
93 case 'o' : // Output file...
95 if (i
>= argc
|| outfile
)
100 catalog
->load_messages(outfile
);
103 case 'v' : // Be verbose...
114 // Open and load the driver info file...
116 _cupsLangPrintf(stdout
,
117 _("ppdc: Loading driver information file \"%s\"."),
120 src
->read_file(argv
[i
]);
123 // If no drivers have been loaded, display the program usage message.
124 if ((d
= (ppdcDriver
*)src
->drivers
->first()) != NULL
)
130 _cupsLangPrintf(stderr
, _("ppdc: Adding/updating UI text from %s."), argv
[i
]);
132 add_ui_strings(d
, catalog
);
134 d
= (ppdcDriver
*)src
->drivers
->next();
140 // Delete the printer driver information...
143 // Write the message catalog...
147 catalog
->save_messages(outfile
);
151 // Return with no errors.
157 // 'add_ui_strings()' - Add all UI strings from the driver.
161 add_ui_strings(ppdcDriver
*d
, // I - Driver data
162 ppdcCatalog
*catalog
) // I - Message catalog
164 // Add the make/model/language strings...
165 catalog
->add_message(d
->manufacturer
->value
);
166 catalog
->add_message(d
->model_name
->value
);
168 // Add the media size strings...
169 ppdcMediaSize
*m
; // Current media size
171 for (m
= (ppdcMediaSize
*)d
->sizes
->first();
173 m
= (ppdcMediaSize
*)d
->sizes
->next())
174 catalog
->add_message(m
->text
->value
);
176 // Add the group/option/choice strings...
177 ppdcGroup
*g
; // Current group
178 ppdcOption
*o
; // Current option
179 ppdcChoice
*c
; // Current choice
181 for (g
= (ppdcGroup
*)d
->groups
->first();
183 g
= (ppdcGroup
*)d
->groups
->next())
185 if (!g
->options
->count
)
188 if (_cups_strcasecmp(g
->name
->value
, "General"))
189 catalog
->add_message(g
->text
->value
);
191 for (o
= (ppdcOption
*)g
->options
->first();
193 o
= (ppdcOption
*)g
->options
->next())
195 if (!o
->choices
->count
)
199 catalog
->add_message(o
->text
->value
);
201 catalog
->add_message(o
->name
->value
);
203 for (c
= (ppdcChoice
*)o
->choices
->first();
205 c
= (ppdcChoice
*)o
->choices
->next())
207 catalog
->add_message(c
->text
->value
);
209 catalog
->add_message(c
->name
->value
);
213 // Add profile and preset strings...
214 ppdcAttr
*a
; // Current attribute
215 for (a
= (ppdcAttr
*)d
->attrs
->first();
217 a
= (ppdcAttr
*)d
->attrs
->next())
218 if (a
->text
->value
&& a
->text
->value
[0] &&
220 !strncmp(a
->name
->value
, "Custom", 6) ||
221 !strncmp(a
->name
->value
, "ParamCustom", 11) ||
222 !strcmp(a
->name
->value
, "APCustomColorMatchingName") ||
223 !strcmp(a
->name
->value
, "APPrinterPreset") ||
224 !strcmp(a
->name
->value
, "cupsICCProfile") ||
225 !strcmp(a
->name
->value
, "cupsIPPReason") ||
226 !strcmp(a
->name
->value
, "cupsMarkerName")))
228 catalog
->add_message(a
->text
->value
);
230 if ((a
->localizable
&& a
->value
->value
[0]) ||
231 !strcmp(a
->name
->value
, "cupsIPPReason"))
232 catalog
->add_message(a
->value
->value
);
234 else if (!strncmp(a
->name
->value
, "Custom", 6) ||
235 !strncmp(a
->name
->value
, "ParamCustom", 11))
236 catalog
->add_message(a
->name
->value
);
241 // 'usage()' - Show usage and exit.
247 _cupsLangPuts(stdout
, _("Usage: ppdpo [options] -o filename.po filename.drv "
248 "[ ... filenameN.drv ]"));
249 _cupsLangPuts(stdout
, _("Options:"));
250 _cupsLangPuts(stdout
, _(" -D name=value Set named variable to "
252 _cupsLangPuts(stdout
, _(" -I include-dir Add include directory to "
254 _cupsLangPuts(stdout
, _(" -v Be verbose."));
261 // End of "$Id: ppdpo.cxx 12634 2015-05-15 19:17:07Z msweet $".