Revert manifest to default one
[external/cups.git] / cgi-bin / testtemplate.c
1 /*
2  * "$Id: testtemplate.c 9771 2011-05-12 05:21:56Z mike $"
3  *
4  *   CGI template test program for CUPS.
5  *
6  *   Copyright 2007-2011 by Apple Inc.
7  *   Copyright 2006 by Easy Software Products.
8  *
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/".
14  *
15  * Contents:
16  *
17  *   main() - Test the template code.
18  */
19
20 /*
21  * Include necessary headers...
22  */
23
24 #include "cgi.h"
25
26
27 /*
28  * 'main()' - Test the template code.
29  */
30
31 int                                     /* O - Exit status */
32 main(int  argc,                         /* I - Number of command-line arguments */
33      char *argv[])                      /* I - Command-line arguments */
34 {
35   int   i;                              /* Looping var */
36   char  *value;                         /* Value in name=value */
37   FILE  *out;                           /* Where to send output */
38
39
40  /*
41   * Don't buffer stdout or stderr so that the mixed output is sane...
42   */
43
44   setbuf(stdout, NULL);
45   setbuf(stderr, NULL);
46
47  /*
48   * Loop through the command-line, assigning variables for any args with
49   * "name=value"...
50   */
51
52   out = stdout;
53
54   for (i = 1; i < argc; i ++)
55   {
56     if (!strcmp(argv[i], "-o"))
57     {
58       i ++;
59       if (i < argc)
60       {
61         out = fopen(argv[i], "w");
62         if (!out)
63         {
64           perror(argv[i]);
65           return (1);
66         }
67       }
68     }
69     else if (!strcmp(argv[i], "-e"))
70     {
71       i ++;
72
73       if (i < argc)
74       {
75         if (!freopen(argv[i], "w", stderr))
76         {
77           perror(argv[i]);
78           return (1);
79         }
80       }
81     }
82     else if (!strcmp(argv[i], "-q"))
83       freopen("/dev/null", "w", stderr);
84     else if ((value = strchr(argv[i], '=')) != NULL)
85     {
86       *value++ = '\0';
87       cgiSetVariable(argv[i], value);
88     }
89     else
90       cgiCopyTemplateFile(out, argv[i]);
91   }
92
93  /*
94   * Return with no errors...
95   */
96
97   return (0);
98 }
99
100
101 /*
102  * End of "$Id: testtemplate.c 9771 2011-05-12 05:21:56Z mike $".
103  */