6333c82c6c58f124e0731f74fdd2f6c16d461be7
[public/netxms.git] / src / libnetxms / inline.cpp
1 /*
2 ** libnetxms - Common NetXMS utility library
3 ** Copyright (C) 2003, 2004 Victor Kirhenshtein
4 **
5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version.
9 **
10 ** This program is distributed in the hope that it will be useful,
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ** GNU General Public License for more details.
14 **
15 ** You should have received a copy of the GNU General Public License
16 ** along with this program; if not, write to the Free Software
17 ** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 **
19 ** $module: inline.cpp
20 **
21 **/
22
23 #define LIBNETXMS_INLINE
24 #include "libnetxms.h"
25 #include <nms_agent.h>
26
27
28 //
29 // Functions defined as inline for C++ programs
30 //
31
32 extern "C" void LIBNETXMS_EXPORTABLE ret_string(TCHAR *rbuf, const TCHAR *value)
33 {
34 _tcsncpy(rbuf, value, MAX_RESULT_LENGTH - 1);
35 rbuf[MAX_RESULT_LENGTH - 1] = 0;
36 }
37
38 extern "C" void LIBNETXMS_EXPORTABLE ret_int(TCHAR *rbuf, LONG value)
39 {
40 _stprintf(rbuf, _T("%d"), value);
41 }
42
43 extern "C" void LIBNETXMS_EXPORTABLE ret_uint(TCHAR *rbuf, DWORD value)
44 {
45 _stprintf(rbuf, _T("%u"), value);
46 }
47
48 extern "C" void LIBNETXMS_EXPORTABLE ret_double(TCHAR *rbuf, double value)
49 {
50 _stprintf(rbuf, _T("%f"), value);
51 }
52
53 extern "C" void LIBNETXMS_EXPORTABLE ret_int64(TCHAR *rbuf, INT64 value)
54 {
55 #ifdef _WIN32
56 _stprintf(rbuf, _T("%I64d"), value);
57 #else /* _WIN32 */
58 _stprintf(rbuf, _T("%lld"), value);
59 #endif /* _WIN32 */
60 }
61
62 extern "C" void LIBNETXMS_EXPORTABLE ret_uint64(TCHAR *rbuf, QWORD value)
63 {
64 #ifdef _WIN32
65 _stprintf(rbuf, _T("%I64u"), value);
66 #else /* _WIN32 */
67 _stprintf(rbuf, _T("%llu"), value);
68 #endif /* _WIN32 */
69 }
70
71 extern "C" TCHAR LIBNETXMS_EXPORTABLE *nx_strncpy(TCHAR *pszDest, const TCHAR *pszSrc, int nLen)
72 {
73 _tcsncpy(pszDest, pszSrc, nLen - 1);
74 pszDest[nLen - 1] = 0;
75 return pszDest;
76 }