X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=server-src%2Fcmdline.c;h=c7894216510aef949bca425d2fa5ca9518a2099d;hb=HEAD;hp=892b6a3c6b600120081ff99388febf2426ebfccf;hpb=2627875b7d18858bc1f9f7652811e4d8c15a23eb;p=debian%2Famanda diff --git a/server-src/cmdline.c b/server-src/cmdline.c index 892b6a3..c789421 100644 --- a/server-src/cmdline.c +++ b/server-src/cmdline.c @@ -1,9 +1,10 @@ /* - * Copyright (c) 2005-2008 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 - * by the Free Software Foundation. + * 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 2 + * 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 @@ -14,7 +15,7 @@ * 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, 465 S Mathlida Ave, Suite 300 + * Contact information: Zmanda Inc, 465 S. Mathilda Ave., Suite 300 * Sunnyvale, CA 94086, USA, or: http://www.zmanda.com * * Author: Dustin J. Mitchell @@ -25,8 +26,9 @@ * Utility routines for handling command lines. */ -#include #include "amanda.h" +#include +#include "match.h" #include "cmdline.h" #include "holding.h" @@ -35,7 +37,8 @@ dumpspec_new( char *host, char *disk, char *datestamp, - char *level) + char *level, + char *write_timestamp) { dumpspec_t *rv; @@ -44,6 +47,7 @@ dumpspec_new( 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; } @@ -57,6 +61,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); } @@ -85,34 +90,27 @@ cmdline_parse_dumpspecs( enum { ARG_GET_HOST, ARG_GET_DISK, ARG_GET_DATESTAMP, ARG_GET_LEVEL } arg_state = ARG_GET_HOST; while (optind < argc) { + char *new_name = NULL; name = argv[optind]; + if (flags & CMDLINE_EXACT_MATCH && *name != '=') { + new_name = g_strconcat("=", name, NULL); + name = new_name; + } 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; @@ -120,12 +118,14 @@ cmdline_parse_dumpspecs( arg_state = ARG_GET_HOST; if (!(flags & CMDLINE_PARSE_LEVEL)) continue; if (name[0] != '\0' + && !(flags & CMDLINE_EXACT_MATCH) && (errstr=validate_regexp(name)) != NULL) { error(_("bad level regex \"%s\": %s\n"), name, errstr); } dumpspec->level = stralloc(name); break; } + amfree(new_name); optind++; } @@ -135,7 +135,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); } @@ -255,7 +255,7 @@ cmdline_match_holding( dumpfile_free_data(&file); } - g_slist_free_full(holding_files); + slist_free_full(holding_files, g_free); return matching_files; }