diff options
author | Guido van Rossum <guido@python.org> | 1996-01-26 21:08:01 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1996-01-26 21:08:01 (GMT) |
commit | e36e1fe5160fb15271783c9ebc02ac311011452b (patch) | |
tree | 59752e5fea026b949a00c1735f8e923be2195000 /Modules/gdbmmodule.c | |
parent | 15ad9a6e52ea092bd3b60b8f4201203d869f825c (diff) | |
download | cpython-e36e1fe5160fb15271783c9ebc02ac311011452b.zip cpython-e36e1fe5160fb15271783c9ebc02ac311011452b.tar.gz cpython-e36e1fe5160fb15271783c9ebc02ac311011452b.tar.bz2 |
support fast mode for gdmb
Diffstat (limited to 'Modules/gdbmmodule.c')
-rw-r--r-- | Modules/gdbmmodule.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/Modules/gdbmmodule.c b/Modules/gdbmmodule.c index e5bc4ac..ecfd31e 100644 --- a/Modules/gdbmmodule.c +++ b/Modules/gdbmmodule.c @@ -335,27 +335,34 @@ dbmopen(self, args) object *args; { char *name; - char *flags = "r"; + char *flags = "r "; int iflags; int mode = 0666; -/* XXXX add other flags */ - if ( !newgetargs(args, "s|si", &name, &flags, &mode) ) +/* XXXX add other flags. 2nd character can be "f" meaning open in fast mode. */ + if ( !newgetargs(args, "s|si", &name, &flags, &mode) ) return NULL; - if ( strcmp(flags, "r") == 0 ) + switch (flags[0]) { + case 'r': iflags = GDBM_READER; - else if ( strcmp(flags, "w") == 0 ) + break; + case 'w': iflags = GDBM_WRITER; - else if ( strcmp(flags, "c") == 0 ) + break; + case 'c': iflags = GDBM_WRCREAT; - else if ( strcmp(flags, "n") == 0 ) + break; + case 'n': iflags = GDBM_NEWDB; - else { + break; + default: err_setstr(DbmError, "Flags should be one of 'r', 'w', 'c' or 'n'"); return NULL; } - return newdbmobject(name, iflags, mode); + if (flags[1] == 'f') + iflags |= GDBM_FAST; + return newdbmobject(name, iflags, mode); } static struct methodlist dbmmodule_methods[] = { |