Imported Upstream version 3.3.1
[debian/amanda] / server-src / amflush.c
index 4d28e44755118821311cffa1a934d9a8234fa689..8403ac2c277c29ba82c3f6a65843137858887f83 100644 (file)
 #include "holding.h"
 #include "server_util.h"
 #include "timestamp.h"
+#include "getopt.h"
+
+static struct option long_options[] = {
+    {"version"         , 0, NULL,  1},
+    {NULL, 0, NULL, 0}
+};
 
 static char *conf_logdir;
 FILE *driver_stream;
@@ -122,8 +128,12 @@ main(
     /* process arguments */
 
     cfg_ovr = new_config_overrides(argc/2);
-    while((opt = getopt(argc, argv, "bfso:D:")) != EOF) {
+    while((opt = getopt_long(argc, argv, "bfso:D:", long_options, NULL)) != EOF) {
        switch(opt) {
+       case 1  : printf("amflush-%s\n", VERSION);
+                 return(0);
+                 break;
+
        case 'b': batch = 1;
                  break;
        case 'f': foreground = 1;
@@ -245,7 +255,7 @@ main(
                    stralloc((char *)datestamp->data),
                    g_compare_strings);
        }
-       g_slist_free_full(all_datestamps);
+       slist_free_full(all_datestamps, g_free);
     }
     else {
        /* otherwise, in batch mode, use all datestamps */
@@ -405,9 +415,9 @@ main(
        }
     }
 
-    g_slist_free_full(datestamp_list);
+    slist_free_full(datestamp_list, g_free);
     datestamp_list = NULL;
-    g_slist_free_full(holding_list);
+    slist_free_full(holding_list, g_free);
     holding_list = NULL;
 
     if(redirect) { /* rename errfile */
@@ -599,7 +609,7 @@ pick_datestamp(void)
                }
                chupper = (char)toupper(ch);
                if (chupper < 'A' || chupper > max_char) {
-                   g_slist_free_full(r_datestamp_list);
+                   slist_free_full(r_datestamp_list, g_free);
                    r_datestamp_list = NULL;
                    break;
                }
@@ -607,7 +617,7 @@ pick_datestamp(void)
                                           stralloc(datestamps[chupper - 'A']));
            } while ((ch = *a++) != '\0');
            if (r_datestamp_list && ch == '\0') {
-               g_slist_free_full(datestamp_list);
+               slist_free_full(datestamp_list, g_free);
                datestamp_list = r_datestamp_list;
                break;
            }
@@ -681,7 +691,7 @@ redirect_stderr(void)
 
     fflush(stdout); fflush(stderr);
     errfile = vstralloc(conf_logdir, "/amflush", NULL);
-    if((fderr = open(errfile, O_WRONLY| O_CREAT | O_TRUNC, 0600)) == -1) {
+    if((fderr = open(errfile, O_WRONLY| O_APPEND | O_CREAT | O_TRUNC, 0600)) == -1) {
        error(_("could not open %s: %s"), errfile, strerror(errno));
        /*NOTREACHED*/
     }