Exemplo n.º 1
0
MODULE load_host_file_in_cache (THREAD *thread)
{
    /*  Load content of host file into cache table.  Skip comment line
     *  beginning with '#' character.  The search key in the cache is the
     *  host name, which is a unique value.
     */

    FILE
        *f_host;
    Bool
        read_line = TRUE;
    char
        *p_char;

    tcb = thread-> tcb;                 /*  Point to thread's context        */

    f_host = file_open (get_host_file (), 'r');
    if (f_host == NULL)
        return;
    read_line = file_read (f_host, buffer);
    while (read_line)
      {
        p_char = strskp (buffer);
        if (*p_char != '#')
            add_host_line_in_cache (p_char);
        read_line = file_read (f_host, buffer);
      }
    file_close (f_host);
}
Exemplo n.º 2
0
MODULE load_host_file_in_cache (THREAD *thread)
{
    /*  Load content of host file into cache table.  Skip comment line
     *  beginning with '#' character.  The search key in the cache is the
     *  host name, which is a unique value.
     */

    FILE
        *f_host;
    Bool
        read_line = TRUE;
    char
        **host_list,
        *p_char,
        *ip_value;
    SYMBOL
        *symbol;
    int
        index,
        list_size;

    tcb = thread-> tcb;                 /*  Point to thread's context        */

    f_host = file_open (get_host_file (), 'r');
    if (f_host == NULL)
        return;
    read_line = file_read (f_host, buffer);
    while (read_line)
      {
        p_char = strskp (buffer);
        if (*p_char != '#')
          {
            host_list = tok_split (p_char);
            if (host_list)
              {
                list_size = tok_size (host_list);
                if (list_size >= 2)
                  {
                    ip_value = host_list [0];
                    for (index = 1;
                         index < list_size
                      && *host_list [index] != '#';
                         index++)
                      {
                        symbol = sym_assume_symbol (
                                   cache_table, host_list [index], ip_value);
                        if (symbol)
                          {
                            symbol-> data = mem_alloc (sizeof (long));
                            if (symbol-> data)
                            *(long *)symbol-> data = -1;
                          }
                      }
                  }
                tok_free (host_list);
              }
          }
        read_line = file_read (f_host, buffer);
      }
    file_close (f_host);
}