コード例 #1
0
ファイル: host.c プロジェクト: Red54/axtu
static void
cache_remove (const char *host)
{
  struct address_list *al;
  if (!host_name_addresses_map)
    return;
  al = hash_table_get (host_name_addresses_map, host);
  if (al)
    {
      address_list_release (al);
      hash_table_remove (host_name_addresses_map, host);
    }
}
コード例 #2
0
static bool
resolve_bind_address (struct sockaddr *sa)
{
  struct address_list *al;

  /* Make sure this is called only once.  opt.bind_address doesn't
     change during a Wget run.  */
  static bool called, should_bind;
  static ip_address ip;
  if (called)
    {
      if (should_bind)
        sockaddr_set_data (sa, &ip, 0);
      return should_bind;
    }
  called = true;

  al = lookup_host (opt.bind_address, LH_BIND | LH_SILENT);
  if (!al)
    {
      /* #### We should be able to print the error message here. */
      logprintf (LOG_NOTQUIET,
                 _("%s: unable to resolve bind address `%s'; disabling bind.\n"),
                 exec_name, opt.bind_address);
      should_bind = false;
      return false;
    }

  /* Pick the first address in the list and use it as bind address.
     Perhaps we should try multiple addresses in succession, but I
     don't think that's necessary in practice.  */
  ip = *address_list_address_at (al, 0);
  address_list_release (al);

  sockaddr_set_data (sa, &ip, 0);
  should_bind = true;
  return true;
}