LCOV - code coverage report
Current view: top level - waltz/resolv - fd_netdb.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 0 12 0.0 %
Date: 2025-07-01 05:00:49 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_waltz_resolv_fd_netdb_h
       2             : #define HEADER_fd_src_waltz_resolv_fd_netdb_h
       3             : 
       4             : #include "../../util/fd_util_base.h"
       5             : 
       6             : typedef struct fd_addrinfo fd_addrinfo_t;
       7             : struct fd_addrinfo {
       8             :   int               ai_flags;
       9             :   int               ai_family;
      10             :   int               ai_protocol;
      11             :   uint              ai_addrlen;
      12             :   struct sockaddr * ai_addr;
      13             :   char *            ai_canonname;
      14             :   fd_addrinfo_t *   ai_next;
      15             : };
      16             : 
      17           0 : #define FD_AI_PASSIVE      0x01
      18           0 : #define FD_AI_NUMERICHOST  0x04
      19           0 : #define FD_AI_V4MAPPED     0x08
      20           0 : #define FD_AI_ALL          0x10
      21             : 
      22           0 : #define FD_EAI_BADFLAGS   -1
      23           0 : #define FD_EAI_NONAME     -2
      24           0 : #define FD_EAI_AGAIN      -3
      25           0 : #define FD_EAI_FAIL       -4
      26           0 : #define FD_EAI_NODATA     -5
      27           0 : #define FD_EAI_FAMILY     -6
      28           0 : #define FD_EAI_MEMORY     -10
      29           0 : #define FD_EAI_SYSTEM     -1000
      30             : 
      31             : struct fd_netdb_fds {
      32             :   int etc_hosts;
      33             :   int etc_resolv_conf;
      34             : };
      35             : 
      36             : typedef struct fd_netdb_fds fd_netdb_fds_t;
      37             : 
      38             : FD_PROTOTYPES_BEGIN
      39             : 
      40             : /* fd_netdb_open opens the /etc/hosts and /etc/resolv.conf file
      41             :    descriptors, and registers them globally.  This avoids open(2)
      42             :    syscalls when running fd_getaddrinfo.  Terminates app if
      43             :    open(/etc/resolv.conf) fails, and logs warning if open(/etc/hosts)
      44             :    fails.  Thread-local. */
      45             : 
      46             : fd_netdb_fds_t *
      47             : fd_netdb_open_fds( fd_netdb_fds_t * fds );
      48             : 
      49             : /* fd_getaddrinfo is derived from musl libc getaddrinfo. */
      50             : 
      51             : int
      52             : fd_getaddrinfo( char const * restrict          node,
      53             :                 fd_addrinfo_t const * restrict hints,
      54             :                 fd_addrinfo_t **  restrict     res,
      55             :                 void **                        out_mem,
      56             :                 ulong                          out_max );
      57             : 
      58             : /* fd_gai_strerror returns a static lifetime cstr describing a return
      59             :    value of fd_getaddrinfo. */
      60             : 
      61             : char const *
      62             : fd_gai_strerror( int );
      63             : 
      64             : FD_PROTOTYPES_END
      65             : 
      66             : #endif /* HEADER_fd_src_waltz_resolv_fd_netdb_h */

Generated by: LCOV version 1.14