added StringMap::findElement
[public/netxms.git] / include / nms_util.h
CommitLineData
cc022855 1/*
7ac71e60 2** NetXMS - Network Management System
b0608204 3** Copyright (C) 2003-2013 Victor Kirhenshtein
e9246d26
VK
4**
5** This program is free software; you can redistribute it and/or modify
68f384ea
VK
6** it under the terms of the GNU Lesser General Public License as published
7** by the Free Software Foundation; either version 3 of the License, or
e9246d26
VK
8** (at your option) any later version.
9**
10** This program is distributed in the hope that it will be useful,
11** but WITHOUT ANY WARRANTY; without even the implied warranty of
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13** GNU General Public License for more details.
14**
68f384ea 15** You should have received a copy of the GNU Lesser General Public License
e9246d26
VK
16** along with this program; if not, write to the Free Software
17** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18**
fb7ce4b9 19** File: nms_util.h
e9246d26
VK
20**
21**/
22
23#ifndef _nms_util_h_
24#define _nms_util_h_
25
64584976
VK
26#ifdef _WIN32
27#ifdef LIBNETXMS_EXPORTS
28#define LIBNETXMS_EXPORTABLE __declspec(dllexport)
29#else
30#define LIBNETXMS_EXPORTABLE __declspec(dllimport)
31#endif
32#else /* _WIN32 */
33#define LIBNETXMS_EXPORTABLE
34#endif
35
36
e9246d26
VK
37#include <nms_common.h>
38#include <nms_cscp.h>
953dfe76 39#include <nms_threads.h>
64584976 40#include <time.h>
e9246d26 41
6d8aee95
VK
42#if HAVE_BYTESWAP_H
43#include <byteswap.h>
44#endif
45
92502d5f
VK
46#include <base64.h>
47
6d8aee95
VK
48
49//
92502d5f 50// Serial communications
6d8aee95
VK
51//
52
53#ifdef _WIN32
54
55#define FLOW_NONE 0
56#define FLOW_SOFTWARE 1
57#define FLOW_HARDWARE 2
58
59#else /* _WIN32 */
60
70fed300
AK
61#ifdef HAVE_TERMIOS_H
62# include <termios.h>
63#else
64# error termios.h not found
65#endif
66
6d8aee95
VK
67#endif /* _WIN32 */
68
e2e66145
VK
69/**
70 * Return codes for IcmpPing()
71 */
66c04cc7
VK
72#define ICMP_SUCCESS 0
73#define ICMP_UNREACHEABLE 1
74#define ICMP_TIMEOUT 2
75#define ICMP_RAW_SOCK_FAILED 3
5418d4bb 76#define ICMP_API_ERROR 4
66c04cc7 77
e2e66145
VK
78/**
79 * Token types for configuration loader
80 */
4826c8a5
VK
81#define CT_LONG 0
82#define CT_STRING 1
83#define CT_STRING_LIST 2
84#define CT_END_OF_LIST 3
85#define CT_BOOLEAN 4
86#define CT_WORD 5
fc935a60 87#define CT_IGNORE 6
dda7c270 88#define CT_MB_STRING 7
4826c8a5 89
605fc935 90/**
e2e66145
VK
91 * Uninitialized value for override indicator
92 */
93#define NXCONFIG_UNINITIALIZED_VALUE (-1)
94
95/**
605fc935
VK
96 * Return codes for NxLoadConfig()
97 */
4826c8a5
VK
98#define NXCFG_ERR_OK 0
99#define NXCFG_ERR_NOFILE 1
100#define NXCFG_ERR_SYNTAX 2
101
605fc935
VK
102/**
103 * nxlog_open() flags
104 */
967893bb
VK
105#define NXLOG_USE_SYSLOG ((UINT32)0x00000001)
106#define NXLOG_PRINT_TO_STDOUT ((UINT32)0x00000002)
107#define NXLOG_IS_OPEN ((UINT32)0x80000000)
9f2902ac 108
605fc935
VK
109/**
110 * nxlog rotation policy
111 */
5945d50a
VK
112#define NXLOG_ROTATION_DISABLED 0
113#define NXLOG_ROTATION_DAILY 1
114#define NXLOG_ROTATION_BY_SIZE 2
115
605fc935
VK
116/**
117 * _tcsdup() replacement
118 */
8ff13508
VK
119#if defined(_WIN32) && defined(USE_WIN32_HEAP)
120#ifdef __cplusplus
121extern "C" {
122#endif
fd72502a 123char LIBNETXMS_EXPORTABLE *nx_strdup(const char *src);
8ff13508
VK
124WCHAR LIBNETXMS_EXPORTABLE *nx_wcsdup(const WCHAR *src);
125#ifdef __cplusplus
126}
127#endif
128#endif
129
605fc935 130/**
f4d2c9ba
VK
131 * Custom wcsdup
132 */
133#if !HAVE_WCSDUP && !defined(_WIN32)
fd72502a 134
f4d2c9ba
VK
135#ifdef __cplusplus
136extern "C" {
137#endif
138 WCHAR LIBNETXMS_EXPORTABLE *wcsdup(const WCHAR *src);
139#ifdef __cplusplus
140}
141#endif
fd72502a
VK
142
143#elif defined(_AIX)
144
145// Some AIX versions have broken wcsdup() so we use internal implementation
146#ifdef __cplusplus
147extern "C" {
148#endif
149 WCHAR LIBNETXMS_EXPORTABLE *nx_wcsdup(const WCHAR *src);
150#ifdef __cplusplus
151}
152#endif
153
154#define wcsdup nx_wcsdup
155
f4d2c9ba
VK
156#endif
157
c012b7b7
VK
158#ifdef __cplusplus
159
f4d2c9ba 160/**
c83f6449
VK
161 * Extended tcsdup: returns NULL if NULL pointer passed
162 */
163inline TCHAR *_tcsdup_ex(const TCHAR *s)
164{
165 return (s != NULL) ? _tcsdup(s) : NULL;
166}
167
c012b7b7
VK
168#endif
169
c83f6449 170/**
605fc935
VK
171 * Class for serial communications
172 */
b160350d
VK
173#ifdef __cplusplus
174
175#ifndef _WIN32
176enum
177{
178 NOPARITY,
179 ODDPARITY,
180 EVENPARITY,
181 ONESTOPBIT,
182 TWOSTOPBITS
183};
184
70fed300
AK
185enum
186{
187 FLOW_NONE,
188 FLOW_HARDWARE,
189 FLOW_SOFTWARE
190};
191
b160350d
VK
192#ifndef INVALID_HANDLE_VALUE
193#define INVALID_HANDLE_VALUE (-1)
194#endif
195#endif /* _WIN32 */
196
197class LIBNETXMS_EXPORTABLE Serial
198{
b160350d
VK
199private:
200 TCHAR *m_pszPort;
201 int m_nTimeout;
202 int m_nSpeed;
203 int m_nDataBits;
204 int m_nStopBits;
205 int m_nParity;
70fed300 206 int m_nFlowControl;
b160350d
VK
207
208#ifndef _WIN32
209 int m_hPort;
70fed300 210 struct termios m_originalSettings;
b160350d
VK
211#else
212 HANDLE m_hPort;
213#endif
b160350d 214
826fcc1f
VK
215public:
216 Serial();
217 ~Serial();
218
219 bool open(const TCHAR *pszPort);
220 void close();
221 void setTimeout(int nTimeout);
222 int read(char *pBuff, int nSize); /* waits up to timeout and do single read */
223 int readAll(char *pBuff, int nSize); /* read until timeout or out of space */
c3f71625 224 int readToMark(char *buff, int size, const char **marks, char **occurence);
826fcc1f
VK
225 bool write(const char *pBuff, int nSize);
226 void flush();
227 bool set(int nSpeed, int nDataBits, int nParity, int nStopBits, int nFlowControl = FLOW_NONE);
228 bool restart();
229};
ff214673 230
3fe40613
VK
231/**
232 * Dynamic string class
233 */
8bad8476
VK
234class LIBNETXMS_EXPORTABLE String
235{
236protected:
237 TCHAR *m_pszBuffer;
967893bb 238 UINT32 m_dwBufSize;
8bad8476
VK
239
240public:
c577e360
VK
241 static const int npos;
242
8bad8476 243 String();
f3cdd1c5 244 String(const TCHAR *init);
643c9dcb 245 String(const String &src);
8bad8476
VK
246 ~String();
247
7618e362 248 TCHAR *getBuffer() { return m_pszBuffer; }
ce7565e7 249 void setBuffer(TCHAR *pszBuffer);
8bad8476 250
2391d4fd 251 const String& operator =(const TCHAR *pszStr);
49bf9d8d 252 const String& operator =(const String &src);
1d34c533
VK
253 const String& operator +=(const TCHAR *str);
254 const String& operator +=(const String &str);
ce7565e7 255 operator const TCHAR*() { return CHECK_NULL_EX(m_pszBuffer); }
8bad8476 256
08b214c6
VK
257 char *getUTF8String();
258
967893bb 259 void addString(const TCHAR *pStr, UINT32 dwLen);
ce7565e7 260 void addDynamicString(TCHAR *pszStr) { if (pszStr != NULL) { *this += pszStr; free(pszStr); } }
c577e360 261
e0471fad
VK
262 void addMultiByteString(const char *pStr, UINT32 size, int nCodePage);
263 void addWideCharString(const WCHAR *pStr, UINT32 size);
ff175e91 264
ce7565e7 265 void addFormattedString(const TCHAR *format, ...);
893dfdd7 266 void addFormattedStringV(const TCHAR *format, va_list args);
c577e360 267
967893bb 268 UINT32 getSize() { return m_dwBufSize > 0 ? m_dwBufSize - 1 : 0; }
ce7565e7 269 BOOL isEmpty() { return m_dwBufSize <= 1; }
c577e360 270
ce7565e7
VK
271 TCHAR *subStr(int nStart, int nLen, TCHAR *pszBuffer);
272 TCHAR *subStr(int nStart, int nLen) { return subStr(nStart, nLen, NULL); }
273 int find(const TCHAR *pszStr, int nStart = 0);
1e1450ef 274
6bcafa2d
VK
275 void escapeCharacter(int ch, int esc);
276 void replace(const TCHAR *pszSrc, const TCHAR *pszDst);
0bbab9d3
VK
277 void trim();
278 void shrink(int chars = 1);
c577e360
VK
279};
280
3fe40613 281/**
400e55c4
VK
282 * Entry of string map
283 */
284struct StringMapEntry;
285
286/**
3fe40613
VK
287 * String maps base class
288 */
289class LIBNETXMS_EXPORTABLE StringMapBase
c577e360
VK
290{
291protected:
a6312bd6 292 int m_size;
400e55c4 293 StringMapEntry *m_data;
3fe40613 294 bool m_objectOwner;
55bdca5a 295 bool m_ignoreCase;
3fe40613 296 void (*m_objectDestructor)(void *);
c577e360 297
400e55c4 298 StringMapEntry *find(const TCHAR *key);
3fe40613
VK
299 void setObject(TCHAR *key, void *value, bool keyPreAlloc);
300 void *getObject(const TCHAR *key);
301 void destroyObject(void *object) { if (object != NULL) m_objectDestructor(object); }
c577e360
VK
302
303public:
3fe40613
VK
304 StringMapBase(bool objectOwner);
305 virtual ~StringMapBase();
306
55bdca5a
VK
307 void setOwner(bool owner) { m_objectOwner = owner; }
308 void setIgnoreCase(bool ignore) { m_ignoreCase = ignore; }
309
3fe40613
VK
310 void remove(const TCHAR *key);
311 void clear();
312
a6312bd6 313 int size() { return m_size; }
400e55c4
VK
314 bool contains(const TCHAR *key) { return find(key) != NULL; }
315
316 bool forEach(bool (*cb)(const TCHAR *, const void *, void *), void *userData);
beab0421 317 const void *findElement(bool (*comparator)(const TCHAR *, const void *, void *), void *userData);
3fe40613
VK
318};
319
320/**
400e55c4
VK
321 * NXCP message class
322 */
323class CSCPMessage;
324
325/**
3fe40613
VK
326 * String map class
327 */
328class LIBNETXMS_EXPORTABLE StringMap : public StringMapBase
329{
330public:
331 StringMap() : StringMapBase(true) { }
fb986055 332 StringMap(const StringMap &src);
3fe40613 333 virtual ~StringMap();
c577e360 334
fb986055 335 StringMap& operator =(const StringMap &src);
40b7416c 336
3fe40613
VK
337 void set(const TCHAR *key, const TCHAR *value) { setObject((TCHAR *)key, _tcsdup(value), false); }
338 void setPreallocated(TCHAR *key, TCHAR *value) { setObject(key, value, true); }
967893bb 339 void set(const TCHAR *key, UINT32 value);
5ad2167d 340
a6312bd6
VK
341 void addAll(StringMap *src);
342
3fe40613 343 const TCHAR *get(const TCHAR *key) { return (const TCHAR *)getObject(key); }
967893bb 344 UINT32 getULong(const TCHAR *key, UINT32 defaultValue);
6acb8479 345 bool getBoolean(const TCHAR *key, bool defaultValue);
5ad2167d 346
400e55c4 347 void fillMessage(CSCPMessage *msg, UINT32 sizeFieldId, UINT32 baseFieldId);
8bad8476
VK
348};
349
3fe40613
VK
350/**
351 * String map template for holding objects as values
352 */
353template <class T> class StringObjectMap : public StringMapBase
354{
355private:
356 static void destructor(void *object) { delete (T*)object; }
6173bea8 357
3fe40613
VK
358public:
359 StringObjectMap(bool objectOwner) : StringMapBase(objectOwner) { m_objectDestructor = destructor; }
360
361 void set(const TCHAR *key, T *object) { setObject((TCHAR *)key, (void *)object, false); }
362 T *get(const TCHAR *key) { return (T*)getObject(key); }
3fe40613 363};
6173bea8 364
3fe40613
VK
365/**
366 * String list class
367 */
6173bea8
VK
368class LIBNETXMS_EXPORTABLE StringList
369{
370private:
371 int m_count;
372 int m_allocated;
373 TCHAR **m_values;
374
375public:
376 StringList();
86c126f5 377 StringList(StringList *src);
22ee6d97 378 StringList(const TCHAR *src, const TCHAR *separator);
6173bea8
VK
379 ~StringList();
380
381 void add(const TCHAR *value);
382 void addPreallocated(TCHAR *value);
967893bb
VK
383 void add(INT32 value);
384 void add(UINT32 value);
6173bea8 385 void add(INT64 value);
967893bb 386 void add(UINT64 value);
6173bea8 387 void add(double value);
24dc5346 388 void replace(int index, const TCHAR *value);
6173bea8 389 void clear();
a6312bd6
VK
390 int size() { return m_count; }
391 const TCHAR *get(int index) { return ((index >=0) && (index < m_count)) ? m_values[index] : NULL; }
392 int indexOf(const TCHAR *value);
393 int indexOfIgnoreCase(const TCHAR *value);
d51f2182 394 void remove(int index);
86c126f5 395 void addAll(const StringList *src);
93dbc1be 396 void merge(const StringList *src, bool matchCase);
7d25a5c5 397 TCHAR *join(const TCHAR *separator);
22ee6d97 398 void splitAndAdd(const TCHAR *src, const TCHAR *separator);
6173bea8
VK
399};
400
3fe40613 401/**
a58501c0
VK
402 * Entry of string set
403 */
404struct StringSetEntry;
405
406/**
f3603b79
VK
407 * NXCP message
408 */
409class CSCPMessage;
410
411/**
a58501c0
VK
412 * String set class
413 */
414class LIBNETXMS_EXPORTABLE StringSet
415{
416private:
417 StringSetEntry *m_data;
418
419public:
420 StringSet();
421 ~StringSet();
422
423 void add(const TCHAR *str);
f3603b79 424 void addPreallocated(TCHAR *str);
a58501c0
VK
425 void remove(const TCHAR *str);
426 void clear();
427
428 int size();
f3603b79 429 bool contains(const TCHAR *str);
5b521bfc 430 bool equals(StringSet *s);
a58501c0 431
fa493140 432 void addAll(StringSet *src);
f3603b79 433 void addAll(TCHAR **strings, int count);
d6c4cdc1 434 void addAllPreallocated(TCHAR **strings, int count);
a58501c0 435 void forEach(bool (*cb)(const TCHAR *, void *), void *userData);
f3603b79
VK
436
437 void fillMessage(CSCPMessage *msg, UINT32 baseId, UINT32 countId);
c262bc08
VK
438 void addAllFromMessage(CSCPMessage *msg, UINT32 baseId, UINT32 countId, bool clearBeforeAdd, bool toUppercase);
439
440 String getAll(const TCHAR *separator);
a58501c0
VK
441};
442
443/**
3fe40613
VK
444 * Dynamic array class
445 */
0d75ea88
VK
446class LIBNETXMS_EXPORTABLE Array
447{
448private:
449 int m_size;
450 int m_allocated;
451 int m_grow;
ac5b1642 452 size_t m_elementSize;
0d75ea88
VK
453 void **m_data;
454 bool m_objectOwner;
455
16d6f798 456 void internalRemove(int index, bool allowDestruction);
cfa7c21f 457 void destroyObject(void *object) { if (object != NULL) m_objectDestructor(object); }
16d6f798 458
0d75ea88 459protected:
1c6d61ca 460 bool m_storePointers;
cfa7c21f 461 void (*m_objectDestructor)(void *);
0d75ea88 462
ac5b1642 463 Array(void *data, int initial, int grow, size_t elementSize);
9a68ca24 464 void *__getBuffer() { return m_data; }
8da70db3 465
0d75ea88
VK
466public:
467 Array(int initial = 0, int grow = 16, bool owner = false);
468 virtual ~Array();
469
8da70db3 470 int add(void *element);
1c6d61ca 471 void *get(int index) { return ((index >= 0) && (index < m_size)) ? (m_storePointers ? m_data[index] : (void *)((char *)m_data + index * m_elementSize)): NULL; }
8da70db3
VK
472 int indexOf(void *element);
473 void set(int index, void *element);
474 void replace(int index, void *element);
16d6f798 475 void remove(int index) { internalRemove(index, true); }
8da70db3 476 void remove(void *element) { internalRemove(indexOf(element), true); }
16d6f798 477 void unlink(int index) { internalRemove(index, false); }
8da70db3 478 void unlink(void *element) { internalRemove(indexOf(element), false); }
0d75ea88 479 void clear();
8b7ae7eb 480 void sort(int (*cb)(const void *, const void *));
f33ff5cb 481 void *find(const void *key, int (*cb)(const void *, const void *));
0d75ea88
VK
482
483 int size() { return m_size; }
484
485 void setOwner(bool owner) { m_objectOwner = owner; }
486 bool isOwner() { return m_objectOwner; }
487};
488
3fe40613
VK
489/**
490 * Template class for dynamic array which holds objects
491 */
0d75ea88
VK
492template <class T> class ObjectArray : public Array
493{
cfa7c21f
VK
494private:
495 static void destructor(void *object) { delete (T*)object; }
0d75ea88
VK
496
497public:
cfa7c21f 498 ObjectArray(int initial = 0, int grow = 16, bool owner = false) : Array(initial, grow, owner) { m_objectDestructor = destructor; }
0d75ea88
VK
499 virtual ~ObjectArray() { }
500
47a89886 501 int add(T *object) { return Array::add((void *)object); }
0d75ea88 502 T *get(int index) { return (T*)Array::get(index); }
74d4ba34 503 int indexOf(T *object) { return Array::indexOf((void *)object); }
47a89886
VK
504 void set(int index, T *object) { Array::set(index, (void *)object); }
505 void replace(int index, T *object) { Array::replace(index, (void *)object); }
74d4ba34
VK
506 void remove(int index) { Array::remove(index); }
507 void remove(T *object) { Array::remove((void *)object); }
508 void unlink(int index) { Array::unlink(index); }
509 void unlink(T *object) { Array::unlink((void *)object); }
0d75ea88
VK
510};
511
25fe6265 512/**
e8e76b4f
VK
513 * Template class for dynamic array which holds scalar values
514 */
515template <class T> class IntegerArray : public Array
516{
517private:
8da70db3 518 static void destructor(void *element) { }
e8e76b4f
VK
519
520public:
1c6d61ca 521 IntegerArray(int initial = 0, int grow = 16) : Array(NULL, initial, grow, sizeof(T)) { m_objectDestructor = destructor; m_storePointers = (sizeof(T) == sizeof(void *)); }
e8e76b4f
VK
522 virtual ~IntegerArray() { }
523
1c6d61ca
VK
524 int add(T value) { return Array::add(m_storePointers ? CAST_TO_POINTER(value, void *) : &value); }
525 T get(int index) { return m_storePointers ? CAST_FROM_POINTER(Array::get(index), T) : *((T*)Array::get(index)); }
526 int indexOf(T value) { return Array::indexOf(m_storePointers ? CAST_TO_POINTER(value, void *) : &value); }
527 void set(int index, T value) { Array::set(index, m_storePointers ? CAST_TO_POINTER(value, void *) : &value); }
528 void replace(int index, T value) { Array::replace(index, m_storePointers ? CAST_TO_POINTER(value, void *) : &value); }
9a68ca24
VK
529
530 T *getBuffer() { return (T*)__getBuffer(); }
e8e76b4f
VK
531};
532
533/**
25fe6265
VK
534 * Auxilliary class to hold dynamically allocated array of structures
535 */
8da70db3 536template <class T> class StructArray : public Array
cc8ce218
VK
537{
538private:
8da70db3 539 static void destructor(void *element) { }
cc8ce218
VK
540
541public:
8da70db3
VK
542 StructArray(int initial = 0, int grow = 16) : Array(NULL, initial, grow, sizeof(T)) { m_objectDestructor = destructor; }
543 StructArray(T *data, int size) : Array(data, size, 16, sizeof(T)) { m_objectDestructor = destructor; }
544 virtual ~StructArray() { }
0105c251 545
8da70db3
VK
546 int add(T *element) { return Array::add((void *)element); }
547 T *get(int index) { return (T*)Array::get(index); }
548 int indexOf(T *element) { return Array::indexOf((void *)element); }
549 void set(int index, T *element) { Array::set(index, (void *)element); }
550 void replace(int index, T *element) { Array::replace(index, (void *)element); }
551 void remove(int index) { Array::remove(index); }
552 void remove(T *element) { Array::remove((void *)element); }
553 void unlink(int index) { Array::unlink(index); }
554 void unlink(T *element) { Array::unlink((void *)element); }
4c5495d9
VK
555
556 T *getBuffer() { return (T*)__getBuffer(); }
cc8ce218
VK
557};
558
25fe6265
VK
559/**
560 * Auxilliary class for objects which counts references and
561 * destroys itself wheren reference count falls to 0
562 */
7f632dfe
VK
563class LIBNETXMS_EXPORTABLE RefCountObject
564{
565private:
7785322f 566 VolatileCounter m_refCount;
7f632dfe
VK
567
568public:
7785322f
VK
569 RefCountObject()
570 {
571 m_refCount = 1;
572 }
b549a0f8 573 virtual ~RefCountObject();
7785322f
VK
574
575 void incRefCount()
576 {
577 InterlockedIncrement(&m_refCount);
578 }
579
580 void decRefCount()
581 {
582 if (InterlockedDecrement(&m_refCount) == 0)
583 delete this;
584 }
7f632dfe
VK
585};
586
967893bb
VK
587class CSCPMessage;
588
589/**
590 * Table column definition
591 */
592class LIBNETXMS_EXPORTABLE TableColumnDefinition
593{
594private:
595 TCHAR *m_name;
596 TCHAR *m_displayName;
597 INT32 m_dataType;
598 bool m_instanceColumn;
599
600public:
601 TableColumnDefinition(const TCHAR *name, const TCHAR *displayName, INT32 dataType, bool isInstance);
602 TableColumnDefinition(CSCPMessage *msg, UINT32 baseId);
603 TableColumnDefinition(TableColumnDefinition *src);
604 ~TableColumnDefinition();
605
606 void fillMessage(CSCPMessage *msg, UINT32 baseId);
607
608 const TCHAR *getName() { return m_name; }
609 const TCHAR *getDisplayName() { return m_displayName; }
610 INT32 getDataType() { return m_dataType; }
611 bool isInstanceColumn() { return m_instanceColumn; }
612
613 void setDataType(INT32 type) { m_dataType = type; }
614 void setInstanceColumn(bool isInstance) { m_instanceColumn = isInstance; }
a0ddfb29 615 void setDisplayName(const TCHAR *name) { safe_free(m_displayName); m_displayName = _tcsdup(CHECK_NULL_EX(name)); }
967893bb
VK
616};
617
618/**
d6bbfa4e
VK
619 * Table cell
620 */
621class TableCell
622{
623private:
624 TCHAR *m_value;
625 int m_status;
626
627public:
628 TableCell() { m_value = NULL; m_status = -1; }
c83f6449
VK
629 TableCell(const TCHAR *value) { m_value = _tcsdup_ex(value); m_status = -1; }
630 TableCell(const TCHAR *value, int status) { m_value = _tcsdup_ex(value); m_status = status; }
631 TableCell(TableCell *src) { m_value = _tcsdup_ex(src->m_value); m_status = src->m_status; }
d6bbfa4e
VK
632 ~TableCell() { safe_free(m_value); }
633
c83f6449 634 void set(const TCHAR *value, int status) { safe_free(m_value); m_value = _tcsdup_ex(value); m_status = status; }
d6bbfa4e
VK
635 void setPreallocated(TCHAR *value, int status) { safe_free(m_value); m_value = value; m_status = status; }
636
637 const TCHAR *getValue() { return m_value; }
c83f6449 638 void setValue(const TCHAR *value) { safe_free(m_value); m_value = _tcsdup_ex(value); }
d6bbfa4e
VK
639 void setPreallocatedValue(TCHAR *value) { safe_free(m_value); m_value = value; }
640
641 int getStatus() { return m_status; }
642 void setStatus(int status) { m_status = status; }
643};
644
645/**
646 * Table row
647 */
648class TableRow
649{
650private:
651 ObjectArray<TableCell> *m_cells;
652 UINT32 m_objectId;
bac74bf7 653
d6bbfa4e
VK
654public:
655 TableRow(int columnCount);
656 TableRow(TableRow *src);
657 ~TableRow() { delete m_cells; }
658
659 void addColumn() { m_cells->add(new TableCell); }
660 void deleteColumn(int index) { m_cells->remove(index); }
bac74bf7 661
d6bbfa4e
VK
662 void set(int index, const TCHAR *value, int status) { TableCell *c = m_cells->get(index); if (c != NULL) c->set(value, status); }
663 void setPreallocated(int index, TCHAR *value, int status) { TableCell *c = m_cells->get(index); if (c != NULL) c->setPreallocated(value, status); }
664
665 void setValue(int index, const TCHAR *value) { TableCell *c = m_cells->get(index); if (c != NULL) c->setValue(value); }
666 void setPreallocatedValue(int index, TCHAR *value) { TableCell *c = m_cells->get(index); if (c != NULL) c->setPreallocatedValue(value); }
667
668 void setStatus(int index, int status) { TableCell *c = m_cells->get(index); if (c != NULL) c->setStatus(status); }
669
670 const TCHAR *getValue(int index) { TableCell *c = m_cells->get(index); return (c != NULL) ? c->getValue() : NULL; }
671 int getStatus(int index) { TableCell *c = m_cells->get(index); return (c != NULL) ? c->getStatus() : -1; }
672
673 UINT32 getObjectId() { return m_objectId; }
674 void setObjectId(UINT32 id) { m_objectId = id; }
675};
676
677/**
967893bb
VK
678 * Class for table data storage
679 */
a0ddfb29 680class LIBNETXMS_EXPORTABLE Table : public RefCountObject
967893bb
VK
681{
682private:
d6bbfa4e 683 ObjectArray<TableRow> *m_data;
967893bb
VK
684 ObjectArray<TableColumnDefinition> *m_columns;
685 TCHAR *m_title;
686 int m_source;
d6bbfa4e 687 bool m_extendedFormat;
967893bb
VK
688
689 void createFromMessage(CSCPMessage *msg);
690 void destroy();
691
692public:
693 Table();
a0ddfb29 694 Table(Table *src);
967893bb 695 Table(CSCPMessage *msg);
b549a0f8 696 virtual ~Table();
967893bb
VK
697
698 int fillMessage(CSCPMessage &msg, int offset, int rowLimit);
699 void updateFromMessage(CSCPMessage *msg);
700
a0ddfb29
VK
701 void addAll(Table *src);
702 void copyRow(Table *src, int row);
967893bb 703
d6bbfa4e
VK
704 int getNumRows() { return m_data->size(); }
705 int getNumColumns() { return m_columns->size(); }
967893bb
VK
706 const TCHAR *getTitle() { return CHECK_NULL_EX(m_title); }
707 int getSource() { return m_source; }
708
d6bbfa4e
VK
709 bool isExtendedFormat() { return m_extendedFormat; }
710 void setExtendedFormat(bool ext) { m_extendedFormat = ext; }
711
967893bb
VK
712 const TCHAR *getColumnName(int col) { return ((col >= 0) && (col < m_columns->size())) ? m_columns->get(col)->getName() : NULL; }
713 INT32 getColumnDataType(int col) { return ((col >= 0) && (col < m_columns->size())) ? m_columns->get(col)->getDataType() : 0; }
714 int getColumnIndex(const TCHAR *name);
715 ObjectArray<TableColumnDefinition> *getColumnDefinitions() { return m_columns; }
716
c83f6449 717 void setTitle(const TCHAR *title) { safe_free(m_title); m_title = _tcsdup_ex(title); }
967893bb 718 void setSource(int source) { m_source = source; }
8dba1eac 719 int addColumn(const TCHAR *name, INT32 dataType = 0, const TCHAR *displayName = NULL, bool isInstance = false);
967893bb
VK
720 void setColumnDataType(int col, INT32 dataType) { if ((col >= 0) && (col < m_columns->size())) m_columns->get(col)->setDataType(dataType); }
721 int addRow();
722
25076d53
VK
723 void deleteRow(int row);
724 void deleteColumn(int col);
725
967893bb
VK
726 void setAt(int nRow, int nCol, INT32 nData);
727 void setAt(int nRow, int nCol, UINT32 dwData);
728 void setAt(int nRow, int nCol, double dData);
729 void setAt(int nRow, int nCol, INT64 nData);
730 void setAt(int nRow, int nCol, UINT64 qwData);
731 void setAt(int nRow, int nCol, const TCHAR *pszData);
732 void setPreallocatedAt(int nRow, int nCol, TCHAR *pszData);
733
d6bbfa4e
VK
734 void set(int nCol, INT32 nData) { setAt(getNumRows() - 1, nCol, nData); }
735 void set(int nCol, UINT32 dwData) { setAt(getNumRows() - 1, nCol, dwData); }
736 void set(int nCol, double dData) { setAt(getNumRows() - 1, nCol, dData); }
737 void set(int nCol, INT64 nData) { setAt(getNumRows() - 1, nCol, nData); }
738 void set(int nCol, UINT64 qwData) { setAt(getNumRows() - 1, nCol, qwData); }
739 void set(int nCol, const TCHAR *pszData) { setAt(getNumRows() - 1, nCol, pszData); }
740 void setPreallocated(int nCol, TCHAR *pszData) { setPreallocatedAt(getNumRows() - 1, nCol, pszData); }
741
742 void setStatusAt(int row, int col, int status);
743 void setStatus(int col, int status) { setStatusAt(getNumRows() - 1, col, status); }
967893bb
VK
744
745 const TCHAR *getAsString(int nRow, int nCol);
746 INT32 getAsInt(int nRow, int nCol);
747 UINT32 getAsUInt(int nRow, int nCol);
748 INT64 getAsInt64(int nRow, int nCol);
749 UINT64 getAsUInt64(int nRow, int nCol);
750 double getAsDouble(int nRow, int nCol);
22aaa779 751
d6bbfa4e
VK
752 int getStatus(int nRow, int nCol);
753
22aaa779 754 void buildInstanceString(int row, TCHAR *buffer, size_t bufLen);
a0ddfb29 755 int findRowByInstance(const TCHAR *instance);
d6bbfa4e
VK
756
757 UINT32 getObjectId(int row) { TableRow *r = m_data->get(row); return (r != NULL) ? r->getObjectId() : 0; }
758 void setObjectId(int row, UINT32 id) { TableRow *r = m_data->get(row); if (r != NULL) r->setObjectId(id); }
967893bb
VK
759};
760
25fe6265 761/**
9319c166
VK
762 * IP address
763 */
764class LIBNETXMS_EXPORTABLE InetAddress
765{
9319c166 766private:
8c75ad41
VK
767 short m_maskBits;
768 short m_family;
769 union
770 {
771 UINT32 v4;
772 BYTE v6[16];
773 } m_addr;
9319c166
VK
774
775public:
8c75ad41
VK
776 InetAddress();
777 InetAddress(UINT32 addr);
778 InetAddress(BYTE *addr);
9319c166 779
8c75ad41
VK
780 bool isAnyLocal() const;
781 bool isLoopback() const;
782 bool isMulticast() const;
783 bool isBroadcast() const;
784 bool isValid() const { return m_family != AF_UNSPEC; }
9319c166 785
8c75ad41 786 int getFamily() const { return m_family; }
c7853753
VK
787 UINT32 getAddressV4() const { return (m_family == AF_INET) ? m_addr.v4 : 0; }
788 const BYTE *getAddressV6() const { return (m_family == AF_INET6) ? m_addr.v6 : (const BYTE *)"\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"; }
9319c166 789
8c75ad41
VK
790 bool contain(const InetAddress &a) const;
791 bool equals(const InetAddress &a) const;
792 int compareTo(const InetAddress &a) const;
9319c166 793
8c75ad41
VK
794 void setMaskBits(int m) { m_maskBits = m; }
795 int getMaskBits() const { return m_maskBits; }
9319c166 796
8c75ad41
VK
797 String toString() const;
798 TCHAR *toString(TCHAR *buffer) const;
9319c166 799
c7853753
VK
800 static InetAddress resolveHostName(const WCHAR *hostname, int af = AF_INET);
801 static InetAddress resolveHostName(const char *hostname, int af = AF_INET);
8c75ad41 802 static InetAddress createFromSockaddr(struct sockaddr *s);
9319c166
VK
803};
804
805/**
25fe6265
VK
806 * Network connection
807 */
58ee2f43
VK
808class LIBNETXMS_EXPORTABLE SocketConnection
809{
810protected:
811 SOCKET m_socket;
812 char m_data[4096];
813 int m_dataPos;
814
815public:
816 SocketConnection();
817 virtual ~SocketConnection();
818
967893bb
VK
819 bool connectTCP(const TCHAR *hostName, WORD port, UINT32 timeout);
820 bool connectTCP(UINT32 ip, WORD port, UINT32 timeout);
58ee2f43
VK
821 void disconnect();
822
967893bb
VK
823 bool canRead(UINT32 timeout);
824 virtual int read(char *pBuff, int nSize, UINT32 timeout = INFINITE);
58ee2f43 825 bool waitForText(const char *text, int timeout);
cc022855 826
58ee2f43 827 int write(const char *pBuff, int nSize);
1671f85d
VK
828 bool writeLine(const char *line);
829
967893bb 830 static SocketConnection *createTCPConnection(const TCHAR *hostName, WORD port, UINT32 timeout);
58ee2f43
VK
831};
832
030a0779
VK
833/**
834 * Telnet connection - handles all telnet negotiation
835 */
def5b792
AK
836class LIBNETXMS_EXPORTABLE TelnetConnection : public SocketConnection
837{
030a0779 838protected:
967893bb
VK
839 bool connectTCP(const TCHAR *hostName, WORD port, UINT32 timeout);
840 bool connectTCP(UINT32 ip, WORD port, UINT32 timeout);
030a0779 841
def5b792 842public:
967893bb 843 static TelnetConnection *createConnection(const TCHAR *hostName, WORD port, UINT32 timeout);
d4e9d325 844
967893bb
VK
845 bool connect(const TCHAR *hostName, WORD port, UINT32 timeout);
846 bool connect(UINT32 ip, WORD port, UINT32 timeout);
847 virtual int read(char *pBuff, int nSize, UINT32 timeout = INFINITE);
848 int readLine(char *buffer, int size, UINT32 timeout = INFINITE);
def5b792
AK
849};
850
b160350d
VK
851#endif /* __cplusplus */
852
030a0779
VK
853/**
854 * Configuration item template for configuration loader
855 */
4826c8a5
VK
856typedef struct
857{
e2e66145
VK
858 TCHAR token[64];
859 BYTE type;
860 BYTE separator; // Separator character for lists
861 WORD listElements; // Number of list elements, should be set to 0 before calling NxLoadConfig()
862 UINT32 bufferSize; // Buffer size for strings or flag to be set for CT_BOOLEAN
863 UINT32 bufferPos; // Should be set to 0
864 void *buffer;
865 void *overrideIndicator;
4826c8a5 866} NX_CFG_TEMPLATE;
dcb44c9a 867
030a0779
VK
868/**
869 * Code translation structure
870 */
bc858635
VK
871typedef struct __CODE_TO_TEXT
872{
873 int code;
874 const TCHAR *text;
875} CODE_TO_TEXT;
876
e2e66145
VK
877/**
878 * getopt() prototype if needed
879 */
df9812a9 880#if USE_BUNDLED_GETOPT
99e50bb7 881#include <netxms_getopt.h>
3046f9a4
VK
882#endif
883
884
885//
f2fdf1b5
VK
886// Win32 API functions missing under WinCE
887//
888
c32b805a 889#if defined(UNDER_CE) && defined(__cplusplus)
f2fdf1b5
VK
890
891inline void GetSystemTimeAsFileTime(LPFILETIME pFt)
892{
893 SYSTEMTIME sysTime;
cc022855 894
f2fdf1b5
VK
895 GetSystemTime(&sysTime);
896 SystemTimeToFileTime(&sysTime, pFt);
897}
898
899#endif // UNDER_CE
900
901
902//
3d1cb7d6
VK
903// Structures for opendir() / readdir() / closedir()
904//
905
906#ifdef _WIN32
907
7f9e0c00 908typedef struct dirent
3d1cb7d6
VK
909{
910 long d_ino; /* inode number (not used by MS-DOS) */
911 int d_namlen; /* Name length */
912 char d_name[257]; /* file name */
913} _DIRECT;
914
915typedef struct _dir_struc
916{
917 char *start; /* Starting position */
918 char *curr; /* Current position */
919 long size; /* Size of string table */
920 long nfiles; /* number if filenames in table */
7f9e0c00 921 struct dirent dirstr; /* Directory structure to return */
3d1cb7d6
VK
922} DIR;
923
5ea2db30
VK
924#ifdef UNICODE
925
926typedef struct dirent_w
927{
928 long d_ino; /* inode number (not used by MS-DOS) */
929 int d_namlen; /* Name length */
930 WCHAR d_name[257]; /* file name */
931} _DIRECTW;
932
933typedef struct _dir_struc_w
934{
935 WCHAR *start; /* Starting position */
936 WCHAR *curr; /* Current position */
937 long size; /* Size of string table */
938 long nfiles; /* number if filenames in table */
939 struct dirent_w dirstr; /* Directory structure to return */
940} DIRW;
941
942#define _TDIR DIRW
943#define _TDIRECT _DIRECTW
944#define _tdirent dirent_w
945
946#else
947
948#define _TDIR DIR
949#define _TDIRECT _DIRECT
950#define _tdirent dirent
951
37d62364
AK
952#endif
953
76b1d3d8
VK
954#else /* not _WIN32 */
955
956typedef struct dirent_w
957{
958 long d_ino; /* inode number */
959 WCHAR d_name[257]; /* file name */
960} _DIRECTW;
961
962typedef struct _dir_struc_w
963{
964 DIR *dir; /* Original non-unicode structure */
965 struct dirent_w dirstr; /* Directory structure to return */
966} DIRW;
967
3d1cb7d6
VK
968#endif /* _WIN32 */
969
970
971//
e9246d26
VK
972// Functions
973//
974
babb8280 975#if WORDS_BIGENDIAN
43d92b4c
VK
976#define htonq(x) (x)
977#define ntohq(x) (x)
9f20696e
VK
978#define htond(x) (x)
979#define ntohd(x) (x)
babb8280
VK
980#define SwapWideString(x)
981#else
ca6ad6bb
VK
982#ifdef HAVE_HTONLL
983#define htonq(x) htonll(x)
984#else
babb8280 985#define htonq(x) __bswap_64(x)
ca6ad6bb
VK
986#endif
987#ifdef HAVE_NTOHLL
988#define ntohq(x) ntohll(x)
989#else
babb8280 990#define ntohq(x) __bswap_64(x)
ca6ad6bb 991#endif
babb8280
VK
992#define htond(x) __bswap_double(x)
993#define ntohd(x) __bswap_double(x)
994#define SwapWideString(x) __bswap_wstr(x)
43d92b4c 995#endif
15929b31 996
55b33d4c
VK
997#ifdef UNDER_CE
998#define close(x) CloseHandle((HANDLE)(x))
999#endif
1000
b50f1100 1001#ifdef __cplusplus
2e590d1a
VK
1002inline TCHAR *nx_strncpy(TCHAR *pszDest, const TCHAR *pszSrc, size_t nLen)
1003{
912b994d 1004#if defined(_WIN32) && (_MSC_VER >= 1400)
2e590d1a 1005 _tcsncpy_s(pszDest, nLen, pszSrc, _TRUNCATE);
912b994d 1006#else
2e590d1a
VK
1007 _tcsncpy(pszDest, pszSrc, nLen - 1);
1008 pszDest[nLen - 1] = 0;
912b994d 1009#endif
2e590d1a
VK
1010 return pszDest;
1011}
f3387429
VK
1012
1013#ifdef UNICODE
2e590d1a
VK
1014inline char *nx_strncpy_mb(char *pszDest, const char *pszSrc, size_t nLen)
1015{
f3387429 1016#if defined(_WIN32) && (_MSC_VER >= 1400)
2e590d1a 1017 strncpy_s(pszDest, nLen, pszSrc, _TRUNCATE);
f3387429 1018#else
2e590d1a
VK
1019 strncpy(pszDest, pszSrc, nLen - 1);
1020 pszDest[nLen - 1] = 0;
c81979bc 1021#endif
2e590d1a
VK
1022 return pszDest;
1023}
c81979bc 1024#else
f3387429 1025#define nx_strncpy_mb nx_strncpy
7b8b337e
VK
1026#endif
1027
967893bb 1028int LIBNETXMS_EXPORTABLE ConnectEx(SOCKET s, struct sockaddr *addr, int len, UINT32 timeout);
5e60b759
VK
1029int LIBNETXMS_EXPORTABLE SendEx(SOCKET hSocket, const void *data, size_t len, int flags, MUTEX mutex);
1030int LIBNETXMS_EXPORTABLE RecvEx(SOCKET hSocket, void *data, size_t len, int flags, UINT32 timeout);
b0608204 1031#endif /* __cplusplus */
c81979bc
VK
1032
1033#ifdef __cplusplus
e9246d26
VK
1034extern "C"
1035{
b50f1100 1036#endif
735bac5c 1037
c5b523e2 1038#if defined(_WIN32) || !(HAVE_DECL___BSWAP_32)
735bac5c 1039UINT32 LIBNETXMS_EXPORTABLE __bswap_32(UINT32 dwVal);
c5b523e2 1040#endif
f52be742 1041#if defined(_WIN32) || !(HAVE_DECL___BSWAP_64)
735bac5c 1042UINT64 LIBNETXMS_EXPORTABLE __bswap_64(UINT64 qwVal);
64584976 1043#endif
735bac5c
VK
1044double LIBNETXMS_EXPORTABLE __bswap_double(double dVal);
1045void LIBNETXMS_EXPORTABLE __bswap_wstr(UCS2CHAR *pStr);
64584976 1046
076a55c4 1047#if !defined(_WIN32) && !defined(_NETWARE)
8b86c5dc 1048#if defined(UNICODE_UCS2) || defined(UNICODE_UCS4)
735bac5c
VK
1049void LIBNETXMS_EXPORTABLE __wcsupr(WCHAR *in);
1050#define wcsupr __wcsupr
cc022855 1051#endif
735bac5c
VK
1052void LIBNETXMS_EXPORTABLE __strupr(char *in);
1053#define strupr __strupr
7e679c4b 1054#endif
cc022855 1055
735bac5c 1056void LIBNETXMS_EXPORTABLE QSortEx(void *base, size_t nmemb, size_t size, void *arg,
b8a8d064
VK
1057 int (*compare)(const void *, const void *, void *));
1058
735bac5c 1059INT64 LIBNETXMS_EXPORTABLE GetCurrentTimeMs();
d35ed0aa 1060
735bac5c
VK
1061UINT64 LIBNETXMS_EXPORTABLE FileSizeW(const WCHAR *pszFileName);
1062UINT64 LIBNETXMS_EXPORTABLE FileSizeA(const char *pszFileName);
d35ed0aa
VK
1063#ifdef UNICODE
1064#define FileSize FileSizeW
1065#else
1066#define FileSize FileSizeA
1067#endif
670c7f3d 1068
735bac5c
VK
1069int LIBNETXMS_EXPORTABLE BitsInMask(UINT32 dwMask);
1070TCHAR LIBNETXMS_EXPORTABLE *IpToStr(UINT32 dwAddr, TCHAR *szBuffer);
e0f99bf0 1071#ifdef UNICODE
735bac5c 1072char LIBNETXMS_EXPORTABLE *IpToStrA(UINT32 dwAddr, char *szBuffer);
17b35ccc
VK
1073#else
1074#define IpToStrA IpToStr
e0f99bf0 1075#endif
8c75ad41 1076TCHAR LIBNETXMS_EXPORTABLE *Ip6ToStr(const BYTE *addr, TCHAR *buffer);
735bac5c 1077TCHAR LIBNETXMS_EXPORTABLE *SockaddrToStr(struct sockaddr *addr, TCHAR *buffer);
60557d06 1078
735bac5c
VK
1079UINT32 LIBNETXMS_EXPORTABLE ResolveHostNameA(const char *name);
1080UINT32 LIBNETXMS_EXPORTABLE ResolveHostNameW(const WCHAR *name);
08b214c6 1081#ifdef UNICODE
cfe20cce 1082#define ResolveHostName ResolveHostNameW
08b214c6 1083#else
cfe20cce 1084#define ResolveHostName ResolveHostNameA
08b214c6 1085#endif
a1dc75b0 1086
735bac5c
VK
1087void LIBNETXMS_EXPORTABLE *nx_memdup(const void *data, size_t size);
1088void LIBNETXMS_EXPORTABLE nx_memswap(void *block1, void *block2, size_t size);
31521248 1089
735bac5c
VK
1090WCHAR LIBNETXMS_EXPORTABLE *BinToStrW(const BYTE *data, size_t size, WCHAR *pStr);
1091char LIBNETXMS_EXPORTABLE *BinToStrA(const BYTE *data, size_t size, char *pStr);
d7970ee7
VK
1092#ifdef UNICODE
1093#define BinToStr BinToStrW
1094#else
1095#define BinToStr BinToStrA
1096#endif
1097
735bac5c
VK
1098size_t LIBNETXMS_EXPORTABLE StrToBinW(const WCHAR *pStr, BYTE *data, size_t size);
1099size_t LIBNETXMS_EXPORTABLE StrToBinA(const char *pStr, BYTE *data, size_t size);
52db3ed1
VK
1100#ifdef UNICODE
1101#define StrToBin StrToBinW
1102#else
1103#define StrToBin StrToBinA
1104#endif
cc022855 1105
735bac5c 1106TCHAR LIBNETXMS_EXPORTABLE *MACToStr(const BYTE *data, TCHAR *pStr);
b50f1100 1107
735bac5c
VK
1108void LIBNETXMS_EXPORTABLE StrStripA(char *pszStr);
1109void LIBNETXMS_EXPORTABLE StrStripW(WCHAR *pszStr);
b07c50cc
VK
1110#ifdef UNICODE
1111#define StrStrip StrStripW
1112#else
1113#define StrStrip StrStripA
1114#endif
1115
735bac5c
VK
1116const char LIBNETXMS_EXPORTABLE *ExtractWordA(const char *line, char *buffer);
1117const WCHAR LIBNETXMS_EXPORTABLE *ExtractWordW(const WCHAR *line, WCHAR *buffer);
ada97259
VK
1118#ifdef UNICODE
1119#define ExtractWord ExtractWordW
1120#else
1121#define ExtractWord ExtractWordA
1122#endif
1123
735bac5c
VK
1124int LIBNETXMS_EXPORTABLE NumCharsA(const char *pszStr, char ch);
1125int LIBNETXMS_EXPORTABLE NumCharsW(const WCHAR *pszStr, WCHAR ch);
3583a400
VK
1126#ifdef UNICODE
1127#define NumChars NumCharsW
1128#else
1129#define NumChars NumCharsA
1130#endif
ada97259 1131
735bac5c
VK
1132void LIBNETXMS_EXPORTABLE RemoveTrailingCRLFA(char *str);
1133void LIBNETXMS_EXPORTABLE RemoveTrailingCRLFW(WCHAR *str);
35f836fe
VK
1134#ifdef UNICODE
1135#define RemoveTrailingCRLF RemoveTrailingCRLFW
1136#else
1137#define RemoveTrailingCRLF RemoveTrailingCRLFA
1138#endif
1139
4893b4aa
VK
1140BOOL LIBNETXMS_EXPORTABLE RegexpMatchA(const char *str, const char *expr, bool matchCase);
1141BOOL LIBNETXMS_EXPORTABLE RegexpMatchW(const WCHAR *str, const WCHAR *expr, bool matchCase);
cafe592d
VK
1142#ifdef UNICODE
1143#define RegexpMatch RegexpMatchW
1144#else
1145#define RegexpMatch RegexpMatchA
1146#endif
1147
735bac5c
VK
1148const TCHAR LIBNETXMS_EXPORTABLE *ExpandFileName(const TCHAR *name, TCHAR *buffer, size_t bufSize, bool allowShellCommand);
1149void LIBNETXMS_EXPORTABLE Trim(TCHAR *str);
1150bool LIBNETXMS_EXPORTABLE MatchString(const TCHAR *pattern, const TCHAR *str, bool matchCase);
1151TCHAR LIBNETXMS_EXPORTABLE **SplitString(const TCHAR *source, TCHAR sep, int *numStrings);
ada97259 1152
f7794b68 1153#ifdef __cplusplus
735bac5c 1154BOOL LIBNETXMS_EXPORTABLE IsValidObjectName(const TCHAR *pszName, BOOL bExtendedChars = FALSE);
f7794b68 1155#endif
735bac5c
VK
1156BOOL LIBNETXMS_EXPORTABLE IsValidScriptName(const TCHAR *pszName);
1157/* deprecated */ void LIBNETXMS_EXPORTABLE TranslateStr(TCHAR *pszString, const TCHAR *pszSubStr, const TCHAR *pszReplace);
1158const TCHAR LIBNETXMS_EXPORTABLE *GetCleanFileName(const TCHAR *pszFileName);
1159void LIBNETXMS_EXPORTABLE GetOSVersionString(TCHAR *pszBuffer, int nBufSize);
1160BYTE LIBNETXMS_EXPORTABLE *LoadFile(const TCHAR *pszFileName, UINT32 *pdwFileSize);
08b214c6 1161#ifdef UNICODE
735bac5c 1162BYTE LIBNETXMS_EXPORTABLE *LoadFileA(const char *pszFileName, UINT32 *pdwFileSize);
08b214c6
VK
1163#else
1164#define LoadFileA LoadFile
1165#endif
1166
735bac5c
VK
1167UINT32 LIBNETXMS_EXPORTABLE CalculateCRC32(const unsigned char *data, UINT32 size, UINT32 dwCRC);
1168void LIBNETXMS_EXPORTABLE CalculateMD5Hash(const unsigned char *data, size_t nbytes, unsigned char *hash);
1169void LIBNETXMS_EXPORTABLE MD5HashForPattern(const unsigned char *data, size_t patternSize, size_t fullSize, BYTE *hash);
1170void LIBNETXMS_EXPORTABLE CalculateSHA1Hash(unsigned char *data, size_t nbytes, unsigned char *hash);
1171void LIBNETXMS_EXPORTABLE SHA1HashForPattern(unsigned char *data, size_t patternSize, size_t fullSize, unsigned char *hash);
1172BOOL LIBNETXMS_EXPORTABLE CalculateFileMD5Hash(const TCHAR *pszFileName, BYTE *pHash);
1173BOOL LIBNETXMS_EXPORTABLE CalculateFileSHA1Hash(const TCHAR *pszFileName, BYTE *pHash);
1174BOOL LIBNETXMS_EXPORTABLE CalculateFileCRC32(const TCHAR *pszFileName, UINT32 *pResult);
66c04cc7 1175
735bac5c
VK
1176void LIBNETXMS_EXPORTABLE ICEEncryptData(const BYTE *in, int inLen, BYTE *out, const BYTE *key);
1177void LIBNETXMS_EXPORTABLE ICEDecryptData(const BYTE *in, int inLen, BYTE *out, const BYTE *key);
4e2debcc 1178
735bac5c 1179BOOL LIBNETXMS_EXPORTABLE DecryptPassword(const TCHAR *login, const TCHAR *encryptedPasswd, TCHAR *decryptedPasswd);
6b1282e7 1180
735bac5c 1181UINT32 LIBNETXMS_EXPORTABLE IcmpPing(UINT32 dwAddr, int iNumRetries, UINT32 dwTimeout, UINT32 *pdwRTT, UINT32 dwPacketSize);
4826c8a5 1182
735bac5c 1183int LIBNETXMS_EXPORTABLE NxDCIDataTypeFromText(const TCHAR *pszText);
aa13cfd9 1184
735bac5c
VK
1185HMODULE LIBNETXMS_EXPORTABLE DLOpen(const TCHAR *pszLibName, TCHAR *pszErrorText);
1186void LIBNETXMS_EXPORTABLE DLClose(HMODULE hModule);
1187void LIBNETXMS_EXPORTABLE *DLGetSymbolAddr(HMODULE hModule, const char *pszSymbol, TCHAR *pszErrorText);
aa13cfd9 1188
735bac5c
VK
1189bool LIBNETXMS_EXPORTABLE ExtractNamedOptionValueW(const WCHAR *optString, const WCHAR *option, WCHAR *buffer, int bufSize);
1190bool LIBNETXMS_EXPORTABLE ExtractNamedOptionValueAsBoolW(const WCHAR *optString, const WCHAR *option, bool defVal);
1191long LIBNETXMS_EXPORTABLE ExtractNamedOptionValueAsIntW(const WCHAR *optString, const WCHAR *option, long defVal);
289d126b 1192
735bac5c
VK
1193bool LIBNETXMS_EXPORTABLE ExtractNamedOptionValueA(const char *optString, const char *option, char *buffer, int bufSize);
1194bool LIBNETXMS_EXPORTABLE ExtractNamedOptionValueAsBoolA(const char *optString, const char *option, bool defVal);
1195long LIBNETXMS_EXPORTABLE ExtractNamedOptionValueAsIntA(const char *optString, const char *option, long defVal);
289d126b
VK
1196
1197#ifdef UNICODE
1198#define ExtractNamedOptionValue ExtractNamedOptionValueW
1199#define ExtractNamedOptionValueAsBool ExtractNamedOptionValueAsBoolW
1200#define ExtractNamedOptionValueAsInt ExtractNamedOptionValueAsIntW
1201#else
1202#define ExtractNamedOptionValue ExtractNamedOptionValueA
1203#define ExtractNamedOptionValueAsBool ExtractNamedOptionValueAsBoolA
1204#define ExtractNamedOptionValueAsInt ExtractNamedOptionValueAsIntA
1205#endif
ae9cddaf 1206
bc858635 1207#ifdef __cplusplus
735bac5c 1208const TCHAR LIBNETXMS_EXPORTABLE *CodeToText(int iCode, CODE_TO_TEXT *pTranslator, const TCHAR *pszDefaultText = _T("Unknown"));
bc858635 1209#else
735bac5c 1210const TCHAR LIBNETXMS_EXPORTABLE *CodeToText(int iCode, CODE_TO_TEXT *pTranslator, const TCHAR *pszDefaultText);
bc858635
VK
1211#endif
1212
aa13cfd9 1213#ifdef _WIN32
735bac5c
VK
1214TCHAR LIBNETXMS_EXPORTABLE *GetSystemErrorText(UINT32 dwError, TCHAR *pszBuffer, size_t iBufSize);
1215BOOL LIBNETXMS_EXPORTABLE GetWindowsVersionString(TCHAR *versionString, int strSize);
1216INT64 LIBNETXMS_EXPORTABLE GetProcessRSS();
aa13cfd9 1217#endif
696fc54f
VK
1218
1219#if !(HAVE_DAEMON)
735bac5c 1220int LIBNETXMS_EXPORTABLE daemon(int nochdir, int noclose);
696fc54f 1221#endif
4332e9d8 1222
735bac5c 1223UINT32 LIBNETXMS_EXPORTABLE inet_addr_w(const WCHAR *pszAddr);
268774a0 1224
4332e9d8 1225#ifndef _WIN32
735bac5c
VK
1226BOOL LIBNETXMS_EXPORTABLE SetDefaultCodepage(const char *cp);
1227int LIBNETXMS_EXPORTABLE WideCharToMultiByte(int iCodePage, UINT32 dwFlags, const WCHAR *pWideCharStr,
1228 int cchWideChar, char *pByteStr, int cchByteChar,
1229 char *pDefaultChar, BOOL *pbUsedDefChar);
1230int LIBNETXMS_EXPORTABLE MultiByteToWideChar(int iCodePage, UINT32 dwFlags, const char *pByteStr,
1231 int cchByteChar, WCHAR *pWideCharStr,
1232 int cchWideChar);
04dbaf62 1233
6b93c954 1234#if !defined(UNICODE_UCS2) || !HAVE_WCSLEN
735bac5c 1235int LIBNETXMS_EXPORTABLE ucs2_strlen(const UCS2CHAR *pStr);
6b93c954
VK
1236#endif
1237#if !defined(UNICODE_UCS2) || !HAVE_WCSNCPY
735bac5c 1238UCS2CHAR LIBNETXMS_EXPORTABLE *ucs2_strncpy(UCS2CHAR *pDst, const UCS2CHAR *pSrc, int nDstLen);
6b93c954
VK
1239#endif
1240#if !defined(UNICODE_UCS2) || !HAVE_WCSDUP
735bac5c 1241UCS2CHAR LIBNETXMS_EXPORTABLE *ucs2__tcsdup(const UCS2CHAR *pStr);
4332e9d8 1242#endif
8b86c5dc 1243
735bac5c
VK
1244size_t LIBNETXMS_EXPORTABLE ucs2_to_mb(const UCS2CHAR *src, int srcLen, char *dst, int dstLen);
1245size_t LIBNETXMS_EXPORTABLE mb_to_ucs2(const char *src, int srcLen, UCS2CHAR *dst, int dstLen);
1246UCS2CHAR LIBNETXMS_EXPORTABLE *UCS2StringFromMBString(const char *pszString);
1247char LIBNETXMS_EXPORTABLE *MBStringFromUCS2String(const UCS2CHAR *pszString);
8b86c5dc 1248
735bac5c
VK
1249int LIBNETXMS_EXPORTABLE nx_wprintf(const WCHAR *format, ...);
1250int LIBNETXMS_EXPORTABLE nx_fwprintf(FILE *fp, const WCHAR *format, ...);
1251int LIBNETXMS_EXPORTABLE nx_swprintf(WCHAR *buffer, size_t size, const WCHAR *format, ...);
1252int LIBNETXMS_EXPORTABLE nx_vwprintf(const WCHAR *format, va_list args);
1253int LIBNETXMS_EXPORTABLE nx_vfwprintf(FILE *fp, const WCHAR *format, va_list args);
1254int LIBNETXMS_EXPORTABLE nx_vswprintf(WCHAR *buffer, size_t size, const WCHAR *format, va_list args);
04dbaf62 1255
735bac5c
VK
1256int LIBNETXMS_EXPORTABLE nx_wscanf(const WCHAR *format, ...);
1257int LIBNETXMS_EXPORTABLE nx_fwscanf(FILE *fp, const WCHAR *format, ...);
1258int LIBNETXMS_EXPORTABLE nx_swscanf(const WCHAR *str, const WCHAR *format, ...);
1259int LIBNETXMS_EXPORTABLE nx_vwscanf(const WCHAR *format, va_list args);
1260int LIBNETXMS_EXPORTABLE nx_vfwscanf(FILE *fp, const WCHAR *format, va_list args);
1261int LIBNETXMS_EXPORTABLE nx_vswscanf(const WCHAR *str, const WCHAR *format, va_list args);
25575d38 1262
3e39fcde 1263#endif /* _WIN32 */
8b86c5dc 1264
735bac5c
VK
1265WCHAR LIBNETXMS_EXPORTABLE *WideStringFromMBString(const char *pszString);
1266WCHAR LIBNETXMS_EXPORTABLE *WideStringFromUTF8String(const char *pszString);
1267char LIBNETXMS_EXPORTABLE *MBStringFromWideString(const WCHAR *pwszString);
1268char LIBNETXMS_EXPORTABLE *UTF8StringFromWideString(const WCHAR *pwszString);
cc022855 1269
3d1058ed 1270#ifdef _WITH_ENCRYPTION
735bac5c 1271WCHAR LIBNETXMS_EXPORTABLE *ERR_error_string_W(int nError, WCHAR *pwszBuffer);
3d1058ed
VK
1272#endif
1273
8b86c5dc 1274#ifdef UNICODE_UCS4
735bac5c
VK
1275size_t LIBNETXMS_EXPORTABLE ucs2_to_ucs4(const UCS2CHAR *src, int srcLen, WCHAR *dst, int dstLen);
1276size_t LIBNETXMS_EXPORTABLE ucs4_to_ucs2(const WCHAR *src, int srcLen, UCS2CHAR *dst, int dstLen);
1277size_t LIBNETXMS_EXPORTABLE ucs2_to_utf8(const UCS2CHAR *src, int srcLen, char *dst, int dstLen);
1278UCS2CHAR LIBNETXMS_EXPORTABLE *UCS2StringFromUCS4String(const WCHAR *pwszString);
1279WCHAR LIBNETXMS_EXPORTABLE *UCS4StringFromUCS2String(const UCS2CHAR *pszString);
b50f1100 1280#endif
8b86c5dc 1281
842c22f4 1282#if !defined(_WIN32) && !HAVE_WSTAT
735bac5c 1283int wstat(const WCHAR *_path, struct stat *_sbuf);
842c22f4
AK
1284#endif
1285
ef856d02 1286#if defined(UNICODE) && !defined(_WIN32)
d9b66a56 1287
f3387429 1288#if !HAVE_WPOPEN
735bac5c 1289FILE LIBNETXMS_EXPORTABLE *wpopen(const WCHAR *_command, const WCHAR *_type);
f3387429 1290#endif
8b86c5dc 1291#if !HAVE_WFOPEN
735bac5c 1292FILE LIBNETXMS_EXPORTABLE *wfopen(const WCHAR *_name, const WCHAR *_type);
8b86c5dc 1293#endif
8c2489aa 1294#if HAVE_FOPEN64 && !HAVE_WFOPEN64
735bac5c 1295FILE LIBNETXMS_EXPORTABLE *wfopen64(const WCHAR *_name, const WCHAR *_type);
8c2489aa 1296#endif
8b86c5dc 1297#if !HAVE_WOPEN
735bac5c 1298int LIBNETXMS_EXPORTABLE wopen(const WCHAR *, int, ...);
b50f1100 1299#endif
f3387429 1300#if !HAVE_WCHMOD
735bac5c 1301int LIBNETXMS_EXPORTABLE wchmod(const WCHAR *_name, int mode);
f3387429 1302#endif
b07c50cc 1303#if !HAVE_WCHDIR
735bac5c 1304int wchdir(const WCHAR *_path);
b07c50cc
VK
1305#endif
1306#if !HAVE_WMKDIR
735bac5c 1307int wmkdir(const WCHAR *_path, int mode);
b07c50cc
VK
1308#endif
1309#if !HAVE_WRMDIR
735bac5c 1310int wrmdir(const WCHAR *_path);
b07c50cc 1311#endif
ccc34207 1312#if !HAVE_WRENAME
735bac5c 1313int wrename(const WCHAR *_oldpath, const WCHAR *_newpath);
ccc34207
VK
1314#endif
1315#if !HAVE_WUNLINK
735bac5c 1316int wunlink(const WCHAR *_path);
ccc34207 1317#endif
b07c50cc 1318#if !HAVE_WREMOVE
735bac5c 1319int wremove(const WCHAR *_path);
b07c50cc
VK
1320#endif
1321#if !HAVE_WSYSTEM
735bac5c 1322int wsystem(const WCHAR *_cmd);
b07c50cc 1323#endif
dda7c270 1324#if !HAVE_WMKSTEMP
735bac5c 1325int wmkstemp(WCHAR *_template);
dda7c270 1326#endif
b07c50cc 1327#if !HAVE_WACCESS
735bac5c 1328int waccess(const WCHAR *_path, int mode);
b07c50cc 1329#endif
273da39a 1330#if !HAVE_WGETENV
735bac5c 1331WCHAR *wgetenv(const WCHAR *_string);
273da39a 1332#endif
f3387429 1333#if !HAVE_WCTIME
735bac5c 1334WCHAR *wctime(const time_t *timep);
f3387429 1335#endif
0186b5da 1336#if !HAVE_PUTWS
735bac5c 1337int putws(const WCHAR *s);
0186b5da 1338#endif
d49d7500 1339#if !HAVE_WCSERROR && HAVE_STRERROR
735bac5c 1340WCHAR *wcserror(int errnum);
d49d7500
VK
1341#endif
1342#if !HAVE_WCSERROR_R && HAVE_STRERROR_R
b0823d06 1343#if HAVE_POSIX_STRERROR_R
735bac5c 1344int wcserror_r(int errnum, WCHAR *strerrbuf, size_t buflen);
b0823d06 1345#else
735bac5c 1346WCHAR *wcserror_r(int errnum, WCHAR *strerrbuf, size_t buflen);
d49d7500 1347#endif
b0823d06 1348#endif
e05f8aaf 1349
ef856d02 1350#endif /* UNICODE && !_WIN32*/
e05f8aaf 1351
8b86c5dc 1352#if !HAVE_STRTOLL
735bac5c 1353INT64 LIBNETXMS_EXPORTABLE strtoll(const char *nptr, char **endptr, int base);
8b86c5dc
VK
1354#endif
1355#if !HAVE_STRTOULL
735bac5c 1356UINT64 LIBNETXMS_EXPORTABLE strtoull(const char *nptr, char **endptr, int base);
8b86c5dc 1357#endif
e05f8aaf
VK
1358
1359#if !HAVE_WCSTOLL
735bac5c 1360INT64 LIBNETXMS_EXPORTABLE wcstoll(const WCHAR *nptr, WCHAR **endptr, int base);
e05f8aaf
VK
1361#endif
1362#if !HAVE_WCSTOULL
735bac5c 1363UINT64 LIBNETXMS_EXPORTABLE wcstoull(const WCHAR *nptr, WCHAR **endptr, int base);
e05f8aaf 1364#endif
b50f1100 1365
2f56be29 1366#if !HAVE_WCSLWR && !defined(_WIN32)
735bac5c 1367WCHAR LIBNETXMS_EXPORTABLE *wcslwr(WCHAR *str);
fdf1ed50
VK
1368#endif
1369
4d978b4a 1370#if !HAVE_WCSCASECMP && !defined(_WIN32)
735bac5c 1371int LIBNETXMS_EXPORTABLE wcscasecmp(const wchar_t *s1, const wchar_t *s2);
4d978b4a
VK
1372#endif
1373
f4d2c9ba 1374#if !HAVE_WCSNCASECMP && !defined(_WIN32)
735bac5c 1375int LIBNETXMS_EXPORTABLE wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n);
f4d2c9ba
VK
1376#endif
1377
3d1cb7d6 1378#ifdef _WIN32
5ea2db30 1379#ifdef UNICODE
735bac5c
VK
1380DIRW LIBNETXMS_EXPORTABLE *wopendir(const WCHAR *filename);
1381struct dirent_w LIBNETXMS_EXPORTABLE *wreaddir(DIRW *dirp);
1382int LIBNETXMS_EXPORTABLE wclosedir(DIRW *dirp);
5ea2db30
VK
1383
1384#define _topendir wopendir
1385#define _treaddir wreaddir
1386#define _tclosedir wclosedir
1387#else
1388#define _topendir opendir
1389#define _treaddir readdir
1390#define _tclosedir closedir
1391#endif
1392
735bac5c
VK
1393DIR LIBNETXMS_EXPORTABLE *opendir(const char *filename);
1394struct dirent LIBNETXMS_EXPORTABLE *readdir(DIR *dirp);
1395int LIBNETXMS_EXPORTABLE closedir(DIR *dirp);
5ea2db30 1396
76b1d3d8
VK
1397#else /* not _WIN32 */
1398
735bac5c
VK
1399DIRW LIBNETXMS_EXPORTABLE *wopendir(const WCHAR *filename);
1400struct dirent_w LIBNETXMS_EXPORTABLE *wreaddir(DIRW *dirp);
1401int LIBNETXMS_EXPORTABLE wclosedir(DIRW *dirp);
76b1d3d8 1402
37d62364 1403#endif
3d1cb7d6 1404
7f9e0c00 1405#if defined(_WIN32) || !(HAVE_SCANDIR)
735bac5c
VK
1406int LIBNETXMS_EXPORTABLE scandir(const char *dir, struct dirent ***namelist,
1407 int (*select)(const struct dirent *),
1408 int (*compar)(const struct dirent **, const struct dirent **));
1409int LIBNETXMS_EXPORTABLE alphasort(const struct dirent **a, const struct dirent **b);
7f9e0c00
VK
1410#endif
1411
3bf0df9f
VK
1412TCHAR LIBNETXMS_EXPORTABLE *safe_fgetts(TCHAR *buffer, int len, FILE *f);
1413
55b33d4c 1414#ifdef UNDER_CE
3bf0df9f
VK
1415int LIBNETXMS_EXPORTABLE _topen(TCHAR *pszName, int nFlags, ...);
1416int LIBNETXMS_EXPORTABLE read(int hFile, void *pBuffer, size_t nBytes);
1417int LIBNETXMS_EXPORTABLE write(int hFile, void *pBuffer, size_t nBytes);
55b33d4c
VK
1418#endif
1419
967893bb 1420BOOL LIBNETXMS_EXPORTABLE nxlog_open(const TCHAR *logName, UINT32 flags, const TCHAR *msgModule,
d49d7500 1421 unsigned int msgCount, const TCHAR **messages);
9f2902ac
VK
1422void LIBNETXMS_EXPORTABLE nxlog_close(void);
1423void LIBNETXMS_EXPORTABLE nxlog_write(DWORD msg, WORD wType, const char *format, ...);
5945d50a 1424BOOL LIBNETXMS_EXPORTABLE nxlog_set_rotation_policy(int rotationMode, int maxLogSize, int historySize, const TCHAR *dailySuffix);
4addc3a3 1425BOOL LIBNETXMS_EXPORTABLE nxlog_rotate();
9113e749
VK
1426
1427typedef void (*NxLogConsoleWriter)(const TCHAR *, ...);
1428void LIBNETXMS_EXPORTABLE nxlog_set_console_writer(NxLogConsoleWriter writer);
f669df41
VK
1429
1430void LIBNETXMS_EXPORTABLE WriteToTerminal(const TCHAR *text);
6e383343
VK
1431void LIBNETXMS_EXPORTABLE WriteToTerminalEx(const TCHAR *format, ...)
1432#if !defined(UNICODE) && (defined(__GNUC__) || defined(__clang__))
1433 __attribute__ ((format(printf, 1, 2)))
1434#endif
1435;
9f2902ac 1436
37a7a862
VK
1437#ifdef _WIN32
1438int LIBNETXMS_EXPORTABLE mkstemp(char *tmpl);
1439int LIBNETXMS_EXPORTABLE wmkstemp(WCHAR *tmpl);
1440#ifdef UNICODE
1441#define _tmkstemp wmkstemp
1442#else
1443#define _tmkstemp mkstemp
1444#endif
1445#endif
1446
9b13553b
VK
1447#ifndef _WIN32
1448int strcat_s(char *dst, size_t dstSize, const char *src);
1449int wcscat_s(WCHAR *dst, size_t dstSize, const WCHAR *src);
1450#endif
1451
c57d020a
VK
1452#if !HAVE_STRPTIME
1453char LIBNETXMS_EXPORTABLE *strptime(const char *buf, const char *fmt, struct tm *_tm);
1454#endif
1455
1456#if !HAVE_TIMEGM
1457time_t LIBNETXMS_EXPORTABLE timegm(struct tm *_tm);
1458#endif
1459
b50f1100 1460#ifdef __cplusplus
e9246d26 1461}
b50f1100 1462#endif
e9246d26 1463
a7ff20a5
VK
1464
1465//
1466// C++ only finctions
1467//
1468
1469#ifdef __cplusplus
1470
240816b0
VK
1471TCHAR LIBNETXMS_EXPORTABLE *EscapeStringForXML(const TCHAR *str, int length);
1472String LIBNETXMS_EXPORTABLE EscapeStringForXML2(const TCHAR *str, int length = -1);
53c96e2d
VK
1473const char LIBNETXMS_EXPORTABLE *XMLGetAttr(const char **attrs, const char *name);
1474int LIBNETXMS_EXPORTABLE XMLGetAttrInt(const char **attrs, const char *name, int defVal);
967893bb 1475UINT32 LIBNETXMS_EXPORTABLE XMLGetAttrUINT32(const char **attrs, const char *name, UINT32 defVal);
53c96e2d
VK
1476bool LIBNETXMS_EXPORTABLE XMLGetAttrBoolean(const char **attrs, const char *name, bool defVal);
1477
1478#if !defined(_WIN32) && !defined(_NETWARE) && defined(NMS_THREADS_H_INCLUDED)
9113e749 1479void LIBNETXMS_EXPORTABLE StartMainLoop(ThreadFunction pfSignalHandler, ThreadFunction pfMain);
53c96e2d
VK
1480#endif
1481
a7ff20a5
VK
1482#endif
1483
e9246d26 1484#endif /* _nms_util_h_ */