fixes welcome message

This commit is contained in:
2026-03-24 13:12:33 +02:00
parent 0b1eb69490
commit 32ac8a2656
2 changed files with 4 additions and 2 deletions
+1
View File
@@ -1,5 +1,6 @@
# Development plans # Development plans
- [] Remove file when error while saving the data in DB
## Features ## Features
- [ ] Return back email field in registration - [ ] Return back email field in registration
+3 -2
View File
@@ -93,7 +93,7 @@ char *get_welcome_mes(void) {
perror(WELCOME_FILE_NAME); perror(WELCOME_FILE_NAME);
exit(7); exit(7);
} }
int filesize = lseek(fd, 0, SEEK_END); int filesize = lseek(fd, 0, SEEK_END)+1;
lseek(fd, 0, SEEK_SET); lseek(fd, 0, SEEK_SET);
char *welcome_message = char *welcome_message =
mmap(NULL, filesize, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0); mmap(NULL, filesize, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
@@ -102,11 +102,12 @@ char *get_welcome_mes(void) {
close(fd); close(fd);
exit(5); exit(5);
} }
welcome_message[filesize-1] = '\04';
close(fd); close(fd);
return welcome_message; return welcome_message;
} }
int start_server() { int start_server(void) {
int res; int res;
int ls = socket(AF_INET, SOCK_STREAM, 0); int ls = socket(AF_INET, SOCK_STREAM, 0);
struct sockaddr_in s_addr; struct sockaddr_in s_addr;