| 53 | */ |
| 54 | |
| 55 | int /* O - Exit status */ |
| 56 | main(void) |
| 57 | { |
| 58 | http_t *http; /* Connection to the server */ |
| 59 | const char *op; /* Operation name */ |
| 60 | |
| 61 | |
| 62 | /* |
| 63 | * Connect to the HTTP server... |
| 64 | */ |
| 65 | |
| 66 | fputs("DEBUG: admin.cgi started...\n", stderr); |
| 67 | |
| 68 | http = httpConnectEncrypt(cupsServer(), ippPort(), cupsEncryption()); |
| 69 | |
| 70 | if (!http) |
| 71 | { |
| 72 | perror("ERROR: Unable to connect to cupsd"); |
| 73 | fprintf(stderr, "DEBUG: cupsServer()=\"%s\"\n", |
| 74 | cupsServer() ? cupsServer() : "(null)"); |
| 75 | fprintf(stderr, "DEBUG: ippPort()=%d\n", ippPort()); |
| 76 | fprintf(stderr, "DEBUG: cupsEncryption()=%d\n", cupsEncryption()); |
| 77 | exit(1); |
| 78 | } |
| 79 | |
| 80 | fprintf(stderr, "DEBUG: http=%p\n", http); |
| 81 | |
| 82 | /* |
| 83 | * Set the web interface section... |
| 84 | */ |
| 85 | |
| 86 | cgiSetVariable("SECTION", "admin"); |
| 87 | cgiSetVariable("REFRESH_PAGE", ""); |
| 88 | |
| 89 | /* |
| 90 | * See if we have form data... |
| 91 | */ |
| 92 | |
| 93 | if (!cgiInitialize() || !cgiGetVariable("OP")) |
| 94 | { |
| 95 | /* |
| 96 | * Nope, send the administration menu... |
| 97 | */ |
| 98 | |
| 99 | fputs("DEBUG: No form data, showing main menu...\n", stderr); |
| 100 | |
| 101 | do_menu(http); |
| 102 | } |
| 103 | else if ((op = cgiGetVariable("OP")) != NULL && cgiIsPOST()) |
| 104 | { |
| 105 | /* |
| 106 | * Do the operation... |
| 107 | */ |
| 108 | |
| 109 | fprintf(stderr, "DEBUG: op=\"%s\"...\n", op); |
| 110 | |
| 111 | if (!*op) |
| 112 | { |
nothing calls this directly
no test coverage detected