"alarm details" view mostly working; event history for active alarms preserved; minor...
[public/netxms.git] / src / libnetxms / main.cpp
1 /*
2 ** NetXMS - Network Management System
3 ** Utility Library
4 ** Copyright (C) 2003-2012 Victor Kirhenshtein
5 **
6 ** This program is free software; you can redistribute it and/or modify
7 ** it under the terms of the GNU Lesser General Public License as published
8 ** by the Free Software Foundation; either version 3 of the License, or
9 ** (at your option) any later version.
10 **
11 ** This program is distributed in the hope that it will be useful,
12 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
13 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ** GNU General Public License for more details.
15 **
16 ** You should have received a copy of the GNU Lesser General Public License
17 ** along with this program; if not, write to the Free Software
18 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 **
20 ** File: main.cpp
21 **
22 **/
23
24 #include "libnetxms.h"
25
26 /**
27 * Swap byte order in 64-bit integer
28 */
29 #if defined(_WIN32) || !(HAVE_DECL___BSWAP_64)
30
31 QWORD LIBNETXMS_EXPORTABLE __bswap_64(QWORD qwVal)
32 {
33 QWORD qwResult;
34 BYTE *sptr = (BYTE *)&qwVal;
35 BYTE *dptr = (BYTE *)&qwResult + 7;
36 int i;
37
38 for(i = 0; i < 8; i++, sptr++, dptr--)
39 *dptr = *sptr;
40
41 return qwResult;
42 }
43
44 #endif
45
46
47 //
48 // Swap bytes in double
49 //
50
51 double LIBNETXMS_EXPORTABLE __bswap_double(double dVal)
52 {
53 double dResult;
54 BYTE *sptr = (BYTE *)&dVal;
55 BYTE *dptr = (BYTE *)&dResult + 7;
56 int i;
57
58 for(i = 0; i < 8; i++, sptr++, dptr--)
59 *dptr = *sptr;
60
61 return dResult;
62 }
63
64
65 //
66 // Swap bytes in wide string (UCS-2)
67 //
68
69 void LIBNETXMS_EXPORTABLE __bswap_wstr(UCS2CHAR *pStr)
70 {
71 UCS2CHAR *pch;
72
73 for(pch = pStr; *pch != 0; pch++)
74 *pch = htons(*pch);
75 }
76
77
78 //
79 // strupr() implementation for non-windows platforms
80 //
81
82 #if !defined(_WIN32) && !defined(_NETWARE)
83
84 void LIBNETXMS_EXPORTABLE strupr(char *in)
85 {
86 char *p = in;
87
88 if (in == NULL)
89 {
90 return;
91 }
92
93 for (; *p != 0; p++)
94 {
95 // TODO: check/set locale
96 *p = toupper(*p);
97 }
98 }
99
100 #if defined(UNICODE_UCS2) || defined(UNICODE_UCS4)
101
102 void LIBNETXMS_EXPORTABLE wcsupr(WCHAR *in)
103 {
104 WCHAR *p = in;
105
106 if (in == NULL)
107 {
108 return;
109 }
110
111 for (; *p != 0; p++)
112 {
113 // TODO: check/set locale
114 #if HAVE_TOWUPPER
115 *p = towupper(*p);
116 #else
117 if (*p < 256)
118 {
119 *p = (WCHAR)toupper(*p);
120 }
121 #endif
122 }
123 }
124
125 #endif
126
127 #endif
128
129
130 //
131 // DLL entry point
132 //
133
134 #ifdef _WIN32
135
136 #ifndef UNDER_CE // FIXME
137 BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
138 {
139 if (dwReason == DLL_PROCESS_ATTACH)
140 {
141 DisableThreadLibraryCalls(hInstance);
142 SEHInit();
143 }
144 return TRUE;
145 }
146 #endif // UNDER_CE
147
148 #endif /* _WIN32 */
149
150
151 //
152 // NetWare library entry point
153 //
154
155 #ifdef _NETWARE
156
157 int _init(void)
158 {
159 return 0;
160 }
161
162 int _fini(void)
163 {
164 return 0;
165 }
166
167 #endif