cvs: /php4/ext/com COM.c /php4/ext/filepro filepro.c /php4/ext/ftp ftp.c /php4/ext/hyperwave hw.c /php4/sapi/isapi php4isapi.c /php4/win32 registry.c
| From: | Sascha Schumann | Date: | Fri, 26 Nov 1999 16:51:58 +0000 |
| Subject: | cvs: /php4/ext/com COM.c /php4/ext/filepro filepro.c /php4/ext/ftp ftp.c /php4/ext/hyperwave hw.c /php4/sapi/isapi php4isapi.c /php4/win32 registry.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-6935@lists.php.net to get a copy of this message | ||
sas Fri Nov 26 11:51:58 1999 EDT
Modified files:
/php4/ext/com COM.c
/php4/ext/filepro filepro.c
/php4/ext/ftp ftp.c
/php4/ext/hyperwave hw.c
/php4/sapi/isapi php4isapi.c
/php4/win32 registry.c
Log:
Convert more source files to use thread-safe functions
Index: php4/ext/com/COM.c
diff -u php4/ext/com/COM.c:1.14 php4/ext/com/COM.c:1.15
--- php4/ext/com/COM.c:1.14 Sat Nov 6 05:01:53 1999
+++ php4/ext/com/COM.c Fri Nov 26 11:51:52 1999
@@ -150,6 +150,7 @@
{
FILE *typelib_file;
char *typelib_name_buffer;
+ char *strtok_buf = NULL;
#if SUPPORT_INTERACTIVE
int interactive;
ELS_FETCH();
@@ -179,9 +180,9 @@
if (typelib_name_buffer[0]==';') {
continue;
}
- typelib_name = strtok(typelib_name_buffer, "\r\n"); /* get rid of newlines */
- typelib_name = strtok(typelib_name, "#");
- modifier = strtok(NULL, "#");
+ typelib_name = strtok_r(typelib_name_buffer, "\r\n", &strtok_buf); /* get rid of
newlines */
+ typelib_name = strtok_r(typelib_name, "#", &strtok_buf);
+ modifier = strtok_r(NULL, "#", &strtok_buf);
if (modifier) {
if (!strcmp(modifier, "cis") || !strcmp(modifier, "case_insensitive")) {
mode &= ~CONST_CS;
Index: php4/ext/filepro/filepro.c
diff -u php4/ext/filepro/filepro.c:1.6 php4/ext/filepro/filepro.c:1.7
--- php4/ext/filepro/filepro.c:1.6 Mon Aug 2 15:16:41 1999
+++ php4/ext/filepro/filepro.c Fri Nov 26 11:51:53 1999
@@ -182,6 +182,7 @@
FILE *fp;
char workbuf[256]; /* FIX - should really be the max filename length */
char readbuf[256];
+ char *strtok_buf = NULL;
int i;
FP_FIELD *new_field, *tmp;
FP_TLS_VARS;
@@ -221,13 +222,13 @@
}
/* Get the field count, assume the file is readable! */
- if (strcmp(strtok(readbuf, ":"), "map")) {
+ if (strcmp(strtok_r(readbuf, ":", &strtok_buf), "map")) {
php_error(E_WARNING, "filePro: map file corrupt or encrypted");
RETURN_FALSE;
}
- FP_GLOBAL(fp_keysize) = atoi(strtok(NULL, ":"));
- strtok(NULL, ":");
- FP_GLOBAL(fp_fcount) = atoi(strtok(NULL, ":"));
+ FP_GLOBAL(fp_keysize) = atoi(strtok_r(NULL, ":", &strtok_buf));
+ strtok_r(NULL, ":", &strtok_buf);
+ FP_GLOBAL(fp_fcount) = atoi(strtok_r(NULL, ":", &strtok_buf));
/* Read in the fields themselves */
for (i = 0; i < FP_GLOBAL(fp_fcount); i++) {
@@ -239,9 +240,9 @@
}
new_field = emalloc(sizeof(FP_FIELD));
new_field->next = NULL;
- new_field->name = estrdup(strtok(readbuf, ":"));
- new_field->width = atoi(strtok(NULL, ":"));
- new_field->format = estrdup(strtok(NULL, ":"));
+ new_field->name = estrdup(strtok_r(readbuf, ":", &strtok_buf));
+ new_field->width = atoi(strtok_r(NULL, ":", &strtok_buf));
+ new_field->format = estrdup(strtok_r(NULL, ":", &strtok_buf));
/* Store in forward-order to save time later */
if (!FP_GLOBAL(fp_fieldlist)) {
Index: php4/ext/ftp/ftp.c
diff -u php4/ext/ftp/ftp.c:1.11 php4/ext/ftp/ftp.c:1.12
--- php4/ext/ftp/ftp.c:1.11 Fri Nov 19 13:33:21 1999
+++ php4/ext/ftp/ftp.c Fri Nov 26 11:51:54 1999
@@ -28,7 +28,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: ftp.c,v 1.11 1999/11/19 18:33:21 thies Exp $ */
+/* $Id: ftp.c,v 1.12 1999/11/26 16:51:54 sas Exp $ */
#include "php.h"
@@ -609,7 +609,7 @@
ftp_mdtm(ftpbuf_t *ftp, const char *path)
{
time_t stamp;
- struct tm *gmt;
+ struct tm *gmt, tmbuf;
struct tm tm;
char *ptr;
int n;
@@ -635,7 +635,7 @@
/* figure out the GMT offset */
stamp = time(NULL);
- gmt = gmtime(&stamp);
+ gmt = gmtime_r(&stamp, &tmbuf);
gmt->tm_isdst = -1;
/* apply the GMT offset */
Index: php4/ext/hyperwave/hw.c
diff -u php4/ext/hyperwave/hw.c:1.24 php4/ext/hyperwave/hw.c:1.25
--- php4/ext/hyperwave/hw.c:1.24 Thu Oct 21 11:15:23 1999
+++ php4/ext/hyperwave/hw.c Fri Nov 26 11:51:54 1999
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: hw.c,v 1.24 1999/10/21 15:15:23 steinm Exp $ */
+/* $Id: hw.c,v 1.25 1999/11/26 16:51:54 sas Exp $ */
#if COMPILE_DL
#include "dl/phpdl.h"
#endif
@@ -285,6 +285,7 @@
char *attrname, *str, *temp, language[3];
int i, count;
zval *spec_arr;
+ char *strtok_buf = NULL;
/* Create an array with an entry containing specs for each attribute
and fill in the specs for Title, Description, Keyword, Group.
@@ -314,7 +315,7 @@
to the return_value array.
*/
temp = estrdup(objrec);
- attrname = strtok(temp, "\n");
+ attrname = strtok_r(temp, "\n", &strtok_buf);
while(attrname != NULL) {
zval *data, **dataptr;
long spec;
@@ -370,7 +371,7 @@
}
}
- attrname = strtok(NULL, "\n");
+ attrname = strtok_r(NULL, "\n", &strtok_buf);
}
if(NULL == sarr){
// spec_arr->refcount--;
@@ -395,6 +396,7 @@
int hasDescription = 0;
int hasKeyword = 0;
int hasGroup = 0;
+ char *strtok_buf;
MAKE_STD_ZVAL(title_arr);
MAKE_STD_ZVAL(desc_arr);
@@ -410,7 +412,7 @@
/* Fill Array of titles, descriptions and keywords */
temp = estrdup(objrec);
- attrname = strtok(temp, "\n");
+ attrname = strtok_r(temp, "\n", &strtok_buf);
while(attrname != NULL) {
str = attrname;
iTitle = 0;
@@ -465,7 +467,7 @@
if(iGroup)
add_next_index_string(group_arr, str, 1);
}
- attrname = strtok(NULL, "\n");
+ attrname = strtok_r(NULL, "\n", &strtok_buf);
}
efree(temp);
@@ -504,7 +506,7 @@
/* All other attributes. Make a another copy first */
temp = estrdup(objrec);
- attrname = strtok(temp, "\n");
+ attrname = strtok_r(temp, "\n", &strtok_buf);
while(attrname != NULL) {
str = attrname;
/* We don't want to insert titles, descr., keywords a second time */
@@ -518,7 +520,7 @@
str++;
add_assoc_string(*return_value, attrname, str, 1);
}
- attrname = strtok(NULL, "\n");
+ attrname = strtok_r(NULL, "\n", &strtok_buf);
}
efree(temp);
@@ -1140,6 +1142,7 @@
zval *user_arr;
char *object, *ptr, *temp, *attrname;
int i;
+ char *strtok_buf;
object = php3_hw_command(INTERNAL_FUNCTION_PARAM_PASSTHRU, WHO_COMMAND);
if(object == NULL)
@@ -1167,7 +1170,7 @@
}
temp = estrdup(ptr);
- attrname = strtok(temp, "\n");
+ attrname = strtok_r(temp, "\n", &strtok_buf);
i = 0;
while(attrname != NULL) {
char *name;
@@ -1241,7 +1244,7 @@
/* Add the user array */
zend_hash_index_update(return_value->value.ht, i++, &user_arr, sizeof(pval), NULL);
- attrname = strtok(NULL, "\n");
+ attrname = strtok_r(NULL, "\n", &strtok_buf);
}
efree(temp);
efree(object);
Index: php4/sapi/isapi/php4isapi.c
diff -u php4/sapi/isapi/php4isapi.c:1.3 php4/sapi/isapi/php4isapi.c:1.4
--- php4/sapi/isapi/php4isapi.c:1.3 Sun Nov 14 14:46:31 1999
+++ php4/sapi/isapi/php4isapi.c Fri Nov 26 11:51:56 1999
@@ -390,6 +390,7 @@
char *variable_buf;
DWORD variable_len = ISAPI_SERVER_VAR_BUF_SIZE;
char *variable;
+ char *strtok_buf = NULL;
LPEXTENSION_CONTROL_BLOCK lpECB;
lpECB = (LPEXTENSION_CONTROL_BLOCK) SG(server_context);
@@ -407,7 +408,7 @@
return;
}
}
- variable = strtok(variable_buf, "\r\n");
+ variable = strtok_r(variable_buf, "\r\n", &strtok_buf);
while (variable) {
char *colon = strchr(variable, ':');
@@ -426,7 +427,7 @@
zend_hash_add(&EG(symbol_table), variable, strlen(variable)+1, &entry, sizeof(zval *),
NULL);
*colon = ':';
}
- variable = strtok(NULL, "\r\n");
+ variable = strtok_r(NULL, "\r\n", &strtok_buf);
}
if (variable_buf!=static_variable_buf) {
efree(variable_buf);
Index: php4/win32/registry.c
diff -u php4/win32/registry.c:1.1 php4/win32/registry.c:1.2
--- php4/win32/registry.c:1.1 Sun Apr 18 11:54:18 1999
+++ php4/win32/registry.c Fri Nov 26 11:51:57 1999
@@ -6,8 +6,8 @@
{
char *p, *orig_path;
HKEY MainKey;
+ char *strtok_buf = NULL;
-
if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\PHP\\Per Directory Values", 0, KEY_READ,
&MainKey)!=ERROR_SUCCESS) {
return;
}
@@ -43,7 +43,7 @@
path++; /* step over the first / */
- path = p = strtok(path, "\\/");
+ path = p = strtok_r(path, "\\/", &strtok_buf);
while (p) {
HKEY hKey;
@@ -67,7 +67,7 @@
}
RegCloseKey(hKey);
- p = strtok(NULL, "\\/");
+ p = strtok_r(NULL, "\\/", &strtok_buf);
}
RegCloseKey(MainKey);
efree(orig_path);