cvs: /php4/ext/standard dns.c mail.c rand.c soundex.c syslog.c
| From: | Sascha Schumann | Date: | Sat, 25 Sep 1999 12:09:50 +0000 |
| Subject: | cvs: /php4/ext/standard dns.c mail.c rand.c soundex.c syslog.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-4901@lists.php.net to get a copy of this message | ||
sas Sat Sep 25 08:09:50 1999 EDT
Modified files:
/php4/ext/standard dns.c mail.c rand.c soundex.c syslog.c
Log:
New Zend API
Index: php4/ext/standard/dns.c
diff -u php4/ext/standard/dns.c:1.7 php4/ext/standard/dns.c:1.8
--- php4/ext/standard/dns.c:1.7 Mon Aug 2 15:16:50 1999
+++ php4/ext/standard/dns.c Sat Sep 25 08:09:50 1999
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: dns.c,v 1.7 1999/08/02 19:16:50 zeev Exp $ */
+/* $Id: dns.c,v 1.8 1999/09/25 12:09:50 sas Exp $ */
#include "php.h"
#if HAVE_SYS_SOCKET_H
@@ -55,14 +55,14 @@
Get the Internet host name corresponding to a given IP address */
PHP_FUNCTION(gethostbyaddr)
{
- pval *arg;
+ pval **arg;
- 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);
- return_value->value.str.val = _php3_gethostbyaddr(arg->value.str.val);
+ return_value->value.str.val = _php3_gethostbyaddr((*arg)->value.str.val);
return_value->value.str.len = strlen(return_value->value.str.val);
return_value->type = IS_STRING;
}
@@ -94,14 +94,14 @@
Get the IP address corresponding to a given Internet host name */
PHP_FUNCTION(gethostbyname)
{
- pval *arg;
+ pval **arg;
- 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);
- return_value->value.str.val = _php3_gethostbyname(arg->value.str.val);
+ return_value->value.str.val = _php3_gethostbyname((*arg)->value.str.val);
return_value->value.str.len = strlen(return_value->value.str.val);
return_value->type = IS_STRING;
}
@@ -111,30 +111,30 @@
Return a list of IP addresses that a given hostname resolves to. */
PHP_FUNCTION(gethostbynamel)
{
- pval *arg;
+ pval **arg;
struct hostent *hp;
struct in_addr in;
int i;
- 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 (array_init(return_value) == FAILURE) {
RETURN_FALSE;
}
- hp = gethostbyname(arg->value.str.val);
+ hp = gethostbyname((*arg)->value.str.val);
if (hp == NULL || hp->h_addr_list == NULL) {
#if DEBUG
- php_error(E_WARNING, "Unable to resolve %s\n", arg->value.str.val);
+ php_error(E_WARNING, "Unable to resolve %s\n", (*arg)->value.str.val);
#endif
return;
}
for (i = 0 ; hp->h_addr_list[i] != 0 ; i++) {
- memcpy(&in.s_addr, hp->h_addr_list[i], sizeof(in.s_addr));
+ in = *(struct in_addr *) hp->h_addr_list[i];
add_next_index_string(return_value, inet_ntoa(in), 1);
}
@@ -164,7 +164,7 @@
Check DNS records corresponding to a given Internet host name or IP address */
PHP_FUNCTION(checkdnsrr)
{
- pval *arg1,*arg2;
+ pval **arg1,**arg2;
int type,i;
#ifndef MAXPACKET
#define MAXPACKET 8192 /* max packet size used internally by BIND */
@@ -173,34 +173,34 @@
switch (ARG_COUNT(ht)) {
case 1:
- if (getParameters(ht, 1, &arg1) == FAILURE) {
+ if (getParametersEx(1, &arg1) == FAILURE) {
WRONG_PARAM_COUNT;
}
type = T_MX;
- convert_to_string(arg1);
+ convert_to_string_ex(arg1);
break;
case 2:
- if (getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
+ if (getParametersEx(2, &arg1, &arg2) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_string(arg1);
- convert_to_string(arg2);
- if ( !strcasecmp("A",arg2->value.str.val) ) type = T_A;
- else if ( !strcasecmp("NS",arg2->value.str.val) ) type = T_NS;
- else if ( !strcasecmp("MX",arg2->value.str.val) ) type = T_MX;
- else if ( !strcasecmp("PTR",arg2->value.str.val) ) type = T_PTR;
- else if ( !strcasecmp("ANY",arg2->value.str.val) ) type = T_ANY;
- else if ( !strcasecmp("SOA",arg2->value.str.val) ) type = T_SOA;
- else if ( !strcasecmp("CNAME",arg2->value.str.val) ) type = T_CNAME;
+ convert_to_string_ex(arg1);
+ convert_to_string_ex(arg2);
+ if ( !strcasecmp("A",(*arg2)->value.str.val) ) type = T_A;
+ else if ( !strcasecmp("NS",(*arg2)->value.str.val) ) type = T_NS;
+ else if ( !strcasecmp("MX",(*arg2)->value.str.val) ) type = T_MX;
+ else if ( !strcasecmp("PTR",(*arg2)->value.str.val) ) type = T_PTR;
+ else if ( !strcasecmp("ANY",(*arg2)->value.str.val) ) type = T_ANY;
+ else if ( !strcasecmp("SOA",(*arg2)->value.str.val) ) type = T_SOA;
+ else if ( !strcasecmp("CNAME",(*arg2)->value.str.val) ) type = T_CNAME;
else {
- php_error(E_WARNING,"Type '%s' not supported",arg2->value.str.val);
+ php_error(E_WARNING,"Type '%s' not supported",(*arg2)->value.str.val);
RETURN_FALSE;
}
break;
default:
WRONG_PARAM_COUNT;
}
- i = res_search(arg1->value.str.val,C_IN,type,ans,sizeof(ans));
+ i = res_search((*arg1)->value.str.val,C_IN,type,ans,sizeof(ans));
if ( i < 0 ) {
RETURN_FALSE;
}
Index: php4/ext/standard/mail.c
diff -u php4/ext/standard/mail.c:1.9 php4/ext/standard/mail.c:1.10
--- php4/ext/standard/mail.c:1.9 Mon Aug 2 15:16:50 1999
+++ php4/ext/standard/mail.c Sat Sep 25 08:09:50 1999
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: mail.c,v 1.9 1999/08/02 19:16:50 zeev Exp $ */
+/* $Id: mail.c,v 1.10 1999/09/25 12:09:50 sas Exp $ */
#include <stdlib.h>
#include <ctype.h>
@@ -57,36 +57,36 @@
Send an email message */
PHP_FUNCTION(mail)
{
- pval *argv[4];
+ pval **argv[4];
char *to=NULL, *message=NULL, *headers=NULL, *subject=NULL;
int argc;
argc = ARG_COUNT(ht);
- if (argc < 3 || argc > 4 || getParametersArray(ht, argc, argv) == FAILURE) {
+ if (argc < 3 || argc > 4 || getParametersArrayEx(argc, argv) == FAILURE) {
WRONG_PARAM_COUNT;
}
/* To: */
- convert_to_string(argv[0]);
- if (argv[0]->value.str.val) {
- to = argv[0]->value.str.val;
+ convert_to_string_ex(argv[0]);
+ if ((*argv[0])->value.str.val) {
+ to = (*argv[0])->value.str.val;
} else {
php_error(E_WARNING, "No to field in mail command");
RETURN_FALSE;
}
/* Subject: */
- convert_to_string(argv[1]);
- if (argv[1]->value.str.val) {
- subject = argv[1]->value.str.val;
+ convert_to_string_ex(argv[1]);
+ if ((*argv[1])->value.str.val) {
+ subject = (*argv[1])->value.str.val;
} else {
php_error(E_WARNING, "No subject field in mail command");
RETURN_FALSE;
}
/* message body */
- convert_to_string(argv[2]);
- if (argv[2]->value.str.val) {
- message = argv[2]->value.str.val;
+ convert_to_string_ex(argv[2]);
+ if ((*argv[2])->value.str.val) {
+ message = (*argv[2])->value.str.val;
} else {
/* this is not really an error, so it is allowed. */
php_error(E_WARNING, "No message string in mail command");
@@ -94,8 +94,8 @@
}
if (argc == 4) { /* other headers */
- convert_to_string(argv[3]);
- headers = argv[3]->value.str.val;
+ convert_to_string_ex(argv[3]);
+ headers = (*argv[3])->value.str.val;
}
if (_php3_mail(to, subject, message, headers)){
Index: php4/ext/standard/rand.c
diff -u php4/ext/standard/rand.c:1.5 php4/ext/standard/rand.c:1.6
--- php4/ext/standard/rand.c:1.5 Mon Aug 2 15:16:50 1999
+++ php4/ext/standard/rand.c Sat Sep 25 08:09:50 1999
@@ -19,7 +19,7 @@
| Based on code from: Shawn Cokus <Cokus@math.washington.edu> |
+----------------------------------------------------------------------+
*/
-/* $Id: rand.c,v 1.5 1999/08/02 19:16:50 zeev Exp $ */
+/* $Id: rand.c,v 1.6 1999/09/25 12:09:50 sas Exp $ */
#include <stdlib.h>
@@ -205,19 +205,19 @@
Seeds random number generator */
PHP_FUNCTION(srand)
{
- pval *arg;
+ pval **arg;
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
+ if (ARG_COUNT(ht) != 1 || getParametersEx(1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_long(arg);
+ convert_to_long_ex(arg);
#ifdef HAVE_SRAND48
- srand48((unsigned int) arg->value.lval);
+ srand48((unsigned int) (*arg)->value.lval);
#else
#ifdef HAVE_SRANDOM
- srandom((unsigned int) arg->value.lval);
+ srandom((unsigned int) (*arg)->value.lval);
#else
- srand((unsigned int) arg->value.lval);
+ srand((unsigned int) (*arg)->value.lval);
#endif
#endif
}
@@ -227,12 +227,13 @@
Seeds Mersenne Twister random number generator */
PHP_FUNCTION(mt_srand)
{
- pval *arg;
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
+ pval **arg;
+
+ if (ARG_COUNT(ht) != 1 || getParametersEx(1, &arg) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_long(arg);
- seedMT(arg->value.lval);
+ convert_to_long_ex(arg);
+ seedMT((*arg)->value.lval);
}
/* }}} */
@@ -240,19 +241,19 @@
Returns a random number */
PHP_FUNCTION(rand)
{
- pval *p_min=NULL, *p_max=NULL;
+ pval **p_min=NULL, **p_max=NULL;
switch (ARG_COUNT(ht)) {
case 0:
break;
case 2:
- if (getParameters(ht, 2, &p_min, &p_max)==FAILURE) {
+ if (getParametersEx(2, &p_min, &p_max)==FAILURE) {
RETURN_FALSE;
}
- convert_to_long(p_min);
- convert_to_long(p_max);
- if (p_max->value.lval-p_min->value.lval <= 0) {
- php_error(E_WARNING,"rand(): Invalid range: %ld..%ld", p_min->value.lval,
p_max->value.lval);
+ convert_to_long_ex(p_min);
+ convert_to_long_ex(p_max);
+ if ((*p_max)->value.lval-(*p_min)->value.lval <= 0) {
+ php_error(E_WARNING,"rand(): Invalid range: %ld..%ld", (*p_min)->value.lval,
(*p_max)->value.lval);
}
break;
default:
@@ -296,8 +297,8 @@
* -RL
*/
if (p_min && p_max) { /* implement range */
- return_value->value.lval = p_min->value.lval +
- (int)((double)(p_max->value.lval - p_min->value.lval + 1) *
return_value->value.lval/(PHP_RAND_MAX+1.0));
+ return_value->value.lval = (*p_min)->value.lval +
+ (int)((double)((*p_max)->value.lval - (*p_min)->value.lval + 1) *
return_value->value.lval/(PHP_RAND_MAX+1.0));
}
}
/* }}} */
@@ -306,19 +307,19 @@
Returns a random number from Mersenne Twister */
PHP_FUNCTION(mt_rand)
{
- pval *p_min=NULL, *p_max=NULL;
+ pval **p_min=NULL, **p_max=NULL;
switch (ARG_COUNT(ht)) {
case 0:
break;
case 2:
- if (getParameters(ht, 2, &p_min, &p_max)==FAILURE) {
+ if (getParametersEx(2, &p_min, &p_max)==FAILURE) {
RETURN_FALSE;
}
- convert_to_long(p_min);
- convert_to_long(p_max);
- if (p_max->value.lval-p_min->value.lval <= 0) {
- php_error(E_WARNING,"mtrand(): Invalid range: %ld..%ld", p_min->value.lval,
p_max->value.lval);
+ convert_to_long_ex(p_min);
+ convert_to_long_ex(p_max);
+ if ((*p_max)->value.lval-(*p_min)->value.lval <= 0) {
+ php_error(E_WARNING,"mtrand(): Invalid range: %ld..%ld", (*p_min)->value.lval,
(*p_max)->value.lval);
}
break;
default:
@@ -338,8 +339,8 @@
return_value->value.lval = (long)(randomMT() >> 1);
if (p_min && p_max) { /* implement range */
- return_value->value.lval = p_min->value.lval +
- (int)((double)(p_max->value.lval - p_min->value.lval + 1) *
return_value->value.lval/(PHP_RAND_MAX+1.0));
+ return_value->value.lval = (*p_min)->value.lval +
+ (int)((double)((*p_max)->value.lval - (*p_min)->value.lval + 1) *
return_value->value.lval/(PHP_RAND_MAX+1.0));
}
}
/* }}} */
Index: php4/ext/standard/soundex.c
diff -u php4/ext/standard/soundex.c:1.6 php4/ext/standard/soundex.c:1.7
--- php4/ext/standard/soundex.c:1.6 Wed Jul 28 13:58:38 1999
+++ php4/ext/standard/soundex.c Sat Sep 25 08:09:50 1999
@@ -15,7 +15,7 @@
| Author: Bjørn Borud - Guardian Networks AS <borud@guardian.no> |
+----------------------------------------------------------------------+
*/
-/* $Id: soundex.c,v 1.6 1999/07/28 17:58:38 andi Exp $ */
+/* $Id: soundex.c,v 1.7 1999/09/25 12:09:50 sas Exp $ */
#include "php.h"
#include <stdlib.h>
@@ -30,7 +30,7 @@
{
char *somestring;
int i, _small, len, code, last;
- pval *arg;
+ pval *arg, **parg;
char soundex[4 + 1];
static char soundex_table[26] =
@@ -61,10 +61,11 @@
0, /* Y */
'2'}; /* Z */
- if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg) == FAILURE) {
+ if (ARG_COUNT(ht) != 1 || getParametersEx(1, &parg) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_string(arg);
+ convert_to_string_ex(parg);
+ arg = *parg;
if (arg->value.str.len==0) {
RETURN_FALSE;
}
Index: php4/ext/standard/syslog.c
diff -u php4/ext/standard/syslog.c:1.7 php4/ext/standard/syslog.c:1.8
--- php4/ext/standard/syslog.c:1.7 Mon Jul 26 16:09:08 1999
+++ php4/ext/standard/syslog.c Sat Sep 25 08:09:50 1999
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: syslog.c,v 1.7 1999/07/26 20:09:08 andrey Exp $ */
+/* $Id: syslog.c,v 1.8 1999/09/25 12:09:50 sas Exp $ */
#include "php.h"
#include "php_ini.h"
@@ -204,18 +204,18 @@
*/
PHP_FUNCTION(openlog)
{
- pval *ident, *option, *facility;
- if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &ident, &option, &facility) == FAILURE)
{
+ pval **ident, **option, **facility;
+ if (ARG_COUNT(ht) != 3 || getParametersEx(3, &ident, &option, &facility) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_string(ident);
- convert_to_long(option);
- convert_to_long(facility);
+ convert_to_string_ex(ident);
+ convert_to_long_ex(option);
+ convert_to_long_ex(facility);
if (syslog_device) {
efree(syslog_device);
}
- syslog_device = estrndup(ident->value.str.val,ident->value.str.len);
- openlog(syslog_device, option->value.lval, facility->value.lval);
+ syslog_device = estrndup((*ident)->value.str.val,(*ident)->value.str.len);
+ openlog(syslog_device, (*option)->value.lval, (*facility)->value.lval);
RETURN_TRUE;
}
/* }}} */
@@ -237,20 +237,20 @@
Generate a system log message */
PHP_FUNCTION(syslog)
{
- pval *priority, *message;
+ pval **priority, **message;
- if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &priority, &message) == FAILURE) {
+ if (ARG_COUNT(ht) != 2 || getParametersEx(2, &priority, &message) == FAILURE) {
WRONG_PARAM_COUNT;
}
- convert_to_long(priority);
- convert_to_string(message);
+ convert_to_long_ex(priority);
+ convert_to_string_ex(message);
/*
* CAVEAT: if the message contains patterns such as "%s",
* this will cause problems.
*/
- syslog(priority->value.lval, message->value.str.val);
+ syslog((*priority)->value.lval, (*message)->value.str.val);
RETURN_TRUE;
}
/* }}} */