]>
git.ipfire.org Git - thirdparty/cups.git/blob - ppdc/ppdhtml.cxx
4 // PPD to HTML utility for the CUPS PPD Compiler.
6 // Copyright 2007-2008 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...
25 #include "ppdc-private.h"
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
55 char *value
; // Value in option
60 // Scan the command-line...
63 for (i
= 1; i
< argc
; i
++)
64 if (argv
[i
][0] == '-')
66 for (opt
= argv
[i
] + 1; *opt
; opt
++)
69 case 'D' : // Define variable
74 if ((value
= strchr(argv
[i
], '=')) != NULL
)
78 src
->set_variable(argv
[i
], value
);
81 src
->set_variable(argv
[i
], "1");
84 case 'I' : // Include directory...
89 ppdcSource::add_include(argv
[i
]);
99 // Open and load the driver info file...
100 src
= new ppdcSource(argv
[i
]);
102 // Create a composite group with all of the features from the
103 // drivers in the info file...
104 composite
= new ppdcGroup("", "");
106 for (d
= (ppdcDriver
*)src
->drivers
->first(); d
; d
= (ppdcDriver
*)src
->drivers
->next())
107 for (g
= (ppdcGroup
*)d
->groups
->first(); g
; g
= (ppdcGroup
*)d
->groups
->next())
108 for (o
= (ppdcOption
*)g
->options
->first(); o
; o
= (ppdcOption
*)g
->options
->next())
110 if ((compo
= composite
->find_option(o
->name
->value
)) == NULL
)
111 composite
->add_option(new ppdcOption(o
));
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>");
151 // Delete the printer driver information...
152 composite
->release();
156 // If no drivers have been loaded, display the program usage message.
160 // Return with no errors.
166 // 'usage()' - Show usage and exit.
172 _cupsLangPuts(stdout
,
173 _("Usage: ppdhtml [options] filename.drv >filename.html\n"
174 " -D name=value Set named variable to value.\n"
176 " -I include-dir Add include directory to search "