-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfileTransferDriver.c
52 lines (44 loc) · 1.15 KB
/
fileTransferDriver.c
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
#include "./fileTransferDriver.h"
PendingFileUpload_t *inProgressFileUploads;
PendingFileUpload_t *getUploadInProgress( long fileId ) {
PendingFileUpload_t *curr = inProgressFileUploads;
while ( curr ) {
if ( curr->fileId == fileId ) {
return curr;
}
curr = inProgressFileUploads->next;
}
return 0;
}
int removeUploadInProgress( long fileId ) {
PendingFileUpload_t *prev = 0;
PendingFileUpload_t *curr = inProgressFileUploads;
while ( curr ) {
if ( curr->fileId == fileId ) {
if ( !prev ) {
inProgressFileUploads = curr->next;
return 0;
}
prev->next = curr->next;
return 0;
}
prev = curr;
curr = inProgressFileUploads->next;
}
return -1;//FIXME: return doesn't exist
}
void init_PendingFileUpload( PendingFileUpload_t *pendingFileUpload, long fileId ) {
pendingFileUpload->fileId = fileId;
pendingFileUpload->currentBytesUploaded = 0;
}
void addUploadInProgress(PendingFileUpload_t *inFileUpload) {
if ( !inProgressFileUploads ) {
inProgressFileUploads = inFileUpload;
return;
}
PendingFileUpload_t *curr = inProgressFileUploads;
while ( curr->next ) {
curr = curr->next;
}
curr->next = inFileUpload;
}