source: nscp/include/NSCAPI.h

Last change on this file was f542694, checked in by Michael Medin <michael@…>, 4 days ago

Yet another massive update with mainly internal stuff
The most interesting thing is I guess the new documentation toolkit which is now "working" (not much content yet, but it will come)

  • Property mode set to 100644
File size: 7.8 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 <unicode_char.hpp>
24#include <string>
25//#include <strEx.h>
26
27namespace NSCAPI {
28        /*
29        #ifdef DEBUG
30        typedef enum {
31        returnCRIT = 2,
32        returnOK = 0,
33        returnWARN = 1,
34        returnUNKNOWN = 3,
35        returnInvalidBufferLen = -2,
36        returnIgnored = -1
37        } nagiosReturn;
38        typedef enum {
39        istrue = 1,
40        isfalse = 0
41        } boolReturn;
42        typedef enum {
43        isSuccess = 1,
44        hasFailed = 0,
45        isInvalidBufferLen = -2
46        } errorReturn;
47        typedef enum {
48        key_string = 100,
49        key_integer = 200,
50        key_bool = 300,
51        } settings_type;
52
53        typedef enum {
54        normalStart = 0,
55        dontStart = 1,
56        } moduleLoadMode;
57        #else
58        */
59        const int normalStart = 0;
60        const int dontStart = 1;
61        const int returnOK = 0;
62        const int returnWARN = 1;
63        const int returnCRIT = 2;
64        const int returnUNKNOWN = 3;
65        const int returnInvalidBufferLen = -2;
66        const int returnIgnored = -1;
67        const int istrue = 1;
68        const int isfalse = 0;
69        const int isSuccess = 1;
70        const int hasFailed = 0;
71        const int isInvalidBufferLen = -2;
72        const int key_string = 100;
73        const int key_integer = 200;
74        const int key_bool = 300;
75
76        const int message_processed     = 0x01;
77        const int message_routed        = 0x02;
78        const int message_ignored       = 0x04;
79        const int message_digested      = 0x08;
80        const int message_modified      = 0x10;
81
82        typedef int nagiosReturn;
83        typedef int boolReturn;
84        typedef int errorReturn;
85        typedef int settings_type;
86        typedef int moduleLoadMode;
87        //#endif
88
89        const unsigned int encryption_xor = 1;
90
91        // Settings types
92        const int settings_default = 0;
93        const int settings_registry = 1;
94        const int settings_inifile = 2;
95
96        // Various message Types
97        namespace log_level {
98                typedef int level;
99                const int off = 0;              // Used to disable logging
100                const int critical = 1; // Critical error
101                const int error = 10;   // Error
102                const int warning = 50; // Warning                      <<< Default for command line interface
103                //const int log = 100;  // Log message          <<< Default for service
104                const int info = 150;   // information
105                const int debug = 500;  // Debug messages       <<< Default for test
106                const int trace = 1000; // Trace messages
107                const int ignore = 5000;// Ignored level (used for controlling states)
108        }
109
110        typedef log_level::level messageTypes;          // Message type
111}
112
113namespace nscapi {
114        class nscapi_exception : public std::exception {
115        public:
116                std::string msg;
117                nscapi_exception(std::string msg) : msg(msg) {}
118
119                ~nscapi_exception() throw() {}
120                const char* what() const throw() {
121                        return msg.c_str();
122                }
123        };
124
125        namespace core_api {
126                typedef void* (*lpNSAPILoader)(const char*);
127
128                typedef void (*lpNSAPIDestroyBuffer)(char**);
129
130                typedef NSCAPI::errorReturn (*lpNSAPIGetApplicationName)(char*,unsigned int);
131                typedef NSCAPI::errorReturn (*lpNSAPIGetApplicationVersionStr)(char*,unsigned int);
132                typedef NSCAPI::errorReturn (*lpNSAPIExpandPath)(const char*,char*,unsigned int);
133                typedef NSCAPI::errorReturn (*lpNSAPIReload)(const char* module);
134                typedef NSCAPI::log_level::level (*lpNSAPIGetLoglevel)();
135                typedef NSCAPI::errorReturn (*lpNSAPISettingsQuery)(const char *, const unsigned int, char **, unsigned int *);
136                typedef NSCAPI::errorReturn (*lpNSAPIRegistryQuery)(const char *, const unsigned int, char **, unsigned int *);
137                typedef NSCAPI::errorReturn (*lpNSCAPIJson2Protobuf)(const char *, const unsigned int, char **, unsigned int *);
138                typedef NSCAPI::errorReturn (*lpNSCAPIProtobuf2Json)(const char *, const char *, const unsigned int, char **, unsigned int *);
139
140                typedef void (*lpNSAPIMessage)(const char*, unsigned int);
141                typedef void (*lpNSAPISimpleMessage)(const char*, int, const char*, int, const char*);
142
143                typedef NSCAPI::nagiosReturn (*lpNSAPIInject)(const char *, const unsigned int, char **, unsigned int *);
144                typedef NSCAPI::nagiosReturn (*lpNSAPIExecCommand)(const char* target, const char *request, const unsigned int request_len, char ** response, unsigned int * response_len);
145                typedef NSCAPI::errorReturn (*lpNSAPINotify)(const char* channel, const char* buffer, unsigned int buffer_len, char ** result_buffer, unsigned int *result_buffer_len);
146
147                // TODO: investigate
148                typedef NSCAPI::boolReturn (*lpNSAPICheckLogMessages)(int);
149
150                // TODO: convert and re-add these
151                typedef NSCAPI::errorReturn (*lpNSAPIEncrypt)(unsigned int, const wchar_t*, unsigned int, wchar_t*, unsigned int *);
152                typedef NSCAPI::errorReturn (*lpNSAPIDecrypt)(unsigned int, const wchar_t*, unsigned int, wchar_t*, unsigned int *);
153
154                // TODO: DEprecate these
155                //              typedef NSCAPI::errorReturn (*lpNSAPISettingsSave)(void);
156                //              typedef NSCAPI::errorReturn (*lpNSAPIRegisterSubmissionListener)(unsigned int plugin_id, const wchar_t* channel);
157                //              typedef NSCAPI::errorReturn (*lpNSAPIRegisterRoutingListener)(unsigned int plugin_id, const wchar_t* channel);
158        }
159
160        namespace plugin_api {
161                typedef NSCAPI::errorReturn (*lpGetName)(char*,unsigned int);
162                typedef NSCAPI::errorReturn (*lpGetDescription)(char*,unsigned int);
163                typedef NSCAPI::errorReturn (*lpModuleHelperInit)(unsigned int, ::nscapi::core_api::lpNSAPILoader f);
164                typedef NSCAPI::errorReturn (*lpGetVersion)(int* major, int* minor, int* revision);
165                typedef NSCAPI::errorReturn (*lpDeleteBuffer)(char** buffer);
166
167                typedef NSCAPI::errorReturn (*lpLoadModule)(unsigned int plugin_id, const char* alias, int mode);
168                typedef NSCAPI::errorReturn (*lpUnLoadModule)(unsigned int plugin_id);
169
170                typedef NSCAPI::errorReturn (*lpHasCommandHandler)(unsigned int plugin_id);
171                typedef NSCAPI::errorReturn (*lpHandleCommand)(unsigned int plugin_id, const char* in_buffer, const unsigned int in_buffer_len, char** out_buffer, unsigned int* out_buffer_len);
172
173                typedef NSCAPI::errorReturn (*lpHasMessageHandler)(unsigned int plugin_id);
174                typedef NSCAPI::errorReturn (*lpHandleMessage)(unsigned int plugin_id, const char* buffer, const unsigned int buffer_len);
175
176                typedef NSCAPI::errorReturn (*lpHasNotificationHandler)(unsigned int plugin_id);
177                typedef NSCAPI::errorReturn (*lpHandleNotification)(unsigned int plugin_id, const char *channel, const char* buffer, unsigned int buffer_len, char **result_buffer, unsigned int *result_buffer_len);
178
179                typedef NSCAPI::errorReturn (*lpHasRoutingHandler)(unsigned int plugin_id);
180                typedef NSCAPI::errorReturn (*lpRouteMessage)(unsigned int plugin_id, const char *channel, const char* buffer, unsigned int buffer_len, char **new_channel_buffer, char **new_buffer, unsigned int *new_buffer_len);
181
182                typedef NSCAPI::errorReturn (*lpCommandLineExec)(unsigned int plugin_id, const char* in_buffer ,const unsigned int in_buffer_len, char** out_buffer, unsigned int* out_buffer_len);
183        }
184}
Note: See TracBrowser for help on using the repository browser.