| 2272 | */ |
| 2273 | |
| 2274 | static void |
| 2275 | do_set_allowed_users(http_t *http) /* I - HTTP connection */ |
| 2276 | { |
| 2277 | int i; /* Looping var */ |
| 2278 | ipp_t *request, /* IPP request */ |
| 2279 | *response; /* IPP response */ |
| 2280 | char uri[HTTP_MAX_URI]; /* Printer URI */ |
| 2281 | const char *printer, /* Printer name */ |
| 2282 | *is_class, /* Is a class? */ |
| 2283 | *users, /* List of users or groups */ |
| 2284 | *type; /* Allow/deny type */ |
| 2285 | int num_users; /* Number of users */ |
| 2286 | char *ptr, /* Pointer into users string */ |
| 2287 | *end, /* Pointer to end of users string */ |
| 2288 | quote; /* Quote character */ |
| 2289 | ipp_attribute_t *attr; /* Attribute */ |
| 2290 | static const char * const attrs[] = /* Requested attributes */ |
| 2291 | { |
| 2292 | "requesting-user-name-allowed", |
| 2293 | "requesting-user-name-denied" |
| 2294 | }; |
| 2295 | |
| 2296 | |
| 2297 | is_class = cgiGetVariable("IS_CLASS"); |
| 2298 | printer = cgiGetTextfield("PRINTER_NAME"); |
| 2299 | |
| 2300 | if (!printer) |
| 2301 | { |
| 2302 | cgiSetVariable("ERROR", cgiText(_("Missing form variable"))); |
| 2303 | cgiStartHTML(cgiText(_("Set Allowed Users"))); |
| 2304 | cgiCopyTemplateLang("error.tmpl"); |
| 2305 | cgiEndHTML(); |
| 2306 | return; |
| 2307 | } |
| 2308 | |
| 2309 | users = cgiGetTextfield("users"); |
| 2310 | type = cgiGetVariable("type"); |
| 2311 | |
| 2312 | if (!users || !type || |
| 2313 | (strcmp(type, "requesting-user-name-allowed") && |
| 2314 | strcmp(type, "requesting-user-name-denied"))) |
| 2315 | { |
| 2316 | /* |
| 2317 | * Build a Get-Printer-Attributes request, which requires the following |
| 2318 | * attributes: |
| 2319 | * |
| 2320 | * attributes-charset |
| 2321 | * attributes-natural-language |
| 2322 | * printer-uri |
| 2323 | * requested-attributes |
| 2324 | */ |
| 2325 | |
| 2326 | request = ippNewRequest(IPP_GET_PRINTER_ATTRIBUTES); |
| 2327 | |
| 2328 | httpAssembleURIf(HTTP_URI_CODING_ALL, uri, sizeof(uri), "ipp", NULL, |
| 2329 | "localhost", 0, is_class ? "/classes/%s" : "/printers/%s", |
| 2330 | printer); |
| 2331 | ippAddString(request, IPP_TAG_OPERATION, IPP_TAG_URI, "printer-uri", |
no test coverage detected