Initial
This commit is contained in:
184
socket/HOSTENT.HPP
Normal file
184
socket/HOSTENT.HPP
Normal file
@@ -0,0 +1,184 @@
|
||||
#ifndef _SOCKET_HOSTENT_HPP_
|
||||
#define _SOCKET_HOSTENT_HPP_
|
||||
#ifndef _COMMON_WINSOCK_HPP_
|
||||
#include <common/winsock.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_BLOCK_HPP_
|
||||
#include <common/block.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _SOCKET_INTERNETADDRESS_HPP_
|
||||
#include <socket/inaddr.hpp>
|
||||
#endif
|
||||
|
||||
class HostEnt
|
||||
{
|
||||
public:
|
||||
enum AddressType{AddressTypeInternet=AF_INET};
|
||||
HostEnt(void);
|
||||
HostEnt(const HostEnt &someHostEnt);
|
||||
HostEnt(const String &hostName);
|
||||
HostEnt(const InternetAddress &internetAddress);
|
||||
virtual ~HostEnt();
|
||||
HostEnt &operator=(const HostEnt &someHostEnt);
|
||||
WORD operator==(const HostEnt &someHostEnt)const;
|
||||
WORD hostByName(const String &hostName);
|
||||
WORD hostByAddress(const InternetAddress &hostAddress);
|
||||
String hostName(void)const;
|
||||
Block<String> aliases(void)const;
|
||||
short addressType(void)const;
|
||||
short addressLength(void)const;
|
||||
Block<InternetAddress> addresses(void)const;
|
||||
private:
|
||||
void hostName(const String &hostName);
|
||||
void aliases(Block<String> &aliases);
|
||||
void addressType(short addressType);
|
||||
void addressLength(short addressLength);
|
||||
void addresses(Block<InternetAddress> &addresses);
|
||||
void pureName(char *lpPureName);
|
||||
void pureAliases(char **lpPureAliases);
|
||||
void pureAddressType(short pureAddressType);
|
||||
void pureLength(short pureLength);
|
||||
void pureAddressList(char **lpPureAddressList);
|
||||
|
||||
String mHostName;
|
||||
Block<String> mAliasNames;
|
||||
short mAddressType;
|
||||
short mAddressLength;
|
||||
Block<InternetAddress> mAddressList;
|
||||
};
|
||||
|
||||
inline
|
||||
HostEnt::HostEnt(void)
|
||||
: mAddressType(0), mAddressLength(0)
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
HostEnt::HostEnt(const String &hostName)
|
||||
{
|
||||
hostByName(hostName);
|
||||
}
|
||||
|
||||
inline
|
||||
HostEnt::HostEnt(const InternetAddress &internetAddress)
|
||||
{
|
||||
hostByAddress(internetAddress);
|
||||
}
|
||||
|
||||
inline
|
||||
HostEnt::HostEnt(const HostEnt &someHostEnt)
|
||||
{
|
||||
*this=someHostEnt;
|
||||
}
|
||||
|
||||
inline
|
||||
HostEnt::~HostEnt()
|
||||
{
|
||||
}
|
||||
|
||||
inline
|
||||
HostEnt &HostEnt::operator=(const HostEnt &someHostEnt)
|
||||
{
|
||||
hostName(someHostEnt.hostName());
|
||||
aliases(someHostEnt.aliases());
|
||||
addressType(someHostEnt.addressType());
|
||||
addressLength(someHostEnt.addressLength());
|
||||
addresses(someHostEnt.addresses());
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline
|
||||
WORD HostEnt::operator==(const HostEnt &someHostEnt)const
|
||||
{
|
||||
return (hostName()==someHostEnt.hostName()&&
|
||||
aliases()==someHostEnt.aliases()&&
|
||||
addressType()==someHostEnt.addressType()&&
|
||||
addressLength()==someHostEnt.addressLength()&&
|
||||
addresses()==someHostEnt.addresses());
|
||||
}
|
||||
|
||||
inline
|
||||
String HostEnt::hostName(void)const
|
||||
{
|
||||
return mHostName;
|
||||
}
|
||||
|
||||
inline
|
||||
void HostEnt::hostName(const String &hostName)
|
||||
{
|
||||
mHostName=hostName;
|
||||
}
|
||||
|
||||
inline
|
||||
Block<String> HostEnt::aliases(void)const
|
||||
{
|
||||
return mAliasNames;
|
||||
}
|
||||
|
||||
inline
|
||||
void HostEnt::aliases(Block<String> &aliases)
|
||||
{
|
||||
mAliasNames=aliases;
|
||||
}
|
||||
|
||||
inline
|
||||
short HostEnt::addressType(void)const
|
||||
{
|
||||
return mAddressType;
|
||||
}
|
||||
|
||||
inline
|
||||
void HostEnt::addressType(short addressType)
|
||||
{
|
||||
mAddressType=addressType;
|
||||
}
|
||||
|
||||
inline
|
||||
short HostEnt::addressLength(void)const
|
||||
{
|
||||
return mAddressLength;
|
||||
}
|
||||
|
||||
inline
|
||||
void HostEnt::addressLength(short addressLength)
|
||||
{
|
||||
mAddressLength=addressLength;
|
||||
}
|
||||
|
||||
inline
|
||||
Block<InternetAddress> HostEnt::addresses(void)const
|
||||
{
|
||||
return mAddressList;
|
||||
}
|
||||
|
||||
inline
|
||||
void HostEnt::addresses(Block<InternetAddress> &addresses)
|
||||
{
|
||||
mAddressList=addresses;
|
||||
}
|
||||
|
||||
inline
|
||||
void HostEnt::pureName(char *lpPureName)
|
||||
{
|
||||
if(!lpPureName)return;
|
||||
mHostName=lpPureName;
|
||||
}
|
||||
|
||||
inline
|
||||
void HostEnt::pureAddressType(short pureAddressType)
|
||||
{
|
||||
addressType(pureAddressType);
|
||||
}
|
||||
|
||||
inline
|
||||
void HostEnt::pureLength(short pureLength)
|
||||
{
|
||||
addressLength(pureLength);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user