#include "ppdc-private.h"
#include <sys/stat.h>
#include <sys/types.h>
static void usage(void);
int main(int argc, char *argv[]) {
int i; ppdcSource *src; ppdcDriver *d; ppdcGroup *g, *composite; ppdcOption *o, *compo; ppdcChoice *c; char *opt; ppdcMediaSize *size; char *value;
_cupsSetLocale(argv);
src = 0;
for (i = 1; i < argc; i ++)
if (argv[i][0] == '-')
{
for (opt = argv[i] + 1; *opt; opt ++)
switch (*opt)
{
case 'D' : i ++;
if (i >= argc)
usage();
if ((value = strchr(argv[i], '=')) != NULL)
{
*value++ = '\0';
src->set_variable(argv[i], value);
}
else
src->set_variable(argv[i], "1");
break;
case 'I' : i ++;
if (i >= argc)
usage();
ppdcSource::add_include(argv[i]);
break;
default : usage();
break;
}
}
else
{
src = new ppdcSource(argv[i]);
composite = new ppdcGroup("", "");
for (d = (ppdcDriver *)src->drivers->first(); d; d = (ppdcDriver *)src->drivers->next())
for (g = (ppdcGroup *)d->groups->first(); g; g = (ppdcGroup *)d->groups->next())
for (o = (ppdcOption *)g->options->first(); o; o = (ppdcOption *)g->options->next())
{
if ((compo = composite->find_option(o->name->value)) == NULL)
composite->add_option(new ppdcOption(o));
}
puts("<html>");
printf("<head><title>Driver Summary for %s</title></head>\n", argv[i]);
printf("<body><h1>Driver Summary for %s</h1>\n", argv[i]);
printf("<p><table border='1'><thead><tr><th>Printer</th><th>Media Size</th>");
for (compo = (ppdcOption *)composite->options->first(); compo; compo = (ppdcOption *)composite->options->next())
printf("<th>%s</th>", compo->text->value);
puts("</tr></thead><tbody>");
for (d = (ppdcDriver *)src->drivers->first(); d; d = (ppdcDriver *)src->drivers->next())
{
printf("<tr valign='top'><td nowrap>%s</td><td nowrap>", d->model_name->value);
for (size = (ppdcMediaSize *)d->sizes->first(); size;
size = (ppdcMediaSize *)d->sizes->next())
printf("%s<br>", size->text->value);
printf("</td>");
for (compo = (ppdcOption *)composite->options->first(); compo;
compo = (ppdcOption *)composite->options->next())
if ((o = d->find_option(compo->name->value)) != NULL)
{
printf("<td nowrap>");
for (c = (ppdcChoice *)o->choices->first(); c;
c = (ppdcChoice *)o->choices->next())
printf("%s<br>", c->text->value);
printf("</td>");
}
else
printf("<td>N/A</td>");
puts("</tr>");
}
puts("</tbody></table></p>");
puts("</body>");
puts("</html>");
composite->release();
src->release();
}
if (!src)
usage();
return (0);
}
static void
usage(void)
{
_cupsLangPuts(stdout, _("Usage: ppdhtml [options] filename.drv "
">filename.html"));
_cupsLangPuts(stdout, _("Options:"));
_cupsLangPuts(stdout, _(" -D name=value Set named variable to "
"value."));
_cupsLangPuts(stdout, _(" -I include-dir Add include directory "
"to search path."));
exit(1);
}