add bug closure to changelog
[debian/amanda] / server-src / cmdline.c
index 816c19488a71260fffe5cb8db56826ced6f5e731..600d50060477ff221816c2e4618aac15f5db0b0e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2005 Zmanda Inc.  All Rights Reserved.
+ * Copyright (c) 2007-2012 Zmanda, Inc.  All Rights Reserved.
  * 
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 as published
@@ -14,8 +14,8 @@
  * with this program; if not, write to the Free Software Foundation, Inc.,
  * 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  * 
- * Contact information: Zmanda Inc, 505 N Mathlida Ave, Suite 120
- * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
+ * Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300
+ * Sunnyvale, CA 94086, USA, or: http://www.zmanda.com
  *
  * Author: Dustin J. Mitchell <dustin@zmanda.com>
  */
@@ -25,8 +25,9 @@
  * Utility routines for handling command lines.
  */
 
-#include <ctype.h>
 #include "amanda.h"
+#include <ctype.h>
+#include "match.h"
 #include "cmdline.h"
 #include "holding.h"
 
@@ -35,16 +36,17 @@ dumpspec_new(
     char *host, 
     char *disk, 
     char *datestamp,
-    char *level)
+    char *level,
+    char *write_timestamp)
 {
     dumpspec_t *rv;
 
-    rv = calloc(1, sizeof(*rv));
-    if (!rv) return NULL;
+    rv = g_new0(dumpspec_t, 1);
     if (host) rv->host = stralloc(host);
     if (disk) rv->disk = stralloc(disk);
     if (datestamp) rv->datestamp = stralloc(datestamp);
     if (level) rv->level = stralloc(level);
+    if (write_timestamp) rv->write_timestamp = stralloc(write_timestamp);
 
     return rv;
 }
@@ -58,6 +60,7 @@ dumpspec_free(
     if (dumpspec->disk) free(dumpspec->disk);
     if (dumpspec->datestamp) free(dumpspec->datestamp);
     if (dumpspec->level) free(dumpspec->level);
+    if (dumpspec->write_timestamp) free(dumpspec->write_timestamp);
     free(dumpspec);
 }
 
@@ -90,30 +93,18 @@ cmdline_parse_dumpspecs(
         switch (arg_state) {
             case ARG_GET_HOST:
                 arg_state = ARG_GET_DISK;
-                if (name[0] != '\0'
-                    && (errstr=validate_regexp(name)) != NULL) {
-                    error(_("bad hostname regex \"%s\": %s\n"), name, errstr);
-                }
-                dumpspec = dumpspec_new(name, NULL, NULL, NULL);
+                dumpspec = dumpspec_new(name, NULL, NULL, NULL, NULL);
                list = g_slist_append(list, (gpointer)dumpspec);
                 break;
 
             case ARG_GET_DISK:
                 arg_state = ARG_GET_DATESTAMP;
-                if (name[0] != '\0'
-                    && (errstr=validate_regexp(name)) != NULL) {
-                    error(_("bad diskname regex \"%s\": %s\n"), name, errstr);
-                }
                 dumpspec->disk = stralloc(name);
                 break;
 
             case ARG_GET_DATESTAMP:
                 arg_state = ARG_GET_LEVEL;
                if (!(flags & CMDLINE_PARSE_DATESTAMP)) continue;
-                if (name[0] != '\0'
-                    && (errstr=validate_regexp(name)) != NULL) {
-                    error(_("bad datestamp regex \"%s\": %s\n"), name, errstr);
-                }
                 dumpspec->datestamp = stralloc(name);
                 break;
 
@@ -136,7 +127,7 @@ cmdline_parse_dumpspecs(
     if (list == NULL && (flags & CMDLINE_EMPTY_TO_WILDCARD)) {
         dumpspec = dumpspec_new("", "", 
                (flags & CMDLINE_PARSE_DATESTAMP)?"":NULL,
-               (flags & CMDLINE_PARSE_LEVEL)?"":NULL);
+               (flags & CMDLINE_PARSE_LEVEL)?"":NULL, "");
        list = g_slist_append(list, (gpointer)dumpspec);
     }
 
@@ -241,7 +232,10 @@ cmdline_match_holding(
     for (hi = holding_files; hi != NULL; hi = hi->next) {
        /* TODO add level */
        if (!holding_file_get_dumpfile((char *)hi->data, &file)) continue;
-        if (file.type != F_DUMPFILE) continue;
+        if (file.type != F_DUMPFILE) {
+           dumpfile_free_data(&file);
+           continue;
+       }
         for (li = dumpspec_list; li != NULL; li = li->next) {
            de = (dumpspec_t *)(li->data);
             if (de->host && de->host[0] && !match_host(de->host, file.name)) continue;
@@ -250,9 +244,10 @@ cmdline_match_holding(
             matching_files = g_slist_append(matching_files, g_strdup((char *)hi->data));
             break;
         }
+       dumpfile_free_data(&file);
     }
 
-    g_slist_free_full(holding_files);
+    slist_free_full(holding_files, g_free);
 
     return matching_files;
 }