/[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.11 by sysadm, Wed Dec 1 08:31:52 2004 UTC Revision 1.15 by sysadm, Fri Apr 11 17:14:49 2008 UTC
# Line 1  Line 1 
1  /*******************************************************/  /*******************************************************/
2  /*                                                     */  /*                                                     */
3  /*  LeafOK Innbbsd                                     */  /*  LeafOK Innbbsd                                     */
 /*  Copyright (C) LeafOK.com, 2003-2004                */  
4  /*                                                     */  /*                                                     */
5  /*  Programmed by Leaf                                 */  /*  Copyright (C) LeafOK.com, 2003-2008                */
 /*  E-mail:leaflet@leafok.com  QQ:6049044              */  
6  /*                                                     */  /*                                                     */
7  /*  http://bbs.leafok.com                              */  /*  http://www.leafok.com                              */
 /*  http://bbs.leafok.net                              */  
 /*  http://bbs.fenglin.info                            */  
8  /*                                                     */  /*                                                     */
9  /*******************************************************/  /*******************************************************/
10    
# Line 46  int base::s_exec(const char* in_str, CSt Line 42  int base::s_exec(const char* in_str, CSt
42          }          }
43          catch(CException* e)          catch(CException* e)
44          {          {
45                  syslog << logfile::log_head << "Error in s_exec()" << endl;                  char strErrMsg[1024];
46                    e->GetErrorMessage(strErrMsg,1024);
47                    syslog << logfile::log_head << "Error in s_exec() [" << strErrMsg << "]" << endl;
48                  e->Delete();                  e->Delete();
49                  return -1;                  return -1;
50          }          }
# Line 59  int base::db_open(const char* conn_str) Line 57  int base::db_open(const char* conn_str)
57          try          try
58          {          {
59                  this->Db.Open("",0,0,conn_str,0);                  this->Db.Open("",0,0,conn_str,0);
60                    this->Db.ExecuteSQL("SET CHARACTER SET gb2312");
61                    this->Db.ExecuteSQL("SET NAMES 'gb2312'");
62          }          }
63          catch(CException* e)          catch(CException* e)
64          {          {
65                  syslog << logfile::log_head << "Open database failed in db_open()" << endl;                  char strErrMsg[1024];
66                    e->GetErrorMessage(strErrMsg,1024);
67                    syslog << logfile::log_head << "Open database failed in db_open() [" << strErrMsg << "]" << endl;
68                  e->Delete();                  e->Delete();
69                  return -1;                  return -1;
70          }          }
# Line 78  int base::db_close(void) Line 80  int base::db_close(void)
80          }          }
81          catch(CException* e)          catch(CException* e)
82          {          {
83                  syslog << logfile::log_head << "Close database failed in db_close()" << endl;                  char strErrMsg[1024];
84                    e->GetErrorMessage(strErrMsg,1024);
85                    syslog << logfile::log_head << "Close database failed in db_close() [" << strErrMsg << "]" << endl;
86                  e->Delete();                  e->Delete();
87                  return -1;                  return -1;
88          }          }
# Line 233  int base::bbs_post(const CString& head, Line 237  int base::bbs_post(const CString& head,
237                                  }                                  }
238                          }                          }
239                          if (nickname.GetLength() > 20)                          if (nickname.GetLength() > 20)
240                                  nickname = nickname.Left(20);                                  nickname = nickname.Left(19) + " ";
241    
242                          //Reference /bbs/add_sub.php                          //Reference /bbs/add_sub.php
243    
# Line 351  long base::last_insert_id(void) Line 355  long base::last_insert_id(void)
355          }          }
356          catch(CException* e)          catch(CException* e)
357          {          {
358                  syslog << logfile::log_head << "Error in last_insert_id()" << endl;                  char strErrMsg[1024];
359                    e->GetErrorMessage(strErrMsg,1024);
360                    syslog << logfile::log_head << "Error in last_insert_id() [" << strErrMsg << "]" << endl;
361                  e->Delete();                  e->Delete();
362                  return 0;                  return 0;
363          }          }
# Line 425  int base::s_send(const char* in_str, boo Line 431  int base::s_send(const char* in_str, boo
431          }          }
432          catch(CException* e)          catch(CException* e)
433          {          {
434                  syslog << logfile::log_head << "Error in s_send()" << endl;                  char strErrMsg[1024];
435                    e->GetErrorMessage(strErrMsg,1024);
436                    syslog << logfile::log_head << "Error in s_send() [" << strErrMsg << "]" << endl;
437                  e->Delete();                  e->Delete();
438                  return -1;                  return -1;
439          }          }
# Line 462  int base::s_receive(CString& out_str, ch Line 470  int base::s_receive(CString& out_str, ch
470          }          }
471          catch(CException* e)          catch(CException* e)
472          {          {
473                  syslog << logfile::log_head << "Error in s_receive()" << endl;                  char strErrMsg[1024];
474                    e->GetErrorMessage(strErrMsg,1024);
475                    syslog << logfile::log_head << "Error in s_receive() [" << strErrMsg << "]" << endl;
476                  e->Delete();                  e->Delete();
477                  return -1;                  return -1;
478          }          }
# Line 477  int base::begin(void) Line 487  int base::begin(void)
487          unsigned int time_wait = 0;          unsigned int time_wait = 0;
488    
489          if (!this->IsShutdown())          if (!this->IsShutdown())
490                  return 1;                  return 0;
491    
492          if (hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)base::Thread,(LPVOID)this,0,&ulThreadId))          if (hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)base::Thread,(LPVOID)this,0,&ulThreadId))
493          {          {
# Line 494  int base::begin(void) Line 504  int base::begin(void)
504          {          {
505          Sleep(100);          Sleep(100);
506                  time_wait += 100;                  time_wait += 100;
507                  if (time_wait > 10000) //Wait 10 seconds                  if (time_wait > 30000) //Wait 30 seconds
508                  {                  {
509                          syslog << logfile::log_head << "Module timeout in begin()" << endl;                          syslog << logfile::log_head << "Module timeout in begin()" << endl;
510                          this->end();                          this->end();
# Line 516  DWORD base::Thread(LPVOID pParam) Line 526  DWORD base::Thread(LPVOID pParam)
526    
527          p->ulMainThreadId = GetCurrentThreadId();          p->ulMainThreadId = GetCurrentThreadId();
528    
529          if (p->GetParentThread()->GetThreadPool()->AddThread(GetCurrentThreadId(), CLOCKS_PER_SEC * 30) != 0)          if (p->GetParentThread()->GetThreadPool()->AddThread(GetCurrentThreadId(), CLOCKS_PER_SEC * 60) != 0)
530          {          {
531                  syslog << logfile::log_head << "Register thread ... Failed" << endl;                  syslog << logfile::log_head << "Register thread ... Failed" << endl;
532          }          }


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

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