source: nscp/include/NSCAPI.h @ 291548e

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

Tweaks to the settings subsystem (thread safeness) as well as additions to the command line client and such...

  • Property mode set to 100644
File size: 7.2 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
24#include <unicode_char.hpp>
25
26namespace NSCAPI {
27
28#ifdef DEBUG
29        typedef enum {
30                returnCRIT = 2,
31                returnOK = 0,
32                returnWARN = 1,
33                returnUNKNOWN = 3,
34                returnInvalidBufferLen = -2,
35                returnIgnored = -1
36        } nagiosReturn;
37        typedef enum {
38                istrue = 1,
39                isfalse = 0
40        } boolReturn;
41        typedef enum {
42                isSuccess = 1,
43                hasFailed = 0,
44                isInvalidBufferLen = -2
45        } errorReturn;
46        typedef enum {
47                key_string = 100,
48                key_integer = 200,
49                key_bool = 300,
50        } settings_type;
51
52        typedef enum {
53                normalStart = 0,
54                dontStart = 1,
55        } moduleLoadMode;
56#else
57        const int normalStart = 0;
58        const int dontStart = 1;
59        const int returnOK = 0;
60        const int returnWARN = 1;
61        const int returnCRIT = 2;
62        const int returnUNKNOWN = 3;
63        const int returnInvalidBufferLen = -2;
64        const int returnIgnored = -1;
65        const int istrue = 1;
66        const int isfalse = 0;
67        const int isSuccess = 1;
68        const int hasFailed = 0;
69        const int isInvalidBufferLen = -2;
70        const int key_string = 100;
71        const int key_integer = 200;
72        const int key_bool = 300;
73
74        typedef int nagiosReturn;
75        typedef int boolReturn;
76        typedef int errorReturn;
77        typedef int settings_type;
78        typedef int moduleLoadMode;
79#endif
80
81        const int encryption_xor = 1;
82
83        // Settings types
84        const int settings_default = 0;
85        const int settings_registry = 1;
86        const int settings_inifile = 2;
87
88        // Various message Types
89        const int log = 1;                              // Log message
90        const int error = -1;                   // Error (non critical)
91        const int critical = -10;               // Critical error
92        const int warning = 2;                  // Warning
93        const int debug = 10;                   // Debug message
94
95        typedef int messageTypes;               // Message type
96
97        struct plugin_info {
98                wchar_t *dll;
99                wchar_t *name;
100                wchar_t *description;
101                wchar_t *version;
102        };
103        typedef plugin_info* plugin_info_list;
104
105
106};
107
108namespace nscapi {
109
110
111        class nscapi_exception {
112        public:
113                std::wstring msg_;
114                nscapi_exception(std::wstring msg) : msg_(msg) {}
115        };
116
117        namespace core_api {
118                typedef void* (*lpNSAPILoader)(const wchar_t*);
119
120                typedef NSCAPI::errorReturn (*lpNSAPIGetBasePath)(wchar_t*,unsigned int);
121                typedef NSCAPI::errorReturn (*lpNSAPIGetApplicationName)(wchar_t*,unsigned int);
122                typedef NSCAPI::errorReturn (*lpNSAPIGetApplicationVersionStr)(wchar_t*,unsigned int);
123                typedef NSCAPI::errorReturn (*lpNSAPIGetSettingsString)(const wchar_t*,const wchar_t*,const wchar_t*,wchar_t*,unsigned int);
124                typedef NSCAPI::errorReturn (*lpNSAPIExpandPath)(const wchar_t*,wchar_t*,unsigned int);
125                typedef NSCAPI::errorReturn (*lpNSAPIGetSettingsInt)(const wchar_t*, const wchar_t*, int);
126                typedef NSCAPI::errorReturn (*lpNSAPIGetSettingsBool)(const wchar_t*, const wchar_t*, int);
127                typedef NSCAPI::errorReturn (*lpNSAPIGetSettingsSection)(const wchar_t*, wchar_t***, unsigned int *);
128                typedef NSCAPI::errorReturn (*lpNSAPIReleaseSettingsSectionBuffer)(wchar_t***, unsigned int *);
129                typedef void (*lpNSAPIMessage)(int, const wchar_t*, const int, const wchar_t*);
130                typedef NSCAPI::errorReturn (*lpNSAPIStopServer)(void);
131                typedef NSCAPI::errorReturn (*lpNSAPIExit)(void);
132                typedef NSCAPI::nagiosReturn (*lpNSAPIInject)(const wchar_t*, const char *, const unsigned int, char **, unsigned int *);
133                typedef void (*lpNSAPIDestroyBuffer)(char**);
134
135                typedef NSCAPI::errorReturn (*lpNSAPINotify)(const wchar_t*, const wchar_t*, NSCAPI::nagiosReturn, const char*, unsigned int);
136
137                typedef NSCAPI::boolReturn (*lpNSAPICheckLogMessages)(int);
138                typedef NSCAPI::errorReturn (*lpNSAPIEncrypt)(unsigned int, const wchar_t*, unsigned int, wchar_t*, unsigned int *);
139                typedef NSCAPI::errorReturn (*lpNSAPIDecrypt)(unsigned int, const wchar_t*, unsigned int, wchar_t*, unsigned int *);
140                typedef NSCAPI::errorReturn (*lpNSAPISetSettingsString)(const wchar_t*, const wchar_t*, const wchar_t*);
141                typedef NSCAPI::errorReturn (*lpNSAPISetSettingsInt)(const wchar_t*, const wchar_t*, int);
142                typedef NSCAPI::errorReturn (*lpNSAPIWriteSettings)(int);
143                typedef NSCAPI::errorReturn (*lpNSAPIReadSettings)(int);
144                typedef NSCAPI::errorReturn (*lpNSAPIRehash)(int);
145                typedef NSCAPI::errorReturn (*lpNSAPIDescribeCommand)(const wchar_t*,wchar_t*,unsigned int);
146                typedef NSCAPI::errorReturn (*lpNSAPIGetAllCommandNames)(wchar_t***, unsigned int *);
147                typedef NSCAPI::errorReturn (*lpNSAPIReleaseAllCommandNamessBuffer)(wchar_t***, unsigned int *);
148                typedef NSCAPI::errorReturn (*lpNSAPIRegisterCommand)(unsigned int, const wchar_t*,const wchar_t*);
149                typedef NSCAPI::errorReturn (*lpNSAPISettingsRegKey)(const wchar_t*, const wchar_t*, int, const wchar_t*, const wchar_t*, const wchar_t*, int);
150                typedef NSCAPI::errorReturn (*lpNSAPISettingsRegPath)(const wchar_t*, const wchar_t*, const wchar_t*, int);
151                typedef NSCAPI::errorReturn (*lpNSAPIGetPluginList)(int *len, NSCAPI::plugin_info *list[]);
152                typedef NSCAPI::errorReturn (*lpNSAPIReleasePluginList)(int len, NSCAPI::plugin_info *list[]);
153                typedef NSCAPI::errorReturn (*lpNSAPISettingsSave)(void);
154        }
155
156        namespace plugin_api {
157                typedef int (*lpModuleHelperInit)(unsigned int, ::nscapi::core_api::lpNSAPILoader f);
158                typedef int (*lpLoadModule)(const wchar_t*,int);
159                typedef int (*lpGetName)(wchar_t*,unsigned int);
160                typedef int (*lpGetDescription)(wchar_t*,unsigned int);
161                typedef int (*lpGetVersion)(int*,int*,int*);
162                typedef int (*lpHasCommandHandler)();
163                typedef int (*lpHasMessageHandler)();
164                typedef NSCAPI::nagiosReturn (*lpHandleCommand)(const wchar_t*,const char*,const unsigned int,char**,unsigned int*);
165                typedef int (*lpDeleteBuffer)(char**);
166                typedef int (*lpCommandLineExec)(const unsigned int,wchar_t**);
167                typedef int (*lpHandleMessage)(int,const wchar_t*,const int,const wchar_t*);
168                typedef int (*lpUnLoadModule)();
169                typedef void (*lpShowTray)();
170                typedef void (*lpHideTray)();
171                typedef int (*lpHasNotificationHandler)();
172                typedef int (*lpHandleNotification)(const wchar_t *channel, const wchar_t* command, NSCAPI::nagiosReturn code, char* result, unsigned int result_len);
173        }
174}
Note: See TracBrowser for help on using the repository browser.