--- basic_functions.c.orig Fri Mar 3 11:11:15 2000 +++ basic_functions.c Fri Mar 3 11:24:35 2000 @@ -234,6 +234,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 @@ -475,6 +477,41 @@ return SUCCESS; } + + +PHP_FUNCTION(ip2long) +{ + pval **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) +{ + pval **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 *