]> git.ipfire.org Git - thirdparty/cups.git/blob - cgi-bin/testtemplate.c
Remove svn:keywords since they cause svn_load_dirs.pl to complain about every file.
[thirdparty/cups.git] / cgi-bin / testtemplate.c
1 /*
2 * "$Id: testtemplate.c 177 2006-06-21 00:20:03Z jlovell $"
3 *
4 * CGI template test program for the Common UNIX Printing System (CUPS).
5 *
6 * Copyright 2006 by Easy Software Products.
7 *
8 * These coded instructions, statements, and computer programs are the
9 * property of Easy Software Products and are protected by Federal
10 * copyright law. Distribution and use rights are outlined in the file
11 * "LICENSE.txt" which should have been included with this file. If this
12 * file is missing or damaged please contact Easy Software Products
13 * at:
14 *
15 * Attn: CUPS Licensing Information
16 * Easy Software Products
17 * 44141 Airport View Drive, Suite 204
18 * Hollywood, Maryland 20636 USA
19 *
20 * Voice: (301) 373-9600
21 * EMail: cups-info@cups.org
22 * WWW: http://www.cups.org
23 *
24 * Contents:
25 *
26 * main() - Test the template code.
27 */
28
29 /*
30 * Include necessary headers...
31 */
32
33 #include "cgi.h"
34
35
36 /*
37 * 'main()' - Test the template code.
38 */
39
40 int /* O - Exit status */
41 main(int argc, /* I - Number of command-line arguments */
42 char *argv[]) /* I - Command-line arguments */
43 {
44 int i; /* Looping var */
45 char *value; /* Value in name=value */
46 FILE *out; /* Where to send output */
47
48
49 /*
50 * Don't buffer stdout or stderr so that the mixed output is sane...
51 */
52
53 setbuf(stdout, NULL);
54 setbuf(stderr, NULL);
55
56 /*
57 * Loop through the command-line, assigning variables for any args with
58 * "name=value"...
59 */
60
61 out = stdout;
62
63 for (i = 1; i < argc; i ++)
64 {
65 if (!strcmp(argv[i], "-o"))
66 {
67 i ++;
68 if (i < argc)
69 {
70 out = fopen(argv[i], "w");
71 if (!out)
72 {
73 perror(argv[i]);
74 return (1);
75 }
76 }
77 }
78 else if (!strcmp(argv[i], "-e"))
79 {
80 i ++;
81
82 if (i < argc)
83 {
84 if (!freopen(argv[i], "w", stderr))
85 {
86 perror(argv[i]);
87 return (1);
88 }
89 }
90 }
91 else if (!strcmp(argv[i], "-q"))
92 freopen("/dev/null", "w", stderr);
93 else if ((value = strchr(argv[i], '=')) != NULL)
94 {
95 *value++ = '\0';
96 cgiSetVariable(argv[i], value);
97 }
98 else
99 cgiCopyTemplateFile(out, argv[i]);
100 }
101
102 /*
103 * Return with no errors...
104 */
105
106 return (0);
107 }
108
109
110 /*
111 * End of "$Id: testtemplate.c 177 2006-06-21 00:20:03Z jlovell $".
112 */