2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1998 University of Maryland at College Park
4 * Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved.
7 * Permission to use, copy, modify, distribute, and sell this software and its
8 * documentation for any purpose is hereby granted without fee, provided that
9 * the above copyright notice appear in all copies and that both that
10 * copyright notice and this permission notice appear in supporting
11 * documentation, and that the name of U.M. not be used in advertising or
12 * publicity pertaining to distribution of the software without specific,
13 * written prior permission. U.M. makes no representations about the
14 * suitability of this software for any purpose. It is provided "as is"
15 * without express or implied warranty.
17 * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
19 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
21 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 * Authors: the Amanda Development Team. Its members are listed in a
25 * file named AUTHORS, in the root directory of this distribution.
28 * $Id: amandad_util.c,v 1.5 2006/07/19 17:46:07 martinea Exp $
36 #define MAXMAXDUMPS 16
40 g_option_t * g_options)
42 g_options->str = NULL;
43 g_options->features = NULL;
44 g_options->hostname = NULL;
45 g_options->auth = NULL;
46 g_options->maxdumps = 0;
47 g_options->config = NULL;
56 g_option_t *g_options;
60 g_options = alloc(sizeof(g_option_t));
61 init_g_options(g_options);
62 g_options->str = stralloc(str);
68 if(strncmp(tok,"features=", 9) == 0) {
70 char *u = strchr(t, ';');
73 if(g_options->features != NULL) {
74 dbprintf(_("multiple features option\n"));
76 g_printf(_("ERROR [multiple features option]\n"));
79 if((g_options->features = am_string_to_feature(t)) == NULL) {
80 dbprintf(_("bad features value \"%s\"\n"), t);
82 g_printf(_("ERROR [bad features value \"%s\"]\n"), t);
88 else if(strncmp(tok,"hostname=", 9) == 0) {
89 if(g_options->hostname != NULL) {
90 dbprintf(_("multiple hostname option\n"));
92 g_printf(_("ERROR [multiple hostname option]\n"));
95 g_options->hostname = stralloc(tok+9);
97 else if(strncmp(tok,"auth=", 5) == 0) {
98 if(g_options->auth != NULL) {
99 dbprintf(_("multiple auth option\n"));
101 g_printf(_("ERROR [multiple auth option]\n"));
104 g_options->auth = stralloc(tok+5);
106 else if(strncmp(tok,"maxdumps=", 9) == 0) {
107 if(g_options->maxdumps != 0) {
108 dbprintf(_("multiple maxdumps option\n"));
110 g_printf(_("ERROR [multiple maxdumps option]\n"));
113 if(sscanf(tok+9, "%d;", &new_maxdumps) == 1) {
114 if (new_maxdumps > MAXMAXDUMPS) {
115 g_options->maxdumps = MAXMAXDUMPS;
117 else if (new_maxdumps > 0) {
118 g_options->maxdumps = new_maxdumps;
121 dbprintf(_("bad maxdumps value \"%s\"\n"), tok+9);
123 g_printf(_("ERROR [bad maxdumps value \"%s\"]\n"),
129 dbprintf(_("bad maxdumps value \"%s\"\n"), tok+9);
131 g_printf(_("ERROR [bad maxdumps value \"%s\"]\n"),
136 else if(strncmp(tok,"config=", 7) == 0) {
137 if(g_options->config != NULL) {
138 dbprintf(_("multiple config option\n"));
140 g_printf(_("ERROR [multiple config option]\n"));
143 g_options->config = stralloc(tok+7);
144 if (strchr(g_options->config, '/')) {
145 amfree(g_options->config);
146 dbprintf(_("invalid character in config option\n"));
148 g_printf(_("ERROR [invalid character in config option]\n"));
153 dbprintf(_("unknown option \"%s\"\n"), tok);
155 g_printf(_("ERROR [unknown option \"%s\"]\n"), tok);
158 tok = strtok(NULL, ";");
160 if(g_options->features == NULL) {
161 g_options->features = am_set_default_feature_set();
163 if(g_options->maxdumps == 0) /* default */
164 g_options->maxdumps = 1;
171 g_option_t * g_options)
173 if (g_options != NULL) {
174 amfree(g_options->str);
175 am_release_feature_set(g_options->features);
176 amfree(g_options->hostname);
177 amfree(g_options->auth);
178 amfree(g_options->config);