diff options
author | Michael Cahill <michael.cahill@wiredtiger.com> | 2012-02-02 17:26:46 +1100 |
---|---|---|
committer | Michael Cahill <michael.cahill@wiredtiger.com> | 2012-02-02 17:26:46 +1100 |
commit | 27074676846bb2666abb06317fcf4999b71ad46b (patch) | |
tree | f72b77b66b01bec1ece9bc4b3f5b410a812ee09e | |
parent | e9652b47af8c9cf154584dd34b0d0c96badf5cab (diff) | |
download | mongo-27074676846bb2666abb06317fcf4999b71ad46b.tar.gz |
Have utilities work on more types of objects (e.g., "wt create colgroup:...").
refs #131
-rw-r--r-- | src/utilities/util.h | 10 | ||||
-rw-r--r-- | src/utilities/util_create.c | 3 | ||||
-rw-r--r-- | src/utilities/util_drop.c | 3 | ||||
-rw-r--r-- | src/utilities/util_main.c | 20 | ||||
-rw-r--r-- | src/utilities/util_read.c | 3 |
5 files changed, 29 insertions, 10 deletions
diff --git a/src/utilities/util.h b/src/utilities/util.h index 6cd5ee9b9cb..0f3b6ed407e 100644 --- a/src/utilities/util.h +++ b/src/utilities/util.h @@ -7,8 +7,14 @@ #include <wt_internal.h> -#define UTIL_FILE_OK 0x01 /* file: prefix OK */ -#define UTIL_TABLE_OK 0x02 /* table: prefix OK */ +#define UTIL_COLGROUP_OK 0x01 /* colgroup: prefix OK */ +#define UTIL_FILE_OK 0x02 /* file: prefix OK */ +#define UTIL_INDEX_OK 0x04 /* index: prefix OK */ +#define UTIL_TABLE_OK 0x08 /* table: prefix OK */ + +/* all known prefixes OK */ +#define UTIL_ALL_OK \ + (UTIL_COLGROUP_OK | UTIL_FILE_OK | UTIL_INDEX_OK | UTIL_TABLE_OK) typedef struct { void *mem; /* Managed memory chunk */ diff --git a/src/utilities/util_create.c b/src/utilities/util_create.c index 9a9755e7a75..106a49d3537 100644 --- a/src/utilities/util_create.c +++ b/src/utilities/util_create.c @@ -33,8 +33,7 @@ util_create(WT_SESSION *session, int argc, char *argv[]) if (argc != 1) return (usage()); - if ((uri = - util_name(*argv, "table", UTIL_FILE_OK | UTIL_TABLE_OK)) == NULL) + if ((uri = util_name(*argv, "table", UTIL_ALL_OK)) == NULL) return (1); if ((ret = session->create(session, uri, config)) != 0) diff --git a/src/utilities/util_drop.c b/src/utilities/util_drop.c index 01392010b21..efd69c98841 100644 --- a/src/utilities/util_drop.c +++ b/src/utilities/util_drop.c @@ -28,8 +28,7 @@ util_drop(WT_SESSION *session, int argc, char *argv[]) /* The remaining argument is the uri. */ if (argc != 1) return (usage()); - if ((name = - util_name(*argv, "table", UTIL_FILE_OK | UTIL_TABLE_OK)) == NULL) + if ((name = util_name(*argv, "table", UTIL_ALL_OK)) == NULL) return (1); return (session->drop(session, name, "force")); diff --git a/src/utilities/util_main.c b/src/utilities/util_main.c index 92712fd5dfe..7fe3015f1b9 100644 --- a/src/utilities/util_main.c +++ b/src/utilities/util_main.c @@ -227,7 +227,15 @@ util_name(const char *s, const char *type, u_int flags) char *name; copy = 0; - if (strncmp(s, "file:", strlen("file:")) == 0) { + if (WT_PREFIX_MATCH(s, "colgroup:")) { + if (!(flags & UTIL_COLGROUP_OK)) { + fprintf(stderr, + "%s: %s: \"colgroup\" type not supported\n", + progname, command); + return (NULL); + } + copy = 1; + } else if (WT_PREFIX_MATCH(s, "file:")) { if (!(flags & UTIL_FILE_OK)) { fprintf(stderr, "%s: %s: \"file\" type not supported\n", @@ -235,7 +243,15 @@ util_name(const char *s, const char *type, u_int flags) return (NULL); } copy = 1; - } else if (strncmp(s, "table:", strlen("table:")) == 0) { + } else if (WT_PREFIX_MATCH(s, "index:")) { + if (!(flags & UTIL_INDEX_OK)) { + fprintf(stderr, + "%s: %s: \"index\" type not supported\n", + progname, command); + return (NULL); + } + copy = 1; + } else if (WT_PREFIX_MATCH(s, "table:")) { if (!(flags & UTIL_TABLE_OK)) { fprintf(stderr, "%s: %s: \"table\" type not supported\n", diff --git a/src/utilities/util_read.c b/src/utilities/util_read.c index 96dc879a539..c3d10368105 100644 --- a/src/utilities/util_read.c +++ b/src/utilities/util_read.c @@ -31,8 +31,7 @@ util_read(WT_SESSION *session, int argc, char *argv[]) /* The remaining arguments are a uri followed by a list of keys. */ if (argc < 2) return (usage()); - if ((uri = - util_name(*argv, "table", UTIL_FILE_OK | UTIL_TABLE_OK)) == NULL) + if ((uri = util_name(*argv, "table", UTIL_ALL_OK)) == NULL) return (1); /* Open the object. */ |