CVS update: php3/functions

From: Date: Sun, 09 May 1999 18:08:18 +0000
Subject: CVS update: php3/functions
Groups: php.dev 
Request: Send a blank email to php-dev+get-5446@lists.php.net to get a copy of this message
Date: Sunday May 9, 1999 @ 14:08 Author: sas Update of /repository/php3/functions In directory php:/tmp/cvs-serv4121/functions Modified Files: dba.c dba_db2.c dba_dbm.c dba_gdbm.c dba_ndbm.c php3_dba.h Log Message: - better dbm compatibility - add dba truncate mode Index: php3/functions/dba.c diff -u php3/functions/dba.c:1.11 php3/functions/dba.c:1.12 --- php3/functions/dba.c:1.11 Sun May 9 13:35:46 1999 +++ php3/functions/dba.c Sun May 9 14:08:18 1999 @@ -27,7 +27,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dba.c,v 1.11 1999/05/09 17:35:46 sas Exp $ */ +/* $Id: dba.c,v 1.12 1999/05/09 18:08:18 sas Exp $ */ #include "php.h" @@ -190,7 +190,7 @@ { dba_handler *hptr; - PUTS("V1 ($Id: dba.c,v 1.11 1999/05/09 17:35:46 sas Exp $)"); + PUTS("V1 ($Id: dba.c,v 1.12 1999/05/09 18:08:18 sas Exp $)"); for(hptr = handler; hptr->name; hptr++) { PUTS(" "); PUTS(hptr->name); @@ -280,6 +280,9 @@ break; case 'r': modenr = DBA_READER; + break; + case 'n': + modenr = DBA_TRUNC; break; default: php3_error(E_WARNING,"illegal DBA mode: %s",args[1]->value.str.val); Index: php3/functions/dba_db2.c diff -u php3/functions/dba_db2.c:1.2 php3/functions/dba_db2.c:1.3 --- php3/functions/dba_db2.c:1.2 Sun May 9 13:35:46 1999 +++ php3/functions/dba_db2.c Sun May 9 14:08:18 1999 @@ -27,7 +27,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dba_db2.c,v 1.2 1999/05/09 17:35:46 sas Exp $ */ +/* $Id: dba_db2.c,v 1.3 1999/05/09 18:08:18 sas Exp $ */ #include "php.h" @@ -62,7 +62,10 @@ int gmode = 0; gmode = info->mode == DBA_READER ? DB_RDONLY : - info->mode == DBA_WRITER ? DB_CREATE : 0; + info->mode == DBA_WRITER ? DB_CREATE : + info->mode == DBA_TRUNC ? DB_TRUNCATE : -1; + if(gmode == -1) + return FAILURE; if(!db_open(info->path, DB_BTREE, gmode, 0644, NULL, NULL, &dbp)) { info->dbf = malloc(sizeof(dba_db2_data)); Index: php3/functions/dba_dbm.c diff -u php3/functions/dba_dbm.c:1.8 php3/functions/dba_dbm.c:1.9 --- php3/functions/dba_dbm.c:1.8 Sun May 9 12:54:35 1999 +++ php3/functions/dba_dbm.c Sun May 9 14:08:18 1999 @@ -27,7 +27,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dba_dbm.c,v 1.8 1999/05/09 16:54:35 sas Exp $ */ +/* $Id: dba_dbm.c,v 1.9 1999/05/09 18:08:18 sas Exp $ */ #include "php.h" @@ -41,17 +41,39 @@ #include <db.h> #endif +#include <unistd.h> + #define DBM_GKEY datum gkey; gkey.dptr = (char *) key; gkey.dsize = keylen +#ifndef PATH_MAX +#define PATH_MAX 255 +#endif + +#define TRUNC_IT(extension) \ + snprintf(buf, PATH_MAX, "%s" extension, info->path); \ + buf[PATH_MAX] = '\0'; \ + truncate(buf, 0) DBA_OPEN_FUNC(dbm) { + if(info->mode == DBA_TRUNC) { + char buf[PATH_MAX + 1]; + +#if HAVE_TRUNCATE + /* dbm/ndbm original */ + TRUNC_IT(".pag"); + TRUNC_IT(".dir"); + /* db2 compatibility */ + TRUNC_IT(".db"); +#endif + } return (dbminit((char *) info->path) ? FAILURE : SUCCESS); } DBA_CLOSE_FUNC(dbm) { /* dbm sucks :) */ + dbmclose(); } DBA_FETCH_FUNC(dbm) Index: php3/functions/dba_gdbm.c diff -u php3/functions/dba_gdbm.c:1.7 php3/functions/dba_gdbm.c:1.8 --- php3/functions/dba_gdbm.c:1.7 Sun May 9 12:54:35 1999 +++ php3/functions/dba_gdbm.c Sun May 9 14:08:18 1999 @@ -27,7 +27,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dba_gdbm.c,v 1.7 1999/05/09 16:54:35 sas Exp $ */ +/* $Id: dba_gdbm.c,v 1.8 1999/05/09 18:08:18 sas Exp $ */ #include "php.h" @@ -55,6 +55,9 @@ break; case DBA_WRITER: gmode = GDBM_WRCREAT; + break; + case DBA_TRUNC: + gmode = GDBM_NEWDB; break; default: /* should not come here */ Index: php3/functions/dba_ndbm.c diff -u php3/functions/dba_ndbm.c:1.6 php3/functions/dba_ndbm.c:1.7 --- php3/functions/dba_ndbm.c:1.6 Sun May 9 12:54:35 1999 +++ php3/functions/dba_ndbm.c Sun May 9 14:08:18 1999 @@ -27,7 +27,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: dba_ndbm.c,v 1.6 1999/05/09 16:54:35 sas Exp $ */ +/* $Id: dba_ndbm.c,v 1.7 1999/05/09 18:08:18 sas Exp $ */ #include "php.h" @@ -58,9 +58,12 @@ case DBA_WRITER: gmode = O_RDWR | O_CREAT; break; + case DBA_TRUNC: + gmode = O_RDWR | O_CREAT | O_TRUNC; + break; default: /* should not come here */ - break; + return FAILURE; } dbf = dbm_open(info->path, gmode, 0644); Index: php3/functions/php3_dba.h diff -u php3/functions/php3_dba.h:1.8 php3/functions/php3_dba.h:1.9 --- php3/functions/php3_dba.h:1.8 Sun May 9 12:54:35 1999 +++ php3/functions/php3_dba.h Sun May 9 14:08:18 1999 @@ -27,7 +27,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php3_dba.h,v 1.8 1999/05/09 16:54:35 sas Exp $ */ +/* $Id: php3_dba.h,v 1.9 1999/05/09 18:08:18 sas Exp $ */ #ifndef _DBA_H #define _DBA_H @@ -38,7 +38,8 @@ typedef enum { DBA_READER = 1, - DBA_WRITER + DBA_WRITER, + DBA_TRUNC } dba_mode_t; typedef struct dba_info { -- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net For help: php-dev-help@lists.php.net

« previous php.dev (#5446) next »