Re: [PHP4BETA] cvs: /php4/ext/standard basic_functions.c basic_functions.h
| From: | Andi Gutmans | Date: | Sat, 04 Mar 2000 18:26:00 +0000 |
| Subject: | Re: [PHP4BETA] cvs: /php4/ext/standard basic_functions.c basic_functions.h | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-11517@lists.php.net to get a copy of this message | ||
I don't think convert_to_string_ex() can fail converting to a string. So you don't need that check.
Andi
At 05:28 PM 3/4/00 +0000, Andrei Zmievski wrote:
andrei Sat Mar 4 09:28:46 2000 EDTModified files:/php4/ext/standard basic_functions.c basic_functions.hLog: @Added ip2long() and long2ip() courtesy of Faisal Nasim <faisal@nasim.org> Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.169 php4/ext/standard/basic_functions.c:1.170 --- php4/ext/standard/basic_functions.c:1.169 Fri Mar 3 18:59:14 2000 +++ php4/ext/standard/basic_functions.c Sat Mar 4 09:28:16 2000 @@ -30,6 +30,7 @@ #include <time.h> #include <stdio.h> #include <netdb.h> +#include <arpa/inet.h> #if HAVE_UNISTD_H #include <unistd.h> #endif @@ -234,6 +235,8 @@PHP_FE(dechex, NULL) PHP_FE(base_convert, NULL)
PHP_FE(number_format, NULL) + PHP_FE(ip2long, NULL) + PHP_FE(long2ip, NULL)
PHP_FE(getenv, NULL)#ifdef HAVE_PUTENV
@@ -480,6 +483,42 @@--- Andi Gutmans <andi@zend.com> http://www.zend.com/return SUCCESS;} + + +PHP_FUNCTION(ip2long) +{+ zval **str;++ if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &str) == FAILURE) { + WRONG_PARAM_COUNT; + }++ convert_to_string_ex(str);++ if ((*str)->type != IS_STRING) { + RETURN_FALSE; + }++ RETURN_LONG ( inet_addr ( ( *str ) -> value.str.val ) );+} + + +PHP_FUNCTION(long2ip) +{+ zval **num; + struct in_addr myaddr;++ if (ARG_COUNT(ht) != 1 || zend_get_parameters_ex(1, &num) == FAILURE) { + WRONG_PARAM_COUNT; + }++ convert_to_long_ex(num); + myaddr.s_addr = (*num) -> value.lval;++ RETURN_STRING ( inet_ntoa ( myaddr ) , 1 );+} + + /******************** * System Functions * Index: php4/ext/standard/basic_functions.h diff -u php4/ext/standard/basic_functions.h:1.48 php4/ext/standard/basic_functions.h:1.49--- php4/ext/standard/basic_functions.h:1.48 Fri Mar 3 18:59:14 2000+++ php4/ext/standard/basic_functions.h Sat Mar 4 09:28:16 2000 @@ -29,7 +29,7 @@ */ -/* $Id: basic_functions.h,v 1.48 2000/03/04 02:59:14 zeev Exp $ */ +/* $Id: basic_functions.h,v 1.49 2000/03/04 17:28:16 andrei Exp $ */ #ifndef _BASIC_FUNCTIONS_H #define _BASIC_FUNCTIONS_H @@ -55,6 +55,8 @@ PHP_FUNCTION(flush); PHP_FUNCTION(gettype); PHP_FUNCTION(settype); +PHP_FUNCTION(ip2long); +PHP_FUNCTION(long2ip); /* system functions */ PHP_FUNCTION(getenv); -- PHP 4.0 Beta Mailing List <http://www.php.net/version4/> To unsubscribe, e-mail: php4beta-unsubscribe@lists.php.net For additional commands, e-mail: php4beta-help@lists.php.net To contact the list administrators, e-mail: php4beta-admin@lists.php.net