Fixed Activate, Disable actions to be able change state againg without dci reselection.
[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
46
47//
48// Swap bytes in double
49//
50
51double 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
69void 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
84void 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
102void 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
137BOOL 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
157int _init(void)
158{
159 return 0;
160}
161
162int _fini(void)
163{
164 return 0;
165}
166
167#endif