added return value check to client & server getline

This commit is contained in:
Václav Šmejkal 2024-01-25 11:23:54 +01:00
parent bd3eb8ed4a
commit abe76d79f0
No known key found for this signature in database
GPG Key ID: A77FB9B47AD0B168
2 changed files with 2 additions and 2 deletions

View File

@ -51,7 +51,7 @@ int main(void)
//GET IP //GET IP
printf("Welcome.\n\nEnter IP Address:\n>>> "); printf("Welcome.\n\nEnter IP Address:\n>>> ");
getline(&line, &line_length, stdin); if (getline(&line, &line_length, stdin) == -1) why2_die("Reading input failed."); //TODO: Add enums to why2_die()
server_addr.sin_addr.s_addr = inet_addr(line); server_addr.sin_addr.s_addr = inet_addr(line);

View File

@ -61,7 +61,7 @@ int main(void)
for (;;) for (;;)
{ {
getline(&line_buffer, &line_length_buffer, stdin); if (getline(&line_buffer, &line_length_buffer, stdin) == -1) why2_die("Reading input failed.");
if (strcmp(line_buffer, "!exit\n") == 0) //USER REQUESTED PROGRAM EXIT if (strcmp(line_buffer, "!exit\n") == 0) //USER REQUESTED PROGRAM EXIT
{ {