created directory ./include/
This commit is contained in:
28
include/tcp-chat/client.h
Normal file
28
include/tcp-chat/client.h
Normal file
@@ -0,0 +1,28 @@
|
||||
#pragma once
|
||||
#include "tlibc/errors.h"
|
||||
#include "tlibc/string/str.h"
|
||||
|
||||
typedef struct Client Client;
|
||||
|
||||
Result(Client*) Client_create(str username, str password);
|
||||
void Client_free(Client* client);
|
||||
|
||||
/// @return username saved during client initialization
|
||||
str Client_getUserName(Client* client);
|
||||
|
||||
/// @return AES key calculated from password that can be used to encrypt user data
|
||||
Array(u8) Client_getUserDataKey(Client* client);
|
||||
|
||||
/// @param server_addr_cstr ip:port
|
||||
/// @param server_pk_base64 public key encoded by `RSA_serializePublicKey_base64()`
|
||||
Result(void) Client_connect(Client* client, cstr server_addr_cstr, cstr server_pk_base64);
|
||||
/// disconnect from current server
|
||||
void Client_disconnect(Client* client);
|
||||
|
||||
/// @param self connected client
|
||||
/// @param out_name owned by Client, fetched from server during Client_connect
|
||||
Result(void) Client_getServerName(Client* self, str* out_name);
|
||||
|
||||
/// @param self connected client
|
||||
/// @param out_name owned by Client, fetched from server during Client_connect
|
||||
Result(void) Client_getServerDescription(Client* self, str* out_desc);
|
||||
15
include/tcp-chat/common_constants.h
Normal file
15
include/tcp-chat/common_constants.h
Normal file
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
#include "tlibc/std.h"
|
||||
|
||||
#define USERNAME_SIZE_MIN 2
|
||||
#define USERNAME_SIZE_MAX 31
|
||||
#define PASSWORD_SIZE_MIN 8
|
||||
#define PASSWORD_SIZE_MAX 31
|
||||
#define PASSWORD_HASH_SIZE 32
|
||||
#define CHANNEL_NAME_SIZE_MIN 1
|
||||
#define CHANNEL_NAME_SIZE_MAX 127
|
||||
#define CHANNEL_DESC_SIZE_MAX 1023
|
||||
#define PRIVATE_KEY_BASE64_SIZE_MAX 1724
|
||||
#define PUBLIC_KEY_BASE64_SIZE_MAX 699
|
||||
#define HOSTADDR_SIZE_MIN 4
|
||||
#define HOSTADDR_SIZE_MAX 255
|
||||
9
include/tcp-chat/server.h
Normal file
9
include/tcp-chat/server.h
Normal file
@@ -0,0 +1,9 @@
|
||||
#pragma once
|
||||
#include "tlibc/errors.h"
|
||||
#include "tlibc/string/str.h"
|
||||
|
||||
typedef struct Server Server;
|
||||
|
||||
Result(Server*) Server_createFromConfig(str config_str);
|
||||
void Server_free(Server* server);
|
||||
Result(void) Server_run(Server* server);
|
||||
Reference in New Issue
Block a user