helly Thu Dec 18 15:14:16 2003 EDT
Modified files:
/php-src/ext/dba dba.c dba_flatfile.c php_dba.h
/php-src/ext/dba/libinifile inifile.c
Log:
Centralize ability to drop APPEND flag. This probably fixes some ini file
issues.
Index: php-src/ext/dba/dba.c
diff -u php-src/ext/dba/dba.c:1.106 php-src/ext/dba/dba.c:1.107
--- php-src/ext/dba/dba.c:1.106 Sun Dec 14 17:08:18 2003
+++ php-src/ext/dba/dba.c Thu Dec 18 15:14:15 2003
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba.c,v 1.106 2003/12/14 22:08:18 helly Exp $ */
+/* $Id: dba.c,v 1.107 2003/12/18 20:14:15 helly Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -248,10 +248,10 @@
DBA_HND(db4, DBA_LOCK_ALL) /* No lock in lib */
#endif
#if DBA_INIFILE
- DBA_HND(inifile, DBA_STREAM_OPEN|DBA_LOCK_ALL) /* No lock in lib */
+ DBA_HND(inifile, DBA_STREAM_OPEN|DBA_LOCK_ALL|DBA_CAST_AS_FD) /* No lock in
lib */
#endif
#if DBA_FLATFILE
- DBA_HND(flatfile, DBA_STREAM_OPEN|DBA_LOCK_ALL) /* No lock in lib */
+ DBA_HND(flatfile, DBA_STREAM_OPEN|DBA_LOCK_ALL|DBA_NO_APPEND) /* No lock in
lib */
#endif
{ NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }
};
@@ -802,6 +802,23 @@
FREENOW;
RETURN_FALSE;
}
+ if (hptr->flags & (DBA_NO_APPEND|DBA_CAST_AS_FD)) {
+ /* Needed becasue some systems do not allow to write to the
original
+ * file contents with O_APPEND being set.
+ */
+ if (SUCCESS != php_stream_cast(info->fp, PHP_STREAM_AS_FD,
(void*)&info->fd, 1)) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not
cast stream");
+ dba_close(info TSRMLS_CC);
+ FREENOW;
+ RETURN_FALSE;
+#ifdef F_SETFL
+ } else if (modenr == DBA_CREAT) {
+ int flags = fcntl(info->fd, F_SETFL);
+ fcntl(info->fd, F_SETFL, flags & ~O_APPEND);
+#endif
+ }
+
+ }
}
if (error || hptr->open(info, &error TSRMLS_CC) != SUCCESS) {
Index: php-src/ext/dba/dba_flatfile.c
diff -u php-src/ext/dba/dba_flatfile.c:1.16 php-src/ext/dba/dba_flatfile.c:1.17
--- php-src/ext/dba/dba_flatfile.c:1.16 Wed Dec 17 03:50:50 2003
+++ php-src/ext/dba/dba_flatfile.c Thu Dec 18 15:14:15 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dba_flatfile.c,v 1.16 2003/12/17 08:50:50 helly Exp $ */
+/* $Id: dba_flatfile.c,v 1.17 2003/12/18 20:14:15 helly Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -41,25 +41,6 @@
DBA_OPEN_FUNC(flatfile)
{
- int fd;
-#ifdef F_SETFL
- int flags;
-#endif
-
- if (info->mode != DBA_READER) {
- if (SUCCESS != php_stream_cast(info->fp, PHP_STREAM_AS_FD, (void*)&fd,
1)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not cast
stream");
- return FAILURE;
- }
-#ifdef F_SETFL
- /* Needed becasue some systems do not allow to write to the original
- * file contents with O_APPEND being set.
- */
- flags = fcntl(fd, F_SETFL);
- fcntl(fd, F_SETFL, flags & ~O_APPEND);
-#endif
- }
-
info->dbf = pemalloc(sizeof(flatfile), info->flags&DBA_PERSISTENT);
memset(info->dbf, 0, sizeof(flatfile));
Index: php-src/ext/dba/php_dba.h
diff -u php-src/ext/dba/php_dba.h:1.26 php-src/ext/dba/php_dba.h:1.27
--- php-src/ext/dba/php_dba.h:1.26 Wed Nov 12 16:43:03 2003
+++ php-src/ext/dba/php_dba.h Thu Dec 18 15:14:15 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: php_dba.h,v 1.26 2003/11/12 21:43:03 helly Exp $ */
+/* $Id: php_dba.h,v 1.27 2003/12/18 20:14:15 helly Exp $ */
#ifndef PHP_DBA_H
#define PHP_DBA_H
@@ -43,6 +43,7 @@
char *path;
dba_mode_t mode;
php_stream *fp; /* this is the database stream for builtin handlers */
+ int fd;
/* arg[cv] are only available when the dba_open handler is called! */
int argc;
zval ***argv;
@@ -64,6 +65,9 @@
#define DBA_STREAM_OPEN (0x0010)
#define DBA_PERSISTENT (0x0020)
+#define DBA_CAST_AS_FD (0x0050)
+#define DBA_NO_APPEND (0x00D0)
+
extern zend_module_entry dba_module_entry;
#define dba_module_ptr &dba_module_entry
Index: php-src/ext/dba/libinifile/inifile.c
diff -u php-src/ext/dba/libinifile/inifile.c:1.11
php-src/ext/dba/libinifile/inifile.c:1.12
--- php-src/ext/dba/libinifile/inifile.c:1.11 Wed Dec 17 03:50:50 2003
+++ php-src/ext/dba/libinifile/inifile.c Thu Dec 18 15:14:15 2003
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: inifile.c,v 1.11 2003/12/17 08:50:50 helly Exp $ */
+/* $Id: inifile.c,v 1.12 2003/12/18 20:14:15 helly Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -43,7 +43,7 @@
/* {{{ inifile_version */
char *inifile_version()
{
- return "1.0, $Revision: 1.11 $";
+ return "1.0, $Revision: 1.12 $";
}
/* }}} */
@@ -83,18 +83,14 @@
inifile * inifile_alloc(php_stream *fp, int readonly, int persistent TSRMLS_DC)
{
inifile *dba;
- int fd;
if (!readonly) {
if (!php_stream_truncate_supported(fp)) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't truncate
this stream");
return NULL;
}
- if (SUCCESS != php_stream_cast(fp, PHP_STREAM_AS_FD, (void*)&fd, 1)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not cast
stream");
- return NULL;
- }
}
+
dba = pemalloc(sizeof(inifile), persistent);
memset(dba, 0, sizeof(inifile));
dba->fp = fp;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php