fixed conflicts with Cortex headers
[public/netxms.git] / src / libnetxms / main.cpp
CommitLineData
5039dede
AK
1/*
2** NetXMS - Network Management System
3** Utility Library
b1e9b6b3 4** Copyright (C) 2003-2012 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
b1e9b6b3
VK
26/**
27 * Swap byte order in 64-bit integer
28 */
5039dede
AK
29#if defined(_WIN32) || !(HAVE_DECL___BSWAP_64)
30
31QWORD 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
76fcb995
VK
46/**
47 * Swap bytes in double
48 */
5039dede
AK
49double LIBNETXMS_EXPORTABLE __bswap_double(double dVal)
50{
51 double dResult;
52 BYTE *sptr = (BYTE *)&dVal;
53 BYTE *dptr = (BYTE *)&dResult + 7;
54 int i;
55
56 for(i = 0; i < 8; i++, sptr++, dptr--)
57 *dptr = *sptr;
58
59 return dResult;
60}
61
76fcb995
VK
62/**
63 * Swap bytes in wide string (UCS-2)
64 */
5039dede
AK
65void LIBNETXMS_EXPORTABLE __bswap_wstr(UCS2CHAR *pStr)
66{
67 UCS2CHAR *pch;
68
69 for(pch = pStr; *pch != 0; pch++)
70 *pch = htons(*pch);
71}
72
5039dede
AK
73#if !defined(_WIN32) && !defined(_NETWARE)
74
76fcb995
VK
75/**
76 * strupr() implementation for non-windows platforms
77 */
735bac5c 78void LIBNETXMS_EXPORTABLE __strupr(char *in)
5039dede
AK
79{
80 char *p = in;
81
82 if (in == NULL)
83 {
84 return;
85 }
86
87 for (; *p != 0; p++)
88 {
89 // TODO: check/set locale
90 *p = toupper(*p);
91 }
92}
93
94#if defined(UNICODE_UCS2) || defined(UNICODE_UCS4)
95
76fcb995
VK
96/**
97 * wcsupr() implementation for non-windows platforms
98 */
735bac5c 99void LIBNETXMS_EXPORTABLE __wcsupr(WCHAR *in)
5039dede
AK
100{
101 WCHAR *p = in;
102
103 if (in == NULL)
104 {
105 return;
106 }
107
108 for (; *p != 0; p++)
109 {
110 // TODO: check/set locale
111#if HAVE_TOWUPPER
112 *p = towupper(*p);
113#else
114 if (*p < 256)
115 {
116 *p = (WCHAR)toupper(*p);
117 }
118#endif
119 }
120}
121
122#endif
123
124#endif
125
126
127//
128// DLL entry point
129//
130
131#ifdef _WIN32
132
133#ifndef UNDER_CE // FIXME
134BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
135{
136 if (dwReason == DLL_PROCESS_ATTACH)
137 {
138 DisableThreadLibraryCalls(hInstance);
139 SEHInit();
140 }
141 return TRUE;
142}
143#endif // UNDER_CE
144
145#endif /* _WIN32 */
146
147
148//
149// NetWare library entry point
150//
151
152#ifdef _NETWARE
153
154int _init(void)
155{
156 return 0;
157}
158
159int _fini(void)
160{
161 return 0;
162}
163
164#endif