Changeset 594
- Timestamp:
- 07/29/06 20:51:55 (2 years ago)
- Files:
-
- nepenthes/trunk/nepenthes-core/include/Makefile.am (modified) (1 diff)
- nepenthes/trunk/nepenthes-core/include/Nepenthes.hpp (modified) (3 diffs)
- nepenthes/trunk/nepenthes-core/include/SQLCallback.hpp (copied) (copied from library/trunk/library-core/include/SQLCallback.hpp) (3 diffs)
- nepenthes/trunk/nepenthes-core/include/SQLHandler.hpp (copied) (copied from library/trunk/library-core/include/SQLHandler.hpp) (5 diffs)
- nepenthes/trunk/nepenthes-core/include/SQLHandlerFactory.hpp (added)
- nepenthes/trunk/nepenthes-core/include/SQLManager.hpp (copied) (copied from library/trunk/library-core/include/SQLManager.hpp) (4 diffs)
- nepenthes/trunk/nepenthes-core/include/SQLQuery.hpp (copied) (copied from library/trunk/library-core/include/SQLQuery.hpp) (3 diffs)
- nepenthes/trunk/nepenthes-core/include/SQLResult.hpp (copied) (copied from library/trunk/library-core/include/SQLResult.hpp) (5 diffs)
- nepenthes/trunk/nepenthes-core/src/Makefile.am (modified) (1 diff)
- nepenthes/trunk/nepenthes-core/src/Nepenthes.cpp (modified) (6 diffs)
- nepenthes/trunk/nepenthes-core/src/SQLCallback.cpp (copied) (copied from library/trunk/library-core/src/SQLCallback.cpp)
- nepenthes/trunk/nepenthes-core/src/SQLHandler.cpp (copied) (copied from library/trunk/library-core/src/SQLHandler.cpp)
- nepenthes/trunk/nepenthes-core/src/SQLManager.cpp (copied) (copied from library/trunk/library-core/src/SQLManager.cpp) (5 diffs)
- nepenthes/trunk/nepenthes-core/src/SQLQuery.cpp (copied) (copied from library/trunk/library-core/src/SQLQuery.cpp) (3 diffs)
- nepenthes/trunk/nepenthes-core/src/SQLResult.cpp (copied) (copied from library/trunk/library-core/src/SQLResult.cpp) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
nepenthes/trunk/nepenthes-core/include/Makefile.am
r535 r594 21 21 EXTRA_DIST += Packet.hpp 22 22 EXTRA_DIST += SubmitManager.hpp SubmitHandler.hpp 23 EXTRA_DIST += SQLCallback.hpp SQLHandlerFactory.hpp SQLHandler.hpp SQLManager.hpp SQLQuery.hpp SQLResult.hpp 23 24 EXTRA_DIST += Utilities.hpp nepenthes/trunk/nepenthes-core/include/Nepenthes.hpp
r551 r594 109 109 class DNSManager; 110 110 class Message; 111 class SQLManager; 111 112 112 113 … … 136 137 virtual DialogueFactoryManager *getFactoryMgr(); 137 138 virtual DNSManager *getDNSMgr(); 139 virtual SQLManager *getSQLMgr(); 138 140 139 141 virtual bool doLoop(); … … 155 157 SocketManager *m_SocketManager; 156 158 Utilities *m_Utilities; 157 159 SQLManager *m_SQLManager; 158 160 159 161 nepenthes/trunk/nepenthes-core/include/SQLCallback.hpp
r474 r594 1 1 /******************************************************************************** 2 * Library2 * Nepenthes 3 3 * - finest collection - 4 4 * … … 22 22 * 23 23 * 24 * contact librarydev@users.sourceforge.net24 * contact nepenthesdev@users.sourceforge.net 25 25 * 26 26 *******************************************************************************/ 27 27 28 28 /* $Id$ */ 29 29 … … 35 35 using namespace std; 36 36 37 namespace library37 namespace nepenthes 38 38 { 39 39 class SQLResult; nepenthes/trunk/nepenthes-core/include/SQLHandler.hpp
r514 r594 1 1 /******************************************************************************** 2 * Library2 * Nepenthes 3 3 * - finest collection - 4 4 * … … 22 22 * 23 23 * 24 * contact librarydev@users.sourceforge.net24 * contact nepenthesdev@users.sourceforge.net 25 25 * 26 26 *******************************************************************************/ … … 33 33 #include <string> 34 34 35 #include "SQLQuery.hpp" 36 35 37 using namespace std; 36 38 37 namespace library39 namespace nepenthes 38 40 { 39 41 class SQLQuery; … … 46 48 47 49 virtual bool runQuery(SQLQuery *query)=0; 48 49 50 virtual string escapeString(string *str)=0; 50 51 virtual string escapeBinary(string *str)=0; 51 52 virtual string unescapeBinary(string *str)=0; 52 53 54 virtual SQLQuery *addQuery(string *query, SQLCallback *callback, void *obj) 55 { 56 // logPF(); 57 // logSpam("Query %s\nCallback %x\n",query->c_str(),callback); 58 SQLQuery *sqlquery = new SQLQuery(query,callback, obj); 59 runQuery(sqlquery); 60 return sqlquery; 61 } 53 62 54 63 virtual string getSQLHandlerName() … … 56 65 return m_SQLHandlerName; 57 66 } 67 58 68 59 69 protected: nepenthes/trunk/nepenthes-core/include/SQLManager.hpp
r514 r594 1 1 /******************************************************************************** 2 * Library2 * Nepenthes 3 3 * - finest collection - 4 4 * … … 22 22 * 23 23 * 24 * contact librarydev@users.sourceforge.net24 * contact nepenthesdev@users.sourceforge.net 25 25 * 26 26 *******************************************************************************/ … … 32 32 33 33 #include <list> 34 #include <string> 34 35 #include <stdint.h> 35 36 36 37 #include "Manager.hpp" 37 38 38 #define SQL_ESCAPE_BINARY(x) g_Library->getSQLMgr()->escapeBinary((x))39 #define SQL_UNESCAPE_BINARY(x) g_Library->getSQLMgr()->unescapeBinary((x))40 #define SQL_ESCAPE_STRING(x) g_Library->getSQLMgr()->escapeString((x))41 42 39 using namespace std; 43 40 44 namespace library41 namespace nepenthes 45 42 { 46 43 class SQLHandler; 44 class SQLHandlerFactory; 47 45 class SQLQuery; 48 46 class SQLCallback; … … 51 49 { 52 50 public: 53 SQLManager( Library *library);51 SQLManager(Nepenthes *nepenthes); 54 52 virtual ~SQLManager(); 55 53 56 virtual SQLQuery *addQuery(string *query, SQLCallback *callback, void *obj);57 virtual string escapeString(string *str);58 virtual string escapeBinary(string *str);59 virtual string unescapeBinary(string *str);60 61 virtual bool setSQLHandler(SQLHandler *handler);62 54 bool Init(); 63 55 bool Exit(); 64 56 void doList(); 65 57 58 virtual bool registerSQLHandlerFactory(SQLHandlerFactory * handlerfactory); 59 virtual void unregisterSQLHandlerFactory(const char *dbtype); 60 virtual SQLHandler *createSQLHandler(const char *dbtype, string user, string passwd, string table, string options); 61 66 62 private: 67 SQLHandler *m_SQLHandler;63 list<SQLHandlerFactory *> m_SQLHandlerFactories; 68 64 }; 69 65 nepenthes/trunk/nepenthes-core/include/SQLQuery.hpp
r474 r594 1 1 /******************************************************************************** 2 * Library2 * Nepenthes 3 3 * - finest collection - 4 4 * … … 22 22 * 23 23 * 24 * contact librarydev@users.sourceforge.net24 * contact nepenthesdev@users.sourceforge.net 25 25 * 26 26 *******************************************************************************/ … … 36 36 37 37 38 namespace library38 namespace nepenthes 39 39 { 40 40 class SQLCallback; nepenthes/trunk/nepenthes-core/include/SQLResult.hpp
r474 r594 1 1 /******************************************************************************** 2 * Library2 * Nepenthes 3 3 * - finest collection - 4 4 * … … 22 22 * 23 23 * 24 * contact librarydev@users.sourceforge.net24 * contact nepenthesdev@users.sourceforge.net 25 25 * 26 26 *******************************************************************************/ … … 31 31 #define HAVE_SQLRESULT_HPP 32 32 33 #include <libpq-fe.h>34 35 36 33 #include <list> 37 34 #include <string> … … 41 38 using namespace std; 42 39 43 namespace library40 namespace nepenthes 44 41 { 45 42 … … 49 46 SQLResult(string query, void *obj); 50 47 virtual ~SQLResult(); 51 virtual string getQuery();52 virtual void *getObject();53 48 virtual string getQuery(); 49 virtual void *getObject(); 50 54 51 virtual vector< map<string,string> > *getResult(); 55 52 protected: 56 53 string m_Query; 57 void *m_Object;58 vector< map<string,string> > m_Result;54 void *m_Object; 55 vector< map<string,string> > m_Result; 59 56 60 57 }; nepenthes/trunk/nepenthes-core/src/Makefile.am
r559 r594 27 27 nepenthes_SOURCES += ShellcodeManager.cpp ShellcodeHandler.cpp 28 28 nepenthes_SOURCES += SubmitManager.cpp SubmitHandler.cpp 29 nepenthes_SOURCES += SQLCallback.cpp SQLHandler.cpp SQLManager.cpp SQLQuery.cpp SQLResult.cpp 29 30 nepenthes_SOURCES += Utilities.cpp 30 31 nepenthes/trunk/nepenthes-core/src/Nepenthes.cpp
r570 r594 66 66 #include "DNSManager.hpp" 67 67 68 #include "SQLManager.hpp" 69 68 70 #include "Message.hpp" 69 71 … … 101 103 m_SubmitManager = NULL; 102 104 m_Utilities = NULL; 105 106 m_SQLManager = NULL; 103 107 104 108 m_UID = 0; … … 413 417 m_Utilities = new Utilities(); 414 418 m_DNSManager = new DNSManager(this); 419 m_SQLManager = new SQLManager(this); 415 420 } 416 421 } … … 562 567 { 563 568 m_DialogueFactoryManager->doList(); 569 } 570 571 if (run == true) 572 { 573 m_SQLManager->doList(); 564 574 } 565 575 … … 731 741 fileCheckMain(filecheckarg,argc,optind,argv); 732 742 } 733 if( run == true )743 if( true )//run == true ) 734 744 { 735 745 doLoop(); … … 1092 1102 1093 1103 1104 /** 1105 * get the SQLManager 1106 * 1107 * @return returns the SQLManager 1108 */ 1109 SQLManager *Nepenthes::getSQLMgr() 1110 { 1111 return m_SQLManager; 1112 } 1094 1113 1095 1114 /** nepenthes/trunk/nepenthes-core/src/SQLManager.cpp
r514 r594 1 1 /******************************************************************************** 2 * Library2 * Nepenthes 3 3 * - finest collection - 4 4 * … … 22 22 * 23 23 * 24 * contact librarydev@users.sourceforge.net24 * contact nepenthesdev@users.sourceforge.net 25 25 * 26 26 *******************************************************************************/ 27 27 28 28 /* $Id$ */ 29 29 … … 34 34 #include "SQLQuery.hpp" 35 35 #include "SQLHandler.hpp" 36 37 #include " Library.hpp"36 #include "SQLHandlerFactory.hpp" 37 #include "Nepenthes.hpp" 38 38 #include "LogManager.hpp" 39 39 40 using namespace library;40 using namespace nepenthes; 41 41 42 42 43 43 44 SQLManager::SQLManager( Library *library)44 SQLManager::SQLManager(Nepenthes *nepenthes) 45 45 { 46 46 m_Nepenthes = nepenthes; 47 47 } 48 48 … … 50 50 { 51 51 52 }53 54 SQLQuery *SQLManager::addQuery(string *query, SQLCallback *callback, void *obj)55 {56 logPF();57 logSpam("Query %s\nCallback %x\n",query->c_str(),callback);58 SQLQuery *sqlquery = new SQLQuery(query,callback, obj);59 m_SQLHandler->runQuery(sqlquery);60 return sqlquery;61 52 } 62 53 … … 74 65 void SQLManager::doList() 75 66 { 76 logInfo("=--- %-69s ---=\n","SQLManager"); 77 if (m_SQLHandler != NULL) 67 68 list <SQLHandlerFactory *>::iterator it; 69 logSpam("=--- %-69s ---=\n","SQLManager"); 70 int32_t i=0; 71 for(it = m_SQLHandlerFactories.begin();it != m_SQLHandlerFactories.end();it++,i++) 78 72 { 79 logInfo(" # %s\n",m_SQLHandler->getSQLHandlerName().c_str()); 80 }else 81 { 82 logCrit("%s"," no sql handler loaded\n"); 73 logSpam(" %i) %-8s \n",i,(*it)->getDBType().c_str()); 83 74 } 84 log Info("=--- %2s %-66s ---=\n","", "SQLHandlerregisterd");75 logSpam("=--- %2i %-66s ---=\n\n",i, "SQLHandlerFactories registerd"); 85 76 } 86 77 87 bool SQLManager::setSQLHandler(SQLHandler *handler) 78 79 bool SQLManager::registerSQLHandlerFactory(SQLHandlerFactory * handlerfactory) 88 80 { 89 if (m_SQLHandler == NULL) 90 { 91 m_SQLHandler = handler; 92 return true; 93 }else 94 { 95 return false; 96 } 81 m_SQLHandlerFactories.push_back(handlerfactory); 82 return true; 97 83 } 98 84 99 string SQLManager::escapeString(string *str)100 { 101 return m_SQLHandler->escapeString(str);85 void SQLManager::unregisterSQLHandlerFactory(const char *dbtype) 86 { // FIXME 87 return; 102 88 } 103 89 104 string SQLManager::escapeBinary(string *str)90 SQLHandler *SQLManager::createSQLHandler(const char *dbtype, string user, string passwd, string table, string options) 105 91 { 106 return m_SQLHandler->escapeBinary(str); 92 list <SQLHandlerFactory *>::iterator it; 93 int i=0; 94 for (it = m_SQLHandlerFactories.begin(); it != m_SQLHandlerFactories.end(); i++) 95 { 96 if (dbtype == (*it)->getDBType()) 97 { 98 SQLHandler *sqlh = (*it)->createSQLHandler(user,passwd,table,options); 99 return sqlh; 100 } 101 } 102 return NULL; 107 103 } 108 109 string SQLManager::unescapeBinary(string *str)110 {111 return m_SQLHandler->unescapeBinary(str);112 }113 nepenthes/trunk/nepenthes-core/src/SQLQuery.cpp
r474 r594 1 1 /******************************************************************************** 2 * Library2 * Nepenthes 3 3 * - finest collection - 4 4 * … … 22 22 * 23 23 * 24 * contact librarydev@users.sourceforge.net24 * contact nepenthesdev@users.sourceforge.net 25 25 * 26 26 *******************************************************************************/ 27 27 28 28 /* $Id$ */ 29 29 … … 35 35 #include "SQLHandler.hpp" 36 36 37 #include " Library.hpp"37 #include "Nepenthes.hpp" 38 38 #include "LogManager.hpp" 39 39 40 using namespace library;40 using namespace nepenthes; 41 41 42 42 nepenthes/trunk/nepenthes-core/src/SQLResult.cpp
r474 r594 1 1 /******************************************************************************** 2 * Library2 * Nepenthes 3 3 * - finest collection - 4 4 * … … 22 22 * 23 23 * 24 * contact librarydev@users.sourceforge.net24 * contact nepenthesdev@users.sourceforge.net 25 25 * 26 26 *******************************************************************************/ 27 27 28 28 /* $Id$ */ 29 29 … … 35 35 #include "SQLHandler.hpp" 36 36 37 #include " Library.hpp"37 #include "Nepenthes.hpp" 38 38 #include "LogManager.hpp" 39 39 40 using namespace library;40 using namespace nepenthes; 41 41 42 42
