chiark / gitweb /
changelog: Finalise 2.2
[innduct.git] / duct.c
diff --git a/duct.c b/duct.c
index a7c487228fdae5a57500bf9266f75e372d0345d9..bf8c8087842c986400cfd1598bf3191876f1b046 100644 (file)
--- a/duct.c
+++ b/duct.c
@@ -3,25 +3,9 @@
  *  tailing reliable realtime streaming feeder for inn
  *  duct.c - main program, option parsing and startup
  *
- *  Copyright (C) 2010 Ian Jackson <ijackson@chiark.greenend.org.uk>
- * 
- *  This program is free software: you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation, either version 3 of the License, or
- *  (at your option) any later version.
- * 
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- * 
- *  You should have received a copy of the GNU General Public License
- *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
- *
- *  (I believe that when you compile and link this as part of the inn2
- *  build, with the Makefile runes I have provided, all the libraries
- *  and files which end up included in innduct are licence-compatible
- *  with GPLv3.  If not then please let me know.  -Ian Jackson.)
+ *  Copyright Ian Jackson <ijackson@chiark.greenend.org.uk>
+ *  and contributors; see LICENCE.txt.
+ *  SPDX-License-Identifier: GPL-3.0-or-later
  */
 
 #include "innduct.h"
@@ -189,7 +173,7 @@ void period(void) {
 
 static void vbadusage(const char *fmt, va_list al) NORET_PRINTF(1,0);
 static void vbadusage(const char *fmt, va_list al) {
-  char *m= xvasprintf(fmt,al);
+  char *m= mvasprintf(fmt,al);
   fprintf(stderr, "bad usage: %s\n"
          "say --help for help, or read the manpage\n",
          m);
@@ -282,7 +266,7 @@ static void print_options(const Option *options, FILE *f) {
   const Option *o;
   for (o=options; o->shrt || o->lng; o++) {
     char shrt[2] = { o->shrt, 0 };
-    char *optspec= xasprintf("%s%s%s%s%s",
+    char *optspec= masprintf("%s%s%s%s%s",
                             o->shrt ? "-" : "", shrt,
                             o->shrt && o->lng ? "|" : "",
                             DELIMPERHAPS("--", o->lng));
@@ -401,9 +385,9 @@ static void printusage(FILE *f) {
 
 static void printcopyright(FILE *f) {
   fputs(
- "innduct is Copyright (C)2010 Ian Jackson.\n"
+ "innduct is Copyright Ian Jackson and contributors.\n"
  "It is free software, licenced under GPL version 3 or later.\n"
- "It is provided WITHOUT ANY WARRANTY.  See the file GPL-3 for details\n",
+ "There is NO WARRANTY.  See the file LICENCE.txt for details.\n",
         stderr);
 }
 
@@ -478,6 +462,7 @@ int main(int argc, char **argv) {
   convert_to_periods_rndup(&spontaneous_flush_periods);
   convert_to_periods_rndup(&max_separated_periods);
   convert_to_periods_rndup(&need_activity_periods);
+  convert_to_periods_rndup(&stats_log_periods);
   convert_to_periods_rndup(&lowvol_periods);
 
   if (max_bad_data_ratio < 0 || max_bad_data_ratio > 100)
@@ -490,19 +475,19 @@ int main(int argc, char **argv) {
   if (!feedfile) feedfile= sitename;
   if (!feedfile[0]) badusage("feed filename, if specified, must be nonempty");
   if (path_ends_slash(feedfile))
-    feedfile= xasprintf("%s%s", feedfile, sitename);
+    feedfile= masprintf("%s%s", feedfile, sitename);
   if (feedfile[0] != '/')
-    feedfile= xasprintf("%s/%s", innconf->pathoutgoing, feedfile);
+    feedfile= masprintf("%s/%s", innconf->pathoutgoing, feedfile);
 
   if (!path_cli) {
     path_cli_dir= "innduct";
   } else if (!path_cli[0] || !strcmp(path_cli,"none")) {
     path_cli= 0; /* ok, don't then */
   } else if (path_ends_slash(path_cli)) {
-    path_cli_dir= xasprintf("%.*s", strlen(path_cli)-1, path_cli);
+    path_cli_dir= masprintf("%.*s", (int)(strlen(path_cli)-1), path_cli);
   }
   if (path_cli_dir)
-    path_cli= xasprintf("%s/%s", path_cli_dir, sitename);
+    path_cli= masprintf("%s/%s", path_cli_dir, sitename);
 
   if (max_queue_per_ipf<0)
     max_queue_per_ipf= max_queue_per_conn * 2;
@@ -523,11 +508,11 @@ int main(int argc, char **argv) {
 
   /* set things up */
 
-  path_lock=        xasprintf("%s_lock",      feedfile);
-  path_flushing=    xasprintf("%s_flushing",  feedfile);
-  path_defer=       xasprintf("%s_defer",     feedfile);
-  path_dump=        xasprintf("%s_dump",      feedfile);
-  globpat_backlog=  xasprintf("%s_backlog*",  feedfile);
+  path_lock=        masprintf("%s_lock",      feedfile);
+  path_flushing=    masprintf("%s_flushing",  feedfile);
+  path_defer=       masprintf("%s_defer",     feedfile);
+  path_dump=        masprintf("%s_dump",      feedfile);
+  globpat_backlog=  masprintf("%s_backlog*",  feedfile);
 
   oop_source_sys *sysloop= oop_sys_new();
   if (!sysloop) syscrash("could not create liboop event loop");
@@ -541,7 +526,7 @@ int main(int argc, char **argv) {
       close(i);
   }
 
-  logv_prefix= xasprintf("%s| ", sitename);
+  logv_prefix= masprintf("%s| ", sitename);
   if (interactive < 2) {
     openlog("innduct",LOG_NDELAY|LOG_PID,LOG_NEWS);
     logv_use_syslog= 1;
@@ -555,13 +540,13 @@ int main(int argc, char **argv) {
     dup2(null,2);
     xclose(null, "/dev/null original fd",0);
 
-    pid_t child1= xfork("daemonise first fork");
+    pid_t child1= xfork_bare("daemonise first fork");
     if (child1) _exit(0);
 
     pid_t sid= setsid();
     if (sid == -1) sysdie("setsid failed");
 
-    pid_t child2= xfork("daemonise second fork");
+    pid_t child2= xfork_bare("daemonise second fork");
     if (child2) _exit(0);
   }