Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 165944 | Differences between
and this patch

Collapse All | Expand All

(-)src-native-new/src/shared/TPTPUtil/dime.c (-2 / +16 lines)
Lines 14-19 Link Here
14
#include "tptp/TPTPCommon.h"
14
#include "tptp/TPTPCommon.h"
15
#include "tptp/TPTPTypes.h"
15
#include "tptp/TPTPTypes.h"
16
#include "tptp/TPTPUtils.h"
16
#include "tptp/TPTPUtils.h"
17
#include "tptp/TPTPErrorCode.h"
17
#include "tptp/dime.h"
18
#include "tptp/dime.h"
18
19
19
#include "tptp/TPTPMessageHeader.h"
20
#include "tptp/TPTPMessageHeader.h"
Lines 81-91 Link Here
81
82
82
tptp_int32 construct_dime_file_transfer(DIME_HEADER_PTR_T *p, char *fileName, tptp_int32 dataSize)
83
tptp_int32 construct_dime_file_transfer(DIME_HEADER_PTR_T *p, char *fileName, tptp_int32 dataSize)
83
{
84
{
85
	return construct_dime_file_transfer_error(p, fileName, dataSize, TPTP_OK);
86
}
87
88
tptp_int32 construct_dime_file_transfer_error(DIME_HEADER_PTR_T *p, char *fileName, tptp_int32 dataSize, int errCode)
89
{
84
	tptp_int32 status;
90
	tptp_int32 status;
85
	tptp_int32 fileNameLength = strlen(fileName)+1;
91
	tptp_int32 fileNameLength = strlen(fileName)+1;
92
	tptp_int32 dime_len;
86
	char *q;
93
	char *q;
87
94
88
	*p = (DIME_HEADER_PTR_T) tptp_malloc(sizeof(DIME_HEADER_T)+ fileNameLength);
95
	dime_len = sizeof(DIME_HEADER_T) + fileNameLength + 1;
96
	*p = (DIME_HEADER_PTR_T) tptp_malloc(dime_len);
89
	status = INIT_DIME_HEADER(*p);
97
	status = INIT_DIME_HEADER(*p);
90
	/* (*p)->data_length = buffer_length; */
98
	/* (*p)->data_length = buffer_length; */
91
99
Lines 96-103 Link Here
96
	(*p)->data_length = (tptp_uint32) dataSize;
104
	(*p)->data_length = (tptp_uint32) dataSize;
97
	/*(*p)->data = buffer; we don't add the buffer to avoid the copy */
105
	/*(*p)->data = buffer; we don't add the buffer to avoid the copy */
98
106
107
	(*p)->options_length = 1;
108
	*(q + fileNameLength) = (char) errCode;
99
109
100
	return sizeof(DIME_HEADER_T) + fileNameLength ; /* may have to add options + type */
110
	return dime_len; /* may have to add options + type */
101
}
111
}
102
112
103
113
Lines 120-125 Link Here
120
	return (construct_dime_file_transfer(p, buffer, dataSize)) ;
130
	return (construct_dime_file_transfer(p, buffer, dataSize)) ;
121
}
131
}
122
132
133
void free_dime (DIME_HEADER_PTR_T p) 
134
{
135
	tptp_free (p);
136
}
123
137
124
tptp_int32  is_valid_header(DIME_HEADER_PTR_T p, tptp_int32 amount_read)
138
tptp_int32  is_valid_header(DIME_HEADER_PTR_T p, tptp_int32 amount_read)
125
{
139
{
(-)src-native-new/src/shared/TPTPUtil/TPTUtil.def (+2 lines)
Lines 56-62 Link Here
56
	XMutexDelete
56
	XMutexDelete
57
	printCurrentSysError			
57
	printCurrentSysError			
58
	construct_dime_file_transfer
58
	construct_dime_file_transfer
59
	construct_dime_file_transfer_error
59
	construct_dime_console
60
	construct_dime_console
61
	free_dime
60
	init_dime_header
62
	init_dime_header
61
	get_dime_id
63
	get_dime_id
62
	get_dime_length
64
	get_dime_length
(-)src-native-new/src/agents/FileTransferAgent/FileTransferAgent.cpp (-1 / +17 lines)
Lines 204-213 Link Here
204
204
205
	MAKE_NBO_DIME_HEADER((char *) dp);
205
	MAKE_NBO_DIME_HEADER((char *) dp);
206
	rc = sendData(destinationID, buffer, bufferLength, dp, dimeLength);
206
	rc = sendData(destinationID, buffer, bufferLength, dp, dimeLength);
207
	FREE_DIME (dp);
207
208
208
	return 0;
209
	return 0;
209
}
210
}
210
211
212
void FileTransferAgent::sendError(tptp_int32 destinationID, char *fileName, int errCode)
213
{
214
	DIME_HEADER_PTR_T dp;
215
	tptp_int32 dimeLength;
216
217
	dimeLength = MAKE_DIME_FILE_TRANSFER_ERROR(&dp, fileName, 0, errCode);
218
	DIME_START(dp);
219
	DIME_END(dp);
220
221
	MAKE_NBO_DIME_HEADER((char *) dp);
222
	sendData(destinationID, NULL, 0, dp, dimeLength);
223
	FREE_DIME (dp);
224
}
225
211
tptp_int32 FileTransferAgent::openAndSendFile(tptp_int32 clientId, char *localFile, char *remoteFile)
226
tptp_int32 FileTransferAgent::openAndSendFile(tptp_int32 clientId, char *localFile, char *remoteFile)
212
{
227
{
213
	char buffer[BLOCK_SIZE+1]; 
228
	char buffer[BLOCK_SIZE+1]; 
Lines 222-227 Link Here
222
	fp = fopen(remoteFile, "rb");
237
	fp = fopen(remoteFile, "rb");
223
	if (fp == NULL) {
238
	if (fp == NULL) {
224
		TPTP_LOG_ERROR_MSG(this, "FileTransferAgent getFile remote NULL");
239
		TPTP_LOG_ERROR_MSG(this, "FileTransferAgent getFile remote NULL");
240
		sendError(clientId, localFile, FILE_NOT_FOUND);
225
		return ret;
241
		return ret;
226
	}
242
	}
227
243
Lines 251-257 Link Here
251
267
252
				recType = DIME_MESSAGE_END;
268
				recType = DIME_MESSAGE_END;
253
			}
269
			}
