/*1* CGI template test program for CUPS.2*3* Copyright 2007-2011 by Apple Inc.4* Copyright 2006 by Easy Software Products.5*6* Licensed under Apache License v2.0. See the file "LICENSE" for more information.7*/89/*10* Include necessary headers...11*/1213#include "cgi.h"141516/*17* 'main()' - Test the template code.18*/1920int /* O - Exit status */21main(int argc, /* I - Number of command-line arguments */22char *argv[]) /* I - Command-line arguments */23{24int i; /* Looping var */25char *value; /* Value in name=value */26FILE *out; /* Where to send output */272829/*30* Don't buffer stdout or stderr so that the mixed output is sane...31*/3233setbuf(stdout, NULL);34setbuf(stderr, NULL);3536/*37* Loop through the command-line, assigning variables for any args with38* "name=value"...39*/4041out = stdout;4243for (i = 1; i < argc; i ++)44{45if (!strcmp(argv[i], "-o"))46{47i ++;48if (i < argc)49{50out = fopen(argv[i], "w");51if (!out)52{53perror(argv[i]);54return (1);55}56}57}58else if (!strcmp(argv[i], "-e"))59{60i ++;6162if (i < argc)63{64if (!freopen(argv[i], "w", stderr))65{66perror(argv[i]);67return (1);68}69}70}71else if (!strcmp(argv[i], "-q"))72freopen("/dev/null", "w", stderr);73else if ((value = strchr(argv[i], '=')) != NULL)74{75*value++ = '\0';76cgiSetVariable(argv[i], value);77}78else79cgiCopyTemplateFile(out, argv[i]);80}8182/*83* Return with no errors...84*/8586return (0);87}888990