Esempio n. 1
0
/* parse_resvconf()
 *
 * inputs - NONE
 * output - -1 if failure 0 if success
 * side effects - fills in irc_nsaddr_list
 */
static int
parse_resvconf(void)
{
  char *p;
  char *opt;
  char *arg;
  char input[DNS_MAXLINE];
  FILE *file;

  /* XXX "/etc/resolv.conf" should be from a define in setup.h perhaps
   * for cygwin support etc. this hardcodes it to unix for now -db
   */
  if ((file = fopen("/etc/resolv.conf", "r")) == NULL)
    return -1;

  while (fgets(input, sizeof(input), file) != NULL)
  {
    /* blow away any newline */
    if ((p = strpbrk(input, "\r\n")) != NULL)
      *p = '\0';

    p = input;
    /* skip until something thats not a space is seen */
    while (isspace((unsigned char)*p))
      p++;
    /* if at this point, have a '\0' then continue */
    if (*p == '\0')
      continue;

    /* Ignore comment lines immediately */
    if (*p == '#' || *p == ';')
      continue;

    /* skip until a space is found */
    opt = p;
    while (!isspace((unsigned char)*p) && *p != '\0')
      p++;
    if (*p == '\0')
      continue;  /* no arguments?.. ignore this line */
    /* blow away the space character */
    *p++ = '\0';

    /* skip these spaces that are before the argument */
    while (isspace((unsigned char)*p))
      p++;
    /* Now arg should be right where p is pointing */
    arg = p;
    if ((p = strpbrk(arg, " \t")) != NULL)
      *p = '\0';  /* take the first word */

    if (strcmp(opt, "domain") == 0)
      mowgli_strlcpy(irc_domain, arg, sizeof(irc_domain));
    else if (strcmp(opt, "nameserver") == 0)
      add_nameserver(arg);
  }

  fclose(file);
  return 0;
}
Esempio n. 2
0
/* parse_resvconf()
 *
 * inputs - NONE
 * output - -1 if failure 0 if success
 * side effects - fills in irc_nsaddr_list
 */
static int
parse_resvconf(void)
{
  char *p;
  char *opt;
  char *arg;
  char input[MAXLINE];
  FBFILE *file;

  /* XXX "/etc/resolv.conf" should be from a define in setup.h perhaps
   * for cygwin support etc. this hardcodes it to unix for now -db
   */
  if ((file = fbopen("/etc/resolv.conf", "r")) == NULL)
    return(-1);

  while (fbgets(input, MAXLINE, file) != NULL)
  {
    /* blow away any newline */
    if ((p = strpbrk(input, "\r\n")) != NULL)
      *p = '\0';

    /* Ignore comment lines immediately */
    if (*input == '#')
      continue;

    p = input;
    /* skip until something thats not a space is seen */
    while (IsSpace(*p))
      p++;
    /* if at this point, have a '\0' then continue */
    if (*p == '\0')
      continue;

    /* skip until a space is found */
    opt = input;
    while (!IsSpace(*p))
      if (*p++ == '\0')
        continue;  /* no arguments?.. ignore this line */
    /* blow away the space character */
    *p++ = '\0';

    /* skip these spaces that are before the argument */
    while (IsSpace(*p))
      p++;
    /* Now arg should be right where p is pointing */
    arg = p;
    if ((p = strpbrk(arg, " \t")) != NULL)
      *p = '\0';  /* take the first word */

    if (strcasecmp(opt, "domain") == 0)
      strlcpy(irc_domain, arg, HOSTLEN);
    else if (strcasecmp(opt, "nameserver") == 0)
      add_nameserver(arg);
  }

  fbclose(file);
  return(0);
}
Esempio n. 3
0
int
irc_res_init(void)
{
  irc_nscount = 0;
  parse_resvconf();
  if (irc_nscount == 0)
    add_nameserver("127.0.0.1");
  return 0;
}
Esempio n. 4
0
void
irc_res_init()
{
  irc_nscount = 0;
  memset(irc_nsaddr_list, 0, sizeof(irc_nsaddr_list));

  parse_resvconf();

  if (!irc_nscount)
    add_nameserver("127.0.0.1");
}
Esempio n. 5
0
static void
parse_windows_resolvers(void)
{
        const char *ns = get_windows_nameservers();
        char *server;
        char *p;
        char *buf = rb_strdup(ns);
        for(server = rb_strtok_r(buf, " ", &p); server != NULL;server = rb_strtok_r(NULL, " ", &p))
        {
                add_nameserver(server);
        }
        rb_free(buf);
}
Esempio n. 6
0
int
irc_res_init(void)
{
  irc_nscount = 0;
#ifndef _WIN32
  parse_resvconf();
#else
  parse_windows_resolvers();
#endif
  if (irc_nscount == 0)
    add_nameserver("127.0.0.1");
  return 0;
}