Started work on forced polls
[public/netxms.git] / src / libnxcl / main.cpp
1 /*
2 ** NetXMS - Network Management System
3 ** Client Library
4 ** Copyright (C) 2004 Victor Kirhenshtein
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 Free Software
18 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 **
20 ** $module: main.cpp
21 **
22 **/
23
24 #include "libnxcl.h"
25
26
27 //
28 // Global variables
29 //
30
31 NXC_EVENT_HANDLER g_pEventHandler = NULL;
32 NXC_DEBUG_CALLBACK g_pDebugCallBack = NULL;
33 DWORD g_dwState = STATE_DISCONNECTED;
34
35
36 //
37 // Initialization function
38 //
39
40 BOOL LIBNXCL_EXPORTABLE NXCInitialize(void)
41 {
42 ObjectsInit();
43 InitSyncStuff();
44 return TRUE;
45 }
46
47
48 //
49 // Shutdown function
50 //
51
52 void LIBNXCL_EXPORTABLE NXCShutdown(void)
53 {
54 SyncCleanup();
55 }
56
57
58 //
59 // Get library version
60 //
61
62 DWORD LIBNXCL_EXPORTABLE NXCGetVersion(void)
63 {
64 return (NETXMS_VERSION_MAJOR << 24) | (NETXMS_VERSION_MINOR << 16) | LIBNXCL_VERSION;
65 }
66
67
68 //
69 // Set event handler
70 //
71
72 void LIBNXCL_EXPORTABLE NXCSetEventHandler(NXC_EVENT_HANDLER pHandler)
73 {
74 g_pEventHandler = pHandler;
75 }
76
77
78 //
79 // Set callback for debug messages
80 //
81
82 void LIBNXCL_EXPORTABLE NXCSetDebugCallback(NXC_DEBUG_CALLBACK pFunc)
83 {
84 g_pDebugCallBack = pFunc;
85 }
86
87
88 //
89 // Ge text for error
90 //
91
92 const char LIBNXCL_EXPORTABLE *NXCGetErrorText(DWORD dwError)
93 {
94 static char *pszErrorText[] =
95 {
96 "Request completed successfully",
97 "Component locked",
98 "Access denied",
99 "Invalid request",
100 "Request timed out",
101 "Request is out of state",
102 "Database failure",
103 "Invalid object ID",
104 "Object already exist",
105 "Communication failure",
106 "System failure",
107 "Invalid user ID",
108 "Invalid argument",
109 "Duplicate DCI",
110 "Invalid DCI ID",
111 "Out of memory",
112 "Input/Output error",
113 "Incompatible operation",
114 "Object creation failed",
115 "Loop in object relationship detected",
116 "Invalid object name",
117 "Invalid alarm ID",
118 "Invalid action ID",
119 "Operation in progress"
120 };
121 return ((dwError >= 0) && (dwError <= RCC_OPERATION_IN_PROGRESS)) ? pszErrorText[dwError] : "Unknown error code";
122 }
123
124
125 //
126 // DLL entry point
127 //
128
129 #ifdef _WIN32
130
131 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
132 {
133 return TRUE;
134 }
135
136 #endif /* _WIN32 */