Index of /tcl/ftparchive/sorted/packages-7.6/databases/tclgdbm1.0

      Name                   Last modified     Size  Description

[DIR] Parent Directory 18-Dec-99 07:01 - [   ] README 03-Feb-94 23:55 5k [CMP] tclgdbm1.0.tar.gz 04-Feb-94 00:00 90k

The orginal interface to gdbm was done by rusty@garnet.berkeley.edu
I've just revised it so that it would be up to date.
This version should work with TCL7.3, TK3.6 and gdbm-1.7.1
It hasn't been very well tested though.

This extension adds the following commands to TCL/TK

gettimeofday
        Returns the number of seconds since midnight January 1, 1970.

ctime <time>
        Returns the conversion of a time as returned by 'gettimeofday'
        into 25 character ascii string; "Sun Sep 16 01:03:52 1973".
        All fields have constant width.

localtime <time>
        returns a 9 element list of numbers converted from a time as
        returned by 'gettimeofday': seconds minutes hour month-day
        month year week-day year-day is-daylight-savings.  These
        quantities give the time on a 24-hour clock, the day of the
        month (1-31), the month of the year (0-11), the day of the
        week (Sunday = 0), the year minus 1900, the day of the year
        (0-365, also known as the Julian date), and either a 1 or a 0
        if daylight saving time is in effect.

gdbm_open <name> [<mode>]
        Opens a gdbm database with the name <name>.  If the <mode>
        is not given it is opened for reading.  <mode> can be "r"
        (read only), "w" (write only), "wc" (write and create if not
        already existant), and "n" (write and create a new database
        regardless if one exists).  A gdbm database can be opened for
        reading many times but if it's opened for writing it can't
        also be opened for reading; in other words, in order to have a
        database opened for writing it can only be opened once for
        writing and nothing else.
        Nothing returned.

gdbm_close <name> 
        Close a gdbm database with the name <name>.

gdbm_insert <name> <key> <content>
        <name> is the name of a gdbm database previously opened with
        'gdbm_open'.  Inserts the data <content> giving it the key
        <key>.  If data with <key> is already in the database an
        error is generated.
        Nothing returned.

gdbm_replace <name> <key> <content>
        <name> is the name of a gdbm database previously opened with
        'gdbm_open'.  Searches the database for <key> and replaces its
        contents with <content>.  If <key> does not exist an error
        is generated.
        Nothing returned.

gdbm_store <name> <key> <content>
        <name> is the name of a gdbm database previously opened with
        'gdbm_open'.  Inserts or replaces data in the database with the
        key <key>.  If <key> already exists its data is replaced with
        <content>.  If <key> doesn't exist, <content> is inserted.
        Nothing returned.

gdbm_fetch <name> <key>
        <name> is the name of a gdbm database previously opened with
        'gdbm_open'.  Searches for <key> in the database and if found
        returns its contents.
        Returns the contents of key <key> or if not found, the empty
        string.

gdbm_delete <name> <key>
        <name> is the name of a gdbm database previously opened with
        'gdbm_open'.  Searches for <key> and deletes it from the
        database.  If <key> is not found an error is generated.
        Nothing returned.

gdbm_list <name>
        <name> is the name of a gdbm database previously opened with
        'gdbm_open'.
        Returns a list of all keys in the database.

gdbm_reorganize <name>
        <name> is the name of a gdbm database previously opened with
        'gdbm_open'.  This routine can be used to shrink the size of the
        database file if there have been a lot of deletions.
        Nothing returned.

"Th..Th..That's all folks"

Files included:

README - this file
gdbm_makefile - makefile for making an wish with gdbm functionality
tcl_gdbm.c - most of the codes
tkAppInit.c - interface code to TCL/TK

Building:

1. Find a place to unpack this stuff
2. Untar the tclgdbm package
   Ex:  gzip -d tclgdbm1.0.tar.gz; tar fxv tclgdbm1.0.tar
3. Make a directory for gdbm-1.7.1 and go there
   Ex:  mkdir gdbm-1.7.1; cd gdbm-1.7.1
4. Untar the gdbm package
   Ex:  tar fxv ../gdbm-1.7.1.tar
5. Build the gdbm package
6. Goto the tclgdbm directory
   Ex:  cd ../tclgdbm
7. Edit the file 'gdbm_makefile' in regard to the location of TCL,TK and
   gdbm.
8. Type: make -f gdbm_makefile
9. If successful, a file called 'gwish' will be created containing extension
   to gdbm.

Example:

#!./gwish -f
gdbm_open test.data wc
foreach i {1 2 3 4 5} {
   gdbm_store test.data $i "This data for $i"
}
gdbm_close test.data
gdbm_open test.data r
foreach key [lsort [gdbm_list test.data]] {
   puts stdout "$key [gdbm_fetch test.data $key]"
}
gdbm_close test.data



Send bugs, suggestions and comments to tdoan@bnr.ca
No guarantee on any of this stuff, use it at your own risks  ;-)