fix compiler errors and warnings

This commit is contained in:
2025-09-19 13:01:03 +02:00
parent 2564df5cec
commit cb642e905f

View File

@@ -39,7 +39,7 @@ int config_parser() {
char left[1000] = {0};
char right[1000] = {0};
while(fgets(line, 10000, fptr) != NULL) {
while(fgets(line, 1000, fptr) != NULL) {
line[strcspn(line, "\n#")] = '\0';
if (strcmp(line, "") == 0) {
continue;
@@ -58,17 +58,17 @@ int config_parser() {
continue;
}
left = strtok(line, "=");
right = strtok(NULL, "\0");
strcpy(left, strtok(line, "="));
strcpy(right, strtok(NULL, "\0"));
if (strcmp(left, "data_dir") == 0) {
config->data_dir = malloc(10000);
memcpy(config->data_dir, right, strlen(right));
config.data_dir = malloc(1000);
strcpy(config.data_dir, right);
} else if (strcmp(left, "gallery-dl_conf") == 0) {
config->gallery_dl_conf = malloc(10000);
memcpy(config->gallery_dl_conf, right, strlen(right));
config.gallery_dl_conf = malloc(1000);
strcpy(config.gallery_dl_conf, right);
} else if (strcmp(left, "yt-dlp_conf") == 0) {
config->yt_dlp_conf = malloc(10000);
memcpy(config->yt_dlp_conf, right, strlen(right));
config.yt_dlp_conf = malloc(1000);
strcpy(config.yt_dlp_conf, right);
} else {
syslog(LOG_WARNING, "config_parser(): Unknown config option. key = '%s'", left);
}
@@ -231,10 +231,10 @@ int main() {
while(1) {
client_sock = accept(server_sock, NULL, NULL);
if (client_sock == -1) {
syslog(LOG_WARNING, "Failed to accept the connection.");
syslog(LOG_WARNING, "Failed connecting to client. Error: '%s'", strerror(client_sock));
continue;
}
syslog(LOG_INFO, "Accepted a connection.");
syslog(LOG_DEBUG, "Accepted a connection.");
data_length = read(client_sock, receive_buf, sizeof receive_buf);
if (data_length <= 0) {
syslog(LOG_WARNING, "Received no data from client.");
@@ -256,23 +256,34 @@ int main() {
break;
}
if (operand1[0] == '\0') {
strcpy(send_buf, "operand1 is empty!");
write(client_sock, send_buf, strlen(send_buf));
syslog(LOG_DEBUG, "Closing connection.");
close(client_sock);
}
if (strcmp(operation, "dl") == 0) {
}
if (strcmp(operation, "add") == 0) {
}
if (strcmp(operation, "add_custom") == 0) {
}
if (strcmp(operation, "delete") == 0) {
}
if (strcmp(operation, "update") == 0) {
}
syslog(LOG_INFO, "Closing connection.");
syslog(LOG_DEBUG, "Closing connection.");
close(client_sock);
}