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

Function httpResolveHostname

cups/http-addr.c:909–940  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

907 */
908
909const char * /* O - Resolved hostname or @code NULL@ */
910httpResolveHostname(http_t *http, /* I - HTTP connection */
911 char *buffer, /* I - Hostname buffer */
912 size_t bufsize) /* I - Size of buffer */
913{
914 if (!http)
915 return (NULL);
916
917 if (isdigit(http->hostname[0] & 255) || http->hostname[0] == '[')
918 {
919 char temp[1024]; /* Temporary string */
920
921 if (httpAddrLookup(http->hostaddr, temp, sizeof(temp)))
922 strlcpy(http->hostname, temp, sizeof(http->hostname));
923 else
924 return (NULL);
925 }
926
927 if (buffer)
928 {
929 if (http->hostname[0] == '/')
930 strlcpy(buffer, "localhost", bufsize);
931 else
932 strlcpy(buffer, http->hostname, bufsize);
933
934 return (buffer);
935 }
936 else if (http->hostname[0] == '/')
937 return ("localhost");
938 else
939 return (http->hostname);
940}

Callers 1

cupsdAcceptClientFunction · 0.85

Calls 1

httpAddrLookupFunction · 0.85

Tested by

no test coverage detected