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(("%s: multiple features option\n",
69 debug_prefix_time(NULL)));
71 printf("ERROR [multiple features option]\n");
74 if((g_options->features = am_string_to_feature(tok+9)) == NULL) {
75 dbprintf(("%s: bad features value \"%s\n",
76 debug_prefix_time(NULL), tok+10));
78 printf("ERROR [bad features value \"%s\"]\n", tok+10);
82 else if(strncmp(tok,"hostname=", 9) == 0) {
83 if(g_options->hostname != NULL) {
84 dbprintf(("%s: multiple hostname option\n",
85 debug_prefix_time(NULL)));
87 printf("ERROR [multiple hostname option]\n");
90 g_options->hostname = stralloc(tok+9);
92 else if(strncmp(tok,"auth=", 5) == 0) {
93 if(g_options->auth != NULL) {
94 dbprintf(("%s: multiple auth option\n",
95 debug_prefix_time(NULL)));
97 printf("ERROR [multiple auth option]\n");
100 g_options->auth = stralloc(tok+5);
102 else if(strncmp(tok,"maxdumps=", 9) == 0) {
103 if(g_options->maxdumps != 0) {
104 dbprintf(("%s: multiple maxdumps option\n",
105 debug_prefix_time(NULL)));
107 printf("ERROR [multiple maxdumps option]\n");
110 if(sscanf(tok+9, "%d;", &new_maxdumps) == 1) {
111 if (new_maxdumps > MAXMAXDUMPS) {
112 g_options->maxdumps = MAXMAXDUMPS;
114 else if (new_maxdumps > 0) {
115 g_options->maxdumps = new_maxdumps;
118 dbprintf(("%s: bad maxdumps value \"%s\"\n",
119 debug_prefix_time(NULL), tok+9));
121 printf("ERROR [bad maxdumps value \"%s\"]\n",
127 dbprintf(("%s: bad maxdumps value \"%s\"\n",
128 debug_prefix_time(NULL), tok+9));
130 printf("ERROR [bad maxdumps value \"%s\"]\n",
135 else if(strncmp(tok,"config=", 7) == 0) {
136 if(g_options->config != NULL) {
137 dbprintf(("%s: multiple config option\n",
138 debug_prefix_time(NULL)));
140 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(("%s: invalid character in config option\n",
147 debug_prefix_time(NULL)));
149 printf("ERROR [invalid character in config option]\n");
154 dbprintf(("%s: unknown option \"%s\"\n",
155 debug_prefix_time(NULL), tok));
157 printf("ERROR [unknown option \"%s\"]\n", tok);
160 tok = strtok(NULL, ";");
162 if(g_options->features == NULL) {
163 g_options->features = am_set_default_feature_set();
165 if(g_options->maxdumps == 0) /* default */
166 g_options->maxdumps = 1;
173 g_option_t * g_options)
175 amfree(g_options->str);
176 am_release_feature_set(g_options->features);
177 amfree(g_options->hostname);
178 amfree(g_options->auth);
179 amfree(g_options->config);