You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by Joe Orton <jo...@orton.demon.co.uk> on 2000/08/10 14:28:18 UTC
[PATCH] sdbm code formatting cleanup
This is from running sdbm/*.[ch] through indent. No functional changes.
Index: .indent.pro
===================================================================
RCS file: .indent.pro
diff -N .indent.pro
--- /dev/null Mon Jul 18 00:46:18 1994
+++ .indent.pro Thu Aug 10 12:28:56 2000
@@ -0,0 +1,4 @@
+-i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -fc1 -brs
+-Tapr_pool_t
+-Tapr_file_t
+-TSDBM
Index: sdbm.c
===================================================================
RCS file: /home/joe/lib/cvsroot/apache2/src/lib/sdbm/sdbm.c,v
retrieving revision 1.7
diff -u -p -r1.7 sdbm.c
--- sdbm.c 2000/08/09 14:29:16 1.7
+++ sdbm.c 2000/08/10 11:29:00
@@ -74,7 +74,7 @@
/*
* forward
*/
-static int getdbit (SDBM *, long);
+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);
@@ -83,7 +83,7 @@ static apr_status_t makroom(SDBM *, long
/*
* useful macros
*/
-#define SDBM_IOERR 0x2 /* data base I/O error */
+#define SDBM_IOERR 0x2 /* data base I/O error */
#define bad(x) ((x).dptr == NULL || (x).dsize <= 0)
#define exhash(item) sdbm_hash((item).dptr, (item).dsize)
@@ -97,202 +97,201 @@ static apr_status_t makroom(SDBM *, long
#define OFF_DIR(off) (apr_off_t) (off) * DBLKSIZ
static long masks[] = {
- 000000000000, 000000000001, 000000000003, 000000000007,
- 000000000017, 000000000037, 000000000077, 000000000177,
- 000000000377, 000000000777, 000000001777, 000000003777,
- 000000007777, 000000017777, 000000037777, 000000077777,
- 000000177777, 000000377777, 000000777777, 000001777777,
- 000003777777, 000007777777, 000017777777, 000037777777,
- 000077777777, 000177777777, 000377777777, 000777777777,
- 001777777777, 003777777777, 007777777777, 017777777777
+ 000000000000, 000000000001, 000000000003, 000000000007,
+ 000000000017, 000000000037, 000000000077, 000000000177,
+ 000000000377, 000000000777, 000000001777, 000000003777,
+ 000000007777, 000000017777, 000000037777, 000000077777,
+ 000000177777, 000000377777, 000000777777, 000001777777,
+ 000003777777, 000007777777, 000017777777, 000037777777,
+ 000077777777, 000177777777, 000377777777, 000777777777,
+ 001777777777, 003777777777, 007777777777, 017777777777
};
-sdbm_datum sdbm_nullitem = {NULL, 0};
+sdbm_datum sdbm_nullitem = { NULL, 0 };
apr_status_t
-sdbm_open(SDBM **db, const char *file, apr_int32_t flags, apr_fileperms_t perms, apr_pool_t *p)
+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 **db, const char *dirname, const char *pagname,
+sdbm_prep(SDBM **db, const char *dirname, const char *pagname,
apr_int32_t flags, apr_fileperms_t perms, apr_pool_t *p)
{
- struct apr_finfo_t finfo;
- apr_status_t status;
+ struct apr_finfo_t finfo;
+ apr_status_t status;
- *db = (SDBM *) apr_pcalloc(p, sizeof(SDBM));
-
-/*
- * adjust user flags so that WRONLY becomes RDWR,
- * as required by this package. Also set our internal
- * flag for RDONLY if needed.
- */
- if (!(flags & APR_WRITE)) {
- (*db)->flags = SDBM_RDONLY;
- }
+ *db = (SDBM *) apr_pcalloc(p, sizeof(SDBM));
- flags |= APR_BINARY | APR_READ;
+ /*
+ * adjust user flags so that WRONLY becomes RDWR,
+ * as required by this package. Also set our internal
+ * flag for RDONLY if needed.
+ */
+ if (!(flags & APR_WRITE)) {
+ (*db)->flags = SDBM_RDONLY;
+ }
-/*
- * open the files in sequence, and stat the dirfile.
- * If we fail anywhere, undo everything, return NULL.
- */
+ flags |= APR_BINARY | APR_READ;
- if ((status = apr_open(&(*db)->pagf, pagname, flags, perms, p))
- == APR_SUCCESS) {
- if ((status = sdbm_lock(*db)) == APR_SUCCESS) {
- if ((status = apr_open(&(*db)->dirf, dirname, flags, perms, p))
+ /*
+ * open the files in sequence, and stat the dirfile.
+ * If we fail anywhere, undo everything, return NULL.
+ */
+
+ if ((status = apr_open(&(*db)->pagf, pagname, flags, perms, p))
+ == APR_SUCCESS) {
+ if ((status = sdbm_lock(*db)) == APR_SUCCESS) {
+ if ((status = apr_open(&(*db)->dirf, dirname, flags, perms, p))
+ == APR_SUCCESS) {
+ /*
+ * need the dirfile size to establish max bit number.
+ */
+ if ((status = apr_getfileinfo(&finfo, (*db)->dirf))
== APR_SUCCESS) {
-/*
- * need the dirfile size to establish max bit number.
- */
- if ((status = apr_getfileinfo(&finfo, (*db)->dirf))
- == APR_SUCCESS) {
-/*
- * zero size: either a fresh database, or one with a single,
- * unsplit data page: dirpage is all zeros.
- */
- (*db)->dirbno = (!finfo.size) ? 0 : -1;
- (*db)->pagbno = -1;
- (*db)->maxbno = finfo.size * BYTESIZ;
-
- /* (apr_pcalloc will zero the buffers) */
- /*
- * success
- */
- return APR_SUCCESS;
- }
- (void) apr_close((*db)->dirf);
+ /*
+ * zero size: either a fresh database, or one with a single,
+ * unsplit data page: dirpage is all zeros.
+ */
+ (*db)->dirbno = (!finfo.size) ? 0 : -1;
+ (*db)->pagbno = -1;
+ (*db)->maxbno = finfo.size * BYTESIZ;
+
+ /* (apr_pcalloc will zero the buffers) */
+ /*
+ * success
+ */
+ return APR_SUCCESS;
}
- (void) sdbm_unlock(*db);
+ (void) apr_close((*db)->dirf);
}
- (void) apr_close((*db)->pagf);
+ (void) sdbm_unlock(*db);
}
-
- *db = NULL;
- return status;
+ (void) apr_close((*db)->pagf);
+ }
+
+ *db = NULL;
+ return status;
}
-void
-sdbm_close(SDBM *db)
+void sdbm_close(SDBM *db)
{
(void) apr_close(db->dirf);
(void) sdbm_unlock(db);
(void) apr_close(db->pagf);
}
-sdbm_datum
-sdbm_fetch(SDBM *db, sdbm_datum key)
+sdbm_datum sdbm_fetch(SDBM *db, sdbm_datum key)
{
- if (db == NULL || bad(key))
- return sdbm_nullitem;
+ if (db == NULL || bad(key))
+ return sdbm_nullitem;
- if (getpage(db, exhash(key)) == APR_SUCCESS)
- return getpair(db->pagbuf, key);
+ if (getpage(db, exhash(key)) == APR_SUCCESS)
+ return getpair(db->pagbuf, key);
- ioerr(db);
- return sdbm_nullitem;
+ ioerr(db);
+ return sdbm_nullitem;
}
static apr_status_t write_page(SDBM *db, const char *buf, long pagno)
{
apr_status_t status;
apr_off_t off = OFF_PAG(pagno);
-
+
if ((status = apr_seek(db->pagf, APR_SET, &off)) != APR_SUCCESS ||
- (status = apr_full_write(db->pagf, buf, PBLKSIZ, NULL)) != APR_SUCCESS) {
+ (status =
+ apr_full_write(db->pagf, buf, PBLKSIZ, NULL)) != APR_SUCCESS) {
ioerr(db);
return status;
}
-
+
return APR_SUCCESS;
}
-apr_status_t
-sdbm_delete(SDBM *db, const sdbm_datum key)
+apr_status_t sdbm_delete(SDBM *db, const sdbm_datum key)
{
- apr_status_t status;
+ apr_status_t status;
- if (db == NULL || bad(key))
- return APR_EINVAL;
- if (sdbm_rdonly(db))
- return APR_EINVAL;
-
- if (getpage(db, exhash(key)) == APR_SUCCESS) {
- if (!delpair(db->pagbuf, key))
- return -1;
-/*
- * update the page file
- */
- if ((status = write_page(db, db->pagbuf, db->pagbno)) != APR_SUCCESS)
- return status;
+ if (db == NULL || bad(key))
+ return APR_EINVAL;
+ if (sdbm_rdonly(db))
+ return APR_EINVAL;
+
+ if (getpage(db, exhash(key)) == APR_SUCCESS) {
+ if (!delpair(db->pagbuf, key))
+ return -1;
+ /*
+ * update the page file
+ */
+ if ((status = write_page(db, db->pagbuf, db->pagbno)) != APR_SUCCESS)
+ return status;
- return APR_SUCCESS;
- }
+ return APR_SUCCESS;
+ }
- ioerr(db);
- return APR_EACCES;
+ ioerr(db);
+ return APR_EACCES;
}
apr_status_t sdbm_store(SDBM *db, sdbm_datum key, sdbm_datum val, int flags)
{
- int need;
- register long hash;
- apr_status_t status;
-
- if (db == NULL || bad(key))
- return APR_EINVAL;
- if (sdbm_rdonly(db))
- return APR_EINVAL;
+ int need;
+ register long hash;
+ apr_status_t status;
- need = key.dsize + val.dsize;
-/*
- * is the pair too big (or too small) for this database ??
- */
- if (need < 0 || need > PAIRMAX)
- return APR_EINVAL;
+ if (db == NULL || bad(key))
+ return APR_EINVAL;
+ if (sdbm_rdonly(db))
+ return APR_EINVAL;
+
+ need = key.dsize + val.dsize;
+ /*
+ * is the pair too big (or too small) for this database ??
+ */
+ if (need < 0 || need > PAIRMAX)
+ return APR_EINVAL;
- if ((status = getpage(db, (hash = exhash(key)))) == APR_SUCCESS) {
+ if ((status = getpage(db, (hash = exhash(key)))) == APR_SUCCESS) {
-/*
- * if we need to replace, delete the key/data pair
- * first. If it is not there, ignore.
- */
- if (flags == SDBM_REPLACE)
- (void) delpair(db->pagbuf, key);
+ /*
+ * if we need to replace, delete the key/data pair
+ * first. If it is not there, ignore.
+ */
+ if (flags == SDBM_REPLACE)
+ (void) delpair(db->pagbuf, key);
#ifdef SEEDUPS
- else if (duppair(db->pagbuf, key))
- return APR_EEXIST;
+ else if (duppair(db->pagbuf, key))
+ return APR_EEXIST;
#endif
-/*
- * if we do not have enough room, we have to split.
- */
- if (!fitpair(db->pagbuf, need))
- if ((status = makroom(db, hash, need)) != APR_SUCCESS)
- return status;
-/*
- * we have enough room or split is successful. insert the key,
- * and update the page file.
- */
- (void) putpair(db->pagbuf, key, val);
+ /*
+ * if we do not have enough room, we have to split.
+ */
+ if (!fitpair(db->pagbuf, need))
+ if ((status = makroom(db, hash, need)) != APR_SUCCESS)
+ return status;
+ /*
+ * we have enough room or split is successful. insert the key,
+ * and update the page file.
+ */
+ (void) putpair(db->pagbuf, key, val);
- if ((status = write_page(db, db->pagbuf, db->pagbno)) != APR_SUCCESS)
- return status;
+ if ((status = write_page(db, db->pagbuf, db->pagbno)) != APR_SUCCESS)
+ return status;
/*
* success
*/
- return APR_SUCCESS;
- }
-
- ioerr(db);
- return status;
+ return APR_SUCCESS;
+ }
+
+ ioerr(db);
+ return status;
}
/*
@@ -300,77 +299,75 @@ apr_status_t sdbm_store(SDBM *db, sdbm_d
* 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(SDBM *db, long hash, int need)
{
- long newp;
- char twin[PBLKSIZ];
- char *pag = db->pagbuf;
- char *new = twin;
- register int smax = SPLTMAX;
- apr_status_t status;
+ long newp;
+ char twin[PBLKSIZ];
+ char *pag = db->pagbuf;
+ char *new = twin;
+ register int smax = SPLTMAX;
+ apr_status_t status;
- do {
-/*
- * split the current page
- */
- (void) splpage(pag, new, db->hmask + 1);
-/*
- * address of the new page
- */
- newp = (hash & db->hmask) | (db->hmask + 1);
+ do {
+ /*
+ * split the current page
+ */
+ (void) splpage(pag, new, db->hmask + 1);
+ /*
+ * address of the new page
+ */
+ newp = (hash & db->hmask) | (db->hmask + 1);
-/*
- * write delay, read avoidence/cache shuffle:
- * select the page for incoming pair: if key is to go to the new page,
- * write out the previous one, and copy the new one over, thus making
- * it the current page. If not, simply write the new page, and we are
- * still looking at the page of interest. current page is not updated
- * here, as sdbm_store will do so, after it inserts the incoming pair.
- */
- if (hash & (db->hmask + 1)) {
- if ((status = write_page(db, db->pagbuf, db->pagbno)) != APR_SUCCESS)
- return status;
-
- db->pagbno = newp;
- (void) memcpy(pag, new, PBLKSIZ);
- }
- else {
- if ((status = write_page(db, new, newp)) != APR_SUCCESS)
- return status;
- }
+ /*
+ * write delay, read avoidence/cache shuffle:
+ * select the page for incoming pair: if key is to go to the new page,
+ * write out the previous one, and copy the new one over, thus making
+ * it the current page. If not, simply write the new page, and we are
+ * still looking at the page of interest. current page is not updated
+ * here, as sdbm_store will do so, after it inserts the incoming pair.
+ */
+ if (hash & (db->hmask + 1)) {
+ if ((status = write_page(db, db->pagbuf, db->pagbno)) !=
+ APR_SUCCESS) return status;
- if ((status = setdbit(db, db->curbit)) != APR_SUCCESS)
- return status;
-/*
- * see if we have enough room now
- */
- if (fitpair(pag, need))
- return APR_SUCCESS;
-/*
- * try again... update curbit and hmask as getpage would have
- * done. because of our update of the current page, we do not
- * need to read in anything. BUT we have to write the current
- * [deferred] page out, as the window of failure is too great.
- */
- db->curbit = 2 * db->curbit +
- ((hash & (db->hmask + 1)) ? 2 : 1);
- db->hmask |= db->hmask + 1;
-
- if ((status = write_page(db, db->pagbuf, db->pagbno))
- != APR_SUCCESS)
- return status;
-
- } while (--smax);
-/*
- * if we are here, this is real bad news. After SPLTMAX splits,
- * we still cannot fit the key. say goodnight.
- */
+ db->pagbno = newp;
+ (void) memcpy(pag, new, PBLKSIZ);
+ }
+ else {
+ if ((status = write_page(db, new, newp)) != APR_SUCCESS)
+ return status;
+ }
+
+ if ((status = setdbit(db, db->curbit)) != APR_SUCCESS)
+ return status;
+ /*
+ * see if we have enough room now
+ */
+ if (fitpair(pag, need))
+ return APR_SUCCESS;
+ /*
+ * try again... update curbit and hmask as getpage would have
+ * done. because of our update of the current page, we do not
+ * need to read in anything. BUT we have to write the current
+ * [deferred] page out, as the window of failure is too great.
+ */
+ db->curbit = 2 * db->curbit + ((hash & (db->hmask + 1)) ? 2 : 1);
+ db->hmask |= db->hmask + 1;
+
+ if ((status = write_page(db, db->pagbuf, db->pagbno))
+ != APR_SUCCESS)
+ return status;
+
+ } while (--smax);
+ /*
+ * if we are here, this is real bad news. After SPLTMAX splits,
+ * we still cannot fit the key. say goodnight.
+ */
#if 0
- (void) write(2, "sdbm: cannot insert after SPLTMAX attempts.\n", 44);
+ (void) write(2, "sdbm: cannot insert after SPLTMAX attempts.\n", 44);
#endif
- /* ### ENOSPC not really appropriate but better than nothing */
- return APR_ENOSPC;
+ /* ### ENOSPC not really appropriate but better than nothing */
+ return APR_ENOSPC;
}
@@ -378,8 +375,8 @@ makroom(SDBM *db, long hash, int need)
* 'off' is given relative to the start of the file.
* If EOF is returned while reading, this is taken as success.
*/
-static apr_status_t read_from(apr_file_t *f, void *buf,
- apr_off_t off, apr_size_t len)
+static apr_status_t read_from(apr_file_t *f, void *buf,
+ apr_off_t off, apr_size_t len)
{
apr_status_t status;
@@ -400,172 +397,163 @@ static apr_status_t read_from(apr_file_t
* the following two routines will break if
* deletions aren't taken into account. (ndbm bug)
*/
-sdbm_datum
-sdbm_firstkey(SDBM *db)
+sdbm_datum sdbm_firstkey(SDBM *db)
{
-/*
- * start at page 0
- */
- if (read_from(db->pagf, db->pagbuf, OFF_PAG(0), PBLKSIZ) != APR_SUCCESS) {
- ioerr(db);
- return sdbm_nullitem;
- }
+ /* start at page 0 */
+ if (read_from(db->pagf, db->pagbuf, OFF_PAG(0), PBLKSIZ) != APR_SUCCESS) {
+ ioerr(db);
+ return sdbm_nullitem;
+ }
- db->pagbno = 0;
- db->blkptr = 0;
- db->keyptr = 0;
+ db->pagbno = 0;
+ db->blkptr = 0;
+ db->keyptr = 0;
- return getnext(db);
+ return getnext(db);
}
-sdbm_datum
-sdbm_nextkey(SDBM *db)
+sdbm_datum sdbm_nextkey(SDBM *db)
{
- return getnext(db);
+ return getnext(db);
}
/*
* all important binary tree traversal
*/
-static apr_status_t
-getpage(SDBM *db, long hash)
+static apr_status_t getpage(SDBM *db, long hash)
{
- register int hbit;
- register long dbit;
- register long pagb;
- apr_status_t status;
-
- dbit = 0;
- hbit = 0;
- while (dbit < db->maxbno && getdbit(db, dbit))
- dbit = 2 * dbit + ((hash & (1 << hbit++)) ? 2 : 1);
-
- debug(("dbit: %d...", dbit));
-
- db->curbit = dbit;
- db->hmask = masks[hbit];
+ register int hbit;
+ register long dbit;
+ register long pagb;
+ apr_status_t status;
- pagb = hash & db->hmask;
-/*
- * see if the block we need is already in memory.
- * note: this lookaside cache has about 10% hit rate.
- */
- if (pagb != db->pagbno) {
-/*
- * note: here, we assume a "hole" is read as 0s.
- * if not, must zero pagbuf first.
- * ### joe: this assumption was surely never correct? but
- * ### we make it so in read_from anyway.
- */
- if ((status = read_from(db->pagf, db->pagbuf, OFF_PAG(pagb), PBLKSIZ))
- != APR_SUCCESS) {
- ioerr(db);
- return status;
- }
+ dbit = 0;
+ hbit = 0;
+ while (dbit < db->maxbno && getdbit(db, dbit))
+ dbit = 2 * dbit + ((hash & (1 << hbit++)) ? 2 : 1);
+
+ debug(("dbit: %d...", dbit));
+
+ db->curbit = dbit;
+ db->hmask = masks[hbit];
+
+ pagb = hash & db->hmask;
+ /*
+ * see if the block we need is already in memory.
+ * note: this lookaside cache has about 10% hit rate.
+ */
+ if (pagb != db->pagbno) {
+ /* note: here, we assume a "hole" is read as 0s.
+ * if not, must zero pagbuf first.
+ * ### joe: this assumption was surely never correct? but
+ * ### we make it so in read_from anyway.
+ */
+ if ((status = read_from(db->pagf, db->pagbuf, OFF_PAG(pagb), PBLKSIZ))
+ != APR_SUCCESS) {
+ ioerr(db);
+ return status;
+ }
- if (!chkpage(db->pagbuf))
- return APR_ENOSPC; /* ### better error? */
- db->pagbno = pagb;
+ if (!chkpage(db->pagbuf))
+ return APR_ENOSPC; /* ### better error? */
+ db->pagbno = pagb;
- debug(("pag read: %d\n", pagb));
- }
- return APR_SUCCESS;
+ debug(("pag read: %d\n", pagb));
+ }
+ return APR_SUCCESS;
}
-static int
-getdbit(SDBM *db, long dbit)
+static int getdbit(SDBM *db, long dbit)
{
- register long c;
- register long dirb;
+ register long c;
+ register long dirb;
- c = dbit / BYTESIZ;
- dirb = c / DBLKSIZ;
+ c = dbit / BYTESIZ;
+ dirb = c / DBLKSIZ;
- if (dirb != db->dirbno) {
- if (read_from(db->dirf, db->dirbuf, OFF_DIR(dirb), DBLKSIZ)
- != APR_SUCCESS)
- return 0;
+ if (dirb != db->dirbno) {
+ if (read_from(db->dirf, db->dirbuf, OFF_DIR(dirb), DBLKSIZ)
+ != APR_SUCCESS)
+ return 0;
- db->dirbno = dirb;
+ db->dirbno = dirb;
- debug(("dir read: %d\n", dirb));
- }
+ debug(("dir read: %d\n", dirb));
+ }
- return db->dirbuf[c % DBLKSIZ] & (1 << dbit % BYTESIZ);
+ return db->dirbuf[c % DBLKSIZ] & (1 << dbit % BYTESIZ);
}
-static apr_status_t
-setdbit(SDBM *db, long dbit)
+static apr_status_t setdbit(SDBM *db, long dbit)
{
- register long c;
- register long dirb;
- apr_status_t status;
- apr_off_t off;
+ register long c;
+ register long dirb;
+ apr_status_t status;
+ apr_off_t off;
- c = dbit / BYTESIZ;
- dirb = c / DBLKSIZ;
+ c = dbit / BYTESIZ;
+ dirb = c / DBLKSIZ;
- if (dirb != db->dirbno) {
- if ((status = read_from(db->dirf, db->dirbuf, OFF_DIR(dirb), DBLKSIZ))
- != APR_SUCCESS)
- return status;
+ if (dirb != db->dirbno) {
+ if ((status = read_from(db->dirf, db->dirbuf, OFF_DIR(dirb), DBLKSIZ))
+ != APR_SUCCESS)
+ return status;
- db->dirbno = dirb;
-
- debug(("dir read: %d\n", dirb));
- }
+ db->dirbno = dirb;
- db->dirbuf[c % DBLKSIZ] |= (1 << dbit % BYTESIZ);
+ debug(("dir read: %d\n", dirb));
+ }
- if (dbit >= db->maxbno)
- db->maxbno += DBLKSIZ * BYTESIZ;
+ db->dirbuf[c % DBLKSIZ] |= (1 << dbit % BYTESIZ);
- off = OFF_DIR(dirb);
- if (((status = apr_seek(db->dirf, APR_SET, &off)) != APR_SUCCESS)
- || (status = apr_full_write(db->dirf, db->dirbuf, DBLKSIZ,
- NULL)) != APR_SUCCESS) {
- return status;
- }
+ if (dbit >= db->maxbno)
+ db->maxbno += DBLKSIZ * BYTESIZ;
- return APR_SUCCESS;
+ off = OFF_DIR(dirb);
+ if (((status = apr_seek(db->dirf, APR_SET, &off)) != APR_SUCCESS)
+ || (status = apr_full_write(db->dirf, db->dirbuf, DBLKSIZ,
+ NULL)) != APR_SUCCESS) {
+ return status;
+ }
+
+ return APR_SUCCESS;
}
/*
* 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 sdbm_datum getnext(SDBM *db)
{
- sdbm_datum key;
-
- for (;;) {
- db->keyptr++;
- key = getnkey(db->pagbuf, db->keyptr);
- if (key.dptr != NULL)
- return key;
-/*
- * we either run out, or there is nothing on this page..
- * try the next one... If we lost our position on the
- * file, we will have to seek.
- */
- db->keyptr = 0;
- if (db->pagbno != db->blkptr++) {
- apr_off_t off = OFF_PAG(db->blkptr);
- if (apr_seek(db->pagf, APR_SET, &off) != APR_SUCCESS)
- break;
- }
+ sdbm_datum key;
- db->pagbno = db->blkptr;
- /* ### EOF acceptable here too? */
- if (apr_full_read(db->pagf, db->pagbuf, PBLKSIZ, NULL) != APR_SUCCESS)
- break;
- if (!chkpage(db->pagbuf))
- break;
+ for (;;) {
+ db->keyptr++;
+ key = getnkey(db->pagbuf, db->keyptr);
+ if (key.dptr != NULL)
+ return key;
+ /*
+ * we either run out, or there is nothing on this page..
+ * try the next one... If we lost our position on the
+ * file, we will have to seek.
+ */
+ db->keyptr = 0;
+ if (db->pagbno != db->blkptr++) {
+ apr_off_t off = OFF_PAG(db->blkptr);
+ if (apr_seek(db->pagf, APR_SET, &off) != APR_SUCCESS)
+ break;
}
-
- ioerr(db);
- return sdbm_nullitem;
+
+ db->pagbno = db->blkptr;
+ /* ### EOF acceptable here too? */
+ if (apr_full_read(db->pagf, db->pagbuf, PBLKSIZ, NULL) != APR_SUCCESS)
+ break;
+ if (!chkpage(db->pagbuf))
+ break;
+ }
+
+ ioerr(db);
+ return sdbm_nullitem;
}
@@ -581,5 +569,5 @@ int sdbm_error(SDBM *db)
int sdbm_clearerr(SDBM *db)
{
- return ((db)->flags &= ~SDBM_IOERR); /* ouch */
+ return ((db)->flags &= ~SDBM_IOERR); /* ouch */
}
Index: sdbm.h
===================================================================
RCS file: /home/joe/lib/cvsroot/apache2/src/lib/sdbm/sdbm.h,v
retrieving revision 1.3
diff -u -p -r1.3 sdbm.h
--- sdbm.h 2000/08/02 05:26:46 1.3
+++ sdbm.h 2000/08/10 11:29:00
@@ -62,7 +62,7 @@
#ifndef SDBM_H
#define SDBM_H
-#include "apr_file_io.h" /* for apr_fileperms_t */
+#include "apr_file_io.h" /* for apr_fileperms_t */
typedef struct SDBM SDBM;
@@ -85,12 +85,12 @@ extern sdbm_datum sdbm_nullitem;
/* Standard dbm interface */
/* Flags to sdbm_open */
-#define SDBM_RDONLY 0x1 /* data base open read-only */
+#define SDBM_RDONLY 0x1 /* data base open read-only */
-apr_status_t sdbm_open(SDBM **db, const char *filename,
- int flags, apr_fileperms_t perms, apr_pool_t *p);
+apr_status_t sdbm_open(SDBM **db, const char *filename,
+ int flags, apr_fileperms_t perms, apr_pool_t *p);
-void sdbm_close(SDBM *db); /* ### should return value? */
+void sdbm_close(SDBM *db); /* ### should return value? */
sdbm_datum sdbm_fetch(SDBM *db, sdbm_datum key);
apr_status_t sdbm_delete(SDBM *db, const sdbm_datum key);
@@ -106,7 +106,7 @@ sdbm_datum sdbm_nextkey(SDBM *db);
* other
*/
apr_status_t sdbm_prep(SDBM **db, const char *dirname, const char *pagname,
- int flags, apr_fileperms_t perms, apr_pool_t *pool);
+ int flags, apr_fileperms_t perms, apr_pool_t *pool);
long sdbm_hash(const char *str, int len);
Index: sdbm_hash.c
===================================================================
RCS file: /home/joe/lib/cvsroot/apache2/src/lib/sdbm/sdbm_hash.c,v
retrieving revision 1.2
diff -u -p -r1.2 sdbm_hash.c
--- sdbm_hash.c 2000/07/13 10:11:23 1.2
+++ sdbm_hash.c 2000/08/10 11:29:00
@@ -67,34 +67,46 @@
* polynomial conversion ignoring overflows
* [this seems to work remarkably well, in fact better
* then the ndbm hash function. Replace at your own risk]
- * use: 65599 nice.
+ * use: 65599 nice.
* 65587 even better.
*/
long sdbm_hash(const char *str, int len)
{
- register unsigned long n = 0;
+ register unsigned long n = 0;
-#define DUFF /* go ahead and use the loop-unrolled version */
+#define DUFF /* go ahead and use the loop-unrolled version */
#ifdef DUFF
#define HASHC n = *str++ + 65599 * n
- if (len > 0) {
- register int loop = (len + 8 - 1) >> 3;
+ if (len > 0) {
+ register int loop = (len + 8 - 1) >> 3;
- switch(len & (8 - 1)) {
- case 0: do {
- HASHC; case 7: HASHC;
- case 6: HASHC; case 5: HASHC;
- case 4: HASHC; case 3: HASHC;
- case 2: HASHC; case 1: HASHC;
- } while (--loop);
- }
-
+ switch (len & (8 - 1)) {
+ case 0:
+ do {
+ HASHC;
+ case 7:
+ HASHC;
+ case 6:
+ HASHC;
+ case 5:
+ HASHC;
+ case 4:
+ HASHC;
+ case 3:
+ HASHC;
+ case 2:
+ HASHC;
+ case 1:
+ HASHC;
+ } while (--loop);
}
+
+ }
#else
- while (len--)
- n = *str++ + 65599 * n;
+ while (len--)
+ n = *str++ + 65599 * n;
#endif
- return n;
+ return n;
}
Index: sdbm_lock.c
===================================================================
RCS file: /home/joe/lib/cvsroot/apache2/src/lib/sdbm/sdbm_lock.c,v
retrieving revision 1.5
diff -u -p -r1.5 sdbm_lock.c
--- sdbm_lock.c 2000/08/02 05:26:46 1.5
+++ sdbm_lock.c 2000/08/10 12:19:53
@@ -70,7 +70,7 @@ static apr_status_t create_lock(SDBM *db
{
/* ### this should be specific to the file... */
return apr_create_lock(&sdbm_lock_object, APR_MUTEX, APR_LOCKALL,
- NULL, NULL);
+ NULL, NULL);
}
/* NOTE: this function blocks until it acquires the lock */
@@ -79,13 +79,13 @@ apr_status_t sdbm_lock(SDBM *db)
apr_status_t status;
if (sdbm_lock_object == NULL) {
- if ((status = create_lock(db)) != APR_SUCCESS) {
- return status;
- }
+ if ((status = create_lock(db)) != APR_SUCCESS) {
+ return status;
+ }
}
/* ### incorrect locking semantics. need some APR work first */
-/* return apr_lock(sdbm_lock_object); */
+ /* return apr_lock(sdbm_lock_object); */
return APR_SUCCESS;
}
@@ -94,12 +94,12 @@ apr_status_t sdbm_unlock(SDBM *db)
apr_status_t status;
if (sdbm_lock_object == NULL) {
- if ((status = create_lock(db)) != APR_SUCCESS) {
- return status;
- }
+ if ((status = create_lock(db)) != APR_SUCCESS) {
+ return status;
+ }
}
/* ### incorrect locking semantics. need some APR work first */
-/* return apr_unlock(sdbm_lock_object); */
+ /* return apr_unlock(sdbm_lock_object); */
return APR_SUCCESS;
}
Index: sdbm_pair.c
===================================================================
RCS file: /home/joe/lib/cvsroot/apache2/src/lib/sdbm/sdbm_pair.c,v
retrieving revision 1.2
diff -u -p -r1.2 sdbm_pair.c
--- sdbm_pair.c 2000/07/13 10:11:23 1.2
+++ sdbm_pair.c 2000/08/10 12:22:15
@@ -66,7 +66,7 @@
#include "sdbm_pair.h"
#include "sdbm_private.h"
-#include <string.h> /* for memset() */
+#include <string.h> /* for memset() */
#define exhash(item) sdbm_hash((item).dptr, (item).dsize)
@@ -78,17 +78,17 @@ static int seepair(char *, int, char *,
/*
* page format:
- * +------------------------------+
- * ino | n | keyoff | datoff | keyoff |
- * +------------+--------+--------+
- * | datoff | - - - ----> |
- * +--------+---------------------+
- * | F R E E A R E A |
- * +--------------+---------------+
- * | <---- - - - | data |
- * +--------+-----+----+----------+
- * | key | data | key |
- * +--------+----------+----------+
+ * +------------------------------+
+ * ino | n | keyoff | datoff | keyoff |
+ * +------------+--------+--------+
+ * | datoff | - - - ----> |
+ * +--------+---------------------+
+ * | F R E E A R E A |
+ * +--------------+---------------+
+ * | <---- - - - | data |
+ * +--------+-----+----+----------+
+ * | key | data | key |
+ * +--------+----------+----------+
*
* calculating the offsets for free area: if the number
* of entries (ino[0]) is zero, the offset to the END of
@@ -96,172 +96,175 @@ static int seepair(char *, int, char *,
* nth (ino[ino[0]]) entry's offset.
*/
-int
-fitpair(pag, need)
-char *pag;
-int need;
+int fitpair(pag, need)
+ char *pag;
+ int need;
{
- register int n;
- register int off;
- register int avail;
- register short *ino = (short *) pag;
-
- off = ((n = ino[0]) > 0) ? ino[n] : PBLKSIZ;
- avail = off - (n + 1) * sizeof(short);
- need += 2 * sizeof(short);
+ register int n;
+ register int off;
+ register int avail;
+ register short *ino = (short *) pag;
+
+ off = ((n = ino[0]) > 0) ? ino[n] : PBLKSIZ;
+ avail = off - (n + 1) * sizeof(short);
+ need += 2 * sizeof(short);
- debug(("avail %d need %d\n", avail, need));
+ debug(("avail %d need %d\n", avail, need));
- return need <= avail;
+ return need <= avail;
}
-void
-putpair(pag, key, val)
-char *pag;
-sdbm_datum key;
-sdbm_datum val;
+void putpair(pag, key, val)
+ char *pag;
+ sdbm_datum key;
+ sdbm_datum val;
{
- register int n;
- register int off;
- register short *ino = (short *) pag;
+ register int n;
+ register int off;
+ register short *ino = (short *) pag;
+
+ off = ((n = ino[0]) > 0) ? ino[n] : PBLKSIZ;
+
+ /* enter the key first */
+ off -= key.dsize;
+ (void) memcpy(pag + off, key.dptr, key.dsize);
+ ino[n + 1] = off;
+
+ /* now the data */
+ off -= val.dsize;
+ (void) memcpy(pag + off, val.dptr, val.dsize);
+ ino[n + 2] = off;
- off = ((n = ino[0]) > 0) ? ino[n] : PBLKSIZ;
-/*
- * enter the key first
- */
- off -= key.dsize;
- (void) memcpy(pag + off, key.dptr, key.dsize);
- ino[n + 1] = off;
-/*
- * now the data
- */
- off -= val.dsize;
- (void) memcpy(pag + off, val.dptr, val.dsize);
- ino[n + 2] = off;
-/*
- * adjust item count
- */
- ino[0] += 2;
+ /* adjust item count */
+ ino[0] += 2;
}
-sdbm_datum
-getpair(pag, key)
-char *pag;
-sdbm_datum key;
+sdbm_datum getpair(pag, key)
+ char *pag;
+ sdbm_datum key;
{
- register int i;
- register int n;
- sdbm_datum val;
- register short *ino = (short *) pag;
-
- if ((n = ino[0]) == 0)
- return sdbm_nullitem;
-
- if ((i = seepair(pag, n, key.dptr, key.dsize)) == 0)
- return sdbm_nullitem;
-
- val.dptr = pag + ino[i + 1];
- val.dsize = ino[i] - ino[i + 1];
- return val;
+ register int i;
+ register int n;
+ sdbm_datum val;
+ register short *ino = (short *) pag;
+
+ if ((n = ino[0]) == 0)
+ return sdbm_nullitem;
+
+ if ((i = seepair(pag, n, key.dptr, key.dsize)) == 0)
+ return sdbm_nullitem;
+
+ val.dptr = pag + ino[i + 1];
+ val.dsize = ino[i] - ino[i + 1];
+ return val;
}
#ifdef SEEDUPS
-int
-duppair(pag, key)
-char *pag;
-sdbm_datum key;
+int duppair(pag, key)
+ char *pag;
+ sdbm_datum key;
{
- register short *ino = (short *) pag;
- return ino[0] > 0 && seepair(pag, ino[0], key.dptr, key.dsize) > 0;
+ register short *ino = (short *) pag;
+ return ino[0] > 0 && seepair(pag, ino[0], key.dptr, key.dsize) > 0;
}
#endif
-sdbm_datum
-getnkey(pag, num)
-char *pag;
-int num;
+sdbm_datum getnkey(pag, num)
+ char *pag;
+ int num;
{
- sdbm_datum key;
- register int off;
- register short *ino = (short *) pag;
+ sdbm_datum key;
+ register int off;
+ register short *ino = (short *) pag;
- num = num * 2 - 1;
- if (ino[0] == 0 || num > ino[0])
- return sdbm_nullitem;
+ num = num * 2 - 1;
+ if (ino[0] == 0 || num > ino[0])
+ return sdbm_nullitem;
- off = (num > 1) ? ino[num - 1] : PBLKSIZ;
+ off = (num > 1) ? ino[num - 1] : PBLKSIZ;
- key.dptr = pag + ino[num];
- key.dsize = off - ino[num];
+ key.dptr = pag + ino[num];
+ key.dsize = off - ino[num];
- return key;
+ return key;
}
-int
-delpair(pag, key)
-char *pag;
-sdbm_datum key;
+int delpair(pag, key)
+ char *pag;
+ sdbm_datum key;
{
- register int n;
- register int i;
- register short *ino = (short *) pag;
-
- if ((n = ino[0]) == 0)
- return 0;
+ register int n;
+ register int i;
+ register short *ino = (short *) pag;
- if ((i = seepair(pag, n, key.dptr, key.dsize)) == 0)
- return 0;
-/*
- * found the key. if it is the last entry
- * [i.e. i == n - 1] we just adjust the entry count.
- * hard case: move all data down onto the deleted pair,
- * shift offsets onto deleted offsets, and adjust them.
- * [note: 0 < i < n]
- */
- if (i < n - 1) {
- register int m;
- register char *dst = pag + (i == 1 ? PBLKSIZ : ino[i - 1]);
- register char *src = pag + ino[i + 1];
- register int zoo = dst - src;
+ if ((n = ino[0]) == 0)
+ return 0;
- debug(("free-up %d ", zoo));
-/*
- * shift data/keys down
- */
- m = ino[i + 1] - ino[n];
+ if ((i = seepair(pag, n, key.dptr, key.dsize)) == 0)
+ return 0;
+ /*
+ * found the key. if it is the last entry
+ * [i.e. i == n - 1] we just adjust the entry count.
+ * hard case: move all data down onto the deleted pair,
+ * shift offsets onto deleted offsets, and adjust them.
+ * [note: 0 < i < n]
+ */
+ if (i < n - 1) {
+ register int m;
+ register char *dst = pag + (i == 1 ? PBLKSIZ : ino[i - 1]);
+ register char *src = pag + ino[i + 1];
+ register int zoo = dst - src;
+
+ debug(("free-up %d ", zoo));
+ /*
+ * shift data/keys down
+ */
+ m = ino[i + 1] - ino[n];
-#undef DUFF /* just use memmove. it should be plenty fast. */
+#undef DUFF /* just use memmove. it should be plenty fast. */
#ifdef DUFF
#define MOVB *--dst = *--src
- if (m > 0) {
- register int loop = (m + 8 - 1) >> 3;
+ if (m > 0) {
+ register int loop = (m + 8 - 1) >> 3;
- switch (m & (8 - 1)) {
- case 0: do {
- MOVB; case 7: MOVB;
- case 6: MOVB; case 5: MOVB;
- case 4: MOVB; case 3: MOVB;
- case 2: MOVB; case 1: MOVB;
- } while (--loop);
- }
- }
+ switch (m & (8 - 1)) {
+ case 0:
+ do {
+ MOVB;
+ case 7:
+ MOVB;
+ case 6:
+ MOVB;
+ case 5:
+ MOVB;
+ case 4:
+ MOVB;
+ case 3:
+ MOVB;
+ case 2:
+ MOVB;
+ case 1:
+ MOVB;
+ } while (--loop);
+ }
+ }
#else
- dst -= m;
- src -= m;
- memmove(dst, src, m);
+ dst -= m;
+ src -= m;
+ memmove(dst, src, m);
#endif
-/*
- * adjust offset index up
- */
- while (i < n - 1) {
- ino[i] = ino[i + 2] + zoo;
- i++;
- }
+ /*
+ * adjust offset index up
+ */
+ while (i < n - 1) {
+ ino[i] = ino[i + 2] + zoo;
+ i++;
}
- ino[0] -= 2;
- return 1;
+ }
+ ino[0] -= 2;
+ return 1;
}
/*
@@ -269,62 +272,58 @@ sdbm_datum key;
* return offset index in the range 0 < i < n.
* return 0 if not found.
*/
-static int
-seepair(pag, n, key, siz)
-char *pag;
-register int n;
-register char *key;
-register int siz;
+static int seepair(pag, n, key, siz)
+ char *pag;
+ register int n;
+ register char *key;
+ register int siz;
{
- register int i;
- register int off = PBLKSIZ;
- register short *ino = (short *) pag;
-
- for (i = 1; i < n; i += 2) {
- if (siz == off - ino[i] &&
- memcmp(key, pag + ino[i], siz) == 0)
- return i;
- off = ino[i + 1];
- }
- return 0;
+ register int i;
+ register int off = PBLKSIZ;
+ register short *ino = (short *) pag;
+
+ for (i = 1; i < n; i += 2) {
+ if (siz == off - ino[i] && memcmp(key, pag + ino[i], siz) == 0)
+ return i;
+ off = ino[i + 1];
+ }
+ return 0;
}
-void
-splpage(pag, new, sbit)
-char *pag;
-char *new;
-long sbit;
+void splpage(pag, new, sbit)
+ char *pag;
+ char *new;
+ long sbit;
{
- sdbm_datum key;
- sdbm_datum val;
+ sdbm_datum key;
+ sdbm_datum val;
- register int n;
- register int off = PBLKSIZ;
- char cur[PBLKSIZ];
- register short *ino = (short *) cur;
-
- (void) memcpy(cur, pag, PBLKSIZ);
- (void) memset(pag, 0, PBLKSIZ);
- (void) memset(new, 0, PBLKSIZ);
+ register int n;
+ register int off = PBLKSIZ;
+ char cur[PBLKSIZ];
+ register short *ino = (short *) cur;
+
+ (void) memcpy(cur, pag, PBLKSIZ);
+ (void) memset(pag, 0, PBLKSIZ);
+ (void) memset(new, 0, PBLKSIZ);
+
+ n = ino[0];
+ for (ino++; n > 0; ino += 2) {
+ key.dptr = cur + ino[0];
+ key.dsize = off - ino[0];
+ val.dptr = cur + ino[1];
+ val.dsize = ino[0] - ino[1];
+ /*
+ * select the page pointer (by looking at sbit) and insert
+ */
+ (void) putpair((exhash(key) & sbit) ? new : pag, key, val);
+
+ off = ino[1];
+ n -= 2;
+ }
- n = ino[0];
- for (ino++; n > 0; ino += 2) {
- key.dptr = cur + ino[0];
- key.dsize = off - ino[0];
- val.dptr = cur + ino[1];
- val.dsize = ino[0] - ino[1];
-/*
- * select the page pointer (by looking at sbit) and insert
- */
- (void) putpair((exhash(key) & sbit) ? new : pag, key, val);
-
- off = ino[1];
- n -= 2;
- }
-
- debug(("%d split %d/%d\n", ((short *) cur)[0] / 2,
- ((short *) new)[0] / 2,
- ((short *) pag)[0] / 2));
+ debug(("%d split %d/%d\n", ((short *) cur)[0] / 2,
+ ((short *) new)[0] / 2, ((short *) pag)[0] / 2));
}
/*
@@ -333,26 +332,24 @@ long sbit;
* reasonable, and all offsets in the index should be in order.
* this could be made more rigorous.
*/
-int
-chkpage(pag)
-char *pag;
+int chkpage(pag)
+ char *pag;
{
- register int n;
- register int off;
- register short *ino = (short *) pag;
+ register int n;
+ register int off;
+ register short *ino = (short *) pag;
- if ((n = ino[0]) < 0 || n > PBLKSIZ / sizeof(short))
- return 0;
+ if ((n = ino[0]) < 0 || n > PBLKSIZ / sizeof(short))
+ return 0;
- if (n > 0) {
- off = PBLKSIZ;
- for (ino++; n > 0; ino += 2) {
- if (ino[0] > off || ino[1] > off ||
- ino[1] > ino[0])
- return 0;
- off = ino[1];
- n -= 2;
- }
+ if (n > 0) {
+ off = PBLKSIZ;
+ for (ino++; n > 0; ino += 2) {
+ if (ino[0] > off || ino[1] > off || ino[1] > ino[0])
+ return 0;
+ off = ino[1];
+ n -= 2;
}
- return 1;
+ }
+ return 1;
}
Index: sdbm_pair.h
===================================================================
RCS file: /home/joe/lib/cvsroot/apache2/src/lib/sdbm/sdbm_pair.h,v
retrieving revision 1.2
diff -u -p -r1.2 sdbm_pair.h
--- sdbm_pair.h 2000/07/13 10:11:23 1.2
+++ sdbm_pair.h 2000/08/10 11:29:00
@@ -66,10 +66,10 @@
#define splpage sdbm__splpage
int fitpair(char *, int);
-void putpair(char *, sdbm_datum, sdbm_datum);
+void putpair(char *, sdbm_datum, sdbm_datum);
sdbm_datum getpair(char *, sdbm_datum);
-int delpair(char *, sdbm_datum);
-int chkpage (char *);
+int delpair(char *, sdbm_datum);
+int chkpage(char *);
sdbm_datum getnkey(char *, int);
void splpage(char *, char *, long);
#ifdef SEEDUPS
@@ -77,4 +77,3 @@ int duppair(char *, sdbm_datum);
#endif
#endif /* SDBM_PAIR_H */
-
Index: sdbm_private.h
===================================================================
RCS file: /home/joe/lib/cvsroot/apache2/src/lib/sdbm/sdbm_private.h,v
retrieving revision 1.2
diff -u -p -r1.2 sdbm_private.h
--- sdbm_private.h 2000/08/02 05:26:46 1.2
+++ sdbm_private.h 2000/08/10 11:29:00
@@ -61,35 +61,35 @@
#ifndef SDBM_PRIVATE_H
#define SDBM_PRIVATE_H
-#include "apr_errno.h" /* for apr_status_t */
+#include "apr_errno.h" /* for apr_status_t */
/* increase the block/page size and what can be inserted */
#if 1
#define DBLKSIZ 16384
#define PBLKSIZ 8192
-#define PAIRMAX 8008 /* arbitrary on PBLKSIZ-N */
+#define PAIRMAX 8008 /* arbitrary on PBLKSIZ-N */
#else
#define DBLKSIZ 4096
#define PBLKSIZ 1024
-#define PAIRMAX 1008 /* arbitrary on PBLKSIZ-N */
+#define PAIRMAX 1008 /* arbitrary on PBLKSIZ-N */
#endif
-#define SPLTMAX 10 /* maximum allowed splits */
+#define SPLTMAX 10 /* maximum allowed splits */
/* for a single insertion */
struct SDBM {
- apr_file_t *dirf; /* directory file descriptor */
- apr_file_t *pagf; /* page file descriptor */
- apr_int32_t flags; /* status/error flags, see below */
- long maxbno; /* size of dirfile in bits */
- long curbit; /* current bit number */
- long hmask; /* current hash mask */
- long blkptr; /* current block for nextkey */
- int keyptr; /* current key for nextkey */
- long blkno; /* current page to read/write */
- long pagbno; /* current page in pagbuf */
- char pagbuf[PBLKSIZ]; /* page file block buffer */
- long dirbno; /* current block in dirbuf */
- char dirbuf[DBLKSIZ]; /* directory file block buffer */
+ apr_file_t *dirf; /* directory file descriptor */
+ apr_file_t *pagf; /* page file descriptor */
+ apr_int32_t flags; /* status/error flags, see below */
+ long maxbno; /* size of dirfile in bits */
+ long curbit; /* current bit number */
+ long hmask; /* current hash mask */
+ long blkptr; /* current block for nextkey */
+ int keyptr; /* current key for nextkey */
+ long blkno; /* current page to read/write */
+ long pagbno; /* current page in pagbuf */
+ char pagbuf[PBLKSIZ]; /* page file block buffer */
+ long dirbno; /* current block in dirbuf */
+ char dirbuf[DBLKSIZ]; /* directory file block buffer */
};
apr_status_t sdbm_lock(SDBM *db);
Re: [PATCH] sdbm code formatting cleanup
Posted by Jeff Trawick <tr...@bellsouth.net>.
Joe Orton <jo...@orton.demon.co.uk> writes:
> This is from running sdbm/*.[ch] through indent. No functional changes.
>
> Index: .indent.pro
> ===================================================================
> RCS file: .indent.pro
> diff -N .indent.pro
> --- /dev/null Mon Jul 18 00:46:18 1994
> +++ .indent.pro Thu Aug 10 12:28:56 2000
> @@ -0,0 +1,4 @@
> +-i4 -npsl -di0 -br -nce -d0 -cli0 -npcs -fc1 -brs
> +-Tapr_pool_t
> +-Tapr_file_t
> +-TSDBM
Silly question: Is there a way to get indent to use spaces instead of
tabs?
--
Jeff Trawick | trawick@ibm.net | PGP public key at web site:
http://www.geocities.com/SiliconValley/Park/9289/
Born in Roswell... married an alien...