2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1998 University of Maryland at College Park
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of U.M. not be used in advertising or
11 * publicity pertaining to distribution of the software without specific,
12 * written prior permission. U.M. makes no representations about the
13 * suitability of this software for any purpose. It is provided "as is"
14 * without express or implied warranty.
16 * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Authors: the Amanda Development Team. Its members are listed in a
24 * file named AUTHORS, in the root directory of this distribution.
27 * $Id: amandad_util.c,v 1.5 2006/07/19 17:46:07 martinea Exp $
34 #define MAXMAXDUMPS 16
38 g_option_t * g_options)
40 g_options->str = NULL;
41 g_options->features = NULL;
42 g_options->hostname = NULL;
43 g_options->auth = NULL;
44 g_options->maxdumps = 0;
45 g_options->config = NULL;
54 g_option_t *g_options;
58 g_options = alloc(sizeof(g_option_t));
59 init_g_options(g_options);
60 g_options->str = stralloc(str);
66 if(strncmp(tok,"features=", 9) == 0) {
67 if(g_options->features != NULL) {
68 dbprintf(_("multiple features option\n"));
70 g_printf(_("ERROR [multiple features option]\n"));
73 if((g_options->features = am_string_to_feature(tok+9)) == NULL) {
74 dbprintf(_("bad features value \"%s\"\n"), tok+10);
76 g_printf(_("ERROR [bad features value \"%s\"]\n"), tok+10);
80 else if(strncmp(tok,"hostname=", 9) == 0) {
81 if(g_options->hostname != NULL) {
82 dbprintf(_("multiple hostname option\n"));
84 g_printf(_("ERROR [multiple hostname option]\n"));
87 g_options->hostname = stralloc(tok+9);
89 else if(strncmp(tok,"auth=", 5) == 0) {
90 if(g_options->auth != NULL) {
91 dbprintf(_("multiple auth option\n"));
93 g_printf(_("ERROR [multiple auth option]\n"));
96 g_options->auth = stralloc(tok+5);
98 else if(strncmp(tok,"maxdumps=", 9) == 0) {
99 if(g_options->maxdumps != 0) {
100 dbprintf(_("multiple maxdumps option\n"));
102 g_printf(_("ERROR [multiple maxdumps option]\n"));
105 if(sscanf(tok+9, "%d;", &new_maxdumps) == 1) {
106 if (new_maxdumps > MAXMAXDUMPS) {
107 g_options->maxdumps = MAXMAXDUMPS;
109 else if (new_maxdumps > 0) {
110 g_options->maxdumps = new_maxdumps;
113 dbprintf(_("bad maxdumps value \"%s\"\n"), tok+9);
115 g_printf(_("ERROR [bad maxdumps value \"%s\"]\n"),
121 dbprintf(_("bad maxdumps value \"%s\"\n"), tok+9);
123 g_printf(_("ERROR [bad maxdumps value \"%s\"]\n"),
128 else if(strncmp(tok,"config=", 7) == 0) {
129 if(g_options->config != NULL) {
130 dbprintf(_("multiple config option\n"));
132 g_printf(_("ERROR [multiple config option]\n"));
135 g_options->config = stralloc(tok+7);
136 if (strchr(g_options->config, '/')) {
137 amfree(g_options->config);
138 dbprintf(_("invalid character in config option\n"));
140 g_printf(_("ERROR [invalid character in config option]\n"));
145 dbprintf(_("unknown option \"%s\"\n"), tok);
147 g_printf(_("ERROR [unknown option \"%s\"]\n"), tok);
150 tok = strtok(NULL, ";");
152 if(g_options->features == NULL) {
153 g_options->features = am_set_default_feature_set();
155 if(g_options->maxdumps == 0) /* default */
156 g_options->maxdumps = 1;
163 g_option_t * g_options)
165 if (g_options != NULL) {
166 amfree(g_options->str);
167 am_release_feature_set(g_options->features);
168 amfree(g_options->hostname);
169 amfree(g_options->auth);
170 amfree(g_options->config);