dload.cpp removed from makefile
[public/netxms.git] / include / nxcscpapi.h
CommitLineData
0d9c1b96
VK
1/*
2** NetXMS - Network Management System
3** CSCP API Library
4** Copyright (C) 2003, 2004 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: nxcscpapi.h
21**
22**/
23
24#ifndef _nxcscpapi_h_
25#define _nxcscpapi_h_
26
27
28#ifdef _WIN32
29#ifdef LIBNXCSCP_EXPORTS
30#define LIBNXCSCP_EXPORTABLE __declspec(dllexport)
31#else
32#define LIBNXCSCP_EXPORTABLE __declspec(dllimport)
33#endif
34#else /* _WIN32 */
35#define LIBNXCSCP_EXPORTABLE
36#endif
37
38
39//
40// Temporary buffer structure for RecvCSCPMessage() function
41//
42
43typedef struct
44{
45 DWORD dwBufSize;
46 DWORD dwBufPos;
47 char szBuffer[CSCP_TEMP_BUF_SIZE];
48} CSCP_BUFFER;
49
50
51//
52// Class for holding CSCP messages
53//
54
55class LIBNXCSCP_EXPORTABLE CSCPMessage
56{
57private:
58 WORD m_wCode;
59 DWORD m_dwId;
60 DWORD m_dwNumVar; // Number of variables
61 CSCP_DF **m_ppVarList; // List of variables
62
a7d07192 63 void *Set(DWORD dwVarId, BYTE bType, void *pValue, DWORD dwSize = 0);
0d9c1b96
VK
64 void *Get(DWORD dwVarId, BYTE bType);
65 DWORD FindVariable(DWORD dwVarId);
66
67public:
68 CSCPMessage();
69 CSCPMessage(CSCP_MESSAGE *pMsg);
70 ~CSCPMessage();
71
72 CSCP_MESSAGE *CreateMessage(void);
73
74 WORD GetCode(void) { return m_wCode; }
75 void SetCode(WORD wCode) { m_wCode = wCode; }
76
77 DWORD GetId(void) { return m_dwId; }
78 void SetId(DWORD dwId) { m_dwId = dwId; }
79
80 BOOL IsVariableExist(DWORD dwVarId) { return (FindVariable(dwVarId) != INVALID_INDEX) ? TRUE : FALSE; }
81
82 void SetVariable(DWORD dwVarId, WORD wValue) { Set(dwVarId, DT_INT16, &wValue); }
83 void SetVariable(DWORD dwVarId, DWORD dwValue) { Set(dwVarId, DT_INTEGER, &dwValue); }
84 void SetVariable(DWORD dwVarId, QWORD qwValue) { Set(dwVarId, DT_INT64, &qwValue); }
f86ffdd2 85 void SetVariable(DWORD dwVarId, double dValue) { Set(dwVarId, DT_FLOAT, &dValue); }
0d9c1b96
VK
86 void SetVariable(DWORD dwVarId, char *szValue) { Set(dwVarId, DT_STRING, szValue); }
87 void SetVariable(DWORD dwVarId, BYTE *pValue, DWORD dwSize) { Set(dwVarId, DT_BINARY, pValue, dwSize); }
a7d07192 88 void SetVariableToInt32Array(DWORD dwVarId, DWORD dwNumElements, DWORD *pdwData);
0d9c1b96
VK
89
90 DWORD GetVariableLong(DWORD dwVarId);
91 QWORD GetVariableInt64(DWORD dwVarId);
92 WORD GetVariableShort(DWORD dwVarId);
f86ffdd2 93 double GetVariableDouble(DWORD dwVarId);
0d9c1b96
VK
94 char *GetVariableStr(DWORD dwVarId, char *szBuffer = NULL, DWORD dwBufSize = 0);
95 DWORD GetVariableBinary(DWORD dwVarId, BYTE *pBuffer, DWORD dwBufSize);
a7d07192 96 DWORD GetVariableInt32Array(DWORD dwVarId, DWORD dwNumElements, DWORD *pdwBuffer);
0d9c1b96
VK
97
98 void DeleteAllVariables(void);
99};
100
101
102//
103// Functions
104//
105
106#ifdef __cplusplus
107extern "C" {
108#endif
109
4c20673b
VK
110int LIBNXCSCP_EXPORTABLE RecvCSCPMessage(SOCKET hSocket, CSCP_MESSAGE *pMsg,
111 CSCP_BUFFER *pBuffer, DWORD dwMaxMsgSize);
b9b4ec17
VK
112CSCP_MESSAGE LIBNXCSCP_EXPORTABLE *CreateRawCSCPMessage(WORD wCode, DWORD dwId,
113 DWORD dwDataSize, void *pData,
0d9c1b96
VK
114 CSCP_MESSAGE *pBuffer);
115char LIBNXCSCP_EXPORTABLE *CSCPMessageCodeName(WORD wCode, char *pszBuffer);
116
117#ifdef __cplusplus
118}
119#endif
120
121#endif /* _nxcscpapi_h_ */