40 #if defined(NCBI_OS_MSWIN)
41 # include <winsock2.h>
42 #elif defined(NCBI_OS_UNIX)
46 # error "Unsupported platform"
51 #define NCBI_USE_ERRCODE_X Util_DNS
53 #define X_MAXHOSTNAMELEN 255
61 const string section(
"LOCAL_DNS");
65 ERR_POST_X(1,
Error <<
"CSmallDNS: cannot open file: " << local_hosts_file);
72 ITERATE(list<string>, it, items) {
73 string val = reg.
Get(section, *it);
97 if (dig.size() != 4) {
100 ITERATE(list<string>, it, dig) {
124 if ( s_LocalHostName->empty() ) {
131 "CSmallDNS: Host name buffer too small");
133 char* dot_pos = strstr(
buffer,
".");
137 *s_LocalHostName =
buffer;
141 "CSmallDNS: Cannot detect host name, errno:" << errno);
144 return s_LocalHostName.
Get();
T & Get(void)
Create the variable if not created yet, return the reference.
const_iterator end() const
const_iterator find(const key_type &key) const
The NCBI C++ standard methods for dealing with std::string.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define ERR_POST_X(err_subcode, message)
Error posting with default error code and given error subcode.
void Error(CExceptionArgs_Base &args)
void Warning(CExceptionArgs_Base &args)
CSmallDNS(const string &local_hosts_file="./hosts.ini")
Creates small DNS service from the registry-like file named by "local_hosts_file" using section "[LOC...
string LocalResolveDNS(const string &hostname) const
Given host name "hostname", return its IP address in dot notation.
map< string, string > m_map
static bool IsValidIP(const string &ip)
Validate if "ip" contains a legal IP address in a dot notation (a la "255.255.255....
string LocalBackResolveDNS(const string &ip) const
Given ip address in dot notation, return host name by look up in the registry.
static string GetLocalHost(void)
Get local (current) host name (uname call).
string GetLocalIP(void) const
Get local (current) host ip address from registry.
virtual const string & Get(const string §ion, const string &name, TFlags flags=0) const
Get the parameter value.
virtual void EnumerateEntries(const string §ion, list< string > *entries, TFlags flags=fAllLayers) const
Enumerate parameter names for a specified section.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ifstream CNcbiIfstream
Portable alias for ifstream.
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static unsigned long StringToULong(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to unsigned long.
Definition of all error codes used in util (xutil.lib).
Static variables safety - create on demand, destroy on application termination.
Process information in the NCBI Registry, including working with configuration files.
Resolve host name to ip address and back using preset ini-file.