externalized strings
[public/netxms.git] / src / server / libnxsrv / apinfo.cpp
CommitLineData
4cd1e46b
AK
1/*
2** NetXMS - Network Management System
3** Copyright (C) 2003-2013 Victor Kirhenshtein
4**
5** This program is free software; you can redistribute it and/or modify
6** it under the terms of the GNU Lesser General Public License as published by
7** the Free Software Foundation; either version 3 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 Lesser 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** File: apinfo.cpp
20**
21**/
22
23#include "libnxsrv.h"
24
de4af576
VK
25/**
26 * Constructor
27 */
b368969c 28AgentPolicyInfo::AgentPolicyInfo(NXCPMessage *msg)
4cd1e46b 29{
b368969c 30 m_size = msg->getFieldAsUInt32(VID_NUM_ELEMENTS);
4cd1e46b
AK
31 if (m_size > 0)
32 {
33 m_guidList = (BYTE *)malloc(UUID_LENGTH * m_size);
34 m_typeList = (int *)malloc(sizeof(int) * m_size);
35 m_serverList = (TCHAR **)malloc(sizeof(TCHAR *) * m_size);
36
37 UINT32 varId = VID_ELEMENT_LIST_BASE;
38 for(int i = 0; i < m_size; i++, varId += 7)
39 {
b368969c
VK
40 msg->getFieldAsBinary(varId++, &m_guidList[i * UUID_LENGTH], UUID_LENGTH);
41 m_typeList[i] = (int)msg->getFieldAsUInt16(varId++);
42 m_serverList[i] = msg->getFieldAsString(varId++);
4cd1e46b
AK
43 }
44 }
45 else
46 {
47 m_guidList = NULL;
48 m_typeList = NULL;
49 m_serverList = NULL;
50 }
51}
52
de4af576
VK
53/**
54 * Destructor
55 */
4cd1e46b
AK
56AgentPolicyInfo::~AgentPolicyInfo()
57{
58 for(int i = 0; i < m_size; i++)
59 safe_free(m_serverList[i]);
60 safe_free(m_serverList);
61 safe_free(m_typeList);
62 safe_free(m_guidList);
63}
64
de4af576
VK
65/**
66 * Get GUID
67 */
68uuid AgentPolicyInfo::getGuid(int index)
4cd1e46b
AK
69{
70 if ((index >= 0) && (index < m_size))
71 {
de4af576 72 return uuid(&m_guidList[index * UUID_LENGTH]);
4cd1e46b
AK
73 }
74 else
75 {
de4af576 76 return uuid::NULL_UUID;
4cd1e46b
AK
77 }
78}