diff options
-rwxr-xr-x | configure | 8 | ||||
-rw-r--r-- | doc/tipidee-config.html | 4 | ||||
-rw-r--r-- | doc/tipideed.html | 4 | ||||
-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 |
6 files changed, 34 insertions, 23 deletions
@@ -23,6 +23,7 @@ Fine tuning of the installation directories: --libexecdir=DIR package-scoped executables [EPREFIX/libexec] --libdir=DIR static library files [PREFIX/lib/$package] --includedir=DIR C header files [PREFIX/include] + --sysconfdir=DIR global configuration files [PREFIX/etc] If no --prefix option is given, by default libdir (but not dynlibdir) will be /usr/lib/$package, and includedir will be /usr/include. @@ -140,6 +141,7 @@ libexecdir='$exec_prefix/libexec' bindir='$exec_prefix/bin' libdir='$prefix/lib/$package' includedir='$prefix/include' +sysconfdir='$prefix/etc' sysdeps='$prefix/lib/skalibs/sysdeps' manualsysdeps=false shared=false @@ -169,6 +171,7 @@ for arg ; do --bindir=*) bindir=${arg#*=} ;; --libdir=*) libdir=${arg#*=} ;; --includedir=*) includedir=${arg#*=} ;; + --sysconfdir=*) sysconfdir=${arg#*=} ;; --with-sysdeps=*) sysdeps=${arg#*=} manualsysdeps=true ;; --with-include=*) var=${arg#*=} ; stripdir var ; addincpath="$addincpath -I$var" ;; --with-lib=*) var=${arg#*=} ; stripdir var ; addlibspath="$addlibspath -L$var" ; vpaths="$vpaths $var" ;; @@ -215,7 +218,7 @@ fi # Expand installation directories stripdir prefix -for i in exec_prefix dynlibdir libexecdir bindir libdir includedir sysdeps sproot ; do +for i in exec_prefix dynlibdir libexecdir bindir libdir includedir sysconfdir sysdeps sproot ; do eval tmp=\${$i} eval $i=$tmp stripdir $i @@ -393,6 +396,7 @@ libexecdir := $libexecdir bindir := $bindir libdir := $libdir includedir := $includedir +sysconfdir := $sysconfdir sysdeps := $sysdeps slashpackage := $slashpackage sproot := $sproot @@ -468,6 +472,8 @@ else echo "#define ${package_macro_name}_EXTBINPREFIX \"\"" fi echo "#define ${package_macro_name}_LIBEXECPREFIX \"$libexecdir/\"" +echo "#define ${package_macro_name}_SYSCONFPREFIX \"$sysconfdir/\"" + echo echo "#endif" exec 1>&3 3>&- diff --git a/doc/tipidee-config.html b/doc/tipidee-config.html index 39ca514..2ade779 100644 --- a/doc/tipidee-config.html +++ b/doc/tipidee-config.html @@ -32,7 +32,9 @@ web server. <ul> <li> tipidee-config reads the <a href="tipidee.conf.html">/etc/tipidee.conf</a> -configuration file, parses it, and outputs a cdb file to <tt>/etc/tipidee.conf.cdb</tt>. </li> +configuration file, parses it, and outputs a cdb file to <tt>/etc/tipidee.conf.cdb</tt>. +(The <tt>/etc</tt> default can be changed at build time with the <tt>--sysconfdir</tt> +option to configure.) </li> <li> It then exits 0. </li> </ul> diff --git a/doc/tipideed.html b/doc/tipideed.html index 1b1b17c..955948f 100644 --- a/doc/tipideed.html +++ b/doc/tipideed.html @@ -202,7 +202,9 @@ command line option overrides any setting present in the configuration file.</dd <dt> -f <em>file</em> </dt> <dd> Use <em>file</em> as the compiled configuration database, typically obtained by running <tt><a href="tipidee-config.html">tipidee-config</a> -o <em>file</em></tt>. -The default is <tt>/etc/tipidee.conf.cdb</tt>. </dd> +The default is <tt>/etc/tipidee.conf.cdb</tt>; <tt>/etc</tt> may be something +else if the <tt>--sysconfdir</tt> option has been given to configure at +build time. </dd> <dt> -d <em>docroot</em> </dt> <dd> Change the working directory to <em>docroot</em> before serving. Default 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 ; |