| 1 |
sysadm |
1.1 |
/*******************************************************/
|
| 2 |
|
|
/* */
|
| 3 |
sysadm |
1.3 |
/* LeafOK Innbbsd */
|
| 4 |
sysadm |
1.1 |
/* Copyright (C) LeafOK.com, 2003-2004 */
|
| 5 |
|
|
/* */
|
| 6 |
|
|
/* Programmed by Leaf */
|
| 7 |
sysadm |
1.3 |
/* E-mail:leaflet@leafok.com QQ:6049044 */
|
| 8 |
sysadm |
1.1 |
/* */
|
| 9 |
|
|
/* http://bbs.leafok.com */
|
| 10 |
|
|
/* http://bbs.leafok.net */
|
| 11 |
|
|
/* http://bbs.fenglin.info */
|
| 12 |
|
|
/* */
|
| 13 |
|
|
/*******************************************************/
|
| 14 |
|
|
|
| 15 |
|
|
#pragma once
|
| 16 |
|
|
|
| 17 |
|
|
#include "afxdb.h"
|
| 18 |
|
|
#include "winsock2.h"
|
| 19 |
sysadm |
1.2 |
#include ".\thread_pool.h"
|
| 20 |
sysadm |
1.1 |
|
| 21 |
|
|
class base
|
| 22 |
|
|
{
|
| 23 |
|
|
public:
|
| 24 |
|
|
base(void);
|
| 25 |
|
|
~base(void);
|
| 26 |
|
|
virtual void configure(const char* innd_id, const char* innd_name, const char* innd_server, unsigned long innd_uid, const char* w_address, unsigned int w_port, const char* w_conn_str);
|
| 27 |
|
|
int begin(void);
|
| 28 |
|
|
int end(void);
|
| 29 |
sysadm |
1.2 |
inline bool IsRunning(void)
|
| 30 |
|
|
{
|
| 31 |
sysadm |
1.3 |
return (this->running && this->IsThreadActive());
|
| 32 |
sysadm |
1.2 |
}
|
| 33 |
|
|
inline base* GetParentThread(void)
|
| 34 |
|
|
{
|
| 35 |
|
|
return this->p_ParentThread;
|
| 36 |
|
|
}
|
| 37 |
|
|
inline void SetParentThread(base* p_ParentThread)
|
| 38 |
|
|
{
|
| 39 |
|
|
this->p_ParentThread = p_ParentThread;
|
| 40 |
|
|
}
|
| 41 |
|
|
inline thread_pool* GetThreadPool(void)
|
| 42 |
|
|
{
|
| 43 |
|
|
return this->p_ThreadPool;
|
| 44 |
|
|
}
|
| 45 |
|
|
inline void SetThreadPool(thread_pool* p_ThreadPool)
|
| 46 |
|
|
{
|
| 47 |
|
|
this->p_ThreadPool = p_ThreadPool;
|
| 48 |
|
|
}
|
| 49 |
sysadm |
1.1 |
protected:
|
| 50 |
sysadm |
1.3 |
ULONG ulMainThreadId;
|
| 51 |
sysadm |
1.2 |
base* p_ParentThread;
|
| 52 |
|
|
thread_pool* p_ThreadPool;
|
| 53 |
sysadm |
1.1 |
SOCKET s;
|
| 54 |
|
|
SOCKADDR sockaddr;
|
| 55 |
|
|
CDatabase Db;
|
| 56 |
|
|
bool isConnected;
|
| 57 |
|
|
bool running;
|
| 58 |
|
|
unsigned long innd_uid;
|
| 59 |
|
|
char innd_id[50];
|
| 60 |
|
|
char innd_name[50];
|
| 61 |
|
|
char innd_server[256];
|
| 62 |
|
|
unsigned int w_port;
|
| 63 |
|
|
char w_address[50];
|
| 64 |
|
|
char w_conn_str[256];
|
| 65 |
|
|
char hostaddr[50];
|
| 66 |
|
|
unsigned int port;
|
| 67 |
|
|
int bbs_post(const CString& head, const CString& body, int sid, long art_id);
|
| 68 |
|
|
long last_insert_id(void);
|
| 69 |
|
|
int bbs_delete(long id);
|
| 70 |
|
|
static CString addslashes(CString str);
|
| 71 |
|
|
int db_open(const char* conn_str = "ODBC;");
|
| 72 |
|
|
int db_close(void);
|
| 73 |
|
|
virtual int s_connect(const char* hostname, unsigned int port) = 0;
|
| 74 |
|
|
virtual int s_close(void) = 0;
|
| 75 |
|
|
int s_send(const char* in_str, bool auto_endl = true);
|
| 76 |
sysadm |
1.5 |
int s_receive(CString& out_str, const char* end_str="\n");
|
| 77 |
|
|
int s_exec(const char* in_str, CString& out_str, const char* end_str="\n");
|
| 78 |
sysadm |
1.1 |
virtual bool IsShutdown(void);
|
| 79 |
|
|
virtual int Shutdown(void);
|
| 80 |
|
|
virtual int Startup(void);
|
| 81 |
|
|
virtual int w_call() = 0;
|
| 82 |
|
|
private:
|
| 83 |
|
|
static DWORD Thread(LPVOID pParam);
|
| 84 |
sysadm |
1.3 |
public:
|
| 85 |
|
|
bool IsThreadActive(void);
|
| 86 |
sysadm |
1.1 |
};
|
| 87 |
|
|
|