This commit is contained in:
Evan Klinger 1999-12-20 02:09:58 +00:00
parent 665078d0c4
commit f5d5637f72
6 changed files with 128 additions and 124 deletions

View File

@ -63,7 +63,7 @@ static int browser_reg_compare(pval *browser)
PHP_FUNCTION(get_browser)
{
pval *agent_name,*agent,tmp;
pval **agent_name,**agent,tmp;
ELS_FETCH();
if (!INI_STR("browscap")) {
@ -73,12 +73,12 @@ PHP_FUNCTION(get_browser)
switch(ARG_COUNT(ht)) {
case 0:
if (zend_hash_find(&EG(symbol_table), "HTTP_USER_AGENT", sizeof("HTTP_USER_AGENT"), (void **) &agent_name)==FAILURE) {
agent_name = &tmp;
var_reset(agent_name);
*agent_name = &tmp;
var_reset(*agent_name);
}
break;
case 1:
if (getParameters(ht, 1, &agent_name)==FAILURE) {
if (zend_get_parameters_ex(1,&agent_name)==FAILURE) {
RETURN_FALSE;
}
break;
@ -87,30 +87,30 @@ PHP_FUNCTION(get_browser)
break;
}
convert_to_string(agent_name);
convert_to_string_ex(agent_name);
if (zend_hash_find(&browser_hash, agent_name->value.str.val, agent_name->value.str.len+1, (void **) &agent)==FAILURE) {
lookup_browser_name = agent_name->value.str.val;
if (zend_hash_find(&browser_hash, (*agent_name)->value.str.val,(*agent_name)->value.str.len+1, (void **) &agent)==FAILURE) {
lookup_browser_name = (*agent_name)->value.str.val;
found_browser_entry = NULL;
zend_hash_apply(&browser_hash,(int (*)(void *)) browser_reg_compare);
if (found_browser_entry) {
agent = found_browser_entry;
*agent = found_browser_entry;
} else if (zend_hash_find(&browser_hash, "Default Browser", sizeof("Default Browser"), (void **) &agent)==FAILURE) {
RETURN_FALSE;
}
}
*return_value = *agent;
*return_value = **agent;
return_value->type = IS_OBJECT;
pval_copy_constructor(return_value);
return_value->value.ht->pDestructor = PVAL_DESTRUCTOR;
while (zend_hash_find(agent->value.ht, "parent", sizeof("parent"), (void **) &agent_name)==SUCCESS) {
if (zend_hash_find(&browser_hash, agent_name->value.str.val, agent_name->value.str.len+1, (void **) &agent)==FAILURE) {
while (zend_hash_find((*agent)->value.ht, "parent",sizeof("parent"), (void **) &agent_name)==SUCCESS) {
if (zend_hash_find(&browser_hash,(*agent_name)->value.str.val, (*agent_name)->value.str.len+1, (void **)&agent)==FAILURE) {
break;
}
zend_hash_merge(return_value->value.ht, agent->value.ht, PVAL_COPY_CTOR, (void *) &tmp, sizeof(pval), 0);
zend_hash_merge(return_value->value.ht,(*agent)->value.ht, PVAL_COPY_CTOR, (void *) &tmp, sizeof(pval), 0);
}
}

View File

@ -271,20 +271,20 @@ static char * php_convert_cyr_string(unsigned char *str, char from, char to)
Convert from one Cyrillic character set to another */
PHP_FUNCTION(convert_cyr_string)
{
pval *str_arg, *fr_cs, *to_cs;
pval **str_arg, **fr_cs, **to_cs;
unsigned char *str;
if (ARG_COUNT(ht) != 3 || getParameters(ht,3,&str_arg, &fr_cs, &to_cs)==FAILURE)
if (ARG_COUNT(ht) != 3 || zend_get_parameters_ex(3,&str_arg,&fr_cs, &to_cs)==FAILURE)
{
WRONG_PARAM_COUNT;
}
convert_to_string(str_arg);
convert_to_string(fr_cs);
convert_to_string(to_cs);
convert_to_string_ex(str_arg);
convert_to_string_ex(fr_cs);
convert_to_string_ex(to_cs);
str = (unsigned char*) str_arg->value.str.val;
str = (unsigned char*) (*str_arg)->value.str.val;
php_convert_cyr_string(str, fr_cs->value.str.val[0], to_cs->value.str.val[0]);
php_convert_cyr_string(str, (*fr_cs)->value.str.val[0],(*to_cs)->value.str.val[0]);
RETVAL_STRING((char *)str, 1)
}
/* }}} */

View File

@ -127,7 +127,7 @@ PHP_FUNCTION(diskfreespace)
DWORD TotalNumberOfClusters;
#else /* not - WINDOWS */
pval *path;
pval **path;
#if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS)
struct statvfs buf;
#elif defined(HAVE_SYS_STATFS_H) && defined(HAVE_STATFS)
@ -136,13 +136,13 @@ PHP_FUNCTION(diskfreespace)
double bytesfree = 0;
#endif /* WINDOWS */
if (ARG_COUNT(ht)!=1 || getParameters(ht,1,&path)==FAILURE) {
if (ARG_COUNT(ht)!=1 || zend_get_parameters_ex(1,&path)==FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string(path);
convert_to_string_ex(path);
if (php_check_open_basedir(path->value.str.val)) RETURN_FALSE;
if (php_check_open_basedir((*path)->value.str.val)) RETURN_FALSE;
#ifdef WINDOWS
/* GetDiskFreeSpaceEx is only available in NT and Win95 post-OSR2,
@ -187,14 +187,14 @@ PHP_FUNCTION(diskfreespace)
}
#else /* WINDOWS, OS/2 */
#if defined(HAVE_SYS_STATVFS_H) && defined(HAVE_STATVFS)
if (statvfs(path->value.str.val,&buf)) RETURN_FALSE;
if (statvfs((*path)->value.str.val,&buf)) RETURN_FALSE;
if (buf.f_frsize) {
bytesfree = (((double)buf.f_bavail) * ((double)buf.f_frsize));
} else {
bytesfree = (((double)buf.f_bavail) * ((double)buf.f_bsize));
}
#elif defined(HAVE_SYS_STATFS_H) && defined(HAVE_STATFS)
if (statfs(path->value.str.val,&buf)) RETURN_FALSE;
if (statfs((*path)->value.str.val,&buf)) RETURN_FALSE;
bytesfree = (((double)buf.f_bsize) * ((double)buf.f_bavail));
#endif
#endif /* WINDOWS */
@ -205,37 +205,38 @@ PHP_FUNCTION(diskfreespace)
PHP_FUNCTION(chgrp)
{
#ifndef WINDOWS
pval *filename, *group;
pval **filename, **group;
gid_t gid;
struct group *gr=NULL;
int ret;
PLS_FETCH();
if (ARG_COUNT(ht)!=2 || getParameters(ht,2,&filename,&group)==FAILURE) {
if (ARG_COUNT(ht)!=2 || zend_get_parameters_ex(2,&filename,&group)==FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string(filename);
if (group->type == IS_STRING) {
gr = getgrnam(group->value.str.val);
convert_to_string_ex(filename);
if ((*group)->type == IS_STRING) {
gr = getgrnam((*group)->value.str.val);
if (!gr) {
php_error(E_WARNING, "unable to find gid for %s",
group->value.str.val);
(*group)->value.str.val);
RETURN_FALSE;
}
gid = gr->gr_gid;
} else {
convert_to_long(group);
gid = group->value.lval;
convert_to_long_ex(group);
gid = (*group)->value.lval;
}
if (PG(safe_mode) &&(!php_checkuid(filename->value.str.val, 1))) {
if (PG(safe_mode) &&(!php_checkuid((*filename)->value.str.val,1))) {
RETURN_FALSE;
}
/* Check the basedir */
if (php_check_open_basedir(filename->value.str.val)) RETURN_FALSE;
if (php_check_open_basedir((*filename)->value.str.val))
RETURN_FALSE;
ret = chown(filename->value.str.val, -1, gid);
ret = chown((*filename)->value.str.val, -1, gid);
if (ret == -1) {
php_error(E_WARNING, "chgrp failed: %s", strerror(errno));
RETURN_FALSE;
@ -250,37 +251,38 @@ PHP_FUNCTION(chgrp)
PHP_FUNCTION(chown)
{
#ifndef WINDOWS
pval *filename, *user;
pval **filename, **user;
int ret;
uid_t uid;
struct passwd *pw = NULL;
PLS_FETCH();
if (ARG_COUNT(ht)!=2 || getParameters(ht,2,&filename,&user)==FAILURE) {
if (ARG_COUNT(ht)!=2 || zend_get_parameters_ex(2,&filename,&user)==FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string(filename);
if (user->type == IS_STRING) {
pw = getpwnam(user->value.str.val);
convert_to_string_ex(filename);
if ((*user)->type == IS_STRING) {
pw = getpwnam((*user)->value.str.val);
if (!pw) {
php_error(E_WARNING, "unable to find uid for %s",
user->value.str.val);
(*user)->value.str.val);
RETURN_FALSE;
}
uid = pw->pw_uid;
} else {
convert_to_long(user);
uid = user->value.lval;
convert_to_long_ex(user);
uid = (*user)->value.lval;
}
if (PG(safe_mode) &&(!php_checkuid(filename->value.str.val, 1))) {
if (PG(safe_mode) &&(!php_checkuid((*filename)->value.str.val,1))) {
RETURN_FALSE;
}
/* Check the basedir */
if (php_check_open_basedir(filename->value.str.val)) RETURN_FALSE;
if (php_check_open_basedir((*filename)->value.str.val))
RETURN_FALSE;
ret = chown(filename->value.str.val, uid, -1);
ret = chown((*filename)->value.str.val, uid, -1);
if (ret == -1) {
php_error(E_WARNING, "chown failed: %s", strerror(errno));
RETURN_FALSE;
@ -292,24 +294,25 @@ PHP_FUNCTION(chown)
PHP_FUNCTION(chmod)
{
pval *filename, *mode;
pval **filename, **mode;
int ret;
PLS_FETCH();
if (ARG_COUNT(ht)!=2 || getParameters(ht,2,&filename,&mode)==FAILURE) {
if (ARG_COUNT(ht)!=2 || zend_get_parameters_ex(2,&filename,&mode)==FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string(filename);
convert_to_long(mode);
convert_to_string_ex(filename);
convert_to_long_ex(mode);
if (PG(safe_mode) &&(!php_checkuid(filename->value.str.val, 1))) {
if (PG(safe_mode) &&(!php_checkuid((*filename)->value.str.val,1))) {
RETURN_FALSE;
}
/* Check the basedir */
if (php_check_open_basedir(filename->value.str.val)) RETURN_FALSE;
if (php_check_open_basedir((*filename)->value.str.val))
RETURN_FALSE;
ret = chmod(filename->value.str.val, mode->value.lval);
ret = chmod((*filename)->value.str.val, (*mode)->value.lval);
if (ret == -1) {
php_error(E_WARNING, "chmod failed: %s", strerror(errno));
RETURN_FALSE;
@ -321,7 +324,7 @@ PHP_FUNCTION(chmod)
PHP_FUNCTION(touch)
{
#if HAVE_UTIME
pval *filename, *filetime;
pval **filename, **filetime;
int ret;
struct stat sb;
FILE *file;
@ -329,7 +332,7 @@ PHP_FUNCTION(touch)
int ac = ARG_COUNT(ht);
PLS_FETCH();
if (ac == 1 && getParameters(ht,1,&filename) != FAILURE) {
if (ac == 1 && zend_get_parameters_ex(1,&filename) != FAILURE) {
#ifndef HAVE_UTIME_NULL
newtime = (struct utimbuf *)emalloc(sizeof(struct utimbuf));
if (!newtime) {
@ -339,41 +342,42 @@ PHP_FUNCTION(touch)
newtime->actime = time(NULL);
newtime->modtime = newtime->actime;
#endif
} else if (ac == 2 && getParameters(ht,2,&filename,&filetime) != FAILURE) {
} else if (ac == 2 && zend_get_parameters_ex(2,&filename,&filetime) != FAILURE) {
newtime = (struct utimbuf *)emalloc(sizeof(struct utimbuf));
if (!newtime) {
php_error(E_WARNING, "unable to emalloc memory for changing time");
return;
}
convert_to_long(filetime);
newtime->actime = filetime->value.lval;
newtime->modtime = filetime->value.lval;
convert_to_long_ex(filetime);
newtime->actime = (*filetime)->value.lval;
newtime->modtime = (*filetime)->value.lval;
} else {
WRONG_PARAM_COUNT;
}
convert_to_string(filename);
convert_to_string_ex(filename);
if (PG(safe_mode) &&(!php_checkuid(filename->value.str.val, 1))) {
if (PG(safe_mode) &&(!php_checkuid((*filename)->value.str.val,1))) {
if (newtime) efree(newtime);
RETURN_FALSE;
}
/* Check the basedir */
if (php_check_open_basedir(filename->value.str.val)) RETURN_FALSE;
if (php_check_open_basedir((*filename)->value.str.val))
RETURN_FALSE;
/* create the file if it doesn't exist already */
ret = stat(filename->value.str.val, &sb);
ret = stat((*filename)->value.str.val, &sb);
if (ret == -1) {
file = fopen(filename->value.str.val, "w");
file = fopen((*filename)->value.str.val, "w");
if (file == NULL) {
php_error(E_WARNING, "unable to create file %s because %s", filename->value.str.val, strerror(errno));
php_error(E_WARNING, "unable to create file %s because %s", (*filename)->value.str.val, strerror(errno));
if (newtime) efree(newtime);
RETURN_FALSE;
}
fclose(file);
}
ret = utime(filename->value.str.val, newtime);
ret = utime((*filename)->value.str.val, newtime);
if (newtime) efree(newtime);
if (ret == -1) {
php_error(E_WARNING, "utime failed: %s", strerror(errno));
@ -534,12 +538,12 @@ static void php_stat(const char *filename, int type, pval *return_value)
/* another quickie macro to make defining similar functions easier */
#define FileFunction(name, funcnum) \
void name(INTERNAL_FUNCTION_PARAMETERS) { \
pval *filename; \
if (ARG_COUNT(ht)!=1 || getParameters(ht,1,&filename) == FAILURE) { \
pval **filename; \
if (ARG_COUNT(ht)!=1 || zend_get_parameters_ex(1,&filename) == FAILURE) { \
WRONG_PARAM_COUNT; \
} \
convert_to_string(filename); \
php_stat(filename->value.str.val, funcnum, return_value); \
convert_to_string_ex(filename); \
php_stat((*filename)->value.str.val, funcnum, return_value); \
}
FileFunction(PHP_FN(fileperms),0)

View File

@ -191,15 +191,15 @@ void php4i_add_header_information(char *header_information, uint header_length)
/* Implementation of the language Header() function */
PHP_FUNCTION(Header)
{
pval *arg1;
pval **arg1;
if (getParameters(ht, 1, &arg1) == FAILURE) {
if (zend_get_parameters_ex(1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string(arg1);
php4i_add_header_information(arg1->value.str.val, arg1->value.str.len);
arg1->type = IS_LONG; /* change arg1's type so that it doesn't get freed */
arg1->value.lval = 0;
convert_to_string_ex(arg1);
php4i_add_header_information((*arg1)->value.str.val,(*arg1)->value.str.len);
(*arg1)->type = IS_LONG; /* change arg1's type so that it doesn't get freed */
(*arg1)->value.lval = 0;
}
@ -409,11 +409,11 @@ PHP_FUNCTION(setcookie)
char *name = NULL, *value = NULL, *path = NULL, *domain = NULL;
time_t expires = 0;
int secure = 0;
pval *arg[6];
pval **arg[6];
int arg_count;
arg_count = ARG_COUNT(ht);
if (arg_count < 1 || arg_count > 6 || getParametersArray(ht, arg_count, arg) == FAILURE) {
if (arg_count < 1 || arg_count > 6 || zend_get_parameters_array_ex(arg_count, arg) == FAILURE) {
WRONG_PARAM_COUNT;
}
if (php_header_printed == 1) {
@ -422,28 +422,28 @@ PHP_FUNCTION(setcookie)
}
switch (arg_count) {
case 6:
convert_to_boolean(arg[5]);
secure = arg[5]->value.lval;
convert_to_boolean_ex(arg[5]);
secure = (*arg[5])->value.lval;
/* break missing intentionally */
case 5:
convert_to_string(arg[4]);
domain = estrndup(arg[4]->value.str.val,arg[4]->value.str.len);
convert_to_string_ex(arg[4]);
domain = estrndup((*arg[4])->value.str.val,(*arg[4])->value.str.len);
/* break missing intentionally */
case 4:
convert_to_string(arg[3]);
path = estrndup(arg[3]->value.str.val,arg[3]->value.str.len);
convert_to_string_ex(arg[3]);
path = estrndup((*arg[3])->value.str.val,(*arg[3])->value.str.len);
/* break missing intentionally */
case 3:
convert_to_long(arg[2]);
expires = arg[2]->value.lval;
convert_to_long_ex(arg[2]);
expires = (*arg[2])->value.lval;
/* break missing intentionally */
case 2:
convert_to_string(arg[1]);
value = estrndup(arg[1]->value.str.val,arg[1]->value.str.len);
convert_to_string_ex(arg[1]);
value = estrndup((*arg[1])->value.str.val,(*arg[1])->value.str.len);
/* break missing intentionally */
case 1:
convert_to_string(arg[0]);
name = estrndup(arg[0]->value.str.val,arg[0]->value.str.len);
convert_to_string_ex(arg[0]);
name = estrndup((*arg[0])->value.str.val,(*arg[0])->value.str.len);
break;
}
#if 0

View File

@ -80,13 +80,13 @@ static int big_endian_long_map[4];
static int little_endian_long_map[4];
static void php_pack(pval *val, int size, int *map, char *output)
static void php_pack(pval **val, int size, int *map, char *output)
{
int i;
char *v;
convert_to_long(val);
v = (char *)&val->value.lval;
convert_to_long_ex(val);
v = (char *)&(*val)->value.lval;
for (i = 0; i < size; i++) {
*(output++) = v[map[i]];
@ -101,7 +101,7 @@ static void php_pack(pval *val, int size, int *map, char *output)
Takes 1 or more arguments and packs them into a binary string according to the format argument */
PHP_FUNCTION(pack)
{
pval **argv;
pval ***argv;
int argc, i;
int currentarg;
char *format;
@ -118,16 +118,16 @@ PHP_FUNCTION(pack)
WRONG_PARAM_COUNT;
}
argv = emalloc(argc * sizeof(pval *));
argv = emalloc(argc * sizeof(pval **));
if (getParametersArray(ht, argc, argv) == FAILURE) {
if (zend_get_parameters_array_ex(argc, argv) == FAILURE) {
efree(argv);
WRONG_PARAM_COUNT;
}
convert_to_string(argv[0]);
format = argv[0]->value.str.val;
formatlen = argv[0]->value.str.len;
convert_to_string_ex(argv[0]);
format = (*argv[0])->value.str.val;
formatlen = (*argv[0])->value.str.len;
/* We have a maximum of <formatlen> format codes to deal with */
formatcodes = emalloc(formatlen * sizeof(*formatcodes));
@ -178,7 +178,7 @@ PHP_FUNCTION(pack)
}
if (arg < 0) {
arg = argv[currentarg]->value.str.len;
arg = (*argv[currentarg])->value.str.len;
}
currentarg++;
@ -291,15 +291,15 @@ PHP_FUNCTION(pack)
for (i = 0; i < formatcount; i++) {
int code = (int)formatcodes[i];
int arg = formatargs[i];
pval *val;
pval **val;
switch ((int)code) {
case 'a': case 'A': {
memset(&output[outputpos], (code == 'a') ? '\0' : ' ', arg);
val = argv[currentarg++];
convert_to_string(val);
memcpy(&output[outputpos], val->value.str.val,
(val->value.str.len < arg) ? val->value.str.len : arg);
convert_to_string_ex(val);
memcpy(&output[outputpos],(*val)->value.str.val,
((*val)->value.str.len < arg) ? (*val)->value.str.len : arg);
outputpos += arg;
break;
}
@ -310,8 +310,8 @@ PHP_FUNCTION(pack)
char *v;
val = argv[currentarg++];
convert_to_string(val);
v = val->value.str.val;
convert_to_string_ex(val);
v = (*val)->value.str.val;
outputpos--;
while (arg-- > 0) {
@ -395,8 +395,8 @@ PHP_FUNCTION(pack)
while (arg-- > 0) {
val = argv[currentarg++];
convert_to_double(val);
v = (float)val->value.dval;
convert_to_double_ex(val);
v = (float)(*val)->value.dval;
memcpy(&output[outputpos], &v, sizeof(v));
outputpos += sizeof(v);
}
@ -408,8 +408,8 @@ PHP_FUNCTION(pack)
while (arg-- > 0) {
val = argv[currentarg++];
convert_to_double(val);
v = (double)val->value.dval;
convert_to_double_ex(val);
v = (double)(*val)->value.dval;
memcpy(&output[outputpos], &v, sizeof(v));
outputpos += sizeof(v);
}
@ -483,25 +483,25 @@ static long php_unpack(char *data, int size, int issigned, int *map)
Unpack binary string into named array elements according to format argument */
PHP_FUNCTION(unpack)
{
pval *formatarg;
pval *inputarg;
pval **formatarg;
pval **inputarg;
char *format;
char *input;
int formatlen;
int inputpos, inputlen;
int i;
if ((ARG_COUNT(ht) != 2) || getParameters(ht, 2, &formatarg, &inputarg) == FAILURE) {
if ((ARG_COUNT(ht) != 2) || zend_get_parameters_ex(2,&formatarg,&inputarg) == FAILURE) {
WRONG_PARAM_COUNT;
}
convert_to_string(formatarg);
convert_to_string(inputarg);
convert_to_string_ex(formatarg);
convert_to_string_ex(inputarg);
format = formatarg->value.str.val;
formatlen = formatarg->value.str.len;
input = inputarg->value.str.val;
inputlen = inputarg->value.str.len;
format = (*formatarg)->value.str.val;
formatlen = (*formatarg)->value.str.len;
input = (*inputarg)->value.str.val;
inputlen = (*inputarg)->value.str.len;
inputpos = 0;
if (array_init(return_value) == FAILURE)

View File

@ -59,17 +59,17 @@ static char php_hex2int(int c)
Convert a quoted-printable string to an 8 bit string */
PHP_FUNCTION(quoted_printable_decode)
{
pval *arg1;
pval **arg1;
char *str;
int i = 0, j = 0;
if (ARG_COUNT(ht) != 1 || getParameters(ht,1,&arg1)==FAILURE)
if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1,&arg1)==FAILURE)
{
WRONG_PARAM_COUNT;
}
convert_to_string(arg1);
convert_to_string_ex(arg1);
str = arg1->value.str.val;
str = (*arg1)->value.str.val;
while ( str[i] )
{
if ( (str[i] == '=') && str[i+1] && str[i+2] &&