lintian doesn't like orphan packages with uploaders...
[debian/amanda] / server-src / amflush.c
index 66bf6dc10af9e4e8532543b1dc1c1f338e50a949..481ff289966e4fe495da10b5d423bea40290b9de 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * Amanda, The Advanced Maryland Automatic Network Disk Archiver
  * Copyright (c) 1991-1998 University of Maryland at College Park
+ * Copyright (c) 2007-2012 Zmanda, Inc.  All Rights Reserved.
  * All Rights Reserved.
  *
  * Permission to use, copy, modify, distribute, and sell this software and its
 #include "holding.h"
 #include "server_util.h"
 #include "timestamp.h"
+#include "getopt.h"
+
+static struct option long_options[] = {
+    {"version"         , 0, NULL,  1},
+    {"exact-match"     , 0, NULL,  2},
+    {NULL, 0, NULL, 0}
+};
 
 static char *conf_logdir;
 FILE *driver_stream;
@@ -94,6 +102,7 @@ main(
     char **config_options;
     find_result_t *holding_files;
     disklist_t holding_disklist = { NULL, NULL };
+    gboolean exact_match = FALSE;
 
     /*
      * Configure program for internationalization:
@@ -122,8 +131,13 @@ 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 2  : exact_match = TRUE;
+                 break;
        case 'b': batch = 1;
                  break;
        case 'f': foreground = 1;
@@ -151,7 +165,7 @@ main(
     }
 
     if(argc < 1) {
-       error(_("Usage: amflush [-b] [-f] [-s] [-D date]* [-o configoption]* <confdir> [host [disk]* ]*"));
+       error(_("Usage: amflush [-b] [-f] [-s] [-D date]* [--exact-match] [-o configoption]* <confdir> [host [disk]* ]*"));
        /*NOTREACHED*/
     }
 
@@ -181,7 +195,7 @@ main(
      * dumps will be filtered properly by match_disklist, setting the dp->todo
      * flag appropriately. */
 
-    errstr = match_disklist(&diskq, argc-1, argv+1);
+    errstr = match_disklist(&diskq, exact_match, argc-1, argv+1);
     if (errstr) {
        g_printf(_("%s"),errstr);
        amfree(errstr);
@@ -280,10 +294,19 @@ main(
 
     for(dp = diskq.head; dp != NULL; dp = dp->next) {
        if(dp->todo) {
-           char *qname;
-           qname = quote_string(dp->name);
-           log_add(L_DISK, "%s %s", dp->host->hostname, qname);
-           amfree(qname);
+           /* is it holding_list */
+           for (holding_file=holding_list; holding_file != NULL;
+                                           holding_file = holding_file->next) {
+               dumpfile_t file;
+               holding_file_get_dumpfile((char *)holding_file->data, &file);
+               if (g_str_equal(dp->host->hostname, file.name) &&
+                   g_str_equal(dp->name, file.disk)) {
+                   char *qname;
+                   qname = quote_string(dp->name);
+                   log_add(L_DISK, "%s %s", dp->host->hostname, qname);
+                   amfree(qname);
+               }
+           }
        }
     }