Windows compatibility fixes
[public/netxms.git] / src / libnetxms / main.cpp
CommitLineData
b01a54ba
VK
1/*
2** NetXMS - Network Management System
3** Utility Library
4** Copyright (C) 2003 Victor Kirhenshtein
5**
6** This program is free software; you can redistribute it and/or modify
7** it under the terms of the GNU General Public License as published by
8** the Free Software Foundation; either version 2 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 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** $module: main.cpp
21**
22**/
23
24#include "libnetxms.h"
25
26
27//
28// Swap byte order in 64-bit integer
29//
30
f52be742 31#if defined(_WIN32) || !(HAVE_DECL___BSWAP_64)
b01a54ba
VK
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//
9f20696e
VK
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//
babb8280
VK
68// Swap bytes in wide string
69//
70
71void LIBNETXMS_EXPORTABLE __bswap_wstr(WCHAR *pStr)
72{
73 WCHAR *pch;
74
75 for(pch = pStr; *pch != 0; pch++)
76 *pch = htons(*pch);
77}
78
79
80//
b01a54ba
VK
81// strupr() implementation for non-windows platforms
82//
83
076a55c4 84#if !defined(_WIN32) && !defined(_NETWARE)
b01a54ba
VK
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#endif
103
104
105//
106// DLL entry point
107//
108
109#ifdef _WIN32
110
018fda4d 111#ifndef UNDER_CE // FIXME
b01a54ba
VK
112BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
113{
114 return TRUE;
115}
018fda4d 116#endif // UNDER_CE
b01a54ba
VK
117
118#endif /* _WIN32 */
3b1f0a0a
VK
119
120
121//
122// NetWare library entry point
123//
124
125#ifdef _NETWARE
126
127int _init(void)
128{
129 return 0;
130}
131
132int _fini(void)
133{
134 return 0;
135}
136
137#endif