From a6e246cfc3a7ea0c516e948ab6d2d8756a7ee283 Mon Sep 17 00:00:00 2001 From: Petr Chornyj Date: Fri, 7 Jan 2011 16:29:40 +0000 Subject: [PATCH] 2011-01-07 18:30 UTC+0200 Petr Chornyj (myorg63 at mail.ru) * ChangeLog ! Fixed previous entry * contrib/hbmxml/3rd/minixml/config.h * contrib/hbmxml/hbmxml.c * contrib/hbmxml/hbmxml.ch * Minor/cosmetic changes * contrib/hbmxml/hbmxml.hbp + hbmxml/hbmxmlp.prg Added mxmlSetTextf()/mxmlNetTextf()/mxmlElementSetAttrf --- harbour/ChangeLog | 16 ++++ harbour/contrib/hbmxml/3rd/minixml/config.h | 64 +++++++------- harbour/contrib/hbmxml/hbmxml.c | 13 ++- harbour/contrib/hbmxml/hbmxml.ch | 2 +- harbour/contrib/hbmxml/hbmxml.hbp | 1 + harbour/contrib/hbmxml/hbmxmlp.prg | 95 +++++++++++++++++++++ 6 files changed, 147 insertions(+), 44 deletions(-) create mode 100644 harbour/contrib/hbmxml/hbmxmlp.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index b8742ac13f..11369db83d 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,22 @@ The license applies to all entries newer than 2009-04-28. */ +2011-01-07 18:30 UTC+0200 Petr Chornyj (myorg63 at mail.ru) + * ChangeLog + ! Fixed previous entry + * contrib/hbmxml/3rd/minixml/config.h + * contrib/hbmxml/hbmxml.c + * contrib/hbmxml/hbmxml.ch + * Minor/cosmetic changes + * contrib/hbmxml/hbmxml.hbp + + hbmxml/hbmxmlp.prg + Added mxmlSetTextf()/mxmlNetTextf()/mxmlElementSetAttrf + +2011-01-07 15:30 UTC+0200 Petr Chornyj (myorg63 at mail.ru) + * contrib/hbmxml/hbmxml.c + * contrib/hbmxml/tests/test.prg + + Added mxmlLoadFile()/mxmlSaveFile functions + 2011-01-07 10:18 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/vm/cmdarg.c + added support for //F: application runtime switch in DOS diff --git a/harbour/contrib/hbmxml/3rd/minixml/config.h b/harbour/contrib/hbmxml/3rd/minixml/config.h index 7a8c9c67ae..62bb6a795d 100644 --- a/harbour/contrib/hbmxml/3rd/minixml/config.h +++ b/harbour/contrib/hbmxml/3rd/minixml/config.h @@ -1,6 +1,6 @@ -/* - * $Id$ - */ +# +# $Id$ +# /* * Configuration file for Mini-XML, a small XML-like file parsing library. @@ -16,30 +16,25 @@ * http://www.minixml.org/ */ - -#ifdef _MSC_VER -#define _CRT_SECURE_NO_DEPRECATE -#define _CRT_SECURE_NO_WARNINGS - -#define close _close -#define open _open -#define read _read -#define snprintf _snprintf -#define strdup _strdup -#define vsnprintf _vsnprintf -#define write _write -#endif - /* * Include necessary headers... */ -#include -#include -#include -#include -#include -#include +#define _CRT_SECURE_NO_DEPRECATE +#define _CRT_SECURE_NO_WARNINGS + +#include "hbdefs.h" +#include "hb_io.h" + +#if defined ( _MSC_VER ) +#define close _close +#define open _open +#define read _read +#define snprintf _snprintf +#define strdup _strdup +#define vsnprintf _vsnprintf +#define write _write +#endif /* * Version number... @@ -47,17 +42,13 @@ #define MXML_VERSION "Mini-XML v2.7" + /* * Inline function support... */ -#if defined( __GNUC__ ) -# define inline __inline__ -#elif defined( _MSC_VER ) -# define inline _inline -#else -# define inline -#endif +#define inline _HB_INLINE_ + /* * Long long support... @@ -65,6 +56,7 @@ #define HAVE_LONG_LONG 1 + /* * Do we have the snprintf() and vsnprintf() functions? */ @@ -72,12 +64,14 @@ #define HAVE_SNPRINTF 1 #define HAVE_VSNPRINTF 1 + /* * Do we have the strXXX() functions? */ #define HAVE_STRDUP 1 + /* * Do we have threading support? */ @@ -90,19 +84,19 @@ */ # ifndef HAVE_STRDUP -extern char *_mxml_strdup(const char *); +extern char *_mxml_strdup(const char *); # define strdup _mxml_strdup # endif /* !HAVE_STRDUP */ -extern char *_mxml_strdupf(const char *, ...); -extern char *_mxml_vstrdupf(const char *, va_list); +extern char *_mxml_strdupf(const char *, ...); +extern char *_mxml_vstrdupf(const char *, va_list); # ifndef HAVE_SNPRINTF -extern int _mxml_snprintf(char *, size_t, const char *, ...); +extern int _mxml_snprintf(char *, size_t, const char *, ...); # define snprintf _mxml_snprintf # endif /* !HAVE_SNPRINTF */ # ifndef HAVE_VSNPRINTF -extern int _mxml_vsnprintf(char *, size_t, const char *, va_list); +extern int _mxml_vsnprintf(char *, size_t, const char *, va_list); # define vsnprintf _mxml_vsnprintf # endif /* !HAVE_VSNPRINTF */ diff --git a/harbour/contrib/hbmxml/hbmxml.c b/harbour/contrib/hbmxml/hbmxml.c index 6fd666bd97..6d66349429 100644 --- a/harbour/contrib/hbmxml/hbmxml.c +++ b/harbour/contrib/hbmxml/hbmxml.c @@ -6,7 +6,7 @@ * Harbour Project source code: * MINIXML functions wrapper * - * Copyright 2010 Petr Chornyj + * Copyright 2010-2011 Petr Chornyj * www - http://harbour-project.org * * This program is free software; you can redistribute it and/or modify @@ -241,20 +241,17 @@ HB_FUNC( HB_MXMLVERSION ) /* ======================== MXML_... wrapper funcs ============================== */ /* - * h mxmlElementSetAttrf * - mxmlEntityAddCallback * - mxmlEntityRemoveCallback * - mxmlGetCustom * - mxmlLoadFd * - mxmlNewCustom - * h mxmlNewTextf * - mxmlSAXLoadFd * - mxmlSAXLoadFile * - mxmlSAXLoadString * - mxmlSaveFd * - mxmlSetCustom * - mxmlSetCustomHandlers - * h mxmlSetTextf */ /* void mxmlAdd( mxml_node_t * parent, int where, mxml_node_t * child, mxml_node_t * node ) */ @@ -742,7 +739,6 @@ static mxml_type_t type_cb( mxml_node_t * node ) int iResult; PHB_ITEM pNode = hb_itemNew( NULL ); - mxmlRetain( node ); hbmxml_node_ItemPut( pNode, node, 0 ); hb_vmPushDynSym( pSym ); @@ -814,10 +810,12 @@ HB_FUNC( MXMLLOADFILE ) file = hb_fopen( hb_parstr_utf8( 2, &hFree, NULL ), "r" ); if( file ) + { node = mxmlLoadFile( node_top, file, cb ); - if( node ) - mxml_node_ret( node, ( node_top == MXML_NO_PARENT ) ? 1 : 0 ); + if( node ) + mxml_node_ret( node, ( node_top == MXML_NO_PARENT ) ? 1 : 0 ); + } pType_cb->type_cb = NULL; hb_strfree( hFree ); @@ -1150,7 +1148,6 @@ static const char * save_cb( mxml_node_t * node, int where ) const char * pszResult; - mxmlRetain( node ); hbmxml_node_ItemPut( pNode, node, 0 ); hb_vmPushDynSym( pSym ); diff --git a/harbour/contrib/hbmxml/hbmxml.ch b/harbour/contrib/hbmxml/hbmxml.ch index 46f13d61e6..cd768a012e 100644 --- a/harbour/contrib/hbmxml/hbmxml.ch +++ b/harbour/contrib/hbmxml/hbmxml.ch @@ -6,7 +6,7 @@ * Harbour Project source code: * MINIXML functions wrapper * - * Copyright 2010 Petr Chornyj + * Copyright 2010-2011 Petr Chornyj * www - http://harbour-project.org * * This program is free software; you can redistribute it and/or modify diff --git a/harbour/contrib/hbmxml/hbmxml.hbp b/harbour/contrib/hbmxml/hbmxml.hbp index 385dcf635c..a8ec837086 100644 --- a/harbour/contrib/hbmxml/hbmxml.hbp +++ b/harbour/contrib/hbmxml/hbmxml.hbp @@ -18,6 +18,7 @@ -instfile=inc:hbmxml.ch +hbmxmlp.prg hbmxml.c 3rd/minixml/mxml.hbc{HBMK_HAS_MXML_LOCAL} diff --git a/harbour/contrib/hbmxml/hbmxmlp.prg b/harbour/contrib/hbmxml/hbmxmlp.prg new file mode 100644 index 0000000000..e9385afdea --- /dev/null +++ b/harbour/contrib/hbmxml/hbmxmlp.prg @@ -0,0 +1,95 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * MINIXML functions wrapper + * + * Copyright 2010. Tamas TEVESZ + * 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 "hbmxml.ch" + +/* + * void mxmlElementSetAttrf( mxml_node_t * node, + * const char * name, + * const char * format, + * ... ) + */ +FUNCTION mxmlElementSetAttrf( hNode, cName, cFormat, ... ) + + LOCAL cValue + + cValue := hb_strFormat( cFormat, ... ) + + RETURN mxmlElementSetAttr( hNode, cName, cValue ) + +/* + * void mxmlNewTextf( mxml_node_t * node, + * int whitespace, + * const char * format, + * ... ) + */ +FUNCTION mxmlNewTextf( hNode, nWhitespace, cFormat, ... ) + + LOCAL cText + + cText := hb_strFormat( cFormat, ... ) + + RETURN mxmlNewText( hNode, nWhitespace, cText ) + +/* + * int mxmlSetTextf( mxml_node_t * node, + * int whitespace, + * const char * format, + * ... ) + */ +FUNCTION mxmlSetTextf( hNode, nWhitespace, cFormat, ... ) + + LOCAL cText + + cText := hb_strFormat( cFormat, ... ) + + RETURN mxmlSetText( hNode, nWhitespace, cText )