alarm detaild view: intermediate commit
[public/netxms.git] / src / libnetxms / main.cpp
CommitLineData
5039dede
AK
1/*
2** NetXMS - Network Management System
3** Utility Library
68f384ea 4** Copyright (C) 2003-2010 Victor Kirhenshtein
5039dede
AK
5**
6** This program is free software; you can redistribute it and/or modify
68f384ea
VK
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
5039dede
AK
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**
68f384ea 16** You should have received a copy of the GNU Lesser General Public License
5039dede
AK
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//
28// Swap byte order in 64-bit integer
29//
30
31#if defined(_WIN32) || !(HAVE_DECL___BSWAP_64)
32
33QWORD LIBNETXMS_EXPORTABLE __bswap_64(QWORD qwVal)
34{
35 QWORD qwResult;
36 BYTE *sptr = (BYTE *)&qwVal;
37 BYTE *dptr = (BYTE *)&qwResult + 7;
38 int i;
39
40 for(i = 0; i < 8; i++, sptr++, dptr--)
41 *dptr = *sptr;
42
43 return qwResult;
44}
45
46#endif
47
48
49//
50// Swap bytes in double
51//
52
53double LIBNETXMS_EXPORTABLE __bswap_double(double dVal)
54{
55 double dResult;
56 BYTE *sptr = (BYTE *)&dVal;
57 BYTE *dptr = (BYTE *)&dResult + 7;
58 int i;
59
60 for(i = 0; i < 8; i++, sptr++, dptr--)
61 *dptr = *sptr;
62
63 return dResult;
64}
65
66
67//
68// Swap bytes in wide string (UCS-2)
69//
70
71void LIBNETXMS_EXPORTABLE __bswap_wstr(UCS2CHAR *pStr)
72{
73 UCS2CHAR *pch;
74
75 for(pch = pStr; *pch != 0; pch++)
76 *pch = htons(*pch);
77}
78
79
80//
81// strupr() implementation for non-windows platforms
82//
83
84#if !defined(_WIN32) && !defined(_NETWARE)
85
86void LIBNETXMS_EXPORTABLE strupr(char *in)
87{
88 char *p = in;
89
90 if (in == NULL)
91 {
92 return;
93 }
94
95 for (; *p != 0; p++)
96 {
97 // TODO: check/set locale
98 *p = toupper(*p);
99 }
100}
101
102#if defined(UNICODE_UCS2) || defined(UNICODE_UCS4)
103
104void LIBNETXMS_EXPORTABLE wcsupr(WCHAR *in)
105{
106 WCHAR *p = in;
107
108 if (in == NULL)
109 {
110 return;
111 }
112
113 for (; *p != 0; p++)
114 {
115 // TODO: check/set locale
116#if HAVE_TOWUPPER
117 *p = towupper(*p);
118#else
119 if (*p < 256)
120 {
121 *p = (WCHAR)toupper(*p);
122 }
123#endif
124 }
125}
126
127#endif
128
129#endif
130
131
132//
133// DLL entry point
134//
135
136#ifdef _WIN32
137
138#ifndef UNDER_CE // FIXME
139BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
140{
141 if (dwReason == DLL_PROCESS_ATTACH)
142 {
143 DisableThreadLibraryCalls(hInstance);
144 SEHInit();
145 }
146 return TRUE;
147}
148#endif // UNDER_CE
149
150#endif /* _WIN32 */
151
152
153//
154// NetWare library entry point
155//
156
157#ifdef _NETWARE
158
159int _init(void)
160{
161 return 0;
162}
163
164int _fini(void)
165{
166 return 0;
167}
168
169#endif