CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/external/source/vncdll/winvnc/FileTransferItemInfo.cpp
Views: 11779
1
// Copyright (C) 2003 Dennis Syrovatsky. All Rights Reserved.
2
//
3
// This file is part of the VNC system.
4
//
5
// The VNC system 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
18
// USA.
19
//
20
// TightVNC distribution homepage on the Web: http://www.tightvnc.com/
21
//
22
// If the source code for the VNC system is not available from the place
23
// whence you received this file, check http://www.uk.research.att.com/vnc or contact
24
// the authors on [email protected] for information on obtaining it.
25
26
#include "FileTransferItemInfo.h"
27
#include "stdlib.h"
28
#include "stdio.h"
29
#include "string.h"
30
31
//////////////////////////////////////////////////////////////////////
32
// Construction/Destruction
33
//////////////////////////////////////////////////////////////////////
34
35
FileTransferItemInfo::FileTransferItemInfo()
36
{
37
m_NumEntries = 0;
38
m_pEntries = NULL;
39
}
40
41
FileTransferItemInfo::~FileTransferItemInfo()
42
{
43
Free();
44
}
45
46
void FileTransferItemInfo::Add(char *Name, unsigned int Size, unsigned int Data)
47
{
48
FTITEMINFO *pTemporary = new FTITEMINFO[m_NumEntries + 1];
49
if (m_NumEntries != 0)
50
memcpy(pTemporary, m_pEntries, m_NumEntries * sizeof(FTITEMINFO));
51
strcpy(pTemporary[m_NumEntries].Name, Name);
52
pTemporary[m_NumEntries].Size = Size;
53
pTemporary[m_NumEntries].Data = Data;
54
if (m_pEntries != NULL) {
55
delete [] m_pEntries;
56
m_pEntries = NULL;
57
}
58
m_pEntries = pTemporary;
59
pTemporary = NULL;
60
m_NumEntries++;
61
}
62
63
void FileTransferItemInfo::Free()
64
{
65
if (m_pEntries != NULL) {
66
delete [] m_pEntries;
67
m_pEntries = NULL;
68
}
69
m_NumEntries = 0;
70
}
71
72
char * FileTransferItemInfo::GetNameAt(int Number)
73
{
74
if ((Number >= 0) && (Number <= m_NumEntries))
75
return m_pEntries[Number].Name;
76
return NULL;
77
}
78
79
unsigned int FileTransferItemInfo::GetSizeAt(int Number)
80
{
81
if ((Number >= 0) && (Number <= m_NumEntries))
82
return m_pEntries[Number].Size;
83
return NULL;
84
}
85
86
unsigned int FileTransferItemInfo::GetDataAt(int Number)
87
{
88
if ((Number >= 0) && (Number <= m_NumEntries))
89
return m_pEntries[Number].Data;
90
return NULL;
91
}
92
93
int FileTransferItemInfo::GetNumEntries()
94
{
95
return m_NumEntries;
96
}
97
98
int FileTransferItemInfo::GetSummaryNamesLength()
99
{
100
size_t sumLen = 0;
101
for (int i = 0; i < m_NumEntries; i++)
102
sumLen += strlen(m_pEntries[i].Name);
103
return (int)sumLen;
104
}
105
106