summaryrefslogtreecommitdiff
path: root/libstore/argp.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-03-14 21:09:32 +0000
committerRoland McGrath <roland@gnu.org>2002-03-14 21:09:32 +0000
commit1da2660337a3f8cf79dd2c2d6cb8c30fa78ffa73 (patch)
tree11a4a190d8ddee83161d5c32fa9d054daec07efe /libstore/argp.c
parent4bf7af7062d8b7217b1e17337657863720ef2846 (diff)
2002-02-08 Roland McGrath <roland@frob.com>
* argp.c (DEFAULT_STORE_TYPE): Macro removed. (DEFAULT_STORE_CLASS): New macro replaces it. (parse_opt): Update the use. 2001-12-28 Roland McGrath <roland@frob.com> * module.c: New file. * store.h (store_module_open, store_module_find_class, store_module_decode): Declare them. * argp.c (parse_opt): Leave PARSED->classes null here instead of defaulting to store_std_classes. (find_class): Default null class-list parameter to store_std_classes here instead. If no matches when defaulted, try calling store_module_open_class too. * typed.c (store_typed_open): If no match when search list is store_std_classes, try calling store_module_open_class too. * url.c (find_url_class): Likewise. * decode.c (store_decode): If no match when search list is store_std_classes, try calling store_module_decode too.
Diffstat (limited to 'libstore/argp.c')
-rw-r--r--libstore/argp.c33
1 files changed, 23 insertions, 10 deletions
diff --git a/libstore/argp.c b/libstore/argp.c
index 058d8276..9af7ae57 100644
--- a/libstore/argp.c
+++ b/libstore/argp.c
@@ -1,6 +1,6 @@
/* Store argument parsing
- Copyright (C) 1996,97,98,99,2001 Free Software Foundation, Inc.
+ Copyright (C) 1996,97,98,99,2001,02 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.org>
This file is part of the GNU Hurd.
@@ -26,7 +26,9 @@
#include "store.h"
-#define DEFAULT_STORE_TYPE "query"
+/* We use this class variable instead of just the name so that we ensure
+ linking in store_open to define it. */
+#define DEFAULT_STORE_CLASS store_query_class
static const struct argp_option options[] = {
{"store-type",'T', "TYPE", 0, "Each DEVICE names a store of type TYPE"},
@@ -230,14 +232,25 @@ store_parsed_open (const struct store_parsed *parsed, int flags,
return err;
}
}
+
static const struct store_class *
-find_class (const char *name, const struct store_class *const *classes)
+find_class (const char *name, const struct store_class *const *const classes)
{
- while (*classes)
- if ((*classes)->name && strcmp (name, (*classes)->name) == 0)
- return *classes;
- else
- classes++;
+ const struct store_class *const *cl;
+ for (cl = classes ?: __start_store_std_classes;
+ classes ? *cl != 0 : cl < __stop_store_std_classes;
+ ++cl)
+ if ((*cl)->name && strcmp (name, (*cl)->name) == 0)
+ return *cl;
+
+# pragma weak store_module_find_class
+ if (! classes && store_module_find_class)
+ {
+ const struct store_class *cl;
+ if (store_module_find_class (name, strchr (name, '\0'), &cl) == 0)
+ return cl;
+ }
+
return 0;
}
@@ -338,9 +351,9 @@ parse_opt (int opt, char *arg, struct argp_state *state)
if (! parsed)
return ENOMEM;
bzero (parsed, sizeof (struct store_parsed));
- parsed->classes = params->classes ?: store_std_classes;
+ parsed->classes = params->classes;
parsed->default_type =
- find_class (params->default_type ?: DEFAULT_STORE_TYPE,
+ find_class (params->default_type ?: DEFAULT_STORE_CLASS.name,
parsed->classes);
if (! parsed->default_type)
{