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

Function get_string

tools/ipptool.c:2569–2640  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2567 */
2568
2569static const char * /* O - Pointer to string */
2570get_string(ipp_attribute_t *attr, /* I - IPP attribute */
2571 int element, /* I - Element to fetch */
2572 int flags, /* I - Value ("with") flags */
2573 char *buffer, /* I - Temporary buffer */
2574 size_t bufsize) /* I - Size of temporary buffer */
2575{
2576 const char *value; /* Value */
2577 char *ptr, /* Pointer into value */
2578 scheme[256], /* URI scheme */
2579 userpass[256], /* Username/password */
2580 hostname[256], /* Hostname */
2581 resource[1024]; /* Resource */
2582 int port; /* Port number */
2583
2584
2585 value = ippGetString(attr, element, NULL);
2586
2587 if (flags & IPPTOOL_WITH_HOSTNAME)
2588 {
2589 if (httpSeparateURI(HTTP_URI_CODING_ALL, value, scheme, sizeof(scheme), userpass, sizeof(userpass), buffer, (int)bufsize, &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
2590 buffer[0] = '\0';
2591
2592 ptr = buffer + strlen(buffer) - 1;
2593 if (ptr >= buffer && *ptr == '.')
2594 *ptr = '\0'; /* Drop trailing "." */
2595
2596 return (buffer);
2597 }
2598 else if (flags & IPPTOOL_WITH_RESOURCE)
2599 {
2600 if (httpSeparateURI(HTTP_URI_CODING_ALL, value, scheme, sizeof(scheme), userpass, sizeof(userpass), hostname, sizeof(hostname), &port, buffer, (int)bufsize) < HTTP_URI_STATUS_OK)
2601 buffer[0] = '\0';
2602
2603 return (buffer);
2604 }
2605 else if (flags & IPPTOOL_WITH_SCHEME)
2606 {
2607 if (httpSeparateURI(HTTP_URI_CODING_ALL, value, buffer, (int)bufsize, userpass, sizeof(userpass), hostname, sizeof(hostname), &port, resource, sizeof(resource)) < HTTP_URI_STATUS_OK)
2608 buffer[0] = '\0';
2609
2610 return (buffer);
2611 }
2612 else if (ippGetValueTag(attr) == IPP_TAG_URI && (!strncmp(value, "ipp://", 6) || !strncmp(value, "http://", 7) || !strncmp(value, "ipps://", 7) || !strncmp(value, "https://", 8)))
2613 {
2614 http_uri_status_t status = httpSeparateURI(HTTP_URI_CODING_ALL, value, scheme, sizeof(scheme), userpass, sizeof(userpass), hostname, sizeof(hostname), &port, resource, sizeof(resource));
2615
2616 if (status < HTTP_URI_STATUS_OK)
2617 {
2618 /*
2619 * Bad URI...
2620 */
2621
2622 buffer[0] = '\0';
2623 }
2624 else
2625 {
2626 /*

Callers 1

with_valueFunction · 0.85

Calls 4

ippGetStringFunction · 0.85
httpSeparateURIFunction · 0.85
ippGetValueTagFunction · 0.85
httpAssembleURIFunction · 0.85

Tested by

no test coverage detected