mariadb/strings/xml.c

401 lines
8.6 KiB
C
Raw Normal View History

2003-01-10 13:34:53 +01:00
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "my_global.h"
#include "m_string.h"
#include "my_xml.h"
#define MY_XML_EOF 'E'
#define MY_XML_STRING 'S'
#define MY_XML_IDENT 'I'
#define MY_XML_EQ '='
#define MY_XML_LT '<'
#define MY_XML_GT '>'
#define MY_XML_SLASH '/'
#define MY_XML_COMMENT 'C'
#define MY_XML_TEXT 'T'
#define MY_XML_QUESTION '?'
#define MY_XML_EXCLAM '!'
typedef struct xml_attr_st
{
const char *beg;
const char *end;
} MY_XML_ATTR;
2003-01-10 13:34:53 +01:00
static const char *lex2str(int lex)
{
switch(lex)
{
case MY_XML_EOF: return "EOF";
case MY_XML_STRING: return "STRING";
case MY_XML_IDENT: return "IDENT";
case MY_XML_EQ: return "'='";
case MY_XML_LT: return "'<'";
case MY_XML_GT: return "'>'";
case MY_XML_SLASH: return "'/'";
case MY_XML_COMMENT: return "COMMENT";
case MY_XML_TEXT: return "TEXT";
case MY_XML_QUESTION: return "'?'";
case MY_XML_EXCLAM: return "'!'";
}
return "UNKNOWN";
}
static void my_xml_norm_text(MY_XML_ATTR *a)
{
for ( ; (a->beg < a->end) && strchr(" \t\r\n",a->beg[0]) ; a->beg++ );
for ( ; (a->beg < a->end) && strchr(" \t\r\n",a->end[-1]) ; a->end-- );
}
static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a)
{
int lex;
for( ; ( p->cur < p->end) && strchr(" \t\r\n",p->cur[0]) ; p->cur++);
if (p->cur >= p->end)
{
a->beg=p->end;
a->end=p->end;
lex=MY_XML_EOF;
goto ret;
}
a->beg=p->cur;
a->end=p->cur;
Review of all code pushed since last review Simple optimzations and cleanups Removed compiler warnings and fixed portability issues Added client functions 'mysql_embedded()' to allow client to check if we are using embedded server Fixes for purify client/mysqlimport.c: Remove not used variable client/mysqltest.c: Remove usage of MAXPATHLEN (all MySQL code uses FN_REFLEN) Simplified code Remove usage of sprintf("%llu") as this is not portable include/mysql.h: Added mysql_embedded() to be able to easily check if we are using the embedded server innobase/srv/srv0start.c: Don't use memcmp() when using purify (to avoid false warnings) libmysql/libmysql.c: Added mysql_embedded() to be able to easily check if we are using the embedded server libmysql/libmysql.def: Added mysql_embedded() to be able to easily check if we are using the embedded server myisam/myisam_ftdump.c: Remove compiler warning myisam/myisamchk.c: Remove compiler warning myisam/rt_test.c: #ifdef not used code mysys/hash.c: Remove compiler warning (from last push) mysys/my_gethwaddr.c: Remove compiler warning ndb/src/ndbapi/ndberror.c: #ifdef not used code regex/regcomp.c: Remove not used code regex/regcomp.ih: Remove not used code (to remove compiler warnings) sql-common/client.c: Remove compiler warnings sql/field.cc: Simple optimization sql/ha_innodb.cc: Rename mysql_embedded -> mysqld_embedded sql/item.cc: Fix comments Move variables first on block Remove else after return Simple optimizations (no logic changes) sql/item_cmpfunc.cc: Added comment sql/mysql_priv.h: Rename mysql_embedded -> mysqld_embedded sql/mysqld.cc: Rename mysql_embedded -> mysqld_embedded sql/sql_acl.cc: Added comments simple optimization Fixed 'very unlikely' bug when doing REVOKE ALL PRIVILEGES sql/sql_select.cc: More comments Simple optimization sql/sql_show.cc: Simple changes to make similar code similar More comments sql/sql_string.cc: Trivial optimization and better code layout strings/Makefile.am: Change xml.c to use bcmp to avoid warnings from purify strings/xml.c: Change xml.c to use bcmp to avoid warnings from purify tests/client_test.c: Remove usage of MAXPATHLEN (all MySQL code uses FN_REFLEN)
2004-10-20 00:28:42 +02:00
if (!bcmp(p->cur,"<!--",4))
2003-01-10 13:34:53 +01:00
{
Review of all code pushed since last review Simple optimzations and cleanups Removed compiler warnings and fixed portability issues Added client functions 'mysql_embedded()' to allow client to check if we are using embedded server Fixes for purify client/mysqlimport.c: Remove not used variable client/mysqltest.c: Remove usage of MAXPATHLEN (all MySQL code uses FN_REFLEN) Simplified code Remove usage of sprintf("%llu") as this is not portable include/mysql.h: Added mysql_embedded() to be able to easily check if we are using the embedded server innobase/srv/srv0start.c: Don't use memcmp() when using purify (to avoid false warnings) libmysql/libmysql.c: Added mysql_embedded() to be able to easily check if we are using the embedded server libmysql/libmysql.def: Added mysql_embedded() to be able to easily check if we are using the embedded server myisam/myisam_ftdump.c: Remove compiler warning myisam/myisamchk.c: Remove compiler warning myisam/rt_test.c: #ifdef not used code mysys/hash.c: Remove compiler warning (from last push) mysys/my_gethwaddr.c: Remove compiler warning ndb/src/ndbapi/ndberror.c: #ifdef not used code regex/regcomp.c: Remove not used code regex/regcomp.ih: Remove not used code (to remove compiler warnings) sql-common/client.c: Remove compiler warnings sql/field.cc: Simple optimization sql/ha_innodb.cc: Rename mysql_embedded -> mysqld_embedded sql/item.cc: Fix comments Move variables first on block Remove else after return Simple optimizations (no logic changes) sql/item_cmpfunc.cc: Added comment sql/mysql_priv.h: Rename mysql_embedded -> mysqld_embedded sql/mysqld.cc: Rename mysql_embedded -> mysqld_embedded sql/sql_acl.cc: Added comments simple optimization Fixed 'very unlikely' bug when doing REVOKE ALL PRIVILEGES sql/sql_select.cc: More comments Simple optimization sql/sql_show.cc: Simple changes to make similar code similar More comments sql/sql_string.cc: Trivial optimization and better code layout strings/Makefile.am: Change xml.c to use bcmp to avoid warnings from purify strings/xml.c: Change xml.c to use bcmp to avoid warnings from purify tests/client_test.c: Remove usage of MAXPATHLEN (all MySQL code uses FN_REFLEN)
2004-10-20 00:28:42 +02:00
for( ; (p->cur < p->end) && bcmp(p->cur, "-->", 3); p->cur++)
{}
if (!bcmp(p->cur, "-->", 3))
2003-01-10 13:34:53 +01:00
p->cur+=3;
a->end=p->cur;
lex=MY_XML_COMMENT;
}
else if (strchr("?=/<>!",p->cur[0]))
{
p->cur++;
a->end=p->cur;
lex=a->beg[0];
}
else if ( (p->cur[0]=='"') || (p->cur[0]=='\'') )
{
p->cur++;
for( ; ( p->cur < p->end ) && (p->cur[0] != a->beg[0]); p->cur++)
{}
2003-01-10 13:34:53 +01:00
a->end=p->cur;
if (a->beg[0]==p->cur[0])p->cur++;
a->beg++;
my_xml_norm_text(a);
lex=MY_XML_STRING;
}
else
{
for(;
(p->cur < p->end) && !strchr("?'\"=/<> \t\r\n", p->cur[0]);
p->cur++)
{}
2003-01-10 13:34:53 +01:00
a->end=p->cur;
my_xml_norm_text(a);
lex=MY_XML_IDENT;
}
#if 0
printf("LEX=%s[%d]\n",lex2str(lex),a->end-a->beg);
#endif
ret:
return lex;
}
static int my_xml_value(MY_XML_PARSER *st, const char *str, uint len)
{
return (st->value) ? (st->value)(st,str,len) : MY_XML_OK;
}
static int my_xml_enter(MY_XML_PARSER *st, const char *str, uint len)
{
After merge fixes config/ac-macros/character_sets.m4: Added latin1_spanish_ci dbug/dbug_analyze.c: Remove compiler warnings include/my_handler.h: Reorder structure arguments to be more optimal innobase/dict/dict0load.c: Fixed wrong define tag (for MySQL 5.0) innobase/fil/fil0fil.c: Fixed compiler warning innobase/os/os0file.c: Fixed compiler warning myisam/ft_boolean_search.c: Fixed compiler warning myisam/ft_static.c: Update to use new HA_KEYSEG structure myisam/mi_open.c: Simple optimization myisammrg/myrg_static.c: Removed compiler warning mysql-test/r/grant.result: Update results after merge mysql-test/r/index_merge.result: Update results after merge mysql-test/r/information_schema_inno.result: Add missing drop table mysql-test/r/lowercase_table.result: safety fix mysql-test/r/multi_update.result: safety fix mysql-test/r/ps_1general.result: safety fix mysql-test/r/ps_2myisam.result: Update results after merge (set is not anymore of binary type) mysql-test/r/ps_3innodb.result: Update results after merge mysql-test/r/ps_4heap.result: Update results after merge mysql-test/r/ps_5merge.result: Update results after merge mysql-test/r/ps_6bdb.result: Update results after merge mysql-test/r/show_check.result: Update results after merge mysql-test/r/subselect.result: Update results after merge (added missing quotes) mysql-test/r/timezone2.result: Update results after merge mysql-test/r/view.result: Update results after merge (note that INSERT IGNORE will work again after next merge from 4.1) mysql-test/t/derived.test: Removed empty line mysql-test/t/grant.test: Update results after merge mysql-test/t/information_schema_inno.test: added missing drop table mysql-test/t/lowercase_table.test: safety fix mysql-test/t/multi_update.test: safety fix mysql-test/t/ps_1general.test: safety fix mysql-test/t/view.test: update error codes after merge ndb/src/mgmsrv/main.cpp: after merge fix ndb/tools/ndb_test_platform.cpp: removed compiler warnings regex/main.c: remove compiler warnings sql/field.cc: Remove compiler warning sql/gen_lex_hash.cc: Added DBUG support sql/ha_myisam.cc: Removed warning from valgrind sql/ha_ndbcluster.cc: Remove compiler warning sql/item_cmpfunc.cc: Better to use val_int() instead of val_real() as we don't want Item_func_nop_all to return different value than the original ref element sql/mysqld.cc: Remove compiler warning sql/sql_acl.cc: More debugging sql/sql_lex.cc: Remove unnecessary 'else' sql/sql_parse.cc: After merge fixes Simplify reset of thd->server_status for SQLCOM_CALL sql/sql_prepare.cc: After merge fixes Removed possible core dump in mysql_stmt_fetch() sql/sql_update.cc: After merge fixes (together with Sanja) strings/ctype-czech.c: Remove compiler warning strings/ctype-ucs2.c: Remove compiler warning strings/ctype-win1250ch.c: Remove compiler warning strings/xml.c: Remove compiler warning tests/client_test.c: Fix test to work with 5.0 vio/test-sslserver.c: Portability fix
2004-12-30 23:44:00 +01:00
if ((uint) (st->attrend-st->attr+len+1) > sizeof(st->attr))
2003-01-10 13:34:53 +01:00
{
sprintf(st->errstr,"To deep XML");
return MY_XML_ERROR;
}
if (st->attrend > st->attr)
{
st->attrend[0]='.';
st->attrend++;
}
memcpy(st->attrend,str,len);
st->attrend+=len;
st->attrend[0]='\0';
fixes for windows 64-bit compiler warnings heap/hp_hash.c: fix for windows 64-bit compiler warnings heap/hp_update.c: fix for windows 64-bit compiler warnings mysys/default.c: fix for windows 64-bit compiler warnings mysys/default_modify.c: fix for windows 64-bit compiler warnings mysys/mf_iocache.c: fix for windows 64-bit compiler warnings mysys/mf_keycache.c: fix for windows 64-bit compiler warnings mysys/my_alloc.c: fix for windows 64-bit compiler warnings mysys/my_getopt.c: fix for windows 64-bit compiler warnings mysys/my_mmap.c: fix for windows 64-bit compiler warnings mysys/my_once.c: fix for windows 64-bit compiler warnings mysys/string.c: fix for windows 64-bit compiler warnings sql-common/client.c: fix for windows 64-bit compiler warnings sql/field.cc: fix for windows 64-bit compiler warnings sql/gstream.cc: fix for windows 64-bit compiler warnings sql/ha_myisam.cc: fix for windows 64-bit compiler warnings sql/ha_myisammrg.cc: fix for windows 64-bit compiler warnings sql/item.cc: fix for windows 64-bit compiler warnings sql/item.h: fix for windows 64-bit compiler warnings sql/item_cmpfunc.cc: fix for windows 64-bit compiler warnings sql/password.c: fix for windows 64-bit compiler warnings sql/set_var.h: fix for windows 64-bit compiler warnings strings/ctype-big5.c: fix for windows 64-bit compiler warnings strings/ctype-bin.c: fix for windows 64-bit compiler warnings strings/ctype-cp932.c: fix for windows 64-bit compiler warnings strings/ctype-eucjpms.c: fix for windows 64-bit compiler warnings strings/ctype-mb.c: fix for windows 64-bit compiler warnings strings/ctype-simple.c: fix for windows 64-bit compiler warnings strings/ctype-sjis.c: fix for windows 64-bit compiler warnings strings/ctype-uca.c: fix for windows 64-bit compiler warnings strings/ctype-ucs2.c: fix for windows 64-bit compiler warnings strings/ctype-ujis.c: fix for windows 64-bit compiler warnings strings/ctype-utf8.c: fix for windows 64-bit compiler warnings strings/ctype.c: fix for windows 64-bit compiler warnings strings/decimal.c: fix for windows 64-bit compiler warnings strings/xml.c: fix for windows 64-bit compiler warnings
2005-06-13 12:41:15 +02:00
return st->enter ? st->enter(st,st->attr,st->attrend-st->attr) : MY_XML_OK;
2003-01-10 13:34:53 +01:00
}
2003-01-10 13:34:53 +01:00
static void mstr(char *s,const char *src,uint l1, uint l2)
{
l1 = l1<l2 ? l1 : l2;
memcpy(s,src,l1);
s[l1]='\0';
}
2003-01-10 13:34:53 +01:00
static int my_xml_leave(MY_XML_PARSER *p, const char *str, uint slen)
{
char *e;
uint glen;
char s[32];
char g[32];
int rc;
/* Find previous '.' or beginning */
for( e=p->attrend; (e>p->attr) && (e[0]!='.') ; e--);
fixes for windows 64-bit compiler warnings heap/hp_hash.c: fix for windows 64-bit compiler warnings heap/hp_update.c: fix for windows 64-bit compiler warnings mysys/default.c: fix for windows 64-bit compiler warnings mysys/default_modify.c: fix for windows 64-bit compiler warnings mysys/mf_iocache.c: fix for windows 64-bit compiler warnings mysys/mf_keycache.c: fix for windows 64-bit compiler warnings mysys/my_alloc.c: fix for windows 64-bit compiler warnings mysys/my_getopt.c: fix for windows 64-bit compiler warnings mysys/my_mmap.c: fix for windows 64-bit compiler warnings mysys/my_once.c: fix for windows 64-bit compiler warnings mysys/string.c: fix for windows 64-bit compiler warnings sql-common/client.c: fix for windows 64-bit compiler warnings sql/field.cc: fix for windows 64-bit compiler warnings sql/gstream.cc: fix for windows 64-bit compiler warnings sql/ha_myisam.cc: fix for windows 64-bit compiler warnings sql/ha_myisammrg.cc: fix for windows 64-bit compiler warnings sql/item.cc: fix for windows 64-bit compiler warnings sql/item.h: fix for windows 64-bit compiler warnings sql/item_cmpfunc.cc: fix for windows 64-bit compiler warnings sql/password.c: fix for windows 64-bit compiler warnings sql/set_var.h: fix for windows 64-bit compiler warnings strings/ctype-big5.c: fix for windows 64-bit compiler warnings strings/ctype-bin.c: fix for windows 64-bit compiler warnings strings/ctype-cp932.c: fix for windows 64-bit compiler warnings strings/ctype-eucjpms.c: fix for windows 64-bit compiler warnings strings/ctype-mb.c: fix for windows 64-bit compiler warnings strings/ctype-simple.c: fix for windows 64-bit compiler warnings strings/ctype-sjis.c: fix for windows 64-bit compiler warnings strings/ctype-uca.c: fix for windows 64-bit compiler warnings strings/ctype-ucs2.c: fix for windows 64-bit compiler warnings strings/ctype-ujis.c: fix for windows 64-bit compiler warnings strings/ctype-utf8.c: fix for windows 64-bit compiler warnings strings/ctype.c: fix for windows 64-bit compiler warnings strings/decimal.c: fix for windows 64-bit compiler warnings strings/xml.c: fix for windows 64-bit compiler warnings
2005-06-13 12:41:15 +02:00
glen = (uint) ((e[0]=='.') ? (p->attrend-e-1) : p->attrend-e);
2003-01-10 13:34:53 +01:00
if (str && (slen != glen))
{
mstr(s,str,sizeof(s)-1,slen);
mstr(g,e+1,sizeof(g)-1,glen),
sprintf(p->errstr,"'</%s>' unexpected ('</%s>' wanted)",s,g);
return MY_XML_ERROR;
}
fixes for windows 64-bit compiler warnings heap/hp_hash.c: fix for windows 64-bit compiler warnings heap/hp_update.c: fix for windows 64-bit compiler warnings mysys/default.c: fix for windows 64-bit compiler warnings mysys/default_modify.c: fix for windows 64-bit compiler warnings mysys/mf_iocache.c: fix for windows 64-bit compiler warnings mysys/mf_keycache.c: fix for windows 64-bit compiler warnings mysys/my_alloc.c: fix for windows 64-bit compiler warnings mysys/my_getopt.c: fix for windows 64-bit compiler warnings mysys/my_mmap.c: fix for windows 64-bit compiler warnings mysys/my_once.c: fix for windows 64-bit compiler warnings mysys/string.c: fix for windows 64-bit compiler warnings sql-common/client.c: fix for windows 64-bit compiler warnings sql/field.cc: fix for windows 64-bit compiler warnings sql/gstream.cc: fix for windows 64-bit compiler warnings sql/ha_myisam.cc: fix for windows 64-bit compiler warnings sql/ha_myisammrg.cc: fix for windows 64-bit compiler warnings sql/item.cc: fix for windows 64-bit compiler warnings sql/item.h: fix for windows 64-bit compiler warnings sql/item_cmpfunc.cc: fix for windows 64-bit compiler warnings sql/password.c: fix for windows 64-bit compiler warnings sql/set_var.h: fix for windows 64-bit compiler warnings strings/ctype-big5.c: fix for windows 64-bit compiler warnings strings/ctype-bin.c: fix for windows 64-bit compiler warnings strings/ctype-cp932.c: fix for windows 64-bit compiler warnings strings/ctype-eucjpms.c: fix for windows 64-bit compiler warnings strings/ctype-mb.c: fix for windows 64-bit compiler warnings strings/ctype-simple.c: fix for windows 64-bit compiler warnings strings/ctype-sjis.c: fix for windows 64-bit compiler warnings strings/ctype-uca.c: fix for windows 64-bit compiler warnings strings/ctype-ucs2.c: fix for windows 64-bit compiler warnings strings/ctype-ujis.c: fix for windows 64-bit compiler warnings strings/ctype-utf8.c: fix for windows 64-bit compiler warnings strings/ctype.c: fix for windows 64-bit compiler warnings strings/decimal.c: fix for windows 64-bit compiler warnings strings/xml.c: fix for windows 64-bit compiler warnings
2005-06-13 12:41:15 +02:00
rc = p->leave_xml ? p->leave_xml(p,p->attr,p->attrend-p->attr) : MY_XML_OK;
2003-01-10 13:34:53 +01:00
*e='\0';
p->attrend=e;
return rc;
}
int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len)
{
p->attrend=p->attr;
p->beg=str;
p->cur=str;
p->end=str+len;
while ( p->cur < p->end )
{
MY_XML_ATTR a;
if(p->cur[0]=='<')
{
int lex;
int question=0;
int exclam=0;
lex=my_xml_scan(p,&a);
if (MY_XML_COMMENT==lex)
{
continue;
}
lex=my_xml_scan(p,&a);
if (MY_XML_SLASH==lex)
{
if(MY_XML_IDENT!=(lex=my_xml_scan(p,&a)))
{
sprintf(p->errstr,"1: %s unexpected (ident wanted)",lex2str(lex));
return MY_XML_ERROR;
}
fixes for windows 64-bit compiler warnings heap/hp_hash.c: fix for windows 64-bit compiler warnings heap/hp_update.c: fix for windows 64-bit compiler warnings mysys/default.c: fix for windows 64-bit compiler warnings mysys/default_modify.c: fix for windows 64-bit compiler warnings mysys/mf_iocache.c: fix for windows 64-bit compiler warnings mysys/mf_keycache.c: fix for windows 64-bit compiler warnings mysys/my_alloc.c: fix for windows 64-bit compiler warnings mysys/my_getopt.c: fix for windows 64-bit compiler warnings mysys/my_mmap.c: fix for windows 64-bit compiler warnings mysys/my_once.c: fix for windows 64-bit compiler warnings mysys/string.c: fix for windows 64-bit compiler warnings sql-common/client.c: fix for windows 64-bit compiler warnings sql/field.cc: fix for windows 64-bit compiler warnings sql/gstream.cc: fix for windows 64-bit compiler warnings sql/ha_myisam.cc: fix for windows 64-bit compiler warnings sql/ha_myisammrg.cc: fix for windows 64-bit compiler warnings sql/item.cc: fix for windows 64-bit compiler warnings sql/item.h: fix for windows 64-bit compiler warnings sql/item_cmpfunc.cc: fix for windows 64-bit compiler warnings sql/password.c: fix for windows 64-bit compiler warnings sql/set_var.h: fix for windows 64-bit compiler warnings strings/ctype-big5.c: fix for windows 64-bit compiler warnings strings/ctype-bin.c: fix for windows 64-bit compiler warnings strings/ctype-cp932.c: fix for windows 64-bit compiler warnings strings/ctype-eucjpms.c: fix for windows 64-bit compiler warnings strings/ctype-mb.c: fix for windows 64-bit compiler warnings strings/ctype-simple.c: fix for windows 64-bit compiler warnings strings/ctype-sjis.c: fix for windows 64-bit compiler warnings strings/ctype-uca.c: fix for windows 64-bit compiler warnings strings/ctype-ucs2.c: fix for windows 64-bit compiler warnings strings/ctype-ujis.c: fix for windows 64-bit compiler warnings strings/ctype-utf8.c: fix for windows 64-bit compiler warnings strings/ctype.c: fix for windows 64-bit compiler warnings strings/decimal.c: fix for windows 64-bit compiler warnings strings/xml.c: fix for windows 64-bit compiler warnings
2005-06-13 12:41:15 +02:00
if(MY_XML_OK!=my_xml_leave(p,a.beg,(uint) (a.end-a.beg)))
2003-01-10 13:34:53 +01:00
return MY_XML_ERROR;
lex=my_xml_scan(p,&a);
goto gt;
}
if (MY_XML_EXCLAM==lex)
{
lex=my_xml_scan(p,&a);
exclam=1;
}
else if (MY_XML_QUESTION==lex)
{
lex=my_xml_scan(p,&a);
question=1;
}
if (MY_XML_IDENT==lex)
{
fixes for windows 64-bit compiler warnings heap/hp_hash.c: fix for windows 64-bit compiler warnings heap/hp_update.c: fix for windows 64-bit compiler warnings mysys/default.c: fix for windows 64-bit compiler warnings mysys/default_modify.c: fix for windows 64-bit compiler warnings mysys/mf_iocache.c: fix for windows 64-bit compiler warnings mysys/mf_keycache.c: fix for windows 64-bit compiler warnings mysys/my_alloc.c: fix for windows 64-bit compiler warnings mysys/my_getopt.c: fix for windows 64-bit compiler warnings mysys/my_mmap.c: fix for windows 64-bit compiler warnings mysys/my_once.c: fix for windows 64-bit compiler warnings mysys/string.c: fix for windows 64-bit compiler warnings sql-common/client.c: fix for windows 64-bit compiler warnings sql/field.cc: fix for windows 64-bit compiler warnings sql/gstream.cc: fix for windows 64-bit compiler warnings sql/ha_myisam.cc: fix for windows 64-bit compiler warnings sql/ha_myisammrg.cc: fix for windows 64-bit compiler warnings sql/item.cc: fix for windows 64-bit compiler warnings sql/item.h: fix for windows 64-bit compiler warnings sql/item_cmpfunc.cc: fix for windows 64-bit compiler warnings sql/password.c: fix for windows 64-bit compiler warnings sql/set_var.h: fix for windows 64-bit compiler warnings strings/ctype-big5.c: fix for windows 64-bit compiler warnings strings/ctype-bin.c: fix for windows 64-bit compiler warnings strings/ctype-cp932.c: fix for windows 64-bit compiler warnings strings/ctype-eucjpms.c: fix for windows 64-bit compiler warnings strings/ctype-mb.c: fix for windows 64-bit compiler warnings strings/ctype-simple.c: fix for windows 64-bit compiler warnings strings/ctype-sjis.c: fix for windows 64-bit compiler warnings strings/ctype-uca.c: fix for windows 64-bit compiler warnings strings/ctype-ucs2.c: fix for windows 64-bit compiler warnings strings/ctype-ujis.c: fix for windows 64-bit compiler warnings strings/ctype-utf8.c: fix for windows 64-bit compiler warnings strings/ctype.c: fix for windows 64-bit compiler warnings strings/decimal.c: fix for windows 64-bit compiler warnings strings/xml.c: fix for windows 64-bit compiler warnings
2005-06-13 12:41:15 +02:00
if(MY_XML_OK!=my_xml_enter(p,a.beg,(uint) (a.end-a.beg)))
2003-01-10 13:34:53 +01:00
return MY_XML_ERROR;
}
else
{
sprintf(p->errstr,"3: %s unexpected (ident or '/' wanted)",
lex2str(lex));
2003-01-10 13:34:53 +01:00
return MY_XML_ERROR;
}
while ((MY_XML_IDENT==(lex=my_xml_scan(p,&a))) || (MY_XML_STRING==lex))
{
MY_XML_ATTR b;
if(MY_XML_EQ==(lex=my_xml_scan(p,&b)))
{
lex=my_xml_scan(p,&b);
2003-09-22 08:26:14 +02:00
if ( (lex==MY_XML_IDENT) || (lex==MY_XML_STRING) )
2003-01-10 13:34:53 +01:00
{
fixes for windows 64-bit compiler warnings heap/hp_hash.c: fix for windows 64-bit compiler warnings heap/hp_update.c: fix for windows 64-bit compiler warnings mysys/default.c: fix for windows 64-bit compiler warnings mysys/default_modify.c: fix for windows 64-bit compiler warnings mysys/mf_iocache.c: fix for windows 64-bit compiler warnings mysys/mf_keycache.c: fix for windows 64-bit compiler warnings mysys/my_alloc.c: fix for windows 64-bit compiler warnings mysys/my_getopt.c: fix for windows 64-bit compiler warnings mysys/my_mmap.c: fix for windows 64-bit compiler warnings mysys/my_once.c: fix for windows 64-bit compiler warnings mysys/string.c: fix for windows 64-bit compiler warnings sql-common/client.c: fix for windows 64-bit compiler warnings sql/field.cc: fix for windows 64-bit compiler warnings sql/gstream.cc: fix for windows 64-bit compiler warnings sql/ha_myisam.cc: fix for windows 64-bit compiler warnings sql/ha_myisammrg.cc: fix for windows 64-bit compiler warnings sql/item.cc: fix for windows 64-bit compiler warnings sql/item.h: fix for windows 64-bit compiler warnings sql/item_cmpfunc.cc: fix for windows 64-bit compiler warnings sql/password.c: fix for windows 64-bit compiler warnings sql/set_var.h: fix for windows 64-bit compiler warnings strings/ctype-big5.c: fix for windows 64-bit compiler warnings strings/ctype-bin.c: fix for windows 64-bit compiler warnings strings/ctype-cp932.c: fix for windows 64-bit compiler warnings strings/ctype-eucjpms.c: fix for windows 64-bit compiler warnings strings/ctype-mb.c: fix for windows 64-bit compiler warnings strings/ctype-simple.c: fix for windows 64-bit compiler warnings strings/ctype-sjis.c: fix for windows 64-bit compiler warnings strings/ctype-uca.c: fix for windows 64-bit compiler warnings strings/ctype-ucs2.c: fix for windows 64-bit compiler warnings strings/ctype-ujis.c: fix for windows 64-bit compiler warnings strings/ctype-utf8.c: fix for windows 64-bit compiler warnings strings/ctype.c: fix for windows 64-bit compiler warnings strings/decimal.c: fix for windows 64-bit compiler warnings strings/xml.c: fix for windows 64-bit compiler warnings
2005-06-13 12:41:15 +02:00
if((MY_XML_OK!=my_xml_enter(p,a.beg,(uint) (a.end-a.beg))) ||
(MY_XML_OK!=my_xml_value(p,b.beg,(uint) (b.end-b.beg))) ||
(MY_XML_OK!=my_xml_leave(p,a.beg,(uint) (a.end-a.beg))))
2003-01-10 13:34:53 +01:00
return MY_XML_ERROR;
}
else
{
sprintf(p->errstr,"4: %s unexpected (ident or string wanted)",
lex2str(lex));
2003-01-10 13:34:53 +01:00
return MY_XML_ERROR;
}
}
else if ( (MY_XML_STRING==lex) || (MY_XML_IDENT==lex) )
{
fixes for windows 64-bit compiler warnings heap/hp_hash.c: fix for windows 64-bit compiler warnings heap/hp_update.c: fix for windows 64-bit compiler warnings mysys/default.c: fix for windows 64-bit compiler warnings mysys/default_modify.c: fix for windows 64-bit compiler warnings mysys/mf_iocache.c: fix for windows 64-bit compiler warnings mysys/mf_keycache.c: fix for windows 64-bit compiler warnings mysys/my_alloc.c: fix for windows 64-bit compiler warnings mysys/my_getopt.c: fix for windows 64-bit compiler warnings mysys/my_mmap.c: fix for windows 64-bit compiler warnings mysys/my_once.c: fix for windows 64-bit compiler warnings mysys/string.c: fix for windows 64-bit compiler warnings sql-common/client.c: fix for windows 64-bit compiler warnings sql/field.cc: fix for windows 64-bit compiler warnings sql/gstream.cc: fix for windows 64-bit compiler warnings sql/ha_myisam.cc: fix for windows 64-bit compiler warnings sql/ha_myisammrg.cc: fix for windows 64-bit compiler warnings sql/item.cc: fix for windows 64-bit compiler warnings sql/item.h: fix for windows 64-bit compiler warnings sql/item_cmpfunc.cc: fix for windows 64-bit compiler warnings sql/password.c: fix for windows 64-bit compiler warnings sql/set_var.h: fix for windows 64-bit compiler warnings strings/ctype-big5.c: fix for windows 64-bit compiler warnings strings/ctype-bin.c: fix for windows 64-bit compiler warnings strings/ctype-cp932.c: fix for windows 64-bit compiler warnings strings/ctype-eucjpms.c: fix for windows 64-bit compiler warnings strings/ctype-mb.c: fix for windows 64-bit compiler warnings strings/ctype-simple.c: fix for windows 64-bit compiler warnings strings/ctype-sjis.c: fix for windows 64-bit compiler warnings strings/ctype-uca.c: fix for windows 64-bit compiler warnings strings/ctype-ucs2.c: fix for windows 64-bit compiler warnings strings/ctype-ujis.c: fix for windows 64-bit compiler warnings strings/ctype-utf8.c: fix for windows 64-bit compiler warnings strings/ctype.c: fix for windows 64-bit compiler warnings strings/decimal.c: fix for windows 64-bit compiler warnings strings/xml.c: fix for windows 64-bit compiler warnings
2005-06-13 12:41:15 +02:00
if((MY_XML_OK!=my_xml_enter(p,a.beg,(uint) (a.end-a.beg))) ||
(MY_XML_OK!=my_xml_leave(p,a.beg,(uint) (a.end-a.beg))))
2003-01-10 13:34:53 +01:00
return MY_XML_ERROR;
}
else
break;
}
if (lex==MY_XML_SLASH)
{
if(MY_XML_OK!=my_xml_leave(p,NULL,0))
return MY_XML_ERROR;
lex=my_xml_scan(p,&a);
}
gt:
if (question)
{
if (lex!=MY_XML_QUESTION)
{
sprintf(p->errstr,"6: %s unexpected ('?' wanted)",lex2str(lex));
return MY_XML_ERROR;
}
if(MY_XML_OK!=my_xml_leave(p,NULL,0))
return MY_XML_ERROR;
lex=my_xml_scan(p,&a);
}
if (exclam)
{
if(MY_XML_OK!=my_xml_leave(p,NULL,0))
return MY_XML_ERROR;
}
if (lex!=MY_XML_GT)
{
sprintf(p->errstr,"5: %s unexpected ('>' wanted)",lex2str(lex));
return MY_XML_ERROR;
}
}
else
{
a.beg=p->cur;
for ( ; (p->cur < p->end) && (p->cur[0]!='<') ; p->cur++);
a.end=p->cur;
my_xml_norm_text(&a);
if (a.beg!=a.end)
{
fixes for windows 64-bit compiler warnings heap/hp_hash.c: fix for windows 64-bit compiler warnings heap/hp_update.c: fix for windows 64-bit compiler warnings mysys/default.c: fix for windows 64-bit compiler warnings mysys/default_modify.c: fix for windows 64-bit compiler warnings mysys/mf_iocache.c: fix for windows 64-bit compiler warnings mysys/mf_keycache.c: fix for windows 64-bit compiler warnings mysys/my_alloc.c: fix for windows 64-bit compiler warnings mysys/my_getopt.c: fix for windows 64-bit compiler warnings mysys/my_mmap.c: fix for windows 64-bit compiler warnings mysys/my_once.c: fix for windows 64-bit compiler warnings mysys/string.c: fix for windows 64-bit compiler warnings sql-common/client.c: fix for windows 64-bit compiler warnings sql/field.cc: fix for windows 64-bit compiler warnings sql/gstream.cc: fix for windows 64-bit compiler warnings sql/ha_myisam.cc: fix for windows 64-bit compiler warnings sql/ha_myisammrg.cc: fix for windows 64-bit compiler warnings sql/item.cc: fix for windows 64-bit compiler warnings sql/item.h: fix for windows 64-bit compiler warnings sql/item_cmpfunc.cc: fix for windows 64-bit compiler warnings sql/password.c: fix for windows 64-bit compiler warnings sql/set_var.h: fix for windows 64-bit compiler warnings strings/ctype-big5.c: fix for windows 64-bit compiler warnings strings/ctype-bin.c: fix for windows 64-bit compiler warnings strings/ctype-cp932.c: fix for windows 64-bit compiler warnings strings/ctype-eucjpms.c: fix for windows 64-bit compiler warnings strings/ctype-mb.c: fix for windows 64-bit compiler warnings strings/ctype-simple.c: fix for windows 64-bit compiler warnings strings/ctype-sjis.c: fix for windows 64-bit compiler warnings strings/ctype-uca.c: fix for windows 64-bit compiler warnings strings/ctype-ucs2.c: fix for windows 64-bit compiler warnings strings/ctype-ujis.c: fix for windows 64-bit compiler warnings strings/ctype-utf8.c: fix for windows 64-bit compiler warnings strings/ctype.c: fix for windows 64-bit compiler warnings strings/decimal.c: fix for windows 64-bit compiler warnings strings/xml.c: fix for windows 64-bit compiler warnings
2005-06-13 12:41:15 +02:00
my_xml_value(p,a.beg,(uint) (a.end-a.beg));
2003-01-10 13:34:53 +01:00
}
}
}
return MY_XML_OK;
}
2003-01-10 13:34:53 +01:00
void my_xml_parser_create(MY_XML_PARSER *p)
{
bzero((void*)p,sizeof(p[0]));
}
2003-01-10 13:34:53 +01:00
void my_xml_parser_free(MY_XML_PARSER *p __attribute__((unused)))
{
}
void my_xml_set_value_handler(MY_XML_PARSER *p,
int (*action)(MY_XML_PARSER *p, const char *s,
uint l))
2003-01-10 13:34:53 +01:00
{
p->value=action;
}
void my_xml_set_enter_handler(MY_XML_PARSER *p,
int (*action)(MY_XML_PARSER *p, const char *s,
uint l))
2003-01-10 13:34:53 +01:00
{
p->enter=action;
}
void my_xml_set_leave_handler(MY_XML_PARSER *p,
int (*action)(MY_XML_PARSER *p, const char *s,
uint l))
2003-01-10 13:34:53 +01:00
{
p->leave_xml=action;
2003-01-10 13:34:53 +01:00
}
2003-01-10 13:34:53 +01:00
void my_xml_set_user_data(MY_XML_PARSER *p, void *user_data)
{
p->user_data=user_data;
}
2003-01-10 13:34:53 +01:00
const char *my_xml_error_string(MY_XML_PARSER *p)
{
return p->errstr;
}
uint my_xml_error_pos(MY_XML_PARSER *p)
{
const char *beg=p->beg;
const char *s;
for ( s=p->beg ; s<p->cur; s++)
{
2003-01-10 13:34:53 +01:00
if (s[0]=='\n')
beg=s;
}
fixes for windows 64-bit compiler warnings heap/hp_hash.c: fix for windows 64-bit compiler warnings heap/hp_update.c: fix for windows 64-bit compiler warnings mysys/default.c: fix for windows 64-bit compiler warnings mysys/default_modify.c: fix for windows 64-bit compiler warnings mysys/mf_iocache.c: fix for windows 64-bit compiler warnings mysys/mf_keycache.c: fix for windows 64-bit compiler warnings mysys/my_alloc.c: fix for windows 64-bit compiler warnings mysys/my_getopt.c: fix for windows 64-bit compiler warnings mysys/my_mmap.c: fix for windows 64-bit compiler warnings mysys/my_once.c: fix for windows 64-bit compiler warnings mysys/string.c: fix for windows 64-bit compiler warnings sql-common/client.c: fix for windows 64-bit compiler warnings sql/field.cc: fix for windows 64-bit compiler warnings sql/gstream.cc: fix for windows 64-bit compiler warnings sql/ha_myisam.cc: fix for windows 64-bit compiler warnings sql/ha_myisammrg.cc: fix for windows 64-bit compiler warnings sql/item.cc: fix for windows 64-bit compiler warnings sql/item.h: fix for windows 64-bit compiler warnings sql/item_cmpfunc.cc: fix for windows 64-bit compiler warnings sql/password.c: fix for windows 64-bit compiler warnings sql/set_var.h: fix for windows 64-bit compiler warnings strings/ctype-big5.c: fix for windows 64-bit compiler warnings strings/ctype-bin.c: fix for windows 64-bit compiler warnings strings/ctype-cp932.c: fix for windows 64-bit compiler warnings strings/ctype-eucjpms.c: fix for windows 64-bit compiler warnings strings/ctype-mb.c: fix for windows 64-bit compiler warnings strings/ctype-simple.c: fix for windows 64-bit compiler warnings strings/ctype-sjis.c: fix for windows 64-bit compiler warnings strings/ctype-uca.c: fix for windows 64-bit compiler warnings strings/ctype-ucs2.c: fix for windows 64-bit compiler warnings strings/ctype-ujis.c: fix for windows 64-bit compiler warnings strings/ctype-utf8.c: fix for windows 64-bit compiler warnings strings/ctype.c: fix for windows 64-bit compiler warnings strings/decimal.c: fix for windows 64-bit compiler warnings strings/xml.c: fix for windows 64-bit compiler warnings
2005-06-13 12:41:15 +02:00
return (uint) (p->cur-beg);
2003-01-10 13:34:53 +01:00
}
uint my_xml_error_lineno(MY_XML_PARSER *p)
{
uint res=0;
const char *s;
for ( s=p->beg ; s<p->cur; s++)
{
2003-01-10 13:34:53 +01:00
if (s[0]=='\n')
res++;
}
2003-01-10 13:34:53 +01:00
return res;
}