Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

AsyncResolverOptions.h

Go to the documentation of this file.
00001 /*  AsyncResolverOptions.h - simple asynchronous DNS resolver stub
00002     Copyright (C) 2004 Mark Weaver
00003     Written by Mark Weaver <mark@npsl.co.uk>
00004 
00005     Part of the Open-Win32 library.
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014     Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public
00017     License along with this library; if not, write to the
00018     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00019     Boston, MA  02111-1307, USA.
00020 */
00021 
00022 /* Copyright 1998 by the Massachusetts Institute of Technology.
00023  *
00024  * Permission to use, copy, modify, and distribute this
00025  * software and its documentation for any purpose and without
00026  * fee is hereby granted, provided that the above copyright
00027  * notice appear in all copies and that both that copyright
00028  * notice and this permission notice appear in supporting
00029  * documentation, and that the name of M.I.T. not be used in
00030  * advertising or publicity pertaining to distribution of the
00031  * software without specific, written prior permission.
00032  * M.I.T. makes no representations about the suitability of
00033  * this software for any purpose.  It is provided "as is"
00034  * without express or implied warranty.
00035  */
00036 
00041 #ifndef OW32_AsyncResolverOptions_h
00042 #define OW32_AsyncResolverOptions_h
00043 
00044 #include <OW32/AsyncResolverError.h>
00045 #include <OW32/tstl.h>
00046 #include <vector>
00047 #include <string>
00048 
00049 namespace OW32
00050 {
00051 
00055 struct apattern 
00056 {
00057     struct in_addr addr;
00058     struct in_addr mask;
00059 };
00060 
00061 #ifdef _MSC_VER
00062 #pragma warning(disable: 4251)
00063 #endif
00064 
00068 class OW32_LIB_EXPORT CAsyncResolverOptions
00069 {
00070 public:
00076     CAsyncResolverOptions();
00077 
00087     AsyncResolverError init(const TCHAR *confPath = NULL);
00088 
00090     AsyncResolverError setSearch(const char *domain_list);
00091 
00093     AsyncResolverError setDomain(const char *domain);
00094 
00096     const std::vector<std::string> &getSearch() const { return m_domains; }
00097 
00103     AsyncResolverError setLookup(const char *lookups);
00104 
00106     const std::string &getLookup() const { return m_lookups; }
00107 
00109     AsyncResolverError setNameServer(const char *ns);
00110 
00112     void clearNameServers() { m_servers.clear(); }
00113 
00115     const std::vector<in_addr> &getServers() const { return m_servers; }
00116 
00123     AsyncResolverError setSortList(const char *sl);
00124 
00126     const std::vector<apattern> getSortList() const { return m_sortlist; }
00127 
00131     void setHostsPath(const TCHAR *path);
00132 
00134     const std::_tstring &getHostsPath() const { return m_hosts_path; }
00135 
00140     void setDots(int ndots) { m_ndots = ndots; }
00141 
00145     int getDots() const { return m_ndots; }
00146 
00150     void setTries(int tries) { m_tries = tries; }
00151 
00155     const int getTries() const { return m_tries; }
00156 
00160     void setTimeout(int timeout) { m_timeout = timeout; }
00161 
00165     const int getTimeout() const { return m_timeout; }
00166 
00170     void setUDPPort(unsigned short udp_port) { m_udp_port = udp_port; }
00171 
00173     const unsigned short getUDPPort() const { return m_udp_port; }
00174 
00175     /*
00176      * Set the nameserver TCP port, defaults to 53.
00177      */
00178     void setTCPPort(unsigned short tcp_port) { m_tcp_port = tcp_port; }
00179 
00181     const unsigned short getTCPPort() const { return m_tcp_port; }
00182 
00184     enum OptionFlagValues
00185     {
00187         ARES_FLAG_USEVC         = (1 << 0),
00189         ARES_FLAG_PRIMARY       = (1 << 1),
00191         ARES_FLAG_IGNTC         = (1 << 2),
00193         ARES_FLAG_NORECURSE     = (1 << 3),
00195         ARES_FLAG_STAYOPEN      = (1 << 4),
00197         ARES_FLAG_NOSEARCH      = (1 << 5),
00199         ARES_FLAG_NOALIASES     = (1 << 6),
00201         ARES_FLAG_NOCHECKRESP   = (1 << 7)
00202     };
00203 
00209     void setFlags(int flags) { m_flags = flags; }
00210 
00214     const int getFlags() const { return m_flags; }
00215 
00216 private:
00220     AsyncResolverError initByEnvironment();
00221 
00226     AsyncResolverError initByConf(const TCHAR *confPath = NULL);
00227 
00231     AsyncResolverError initByIPHelper();
00232 
00236     AsyncResolverError initByRegistry();
00237 
00241     AsyncResolverError initByDefaults();
00242 
00246     AsyncResolverError setOptions(const char *opt);
00247 
00249     int                         m_flags;
00251     int                         m_timeout;
00253     int                         m_tries;
00255     int                         m_ndots;
00257     unsigned short              m_udp_port;
00259     unsigned short              m_tcp_port;
00261     std::vector<in_addr>        m_servers;
00263     std::vector<std::string>    m_domains;
00265     std::vector<apattern>       m_sortlist;
00267     std::string                 m_lookups;
00269     std::_tstring               m_hosts_path;
00271     bool                        m_fSetServers;
00273     bool                        m_fSetSearch;
00275     bool                        m_fSetSort;
00276 };
00277 
00278 #ifdef _MSC_VER
00279 #pragma warning(default: 4251)
00280 #endif
00281 
00282 } // namespace OW32
00283 
00284 #endif // OW32_AsyncResolverOptions_h

Generated on Sun Jun 5 01:29:17 2005 for OW32 by  doxygen 1.3.9.1