cvs: /php4 fopen-wrappers.h rfc1867.c /php4/ext/standard file.c file.h fsock.c
| From: | Thies C. Arntzen | Date: | Tue, 12 Oct 1999 18:50:35 +0000 |
| Subject: | cvs: /php4 fopen-wrappers.h rfc1867.c /php4/ext/standard file.c file.h fsock.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-5520@lists.php.net to get a copy of this message | ||
thies Tue Oct 12 14:50:35 1999 EDT
Modified files:
/php4 fopen-wrappers.h rfc1867.c
/php4/ext/standard file.c file.h fsock.c
Log:
starting to clean-up/new API'ize and resourcify the file-stuff - nothing happened yet - just
renaming things around.
Index: php4/fopen-wrappers.h
diff -u php4/fopen-wrappers.h:1.7 php4/fopen-wrappers.h:1.8
--- php4/fopen-wrappers.h:1.7 Fri Jul 16 09:12:41 1999
+++ php4/fopen-wrappers.h Tue Oct 12 14:50:04 1999
@@ -15,7 +15,7 @@
| Authors: Jim Winstead <jimw@php.net> |
+----------------------------------------------------------------------+
*/
-/* $Id: fopen-wrappers.h,v 1.7 1999/07/16 13:12:41 zeev Exp $ */
+/* $Id: fopen-wrappers.h,v 1.8 1999/10/12 18:50:04 thies Exp $ */
/* Synced with php3 revision 1.25 1999-06-16 [ssb] */
@@ -66,9 +66,7 @@
#define IS_SOCKET 1
#define BAD_URL 2
-#ifndef THREAD_SAFE
-extern int wsa_fp; /* a list for open sockets */
-#endif
+extern int le_socket; /* a list for open sockets */
extern PHPAPI FILE *php3_fopen_wrapper(char *filename, char *mode, int options, int *issock, int
*socketd);
Index: php4/rfc1867.c
diff -u php4/rfc1867.c:1.11 php4/rfc1867.c:1.12
--- php4/rfc1867.c:1.11 Thu Sep 16 19:18:15 1999
+++ php4/rfc1867.c Tue Oct 12 14:50:04 1999
@@ -15,7 +15,7 @@
| Authors: Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
-/* $Id: rfc1867.c,v 1.11 1999/09/16 23:18:15 zeev Exp $ */
+/* $Id: rfc1867.c,v 1.12 1999/10/12 18:50:04 thies Exp $ */
#include <stdio.h>
#include "php.h"
@@ -25,7 +25,7 @@
#include "rfc1867.h"
#ifndef THREAD_SAFE
-int le_uploads;
+extern int le_uploads; /* "borrowed" from file.c */
extern HashTable list;
#endif
Index: php4/ext/standard/file.c
diff -u php4/ext/standard/file.c:1.33 php4/ext/standard/file.c:1.34
--- php4/ext/standard/file.c:1.33 Tue Sep 21 13:50:50 1999
+++ php4/ext/standard/file.c Tue Oct 12 14:50:05 1999
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.c,v 1.33 1999/09/21 17:50:50 rasmus Exp $ */
+/* $Id: file.c,v 1.34 1999/10/12 18:50:05 thies Exp $ */
/* Synced with php3 revision 1.218 1999-06-16 [ssb] */
@@ -83,15 +83,12 @@
#define MAP_FAILED ((void *) -1)
#endif
-static void _php3_closesocket(int *);
+static void _file_socket_dtor(int *);
-#ifndef THREAD_SAFE
+int le_fopen,le_popen, le_socket, le_uploads;
+
static int fgetss_state = 0;
-int le_fp,le_pp;
-int wsa_fp; /*to handle reading and writing to windows sockets*/
static int pclose_ret;
-extern int le_uploads;
-#endif
#ifndef HAVE_TEMPNAM
/*
@@ -186,7 +183,7 @@
#endif
-function_entry php3_file_functions[] = {
+function_entry file_functions[] = {
PHP_FE(pclose, NULL)
PHP_FE(popen, NULL)
PHP_FE(readfile, NULL)
@@ -220,9 +217,9 @@
{NULL, NULL, NULL}
};
-php3_module_entry php3_file_module_entry = {
+zend_module_entry file_module_entry = {
"File functions",
- php3_file_functions,
+ file_functions,
PHP_MINIT(file),
NULL,
NULL,
@@ -235,6 +232,7 @@
static int flock_values[] = { LOCK_SH, LOCK_EX, LOCK_UN };
/* {{{ proto bool flock(int fp, int operation)
+
portable file locking */
PHP_FUNCTION(flock)
{
@@ -253,13 +251,13 @@
convert_to_long(arg2);
fp = php3_list_find(arg1->value.lval, &type);
- if (type == wsa_fp){
+ if (type == le_socket){
issock = 1;
sock = php3_list_find(arg1->value.lval, &type);
fd = *sock;
}
- if ((!fp || (type!=le_fp && type!=le_pp)) && (!fd || type!=wsa_fp)) {
+ if ((!fp || (type!=le_fopen && type!=le_popen)) && (!fd || type!=le_socket)) {
php_error(E_WARNING,"Unable to find file identifier %d",arg1->value.lval);
RETURN_FALSE;
}
@@ -282,6 +280,7 @@
RETURN_TRUE;
}
+
/* }}} */
@@ -474,41 +473,39 @@
/* }}} */
-static void __pclose(FILE *pipe)
+static void _file_popen_dtor(FILE *pipe)
{
pclose_ret = pclose(pipe);
}
-static void _php3_closesocket(int *sock) {
- if (sock) {
- SOCK_FCLOSE(*sock);
+static void _file_socket_dtor(int *sock)
+{
+ SOCK_FCLOSE(*sock);
#if HAVE_SHUTDOWN
- shutdown(*sock, 0);
+ shutdown(*sock, 0);
#endif
- efree(sock);
- }
+ efree(sock);
}
-static void _php3_unlink_uploaded_file(char *file)
+static void _file_upload_dtor(char *file)
{
- if(file) {
- unlink(file);
- }
+ unlink(file);
}
-static void php3i_destructor_fclose(FILE *fp) {
- (void)fclose(fp);
+static void _file_fopen_dtor(FILE *fp)
+{
+ fclose(fp);
}
PHP_MINIT_FUNCTION(file)
{
- le_fp = register_list_destructors(php3i_destructor_fclose, NULL);
- le_pp = register_list_destructors(__pclose, NULL);
- wsa_fp = register_list_destructors(_php3_closesocket, NULL);
- le_uploads = register_list_destructors(_php3_unlink_uploaded_file, NULL);
+ le_fopen = register_list_destructors(_file_fopen_dtor, NULL);
+ le_popen = register_list_destructors(_file_popen_dtor, NULL);
+ le_socket = register_list_destructors(_file_socket_dtor, NULL);
+ le_uploads = register_list_destructors(_file_upload_dtor, NULL);
return SUCCESS;
}
@@ -590,9 +587,9 @@
if (issock) {
sock=emalloc(sizeof(int));
*sock=socketd;
- id = php3_list_insert(sock,wsa_fp);
+ id = php3_list_insert(sock,le_socket);
} else {
- id = php3_list_insert(fp,le_fp);
+ id = php3_list_insert(fp,le_fopen);
}
efree(p);
RETURN_LONG(id);
@@ -614,7 +611,7 @@
convert_to_long(arg1);
id=arg1->value.lval;
fp = php3_list_find(id,&type);
- if (!fp || (type!=le_fp && type!=wsa_fp)) {
+ if (!fp || (type!=le_fopen && type!=le_socket)) {
php_error(E_WARNING,"Unable to find file identifier %d",id);
RETURN_FALSE;
}
@@ -673,7 +670,7 @@
RETURN_FALSE;
}
}
- id = php3_list_insert(fp,le_pp);
+ id = php3_list_insert(fp,le_popen);
efree(p);
RETURN_LONG(id);
}
@@ -695,7 +692,7 @@
id = arg1->value.lval;
fp = php3_list_find(id,&type);
- if (!fp || type!=le_pp) {
+ if (!fp || type!=le_popen) {
php_error(E_WARNING,"Unable to find pipe identifier %d",id);
RETURN_FALSE;
}
@@ -721,12 +718,12 @@
convert_to_long(arg1);
id = arg1->value.lval;
fp = php3_list_find(id,&type);
- if (type==wsa_fp){
+ if (type==le_socket){
issock=1;
sock = php3_list_find(id,&type);
socketd=*sock;
}
- if ((!fp || (type!=le_fp && type!=le_pp)) && (!socketd || type!=wsa_fp)) {
+ if ((!fp || (type!=le_fopen && type!=le_popen)) && (!socketd || type!=le_socket))
{
php_error(E_WARNING,"Unable to find file identifier %d",id);
/* we're at the eof if the file doesn't exist */
RETURN_TRUE;
@@ -787,7 +784,7 @@
block = arg2->value.lval;
sock = php3_list_find(id,&type);
- if (type != wsa_fp) {
+ if (type != le_socket) {
php_error(E_WARNING,"%d is not a socket id",id);
RETURN_FALSE;
}
@@ -815,7 +812,7 @@
convert_to_long(timeout);
sock = php3_list_find(socket->value.lval, &type);
- if (type!=wsa_fp) {
+ if (type!=le_socket) {
php_error(E_WARNING,"%d is not a socket id",socket->value.lval);
RETURN_FALSE;
}
@@ -849,12 +846,12 @@
len = arg2->value.lval;
fp = php3_list_find(id,&type);
- if (type==wsa_fp){
+ if (type==le_socket){
issock=1;
sock = php3_list_find(id,&type);
socketd=*sock;
}
- if ((!fp || (type!=le_fp && type!=le_pp)) && (!socketd || type!=wsa_fp)) {
+ if ((!fp || (type!=le_fopen && type!=le_popen)) && (!socketd || type!=le_socket))
{
php_error(E_WARNING,"Unable to find file identifier %d",id);
RETURN_FALSE;
}
@@ -895,12 +892,12 @@
id = arg1->value.lval;
fp = php3_list_find(id,&type);
- if (type==wsa_fp){
+ if (type==le_socket){
issock=1;
sock = php3_list_find(id,&type);
socketd = *sock;
}
- if ((!fp || (type!=le_fp && type!=le_pp)) && (!socketd || type!=wsa_fp)) {
+ if ((!fp || (type!=le_fopen && type!=le_popen)) && (!socketd || type!=le_socket))
{
php_error(E_WARNING,"Unable to find file identifier %d",id);
RETURN_FALSE;
}
@@ -955,12 +952,12 @@
len = bytes->value.lval;
fp = php3_list_find(id,&type);
- if (type == wsa_fp){
+ if (type == le_socket){
issock = 1;
sock = php3_list_find(id, &type);
socketd=*sock;
}
- if ((!fp || (type!=le_fp && type!=le_pp)) && (!socketd || type!=wsa_fp)) {
+ if ((!fp || (type!=le_fopen && type!=le_popen)) && (!socketd || type!=le_socket))
{
php_error(E_WARNING, "Unable to find file identifier %d", id);
RETURN_FALSE;
}
@@ -1020,12 +1017,12 @@
id = arg1->value.lval;
fp = php3_list_find(id,&type);
- if (type==wsa_fp){
+ if (type==le_socket){
issock=1;
sock = php3_list_find(id,&type);
socketd=*sock;
}
- if ((!fp || (type!=le_fp && type!=le_pp)) && (!socketd || type!=wsa_fp)) {
+ if ((!fp || (type!=le_fopen && type!=le_popen)) && (!socketd || type!=le_socket))
{
php_error(E_WARNING,"Unable to find file identifier %d",id);
RETURN_FALSE;
}
@@ -1076,13 +1073,13 @@
id = arg1->value.lval;
buff = arg2->value.lval;
fp = php3_list_find(id,&type);
- if (type == wsa_fp){
+ if (type == le_socket){
issock = 1;
sock = php3_list_find(id,&type);
socketd = *sock;
}
- if ((!fp || (type != le_fp && type != le_pp)) &&
- (!socketd || type != wsa_fp)) {
+ if ((!fp || (type != le_fopen && type != le_popen)) &&
+ (!socketd || type != le_socket)) {
php_error(E_WARNING,"Unable to find file identifier %d",id);
RETURN_FALSE;
}
@@ -1112,7 +1109,7 @@
convert_to_long(arg1);
id = arg1->value.lval;
fp = php3_list_find(id,&type);
- if (!fp || (type!=le_fp && type!=le_pp)) {
+ if (!fp || (type!=le_fopen && type!=le_popen)) {
php_error(E_WARNING,"Unable to find file identifier %d",id);
RETURN_FALSE;
}
@@ -1137,7 +1134,7 @@
convert_to_long(arg1);
id = arg1->value.lval;
fp = php3_list_find(id,&type);
- if (!fp || (type!=le_fp && type!=le_pp)) {
+ if (!fp || (type!=le_fopen && type!=le_popen)) {
php_error(E_WARNING,"Unable to find file identifier %d",id);
RETURN_FALSE;
}
@@ -1164,7 +1161,7 @@
pos = arg2->value.lval;
id = arg1->value.lval;
fp = php3_list_find(id,&type);
- if (!fp || (type!=le_fp && type!=le_pp)) {
+ if (!fp || (type!=le_fopen && type!=le_popen)) {
php_error(E_WARNING,"Unable to find file identifier %d",id);
RETURN_FALSE;
}
@@ -1376,12 +1373,12 @@
convert_to_long(arg1);
id = arg1->value.lval;
fp = php3_list_find(id,&type);
- if (type==wsa_fp){
+ if (type==le_socket){
issock=1;
sock = php3_list_find(id,&type);
socketd=*sock;
}
- if ((!fp || (type!=le_fp && type!=le_pp)) && (!socketd || type!=wsa_fp)) {
+ if ((!fp || (type!=le_fopen && type!=le_popen)) && (!socketd || type!=le_socket))
{
php_error(E_WARNING,"Unable to find file identifier %d",id);
RETURN_FALSE;
}
@@ -1505,12 +1502,12 @@
len = arg2->value.lval;
fp = php3_list_find(id,&type);
- if (type==wsa_fp){
+ if (type==le_socket){
issock=1;
sock = php3_list_find(id,&type);
socketd=*sock;
}
- if ((!fp || (type!=le_fp && type!=le_pp)) && (!socketd || type!=wsa_fp)) {
+ if ((!fp || (type!=le_fopen && type!=le_popen)) && (!socketd || type!=le_socket))
{
php_error(E_WARNING,"Unable to find file identifier %d",id);
RETURN_FALSE;
}
@@ -1532,9 +1529,9 @@
/* aparently needed for pdf to be compiled as a module under windows */
-PHPAPI int php3i_get_le_fp(void)
+PHPAPI int php3i_get_le_fopen(void)
{
- return le_fp;
+ return le_fopen;
}
/* {{{ proto array fgetcsv(int fp, int length)
@@ -1586,13 +1583,13 @@
len = bytes->value.lval;
fp = php3_list_find(id, &type);
- if (type == wsa_fp){
+ if (type == le_socket){
issock = 1;
sock = php3_list_find(id,&type);
socketd = *sock;
}
- if ((!fp || (type != le_fp && type != le_pp)) &&
- (!socketd || type != wsa_fp)) {
+ if ((!fp || (type != le_fopen && type != le_popen)) &&
+ (!socketd || type != le_socket)) {
php_error(E_WARNING, "Unable to find file identifier %d", id);
RETURN_FALSE;
}
@@ -1680,5 +1677,6 @@
/*
* Local variables:
* tab-width: 4
+ * c-basic-offset: 4
* End:
*/
Index: php4/ext/standard/file.h
diff -u php4/ext/standard/file.h:1.9 php4/ext/standard/file.h:1.10
--- php4/ext/standard/file.h:1.9 Mon Jul 26 16:09:08 1999
+++ php4/ext/standard/file.h Tue Oct 12 14:50:05 1999
@@ -27,15 +27,15 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.h,v 1.9 1999/07/26 20:09:08 andrey Exp $ */
+/* $Id: file.h,v 1.10 1999/10/12 18:50:05 thies Exp $ */
/* Synced with php3 revision 1.30 1999-06-16 [ssb] */
#ifndef _FILE_H
#define _FILE_H
-extern php3_module_entry php3_file_module_entry;
-#define php3_file_module_ptr &php3_file_module_entry
+extern zend_module_entry file_module_entry;
+#define file_module_ptr &file_module_entry
extern PHP_MINIT_FUNCTION(file);
@@ -70,5 +70,5 @@
PHPAPI int _php3_set_sock_blocking(int socketd, int block);
-#define phpext_file_ptr php3_file_module_ptr
+#define phpext_file_ptr file_module_ptr
#endif /* _FILE_H */
Index: php4/ext/standard/fsock.c
diff -u php4/ext/standard/fsock.c:1.23 php4/ext/standard/fsock.c:1.24
--- php4/ext/standard/fsock.c:1.23 Tue Sep 7 14:46:25 1999
+++ php4/ext/standard/fsock.c Tue Oct 12 14:50:05 1999
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: fsock.c,v 1.23 1999/09/07 18:46:25 ssb Exp $ */
+/* $Id: fsock.c,v 1.24 1999/10/12 18:50:05 thies Exp $ */
/* Synced with php3 revision 1.121 1999-06-18 [ssb] */
/* Synced with php3 revision 1.133 1999-07-21 [sas] */
@@ -284,7 +284,7 @@
(void *) &sockp) == SUCCESS) {
FREE_SOCK;
*sock = *sockp;
- RETURN_LONG(php3_list_insert(sock, wsa_fp));
+ RETURN_LONG(php3_list_insert(sock, le_socket));
}
if (portno) {
@@ -361,7 +361,7 @@
key, strlen(key) + 1, NULL);
}
if(key) efree(key);
- id = php3_list_insert(sock,wsa_fp);
+ id = php3_list_insert(sock,le_socket);
RETURN_LONG(id);
}
/* }}} */