]>
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...
27 #include <sys/types.h>
28 #include <cups/i18n.h>
35 static void usage(void);
39 // 'main()' - Main entry for the PPD compiler.
42 int // O - Exit status
43 main(int argc
, // I - Number of command-line arguments
44 char *argv
[]) // I - Command-line arguments
47 ppdcSource
*src
; // PPD source file data
48 ppdcDriver
*d
; // Current driver
49 ppdcGroup
*g
, // Current group
50 *composite
; // Composite of all drivers
51 ppdcOption
*o
, // Current option
52 *compo
; // Composite option
53 ppdcChoice
*c
; // Current choice
54 char *opt
; // Current option char
55 ppdcMediaSize
*size
; // Current media size
56 char *value
; // Value in option
61 // Scan the command-line...
64 for (i
= 1; i
< argc
; i
++)
65 if (argv
[i
][0] == '-')
67 for (opt
= argv
[i
] + 1; *opt
; opt
++)
70 case 'D' : // Define variable
75 if ((value
= strchr(argv
[i
], '=')) != NULL
)
79 src
->set_variable(argv
[i
], value
);
82 src
->set_variable(argv
[i
], "1");
85 case 'I' : // Include directory...
90 ppdcSource::add_include(argv
[i
]);
100 // Open and load the driver info file...
101 src
= new ppdcSource(argv
[i
]);
103 // Create a composite group with all of the features from the
104 // drivers in the info file...
105 composite
= new ppdcGroup("", "");
107 for (d
= (ppdcDriver
*)src
->drivers
->first(); d
; d
= (ppdcDriver
*)src
->drivers
->next())
108 for (g
= (ppdcGroup
*)d
->groups
->first(); g
; g
= (ppdcGroup
*)d
->groups
->next())
109 for (o
= (ppdcOption
*)g
->options
->first(); o
; o
= (ppdcOption
*)g
->options
->next())
111 if ((compo
= composite
->find_option(o
->name
->value
)) == NULL
)
112 composite
->add_option(new ppdcOption(o
));
116 printf("<head><title>Driver Summary for %s</title></head>\n", argv
[i
]);
117 printf("<body><h1>Driver Summary for %s</h1>\n", argv
[i
]);
118 printf("<p><table border='1'><thead><tr><th>Printer</th><th>Media Size</th>");
119 for (compo
= (ppdcOption
*)composite
->options
->first(); compo
; compo
= (ppdcOption
*)composite
->options
->next())
120 printf("<th>%s</th>", compo
->text
->value
);
121 puts("</tr></thead><tbody>");
123 // Write HTML summary...
124 for (d
= (ppdcDriver
*)src
->drivers
->first(); d
; d
= (ppdcDriver
*)src
->drivers
->next())
126 // Write the summary for this driver...
127 printf("<tr valign='top'><td nowrap>%s</td><td nowrap>", d
->model_name
->value
);
128 for (size
= (ppdcMediaSize
*)d
->sizes
->first(); size
;
129 size
= (ppdcMediaSize
*)d
->sizes
->next())
130 printf("%s<br>", size
->text
->value
);
133 for (compo
= (ppdcOption
*)composite
->options
->first(); compo
;
134 compo
= (ppdcOption
*)composite
->options
->next())
135 if ((o
= d
->find_option(compo
->name
->value
)) != NULL
)
137 printf("<td nowrap>");
138 for (c
= (ppdcChoice
*)o
->choices
->first(); c
;
139 c
= (ppdcChoice
*)o
->choices
->next())
140 printf("%s<br>", c
->text
->value
);
144 printf("<td>N/A</td>");
149 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.
161 // Return with no errors.
167 // 'usage()' - Show usage and exit.
173 _cupsLangPuts(stdout
,
174 _("Usage: ppdhtml [options] filename.drv >filename.html\n"
175 " -D name=value Set named variable to value.\n"
177 " -I include-dir Add include directory to search "