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

Function httpSetAuthString

cups/http.c:2475–2522  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2473 */
2474
2475void
2476httpSetAuthString(http_t *http, /* I - HTTP connection */
2477 const char *scheme, /* I - Auth scheme (NULL to clear it) */
2478 const char *data) /* I - Auth data (NULL for none) */
2479{
2480 /*
2481 * Range check input...
2482 */
2483
2484 if (!http)
2485 return;
2486
2487 if (http->authstring && http->authstring != http->_authstring)
2488 free(http->authstring);
2489
2490 http->authstring = http->_authstring;
2491
2492 if (scheme)
2493 {
2494 /*
2495 * Set the current authorization string...
2496 */
2497
2498 size_t len = strlen(scheme) + (data ? strlen(data) + 1 : 0) + 1;
2499 char *temp;
2500
2501 if (len > sizeof(http->_authstring))
2502 {
2503 if ((temp = malloc(len)) == NULL)
2504 len = sizeof(http->_authstring);
2505 else
2506 http->authstring = temp;
2507 }
2508
2509 if (data)
2510 snprintf(http->authstring, len, "%s %s", scheme, data);
2511 else
2512 strlcpy(http->authstring, scheme, len);
2513 }
2514 else
2515 {
2516 /*
2517 * Clear the current authorization string...
2518 */
2519
2520 http->_authstring[0] = '\0';
2521 }
2522}
2523
2524
2525/*

Callers 5

cupsDoAuthenticationFunction · 0.85
ifFunction · 0.85
cups_local_authFunction · 0.85
cupsDoIORequestFunction · 0.85
_httpSetDigestAuthStringFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected