Files
harbour-core/contrib/hbexpat/tests/test.prg
Aleksander Czajczynski 6e3fe511f0 2017-12-14 14:20 UTC+0100 Aleksander Czajczynski (hb fki.pl)
* contrib/hbamf/amfenc.c
    * update amf3_Encode() serialize function with great idea of Przemek
      implemented recenly in hb_Serialize(). Checking garbage collector
      reference count can save time here too, unique arrays and hashes won't
      be indexed as references.

  * contrib/hbexpat/3rd/expat/*
    ! updated to 2.2.5 (from 2.2.1) using 3rdpatch.hb, expat.diff from
      Viktor's 3.4 fork was used - but (again) adapted for DOS 8.3 naming
      scheme. Also i've kept local patches for WinCE, OpenWatcom DOS/OS2,
      please test. Compilation in CPP mode is explicitly disabled for libexpat
      now, as upstream decided to ignore such use cases completly.

   * contrib/hbexpat/*
     * synced with Viktor's 3.4 fork

   + include/hbarc4.h
   * src/harbour.def
     + export ARC4 core routines like in 3.4 fork, updated expat lib reuses it.

   * contrib/hbtip/hbtip.hbp
     ! adapt *.hbx file specifier to hbmk2 3.2 syntax
2017-12-14 14:21:03 +01:00

83 lines
1.8 KiB
Plaintext

/* Copyright 2010 Viktor Szakats (vszakats.net/harbour) */
#require "hbexpat"
#include "simpleio.ch"
REQUEST HB_CODEPAGE_UTF8EX
PROCEDURE Main( cFileName )
LOCAL p := XML_ParserCreate()
LOCAL aUserData
LOCAL v1, v2, v3
hb_cdpSelect( "UTF8EX" )
hb_SetTermCP( hb_cdpTerm() )
? XML_ExpatVersion()
XML_ExpatVersionInfo( @v1, @v2, @v3 )
? hb_ntos( v1 ) + "." + hb_ntos( v2 ) + "." + hb_ntos( v3 )
hb_XML_ExpatVersionInfo( @v1, @v2, @v3 )
? hb_ntos( v1 ) + "." + hb_ntos( v2 ) + "." + hb_ntos( v3 )
IF Empty( p )
? "Couldn't allocate memory for parser"
ErrorLevel( -1 )
RETURN
ENDIF
aUserData := Array( 1 )
aUserData[ 1 ] := 1
? XML_GetUserData( p )
XML_SetUserData( p, aUserData )
? ValType( XML_GetUserData( p ) )
XML_SetElementHandler( p, {| x, e, a | cb_start( x, e, a ) }, {| x, e | cb_end( x, e ) } )
XML_SetCharacterDataHandler( p, {| x, d | cb_data( x, d ) } )
IF XML_Parse( p, MemoRead( hb_defaultValue( cFileName, hb_DirBase() + "test.xml" ) ), .T. ) == HB_XML_STATUS_ERROR
? hb_StrFormat( e"Parse error at line %1$d:\n%2$s", ;
XML_GetCurrentLineNumber( p ), ;
XML_ErrorString( XML_GetErrorCode( p ) ) )
ErrorLevel( -1 )
RETURN
ENDIF
RETURN
STATIC PROCEDURE cb_start( aUserData, cElement, aAttr )
LOCAL aItem
? Replicate( " ", aUserData[ 1 ] ), cElement
IF ! Empty( aAttr )
FOR EACH aItem IN aAttr
?? "", aItem[ HB_XML_ATTR_cName ] + "='" + aItem[ HB_XML_ATTR_cValue ] + "'"
NEXT
ENDIF
++aUserData[ 1 ]
RETURN
STATIC PROCEDURE cb_end( aUserData, cElement )
HB_SYMBOL_UNUSED( aUserData )
HB_SYMBOL_UNUSED( cElement )
--aUserData[ 1 ]
RETURN
STATIC PROCEDURE cb_data( aUserData, cData )
HB_SYMBOL_UNUSED( aUserData )
IF ! Empty( cData )
?? "", "'" + cData + "'"
ENDIF
RETURN