Remove headers.h
[novacoin.git] / src / init.cpp
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2012 The Bitcoin developers
3 // Distributed under the MIT/X11 software license, see the accompanying
4 // file license.txt or http://www.opensource.org/licenses/mit-license.php.
5 #include "db.h"
6 #include "bitcoinrpc.h"
7 #include "net.h"
8 #include "init.h"
9 #include "strlcpy.h"
10 #include "util.h"
11 #include "ui_interface.h"
12 #include <boost/filesystem.hpp>
13 #include <boost/filesystem/fstream.hpp>
14 #include <boost/filesystem/convenience.hpp>
15 #include <boost/interprocess/sync/file_lock.hpp>
16
17 #ifndef WIN32
18 #include <signal.h>
19 #endif
20
21 using namespace std;
22 using namespace boost;
23
24 CWallet* pwalletMain;
25
26 //////////////////////////////////////////////////////////////////////////////
27 //
28 // Shutdown
29 //
30
31 void ExitTimeout(void* parg)
32 {
33 #ifdef WIN32
34     Sleep(5000);
35     ExitProcess(0);
36 #endif
37 }
38
39 void Shutdown(void* parg)
40 {
41     static CCriticalSection cs_Shutdown;
42     static bool fTaken;
43     bool fFirstThread = false;
44     {
45         TRY_LOCK(cs_Shutdown, lockShutdown);
46         if (lockShutdown)
47         {
48             fFirstThread = !fTaken;
49             fTaken = true;
50         }
51     }
52     static bool fExit;
53     if (fFirstThread)
54     {
55         fShutdown = true;
56         nTransactionsUpdated++;
57         DBFlush(false);
58         StopNode();
59         DBFlush(true);
60         boost::filesystem::remove(GetPidFile());
61         UnregisterWallet(pwalletMain);
62         delete pwalletMain;
63         CreateThread(ExitTimeout, NULL);
64         Sleep(50);
65         printf("Bitcoin exiting\n\n");
66         fExit = true;
67         exit(0);
68     }
69     else
70     {
71         while (!fExit)
72             Sleep(500);
73         Sleep(100);
74         ExitThread(0);
75     }
76 }
77
78 void HandleSIGTERM(int)
79 {
80     fRequestShutdown = true;
81 }
82
83
84
85
86
87
88 //////////////////////////////////////////////////////////////////////////////
89 //
90 // Start
91 //
92 #if !defined(QT_GUI)
93 int main(int argc, char* argv[])
94 {
95     bool fRet = false;
96     fRet = AppInit(argc, argv);
97
98     if (fRet && fDaemon)
99         return 0;
100
101     return 1;
102 }
103 #endif
104
105 bool AppInit(int argc, char* argv[])
106 {
107     bool fRet = false;
108     try
109     {
110         fRet = AppInit2(argc, argv);
111     }
112     catch (std::exception& e) {
113         PrintException(&e, "AppInit()");
114     } catch (...) {
115         PrintException(NULL, "AppInit()");
116     }
117     if (!fRet)
118         Shutdown(NULL);
119     return fRet;
120 }
121
122 bool AppInit2(int argc, char* argv[])
123 {
124 #ifdef _MSC_VER
125     // Turn off microsoft heap dump noise
126     _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
127     _CrtSetReportFile(_CRT_WARN, CreateFileA("NUL", GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, 0));
128 #endif
129 #if _MSC_VER >= 1400
130     // Disable confusing "helpful" text message on abort, ctrl-c
131     _set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
132 #endif
133 #ifndef WIN32
134     umask(077);
135 #endif
136 #ifndef WIN32
137     // Clean shutdown on SIGTERM
138     struct sigaction sa;
139     sa.sa_handler = HandleSIGTERM;
140     sigemptyset(&sa.sa_mask);
141     sa.sa_flags = 0;
142     sigaction(SIGTERM, &sa, NULL);
143     sigaction(SIGINT, &sa, NULL);
144     sigaction(SIGHUP, &sa, NULL);
145 #endif
146
147     //
148     // Parameters
149     //
150     // If Qt is used, parameters/bitcoin.conf are parsed in qt/bitcoin.cpp's main()
151 #if !defined(QT_GUI)
152     ParseParameters(argc, argv);
153     if (!ReadConfigFile(mapArgs, mapMultiArgs))
154     {
155         fprintf(stderr, "Error: Specified directory does not exist\n");
156         Shutdown(NULL);
157     }
158 #endif
159
160     if (mapArgs.count("-?") || mapArgs.count("--help"))
161     {
162         string strUsage = string() +
163           _("Bitcoin version") + " " + FormatFullVersion() + "\n\n" +
164           _("Usage:") + "\t\t\t\t\t\t\t\t\t\t\n" +
165             "  bitcoind [options]                   \t  " + "\n" +
166             "  bitcoind [options] <command> [params]\t  " + _("Send command to -server or bitcoind") + "\n" +
167             "  bitcoind [options] help              \t\t  " + _("List commands") + "\n" +
168             "  bitcoind [options] help <command>    \t\t  " + _("Get help for a command") + "\n" +
169           _("Options:") + "\n" +
170             "  -conf=<file>     \t\t  " + _("Specify configuration file (default: bitcoin.conf)") + "\n" +
171             "  -pid=<file>      \t\t  " + _("Specify pid file (default: bitcoind.pid)") + "\n" +
172             "  -gen             \t\t  " + _("Generate coins") + "\n" +
173             "  -gen=0           \t\t  " + _("Don't generate coins") + "\n" +
174             "  -min             \t\t  " + _("Start minimized") + "\n" +
175             "  -splash          \t\t  " + _("Show splash screen on startup (default: 1)") + "\n" +
176             "  -datadir=<dir>   \t\t  " + _("Specify data directory") + "\n" +
177             "  -dbcache=<n>     \t\t  " + _("Set database cache size in megabytes (default: 25)") + "\n" +
178             "  -dblogsize=<n>   \t\t  " + _("Set database disk log size in megabytes (default: 100)") + "\n" +
179             "  -timeout=<n>     \t  "   + _("Specify connection timeout (in milliseconds)") + "\n" +
180             "  -proxy=<ip:port> \t  "   + _("Connect through socks4 proxy") + "\n" +
181             "  -dns             \t  "   + _("Allow DNS lookups for addnode and connect") + "\n" +
182             "  -port=<port>     \t\t  " + _("Listen for connections on <port> (default: 8333 or testnet: 18333)") + "\n" +
183             "  -maxconnections=<n>\t  " + _("Maintain at most <n> connections to peers (default: 125)") + "\n" +
184             "  -addnode=<ip>    \t  "   + _("Add a node to connect to and attempt to keep the connection open") + "\n" +
185             "  -connect=<ip>    \t\t  " + _("Connect only to the specified node") + "\n" +
186             "  -irc             \t  "   + _("Find peers using internet relay chat (default: 0)") + "\n" +
187             "  -listen          \t  "   + _("Accept connections from outside (default: 1)") + "\n" +
188 #ifdef QT_GUI
189             "  -lang=<lang>     \t\t  " + _("Set language, for example \"de_DE\" (default: system locale)") + "\n" +
190 #endif
191             "  -dnsseed         \t  "   + _("Find peers using DNS lookup (default: 1)") + "\n" +
192             "  -banscore=<n>    \t  "   + _("Threshold for disconnecting misbehaving peers (default: 100)") + "\n" +
193             "  -bantime=<n>     \t  "   + _("Number of seconds to keep misbehaving peers from reconnecting (default: 86400)") + "\n" +
194             "  -maxreceivebuffer=<n>\t  " + _("Maximum per-connection receive buffer, <n>*1000 bytes (default: 10000)") + "\n" +
195             "  -maxsendbuffer=<n>\t  "   + _("Maximum per-connection send buffer, <n>*1000 bytes (default: 10000)") + "\n" +
196 #ifdef USE_UPNP
197 #if USE_UPNP
198             "  -upnp            \t  "   + _("Use Universal Plug and Play to map the listening port (default: 1)") + "\n" +
199 #else
200             "  -upnp            \t  "   + _("Use Universal Plug and Play to map the listening port (default: 0)") + "\n" +
201 #endif
202 #endif
203             "  -paytxfee=<amt>  \t  "   + _("Fee per KB to add to transactions you send") + "\n" +
204 #ifdef QT_GUI
205             "  -server          \t\t  " + _("Accept command line and JSON-RPC commands") + "\n" +
206 #endif
207 #if !defined(WIN32) && !defined(QT_GUI)
208             "  -daemon          \t\t  " + _("Run in the background as a daemon and accept commands") + "\n" +
209 #endif
210             "  -testnet         \t\t  " + _("Use the test network") + "\n" +
211             "  -debug           \t\t  " + _("Output extra debugging information") + "\n" +
212             "  -logtimestamps   \t  "   + _("Prepend debug output with timestamp") + "\n" +
213             "  -printtoconsole  \t  "   + _("Send trace/debug info to console instead of debug.log file") + "\n" +
214 #ifdef WIN32
215             "  -printtodebugger \t  "   + _("Send trace/debug info to debugger") + "\n" +
216 #endif
217             "  -rpcuser=<user>  \t  "   + _("Username for JSON-RPC connections") + "\n" +
218             "  -rpcpassword=<pw>\t  "   + _("Password for JSON-RPC connections") + "\n" +
219             "  -rpcport=<port>  \t\t  " + _("Listen for JSON-RPC connections on <port> (default: 8332)") + "\n" +
220             "  -rpcallowip=<ip> \t\t  " + _("Allow JSON-RPC connections from specified IP address") + "\n" +
221             "  -rpcconnect=<ip> \t  "   + _("Send commands to node running on <ip> (default: 127.0.0.1)") + "\n" +
222             "  -blocknotify=<cmd> "     + _("Execute command when the best block changes (%s in cmd is replaced by block hash)") + "\n" +
223             "  -upgradewallet   \t  "   + _("Upgrade wallet to latest format") + "\n" +
224             "  -keypool=<n>     \t  "   + _("Set key pool size to <n> (default: 100)") + "\n" +
225             "  -rescan          \t  "   + _("Rescan the block chain for missing wallet transactions") + "\n" +
226             "  -checkblocks=<n> \t\t  " + _("How many blocks to check at startup (default: 2500, 0 = all)") + "\n" +
227             "  -checklevel=<n>  \t\t  " + _("How thorough the block verification is (0-6, default: 1)") + "\n";
228
229         strUsage += string() +
230             _("\nSSL options: (see the Bitcoin Wiki for SSL setup instructions)") + "\n" +
231             "  -rpcssl                                \t  " + _("Use OpenSSL (https) for JSON-RPC connections") + "\n" +
232             "  -rpcsslcertificatechainfile=<file.cert>\t  " + _("Server certificate file (default: server.cert)") + "\n" +
233             "  -rpcsslprivatekeyfile=<file.pem>       \t  " + _("Server private key (default: server.pem)") + "\n" +
234             "  -rpcsslciphers=<ciphers>               \t  " + _("Acceptable ciphers (default: TLSv1+HIGH:!SSLv2:!aNULL:!eNULL:!AH:!3DES:@STRENGTH)") + "\n";
235
236         strUsage += string() +
237             "  -?               \t\t  " + _("This help message") + "\n";
238
239         // Remove tabs
240         strUsage.erase(std::remove(strUsage.begin(), strUsage.end(), '\t'), strUsage.end());
241 #if defined(QT_GUI) && defined(WIN32)
242         // On windows, show a message box, as there is no stderr
243         ThreadSafeMessageBox(strUsage, _("Usage"), wxOK | wxMODAL);
244 #else
245         fprintf(stderr, "%s", strUsage.c_str());
246 #endif
247         return false;
248     }
249
250     fTestNet = GetBoolArg("-testnet");
251     if (fTestNet)
252     {
253         SoftSetBoolArg("-irc", true);
254     }
255
256     fDebug = GetBoolArg("-debug");
257
258 #if !defined(WIN32) && !defined(QT_GUI)
259     fDaemon = GetBoolArg("-daemon");
260 #else
261     fDaemon = false;
262 #endif
263
264     if (fDaemon)
265         fServer = true;
266     else
267         fServer = GetBoolArg("-server");
268
269     /* force fServer when running without GUI */
270 #if !defined(QT_GUI)
271     fServer = true;
272 #endif
273     fPrintToConsole = GetBoolArg("-printtoconsole");
274     fPrintToDebugger = GetBoolArg("-printtodebugger");
275     fLogTimestamps = GetBoolArg("-logtimestamps");
276
277 #ifndef QT_GUI
278     for (int i = 1; i < argc; i++)
279         if (!IsSwitchChar(argv[i][0]) && !(strlen(argv[i]) > 7 && strncasecmp(argv[i], "bitcoin:", 8) == 0))
280             fCommandLine = true;
281
282     if (fCommandLine)
283     {
284         int ret = CommandLineRPC(argc, argv);
285         exit(ret);
286     }
287 #endif
288
289 #if !defined(WIN32) && !defined(QT_GUI)
290     if (fDaemon)
291     {
292         // Daemonize
293         pid_t pid = fork();
294         if (pid < 0)
295         {
296             fprintf(stderr, "Error: fork() returned %d errno %d\n", pid, errno);
297             return false;
298         }
299         if (pid > 0)
300         {
301             CreatePidFile(GetPidFile(), pid);
302             return true;
303         }
304
305         pid_t sid = setsid();
306         if (sid < 0)
307             fprintf(stderr, "Error: setsid() returned %d errno %d\n", sid, errno);
308     }
309 #endif
310
311     if (!fDebug)
312         ShrinkDebugFile();
313     printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
314     printf("Bitcoin version %s (%s)\n", FormatFullVersion().c_str(), CLIENT_DATE.c_str());
315     printf("Default data directory %s\n", GetDefaultDataDir().string().c_str());
316
317     if (GetBoolArg("-loadblockindextest"))
318     {
319         CTxDB txdb("r");
320         txdb.LoadBlockIndex();
321         PrintBlockTree();
322         return false;
323     }
324
325     // Make sure only a single bitcoin process is using the data directory.
326     boost::filesystem::path pathLockFile = GetDataDir() / ".lock";
327     FILE* file = fopen(pathLockFile.string().c_str(), "a"); // empty lock file; created if it doesn't exist.
328     if (file) fclose(file);
329     static boost::interprocess::file_lock lock(pathLockFile.string().c_str());
330     if (!lock.try_lock())
331     {
332         ThreadSafeMessageBox(strprintf(_("Cannot obtain a lock on data directory %s.  Bitcoin is probably already running."), GetDataDir().string().c_str()), _("Bitcoin"), wxOK|wxMODAL);
333         return false;
334     }
335
336     std::ostringstream strErrors;
337     //
338     // Load data files
339     //
340     if (fDaemon)
341         fprintf(stdout, "bitcoin server starting\n");
342     int64 nStart;
343
344     InitMessage(_("Loading addresses..."));
345     printf("Loading addresses...\n");
346     nStart = GetTimeMillis();
347     if (!LoadAddresses())
348         strErrors << _("Error loading addr.dat") << "\n";
349     printf(" addresses   %15"PRI64d"ms\n", GetTimeMillis() - nStart);
350
351     InitMessage(_("Loading block index..."));
352     printf("Loading block index...\n");
353     nStart = GetTimeMillis();
354     if (!LoadBlockIndex())
355         strErrors << _("Error loading blkindex.dat") << "\n";
356     printf(" block index %15"PRI64d"ms\n", GetTimeMillis() - nStart);
357
358     InitMessage(_("Loading wallet..."));
359     printf("Loading wallet...\n");
360     nStart = GetTimeMillis();
361     bool fFirstRun;
362     pwalletMain = new CWallet("wallet.dat");
363     int nLoadWalletRet = pwalletMain->LoadWallet(fFirstRun);
364     if (nLoadWalletRet != DB_LOAD_OK)
365     {
366         if (nLoadWalletRet == DB_CORRUPT)
367             strErrors << _("Error loading wallet.dat: Wallet corrupted") << "\n";
368         else if (nLoadWalletRet == DB_TOO_NEW)
369             strErrors << _("Error loading wallet.dat: Wallet requires newer version of Bitcoin") << "\n";
370         else if (nLoadWalletRet == DB_NEED_REWRITE)
371         {
372             strErrors << _("Wallet needed to be rewritten: restart Bitcoin to complete") << "\n";
373             printf("%s", strErrors.str().c_str());
374             ThreadSafeMessageBox(strErrors.str(), _("Bitcoin"), wxOK | wxICON_ERROR | wxMODAL);
375             return false;
376         }
377         else
378             strErrors << _("Error loading wallet.dat") << "\n";
379     }
380
381     if (GetBoolArg("-upgradewallet", fFirstRun))
382     {
383         int nMaxVersion = GetArg("-upgradewallet", 0);
384         if (nMaxVersion == 0) // the -walletupgrade without argument case
385         {
386             printf("Performing wallet upgrade to %i\n", FEATURE_LATEST);
387             nMaxVersion = CLIENT_VERSION;
388             pwalletMain->SetMinVersion(FEATURE_LATEST); // permanently upgrade the wallet immediately
389         }
390         else
391             printf("Allowing wallet upgrade up to %i\n", nMaxVersion);
392         if (nMaxVersion < pwalletMain->GetVersion())
393             strErrors << _("Cannot downgrade wallet") << "\n";
394         pwalletMain->SetMaxVersion(nMaxVersion);
395     }
396
397     if (fFirstRun)
398     {
399         // Create new keyUser and set as default key
400         RandAddSeedPerfmon();
401
402         std::vector<unsigned char> newDefaultKey;
403         if (!pwalletMain->GetKeyFromPool(newDefaultKey, false))
404             strErrors << _("Cannot initialize keypool") << "\n";
405         pwalletMain->SetDefaultKey(newDefaultKey);
406         if (!pwalletMain->SetAddressBookName(CBitcoinAddress(pwalletMain->vchDefaultKey), ""))
407             strErrors << _("Cannot write default address") << "\n";
408     }
409
410     printf("%s", strErrors.str().c_str());
411     printf(" wallet      %15"PRI64d"ms\n", GetTimeMillis() - nStart);
412
413     RegisterWallet(pwalletMain);
414
415     CBlockIndex *pindexRescan = pindexBest;
416     if (GetBoolArg("-rescan"))
417         pindexRescan = pindexGenesisBlock;
418     else
419     {
420         CWalletDB walletdb("wallet.dat");
421         CBlockLocator locator;
422         if (walletdb.ReadBestBlock(locator))
423             pindexRescan = locator.GetBlockIndex();
424     }
425     if (pindexBest != pindexRescan)
426     {
427         InitMessage(_("Rescanning..."));
428         printf("Rescanning last %i blocks (from block %i)...\n", pindexBest->nHeight - pindexRescan->nHeight, pindexRescan->nHeight);
429         nStart = GetTimeMillis();
430         pwalletMain->ScanForWalletTransactions(pindexRescan, true);
431         printf(" rescan      %15"PRI64d"ms\n", GetTimeMillis() - nStart);
432     }
433
434     InitMessage(_("Done loading"));
435     printf("Done loading\n");
436
437     //// debug print
438     printf("mapBlockIndex.size() = %d\n",   mapBlockIndex.size());
439     printf("nBestHeight = %d\n",            nBestHeight);
440     printf("setKeyPool.size() = %d\n",      pwalletMain->setKeyPool.size());
441     printf("mapWallet.size() = %d\n",       pwalletMain->mapWallet.size());
442     printf("mapAddressBook.size() = %d\n",  pwalletMain->mapAddressBook.size());
443
444     if (!strErrors.str().empty())
445     {
446         ThreadSafeMessageBox(strErrors.str(), _("Bitcoin"), wxOK | wxICON_ERROR | wxMODAL);
447         return false;
448     }
449
450     // Add wallet transactions that aren't already in a block to mapTransactions
451     pwalletMain->ReacceptWalletTransactions();
452
453     // Note: Bitcoin-QT stores several settings in the wallet, so we want
454     // to load the wallet BEFORE parsing command-line arguments, so
455     // the command-line/bitcoin.conf settings override GUI setting.
456
457     //
458     // Parameters
459     //
460     if (GetBoolArg("-printblockindex") || GetBoolArg("-printblocktree"))
461     {
462         PrintBlockTree();
463         return false;
464     }
465
466     if (mapArgs.count("-timeout"))
467     {
468         int nNewTimeout = GetArg("-timeout", 5000);
469         if (nNewTimeout > 0 && nNewTimeout < 600000)
470             nConnectTimeout = nNewTimeout;
471     }
472
473     if (mapArgs.count("-printblock"))
474     {
475         string strMatch = mapArgs["-printblock"];
476         int nFound = 0;
477         for (map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.begin(); mi != mapBlockIndex.end(); ++mi)
478         {
479             uint256 hash = (*mi).first;
480             if (strncmp(hash.ToString().c_str(), strMatch.c_str(), strMatch.size()) == 0)
481             {
482                 CBlockIndex* pindex = (*mi).second;
483                 CBlock block;
484                 block.ReadFromDisk(pindex);
485                 block.BuildMerkleTree();
486                 block.print();
487                 printf("\n");
488                 nFound++;
489             }
490         }
491         if (nFound == 0)
492             printf("No blocks matching %s were found\n", strMatch.c_str());
493         return false;
494     }
495
496     if (mapArgs.count("-proxy"))
497     {
498         fUseProxy = true;
499         addrProxy = CService(mapArgs["-proxy"], 9050);
500         if (!addrProxy.IsValid())
501         {
502             ThreadSafeMessageBox(_("Invalid -proxy address"), _("Bitcoin"), wxOK | wxMODAL);
503             return false;
504         }
505     }
506
507     bool fTor = (fUseProxy && addrProxy.GetPort() == 9050);
508     if (fTor)
509     {
510         // Use SoftSetBoolArg here so user can override any of these if they wish.
511         // Note: the GetBoolArg() calls for all of these must happen later.
512         SoftSetBoolArg("-listen", false);
513         SoftSetBoolArg("-irc", false);
514         SoftSetBoolArg("-dnsseed", false);
515         SoftSetBoolArg("-upnp", false);
516         SoftSetBoolArg("-dns", false);
517     }
518
519     fAllowDNS = GetBoolArg("-dns");
520     fNoListen = !GetBoolArg("-listen", true);
521
522     // Continue to put "/P2SH/" in the coinbase to monitor
523     // BIP16 support.
524     // This can be removed eventually...
525     const char* pszP2SH = "/P2SH/";
526     COINBASE_FLAGS << std::vector<unsigned char>(pszP2SH, pszP2SH+strlen(pszP2SH));
527
528     if (!fNoListen)
529     {
530         std::string strError;
531         if (!BindListenPort(strError))
532         {
533             ThreadSafeMessageBox(strError, _("Bitcoin"), wxOK | wxMODAL);
534             return false;
535         }
536     }
537
538     if (mapArgs.count("-addnode"))
539     {
540         BOOST_FOREACH(string strAddr, mapMultiArgs["-addnode"])
541         {
542             CAddress addr(CService(strAddr, GetDefaultPort(), fAllowDNS));
543             addr.nTime = 0; // so it won't relay unless successfully connected
544             if (addr.IsValid())
545                 addrman.Add(addr, CNetAddr("127.0.0.1"));
546         }
547     }
548
549     if (mapArgs.count("-paytxfee"))
550     {
551         if (!ParseMoney(mapArgs["-paytxfee"], nTransactionFee))
552         {
553             ThreadSafeMessageBox(_("Invalid amount for -paytxfee=<amount>"), _("Bitcoin"), wxOK | wxMODAL);
554             return false;
555         }
556         if (nTransactionFee > 0.25 * COIN)
557             ThreadSafeMessageBox(_("Warning: -paytxfee is set very high.  This is the transaction fee you will pay if you send a transaction."), _("Bitcoin"), wxOK | wxICON_EXCLAMATION | wxMODAL);
558     }
559
560     //
561     // Start the node
562     //
563     if (!CheckDiskSpace())
564         return false;
565
566     RandAddSeedPerfmon();
567
568     if (!CreateThread(StartNode, NULL))
569         ThreadSafeMessageBox(_("Error: CreateThread(StartNode) failed"), _("Bitcoin"), wxOK | wxMODAL);
570
571     if (fServer)
572         CreateThread(ThreadRPCServer, NULL);
573
574 #ifdef QT_GUI
575     if(GetStartOnSystemStartup())
576         SetStartOnSystemStartup(true); // Remove startup links to bitcoin-wx
577 #endif
578
579 #if !defined(QT_GUI)
580     while (1)
581         Sleep(5000);
582 #endif
583
584     return true;
585 }
586