2 * Copyright (c) 2005 Zmanda Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 * Contact information: Zmanda Inc, 505 N Mathlida Ave, Suite 120
19 * Sunnyvale, CA 94085, USA, or: http://www.zmanda.com
21 * Author: Dustin J. Mitchell <dustin@zmanda.com>
26 * Utility routines for handling command lines.
34 /* TODO: use glib's linked lists instead; dumpspec_list_t provides basic
35 * type-checking to allow that to be implemented with a simple search and
38 /* A dumpspec can specify a particular dump (combining host, disk, and
39 * datestamp), or can be less specific by leaving out some components.
40 * In some cases (such as selecting DLEs), the datestamp is not relevant.
41 * Functions for these cases leave the datestamp NULL.
43 typedef struct dumpspec_s {
48 struct dumpspec_s * next;
52 typedef dumpspec_t dumpspec_list_t;
53 #define dumpspec_list_first(dsl) ((dumpspec_t *)(dsl))
56 * Dumpspec list management
59 /* Create a new dumpspec with the given components
61 * @param host: host name
62 * @param disk: disk name
63 * @param datestamp: datestamp
64 * @returns: dumpspec, or NULL on error
72 /* Free memory associated with a single dumpspec. (Does not chase
75 * @param dumpspec: the dumpspec to free
79 dumpspec_t *dumpspec);
81 /* Free memory associated with a list of dumpspecs.
83 * @param dumpspec_list: the dumpspec list to free
87 dumpspec_list_t *dumpspec_list);
93 /* Parse a command line matching the following syntax, and return
94 * the results as a linked list.
96 * [ host [ disk [ datestamp [ host [ disk [ datestamp .. ] ] ] ] ] ]
98 * If no results are specified, a dumpspec with all entries set to ""
99 * is returned; the caller may treat this as a wildcard or an error, as
102 * Prints a message to stderr and returns NULL if an error occurs.
104 * @param argc: count of command line arguments
105 * @param argv: command line arguments
106 * @returns: dumpspec list, or NULL on error
109 cmdline_parse_dumpspecs(
113 /* TODO: new name for match_disklist */
115 cmdline_parse_disk_list_entries(
123 /* Format a dumpspec into a string, with shell-compatible quoting.
125 * Caller is responsible for freeing the string.
127 * @param dumpspec: the dumpspec to format
128 * @returns: newly allocated string, or NULL on error
131 cmdline_format_dumpspec(
132 dumpspec_t *dumpspec);
134 /* Like cmdline_format_dumpspec, but with components supplied
135 * individually. Caller is responsible for freeing the
138 * @param host: host name
139 * @param disk: disk name
140 * @param datestamp: datestamp
141 * @returns: newly allocated string, or NULL on error
144 cmdline_format_dumpspec_components(
153 /* TODO: use glib here too */
155 /* Find all holding files matching the dumpspec list.
157 * @param dumpspec_list: a list of dumpspecs
158 * @returns: a list of holding disk filenames.
161 cmdline_match_holding(
162 dumpspec_list_t *dumpspec_list);
164 #endif /* CMDLINE_H */