| 1 |
/*******************************************************/ |
/*******************************************************/ |
| 2 |
/* */ |
/* */ |
| 3 |
/* LeafOK Innd */ |
/* LeafOK Innbbsd */ |
| 4 |
/* Copyright (C) LeafOK.com, 2003-2004 */ |
/* Copyright (C) LeafOK.com, 2003-2005 */ |
| 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 */ |
| 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 |
| 63 |
|
|
| 64 |
syslog.open(app_path + log_file, ios_base::out | ios_base::app); |
syslog.open(app_path + log_file, ios_base::out | ios_base::app); |
| 65 |
|
|
| 66 |
|
// Report program information |
| 67 |
|
syslog << "********************" << endl; |
| 68 |
|
syslog << App_common::GetVersion() << endl; |
| 69 |
|
syslog << App_common::Copyright << endl; |
| 70 |
|
syslog << logfile::log_head << "Starting up..." << endl; |
| 71 |
|
|
| 72 |
// Initialize sockets |
// Initialize sockets |
| 73 |
if(!AfxSocketInit()) |
if(!AfxSocketInit()) |
| 74 |
{ |
{ |
| 85 |
if (argc == 2 && _stricmp(argv[1], "-s") == 0) |
if (argc == 2 && _stricmp(argv[1], "-s") == 0) |
| 86 |
{ |
{ |
| 87 |
innbbsd_srv.ctrld.InitThreadPool(); |
innbbsd_srv.ctrld.InitThreadPool(); |
|
innbbsd_srv.ctrld.begin(); |
|
|
innbbsd_srv.ctrld.StartupChild(); |
|
| 88 |
|
|
| 89 |
while (innbbsd_srv.ctrld.IsRunning()) |
if (innbbsd_srv.ctrld.begin() == 0) |
| 90 |
|
{ |
| 91 |
|
syslog << logfile::log_head << "Begin CONTROLD ... OK" << endl; |
| 92 |
|
|
| 93 |
|
innbbsd_srv.ctrld.StartupChild(); |
| 94 |
|
|
| 95 |
|
while (innbbsd_srv.ctrld.IsRunning()) |
| 96 |
|
{ |
| 97 |
|
Sleep(100); |
| 98 |
|
} |
| 99 |
|
|
| 100 |
|
innbbsd_srv.ctrld.ShutdownChild(); |
| 101 |
|
} |
| 102 |
|
else |
| 103 |
{ |
{ |
| 104 |
Sleep(100); |
syslog << logfile::log_head << "Begin CONTROLD ... Failed" << endl; |
| 105 |
} |
} |
| 106 |
|
|
| 107 |
|
if (innbbsd_srv.ctrld.end() == 0) |
| 108 |
|
{ |
| 109 |
|
syslog << logfile::log_head << "End CONTROLD ... OK" << endl; |
| 110 |
|
} |
| 111 |
|
else |
| 112 |
|
{ |
| 113 |
|
syslog << logfile::log_head << "End CONTROLD ... Failed" << endl; |
| 114 |
|
} |
| 115 |
|
|
|
innbbsd_srv.ctrld.ShutdownChild(); |
|
|
innbbsd_srv.ctrld.end(); |
|
| 116 |
innbbsd_srv.ctrld.CleanupThreadPool(); |
innbbsd_srv.ctrld.CleanupThreadPool(); |
| 117 |
|
|
| 118 |
|
ExitProcess(0); |
| 119 |
|
|
| 120 |
return 0; |
return 0; |
| 121 |
} |
} |
| 122 |
|
|
| 123 |
// Parse for standard arguments (install, uninstall, version etc.) |
// Display version infomation |
| 124 |
|
if (argc == 2 && _stricmp(argv[1], "-c") == 0) |
| 125 |
|
{ |
| 126 |
|
cout << App_common::GetVersion() << endl; |
| 127 |
|
cout << App_common::Copyright << endl; |
| 128 |
|
} |
| 129 |
|
|
| 130 |
|
// Parse for standard arguments (install, uninstall, version etc.) |
| 131 |
if (!innbbsd_srv.ParseStandardArgs(argc, argv)) { |
if (!innbbsd_srv.ParseStandardArgs(argc, argv)) { |
| 132 |
//DebugBreak(); |
//DebugBreak(); |
| 133 |
innbbsd_srv.StartService(); |
innbbsd_srv.StartService(); |