cvs: /php4/ext/standard base64.c crypt.c link.c md5.c microtime.c uniqid.c url.c
| From: | Sascha Schumann | Date: | Fri, 24 Sep 1999 19:35:25 +0000 |
| Subject: | cvs: /php4/ext/standard base64.c crypt.c link.c md5.c microtime.c uniqid.c url.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-4881@lists.php.net to get a copy of this message | ||
sas Fri Sep 24 15:35:25 1999 EDT
Modified files:
/php4/ext/standard base64.c crypt.c link.c md5.c microtime.c
uniqid.c url.c
Log:
Use new Zend API.
Index: php4/ext/standard/base64.c
diff -u php4/ext/standard/base64.c:1.8 php4/ext/standard/base64.c:1.9
--- php4/ext/standard/base64.c:1.8 Wed Jul 21 10:27:05 1999
+++ php4/ext/standard/base64.c Fri Sep 24 15:35:25 1999
@@ -15,7 +15,7 @@
| Author: Jim Winstead (jimw@php.net) |
+----------------------------------------------------------------------+
*/
-/* $Id: base64.c,v 1.8 1999/07/21 14:27:05 ssb Exp $ */
+/* $Id: base64.c,v 1.9 1999/09/24 19:35:25 sas Exp $ */
#include <string.h>
@@ -142,15 +142,15 @@
/* {{{ proto string base64_encode(string str)
Encodes string using MIME base64 algorithm */
PHP_FUNCTION(base64_encode) {
- pval *string;
+ pval **string;
unsigned char *result;
int ret_length;
- if (ARG_COUNT(ht)!=1 || getParameters(ht,1,&string) == FAILURE) {
+ if (ARG_COUNT(ht)!=1 || getParametersEx(1,&string) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_string(string);
- result = _php3_base64_encode(string->value.str.val, string->value.str.len, &ret_length);
+ convert_to_string_ex(string);
+ result = _php3_base64_encode((*string)->value.str.val, (*string)->value.str.len,
&ret_length);
if (result != NULL) {
return_value->value.str.val = result;
return_value->value.str.len = ret_length;
@@ -165,15 +165,15 @@
/* {{{ proto string base64_decode(string str)
Decodes string using MIME base64 algorithm */
PHP_FUNCTION(base64_decode) {
- pval *string;
+ pval **string;
unsigned char *result;
int ret_length;
- if (ARG_COUNT(ht)!=1 || getParameters(ht,1,&string) == FAILURE) {
+ if (ARG_COUNT(ht)!=1 || getParametersEx(1,&string) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_string(string);
- result = _php3_base64_decode(string->value.str.val, string->value.str.len, &ret_length);
+ convert_to_string_ex(string);
+ result = _php3_base64_decode((*string)->value.str.val, (*string)->value.str.len,
&ret_length);
if (result != NULL) {
return_value->value.str.val = result;
return_value->value.str.len = ret_length;
Index: php4/ext/standard/crypt.c
diff -u php4/ext/standard/crypt.c:1.9 php4/ext/standard/crypt.c:1.10
--- php4/ext/standard/crypt.c:1.9 Mon Sep 6 09:24:36 1999
+++ php4/ext/standard/crypt.c Fri Sep 24 15:35:25 1999
@@ -17,7 +17,7 @@
| Rasmus Lerdorf <rasmus@lerdorf.on.ca> |
+----------------------------------------------------------------------+
*/
-/* $Id: crypt.c,v 1.9 1999/09/06 13:24:36 riffraff Exp $ */
+/* $Id: crypt.c,v 1.10 1999/09/24 19:35:25 sas Exp $ */
#include <stdlib.h>
#include "php.h"
@@ -120,7 +120,7 @@
PHP_FUNCTION(crypt)
{
char salt[PHP3_MAX_SALT_LEN+1];
- pval *arg1, *arg2;
+ pval **arg1, **arg2;
salt[0]=salt[PHP3_MAX_SALT_LEN]='\0';
/* This will produce suitable results if people depend on DES-encryption
@@ -129,22 +129,22 @@
switch (ARG_COUNT(ht)) {
case 1:
- if (getParameters(ht, 1, &arg1)==FAILURE) {
+ if (getParametersEx(1, &arg1)==FAILURE) {
RETURN_FALSE;
}
break;
case 2:
- if (getParameters(ht, 2, &arg1, &arg2)==FAILURE) {
+ if (getParametersEx(2, &arg1, &arg2)==FAILURE) {
RETURN_FALSE;
}
- convert_to_string(arg2);
- memcpy(salt, arg2->value.str.val, MIN(PHP3_MAX_SALT_LEN,arg2->value.str.len));
+ convert_to_string_ex(arg2);
+ memcpy(salt, (*arg2)->value.str.val, MIN(PHP3_MAX_SALT_LEN,(*arg2)->value.str.len));
break;
default:
WRONG_PARAM_COUNT;
break;
}
- convert_to_string(arg1);
+ convert_to_string_ex(arg1);
/* The automatic salt generation only covers standard DES and md5-crypt */
if(!*salt) {
@@ -171,7 +171,7 @@
#endif
}
- return_value->value.str.val = (char *) crypt(arg1->value.str.val, salt);
+ return_value->value.str.val = (char *) crypt((*arg1)->value.str.val, salt);
return_value->value.str.len = strlen(return_value->value.str.val);
return_value->type = IS_STRING;
pval_copy_constructor(return_value);
Index: php4/ext/standard/link.c
diff -u php4/ext/standard/link.c:1.9 php4/ext/standard/link.c:1.10
--- php4/ext/standard/link.c:1.9 Sun Aug 15 14:52:10 1999
+++ php4/ext/standard/link.c Fri Sep 24 15:35:25 1999
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: link.c,v 1.9 1999/08/15 18:52:10 thies Exp $ */
+/* $Id: link.c,v 1.10 1999/09/24 19:35:25 sas Exp $ */
#include "php.h"
#include "php3_filestat.h"
@@ -53,16 +53,16 @@
PHP_FUNCTION(readlink)
{
#if HAVE_SYMLINK
- pval *filename;
+ pval **filename;
char buff[256];
int ret;
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &filename) == FAILURE) {
+ if (ARG_COUNT(ht) != 1 || getParametersEx(1, &filename) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_string(filename);
+ convert_to_string_ex(filename);
- ret = readlink(filename->value.str.val, buff, 255);
+ ret = readlink((*filename)->value.str.val, buff, 255);
if (ret == -1) {
php_error(E_WARNING, "readlink failed (%s)", strerror(errno));
RETURN_FALSE;
@@ -79,16 +79,16 @@
PHP_FUNCTION(linkinfo)
{
#if HAVE_SYMLINK
- pval *filename;
+ pval **filename;
struct stat sb;
int ret;
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &filename) == FAILURE) {
+ if (ARG_COUNT(ht) != 1 || getParametersEx(1, &filename) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_string(filename);
+ convert_to_string_ex(filename);
- ret = lstat(filename->value.str.val, &sb);
+ ret = lstat((*filename)->value.str.val, &sb);
if (ret == -1) {
php_error(E_WARNING, "LinkInfo failed (%s)", strerror(errno));
RETURN_LONG(-1L);
@@ -103,21 +103,21 @@
PHP_FUNCTION(symlink)
{
#if HAVE_SYMLINK
- pval *topath, *frompath;
+ pval **topath, **frompath;
int ret;
PLS_FETCH();
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &topath, &frompath) == FAILURE) {
+ if (ARG_COUNT(ht) != 2 || getParametersEx(2, &topath, &frompath) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_string(topath);
- convert_to_string(frompath);
+ convert_to_string_ex(topath);
+ convert_to_string_ex(frompath);
- if (PG(safe_mode) && !_php3_checkuid(topath->value.str.val, 2)) {
+ if (PG(safe_mode) && !_php3_checkuid((*topath)->value.str.val, 2)) {
RETURN_FALSE;
}
- ret = symlink(topath->value.str.val, frompath->value.str.val);
+ ret = symlink((*topath)->value.str.val, (*frompath)->value.str.val);
if (ret == -1) {
php_error(E_WARNING, "SymLink failed (%s)", strerror(errno));
RETURN_FALSE;
@@ -132,21 +132,21 @@
PHP_FUNCTION(link)
{
#if HAVE_LINK
- pval *topath, *frompath;
+ pval **topath, **frompath;
int ret;
PLS_FETCH();
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &topath, &frompath) == FAILURE) {
+ if (ARG_COUNT(ht) != 2 || getParametersEx(2, &topath, &frompath) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_string(topath);
- convert_to_string(frompath);
+ convert_to_string_ex(topath);
+ convert_to_string_ex(frompath);
- if (PG(safe_mode) && !_php3_checkuid(topath->value.str.val, 2)) {
+ if (PG(safe_mode) && !_php3_checkuid((*topath)->value.str.val, 2)) {
RETURN_FALSE;
}
- ret = link(topath->value.str.val, frompath->value.str.val);
+ ret = link((*topath)->value.str.val, (*frompath)->value.str.val);
if (ret == -1) {
php_error(E_WARNING, "Link failed (%s)", strerror(errno));
RETURN_FALSE;
@@ -160,20 +160,20 @@
Delete a file */
PHP_FUNCTION(unlink)
{
- pval *filename;
+ pval **filename;
int ret;
PLS_FETCH();
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &filename) == FAILURE) {
+ if (ARG_COUNT(ht) != 1 || getParametersEx(1, &filename) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_string(filename);
+ convert_to_string_ex(filename);
- if (PG(safe_mode) && !_php3_checkuid(filename->value.str.val, 2)) {
+ if (PG(safe_mode) && !_php3_checkuid((*filename)->value.str.val, 2)) {
RETURN_FALSE;
}
- ret = unlink(filename->value.str.val);
+ ret = unlink((*filename)->value.str.val);
if (ret == -1) {
php_error(E_WARNING, "Unlink failed (%s)", strerror(errno));
RETURN_FALSE;
Index: php4/ext/standard/md5.c
diff -u php4/ext/standard/md5.c:1.5 php4/ext/standard/md5.c:1.6
--- php4/ext/standard/md5.c:1.5 Fri Jul 16 09:12:56 1999
+++ php4/ext/standard/md5.c Fri Sep 24 15:35:25 1999
@@ -29,21 +29,21 @@
Calculate the md5 hash of a string */
PHP_FUNCTION(md5)
{
- pval *arg;
+ pval **arg;
char md5str[33];
PHP3_MD5_CTX context;
unsigned char digest[16];
int i;
char *r;
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
+ if (ARG_COUNT(ht) != 1 || getParametersEx(1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_string(arg);
+ convert_to_string_ex(arg);
md5str[0] = '\0';
PHP3_MD5Init(&context);
- PHP3_MD5Update(&context, arg->value.str.val, arg->value.str.len);
+ PHP3_MD5Update(&context, (*arg)->value.str.val, (*arg)->value.str.len);
PHP3_MD5Final(digest, &context);
for (i = 0, r = md5str; i < 16; i++, r += 2) {
sprintf(r, "%02x", digest[i]);
Index: php4/ext/standard/microtime.c
diff -u php4/ext/standard/microtime.c:1.9 php4/ext/standard/microtime.c:1.10
--- php4/ext/standard/microtime.c:1.9 Tue Sep 21 04:41:31 1999
+++ php4/ext/standard/microtime.c Fri Sep 24 15:35:25 1999
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: microtime.c,v 1.9 1999/09/21 08:41:31 sas Exp $ */
+/* $Id: microtime.c,v 1.10 1999/09/24 19:35:25 sas Exp $ */
#include <stdlib.h>
#ifdef HAVE_UNISTD_H
@@ -93,13 +93,13 @@
#if HAVE_GETRUSAGE
struct rusage usg;
int ac = ARG_COUNT(ht);
- pval *pwho;
+ pval **pwho;
int who = RUSAGE_SELF;
if(ac == 1 &&
- getParameters(ht, ac, &pwho) != FAILURE) {
- convert_to_long(pwho);
- if(pwho->value.lval == 1)
+ getParametersEx(ac, &pwho) != FAILURE) {
+ convert_to_long_ex(pwho);
+ if((*pwho)->value.lval == 1)
who = RUSAGE_CHILDREN;
}
Index: php4/ext/standard/uniqid.c
diff -u php4/ext/standard/uniqid.c:1.12 php4/ext/standard/uniqid.c:1.13
--- php4/ext/standard/uniqid.c:1.12 Mon Sep 20 09:11:34 1999
+++ php4/ext/standard/uniqid.c Fri Sep 24 15:35:25 1999
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: uniqid.c,v 1.12 1999/09/20 13:11:34 ssb Exp $ */
+/* $Id: uniqid.c,v 1.13 1999/09/24 19:35:25 sas Exp $ */
#include "php.h"
@@ -38,32 +38,34 @@
#include "php_lcg.h"
#include "uniqid.h"
+#define MORE_ENTROPY (argc == 2 && (*flags)->value.lval)
+
/* {{{ proto string uniqid(string prefix, [bool more_entropy])
Generate a unique id */
PHP_FUNCTION(uniqid)
{
#ifdef HAVE_GETTIMEOFDAY
- pval *prefix, *flags;
+ pval **prefix, **flags;
char uniqid[138];
int sec, usec, argc;
struct timeval tv;
argc = ARG_COUNT(ht);
- if (argc < 1 || argc > 2 || getParameters(ht, argc, &prefix, &flags)) {
+ if (argc < 1 || argc > 2 || getParametersEx(argc, &prefix, &flags)) {
WRONG_PARAM_COUNT;
}
- convert_to_string(prefix);
+ convert_to_string_ex(prefix);
if (argc == 2) {
- convert_to_boolean(flags);
+ convert_to_boolean_ex(flags);
}
/* Do some bounds checking since we are using a char array. */
- if (prefix->value.str.len > 114) {
+ if ((*prefix)->value.str.len > 114) {
php_error(E_WARNING, "The prefix to uniqid should not be more than 114 characters.");
return;
}
#if HAVE_USLEEP && !(WIN32|WINNT)
- if (argc < 2 || !flags->value.lval) {
+ if (!MORE_ENTROPY) {
usleep(1);
}
#endif
@@ -74,10 +76,10 @@
/* The max value usec can have is 0xF423F, so we use only five hex
* digits for usecs.
*/
- if (argc == 2 && flags->value.lval) {
- sprintf(uniqid, "%s%08x%05x%.8f", prefix->value.str.val, sec, usec,
php_combined_lcg() * 10);
+ if (MORE_ENTROPY) {
+ sprintf(uniqid, "%s%08x%05x%.8f", (*prefix)->value.str.val, sec, usec,
php_combined_lcg() * 10);
} else {
- sprintf(uniqid, "%s%08x%05x", prefix->value.str.val, sec, usec);
+ sprintf(uniqid, "%s%08x%05x", (*prefix)->value.str.val, sec, usec);
}
RETURN_STRING(uniqid,1);
Index: php4/ext/standard/url.c
diff -u php4/ext/standard/url.c:1.8 php4/ext/standard/url.c:1.9
--- php4/ext/standard/url.c:1.8 Mon Aug 2 15:16:51 1999
+++ php4/ext/standard/url.c Fri Sep 24 15:35:25 1999
@@ -15,7 +15,7 @@
| Author: Jim Winstead (jimw@php.net) |
+----------------------------------------------------------------------+
*/
-/* $Id: url.c,v 1.8 1999/08/02 19:16:51 zeev Exp $ */
+/* $Id: url.c,v 1.9 1999/09/24 19:35:25 sas Exp $ */
#include <stdlib.h>
#include <string.h>
@@ -148,18 +148,18 @@
Parse a URL and return its components */
PHP_FUNCTION(parse_url)
{
- pval *string;
+ pval **string;
url *resource;
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &string) == FAILURE) {
+ if (ARG_COUNT(ht) != 1 || getParametersEx(1, &string) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_string(string);
+ convert_to_string_ex(string);
- resource = url_parse(string->value.str.val);
+ resource = url_parse((*string)->value.str.val);
if (resource == NULL) {
- php_error(E_WARNING, "unable to parse url (%s)", string->value.str.val);
+ php_error(E_WARNING, "unable to parse url (%s)", (*string)->value.str.val);
RETURN_FALSE;
}
/* allocate an array for return */
@@ -256,19 +256,19 @@
URL-encodes string */
PHP_FUNCTION(urlencode)
{
- pval *arg;
+ pval **arg;
char *str;
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
+ if (ARG_COUNT(ht) != 1 || getParametersEx(1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_string(arg);
+ convert_to_string_ex(arg);
- if (!arg->value.str.len) {
+ if (!(*arg)->value.str.len) {
var_reset(return_value);
return;
}
- str = _php3_urlencode(arg->value.str.val, arg->value.str.len);
+ str = _php3_urlencode((*arg)->value.str.val, (*arg)->value.str.len);
RETVAL_STRING(str, 1);
efree(str);
}
@@ -278,21 +278,21 @@
Decodes URL-encoded string */
PHP_FUNCTION(urldecode)
{
- pval *arg;
+ pval **arg;
int len;
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
+ if (ARG_COUNT(ht) != 1 || getParametersEx(1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_string(arg);
+ convert_to_string_ex(arg);
- if (!arg->value.str.len) {
+ if (!(*arg)->value.str.len) {
var_reset(return_value);
return;
}
- len = _php3_urldecode(arg->value.str.val, arg->value.str.len);
+ len = _php3_urldecode((*arg)->value.str.val, (*arg)->value.str.len);
- RETVAL_STRINGL(arg->value.str.val, len, 1);
+ RETVAL_STRINGL((*arg)->value.str.val, len, 1);
}
/* }}} */
@@ -353,18 +353,18 @@
URL-encodes string */
PHP_FUNCTION(rawurlencode)
{
- pval *arg;
+ pval **arg;
char *str;
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
+ if (ARG_COUNT(ht) != 1 || getParametersEx(1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_string(arg);
+ convert_to_string_ex(arg);
- if (!arg->value.str.len) {
+ if (!(*arg)->value.str.len) {
RETURN_FALSE;
}
- str = _php3_rawurlencode(arg->value.str.val, arg->value.str.len);
+ str = _php3_rawurlencode((*arg)->value.str.val, (*arg)->value.str.len);
RETVAL_STRING(str, 1);
efree(str);
}
@@ -374,20 +374,20 @@
Decodes URL-encodes string */
PHP_FUNCTION(rawurldecode)
{
- pval *arg;
+ pval **arg;
int len;
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
+ if (ARG_COUNT(ht) != 1 || getParametersEx(1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_string(arg);
+ convert_to_string_ex(arg);
- if (!arg->value.str.len) {
+ if (!(*arg)->value.str.len) {
RETURN_FALSE;
}
- len = _php3_rawurldecode(arg->value.str.val, arg->value.str.len);
+ len = _php3_rawurldecode((*arg)->value.str.val, (*arg)->value.str.len);
- RETVAL_STRINGL(arg->value.str.val, len, 1);
+ RETVAL_STRINGL((*arg)->value.str.val, len, 1);
}
/* }}} */