implemented auto_connect in client
This commit is contained in:
parent
85271c8aae
commit
57eba2caf6
@ -50,13 +50,34 @@ int main(void)
|
||||
server_addr.sin_port = htons(WHY2_SERVER_PORT);
|
||||
|
||||
//GET IP
|
||||
printf("Welcome.\n\nEnter IP Address:\n>>> ");
|
||||
if (getline(&line, &line_length, stdin) == -1) why2_die("Reading input failed."); //TODO: Add enums to why2_die()
|
||||
printf("Welcome.\n\n");
|
||||
|
||||
char *path = why2_replace(WHY2_CHAT_CONFIG_DIR "/" WHY2_CHAT_CONFIG_CLIENT, "{USER}", getenv("USER"));
|
||||
char *auto_connect = why2_toml_read(path, "auto_connect");
|
||||
|
||||
if (strcmp(auto_connect, "true") == 0) //USER ENABLED AUTOMATIC CONNECTION
|
||||
{
|
||||
char *auto_connect_ip = why2_toml_read(path, "auto_connect_ip"); //GET IP
|
||||
|
||||
line = strdup(auto_connect_ip);
|
||||
printf("%s\n", line);
|
||||
|
||||
why2_toml_read_free(auto_connect_ip);
|
||||
} else
|
||||
{
|
||||
printf("Enter IP Address:\n>>> ");
|
||||
if (getline(&line, &line_length, stdin) == -1) why2_die("Reading input failed.");
|
||||
|
||||
line_length = 3; //THIS IS FOR THE UNDERLINE THINGY
|
||||
}
|
||||
|
||||
why2_deallocate(path);
|
||||
why2_toml_read_free(auto_connect);
|
||||
|
||||
server_addr.sin_addr.s_addr = inet_addr(line);
|
||||
|
||||
//PRINT UNDERLINE
|
||||
for (unsigned long i = 0; i < strlen(line) + 3; i++)
|
||||
for (unsigned long i = 0; i < strlen(line) + line_length; i++)
|
||||
{
|
||||
printf("#");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user