mzgdbm - A Scheme Extension for GDBM
mzgdbm is an extension for PLT-Scheme that allows Scheme programs to read and write GDBM hashs.
The original version of this extension was written by Alex Ott
The extension was modified by Phil Windley
The original included a Makefile, but it didn't work anymore and seemed like overkill for such a simple build. I've put build instructions in the comments of mzgdbm.c.
The orginal also included a .h file with some macro definitions, but since there's only one source file, that also seemed unncessarily complicated, so I've just put them in the source file itself.
Building the Extension
- Download and unpack the tarball.
- Compile the mzgdbm.c file using the following command:
mzc --cc ++ccf -I/usr/local/plt/include mzgdbm.c
The include path should be able to find escheme.h and scheme.h both of which come with the MzScheme distrbution. - Link the resulting .o file into a dynamic library like so:
mzc --ld mzgdbm.dylib ++ldf -L/usr/local/plt/lib/ ++ldf -lgdbm \\ ++ldf -liconv ++ldf -framework PLT_MzScheme mzgdbm.oThe -framework is OS X specific. You'll have to figure out what other libraries you need. Likewise, most systems use .so as the extension for dynamic libraries instead of .dylib. - Test the extension by running
mzscheme -f mzgdbm-tests.scm
This should return 8 success(es) 0 error(s) 0 failure(s). The first time you run it, it will download the schemeunit.ss library from PLaneT, so it may take some time.
That's it. You should now have a working GDBM extension.
Limitations
I have not used this extension much yet, so beyond the tests in the test file, I'm not sure how well it works.
GDBM hashes can be used to store integers, floating point numbers, and strings. The numbers are all converted to strings before they're stored, so you'll see the following behavior:
> (load-extension "mzgdbm.dylib") > (define my-hash #f) > (set! my-hash (gdbm:open "test.db" :gdbm:write-create)) > (gdbm:store my-hash 5 6) > (gdbm:fetch my-hash 5) "6"
You cannot store booleans or more complex aggregations, such as pairs, in the hash.
Documentation
Documentation for the extension is available. For more information, see man 3 gdbm.
Last Modified: Saturday, 02-Apr-2005 11:51:06 MST


