]>
git.ipfire.org Git - thirdparty/cups.git/blob - ppdc/ppdhtml.cxx
4 // PPD to HTML utility 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 to HTML utility.
18 // usage() - Show usage and exit.
22 // Include necessary headers...
27 #include <sys/types.h>
34 static void usage(void);
38 // 'main()' - Main entry for the PPD compiler.
41 int // O - Exit status
42 main(int argc
, // I - Number of command-line arguments
43 char *argv
[]) // I - Command-line arguments
46 ppdcSource
*src
; // PPD source file data
47 ppdcDriver
*d
; // Current driver
48 ppdcGroup
*g
, // Current group
49 *composite
; // Composite of all drivers
50 ppdcOption
*o
, // Current option
51 *compo
; // Composite option
52 ppdcChoice
*c
; // Current choice
53 char *opt
; // Current option char
54 ppdcMediaSize
*size
; // Current media size
57 // Scan the command-line...
60 for (i
= 1; i
< argc
; i
++)
61 if (argv
[i
][0] == '-')
63 for (opt
= argv
[i
] + 1; *opt
; opt
++)
66 case 'I' : // Include directory...
71 ppdcSource::add_include(argv
[i
]);
81 // Open and load the driver info file...
82 src
= new ppdcSource(argv
[i
]);
84 // Create a composite group with all of the features from the
85 // drivers in the info file...
86 composite
= new ppdcGroup("", "");
88 for (d
= (ppdcDriver
*)src
->drivers
->first(); d
; d
= (ppdcDriver
*)src
->drivers
->next())
89 for (g
= (ppdcGroup
*)d
->groups
->first(); g
; g
= (ppdcGroup
*)d
->groups
->next())
90 for (o
= (ppdcOption
*)g
->options
->first(); o
; o
= (ppdcOption
*)g
->options
->next())
92 if ((compo
= composite
->find_option(o
->name
->value
)) == NULL
)
93 composite
->add_option(new ppdcOption(o
));
97 printf("<head><title>Driver Summary for %s</title></head>\n", argv
[i
]);
98 printf("<body><h1>Driver Summary for %s</h1>\n", argv
[i
]);
99 printf("<p><table border='1'><thead><tr><th>Printer</th><th>Media Size</th>");
100 for (compo
= (ppdcOption
*)composite
->options
->first(); compo
; compo
= (ppdcOption
*)composite
->options
->next())
101 printf("<th>%s</th>", compo
->text
->value
);
102 puts("</tr></thead><tbody>");
104 // Write HTML summary...
105 for (d
= (ppdcDriver
*)src
->drivers
->first(); d
; d
= (ppdcDriver
*)src
->drivers
->next())
107 // Write the summary for this driver...
108 printf("<tr valign='top'><td nowrap>%s</td><td nowrap>", d
->model_name
->value
);
109 for (size
= (ppdcMediaSize
*)d
->sizes
->first(); size
;
110 size
= (ppdcMediaSize
*)d
->sizes
->next())
111 printf("%s<br>", size
->text
->value
);
114 for (compo
= (ppdcOption
*)composite
->options
->first(); compo
;
115 compo
= (ppdcOption
*)composite
->options
->next())
116 if ((o
= d
->find_option(compo
->name
->value
)) != NULL
)
118 printf("<td nowrap>");
119 for (c
= (ppdcChoice
*)o
->choices
->first(); c
;
120 c
= (ppdcChoice
*)o
->choices
->next())
121 printf("%s<br>", c
->text
->value
);
125 printf("<td>N/A</td>");
130 puts("</tbody></table></p>");
133 // Delete the printer driver information...
138 // If no drivers have been loaded, display the program usage message.
142 // Return with no errors.
148 // 'usage()' - Show usage and exit.
154 puts("Usage: ppdhtml [options] filename.drv >filename.html");
156 puts(" -I include-dir Add include directory to search path.");