You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@apr.apache.org by ia...@apache.org on 2001/09/27 19:12:07 UTC
cvs commit: apr-util/test testdbm.c
ianh 01/09/27 10:12:07
Modified: include apr_dbm.h
dbm apr_dbm.c
test testdbm.c
Log:
add a truncate option to apr_dbm_open APR_DBM_RWTRUNC
which will truncate the existing dbm if it is there
Revision Changes Path
1.13 +3 -0 apr-util/include/apr_dbm.h
Index: apr_dbm.h
===================================================================
RCS file: /home/cvs/apr-util/include/apr_dbm.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- apr_dbm.h 2001/09/09 05:54:35 1.12
+++ apr_dbm.h 2001/09/27 17:12:07 1.13
@@ -94,6 +94,8 @@
#define APR_DBM_READONLY 1 /**< open for read-only access */
#define APR_DBM_READWRITE 2 /**< open for read-write access */
#define APR_DBM_RWCREATE 3 /**< open for r/w, create if needed */
+#define APR_DBM_RWTRUNC 4 /**< open for r/w, truncating a existing
+ DB if present */
/**
* Open a dbm file by file name
@@ -104,6 +106,7 @@
* APR_DBM_READONLY open for read-only access
* APR_DBM_READWRITE open for read-write access
* APR_DBM_RWCREATE open for r/w, create if needed
+ * APR_DBM_RWTRUNC open for r/w, truncatate if already there
* </PRE>
* @param perm Permissions to apply to if created
* @param cntxt The pool to use when creating the dbm
1.28 +7 -0 apr-util/dbm/apr_dbm.c
Index: apr_dbm.c
===================================================================
RCS file: /home/cvs/apr-util/dbm/apr_dbm.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- apr_dbm.c 2001/08/29 18:34:05 1.27
+++ apr_dbm.c 2001/09/27 17:12:07 1.28
@@ -92,6 +92,7 @@
#define APR_DBM_DBMODE_RO APR_READ
#define APR_DBM_DBMODE_RW (APR_READ | APR_WRITE)
#define APR_DBM_DBMODE_RWCREATE (APR_READ | APR_WRITE | APR_CREATE)
+#define APR_DBM_DBMODE_RWTRUNC (APR_READ | APR_WRITE | APR_CREATE|APR_TRUNCATE)
#else /* Not using SDBM: */
@@ -134,6 +135,7 @@
#define APR_DBM_DBMODE_RO GDBM_READER
#define APR_DBM_DBMODE_RW GDBM_WRITER
#define APR_DBM_DBMODE_RWCREATE GDBM_WRCREAT
+#define APR_DBM_DBMODE_RWTRUNC GDBM_NEWDB
/* map a GDBM error to an apr_status_t */
static apr_status_t g2s(int gerr)
@@ -202,10 +204,12 @@
#define APR_DBM_DBMODE_RO O_RDONLY
#define APR_DBM_DBMODE_RW O_RDWR
#define APR_DBM_DBMODE_RWCREATE (O_CREAT | O_RDWR)
+#define APR_DBM_DBMODE_RWTRUNC (O_CREAT | O_RDWR|O_TRUNC)
#else
#define APR_DBM_DBMODE_RO DB_RDONLY
#define APR_DBM_DBMODE_RW 0
#define APR_DBM_DBMODE_RWCREATE DB_CREATE
+#define APR_DBM_DBMODE_RWTRUNC DB_TRUNCATE
#endif /* DBVER == 1 */
/* map a DB error to an apr_status_t */
@@ -376,6 +380,9 @@
break;
case APR_DBM_RWCREATE:
dbmode = APR_DBM_DBMODE_RWCREATE;
+ break;
+ case APR_DBM_RWTRUNC:
+ dbmode = APR_DBM_DBMODE_RWTRUNC;
break;
default:
return APR_EINVAL;
1.11 +4 -0 apr-util/test/testdbm.c
Index: testdbm.c
===================================================================
RCS file: /home/cvs/apr-util/test/testdbm.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- testdbm.c 2001/08/23 03:38:10 1.10
+++ testdbm.c 2001/09/27 17:12:07 1.11
@@ -88,6 +88,7 @@
#define DPRESS 6
#define DCREAT 7
#define DNAME 8
+#define DTRUNC 9
#define LINEMAX 8192
@@ -112,6 +113,7 @@
{ "cat", DCAT, APR_DBM_READONLY, },
{ "build", DBUILD, APR_DBM_RWCREATE, }, /** this one creates the DB */
{ "creat", DCREAT, APR_DBM_RWCREATE, },
+ { "trunc", DTRUNC, APR_DBM_RWTRUNC, },
{ "new", DCREAT, APR_DBM_RWCREATE, },
{ "names", DNAME, APR_DBM_READONLY, },
#if 0
@@ -282,6 +284,8 @@
case DPRESS:
break;
case DCREAT:
+ break;
+ case DTRUNC:
break;
case DNAME:
apr_dbm_get_usednames(pool, file, &use1, &use2);