cvs: /php4/ext/standard basic_functions.c basic_functions.h

From: Date: Tue, 02 Nov 1999 03:47:40 +0000
Subject: cvs: /php4/ext/standard basic_functions.c basic_functions.h
Groups: php.version4 
Request: Send a blank email to php-version4+get-5830@lists.php.net to get a copy of this message
evan Mon Nov 1 22:47:40 1999 EDT Modified files: /php4/ext/standard basic_functions.c basic_functions.h Log: (PHP getprotoby{name,number}) New Functions Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.113 php4/ext/standard/basic_functions.c:1.114 --- php4/ext/standard/basic_functions.c:1.113 Mon Nov 1 15:51:04 1999 +++ php4/ext/standard/basic_functions.c Mon Nov 1 22:47:09 1999 @@ -212,6 +212,8 @@ PHP_FE(mt_getrandmax, NULL) PHP_FE(getservbyname, NULL) PHP_FE(getservbyport, NULL) + PHP_FE(getprotobyname, NULL) + PHP_FE(getprotobynumber, NULL) PHP_FE(gethostbyaddr, NULL) PHP_FE(gethostbyname, NULL) PHP_FE(gethostbynamel, NULL) @@ -3157,6 +3159,55 @@ RETURN_FALSE; RETURN_STRING(serv->s_name,1); +} +/* }}} */ + + +/* {{{ proto int getprotobyname(string name) + Returns protocol number associated with name as per /etc/protocols. */ +PHP_FUNCTION(getprotobyname) +{ + pval **name; + struct protoent *ent; + + if(ARG_COUNT(ht) != 1 || getParametersEx(1, &name) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_string_ex(name); + + ent = getprotobyname((*name)->value.str.val); + + if(ent == NULL) { + return_value->value.lval = -1; + return_value->type = IS_LONG; + return; + } + + RETURN_LONG(ent->p_proto); +} +/* }}} */ + + +/* {{{ proto string getprotobynumber(int proto) + Returns protocol name associated with protocol number proto. */ +PHP_FUNCTION(getprotobynumber) +{ + pval **proto; + struct protoent *ent; + + if(ARG_COUNT(ht) != 1 || getParametersEx(1, &proto) == FAILURE) { + WRONG_PARAM_COUNT; + } + + convert_to_long_ex(proto); + + ent = getprotobynumber((*proto)->value.lval); + + if(ent == NULL) + RETURN_FALSE; + + RETURN_STRING(ent->p_name,1); } /* }}} */ Index: php4/ext/standard/basic_functions.h diff -u php4/ext/standard/basic_functions.h:1.28 php4/ext/standard/basic_functions.h:1.29 --- php4/ext/standard/basic_functions.h:1.28 Mon Nov 1 15:51:04 1999 +++ php4/ext/standard/basic_functions.h Mon Nov 1 22:47:09 1999 @@ -29,7 +29,7 @@ */ -/* $Id: basic_functions.h,v 1.28 1999/11/01 20:51:04 andrei Exp $ */ +/* $Id: basic_functions.h,v 1.29 1999/11/02 03:47:09 evan Exp $ */ #ifndef _BASIC_FUNCTIONS_H #define _BASIC_FUNCTIONS_H @@ -137,6 +137,8 @@ PHP_FUNCTION(getservbyname); PHP_FUNCTION(getservbyport); +PHP_FUNCTION(getprotobyname); +PHP_FUNCTION(getprotobynumber); #if HAVE_PUTENV typedef struct {

« previous php.version4 (#5830) next »