diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-09-22 08:14:38 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-09-22 08:14:38 +0000 |
commit | 8d7cba497938020ee5e8f408e6a52cd37274722b (patch) | |
tree | 6b8fefa0a6c059b4a826c16db789677d4423e8a4 /src | |
parent | 9107d979ad9bef3bd710efae86102286054136ee (diff) | |
download | tipidee-8d7cba497938020ee5e8f408e6a52cd37274722b.tar.gz tipidee-8d7cba497938020ee5e8f408e6a52cd37274722b.tar.xz tipidee-8d7cba497938020ee5e8f408e6a52cd37274722b.zip |
Make /etc configurable; fix some bugs
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/config/tipidee-config.c | 4 | ||||
-rw-r--r-- | src/tipideed/send_file.c | 35 | ||||
-rw-r--r-- | src/tipideed/tipideed.c | 2 |
3 files changed, 21 insertions, 20 deletions
diff --git a/src/config/tipidee-config.c b/src/config/tipidee-config.c index 235725d..3a8d999 100644 --- a/src/config/tipidee-config.c +++ b/src/config/tipidee-config.c @@ -87,8 +87,8 @@ static inline void conf_output (char const *ofile, unsigned int omode) int main (int argc, char const *const *argv, char const *const *envp) { - char const *ifile = "/etc/tipidee.conf" ; - char const *ofile = "/etc/tipidee.conf.cdb" ; + char const *ifile = TIPIDEE_SYSCONFPREFIX "tipidee.conf" ; + char const *ofile = TIPIDEE_SYSCONFPREFIX "tipidee.conf.cdb" ; unsigned int omode = 0644 ; PROG = "tipidee-config" ; diff --git a/src/tipideed/send_file.c b/src/tipideed/send_file.c index 23a0373..2aeec65 100644 --- a/src/tipideed/send_file.c +++ b/src/tipideed/send_file.c @@ -99,25 +99,26 @@ void send_file (int fd, uint64_t n, char const *fn) { tain deadline ; struct iovec v[2] ; - while (n) + ssize_t r ; + if (!n) goto flushit ; /* I know, I know, but do-while SUCKS */ + fillit: + buffer_wpeek(buffer_1, v) ; + r = allreadv(fd, v, 2) ; + if (r == -1) strerr_diefu2sys(111, "read from ", fn) ; + if (!r) strerr_diefu3x(111, "serve ", fn, ": file was truncated") ; + if (r > n) { - ssize_t r ; - buffer_rpeek(buffer_1, v) ; - r = allreadv(fd, v, 2) ; - if (r == -1) strerr_diefu2sys(111, "read from ", fn) ; - if (!r) strerr_diefu3x(111, "serve ", fn, ": file was truncated") ; - if (r > n) - { - r = n ; - if (g.verbosity >= 2) - strerr_warnw2x("serving elongated file: ", fn) ; - } - buffer_rseek(buffer_1, r) ; - tain_add_g(&deadline, &g.writetto) ; - if (!buffer_timed_flush_g(buffer_1, &deadline)) - strerr_diefu1sys(111, "write to stdout") ; - n -= r ; + r = n ; + if (g.verbosity >= 2) + strerr_warnw2x("serving elongated file: ", fn) ; } + buffer_wseek(buffer_1, r) ; + n -= r ; + flushit: + tain_add_g(&deadline, &g.writetto) ; + if (!buffer_timed_flush_g(buffer_1, &deadline)) + strerr_diefu1sys(111, "write to stdout") ; + if (n) goto fillit ; } #endif diff --git a/src/tipideed/tipideed.c b/src/tipideed/tipideed.c index 13e5d7b..c41553e 100644 --- a/src/tipideed/tipideed.c +++ b/src/tipideed/tipideed.c @@ -335,7 +335,7 @@ int main (int argc, char const *const *argv, char const *const *envp) PROG = progstr ; { - char const *conffile = "/etc/tipidee.conf.cdb" ; + char const *conffile = TIPIDEE_SYSCONFPREFIX "tipidee.conf.cdb" ; char const *newroot = 0 ; unsigned int h = 0 ; int gotv = 0 ; |