improved table output in nxget
[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
e2e66145
VK
90/**
91 * Uninitialized value for override indicator
92 */
93#define NXCONFIG_UNINITIALIZED_VALUE (-1)
94
605fc935
VK
95/**
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
f4d2c9ba
VK
130/**
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
c83f6449
VK
160/**
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
605fc935
VK
170/**
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
400e55c4 281/**
f9861ff9
VK
282 * Dynamic array class
283 */
284class LIBNETXMS_EXPORTABLE Array
285{
286private:
287 int m_size;
288 int m_allocated;
289 int m_grow;
290 size_t m_elementSize;
291 void **m_data;
292 bool m_objectOwner;
293
294 void internalRemove(int index, bool allowDestruction);
295 void destroyObject(void *object) { if (object != NULL) m_objectDestructor(object); }
296
297protected:
298 bool m_storePointers;
299 void (*m_objectDestructor)(void *);
300
301 Array(void *data, int initial, int grow, size_t elementSize);
302 void *__getBuffer() { return m_data; }
303
304public:
305 Array(int initial = 0, int grow = 16, bool owner = false);
306 virtual ~Array();
307
308 int add(void *element);
309 void *get(int index) { return ((index >= 0) && (index < m_size)) ? (m_storePointers ? m_data[index] : (void *)((char *)m_data + index * m_elementSize)): NULL; }
310 int indexOf(void *element);
311 void set(int index, void *element);
312 void replace(int index, void *element);
313 void remove(int index) { internalRemove(index, true); }
314 void remove(void *element) { internalRemove(indexOf(element), true); }
315 void unlink(int index) { internalRemove(index, false); }
316 void unlink(void *element) { internalRemove(indexOf(element), false); }
317 void clear();
318 void sort(int (*cb)(const void *, const void *));
319 void *find(const void *key, int (*cb)(const void *, const void *));
320
321 int size() { return m_size; }
322
323 void setOwner(bool owner) { m_objectOwner = owner; }
324 bool isOwner() { return m_objectOwner; }
325};
326
327/**
328 * Template class for dynamic array which holds objects
329 */
330template <class T> class ObjectArray : public Array
331{
332private:
333 static void destructor(void *object) { delete (T*)object; }
334
335public:
336 ObjectArray(int initial = 0, int grow = 16, bool owner = false) : Array(initial, grow, owner) { m_objectDestructor = destructor; }
337 virtual ~ObjectArray() { }
338
339 int add(T *object) { return Array::add((void *)object); }
340 T *get(int index) { return (T*)Array::get(index); }
341 int indexOf(T *object) { return Array::indexOf((void *)object); }
342 void set(int index, T *object) { Array::set(index, (void *)object); }
343 void replace(int index, T *object) { Array::replace(index, (void *)object); }
344 void remove(int index) { Array::remove(index); }
345 void remove(T *object) { Array::remove((void *)object); }
346 void unlink(int index) { Array::unlink(index); }
347 void unlink(T *object) { Array::unlink((void *)object); }
348};
349
350/**
351 * Template class for dynamic array which holds scalar values
352 */
353template <class T> class IntegerArray : public Array
354{
355private:
356 static void destructor(void *element) { }
357
358public:
359 IntegerArray(int initial = 0, int grow = 16) : Array(NULL, initial, grow, sizeof(T)) { m_objectDestructor = destructor; m_storePointers = (sizeof(T) == sizeof(void *)); }
360 virtual ~IntegerArray() { }
361
362 int add(T value) { return Array::add(m_storePointers ? CAST_TO_POINTER(value, void *) : &value); }
363 T get(int index) { return m_storePointers ? CAST_FROM_POINTER(Array::get(index), T) : *((T*)Array::get(index)); }
364 int indexOf(T value) { return Array::indexOf(m_storePointers ? CAST_TO_POINTER(value, void *) : &value); }
365 void set(int index, T value) { Array::set(index, m_storePointers ? CAST_TO_POINTER(value, void *) : &value); }
366 void replace(int index, T value) { Array::replace(index, m_storePointers ? CAST_TO_POINTER(value, void *) : &value); }
367
368 T *getBuffer() { return (T*)__getBuffer(); }
369};
370
371/**
372 * Auxilliary class to hold dynamically allocated array of structures
373 */
374template <class T> class StructArray : public Array
375{
376private:
377 static void destructor(void *element) { }
378
379public:
380 StructArray(int initial = 0, int grow = 16) : Array(NULL, initial, grow, sizeof(T)) { m_objectDestructor = destructor; }
381 StructArray(T *data, int size) : Array(data, size, 16, sizeof(T)) { m_objectDestructor = destructor; }
382 virtual ~StructArray() { }
383
384 int add(T *element) { return Array::add((void *)element); }
385 T *get(int index) { return (T*)Array::get(index); }
386 int indexOf(T *element) { return Array::indexOf((void *)element); }
387 void set(int index, T *element) { Array::set(index, (void *)element); }
388 void replace(int index, T *element) { Array::replace(index, (void *)element); }
389 void remove(int index) { Array::remove(index); }
390 void remove(T *element) { Array::remove((void *)element); }
391 void unlink(int index) { Array::unlink(index); }
392 void unlink(T *element) { Array::unlink((void *)element); }
393
394 T *getBuffer() { return (T*)__getBuffer(); }
395};
396
397/**
398 * Entry of string map (internal)
400e55c4
VK
399 */
400struct StringMapEntry;
401
f9861ff9
VK
402/**
403 * Key/value pair
404 */
405struct KeyValuePair
406{
407 const TCHAR *key;
408 const void *value;
409};
410
3fe40613
VK
411/**
412 * String maps base class
413 */
414class LIBNETXMS_EXPORTABLE StringMapBase
c577e360
VK
415{
416protected:
400e55c4 417 StringMapEntry *m_data;
3fe40613 418 bool m_objectOwner;
55bdca5a 419 bool m_ignoreCase;
3fe40613 420 void (*m_objectDestructor)(void *);
c577e360 421
400e55c4 422 StringMapEntry *find(const TCHAR *key);
3fe40613
VK
423 void setObject(TCHAR *key, void *value, bool keyPreAlloc);
424 void *getObject(const TCHAR *key);
425 void destroyObject(void *object) { if (object != NULL) m_objectDestructor(object); }
c577e360
VK
426
427public:
3fe40613
VK
428 StringMapBase(bool objectOwner);
429 virtual ~StringMapBase();
430
55bdca5a 431 void setOwner(bool owner) { m_objectOwner = owner; }
91a581c5 432 void setIgnoreCase(bool ignore);
55bdca5a 433
3fe40613
VK
434 void remove(const TCHAR *key);
435 void clear();
436
c1a30973 437 int size();
400e55c4
VK
438 bool contains(const TCHAR *key) { return find(key) != NULL; }
439
440 bool forEach(bool (*cb)(const TCHAR *, const void *, void *), void *userData);
beab0421 441 const void *findElement(bool (*comparator)(const TCHAR *, const void *, void *), void *userData);
f9861ff9
VK
442
443 StructArray<KeyValuePair> *toArray();
3fe40613
VK
444};
445
400e55c4
VK
446/**
447 * NXCP message class
448 */
449class CSCPMessage;
450
3fe40613
VK
451/**
452 * String map class
453 */
454class LIBNETXMS_EXPORTABLE StringMap : public StringMapBase
455{
456public:
457 StringMap() : StringMapBase(true) { }
fb986055 458 StringMap(const StringMap &src);
3fe40613 459 virtual ~StringMap();
c577e360 460
fb986055 461 StringMap& operator =(const StringMap &src);
40b7416c 462
3fe40613
VK
463 void set(const TCHAR *key, const TCHAR *value) { setObject((TCHAR *)key, _tcsdup(value), false); }
464 void setPreallocated(TCHAR *key, TCHAR *value) { setObject(key, value, true); }
967893bb 465 void set(const TCHAR *key, UINT32 value);
5ad2167d 466
a6312bd6
VK
467 void addAll(StringMap *src);
468
3fe40613 469 const TCHAR *get(const TCHAR *key) { return (const TCHAR *)getObject(key); }
967893bb 470 UINT32 getULong(const TCHAR *key, UINT32 defaultValue);
6acb8479 471 bool getBoolean(const TCHAR *key, bool defaultValue);
5ad2167d 472
400e55c4 473 void fillMessage(CSCPMessage *msg, UINT32 sizeFieldId, UINT32 baseFieldId);
8bad8476
VK
474};
475
3fe40613
VK
476/**
477 * String map template for holding objects as values
478 */
479template <class T> class StringObjectMap : public StringMapBase
480{
481private:
482 static void destructor(void *object) { delete (T*)object; }
6173bea8 483
3fe40613
VK
484public:
485 StringObjectMap(bool objectOwner) : StringMapBase(objectOwner) { m_objectDestructor = destructor; }
486
487 void set(const TCHAR *key, T *object) { setObject((TCHAR *)key, (void *)object, false); }
488 T *get(const TCHAR *key) { return (T*)getObject(key); }
3fe40613 489};
6173bea8 490
3fe40613
VK
491/**
492 * String list class
493 */
6173bea8
VK
494class LIBNETXMS_EXPORTABLE StringList
495{
496private:
497 int m_count;
498 int m_allocated;
499 TCHAR **m_values;
500
501public:
502 StringList();
86c126f5 503 StringList(StringList *src);
22ee6d97 504 StringList(const TCHAR *src, const TCHAR *separator);
6173bea8
VK
505 ~StringList();
506
507 void add(const TCHAR *value);
508 void addPreallocated(TCHAR *value);
967893bb
VK
509 void add(INT32 value);
510 void add(UINT32 value);
6173bea8 511 void add(INT64 value);
967893bb 512 void add(UINT64 value);
6173bea8 513 void add(double value);
24dc5346 514 void replace(int index, const TCHAR *value);
6173bea8 515 void clear();
a6312bd6
VK
516 int size() { return m_count; }
517 const TCHAR *get(int index) { return ((index >=0) && (index < m_count)) ? m_values[index] : NULL; }
518 int indexOf(const TCHAR *value);
519 int indexOfIgnoreCase(const TCHAR *value);
d51f2182 520 void remove(int index);
86c126f5 521 void addAll(const StringList *src);
93dbc1be 522 void merge(const StringList *src, bool matchCase);
7d25a5c5 523 TCHAR *join(const TCHAR *separator);
22ee6d97 524 void splitAndAdd(const TCHAR *src, const TCHAR *separator);
6173bea8
VK
525};
526
a58501c0
VK
527/**
528 * Entry of string set
529 */
530struct StringSetEntry;
531
f3603b79
VK
532/**
533 * NXCP message
534 */
535class CSCPMessage;
536
a58501c0
VK
537/**
538 * String set class
539 */
540class LIBNETXMS_EXPORTABLE StringSet
541{
542private:
543 StringSetEntry *m_data;
544
545public:
546 StringSet();
547 ~StringSet();
548
549 void add(const TCHAR *str);
f3603b79 550 void addPreallocated(TCHAR *str);
a58501c0
VK
551 void remove(const TCHAR *str);
552 void clear();
553
554 int size();
f3603b79 555 bool contains(const TCHAR *str);
5b521bfc 556 bool equals(StringSet *s);
a58501c0 557
fa493140 558 void addAll(StringSet *src);
f3603b79 559 void addAll(TCHAR **strings, int count);
d6c4cdc1 560 void addAllPreallocated(TCHAR **strings, int count);
a58501c0 561 void forEach(bool (*cb)(const TCHAR *, void *), void *userData);
f3603b79
VK
562
563 void fillMessage(CSCPMessage *msg, UINT32 baseId, UINT32 countId);
c262bc08
VK
564 void addAllFromMessage(CSCPMessage *msg, UINT32 baseId, UINT32 countId, bool clearBeforeAdd, bool toUppercase);
565
566 String getAll(const TCHAR *separator);
a58501c0
VK
567};
568
25fe6265
VK
569/**
570 * Auxilliary class for objects which counts references and
571 * destroys itself wheren reference count falls to 0
572 */
7f632dfe
VK
573class LIBNETXMS_EXPORTABLE RefCountObject
574{
575private:
7785322f 576 VolatileCounter m_refCount;
7f632dfe
VK
577
578public:
7785322f
VK
579 RefCountObject()
580 {
581 m_refCount = 1;
582 }
b549a0f8 583 virtual ~RefCountObject();
7785322f
VK
584
585 void incRefCount()
586 {
587 InterlockedIncrement(&m_refCount);
588 }
589
590 void decRefCount()
591 {
592 if (InterlockedDecrement(&m_refCount) == 0)
593 delete this;
594 }
7f632dfe
VK
595};
596
967893bb
VK
597class CSCPMessage;
598
599/**
600 * Table column definition
601 */
602class LIBNETXMS_EXPORTABLE TableColumnDefinition
603{
604private:
605 TCHAR *m_name;
606 TCHAR *m_displayName;
607 INT32 m_dataType;
608 bool m_instanceColumn;
609
610public:
611 TableColumnDefinition(const TCHAR *name, const TCHAR *displayName, INT32 dataType, bool isInstance);
612 TableColumnDefinition(CSCPMessage *msg, UINT32 baseId);
613 TableColumnDefinition(TableColumnDefinition *src);
614 ~TableColumnDefinition();
615
616 void fillMessage(CSCPMessage *msg, UINT32 baseId);
617
618 const TCHAR *getName() { return m_name; }
619 const TCHAR *getDisplayName() { return m_displayName; }
620 INT32 getDataType() { return m_dataType; }
621 bool isInstanceColumn() { return m_instanceColumn; }
622
623 void setDataType(INT32 type) { m_dataType = type; }
624 void setInstanceColumn(bool isInstance) { m_instanceColumn = isInstance; }
a0ddfb29 625 void setDisplayName(const TCHAR *name) { safe_free(m_displayName); m_displayName = _tcsdup(CHECK_NULL_EX(name)); }
967893bb
VK
626};
627
d6bbfa4e
VK
628/**
629 * Table cell
630 */
631class TableCell
632{
633private:
634 TCHAR *m_value;
635 int m_status;
636
637public:
638 TableCell() { m_value = NULL; m_status = -1; }
c83f6449
VK
639 TableCell(const TCHAR *value) { m_value = _tcsdup_ex(value); m_status = -1; }
640 TableCell(const TCHAR *value, int status) { m_value = _tcsdup_ex(value); m_status = status; }
641 TableCell(TableCell *src) { m_value = _tcsdup_ex(src->m_value); m_status = src->m_status; }
d6bbfa4e
VK
642 ~TableCell() { safe_free(m_value); }
643
c83f6449 644 void set(const TCHAR *value, int status) { safe_free(m_value); m_value = _tcsdup_ex(value); m_status = status; }
d6bbfa4e
VK
645 void setPreallocated(TCHAR *value, int status) { safe_free(m_value); m_value = value; m_status = status; }
646
647 const TCHAR *getValue() { return m_value; }
c83f6449 648 void setValue(const TCHAR *value) { safe_free(m_value); m_value = _tcsdup_ex(value); }
d6bbfa4e
VK
649 void setPreallocatedValue(TCHAR *value) { safe_free(m_value); m_value = value; }
650
651 int getStatus() { return m_status; }
652 void setStatus(int status) { m_status = status; }
653};
654
655/**
656 * Table row
657 */
658class TableRow
659{
660private:
661 ObjectArray<TableCell> *m_cells;
662 UINT32 m_objectId;
bac74bf7 663
d6bbfa4e
VK
664public:
665 TableRow(int columnCount);
666 TableRow(TableRow *src);
667 ~TableRow() { delete m_cells; }
668
669 void addColumn() { m_cells->add(new TableCell); }
670 void deleteColumn(int index) { m_cells->remove(index); }
bac74bf7 671
d6bbfa4e
VK
672 void set(int index, const TCHAR *value, int status) { TableCell *c = m_cells->get(index); if (c != NULL) c->set(value, status); }
673 void setPreallocated(int index, TCHAR *value, int status) { TableCell *c = m_cells->get(index); if (c != NULL) c->setPreallocated(value, status); }
674
675 void setValue(int index, const TCHAR *value) { TableCell *c = m_cells->get(index); if (c != NULL) c->setValue(value); }
676 void setPreallocatedValue(int index, TCHAR *value) { TableCell *c = m_cells->get(index); if (c != NULL) c->setPreallocatedValue(value); }
677
678 void setStatus(int index, int status) { TableCell *c = m_cells->get(index); if (c != NULL) c->setStatus(status); }
679
680 const TCHAR *getValue(int index) { TableCell *c = m_cells->get(index); return (c != NULL) ? c->getValue() : NULL; }
681 int getStatus(int index) { TableCell *c = m_cells->get(index); return (c != NULL) ? c->getStatus() : -1; }
682
683 UINT32 getObjectId() { return m_objectId; }
684 void setObjectId(UINT32 id) { m_objectId = id; }
685};
686
967893bb
VK
687/**
688 * Class for table data storage
689 */
a0ddfb29 690class LIBNETXMS_EXPORTABLE Table : public RefCountObject
967893bb
VK
691{
692private:
d6bbfa4e 693 ObjectArray<TableRow> *m_data;
967893bb
VK
694 ObjectArray<TableColumnDefinition> *m_columns;
695 TCHAR *m_title;
696 int m_source;
d6bbfa4e 697 bool m_extendedFormat;
967893bb
VK
698
699 void createFromMessage(CSCPMessage *msg);
700 void destroy();
701
702public:
703 Table();
a0ddfb29 704 Table(Table *src);
967893bb 705 Table(CSCPMessage *msg);
b549a0f8 706 virtual ~Table();
967893bb
VK
707
708 int fillMessage(CSCPMessage &msg, int offset, int rowLimit);
709 void updateFromMessage(CSCPMessage *msg);
710
a0ddfb29
VK
711 void addAll(Table *src);
712 void copyRow(Table *src, int row);
967893bb 713
d6bbfa4e
VK
714 int getNumRows() { return m_data->size(); }
715 int getNumColumns() { return m_columns->size(); }
967893bb
VK
716 const TCHAR *getTitle() { return CHECK_NULL_EX(m_title); }
717 int getSource() { return m_source; }
718
d6bbfa4e
VK
719 bool isExtendedFormat() { return m_extendedFormat; }
720 void setExtendedFormat(bool ext) { m_extendedFormat = ext; }
721
967893bb
VK
722 const TCHAR *getColumnName(int col) { return ((col >= 0) && (col < m_columns->size())) ? m_columns->get(col)->getName() : NULL; }
723 INT32 getColumnDataType(int col) { return ((col >= 0) && (col < m_columns->size())) ? m_columns->get(col)->getDataType() : 0; }
724 int getColumnIndex(const TCHAR *name);
725 ObjectArray<TableColumnDefinition> *getColumnDefinitions() { return m_columns; }
726
c83f6449 727 void setTitle(const TCHAR *title) { safe_free(m_title); m_title = _tcsdup_ex(title); }
967893bb 728 void setSource(int source) { m_source = source; }
8dba1eac 729 int addColumn(const TCHAR *name, INT32 dataType = 0, const TCHAR *displayName = NULL, bool isInstance = false);
967893bb
VK
730 void setColumnDataType(int col, INT32 dataType) { if ((col >= 0) && (col < m_columns->size())) m_columns->get(col)->setDataType(dataType); }
731 int addRow();
732
25076d53
VK
733 void deleteRow(int row);
734 void deleteColumn(int col);
735
967893bb
VK
736 void setAt(int nRow, int nCol, INT32 nData);
737 void setAt(int nRow, int nCol, UINT32 dwData);
738 void setAt(int nRow, int nCol, double dData);
739 void setAt(int nRow, int nCol, INT64 nData);
740 void setAt(int nRow, int nCol, UINT64 qwData);
741 void setAt(int nRow, int nCol, const TCHAR *pszData);
742 void setPreallocatedAt(int nRow, int nCol, TCHAR *pszData);
743
d6bbfa4e
VK
744 void set(int nCol, INT32 nData) { setAt(getNumRows() - 1, nCol, nData); }
745 void set(int nCol, UINT32 dwData) { setAt(getNumRows() - 1, nCol, dwData); }
746 void set(int nCol, double dData) { setAt(getNumRows() - 1, nCol, dData); }
747 void set(int nCol, INT64 nData) { setAt(getNumRows() - 1, nCol, nData); }
748 void set(int nCol, UINT64 qwData) { setAt(getNumRows() - 1, nCol, qwData); }
749 void set(int nCol, const TCHAR *pszData) { setAt(getNumRows() - 1, nCol, pszData); }
750 void setPreallocated(int nCol, TCHAR *pszData) { setPreallocatedAt(getNumRows() - 1, nCol, pszData); }
751
752 void setStatusAt(int row, int col, int status);
753 void setStatus(int col, int status) { setStatusAt(getNumRows() - 1, col, status); }
967893bb
VK
754
755 const TCHAR *getAsString(int nRow, int nCol);
756 INT32 getAsInt(int nRow, int nCol);
757 UINT32 getAsUInt(int nRow, int nCol);
758 INT64 getAsInt64(int nRow, int nCol);
759 UINT64 getAsUInt64(int nRow, int nCol);
760 double getAsDouble(int nRow, int nCol);
22aaa779 761
d6bbfa4e
VK
762 int getStatus(int nRow, int nCol);
763
22aaa779 764 void buildInstanceString(int row, TCHAR *buffer, size_t bufLen);
a0ddfb29 765 int findRowByInstance(const TCHAR *instance);
d6bbfa4e
VK
766
767 UINT32 getObjectId(int row) { TableRow *r = m_data->get(row); return (r != NULL) ? r->getObjectId() : 0; }
768 void setObjectId(int row, UINT32 id) { TableRow *r = m_data->get(row); if (r != NULL) r->setObjectId(id); }
967893bb
VK
769};
770
9319c166
VK
771/**
772 * IP address
773 */
774class LIBNETXMS_EXPORTABLE InetAddress
775{
9319c166 776private:
8c75ad41
VK
777 short m_maskBits;
778 short m_family;
779 union
780 {
781 UINT32 v4;
782 BYTE v6[16];
783 } m_addr;
9319c166
VK
784
785public:
8c75ad41
VK
786 InetAddress();
787 InetAddress(UINT32 addr);
788 InetAddress(BYTE *addr);
9319c166 789
8c75ad41
VK
790 bool isAnyLocal() const;
791 bool isLoopback() const;
792 bool isMulticast() const;
793 bool isBroadcast() const;
794 bool isValid() const { return m_family != AF_UNSPEC; }
9319c166 795
8c75ad41 796 int getFamily() const { return m_family; }
c7853753
VK
797 UINT32 getAddressV4() const { return (m_family == AF_INET) ? m_addr.v4 : 0; }
798 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 799
8c75ad41
VK
800 bool contain(const InetAddress &a) const;
801 bool equals(const InetAddress &a) const;
802 int compareTo(const InetAddress &a) const;
9319c166 803
8c75ad41
VK
804 void setMaskBits(int m) { m_maskBits = m; }
805 int getMaskBits() const { return m_maskBits; }
9319c166 806
8c75ad41
VK
807 String toString() const;
808 TCHAR *toString(TCHAR *buffer) const;
9319c166 809
c7853753
VK
810 static InetAddress resolveHostName(const WCHAR *hostname, int af = AF_INET);
811 static InetAddress resolveHostName(const char *hostname, int af = AF_INET);
8c75ad41 812 static InetAddress createFromSockaddr(struct sockaddr *s);
9319c166
VK
813};
814
25fe6265
VK
815/**
816 * Network connection
817 */
58ee2f43
VK
818class LIBNETXMS_EXPORTABLE SocketConnection
819{
820protected:
821 SOCKET m_socket;
822 char m_data[4096];
823 int m_dataPos;
824
825public:
826 SocketConnection();
827 virtual ~SocketConnection();
828
967893bb
VK
829 bool connectTCP(const TCHAR *hostName, WORD port, UINT32 timeout);
830 bool connectTCP(UINT32 ip, WORD port, UINT32 timeout);
58ee2f43
VK
831 void disconnect();
832
967893bb
VK
833 bool canRead(UINT32 timeout);
834 virtual int read(char *pBuff, int nSize, UINT32 timeout = INFINITE);
58ee2f43 835 bool waitForText(const char *text, int timeout);
cc022855 836
58ee2f43 837 int write(const char *pBuff, int nSize);
1671f85d
VK
838 bool writeLine(const char *line);
839
967893bb 840 static SocketConnection *createTCPConnection(const TCHAR *hostName, WORD port, UINT32 timeout);
58ee2f43
VK
841};
842
030a0779
VK
843/**
844 * Telnet connection - handles all telnet negotiation
845 */
def5b792
AK
846class LIBNETXMS_EXPORTABLE TelnetConnection : public SocketConnection
847{
030a0779 848protected:
967893bb
VK
849 bool connectTCP(const TCHAR *hostName, WORD port, UINT32 timeout);
850 bool connectTCP(UINT32 ip, WORD port, UINT32 timeout);
030a0779 851
def5b792 852public:
967893bb 853 static TelnetConnection *createConnection(const TCHAR *hostName, WORD port, UINT32 timeout);
d4e9d325 854
967893bb
VK
855 bool connect(const TCHAR *hostName, WORD port, UINT32 timeout);
856 bool connect(UINT32 ip, WORD port, UINT32 timeout);
857 virtual int read(char *pBuff, int nSize, UINT32 timeout = INFINITE);
858 int readLine(char *buffer, int size, UINT32 timeout = INFINITE);
def5b792
AK
859};
860
56fa1092
VK
861/**
862 * Postal address representation
863 */
864class LIBNETXMS_EXPORTABLE PostalAddress
865{
866private:
867 TCHAR *m_country;
868 TCHAR *m_city;
869 TCHAR *m_streetAddress;
870 TCHAR *m_postcode;
871
872public:
873 PostalAddress();
874 PostalAddress(const TCHAR *country, const TCHAR *city, const TCHAR *streetAddress, const TCHAR *postcode);
875 ~PostalAddress();
876
877 const TCHAR *getCountry() { return CHECK_NULL_EX(m_country); }
878 const TCHAR *getCity() { return CHECK_NULL_EX(m_city); }
879 const TCHAR *getStreetAddress() { return CHECK_NULL_EX(m_streetAddress); }
880 const TCHAR *getPostCode() { return CHECK_NULL_EX(m_postcode); }
881
882 void setCountry(const TCHAR *country) { safe_free(m_country); m_country = _tcsdup_ex(country); }
883 void setCity(const TCHAR *city) { safe_free(m_city); m_city = _tcsdup_ex(city); }
884 void setStreetAddress(const TCHAR *streetAddress) { safe_free(m_streetAddress); m_streetAddress = _tcsdup_ex(streetAddress); }
885 void setPostCode(const TCHAR *postcode) { safe_free(m_postcode); m_postcode = _tcsdup_ex(postcode); }
886};
887
b160350d
VK
888#endif /* __cplusplus */
889
030a0779
VK
890/**
891 * Configuration item template for configuration loader
892 */
4826c8a5
VK
893typedef struct
894{
e2e66145
VK
895 TCHAR token[64];
896 BYTE type;
897 BYTE separator; // Separator character for lists
898 WORD listElements; // Number of list elements, should be set to 0 before calling NxLoadConfig()
899 UINT32 bufferSize; // Buffer size for strings or flag to be set for CT_BOOLEAN
900 UINT32 bufferPos; // Should be set to 0
901 void *buffer;
902 void *overrideIndicator;
4826c8a5 903} NX_CFG_TEMPLATE;
dcb44c9a 904
030a0779
VK
905/**
906 * Code translation structure
907 */
bc858635
VK
908typedef struct __CODE_TO_TEXT
909{
910 int code;
911 const TCHAR *text;
912} CODE_TO_TEXT;
913
e2e66145
VK
914/**
915 * getopt() prototype if needed
916 */
df9812a9 917#if USE_BUNDLED_GETOPT
99e50bb7 918#include <netxms_getopt.h>
3046f9a4
VK
919#endif
920
921
f2fdf1b5
VK
922//
923// Win32 API functions missing under WinCE
924//
925
c32b805a 926#if defined(UNDER_CE) && defined(__cplusplus)
f2fdf1b5
VK
927
928inline void GetSystemTimeAsFileTime(LPFILETIME pFt)
929{
930 SYSTEMTIME sysTime;
cc022855 931
f2fdf1b5
VK
932 GetSystemTime(&sysTime);
933 SystemTimeToFileTime(&sysTime, pFt);
934}
935
936#endif // UNDER_CE
937
938
3d1cb7d6
VK
939//
940// Structures for opendir() / readdir() / closedir()
941//
942
943#ifdef _WIN32
944
7f9e0c00 945typedef struct dirent
3d1cb7d6
VK
946{
947 long d_ino; /* inode number (not used by MS-DOS) */
948 int d_namlen; /* Name length */
949 char d_name[257]; /* file name */
950} _DIRECT;
951
952typedef struct _dir_struc
953{
954 char *start; /* Starting position */
955 char *curr; /* Current position */
956 long size; /* Size of string table */
957 long nfiles; /* number if filenames in table */
7f9e0c00 958 struct dirent dirstr; /* Directory structure to return */
3d1cb7d6
VK
959} DIR;
960
5ea2db30
VK
961#ifdef UNICODE
962
963typedef struct dirent_w
964{
965 long d_ino; /* inode number (not used by MS-DOS) */
966 int d_namlen; /* Name length */
967 WCHAR d_name[257]; /* file name */
968} _DIRECTW;
969
970typedef struct _dir_struc_w
971{
972 WCHAR *start; /* Starting position */
973 WCHAR *curr; /* Current position */
974 long size; /* Size of string table */
975 long nfiles; /* number if filenames in table */
976 struct dirent_w dirstr; /* Directory structure to return */
977} DIRW;
978
979#define _TDIR DIRW
980#define _TDIRECT _DIRECTW
981#define _tdirent dirent_w
982
983#else
984
985#define _TDIR DIR
986#define _TDIRECT _DIRECT
987#define _tdirent dirent
988
37d62364
AK
989#endif
990
76b1d3d8
VK
991#else /* not _WIN32 */
992
993typedef struct dirent_w
994{
995 long d_ino; /* inode number */
996 WCHAR d_name[257]; /* file name */
997} _DIRECTW;
998
999typedef struct _dir_struc_w
1000{
1001 DIR *dir; /* Original non-unicode structure */
1002 struct dirent_w dirstr; /* Directory structure to return */
1003} DIRW;
1004
3d1cb7d6
VK
1005#endif /* _WIN32 */
1006
1007
e9246d26
VK
1008//
1009// Functions
1010//
1011
babb8280 1012#if WORDS_BIGENDIAN
43d92b4c
VK
1013#define htonq(x) (x)
1014#define ntohq(x) (x)
9f20696e
VK
1015#define htond(x) (x)
1016#define ntohd(x) (x)
babb8280
VK
1017#define SwapWideString(x)
1018#else
ca6ad6bb
VK
1019#ifdef HAVE_HTONLL
1020#define htonq(x) htonll(x)
1021#else
babb8280 1022#define htonq(x) __bswap_64(x)
ca6ad6bb
VK
1023#endif
1024#ifdef HAVE_NTOHLL
1025#define ntohq(x) ntohll(x)
1026#else
babb8280 1027#define ntohq(x) __bswap_64(x)
ca6ad6bb 1028#endif
babb8280
VK
1029#define htond(x) __bswap_double(x)
1030#define ntohd(x) __bswap_double(x)
1031#define SwapWideString(x) __bswap_wstr(x)
43d92b4c 1032#endif
15929b31 1033
55b33d4c
VK
1034#ifdef UNDER_CE
1035#define close(x) CloseHandle((HANDLE)(x))
1036#endif
1037
c81979bc 1038#ifdef __cplusplus
2e590d1a
VK
1039inline TCHAR *nx_strncpy(TCHAR *pszDest, const TCHAR *pszSrc, size_t nLen)
1040{
912b994d 1041#if defined(_WIN32) && (_MSC_VER >= 1400)
2e590d1a 1042 _tcsncpy_s(pszDest, nLen, pszSrc, _TRUNCATE);
912b994d 1043#else
2e590d1a
VK
1044 _tcsncpy(pszDest, pszSrc, nLen - 1);
1045 pszDest[nLen - 1] = 0;
912b994d 1046#endif
2e590d1a
VK
1047 return pszDest;
1048}
f3387429
VK
1049
1050#ifdef UNICODE
2e590d1a
VK
1051inline char *nx_strncpy_mb(char *pszDest, const char *pszSrc, size_t nLen)
1052{
f3387429 1053#if defined(_WIN32) && (_MSC_VER >= 1400)
2e590d1a 1054 strncpy_s(pszDest, nLen, pszSrc, _TRUNCATE);
f3387429 1055#else
2e590d1a
VK
1056 strncpy(pszDest, pszSrc, nLen - 1);
1057 pszDest[nLen - 1] = 0;
c81979bc 1058#endif
2e590d1a
VK
1059 return pszDest;
1060}
c81979bc 1061#else
f3387429 1062#define nx_strncpy_mb nx_strncpy
7b8b337e
VK
1063#endif
1064
967893bb 1065int LIBNETXMS_EXPORTABLE ConnectEx(SOCKET s, struct sockaddr *addr, int len, UINT32 timeout);
5e60b759
VK
1066int LIBNETXMS_EXPORTABLE SendEx(SOCKET hSocket, const void *data, size_t len, int flags, MUTEX mutex);
1067int LIBNETXMS_EXPORTABLE RecvEx(SOCKET hSocket, void *data, size_t len, int flags, UINT32 timeout);
b0608204 1068#endif /* __cplusplus */
c81979bc 1069
b50f1100 1070#ifdef __cplusplus
e9246d26
VK
1071extern "C"
1072{
b50f1100 1073#endif
735bac5c 1074
c5b523e2 1075#if defined(_WIN32) || !(HAVE_DECL___BSWAP_32)
735bac5c 1076UINT32 LIBNETXMS_EXPORTABLE __bswap_32(UINT32 dwVal);
c5b523e2 1077#endif
f52be742 1078#if defined(_WIN32) || !(HAVE_DECL___BSWAP_64)
735bac5c 1079UINT64 LIBNETXMS_EXPORTABLE __bswap_64(UINT64 qwVal);
64584976 1080#endif
735bac5c
VK
1081double LIBNETXMS_EXPORTABLE __bswap_double(double dVal);
1082void LIBNETXMS_EXPORTABLE __bswap_wstr(UCS2CHAR *pStr);
64584976 1083
076a55c4 1084#if !defined(_WIN32) && !defined(_NETWARE)
8b86c5dc 1085#if defined(UNICODE_UCS2) || defined(UNICODE_UCS4)
735bac5c
VK
1086void LIBNETXMS_EXPORTABLE __wcsupr(WCHAR *in);
1087#define wcsupr __wcsupr
cc022855 1088#endif
735bac5c
VK
1089void LIBNETXMS_EXPORTABLE __strupr(char *in);
1090#define strupr __strupr
7e679c4b 1091#endif
cc022855 1092
735bac5c 1093void LIBNETXMS_EXPORTABLE QSortEx(void *base, size_t nmemb, size_t size, void *arg,
b8a8d064
VK
1094 int (*compare)(const void *, const void *, void *));
1095
735bac5c 1096INT64 LIBNETXMS_EXPORTABLE GetCurrentTimeMs();
d35ed0aa 1097
735bac5c
VK
1098UINT64 LIBNETXMS_EXPORTABLE FileSizeW(const WCHAR *pszFileName);
1099UINT64 LIBNETXMS_EXPORTABLE FileSizeA(const char *pszFileName);
d35ed0aa
VK
1100#ifdef UNICODE
1101#define FileSize FileSizeW
1102#else
1103#define FileSize FileSizeA
1104#endif
670c7f3d 1105
735bac5c
VK
1106int LIBNETXMS_EXPORTABLE BitsInMask(UINT32 dwMask);
1107TCHAR LIBNETXMS_EXPORTABLE *IpToStr(UINT32 dwAddr, TCHAR *szBuffer);
e0f99bf0 1108#ifdef UNICODE
735bac5c 1109char LIBNETXMS_EXPORTABLE *IpToStrA(UINT32 dwAddr, char *szBuffer);
17b35ccc
VK
1110#else
1111#define IpToStrA IpToStr
e0f99bf0 1112#endif
8c75ad41 1113TCHAR LIBNETXMS_EXPORTABLE *Ip6ToStr(const BYTE *addr, TCHAR *buffer);
735bac5c 1114TCHAR LIBNETXMS_EXPORTABLE *SockaddrToStr(struct sockaddr *addr, TCHAR *buffer);
60557d06 1115
735bac5c
VK
1116UINT32 LIBNETXMS_EXPORTABLE ResolveHostNameA(const char *name);
1117UINT32 LIBNETXMS_EXPORTABLE ResolveHostNameW(const WCHAR *name);
08b214c6 1118#ifdef UNICODE
cfe20cce 1119#define ResolveHostName ResolveHostNameW
08b214c6 1120#else
cfe20cce 1121#define ResolveHostName ResolveHostNameA
08b214c6 1122#endif
a1dc75b0 1123
735bac5c
VK
1124void LIBNETXMS_EXPORTABLE *nx_memdup(const void *data, size_t size);
1125void LIBNETXMS_EXPORTABLE nx_memswap(void *block1, void *block2, size_t size);
31521248 1126
735bac5c
VK
1127WCHAR LIBNETXMS_EXPORTABLE *BinToStrW(const BYTE *data, size_t size, WCHAR *pStr);
1128char LIBNETXMS_EXPORTABLE *BinToStrA(const BYTE *data, size_t size, char *pStr);
d7970ee7
VK
1129#ifdef UNICODE
1130#define BinToStr BinToStrW
1131#else
1132#define BinToStr BinToStrA
1133#endif
1134
735bac5c
VK
1135size_t LIBNETXMS_EXPORTABLE StrToBinW(const WCHAR *pStr, BYTE *data, size_t size);
1136size_t LIBNETXMS_EXPORTABLE StrToBinA(const char *pStr, BYTE *data, size_t size);
52db3ed1
VK
1137#ifdef UNICODE
1138#define StrToBin StrToBinW
1139#else
1140#define StrToBin StrToBinA
1141#endif
cc022855 1142
735bac5c 1143TCHAR LIBNETXMS_EXPORTABLE *MACToStr(const BYTE *data, TCHAR *pStr);
b50f1100 1144
735bac5c
VK
1145void LIBNETXMS_EXPORTABLE StrStripA(char *pszStr);
1146void LIBNETXMS_EXPORTABLE StrStripW(WCHAR *pszStr);
b07c50cc
VK
1147#ifdef UNICODE
1148#define StrStrip StrStripW
1149#else
1150#define StrStrip StrStripA
1151#endif
1152
735bac5c
VK
1153const char LIBNETXMS_EXPORTABLE *ExtractWordA(const char *line, char *buffer);
1154const WCHAR LIBNETXMS_EXPORTABLE *ExtractWordW(const WCHAR *line, WCHAR *buffer);
ada97259
VK
1155#ifdef UNICODE
1156#define ExtractWord ExtractWordW
1157#else
1158#define ExtractWord ExtractWordA
1159#endif
1160
735bac5c
VK
1161int LIBNETXMS_EXPORTABLE NumCharsA(const char *pszStr, char ch);
1162int LIBNETXMS_EXPORTABLE NumCharsW(const WCHAR *pszStr, WCHAR ch);
3583a400
VK
1163#ifdef UNICODE
1164#define NumChars NumCharsW
1165#else
1166#define NumChars NumCharsA
1167#endif
ada97259 1168
735bac5c
VK
1169void LIBNETXMS_EXPORTABLE RemoveTrailingCRLFA(char *str);
1170void LIBNETXMS_EXPORTABLE RemoveTrailingCRLFW(WCHAR *str);
35f836fe
VK
1171#ifdef UNICODE
1172#define RemoveTrailingCRLF RemoveTrailingCRLFW
1173#else
1174#define RemoveTrailingCRLF RemoveTrailingCRLFA
cafe592d
VK
1175#endif
1176
4893b4aa
VK
1177BOOL LIBNETXMS_EXPORTABLE RegexpMatchA(const char *str, const char *expr, bool matchCase);
1178BOOL LIBNETXMS_EXPORTABLE RegexpMatchW(const WCHAR *str, const WCHAR *expr, bool matchCase);
cafe592d
VK
1179#ifdef UNICODE
1180#define RegexpMatch RegexpMatchW
1181#else
1182#define RegexpMatch RegexpMatchA
35f836fe
VK
1183#endif
1184
735bac5c
VK
1185const TCHAR LIBNETXMS_EXPORTABLE *ExpandFileName(const TCHAR *name, TCHAR *buffer, size_t bufSize, bool allowShellCommand);
1186void LIBNETXMS_EXPORTABLE Trim(TCHAR *str);
1187bool LIBNETXMS_EXPORTABLE MatchString(const TCHAR *pattern, const TCHAR *str, bool matchCase);
1188TCHAR LIBNETXMS_EXPORTABLE **SplitString(const TCHAR *source, TCHAR sep, int *numStrings);
ada97259 1189
f7794b68 1190#ifdef __cplusplus
735bac5c 1191BOOL LIBNETXMS_EXPORTABLE IsValidObjectName(const TCHAR *pszName, BOOL bExtendedChars = FALSE);
f7794b68 1192#endif
735bac5c
VK
1193BOOL LIBNETXMS_EXPORTABLE IsValidScriptName(const TCHAR *pszName);
1194/* deprecated */ void LIBNETXMS_EXPORTABLE TranslateStr(TCHAR *pszString, const TCHAR *pszSubStr, const TCHAR *pszReplace);
1195const TCHAR LIBNETXMS_EXPORTABLE *GetCleanFileName(const TCHAR *pszFileName);
1196void LIBNETXMS_EXPORTABLE GetOSVersionString(TCHAR *pszBuffer, int nBufSize);
1197BYTE LIBNETXMS_EXPORTABLE *LoadFile(const TCHAR *pszFileName, UINT32 *pdwFileSize);
08b214c6 1198#ifdef UNICODE
735bac5c 1199BYTE LIBNETXMS_EXPORTABLE *LoadFileA(const char *pszFileName, UINT32 *pdwFileSize);
08b214c6
VK
1200#else
1201#define LoadFileA LoadFile
1202#endif
1203
735bac5c
VK
1204UINT32 LIBNETXMS_EXPORTABLE CalculateCRC32(const unsigned char *data, UINT32 size, UINT32 dwCRC);
1205void LIBNETXMS_EXPORTABLE CalculateMD5Hash(const unsigned char *data, size_t nbytes, unsigned char *hash);
1206void LIBNETXMS_EXPORTABLE MD5HashForPattern(const unsigned char *data, size_t patternSize, size_t fullSize, BYTE *hash);
1207void LIBNETXMS_EXPORTABLE CalculateSHA1Hash(unsigned char *data, size_t nbytes, unsigned char *hash);
1208void LIBNETXMS_EXPORTABLE SHA1HashForPattern(unsigned char *data, size_t patternSize, size_t fullSize, unsigned char *hash);
1209BOOL LIBNETXMS_EXPORTABLE CalculateFileMD5Hash(const TCHAR *pszFileName, BYTE *pHash);
1210BOOL LIBNETXMS_EXPORTABLE CalculateFileSHA1Hash(const TCHAR *pszFileName, BYTE *pHash);
1211BOOL LIBNETXMS_EXPORTABLE CalculateFileCRC32(const TCHAR *pszFileName, UINT32 *pResult);
66c04cc7 1212
735bac5c
VK
1213void LIBNETXMS_EXPORTABLE ICEEncryptData(const BYTE *in, int inLen, BYTE *out, const BYTE *key);
1214void LIBNETXMS_EXPORTABLE ICEDecryptData(const BYTE *in, int inLen, BYTE *out, const BYTE *key);
4e2debcc 1215
735bac5c 1216BOOL LIBNETXMS_EXPORTABLE DecryptPassword(const TCHAR *login, const TCHAR *encryptedPasswd, TCHAR *decryptedPasswd);
6b1282e7 1217
735bac5c 1218UINT32 LIBNETXMS_EXPORTABLE IcmpPing(UINT32 dwAddr, int iNumRetries, UINT32 dwTimeout, UINT32 *pdwRTT, UINT32 dwPacketSize);
4826c8a5 1219
735bac5c 1220int LIBNETXMS_EXPORTABLE NxDCIDataTypeFromText(const TCHAR *pszText);
aa13cfd9 1221
735bac5c
VK
1222HMODULE LIBNETXMS_EXPORTABLE DLOpen(const TCHAR *pszLibName, TCHAR *pszErrorText);
1223void LIBNETXMS_EXPORTABLE DLClose(HMODULE hModule);
1224void LIBNETXMS_EXPORTABLE *DLGetSymbolAddr(HMODULE hModule, const char *pszSymbol, TCHAR *pszErrorText);
aa13cfd9 1225
735bac5c
VK
1226bool LIBNETXMS_EXPORTABLE ExtractNamedOptionValueW(const WCHAR *optString, const WCHAR *option, WCHAR *buffer, int bufSize);
1227bool LIBNETXMS_EXPORTABLE ExtractNamedOptionValueAsBoolW(const WCHAR *optString, const WCHAR *option, bool defVal);
1228long LIBNETXMS_EXPORTABLE ExtractNamedOptionValueAsIntW(const WCHAR *optString, const WCHAR *option, long defVal);
289d126b 1229
735bac5c
VK
1230bool LIBNETXMS_EXPORTABLE ExtractNamedOptionValueA(const char *optString, const char *option, char *buffer, int bufSize);
1231bool LIBNETXMS_EXPORTABLE ExtractNamedOptionValueAsBoolA(const char *optString, const char *option, bool defVal);
1232long LIBNETXMS_EXPORTABLE ExtractNamedOptionValueAsIntA(const char *optString, const char *option, long defVal);
289d126b
VK
1233
1234#ifdef UNICODE
1235#define ExtractNamedOptionValue ExtractNamedOptionValueW
1236#define ExtractNamedOptionValueAsBool ExtractNamedOptionValueAsBoolW
1237#define ExtractNamedOptionValueAsInt ExtractNamedOptionValueAsIntW
1238#else
1239#define ExtractNamedOptionValue ExtractNamedOptionValueA
1240#define ExtractNamedOptionValueAsBool ExtractNamedOptionValueAsBoolA
1241#define ExtractNamedOptionValueAsInt ExtractNamedOptionValueAsIntA
1242#endif
ae9cddaf 1243
bc858635 1244#ifdef __cplusplus
735bac5c 1245const TCHAR LIBNETXMS_EXPORTABLE *CodeToText(int iCode, CODE_TO_TEXT *pTranslator, const TCHAR *pszDefaultText = _T("Unknown"));
bc858635 1246#else
735bac5c 1247const TCHAR LIBNETXMS_EXPORTABLE *CodeToText(int iCode, CODE_TO_TEXT *pTranslator, const TCHAR *pszDefaultText);
bc858635
VK
1248#endif
1249
aa13cfd9 1250#ifdef _WIN32
735bac5c
VK
1251TCHAR LIBNETXMS_EXPORTABLE *GetSystemErrorText(UINT32 dwError, TCHAR *pszBuffer, size_t iBufSize);
1252BOOL LIBNETXMS_EXPORTABLE GetWindowsVersionString(TCHAR *versionString, int strSize);
1253INT64 LIBNETXMS_EXPORTABLE GetProcessRSS();
aa13cfd9 1254#endif
696fc54f
VK
1255
1256#if !(HAVE_DAEMON)
735bac5c 1257int LIBNETXMS_EXPORTABLE daemon(int nochdir, int noclose);
696fc54f 1258#endif
4332e9d8 1259
735bac5c 1260UINT32 LIBNETXMS_EXPORTABLE inet_addr_w(const WCHAR *pszAddr);
268774a0 1261
4332e9d8 1262#ifndef _WIN32
735bac5c
VK
1263BOOL LIBNETXMS_EXPORTABLE SetDefaultCodepage(const char *cp);
1264int LIBNETXMS_EXPORTABLE WideCharToMultiByte(int iCodePage, UINT32 dwFlags, const WCHAR *pWideCharStr,
1265 int cchWideChar, char *pByteStr, int cchByteChar,
1266 char *pDefaultChar, BOOL *pbUsedDefChar);
1267int LIBNETXMS_EXPORTABLE MultiByteToWideChar(int iCodePage, UINT32 dwFlags, const char *pByteStr,
1268 int cchByteChar, WCHAR *pWideCharStr,
1269 int cchWideChar);
04dbaf62 1270
6b93c954 1271#if !defined(UNICODE_UCS2) || !HAVE_WCSLEN
735bac5c 1272int LIBNETXMS_EXPORTABLE ucs2_strlen(const UCS2CHAR *pStr);
6b93c954
VK
1273#endif
1274#if !defined(UNICODE_UCS2) || !HAVE_WCSNCPY
735bac5c 1275UCS2CHAR LIBNETXMS_EXPORTABLE *ucs2_strncpy(UCS2CHAR *pDst, const UCS2CHAR *pSrc, int nDstLen);
6b93c954
VK
1276#endif
1277#if !defined(UNICODE_UCS2) || !HAVE_WCSDUP
b6ec31bb 1278UCS2CHAR LIBNETXMS_EXPORTABLE *ucs2_strdup(const UCS2CHAR *pStr);
4332e9d8 1279#endif
8b86c5dc 1280
735bac5c
VK
1281size_t LIBNETXMS_EXPORTABLE ucs2_to_mb(const UCS2CHAR *src, int srcLen, char *dst, int dstLen);
1282size_t LIBNETXMS_EXPORTABLE mb_to_ucs2(const char *src, int srcLen, UCS2CHAR *dst, int dstLen);
1283UCS2CHAR LIBNETXMS_EXPORTABLE *UCS2StringFromMBString(const char *pszString);
1284char LIBNETXMS_EXPORTABLE *MBStringFromUCS2String(const UCS2CHAR *pszString);
8b86c5dc 1285
735bac5c
VK
1286int LIBNETXMS_EXPORTABLE nx_wprintf(const WCHAR *format, ...);
1287int LIBNETXMS_EXPORTABLE nx_fwprintf(FILE *fp, const WCHAR *format, ...);
1288int LIBNETXMS_EXPORTABLE nx_swprintf(WCHAR *buffer, size_t size, const WCHAR *format, ...);
1289int LIBNETXMS_EXPORTABLE nx_vwprintf(const WCHAR *format, va_list args);
1290int LIBNETXMS_EXPORTABLE nx_vfwprintf(FILE *fp, const WCHAR *format, va_list args);
1291int LIBNETXMS_EXPORTABLE nx_vswprintf(WCHAR *buffer, size_t size, const WCHAR *format, va_list args);
04dbaf62 1292
735bac5c
VK
1293int LIBNETXMS_EXPORTABLE nx_wscanf(const WCHAR *format, ...);
1294int LIBNETXMS_EXPORTABLE nx_fwscanf(FILE *fp, const WCHAR *format, ...);
1295int LIBNETXMS_EXPORTABLE nx_swscanf(const WCHAR *str, const WCHAR *format, ...);
1296int LIBNETXMS_EXPORTABLE nx_vwscanf(const WCHAR *format, va_list args);
1297int LIBNETXMS_EXPORTABLE nx_vfwscanf(FILE *fp, const WCHAR *format, va_list args);
1298int LIBNETXMS_EXPORTABLE nx_vswscanf(const WCHAR *str, const WCHAR *format, va_list args);
25575d38 1299
3e39fcde 1300#endif /* _WIN32 */
8b86c5dc 1301
735bac5c
VK
1302WCHAR LIBNETXMS_EXPORTABLE *WideStringFromMBString(const char *pszString);
1303WCHAR LIBNETXMS_EXPORTABLE *WideStringFromUTF8String(const char *pszString);
1304char LIBNETXMS_EXPORTABLE *MBStringFromWideString(const WCHAR *pwszString);
1305char LIBNETXMS_EXPORTABLE *UTF8StringFromWideString(const WCHAR *pwszString);
cc022855 1306
3d1058ed 1307#ifdef _WITH_ENCRYPTION
735bac5c 1308WCHAR LIBNETXMS_EXPORTABLE *ERR_error_string_W(int nError, WCHAR *pwszBuffer);
3d1058ed
VK
1309#endif
1310
8b86c5dc 1311#ifdef UNICODE_UCS4
735bac5c
VK
1312size_t LIBNETXMS_EXPORTABLE ucs2_to_ucs4(const UCS2CHAR *src, int srcLen, WCHAR *dst, int dstLen);
1313size_t LIBNETXMS_EXPORTABLE ucs4_to_ucs2(const WCHAR *src, int srcLen, UCS2CHAR *dst, int dstLen);
1314size_t LIBNETXMS_EXPORTABLE ucs2_to_utf8(const UCS2CHAR *src, int srcLen, char *dst, int dstLen);
1315UCS2CHAR LIBNETXMS_EXPORTABLE *UCS2StringFromUCS4String(const WCHAR *pwszString);
1316WCHAR LIBNETXMS_EXPORTABLE *UCS4StringFromUCS2String(const UCS2CHAR *pszString);
b50f1100 1317#endif
8b86c5dc 1318
842c22f4 1319#if !defined(_WIN32) && !HAVE_WSTAT
735bac5c 1320int wstat(const WCHAR *_path, struct stat *_sbuf);
842c22f4
AK
1321#endif
1322
ef856d02 1323#if defined(UNICODE) && !defined(_WIN32)
d9b66a56 1324
f3387429 1325#if !HAVE_WPOPEN
735bac5c 1326FILE LIBNETXMS_EXPORTABLE *wpopen(const WCHAR *_command, const WCHAR *_type);
f3387429 1327#endif
8b86c5dc 1328#if !HAVE_WFOPEN
735bac5c 1329FILE LIBNETXMS_EXPORTABLE *wfopen(const WCHAR *_name, const WCHAR *_type);
8b86c5dc 1330#endif
8c2489aa 1331#if HAVE_FOPEN64 && !HAVE_WFOPEN64
735bac5c 1332FILE LIBNETXMS_EXPORTABLE *wfopen64(const WCHAR *_name, const WCHAR *_type);
8c2489aa 1333#endif
8b86c5dc 1334#if !HAVE_WOPEN
735bac5c 1335int LIBNETXMS_EXPORTABLE wopen(const WCHAR *, int, ...);
b50f1100 1336#endif
f3387429 1337#if !HAVE_WCHMOD
735bac5c 1338int LIBNETXMS_EXPORTABLE wchmod(const WCHAR *_name, int mode);
f3387429 1339#endif
b07c50cc 1340#if !HAVE_WCHDIR
735bac5c 1341int wchdir(const WCHAR *_path);
b07c50cc
VK
1342#endif
1343#if !HAVE_WMKDIR
735bac5c 1344int wmkdir(const WCHAR *_path, int mode);
b07c50cc
VK
1345#endif
1346#if !HAVE_WRMDIR
735bac5c 1347int wrmdir(const WCHAR *_path);
b07c50cc 1348#endif
ccc34207 1349#if !HAVE_WRENAME
735bac5c 1350int wrename(const WCHAR *_oldpath, const WCHAR *_newpath);
ccc34207
VK
1351#endif
1352#if !HAVE_WUNLINK
735bac5c 1353int wunlink(const WCHAR *_path);
ccc34207 1354#endif
b07c50cc 1355#if !HAVE_WREMOVE
735bac5c 1356int wremove(const WCHAR *_path);
b07c50cc
VK
1357#endif
1358#if !HAVE_WSYSTEM
735bac5c 1359int wsystem(const WCHAR *_cmd);
b07c50cc 1360#endif
dda7c270 1361#if !HAVE_WMKSTEMP
735bac5c 1362int wmkstemp(WCHAR *_template);
dda7c270 1363#endif
b07c50cc 1364#if !HAVE_WACCESS
735bac5c 1365int waccess(const WCHAR *_path, int mode);
b07c50cc 1366#endif
273da39a 1367#if !HAVE_WGETENV
735bac5c 1368WCHAR *wgetenv(const WCHAR *_string);
273da39a 1369#endif
f3387429 1370#if !HAVE_WCTIME
735bac5c 1371WCHAR *wctime(const time_t *timep);
f3387429 1372#endif
0186b5da 1373#if !HAVE_PUTWS
735bac5c 1374int putws(const WCHAR *s);
0186b5da 1375#endif
d49d7500 1376#if !HAVE_WCSERROR && HAVE_STRERROR
735bac5c 1377WCHAR *wcserror(int errnum);
d49d7500
VK
1378#endif
1379#if !HAVE_WCSERROR_R && HAVE_STRERROR_R
b0823d06 1380#if HAVE_POSIX_STRERROR_R
735bac5c 1381int wcserror_r(int errnum, WCHAR *strerrbuf, size_t buflen);
b0823d06 1382#else
735bac5c 1383WCHAR *wcserror_r(int errnum, WCHAR *strerrbuf, size_t buflen);
d49d7500 1384#endif
b0823d06 1385#endif
e05f8aaf 1386
ef856d02 1387#endif /* UNICODE && !_WIN32*/
e05f8aaf 1388
8b86c5dc 1389#if !HAVE_STRTOLL
735bac5c 1390INT64 LIBNETXMS_EXPORTABLE strtoll(const char *nptr, char **endptr, int base);
8b86c5dc
VK
1391#endif
1392#if !HAVE_STRTOULL
735bac5c 1393UINT64 LIBNETXMS_EXPORTABLE strtoull(const char *nptr, char **endptr, int base);
8b86c5dc 1394#endif
e05f8aaf
VK
1395
1396#if !HAVE_WCSTOLL
735bac5c 1397INT64 LIBNETXMS_EXPORTABLE wcstoll(const WCHAR *nptr, WCHAR **endptr, int base);
e05f8aaf
VK
1398#endif
1399#if !HAVE_WCSTOULL
735bac5c 1400UINT64 LIBNETXMS_EXPORTABLE wcstoull(const WCHAR *nptr, WCHAR **endptr, int base);
e05f8aaf 1401#endif
b50f1100 1402
2f56be29 1403#if !HAVE_WCSLWR && !defined(_WIN32)
735bac5c 1404WCHAR LIBNETXMS_EXPORTABLE *wcslwr(WCHAR *str);
fdf1ed50
VK
1405#endif
1406
4d978b4a 1407#if !HAVE_WCSCASECMP && !defined(_WIN32)
735bac5c 1408int LIBNETXMS_EXPORTABLE wcscasecmp(const wchar_t *s1, const wchar_t *s2);
4d978b4a
VK
1409#endif
1410
f4d2c9ba 1411#if !HAVE_WCSNCASECMP && !defined(_WIN32)
735bac5c 1412int LIBNETXMS_EXPORTABLE wcsncasecmp(const wchar_t *s1, const wchar_t *s2, size_t n);
f4d2c9ba
VK
1413#endif
1414
3d1cb7d6 1415#ifdef _WIN32
5ea2db30 1416#ifdef UNICODE
735bac5c
VK
1417DIRW LIBNETXMS_EXPORTABLE *wopendir(const WCHAR *filename);
1418struct dirent_w LIBNETXMS_EXPORTABLE *wreaddir(DIRW *dirp);
1419int LIBNETXMS_EXPORTABLE wclosedir(DIRW *dirp);
5ea2db30
VK
1420
1421#define _topendir wopendir
1422#define _treaddir wreaddir
1423#define _tclosedir wclosedir
1424#else
1425#define _topendir opendir
1426#define _treaddir readdir
1427#define _tclosedir closedir
1428#endif
1429
735bac5c
VK
1430DIR LIBNETXMS_EXPORTABLE *opendir(const char *filename);
1431struct dirent LIBNETXMS_EXPORTABLE *readdir(DIR *dirp);
1432int LIBNETXMS_EXPORTABLE closedir(DIR *dirp);
5ea2db30 1433
76b1d3d8
VK
1434#else /* not _WIN32 */
1435
735bac5c
VK
1436DIRW LIBNETXMS_EXPORTABLE *wopendir(const WCHAR *filename);
1437struct dirent_w LIBNETXMS_EXPORTABLE *wreaddir(DIRW *dirp);
1438int LIBNETXMS_EXPORTABLE wclosedir(DIRW *dirp);
76b1d3d8 1439
37d62364 1440#endif
3d1cb7d6 1441
7f9e0c00 1442#if defined(_WIN32) || !(HAVE_SCANDIR)
735bac5c
VK
1443int LIBNETXMS_EXPORTABLE scandir(const char *dir, struct dirent ***namelist,
1444 int (*select)(const struct dirent *),
1445 int (*compar)(const struct dirent **, const struct dirent **));
1446int LIBNETXMS_EXPORTABLE alphasort(const struct dirent **a, const struct dirent **b);
7f9e0c00
VK
1447#endif
1448
3bf0df9f
VK
1449TCHAR LIBNETXMS_EXPORTABLE *safe_fgetts(TCHAR *buffer, int len, FILE *f);
1450
55b33d4c 1451#ifdef UNDER_CE
3bf0df9f
VK
1452int LIBNETXMS_EXPORTABLE _topen(TCHAR *pszName, int nFlags, ...);
1453int LIBNETXMS_EXPORTABLE read(int hFile, void *pBuffer, size_t nBytes);
1454int LIBNETXMS_EXPORTABLE write(int hFile, void *pBuffer, size_t nBytes);
55b33d4c
VK
1455#endif
1456
967893bb 1457BOOL LIBNETXMS_EXPORTABLE nxlog_open(const TCHAR *logName, UINT32 flags, const TCHAR *msgModule,
d49d7500 1458 unsigned int msgCount, const TCHAR **messages);
9f2902ac
VK
1459void LIBNETXMS_EXPORTABLE nxlog_close(void);
1460void LIBNETXMS_EXPORTABLE nxlog_write(DWORD msg, WORD wType, const char *format, ...);
5945d50a 1461BOOL LIBNETXMS_EXPORTABLE nxlog_set_rotation_policy(int rotationMode, int maxLogSize, int historySize, const TCHAR *dailySuffix);
4addc3a3 1462BOOL LIBNETXMS_EXPORTABLE nxlog_rotate();
9113e749
VK
1463
1464typedef void (*NxLogConsoleWriter)(const TCHAR *, ...);
1465void LIBNETXMS_EXPORTABLE nxlog_set_console_writer(NxLogConsoleWriter writer);
f669df41
VK
1466
1467void LIBNETXMS_EXPORTABLE WriteToTerminal(const TCHAR *text);
6e383343
VK
1468void LIBNETXMS_EXPORTABLE WriteToTerminalEx(const TCHAR *format, ...)
1469#if !defined(UNICODE) && (defined(__GNUC__) || defined(__clang__))
1470 __attribute__ ((format(printf, 1, 2)))
1471#endif
1472;
9f2902ac 1473
37a7a862
VK
1474#ifdef _WIN32
1475int LIBNETXMS_EXPORTABLE mkstemp(char *tmpl);
1476int LIBNETXMS_EXPORTABLE wmkstemp(WCHAR *tmpl);
1477#ifdef UNICODE
1478#define _tmkstemp wmkstemp
1479#else
1480#define _tmkstemp mkstemp
1481#endif
1482#endif
1483
9b13553b
VK
1484#ifndef _WIN32
1485int strcat_s(char *dst, size_t dstSize, const char *src);
1486int wcscat_s(WCHAR *dst, size_t dstSize, const WCHAR *src);
1487#endif
1488
c57d020a
VK
1489#if !HAVE_STRPTIME
1490char LIBNETXMS_EXPORTABLE *strptime(const char *buf, const char *fmt, struct tm *_tm);
1491#endif
1492
1493#if !HAVE_TIMEGM
1494time_t LIBNETXMS_EXPORTABLE timegm(struct tm *_tm);
1495#endif
1496
b50f1100 1497#ifdef __cplusplus
e9246d26 1498}
b50f1100 1499#endif
e9246d26 1500
a7ff20a5
VK
1501
1502//
1503// C++ only finctions
1504//
1505
1506#ifdef __cplusplus
1507
240816b0
VK
1508TCHAR LIBNETXMS_EXPORTABLE *EscapeStringForXML(const TCHAR *str, int length);
1509String LIBNETXMS_EXPORTABLE EscapeStringForXML2(const TCHAR *str, int length = -1);
53c96e2d
VK
1510const char LIBNETXMS_EXPORTABLE *XMLGetAttr(const char **attrs, const char *name);
1511int LIBNETXMS_EXPORTABLE XMLGetAttrInt(const char **attrs, const char *name, int defVal);
967893bb 1512UINT32 LIBNETXMS_EXPORTABLE XMLGetAttrUINT32(const char **attrs, const char *name, UINT32 defVal);
53c96e2d
VK
1513bool LIBNETXMS_EXPORTABLE XMLGetAttrBoolean(const char **attrs, const char *name, bool defVal);
1514
1515#if !defined(_WIN32) && !defined(_NETWARE) && defined(NMS_THREADS_H_INCLUDED)
9113e749 1516void LIBNETXMS_EXPORTABLE StartMainLoop(ThreadFunction pfSignalHandler, ThreadFunction pfMain);
53c96e2d
VK
1517#endif
1518
a7ff20a5
VK
1519#endif
1520
e9246d26 1521#endif /* _nms_util_h_ */