#include "gb-include.h" #include "Collectiondb.h" #include "Pages.h" #include "SafeBuf.h" #include "Msg1f.h" #include "Parms.h" #include "Users.h" #define MAX_LOG_WINDOW 8192 static void gotRemoteLogWrapper(void *state, UdpSlot *slot); struct StateLogView { TcpSocket *m_s; SafeBuf m_sb; int32_t m_numOutstanding; // char m_readBuf[MAX_HOSTS * MAX_LOG_WINDOW]; //we need to malloc this now, incase they want to see more of the log. int32_t m_readBufSize; char *m_readBuf; char *m_readBufPtrs[MAX_HOSTS]; bool m_filters[8]; char *m_filterStr[8]; char m_numFilts; char *m_lastPtr; int32_t m_numSlots; }; static char *s_magicStr = "4j3.8x*"; #define BABY_BLUE "e0e0d0" //#define LIGHT_BLUE "d0d0e0" //#define DARK_BLUE "c0c0f0" bool sendPageLogView ( TcpSocket *s , HttpRequest *r ) { StateLogView* st; try { st = new (StateLogView); } catch ( ... ) { g_errno = ENOMEM; return g_httpServer.sendErrorReply(s,500,"Out of memory"); } mnew ( st , sizeof(StateLogView) , "StateLogViewA" ); st->m_numOutstanding = 0; st->m_numSlots = 0; st->m_s = s; SafeBuf *p = &st->m_sb; p->reserve2x(65535); //int32_t user = g_pages.getUserType( s , r ); //char *username = g_users.getUsername(r); //char *pwd = r->getString ("pwd"); //char *coll = r->getString ("c"); int32_t refreshRate = r->getLong("rr", 0); int32_t sampleSize = r->getLong("ss", 2048); if(refreshRate > 0) p->safePrintf("", refreshRate); // char *ss = p->getBuf(); // char *ssend = p->getBufEnd(); g_pages.printAdminTop ( p, s, r ); // p->incrementLength(sss - ss); int32_t nh = g_hostdb.getNumHosts(); bool blocked = true; p->safePrintf(" "); p->safePrintf("
"); if(!blocked) return blocked; gotRemoteLogWrapper(st, NULL); return true; } bool showLine ( SafeBuf *sb , char *s , int32_t len ) { return sb->brify ( s , len , 0 , // niceness 80 , // cols ""); while(1) { int64_t timeStamp = 9223372036854775807LL; //int64_t timeStamp = LONG_LONG_MAX; int32_t ndx = -1; //get next winner for (int32_t i = 0; i < st->m_numSlots; i++) { if(!st->m_readBufPtrs[i]) continue; int64_t t = atoll(st->m_readBufPtrs[i]); if(t > timeStamp) continue; timeStamp = t; ndx = i; } if(ndx == -1) { p->safePrintf(""); // p->safePrintf(" "); p->safePrintf("