joachim99@75
|
1 /*
|
joachim99@75
|
2 * Copyright (c) 2003-2005, Sergey Zorin. All rights reserved.
|
joachim99@75
|
3 *
|
joachim99@75
|
4 * This software is distributable under the BSD license. See the terms
|
joachim99@75
|
5 * of the BSD license in the LICENSE file provided with this software.
|
joachim99@75
|
6 *
|
joachim99@75
|
7 */
|
joachim99@75
|
8 #ifndef __server_h__
|
joachim99@75
|
9 #define __server_h__
|
joachim99@75
|
10 #include <list> // std::list
|
joachim99@75
|
11 //#include <log/file_sink.h>
|
joachim99@75
|
12 #include <windows.h>
|
joachim99@75
|
13
|
joachim99@75
|
14 #if 1
|
joachim99@75
|
15 #include <string> // std::wstring
|
joachim99@75
|
16 #ifdef UNICODE
|
joachim99@75
|
17 typedef std::wstring tstring;
|
joachim99@75
|
18 #else
|
joachim99@75
|
19 typedef std::string tstring;
|
joachim99@75
|
20 #endif
|
joachim99@75
|
21 #define i18n(x) getTranslation( TEXT(x) )
|
joachim99@75
|
22 #else
|
joachim99@75
|
23 #include "diffextstring.h"
|
joachim99@75
|
24 typedef STRING tstring;
|
joachim99@75
|
25 #define i18n(x) TEXT(x)
|
joachim99@75
|
26 #endif
|
joachim99@75
|
27
|
joachim99@75
|
28 #define MESSAGELOG( msg ) SERVER::logMessage( __FUNCTION__, __FILE__, __LINE__, msg )
|
joachim99@75
|
29 #define LOG() MESSAGELOG( TEXT("") )
|
joachim99@75
|
30 #define ERRORLOG( msg ) MESSAGELOG( TEXT("Error: ")+tstring(msg) )
|
joachim99@75
|
31 #define SYSERRORLOG( msg ) \
|
joachim99@75
|
32 { \
|
joachim99@75
|
33 LPTSTR message; \
|
joachim99@75
|
34 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM, 0, \
|
joachim99@75
|
35 GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &message, 0, 0); \
|
joachim99@75
|
36 ERRORLOG( (tstring(msg) + TEXT(": ")) + message ); \
|
joachim99@75
|
37 LocalFree(message); \
|
joachim99@75
|
38 }
|
joachim99@75
|
39
|
joachim99@75
|
40
|
joachim99@75
|
41 class SERVER {
|
joachim99@75
|
42 public:
|
joachim99@75
|
43 static SERVER* instance();
|
joachim99@75
|
44 void initLogging();
|
joachim99@75
|
45
|
joachim99@75
|
46 public:
|
joachim99@75
|
47 virtual ~SERVER();
|
joachim99@75
|
48
|
joachim99@75
|
49 tstring getRegistryKeyString( const tstring& subKey, const tstring& value );
|
joachim99@75
|
50
|
joachim99@75
|
51 HINSTANCE handle() const;
|
joachim99@75
|
52
|
joachim99@75
|
53 HRESULT do_register();
|
joachim99@75
|
54 HRESULT do_unregister();
|
joachim99@75
|
55
|
joachim99@75
|
56 void lock();
|
joachim99@75
|
57 void release();
|
joachim99@75
|
58
|
joachim99@75
|
59 ULONG reference_count() const {
|
joachim99@75
|
60 return _reference_count;
|
joachim99@75
|
61 }
|
joachim99@75
|
62
|
joachim99@75
|
63 std::list< tstring >& recent_files();
|
joachim99@75
|
64
|
joachim99@75
|
65 void save_history() const;
|
joachim99@75
|
66
|
joachim99@75
|
67 static void logMessage( const char* function, const char* file, int line, const tstring& msg );
|
joachim99@75
|
68
|
joachim99@75
|
69 private:
|
joachim99@75
|
70 SERVER();
|
joachim99@75
|
71 SERVER(const SERVER&) {}
|
joachim99@75
|
72
|
joachim99@75
|
73 private:
|
joachim99@75
|
74 LONG _reference_count;
|
joachim99@75
|
75 std::list<tstring>* m_pRecentFiles;
|
joachim99@75
|
76 static SERVER* _instance;
|
joachim99@75
|
77 tstring m_registryBaseName;
|
joachim99@75
|
78 FILE* m_pLogFile;
|
joachim99@75
|
79 };
|
joachim99@75
|
80
|
joachim99@75
|
81 #endif // __server_h__
|