-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.h
More file actions
55 lines (47 loc) · 1.09 KB
/
client.h
File metadata and controls
55 lines (47 loc) · 1.09 KB
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
#ifndef CLIENT_H
#define CLIENT_H
#include <netdb.h>
#include <termios.h>
#include <sys/ioctl.h>
#define KEY_ENTER 10
#define KEY_BACKSPACE 127
#define CTRL_KEY(k) ((k) & 0x1F)
#define BUFF_CAPACITY 32
#define BUFSIZE 256
#define USERNAME_SIZE 14
// TODO: Vec of strings
struct append_buffer {
char** arr;
size_t len;
size_t capacity;
};
typedef struct {
int sockfd;
char buf[BUFSIZE];
char username[USERNAME_SIZE];
struct addrinfo hints;
struct addrinfo* res;
struct sockaddr_in* servaddr;
} net_info;
typedef struct {
struct termios orig_termios;
struct winsize win;
char input[BUFSIZE + USERNAME_SIZE];
int len;
int cols;
int rows;
} term_config;
void clear(void);
void init_buffer(struct append_buffer* abuff);
void append_to_buffer(struct append_buffer* abuff, char* str);
void free_abuff(struct append_buffer* abuff);
void window_resize(int sig);
void init_term(void);
void enable_raw_mode(void);
void revert_canon(void);
void handle_input(void);
void draw(void);
void print_bar(void);
void cleanup(void);
void recv_serv_msg(void);
#endif