Name of changed file | |
| Version and , file | Version and , file |
| Line 1 in | Line 1 in |
Context line Removed line Changed line Context line | Context line Changed line Added line Context line |
ajp13.h | |
| /usr/src/Sockets-2.3.9/ajp13.h 2009-08-24 18:40:03.0, 0200 | /usr/src/Sockets-2.3.9.1/ajp13.h 2010-02-09 21:13:41.0, 0100 |
| Line 5 in ajp13.h | Line 5 in ajp13.h |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Ajp13Socket.cpp | |
| /usr/src/Sockets-2.3.9/Ajp13Socket.cpp 2010-01-23 14:27:30.0, 0100 | /usr/src/Sockets-2.3.9.1/Ajp13Socket.cpp 2010-02-09 21:13:42.0, 0100 |
| Line 5 in Ajp13Socket.cpp | Line 5 in Ajp13Socket.cpp |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Ajp13Socket.h | |
| /usr/src/Sockets-2.3.9/Ajp13Socket.h 2009-08-24 18:40:10.0, 0200 | /usr/src/Sockets-2.3.9.1/Ajp13Socket.h 2010-02-09 21:13:43.0, 0100 |
| Line 5 in Ajp13Socket.h | Line 5 in Ajp13Socket.h |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
AjpBaseSocket.cpp | |
| /usr/src/Sockets-2.3.9/AjpBaseSocket.cpp 2009-08-24 18:47:24.0, 0200 | /usr/src/Sockets-2.3.9.1/AjpBaseSocket.cpp 2010-02-09 21:13:44.0, 0100 |
| Line 5 in AjpBaseSocket.cpp | Line 5 in AjpBaseSocket.cpp |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
AjpBaseSocket.h | |
| /usr/src/Sockets-2.3.9/AjpBaseSocket.h 2009-08-24 18:40:16.0, 0200 | /usr/src/Sockets-2.3.9.1/AjpBaseSocket.h 2010-02-09 21:13:45.0, 0100 |
| Line 5 in AjpBaseSocket.h | Line 5 in AjpBaseSocket.h |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Base64.cpp | |
| /usr/src/Sockets-2.3.9/Base64.cpp 2009-08-24 18:47:28.0, 0200 | /usr/src/Sockets-2.3.9.1/Base64.cpp 2010-02-09 21:13:47.0, 0100 |
| Line 4 in Base64.cpp | Line 4 in Base64.cpp |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Base64.h | |
| /usr/src/Sockets-2.3.9/Base64.h 2009-08-24 18:40:21.0, 0200 | /usr/src/Sockets-2.3.9.1/Base64.h 2010-02-09 21:13:48.0, 0100 |
| Line 4 in Base64.h | Line 4 in Base64.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Changelog | |
| /usr/src/Sockets-2.3.9/Changelog 2010-01-30 11:37:17.0, 0100 | /usr/src/Sockets-2.3.9.1/Changelog 2010-02-09 21:26:01.0, 0100 |
| Line 1 in Changelog | Line 1 in Changelog |
diff for next release always available @ http://www.alhem.net/Sockets/latest_diff.html next ------ TcpSocket using std::vector<char> to receive incoming line (OnLine | diff for next release always available @ http://www.alhem.net/Sockets/latest_diff.html 2.3.9.1 -------- Using thread- and memory safe clib/c runtime function when possible. Restructured sockethandler internals. Quicker tcp shutdown sequence when sockets lib initiates close. Renamed Utility::GetCurrentDirectory to Utility::CurrentDirectory, and added Utility::GetEnv(). Removed unused triggers code. 2.3.9 ------ TcpSocket using std::vector<char> to receive incoming line (OnLine |
Debug.cpp | |
| /usr/src/Sockets-2.3.9/Debug.cpp 2010-01-28 13:44:31.0, 0100 | /usr/src/Sockets-2.3.9.1/Debug.cpp 2010-02-09 20:47:42.0, 0100 |
| Line 35 in Debug.cpp | Line 35 in Debug.cpp |
va_start(ap, format); #ifdef _WIN32 vsprintf(slask, format, ap); #else vsnprintf(slask, 5000, format, ap); #endif va_end(ap); | va_start(ap, format); #ifdef _WIN32 vsprintf_s(slask, sizeof(slask), format, ap); #else vsnprintf(slask, sizeof(slask), format, ap); #endif va_end(ap); |
| Line 88 in Debug.cpp | Line 88 in Debug.cpp |
{ char slask[100]; sprintf(slask, "%f", d); m_line += slask; return *this; | { char slask[100]; snprintf(slask, sizeof(slask), "%f", d); m_line += slask; return *this; |
Event.cpp | |
| /usr/src/Sockets-2.3.9/Event.cpp 2009-08-24 18:47:40.0, 0200 | /usr/src/Sockets-2.3.9.1/Event.cpp 2010-02-09 21:13:53.0, 0100 |
| Line 4 in Event.cpp | Line 4 in Event.cpp |
**/ /* Copyright (C) 2005-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2005-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Event.h | |
| /usr/src/Sockets-2.3.9/Event.h 2009-08-24 18:40:50.0, 0200 | /usr/src/Sockets-2.3.9.1/Event.h 2010-02-09 21:13:54.0, 0100 |
| Line 4 in Event.h | Line 4 in Event.h |
**/ /* Copyright (C) 2005-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2005-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
EventHandler.cpp | |
| /usr/src/Sockets-2.3.9/EventHandler.cpp 2009-10-10 05:35:27.0, 0200 | /usr/src/Sockets-2.3.9.1/EventHandler.cpp 2010-02-09 21:13:55.0, 0100 |
| Line 4 in EventHandler.cpp | Line 4 in EventHandler.cpp |
**/ /* Copyright (C) 2005-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2005-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
EventHandler.h | |
| /usr/src/Sockets-2.3.9/EventHandler.h 2009-08-24 18:40:55.0, 0200 | /usr/src/Sockets-2.3.9.1/EventHandler.h 2010-02-09 21:13:56.0, 0100 |
| Line 4 in EventHandler.h | Line 4 in EventHandler.h |
**/ /* Copyright (C) 2005-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2005-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
EventTime.cpp | |
| /usr/src/Sockets-2.3.9/EventTime.cpp 2009-08-24 18:47:48.0, 0200 | /usr/src/Sockets-2.3.9.1/EventTime.cpp 2010-02-09 21:13:57.0, 0100 |
| Line 4 in EventTime.cpp | Line 4 in EventTime.cpp |
**/ /* Copyright (C) 2005-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2005-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
EventTime.h | |
| /usr/src/Sockets-2.3.9/EventTime.h 2009-08-24 18:41:00.0, 0200 | /usr/src/Sockets-2.3.9.1/EventTime.h 2010-02-09 21:13:58.0, 0100 |
| Line 4 in EventTime.h | Line 4 in EventTime.h |
**/ /* Copyright (C) 2005-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2005-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Exception.cpp | |
| /usr/src/Sockets-2.3.9/Exception.cpp 2009-08-24 18:47:53.0, 0200 | /usr/src/Sockets-2.3.9.1/Exception.cpp 2010-02-09 21:13:59.0, 0100 |
| Line 5 in Exception.cpp | Line 5 in Exception.cpp |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Exception.h | |
| /usr/src/Sockets-2.3.9/Exception.h 2009-08-24 18:41:05.0, 0200 | /usr/src/Sockets-2.3.9.1/Exception.h 2010-02-09 21:14:00.0, 0100 |
| Line 5 in Exception.h | Line 5 in Exception.h |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
File.cpp | |
| /usr/src/Sockets-2.3.9/File.cpp 2010-01-22 18:10:53.0, 0100 | /usr/src/Sockets-2.3.9.1/File.cpp 2010-02-09 21:14:01.0, 0100 |
| Line 4 in File.cpp | Line 4 in File.cpp |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 68 in File.cpp | Line 68 in File.cpp |
m_path = path; m_mode = mode; #ifdef _WIN32 if (fopen_s(&m_fil, path.c_str(), mode.c_str())) m_fil = NULL; #else m_fil = ::fopen(path.c_str(), mode.c_str()); #endif return m_fil ? true : false; | |
File.h | |
| /usr/src/Sockets-2.3.9/File.h 2010-01-22 18:10:45.0, 0100 | /usr/src/Sockets-2.3.9.1/File.h 2010-02-09 21:14:02.0, 0100 |
| Line 4 in File.h | Line 4 in File.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
FileStream.cpp | |
| /usr/src/Sockets-2.3.9/FileStream.cpp 2009-08-24 18:48:02.0, 0200 | /usr/src/Sockets-2.3.9.1/FileStream.cpp 2010-02-09 21:14:03.0, 0100 |
| Line 5 in FileStream.cpp | Line 5 in FileStream.cpp |
**/ /* Copyright (C) 2008-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2008-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
FileStream.h | |
| /usr/src/Sockets-2.3.9/FileStream.h 2009-08-24 18:41:21.0, 0200 | /usr/src/Sockets-2.3.9.1/FileStream.h 2010-02-09 21:14:04.0, 0100 |
| Line 5 in FileStream.h | Line 5 in FileStream.h |
**/ /* Copyright (C) 2008-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2008-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
HttpBaseSocket.cpp | |
| /usr/src/Sockets-2.3.9/HttpBaseSocket.cpp 2010-01-23 14:27:23.0, 0100 | /usr/src/Sockets-2.3.9.1/HttpBaseSocket.cpp 2010-02-09 21:14:05.0, 0100 |
| Line 5 in HttpBaseSocket.cpp | Line 5 in HttpBaseSocket.cpp |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
HttpBaseSocket.h | |
| /usr/src/Sockets-2.3.9/HttpBaseSocket.h 2009-08-24 18:41:31.0, 0200 | /usr/src/Sockets-2.3.9.1/HttpBaseSocket.h 2010-02-09 21:14:06.0, 0100 |
| Line 5 in HttpBaseSocket.h | Line 5 in HttpBaseSocket.h |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
HttpClientSocket.cpp | |
| /usr/src/Sockets-2.3.9/HttpClientSocket.cpp 2010-01-29 11:32:36.0, 0100 | /usr/src/Sockets-2.3.9.1/HttpClientSocket.cpp 2010-02-09 21:14:07.0, 0100 |
| Line 5 in HttpClientSocket.cpp | Line 5 in HttpClientSocket.cpp |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 136 in HttpClientSocket.cpp | Line 136 in HttpClientSocket.cpp |
if (m_filename.size()) { #ifdef _WIN32 if (fopen_s(&m_fil, m_filename.c_str(), "wb")) m_fil = NULL; #else m_fil = fopen(m_filename.c_str(), "wb"); #endif } else | |
HttpClientSocket.h | |
| /usr/src/Sockets-2.3.9/HttpClientSocket.h 2009-08-24 18:41:35.0, 0200 | /usr/src/Sockets-2.3.9.1/HttpClientSocket.h 2010-02-09 21:14:08.0, 0100 |
| Line 5 in HttpClientSocket.h | Line 5 in HttpClientSocket.h |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
HttpdCookies.cpp | |
| /usr/src/Sockets-2.3.9/HttpdCookies.cpp 2009-10-10 05:05:39.0, 0200 | /usr/src/Sockets-2.3.9.1/HttpdCookies.cpp 2010-02-09 21:14:09.0, 0100 |
| Line 2 in HttpdCookies.cpp | Line 2 in HttpdCookies.cpp |
*/ /* Copyright (C) 2003-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | */ /* Copyright (C) 2003-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 146 in HttpdCookies.cpp | Line 146 in HttpdCookies.cpp |
void HttpdCookies::setcookie(HTTPSocket *sock, const std::string& domain, const std::string& path, const std::string& name, const std::string& value) { char *str = new char[name.size() + value.size() + domain.size() + path.size() + 100]; // set-cookie response if (domain.size()) { sprintf(str, "%s=%s; domain=%s; path=%s; expires=%s", name.c_str(), value.c_str(), domain.c_str(), | void HttpdCookies::setcookie(HTTPSocket *sock, const std::string& domain, const std::string& path, const std::string& name, const std::string& value) { size_t sz = name.size() + value.size() + domain.size() + path.size() + 100; char *str = new char[sz]; // set-cookie response if (domain.size()) { snprintf(str, sz, "%s=%s; domain=%s; path=%s; expires=%s", name.c_str(), value.c_str(), domain.c_str(), |
| Line 159 in HttpdCookies.cpp | Line 160 in HttpdCookies.cpp |
else { sprintf(str, "%s=%s; path=%s; expires=%s", name.c_str(), value.c_str(), path.c_str(), | else { snprintf(str, sz, "%s=%s; path=%s; expires=%s", name.c_str(), value.c_str(), path.c_str(), |
| Line 172 in HttpdCookies.cpp | Line 173 in HttpdCookies.cpp |
void HttpdCookies::setcookie(HTTPSocket *sock, const std::string& domain, const std::string& path, const std::string& name, long value) { char *str = new char[name.size() + domain.size() + path.size() + 100]; char dt[80]; | void HttpdCookies::setcookie(HTTPSocket *sock, const std::string& domain, const std::string& path, const std::string& name, long value) { size_t sz = name.size() + domain.size() + path.size() + 100; char *str = new char[sz]; char dt[80]; |
| Line 178 in HttpdCookies.cpp | Line 180 in HttpdCookies.cpp |
if (domain.size()) { sprintf(str, "%s=%ld; domain=%s; path=%s; expires=%s", name.c_str(), value, domain.c_str(), | if (domain.size()) { snprintf(str, sz, "%s=%ld; domain=%s; path=%s; expires=%s", name.c_str(), value, domain.c_str(), |
| Line 186 in HttpdCookies.cpp | Line 188 in HttpdCookies.cpp |
else { sprintf(str, "%s=%ld; path=%s; expires=%s", name.c_str(), value, path.c_str(), | else { snprintf(str, sz, "%s=%ld; path=%s; expires=%s", name.c_str(), value, path.c_str(), |
| Line 194 in HttpdCookies.cpp | Line 196 in HttpdCookies.cpp |
delete[] str; sprintf(dt, "%ld", value); replacevalue(name, dt); } | delete[] str; snprintf(dt, sizeof(dt), "%ld", value); replacevalue(name, dt); } |
| Line 200 in HttpdCookies.cpp | Line 202 in HttpdCookies.cpp |
void HttpdCookies::setcookie(HTTPSocket *sock, const std::string& domain, const std::string& path, const std::string& name, int value) { char *str = new char[name.size() + domain.size() + path.size() + 100]; char dt[80]; | void HttpdCookies::setcookie(HTTPSocket *sock, const std::string& domain, const std::string& path, const std::string& name, int value) { size_t sz = name.size() + domain.size() + path.size() + 100; char *str = new char[sz]; char dt[80]; |
| Line 206 in HttpdCookies.cpp | Line 209 in HttpdCookies.cpp |
if (domain.size()) { sprintf(str, "%s=%d; domain=%s; path=%s; expires=%s", name.c_str(), value, domain.c_str(), | if (domain.size()) { snprintf(str, sz, "%s=%d; domain=%s; path=%s; expires=%s", name.c_str(), value, domain.c_str(), |
| Line 214 in HttpdCookies.cpp | Line 217 in HttpdCookies.cpp |
else { sprintf(str, "%s=%d; path=%s; expires=%s", name.c_str(), value, path.c_str(), | else { snprintf(str, sz, "%s=%d; path=%s; expires=%s", name.c_str(), value, path.c_str(), |
| Line 222 in HttpdCookies.cpp | Line 225 in HttpdCookies.cpp |
delete[] str; sprintf(dt, "%d", value); replacevalue(name, dt); } | delete[] str; snprintf(dt, sizeof(dt), "%d", value); replacevalue(name, dt); } |
| Line 232 in HttpdCookies.cpp | Line 235 in HttpdCookies.cpp |
struct tm tp; #ifdef _WIN32 memcpy(&tp, gmtime(&t), sizeof(tp)); #else gmtime_r(&t, &tp); | struct tm tp; #ifdef _WIN32 gmtime_s(&tp, &t); #else gmtime_r(&t, &tp); |
| Line 242 in HttpdCookies.cpp | Line 245 in HttpdCookies.cpp |
char dt[100]; sprintf(dt, "%s, %02d-%s-%04d %02d:%02d:%02d GMT", days[tp.tm_wday], tp.tm_mday, | char dt[100]; snprintf(dt, sizeof(dt), "%s, %02d-%s-%04d %02d:%02d:%02d GMT", days[tp.tm_wday], tp.tm_mday, |
HttpdCookies.h | |
| /usr/src/Sockets-2.3.9/HttpdCookies.h 2009-08-24 18:41:39.0, 0200 | /usr/src/Sockets-2.3.9.1/HttpdCookies.h 2010-02-09 21:14:10.0, 0100 |
| Line 2 in HttpdCookies.h | Line 2 in HttpdCookies.h |
*/ /* Copyright (C) 2003-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | */ /* Copyright (C) 2003-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
HttpDebugSocket.cpp | |
| /usr/src/Sockets-2.3.9/HttpDebugSocket.cpp 2009-10-10 05:08:10.0, 0200 | /usr/src/Sockets-2.3.9.1/HttpDebugSocket.cpp 2010-02-09 21:14:11.0, 0100 |
| Line 3 in HttpDebugSocket.cpp | Line 3 in HttpDebugSocket.cpp |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom (grymse@alhem.net) This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom (grymse@alhem.net) This library is made available under the terms of the GNU GPL, with |
HttpDebugSocket.h | |
| /usr/src/Sockets-2.3.9/HttpDebugSocket.h 2009-08-24 18:57:11.0, 0200 | /usr/src/Sockets-2.3.9.1/HttpDebugSocket.h 2010-02-09 21:14:12.0, 0100 |
| Line 3 in HttpDebugSocket.h | Line 3 in HttpDebugSocket.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom (grymse@alhem.net) This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom (grymse@alhem.net) This library is made available under the terms of the GNU GPL, with |
HttpdForm.cpp | |
| /usr/src/Sockets-2.3.9/HttpdForm.cpp 2009-10-10 05:17:31.0, 0200 | /usr/src/Sockets-2.3.9.1/HttpdForm.cpp 2010-02-09 21:14:13.0, 0100 |
| Line 5 in HttpdForm.cpp | Line 5 in HttpdForm.cpp |
/* Copyright (C) 1999-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | /* Copyright (C) 1999-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 89 in HttpdForm.cpp | Line 89 in HttpdForm.cpp |
char *slask = new char[TMPSIZE]; infil -> fgets(slask, TMPSIZE); cl -= strlen(slask); while (cl >= 0 && !infil -> eof()) { | char *slask = new char[TMPSIZE]; infil -> fgets(slask, TMPSIZE); cl -= (int)strlen(slask); while (cl >= 0 && !infil -> eof()) { |
| Line 110 in HttpdForm.cpp | Line 110 in HttpdForm.cpp |
// Get headers until empty line infil -> fgets(slask, TMPSIZE); cl -= strlen(slask); while (strlen(slask) && (slask[strlen(slask) - 1] == 13 || slask[strlen(slask) - 1] == 10)) { | // Get headers until empty line infil -> fgets(slask, TMPSIZE); cl -= (int)strlen(slask); while (strlen(slask) && (slask[strlen(slask) - 1] == 13 || slask[strlen(slask) - 1] == 10)) { |
| Line 178 in HttpdForm.cpp | Line 178 in HttpdForm.cpp |
// get next header value infil -> fgets(slask, TMPSIZE); cl -= strlen(slask); while (strlen(slask) && (slask[strlen(slask) - 1] == 13 || slask[strlen(slask) - 1] == 10)) { | // get next header value infil -> fgets(slask, TMPSIZE); cl -= (int)strlen(slask); while (strlen(slask) && (slask[strlen(slask) - 1] == 13 || slask[strlen(slask) - 1] == 10)) { |
| Line 189 in HttpdForm.cpp | Line 189 in HttpdForm.cpp |
std::string val; infil -> fgets(slask, TMPSIZE); cl -= strlen(slask); while (cl >= 0 && !infil -> eof() && strncmp(slask,m_strBoundary.c_str(),m_strBoundary.size() )) { val += slask; infil -> fgets(slask, TMPSIZE); cl -= strlen(slask); } // remove trailing cr/linefeed | std::string val; infil -> fgets(slask, TMPSIZE); cl -= (int)strlen(slask); while (cl >= 0 && !infil -> eof() && strncmp(slask,m_strBoundary.c_str(),m_strBoundary.size() )) { val += slask; infil -> fgets(slask, TMPSIZE); cl -= (int)strlen(slask); } // remove trailing cr/linefeed |
| Line 221 in HttpdForm.cpp | Line 221 in HttpdForm.cpp |
if (tmp_path[strlen(tmp_path) - 1] != '\\') { strcat(tmp_path, "\\"); } sprintf(fn,"%s%s",tmp_path,current_filename.c_str()); } #else sprintf(fn,"/tmp/%s",current_filename.c_str()); #endif if (m_file_upload && !m_upload_stream) m_upload_stream = &m_file_upload -> IFileUploadBegin(current_name, current_filename, content_type); else fil = fopen(fn, "wb"); if (fil || m_upload_stream) { | if (tmp_path[strlen(tmp_path) - 1] != '\\') { strcat_s(tmp_path, sizeof(tmp_path), "\\"); } snprintf(fn,sizeof(fn),"%s%s",tmp_path,current_filename.c_str()); } #else snprintf(fn,sizeof(fn),"/tmp/%s",current_filename.c_str()); #endif if (m_file_upload && !m_upload_stream) m_upload_stream = &m_file_upload -> IFileUploadBegin(current_name, current_filename, content_type); else { #ifdef _WIN32 if (fopen_s(&fil, fn, "wb")) fil = NULL; #else fil = fopen(fn, "wb"); #endif } if (fil || m_upload_stream) { |
| Line 284 in HttpdForm.cpp | Line 291 in HttpdForm.cpp |
m_cgi.push_back(cgi); strcpy(slask, m_strBoundary.c_str()); size_t l = strlen(slask); infil -> fgets(slask + l, TMPSIZE); // next line cl -= strlen(slask + l); } else | m_cgi.push_back(cgi); #ifdef _WIN32 strcpy_s(slask, TMPSIZE, m_strBoundary.c_str()); #else strcpy(slask, m_strBoundary.c_str()); #endif size_t l = strlen(slask); infil -> fgets(slask + l, TMPSIZE - (int)l); // next line cl -= (int)strlen(slask + l); } else |
HttpdForm.h | |
| /usr/src/Sockets-2.3.9/HttpdForm.h 2009-08-24 18:41:54.0, 0200 | /usr/src/Sockets-2.3.9.1/HttpdForm.h 2010-02-09 21:14:14.0, 0100 |
| Line 5 in HttpdForm.h | Line 5 in HttpdForm.h |
/* Copyright (C) 1999-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | /* Copyright (C) 1999-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 38 in HttpdForm.h | Line 38 in HttpdForm.h |
#include <string> #include <list> #include <cstdio> #include <cstring> #ifdef SOCKETS_NAMESPACE | |
HttpdSocket.cpp | |
| /usr/src/Sockets-2.3.9/HttpdSocket.cpp 2009-10-10 05:06:34.0, 0200 | /usr/src/Sockets-2.3.9.1/HttpdSocket.cpp 2010-02-09 21:14:15.0, 0100 |
| Line 2 in HttpdSocket.cpp | Line 2 in HttpdSocket.cpp |
*/ /* Copyright (C) 2001-2009 Anders Hedstrom (grymse@alhem.net) This library is made available under the terms of the GNU GPL, with | */ /* Copyright (C) 2001-2010 Anders Hedstrom (grymse@alhem.net) This library is made available under the terms of the GNU GPL, with |
| Line 238 in HttpdSocket.cpp | Line 238 in HttpdSocket.cpp |
} sprintf(s,"%s, %02d %s %d %02d:%02d:%02d GMT", days[tp.tm_wday], tp.tm_mday, | } snprintf(s,sizeof(s),"%s, %02d %s %d %02d:%02d:%02d GMT", days[tp.tm_wday], tp.tm_mday, |
| Line 258 in HttpdSocket.cpp | Line 258 in HttpdSocket.cpp |
struct tm tp; #ifdef _WIN32 memcpy(&tp, localtime(&t), sizeof(tp)); #else localtime_r(&t, &tp); #endif char slask[40]; // yyyy-mm-dd hh:mm:ss sprintf(slask,"%d-%02d-%02d %02d:%02d:%02d", tp.tm_year + 1900, tp.tm_mon + 1, | struct tm tp; #ifdef _WIN32 localtime_s(&tp, &t); #else localtime_r(&t, &tp); #endif char slask[40]; // yyyy-mm-dd hh:mm:ss snprintf(slask,sizeof(slask),"%d-%02d-%02d %02d:%02d:%02d", tp.tm_year + 1900, tp.tm_mon + 1, |
HttpdSocket.h | |
| /usr/src/Sockets-2.3.9/HttpdSocket.h 2009-08-24 18:41:58.0, 0200 | /usr/src/Sockets-2.3.9.1/HttpdSocket.h 2010-02-09 21:14:16.0, 0100 |
| Line 2 in HttpdSocket.h | Line 2 in HttpdSocket.h |
*/ /* Copyright (C) 2001-2009 Anders Hedstrom (grymse@alhem.net) This library is made available under the terms of the GNU GPL, with | */ /* Copyright (C) 2001-2010 Anders Hedstrom (grymse@alhem.net) This library is made available under the terms of the GNU GPL, with |
HttpGetSocket.cpp | |
| /usr/src/Sockets-2.3.9/HttpGetSocket.cpp 2010-01-29 11:32:46.0, 0100 | /usr/src/Sockets-2.3.9.1/HttpGetSocket.cpp 2010-02-09 21:14:17.0, 0100 |
| Line 4 in HttpGetSocket.cpp | Line 4 in HttpGetSocket.cpp |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
HttpGetSocket.h | |
| /usr/src/Sockets-2.3.9/HttpGetSocket.h 2009-08-24 18:42:04.0, 0200 | /usr/src/Sockets-2.3.9.1/HttpGetSocket.h 2010-02-09 21:14:19.0, 0100 |
| Line 4 in HttpGetSocket.h | Line 4 in HttpGetSocket.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
HttpPostSocket.cpp | |
| /usr/src/Sockets-2.3.9/HttpPostSocket.cpp 2009-10-10 05:07:34.0, 0200 | /usr/src/Sockets-2.3.9.1/HttpPostSocket.cpp 2010-02-09 21:14:20.0, 0100 |
| Line 4 in HttpPostSocket.cpp | Line 4 in HttpPostSocket.cpp |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 261 in HttpPostSocket.cpp | Line 261 in HttpPostSocket.cpp |
Send( tmp ); { #ifdef _WIN32 FILE *fil; if (fopen_s(&fil, filename.c_str(), "rb")) fil = NULL; #else FILE *fil = fopen(filename.c_str(),"rb"); #endif if (fil) { | |
HttpPostSocket.h | |
| /usr/src/Sockets-2.3.9/HttpPostSocket.h 2009-08-24 18:42:09.0, 0200 | /usr/src/Sockets-2.3.9.1/HttpPostSocket.h 2010-02-09 21:14:21.0, 0100 |
| Line 4 in HttpPostSocket.h | Line 4 in HttpPostSocket.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
HttpPutSocket.cpp | |
| /usr/src/Sockets-2.3.9/HttpPutSocket.cpp 2009-10-10 05:07:08.0, 0200 | /usr/src/Sockets-2.3.9.1/HttpPutSocket.cpp 2010-02-09 21:14:22.0, 0100 |
| Line 4 in HttpPutSocket.cpp | Line 4 in HttpPutSocket.cpp |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 104 in HttpPutSocket.cpp | Line 104 in HttpPutSocket.cpp |
SendRequest(); #ifdef _WIN32 FILE *fil; if (fopen_s(&fil, m_filename.c_str(), "rb")) fil = NULL; #else FILE *fil = fopen(m_filename.c_str(), "rb"); #endif if (fil) { | |
HttpPutSocket.h | |
| /usr/src/Sockets-2.3.9/HttpPutSocket.h 2009-08-24 18:42:15.0, 0200 | /usr/src/Sockets-2.3.9.1/HttpPutSocket.h 2010-02-09 21:14:23.0, 0100 |
| Line 4 in HttpPutSocket.h | Line 4 in HttpPutSocket.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
HttpRequest.cpp | |
| /usr/src/Sockets-2.3.9/HttpRequest.cpp 2009-10-10 05:08:34.0, 0200 | /usr/src/Sockets-2.3.9.1/HttpRequest.cpp 2010-02-09 21:14:24.0, 0100 |
| Line 5 in HttpRequest.cpp | Line 5 in HttpRequest.cpp |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
HttpRequest.h | |
| /usr/src/Sockets-2.3.9/HttpRequest.h 2009-10-10 05:21:10.0, 0200 | /usr/src/Sockets-2.3.9.1/HttpRequest.h 2010-02-09 21:14:25.0, 0100 |
| Line 5 in HttpRequest.h | Line 5 in HttpRequest.h |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
HttpResponse.cpp | |
| /usr/src/Sockets-2.3.9/HttpResponse.cpp 2010-01-29 11:47:12.0, 0100 | /usr/src/Sockets-2.3.9.1/HttpResponse.cpp 2010-02-09 21:14:26.0, 0100 |
| Line 5 in HttpResponse.cpp | Line 5 in HttpResponse.cpp |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 196 in HttpResponse.cpp | Line 196 in HttpResponse.cpp |
va_start(ap, format); char tmp[10000]; vsprintf(tmp, format, ap); va_end(ap); m_file -> fwrite( tmp, 1, strlen(tmp) ); | va_start(ap, format); char tmp[10000]; #ifdef _WIN32 vsprintf_s(tmp, sizeof(tmp), format, ap); #else vsnprintf(tmp, sizeof(tmp), format, ap); #endif va_end(ap); m_file -> fwrite( tmp, 1, strlen(tmp) ); |
HttpResponse.h | |
| /usr/src/Sockets-2.3.9/HttpResponse.h 2010-01-29 11:46:56.0, 0100 | /usr/src/Sockets-2.3.9.1/HttpResponse.h 2010-02-09 21:14:27.0, 0100 |
| Line 5 in HttpResponse.h | Line 5 in HttpResponse.h |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
HTTPSocket.cpp | |
| /usr/src/Sockets-2.3.9/HTTPSocket.cpp 2010-01-29 11:53:48.0, 0100 | /usr/src/Sockets-2.3.9.1/HTTPSocket.cpp 2010-02-09 21:14:28.0, 0100 |
| Line 4 in HTTPSocket.cpp | Line 4 in HTTPSocket.cpp |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 300 in HTTPSocket.cpp | Line 300 in HTTPSocket.cpp |
va_start(ap, format); #ifdef _WIN32 vsprintf(slask, format, ap); #else vsnprintf(slask, 8192, format, ap); #endif va_end(ap); | va_start(ap, format); #ifdef _WIN32 vsprintf_s(slask, sizeof(slask), format, ap); #else vsnprintf(slask, sizeof(slask), format, ap); #endif va_end(ap); |
HTTPSocket.h | |
| /usr/src/Sockets-2.3.9/HTTPSocket.h 2010-01-29 11:43:40.0, 0100 | /usr/src/Sockets-2.3.9.1/HTTPSocket.h 2010-02-09 21:14:29.0, 0100 |
| Line 4 in HTTPSocket.h | Line 4 in HTTPSocket.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
HttpTransaction.cpp | |
| /usr/src/Sockets-2.3.9/HttpTransaction.cpp 2009-10-10 05:10:09.0, 0200 | /usr/src/Sockets-2.3.9.1/HttpTransaction.cpp 2010-02-09 21:14:30.0, 0100 |
| Line 5 in HttpTransaction.cpp | Line 5 in HttpTransaction.cpp |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 187 in HttpTransaction.cpp | Line 187 in HttpTransaction.cpp |
const std::string HttpTransaction::HostOnly() const { std::string host = Header("host"); size_t pos = host.find(":"); if (pos != std::string::npos) return host.substr(0, pos); return host; } // -------------------------------------------------------------------------------------- | |
HttpTransaction.h | |
| /usr/src/Sockets-2.3.9/HttpTransaction.h 2009-10-10 05:20:43.0, 0200 | /usr/src/Sockets-2.3.9.1/HttpTransaction.h 2010-02-09 21:14:31.0, 0100 |
| Line 5 in HttpTransaction.h | Line 5 in HttpTransaction.h |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 76 in HttpTransaction.h | Line 76 in HttpTransaction.h |
void SetHost(const std::string& value); const std::string& Host() const; const std::string HostOnly() const; void SetPragma(const std::string& value); | |
IBase.h | |
| /usr/src/Sockets-2.3.9/IBase.h 2008-12-20 12:46:57.0, 0100 | /usr/src/Sockets-2.3.9.1/IBase.h 2010-02-09 21:17:49.0, 0100 |
| Line 5 in IBase.h | Line 5 in IBase.h |
**/ /* Copyright (C) 2007-2008 Anders Hedstrom This program is free software; you can redistribute it and/or | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This program is free software; you can redistribute it and/or |
IEventHandler.h | |
| /usr/src/Sockets-2.3.9/IEventHandler.h 2009-08-24 18:43:53.0, 0200 | /usr/src/Sockets-2.3.9.1/IEventHandler.h 2010-02-09 21:14:33.0, 0100 |
| Line 4 in IEventHandler.h | Line 4 in IEventHandler.h |
**/ /* Copyright (C) 2005-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2005-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
IEventOwner.cpp | |
| /usr/src/Sockets-2.3.9/IEventOwner.cpp 2009-08-24 18:49:04.0, 0200 | /usr/src/Sockets-2.3.9.1/IEventOwner.cpp 2010-02-09 21:15:03.0, 0100 |
| Line 4 in IEventOwner.cpp | Line 4 in IEventOwner.cpp |
**/ /* Copyright (C) 2005-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2005-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
IEventOwner.h | |
| /usr/src/Sockets-2.3.9/IEventOwner.h 2009-08-24 18:43:57.0, 0200 | /usr/src/Sockets-2.3.9.1/IEventOwner.h 2010-02-09 21:15:04.0, 0100 |
| Line 4 in IEventOwner.h | Line 4 in IEventOwner.h |
**/ /* Copyright (C) 2005-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2005-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
IFile.h | |
| /usr/src/Sockets-2.3.9/IFile.h 2010-01-22 17:48:51.0, 0100 | /usr/src/Sockets-2.3.9.1/IFile.h 2010-02-09 21:15:05.0, 0100 |
| Line 4 in IFile.h | Line 4 in IFile.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
IFileUpload.h | |
| /usr/src/Sockets-2.3.9/IFileUpload.h 2009-04-22 12:44:43.0, 0200 | /usr/src/Sockets-2.3.9.1/IFileUpload.h 2010-02-09 21:15:06.0, 0100 |
| Line 4 in IFileUpload.h | Line 4 in IFileUpload.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL. | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL. |
IHttpServer.h | |
| /usr/src/Sockets-2.3.9/IHttpServer.h 2009-08-24 18:44:06.0, 0200 | /usr/src/Sockets-2.3.9.1/IHttpServer.h 2010-02-09 21:15:07.0, 0100 |
| Line 5 in IHttpServer.h | Line 5 in IHttpServer.h |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
IMutex.h | |
| /usr/src/Sockets-2.3.9/IMutex.h 2009-09-16 06:23:57.0, 0200 | /usr/src/Sockets-2.3.9.1/IMutex.h 2010-02-09 21:15:08.0, 0100 |
| Line 4 in IMutex.h | Line 4 in IMutex.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Ipv4Address.cpp | |
| /usr/src/Sockets-2.3.9/Ipv4Address.cpp 2009-08-24 18:49:08.0, 0200 | /usr/src/Sockets-2.3.9.1/Ipv4Address.cpp 2010-02-09 21:15:09.0, 0100 |
| Line 5 in Ipv4Address.cpp | Line 5 in Ipv4Address.cpp |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Ipv4Address.h | |
| /usr/src/Sockets-2.3.9/Ipv4Address.h 2009-08-24 18:44:23.0, 0200 | /usr/src/Sockets-2.3.9.1/Ipv4Address.h 2010-02-09 21:15:10.0, 0100 |
| Line 5 in Ipv4Address.h | Line 5 in Ipv4Address.h |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Ipv6Address.cpp | |
| /usr/src/Sockets-2.3.9/Ipv6Address.cpp 2009-08-24 18:49:12.0, 0200 | /usr/src/Sockets-2.3.9.1/Ipv6Address.cpp 2010-02-09 21:15:10.0, 0100 |
| Line 5 in Ipv6Address.cpp | Line 5 in Ipv6Address.cpp |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 166 in Ipv6Address.cpp | Line 166 in Ipv6Address.cpp |
x = ntohs(addr16[i]); if (*slask && (x || !ok_to_skip || prev)) strcat(slask,":"); if (x || !ok_to_skip) { sprintf(slask + strlen(slask),"%x", x); if (x && skipped) ok_to_skip = false; | x = ntohs(addr16[i]); if (*slask && (x || !ok_to_skip || prev)) { #ifdef _WIN32 strcat_s(slask,sizeof(slask),":"); #else strcat(slask,":"); #endif } if (x || !ok_to_skip) { snprintf(slask + strlen(slask), sizeof(slask) - strlen(slask),"%x", x); if (x && skipped) ok_to_skip = false; |
| Line 180 in Ipv6Address.cpp | Line 186 in Ipv6Address.cpp |
} x = ntohs(addr16[6]); sprintf(slask + strlen(slask),":%u.%u",x / 256,x & 255); x = ntohs(addr16[7]); sprintf(slask + strlen(slask),".%u.%u",x / 256,x & 255); } else | } x = ntohs(addr16[6]); snprintf(slask + strlen(slask), sizeof(slask) - strlen(slask),":%u.%u",x / 256,x & 255); x = ntohs(addr16[7]); snprintf(slask + strlen(slask), sizeof(slask) - strlen(slask),".%u.%u",x / 256,x & 255); } else |
Ipv6Address.h | |
| /usr/src/Sockets-2.3.9/Ipv6Address.h 2009-08-24 18:44:28.0, 0200 | /usr/src/Sockets-2.3.9.1/Ipv6Address.h 2010-02-09 21:15:11.0, 0100 |
| Line 5 in Ipv6Address.h | Line 5 in Ipv6Address.h |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
ISocketHandler.h | |
| /usr/src/Sockets-2.3.9/ISocketHandler.h 2010-01-28 16:23:07.0, 0100 | /usr/src/Sockets-2.3.9.1/ISocketHandler.h 2010-02-09 21:15:38.0, 0100 |
| Line 4 in ISocketHandler.h | Line 4 in ISocketHandler.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 40 in ISocketHandler.h | Line 40 in ISocketHandler.h |
#include "Socket.h" #include "StdLog.h" #include "IBase.h" #ifdef SOCKETS_NAMESPACE | |
| Line 46 in ISocketHandler.h | Line 45 in ISocketHandler.h |
#endif typedef enum { LIST_CALLONCONNECT = 0, #ifdef ENABLE_DETACH LIST_DETACH, #endif LIST_TIMEOUT, LIST_RETRY, LIST_CLOSE } list_t; class SocketAddress; class IMutex; | |
| Line 62 in ISocketHandler.h | Line 51 in ISocketHandler.h |
/** Socket container class, event generator. \ingroup basic */ class ISocketHandler : public IBase { friend class Socket; | /** Socket container class, event generator. \ingroup basic */ class ISocketHandler { friend class Socket; |
| Line 88 in ISocketHandler.h | Line 77 in ISocketHandler.h |
public: virtual ~ISocketHandler() {} /** Get mutex reference for threadsafe operations. */ virtual IMutex& GetMutex() const = 0; | |
| Line 131 in ISocketHandler.h | Line 122 in ISocketHandler.h |
virtual bool OkToAccept(Socket *p) = 0; /** Called by Socket when a socket changes state. */ virtual void AddList(SOCKET s,list_t which_one,bool add) = 0; /** Use with care, always lock with h.GetMutex() if multithreaded */ virtual const std::map<SOCKET, Socket *>& AllSockets() = 0; | |
| Line 140 in ISocketHandler.h | Line 128 in ISocketHandler.h |
virtual size_t MaxTcpLineSize() = 0; virtual void SetCallOnConnect(bool = true) = 0; virtual void SetDetach(bool = true) = 0; virtual void SetTimeout(bool = true) = 0; virtual void SetRetry(bool = true) = 0; virtual void SetClose(bool = true) = 0; // ------------------------------------------------------------------------- // Connection pool | |
| Line 211 in ISocketHandler.h | Line 205 in ISocketHandler.h |
#endif // ENABLE_RESOLVER #ifdef ENABLE_TRIGGERS /** Fetch unique trigger id. */ virtual int TriggerID(Socket *src) = 0; /** Subscribe socket to trigger id. */ virtual bool Subscribe(int id, Socket *dst) = 0; /** Unsubscribe socket from trigger id. */ virtual bool Unsubscribe(int id, Socket *dst) = 0; /** Execute OnTrigger for subscribed sockets. \param id Trigger ID \param data Data passed from source to destination \param erase Empty trigger id source and destination maps if 'true', Leave them in place if 'false' - if a trigger should be called many times */ virtual void Trigger(int id, Socket::TriggerData& data, bool erase = true) = 0; #endif // ENABLE_TRIGGERS #ifdef ENABLE_DETACH /** Indicates that the handler runs under SocketThread. */ | |
IStream.h | |
| /usr/src/Sockets-2.3.9/IStream.h 2009-08-24 18:44:39.0, 0200 | /usr/src/Sockets-2.3.9.1/IStream.h 2010-02-09 21:15:39.0, 0100 |
| Line 4 in IStream.h | Line 4 in IStream.h |
**/ /* Copyright (C) 2008-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2008-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
ListenSocket.h | |
| /usr/src/Sockets-2.3.9/ListenSocket.h 2010-01-30 11:35:36.0, 0100 | /usr/src/Sockets-2.3.9.1/ListenSocket.h 2010-02-09 21:15:40.0, 0100 |
| Line 4 in ListenSocket.h | Line 4 in ListenSocket.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Lock.cpp | |
| /usr/src/Sockets-2.3.9/Lock.cpp 2009-08-24 18:49:20.0, 0200 | /usr/src/Sockets-2.3.9.1/Lock.cpp 2010-02-09 21:15:42.0, 0100 |
| Line 4 in Lock.cpp | Line 4 in Lock.cpp |
**/ /* Copyright (C) 2005-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2005-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Lock.h | |
| /usr/src/Sockets-2.3.9/Lock.h 2009-08-24 18:44:48.0, 0200 | /usr/src/Sockets-2.3.9.1/Lock.h 2010-02-09 21:15:43.0, 0100 |
| Line 4 in Lock.h | Line 4 in Lock.h |
**/ /* Copyright (C) 2005-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2005-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Makefile | |
| /usr/src/Sockets-2.3.9/Makefile 2010-01-26 16:17:27.0, 0100 | /usr/src/Sockets-2.3.9.1/Makefile 2010-02-06 20:02:11.0, 0100 |
| Line 113 in Makefile | Line 113 in Makefile |
cp $(SHAREDLIBNAME) $(DESTDIR)/$(PREFIX)/lib cp -a pkgconfig/*pc $(DESTDIR)/$(PREFIX)/lib/pkgconfig # no binary files, zip will translate lf to cr lf FILES = *.h *.cpp Makefile Makefile.Defines.* Makefile.solaris9-sparc-64 Project/*.ds* \ README Changelog README.macosx gpl.txt mkdot.sh \ Project.net/Sockets/*.vcproj Project.net/Sockets/*.sln \ | cp $(SHAREDLIBNAME) $(DESTDIR)/$(PREFIX)/lib cp -a pkgconfig/*pc $(DESTDIR)/$(PREFIX)/lib/pkgconfig rm -f $(DESTDIR)/$(PREFIX)/lib/lib$(NAME).so rm -f $(DESTDIR)/$(PREFIX)/lib/lib$(NAME).so.$(MAJOR) ln -s $(DESTDIR)/$(PREFIX)/lib/lib$(NAME).so.$(MAJOR).$(MINOR) $(DESTDIR)/$(PREFIX)/lib/lib$(NAME).so ln -s $(DESTDIR)/$(PREFIX)/lib/lib$(NAME).so.$(MAJOR).$(MINOR) $(DESTDIR)/$(PREFIX)/lib/lib$(NAME).so.$(MAJOR) ldconfig # no binary files, zip will translate lf to cr lf FILES = *.h *.cpp \ Makefile Makefile.version \ Makefile.Defines.* Makefile.solaris9-sparc-64 Project/*.ds* \ README Changelog README.macosx gpl.txt mkdot.sh \ Project.net/Sockets/*.vcproj Project.net/Sockets/*.sln \ |
MemFile.cpp | |
| /usr/src/Sockets-2.3.9/MemFile.cpp 2010-01-27 14:07:00.0, 0100 | /usr/src/Sockets-2.3.9.1/MemFile.cpp 2010-02-09 21:15:44.0, 0100 |
| Line 4 in MemFile.cpp | Line 4 in MemFile.cpp |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 50 in MemFile.cpp | Line 50 in MemFile.cpp |
MemFile::MemFile() :m_src(*this) ,m_src_valid(false) ,m_base(new block_t) | MemFile::MemFile() :m_src(m_src) ,m_src_valid(false) ,m_base(new block_t) |
| Line 84 in MemFile.cpp | Line 84 in MemFile.cpp |
MemFile::MemFile(File& f) :m_src(*this) ,m_src_valid(false) ,m_base(new block_t) | MemFile::MemFile(File& f) :m_src(m_src) ,m_src_valid(false) ,m_base(new block_t) |
| Line 287 in MemFile.cpp | Line 287 in MemFile.cpp |
va_start(ap, format); #ifdef _WIN32 vsprintf(tmp, format, ap); #else vsnprintf(tmp, BLOCKSIZE - 1, format, ap); #endif va_end(ap); | va_start(ap, format); #ifdef _WIN32 vsprintf_s(tmp, sizeof(tmp), format, ap); #else vsnprintf(tmp, sizeof(tmp), format, ap); #endif va_end(ap); |
MemFile.h | |
| /usr/src/Sockets-2.3.9/MemFile.h 2010-01-24 09:46:09.0, 0100 | /usr/src/Sockets-2.3.9.1/MemFile.h 2010-02-09 21:15:45.0, 0100 |
| Line 4 in MemFile.h | Line 4 in MemFile.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Mutex.cpp | |
| /usr/src/Sockets-2.3.9/Mutex.cpp 2009-08-24 18:49:29.0, 0200 | /usr/src/Sockets-2.3.9.1/Mutex.cpp 2010-02-09 21:16:47.0, 0100 |
| Line 4 in Mutex.cpp | Line 4 in Mutex.cpp |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Mutex.h | |
| /usr/src/Sockets-2.3.9/Mutex.h 2009-08-24 18:44:57.0, 0200 | /usr/src/Sockets-2.3.9.1/Mutex.h 2010-02-09 21:16:08.0, 0100 |
| Line 4 in Mutex.h | Line 4 in Mutex.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 37 in Mutex.h | Line 37 in Mutex.h |
#include <pthread.h> #else #include "socket_include.h" #include <windows.h> #endif | |
Parse.cpp | |
| /usr/src/Sockets-2.3.9/Parse.cpp 2009-08-24 18:49:37.0, 0200 | /usr/src/Sockets-2.3.9.1/Parse.cpp 2010-02-09 21:16:12.0, 0100 |
| Line 5 in Parse.cpp | Line 5 in Parse.cpp |
/* Copyright (C) 1999-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | /* Copyright (C) 1999-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Parse.h | |
| /usr/src/Sockets-2.3.9/Parse.h 2009-08-24 18:45:05.0, 0200 | /usr/src/Sockets-2.3.9.1/Parse.h 2010-02-09 21:16:14.0, 0100 |
| Line 5 in Parse.h | Line 5 in Parse.h |
/* Copyright (C) 1999-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | /* Copyright (C) 1999-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
ResolvServer.cpp | |
| /usr/src/Sockets-2.3.9/ResolvServer.cpp 2009-09-16 06:27:37.0, 0200 | /usr/src/Sockets-2.3.9.1/ResolvServer.cpp 2010-02-09 21:16:15.0, 0100 |
| Line 4 in ResolvServer.cpp | Line 4 in ResolvServer.cpp |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
ResolvServer.h | |
| /usr/src/Sockets-2.3.9/ResolvServer.h 2009-08-24 18:45:09.0, 0200 | /usr/src/Sockets-2.3.9.1/ResolvServer.h 2010-02-09 21:16:16.0, 0100 |
| Line 4 in ResolvServer.h | Line 4 in ResolvServer.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
ResolvSocket.cpp | |
| /usr/src/Sockets-2.3.9/ResolvSocket.cpp 2009-08-24 18:49:48.0, 0200 | /usr/src/Sockets-2.3.9.1/ResolvSocket.cpp 2010-02-09 21:16:18.0, 0100 |
| Line 4 in ResolvSocket.cpp | Line 4 in ResolvSocket.cpp |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
ResolvSocket.h | |
| /usr/src/Sockets-2.3.9/ResolvSocket.h 2009-08-24 18:45:13.0, 0200 | /usr/src/Sockets-2.3.9.1/ResolvSocket.h 2010-02-09 21:16:19.0, 0100 |
| Line 4 in ResolvSocket.h | Line 4 in ResolvSocket.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
SctpSocket.cpp | |
| /usr/src/Sockets-2.3.9/SctpSocket.cpp 2009-08-24 18:49:53.0, 0200 | /usr/src/Sockets-2.3.9.1/SctpSocket.cpp 2010-02-09 21:16:20.0, 0100 |
| Line 5 in SctpSocket.cpp | Line 5 in SctpSocket.cpp |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
SctpSocket.h | |
| /usr/src/Sockets-2.3.9/SctpSocket.h 2009-08-24 18:45:19.0, 0200 | /usr/src/Sockets-2.3.9.1/SctpSocket.h 2010-02-09 21:16:22.0, 0100 |
| Line 5 in SctpSocket.h | Line 5 in SctpSocket.h |
**/ /* Copyright (C) 2008-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2008-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Semaphore.cpp | |
| /usr/src/Sockets-2.3.9/Semaphore.cpp 2009-08-24 18:58:26.0, 0200 | /usr/src/Sockets-2.3.9.1/Semaphore.cpp 2010-02-09 21:16:23.0, 0100 |
| Line 5 in Semaphore.cpp | Line 5 in Semaphore.cpp |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Semaphore.h | |
| /usr/src/Sockets-2.3.9/Semaphore.h 2009-08-24 18:45:24.0, 0200 | /usr/src/Sockets-2.3.9.1/Semaphore.h 2010-02-09 21:16:24.0, 0100 |
| Line 5 in Semaphore.h | Line 5 in Semaphore.h |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
SmtpdSocket.cpp | |
| /usr/src/Sockets-2.3.9/SmtpdSocket.cpp 2009-08-24 18:50:10.0, 0200 | /usr/src/Sockets-2.3.9.1/SmtpdSocket.cpp 2010-02-09 21:16:26.0, 0100 |
| Line 5 in SmtpdSocket.cpp | Line 5 in SmtpdSocket.cpp |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
SmtpdSocket.h | |
| /usr/src/Sockets-2.3.9/SmtpdSocket.h 2009-08-24 18:45:28.0, 0200 | /usr/src/Sockets-2.3.9.1/SmtpdSocket.h 2010-02-09 21:16:27.0, 0100 |
| Line 5 in SmtpdSocket.h | Line 5 in SmtpdSocket.h |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
SocketAddress.h | |
| /usr/src/Sockets-2.3.9/SocketAddress.h 2009-08-24 18:45:31.0, 0200 | /usr/src/Sockets-2.3.9.1/SocketAddress.h 2010-02-09 21:16:28.0, 0100 |
| Line 5 in SocketAddress.h | Line 5 in SocketAddress.h |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Socket.cpp | |
| /usr/src/Sockets-2.3.9/Socket.cpp 2010-01-30 11:36:08.0, 0100 | /usr/src/Sockets-2.3.9.1/Socket.cpp 2010-02-09 21:16:30.0, 0100 |
| Line 4 in Socket.cpp | Line 4 in Socket.cpp |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 88 in Socket.cpp | Line 88 in Socket.cpp |
,m_remote_address(NULL) ,m_traffic_monitor(NULL) ,m_timeout_start(0) ,m_timeout_limit(0) ,m_bLost(false) ,m_uid(++Socket::m_next_uid) ,m_call_on_connect(false) ,m_b_retry_connect(false) #ifdef HAVE_OPENSSL ,m_b_enable_ssl(false) | |
| Line 187 in Socket.cpp | Line 191 in Socket.cpp |
} Handler().Set(m_socket, false, false, false); // remove from fd_set's Handler().AddList(m_socket, LIST_CALLONCONNECT, false); #ifdef ENABLE_DETACH Handler().AddList(m_socket, LIST_DETACH, false); #endif Handler().AddList(m_socket, LIST_TIMEOUT, false); Handler().AddList(m_socket, LIST_RETRY, false); Handler().AddList(m_socket, LIST_CLOSE, false); m_socket = INVALID_SOCKET; return n; | |
| Line 268 in Socket.cpp | Line 265 in Socket.cpp |
if (x != m_bClose) { Handler().AddList(m_socket, LIST_CLOSE, x); m_bClose = x; if (x) { m_tClose = time(NULL); } } | if (x != m_bClose) { m_bClose = x; if (x) { m_tClose = time(NULL); Handler().SetClose(); } } |
| Line 633 in Socket.cpp | Line 630 in Socket.cpp |
void Socket::SetCallOnConnect(bool x) { m_call_on_connect = x; if (x) Handler().SetCallOnConnect(); } bool Socket::CallOnConnect() { return m_call_on_connect; } void Socket::SetRetryClientConnect(bool x) { m_b_retry_connect = x; if (x) Handler().SetRetry(); } bool Socket::RetryClientConnect() { return m_b_retry_connect; } #ifdef HAVE_OPENSSL void Socket::OnSSLConnect() | |
| Line 744 in Socket.cpp | Line 769 in Socket.cpp |
void Socket::SetRetain() { if (m_bClient) m_bRetain = true; } | void Socket::SetRetain() { if (m_bClient) m_bRetain = true; } |
| Line 861 in Socket.cpp | Line 887 in Socket.cpp |
void Socket::SetDetach(bool x) { Handler().AddList(m_socket, LIST_DETACH, x); m_detach = x; } | void Socket::SetDetach(bool x) { m_detach = x; if (x) Handler().SetDetach(); } |
| Line 1748 in Socket.cpp | Line 1775 in Socket.cpp |
#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) { Handler().AddList(m_socket, LIST_TIMEOUT, false); return; } Handler().AddList(m_socket, LIST_TIMEOUT, true); m_timeout_start = time(NULL); m_timeout_limit = secs; } | void Socket::SetTimeout(time_t secs) { if (!secs) { m_timeout_start = 0; m_timeout_limit = 0; return; } m_timeout_start = time(NULL); m_timeout_limit = secs; Handler().SetTimeout(); } bool Socket::CheckTimeout() { return m_timeout_start > 0 && m_timeout_limit > 0; } |
| Line 1797 in Socket.cpp | Line 1807 in Socket.cpp |
bool Socket::Timeout(time_t tnow) { if (tnow - m_timeout_start > m_timeout_limit) return true; return false; | bool Socket::Timeout(time_t tnow) { if (m_timeout_start > 0 && tnow - m_timeout_start > m_timeout_limit) return true; return false; |
Socket.h | |
| /usr/src/Sockets-2.3.9/Socket.h 2009-10-10 05:43:10.0, 0200 | /usr/src/Sockets-2.3.9.1/Socket.h 2010-02-09 21:16:31.0, 0100 |
| Line 4 in Socket.h | Line 4 in Socket.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 82 in Socket.h | Line 82 in Socket.h |
#endif // ENABLE_DETACH #ifdef ENABLE_TRIGGERS public: /** Data pass class from source to destination. */ class TriggerData { public: TriggerData() : m_src(NULL) {} virtual ~TriggerData() {} Socket *GetSource() const { return m_src; } void SetSource(Socket *x) { m_src = x; } private: Socket *m_src; }; #endif // ENABLE_TRIGGERS /** Socket mode flags. */ /* | |
| Line 236 in Socket.h | Line 219 in Socket.h |
void SetTimeout(time_t secs); bool CheckTimeout(); /** Check timeout. \return true if time limit reached */ bool Timeout(time_t tnow); | |
| Line 484 in Socket.h | Line 469 in Socket.h |
// LIST_CALLONCONNECT /** Instruct socket to call OnConnect callback next sockethandler cycle. */ void SetCallOnConnect(bool x = true); /** Check call on connect flag. \return true if OnConnect() should be called a.s.a.p */ bool CallOnConnect(); // LIST_RETRY /** Set flag to initiate a connection attempt after a connection timeout. */ void SetRetryClientConnect(bool x = true); /** Check if a connection attempt should be made. \return true when another attempt should be made */ bool RetryClientConnect(); #ifdef HAVE_OPENSSL /** @name SSL Support */ | |
| Line 660 in Socket.h | Line 663 in Socket.h |
void SetTrafficMonitor(IFile *p) { m_traffic_monitor = p; } #ifdef ENABLE_TRIGGERS /** \name Triggers */ //@{ /** Subscribe to trigger id. */ void Subscribe(int id); /** Unsubscribe from trigger id. */ void Unsubscribe(int id); /** Trigger callback, with data passed from source to destination. */ virtual void OnTrigger(int id, const TriggerData& data); /** Trigger cancelled because source has been deleted (as in delete). */ virtual void OnCancelled(int id); //@} #endif protected: /** default constructor not available */ | |
| Line 707 in Socket.h | Line 696 in Socket.h |
static socketuid_t m_next_uid; socketuid_t m_uid; bool m_call_on_connect; ///< OnConnect will be called next ISocketHandler cycle if true bool m_b_retry_connect; ///< Try another connection attempt next ISocketHandler cycle #ifdef _WIN32 | |
SocketHandler.cpp | |
| /usr/src/Sockets-2.3.9/SocketHandler.cpp 2010-01-30 11:36:19.0, 0100 | /usr/src/Sockets-2.3.9.1/SocketHandler.cpp 2010-02-09 21:16:32.0, 0100 |
| Line 4 in SocketHandler.cpp | Line 4 in SocketHandler.cpp |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 46 in SocketHandler.cpp | Line 46 in SocketHandler.cpp |
#include "Utility.h" #include "SocketAddress.h" #include "Exception.h" #ifdef SOCKETS_NAMESPACE | |
| Line 63 in SocketHandler.cpp | Line 64 in SocketHandler.cpp |
,m_b_use_mutex(false) ,m_maxsock(0) ,m_preverror(-1) ,m_errcnt(0) ,m_tlast(0) #ifdef ENABLE_SOCKS4 ,m_socks4_host(0) | ,m_b_use_mutex(false) ,m_maxsock(0) ,m_tlast(0) ,m_b_check_callonconnect(false) ,m_b_check_detach(false) ,m_b_check_timeout(false) ,m_b_check_retry(false) ,m_b_check_close(false) #ifdef ENABLE_SOCKS4 ,m_socks4_host(0) |
| Line 78 in SocketHandler.cpp | Line 82 in SocketHandler.cpp |
,m_b_enable_pool(false) #endif #ifdef ENABLE_TRIGGERS ,m_next_trigger_id(0) #endif #ifdef ENABLE_DETACH ,m_slave(false) | |
| Line 96 in SocketHandler.cpp | Line 97 in SocketHandler.cpp |
,m_b_use_mutex(true) ,m_maxsock(0) ,m_preverror(-1) ,m_errcnt(0) ,m_tlast(0) #ifdef ENABLE_SOCKS4 ,m_socks4_host(0) | ,m_b_use_mutex(true) ,m_maxsock(0) ,m_tlast(0) ,m_b_check_callonconnect(false) ,m_b_check_detach(false) ,m_b_check_timeout(false) ,m_b_check_retry(false) ,m_b_check_close(false) #ifdef ENABLE_SOCKS4 ,m_socks4_host(0) |
| Line 111 in SocketHandler.cpp | Line 115 in SocketHandler.cpp |
,m_b_enable_pool(false) #endif #ifdef ENABLE_TRIGGERS ,m_next_trigger_id(0) #endif #ifdef ENABLE_DETACH ,m_slave(false) | |
| Line 220 in SocketHandler.cpp | Line 221 in SocketHandler.cpp |
void SocketHandler::Add(Socket *p) { if (p -> GetSocket() == INVALID_SOCKET) { LogError(p, "Add", -1, "Invalid socket", LOG_LEVEL_WARNING); if (p -> CloseAndDelete()) { m_delete.push_back(p); } return; } if (m_add.find(p -> GetSocket()) != m_add.end()) { LogError(p, "Add", (int)p -> GetSocket(), "Attempt to add socket already in add queue", LOG_LEVEL_FATAL); m_delete.push_back(p); return; } m_add[p -> GetSocket()] = p; } | void SocketHandler::Add(Socket *p) { m_add.push_back(p); // no checks here } |
| Line 292 in SocketHandler.cpp | Line 278 in SocketHandler.cpp |
int SocketHandler::Select(long sec,long usec) { struct timeval tv; tv.tv_sec = sec; tv.tv_usec = usec; return Select(&tv); } int SocketHandler::Select() { if (m_fds_callonconnect.size() || #ifdef ENABLE_DETACH (!m_slave && m_fds_detach.size()) || #endif m_fds_timeout.size() || m_fds_retry.size() || m_fds_close.size() || m_fds_erase.size()) { return Select(0, 200000); } return Select(NULL); } int SocketHandler::Select(struct timeval *tsel) { size_t ignore = 0; while (m_add.size() > ignore) { if (m_sockets.size() >= FD_SETSIZE) { LogError(NULL, "Select", (int)m_sockets.size(), "FD_SETSIZE reached", LOG_LEVEL_WARNING); break; } socket_m::iterator it = m_add.begin(); SOCKET s = it -> first; Socket *p = it -> second; DEB( fprintf(stderr, "Trying to add fd %d, m_add.size() %d, ignore %d\n", (int)s, (int)m_add.size(), (int)ignore);) // if (m_sockets.find(p -> GetSocket()) != m_sockets.end()) { LogError(p, "Add", (int)p -> GetSocket(), "Attempt to add socket already in controlled queue", LOG_LEVEL_FATAL); // %! it's a dup, don't add to delete queue, just ignore it m_delete.push_back(p); m_add.erase(it); // ignore++; continue; } if (!p -> CloseAndDelete()) { StreamSocket *scp = dynamic_cast<StreamSocket *>(p); if (scp && scp -> Connecting()) // 'Open' called before adding socket { Set(s,false,true); } else { TcpSocket *tcp = dynamic_cast<TcpSocket *>(p); bool bWrite = tcp ? tcp -> GetOutputLength() != 0 : false; if (p -> IsDisableRead()) { Set(s, false, bWrite); } else { Set(s, true, bWrite); } } m_maxsock = (s > m_maxsock) ? s : m_maxsock; } else { LogError(p, "Add", (int)p -> GetSocket(), "Trying to add socket with SetCloseAndDelete() true", LOG_LEVEL_WARNING); } // only add to m_fds (process fd_set events) if // slave handler and detached/detaching socket // master handler and non-detached socket #ifdef ENABLE_DETACH if (!(m_slave ^ p -> IsDetach())) #endif { m_fds.push_back(s); } m_sockets[s] = p; // m_add.erase(it); } #ifdef MACOSX fd_set rfds; fd_set wfds; fd_set efds; FD_COPY(&m_rfds, &rfds); FD_COPY(&m_wfds, &wfds); FD_COPY(&m_efds, &efds); #else fd_set rfds = m_rfds; fd_set wfds = m_wfds; fd_set efds = m_efds; #endif int n; if (m_b_use_mutex) { m_mutex.Unlock(); n = select( (int)(m_maxsock + 1),&rfds,&wfds,&efds,tsel); m_mutex.Lock(); } else { n = select( (int)(m_maxsock + 1),&rfds,&wfds,&efds,tsel); } if (n == -1) { /* EBADF An invalid file descriptor was given in one of the sets. EINTR A non blocked signal was caught. EINVAL n is negative. Or struct timeval contains bad time values (<0). ENOMEM select was unable to allocate memory for internal tables. */ if (Errno != m_preverror || m_errcnt++ % 10000 == 0) { LogError(NULL, "select", Errno, StrError(Errno)); DEB( fprintf(stderr, "m_maxsock: %d\n", m_maxsock); fprintf(stderr, "%s\n", Errno == EINVAL ? "EINVAL" : Errno == EINTR ? "EINTR" : Errno == EBADF ? "EBADF" : Errno == ENOMEM ? "ENOMEM" : "<another>"); // test bad fd for (SOCKET i = 0; i <= m_maxsock; i++) { bool t = false; FD_ZERO(&rfds); FD_ZERO(&wfds); FD_ZERO(&efds); if (FD_ISSET(i, &m_rfds)) { FD_SET(i, &rfds); t = true; } if (FD_ISSET(i, &m_wfds)) { FD_SET(i, &wfds); t = true; } if (FD_ISSET(i, &m_efds)) { FD_SET(i, &efds); t = true; } if (t && m_sockets.find(i) == m_sockets.end()) { LogError(NULL, "Select", i, "Bad fd in fd_set", LOG_LEVEL_ERROR); } } ) // DEB m_preverror = Errno; } /// \todo rebuild fd_set's from active sockets list (m_sockets) here FD_ZERO(&rfds); FD_ZERO(&wfds); FD_ZERO(&efds); for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); ++it) { SOCKET s = it -> first; Socket *p = it -> second; if (s == p -> GetSocket()) { fd_set fds; FD_ZERO(&fds); FD_SET(s, &fds); struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 0; int n = select(s + 1, &fds, NULL, NULL, &tv); if (n == -1) { // %! bad fd, remove LogError(p, "Select", s, "Bad fd in fd_set (2)", LOG_LEVEL_ERROR); m_fds_erase.push_back(s); } else { if (FD_ISSET(s, &m_rfds)) FD_SET(s, &rfds); if (FD_ISSET(s, &m_wfds)) FD_SET(s, &wfds); if (FD_ISSET(s, &m_efds)) FD_SET(s, &efds); } } else { // %! mismatch LogError(p, "Select", s, "Bad fd in fd_set (3)", LOG_LEVEL_ERROR); m_fds_erase.push_back(s); } } m_rfds = rfds; m_wfds = wfds; m_efds = efds; } else if (!n) { m_preverror = -1; } else if (n > 0) { for (socket_v::iterator it2 = m_fds.begin(); it2 != m_fds.end() && n; ++it2) { SOCKET i = *it2; // --------------------------------------------------------------------------------- if (FD_ISSET(i, &rfds)) { socket_m::iterator itmp = m_sockets.find(i); if (itmp != m_sockets.end()) // found { Socket *p = itmp -> second; // new SSL negotiate method #ifdef HAVE_OPENSSL if (p -> IsSSLNegotiate()) { p -> SSLNegotiate(); } else #endif { p -> OnRead(); } } else { LogError(NULL, "GetSocket/handler/1", (int)i, "Did not find expected socket using file descriptor", LOG_LEVEL_WARNING); } n--; } // --------------------------------------------------------------------------------- if (FD_ISSET(i, &wfds)) { socket_m::iterator itmp = m_sockets.find(i); if (itmp != m_sockets.end()) // found { Socket *p = itmp -> second; // new SSL negotiate method #ifdef HAVE_OPENSSL if (p -> IsSSLNegotiate()) { p -> SSLNegotiate(); } else #endif { p -> OnWrite(); } } else { LogError(NULL, "GetSocket/handler/2", (int)i, "Did not find expected socket using file descriptor", LOG_LEVEL_WARNING); } n--; } // --------------------------------------------------------------------------------- if (FD_ISSET(i, &efds)) { socket_m::iterator itmp = m_sockets.find(i); if (itmp != m_sockets.end()) // found { Socket *p = itmp -> second; p -> OnException(); } else { LogError(NULL, "GetSocket/handler/3", (int)i, "Did not find expected socket using file descriptor", LOG_LEVEL_WARNING); } n--; } // --------------------------------------------------------------------------------- } // m_fds loop m_preverror = -1; } // if (n > 0) // check CallOnConnect - EVENT if (m_fds_callonconnect.size()) { socket_v tmp = m_fds_callonconnect; for (socket_v::iterator it = tmp.begin(); it != tmp.end(); ++it) { Socket *p = NULL; { socket_m::iterator itmp = m_sockets.find(*it); if (itmp != m_sockets.end()) // found { p = itmp -> second; } else { LogError(NULL, "GetSocket/handler/4", (int)*it, "Did not find expected socket using file descriptor", LOG_LEVEL_WARNING); } } if (p) { // if (p -> CallOnConnect() && p -> Ready() ) { p -> SetConnected(); // moved here from inside if (tcp) check below #ifdef HAVE_OPENSSL if (p -> IsSSL()) // SSL Enabled socket p -> OnSSLConnect(); else #endif #ifdef ENABLE_SOCKS4 if (p -> Socks4()) p -> OnSocks4Connect(); else #endif { TcpSocket *tcp = dynamic_cast<TcpSocket *>(p); if (tcp) { if (tcp -> GetOutputLength()) { p -> OnWrite(); } } #ifdef ENABLE_RECONNECT if (tcp && tcp -> IsReconnect()) p -> OnReconnect(); else #endif { // LogError(p, "Calling OnConnect", 0, "Because CallOnConnect", LOG_LEVEL_INFO); p -> OnConnect(); } } // p -> SetCallOnConnect( false ); AddList(p -> GetSocket(), LIST_CALLONCONNECT, false); } } } } #ifdef ENABLE_DETACH // check detach of socket if master handler - EVENT if (!m_slave && m_fds_detach.size()) { // %! why not using tmp list here??!? for (socket_v::iterator it = m_fds_detach.begin(); it != m_fds_detach.end(); ++it) { Socket *p = NULL; { socket_m::iterator itmp = m_sockets.find(*it); if (itmp != m_sockets.end()) // found { p = itmp -> second; } else { LogError(NULL, "GetSocket/handler/5", (int)*it, "Did not find expected socket using file descriptor", LOG_LEVEL_WARNING); } } if (p) { // if (p -> IsDetach()) { Set(p -> GetSocket(), false, false, false); // After DetachSocket(), all calls to Handler() will return a reference // to the new slave SocketHandler running in the new thread. p -> DetachSocket(); // Adding the file descriptor to m_fds_erase will now also remove the // socket from the detach queue - tnx knightmad m_fds_erase.push_back(p -> GetSocket()); } } } } #endif // check Connecting - connection timeout - conditional event if (m_fds_timeout.size()) { time_t tnow = time(NULL); if (tnow != m_tlast) { socket_v tmp = m_fds_timeout; for (socket_v::iterator it = tmp.begin(); it != tmp.end(); ++it) { Socket *p = NULL; { socket_m::iterator itmp = m_sockets.find(*it); if (itmp != m_sockets.end()) // found { p = itmp -> second; } else { itmp = m_add.find(*it); if (itmp != m_add.end()) { p = itmp -> second; } else { LogError(NULL, "GetSocket/handler/6", (int)*it, "Did not find expected socket using file descriptor", LOG_LEVEL_WARNING); } } } if (p) { if (p -> Timeout(tnow)) { StreamSocket *scp = dynamic_cast<StreamSocket *>(p); DEB( fprintf(stderr, "Checking %d socket(s) for timeout\n", tmp.size());) p -> SetTimeout(0); if (scp && scp -> Connecting()) p -> OnConnectTimeout(); else p -> OnTimeout(); } } } m_tlast = tnow; } // tnow != tlast } // check retry client connect - EVENT if (m_fds_retry.size()) { socket_v tmp = m_fds_retry; for (socket_v::iterator it = tmp.begin(); it != tmp.end(); ++it) { Socket *p = NULL; { socket_m::iterator itmp = m_sockets.find(*it); if (itmp != m_sockets.end()) // found { p = itmp -> second; } else { LogError(NULL, "GetSocket/handler/7", (int)*it, "Did not find expected socket using file descriptor", LOG_LEVEL_WARNING); } } if (p) { // if (p -> RetryClientConnect()) { TcpSocket *tcp = dynamic_cast<TcpSocket *>(p); SOCKET nn = *it; tcp -> SetRetryClientConnect(false); DEB( fprintf(stderr, "Close() before retry client connect\n");) p -> Close(); // removes from m_fds_retry std::auto_ptr<SocketAddress> ad = p -> GetClientRemoteAddress(); if (ad.get()) { tcp -> Open(*ad); } else { LogError(p, "RetryClientConnect", 0, "no address", LOG_LEVEL_ERROR); } Add(p); m_fds_erase.push_back(nn); } } } } // check close and delete - conditional event if (m_fds_close.size()) { socket_v tmp = m_fds_close; DEB( fprintf(stderr, "m_fds_close.size() == %d\n", (int)m_fds_close.size());) for (socket_v::iterator it = tmp.begin(); it != tmp.end(); ++it) { Socket *p = NULL; { socket_m::iterator itmp = m_sockets.find(*it); if (itmp != m_sockets.end()) // found { p = itmp -> second; } else { itmp = m_add.find(*it); if (itmp != m_add.end()) { p = itmp -> second; } else { LogError(NULL, "GetSocket/handler/8", (int)*it, "Did not find expected socket using file descriptor", LOG_LEVEL_WARNING); } } } if (p) { // if (p -> CloseAndDelete() ) { TcpSocket *tcp = dynamic_cast<TcpSocket *>(p); // new graceful tcp - flush and close timeout 5s if (tcp && p -> IsConnected() && tcp -> GetFlushBeforeClose() && #ifdef HAVE_OPENSSL !tcp -> IsSSL() && #endif p -> TimeSinceClose() < 5) { DEB( fprintf(stderr, " close(1)\n");) if (tcp -> GetOutputLength()) { LogError(p, "Closing", (int)tcp -> GetOutputLength(), "Sending all data before closing", LOG_LEVEL_INFO); } else // shutdown write when output buffer is empty if (!(tcp -> GetShutdown() & SHUT_WR)) { SOCKET nn = *it; if (nn != INVALID_SOCKET && shutdown(nn, SHUT_WR) == -1) { LogError(p, "graceful shutdown", Errno, StrError(Errno), LOG_LEVEL_ERROR); } tcp -> SetShutdown(SHUT_WR); } } else #ifdef ENABLE_RECONNECT if (tcp && p -> IsConnected() && tcp -> Reconnect()) { SOCKET nn = *it; DEB( fprintf(stderr, " close(2) fd %d\n", nn);) p -> SetCloseAndDelete(false); tcp -> SetIsReconnect(); p -> SetConnected(false); DEB( fprintf(stderr, "Close() before reconnect\n");) p -> Close(); // dispose of old file descriptor (Open creates a new) p -> OnDisconnect(); std::auto_ptr<SocketAddress> ad = p -> GetClientRemoteAddress(); if (ad.get()) { tcp -> Open(*ad); } else { LogError(p, "Reconnect", 0, "no address", LOG_LEVEL_ERROR); } tcp -> ResetConnectionRetries(); Add(p); m_fds_erase.push_back(nn); } else #endif { SOCKET nn = *it; DEB( fprintf(stderr, " close(3) fd %d GetSocket() %d\n", nn, p -> GetSocket());) if (tcp && p -> IsConnected() && tcp -> GetOutputLength()) { LogError(p, "Closing", (int)tcp -> GetOutputLength(), "Closing socket while data still left to send", LOG_LEVEL_WARNING); } #ifdef ENABLE_POOL if (p -> Retain() && !p -> Lost()) { PoolSocket *p2 = new PoolSocket(*this, p); p2 -> SetDeleteByHandler(); Add(p2); // p -> SetCloseAndDelete(false); // added - remove from m_fds_close } else #endif // ENABLE_POOL { Set(p -> GetSocket(),false,false,false); DEB( fprintf(stderr, "Close() before OnDelete\n");) p -> Close(); } p -> OnDelete(); if (p -> DeleteByHandler()) { p -> SetErasedByHandler(); } m_fds_erase.push_back(nn); } } } } } // check erased sockets bool check_max_fd = false; while (m_fds_erase.size()) { socket_v::iterator it = m_fds_erase.begin(); SOCKET nn = *it; #ifdef ENABLE_DETACH { for (socket_v::iterator it = m_fds_detach.begin(); it != m_fds_detach.end(); ++it) { if (*it == nn) { m_fds_detach.erase(it); break; } } } #endif { for (socket_v::iterator it = m_fds.begin(); it != m_fds.end(); ++it) { if (*it == nn) { m_fds.erase(it); break; } } } { socket_m::iterator it = m_sockets.find(nn); if (it != m_sockets.end()) { Socket *p = it -> second; /* Sometimes a SocketThread class can finish its run before the master sockethandler gets here. In that case, the SocketThread has set the | #ifdef ENABLE_RESOLVER bool SocketHandler::Resolving(Socket *p0) { std::map<socketuid_t, bool>::iterator it = m_resolve_q.find(p0 -> UniqueIdentifier()); return it != m_resolve_q.end(); } #endif bool SocketHandler::Valid(Socket *p0) { for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); ++it) { Socket *p = it -> second; if (p0 == p) return true; } return false; } bool SocketHandler::Valid(socketuid_t uid) { for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); ++it) { Socket *p = it -> second; if (p -> UniqueIdentifier() == uid) return true; } return false; } bool SocketHandler::OkToAccept(Socket *) { return true; } size_t SocketHandler::GetCount() { 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) { // check cache ResolvSocket *resolv = new ResolvSocket(*this, p, host, port); resolv -> SetId(++m_resolv_id); resolv -> SetDeleteByHandler(); ipaddr_t local; Utility::u2ip("127.0.0.1", local); if (!resolv -> Open(local, m_resolver_port)) { LogError(resolv, "Resolve", -1, "Can't connect to local resolve server", LOG_LEVEL_FATAL); } Add(resolv); m_resolve_q[p -> UniqueIdentifier()] = true; DEB( fprintf(stderr, " *** Resolve '%s:%d' id#%d m_resolve_q size: %d p: %p\n", host.c_str(), port, resolv -> GetId(), m_resolve_q.size(), p);) return resolv -> GetId(); } #ifdef ENABLE_IPV6 int SocketHandler::Resolve6(Socket *p,const std::string& host,port_t port) { // check cache ResolvSocket *resolv = new ResolvSocket(*this, p, host, port, true); resolv -> SetId(++m_resolv_id); resolv -> SetDeleteByHandler(); ipaddr_t local; Utility::u2ip("127.0.0.1", local); if (!resolv -> Open(local, m_resolver_port)) { LogError(resolv, "Resolve", -1, "Can't connect to local resolve server", LOG_LEVEL_FATAL); } Add(resolv); m_resolve_q[p -> UniqueIdentifier()] = true; return resolv -> GetId(); } #endif int SocketHandler::Resolve(Socket *p,ipaddr_t a) { // check cache ResolvSocket *resolv = new ResolvSocket(*this, p, a); resolv -> SetId(++m_resolv_id); resolv -> SetDeleteByHandler(); ipaddr_t local; Utility::u2ip("127.0.0.1", local); if (!resolv -> Open(local, m_resolver_port)) { LogError(resolv, "Resolve", -1, "Can't connect to local resolve server", LOG_LEVEL_FATAL); } Add(resolv); m_resolve_q[p -> UniqueIdentifier()] = true; return resolv -> GetId(); } #ifdef ENABLE_IPV6 int SocketHandler::Resolve(Socket *p,in6_addr& a) { // check cache ResolvSocket *resolv = new ResolvSocket(*this, p, a); resolv -> SetId(++m_resolv_id); resolv -> SetDeleteByHandler(); ipaddr_t local; Utility::u2ip("127.0.0.1", local); if (!resolv -> Open(local, m_resolver_port)) { LogError(resolv, "Resolve", -1, "Can't connect to local resolve server", LOG_LEVEL_FATAL); } Add(resolv); m_resolve_q[p -> UniqueIdentifier()] = true; return resolv -> GetId(); } #endif void SocketHandler::EnableResolver(port_t port) { if (!m_resolver) { m_resolver_port = port; m_resolver = new ResolvServer(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) { for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end() && m_sockets.size(); ++it) { PoolSocket *pools = dynamic_cast<PoolSocket *>(it -> second); if (pools) { if (pools -> GetSocketType() == type && pools -> GetSocketProtocol() == protocol && // %! pools -> GetClientRemoteAddress() && *pools -> GetClientRemoteAddress() == ad) { m_sockets.erase(it); pools -> SetRetain(); // avoid Close in Socket destructor return pools; // Caller is responsible that this socket is deleted } } } 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 std::map<socketuid_t, bool>::iterator it4 = m_resolve_q.find(p -> UniqueIdentifier()); if (it4 != m_resolve_q.end()) m_resolve_q.erase(it4); #endif if (p -> ErasedByHandler()) { return; } for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); ++it) { if (it -> second == p) { LogError(p, "Remove", -1, "Socket destructor called while still in use", LOG_LEVEL_WARNING); m_sockets.erase(it); return; } } for (std::list<Socket *>::iterator it2 = m_add.begin(); it2 != m_add.end(); ++it2) { if (*it2 == p) { LogError(p, "Remove", -2, "Socket destructor called while still in use", LOG_LEVEL_WARNING); m_add.erase(it2); return; } } for (std::list<Socket *>::iterator it3 = m_delete.begin(); it3 != m_delete.end(); ++it3) { if (*it3 == p) { LogError(p, "Remove", -3, "Socket destructor called while still in use", LOG_LEVEL_WARNING); m_delete.erase(it3); return; } } } void SocketHandler::SetCallOnConnect(bool x) { m_b_check_callonconnect = x; } void SocketHandler::SetDetach(bool x) { m_b_check_detach = x; } void SocketHandler::SetTimeout(bool x) { m_b_check_timeout = x; } void SocketHandler::SetRetry(bool x) { m_b_check_retry = x; } void SocketHandler::SetClose(bool x) { m_b_check_close = x; } void SocketHandler::DeleteSocket(Socket *p) { p -> OnDelete(); if (p -> DeleteByHandler() && !p -> ErasedByHandler()) { p -> SetErasedByHandler(); } m_fds_erase.push_back(p -> UniqueIdentifier()); } void SocketHandler::RebuildFdset() { fd_set rfds; fd_set wfds; fd_set efds; // rebuild fd_set's from active sockets list (m_sockets) here FD_ZERO(&rfds); FD_ZERO(&wfds); FD_ZERO(&efds); for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); ++it) { SOCKET s = it -> first; Socket *p = it -> second; if (s == p -> GetSocket() && s >= 0) { fd_set fds; FD_ZERO(&fds); FD_SET(s, &fds); struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 0; int n = select((int)s + 1, &fds, NULL, NULL, &tv); if (n == -1 && Errno == EBADF) { // %! bad fd, remove LogError(p, "Select", (int)s, "Bad fd in fd_set (2)", LOG_LEVEL_ERROR); DeleteSocket(p); } else { if (FD_ISSET(s, &m_rfds)) FD_SET(s, &rfds); if (FD_ISSET(s, &m_wfds)) FD_SET(s, &wfds); if (FD_ISSET(s, &m_efds)) FD_SET(s, &efds); } } else { // %! mismatch LogError(p, "Select", (int)s, "Bad fd in fd_set (3)", LOG_LEVEL_ERROR); DeleteSocket(p); } } m_rfds = rfds; m_wfds = wfds; m_efds = efds; } void SocketHandler::AddIncoming() { while (m_add.size() > 0) { if (m_sockets.size() >= FD_SETSIZE) { LogError(NULL, "Select", (int)m_sockets.size(), "FD_SETSIZE reached", LOG_LEVEL_WARNING); break; } std::list<Socket *>::iterator it = m_add.begin(); Socket *p = *it; SOCKET s = p -> GetSocket(); DEB( fprintf(stderr, "Trying to add fd %d, m_add.size() %d\n", (int)s, (int)m_add.size());) // if (s == INVALID_SOCKET) { LogError(p, "Add", -1, "Invalid socket", LOG_LEVEL_WARNING); m_delete.push_back(p); m_add.erase(it); continue; } socket_m::iterator it2; if ((it2 = m_sockets.find(s)) != m_sockets.end()) { Socket *found = it2 -> second; if (p -> UniqueIdentifier() > found -> UniqueIdentifier()) { LogError(p, "Add", (int)p -> GetSocket(), "Replacing socket already in controlled queue (newer uid)", LOG_LEVEL_WARNING); // replace DeleteSocket(found); } else if (p -> UniqueIdentifier() == found -> UniqueIdentifier()) { LogError(p, "Add", (int)p -> GetSocket(), "Attempt to add socket already in controlled queue (same uid)", LOG_LEVEL_ERROR); // same - ignore if (p != found) m_delete.push_back(p); m_add.erase(it); continue; } else { LogError(p, "Add", (int)p -> GetSocket(), "Attempt to add socket already in controlled queue (older uid)", LOG_LEVEL_FATAL); // %! it's a dup, don't add to delete queue, just ignore it m_delete.push_back(p); m_add.erase(it); continue; } } if (!p -> CloseAndDelete()) { StreamSocket *scp = dynamic_cast<StreamSocket *>(p); if (scp && scp -> Connecting()) // 'Open' called before adding socket { Set(s,false,true); } else { TcpSocket *tcp = dynamic_cast<TcpSocket *>(p); bool bWrite = tcp ? tcp -> GetOutputLength() != 0 : false; if (p -> IsDisableRead()) { Set(s, false, bWrite); } else { Set(s, true, bWrite); } } m_maxsock = (s > m_maxsock) ? s : m_maxsock; } else { LogError(p, "Add", (int)p -> GetSocket(), "Added socket with SetCloseAndDelete() true", LOG_LEVEL_WARNING); } m_sockets[s] = p; // m_add.erase(it); } } void SocketHandler::CheckErasedSockets() { // check erased sockets bool check_max_fd = false; while (m_fds_erase.size()) { std::list<socketuid_t>::iterator it = m_fds_erase.begin(); socketuid_t uid = *it; for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++) { Socket *p = it -> second; if (p -> UniqueIdentifier() == uid) { /* Sometimes a SocketThread class can finish its run before the master sockethandler gets here. In that case, the SocketThread has set the |
| Line 919 in SocketHandler.cpp | Line 768 in SocketHandler.cpp |
) { #ifdef ENABLE_TRIGGERS bool again = false; do { again = false; for (std::map<int, Socket *>::iterator it = m_trigger_src.begin(); it != m_trigger_src.end(); ++it) { int id = it -> first; Socket *src = it -> second; if (src == p) { for (std::map<Socket *, bool>::iterator it = m_trigger_dst[id].begin(); it != m_trigger_dst[id].end(); ++it) { Socket *dst = it -> first; if (Valid(dst)) { dst -> OnCancelled(id); } } m_trigger_src.erase(m_trigger_src.find(id)); m_trigger_dst.erase(m_trigger_dst.find(id)); again = true; break; } } } while (again); #endif delete p; } m_sockets.erase(it); } } | ) { delete p; } m_sockets.erase(it); break; } } |
| Line 958 in SocketHandler.cpp | Line 781 in SocketHandler.cpp |
{ m_maxsock = 0; for (socket_v::iterator it = m_fds.begin(); it != m_fds.end(); ++it) { SOCKET s = *it; m_maxsock = s > m_maxsock ? s : m_maxsock; } } // remove Add's that fizzed while (m_delete.size()) { std::list<Socket *>::iterator it = m_delete.begin(); Socket *p = *it; p -> OnDelete(); m_delete.erase(it); if (p -> DeleteByHandler() #ifdef ENABLE_DETACH && !(m_slave ^ p -> IsDetached()) #endif ) { p -> SetErasedByHandler(); #ifdef ENABLE_TRIGGERS bool again = false; do { again = false; for (std::map<int, Socket *>::iterator it = m_trigger_src.begin(); it != m_trigger_src.end(); ++it) { int id = it -> first; Socket *src = it -> second; if (src == p) { for (std::map<Socket *, bool>::iterator it = m_trigger_dst[id].begin(); it != m_trigger_dst[id].end(); ++it) { Socket *dst = it -> first; if (Valid(dst)) { dst -> OnCancelled(id); } } m_trigger_src.erase(m_trigger_src.find(id)); m_trigger_dst.erase(m_trigger_dst.find(id)); again = true; break; } } } while (again); #endif delete p; } } return n; } #ifdef ENABLE_RESOLVER bool SocketHandler::Resolving(Socket *p0) { std::map<socketuid_t, bool>::iterator it = m_resolve_q.find(p0 -> UniqueIdentifier()); return it != m_resolve_q.end(); } #endif bool SocketHandler::Valid(Socket *p0) { for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); ++it) { Socket *p = it -> second; if (p0 == p) return true; } return false; } bool SocketHandler::Valid(socketuid_t uid) { for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); ++it) { Socket *p = it -> second; if (p -> UniqueIdentifier() == uid) return true; } return false; } bool SocketHandler::OkToAccept(Socket *) { return true; } size_t SocketHandler::GetCount() { /* printf(" m_sockets : %d\n", m_sockets.size()); printf(" m_add : %d\n", m_add.size()); 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) { // check cache ResolvSocket *resolv = new ResolvSocket(*this, p, host, port); resolv -> SetId(++m_resolv_id); resolv -> SetDeleteByHandler(); ipaddr_t local; Utility::u2ip("127.0.0.1", local); if (!resolv -> Open(local, m_resolver_port)) { LogError(resolv, "Resolve", -1, "Can't connect to local resolve server", LOG_LEVEL_FATAL); } Add(resolv); m_resolve_q[p -> UniqueIdentifier()] = true; DEB( fprintf(stderr, " *** Resolve '%s:%d' id#%d m_resolve_q size: %d p: %p\n", host.c_str(), port, resolv -> GetId(), m_resolve_q.size(), p);) return resolv -> GetId(); } #ifdef ENABLE_IPV6 int SocketHandler::Resolve6(Socket *p,const std::string& host,port_t port) { // check cache ResolvSocket *resolv = new ResolvSocket(*this, p, host, port, true); resolv -> SetId(++m_resolv_id); resolv -> SetDeleteByHandler(); ipaddr_t local; Utility::u2ip("127.0.0.1", local); if (!resolv -> Open(local, m_resolver_port)) { LogError(resolv, "Resolve", -1, "Can't connect to local resolve server", LOG_LEVEL_FATAL); } Add(resolv); m_resolve_q[p -> UniqueIdentifier()] = true; return resolv -> GetId(); } #endif int SocketHandler::Resolve(Socket *p,ipaddr_t a) { // check cache ResolvSocket *resolv = new ResolvSocket(*this, p, a); resolv -> SetId(++m_resolv_id); resolv -> SetDeleteByHandler(); ipaddr_t local; Utility::u2ip("127.0.0.1", local); if (!resolv -> Open(local, m_resolver_port)) { LogError(resolv, "Resolve", -1, "Can't connect to local resolve server", LOG_LEVEL_FATAL); } Add(resolv); m_resolve_q[p -> UniqueIdentifier()] = true; return resolv -> GetId(); } #ifdef ENABLE_IPV6 int SocketHandler::Resolve(Socket *p,in6_addr& a) { // check cache ResolvSocket *resolv = new ResolvSocket(*this, p, a); resolv -> SetId(++m_resolv_id); resolv -> SetDeleteByHandler(); ipaddr_t local; Utility::u2ip("127.0.0.1", local); if (!resolv -> Open(local, m_resolver_port)) { LogError(resolv, "Resolve", -1, "Can't connect to local resolve server", LOG_LEVEL_FATAL); } Add(resolv); m_resolve_q[p -> UniqueIdentifier()] = true; return resolv -> GetId(); } #endif void SocketHandler::EnableResolver(port_t port) { if (!m_resolver) { m_resolver_port = port; m_resolver = new ResolvServer(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) { for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end() && m_sockets.size(); ++it) { PoolSocket *pools = dynamic_cast<PoolSocket *>(it -> second); if (pools) { if (pools -> GetSocketType() == type && pools -> GetSocketProtocol() == protocol && // %! pools -> GetClientRemoteAddress() && *pools -> GetClientRemoteAddress() == ad) { m_sockets.erase(it); pools -> SetRetain(); // avoid Close in Socket destructor return pools; // Caller is responsible that this socket is deleted } } } 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 std::map<socketuid_t, bool>::iterator it4 = m_resolve_q.find(p -> UniqueIdentifier()); if (it4 != m_resolve_q.end()) m_resolve_q.erase(it4); #endif if (p -> ErasedByHandler()) { return; } for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); ++it) { if (it -> second == p) { LogError(p, "Remove", -1, "Socket destructor called while still in use", LOG_LEVEL_WARNING); m_sockets.erase(it); return; } } for (socket_m::iterator it2 = m_add.begin(); it2 != m_add.end(); ++it2) { if (it2 -> second == p) { LogError(p, "Remove", -2, "Socket destructor called while still in use", LOG_LEVEL_WARNING); m_add.erase(it2); return; } } for (std::list<Socket *>::iterator it3 = m_delete.begin(); it3 != m_delete.end(); ++it3) { if (*it3 == p) { LogError(p, "Remove", -3, "Socket destructor called while still in use", LOG_LEVEL_WARNING); m_delete.erase(it3); return; } } } void SocketHandler::CheckSanity() { CheckList(m_fds, "active sockets"); // active sockets CheckList(m_fds_erase, "sockets to be erased"); // should always be empty anyway CheckList(m_fds_callonconnect, "checklist CallOnConnect"); #ifdef ENABLE_DETACH CheckList(m_fds_detach, "checklist Detach"); #endif CheckList(m_fds_timeout, "checklist Timeout"); CheckList(m_fds_retry, "checklist retry client connect"); 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) { SOCKET s = *it; if (m_sockets.find(s) != m_sockets.end()) continue; if (m_add.find(s) != m_add.end()) continue; bool found = false; for (std::list<Socket *>::iterator it = m_delete.begin(); it != m_delete.end(); ++it) { Socket *p = *it; if (p -> GetSocket() == s) { found = true; break; } } if (!found) { DEB( fprintf(stderr, "CheckList failed for \"%s\": fd %d\n", listname.c_str(), s);) } } | { m_maxsock = 0; for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++) { SOCKET s = it -> first; m_maxsock = s > m_maxsock ? s : m_maxsock; } } } void SocketHandler::CheckCallOnConnect() { m_b_check_callonconnect = false; for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++) { Socket *p = it -> second; if (p -> CallOnConnect()) { TcpSocket *tcp = dynamic_cast<TcpSocket *>(p); p -> SetConnected(); // moved here from inside if (tcp) check below #ifdef HAVE_OPENSSL if (p -> IsSSL()) // SSL Enabled socket p -> OnSSLConnect(); else #endif #ifdef ENABLE_SOCKS4 if (p -> Socks4()) p -> OnSocks4Connect(); else #endif { if (tcp) { if (tcp -> GetOutputLength()) { p -> OnWrite(); } } #ifdef ENABLE_RECONNECT if (tcp && tcp -> IsReconnect()) p -> OnReconnect(); else #endif { p -> OnConnect(); } } p -> SetCallOnConnect( false ); m_b_check_callonconnect = true; } } } void SocketHandler::CheckDetach() { m_b_check_detach = false; for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++) { Socket *p = it -> second; if (p -> IsDetach()) { Set(p -> GetSocket(), false, false, false); // After DetachSocket(), all calls to Handler() will return a reference // to the new slave SocketHandler running in the new thread. p -> DetachSocket(); // Adding the file descriptor to m_fds_erase will now also remove the // socket from the detach queue - tnx knightmad m_fds_erase.push_back(p -> UniqueIdentifier()); m_b_check_detach = true; } } } void SocketHandler::CheckTimeout(time_t tnow) { m_b_check_timeout = false; for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++) { Socket *p = it -> second; if (p -> CheckTimeout()) { if (p -> Timeout(tnow)) { StreamSocket *scp = dynamic_cast<StreamSocket *>(p); p -> SetTimeout(0); if (scp && scp -> Connecting()) { p -> OnConnectTimeout(); // restart timer p -> SetTimeout( scp -> GetConnectTimeout() ); } else { p -> OnTimeout(); } } m_b_check_timeout = true; } } } void SocketHandler::CheckRetry() { m_b_check_retry = false; for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++) { Socket *p = it -> second; if (p -> RetryClientConnect()) { TcpSocket *tcp = dynamic_cast<TcpSocket *>(p); tcp -> SetRetryClientConnect(false); DEB( fprintf(stderr, "Close() before retry client connect\n");) p -> Close(); // removes from m_fds_retry std::auto_ptr<SocketAddress> ad = p -> GetClientRemoteAddress(); if (ad.get()) { tcp -> Open(*ad); } else { LogError(p, "RetryClientConnect", 0, "no address", LOG_LEVEL_ERROR); } Add(p); m_fds_erase.push_back(p -> UniqueIdentifier()); m_b_check_retry = true; } } } void SocketHandler::CheckClose() { m_b_check_close = false; for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++) { Socket *p = it -> second; if (p -> CloseAndDelete() ) { TcpSocket *tcp = dynamic_cast<TcpSocket *>(p); if (p -> Lost()) { DeleteSocket(p); } else // new graceful tcp - flush and close timeout 5s if (tcp && p -> IsConnected() && tcp -> GetFlushBeforeClose() && #ifdef HAVE_OPENSSL !tcp -> IsSSL() && #endif p -> TimeSinceClose() < 5) { DEB( fprintf(stderr, " close(1)\n");) if (tcp -> GetOutputLength()) { LogError(p, "Closing", (int)tcp -> GetOutputLength(), "Sending all data before closing", LOG_LEVEL_INFO); } else // shutdown write when output buffer is empty if (!(tcp -> GetShutdown() & SHUT_WR)) { SOCKET nn = it -> first; if (nn != INVALID_SOCKET && shutdown(nn, SHUT_WR) == -1) { LogError(p, "graceful shutdown", Errno, StrError(Errno), LOG_LEVEL_ERROR); } tcp -> SetShutdown(SHUT_WR); } else { Set(p -> GetSocket(),false,false,false); tcp -> Close(); DeleteSocket(p); } } else #ifdef ENABLE_RECONNECT if (tcp && p -> IsConnected() && tcp -> Reconnect()) { p -> SetCloseAndDelete(false); tcp -> SetIsReconnect(); p -> SetConnected(false); DEB( fprintf(stderr, "Close() before reconnect\n");) p -> Close(); // dispose of old file descriptor (Open creates a new) p -> OnDisconnect(); std::auto_ptr<SocketAddress> ad = p -> GetClientRemoteAddress(); if (ad.get()) { tcp -> Open(*ad); } else { LogError(p, "Reconnect", 0, "no address", LOG_LEVEL_ERROR); } tcp -> ResetConnectionRetries(); Add(p); m_fds_erase.push_back(p -> UniqueIdentifier()); } else #endif { if (tcp && p -> IsConnected() && tcp -> GetOutputLength()) { LogError(p, "Closing", (int)tcp -> GetOutputLength(), "Closing socket while data still left to send", LOG_LEVEL_WARNING); } #ifdef ENABLE_POOL if (p -> Retain() && !p -> Lost()) { PoolSocket *p2 = new PoolSocket(*this, p); p2 -> SetDeleteByHandler(); Add(p2); // p -> SetCloseAndDelete(false); // added - remove from m_fds_close } else #endif // ENABLE_POOL { Set(p -> GetSocket(),false,false,false); DEB( fprintf(stderr, "Close() before OnDelete\n");) p -> Close(); } DeleteSocket(p); } m_b_check_close = true; } } |
| Line 1347 in SocketHandler.cpp | Line 1010 in SocketHandler.cpp |
void SocketHandler::AddList(SOCKET s,list_t which_one,bool add) { if (s == INVALID_SOCKET) { DEB( fprintf(stderr, "AddList: invalid_socket\n%s\n", Utility::Stack().c_str());) return; } socket_v& ref = (which_one == LIST_CALLONCONNECT) ? m_fds_callonconnect : #ifdef ENABLE_DETACH (which_one == LIST_DETACH) ? m_fds_detach : #endif (which_one == LIST_TIMEOUT) ? m_fds_timeout : (which_one == LIST_RETRY) ? m_fds_retry : (which_one == LIST_CLOSE) ? m_fds_close : m_fds_close; if (add) { for (socket_v::iterator it = ref.begin(); it != ref.end(); ++it) { if (*it == s) // already there { return; } } ref.push_back(s); #ifdef ENABLE_DETACH DEB( fprintf(stderr, " ^^ Add file descriptor %5d to list %s List size after operation %d\n", s, (which_one == LIST_CALLONCONNECT) ? "CallOnConnect" : (which_one == LIST_DETACH) ? "Detach" : (which_one == LIST_TIMEOUT) ? "Timeout" : (which_one == LIST_RETRY) ? "Retry" : (which_one == LIST_CLOSE) ? "Close" : "<undef>", ref.size());) #else DEB( fprintf(stderr, " ^^ Add file descriptor %5d to list %s List size after operation %d\n", s, (which_one == LIST_CALLONCONNECT) ? "CallOnConnect" : (which_one == LIST_TIMEOUT) ? "Timeout" : (which_one == LIST_RETRY) ? "Retry" : (which_one == LIST_CLOSE) ? "Close" : "<undef>", ref.size());) #endif return; } // remove for (socket_v::iterator it = ref.begin(); it != ref.end(); ++it) { while (it != ref.end() && *it == s) { it = ref.erase(it); #ifdef ENABLE_DETACH DEB( fprintf(stderr, " ^^ Remove file descriptor %5d from list %s List size after operation %d\n", s, (which_one == LIST_CALLONCONNECT) ? "CallOnConnect" : (which_one == LIST_DETACH) ? "Detach" : (which_one == LIST_TIMEOUT) ? "Timeout" : (which_one == LIST_RETRY) ? "Retry" : (which_one == LIST_CLOSE) ? "Close" : "<undef>", ref.size());) #else DEB( fprintf(stderr, " ^^ Remove file descriptor %5d from list %s List size after operation %d\n", s, (which_one == LIST_CALLONCONNECT) ? "CallOnConnect" : (which_one == LIST_TIMEOUT) ? "Timeout" : (which_one == LIST_RETRY) ? "Retry" : (which_one == LIST_CLOSE) ? "Close" : "<undef>", ref.size());) #endif } if (it == ref.end()) { break; } } } #ifdef ENABLE_TRIGGERS int SocketHandler::TriggerID(Socket *src) { int id = m_next_trigger_id++; m_trigger_src[id] = src; return id; } bool SocketHandler::Subscribe(int id, Socket *dst) { if (m_trigger_src.find(id) != m_trigger_src.end()) { std::map<Socket *, bool>::iterator it = m_trigger_dst[id].find(dst); if (it != m_trigger_dst[id].end()) { m_trigger_dst[id][dst] = true; return true; } LogError(dst, "Subscribe", id, "Already subscribed", LOG_LEVEL_INFO); return false; } LogError(dst, "Subscribe", id, "Trigger id not found", LOG_LEVEL_INFO); return false; } bool SocketHandler::Unsubscribe(int id, Socket *dst) { if (m_trigger_src.find(id) != m_trigger_src.end()) { std::map<Socket *, bool>::iterator it = m_trigger_dst[id].find(dst); if (it != m_trigger_dst[id].end()) { m_trigger_dst[id].erase(it); return true; } LogError(dst, "Unsubscribe", id, "Not subscribed", LOG_LEVEL_INFO); return false; } LogError(dst, "Unsubscribe", id, "Trigger id not found", LOG_LEVEL_INFO); return false; } void SocketHandler::Trigger(int id, Socket::TriggerData& data, bool erase) { if (m_trigger_src.find(id) != m_trigger_src.end()) { data.SetSource( m_trigger_src[id] ); for (std::map<Socket *, bool>::iterator it = m_trigger_dst[id].begin(); it != m_trigger_dst[id].end(); ++it) { Socket *dst = it -> first; if (Valid(dst)) { dst -> OnTrigger(id, data); } } if (erase) { m_trigger_src.erase(m_trigger_src.find(id)); m_trigger_dst.erase(m_trigger_dst.find(id)); } } else { LogError(NULL, "Trigger", id, "Trigger id not found", LOG_LEVEL_INFO); } } #endif // ENABLE_TRIGGERS | int SocketHandler::Select(long sec,long usec) { struct timeval tv; tv.tv_sec = sec; tv.tv_usec = usec; return Select(&tv); } int SocketHandler::Select() { if (m_b_check_callonconnect || m_b_check_detach || m_b_check_timeout || m_b_check_retry || m_b_check_close) { return Select(0, 200000); } return Select(NULL); } int SocketHandler::Select(struct timeval *tsel) { if (!m_add.empty()) { AddIncoming(); } #ifdef MACOSX fd_set rfds; fd_set wfds; fd_set efds; FD_COPY(&m_rfds, &rfds); FD_COPY(&m_wfds, &wfds); FD_COPY(&m_efds, &efds); #else fd_set rfds = m_rfds; fd_set wfds = m_wfds; fd_set efds = m_efds; #endif int n; DEB( printf("select( %d, [", m_maxsock + 1); for (size_t i = 0; i <= m_maxsock; i++) if (FD_ISSET(i, &rfds)) printf(" %d", i); printf("], ["); for (size_t i = 0; i <= m_maxsock; i++) if (FD_ISSET(i, &wfds)) printf(" %d", i); printf("], ["); for (size_t i = 0; i <= m_maxsock; i++) if (FD_ISSET(i, &efds)) printf(" %d", i); printf("]\n"); ) if (m_b_use_mutex) { m_mutex.Unlock(); n = select( (int)(m_maxsock + 1),&rfds,&wfds,&efds,tsel); m_mutex.Lock(); } else { n = select( (int)(m_maxsock + 1),&rfds,&wfds,&efds,tsel); } if (n == -1) // error on select { /* EBADF An invalid file descriptor was given in one of the sets. EINTR A non blocked signal was caught. EINVAL n is negative. Or struct timeval contains bad time values (<0). ENOMEM select was unable to allocate memory for internal tables. */ if (Errno == EBADF) { RebuildFdset(); } else if (Errno == EINTR) { } else if (Errno == EINVAL) { LogError(NULL, "SocketHandler::Select", Errno, StrError(Errno), LOG_LEVEL_FATAL); throw Exception("select(n): n is negative. Or struct timeval contains bad time values (<0)."); } else if (Errno == ENOMEM) { LogError(NULL, "SocketHandler::Select", Errno, StrError(Errno), LOG_LEVEL_ERROR); } } else if (!n) // timeout { } else if (n > 0) { for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++) { SOCKET i = it -> first; Socket *p = it -> second; // --------------------------------------------------------------------------------- if (FD_ISSET(i, &rfds)) { #ifdef HAVE_OPENSSL if (p -> IsSSLNegotiate()) { p -> SSLNegotiate(); } else #endif { p -> OnRead(); } } // --------------------------------------------------------------------------------- if (FD_ISSET(i, &wfds)) { #ifdef HAVE_OPENSSL if (p -> IsSSLNegotiate()) { p -> SSLNegotiate(); } else #endif { p -> OnWrite(); } } // --------------------------------------------------------------------------------- if (FD_ISSET(i, &efds)) { p -> OnException(); } } // m_sockets ... } // if (n > 0) // check CallOnConnect - EVENT if (m_b_check_callonconnect) { CheckCallOnConnect(); } #ifdef ENABLE_DETACH // check detach of socket if master handler - EVENT if (!m_slave && m_b_check_detach) { CheckDetach(); } #endif // check Connecting - connection timeout - conditional event if (m_b_check_timeout) { time_t tnow = time(NULL); if (tnow != m_tlast) { CheckTimeout(tnow); m_tlast = tnow; } // tnow != tlast } // check retry client connect - EVENT if (m_b_check_retry) { CheckRetry(); } // check close and delete - conditional event if (m_b_check_close) { CheckClose(); } if (!m_fds_erase.empty()) { CheckErasedSockets(); } // remove Add's that fizzed while (m_delete.size()) { std::list<Socket *>::iterator it = m_delete.begin(); Socket *p = *it; p -> OnDelete(); m_delete.erase(it); if (p -> DeleteByHandler() #ifdef ENABLE_DETACH && !(m_slave ^ p -> IsDetached()) #endif ) { p -> SetErasedByHandler(); delete p; } } return n; } |
SocketHandler.h | |
| /usr/src/Sockets-2.3.9/SocketHandler.h 2010-01-28 16:23:34.0, 0100 | /usr/src/Sockets-2.3.9.1/SocketHandler.h 2010-02-09 21:16:33.0, 0100 |
| Line 4 in SocketHandler.h | Line 4 in SocketHandler.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 110 in SocketHandler.h | Line 110 in SocketHandler.h |
bool OkToAccept(Socket *p); /** Called by Socket when a socket changes state. */ void AddList(SOCKET s,list_t which_one,bool add); // Connection pool | bool OkToAccept(Socket *p); /** Use with care, always lock with h.GetMutex() if multithreaded */ const std::map<SOCKET, Socket *>& AllSockets() { return m_sockets; } size_t MaxTcpLineSize() { return TCP_LINE_SIZE; } void SetCallOnConnect(bool = true); void SetDetach(bool = true); void SetTimeout(bool = true); void SetRetry(bool = true); void SetClose(bool = true); // Connection pool |
| Line 178 in SocketHandler.h | Line 186 in SocketHandler.h |
#endif // ENABLE_RESOLVER #ifdef ENABLE_TRIGGERS /** Fetch unique trigger id. */ int TriggerID(Socket *src); /** Subscribe socket to trigger id. */ bool Subscribe(int id, Socket *dst); /** Unsubscribe socket from trigger id. */ bool Unsubscribe(int id, Socket *dst); /** Execute OnTrigger for subscribed sockets. \param id Trigger ID \param data Data passed from source to destination \param erase Empty trigger id source and destination maps if 'true', Leave them in place if 'false' - if a trigger should be called many times */ void Trigger(int id, Socket::TriggerData& data, bool erase = true); #endif // ENABLE_TRIGGERS #ifdef ENABLE_DETACH /** Indicates that the handler runs under SocketThread. */ | |
| Line 200 in SocketHandler.h | Line 193 in SocketHandler.h |
#endif /** Sanity check of those accursed lists. */ void CheckSanity(); /** Use with care, always lock with h.GetMutex() if multithreaded */ const std::map<SOCKET, Socket *>& AllSockets() { return m_sockets; } size_t MaxTcpLineSize() { return TCP_LINE_SIZE; } protected: socket_m m_sockets; ///< Active sockets map socket_m m_add; ///< Sockets to be added to sockets map std::list<Socket *> m_delete; ///< Sockets to be deleted (failed when Add) | #endif protected: socket_m m_sockets; ///< Active sockets map std::list<Socket *> m_add; ///< Sockets to be added to sockets map std::list<Socket *> m_delete; ///< Sockets to be deleted (failed when Add) |
| Line 221 in SocketHandler.h | Line 206 in SocketHandler.h |
private: void CheckList(socket_v&,const std::string&); ///< Used by CheckSanity SOCKET m_maxsock; ///< Highest file descriptor + 1 in active sockets list fd_set m_rfds; ///< file descriptor set monitored for read events fd_set m_wfds; ///< file descriptor set monitored for write events fd_set m_efds; ///< file descriptor set monitored for exceptions int m_preverror; ///< debug select() error int m_errcnt; ///< debug select() error time_t m_tlast; ///< timeout control // state lists socket_v m_fds; ///< Active file descriptor list socket_v m_fds_erase; ///< File descriptors that are to be erased from m_sockets socket_v m_fds_callonconnect; ///< checklist CallOnConnect #ifdef ENABLE_DETACH socket_v m_fds_detach; ///< checklist Detach #endif socket_v m_fds_timeout; ///< checklist timeout socket_v m_fds_retry; ///< checklist retry client connect socket_v m_fds_close; ///< checklist close and delete #ifdef ENABLE_SOCKS4 | private: /** Schedule socket for deletion */ void DeleteSocket(Socket *); void RebuildFdset(); void AddIncoming(); void CheckErasedSockets(); void CheckCallOnConnect(); void CheckDetach(); void CheckTimeout(time_t); void CheckRetry(); void CheckClose(); // SOCKET m_maxsock; ///< Highest file descriptor + 1 in active sockets list fd_set m_rfds; ///< file descriptor set monitored for read events fd_set m_wfds; ///< file descriptor set monitored for write events fd_set m_efds; ///< file descriptor set monitored for exceptions time_t m_tlast; ///< timeout control // state lists std::list<socketuid_t> m_fds_erase; ///< File descriptors that are to be erased from m_sockets bool m_b_check_callonconnect; bool m_b_check_detach; bool m_b_check_timeout; bool m_b_check_retry; bool m_b_check_close; #ifdef ENABLE_SOCKS4 |
| Line 256 in SocketHandler.h | Line 248 in SocketHandler.h |
bool m_b_enable_pool; ///< Connection pool enabled if true #endif #ifdef ENABLE_TRIGGERS int m_next_trigger_id; ///< Unique trigger id counter std::map<int, Socket *> m_trigger_src; ///< mapping trigger id to source socket std::map<int, std::map<Socket *, bool> > m_trigger_dst; ///< mapping trigger id to destination sockets #endif #ifdef ENABLE_DETACH bool m_slave; ///< Indicates that this is a ISocketHandler run in SocketThread | |
socket_include.cpp | |
| /usr/src/Sockets-2.3.9/socket_include.cpp 2009-08-24 18:50:24.0, 0200 | /usr/src/Sockets-2.3.9.1/socket_include.cpp 2010-02-09 21:16:34.0, 0100 |
| Line 4 in socket_include.cpp | Line 4 in socket_include.cpp |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 85 in socket_include.cpp | Line 85 in socket_include.cpp |
break; } sprintf(tmp, "Winsock error code: %d", x); return tmp; } | break; } #ifdef _WIN32 sprintf_s(tmp, sizeof(tmp), "Winsock error code: %d", x); #else snprintf(tmp, sizeof(tmp), "Winsock error code: %d", x); #endif return tmp; } |
socket_include.h | |
| /usr/src/Sockets-2.3.9/socket_include.h 2009-08-24 18:45:44.0, 0200 | /usr/src/Sockets-2.3.9.1/socket_include.h 2010-02-09 21:16:36.0, 0100 |
| Line 4 in socket_include.h | Line 4 in socket_include.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 184 in socket_include.h | Line 184 in socket_include.h |
#endif #define strcasecmp _stricmp #define snprintf sprintf_s typedef unsigned long ipaddr_t; | |
sockets-config.h | |
| /usr/src/Sockets-2.3.9/sockets-config.h 2010-01-29 11:53:34.0, 0100 | /usr/src/Sockets-2.3.9.1/sockets-config.h 2010-02-09 21:26:29.0, 0100 |
| Line 5 in sockets-config.h | Line 5 in sockets-config.h |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 49 in sockets-config.h | Line 49 in sockets-config.h |
#undef ENABLE_RECONNECT #undef ENABLE_DETACH #undef ENABLE_TRIGGERS #undef ENABLE_EXCEPTIONS #undef ENABLE_XML | |
| Line 95 in sockets-config.h | Line 94 in sockets-config.h |
/* Enable socket to socket triggers. Not yet in use. */ //#define ENABLE_TRIGGERS /* Enabled exceptions. */ #define ENABLE_EXCEPTIONS | |
| Line 104 in sockets-config.h | Line 99 in sockets-config.h |
/* XML classes. */ #define ENABLE_XML | /* XML classes. */ //#define ENABLE_XML |
SocketStream.cpp | |
| /usr/src/Sockets-2.3.9/SocketStream.cpp 2009-08-24 18:50:31.0, 0200 | /usr/src/Sockets-2.3.9.1/SocketStream.cpp 2010-02-09 21:16:49.0, 0100 |
| Line 5 in SocketStream.cpp | Line 5 in SocketStream.cpp |
**/ /* Copyright (C) 2008-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2008-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
SocketStream.h | |
| /usr/src/Sockets-2.3.9/SocketStream.h 2009-09-16 06:18:54.0, 0200 | /usr/src/Sockets-2.3.9.1/SocketStream.h 2010-02-09 21:16:50.0, 0100 |
| Line 5 in SocketStream.h | Line 5 in SocketStream.h |
**/ /* Copyright (C) 2008-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2008-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
SSLInitializer.cpp | |
| /usr/src/Sockets-2.3.9/SSLInitializer.cpp 2009-08-24 18:50:35.0, 0200 | /usr/src/Sockets-2.3.9.1/SSLInitializer.cpp 2010-02-09 21:16:51.0, 0100 |
| Line 5 in SSLInitializer.cpp | Line 5 in SSLInitializer.cpp |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 77 in SSLInitializer.cpp | Line 77 in SSLInitializer.cpp |
CRYPTO_set_id_callback( SSL_id_function ); char *randfile = getenv("RANDFILE"); char *home = getenv("HOME"); if (!randfile && !home) { char *homepath = getenv("HOMEPATH"); if (homepath) { Utility::SetEnv("HOME", homepath); | CRYPTO_set_id_callback( SSL_id_function ); std::string randfile = Utility::GetEnv("RANDFILE"); std::string home = Utility::GetEnv("HOME"); if (randfile.empty() && home.empty()) { std::string homepath = Utility::GetEnv("HOMEPATH"); if (!homepath.empty()) { Utility::SetEnv("HOME", homepath); |
| Line 122 in SSLInitializer.cpp | Line 122 in SSLInitializer.cpp |
if (m_rand_file.size()) { #ifdef _WIN32 _unlink(m_rand_file.c_str()); #else unlink(m_rand_file.c_str()); #endif } } | |
SSLInitializer.h | |
| /usr/src/Sockets-2.3.9/SSLInitializer.h 2009-08-24 18:46:00.0, 0200 | /usr/src/Sockets-2.3.9.1/SSLInitializer.h 2010-02-09 21:16:52.0, 0100 |
| Line 5 in SSLInitializer.h | Line 5 in SSLInitializer.h |
**/ /* Copyright (C) 2007-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2007-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
StdLog.h | |
| /usr/src/Sockets-2.3.9/StdLog.h 2010-01-29 22:38:58.0, 0100 | /usr/src/Sockets-2.3.9.1/StdLog.h 2010-02-09 21:16:53.0, 0100 |
| Line 4 in StdLog.h | Line 4 in StdLog.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
StdoutLog.cpp | |
| /usr/src/Sockets-2.3.9/StdoutLog.cpp 2010-01-29 22:39:20.0, 0100 | /usr/src/Sockets-2.3.9.1/StdoutLog.cpp 2010-02-09 21:16:54.0, 0100 |
| Line 4 in StdoutLog.cpp | Line 4 in StdoutLog.cpp |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 50 in StdoutLog.cpp | Line 50 in StdoutLog.cpp |
struct tm tp; #ifdef _WIN32 memcpy(&tp, localtime(&t), sizeof(tp)); #else localtime_r(&t, &tp); | struct tm tp; #ifdef _WIN32 localtime_s(&tp, &t); #else localtime_r(&t, &tp); |
StdoutLog.h | |
| /usr/src/Sockets-2.3.9/StdoutLog.h 2010-01-29 22:47:16.0, 0100 | /usr/src/Sockets-2.3.9.1/StdoutLog.h 2010-02-09 21:16:55.0, 0100 |
| Line 4 in StdoutLog.h | Line 4 in StdoutLog.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
StreamSocket.cpp | |
| /usr/src/Sockets-2.3.9/StreamSocket.cpp 2009-08-24 18:50:45.0, 0200 | /usr/src/Sockets-2.3.9.1/StreamSocket.cpp 2010-02-09 21:16:56.0, 0100 |
| Line 5 in StreamSocket.cpp | Line 5 in StreamSocket.cpp |
**/ /* Copyright (C) 2008-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2008-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 46 in StreamSocket.cpp | Line 46 in StreamSocket.cpp |
,m_connection_retry(0) ,m_retries(0) ,m_call_on_connect(false) ,m_b_retry_connect(false) ,m_line_protocol(false) ,m_shutdown(0) | |
| Line 144 in StreamSocket.cpp | Line 142 in StreamSocket.cpp |
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) { | |
StreamSocket.h | |
| /usr/src/Sockets-2.3.9/StreamSocket.h 2009-08-24 18:46:17.0, 0200 | /usr/src/Sockets-2.3.9.1/StreamSocket.h 2010-02-09 21:16:57.0, 0100 |
| Line 5 in StreamSocket.h | Line 5 in StreamSocket.h |
**/ /* Copyright (C) 2008-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2008-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 96 in StreamSocket.h | Line 96 in StreamSocket.h |
void ResetConnectionRetries(); // LIST_CALLONCONNECT /** Instruct socket to call OnConnect callback next sockethandler cycle. */ void SetCallOnConnect(bool x = true); /** Check call on connect flag. \return true if OnConnect() should be called a.s.a.p */ bool CallOnConnect(); // LIST_RETRY /** Set flag to initiate a connection attempt after a connection timeout. */ void SetRetryClientConnect(bool x = true); /** Check if a connection attempt should be made. \return true when another attempt should be made */ bool RetryClientConnect(); /** Called after OnRead if socket is in line protocol mode. \sa SetLineProtocol */ | |
| Line 144 in StreamSocket.h | Line 126 in StreamSocket.h |
int m_connection_retry; ///< Maximum connection retries (tcp) int m_retries; ///< Actual number of connection retries (tcp) bool m_call_on_connect; ///< OnConnect will be called next ISocketHandler cycle if true bool m_b_retry_connect; ///< Try another connection attempt next ISocketHandler cycle bool m_line_protocol; ///< Line protocol mode flag int m_shutdown; ///< Shutdown status | |
StreamWriter.cpp | |
| /usr/src/Sockets-2.3.9/StreamWriter.cpp 2009-08-24 18:50:50.0, 0200 | /usr/src/Sockets-2.3.9.1/StreamWriter.cpp 2010-02-09 21:16:58.0, 0100 |
| Line 5 in StreamWriter.cpp | Line 5 in StreamWriter.cpp |
**/ /* Copyright (C) 2008-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2008-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
StreamWriter.h | |
| /usr/src/Sockets-2.3.9/StreamWriter.h 2009-08-24 18:46:23.0, 0200 | /usr/src/Sockets-2.3.9.1/StreamWriter.h 2010-02-09 21:16:59.0, 0100 |
| Line 5 in StreamWriter.h | Line 5 in StreamWriter.h |
**/ /* Copyright (C) 2008-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2008-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
TcpSocket.cpp | |
| /usr/src/Sockets-2.3.9/TcpSocket.cpp 2010-01-28 16:24:29.0, 0100 | /usr/src/Sockets-2.3.9.1/TcpSocket.cpp 2010-02-09 21:17:00.0, 0100 |
| Line 4 in TcpSocket.cpp | Line 4 in TcpSocket.cpp |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 596 in TcpSocket.cpp | Line 596 in TcpSocket.cpp |
else { Handler().LogError(this, "TcpSocket::OnRead", m_line_ptr + sz, "maximum tcp_line_size exceeded, connection closed", LOG_LEVEL_FATAL); SetCloseAndDelete(); } | else { Handler().LogError(this, "TcpSocket::OnRead", (int)(m_line_ptr + sz), "maximum tcp_line_size exceeded, connection closed", LOG_LEVEL_FATAL); SetCloseAndDelete(); } |
| Line 638 in TcpSocket.cpp | Line 638 in TcpSocket.cpp |
else { Handler().LogError(this, "TcpSocket::OnRead", m_line_ptr + sz, "maximum tcp_line_size exceeded, connection closed", LOG_LEVEL_FATAL); SetCloseAndDelete(); } | else { Handler().LogError(this, "TcpSocket::OnRead", (int)(m_line_ptr + sz), "maximum tcp_line_size exceeded, connection closed", LOG_LEVEL_FATAL); SetCloseAndDelete(); } |
| Line 729 in TcpSocket.cpp | Line 729 in TcpSocket.cpp |
if (m_obuf.empty()) { Handler().LogError(this, "OnWrite", m_output_length, "Empty output buffer in OnWrite", LOG_LEVEL_ERROR); break; } | if (m_obuf.empty()) { Handler().LogError(this, "OnWrite", (int)m_output_length, "Empty output buffer in OnWrite", LOG_LEVEL_ERROR); break; } |
| Line 915 in TcpSocket.cpp | Line 915 in TcpSocket.cpp |
return; } #ifdef HAVE_OPENSSL if (IsSSL()) { | |
| Line 921 in TcpSocket.cpp | Line 922 in TcpSocket.cpp |
return; } #endif int n = TryWrite(buf, len); if (n >= 0 && n < (int)len) | |
| Line 994 in TcpSocket.cpp | Line 996 in TcpSocket.cpp |
} } #ifdef _WIN32 strcpy_s(request + 8, sizeof(request) - 8, GetSocks4Userid().c_str()); #else strcpy(request + 8, GetSocks4Userid().c_str()); #endif size_t length = GetSocks4Userid().size() + 8 + 1; SendBuf(request, length); | |
| Line 1083 in TcpSocket.cpp | Line 1089 in TcpSocket.cpp |
char slask[5000]; // vsprintf / vsnprintf temporary #ifdef _WIN32 vsprintf(slask, format, ap); #else vsnprintf(slask, 5000, format, ap); #endif va_end(ap); | char slask[5000]; // vsprintf / vsnprintf temporary #ifdef _WIN32 vsprintf_s(slask, sizeof(slask), format, ap); #else vsnprintf(slask, sizeof(slask), format, ap); #endif va_end(ap); |
| Line 1376 in TcpSocket.cpp | Line 1382 in TcpSocket.cpp |
return 0; } #ifdef _WIN32 strcpy_s(buf, num, pw.c_str()); #else strcpy(buf,pw.c_str()); #endif return (int)pw.size(); } | |
| Line 1731 in TcpSocket.cpp | Line 1741 in TcpSocket.cpp |
/// \todo state reason why connect failed OnConnectFailed(); // SetConnecting(false); } } | |
| Line 1738 in TcpSocket.cpp | Line 1750 in TcpSocket.cpp |
/// \todo state reason why connect failed OnConnectFailed(); } // SetConnecting(false); } | /// \todo state reason why connect failed OnConnectFailed(); // SetConnecting(false); } } |
TcpSocket.h | |
| /usr/src/Sockets-2.3.9/TcpSocket.h 2010-01-28 15:59:15.0, 0100 | /usr/src/Sockets-2.3.9.1/TcpSocket.h 2010-02-09 21:17:01.0, 0100 |
| Line 4 in TcpSocket.h | Line 4 in TcpSocket.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Thread.cpp | |
| /usr/src/Sockets-2.3.9/Thread.cpp 2009-08-24 18:50:59.0, 0200 | /usr/src/Sockets-2.3.9.1/Thread.cpp 2010-02-09 21:17:02.0, 0100 |
| Line 4 in Thread.cpp | Line 4 in Thread.cpp |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Thread.h | |
| /usr/src/Sockets-2.3.9/Thread.h 2010-01-24 10:07:13.0, 0100 | /usr/src/Sockets-2.3.9.1/Thread.h 2010-02-09 21:17:03.0, 0100 |
| Line 4 in Thread.h | Line 4 in Thread.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
UdpSocket.cpp | |
| /usr/src/Sockets-2.3.9/UdpSocket.cpp 2009-08-24 18:51:03.0, 0200 | /usr/src/Sockets-2.3.9.1/UdpSocket.cpp 2010-02-09 21:17:04.0, 0100 |
| Line 4 in UdpSocket.cpp | Line 4 in UdpSocket.cpp |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
UdpSocket.h | |
| /usr/src/Sockets-2.3.9/UdpSocket.h 2009-08-24 18:46:35.0, 0200 | /usr/src/Sockets-2.3.9.1/UdpSocket.h 2010-02-09 21:17:05.0, 0100 |
| Line 4 in UdpSocket.h | Line 4 in UdpSocket.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
Utility.cpp | |
| /usr/src/Sockets-2.3.9/Utility.cpp 2010-01-27 05:59:24.0, 0100 | /usr/src/Sockets-2.3.9.1/Utility.cpp 2010-02-09 21:17:08.0, 0100 |
| Line 4 in Utility.cpp | Line 4 in Utility.cpp |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 205 in Utility.cpp | Line 205 in Utility.cpp |
std::string str; char tmp[100]; sprintf(tmp,"%ld",l); str = tmp; return str; | std::string str; char tmp[100]; snprintf(tmp,sizeof(tmp),"%ld",l); str = tmp; return str; |
| Line 431 in Utility.cpp | Line 431 in Utility.cpp |
x = ntohs(addr16[i]); if (*slask && (x || !ok_to_skip || prev)) strcat(slask,":"); if (x || !ok_to_skip) { sprintf(slask + strlen(slask),"%x", x); if (x && skipped) ok_to_skip = false; | x = ntohs(addr16[i]); if (*slask && (x || !ok_to_skip || prev)) { #ifdef _WIN32 strcat_s(slask,sizeof(slask),":"); #else strcat(slask,":"); #endif } if (x || !ok_to_skip) { snprintf(slask + strlen(slask),sizeof(slask) - strlen(slask),"%x", x); if (x && skipped) ok_to_skip = false; |
| Line 445 in Utility.cpp | Line 451 in Utility.cpp |
} x = ntohs(addr16[6]); sprintf(slask + strlen(slask),":%u.%u",x / 256,x & 255); x = ntohs(addr16[7]); sprintf(slask + strlen(slask),".%u.%u",x / 256,x & 255); } else | } x = ntohs(addr16[6]); snprintf(slask + strlen(slask),sizeof(slask) - strlen(slask),":%u.%u",x / 256,x & 255); x = ntohs(addr16[7]); snprintf(slask + strlen(slask),sizeof(slask) - strlen(slask),".%u.%u",x / 256,x & 255); } else |
| Line 560 in Utility.cpp | Line 566 in Utility.cpp |
const std::string Utility::GetEnv(const std::string& name) { #ifdef _WIN32 size_t sz = 0; char tmp[2048]; if (getenv_s(&sz, tmp, sizeof(tmp), name.c_str())) { *tmp = 0; } return tmp; #else char *s = getenv(name.c_str()); if (!s) return ""; return s; #endif } void Utility::SetEnv(const std::string& var,const std::string& value) { | |
| Line 569 in Utility.cpp | Line 594 in Utility.cpp |
delete[] vmap[var]; } vmap[var] = new char[var.size() + 1 + value.size() + 1]; sprintf(vmap[var], "%s=%s", var.c_str(), value.c_str()); putenv( vmap[var] ); } | delete[] vmap[var]; } size_t sz = var.size() + 1 + value.size() + 1; vmap[var] = new char[sz]; snprintf(vmap[var], sz, "%s=%s", var.c_str(), value.c_str()); putenv( vmap[var] ); } |
| Line 771 in Utility.cpp | Line 797 in Utility.cpp |
unsigned long b2 = static_cast<unsigned long>(pa.getvalue()); unsigned long b3 = static_cast<unsigned long>(pa.getvalue()); sprintf(slask,"%lx",b0 * 256 + b1); vec.push_back(slask); sprintf(slask,"%lx",b2 * 256 + b3); vec.push_back(slask); } | unsigned long b2 = static_cast<unsigned long>(pa.getvalue()); unsigned long b3 = static_cast<unsigned long>(pa.getvalue()); snprintf(slask,sizeof(slask),"%lx",b0 * 256 + b1); vec.push_back(slask); snprintf(slask,sizeof(slask),"%lx",b2 * 256 + b3); vec.push_back(slask); } |
| Line 891 in Utility.cpp | Line 917 in Utility.cpp |
memcpy(&u.l, &sa_in -> sin_addr, sizeof(u.l)); char tmp[100]; sprintf(tmp, "%u.%u.%u.%u", u.a.b1, u.a.b2, u.a.b3, u.a.b4); hostname = tmp; return true; | memcpy(&u.l, &sa_in -> sin_addr, sizeof(u.l)); char tmp[100]; snprintf(tmp, sizeof(tmp), "%u.%u.%u.%u", u.a.b1, u.a.b2, u.a.b3, u.a.b4); hostname = tmp; return true; |
| Line 923 in Utility.cpp | Line 949 in Utility.cpp |
unsigned short x = ntohs(addr16[i]); if (*slask && (x || !ok_to_skip || prev)) strcat(slask,":"); if (x || !ok_to_skip) { sprintf(slask + strlen(slask),"%x", x); if (x && skipped) ok_to_skip = false; | unsigned short x = ntohs(addr16[i]); if (*slask && (x || !ok_to_skip || prev)) { #ifdef _WIN32 strcat_s(slask, sizeof(slask),":"); #else strcat(slask,":"); #endif } if (x || !ok_to_skip) { snprintf(slask + strlen(slask), sizeof(slask) - strlen(slask),"%x", x); if (x && skipped) ok_to_skip = false; |
| Line 938 in Utility.cpp | Line 970 in Utility.cpp |
} if (!*slask) { #ifdef _WIN32 strcpy_s(slask, sizeof(slask), "::"); #else strcpy(slask, "::"); #endif } hostname = slask; return true; | |
| Line 1057 in Utility.cpp | Line 1095 in Utility.cpp |
{ char tmp[100]; sprintf(tmp, "%f", d); return tmp; } | { char tmp[100]; snprintf(tmp, sizeof(tmp), "%f", d); return tmp; } |
| Line 1315 in Utility.cpp | Line 1353 in Utility.cpp |
const Utility::Path Utility::GetCurrentDirectory() { #ifdef _WIN32 #else char slask[32000]; | const Utility::Path Utility::CurrentDirectory() { #ifdef _WIN32 TCHAR slask[MAX_PATH + 1]; DWORD ret = #ifdef UNICODE ::GetCurrentDirectoryW(MAX_PATH, slask); #else ::GetCurrentDirectoryA(MAX_PATH, slask); #endif if (!ret) { *slask = 0; DWORD err = GetLastError(); } return Path(slask); #else char slask[32000]; |
| Line 1332 in Utility.cpp | Line 1383 in Utility.cpp |
{ #ifdef _WIN32 return SetCurrentDirectory(to_dir.GetPath().c_str()) ? true : false; #else if (chdir( to_dir.GetPath().c_str() ) == -1) | |
Utility.h | |
| /usr/src/Sockets-2.3.9/Utility.h 2010-01-27 06:03:46.0, 0100 | /usr/src/Sockets-2.3.9.1/Utility.h 2010-02-09 21:17:10.0, 0100 |
| Line 4 in Utility.h | Line 4 in Utility.h |
**/ /* Copyright (C) 2004-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2004-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
| Line 183 in Utility.h | Line 183 in Utility.h |
#endif #endif /** Get environment variable */ static const std::string GetEnv(const std::string& name); /** Set environment variable. \param var Name of variable to set | |
| Line 215 in Utility.h | Line 217 in Utility.h |
/** File system stuff */ static const Path GetCurrentDirectory(); static bool ChangeDirectory(const Path& to_dir); | /** File system stuff */ static const Path CurrentDirectory(); static bool ChangeDirectory(const Path& to_dir); |
XmlDocument.cpp | |
| /usr/src/Sockets-2.3.9/XmlDocument.cpp 2009-08-24 18:51:15.0, 0200 | /usr/src/Sockets-2.3.9.1/XmlDocument.cpp 2010-02-09 21:17:11.0, 0100 |
| Line 5 in XmlDocument.cpp | Line 5 in XmlDocument.cpp |
**/ /* Copyright (C) 2008-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2008-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
XmlDocument.h | |
| /usr/src/Sockets-2.3.9/XmlDocument.h 2009-08-24 18:46:49.0, 0200 | /usr/src/Sockets-2.3.9.1/XmlDocument.h 2010-02-09 21:17:12.0, 0100 |
| Line 5 in XmlDocument.h | Line 5 in XmlDocument.h |
**/ /* Copyright (C) 2008-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2008-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
XmlException.cpp | |
| /usr/src/Sockets-2.3.9/XmlException.cpp 2009-08-24 18:51:20.0, 0200 | /usr/src/Sockets-2.3.9.1/XmlException.cpp 2010-02-09 21:17:13.0, 0100 |
| Line 5 in XmlException.cpp | Line 5 in XmlException.cpp |
**/ /* Copyright (C) 2008-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2008-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
XmlException.h | |
| /usr/src/Sockets-2.3.9/XmlException.h 2009-08-24 18:46:54.0, 0200 | /usr/src/Sockets-2.3.9.1/XmlException.h 2010-02-09 21:17:14.0, 0100 |
| Line 5 in XmlException.h | Line 5 in XmlException.h |
**/ /* Copyright (C) 2008-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2008-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
XmlNode.cpp | |
| /usr/src/Sockets-2.3.9/XmlNode.cpp 2009-08-25 12:52:21.0, 0200 | /usr/src/Sockets-2.3.9.1/XmlNode.cpp 2010-02-09 21:17:15.0, 0100 |
| Line 5 in XmlNode.cpp | Line 5 in XmlNode.cpp |
**/ /* Copyright (C) 2008-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2008-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |
XmlNode.h | |
| /usr/src/Sockets-2.3.9/XmlNode.h 2009-08-25 12:50:53.0, 0200 | /usr/src/Sockets-2.3.9.1/XmlNode.h 2010-02-09 21:17:16.0, 0100 |
| Line 5 in XmlNode.h | Line 5 in XmlNode.h |
**/ /* Copyright (C) 2008-2009 Anders Hedstrom This library is made available under the terms of the GNU GPL, with | **/ /* Copyright (C) 2008-2010 Anders Hedstrom This library is made available under the terms of the GNU GPL, with |