1 |
/* Store argument parsing |
/* Store argument parsing |
2 |
|
|
3 |
Copyright (C) 1996,97,98,99,2001 Free Software Foundation, Inc. |
Copyright (C) 1996,97,98,99,2001,02 Free Software Foundation, Inc. |
4 |
Written by Miles Bader <miles@gnu.org> |
Written by Miles Bader <miles@gnu.org> |
5 |
This file is part of the GNU Hurd. |
This file is part of the GNU Hurd. |
6 |
|
|
26 |
|
|
27 |
#include "store.h" |
#include "store.h" |
28 |
|
|
29 |
#define DEFAULT_STORE_TYPE "query" |
/* We use this class variable instead of just the name so that we ensure |
30 |
|
linking in store_open to define it. */ |
31 |
|
#define DEFAULT_STORE_CLASS store_query_class |
32 |
|
|
33 |
static const struct argp_option options[] = { |
static const struct argp_option options[] = { |
34 |
{"store-type",'T', "TYPE", 0, "Each DEVICE names a store of type TYPE"}, |
{"store-type",'T', "TYPE", 0, "Each DEVICE names a store of type TYPE"}, |
232 |
return err; |
return err; |
233 |
} |
} |
234 |
} |
} |
235 |
|
|
236 |
static const struct store_class * |
static const struct store_class * |
237 |
find_class (const char *name, const struct store_class *const *classes) |
find_class (const char *name, const struct store_class *const *const classes) |
238 |
{ |
{ |
239 |
while (*classes) |
const struct store_class *const *cl; |
240 |
if ((*classes)->name && strcmp (name, (*classes)->name) == 0) |
for (cl = classes ?: __start_store_std_classes; |
241 |
return *classes; |
classes ? *cl != 0 : cl < __stop_store_std_classes; |
242 |
else |
++cl) |
243 |
classes++; |
if ((*cl)->name && strcmp (name, (*cl)->name) == 0) |
244 |
|
return *cl; |
245 |
|
|
246 |
|
# pragma weak store_module_find_class |
247 |
|
if (! classes && store_module_find_class) |
248 |
|
{ |
249 |
|
const struct store_class *cl; |
250 |
|
if (store_module_find_class (name, strchr (name, '\0'), &cl) == 0) |
251 |
|
return cl; |
252 |
|
} |
253 |
|
|
254 |
return 0; |
return 0; |
255 |
} |
} |
256 |
|
|
351 |
if (! parsed) |
if (! parsed) |
352 |
return ENOMEM; |
return ENOMEM; |
353 |
bzero (parsed, sizeof (struct store_parsed)); |
bzero (parsed, sizeof (struct store_parsed)); |
354 |
parsed->classes = params->classes ?: store_std_classes; |
parsed->classes = params->classes; |
355 |
parsed->default_type = |
parsed->default_type = |
356 |
find_class (params->default_type ?: DEFAULT_STORE_TYPE, |
find_class (params->default_type ?: DEFAULT_STORE_CLASS.name, |
357 |
parsed->classes); |
parsed->classes); |
358 |
if (! parsed->default_type) |
if (! parsed->default_type) |
359 |
{ |
{ |