-
Notifications
You must be signed in to change notification settings - Fork 0
/
helpers.h
38 lines (28 loc) · 964 Bytes
/
helpers.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
#ifndef _HELPERS_
#define _HELPERS_
#define BUFLEN 4096
#define LINELEN 1000
#define HOST "34.254.242.81"
#define PORT 8080
#define MAX_COMMAND strlen("enter_library")
#define MAX_BOOK_ID 10
#define MAX_PATH_LEN 50
#define PATH_ADDR "application/json"
enum my_boolean {
false, true
};
// shows the current error
void error(const char *msg);
// adds a line to a string message
void compute_message(char *message, const char *line);
// opens a connection with server host_ip on port portno, returns a socket
int open_connection(char *host_ip, int portno, int ip_type, int socket_type, int flag);
// closes a server connection on socket sockfd
void close_connection(int sockfd);
// send a message to a server
void send_to_server(int sockfd, char *message);
// receives and returns the message from a server
char *receive_from_server(int sockfd);
// extracts and returns a JSON from a server response
char *basic_extract_json_response(char *str);
#endif