From mboxrd@z Thu Jan 1 00:00:00 1970 From: hjl@valinux.com (H.J. Lu) To: libc-hacker@sourceware.cygnus.com (GNU C Library) Subject: A patch for libresolv Date: Tue, 05 Oct 1999 18:27:00 -0000 Message-id: <19991006012700.3C0933FC1@valinux.com> X-SW-Source: 1999-10/msg00008.html Hi, There are many options in libresolve. However, there are no codes to set them. Here is a patch to handle options for libresolve. -- H.J. Lu (hjl@gnu.org) -- Tue Oct 5 18:23:01 1999 H.J. Lu * resolv/res_init.c (o_mnemonic): New. (res_setoptions): Use it. Index: resolv/res_init.c =================================================================== RCS file: /work/cvs/gnu/glibc-2.1/resolv/res_init.c,v retrieving revision 1.1.1.9 diff -u -p -r1.1.1.9 res_init.c --- resolv/res_init.c 1999/05/05 01:35:31 1.1.1.9 +++ resolv/res_init.c 1999/10/06 01:21:05 @@ -111,6 +111,7 @@ static int netinfo_res_init __P((int *ha #endif static void res_setoptions __P((char *, char *)) internal_function; +static u_long o_mnemonic __P((const char * mnemonic)) internal_function; #ifdef RESOLVSORT static const char sort_mask[] = "/&"; @@ -427,12 +428,66 @@ res_init() return (0); } +/* + * Return an option from a mnemonic. + */ +static u_long +internal_function +o_mnemonic (mnemonic) + const char * mnemonic; +{ + if (strncasecmp (mnemonic, "init", sizeof ("init") - 1) == 0) + return RES_INIT; + else if (strncasecmp (mnemonic, "debug", + sizeof ("debug") - 1) == 0) + return RES_DEBUG; + else if (strncasecmp (mnemonic, "aaonly", + sizeof ("aaonly") - 1) == 0) + return RES_AAONLY; + else if (strncasecmp (mnemonic, "usevc", + sizeof ("usevc") - 1) == 0) + return RES_USEVC; + else if (strncasecmp (mnemonic, "primry", + sizeof ("primry") - 1) == 0) + return RES_PRIMARY; + else if (strncasecmp (mnemonic, "igntc", + sizeof ("igntc") - 1) == 0) + return RES_IGNTC; + else if (strncasecmp (mnemonic, "recurs", + sizeof ("recurs") - 1) == 0) + return RES_RECURSE; + else if (strncasecmp (mnemonic, "defnam", + sizeof ("defnam") - 1) == 0) + return RES_DEFNAMES; + else if (strncasecmp (mnemonic, "styopn", + sizeof ("styopn") - 1) == 0) + return RES_STAYOPEN; + else if (strncasecmp (mnemonic, "dnsrch", + sizeof ("dnsrch") - 1) == 0) + return RES_DNSRCH; + else if (strncasecmp (mnemonic, "insecure1", + sizeof ("insecure1") - 1) == 0) + return RES_INSECURE1; + else if (strncasecmp (mnemonic, "insecure2", + sizeof ("insecure2") - 1) == 0) + return RES_INSECURE2; + else if (strncasecmp (mnemonic, "noaliases", + sizeof ("noaliases") - 1) == 0) + return RES_NOALIASES; + else if (strncasecmp (mnemonic, "inet6", + sizeof ("inet6") - 1) == 0) + return RES_USE_INET6; + else + return ~0; +} + static void internal_function res_setoptions(options, source) char *options, *source; { char *cp = options; + u_long option; int i; #ifdef DEBUG @@ -464,8 +519,8 @@ res_setoptions(options, source) } printf(";;\tdebug\n"); #endif - } else if (!strncmp(cp, "inet6", sizeof("inet6") - 1)) { - _res.options |= RES_USE_INET6; + } else if ((option = o_mnemonic (cp)) != ~0) { + _res.options |= option; } else { /* XXX - print a warning here? */ }