Date: 10/21/98
- Next message: bb26 <email protected>: "[PHP-DEV] Bug #863: PHP returns bad values for 'REAL' columns coming from sybase"
- Previous message: ssb: "[PHP-DEV] CVS update: php3/functions"
- Next in thread: ssb: "[PHP-DEV] CVS update: php3/functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wednesday October 21, 1998 @ 9:45
Author: ssb
Update of /repository/php3/functions
In directory asf:/u2/tmp/cvs-serv3464
Modified Files:
xml.c
Log Message:
* added XML_Parser{Set,Get}Option() functions
* added case-folding option
Index: php3/functions/xml.c
diff -c php3/functions/xml.c:1.3 php3/functions/xml.c:1.4
*** php3/functions/xml.c:1.3 Wed Oct 21 08:27:08 1998
--- php3/functions/xml.c Wed Oct 21 09:45:01 1998
***************
*** 27,33 ****
+----------------------------------------------------------------------+
*/
! /* $Id: xml.c,v 1.3 1998/10/21 12:27:08 ssb Exp $ */
#include "php.h"
#include "internal_functions.h"
--- 27,33 ----
+----------------------------------------------------------------------+
*/
! /* $Id: xml.c,v 1.4 1998/10/21 13:45:01 ssb Exp $ */
#include "php.h"
#include "internal_functions.h"
***************
*** 39,44 ****
--- 39,45 ----
# include "build-defs.h"
# include "snprintf.h"
# include "head.h"
+ # include "php3_string.h"
/* Short-term TODO list:
* - Fix the expat library so you can install your own memory manager
***************
*** 156,161 ****
--- 157,164 ----
PHP_FE(xml_getcurrentcolumnnumber, NULL)
PHP_FE(xml_getcurrentbyteindex, NULL)
PHP_FE(xml_parserfree, NULL)
+ PHP_FE(xml_parsersetoption, NULL)
+ PHP_FE(xml_parsergetoption, NULL)
{NULL, NULL, NULL}
};
***************
*** 224,229 ****
--- 227,234 ----
REGISTER_LONG_CONSTANT("XML_ERROR_UNCLOSED_CDATA_SECTION", XML_ERROR_UNCLOSED_CDATA_SECTION, CONST_CS|CONST_PERSISTENT);
REGISTER_LONG_CONSTANT("XML_ERROR_EXTERNAL_ENTITY_HANDLING", XML_ERROR_EXTERNAL_ENTITY_HANDLING, CONST_CS|CONST_PERSISTENT);
+ REGISTER_LONG_CONSTANT("XML_OPTION_CASE_FOLDING", PHP3_XML_OPTION_CASE_FOLDING, CONST_CS|CONST_PERSISTENT);
+
return SUCCESS;
}
***************
*** 487,504 ****
if (parser && parser->startElementHandler) {
pval *retval, *args[3];
args[0] = php3i_longpval(parser->index);
args[1] = php3i_stringpval(name);
args[2] = emalloc(sizeof(pval));
array_init(args[2]);
while (attributes && *attributes) {
! add_assoc_string(args[2], (char *)attributes[0], (char *)attributes[1], 1);
attributes += 2;
}
if ((retval = xml_call_handler(parser, parser->startElementHandler, 3, args))) {
pval_destructor(retval);
efree(retval);
}
}
}
--- 492,523 ----
if (parser && parser->startElementHandler) {
pval *retval, *args[3];
+ if (parser->case_folding) {
+ name = _php3_strtolower(estrdup(name));
+ }
args[0] = php3i_longpval(parser->index);
args[1] = php3i_stringpval(name);
args[2] = emalloc(sizeof(pval));
array_init(args[2]);
while (attributes && *attributes) {
! char *key = (char *)attributes[0];
! char *value = (char *)attributes[1];
! if (parser->case_folding) {
! key = _php3_strtolower(estrdup(key));
! }
! add_assoc_string(args[2], key, value, 1);
! if (parser->case_folding) {
! efree(key);
! }
attributes += 2;
}
if ((retval = xml_call_handler(parser, parser->startElementHandler, 3, args))) {
pval_destructor(retval);
efree(retval);
}
+ if (parser->case_folding) {
+ efree((char *)name);
+ }
}
}
***************
*** 513,524 ****
--- 532,549 ----
if (parser && parser->endElementHandler) {
pval *retval, *args[2];
+ if (parser->case_folding) {
+ name = _php3_strtolower(estrdup(name));
+ }
args[0] = php3i_longpval(parser->index);
args[1] = php3i_stringpval(name);
if ((retval = xml_call_handler(parser, parser->endElementHandler, 2, args))) {
pval_destructor(retval);
efree(retval);
}
+ if (parser->case_folding) {
+ efree((char *)name);
+ }
}
}
***************
*** 706,711 ****
--- 731,737 ----
id = php3_list_insert(parser, XML_GLOBAL(php3_xml_module).le_xml_parser);
parser = xml_get_parser(id, "XML_ParserCreate", list);
parser->index = id;
+ parser->case_folding = 1;
RETVAL_LONG(id);
}
***************
*** 919,925 ****
}
/* }}} */
! /* {{{ int XML_ErrorString(int code) */
PHP_FUNCTION(xml_errorstring)
{
--- 945,951 ----
}
/* }}} */
! /* {{{ string XML_ErrorString(int code) */
PHP_FUNCTION(xml_errorstring)
{
***************
*** 1013,1018 ****
--- 1039,1107 ----
RETURN_FALSE;
}
RETVAL_TRUE;
+ }
+
+ /* }}} */
+ /* {{{ int XML_ParserSetOption(int pind, int option, mixed value) */
+
+ PHP_FUNCTION(xml_parsersetoption)
+ {
+ xml_parser *parser;
+ pval *pind, *opt, *val;
+ char thisfunc[] = "XML_ParserSetOption";
+ XML_TLS_VARS;
+
+ if (ARG_COUNT(ht) != 3 || getParameters(ht, 3, &pind, &opt, &val) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long(pind);
+ convert_to_long(opt);
+ parser = xml_get_parser(pind->value.lval, thisfunc, list);
+ if (parser == NULL) {
+ RETURN_FALSE;
+ }
+ switch (opt->value.lval) {
+ case PHP3_XML_OPTION_CASE_FOLDING:
+ convert_to_long(val);
+ parser->case_folding = val->value.lval;
+ break;
+ default:
+ php3_error(E_WARNING, "%s: unknown option", thisfunc);
+ RETURN_FALSE;
+ break;
+ }
+ RETVAL_TRUE;
+ }
+
+ /* }}} */
+ /* {{{ int XML_ParserGetOption(int pind, int option) */
+
+ PHP_FUNCTION(xml_parsergetoption)
+ {
+ xml_parser *parser;
+ pval *pind, *opt;
+ char thisfunc[] = "XML_ParserGetOption";
+ XML_TLS_VARS;
+
+ if (ARG_COUNT(ht) != 2 || getParameters(ht, 2, &pind, &opt) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+ convert_to_long(pind);
+ convert_to_long(opt);
+ parser = xml_get_parser(pind->value.lval, thisfunc, list);
+ if (parser == NULL) {
+ RETURN_FALSE;
+ }
+ switch (opt->value.lval) {
+ case PHP3_XML_OPTION_CASE_FOLDING:
+ RETURN_LONG(parser->case_folding);
+ break;
+ default:
+ php3_error(E_WARNING, "%s: unknown option", thisfunc);
+ RETURN_FALSE;
+ break;
+ }
+ RETVAL_FALSE;
}
/* }}} */
-- PHP Development Mailing List http://www.php.net/ To unsubscribe send an empty message to php-dev-unsubscribe <email protected> For help: php-dev-help <email protected>
- Next message: bb26 <email protected>: "[PHP-DEV] Bug #863: PHP returns bad values for 'REAL' columns coming from sybase"
- Previous message: ssb: "[PHP-DEV] CVS update: php3/functions"
- Next in thread: ssb: "[PHP-DEV] CVS update: php3/functions"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

