Google
Web alhem.net
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

FinderHandler Class Reference

#include <FinderHandler.h>

Collaboration diagram for FinderHandler:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 FinderHandler (Database &)
 ~FinderHandler ()
Database & GetDatabase ()
std::string datetime2httpdate (const std::string &dt)
std::string GetStart ()
std::string GetDate ()
std::string GetMimeFromFile (const std::string &)
std::string GetVersion ()
unsigned char * GetKey_m2minion ()
size_t MinionSockets ()
unsigned long Get_tdiff ()
unsigned long Get_tdiff2 ()
void CheckSocketTimeout ()
void BeginTop ()
void EndTop ()
int FinderSockets ()

Private Attributes

Database & m_db
time_t m_start
Mime m_mime
unsigned long m_tdiff
unsigned long m_tdiff2

Static Private Attributes

unsigned char m_m2minion [32]

Constructor & Destructor Documentation

FinderHandler::FinderHandler Database &   ) 
 

Definition at line 50 of file FinderHandler.cpp.

References FinderHandler().

Referenced by FinderHandler().

00050 : MinderHandler() 00051 ,m_db(p) 00052 ,m_start(time(NULL)) 00053 ,m_mime("mime.types") 00054 { 00055 }

FinderHandler::~FinderHandler  ) 
 

Definition at line 58 of file FinderHandler.cpp.

00059 { 00060 }


Member Function Documentation

void FinderHandler::BeginTop  ) 
 

Definition at line 184 of file FinderHandler.cpp.

References GetVersion().

Referenced by start().

00185 { 00186 std::string msg = "Tip_" + Utility::l2string(GetHostId()); 00187 SendMessage(Utility::base64(msg)); 00188 unlink("top_map.dot"); 00189 FILE *fil; 00190 00191 if ((fil = fopen("top_map.dot","wt")) != NULL) 00192 { 00193 fprintf(fil,"digraph \"G\" {\n"); 00194 fprintf(fil,"\tedge [arrowhead=open]\n"); 00195 #ifdef _WIN32 00196 std::string os = "Win32"; 00197 #else 00198 std::string os = "Linux"; 00199 #endif 00200 fprintf(fil,"\t\"%ld\" [label=\"%ld\\n%s\\n%s\" style=filled fillcolor=\"#e0e0e0\"]\n", 00201 GetHostId(), 00202 GetHostId(), 00203 GetVersion().c_str(), 00204 os.c_str()); 00205 Tops(fil); 00206 fclose(fil); 00207 } 00208 }

void FinderHandler::CheckSocketTimeout  ) 
 

Definition at line 173 of file FinderHandler.cpp.

00174 { 00175 time_t tnow = time(NULL); 00176 for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++) 00177 { 00178 Socket *p0 = (*it).second; 00179 ExecSocket *sock = dynamic_cast<ExecSocket *>(p0); 00180 } 00181 }

std::string FinderHandler::datetime2httpdate const std::string &  dt  ) 
 

Definition at line 63 of file FinderHandler.cpp.

References datetime2httpdate().

Referenced by datetime2httpdate(), and GetStart().

00064 { 00065 char slask[8]; 00066 struct tm tp; 00067 time_t t; 00068 char *days[] = { "Sun","Mon","Tue","Wed","Thu","Fri","Sat" }; 00069 char *months[] = { "Jan","Feb","Mar","Apr","May","Jun", 00070 "Jul","Aug","Sep","Oct","Nov","Dec" }; 00071 int i; 00072 char s[40]; 00073 00074 /* 1997-12-16 09:50:40 */ 00075 00076 if (dt.size() == 19) // && (int)strlen(dt) == 19) 00077 { 00078 slask[4] = 0; 00079 tp.tm_year = atoi(strncpy(slask,dt.c_str(),4)) - 1900; 00080 slask[2] = 0; 00081 i = atoi(strncpy(slask,dt.c_str() + 5,2)) - 1; 00082 tp.tm_mon = i >= 0 ? i : 0; 00083 tp.tm_mday = atoi(strncpy(slask,dt.c_str() + 8,2)); 00084 tp.tm_hour = atoi(strncpy(slask,dt.c_str() + 11,2)); 00085 tp.tm_min = atoi(strncpy(slask,dt.c_str() + 14,2)); 00086 tp.tm_sec = atoi(strncpy(slask,dt.c_str() + 17,2)); 00087 tp.tm_wday = 0; 00088 tp.tm_yday = 0; 00089 tp.tm_isdst = 0; 00090 t = mktime(&tp); 00091 if (t == -1) 00092 { 00093 this->LogError(NULL, "datetime2httpdate", 0, "mktime() failed"); 00094 } 00095 00096 sprintf(s,"%s, %02d %s %d %02d:%02d:%02d GMT", 00097 days[tp.tm_wday], 00098 tp.tm_mday, 00099 months[tp.tm_mon], 00100 tp.tm_year + 1900, 00101 tp.tm_hour,tp.tm_min,tp.tm_sec); 00102 } 00103 else 00104 { 00105 *s = 0; 00106 } 00107 return s; 00108 }

void FinderHandler::EndTop  ) 
 

Definition at line 211 of file FinderHandler.cpp.

Referenced by start().

00212 { 00213 FILE *fil = fopen("top_map.dot","at"); 00214 char cmd[200]; 00215 if (fil) 00216 { 00217 fprintf(fil,"}\n"); 00218 fclose(fil); 00219 sprintf(cmd, "DOT.EXE -Tpng -o top_map.png top_map.dot"); 00220 system( cmd ); 00221 unlink("top_map.dot"); 00222 } 00223 }

