source: nscp/include/NSCHelper.h @ f0eb62d

0.4.00.4.10.4.2
Last change on this file since f0eb62d was f0eb62d, checked in by Michael Medin <michael@…>, 4 years ago

Refactored service into its own project

  • Property mode set to 100644
File size: 20.5 KB
Line 
1/**************************************************************************
2*   Copyright (C) 2004-2007 by Michael Medin <michael@medin.name>         *
3*                                                                         *
4*   This code is part of NSClient++ - http://trac.nakednuns.org/nscp      *
5*                                                                         *
6*   This program is free software; you can redistribute it and/or modify  *
7*   it under the terms of the GNU General Public License as published by  *
8*   the Free Software Foundation; either version 2 of the License, or     *
9*   (at your option) any later version.                                   *
10*                                                                         *
11*   This program is distributed in the hope that it will be useful,       *
12*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
13*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
14*   GNU General Public License for more details.                          *
15*                                                                         *
16*   You should have received a copy of the GNU General Public License     *
17*   along with this program; if not, write to the                         *
18*   Free Software Foundation, Inc.,                                       *
19*   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
20***************************************************************************/
21#pragma once
22
23#include <string>
24#include <list>
25#include <NSCAPI.h>
26#include <iostream>
27#include <charEx.h>
28#include <arrayBuffer.h>
29#include <windows.h>
30
31
32namespace NSCHelper
33{
34#ifdef DEBUG
35        NSCAPI::nagiosReturn wrapReturnString(TCHAR *buffer, unsigned int bufLen, std::wstring str, NSCAPI::nagiosReturn defaultReturnCode);
36        NSCAPI::errorReturn wrapReturnString(TCHAR *buffer, unsigned int bufLen, std::wstring str, NSCAPI::errorReturn defaultReturnCode);
37#else
38        int wrapReturnString(TCHAR *buffer, unsigned int bufLen, std::wstring str, int defaultReturnCode);
39#endif
40        std::wstring translateMessageType(NSCAPI::messageTypes msgType);
41        std::wstring translateReturn(NSCAPI::nagiosReturn returnCode);
42        NSCAPI::nagiosReturn translateReturn(std::wstring str);
43        NSCAPI::nagiosReturn maxState(NSCAPI::nagiosReturn a, NSCAPI::nagiosReturn b);
44
45        inline bool isNagiosReturnCode(NSCAPI::nagiosReturn code) {
46                if ( (code == NSCAPI::returnOK) || (code == NSCAPI::returnWARN) || (code == NSCAPI::returnCRIT) || (code == NSCAPI::returnUNKNOWN) )
47                        return true;
48                return false;
49        }
50        inline bool isMyNagiosReturn(NSCAPI::nagiosReturn code) {
51                return code == NSCAPI::returnCRIT || code == NSCAPI::returnOK || code == NSCAPI::returnWARN || code == NSCAPI::returnUNKNOWN
52                        || code == NSCAPI::returnInvalidBufferLen || code == NSCAPI::returnIgnored;
53        }
54
55#ifdef DEBUG
56        inline NSCAPI::nagiosReturn int2nagios(int code) {
57                if (code == 0)
58                        return NSCAPI::returnOK;
59                if (code == 1)
60                        return NSCAPI::returnWARN;
61                if (code == 2)
62                        return NSCAPI::returnCRIT;
63                if (code == 4)
64                        return NSCAPI::returnUNKNOWN;
65                throw "@fixme bad code";
66        }
67        inline int nagios2int(NSCAPI::nagiosReturn code) {
68                if (code == NSCAPI::returnOK)
69                        return 0;
70                if (code == NSCAPI::returnWARN)
71                        return 1;
72                if (code == NSCAPI::returnCRIT)
73                        return 2;
74                if (code == NSCAPI::returnUNKNOWN)
75                        return 4;
76                throw "@fixme bad code";
77        }
78#else
79        inline NSCAPI::nagiosReturn int2nagios(int code) {
80                return code;
81        }
82        inline int nagios2int(NSCAPI::nagiosReturn code) {
83                return code;
84        }
85#endif
86        inline void escalteReturnCodeToCRIT(NSCAPI::nagiosReturn &currentReturnCode) {
87                currentReturnCode = NSCAPI::returnCRIT;
88        }
89        inline void escalteReturnCodeToWARN(NSCAPI::nagiosReturn &currentReturnCode) {
90                if (currentReturnCode != NSCAPI::returnCRIT)
91                        currentReturnCode = NSCAPI::returnWARN;
92        }
93};
94
95namespace NSCModuleHelper
96{
97        class NSCMHExcpetion {
98        public:
99                std::wstring msg_;
100                NSCMHExcpetion(std::wstring msg) : msg_(msg) {}
101        };
102        struct plugin_info_type {
103                std::wstring dll;
104                std::wstring name;
105                std::wstring version;
106                std::wstring description;
107        };
108        typedef std::list<plugin_info_type> plugin_info_list;
109        // Types for the Callbacks into the main program
110        typedef NSCAPI::errorReturn (*lpNSAPIGetBasePath)(TCHAR*,unsigned int);
111        typedef NSCAPI::errorReturn (*lpNSAPIGetApplicationName)(TCHAR*,unsigned int);
112        typedef NSCAPI::errorReturn (*lpNSAPIGetApplicationVersionStr)(TCHAR*,unsigned int);
113        typedef NSCAPI::errorReturn (*lpNSAPIGetSettingsString)(const TCHAR*,const TCHAR*,const TCHAR*,TCHAR*,unsigned int);
114        typedef NSCAPI::errorReturn (*lpNSAPIGetSettingsInt)(const TCHAR*, const TCHAR*, int);
115        typedef NSCAPI::errorReturn (*lpNSAPIGetSettingsSection)(const TCHAR*, arrayBuffer::arrayBuffer*, unsigned int *);
116        typedef NSCAPI::errorReturn (*lpNSAPIReleaseSettingsSectionBuffer)(arrayBuffer::arrayBuffer*, unsigned int *);
117        typedef void (*lpNSAPIMessage)(int, const TCHAR*, const int, const TCHAR*);
118        typedef NSCAPI::errorReturn (*lpNSAPIStopServer)(void);
119        typedef NSCAPI::errorReturn (*lpNSAPIExit)(void);
120        typedef NSCAPI::nagiosReturn (*lpNSAPIInject)(const TCHAR*, const unsigned int, TCHAR **, TCHAR *, unsigned int, TCHAR *, unsigned int);
121        typedef void* (*lpNSAPILoader)(TCHAR*);
122        typedef NSCAPI::boolReturn (*lpNSAPICheckLogMessages)(int);
123        typedef NSCAPI::errorReturn (*lpNSAPIEncrypt)(unsigned int, const TCHAR*, unsigned int, TCHAR*, unsigned int *);
124        typedef NSCAPI::errorReturn (*lpNSAPIDecrypt)(unsigned int, const TCHAR*, unsigned int, TCHAR*, unsigned int *);
125        typedef NSCAPI::errorReturn (*lpNSAPISetSettingsString)(const TCHAR*, const TCHAR*, const TCHAR*);
126        typedef NSCAPI::errorReturn (*lpNSAPISetSettingsInt)(const TCHAR*, const TCHAR*, int);
127        typedef NSCAPI::errorReturn (*lpNSAPIWriteSettings)(int);
128        typedef NSCAPI::errorReturn (*lpNSAPIReadSettings)(int);
129        typedef NSCAPI::errorReturn (*lpNSAPIRehash)(int);
130        typedef NSCAPI::errorReturn (*lpNSAPIDescribeCommand)(const TCHAR*,TCHAR*,unsigned int);
131        typedef NSCAPI::errorReturn (*lpNSAPIGetAllCommandNames)(arrayBuffer::arrayBuffer*, unsigned int *);
132        typedef NSCAPI::errorReturn (*lpNSAPIReleaseAllCommandNamessBuffer)(arrayBuffer::arrayBuffer*, unsigned int *);
133        typedef NSCAPI::errorReturn (*lpNSAPIRegisterCommand)(const TCHAR*,const TCHAR*);
134        typedef NSCAPI::errorReturn (*lpNSAPISettingsRegKey)(const TCHAR*, const TCHAR*, int, const TCHAR*, const TCHAR*, const TCHAR*, int);
135        typedef NSCAPI::errorReturn (*lpNSAPISettingsRegPath)(const TCHAR*, const TCHAR*, const TCHAR*, int);
136        typedef NSCAPI::errorReturn (*lpNSAPIGetPluginList)(int *len, NSCAPI::plugin_info *list[]);
137        typedef NSCAPI::errorReturn (*lpNSAPIReleasePluginList)(int len, NSCAPI::plugin_info *list[]);
138        typedef NSCAPI::errorReturn (*lpNSAPISettingsSave)(void);
139
140
141        // Helper functions for calling into the core
142        std::wstring getApplicationName(void);
143        std::wstring getApplicationVersionString(void);
144        std::list<std::wstring> getSettingsSection(std::wstring section);
145        std::wstring getSettingsString(std::wstring section, std::wstring key, std::wstring defaultValue);
146        int getSettingsInt(std::wstring section, std::wstring key, int defaultValue);
147        void settings_register_key(std::wstring path, std::wstring key, NSCAPI::settings_type type, std::wstring title, std::wstring description, std::wstring defaultValue, bool advanced);
148        void settings_register_path(std::wstring path, std::wstring title, std::wstring description, bool advanced);
149        void settings_save();
150
151        void Message(int msgType, std::wstring file, int line, std::wstring message);
152        NSCAPI::nagiosReturn InjectCommandRAW(const TCHAR* command, const unsigned int argLen, TCHAR **argument, TCHAR *returnMessageBuffer, unsigned int returnMessageBufferLen, TCHAR *returnPerfBuffer, unsigned int returnPerfBufferLen);
153        NSCAPI::nagiosReturn InjectCommand(const TCHAR* command, const unsigned int argLen, TCHAR **argument, std::wstring & message, std::wstring & perf);
154        NSCAPI::nagiosReturn InjectCommand(const TCHAR* command, std::list<std::wstring> argument, std::wstring & message, std::wstring & perf);
155        NSCAPI::nagiosReturn InjectSplitAndCommand(const TCHAR* command, TCHAR* buffer, TCHAR splitChar, std::wstring & message, std::wstring & perf);
156        NSCAPI::nagiosReturn InjectSplitAndCommand(const std::wstring command, const std::wstring buffer, TCHAR splitChar, std::wstring & message, std::wstring & perf, bool escape = false);
157        void StopService(void);
158        void Exit(void);
159        std::wstring getBasePath();
160        bool logDebug();
161        bool checkLogMessages(int type);
162        std::wstring Encrypt(std::wstring str, unsigned int algorithm = NSCAPI::xor);
163        std::wstring Decrypt(std::wstring str, unsigned int algorithm = NSCAPI::xor);
164        NSCAPI::errorReturn SetSettingsString(std::wstring section, std::wstring key, std::wstring value);
165        NSCAPI::errorReturn SetSettingsInt(std::wstring section, std::wstring key, int value);
166        NSCAPI::errorReturn WriteSettings(int type);
167        NSCAPI::errorReturn ReadSettings(int type);
168        NSCAPI::errorReturn Rehash(int flag);
169        plugin_info_list getPluginList();
170
171        std::list<std::wstring> getAllCommandNames();
172        std::wstring describeCommand(std::wstring command);
173        void registerCommand(std::wstring command, std::wstring description);
174        unsigned int getBufferLength();
175};
176
177namespace NSCModuleWrapper {
178        struct module_version {
179                int major;
180                int minor;
181                int revision;
182        };
183
184        BOOL wrapDllMain(HANDLE hModule, DWORD ul_reason_for_call);
185        HINSTANCE getModule();
186
187        int wrapModuleHelperInit(NSCModuleHelper::lpNSAPILoader f);;
188        NSCAPI::errorReturn wrapGetModuleName(TCHAR* buf, unsigned int buflen, std::wstring str);
189        NSCAPI::errorReturn wrapGetConfigurationMeta(TCHAR* buf, unsigned int buflen, std::wstring str);
190        int wrapLoadModule(bool success);
191        NSCAPI::errorReturn wrapGetModuleVersion(int *major, int *minor, int *revision, module_version version);
192        NSCAPI::boolReturn wrapHasCommandHandler(bool has);
193        NSCAPI::boolReturn wrapHasMessageHandler(bool has);
194        int wrapUnloadModule(bool success);
195        NSCAPI::nagiosReturn wrapHandleCommand(NSCAPI::nagiosReturn retResult, const std::wstring retMessage, const std::wstring retPerformance, TCHAR *returnBufferMessage, unsigned int returnBufferMessageLen, TCHAR *returnBufferPerf, unsigned int returnBufferPerfLen);
196}
197
198//////////////////////////////////////////////////////////////////////////
199// Module wrappers (definitions)
200#define NSC_WRAPPERS_MAIN() \
201        extern "C" int NSModuleHelperInit(NSCModuleHelper::lpNSAPILoader f); \
202        extern int NSLoadModule(int mode); \
203        extern int NSGetModuleName(TCHAR* buf, int buflen); \
204        extern int NSGetModuleDescription(TCHAR* buf, int buflen); \
205        extern int NSGetModuleVersion(int *major, int *minor, int *revision); \
206        extern NSCAPI::boolReturn NSHasCommandHandler(); \
207        extern NSCAPI::boolReturn NSHasMessageHandler(); \
208        extern void NSHandleMessage(int msgType, TCHAR* file, int line, TCHAR* message); \
209        extern NSCAPI::nagiosReturn NSHandleCommand(const TCHAR* IN_cmd, const unsigned int IN_argsLen, TCHAR **IN_args, \
210                TCHAR *OUT_retBufMessage, unsigned int IN_retBufMessageLen, TCHAR *OUT_retBufPerf, unsigned int IN_retBufPerfLen); \
211        extern int NSUnloadModule(); \
212        extern int NSGetConfigurationMeta(int IN_retBufLen, TCHAR *OUT_retBuf)
213
214#define NSC_WRAPPERS_CLI() \
215        extern int NSCommandLineExec(const TCHAR*,const unsigned int,TCHAR**)
216
217#ifdef DEBUG
218#define NSC_LOG_ERROR_STD_C(msg) NSC_LOG_ERROR(((std::wstring)msg).c_str())
219#define NSC_LOG_ERROR_C(msg) { \
220        NSCModuleHelper::Message(NSCAPI::error, _T(__FILE__), __LINE__, msg) \
221        std::wcerr << msg << std::endl; }
222#else
223#define NSC_LOG_ERROR_STD_C(msg) NSC_LOG_ERROR_STD(msg)
224#define NSC_LOG_ERROR_C(msg) NSC_LOG_ERROR(msg)
225#endif
226
227
228#define NSC_LOG_ERROR_STD(msg) NSC_LOG_ERROR(((std::wstring)msg).c_str())
229#define NSC_LOG_ERROR(msg) \
230        NSCModuleHelper::Message(NSCAPI::error, _T(__FILE__), __LINE__, msg)
231
232#define NSC_LOG_CRITICAL_STD(msg) NSC_LOG_CRITICAL(((std::wstring)msg).c_str())
233#define NSC_LOG_CRITICAL(msg) \
234        NSCModuleHelper::Message(NSCAPI::critical, _T(__FILE__), __LINE__, msg)
235
236#define NSC_LOG_MESSAGE_STD(msg) NSC_LOG_MESSAGE(((std::wstring)msg).c_str())
237#define NSC_LOG_MESSAGE(msg) \
238        NSCModuleHelper::Message(NSCAPI::log, _T(__FILE__), __LINE__, msg)
239
240//#define NSC_DEBUG_MSG_STD(msg) NSC_DEBUG_MSG(((std::wstring)msg).c_str())
241#define NSC_DEBUG_MSG_STD(msg) NSC_DEBUG_MSG((std::wstring)msg)
242#define NSC_DEBUG_MSG(msg) \
243        NSCModuleHelper::Message(NSCAPI::debug, _T(__FILE__), __LINE__, msg)
244
245/*
246#define NSC_DEBUG_MSG_STD(msg)
247#define NSC_DEBUG_MSG(msg)
248*/
249//////////////////////////////////////////////////////////////////////////
250// Message wrappers below this point
251
252#define NSC_WRAPPERS_MAIN_DEF(toObject) \
253        extern int NSModuleHelperInit(NSCModuleHelper::lpNSAPILoader f) { \
254                try { \
255                        return NSCModuleWrapper::wrapModuleHelperInit(f); \
256                } catch (...) { \
257                        NSC_LOG_CRITICAL(_T("Unknown exception in: wrapModuleHelperInit(...)")); \
258                        return NSCAPI::hasFailed; \
259                } \
260        } \
261        extern int NSLoadModule(int mode) { \
262                try { \
263                        return NSCModuleWrapper::wrapLoadModule(toObject.loadModule(mode)); \
264                } catch (NSCModuleHelper::NSCMHExcpetion e) { \
265                        NSC_LOG_CRITICAL(_T("NSCMHE in: wrapLoadModule: " + e.msg_)); \
266                        return NSCAPI::hasFailed; \
267                } catch (...) { \
268                        NSC_LOG_CRITICAL(_T("Unknown exception in: wrapLoadModule(...)")); \
269                        return NSCAPI::hasFailed; \
270                } \
271        } \
272        extern int NSGetModuleName(TCHAR* buf, int buflen) { \
273                try { \
274                        return NSCModuleWrapper::wrapGetModuleName(buf, buflen, toObject.getModuleName()); \
275                } catch (...) { \
276                        NSC_LOG_CRITICAL(_T("Unknown exception in: wrapGetModuleName(...)")); \
277                        return NSCAPI::hasFailed; \
278                } \
279        } \
280        extern int NSGetModuleDescription(TCHAR* buf, int buflen) { \
281                try { \
282                        return NSCModuleWrapper::wrapGetModuleName(buf, buflen, toObject.getModuleDescription()); \
283                } catch (...) { \
284                        NSC_LOG_CRITICAL(_T("Unknown exception in: wrapGetModuleName(...)")); \
285                        return NSCAPI::hasFailed; \
286                } \
287        } \
288        extern int NSGetModuleVersion(int *major, int *minor, int *revision) { \
289                try { \
290                        return NSCModuleWrapper::wrapGetModuleVersion(major, minor, revision, toObject.getModuleVersion()); \
291                } catch (...) { \
292                        NSC_LOG_CRITICAL(_T("Unknown exception in: wrapGetModuleVersion(...)")); \
293                        return NSCAPI::hasFailed; \
294                } \
295        } \
296        extern int NSUnloadModule() { \
297                try { \
298                        return NSCModuleWrapper::wrapUnloadModule(toObject.unloadModule()); \
299                } catch (...) { \
300                        NSC_LOG_CRITICAL(_T("Unknown exception in: wrapGetModuleVersion(...)")); \
301                        return NSCAPI::hasFailed; \
302                } \
303        }
304#define NSC_WRAPPERS_HANDLE_MSG_DEF(toObject) \
305        extern void NSHandleMessage(int msgType, TCHAR* file, int line, TCHAR* message) { \
306                try { \
307                        toObject.handleMessage(msgType, file, line, message); \
308                } catch (...) { \
309                        NSC_LOG_CRITICAL(_T("Unknown exception in: handleMessage(...)")); \
310                } \
311        } \
312        extern NSCAPI::boolReturn NSHasMessageHandler() { \
313                try { \
314                        return NSCModuleWrapper::wrapHasMessageHandler(toObject.hasMessageHandler()); \
315                } catch (...) { \
316                        NSC_LOG_CRITICAL(_T("Unknown exception in: wrapHasMessageHandler(...)")); \
317                        return NSCAPI::isfalse; \
318                } \
319        }
320#define NSC_WRAPPERS_IGNORE_MSG_DEF() \
321        extern void NSHandleMessage(int msgType, TCHAR* file, int line, TCHAR* message) {} \
322        extern NSCAPI::boolReturn NSHasMessageHandler() { return NSCAPI::isfalse; }
323#define NSC_WRAPPERS_HANDLE_CMD_DEF(toObject) \
324        extern NSCAPI::nagiosReturn NSHandleCommand(const TCHAR* IN_cmd, const unsigned int IN_argsLen, TCHAR **IN_args, \
325                                                                        TCHAR *OUT_retBufMessage, unsigned int IN_retBufMessageLen, TCHAR *OUT_retBufPerf, unsigned int IN_retBufPerfLen) \
326        { \
327                try { \
328                        std::wstring message, perf; \
329                        NSCAPI::nagiosReturn retCode = toObject.handleCommand(IN_cmd, IN_argsLen, IN_args, message, perf); \
330                        return NSCModuleWrapper::wrapHandleCommand(retCode, message, perf, OUT_retBufMessage, IN_retBufMessageLen, OUT_retBufPerf, IN_retBufPerfLen); \
331                } catch (...) { \
332                        NSC_LOG_CRITICAL(_T("Unknown exception in: wrapHandleCommand(...)")); \
333                        return NSCAPI::returnIgnored; \
334                } \
335        } \
336        extern NSCAPI::boolReturn NSHasCommandHandler() { \
337                try { \
338                        return NSCModuleWrapper::wrapHasCommandHandler(toObject.hasCommandHandler()); \
339                } catch (...) { \
340                        NSC_LOG_CRITICAL(_T("Unknown exception in: wrapHasCommandHandler(...)")); \
341                        return NSCAPI::isfalse; \
342                } \
343        }
344#define NSC_WRAPPERS_IGNORE_CMD_DEF() \
345        extern NSCAPI::nagiosReturn NSHandleCommand(const TCHAR* IN_cmd, const unsigned int IN_argsLen, TCHAR **IN_args, \
346                                                                        TCHAR *OUT_retBufMessage, unsigned int IN_retBufMessageLen, TCHAR *OUT_retBufPerf, unsigned int IN_retBufPerfLen) { \
347                return NSCAPI::returnIgnored; \
348        } \
349        extern NSCAPI::boolReturn NSHasCommandHandler() { return NSCAPI::isfalse; }
350
351
352#define NSC_WRAPPERS_HANDLE_CONFIGURATION(toObject) \
353        extern int NSGetConfigurationMeta(int IN_retBufLen, TCHAR *OUT_retBuf) \
354        { \
355                try { \
356                        return NSCModuleWrapper::wrapGetConfigurationMeta(OUT_retBuf, IN_retBufLen, toObject.getConfigurationMeta()); \
357                } catch (...) { \
358                        NSC_LOG_CRITICAL(_T("Unknown exception in: wrapGetConfigurationMeta(...)")); \
359                        return NSCAPI::hasFailed; \
360                } \
361        }
362
363#define NSC_WRAPPERS_CLI_DEF(toObject) \
364        extern int NSCommandLineExec(const TCHAR* command,const unsigned int argLen,TCHAR** args) { \
365                try { \
366                        return toObject.commandLineExec(command, argLen, args); \
367                } catch (...) { \
368                        NSC_LOG_CRITICAL(_T("Unknown exception in: commandLineExec(...)")); \
369                        std::wcerr << _T("Unknown exception in: commandLineExec(...)") << std::endl; \
370                        return NSCAPI::hasFailed; \
371                } \
372        } \
373
374//////////////////////////////////////////////////////////////////////////
375#define MODULE_SETTINGS_START(class, name, description) \
376        std::wstring class::getConfigurationMeta() { \
377        return (std::wstring)_T("<module name=\"") + name + _T("\" description=\"") + description + _T("\">") \
378        _T("<pages>")
379
380
381#define ADVANCED_PAGE(title) \
382        _T("<page title=\"") title _T("\" advanced=\"true\">") \
383        _T("<items>")
384
385#define PAGE(title) \
386        _T("<page title=\"") title _T("\">") \
387        _T("<items>")
388
389#define ITEM_EDIT_TEXT(caption, description) \
390        _T("<item type=\"text\" caption=\"") caption _T("\" description=\"") description _T("\"><options>")
391
392#define ITEM_EDIT_OPTIONAL_LIST(caption, description) \
393        _T("<item type=\"optional_list\" caption=\"") caption _T("\" description=\"") description _T("\"><options>")
394
395#define ITEM_CHECK_BOOL(caption, description) \
396        _T("<item type=\"bool\" caption=\"") caption _T("\" description=\"") description _T("\"><options>")
397
398#define ITEM_MAP_TO(type) \
399        _T("</options><mapper type=\"") type _T("\">") \
400        _T("<options>")
401
402#define OPTION(key, value) \
403        _T("<option key=\"") key _T("\" value=\"") value _T("\"/>")
404
405#define ITEM_END() \
406        _T("</options>") \
407        _T("</mapper>") \
408        _T("</item>")
409
410#define PAGE_END() \
411        _T("</items>") \
412        _T("</page>")
413
414#define MODULE_SETTINGS_END() \
415                        _T("</pages>") \
416                _T("</module>"); \
417        }
418
419#define SETTINGS_MAKE_NAME(key) \
420        std::wstring(settings::key ## _PATH + _T(".") + settings::key)
421
422#define SETTINGS_GET_STRING(key) \
423        NSCModuleHelper::getSettingsString(settings::key ## _PATH, settings::key, settings::key ## _DEFAULT)
424#define SETTINGS_GET_INT(key) \
425        NSCModuleHelper::getSettingsInt(settings::key ## _PATH, settings::key, settings::key ## _DEFAULT)
426#define SETTINGS_GET_BOOL(key) \
427        NSCModuleHelper::getSettingsInt(settings::key ## _PATH, settings::key, settings::key ## _DEFAULT)
428
429#define SETTINGS_GET_STRING_FALLBACK(key, fallback) \
430        NSCModuleHelper::getSettingsString(settings::key ## _PATH, settings::key, NSCModuleHelper::getSettingsString(settings::fallback ## _PATH, settings::fallback, settings::fallback ## _DEFAULT))
431#define SETTINGS_GET_INT_FALLBACK(key, fallback) \
432        NSCModuleHelper::getSettingsInt(settings::key ## _PATH, settings::key, NSCModuleHelper::getSettingsInt(settings::fallback ## _PATH, settings::fallback, settings::fallback ## _DEFAULT))
433#define SETTINGS_GET_BOOL_FALLBACK(key, fallback) \
434        NSCModuleHelper::getSettingsInt(settings::key ## _PATH, settings::key, NSCModuleHelper::getSettingsInt(settings::fallback ## _PATH, settings::fallback, settings::fallback ## _DEFAULT))
435
436#define SETTINGS_REG_KEY_S(key) \
437        NSCModuleHelper::settings_register_key(settings::key ## _PATH, settings::key, NSCAPI::key_string, settings::key ## _TITLE, settings::key ## _DESC, settings::key ## _DEFAULT, settings::key ## _ADVANCED);
438#define SETTINGS_REG_KEY_I(key) \
439        NSCModuleHelper::settings_register_key(settings::key ## _PATH, settings::key, NSCAPI::key_integer, settings::key ## _TITLE, settings::key ## _DESC, strEx::itos(settings::key ## _DEFAULT), settings::key ## _ADVANCED);
440#define SETTINGS_REG_KEY_B(key) \
441        NSCModuleHelper::settings_register_key(settings::key ## _PATH, settings::key, NSCAPI::key_integer, settings::key ## _TITLE, settings::key ## _DESC, settings::key ## _DEFAULT==1?_T("1"):_T("0"), settings::key ## _ADVANCED);
442#define SETTINGS_REG_PATH(key) \
443        NSCModuleHelper::settings_register_path(settings::key ## _PATH, settings::key ## _TITLE, settings::key ## _DESC, settings::key ## _ADVANCED);
Note: See TracBrowser for help on using the repository browser.