Index: ares_init.c
===================================================================
RCS file: /repository/curl/ares/ares_init.c,v
retrieving revision 1.3
diff -c -r1.3 ares_init.c
*** ares_init.c	4 Feb 2004 07:50:51 -0000	1.3
--- ares_init.c	22 Feb 2004 18:20:03 -0000
***************
*** 44,50 ****
  static int config_domain(ares_channel channel, char *str);
  static int config_lookup(ares_channel channel, const char *str);
  static int config_nameserver(struct server_state **servers, int *nservers,
! 			     const char *str);
  static int config_sortlist(struct apattern **sortlist, int *nsort,
  			   const char *str);
  static int set_search(ares_channel channel, const char *str);
--- 44,50 ----
  static int config_domain(ares_channel channel, char *str);
  static int config_lookup(ares_channel channel, const char *str);
  static int config_nameserver(struct server_state **servers, int *nservers,
! 			     char *str);
  static int config_sortlist(struct apattern **sortlist, int *nsort,
  			   const char *str);
  static int set_search(ares_channel channel, const char *str);
***************
*** 284,292 ****
  
  static int init_by_resolv_conf(ares_channel channel)
  {
!   FILE *fp;
!   char *line = NULL, *p;
!   int linesize, status, nservers = 0, nsort = 0;
    struct server_state *servers = NULL;
    struct apattern *sortlist = NULL;
  
--- 284,291 ----
  
  static int init_by_resolv_conf(ares_channel channel)
  {
!   char *line = NULL;
!   int status, nservers = 0, nsort = 0;
    struct server_state *servers = NULL;
    struct apattern *sortlist = NULL;
  
***************
*** 315,322 ****
    DWORD data_type;
    DWORD bytes;
    DWORD result;
-   DWORD index;
-   char name[MAX_PATH];
    DWORD keysize = MAX_PATH;
  
    status = ARES_EFILE;
--- 314,319 ----
***************
*** 421,426 ****
--- 418,426 ----
    }
  
  #else
+   char *p;
+   FILE *fp;
+   int linesize;
  
    fp = fopen(PATH_RESOLV_CONF, "r");
    if (!fp)
***************
*** 579,589 ****
  }
  
  static int config_nameserver(struct server_state **servers, int *nservers,
! 			     const char *str)
  {
    struct in_addr addr;
    struct server_state *newserv;
  
    /* Add a nameserver entry, if this is a valid address. */
    addr.s_addr = inet_addr(str);
    if (addr.s_addr == INADDR_NONE)
--- 579,630 ----
  }
  
  static int config_nameserver(struct server_state **servers, int *nservers,
! 			     char *str)
  {
    struct in_addr addr;
    struct server_state *newserv;
+   /* On Windows, there may be more than one nameserver specified in the same
+    * registry key, so we parse it as a space or comma seperated list.
+    */
+ #ifdef WIN32
+   char *p = str;
+   char *begin = str;
+   int more = 1;
+   while (more)
+   {
+     more = 0;
+     while (*p && !isspace(*p) && *str != ',')
+       p++;
+ 
+     if (*p)
+     {
+       *p = 0;
+       more = 1;
+     }
  
+     /* Skip multiple spaces or trailing spaces */
+     if (!*begin)
+     {
+       begin = ++p;
+       continue;
+     }
+ 
+     /* This is the part that actually sets the nameserver */
+     addr.s_addr = inet_addr(begin);
+     if (addr.s_addr == INADDR_NONE)
+       continue;
+     newserv = realloc(*servers, (*nservers + 1) * sizeof(struct server_state));
+     if (!newserv)
+       return ARES_ENOMEM;
+     newserv[*nservers].addr = addr;
+     *servers = newserv;
+     (*nservers)++;
+ 
+     if (!more)
+       break;
+     begin = ++p;
+   }
+ #else
    /* Add a nameserver entry, if this is a valid address. */
    addr.s_addr = inet_addr(str);
    if (addr.s_addr == INADDR_NONE)
***************
*** 594,599 ****
--- 635,641 ----
    newserv[*nservers].addr = addr;
    *servers = newserv;
    (*nservers)++;
+ #endif
    return ARES_SUCCESS;
  }
  

