00001 #ifndef NAME_CACHE_CLASS 00002 #define NAME_CACHE_CLASS 00003 00004 /*****************************************************************************\ 00005 * * 00006 * Name : name_cache * 00007 * Author : Chris Koeritz * 00008 * * 00009 * Purpose: * 00010 * * 00011 * Stores resolved hostnames to avoid repeatedly calling upon the DNS. * 00012 * * 00013 ******************************************************************************* 00014 * Copyright (c) 1992-$now By Author. This program is free software; you can * 00015 * redistribute it and/or modify it under the terms of the GNU General Public * 00016 * License as published by the Free Software Foundation; either version 2 of * 00017 * the License or (at your option) any later version. This is online at: * 00018 * http://www.fsf.org/copyleft/gpl.html * 00019 * Please send any updates to: fred@gruntose.com * 00020 \*****************************************************************************/ 00021 00022 #include "resolver_dll.h" 00023 00024 // forward. 00025 class dns_entry; 00026 class dns_entry_table; 00027 00028 class RESOLVER_CLASS_STYLE name_cache 00029 { 00030 public: 00031 name_cache(int maximum_entries); 00032 // the "maximum_entries" specifies how many names can exist before old 00033 // names start dropping out of the list. 00034 00035 ~name_cache(); 00036 00037 void add(const istring &name, const dns_entry &info); 00038 // enters a network name listing for the readable "name". if the 00039 // "resolved" field in "info" is true, then the "info" is considered 00040 // completely valid and any existing information is updated. otherwise, 00041 // only provisional records will be kept. 00042 00043 bool remove(const istring &name); 00044 // eliminates the data for "name", if possible. 00045 00046 dns_entry lookup(const istring &name) const; 00047 // finds the name information held for the "name" specified. if the entry 00048 // could not be found, then the returned item will have an uninitialized 00049 // address member. 00050 00051 void show_names(istring &to_fill); 00052 // returns the full status of the name_cache in the string "to_fill". 00053 00054 private: 00055 int _max_cache; // maximum number of entries in the cache. 00056 mutex *_lock; // synchronizes access to list. 00057 dns_entry_table *_name_list; // the list of names. 00058 }; 00059 00060 #endif 00061
1.5.1