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

Diff of /innwebd/innbbsd.cpp

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

Revision 1.1 by sysadm, Fri Jul 2 11:30:28 2004 UTC Revision 1.7 by sysadm, Fri Apr 11 17:14:49 2008 UTC
# Line 1  Line 1 
1  /*******************************************************/  /*******************************************************/
2  /*                                                     */  /*                                                     */
3  /*  LeafOK Innd                                        */  /*  LeafOK Innbbsd                                     */
 /*  Copyright (C) LeafOK.com, 2003-2004                */  
4  /*                                                     */  /*                                                     */
5  /*  Programmed by Leaf                                 */  /*  Copyright (C) LeafOK.com, 2003-2008                */
 /*  E-mail:leaf@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 20  Line 16 
16  #include ".\innbbsd.h"  #include ".\innbbsd.h"
17  #include ".\service.h"  #include ".\service.h"
18  #include ".\bbs_fun.h"  #include ".\bbs_fun.h"
19    #include ".\App_common.h"
20    
21  #ifdef _DEBUG  #ifdef _DEBUG
22  #define new DEBUG_NEW  #define new DEBUG_NEW
# Line 45  int _tmain(int argc, TCHAR* argv[], TCHA Line 42  int _tmain(int argc, TCHAR* argv[], TCHA
42                  return 1;                  return 1;
43          }          }
44    
         // TODO: 在此处为应用程序的行为编写代码。  
   
45          // System settings          // System settings
46          const char* logfile_file = _T("innbbsd.log");          const char* conf_file = _T("innbbsd.conf");
47            const char* log_file = _T("innbbsd.log");
48    
49          syslog.open(logfile_file,ios_base::out | ios_base::app);          // Get application path
50            CString app_path;
51            int pos;
52    
53            app_path = argv[0];
54            pos = app_path.ReverseFind('\\');
55            if (pos != -1)
56                    app_path = app_path.Left(pos + 1);
57            else
58                    app_path = "";
59    
60            syslog.open(app_path + log_file, ios_base::out | ios_base::app);
61    
62            // Report program information
63            syslog << "********************" << endl;
64            syslog << App_common::GetVersion() << endl;
65            syslog << App_common::Copyright << endl;
66            syslog << logfile::log_head << "Starting up..." << endl;
67    
68            // Initialize sockets
69          if(!AfxSocketInit())          if(!AfxSocketInit())
70          {          {
71                  syslog << logfile::log_head << "Sockets init failed" << endl;                  syslog << logfile::log_head << "Sockets init failed" << endl;
# Line 61  int _tmain(int argc, TCHAR* argv[], TCHA Line 75  int _tmain(int argc, TCHAR* argv[], TCHA
75      // Create the service object      // Create the service object
76      service innbbsd_srv;      service innbbsd_srv;
77    
78          CString conf_file;          innbbsd_srv.ctrld.load_conf(app_path + conf_file);
         conf_file = argv[0];  
         conf_file = conf_file.Left(conf_file.ReverseFind('\\')) + "\\innbbsd.conf";  
   
         innbbsd_srv.ctrld.load_conf(conf_file);  
79    
80          //Standalone mode          //Standalone mode
81          if (argc == 2 && _stricmp(argv[1], "-s") == 0)          if (argc == 2 && _stricmp(argv[1], "-s") == 0)
82          {          {
83                  innbbsd_srv.ctrld.begin();                  innbbsd_srv.ctrld.InitThreadPool();
84                  innbbsd_srv.ctrld.StartupChild();  
85                    if (innbbsd_srv.ctrld.begin() == 0)
86                    {
87                            syslog << logfile::log_head << "Begin CONTROLD ... OK" << endl;
88    
89                            innbbsd_srv.ctrld.StartupChild();
90    
91                            while (innbbsd_srv.ctrld.IsRunning())
92                            {
93                                    Sleep(100);
94                            }
95    
96                            innbbsd_srv.ctrld.ShutdownChild();
97                    }
98                    else
99                    {
100                            syslog << logfile::log_head << "Begin CONTROLD ... Failed" << endl;
101                    }
102    
103                  while (innbbsd_srv.ctrld.IsRunning())                  if (innbbsd_srv.ctrld.end() == 0)
104                    {
105                            syslog << logfile::log_head << "End CONTROLD ... OK" << endl;
106                    }
107                    else
108                  {                  {
109                      Sleep(100);                          syslog << logfile::log_head << "End CONTROLD ... Failed" << endl;
110              }                  }
111    
112                    innbbsd_srv.ctrld.CleanupThreadPool();
113    
114                  innbbsd_srv.ctrld.bbsd.end();                  ExitProcess(0);
                 innbbsd_srv.ctrld.innd.end();  
                 innbbsd_srv.ctrld.outd.end();  
                 innbbsd_srv.ctrld.end();  
115    
116                  return 0;                  return 0;
117          }          }
118    
119      // Parse for standard arguments (install, uninstall, version etc.)          // Display version infomation
120            if (argc == 2 && _stricmp(argv[1], "-c") == 0)
121            {
122                    cout << App_common::GetVersion() << endl;
123                    cout << App_common::Copyright << endl;
124            }
125    
126            // Parse for standard arguments (install, uninstall, version etc.)
127      if (!innbbsd_srv.ParseStandardArgs(argc, argv)) {      if (!innbbsd_srv.ParseStandardArgs(argc, argv)) {
128          //DebugBreak();          //DebugBreak();
129          innbbsd_srv.StartService();          innbbsd_srv.StartService();


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

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