254
		}
270
		}		
255
		ret = this->sendFileData(clientId, buffer, n, recType, localFile);
271
		ret = this->sendFileData(clientId, buffer, n, recType, localFile);
256
		//TPTP_LOG_DEBUG_MSG1(this, "Send %d bytes of data", n);
272
		//TPTP_LOG_DEBUG_MSG1(this, "Send %d bytes of data", n);
257
		i++;
273
		i++;
(-)src-native-new/include/tptp/dime.h (+4 lines)
Lines 52-59 Link Here
52
52
53
tptp_int32 init_dime_header(DIME_HEADER_PTR_T p);
53
tptp_int32 init_dime_header(DIME_HEADER_PTR_T p);
54
tptp_int32 construct_dime_file_transfer(DIME_HEADER_PTR_T *p, char *fileName, tptp_int32 length);
54
tptp_int32 construct_dime_file_transfer(DIME_HEADER_PTR_T *p, char *fileName, tptp_int32 length);
55
tptp_int32 construct_dime_file_transfer_error(DIME_HEADER_PTR_T *p, char *fileName, tptp_int32 length, int errCode);
55
tptp_int32 construct_dime_console(DIME_HEADER_PTR_T *p,  PID processId, tptp_int32 consoleType, tptp_int32 dataSize) ;
56
tptp_int32 construct_dime_console(DIME_HEADER_PTR_T *p,  PID processId, tptp_int32 consoleType, tptp_int32 dataSize) ;
56
char *get_dime_id(DIME_HEADER_PTR_T p);
57
char *get_dime_id(DIME_HEADER_PTR_T p);
58
void free_dime(DIME_HEADER_PTR_T p);
57
59
58
PID get_dime_process_id(DIME_HEADER_PTR_T p);
60
PID get_dime_process_id(DIME_HEADER_PTR_T p);
59
tptp_int32 get_dime_console_type(DIME_HEADER_PTR_T p);
61
tptp_int32 get_dime_console_type(DIME_HEADER_PTR_T p);
Lines 66-72 Link Here
66
#define MAKE_NBO_DIME_HEADER(b) make_dime_header(b)
68
#define MAKE_NBO_DIME_HEADER(b) make_dime_header(b)
67
#define MAKE_DIME_HEADER(b) make_dime_header(b)
69
#define MAKE_DIME_HEADER(b) make_dime_header(b)
68
#define MAKE_DIME_FILE_TRANSFER(xp, b, c) construct_dime_file_transfer(xp, b, c)
70
#define MAKE_DIME_FILE_TRANSFER(xp, b, c) construct_dime_file_transfer(xp, b, c)
71
#define MAKE_DIME_FILE_TRANSFER_ERROR(xp, b, c, e) construct_dime_file_transfer_error(xp, b, c, e)
69
#define MAKE_DIME_CONSOLE(xp, id, ct, ds) construct_dime_console(xp, id, ct, ds)
72
#define MAKE_DIME_CONSOLE(xp, id, ct, ds) construct_dime_console(xp, id, ct, ds)
73
#define FREE_DIME(x)	free_dime(x)
70
#define DIME_START(xp) xp->mb = 0x1;
74
#define DIME_START(xp) xp->mb = 0x1;
71
#define DIME_END(xp) xp->me   = 0x1;
75
#define DIME_END(xp) xp->me   = 0x1;
72
76
(-)src-native-new/include/tptp/agents/FileTransferAgent.h (-1 / +4 lines)
Lines 19-25 Link Here
19
#include "tptp/TPTPTypes.h"
19
#include "tptp/TPTPTypes.h"
20
#include "tptp/TPTPUtils.h"
20
#include "tptp/TPTPUtils.h"
21
21
22
22
#define FILE_TRANSFER_ERROR	1
23
#define FILE_NOT_FOUND 		2
24
#define FILE_READ_ERROR		3
23
25
24
using namespace std;
26
using namespace std;
25
27
Lines 41-46 Link Here
41
		tptp_int32 MapCommandNameToID(char* cmdName);
43
		tptp_int32 MapCommandNameToID(char* cmdName);
42
		tptp_int32 MapInterfaceNameToID(char* interfaceName);
44
		tptp_int32 MapInterfaceNameToID(char* interfaceName);
43
		tptp_int32 sendFileData(tptp_int32 destinationID, char buffer[], tptp_int32 bufferLength, tptp_int32 recType, char *fileName);
45
		tptp_int32 sendFileData(tptp_int32 destinationID, char buffer[], tptp_int32 bufferLength, tptp_int32 recType, char *fileName);
46
		void sendError(tptp_int32 destinationID, char *fileName, int errCode);
44
		tptp_list_t fileOpList;
47
		tptp_list_t fileOpList;
45
		Lock_t fileOpListLock;
48
		Lock_t fileOpListLock;
46
		tptp_int32 findFileRecordByName(const char *fileName, tptp_file_t *fileRec);
49
		tptp_int32 findFileRecordByName(const char *fileName, tptp_file_t *fileRec);

Return to bug 165944