summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2024-08-05 06:06:57 +0200
committerGravatar default2024-08-05 06:06:57 +0200
commit8a6c6134ef603caedb7df2741b38bcc3d423eb34 (patch)
tree69fa737c1551fff2a1e78f837236a6f8c78d5921
parentAdded support for listening on unix sockets. (diff)
downloadpenes-snac2-8a6c6134ef603caedb7df2741b38bcc3d423eb34.tar.gz
penes-snac2-8a6c6134ef603caedb7df2741b38bcc3d423eb34.tar.xz
penes-snac2-8a6c6134ef603caedb7df2741b38bcc3d423eb34.zip
Add support to unix sockets in snac_init().
Diffstat (limited to '')
-rw-r--r--utils.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/utils.c b/utils.c
index 60cd8dd..5a465ee 100644
--- a/utils.c
+++ b/utils.c
@@ -131,21 +131,33 @@ int snac_init(const char *basedir)
131 xs *layout = xs_number_new(disk_layout); 131 xs *layout = xs_number_new(disk_layout);
132 srv_config = xs_dict_set(srv_config, "layout", layout); 132 srv_config = xs_dict_set(srv_config, "layout", layout);
133 133
134 printf("Network address [%s]: ", xs_dict_get(srv_config, "address")); fflush(stdout); 134 int is_unix_socket = 0;
135
136 printf("Network address or full path to unix socket [%s]: ", xs_dict_get(srv_config, "address")); fflush(stdout);
135 { 137 {
136 xs *i = xs_strip_i(xs_readline(stdin)); 138 xs *i = xs_strip_i(xs_readline(stdin));
137 if (*i) 139 if (*i) {
138 srv_config = xs_dict_set(srv_config, "address", i); 140 srv_config = xs_dict_set(srv_config, "address", i);
141
142 if (*i == '/')
143 is_unix_socket = 1;
144 }
139 } 145 }
140 146
141 printf("Network port [%d]: ", (int)xs_number_get(xs_dict_get(srv_config, "port"))); fflush(stdout); 147 if (!is_unix_socket) {
142 { 148 printf("Network port [%d]: ", (int)xs_number_get(xs_dict_get(srv_config, "port"))); fflush(stdout);
143 xs *i = xs_strip_i(xs_readline(stdin)); 149 {
144 if (*i) { 150 xs *i = xs_strip_i(xs_readline(stdin));
145 xs *n = xs_number_new(atoi(i)); 151 if (*i) {
146 srv_config = xs_dict_set(srv_config, "port", n); 152 xs *n = xs_number_new(atoi(i));
153 srv_config = xs_dict_set(srv_config, "port", n);
154 }
147 } 155 }
148 } 156 }
157 else {
158 xs *n = xs_number_new(0);
159 srv_config = xs_dict_set(srv_config, "port", n);
160 }
149 161
150 printf("Host name: "); fflush(stdout); 162 printf("Host name: "); fflush(stdout);
151 { 163 {