]>
git.ipfire.org Git - thirdparty/cups.git/blob - ppdc/ppdhtml.cxx
2 // PPD to HTML utility 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 usage(void);
27 // 'main()' - Main entry for the PPD compiler.
30 int // O - Exit status
31 main(int argc
, // I - Number of command-line arguments
32 char *argv
[]) // I - Command-line arguments
35 ppdcSource
*src
; // PPD source file data
36 ppdcDriver
*d
; // Current driver
37 ppdcGroup
*g
, // Current group
38 *composite
; // Composite of all drivers
39 ppdcOption
*o
, // Current option
40 *compo
; // Composite option
41 ppdcChoice
*c
; // Current choice
42 char *opt
; // Current option char
43 ppdcMediaSize
*size
; // Current media size
44 char *value
; // Value in option
49 // Scan the command-line...
50 src
= new ppdcSource();
52 for (i
= 1; i
< argc
; i
++)
53 if (argv
[i
][0] == '-')
55 for (opt
= argv
[i
] + 1; *opt
; opt
++)
58 case 'D' : // Define variable
63 if ((value
= strchr(argv
[i
], '=')) != NULL
)
67 src
->set_variable(argv
[i
], value
);
70 src
->set_variable(argv
[i
], "1");
73 case 'I' : // Include directory...
78 ppdcSource::add_include(argv
[i
]);
88 // Open and load the driver info file...
89 src
->read_file(argv
[i
]);
92 if ((d
= (ppdcDriver
*)src
->drivers
->first()) != NULL
)
94 // Create a composite group with all of the features from the
95 // drivers in the info file...
96 composite
= new ppdcGroup("", "");
100 for (g
= (ppdcGroup
*)d
->groups
->first(); g
; g
= (ppdcGroup
*)d
->groups
->next())
101 for (o
= (ppdcOption
*)g
->options
->first(); o
; o
= (ppdcOption
*)g
->options
->next())
103 if ((compo
= composite
->find_option(o
->name
->value
)) == NULL
)
104 composite
->add_option(new ppdcOption(o
));
107 d
= (ppdcDriver
*)src
->drivers
->next();
111 printf("<head><title>Driver Summary for %s</title></head>\n", argv
[i
]);
112 printf("<body><h1>Driver Summary for %s</h1>\n", argv
[i
]);
113 printf("<p><table border='1'><thead><tr><th>Printer</th><th>Media Size</th>");
114 for (compo
= (ppdcOption
*)composite
->options
->first(); compo
; compo
= (ppdcOption
*)composite
->options
->next())
115 printf("<th>%s</th>", compo
->text
->value
);
116 puts("</tr></thead><tbody>");
118 // Write HTML summary...
119 for (d
= (ppdcDriver
*)src
->drivers
->first(); d
; d
= (ppdcDriver
*)src
->drivers
->next())
121 // Write the summary for this driver...
122 printf("<tr valign='top'><td nowrap>%s</td><td nowrap>", d
->model_name
->value
);
123 for (size
= (ppdcMediaSize
*)d
->sizes
->first(); size
;
124 size
= (ppdcMediaSize
*)d
->sizes
->next())
125 printf("%s<br>", size
->text
->value
);
128 for (compo
= (ppdcOption
*)composite
->options
->first(); compo
;
129 compo
= (ppdcOption
*)composite
->options
->next())
130 if ((o
= d
->find_option(compo
->name
->value
)) != NULL
)
132 printf("<td nowrap>");
133 for (c
= (ppdcChoice
*)o
->choices
->first(); c
;
134 c
= (ppdcChoice
*)o
->choices
->next())
135 printf("%s<br>", c
->text
->value
);
139 printf("<td>N/A</td>");
144 puts("</tbody></table></p>");
148 // Delete the printer driver information...
149 composite
->release();
153 // If no drivers have been loaded, display the program usage message.
159 // Return with no errors.
165 // 'usage()' - Show usage and exit.
171 _cupsLangPuts(stdout
, _("Usage: ppdhtml [options] filename.drv "
173 _cupsLangPuts(stdout
, _("Options:"));
174 _cupsLangPuts(stdout
, _(" -D name=value Set named variable to "
176 _cupsLangPuts(stdout
, _(" -I include-dir Add include directory "