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

Function httpAddrLookup

cups/http-addr.c:322–438  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320 */
321
322char * /* O - Host name */
323httpAddrLookup(
324 const http_addr_t *addr, /* I - Address to lookup */
325 char *name, /* I - Host name buffer */
326 int namelen) /* I - Size of name buffer */
327{
328 _cups_globals_t *cg = _cupsGlobals();
329 /* Global data */
330
331
332 DEBUG_printf(("httpAddrLookup(addr=%p, name=%p, namelen=%d)", (void *)addr, (void *)name, namelen));
333
334 /*
335 * Range check input...
336 */
337
338 if (!addr || !name || namelen <= 2)
339 {
340 if (name && namelen >= 1)
341 *name = '\0';
342
343 return (NULL);
344 }
345
346#ifdef AF_LOCAL
347 if (addr->addr.sa_family == AF_LOCAL)
348 {
349 strlcpy(name, addr->un.sun_path, (size_t)namelen);
350 return (name);
351 }
352#endif /* AF_LOCAL */
353
354 /*
355 * Optimize lookups for localhost/loopback addresses...
356 */
357
358 if (httpAddrLocalhost(addr))
359 {
360 strlcpy(name, "localhost", (size_t)namelen);
361 return (name);
362 }
363
364#ifdef HAVE_RES_INIT
365 /*
366 * STR #2920: Initialize resolver after failure in cups-polld
367 *
368 * If the previous lookup failed, re-initialize the resolver to prevent
369 * temporary network errors from persisting. This *should* be handled by
370 * the resolver libraries, but apparently the glibc folks do not agree.
371 *
372 * We set a flag at the end of this function if we encounter an error that
373 * requires reinitialization of the resolver functions. We then call
374 * res_init() if the flag is set on the next call here or in httpAddrLookup().
375 */
376
377 if (cg->need_res_init)
378 {
379 res_init();

Callers 9

cupsdNetIFUpdateFunction · 0.85
cupsdAcceptClientFunction · 0.85
mainFunction · 0.85
read_snmp_responseFunction · 0.85
_httpTLSStartFunction · 0.85
httpResolveHostnameFunction · 0.85
_httpTLSStartFunction · 0.85
_httpTLSStartFunction · 0.85
_httpTLSStartFunction · 0.85

Calls 4

_cupsGlobalsFunction · 0.85
httpAddrLocalhostFunction · 0.85
httpAddrLengthFunction · 0.85
httpAddrStringFunction · 0.85

Tested by

no test coverage detected