mirror of
https://codeberg.org/grunfink/snac2.git
synced 2024-11-25 22:45:05 +00:00
Add support to unix sockets in snac_init().
This commit is contained in:
parent
972c3dc5d4
commit
8a6c6134ef
1 changed files with 21 additions and 9 deletions
16
utils.c
16
utils.c
|
@ -131,13 +131,20 @@ int snac_init(const char *basedir)
|
||||||
xs *layout = xs_number_new(disk_layout);
|
xs *layout = xs_number_new(disk_layout);
|
||||||
srv_config = xs_dict_set(srv_config, "layout", 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));
|
xs *i = xs_strip_i(xs_readline(stdin));
|
||||||
if (*i)
|
if (*i) {
|
||||||
srv_config = xs_dict_set(srv_config, "address", i);
|
srv_config = xs_dict_set(srv_config, "address", i);
|
||||||
|
|
||||||
|
if (*i == '/')
|
||||||
|
is_unix_socket = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_unix_socket) {
|
||||||
printf("Network port [%d]: ", (int)xs_number_get(xs_dict_get(srv_config, "port"))); fflush(stdout);
|
printf("Network port [%d]: ", (int)xs_number_get(xs_dict_get(srv_config, "port"))); fflush(stdout);
|
||||||
{
|
{
|
||||||
xs *i = xs_strip_i(xs_readline(stdin));
|
xs *i = xs_strip_i(xs_readline(stdin));
|
||||||
|
@ -146,6 +153,11 @@ int snac_init(const char *basedir)
|
||||||
srv_config = xs_dict_set(srv_config, "port", n);
|
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);
|
printf("Host name: "); fflush(stdout);
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue