summaryrefslogtreecommitdiff
path: root/libstore/typed.c
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1997-06-20 05:02:16 +0000
committerMiles Bader <miles@gnu.org>1997-06-20 05:02:16 +0000
commitd3c9edebe8bc2067bf2e293e0693f873b2576713 (patch)
tree0885107c122f95ec40ef2acbcfd0c01e8bc31e97 /libstore/typed.c
parent495ea95be97f58d99797c370d6b1f4593ecf863e (diff)
Initial checkin
Diffstat (limited to 'libstore/typed.c')
-rw-r--r--libstore/typed.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/libstore/typed.c b/libstore/typed.c
new file mode 100644
index 00000000..09f939d1
--- /dev/null
+++ b/libstore/typed.c
@@ -0,0 +1,62 @@
+/* Support for opening `typed' stores
+
+ Copyright (C) 1997 Free Software Foundation, Inc.
+
+ Written by Miles Bader <miles@gnu.ai.mit.edu>
+
+ This task is part of the GNU Hurd.
+
+ The GNU Hurd is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License as
+ published by the Free Software Foundation; either version 2, or (at
+ your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+
+#include <string.h>
+
+#include "store.h"
+
+/* Open the store indicated by NAME, which should consist of a store type
+ name followed by a ':' and any type-specific name, returning the new store
+ in STORE. CLASSES is used to select classes specified by the type name;
+ if it is 0, STORE_STD_CLASSES is used. */
+error_t
+store_typed_open (const char *name, int flags,
+ const struct store_class *const *classes,
+ struct store **store)
+{
+ const struct store_class *const *cl;
+ const char *clname_end = strchr (name, ':');
+
+ if (! clname_end)
+ clname_end = name + strlen (name);
+
+ if (! classes)
+ classes = store_std_classes;
+ for (cl = classes; *cl; cl++)
+ if (strlen ((*cl)->name) == (clname_end - name)
+ && strncmp (name, (*cl)->name, (clname_end - name)) == 0)
+ break;
+
+ if (! *cl)
+ return EINVAL;
+
+ if (! (*cl)->open)
+ return EOPNOTSUPP;
+
+ if (*clname_end)
+ clname_end++; /* Skip the ':' */
+
+ return (*(*cl)->open) (clname_end, flags, classes, store);
+}
+
+struct store_class
+store_typed_open_class = { -1, "typed", open: store_typed_open };