diff options
author | maximius <none@none> | 2009-10-17 16:20:24 -0700 |
---|---|---|
committer | maximius <none@none> | 2009-10-17 16:20:24 -0700 |
commit | 3f338cc1c328c7280957583b50598292cd8fb64b (patch) | |
tree | ca209c2cd024e3902b7844b3224bceff7c5bb570 /dep/src | |
parent | e585187b248f48b3c6e9247b49fa07c6565d65e5 (diff) |
*Massive cleanup redux.
--HG--
branch : trunk
Diffstat (limited to 'dep/src')
38 files changed, 33 insertions, 657 deletions
diff --git a/dep/src/g3dlite/AABox.cpp b/dep/src/g3dlite/AABox.cpp index f2f2b70535c..2279e9a51f0 100644 --- a/dep/src/g3dlite/AABox.cpp +++ b/dep/src/g3dlite/AABox.cpp @@ -19,15 +19,12 @@ #include "G3D/Plane.h" #include "G3D/Sphere.h" - namespace G3D { Box AABox::toBox() const { return Box(lo, hi); } - - void AABox::split(const Vector3::Axis& axis, float location, AABox& low, AABox& high) const { // Low, medium, and high along the chosen axis float L = G3D::min(location, lo[axis]); @@ -82,7 +79,6 @@ Vector3 AABox::randomSurfacePoint() const { } } - Vector3 AABox::randomInteriorPoint() const { return Vector3( (float)random(lo.x, hi.x), @@ -91,7 +87,6 @@ Vector3 AABox::randomInteriorPoint() const { } #endif - bool AABox::intersects(const AABox& other) const { // Must be overlap along all three axes. // Try to find a separating axis. @@ -110,7 +105,6 @@ bool AABox::intersects(const AABox& other) const { return true; } - bool AABox::culledBy( const Array<Plane>& plane, int& cullingPlaneIndex, @@ -120,7 +114,6 @@ bool AABox::culledBy( return culledBy(plane.getCArray(), plane.size(), cullingPlaneIndex, inMask, outMask); } - bool AABox::culledBy( const Array<Plane>& plane, int& cullingPlaneIndex, @@ -129,10 +122,8 @@ bool AABox::culledBy( return culledBy(plane.getCArray(), plane.size(), cullingPlaneIndex, inMask); } - int AABox::dummy = 0; - bool AABox::culledBy( const class Plane* plane, int numPlanes, @@ -213,7 +204,6 @@ bool AABox::culledBy( return false; } - bool AABox::culledBy( const class Plane* plane, int numPlanes, @@ -278,7 +268,6 @@ bool AABox::culledBy( return false; } - bool AABox::intersects(const class Sphere& sphere) const { double d = 0; @@ -295,6 +284,5 @@ bool AABox::intersects(const class Sphere& sphere) const { return d <= square(sphere.radius); } - } // namespace diff --git a/dep/src/g3dlite/Box.cpp b/dep/src/g3dlite/Box.cpp index fd3067048c0..725a7e95c3a 100644 --- a/dep/src/g3dlite/Box.cpp +++ b/dep/src/g3dlite/Box.cpp @@ -27,12 +27,10 @@ namespace G3D { Box::Box() { } - Box::Box(const AABox& b) { init(b.low(), b.high()); } - Box::Box( const Vector3& min, const Vector3& max) { @@ -61,7 +59,7 @@ void Box::init( _axis[2] = Vector3::unitZ(); _volume = _extent.x * _extent.y * _extent.z; - _area = 2 * + _area = 2 * (_extent.x * _extent.y + _extent.y * _extent.z + _extent.z * _extent.x); @@ -69,17 +67,14 @@ void Box::init( _center = (max + min) / 2; } - float Box::volume() const { return _volume; } - float Box::surfaceArea() const { return _area; } - void Box::getLocalFrame(CoordinateFrame& frame) const { frame.rotation = Matrix3( @@ -90,14 +85,12 @@ void Box::getLocalFrame(CoordinateFrame& frame) const { frame.translation = _center; } - CoordinateFrame Box::localFrame() const { CoordinateFrame out; getLocalFrame(out); return out; } - void Box::getFaceCorners(int f, Vector3& v0, Vector3& v1, Vector3& v2, Vector3& v3) const { switch (f) { case 0: @@ -129,7 +122,6 @@ void Box::getFaceCorners(int f, Vector3& v0, Vector3& v1, Vector3& v2, Vector3& } } - bool Box::culledBy( const Array<Plane>& plane, int& cullingPlaneIndex, @@ -139,7 +131,6 @@ bool Box::culledBy( return culledBy(plane.getCArray(), plane.size(), cullingPlaneIndex, inMask, outMask); } - bool Box::culledBy( const Array<Plane>& plane, int& cullingPlaneIndex, @@ -148,7 +139,6 @@ bool Box::culledBy( return culledBy(plane.getCArray(), plane.size(), cullingPlaneIndex, inMask); } - int32 Box::dummy = 0; bool Box::culledBy( @@ -169,7 +159,7 @@ bool Box::culledBy( // Only test planes that are not masked if ((inMask & 1) != 0) { - + Vector3 corner; int numContained = 0; @@ -211,7 +201,6 @@ bool Box::culledBy( return false; } - bool Box::culledBy( const class Plane* plane, int numPlanes, @@ -227,7 +216,7 @@ bool Box::culledBy( // Only test planes that are not masked if ((inMask & 1) != 0) { - + bool culled = true; int v; @@ -256,7 +245,6 @@ bool Box::culledBy( return false; } - bool Box::contains( const Vector3& point) const { @@ -276,7 +264,7 @@ bool Box::contains( Vector3 osPoint = M.inverse() * (point - _corner[0]); return - (osPoint.x >= 0) && + (osPoint.x >= 0) && (osPoint.y >= 0) && (osPoint.z >= 0) && (osPoint.x <= 1) && @@ -317,7 +305,6 @@ void Box::getRandomSurfacePoint(Vector3& P, Vector3& N) const { } } - Vector3 Box::randomInteriorPoint() const { Vector3 sum = _center; @@ -329,7 +316,6 @@ Vector3 Box::randomInteriorPoint() const { } #endif - void Box::getBounds(class AABox& aabb) const { Vector3 lo = _corner[0]; @@ -344,6 +330,5 @@ void Box::getBounds(class AABox& aabb) const { aabb = AABox(lo, hi); } - } // namespace diff --git a/dep/src/g3dlite/Crypto.cpp b/dep/src/g3dlite/Crypto.cpp index bff3a5a966c..03851193e57 100644 --- a/dep/src/g3dlite/Crypto.cpp +++ b/dep/src/g3dlite/Crypto.cpp @@ -3,7 +3,6 @@ @author Morgan McGuire, matrix@graphics3d.com - @created 2006-03-28 @edited 2006-04-06 */ @@ -14,7 +13,6 @@ namespace G3D { - int Crypto::smallPrime(int n) { debugAssert(n < numSmallPrimes() && n >= 0); @@ -57,7 +55,6 @@ int Crypto::smallPrime(int n) { return table[n]; } - int Crypto::numSmallPrimes() { return 303; } diff --git a/dep/src/g3dlite/Matrix3.cpp b/dep/src/g3dlite/Matrix3.cpp index 630c1883c0b..76864e1b60c 100644 --- a/dep/src/g3dlite/Matrix3.cpp +++ b/dep/src/g3dlite/Matrix3.cpp @@ -49,7 +49,6 @@ bool Matrix3::fuzzyEq(const Matrix3& b) const { return true; } - bool Matrix3::isOrthonormal() const { Vector3 X = getColumn(0); Vector3 Y = getColumn(1); @@ -123,7 +122,6 @@ void Matrix3::set( elt[2][2] = fEntry22; } - //---------------------------------------------------------------------------- Vector3 Matrix3::getColumn (int iCol) const { assert((0 <= iCol) && (iCol < 3)); @@ -142,7 +140,6 @@ void Matrix3::setColumn(int iCol, const Vector3 &vector) { elt[2][iCol] = vector.z; } - void Matrix3::setRow(int iRow, const Vector3 &vector) { debugAssert((iRow >= 0) && (iRow < 3)); elt[iRow][0] = vector.x; @@ -150,7 +147,6 @@ void Matrix3::setRow(int iRow, const Vector3 &vector) { elt[iRow][2] = vector.z; } - //---------------------------------------------------------------------------- bool Matrix3::operator== (const Matrix3& rkMatrix) const { for (int iRow = 0; iRow < 3; iRow++) { @@ -290,7 +286,6 @@ Matrix3 operator* (float fScalar, const Matrix3& rkMatrix) { return (double)fScalar * rkMatrix; } - Matrix3 operator* (int fScalar, const Matrix3& rkMatrix) { return (double)fScalar * rkMatrix; } @@ -1680,8 +1675,6 @@ std::string Matrix3::toString() const { elt[2][0], elt[2][1], elt[2][2]); } - - } // namespace diff --git a/dep/src/g3dlite/Plane.cpp b/dep/src/g3dlite/Plane.cpp index 10ee7ff0f0c..5ae60b0f762 100644 --- a/dep/src/g3dlite/Plane.cpp +++ b/dep/src/g3dlite/Plane.cpp @@ -60,7 +60,6 @@ Plane::Plane( _distance = _normal.dot(point0.xyz()); } - Plane::Plane( const Vector3& point0, const Vector3& point1, @@ -70,7 +69,6 @@ Plane::Plane( _distance = _normal.dot(point0); } - Plane::Plane( const Vector3& __normal, const Vector3& point) { @@ -79,7 +77,6 @@ Plane::Plane( _distance = _normal.dot(point); } - Plane Plane::fromEquation(float a, float b, float c, float d) { Vector3 n(a, b, c); float magnitude = n.magnitude(); @@ -88,13 +85,11 @@ Plane Plane::fromEquation(float a, float b, float c, float d) { return Plane(n, -d); } - void Plane::flip() { _normal = -_normal; _distance = -_distance; } - void Plane::getEquation(Vector3& n, float& d) const { double _d; getEquation(n, _d); @@ -106,7 +101,6 @@ void Plane::getEquation(Vector3& n, double& d) const { d = -_distance; } - void Plane::getEquation(float& a, float& b, float& c, float& d) const { double _a, _b, _c, _d; getEquation(_a, _b, _c, _d); @@ -123,7 +117,6 @@ void Plane::getEquation(double& a, double& b, double& c, double& d) const { d = -_distance; } - std::string Plane::toString() const { return format("Plane(%g, %g, %g, %g)", _normal.x, _normal.y, _normal.z, _distance); } diff --git a/dep/src/g3dlite/System.cpp b/dep/src/g3dlite/System.cpp index 88fd39b52ca..e55be13adc5 100644 --- a/dep/src/g3dlite/System.cpp +++ b/dep/src/g3dlite/System.cpp @@ -76,7 +76,6 @@ namespace G3D { static char versionCstr[1024]; System::OutOfMemoryCallback System::outOfMemoryCallback = NULL; - void System::init() { // Cannot use most G3D data structures or utility functions in here because // they are not initialized. @@ -102,21 +101,15 @@ void System::init() { } - - void System::memcpy(void* dst, const void* src, size_t numBytes) { ::memcpy(dst, src, numBytes); } - void System::memset(void* dst, uint8 value, size_t numBytes) { ::memset(dst, value, numBytes); } - - - //////////////////////////////////////////////////////////////// class BufferPool { public: @@ -231,7 +224,6 @@ private: poolSize = 0; } - /** Allocate out of a specific pool-> Return NULL if no suitable memory was found. @@ -292,7 +284,6 @@ public: medPoolSize = 0; - // Initialize the tiny heap as a bunch of pointers into one // pre-allocated buffer. tinyHeap = ::malloc(maxTinyBuffers * tinyBufferSize); @@ -308,7 +299,6 @@ public: # endif } - ~BufferPool() { ::free(tinyHeap); # ifdef G3D_WIN32 @@ -318,7 +308,6 @@ public: # endif } - void* realloc(void* ptr, size_t bytes) { if (ptr == NULL) { return malloc(bytes); @@ -355,7 +344,6 @@ public: } } - void* malloc(size_t bytes) { lock(); ++totalMallocs; @@ -414,7 +402,6 @@ public: ptr = ::malloc(bytes + 4); } - if (ptr == NULL) { if ((System::outOfMemoryCallback != NULL) && (System::outOfMemoryCallback(bytes + 4, true) == true)) { @@ -436,7 +423,6 @@ public: return (uint8*)ptr + 4; } - void free(void* ptr) { if (ptr == NULL) { // Free does nothing on null pointers @@ -527,7 +513,6 @@ std::string System::mallocStatus() { #endif } - void System::resetMallocPerformanceCounters() { #ifndef NO_BUFFERPOOL bufferpool->totalMallocs = 0; @@ -537,7 +522,6 @@ void System::resetMallocPerformanceCounters() { #endif } - #ifndef NO_BUFFERPOOL inline void initMem() { // Putting the test here ensures that the system is always @@ -550,7 +534,6 @@ inline void initMem() { } #endif - void* System::malloc(size_t bytes) { #ifndef NO_BUFFERPOOL initMem(); @@ -570,7 +553,6 @@ void* System::calloc(size_t n, size_t x) { #endif } - void* System::realloc(void* block, size_t bytes) { #ifndef NO_BUFFERPOOL initMem(); @@ -580,7 +562,6 @@ void* System::realloc(void* block, size_t bytes) { #endif } - void System::free(void* p) { #ifndef NO_BUFFERPOOL bufferpool->free(p); @@ -589,7 +570,6 @@ void System::free(void* p) { #endif } - void* System::alignedMalloc(size_t bytes, size_t alignment) { alwaysAssertM(isPow2(alignment), "alignment must be a power of 2"); @@ -646,7 +626,6 @@ void* System::alignedMalloc(size_t bytes, size_t alignment) { return (void*)alignedPtr; } - void System::alignedFree(void* _ptr) { if (_ptr == NULL) { return; @@ -666,6 +645,5 @@ void System::alignedFree(void* _ptr) { System::free(truePtr); } - } // namespace diff --git a/dep/src/g3dlite/Triangle.cpp b/dep/src/g3dlite/Triangle.cpp index bb5b8f94635..2e221b12f1d 100644 --- a/dep/src/g3dlite/Triangle.cpp +++ b/dep/src/g3dlite/Triangle.cpp @@ -17,7 +17,6 @@ namespace G3D { - void Triangle::init(const Vector3& v0, const Vector3& v1, const Vector3& v2) { _plane = Plane(v0, v1, v2); @@ -46,36 +45,29 @@ void Triangle::init(const Vector3& v0, const Vector3& v1, const Vector3& v2) { } - Triangle::Triangle() { init(Vector3::zero(), Vector3::zero(), Vector3::zero()); } - Triangle::Triangle(const Vector3& v0, const Vector3& v1, const Vector3& v2) { init(v0, v1, v2); } - Triangle::~Triangle() { } - double Triangle::area() const { return _area; } - const Vector3& Triangle::normal() const { return _plane.normal(); } - const Plane& Triangle::plane() const { return _plane; } - Vector3 Triangle::center() const { return (_vertex[0] + _vertex[1] + _vertex[2]) / 3.0; } @@ -96,7 +88,6 @@ Vector3 Triangle::randomPoint() const { return edge01 * s + edge02 * t + _vertex[0]; } - void Triangle::getBounds(AABox& out) const { Vector3 lo = _vertex[0]; Vector3 hi = lo; diff --git a/dep/src/g3dlite/Vector3.cpp b/dep/src/g3dlite/Vector3.cpp index 09c3003888b..b0ca1990a3f 100644 --- a/dep/src/g3dlite/Vector3.cpp +++ b/dep/src/g3dlite/Vector3.cpp @@ -62,7 +62,6 @@ Vector3::Axis Vector3::primaryAxis() const { return a; } - unsigned int Vector3::hashCode() const { unsigned int xhash = (*(int*)(void*)(&x)); unsigned int yhash = (*(int*)(void*)(&y)); @@ -75,21 +74,18 @@ std::ostream& operator<<(std::ostream& os, const Vector3& v) { return os << v.toString(); } - //---------------------------------------------------------------------------- double frand() { return rand() / (double) RAND_MAX; } - Vector3::Vector3(const class Vector3int16& v) { x = v.x; y = v.y; z = v.z; } - Vector3 Vector3::random() { Vector3 result; @@ -298,7 +294,6 @@ std::string Vector3::toString() const { return G3D::format("(%g, %g, %g)", x, y, z); } - //---------------------------------------------------------------------------- Matrix3 Vector3::cross() const { @@ -307,7 +302,6 @@ Matrix3 Vector3::cross() const { -y, x, 0); } - //---------------------------------------------------------------------------- // 2-char swizzles @@ -437,8 +431,5 @@ Vector4 Vector3::zzzz() const { return Vector4 (z, z, z, z); } - - - } // namespace diff --git a/dep/src/g3dlite/Vector4.cpp b/dep/src/g3dlite/Vector4.cpp index 91f916d1040..b38e6f7cb57 100644 --- a/dep/src/g3dlite/Vector4.cpp +++ b/dep/src/g3dlite/Vector4.cpp @@ -35,7 +35,6 @@ Vector4::Vector4(const class Color4& c) { } #endif - Vector4::Vector4(const Vector2& v1, const Vector2& v2) { x = v1.x; y = v1.y; @@ -43,7 +42,6 @@ Vector4::Vector4(const Vector2& v1, const Vector2& v2) { w = v2.y; } - Vector4::Vector4(const Vector2& v1, float fz, float fw) { x = v1.x; y = v1.y; @@ -83,7 +81,6 @@ Vector4& Vector4::operator/= (float fScalar) { return *this; } - //---------------------------------------------------------------------------- std::string Vector4::toString() const { @@ -434,6 +431,5 @@ Vector4 Vector4::ywww() const { return Vector4 (y, w, w, w); } Vector4 Vector4::zwww() const { return Vector4 (z, w, w, w); } Vector4 Vector4::wwww() const { return Vector4 (w, w, w, w); } - }; // namespace diff --git a/dep/src/sockets/Base64.cpp b/dep/src/sockets/Base64.cpp index cb66b93af6f..f7f12f5edff 100644 --- a/dep/src/sockets/Base64.cpp +++ b/dep/src/sockets/Base64.cpp @@ -33,7 +33,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. namespace SOCKETS_NAMESPACE { #endif - const char *Base64::bstr = "ABCDEFGHIJKLMNOPQ" "RSTUVWXYZabcdefgh" @@ -50,12 +49,10 @@ const char Base64::rstr[] = { 0, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 0, 0, 0, 0, 0}; - Base64::Base64() { } - void Base64::encode(FILE *fil, std::string& output, bool add_crlf) { size_t remain; @@ -94,13 +91,11 @@ void Base64::encode(FILE *fil, std::string& output, bool add_crlf) } } - void Base64::encode(const std::string& str_in, std::string& str_out, bool add_crlf) { encode(str_in.c_str(), str_in.size(), str_out, add_crlf); } - void Base64::encode(const char* input,size_t l,std::string& output, bool add_crlf) { size_t i = 0; @@ -136,7 +131,6 @@ void Base64::encode(const char* input,size_t l,std::string& output, bool add_crl } } - void Base64::encode(const unsigned char* input,size_t l,std::string& output,bool add_crlf) { size_t i = 0; @@ -172,7 +166,6 @@ void Base64::encode(const unsigned char* input,size_t l,std::string& output,bool } } - void Base64::decode(const std::string& input,std::string& output) { size_t i = 0; @@ -205,7 +198,6 @@ void Base64::decode(const std::string& input,std::string& output) } } - void Base64::decode(const std::string& input, unsigned char *output, size_t& sz) { size_t i = 0; @@ -251,7 +243,6 @@ void Base64::decode(const std::string& input, unsigned char *output, size_t& sz) sz = j; } - size_t Base64::decode_length(const std::string& str64) { if (str64.empty() || str64.size() % 4) @@ -264,10 +255,8 @@ size_t Base64::decode_length(const std::string& str64) return l; } - #ifdef SOCKETS_NAMESPACE } #endif - diff --git a/dep/src/sockets/Exception.cpp b/dep/src/sockets/Exception.cpp index 33a7b4a133c..4d79aeef813 100644 --- a/dep/src/sockets/Exception.cpp +++ b/dep/src/sockets/Exception.cpp @@ -29,19 +29,15 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. namespace SOCKETS_NAMESPACE { #endif - - Exception::Exception(const std::string& description) : m_description(description) { } - const std::string Exception::ToString() const { return m_description; } - #ifdef SOCKETS_NAMESPACE } // namespace SOCKETS_NAMESPACE { #endif diff --git a/dep/src/sockets/Ipv4Address.cpp b/dep/src/sockets/Ipv4Address.cpp index b89cc2a449b..03935038951 100644 --- a/dep/src/sockets/Ipv4Address.cpp +++ b/dep/src/sockets/Ipv4Address.cpp @@ -27,13 +27,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <netdb.h> #endif - #ifdef SOCKETS_NAMESPACE namespace SOCKETS_NAMESPACE { #endif - - Ipv4Address::Ipv4Address(port_t port) : m_valid(true) { memset(&m_addr, 0, sizeof(m_addr)); @@ -41,7 +38,6 @@ Ipv4Address::Ipv4Address(port_t port) : m_valid(true) m_addr.sin_port = htons( port ); } - Ipv4Address::Ipv4Address(ipaddr_t a,port_t port) : m_valid(true) { memset(&m_addr, 0, sizeof(m_addr)); @@ -50,7 +46,6 @@ Ipv4Address::Ipv4Address(ipaddr_t a,port_t port) : m_valid(true) memcpy(&m_addr.sin_addr, &a, sizeof(struct in_addr)); } - Ipv4Address::Ipv4Address(struct in_addr& a,port_t port) : m_valid(true) { memset(&m_addr, 0, sizeof(m_addr)); @@ -59,7 +54,6 @@ Ipv4Address::Ipv4Address(struct in_addr& a,port_t port) : m_valid(true) m_addr.sin_addr = a; } - Ipv4Address::Ipv4Address(const std::string& host,port_t port) : m_valid(false) { memset(&m_addr, 0, sizeof(m_addr)); @@ -75,43 +69,36 @@ Ipv4Address::Ipv4Address(const std::string& host,port_t port) : m_valid(false) } } - Ipv4Address::Ipv4Address(struct sockaddr_in& sa) { m_addr = sa; m_valid = sa.sin_family == AF_INET; } - Ipv4Address::~Ipv4Address() { } - Ipv4Address::operator struct sockaddr *() { return (struct sockaddr *)&m_addr; } - Ipv4Address::operator socklen_t() { return sizeof(struct sockaddr_in); } - void Ipv4Address::SetPort(port_t port) { m_addr.sin_port = htons( port ); } - port_t Ipv4Address::GetPort() { return ntohs( m_addr.sin_port ); } - bool Ipv4Address::Resolve(const std::string& hostname,struct in_addr& a) { struct sockaddr_in sa; @@ -129,7 +116,6 @@ bool Ipv4Address::Resolve(const std::string& hostname,struct in_addr& a) return true; } - bool Ipv4Address::Reverse(struct in_addr& a,std::string& name) { struct sockaddr_in sa; @@ -139,7 +125,6 @@ bool Ipv4Address::Reverse(struct in_addr& a,std::string& name) return Utility::reverse((struct sockaddr *)&sa, sizeof(sa), name); } - std::string Ipv4Address::Convert(bool include_port) { if (include_port) @@ -147,7 +132,6 @@ std::string Ipv4Address::Convert(bool include_port) return Convert(m_addr.sin_addr); } - std::string Ipv4Address::Convert(struct in_addr& a) { struct sockaddr_in sa; @@ -159,25 +143,21 @@ std::string Ipv4Address::Convert(struct in_addr& a) return name; } - void Ipv4Address::SetAddress(struct sockaddr *sa) { memcpy(&m_addr, sa, sizeof(struct sockaddr_in)); } - int Ipv4Address::GetFamily() { return m_addr.sin_family; } - bool Ipv4Address::IsValid() { return m_valid; } - bool Ipv4Address::operator==(SocketAddress& a) { if (a.GetFamily() != GetFamily()) @@ -193,13 +173,11 @@ bool Ipv4Address::operator==(SocketAddress& a) return true; } - std::auto_ptr<SocketAddress> Ipv4Address::GetCopy() { return std::auto_ptr<SocketAddress>(new Ipv4Address(m_addr)); } - std::string Ipv4Address::Reverse() { std::string tmp; @@ -207,7 +185,6 @@ std::string Ipv4Address::Reverse() return tmp; } - #ifdef SOCKETS_NAMESPACE } // namespace SOCKETS_NAMESPACE { #endif diff --git a/dep/src/sockets/Ipv6Address.cpp b/dep/src/sockets/Ipv6Address.cpp index 6c92de24871..3208b5098fa 100644 --- a/dep/src/sockets/Ipv6Address.cpp +++ b/dep/src/sockets/Ipv6Address.cpp @@ -34,7 +34,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. namespace SOCKETS_NAMESPACE { #endif - Ipv6Address::Ipv6Address(port_t port) : m_valid(true) { memset(&m_addr, 0, sizeof(m_addr)); @@ -42,7 +41,6 @@ Ipv6Address::Ipv6Address(port_t port) : m_valid(true) m_addr.sin6_port = htons( port ); } - Ipv6Address::Ipv6Address(struct in6_addr& a,port_t port) : m_valid(true) { memset(&m_addr, 0, sizeof(m_addr)); @@ -51,7 +49,6 @@ Ipv6Address::Ipv6Address(struct in6_addr& a,port_t port) : m_valid(true) m_addr.sin6_addr = a; } - Ipv6Address::Ipv6Address(const std::string& host,port_t port) : m_valid(false) { memset(&m_addr, 0, sizeof(m_addr)); @@ -67,43 +64,36 @@ Ipv6Address::Ipv6Address(const std::string& host,port_t port) : m_valid(false) } } - Ipv6Address::Ipv6Address(struct sockaddr_in6& sa) { m_addr = sa; m_valid = sa.sin6_family == AF_INET6; } - Ipv6Address::~Ipv6Address() { } - Ipv6Address::operator struct sockaddr *() { return (struct sockaddr *)&m_addr; } - Ipv6Address::operator socklen_t() { return sizeof(struct sockaddr_in6); } - void Ipv6Address::SetPort(port_t port) { m_addr.sin6_port = htons( port ); } - port_t Ipv6Address::GetPort() { return ntohs( m_addr.sin6_port ); } - bool Ipv6Address::Resolve(const std::string& hostname,struct in6_addr& a) { struct sockaddr_in6 sa; @@ -121,7 +111,6 @@ bool Ipv6Address::Resolve(const std::string& hostname,struct in6_addr& a) return true; } - bool Ipv6Address::Reverse(struct in6_addr& a,std::string& name) { struct sockaddr_in6 sa; @@ -131,7 +120,6 @@ bool Ipv6Address::Reverse(struct in6_addr& a,std::string& name) return Utility::reverse((struct sockaddr *)&sa, sizeof(sa), name); } - std::string Ipv6Address::Convert(bool include_port) { if (include_port) @@ -139,7 +127,6 @@ std::string Ipv6Address::Convert(bool include_port) return Convert(m_addr.sin6_addr); } - std::string Ipv6Address::Convert(struct in6_addr& a,bool mixed) { char slask[100]; // l2ip temporary @@ -187,51 +174,43 @@ std::string Ipv6Address::Convert(struct in6_addr& a,bool mixed) return slask; } - void Ipv6Address::SetAddress(struct sockaddr *sa) { memcpy(&m_addr, sa, sizeof(struct sockaddr_in6)); } - int Ipv6Address::GetFamily() { return m_addr.sin6_family; } - void Ipv6Address::SetFlowinfo(uint32_t x) { m_addr.sin6_flowinfo = x; } - uint32_t Ipv6Address::GetFlowinfo() { return m_addr.sin6_flowinfo; } - #ifndef _WIN32 void Ipv6Address::SetScopeId(uint32_t x) { m_addr.sin6_scope_id = x; } - uint32_t Ipv6Address::GetScopeId() { return m_addr.sin6_scope_id; } #endif - bool Ipv6Address::IsValid() { return m_valid; } - bool Ipv6Address::operator==(SocketAddress& a) { if (a.GetFamily() != GetFamily()) @@ -247,13 +226,11 @@ bool Ipv6Address::operator==(SocketAddress& a) return true; } - std::auto_ptr<SocketAddress> Ipv6Address::GetCopy() { return std::auto_ptr<SocketAddress>(new Ipv6Address(m_addr)); } - std::string Ipv6Address::Reverse() { std::string tmp; @@ -261,7 +238,6 @@ std::string Ipv6Address::Reverse() return tmp; } - #ifdef SOCKETS_NAMESPACE } // namespace SOCKETS_NAMESPACE { #endif diff --git a/dep/src/sockets/Lock.cpp b/dep/src/sockets/Lock.cpp index 597ca30afc6..b75664cfbdc 100644 --- a/dep/src/sockets/Lock.cpp +++ b/dep/src/sockets/Lock.cpp @@ -34,21 +34,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. namespace SOCKETS_NAMESPACE { #endif - Lock::Lock(Mutex& m) : m_mutex(m) { m_mutex.Lock(); } - Lock::~Lock() { m_mutex.Unlock(); } - - #ifdef SOCKETS_NAMESPACE } #endif diff --git a/dep/src/sockets/Mutex.cpp b/dep/src/sockets/Mutex.cpp index 3bfe64d04c7..681e85cee5b 100644 --- a/dep/src/sockets/Mutex.cpp +++ b/dep/src/sockets/Mutex.cpp @@ -33,7 +33,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. namespace SOCKETS_NAMESPACE { #endif - Mutex::Mutex() { #ifdef _WIN32 @@ -43,7 +42,6 @@ Mutex::Mutex() #endif } - Mutex::~Mutex() { #ifdef _WIN32 @@ -53,7 +51,6 @@ Mutex::~Mutex() #endif } - void Mutex::Lock() { #ifdef _WIN32 @@ -64,7 +61,6 @@ void Mutex::Lock() #endif } - void Mutex::Unlock() { #ifdef _WIN32 @@ -74,7 +70,6 @@ void Mutex::Unlock() #endif } - #ifdef SOCKETS_NAMESPACE } #endif diff --git a/dep/src/sockets/Parse.cpp b/dep/src/sockets/Parse.cpp index ccbd553b0e6..2967859f23d 100644 --- a/dep/src/sockets/Parse.cpp +++ b/dep/src/sockets/Parse.cpp @@ -33,12 +33,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Parse.h" - #ifdef SOCKETS_NAMESPACE namespace SOCKETS_NAMESPACE { #endif - /* implementation of class Parse */ Parse::Parse() @@ -93,7 +91,6 @@ Parse::Parse(const std::string&s,const std::string&sp,short /*nospace*/) { } - Parse::~Parse() { } @@ -319,4 +316,3 @@ void Parse::getline(std::string&s) #endif - diff --git a/dep/src/sockets/ResolvServer.cpp b/dep/src/sockets/ResolvServer.cpp index 492d6705080..3c8a7de6bc0 100644 --- a/dep/src/sockets/ResolvServer.cpp +++ b/dep/src/sockets/ResolvServer.cpp @@ -41,7 +41,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. namespace SOCKETS_NAMESPACE { #endif - ResolvServer::ResolvServer(port_t port) :Thread() ,m_quit(false) @@ -50,12 +49,10 @@ ResolvServer::ResolvServer(port_t port) { } - ResolvServer::~ResolvServer() { } - void ResolvServer::Run() { // StdoutLog log; @@ -76,19 +73,16 @@ void ResolvServer::Run() SetRunning(false); } - void ResolvServer::Quit() { m_quit = true; } - bool ResolvServer::Ready() { return m_ready; } - #ifdef SOCKETS_NAMESPACE } #endif diff --git a/dep/src/sockets/ResolvSocket.cpp b/dep/src/sockets/ResolvSocket.cpp index 236e93f9704..636de276426 100644 --- a/dep/src/sockets/ResolvSocket.cpp +++ b/dep/src/sockets/ResolvSocket.cpp @@ -53,13 +53,11 @@ namespace SOCKETS_NAMESPACE { #define DEB(x) //#endif - // static ResolvSocket::cache_t ResolvSocket::m_cache; ResolvSocket::timeout_t ResolvSocket::m_cache_to; Mutex ResolvSocket::m_cache_mutex; - ResolvSocket::ResolvSocket(ISocketHandler& h) :TcpSocket(h) ,m_bServer(false) @@ -72,7 +70,6 @@ ResolvSocket::ResolvSocket(ISocketHandler& h) SetLineProtocol(); } - ResolvSocket::ResolvSocket(ISocketHandler& h, Socket *parent, const std::string& host, port_t port, bool ipv6) :TcpSocket(h) ,m_bServer(false) @@ -87,7 +84,6 @@ ResolvSocket::ResolvSocket(ISocketHandler& h, Socket *parent, const std::string& SetLineProtocol(); } - ResolvSocket::ResolvSocket(ISocketHandler& h, Socket *parent, ipaddr_t a) :TcpSocket(h) ,m_bServer(false) @@ -102,7 +98,6 @@ ResolvSocket::ResolvSocket(ISocketHandler& h, Socket *parent, ipaddr_t a) SetLineProtocol(); } - #ifdef ENABLE_IPV6 ResolvSocket::ResolvSocket(ISocketHandler& h, Socket *parent, in6_addr& a) :TcpSocket(h) @@ -117,12 +112,10 @@ ResolvSocket::ResolvSocket(ISocketHandler& h, Socket *parent, in6_addr& a) } #endif - ResolvSocket::~ResolvSocket() { } - void ResolvSocket::OnLine(const std::string& line) { Parse pa(line, ":"); @@ -268,7 +261,6 @@ DEB(fprintf(stderr, " *** Update cache for [%s][%s] = '%s'\n", m_query.c_str(), #endif } - void ResolvSocket::OnDetached() { DEB( fprintf(stderr, " *** ResolvSocket::OnDetached(); query=%s, data=%s\n", m_query.c_str(), m_data.c_str());) @@ -370,7 +362,6 @@ DEB( fprintf(stderr, " *** ResolvSocket::OnDetached(); query=%s, data=%s\n", SetCloseAndDelete(); } - void ResolvSocket::OnConnect() { if (!m_resolv_host.empty()) @@ -405,7 +396,6 @@ void ResolvSocket::OnConnect() Send( msg ); } - void ResolvSocket::OnDelete() { if (m_parent) @@ -427,7 +417,6 @@ DEB(fprintf(stderr, " *** Update cache for [%s][%s] = '%s'\n", m_query.c_str(), } } - #ifdef SOCKETS_NAMESPACE } #endif diff --git a/dep/src/sockets/Socket.cpp b/dep/src/sockets/Socket.cpp index bf1a73abf6e..f53cd27621e 100644 --- a/dep/src/sockets/Socket.cpp +++ b/dep/src/sockets/Socket.cpp @@ -60,13 +60,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. namespace SOCKETS_NAMESPACE { #endif - // statics #ifdef _WIN32 WSAInitializer Socket::m_winsock_init; #endif - Socket::Socket(ISocketHandler& h) //:m_flags(0) :m_handler(h) @@ -111,7 +109,6 @@ Socket::Socket(ISocketHandler& h) { } - Socket::~Socket() { Handler().Remove(this); @@ -125,22 +122,18 @@ Socket::~Socket() } } - void Socket::Init() { } - void Socket::OnRead() { } - void Socket::OnWrite() { } - void Socket::OnException() { // %! exception doesn't always mean something bad happened, this code should be reworked @@ -150,22 +143,18 @@ void Socket::OnException() SetCloseAndDelete(); } - void Socket::OnDelete() { } - void Socket::OnConnect() { } - void Socket::OnAccept() { } - int Socket::Close() { if (m_socket == INVALID_SOCKET) // this could happen @@ -191,7 +180,6 @@ int Socket::Close() return n; } - SOCKET Socket::CreateSocket(int af,int type, const std::string& protocol) { struct protoent *p = NULL; @@ -232,31 +220,26 @@ SOCKET Socket::CreateSocket(int af,int type, const std::string& protocol) return s; } - void Socket::Attach(SOCKET s) { m_socket = s; } - SOCKET Socket::GetSocket() { return m_socket; } - void Socket::SetDeleteByHandler(bool x) { m_bDel = x; } - bool Socket::DeleteByHandler() { return m_bDel; } - void Socket::SetCloseAndDelete(bool x) { if (x != m_bClose) @@ -270,25 +253,21 @@ void Socket::SetCloseAndDelete(bool x) } } - bool Socket::CloseAndDelete() { return m_bClose; } - void Socket::SetRemoteAddress(SocketAddress& ad) //struct sockaddr* sa, socklen_t l) { m_remote_address = ad.GetCopy(); } - std::auto_ptr<SocketAddress> Socket::GetRemoteSocketAddress() { return m_remote_address -> GetCopy(); } - ISocketHandler& Socket::Handler() const { #ifdef ENABLE_DETACH @@ -298,13 +277,11 @@ ISocketHandler& Socket::Handler() const return m_handler; } - ISocketHandler& Socket::MasterHandler() const { return m_handler; } - ipaddr_t Socket::GetRemoteIP4() { ipaddr_t l = 0; @@ -323,7 +300,6 @@ ipaddr_t Socket::GetRemoteIP4() return l; } - #ifdef ENABLE_IPV6 #ifdef IPPROTO_IPV6 struct in6_addr Socket::GetRemoteIP6() @@ -347,7 +323,6 @@ struct in6_addr Socket::GetRemoteIP6() #endif #endif - port_t Socket::GetRemotePort() { if (!m_remote_address.get()) @@ -357,7 +332,6 @@ port_t Socket::GetRemotePort() return m_remote_address -> GetPort(); } - std::string Socket::GetRemoteAddress() { if (!m_remote_address.get()) @@ -367,7 +341,6 @@ std::string Socket::GetRemoteAddress() return m_remote_address -> Convert(false); } - std::string Socket::GetRemoteHostname() { if (!m_remote_address.get()) @@ -377,7 +350,6 @@ std::string Socket::GetRemoteHostname() return m_remote_address -> Reverse(); } - bool Socket::SetNonblocking(bool bNb) { #ifdef _WIN32 @@ -410,7 +382,6 @@ bool Socket::SetNonblocking(bool bNb) #endif } - bool Socket::SetNonblocking(bool bNb, SOCKET s) { #ifdef _WIN32 @@ -443,13 +414,11 @@ bool Socket::SetNonblocking(bool bNb, SOCKET s) #endif } - void Socket::Set(bool bRead, bool bWrite, bool bException) { Handler().Set(m_socket, bRead, bWrite, bException); } - bool Socket::Ready() { if (m_socket != INVALID_SOCKET && !CloseAndDelete()) @@ -457,138 +426,115 @@ bool Socket::Ready() return false; } - void Socket::OnLine(const std::string& ) { } - void Socket::OnConnectFailed() { } - Socket *Socket::GetParent() { return m_parent; } - void Socket::SetParent(Socket *x) { m_parent = x; } - port_t Socket::GetPort() { Handler().LogError(this, "GetPort", 0, "GetPort only implemented for ListenSocket", LOG_LEVEL_WARNING); return 0; } - bool Socket::OnConnectRetry() { return true; } - #ifdef ENABLE_RECONNECT void Socket::OnReconnect() { } #endif - time_t Socket::Uptime() { return time(NULL) - m_tCreate; } - #ifdef ENABLE_IPV6 void Socket::SetIpv6(bool x) { m_ipv6 = x; } - bool Socket::IsIpv6() { return m_ipv6; } #endif - void Socket::DisableRead(bool x) { m_b_disable_read = x; } - bool Socket::IsDisableRead() { return m_b_disable_read; } - void Socket::SendBuf(const char *,size_t,int) { } - void Socket::Send(const std::string&,int) { } - void Socket::SetConnected(bool x) { m_connected = x; } - bool Socket::IsConnected() { return m_connected; } - void Socket::OnDisconnect() { } - void Socket::SetLost() { m_bLost = true; } - bool Socket::Lost() { return m_bLost; } - void Socket::SetErasedByHandler(bool x) { m_b_erased_by_handler = x; } - bool Socket::ErasedByHandler() { return m_b_erased_by_handler; } - time_t Socket::TimeSinceClose() { return time(NULL) - m_tClose; } - void Socket::SetClientRemoteAddress(SocketAddress& ad) { if (!ad.IsValid()) @@ -598,7 +544,6 @@ void Socket::SetClientRemoteAddress(SocketAddress& ad) m_client_remote_address = ad.GetCopy(); } - std::auto_ptr<SocketAddress> Socket::GetClientRemoteAddress() { if (!m_client_remote_address.get()) @@ -608,83 +553,69 @@ std::auto_ptr<SocketAddress> Socket::GetClientRemoteAddress() return m_client_remote_address -> GetCopy(); } - uint64_t Socket::GetBytesSent(bool) { return 0; } - uint64_t Socket::GetBytesReceived(bool) { return 0; } - #ifdef HAVE_OPENSSL void Socket::OnSSLConnect() { } - void Socket::OnSSLAccept() { } - bool Socket::SSLNegotiate() { return false; } - bool Socket::IsSSL() { return m_b_enable_ssl; } - void Socket::EnableSSL(bool x) { m_b_enable_ssl = x; } - bool Socket::IsSSLNegotiate() { return m_b_ssl; } - void Socket::SetSSLNegotiate(bool x) { m_b_ssl = x; } - bool Socket::IsSSLServer() { return m_b_ssl_server; } - void Socket::SetSSLServer(bool x) { m_b_ssl_server = x; } - void Socket::OnSSLConnectFailed() { } - void Socket::OnSSLAcceptFailed() { } #endif // HAVE_OPENSSL - #ifdef ENABLE_POOL void Socket::CopyConnection(Socket *sock) { @@ -699,127 +630,106 @@ void Socket::CopyConnection(Socket *sock) SetRemoteAddress( *sock -> GetRemoteSocketAddress() ); } - void Socket::SetIsClient() { m_bClient = true; } - void Socket::SetSocketType(int x) { m_socket_type = x; } - int Socket::GetSocketType() { return m_socket_type; } - void Socket::SetSocketProtocol(const std::string& x) { m_socket_protocol = x; } - const std::string& Socket::GetSocketProtocol() { return m_socket_protocol; } - void Socket::SetRetain() { if (m_bClient) m_bRetain = true; } - bool Socket::Retain() { return m_bRetain; } - #endif // ENABLE_POOL - #ifdef ENABLE_SOCKS4 void Socket::OnSocks4Connect() { Handler().LogError(this, "OnSocks4Connect", 0, "Use with TcpSocket only"); } - void Socket::OnSocks4ConnectFailed() { Handler().LogError(this, "OnSocks4ConnectFailed", 0, "Use with TcpSocket only"); } - bool Socket::OnSocks4Read() { Handler().LogError(this, "OnSocks4Read", 0, "Use with TcpSocket only"); return true; } - void Socket::SetSocks4Host(const std::string& host) { Utility::u2ip(host, m_socks4_host); } - bool Socket::Socks4() { return m_bSocks4; } - void Socket::SetSocks4(bool x) { m_bSocks4 = x; } - void Socket::SetSocks4Host(ipaddr_t a) { m_socks4_host = a; } - void Socket::SetSocks4Port(port_t p) { m_socks4_port = p; } - void Socket::SetSocks4Userid(const std::string& x) { m_socks4_userid = x; } - ipaddr_t Socket::GetSocks4Host() { return m_socks4_host; } - port_t Socket::GetSocks4Port() { return m_socks4_port; } - const std::string& Socket::GetSocks4Userid() { return m_socks4_userid; } #endif // ENABLE_SOCKS4 - #ifdef ENABLE_DETACH bool Socket::Detach() { @@ -833,7 +743,6 @@ bool Socket::Detach() return true; } - void Socket::DetachSocket() { SetDetached(); @@ -841,43 +750,36 @@ void Socket::DetachSocket() m_pThread -> SetRelease(true); } - void Socket::OnDetached() { } - void Socket::SetDetach(bool x) { Handler().AddList(m_socket, LIST_DETACH, x); m_detach = x; } - bool Socket::IsDetach() { return m_detach; } - void Socket::SetDetached(bool x) { m_detached = x; } - const bool Socket::IsDetached() const { return m_detached; } - void Socket::SetSlaveHandler(ISocketHandler *p) { m_slave_handler = p; } - Socket::SocketThread::SocketThread(Socket *p) :Thread(false) ,m_socket(p) @@ -885,7 +787,6 @@ Socket::SocketThread::SocketThread(Socket *p) // Creator will release } - Socket::SocketThread::~SocketThread() { if (IsRunning()) @@ -900,7 +801,6 @@ Socket::SocketThread::~SocketThread() } } - void Socket::SocketThread::Run() { SocketHandler h; @@ -919,14 +819,12 @@ void Socket::SocketThread::Run() } #endif // ENABLE_DETACH - #ifdef ENABLE_RESOLVER int Socket::Resolve(const std::string& host,port_t port) { return Handler().Resolve(this, host, port); } - #ifdef ENABLE_IPV6 int Socket::Resolve6(const std::string& host,port_t port) { @@ -934,13 +832,11 @@ int Socket::Resolve6(const std::string& host,port_t port) } #endif - int Socket::Resolve(ipaddr_t a) { return Handler().Resolve(this, a); } - #ifdef ENABLE_IPV6 int Socket::Resolve(in6_addr& a) { @@ -948,33 +844,27 @@ int Socket::Resolve(in6_addr& a) } #endif - void Socket::OnResolved(int,ipaddr_t,port_t) { } - #ifdef ENABLE_IPV6 void Socket::OnResolved(int,in6_addr&,port_t) { } #endif - void Socket::OnReverseResolved(int,const std::string&) { } - void Socket::OnResolveFailed(int) { } #endif // ENABLE_RESOLVER - /* IP options */ - bool Socket::SetIpOptions(const void *p, socklen_t len) { #ifdef IP_OPTIONS @@ -990,7 +880,6 @@ bool Socket::SetIpOptions(const void *p, socklen_t len) #endif } - #ifdef IP_PKTINFO bool Socket::SetIpPktinfo(bool x) { @@ -1004,7 +893,6 @@ bool Socket::SetIpPktinfo(bool x) } #endif - #ifdef IP_RECVTOS bool Socket::SetIpRecvTOS(bool x) { @@ -1018,7 +906,6 @@ bool Socket::SetIpRecvTOS(bool x) } #endif - #ifdef IP_RECVTTL bool Socket::SetIpRecvTTL(bool x) { @@ -1032,7 +919,6 @@ bool Socket::SetIpRecvTTL(bool x) } #endif - #ifdef IP_RECVOPTS bool Socket::SetIpRecvopts(bool x) { @@ -1046,7 +932,6 @@ bool Socket::SetIpRecvopts(bool x) } #endif - #ifdef IP_RETOPTS bool Socket::SetIpRetopts(bool x) { @@ -1060,7 +945,6 @@ bool Socket::SetIpRetopts(bool x) } #endif - bool Socket::SetIpTOS(unsigned char tos) { #ifdef IP_TOS @@ -1076,7 +960,6 @@ bool Socket::SetIpTOS(unsigned char tos) #endif } - unsigned char Socket::IpTOS() { unsigned char tos = 0; @@ -1092,7 +975,6 @@ unsigned char Socket::IpTOS() return tos; } - bool Socket::SetIpTTL(int ttl) { #ifdef IP_TTL @@ -1108,7 +990,6 @@ bool Socket::SetIpTTL(int ttl) #endif } - int Socket::IpTTL() { int ttl = 0; @@ -1124,7 +1005,6 @@ int Socket::IpTTL() return ttl; } - bool Socket::SetIpHdrincl(bool x) { #ifdef IP_HDRINCL @@ -1141,7 +1021,6 @@ bool Socket::SetIpHdrincl(bool x) #endif } - #ifdef IP_RECVERR bool Socket::SetIpRecverr(bool x) { @@ -1155,7 +1034,6 @@ bool Socket::SetIpRecverr(bool x) } #endif - #ifdef IP_MTU_DISCOVER bool Socket::SetIpMtudiscover(bool x) { @@ -1169,7 +1047,6 @@ bool Socket::SetIpMtudiscover(bool x) } #endif - #ifdef IP_MTU int Socket::IpMtu() { @@ -1183,7 +1060,6 @@ int Socket::IpMtu() } #endif - #ifdef IP_ROUTER_ALERT bool Socket::SetIpRouterAlert(bool x) { @@ -1197,7 +1073,6 @@ bool Socket::SetIpRouterAlert(bool x) } #endif - bool Socket::SetIpMulticastTTL(int ttl) { #ifdef IP_MULTICAST_TTL @@ -1213,7 +1088,6 @@ bool Socket::SetIpMulticastTTL(int ttl) #endif } - int Socket::IpMulticastTTL() { int ttl = 0; @@ -1229,7 +1103,6 @@ int Socket::IpMulticastTTL() return ttl; } - bool Socket::SetMulticastLoop(bool x) { #ifdef IP_MULTICAST_LOOP @@ -1246,7 +1119,6 @@ bool Socket::SetMulticastLoop(bool x) #endif } - #ifdef LINUX bool Socket::IpAddMembership(struct ip_mreqn& ref) { @@ -1264,7 +1136,6 @@ bool Socket::IpAddMembership(struct ip_mreqn& ref) } #endif - bool Socket::IpAddMembership(struct ip_mreq& ref) { #ifdef IP_ADD_MEMBERSHIP @@ -1280,7 +1151,6 @@ bool Socket::IpAddMembership(struct ip_mreq& ref) #endif } - #ifdef LINUX bool Socket::IpDropMembership(struct ip_mreqn& ref) { @@ -1298,7 +1168,6 @@ bool Socket::IpDropMembership(struct ip_mreqn& ref) } #endif - bool Socket::IpDropMembership(struct ip_mreq& ref) { #ifdef IP_DROP_MEMBERSHIP @@ -1314,10 +1183,8 @@ bool Socket::IpDropMembership(struct ip_mreq& ref) #endif } - /* SOCKET options */ - bool Socket::SetSoReuseaddr(bool x) { #ifdef SO_REUSEADDR @@ -1334,7 +1201,6 @@ bool Socket::SetSoReuseaddr(bool x) #endif } - bool Socket::SetSoKeepalive(bool x) { #ifdef SO_KEEPALIVE @@ -1351,7 +1217,6 @@ bool Socket::SetSoKeepalive(bool x) #endif } - #ifdef SO_NOSIGPIPE bool Socket::SetSoNosigpipe(bool x) { @@ -1365,7 +1230,6 @@ bool Socket::SetSoNosigpipe(bool x) } #endif - bool Socket::SoAcceptconn() { int value = 0; @@ -1381,7 +1245,6 @@ bool Socket::SoAcceptconn() return value ? true : false; } - #ifdef SO_BSDCOMPAT bool Socket::SetSoBsdcompat(bool x) { @@ -1395,7 +1258,6 @@ bool Socket::SetSoBsdcompat(bool x) } #endif - #ifdef SO_BINDTODEVICE bool Socket::SetSoBindtodevice(const std::string& intf) { @@ -1408,7 +1270,6 @@ bool Socket::SetSoBindtodevice(const std::string& intf) } #endif - bool Socket::SetSoBroadcast(bool x) { #ifdef SO_BROADCAST @@ -1425,7 +1286,6 @@ bool Socket::SetSoBroadcast(bool x) #endif } - bool Socket::SetSoDebug(bool x) { #ifdef SO_DEBUG @@ -1442,7 +1302,6 @@ bool Socket::SetSoDebug(bool x) #endif } - int Socket::SoError() { int value = 0; @@ -1458,7 +1317,6 @@ int Socket::SoError() return value; } - bool Socket::SetSoDontroute(bool x) { #ifdef SO_DONTROUTE @@ -1475,7 +1333,6 @@ bool Socket::SetSoDontroute(bool x) #endif } - bool Socket::SetSoLinger(int onoff, int linger) { #ifdef SO_LINGER @@ -1494,7 +1351,6 @@ bool Socket::SetSoLinger(int onoff, int linger) #endif } - bool Socket::SetSoOobinline(bool x) { #ifdef SO_OOBINLINE @@ -1511,7 +1367,6 @@ bool Socket::SetSoOobinline(bool x) #endif } - #ifdef SO_PASSCRED bool Socket::SetSoPasscred(bool x) { @@ -1525,7 +1380,6 @@ bool Socket::SetSoPasscred(bool x) } #endif - #ifdef SO_PEERCRED bool Socket::SoPeercred(struct ucred& ucr) { @@ -1538,7 +1392,6 @@ bool Socket::SoPeercred(struct ucred& ucr) } #endif - #ifdef SO_PRIORITY bool Socket::SetSoPriority(int x) { @@ -1551,7 +1404,6 @@ bool Socket::SetSoPriority(int x) } #endif - bool Socket::SetSoRcvlowat(int x) { #ifdef SO_RCVLOWAT @@ -1567,7 +1419,6 @@ bool Socket::SetSoRcvlowat(int x) #endif } - bool Socket::SetSoSndlowat(int x) { #ifdef SO_SNDLOWAT @@ -1583,7 +1434,6 @@ bool Socket::SetSoSndlowat(int x) #endif } - bool Socket::SetSoRcvtimeo(struct timeval& tv) { #ifdef SO_RCVTIMEO @@ -1599,7 +1449,6 @@ bool Socket::SetSoRcvtimeo(struct timeval& tv) #endif } - bool Socket::SetSoSndtimeo(struct timeval& tv) { #ifdef SO_SNDTIMEO @@ -1615,7 +1464,6 @@ bool Socket::SetSoSndtimeo(struct timeval& tv) #endif } - bool Socket::SetSoRcvbuf(int x) { #ifdef SO_RCVBUF @@ -1631,7 +1479,6 @@ bool Socket::SetSoRcvbuf(int x) #endif } - int Socket::SoRcvbuf() { int value = 0; @@ -1647,7 +1494,6 @@ int Socket::SoRcvbuf() return value; } - #ifdef SO_RCVBUFFORCE bool Socket::SetSoRcvbufforce(int x) { @@ -1660,7 +1506,6 @@ bool Socket::SetSoRcvbufforce(int x) } #endif - bool Socket::SetSoSndbuf(int x) { #ifdef SO_SNDBUF @@ -1676,7 +1521,6 @@ bool Socket::SetSoSndbuf(int x) #endif } - int Socket::SoSndbuf() { int value = 0; @@ -1692,7 +1536,6 @@ int Socket::SoSndbuf() return value; } - #ifdef SO_SNDBUFFORCE bool Socket::SetSoSndbufforce(int x) { @@ -1705,7 +1548,6 @@ bool Socket::SetSoSndbufforce(int x) } #endif - #ifdef SO_TIMESTAMP bool Socket::SetSoTimestamp(bool x) { @@ -1719,7 +1561,6 @@ bool Socket::SetSoTimestamp(bool x) } #endif - int Socket::SoType() { int value = 0; @@ -1735,31 +1576,26 @@ int Socket::SoType() return value; } - #ifdef ENABLE_TRIGGERS void Socket::Subscribe(int id) { Handler().Subscribe(id, this); } - void Socket::Unsubscribe(int id) { Handler().Unsubscribe(id, this); } - void Socket::OnTrigger(int, const TriggerData&) { } - void Socket::OnCancelled(int) { } #endif - void Socket::SetTimeout(time_t secs) { if (!secs) @@ -1772,17 +1608,14 @@ void Socket::SetTimeout(time_t secs) m_timeout_limit = secs; } - void Socket::OnTimeout() { } - void Socket::OnConnectTimeout() { } - bool Socket::Timeout(time_t tnow) { if (tnow - m_timeout_start > m_timeout_limit) @@ -1790,7 +1623,6 @@ bool Socket::Timeout(time_t tnow) return false; } - /** Returns local port number for bound socket file descriptor. */ port_t Socket::GetSockPort() { @@ -1813,7 +1645,6 @@ port_t Socket::GetSockPort() return ntohs(sa.sin_port); } - /** Returns local ipv4 address for bound socket file descriptor. */ ipaddr_t Socket::GetSockIP4() { @@ -1834,7 +1665,6 @@ ipaddr_t Socket::GetSockIP4() return a; } - /** Returns local ipv4 address as text for bound socket file descriptor. */ std::string Socket::GetSockAddress() { @@ -1854,7 +1684,6 @@ std::string Socket::GetSockAddress() return addr.Convert(); } - #ifdef ENABLE_IPV6 #ifdef IPPROTO_IPV6 /** Returns local ipv6 address for bound socket file descriptor. */ @@ -1873,7 +1702,6 @@ struct in6_addr Socket::GetSockIP6() return a; } - /** Returns local ipv6 address as text for bound socket file descriptor. */ std::string Socket::GetSockAddress6() { @@ -1891,7 +1719,6 @@ std::string Socket::GetSockAddress6() #endif #endif - #ifdef SOCKETS_NAMESPACE } #endif diff --git a/dep/src/sockets/SocketHandler.cpp b/dep/src/sockets/SocketHandler.cpp index 84d110cfe72..acf71fb2efa 100644 --- a/dep/src/sockets/SocketHandler.cpp +++ b/dep/src/sockets/SocketHandler.cpp @@ -50,14 +50,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. namespace SOCKETS_NAMESPACE { #endif - //#ifdef _DEBUG //#define DEB(x) x; fflush(stderr); //#else #define DEB(x) //#endif - SocketHandler::SocketHandler(StdLog *p) :m_stdlog(p) ,m_mutex(m_mutex) @@ -90,7 +88,6 @@ SocketHandler::SocketHandler(StdLog *p) FD_ZERO(&m_efds); } - SocketHandler::SocketHandler(Mutex& mutex,StdLog *p) :m_stdlog(p) ,m_mutex(mutex) @@ -124,7 +121,6 @@ SocketHandler::SocketHandler(Mutex& mutex,StdLog *p) FD_ZERO(&m_efds); } - SocketHandler::~SocketHandler() { #ifdef ENABLE_RESOLVER @@ -182,33 +178,28 @@ DEB( fprintf(stderr, "/Emptying sockets list in SocketHandler destructor, } } - Mutex& SocketHandler::GetMutex() const { return m_mutex; } - #ifdef ENABLE_DETACH void SocketHandler::SetSlave(bool x) { m_slave = x; } - bool SocketHandler::IsSlave() { return m_slave; } #endif - void SocketHandler::RegStdLog(StdLog *log) { m_stdlog = log; } - void SocketHandler::LogError(Socket *p,const std::string& user_text,int err,const std::string& sys_err,loglevel_t t) { if (m_stdlog) @@ -217,7 +208,6 @@ void SocketHandler::LogError(Socket *p,const std::string& user_text,int err,cons } } - void SocketHandler::Add(Socket *p) { if (p -> GetSocket() == INVALID_SOCKET) @@ -238,7 +228,6 @@ void SocketHandler::Add(Socket *p) m_add[p -> GetSocket()] = p; } - void SocketHandler::Get(SOCKET s,bool& r,bool& w,bool& e) { if (s >= 0) @@ -249,7 +238,6 @@ void SocketHandler::Get(SOCKET s,bool& r,bool& w,bool& e) } } - void SocketHandler::Set(SOCKET s,bool bRead,bool bWrite,bool bException) { DEB( fprintf(stderr, "Set(%d, %s, %s, %s)\n", s, bRead ? "true" : "false", bWrite ? "true" : "false", bException ? "true" : "false");) @@ -291,7 +279,6 @@ DEB( fprintf(stderr, "Set(%d, %s, %s, %s)\n", s, bRead ? "true" : "false", bW } } - int SocketHandler::Select(long sec,long usec) { struct timeval tv; @@ -300,7 +287,6 @@ int SocketHandler::Select(long sec,long usec) return Select(&tv); } - int SocketHandler::Select() { if (!m_fds_callonconnect.empty() || @@ -317,7 +303,6 @@ int SocketHandler::Select() return Select(NULL); } - int SocketHandler::Select(struct timeval *tsel) { size_t ignore = 0; @@ -965,7 +950,6 @@ DEB( fprintf(stderr, "Close() before OnDelete\n");) return n; } - #ifdef ENABLE_RESOLVER bool SocketHandler::Resolving(Socket *p0) { @@ -974,7 +958,6 @@ bool SocketHandler::Resolving(Socket *p0) } #endif - bool SocketHandler::Valid(Socket *p0) { for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++) @@ -986,13 +969,11 @@ bool SocketHandler::Valid(Socket *p0) return false; } - bool SocketHandler::OkToAccept(Socket *) { return true; } - size_t SocketHandler::GetCount() { /* @@ -1003,33 +984,28 @@ printf(" m_delete : %d\n", m_delete.size()); return m_sockets.size() + m_add.size() + m_delete.size(); } - #ifdef ENABLE_SOCKS4 void SocketHandler::SetSocks4Host(ipaddr_t a) { m_socks4_host = a; } - void SocketHandler::SetSocks4Host(const std::string& host) { Utility::u2ip(host, m_socks4_host); } - void SocketHandler::SetSocks4Port(port_t port) { m_socks4_port = port; } - void SocketHandler::SetSocks4Userid(const std::string& id) { m_socks4_userid = id; } #endif - #ifdef ENABLE_RESOLVER int SocketHandler::Resolve(Socket *p,const std::string& host,port_t port) { @@ -1049,7 +1025,6 @@ DEB( fprintf(stderr, " *** Resolve '%s:%d' id#%d m_resolve_q size: %d p: %p return resolv -> GetId(); } - #ifdef ENABLE_IPV6 int SocketHandler::Resolve6(Socket *p,const std::string& host,port_t port) { @@ -1069,7 +1044,6 @@ int SocketHandler::Resolve6(Socket *p,const std::string& host,port_t port) } #endif - int SocketHandler::Resolve(Socket *p,ipaddr_t a) { // check cache @@ -1087,7 +1061,6 @@ int SocketHandler::Resolve(Socket *p,ipaddr_t a) return resolv -> GetId(); } - #ifdef ENABLE_IPV6 int SocketHandler::Resolve(Socket *p,in6_addr& a) { @@ -1107,7 +1080,6 @@ int SocketHandler::Resolve(Socket *p,in6_addr& a) } #endif - void SocketHandler::EnableResolver(port_t port) { if (!m_resolver) @@ -1117,60 +1089,51 @@ void SocketHandler::EnableResolver(port_t port) } } - bool SocketHandler::ResolverReady() { return m_resolver ? m_resolver -> Ready() : false; } #endif // ENABLE_RESOLVER - #ifdef ENABLE_SOCKS4 void SocketHandler::SetSocks4TryDirect(bool x) { m_bTryDirect = x; } - ipaddr_t SocketHandler::GetSocks4Host() { return m_socks4_host; } - port_t SocketHandler::GetSocks4Port() { return m_socks4_port; } - const std::string& SocketHandler::GetSocks4Userid() { return m_socks4_userid; } - bool SocketHandler::Socks4TryDirect() { return m_bTryDirect; } #endif - #ifdef ENABLE_RESOLVER bool SocketHandler::ResolverEnabled() { return m_resolver ? true : false; } - port_t SocketHandler::GetResolverPort() { return m_resolver_port; } #endif // ENABLE_RESOLVER - #ifdef ENABLE_POOL ISocketHandler::PoolSocket *SocketHandler::FindConnection(int type,const std::string& protocol,SocketAddress& ad) { @@ -1193,20 +1156,17 @@ ISocketHandler::PoolSocket *SocketHandler::FindConnection(int type,const std::st return NULL; } - void SocketHandler::EnablePool(bool x) { m_b_enable_pool = x; } - bool SocketHandler::PoolEnabled() { return m_b_enable_pool; } #endif - void SocketHandler::Remove(Socket *p) { #ifdef ENABLE_RESOLVER @@ -1247,7 +1207,6 @@ void SocketHandler::Remove(Socket *p) } } - void SocketHandler::CheckSanity() { CheckList(m_fds, "active sockets"); // active sockets @@ -1261,7 +1220,6 @@ void SocketHandler::CheckSanity() CheckList(m_fds_close, "checklist close and delete"); } - void SocketHandler::CheckList(socket_v& ref,const std::string& listname) { for (socket_v::iterator it = ref.begin(); it != ref.end(); it++) @@ -1288,7 +1246,6 @@ void SocketHandler::CheckList(socket_v& ref,const std::string& listname) } } - void SocketHandler::AddList(SOCKET s,list_t which_one,bool add) { if (s == INVALID_SOCKET) @@ -1345,7 +1302,6 @@ DEB( fprintf(stderr, "AddList; %5d: %s: %s\n", s, (which_one == LIST_CALLONC //DEB( fprintf(stderr, "/AddList\n");) } - #ifdef ENABLE_TRIGGERS int SocketHandler::TriggerID(Socket *src) { @@ -1354,7 +1310,6 @@ int SocketHandler::TriggerID(Socket *src) return id; } - bool SocketHandler::Subscribe(int id, Socket *dst) { if (m_trigger_src.find(id) != m_trigger_src.end()) @@ -1372,7 +1327,6 @@ bool SocketHandler::Subscribe(int id, Socket *dst) return false; } - bool SocketHandler::Unsubscribe(int id, Socket *dst) { if (m_trigger_src.find(id) != m_trigger_src.end()) @@ -1390,7 +1344,6 @@ bool SocketHandler::Unsubscribe(int id, Socket *dst) return false; } - void SocketHandler::Trigger(int id, Socket::TriggerData& data, bool erase) { if (m_trigger_src.find(id) != m_trigger_src.end()) @@ -1417,7 +1370,6 @@ void SocketHandler::Trigger(int id, Socket::TriggerData& data, bool erase) } #endif // ENABLE_TRIGGERS - #ifdef SOCKETS_NAMESPACE } #endif diff --git a/dep/src/sockets/StdoutLog.cpp b/dep/src/sockets/StdoutLog.cpp index 998613f0fb2..e745a6d3358 100644 --- a/dep/src/sockets/StdoutLog.cpp +++ b/dep/src/sockets/StdoutLog.cpp @@ -44,8 +44,6 @@ namespace SOCKETS_NAMESPACE { #endif - - void StdoutLog::error(ISocketHandler *,Socket *sock,const std::string& call,int err,const std::string& sys_err,loglevel_t lvl) { time_t t = time(NULL); @@ -93,10 +91,8 @@ void StdoutLog::error(ISocketHandler *,Socket *sock,const std::string& call,int } } - #ifdef SOCKETS_NAMESPACE } #endif - diff --git a/dep/src/sockets/StreamSocket.cpp b/dep/src/sockets/StreamSocket.cpp index c8a3c32e496..009abadad8f 100644 --- a/dep/src/sockets/StreamSocket.cpp +++ b/dep/src/sockets/StreamSocket.cpp @@ -1,12 +1,10 @@ #include "StreamSocket.h" #include "ISocketHandler.h" - #ifdef SOCKETS_NAMESPACE namespace SOCKETS_NAMESPACE { #endif - StreamSocket::StreamSocket(ISocketHandler& h) : Socket(h) ,m_bConnecting(false) ,m_connect_timeout(5) @@ -20,12 +18,10 @@ StreamSocket::StreamSocket(ISocketHandler& h) : Socket(h) { } - StreamSocket::~StreamSocket() { } - void StreamSocket::SetConnecting(bool x) { if (x != m_bConnecting) @@ -42,13 +38,11 @@ void StreamSocket::SetConnecting(bool x) } } - bool StreamSocket::Connecting() { return m_bConnecting; } - bool StreamSocket::Ready() { if (GetSocket() != INVALID_SOCKET && !Connecting() && !CloseAndDelete()) @@ -56,113 +50,94 @@ bool StreamSocket::Ready() return false; } - void StreamSocket::SetConnectTimeout(int x) { m_connect_timeout = x; } - int StreamSocket::GetConnectTimeout() { return m_connect_timeout; } - void StreamSocket::SetFlushBeforeClose(bool x) { m_flush_before_close = x; } - bool StreamSocket::GetFlushBeforeClose() { return m_flush_before_close; } - int StreamSocket::GetConnectionRetry() { return m_connection_retry; } - void StreamSocket::SetConnectionRetry(int x) { m_connection_retry = x; } - int StreamSocket::GetConnectionRetries() { return m_retries; } - void StreamSocket::IncreaseConnectionRetries() { m_retries++; } - void StreamSocket::ResetConnectionRetries() { m_retries = 0; } - void StreamSocket::SetCallOnConnect(bool x) { Handler().AddList(GetSocket(), LIST_CALLONCONNECT, x); m_call_on_connect = x; } - bool StreamSocket::CallOnConnect() { return m_call_on_connect; } - void StreamSocket::SetRetryClientConnect(bool x) { Handler().AddList(GetSocket(), LIST_RETRY, x); m_b_retry_connect = x; } - bool StreamSocket::RetryClientConnect() { return m_b_retry_connect; } - void StreamSocket::SetLineProtocol(bool x) { m_line_protocol = x; } - bool StreamSocket::LineProtocol() { return m_line_protocol; } - void StreamSocket::SetShutdown(int x) { m_shutdown = x; } - int StreamSocket::GetShutdown() { return m_shutdown; } - - #ifdef SOCKETS_NAMESPACE } // namespace SOCKETS_NAMESPACE { #endif diff --git a/dep/src/sockets/TcpSocket.cpp b/dep/src/sockets/TcpSocket.cpp index c4efa05d5bf..5f067b53124 100644 --- a/dep/src/sockets/TcpSocket.cpp +++ b/dep/src/sockets/TcpSocket.cpp @@ -58,20 +58,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. namespace SOCKETS_NAMESPACE { #endif - //#ifdef _DEBUG //#define DEB(x) x //#else #define DEB(x) //#endif - // statics #ifdef HAVE_OPENSSL SSLInitializer TcpSocket::m_ssl_init; #endif - // thanks, q #ifdef _MSC_VER #pragma warning(disable:4355) @@ -109,7 +106,6 @@ TcpSocket::TcpSocket(ISocketHandler& h) : StreamSocket(h) #pragma warning(default:4355) #endif - #ifdef _MSC_VER #pragma warning(disable:4355) #endif @@ -146,7 +142,6 @@ TcpSocket::TcpSocket(ISocketHandler& h,size_t isize,size_t osize) : StreamSocket #pragma warning(default:4355) #endif - TcpSocket::~TcpSocket() { #ifdef SOCKETS_DYNAMIC_TEMP @@ -168,7 +163,6 @@ TcpSocket::~TcpSocket() #endif } - bool TcpSocket::Open(ipaddr_t ip,port_t port,bool skip_socks) { Ipv4Address ad(ip, port); @@ -176,7 +170,6 @@ bool TcpSocket::Open(ipaddr_t ip,port_t port,bool skip_socks) return Open(ad, local, skip_socks); } - #ifdef ENABLE_IPV6 #ifdef IPPROTO_IPV6 bool TcpSocket::Open(in6_addr ip,port_t port,bool skip_socks) @@ -187,14 +180,12 @@ bool TcpSocket::Open(in6_addr ip,port_t port,bool skip_socks) #endif #endif - bool TcpSocket::Open(SocketAddress& ad,bool skip_socks) { Ipv4Address bind_ad("0.0.0.0", 0); return Open(ad, bind_ad, skip_socks); } - bool TcpSocket::Open(SocketAddress& ad,SocketAddress& bind_ad,bool skip_socks) { if (!ad.IsValid()) @@ -320,7 +311,6 @@ bool TcpSocket::Open(SocketAddress& ad,SocketAddress& bind_ad,bool skip_socks) return true; //!Connecting(); } - bool TcpSocket::Open(const std::string &host,port_t port) { #ifdef ENABLE_IPV6 @@ -369,7 +359,6 @@ bool TcpSocket::Open(const std::string &host,port_t port) #endif } - #ifdef ENABLE_RESOLVER void TcpSocket::OnResolved(int id,ipaddr_t a,port_t port) { @@ -401,7 +390,6 @@ DEB( fprintf(stderr, "TcpSocket::OnResolved id %d addr %x port %d\n", id, a, } } - #ifdef ENABLE_IPV6 void TcpSocket::OnResolved(int id,in6_addr& a,port_t port) { @@ -429,7 +417,6 @@ void TcpSocket::OnResolved(int id,in6_addr& a,port_t port) #endif #endif - void TcpSocket::OnRead() { int n = 0; @@ -542,7 +529,6 @@ DEB( fprintf(stderr, "SSL read problem, errcode = %d\n",n);) OnRead( buf, n ); } - void TcpSocket::OnRead( char *buf, size_t n ) { // unbuffered @@ -620,12 +606,10 @@ void TcpSocket::OnRead( char *buf, size_t n ) #endif } - void TcpSocket::OnWriteComplete() { } - void TcpSocket::OnWrite() { if (Connecting()) @@ -718,7 +702,6 @@ void TcpSocket::OnWrite() } } - int TcpSocket::TryWrite(const char *buf, size_t len) { int n = 0; @@ -787,7 +770,6 @@ DEB( int errnr = SSL_get_error(m_ssl, n); return n; } - void TcpSocket::Buffer(const char *buf, size_t len) { size_t ptr = 0; @@ -819,13 +801,11 @@ void TcpSocket::Buffer(const char *buf, size_t len) } } - void TcpSocket::Send(const std::string &str,int i) { SendBuf(str.c_str(),str.size(),i); } - void TcpSocket::SendBuf(const char *buf,size_t len,int) { if (!Ready() && !Connecting()) @@ -876,12 +856,10 @@ void TcpSocket::SendBuf(const char *buf,size_t len,int) } } - void TcpSocket::OnLine(const std::string& ) { } - #ifdef _MSC_VER #pragma warning(disable:4355) #endif @@ -894,7 +872,6 @@ TcpSocket::TcpSocket(const TcpSocket& s) #pragma warning(default:4355) #endif - #ifdef ENABLE_SOCKS4 void TcpSocket::OnSocks4Connect() { @@ -929,7 +906,6 @@ void TcpSocket::OnSocks4Connect() m_socks4_state = 0; } - void TcpSocket::OnSocks4ConnectFailed() { Handler().LogError(this,"OnSocks4ConnectFailed",0,"connection to socks4 server failed, trying direct connection",LOG_LEVEL_WARNING); @@ -945,7 +921,6 @@ void TcpSocket::OnSocks4ConnectFailed() } } - bool TcpSocket::OnSocks4Read() { switch (m_socks4_state) @@ -1005,7 +980,6 @@ bool TcpSocket::OnSocks4Read() } #endif - void TcpSocket::Sendf(const char *format, ...) { va_list ap; @@ -1020,7 +994,6 @@ void TcpSocket::Sendf(const char *format, ...) Send( slask ); } - #ifdef HAVE_OPENSSL void TcpSocket::OnSSLConnect() { @@ -1064,7 +1037,6 @@ DEB( fprintf(stderr, " m_sbio is NULL\n");) } } - void TcpSocket::OnSSLAccept() { SetNonblocking(true); @@ -1103,7 +1075,6 @@ DEB( fprintf(stderr, " m_sbio is NULL\n");) } } - bool TcpSocket::SSLNegotiate() { if (!IsSSLServer()) // client @@ -1200,20 +1171,17 @@ DEB( fprintf(stderr, "SSL_accept() failed - closing socket, retur return false; } - void TcpSocket::InitSSLClient() { InitializeContext("", SSLv23_method()); } - void TcpSocket::InitSSLServer() { Handler().LogError(this, "InitSSLServer", 0, "You MUST implement your own InitSSLServer method", LOG_LEVEL_FATAL); SetCloseAndDelete(); } - void TcpSocket::InitializeContext(const std::string& context, SSL_METHOD *meth_in) { /* Create our context*/ @@ -1230,7 +1198,6 @@ void TcpSocket::InitializeContext(const std::string& context, SSL_METHOD *meth_i } } - void TcpSocket::InitializeContext(const std::string& context,const std::string& keyfile,const std::string& password,SSL_METHOD *meth_in) { /* Create our context*/ @@ -1266,7 +1233,6 @@ void TcpSocket::InitializeContext(const std::string& context,const std::string& } } - void TcpSocket::InitializeContext(const std::string& context,const std::string& certfile,const std::string& keyfile,const std::string& password,SSL_METHOD *meth_in) { /* Create our context*/ @@ -1302,7 +1268,6 @@ void TcpSocket::InitializeContext(const std::string& context,const std::string& } } - int TcpSocket::SSL_password_cb(char *buf,int num,int rwflag,void *userdata) { Socket *p0 = static_cast<Socket *>(userdata); @@ -1317,7 +1282,6 @@ int TcpSocket::SSL_password_cb(char *buf,int num,int rwflag,void *userdata) } #endif // HAVE_OPENSSL - int TcpSocket::Close() { if (GetSocket() == INVALID_SOCKET) // this could happen @@ -1356,7 +1320,6 @@ int TcpSocket::Close() return Socket::Close(); } - #ifdef HAVE_OPENSSL SSL_CTX *TcpSocket::GetSslContext() { @@ -1373,7 +1336,6 @@ SSL *TcpSocket::GetSsl() } #endif - #ifdef ENABLE_RECONNECT void TcpSocket::SetReconnect(bool x) { @@ -1381,24 +1343,20 @@ void TcpSocket::SetReconnect(bool x) } #endif - void TcpSocket::OnRawData(const char *buf_in,size_t len) { } - size_t TcpSocket::GetInputLength() { return ibuf.GetLength(); } - size_t TcpSocket::GetOutputLength() { return m_output_length; } - uint64_t TcpSocket::GetBytesReceived(bool clear) { uint64_t z = m_bytes_received; @@ -1407,7 +1365,6 @@ uint64_t TcpSocket::GetBytesReceived(bool clear) return z; } - uint64_t TcpSocket::GetBytesSent(bool clear) { uint64_t z = m_bytes_sent; @@ -1416,27 +1373,23 @@ uint64_t TcpSocket::GetBytesSent(bool clear) return z; } - #ifdef ENABLE_RECONNECT bool TcpSocket::Reconnect() { return m_b_reconnect; } - void TcpSocket::SetIsReconnect(bool x) { m_b_is_reconnect = x; } - bool TcpSocket::IsReconnect() { return m_b_is_reconnect; } #endif - #ifdef HAVE_OPENSSL const std::string& TcpSocket::GetPassword() { @@ -1444,13 +1397,11 @@ const std::string& TcpSocket::GetPassword() } #endif - void TcpSocket::DisableInputBuffer(bool x) { m_b_input_buffer_disabled = x; } - void TcpSocket::OnOptions(int family,int type,int protocol,SOCKET s) { DEB( fprintf(stderr, "Socket::OnOptions()\n");) @@ -1461,14 +1412,12 @@ DEB( fprintf(stderr, "Socket::OnOptions()\n");) SetSoKeepalive(true); } - void TcpSocket::SetLineProtocol(bool x) { StreamSocket::SetLineProtocol(x); DisableInputBuffer(x); } - bool TcpSocket::SetTcpNodelay(bool x) { #ifdef TCP_NODELAY @@ -1485,7 +1434,6 @@ bool TcpSocket::SetTcpNodelay(bool x) #endif } - TcpSocket::CircularBuffer::CircularBuffer(size_t size) :buf(new char[2 * size]) ,m_max(size) @@ -1496,13 +1444,11 @@ TcpSocket::CircularBuffer::CircularBuffer(size_t size) { } - TcpSocket::CircularBuffer::~CircularBuffer() { delete[] buf; } - bool TcpSocket::CircularBuffer::Write(const char *s,size_t l) { if (m_q + l > m_max) @@ -1532,7 +1478,6 @@ bool TcpSocket::CircularBuffer::Write(const char *s,size_t l) return true; } - bool TcpSocket::CircularBuffer::Read(char *s,size_t l) { if (l > m_q) @@ -1598,31 +1543,26 @@ bool TcpSocket::CircularBuffer::Remove(size_t l) return Read(NULL, l); } - size_t TcpSocket::CircularBuffer::GetLength() { return m_q; } - const char *TcpSocket::CircularBuffer::GetStart() { return buf + m_b; } - size_t TcpSocket::CircularBuffer::GetL() { return (m_b + m_q > m_max) ? m_max - m_b : m_q; } - size_t TcpSocket::CircularBuffer::Space() { return m_max - m_q; } - unsigned long TcpSocket::CircularBuffer::ByteCounter(bool clear) { if (clear) @@ -1634,7 +1574,6 @@ unsigned long TcpSocket::CircularBuffer::ByteCounter(bool clear) return m_count; } - std::string TcpSocket::CircularBuffer::ReadString(size_t l) { char *sz = new char[l + 1]; @@ -1649,7 +1588,6 @@ std::string TcpSocket::CircularBuffer::ReadString(size_t l) return tmp; } - void TcpSocket::OnConnectTimeout() { Handler().LogError(this, "connect", -1, "connect timeout", LOG_LEVEL_FATAL); @@ -1687,7 +1625,6 @@ void TcpSocket::OnConnectTimeout() SetConnecting(false); } - #ifdef _WIN32 void TcpSocket::OnException() { @@ -1723,24 +1660,20 @@ void TcpSocket::OnException() } #endif // _WIN32 - int TcpSocket::Protocol() { return IPPROTO_TCP; } - void TcpSocket::SetTransferLimit(size_t sz) { m_transfer_limit = sz; } - void TcpSocket::OnTransferLimit() { } - #ifdef SOCKETS_NAMESPACE } #endif diff --git a/dep/src/sockets/Thread.cpp b/dep/src/sockets/Thread.cpp index a387a7e3824..773e9f214fa 100644 --- a/dep/src/sockets/Thread.cpp +++ b/dep/src/sockets/Thread.cpp @@ -37,12 +37,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Thread.h" - #ifdef SOCKETS_NAMESPACE namespace SOCKETS_NAMESPACE { #endif - Thread::Thread(bool release) :m_thread(0) ,m_running(true) @@ -68,7 +66,6 @@ Thread::Thread(bool release) m_release = release; } - Thread::~Thread() { m_b_destructor = true; @@ -88,7 +85,6 @@ Thread::~Thread() #endif } - threadfunc_t STDPREFIX Thread::StartThread(threadparam_t zz) { Thread *p = (Thread *)zz; @@ -116,52 +112,43 @@ threadfunc_t STDPREFIX Thread::StartThread(threadparam_t zz) return (threadfunc_t)NULL; } - bool Thread::IsRunning() { return m_running; } - void Thread::SetRunning(bool x) { m_running = x; } - bool Thread::IsReleased() { return m_release; } - void Thread::SetRelease(bool x) { m_release = x; } - bool Thread::DeleteOnExit() { return m_b_delete_on_exit; } - void Thread::SetDeleteOnExit(bool x) { m_b_delete_on_exit = x; } - bool Thread::IsDestructor() { return m_b_destructor; } - #ifdef SOCKETS_NAMESPACE } #endif - diff --git a/dep/src/sockets/UdpSocket.cpp b/dep/src/sockets/UdpSocket.cpp index f4c3d2f9657..a3d393c00e2 100644 --- a/dep/src/sockets/UdpSocket.cpp +++ b/dep/src/sockets/UdpSocket.cpp @@ -47,12 +47,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // include this to see strange sights //#include <linux/in6.h> - #ifdef SOCKETS_NAMESPACE namespace SOCKETS_NAMESPACE { #endif - UdpSocket::UdpSocket(ISocketHandler& h, int ibufsz, bool ipv6, int retries) : Socket(h) , m_ibuf(new char[ibufsz]) , m_ibufsz(ibufsz) @@ -69,14 +67,12 @@ UdpSocket::UdpSocket(ISocketHandler& h, int ibufsz, bool ipv6, int retries) : So #endif } - UdpSocket::~UdpSocket() { Close(); delete[] m_ibuf; } - int UdpSocket::Bind(port_t &port, int range) { #ifdef ENABLE_IPV6 @@ -92,7 +88,6 @@ int UdpSocket::Bind(port_t &port, int range) return Bind(ad, range); } - int UdpSocket::Bind(const std::string& intf, port_t &port, int range) { #ifdef ENABLE_IPV6 @@ -118,14 +113,12 @@ int UdpSocket::Bind(const std::string& intf, port_t &port, int range) return -1; } - int UdpSocket::Bind(ipaddr_t a, port_t &port, int range) { Ipv4Address ad(a, port); return Bind(ad, range); } - #ifdef ENABLE_IPV6 #ifdef IPPROTO_IPV6 int UdpSocket::Bind(in6_addr a, port_t &port, int range) @@ -136,7 +129,6 @@ int UdpSocket::Bind(in6_addr a, port_t &port, int range) #endif #endif - int UdpSocket::Bind(SocketAddress& ad, int range) { if (GetSocket() == INVALID_SOCKET) @@ -169,7 +161,6 @@ int UdpSocket::Bind(SocketAddress& ad, int range) return -1; } - /** if you wish to use Send, first Open a connection */ bool UdpSocket::Open(ipaddr_t l, port_t port) { @@ -177,7 +168,6 @@ bool UdpSocket::Open(ipaddr_t l, port_t port) return Open(ad); } - bool UdpSocket::Open(const std::string& host, port_t port) { #ifdef ENABLE_IPV6 @@ -201,7 +191,6 @@ bool UdpSocket::Open(const std::string& host, port_t port) return false; } - #ifdef ENABLE_IPV6 #ifdef IPPROTO_IPV6 bool UdpSocket::Open(struct in6_addr& a, port_t port) @@ -212,7 +201,6 @@ bool UdpSocket::Open(struct in6_addr& a, port_t port) #endif #endif - bool UdpSocket::Open(SocketAddress& ad) { if (GetSocket() == INVALID_SOCKET) @@ -234,7 +222,6 @@ bool UdpSocket::Open(SocketAddress& ad) return false; } - void UdpSocket::CreateConnection() { #ifdef ENABLE_IPV6 @@ -267,7 +254,6 @@ void UdpSocket::CreateConnection() } } - /** send to specified address */ void UdpSocket::SendToBuf(const std::string& h, port_t p, const char *data, int len, int flags) { @@ -291,7 +277,6 @@ void UdpSocket::SendToBuf(const std::string& h, port_t p, const char *data, int } } - /** send to specified address */ void UdpSocket::SendToBuf(ipaddr_t a, port_t p, const char *data, int len, int flags) { @@ -299,7 +284,6 @@ void UdpSocket::SendToBuf(ipaddr_t a, port_t p, const char *data, int len, int f SendToBuf(ad, data, len, flags); } - #ifdef ENABLE_IPV6 #ifdef IPPROTO_IPV6 void UdpSocket::SendToBuf(in6_addr a, port_t p, const char *data, int len, int flags) @@ -310,7 +294,6 @@ void UdpSocket::SendToBuf(in6_addr a, port_t p, const char *data, int len, int f #endif #endif - void UdpSocket::SendToBuf(SocketAddress& ad, const char *data, int len, int flags) { if (GetSocket() == INVALID_SOCKET) @@ -327,19 +310,16 @@ void UdpSocket::SendToBuf(SocketAddress& ad, const char *data, int len, int flag } } - void UdpSocket::SendTo(const std::string& a, port_t p, const std::string& str, int flags) { SendToBuf(a, p, str.c_str(), (int)str.size(), flags); } - void UdpSocket::SendTo(ipaddr_t a, port_t p, const std::string& str, int flags) { SendToBuf(a, p, str.c_str(), (int)str.size(), flags); } - #ifdef ENABLE_IPV6 #ifdef IPPROTO_IPV6 void UdpSocket::SendTo(in6_addr a, port_t p, const std::string& str, int flags) @@ -349,13 +329,11 @@ void UdpSocket::SendTo(in6_addr a, port_t p, const std::string& str, int flags) #endif #endif - void UdpSocket::SendTo(SocketAddress& ad, const std::string& str, int flags) { SendToBuf(ad, str.c_str(), (int)str.size(), flags); } - /** send to connected address */ void UdpSocket::SendBuf(const char *data, size_t len, int flags) { @@ -370,13 +348,11 @@ void UdpSocket::SendBuf(const char *data, size_t len, int flags) } } - void UdpSocket::Send(const std::string& str, int flags) { SendBuf(str.c_str(), (int)str.size(), flags); } - #if defined(LINUX) || defined(MACOSX) int UdpSocket::ReadTS(char *ioBuf, int inBufSize, struct sockaddr *from, socklen_t fromlen, struct timeval *ts) { @@ -442,7 +418,6 @@ int UdpSocket::ReadTS(char *ioBuf, int inBufSize, struct sockaddr *from, socklen } #endif - void UdpSocket::OnRead() { #ifdef ENABLE_IPV6 @@ -555,7 +530,6 @@ void UdpSocket::OnRead() } } - void UdpSocket::SetBroadcast(bool b) { int one = 1; @@ -581,7 +555,6 @@ void UdpSocket::SetBroadcast(bool b) } } - bool UdpSocket::IsBroadcast() { int is_broadcast = 0; @@ -598,7 +571,6 @@ bool UdpSocket::IsBroadcast() return is_broadcast != 0; } - void UdpSocket::SetMulticastTTL(int ttl) { if (GetSocket() == INVALID_SOCKET) @@ -611,7 +583,6 @@ void UdpSocket::SetMulticastTTL(int ttl) } } - int UdpSocket::GetMulticastTTL() { int ttl = 0; @@ -628,7 +599,6 @@ int UdpSocket::GetMulticastTTL() return ttl; } - void UdpSocket::SetMulticastLoop(bool x) { if (GetSocket() == INVALID_SOCKET) @@ -655,7 +625,6 @@ void UdpSocket::SetMulticastLoop(bool x) } } - bool UdpSocket::IsMulticastLoop() { if (GetSocket() == INVALID_SOCKET) @@ -685,7 +654,6 @@ bool UdpSocket::IsMulticastLoop() return is_loop ? true : false; } - void UdpSocket::AddMulticastMembership(const std::string& group, const std::string& local_if, int if_index) { if (GetSocket() == INVALID_SOCKET) @@ -726,7 +694,6 @@ void UdpSocket::AddMulticastMembership(const std::string& group, const std::stri } } - void UdpSocket::DropMulticastMembership(const std::string& group, const std::string& local_if, int if_index) { if (GetSocket() == INVALID_SOCKET) @@ -767,7 +734,6 @@ void UdpSocket::DropMulticastMembership(const std::string& group, const std::str } } - #ifdef ENABLE_IPV6 #ifdef IPPROTO_IPV6 void UdpSocket::SetMulticastHops(int hops) @@ -787,7 +753,6 @@ void UdpSocket::SetMulticastHops(int hops) } } - int UdpSocket::GetMulticastHops() { if (GetSocket() == INVALID_SOCKET) @@ -810,44 +775,36 @@ int UdpSocket::GetMulticastHops() #endif // IPPROTO_IPV6 #endif - bool UdpSocket::IsBound() { return m_bind_ok; } - void UdpSocket::OnRawData(const char *buf, size_t len, struct sockaddr *sa, socklen_t sa_len) { } - void UdpSocket::OnRawData(const char *buf, size_t len, struct sockaddr *sa, socklen_t sa_len, struct timeval *ts) { } - port_t UdpSocket::GetPort() { return m_port; } - int UdpSocket::GetLastSizeWritten() { return m_last_size_written; } - void UdpSocket::SetTimestamp(bool x) { m_b_read_ts = x; } - #ifdef SOCKETS_NAMESPACE } #endif - diff --git a/dep/src/sockets/Utility.cpp b/dep/src/sockets/Utility.cpp index 6473f0a2564..7c093fc0832 100644 --- a/dep/src/sockets/Utility.cpp +++ b/dep/src/sockets/Utility.cpp @@ -45,7 +45,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. namespace SOCKETS_NAMESPACE { #endif - // defines for the random number generator #define TWIST_IA 397 #define TWIST_IB (TWIST_LEN - TWIST_IA) @@ -55,7 +54,6 @@ namespace SOCKETS_NAMESPACE { #define TWIST(b,i,j) ((b)[i] & UMASK) | ((b)[j] & LMASK) #define MAGIC_TWIST(s) (((s) & 1) * MATRIX_A) - // statics std::string Utility::m_host; bool Utility::m_local_resolved = false; @@ -68,7 +66,6 @@ std::string Utility::m_local_addr6; #endif #endif - std::string Utility::base64(const std::string& str_in) { std::string str; @@ -77,7 +74,6 @@ std::string Utility::base64(const std::string& str_in) return str; } - std::string Utility::base64d(const std::string& str_in) { std::string str; @@ -86,7 +82,6 @@ std::string Utility::base64d(const std::string& str_in) return str; } - std::string Utility::l2string(long l) { std::string str; @@ -96,7 +91,6 @@ std::string Utility::l2string(long l) return str; } - std::string Utility::bigint2string(uint64_t l) { std::string str; @@ -114,7 +108,6 @@ std::string Utility::bigint2string(uint64_t l) return str; } - uint64_t Utility::atoi64(const std::string& str) { uint64_t l = 0; @@ -125,7 +118,6 @@ uint64_t Utility::atoi64(const std::string& str) return l; } - unsigned int Utility::hex2unsigned(const std::string& str) { unsigned int r = 0; @@ -136,7 +128,6 @@ unsigned int Utility::hex2unsigned(const std::string& str) return r; } - /* * Encode string per RFC1738 URL encoding rules * tnx rstaveley @@ -167,7 +158,6 @@ static char hex[] = "0123456789ABCDEF"; return dst; } // rfc1738_encode - /* * Decode string per RFC1738 URL encoding rules * tnx rstaveley @@ -198,7 +188,6 @@ std::string Utility::rfc1738_decode(const std::string& src) return dst; } // rfc1738_decode - bool Utility::isipv4(const std::string& str) { int dots = 0; @@ -216,7 +205,6 @@ bool Utility::isipv4(const std::string& str) return true; } - bool Utility::isipv6(const std::string& str) { size_t qc = 0; @@ -256,7 +244,6 @@ bool Utility::isipv6(const std::string& str) return true; } - bool Utility::u2ip(const std::string& str, ipaddr_t& l) { struct sockaddr_in sa; @@ -265,7 +252,6 @@ bool Utility::u2ip(const std::string& str, ipaddr_t& l) return r; } - #ifdef ENABLE_IPV6 #ifdef IPPROTO_IPV6 bool Utility::u2ip(const std::string& str, struct in6_addr& l) @@ -278,7 +264,6 @@ bool Utility::u2ip(const std::string& str, struct in6_addr& l) #endif #endif - void Utility::l2ip(const ipaddr_t ip, std::string& str) { struct sockaddr_in sa; @@ -288,7 +273,6 @@ void Utility::l2ip(const ipaddr_t ip, std::string& str) Utility::reverse( (struct sockaddr *)&sa, sizeof(sa), str, NI_NUMERICHOST); } - void Utility::l2ip(const in_addr& ip, std::string& str) { struct sockaddr_in sa; @@ -298,7 +282,6 @@ void Utility::l2ip(const in_addr& ip, std::string& str) Utility::reverse( (struct sockaddr *)&sa, sizeof(sa), str, NI_NUMERICHOST); } - #ifdef ENABLE_IPV6 #ifdef IPPROTO_IPV6 void Utility::l2ip(const struct in6_addr& ip, std::string& str,bool mixed) @@ -347,7 +330,6 @@ void Utility::l2ip(const struct in6_addr& ip, std::string& str,bool mixed) str = slask; } - int Utility::in6_addr_compare(in6_addr a,in6_addr b) { for (size_t i = 0; i < 16; i++) @@ -362,7 +344,6 @@ int Utility::in6_addr_compare(in6_addr a,in6_addr b) #endif #endif - void Utility::ResolveLocal() { char h[256]; @@ -391,7 +372,6 @@ void Utility::ResolveLocal() m_local_resolved = true; } - const std::string& Utility::GetLocalHostname() { if (!m_local_resolved) @@ -401,7 +381,6 @@ const std::string& Utility::GetLocalHostname() return m_host; } - ipaddr_t Utility::GetLocalIP() { if (!m_local_resolved) @@ -411,7 +390,6 @@ ipaddr_t Utility::GetLocalIP() return m_ip; } - const std::string& Utility::GetLocalAddress() { if (!m_local_resolved) @@ -421,7 +399,6 @@ const std::string& Utility::GetLocalAddress() return m_addr; } - #ifdef ENABLE_IPV6 #ifdef IPPROTO_IPV6 const struct in6_addr& Utility::GetLocalIP6() @@ -433,7 +410,6 @@ const struct in6_addr& Utility::GetLocalIP6() return m_local_ip6; } - const std::string& Utility::GetLocalAddress6() { if (!m_local_resolved) @@ -445,7 +421,6 @@ const std::string& Utility::GetLocalAddress6() #endif #endif - void Utility::SetEnv(const std::string& var,const std::string& value) { #if (defined(SOLARIS8) || defined(SOLARIS)) @@ -469,7 +444,6 @@ void Utility::SetEnv(const std::string& var,const std::string& value) #endif } - std::string Utility::Sa2String(struct sockaddr *sa) { #ifdef ENABLE_IPV6 @@ -495,7 +469,6 @@ std::string Utility::Sa2String(struct sockaddr *sa) return ""; } - void Utility::GetTime(struct timeval *p) { #ifdef _WIN32 @@ -511,7 +484,6 @@ void Utility::GetTime(struct timeval *p) #endif } - std::auto_ptr<SocketAddress> Utility::CreateAddress(struct sockaddr *sa,socklen_t sa_len) { switch (sa -> sa_family) @@ -538,7 +510,6 @@ std::auto_ptr<SocketAddress> Utility::CreateAddress(struct sockaddr *sa,socklen_ return std::auto_ptr<SocketAddress>(NULL); } - bool Utility::u2ip(const std::string& host, struct sockaddr_in& sa, int ai_flags) { memset(&sa, 0, sizeof(sa)); @@ -631,7 +602,6 @@ bool Utility::u2ip(const std::string& host, struct sockaddr_in& sa, int ai_flags #endif // NO_GETADDRINFO } - #ifdef ENABLE_IPV6 #ifdef IPPROTO_IPV6 bool Utility::u2ip(const std::string& host, struct sockaddr_in6& sa, int ai_flags) @@ -747,14 +717,12 @@ bool Utility::u2ip(const std::string& host, struct sockaddr_in6& sa, int ai_flag #endif // IPPROTO_IPV6 #endif // ENABLE_IPV6 - bool Utility::reverse(struct sockaddr *sa, socklen_t sa_len, std::string& hostname, int flags) { std::string service; return Utility::reverse(sa, sa_len, hostname, service, flags); } - bool Utility::reverse(struct sockaddr *sa, socklen_t sa_len, std::string& hostname, std::string& service, int flags) { hostname = ""; @@ -870,7 +838,6 @@ bool Utility::reverse(struct sockaddr *sa, socklen_t sa_len, std::string& hostna #endif // NO_GETADDRINFO } - bool Utility::u2service(const std::string& name, int& service, int ai_flags) { #ifdef NO_GETADDRINFO @@ -903,7 +870,6 @@ bool Utility::u2service(const std::string& name, int& service, int ai_flags) #endif // NO_GETADDRINFO } - unsigned long Utility::ThreadID() { #ifdef _WIN32 @@ -913,7 +879,6 @@ unsigned long Utility::ThreadID() #endif } - std::string Utility::ToLower(const std::string& str) { std::string r; @@ -927,7 +892,6 @@ std::string Utility::ToLower(const std::string& str) return r; } - std::string Utility::ToUpper(const std::string& str) { std::string r; @@ -941,7 +905,6 @@ std::string Utility::ToUpper(const std::string& str) return r; } - std::string Utility::ToString(double d) { char tmp[100]; @@ -949,14 +912,12 @@ std::string Utility::ToString(double d) return tmp; } - unsigned long Utility::Rnd() { static Utility::Rng generator( (unsigned long)time(NULL) ); return generator.Get(); } - Utility::Rng::Rng(unsigned long seed) : m_value( 0 ) { m_tmp[0]= seed & 0xffffffffUL; @@ -966,7 +927,6 @@ Utility::Rng::Rng(unsigned long seed) : m_value( 0 ) } } - unsigned long Utility::Rng::Get() { unsigned long val = m_tmp[m_value]; diff --git a/dep/src/sockets/socket_include.cpp b/dep/src/sockets/socket_include.cpp index 133ff745d91..290602c1b52 100644 --- a/dep/src/sockets/socket_include.cpp +++ b/dep/src/sockets/socket_include.cpp @@ -87,5 +87,3 @@ static char tmp[100]; } - - diff --git a/dep/src/zlib/deflate.c b/dep/src/zlib/deflate.c index 29ce1f64a57..2ed78a7d2a1 100644 --- a/dep/src/zlib/deflate.c +++ b/dep/src/zlib/deflate.c @@ -169,7 +169,6 @@ struct static_tree_desc_s {int dummy;}; /* for buggy compilers */ */ #define UPDATE_HASH(s,h,c) (h = (((h)<<s->hash_shift) ^ (c)) & s->hash_mask) - /* =========================================================================== * Insert string str in the dictionary and set match_head to the previous head * of the hash chain (the most recent string with same hash key). Return @@ -902,7 +901,6 @@ int ZEXPORT deflateCopy (dest, source) deflate_state *ss; ushf *overlay; - if (source == Z_NULL || dest == Z_NULL || source->state == Z_NULL) { return Z_STREAM_ERROR; } @@ -1402,7 +1400,7 @@ local block_state deflate_stored(s, flush) } /* Copy as much as possible from input to output: */ - for (;;) { + for (; ; ) { /* Fill the window as much as possible: */ if (s->lookahead <= 1) { @@ -1452,7 +1450,7 @@ local block_state deflate_fast(s, flush) IPos hash_head = NIL; /* head of the hash chain */ int bflush; /* set if current block must be flushed */ - for (;;) { + for (; ; ) { /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes * for the next match, plus MIN_MATCH bytes to insert the @@ -1559,7 +1557,7 @@ local block_state deflate_slow(s, flush) int bflush; /* set if current block must be flushed */ /* Process the input block. */ - for (;;) { + for (; ; ) { /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes * for the next match, plus MIN_MATCH bytes to insert the @@ -1690,7 +1688,7 @@ local block_state deflate_rle(s, flush) uInt prev; /* byte at distance one to match */ Bytef *scan; /* scan for end of run */ - for (;;) { + for (; ; ) { /* Make sure that we always have enough lookahead, except * at the end of the input file. We need MAX_MATCH bytes * for the longest encodable run. diff --git a/dep/src/zlib/deflate.h b/dep/src/zlib/deflate.h index d56e97db4cb..ad1f46a8dae 100644 --- a/dep/src/zlib/deflate.h +++ b/dep/src/zlib/deflate.h @@ -57,7 +57,6 @@ #define FINISH_STATE 666 /* Stream status */ - /* Data structure describing a single value and its code string. */ typedef struct ct_data_s { union { @@ -267,7 +266,6 @@ typedef struct internal_state { */ #define put_byte(s, c) {s->pending_buf[s->pending++] = (c);} - #define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1) /* Minimum amount of lookahead, except at the end of the input file. * See deflate.c for comments about the MIN_MATCH+1. diff --git a/dep/src/zlib/example.c b/dep/src/zlib/example.c index 6c8a0ee7633..73799eac8cc 100644 --- a/dep/src/zlib/example.c +++ b/dep/src/zlib/example.c @@ -190,7 +190,7 @@ void test_deflate(compr, comprLen) CHECK_ERR(err, "deflate"); } /* Finish the stream, still forcing small buffers: */ - for (;;) { + for (; ; ) { c_stream.avail_out = 1; err = deflate(&c_stream, Z_FINISH); if (err == Z_STREAM_END) break; @@ -319,7 +319,7 @@ void test_large_inflate(compr, comprLen, uncompr, uncomprLen) err = inflateInit(&d_stream); CHECK_ERR(err, "inflateInit"); - for (;;) { + for (; ; ) { d_stream.next_out = uncompr; /* discard the output */ d_stream.avail_out = (uInt)uncomprLen; err = inflate(&d_stream, Z_NO_FLUSH); @@ -482,7 +482,7 @@ void test_dict_inflate(compr, comprLen, uncompr, uncomprLen) d_stream.next_out = uncompr; d_stream.avail_out = (uInt)uncomprLen; - for (;;) { + for (; ; ) { err = inflate(&d_stream, Z_NO_FLUSH); if (err == Z_STREAM_END) break; if (err == Z_NEED_DICT) { diff --git a/dep/src/zlib/gzio.c b/dep/src/zlib/gzio.c index 7e90f4928fc..64dcae88107 100644 --- a/dep/src/zlib/gzio.c +++ b/dep/src/zlib/gzio.c @@ -72,7 +72,6 @@ typedef struct gz_stream { int last; /* true if push-back is last character */ } gz_stream; - local gzFile gz_open OF((const char *path, const char *mode, int fd)); local int do_flush OF((gzFile file, int flush)); local int get_byte OF((gz_stream *s)); @@ -495,7 +494,6 @@ int ZEXPORT gzread (file, buf, len) return (int)(len - s->stream.avail_out); } - /* =========================================================================== Reads one byte from the compressed file. gzgetc returns this byte or -1 in case of end of file or error. @@ -508,7 +506,6 @@ int ZEXPORT gzgetc(file) return gzread(file, &c, 1) == 1 ? c : -1; } - /* =========================================================================== Push one byte back onto the stream. */ @@ -527,7 +524,6 @@ int ZEXPORT gzungetc(c, file) return c; } - /* =========================================================================== Reads bytes from the compressed file until len-1 characters are read, or a newline character is read and transferred to buf, or an @@ -550,7 +546,6 @@ char * ZEXPORT gzgets(file, buf, len) return b == buf && len > 0 ? Z_NULL : b; } - #ifndef NO_GZCOMPRESS /* =========================================================================== Writes the given number of uncompressed bytes into the compressed file. @@ -591,7 +586,6 @@ int ZEXPORT gzwrite (file, buf, len) return (int)(len - s->stream.avail_in); } - /* =========================================================================== Converts, formats, and writes the args to the compressed file under control of the format string, as in fprintf. gzprintf returns the number of @@ -684,7 +678,6 @@ int ZEXPORT gzputc(file, c) return gzwrite(file, &cc, 1) == 1 ? (int)cc : -1; } - /* =========================================================================== Writes the given null-terminated string to the compressed file, excluding the terminating null character. @@ -697,7 +690,6 @@ int ZEXPORT gzputs(file, s) return gzwrite(file, (char*)s, (unsigned)strlen(s)); } - /* =========================================================================== Flushes all pending output into the compressed file. The parameter flush is as in the deflate() function. @@ -714,7 +706,7 @@ local int do_flush (file, flush) s->stream.avail_in = 0; /* should be zero already anyway */ - for (;;) { + for (; ; ) { len = Z_BUFSIZE - s->stream.avail_out; if (len != 0) { diff --git a/dep/src/zlib/infback.c b/dep/src/zlib/infback.c index 455dbc9ee84..781be49c171 100644 --- a/dep/src/zlib/infback.c +++ b/dep/src/zlib/infback.c @@ -278,7 +278,7 @@ void FAR *out_desc; left = state->wsize; /* Inflate until end of block marked as last */ - for (;;) + for (; ; ) switch (state->mode) { case TYPE: /* determine and dispatch block type */ @@ -388,7 +388,7 @@ void FAR *out_desc; /* get length and distance code code lengths */ state->have = 0; while (state->have < state->nlen + state->ndist) { - for (;;) { + for (; ; ) { this = state->lencode[BITS(state->lenbits)]; if ((unsigned)(this.bits) <= bits) break; PULLBYTE(); @@ -473,14 +473,14 @@ void FAR *out_desc; } /* get a literal, length, or end-of-block code */ - for (;;) { + for (; ; ) { this = state->lencode[BITS(state->lenbits)]; if ((unsigned)(this.bits) <= bits) break; PULLBYTE(); } if (this.op && (this.op & 0xf0) == 0) { last = this; - for (;;) { + for (; ; ) { this = state->lencode[last.val + (BITS(last.bits + last.op) >> last.bits)]; if ((unsigned)(last.bits + this.bits) <= bits) break; @@ -527,14 +527,14 @@ void FAR *out_desc; Tracevv((stderr, "inflate: length %u\n", state->length)); /* get distance code */ - for (;;) { + for (; ; ) { this = state->distcode[BITS(state->distbits)]; if ((unsigned)(this.bits) <= bits) break; PULLBYTE(); } if ((this.op & 0xf0) == 0) { last = this; - for (;;) { + for (; ; ) { this = state->distcode[last.val + (BITS(last.bits + last.op) >> last.bits)]; if ((unsigned)(last.bits + this.bits) <= bits) break; diff --git a/dep/src/zlib/inflate.c b/dep/src/zlib/inflate.c index 792fdee8e9c..6b7a57e747c 100644 --- a/dep/src/zlib/inflate.c +++ b/dep/src/zlib/inflate.c @@ -62,7 +62,7 @@ * 1.2.beta6 4 Jan 2003 * - Added comments in inffast.c on effectiveness of POSTINC * - Typecasting all around to reduce compiler warnings - * - Changed loops from while (1) or do {} while (1) to for (;;), again to + * - Changed loops from while (1) or do {} while (1) to for (; ; ), again to * make compilers happy * - Changed type of window in inflateBackInit() to unsigned char * * @@ -284,7 +284,7 @@ void makefixed() size = 1U << 9; printf(" static const code lenfix[%u] = {", size); low = 0; - for (;;) { + for (; ; ) { if ((low % 7) == 0) printf("\n "); printf("{%u,%u,%d}", state.lencode[low].op, state.lencode[low].bits, state.lencode[low].val); @@ -295,7 +295,7 @@ void makefixed() size = 1U << 5; printf("\n static const code distfix[%u] = {", size); low = 0; - for (;;) { + for (; ; ) { if ((low % 6) == 0) printf("\n "); printf("{%u,%u,%d}", state.distcode[low].op, state.distcode[low].bits, state.distcode[low].val); @@ -474,7 +474,7 @@ unsigned out; much output data as possible before returning. The state machine is structured roughly as follows: - for (;;) switch (state) { + for (; ; ) switch (state) { ... case STATEn: if (not enough input data or output space to make progress) @@ -584,7 +584,7 @@ int flush; in = have; out = left; ret = Z_OK; - for (;;) + for (; ; ) switch (state->mode) { case HEAD: if (state->wrap == 0) { @@ -875,7 +875,7 @@ int flush; state->mode = CODELENS; case CODELENS: while (state->have < state->nlen + state->ndist) { - for (;;) { + for (; ; ) { this = state->lencode[BITS(state->lenbits)]; if ((unsigned)(this.bits) <= bits) break; PULLBYTE(); @@ -954,14 +954,14 @@ int flush; LOAD(); break; } - for (;;) { + for (; ; ) { this = state->lencode[BITS(state->lenbits)]; if ((unsigned)(this.bits) <= bits) break; PULLBYTE(); } if (this.op && (this.op & 0xf0) == 0) { last = this; - for (;;) { + for (; ; ) { this = state->lencode[last.val + (BITS(last.bits + last.op) >> last.bits)]; if ((unsigned)(last.bits + this.bits) <= bits) break; @@ -999,14 +999,14 @@ int flush; Tracevv((stderr, "inflate: length %u\n", state->length)); state->mode = DIST; case DIST: - for (;;) { + for (; ; ) { this = state->distcode[BITS(state->distbits)]; if ((unsigned)(this.bits) <= bits) break; PULLBYTE(); } if ((this.op & 0xf0) == 0) { last = this; - for (;;) { + for (; ; ) { this = state->distcode[last.val + (BITS(last.bits + last.op) >> last.bits)]; if ((unsigned)(last.bits + this.bits) <= bits) break; diff --git a/dep/src/zlib/inftrees.c b/dep/src/zlib/inftrees.c index 8a9c13ff03d..3a3fabc4bea 100644 --- a/dep/src/zlib/inftrees.c +++ b/dep/src/zlib/inftrees.c @@ -213,7 +213,7 @@ unsigned short FAR *work; return 1; /* process all codes and make table entries */ - for (;;) { + for (; ; ) { /* create table entry */ this.bits = (unsigned char)(len - drop); if ((int)(work[sym]) < end) { diff --git a/dep/src/zlib/trees.c b/dep/src/zlib/trees.c index 395e4e16814..bf8720a8b32 100644 --- a/dep/src/zlib/trees.c +++ b/dep/src/zlib/trees.c @@ -229,7 +229,6 @@ local void send_bits(s, value, length) } #endif /* DEBUG */ - /* the arguments must not have side effects */ /* =========================================================================== @@ -281,7 +280,7 @@ local void tr_static_init() } Assert (dist == 256, "tr_static_init: dist != 256"); dist >>= 7; /* from now on, all distances are divided by 128 */ - for ( ; code < D_CODES; code++) { + for (; code < D_CODES; code++) { base_dist[code] = dist << 7; for (n = 0; n < (1<<(extra_dbits[code]-7)); n++) { _dist_code[256 + dist++] = (uch)code; @@ -414,8 +413,8 @@ local void init_block(s) int n; /* iterates over tree elements */ /* Initialize the trees. */ - for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; - for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; + for (n = 0; n < L_CODES; n++) s->dyn_ltree[n].Freq = 0; + for (n = 0; n < D_CODES; n++) s->dyn_dtree[n].Freq = 0; for (n = 0; n < BL_CODES; n++) s->bl_tree[n].Freq = 0; s->dyn_ltree[END_BLOCK].Freq = 1; @@ -426,7 +425,6 @@ local void init_block(s) #define SMALLEST 1 /* Index within the heap array of least frequent node in the Huffman tree */ - /* =========================================================================== * Remove the smallest element from the heap and recreate the heap with * one less element. Updates heap and heap_len. @@ -597,7 +595,7 @@ local void gen_codes (tree, max_code, bl_count) "inconsistent bit counts"); Tracev((stderr,"\ngen_codes: max_code %d ", max_code)); - for (n = 0; n <= max_code; n++) { + for (n = 0; n <= max_code; n++) { int len = tree[n].Len; if (len == 0) continue; /* Now reverse the bits */ diff --git a/dep/src/zlib/zlib.h b/dep/src/zlib/zlib.h index 2ad74617098..3898076f565 100644 --- a/dep/src/zlib/zlib.h +++ b/dep/src/zlib/zlib.h @@ -22,7 +22,6 @@ Jean-loup Gailly Mark Adler jloup@gzip.org madler@alumni.caltech.edu - The data format used by the zlib library is described by RFCs (Request for Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). @@ -238,7 +237,6 @@ ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); perform any compression: this will be done by deflate(). */ - ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); /* deflate compresses as much data as possible, and stops when the input @@ -324,7 +322,6 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); space to continue compressing. */ - ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); /* All dynamically allocated data structures for this stream are freed. @@ -338,7 +335,6 @@ ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); deallocated). */ - /* ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); @@ -359,7 +355,6 @@ ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); avail_in may be modified, but next_out and avail_out are unchanged.) */ - ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); /* inflate decompresses as much data as possible, and stops when the input @@ -458,7 +453,6 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); of the data is desired. */ - ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); /* All dynamically allocated data structures for this stream are freed. @@ -995,7 +989,6 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); 27-31: 0 (reserved) */ - /* utility functions */ /* @@ -1062,7 +1055,6 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. */ - typedef voidp gzFile; ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); @@ -1308,7 +1300,6 @@ ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); len2. */ - /* various hacks, don't look :) */ /* deflateInit and inflateInit are macros to allow checking the zlib version @@ -1341,7 +1332,6 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, inflateBackInit_((strm), (windowBits), (window), \ ZLIB_VERSION, sizeof(z_stream)) - #if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) struct internal_state {int dummy;}; /* hack for buggy compilers */ #endif diff --git a/dep/src/zlib/zutil.c b/dep/src/zlib/zutil.c index d55f5948a37..9116a331be4 100644 --- a/dep/src/zlib/zutil.c +++ b/dep/src/zlib/zutil.c @@ -23,7 +23,6 @@ const char * const z_errmsg[10] = { "incompatible version",/* Z_VERSION_ERROR (-6) */ ""}; - const char * ZEXPORT zlibVersion() { return ZLIB_VERSION; @@ -181,7 +180,6 @@ void zmemzero(dest, len) } #endif - #ifdef SYS16BIT #ifdef __TURBOC__ @@ -261,7 +259,6 @@ void zcfree (voidpf opaque, voidpf ptr) #endif /* __TURBOC__ */ - #ifdef M_I86 /* Microsoft C in 16-bit mode */ @@ -288,7 +285,6 @@ void zcfree (voidpf opaque, voidpf ptr) #endif /* SYS16BIT */ - #ifndef MY_ZCALLOC /* Any system without a special alloc function */ #ifndef STDC diff --git a/dep/src/zlib/zutil.h b/dep/src/zlib/zutil.h index b8a722d904d..7f40ca4d975 100644 --- a/dep/src/zlib/zutil.h +++ b/dep/src/zlib/zutil.h @@ -257,7 +257,6 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ # define Tracecv(c,x) #endif - voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); void zcfree OF((voidpf opaque, voidpf ptr)); |