From 0b8fd992860d74364073d4614e9b2ab334005d01 Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Tue, 9 Nov 2010 11:53:06 +0000 Subject: [PATCH] 2010-11-09 12:52 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/contrib/hbexpat/hbexpatc.c * harbour/contrib/hbexpat/hbexpatp.prg * harbour/contrib/hbexpat/hbexpat.hbp * harbour/contrib/hbexpat/hbexpat.ch * harbour/contrib/hbexpat/hbexpat.hbc * harbour/contrib/hbexpat/hbexpat.c * harbour/contrib/hbqt/tests/testres.prg * harbour/contrib/hbqt/qtuitools/hbqtuitools.hbm * harbour/contrib/hbqt/qtuitools/hbqtuitools.hbp * harbour/contrib/hbqt/qtuitools/hbqtuitools.hbc ! fixed hardcoded CRLF EOLs and set svn:eol-style=native * harbour/contrib/xhb/xhbarrex.c * harbour/contrib/hbexpat/hbexpatc.c * harbour/contrib/hbexpat/hbexpatp.prg * harbour/contrib/hbexpat/hbexpat.hbp * harbour/contrib/hbexpat/hbexpat.ch * harbour/contrib/hbexpat/hbexpat.hbc * harbour/contrib/hbexpat/hbexpat.c * harbour/contrib/hbqt/qtgui/hbqt_hbqabstractitemmodel.cpp * harbour/contrib/hbqt/qtgui/hbqt_init.cpp * harbour/contrib/hbqt/qtgui/hbqt_hbqabstractitemmodel.h * harbour/contrib/hbqt/qtgui/hbqt_hbqgraphicsscene.cpp * harbour/contrib/hbqt/qtgui/hbqt_hbqgraphicsitem.cpp * harbour/contrib/hbqt/qtgui/hbqt_hbqgraphicsscene.h * harbour/contrib/hbqt/qtgui/hbqt_hbqgraphicsitem.h * harbour/contrib/hbqt/qtwebkit/hbqtwebkit.hbm * harbour/contrib/hbqt/qtwebkit/hbqtwebkit.hbp * harbour/contrib/hbqt/qtcore/hbqt_hbqstring.cpp * harbour/contrib/hbqt/qtcore/hbqt_init.cpp * harbour/contrib/hbqt/qtcore/hbqt_hbqstring.h * harbour/contrib/hbqt/qtnetwork/hbqt_init.cpp * harbour/contrib/hbqt/tests/testres.prg * harbour/contrib/hbqt/tests/wvtqt.hbp * harbour/contrib/hbqt/tests/wvtqt.prg * harbour/contrib/hbqt/qtuitools/hbqtuitools.hbm * harbour/contrib/hbqt/qtuitools/hbqtuitools.hbp * harbour/contrib/hbqt/qtuitools/hbqtuitools.hbc * harbour/contrib/hbqt/qtdesigner/hbqtdesigner.hbm * harbour/contrib/hbqt/qtdesigner/hbqtdesigner.hbp * harbour/contrib/hbfship/fldarr.prg * harbour/contrib/hbfship/isbegseq.c * harbour/contrib/hbfship/isfunc.c * harbour/contrib/hbfship/isdb.prg * harbour/contrib/hbfship/flddeci.c * set svn:keywords="Author Date Id Revision" --- harbour/ChangeLog | 48 + harbour/contrib/hbexpat/hbexpat.c | 2440 ++++++++--------- harbour/contrib/hbexpat/hbexpat.ch | 226 +- harbour/contrib/hbexpat/hbexpat.hbc | 16 +- harbour/contrib/hbexpat/hbexpat.hbp | 54 +- harbour/contrib/hbexpat/hbexpatc.c | 144 +- harbour/contrib/hbexpat/hbexpatp.prg | 150 +- .../contrib/hbqt/qtuitools/hbqtuitools.hbc | 32 +- .../contrib/hbqt/qtuitools/hbqtuitools.hbm | 30 +- .../contrib/hbqt/qtuitools/hbqtuitools.hbp | 18 +- harbour/contrib/hbqt/tests/testres.prg | 110 +- 11 files changed, 1658 insertions(+), 1610 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 463c3086c4..9dab21e263 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,54 @@ The license applies to all entries newer than 2009-04-28. */ +2010-11-09 12:52 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/contrib/hbexpat/hbexpatc.c + * harbour/contrib/hbexpat/hbexpatp.prg + * harbour/contrib/hbexpat/hbexpat.hbp + * harbour/contrib/hbexpat/hbexpat.ch + * harbour/contrib/hbexpat/hbexpat.hbc + * harbour/contrib/hbexpat/hbexpat.c + * harbour/contrib/hbqt/tests/testres.prg + * harbour/contrib/hbqt/qtuitools/hbqtuitools.hbm + * harbour/contrib/hbqt/qtuitools/hbqtuitools.hbp + * harbour/contrib/hbqt/qtuitools/hbqtuitools.hbc + ! fixed hardcoded CRLF EOLs and set svn:eol-style=native + + * harbour/contrib/xhb/xhbarrex.c + * harbour/contrib/hbexpat/hbexpatc.c + * harbour/contrib/hbexpat/hbexpatp.prg + * harbour/contrib/hbexpat/hbexpat.hbp + * harbour/contrib/hbexpat/hbexpat.ch + * harbour/contrib/hbexpat/hbexpat.hbc + * harbour/contrib/hbexpat/hbexpat.c + * harbour/contrib/hbqt/qtgui/hbqt_hbqabstractitemmodel.cpp + * harbour/contrib/hbqt/qtgui/hbqt_init.cpp + * harbour/contrib/hbqt/qtgui/hbqt_hbqabstractitemmodel.h + * harbour/contrib/hbqt/qtgui/hbqt_hbqgraphicsscene.cpp + * harbour/contrib/hbqt/qtgui/hbqt_hbqgraphicsitem.cpp + * harbour/contrib/hbqt/qtgui/hbqt_hbqgraphicsscene.h + * harbour/contrib/hbqt/qtgui/hbqt_hbqgraphicsitem.h + * harbour/contrib/hbqt/qtwebkit/hbqtwebkit.hbm + * harbour/contrib/hbqt/qtwebkit/hbqtwebkit.hbp + * harbour/contrib/hbqt/qtcore/hbqt_hbqstring.cpp + * harbour/contrib/hbqt/qtcore/hbqt_init.cpp + * harbour/contrib/hbqt/qtcore/hbqt_hbqstring.h + * harbour/contrib/hbqt/qtnetwork/hbqt_init.cpp + * harbour/contrib/hbqt/tests/testres.prg + * harbour/contrib/hbqt/tests/wvtqt.hbp + * harbour/contrib/hbqt/tests/wvtqt.prg + * harbour/contrib/hbqt/qtuitools/hbqtuitools.hbm + * harbour/contrib/hbqt/qtuitools/hbqtuitools.hbp + * harbour/contrib/hbqt/qtuitools/hbqtuitools.hbc + * harbour/contrib/hbqt/qtdesigner/hbqtdesigner.hbm + * harbour/contrib/hbqt/qtdesigner/hbqtdesigner.hbp + * harbour/contrib/hbfship/fldarr.prg + * harbour/contrib/hbfship/isbegseq.c + * harbour/contrib/hbfship/isfunc.c + * harbour/contrib/hbfship/isdb.prg + * harbour/contrib/hbfship/flddeci.c + * set svn:keywords="Author Date Id Revision" + 2010-11-09 11:14 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbhpdf/harupdf.c ! Applied patch from Saulius Zrelskis, fixing non-uppercased diff --git a/harbour/contrib/hbexpat/hbexpat.c b/harbour/contrib/hbexpat/hbexpat.c index 909963d323..2f654f253f 100644 --- a/harbour/contrib/hbexpat/hbexpat.c +++ b/harbour/contrib/hbexpat/hbexpat.c @@ -1,1220 +1,1220 @@ -/* - * $Id: hbexpat.c 1965 2010-08-28 13:19:42Z vszakats $ - */ - -/* - * Harbour Project source code: - * expat API - Harbour interface - * - * Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) - * www - http://harbour-project.org - * - * 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, 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 software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -/* - Author James Clark: - http://www.jclark.com/xml/ - Using Expat: - http://www.xml.com/pub/a/1999/09/expat/index.html - http://www.xml.com/lpt/a/47 - */ - -/* - TODO: - XML_SetExternalEntityRefHandler() - XML_SetExternalEntityRefHandlerArg() - XML_ExternalEntityParserCreate() - XML_SetElementDeclHandler() - and related functions/constants - */ - -#include "expat.h" - -#define HB_EXPAT_VERS( ma, mi, mu ) ( XML_MAJOR_VERSION >= ma && XML_MINOR_VERSION >= mi && XML_MICRO_VERSION >= mu ) - -#include "hbapi.h" -#include "hbapiitm.h" -#include "hbapistr.h" -#include "hbapierr.h" -#include "hbvm.h" - -#include "hbexpat.ch" - -#define _VAR_xUserData 0 -#define _VAR_xEncodingHandlerData 1 -#define _VAR_bStartElementHandler 2 -#define _VAR_bEndElementHandler 3 -#define _VAR_bCharacterDataHandler 4 -#define _VAR_bProcessingInstructionHandler 5 -#define _VAR_bCommentHandler 6 -#define _VAR_bStartCdataSectionHandler 7 -#define _VAR_bEndCdataSectionHandler 8 -#define _VAR_bDefaultHandler 9 -#define _VAR_bDefaultHandlerExpand 10 -#define _VAR_bSkippedEntityHandler 11 -#define _VAR_bUnknownEncodingHandler 12 -#define _VAR_bStartNamespaceDeclHandler 13 -#define _VAR_bEndNamespaceDeclHandler 14 -#define _VAR_bXmlDeclHandler 15 -#define _VAR_bStartDoctypeDeclHandler 16 -#define _VAR_bEndDoctypeDeclHandler 17 -#define _VAR_bAttlistDeclHandler 18 -#define _VAR_bEntityDeclHandler 19 -#define _VAR_bUnparsedEntityDeclHandler 20 -#define _VAR_bNotationDeclHandler 21 -#define _VAR_bNotStandaloneHandler 22 -#define _VAR_LEN_ 23 - -typedef struct _HB_EXPAT -{ - XML_Parser parser; - PHB_ITEM pVar[ _VAR_LEN_ ]; -} HB_EXPAT, * PHB_EXPAT; - -/* Skeleton wrapper for all single handler setters */ -#define HB_EXPAT_SETHANDLER( _nameu_, _name_ ) \ - HB_FUNC( XML_SET##_nameu_ ) \ - { \ - if( PHB_EXPAT_is( 1 ) ) \ - { \ - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); \ - \ - hb_expat_setvar( hb_expat, _VAR_b##_name_, hb_param( 2, HB_IT_BLOCK ) ); \ - \ - XML_Set##_name_ ( hb_expat->parser, hb_expat->pVar[ _VAR_b##_name_ ] ? hb_expat_##_name_ : NULL ); \ - \ - hb_ret(); \ - } \ - else \ - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); \ - } - -/* ---------------------------------------------------------------------------- */ -/* Global initialization/deinitialization */ - -static void * XMLCALL hb_expat_xgrab( size_t size ) -{ - return hb_xgrab( size ); -} - -static void XMLCALL hb_expat_xfree( void * p ) -{ - if( p ) - hb_xfree( p ); -} - -static void * XMLCALL hb_expat_xrealloc( void * p, size_t size ) -{ - return hb_xrealloc( p, size ); -} - -/* ---------------------------------------------------------------------------- */ -/* Callbacks */ - -/* Common */ - -static void hb_expat_hnd_void( int nHnd, void * userdata ) -{ - PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; - - if( hb_expat && hb_expat->pVar[ nHnd ] ) - { - if( hb_vmRequestReenter() ) - { - PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); - - hb_vmEvalBlockV( hb_expat->pVar[ nHnd ], 1, pUserData ); - - hb_itemRelease( pUserData ); - - hb_vmRequestRestore(); - } - } -} - -static void hb_expat_hnd_C( int nHnd, void * userdata, const XML_Char * par1 ) -{ - PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; - - if( hb_expat && hb_expat->pVar[ nHnd ] ) - { - if( hb_vmRequestReenter() ) - { - PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); - PHB_ITEM pPar1 = hb_itemPutStrUTF8( NULL, par1 ); - - hb_vmEvalBlockV( hb_expat->pVar[ nHnd ], 2, pUserData, pPar1 ); - - hb_itemRelease( pPar1 ); - hb_itemRelease( pUserData ); - - hb_vmRequestRestore(); - } - } -} - -static void hb_expat_hnd_CLen( int nHnd, void * userdata, const XML_Char * par1, int par1len ) -{ - PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; - - if( hb_expat && hb_expat->pVar[ nHnd ] ) - { - if( hb_vmRequestReenter() ) - { - PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); - PHB_ITEM pPar1 = hb_itemPutStrLenUTF8( NULL, par1, par1len ); - - hb_vmEvalBlockV( hb_expat->pVar[ nHnd ], 2, pUserData, pPar1 ); - - hb_itemRelease( pPar1 ); - hb_itemRelease( pUserData ); - - hb_vmRequestRestore(); - } - } -} - -/* Specific */ - -static void XMLCALL hb_expat_StartElementHandler( void * userdata, const XML_Char * name, const XML_Char ** atts ) -{ - PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; - - if( hb_expat && hb_expat->pVar[ _VAR_bStartElementHandler ] ) - { - if( hb_vmRequestReenter() ) - { - PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); - PHB_ITEM pElement = hb_itemPutStrUTF8( NULL, name ); - PHB_ITEM pAttr; - - if( atts ) - { - PHB_ITEM pTempItem = hb_itemNew( NULL ); - HB_ISIZ nPos; - HB_ISIZ nLen = 0; - - for( nPos = 0; atts[ nPos ]; nPos += 2 ) - ++nLen; - - pAttr = hb_itemArrayNew( nLen ); - - for( nPos = 0; atts[ nPos ]; nPos += 2 ) - { - hb_arrayNew( pTempItem, 2 ); - - hb_arraySetStrUTF8( pTempItem, 1, atts[ nPos ] ); - hb_arraySetStrUTF8( pTempItem, 2, atts[ nPos + 1 ] ); - - hb_arraySetForward( pAttr, ( nPos >> 1 ) + 1, pTempItem ); - } - - hb_itemRelease( pTempItem ); - } - else - pAttr = hb_itemArrayNew( 0 ); - - hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bStartElementHandler ], 3, pUserData, pElement, pAttr ); - - hb_itemRelease( pAttr ); - hb_itemRelease( pElement ); - hb_itemRelease( pUserData ); - - hb_vmRequestRestore(); - } - } -} - -static void XMLCALL hb_expat_EndElementHandler( void * userdata, const XML_Char * name ) -{ - hb_expat_hnd_C( _VAR_bEndElementHandler, userdata, name ); -} - -static void XMLCALL hb_expat_CharacterDataHandler( void * userdata, const XML_Char * s, int len ) -{ - hb_expat_hnd_CLen( _VAR_bCharacterDataHandler, userdata, s, len ); -} - -static void XMLCALL hb_expat_ProcessingInstructionHandler( void * userdata, const XML_Char * target, const XML_Char * data ) -{ - PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; - - if( hb_expat && hb_expat->pVar[ _VAR_bProcessingInstructionHandler ] ) - { - if( hb_vmRequestReenter() ) - { - PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); - PHB_ITEM pTarget = hb_itemPutStrUTF8( NULL, target ); - PHB_ITEM pData = hb_itemPutStrUTF8( NULL, data ); - - hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bProcessingInstructionHandler ], 3, pUserData, pTarget, pData ); - - hb_itemRelease( pData ); - hb_itemRelease( pTarget ); - hb_itemRelease( pUserData ); - - hb_vmRequestRestore(); - } - } -} - -static void XMLCALL hb_expat_CommentHandler( void * userdata, const XML_Char * data ) -{ - hb_expat_hnd_C( _VAR_bCommentHandler, userdata, data ); -} - -static void XMLCALL hb_expat_StartCdataSectionHandler( void * userdata ) -{ - hb_expat_hnd_void( _VAR_bStartCdataSectionHandler, userdata ); -} - -static void XMLCALL hb_expat_EndCdataSectionHandler( void * userdata ) -{ - hb_expat_hnd_void( _VAR_bEndCdataSectionHandler, userdata ); -} - -static void XMLCALL hb_expat_DefaultHandler( void * userdata, const XML_Char * s, int len ) -{ - hb_expat_hnd_CLen( _VAR_bDefaultHandler, userdata, s, len ); -} - -static void XMLCALL hb_expat_DefaultHandlerExpand( void * userdata, const XML_Char * s, int len ) -{ - hb_expat_hnd_CLen( _VAR_bDefaultHandlerExpand, userdata, s, len ); -} - -static void XMLCALL hb_expat_SkippedEntityHandler( void * userdata, - const XML_Char * entityName, - int is_parameter_entity ) -{ - PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; - - if( hb_expat && hb_expat->pVar[ _VAR_bSkippedEntityHandler ] ) - { - if( hb_vmRequestReenter() ) - { - PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); - PHB_ITEM pPar1 = hb_itemPutStrUTF8( NULL, entityName ); - PHB_ITEM pPar2 = hb_itemPutL( NULL, is_parameter_entity ); - - hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bSkippedEntityHandler ], 3, pUserData, pPar1, pPar2 ); - - hb_itemRelease( pPar2 ); - hb_itemRelease( pPar1 ); - hb_itemRelease( pUserData ); - - hb_vmRequestRestore(); - } - } -} - -static int XMLCALL hb_expat_UnknownEncodingHandler( void * userdata, - const XML_Char * name, - XML_Encoding * info ) -{ - PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; - int iResult = XML_STATUS_ERROR; - - if( hb_expat && hb_expat->pVar[ _VAR_bUnknownEncodingHandler ] ) - { - if( hb_vmRequestReenter() ) - { - PHB_ITEM pEncData = hb_itemNew( hb_expat->pVar[ _VAR_xEncodingHandlerData ] ); - PHB_ITEM pPar1 = hb_itemPutStrUTF8( NULL, name ); - PHB_ITEM pPar2 = hb_itemArrayNew( HB_SIZEOFARRAY( info->map ) ); - - iResult = hb_itemGetNI( hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bUnknownEncodingHandler ], 3, pEncData, pPar1, pPar2 ) ); - - if( iResult == XML_STATUS_OK ) - { - HB_UINT tmp; - - for( tmp = 0; tmp < HB_SIZEOFARRAY( info->map ); ++tmp ) - info->map[ tmp ] = hb_arrayGetNI( pPar2, tmp + 1 ); - - /* NOTE: Not supported by wrapper layer yet. */ - info->data = NULL; - info->convert = NULL; - info->release = NULL; - } - - hb_itemRelease( pPar2 ); - hb_itemRelease( pPar1 ); - hb_itemRelease( pEncData ); - - hb_vmRequestRestore(); - } - } - - return iResult; -} - -static void XMLCALL hb_expat_StartNamespaceDeclHandler( void * userdata, - const XML_Char * prefix, - const XML_Char * uri ) -{ - PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; - - if( hb_expat && hb_expat->pVar[ _VAR_bStartNamespaceDeclHandler ] ) - { - if( hb_vmRequestReenter() ) - { - PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); - PHB_ITEM pPar1 = hb_itemPutStrUTF8( NULL, prefix ); - PHB_ITEM pPar2 = hb_itemPutStrUTF8( NULL, uri ); - - hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bStartNamespaceDeclHandler ], 3, pUserData, pPar1, pPar2 ); - - hb_itemRelease( pPar2 ); - hb_itemRelease( pPar1 ); - hb_itemRelease( pUserData ); - - hb_vmRequestRestore(); - } - } -} - -static void XMLCALL hb_expat_EndNamespaceDeclHandler( void * userdata, const XML_Char * prefix ) -{ - hb_expat_hnd_C( _VAR_bEndNamespaceDeclHandler, userdata, prefix ); -} - -static void XMLCALL hb_expat_XmlDeclHandler( void * userdata, - const XML_Char * version, - const XML_Char * encoding, - int standalone ) -{ - PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; - - if( hb_expat && hb_expat->pVar[ _VAR_bXmlDeclHandler ] ) - { - if( hb_vmRequestReenter() ) - { - PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); - PHB_ITEM pPar1 = version ? hb_itemPutStrUTF8( NULL, version ) : hb_itemNew( NULL ); - PHB_ITEM pPar2 = encoding ? hb_itemPutStrUTF8( NULL, encoding ) : hb_itemNew( NULL ); - PHB_ITEM pPar3 = hb_itemPutNI( NULL, standalone ); - - hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bXmlDeclHandler ], 4, pUserData, pPar1, pPar2, pPar3 ); - - hb_itemRelease( pPar3 ); - hb_itemRelease( pPar2 ); - hb_itemRelease( pPar1 ); - hb_itemRelease( pUserData ); - - hb_vmRequestRestore(); - } - } -} - -static void XMLCALL hb_expat_StartDoctypeDeclHandler( void * userdata, - const XML_Char * doctypeName, - const XML_Char * sysid, - const XML_Char * pubid, - int has_internal_subset ) -{ - PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; - - if( hb_expat && hb_expat->pVar[ _VAR_bStartDoctypeDeclHandler ] ) - { - if( hb_vmRequestReenter() ) - { - PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); - PHB_ITEM pPar1 = hb_itemPutStrUTF8( NULL, doctypeName ); - PHB_ITEM pPar2 = sysid ? hb_itemPutStrUTF8( NULL, sysid ) : hb_itemNew( NULL ); - PHB_ITEM pPar3 = pubid ? hb_itemPutStrUTF8( NULL, pubid ) : hb_itemNew( NULL ); - PHB_ITEM pPar4 = hb_itemPutL( NULL, has_internal_subset ); - - hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bStartDoctypeDeclHandler ], 5, pUserData, pPar1, pPar2, pPar3, pPar4 ); - - hb_itemRelease( pPar4 ); - hb_itemRelease( pPar3 ); - hb_itemRelease( pPar2 ); - hb_itemRelease( pPar1 ); - hb_itemRelease( pUserData ); - - hb_vmRequestRestore(); - } - } -} - -static void XMLCALL hb_expat_EndDoctypeDeclHandler( void * userdata ) -{ - hb_expat_hnd_void( _VAR_bEndDoctypeDeclHandler, userdata ); -} - -static void XMLCALL hb_expat_AttlistDeclHandler( void * userdata, - const XML_Char * elname, - const XML_Char * attname, - const XML_Char * att_type, - const XML_Char * dflt, - int isrequired ) -{ - PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; - - if( hb_expat && hb_expat->pVar[ _VAR_bAttlistDeclHandler ] ) - { - if( hb_vmRequestReenter() ) - { - PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); - PHB_ITEM pPar1 = hb_itemPutStrUTF8( NULL, elname ); - PHB_ITEM pPar2 = hb_itemPutStrUTF8( NULL, attname ); - PHB_ITEM pPar3 = hb_itemPutStrUTF8( NULL, att_type ); - PHB_ITEM pPar4 = dflt ? hb_itemPutStrUTF8( NULL, dflt ) : hb_itemNew( NULL ); - PHB_ITEM pPar5 = hb_itemPutL( NULL, isrequired ); - - hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bAttlistDeclHandler ], 6, pUserData, pPar1, pPar2, pPar3, pPar4, pPar5 ); - - hb_itemRelease( pPar5 ); - hb_itemRelease( pPar4 ); - hb_itemRelease( pPar3 ); - hb_itemRelease( pPar2 ); - hb_itemRelease( pPar1 ); - hb_itemRelease( pUserData ); - - hb_vmRequestRestore(); - } - } -} - -static void XMLCALL hb_expat_EntityDeclHandler( void * userdata, - const XML_Char * entityName, - int is_parameter_entity, - const XML_Char * value, - int value_length, - const XML_Char * base, - const XML_Char * systemId, - const XML_Char * publicId, - const XML_Char * notationName ) -{ - PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; - - if( hb_expat && hb_expat->pVar[ _VAR_bEntityDeclHandler ] ) - { - if( hb_vmRequestReenter() ) - { - PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); - PHB_ITEM pPar1 = hb_itemPutStrUTF8( NULL, entityName ); - PHB_ITEM pPar2 = hb_itemPutL( NULL, is_parameter_entity ); - PHB_ITEM pPar3 = value ? hb_itemPutStrLenUTF8( NULL, value, value_length ) : hb_itemNew( NULL ); - PHB_ITEM pPar4 = base ? hb_itemPutStrUTF8( NULL, base ) : hb_itemNew( NULL ); - PHB_ITEM pPar5 = systemId ? hb_itemPutStrUTF8( NULL, systemId ) : hb_itemNew( NULL ); - PHB_ITEM pPar6 = publicId ? hb_itemPutStrUTF8( NULL, publicId ) : hb_itemNew( NULL ); - PHB_ITEM pPar7 = notationName ? hb_itemPutStrUTF8( NULL, notationName ) : hb_itemNew( NULL ); - - hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bEntityDeclHandler ], 8, pUserData, pPar1, pPar2, pPar3, pPar4, pPar5, pPar6, pPar7 ); - - hb_itemRelease( pPar7 ); - hb_itemRelease( pPar6 ); - hb_itemRelease( pPar5 ); - hb_itemRelease( pPar4 ); - hb_itemRelease( pPar3 ); - hb_itemRelease( pPar2 ); - hb_itemRelease( pPar1 ); - hb_itemRelease( pUserData ); - - hb_vmRequestRestore(); - } - } -} - -#if 0 -static void XMLCALL hb_expat_UnparsedEntityDeclHandler( void * userdata, - const XML_Char * entityName, - const XML_Char * base, - const XML_Char * systemId, - const XML_Char * publicId, - const XML_Char * notationName ) -{ - PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; - - if( hb_expat && hb_expat->pVar[ _VAR_bUnparsedEntityDeclHandler ] ) - { - if( hb_vmRequestReenter() ) - { - PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); - PHB_ITEM pPar1 = hb_itemPutStrUTF8( NULL, entityName ); - PHB_ITEM pPar2 = hb_itemPutStrUTF8( NULL, base ); - PHB_ITEM pPar3 = hb_itemPutStrUTF8( NULL, systemId ); - PHB_ITEM pPar4 = hb_itemPutStrUTF8( NULL, publicId ); - PHB_ITEM pPar5 = hb_itemPutStrUTF8( NULL, notationName ); - - hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bUnparsedEntityDeclHandler ], 6, pUserData, pPar1, pPar2, pPar3, pPar4, pPar5 ); - - hb_itemRelease( pPar5 ); - hb_itemRelease( pPar4 ); - hb_itemRelease( pPar3 ); - hb_itemRelease( pPar2 ); - hb_itemRelease( pPar1 ); - hb_itemRelease( pUserData ); - - hb_vmRequestRestore(); - } - } -} -#endif - -static void XMLCALL hb_expat_NotationDeclHandler( void * userdata, - const XML_Char * notationName, - const XML_Char * base, - const XML_Char * systemId, - const XML_Char * publicId ) -{ - PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; - - if( hb_expat && hb_expat->pVar[ _VAR_bNotationDeclHandler ] ) - { - if( hb_vmRequestReenter() ) - { - PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); - PHB_ITEM pPar1 = hb_itemPutStrUTF8( NULL, notationName ); - PHB_ITEM pPar2 = base ? hb_itemPutStrUTF8( NULL, base ) : hb_itemNew( NULL ); - PHB_ITEM pPar3 = systemId ? hb_itemPutStrUTF8( NULL, systemId ) : hb_itemNew( NULL ); - PHB_ITEM pPar4 = publicId ? hb_itemPutStrUTF8( NULL, publicId ) : hb_itemNew( NULL ); - - hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bNotationDeclHandler ], 5, pUserData, pPar1, pPar2, pPar3, pPar4 ); - - hb_itemRelease( pPar4 ); - hb_itemRelease( pPar3 ); - hb_itemRelease( pPar2 ); - hb_itemRelease( pPar1 ); - hb_itemRelease( pUserData ); - - hb_vmRequestRestore(); - } - } -} - -static int XMLCALL hb_expat_NotStandaloneHandler( void * userdata ) -{ - PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; - - int iResult = XML_STATUS_ERROR; - - if( hb_expat && hb_expat->pVar[ _VAR_bNotStandaloneHandler ] ) - { - if( hb_vmRequestReenter() ) - { - PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); - - iResult = hb_itemGetNI( hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bNotStandaloneHandler ], 1, pUserData ) ); - - hb_itemRelease( pUserData ); - - hb_vmRequestRestore(); - } - } - - return iResult; -} - -/* ---------------------------------------------------------------------------- */ -/* Constructor/Destructor */ - -static void PHB_EXPAT_free( PHB_EXPAT hb_expat, HB_BOOL bFree ) -{ - HB_UINT tmp; - - for( tmp = 0; tmp < HB_SIZEOFARRAY( hb_expat->pVar ); ++tmp ) - { - if( hb_expat->pVar[ tmp ] ) - { - hb_itemRelease( hb_expat->pVar[ tmp ] ); - hb_expat->pVar[ tmp ] = NULL; - } - } - - if( bFree ) - { - XML_SetUserData( hb_expat->parser, NULL ); - XML_ParserFree( hb_expat->parser ); - hb_xfree( hb_expat ); - } -} - -static HB_GARBAGE_FUNC( PHB_EXPAT_release ) -{ - PHB_EXPAT * hb_expat_ptr = ( PHB_EXPAT * ) Cargo; - /* Check if pointer is not NULL to avoid multiple freeing */ - if( hb_expat_ptr && * hb_expat_ptr ) - { - PHB_EXPAT hb_expat = * hb_expat_ptr; - - /* set pointer to NULL to avoid multiple freeing */ - * hb_expat_ptr = NULL; - - /* Destroy the object */ - PHB_EXPAT_free( hb_expat, HB_TRUE ); - } -} - -static HB_GARBAGE_FUNC( PHB_EXPAT_mark ) -{ - PHB_EXPAT * hb_expat_ptr = ( PHB_EXPAT * ) Cargo; - - if( hb_expat_ptr && * hb_expat_ptr ) - { - PHB_EXPAT hb_expat = * hb_expat_ptr; - HB_UINT tmp; - - for( tmp = 0; tmp < HB_SIZEOFARRAY( hb_expat->pVar ); ++tmp ) - { - if( hb_expat->pVar[ tmp ] ) - hb_gcMark( hb_expat->pVar[ tmp ] ); - } - } -} - -static const HB_GC_FUNCS s_gcEXPATFuncs = -{ - PHB_EXPAT_release, - PHB_EXPAT_mark -}; - -static void * PHB_EXPAT_is( int iParam ) -{ - return hb_parptrGC( &s_gcEXPATFuncs, iParam ); -} - -static PHB_EXPAT PHB_EXPAT_par( int iParam ) -{ - void ** ph = ( void ** ) hb_parptrGC( &s_gcEXPATFuncs, iParam ); - - return ph ? ( PHB_EXPAT ) * ph : NULL; -} - -static void hb_expat_setvar( PHB_EXPAT hb_expat, int iHandler, PHB_ITEM pBlock ) -{ - if( hb_expat->pVar[ iHandler ] ) - { - hb_itemRelease( hb_expat->pVar[ iHandler ] ); - hb_expat->pVar[ iHandler ] = NULL; - } - - if( pBlock ) - { - hb_expat->pVar[ iHandler ] = hb_itemNew( pBlock ); - /* unlock the item so GC will not mark them as used */ - hb_gcUnlock( hb_expat->pVar[ iHandler ] ); - } -} - -/* ---------------------------------------------------------------------------- */ -/* Harbour interface */ - -HB_FUNC( XML_PARSERCREATE ) -{ - void ** ph = ( void ** ) hb_gcAllocate( sizeof( PHB_EXPAT ), &s_gcEXPATFuncs ); - - XML_Parser parser; - XML_Memory_Handling_Suite ms; - - void * hEncoding; - void * hSep; - - ms.malloc_fcn = hb_expat_xgrab; - ms.realloc_fcn = hb_expat_xrealloc; - ms.free_fcn = hb_expat_xfree; - - parser = XML_ParserCreate_MM( hb_parstr_utf8( 1, &hEncoding, NULL ), - &ms, - hb_parstr_utf8( 2, &hSep, NULL ) ); - - hb_strfree( hSep ); - hb_strfree( hEncoding ); - - if( parser ) - { - PHB_EXPAT hb_expat = ( PHB_EXPAT ) hb_xgrab( sizeof( HB_EXPAT ) ); - - memset( hb_expat, 0, sizeof( HB_EXPAT ) ); - hb_expat->parser = parser; - - XML_SetUserData( hb_expat->parser, hb_expat ); - - * ph = hb_expat; - } - else - * ph = NULL; - - hb_retptrGC( ph ); -} - -HB_FUNC( XML_PARSERESET ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - if( hb_expat ) - { - void * hEncoding; - - PHB_EXPAT_free( hb_expat, HB_FALSE ); - - XML_ParserReset( hb_expat->parser, - hb_parstr_utf8( 1, &hEncoding, NULL ) ); - - hb_strfree( hEncoding ); - } - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_PARSERFREE ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - void ** ph = ( void ** ) hb_parptrGC( &s_gcEXPATFuncs, 1 ); - - if( ph && * ph ) - { - PHB_EXPAT hb_expat = ( PHB_EXPAT ) * ph; - - /* set pointer to NULL to avoid multiple freeing */ - * ph = NULL; - - /* Destroy the object */ - PHB_EXPAT_free( hb_expat, HB_TRUE ); - } - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_SETUSERDATA ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - hb_expat_setvar( hb_expat, _VAR_xUserData, hb_param( 2, HB_IT_ANY ) ); - - hb_ret(); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_GETUSERDATA ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - hb_itemReturnRelease( hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ) ); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_SETELEMENTHANDLER ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - hb_expat_setvar( hb_expat, _VAR_bStartElementHandler, hb_param( 2, HB_IT_BLOCK ) ); - hb_expat_setvar( hb_expat, _VAR_bEndElementHandler, hb_param( 3, HB_IT_BLOCK ) ); - - XML_SetElementHandler( hb_expat->parser, - hb_expat->pVar[ _VAR_bStartElementHandler ] ? hb_expat_StartElementHandler : NULL, - hb_expat->pVar[ _VAR_bEndElementHandler ] ? hb_expat_EndElementHandler : NULL ); - - hb_ret(); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_SETCDATASECTIONHANDLER ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - hb_expat_setvar( hb_expat, _VAR_bStartCdataSectionHandler, hb_param( 2, HB_IT_BLOCK ) ); - hb_expat_setvar( hb_expat, _VAR_bEndCdataSectionHandler, hb_param( 3, HB_IT_BLOCK ) ); - - XML_SetCdataSectionHandler( hb_expat->parser, - hb_expat->pVar[ _VAR_bStartCdataSectionHandler ] ? hb_expat_StartCdataSectionHandler : NULL, - hb_expat->pVar[ _VAR_bEndCdataSectionHandler ] ? hb_expat_EndCdataSectionHandler : NULL ); - - hb_ret(); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_SETNAMESPACEDECLHANDLER ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - hb_expat_setvar( hb_expat, _VAR_bStartNamespaceDeclHandler, hb_param( 2, HB_IT_BLOCK ) ); - hb_expat_setvar( hb_expat, _VAR_bEndNamespaceDeclHandler, hb_param( 3, HB_IT_BLOCK ) ); - - XML_SetNamespaceDeclHandler( hb_expat->parser, - hb_expat->pVar[ _VAR_bStartNamespaceDeclHandler ] ? hb_expat_StartNamespaceDeclHandler : NULL, - hb_expat->pVar[ _VAR_bEndNamespaceDeclHandler ] ? hb_expat_EndNamespaceDeclHandler : NULL ); - - hb_ret(); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_SETUNKNOWNENCODINGHANDLER ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - hb_expat_setvar( hb_expat, _VAR_bUnknownEncodingHandler, hb_param( 2, HB_IT_BLOCK ) ); - hb_expat_setvar( hb_expat, _VAR_xEncodingHandlerData, hb_param( 3, HB_IT_ANY ) ); - - XML_SetUnknownEncodingHandler( hb_expat->parser, - hb_expat->pVar[ _VAR_bUnknownEncodingHandler ] ? hb_expat_UnknownEncodingHandler : NULL, - hb_expat ); - - hb_ret(); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -/* ; */ - -HB_FUNC( XML_PARSE ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - hb_retni( XML_Parse( hb_expat->parser, hb_parcx( 2 ), ( int ) hb_parclen( 2 ), ( int ) hb_parl( 3 ) ) ); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_GETERRORCODE ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - hb_retni( ( int ) XML_GetErrorCode( hb_expat->parser ) ); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_ERRORSTRING ) -{ - hb_retc( XML_ErrorString( ( enum XML_Error ) hb_parni( 1 ) ) ); -} - -HB_FUNC( XML_GETCURRENTBYTEINDEX ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - hb_retns( XML_GetCurrentByteIndex( hb_expat->parser ) ); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_GETCURRENTLINENUMBER ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - hb_retns( XML_GetCurrentLineNumber( hb_expat->parser ) ); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_GETCURRENTCOLUMNNUMBER ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - hb_retns( XML_GetCurrentColumnNumber( hb_expat->parser ) ); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_GETCURRENTBYTECOUNT ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - hb_retni( XML_GetCurrentByteCount( hb_expat->parser ) ); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_SETBASE ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - void * hBase; - - hb_retni( ( int ) XML_SetBase( hb_expat->parser, hb_parstr_utf8( 1, &hBase, NULL ) ) ); - - hb_strfree( hBase ); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_GETBASE ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - hb_retstr_utf8( XML_GetBase( hb_expat->parser ) ); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_GETSPECIFIEDATTRIBUTECOUNT ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - hb_retni( XML_GetSpecifiedAttributeCount( hb_expat->parser ) ); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_GETIDATTRIBUTEINDEX ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - hb_retni( XML_GetIdAttributeIndex( hb_expat->parser ) ); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_SETENCODING ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - void * hEncoding; - - hb_retni( ( int ) XML_SetEncoding( hb_expat->parser, - hb_parstr_utf8( 1, &hEncoding, NULL ) ) ); - - hb_strfree( hEncoding ); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_SETPARAMENTITYPARSING ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - hb_retni( XML_SetParamEntityParsing( hb_expat->parser, ( enum XML_ParamEntityParsing ) hb_parni( 2 ) ) ); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_USEFOREIGNDTD ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - hb_retni( ( int ) XML_UseForeignDTD( hb_expat->parser, ( XML_Bool ) hb_parl( 2 ) ) ); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_SETRETURNNSTRIPLET ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - XML_SetReturnNSTriplet( hb_expat->parser, hb_parni( 2 ) ); - - hb_ret(); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_DEFAULTCURRENT ) -{ - if( PHB_EXPAT_is( 1 ) ) - { - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - XML_DefaultCurrent( hb_expat->parser ); - - hb_ret(); - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_STOPPARSER ) -{ - if( PHB_EXPAT_is( 1 ) ) - { -#if HB_EXPAT_VERS( 1, 95, 8 ) - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - hb_retni( ( int ) XML_StopParser( hb_expat->parser, hb_parl( 2 ) ) ); -#else - hb_retni( HB_XML_ERROR_NOT_IMPLEMENTED_ ); -#endif - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_RESUMEPARSER ) -{ - if( PHB_EXPAT_is( 1 ) ) - { -#if HB_EXPAT_VERS( 1, 95, 8 ) - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - - hb_retni( ( int ) XML_ResumeParser( hb_expat->parser ) ); -#else - hb_retni( HB_XML_ERROR_NOT_IMPLEMENTED_ ); -#endif - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_GETPARSINGSTATUS ) -{ - if( PHB_EXPAT_is( 1 ) ) - { -#if HB_EXPAT_VERS( 1, 95, 8 ) - PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); - XML_ParsingStatus status; - - XML_GetParsingStatus( hb_expat->parser, &status ); - - hb_storni( ( int ) status->parsing, 2 ); - hb_storl( ( HB_BOOL ) status->finalBuffer, 3 ); -#else - hb_storni( -1, 2 ); - hb_storl( HB_FALSE, 3 ); -#endif - } - else - hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); -} - -HB_FUNC( XML_EXPATVERSION ) -{ - hb_retc( XML_ExpatVersion() ); -} - -HB_FUNC( XML_EXPATVERSIONINFO ) -{ - XML_Expat_Version var = XML_ExpatVersionInfo(); - - hb_storni( var.major, 1 ); - hb_storni( var.minor, 2 ); - hb_storni( var.micro, 3 ); -} - -HB_FUNC( HB_XML_EXPATVERSIONINFO ) -{ - hb_storni( XML_MAJOR_VERSION, 1 ); - hb_storni( XML_MINOR_VERSION, 2 ); - hb_storni( XML_MICRO_VERSION, 3 ); -} - -HB_EXPAT_SETHANDLER( STARTELEMENTHANDLER , StartElementHandler ) -HB_EXPAT_SETHANDLER( ENDELEMENTHANDLER , EndElementHandler ) -HB_EXPAT_SETHANDLER( CHARACTERDATAHANDLER , CharacterDataHandler ) -HB_EXPAT_SETHANDLER( PROCESSINGINSTRUCTIONHANDLER, ProcessingInstructionHandler ) -HB_EXPAT_SETHANDLER( COMMENTHANDLER , CommentHandler ) -HB_EXPAT_SETHANDLER( STARTCDATASECTIONHANDLER , StartCdataSectionHandler ) -HB_EXPAT_SETHANDLER( ENDCDATASECTIONHANDLER , EndCdataSectionHandler ) -HB_EXPAT_SETHANDLER( DEFAULTHANDLER , DefaultHandler ) -HB_EXPAT_SETHANDLER( DEFAULTHANDLEREXPAND , DefaultHandlerExpand ) -HB_EXPAT_SETHANDLER( SKIPPEDENTITYHANDLER , SkippedEntityHandler ) -HB_EXPAT_SETHANDLER( STARTNAMESPACEDECLHANDLER , StartNamespaceDeclHandler ) -HB_EXPAT_SETHANDLER( ENDNAMESPACEDECLHANDLER , EndNamespaceDeclHandler ) -HB_EXPAT_SETHANDLER( XMLDECLHANDLER , XmlDeclHandler ) -HB_EXPAT_SETHANDLER( STARTDOCTYPEDECLHANDLER , StartDoctypeDeclHandler ) -HB_EXPAT_SETHANDLER( ENDDOCTYPEDECLHANDLER , EndDoctypeDeclHandler ) -HB_EXPAT_SETHANDLER( ATTLISTDECLHANDLER , AttlistDeclHandler ) -HB_EXPAT_SETHANDLER( ENTITYDECLHANDLER , EntityDeclHandler ) -#if 0 /* Obsolete */ -HB_EXPAT_SETHANDLER( UNPARSEDENTITYDECLHANDLER , UnparsedEntityDeclHandler ) -#endif -HB_EXPAT_SETHANDLER( NOTATIONDECLHANDLER , NotationDeclHandler ) -HB_EXPAT_SETHANDLER( NOTSTANDALONEHANDLER , NotStandaloneHandler ) +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * expat API - Harbour interface + * + * Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) + * www - http://harbour-project.org + * + * 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, 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 software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + +/* + Author James Clark: + http://www.jclark.com/xml/ + Using Expat: + http://www.xml.com/pub/a/1999/09/expat/index.html + http://www.xml.com/lpt/a/47 + */ + +/* + TODO: + XML_SetExternalEntityRefHandler() + XML_SetExternalEntityRefHandlerArg() + XML_ExternalEntityParserCreate() + XML_SetElementDeclHandler() + and related functions/constants + */ + +#include "expat.h" + +#define HB_EXPAT_VERS( ma, mi, mu ) ( XML_MAJOR_VERSION >= ma && XML_MINOR_VERSION >= mi && XML_MICRO_VERSION >= mu ) + +#include "hbapi.h" +#include "hbapiitm.h" +#include "hbapistr.h" +#include "hbapierr.h" +#include "hbvm.h" + +#include "hbexpat.ch" + +#define _VAR_xUserData 0 +#define _VAR_xEncodingHandlerData 1 +#define _VAR_bStartElementHandler 2 +#define _VAR_bEndElementHandler 3 +#define _VAR_bCharacterDataHandler 4 +#define _VAR_bProcessingInstructionHandler 5 +#define _VAR_bCommentHandler 6 +#define _VAR_bStartCdataSectionHandler 7 +#define _VAR_bEndCdataSectionHandler 8 +#define _VAR_bDefaultHandler 9 +#define _VAR_bDefaultHandlerExpand 10 +#define _VAR_bSkippedEntityHandler 11 +#define _VAR_bUnknownEncodingHandler 12 +#define _VAR_bStartNamespaceDeclHandler 13 +#define _VAR_bEndNamespaceDeclHandler 14 +#define _VAR_bXmlDeclHandler 15 +#define _VAR_bStartDoctypeDeclHandler 16 +#define _VAR_bEndDoctypeDeclHandler 17 +#define _VAR_bAttlistDeclHandler 18 +#define _VAR_bEntityDeclHandler 19 +#define _VAR_bUnparsedEntityDeclHandler 20 +#define _VAR_bNotationDeclHandler 21 +#define _VAR_bNotStandaloneHandler 22 +#define _VAR_LEN_ 23 + +typedef struct _HB_EXPAT +{ + XML_Parser parser; + PHB_ITEM pVar[ _VAR_LEN_ ]; +} HB_EXPAT, * PHB_EXPAT; + +/* Skeleton wrapper for all single handler setters */ +#define HB_EXPAT_SETHANDLER( _nameu_, _name_ ) \ + HB_FUNC( XML_SET##_nameu_ ) \ + { \ + if( PHB_EXPAT_is( 1 ) ) \ + { \ + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); \ + \ + hb_expat_setvar( hb_expat, _VAR_b##_name_, hb_param( 2, HB_IT_BLOCK ) ); \ + \ + XML_Set##_name_ ( hb_expat->parser, hb_expat->pVar[ _VAR_b##_name_ ] ? hb_expat_##_name_ : NULL ); \ + \ + hb_ret(); \ + } \ + else \ + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); \ + } + +/* ---------------------------------------------------------------------------- */ +/* Global initialization/deinitialization */ + +static void * XMLCALL hb_expat_xgrab( size_t size ) +{ + return hb_xgrab( size ); +} + +static void XMLCALL hb_expat_xfree( void * p ) +{ + if( p ) + hb_xfree( p ); +} + +static void * XMLCALL hb_expat_xrealloc( void * p, size_t size ) +{ + return hb_xrealloc( p, size ); +} + +/* ---------------------------------------------------------------------------- */ +/* Callbacks */ + +/* Common */ + +static void hb_expat_hnd_void( int nHnd, void * userdata ) +{ + PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; + + if( hb_expat && hb_expat->pVar[ nHnd ] ) + { + if( hb_vmRequestReenter() ) + { + PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); + + hb_vmEvalBlockV( hb_expat->pVar[ nHnd ], 1, pUserData ); + + hb_itemRelease( pUserData ); + + hb_vmRequestRestore(); + } + } +} + +static void hb_expat_hnd_C( int nHnd, void * userdata, const XML_Char * par1 ) +{ + PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; + + if( hb_expat && hb_expat->pVar[ nHnd ] ) + { + if( hb_vmRequestReenter() ) + { + PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); + PHB_ITEM pPar1 = hb_itemPutStrUTF8( NULL, par1 ); + + hb_vmEvalBlockV( hb_expat->pVar[ nHnd ], 2, pUserData, pPar1 ); + + hb_itemRelease( pPar1 ); + hb_itemRelease( pUserData ); + + hb_vmRequestRestore(); + } + } +} + +static void hb_expat_hnd_CLen( int nHnd, void * userdata, const XML_Char * par1, int par1len ) +{ + PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; + + if( hb_expat && hb_expat->pVar[ nHnd ] ) + { + if( hb_vmRequestReenter() ) + { + PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); + PHB_ITEM pPar1 = hb_itemPutStrLenUTF8( NULL, par1, par1len ); + + hb_vmEvalBlockV( hb_expat->pVar[ nHnd ], 2, pUserData, pPar1 ); + + hb_itemRelease( pPar1 ); + hb_itemRelease( pUserData ); + + hb_vmRequestRestore(); + } + } +} + +/* Specific */ + +static void XMLCALL hb_expat_StartElementHandler( void * userdata, const XML_Char * name, const XML_Char ** atts ) +{ + PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; + + if( hb_expat && hb_expat->pVar[ _VAR_bStartElementHandler ] ) + { + if( hb_vmRequestReenter() ) + { + PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); + PHB_ITEM pElement = hb_itemPutStrUTF8( NULL, name ); + PHB_ITEM pAttr; + + if( atts ) + { + PHB_ITEM pTempItem = hb_itemNew( NULL ); + HB_ISIZ nPos; + HB_ISIZ nLen = 0; + + for( nPos = 0; atts[ nPos ]; nPos += 2 ) + ++nLen; + + pAttr = hb_itemArrayNew( nLen ); + + for( nPos = 0; atts[ nPos ]; nPos += 2 ) + { + hb_arrayNew( pTempItem, 2 ); + + hb_arraySetStrUTF8( pTempItem, 1, atts[ nPos ] ); + hb_arraySetStrUTF8( pTempItem, 2, atts[ nPos + 1 ] ); + + hb_arraySetForward( pAttr, ( nPos >> 1 ) + 1, pTempItem ); + } + + hb_itemRelease( pTempItem ); + } + else + pAttr = hb_itemArrayNew( 0 ); + + hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bStartElementHandler ], 3, pUserData, pElement, pAttr ); + + hb_itemRelease( pAttr ); + hb_itemRelease( pElement ); + hb_itemRelease( pUserData ); + + hb_vmRequestRestore(); + } + } +} + +static void XMLCALL hb_expat_EndElementHandler( void * userdata, const XML_Char * name ) +{ + hb_expat_hnd_C( _VAR_bEndElementHandler, userdata, name ); +} + +static void XMLCALL hb_expat_CharacterDataHandler( void * userdata, const XML_Char * s, int len ) +{ + hb_expat_hnd_CLen( _VAR_bCharacterDataHandler, userdata, s, len ); +} + +static void XMLCALL hb_expat_ProcessingInstructionHandler( void * userdata, const XML_Char * target, const XML_Char * data ) +{ + PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; + + if( hb_expat && hb_expat->pVar[ _VAR_bProcessingInstructionHandler ] ) + { + if( hb_vmRequestReenter() ) + { + PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); + PHB_ITEM pTarget = hb_itemPutStrUTF8( NULL, target ); + PHB_ITEM pData = hb_itemPutStrUTF8( NULL, data ); + + hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bProcessingInstructionHandler ], 3, pUserData, pTarget, pData ); + + hb_itemRelease( pData ); + hb_itemRelease( pTarget ); + hb_itemRelease( pUserData ); + + hb_vmRequestRestore(); + } + } +} + +static void XMLCALL hb_expat_CommentHandler( void * userdata, const XML_Char * data ) +{ + hb_expat_hnd_C( _VAR_bCommentHandler, userdata, data ); +} + +static void XMLCALL hb_expat_StartCdataSectionHandler( void * userdata ) +{ + hb_expat_hnd_void( _VAR_bStartCdataSectionHandler, userdata ); +} + +static void XMLCALL hb_expat_EndCdataSectionHandler( void * userdata ) +{ + hb_expat_hnd_void( _VAR_bEndCdataSectionHandler, userdata ); +} + +static void XMLCALL hb_expat_DefaultHandler( void * userdata, const XML_Char * s, int len ) +{ + hb_expat_hnd_CLen( _VAR_bDefaultHandler, userdata, s, len ); +} + +static void XMLCALL hb_expat_DefaultHandlerExpand( void * userdata, const XML_Char * s, int len ) +{ + hb_expat_hnd_CLen( _VAR_bDefaultHandlerExpand, userdata, s, len ); +} + +static void XMLCALL hb_expat_SkippedEntityHandler( void * userdata, + const XML_Char * entityName, + int is_parameter_entity ) +{ + PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; + + if( hb_expat && hb_expat->pVar[ _VAR_bSkippedEntityHandler ] ) + { + if( hb_vmRequestReenter() ) + { + PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); + PHB_ITEM pPar1 = hb_itemPutStrUTF8( NULL, entityName ); + PHB_ITEM pPar2 = hb_itemPutL( NULL, is_parameter_entity ); + + hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bSkippedEntityHandler ], 3, pUserData, pPar1, pPar2 ); + + hb_itemRelease( pPar2 ); + hb_itemRelease( pPar1 ); + hb_itemRelease( pUserData ); + + hb_vmRequestRestore(); + } + } +} + +static int XMLCALL hb_expat_UnknownEncodingHandler( void * userdata, + const XML_Char * name, + XML_Encoding * info ) +{ + PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; + int iResult = XML_STATUS_ERROR; + + if( hb_expat && hb_expat->pVar[ _VAR_bUnknownEncodingHandler ] ) + { + if( hb_vmRequestReenter() ) + { + PHB_ITEM pEncData = hb_itemNew( hb_expat->pVar[ _VAR_xEncodingHandlerData ] ); + PHB_ITEM pPar1 = hb_itemPutStrUTF8( NULL, name ); + PHB_ITEM pPar2 = hb_itemArrayNew( HB_SIZEOFARRAY( info->map ) ); + + iResult = hb_itemGetNI( hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bUnknownEncodingHandler ], 3, pEncData, pPar1, pPar2 ) ); + + if( iResult == XML_STATUS_OK ) + { + HB_UINT tmp; + + for( tmp = 0; tmp < HB_SIZEOFARRAY( info->map ); ++tmp ) + info->map[ tmp ] = hb_arrayGetNI( pPar2, tmp + 1 ); + + /* NOTE: Not supported by wrapper layer yet. */ + info->data = NULL; + info->convert = NULL; + info->release = NULL; + } + + hb_itemRelease( pPar2 ); + hb_itemRelease( pPar1 ); + hb_itemRelease( pEncData ); + + hb_vmRequestRestore(); + } + } + + return iResult; +} + +static void XMLCALL hb_expat_StartNamespaceDeclHandler( void * userdata, + const XML_Char * prefix, + const XML_Char * uri ) +{ + PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; + + if( hb_expat && hb_expat->pVar[ _VAR_bStartNamespaceDeclHandler ] ) + { + if( hb_vmRequestReenter() ) + { + PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); + PHB_ITEM pPar1 = hb_itemPutStrUTF8( NULL, prefix ); + PHB_ITEM pPar2 = hb_itemPutStrUTF8( NULL, uri ); + + hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bStartNamespaceDeclHandler ], 3, pUserData, pPar1, pPar2 ); + + hb_itemRelease( pPar2 ); + hb_itemRelease( pPar1 ); + hb_itemRelease( pUserData ); + + hb_vmRequestRestore(); + } + } +} + +static void XMLCALL hb_expat_EndNamespaceDeclHandler( void * userdata, const XML_Char * prefix ) +{ + hb_expat_hnd_C( _VAR_bEndNamespaceDeclHandler, userdata, prefix ); +} + +static void XMLCALL hb_expat_XmlDeclHandler( void * userdata, + const XML_Char * version, + const XML_Char * encoding, + int standalone ) +{ + PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; + + if( hb_expat && hb_expat->pVar[ _VAR_bXmlDeclHandler ] ) + { + if( hb_vmRequestReenter() ) + { + PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); + PHB_ITEM pPar1 = version ? hb_itemPutStrUTF8( NULL, version ) : hb_itemNew( NULL ); + PHB_ITEM pPar2 = encoding ? hb_itemPutStrUTF8( NULL, encoding ) : hb_itemNew( NULL ); + PHB_ITEM pPar3 = hb_itemPutNI( NULL, standalone ); + + hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bXmlDeclHandler ], 4, pUserData, pPar1, pPar2, pPar3 ); + + hb_itemRelease( pPar3 ); + hb_itemRelease( pPar2 ); + hb_itemRelease( pPar1 ); + hb_itemRelease( pUserData ); + + hb_vmRequestRestore(); + } + } +} + +static void XMLCALL hb_expat_StartDoctypeDeclHandler( void * userdata, + const XML_Char * doctypeName, + const XML_Char * sysid, + const XML_Char * pubid, + int has_internal_subset ) +{ + PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; + + if( hb_expat && hb_expat->pVar[ _VAR_bStartDoctypeDeclHandler ] ) + { + if( hb_vmRequestReenter() ) + { + PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); + PHB_ITEM pPar1 = hb_itemPutStrUTF8( NULL, doctypeName ); + PHB_ITEM pPar2 = sysid ? hb_itemPutStrUTF8( NULL, sysid ) : hb_itemNew( NULL ); + PHB_ITEM pPar3 = pubid ? hb_itemPutStrUTF8( NULL, pubid ) : hb_itemNew( NULL ); + PHB_ITEM pPar4 = hb_itemPutL( NULL, has_internal_subset ); + + hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bStartDoctypeDeclHandler ], 5, pUserData, pPar1, pPar2, pPar3, pPar4 ); + + hb_itemRelease( pPar4 ); + hb_itemRelease( pPar3 ); + hb_itemRelease( pPar2 ); + hb_itemRelease( pPar1 ); + hb_itemRelease( pUserData ); + + hb_vmRequestRestore(); + } + } +} + +static void XMLCALL hb_expat_EndDoctypeDeclHandler( void * userdata ) +{ + hb_expat_hnd_void( _VAR_bEndDoctypeDeclHandler, userdata ); +} + +static void XMLCALL hb_expat_AttlistDeclHandler( void * userdata, + const XML_Char * elname, + const XML_Char * attname, + const XML_Char * att_type, + const XML_Char * dflt, + int isrequired ) +{ + PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; + + if( hb_expat && hb_expat->pVar[ _VAR_bAttlistDeclHandler ] ) + { + if( hb_vmRequestReenter() ) + { + PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); + PHB_ITEM pPar1 = hb_itemPutStrUTF8( NULL, elname ); + PHB_ITEM pPar2 = hb_itemPutStrUTF8( NULL, attname ); + PHB_ITEM pPar3 = hb_itemPutStrUTF8( NULL, att_type ); + PHB_ITEM pPar4 = dflt ? hb_itemPutStrUTF8( NULL, dflt ) : hb_itemNew( NULL ); + PHB_ITEM pPar5 = hb_itemPutL( NULL, isrequired ); + + hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bAttlistDeclHandler ], 6, pUserData, pPar1, pPar2, pPar3, pPar4, pPar5 ); + + hb_itemRelease( pPar5 ); + hb_itemRelease( pPar4 ); + hb_itemRelease( pPar3 ); + hb_itemRelease( pPar2 ); + hb_itemRelease( pPar1 ); + hb_itemRelease( pUserData ); + + hb_vmRequestRestore(); + } + } +} + +static void XMLCALL hb_expat_EntityDeclHandler( void * userdata, + const XML_Char * entityName, + int is_parameter_entity, + const XML_Char * value, + int value_length, + const XML_Char * base, + const XML_Char * systemId, + const XML_Char * publicId, + const XML_Char * notationName ) +{ + PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; + + if( hb_expat && hb_expat->pVar[ _VAR_bEntityDeclHandler ] ) + { + if( hb_vmRequestReenter() ) + { + PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); + PHB_ITEM pPar1 = hb_itemPutStrUTF8( NULL, entityName ); + PHB_ITEM pPar2 = hb_itemPutL( NULL, is_parameter_entity ); + PHB_ITEM pPar3 = value ? hb_itemPutStrLenUTF8( NULL, value, value_length ) : hb_itemNew( NULL ); + PHB_ITEM pPar4 = base ? hb_itemPutStrUTF8( NULL, base ) : hb_itemNew( NULL ); + PHB_ITEM pPar5 = systemId ? hb_itemPutStrUTF8( NULL, systemId ) : hb_itemNew( NULL ); + PHB_ITEM pPar6 = publicId ? hb_itemPutStrUTF8( NULL, publicId ) : hb_itemNew( NULL ); + PHB_ITEM pPar7 = notationName ? hb_itemPutStrUTF8( NULL, notationName ) : hb_itemNew( NULL ); + + hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bEntityDeclHandler ], 8, pUserData, pPar1, pPar2, pPar3, pPar4, pPar5, pPar6, pPar7 ); + + hb_itemRelease( pPar7 ); + hb_itemRelease( pPar6 ); + hb_itemRelease( pPar5 ); + hb_itemRelease( pPar4 ); + hb_itemRelease( pPar3 ); + hb_itemRelease( pPar2 ); + hb_itemRelease( pPar1 ); + hb_itemRelease( pUserData ); + + hb_vmRequestRestore(); + } + } +} + +#if 0 +static void XMLCALL hb_expat_UnparsedEntityDeclHandler( void * userdata, + const XML_Char * entityName, + const XML_Char * base, + const XML_Char * systemId, + const XML_Char * publicId, + const XML_Char * notationName ) +{ + PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; + + if( hb_expat && hb_expat->pVar[ _VAR_bUnparsedEntityDeclHandler ] ) + { + if( hb_vmRequestReenter() ) + { + PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); + PHB_ITEM pPar1 = hb_itemPutStrUTF8( NULL, entityName ); + PHB_ITEM pPar2 = hb_itemPutStrUTF8( NULL, base ); + PHB_ITEM pPar3 = hb_itemPutStrUTF8( NULL, systemId ); + PHB_ITEM pPar4 = hb_itemPutStrUTF8( NULL, publicId ); + PHB_ITEM pPar5 = hb_itemPutStrUTF8( NULL, notationName ); + + hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bUnparsedEntityDeclHandler ], 6, pUserData, pPar1, pPar2, pPar3, pPar4, pPar5 ); + + hb_itemRelease( pPar5 ); + hb_itemRelease( pPar4 ); + hb_itemRelease( pPar3 ); + hb_itemRelease( pPar2 ); + hb_itemRelease( pPar1 ); + hb_itemRelease( pUserData ); + + hb_vmRequestRestore(); + } + } +} +#endif + +static void XMLCALL hb_expat_NotationDeclHandler( void * userdata, + const XML_Char * notationName, + const XML_Char * base, + const XML_Char * systemId, + const XML_Char * publicId ) +{ + PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; + + if( hb_expat && hb_expat->pVar[ _VAR_bNotationDeclHandler ] ) + { + if( hb_vmRequestReenter() ) + { + PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); + PHB_ITEM pPar1 = hb_itemPutStrUTF8( NULL, notationName ); + PHB_ITEM pPar2 = base ? hb_itemPutStrUTF8( NULL, base ) : hb_itemNew( NULL ); + PHB_ITEM pPar3 = systemId ? hb_itemPutStrUTF8( NULL, systemId ) : hb_itemNew( NULL ); + PHB_ITEM pPar4 = publicId ? hb_itemPutStrUTF8( NULL, publicId ) : hb_itemNew( NULL ); + + hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bNotationDeclHandler ], 5, pUserData, pPar1, pPar2, pPar3, pPar4 ); + + hb_itemRelease( pPar4 ); + hb_itemRelease( pPar3 ); + hb_itemRelease( pPar2 ); + hb_itemRelease( pPar1 ); + hb_itemRelease( pUserData ); + + hb_vmRequestRestore(); + } + } +} + +static int XMLCALL hb_expat_NotStandaloneHandler( void * userdata ) +{ + PHB_EXPAT hb_expat = ( PHB_EXPAT ) userdata; + + int iResult = XML_STATUS_ERROR; + + if( hb_expat && hb_expat->pVar[ _VAR_bNotStandaloneHandler ] ) + { + if( hb_vmRequestReenter() ) + { + PHB_ITEM pUserData = hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ); + + iResult = hb_itemGetNI( hb_vmEvalBlockV( hb_expat->pVar[ _VAR_bNotStandaloneHandler ], 1, pUserData ) ); + + hb_itemRelease( pUserData ); + + hb_vmRequestRestore(); + } + } + + return iResult; +} + +/* ---------------------------------------------------------------------------- */ +/* Constructor/Destructor */ + +static void PHB_EXPAT_free( PHB_EXPAT hb_expat, HB_BOOL bFree ) +{ + HB_UINT tmp; + + for( tmp = 0; tmp < HB_SIZEOFARRAY( hb_expat->pVar ); ++tmp ) + { + if( hb_expat->pVar[ tmp ] ) + { + hb_itemRelease( hb_expat->pVar[ tmp ] ); + hb_expat->pVar[ tmp ] = NULL; + } + } + + if( bFree ) + { + XML_SetUserData( hb_expat->parser, NULL ); + XML_ParserFree( hb_expat->parser ); + hb_xfree( hb_expat ); + } +} + +static HB_GARBAGE_FUNC( PHB_EXPAT_release ) +{ + PHB_EXPAT * hb_expat_ptr = ( PHB_EXPAT * ) Cargo; + /* Check if pointer is not NULL to avoid multiple freeing */ + if( hb_expat_ptr && * hb_expat_ptr ) + { + PHB_EXPAT hb_expat = * hb_expat_ptr; + + /* set pointer to NULL to avoid multiple freeing */ + * hb_expat_ptr = NULL; + + /* Destroy the object */ + PHB_EXPAT_free( hb_expat, HB_TRUE ); + } +} + +static HB_GARBAGE_FUNC( PHB_EXPAT_mark ) +{ + PHB_EXPAT * hb_expat_ptr = ( PHB_EXPAT * ) Cargo; + + if( hb_expat_ptr && * hb_expat_ptr ) + { + PHB_EXPAT hb_expat = * hb_expat_ptr; + HB_UINT tmp; + + for( tmp = 0; tmp < HB_SIZEOFARRAY( hb_expat->pVar ); ++tmp ) + { + if( hb_expat->pVar[ tmp ] ) + hb_gcMark( hb_expat->pVar[ tmp ] ); + } + } +} + +static const HB_GC_FUNCS s_gcEXPATFuncs = +{ + PHB_EXPAT_release, + PHB_EXPAT_mark +}; + +static void * PHB_EXPAT_is( int iParam ) +{ + return hb_parptrGC( &s_gcEXPATFuncs, iParam ); +} + +static PHB_EXPAT PHB_EXPAT_par( int iParam ) +{ + void ** ph = ( void ** ) hb_parptrGC( &s_gcEXPATFuncs, iParam ); + + return ph ? ( PHB_EXPAT ) * ph : NULL; +} + +static void hb_expat_setvar( PHB_EXPAT hb_expat, int iHandler, PHB_ITEM pBlock ) +{ + if( hb_expat->pVar[ iHandler ] ) + { + hb_itemRelease( hb_expat->pVar[ iHandler ] ); + hb_expat->pVar[ iHandler ] = NULL; + } + + if( pBlock ) + { + hb_expat->pVar[ iHandler ] = hb_itemNew( pBlock ); + /* unlock the item so GC will not mark them as used */ + hb_gcUnlock( hb_expat->pVar[ iHandler ] ); + } +} + +/* ---------------------------------------------------------------------------- */ +/* Harbour interface */ + +HB_FUNC( XML_PARSERCREATE ) +{ + void ** ph = ( void ** ) hb_gcAllocate( sizeof( PHB_EXPAT ), &s_gcEXPATFuncs ); + + XML_Parser parser; + XML_Memory_Handling_Suite ms; + + void * hEncoding; + void * hSep; + + ms.malloc_fcn = hb_expat_xgrab; + ms.realloc_fcn = hb_expat_xrealloc; + ms.free_fcn = hb_expat_xfree; + + parser = XML_ParserCreate_MM( hb_parstr_utf8( 1, &hEncoding, NULL ), + &ms, + hb_parstr_utf8( 2, &hSep, NULL ) ); + + hb_strfree( hSep ); + hb_strfree( hEncoding ); + + if( parser ) + { + PHB_EXPAT hb_expat = ( PHB_EXPAT ) hb_xgrab( sizeof( HB_EXPAT ) ); + + memset( hb_expat, 0, sizeof( HB_EXPAT ) ); + hb_expat->parser = parser; + + XML_SetUserData( hb_expat->parser, hb_expat ); + + * ph = hb_expat; + } + else + * ph = NULL; + + hb_retptrGC( ph ); +} + +HB_FUNC( XML_PARSERESET ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + if( hb_expat ) + { + void * hEncoding; + + PHB_EXPAT_free( hb_expat, HB_FALSE ); + + XML_ParserReset( hb_expat->parser, + hb_parstr_utf8( 1, &hEncoding, NULL ) ); + + hb_strfree( hEncoding ); + } + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_PARSERFREE ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + void ** ph = ( void ** ) hb_parptrGC( &s_gcEXPATFuncs, 1 ); + + if( ph && * ph ) + { + PHB_EXPAT hb_expat = ( PHB_EXPAT ) * ph; + + /* set pointer to NULL to avoid multiple freeing */ + * ph = NULL; + + /* Destroy the object */ + PHB_EXPAT_free( hb_expat, HB_TRUE ); + } + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_SETUSERDATA ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + hb_expat_setvar( hb_expat, _VAR_xUserData, hb_param( 2, HB_IT_ANY ) ); + + hb_ret(); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_GETUSERDATA ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + hb_itemReturnRelease( hb_itemNew( hb_expat->pVar[ _VAR_xUserData ] ) ); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_SETELEMENTHANDLER ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + hb_expat_setvar( hb_expat, _VAR_bStartElementHandler, hb_param( 2, HB_IT_BLOCK ) ); + hb_expat_setvar( hb_expat, _VAR_bEndElementHandler, hb_param( 3, HB_IT_BLOCK ) ); + + XML_SetElementHandler( hb_expat->parser, + hb_expat->pVar[ _VAR_bStartElementHandler ] ? hb_expat_StartElementHandler : NULL, + hb_expat->pVar[ _VAR_bEndElementHandler ] ? hb_expat_EndElementHandler : NULL ); + + hb_ret(); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_SETCDATASECTIONHANDLER ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + hb_expat_setvar( hb_expat, _VAR_bStartCdataSectionHandler, hb_param( 2, HB_IT_BLOCK ) ); + hb_expat_setvar( hb_expat, _VAR_bEndCdataSectionHandler, hb_param( 3, HB_IT_BLOCK ) ); + + XML_SetCdataSectionHandler( hb_expat->parser, + hb_expat->pVar[ _VAR_bStartCdataSectionHandler ] ? hb_expat_StartCdataSectionHandler : NULL, + hb_expat->pVar[ _VAR_bEndCdataSectionHandler ] ? hb_expat_EndCdataSectionHandler : NULL ); + + hb_ret(); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_SETNAMESPACEDECLHANDLER ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + hb_expat_setvar( hb_expat, _VAR_bStartNamespaceDeclHandler, hb_param( 2, HB_IT_BLOCK ) ); + hb_expat_setvar( hb_expat, _VAR_bEndNamespaceDeclHandler, hb_param( 3, HB_IT_BLOCK ) ); + + XML_SetNamespaceDeclHandler( hb_expat->parser, + hb_expat->pVar[ _VAR_bStartNamespaceDeclHandler ] ? hb_expat_StartNamespaceDeclHandler : NULL, + hb_expat->pVar[ _VAR_bEndNamespaceDeclHandler ] ? hb_expat_EndNamespaceDeclHandler : NULL ); + + hb_ret(); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_SETUNKNOWNENCODINGHANDLER ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + hb_expat_setvar( hb_expat, _VAR_bUnknownEncodingHandler, hb_param( 2, HB_IT_BLOCK ) ); + hb_expat_setvar( hb_expat, _VAR_xEncodingHandlerData, hb_param( 3, HB_IT_ANY ) ); + + XML_SetUnknownEncodingHandler( hb_expat->parser, + hb_expat->pVar[ _VAR_bUnknownEncodingHandler ] ? hb_expat_UnknownEncodingHandler : NULL, + hb_expat ); + + hb_ret(); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +/* ; */ + +HB_FUNC( XML_PARSE ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + hb_retni( XML_Parse( hb_expat->parser, hb_parcx( 2 ), ( int ) hb_parclen( 2 ), ( int ) hb_parl( 3 ) ) ); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_GETERRORCODE ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + hb_retni( ( int ) XML_GetErrorCode( hb_expat->parser ) ); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_ERRORSTRING ) +{ + hb_retc( XML_ErrorString( ( enum XML_Error ) hb_parni( 1 ) ) ); +} + +HB_FUNC( XML_GETCURRENTBYTEINDEX ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + hb_retns( XML_GetCurrentByteIndex( hb_expat->parser ) ); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_GETCURRENTLINENUMBER ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + hb_retns( XML_GetCurrentLineNumber( hb_expat->parser ) ); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_GETCURRENTCOLUMNNUMBER ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + hb_retns( XML_GetCurrentColumnNumber( hb_expat->parser ) ); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_GETCURRENTBYTECOUNT ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + hb_retni( XML_GetCurrentByteCount( hb_expat->parser ) ); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_SETBASE ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + void * hBase; + + hb_retni( ( int ) XML_SetBase( hb_expat->parser, hb_parstr_utf8( 1, &hBase, NULL ) ) ); + + hb_strfree( hBase ); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_GETBASE ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + hb_retstr_utf8( XML_GetBase( hb_expat->parser ) ); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_GETSPECIFIEDATTRIBUTECOUNT ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + hb_retni( XML_GetSpecifiedAttributeCount( hb_expat->parser ) ); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_GETIDATTRIBUTEINDEX ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + hb_retni( XML_GetIdAttributeIndex( hb_expat->parser ) ); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_SETENCODING ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + void * hEncoding; + + hb_retni( ( int ) XML_SetEncoding( hb_expat->parser, + hb_parstr_utf8( 1, &hEncoding, NULL ) ) ); + + hb_strfree( hEncoding ); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_SETPARAMENTITYPARSING ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + hb_retni( XML_SetParamEntityParsing( hb_expat->parser, ( enum XML_ParamEntityParsing ) hb_parni( 2 ) ) ); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_USEFOREIGNDTD ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + hb_retni( ( int ) XML_UseForeignDTD( hb_expat->parser, ( XML_Bool ) hb_parl( 2 ) ) ); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_SETRETURNNSTRIPLET ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + XML_SetReturnNSTriplet( hb_expat->parser, hb_parni( 2 ) ); + + hb_ret(); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_DEFAULTCURRENT ) +{ + if( PHB_EXPAT_is( 1 ) ) + { + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + XML_DefaultCurrent( hb_expat->parser ); + + hb_ret(); + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_STOPPARSER ) +{ + if( PHB_EXPAT_is( 1 ) ) + { +#if HB_EXPAT_VERS( 1, 95, 8 ) + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + hb_retni( ( int ) XML_StopParser( hb_expat->parser, hb_parl( 2 ) ) ); +#else + hb_retni( HB_XML_ERROR_NOT_IMPLEMENTED_ ); +#endif + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_RESUMEPARSER ) +{ + if( PHB_EXPAT_is( 1 ) ) + { +#if HB_EXPAT_VERS( 1, 95, 8 ) + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + + hb_retni( ( int ) XML_ResumeParser( hb_expat->parser ) ); +#else + hb_retni( HB_XML_ERROR_NOT_IMPLEMENTED_ ); +#endif + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_GETPARSINGSTATUS ) +{ + if( PHB_EXPAT_is( 1 ) ) + { +#if HB_EXPAT_VERS( 1, 95, 8 ) + PHB_EXPAT hb_expat = PHB_EXPAT_par( 1 ); + XML_ParsingStatus status; + + XML_GetParsingStatus( hb_expat->parser, &status ); + + hb_storni( ( int ) status->parsing, 2 ); + hb_storl( ( HB_BOOL ) status->finalBuffer, 3 ); +#else + hb_storni( -1, 2 ); + hb_storl( HB_FALSE, 3 ); +#endif + } + else + hb_errRT_BASE( EG_ARG, 2020, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS ); +} + +HB_FUNC( XML_EXPATVERSION ) +{ + hb_retc( XML_ExpatVersion() ); +} + +HB_FUNC( XML_EXPATVERSIONINFO ) +{ + XML_Expat_Version var = XML_ExpatVersionInfo(); + + hb_storni( var.major, 1 ); + hb_storni( var.minor, 2 ); + hb_storni( var.micro, 3 ); +} + +HB_FUNC( HB_XML_EXPATVERSIONINFO ) +{ + hb_storni( XML_MAJOR_VERSION, 1 ); + hb_storni( XML_MINOR_VERSION, 2 ); + hb_storni( XML_MICRO_VERSION, 3 ); +} + +HB_EXPAT_SETHANDLER( STARTELEMENTHANDLER , StartElementHandler ) +HB_EXPAT_SETHANDLER( ENDELEMENTHANDLER , EndElementHandler ) +HB_EXPAT_SETHANDLER( CHARACTERDATAHANDLER , CharacterDataHandler ) +HB_EXPAT_SETHANDLER( PROCESSINGINSTRUCTIONHANDLER, ProcessingInstructionHandler ) +HB_EXPAT_SETHANDLER( COMMENTHANDLER , CommentHandler ) +HB_EXPAT_SETHANDLER( STARTCDATASECTIONHANDLER , StartCdataSectionHandler ) +HB_EXPAT_SETHANDLER( ENDCDATASECTIONHANDLER , EndCdataSectionHandler ) +HB_EXPAT_SETHANDLER( DEFAULTHANDLER , DefaultHandler ) +HB_EXPAT_SETHANDLER( DEFAULTHANDLEREXPAND , DefaultHandlerExpand ) +HB_EXPAT_SETHANDLER( SKIPPEDENTITYHANDLER , SkippedEntityHandler ) +HB_EXPAT_SETHANDLER( STARTNAMESPACEDECLHANDLER , StartNamespaceDeclHandler ) +HB_EXPAT_SETHANDLER( ENDNAMESPACEDECLHANDLER , EndNamespaceDeclHandler ) +HB_EXPAT_SETHANDLER( XMLDECLHANDLER , XmlDeclHandler ) +HB_EXPAT_SETHANDLER( STARTDOCTYPEDECLHANDLER , StartDoctypeDeclHandler ) +HB_EXPAT_SETHANDLER( ENDDOCTYPEDECLHANDLER , EndDoctypeDeclHandler ) +HB_EXPAT_SETHANDLER( ATTLISTDECLHANDLER , AttlistDeclHandler ) +HB_EXPAT_SETHANDLER( ENTITYDECLHANDLER , EntityDeclHandler ) +#if 0 /* Obsolete */ +HB_EXPAT_SETHANDLER( UNPARSEDENTITYDECLHANDLER , UnparsedEntityDeclHandler ) +#endif +HB_EXPAT_SETHANDLER( NOTATIONDECLHANDLER , NotationDeclHandler ) +HB_EXPAT_SETHANDLER( NOTSTANDALONEHANDLER , NotStandaloneHandler ) diff --git a/harbour/contrib/hbexpat/hbexpat.ch b/harbour/contrib/hbexpat/hbexpat.ch index af18a0e6a5..2de0418383 100644 --- a/harbour/contrib/hbexpat/hbexpat.ch +++ b/harbour/contrib/hbexpat/hbexpat.ch @@ -1,113 +1,113 @@ -/* - * $Id: hbexpat.ch 1965 2010-08-28 13:19:42Z vszakats $ - */ - -/* - * Harbour Project source code: - * expat API - Harbour header - * - * Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) - * www - http://harbour-project.org - * - * 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, 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 software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -/* NOTE: This file is also used by C code. */ - -#ifndef HBEXPAT_CH_ -#define HBEXPAT_CH_ - -#define HB_XML_STATUS_ERROR 0 -#define HB_XML_STATUS_OK 1 - -#define HB_XML_ERROR_NOT_IMPLEMENTED_ ( -1 ) /* Harbour specific */ -#define HB_XML_ERROR_NONE 0 -#define HB_XML_ERROR_NO_MEMORY 1 -#define HB_XML_ERROR_SYNTAX 2 -#define HB_XML_ERROR_NO_ELEMENTS 3 -#define HB_XML_ERROR_INVALID_TOKEN 4 -#define HB_XML_ERROR_UNCLOSED_TOKEN 5 -#define HB_XML_ERROR_PARTIAL_CHAR 6 -#define HB_XML_ERROR_TAG_MISMATCH 7 -#define HB_XML_ERROR_DUPLICATE_ATTRIBUTE 8 -#define HB_XML_ERROR_JUNK_AFTER_DOC_ELEMENT 9 -#define HB_XML_ERROR_PARAM_ENTITY_REF 10 -#define HB_XML_ERROR_UNDEFINED_ENTITY 11 -#define HB_XML_ERROR_RECURSIVE_ENTITY_REF 12 -#define HB_XML_ERROR_ASYNC_ENTITY 13 -#define HB_XML_ERROR_BAD_CHAR_REF 14 -#define HB_XML_ERROR_BINARY_ENTITY_REF 15 -#define HB_XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF 16 -#define HB_XML_ERROR_MISPLACED_XML_PI 17 -#define HB_XML_ERROR_UNKNOWN_ENCODING 18 -#define HB_XML_ERROR_INCORRECT_ENCODING 19 -#define HB_XML_ERROR_UNCLOSED_CDATA_SECTION 20 -#define HB_XML_ERROR_EXTERNAL_ENTITY_HANDLING 21 -#define HB_XML_ERROR_NOT_STANDALONE 22 -#define HB_XML_ERROR_UNEXPECTED_STATE 23 -#define HB_XML_ERROR_ENTITY_DECLARED_IN_PE 24 -#define HB_XML_ERROR_FEATURE_REQUIRES_XML_DTD 25 -#define HB_XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING 26 -#define HB_XML_ERROR_UNBOUND_PREFIX 27 -#define HB_XML_ERROR_UNDECLARING_PREFIX 28 -#define HB_XML_ERROR_INCOMPLETE_PE 29 -#define HB_XML_ERROR_XML_DECL 30 -#define HB_XML_ERROR_TEXT_DECL 31 -#define HB_XML_ERROR_PUBLICID 32 -#define HB_XML_ERROR_SUSPENDED 33 -#define HB_XML_ERROR_NOT_SUSPENDED 34 -#define HB_XML_ERROR_ABORTED 35 -#define HB_XML_ERROR_FINISHED 36 -#define HB_XML_ERROR_SUSPEND_PE 37 -#define HB_XML_ERROR_RESERVED_PREFIX_XML 38 -#define HB_XML_ERROR_RESERVED_PREFIX_XMLNS 39 -#define HB_XML_ERROR_RESERVED_NAMESPACE_URI 40 - -#define HB_XML_INITIALIZED 0 -#define HB_XML_PARSING 1 -#define HB_XML_FINISHED 2 -#define HB_XML_SUSPENDED 3 - -#define HB_XML_PARAM_ENTITY_PARSING_NEVER 0 -#define HB_XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE 1 -#define HB_XML_PARAM_ENTITY_PARSING_ALWAYS 2 - -#endif /* HBEXPAT_CH_ */ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * expat API - Harbour header + * + * Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) + * www - http://harbour-project.org + * + * 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, 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 software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + +/* NOTE: This file is also used by C code. */ + +#ifndef HBEXPAT_CH_ +#define HBEXPAT_CH_ + +#define HB_XML_STATUS_ERROR 0 +#define HB_XML_STATUS_OK 1 + +#define HB_XML_ERROR_NOT_IMPLEMENTED_ ( -1 ) /* Harbour specific */ +#define HB_XML_ERROR_NONE 0 +#define HB_XML_ERROR_NO_MEMORY 1 +#define HB_XML_ERROR_SYNTAX 2 +#define HB_XML_ERROR_NO_ELEMENTS 3 +#define HB_XML_ERROR_INVALID_TOKEN 4 +#define HB_XML_ERROR_UNCLOSED_TOKEN 5 +#define HB_XML_ERROR_PARTIAL_CHAR 6 +#define HB_XML_ERROR_TAG_MISMATCH 7 +#define HB_XML_ERROR_DUPLICATE_ATTRIBUTE 8 +#define HB_XML_ERROR_JUNK_AFTER_DOC_ELEMENT 9 +#define HB_XML_ERROR_PARAM_ENTITY_REF 10 +#define HB_XML_ERROR_UNDEFINED_ENTITY 11 +#define HB_XML_ERROR_RECURSIVE_ENTITY_REF 12 +#define HB_XML_ERROR_ASYNC_ENTITY 13 +#define HB_XML_ERROR_BAD_CHAR_REF 14 +#define HB_XML_ERROR_BINARY_ENTITY_REF 15 +#define HB_XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF 16 +#define HB_XML_ERROR_MISPLACED_XML_PI 17 +#define HB_XML_ERROR_UNKNOWN_ENCODING 18 +#define HB_XML_ERROR_INCORRECT_ENCODING 19 +#define HB_XML_ERROR_UNCLOSED_CDATA_SECTION 20 +#define HB_XML_ERROR_EXTERNAL_ENTITY_HANDLING 21 +#define HB_XML_ERROR_NOT_STANDALONE 22 +#define HB_XML_ERROR_UNEXPECTED_STATE 23 +#define HB_XML_ERROR_ENTITY_DECLARED_IN_PE 24 +#define HB_XML_ERROR_FEATURE_REQUIRES_XML_DTD 25 +#define HB_XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING 26 +#define HB_XML_ERROR_UNBOUND_PREFIX 27 +#define HB_XML_ERROR_UNDECLARING_PREFIX 28 +#define HB_XML_ERROR_INCOMPLETE_PE 29 +#define HB_XML_ERROR_XML_DECL 30 +#define HB_XML_ERROR_TEXT_DECL 31 +#define HB_XML_ERROR_PUBLICID 32 +#define HB_XML_ERROR_SUSPENDED 33 +#define HB_XML_ERROR_NOT_SUSPENDED 34 +#define HB_XML_ERROR_ABORTED 35 +#define HB_XML_ERROR_FINISHED 36 +#define HB_XML_ERROR_SUSPEND_PE 37 +#define HB_XML_ERROR_RESERVED_PREFIX_XML 38 +#define HB_XML_ERROR_RESERVED_PREFIX_XMLNS 39 +#define HB_XML_ERROR_RESERVED_NAMESPACE_URI 40 + +#define HB_XML_INITIALIZED 0 +#define HB_XML_PARSING 1 +#define HB_XML_FINISHED 2 +#define HB_XML_SUSPENDED 3 + +#define HB_XML_PARAM_ENTITY_PARSING_NEVER 0 +#define HB_XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE 1 +#define HB_XML_PARAM_ENTITY_PARSING_ALWAYS 2 + +#endif /* HBEXPAT_CH_ */ diff --git a/harbour/contrib/hbexpat/hbexpat.hbc b/harbour/contrib/hbexpat/hbexpat.hbc index 4329c085df..2e516f60b9 100644 --- a/harbour/contrib/hbexpat/hbexpat.hbc +++ b/harbour/contrib/hbexpat/hbexpat.hbc @@ -1,8 +1,8 @@ -# -# $Id: hbexpat.hbc 1965 2010-08-28 13:19:42Z vszakats $ -# - -incpaths=. - -libs=${hb_name} -libs=3rd/expat/expat.hbc +# +# $Id$ +# + +incpaths=. + +libs=${hb_name} +libs=3rd/expat/expat.hbc diff --git a/harbour/contrib/hbexpat/hbexpat.hbp b/harbour/contrib/hbexpat/hbexpat.hbp index 59492ac1ea..ab100b91b4 100644 --- a/harbour/contrib/hbexpat/hbexpat.hbp +++ b/harbour/contrib/hbexpat/hbexpat.hbp @@ -1,27 +1,27 @@ -# -# $Id: hbexpat.hbp 1965 2010-08-28 13:19:42Z vszakats $ -# - --hblib --inc - --o${hb_targetname} - --w3 -es2 - --depkeyhead=expat:expat.h --depcontrol=expat:no{HB_BUILD_3RDEXT='no'} --depcontrol=expat:${HB_WITH_EXPAT} --depincpath=expat:/usr/include --depincpathlocal=expat:3rd/expat --depfinish=expat - --instfile=inc:hbexpat.ch --instfile=inc:hbexpatx.ch - -hbexpat.c -hbexpatc.c -hbexpatp.prg -hbexpatx.prg - -3rd/expat/expat.hbc{HBMK_HAS_EXPAT_LOCAL} +# +# $Id$ +# + +-hblib +-inc + +-o${hb_targetname} + +-w3 -es2 + +-depkeyhead=expat:expat.h +-depcontrol=expat:no{HB_BUILD_3RDEXT='no'} +-depcontrol=expat:${HB_WITH_EXPAT} +-depincpath=expat:/usr/include +-depincpathlocal=expat:3rd/expat +-depfinish=expat + +-instfile=inc:hbexpat.ch +-instfile=inc:hbexpatx.ch + +hbexpat.c +hbexpatc.c +hbexpatp.prg +hbexpatx.prg + +3rd/expat/expat.hbc{HBMK_HAS_EXPAT_LOCAL} diff --git a/harbour/contrib/hbexpat/hbexpatc.c b/harbour/contrib/hbexpat/hbexpatc.c index 706c379e0e..87898fd1a1 100644 --- a/harbour/contrib/hbexpat/hbexpatc.c +++ b/harbour/contrib/hbexpat/hbexpatc.c @@ -1,72 +1,72 @@ -/* - * $Id: hbexpatc.c 1965 2010-08-28 13:19:42Z vszakats $ - */ - -/* - * Harbour Project source code: - * expat API - Harbour complementary functions - * - * Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) - * www - http://harbour-project.org - * - * 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, 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 software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -#include "hbapicdp.h" -#include "hbapiitm.h" - -HB_FUNC( __HB_XML_CDPU16MAP ) -{ - PHB_CODEPAGE cdp = hb_cdpFindExt( hb_parcx( 1 ) ); - - if( cdp ) - { - PHB_ITEM pMap = hb_itemArrayNew( UCHAR_MAX + 1 ); - int tmp; - - for( tmp = 0; tmp <= UCHAR_MAX; ++tmp ) - hb_arraySetNI( pMap, tmp + 1, hb_cdpGetU16( cdp, HB_FALSE, ( HB_UCHAR ) tmp ) ); - - hb_itemReturnRelease( pMap ); - } - else - hb_ret(); -} +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * expat API - Harbour complementary functions + * + * Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) + * www - http://harbour-project.org + * + * 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, 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 software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + +#include "hbapicdp.h" +#include "hbapiitm.h" + +HB_FUNC( __HB_XML_CDPU16MAP ) +{ + PHB_CODEPAGE cdp = hb_cdpFindExt( hb_parcx( 1 ) ); + + if( cdp ) + { + PHB_ITEM pMap = hb_itemArrayNew( UCHAR_MAX + 1 ); + int tmp; + + for( tmp = 0; tmp <= UCHAR_MAX; ++tmp ) + hb_arraySetNI( pMap, tmp + 1, hb_cdpGetU16( cdp, HB_FALSE, ( HB_UCHAR ) tmp ) ); + + hb_itemReturnRelease( pMap ); + } + else + hb_ret(); +} diff --git a/harbour/contrib/hbexpat/hbexpatp.prg b/harbour/contrib/hbexpat/hbexpatp.prg index b0bd357732..f560734701 100644 --- a/harbour/contrib/hbexpat/hbexpatp.prg +++ b/harbour/contrib/hbexpat/hbexpatp.prg @@ -1,75 +1,75 @@ -/* - * $Id: hbexpatp.prg 1965 2010-08-28 13:19:42Z vszakats $ - */ - -/* - * Harbour Project source code: - * expat API - Harbour complementary functions - * - * Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) - * www - http://harbour-project.org - * - * 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, 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 software; see the file COPYING. If not, write to - * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, - * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). - * - * As a special exception, the Harbour Project gives permission for - * additional uses of the text contained in its release of Harbour. - * - * The exception is that, if you link the Harbour libraries with other - * files to produce an executable, this does not by itself cause the - * resulting executable to be covered by the GNU General Public License. - * Your use of that executable is in no way restricted on account of - * linking the Harbour library code into it. - * - * This exception does not however invalidate any other reasons why - * the executable file might be covered by the GNU General Public License. - * - * This exception applies only to the code released by the Harbour - * Project under the name Harbour. If you copy code from other - * Harbour Project or Free Software Foundation releases into a copy of - * Harbour, as the General Public License permits, the exception does - * not apply to the code that you add in this way. To avoid misleading - * anyone as to the status of such modified files, you must delete - * this exception notice from them. - * - * If you write modifications of your own for Harbour, it is your choice - * whether to permit this exception to apply to your modifications. - * If you do not wish that, delete this exception notice. - * - */ - -#include "hbextcdp.ch" - -#define _UNI_NAME_NORM( s ) StrTran( StrTran( StrTran( s, "-" ), "." ), " " ) - -FUNCTION hb_xml_get_unicode_table( cCP ) - STATIC s_uni := NIL - - LOCAL cdp - - IF s_uni == NIL - /* Gather full list of unicode tables supported by codepage modules. */ - s_uni := { => } - FOR EACH cdp IN hb_cdpList() - s_uni[ _UNI_NAME_NORM( hb_cdpUniID( cdp ) ) ] := cdp - NEXT - ENDIF - - cCP := _UNI_NAME_NORM( cCP ) - IF cCP $ s_uni - RETURN __hb_xml_cdpu16map( s_uni[ cCP ] ) - ENDIF - - RETURN NIL +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * expat API - Harbour complementary functions + * + * Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) + * www - http://harbour-project.org + * + * 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, 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 software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + +#include "hbextcdp.ch" + +#define _UNI_NAME_NORM( s ) StrTran( StrTran( StrTran( s, "-" ), "." ), " " ) + +FUNCTION hb_xml_get_unicode_table( cCP ) + STATIC s_uni := NIL + + LOCAL cdp + + IF s_uni == NIL + /* Gather full list of unicode tables supported by codepage modules. */ + s_uni := { => } + FOR EACH cdp IN hb_cdpList() + s_uni[ _UNI_NAME_NORM( hb_cdpUniID( cdp ) ) ] := cdp + NEXT + ENDIF + + cCP := _UNI_NAME_NORM( cCP ) + IF cCP $ s_uni + RETURN __hb_xml_cdpu16map( s_uni[ cCP ] ) + ENDIF + + RETURN NIL diff --git a/harbour/contrib/hbqt/qtuitools/hbqtuitools.hbc b/harbour/contrib/hbqt/qtuitools/hbqtuitools.hbc index b29d69d81e..8b8ec207c0 100644 --- a/harbour/contrib/hbqt/qtuitools/hbqtuitools.hbc +++ b/harbour/contrib/hbqt/qtuitools/hbqtuitools.hbc @@ -1,16 +1,16 @@ -# -# $Id: hbqtnetwork.hbc 15328 2010-08-06 12:35:40Z vszakats $ -# - -# --------------------------------------------------------------- -# Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) -# See COPYING for licensing terms. -# --------------------------------------------------------------- - -incpaths=. - -libs=../qtgui/hbqtgui.hbc - -libs=hbqtuitools${__HB_DYN__} -{!HB_STATIC_QT}libs=QtUiTools -{HB_STATIC_QT&(allwin|linux)}libs=QtUiTools +# +# $Id$ +# + +# --------------------------------------------------------------- +# Copyright 2010 Viktor Szakats (harbour.01 syenar.hu) +# See COPYING for licensing terms. +# --------------------------------------------------------------- + +incpaths=. + +libs=../qtgui/hbqtgui.hbc + +libs=hbqtuitools${__HB_DYN__} +{!HB_STATIC_QT}libs=QtUiTools +{HB_STATIC_QT&(allwin|linux)}libs=QtUiTools diff --git a/harbour/contrib/hbqt/qtuitools/hbqtuitools.hbm b/harbour/contrib/hbqt/qtuitools/hbqtuitools.hbm index b7d482a0ef..94b55e26c5 100644 --- a/harbour/contrib/hbqt/qtuitools/hbqtuitools.hbm +++ b/harbour/contrib/hbqt/qtuitools/hbqtuitools.hbm @@ -1,15 +1,15 @@ -# -# $Id: hbqtnetwork.hbm 15310 2010-08-04 20:04:53Z vszakats $ -# - --i. - -qth/filelist.hbm - -hbqt_init.cpp - -hbqt_extern.prg - -THbQtUILoader.prg - -../qtgui/hbqtgui.hbc +# +# $Id$ +# + +-i. + +qth/filelist.hbm + +hbqt_init.cpp + +hbqt_extern.prg + +THbQtUILoader.prg + +../qtgui/hbqtgui.hbc diff --git a/harbour/contrib/hbqt/qtuitools/hbqtuitools.hbp b/harbour/contrib/hbqt/qtuitools/hbqtuitools.hbp index 7492a75457..ae6ff71319 100644 --- a/harbour/contrib/hbqt/qtuitools/hbqtuitools.hbp +++ b/harbour/contrib/hbqt/qtuitools/hbqtuitools.hbp @@ -1,9 +1,9 @@ -# -# $Id: hbqtnetwork.hbp 15310 2010-08-04 20:04:53Z vszakats $ -# - -../hbqt_common.hbm - -hbqtuitools.hbm - --instfile=inc:hbqtuitools.hbx +# +# $Id$ +# + +../hbqt_common.hbm + +hbqtuitools.hbm + +-instfile=inc:hbqtuitools.hbx diff --git a/harbour/contrib/hbqt/tests/testres.prg b/harbour/contrib/hbqt/tests/testres.prg index 0fd1cdff2f..13f708a2b0 100644 --- a/harbour/contrib/hbqt/tests/testres.prg +++ b/harbour/contrib/hbqt/tests/testres.prg @@ -1,55 +1,55 @@ -/* - * $Id: qtver.prg 14742 2010-06-10 21:02:20Z vszakats $ - */ - -/* - * Harbour Project source code: - * - * Copyright 2010 Carlos Bacco - * www - http://harbour-project.org - * - */ - -#include "hbqtgui.ch" - -#include "hbtrace.ch" - -#include "common.ch" - -STATIC s_qApp -STATIC s_re1 - -INIT PROCEDURE Qt_Start() - s_qApp := QApplication() - s_re1 := QResource() - s_re1:registerResource_1( HBQTRES_TESTRES() ) - RETURN - -EXIT PROCEDURE Qt_End() - s_re1:unregisterResource_1( HBQTRES_TESTRES() ) - s_qApp:quit() - RETURN - -PROCEDURE Main() - LOCAL oWnd - LOCAL oDA - LOCAL lb1 - LOCAL ly1 - - oWnd := QMainWindow() - oWnd:setWindowIcon( ":harbour-icon.png" ) - - oDA := QWidget() - oWnd:setCentralWidget( oDA ) - - lb1 := Qlabel() - lb1:setAlignment( hb_bitOr( Qt_AlignHCenter, Qt_AlignVCenter ) ) - lb1:setPixMap( QPixMap( ":harbour-logo.png" ) ) - - ly1 := QVBoxLayout( oDA ) - ly1:addWidget( lb1 ) - - oWnd:Show() - s_qApp:exec() - - RETURN +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * + * Copyright 2010 Carlos Bacco + * www - http://harbour-project.org + * + */ + +#include "hbqtgui.ch" + +#include "hbtrace.ch" + +#include "common.ch" + +STATIC s_qApp +STATIC s_re1 + +INIT PROCEDURE Qt_Start() + s_qApp := QApplication() + s_re1 := QResource() + s_re1:registerResource_1( HBQTRES_TESTRES() ) + RETURN + +EXIT PROCEDURE Qt_End() + s_re1:unregisterResource_1( HBQTRES_TESTRES() ) + s_qApp:quit() + RETURN + +PROCEDURE Main() + LOCAL oWnd + LOCAL oDA + LOCAL lb1 + LOCAL ly1 + + oWnd := QMainWindow() + oWnd:setWindowIcon( ":harbour-icon.png" ) + + oDA := QWidget() + oWnd:setCentralWidget( oDA ) + + lb1 := Qlabel() + lb1:setAlignment( hb_bitOr( Qt_AlignHCenter, Qt_AlignVCenter ) ) + lb1:setPixMap( QPixMap( ":harbour-logo.png" ) ) + + ly1 := QVBoxLayout( oDA ) + ly1:addWidget( lb1 ) + + oWnd:Show() + s_qApp:exec() + + RETURN