Files
threaded_network_chat/chat.h
2026-03-08 01:29:25 -06:00

61 lines
1.1 KiB
C++

#ifndef CHAT_H
#define CHAT_H
#ifndef _GLIBCXX_STRING
#include <string>
#endif
#ifndef _NETINET_IN_H
#include <netinet/in.h>
#endif
typedef enum {
NO_MODE = 0,
SERVER_MODE = 1,
CLIENT_MODE = 2
} chatmode_t;
typedef struct {
sockaddr_in new_addr;
socklen_t new_addr_siz;
int aux;
}wclient_args_t;
const int CURSOR_DEFAULT_POSITION_X = 2;
const int CURSOR_DEFAULT_POSITION_Y = 12;
const int LOG_LENGTH = 10;
int line_position = 0;
chatmode_t mode = NO_MODE;
struct timeval time_start;
struct timeval time_end;
int bytes_read;
int bytes_written;
int listen_port = 9999;
std::string listen_ip_address = "127.0.0.1";
std::string log_path;
int socket_descriptor_server;
int socket_descriptor_client;
pthread_t client_wait_thread;
void *await_client(void *a);
void clear_rows(int s, int e);
int count_lines(std::string p);
int file_disp(std::string p, int lnstart, int lncount = 10);
int log_append(std::string p, std::string ln);
int log_linect(std::string p);
void *client_poll(void);
void client_start(void);
void client_stop(void);
void *server_poll(void *a);
void server_start(int port);
void server_stop(void);
#endif