[8839] Correct "outdated OpenSSL" warning message.
[getmangos.git] / src / mangosd / Main.cpp
bloba662dd56d8018bb4961dc56afce1e9ab349caf16
1 /*
2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 /// \addtogroup mangosd Mangos Daemon
20 /// @{
21 /// \file
23 #include "Common.h"
24 #include "Database/DatabaseEnv.h"
25 #include "Config/ConfigEnv.h"
26 #include "Log.h"
27 #include "Master.h"
28 #include "SystemConfig.h"
29 #include "revision.h"
30 #include "revision_nr.h"
31 #include <openssl/opensslv.h>
32 #include <openssl/crypto.h>
34 #ifdef WIN32
35 #include "ServiceWin32.h"
36 char serviceName[] = "mangosd";
37 char serviceLongName[] = "MaNGOS world service";
38 char serviceDescription[] = "Massive Network Game Object Server";
40 * -1 - not in service mode
41 * 0 - stopped
42 * 1 - running
43 * 2 - paused
45 int m_ServiceStatus = -1;
46 #endif
48 DatabaseType WorldDatabase; ///< Accessor to the world database
49 DatabaseType CharacterDatabase; ///< Accessor to the character database
50 DatabaseType loginDatabase; ///< Accessor to the realm/login database
52 uint32 realmID; ///< Id of the realm
54 /// Print out the usage string for this program on the console.
55 void usage(const char *prog)
57 sLog.outString("Usage: \n %s [<options>]\n"
58 " --version print version and exist\n\r"
59 " -c config_file use config_file as configuration file\n\r"
60 #ifdef WIN32
61 " Running as service functions:\n\r"
62 " --service run as service\n\r"
63 " -s install install service\n\r"
64 " -s uninstall uninstall service\n\r"
65 #endif
66 ,prog);
69 /// Launch the mangos server
70 extern int main(int argc, char **argv)
72 // - Construct Memory Manager Instance
73 MaNGOS::Singleton<MemoryManager>::Instance();
75 //char *leak = new char[1000]; // test leak detection
77 ///- Command line parsing to get the configuration file name
78 char const* cfg_file = _MANGOSD_CONFIG;
79 int c=1;
80 while( c < argc )
82 if( strcmp(argv[c],"-c") == 0)
84 if( ++c >= argc )
86 sLog.outError("Runtime-Error: -c option requires an input argument");
87 usage(argv[0]);
88 return 1;
90 else
91 cfg_file = argv[c];
94 if( strcmp(argv[c],"--version") == 0)
96 printf("%s\n", _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,REVISION_ID));
97 return 0;
100 #ifdef WIN32
101 ////////////
102 //Services//
103 ////////////
104 if( strcmp(argv[c],"-s") == 0)
106 if( ++c >= argc )
108 sLog.outError("Runtime-Error: -s option requires an input argument");
109 usage(argv[0]);
110 return 1;
112 if( strcmp(argv[c],"install") == 0)
114 if (WinServiceInstall())
115 sLog.outString("Installing service");
116 return 1;
118 else if( strcmp(argv[c],"uninstall") == 0)
120 if(WinServiceUninstall())
121 sLog.outString("Uninstalling service");
122 return 1;
124 else
126 sLog.outError("Runtime-Error: unsupported option %s",argv[c]);
127 usage(argv[0]);
128 return 1;
131 if( strcmp(argv[c],"--service") == 0)
133 WinServiceRun();
135 ////
136 #endif
137 ++c;
140 if (!sConfig.SetSource(cfg_file))
142 sLog.outError("Could not find configuration file %s.", cfg_file);
143 return 1;
146 sLog.outString( "%s [world-daemon]", _FULLVERSION(REVISION_DATE,REVISION_TIME,REVISION_NR,REVISION_ID) );
147 sLog.outString( "<Ctrl-C> to stop.\n\n" );
149 sLog.outTitle( "MM MM MM MM MMMMM MMMM MMMMM");
150 sLog.outTitle( "MM MM MM MM MMM MMM MM MM MMM MMM");
151 sLog.outTitle( "MMM MMM MMM MM MMM MMM MM MM MMM");
152 sLog.outTitle( "MM M MM MMMM MM MMM MM MM MMM");
153 sLog.outTitle( "MM M MM MMMMM MM MMMM MMM MM MM MMM");
154 sLog.outTitle( "MM M MM M MMM MM MMM MMMMMMM MM MM MMM");
155 sLog.outTitle( "MM MM MMM MM MM MM MMM MM MM MMM");
156 sLog.outTitle( "MM MM MMMMMMM MM MM MMM MMM MM MM MMM MMM");
157 sLog.outTitle( "MM MM MM MMM MM MM MMMMMM MMMM MMMMM");
158 sLog.outTitle( " MM MMM http://getmangos.com");
159 sLog.outTitle( " MMMMMM\n\n");
161 sLog.outString("Using configuration file %s.", cfg_file);
163 sLog.outDetail("%s (Library: %s)", OPENSSL_VERSION_TEXT, SSLeay_version(SSLEAY_VERSION));
164 if (SSLeay() < 0x009080bfL )
166 sLog.outDetail("WARNING: Outdated version of OpenSSL lib. Logins to server may not work!");
167 sLog.outDetail("WARNING: Minimal required version [OpenSSL 0.9.8k]");
170 ///- and run the 'Master'
171 /// \todo Why do we need this 'Master'? Can't all of this be in the Main as for Realmd?
172 return sMaster.Run();
174 // at sMaster return function exist with codes
175 // 0 - normal shutdown
176 // 1 - shutdown at error
177 // 2 - restart command used, this code can be used by restarter for restart mangosd
180 /// @}