/[anubis]/anubis/src/gdbm.c
ViewVC logotype

Diff of /anubis/src/gdbm.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.2 by polak, Fri Nov 21 09:22:16 2003 UTC revision 1.3 by gray, Sun Nov 30 00:46:44 2003 UTC
# Line 23  Line 23 
23  */  */
24    
25  #include "headers.h"  #include "headers.h"
26    #if defined(HAVE_LIBGDBM)
27  #include <gdbm.h>  #include <gdbm.h>
28    
29  /* Format of an GDBM record:  /* Format of an GDBM record:
# Line 35  Line 36 
36                           The last two items are optional */                           The last two items are optional */
37    
38  static int  static int
39  gdbm_db_open (void **dp, char *arg, enum anubis_db_mode mode)  gdbm_db_open (void **dp, ANUBIS_URL *url, enum anubis_db_mode mode)
40  {  {
41          GDBM_FILE dbf;          GDBM_FILE dbf;
42          int flags;          int flags;
43            char *path;
44                    
45          switch (mode) {          switch (mode) {
46          case anubis_db_rdonly:          case anubis_db_rdonly:
# Line 49  gdbm_db_open (void **dp, char *arg, enum Line 51  gdbm_db_open (void **dp, char *arg, enum
51                  flags = GDBM_WRCREAT;                  flags = GDBM_WRCREAT;
52          }          }
53                    
54                    path = anubis_url_full_path(url);
55          dbf = gdbm_open(arg, 0, flags, 0644, NULL);          dbf = gdbm_open(path, 0, flags, 0644, NULL);
56            free(path);
57          if (!dbf)          if (!dbf)
58                  return ANUBIS_DB_FAIL;                  return ANUBIS_DB_FAIL;
59          *dp = dbf;          *dp = dbf;
# Line 138  gdbm_db_put (void *d, char *keystr, ANUB Line 141  gdbm_db_put (void *d, char *keystr, ANUB
141          return rc;          return rc;
142  }  }
143    
144    static int
145    gdbm_db_delete(void *d, char *keystr, int *ecode)
146    {
147            int rc;
148            datum key;
149    
150            key.dptr = keystr;
151            key.dsize = strlen(keystr);
152            if (gdbm_delete((GDBM_FILE)d, key))
153                    rc = ANUBIS_DB_FAIL;
154            else
155                    rc = ANUBIS_DB_SUCCESS;
156            return rc;
157    }
158    
159  void  void
160  gdbm_db_init()  gdbm_db_init()
161  {  {
# Line 146  gdbm_db_init() Line 164  gdbm_db_init()
164                             gdbm_db_close,                             gdbm_db_close,
165                             gdbm_db_get,                             gdbm_db_get,
166                             gdbm_db_put,                             gdbm_db_put,
167                               gdbm_db_delete,
168                             NULL);                             NULL);
169  }  }
170    #endif

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.3

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26