| 95 | */ |
| 96 | |
| 97 | int /* O - 1 on success, 0 on failure */ |
| 98 | cupsAdminGetServerSettings( |
| 99 | http_t *http, /* I - Connection to server or @code CUPS_HTTP_DEFAULT@ */ |
| 100 | int *num_settings, /* O - Number of settings */ |
| 101 | cups_option_t **settings) /* O - Settings */ |
| 102 | { |
| 103 | int i; /* Looping var */ |
| 104 | cups_file_t *cupsd; /* cupsd.conf file */ |
| 105 | char cupsdconf[1024]; /* cupsd.conf filename */ |
| 106 | int remote; /* Remote cupsd.conf file? */ |
| 107 | http_status_t status; /* Status of getting cupsd.conf */ |
| 108 | char line[1024], /* Line from cupsd.conf file */ |
| 109 | *value; /* Value on line */ |
| 110 | cups_option_t *setting; /* Current setting */ |
| 111 | _cups_globals_t *cg = _cupsGlobals(); /* Global data */ |
| 112 | |
| 113 | |
| 114 | /* |
| 115 | * Range check input... |
| 116 | */ |
| 117 | |
| 118 | if (!http) |
| 119 | { |
| 120 | /* |
| 121 | * See if we are connected to the same server... |
| 122 | */ |
| 123 | |
| 124 | if (cg->http) |
| 125 | { |
| 126 | /* |
| 127 | * Compare the connection hostname, port, and encryption settings to |
| 128 | * the cached defaults; these were initialized the first time we |
| 129 | * connected... |
| 130 | */ |
| 131 | |
| 132 | if (strcmp(cg->http->hostname, cg->server) || |
| 133 | cg->ipp_port != httpAddrPort(cg->http->hostaddr) || |
| 134 | (cg->http->encryption != cg->encryption && |
| 135 | cg->http->encryption == HTTP_ENCRYPTION_NEVER)) |
| 136 | { |
| 137 | /* |
| 138 | * Need to close the current connection because something has changed... |
| 139 | */ |
| 140 | |
| 141 | httpClose(cg->http); |
| 142 | cg->http = NULL; |
| 143 | } |
| 144 | } |
| 145 | |
| 146 | /* |
| 147 | * (Re)connect as needed... |
| 148 | */ |
| 149 | |
| 150 | if (!cg->http) |
| 151 | { |
| 152 | if ((cg->http = httpConnect2(cupsServer(), ippPort(), NULL, AF_UNSPEC, |
| 153 | cupsEncryption(), 1, 0, NULL)) == NULL) |
| 154 | { |