cleanup: remove dead code, fix bugs, refactor SSH dest parsing

- Remove debug printf calls from file.c
- Remove dead code: chunk_print, chunk_format, chunk_data_create/delete
- Remove unused config.use_single_send_per_file field
- Fix server_delete() no-op (double-pointer)
- Fix double cast (long)(long) -> ptrdiff_t in chunk.c
- Fix thread return value: thrd_error instead of 1
- Remove unused config param from receive_chunk_enqueue()
- Make queue_double_capacity() static
- Move SSH dest parsing into config.c as config_parse_ssh_dest()
- Fix test_config_ssh_dest to test parsing round-trip
- Remove chunk_format test (obsolete format)
- Replace chunk_data_delete with data_destroy in tests
This commit is contained in:
2026-07-07 19:07:24 +02:00
parent 783400d7e9
commit b3f69208ce
14 changed files with 69 additions and 189 deletions
+23
View File
@@ -1,8 +1,10 @@
#include "config.h"
#include "socket.h"
#include "utils.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Config *config_create(char *version, char *send_directory,
char *receive_directory, bool save_to_disk,
@@ -27,6 +29,27 @@ Config *config_create(char *version, char *send_directory,
return config;
}
bool is_remote_dest(const char *s) {
if (s == NULL) return false;
const char *colon = strchr(s, ':');
if (colon == NULL) return false;
if (colon == s) return false;
for (const char *p = s; p < colon; p++) {
if (*p == '/') return false;
}
return true;
}
void config_parse_ssh_dest(Config *config) {
if (!is_remote_dest(config->receive_root_directory)) return;
config->transport = TRANSPORT_SSH;
config->ssh_destination = str_dup(config->receive_root_directory);
char *colon = strchr(config->receive_root_directory, ':');
char *path = str_dup(colon + 1);
free(config->receive_root_directory);
config->receive_root_directory = path;
}
void config_delete(Config *config) {
free(config->version);
free(config->send_directory);