MCPcopy Create free account
hub / github.com/OpenPrinting/cups / do_set_allowed_users

Function do_set_allowed_users

cgi-bin/admin.c:2274–2533  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2272 */
2273
2274static void
2275do_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",

Callers 1

mainFunction · 0.85

Calls 15

cgiGetVariableFunction · 0.85
cgiGetTextfieldFunction · 0.85
cgiSetVariableFunction · 0.85
cgiTextFunction · 0.85
cgiStartHTMLFunction · 0.85
cgiCopyTemplateLangFunction · 0.85
cgiEndHTMLFunction · 0.85
ippNewRequestFunction · 0.85
httpAssembleURIfFunction · 0.85
ippAddStringFunction · 0.85
ippAddStringsFunction · 0.85
cupsDoRequestFunction · 0.85

Tested by

no test coverage detected