]>
git.ipfire.org Git - thirdparty/cups.git/blob - ppdc/ppdpo.cxx
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 // Licensed under Apache License v2.0. See the file "LICENSE" for more information.
11 // Include necessary headers...
14 #include "ppdc-private.h"
16 #include <sys/types.h>
23 static void add_ui_strings(ppdcDriver
*d
, ppdcCatalog
*catalog
);
24 static void usage(void);
28 // 'main()' - Main entry for the PPD compiler.
31 int // O - Exit status
32 main(int argc
, // I - Number of command-line arguments
33 char *argv
[]) // I - Command-line arguments
36 ppdcCatalog
*catalog
; // Message catalog
37 ppdcSource
*src
; // PPD source file data
38 ppdcDriver
*d
; // Current driver
39 char *opt
; // Current option
40 int verbose
; // Verbosity
41 const char *outfile
; // Output file
42 char *value
; // Value in option
47 // Scan the command-line...
48 catalog
= new ppdcCatalog("en");
49 src
= new ppdcSource();
53 for (i
= 1; i
< argc
; i
++)
54 if (argv
[i
][0] == '-')
56 for (opt
= argv
[i
] + 1; *opt
; opt
++)
59 case 'D' : // Define variable
64 if ((value
= strchr(argv
[i
], '=')) != NULL
)
68 src
->set_variable(argv
[i
], value
);
71 src
->set_variable(argv
[i
], "1");
74 case 'I' : // Include directory...
80 _cupsLangPrintf(stdout
,
81 _("ppdc: Adding include directory \"%s\"."),
84 ppdcSource::add_include(argv
[i
]);
87 case 'o' : // Output file...
89 if (i
>= argc
|| outfile
)
94 catalog
->load_messages(outfile
);
97 case 'v' : // Be verbose...
108 // Open and load the driver info file...
110 _cupsLangPrintf(stdout
,
111 _("ppdc: Loading driver information file \"%s\"."),
114 src
->read_file(argv
[i
]);
117 // If no drivers have been loaded, display the program usage message.
118 if ((d
= (ppdcDriver
*)src
->drivers
->first()) != NULL
)
124 _cupsLangPrintf(stderr
, _("ppdc: Adding/updating UI text from %s."), argv
[i
]);
126 add_ui_strings(d
, catalog
);
128 d
= (ppdcDriver
*)src
->drivers
->next();
134 // Delete the printer driver information...
137 // Write the message catalog...
141 catalog
->save_messages(outfile
);
145 // Return with no errors.
151 // 'add_ui_strings()' - Add all UI strings from the driver.
155 add_ui_strings(ppdcDriver
*d
, // I - Driver data
156 ppdcCatalog
*catalog
) // I - Message catalog
158 // Add the make/model/language strings...
159 catalog
->add_message(d
->manufacturer
->value
);
160 catalog
->add_message(d
->model_name
->value
);
162 // Add the media size strings...
163 ppdcMediaSize
*m
; // Current media size
165 for (m
= (ppdcMediaSize
*)d
->sizes
->first();
167 m
= (ppdcMediaSize
*)d
->sizes
->next())
168 catalog
->add_message(m
->text
->value
);
170 // Add the group/option/choice strings...
171 ppdcGroup
*g
; // Current group
172 ppdcOption
*o
; // Current option
173 ppdcChoice
*c
; // Current choice
175 for (g
= (ppdcGroup
*)d
->groups
->first();
177 g
= (ppdcGroup
*)d
->groups
->next())
179 if (!g
->options
->count
)
182 if (_cups_strcasecmp(g
->name
->value
, "General"))
183 catalog
->add_message(g
->text
->value
);
185 for (o
= (ppdcOption
*)g
->options
->first();
187 o
= (ppdcOption
*)g
->options
->next())
189 if (!o
->choices
->count
)
193 catalog
->add_message(o
->text
->value
);
195 catalog
->add_message(o
->name
->value
);
197 for (c
= (ppdcChoice
*)o
->choices
->first();
199 c
= (ppdcChoice
*)o
->choices
->next())
201 catalog
->add_message(c
->text
->value
);
203 catalog
->add_message(c
->name
->value
);
207 // Add profile and preset strings...
208 ppdcAttr
*a
; // Current attribute
209 for (a
= (ppdcAttr
*)d
->attrs
->first();
211 a
= (ppdcAttr
*)d
->attrs
->next())
212 if (a
->text
->value
&& a
->text
->value
[0] &&
214 !strncmp(a
->name
->value
, "Custom", 6) ||
215 !strncmp(a
->name
->value
, "ParamCustom", 11) ||
216 !strcmp(a
->name
->value
, "APCustomColorMatchingName") ||
217 !strcmp(a
->name
->value
, "APPrinterPreset") ||
218 !strcmp(a
->name
->value
, "cupsICCProfile") ||
219 !strcmp(a
->name
->value
, "cupsIPPReason") ||
220 !strcmp(a
->name
->value
, "cupsMarkerName")))
222 catalog
->add_message(a
->text
->value
);
224 if ((a
->localizable
&& a
->value
->value
[0]) ||
225 !strcmp(a
->name
->value
, "cupsIPPReason"))
226 catalog
->add_message(a
->value
->value
);
228 else if (!strncmp(a
->name
->value
, "Custom", 6) ||
229 !strncmp(a
->name
->value
, "ParamCustom", 11))
230 catalog
->add_message(a
->name
->value
);
235 // 'usage()' - Show usage and exit.
241 _cupsLangPuts(stdout
, _("Usage: ppdpo [options] -o filename.po filename.drv "
242 "[ ... filenameN.drv ]"));
243 _cupsLangPuts(stdout
, _("Options:"));
244 _cupsLangPuts(stdout
, _(" -D name=value Set named variable to "
246 _cupsLangPuts(stdout
, _(" -I include-dir Add include directory to "
248 _cupsLangPuts(stdout
, _(" -v Be verbose."));