Purpose of _LIBC in resolv/ ?

Petr Spacek pspacek@redhat.com
Tue Jun 3 07:46:00 GMT 2014


Hello list,

Could somebody explain to me what is the purpose of #ifdef _LIBC in resolv/ ?

1) Why resolver should behave differently when it is compiled into libc and 
into application?

2) It seems that code in resolv/ directory cannot be compiled without _LIBC at 
least from 2008-12-03 (commit 6f5c3117). I hope I read the code correctly:

int
__res_vinit(res_state statp, int preinit) {
         FILE *fp;
         char *cp, **pp;
         int n;
         char buf[BUFSIZ];
         int nserv = 0;    /* number of nameserver records read from file */
#ifdef _LIBC
         int nservall = 0; /* number of NS records read, nserv IPv4 only */
#endif
// snip
#ifdef _LIBC
                 if (MATCH(buf, "nameserver") && nservall < MAXNS) {
#else
                 if (MATCH(buf, "nameserver") && nserv < MAXNS) {
#endif
                     struct in_addr a;

                     cp = buf + sizeof("nameserver") - 1;
                     while (*cp == ' ' || *cp == '\t')
                         cp++;
                     if ((*cp != '\0') && (*cp != '\n')
                         && __inet_aton(cp, &a)) {
// the problem is that nservall is not declared without _LIBC
                         statp->nsaddr_list[nservall].sin_addr = a;
                         statp->nsaddr_list[nservall].sin_family = AF_INET;
                         statp->nsaddr_list[nservall].sin_port =
                                 htons(NAMESERVER_PORT);
                         nserv++;
#ifdef _LIBC
                         nservall++;
                     } else {
// snip


I'm going to write a patch for DNSSEC support. Can I remove this _LIBC magic 
as the first step, before I dive into DNSSEC?

Please explain me the purpose of this if it has to stay there.

Thank you for your time!

-- 
Petr Spacek  @  Red Hat



More information about the Libc-alpha mailing list