-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.h
62 lines (50 loc) · 2.52 KB
/
client.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
#include<limits.h>
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<sys/types.h>
#include<sys/socket.h>
#include<netinet/in.h>
#include<errno.h>
#include<unistd.h>
#include<arpa/inet.h>
#include<pthread.h>
#include<sys/stat.h>
#include<openssl/md5.h>
struct ClientFileContent {
char *username;
char *password;
char ports[10][10];
char addresses[10][16];
};
struct FileDistributionCombination {
int hash_combo_zero_servers[8];
int hash_combo_one_servers[8];
int hash_combo_two_servers[8];
int hash_combo_three_servers[8];
};
static struct FileDistributionCombination destination_matrix = {
{4,1,1,2,2,3,3,4},
{1,2,2,3,3,4,4,1},
{2,3,3,4,4,1,1,2},
{3,4,4,1,1,2,2,3}};
struct FilePortionLocations {
int portion_locations[4][2];
};
// void setup_file_matrix(struct FileCombos *matrix);
void get_portion_size(char *file_content, unsigned long *body_size);
int check_locations_array(struct FilePortionLocations *locations);
void update_locations_array(char *server_message, struct FilePortionLocations *locations, int port_number);
void send_file (int first_server_number, int second_server_number, int portion_number, ssize_t portion_size, FILE *user_file, struct ClientFileContent *params, char *portion_file_name);
int create_socket_to_server(int server_number, struct ClientFileContent *params);
void send_to_server(char *message, int server_number, struct ClientFileContent *params);
void construct_put_header(char *filename, char *filesize, struct ClientFileContent *params, char *header);
void construct_getpn_header(char *filename, struct ClientFileContent *params, char *header);
void construct_get_header(char *filename, struct ClientFileContent *params, char *header, int server_number, int portion_number);
void construct_list_header(struct ClientFileContent *params, char *header);
void deleteSubstring(char *original_string,const char *sub_string);
void parse_client_conf_file(struct ClientFileContent *params, char *file_name);
int can_file_be_reconstructed (char *get_command, struct ClientFileContent *params, struct FileDistributionCombination *matrix, struct FilePortionLocations *locations);
int handle_get (char *get_command, struct ClientFileContent *params, struct FileDistributionCombination *matrix, struct FilePortionLocations *locations);
int handle_put (char *put_command, struct ClientFileContent *params, struct FileDistributionCombination *matrix);
int handle_list (char *list_command, struct ClientFileContent *params, struct FileDistributionCombination *matrix, struct FilePortionLocations *locations);