]>
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 // These coded instructions, statements, and computer programs are the
8 // property of Apple Inc. and are protected by Federal copyright
9 // law. Distribution and use rights are outlined in the file "LICENSE.txt"
10 // which should have been included with this file. If this file is
11 // file is missing or damaged, see the license at "http://www.cups.org/".
15 // Include necessary headers...
18 #include "ppdc-private.h"
20 #include <sys/types.h>
27 static void usage(void);
31 // 'main()' - Main entry for the PPD compiler.
34 int // O - Exit status
35 main(int argc
, // I - Number of command-line arguments
36 char *argv
[]) // I - Command-line arguments
39 ppdcSource
*src
; // PPD source file data
40 ppdcDriver
*d
; // Current driver
41 ppdcGroup
*g
, // Current group
42 *composite
; // Composite of all drivers
43 ppdcOption
*o
, // Current option
44 *compo
; // Composite option
45 ppdcChoice
*c
; // Current choice
46 char *opt
; // Current option char
47 ppdcMediaSize
*size
; // Current media size
48 char *value
; // Value in option
53 // Scan the command-line...
54 src
= new ppdcSource();
56 for (i
= 1; i
< argc
; i
++)
57 if (argv
[i
][0] == '-')
59 for (opt
= argv
[i
] + 1; *opt
; opt
++)
62 case 'D' : // Define variable
67 if ((value
= strchr(argv
[i
], '=')) != NULL
)
71 src
->set_variable(argv
[i
], value
);
74 src
->set_variable(argv
[i
], "1");
77 case 'I' : // Include directory...
82 ppdcSource::add_include(argv
[i
]);
92 // Open and load the driver info file...
93 src
->read_file(argv
[i
]);
96 if ((d
= (ppdcDriver
*)src
->drivers
->first()) != NULL
)
98 // Create a composite group with all of the features from the
99 // drivers in the info file...
100 composite
= new ppdcGroup("", "");
104 for (g
= (ppdcGroup
*)d
->groups
->first(); g
; g
= (ppdcGroup
*)d
->groups
->next())
105 for (o
= (ppdcOption
*)g
->options
->first(); o
; o
= (ppdcOption
*)g
->options
->next())
107 if ((compo
= composite
->find_option(o
->name
->value
)) == NULL
)
108 composite
->add_option(new ppdcOption(o
));
111 d
= (ppdcDriver
*)src
->drivers
->next();
115 printf("<head><title>Driver Summary for %s</title></head>\n", argv
[i
]);
116 printf("<body><h1>Driver Summary for %s</h1>\n", argv
[i
]);
117 printf("<p><table border='1'><thead><tr><th>Printer</th><th>Media Size</th>");
118 for (compo
= (ppdcOption
*)composite
->options
->first(); compo
; compo
= (ppdcOption
*)composite
->options
->next())
119 printf("<th>%s</th>", compo
->text
->value
);
120 puts("</tr></thead><tbody>");
122 // Write HTML summary...
123 for (d
= (ppdcDriver
*)src
->drivers
->first(); d
; d
= (ppdcDriver
*)src
->drivers
->next())
125 // Write the summary for this driver...
126 printf("<tr valign='top'><td nowrap>%s</td><td nowrap>", d
->model_name
->value
);
127 for (size
= (ppdcMediaSize
*)d
->sizes
->first(); size
;
128 size
= (ppdcMediaSize
*)d
->sizes
->next())
129 printf("%s<br>", size
->text
->value
);
132 for (compo
= (ppdcOption
*)composite
->options
->first(); compo
;
133 compo
= (ppdcOption
*)composite
->options
->next())
134 if ((o
= d
->find_option(compo
->name
->value
)) != NULL
)
136 printf("<td nowrap>");
137 for (c
= (ppdcChoice
*)o
->choices
->first(); c
;
138 c
= (ppdcChoice
*)o
->choices
->next())
139 printf("%s<br>", c
->text
->value
);
143 printf("<td>N/A</td>");
148 puts("</tbody></table></p>");
152 // Delete the printer driver information...
153 composite
->release();
157 // If no drivers have been loaded, display the program usage message.
163 // Return with no errors.
169 // 'usage()' - Show usage and exit.
175 _cupsLangPuts(stdout
, _("Usage: ppdhtml [options] filename.drv "
177 _cupsLangPuts(stdout
, _("Options:"));
178 _cupsLangPuts(stdout
, _(" -D name=value Set named variable to "
180 _cupsLangPuts(stdout
, _(" -I include-dir Add include directory "