| 21 | */ |
| 22 | |
| 23 | int /* O - Exit status */ |
| 24 | main(int argc, /* I - Number of command-line arguments */ |
| 25 | char *argv[]) /* I - Command-line arguments */ |
| 26 | { |
| 27 | int i; /* Looping var */ |
| 28 | char *value; /* Value in name=value */ |
| 29 | FILE *out; /* Where to send output */ |
| 30 | |
| 31 | |
| 32 | /* |
| 33 | * Don't buffer stdout or stderr so that the mixed output is sane... |
| 34 | */ |
| 35 | |
| 36 | setbuf(stdout, NULL); |
| 37 | setbuf(stderr, NULL); |
| 38 | |
| 39 | /* |
| 40 | * Loop through the command-line, assigning variables for any args with |
| 41 | * "name=value"... |
| 42 | */ |
| 43 | |
| 44 | out = stdout; |
| 45 | |
| 46 | for (i = 1; i < argc; i ++) |
| 47 | { |
| 48 | if (!strcmp(argv[i], "-o")) |
| 49 | { |
| 50 | i ++; |
| 51 | if (i < argc) |
| 52 | { |
| 53 | out = fopen(argv[i], "w"); |
| 54 | if (!out) |
| 55 | { |
| 56 | perror(argv[i]); |
| 57 | return (1); |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | else if (!strcmp(argv[i], "-e")) |
| 62 | { |
| 63 | i ++; |
| 64 | |
| 65 | if (i < argc) |
| 66 | { |
| 67 | if (!freopen(argv[i], "w", stderr)) |
| 68 | { |
| 69 | perror(argv[i]); |
| 70 | return (1); |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | else if (!strcmp(argv[i], "-q")) |
| 75 | freopen("/dev/null", "w", stderr); |
| 76 | else if ((value = strchr(argv[i], '=')) != NULL) |
| 77 | { |
| 78 | *value++ = '\0'; |
| 79 | cgiSetVariable(argv[i], value); |
| 80 | } |
nothing calls this directly
no test coverage detected