int FinderHandler::FinderSockets  ) 
 

Definition at line 226 of file FinderHandler.cpp.

00227 { 00228 int q = 0; 00229 for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++) 00230 { 00231 Socket *p0 = (*it).second; 00232 if (dynamic_cast<ExecSocket *>(p0)) 00233 { 00234 q++; 00235 } 00236 } 00237 return q; 00238 }

unsigned long FinderHandler::Get_tdiff  )  [inline]
 

Definition at line 57 of file FinderHandler.h.

References m_tdiff.

00057 { return m_tdiff; }

unsigned long FinderHandler::Get_tdiff2  )  [inline]
 

Definition at line 58 of file FinderHandler.h.

References m_tdiff2.

00058 { return m_tdiff2; }

Database& FinderHandler::GetDatabase  )  [inline]
 

Definition at line 41 of file FinderHandler.h.

References m_db.

Referenced by MyMinionSocket::OnVerifiedLine().

00041 { return m_db; }

std::string FinderHandler::GetDate  ) 
 

Get current datetime yyyy-mm-dd hh:mm:ss

Definition at line 131 of file FinderHandler.cpp.

00132 { 00133 time_t t = time(NULL); 00134 struct tm* tp = localtime(&t); 00135 char slask[40]; 00136 if (tp) 00137 { 00138 sprintf(slask,"%d-%02d-%02d %02d:%02d:%02d", 00139 tp -> tm_year + 1900, 00140 tp -> tm_mon + 1, 00141 tp -> tm_mday, 00142 tp -> tm_hour,tp -> tm_min,tp -> tm_sec); 00143 } 00144 else 00145 { 00146 *slask = 0; 00147 } 00148 return slask; 00149 }

unsigned char* FinderHandler::GetKey_m2minion  )  [inline]
 

Definition at line 53 of file FinderHandler.h.

References m_m2minion.

00053 { return m_m2minion; }

std::string FinderHandler::GetMimeFromFile const std::string &   ) 
 

Definition at line 152 of file FinderHandler.cpp.

References Mime::GetMimeFromFile(), GetMimeFromFile(), and m_mime.

Referenced by GetMimeFromFile().

00153 { 00154 return m_mime.GetMimeFromFile(name); 00155 }

std::string FinderHandler::GetStart  ) 
 

Get server startup datetime in httpdate format

Definition at line 111 of file FinderHandler.cpp.

References datetime2httpdate(), and m_start.

00112 { 00113 struct tm* tp = localtime(&m_start); 00114 char slask[40]; 00115 if (tp) 00116 { 00117 sprintf(slask,"%d-%02d-%02d %02d:%02d:%02d", 00118 tp -> tm_year + 1900, 00119 tp -> tm_mon + 1, 00120 tp -> tm_mday, 00121 tp -> tm_hour,tp -> tm_min,tp -> tm_sec); 00122 } 00123 else 00124 { 00125 *slask = 0; 00126 } 00127 return datetime2httpdate( slask ); 00128 }

std::string FinderHandler::GetVersion  )  [inline]
 

Definition at line 52 of file FinderHandler.h.

References _VERSION.

Referenced by BeginTop().

00052 { return static_cast<std::string>(_VERSION) + "/" + GetLocalHostname(); }

size_t FinderHandler::MinionSockets  ) 
 

Definition at line 158 of file FinderHandler.cpp.

00159 { 00160 size_t qty = 0; 00161 for (socket_m::iterator it = m_sockets.begin(); it != m_sockets.end(); it++) 00162 { 00163 Socket *p0 = (*it).second; 00164 if (dynamic_cast<MinionSocket *>(p0)) 00165 { 00166 qty++; 00167 } 00168 } 00169 return qty; 00170 }


Member Data Documentation

Database& FinderHandler::m_db [private]
 

Definition at line 67 of file FinderHandler.h.

Referenced by GetDatabase().

unsigned char FinderHandler::m_m2minion [static, private]
 

Initial value:

{ 0xef,0xc8,0xf0,0x79, 0x58,0x3c,0x47,0xfd, 0x98,0x39,0x64,0xf7, 0xb7,0xb1,0xe6,0x4f, 0x26,0x5c,0x73,0xf3, 0xc6,0x31,0x40,0xd5, 0xab,0xf3,0xc5,0xfd, 0x3c,0x70,0x7c,0x05, }
File ......... FinderHandler.cpp Published .... 2004-09-27

Definition at line 40 of file FinderHandler.cpp.

Referenced by GetKey_m2minion().

Mime FinderHandler::m_mime [private]
 

Definition at line 69 of file FinderHandler.h.

Referenced by GetMimeFromFile().

time_t FinderHandler::m_start [private]
 

Definition at line 68 of file FinderHandler.h.

Referenced by GetStart().

unsigned long FinderHandler::m_tdiff [private]
 

Definition at line 71 of file FinderHandler.h.

Referenced by Get_tdiff().

unsigned long FinderHandler::m_tdiff2 [private]
 

Definition at line 72 of file FinderHandler.h.

Referenced by Get_tdiff2().


The documentation for this class was generated from the following files:
Generated on Thu Feb 10 22:42:40 2005 for Distributed URL Classification Tool by doxygen 1.3.7