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

From: Date: Sun, 21 Nov 1999 13:25:34 +0000
Subject: cvs: /php4/ext/standard basic_functions.c html.c html.h
Groups: php.version4 
Request: Send a blank email to php-version4+get-6620@lists.php.net to get a copy of this message
thies Sun Nov 21 08:25:34 1999 EDT Modified files: /php4/ext/standard basic_functions.c html.c html.h Log: (PHP get_html_translation_table) new function. Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.122 php4/ext/standard/basic_functions.c:1.123 --- php4/ext/standard/basic_functions.c:1.122 Tue Nov 16 17:44:13 1999 +++ php4/ext/standard/basic_functions.c Sun Nov 21 08:25:04 1999 @@ -105,6 +105,7 @@ PHP_FE(htmlspecialchars, NULL) PHP_FE(htmlentities, NULL) + PHP_FE(get_html_translation_table, NULL) PHP_FE(md5, NULL) @@ -366,6 +367,7 @@ REGISTER_INI_ENTRIES(); register_phpinfo_constants(INIT_FUNC_ARGS_PASSTHRU); + register_html_constants(INIT_FUNC_ARGS_PASSTHRU); return SUCCESS; } Index: php4/ext/standard/html.c diff -u php4/ext/standard/html.c:1.6 php4/ext/standard/html.c:1.7 --- php4/ext/standard/html.c:1.6 Wed Oct 13 15:51:11 1999 +++ php4/ext/standard/html.c Sun Nov 21 08:25:04 1999 @@ -95,6 +95,16 @@ efree(new); } +#define HTML_SPECIALCHARS 0 +#define HTML_ENTITIES 1 + +void register_html_constants(INIT_FUNC_ARGS) +{ + ELS_FETCH(); + REGISTER_LONG_CONSTANT("HTML_SPECIALCHARS", HTML_SPECIALCHARS, CONST_PERSISTENT|CONST_CS); + REGISTER_LONG_CONSTANT("HTML_ENTITIES", HTML_ENTITIES, CONST_PERSISTENT|CONST_CS); +} + /* {{{ proto string htmlspecialchars(string string) Convert special characters to HTML entities */ PHP_FUNCTION(htmlspecialchars) @@ -108,6 +118,49 @@ PHP_FUNCTION(htmlentities) { _php3_htmlentities(INTERNAL_FUNCTION_PARAM_PASSTHRU,1); +} +/* }}} */ + +/* {{{ proto array get_html_translation_table([int whichone]) + returns the internal translation-table used by htmlspecialchars and htmlentities */ +PHP_FUNCTION(get_html_translation_table) +{ + zval **whichone; + int which = 0; + int ac = ARG_COUNT(ht); + int inx; + char ind[ 2 ]; + + if (ac < 0 || ac > 1 || getParametersEx(ac, &whichone) == FAILURE) { + WRONG_PARAM_COUNT; + } + + if (ac == 1) { + convert_to_long_ex(whichone); + which = (*whichone)->value.lval; + } + + array_init(return_value); + + ind[1] = 0; + + switch (which) { + case HTML_ENTITIES: + for (inx = 160; inx <= 255; inx++) { + char buffer[16]; + ind[0] = inx; + sprintf(buffer,"&%s;",EntTable[inx-160]); + add_assoc_string(return_value,ind,buffer,1); + } + /* break thru */ + + case HTML_SPECIALCHARS: + ind[0]=38; add_assoc_string(return_value,ind,"&amp;",1); + ind[0]=34; add_assoc_string(return_value,ind,"&quot;",1); + ind[0]=60; add_assoc_string(return_value,ind,"&lt;",1); + ind[0]=62; add_assoc_string(return_value,ind,"&gt;",1); + break; + } } /* }}} */ Index: php4/ext/standard/html.h diff -u php4/ext/standard/html.h:1.2 php4/ext/standard/html.h:1.3 --- php4/ext/standard/html.h:1.2 Sun May 16 07:19:26 1999 +++ php4/ext/standard/html.h Sun Nov 21 08:25:04 1999 @@ -27,12 +27,15 @@ +----------------------------------------------------------------------+ */ -/* $Id: html.h,v 1.2 1999/05/16 11:19:26 sas Exp $ */ +/* $Id: html.h,v 1.3 1999/11/21 13:25:04 thies Exp $ */ #ifndef _HTML_H #define _HTML_H +void register_html_constants(INIT_FUNC_ARGS); + PHP_FUNCTION(htmlspecialchars); PHP_FUNCTION(htmlentities); +PHP_FUNCTION(get_html_translation_table); #endif /* _HTML_H */

« previous php.version4 (#6620) next »