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

Function if

cups/http-addr.c:543–643  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

541 }
542#ifdef AF_INET6
543 else if (addr->addr.sa_family == AF_INET6)
544 {
545 char *sptr, /* Pointer into string */
546 temps[64]; /* Temporary string for address */
547
548# ifdef HAVE_GETNAMEINFO
549 if (getnameinfo(&addr->addr, (socklen_t)httpAddrLength(addr), temps, sizeof(temps), NULL, 0, NI_NUMERICHOST))
550 {
551 /*
552 * If we get an error back, then the address type is not supported
553 * and we should zero out the buffer...
554 */
555
556 s[0] = '\0';
557
558 return (NULL);
559 }
560 else if ((sptr = strchr(temps, '%')) != NULL)
561 {
562 /*
563 * Convert "%zone" to "+zone" to match URI form...
564 */
565
566 *sptr = '+';
567 }
568
569# else
570 int i; /* Looping var */
571 unsigned temp; /* Current value */
572 const char *prefix; /* Prefix for address */
573
574
575 prefix = "";
576 for (sptr = temps, i = 0; i < 4 && addr->ipv6.sin6_addr.s6_addr32[i]; i ++)
577 {
578 temp = ntohl(addr->ipv6.sin6_addr.s6_addr32[i]);
579
580 snprintf(sptr, sizeof(temps) - (size_t)(sptr - temps), "%s%x", prefix, (temp >> 16) & 0xffff);
581 prefix = ":";
582 sptr += strlen(sptr);
583
584 temp &= 0xffff;
585
586 if (temp || i == 3 || addr->ipv6.sin6_addr.s6_addr32[i + 1])
587 {
588 snprintf(sptr, sizeof(temps) - (size_t)(sptr - temps), "%s%x", prefix, temp);
589 sptr += strlen(sptr);
590 }
591 }
592
593 if (i < 4)
594 {
595 while (i < 4 && !addr->ipv6.sin6_addr.s6_addr32[i])
596 i ++;
597
598 if (i < 4)
599 {
600 snprintf(sptr, sizeof(temps) - (size_t)(sptr - temps), "%s:", prefix);

Callers

nothing calls this directly

Calls 1

httpAddrLengthFunction · 0.85

Tested by

no test coverage detected