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