]>
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 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>
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
56 // Scan the command-line...
57 catalog
= new ppdcCatalog("en");
62 for (i
= 1; i
< argc
; i
++)
63 if (argv
[i
][0] == '-')
65 for (opt
= argv
[i
] + 1; *opt
; opt
++)
68 case 'I' : // Include directory...
74 printf("ppdc: Adding include directory \"%s\"...\n", argv
[i
]);
76 ppdcSource::add_include(argv
[i
]);
79 case 'o' : // Output file...
81 if (i
>= argc
|| outfile
)
86 catalog
->load_messages(outfile
);
89 case 'v' : // Be verbose...
100 // Open and load the driver info file...
102 printf("ppdc: Loading driver information file \"%s\"...\n", argv
[i
]);
104 src
= new ppdcSource(argv
[i
]);
107 for (d
= (ppdcDriver
*)src
->drivers
->first();
109 d
= (ppdcDriver
*)src
->drivers
->next())
112 printf("ppdc: Adding/updating UI text from %s...\n", argv
[i
]);
114 add_ui_strings(d
, catalog
);
117 // Delete the printer driver information...
121 // Write the message catalog...
125 catalog
->save_messages(outfile
);
129 // If no drivers have been loaded, display the program usage message.
133 // Return with no errors.
139 // 'add_ui_strings()' - Add all UI strings from the driver.
143 add_ui_strings(ppdcDriver
*d
, // I - Driver data
144 ppdcCatalog
*catalog
) // I - Message catalog
146 // Add the make/model/language strings...
147 catalog
->add_message(d
->manufacturer
->value
);
148 catalog
->add_message(d
->model_name
->value
);
150 // Add the media size strings...
151 ppdcMediaSize
*m
; // Current media size
153 for (m
= (ppdcMediaSize
*)d
->sizes
->first();
155 m
= (ppdcMediaSize
*)d
->sizes
->next())
156 catalog
->add_message(m
->text
->value
);
158 // Add the group/option/choice strings...
159 ppdcGroup
*g
; // Current group
160 ppdcOption
*o
; // Current option
161 ppdcChoice
*c
; // Current choice
163 for (g
= (ppdcGroup
*)d
->groups
->first();
165 g
= (ppdcGroup
*)d
->groups
->next())
167 if (!g
->options
->count
)
170 if (strcasecmp(g
->name
->value
, "General"))
171 catalog
->add_message(g
->text
->value
);
173 for (o
= (ppdcOption
*)g
->options
->first();
175 o
= (ppdcOption
*)g
->options
->next())
177 if (!o
->choices
->count
)
180 if (o
->text
->value
&& strcmp(o
->name
->value
, o
->text
->value
))
181 catalog
->add_message(o
->text
->value
);
183 catalog
->add_message(o
->name
->value
);
185 for (c
= (ppdcChoice
*)o
->choices
->first();
187 c
= (ppdcChoice
*)o
->choices
->next())
188 if (c
->text
->value
&& strcmp(c
->name
->value
, c
->text
->value
))
189 catalog
->add_message(c
->text
->value
);
191 catalog
->add_message(c
->name
->value
);
195 // Add profile and preset strings...
196 ppdcAttr
*a
; // Current attribute
197 for (a
= (ppdcAttr
*)d
->attrs
->first();
199 a
= (ppdcAttr
*)d
->attrs
->next())
200 if (a
->text
->value
&& a
->text
->value
[0] &&
201 (!strncmp(a
->name
->value
, "Custom", 6) ||
202 !strncmp(a
->name
->value
, "ParamCustom", 11) ||
203 !strcmp(a
->name
->value
, "APCustomColorMatchingName") ||
204 !strcmp(a
->name
->value
, "APPrinterPreset") ||
205 !strcmp(a
->name
->value
, "cupsICCProfile") ||
206 !strcmp(a
->name
->value
, "cupsIPPReason")))
207 catalog
->add_message(a
->text
->value
);
208 else if (!strncmp(a
->name
->value
, "Custom", 6) ||
209 !strncmp(a
->name
->value
, "ParamCustom", 11))
210 catalog
->add_message(a
->name
->value
);
215 // 'usage()' - Show usage and exit.
221 puts("Usage: ppdpo [options] -o filename.po filename.drv [ ... filenameN.drv ]");
223 puts(" -I include-dir Add include directory to search path.");
224 puts(" -v Be verbose (more v's for more verbosity).");