apr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wr...@apache.org
Subject cvs commit: apr-util/include apr_sdbm.h
Date Mon, 30 Apr 2001 17:16:41 GMT
wrowe       01/04/30 10:16:40

  Modified:    .        CHANGES
               dbm      apr_dbm.c
               dbm/sdbm sdbm.c sdbm_lock.c sdbm_pair.c sdbm_pair.h
                        sdbm_private.h sdbm_tune.h
               include  apr_sdbm.h
  Log:
    Namespace protect public apr_sdbm functions (fixing apr_sdbm_error_get
    and apr_sdbm_error_clear) and normalize the return type (so val, key must
    be passed as pointers).
  
  Revision  Changes    Path
  1.13      +5 -0      apr-util/CHANGES
  
  Index: CHANGES
  ===================================================================
  RCS file: /home/cvs/apr-util/CHANGES,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- CHANGES	2001/04/28 00:23:41	1.12
  +++ CHANGES	2001/04/30 17:16:07	1.13
  @@ -1,5 +1,10 @@
   Changes with APR-util b1  
   
  +  *) Namespace protect apr_sdbm, and normalize the return values (including
  +     the apr_sdbm_fetch, apr_sdbm_firstkey and apr_sdbm_nextkey functions).
  +     Normalized the get/clear error function names, and stores the actual 
  +     apr error for apr_sdbm_error_get. [Will Rowe]
  +
     *) Introduce an apr_fileperms_t argument to apr_dbm_open(). [Will Rowe]
   
     *) Removed apr_bucket_do_create() macro, which was causing warnings
  
  
  
  1.20      +20 -16    apr-util/dbm/apr_dbm.c
  
  Index: apr_dbm.c
  ===================================================================
  RCS file: /home/cvs/apr-util/dbm/apr_dbm.c,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- apr_dbm.c	2001/04/28 00:23:41	1.19
  +++ apr_dbm.c	2001/04/30 17:16:13	1.20
  @@ -70,20 +70,20 @@
   
   #include "apr_sdbm.h"
   
  -typedef SDBM *real_file_t;
  +typedef apr_sdbm_t *real_file_t;
   
  -typedef sdbm_datum *cvt_datum_t;
  -#define CONVERT_DATUM(cvt, pinput) ((cvt) = (sdbm_datum *)(pinput))
  +typedef apr_sdbm_datum_t *cvt_datum_t;
  +#define CONVERT_DATUM(cvt, pinput) ((cvt) = (apr_sdbm_datum_t *)(pinput))
   
  -typedef sdbm_datum result_datum_t;
  +typedef apr_sdbm_datum_t result_datum_t;
   #define RETURN_DATUM(poutput, rd) (*(poutput) = *(apr_datum_t *)&(rd))
   
  -#define APR_DBM_CLOSE(f)	sdbm_close(f)
  -#define APR_DBM_FETCH(f, k, v)	((v) = sdbm_fetch(f, *(k)), APR_SUCCESS)
  -#define APR_DBM_STORE(f, k, v)	sdbm_store(f, *(k), *(v), SDBM_REPLACE)
  -#define APR_DBM_DELETE(f, k)	sdbm_delete(f, *(k))
  -#define APR_DBM_FIRSTKEY(f, k)	((k) = sdbm_firstkey(f), APR_SUCCESS)
  -#define APR_DBM_NEXTKEY(f, k, nk) ((nk) = sdbm_nextkey(f), APR_SUCCESS)
  +#define APR_DBM_CLOSE(f)	apr_sdbm_close(f)
  +#define APR_DBM_FETCH(f, k, v)	apr_sdbm_fetch(f, &v, *(k))
  +#define APR_DBM_STORE(f, k, v)	apr_sdbm_store(f, *(k), *(v), APR_SDBM_REPLACE)
  +#define APR_DBM_DELETE(f, k)	apr_sdbm_delete(f, *(k))
  +#define APR_DBM_FIRSTKEY(f, k)	apr_sdbm_firstkey(f, &k)
  +#define APR_DBM_NEXTKEY(f, k, nk) apr_sdbm_nextkey(f, &nk)
   #define APR_DBM_FREEDPTR(dptr)	NOOP_FUNCTION
   
   #define APR_DBM_DBMODE_RO       APR_READ
  @@ -311,7 +311,7 @@
   
   #if APU_USE_SDBM
   
  -    if ((dbm->errcode = sdbm_error(dbm->file)) == 0) {
  +    if ((dbm->errcode = apr_sdbm_error_get(dbm->file)) == 0) {
           dbm->errmsg = NULL;
       }
       else {
  @@ -320,7 +320,7 @@
       }
   
       /* captured it. clear it now. */
  -    sdbm_clearerr(dbm->file);
  +    apr_sdbm_error_clear(dbm->file);
   
   #elif APU_USE_GDBM
   
  @@ -383,7 +383,7 @@
       {
           apr_status_t rv;
   
  -        rv = sdbm_open(&file, pathname, dbmode, perm, pool);
  +        rv = apr_sdbm_open(&file, pathname, dbmode, perm, pool);
           if (rv != APR_SUCCESS)
               return rv;
       }
  @@ -501,9 +501,13 @@
   
   #if APU_USE_SDBM
       {
  -	sdbm_datum value = sdbm_fetch(dbm->file, *ckey);
  -	sdbm_clearerr(dbm->file);	/* don't need the error */
  -	exists = value.dptr != NULL;
  +	apr_sdbm_datum_t value;
  +        if (apr_sdbm_fetch(dbm->file, &value, *ckey) != APR_SUCCESS) {
  +	    apr_sdbm_error_clear(dbm->file);	/* don't need the error */
  +            exists = FALSE;
  +        }
  +        else
  +            exists = value.dptr != NULL;
       }
   #elif APU_USE_GDBM
       exists = gdbm_exists(dbm->file, *ckey) != 0;
  
  
  
  1.13      +75 -68    apr-util/dbm/sdbm/sdbm.c
  
  Index: sdbm.c
  ===================================================================
  RCS file: /home/cvs/apr-util/dbm/sdbm/sdbm.c,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- sdbm.c	2001/04/30 14:34:53	1.12
  +++ sdbm.c	2001/04/30 17:16:17	1.13
  @@ -76,11 +76,11 @@
   /*
    * forward
    */
  -static int getdbit (SDBM *, long);
  -static apr_status_t setdbit(SDBM *, long);
  -static apr_status_t getpage(SDBM *db, long);
  -static sdbm_datum getnext(SDBM *db);
  -static apr_status_t makroom(SDBM *, long, int);
  +static int getdbit (apr_sdbm_t *, long);
  +static apr_status_t setdbit(apr_sdbm_t *, long);
  +static apr_status_t getpage(apr_sdbm_t *db, long);
  +static apr_status_t getnext(apr_sdbm_datum_t *key, apr_sdbm_t *db);
  +static apr_status_t makroom(apr_sdbm_t *, long, int);
   
   /*
    * useful macros
  @@ -89,7 +89,7 @@
   
   #define bad(x)		((x).dptr == NULL || (x).dsize <= 0)
   #define exhash(item)	sdbm_hash((item).dptr, (item).dsize)
  -#define ioerr(db)	((db)->flags |= SDBM_IOERR)
  +#define ioerr(db,stat)	((db)->status = stat)
   
   /* ### Does anything need these externally? */
   #define sdbm_dirfno(db)	((db)->dirf)
  @@ -109,11 +109,11 @@
           001777777777, 003777777777, 007777777777, 017777777777
   };
   
  -const sdbm_datum sdbm_nullitem = { NULL, 0 };
  +const apr_sdbm_datum_t sdbm_nullitem = { NULL, 0 };
   
   static apr_status_t database_cleanup(void *data)
   {
  -    SDBM *db = data;
  +    apr_sdbm_t *db = data;
   
       (void) apr_file_close(db->dirf);
       (void) sdbm_unlock(db);
  @@ -123,19 +123,10 @@
       return APR_SUCCESS;
   }
   
  -apr_status_t sdbm_open(SDBM **db, const char *file, apr_int32_t flags, 
  -                       apr_fileperms_t perms, apr_pool_t *p)
  -{
  -    char *dirname = apr_pstrcat(p, file, SDBM_DIRFEXT, NULL);
  -    char *pagname = apr_pstrcat(p, file, SDBM_PAGFEXT, NULL);
  -    
  -    return sdbm_prep(db, dirname, pagname, flags, perms, p);
  -}
  -
  -apr_status_t sdbm_prep(SDBM **pdb, const char *dirname, const char *pagname,
  +apr_status_t prep(apr_sdbm_t **pdb, const char *dirname, const char *pagname,
                          apr_int32_t flags, apr_fileperms_t perms, apr_pool_t *p)
   {
  -    SDBM *db;
  +    apr_sdbm_t *db;
       apr_finfo_t finfo;
       apr_status_t status;
   
  @@ -208,25 +199,40 @@
       free(db);
       return status;
   }
  +
  +apr_status_t apr_sdbm_open(apr_sdbm_t **db, const char *file, 
  +                           apr_int32_t flags, apr_fileperms_t perms,
  +                           apr_pool_t *p)
  +{
  +    char *dirname = apr_pstrcat(p, file, SDBM_DIRFEXT, NULL);
  +    char *pagname = apr_pstrcat(p, file, SDBM_PAGFEXT, NULL);
  +    
  +    return prep(db, dirname, pagname, flags, perms, p);
  +}
   
  -void sdbm_close(SDBM *db)
  +apr_status_t apr_sdbm_close(apr_sdbm_t *db)
   {
  -    (void) apr_pool_cleanup_run(db->pool, db, database_cleanup);
  +    return apr_pool_cleanup_run(db->pool, db, database_cleanup);
   }
   
  -sdbm_datum sdbm_fetch(SDBM *db, sdbm_datum key)
  +apr_status_t apr_sdbm_fetch(apr_sdbm_t *db, apr_sdbm_datum_t *val, 
  +                            apr_sdbm_datum_t key)
   {
  +    apr_status_t status;
       if (db == NULL || bad(key))
  -        return sdbm_nullitem;
  +        return APR_EINVAL;
   
  -    if (getpage(db, exhash(key)) == APR_SUCCESS)
  -        return getpair(db->pagbuf, key);
  +    if ((status = getpage(db, exhash(key))) == APR_SUCCESS) {
  +        *val = getpair(db->pagbuf, key);
  +        /* ### do we want a not-found result? */
  +        return APR_SUCCESS;
  +    }
   
  -    ioerr(db);
  -    return sdbm_nullitem;
  +    ioerr(db, status);
  +    return status;
   }
   
  -static apr_status_t write_page(SDBM *db, const char *buf, long pagno)
  +static apr_status_t write_page(apr_sdbm_t *db, const char *buf, long pagno)
   {
       apr_status_t status;
       apr_off_t off = OFF_PAG(pagno);
  @@ -234,23 +240,23 @@
       if ((status = apr_file_seek(db->pagf, APR_SET, &off)) != APR_SUCCESS ||
           (status = apr_file_write_full(db->pagf, buf, PBLKSIZ, NULL)) 
                   != APR_SUCCESS) {
  -        ioerr(db);
  +        ioerr(db, status);
           return status;
       }
       
       return APR_SUCCESS;
   }
   
  -apr_status_t sdbm_delete(SDBM *db, const sdbm_datum key)
  +apr_status_t apr_sdbm_delete(apr_sdbm_t *db, const apr_sdbm_datum_t key)
   {
       apr_status_t status;
   
       if (db == NULL || bad(key))
           return APR_EINVAL;
  -    if (sdbm_rdonly(db))
  +    if (apr_sdbm_rdonly(db))
           return APR_EINVAL;
   
  -    if (getpage(db, exhash(key)) == APR_SUCCESS) {
  +    if ((status = getpage(db, exhash(key))) == APR_SUCCESS) {
           if (!delpair(db->pagbuf, key))
               /* ### should we define some APRUTIL codes? */
               return APR_EGENERAL;
  @@ -264,11 +270,12 @@
           return APR_SUCCESS;
       }
   
  -    ioerr(db);
  +    ioerr(db, status);
       return APR_EACCES;
   }
   
  -apr_status_t sdbm_store(SDBM *db, sdbm_datum key, sdbm_datum val, int flags)
  +apr_status_t apr_sdbm_store(apr_sdbm_t *db, apr_sdbm_datum_t key, 
  +                            apr_sdbm_datum_t val, int flags)
   {
       int need;
       register long hash;
  @@ -276,7 +283,7 @@
   
       if (db == NULL || bad(key))
           return APR_EINVAL;
  -    if (sdbm_rdonly(db))
  +    if (apr_sdbm_rdonly(db))
           return APR_EINVAL;
   
       need = key.dsize + val.dsize;
  @@ -292,12 +299,10 @@
            * if we need to replace, delete the key/data pair
            * first. If it is not there, ignore.
            */
  -        if (flags == SDBM_REPLACE)
  +        if (flags == APR_SDBM_REPLACE)
               (void) delpair(db->pagbuf, key);
  -#ifdef SEEDUPS
  -        else if (duppair(db->pagbuf, key))
  +        else if (!(flags & APR_SDBM_INSERTDUP) && duppair(db->pagbuf, key))
               return APR_EEXIST;
  -#endif
           /*
            * if we do not have enough room, we have to split.
            */
  @@ -316,7 +321,7 @@
           return APR_SUCCESS;
       }
       
  -    ioerr(db);
  +    ioerr(db, status);
       return status;
   }
   
  @@ -325,7 +330,7 @@
    * this routine will attempt to make room for SPLTMAX times before
    * giving up.
    */
  -static apr_status_t makroom(SDBM *db, long hash, int need)
  +static apr_status_t makroom(apr_sdbm_t *db, long hash, int need)
   {
       long newp;
       char twin[PBLKSIZ];
  @@ -426,32 +431,34 @@
    * the following two routines will break if
    * deletions aren't taken into account. (ndbm bug)
    */
  -sdbm_datum sdbm_firstkey(SDBM *db)
  +apr_status_t apr_sdbm_firstkey(apr_sdbm_t *db, apr_sdbm_datum_t *key)
   {
       /*
        * start at page 0
        */
  -    if (read_from(db->pagf, db->pagbuf, OFF_PAG(0), PBLKSIZ) != APR_SUCCESS) {
  -        ioerr(db);
  -        return sdbm_nullitem;
  +    apr_status_t status;
  +    if ((status = read_from(db->pagf, db->pagbuf, OFF_PAG(0), PBLKSIZ))
  +                != APR_SUCCESS) {
  +        ioerr(db, status);
  +        return status;
       }
   
       db->pagbno = 0;
       db->blkptr = 0;
       db->keyptr = 0;
   
  -    return getnext(db);
  +    return getnext(key, db);
   }
   
  -sdbm_datum sdbm_nextkey(SDBM *db)
  +apr_status_t apr_sdbm_nextkey(apr_sdbm_t *db, apr_sdbm_datum_t *key)
   {
  -    return getnext(db);
  +    return getnext(key, db);
   }
   
   /*
    * all important binary tree traversal
    */
  -static apr_status_t getpage(SDBM *db, long hash)
  +static apr_status_t getpage(apr_sdbm_t *db, long hash)
   {
       register int hbit;
       register long dbit;
  @@ -482,7 +489,7 @@
            */
           if ((status = read_from(db->pagf, db->pagbuf, OFF_PAG(pagb), PBLKSIZ)) 
               != APR_SUCCESS) {
  -            ioerr(db);		    
  +            ioerr(db, status);
               return status;
           }
   
  @@ -495,7 +502,7 @@
       return APR_SUCCESS;
   }
   
  -static int getdbit(SDBM *db, long dbit)
  +static int getdbit(apr_sdbm_t *db, long dbit)
   {
       register long c;
       register long dirb;
  @@ -516,7 +523,7 @@
       return db->dirbuf[c % DBLKSIZ] & (1 << dbit % BYTESIZ);
   }
   
  -static apr_status_t setdbit(SDBM *db, long dbit)
  +static apr_status_t setdbit(apr_sdbm_t *db, long dbit)
   {
       register long c;
       register long dirb;
  @@ -555,15 +562,14 @@
   * getnext - get the next key in the page, and if done with
   * the page, try the next page in sequence
   */
  -static sdbm_datum getnext(SDBM *db)
  +static apr_status_t getnext(apr_sdbm_datum_t *key, apr_sdbm_t *db)
   {
  -    sdbm_datum key;
  -
  +    apr_status_t status;
       for (;;) {
           db->keyptr++;
  -        key = getnkey(db->pagbuf, db->keyptr);
  -        if (key.dptr != NULL)
  -            return key;
  +        *key = getnkey(db->pagbuf, db->keyptr);
  +        if (key->dptr != NULL)
  +            return APR_SUCCESS;
           /*
            * we either run out, or there is nothing on this page..
            * try the next one... If we lost our position on the
  @@ -572,35 +578,36 @@
           db->keyptr = 0;
           if (db->pagbno != db->blkptr++) {
               apr_off_t off = OFF_PAG(db->blkptr);
  -            if (apr_file_seek(db->pagf, APR_SET, &off) != APR_SUCCESS)
  +            if ((status = apr_file_seek(db->pagf, APR_SET, &off) 
  +                        != APR_SUCCESS))
                   break;
           }
   
           db->pagbno = db->blkptr;
           /* ### EOF acceptable here too? */
  -        if (apr_file_read_full(db->pagf, db->pagbuf, PBLKSIZ, NULL) 
  -                != APR_SUCCESS)
  +        if ((status = apr_file_read_full(db->pagf, db->pagbuf, PBLKSIZ, NULL))
  +                    != APR_SUCCESS)
               break;
           if (!chkpage(db->pagbuf))
               break;
       }
       
  -    ioerr(db);
  -    return sdbm_nullitem;
  +    ioerr(db, status);
  +    return status;
   }
   
   
  -int sdbm_rdonly(SDBM *db)
  +int apr_sdbm_rdonly(apr_sdbm_t *db)
   {
       return ((db)->flags & SDBM_RDONLY);
   }
   
  -int sdbm_error(SDBM *db)
  +apr_status_t apr_sdbm_error_get(apr_sdbm_t *db)
   {
  -    return ((db)->flags & SDBM_IOERR);
  +    return ((db)->status);
   }
   
  -int sdbm_clearerr(SDBM *db)
  +int apr_sdbm_error_clear(apr_sdbm_t *db)
   {
  -    return ((db)->flags &= ~SDBM_IOERR);  /* ouch */
  +    return ((db)->status = APR_SUCCESS);
   }
  
  
  
  1.6       +2 -2      apr-util/dbm/sdbm/sdbm_lock.c
  
  Index: sdbm_lock.c
  ===================================================================
  RCS file: /home/cvs/apr-util/dbm/sdbm/sdbm_lock.c,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- sdbm_lock.c	2001/04/30 13:48:48	1.5
  +++ sdbm_lock.c	2001/04/30 17:16:19	1.6
  @@ -58,7 +58,7 @@
   #include "sdbm_private.h"
   
   /* NOTE: this function blocks until it acquires the lock */
  -apr_status_t sdbm_lock(SDBM *db, int exclusive)
  +apr_status_t sdbm_lock(apr_sdbm_t *db, int exclusive)
   {
       int type;
   
  @@ -70,7 +70,7 @@
       return apr_file_lock(db->pagf, type);
   }
   
  -apr_status_t sdbm_unlock(SDBM *db)
  +apr_status_t sdbm_unlock(apr_sdbm_t *db)
   {
       return apr_file_unlock(db->pagf);
   }
  
  
  
  1.4       +11 -13    apr-util/dbm/sdbm/sdbm_pair.c
  
  Index: sdbm_pair.c
  ===================================================================
  RCS file: /home/cvs/apr-util/dbm/sdbm/sdbm_pair.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- sdbm_pair.c	2001/02/16 04:17:09	1.3
  +++ sdbm_pair.c	2001/04/30 17:16:20	1.4
  @@ -119,8 +119,8 @@
   void
   putpair(pag, key, val)
   char *pag;
  -sdbm_datum key;
  -sdbm_datum val;
  +apr_sdbm_datum_t key;
  +apr_sdbm_datum_t val;
   {
   	register int n;
   	register int off;
  @@ -145,14 +145,14 @@
   	ino[0] += 2;
   }
   
  -sdbm_datum
  +apr_sdbm_datum_t
   getpair(pag, key)
   char *pag;
  -sdbm_datum key;
  +apr_sdbm_datum_t key;
   {
   	register int i;
   	register int n;
  -	sdbm_datum val;
  +	apr_sdbm_datum_t val;
   	register short *ino = (short *) pag;
   
   	if ((n = ino[0]) == 0)
  @@ -166,23 +166,21 @@
   	return val;
   }
   
  -#ifdef SEEDUPS
   int
   duppair(pag, key)
   char *pag;
  -sdbm_datum key;
  +apr_sdbm_datum_t key;
   {
   	register short *ino = (short *) pag;
   	return ino[0] > 0 && seepair(pag, ino[0], key.dptr, key.dsize) > 0;
   }
  -#endif
   
  -sdbm_datum
  +apr_sdbm_datum_t
   getnkey(pag, num)
   char *pag;
   int num;
   {
  -	sdbm_datum key;
  +	apr_sdbm_datum_t key;
   	register int off;
   	register short *ino = (short *) pag;
   
  @@ -201,7 +199,7 @@
   int
   delpair(pag, key)
   char *pag;
  -sdbm_datum key;
  +apr_sdbm_datum_t key;
   {
   	register int n;
   	register int i;
  @@ -296,8 +294,8 @@
   char *new;
   long sbit;
   {
  -	sdbm_datum key;
  -	sdbm_datum val;
  +	apr_sdbm_datum_t key;
  +	apr_sdbm_datum_t val;
   
   	register int n;
   	register int off = PBLKSIZ;
  
  
  
  1.3       +5 -7      apr-util/dbm/sdbm/sdbm_pair.h
  
  Index: sdbm_pair.h
  ===================================================================
  RCS file: /home/cvs/apr-util/dbm/sdbm/sdbm_pair.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- sdbm_pair.h	2001/02/16 04:17:09	1.2
  +++ sdbm_pair.h	2001/04/30 17:16:21	1.3
  @@ -66,15 +66,13 @@
   #define splpage sdbm__splpage
   
   int fitpair(char *, int);
  -void  putpair(char *, sdbm_datum, sdbm_datum);
  -sdbm_datum getpair(char *, sdbm_datum);
  -int  delpair(char *, sdbm_datum);
  +void  putpair(char *, apr_sdbm_datum_t, apr_sdbm_datum_t);
  +apr_sdbm_datum_t getpair(char *, apr_sdbm_datum_t);
  +int  delpair(char *, apr_sdbm_datum_t);
   int  chkpage (char *);
  -sdbm_datum getnkey(char *, int);
  +apr_sdbm_datum_t getnkey(char *, int);
   void splpage(char *, char *, long);
  -#ifdef SEEDUPS
  -int duppair(char *, sdbm_datum);
  -#endif
  +int duppair(char *, apr_sdbm_datum_t);
   
   #endif /* SDBM_PAIR_H */
   
  
  
  
  1.5       +11 -7     apr-util/dbm/sdbm/sdbm_private.h
  
  Index: sdbm_private.h
  ===================================================================
  RCS file: /home/cvs/apr-util/dbm/sdbm/sdbm_private.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- sdbm_private.h	2001/04/30 15:52:11	1.4
  +++ sdbm_private.h	2001/04/30 17:16:23	1.5
  @@ -67,7 +67,7 @@
   #include "apr_errno.h" /* for apr_status_t */
   
   #if 0
  -/* if the block/page size is increased, it breaks perl SDBM compatibility */
  +/* if the block/page size is increased, it breaks perl apr_sdbm_t compatibility */
   #define DBLKSIZ 16384
   #define PBLKSIZ 8192
   #define PAIRMAX 8008			/* arbitrary on PBLKSIZ-N */
  @@ -78,10 +78,11 @@
   #endif
   #define SPLTMAX	10			/* maximum allowed splits */
   
  -/* for SDBM.flags */
  +/* for apr_sdbm_t.flags */
   #define SDBM_RDONLY	0x1	       /* data base open read-only */
  -					/* for a single insertion */
  -struct SDBM {
  +#define SDBM_SHARED	0x4	       /* data base locks for shared write */
  +
  +struct apr_sdbm_t {
       apr_pool_t *pool;
       apr_file_t *dirf;		       /* directory file descriptor */
       apr_file_t *pagf;		       /* page file descriptor */
  @@ -96,11 +97,14 @@
       char pagbuf[PBLKSIZ];	       /* page file block buffer */
       long dirbno;		       /* current block in dirbuf */
       char dirbuf[DBLKSIZ];	       /* directory file block buffer */
  +    apr_status_t status;               /* track the specific last error */
   };
  +
  +apr_status_t sdbm_lock(apr_sdbm_t *db, int exclusive);
  +apr_status_t sdbm_unlock(apr_sdbm_t *db);
   
  -apr_status_t sdbm_lock(SDBM *db, int exclusive);
  -apr_status_t sdbm_unlock(SDBM *db);
  +extern const apr_sdbm_datum_t sdbm_nullitem;
   
  -extern const sdbm_datum sdbm_nullitem;
  +long sdbm_hash(const char *str, int len);
   
   #endif /* SDBM_PRIVATE_H */
  
  
  
  1.3       +0 -10     apr-util/dbm/sdbm/sdbm_tune.h
  
  Index: sdbm_tune.h
  ===================================================================
  RCS file: /home/cvs/apr-util/dbm/sdbm/sdbm_tune.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- sdbm_tune.h	2001/02/16 04:17:09	1.2
  +++ sdbm_tune.h	2001/04/30 17:16:24	1.3
  @@ -67,13 +67,6 @@
   #define BYTESIZ		8
   
   /*
  - * important tuning parms (hah)
  - */
  -
  -#define SEEDUPS			/* always detect duplicates */
  -#define BADMESS			/* generate a message for worst case:
  -				   cannot make room after SPLTMAX splits */
  -/*
    * misc
    */
   #ifdef DEBUG
  @@ -81,8 +74,5 @@
   #else
   #define debug(x)
   #endif
  -
  -apr_status_t sdbm_fd_lock(int fd, int readonly);
  -apr_status_t sdbm_fd_unlock(int fd);
   
   #endif /* SDBM_TUNE_H */
  
  
  
  1.4       +18 -24    apr-util/include/apr_sdbm.h
  
  Index: apr_sdbm.h
  ===================================================================
  RCS file: /home/cvs/apr-util/include/apr_sdbm.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- apr_sdbm.h	2001/02/16 04:17:10	1.3
  +++ apr_sdbm.h	2001/04/30 17:16:37	1.4
  @@ -65,17 +65,17 @@
   #include "apr_errno.h"
   #include "apr_file_io.h"   /* for apr_fileperms_t */
   
  -typedef struct SDBM SDBM;
  +typedef struct apr_sdbm_t apr_sdbm_t;
   
   /* utility functions */
  -int sdbm_rdonly(SDBM *db);
  -int sdbm_error(SDBM *db);
  -int sdbm_clearerr(SDBM *db);
  +int apr_sdbm_rdonly(apr_sdbm_t *db);
  +int apr_sdbm_error_get(apr_sdbm_t *db);
  +int apr_sdbm_error_clear(apr_sdbm_t *db);
   
   typedef struct {
       char *dptr;
       int dsize;
  -} sdbm_datum;
  +} apr_sdbm_datum_t;
   
   /* The extensions used for the database files */
   #define SDBM_DIRFEXT	".dir"
  @@ -83,28 +83,22 @@
   
   /* Standard dbm interface */
   
  -apr_status_t sdbm_open(SDBM **db, const char *filename, apr_int32_t flags,
  -                       apr_fileperms_t perms, apr_pool_t *p);
  +apr_status_t apr_sdbm_open(apr_sdbm_t **db, const char *filename, 
  +                           apr_int32_t flags, apr_fileperms_t perms, 
  +                           apr_pool_t *p);
   
  -void sdbm_close(SDBM *db); /* ### should return value? */
  +apr_status_t apr_sdbm_close(apr_sdbm_t *db);
   
  -sdbm_datum sdbm_fetch(SDBM *db, sdbm_datum key);
  -apr_status_t sdbm_delete(SDBM *db, const sdbm_datum key);
  +apr_status_t apr_sdbm_fetch(apr_sdbm_t *db, apr_sdbm_datum_t *val, apr_sdbm_datum_t key);
  +apr_status_t apr_sdbm_delete(apr_sdbm_t *db, const apr_sdbm_datum_t key);
   
   /* * flags to sdbm_store */
  -#define SDBM_INSERT	0
  -#define SDBM_REPLACE	1
  -apr_status_t sdbm_store(SDBM *db, sdbm_datum key, sdbm_datum value, int flags);
  -sdbm_datum sdbm_firstkey(SDBM *db);
  -sdbm_datum sdbm_nextkey(SDBM *db);
  -
  -/*
  - * other
  - */
  -apr_status_t sdbm_prep(SDBM **db, const char *dirname, const char *pagname,
  -                       apr_int32_t flags, apr_fileperms_t perms,
  -                       apr_pool_t *pool);
  -
  -long sdbm_hash(const char *str, int len);
  +#define APR_SDBM_INSERT     0
  +#define APR_SDBM_REPLACE    1
  +#define APR_SDBM_INSERTDUP  2
  +apr_status_t apr_sdbm_store(apr_sdbm_t *db, apr_sdbm_datum_t key, 
  +                            apr_sdbm_datum_t value, int flags);
  +apr_status_t apr_sdbm_firstkey(apr_sdbm_t *db, apr_sdbm_datum_t *key);
  +apr_status_t apr_sdbm_nextkey(apr_sdbm_t *db, apr_sdbm_datum_t *key);
   
   #endif /* APR_SDBM_H */
  
  
  

Mime
View raw message