-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformat.c
56 lines (45 loc) · 1.6 KB
/
format.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
51
52
53
54
55
56
#include "format.h"
const char *err_bad_request = "Bad request\n";
const char *err_bad_file_size = "Bad file size\n";
const char *err_no_such_file = "No such file\n";
void print_client_usage() {
printf("./client <host>:<port> <method> [remote] [local]\n \
<host>\t\tAddress to conenct to.\n \
<port>\t\tPort to set up connection on.\n \
<method>\tMethod of request to send.\n \
[remote]\tOptional argument refering to remote filename\n \
[local]\tOptional argument refering to file on local system\n \
If <method> is any PUT, GET, or DELETE then [remote] and/or [local] are required\n");
}
void print_client_help() {
print_client_usage();
printf("Methods:\n \
LIST\t\t\tRequests a list of files on the server.\n \
PUT <remote> <local>\tUploads <local> file to serve as filename <remote>.\n \
GET <remote> <local>\tDownloads file named <remote> from server as filename <local>.\n \
DELETE <remote>\tDeletes file named <remote> on server.\n");
}
void print_connection_closed() {
printf("Connection closed\n");
}
void print_error_message(char *err) {
printf("%s\n", err);
}
void print_invalid_response() {
printf("Invalid response\n");
}
void print_received_too_much_data() {
printf("Received too much data\n");
}
void print_too_little_data() {
printf("Received too little data\n");
}
void print_success() {
printf("DELETE/PUT successful\n");
}
void print_temp_directory(char *temp_directory) {
fprintf(stdout, "%s\n", temp_directory);
}
void print_server_usage(void) {
fprintf(stderr, "./server <port>\n");
}