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