/[LeafOK_CVS]/innwebd/base.cpp
ViewVC logotype

Diff of /innwebd/base.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 by sysadm, Fri Jul 2 11:22:07 2004 UTC Revision 1.5 by sysadm, Sun Jul 4 08:04:08 2004 UTC
# Line 1  Line 1 
1  /*******************************************************/  /*******************************************************/
2  /*                                                     */  /*                                                     */
3  /*  LeafOK Innd                                        */  /*  LeafOK Innbbsd                                     */
4  /*  Copyright (C) LeafOK.com, 2003-2004                */  /*  Copyright (C) LeafOK.com, 2003-2004                */
5  /*                                                     */  /*                                                     */
6  /*  Programmed by Leaf                                 */  /*  Programmed by Leaf                                 */
7  /*  E-mail:leaf@leafok.com  QQ:6049044                 */  /*  E-mail:leaflet@leafok.com  QQ:6049044              */
8  /*                                                     */  /*                                                     */
9  /*  http://bbs.leafok.com                              */  /*  http://bbs.leafok.com                              */
10  /*  http://bbs.leafok.net                              */  /*  http://bbs.leafok.net                              */
# Line 21  Line 21 
21  using namespace std;  using namespace std;
22    
23  base::base(void)  base::base(void)
24  : innd_uid(0)  : p_ParentThread(NULL)
25    , p_ThreadPool(NULL)
26    , ulMainThreadId(0)
27    , innd_uid(0)
28  , isConnected(false)  , isConnected(false)
29  , running(false)  , running(false)
30  {  {
# Line 29  base::base(void) Line 32  base::base(void)
32    
33  base::~base(void)  base::~base(void)
34  {  {
35            if (this->GetThreadPool() != NULL)
36                    delete (this->GetThreadPool());
37  }  }
38    
39  int base::s_exec(const char* in_str, CString& out_str, const char* end_str)  int base::s_exec(const char* in_str, CString& out_str, const char* end_str)
# Line 280  int base::bbs_post(const CString& head, Line 285  int base::bbs_post(const CString& head,
285                                                  RS.GetFieldValue("UID",dbVar,SQL_C_SLONG);                                                  RS.GetFieldValue("UID",dbVar,SQL_C_SLONG);
286                                                  sql.Format("insert into bbs_msg(fromUID,toUID,ntent,send_dt,send_ip)"                                                  sql.Format("insert into bbs_msg(fromUID,toUID,ntent,send_dt,send_ip)"
287                                                                  " valulues(%ld,%ld,'%s',now(),'%s')",                                                                  " valulues(%ld,%ld,'%s',now(),'%s')",
288                                                                  this->innd_uid,dbVar.m_lVal,addslashes(msg_connt),ththis->hostaddr);                                                                  this->innd_uid,dbVar.m_lVal,addslashes(msg_content),this->hostaddr);
289                                                  this->Db.ExecuteSQL(sql);                                                  this->Db.ExecuteSQL(sql);
290                                          }                                          }
291                                  }                                  }
292                                  RS.Close();                                  RS.Close();
293                          }                          }
294    
295                          sql.Format("insert delayed into innd_logfile(AID,art_id,msg_id,op) values"                          sql.Format("insert delayed into innd_log(AID,art_id,msg_id,op) values"
296                                  "(%ld,%ld,'%s','I')",                                  "(%ld,%ld,'%s','I')",
297                                  aid,art_id,addslashes(msg_id));                                  aid,art_id,addslashes(msg_id));
298                          this->Db.ExecuteSQL(sql);                          this->Db.ExecuteSQL(sql);
# Line 299  int base::bbs_post(const CString& head, Line 304  int base::bbs_post(const CString& head,
304          }          }
305          catch(CException* e)          catch(CException* e)
306          {          {
307                  syslog << logfile::log_head << "Error in bbs_post()" << endl;                  char strErrMsg[256];
308                    e->GetErrorMessage(strErrMsg,256);
309                    syslog << logfile::log_head << "Error in bbs_post() [" << strErrMsg << "]" << endl;
310                  e->Delete();                  e->Delete();
311                  return -1;                  return -1;
312          }          }
# Line 384  int base::bbs_delete(long id) Line 391  int base::bbs_delete(long id)
391                                  this->Db.ExecuteSQL(sql);                                  this->Db.ExecuteSQL(sql);
392                          }                          }
393    
394                          sql.Format("update innd_logfile set cancel=1 where AID=%ld",id);                          sql.Format("update innd_log set cancel=1 where AID=%ld",id);
395                          this->Db.ExecuteSQL(sql);                          this->Db.ExecuteSQL(sql);
396                  }                  }
397                  RS.Close();                  RS.Close();
398          }          }
399          catch(CException* e)          catch(CException* e)
400          {          {
401                  syslog << logfile::log_head << "Getting article error in bbs_delete()" << endl;                  char strErrMsg[256];
402                    e->GetErrorMessage(strErrMsg,256);
403                    syslog << logfile::log_head << "Getting article error in bbs_delete() [" << strErrMsg << "]" << endl;
404                  e->Delete();                  e->Delete();
405                  return -1;                  return -1;
406          }          }
# Line 452  int base::s_receive(CString& out_str, co Line 461  int base::s_receive(CString& out_str, co
461          return total_read;          return total_read;
462  }  }
463    
 bool base::IsRunning(void)  
 {  
         return this->running;  
 }  
   
464  int base::begin(void)  int base::begin(void)
465  {  {
466          ULONG ulThreadId;          ULONG ulThreadId;
# Line 496  DWORD base::Thread(LPVOID pParam) Line 500  DWORD base::Thread(LPVOID pParam)
500          base* p;          base* p;
501    
502          syslog << logfile::log_head << "Thread started." << endl;          syslog << logfile::log_head << "Thread started." << endl;
503    
504          p = (base*)pParam;          p = (base*)pParam;
505    
506            p->ulMainThreadId = GetCurrentThreadId();
507    
508            if (p->GetParentThread()->GetThreadPool()->AddThread(GetCurrentThreadId(), CLOCKS_PER_SEC * 30) != 0)
509            {
510                    syslog << logfile::log_head << "Register thread ... Failed" << endl;
511            }
512            p->GetParentThread()->GetThreadPool()->SetThreadStatus(GetCurrentThreadId(),thread_pool::S_WORKING);
513    
514          p->w_call();          p->w_call();
515    
516            if (p->GetParentThread()->GetThreadPool()->RemoveThread(GetCurrentThreadId()) != 0)
517            {
518                    syslog << logfile::log_head << "Unregister thread ... Failed" << endl;
519            }
520    
521          syslog << logfile::log_head << "Thread stopped." << endl;          syslog << logfile::log_head << "Thread stopped." << endl;
522    
523          return 0;          return 0;
# Line 537  int base::Startup(void) Line 557  int base::Startup(void)
557  {  {
558          return 0;          return 0;
559  }  }
560    
561    bool base::IsThreadActive(void)
562    {
563            bool bIsActive = false;
564    
565            switch (this->GetParentThread()->GetThreadPool()->GetThreadStatus(this->ulMainThreadId))
566            {
567            case thread_pool::S_WAITING:
568            case thread_pool::S_WORKING:
569                    bIsActive = true;
570                    break;
571            default:
572                    bIsActive = false;
573            }
574    
575            return bIsActive;
576    }


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1