diff options
author | default <nobody@localhost> | 2024-08-05 06:06:57 +0200 |
---|---|---|
committer | default <nobody@localhost> | 2024-08-05 06:06:57 +0200 |
commit | 8a6c6134ef603caedb7df2741b38bcc3d423eb34 (patch) | |
tree | 69fa737c1551fff2a1e78f837236a6f8c78d5921 | |
parent | 972c3dc5d43a114ae59386d4edfdfb8ce0f3793e (diff) |
Add support to unix sockets in snac_init().
-rw-r--r-- | utils.c | 28 |
1 files changed, 20 insertions, 8 deletions
@@ -131,21 +131,33 @@ int snac_init(const char *basedir) xs *layout = xs_number_new(disk_layout); srv_config = xs_dict_set(srv_config, "layout", layout); - printf("Network address [%s]: ", xs_dict_get(srv_config, "address")); fflush(stdout); + int is_unix_socket = 0; + + printf("Network address or full path to unix socket [%s]: ", xs_dict_get(srv_config, "address")); fflush(stdout); { xs *i = xs_strip_i(xs_readline(stdin)); - if (*i) + if (*i) { srv_config = xs_dict_set(srv_config, "address", i); + + if (*i == '/') + is_unix_socket = 1; + } } - printf("Network port [%d]: ", (int)xs_number_get(xs_dict_get(srv_config, "port"))); fflush(stdout); - { - xs *i = xs_strip_i(xs_readline(stdin)); - if (*i) { - xs *n = xs_number_new(atoi(i)); - srv_config = xs_dict_set(srv_config, "port", n); + if (!is_unix_socket) { + printf("Network port [%d]: ", (int)xs_number_get(xs_dict_get(srv_config, "port"))); fflush(stdout); + { + xs *i = xs_strip_i(xs_readline(stdin)); + if (*i) { + xs *n = xs_number_new(atoi(i)); + srv_config = xs_dict_set(srv_config, "port", n); + } } } + else { + xs *n = xs_number_new(0); + srv_config = xs_dict_set(srv_config, "port", n); + } printf("Host name: "); fflush(stdout); { |