-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfileTransferDriver.h
88 lines (71 loc) · 2.49 KB
/
fileTransferDriver.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#ifndef FILETRANSFERDRIVER_H
#define FILETRANSFERDRIVER_H
#include "net/connection.h"
#include "crypto.h"
#include "httpProcessing/commonHTTP.h"
#include "httpProcessing/realtimePacketParser.h"
struct DriverState_t;
typedef struct FileTransferDriver_ops_t FileTransferDriver_ops_t;
//This is state held from the init of the driver
typedef struct DriverState_t {
FileTransferDriver_ops_t *ops;
void *priv;
} DriverState_t;
//This is the state held for one file download
typedef struct FileDownloadState_t {
DriverState_t *driverState;
CryptoState_t *encryptionState;
Connection_t *connection;
HTTPHeaderState_t headerState;
HTTPParserState_t parserState;
int isEncrypted;
int isRangedRequest;
unsigned long rangeStart;
unsigned long rangeEnd;
int isEndRangeSet;
unsigned long encryptedRangeStart;
unsigned long encryptedRangeEnd;
unsigned long encryptedDataDownloaded;
unsigned long amountOfFileDecrypted;
int fileDownloadComplete;
long fileSize;
char *fileUrl;
char *requestedFilePath;
void *priv_connection;
} FileDownloadState_t;
//This is the state held for one file upload
typedef struct FileUploadState_t {
DriverState_t *driverState;
CryptoState_t *encryptionState;
Connection_t *connection;
HTTPHeaderState_t headerState;
HTTPParserState_t parserState;
char *fileUrl;
} FileUploadState_t;
typedef struct FileTransferDriver_ops_t {
//called once per driver init
int ( *prepDriverForFileTransfer )( DriverState_t* );
int ( *downloadInit )( FileDownloadState_t * );
//returns error code
int ( *downloadUpdate )( FileDownloadState_t *downloadState, char *outputBuffer,
int bufferMaxLength );
//@finishDownload doesn't return any data only cleans up
int ( *downloadFinish )( FileDownloadState_t * );
int ( *uploadInit )( FileUploadState_t * );
int ( *uploadUpdate )( FileUploadState_t *uploadState, const char *inputBuffer,
int dataLength );
//@finishUpload doesn't return any data only cleans up
int ( *finishUpload )( FileUploadState_t * );
} FileTransferDriver_ops_t;
typedef struct PendingFileUpload_t PendingFileUpload_t;
typedef struct PendingFileUpload_t {
long fileId;
long currentBytesUploaded;
PendingFileUpload_t *next;
void *priv_connection;
} PendingFileUpload_t;
PendingFileUpload_t *getUploadInProgress( long fileId );
int removeUploadInProgress( long fileId );
void init_PendingFileUpload( PendingFileUpload_t *pendingFileUpload, long fileId );
void addUploadInProgress(PendingFileUpload_t *inFileUpload);
#endif /* FILETRANSFERDRIVER_H */