implemented default_username from server config

This commit is contained in:
Václav Šmejkal 2024-02-21 16:39:44 +01:00
parent e450032f26
commit 8c742b1884
Signed by: ENGO150
GPG Key ID: 4A57E86482968843
2 changed files with 6 additions and 2 deletions

View File

@ -32,7 +32,6 @@ extern "C" {
#define WHY2_CLEAR_AND_GO_UP "\33[2K\r\033[A" //i mean read the name
#define WHY2_INVALID_POINTER (void*) 0xffffffffffffffff
#define WHY2_CHAT_DEFAULT_USERNAME "anon"
#define WHY2_MAX_USERNAME_LENGTH 20 //MAXIMAL USERNAME LENGTH
#define WHY2_MIN_USERNAME_LENGTH 4 //MINIMAL USERNAME LENGTH

View File

@ -405,10 +405,15 @@ void *why2_communicate_thread(void *arg)
why2_bool invalid_username = 1;
why2_bool exiting = 0;
char *decoded_buffer = NULL;
char *username = why2_strdup(WHY2_CHAT_DEFAULT_USERNAME);
char *username;
int usernames_n = 0;
struct json_object *json = json_tokener_parse("{}");
//GET DEFAULT USERNAME
char *default_username = why2_chat_server_config("default_username");
username = why2_strdup(default_username);
why2_toml_read_free(default_username);
if (config_username == NULL || strcmp(config_username, "true") == 0)
{
if (config_username == NULL) fprintf(stderr, "Your config doesn't contain 'user_pick_username'. Please update your configuration.\n");