Sun code escaped.
[public/netxms.git] / src / server / libnxsrv / apinfo.cpp
CommitLineData
1f385e47
VK
1/*\r
2** NetXMS - Network Management System\r
967893bb 3** Copyright (C) 2003-2013 Victor Kirhenshtein\r
1f385e47
VK
4**\r
5** This program is free software; you can redistribute it and/or modify\r
6** it under the terms of the GNU Lesser General Public License as published by\r
7** the Free Software Foundation; either version 3 of the License, or\r
8** (at your option) any later version.\r
9**\r
10** This program is distributed in the hope that it will be useful,\r
11** but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
13** GNU General Public License for more details.\r
14**\r
15** You should have received a copy of the GNU Lesser General Public License\r
16** along with this program; if not, write to the Free Software\r
17** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.\r
18**\r
19** File: apinfo.cpp\r
20**\r
21**/\r
22\r
23#include "libnxsrv.h"\r
24\r
25\r
26//\r
27// Constructor\r
28//\r
29\r
30AgentPolicyInfo::AgentPolicyInfo(CSCPMessage *msg)\r
31{\r
32 m_size = msg->GetVariableLong(VID_NUM_ELEMENTS);\r
33 if (m_size > 0)\r
34 {\r
35 m_guidList = (BYTE *)malloc(UUID_LENGTH * m_size);\r
36 m_typeList = (int *)malloc(sizeof(int) * m_size);\r
37 m_serverList = (TCHAR **)malloc(sizeof(TCHAR *) * m_size);\r
38\r
967893bb 39 UINT32 varId = VID_ELEMENT_LIST_BASE;\r
1f385e47
VK
40 for(int i = 0; i < m_size; i++, varId += 7)\r
41 {\r
42 msg->GetVariableBinary(varId++, &m_guidList[i * UUID_LENGTH], UUID_LENGTH);\r
43 m_typeList[i] = (int)msg->GetVariableShort(varId++);\r
44 m_serverList[i] = msg->GetVariableStr(varId++);\r
45 }\r
46 }\r
47 else\r
48 {\r
49 m_guidList = NULL;\r
50 m_typeList = NULL;\r
51 m_serverList = NULL;\r
52 }\r
53}\r
54\r
55\r
56//\r
57// Destructor\r
58//\r
59\r
60AgentPolicyInfo::~AgentPolicyInfo()\r
61{\r
62 for(int i = 0; i < m_size; i++)\r
63 safe_free(m_serverList[i]);\r
64 safe_free(m_serverList);\r
65 safe_free(m_typeList);\r
66 safe_free(m_guidList);\r
67}\r
68\r
69\r
70//\r
71// Get GUID\r
72//\r
73\r
74bool AgentPolicyInfo::getGuid(int index, uuid_t guid)\r
75{\r
76 if ((index >= 0) && (index < m_size))\r
77 {\r
78 memcpy(guid, &m_guidList[index * UUID_LENGTH], UUID_LENGTH);\r
79 return true;\r
80 }\r
81 else\r
82 {\r
83 return false;\r
84 }\r
85}\r