From c3e1436da04df92aeaee308282ff7c7aaeebfb7d Mon Sep 17 00:00:00 2001 From: Przemyslaw Czerpak Date: Fri, 26 Jun 2009 00:33:38 +0000 Subject: [PATCH] 2009-06-26 02:22 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/include/hbvm.h * harbour/include/hbrdddbf.h * harbour/include/hbapidbg.h * harbour/include/hbset.h * harbour/include/hbcomp.h * harbour/include/hbapirdd.h * harbour/include/hbstack.h * harbour/include/hbsxfunc.h * harbour/include/hbapilng.h * harbour/include/hbgtcore.h * harbour/include/hbapifs.h * harbour/include/hbdbsort.h * harbour/include/hbapigt.h * harbour/include/hbapi.h * harbour/include/hbapierr.h * harbour/include/hbapiitm.h * harbour/include/hbrddfpt.h * harbour/contrib/hbmysql/mysql.c * harbour/contrib/hbct/bitnum.c * harbour/contrib/hbct/token2.c * harbour/contrib/hbct/charsprd.c * harbour/contrib/hbct/ctnet.c * harbour/contrib/hbct/charonly.c * harbour/contrib/hbct/atadjust.c * harbour/contrib/hbct/ctwin.c * harbour/contrib/hbct/charsort.c * harbour/contrib/hbct/ctwin.h * harbour/contrib/hbct/charmix.c * harbour/contrib/hbct/charevod.c * harbour/contrib/hbct/maxline.c * harbour/contrib/hbct/wordrepl.c * harbour/contrib/hbct/charrepl.c * harbour/contrib/hbct/files.c * harbour/contrib/hbct/video.c * harbour/contrib/hbct/charswap.c * harbour/contrib/hbct/dattime3.c * harbour/contrib/hbct/charop.c * harbour/contrib/hbct/misc2.c * harbour/contrib/hbct/charone.c * harbour/contrib/hbct/ctstr.c * harbour/contrib/hbct/screen1.c * harbour/contrib/hbct/token1.c * harbour/contrib/hbct/ctstr.h * harbour/contrib/hbct/charmirr.c * harbour/contrib/hbct/relation.c * harbour/contrib/hbct/atnum.c * harbour/contrib/hbct/like.c * harbour/contrib/hbct/count.c * harbour/contrib/hbct/disk.c * harbour/contrib/hbct/ctstrfil.c * harbour/contrib/hbct/posdiff.c * harbour/contrib/hbct/addascii.c * harbour/contrib/hbct/tab.c * harbour/contrib/hbct/numline.c * harbour/contrib/hbct/dattime2.c * harbour/contrib/hbct/asciisum.c * harbour/contrib/hbct/expand.c * harbour/contrib/hbct/pos2.c * harbour/contrib/hbct/numat.c * harbour/contrib/hbct/atrepl.c * harbour/contrib/hbct/wordtoch.c * harbour/contrib/hbct/print.c * harbour/contrib/hbct/justify.c * harbour/contrib/xhb/hbxml.c * harbour/contrib/xhb/dbf2txt.c * harbour/contrib/xhb/xhbis.c * harbour/contrib/xhb/fparse.c * harbour/contrib/xhb/xstrdel.c * harbour/contrib/xhb/hbcomprs.c * harbour/contrib/xhb/datesxhb.c * harbour/contrib/xhb/xhbmsgs.c * harbour/contrib/xhb/freadlin.c * harbour/contrib/xhb/txtline.c * harbour/contrib/xhb/xhbtrim.c * harbour/contrib/xhb/xhbcopyf.c * harbour/contrib/xhb/cstructc.c * harbour/contrib/xhb/xhbfunc.c * harbour/contrib/hbtpathy/tplinux.c * harbour/contrib/hbgt/charmixg.c * harbour/contrib/hbgt/strexpan.c * harbour/contrib/hbgt/charodd.c * harbour/contrib/hbgt/strright.c * harbour/contrib/hbgt/asciisgt.c * harbour/contrib/hbgt/strdiffg.c * harbour/contrib/hbgt/chrtotal.c * harbour/contrib/hbgt/strcount.c * harbour/contrib/hbgt/strleft.c * harbour/contrib/hbgt/ascposgt.c * harbour/contrib/hbgt/chrfirst.c * harbour/contrib/hbgt/chrcount.c * harbour/contrib/hbgt/strpbrk.c * harbour/contrib/hbgt/chareven.c * harbour/contrib/hbgt/strcspn.c * harbour/contrib/hbgt/atdiff.c * harbour/contrib/hbsqlit3/hbsqlit3.c * harbour/contrib/hbmzip/hbmzip.c * harbour/contrib/hbnf/proper.c * harbour/contrib/hbnf/fttext.c * harbour/contrib/hbnf/chdir.c * harbour/contrib/hbnf/getver.c * harbour/contrib/hbnf/ftattr.c * harbour/contrib/hbnf/mkdir.c * harbour/contrib/hbnf/rmdir.c * harbour/contrib/Makefile * harbour/contrib/hbcurl/hbcurl.c * harbour/contrib/rddsql/sddmy/mysqldd.c * harbour/contrib/rddsql/sddpg/pgsqldd.c * harbour/contrib/rddsql/sddfb/fbirddd.c * harbour/contrib/rddsql/sddodbc/odbcdd.c * harbour/contrib/rddsql/sqlmix.c * harbour/contrib/hbhpdf/harupdf.c * harbour/contrib/rddads/adsx.c * harbour/contrib/rddads/adsfunc.c * harbour/contrib/rddads/rddads.h * harbour/contrib/rddads/ads1.c * harbour/contrib/hbmisc/hb_f.c * harbour/contrib/hbmisc/strfmt.c * harbour/contrib/hbmisc/stringsx.c * harbour/contrib/hbmisc/spd.c * harbour/contrib/hbtip/utils.c * harbour/contrib/hbwin/wapi_winbase.c * harbour/contrib/hbwin/win_misc.c * harbour/contrib/hbbtree/hb_btree.h * harbour/contrib/hbbtree/hb_btree.c * harbour/source/pp/hbpp.c * harbour/source/vm/runner.c * harbour/source/vm/estack.c * harbour/source/vm/itemapi.c * harbour/source/vm/hvm.c * harbour/source/vm/cmdarg.c * harbour/source/vm/memvars.c * harbour/source/vm/dynlibhb.c * harbour/source/vm/set.c * harbour/source/main/harbour.c * harbour/source/debug/dbgentry.c * harbour/source/common/hbfsapi.c * harbour/source/common/hbfopen.c * harbour/source/rtl/gtdos/gtdos.c * harbour/source/rtl/diskspac.c * harbour/source/rtl/console.c * harbour/source/rtl/chrasc.c * harbour/source/rtl/fscopy.c * harbour/source/rtl/run.c * harbour/source/rtl/spfiles.c * harbour/source/rtl/defpath.c * harbour/source/rtl/philes.c * harbour/source/rtl/oldbox.c * harbour/source/rtl/math.c * harbour/source/rtl/hbgtcore.c * harbour/source/rtl/cdpapi.c * harbour/source/rtl/gtcrs/gtcrs.c * harbour/source/rtl/dirdrive.c * harbour/source/rtl/hbi18n1.c * harbour/source/rtl/trim.c * harbour/source/rtl/hbzlibgz.c * harbour/source/rtl/philesx.c * harbour/source/rtl/mlcfunc.c * harbour/source/rtl/filehb.c * harbour/source/rtl/fstemp.c * harbour/source/rtl/is.c * harbour/source/rtl/hbrunfun.c * harbour/source/rtl/ampm.c * harbour/source/rtl/setcolor.c * harbour/source/rtl/oemansi.c * harbour/source/rtl/disksphb.c * harbour/source/rtl/hbzlib.c * harbour/source/rtl/strpeek.c * harbour/source/rtl/replic.c * harbour/source/rtl/stuff.c * harbour/source/rtl/hbstrfmt.c * harbour/source/rtl/transfrm.c * harbour/source/rtl/hbhex.c * harbour/source/rtl/trace.c * harbour/source/rtl/hbadler.c * harbour/source/rtl/samples.c * harbour/source/rtl/filebuf.c * harbour/source/rtl/hbcrc.c * harbour/source/rtl/gete.c * harbour/source/rtl/hbmd5.c * harbour/source/rtl/langapi.c * harbour/source/rtl/gtcgi/gtcgi.c * harbour/source/rtl/errapi.c * harbour/source/rtl/hbregexc.c * harbour/source/rtl/natmsg.c * harbour/source/rtl/fssize.c * harbour/source/rtl/hbinet.c * harbour/source/rtl/colorind.c * harbour/source/rtl/copyfile.c * harbour/source/rtl/mouseapi.c * harbour/source/rtl/soundex.c * harbour/source/rtl/memofile.c * harbour/source/rtl/hbffind.c * harbour/source/rtl/gtapi.c * harbour/source/rtl/direct.c * harbour/source/rtl/filesys.c * harbour/source/rtl/file.c * harbour/source/rtl/val.c * harbour/source/rtl/hbregex.c * harbour/source/rtl/rat.c * harbour/source/rtl/isprint.c * harbour/source/rdd/dbfntx/dbfntx1.c * harbour/source/rdd/dbsql.c * harbour/source/rdd/workarea.c * harbour/source/rdd/wacore.c * harbour/source/rdd/sdf1.c * harbour/source/rdd/dbdetach.c * harbour/source/rdd/dbcmdx.c * harbour/source/rdd/dbfnsx/dbfnsx1.c * harbour/source/rdd/dbcmd.c * harbour/source/rdd/dbfcdx/dbfcdx1.c * harbour/source/rdd/delim1.c * harbour/source/rdd/dbf1.c * harbour/source/rdd/hsx/hsx.c * harbour/source/rdd/dbcmd53.c * harbour/source/rdd/usrrdd/usrrdd.c * harbour/source/rdd/wafunc.c * harbour/source/rdd/dbffpt/dbffpt1.c * harbour/source/rdd/hbsix/sxsem.c * harbour/source/rdd/hbsix/sxord.c * harbour/source/rdd/hbsix/sxfname.c * harbour/source/rdd/hbsix/sxtable.c * harbour/source/rdd/hbsix/sxdate.c * harbour/source/rdd/hbsix/sxutil.c * harbour/source/rdd/hbsix/sxcompr.c * harbour/source/compiler/hbmain.c * harbour/source/compiler/cmdcheck.c * harbour/source/compiler/hbpcode.c * harbour/source/compiler/genc.c * harbour/source/compiler/gencc.c * harbour/source/compiler/hbcmplib.c * harbour/source/compiler/ppcomp.c * changed 'char *' and changed 'BYTE *' to 'const char *' in the following functions: const char * hb_vmFindModuleSymbolName( PHB_SYMB pSym ); void hb_vmInitSymbolGroup( void * hNewDynLib, int argc, const char * argv[] ); void hb_dbgEntry( int nMode, int nLine, const char *szName, int nIndex, PHB_ITEM pFrame ); void hb_dbgAddBreak( void *handle, const char *cModule, int nLine, const char *szFunction ); void hb_dbgAddWatch( void *handle, const char *szExpr, BOOL bTrace ); PHB_ITEM hb_dbgGetExpressionValue( void *handle, const char *expression ); BOOL hb_dbgIsValidStopLine( void *handle, const char *szModule, int nLine ); void hb_dbgSetToCursor( void *handle, const char *szModule, int nLine ); void hb_dbgSetWatch( void *handle, int nWatch, const char *szExpr, BOOL bTrace ); const char * hb_setGetCPtr( HB_set_enum set_specifier ); const char * hb_setGetAltFile( void ); const char * hb_setGetDateFormat( void ); const char * hb_setGetTimeFormat( void ); const char * hb_setGetDefault( void ); const char * hb_setGetDelimChars( void ); const char * hb_setGetDevice( void ); const char * hb_setGetExtraFile( void ); const char * hb_setGetPath( void ); const char * hb_setGetMFileExt( void ); const char * hb_setGetPrintFile( void ); const char * hb_setGetEOL( void ); const char * hb_setGetHBOUTLOG( void ); const char * hb_setGetHBOUTLOGINFO( void ); const char * hb_setGetOSCODEPAGE( void ); void hb_compInitPP( HB_COMP_DECL, int argc, const char * const argv[] ); void hb_compGenPCodeN( const BYTE * pBuffer, ULONG ulSize, HB_COMP_DECL ); int hb_compMain( int argc, const char * const argv[], BYTE ** pBufPtr, ULONG * pulSize, const char * szSource ); void hb_compChkCompilerSwitch( HB_COMP_DECL, int, const char * const args[] ); void hb_compChkDefines( HB_COMP_DECL, int iArg, const char * const args[] ); void hb_compGenCString( FILE * yyc, const BYTE * pText, ULONG ulLen ); AREAP hb_rddRequestArea( const char * szAlias, PHB_ITEM pCargo, BOOL fNewArea, BOOL fWait ); char * hb_stackDirBuffer( void ); LONG hb_sxPtoD( const char * pDate ); const char * hb_langID( void ); const char * hb_langSelectID( const char * pszID ); const char * hb_langDGetItem( int iIndex ); const char * hb_langDGetErrorDesc( ULONG ulIndex ); BOOL hb_fsChDir( const char * pszDirName ); HB_FHANDLE hb_fsCreate( const char * pszFileName, ULONG ulAttr ); HB_FHANDLE hb_fsCreateEx( const char * pszFilename, ULONG ulAttr, USHORT uiFlags ); HB_FHANDLE hb_fsCreateTemp( const char * pszDir, const char * pszPrefix, ULONG ulAttr, char * pszName ); HB_FHANDLE hb_fsCreateTempEx( char * pszName, const char * pszDir, const char * pszPrefix, const char * pszExt, ULONG ulAttr ); const char * hb_fsCurDir( USHORT uiDrive ); USHORT hb_fsCurDirBuff( USHORT uiDrive, char * pbyBuffer, ULONG ulLen ); void hb_fsBaseDirBuff( char * pbyBuffer ); BOOL hb_fsDelete( const char * pszFileName ); BOOL hb_fsFile( const char * pszFileName ); BOOL hb_fsIsDirectory( const char * pszFilename ); HB_FOFFSET hb_fsFSize( const char * pszFileName, BOOL bUseDirEntry ); HB_FHANDLE hb_fsExtOpen( const char * pszFileName, const char * pDefExt, char * hb_fsExtName( const char * pFilename, const char * pDefExt, USHORT uiExFlags, const char * pPaths ); BOOL hb_fsMkDir( const char * pszDirName ); HB_FHANDLE hb_fsOpen( const char * pszFileName, USHORT uiFlags ); BOOL hb_fsRmDir( const char * pszDirName ); BOOL hb_fsRename( const char * pszOldName, const char * pszNewName ); BOOL hb_fsGetFileTime( const char * pszFileName, LONG * plJulian, LONG * plMillisec ); BOOL hb_fsSetFileTime( const char * pszFileName, LONG lJulian, LONG lMillisec ); BOOL hb_fsGetAttr( const char * pszFileName, ULONG * pulAttr ); BOOL hb_fsSetAttr( const char * pszFileName, ULONG ulAttr ); HB_FHANDLE hb_fsPOpen( const char * pFilename, const char * pMode ); BOOL hb_fsCopy( const char * pSource, const char * pDest ); BOOL hb_spFile( const char * pFilename, char * pRetPath ); BOOL hb_spFileExists( const char * pFilename, char * pRetPath ); HB_FHANDLE hb_spOpen( const char * pFilename, USHORT uiFlags ); HB_FHANDLE hb_spCreate( const char * pFilename, ULONG ulAttr ); HB_FHANDLE hb_spCreateEx( const char * pFilename, ULONG ulAttr, USHORT uiFlags ); PHB_FILE hb_fileExtOpen( const char * pFilename, const char * pDefExt, USHORT uiExFlags, const char * pPaths, PHB_ITEM pError ); PHB_FILE hb_fileCreateTemp( const char * pszDir, const char * pszPrefix, ULONG ulAttr, char * pszName ); PHB_FILE hb_fileCreateTempEx( char * pszName, const char * pszDir, const char * pszPrefix, const char * pszExt, ULONG ulAttr ); HB_ERRCODE hb_gtBox( SHORT uiTop, SHORT uiLeft, SHORT uiBottom, SHORT uiRight, const BYTE * pbyFrame ); HB_ERRCODE hb_gtDrawBox( SHORT uiTop, SHORT uiLeft, SHORT uiBottom, SHORT uiRight, const BYTE * pbyFrame, int iColor ); HB_ERRCODE hb_gtWrite( const BYTE * pbyStr, ULONG ulLen ); HB_ERRCODE hb_gtWriteAt( USHORT uiRow, USHORT uiCol, const BYTE * pbyStr, ULONG ulLen ); HB_ERRCODE hb_gtWriteCon( const BYTE * pbyStr, ULONG ulLen ); HB_ERRCODE hb_gtPutText( USHORT uiRow, USHORT uiCol, const BYTE * pStr, ULONG ulLength, int iColor ); HB_ERRCODE hb_gtOutStd( const BYTE * pbyStr, ULONG ulLen ); HB_ERRCODE hb_gtOutErr( const BYTE * pbyStr, ULONG ulLen ); HB_ERRCODE hb_gtBoxEx( int iTop, int iLeft, int iBottom, int iRight, const BYTE * pbyFrame, int iColor ); void hb_mouseRestoreState( const BYTE * pBuffer ); const char * hb_strLTrim( const char * szText, ULONG * ulLen ); const char * hb_conNewLine( void ); const char * hb_conSetColor( const char * szColor ); const char * hb_errGetDescription( PHB_ITEM pError ); const char * hb_errGetFileName( PHB_ITEM pError ); const char * hb_errGetOperation( PHB_ITEM pError ); const char * hb_errGetSubSystem( PHB_ITEM pError ); int hb_ctwAddWindowBox( int iWindow, const BYTE * szBox, int iColor ); const char *ct_at_exact_forward ( const char *pcString, size_t sStrLen, const char *pcMatch, size_t sMatchLen, size_t *psMatchStrLen ); const char *ct_at_exact_backward ( const char *pcString, size_t sStrLen, const char *pcMatch, size_t sMatchLen, size_t *psMatchStrLen ); const char *ct_at_wildcard_forward ( const char *pcString, size_t sStrLen, const char *pcMatch, size_t sMatchLen, char cWildCard, size_t *psMatchStrLen ); const char *ct_at_wildcard_backward ( const char *pcString, size_t sStrLen, const char *pcMatch, size_t sMatchLen, char cWildCard, size_t *psMatchStrLen ); const char *ct_at_charset_forward ( const char *pcString, size_t sStrLen, const char *pcCharSet, size_t sCharSetLen, size_t *psMatchedCharPos ); const char *ct_at_charset_backward ( const char *pcString, size_t sStrLen, const char *pcCharSet, size_t sCharSetLen, size_t *psMatchedCharPos ); char * hb_adsOemToAnsi( const char * pcString, ULONG ulLen ); char * hb_adsAnsiToOem( const char * pcString, ULONG ulLen ); struct hb_BTree * hb_BTreeNew( const char *FileName, USHORT usPageSize, USHORT usKeySize, ULONG ulFlags, USHORT usBuffers ); struct hb_BTree * hb_BTreeOpen( const char *FileName, ULONG lFlags, USHORT usBuffers ); BOOL hb_BTreeInsert( struct hb_BTree * pBTree, const char * szKey, PHB_ITEM pData ); BOOL hb_BTreeDelete( struct hb_BTree * pBTree, const char * szKey, LONG lData ); BOOL hb_BTreeSeek( struct hb_BTree * pBTree, const char * szKey, LONG lData, BOOL bSoftSeek ); const char * hb_BTreeKey( struct hb_BTree * pBTree ); * modified RDD methods: HB_ERRCODE PUTVALUEFILE( AREAP, USHORT, const char *, USHORT ); HB_ERRCODE GETVALUEFILE( AREAP, USHORT, const char *, USHORT ); * modified GT methods: void REST( HB_GT_PTR, int, int, int, int, const BYTE * ); void PUTTEXT( HB_GT_PTR, int, int, BYTE, const BYTE *, ULONG ); void WRITEAT( HB_GT_PTR, int, int, const BYTE *, ULONG ); void WRITE( HB_GT_PTR, const BYTE *, ULONG ); void WRITECON( HB_GT_PTR, const BYTE *, ULONG ); void BOX( HB_GT_PTR, int, int, int, int, const BYTE *, BYTE ); void BOXD( HB_GT_PTR, int, int, int, int, const BYTE *, BYTE ); void BOXS( HB_GT_PTR, int, int, int, int, const BYTE *, BYTE ); void OUTSTD( HB_GT_PTR, BYTE *, ULONG ); void OUTERR( HB_GT_PTR, BYTE *, ULONG ); void MOUSERESTORESTATE( HB_GT_PTR, const BYTE * ); * modified RDD structers: DBFIELDINFO, DBOPENINFO, DBORDERCONDINFO, DBCONSTRAINTINFO, DBORDERCREATEINFO + modified parameters and behevior: const char * hb_fsNameConv( const char * szFileName, char ** pszFree ); const char * hb_osEncode( const char * szFileName, char ** pszFree ); const char * hb_osDecode( const char * szFileName, char ** pszFree ); Please look at implementation and current usage of these functions. + added new function: BOOL hb_itemGetWriteCL( PHB_ITEM pItem, char ** pszValue, ULONG * pulLen ); which converts item string buffer to writable state to use with functions like FREAD() instead of hb_itemUnShare*() * updatd other code to respect above modifications ! fixed bugs (also GPF traps) located by above modifications TODO: please make build tests. Especially in OS2 - not tested at all. --- harbour/ChangeLog | 433 +++++++++++++++++++++++ harbour/contrib/Makefile | 3 +- harbour/contrib/hbbtree/hb_btree.c | 44 +-- harbour/contrib/hbbtree/hb_btree.h | 12 +- harbour/contrib/hbct/addascii.c | 2 +- harbour/contrib/hbct/asciisum.c | 2 +- harbour/contrib/hbct/atadjust.c | 11 +- harbour/contrib/hbct/atnum.c | 8 +- harbour/contrib/hbct/atrepl.c | 25 +- harbour/contrib/hbct/bitnum.c | 2 +- harbour/contrib/hbct/charevod.c | 2 +- harbour/contrib/hbct/charmirr.c | 4 +- harbour/contrib/hbct/charmix.c | 2 +- harbour/contrib/hbct/charone.c | 12 +- harbour/contrib/hbct/charonly.c | 6 +- harbour/contrib/hbct/charop.c | 10 +- harbour/contrib/hbct/charrepl.c | 18 +- harbour/contrib/hbct/charsort.c | 2 +- harbour/contrib/hbct/charsprd.c | 3 +- harbour/contrib/hbct/charswap.c | 4 +- harbour/contrib/hbct/count.c | 4 +- harbour/contrib/hbct/ctnet.c | 4 +- harbour/contrib/hbct/ctstr.c | 40 +-- harbour/contrib/hbct/ctstr.h | 36 +- harbour/contrib/hbct/ctstrfil.c | 10 +- harbour/contrib/hbct/ctwin.c | 22 +- harbour/contrib/hbct/ctwin.h | 2 +- harbour/contrib/hbct/dattime2.c | 92 ++--- harbour/contrib/hbct/dattime3.c | 2 +- harbour/contrib/hbct/disk.c | 47 ++- harbour/contrib/hbct/expand.c | 2 +- harbour/contrib/hbct/files.c | 40 +-- harbour/contrib/hbct/justify.c | 13 +- harbour/contrib/hbct/like.c | 4 +- harbour/contrib/hbct/maxline.c | 4 +- harbour/contrib/hbct/misc2.c | 3 +- harbour/contrib/hbct/numat.c | 2 +- harbour/contrib/hbct/numline.c | 4 +- harbour/contrib/hbct/pos2.c | 12 +- harbour/contrib/hbct/posdiff.c | 12 +- harbour/contrib/hbct/print.c | 12 +- harbour/contrib/hbct/relation.c | 22 +- harbour/contrib/hbct/screen1.c | 4 +- harbour/contrib/hbct/tab.c | 4 +- harbour/contrib/hbct/token1.c | 10 +- harbour/contrib/hbct/token2.c | 8 +- harbour/contrib/hbct/video.c | 6 +- harbour/contrib/hbct/wordrepl.c | 8 +- harbour/contrib/hbct/wordtoch.c | 8 +- harbour/contrib/hbcurl/hbcurl.c | 10 +- harbour/contrib/hbgt/asciisgt.c | 2 +- harbour/contrib/hbgt/ascposgt.c | 2 +- harbour/contrib/hbgt/atdiff.c | 2 +- harbour/contrib/hbgt/chareven.c | 10 +- harbour/contrib/hbgt/charmixg.c | 3 +- harbour/contrib/hbgt/charodd.c | 3 +- harbour/contrib/hbgt/chrcount.c | 2 +- harbour/contrib/hbgt/chrfirst.c | 4 +- harbour/contrib/hbgt/chrtotal.c | 2 +- harbour/contrib/hbgt/strcount.c | 2 +- harbour/contrib/hbgt/strcspn.c | 4 +- harbour/contrib/hbgt/strdiffg.c | 2 +- harbour/contrib/hbgt/strexpan.c | 3 +- harbour/contrib/hbgt/strleft.c | 4 +- harbour/contrib/hbgt/strpbrk.c | 4 +- harbour/contrib/hbgt/strright.c | 4 +- harbour/contrib/hbhpdf/harupdf.c | 48 +-- harbour/contrib/hbmisc/hb_f.c | 2 +- harbour/contrib/hbmisc/spd.c | 12 +- harbour/contrib/hbmisc/strfmt.c | 2 +- harbour/contrib/hbmisc/stringsx.c | 6 +- harbour/contrib/hbmysql/mysql.c | 2 +- harbour/contrib/hbmzip/hbmzip.c | 33 +- harbour/contrib/hbnf/chdir.c | 2 +- harbour/contrib/hbnf/ftattr.c | 2 +- harbour/contrib/hbnf/fttext.c | 4 +- harbour/contrib/hbnf/getver.c | 2 +- harbour/contrib/hbnf/mkdir.c | 2 +- harbour/contrib/hbnf/proper.c | 12 +- harbour/contrib/hbnf/rmdir.c | 2 +- harbour/contrib/hbsqlit3/hbsqlit3.c | 24 +- harbour/contrib/hbtip/utils.c | 2 +- harbour/contrib/hbtpathy/tplinux.c | 2 +- harbour/contrib/hbwin/wapi_winbase.c | 10 +- harbour/contrib/hbwin/win_misc.c | 10 +- harbour/contrib/rddads/ads1.c | 41 +-- harbour/contrib/rddads/adsfunc.c | 23 +- harbour/contrib/rddads/adsx.c | 4 +- harbour/contrib/rddads/rddads.h | 8 +- harbour/contrib/rddsql/sddfb/fbirddd.c | 9 +- harbour/contrib/rddsql/sddmy/mysqldd.c | 10 +- harbour/contrib/rddsql/sddodbc/odbcdd.c | 6 +- harbour/contrib/rddsql/sddpg/pgsqldd.c | 14 +- harbour/contrib/rddsql/sqlmix.c | 4 +- harbour/contrib/xhb/cstructc.c | 2 +- harbour/contrib/xhb/datesxhb.c | 2 +- harbour/contrib/xhb/dbf2txt.c | 6 +- harbour/contrib/xhb/fparse.c | 2 +- harbour/contrib/xhb/freadlin.c | 10 +- harbour/contrib/xhb/hbcomprs.c | 20 +- harbour/contrib/xhb/hbxml.c | 11 +- harbour/contrib/xhb/txtline.c | 8 +- harbour/contrib/xhb/xhbcopyf.c | 6 +- harbour/contrib/xhb/xhbfunc.c | 2 +- harbour/contrib/xhb/xhbis.c | 16 +- harbour/contrib/xhb/xhbmsgs.c | 6 +- harbour/contrib/xhb/xhbtrim.c | 4 +- harbour/contrib/xhb/xstrdel.c | 4 +- harbour/include/hbapi.h | 24 +- harbour/include/hbapidbg.h | 16 +- harbour/include/hbapierr.h | 56 +-- harbour/include/hbapifs.h | 80 ++--- harbour/include/hbapigt.h | 20 +- harbour/include/hbapiitm.h | 1 + harbour/include/hbapilng.h | 18 +- harbour/include/hbapirdd.h | 90 ++--- harbour/include/hbcomp.h | 12 +- harbour/include/hbdbsort.h | 2 +- harbour/include/hbgtcore.h | 22 +- harbour/include/hbrdddbf.h | 4 +- harbour/include/hbrddfpt.h | 4 +- harbour/include/hbset.h | 146 ++++---- harbour/include/hbstack.h | 4 +- harbour/include/hbsxfunc.h | 2 +- harbour/include/hbvm.h | 26 +- harbour/source/common/hbfopen.c | 12 +- harbour/source/common/hbfsapi.c | 24 +- harbour/source/compiler/cmdcheck.c | 4 +- harbour/source/compiler/genc.c | 2 +- harbour/source/compiler/gencc.c | 4 +- harbour/source/compiler/hbcmplib.c | 12 +- harbour/source/compiler/hbmain.c | 4 +- harbour/source/compiler/hbpcode.c | 2 +- harbour/source/compiler/ppcomp.c | 2 +- harbour/source/debug/dbgentry.c | 156 +++++---- harbour/source/main/harbour.c | 24 +- harbour/source/pp/hbpp.c | 2 +- harbour/source/rdd/dbcmd.c | 22 +- harbour/source/rdd/dbcmd53.c | 4 +- harbour/source/rdd/dbcmdx.c | 4 +- harbour/source/rdd/dbdetach.c | 4 +- harbour/source/rdd/dbf1.c | 109 +++--- harbour/source/rdd/dbfcdx/dbfcdx1.c | 80 +++-- harbour/source/rdd/dbffpt/dbffpt1.c | 52 ++- harbour/source/rdd/dbfnsx/dbfnsx1.c | 41 ++- harbour/source/rdd/dbfntx/dbfntx1.c | 66 ++-- harbour/source/rdd/dbsql.c | 40 +-- harbour/source/rdd/delim1.c | 42 +-- harbour/source/rdd/hbsix/sxcompr.c | 16 +- harbour/source/rdd/hbsix/sxdate.c | 2 +- harbour/source/rdd/hbsix/sxfname.c | 15 +- harbour/source/rdd/hbsix/sxord.c | 4 +- harbour/source/rdd/hbsix/sxsem.c | 22 +- harbour/source/rdd/hbsix/sxtable.c | 6 +- harbour/source/rdd/hbsix/sxutil.c | 4 +- harbour/source/rdd/hsx/hsx.c | 17 +- harbour/source/rdd/sdf1.c | 36 +- harbour/source/rdd/usrrdd/usrrdd.c | 32 +- harbour/source/rdd/wacore.c | 2 +- harbour/source/rdd/wafunc.c | 22 +- harbour/source/rdd/workarea.c | 7 +- harbour/source/rtl/ampm.c | 2 +- harbour/source/rtl/cdpapi.c | 23 +- harbour/source/rtl/chrasc.c | 2 +- harbour/source/rtl/colorind.c | 2 +- harbour/source/rtl/console.c | 6 +- harbour/source/rtl/copyfile.c | 4 +- harbour/source/rtl/defpath.c | 2 +- harbour/source/rtl/dirdrive.c | 10 +- harbour/source/rtl/direct.c | 36 +- harbour/source/rtl/diskspac.c | 12 +- harbour/source/rtl/disksphb.c | 10 +- harbour/source/rtl/errapi.c | 8 +- harbour/source/rtl/file.c | 44 ++- harbour/source/rtl/filebuf.c | 18 +- harbour/source/rtl/filehb.c | 2 +- harbour/source/rtl/filesys.c | 437 ++++++++++++------------ harbour/source/rtl/fscopy.c | 12 +- harbour/source/rtl/fssize.c | 36 +- harbour/source/rtl/fstemp.c | 78 ++--- harbour/source/rtl/gete.c | 58 ++-- harbour/source/rtl/gtapi.c | 24 +- harbour/source/rtl/gtcgi/gtcgi.c | 6 +- harbour/source/rtl/gtcrs/gtcrs.c | 4 +- harbour/source/rtl/gtdos/gtdos.c | 2 +- harbour/source/rtl/hbadler.c | 2 +- harbour/source/rtl/hbcrc.c | 8 +- harbour/source/rtl/hbffind.c | 10 +- harbour/source/rtl/hbgtcore.c | 56 +-- harbour/source/rtl/hbhex.c | 9 +- harbour/source/rtl/hbi18n1.c | 55 ++- harbour/source/rtl/hbinet.c | 62 ++-- harbour/source/rtl/hbmd5.c | 6 +- harbour/source/rtl/hbregex.c | 4 +- harbour/source/rtl/hbregexc.c | 2 +- harbour/source/rtl/hbrunfun.c | 15 +- harbour/source/rtl/hbstrfmt.c | 4 +- harbour/source/rtl/hbzlib.c | 14 +- harbour/source/rtl/hbzlibgz.c | 22 +- harbour/source/rtl/is.c | 8 +- harbour/source/rtl/isprint.c | 2 +- harbour/source/rtl/langapi.c | 22 +- harbour/source/rtl/math.c | 2 +- harbour/source/rtl/memofile.c | 4 +- harbour/source/rtl/mlcfunc.c | 42 ++- harbour/source/rtl/mouseapi.c | 2 +- harbour/source/rtl/natmsg.c | 8 +- harbour/source/rtl/oemansi.c | 4 +- harbour/source/rtl/oldbox.c | 4 +- harbour/source/rtl/philes.c | 79 +++-- harbour/source/rtl/philesx.c | 3 +- harbour/source/rtl/rat.c | 8 +- harbour/source/rtl/replic.c | 2 +- harbour/source/rtl/run.c | 15 +- harbour/source/rtl/samples.c | 2 +- harbour/source/rtl/setcolor.c | 4 +- harbour/source/rtl/soundex.c | 2 +- harbour/source/rtl/spfiles.c | 70 ++-- harbour/source/rtl/strpeek.c | 9 +- harbour/source/rtl/stuff.c | 2 +- harbour/source/rtl/trace.c | 2 +- harbour/source/rtl/transfrm.c | 10 +- harbour/source/rtl/trim.c | 10 +- harbour/source/rtl/val.c | 2 +- harbour/source/vm/cmdarg.c | 21 +- harbour/source/vm/dynlibhb.c | 4 +- harbour/source/vm/estack.c | 18 +- harbour/source/vm/hvm.c | 10 +- harbour/source/vm/itemapi.c | 20 ++ harbour/source/vm/memvars.c | 4 +- harbour/source/vm/runner.c | 2 +- harbour/source/vm/set.c | 88 +++-- 232 files changed, 2444 insertions(+), 2074 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 1cdc518c56..996f8bc57a 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,439 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-06-26 02:22 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/include/hbvm.h + * harbour/include/hbrdddbf.h + * harbour/include/hbapidbg.h + * harbour/include/hbset.h + * harbour/include/hbcomp.h + * harbour/include/hbapirdd.h + * harbour/include/hbstack.h + * harbour/include/hbsxfunc.h + * harbour/include/hbapilng.h + * harbour/include/hbgtcore.h + * harbour/include/hbapifs.h + * harbour/include/hbdbsort.h + * harbour/include/hbapigt.h + * harbour/include/hbapi.h + * harbour/include/hbapierr.h + * harbour/include/hbapiitm.h + * harbour/include/hbrddfpt.h + * harbour/contrib/hbmysql/mysql.c + * harbour/contrib/hbct/bitnum.c + * harbour/contrib/hbct/token2.c + * harbour/contrib/hbct/charsprd.c + * harbour/contrib/hbct/ctnet.c + * harbour/contrib/hbct/charonly.c + * harbour/contrib/hbct/atadjust.c + * harbour/contrib/hbct/ctwin.c + * harbour/contrib/hbct/charsort.c + * harbour/contrib/hbct/ctwin.h + * harbour/contrib/hbct/charmix.c + * harbour/contrib/hbct/charevod.c + * harbour/contrib/hbct/maxline.c + * harbour/contrib/hbct/wordrepl.c + * harbour/contrib/hbct/charrepl.c + * harbour/contrib/hbct/files.c + * harbour/contrib/hbct/video.c + * harbour/contrib/hbct/charswap.c + * harbour/contrib/hbct/dattime3.c + * harbour/contrib/hbct/charop.c + * harbour/contrib/hbct/misc2.c + * harbour/contrib/hbct/charone.c + * harbour/contrib/hbct/ctstr.c + * harbour/contrib/hbct/screen1.c + * harbour/contrib/hbct/token1.c + * harbour/contrib/hbct/ctstr.h + * harbour/contrib/hbct/charmirr.c + * harbour/contrib/hbct/relation.c + * harbour/contrib/hbct/atnum.c + * harbour/contrib/hbct/like.c + * harbour/contrib/hbct/count.c + * harbour/contrib/hbct/disk.c + * harbour/contrib/hbct/ctstrfil.c + * harbour/contrib/hbct/posdiff.c + * harbour/contrib/hbct/addascii.c + * harbour/contrib/hbct/tab.c + * harbour/contrib/hbct/numline.c + * harbour/contrib/hbct/dattime2.c + * harbour/contrib/hbct/asciisum.c + * harbour/contrib/hbct/expand.c + * harbour/contrib/hbct/pos2.c + * harbour/contrib/hbct/numat.c + * harbour/contrib/hbct/atrepl.c + * harbour/contrib/hbct/wordtoch.c + * harbour/contrib/hbct/print.c + * harbour/contrib/hbct/justify.c + * harbour/contrib/xhb/hbxml.c + * harbour/contrib/xhb/dbf2txt.c + * harbour/contrib/xhb/xhbis.c + * harbour/contrib/xhb/fparse.c + * harbour/contrib/xhb/xstrdel.c + * harbour/contrib/xhb/hbcomprs.c + * harbour/contrib/xhb/datesxhb.c + * harbour/contrib/xhb/xhbmsgs.c + * harbour/contrib/xhb/freadlin.c + * harbour/contrib/xhb/txtline.c + * harbour/contrib/xhb/xhbtrim.c + * harbour/contrib/xhb/xhbcopyf.c + * harbour/contrib/xhb/cstructc.c + * harbour/contrib/xhb/xhbfunc.c + * harbour/contrib/hbtpathy/tplinux.c + * harbour/contrib/hbgt/charmixg.c + * harbour/contrib/hbgt/strexpan.c + * harbour/contrib/hbgt/charodd.c + * harbour/contrib/hbgt/strright.c + * harbour/contrib/hbgt/asciisgt.c + * harbour/contrib/hbgt/strdiffg.c + * harbour/contrib/hbgt/chrtotal.c + * harbour/contrib/hbgt/strcount.c + * harbour/contrib/hbgt/strleft.c + * harbour/contrib/hbgt/ascposgt.c + * harbour/contrib/hbgt/chrfirst.c + * harbour/contrib/hbgt/chrcount.c + * harbour/contrib/hbgt/strpbrk.c + * harbour/contrib/hbgt/chareven.c + * harbour/contrib/hbgt/strcspn.c + * harbour/contrib/hbgt/atdiff.c + * harbour/contrib/hbsqlit3/hbsqlit3.c + * harbour/contrib/hbmzip/hbmzip.c + * harbour/contrib/hbnf/proper.c + * harbour/contrib/hbnf/fttext.c + * harbour/contrib/hbnf/chdir.c + * harbour/contrib/hbnf/getver.c + * harbour/contrib/hbnf/ftattr.c + * harbour/contrib/hbnf/mkdir.c + * harbour/contrib/hbnf/rmdir.c + * harbour/contrib/Makefile + * harbour/contrib/hbcurl/hbcurl.c + * harbour/contrib/rddsql/sddmy/mysqldd.c + * harbour/contrib/rddsql/sddpg/pgsqldd.c + * harbour/contrib/rddsql/sddfb/fbirddd.c + * harbour/contrib/rddsql/sddodbc/odbcdd.c + * harbour/contrib/rddsql/sqlmix.c + * harbour/contrib/hbhpdf/harupdf.c + * harbour/contrib/rddads/adsx.c + * harbour/contrib/rddads/adsfunc.c + * harbour/contrib/rddads/rddads.h + * harbour/contrib/rddads/ads1.c + * harbour/contrib/hbmisc/hb_f.c + * harbour/contrib/hbmisc/strfmt.c + * harbour/contrib/hbmisc/stringsx.c + * harbour/contrib/hbmisc/spd.c + * harbour/contrib/hbtip/utils.c + * harbour/contrib/hbwin/wapi_winbase.c + * harbour/contrib/hbwin/win_misc.c + * harbour/contrib/hbbtree/hb_btree.h + * harbour/contrib/hbbtree/hb_btree.c + * harbour/source/pp/hbpp.c + * harbour/source/vm/runner.c + * harbour/source/vm/estack.c + * harbour/source/vm/itemapi.c + * harbour/source/vm/hvm.c + * harbour/source/vm/cmdarg.c + * harbour/source/vm/memvars.c + * harbour/source/vm/dynlibhb.c + * harbour/source/vm/set.c + * harbour/source/main/harbour.c + * harbour/source/debug/dbgentry.c + * harbour/source/common/hbfsapi.c + * harbour/source/common/hbfopen.c + * harbour/source/rtl/gtdos/gtdos.c + * harbour/source/rtl/diskspac.c + * harbour/source/rtl/console.c + * harbour/source/rtl/chrasc.c + * harbour/source/rtl/fscopy.c + * harbour/source/rtl/run.c + * harbour/source/rtl/spfiles.c + * harbour/source/rtl/defpath.c + * harbour/source/rtl/philes.c + * harbour/source/rtl/oldbox.c + * harbour/source/rtl/math.c + * harbour/source/rtl/hbgtcore.c + * harbour/source/rtl/cdpapi.c + * harbour/source/rtl/gtcrs/gtcrs.c + * harbour/source/rtl/dirdrive.c + * harbour/source/rtl/hbi18n1.c + * harbour/source/rtl/trim.c + * harbour/source/rtl/hbzlibgz.c + * harbour/source/rtl/philesx.c + * harbour/source/rtl/mlcfunc.c + * harbour/source/rtl/filehb.c + * harbour/source/rtl/fstemp.c + * harbour/source/rtl/is.c + * harbour/source/rtl/hbrunfun.c + * harbour/source/rtl/ampm.c + * harbour/source/rtl/setcolor.c + * harbour/source/rtl/oemansi.c + * harbour/source/rtl/disksphb.c + * harbour/source/rtl/hbzlib.c + * harbour/source/rtl/strpeek.c + * harbour/source/rtl/replic.c + * harbour/source/rtl/stuff.c + * harbour/source/rtl/hbstrfmt.c + * harbour/source/rtl/transfrm.c + * harbour/source/rtl/hbhex.c + * harbour/source/rtl/trace.c + * harbour/source/rtl/hbadler.c + * harbour/source/rtl/samples.c + * harbour/source/rtl/filebuf.c + * harbour/source/rtl/hbcrc.c + * harbour/source/rtl/gete.c + * harbour/source/rtl/hbmd5.c + * harbour/source/rtl/langapi.c + * harbour/source/rtl/gtcgi/gtcgi.c + * harbour/source/rtl/errapi.c + * harbour/source/rtl/hbregexc.c + * harbour/source/rtl/natmsg.c + * harbour/source/rtl/fssize.c + * harbour/source/rtl/hbinet.c + * harbour/source/rtl/colorind.c + * harbour/source/rtl/copyfile.c + * harbour/source/rtl/mouseapi.c + * harbour/source/rtl/soundex.c + * harbour/source/rtl/memofile.c + * harbour/source/rtl/hbffind.c + * harbour/source/rtl/gtapi.c + * harbour/source/rtl/direct.c + * harbour/source/rtl/filesys.c + * harbour/source/rtl/file.c + * harbour/source/rtl/val.c + * harbour/source/rtl/hbregex.c + * harbour/source/rtl/rat.c + * harbour/source/rtl/isprint.c + * harbour/source/rdd/dbfntx/dbfntx1.c + * harbour/source/rdd/dbsql.c + * harbour/source/rdd/workarea.c + * harbour/source/rdd/wacore.c + * harbour/source/rdd/sdf1.c + * harbour/source/rdd/dbdetach.c + * harbour/source/rdd/dbcmdx.c + * harbour/source/rdd/dbfnsx/dbfnsx1.c + * harbour/source/rdd/dbcmd.c + * harbour/source/rdd/dbfcdx/dbfcdx1.c + * harbour/source/rdd/delim1.c + * harbour/source/rdd/dbf1.c + * harbour/source/rdd/hsx/hsx.c + * harbour/source/rdd/dbcmd53.c + * harbour/source/rdd/usrrdd/usrrdd.c + * harbour/source/rdd/wafunc.c + * harbour/source/rdd/dbffpt/dbffpt1.c + * harbour/source/rdd/hbsix/sxsem.c + * harbour/source/rdd/hbsix/sxord.c + * harbour/source/rdd/hbsix/sxfname.c + * harbour/source/rdd/hbsix/sxtable.c + * harbour/source/rdd/hbsix/sxdate.c + * harbour/source/rdd/hbsix/sxutil.c + * harbour/source/rdd/hbsix/sxcompr.c + * harbour/source/compiler/hbmain.c + * harbour/source/compiler/cmdcheck.c + * harbour/source/compiler/hbpcode.c + * harbour/source/compiler/genc.c + * harbour/source/compiler/gencc.c + * harbour/source/compiler/hbcmplib.c + * harbour/source/compiler/ppcomp.c + * changed 'char *' and changed 'BYTE *' to 'const char *' in + the following functions: + const char * hb_vmFindModuleSymbolName( PHB_SYMB pSym ); + void hb_vmInitSymbolGroup( void * hNewDynLib, int argc, + const char * argv[] ); + void hb_dbgEntry( int nMode, int nLine, const char *szName, + int nIndex, PHB_ITEM pFrame ); + void hb_dbgAddBreak( void *handle, const char *cModule, + int nLine, const char *szFunction ); + void hb_dbgAddWatch( void *handle, const char *szExpr, BOOL bTrace ); + PHB_ITEM hb_dbgGetExpressionValue( void *handle, + const char *expression ); + BOOL hb_dbgIsValidStopLine( void *handle, const char *szModule, + int nLine ); + void hb_dbgSetToCursor( void *handle, const char *szModule, + int nLine ); + void hb_dbgSetWatch( void *handle, int nWatch, + const char *szExpr, BOOL bTrace ); + const char * hb_setGetCPtr( HB_set_enum set_specifier ); + const char * hb_setGetAltFile( void ); + const char * hb_setGetDateFormat( void ); + const char * hb_setGetTimeFormat( void ); + const char * hb_setGetDefault( void ); + const char * hb_setGetDelimChars( void ); + const char * hb_setGetDevice( void ); + const char * hb_setGetExtraFile( void ); + const char * hb_setGetPath( void ); + const char * hb_setGetMFileExt( void ); + const char * hb_setGetPrintFile( void ); + const char * hb_setGetEOL( void ); + const char * hb_setGetHBOUTLOG( void ); + const char * hb_setGetHBOUTLOGINFO( void ); + const char * hb_setGetOSCODEPAGE( void ); + void hb_compInitPP( HB_COMP_DECL, int argc, + const char * const argv[] ); + void hb_compGenPCodeN( const BYTE * pBuffer, ULONG ulSize, + HB_COMP_DECL ); + int hb_compMain( int argc, const char * const argv[], + BYTE ** pBufPtr, ULONG * pulSize, + const char * szSource ); + void hb_compChkCompilerSwitch( HB_COMP_DECL, int, + const char * const args[] ); + void hb_compChkDefines( HB_COMP_DECL, int iArg, + const char * const args[] ); + void hb_compGenCString( FILE * yyc, const BYTE * pText, ULONG ulLen ); + AREAP hb_rddRequestArea( const char * szAlias, PHB_ITEM pCargo, + BOOL fNewArea, BOOL fWait ); + char * hb_stackDirBuffer( void ); + LONG hb_sxPtoD( const char * pDate ); + const char * hb_langID( void ); + const char * hb_langSelectID( const char * pszID ); + const char * hb_langDGetItem( int iIndex ); + const char * hb_langDGetErrorDesc( ULONG ulIndex ); + BOOL hb_fsChDir( const char * pszDirName ); + HB_FHANDLE hb_fsCreate( const char * pszFileName, ULONG ulAttr ); + HB_FHANDLE hb_fsCreateEx( const char * pszFilename, ULONG ulAttr, + USHORT uiFlags ); + HB_FHANDLE hb_fsCreateTemp( const char * pszDir, + const char * pszPrefix, + ULONG ulAttr, char * pszName ); + HB_FHANDLE hb_fsCreateTempEx( char * pszName, const char * pszDir, + const char * pszPrefix, + const char * pszExt, ULONG ulAttr ); + const char * hb_fsCurDir( USHORT uiDrive ); + USHORT hb_fsCurDirBuff( USHORT uiDrive, char * pbyBuffer, + ULONG ulLen ); + void hb_fsBaseDirBuff( char * pbyBuffer ); + BOOL hb_fsDelete( const char * pszFileName ); + BOOL hb_fsFile( const char * pszFileName ); + BOOL hb_fsIsDirectory( const char * pszFilename ); + HB_FOFFSET hb_fsFSize( const char * pszFileName, BOOL bUseDirEntry ); + HB_FHANDLE hb_fsExtOpen( const char * pszFileName, + const char * pDefExt, + char * hb_fsExtName( const char * pFilename, + const char * pDefExt, USHORT uiExFlags, + const char * pPaths ); + BOOL hb_fsMkDir( const char * pszDirName ); + HB_FHANDLE hb_fsOpen( const char * pszFileName, USHORT uiFlags ); + BOOL hb_fsRmDir( const char * pszDirName ); + BOOL hb_fsRename( const char * pszOldName, + const char * pszNewName ); + BOOL hb_fsGetFileTime( const char * pszFileName, + LONG * plJulian, LONG * plMillisec ); + BOOL hb_fsSetFileTime( const char * pszFileName, + LONG lJulian, LONG lMillisec ); + BOOL hb_fsGetAttr( const char * pszFileName, ULONG * pulAttr ); + BOOL hb_fsSetAttr( const char * pszFileName, ULONG ulAttr ); + HB_FHANDLE hb_fsPOpen( const char * pFilename, const char * pMode ); + BOOL hb_fsCopy( const char * pSource, const char * pDest ); + BOOL hb_spFile( const char * pFilename, char * pRetPath ); + BOOL hb_spFileExists( const char * pFilename, char * pRetPath ); + HB_FHANDLE hb_spOpen( const char * pFilename, USHORT uiFlags ); + HB_FHANDLE hb_spCreate( const char * pFilename, ULONG ulAttr ); + HB_FHANDLE hb_spCreateEx( const char * pFilename, + ULONG ulAttr, USHORT uiFlags ); + PHB_FILE hb_fileExtOpen( const char * pFilename, + const char * pDefExt, USHORT uiExFlags, + const char * pPaths, PHB_ITEM pError ); + PHB_FILE hb_fileCreateTemp( const char * pszDir, + const char * pszPrefix, + ULONG ulAttr, char * pszName ); + PHB_FILE hb_fileCreateTempEx( char * pszName, const char * pszDir, + const char * pszPrefix, + const char * pszExt, ULONG ulAttr ); + HB_ERRCODE hb_gtBox( SHORT uiTop, SHORT uiLeft, SHORT uiBottom, + SHORT uiRight, const BYTE * pbyFrame ); + HB_ERRCODE hb_gtDrawBox( SHORT uiTop, SHORT uiLeft, SHORT uiBottom, + SHORT uiRight, const BYTE * pbyFrame, + int iColor ); + HB_ERRCODE hb_gtWrite( const BYTE * pbyStr, ULONG ulLen ); + HB_ERRCODE hb_gtWriteAt( USHORT uiRow, USHORT uiCol, + const BYTE * pbyStr, ULONG ulLen ); + HB_ERRCODE hb_gtWriteCon( const BYTE * pbyStr, ULONG ulLen ); + HB_ERRCODE hb_gtPutText( USHORT uiRow, USHORT uiCol, + const BYTE * pStr, ULONG ulLength, + int iColor ); + HB_ERRCODE hb_gtOutStd( const BYTE * pbyStr, ULONG ulLen ); + HB_ERRCODE hb_gtOutErr( const BYTE * pbyStr, ULONG ulLen ); + HB_ERRCODE hb_gtBoxEx( int iTop, int iLeft, int iBottom, int iRight, + const BYTE * pbyFrame, int iColor ); + void hb_mouseRestoreState( const BYTE * pBuffer ); + const char * hb_strLTrim( const char * szText, ULONG * ulLen ); + const char * hb_conNewLine( void ); + const char * hb_conSetColor( const char * szColor ); + const char * hb_errGetDescription( PHB_ITEM pError ); + const char * hb_errGetFileName( PHB_ITEM pError ); + const char * hb_errGetOperation( PHB_ITEM pError ); + const char * hb_errGetSubSystem( PHB_ITEM pError ); + int hb_ctwAddWindowBox( int iWindow, const BYTE * szBox, int iColor ); + const char *ct_at_exact_forward + ( const char *pcString, size_t sStrLen, + const char *pcMatch, size_t sMatchLen, + size_t *psMatchStrLen ); + const char *ct_at_exact_backward + ( const char *pcString, size_t sStrLen, + const char *pcMatch, size_t sMatchLen, + size_t *psMatchStrLen ); + const char *ct_at_wildcard_forward + ( const char *pcString, size_t sStrLen, + const char *pcMatch, size_t sMatchLen, + char cWildCard, size_t *psMatchStrLen ); + const char *ct_at_wildcard_backward + ( const char *pcString, size_t sStrLen, + const char *pcMatch, size_t sMatchLen, + char cWildCard, size_t *psMatchStrLen ); + const char *ct_at_charset_forward + ( const char *pcString, size_t sStrLen, + const char *pcCharSet, size_t sCharSetLen, + size_t *psMatchedCharPos ); + const char *ct_at_charset_backward + ( const char *pcString, size_t sStrLen, + const char *pcCharSet, size_t sCharSetLen, + size_t *psMatchedCharPos ); + char * hb_adsOemToAnsi( const char * pcString, ULONG ulLen ); + char * hb_adsAnsiToOem( const char * pcString, ULONG ulLen ); + struct hb_BTree * hb_BTreeNew( const char *FileName, + USHORT usPageSize, USHORT usKeySize, + ULONG ulFlags, USHORT usBuffers ); + struct hb_BTree * hb_BTreeOpen( const char *FileName, ULONG lFlags, + USHORT usBuffers ); + BOOL hb_BTreeInsert( struct hb_BTree * pBTree, const char * szKey, + PHB_ITEM pData ); + BOOL hb_BTreeDelete( struct hb_BTree * pBTree, const char * szKey, + LONG lData ); + BOOL hb_BTreeSeek( struct hb_BTree * pBTree, const char * szKey, + LONG lData, BOOL bSoftSeek ); + const char * hb_BTreeKey( struct hb_BTree * pBTree ); + + * modified RDD methods: + HB_ERRCODE PUTVALUEFILE( AREAP, USHORT, const char *, USHORT ); + HB_ERRCODE GETVALUEFILE( AREAP, USHORT, const char *, USHORT ); + * modified GT methods: + void REST( HB_GT_PTR, int, int, int, int, const BYTE * ); + void PUTTEXT( HB_GT_PTR, int, int, BYTE, const BYTE *, ULONG ); + void WRITEAT( HB_GT_PTR, int, int, const BYTE *, ULONG ); + void WRITE( HB_GT_PTR, const BYTE *, ULONG ); + void WRITECON( HB_GT_PTR, const BYTE *, ULONG ); + void BOX( HB_GT_PTR, int, int, int, int, const BYTE *, BYTE ); + void BOXD( HB_GT_PTR, int, int, int, int, const BYTE *, BYTE ); + void BOXS( HB_GT_PTR, int, int, int, int, const BYTE *, BYTE ); + void OUTSTD( HB_GT_PTR, BYTE *, ULONG ); + void OUTERR( HB_GT_PTR, BYTE *, ULONG ); + void MOUSERESTORESTATE( HB_GT_PTR, const BYTE * ); + * modified RDD structers: + DBFIELDINFO, DBOPENINFO, DBORDERCONDINFO, DBCONSTRAINTINFO, + DBORDERCREATEINFO + + modified parameters and behevior: + const char * hb_fsNameConv( const char * szFileName, char ** pszFree ); + const char * hb_osEncode( const char * szFileName, char ** pszFree ); + const char * hb_osDecode( const char * szFileName, char ** pszFree ); + Please look at implementation and current usage of these functions. + + added new function: + BOOL hb_itemGetWriteCL( PHB_ITEM pItem, + char ** pszValue, ULONG * pulLen ); + which converts item string buffer to writable state to use with + functions like FREAD() instead of hb_itemUnShare*() + * updatd other code to respect above modifications + ! fixed bugs (also GPF traps) located by above modifications + + TODO: please make build tests. Especially in OS2 - not tested at all. + 2009-06-25 13:58 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * utils/hbformat/hbformac.c * examples/superlib/superlib.dif diff --git a/harbour/contrib/Makefile b/harbour/contrib/Makefile index a9de2e6247..31b7f1ff37 100644 --- a/harbour/contrib/Makefile +++ b/harbour/contrib/Makefile @@ -7,9 +7,10 @@ ROOT = ../ ifeq ($(HB_CONTRIBLIBS),) # standalone contribs +# hbbmcdx \ + DIRS=\ gtwvg \ - hbbmcdx \ hbbtree \ hbclipsm \ hbcrypt \ diff --git a/harbour/contrib/hbbtree/hb_btree.c b/harbour/contrib/hbbtree/hb_btree.c index 230574475c..64d42488ec 100644 --- a/harbour/contrib/hbbtree/hb_btree.c +++ b/harbour/contrib/hbbtree/hb_btree.c @@ -302,7 +302,7 @@ typedef int ( * BTreeCmpFunc )( const char * l, const char * r, size_t n ); struct hb_BTree { - BYTE * szFileName; + char * szFileName; HB_FHANDLE hFile; ULONG ulRootPage; ULONG ulFreePage; @@ -708,12 +708,12 @@ static void HeaderWrite( struct hb_BTree * pBTree ) hb_fsSeek( pBTree->hFile, 0, SEEK_SET ); if ( hb_fsWrite( pBTree->hFile, HEADER_ID, sizeof( HEADER_ID ) ) + - hb_fsWrite( pBTree->hFile, ( BYTE * )&pBTree->ulFreePage, sizeof( pBTree->ulFreePage ) ) + /* 4 bytes */ - hb_fsWrite( pBTree->hFile, ( BYTE * )&pBTree->usPageSize, sizeof( pBTree->usPageSize ) ) + /* 2 bytes */ - hb_fsWrite( pBTree->hFile, ( BYTE * )&pBTree->usKeySize , sizeof( pBTree->usKeySize ) ) + /* 4 bytes */ - hb_fsWrite( pBTree->hFile, ( BYTE * )&pBTree->ulRootPage, sizeof( pBTree->ulRootPage ) ) + /* 4 bytes */ - hb_fsWrite( pBTree->hFile, ( BYTE * )&pBTree->ulFlags , sizeof( pBTree->ulFlags ) ) + /* 4 bytes */ - hb_fsWrite( pBTree->hFile, ( BYTE * )&pBTree->ulKeyCount, sizeof( pBTree->ulKeyCount ) ) + /* 4 bytes */ + hb_fsWrite( pBTree->hFile, ( const BYTE * )&pBTree->ulFreePage, sizeof( pBTree->ulFreePage ) ) + /* 4 bytes */ + hb_fsWrite( pBTree->hFile, ( const BYTE * )&pBTree->usPageSize, sizeof( pBTree->usPageSize ) ) + /* 2 bytes */ + hb_fsWrite( pBTree->hFile, ( const BYTE * )&pBTree->usKeySize , sizeof( pBTree->usKeySize ) ) + /* 4 bytes */ + hb_fsWrite( pBTree->hFile, ( const BYTE * )&pBTree->ulRootPage, sizeof( pBTree->ulRootPage ) ) + /* 4 bytes */ + hb_fsWrite( pBTree->hFile, ( const BYTE * )&pBTree->ulFlags , sizeof( pBTree->ulFlags ) ) + /* 4 bytes */ + hb_fsWrite( pBTree->hFile, ( const BYTE * )&pBTree->ulKeyCount, sizeof( pBTree->ulKeyCount ) ) + /* 4 bytes */ 0 != sizeof( HEADER_ID ) + sizeof( pBTree->ulFreePage ) + sizeof( pBTree->usPageSize ) + @@ -790,7 +790,7 @@ static void Prune( struct hb_BTree * pBTree, ULONG ulNode ) else { hb_fsSeek( pBTree->hFile, ulNode, SEEK_SET ); - if ( hb_fsWrite( pBTree->hFile, ( BYTE * )&pBTree->ulFreePage, sizeof( pBTree->ulFreePage ) ) != sizeof( pBTree->ulFreePage ) ) + if ( hb_fsWrite( pBTree->hFile, ( const BYTE * )&pBTree->ulFreePage, sizeof( pBTree->ulFreePage ) ) != sizeof( pBTree->ulFreePage ) ) { hb_RaiseError( HB_BTree_WriteError_EC, "write error", "Prune*", 0 ); } @@ -1111,7 +1111,7 @@ static BOOL PushDown( struct hb_BTree * pBTree, hb_KeyData_T *newkey, ULONG ulNo } } -BOOL hb_BTreeInsert( struct hb_BTree * pBTree, BYTE * szKey, PHB_ITEM pData ) +BOOL hb_BTreeInsert( struct hb_BTree * pBTree, const char * szKey, PHB_ITEM pData ) { hb_KeyData_T *xkey = ( hb_KeyData_T * ) BufferAlloc( sizeof( hb_KeyData_T ) + pBTree->usKeySize + 1 ); ULONG xbranch; @@ -1420,7 +1420,7 @@ static BOOL RecDelete( struct hb_BTree * pBTree, hb_KeyData_T *target, ULONG ulN } #endif -BOOL hb_BTreeDelete( struct hb_BTree * pBTree, BYTE *target, LONG lData ) +BOOL hb_BTreeDelete( struct hb_BTree * pBTree, const char *target, LONG lData ) { ULONG ulNode; int iPosition; @@ -1522,7 +1522,7 @@ LONG hb_BTreeSkip( struct hb_BTree * pBTree, LONG records ) return results; } -BOOL hb_BTreeSeek( struct hb_BTree * pBTree, BYTE *szKey, LONG lData, BOOL bSoftSeek ) +BOOL hb_BTreeSeek( struct hb_BTree * pBTree, const char *szKey, LONG lData, BOOL bSoftSeek ) { BOOL results = FALSE; int iPosition; @@ -1558,7 +1558,7 @@ static int hb_BTstrncmp( const char *s1, const char *s2, size_t n ) } /* allocate hb_BTree structure */ -struct hb_BTree * hb_BTreeNew( BYTE * FileName, USHORT usPageSize, USHORT usKeySize, ULONG ulFlags, USHORT usBuffers ) +struct hb_BTree * hb_BTreeNew( const char * FileName, USHORT usPageSize, USHORT usKeySize, ULONG ulFlags, USHORT usBuffers ) { struct hb_BTree *pBTree = ( struct hb_BTree * )BufferAlloc( sizeof( struct hb_BTree ) ); int iMaximumKeys, size; @@ -1621,7 +1621,7 @@ struct hb_BTree * hb_BTreeNew( BYTE * FileName, USHORT usPageSize, USHORT usKeyS } } - pBTree->szFileName = ( BYTE * ) hb_strdup( ( char * ) FileName ); + pBTree->szFileName = hb_strdup( FileName ); } pBTree->ulFreePage = NULLPAGE; @@ -1674,7 +1674,7 @@ struct hb_BTree * hb_BTreeNew( BYTE * FileName, USHORT usPageSize, USHORT usKeyS } /* open an existing structure */ -struct hb_BTree *hb_BTreeOpen( BYTE *FileName, ULONG ulFlags, USHORT usBuffers ) +struct hb_BTree *hb_BTreeOpen( const char *FileName, ULONG ulFlags, USHORT usBuffers ) { struct hb_BTree *pBTree = ( struct hb_BTree * )BufferAlloc( sizeof( struct hb_BTree ) ); int iMaximumKeys; @@ -1682,7 +1682,7 @@ struct hb_BTree *hb_BTreeOpen( BYTE *FileName, ULONG ulFlags, USHORT usBuffers ) HB_TRACE( HB_TR_DEBUG, ( SRCLINENO ) ); - pBTree->szFileName = ( BYTE * ) hb_strdup( ( char * ) FileName ); + pBTree->szFileName = hb_strdup( FileName ); pBTree->hFile = hb_fsOpen( pBTree->szFileName, FO_READWRITE ); if ( pBTree->hFile == -1 ) { @@ -1750,9 +1750,9 @@ void hb_BTreeClose( struct hb_BTree * pBTree ) BufferRelease( pBTree ); } -const BYTE * hb_BTreeKey( struct hb_BTree * pBTree ) +const char * hb_BTreeKey( struct hb_BTree * pBTree ) { - return ( const BYTE * )pBTree->pThisKeyData->szKey; + return ( const char * )pBTree->pThisKeyData->szKey; } LONG hb_BTreeData( struct hb_BTree * pBTree ) @@ -1807,7 +1807,7 @@ HB_FUNC( HB_BTREEOPEN ) /* hb_BTreeOpen( CHAR cFileName, ULONG ulFlags [ , int { HB_TRACE( HB_TR_DEBUG, ( SRCLINENO ) ); if ( HB_ISCHAR( 1 ) ) - hb_retni( BTree_SetTreeIndex( hb_BTreeOpen( ( BYTE * ) hb_parc( 1 ), hb_parnl( 2 ), hb_parni( 3 ) ) ) ); + hb_retni( BTree_SetTreeIndex( hb_BTreeOpen( hb_parc( 1 ), hb_parnl( 2 ), hb_parni( 3 ) ) ) ); else { hb_RaiseError( HB_BTreeArgError_EC, "Bad argument(s)", HB_ERR_FUNCNAME, hb_pcount() ); @@ -1821,7 +1821,7 @@ HB_FUNC( HB_BTREENEW ) /* hb_BTreeNew( CHAR cFileName, int nPageSize, int nKeyS if ( ( ( hb_parnl( 4 ) & HB_BTREE_INMEMORY ) == HB_BTREE_INMEMORY || HB_ISCHAR( 1 ) ) && HB_ISNUM( 2 ) && HB_ISNUM( 3 ) ) { - hb_retni( BTree_SetTreeIndex( hb_BTreeNew( ( BYTE * ) hb_parc( 1 ), hb_parni( 2 ), hb_parni( 3 ), hb_parnl( 4 ), hb_parni( 5 ) ) ) ); + hb_retni( BTree_SetTreeIndex( hb_BTreeNew( hb_parc( 1 ), hb_parni( 2 ), hb_parni( 3 ), hb_parnl( 4 ), hb_parni( 5 ) ) ) ); } else { @@ -1844,7 +1844,7 @@ HB_FUNC( HB_BTREEINSERT ) /* hb_BTreeInsert( hb_BTree_Handle, CHAR cKey, LONG l HB_TRACE( HB_TR_DEBUG, ( SRCLINENO ) ); if ( HB_ISNUM( 1 ) && HB_ISCHAR( 2 ) && ( hb_pcount() == 2 || GETFLAG( pBTree, IsInMemory ) || HB_ISNUM( 3 ) ) ) - hb_retl( hb_BTreeInsert( BTree_GetTreeIndex( "hb_btreeinsert" ), ( BYTE * ) hb_parc( 2 ), hb_paramError( 3 ) ) ); + hb_retl( hb_BTreeInsert( BTree_GetTreeIndex( "hb_btreeinsert" ), hb_parc( 2 ), hb_paramError( 3 ) ) ); else { hb_RaiseError( HB_BTreeArgError_EC, "Bad argument(s)", HB_ERR_FUNCNAME, hb_pcount() ); @@ -1856,7 +1856,7 @@ HB_FUNC( HB_BTREEDELETE ) /* hb_BTreeDelete( hb_BTree_Handle, CHAR cKey, LONG l { HB_TRACE( HB_TR_DEBUG, ( SRCLINENO ) ); if ( HB_ISNUM( 1 ) && HB_ISCHAR( 2 ) && ( hb_pcount() == 2 || HB_ISNUM( 3 ) ) ) - hb_retl( hb_BTreeDelete( BTree_GetTreeIndex( "hb_btreedelete" ), ( BYTE * ) hb_parc( 2 ), hb_parnl( 3 ) ) ); + hb_retl( hb_BTreeDelete( BTree_GetTreeIndex( "hb_btreedelete" ), hb_parc( 2 ), hb_parnl( 3 ) ) ); else { hb_RaiseError( HB_BTreeArgError_EC, "Bad argument(s)", HB_ERR_FUNCNAME, hb_pcount() ); @@ -1916,7 +1916,7 @@ HB_FUNC( HB_BTREESEEK ) /* hb_BTreeSeek( hb_BTree_Handle, CHAR cKey, LONG lData { HB_TRACE( HB_TR_DEBUG, ( SRCLINENO ) ); if ( HB_ISNUM( 1 ) && HB_ISCHAR( 2 ) ) - hb_retl( hb_BTreeSeek( BTree_GetTreeIndex( "hb_btreeseek" ), ( BYTE * ) hb_parc( 2 ), hb_parnl( 3 ), hb_parl( 4 ) ) ); + hb_retl( hb_BTreeSeek( BTree_GetTreeIndex( "hb_btreeseek" ), hb_parc( 2 ), hb_parnl( 3 ), hb_parl( 4 ) ) ); else { hb_RaiseError( HB_BTreeArgError_EC, "Bad argument(s)", HB_ERR_FUNCNAME, hb_pcount() ); diff --git a/harbour/contrib/hbbtree/hb_btree.h b/harbour/contrib/hbbtree/hb_btree.h index 9673f448cf..0737277906 100644 --- a/harbour/contrib/hbbtree/hb_btree.h +++ b/harbour/contrib/hbbtree/hb_btree.h @@ -59,16 +59,16 @@ HB_EXTERN_BEGIN struct hb_BTree; -struct hb_BTree * hb_BTreeNew( BYTE *FileName, USHORT usPageSize, USHORT usKeySize, ULONG ulFlags, USHORT usBuffers ); -struct hb_BTree * hb_BTreeOpen( BYTE *FileName, ULONG lFlags, USHORT usBuffers ); +struct hb_BTree * hb_BTreeNew( const char *FileName, USHORT usPageSize, USHORT usKeySize, ULONG ulFlags, USHORT usBuffers ); +struct hb_BTree * hb_BTreeOpen( const char *FileName, ULONG lFlags, USHORT usBuffers ); void hb_BTreeClose( struct hb_BTree * pBTree ); -BOOL hb_BTreeInsert( struct hb_BTree * pBTree, BYTE * szKey, PHB_ITEM pData ); -BOOL hb_BTreeDelete( struct hb_BTree * pBTree, BYTE * szKey, LONG lData ); +BOOL hb_BTreeInsert( struct hb_BTree * pBTree, const char * szKey, PHB_ITEM pData ); +BOOL hb_BTreeDelete( struct hb_BTree * pBTree, const char * szKey, LONG lData ); void hb_BTreeGoTop( struct hb_BTree * pBTree ); void hb_BTreeGoBottom( struct hb_BTree * pBTree ); -BOOL hb_BTreeSeek( struct hb_BTree * pBTree, BYTE * szKey, LONG lData, BOOL bSoftSeek ); +BOOL hb_BTreeSeek( struct hb_BTree * pBTree, const char * szKey, LONG lData, BOOL bSoftSeek ); LONG hb_BTreeSkip( struct hb_BTree * pBTree, LONG nRecords ); -const BYTE * hb_BTreeKey( struct hb_BTree * pBTree ); +const char * hb_BTreeKey( struct hb_BTree * pBTree ); LONG hb_BTreeData( struct hb_BTree * pBTree ); PHB_ITEM hb_BTreeDataItem( struct hb_BTree * pBTree ); diff --git a/harbour/contrib/hbct/addascii.c b/harbour/contrib/hbct/addascii.c index fdb3937f2a..a2a75ada36 100644 --- a/harbour/contrib/hbct/addascii.c +++ b/harbour/contrib/hbct/addascii.c @@ -129,7 +129,7 @@ HB_FUNC( ADDASCII ) if( HB_ISCHAR( 1 ) ) { - char *pcSource = hb_parc( 1 ); + const char *pcSource = hb_parc( 1 ); size_t sLen = hb_parclen( 1 ); char *pcResult; size_t sPos; diff --git a/harbour/contrib/hbct/asciisum.c b/harbour/contrib/hbct/asciisum.c index cd2b3bfaca..802c5f6870 100644 --- a/harbour/contrib/hbct/asciisum.c +++ b/harbour/contrib/hbct/asciisum.c @@ -100,7 +100,7 @@ HB_FUNC( ASCIISUM ) if( HB_ISCHAR( 1 ) ) { size_t sStrSize = hb_parclen( 1 ); - char *pcString = hb_parc( 1 ); + const char *pcString = hb_parc( 1 ); size_t sPos; ULONG ulResult = 0; diff --git a/harbour/contrib/hbct/atadjust.c b/harbour/contrib/hbct/atadjust.c index 8ccfe29732..3dad5ae065 100644 --- a/harbour/contrib/hbct/atadjust.c +++ b/harbour/contrib/hbct/atadjust.c @@ -102,9 +102,9 @@ HB_FUNC( ATADJUST ) { if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) && HB_ISNUM( 3 ) ) { - char *pcStringToMatch = hb_parc( 1 ); + const char *pcStringToMatch = hb_parc( 1 ); size_t sStrToMatchLen = ( size_t ) hb_parclen( 1 ); - char *pcString = hb_parc( 2 ); + const char *pcString = hb_parc( 2 ); size_t sStrLen = ( size_t ) hb_parclen( 2 ); size_t sAdjustPosition = hb_parnl( 3 ); @@ -113,10 +113,11 @@ HB_FUNC( ATADJUST ) char cAtLike = ct_getatlikechar(); size_t sIgnore, sMatchStrLen = 0; ULONG ulCounter; - char *pc = NULL; + const char *pc = NULL; char cFillChar; - char *pcRetStr, *pcCheckFill; + const char *pcCheckFill; + char *pcRetStr; size_t sRetStrLen; /* eventually ignore some characters */ @@ -163,7 +164,7 @@ HB_FUNC( ATADJUST ) if( HB_ISNUM( 4 ) && ( ulCounter = hb_parnl( 4 ) ) != 0 ) { /* find the th match */ - char *pcSubStr; + const char *pcSubStr; size_t sSubStrLen; ULONG ulMatchCounter = 0; diff --git a/harbour/contrib/hbct/atnum.c b/harbour/contrib/hbct/atnum.c index 2a2677901e..237b5617a0 100644 --- a/harbour/contrib/hbct/atnum.c +++ b/harbour/contrib/hbct/atnum.c @@ -67,16 +67,16 @@ static void do_atnum( int iSwitch ) { if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) { - char *pcStringToMatch = hb_parc( 1 ); + const char *pcStringToMatch = hb_parc( 1 ); size_t sStrToMatchLen = ( size_t ) hb_parclen( 1 ); - char *pcString = hb_parc( 2 ); + const char *pcString = hb_parc( 2 ); size_t sStrLen = ( size_t ) hb_parclen( 2 ); int iMultiPass = ct_getatmupa(); int iAtLike = ct_getatlike(); char cAtLike = ct_getatlikechar(); size_t sIgnore, sMatchStrLen = 0; ULONG ulCounter; - char *pc = NULL; + const char *pc = NULL; /* eventually ignore some characters */ if( HB_ISNUM( 4 ) ) @@ -140,7 +140,7 @@ static void do_atnum( int iSwitch ) if( HB_ISNUM( 3 ) && ( ulCounter = hb_parnl( 3 ) ) != 0 ) { /* find the th match */ - char *pcSubStr; + const char *pcSubStr; size_t sSubStrLen; ULONG ulMatchCounter = 0; diff --git a/harbour/contrib/hbct/atrepl.c b/harbour/contrib/hbct/atrepl.c index b83c86bd91..6a9b25d075 100644 --- a/harbour/contrib/hbct/atrepl.c +++ b/harbour/contrib/hbct/atrepl.c @@ -125,9 +125,9 @@ HB_FUNC( ATREPL ) { if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) { - char *pcStringToMatch = hb_parc( 1 ); + const char *pcStringToMatch = hb_parc( 1 ); size_t sStrToMatchLen = ( size_t ) hb_parclen( 1 ); - char *pcString = hb_parc( 2 ); + const char *pcString = hb_parc( 2 ); size_t sStrLen = ( size_t ) hb_parclen( 2 ); int iMultiPass = ct_getatmupa(); int iAtLike = ct_getatlike(); @@ -211,13 +211,13 @@ HB_FUNC( ATREPL ) switch ( iAtLike ) { case CT_SETATLIKE_EXACT: - pc = ct_at_exact_forward( pcRetSubStr, sRetSubStrLen, pcStringToMatch, - sStrToMatchLen, &sMatchStrLen ); + pc = ( char * ) ct_at_exact_forward( pcRetSubStr, sRetSubStrLen, pcStringToMatch, + sStrToMatchLen, &sMatchStrLen ); break; case CT_SETATLIKE_WILDCARD: - pc = ct_at_wildcard_forward( pcRetSubStr, sRetSubStrLen, pcStringToMatch, - sStrToMatchLen, cAtLike, &sMatchStrLen ); + pc = ( char * ) ct_at_wildcard_forward( pcRetSubStr, sRetSubStrLen, pcStringToMatch, + sStrToMatchLen, cAtLike, &sMatchStrLen ); break; default: @@ -226,8 +226,7 @@ HB_FUNC( ATREPL ) if( pc == NULL ) { - hb_retclen( pcRetStr, sRetStrLen ); - hb_xfree( pcRetStr ); + hb_retclen_buffer( pcRetStr, sRetStrLen ); return; } @@ -281,14 +280,14 @@ HB_FUNC( ATREPL ) switch ( iAtLike ) { case CT_SETATLIKE_EXACT: - pc = ct_at_exact_backward( pcRetStr + sIgnore, sRetStrLen - sIgnore, - pcStringToMatch, sStrToMatchLen, &sMatchStrLen ); + pc = ( char * ) ct_at_exact_backward( pcRetStr + sIgnore, sRetStrLen - sIgnore, + pcStringToMatch, sStrToMatchLen, &sMatchStrLen ); break; case CT_SETATLIKE_WILDCARD: - pc = ct_at_wildcard_backward( pcRetStr + sIgnore, sRetStrLen - sIgnore, - pcStringToMatch, sStrToMatchLen, - cAtLike, &sMatchStrLen ); + pc = ( char * ) ct_at_wildcard_backward( pcRetStr + sIgnore, sRetStrLen - sIgnore, + pcStringToMatch, sStrToMatchLen, + cAtLike, &sMatchStrLen ); break; default: diff --git a/harbour/contrib/hbct/bitnum.c b/harbour/contrib/hbct/bitnum.c index ed4eb4606e..5a187d6b34 100644 --- a/harbour/contrib/hbct/bitnum.c +++ b/harbour/contrib/hbct/bitnum.c @@ -58,7 +58,7 @@ static BOOL __numParam( int iParam, HB_LONG * plNum ) { - char *szHex = hb_parc( iParam ); + const char *szHex = hb_parc( iParam ); if( szHex ) { diff --git a/harbour/contrib/hbct/charevod.c b/harbour/contrib/hbct/charevod.c index d12628812b..46099dae3f 100644 --- a/harbour/contrib/hbct/charevod.c +++ b/harbour/contrib/hbct/charevod.c @@ -67,7 +67,7 @@ static void do_charevod( int iSwitch ) { if( HB_ISCHAR( 1 ) ) { - char *pcString = hb_parc( 1 ); + const char *pcString = hb_parc( 1 ); size_t sLen = hb_parclen( 1 ); char *pcResult; size_t sPos, sResultPos; diff --git a/harbour/contrib/hbct/charmirr.c b/harbour/contrib/hbct/charmirr.c index c1a92dbad8..3707ecfc54 100644 --- a/harbour/contrib/hbct/charmirr.c +++ b/harbour/contrib/hbct/charmirr.c @@ -112,9 +112,9 @@ HB_FUNC( CHARMIRR ) if( HB_ISCHAR( 1 ) ) { - char *pcString = hb_parc( 1 ); + const char *pcString = hb_parc( 1 ), *pc1; size_t sStrLen = ( size_t ) hb_parclen( 1 ); - char *pcRet, *pc1, *pc2; + char *pcRet, *pc2; int iDontMirrorSpaces; if( HB_ISLOG( 2 ) ) diff --git a/harbour/contrib/hbct/charmix.c b/harbour/contrib/hbct/charmix.c index be5e838621..2dee1d0d01 100644 --- a/harbour/contrib/hbct/charmix.c +++ b/harbour/contrib/hbct/charmix.c @@ -112,7 +112,7 @@ HB_FUNC( CHARMIX ) { if( HB_ISCHAR( 1 ) ) { - char *pcString1 = hb_parc( 1 ); + const char *pcString1 = hb_parc( 1 ); const char *pcString2; char *pcResult; size_t sLen1 = hb_parclen( 1 ); diff --git a/harbour/contrib/hbct/charone.c b/harbour/contrib/hbct/charone.c index 8ad08edb68..3d831978a6 100644 --- a/harbour/contrib/hbct/charone.c +++ b/harbour/contrib/hbct/charone.c @@ -65,9 +65,9 @@ /* helper function for the *one functions */ static void do_charone( int iSwitch ) { - char *pcString; + const char *pcString; size_t sStrLen; - char *pcDeleteSet; + const char *pcDeleteSet; size_t sDeleteSetLen; /* param check */ @@ -93,7 +93,7 @@ static void do_charone( int iSwitch ) case DO_CHARONE_CHARONE: if( sStrLen > 1 ) { - char *pcSub; + const char *pcSub; char *pcRet; size_t sRetStrLen = 0; char cCurrent = *pcString; @@ -128,7 +128,7 @@ static void do_charone( int iSwitch ) case DO_CHARONE_WORDONE: if( sStrLen > 3 && sDeleteSetLen >= 2 ) { - char *pcSub; + const char *pcSub; char *pcRet; size_t sRetStrLen = 0; char cCurrent1 = pcString[0]; @@ -150,8 +150,8 @@ static void do_charone( int iSwitch ) } else if( pcDeleteSet != NULL ) { - char *pc = NULL; - char *pStart = pcDeleteSet; + const char *pc = NULL; + const char *pStart = pcDeleteSet; size_t sLen = sDeleteSetLen; while( sLen >= 2 && diff --git a/harbour/contrib/hbct/charonly.c b/harbour/contrib/hbct/charonly.c index b2f3e87073..22f347d6e7 100644 --- a/harbour/contrib/hbct/charonly.c +++ b/harbour/contrib/hbct/charonly.c @@ -72,14 +72,14 @@ static void do_charonly( int iSwitch ) /* param check */ if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) { - char *pcString = hb_parc( 2 ); + const char *pcString = hb_parc( 2 ); size_t sStrLen = ( size_t ) hb_parclen( 2 ); - char *pcOnlySet = hb_parc( 1 ); + const char *pcOnlySet = hb_parc( 1 ); size_t sOnlySetLen = ( size_t ) hb_parclen( 1 ); char *pcRet; size_t sRetStrLen = 0; int iShift, iBool; - char *pcSub, *pc; + const char *pcSub, *pc; /* check for zero-length strings */ switch ( iSwitch ) diff --git a/harbour/contrib/hbct/charop.c b/harbour/contrib/hbct/charop.c index 5bcf1edeb4..8c01c5cf6b 100644 --- a/harbour/contrib/hbct/charop.c +++ b/harbour/contrib/hbct/charop.c @@ -198,7 +198,7 @@ static void do_charop( int iSwitch ) { if( HB_ISCHAR( 2 ) ) { - char *pucString2 = hb_parc( 2 ); + const char *pucString2 = hb_parc( 2 ); size_t sStrLen2 = hb_parclen( 2 ); for( sPos = 0; sPos < sStrLen; sPos++ ) @@ -224,7 +224,7 @@ static void do_charop( int iSwitch ) { if( HB_ISCHAR( 2 ) ) { - char *pucString2 = hb_parc( 2 ); + const char *pucString2 = hb_parc( 2 ); size_t sStrLen2 = hb_parclen( 2 ); for( sPos = 0; sPos < sStrLen; sPos++ ) @@ -250,7 +250,7 @@ static void do_charop( int iSwitch ) { if( HB_ISCHAR( 2 ) ) { - char *pucString2 = hb_parc( 2 ); + const char *pucString2 = hb_parc( 2 ); size_t sStrLen2 = hb_parclen( 2 ); for( sPos = 0; sPos < sStrLen; sPos++ ) @@ -275,7 +275,7 @@ static void do_charop( int iSwitch ) { if( HB_ISCHAR( 2 ) ) { - char *pucString2 = hb_parc( 2 ); + const char *pucString2 = hb_parc( 2 ); size_t sStrLen2 = hb_parclen( 2 ); for( sPos = 0; sPos < sStrLen; sPos++ ) @@ -300,7 +300,7 @@ static void do_charop( int iSwitch ) { if( HB_ISCHAR( 2 ) ) { - char *pucString2 = hb_parc( 2 ); + const char *pucString2 = hb_parc( 2 ); size_t sStrLen2 = hb_parclen( 2 ); for( sPos = 0; sPos < sStrLen; sPos++ ) diff --git a/harbour/contrib/hbct/charrepl.c b/harbour/contrib/hbct/charrepl.c index 28ba708461..a5c44fabba 100644 --- a/harbour/contrib/hbct/charrepl.c +++ b/harbour/contrib/hbct/charrepl.c @@ -133,10 +133,10 @@ HB_FUNC( CHARREPL ) ( sReplaceLen = ( size_t ) hb_parclen( 3 ) ) > 0 ) { /* get parameters */ - char *pcSearch = hb_parc( 1 ); - char *pcString = hb_parc( 2 ); + const char *pcSearch = hb_parc( 1 ); + const char *pcString = hb_parc( 2 ); size_t sStrLen = ( size_t ) hb_parclen( 2 ); - char *pcReplace = hb_parc( 3 ); + const char *pcReplace = hb_parc( 3 ); int iMode; char *pcRet; size_t sIndex; @@ -170,7 +170,7 @@ HB_FUNC( CHARREPL ) for( sIndex = 0; sIndex < sSearchLen; sIndex++ ) { size_t sMatchStrLen; - char *pc; + const char *pc; size_t sReplIndex = sIndex; if( sReplIndex > sReplaceLen - 1 ) @@ -195,12 +195,12 @@ HB_FUNC( CHARREPL ) else { /* multiple replacements: searching & replacing in pcRet */ - pc = pcRet; - while( ( pc = ct_at_exact_forward( pc, sStrLen - ( pc - pcRet ), - pcSearch + sIndex, 1, - &sMatchStrLen ) ) != NULL ) + char * pcw = pcRet; + while( ( pcw = ( char * ) ct_at_exact_forward( pcw, sStrLen - ( pcw - pcRet ), + pcSearch + sIndex, 1, + &sMatchStrLen ) ) != NULL ) { - *pc++ = *( pcReplace + sReplIndex ); + *pcw++ = *( pcReplace + sReplIndex ); } } } diff --git a/harbour/contrib/hbct/charsort.c b/harbour/contrib/hbct/charsort.c index 8207b8bec5..74921710cc 100644 --- a/harbour/contrib/hbct/charsort.c +++ b/harbour/contrib/hbct/charsort.c @@ -184,7 +184,7 @@ HB_FUNC( CHARSORT ) if( HB_ISCHAR( 1 ) ) { /* get parameters */ - char *pcString = hb_parc( 1 ); + const char *pcString = hb_parc( 1 ); char *pcRet; size_t sStrLen = ( size_t ) hb_parclen( 1 ); size_t sElementLen, sIgnore, sSortLen; diff --git a/harbour/contrib/hbct/charsprd.c b/harbour/contrib/hbct/charsprd.c index 83670114bc..e28d35218b 100644 --- a/harbour/contrib/hbct/charsprd.c +++ b/harbour/contrib/hbct/charsprd.c @@ -68,7 +68,8 @@ HB_FUNC( CHARSPREAD ) hb_itemReturn( hb_param( 1, HB_IT_ANY ) ); else { - char * szText = hb_parc( 1 ), * szDest, cDelim = ' '; + const char * szText = hb_parc( 1 ); + char * szDest, cDelim = ' '; int iTokens = 0, iRepl, iRest, iFirst, i; ULONG ul, ulDst, ulRest; diff --git a/harbour/contrib/hbct/charswap.c b/harbour/contrib/hbct/charswap.c index 85162c5ddb..ab85054b8d 100644 --- a/harbour/contrib/hbct/charswap.c +++ b/harbour/contrib/hbct/charswap.c @@ -74,12 +74,12 @@ static void do_charswap( int iSwitch ) /* param check */ if( HB_ISCHAR( 1 ) ) { - char *pcString = hb_parc( 1 ); + const char *pcString = hb_parc( 1 ); size_t sStrLen = ( size_t ) hb_parclen( 1 ); char *pcRet; size_t sRetIndex = 0; int iShift, iMod; - char *pcSub; + const char *pcSub; if( sStrLen == 0 ) { diff --git a/harbour/contrib/hbct/count.c b/harbour/contrib/hbct/count.c index 0e52b08e9b..b2b5961f51 100644 --- a/harbour/contrib/hbct/count.c +++ b/harbour/contrib/hbct/count.c @@ -64,10 +64,10 @@ static void do_count( int iSwitch ) /* param check */ if( HB_ISCHAR( 1 ) ) { - char *pcString = hb_parc( 1 ); + const char *pcString = hb_parc( 1 ); size_t sStrLen = ( size_t ) hb_parclen( 1 ); size_t sRetVal; - char *pc; + const char *pc; char cSearch; if( hb_parclen( 2 ) > 0 ) diff --git a/harbour/contrib/hbct/ctnet.c b/harbour/contrib/hbct/ctnet.c index 2c9ce9dce7..1905beb3ba 100644 --- a/harbour/contrib/hbct/ctnet.c +++ b/harbour/contrib/hbct/ctnet.c @@ -144,7 +144,7 @@ BOOL WINAPI WNetErrorHandler( DWORD dwErrorCode, LPSTR lpszFunction ) return TRUE; } -static BOOL hb_IsNetShared( LPSTR szLocalDevice ) +static BOOL hb_IsNetShared( const char *szLocalDevice ) { TCHAR lpRemoteDevice[80]; LPTSTR lpLocalDevice; @@ -176,7 +176,7 @@ HB_FUNC( NETCANCEL ) HB_FUNC( NETPRINTER ) { - char * cPrn = hb_setGetCPtr( HB_SET_PRINTFILE ); /* query default local printer port. */ + const char * cPrn = hb_setGetCPtr( HB_SET_PRINTFILE ); /* query default local printer port. */ if( !cPrn || !*cPrn || hb_stricmp( cPrn, "PRN" ) == 0 ) cPrn = "LPT1"; diff --git a/harbour/contrib/hbct/ctstr.c b/harbour/contrib/hbct/ctstr.c index eb55211c8a..967aea3a55 100644 --- a/harbour/contrib/hbct/ctstr.c +++ b/harbour/contrib/hbct/ctstr.c @@ -75,8 +75,8 @@ int ct_str_exit( void ) /* -------------------------- */ /* search for exact substring */ /* -------------------------- */ -char *ct_at_exact_forward( char *pcString, size_t sStrLen, - char *pcMatch, size_t sMatchLen, size_t * psMatchStrLen ) +const char *ct_at_exact_forward( const char *pcString, size_t sStrLen, + const char *pcMatch, size_t sMatchLen, size_t * psMatchStrLen ) { size_t sPos; @@ -105,12 +105,12 @@ char *ct_at_exact_forward( char *pcString, size_t sStrLen, /* ------------------------------------------------ */ /* search for exact substring in backward direction */ /* ------------------------------------------------ */ -char *ct_at_exact_backward( char *pcString, size_t sStrLen, - char *pcMatch, size_t sMatchLen, size_t * psMatchStrLen ) +const char *ct_at_exact_backward( const char *pcString, size_t sStrLen, + const char *pcMatch, size_t sMatchLen, size_t * psMatchStrLen ) { size_t sIndex; - char *pcRet; + const char *pcRet; HB_TRACE( HB_TR_DEBUG, ( "ct_at_exact_backward (\"%s\", %u, \"%s\", %u, %p)", pcString, sStrLen, pcMatch, sMatchLen, psMatchStrLen ) ); @@ -139,13 +139,13 @@ char *ct_at_exact_backward( char *pcString, size_t sStrLen, /* ----------------------------------- */ /* search for substring using wildcard */ /* ----------------------------------- */ -char *ct_at_wildcard_forward( char *pcString, size_t sStrLen, - char *pcMatch, size_t sMatchLen, - char cWildCard, size_t * psMatchStrLen ) +const char *ct_at_wildcard_forward( const char *pcString, size_t sStrLen, + const char *pcMatch, size_t sMatchLen, + char cWildCard, size_t * psMatchStrLen ) { size_t sIndex; - char *pcRet, *pcStop; + const char *pcRet, *pcStop; HB_TRACE( HB_TR_DEBUG, ( "ct_at_wildcard_forward (\"%s\", %u, \"%s\", %u, \'%c\', %p)", pcString, sStrLen, pcMatch, sMatchLen, cWildCard, psMatchStrLen ) ); @@ -178,13 +178,13 @@ char *ct_at_wildcard_forward( char *pcString, size_t sStrLen, /* --------------------------------------------------------- */ /* search for substring using wildcard in backward direction */ /* --------------------------------------------------------- */ -char *ct_at_wildcard_backward( char *pcString, size_t sStrLen, - char *pcMatch, size_t sMatchLen, - char cWildCard, size_t * psMatchStrLen ) +const char *ct_at_wildcard_backward( const char *pcString, size_t sStrLen, + const char *pcMatch, size_t sMatchLen, + char cWildCard, size_t * psMatchStrLen ) { size_t sIndex; - char *pcRet; + const char *pcRet; HB_TRACE( HB_TR_DEBUG, ( "ct_at_wildcard_backward (\"%s\", %u, \"%s\", %u, \'%c\', %p)", pcString, sStrLen, pcMatch, sMatchLen, cWildCard, psMatchStrLen ) ); @@ -217,11 +217,11 @@ char *ct_at_wildcard_backward( char *pcString, size_t sStrLen, /* ------------------------------- */ /* search for character from a set */ /* ------------------------------- */ -char *ct_at_charset_forward( char *pcString, size_t sStrLen, - char *pcCharSet, size_t sCharSetLen, size_t * psMatchedCharPos ) +const char *ct_at_charset_forward( const char *pcString, size_t sStrLen, + const char *pcCharSet, size_t sCharSetLen, size_t * psMatchedCharPos ) { - char *pcRet, *pcSet, *pcStop1, *pcStop2; + const char *pcRet, *pcSet, *pcStop1, *pcStop2; HB_TRACE( HB_TR_DEBUG, ( "ct_at_charset_forward (\"%s\", %u, \"%s\", %u, %p)", pcString, sStrLen, pcCharSet, sCharSetLen, psMatchedCharPos ) ); @@ -251,11 +251,11 @@ char *ct_at_charset_forward( char *pcString, size_t sStrLen, /* ----------------------------------------------------- */ /* search for character from a set in backward direction */ /* ----------------------------------------------------- */ -char *ct_at_charset_backward( char *pcString, size_t sStrLen, - char *pcCharSet, size_t sCharSetLen, size_t * psMatchedCharPos ) +const char *ct_at_charset_backward( const char *pcString, size_t sStrLen, + const char *pcCharSet, size_t sCharSetLen, size_t * psMatchedCharPos ) { - char *pcRet, *pcSet, *pcStop; + const char *pcRet, *pcSet, *pcStop; HB_TRACE( HB_TR_DEBUG, ( "ct_at_charset_backward (\"%s\", %u, \"%s\", %u, %p)", pcString, sStrLen, pcCharSet, sCharSetLen, psMatchedCharPos ) ); @@ -601,7 +601,7 @@ HB_FUNC( SETATLIKE ) } else { - char *pcNewChar = hb_parc( 2 ); + const char *pcNewChar = hb_parc( 2 ); if( hb_parclen( 2 ) > 0 ) ct_setatlikechar( *pcNewChar ); diff --git a/harbour/contrib/hbct/ctstr.h b/harbour/contrib/hbct/ctstr.h index 0ee7c95e72..468741e386 100644 --- a/harbour/contrib/hbct/ctstr.h +++ b/harbour/contrib/hbct/ctstr.h @@ -61,24 +61,24 @@ HB_EXTERN_BEGIN extern int ct_str_init( void ); extern int ct_str_exit( void ); -extern char *ct_at_exact_forward( char *pcString, size_t sStrLen, - char *pcMatch, size_t sMatchLen, - size_t *psMatchStrLen ); -extern char *ct_at_exact_backward( char *pcString, size_t sStrLen, - char *pcMatch, size_t sMatchLen, - size_t *psMatchStrLen ); -extern char *ct_at_wildcard_forward( char *pcString, size_t sStrLen, - char *pcMatch, size_t sMatchLen, - char cWildCard, size_t *psMatchStrLen ); -extern char *ct_at_wildcard_backward( char *pcString, size_t sStrLen, - char *pcMatch, size_t sMatchLen, - char cWildCard, size_t *psMatchStrLen ); -extern char *ct_at_charset_forward( char *pcString, size_t sStrLen, - char *pcCharSet, size_t sCharSetLen, - size_t *psMatchedCharPos ); -extern char *ct_at_charset_backward( char *pcString, size_t sStrLen, - char *pcCharSet, size_t sCharSetLen, - size_t *psMatchedCharPos ); +extern const char *ct_at_exact_forward( const char *pcString, size_t sStrLen, + const char *pcMatch, size_t sMatchLen, + size_t *psMatchStrLen ); +extern const char *ct_at_exact_backward( const char *pcString, size_t sStrLen, + const char *pcMatch, size_t sMatchLen, + size_t *psMatchStrLen ); +extern const char *ct_at_wildcard_forward( const char *pcString, size_t sStrLen, + const char *pcMatch, size_t sMatchLen, + char cWildCard, size_t *psMatchStrLen ); +extern const char *ct_at_wildcard_backward( const char *pcString, size_t sStrLen, + const char *pcMatch, size_t sMatchLen, + char cWildCard, size_t *psMatchStrLen ); +extern const char *ct_at_charset_forward( const char *pcString, size_t sStrLen, + const char *pcCharSet, size_t sCharSetLen, + size_t *psMatchedCharPos ); +extern const char *ct_at_charset_backward( const char *pcString, size_t sStrLen, + const char *pcCharSet, size_t sCharSetLen, + size_t *psMatchedCharPos ); extern void ct_setref( int iNewSwitch ); extern int ct_getref( void ); diff --git a/harbour/contrib/hbct/ctstrfil.c b/harbour/contrib/hbct/ctstrfil.c index eb6c0d22ab..face76e2d6 100644 --- a/harbour/contrib/hbct/ctstrfil.c +++ b/harbour/contrib/hbct/ctstrfil.c @@ -105,7 +105,7 @@ HB_FUNC( CSETSAFETY ) } } -static LONG ct_StrFile( BYTE * pFileName, BYTE * pcStr, ULONG ulLen, BOOL bOverwrite, LONG lOffset, +static LONG ct_StrFile( const char * pFileName, const BYTE * pcStr, ULONG ulLen, BOOL bOverwrite, LONG lOffset, BOOL bTrunc ) { HB_FHANDLE hFile; @@ -147,7 +147,7 @@ HB_FUNC( STRFILE ) { if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) { - hb_retnl( ct_StrFile( ( BYTE * ) hb_parc( 2 ), ( BYTE * ) hb_parc( 1 ), + hb_retnl( ct_StrFile( hb_parc( 2 ), ( const BYTE * ) hb_parc( 1 ), hb_parclen( 1 ), HB_ISLOG( 3 ) && hb_parl( 3 ), hb_parnl( 4 ), HB_ISLOG( 5 ) && hb_parl( 5 ) ) ); } @@ -161,7 +161,7 @@ HB_FUNC( FILESTR ) { if( HB_ISCHAR( 1 ) ) { - HB_FHANDLE hFile = hb_fsOpen( ( BYTE * ) hb_parc( 1 ), FO_READ ); + HB_FHANDLE hFile = hb_fsOpen( hb_parc( 1 ), FO_READ ); if( hFile != FS_ERROR ) { @@ -218,7 +218,7 @@ HB_FUNC( SCREENFILE ) hb_gtSave( 0, 0, hb_gtMaxRow(), hb_gtMaxCol(), pBuffer ); - hb_retnl( ct_StrFile( ( BYTE * ) hb_parc( 1 ), ( BYTE * ) pBuffer, + hb_retnl( ct_StrFile( hb_parc( 1 ), ( const BYTE * ) pBuffer, ulSize, HB_ISLOG( 2 ) && hb_parl( 2 ), hb_parnl( 3 ), HB_ISLOG( 4 ) && hb_parl( 4 ) ) ); hb_xfree( pBuffer ); @@ -233,7 +233,7 @@ HB_FUNC( FILESCREEN ) { if( HB_ISCHAR( 1 ) ) { - HB_FHANDLE hFile = hb_fsOpen( ( BYTE * ) hb_parc( 1 ), FO_READ ); + HB_FHANDLE hFile = hb_fsOpen( hb_parc( 1 ), FO_READ ); if( hFile != FS_ERROR ) { diff --git a/harbour/contrib/hbct/ctwin.c b/harbour/contrib/hbct/ctwin.c index e804ada808..56dbe0e035 100644 --- a/harbour/contrib/hbct/ctwin.c +++ b/harbour/contrib/hbct/ctwin.c @@ -1024,7 +1024,7 @@ static int hb_ctw_GetFormatCords( PHB_GTCTW pCTW, int iWindow, BOOL fRelative, i return -1; } -static int hb_ctw_AddWindowBox( PHB_GTCTW pCTW, int iWindow, UCHAR * szBox, int iColor ) +static int hb_ctw_AddWindowBox( PHB_GTCTW pCTW, int iWindow, const BYTE * szBox, int iColor ) { int iMaxRow, iMaxCol; @@ -1310,13 +1310,13 @@ static int hb_ctw_gt_MaxRow( PHB_GT pGT ) */ #define WRITECON_BUFFER_SIZE 512 -static void hb_ctw_gt_WriteCon( PHB_GT pGT, UCHAR * pText, ULONG ulLength ) +static void hb_ctw_gt_WriteCon( PHB_GT pGT, const BYTE * pText, ULONG ulLength ) { int iLen = 0; BOOL bDisp = FALSE; BOOL bBell = FALSE; int iRow, iCol, iMaxRow, iMaxCol; - UCHAR szString[ WRITECON_BUFFER_SIZE ]; + BYTE szString[ WRITECON_BUFFER_SIZE ]; HB_TRACE(HB_TR_DEBUG, ("hb_ctw_gt_WriteCon(%p,%p,%lu)", pGT, pText, ulLength)); @@ -1344,7 +1344,7 @@ static void hb_ctw_gt_WriteCon( PHB_GT pGT, UCHAR * pText, ULONG ulLength ) while( ulLength-- ) { - UCHAR ch = *pText++; + BYTE ch = *pText++; switch( ch ) { @@ -1913,7 +1913,7 @@ static int hb_ctw_gt_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions, ULONG ulWidth = 0, ulCurrWidth = 0, ul = 0, ul2, ulMaxWidth, ulLast; int iKey, iDspCount, iLines = 0, iTop, iLeft, iBottom, iRight, iMnuCol, iPos, iClr, iWnd, iPrevWnd, i; - char * szMessage = hb_itemGetCPtr( pMessage ); + const char * szMessage = hb_itemGetCPtr( pMessage ); ULONG ulLen = hb_itemGetCLen( pMessage ); ulMaxWidth = iCols - 4; @@ -1960,7 +1960,7 @@ static int hb_ctw_gt_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions, iPrevWnd = hb_ctw_CurrentWindow( pCTW ); iWnd = hb_ctw_CreateWindow( pCTW, iTop, iLeft, iBottom, iRight, TRUE, iClrNorm, TRUE ); - hb_ctw_AddWindowBox( pCTW, iWnd, ( UCHAR * ) _B_SINGLE, iClrNorm ); + hb_ctw_AddWindowBox( pCTW, iWnd, ( const BYTE * ) _B_SINGLE, iClrNorm ); HB_GTSELF_SETCURSORSTYLE( pGT, SC_NONE ); ulLast = 0; i = 0; @@ -1974,7 +1974,7 @@ static int hb_ctw_gt_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions, if( ul2 > ulWidth ) ul2 = ulWidth; HB_GTSELF_PUTTEXT( pGT, i, ( ( ulWidth - ul2 + 1 ) >> 1 ) + 1, ( BYTE ) iClrNorm, - ( UCHAR * ) szMessage + ulLast, ul2 ); + ( const BYTE * ) szMessage + ulLast, ul2 ); } ulLast = ul + 1; if( ++i >= iLines ) @@ -1987,7 +1987,7 @@ static int hb_ctw_gt_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions, if( ul2 > ulWidth ) ul2 = ulWidth; HB_GTSELF_PUTTEXT( pGT, i, ( ( ulWidth - ul2 + 1 ) >> 1 ) + 1, ( BYTE ) iClrNorm, - ( UCHAR * ) szMessage + ulLast, ul2 ); + ( const BYTE * ) szMessage + ulLast, ul2 ); } iPos = 1; @@ -2000,7 +2000,7 @@ static int hb_ctw_gt_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions, iClr = i == iPos ? iClrHigh : iClrNorm; ulLen = hb_arrayGetCLen( pOptions, i ); HB_GTSELF_PUTTEXT( pGT, iLines + 1, iMnuCol, ( BYTE ) iClr, - ( UCHAR * ) hb_arrayGetCPtr( pOptions, i ), ulLen ); + ( const BYTE * ) hb_arrayGetCPtr( pOptions, i ), ulLen ); iMnuCol += ulLen + 3; } while( HB_GTSELF_DISPCOUNT( pGT ) ) @@ -2054,7 +2054,7 @@ static int hb_ctw_gt_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions, int iUp = hb_charUpper( iKey ); for( i = 1; i <= iOptions; ++i ) { - char *szValue = hb_arrayGetCPtr( pOptions, i ); + const char *szValue = hb_arrayGetCPtr( pOptions, i ); if( szValue && iUp == hb_charUpper( *szValue ) ) { iRet = i; @@ -2410,7 +2410,7 @@ int hb_ctwCenterWindow( int iWindow, BOOL fCenter ) return iResult; } -int hb_ctwAddWindowBox( int iWindow, UCHAR * szBox, int iColor ) +int hb_ctwAddWindowBox( int iWindow, const BYTE * szBox, int iColor ) { int iResult = -1; PHB_GTCTW pCTW = hb_ctw_base(); diff --git a/harbour/contrib/hbct/ctwin.h b/harbour/contrib/hbct/ctwin.h index b089eca970..bae458bdde 100644 --- a/harbour/contrib/hbct/ctwin.h +++ b/harbour/contrib/hbct/ctwin.h @@ -89,7 +89,7 @@ extern int hb_ctwGetWindowCords( int iWindow, BOOL fCenter, int * piTop, int * extern int hb_ctwGetFormatCords( int iWindow, BOOL fRelative, int * piTop, int * piLeft, int * piBottom, int * piRight ); extern int hb_ctwMoveWindow( int iWindow, int iRow, int iCol ); extern int hb_ctwCenterWindow( int iWindow, BOOL fCenter ); -extern int hb_ctwAddWindowBox( int iWindow, UCHAR * szBox, int iColor ); +extern int hb_ctwAddWindowBox( int iWindow, const BYTE * szBox, int iColor ); extern int hb_ctwSwapWindows( int iWindow1, int iWindow2 ); extern int hb_ctwGetPosWindow( int iRow, int iCol ); extern int hb_ctwLastKey( void ); diff --git a/harbour/contrib/hbct/dattime2.c b/harbour/contrib/hbct/dattime2.c index 3ea544a6c1..f595a8410e 100644 --- a/harbour/contrib/hbct/dattime2.c +++ b/harbour/contrib/hbct/dattime2.c @@ -141,49 +141,22 @@ static int ct_doy( LONG lDate ) */ HB_FUNC( CTODOW ) { - if( HB_ISCHAR( 1 ) ) + ULONG ulLen = hb_parclen( 1 ); + int iDow = 0; + + if( ulLen ) { - char *szParam = hb_parc( 1 ), *szDow; - int iDow, iEqual; + const char *szParam = hb_parc( 1 ); - hb_strupr( szParam ); - - for( iDow = 0; iDow < 7; iDow++ ) + for( iDow = 7; iDow > 0; iDow-- ) { - szDow = hb_strdup( ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_DAY + iDow ) ); - hb_strupr( szDow ); - - if( hb_setGetL( HB_SET_EXACT ) ) - { - iEqual = ( strlen( szDow ) == strlen( szParam ) ) - && !memcmp( szDow, szParam, strlen( szParam ) ); - } - else - { - iEqual = !memcmp( szDow, szParam, strlen( szParam ) ); - } - - hb_xfree( szDow ); - if( iEqual ) - { + const char * szDow = hb_langDGetItem( HB_LANG_ITEM_BASE_DAY + iDow - 1 ); + if( hb_strnicmp( szDow, szParam, ulLen ) == 0 ) break; - } } - - if( iDow == 7 ) - { - hb_retni( 0 ); - } - else - { - hb_retnl( iDow + 1 ); - } - - } - else - { - hb_retni( 0 ); } + + hb_retnl( iDow ); } @@ -216,46 +189,21 @@ HB_FUNC( CTODOW ) */ HB_FUNC( CTOMONTH ) { - if( HB_ISCHAR( 1 ) ) + ULONG ulLen = hb_parclen( 1 ); + int iMonth = 0; + + if( ulLen ) { - char *szParam = hb_parc( 1 ), *szMonth; - int iMonth, iEqual; - - hb_strupr( szParam ); - - for( iMonth = 1; iMonth <= 12; iMonth++ ) + const char *szParam = hb_parc( 1 ); + for( iMonth = 12; iMonth > 0; iMonth-- ) { - szMonth = hb_strdup( ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_MONTH + iMonth - 1 ) ); - hb_strupr( szMonth ); - - if( hb_setGetL( HB_SET_EXACT ) ) - { - iEqual = ( strlen( szMonth ) == strlen( szParam ) ) - && !memcmp( szMonth, szParam, strlen( szParam ) ); - } - else - { - iEqual = !memcmp( szMonth, szParam, strlen( szParam ) ); - } - - hb_xfree( szMonth ); - if( iEqual ) - { + const char * szMonth = hb_langDGetItem( HB_LANG_ITEM_BASE_MONTH + iMonth - 1 ); + if( hb_strnicmp( szMonth, szParam, ulLen ) == 0 ) break; - } } - - if( iMonth > 12 ) - { - iMonth = 0; - } - hb_retnl( iMonth ); - - } - else - { - hb_retni( 0 ); } + + hb_retnl( iMonth ); } diff --git a/harbour/contrib/hbct/dattime3.c b/harbour/contrib/hbct/dattime3.c index 0298f7724b..0def17c26e 100644 --- a/harbour/contrib/hbct/dattime3.c +++ b/harbour/contrib/hbct/dattime3.c @@ -137,7 +137,7 @@ HB_FUNC( WAITPERIOD ) hb_retl( d < s_dTimeCounter ); } -static BOOL _hb_timeValid( char * szTime, ULONG ulLen, int * piDecode ) +static BOOL _hb_timeValid( const char * szTime, ULONG ulLen, int * piDecode ) { BOOL fValid = FALSE; diff --git a/harbour/contrib/hbct/disk.c b/harbour/contrib/hbct/disk.c index c9943bc429..fd77945253 100644 --- a/harbour/contrib/hbct/disk.c +++ b/harbour/contrib/hbct/disk.c @@ -87,38 +87,35 @@ HB_FUNC( DIRMAKE ) { - BYTE *pFileName = ( BYTE * ) hb_parcx( 1 ); + const char *pFileName = hb_parcx( 1 ); if( hb_fsMkDir( pFileName ) ) - { hb_retni( 0 ); - } else - { hb_retni( -hb_fsOsError() ); - } } HB_FUNC( DIRNAME ) { - BYTE *pbyBuffer = ( BYTE * ) hb_xgrab( HB_PATH_MAX ); - unsigned char *pszDrive = ( unsigned char * ) hb_parc( 1 ); + char *pbyBuffer = ( char * ) hb_xgrab( HB_PATH_MAX ); + const char *pszDrive = hb_parc( 1 ); USHORT uiDrive = 0; if( pszDrive ) { + UCHAR uc = ( UCHAR ) *pszDrive; /* some network drivers (f.e. NETX from Novel Netware) allow * to create drives after 'Z' letter. */ - if( *pszDrive >= 'A' && *pszDrive < 'A' + 32 ) - uiDrive = *pszDrive - ( 'A' - 1 ); - else if( *pszDrive >= 'a' && *pszDrive < 'a' + 32 ) - uiDrive = *pszDrive - ( 'a' - 1 ); + if( uc >= 'A' && uc < 'A' + 32 ) + uiDrive = uc - ( 'A' - 1 ); + else if( uc >= 'a' && uc < 'a' + 32 ) + uiDrive = uc - ( 'a' - 1 ); } pbyBuffer[0] = HB_OS_PATH_DELIM_CHR; hb_fsCurDirBuff( uiDrive, pbyBuffer + 1, HB_PATH_MAX - 1 ); - hb_retc_buffer( ( char * ) pbyBuffer ); + hb_retc_buffer( pbyBuffer ); } @@ -130,7 +127,7 @@ HB_FUNC( DRIVETYPE ) LPTSTR lpDrive; int iType; - hb_strncpy( pszDrive, ( char * ) hb_parcx( 1 ), ulSize ); + hb_strncpy( pszDrive, hb_parcx( 1 ), ulSize ); if( strstr( pszDrive, ":" ) == NULL ) hb_strncat( pszDrive, ":", ulSize ); @@ -216,17 +213,17 @@ HB_FUNC( VOLUME ) if( !ct_getsafety() ) { PHB_FNAME fname; - BYTE *sDiskName; + const char *sDiskName; char *sRoot = NULL; char *sVolName = NULL; char sRootBuf[4], sVolNameBuf[12]; - BOOL fFree; + char * pszFree; - if( HB_ISCHAR( 1 ) && hb_parclen( 1 ) > 0 ) + if( hb_parclen( 1 ) > 0 ) { - sDiskName = hb_fsNameConv( ( BYTE * ) hb_parc( 1 ), &fFree ); + sDiskName = hb_fsNameConv( hb_parc( 1 ), &pszFree ); - if( ( fname = hb_fsFNameSplit( ( char * ) sDiskName ) ) != NULL ) + if( ( fname = hb_fsFNameSplit( sDiskName ) ) != NULL ) { if( fname->szPath ) { @@ -243,11 +240,11 @@ HB_FUNC( VOLUME ) } else { - hb_strncpy( sVolNameBuf, ( char * ) sDiskName, sizeof( sVolNameBuf ) - 1 ); + hb_strncpy( sVolNameBuf, sDiskName, sizeof( sVolNameBuf ) - 1 ); sVolName = sVolNameBuf; } - if( fFree ) - hb_xfree( sDiskName ); + if( pszFree ) + hb_xfree( pszFree ); } #if defined(HB_OS_WIN) && ! defined(HB_OS_WIN_CE) { @@ -275,7 +272,7 @@ HB_FUNC( GETVOLINFO ) { #if defined(HB_OS_WIN) && ! defined(HB_OS_WIN_CE) int iretval; - char *sDrive = hb_parcx( 1 ), *sVolName; + const char *sDrive = hb_parcx( 1 ); TCHAR lpVolName[256]; LPTSTR lpDrive; @@ -286,7 +283,7 @@ HB_FUNC( GETVOLINFO ) if( iretval != 0 ) { - sVolName = HB_TCHAR_CONVFROM( lpVolName ); + char * sVolName = HB_TCHAR_CONVFROM( lpVolName ); hb_retc( sVolName ); HB_TCHAR_FREE( sVolName ); } @@ -312,7 +309,7 @@ HB_FUNC( VOLSERIAL ) { #if defined(HB_OS_WIN) && ! defined(HB_OS_WIN_CE) int retval; - char *sDrive = hb_parcx( 1 ); + const char *sDrive = hb_parcx( 1 ); LPTSTR lpDrive; DWORD dSerial; @@ -337,7 +334,7 @@ HB_FUNC( VOLSERIAL ) HB_FUNC( TRUENAME ) { - char * szFile = hb_parc( 1 ); + const char * szFile = hb_parc( 1 ); if( szFile ) { diff --git a/harbour/contrib/hbct/expand.c b/harbour/contrib/hbct/expand.c index eb3fada1c1..7d6d1671f3 100644 --- a/harbour/contrib/hbct/expand.c +++ b/harbour/contrib/hbct/expand.c @@ -59,7 +59,7 @@ HB_FUNC( EXPAND ) if( ulLen > 0 ) { - char * szText = hb_parc( 1 ); + const char * szText = hb_parc( 1 ); if( ulLen == 1 ) hb_retclen( szText, 1 ); else diff --git a/harbour/contrib/hbct/files.c b/harbour/contrib/hbct/files.c index 6cdd7e89c5..e10ae60236 100644 --- a/harbour/contrib/hbct/files.c +++ b/harbour/contrib/hbct/files.c @@ -120,8 +120,8 @@ static PHB_FFIND _hb_fileStart( BOOL fNext, ULONG ulAttr ) if( hb_pcount() > 0 ) { - char * szFile = hb_parc( 1 ); - BOOL fFree; + const char * szFile = hb_parc( 1 ); + char * pszFree; if( pFFData->ffind ) { @@ -131,13 +131,13 @@ static PHB_FFIND _hb_fileStart( BOOL fNext, ULONG ulAttr ) if( szFile ) { - szFile = ( char * ) hb_fsNameConv( ( BYTE * ) szFile, &fFree ); + szFile = hb_fsNameConv( szFile, &pszFree ); if( HB_ISNUM( 2 ) ) ulAttr = ( ULONG ) hb_parnl( 2 ); pFFData->ulAttr = HB_ISLOG( 3 ) && hb_parl( 3 ) ? ulAttr : 0; pFFData->ffind = hb_fsFindFirst( szFile, ulAttr ); - if( fFree ) - hb_xfree( szFile ); + if( pszFree ) + hb_xfree( pszFree ); while( pFFData->ffind && pFFData->ulAttr && pFFData->ffind->attr != pFFData->ulAttr ) { @@ -210,8 +210,8 @@ HB_FUNC( SETFATTR ) { int iResult; - if( hb_fsSetAttr( ( BYTE * ) hb_parcx( 1 ), - HB_ISNUM( 2 ) ? hb_parnl( 2 ) : HB_FA_ARCHIVE ) ) + if( hb_fsSetAttr( hb_parcx( 1 ), + HB_ISNUM( 2 ) ? hb_parnl( 2 ) : HB_FA_ARCHIVE ) ) iResult = 0; else iResult = -1; @@ -222,7 +222,7 @@ HB_FUNC( SETFATTR ) HB_FUNC( SETFDATI ) { - char *szFile = hb_parc( 1 ); + const char *szFile = hb_parc( 1 ); BOOL fResult = FALSE; if( szFile && *szFile ) @@ -252,7 +252,7 @@ HB_FUNC( SETFDATI ) else lMillisec = -1; } - fResult = hb_fsSetFileTime( ( BYTE * ) szFile, lJulian, lMillisec ); + fResult = hb_fsSetFileTime( szFile, lJulian, lMillisec ); } hb_retl( fResult ); @@ -265,20 +265,20 @@ HB_FUNC( FILEDELETE ) if( HB_ISCHAR( 1 ) ) { - BYTE * pDirSpec; + const char * pDirSpec; PHB_FFIND ffind; ULONG ulAttr = HB_FA_ALL; - BOOL fFree; + char * pszFree; - pDirSpec = hb_fsNameConv( ( BYTE * ) hb_parc( 1 ), &fFree ); + pDirSpec = hb_fsNameConv( hb_parc( 1 ), &pszFree ); if( HB_ISNUM( 2 ) ) ulAttr = hb_parnl( 2 ); - if( ( ffind = hb_fsFindFirst( ( char * ) pDirSpec, ulAttr ) ) != NULL ) + if( ( ffind = hb_fsFindFirst( pDirSpec, ulAttr ) ) != NULL ) { PHB_FNAME pFilepath; - pFilepath = hb_fsFNameSplit( ( char * ) pDirSpec ); + pFilepath = hb_fsFNameSplit( pDirSpec ); pFilepath->szExtension = NULL; do @@ -288,7 +288,7 @@ HB_FUNC( FILEDELETE ) pFilepath->szName = ffind->szName; hb_fsFNameMerge( szPath, pFilepath ); - if( hb_fsDelete( ( BYTE * ) szPath ) ) + if( hb_fsDelete( szPath ) ) bReturn = TRUE; } while( hb_fsFindNext( ffind ) ); @@ -296,8 +296,8 @@ HB_FUNC( FILEDELETE ) hb_xfree( pFilepath ); hb_fsFindClose( ffind ); } - if( fFree ) - hb_xfree( pDirSpec ); + if( pszFree ) + hb_xfree( pszFree ); } hb_retl( bReturn ); @@ -306,8 +306,8 @@ HB_FUNC( FILEDELETE ) HB_FUNC( FILEMOVE ) { - hb_retni( hb_fsRename( ( BYTE * ) hb_parcx( 1 ), - ( BYTE * ) hb_parcx( 2 ) ) ? 0 : -hb_fsOsError() ); + hb_retni( hb_fsRename( hb_parcx( 1 ), + hb_parcx( 2 ) ) ? 0 : -hb_fsOsError() ); } @@ -319,7 +319,7 @@ HB_FUNC( RENAMEFILE ) HB_FUNC( DELETEFILE ) { - hb_retni( hb_fsDelete( ( BYTE * ) hb_parcx( 1 ) ) ? 0 : -hb_fsOsError() ); + hb_retni( hb_fsDelete( hb_parcx( 1 ) ) ? 0 : -hb_fsOsError() ); } diff --git a/harbour/contrib/hbct/justify.c b/harbour/contrib/hbct/justify.c index 9ec4111309..df2c545e08 100644 --- a/harbour/contrib/hbct/justify.c +++ b/harbour/contrib/hbct/justify.c @@ -71,10 +71,11 @@ static void do_justify( int iSwitch ) if( HB_ISCHAR( 1 ) ) { - char *pcString = hb_parc( 1 ); + const char *pcString = hb_parc( 1 ); size_t sStrLen = hb_parclen( 1 ); char cJustChar; - char *pc, *pcRet; + const char *pc; + char *pcRet, *pcw; size_t sJustOffset; if( sStrLen == 0 ) @@ -106,9 +107,9 @@ static void do_justify( int iSwitch ) pc++; } hb_xmemcpy( pcRet, pcString + sJustOffset, sStrLen - sJustOffset ); - for( pc = pcRet + sStrLen - sJustOffset; pc < pcRet + sStrLen; pc++ ) + for( pcw = pcRet + sStrLen - sJustOffset; pc < pcRet + sStrLen; pc++ ) { - *pc = cJustChar; + *pcw = cJustChar; } break; @@ -120,9 +121,9 @@ static void do_justify( int iSwitch ) sJustOffset++; pc--; } - for( pc = pcRet; pc < pcRet + sJustOffset; pc++ ) + for( pcw = pcRet; pc < pcRet + sJustOffset; pc++ ) { - *pc = cJustChar; + *pcw = cJustChar; } hb_xmemcpy( pcRet + sJustOffset, pcString, sStrLen - sJustOffset ); break; diff --git a/harbour/contrib/hbct/like.c b/harbour/contrib/hbct/like.c index 9111371f77..06a8b9a0c1 100644 --- a/harbour/contrib/hbct/like.c +++ b/harbour/contrib/hbct/like.c @@ -55,8 +55,8 @@ HB_FUNC( LIKE ) { - char * szPattern = hb_parc( 1 ), - * szString = hb_parc( 2 ); + const char * szPattern = hb_parc( 1 ), + * szString = hb_parc( 2 ); hb_retl( szPattern && szString && hb_strMatchWildExact( szString, szPattern ) ); } diff --git a/harbour/contrib/hbct/maxline.c b/harbour/contrib/hbct/maxline.c index 7a67ed6933..40aa29aa53 100644 --- a/harbour/contrib/hbct/maxline.c +++ b/harbour/contrib/hbct/maxline.c @@ -59,8 +59,8 @@ HB_FUNC( MAXLINE ) if( HB_ISCHAR( 1 ) ) { - char *pcString = hb_parc( 1 ); - char *pBuffer; + const char *pcString = hb_parc( 1 ); + const char *pBuffer; LONG lStrLen = hb_parclen( 1 ); while( lStrLen > 0 ) diff --git a/harbour/contrib/hbct/misc2.c b/harbour/contrib/hbct/misc2.c index 11a975b9c9..81686d6147 100644 --- a/harbour/contrib/hbct/misc2.c +++ b/harbour/contrib/hbct/misc2.c @@ -65,7 +65,8 @@ HB_FUNC( COMPLEMENT ) if( ulLen > 0 ) { - char *szBuffer = ( char * ) hb_xgrab( ulLen + 1 ), *szSrc = hb_itemGetCPtr( pItem ); + const char *szSrc = hb_itemGetCPtr( pItem ); + char *szBuffer = ( char * ) hb_xgrab( ulLen + 1 ); for( ulPos = 0; ulPos < ulLen; ulPos++ ) szBuffer[ulPos] = ~szSrc[ulPos]; diff --git a/harbour/contrib/hbct/numat.c b/harbour/contrib/hbct/numat.c index 70dd3ecca2..b9944b8031 100644 --- a/harbour/contrib/hbct/numat.c +++ b/harbour/contrib/hbct/numat.c @@ -96,7 +96,7 @@ HB_FUNC( NUMAT ) char cAtLike = ct_getatlikechar(); size_t sIgnore, sMatchStrLen = 0, sSubStrLen; ULONG ulCounter; - char *pc, *pcSubStr; + const char *pc, *pcSubStr; /* eventually ignore some characters */ if( HB_ISNUM( 3 ) ) diff --git a/harbour/contrib/hbct/numline.c b/harbour/contrib/hbct/numline.c index 20ecdfe9f3..fcb6ccb60b 100644 --- a/harbour/contrib/hbct/numline.c +++ b/harbour/contrib/hbct/numline.c @@ -59,8 +59,8 @@ HB_FUNC( NUMLINE ) if( HB_ISCHAR( 1 ) ) { - char *pcString = hb_parc( 1 ); - char *pBuffer; + const char *pcString = hb_parc( 1 ); + const char *pBuffer; LONG lStrLen = hb_parclen( 1 ); LONG lLength = HB_ISNUM( 2 ) ? hb_parnl( 2 ) : 80; diff --git a/harbour/contrib/hbct/pos2.c b/harbour/contrib/hbct/pos2.c index c3103e0778..094991dae7 100644 --- a/harbour/contrib/hbct/pos2.c +++ b/harbour/contrib/hbct/pos2.c @@ -94,7 +94,7 @@ HB_FUNC( POSCHAR ) { if( ( hb_parclen( 2 ) > 0 ) || HB_ISNUM( 2 ) ) { - char *pcString = hb_parc( 1 ); + const char *pcString = hb_parc( 1 ); size_t sStrLen = hb_parclen( 1 ); char *pcRet; char cReplace; @@ -203,7 +203,7 @@ HB_FUNC( POSDEL ) { if( HB_ISCHAR( 1 ) ) { - char *pcString = hb_parc( 1 ); + const char *pcString = hb_parc( 1 ); size_t sStrLen = hb_parclen( 1 ); size_t sStartPos, sDelLen; char *pcRet; @@ -297,9 +297,9 @@ HB_FUNC( POSINS ) { if( HB_ISCHAR( 1 ) ) { - char *pcString = hb_parc( 1 ); + const char *pcString = hb_parc( 1 ); size_t sStrLen = hb_parclen( 1 ); - char *pcInsert; + const char *pcInsert; size_t sInsLen; if( ( sInsLen = hb_parclen( 2 ) ) > 0 ) @@ -410,9 +410,9 @@ HB_FUNC( POSREPL ) if( HB_ISCHAR( 1 ) ) { - char *pcString = hb_parc( 1 ); + const char *pcString = hb_parc( 1 ); size_t sStrLen = hb_parclen( 1 ); - char *pcReplace; + const char *pcReplace; size_t sReplLen; if( ( sReplLen = hb_parclen( 2 ) ) > 0 ) diff --git a/harbour/contrib/hbct/posdiff.c b/harbour/contrib/hbct/posdiff.c index fd4dc3ab27..84bf8de0cf 100644 --- a/harbour/contrib/hbct/posdiff.c +++ b/harbour/contrib/hbct/posdiff.c @@ -88,11 +88,11 @@ HB_FUNC( POSDIFF ) { if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) { - char *pcString1 = hb_parc( 1 ); + const char *pcString1 = hb_parc( 1 ); size_t sStrLen1 = hb_parclen( 1 ); - char *pcString2 = hb_parc( 2 ); + const char *pcString2 = hb_parc( 2 ); size_t sStrLen2 = hb_parclen( 2 ); - char *pc1, *pc2; + const char *pc1, *pc2; size_t sIgnore; if( HB_ISNUM( 3 ) ) @@ -186,11 +186,11 @@ HB_FUNC( POSEQUAL ) { if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) { - char *pcString1 = hb_parc( 1 ); + const char *pcString1 = hb_parc( 1 ); size_t sStrLen1 = hb_parclen( 1 ); - char *pcString2 = hb_parc( 2 ); + const char *pcString2 = hb_parc( 2 ); size_t sStrLen2 = hb_parclen( 2 ); - char *pc1, *pc2; + const char *pc1, *pc2; size_t sIgnore, sCompare, sCompareCnt, sRet = 0; if( HB_ISNUM( 4 ) ) diff --git a/harbour/contrib/hbct/print.c b/harbour/contrib/hbct/print.c index 3ba01281c9..2c3b4ca1a1 100644 --- a/harbour/contrib/hbct/print.c +++ b/harbour/contrib/hbct/print.c @@ -184,7 +184,7 @@ HB_FUNC( PRINTSEND ) } else if( HB_ISCHAR( 1 ) ) { - char *string = hb_parcx( 1 ); + const char *string = hb_parcx( 1 ); int i, len = hb_parclen( 1 ); r.h.ah = 0; @@ -201,9 +201,9 @@ HB_FUNC( PRINTSEND ) #elif defined( HB_OS_WIN_32 ) - char * szPort = "lpt1"; - char * szChr = " "; - char * szStr = NULL; + char szChr[ 2 ] = { ' ', '\0' }; + char szPort[ 5 ] = { 'l', 'p', 't', '1', '\0' }; + const char * szStr = NULL; USHORT usLen = 0, usRet = 0; if( HB_ISNUM( 1 ) ) @@ -223,10 +223,10 @@ HB_FUNC( PRINTSEND ) if( usLen ) { - HB_FHANDLE hFile = hb_fsOpen( ( BYTE * ) szPort, FO_WRITE ); + HB_FHANDLE hFile = hb_fsOpen( szPort, FO_WRITE ); if( hFile != FS_ERROR ) { - usRet = hb_fsWrite( hFile, ( BYTE * ) szStr, usLen ); + usRet = hb_fsWrite( hFile, ( const BYTE * ) szStr, usLen ); hb_fsClose( hFile ); } } diff --git a/harbour/contrib/hbct/relation.c b/harbour/contrib/hbct/relation.c index 655c8fe9f1..0708dbc509 100644 --- a/harbour/contrib/hbct/relation.c +++ b/harbour/contrib/hbct/relation.c @@ -89,16 +89,16 @@ HB_FUNC( CHARRELA ) { if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) && HB_ISCHAR( 3 ) && HB_ISCHAR( 4 ) ) { - char *pcStringToMatch1 = hb_parc( 1 ); + const char *pcStringToMatch1 = hb_parc( 1 ); size_t sStrToMatchLen1 = hb_parclen( 1 ); - char *pcString1 = hb_parc( 2 ); + const char *pcString1 = hb_parc( 2 ); size_t sStrLen1 = hb_parclen( 2 ); - char *pcStringToMatch2 = hb_parc( 3 ); + const char *pcStringToMatch2 = hb_parc( 3 ); size_t sStrToMatchLen2 = hb_parclen( 3 ); - char *pcString2 = hb_parc( 4 ); + const char *pcString2 = hb_parc( 4 ); size_t sStrLen2 = hb_parclen( 4 ); - char *pc1, *pc2; + const char *pc1, *pc2; size_t sOffset1, sOffset2; size_t sMatchStrLen; @@ -204,18 +204,18 @@ HB_FUNC( CHARRELREP ) if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) && HB_ISCHAR( 3 ) && HB_ISCHAR( 4 ) && HB_ISCHAR( 5 ) ) { - char *pcStringToMatch1 = hb_parc( 1 ); + const char *pcStringToMatch1 = hb_parc( 1 ); size_t sStrToMatchLen1 = hb_parclen( 1 ); - char *pcString1 = hb_parc( 2 ); + const char *pcString1 = hb_parc( 2 ); size_t sStrLen1 = hb_parclen( 2 ); - char *pcStringToMatch2 = hb_parc( 3 ); + const char *pcStringToMatch2 = hb_parc( 3 ); size_t sStrToMatchLen2 = hb_parclen( 3 ); - char *pcString2 = hb_parc( 4 ); + const char *pcString2 = hb_parc( 4 ); size_t sStrLen2 = hb_parclen( 4 ); - char *pcReplace = hb_parc( 5 ); + const char *pcReplace = hb_parc( 5 ); size_t sReplaceLen = hb_parclen( 5 ); char *pcRet; - char *pc1, *pc2; + const char *pc1, *pc2; size_t sOffset1, sOffset2; size_t sMatchStrLen; diff --git a/harbour/contrib/hbct/screen1.c b/harbour/contrib/hbct/screen1.c index acf02a2254..8e97193a10 100644 --- a/harbour/contrib/hbct/screen1.c +++ b/harbour/contrib/hbct/screen1.c @@ -148,7 +148,7 @@ HB_FUNC( SCREENMIX ) if( ulLen ) { - char * szText = hb_parc( 1 ); + const char * szText = hb_parc( 1 ); const char * szAttr; ULONG ulAttr = hb_parclen( 2 ), ul = 0; SHORT sRow, sCol; @@ -230,7 +230,7 @@ HB_FUNC( SAYSCREEN ) if( ulLen ) { - char * szText = hb_parc( 1 ); + const char * szText = hb_parc( 1 ); SHORT sRow, sCol; SHORT iRow, iCol, i; diff --git a/harbour/contrib/hbct/tab.c b/harbour/contrib/hbct/tab.c index ba7ac02c60..1a7843fad1 100644 --- a/harbour/contrib/hbct/tab.c +++ b/harbour/contrib/hbct/tab.c @@ -116,7 +116,7 @@ HB_FUNC( TABEXPAND ) size_t sRetLen; size_t sTabWidth = 0; char cFill, cTab, cCR; - char *pcNewLine; + const char *pcNewLine; size_t sNewLineLen; int iIgnore141; size_t sIndex, sLineIndex; @@ -317,7 +317,7 @@ HB_FUNC( TABPACK ) size_t sRetLen; size_t sTabWidth = 0; char cFill, cTab, cCR; - char *pcNewLine; + const char *pcNewLine; size_t sNewLineLen; int iIgnore141; size_t sIndex, sTabIndex, sFillCount; diff --git a/harbour/contrib/hbct/token1.c b/harbour/contrib/hbct/token1.c index 63a0c58650..93f59d446e 100644 --- a/harbour/contrib/hbct/token1.c +++ b/harbour/contrib/hbct/token1.c @@ -100,19 +100,19 @@ static void do_token1( int iSwitch ) if( iParamCheck ) { - char *pcString = hb_parc( 1 ); + const char *pcString = hb_parc( 1 ); size_t sStrLen = ( size_t ) hb_parclen( 1 ); - char *pcSeparatorStr; + const char *pcSeparatorStr; size_t sSeparatorStrLen; ULONG ulTokenCounter = 0; ULONG ulSkip; - char *pcSubStr; + const char *pcSubStr; char *pcRet = NULL; size_t sSubStrLen; size_t sRetStrLen = 0; ULONG ulToken = 0; ULONG ulSkipCnt; - char *pc; + const char *pc; /* separator string */ sSeparatorStrLen = hb_parclen( 2 ); @@ -282,7 +282,7 @@ static void do_token1( int iSwitch ) { if( ulSkip == 0xFFFFFFFFUL ) { - char *t; + const char *t; BOOL bLast = TRUE; for( t = pc + 1; t < pcString + sStrLen; t++ ) diff --git a/harbour/contrib/hbct/token2.c b/harbour/contrib/hbct/token2.c index ed931b9fd7..87890c3ff6 100644 --- a/harbour/contrib/hbct/token2.c +++ b/harbour/contrib/hbct/token2.c @@ -371,12 +371,12 @@ HB_FUNC( TOKENINIT ) { if( HB_ISCHAR( 1 ) ) { - char *pcString = hb_parc( 1 ); + const char *pcString = hb_parc( 1 ); size_t sStrLen = ( size_t ) hb_parclen( 1 ); - char *pcSeparatorStr; + const char *pcSeparatorStr; size_t sSeparatorStrLen; ULONG ulSkipCnt, ulSkip; - char *pcSubStr, *pc; + const char *pcSubStr, *pc; size_t sSubStrLen; TOKEN_ENVIRONMENT sTokenEnvironment; TOKEN_POSITION sTokenPosition; @@ -577,7 +577,7 @@ HB_FUNC( TOKENNEXT ) { if( HB_ISCHAR( 1 ) ) { - char *pcString = hb_parc( 1 ); + const char *pcString = hb_parc( 1 ); size_t sStrLen = ( size_t ) hb_parclen( 1 ); TOKEN_ENVIRONMENT sTokenEnvironment; diff --git a/harbour/contrib/hbct/video.c b/harbour/contrib/hbct/video.c index 03cb2bec68..ff7665d29d 100644 --- a/harbour/contrib/hbct/video.c +++ b/harbour/contrib/hbct/video.c @@ -145,7 +145,7 @@ HB_FUNC( CHARPIX ) HB_FUNC( VGAPALETTE ) { - char *color_string; + const char *color_string; char red, green, blue; char attr = 0; @@ -161,7 +161,7 @@ HB_FUNC( VGAPALETTE ) } else if( HB_ISCHAR( 1 ) ) { - char *s; + const char *s; color_string = hb_parcx( 1 ); for( s = color_string; *s; s++ ) @@ -339,7 +339,7 @@ HB_FUNC( VIDEOTYPE ) HB_FUNC( SETFONT ) { - char *font = hb_parcx( 1 ); + const char *font = hb_parcx( 1 ); int len = hb_parclen( 1 ); int area = hb_parni( 2 ); int offset = 0; diff --git a/harbour/contrib/hbct/wordrepl.c b/harbour/contrib/hbct/wordrepl.c index e5ebf432dc..1d34887eee 100644 --- a/harbour/contrib/hbct/wordrepl.c +++ b/harbour/contrib/hbct/wordrepl.c @@ -136,10 +136,10 @@ HB_FUNC( WORDREPL ) ( sReplaceLen = ( size_t ) hb_parclen( 3 ) ) / 2 > 0 ) { /* get parameters */ - char *pcSearch = hb_parc( 1 ); - char *pcString = hb_parc( 2 ); + const char *pcSearch = hb_parc( 1 ); + const char *pcString = hb_parc( 2 ); size_t sStrLen = ( size_t ) hb_parclen( 2 ); - char *pcReplace = hb_parc( 3 ); + const char *pcReplace = hb_parc( 3 ); int iMode; char *pcRet; size_t sIndex; @@ -156,7 +156,7 @@ HB_FUNC( WORDREPL ) { size_t sMatchStrLen; - char *pc; + const char *pc; size_t sReplIndex = sIndex; if( sReplIndex > ( sReplaceLen & 0xFFFFFFFE ) ) diff --git a/harbour/contrib/hbct/wordtoch.c b/harbour/contrib/hbct/wordtoch.c index 3482246a55..78b4836275 100644 --- a/harbour/contrib/hbct/wordtoch.c +++ b/harbour/contrib/hbct/wordtoch.c @@ -99,9 +99,9 @@ HB_FUNC( WORDTOCHAR ) { /* get parameters */ - char *pcSearch = ( char * ) hb_parc( 1 ); - char *pcString = ( char * ) hb_parc( 2 ); - char *pcReplace = ( char * ) hb_parc( 3 ); + const char *pcSearch = hb_parc( 1 ); + const char *pcString = hb_parc( 2 ); + const char *pcReplace = hb_parc( 3 ); char *pcRet; size_t sRetIndex, sIndex; int iNoReplace; @@ -116,7 +116,7 @@ HB_FUNC( WORDTOCHAR ) do { size_t sMatchStrLen; - char *pc; + const char *pc; size_t sReplIndex; *( pcRet + sRetIndex + 1 ) = *( pcString + sIndex + 1 ); diff --git a/harbour/contrib/hbcurl/hbcurl.c b/harbour/contrib/hbcurl/hbcurl.c index f25c38eba5..5606b23e5a 100644 --- a/harbour/contrib/hbcurl/hbcurl.c +++ b/harbour/contrib/hbcurl/hbcurl.c @@ -95,10 +95,10 @@ typedef struct _HB_CURL struct curl_slist * pPREQUOTE; struct curl_slist * pTELNETOPTIONS; - BYTE * ul_name; + char * ul_name; HB_FHANDLE ul_handle; - BYTE * dl_name; + char * dl_name; HB_FHANDLE dl_handle; BYTE * ul_ptr; @@ -302,7 +302,7 @@ size_t hb_curl_write_file_callback( void * buffer, size_t size, size_t nmemb, vo return ( size_t ) -1; } - return hb_fsWriteLarge( hb_curl->dl_handle, ( BYTE * ) buffer, size * nmemb ); + return hb_fsWriteLarge( hb_curl->dl_handle, ( const BYTE * ) buffer, size * nmemb ); } return ( size_t ) -1; @@ -1378,7 +1378,7 @@ HB_FUNC( CURL_EASY_SETOPT ) if( HB_ISCHAR( 3 ) ) { - hb_curl->ul_name = ( BYTE * ) hb_strdup( hb_parc( 3 ) ); + hb_curl->ul_name = hb_strdup( hb_parc( 3 ) ); hb_curl->ul_handle = FS_ERROR; curl_easy_setopt( hb_curl->curl, CURLOPT_READFUNCTION, hb_curl_read_file_callback ); @@ -1398,7 +1398,7 @@ HB_FUNC( CURL_EASY_SETOPT ) if( HB_ISCHAR( 3 ) ) { - hb_curl->dl_name = ( BYTE * ) hb_strdup( hb_parc( 3 ) ); + hb_curl->dl_name = hb_strdup( hb_parc( 3 ) ); hb_curl->dl_handle = FS_ERROR; curl_easy_setopt( hb_curl->curl, CURLOPT_WRITEFUNCTION, hb_curl_write_file_callback ); diff --git a/harbour/contrib/hbgt/asciisgt.c b/harbour/contrib/hbgt/asciisgt.c index d17103956f..d502fb2131 100644 --- a/harbour/contrib/hbgt/asciisgt.c +++ b/harbour/contrib/hbgt/asciisgt.c @@ -19,7 +19,7 @@ HB_FUNC( GT_ASCIISUM ) { - char *str; + const char *str; int len, i; long ascSum = 0; diff --git a/harbour/contrib/hbgt/ascposgt.c b/harbour/contrib/hbgt/ascposgt.c index 50db84f3ea..9cf6698b8e 100644 --- a/harbour/contrib/hbgt/ascposgt.c +++ b/harbour/contrib/hbgt/ascposgt.c @@ -21,7 +21,7 @@ HB_FUNC( GT_ASCPOS ) { - char *s; + const char *s; ULONG p; if (ISCHAR(1) && HB_ISNUM(2)) { diff --git a/harbour/contrib/hbgt/atdiff.c b/harbour/contrib/hbgt/atdiff.c index f6729fdad9..e8d5b28033 100644 --- a/harbour/contrib/hbgt/atdiff.c +++ b/harbour/contrib/hbgt/atdiff.c @@ -21,7 +21,7 @@ HB_FUNC( GT_ATDIFF ) { - char *s1, *s2; + const char *s1, *s2; int pos, len; if (ISCHAR(1) && HB_ISCHAR(2)) { diff --git a/harbour/contrib/hbgt/chareven.c b/harbour/contrib/hbgt/chareven.c index 2dc712d4f3..9445993ee5 100644 --- a/harbour/contrib/hbgt/chareven.c +++ b/harbour/contrib/hbgt/chareven.c @@ -21,21 +21,21 @@ HB_FUNC( GT_CHAREVEN ) { - char *s1, *s2; + const char *s1; + char *s2; int len, i; if (ISCHAR(1)) { s1 = hb_parc(1); len = hb_parclen(1); - s2 = (char *)hb_xgrab(len / 2); /* grab us some mem to work with */ + s2 = (char *) hb_xgrab(len / 2 + 1); /* grab us some mem to work with */ for (i = 1; i <= len; i += 2) s2[(i - 1)/2] = s1[i] & 0x7f; - hb_retclen(s2, len); - hb_xfree(s2); /* free alloc'ed mem */ + hb_retclen_buffer(s2, len/2); } else { - hb_retc((char *) NULL); /* parameter mismatch - error NullStr */ + hb_retc_null(); /* parameter mismatch - error NullStr */ } } diff --git a/harbour/contrib/hbgt/charmixg.c b/harbour/contrib/hbgt/charmixg.c index 11d7699989..b182dd4ceb 100644 --- a/harbour/contrib/hbgt/charmixg.c +++ b/harbour/contrib/hbgt/charmixg.c @@ -21,7 +21,8 @@ HB_FUNC( GT_CHARMIX ) { - char *s1, *s2, *s3; + const char *s1, *s2; + char *s3; int l1, l2, i, pos3; if (ISCHAR(1) && HB_ISCHAR(2)) { diff --git a/harbour/contrib/hbgt/charodd.c b/harbour/contrib/hbgt/charodd.c index 3edd6bf028..5615f6e0e0 100644 --- a/harbour/contrib/hbgt/charodd.c +++ b/harbour/contrib/hbgt/charodd.c @@ -21,7 +21,8 @@ HB_FUNC( GT_CHARODD ) { - char *s1, *s2; + const char *s1; + char *s2; int len, i; if (ISCHAR(1)) { diff --git a/harbour/contrib/hbgt/chrcount.c b/harbour/contrib/hbgt/chrcount.c index 7f0cb21144..639cd2edcd 100644 --- a/harbour/contrib/hbgt/chrcount.c +++ b/harbour/contrib/hbgt/chrcount.c @@ -21,7 +21,7 @@ HB_FUNC( GT_CHRCOUNT ) { - char *s1, *s2; + const char *s1, *s2; int count, pos2, len; if (ISCHAR(1) && HB_ISCHAR(2)) { diff --git a/harbour/contrib/hbgt/chrfirst.c b/harbour/contrib/hbgt/chrfirst.c index f6d7ca7b12..061af50c24 100644 --- a/harbour/contrib/hbgt/chrfirst.c +++ b/harbour/contrib/hbgt/chrfirst.c @@ -21,8 +21,8 @@ HB_FUNC( GT_CHRFIRST ) { - char *string; - char *cset; + const char *string; + const char *cset; int l1, l2; int p1, p2; diff --git a/harbour/contrib/hbgt/chrtotal.c b/harbour/contrib/hbgt/chrtotal.c index 47fc37367c..13926bdae1 100644 --- a/harbour/contrib/hbgt/chrtotal.c +++ b/harbour/contrib/hbgt/chrtotal.c @@ -21,7 +21,7 @@ HB_FUNC( GT_CHRTOTAL ) { - char *s1, *s2; + const char *s1, *s2; int count, p1, p2, l2, l1; if (ISCHAR(1) && HB_ISCHAR(2)) { diff --git a/harbour/contrib/hbgt/strcount.c b/harbour/contrib/hbgt/strcount.c index 86bf3fcfaa..dd04365789 100644 --- a/harbour/contrib/hbgt/strcount.c +++ b/harbour/contrib/hbgt/strcount.c @@ -21,7 +21,7 @@ HB_FUNC( GT_STRCOUNT ) { - char *s1, *s2; + const char *s1, *s2; int count, p1, p2, l1, l2; int match; diff --git a/harbour/contrib/hbgt/strcspn.c b/harbour/contrib/hbgt/strcspn.c index 0a84a1a234..bd725db2a3 100644 --- a/harbour/contrib/hbgt/strcspn.c +++ b/harbour/contrib/hbgt/strcspn.c @@ -21,8 +21,8 @@ HB_FUNC( GT_STRCSPN ) { - char *string; - char *cset; + const char *string; + const char *cset; int l1, l2; int p1, p2; diff --git a/harbour/contrib/hbgt/strdiffg.c b/harbour/contrib/hbgt/strdiffg.c index da53ec98d1..7b0987f42c 100644 --- a/harbour/contrib/hbgt/strdiffg.c +++ b/harbour/contrib/hbgt/strdiffg.c @@ -21,7 +21,7 @@ HB_FUNC( GT_STRDIFF ) { - char *s1, *s2; + const char *s1, *s2; int pos, len; if (ISCHAR(1) && HB_ISCHAR(2)) { diff --git a/harbour/contrib/hbgt/strexpan.c b/harbour/contrib/hbgt/strexpan.c index 425d74ad0b..c69704b0d3 100644 --- a/harbour/contrib/hbgt/strexpan.c +++ b/harbour/contrib/hbgt/strexpan.c @@ -21,7 +21,8 @@ HB_FUNC( GT_STREXPAND ) { - char *in, *out; + const char *in; + char *out; int nIns = 1; const char *insert = " "; int len; diff --git a/harbour/contrib/hbgt/strleft.c b/harbour/contrib/hbgt/strleft.c index a0cc1bf5fb..d5b42fc356 100644 --- a/harbour/contrib/hbgt/strleft.c +++ b/harbour/contrib/hbgt/strleft.c @@ -21,8 +21,8 @@ HB_FUNC( GT_STRLEFT ) { - char *string; - char *cset; + const char *string; + const char *cset; int l1, l2; int p1, p2; diff --git a/harbour/contrib/hbgt/strpbrk.c b/harbour/contrib/hbgt/strpbrk.c index ff8ece3a1c..65e617c2c2 100644 --- a/harbour/contrib/hbgt/strpbrk.c +++ b/harbour/contrib/hbgt/strpbrk.c @@ -21,8 +21,8 @@ HB_FUNC( GT_STRPBRK ) { - char *string; - char *cset; + const char *string; + const char *cset; int l1, l2; int p1, p2; diff --git a/harbour/contrib/hbgt/strright.c b/harbour/contrib/hbgt/strright.c index 2c34d0b626..1a36f1b7ad 100644 --- a/harbour/contrib/hbgt/strright.c +++ b/harbour/contrib/hbgt/strright.c @@ -21,8 +21,8 @@ HB_FUNC( GT_STRRIGHT ) { - char *string; - char *cset; + const char *string; + const char *cset; int l1, l2; int p1, p2; diff --git a/harbour/contrib/hbhpdf/harupdf.c b/harbour/contrib/hbhpdf/harupdf.c index b1d4cd9965..b13b2597d7 100644 --- a/harbour/contrib/hbhpdf/harupdf.c +++ b/harbour/contrib/hbhpdf/harupdf.c @@ -143,13 +143,13 @@ HB_FUNC( HPDF_FREEDOCALL ) */ HB_FUNC( HPDF_SAVETOFILE ) { - BOOL fFree; - BYTE * pszFileName = hb_fsNameConv( ( BYTE * ) hb_parc( 2 ), &fFree ); + char * pszFree; + const char * pszFileName = hb_fsNameConv( hb_parcx( 2 ), &pszFree ); - hb_retnl( ( long ) HPDF_SaveToFile( HPDF_Doc_par( 1 ), ( char * ) pszFileName ) ); + hb_retnl( ( long ) HPDF_SaveToFile( HPDF_Doc_par( 1 ), pszFileName ) ); - if( fFree ) - hb_xfree( ( void * ) pszFileName ); + if( pszFree ) + hb_xfree( ( void * ) pszFree ); } /*----------------------------------------------------------------------*/ /* HPdf_SaveToStream( hDoc ) -> hStatus @@ -308,44 +308,44 @@ HB_FUNC( HPDF_GETFONT ) */ HB_FUNC( HPDF_LOADTYPE1FONTFROMFILE ) { - BOOL fFree1; - BYTE * pszFileName1 = hb_fsNameConv( ( BYTE * ) hb_parc( 2 ), &fFree1 ); - BOOL fFree2; - BYTE * pszFileName2 = hb_fsNameConv( ( BYTE * ) hb_parc( 3 ), &fFree2 ); + char * pszFree1; + const char * pszFileName1 = hb_fsNameConv( hb_parcx( 2 ), &pszFree1 ); + char * pszFree2; + const char * pszFileName2 = hb_fsNameConv( hb_parcx( 3 ), &pszFree2 ); - hb_retc( HPDF_LoadType1FontFromFile( HPDF_Doc_par( 1 ), ( char * ) pszFileName1, ( char * ) pszFileName2 ) ); + hb_retc( HPDF_LoadType1FontFromFile( HPDF_Doc_par( 1 ), pszFileName1, pszFileName2 ) ); - if( fFree1 ) - hb_xfree( pszFileName1 ); + if( pszFree1 ) + hb_xfree( pszFree1 ); - if( fFree2 ) - hb_xfree( pszFileName2 ); + if( pszFree2 ) + hb_xfree( pszFree2 ); } /*----------------------------------------------------------------------*/ /* HPdf_LoadTTFontFromFile( hDoc, cTTFontFileName, lEmbed ) -> cFontName */ HB_FUNC( HPDF_LOADTTFONTFROMFILE ) { - BOOL fFree; - BYTE * pszFileName = hb_fsNameConv( ( BYTE * ) hb_parc( 2 ), &fFree ); + char * pszFree; + const char * pszFileName = hb_fsNameConv( hb_parcx( 2 ), &pszFree ); - hb_retc( HPDF_LoadTTFontFromFile( HPDF_Doc_par( 1 ), ( char * ) pszFileName, hb_parl( 3 ) ) ); + hb_retc( HPDF_LoadTTFontFromFile( HPDF_Doc_par( 1 ), pszFileName, hb_parl( 3 ) ) ); - if( fFree ) - hb_xfree( ( void * ) pszFileName ); + if( pszFree ) + hb_xfree( pszFree ); } /*----------------------------------------------------------------------*/ /* HPdf_LoadTTFontFromFile2( hDoc, cTTFontFileName, nIndexInFile, lEmbed ) -> cFontName */ HB_FUNC( HPDF_LOADTTFONTFROMFILE2 ) { - BOOL fFree; - BYTE * pszFileName = hb_fsNameConv( ( BYTE * ) hb_parc( 2 ), &fFree ); + char * pszFree; + const char * pszFileName = hb_fsNameConv( hb_parcx( 2 ), &pszFree ); - hb_retc( HPDF_LoadTTFontFromFile2( HPDF_Doc_par( 1 ), ( char * ) pszFileName, hb_parni( 3 ), hb_parl( 4 ) ) ); + hb_retc( HPDF_LoadTTFontFromFile2( HPDF_Doc_par( 1 ), pszFileName, hb_parni( 3 ), hb_parl( 4 ) ) ); - if( fFree ) - hb_xfree( ( void * ) pszFileName ); + if( pszFree ) + hb_xfree( pszFree ); } /*----------------------------------------------------------------------*/ /* HPdf_AddPageLabel( hDoc, nPageNum, nPgNoStyle, nFirstPageInRange, cPrefixToLabel ) -> hStatus diff --git a/harbour/contrib/hbmisc/hb_f.c b/harbour/contrib/hbmisc/hb_f.c index a73e40d197..66125e31a5 100644 --- a/harbour/contrib/hbmisc/hb_f.c +++ b/harbour/contrib/hbmisc/hb_f.c @@ -81,7 +81,7 @@ HB_FUNC( HB_FUSE ) else open_flags = 0; - handles[area] = hb_fsOpen( ( BYTE * ) hb_parc( 1 ), ( SHORT ) open_flags ); + handles[area] = hb_fsOpen( hb_parc( 1 ), ( SHORT ) open_flags ); offset[area] = 0; recno[area] = 1; b = ( char * ) hb_xgrab( b_size ); diff --git a/harbour/contrib/hbmisc/spd.c b/harbour/contrib/hbmisc/spd.c index ca6d9db1f3..03293d2b8a 100644 --- a/harbour/contrib/hbmisc/spd.c +++ b/harbour/contrib/hbmisc/spd.c @@ -58,7 +58,8 @@ static void STAItm( PHB_ITEM pItmPar ) { ULONG i, ulItmPar = hb_itemGetCLen( pItmPar ); - char *cRes, *c, *cItmPar = hb_itemGetCPtr( pItmPar ); + const char *cItmPar = hb_itemGetCPtr( pItmPar ), *c; + char *cRes; for( i = 3, c = cItmPar; *c; c++ ){ if( *c == '\'' ) i++; /* Count ' Tokens */ @@ -180,7 +181,8 @@ static ULONG SCItm( char *cBuffer, ULONG ulMaxBuf, char *cParFrm, int iCOut, int HB_FUNC( SQL_SPRINTF ) { ULONG ulItmFrm; - char *cRes, *cItmFrm; + const char *cItmFrm; + char *cRes; int argc = hb_pcount() - 1; PHB_ITEM pItmFrm = hb_param( 1, HB_IT_STRING ); @@ -194,7 +196,8 @@ HB_FUNC( SQL_SPRINTF ) hb_retclen_buffer( cRes, ulItmFrm ); }else{ PHB_ITEM pItmPar, pItmCpy; - char *cIntMod, *cBuffer, *cParFrm, *c; + char *cIntMod, *cBuffer, *cParFrm; + const char *c; int p, arg, iCOut, IsType, IsIndW, IsIndP, iIndWidth, iIndPrec, iErrorPar = 0; ULONG s, f, i, ulWidth, ulParPos = 0, ulResPos = 0, ulMaxBuf = DK_INCBUF, ulMaxRes = DK_INCRES; static char cToken[] = "stcdiouxXaAeEfgGpnSC"; @@ -419,7 +422,8 @@ HB_FUNC( SQL_SPRINTF ) if( iCOut == 's' ) hb_itemRelease( pItmPar ); }else if( iCOut == 's' ){ - char *cTrimStr, *cStr = hb_itemStr( pItmPar, NULL, NULL ); + char *cStr = hb_itemStr( pItmPar, NULL, NULL ); + const char *cTrimStr; if( cStr ){ f = strlen( cStr ); cTrimStr = hb_strLTrim( cStr, &f ); diff --git a/harbour/contrib/hbmisc/strfmt.c b/harbour/contrib/hbmisc/strfmt.c index 9fc8531974..f5e6cde478 100644 --- a/harbour/contrib/hbmisc/strfmt.c +++ b/harbour/contrib/hbmisc/strfmt.c @@ -59,7 +59,7 @@ typedef struct { char * raw; - char * buffer; + const char * buffer; ULONG ulLen; BOOL bFreeReq; } STRPAR; diff --git a/harbour/contrib/hbmisc/stringsx.c b/harbour/contrib/hbmisc/stringsx.c index 3dcdf06c31..bae5bbf54e 100644 --- a/harbour/contrib/hbmisc/stringsx.c +++ b/harbour/contrib/hbmisc/stringsx.c @@ -6,7 +6,7 @@ /* TODO: search this file for TODO and find 'em! */ -static const char *hb_strtoken(char *szText, +static const char *hb_strtoken(const char *szText, long lText, long lIndex, char cDelimiter, @@ -76,7 +76,7 @@ HB_FUNC( STRTOKEN ) /* debug function to dump the ASCII values of an entire string */ HB_FUNC( STRDUMP ) { - char *szText = hb_parc(1); + const char *szText = hb_parc(1); long i, lLength = hb_parclen(1); for( i = 0; i < lLength; i++ ) printf("%d ", szText[i]); @@ -87,7 +87,7 @@ HB_FUNC( ROT13 ) { if( HB_ISCHAR(1) ) { - char *szText = hb_parc( 1 ); + const char *szText = hb_parc( 1 ); ULONG i, lLen = hb_parclen( 1 ); char *szResult = (char*)hb_xgrab(lLen + 1); diff --git a/harbour/contrib/hbmysql/mysql.c b/harbour/contrib/hbmysql/mysql.c index e70d0bc245..be64028ef5 100644 --- a/harbour/contrib/hbmysql/mysql.c +++ b/harbour/contrib/hbmysql/mysql.c @@ -320,7 +320,7 @@ HB_FUNC( MYSQL_ESCAPE_STRING ) static char * filetoBuff( const char * fname, int * size ) { char * buffer = NULL; - HB_FHANDLE handle = hb_fsOpen( ( BYTE * ) fname, FO_READWRITE ); + HB_FHANDLE handle = hb_fsOpen( fname, FO_READWRITE ); if( handle != FS_ERROR ) { diff --git a/harbour/contrib/hbmzip/hbmzip.c b/harbour/contrib/hbmzip/hbmzip.c index b651938b99..4452cd06bd 100644 --- a/harbour/contrib/hbmzip/hbmzip.c +++ b/harbour/contrib/hbmzip/hbmzip.c @@ -478,26 +478,26 @@ HB_FUNC( HB_UNZIPFILEOPEN ) HB_FUNC( HB_UNZIPFILEREAD ) { PHB_ITEM pBuffer = hb_param( 2, HB_IT_STRING ); + char * buffer; + ULONG ulSize; - if( pBuffer && HB_ISBYREF( 2 ) ) + if( pBuffer && HB_ISBYREF( 2 ) && + hb_itemGetWriteCL( pBuffer, &buffer, &ulSize ) ) { unzFile hUnzip = hb_unzipfileParam( 1 ); if( hUnzip ) { - ULONG ulRead; - ULONG ulSize = hb_parclen( 2 ); int iResult; if( HB_ISNUM( 3 ) ) { - ulRead = (ULONG) hb_parnl( 3 ); + ULONG ulRead = (ULONG) hb_parnl( 3 ); if( ulRead < ulSize ) ulSize = ulRead; } - pBuffer = hb_itemUnShareString( pBuffer ); - iResult = unzReadCurrentFile( hUnzip, hb_itemGetCPtr( pBuffer ), ulSize ); + iResult = unzReadCurrentFile( hUnzip, buffer, ulSize ); hb_retnl( iResult ); } } @@ -868,7 +868,7 @@ static int hb_zipStoreFile( zipFile hZip, const char* szFileName, const char* sz } else { - hFile = hb_fsOpen( ( BYTE * ) szFileName, FO_READ ); + hFile = hb_fsOpen( szFileName, FO_READ ); if( hFile != FS_ERROR ) { @@ -1058,7 +1058,7 @@ static int hb_unzipExtractCurrentFile( unzFile hUnzip, const char* szFileName, c if( ( cSep == '\\' || cSep == '/' ) && ulPos < ulLen - 1 ) { szName[ ulPos ] = '\0'; - hb_fsMkDir( (BYTE*) szName ); + hb_fsMkDir( szName ); szName[ ulPos ] = cSep; } ulPos++; @@ -1066,12 +1066,12 @@ static int hb_unzipExtractCurrentFile( unzFile hUnzip, const char* szFileName, c if( ufi.external_fa & 0x40000000 ) /* DIRECTORY */ { - hb_fsMkDir( (BYTE*) szName ); + hb_fsMkDir( szName ); iResult = UNZ_OK; } else { - hFile = hb_fsCreate( (BYTE*) szName, FC_NORMAL ); + hFile = hb_fsCreate( szName, FC_NORMAL ); if( hFile != FS_ERROR ) { @@ -1079,7 +1079,8 @@ static int hb_unzipExtractCurrentFile( unzFile hUnzip, const char* szFileName, c while( ( iResult = unzReadCurrentFile( hUnzip, pString, HB_Z_IOBUF_SIZE ) ) > 0 ) { - hb_fsWriteLarge( hFile, (BYTE*) pString, (ULONG) iResult ); + hb_fsWriteLarge( hFile, ( const BYTE* + ) pString, (ULONG) iResult ); } hb_xfree( pString ); @@ -1324,7 +1325,7 @@ static int hb_zipDeleteFile( const char* szZipFile, const char* szFileMask ) return UNZ_ERRNO; pFileName = hb_fsFNameSplit( szZipFile ); - hFile = hb_fsCreateTemp( ( BYTE * ) pFileName->szPath, NULL, FC_NORMAL, ( BYTE * ) szTempFile ); + hFile = hb_fsCreateTemp( pFileName->szPath, NULL, FC_NORMAL, szTempFile ); hZip = NULL; if( hFile != FS_ERROR ) { @@ -1482,14 +1483,14 @@ static int hb_zipDeleteFile( const char* szZipFile, const char* szFileMask ) hb_xfree( pszGlobalComment ); if( iResult != UNZ_OK ) - hb_fsDelete( ( BYTE * ) szTempFile ); + hb_fsDelete( szTempFile ); else { - hb_fsDelete( ( BYTE * ) szZipFile ); + hb_fsDelete( szZipFile ); if( iFilesLeft == 0 ) - hb_fsDelete( ( BYTE * ) szTempFile ); - else if( !hb_fsRename( ( BYTE * ) szTempFile, ( BYTE * ) szZipFile ) ) + hb_fsDelete( szTempFile ); + else if( !hb_fsRename( szTempFile, szZipFile ) ) iResult = UNZ_ERRNO; } diff --git a/harbour/contrib/hbnf/chdir.c b/harbour/contrib/hbnf/chdir.c index da1da5376b..2cdd955f14 100644 --- a/harbour/contrib/hbnf/chdir.c +++ b/harbour/contrib/hbnf/chdir.c @@ -83,5 +83,5 @@ End HB_FUNC( FT_CHDIR) { - hb_retl( HB_ISCHAR( 1 ) && hb_fsChDir( ( BYTE * ) hb_parc(1) ) ); + hb_retl( HB_ISCHAR( 1 ) && hb_fsChDir( hb_parc( 1 ) ) ); } diff --git a/harbour/contrib/hbnf/ftattr.c b/harbour/contrib/hbnf/ftattr.c index 9173bb58d1..68d40eeae5 100644 --- a/harbour/contrib/hbnf/ftattr.c +++ b/harbour/contrib/hbnf/ftattr.c @@ -392,7 +392,7 @@ HB_FUNC( FT_RESTATT ) USHORT uiMaxCol = hb_gtMaxCol(); USHORT uiBottom = HB_ISNUM( 3 ) ? ( USHORT ) hb_parni( 3 ) : hb_gtMaxRow(); USHORT uiRight = HB_ISNUM( 4 ) ? ( USHORT ) hb_parni( 4 ) : hb_gtMaxCol(); - char * pAttrib = hb_parc( 5 ); + const char * pAttrib = hb_parc( 5 ); if( uiBottom > uiMaxRow ) uiBottom = uiMaxRow; diff --git a/harbour/contrib/hbnf/fttext.c b/harbour/contrib/hbnf/fttext.c index bbca307ee5..76aa5a9314 100644 --- a/harbour/contrib/hbnf/fttext.c +++ b/harbour/contrib/hbnf/fttext.c @@ -304,7 +304,7 @@ HB_FUNC( FT_FUSE ) if ( HB_ISCHAR(1) ) { - handles[area] = hb_fsOpen( ( BYTE * ) hb_parc(1), ( USHORT ) attr ) ; + handles[area] = hb_fsOpen( hb_parc(1), ( USHORT ) attr ) ; if( handles[area] <= 0 ) error[area] = hb_fsError(); offset[area] = 0 ; @@ -1976,7 +1976,7 @@ static int _writeLine( BYTE * theData, ULONG iDataLen ) static BOOL _writeeol( HB_FHANDLE fhnd ) { - char * crlf = hb_conNewLine(); + const char * crlf = hb_conNewLine(); ULONG len = strlen( crlf ); return hb_fsWriteLarge( fhnd, ( BYTE * ) crlf, len ) == ( ULONG ) len; diff --git a/harbour/contrib/hbnf/getver.c b/harbour/contrib/hbnf/getver.c index 69ac46e4f9..4861cc018d 100644 --- a/harbour/contrib/hbnf/getver.c +++ b/harbour/contrib/hbnf/getver.c @@ -149,7 +149,7 @@ HB_FUNC( _FT_TEMPFIL ) { int nax; int iflags; - char * cPath; + const char * cPath; #if defined(HB_OS_DOS) && !defined(HB_OS_DOS_32) { diff --git a/harbour/contrib/hbnf/mkdir.c b/harbour/contrib/hbnf/mkdir.c index 248ce345a3..437f953b5f 100644 --- a/harbour/contrib/hbnf/mkdir.c +++ b/harbour/contrib/hbnf/mkdir.c @@ -86,5 +86,5 @@ End HB_FUNC(FT_MKDIR) { - hb_retl( HB_ISCHAR( 1 ) && hb_fsMkDir( ( BYTE * ) hb_parc(1) ) ); + hb_retl( HB_ISCHAR( 1 ) && hb_fsMkDir( hb_parc(1) ) ); } diff --git a/harbour/contrib/hbnf/proper.c b/harbour/contrib/hbnf/proper.c index 68b8ca5608..43847d9f6b 100644 --- a/harbour/contrib/hbnf/proper.c +++ b/harbour/contrib/hbnf/proper.c @@ -99,8 +99,9 @@ static int _ftIsAlpha( char c ) HB_FUNC( FT_PROPER ) { - int iLen = hb_parclen(1); - char *cStr, *cDst = NULL; + int iLen = hb_parclen(1); + const char *cStr; + char *cDst = NULL; int i, fCap = TRUE; /*, iPos = 0; */ hb_storc( NULL, 1 ); @@ -111,12 +112,11 @@ HB_FUNC( FT_PROPER ) if( !cDst ) { cDst = (char *) hb_xgrab(iLen + 1); memcpy(cDst, cStr, iLen + 1); - cStr = cDst; } if( fCap != 0 ) - cStr[i] = _ftToUpper( cStr[i] ); + cDst[i] = _ftToUpper( cDst[i] ); else - cStr[i] = _ftToLower( cStr[i] ); + cDst[i] = _ftToLower( cDst[i] ); } fCap = ( cStr[i] == ' ' || cStr[i] == '-' || cStr[i] == 0x27 ); } @@ -125,7 +125,7 @@ HB_FUNC( FT_PROPER ) if( cDst ) { for( i = 0; i < iLen - 2; i++ ) if( cStr[i] == 'M' && cStr[i+1] == 'c' ) { - cStr[i+2] = _ftToUpper( cStr[i+2] ); + cDst[i+2] = _ftToUpper( cDst[i+2] ); } } /* // If "Mc" was found, Cap next letter if Alpha diff --git a/harbour/contrib/hbnf/rmdir.c b/harbour/contrib/hbnf/rmdir.c index 104102e25a..68d592ff2a 100644 --- a/harbour/contrib/hbnf/rmdir.c +++ b/harbour/contrib/hbnf/rmdir.c @@ -85,5 +85,5 @@ End HB_FUNC(FT_RMDIR) { - hb_retl( HB_ISCHAR( 1 ) && hb_fsRmDir( ( BYTE * ) hb_parc(1) ) ); + hb_retl( HB_ISCHAR( 1 ) && hb_fsRmDir( hb_parc(1) ) ); } diff --git a/harbour/contrib/hbsqlit3/hbsqlit3.c b/harbour/contrib/hbsqlit3/hbsqlit3.c index 96e8e850d5..9fcc25561d 100644 --- a/harbour/contrib/hbsqlit3/hbsqlit3.c +++ b/harbour/contrib/hbsqlit3/hbsqlit3.c @@ -597,8 +597,8 @@ HB_FUNC( SQLITE3_TEMP_DIRECTORY ) HB_FUNC( SQLITE3_OPEN ) { sqlite3 *db; - BOOL fFree; - char *pszdbName = ( char * ) hb_fsNameConv( ( BYTE * ) hb_parcx(1), &fFree ); + char *pszFree; + const char *pszdbName = hb_fsNameConv( hb_parcx(1), &pszFree ); if( hb_fsFileExists(( const char * ) pszdbName) || hb_parl(2) ) { @@ -625,18 +625,16 @@ HB_FUNC( SQLITE3_OPEN ) hb_retptr( NULL ); } - if( fFree ) - { - hb_xfree( pszdbName ); - } + if( pszFree ) + hb_xfree( pszFree ); } HB_FUNC( SQLITE3_OPEN_V2 ) { #if SQLITE_VERSION_NUMBER >= 3005000 sqlite3 *db; - BOOL fFree; - char *pszdbName = ( char * ) hb_fsNameConv( ( BYTE * ) hb_parcx(1), &fFree ); + char *pszFree; + const char *pszdbName = hb_fsNameConv( hb_parcx(1), &pszFree ); if( sqlite3_open_v2(pszdbName, &db, hb_parni(2), NULL) == SQLITE_OK ) { @@ -654,10 +652,8 @@ HB_FUNC( SQLITE3_OPEN_V2 ) hb_retptr( NULL ); } - if( fFree ) - { - hb_xfree( pszdbName ); - } + if( pszFree ) + hb_xfree( pszFree ); #else hb_retptr( NULL ); #endif /* SQLITE_VERSION_NUMBER >= 3005000 */ @@ -1797,7 +1793,7 @@ HB_FUNC( SQLITE3_TRACE ) HB_FUNC( SQLITE3_FILE_TO_BUFF ) { - int handle = hb_fsOpen( ( BYTE * ) hb_parc(1), FO_READ ); + int handle = hb_fsOpen( hb_parcx(1), FO_READ ); if( handle != FS_ERROR ) { @@ -1821,7 +1817,7 @@ HB_FUNC( SQLITE3_FILE_TO_BUFF ) HB_FUNC( SQLITE3_BUFF_TO_FILE ) { - int handle = hb_fsCreate( ( BYTE * ) hb_parc(1), FC_NORMAL ); + int handle = hb_fsCreate( hb_parcx(1), FC_NORMAL ); ULONG iSize = hb_parcsiz( 2 ) - 1; if( handle != FS_ERROR && iSize > 0 ) diff --git a/harbour/contrib/hbtip/utils.c b/harbour/contrib/hbtip/utils.c index 721b56d46d..7ca7f89f3d 100644 --- a/harbour/contrib/hbtip/utils.c +++ b/harbour/contrib/hbtip/utils.c @@ -643,7 +643,7 @@ HB_FUNC( TIP_FILEMIMETYPE ) ext_type = s_findExtMimeType( fname + iPos + 1 ); } - fileIn = hb_fsOpen( ( BYTE * ) fname, FO_READ ); + fileIn = hb_fsOpen( fname, FO_READ ); if ( hb_fsError() == 0 ) { magic_type = s_findFileMimeType( fileIn ); diff --git a/harbour/contrib/hbtpathy/tplinux.c b/harbour/contrib/hbtpathy/tplinux.c index f8786c9bd8..664b240f9a 100644 --- a/harbour/contrib/hbtpathy/tplinux.c +++ b/harbour/contrib/hbtpathy/tplinux.c @@ -90,7 +90,7 @@ HB_FUNC( P_INITPORTSPEED ) struct termios options; int port = hb_parnl( 1 ); int baud = B300; - char * ptr = hb_parcx( 4 ); + const char * ptr = hb_parcx( 4 ); int rc; tcgetattr( port, &options ); diff --git a/harbour/contrib/hbwin/wapi_winbase.c b/harbour/contrib/hbwin/wapi_winbase.c index fe9d1b48c0..7a44ae8002 100644 --- a/harbour/contrib/hbwin/wapi_winbase.c +++ b/harbour/contrib/hbwin/wapi_winbase.c @@ -61,13 +61,13 @@ HB_FUNC( WAPI_GETCOMMANDLINE ) { /* Convert from OS codepage */ - BOOL fFree; - char * pbyResult = ( char * ) hb_osDecode( ( BYTE * ) buffer, &fFree ); + char * pszFree; + const char * pszResult = hb_osDecode( buffer, &pszFree ); - if( fFree ) - hb_retc_buffer( pbyResult ); + if( pszFree ) + hb_retc_buffer( pszFree ); else - hb_retc( pbyResult ); + hb_retc( pszResult ); } HB_TCHAR_FREE( buffer ); diff --git a/harbour/contrib/hbwin/win_misc.c b/harbour/contrib/hbwin/win_misc.c index 0006054293..441d91a775 100644 --- a/harbour/contrib/hbwin/win_misc.c +++ b/harbour/contrib/hbwin/win_misc.c @@ -165,13 +165,13 @@ HB_FUNC( WIN_GETCOMMANDLINEPARAM ) { /* Convert from OS codepage */ - BOOL fFree; - char * pbyResult = ( char * ) hb_osDecode( ( BYTE * ) buffer + pos, &fFree ); + char * pszFree; + const char * pszResult = hb_osDecode( buffer + pos, &pszFree ); - if( fFree ) - hb_retc_buffer( pbyResult ); + if( pszFree ) + hb_retc_buffer( pszFree ); else - hb_retc( pbyResult ); + hb_retc( pszResult ); } HB_TCHAR_FREE( buffer ); diff --git a/harbour/contrib/rddads/ads1.c b/harbour/contrib/rddads/ads1.c index f04a1fda0f..534d5a62f9 100644 --- a/harbour/contrib/rddads/ads1.c +++ b/harbour/contrib/rddads/ads1.c @@ -312,7 +312,7 @@ static const char * adsIndexExt( int iFileType ) return ".ntx"; } -static ADSHANDLE hb_adsFindBag( ADSAREAP pArea, char * szBagName ) +static ADSHANDLE hb_adsFindBag( ADSAREAP pArea, const char * szBagName ) { /* This method seems to be most easy one though I'm doubt it's really the best one */ @@ -1456,7 +1456,7 @@ static HB_ERRCODE adsCreateFields( ADSAREAP pArea, PHB_ITEM pStruct ) dbFieldInfo.uiTypeExtended = 0; dbFieldInfo.uiFlags = 0; pFieldDesc = hb_arrayGetItemPtr( pStruct, uiCount + 1 ); - dbFieldInfo.atomName = ( BYTE * ) hb_arrayGetCPtr( pFieldDesc, 1 ); + dbFieldInfo.atomName = hb_arrayGetCPtr( pFieldDesc, 1 ); iData = hb_arrayGetNI( pFieldDesc, 3 ); if( iData < 0 ) iData = 0; @@ -2841,8 +2841,8 @@ static HB_ERRCODE adsCreate( ADSAREAP pArea, LPDBOPENINFO pCreateInfo ) pArea->maxFieldLen = 24; uRetVal = AdsCreateTable( hConnection, - pCreateInfo->abName, - pCreateInfo->atomAlias, + ( UNSIGNED8* ) pCreateInfo->abName, + ( UNSIGNED8* ) pCreateInfo->atomAlias, ( UNSIGNED16 ) pArea->iFileType, ( UNSIGNED16 ) hb_ads_iCharType, ( UNSIGNED16 ) hb_ads_iLockType, @@ -3150,8 +3150,8 @@ static HB_ERRCODE adsOpen( ADSAREAP pArea, LPDBOPENINFO pOpenInfo ) do { u32RetVal = AdsOpenTable( hConnection, - pOpenInfo->abName, - pOpenInfo->atomAlias, + ( UNSIGNED8* ) pOpenInfo->abName, + ( UNSIGNED8* ) pOpenInfo->atomAlias, ( fDictionary ? ADS_DEFAULT : ( UNSIGNED16 ) pArea->iFileType), ( UNSIGNED16 ) hb_ads_iCharType, ( UNSIGNED16 ) hb_ads_iLockType, @@ -3184,9 +3184,9 @@ static HB_ERRCODE adsOpen( ADSAREAP pArea, LPDBOPENINFO pOpenInfo ) { UNSIGNED16 uiAliasLen = HB_RDD_MAX_ALIAS_LEN; if( AdsGetTableAlias( hTable, ( UNSIGNED8 * ) szAlias, &uiAliasLen ) == AE_SUCCESS ) - pOpenInfo->atomAlias = ( BYTE * ) szAlias; + pOpenInfo->atomAlias = szAlias; else - pOpenInfo->atomAlias = ( BYTE * ) ""; + pOpenInfo->atomAlias = ""; } pArea->szDataFileName = hb_strdup( ( char * ) ( pOpenInfo->abName ) ); @@ -3207,9 +3207,8 @@ static HB_ERRCODE adsOpen( ADSAREAP pArea, LPDBOPENINFO pOpenInfo ) { usBufLen = ADS_MAX_FIELD_NAME; AdsGetFieldName( pArea->hTable, uiCount, szName, &usBufLen ); - dbFieldInfo.atomName = szName; - - * ( dbFieldInfo.atomName + usBufLen ) = '\0'; + szName[ usBufLen ] = '\0'; + dbFieldInfo.atomName = ( char * ) szName; AdsGetFieldType( pArea->hTable, szName, &usType ); AdsGetFieldLength( pArea->hTable, szName, &u32Length ); dbFieldInfo.uiLen = ( USHORT ) u32Length; @@ -3804,8 +3803,10 @@ static HB_ERRCODE adsOrderCreate( ADSAREAP pArea, LPDBORDERCREATEINFO pOrderInfo u32Options |= ADS_UNIQUE; #if ADS_LIB_VERSION >= 610 - u32RetVal = AdsCreateIndex61( hTableOrIndex, pOrderInfo->abBagName, - pOrderInfo->atomBagName, ( UNSIGNED8 * ) hb_itemGetCPtr( pExprItem ), + u32RetVal = AdsCreateIndex61( hTableOrIndex, + ( UNSIGNED8 * ) pOrderInfo->abBagName, + ( UNSIGNED8 * ) pOrderInfo->atomBagName, + ( UNSIGNED8 * ) hb_itemGetCPtr( pExprItem ), ( pArea->lpdbOrdCondInfo && pArea->lpdbOrdCondInfo->abFor ) ? ( UNSIGNED8 * ) pArea->lpdbOrdCondInfo->abFor : ( UNSIGNED8 * ) "", pucWhile, u32Options, ADS_DEFAULT, &hIndex); @@ -4528,7 +4529,7 @@ static HB_ERRCODE adsUnLock( ADSAREAP pArea, PHB_ITEM pRecNo ) #define adsCloseMemFile NULL #define adsCreateMemFile NULL -static HB_ERRCODE adsGetValueFile( ADSAREAP pArea, USHORT uiIndex, BYTE * szFile, USHORT uiMode ) +static HB_ERRCODE adsGetValueFile( ADSAREAP pArea, USHORT uiIndex, const char * szFile, USHORT uiMode ) { UNSIGNED32 u32RetVal; @@ -4558,7 +4559,7 @@ static HB_ERRCODE adsGetValueFile( ADSAREAP pArea, USHORT uiIndex, BYTE * szFile #define adsOpenMemFile NULL -static HB_ERRCODE adsPutValueFile( ADSAREAP pArea, USHORT uiIndex, BYTE * szFile, USHORT uiMode ) +static HB_ERRCODE adsPutValueFile( ADSAREAP pArea, USHORT uiIndex, const char * szFile, USHORT uiMode ) { UNSIGNED32 u32RetVal; @@ -4632,9 +4633,9 @@ static HB_ERRCODE adsDrop( LPRDDNODE pRDD, PHB_ITEM pItemTable, PHB_ITEM pItemIn hb_xfree( pFileName ); /* Use hb_spFile first to locate table which can be in differ path */ - if( hb_spFile( ( BYTE * ) szFileName, ( BYTE * ) szFileName ) ) + if( hb_spFile( szFileName, szFileName ) ) { - fResult = hb_fsDelete( ( BYTE * ) szFileName ); + fResult = hb_fsDelete( szFileName ); if( fResult && fTable ) { /* @@ -4653,7 +4654,7 @@ static HB_ERRCODE adsDrop( LPRDDNODE pRDD, PHB_ITEM pItemTable, PHB_ITEM pItemIn { pFileName->szExtension = szExt; hb_fsFNameMerge( szFileName, pFileName ); - hb_fsDelete( ( BYTE * ) szFileName ); + hb_fsDelete( szFileName ); } } /* @@ -4668,7 +4669,7 @@ static HB_ERRCODE adsDrop( LPRDDNODE pRDD, PHB_ITEM pItemTable, PHB_ITEM pItemIn { pFileName->szExtension = szExt; hb_fsFNameMerge( szFileName, pFileName ); - hb_fsDelete( ( BYTE * ) szFileName ); + hb_fsDelete( szFileName ); } } hb_xfree( pFileName ); @@ -4719,7 +4720,7 @@ static HB_ERRCODE adsExists( LPRDDNODE pRDD, PHB_ITEM pItemTable, PHB_ITEM pItem if( pFileExt ) hb_itemRelease( pFileExt ); - return hb_spFile( ( BYTE * ) szFileName, NULL ) ? HB_SUCCESS : HB_FAILURE; + return hb_spFile( szFileName, NULL ) ? HB_SUCCESS : HB_FAILURE; } #define adsInit NULL diff --git a/harbour/contrib/rddads/adsfunc.c b/harbour/contrib/rddads/adsfunc.c index ccdbeb3df6..8b23108fab 100644 --- a/harbour/contrib/rddads/adsfunc.c +++ b/harbour/contrib/rddads/adsfunc.c @@ -81,7 +81,7 @@ ADSHANDLE hb_ads_hConnect = 0; BOOL hb_ads_bOEM = FALSE; -char * hb_adsOemToAnsi( char * pcString, ULONG ulLen ) +char * hb_adsOemToAnsi( const char * pcString, ULONG ulLen ) { if( hb_ads_bOEM ) { @@ -90,10 +90,10 @@ char * hb_adsOemToAnsi( char * pcString, ULONG ulLen ) pszDst[ ulLen ] = '\0'; return pszDst; } - return pcString; + return ( char * ) pcString; } -char * hb_adsAnsiToOem( char * pcString, ULONG ulLen ) +char * hb_adsAnsiToOem( const char * pcString, ULONG ulLen ) { if( hb_ads_bOEM ) { @@ -102,7 +102,7 @@ char * hb_adsAnsiToOem( char * pcString, ULONG ulLen ) pszDst[ ulLen ] = '\0'; return pszDst; } - return pcString; + return ( char * ) pcString; } void hb_adsOemAnsiFree( char * pcString ) @@ -421,8 +421,7 @@ HB_FUNC( ADSBLOB2FILE ) const char * szFileName = hb_parcx( 1 ); const char * szFieldName = hb_parcx( 2 ); - if( strlen( szFileName ) && - strlen( szFieldName ) ) + if( *szFileName && *szFieldName ) { ADSAREAP pArea = hb_adsGetWorkAreaPointer(); @@ -442,8 +441,7 @@ HB_FUNC( ADSFILE2BLOB ) const char * szFileName = hb_parcx( 1 ); const char * szFieldName = hb_parcx( 2 ); - if( strlen( szFileName ) && - strlen( szFieldName ) ) + if( *szFileName && *szFieldName ) { ADSAREAP pArea = hb_adsGetWorkAreaPointer(); @@ -981,7 +979,7 @@ HB_FUNC( ADSENABLEENCRYPTION ) { const char * pucPassword = hb_parcx( 1 ); - if( strlen( pucPassword ) ) + if( *pucPassword ) { ADSAREAP pArea = hb_adsGetWorkAreaPointer(); @@ -1223,7 +1221,7 @@ HB_FUNC( ADSEXECUTESQLDIRECT ) DBOPENINFO pInfo; memset( &pInfo, 0, sizeof( DBOPENINFO ) ); - pInfo.abName = ( BYTE * ) ""; + pInfo.abName = ""; pInfo.fReadonly = TRUE; pArea->hTable = hCursor; SELF_OPEN( ( AREAP ) pArea, &pInfo ); @@ -1297,7 +1295,7 @@ HB_FUNC( ADSEXECUTESQL ) DBOPENINFO pInfo; memset( &pInfo, 0, sizeof( DBOPENINFO ) ); - pInfo.abName = ( BYTE * ) ""; + pInfo.abName = ""; pInfo.fReadonly = TRUE; pArea->hTable = hCursor; SELF_OPEN( ( AREAP ) pArea, &pInfo ); @@ -2178,8 +2176,7 @@ HB_FUNC( ADSSTMTSETTABLEPASSWORD ) const char * pucTableName = hb_parcx( 1 ); const char * pucPassword = hb_parcx( 2 ); - if( strlen( pucTableName ) && - strlen( pucPassword ) ) + if( *pucTableName && *pucPassword ) { ADSAREAP pArea = hb_adsGetWorkAreaPointer(); diff --git a/harbour/contrib/rddads/adsx.c b/harbour/contrib/rddads/adsx.c index 83b8395e20..0e1adecdf8 100644 --- a/harbour/contrib/rddads/adsx.c +++ b/harbour/contrib/rddads/adsx.c @@ -1086,7 +1086,7 @@ static HB_ERRCODE adsxOrderCreate( ADSXAREAP pArea, LPDBORDERCREATEINFO pOrderIn } else if( pArea->lpdbOrdCondInfo->abFor ) { - if( SELF_COMPILE( (AREAP) pArea, pArea->lpdbOrdCondInfo->abFor ) == HB_FAILURE ) + if( SELF_COMPILE( (AREAP) pArea, ( BYTE * ) pArea->lpdbOrdCondInfo->abFor ) == HB_FAILURE ) { hb_vmDestroyBlockOrMacro( pKeyItem ); SELF_GOTO( (AREAP) pArea, ulRecNo ); @@ -1103,7 +1103,7 @@ static HB_ERRCODE adsxOrderCreate( ADSXAREAP pArea, LPDBORDERCREATEINFO pOrderIn } else if( pArea->lpdbOrdCondInfo->abWhile ) { - if( SELF_COMPILE( (AREAP) pArea, pArea->lpdbOrdCondInfo->abWhile ) == HB_FAILURE ) + if( SELF_COMPILE( (AREAP) pArea, ( BYTE * ) pArea->lpdbOrdCondInfo->abWhile ) == HB_FAILURE ) { hb_vmDestroyBlockOrMacro( pKeyItem ); if( pForItem ) diff --git a/harbour/contrib/rddads/rddads.h b/harbour/contrib/rddads/rddads.h index fdb847d016..ec1bf44406 100644 --- a/harbour/contrib/rddads/rddads.h +++ b/harbour/contrib/rddads/rddads.h @@ -223,8 +223,8 @@ extern ADSAREAP hb_adsGetWorkAreaPointer( void ); #ifdef ADS_USE_OEM_TRANSLATION extern BOOL hb_ads_bOEM; - extern char * hb_adsOemToAnsi( char * pcString, ULONG ulLen ); - extern char * hb_adsAnsiToOem( char * pcString, ULONG ulLen ); + extern char * hb_adsOemToAnsi( const char * pcString, ULONG ulLen ); + extern char * hb_adsAnsiToOem( const char * pcString, ULONG ulLen ); extern void hb_adsOemAnsiFree( char * pcString ); /* NOTE: Undocumented ACE function. */ @@ -240,8 +240,8 @@ extern ADSAREAP hb_adsGetWorkAreaPointer( void ); UNSIGNED32 * pulLen ); #else -# define hb_adsOemToAnsi( s, l ) ( s ) -# define hb_adsAnsiToOem( s, l ) ( s ) +# define hb_adsOemToAnsi( s, l ) ( ( char * ) ( s ) ) +# define hb_adsAnsiToOem( s, l ) ( ( char * ) ( s ) ) # define hb_adsOemAnsiFree( s ) #endif diff --git a/harbour/contrib/rddsql/sddfb/fbirddd.c b/harbour/contrib/rddsql/sddfb/fbirddd.c index 0d13b6bdf8..1368875166 100644 --- a/harbour/contrib/rddsql/sddfb/fbirddd.c +++ b/harbour/contrib/rddsql/sddfb/fbirddd.c @@ -219,7 +219,7 @@ static HB_ERRCODE fbOpen( SQLBASEAREAP pArea ) PHB_ITEM pItemEof, pItem; DBFIELDINFO pFieldInfo; BOOL bError; - BYTE* pBuffer; + char* pBuffer; USHORT uiFields, uiCount; int iType; @@ -273,16 +273,15 @@ static HB_ERRCODE fbOpen( SQLBASEAREAP pArea ) pItemEof = hb_itemArrayNew( uiFields ); - pBuffer = ( BYTE * ) hb_xgrab( 256 ); + pBuffer = ( char * ) hb_xgrab( 256 ); bError = FALSE; for ( uiCount = 0, pVar = pSqlda->sqlvar; uiCount < uiFields; uiCount++, pVar++ ) { memcpy( pBuffer, pVar->sqlname, pVar->sqlname_length ); - pBuffer[ pVar->sqlname_length ] = '\0'; + pBuffer[ HB_MIN( pVar->sqlname_length, MAX_FIELD_NAME ) ] = '\0'; + hb_strUpper( pBuffer, MAX_FIELD_NAME + 1 ); pFieldInfo.atomName = pBuffer; - pFieldInfo.atomName[ MAX_FIELD_NAME ] = '\0'; - hb_strUpper( ( char* ) pFieldInfo.atomName, MAX_FIELD_NAME + 1 ); pFieldInfo.uiDec = 0; diff --git a/harbour/contrib/rddsql/sddmy/mysqldd.c b/harbour/contrib/rddsql/sddmy/mysqldd.c index 26ff4a8c17..26a5620cd6 100644 --- a/harbour/contrib/rddsql/sddmy/mysqldd.c +++ b/harbour/contrib/rddsql/sddmy/mysqldd.c @@ -254,7 +254,7 @@ static HB_ERRCODE mysqlOpen( SQLBASEAREAP pArea ) ULONG ulIndex; USHORT uiFields, uiCount, uiError = 0; BOOL bError; - BYTE* pBuffer; + char* pBuffer; DBFIELDINFO pFieldInfo; MYSQL_FIELD* pMyField; void** pRow; @@ -278,17 +278,17 @@ static HB_ERRCODE mysqlOpen( SQLBASEAREAP pArea ) pItemEof = hb_itemArrayNew( uiFields ); - pBuffer = (BYTE*) hb_xgrab( 256 ); + pBuffer = (char*) hb_xgrab( 256 ); bError = FALSE; for ( uiCount = 0; uiCount < uiFields; uiCount++ ) { pMyField = mysql_fetch_field_direct( (MYSQL_RES*) pArea->pResult, uiCount ); - hb_strncpy( ( char * ) pBuffer, pMyField->name, 256 - 1 ); + hb_strncpy( pBuffer, pMyField->name, 256 - 1 ); + pBuffer[ MAX_FIELD_NAME ] = '\0'; + hb_strUpper( pBuffer, MAX_FIELD_NAME + 1 ); pFieldInfo.atomName = pBuffer; - pFieldInfo.atomName[ MAX_FIELD_NAME ] = '\0'; - hb_strUpper( (char *) pFieldInfo.atomName, MAX_FIELD_NAME + 1 ); pFieldInfo.uiLen = pMyField->length; pFieldInfo.uiDec = 0; diff --git a/harbour/contrib/rddsql/sddodbc/odbcdd.c b/harbour/contrib/rddsql/sddodbc/odbcdd.c index 2ba4bf9346..09bbfb9e29 100644 --- a/harbour/contrib/rddsql/sddodbc/odbcdd.c +++ b/harbour/contrib/rddsql/sddodbc/odbcdd.c @@ -293,9 +293,9 @@ static HB_ERRCODE odbcOpen( SQLBASEAREAP pArea ) return HB_FAILURE; } - pFieldInfo.atomName = ( BYTE* ) cName; - pFieldInfo.atomName[ MAX_FIELD_NAME ] = '\0'; - hb_strUpper( (char *) pFieldInfo.atomName, MAX_FIELD_NAME + 1 ); + cName[ MAX_FIELD_NAME ] = '\0'; + hb_strUpper( ( char * ) cName, MAX_FIELD_NAME + 1 ); + pFieldInfo.atomName = ( char * ) cName; pFieldInfo.uiLen = ( USHORT ) uiSize; pFieldInfo.uiDec = iDec; diff --git a/harbour/contrib/rddsql/sddpg/pgsqldd.c b/harbour/contrib/rddsql/sddpg/pgsqldd.c index 9a25948f5f..3653c6f516 100644 --- a/harbour/contrib/rddsql/sddpg/pgsqldd.c +++ b/harbour/contrib/rddsql/sddpg/pgsqldd.c @@ -209,7 +209,7 @@ static HB_ERRCODE pgsqlDisconnect( SQLDDCONNECTION* pConnection ) static HB_ERRCODE pgsqlExecute( SQLDDCONNECTION* pConnection, PHB_ITEM pItem ) { - char* szQuery; + const char* szQuery; int iTuples; PGresult* pResult; @@ -247,7 +247,7 @@ static HB_ERRCODE pgsqlOpen( SQLBASEAREAP pArea ) PHB_ITEM pItemEof, pItem; USHORT uiFields, uiCount; BOOL bError; - BYTE* pBuffer; + char* pBuffer; DBFIELDINFO pFieldInfo; @@ -272,15 +272,15 @@ static HB_ERRCODE pgsqlOpen( SQLBASEAREAP pArea ) pItemEof = hb_itemArrayNew( uiFields ); - pBuffer = ( BYTE* ) hb_xgrab( 256 ); + pBuffer = ( char* ) hb_xgrab( 256 ); bError = FALSE; for ( uiCount = 0; uiCount < uiFields; uiCount++ ) { - hb_strncpy( ( char* ) pBuffer, PQfname( pResult, (int) uiCount ), 256 - 1 ); - pFieldInfo.atomName = ( BYTE* ) pBuffer; - pFieldInfo.atomName[ MAX_FIELD_NAME ] = '\0'; - hb_strUpper( ( char* ) pFieldInfo.atomName, MAX_FIELD_NAME + 1 ); + hb_strncpy( pBuffer, PQfname( pResult, (int) uiCount ), 256 - 1 ); + hb_strUpper( pBuffer, MAX_FIELD_NAME + 1 ); + pBuffer[ MAX_FIELD_NAME ] = '\0'; + pFieldInfo.atomName = pBuffer; pFieldInfo.uiDec = 0; diff --git a/harbour/contrib/rddsql/sqlmix.c b/harbour/contrib/rddsql/sqlmix.c index d80de79def..e32d76c7c7 100644 --- a/harbour/contrib/rddsql/sqlmix.c +++ b/harbour/contrib/rddsql/sqlmix.c @@ -1774,7 +1774,7 @@ static HB_ERRCODE sqlmixOrderCreate( SQLMIXAREAP pArea, LPDBORDERCREATEINFO pOrd } else if ( pArea->lpdbOrdCondInfo->abFor ) { - if ( SELF_COMPILE( (AREAP) pArea, pArea->lpdbOrdCondInfo->abFor ) == HB_FAILURE ) + if ( SELF_COMPILE( (AREAP) pArea, ( BYTE * ) pArea->lpdbOrdCondInfo->abFor ) == HB_FAILURE ) { hb_vmDestroyBlockOrMacro( pKeyItem ); SELF_GOTO( (AREAP) pArea, ulRecNo ); @@ -1791,7 +1791,7 @@ static HB_ERRCODE sqlmixOrderCreate( SQLMIXAREAP pArea, LPDBORDERCREATEINFO pOrd } else if ( pArea->lpdbOrdCondInfo->abWhile ) { - if ( SELF_COMPILE( (AREAP) pArea, pArea->lpdbOrdCondInfo->abWhile ) == HB_FAILURE ) + if ( SELF_COMPILE( (AREAP) pArea, ( BYTE * ) pArea->lpdbOrdCondInfo->abWhile ) == HB_FAILURE ) { hb_vmDestroyBlockOrMacro( pKeyItem ); if ( pForItem ) diff --git a/harbour/contrib/xhb/cstructc.c b/harbour/contrib/xhb/cstructc.c index d7f3c12c5c..30ceea1475 100644 --- a/harbour/contrib/xhb/cstructc.c +++ b/harbour/contrib/xhb/cstructc.c @@ -1427,7 +1427,7 @@ HB_FUNC( HB_POINTER2STRING ) HB_FUNC( HB_STRING2POINTER ) { - char * pszString = hb_parc( 1 ); + const char * pszString = hb_parc( 1 ); if( pszString ) hb_retptr( ( void * ) pszString ); diff --git a/harbour/contrib/xhb/datesxhb.c b/harbour/contrib/xhb/datesxhb.c index 595602ba32..086ddea304 100644 --- a/harbour/contrib/xhb/datesxhb.c +++ b/harbour/contrib/xhb/datesxhb.c @@ -58,7 +58,7 @@ /* NOTE: szTime must be 9 chars large. */ -static ULONG hb_TimeStrToSec( char * pszTime ) +static ULONG hb_TimeStrToSec( const char * pszTime ) { ULONG ulLen; ULONG ulTime = 0; diff --git a/harbour/contrib/xhb/dbf2txt.c b/harbour/contrib/xhb/dbf2txt.c index df99abbb63..c402ecb14e 100644 --- a/harbour/contrib/xhb/dbf2txt.c +++ b/harbour/contrib/xhb/dbf2txt.c @@ -142,9 +142,9 @@ static BOOL hb_ExportVar( HB_FHANDLE handle, PHB_ITEM pValue, const char * cDeli if( szResult ) { ULONG ulLen = strlen( szResult ); - char * szTrimmed = hb_strLTrim( szResult, &ulLen ); + const char * szTrimmed = hb_strLTrim( szResult, &ulLen ); - hb_fsWriteLarge( handle, ( BYTE * ) szTrimmed, strlen( szTrimmed ) ); + hb_fsWriteLarge( handle, ( const BYTE * ) szTrimmed, strlen( szTrimmed ) ); hb_xfree( szResult ); } break; @@ -255,7 +255,7 @@ HB_FUNC( DBF2TEXT ) for( uiItter = 1; uiItter <= uiFieldCopy; uiItter++ ) { - char * szFieldName = hb_arrayGetCPtr( pFields, uiItter ); + const char * szFieldName = hb_arrayGetCPtr( pFields, uiItter ); if( szFieldName ) { int iPos = hb_rddFieldIndex( pArea, szFieldName ); diff --git a/harbour/contrib/xhb/fparse.c b/harbour/contrib/xhb/fparse.c index 0f4e46ed48..d8f03cb584 100644 --- a/harbour/contrib/xhb/fparse.c +++ b/harbour/contrib/xhb/fparse.c @@ -80,7 +80,7 @@ FPARSE( cFile, cDelimiter ) -> array /* adjustable, but this should be sufficient in normal situation */ #define MAX_READ 4096 /*----------------------------------------------------------------------------*/ -void hb_ParseLine( PHB_ITEM pReturn, char * szText, int iDelimiter, int * iWord ) +void hb_ParseLine( PHB_ITEM pReturn, const char * szText, int iDelimiter, int * iWord ) { if ( szText ) { diff --git a/harbour/contrib/xhb/freadlin.c b/harbour/contrib/xhb/freadlin.c index db3fcc17b9..08cb405a21 100644 --- a/harbour/contrib/xhb/freadlin.c +++ b/harbour/contrib/xhb/freadlin.c @@ -58,7 +58,7 @@ #define READING_BLOCK 4096 -BYTE * hb_fsReadLine( HB_FHANDLE hFileHandle, LONG * plBuffLen, char ** Term, int * iTermSizes, USHORT iTerms, BOOL * bFound, BOOL * bEOF ) +BYTE * hb_fsReadLine( HB_FHANDLE hFileHandle, LONG * plBuffLen, const char ** Term, int * iTermSizes, USHORT iTerms, BOOL * bFound, BOOL * bEOF ) { USHORT uiPosTerm = 0, iPos, uiPosition; USHORT nTries; @@ -166,7 +166,7 @@ HB_FUNC( HB_FREADLINE ) { PHB_ITEM pTerm1; HB_FHANDLE hFileHandle = ( HB_FHANDLE ) hb_parnl( 1 ); - char ** Term; + const char ** Term; BYTE * pBuffer; int * iTermSizes; LONG lSize = hb_parnl( 4 ); @@ -200,7 +200,7 @@ HB_FUNC( HB_FREADLINE ) return; } - Term = ( char ** ) hb_xgrab( sizeof( char * ) * iTerms ); + Term = ( const char ** ) hb_xgrab( sizeof( char * ) * iTerms ); iTermSizes = ( int * ) hb_xgrab( sizeof( int ) * iTerms ); for( i = 0; i < iTerms; i++ ) @@ -212,7 +212,7 @@ HB_FUNC( HB_FREADLINE ) else { pTerm1 = hb_param( 3, HB_IT_STRING ); - Term = ( char ** ) hb_xgrab( sizeof( char * ) ); + Term = ( const char ** ) hb_xgrab( sizeof( char * ) ); iTermSizes = ( int * ) hb_xgrab( sizeof( int ) ); Term[ 0 ] = ( char * ) hb_itemGetCPtr( pTerm1 ); iTermSizes[ 0 ] = hb_itemGetCLen( pTerm1 ); @@ -221,7 +221,7 @@ HB_FUNC( HB_FREADLINE ) } else { - Term = ( char ** ) hb_xgrab( sizeof( char * ) ); + Term = ( const char ** ) hb_xgrab( sizeof( char * ) ); iTermSizes = ( int * ) hb_xgrab( sizeof( int ) ); Term[ 0 ] = ( char * ) "\r\n"; /* Should be preplaced with the default EOL sequence */ iTerms = 1; diff --git a/harbour/contrib/xhb/hbcomprs.c b/harbour/contrib/xhb/hbcomprs.c index 300eb062de..5d84b91f50 100644 --- a/harbour/contrib/xhb/hbcomprs.c +++ b/harbour/contrib/xhb/hbcomprs.c @@ -82,7 +82,8 @@ ULONG hb_destBuflen( ULONG srclen ) HB_FUNC( HB_COMPRESS ) { - char *cDest, *cSource; + const char *cSource; + char *cDest; ULONG ulSrclen, ulDstlen, ulBufLen; PHB_ITEM pSource, pDest =NULL, pDestLen = NULL; int nCompFactor, iFirst; @@ -127,12 +128,7 @@ HB_FUNC( HB_COMPRESS ) ulBufLen = 0; if( pDest && pDestLen && ulDstlen > 0 ) { - pDest = hb_itemUnShare( pDest ); - if( HB_IS_STRING( pDest ) ) - { - cDest = hb_itemGetCPtr( pDest ); - ulBufLen = hb_itemGetCLen( pDest ); - } + hb_itemGetWriteCL( pDest, &cDest, &ulBufLen ); } if( cDest == NULL || ulBufLen < ulDstlen ) { @@ -183,7 +179,8 @@ HB_FUNC( HB_COMPRESS ) HB_FUNC( HB_UNCOMPRESS ) { - char *cDest, *cSource; + const char *cSource; + char *cDest; ULONG ulSrclen, ulDstlen, ulBufLen; PHB_ITEM pSource, pDest; int cerr; @@ -215,12 +212,7 @@ HB_FUNC( HB_UNCOMPRESS ) ulBufLen = 0; if( pDest ) { - pDest = hb_itemUnShare( pDest ); - if( HB_IS_STRING( pDest ) ) - { - cDest = hb_itemGetCPtr( pDest ); - ulBufLen = hb_itemGetCLen( pDest ); - } + hb_itemGetWriteCL( pDest, &cDest, &ulBufLen ); } if( cDest == NULL || ulBufLen < ulDstlen ) { diff --git a/harbour/contrib/xhb/hbxml.c b/harbour/contrib/xhb/hbxml.c index 413834b318..5093cdd246 100644 --- a/harbour/contrib/xhb/hbxml.c +++ b/harbour/contrib/xhb/hbxml.c @@ -433,7 +433,7 @@ static MXML_STATUS mxml_attribute_read( MXML_REFIL *ref, PHB_ITEM pDoc, PHB_ITEM static MXML_STATUS mxml_attribute_write( MXML_OUTPUT *out, PHBXML_ATTRIBUTE pAttr, int style ) { - char *name = hb_itemGetCPtr( pAttr->pName ); + const char *name = hb_itemGetCPtr( pAttr->pName ); mxml_output_string_len( out, name, hb_itemGetCLen( pAttr->pName ) ); mxml_output_char( out, '=' ); @@ -2300,7 +2300,8 @@ HB_FUNC( HBXML_DATAREAD ) int iStyle = hb_parni(3); PHB_ITEM pRoot; MXML_REFIL refil; - char buffer[512]; + char buffer[512], * buf; + ULONG ulLen; if( pDoc == NULL || pParam == NULL || ( !HB_IS_STRING( pParam ) && !HB_IS_NUMERIC( pParam ) ) ) @@ -2309,11 +2310,9 @@ HB_FUNC( HBXML_DATAREAD ) return; } - - if( HB_IS_STRING( pParam ) ) + if( hb_itemGetWriteCL( pParam, &buf, &ulLen ) ) { - ULONG ulLen = hb_itemGetCLen( pParam ); - mxml_refil_setup( &refil, NULL, hb_itemGetCPtr( pParam ), ulLen, ulLen ); + mxml_refil_setup( &refil, NULL, buf, ulLen, ulLen ); } else /* can only be an integer, that is, a file handle */ { diff --git a/harbour/contrib/xhb/txtline.c b/harbour/contrib/xhb/txtline.c index cc6559ac38..f18a0f47f0 100644 --- a/harbour/contrib/xhb/txtline.c +++ b/harbour/contrib/xhb/txtline.c @@ -56,7 +56,7 @@ #include "hbapiitm.h" #include "hbapierr.h" -void hb_readLine( char * szText, ULONG ulTextLen, ULONG uiLineLen, USHORT uiTabLen, BOOL bWrap, char ** Term, int * iTermSizes, USHORT uiTerms, BOOL * bFound, BOOL * bEOF, LONG * lEnd, ULONG * ulEndOffset ) +void hb_readLine( const char * szText, ULONG ulTextLen, ULONG uiLineLen, USHORT uiTabLen, BOOL bWrap, char ** Term, int * iTermSizes, USHORT uiTerms, BOOL * bFound, BOOL * bEOF, LONG * lEnd, ULONG * ulEndOffset ) { USHORT uiPosTerm, uiPosition; ULONG ulPos, ulCurrCol, ulLastBlk; @@ -174,7 +174,7 @@ void hb_readLine( char * szText, ULONG ulTextLen, ULONG uiLineLen, USHORT uiTabL } } -LONG hb_tabexpand(char * szString, char * szRet, LONG lEnd, USHORT uiTabLen ) +LONG hb_tabexpand(const char * szString, char * szRet, LONG lEnd, USHORT uiTabLen ) { LONG lPos, lSpAdded = 0; @@ -199,7 +199,7 @@ LONG hb_tabexpand(char * szString, char * szRet, LONG lEnd, USHORT uiTabLen ) HB_FUNC( HB_TABEXPAND ) { - char * szText = hb_parcx( 1 ); + const char * szText = hb_parcx( 1 ); LONG lStrLen = hb_parclen( 1 ); USHORT uiTabLen = (USHORT) hb_parni( 2 ); USHORT uiTabCount = 0; @@ -233,7 +233,7 @@ HB_FUNC( HB_TABEXPAND ) HB_FUNC( HB_READLINE ) { PHB_ITEM pTerm1; - char * szText = hb_parcx( 1 ); + const char * szText = hb_parcx( 1 ); char ** Term; int * iTermSizes; USHORT uiTabLen, uiTerms; diff --git a/harbour/contrib/xhb/xhbcopyf.c b/harbour/contrib/xhb/xhbcopyf.c index 43b972bdc0..d6b99921c1 100644 --- a/harbour/contrib/xhb/xhbcopyf.c +++ b/harbour/contrib/xhb/xhbcopyf.c @@ -63,14 +63,14 @@ #define BUFFER_SIZE 8192 -static BOOL hb_copyfile( char * szSource, char * szDest, PHB_ITEM pBlock ) +static BOOL hb_copyfile( const char * szSource, const char * szDest, PHB_ITEM pBlock ) { BOOL bRetVal = FALSE; HB_FHANDLE fhndSource; HB_TRACE(HB_TR_DEBUG, ("hb_copyfile(%s, %s)", szSource, szDest)); - while( ( fhndSource = hb_spOpen( ( BYTE * ) szSource, FO_READ | FO_SHARED | FO_PRIVATE ) ) == FS_ERROR ) + while( ( fhndSource = hb_spOpen( szSource, FO_READ | FO_SHARED | FO_PRIVATE ) ) == FS_ERROR ) { USHORT uiAction = hb_errRT_BASE_Ext1( EG_OPEN, 2012, NULL, szSource, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY, 0 ); @@ -82,7 +82,7 @@ static BOOL hb_copyfile( char * szSource, char * szDest, PHB_ITEM pBlock ) { HB_FHANDLE fhndDest; - while( ( fhndDest = hb_spCreate( ( BYTE * ) szDest, FC_NORMAL ) ) == FS_ERROR ) + while( ( fhndDest = hb_spCreate( szDest, FC_NORMAL ) ) == FS_ERROR ) { USHORT uiAction = hb_errRT_BASE_Ext1( EG_CREATE, 2012, NULL, szDest, hb_fsError(), EF_CANDEFAULT | EF_CANRETRY, 0 ); diff --git a/harbour/contrib/xhb/xhbfunc.c b/harbour/contrib/xhb/xhbfunc.c index 3162aff7f9..1ce5fc8096 100644 --- a/harbour/contrib/xhb/xhbfunc.c +++ b/harbour/contrib/xhb/xhbfunc.c @@ -162,7 +162,7 @@ HB_FUNC( HB_CREATELEN8 ) HB_FUNC( HB_GETLEN8 ) { - char * buffer = hb_parc( 1 ); + const char * buffer = hb_parc( 1 ); if( buffer && hb_parclen( 1 ) >= 8 ) hb_retnint( HB_GET_LE_UINT64( buffer ) ); else diff --git a/harbour/contrib/xhb/xhbis.c b/harbour/contrib/xhb/xhbis.c index 3e5cb7e020..722c92488e 100644 --- a/harbour/contrib/xhb/xhbis.c +++ b/harbour/contrib/xhb/xhbis.c @@ -96,7 +96,7 @@ HB_FUNC( ISALNUM ) { - char * szString = hb_parc( 1 ); + const char * szString = hb_parc( 1 ); if( szString != NULL ) hb_retl( HB_ISALNUM( ( BYTE ) * szString ) ); @@ -111,7 +111,7 @@ HB_FUNC( ISALNUM ) HB_FUNC( ISSPACE ) { - char * szString = hb_parc( 1 ); + const char * szString = hb_parc( 1 ); if( szString != NULL ) hb_retl( HB_ISSPACE( ( BYTE ) * szString ) ); @@ -125,7 +125,7 @@ HB_FUNC( ISSPACE ) HB_FUNC( ISXDIGIT ) { - char * szString = hb_parc( 1 ); + const char * szString = hb_parc( 1 ); hb_retl( szString && HB_ISXDIGIT( ( BYTE ) * szString ) ); } @@ -136,7 +136,7 @@ HB_FUNC( ISXDIGIT ) HB_FUNC( ISCNTRL ) { - char * szString = hb_parc( 1 ); + const char * szString = hb_parc( 1 ); hb_retl( szString && iscntrl( ( BYTE ) * szString ) ); } @@ -147,7 +147,7 @@ HB_FUNC( ISCNTRL ) HB_FUNC( ISGRAPH ) { - char * szString = hb_parc( 1 ); + const char * szString = hb_parc( 1 ); hb_retl( szString && isgraph( ( BYTE ) * szString ) ); } @@ -159,7 +159,7 @@ HB_FUNC( ISGRAPH ) HB_FUNC( ISPRINT ) { - char * szString = hb_parc( 1 ); + const char * szString = hb_parc( 1 ); hb_retl( szString && isprint( ( BYTE ) * szString ) ) ; } @@ -171,7 +171,7 @@ HB_FUNC( ISPRINT ) HB_FUNC( ISPUNCT ) { - char * szString = hb_parc( 1 ); + const char * szString = hb_parc( 1 ); hb_retl( szString && ispunct( ( BYTE ) * szString ) ); } @@ -182,7 +182,7 @@ HB_FUNC( ISPUNCT ) HB_FUNC( ISASCII ) { - char * szString = hb_parc( 1 ); + const char * szString = hb_parc( 1 ); hb_retl( szString && isascii( ( BYTE ) * szString ) ); } diff --git a/harbour/contrib/xhb/xhbmsgs.c b/harbour/contrib/xhb/xhbmsgs.c index d6bc030c4a..310d3579a9 100644 --- a/harbour/contrib/xhb/xhbmsgs.c +++ b/harbour/contrib/xhb/xhbmsgs.c @@ -331,8 +331,10 @@ HB_FUNC( XHB_INDEX ) hb_itemPutCL( pSelf, &cValue, 1 ); else { - hb_itemUnShareString( pSelf ); - hb_itemGetCPtr( pSelf )[ ulIndex - 1 ] = cValue; + char * pszText; + if( hb_itemGetWriteCL( pSelf, &pszText, &ulLen ) && + ulIndex < ulLen ) + pszText[ ulIndex - 1 ] = cValue; } } else diff --git a/harbour/contrib/xhb/xhbtrim.c b/harbour/contrib/xhb/xhbtrim.c index 79999b6483..cfd1502cd7 100644 --- a/harbour/contrib/xhb/xhbtrim.c +++ b/harbour/contrib/xhb/xhbtrim.c @@ -65,7 +65,7 @@ HB_FUNC( XHB_RTRIM ) if( pText ) { ULONG ulLen, ulSrc; - char * szText = hb_itemGetCPtr( pText ); + const char * szText = hb_itemGetCPtr( pText ); ulSrc = hb_itemGetCLen( pText ); ulLen = hb_strRTrimLen( szText, ulSrc, HB_ISLOG( 2 ) && hb_parl( 2 ) ); @@ -97,7 +97,7 @@ HB_FUNC( XHB_ALLTRIM ) if( pText ) { ULONG ulLen, ulSrc; - char * szText = hb_itemGetCPtr( pText ); + const char * szText = hb_itemGetCPtr( pText ); ulSrc = hb_itemGetCLen( pText ); ulLen = hb_strRTrimLen( szText, ulSrc, HB_ISLOG( 2 ) && hb_parl( 2 ) ); diff --git a/harbour/contrib/xhb/xstrdel.c b/harbour/contrib/xhb/xstrdel.c index 53e3f4194b..7e11a8a7f7 100644 --- a/harbour/contrib/xhb/xstrdel.c +++ b/harbour/contrib/xhb/xstrdel.c @@ -57,13 +57,13 @@ HB_FUNC( STRDEL ) { if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) { - char * szText = hb_parcx( 1 ); + const char * szText = hb_parcx( 1 ); ULONG ulText = hb_parclen( 1 ); ULONG ulDel = hb_parclen( 2 ); if( ulDel > 0 && ulText > 0 ) { - char * szDel = hb_parcx( 2 ); + const char * szDel = hb_parcx( 2 ); ULONG ulPosTxt = 0; ULONG ulResult = 0; ULONG ulPosDel = 0; diff --git a/harbour/include/hbapi.h b/harbour/include/hbapi.h index ef7adaf9f7..aa9772acc4 100644 --- a/harbour/include/hbapi.h +++ b/harbour/include/hbapi.h @@ -775,7 +775,7 @@ extern HB_EXPORT BOOL hb_arrayGet( PHB_ITEM pArray, ULONG ulIndex, PHB_I extern HB_EXPORT BOOL hb_arrayGetItemRef( PHB_ITEM pArray, ULONG ulIndex, PHB_ITEM pItem ); /* create a reference to an array element */ /* hb_arrayGetItemPtr() is dangerous, be sure that base ARRAY value will not be changed (f.e. resized) */ extern HB_EXPORT PHB_ITEM hb_arrayGetItemPtr( PHB_ITEM pArray, ULONG ulIndex ); /* returns pointer to specified element of the array */ -extern HB_EXPORT ULONG hb_arrayCopyC( PHB_ITEM pArray, ULONG ulIndex, char * szBuffer, ULONG ulLen ); /* copy a string into an array item */ +extern HB_EXPORT ULONG hb_arrayCopyC( PHB_ITEM pArray, ULONG ulIndex, char * szBuffer, ULONG ulLen ); /* copy a string from an array item */ extern HB_EXPORT char * hb_arrayGetC( PHB_ITEM pArray, ULONG ulIndex ); /* retrieves the string contained on an array element */ extern HB_EXPORT const char * hb_arrayGetCPtr( PHB_ITEM pArray, ULONG ulIndex ); /* retrieves the string pointer on an array element */ extern HB_EXPORT ULONG hb_arrayGetCLen( PHB_ITEM pArray, ULONG ulIndex ); /* retrieves the string length contained on an array element */ @@ -936,7 +936,7 @@ extern HB_EXPORT char * hb_strncpyLower( char * pDest, const char * pSource, extern HB_EXPORT char * hb_strncpyUpper( char * pDest, const char * pSource, ULONG ulLen ); /* copy an existing string buffer to another buffer, as upper case */ extern HB_EXPORT char * hb_strncpyUpperTrim( char * pDest, const char * pSource, ULONG ulLen ); extern HB_EXPORT double hb_strVal( const char * szText, ULONG ulLen ); /* return the numeric value of a character string representation of a number */ -extern HB_EXPORT char * hb_strLTrim( const char * szText, ULONG * ulLen ); /* return a pointer to the first non-white space character */ +extern HB_EXPORT const char * hb_strLTrim( const char * szText, ULONG * ulLen ); /* return a pointer to the first non-white space character */ extern HB_EXPORT ULONG hb_strRTrimLen( const char * szText, ULONG ulLen, BOOL bAnySpace ); /* return length of a string, ignoring trailing white space (or true spaces) */ extern HB_EXPORT double hb_strVal( const char * szText, ULONG ulLen ); extern HB_EXPORT HB_LONG hb_strValInt( const char * szText, int * iOverflow ); @@ -1039,14 +1039,14 @@ extern PHB_ITEM hb_memvarGetItem( PHB_SYMB pMemvarSymb ); #endif /* _HB_API_INTERNAL_ */ /* console I/O subsystem */ -extern void hb_conInit( void ); /* initialize the console API system */ -extern void hb_conRelease( void ); /* release the console API system */ -extern HB_EXPORT char * hb_conNewLine( void ); /* retrieve a pointer to a static buffer containing new-line characters */ -extern HB_EXPORT void hb_conOutStd( const char * pStr, ULONG ulLen ); /* output an string to STDOUT */ -extern HB_EXPORT void hb_conOutErr( const char * pStr, ULONG ulLen ); /* output an string to STDERR */ -extern HB_EXPORT void hb_conOutAlt( const char * pStr, ULONG ulLen ); /* output an string to the screen and/or printer and/or alternate */ -extern HB_EXPORT USHORT hb_conSetCursor( BOOL bSetCursor, USHORT usNewCursor ); /* retrieve and optionally set cursor shape */ -extern HB_EXPORT char * hb_conSetColor( const char * szColor ); /* retrieve and optionally set console color */ +extern void hb_conInit( void ); /* initialize the console API system */ +extern void hb_conRelease( void ); /* release the console API system */ +extern HB_EXPORT const char * hb_conNewLine( void ); /* retrieve a pointer to a static buffer containing new-line characters */ +extern HB_EXPORT void hb_conOutStd( const char * pStr, ULONG ulLen ); /* output an string to STDOUT */ +extern HB_EXPORT void hb_conOutErr( const char * pStr, ULONG ulLen ); /* output an string to STDERR */ +extern HB_EXPORT void hb_conOutAlt( const char * pStr, ULONG ulLen ); /* output an string to the screen and/or printer and/or alternate */ +extern HB_EXPORT USHORT hb_conSetCursor( BOOL bSetCursor, USHORT usNewCursor ); /* retrieve and optionally set cursor shape */ +extern HB_EXPORT const char * hb_conSetColor( const char * szColor ); /* retrieve and optionally set console color */ /* compiler and macro compiler */ extern const char * hb_compReservedName( const char * szName ); /* determines if a string contains a reserve word */ @@ -1120,8 +1120,8 @@ extern HB_EXPORT BOOL hb_iswince( void ); /* return .T. if OS is Windows CE or extern HB_EXPORT BOOL hb_printerIsReady( const char * pszPrinterName ); /* OS/Harbour codepage conversion */ -extern HB_EXPORT BYTE * hb_osEncode( BYTE * szFileName, BOOL * pfFree ); /* Convert a string sent to a system call, from Harbour codepage. */ -extern HB_EXPORT BYTE * hb_osDecode( BYTE * szFileName, BOOL * pfFree ); /* Convert a string received from a system call, to Harbour codepage. */ +extern HB_EXPORT const char * hb_osEncode( const char * szFileName, char ** pszFree ); /* Convert a string sent to a system call, from Harbour codepage. */ +extern HB_EXPORT const char * hb_osDecode( const char * szFileName, char ** pszFree ); /* Convert a string received from a system call, to Harbour codepage. */ /* environment variables access */ extern BOOL hb_getenv_buffer( const char * szName, char * szBuffer, int nSize ); diff --git a/harbour/include/hbapidbg.h b/harbour/include/hbapidbg.h index 6113828279..d1cabb1d5f 100644 --- a/harbour/include/hbapidbg.h +++ b/harbour/include/hbapidbg.h @@ -60,7 +60,7 @@ HB_EXTERN_BEGIN /*Debugger API */ /* HVM debugger function */ -typedef void (*HB_DBGENTRY_FUNC) ( int , int , char *, int , PHB_ITEM ); +typedef void (*HB_DBGENTRY_FUNC) ( int , int , const char *, int , PHB_ITEM ); extern HB_DBGENTRY_FUNC hb_dbg_SetEntry( HB_DBGENTRY_FUNC pFunDbgEntry ); extern BOOL hb_dbg_InvokeDebug( BOOL bInvoke ); extern ULONG hb_dbg_ProcLevel( void ); @@ -70,23 +70,23 @@ extern ULONG hb_dbg_vmVarGCount( void ); extern PHB_ITEM hb_dbg_vmVarGGet( int nGlobal, int nOffset ); /* internal debugger function */ -extern void hb_dbgEntry( int nMode, int nLine, char *szName, int nIndex, PHB_ITEM pFrame ); -extern void hb_dbgAddBreak( void *handle, char *cModule, int nLine, char *szFunction ); -extern void hb_dbgAddWatch( void *handle, char *szExpr, BOOL bTrace ); +extern void hb_dbgEntry( int nMode, int nLine, const char *szName, int nIndex, PHB_ITEM pFrame ); +extern void hb_dbgAddBreak( void *handle, const char *cModule, int nLine, const char *szFunction ); +extern void hb_dbgAddWatch( void *handle, const char *szExpr, BOOL bTrace ); extern void hb_dbgDelBreak( void *handle, int nBreak ); extern void hb_dbgDelWatch( void *handle, int nWatch ); -extern PHB_ITEM hb_dbgGetExpressionValue( void *handle, char *expression ); +extern PHB_ITEM hb_dbgGetExpressionValue( void *handle, const char *expression ); extern PHB_ITEM hb_dbgGetSourceFiles( void *handle ); extern PHB_ITEM hb_dbgGetWatchValue( void *handle, int nWatch ); -extern BOOL hb_dbgIsValidStopLine( void *handle, char *szModule, int nLine ); +extern BOOL hb_dbgIsValidStopLine( void *handle, const char *szModule, int nLine ); extern void hb_dbgSetCBTrace( void *handle, BOOL bCBTrace ); extern void hb_dbgSetGo( void *handle ); extern void hb_dbgSetInvoke( void *handle, BOOL ( *pFunInvoke )( void ) ); extern void hb_dbgSetNextRoutine( void *handle ); extern void hb_dbgSetQuit( void *handle ); -extern void hb_dbgSetToCursor( void *handle, char *szModule, int nLine ); +extern void hb_dbgSetToCursor( void *handle, const char *szModule, int nLine ); extern void hb_dbgSetTrace( void *handle ); -extern void hb_dbgSetWatch( void *handle, int nWatch, char *szExpr, BOOL bTrace ); +extern void hb_dbgSetWatch( void *handle, int nWatch, const char *szExpr, BOOL bTrace ); HB_EXTERN_END diff --git a/harbour/include/hbapierr.h b/harbour/include/hbapierr.h index 1e6b272978..96443d380c 100644 --- a/harbour/include/hbapierr.h +++ b/harbour/include/hbapierr.h @@ -99,34 +99,34 @@ HB_EXTERN_BEGIN /* Standard API */ -extern HB_EXPORT PHB_ITEM hb_errGetCargo ( PHB_ITEM pError ); -extern HB_EXPORT PHB_ITEM hb_errGetArgs ( PHB_ITEM pError ); -extern HB_EXPORT char * hb_errGetDescription ( PHB_ITEM pError ); -extern HB_EXPORT char * hb_errGetFileName ( PHB_ITEM pError ); -extern HB_EXPORT USHORT hb_errGetFlags ( PHB_ITEM pError ); -extern HB_EXPORT USHORT hb_errGetGenCode ( PHB_ITEM pError ); -extern HB_EXPORT char * hb_errGetOperation ( PHB_ITEM pError ); -extern HB_EXPORT USHORT hb_errGetOsCode ( PHB_ITEM pError ); -extern HB_EXPORT USHORT hb_errGetSeverity ( PHB_ITEM pError ); -extern HB_EXPORT USHORT hb_errGetSubCode ( PHB_ITEM pError ); -extern HB_EXPORT char * hb_errGetSubSystem ( PHB_ITEM pError ); -extern HB_EXPORT USHORT hb_errGetTries ( PHB_ITEM pError ); -extern HB_EXPORT USHORT hb_errLaunch ( PHB_ITEM pError ); -extern HB_EXPORT PHB_ITEM hb_errNew ( void ); -extern HB_EXPORT PHB_ITEM hb_errPutCargo ( PHB_ITEM pError, PHB_ITEM pCargo ); -extern HB_EXPORT PHB_ITEM hb_errPutArgsArray ( PHB_ITEM pError, PHB_ITEM pArgs ); -extern HB_EXPORT PHB_ITEM hb_errPutArgs ( PHB_ITEM pError, ULONG ulArgCount, ... ); -extern HB_EXPORT PHB_ITEM hb_errPutDescription ( PHB_ITEM pError, const char * szDescription ); -extern HB_EXPORT PHB_ITEM hb_errPutFileName ( PHB_ITEM pError, const char * szFileName ); -extern HB_EXPORT PHB_ITEM hb_errPutFlags ( PHB_ITEM pError, USHORT uiFlags ); -extern HB_EXPORT PHB_ITEM hb_errPutGenCode ( PHB_ITEM pError, USHORT uiGenCode ); -extern HB_EXPORT PHB_ITEM hb_errPutOperation ( PHB_ITEM pError, const char * szOperation ); -extern HB_EXPORT PHB_ITEM hb_errPutOsCode ( PHB_ITEM pError, USHORT uiOsCode ); -extern HB_EXPORT PHB_ITEM hb_errPutSeverity ( PHB_ITEM pError, USHORT uiSeverity ); -extern HB_EXPORT PHB_ITEM hb_errPutSubCode ( PHB_ITEM pError, USHORT uiSubCode ); -extern HB_EXPORT PHB_ITEM hb_errPutSubSystem ( PHB_ITEM pError, const char * szSubSystem ); -extern HB_EXPORT PHB_ITEM hb_errPutTries ( PHB_ITEM pError, USHORT uiTries ); -extern HB_EXPORT void hb_errRelease ( PHB_ITEM pError ); +extern HB_EXPORT PHB_ITEM hb_errGetCargo ( PHB_ITEM pError ); +extern HB_EXPORT PHB_ITEM hb_errGetArgs ( PHB_ITEM pError ); +extern HB_EXPORT const char * hb_errGetDescription ( PHB_ITEM pError ); +extern HB_EXPORT const char * hb_errGetFileName ( PHB_ITEM pError ); +extern HB_EXPORT USHORT hb_errGetFlags ( PHB_ITEM pError ); +extern HB_EXPORT USHORT hb_errGetGenCode ( PHB_ITEM pError ); +extern HB_EXPORT const char * hb_errGetOperation ( PHB_ITEM pError ); +extern HB_EXPORT USHORT hb_errGetOsCode ( PHB_ITEM pError ); +extern HB_EXPORT USHORT hb_errGetSeverity ( PHB_ITEM pError ); +extern HB_EXPORT USHORT hb_errGetSubCode ( PHB_ITEM pError ); +extern HB_EXPORT const char * hb_errGetSubSystem ( PHB_ITEM pError ); +extern HB_EXPORT USHORT hb_errGetTries ( PHB_ITEM pError ); +extern HB_EXPORT USHORT hb_errLaunch ( PHB_ITEM pError ); +extern HB_EXPORT PHB_ITEM hb_errNew ( void ); +extern HB_EXPORT PHB_ITEM hb_errPutCargo ( PHB_ITEM pError, PHB_ITEM pCargo ); +extern HB_EXPORT PHB_ITEM hb_errPutArgsArray ( PHB_ITEM pError, PHB_ITEM pArgs ); +extern HB_EXPORT PHB_ITEM hb_errPutArgs ( PHB_ITEM pError, ULONG ulArgCount, ... ); +extern HB_EXPORT PHB_ITEM hb_errPutDescription ( PHB_ITEM pError, const char * szDescription ); +extern HB_EXPORT PHB_ITEM hb_errPutFileName ( PHB_ITEM pError, const char * szFileName ); +extern HB_EXPORT PHB_ITEM hb_errPutFlags ( PHB_ITEM pError, USHORT uiFlags ); +extern HB_EXPORT PHB_ITEM hb_errPutGenCode ( PHB_ITEM pError, USHORT uiGenCode ); +extern HB_EXPORT PHB_ITEM hb_errPutOperation ( PHB_ITEM pError, const char * szOperation ); +extern HB_EXPORT PHB_ITEM hb_errPutOsCode ( PHB_ITEM pError, USHORT uiOsCode ); +extern HB_EXPORT PHB_ITEM hb_errPutSeverity ( PHB_ITEM pError, USHORT uiSeverity ); +extern HB_EXPORT PHB_ITEM hb_errPutSubCode ( PHB_ITEM pError, USHORT uiSubCode ); +extern HB_EXPORT PHB_ITEM hb_errPutSubSystem ( PHB_ITEM pError, const char * szSubSystem ); +extern HB_EXPORT PHB_ITEM hb_errPutTries ( PHB_ITEM pError, USHORT uiTries ); +extern HB_EXPORT void hb_errRelease ( PHB_ITEM pError ); /* Harbour additions */ diff --git a/harbour/include/hbapifs.h b/harbour/include/hbapifs.h index 32f83a8061..c16d6f390f 100644 --- a/harbour/include/hbapifs.h +++ b/harbour/include/hbapifs.h @@ -154,63 +154,63 @@ HB_EXTERN_BEGIN HB_FA_POSIX_USR(a) | \ HB_FA_POSIX_SID(a) ) -extern HB_EXPORT BOOL hb_fsChDir ( BYTE * pszDirName ); /* change working directory */ +extern HB_EXPORT BOOL hb_fsChDir ( const char * pszDirName ); /* change working directory */ extern HB_EXPORT USHORT hb_fsChDrv ( BYTE nDrive ); /* change working drive */ extern HB_EXPORT void hb_fsClose ( HB_FHANDLE hFileHandle ); /* close a file */ extern HB_EXPORT void hb_fsCommit ( HB_FHANDLE hFileHandle ); /* commit updates of a file */ -extern HB_EXPORT HB_FHANDLE hb_fsCreate ( BYTE * pszFileName, ULONG ulAttr ); /* create a file */ -extern HB_EXPORT HB_FHANDLE hb_fsCreateEx ( BYTE * pszFilename, ULONG ulAttr, USHORT uiFlags ); /* create a file, with specific open mode */ -extern HB_EXPORT HB_FHANDLE hb_fsCreateTemp ( const BYTE * pszDir, const BYTE * pszPrefix, ULONG ulAttr, BYTE * pszName ); /* create a temporary file from components */ -extern HB_EXPORT HB_FHANDLE hb_fsCreateTempEx( BYTE * pszName, const BYTE * pszDir, const BYTE * pszPrefix, const BYTE * pszExt, ULONG ulAttr ); /* create a temporary file from components */ -extern HB_EXPORT BYTE * hb_fsCurDir ( USHORT uiDrive ); /* retrieve a static pointer containing current directory for specified drive */ -extern HB_EXPORT USHORT hb_fsCurDirBuff ( USHORT uiDrive, BYTE * pbyBuffer, ULONG ulLen ); /* copy current directory for given drive into a buffer */ -extern HB_EXPORT void hb_fsBaseDirBuff ( BYTE * pbyBuffer ); /* retrieve the base dir of the executable */ +extern HB_EXPORT HB_FHANDLE hb_fsCreate ( const char * pszFileName, ULONG ulAttr ); /* create a file */ +extern HB_EXPORT HB_FHANDLE hb_fsCreateEx ( const char * pszFilename, ULONG ulAttr, USHORT uiFlags ); /* create a file, with specific open mode */ +extern HB_EXPORT HB_FHANDLE hb_fsCreateTemp ( const char * pszDir, const char * pszPrefix, ULONG ulAttr, char * pszName ); /* create a temporary file from components */ +extern HB_EXPORT HB_FHANDLE hb_fsCreateTempEx( char * pszName, const char * pszDir, const char * pszPrefix, const char * pszExt, ULONG ulAttr ); /* create a temporary file from components */ +extern HB_EXPORT const char * hb_fsCurDir ( USHORT uiDrive ); /* retrieve a static pointer containing current directory for specified drive */ +extern HB_EXPORT USHORT hb_fsCurDirBuff ( USHORT uiDrive, char * pbyBuffer, ULONG ulLen ); /* copy current directory for given drive into a buffer */ +extern HB_EXPORT void hb_fsBaseDirBuff ( char * pbyBuffer ); /* retrieve the base dir of the executable */ extern HB_EXPORT BYTE hb_fsCurDrv ( void ); /* retrieve current drive number */ -extern HB_EXPORT BOOL hb_fsDelete ( BYTE * pszFileName ); /* delete a file */ +extern HB_EXPORT BOOL hb_fsDelete ( const char * pszFileName ); /* delete a file */ extern HB_EXPORT BOOL hb_fsEof ( HB_FHANDLE hFileHandle ); /* determine if an open file is position at end-of-file */ extern HB_EXPORT USHORT hb_fsError ( void ); /* retrieve file system error */ extern HB_EXPORT USHORT hb_fsOsError ( void ); /* retrieve system dependant file system error */ -extern HB_EXPORT BOOL hb_fsFile ( BYTE * pszFileName ); /* determine if a file exists */ -extern HB_EXPORT BOOL hb_fsIsDirectory ( BYTE * pszFilename ); -extern HB_EXPORT HB_FOFFSET hb_fsFSize ( BYTE * pszFileName, BOOL bUseDirEntry ); /* determine the size of a file */ -extern HB_EXPORT HB_FHANDLE hb_fsExtOpen ( BYTE * pszFileName, BYTE * pDefExt, - USHORT uiFlags, BYTE * pPaths, PHB_ITEM pError ); /* open a file using default extension and a list of paths */ -extern HB_EXPORT BYTE * hb_fsExtName ( BYTE * pFilename, BYTE * pDefExt, - USHORT uiExFlags, BYTE * pPaths ); /* convert file name for hb_fsExtOpen, caller must free the returned buffer */ +extern HB_EXPORT BOOL hb_fsFile ( const char * pszFileName ); /* determine if a file exists */ +extern HB_EXPORT BOOL hb_fsIsDirectory ( const char * pszFilename ); +extern HB_EXPORT HB_FOFFSET hb_fsFSize ( const char * pszFileName, BOOL bUseDirEntry ); /* determine the size of a file */ +extern HB_EXPORT HB_FHANDLE hb_fsExtOpen ( const char * pszFileName, const char * pDefExt, + USHORT uiFlags, const char * pPaths, PHB_ITEM pError ); /* open a file using default extension and a list of paths */ +extern HB_EXPORT char * hb_fsExtName ( const char * pFilename, const char * pDefExt, + USHORT uiExFlags, const char * pPaths ); /* convert file name for hb_fsExtOpen, caller must free the returned buffer */ extern HB_EXPORT USHORT hb_fsIsDrv ( BYTE nDrive ); /* determine if a drive number is a valid drive */ extern HB_EXPORT BOOL hb_fsIsDevice ( HB_FHANDLE hFileHandle ); /* determine if a file is attached to a device (console?) */ extern HB_EXPORT BOOL hb_fsLock ( HB_FHANDLE hFileHandle, ULONG ulStart, ULONG ulLength, USHORT uiMode ); /* request a lock on a portion of a file */ extern HB_EXPORT BOOL hb_fsLockLarge ( HB_FHANDLE hFileHandle, HB_FOFFSET ulStart, HB_FOFFSET ulLength, USHORT uiMode ); /* request a lock on a portion of a file using 64bit API */ -extern HB_EXPORT BOOL hb_fsMkDir ( BYTE * pszDirName ); /* create a directory */ -extern HB_EXPORT HB_FHANDLE hb_fsOpen ( BYTE * pszFileName, USHORT uiFlags ); /* open a file */ +extern HB_EXPORT BOOL hb_fsMkDir ( const char * pszDirName ); /* create a directory */ +extern HB_EXPORT HB_FHANDLE hb_fsOpen ( const char * pszFileName, USHORT uiFlags ); /* open a file */ extern HB_EXPORT USHORT hb_fsRead ( HB_FHANDLE hFileHandle, BYTE * pBuff, USHORT ulCount ); /* read contents of a file into a buffer (<=64K) */ extern HB_EXPORT ULONG hb_fsReadLarge ( HB_FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount ); /* read contents of a file into a buffer (>64K) */ extern HB_EXPORT ULONG hb_fsReadAt ( HB_FHANDLE hFileHandle, BYTE * pBuff, ULONG ulCount, HB_FOFFSET llOffset ); /* read from given offset contents of a file into a buffer (>64K) */ -extern HB_EXPORT BOOL hb_fsRmDir ( BYTE * pszDirName ); /* remove a directory */ -extern HB_EXPORT BOOL hb_fsRename ( BYTE * pszOldName, BYTE * pszNewName ); /* rename a file */ +extern HB_EXPORT BOOL hb_fsRmDir ( const char * pszDirName ); /* remove a directory */ +extern HB_EXPORT BOOL hb_fsRename ( const char * pszOldName, const char * pszNewName ); /* rename a file */ extern HB_EXPORT ULONG hb_fsSeek ( HB_FHANDLE hFileHandle, LONG lOffset, USHORT uiMode ); /* reposition an open file */ extern HB_EXPORT HB_FOFFSET hb_fsSeekLarge ( HB_FHANDLE hFileHandle, HB_FOFFSET llOffset, USHORT uiFlags ); /* reposition an open file using 64bit API */ extern HB_EXPORT ULONG hb_fsTell ( HB_FHANDLE hFileHandle ); /* retrieve the current position of a file */ extern HB_EXPORT BOOL hb_fsSetDevMode ( HB_FHANDLE hFileHandle, USHORT uiDevMode ); /* change the device mode of a file (text/binary) */ -extern HB_EXPORT BOOL hb_fsGetFileTime ( BYTE * pszFileName, LONG * plJulian, LONG * plMillisec ); -extern HB_EXPORT BOOL hb_fsSetFileTime ( BYTE * pszFileName, LONG lJulian, LONG lMillisec ); -extern HB_EXPORT BOOL hb_fsGetAttr ( BYTE * pszFileName, ULONG * pulAttr ); -extern HB_EXPORT BOOL hb_fsSetAttr ( BYTE * pszFileName, ULONG ulAttr ); +extern HB_EXPORT BOOL hb_fsGetFileTime ( const char * pszFileName, LONG * plJulian, LONG * plMillisec ); +extern HB_EXPORT BOOL hb_fsSetFileTime ( const char * pszFileName, LONG lJulian, LONG lMillisec ); +extern HB_EXPORT BOOL hb_fsGetAttr ( const char * pszFileName, ULONG * pulAttr ); +extern HB_EXPORT BOOL hb_fsSetAttr ( const char * pszFileName, ULONG ulAttr ); extern HB_EXPORT void hb_fsSetError ( USHORT uiError ); /* set the file system DOS error number */ extern HB_EXPORT void hb_fsSetIOError ( BOOL fResult, USHORT uiOperation ); /* set the file system error number after IO operation */ extern HB_EXPORT BOOL hb_fsTruncAt ( HB_FHANDLE hFileHandle, HB_FOFFSET llOffset ); /* truncate file to given size */ extern HB_EXPORT USHORT hb_fsWrite ( HB_FHANDLE hFileHandle, const BYTE * pBuff, USHORT ulCount ); /* write to an open file from a buffer (<=64K) */ extern HB_EXPORT ULONG hb_fsWriteLarge ( HB_FHANDLE hFileHandle, const BYTE * pBuff, ULONG ulCount ); /* write to an open file from a buffer (>64K) */ extern HB_EXPORT ULONG hb_fsWriteAt ( HB_FHANDLE hFileHandle, const BYTE * pBuff, ULONG ulCount, HB_FOFFSET llOffset ); /* write to an open file at given offset from a buffer (>64K) */ -extern HB_EXPORT HB_FHANDLE hb_fsPOpen ( BYTE * pFilename, BYTE * pMode ); +extern HB_EXPORT HB_FHANDLE hb_fsPOpen ( const char * pFilename, const char * pMode ); extern HB_EXPORT HB_FHANDLE hb_fsGetOsHandle ( HB_FHANDLE hFileHandle ); extern HB_EXPORT USHORT hb_fsGetFError ( void ); /* get FERROR() flag */ extern HB_EXPORT void hb_fsSetFError ( USHORT uiError ); /* set FERROR() flag */ extern HB_EXPORT BOOL hb_fsNameExists ( const char * pszFileName ); /* check if a name exists in the filesystem (wildcard chars not accepted). */ extern HB_EXPORT BOOL hb_fsFileExists ( const char * pszFileName ); /* check if a file exists (wildcard chars not accepted). */ extern HB_EXPORT BOOL hb_fsDirExists ( const char * pszDirName ); /* check if a directory exists (wildcard chars not accepted). */ -extern HB_EXPORT BOOL hb_fsCopy ( const BYTE * pSource, const BYTE * pDest ); +extern HB_EXPORT BOOL hb_fsCopy ( const char * pSource, const char * pDest ); #define hb_fsFLock( h, s, l ) hb_fsLock( h, s, l, FL_LOCK ) #define hb_fsFUnlock( h, s, l ) hb_fsLock( h, s, l, FL_UNLOCK ) @@ -261,11 +261,11 @@ typedef struct _HB_PATHNAMES extern HB_EXPORT void hb_fsAddSearchPath( const char * szPath, HB_PATHNAMES ** pSearchList ); extern HB_EXPORT void hb_fsFreeSearchPath( HB_PATHNAMES * pSearchList ); -extern HB_EXPORT BOOL hb_spFile( BYTE * pFilename, BYTE * pRetPath ); -extern HB_EXPORT BOOL hb_spFileExists( BYTE * pFilename, BYTE * pRetPath ); -extern HB_EXPORT HB_FHANDLE hb_spOpen( BYTE * pFilename, USHORT uiFlags ); -extern HB_EXPORT HB_FHANDLE hb_spCreate( BYTE * pFilename, ULONG ulAttr ); -extern HB_EXPORT HB_FHANDLE hb_spCreateEx( BYTE * pFilename, ULONG ulAttr, USHORT uiFlags ); +extern HB_EXPORT BOOL hb_spFile( const char * pFilename, char * pRetPath ); +extern HB_EXPORT BOOL hb_spFileExists( const char * pFilename, char * pRetPath ); +extern HB_EXPORT HB_FHANDLE hb_spOpen( const char * pFilename, USHORT uiFlags ); +extern HB_EXPORT HB_FHANDLE hb_spCreate( const char * pFilename, ULONG ulAttr ); +extern HB_EXPORT HB_FHANDLE hb_spCreateEx( const char * pFilename, ULONG ulAttr, USHORT uiFlags ); /* File Find API structure */ typedef struct @@ -305,8 +305,8 @@ extern ULONG hb_fsAttrFromRaw( ULONG raw_attr ); extern ULONG hb_fsAttrToRaw( ULONG ulAttr ); extern ULONG hb_fsAttrEncode( const char * szAttr ); extern char * hb_fsAttrDecode( ULONG ulAttr, char * szAttr ); -extern HB_EXPORT BYTE * hb_fsNameConv( BYTE * szFileName, BOOL * pfFree ); extern HB_EXPORT BOOL hb_fsMaxFilesError( void ); +extern HB_EXPORT const char * hb_fsNameConv( const char * szFileName, char ** pszFree ); /* Harbour file functions with shared file handles and locks * (buffers in the future) @@ -314,15 +314,15 @@ extern HB_EXPORT BOOL hb_fsMaxFilesError( void ); #ifndef _HB_FILE_INTERNAL_ typedef void * PHB_FILE; #endif -HB_EXPORT PHB_FILE hb_fileExtOpen( BYTE * pFilename, BYTE * pDefExt, - USHORT uiExFlags, BYTE * pPaths, +HB_EXPORT PHB_FILE hb_fileExtOpen( const char * pFilename, const char * pDefExt, + USHORT uiExFlags, const char * pPaths, PHB_ITEM pError ); -HB_EXPORT PHB_FILE hb_fileCreateTemp( const BYTE * pszDir, const BYTE * pszPrefix, - ULONG ulAttr, BYTE * pszName ); -HB_EXPORT PHB_FILE hb_fileCreateTempEx( BYTE * pszName, - const BYTE * pszDir, - const BYTE * pszPrefix, - const BYTE * pszExt, +HB_EXPORT PHB_FILE hb_fileCreateTemp( const char * pszDir, const char * pszPrefix, + ULONG ulAttr, char * pszName ); +HB_EXPORT PHB_FILE hb_fileCreateTempEx( char * pszName, + const char * pszDir, + const char * pszPrefix, + const char * pszExt, ULONG ulAttr ); HB_EXPORT void hb_fileClose( PHB_FILE pFile ); HB_EXPORT BOOL hb_fileLock( PHB_FILE pFile, HB_FOFFSET ulStart, HB_FOFFSET ulLen, int iType ); diff --git a/harbour/include/hbapigt.h b/harbour/include/hbapigt.h index 417c9cf3d4..f238e16e10 100644 --- a/harbour/include/hbapigt.h +++ b/harbour/include/hbapigt.h @@ -171,10 +171,10 @@ extern HB_EXPORT HB_ERRCODE hb_gtInit( HB_FHANDLE hFilenoStdin, HB_FHANDLE hFile extern HB_EXPORT HB_ERRCODE hb_gtExit( void ); extern HB_EXPORT HB_ERRCODE hb_gtLock( void ); extern HB_EXPORT HB_ERRCODE hb_gtUnlock( void ); -extern HB_EXPORT HB_ERRCODE hb_gtBox( SHORT uiTop, SHORT uiLeft, SHORT uiBottom, SHORT uiRight, BYTE * pbyFrame ); +extern HB_EXPORT HB_ERRCODE hb_gtBox( SHORT uiTop, SHORT uiLeft, SHORT uiBottom, SHORT uiRight, const BYTE * pbyFrame ); extern HB_EXPORT HB_ERRCODE hb_gtBoxD( SHORT uiTop, SHORT uiLeft, SHORT uiBottom, SHORT uiRight ); extern HB_EXPORT HB_ERRCODE hb_gtBoxS( SHORT uiTop, SHORT uiLeft, SHORT uiBottom, SHORT uiRight ); -extern HB_EXPORT HB_ERRCODE hb_gtDrawBox( SHORT uiTop, SHORT uiLeft, SHORT uiBottom, SHORT uiRight, BYTE * pbyFrame, int iColor ); +extern HB_EXPORT HB_ERRCODE hb_gtDrawBox( SHORT uiTop, SHORT uiLeft, SHORT uiBottom, SHORT uiRight, const BYTE * pbyFrame, int iColor ); extern HB_EXPORT HB_ERRCODE hb_gtColorSelect( USHORT uiColorIndex ); extern HB_EXPORT int hb_gtColorToN( const char * szColorString ); extern HB_EXPORT HB_ERRCODE hb_gtColorsToString( int * pColors, int iColorCount, char * pszColorString, int iBufSize ); @@ -213,13 +213,13 @@ extern HB_EXPORT HB_ERRCODE hb_gtSetMode( USHORT uiRows, USHORT uiCols ); extern HB_EXPORT HB_ERRCODE hb_gtSetPos( SHORT iRow, SHORT iCol ); extern HB_EXPORT HB_ERRCODE hb_gtSetSnowFlag( BOOL bNoSnow ); extern HB_EXPORT HB_ERRCODE hb_gtTone( double dFrequency, double dDuration ); -extern HB_EXPORT HB_ERRCODE hb_gtWrite( BYTE * pbyStr, ULONG ulLen ); -extern HB_EXPORT HB_ERRCODE hb_gtWriteAt( USHORT uiRow, USHORT uiCol, BYTE * pbyStr, ULONG ulLen ); -extern HB_EXPORT HB_ERRCODE hb_gtWriteCon( BYTE * pbyStr, ULONG ulLen ); -extern HB_EXPORT HB_ERRCODE hb_gtPutText( USHORT uiRow, USHORT uiCol, BYTE * pStr, ULONG ulLength, int iColor ); +extern HB_EXPORT HB_ERRCODE hb_gtWrite( const BYTE * pbyStr, ULONG ulLen ); +extern HB_EXPORT HB_ERRCODE hb_gtWriteAt( USHORT uiRow, USHORT uiCol, const BYTE * pbyStr, ULONG ulLen ); +extern HB_EXPORT HB_ERRCODE hb_gtWriteCon( const BYTE * pbyStr, ULONG ulLen ); +extern HB_EXPORT HB_ERRCODE hb_gtPutText( USHORT uiRow, USHORT uiCol, const BYTE * pStr, ULONG ulLength, int iColor ); extern HB_EXPORT const char * hb_gtVersion( int iType ); -extern HB_EXPORT HB_ERRCODE hb_gtOutStd( BYTE * pbyStr, ULONG ulLen ); -extern HB_EXPORT HB_ERRCODE hb_gtOutErr( BYTE * pbyStr, ULONG ulLen ); +extern HB_EXPORT HB_ERRCODE hb_gtOutStd( const BYTE * pbyStr, ULONG ulLen ); +extern HB_EXPORT HB_ERRCODE hb_gtOutErr( const BYTE * pbyStr, ULONG ulLen ); extern HB_EXPORT HB_ERRCODE hb_gtSetDispCP( const char * pszTermCDP, const char * pszHostCDP, BOOL fBox ); extern HB_EXPORT HB_ERRCODE hb_gtSetKeyCP( const char * pszTermCDP, const char * pszHostCDP ); extern HB_EXPORT HB_ERRCODE hb_gtInfo( int iType, PHB_GT_INFO pInfo ); @@ -235,7 +235,7 @@ extern HB_EXPORT HB_ERRCODE hb_gtPutScrChar( int iRow, int iCol, BYTE bColor, BY extern HB_EXPORT HB_ERRCODE hb_gtFlush( void ); extern HB_EXPORT HB_ERRCODE hb_gtGetPosEx( int * piRow, int * piCol ); extern HB_EXPORT HB_ERRCODE hb_gtScrollEx( int iTop, int iLeft, int iBottom, int iRight, int iColor, int iChar, int iRows, int iCols ); -extern HB_EXPORT HB_ERRCODE hb_gtBoxEx( int iTop, int iLeft, int iBottom, int iRight, BYTE * pbyFrame, int iColor ); +extern HB_EXPORT HB_ERRCODE hb_gtBoxEx( int iTop, int iLeft, int iBottom, int iRight, const BYTE * pbyFrame, int iColor ); extern HB_EXPORT int hb_gtGfxPrimitive( int iType, int iTop, int iLeft, int iBottom, int iRight, int iColor ); extern HB_EXPORT HB_ERRCODE hb_gtGfxText( int iTop, int iLeft, const char * szText, int iColor, int iSize, int iWidth ); @@ -250,7 +250,7 @@ extern HB_EXPORT void hb_mouseSetBounds( int iTop, int iLeft, int iBottom, extern HB_EXPORT void hb_mouseGetBounds( int * piTop, int * piLeft, int * piBottom, int * piRight ); extern HB_EXPORT int hb_mouseStorageSize( void ); extern HB_EXPORT void hb_mouseSaveState( BYTE * pBuffer ); -extern HB_EXPORT void hb_mouseRestoreState( BYTE * pBuffer ); +extern HB_EXPORT void hb_mouseRestoreState( const BYTE * pBuffer ); extern HB_EXPORT int hb_mouseGetDoubleClickSpeed( void ); extern HB_EXPORT void hb_mouseSetDoubleClickSpeed( int iSpeed ); extern HB_EXPORT int hb_mouseCountButton( void ); diff --git a/harbour/include/hbapiitm.h b/harbour/include/hbapiitm.h index c2f86b4a15..ab43269b0e 100644 --- a/harbour/include/hbapiitm.h +++ b/harbour/include/hbapiitm.h @@ -170,6 +170,7 @@ extern HB_EXPORT PHB_ITEM hb_itemUnRefWrite( PHB_ITEM pItem, PHB_ITEM pSourc extern HB_EXPORT PHB_ITEM hb_itemUnShare ( PHB_ITEM pItem ); /* un-share given string item */ extern HB_EXPORT PHB_ITEM hb_itemUnShareString( PHB_ITEM pItem ); /* un-share given string item - the pItem have to be valid unrefed string item */ extern HB_EXPORT PHB_ITEM hb_itemReSizeString( PHB_ITEM pItem, ULONG ulSize ); /* Resize string buffer of given string item - the pItem have to be valid unrefed string item */ +extern HB_EXPORT BOOL hb_itemGetWriteCL( PHB_ITEM pItem, char ** pszValue, ULONG * pulLen ); extern HB_EXPORT PHB_ITEM hb_itemClone ( PHB_ITEM pItem ); /* clone the given item */ extern HB_EXPORT char * hb_itemStr ( PHB_ITEM pNumber, PHB_ITEM pWidth, PHB_ITEM pDec ); /* convert a number to a string */ extern HB_EXPORT char * hb_itemString ( PHB_ITEM pItem, ULONG * ulLen, BOOL * bFreeReq ); /* Convert any scalar to a string */ diff --git a/harbour/include/hbapilng.h b/harbour/include/hbapilng.h index 5fdc2c03c3..9e7c65ff5d 100644 --- a/harbour/include/hbapilng.h +++ b/harbour/include/hbapilng.h @@ -82,21 +82,21 @@ extern HB_EXPORT void hb_vmSetLang( PHB_LANG pLang ); /* Supported language list management */ -extern HB_EXPORT BOOL hb_langRegister ( PHB_LANG lang ); -extern HB_EXPORT BOOL hb_langDeRegister ( const char * pszID ); -extern HB_EXPORT PHB_LANG hb_langFind ( const char * pszID ); +extern HB_EXPORT BOOL hb_langRegister ( PHB_LANG lang ); +extern HB_EXPORT BOOL hb_langDeRegister ( const char * pszID ); +extern HB_EXPORT PHB_LANG hb_langFind ( const char * pszID ); /* Default language selection and data query */ -extern HB_EXPORT PHB_LANG hb_langSelect ( PHB_LANG lang ); -extern HB_EXPORT char * hb_langSelectID ( const char * pszID ); -extern HB_EXPORT char * hb_langDGetItem ( int iIndex ); -extern HB_EXPORT char * hb_langID ( void ); -extern HB_EXPORT char * hb_langName ( void ); +extern HB_EXPORT PHB_LANG hb_langSelect ( PHB_LANG lang ); +extern HB_EXPORT const char * hb_langSelectID ( const char * pszID ); +extern HB_EXPORT const char * hb_langDGetItem ( int iIndex ); +extern HB_EXPORT const char * hb_langID ( void ); +extern HB_EXPORT char * hb_langName ( void ); /* Compatibility interface */ -extern HB_EXPORT char * hb_langDGetErrorDesc ( ULONG ulIndex ); +extern HB_EXPORT const char * hb_langDGetErrorDesc ( ULONG ulIndex ); HB_EXTERN_END diff --git a/harbour/include/hbapirdd.h b/harbour/include/hbapirdd.h index 6b3dd44c99..5bbc48280f 100644 --- a/harbour/include/hbapirdd.h +++ b/harbour/include/hbapirdd.h @@ -172,12 +172,12 @@ struct _RDDNODE; typedef struct { - BYTE * atomName; /* FIELD (symbol) name */ - HB_TYPE uiType; /* FIELD type */ - USHORT uiTypeExtended; /* FIELD type extended */ - USHORT uiLen; /* Overall FIELD length */ - USHORT uiDec; /* Decimal places of numeric FIELD */ - USHORT uiFlags; /* FIELD flags */ + const char * atomName; /* FIELD (symbol) name */ + HB_TYPE uiType; /* FIELD type */ + USHORT uiTypeExtended; /* FIELD type extended */ + USHORT uiLen; /* Overall FIELD length */ + USHORT uiDec; /* Decimal places of numeric FIELD */ + USHORT uiFlags; /* FIELD flags */ } DBFIELDINFO; typedef DBFIELDINFO * LPDBFIELDINFO; @@ -192,14 +192,14 @@ typedef DBFIELDINFO * LPDBFIELDINFO; typedef struct { - USHORT uiArea; /* Work Area number of the data store */ - BYTE * abName; /* The qualified name of the data store */ - BYTE * atomAlias; /* The logical name of the data store */ - BOOL fShared; /* Share mode of the data store */ - BOOL fReadonly; /* Readonly mode of the data store */ - BYTE * cdpId; /* Id of a codepage */ - ULONG ulConnection; /* connection handler for RDDs which support it */ - void * lpdbHeader; /* Pointer to a header of the data store */ + USHORT uiArea; /* Work Area number of the data store */ + const char * abName; /* The qualified name of the data store */ + const char * atomAlias; /* The logical name of the data store */ + BOOL fShared; /* Share mode of the data store */ + BOOL fReadonly; /* Readonly mode of the data store */ + const char * cdpId; /* Id of a codepage */ + ULONG ulConnection; /* connection handler for RDDs which support it */ + void * lpdbHeader; /* Pointer to a header of the data store */ } DBOPENINFO; typedef DBOPENINFO * LPDBOPENINFO; @@ -214,29 +214,29 @@ typedef DBOPENINFO * LPDBOPENINFO; typedef struct _DBORDERCONDINFO { - BOOL fActive; - BYTE * abFor; - BYTE * abWhile; - PHB_ITEM itmCobFor; - PHB_ITEM itmCobWhile; - PHB_ITEM itmCobEval; - LONG lStep; - PHB_ITEM itmStartRecID; - LONG lNextCount; - PHB_ITEM itmRecID; - BOOL fRest; - BOOL fDescending; - BOOL fScoped; - BOOL fAll; - BOOL fAdditive; - BOOL fUseCurrent; - BOOL fCustom; - BOOL fNoOptimize; - BOOL fCompound; - BOOL fUseFilter; - BOOL fTemporary; - BOOL fExclusive; - void * lpvCargo; + BOOL fActive; + char * abFor; + char * abWhile; + PHB_ITEM itmCobFor; + PHB_ITEM itmCobWhile; + PHB_ITEM itmCobEval; + LONG lStep; + PHB_ITEM itmStartRecID; + LONG lNextCount; + PHB_ITEM itmRecID; + BOOL fRest; + BOOL fDescending; + BOOL fScoped; + BOOL fAll; + BOOL fAdditive; + BOOL fUseCurrent; + BOOL fCustom; + BOOL fNoOptimize; + BOOL fCompound; + BOOL fUseFilter; + BOOL fTemporary; + BOOL fExclusive; + void * lpvCargo; } DBORDERCONDINFO; typedef DBORDERCONDINFO * LPDBORDERCONDINFO; @@ -245,10 +245,10 @@ typedef DBORDERCONDINFO * LPDBORDERCONDINFO; typedef struct { - BYTE * abConstrName; /* Name of relational integrity constraint */ - BYTE * abTargetName; /* Name of target relation table */ - PHB_ITEM itmRelationKey; /* Array of columns in source table to match target primary key */ - BOOL fEnabled; /* Is constraint enabled ? */ + const char * abConstrName; /* Name of relational integrity constraint */ + const char * abTargetName; /* Name of target relation table */ + PHB_ITEM itmRelationKey; /* Array of columns in source table to match target primary key */ + BOOL fEnabled; /* Is constraint enabled ? */ } DBCONSTRAINTINFO; typedef DBCONSTRAINTINFO * LPDBCONSTRAINTINFO; @@ -263,8 +263,8 @@ typedef DBCONSTRAINTINFO * LPDBCONSTRAINTINFO; typedef struct { LPDBORDERCONDINFO lpdbOrdCondInfo; /* Conditional information */ - BYTE * abBagName; /* Name of the Order bag */ - BYTE * atomBagName; /* Name of the Order */ + const char * abBagName; /* Name of the Order bag */ + const char* atomBagName; /* Name of the Order */ PHB_ITEM itmOrder; BOOL fUnique; /* Flag to determine if all keys are unique */ PHB_ITEM itmCobExpr; /* Code block containing the KEY expression */ @@ -617,7 +617,7 @@ typedef USHORT ( * DBENTRYP_S )( AREAP area, USHORT param ); typedef USHORT ( * DBENTRYP_LP )( AREAP area, LONG * param ); typedef USHORT ( * DBENTRYP_ULP )( AREAP area, ULONG * param ); typedef USHORT ( * DBENTRYP_SVP )( AREAP area, USHORT index, void * param ); -typedef USHORT ( * DBENTRYP_SVPB )( AREAP area, USHORT index, void * param, USHORT p3 ); +typedef USHORT ( * DBENTRYP_SVPB )( AREAP area, USHORT index, const char * param, USHORT p3 ); typedef USHORT ( * DBENTRYP_VSP )( AREAP area, USHORT action, ULONG lRecord ); typedef USHORT ( * DBENTRYP_SVL )( AREAP area, USHORT index, ULONG * param ); typedef USHORT ( * DBENTRYP_SSI )( AREAP area, USHORT p1, USHORT p2, PHB_ITEM p3 ); @@ -1221,7 +1221,7 @@ extern HB_EXPORT HB_ERRCODE hb_rddCloseAllParentRelations( AREAP pArea ); extern HB_EXPORT HB_ERRCODE hb_rddEvalWA( PHB_ITEM pBlock ); extern HB_EXPORT HB_ERRCODE hb_rddDetachArea( AREAP pArea, PHB_ITEM pCargo ); -extern HB_EXPORT AREAP hb_rddRequestArea( char * szAlias, PHB_ITEM pCargo, +extern HB_EXPORT AREAP hb_rddRequestArea( const char * szAlias, PHB_ITEM pCargo, BOOL fNewArea, BOOL fWait ); #if 0 diff --git a/harbour/include/hbcomp.h b/harbour/include/hbcomp.h index 66b77335cc..17359e35c0 100644 --- a/harbour/include/hbcomp.h +++ b/harbour/include/hbcomp.h @@ -82,7 +82,7 @@ extern void hb_compPCodeTrace( PFUNCTION, const HB_PCODE_FUNC_PTR *, void * ); extern void hb_compGenLabelTable( PFUNCTION pFunc, PHB_LABEL_INFO label_info ); extern PHB_DEBUGINFO hb_compGetDebugInfo( HB_COMP_DECL ); -extern void hb_compInitPP( HB_COMP_DECL, int argc, char * const argv[] ); +extern void hb_compInitPP( HB_COMP_DECL, int argc, const char * const argv[] ); extern void hb_compCompileEnd( HB_COMP_DECL ); extern int hb_compparse( HB_COMP_DECL ); @@ -220,7 +220,7 @@ extern void hb_compGenPCode1( BYTE, HB_COMP_DECL ); /* generates 1 byte of pcode extern void hb_compGenPCode2( BYTE, BYTE, HB_COMP_DECL ); /* generates 2 bytes of pcode + flag for optional StrongType(). */ extern void hb_compGenPCode3( BYTE, BYTE, BYTE, HB_COMP_DECL ); /* generates 3 bytes of pcode + flag for optional StrongType() */ extern void hb_compGenPCode4( BYTE, BYTE, BYTE, BYTE, HB_COMP_DECL ); /* generates 4 bytes of pcode + flag for optional StrongType() */ -extern void hb_compGenPCodeN( BYTE * pBuffer, ULONG ulSize, HB_COMP_DECL ); /* copy bytes to a pcode buffer + flag for optional StrongType() */ +extern void hb_compGenPCodeN( const BYTE * pBuffer, ULONG ulSize, HB_COMP_DECL ); /* copy bytes to a pcode buffer + flag for optional StrongType() */ extern ULONG hb_compSequenceBegin( HB_COMP_DECL ); extern ULONG hb_compSequenceEnd( HB_COMP_DECL ); @@ -269,7 +269,7 @@ extern BOOL hb_compCheckUnclosedStru( HB_COMP_DECL, PFUNCTION ); #define HB_GEN_FUNC3( func, p1,p2,p3 ) hb_compGen##func( p1, p2, p3, HB_COMP_PARAM ) #define HB_GEN_FUNC4( func, p1,p2,p3,p4 ) hb_compGen##func( p1, p2, p3, p4, HB_COMP_PARAM ) -extern int hb_compMain( int argc, char * const argv[], BYTE ** pBufPtr, ULONG * pulSize, const char * szSource ); +extern int hb_compMain( int argc, const char * const argv[], BYTE ** pBufPtr, ULONG * pulSize, const char * szSource ); extern void hb_compOutStd( HB_COMP_DECL, const char * szMessage ); extern void hb_compOutErr( HB_COMP_DECL, const char * szMessage ); @@ -306,9 +306,9 @@ extern void hb_compCodeBlockRewind( HB_COMP_DECL ); /* restart of fake code extern ULONG hb_compExprListEval( HB_COMP_DECL, HB_EXPR_PTR pExpr, HB_CARGO_FUNC_PTR pEval ); extern ULONG hb_compExprListEval2( HB_COMP_DECL, HB_EXPR_PTR pExpr1, HB_EXPR_PTR pExpr2, HB_CARGO2_FUNC_PTR pEval ); -extern void hb_compChkCompilerSwitch( HB_COMP_DECL, int, char * const Args[] ); +extern void hb_compChkCompilerSwitch( HB_COMP_DECL, int, const char * const args[] ); extern void hb_compChkPaths( HB_COMP_DECL ); -extern void hb_compChkDefines( HB_COMP_DECL, int iArg, char * const Args[] ); +extern void hb_compChkDefines( HB_COMP_DECL, int iArg, const char * const args[] ); extern void hb_compPrintUsage( HB_COMP_DECL, const char * ); extern void hb_compPrintCredits( HB_COMP_DECL ); @@ -340,7 +340,7 @@ extern void hb_compGenCObj( HB_COMP_DECL, PHB_FNAME ); /* generates platfo extern void hb_compGenBufPortObj( HB_COMP_DECL, BYTE ** pBufPtr, ULONG * pulSize ); /* generates the portable objects to memory buffer */ extern void hb_compGenCRealCode( HB_COMP_DECL, PFUNCTION pFunc, FILE * yyc ); -extern void hb_compGenCString( FILE * yyc, BYTE * pText, ULONG ulLen ); +extern void hb_compGenCString( FILE * yyc, const BYTE * pText, ULONG ulLen ); /* hbident.c */ extern const char * hb_compIdentifierNew( HB_COMP_DECL, const char * szName, int iType ); /* create the reusable identifier */ diff --git a/harbour/include/hbdbsort.h b/harbour/include/hbdbsort.h index afb27cf004..a2ce7606c8 100644 --- a/harbour/include/hbdbsort.h +++ b/harbour/include/hbdbsort.h @@ -66,7 +66,7 @@ HB_EXTERN_BEGIN typedef struct _DBQUICKSORT { HB_FHANDLE hFile; - BYTE szTempName[ HB_PATH_MAX ]; + char szTempName[ HB_PATH_MAX ]; BYTE * pBuffer; BYTE * pSwapBufferA; BYTE * pSwapBufferB; diff --git a/harbour/include/hbgtcore.h b/harbour/include/hbgtcore.h index bdd4e18a1c..d0bf971561 100644 --- a/harbour/include/hbgtcore.h +++ b/harbour/include/hbgtcore.h @@ -159,19 +159,19 @@ typedef struct BOOL (* PutChar) ( HB_GT_PTR, int, int, BYTE, BYTE, USHORT ); long (* RectSize) ( HB_GT_PTR, int, int, int, int ); void (* Save) ( HB_GT_PTR, int, int, int, int, BYTE * ); - void (* Rest) ( HB_GT_PTR, int, int, int, int, BYTE * ); - void (* PutText) ( HB_GT_PTR, int, int, BYTE, BYTE *, ULONG ); + void (* Rest) ( HB_GT_PTR, int, int, int, int, const BYTE * ); + void (* PutText) ( HB_GT_PTR, int, int, BYTE, const BYTE *, ULONG ); void (* Replicate) ( HB_GT_PTR, int, int, BYTE, BYTE, USHORT, ULONG ); - void (* WriteAt) ( HB_GT_PTR, int, int, BYTE *, ULONG ); - void (* Write) ( HB_GT_PTR, BYTE *, ULONG ); - void (* WriteCon) ( HB_GT_PTR, BYTE *, ULONG ); + void (* WriteAt) ( HB_GT_PTR, int, int, const BYTE *, ULONG ); + void (* Write) ( HB_GT_PTR, const BYTE *, ULONG ); + void (* WriteCon) ( HB_GT_PTR, const BYTE *, ULONG ); void (* SetAttribute) ( HB_GT_PTR, int, int, int, int, BYTE ); void (* DrawShadow) ( HB_GT_PTR, int, int, int, int, BYTE ); void (* Scroll) ( HB_GT_PTR, int, int, int, int, BYTE, BYTE, int, int ); void (* ScrollUp) ( HB_GT_PTR, int, BYTE, BYTE ); - void (* Box) ( HB_GT_PTR, int, int, int, int, BYTE *, BYTE ); - void (* BoxD) ( HB_GT_PTR, int, int, int, int, BYTE *, BYTE ); - void (* BoxS) ( HB_GT_PTR, int, int, int, int, BYTE *, BYTE ); + void (* Box) ( HB_GT_PTR, int, int, int, int, const BYTE *, BYTE ); + void (* BoxD) ( HB_GT_PTR, int, int, int, int, const BYTE *, BYTE ); + void (* BoxS) ( HB_GT_PTR, int, int, int, int, const BYTE *, BYTE ); void (* HorizLine) ( HB_GT_PTR, int, int, int, BYTE, BYTE ); void (* VertLine) ( HB_GT_PTR, int, int, int, BYTE, BYTE ); BOOL (* GetBlink) ( HB_GT_PTR ); @@ -182,8 +182,8 @@ typedef struct BOOL (* Resume) ( HB_GT_PTR ); BOOL (* PreExt) ( HB_GT_PTR ); BOOL (* PostExt) ( HB_GT_PTR ); - void (* OutStd) ( HB_GT_PTR, BYTE *, ULONG ); - void (* OutErr) ( HB_GT_PTR, BYTE *, ULONG ); + void (* OutStd) ( HB_GT_PTR, const BYTE *, ULONG ); + void (* OutErr) ( HB_GT_PTR, const BYTE *, ULONG ); void (* Tone) ( HB_GT_PTR, double, double ); void (* Bell) ( HB_GT_PTR ); BOOL (* Info) ( HB_GT_PTR, int, PHB_GT_INFO ); @@ -224,7 +224,7 @@ typedef struct void (* MouseGetBounds) ( HB_GT_PTR, int *, int *, int *, int * ); int (* MouseStorageSize) ( HB_GT_PTR ); void (* MouseSaveState) ( HB_GT_PTR, BYTE * ); - void (* MouseRestoreState) ( HB_GT_PTR, BYTE * ); + void (* MouseRestoreState) ( HB_GT_PTR, const BYTE * ); int (* MouseGetDoubleClickSpeed) ( HB_GT_PTR ); void (* MouseSetDoubleClickSpeed) ( HB_GT_PTR, int ); int (* MouseCountButton) ( HB_GT_PTR ); diff --git a/harbour/include/hbrdddbf.h b/harbour/include/hbrdddbf.h index 416eeb1098..6eca40dc38 100644 --- a/harbour/include/hbrdddbf.h +++ b/harbour/include/hbrdddbf.h @@ -352,9 +352,9 @@ static HB_ERRCODE hb_dbfLock( DBFAREAP pArea, LPDBLOCKINFO pLockInfo ); static HB_ERRCODE hb_dbfUnLock( DBFAREAP pArea, PHB_ITEM pRecNo ); #define hb_dbfCloseMemFile NULL static HB_ERRCODE hb_dbfCreateMemFile( DBFAREAP pArea, LPDBOPENINFO pCreateInfo ); -static HB_ERRCODE hb_dbfGetValueFile( DBFAREAP pArea, USHORT uiIndex, BYTE * szFile, USHORT uiMode ); +static HB_ERRCODE hb_dbfGetValueFile( DBFAREAP pArea, USHORT uiIndex, const char * szFile, USHORT uiMode ); static HB_ERRCODE hb_dbfOpenMemFile( DBFAREAP pArea, LPDBOPENINFO pOpenInfo ); -static HB_ERRCODE hb_dbfPutValueFile( DBFAREAP pArea, USHORT uiIndex, BYTE * szFile, USHORT uiMode ); +static HB_ERRCODE hb_dbfPutValueFile( DBFAREAP pArea, USHORT uiIndex, const char * szFile, USHORT uiMode ); static HB_ERRCODE hb_dbfReadDBHeader( DBFAREAP pArea ); static HB_ERRCODE hb_dbfWriteDBHeader( DBFAREAP pArea ); diff --git a/harbour/include/hbrddfpt.h b/harbour/include/hbrddfpt.h index a84f4dc754..3fab267875 100644 --- a/harbour/include/hbrddfpt.h +++ b/harbour/include/hbrddfpt.h @@ -338,9 +338,9 @@ static HB_ERRCODE hb_fptPackRec( FPTAREAP pArea, ULONG ulRecNo, BOOL *pfWritten #define hb_fptUnLock NULL #define hb_fptCloseMemFile NULL static HB_ERRCODE hb_fptCreateMemFile( FPTAREAP pArea, LPDBOPENINFO pCreateInfo ); -static HB_ERRCODE hb_fptGetValueFile( FPTAREAP pArea, USHORT uiIndex, BYTE * szFile, USHORT uiMode ); +static HB_ERRCODE hb_fptGetValueFile( FPTAREAP pArea, USHORT uiIndex, const char * szFile, USHORT uiMode ); static HB_ERRCODE hb_fptOpenMemFile( FPTAREAP pArea, LPDBOPENINFO pOpenInfo ); -static HB_ERRCODE hb_fptPutValueFile( FPTAREAP pArea, USHORT uiIndex, BYTE * szFile, USHORT uiMode ); +static HB_ERRCODE hb_fptPutValueFile( FPTAREAP pArea, USHORT uiIndex, const char * szFile, USHORT uiMode ); #define hb_fptReadDBHeader NULL #define hb_fptWriteDBHeader NULL #define hb_fptInit NULL diff --git a/harbour/include/hbset.h b/harbour/include/hbset.h index 69f90edbc4..3a38aef8bb 100644 --- a/harbour/include/hbset.h +++ b/harbour/include/hbset.h @@ -254,84 +254,84 @@ extern int hb_setListenerAdd( HB_SET_LISTENER_CALLBACK * ); extern void hb_setListenerNotify( HB_set_enum, HB_set_listener_enum ); extern int hb_setListenerRemove( int ); -extern HB_EXPORT BOOL hb_setGetL( HB_set_enum set_specifier ); -extern HB_EXPORT char * hb_setGetCPtr( HB_set_enum set_specifier ); -extern HB_EXPORT int hb_setGetNI( HB_set_enum set_specifier ); -extern HB_EXPORT long hb_setGetNL( HB_set_enum set_specifier ); +extern HB_EXPORT BOOL hb_setGetL( HB_set_enum set_specifier ); +extern HB_EXPORT const char * hb_setGetCPtr( HB_set_enum set_specifier ); +extern HB_EXPORT int hb_setGetNI( HB_set_enum set_specifier ); +extern HB_EXPORT long hb_setGetNL( HB_set_enum set_specifier ); -extern HB_EXPORT BOOL hb_setSetItem( HB_set_enum set_specifier, PHB_ITEM pItem ); -extern HB_EXPORT BOOL hb_setSetItem2( HB_set_enum set_specifier, PHB_ITEM pItem1, PHB_ITEM pItem2 ); +extern HB_EXPORT BOOL hb_setSetItem( HB_set_enum set_specifier, PHB_ITEM pItem ); +extern HB_EXPORT BOOL hb_setSetItem2( HB_set_enum set_specifier, PHB_ITEM pItem1, PHB_ITEM pItem2 ); extern HB_EXPORT HB_PATHNAMES * hb_setGetFirstSetPath( void ); -extern HB_EXPORT BOOL hb_setGetCentury( void ); -extern HB_EXPORT BOOL hb_setSetCentury( BOOL ); +extern HB_EXPORT BOOL hb_setGetCentury( void ); +extern HB_EXPORT BOOL hb_setSetCentury( BOOL ); -extern HB_EXPORT HB_FHANDLE hb_setGetAltHan( void ); -extern HB_EXPORT HB_FHANDLE hb_setGetExtraHan( void ); -extern HB_EXPORT HB_FHANDLE hb_setGetPrintHan( void ); -extern HB_EXPORT HB_FHANDLE hb_setGetPrinterHandle( int ); -extern HB_EXPORT BOOL hb_setGetAlternate( void ); -extern HB_EXPORT char * hb_setGetAltFile( void ); -extern HB_EXPORT BOOL hb_setGetAutOpen( void ); -extern HB_EXPORT int hb_setGetAutOrder( void ); -extern HB_EXPORT int hb_setGetAutoShare( void ); -extern HB_EXPORT BOOL hb_setGetBell( void ); -extern HB_EXPORT BOOL hb_setGetCancel( void ); -extern HB_EXPORT char * hb_setGetColor( void ); -extern HB_EXPORT BOOL hb_setGetConfirm( void ); -extern HB_EXPORT BOOL hb_setGetConsole( void ); -extern HB_EXPORT char * hb_setGetDateFormat( void ); -extern HB_EXPORT char * hb_setGetTimeFormat( void ); -extern HB_EXPORT BOOL hb_setGetDebug( void ); -extern HB_EXPORT int hb_setGetDecimals( void ); -extern HB_EXPORT char * hb_setGetDefault( void ); -extern HB_EXPORT BOOL hb_setGetDeleted( void ); -extern HB_EXPORT char * hb_setGetDelimChars( void ); -extern HB_EXPORT BOOL hb_setGetDelimiters( void ); -extern HB_EXPORT char * hb_setGetDevice( void ); -extern HB_EXPORT BOOL hb_setGetEOF( void ); -extern HB_EXPORT int hb_setGetEpoch( void ); -extern HB_EXPORT BOOL hb_setGetEscape( void ); -extern HB_EXPORT int hb_setGetEventMask( void ); -extern HB_EXPORT BOOL hb_setGetExact( void ); -extern HB_EXPORT BOOL hb_setGetExclusive( void ); -extern HB_EXPORT BOOL hb_setGetExit( void ); -extern HB_EXPORT BOOL hb_setGetExtra( void ); -extern HB_EXPORT char * hb_setGetExtraFile( void ); -extern HB_EXPORT BOOL hb_setGetFixed( void ); -extern HB_EXPORT BOOL hb_setGetIdleRepeat( void ); -extern HB_EXPORT BOOL hb_setGetInsert( void ); -extern HB_EXPORT BOOL hb_setGetIntensity( void ); -extern HB_EXPORT char * hb_setGetPath( void ); -extern HB_EXPORT int hb_setGetMargin( void ); -extern HB_EXPORT int hb_setGetMBlockSize( void ); -extern HB_EXPORT BOOL hb_setGetMCenter( void ); -extern HB_EXPORT int hb_setGetMessage( void ); -extern HB_EXPORT char * hb_setGetMFileExt( void ); -extern HB_EXPORT BOOL hb_setGetOptimize( void ); -extern HB_EXPORT BOOL hb_setGetPrinter( void ); -extern HB_EXPORT char * hb_setGetPrintFile( void ); -extern HB_EXPORT BOOL hb_setGetScoreBoard( void ); -extern HB_EXPORT BOOL hb_setGetScrollBreak( void ); -extern HB_EXPORT BOOL hb_setGetSoftSeek( void ); -extern HB_EXPORT BOOL hb_setGetStrictRead( void ); -extern HB_EXPORT int hb_setGetTypeAhead( void ); -extern HB_EXPORT BOOL hb_setGetUnique( void ); -extern HB_EXPORT int hb_setGetFileCase( void ); -extern HB_EXPORT int hb_setGetDirCase( void ); -extern HB_EXPORT int hb_setGetDirSeparator( void ); -extern HB_EXPORT int hb_setGetVideoMode( void ); -extern HB_EXPORT BOOL hb_setGetWrap( void ); -extern HB_EXPORT int hb_setGetDBFLockScheme( void ); -extern HB_EXPORT BOOL hb_setGetHardCommit( void ); -extern HB_EXPORT BOOL hb_setGetForceOpt( void ); -extern HB_EXPORT BOOL hb_setGetDefExtension( void ); -extern HB_EXPORT char * hb_setGetEOL( void ); -extern HB_EXPORT BOOL hb_setGetTrimFileName( void ); -extern HB_EXPORT char * hb_setGetHBOUTLOG( void ); -extern HB_EXPORT char * hb_setGetHBOUTLOGINFO( void ); -extern HB_EXPORT char * hb_setGetOSCODEPAGE( void ); +extern HB_EXPORT HB_FHANDLE hb_setGetAltHan( void ); +extern HB_EXPORT HB_FHANDLE hb_setGetExtraHan( void ); +extern HB_EXPORT HB_FHANDLE hb_setGetPrintHan( void ); +extern HB_EXPORT HB_FHANDLE hb_setGetPrinterHandle( int ); +extern HB_EXPORT BOOL hb_setGetAlternate( void ); +extern HB_EXPORT const char * hb_setGetAltFile( void ); +extern HB_EXPORT BOOL hb_setGetAutOpen( void ); +extern HB_EXPORT int hb_setGetAutOrder( void ); +extern HB_EXPORT int hb_setGetAutoShare( void ); +extern HB_EXPORT BOOL hb_setGetBell( void ); +extern HB_EXPORT BOOL hb_setGetCancel( void ); +extern HB_EXPORT char * hb_setGetColor( void ); +extern HB_EXPORT BOOL hb_setGetConfirm( void ); +extern HB_EXPORT BOOL hb_setGetConsole( void ); +extern HB_EXPORT const char * hb_setGetDateFormat( void ); +extern HB_EXPORT const char * hb_setGetTimeFormat( void ); +extern HB_EXPORT BOOL hb_setGetDebug( void ); +extern HB_EXPORT int hb_setGetDecimals( void ); +extern HB_EXPORT const char * hb_setGetDefault( void ); +extern HB_EXPORT BOOL hb_setGetDeleted( void ); +extern HB_EXPORT const char * hb_setGetDelimChars( void ); +extern HB_EXPORT BOOL hb_setGetDelimiters( void ); +extern HB_EXPORT const char * hb_setGetDevice( void ); +extern HB_EXPORT BOOL hb_setGetEOF( void ); +extern HB_EXPORT int hb_setGetEpoch( void ); +extern HB_EXPORT BOOL hb_setGetEscape( void ); +extern HB_EXPORT int hb_setGetEventMask( void ); +extern HB_EXPORT BOOL hb_setGetExact( void ); +extern HB_EXPORT BOOL hb_setGetExclusive( void ); +extern HB_EXPORT BOOL hb_setGetExit( void ); +extern HB_EXPORT BOOL hb_setGetExtra( void ); +extern HB_EXPORT const char * hb_setGetExtraFile( void ); +extern HB_EXPORT BOOL hb_setGetFixed( void ); +extern HB_EXPORT BOOL hb_setGetIdleRepeat( void ); +extern HB_EXPORT BOOL hb_setGetInsert( void ); +extern HB_EXPORT BOOL hb_setGetIntensity( void ); +extern HB_EXPORT const char * hb_setGetPath( void ); +extern HB_EXPORT int hb_setGetMargin( void ); +extern HB_EXPORT int hb_setGetMBlockSize( void ); +extern HB_EXPORT BOOL hb_setGetMCenter( void ); +extern HB_EXPORT int hb_setGetMessage( void ); +extern HB_EXPORT const char * hb_setGetMFileExt( void ); +extern HB_EXPORT BOOL hb_setGetOptimize( void ); +extern HB_EXPORT BOOL hb_setGetPrinter( void ); +extern HB_EXPORT const char * hb_setGetPrintFile( void ); +extern HB_EXPORT BOOL hb_setGetScoreBoard( void ); +extern HB_EXPORT BOOL hb_setGetScrollBreak( void ); +extern HB_EXPORT BOOL hb_setGetSoftSeek( void ); +extern HB_EXPORT BOOL hb_setGetStrictRead( void ); +extern HB_EXPORT int hb_setGetTypeAhead( void ); +extern HB_EXPORT BOOL hb_setGetUnique( void ); +extern HB_EXPORT int hb_setGetFileCase( void ); +extern HB_EXPORT int hb_setGetDirCase( void ); +extern HB_EXPORT int hb_setGetDirSeparator( void ); +extern HB_EXPORT int hb_setGetVideoMode( void ); +extern HB_EXPORT BOOL hb_setGetWrap( void ); +extern HB_EXPORT int hb_setGetDBFLockScheme( void ); +extern HB_EXPORT BOOL hb_setGetHardCommit( void ); +extern HB_EXPORT BOOL hb_setGetForceOpt( void ); +extern HB_EXPORT BOOL hb_setGetDefExtension( void ); +extern HB_EXPORT const char * hb_setGetEOL( void ); +extern HB_EXPORT BOOL hb_setGetTrimFileName( void ); +extern HB_EXPORT const char * hb_setGetHBOUTLOG( void ); +extern HB_EXPORT const char * hb_setGetHBOUTLOGINFO( void ); +extern HB_EXPORT const char * hb_setGetOSCODEPAGE( void ); HB_EXTERN_END diff --git a/harbour/include/hbstack.h b/harbour/include/hbstack.h index e69f421217..382eb62a55 100644 --- a/harbour/include/hbstack.h +++ b/harbour/include/hbstack.h @@ -183,7 +183,7 @@ typedef struct int iDynH; /* number of dynamic symbol handles */ void * pStackLst; /* this stack entry in stack linked list */ HB_IOERRORS IOErrors; /* MT safe buffer for IO errors */ - BYTE * byDirBuffer; /* MT safe buffer for hb_fsCurDir() results */ + char * pDirBuffer; /* MT safe buffer for hb_fsCurDir() results */ void * allocator; /* memory manager global struct pointer */ #endif } HB_STACK, * PHB_STACK; @@ -300,7 +300,7 @@ extern void * hb_stackGetTSD( PHB_TSD pTSD ); extern void * hb_stackTestTSD( PHB_TSD pTSD ); extern void hb_stackReleaseTSD( PHB_TSD pTSD ); -extern BYTE * hb_stackDirBuffer( void ); +extern char * hb_stackDirBuffer( void ); extern PHB_IOERRORS hb_stackIOErrors( void ); extern void * hb_stackGetGT( void ); extern void hb_stackSetGT( void * ); diff --git a/harbour/include/hbsxfunc.h b/harbour/include/hbsxfunc.h index 29f09e7e89..beca809559 100644 --- a/harbour/include/hbsxfunc.h +++ b/harbour/include/hbsxfunc.h @@ -63,7 +63,7 @@ HB_EXTERN_BEGIN char * hb_sxDtoP( char * pDate, LONG lJulian ); -LONG hb_sxPtoD( char * pDate ); +LONG hb_sxPtoD( const char * pDate ); void hb_sxEnCrypt( BYTE * pSrc, BYTE * pDst, BYTE * pKeyVal, ULONG ulLen ); void hb_sxDeCrypt( BYTE * pSrc, BYTE * pDst, BYTE * pKeyVal, ULONG ulLen ); diff --git a/harbour/include/hbvm.h b/harbour/include/hbvm.h index 6776af7dbb..1170e781bc 100644 --- a/harbour/include/hbvm.h +++ b/harbour/include/hbvm.h @@ -95,20 +95,20 @@ extern HB_EXPORT PHB_SYMB hb_vmProcessDynLibSymbols( PHB_SYMB pSymbols, USHORT u ULONG ulID; /* module unique identifier */ } HB_SYMBOLS, * PHB_SYMBOLS; /* structure to keep track of all modules symbol tables */ - extern PHB_SYMBOLS hb_vmRegisterSymbols( PHB_SYMB pModuleSymbols, USHORT uiSymbols, const char * szModuleName, ULONG ulID, BOOL fDynLib, BOOL fClone ); - extern BOOL hb_vmLockModuleSymbols( void ); - extern void hb_vmUnlockModuleSymbols( void ); - extern void hb_vmFreeSymbols( PHB_SYMBOLS pSymbols ); - extern void hb_vmBeginSymbolGroup( void * hDynLib, BOOL fClone ); - extern void hb_vmInitSymbolGroup( void * hNewDynLib, int argc, char * argv[] ); - extern void hb_vmExitSymbolGroup( void * hDynLib ); - extern char * hb_vmFindModuleSymbolName( PHB_SYMB pSym ); - extern BOOL hb_vmFindModuleSymbols( PHB_SYMB pSym, PHB_SYMB * pSymbols, USHORT * puiSymbols ); - extern PHB_SYMB hb_vmGetRealFuncSym( PHB_SYMB pSym ); - extern void hb_vmSetFunction( PHB_SYMB pOldSym, PHB_SYMB pNewSym ); + extern PHB_SYMBOLS hb_vmRegisterSymbols( PHB_SYMB pModuleSymbols, USHORT uiSymbols, const char * szModuleName, ULONG ulID, BOOL fDynLib, BOOL fClone ); + extern BOOL hb_vmLockModuleSymbols( void ); + extern void hb_vmUnlockModuleSymbols( void ); + extern void hb_vmFreeSymbols( PHB_SYMBOLS pSymbols ); + extern void hb_vmBeginSymbolGroup( void * hDynLib, BOOL fClone ); + extern void hb_vmInitSymbolGroup( void * hNewDynLib, int argc, const char * argv[] ); + extern void hb_vmExitSymbolGroup( void * hDynLib ); + extern const char * hb_vmFindModuleSymbolName( PHB_SYMB pSym ); + extern BOOL hb_vmFindModuleSymbols( PHB_SYMB pSym, PHB_SYMB * pSymbols, USHORT * puiSymbols ); + extern PHB_SYMB hb_vmGetRealFuncSym( PHB_SYMB pSym ); + extern void hb_vmSetFunction( PHB_SYMB pOldSym, PHB_SYMB pNewSym ); - extern void hb_vmEnumRelease( PHB_ITEM pBase, PHB_ITEM pValue ); - extern BOOL hb_vmMsgReference( PHB_ITEM pObject, PHB_DYNS pMessage, PHB_DYNS pAccMsg ); /* create extended message reference */ + extern void hb_vmEnumRelease( PHB_ITEM pBase, PHB_ITEM pValue ); + extern BOOL hb_vmMsgReference( PHB_ITEM pObject, PHB_DYNS pMessage, PHB_DYNS pAccMsg ); /* create extended message reference */ #endif extern void hb_vmSetExceptionHandler( void ); diff --git a/harbour/source/common/hbfopen.c b/harbour/source/common/hbfopen.c index 5a6a938a97..5b2eb3e8cb 100644 --- a/harbour/source/common/hbfopen.c +++ b/harbour/source/common/hbfopen.c @@ -54,13 +54,13 @@ FILE * hb_fopen( const char *path, const char *mode ) { - BOOL fFree; - char * pszFile = ( char * ) hb_fsNameConv( ( BYTE * ) path, &fFree ); + char * pszFree = NULL; + FILE * file; - FILE * file = fopen( pszFile, mode ); - - if( fFree ) - hb_xfree( pszFile ); + path = hb_fsNameConv( path, &pszFree ); + file = fopen( path, mode ); + if( pszFree ) + hb_xfree( pszFree ); return file; } diff --git a/harbour/source/common/hbfsapi.c b/harbour/source/common/hbfsapi.c index 4718b1c60d..8d425a9b0f 100644 --- a/harbour/source/common/hbfsapi.c +++ b/harbour/source/common/hbfsapi.c @@ -290,14 +290,14 @@ char * hb_fsFNameMerge( char * pszFileName, PHB_FNAME pFileName ) BOOL hb_fsNameExists( const char * pszFileName ) { BOOL fExist; - BOOL fFree; + char * pszFree = NULL; HB_TRACE(HB_TR_DEBUG, ("hb_fsNameExists(%p)", pszFileName)); if( pszFileName == NULL ) return FALSE; - pszFileName = ( char * ) hb_fsNameConv( ( BYTE * ) pszFileName, &fFree ); + pszFileName = hb_fsNameConv( pszFileName, &pszFree ); #if defined( HB_OS_DOS ) { @@ -332,8 +332,8 @@ BOOL hb_fsNameExists( const char * pszFileName ) } #endif - if( fFree ) - hb_xfree( ( void * ) pszFileName ); + if( pszFree ) + hb_xfree( pszFree ); return fExist; } @@ -341,14 +341,14 @@ BOOL hb_fsNameExists( const char * pszFileName ) BOOL hb_fsFileExists( const char * pszFileName ) { BOOL fExist; - BOOL fFree; + char * pszFree = NULL; HB_TRACE(HB_TR_DEBUG, ("hb_fsFileExists(%p)", pszFileName)); if( pszFileName == NULL ) return FALSE; - pszFileName = ( char * ) hb_fsNameConv( ( BYTE * ) pszFileName, &fFree ); + pszFileName = hb_fsNameConv( pszFileName, &pszFree ); #if defined( HB_OS_DOS ) { @@ -392,8 +392,8 @@ BOOL hb_fsFileExists( const char * pszFileName ) } #endif - if( fFree ) - hb_xfree( ( void * ) pszFileName ); + if( pszFree ) + hb_xfree( ( void * ) pszFree ); return fExist; } @@ -401,14 +401,14 @@ BOOL hb_fsFileExists( const char * pszFileName ) BOOL hb_fsDirExists( const char * pszDirName ) { BOOL fExist; - BOOL fFree; + char * pszFree = NULL; HB_TRACE(HB_TR_DEBUG, ("hb_fsDirExists(%p)", pszDirName)); if( pszDirName == NULL ) return FALSE; - pszDirName = ( char * ) hb_fsNameConv( ( BYTE * ) pszDirName, &fFree ); + pszDirName = hb_fsNameConv( pszDirName, &pszFree ); #if defined( HB_OS_DOS ) { @@ -451,8 +451,8 @@ BOOL hb_fsDirExists( const char * pszDirName ) } #endif - if( fFree ) - hb_xfree( ( void * ) pszDirName ); + if( pszFree ) + hb_xfree( ( void * ) pszFree ); return fExist; } diff --git a/harbour/source/compiler/cmdcheck.c b/harbour/source/compiler/cmdcheck.c index 3cf6910af5..88704365a3 100644 --- a/harbour/source/compiler/cmdcheck.c +++ b/harbour/source/compiler/cmdcheck.c @@ -652,7 +652,7 @@ static void hb_compChkEnvironVar( HB_COMP_DECL, const char *szSwitch ) } } -void hb_compChkCompilerSwitch( HB_COMP_DECL, int iArg, char * const Args[] ) +void hb_compChkCompilerSwitch( HB_COMP_DECL, int iArg, const char * const Args[] ) { /* If iArg is passed check the command line options */ if( iArg ) @@ -1089,7 +1089,7 @@ static void hb_compChkDefineSwitch( HB_COMP_DECL, const char *pszSwitch ) } } -void hb_compChkDefines( HB_COMP_DECL, int iArg, char * const Args[] ) +void hb_compChkDefines( HB_COMP_DECL, int iArg, const char * const Args[] ) { /* Check the environment variables */ { diff --git a/harbour/source/compiler/genc.c b/harbour/source/compiler/genc.c index 45dbd77fc9..803b1271e1 100644 --- a/harbour/source/compiler/genc.c +++ b/harbour/source/compiler/genc.c @@ -522,7 +522,7 @@ static void hb_compGenCFunc( FILE * yyc, const char *cDecor, const char *szName, } } -static void hb_compGenCByteStr( FILE * yyc, BYTE * pText, ULONG ulLen ) +static void hb_compGenCByteStr( FILE * yyc, const BYTE * pText, ULONG ulLen ) { ULONG ulPos; for( ulPos = 0; ulPos < ulLen; ulPos++ ) diff --git a/harbour/source/compiler/gencc.c b/harbour/source/compiler/gencc.c index b7b83ec43f..6c2621495e 100644 --- a/harbour/source/compiler/gencc.c +++ b/harbour/source/compiler/gencc.c @@ -70,7 +70,7 @@ typedef HB_GENC_FUNC_ * HB_GENC_FUNC_PTR; fprintf( cargo->yyc, "\t#error: \"" s "\"\n" ); \ } while( 0 ) -void hb_compGenCString( FILE * yyc, BYTE * pText, ULONG ulLen ) +void hb_compGenCString( FILE * yyc, const BYTE * pText, ULONG ulLen ) { ULONG ulPos; @@ -1727,7 +1727,7 @@ static HB_GENC_FUNC( hb_p_switch ) { fprintf( cargo->yyc, "\t{\n\t\tPHB_ITEM pSwitch;\n\t\tHB_TYPE type;\n" ); if( fStr ) - fprintf( cargo->yyc, "\t\tchar * pszText;\n\t\tULONG ulLen;\n" ); + fprintf( cargo->yyc, "\t\tconst char * pszText;\n\t\tULONG ulLen;\n" ); if( fNum ) fprintf( cargo->yyc, "\t\tlong lVal;\n" ); fprintf( cargo->yyc, "\t\tif( hb_xvmSwitchGet( &pSwitch ) ) break;\n" diff --git a/harbour/source/compiler/hbcmplib.c b/harbour/source/compiler/hbcmplib.c index 3518540d90..b553513507 100644 --- a/harbour/source/compiler/hbcmplib.c +++ b/harbour/source/compiler/hbcmplib.c @@ -54,12 +54,12 @@ #include "hbcomp.h" static void hb_compGenArgList( int iFirst, int iLast, - int * pArgC, char *** pArgV ) + int * pArgC, const char *** pArgV ) { PHB_ITEM pParam; ULONG ul, ulLen; int argc = 1, i; - char ** argv; + const char ** argv; for( i = iFirst; i <= iLast; ++i ) { @@ -81,7 +81,7 @@ static void hb_compGenArgList( int iFirst, int iLast, } } - argv = ( char ** ) hb_xgrab( sizeof( char * ) * ( argc + 1 ) ); + argv = ( const char ** ) hb_xgrab( sizeof( char * ) * ( argc + 1 ) ); argc = 0; for( i = iFirst; i <= iLast; ++i ) { @@ -110,7 +110,7 @@ static void hb_compGenArgList( int iFirst, int iLast, HB_FUNC( HB_COMPILE ) { int argc; - char ** argv; + const char ** argv; hb_compGenArgList( 1, hb_pcount(), &argc, &argv ); @@ -121,7 +121,7 @@ HB_FUNC( HB_COMPILE ) HB_FUNC( HB_COMPILEBUF ) { int iResult, argc; - char ** argv; + const char ** argv; BYTE * pBuffer; ULONG ulLen; @@ -135,7 +135,7 @@ HB_FUNC( HB_COMPILEBUF ) HB_FUNC( HB_COMPILEFROMBUF ) { int iResult, argc; - char ** argv; + const char ** argv; const char * szSource; BYTE * pBuffer; ULONG ulLen; diff --git a/harbour/source/compiler/hbmain.c b/harbour/source/compiler/hbmain.c index f3b750d700..28f685a2ef 100644 --- a/harbour/source/compiler/hbmain.c +++ b/harbour/source/compiler/hbmain.c @@ -69,8 +69,8 @@ static BOOL hb_compRegisterFunc( HB_COMP_DECL, const char * szFunName, HB_SYMBOL /* ************************************************************************* */ -int hb_compMain( int argc, char * const argv[], BYTE ** pBufPtr, ULONG * pulSize, - const char * szSource ) +int hb_compMain( int argc, const char * const argv[], + BYTE ** pBufPtr, ULONG * pulSize, const char * szSource ) { HB_COMP_DECL; int iStatus = EXIT_SUCCESS; diff --git a/harbour/source/compiler/hbpcode.c b/harbour/source/compiler/hbpcode.c index 0bdc24cbed..5b52dd36ad 100644 --- a/harbour/source/compiler/hbpcode.c +++ b/harbour/source/compiler/hbpcode.c @@ -671,7 +671,7 @@ void hb_compGenPCode4( BYTE byte1, BYTE byte2, BYTE byte3, BYTE byte4, HB_COMP_D pFunc->pCode[ pFunc->lPCodePos++ ] = byte4; } -void hb_compGenPCodeN( BYTE * pBuffer, ULONG ulSize, HB_COMP_DECL ) +void hb_compGenPCodeN( const BYTE * pBuffer, ULONG ulSize, HB_COMP_DECL ) { PFUNCTION pFunc = HB_COMP_PARAM->functions.pLast; /* get the currently defined Clipper function */ diff --git a/harbour/source/compiler/ppcomp.c b/harbour/source/compiler/ppcomp.c index 11b5f5ac64..11e41b0707 100644 --- a/harbour/source/compiler/ppcomp.c +++ b/harbour/source/compiler/ppcomp.c @@ -273,7 +273,7 @@ static BOOL hb_pp_CompilerSwitch( void * cargo, const char * szSwitch, } -void hb_compInitPP( HB_COMP_DECL, int argc, char * const argv[] ) +void hb_compInitPP( HB_COMP_DECL, int argc, const char * const argv[] ) { HB_TRACE( HB_TR_DEBUG, ( "hb_compInitPP()" ) ); diff --git a/harbour/source/debug/dbgentry.c b/harbour/source/debug/dbgentry.c index abf67cf021..d5bef3ecd4 100644 --- a/harbour/source/debug/dbgentry.c +++ b/harbour/source/debug/dbgentry.c @@ -70,11 +70,6 @@ static BOOL hb_clsSetScope( BOOL fScope ) { return fScope; } #define FILENAME_EQUAL(s1, s2) ( !hb_stricmp( (s1), (s2) ) ) #endif -#define ALLOC hb_xgrab -#define FREE hb_xfree -#define STRDUP hb_strdup -#define STRNDUP( dest, source, len ) ( dest = hb_strndup( (source), (len) ) ) - #define ARRAY_ADD( type, array, length ) \ ( ( ++length == 1 ) ? ( array = ( type * ) hb_xgrab( sizeof( type ) ) ) : \ ( ( array = ( type * ) hb_xrealloc( array, sizeof( type ) * length ) ) + \ @@ -179,19 +174,19 @@ typedef struct static PHB_ITEM hb_dbgActivateBreakArray( HB_DEBUGINFO *info ); static PHB_ITEM hb_dbgActivateModuleArray( HB_DEBUGINFO *info ); static PHB_ITEM hb_dbgActivateVarArray( int nVars, HB_VARINFO *aVars ); -static void hb_dbgAddLocal( HB_DEBUGINFO *info, char *szName, int nIndex, int nFrame ); -static void hb_dbgAddModule( HB_DEBUGINFO *info, char *szName ); -static void hb_dbgAddStack( HB_DEBUGINFO *info, char *szName, int nProcLevel ); -static void hb_dbgAddStatic( HB_DEBUGINFO *info, char *szName, int nIndex, PHB_ITEM pFrame ); -static void hb_dbgAddVar( int *nVars, HB_VARINFO **aVars, char *szName, char cType, int nIndex, int nFrame, PHB_ITEM pFrame ); +static void hb_dbgAddLocal( HB_DEBUGINFO *info, const char *szName, int nIndex, int nFrame ); +static void hb_dbgAddModule( HB_DEBUGINFO *info, const char *szName ); +static void hb_dbgAddStack( HB_DEBUGINFO *info, const char *szName, int nProcLevel ); +static void hb_dbgAddStatic( HB_DEBUGINFO *info, const char *szName, int nIndex, PHB_ITEM pFrame ); +static void hb_dbgAddVar( int *nVars, HB_VARINFO **aVars, const char *szName, char cType, int nIndex, int nFrame, PHB_ITEM pFrame ); static void hb_dbgAddStopLines( HB_DEBUGINFO *info, PHB_ITEM pItem ); static void hb_dbgEndProc( HB_DEBUGINFO *info ); static PHB_ITEM hb_dbgEval( HB_DEBUGINFO *info, HB_WATCHPOINT *watch ); -static PHB_ITEM hb_dbgEvalMacro( char *szExpr, PHB_ITEM pItem ); +static PHB_ITEM hb_dbgEvalMacro( const char *szExpr, PHB_ITEM pItem ); static PHB_ITEM hb_dbgEvalMakeBlock( HB_WATCHPOINT *watch ); static PHB_ITEM hb_dbgEvalResolve( HB_DEBUGINFO *info, HB_WATCHPOINT *watch ); static BOOL hb_dbgIsAltD( void ); -static BOOL hb_dbgIsBreakPoint( HB_DEBUGINFO *info, char *szModule, int nLine ); +static BOOL hb_dbgIsBreakPoint( HB_DEBUGINFO *info, const char *szModule, int nLine ); static BOOL hb_dbgEqual( PHB_ITEM pItem1, PHB_ITEM pItem2 ); static void hb_dbgQuit( HB_DEBUGINFO *info ); static PHB_ITEM hb_dbgVarGet( HB_VARINFO *scope ); @@ -336,7 +331,7 @@ static PHB_ITEM hb_dbgActivateVarArray( int nVars, HB_VARINFO *aVars ) } -void hb_dbgEntry( int nMode, int nLine, char *szName, int nIndex, PHB_ITEM pFrame ) +void hb_dbgEntry( int nMode, int nLine, const char *szName, int nIndex, PHB_ITEM pFrame ) { int i; ULONG nProcLevel; @@ -350,7 +345,7 @@ void hb_dbgEntry( int nMode, int nLine, char *szName, int nIndex, PHB_ITEM pFram { if( !info ) { - info = *infoPtr = ( HB_DEBUGINFO * ) ALLOC( sizeof( HB_DEBUGINFO ) ); + info = *infoPtr = ( HB_DEBUGINFO * ) hb_xgrab( sizeof( HB_DEBUGINFO ) ); memset( info, 0, sizeof( HB_DEBUGINFO ) ); info->bCBTrace = TRUE; } @@ -439,7 +434,7 @@ void hb_dbgEntry( int nMode, int nLine, char *szName, int nIndex, PHB_ITEM pFram if ( info->bToCursor ) { info->bToCursor = FALSE; - FREE( info->szToCursorModule ); + hb_xfree( info->szToCursorModule ); } info->bNextRoutine = FALSE; @@ -458,7 +453,7 @@ void hb_dbgEntry( int nMode, int nLine, char *szName, int nIndex, PHB_ITEM pFram if ( info->bToCursor ) { info->bToCursor = FALSE; - FREE( info->szToCursorModule ); + hb_xfree( info->szToCursorModule ); } info->bNextRoutine = FALSE; info->bGo = FALSE; @@ -478,7 +473,7 @@ void hb_dbgEntry( int nMode, int nLine, char *szName, int nIndex, PHB_ITEM pFram if ( nLine == info->nToCursorLine && FILENAME_EQUAL( pTop->szModule, info->szToCursorModule ) ) { - FREE( info->szToCursorModule ); + hb_xfree( info->szToCursorModule ); info->bToCursor = FALSE; } else @@ -528,7 +523,7 @@ void hb_dbgEntry( int nMode, int nLine, char *szName, int nIndex, PHB_ITEM pFram if( info ) { hb_dbgQuit( info ); - FREE( info ); + hb_xfree( info ); *infoPtr = HB_DBGINFO_DISABLE; } return; @@ -536,9 +531,9 @@ void hb_dbgEntry( int nMode, int nLine, char *szName, int nIndex, PHB_ITEM pFram } -static char * hb_dbgStripModuleName( char * szName ) +static const char * hb_dbgStripModuleName( const char * szName ) { - char * ptr; + const char * ptr; if( ( ptr = strrchr( szName, '/' ) ) != NULL ) { @@ -553,17 +548,17 @@ static char * hb_dbgStripModuleName( char * szName ) } -void hb_dbgAddBreak( void *handle, char *cModule, int nLine, char *szFunction ) +void hb_dbgAddBreak( void *handle, const char *szModule, int nLine, const char *szFunction ) { HB_DEBUGINFO *info = (HB_DEBUGINFO *)handle; HB_BREAKPOINT *pBreak; pBreak = ARRAY_ADD( HB_BREAKPOINT, info->aBreak, info->nBreakPoints ); - pBreak->szModule = STRDUP( cModule ); + pBreak->szModule = hb_strdup( szModule ); pBreak->nLine = nLine; if ( szFunction ) { - pBreak->szFunction = STRDUP( szFunction ); + pBreak->szFunction = hb_strdup( szFunction ); } else { @@ -572,7 +567,7 @@ void hb_dbgAddBreak( void *handle, char *cModule, int nLine, char *szFunction ) } -static void hb_dbgAddLocal( HB_DEBUGINFO *info, char *szName, int nIndex, int nFrame ) +static void hb_dbgAddLocal( HB_DEBUGINFO *info, const char *szName, int nIndex, int nFrame ) { if ( info->bInitGlobals ) { @@ -589,16 +584,16 @@ static void hb_dbgAddLocal( HB_DEBUGINFO *info, char *szName, int nIndex, int nF } -static void hb_dbgAddModule( HB_DEBUGINFO *info, char *szName ) +static void hb_dbgAddModule( HB_DEBUGINFO *info, const char *szName ) { char * szModuleName; - char * szFuncName; + const char * szFuncName; int iLen; szName = hb_dbgStripModuleName( szName ); szFuncName = strrchr( szName, ':' ); iLen = szFuncName ? ( int ) ( szFuncName - szName ) : ( int ) strlen( szName ); - STRNDUP( szModuleName, szName, iLen ); + szModuleName = hb_strndup( szName, iLen ); if( !info->nModules || strcmp( info->aModules[ info->nModules - 1 ].szModule, szModuleName ) ) { @@ -612,16 +607,16 @@ static void hb_dbgAddModule( HB_DEBUGINFO *info, char *szName ) } else { - FREE( szModuleName ); + hb_xfree( szModuleName ); } } -static void hb_dbgAddStack( HB_DEBUGINFO *info, char *szName, int nProcLevel ) +static void hb_dbgAddStack( HB_DEBUGINFO *info, const char *szName, int nProcLevel ) { char szBuff[ HB_SYMBOL_NAME_LEN + HB_SYMBOL_NAME_LEN + 5 ]; HB_CALLSTACKINFO *top; - char *szFunction = strrchr( szName, ':' ); + const char *szFunction = strrchr( szName, ':' ); if ( szFunction ) { @@ -632,29 +627,29 @@ static void hb_dbgAddStack( HB_DEBUGINFO *info, char *szName, int nProcLevel ) { memcpy( szBuff, "(b)", 3 ); hb_strncpy( szBuff + 3, szFunction, sizeof( szBuff ) - 4 ); - top->szFunction = STRDUP( szBuff ); + top->szFunction = hb_strdup( szBuff ); } else { if ( szFunction ) { - top->szFunction = STRDUP( szFunction ); + top->szFunction = hb_strdup( szFunction ); } else { /* We're in an (_INITSTATICSnnnnn) pseudo-function */ hb_procinfo( 0, szBuff, NULL, NULL ); - top->szFunction = STRDUP( szBuff ); + top->szFunction = hb_strdup( szBuff ); } } szName = hb_dbgStripModuleName( szName ); if ( szFunction ) { - STRNDUP( top->szModule, szName, szFunction - szName - 1 ); + top->szModule = hb_strndup( szName, szFunction - szName - 1 ); } else { - top->szModule = STRDUP( szName ); + top->szModule = hb_strdup( szName ); } top->nProcLevel = nProcLevel; top->nLine = 0; @@ -663,7 +658,7 @@ static void hb_dbgAddStack( HB_DEBUGINFO *info, char *szName, int nProcLevel ) } -static void hb_dbgAddStatic( HB_DEBUGINFO *info, char *szName, int nIndex, PHB_ITEM pFrame ) +static void hb_dbgAddStatic( HB_DEBUGINFO *info, const char *szName, int nIndex, PHB_ITEM pFrame ) { if ( info->bInitGlobals ) { @@ -705,7 +700,7 @@ static void hb_dbgAddStopLines( HB_DEBUGINFO *info, PHB_ITEM pItem ) for ( i = 1; i <= nItemLen; i++ ) { PHB_ITEM pEntry = hb_arrayGetItemPtr( pItem, i ); - char *szModule = hb_arrayGetCPtr( pEntry, 1 ); + const char *szModule = hb_arrayGetCPtr( pEntry, 1 ); BOOL bFound = FALSE; szModule = hb_dbgStripModuleName( szModule ); @@ -722,8 +717,8 @@ static void hb_dbgAddStopLines( HB_DEBUGINFO *info, PHB_ITEM pItem ) int nNewLen = hb_arrayGetCLen( pEntry, 3 ); int nMin = HB_MIN( nNewMin, nOrigMin ); int nMax = HB_MAX( nNewMin + nNewLen * 8, nOrigMin + nOrigLen * 8 ); - char *pOrigBuffer = hb_arrayGetCPtr( pLines, 3 ); - char *pNewBuffer = hb_arrayGetCPtr( pEntry, 3 ); + const char *pOrigBuffer = hb_arrayGetCPtr( pLines, 3 ); + const char *pNewBuffer = hb_arrayGetCPtr( pEntry, 3 ); int nLen = ( nMax + 1 - nMin + 7 ) / 8 + 1; int k; char *pBuffer = (char *) hb_xgrab( nLen ); @@ -752,27 +747,28 @@ static void hb_dbgAddStopLines( HB_DEBUGINFO *info, PHB_ITEM pItem ) for ( i = 1; i <= nLinesLen; i++ ) { PHB_ITEM pEntry = hb_arrayGetItemPtr( info->pStopLines, i ); - char *szModule = hb_arrayGetCPtr( pEntry, 1 ); + const char *szModule = hb_arrayGetCPtr( pEntry, 1 ); if( szModule ) { - char *szName = hb_dbgStripModuleName( szModule ); + const char *szName = hb_dbgStripModuleName( szModule ); if( szName != szModule ) { - hb_arraySetC( pEntry, 1, szName ); + hb_arraySetCPtr( pEntry, 1, hb_strdup( szName ), strlen( szName ) ); } } } } -static void hb_dbgAddVar( int *nVars, HB_VARINFO **aVars, char *szName, char cType, int nIndex, int nFrame, PHB_ITEM pFrame ) +static void hb_dbgAddVar( int *nVars, HB_VARINFO **aVars, const char *szName, char cType, int nIndex, int nFrame, PHB_ITEM pFrame ) { HB_VARINFO *var; var = ARRAY_ADD( HB_VARINFO, *aVars, *nVars ); - var->szName = szName; + /* TODO/TOFIX: value should be duplicated here and then released */ + var->szName = ( char * ) szName; var->cType = cType; var->nIndex = nIndex; if( cType == 'S' ) @@ -782,13 +778,13 @@ static void hb_dbgAddVar( int *nVars, HB_VARINFO **aVars, char *szName, char cTy } -void hb_dbgAddWatch( void *handle, char *szExpr, BOOL bTrace ) +void hb_dbgAddWatch( void *handle, const char *szExpr, BOOL bTrace ) { HB_DEBUGINFO *info = (HB_DEBUGINFO *)handle; HB_WATCHPOINT *pWatch; pWatch = ARRAY_ADD( HB_WATCHPOINT, info->aWatch, info->nWatchPoints ); - pWatch->szExpr = STRDUP( szExpr ); + pWatch->szExpr = hb_strdup( szExpr ); pWatch->pBlock = NULL; pWatch->nVars = 0; @@ -804,7 +800,7 @@ void hb_dbgAddWatch( void *handle, char *szExpr, BOOL bTrace ) static void hb_dbgClearWatch( HB_WATCHPOINT *pWatch ) { - FREE( pWatch->szExpr ); + hb_xfree( pWatch->szExpr ); if ( pWatch->pBlock ) { hb_itemRelease( pWatch->pBlock ); @@ -815,9 +811,9 @@ static void hb_dbgClearWatch( HB_WATCHPOINT *pWatch ) for (i = 0; i < pWatch->nVars; i++) { - FREE( pWatch->aVars[ i ] ); + hb_xfree( pWatch->aVars[ i ] ); } - FREE( pWatch->aVars ); + hb_xfree( pWatch->aVars ); } } @@ -827,10 +823,10 @@ void hb_dbgDelBreak( void *handle, int nBreak ) HB_DEBUGINFO *info = (HB_DEBUGINFO *)handle; HB_BREAKPOINT *pBreak = &info->aBreak[ nBreak ]; - FREE( pBreak->szModule ); + hb_xfree( pBreak->szModule ); if ( pBreak->szFunction ) { - FREE( pBreak->szFunction ); + hb_xfree( pBreak->szFunction ); } ARRAY_DEL( HB_BREAKPOINT, info->aBreak, info->nBreakPoints, nBreak ); } @@ -874,19 +870,19 @@ static void hb_dbgEndProc( HB_DEBUGINFO *info ) return; top = &info->aCallStack[ --info->nCallStackLen ]; - FREE( top->szFunction ); - FREE( top->szModule ); + hb_xfree( top->szFunction ); + hb_xfree( top->szModule ); if ( top->nLocals ) { - FREE( top->aLocals ); + hb_xfree( top->aLocals ); } if ( top->nStatics ) { - FREE( top->aStatics ); + hb_xfree( top->aStatics ); } if ( !info->nCallStackLen ) { - FREE( info->aCallStack ); + hb_xfree( info->aCallStack ); info->aCallStack = NULL; } } @@ -959,19 +955,19 @@ static PHB_ITEM hb_dbgEval( HB_DEBUGINFO *info, HB_WATCHPOINT *watch ) { if ( watch->aScopes[ i ].cType == 'M' ) { - FREE( watch->aScopes[ i ].szName ); + hb_xfree( watch->aScopes[ i ].szName ); } } if ( watch->nVars ) { - FREE( watch->aScopes ); + hb_xfree( watch->aScopes ); } } return xResult; } -static PHB_ITEM hb_dbgEvalMacro( char *szExpr, PHB_ITEM pItem ) +static PHB_ITEM hb_dbgEvalMacro( const char *szExpr, PHB_ITEM pItem ) { PHB_ITEM pStr; const char *type; @@ -1012,17 +1008,17 @@ static int hb_dbgEvalSubstituteVar( HB_WATCHPOINT *watch, char *szWord, int nSta } else { - FREE( szWord ); + hb_xfree( szWord ); } - t = (char *) ALLOC( strlen( watch->szExpr ) - nLen + 9 + 1 ); + t = (char *) hb_xgrab( strlen( watch->szExpr ) - nLen + 9 + 1 ); memmove( t, watch->szExpr, nStart ); memmove( t + nStart, "__dbg[", 6 ); t[ nStart + 6 ] = '0' + ( char ) ( ( j + 1 ) / 10 ); t[ nStart + 7 ] = '0' + ( char ) ( ( j + 1 ) % 10 ); t[ nStart + 8 ] = ']'; hb_strncpy( t + nStart + 9, watch->szExpr + nStart + nLen, strlen( watch->szExpr ) - nLen - nStart ); - FREE( watch->szExpr ); + hb_xfree( watch->szExpr ); watch->szExpr = t; return nStart + 9; } @@ -1053,7 +1049,7 @@ static PHB_ITEM hb_dbgEvalMakeBlock( HB_WATCHPOINT *watch ) c = watch->szExpr[ j ]; } nLen = j - i; - STRNDUP( szWord, watch->szExpr + i, nLen ); + szWord = hb_strndup( watch->szExpr + i, nLen ); i = j; if ( c ) { @@ -1063,7 +1059,7 @@ static PHB_ITEM hb_dbgEvalMakeBlock( HB_WATCHPOINT *watch ) } if ( watch->szExpr[ i ] == '(' ) { - FREE( szWord ); + hb_xfree( szWord ); continue; } if ( watch->szExpr[ i ] == '-' && watch->szExpr[ i + 1 ] == '>' ) @@ -1073,7 +1069,7 @@ static PHB_ITEM hb_dbgEvalMakeBlock( HB_WATCHPOINT *watch ) { i++; } - FREE( szWord ); + hb_xfree( szWord ); continue; } } @@ -1174,7 +1170,7 @@ static PHB_ITEM hb_dbgEvalMakeBlock( HB_WATCHPOINT *watch ) buffsize = 8 + strlen( watch->szExpr ) + 1; - s = ( char * ) ALLOC( buffsize + 1 ); + s = ( char * ) hb_xgrab( buffsize + 1 ); hb_strncpy( s, "{|__dbg|", buffsize ); hb_strncat( s, watch->szExpr, buffsize ); hb_strncat( s, "}", buffsize ); @@ -1185,7 +1181,7 @@ static PHB_ITEM hb_dbgEvalMakeBlock( HB_WATCHPOINT *watch ) hb_itemRelease( pBlock ); pBlock = NULL; } - FREE( s ); + hb_xfree( s ); return pBlock; } @@ -1205,7 +1201,7 @@ static PHB_ITEM hb_dbgEvalResolve( HB_DEBUGINFO *info, HB_WATCHPOINT *watch ) return aVars; } - scopes = (HB_VARINFO *) ALLOC( watch->nVars * sizeof( HB_VARINFO ) ); + scopes = (HB_VARINFO *) hb_xgrab( watch->nVars * sizeof( HB_VARINFO ) ); nProcLevel = hb_dbg_ProcLevel(); for ( i = 0; i < info->nModules; i++ ) @@ -1303,7 +1299,7 @@ static PHB_ITEM hb_dbgEvalResolve( HB_DEBUGINFO *info, HB_WATCHPOINT *watch ) } scopes[ i ].cType = 'M'; - scopes[ i ].szName = STRDUP( name ); + scopes[ i ].szName = hb_strdup( name ); pItem = hb_dbgVarGet( &scopes[ i ] ); if ( pItem ) { @@ -1319,13 +1315,13 @@ static PHB_ITEM hb_dbgEvalResolve( HB_DEBUGINFO *info, HB_WATCHPOINT *watch ) } -PHB_ITEM hb_dbgGetExpressionValue( void *handle, char *expression ) +PHB_ITEM hb_dbgGetExpressionValue( void *handle, const char *expression ) { HB_DEBUGINFO *info = (HB_DEBUGINFO *)handle; PHB_ITEM result; HB_WATCHPOINT point; - point.szExpr = STRDUP( expression ); + point.szExpr = hb_strdup( expression ); point.pBlock = NULL; point.nVars = 0; @@ -1369,7 +1365,7 @@ static BOOL hb_dbgIsAltD( void ) } -static BOOL hb_dbgIsBreakPoint( HB_DEBUGINFO *info, char *szModule, int nLine ) +static BOOL hb_dbgIsBreakPoint( HB_DEBUGINFO *info, const char *szModule, int nLine ) { int i; @@ -1385,7 +1381,7 @@ static BOOL hb_dbgIsBreakPoint( HB_DEBUGINFO *info, char *szModule, int nLine ) } -BOOL hb_dbgIsValidStopLine( void *handle, char *szModule, int nLine ) +BOOL hb_dbgIsValidStopLine( void *handle, const char *szModule, int nLine ) { HB_DEBUGINFO *info = (HB_DEBUGINFO *)handle; int nModules = hb_itemSize( info->pStopLines ); @@ -1435,18 +1431,18 @@ static void hb_dbgQuit( HB_DEBUGINFO *info ) HB_MODULEINFO *module = &info->aModules[ nModules ]; if ( module->nStatics ) { - FREE( module->aStatics ); + hb_xfree( module->aStatics ); } if ( module->szModule ) { - FREE( module->szModule ); + hb_xfree( module->szModule ); } ARRAY_DEL( HB_MODULEINFO, info->aModules, info->nModules, nModules ); } if ( info->bToCursor ) { info->bToCursor = FALSE; - FREE( info->szToCursorModule ); + hb_xfree( info->szToCursorModule ); } } @@ -1491,12 +1487,12 @@ void hb_dbgSetQuit( void *handle ) } -void hb_dbgSetToCursor( void *handle, char *szModule, int nLine ) +void hb_dbgSetToCursor( void *handle, const char *szModule, int nLine ) { HB_DEBUGINFO *info = (HB_DEBUGINFO *)handle; info->bToCursor = TRUE; - info->szToCursorModule = STRDUP( szModule ); + info->szToCursorModule = hb_strdup( szModule ); info->nToCursorLine = nLine; } @@ -1510,14 +1506,14 @@ void hb_dbgSetTrace( void *handle ) } -void hb_dbgSetWatch( void *handle, int nWatch, char *szExpr, BOOL bTrace ) +void hb_dbgSetWatch( void *handle, int nWatch, const char *szExpr, BOOL bTrace ) { HB_DEBUGINFO *info = (HB_DEBUGINFO *)handle; HB_WATCHPOINT *pWatch = &info->aWatch[ nWatch ]; int i; hb_dbgClearWatch( pWatch ); - pWatch->szExpr = STRDUP( szExpr ); + pWatch->szExpr = hb_strdup( szExpr ); pWatch->pBlock = NULL; for ( i = 0; i < info->nTracePoints; i++ ) { diff --git a/harbour/source/main/harbour.c b/harbour/source/main/harbour.c index fd3c13b116..dd82cf5936 100644 --- a/harbour/source/main/harbour.c +++ b/harbour/source/main/harbour.c @@ -349,9 +349,9 @@ void hb_conOutErr( const char * pStr, ULONG ulLen ) fprintf( stderr, "%.*s", ( int ) ulLen, pStr ); } -char * hb_conNewLine( void ) +const char * hb_conNewLine( void ) { - return ( char * ) "\n"; + return "\n"; } static int s_iFileCase = HB_SET_CASE_MIXED; @@ -359,7 +359,7 @@ static int s_iDirCase = HB_SET_CASE_MIXED; static BOOL s_fFnTrim = FALSE; static char s_cDirSep = HB_OS_PATH_DELIM_CHR; -BYTE * hb_fsNameConv( BYTE * szFileName, BOOL * pfFree ) +const char * hb_fsNameConv( const char * szFileName, char ** pszFree ) { if( s_fFnTrim || s_cDirSep != HB_OS_PATH_DELIM_CHR || s_iFileCase != HB_SET_CASE_MIXED || s_iDirCase != HB_SET_CASE_MIXED ) @@ -367,17 +367,15 @@ BYTE * hb_fsNameConv( BYTE * szFileName, BOOL * pfFree ) PHB_FNAME pFileName; ULONG ulLen; - if( pfFree ) + if( pszFree ) { - BYTE * szNew = ( BYTE * ) hb_xgrab( HB_PATH_MAX ); - hb_strncpy( ( char * ) szNew, ( char * ) szFileName, HB_PATH_MAX - 1 ); - szFileName = szNew; - *pfFree = TRUE; + szFileName = *pszFree = hb_strncpy( ( char * ) hb_xgrab( HB_PATH_MAX ), + szFileName, HB_PATH_MAX - 1 ); } if( s_cDirSep != HB_OS_PATH_DELIM_CHR ) { - BYTE *p = szFileName; + char *p = ( char * ) szFileName; while( *p ) { if( *p == s_cDirSep ) @@ -386,7 +384,7 @@ BYTE * hb_fsNameConv( BYTE * szFileName, BOOL * pfFree ) } } - pFileName = hb_fsFNameSplit( ( char * ) szFileName ); + pFileName = hb_fsFNameSplit( szFileName ); /* strip trailing and leading spaces */ if( s_fFnTrim ) @@ -445,8 +443,8 @@ BYTE * hb_fsNameConv( BYTE * szFileName, BOOL * pfFree ) hb_fsFNameMerge( ( char * ) szFileName, pFileName ); hb_xfree( pFileName ); } - else if( pfFree ) - *pfFree = FALSE; + else if( pszFree ) + *pszFree = NULL; return szFileName; } @@ -636,7 +634,7 @@ int main( int argc, char * argv[] ) hb_compChkFileSwitches( argc, argv ); - iResult = hb_compMain( argc, argv, NULL, NULL, NULL ); + iResult = hb_compMain( argc, ( const char * const* ) argv, NULL, NULL, NULL ); hb_xexit(); return iResult; diff --git a/harbour/source/pp/hbpp.c b/harbour/source/pp/hbpp.c index 8ec5ea2e9c..c06d189276 100644 --- a/harbour/source/pp/hbpp.c +++ b/harbour/source/pp/hbpp.c @@ -61,7 +61,7 @@ void * hb_xgrab( ULONG ulSize ) { return malloc( ulSize ); } void * hb_xrealloc( void * pMem, ULONG ulSize ) { return realloc( pMem, ulSize ); } void hb_xfree( void * pMem ) { free( pMem ); } -BYTE * hb_fsNameConv( BYTE * szFileName, BOOL * pfFree ) { if( pfFree ) * pfFree = FALSE; return szFileName; } +const char * hb_fsNameConv( const char * szFileName, char ** pszFree ) { if( pszFree ) * pszFree = NULL; return szFileName; } int hb_setGetDirSeparator( void ) { return HB_OS_PATH_DELIM_CHR; } int hb_verSvnID( void ) { return 0; } diff --git a/harbour/source/rdd/dbcmd.c b/harbour/source/rdd/dbcmd.c index ebfaa0d8f6..e594642c05 100644 --- a/harbour/source/rdd/dbcmd.c +++ b/harbour/source/rdd/dbcmd.c @@ -334,7 +334,7 @@ HB_FUNC( DBCOMMITALL ) */ HB_FUNC( DBCREATE ) { - char * szFileName, * szAlias, * szDriver, * szCpId; + const char * szFileName, * szAlias, * szDriver, * szCpId; USHORT uiSize, uiLen; PHB_ITEM pStruct, pFieldDesc, pDelim; BOOL fKeepOpen, fCurrArea; @@ -403,7 +403,7 @@ HB_FUNC( DBCREATE ) */ HB_FUNC( HB_DBCREATETEMP ) { - char * szAlias, * szDriver, * szCpId; + const char * szAlias, * szDriver, * szCpId; USHORT uiSize, uiLen; PHB_ITEM pStruct, pFieldDesc; ULONG ulConnection; @@ -461,7 +461,7 @@ HB_FUNC( HB_DBCREATETEMP ) /* __dbopensdf( cFile, aStruct, cRDD, lKeepOpen, cAlias, cDelimArg, cCodePage, nConnection ) */ HB_FUNC( __DBOPENSDF ) { - char * szFileName, * szAlias, * szDriver, * szCpId; + const char * szFileName, * szAlias, * szDriver, * szCpId; USHORT uiSize, uiLen; PHB_ITEM pStruct, pFieldDesc, pDelim; BOOL fKeepOpen, fCurrArea; @@ -757,7 +757,7 @@ HB_FUNC( DBSEEK ) HB_FUNC( DBSELECTAREA ) { - char * szAlias = hb_parc( 1 ); + const char * szAlias = hb_parc( 1 ); if( szAlias ) { @@ -1191,14 +1191,14 @@ HB_FUNC( ORDCONDSET ) lpdbOrdCondInfo = ( LPDBORDERCONDINFO ) hb_xgrab( sizeof( DBORDERCONDINFO ) ); lpdbOrdCondInfo->abFor = hb_parclen( 1 ) > 0 ? - ( BYTE * ) hb_strdup( hb_parc( 1 ) ) : NULL; + hb_strdup( hb_parc( 1 ) ) : NULL; pItem = hb_param( 2, HB_IT_BLOCK ); lpdbOrdCondInfo->itmCobFor = pItem ? hb_itemNew( pItem ) : NULL; lpdbOrdCondInfo->fAll = ! HB_ISLOG( 3 ) || hb_parl( 3 ); lpdbOrdCondInfo->abWhile = hb_parclen( 17 ) > 0 ? - ( BYTE * ) hb_strdup( hb_parc( 17 ) ) : NULL; + hb_strdup( hb_parc( 17 ) ) : NULL; pItem = hb_param( 4, HB_IT_BLOCK ); lpdbOrdCondInfo->itmCobWhile = pItem ? hb_itemNew( pItem ) : NULL; @@ -1265,8 +1265,8 @@ HB_FUNC( ORDCREATE ) DBCONSTRAINTINFO dbConstrInfo; dbOrderInfo.lpdbOrdCondInfo = pArea->lpdbOrdCondInfo; - dbOrderInfo.abBagName = ( BYTE * ) hb_parcx( 1 ); - dbOrderInfo.atomBagName = ( BYTE * ) hb_parcx( 2 ); + dbOrderInfo.abBagName = hb_parcx( 1 ); + dbOrderInfo.atomBagName = hb_parcx( 2 ); dbOrderInfo.itmOrder = NULL; dbOrderInfo.fUnique = HB_ISLOG( 5 ) ? ( BOOL ) hb_parl( 5 ) : hb_setGetUnique(); dbOrderInfo.abExpr = hb_param( 3, HB_IT_STRING ); @@ -1279,8 +1279,8 @@ HB_FUNC( ORDCREATE ) } dbOrderInfo.itmCobExpr = hb_param( 4, HB_IT_BLOCK ); - dbConstrInfo.abConstrName = ( BYTE * ) hb_parc( 6 ); - dbConstrInfo.abTargetName = ( BYTE * ) hb_parc( 7 ); + dbConstrInfo.abConstrName = hb_parc( 6 ); + dbConstrInfo.abTargetName = hb_parc( 7 ); dbConstrInfo.itmRelationKey = hb_param( 8, HB_IT_ARRAY ); if( dbConstrInfo.abConstrName && dbConstrInfo.abTargetName && dbConstrInfo.itmRelationKey ) { @@ -1640,7 +1640,7 @@ HB_FUNC( SELECT ) } else { - char * szAlias = hb_parc( 1 ); + const char * szAlias = hb_parc( 1 ); int iArea = 0; if( szAlias ) diff --git a/harbour/source/rdd/dbcmd53.c b/harbour/source/rdd/dbcmd53.c index 0f2ef09217..99e4beea99 100644 --- a/harbour/source/rdd/dbcmd53.c +++ b/harbour/source/rdd/dbcmd53.c @@ -455,7 +455,7 @@ HB_FUNC( DBFILEGET ) { USHORT uiFields, uiIndex; PHB_ITEM pMode; - char * szField = hb_parc( 1 ); + const char * szField = hb_parc( 1 ); if( szField ) uiIndex = hb_rddFieldIndex( pArea, szField ); @@ -487,7 +487,7 @@ HB_FUNC( DBFILEPUT ) if( pArea ) { USHORT uiFields, uiIndex; - char * szField = hb_parc( 1 ); + const char * szField = hb_parc( 1 ); if( szField ) uiIndex = hb_rddFieldIndex( pArea, szField ); diff --git a/harbour/source/rdd/dbcmdx.c b/harbour/source/rdd/dbcmdx.c index 05225ffa7c..80aef982cf 100644 --- a/harbour/source/rdd/dbcmdx.c +++ b/harbour/source/rdd/dbcmdx.c @@ -78,7 +78,7 @@ HB_FUNC( ORDWILDSEEK ) if( pArea ) { - char * szPattern = hb_parc( 1 ); + const char * szPattern = hb_parc( 1 ); if( szPattern ) { @@ -91,7 +91,7 @@ HB_FUNC( ORDWILDSEEK ) if( !fCont ) { - char * szKey; + const char * szKey; if( fBack ) errCode = SELF_GOBOTTOM( pArea ); diff --git a/harbour/source/rdd/dbdetach.c b/harbour/source/rdd/dbdetach.c index 0074a79294..609108ddf5 100644 --- a/harbour/source/rdd/dbdetach.c +++ b/harbour/source/rdd/dbdetach.c @@ -71,7 +71,7 @@ HB_FUNC( HB_DBDETACH ) } else if( HB_IS_STRING( pAlias ) ) { - char * szAlias = hb_itemGetCPtr( pAlias ); + const char * szAlias = hb_itemGetCPtr( pAlias ); hb_rddGetAliasNumber( szAlias, &iArea ); if( iArea > 0 ) pArea = ( AREAP ) hb_rddGetWorkAreaPointer( iArea ); @@ -100,7 +100,7 @@ HB_FUNC( HB_DBDETACH ) */ HB_FUNC( HB_DBREQUEST ) { - char * szAlias; + const char * szAlias; PHB_ITEM pCargo; BOOL fNewArea, fWait; AREAP pArea; diff --git a/harbour/source/rdd/dbf1.c b/harbour/source/rdd/dbf1.c index 8e43fe600b..daabc1da1e 100644 --- a/harbour/source/rdd/dbf1.c +++ b/harbour/source/rdd/dbf1.c @@ -206,7 +206,7 @@ static HB_LONG hb_dbfGetRowVer( DBFAREAP pArea, USHORT uiField, HB_LONG * pValue { *pValue = HB_GET_LE_UINT64( dbField.bReserved2 ) + 1; HB_PUT_LE_UINT64( dbField.bReserved2, *pValue ); - hb_fileWriteAt( pArea->pDataFile, ( BYTE * ) &dbField, sizeof( dbField ), + hb_fileWriteAt( pArea->pDataFile, ( const BYTE * ) &dbField, sizeof( dbField ), sizeof( DBFHEADER ) + uiField * sizeof( DBFFIELD ) ); } @@ -230,7 +230,7 @@ static HB_LONG hb_dbfGetNextValue( DBFAREAP pArea, USHORT uiField ) { nValue = HB_GET_LE_UINT32( dbField.bCounter ); HB_PUT_LE_UINT32( dbField.bCounter, nValue + dbField.bStep ); - hb_fileWriteAt( pArea->pDataFile, ( BYTE * ) &dbField, sizeof( dbField ), + hb_fileWriteAt( pArea->pDataFile, ( const BYTE * ) &dbField, sizeof( dbField ), sizeof( DBFHEADER ) + uiField * sizeof( DBFFIELD ) ); } @@ -499,7 +499,7 @@ static BOOL hb_dbfTriggerDo( DBFAREAP pArea, int iEvent, */ static void hb_dbfTriggerSet( DBFAREAP pArea, PHB_ITEM pTrigger ) { - char * szName; + const char * szName; HB_TRACE(HB_TR_DEBUG, ("hb_dbfTriggerSet(%p,%p)", pArea, pTrigger)); @@ -2741,7 +2741,7 @@ static HB_ERRCODE hb_dbfClose( DBFAREAP pArea ) pArea->pDataFile = NULL; if( pArea->fTemporary ) - hb_fsDelete( ( BYTE * ) pArea->szDataFileName ); + hb_fsDelete( pArea->szDataFileName ); } /* Close the memo file */ @@ -2751,7 +2751,7 @@ static HB_ERRCODE hb_dbfClose( DBFAREAP pArea ) pArea->pMemoFile = NULL; if( pArea->fTemporary ) - hb_fsDelete( ( BYTE * ) pArea->szMemoFileName ); + hb_fsDelete( pArea->szMemoFileName ); } pArea->fTemporary = FALSE; @@ -2819,7 +2819,7 @@ static HB_ERRCODE hb_dbfCreate( DBFAREAP pArea, LPDBOPENINFO pCreateInfo ) BYTE * pBuffer; PHB_FNAME pFileName; PHB_ITEM pItem = NULL, pError; - BYTE szFileName[ HB_PATH_MAX ]; + char szFileName[ HB_PATH_MAX ]; HB_TRACE(HB_TR_DEBUG, ("hb_dbfCreate(%p, %p)", pArea, pCreateInfo)); @@ -2827,7 +2827,7 @@ static HB_ERRCODE hb_dbfCreate( DBFAREAP pArea, LPDBOPENINFO pCreateInfo ) if( ! pArea->fTemporary ) { - pFileName = hb_fsFNameSplit( ( char * ) pCreateInfo->abName ); + pFileName = hb_fsFNameSplit( pCreateInfo->abName ); if( ! pFileName->szExtension && hb_setGetDefExtension() ) { @@ -2840,11 +2840,11 @@ static HB_ERRCODE hb_dbfCreate( DBFAREAP pArea, LPDBOPENINFO pCreateInfo ) return HB_FAILURE; } pFileName->szExtension = hb_itemGetCPtr( pItem ); - hb_fsFNameMerge( ( char * ) szFileName, pFileName ); + hb_fsFNameMerge( szFileName, pFileName ); } else { - hb_strncpy( ( char * ) szFileName, ( char * ) pCreateInfo->abName, sizeof( szFileName ) - 1 ); + hb_strncpy( szFileName, pCreateInfo->abName, sizeof( szFileName ) - 1 ); } hb_xfree( pFileName ); } @@ -2898,7 +2898,7 @@ static HB_ERRCODE hb_dbfCreate( DBFAREAP pArea, LPDBOPENINFO pCreateInfo ) hb_errPutGenCode( pError, EG_CREATE ); hb_errPutSubCode( pError, EDBF_DATAWIDTH ); hb_errPutDescription( pError, hb_langDGetErrorDesc( EG_CREATE ) ); - hb_errPutFileName( pError, ( char * ) pCreateInfo->abName ); + hb_errPutFileName( pError, pCreateInfo->abName ); SELF_ERROR( ( AREAP ) pArea, pError ); hb_itemRelease( pError ); pArea->lpdbOpenInfo = NULL; @@ -2926,7 +2926,7 @@ static HB_ERRCODE hb_dbfCreate( DBFAREAP pArea, LPDBOPENINFO pCreateInfo ) hb_errPutGenCode( pError, EG_CREATE ); hb_errPutSubCode( pError, EDBF_CREATE_DBF ); hb_errPutDescription( pError, hb_langDGetErrorDesc( EG_CREATE ) ); - hb_errPutFileName( pError, ( char * ) szFileName ); + hb_errPutFileName( pError, szFileName ); hb_errPutFlags( pError, EF_CANRETRY | EF_CANDEFAULT ); } hb_errPutOsCode( pError, hb_fsError() ); @@ -2948,7 +2948,7 @@ static HB_ERRCODE hb_dbfCreate( DBFAREAP pArea, LPDBOPENINFO pCreateInfo ) } } - pArea->szDataFileName = hb_strdup( ( char * ) szFileName ); + pArea->szDataFileName = hb_strdup( szFileName ); ulSize = ( ULONG ) pArea->uiFieldCount * sizeof( DBFFIELD ) + ( pArea->bTableType == DB_DBF_VFP ? 1 : 2 ); @@ -3171,7 +3171,7 @@ static HB_ERRCODE hb_dbfCreate( DBFAREAP pArea, LPDBOPENINFO pCreateInfo ) hb_errPutGenCode( pError, EG_CREATE ); hb_errPutSubCode( pError, EDBF_DATATYPE ); hb_errPutDescription( pError, hb_langDGetErrorDesc( EG_CREATE ) ); - hb_errPutFileName( pError, ( char * ) pCreateInfo->abName ); + hb_errPutFileName( pError, pCreateInfo->abName ); SELF_ERROR( ( AREAP ) pArea, pError ); hb_itemRelease( pError ); pArea->lpdbOpenInfo = NULL; @@ -3210,7 +3210,7 @@ static HB_ERRCODE hb_dbfCreate( DBFAREAP pArea, LPDBOPENINFO pCreateInfo ) #ifndef HB_CDP_SUPPORT_OFF if( pCreateInfo->cdpId ) { - pArea->cdPage = hb_cdpFind( (char *) pCreateInfo->cdpId ); + pArea->cdPage = hb_cdpFind( pCreateInfo->cdpId ); if( !pArea->cdPage ) pArea->cdPage = hb_vmCDP(); } @@ -3277,9 +3277,9 @@ static HB_ERRCODE hb_dbfCreate( DBFAREAP pArea, LPDBOPENINFO pCreateInfo ) /* Create memo file */ if( pArea->fHasMemo ) { - pFileName = hb_fsFNameSplit( ( char * ) szFileName ); + pFileName = hb_fsFNameSplit( szFileName ); pFileName->szExtension = NULL; - hb_fsFNameMerge( ( char * ) szFileName, pFileName ); + hb_fsFNameMerge( szFileName, pFileName ); hb_xfree( pFileName ); pCreateInfo->abName = szFileName; errCode = SELF_CREATEMEMFILE( ( AREAP ) pArea, pCreateInfo ); @@ -3733,7 +3733,7 @@ static HB_ERRCODE hb_dbfOpen( DBFAREAP pArea, LPDBOPENINFO pOpenInfo ) BYTE * pBuffer; LPDBFFIELD pField; DBFIELDINFO dbFieldInfo; - BYTE szFileName[ HB_PATH_MAX ]; + char szFileName[ HB_PATH_MAX ]; char szAlias[ HB_RDD_MAX_ALIAS_LEN + 1 ]; HB_TRACE(HB_TR_DEBUG, ("hb_dbfOpen(%p, %p)", pArea, pOpenInfo)); @@ -3761,17 +3761,17 @@ static HB_ERRCODE hb_dbfOpen( DBFAREAP pArea, LPDBOPENINFO pOpenInfo ) if( pArea->fTrigger ) { - hb_itemPutC( pItem, ( char * ) pOpenInfo->abName ); + hb_itemPutC( pItem, pOpenInfo->abName ); if( !hb_dbfTriggerDo( pArea, EVENT_PREUSE, 0, pItem ) ) { hb_itemRelease( pItem ); pArea->lpdbOpenInfo = NULL; return HB_FAILURE; } - hb_strncpy( ( char * ) szFileName, hb_itemGetCPtr( pItem ), sizeof( szFileName ) - 1 ); + hb_strncpy( szFileName, hb_itemGetCPtr( pItem ), sizeof( szFileName ) - 1 ); } else - hb_strncpy( ( char * ) szFileName, ( char * ) pOpenInfo->abName, sizeof( szFileName ) - 1 ); + hb_strncpy( szFileName, pOpenInfo->abName, sizeof( szFileName ) - 1 ); if( !pArea->bLockType ) { @@ -3789,7 +3789,7 @@ static HB_ERRCODE hb_dbfOpen( DBFAREAP pArea, LPDBOPENINFO pOpenInfo ) #ifndef HB_CDP_SUPPORT_OFF if( pOpenInfo->cdpId ) { - pArea->cdPage = hb_cdpFind( (char *) pOpenInfo->cdpId ); + pArea->cdPage = hb_cdpFind( pOpenInfo->cdpId ); if( !pArea->cdPage ) pArea->cdPage = hb_vmCDP(); } @@ -3809,7 +3809,7 @@ static HB_ERRCODE hb_dbfOpen( DBFAREAP pArea, LPDBOPENINFO pOpenInfo ) (pArea->fShared ? FO_DENYNONE : FO_EXCLUSIVE); pError = NULL; - pFileName = hb_fsFNameSplit( ( char * ) szFileName ); + pFileName = hb_fsFNameSplit( szFileName ); /* Add default file name extension if necessary */ if( ! pFileName->szExtension && hb_setGetDefExtension() ) { @@ -3822,14 +3822,14 @@ static HB_ERRCODE hb_dbfOpen( DBFAREAP pArea, LPDBOPENINFO pOpenInfo ) return HB_FAILURE; } pFileName->szExtension = hb_itemGetCPtr( pItem ); - hb_fsFNameMerge( ( char * ) szFileName, pFileName ); + hb_fsFNameMerge( szFileName, pFileName ); } /* Create default alias if necessary */ if( !pOpenInfo->atomAlias && pFileName->szName ) { hb_strncpyUpperTrim( szAlias, pFileName->szName, sizeof( szAlias ) - 1 ); - pOpenInfo->atomAlias = ( BYTE * ) szAlias; + pOpenInfo->atomAlias = szAlias; } hb_xfree( pFileName ); @@ -3861,7 +3861,7 @@ static HB_ERRCODE hb_dbfOpen( DBFAREAP pArea, LPDBOPENINFO pOpenInfo ) hb_errPutGenCode( pError, EG_OPEN ); hb_errPutSubCode( pError, EDBF_OPEN_DBF ); hb_errPutDescription( pError, hb_langDGetErrorDesc( EG_OPEN ) ); - hb_errPutFileName( pError, ( char * ) szFileName ); + hb_errPutFileName( pError, szFileName ); hb_errPutFlags( pError, EF_CANRETRY | EF_CANDEFAULT ); } hb_errPutOsCode( pError, hb_fsError() ); @@ -3886,7 +3886,7 @@ static HB_ERRCODE hb_dbfOpen( DBFAREAP pArea, LPDBOPENINFO pOpenInfo ) } /* Allocate only after succesfully open file */ - pArea->szDataFileName = hb_strdup( ( char * ) szFileName ); + pArea->szDataFileName = hb_strdup( szFileName ); /* Read file header and exit if error */ errCode = SELF_READDBHEADER( ( AREAP ) pArea ); @@ -3990,9 +3990,9 @@ static HB_ERRCODE hb_dbfOpen( DBFAREAP pArea, LPDBOPENINFO pOpenInfo ) for( uiCount = 0; uiCount < uiFields + uiSkip; uiCount++ ) { pField = ( LPDBFFIELD ) ( pBuffer + uiCount * sizeof( DBFFIELD ) ); - dbFieldInfo.atomName = pField->bName; - dbFieldInfo.atomName[10] = '\0'; - /* hb_strUpper( (char *) dbFieldInfo.atomName, 11 ); */ + pField->bName[10] = '\0'; + /* hb_strUpper( ( char * ) pField->bName ); */ + dbFieldInfo.atomName = ( const char * ) pField->bName; dbFieldInfo.uiLen = pField->bLen; dbFieldInfo.uiDec = 0; dbFieldInfo.uiTypeExtended = 0; @@ -4231,9 +4231,9 @@ static HB_ERRCODE hb_dbfOpen( DBFAREAP pArea, LPDBOPENINFO pOpenInfo ) /* Open memo file if exists */ if( pArea->fHasMemo ) { - pFileName = hb_fsFNameSplit( ( char * ) szFileName ); + pFileName = hb_fsFNameSplit( szFileName ); pFileName->szExtension = NULL; - hb_fsFNameMerge( ( char * ) szFileName, pFileName ); + hb_fsFNameMerge( szFileName, pFileName ); hb_xfree( pFileName ); pOpenInfo->abName = szFileName; errCode = SELF_OPENMEMFILE( ( AREAP ) pArea, pOpenInfo ); @@ -4960,7 +4960,7 @@ static HB_ERRCODE hb_dbfCreateMemFile( DBFAREAP pArea, LPDBOPENINFO pCreateInfo hb_errPutGenCode( pError, EG_CREATE ); hb_errPutSubCode( pError, EDBF_DATATYPE ); hb_errPutDescription( pError, hb_langDGetErrorDesc( EG_CREATE ) ); - hb_errPutFileName( pError, ( char * ) pCreateInfo->abName ); + hb_errPutFileName( pError, pCreateInfo->abName ); SELF_ERROR( ( AREAP ) pArea, pError ); hb_itemRelease( pError ); } @@ -4971,7 +4971,7 @@ static HB_ERRCODE hb_dbfCreateMemFile( DBFAREAP pArea, LPDBOPENINFO pCreateInfo /* * BLOB2FILE - retrieve memo contents into file */ -static HB_ERRCODE hb_dbfGetValueFile( DBFAREAP pArea, USHORT uiIndex, BYTE * szFile, USHORT uiMode ) +static HB_ERRCODE hb_dbfGetValueFile( DBFAREAP pArea, USHORT uiIndex, const char * szFile, USHORT uiMode ) { USHORT uiError = HB_SUCCESS; LPFIELD pField; @@ -5031,7 +5031,7 @@ static HB_ERRCODE hb_dbfGetValueFile( DBFAREAP pArea, USHORT uiIndex, BYTE * szF if( uiError != EDBF_DATATYPE ) { hb_errPutOsCode( pError, hb_fsError() ); - hb_errPutFileName( pError, ( char * ) szFile ); + hb_errPutFileName( pError, szFile ); } SELF_ERROR( ( AREAP ) pArea, pError ); hb_itemRelease( pError ); @@ -5053,7 +5053,7 @@ static HB_ERRCODE hb_dbfOpenMemFile( DBFAREAP pArea, LPDBOPENINFO pOpenInfo ) hb_errPutGenCode( pError, EG_OPEN ); hb_errPutSubCode( pError, EDBF_OPEN_DBF ); hb_errPutDescription( pError, hb_langDGetErrorDesc( EG_OPEN ) ); - hb_errPutFileName( pError, ( char * ) pOpenInfo->abName ); + hb_errPutFileName( pError, pOpenInfo->abName ); SELF_ERROR( ( AREAP ) pArea, pError ); hb_itemRelease( pError ); return HB_FAILURE; @@ -5062,7 +5062,7 @@ static HB_ERRCODE hb_dbfOpenMemFile( DBFAREAP pArea, LPDBOPENINFO pOpenInfo ) /* * FILE2BLOB - store file contents in MEMO */ -static HB_ERRCODE hb_dbfPutValueFile( DBFAREAP pArea, USHORT uiIndex, BYTE * szFile, USHORT uiMode ) +static HB_ERRCODE hb_dbfPutValueFile( DBFAREAP pArea, USHORT uiIndex, const char * szFile, USHORT uiMode ) { USHORT uiError = HB_SUCCESS, uiRead; LPFIELD pField; @@ -5128,7 +5128,7 @@ static HB_ERRCODE hb_dbfPutValueFile( DBFAREAP pArea, USHORT uiIndex, BYTE * szF if( uiError != EDBF_DATATYPE ) { hb_errPutOsCode( pError, hb_fsError() ); - hb_errPutFileName( pError, ( char * ) szFile ); + hb_errPutFileName( pError, szFile ); } SELF_ERROR( ( AREAP ) pArea, pError ); hb_itemRelease( pError ); @@ -5330,14 +5330,14 @@ static HB_ERRCODE hb_dbfWriteDBHeader( DBFAREAP pArea ) HB_FOFFSET llOffset = ( HB_FOFFSET ) pArea->uiHeaderLen + ( HB_FOFFSET ) pArea->uiRecordLen * ( HB_FOFFSET ) pArea->ulRecCount; - hb_fileWriteAt( pArea->pDataFile, ( BYTE * ) "\032", 1, llOffset ); + hb_fileWriteAt( pArea->pDataFile, ( const BYTE * ) "\032", 1, llOffset ); hb_fileTruncAt( pArea->pDataFile, llOffset + 1 ); } HB_PUT_LE_UINT32( pArea->dbfHeader.ulRecCount, pArea->ulRecCount ); HB_PUT_LE_UINT16( pArea->dbfHeader.uiHeaderLen, pArea->uiHeaderLen ); HB_PUT_LE_UINT16( pArea->dbfHeader.uiRecordLen, pArea->uiRecordLen ); - if( hb_fileWriteAt( pArea->pDataFile, ( BYTE * ) &pArea->dbfHeader, + if( hb_fileWriteAt( pArea->pDataFile, ( const BYTE * ) &pArea->dbfHeader, sizeof( DBFHEADER ), 0 ) == sizeof( DBFHEADER ) ) { errCode = HB_SUCCESS; @@ -5372,7 +5372,8 @@ static HB_ERRCODE hb_dbfWriteDBHeader( DBFAREAP pArea ) static HB_ERRCODE hb_dbfDrop( LPRDDNODE pRDD, PHB_ITEM pItemTable, PHB_ITEM pItemIndex, ULONG ulConnect ) { - char szFileName[ HB_PATH_MAX ], * szFile, * szExt; + char szFileName[ HB_PATH_MAX ]; + const char * szFile, * szExt; PHB_ITEM pFileExt = NULL; PHB_FNAME pFileName; BOOL fTable = FALSE, fResult = FALSE; @@ -5402,9 +5403,9 @@ static HB_ERRCODE hb_dbfDrop( LPRDDNODE pRDD, PHB_ITEM pItemTable, PHB_ITEM pIte hb_xfree( pFileName ); /* Use hb_spFileExists first to locate table which can be in differ path */ - if( hb_spFileExists( ( BYTE * ) szFileName, ( BYTE * ) szFileName ) ) + if( hb_spFileExists( szFileName, szFileName ) ) { - fResult = hb_fsDelete( ( BYTE * ) szFileName ); + fResult = hb_fsDelete( szFileName ); if( fResult && fTable ) { /* @@ -5423,7 +5424,7 @@ static HB_ERRCODE hb_dbfDrop( LPRDDNODE pRDD, PHB_ITEM pItemTable, PHB_ITEM pIte { pFileName->szExtension = szExt; hb_fsFNameMerge( szFileName, pFileName ); - hb_fsDelete( ( BYTE * ) szFileName ); + hb_fsDelete( szFileName ); } } /* @@ -5438,7 +5439,7 @@ static HB_ERRCODE hb_dbfDrop( LPRDDNODE pRDD, PHB_ITEM pItemTable, PHB_ITEM pIte { pFileName->szExtension = szExt; hb_fsFNameMerge( szFileName, pFileName ); - hb_fsDelete( ( BYTE * ) szFileName ); + hb_fsDelete( szFileName ); } } hb_xfree( pFileName ); @@ -5454,7 +5455,8 @@ static HB_ERRCODE hb_dbfDrop( LPRDDNODE pRDD, PHB_ITEM pItemTable, PHB_ITEM pIte static HB_ERRCODE hb_dbfExists( LPRDDNODE pRDD, PHB_ITEM pItemTable, PHB_ITEM pItemIndex, ULONG ulConnect ) { - char szFileName[ HB_PATH_MAX ], * szFile; + char szFileName[ HB_PATH_MAX ]; + const char * szFile; PHB_ITEM pFileExt = NULL; PHB_FNAME pFileName; BOOL fTable = FALSE; @@ -5485,7 +5487,7 @@ static HB_ERRCODE hb_dbfExists( LPRDDNODE pRDD, PHB_ITEM pItemTable, PHB_ITEM pI hb_itemRelease( pFileExt ); } - return hb_spFileExists( ( BYTE * ) szFileName, NULL ) ? HB_SUCCESS : HB_FAILURE; + return hb_spFileExists( szFileName, NULL ) ? HB_SUCCESS : HB_FAILURE; } static void hb_dbfInitTSD( void * Cargo ) @@ -5561,18 +5563,15 @@ static HB_ERRCODE hb_dbfRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnect case RDDI_TABLEEXT: { - char * szNew = hb_itemGetCPtr( pItem ); - - if( szNew[0] == '.' && szNew[1] ) - szNew = hb_strdup( szNew ); - else - szNew = NULL; + const char * szNew = hb_itemGetCPtr( pItem ); + char * szNewVal; + szNewVal = szNew[0] == '.' && szNew[1] ? hb_strdup( szNew ) : NULL; hb_itemPutC( pItem, pData->szTableExt[ 0 ] ? pData->szTableExt : DBF_TABLEEXT ); - if( szNew ) + if( szNewVal ) { - hb_strncpy( pData->szTableExt, szNew, sizeof( pData->szTableExt ) - 1 ); - hb_xfree( szNew ); + hb_strncpy( pData->szTableExt, szNewVal, sizeof( pData->szTableExt ) - 1 ); + hb_xfree( szNewVal ); } break; } diff --git a/harbour/source/rdd/dbfcdx/dbfcdx1.c b/harbour/source/rdd/dbfcdx/dbfcdx1.c index db5c7b892d..0a9e359dc7 100644 --- a/harbour/source/rdd/dbfcdx/dbfcdx1.c +++ b/harbour/source/rdd/dbfcdx/dbfcdx1.c @@ -508,7 +508,7 @@ static LPCDXKEY hb_cdxKeyPut( LPCDXKEY pKey, BYTE * pbVal, USHORT uiLen, ULONG u /* * store string0 value in index key */ -static LPCDXKEY hb_cdxKeyPutC( LPCDXKEY pKey, char * szText, USHORT uiRealLen, ULONG ulRec ) +static LPCDXKEY hb_cdxKeyPutC( LPCDXKEY pKey, const char * szText, USHORT uiRealLen, ULONG ulRec ) { USHORT uiLen; @@ -3740,7 +3740,7 @@ static void hb_cdxTagFree( LPCDXTAG pTag ) * TagHdr = offset of index page where a tag header is stored * if CDX_DUMMYNODE then allocate space ofor a new tag header */ -static LPCDXTAG hb_cdxTagNew( LPCDXINDEX pIndex, char *szTagName, ULONG TagHdr ) +static LPCDXTAG hb_cdxTagNew( LPCDXINDEX pIndex, const char *szTagName, ULONG TagHdr ) { LPCDXTAG pTag; char szName[ CDX_MAXTAGNAMELEN + 1 ]; @@ -4645,10 +4645,10 @@ static void hb_cdxReorderTagList( LPCDXTAG * TagListPtr ) * create new order header, store it and then make an order */ static LPCDXTAG hb_cdxIndexCreateTag( BOOL fStruct, LPCDXINDEX pIndex, - char * szTagName, - char * KeyExp, PHB_ITEM pKeyItem, + const char * szTagName, + const char * szKeyExp, PHB_ITEM pKeyItem, BYTE bType, USHORT uiLen, - char * ForExp, PHB_ITEM pForItem, + const char * szForExp, PHB_ITEM pForItem, BOOL fAscnd, BOOL fUniq, BOOL fNoCase, BOOL fCustom, BOOL fReindex ) { @@ -4662,15 +4662,15 @@ static LPCDXTAG hb_cdxIndexCreateTag( BOOL fStruct, LPCDXINDEX pIndex, if( bType == 'C' ) hb_cdxMakeSortTab( pTag->pIndex->pArea ); - if( KeyExp != NULL ) + if( szKeyExp != NULL ) { - pTag->KeyExpr = hb_strduptrim( KeyExp ); + pTag->KeyExpr = hb_strduptrim( szKeyExp ); pTag->nField = hb_rddFieldExpIndex( ( AREAP ) pTag->pIndex->pArea, pTag->KeyExpr ); } pTag->pKeyItem = pKeyItem; - if( ForExp != NULL ) - pTag->ForExpr = hb_strduptrim( ForExp ); + if( szForExp != NULL ) + pTag->ForExpr = hb_strduptrim( szForExp ); pTag->pForItem = pForItem; pTag->AscendKey = pTag->UsrAscend = fAscnd; @@ -4726,7 +4726,7 @@ static void hb_cdxIndexFreePages( LPCDXPAGE pPage ) /* * remove Tag from Bag */ -static void hb_cdxIndexDelTag( LPCDXINDEX pIndex, char * szTagName ) +static void hb_cdxIndexDelTag( LPCDXINDEX pIndex, const char * szTagName ) { LPCDXTAG *pTagPtr = &pIndex->TagList; @@ -4765,10 +4765,10 @@ static void hb_cdxIndexDelTag( LPCDXINDEX pIndex, char * szTagName ) /* * add tag to order bag */ -static LPCDXTAG hb_cdxIndexAddTag( LPCDXINDEX pIndex, char * szTagName, - char * szKeyExp, PHB_ITEM pKeyItem, +static LPCDXTAG hb_cdxIndexAddTag( LPCDXINDEX pIndex, const char * szTagName, + const char * szKeyExp, PHB_ITEM pKeyItem, BYTE bType, USHORT uiLen, - char * szForExp, PHB_ITEM pForItem, + const char * szForExp, PHB_ITEM pForItem, BOOL fAscend, BOOL fUnique, BOOL fNoCase, BOOL fCustom, BOOL fReindex ) { @@ -4889,10 +4889,7 @@ static void hb_cdxIndexFree( LPCDXINDEX pIndex ) { hb_fileClose( pIndex->pFile ); if( pIndex->fDelete ) - { - hb_fsDelete( ( BYTE * ) ( pIndex->szRealName ? - pIndex->szRealName : pIndex->szFileName ) ); - } + hb_fsDelete( pIndex->szRealName ? pIndex->szRealName : pIndex->szFileName ); } #ifdef HB_CDX_DBGCODE @@ -4966,7 +4963,8 @@ static BOOL hb_cdxIndexLoad( LPCDXINDEX pIndex, char * szBaseName ) /* * create index file name */ -static void hb_cdxCreateFName( CDXAREAP pArea, char * szBagName, BOOL * fProd, +static void hb_cdxCreateFName( CDXAREAP pArea, const char * szBagName, + BOOL * fProd, char * szFileName, char * szBaseName ) { PHB_FNAME pFileName; @@ -5082,7 +5080,7 @@ static void hb_cdxOrdListClear( CDXAREAP pArea, BOOL fAll, LPCDXINDEX pKeepInd ) /* * find order bag by its name */ -static LPCDXINDEX hb_cdxFindBag( CDXAREAP pArea, char * szBagName ) +static LPCDXINDEX hb_cdxFindBag( CDXAREAP pArea, const char * szBagName ) { LPCDXINDEX pIndex; PHB_FNAME pFileName; @@ -5092,7 +5090,7 @@ static LPCDXINDEX hb_cdxFindBag( CDXAREAP pArea, char * szBagName ) szBaseName = hb_strdup( pFileName->szName ? pFileName->szName : "" ); szBasePath = pFileName->szPath ? hb_strdup( pFileName->szPath ) : NULL; szBaseExt = pFileName->szExtension ? hb_strdup( pFileName->szExtension ) : NULL; - hb_strUpper( szBaseName, strlen(szBaseName) ); + hb_strUpper( szBaseName, strlen( szBaseName ) ); pIndex = pArea->lpIndexes; while( pIndex ) @@ -5527,7 +5525,8 @@ static BOOL hb_cdxDBOISkipWild( CDXAREAP pArea, LPCDXTAG pTag, BOOL fForward, PHB_ITEM pWildItm ) { BOOL fFound = FALSE, fFirst = TRUE; - char *szPattern, *szFree = NULL; + const char *szPattern; + char *szFree = NULL; int iFixed = 0, iStop; HB_TRACE(HB_TR_DEBUG, ("hb_cdxDBOISkipWild(%p, %p, %i, %p)", pArea, pTag, fForward, pWildItm)); @@ -5548,7 +5547,7 @@ static BOOL hb_cdxDBOISkipWild( CDXAREAP pArea, LPCDXTAG pTag, BOOL fForward, if( pArea->cdPage != hb_vmCDP() ) { szPattern = szFree = hb_strdup( szPattern ); - hb_cdpTranslate( szPattern, hb_vmCDP(), pArea->cdPage ); + hb_cdpTranslate( szFree, hb_vmCDP(), pArea->cdPage ); } #endif while( iFixed < pTag->uiLen && szPattern[ iFixed ] && @@ -7171,7 +7170,7 @@ static HB_ERRCODE hb_cdxOpen( CDXAREAP pArea, LPDBOPENINFO pOpenInfo ) pArea->fHasTags = FALSE; hb_cdxCreateFName( pArea, NULL, NULL, szFileName, NULL ); - if( hb_spFileExists( ( BYTE * ) szFileName, NULL ) || + if( hb_spFileExists( szFileName, NULL ) || DBFAREA_DATA( pArea )->fStrictStruct ) { DBORDERINFO pOrderInfo; @@ -7311,7 +7310,7 @@ static HB_ERRCODE hb_cdxOrderListAdd( CDXAREAP pArea, LPDBORDERINFO pOrderInfo ) ( pArea->fShared ? FO_DENYNONE : FO_EXCLUSIVE ); do { - pFile = hb_fileExtOpen( ( BYTE * ) szFileName, NULL, uiFlags | + pFile = hb_fileExtOpen( szFileName, NULL, uiFlags | FXO_DEFAULTS | FXO_SHARELOCK | FXO_COPYNAME, NULL, pError ); if( !pFile ) @@ -7743,12 +7742,12 @@ static HB_ERRCODE hb_cdxOrderCreate( CDXAREAP pArea, LPDBORDERCREATEINFO pOrderI { if( fTemporary ) { - pFile = hb_fileCreateTemp( NULL, NULL, FC_NORMAL, ( BYTE * ) szTempFile ); + pFile = hb_fileCreateTemp( NULL, NULL, FC_NORMAL, szTempFile ); fNewFile = TRUE; } else { - pFile = hb_fileExtOpen( ( BYTE * ) szFileName, NULL, FO_READWRITE | + pFile = hb_fileExtOpen( szFileName, NULL, FO_READWRITE | ( fShared ? FO_DENYNONE : FO_EXCLUSIVE ) | ( fNewFile ? FXO_TRUNCATE : FXO_APPEND ) | FXO_DEFAULTS | FXO_SHARELOCK | FXO_COPYNAME, @@ -8041,8 +8040,8 @@ static HB_ERRCODE hb_cdxOrderInfo( CDXAREAP pArea, USHORT uiIndex, LPDBORDERINFO case DBOI_ORDERCOUNT: { LPCDXINDEX pIndex; - char *pszBag = hb_itemGetCLen( pInfo->atomBagName ) > 0 ? - hb_itemGetCPtr( pInfo->atomBagName ) : NULL; + const char *pszBag = hb_itemGetCLen( pInfo->atomBagName ) > 0 ? + hb_itemGetCPtr( pInfo->atomBagName ) : NULL; pIndex = pszBag ? hb_cdxFindBag( pArea, pszBag ) : pArea->lpIndexes; while( pIndex ) { @@ -8166,9 +8165,9 @@ static HB_ERRCODE hb_cdxOrderInfo( CDXAREAP pArea, USHORT uiIndex, LPDBORDERINFO } if( hb_itemGetCLen( pInfo->itmNewVal ) > 0 ) { - char * pForExpr = hb_itemGetCPtr( pInfo->itmNewVal ); + const char * pForExpr = hb_itemGetCPtr( pInfo->itmNewVal ); - if( SELF_COMPILE( ( AREAP ) pArea, ( BYTE *) pForExpr ) == HB_SUCCESS ) + if( SELF_COMPILE( ( AREAP ) pArea, ( BYTE * ) pForExpr ) == HB_SUCCESS ) { PHB_ITEM pForItem = pArea->valResult; pArea->valResult = NULL; @@ -8754,18 +8753,15 @@ static HB_ERRCODE hb_cdxRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnect case RDDI_ORDEREXT: case RDDI_ORDSTRUCTEXT: { - char * szNew = hb_itemGetCPtr( pItem ); - - if( szNew[0] == '.' && szNew[1] ) - szNew = hb_strdup( szNew ); - else - szNew = NULL; + const char * szExt = hb_itemGetCPtr( pItem ); + char * szNewVal; + szNewVal = szExt[0] == '.' && szExt[1] ? hb_strdup( szExt ) : NULL; hb_itemPutC( pItem, pData->szIndexExt[ 0 ] ? pData->szIndexExt : CDX_INDEXEXT ); - if( szNew ) + if( szNewVal ) { - hb_strncpy( pData->szIndexExt, szNew, sizeof( pData->szIndexExt ) - 1 ); - hb_xfree( szNew ); + hb_strncpy( pData->szIndexExt, szNewVal, sizeof( pData->szIndexExt ) - 1 ); + hb_xfree( szNewVal ); } break; } @@ -9005,13 +9001,13 @@ static void hb_cdxSortWritePage( LPCDXSORTINFO pSort ) if( pSort->hTempFile == FS_ERROR ) { - BYTE szName[ HB_PATH_MAX ]; + char szName[ HB_PATH_MAX ]; pSort->hTempFile = hb_fsCreateTemp( NULL, NULL, FC_NORMAL, szName ); if( pSort->hTempFile == FS_ERROR ) { hb_errInternal( 9301, "hb_cdxSortWritePage: Can't create temporary file.", NULL, NULL ); } - pSort->szTempFileName = hb_strdup( ( char * ) szName ); + pSort->szTempFileName = hb_strdup( szName ); } pSort->pSwapPage[ pSort->ulCurPage ].ulKeys = pSort->ulKeys; pSort->pSwapPage[ pSort->ulCurPage ].nOffset = hb_fsSeekLarge( pSort->hTempFile, 0, FS_END ); @@ -9306,7 +9302,7 @@ static void hb_cdxSortFree( LPCDXSORTINFO pSort ) } if( pSort->szTempFileName ) { - hb_fsDelete( (BYTE *) ( pSort->szTempFileName ) ); + hb_fsDelete( pSort->szTempFileName ); hb_xfree( pSort->szTempFileName ); } if( pSort->pKeyPool ) diff --git a/harbour/source/rdd/dbffpt/dbffpt1.c b/harbour/source/rdd/dbffpt/dbffpt1.c index 614e3c1602..97c8a07986 100644 --- a/harbour/source/rdd/dbffpt/dbffpt1.c +++ b/harbour/source/rdd/dbffpt/dbffpt1.c @@ -3426,7 +3426,7 @@ static HB_ERRCODE hb_fptGetVarField( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pI return uiError; } -static HB_ERRCODE hb_fptGetVarFile( FPTAREAP pArea, ULONG ulBlock, BYTE * szFile, USHORT uiMode ) +static HB_ERRCODE hb_fptGetVarFile( FPTAREAP pArea, ULONG ulBlock, const char * szFile, USHORT uiMode ) { USHORT uiError; HB_FHANDLE hFile; @@ -3465,7 +3465,7 @@ static HB_ERRCODE hb_fptGetVarFile( FPTAREAP pArea, ULONG ulBlock, BYTE * szFile return HB_SUCCESS; } -static ULONG hb_fptPutVarFile( FPTAREAP pArea, ULONG ulBlock, BYTE * szFile ) +static ULONG hb_fptPutVarFile( FPTAREAP pArea, ULONG ulBlock, const char * szFile ) { USHORT uiError; HB_FHANDLE hFile; @@ -3855,7 +3855,7 @@ static HB_ERRCODE hb_fptCreateMemFile( FPTAREAP pArea, LPDBOPENINFO pCreateInfo if( pCreateInfo ) { - BYTE szFileName[ HB_PATH_MAX ]; + char szFileName[ HB_PATH_MAX ]; PHB_FNAME pFileName; PHB_ITEM pError = NULL, pItem = NULL; BOOL bRetry; @@ -4034,7 +4034,7 @@ static HB_ERRCODE hb_fptCreateMemFile( FPTAREAP pArea, LPDBOPENINFO pCreateInfo * BLOB2FILE - retrieve memo contents into file * ( DBENTRYP_SVPB ) hb_fptGetValueFile */ -static HB_ERRCODE hb_fptGetValueFile( FPTAREAP pArea, USHORT uiIndex, BYTE * szFile, USHORT uiMode ) +static HB_ERRCODE hb_fptGetValueFile( FPTAREAP pArea, USHORT uiIndex, const char * szFile, USHORT uiMode ) { HB_TRACE(HB_TR_DEBUG, ("hb_fptGetValueFile(%p, %hu, %s, %hu)", pArea, uiIndex, szFile, uiMode)); @@ -4091,7 +4091,7 @@ static HB_ERRCODE hb_fptGetValueFile( FPTAREAP pArea, USHORT uiIndex, BYTE * szF */ static HB_ERRCODE hb_fptOpenMemFile( FPTAREAP pArea, LPDBOPENINFO pOpenInfo ) { - BYTE szFileName[ HB_PATH_MAX ]; + char szFileName[ HB_PATH_MAX ]; PHB_FNAME pFileName; PHB_ITEM pError; USHORT uiFlags; @@ -4224,7 +4224,7 @@ static HB_ERRCODE hb_fptOpenMemFile( FPTAREAP pArea, LPDBOPENINFO pOpenInfo ) * FILE2BLOB - store file contents in MEMO * ( DBENTRYP_SVPB ) hb_fptPutValueFile */ -static HB_ERRCODE hb_fptPutValueFile( FPTAREAP pArea, USHORT uiIndex, BYTE * szFile, USHORT uiMode ) +static HB_ERRCODE hb_fptPutValueFile( FPTAREAP pArea, USHORT uiIndex, const char * szFile, USHORT uiMode ) { LPFIELD pField; @@ -4483,7 +4483,7 @@ static HB_ERRCODE hb_fptDoPack( FPTAREAP pArea, USHORT uiBlockSize, return HB_FAILURE; else if( pArea->fHasMemo && pArea->pMemoFile && pArea->pDataFile ) { - BYTE szFile[ HB_PATH_MAX ]; + char szFile[ HB_PATH_MAX ]; ULONG ulRecNo, ulRecords; LONG lStep = lEvalStep; @@ -4576,7 +4576,7 @@ static HB_ERRCODE hb_fptDoPack( FPTAREAP pArea, USHORT uiBlockSize, } } hb_fileClose( pArea->pMemoTmpFile ); - hb_fsDelete( ( BYTE * ) szFile ); + hb_fsDelete( szFile ); pArea->pMemoTmpFile = NULL; } } @@ -4627,7 +4627,7 @@ static HB_ERRCODE hb_fptPack( FPTAREAP pArea ) if( !pArea->fReadonly && !pArea->fShared && pArea->fHasMemo && pArea->pMemoFile && pArea->pDataFile ) { - BYTE szFile[ HB_PATH_MAX ]; + char szFile[ HB_PATH_MAX ]; if( SELF_GOCOLD( ( AREAP ) pArea ) != HB_SUCCESS ) return HB_FAILURE; @@ -4677,7 +4677,7 @@ static HB_ERRCODE hb_fptPack( FPTAREAP pArea ) } } hb_fileClose( pArea->pMemoTmpFile ); - hb_fsDelete( ( BYTE * ) szFile ); + hb_fsDelete( szFile ); pArea->pMemoTmpFile = NULL; return errCode; } @@ -4708,16 +4708,15 @@ static HB_ERRCODE hb_fptInfo( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) else { LPDBFDATA pData = DBFAREA_DATA( pArea ); - char * szMFileExt; + const char * szExt; if( pData->szMemoExt[ 0 ] ) hb_itemPutC( pItem, pData->szMemoExt ); else if( pArea->bMemoType == DB_MEMO_FPT && - ( szMFileExt = hb_setGetMFileExt() ) != NULL && - *szMFileExt ) - hb_itemPutC( pItem, szMFileExt ); + ( szExt = hb_setGetMFileExt() ) != NULL && *szExt ) + hb_itemPutC( pItem, szExt ); else { - const char * szExt = hb_memoDefaultFileExt( pArea->bMemoType, pArea->rddID ); + szExt = hb_memoDefaultFileExt( pArea->bMemoType, pArea->rddID ); if( !szExt ) szExt = hb_memoDefaultFileExt( pData->bMemoType, pArea->rddID ); hb_itemPutC( pItem, szExt ); @@ -4778,7 +4777,7 @@ static HB_ERRCODE hb_fptInfo( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) if( HB_IS_ARRAY( pItem ) ) { ULONG ulBlock = hb_arrayGetNL( pItem, 1 ); - BYTE * szFile = ( BYTE * ) hb_arrayGetCPtr( pItem, 2 ); + const char * szFile = hb_arrayGetCPtr( pItem, 2 ); if( ulBlock && szFile && *szFile ) errCode = hb_fptGetVarFile( pArea, ulBlock, szFile, @@ -4818,7 +4817,7 @@ static HB_ERRCODE hb_fptInfo( FPTAREAP pArea, USHORT uiIndex, PHB_ITEM pItem ) if( HB_IS_ARRAY( pItem ) ) hb_itemPutNInt( pItem, hb_fptPutVarFile( pArea, hb_arrayGetNL( pItem, 1 ), - ( BYTE * ) hb_arrayGetCPtr( pItem, 2 ) ) ); + hb_arrayGetCPtr( pItem, 2 ) ) ); else hb_itemPutNI( pItem, 0 ); break; @@ -5015,26 +5014,23 @@ static HB_ERRCODE hb_fptRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnect { case RDDI_MEMOEXT: { - char * szNew = hb_itemGetCPtr( pItem ), *szMFileExt; + const char * szExt = hb_itemGetCPtr( pItem ); + char * szNewVal; - if( szNew && szNew[0] == '.' && szNew[1] ) - szNew = hb_strdup( szNew ); - else - szNew = NULL; + szNewVal = szExt[0] == '.' && szExt[1] ? hb_strdup( szExt ) : NULL; if( pData->szMemoExt[ 0 ] ) hb_itemPutC( pItem, pData->szMemoExt ); else if( pData->bMemoType == DB_MEMO_FPT && pRDD->rddID != s_uiRddIdBLOB && - ( szMFileExt = hb_setGetMFileExt() ) != NULL && - *szMFileExt ) - hb_itemPutC( pItem, szMFileExt ); + ( szExt = hb_setGetMFileExt() ) != NULL && *szExt ) + hb_itemPutC( pItem, szExt ); else hb_itemPutC( pItem, hb_memoDefaultFileExt( pData->bMemoType, pRDD->rddID ) ); - if( szNew ) + if( szNewVal ) { - hb_strncpy( pData->szMemoExt, szNew, sizeof( pData->szMemoExt ) - 1 ); - hb_xfree( szNew ); + hb_strncpy( pData->szMemoExt, szNewVal, sizeof( pData->szMemoExt ) - 1 ); + hb_xfree( szNewVal ); } break; } diff --git a/harbour/source/rdd/dbfnsx/dbfnsx1.c b/harbour/source/rdd/dbfnsx/dbfnsx1.c index 04e7500233..97009b9853 100644 --- a/harbour/source/rdd/dbfnsx/dbfnsx1.c +++ b/harbour/source/rdd/dbfnsx/dbfnsx1.c @@ -1981,8 +1981,7 @@ static void hb_nsxIndexFree( LPNSXINDEX pIndex ) hb_fileClose( pIndex->pFile ); if( pIndex->fDelete ) { - hb_fsDelete( ( BYTE * ) ( pIndex->RealName ? - pIndex->RealName : pIndex->IndexName ) ); + hb_fsDelete( pIndex->RealName ? pIndex->RealName : pIndex->IndexName ); } } if( pIndex->IndexName ) @@ -4575,7 +4574,8 @@ static BOOL hb_nsxOrdSkipEval( LPTAGINFO pTag, BOOL fForward, PHB_ITEM pEval ) static BOOL hb_nsxOrdSkipWild( LPTAGINFO pTag, BOOL fForward, PHB_ITEM pWildItm ) { NSXAREAP pArea = pTag->pIndex->pArea; - char *szPattern, *szFree = NULL; + const char *szPattern; + char *szFree = NULL; BOOL fFound = FALSE; int iFixed = 0; @@ -4594,7 +4594,7 @@ static BOOL hb_nsxOrdSkipWild( LPTAGINFO pTag, BOOL fForward, PHB_ITEM pWildItm if( pArea->cdPage != hb_vmCDP() ) { szPattern = szFree = hb_strdup( szPattern ); - hb_cdpTranslate( szPattern, hb_vmCDP(), pArea->cdPage ); + hb_cdpTranslate( szFree, hb_vmCDP(), pArea->cdPage ); } #endif while( iFixed < pTag->KeyLength && szPattern[ iFixed ] && @@ -4691,7 +4691,7 @@ static BOOL hb_nsxOrdSkipWild( LPTAGINFO pTag, BOOL fForward, PHB_ITEM pWildItm pArea->fEof = FALSE; if( szFree ) - hb_xfree( szPattern ); + hb_xfree( szFree ); return fFound; } @@ -5201,13 +5201,13 @@ static void hb_nsxSortWritePage( LPNSXSORTINFO pSort ) if( pSort->hTempFile == FS_ERROR ) { - BYTE szName[ HB_PATH_MAX ]; + char szName[ HB_PATH_MAX ]; pSort->hTempFile = hb_fsCreateTemp( NULL, NULL, FC_NORMAL, szName ); if( pSort->hTempFile == FS_ERROR ) hb_nsxErrorRT( pSort->pTag->pIndex->pArea, EG_CREATE, EDBF_CREATE_TEMP, - ( const char * ) szName, 0, 0, NULL ); + szName, 0, 0, NULL ); else - pSort->szTempFileName = hb_strdup( ( const char * ) szName ); + pSort->szTempFileName = hb_strdup( szName ); } pSort->pSwapPage[ pSort->ulCurPage ].ulKeys = pSort->ulKeys; @@ -5475,7 +5475,7 @@ static void hb_nsxSortFree( LPNSXSORTINFO pSort, BOOL fFull ) } if( pSort->szTempFileName ) { - hb_fsDelete( ( BYTE * ) pSort->szTempFileName ); + hb_fsDelete( pSort->szTempFileName ); hb_xfree( pSort->szTempFileName ); pSort->szTempFileName = NULL; } @@ -6554,7 +6554,7 @@ static HB_ERRCODE hb_nsxOpen( NSXAREAP pArea, LPDBOPENINFO pOpenInfo ) char szFileName[ HB_PATH_MAX ]; hb_nsxCreateFName( pArea, NULL, NULL, szFileName, NULL ); - if( hb_spFileExists( ( BYTE * ) szFileName, NULL ) || + if( hb_spFileExists( szFileName, NULL ) || DBFAREA_DATA( pArea )->fStrictStruct ) { DBORDERINFO pOrderInfo; @@ -6799,12 +6799,12 @@ static HB_ERRCODE hb_nsxOrderCreate( NSXAREAP pArea, LPDBORDERCREATEINFO pOrderI { if( fTemporary ) { - pFile = hb_fileCreateTemp( NULL, NULL, FC_NORMAL, ( BYTE * ) szSpFile ); + pFile = hb_fileCreateTemp( NULL, NULL, FC_NORMAL, szSpFile ); fNewFile = TRUE; } else { - pFile = hb_fileExtOpen( ( BYTE * ) szFileName, NULL, uiFlags | + pFile = hb_fileExtOpen( szFileName, NULL, uiFlags | ( fNewFile ? FXO_TRUNCATE : FXO_APPEND ) | FXO_DEFAULTS | FXO_SHARELOCK | FXO_COPYNAME, NULL, pError ); @@ -7765,7 +7765,7 @@ static HB_ERRCODE hb_nsxOrderListAdd( NSXAREAP pArea, LPDBORDERINFO pOrderInfo ) do { fRetry = FALSE; - pFile = hb_fileExtOpen( ( BYTE * ) szFileName, NULL, uiFlags | + pFile = hb_fileExtOpen( szFileName, NULL, uiFlags | FXO_DEFAULTS | FXO_SHARELOCK | FXO_COPYNAME, NULL, pError ); if( !pFile ) @@ -7974,18 +7974,15 @@ static HB_ERRCODE hb_nsxRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnect case RDDI_ORDEREXT: case RDDI_ORDSTRUCTEXT: { - char * szNew = hb_itemGetCPtr( pItem ); - - if( szNew[0] == '.' && szNew[1] ) - szNew = hb_strdup( szNew ); - else - szNew = NULL; + const char * szNew = hb_itemGetCPtr( pItem ); + char * szNewVal; + szNewVal = szNew[0] == '.' && szNew[1] ? hb_strdup( szNew ) : NULL; hb_itemPutC( pItem, pData->szIndexExt[ 0 ] ? pData->szIndexExt : NSX_INDEXEXT ); - if( szNew ) + if( szNewVal ) { - hb_strncpy( pData->szIndexExt, szNew, HB_MAX_FILE_EXT ); - hb_xfree( szNew ); + hb_strncpy( pData->szIndexExt, szNewVal, HB_MAX_FILE_EXT ); + hb_xfree( szNewVal ); } break; } diff --git a/harbour/source/rdd/dbfntx/dbfntx1.c b/harbour/source/rdd/dbfntx/dbfntx1.c index 662093ce77..b3b86396e4 100644 --- a/harbour/source/rdd/dbfntx/dbfntx1.c +++ b/harbour/source/rdd/dbfntx/dbfntx1.c @@ -676,8 +676,8 @@ static LPKEYINFO hb_ntxEvalKey( LPKEYINFO pKey, LPTAGINFO pTag ) /* * compare two values using Tag conditions (len & type) */ -static int hb_ntxValCompare( LPTAGINFO pTag, char* val1, int len1, - char* val2, int len2, BOOL fExact ) +static int hb_ntxValCompare( LPTAGINFO pTag, const char* val1, int len1, + const char* val2, int len2, BOOL fExact ) { int iLimit, iResult = 0; @@ -1423,10 +1423,10 @@ static ULONG hb_ntxPageGetFree( LPTAGINFO pTag ) * create the new tag structure */ static LPTAGINFO hb_ntxTagNew( LPNTXINDEX pIndex, - char * szTagName, BOOL fTagName, - char *szKeyExpr, PHB_ITEM pKeyExpr, + const char * szTagName, BOOL fTagName, + const char *szKeyExpr, PHB_ITEM pKeyExpr, BYTE bKeyType, USHORT uiKeyLen, USHORT uiKeyDec, - char *szForExpr, PHB_ITEM pForExpr, + const char *szForExpr, PHB_ITEM pForExpr, BOOL fAscendKey, BOOL fUnique, BOOL fCustom, BOOL fSortRec ) { @@ -1820,8 +1820,7 @@ static void hb_ntxIndexFree( LPNTXINDEX pIndex ) hb_fileClose( pIndex->DiskFile ); if( pIndex->fDelete ) { - hb_fsDelete( ( BYTE * ) ( pIndex->RealName ? - pIndex->RealName : pIndex->IndexName ) ); + hb_fsDelete( pIndex->RealName ? pIndex->RealName : pIndex->IndexName ); } } if( pIndex->IndexName ) @@ -3534,7 +3533,7 @@ static HB_ERRCODE hb_ntxTagSpaceFree( LPTAGINFO pTag ) /* * create index file name */ -static void hb_ntxCreateFName( NTXAREAP pArea, char * szBagName, BOOL * fProd, +static void hb_ntxCreateFName( NTXAREAP pArea, const char * szBagName, BOOL * fProd, char * szFileName, char * szTagName ) { PHB_FNAME pFileName; @@ -3598,7 +3597,7 @@ static void hb_ntxCreateFName( NTXAREAP pArea, char * szBagName, BOOL * fProd, /* * find order bag by its name */ -static LPNTXINDEX hb_ntxFindBag( NTXAREAP pArea, char * szBagName ) +static LPNTXINDEX hb_ntxFindBag( NTXAREAP pArea, const char * szBagName ) { LPNTXINDEX pIndex; PHB_FNAME pSeek, pName; @@ -3631,7 +3630,7 @@ static LPNTXINDEX hb_ntxFindBag( NTXAREAP pArea, char * szBagName ) /* * Find tag by name in index bag */ -static int hb_ntxFindTagByName( LPNTXINDEX pIndex, char * szTag ) +static int hb_ntxFindTagByName( LPNTXINDEX pIndex, const char * szTag ) { int i; @@ -3689,7 +3688,7 @@ static LPTAGINFO hb_ntxFindTag( NTXAREAP pArea, PHB_ITEM pTagItem, { if( hb_itemType( pTagItem ) & HB_IT_STRING ) { - char * szTag = hb_itemGetCPtr( pTagItem ); + const char * szTag = hb_itemGetCPtr( pTagItem ); int iTag; if( fBag ) @@ -4216,7 +4215,8 @@ static BOOL hb_ntxOrdSkipEval( LPTAGINFO pTag, BOOL fForward, PHB_ITEM pEval ) static BOOL hb_ntxOrdSkipWild( LPTAGINFO pTag, BOOL fForward, PHB_ITEM pWildItm ) { NTXAREAP pArea = pTag->Owner->Owner; - char *szPattern, *szFree = NULL; + const char * szPattern; + char * szFree = NULL; BOOL fFound = FALSE; int iFixed = 0; @@ -4235,7 +4235,7 @@ static BOOL hb_ntxOrdSkipWild( LPTAGINFO pTag, BOOL fForward, PHB_ITEM pWildItm if( pArea->cdPage != hb_vmCDP() ) { szPattern = szFree = hb_strdup( szPattern ); - hb_cdpTranslate( szPattern, hb_vmCDP(), pArea->cdPage ); + hb_cdpTranslate( szFree, hb_vmCDP(), pArea->cdPage ); } #endif while( iFixed < pTag->KeyLength && szPattern[ iFixed ] && @@ -4331,7 +4331,7 @@ static BOOL hb_ntxOrdSkipWild( LPTAGINFO pTag, BOOL fForward, PHB_ITEM pWildItm pArea->fEof = FALSE; if( szFree ) - hb_xfree( szPattern ); + hb_xfree( szFree ); return fFound; } @@ -4790,13 +4790,13 @@ static void hb_ntxSortWritePage( LPNTXSORTINFO pSort ) if( pSort->hTempFile == FS_ERROR ) { - BYTE szName[ HB_PATH_MAX ]; + char szName[ HB_PATH_MAX ]; pSort->hTempFile = hb_fsCreateTemp( NULL, NULL, FC_NORMAL, szName ); if( pSort->hTempFile == FS_ERROR ) hb_ntxErrorRT( pSort->pTag->Owner->Owner, EG_CREATE, EDBF_CREATE_TEMP, - ( const char * ) szName, 0, 0, NULL ); + szName, 0, 0, NULL ); else - pSort->szTempFileName = hb_strdup( ( const char * ) szName ); + pSort->szTempFileName = hb_strdup( szName ); } pSort->pSwapPage[ pSort->ulCurPage ].ulKeys = pSort->ulKeys; @@ -4955,7 +4955,7 @@ static BOOL hb_ntxSortKeyGet( LPNTXSORTINFO pSort, BYTE ** pKeyVal, ULONG *pulRe return FALSE; } -static void hb_ntxSortKeyAdd( LPNTXSORTINFO pSort, ULONG ulRec, char * pKeyVal, int iKeyLen ) +static void hb_ntxSortKeyAdd( LPNTXSORTINFO pSort, ULONG ulRec, const char * pKeyVal, int iKeyLen ) { int iLen = pSort->keyLen; BYTE *pDst; @@ -5074,7 +5074,7 @@ static void hb_ntxSortFree( LPNTXSORTINFO pSort, BOOL fFull ) } if( pSort->szTempFileName ) { - hb_fsDelete( ( BYTE * ) pSort->szTempFileName ); + hb_fsDelete( pSort->szTempFileName ); hb_xfree( pSort->szTempFileName ); pSort->szTempFileName = NULL; } @@ -6079,7 +6079,7 @@ static HB_ERRCODE ntxOpen( NTXAREAP pArea, LPDBOPENINFO pOpenInfo ) char szFileName[ HB_PATH_MAX ]; hb_ntxCreateFName( pArea, NULL, NULL, szFileName, NULL ); - if( hb_spFileExists( ( BYTE * ) szFileName, NULL ) || + if( hb_spFileExists( szFileName, NULL ) || DBFAREA_DATA( pArea )->fStrictStruct ) { DBORDERINFO pOrderInfo; @@ -6135,7 +6135,8 @@ static HB_ERRCODE ntxOrderCreate( NTXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo PHB_ITEM pResult, pKeyExp, pForExp = NULL; int iLen, iDec, iTag, i; char szFileName[ HB_PATH_MAX ], szSpFile[ HB_PATH_MAX ], - szTagName[ NTX_MAX_TAGNAME + 1 ], * szKey, * szFor = NULL; + szTagName[ NTX_MAX_TAGNAME + 1 ]; + const char * szKey, * szFor = NULL; LPNTXINDEX pIndex, * pIndexPtr; LPTAGINFO pTag = NULL; LPDBFDATA pData; @@ -6355,12 +6356,12 @@ static HB_ERRCODE ntxOrderCreate( NTXAREAP pArea, LPDBORDERCREATEINFO pOrderInfo { if( fTemporary ) { - pFile = hb_fileCreateTemp( NULL, NULL, FC_NORMAL, ( BYTE * ) szSpFile ); + pFile = hb_fileCreateTemp( NULL, NULL, FC_NORMAL, szSpFile ); fOld = FALSE; } else { - pFile = hb_fileExtOpen( ( BYTE * ) szFileName, NULL, uiFlags | + pFile = hb_fileExtOpen( szFileName, NULL, uiFlags | ( fOld ? FXO_APPEND : FXO_TRUNCATE ) | FXO_DEFAULTS | FXO_SHARELOCK | FXO_COPYNAME, NULL, pError ); @@ -6779,7 +6780,7 @@ static HB_ERRCODE ntxOrderInfo( NTXAREAP pArea, USHORT uiIndex, LPDBORDERINFO pI hb_itemPutC( pInfo->itmResult, pTag->ForExpr ? pTag->ForExpr : NULL ); if( hb_itemType( pInfo->itmNewVal ) & HB_IT_STRING ) { - char * szForExpr = hb_itemGetCPtr( pInfo->itmNewVal ); + const char * szForExpr = hb_itemGetCPtr( pInfo->itmNewVal ); if( pTag->ForExpr ? strncmp( pTag->ForExpr, szForExpr, NTX_MAX_EXP ) != 0 : *szForExpr ) @@ -7351,7 +7352,7 @@ static HB_ERRCODE ntxOrderListAdd( NTXAREAP pArea, LPDBORDERINFO pOrderInfo ) do { fRetry = FALSE; - pFile = hb_fileExtOpen( ( BYTE * ) szFileName, NULL, uiFlags | + pFile = hb_fileExtOpen( szFileName, NULL, uiFlags | FXO_DEFAULTS | FXO_SHARELOCK | FXO_COPYNAME, NULL, pError ); if( !pFile ) @@ -7575,18 +7576,15 @@ static HB_ERRCODE ntxRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnect, P case RDDI_ORDEREXT: case RDDI_ORDSTRUCTEXT: { - char * szNew = hb_itemGetCPtr( pItem ); - - if( szNew[0] == '.' && szNew[1] ) - szNew = hb_strdup( szNew ); - else - szNew = NULL; + const char * szNew = hb_itemGetC( pItem ); + char * szNewVal; + szNewVal = szNew[0] == '.' && szNew[1] ? hb_strdup( szNew ) : NULL; hb_itemPutC( pItem, pData->szIndexExt[ 0 ] ? pData->szIndexExt : NTX_INDEXEXT ); - if( szNew ) + if( szNewVal ) { - hb_strncpy( pData->szIndexExt, szNew, sizeof( pData->szIndexExt ) - 1 ); - hb_xfree( szNew ); + hb_strncpy( pData->szIndexExt, szNewVal, sizeof( pData->szIndexExt ) - 1 ); + hb_xfree( szNewVal ); } break; } diff --git a/harbour/source/rdd/dbsql.c b/harbour/source/rdd/dbsql.c index 2a58bc602c..88ec539fd2 100644 --- a/harbour/source/rdd/dbsql.c +++ b/harbour/source/rdd/dbsql.c @@ -236,9 +236,9 @@ static BOOL hb_exportBufSqlVar( PHB_FILEBUF pFileBuf, PHB_ITEM pValue, /* Export DBF content to a SQL script file */ static ULONG hb_db2Sql( AREAP pArea, PHB_ITEM pFields, HB_LONG llNext, PHB_ITEM pWhile, PHB_ITEM pFor, - const char * szDelim, char * szSep, const char * szEsc, - const char * szTable, HB_FHANDLE hFile, - BOOL fInsert, BOOL fRecno ) + const char * szDelim, const char * szSep, + const char * szEsc, const char * szTable, + HB_FHANDLE hFile, BOOL fInsert, BOOL fRecno ) { PHB_FILEBUF pFileBuf; ULONG ulRecords = 0; @@ -347,22 +347,22 @@ HB_FUNC( __DBSQL ) AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer(); if( pArea ) { - BOOL fExport = hb_parl( 1 ); - char * szFileName = hb_parc( 2 ); - char * szTable = hb_parc( 3 ); - PHB_ITEM pFields = hb_param( 4, HB_IT_ARRAY ); - PHB_ITEM pFor = hb_param( 5, HB_IT_BLOCK ); - PHB_ITEM pWhile = hb_param( 6, HB_IT_BLOCK ); - PHB_ITEM pNext = hb_param( 7, HB_IT_NUMERIC ); - PHB_ITEM pRecord = HB_ISNIL( 8 ) ? NULL : hb_param( 8, HB_IT_ANY ); - BOOL fRest = pWhile != NULL || ( HB_ISLOG( 9 ) && hb_parl( 9 ) ); - BOOL fAppend = HB_ISLOG( 10 ) && hb_parl( 10 ); - BOOL fInsert = HB_ISLOG( 11 ) && hb_parl( 11 ); - BOOL fRecno = HB_ISLOG( 12 ) && hb_parl( 12 ); - char * szSep = hb_parcx( 13 ); - char * szDelim = hb_parcx( 14 ); - char * szEsc = hb_parcx( 15 ); - HB_LONG llNext = HB_LONG_MAX; + BOOL fExport = hb_parl( 1 ); + const char * szFileName = hb_parc( 2 ); + const char * szTable = hb_parc( 3 ); + PHB_ITEM pFields = hb_param( 4, HB_IT_ARRAY ); + PHB_ITEM pFor = hb_param( 5, HB_IT_BLOCK ); + PHB_ITEM pWhile = hb_param( 6, HB_IT_BLOCK ); + PHB_ITEM pNext = hb_param( 7, HB_IT_NUMERIC ); + PHB_ITEM pRecord = HB_ISNIL( 8 ) ? NULL : hb_param( 8, HB_IT_ANY ); + BOOL fRest = pWhile != NULL || ( HB_ISLOG( 9 ) && hb_parl( 9 ) ); + BOOL fAppend = HB_ISLOG( 10 ) && hb_parl( 10 ); + BOOL fInsert = HB_ISLOG( 11 ) && hb_parl( 11 ); + BOOL fRecno = HB_ISLOG( 12 ) && hb_parl( 12 ); + const char * szSep = hb_parcx( 13 ); + const char * szDelim = hb_parcx( 14 ); + const char * szEsc = hb_parcx( 15 ); + HB_LONG llNext = HB_LONG_MAX; HB_FHANDLE hFile; HB_ERRCODE errCode; @@ -376,7 +376,7 @@ HB_FUNC( __DBSQL ) /* Try to create Dat file */ do { - hFile = hb_fsExtOpen( ( BYTE * ) szFileName, NULL, + hFile = hb_fsExtOpen( szFileName, NULL, ( fAppend ? 0 : FXO_TRUNCATE ) | FO_READWRITE | FO_EXCLUSIVE | FXO_DEFAULTS | FXO_SHARELOCK, diff --git a/harbour/source/rdd/delim1.c b/harbour/source/rdd/delim1.c index 78df3fc182..eaeab392b2 100644 --- a/harbour/source/rdd/delim1.c +++ b/harbour/source/rdd/delim1.c @@ -70,7 +70,7 @@ static const USHORT s_uiNumLength[ 9 ] = { 0, 4, 6, 8, 11, 13, 16, 18, 20 }; static void hb_delimInitArea( DELIMAREAP pArea, char * szFileName ) { - char * szEol; + const char * szEol; /* Allocate only after succesfully open file */ pArea->szFileName = hb_strdup( szFileName ); @@ -587,7 +587,7 @@ static HB_ERRCODE hb_delimGetValue( DELIMAREAP pArea, USHORT uiIndex, PHB_ITEM p break; case HB_FT_DATE: - hb_itemPutDS( pItem, ( char * ) pArea->pRecord + pArea->pFieldOffset[ uiIndex ] ); + hb_itemPutDS( pItem, ( const char * ) pArea->pRecord + pArea->pFieldOffset[ uiIndex ] ); break; case HB_FT_LONG: @@ -675,7 +675,7 @@ static HB_ERRCODE hb_delimPutValue( DELIMAREAP pArea, USHORT uiIndex, PHB_ITEM p memcpy( pArea->pRecord + pArea->pFieldOffset[ uiIndex ], hb_itemGetCPtr( pItem ), uiSize ); #ifndef HB_CDP_SUPPORT_OFF - hb_cdpnTranslate( (char *) pArea->pRecord + pArea->pFieldOffset[ uiIndex ], hb_vmCDP(), pArea->cdPage, uiSize ); + hb_cdpnTranslate( ( char * ) pArea->pRecord + pArea->pFieldOffset[ uiIndex ], hb_vmCDP(), pArea->cdPage, uiSize ); #endif memset( pArea->pRecord + pArea->pFieldOffset[ uiIndex ] + uiSize, ' ', pField->uiLen - uiSize ); @@ -883,7 +883,7 @@ static HB_ERRCODE hb_delimFlush( DELIMAREAP pArea ) if( pArea->fFlush ) { - hb_fileWriteAt( pArea->pFile, ( BYTE * ) "\032", 1, pArea->ulFileSize ); + hb_fileWriteAt( pArea->pFile, ( const BYTE * ) "\032", 1, pArea->ulFileSize ); if( hb_setGetHardCommit() ) { hb_fileCommit( pArea->pFile ); @@ -922,7 +922,7 @@ static HB_ERRCODE hb_delimInfo( DELIMAREAP pArea, USHORT uiIndex, PHB_ITEM pItem case DBI_SETDELIMITER: if( hb_itemType( pItem ) & HB_IT_STRING ) { - char * szDelim = hb_itemGetCPtr( pItem ); + const char * szDelim = hb_itemGetCPtr( pItem ); if( hb_stricmp( szDelim, "BLANK" ) == 0 ) { @@ -972,7 +972,7 @@ static HB_ERRCODE hb_delimInfo( DELIMAREAP pArea, USHORT uiIndex, PHB_ITEM pItem case DBI_SEPARATOR: { char szSeparator[ 2 ]; - char * szNew = hb_itemGetCPtr( pItem ); + const char * szNew = hb_itemGetCPtr( pItem ); szSeparator[ 0 ] = pArea->cSeparator; szSeparator[ 1 ] = '\0'; if( *szNew ) @@ -1252,7 +1252,7 @@ static HB_ERRCODE hb_delimCreate( DELIMAREAP pArea, LPDBOPENINFO pCreateInfo ) PHB_FNAME pFileName; HB_ERRCODE errCode; BOOL fRetry; - BYTE szFileName[ HB_PATH_MAX ]; + char szFileName[ HB_PATH_MAX ]; HB_TRACE(HB_TR_DEBUG, ("hb_delimCreate(%p,%p)", pArea, pCreateInfo)); @@ -1261,7 +1261,7 @@ static HB_ERRCODE hb_delimCreate( DELIMAREAP pArea, LPDBOPENINFO pCreateInfo ) #ifndef HB_CDP_SUPPORT_OFF if( pCreateInfo->cdpId ) { - pArea->cdPage = hb_cdpFind( (char *) pCreateInfo->cdpId ); + pArea->cdPage = hb_cdpFind( pCreateInfo->cdpId ); if( !pArea->cdPage ) pArea->cdPage = hb_vmCDP(); } @@ -1269,18 +1269,18 @@ static HB_ERRCODE hb_delimCreate( DELIMAREAP pArea, LPDBOPENINFO pCreateInfo ) pArea->cdPage = hb_vmCDP(); #endif - pFileName = hb_fsFNameSplit( ( char * ) pCreateInfo->abName ); + pFileName = hb_fsFNameSplit( pCreateInfo->abName ); if( hb_setGetDefExtension() && ! pFileName->szExtension ) { PHB_ITEM pItem = hb_itemPutC( NULL, NULL ); SELF_INFO( ( AREAP ) pArea, DBI_TABLEEXT, pItem ); pFileName->szExtension = hb_itemGetCPtr( pItem ); - hb_fsFNameMerge( ( char * ) szFileName, pFileName ); + hb_fsFNameMerge( szFileName, pFileName ); hb_itemRelease( pItem ); } else { - hb_strncpy( ( char * ) szFileName, ( char * ) pCreateInfo->abName, sizeof( szFileName ) - 1 ); + hb_strncpy( szFileName, pCreateInfo->abName, sizeof( szFileName ) - 1 ); } hb_xfree( pFileName ); @@ -1300,7 +1300,7 @@ static HB_ERRCODE hb_delimCreate( DELIMAREAP pArea, LPDBOPENINFO pCreateInfo ) hb_errPutSubCode( pError, EDBF_CREATE_DBF ); hb_errPutOsCode( pError, hb_fsError() ); hb_errPutDescription( pError, hb_langDGetErrorDesc( EG_CREATE ) ); - hb_errPutFileName( pError, ( char * ) szFileName ); + hb_errPutFileName( pError, szFileName ); hb_errPutFlags( pError, EF_CANRETRY | EF_CANDEFAULT ); } fRetry = ( SELF_ERROR( ( AREAP ) pArea, pError ) == E_RETRY ); @@ -1323,7 +1323,7 @@ static HB_ERRCODE hb_delimCreate( DELIMAREAP pArea, LPDBOPENINFO pCreateInfo ) return errCode; } - hb_delimInitArea( pArea, ( char * ) szFileName ); + hb_delimInitArea( pArea, szFileName ); /* Position cursor at the first record */ return SELF_GOTOP( ( AREAP ) pArea ); @@ -1339,7 +1339,7 @@ static HB_ERRCODE hb_delimOpen( DELIMAREAP pArea, LPDBOPENINFO pOpenInfo ) HB_ERRCODE errCode; USHORT uiFlags; BOOL fRetry; - BYTE szFileName[ HB_PATH_MAX ]; + char szFileName[ HB_PATH_MAX ]; char szAlias[ HB_RDD_MAX_ALIAS_LEN + 1 ]; HB_TRACE(HB_TR_DEBUG, ("hb_delimOpen(%p,%p)", pArea, pOpenInfo)); @@ -1349,7 +1349,7 @@ static HB_ERRCODE hb_delimOpen( DELIMAREAP pArea, LPDBOPENINFO pOpenInfo ) #ifndef HB_CDP_SUPPORT_OFF if( pOpenInfo->cdpId ) { - pArea->cdPage = hb_cdpFind( (char *) pOpenInfo->cdpId ); + pArea->cdPage = hb_cdpFind( pOpenInfo->cdpId ); if( !pArea->cdPage ) pArea->cdPage = hb_vmCDP(); } @@ -1360,26 +1360,26 @@ static HB_ERRCODE hb_delimOpen( DELIMAREAP pArea, LPDBOPENINFO pOpenInfo ) uiFlags = ( pArea->fReadonly ? FO_READ : FO_READWRITE ) | ( pArea->fShared ? FO_DENYNONE : FO_EXCLUSIVE ); - pFileName = hb_fsFNameSplit( ( char * ) pOpenInfo->abName ); + pFileName = hb_fsFNameSplit( pOpenInfo->abName ); /* Add default file name extension if necessary */ if( hb_setGetDefExtension() && ! pFileName->szExtension ) { PHB_ITEM pFileExt = hb_itemPutC( NULL, NULL ); SELF_INFO( ( AREAP ) pArea, DBI_TABLEEXT, pFileExt ); pFileName->szExtension = hb_itemGetCPtr( pFileExt ); - hb_fsFNameMerge( ( char * ) szFileName, pFileName ); + hb_fsFNameMerge( szFileName, pFileName ); hb_itemRelease( pFileExt ); } else { - hb_strncpy( ( char * ) szFileName, ( char * ) pOpenInfo->abName, sizeof( szFileName ) - 1 ); + hb_strncpy( szFileName, pOpenInfo->abName, sizeof( szFileName ) - 1 ); } /* Create default alias if necessary */ if( !pOpenInfo->atomAlias && pFileName->szName ) { hb_strncpyUpperTrim( szAlias, pFileName->szName, sizeof( szAlias ) - 1 ); - pOpenInfo->atomAlias = ( BYTE * ) szAlias; + pOpenInfo->atomAlias = szAlias; } hb_xfree( pFileName ); @@ -1398,7 +1398,7 @@ static HB_ERRCODE hb_delimOpen( DELIMAREAP pArea, LPDBOPENINFO pOpenInfo ) hb_errPutSubCode( pError, EDBF_OPEN_DBF ); hb_errPutOsCode( pError, hb_fsError() ); hb_errPutDescription( pError, hb_langDGetErrorDesc( EG_OPEN ) ); - hb_errPutFileName( pError, ( char * ) szFileName ); + hb_errPutFileName( pError, szFileName ); hb_errPutFlags( pError, EF_CANRETRY | EF_CANDEFAULT ); } fRetry = ( SELF_ERROR( ( AREAP ) pArea, pError ) == E_RETRY ); @@ -1421,7 +1421,7 @@ static HB_ERRCODE hb_delimOpen( DELIMAREAP pArea, LPDBOPENINFO pOpenInfo ) return HB_FAILURE; } - hb_delimInitArea( pArea, ( char * ) szFileName ); + hb_delimInitArea( pArea, szFileName ); /* Position cursor at the first record */ return SELF_GOTOP( ( AREAP ) pArea ); diff --git a/harbour/source/rdd/hbsix/sxcompr.c b/harbour/source/rdd/hbsix/sxcompr.c index ab549b1cd2..9fceed2239 100644 --- a/harbour/source/rdd/hbsix/sxcompr.c +++ b/harbour/source/rdd/hbsix/sxcompr.c @@ -617,17 +617,17 @@ HB_FUNC( SX_FCOMPRESS ) { BOOL fRet = FALSE; HB_FHANDLE hInput, hOutput; - char * szSource = hb_parc( 1 ), * szDestin = hb_parc( 2 ); + const char * szSource = hb_parc( 1 ), * szDestin = hb_parc( 2 ); BYTE buf[ 4 ]; ULONG ulSize; if( szSource && *szSource && szDestin && *szDestin ) { - hInput = hb_fsExtOpen( ( BYTE * ) szSource, NULL, FO_READ | FO_DENYNONE | - FXO_DEFAULTS | FXO_SHARELOCK, NULL, NULL ); + hInput = hb_fsExtOpen( szSource, NULL, FO_READ | FO_DENYNONE | + FXO_DEFAULTS | FXO_SHARELOCK, NULL, NULL ); if( hInput != FS_ERROR ) { - hOutput = hb_fsExtOpen( ( BYTE * ) szDestin, NULL, FO_READWRITE | + hOutput = hb_fsExtOpen( szDestin, NULL, FO_READWRITE | FO_EXCLUSIVE | FXO_TRUNCATE | FXO_DEFAULTS | FXO_SHARELOCK, NULL, NULL ); if( hOutput != FS_ERROR ) @@ -654,15 +654,15 @@ HB_FUNC( SX_FDECOMPRESS ) { BOOL fRet = FALSE; HB_FHANDLE hInput, hOutput; - char * szSource = hb_parc( 1 ), * szDestin = hb_parc( 2 ); + const char * szSource = hb_parc( 1 ), * szDestin = hb_parc( 2 ); if( szSource && *szSource && szDestin && *szDestin ) { - hInput = hb_fsExtOpen( ( BYTE * ) szSource, NULL, FO_READ | FO_DENYNONE | - FXO_DEFAULTS | FXO_SHARELOCK, NULL, NULL ); + hInput = hb_fsExtOpen( szSource, NULL, FO_READ | FO_DENYNONE | + FXO_DEFAULTS | FXO_SHARELOCK, NULL, NULL ); if( hInput != FS_ERROR ) { - hOutput = hb_fsExtOpen( ( BYTE * ) szDestin, NULL, FO_READWRITE | + hOutput = hb_fsExtOpen( szDestin, NULL, FO_READWRITE | FO_EXCLUSIVE | FXO_TRUNCATE | FXO_DEFAULTS | FXO_SHARELOCK, NULL, NULL ); if( hOutput != FS_ERROR ) diff --git a/harbour/source/rdd/hbsix/sxdate.c b/harbour/source/rdd/hbsix/sxdate.c index 39009b0cbb..0ba76066ac 100644 --- a/harbour/source/rdd/hbsix/sxdate.c +++ b/harbour/source/rdd/hbsix/sxdate.c @@ -72,7 +72,7 @@ char * hb_sxDtoP( char * pDate, LONG lJulian ) return pDate; } -LONG hb_sxPtoD( char * pDate ) +LONG hb_sxPtoD( const char * pDate ) { int iYear, iMonth, iDay; LONG lPDate; diff --git a/harbour/source/rdd/hbsix/sxfname.c b/harbour/source/rdd/hbsix/sxfname.c index 723484dfad..03fd54444e 100644 --- a/harbour/source/rdd/hbsix/sxfname.c +++ b/harbour/source/rdd/hbsix/sxfname.c @@ -57,18 +57,19 @@ HB_FUNC( SX_FNAMEPARSER ) { - char * szFileName = hb_parc( 1 ); + const char * szFileName = hb_parc( 1 ); if( szFileName ) { char szPathBuf[ HB_PATH_MAX ]; PHB_FNAME pFileName; ULONG ulLen; - BOOL fFree; - - szFileName = ( char * ) hb_fsNameConv( ( BYTE * ) szFileName, &fFree ); + char * pszFree; + szFileName = hb_fsNameConv( szFileName, &pszFree ); pFileName = hb_fsFNameSplit( szFileName ); + if( pszFree ) + hb_xfree( pszFree ); if( ! HB_ISLOG( 2 ) || ! hb_parl( 2 ) ) pFileName->szPath = NULL; @@ -93,11 +94,7 @@ HB_FUNC( SX_FNAMEPARSER ) } } - if( fFree ) - hb_retc_buffer( hb_fsFNameMerge( szFileName, pFileName ) ); - else - hb_retc( hb_fsFNameMerge( szPathBuf, pFileName ) ); - + hb_retc( hb_fsFNameMerge( szPathBuf, pFileName ) ); hb_xfree( pFileName ); } else diff --git a/harbour/source/rdd/hbsix/sxord.c b/harbour/source/rdd/hbsix/sxord.c index b5c082873c..cd5af19638 100644 --- a/harbour/source/rdd/hbsix/sxord.c +++ b/harbour/source/rdd/hbsix/sxord.c @@ -682,7 +682,7 @@ HB_FUNC( SX_TAGUNIQUE ) HB_FUNC( SX_WILDSEEK ) { AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer(); - char * szPattern = hb_parc( 1 ); + const char * szPattern = hb_parc( 1 ); BOOL fCont = HB_ISLOG( 2 ) && hb_parl( 2 ); BOOL fFound = FALSE; int iOrder = 0; @@ -709,7 +709,7 @@ HB_FUNC( SX_WILDSEEK ) errCode = SELF_ORDINFO( pArea, DBOI_KEYVAL, &Info ); if( errCode == HB_SUCCESS ) { - char * szKey = hb_itemGetCPtr( Info.itmResult ); + const char * szKey = hb_itemGetCPtr( Info.itmResult ); fFound = hb_strMatchWild( szKey, szPattern ); } } diff --git a/harbour/source/rdd/hbsix/sxsem.c b/harbour/source/rdd/hbsix/sxsem.c index 587d6b195d..9a5f828711 100644 --- a/harbour/source/rdd/hbsix/sxsem.c +++ b/harbour/source/rdd/hbsix/sxsem.c @@ -61,7 +61,7 @@ static BOOL hb_sxSemName( char * szFileName ) { - char * szName = hb_parc( 1 ); + const char * szName = hb_parc( 1 ); BOOL fResult = FALSE; if( szName && szName[0] ) @@ -97,14 +97,14 @@ static BOOL hb_sxSemName( char * szFileName ) return fResult; } -static HB_FHANDLE hb_sxSemOpen( BYTE * szFileName, BOOL * pfNewFile ) +static HB_FHANDLE hb_sxSemOpen( char * szFileName, BOOL * pfNewFile ) { HB_FHANDLE hFile; int i = 0; do { - hFile = hb_fsExtOpen( szFileName, ( BYTE * ) ".sem", + hFile = hb_fsExtOpen( szFileName, ".sem", FO_READWRITE | FO_EXCLUSIVE | FXO_DEFAULTS | FXO_SHARELOCK | FXO_COPYNAME, NULL, NULL ); if( hFile != FS_ERROR ) @@ -112,7 +112,7 @@ static HB_FHANDLE hb_sxSemOpen( BYTE * szFileName, BOOL * pfNewFile ) if( pfNewFile ) { - hFile = hb_fsExtOpen( szFileName, ( BYTE * ) ".sem", FXO_UNIQUE | + hFile = hb_fsExtOpen( szFileName, ".sem", FXO_UNIQUE | FO_READWRITE | FO_EXCLUSIVE | FXO_DEFAULTS | FXO_SHARELOCK | FXO_COPYNAME, NULL, NULL ); if( hFile != FS_ERROR ) @@ -138,11 +138,12 @@ static HB_FHANDLE hb_sxSemOpen( BYTE * szFileName, BOOL * pfNewFile ) HB_FUNC( SX_MAKESEM ) { - BYTE szFileName[HB_PATH_MAX], buffer[2]; + char szFileName[HB_PATH_MAX]; + BYTE buffer[2]; int iUsers = -1; BOOL fError = FALSE, fNewFile = FALSE; - if( hb_sxSemName( ( char * ) szFileName ) ) + if( hb_sxSemName( szFileName ) ) { HB_FHANDLE hFile = hb_sxSemOpen( szFileName, &fNewFile ); if( hFile != FS_ERROR ) @@ -175,10 +176,11 @@ HB_FUNC( SX_MAKESEM ) HB_FUNC( SX_KILLSEM ) { - BYTE szFileName[HB_PATH_MAX], buffer[2]; + char szFileName[HB_PATH_MAX]; + BYTE buffer[2]; int iUsers = -1; - if( hb_sxSemName( ( char * ) szFileName ) ) + if( hb_sxSemName( szFileName ) ) { HB_FHANDLE hFile = hb_sxSemOpen( szFileName, NULL ); if( hFile != FS_ERROR ) @@ -201,10 +203,10 @@ HB_FUNC( SX_KILLSEM ) HB_FUNC( SX_ISSEM ) { - BYTE szFileName[HB_PATH_MAX]; + char szFileName[HB_PATH_MAX]; HB_FHANDLE hFile = FS_ERROR; - if( hb_sxSemName( ( char * ) szFileName ) ) + if( hb_sxSemName( szFileName ) ) { hFile = hb_sxSemOpen( szFileName, NULL ); if( hFile != FS_ERROR ) diff --git a/harbour/source/rdd/hbsix/sxtable.c b/harbour/source/rdd/hbsix/sxtable.c index 9057634955..673d917c75 100644 --- a/harbour/source/rdd/hbsix/sxtable.c +++ b/harbour/source/rdd/hbsix/sxtable.c @@ -480,11 +480,11 @@ HB_FUNC( _SXOPENINIT ) pInfo->fReadonly = hb_parl( 2 ); if( HB_ISCHAR( 4 ) ) { - char * szAlias = hb_parc( 1 ); + const char * szAlias = hb_parc( 1 ); if( szAlias && szAlias[ 0 ] ) - pInfo->atomAlias = ( BYTE * ) hb_dynsymName( hb_dynsymGet( szAlias ) ); + pInfo->atomAlias = hb_dynsymName( hb_dynsymGet( szAlias ) ); else - pInfo->atomAlias = ( BYTE * ) ""; + pInfo->atomAlias = ""; } } } diff --git a/harbour/source/rdd/hbsix/sxutil.c b/harbour/source/rdd/hbsix/sxutil.c index c0a2a56822..c23c4c7d5e 100644 --- a/harbour/source/rdd/hbsix/sxutil.c +++ b/harbour/source/rdd/hbsix/sxutil.c @@ -58,7 +58,7 @@ HB_FUNC( SX_SLIMFAST ) { - char * szExp = hb_parc( 1 ); + const char * szExp = hb_parc( 1 ); if( szExp && *szExp ) { @@ -91,7 +91,7 @@ HB_FUNC( SX_SLIMFAST ) HB_FUNC( SX_WILDMATCH ) { - char * szPattern = hb_parc( 1 ), * szValue = hb_parc( 2 ); + const char * szPattern = hb_parc( 1 ), * szValue = hb_parc( 2 ); BOOL fMatch = FALSE; if( szPattern && szPattern[0] && szValue ) diff --git a/harbour/source/rdd/hsx/hsx.c b/harbour/source/rdd/hsx/hsx.c index 4cbf8275e3..1968323719 100644 --- a/harbour/source/rdd/hsx/hsx.c +++ b/harbour/source/rdd/hsx/hsx.c @@ -567,7 +567,7 @@ static LPHSXINFO hb_hsxGetPointer( int iHandle ) return pHSX; } -static int hb_hsxCompile( char * szExpr, PHB_ITEM * pExpr ) +static int hb_hsxCompile( const char * szExpr, PHB_ITEM * pExpr ) { AREAP pArea = ( AREAP ) hb_rddGetCurrentWorkAreaPointer(); @@ -1384,10 +1384,11 @@ static int hb_hsxDestroy( int iHandle ) return iRetVal; } -static int hb_hsxCreate( char * szFile, int iBufSize, int iKeySize, +static int hb_hsxCreate( const char * szFile, int iBufSize, int iKeySize, BOOL fIgnoreCase, int iFilter, PHB_ITEM pExpr ) { - char szFileName[ HB_PATH_MAX ], * szExpr = NULL; + char szFileName[ HB_PATH_MAX ]; + const char * szExpr = NULL; PHB_ITEM pKeyExpr = NULL; ULONG ulBufSize; USHORT uiRecordSize; @@ -1430,7 +1431,7 @@ static int hb_hsxCreate( char * szFile, int iBufSize, int iKeySize, pKeyExpr = hb_itemNew( pExpr ); } - pFile = hb_fileExtOpen( ( BYTE * ) szFileName, ( BYTE * ) HSX_FILEEXT, + pFile = hb_fileExtOpen( szFileName, HSX_FILEEXT, FO_READWRITE | FO_EXCLUSIVE | FXO_TRUNCATE | FXO_DEFAULTS | FXO_SHARELOCK | FXO_COPYNAME, NULL, NULL ); @@ -1473,7 +1474,7 @@ static int hb_hsxCreate( char * szFile, int iBufSize, int iKeySize, return pHSX->iHandle; } -static int hb_hsxOpen( char * szFile, int iBufSize, int iMode ) +static int hb_hsxOpen( const char * szFile, int iBufSize, int iMode ) { char szFileName[ HB_PATH_MAX ]; BOOL fShared, fReadonly; @@ -1506,7 +1507,7 @@ static int hb_hsxOpen( char * szFile, int iBufSize, int iMode ) uiFlags = ( fReadonly ? FO_READ : FO_READWRITE ) | ( fShared ? FO_DENYNONE : FO_EXCLUSIVE ); - pFile = hb_fileExtOpen( ( BYTE * ) szFileName, ( BYTE * ) HSX_FILEEXT, + pFile = hb_fileExtOpen( szFileName, HSX_FILEEXT, uiFlags | FXO_DEFAULTS | FXO_SHARELOCK | FXO_COPYNAME, NULL, NULL ); @@ -1547,8 +1548,8 @@ static int hb_hsxOpen( char * szFile, int iBufSize, int iMode ) return pHSX->iHandle; } -static int hb_hsxIndex( char * szFile, PHB_ITEM pExpr, int iKeySize, int iMode, - int iBufSize, BOOL fIgnoreCase, int iFilter ) +static int hb_hsxIndex( const char * szFile, PHB_ITEM pExpr, int iKeySize, + int iMode, int iBufSize, BOOL fIgnoreCase, int iFilter ) { int iRetVal = HSX_SUCCESS, iHandle; ULONG ulRecNo = 0, ulRecCount = 0, ulNewRec, ulRec; diff --git a/harbour/source/rdd/sdf1.c b/harbour/source/rdd/sdf1.c index 5434d1cd08..ace7526b6f 100644 --- a/harbour/source/rdd/sdf1.c +++ b/harbour/source/rdd/sdf1.c @@ -70,7 +70,7 @@ static const USHORT s_uiNumLength[ 9 ] = { 0, 4, 6, 8, 11, 13, 16, 18, 20 }; static void hb_sdfInitArea( SDFAREAP pArea, char * szFileName ) { - char * szEol; + const char * szEol; /* Allocate only after succesfully open file */ pArea->szFileName = hb_strdup( szFileName ); @@ -498,7 +498,7 @@ static HB_ERRCODE hb_sdfPutValue( SDFAREAP pArea, USHORT uiIndex, PHB_ITEM pItem memcpy( pArea->pRecord + pArea->pFieldOffset[ uiIndex ], hb_itemGetCPtr( pItem ), uiSize ); #ifndef HB_CDP_SUPPORT_OFF - hb_cdpnTranslate( (char *) pArea->pRecord + pArea->pFieldOffset[ uiIndex ], hb_vmCDP(), pArea->cdPage, uiSize ); + hb_cdpnTranslate( ( char * ) pArea->pRecord + pArea->pFieldOffset[ uiIndex ], hb_vmCDP(), pArea->cdPage, uiSize ); #endif memset( pArea->pRecord + pArea->pFieldOffset[ uiIndex ] + uiSize, ' ', pField->uiLen - uiSize ); @@ -706,7 +706,7 @@ static HB_ERRCODE hb_sdfFlush( SDFAREAP pArea ) if( pArea->fFlush ) { - hb_fileWriteAt( pArea->pFile, ( BYTE * ) "\032", 1, pArea->ulFileSize ); + hb_fileWriteAt( pArea->pFile, ( const BYTE * ) "\032", 1, pArea->ulFileSize ); if( hb_setGetHardCommit() ) { hb_fileCommit( pArea->pFile ); @@ -987,7 +987,7 @@ static HB_ERRCODE hb_sdfCreate( SDFAREAP pArea, LPDBOPENINFO pCreateInfo ) PHB_FNAME pFileName; PHB_ITEM pError = NULL; BOOL fRetry; - BYTE szFileName[ HB_PATH_MAX ]; + char szFileName[ HB_PATH_MAX ]; HB_TRACE(HB_TR_DEBUG, ("hb_sdfCreate(%p,%p)", pArea, pCreateInfo)); @@ -996,7 +996,7 @@ static HB_ERRCODE hb_sdfCreate( SDFAREAP pArea, LPDBOPENINFO pCreateInfo ) #ifndef HB_CDP_SUPPORT_OFF if( pCreateInfo->cdpId ) { - pArea->cdPage = hb_cdpFind( (char *) pCreateInfo->cdpId ); + pArea->cdPage = hb_cdpFind( pCreateInfo->cdpId ); if( !pArea->cdPage ) pArea->cdPage = hb_vmCDP(); } @@ -1004,18 +1004,18 @@ static HB_ERRCODE hb_sdfCreate( SDFAREAP pArea, LPDBOPENINFO pCreateInfo ) pArea->cdPage = hb_vmCDP(); #endif - pFileName = hb_fsFNameSplit( ( char * ) pCreateInfo->abName ); + pFileName = hb_fsFNameSplit( pCreateInfo->abName ); if( hb_setGetDefExtension() && ! pFileName->szExtension ) { PHB_ITEM pItem = hb_itemPutC( NULL, NULL ); SELF_INFO( ( AREAP ) pArea, DBI_TABLEEXT, pItem ); pFileName->szExtension = hb_itemGetCPtr( pItem ); - hb_fsFNameMerge( ( char * ) szFileName, pFileName ); + hb_fsFNameMerge( szFileName, pFileName ); hb_itemRelease( pItem ); } else { - hb_strncpy( ( char * ) szFileName, ( char * ) pCreateInfo->abName, sizeof( szFileName ) - 1 ); + hb_strncpy( szFileName, pCreateInfo->abName, sizeof( szFileName ) - 1 ); } hb_xfree( pFileName ); @@ -1035,7 +1035,7 @@ static HB_ERRCODE hb_sdfCreate( SDFAREAP pArea, LPDBOPENINFO pCreateInfo ) hb_errPutSubCode( pError, EDBF_CREATE_DBF ); hb_errPutOsCode( pError, hb_fsError() ); hb_errPutDescription( pError, hb_langDGetErrorDesc( EG_CREATE ) ); - hb_errPutFileName( pError, ( char * ) szFileName ); + hb_errPutFileName( pError, szFileName ); hb_errPutFlags( pError, EF_CANRETRY | EF_CANDEFAULT ); } fRetry = ( SELF_ERROR( ( AREAP ) pArea, pError ) == E_RETRY ); @@ -1058,7 +1058,7 @@ static HB_ERRCODE hb_sdfCreate( SDFAREAP pArea, LPDBOPENINFO pCreateInfo ) return errCode; } - hb_sdfInitArea( pArea, ( char * ) szFileName ); + hb_sdfInitArea( pArea, szFileName ); /* Position cursor at the first record */ return SELF_GOTOP( ( AREAP ) pArea ); @@ -1074,7 +1074,7 @@ static HB_ERRCODE hb_sdfOpen( SDFAREAP pArea, LPDBOPENINFO pOpenInfo ) HB_ERRCODE errCode; USHORT uiFlags; BOOL fRetry; - BYTE szFileName[ HB_PATH_MAX ]; + char szFileName[ HB_PATH_MAX ]; char szAlias[ HB_RDD_MAX_ALIAS_LEN + 1 ]; HB_TRACE(HB_TR_DEBUG, ("hb_sdfOpen(%p,%p)", pArea, pOpenInfo)); @@ -1084,7 +1084,7 @@ static HB_ERRCODE hb_sdfOpen( SDFAREAP pArea, LPDBOPENINFO pOpenInfo ) #ifndef HB_CDP_SUPPORT_OFF if( pOpenInfo->cdpId ) { - pArea->cdPage = hb_cdpFind( (char *) pOpenInfo->cdpId ); + pArea->cdPage = hb_cdpFind( pOpenInfo->cdpId ); if( !pArea->cdPage ) pArea->cdPage = hb_vmCDP(); } @@ -1095,26 +1095,26 @@ static HB_ERRCODE hb_sdfOpen( SDFAREAP pArea, LPDBOPENINFO pOpenInfo ) uiFlags = ( pArea->fReadonly ? FO_READ : FO_READWRITE ) | ( pArea->fShared ? FO_DENYNONE : FO_EXCLUSIVE ); - pFileName = hb_fsFNameSplit( ( char * ) pOpenInfo->abName ); + pFileName = hb_fsFNameSplit( pOpenInfo->abName ); /* Add default file name extension if necessary */ if( hb_setGetDefExtension() && ! pFileName->szExtension ) { PHB_ITEM pFileExt = hb_itemPutC( NULL, NULL ); SELF_INFO( ( AREAP ) pArea, DBI_TABLEEXT, pFileExt ); pFileName->szExtension = hb_itemGetCPtr( pFileExt ); - hb_fsFNameMerge( ( char * ) szFileName, pFileName ); + hb_fsFNameMerge( szFileName, pFileName ); hb_itemRelease( pFileExt ); } else { - hb_strncpy( ( char * ) szFileName, ( char * ) pOpenInfo->abName, sizeof( szFileName ) - 1 ); + hb_strncpy( szFileName, pOpenInfo->abName, sizeof( szFileName ) - 1 ); } /* Create default alias if necessary */ if( !pOpenInfo->atomAlias && pFileName->szName ) { hb_strncpyUpperTrim( szAlias, pFileName->szName, sizeof( szAlias ) - 1 ); - pOpenInfo->atomAlias = ( BYTE * ) szAlias; + pOpenInfo->atomAlias = szAlias; } hb_xfree( pFileName ); @@ -1133,7 +1133,7 @@ static HB_ERRCODE hb_sdfOpen( SDFAREAP pArea, LPDBOPENINFO pOpenInfo ) hb_errPutSubCode( pError, EDBF_OPEN_DBF ); hb_errPutOsCode( pError, hb_fsError() ); hb_errPutDescription( pError, hb_langDGetErrorDesc( EG_OPEN ) ); - hb_errPutFileName( pError, ( char * ) szFileName ); + hb_errPutFileName( pError, szFileName ); hb_errPutFlags( pError, EF_CANRETRY | EF_CANDEFAULT ); } fRetry = ( SELF_ERROR( ( AREAP ) pArea, pError ) == E_RETRY ); @@ -1156,7 +1156,7 @@ static HB_ERRCODE hb_sdfOpen( SDFAREAP pArea, LPDBOPENINFO pOpenInfo ) return HB_FAILURE; } - hb_sdfInitArea( pArea, ( char * ) szFileName ); + hb_sdfInitArea( pArea, szFileName ); /* Position cursor at the first record */ return SELF_GOTOP( ( AREAP ) pArea ); diff --git a/harbour/source/rdd/usrrdd/usrrdd.c b/harbour/source/rdd/usrrdd/usrrdd.c index 9b9bacf369..21e0b399e2 100644 --- a/harbour/source/rdd/usrrdd/usrrdd.c +++ b/harbour/source/rdd/usrrdd/usrrdd.c @@ -180,7 +180,7 @@ static PHB_ITEM hb_usrArrayGet( PHB_ITEM pArray, ULONG ulPos, HB_TYPE uiType ) return NULL; } -static char * hb_usrArrayGetC( PHB_ITEM pArray, ULONG ulPos ) +static const char * hb_usrArrayGetC( PHB_ITEM pArray, ULONG ulPos ) { PHB_ITEM pItem = hb_arrayGetItemPtr( pArray, ulPos ); @@ -209,7 +209,7 @@ static BOOL hb_usrItemToFieldInfo( PHB_ITEM pItem, LPDBFIELDINFO pFieldInfo ) { if( pItem && hb_arrayLen( pItem ) == UR_FI_SIZE ) { - pFieldInfo->atomName = ( BYTE * ) hb_usrArrayGetC( pItem, UR_FI_NAME ); + pFieldInfo->atomName = hb_usrArrayGetC( pItem, UR_FI_NAME ); pFieldInfo->uiType = hb_arrayGetNI( pItem, UR_FI_TYPE ); pFieldInfo->uiTypeExtended = hb_arrayGetNI( pItem, UR_FI_TYPEEXT ); pFieldInfo->uiLen = hb_arrayGetNI( pItem, UR_FI_LEN ); @@ -245,11 +245,11 @@ static BOOL hb_usrItemToOpenInfo( PHB_ITEM pItem, LPDBOPENINFO pOpenInfo ) if( pItem && hb_arrayLen( pItem ) == UR_OI_SIZE ) { pOpenInfo->uiArea = hb_arrayGetNI( pItem, UR_OI_AREA ); - pOpenInfo->abName = ( BYTE * ) hb_usrArrayGetC( pItem, UR_OI_NAME ); - pOpenInfo->atomAlias = ( BYTE * ) hb_usrArrayGetC( pItem, UR_OI_ALIAS ); + pOpenInfo->abName = hb_usrArrayGetC( pItem, UR_OI_NAME ); + pOpenInfo->atomAlias = hb_usrArrayGetC( pItem, UR_OI_ALIAS ); pOpenInfo->fShared = hb_arrayGetL( pItem, UR_OI_SHARED ); pOpenInfo->fReadonly = hb_arrayGetL( pItem, UR_OI_READONLY ); - pOpenInfo->cdpId = ( BYTE * ) hb_usrArrayGetC( pItem, UR_OI_CDPID ); + pOpenInfo->cdpId = hb_usrArrayGetC( pItem, UR_OI_CDPID ); pOpenInfo->ulConnection = hb_arrayGetNL( pItem, UR_OI_CONNECT ); pOpenInfo->lpdbHeader = hb_arrayGetPtr( pItem, UR_OI_HEADER ); return TRUE; @@ -652,8 +652,8 @@ static BOOL hb_usrItemToOrderCondInfo( PHB_ITEM pItem, if( pItem && hb_arrayLen( pItem ) == UR_ORC_SIZE ) { pOrderCondInfo->fActive = hb_arrayGetL( pItem, UR_ORC_ACTIVE ); - pOrderCondInfo->abFor = ( BYTE * ) hb_usrArrayGetC( pItem, UR_ORC_CFOR ); - pOrderCondInfo->abWhile = ( BYTE * ) hb_usrArrayGetC( pItem, UR_ORC_CWHILE ); + pOrderCondInfo->abFor = ( char * ) hb_usrArrayGetC( pItem, UR_ORC_CFOR ); + pOrderCondInfo->abWhile = ( char * ) hb_usrArrayGetC( pItem, UR_ORC_CWHILE ); pOrderCondInfo->itmCobFor = hb_usrArrayGet( pItem, UR_ORC_BFOR, HB_IT_ANY ); pOrderCondInfo->itmCobWhile = hb_usrArrayGet( pItem, UR_ORC_BWHILE, HB_IT_ANY ); pOrderCondInfo->itmCobEval = hb_usrArrayGet( pItem, UR_ORC_BEVAL, HB_IT_ANY ); @@ -701,9 +701,9 @@ static void hb_usrOrderCondFree( LPDBORDERCONDINFO pOrderCondInfo ) static void hb_usrOrderCondClone( LPDBORDERCONDINFO pOrderCondInfo ) { if( pOrderCondInfo->abFor ) - pOrderCondInfo->abFor = ( BYTE * ) hb_strdup( ( char * ) pOrderCondInfo->abFor ); + pOrderCondInfo->abFor = hb_strdup( pOrderCondInfo->abFor ); if( pOrderCondInfo->abWhile ) - pOrderCondInfo->abWhile = ( BYTE * ) hb_strdup( ( char * ) pOrderCondInfo->abWhile ); + pOrderCondInfo->abWhile = hb_strdup( pOrderCondInfo->abWhile ); if( pOrderCondInfo->itmCobFor ) pOrderCondInfo->itmCobFor = hb_itemNew( pOrderCondInfo->itmCobFor ); if( pOrderCondInfo->itmCobWhile ) @@ -765,8 +765,8 @@ static BOOL hb_usrItemToOrderCreateInfo( PHB_ITEM pItem, pOrderCreateInfo->lpdbOrdCondInfo = NULL; } - pOrderCreateInfo->abBagName = ( BYTE * ) hb_usrArrayGetC( pItem, UR_ORCR_BAGNAME ); - pOrderCreateInfo->atomBagName = ( BYTE * ) hb_usrArrayGetC( pItem, UR_ORCR_TAGNAME ); + pOrderCreateInfo->abBagName = hb_usrArrayGetC( pItem, UR_ORCR_BAGNAME ); + pOrderCreateInfo->atomBagName = hb_usrArrayGetC( pItem, UR_ORCR_TAGNAME ); pOrderCreateInfo->itmOrder = hb_usrArrayGet( pItem, UR_ORCR_ORDER, HB_IT_ANY ); pOrderCreateInfo->fUnique = hb_arrayGetL( pItem, UR_ORCR_UNIQUE ); pOrderCreateInfo->itmCobExpr = hb_usrArrayGet( pItem, UR_ORCR_BKEY, HB_IT_ANY ); @@ -2461,7 +2461,7 @@ static HB_ERRCODE hb_usrOpenMemFile( AREAP pArea, LPDBOPENINFO pOpenInfo ) return hb_usrReturn(); } -static HB_ERRCODE hb_usrGetValueFile( AREAP pArea, USHORT uiIndex, void * szFile, USHORT uiMode ) +static HB_ERRCODE hb_usrGetValueFile( AREAP pArea, USHORT uiIndex, const char * szFile, USHORT uiMode ) { HB_TRACE(HB_TR_DEBUG, ("hb_usrGetValueFile(%p,%hu,%p,%hu)", pArea, uiIndex, szFile, uiMode)); @@ -2470,14 +2470,14 @@ static HB_ERRCODE hb_usrGetValueFile( AREAP pArea, USHORT uiIndex, void * szFile hb_vmPushInteger( pArea->uiArea ); hb_vmPushInteger( uiIndex ); - hb_vmPushString( ( char * ) szFile, strlen( ( char * ) szFile ) ); + hb_vmPushString( szFile, strlen( szFile ) ); hb_vmPushInteger( uiMode ); hb_vmDo( 4 ); return hb_usrReturn(); } -static HB_ERRCODE hb_usrPutValueFile( AREAP pArea, USHORT uiIndex, void * szFile, USHORT uiMode ) +static HB_ERRCODE hb_usrPutValueFile( AREAP pArea, USHORT uiIndex, const char * szFile, USHORT uiMode ) { HB_TRACE(HB_TR_DEBUG, ("hb_usrPutValueFile(%p,%hu,%p,%hu)", pArea, uiIndex, szFile, uiMode)); @@ -2486,7 +2486,7 @@ static HB_ERRCODE hb_usrPutValueFile( AREAP pArea, USHORT uiIndex, void * szFile hb_vmPushInteger( pArea->uiArea ); hb_vmPushInteger( uiIndex ); - hb_vmPushString( ( char * ) szFile, strlen( ( char * ) szFile ) ); + hb_vmPushString( szFile, strlen( szFile ) ); hb_vmPushInteger( uiMode ); hb_vmDo( 4 ); @@ -2834,7 +2834,7 @@ HB_FUNC( USRRDD_GETFUNCTABLE ) { RDDFUNCS * pSelfTable, * pSuperTable; USHORT * puiCount, uiResult, uiCount, uiSize; - char * szSuperRDD; + const char * szSuperRDD; PHB_ITEM pMethods; HB_TRACE(HB_TR_DEBUG, ("USRRDD_GETFUNCTABLE()")); diff --git a/harbour/source/rdd/wacore.c b/harbour/source/rdd/wacore.c index 8ec3ffaa06..bb7753e05f 100644 --- a/harbour/source/rdd/wacore.c +++ b/harbour/source/rdd/wacore.c @@ -567,7 +567,7 @@ HB_ERRCODE hb_rddDetachArea( AREAP pArea, PHB_ITEM pCargo ) return HB_SUCCESS; } -AREAP hb_rddRequestArea( char * szAlias, PHB_ITEM pCargo, +AREAP hb_rddRequestArea( const char * szAlias, PHB_ITEM pCargo, BOOL fNewArea, BOOL fWait ) { PHB_DYNS pSymAlias = NULL; diff --git a/harbour/source/rdd/wafunc.c b/harbour/source/rdd/wafunc.c index 711b5edc71..75560a117f 100644 --- a/harbour/source/rdd/wafunc.c +++ b/harbour/source/rdd/wafunc.c @@ -646,11 +646,11 @@ HB_ERRCODE hb_rddOpenTable( const char * szFileName, const char * szDriver, /* Fill pInfo structure */ pInfo.uiArea = pArea->uiArea; - pInfo.abName = ( BYTE * ) szFileName; - pInfo.atomAlias = ( BYTE * ) szAlias; + pInfo.abName = szFileName; + pInfo.atomAlias = szAlias; pInfo.fShared = fShared; pInfo.fReadonly = fReadonly; - pInfo.cdpId = ( BYTE * ) szCpId; + pInfo.cdpId = szCpId; pInfo.ulConnection = ulConnection; pInfo.lpdbHeader = NULL; @@ -714,11 +714,11 @@ HB_ERRCODE hb_rddCreateTable( const char * szFileName, const char * szDriver, /* Fill pInfo structure */ pInfo.uiArea = pArea->uiArea; - pInfo.abName = ( BYTE * ) szFileName; - pInfo.atomAlias = ( BYTE * ) szAlias; + pInfo.abName = szFileName; + pInfo.atomAlias = szAlias; pInfo.fShared = FALSE; pInfo.fReadonly = FALSE; - pInfo.cdpId = ( BYTE * ) szCpId; + pInfo.cdpId = szCpId; pInfo.ulConnection = ulConnection; pInfo.lpdbHeader = NULL; @@ -780,10 +780,10 @@ HB_ERRCODE hb_rddCreateTableTemp( const char * szDriver, /* Fill pInfo structure */ pInfo.uiArea = pArea->uiArea; pInfo.abName = NULL; - pInfo.atomAlias = ( BYTE * ) szAlias; + pInfo.atomAlias = szAlias; pInfo.fShared = FALSE; pInfo.fReadonly = FALSE; - pInfo.cdpId = ( BYTE * ) szCpId; + pInfo.cdpId = szCpId; pInfo.ulConnection = ulConnection; pInfo.lpdbHeader = NULL; @@ -846,9 +846,9 @@ void hb_tblStructure( AREAP pArea, PHB_ITEM pStruct, USHORT uiSize ) } } -static char * hb_dbTransFieldPos( PHB_ITEM pFields, USHORT uiField ) +static const char * hb_dbTransFieldPos( PHB_ITEM pFields, USHORT uiField ) { - char * szField = NULL; + const char * szField = NULL; PHB_ITEM pItem; pItem = hb_arrayGetItemPtr( pFields, uiField ); @@ -874,7 +874,7 @@ HB_ERRCODE hb_dbTransStruct( AREAP lpaSource, AREAP lpaDest, { USHORT uiFields, uiSize, uiCount, uiPosSrc, uiPosDst, uiSizeSrc, uiSizeDst; HB_ERRCODE errCode; - char * szField; + const char * szField; BOOL fAll; errCode = SELF_FIELDCOUNT( lpaSource, &uiSizeSrc ); diff --git a/harbour/source/rdd/workarea.c b/harbour/source/rdd/workarea.c index 3a89d1435d..ad960e8107 100644 --- a/harbour/source/rdd/workarea.c +++ b/harbour/source/rdd/workarea.c @@ -288,7 +288,7 @@ static HB_ERRCODE hb_waCreateFields( AREAP pArea, PHB_ITEM pStruct ) { pFieldInfo.uiTypeExtended = 0; pFieldDesc = hb_arrayGetItemPtr( pStruct, uiCount + 1 ); - pFieldInfo.atomName = ( BYTE * ) hb_arrayGetCPtr( pFieldDesc, DBS_NAME ); + pFieldInfo.atomName = hb_arrayGetCPtr( pFieldDesc, DBS_NAME ); iData = hb_arrayGetNI( pFieldDesc, DBS_LEN ); if( iData < 0 ) iData = 0; @@ -1800,9 +1800,8 @@ static HB_ERRCODE hb_waRddInfo( LPRDDNODE pRDD, USHORT uiIndex, ULONG ulConnecti break; case RDDI_MEMOEXT: { - char * szResult = hb_setGetMFileExt(); - if( szResult ) - szResult = hb_strdup( szResult ); + const char * szExt = hb_setGetMFileExt(); + char * szResult = szExt ? hb_strdup( szExt ) : NULL; if( hb_itemType( pItem ) & HB_IT_STRING ) { hb_setSetItem( HB_SET_MFILEEXT, pItem ); diff --git a/harbour/source/rtl/ampm.c b/harbour/source/rtl/ampm.c index 91cbcb7ab1..dc1b9fbed6 100644 --- a/harbour/source/rtl/ampm.c +++ b/harbour/source/rtl/ampm.c @@ -61,7 +61,7 @@ HB_FUNC( AMPM ) if( ulTimeLen ) { - char * pszTime = hb_parc( 1 ); + const char * pszTime = hb_parc( 1 ); memcpy( pszResult, pszTime, ulTimeLen ); uiHour = ( USHORT ) hb_strVal( pszTime, ulTimeLen ); } diff --git a/harbour/source/rtl/cdpapi.c b/harbour/source/rtl/cdpapi.c index 075551ec4c..c0e8dca1e8 100644 --- a/harbour/source/rtl/cdpapi.c +++ b/harbour/source/rtl/cdpapi.c @@ -1205,8 +1205,8 @@ HB_FUNC( HB_SETCODEPAGE ) HB_FUNC( HB_TRANSLATE ) { ULONG ulLen = hb_parclen( 1 ); - char *szIdIn = hb_parc( 2 ); - char *szIdOut = hb_parc( 3 ); + const char *szIdIn = hb_parc( 2 ); + const char *szIdOut = hb_parc( 3 ); if( ulLen && ( szIdIn || szIdOut ) ) { @@ -1248,7 +1248,8 @@ HB_FUNC( HB_CDPLIST ) HB_FUNC( HB_STRTOUTF8 ) { ULONG ulLen = hb_parclen( 1 ), ulDest = 0; - char *szString, *szDest = NULL; + const char *szString; + char *szDest = NULL; if( ulLen ) { @@ -1286,7 +1287,7 @@ HB_FUNC( HB_UTF8CHR ) HB_FUNC( HB_UTF8TOSTR ) { - char *szString = hb_parc( 1 ); + const char *szString = hb_parc( 1 ); if( szString ) { @@ -1317,7 +1318,7 @@ HB_FUNC( HB_UTF8TOSTR ) HB_FUNC( HB_UTF8SUBSTR ) { - char *szString = hb_parc( 1 ); + const char *szString = hb_parc( 1 ); int iPCount = hb_pcount(); if( szString && ( iPCount < 2 || ( HB_ISNUM( 2 ) && ( iPCount < 3 || HB_ISNUM( 3 ) ) ) ) ) @@ -1350,7 +1351,7 @@ HB_FUNC( HB_UTF8SUBSTR ) HB_FUNC( HB_UTF8LEFT ) { - char *szString = hb_parc( 1 ); + const char *szString = hb_parc( 1 ); if( szString && HB_ISNUM( 2 ) ) { @@ -1373,7 +1374,7 @@ HB_FUNC( HB_UTF8LEFT ) HB_FUNC( HB_UTF8RIGHT ) { - char *szString = hb_parc( 1 ); + const char *szString = hb_parc( 1 ); if( szString && HB_ISNUM( 2 ) ) { @@ -1401,7 +1402,7 @@ HB_FUNC( HB_UTF8RIGHT ) HB_FUNC( HB_UTF8PEEK ) { - char *szString = hb_parc( 1 ); + const char *szString = hb_parc( 1 ); if( szString && HB_ISNUM( 2 ) ) { @@ -1423,7 +1424,7 @@ HB_FUNC( HB_UTF8POKE ) if( pText && HB_ISNUM( 2 ) && HB_ISNUM( 3 ) ) { - char *szString = hb_itemGetCPtr( pText ); + const char *szString = hb_itemGetCPtr( pText ); ULONG ulLen = hb_parclen( 1 ), ulPos; ulPos = utf8pos( ( BYTE * ) szString, ulLen, hb_parnl( 2 ) ); @@ -1465,7 +1466,7 @@ HB_FUNC( HB_UTF8POKE ) HB_FUNC( HB_UTF8STUFF ) { - char *szString = hb_parc( 1 ); + const char *szString = hb_parc( 1 ); if( szString && HB_ISNUM( 2 ) && HB_ISNUM( 3 ) && HB_ISCHAR( 4 ) ) { @@ -1516,7 +1517,7 @@ HB_FUNC( HB_UTF8STUFF ) HB_FUNC( HB_UTF8LEN ) { - char *szString = hb_parc( 1 ); + const char *szString = hb_parc( 1 ); if( szString ) hb_retnint( hb_cdpUTF8StringLength( ( BYTE * ) szString, hb_parclen( 1 ) ) ); diff --git a/harbour/source/rtl/chrasc.c b/harbour/source/rtl/chrasc.c index dbf06a14d8..90e5c9b79e 100644 --- a/harbour/source/rtl/chrasc.c +++ b/harbour/source/rtl/chrasc.c @@ -81,7 +81,7 @@ HB_FUNC( CHR ) /* converts a character value to an ASCII code */ HB_FUNC( ASC ) { - char * szValue = hb_parc( 1 ); + const char * szValue = hb_parc( 1 ); if( szValue ) hb_retni( ( UCHAR ) szValue[ 0 ] ); diff --git a/harbour/source/rtl/colorind.c b/harbour/source/rtl/colorind.c index b0a31e1263..78d53a3994 100644 --- a/harbour/source/rtl/colorind.c +++ b/harbour/source/rtl/colorind.c @@ -56,7 +56,7 @@ HB_FUNC( HB_COLORINDEX ) { if( HB_ISCHAR( 1 ) && HB_ISNUM( 2 ) ) { - char * pszColor = hb_parc( 1 ); + const char * pszColor = hb_parc( 1 ); ULONG ulColorPos; ULONG ulColorLen; USHORT uiColorIndex = ( USHORT ) hb_parni( 2 ); diff --git a/harbour/source/rtl/console.c b/harbour/source/rtl/console.c index eb0bb80907..8a8c1d7919 100644 --- a/harbour/source/rtl/console.c +++ b/harbour/source/rtl/console.c @@ -187,11 +187,11 @@ void hb_conRelease( void ) hb_fsSetDevMode( s_hFilenoStderr, FD_TEXT ); } -char * hb_conNewLine( void ) +const char * hb_conNewLine( void ) { HB_TRACE(HB_TR_DEBUG, ("hb_conNewLine()")); - return ( char * ) s_szCrLf; + return s_szCrLf; } HB_FUNC( HB_OSNEWLINE ) @@ -627,7 +627,7 @@ HB_FUNC( HB_DISPOUTATBOX ) { SHORT nRow = ( SHORT ) hb_parni( 1 ); SHORT nCol = ( SHORT ) hb_parni( 2 ); - char * pszString = hb_parcx( 3 ); + const char * pszString = hb_parcx( 3 ); ULONG nStringLen = hb_parclen( 3 ); int iColor; diff --git a/harbour/source/rtl/copyfile.c b/harbour/source/rtl/copyfile.c index 0c9af3bbca..d0bd80beac 100644 --- a/harbour/source/rtl/copyfile.c +++ b/harbour/source/rtl/copyfile.c @@ -72,7 +72,7 @@ static BOOL hb_copyfile( const char * szSource, const char * szDest ) do { - fhndSource = hb_fsExtOpen( ( BYTE * ) szSource, NULL, + fhndSource = hb_fsExtOpen( szSource, NULL, FO_READ | FXO_DEFAULTS | FXO_SHARELOCK, NULL, pError ); if( fhndSource == FS_ERROR ) @@ -90,7 +90,7 @@ static BOOL hb_copyfile( const char * szSource, const char * szDest ) do { - fhndDest = hb_fsExtOpen( ( BYTE * ) szDest, NULL, + fhndDest = hb_fsExtOpen( szDest, NULL, FXO_TRUNCATE | FO_READWRITE | FO_EXCLUSIVE | FXO_DEFAULTS | FXO_SHARELOCK, NULL, pError ); diff --git a/harbour/source/rtl/defpath.c b/harbour/source/rtl/defpath.c index 94edd651b3..ba37863a6a 100644 --- a/harbour/source/rtl/defpath.c +++ b/harbour/source/rtl/defpath.c @@ -56,7 +56,7 @@ HB_FUNC( __DEFPATH ) { char buffer[ HB_PATH_MAX - 1 + 2 ]; - char * szDefault; + const char * szDefault; int size = 0; szDefault = hb_setGetDefault(); diff --git a/harbour/source/rtl/dirdrive.c b/harbour/source/rtl/dirdrive.c index dbbdfad209..20814e7b1b 100644 --- a/harbour/source/rtl/dirdrive.c +++ b/harbour/source/rtl/dirdrive.c @@ -60,7 +60,7 @@ HB_FUNC( DIRCHANGE ) { if( HB_ISCHAR( 1 ) ) - hb_retni( hb_fsChDir( ( BYTE * ) hb_parc( 1 ) ) ? 0 : hb_fsError() ); + hb_retni( hb_fsChDir( hb_parc( 1 ) ) ? 0 : hb_fsError() ); else hb_retni( F_ERROR ); } @@ -71,7 +71,7 @@ HB_FUNC( DIRCHANGE ) HB_FUNC( MAKEDIR ) { if( HB_ISCHAR( 1 ) ) - hb_retni( hb_fsMkDir( ( BYTE * ) hb_parc( 1 ) ) ? 0 : hb_fsError() ); + hb_retni( hb_fsMkDir( hb_parc( 1 ) ) ? 0 : hb_fsError() ); else hb_retni( F_ERROR ); } @@ -79,7 +79,7 @@ HB_FUNC( MAKEDIR ) HB_FUNC( DIRREMOVE ) { if( HB_ISCHAR( 1 ) ) - hb_retni( hb_fsRmDir( ( BYTE * ) hb_parc( 1 ) ) ? 0 : hb_fsError() ); + hb_retni( hb_fsRmDir( hb_parc( 1 ) ) ? 0 : hb_fsError() ); else hb_retni( F_ERROR ); } @@ -91,7 +91,7 @@ HB_FUNC( DIRREMOVE ) HB_FUNC( ISDISK ) { BOOL fResult = FALSE; - char * szDrive = hb_parc( 1 ); + const char * szDrive = hb_parc( 1 ); if( szDrive ) { @@ -106,7 +106,7 @@ HB_FUNC( ISDISK ) HB_FUNC( DISKCHANGE ) { BOOL fResult = FALSE; - char * szDrive = hb_parc( 1 ); + const char * szDrive = hb_parc( 1 ); if( szDrive ) { diff --git a/harbour/source/rtl/direct.c b/harbour/source/rtl/direct.c index 50de504fb7..eda0e8319b 100644 --- a/harbour/source/rtl/direct.c +++ b/harbour/source/rtl/direct.c @@ -105,10 +105,10 @@ HB_FUNC( DIRECTORY ) { - char * szDirSpec = hb_parc( 1 ); - char * szAttributes = hb_parc( 2 ); - BOOL fFree = FALSE; - ULONG ulMask; + const char * szDirSpec = hb_parc( 1 ); + const char * szAttributes = hb_parc( 2 ); + char * pszFree = NULL; + ULONG ulMask; PHB_ITEM pDir = hb_itemArrayNew( 0 ); PHB_FFIND ffind; @@ -138,7 +138,7 @@ HB_FUNC( DIRECTORY ) if( szDirSpec && *szDirSpec ) { - szDirSpec = ( char * ) hb_fsNameConv( ( BYTE * ) szDirSpec, &fFree ); + szDirSpec = hb_fsNameConv( szDirSpec, &pszFree ); if( ulMask != HB_FA_LABEL ) { if( *szDirSpec ) @@ -154,32 +154,24 @@ HB_FUNC( DIRECTORY ) if( szDirSpec[ iLen ] == HB_OS_PATH_DELIM_CHR ) #endif { - if( fFree ) + if( pszFree ) { - char * szTemp = hb_xstrcpy( NULL, szDirSpec, HB_OS_ALLFILE_MASK, NULL ); - hb_xfree( szDirSpec ); - szDirSpec = szTemp; + char * pszTemp = hb_xstrcpy( NULL, szDirSpec, HB_OS_ALLFILE_MASK, NULL ); + hb_xfree( pszFree ); + szDirSpec = pszFree = pszTemp; } else { - szDirSpec = hb_xstrcpy( NULL, szDirSpec, HB_OS_ALLFILE_MASK, NULL ); - fFree = TRUE; + szDirSpec = pszFree = hb_xstrcpy( NULL, szDirSpec, HB_OS_ALLFILE_MASK, NULL ); } } } else - { - if( fFree ) - { - hb_xfree( szDirSpec ); - fFree = FALSE; - } - szDirSpec = ( char * ) HB_OS_ALLFILE_MASK; - } + szDirSpec = HB_OS_ALLFILE_MASK; } } else - szDirSpec = ( char * ) HB_OS_ALLFILE_MASK; + szDirSpec = HB_OS_ALLFILE_MASK; /* Get the file list */ @@ -208,8 +200,8 @@ HB_FUNC( DIRECTORY ) hb_fsFindClose( ffind ); } - if( fFree ) - hb_xfree( szDirSpec ); + if( pszFree ) + hb_xfree( pszFree ); hb_itemReturnRelease( pDir ); } diff --git a/harbour/source/rtl/diskspac.c b/harbour/source/rtl/diskspac.c index 0f6009d2c0..a066d71c71 100644 --- a/harbour/source/rtl/diskspac.c +++ b/harbour/source/rtl/diskspac.c @@ -189,13 +189,13 @@ HB_FUNC( DISKSPACE ) } #elif defined(HB_OS_UNIX) { - char * szName = hb_parc( 1 ); - BOOL fFree = FALSE; + const char * szName = hb_parc( 1 ); + char * pszFree = NULL; if( !szName ) - szName = ( char * ) "/"; + szName = "/"; else - szName = ( char * ) hb_fsNameConv( ( BYTE * ) szName, &fFree ); + szName = hb_fsNameConv( szName, &pszFree ); { #if defined(__WATCOMC__) || defined(__CEGCC__) @@ -221,8 +221,8 @@ HB_FUNC( DISKSPACE ) #endif } - if( fFree ) - hb_xfree( szName ); + if( pszFree ) + hb_xfree( pszFree ); } #else bError = FALSE; diff --git a/harbour/source/rtl/disksphb.c b/harbour/source/rtl/disksphb.c index db8f380d80..9d3dd990a1 100644 --- a/harbour/source/rtl/disksphb.c +++ b/harbour/source/rtl/disksphb.c @@ -70,7 +70,7 @@ HB_FUNC( HB_DISKSPACE ) { char szPathBuf[ 4 ]; - char * szPath = hb_parc( 1 ); + const char * szPath = hb_parc( 1 ); USHORT uiType = HB_ISNUM( 2 ) ? ( USHORT ) hb_parni( 2 ) : HB_DISK_AVAIL; double dSpace = 0.0; @@ -335,9 +335,9 @@ HB_FUNC( HB_DISKSPACE ) #else struct statvfs sf; #endif - BOOL fFree = FALSE; + char * pszFree; - szPath = ( char * ) hb_fsNameConv( ( BYTE * ) szPath, &fFree ); + szPath = hb_fsNameConv( szPath, &pszFree ); #if defined(HB_OS_DARWIN) if( statfs( szPath, &sf ) == 0 ) @@ -369,8 +369,8 @@ HB_FUNC( HB_DISKSPACE ) else hb_fsSetIOError( FALSE, 0 ); - if( fFree ) - hb_xfree( szPath ); + if( pszFree ) + hb_xfree( pszFree ); } #else { diff --git a/harbour/source/rtl/errapi.c b/harbour/source/rtl/errapi.c index de079428bd..9ca18fcebe 100644 --- a/harbour/source/rtl/errapi.c +++ b/harbour/source/rtl/errapi.c @@ -736,7 +736,7 @@ PHB_ITEM hb_errPutArgsArray( PHB_ITEM pError, PHB_ITEM pArgs ) return pError; } -char * hb_errGetDescription( PHB_ITEM pError ) +const char * hb_errGetDescription( PHB_ITEM pError ) { HB_TRACE(HB_TR_DEBUG, ("hb_errGetDescription(%p)", pError)); @@ -752,7 +752,7 @@ PHB_ITEM hb_errPutDescription( PHB_ITEM pError, const char * szDescription ) return pError; } -char * hb_errGetFileName( PHB_ITEM pError ) +const char * hb_errGetFileName( PHB_ITEM pError ) { HB_TRACE(HB_TR_DEBUG, ("hb_errGetFileName(%p)", pError)); @@ -784,7 +784,7 @@ PHB_ITEM hb_errPutGenCode( PHB_ITEM pError, USHORT uiGenCode ) return pError; } -char * hb_errGetOperation( PHB_ITEM pError ) +const char * hb_errGetOperation( PHB_ITEM pError ) { HB_TRACE(HB_TR_DEBUG, ("hb_errGetOperation(%p)", pError)); @@ -855,7 +855,7 @@ PHB_ITEM hb_errPutSubCode( PHB_ITEM pError, USHORT uiSubCode ) return pError; } -char * hb_errGetSubSystem( PHB_ITEM pError ) +const char * hb_errGetSubSystem( PHB_ITEM pError ) { HB_TRACE(HB_TR_DEBUG, ("hb_errGetSubSytem(%p)", pError)); diff --git a/harbour/source/rtl/file.c b/harbour/source/rtl/file.c index 61b2c1c8ed..b362821170 100644 --- a/harbour/source/rtl/file.c +++ b/harbour/source/rtl/file.c @@ -53,57 +53,55 @@ #include "hbapi.h" #include "hbapifs.h" -BOOL hb_fsFile( BYTE * pszFilename ) +BOOL hb_fsFile( const char * pszFilename ) { PHB_FFIND ffind; - BOOL fFree; + char * pszFree; - HB_TRACE(HB_TR_DEBUG, ("hb_fsFile(%s)", ( char * ) pszFilename)); + HB_TRACE(HB_TR_DEBUG, ("hb_fsFile(%s)", pszFilename)); - pszFilename = hb_fsNameConv( pszFilename, &fFree ); + pszFilename = hb_fsNameConv( pszFilename, &pszFree ); - if( ( ffind = hb_fsFindFirst( ( char * ) pszFilename, HB_FA_ALL ) ) != NULL ) + if( ( ffind = hb_fsFindFirst( pszFilename, HB_FA_ALL ) ) != NULL ) { hb_fsFindClose( ffind ); - if( fFree ) - hb_xfree( pszFilename ); + if( pszFree ) + hb_xfree( pszFree ); return TRUE; } - if( fFree ) - hb_xfree( pszFilename ); + if( pszFree ) + hb_xfree( pszFree ); return FALSE; } -BOOL hb_fsIsDirectory( BYTE * pszFilename ) +BOOL hb_fsIsDirectory( const char * pszFilename ) { - BOOL bResult = FALSE, fFree; + BOOL bResult = FALSE; PHB_FFIND ffind; + char * pszFree = NULL; int iLen; - HB_TRACE(HB_TR_DEBUG, ("hb_fsIsDirectory(%s)", ( char * ) pszFilename)); + HB_TRACE(HB_TR_DEBUG, ("hb_fsIsDirectory(%s)", pszFilename)); - pszFilename = hb_fsNameConv( pszFilename, &fFree ); + pszFilename = hb_fsNameConv( pszFilename, &pszFree ); - iLen = strlen( ( char * ) pszFilename ); + iLen = strlen( pszFilename ); while( iLen && strchr( HB_OS_PATH_DELIM_CHR_LIST, pszFilename[ iLen - 1 ] ) ) --iLen; if( pszFilename[ iLen ] ) { - if( fFree ) - pszFilename[ iLen ] = '\0'; + if( pszFree ) + pszFree[ iLen ] = '\0'; else - { - pszFilename = ( BYTE * ) hb_strndup( ( char * ) pszFilename, iLen ); - fFree = TRUE; - } + pszFilename = pszFree = hb_strndup( pszFilename, iLen ); } if( iLen && iLen <= ( HB_PATH_MAX - 1 ) ) { - if( ( ffind = hb_fsFindFirst( ( char * ) pszFilename, HB_FA_DIRECTORY ) ) != NULL ) + if( ( ffind = hb_fsFindFirst( pszFilename, HB_FA_DIRECTORY ) ) != NULL ) { if( ( ffind->attr & HB_FA_DIRECTORY ) == HB_FA_DIRECTORY ) bResult = TRUE; @@ -111,8 +109,8 @@ BOOL hb_fsIsDirectory( BYTE * pszFilename ) } } - if( fFree ) - hb_xfree( pszFilename ); + if( pszFree ) + hb_xfree( pszFree ); return bResult; } diff --git a/harbour/source/rtl/filebuf.c b/harbour/source/rtl/filebuf.c index ef5f902ec7..a9de448647 100644 --- a/harbour/source/rtl/filebuf.c +++ b/harbour/source/rtl/filebuf.c @@ -303,8 +303,8 @@ static BOOL hb_fileUnlock( PHB_FILE pFile, BOOL * pfLockFS, * public API functions */ -PHB_FILE hb_fileExtOpen( BYTE * pFilename, BYTE * pDefExt, - USHORT uiExFlags, BYTE * pPaths, +PHB_FILE hb_fileExtOpen( const char * pFilename, const char * pDefExt, + USHORT uiExFlags, const char * pPaths, PHB_ITEM pError ) { PHB_FILE pFile = NULL; @@ -314,7 +314,7 @@ PHB_FILE hb_fileExtOpen( BYTE * pFilename, BYTE * pDefExt, #endif BOOL fShared, fReadonly; HB_FHANDLE hFile; - BYTE * pszFile; + char * pszFile; fShared = ( uiExFlags & ( FO_DENYREAD | FO_DENYWRITE | FO_EXCLUSIVE ) ) == 0; fReadonly = ( uiExFlags & ( FO_READ | FO_WRITE | FO_READWRITE ) ) == FO_READ; @@ -492,8 +492,8 @@ HB_FHANDLE hb_fileHandle( PHB_FILE pFile ) return pFile ? pFile->hFile : FS_ERROR; } -PHB_FILE hb_fileCreateTemp( const BYTE * pszDir, const BYTE * pszPrefix, - ULONG ulAttr, BYTE * pszName ) +PHB_FILE hb_fileCreateTemp( const char * pszDir, const char * pszPrefix, + ULONG ulAttr, char * pszName ) { PHB_FILE pFile = NULL; HB_FHANDLE hFile; @@ -505,10 +505,10 @@ PHB_FILE hb_fileCreateTemp( const BYTE * pszDir, const BYTE * pszPrefix, return pFile; } -PHB_FILE hb_fileCreateTempEx( BYTE * pszName, - const BYTE * pszDir, - const BYTE * pszPrefix, - const BYTE * pszExt, +PHB_FILE hb_fileCreateTempEx( char * pszName, + const char * pszDir, + const char * pszPrefix, + const char * pszExt, ULONG ulAttr ) { PHB_FILE pFile = NULL; diff --git a/harbour/source/rtl/filehb.c b/harbour/source/rtl/filehb.c index d1e0b99328..032864d1c6 100644 --- a/harbour/source/rtl/filehb.c +++ b/harbour/source/rtl/filehb.c @@ -66,7 +66,7 @@ HB_FUNC( FILE ) { - BYTE * szFile = ( BYTE * ) hb_parc( 1 ); + const char * szFile = hb_parc( 1 ); hb_retl( szFile ? hb_spFile( szFile, NULL ) : FALSE ); } diff --git a/harbour/source/rtl/filesys.c b/harbour/source/rtl/filesys.c index 55acd2924e..e56e7cdd61 100644 --- a/harbour/source/rtl/filesys.c +++ b/harbour/source/rtl/filesys.c @@ -542,7 +542,7 @@ HB_FHANDLE hb_fsGetOsHandle( HB_FHANDLE hFileHandle ) #endif } -HB_FHANDLE hb_fsPOpen( BYTE * pFilename, BYTE * pMode ) +HB_FHANDLE hb_fsPOpen( const char * pFilename, const char * pMode ) { HB_FHANDLE hFileHandle = FS_ERROR; @@ -552,12 +552,12 @@ HB_FHANDLE hb_fsPOpen( BYTE * pFilename, BYTE * pMode ) { HB_FHANDLE hPipeHandle[2], hNullHandle; pid_t pid; - BYTE * pbyTmp; + char * pszTmp; BOOL bRead; ULONG ulLen; int iMaxFD; - ulLen = strlen( ( char * ) pFilename ); + ulLen = strlen( pFilename ); if( pMode && ( *pMode == 'r' || *pMode == 'w' ) ) bRead = ( *pMode == 'r' ); else @@ -577,11 +577,11 @@ HB_FHANDLE hb_fsPOpen( BYTE * pFilename, BYTE * pMode ) } if( pFilename[ ulLen - 1 ] == '|' ) { - pbyTmp = ( BYTE * ) hb_strdup( ( char * ) pFilename ); - pbyTmp[--ulLen] = 0; - pFilename = pbyTmp; + pszTmp = hb_strdup( pFilename ); + pszTmp[--ulLen] = 0; + pFilename = pszTmp; } else - pbyTmp = NULL; + pszTmp = NULL; hb_vmUnlock(); if( pipe( hPipeHandle ) == 0 ) { @@ -595,11 +595,11 @@ HB_FHANDLE hb_fsPOpen( BYTE * pFilename, BYTE * pMode ) hFileHandle = hPipeHandle[ 1 ]; } } else { - char * argv[4]; - argv[0] = ( char * ) "sh"; - argv[1] = ( char * ) "-c"; - argv[2] = ( char * ) pFilename; - argv[3] = ( char * ) 0; + const char * argv[4]; + argv[0] = "sh"; + argv[1] = "-c"; + argv[2] = pFilename; + argv[3] = 0; hNullHandle = open( "/dev/null", O_RDWR ); if( bRead ) { close( hPipeHandle[ 0 ] ); @@ -619,7 +619,7 @@ HB_FHANDLE hb_fsPOpen( BYTE * pFilename, BYTE * pMode ) close( hNullHandle ); setuid( getuid() ); setgid( getgid() ); - execv( "/bin/sh", argv ); + execv( "/bin/sh", ( char ** ) argv ); exit(1); } } @@ -632,8 +632,8 @@ HB_FHANDLE hb_fsPOpen( BYTE * pFilename, BYTE * pMode ) hb_fsSetIOError( hFileHandle != FS_ERROR, 0 ); hb_vmLock(); - if( pbyTmp ) - hb_xfree( pbyTmp ); + if( pszTmp ) + hb_xfree( pszTmp ); } #else @@ -647,14 +647,14 @@ HB_FHANDLE hb_fsPOpen( BYTE * pFilename, BYTE * pMode ) return hFileHandle; } -HB_FHANDLE hb_fsOpen( BYTE * pFilename, USHORT uiFlags ) +HB_FHANDLE hb_fsOpen( const char * pFilename, USHORT uiFlags ) { HB_FHANDLE hFileHandle; - BOOL fFree; + char * pszFree; HB_TRACE(HB_TR_DEBUG, ("hb_fsOpen(%s, %hu)", pFilename, uiFlags)); - pFilename = hb_fsNameConv( pFilename, &fFree ); + pFilename = hb_fsNameConv( pFilename, &pszFree ); #if defined(HB_IO_WIN) { @@ -664,7 +664,7 @@ HB_FHANDLE hb_fsOpen( BYTE * pFilename, USHORT uiFlags ) convert_open_flags( FALSE, FC_NORMAL, uiFlags, &dwMode, &dwShare, &dwCreat, &dwAttr ); hb_vmUnlock(); - hFile = ( HANDLE ) CreateFileA( ( char * ) pFilename, dwMode, dwShare, + hFile = ( HANDLE ) CreateFileA( pFilename, dwMode, dwShare, NULL, dwCreat, dwAttr, NULL ); hb_fsSetIOError( hFile != ( HANDLE ) INVALID_HANDLE_VALUE, 0 ); hb_vmLock(); @@ -680,16 +680,16 @@ HB_FHANDLE hb_fsOpen( BYTE * pFilename, USHORT uiFlags ) hb_vmUnlock(); #if defined(_MSC_VER) || defined(__DMC__) if( share ) - hFileHandle = _sopen( ( char * ) pFilename, flags, share, mode ); + hFileHandle = _sopen( pFilename, flags, share, mode ); else - hFileHandle = _open( ( char * ) pFilename, flags, mode ); + hFileHandle = _open( pFilename, flags, mode ); #elif defined(HB_FS_SOPEN) if( share ) - hFileHandle = sopen( ( char * ) pFilename, flags, share, mode ); + hFileHandle = sopen( pFilename, flags, share, mode ); else - hFileHandle = open( ( char * ) pFilename, flags, mode ); + hFileHandle = open( pFilename, flags, mode ); #else - hFileHandle = open( ( char * ) pFilename, flags | share, mode ); + hFileHandle = open( pFilename, flags | share, mode ); #endif hb_fsSetIOError( hFileHandle != FS_ERROR, 0 ); hb_vmLock(); @@ -701,20 +701,20 @@ HB_FHANDLE hb_fsOpen( BYTE * pFilename, USHORT uiFlags ) #endif - if( fFree ) - hb_xfree( pFilename ); + if( pszFree ) + hb_xfree( pszFree ); return hFileHandle; } -HB_FHANDLE hb_fsCreate( BYTE * pFilename, ULONG ulAttr ) +HB_FHANDLE hb_fsCreate( const char * pFilename, ULONG ulAttr ) { HB_FHANDLE hFileHandle; - BOOL fFree; + char * pszFree; HB_TRACE(HB_TR_DEBUG, ("hb_fsCreate(%s, %lu)", pFilename, ulAttr)); - pFilename = hb_fsNameConv( pFilename, &fFree ); + pFilename = hb_fsNameConv( pFilename, &pszFree ); #if defined(HB_IO_WIN) { @@ -724,7 +724,7 @@ HB_FHANDLE hb_fsCreate( BYTE * pFilename, ULONG ulAttr ) convert_open_flags( TRUE, ulAttr, FO_EXCLUSIVE, &dwMode, &dwShare, &dwCreat, &dwAttr ); hb_vmUnlock(); - hFile = ( HANDLE ) CreateFileA( ( char * ) pFilename, dwMode, dwShare, + hFile = ( HANDLE ) CreateFileA( pFilename, dwMode, dwShare, NULL, dwCreat, dwAttr, NULL ); hb_fsSetIOError( hFile != ( HANDLE ) INVALID_HANDLE_VALUE, 0 ); hb_vmLock(); @@ -739,11 +739,11 @@ HB_FHANDLE hb_fsCreate( BYTE * pFilename, ULONG ulAttr ) hb_vmUnlock(); #if defined(HB_FS_DOSCREAT) - hFileHandle = _creat( ( char * ) pFilename, attr ); + hFileHandle = _creat( pFilename, attr ); #elif defined(HB_FS_SOPEN) - hFileHandle = open( ( char * ) pFilename, flags, mode ); + hFileHandle = open( pFilename, flags, mode ); #else - hFileHandle = open( ( char * ) pFilename, flags | share, mode ); + hFileHandle = open( pFilename, flags | share, mode ); #endif hb_fsSetIOError( hFileHandle != FS_ERROR, 0 ); hb_vmLock(); @@ -755,8 +755,8 @@ HB_FHANDLE hb_fsCreate( BYTE * pFilename, ULONG ulAttr ) #endif - if( fFree ) - hb_xfree( pFilename ); + if( pszFree ) + hb_xfree( pszFree ); return hFileHandle; } @@ -767,14 +767,14 @@ HB_FHANDLE hb_fsCreate( BYTE * pFilename, ULONG ulAttr ) [vszakats] */ -HB_FHANDLE hb_fsCreateEx( BYTE * pFilename, ULONG ulAttr, USHORT uiFlags ) +HB_FHANDLE hb_fsCreateEx( const char * pFilename, ULONG ulAttr, USHORT uiFlags ) { HB_FHANDLE hFileHandle; - BOOL fFree; + char * pszFree; HB_TRACE(HB_TR_DEBUG, ("hb_fsCreateEx(%s, %lu, %hu)", pFilename, ulAttr, uiFlags)); - pFilename = hb_fsNameConv( pFilename, &fFree ); + pFilename = hb_fsNameConv( pFilename, &pszFree ); #if defined( HB_IO_WIN ) { @@ -784,7 +784,7 @@ HB_FHANDLE hb_fsCreateEx( BYTE * pFilename, ULONG ulAttr, USHORT uiFlags ) convert_open_flags( TRUE, ulAttr, uiFlags, &dwMode, &dwShare, &dwCreat, &dwAttr ); hb_vmUnlock(); - hFile = ( HANDLE ) CreateFileA( ( char * ) pFilename, dwMode, dwShare, + hFile = ( HANDLE ) CreateFileA( pFilename, dwMode, dwShare, NULL, dwCreat, dwAttr, NULL ); hb_fsSetIOError( hFile != ( HANDLE ) INVALID_HANDLE_VALUE, 0 ); hb_vmLock(); @@ -799,9 +799,9 @@ HB_FHANDLE hb_fsCreateEx( BYTE * pFilename, ULONG ulAttr, USHORT uiFlags ) hb_vmUnlock(); #if defined(HB_FS_SOPEN) - hFileHandle = open( ( char * ) pFilename, flags, mode ); + hFileHandle = open( pFilename, flags, mode ); #else - hFileHandle = open( ( char * ) pFilename, flags | share, mode ); + hFileHandle = open( pFilename, flags | share, mode ); #endif hb_fsSetIOError( hFileHandle != FS_ERROR, 0 ); hb_vmLock(); @@ -813,8 +813,8 @@ HB_FHANDLE hb_fsCreateEx( BYTE * pFilename, ULONG ulAttr, USHORT uiFlags ) #endif - if( fFree ) - hb_xfree( pFilename ); + if( pszFree ) + hb_xfree( pszFree ); return hFileHandle; } @@ -921,7 +921,7 @@ BOOL hb_fsSetDevMode( HB_FHANDLE hFileHandle, USHORT uiDevMode ) #endif } -BOOL hb_fsGetFileTime( BYTE * pszFileName, LONG * plJulian, LONG * plMillisec ) +BOOL hb_fsGetFileTime( const char * pszFileName, LONG * plJulian, LONG * plMillisec ) { BOOL fResult; @@ -956,12 +956,12 @@ BOOL hb_fsGetFileTime( BYTE * pszFileName, LONG * plJulian, LONG * plMillisec ) #elif defined( HB_OS_UNIX ) || defined( HB_OS_OS2 ) || defined( HB_OS_DOS ) || defined( __GNUC__ ) { struct stat sStat; - BOOL fFree; + char * pszFree; - pszFileName = hb_fsNameConv( pszFileName, &fFree ); + pszFileName = hb_fsNameConv( pszFileName, &pszFree ); hb_vmUnlock(); - if( stat( ( char * ) pszFileName, &sStat ) == 0 ) + if( stat( pszFileName, &sStat ) == 0 ) { time_t ftime; struct tm ft; @@ -986,8 +986,8 @@ BOOL hb_fsGetFileTime( BYTE * pszFileName, LONG * plJulian, LONG * plMillisec ) hb_fsSetIOError( fResult, 0 ); hb_vmLock(); - if( fFree ) - hb_xfree( pszFileName ); + if( pszFree ) + hb_xfree( pszFree ); } #else { @@ -1002,23 +1002,23 @@ BOOL hb_fsGetFileTime( BYTE * pszFileName, LONG * plJulian, LONG * plMillisec ) return fResult; } -BOOL hb_fsGetAttr( BYTE * pszFileName, ULONG * pulAttr ) +BOOL hb_fsGetAttr( const char * pszFileName, ULONG * pulAttr ) { BOOL fResult; - BOOL fFree; + char * pszFree; HB_TRACE(HB_TR_DEBUG, ("hb_fsGetAttr(%s, %p)", pszFileName, pulAttr)); *pulAttr = 0; fResult = FALSE; - pszFileName = hb_fsNameConv( pszFileName, &fFree ); + pszFileName = hb_fsNameConv( pszFileName, &pszFree ); #if defined( HB_OS_WIN ) { DWORD dwAttr; hb_vmUnlock(); - dwAttr = GetFileAttributesA( ( char * ) pszFileName ); + dwAttr = GetFileAttributesA( pszFileName ); if( dwAttr != INVALID_FILE_ATTRIBUTES ) { @@ -1032,11 +1032,11 @@ BOOL hb_fsGetAttr( BYTE * pszFileName, ULONG * pulAttr ) hb_vmUnlock(); { #if defined( __DJGPP__ ) || defined(__BORLANDC__) - int attr = _chmod( ( char * ) pszFileName, 0, 0 ); + int attr = _chmod( pszFileName, 0, 0 ); if( attr != -1 ) #else unsigned int attr = 0; - if( _dos_getfileattr( ( char * ) pszFileName, &attr ) == 0 ) + if( _dos_getfileattr( pszFileName, &attr ) == 0 ) #endif { *pulAttr = hb_fsAttrFromRaw( attr ); @@ -1065,7 +1065,7 @@ BOOL hb_fsGetAttr( BYTE * pszFileName, ULONG * pulAttr ) struct stat sStat; hb_vmUnlock(); - if( stat( ( char * ) pszFileName, &sStat ) == 0 ) + if( stat( pszFileName, &sStat ) == 0 ) { *pulAttr = hb_fsAttrFromRaw( sStat.st_mode ); fResult = TRUE; @@ -1082,13 +1082,13 @@ BOOL hb_fsGetAttr( BYTE * pszFileName, ULONG * pulAttr ) } #endif - if( fFree ) - hb_xfree( pszFileName ); + if( pszFree ) + hb_xfree( pszFree ); return fResult; } -BOOL hb_fsSetFileTime( BYTE * pszFileName, LONG lJulian, LONG lMillisec ) +BOOL hb_fsSetFileTime( const char * pszFileName, LONG lJulian, LONG lMillisec ) { BOOL fResult; int iYear, iMonth, iDay; @@ -1140,9 +1140,9 @@ BOOL hb_fsSetFileTime( BYTE * pszFileName, LONG lJulian, LONG lMillisec ) { FILESTATUS3 fs3; APIRET ulrc; - BOOL fFree; + char * pszFree; - pszFileName = hb_fsNameConv( pszFileName, &fFree ); + pszFileName = hb_fsNameConv( pszFileName, &pszFree ); hb_vmUnlock(); ulrc = DosQueryPathInfo( ( PCSZ ) pszFileName, FIL_STANDARD, &fs3, sizeof( fs3 ) ); @@ -1185,19 +1185,19 @@ BOOL hb_fsSetFileTime( BYTE * pszFileName, LONG lJulian, LONG lMillisec ) fResult = ulrc == NO_ERROR; hb_fsSetIOError( fResult, 0 ); hb_vmLock(); - if( fFree ) - hb_xfree( pszFileName ); + if( pszFree ) + hb_xfree( pszFree ); } #elif defined( HB_OS_UNIX_COMPATIBLE ) || defined( HB_OS_DOS ) { - BOOL fFree; + char * pszFree; - pszFileName = hb_fsNameConv( pszFileName, &fFree ); + pszFileName = hb_fsNameConv( pszFileName, &pszFree ); hb_vmUnlock(); if( lJulian <= 0 && lMillisec ) { - fResult = utime( ( char * ) pszFileName, NULL ) == 0; + fResult = utime( pszFileName, NULL ) == 0; } else { @@ -1241,20 +1241,20 @@ BOOL hb_fsSetFileTime( BYTE * pszFileName, LONG lJulian, LONG lMillisec ) struct timeval times[2]; times[ 0 ].tv_sec = times[ 1 ].tv_sec = mktime( &new_value ); times[ 0 ].tv_usec = times[ 1 ].tv_usec = iMSec * 1000; - fResult = utimes( ( char * ) pszFileName, times ) == 0; + fResult = utimes( pszFileName, times ) == 0; } #else { struct utimbuf buf; buf.actime = buf.modtime = mktime( &new_value ); - fResult = utime( ( char * ) pszFileName, &buf ) == 0; + fResult = utime( pszFileName, &buf ) == 0; } #endif } hb_fsSetIOError( fResult, 0 ); hb_vmLock(); - if( fFree ) - hb_xfree( pszFileName ); + if( pszFree ) + hb_xfree( pszFree ); } #else { @@ -1268,14 +1268,14 @@ BOOL hb_fsSetFileTime( BYTE * pszFileName, LONG lJulian, LONG lMillisec ) return fResult; } -BOOL hb_fsSetAttr( BYTE * pszFileName, ULONG ulAttr ) +BOOL hb_fsSetAttr( const char * pszFileName, ULONG ulAttr ) { BOOL fResult; - BOOL fFree; + char * pszFree; HB_TRACE(HB_TR_DEBUG, ("hb_fsSetAttr(%s, %lu)", pszFileName, ulAttr)); - pszFileName = hb_fsNameConv( pszFileName, &fFree ); + pszFileName = hb_fsNameConv( pszFileName, &pszFree ); #if defined( HB_OS_WIN ) { @@ -1290,7 +1290,7 @@ BOOL hb_fsSetAttr( BYTE * pszFileName, ULONG ulAttr ) if( ulAttr & HB_FA_NORMAL ) dwFlags |= FILE_ATTRIBUTE_NORMAL; hb_vmUnlock(); - fResult = SetFileAttributesA( ( char * ) pszFileName, dwFlags ); + fResult = SetFileAttributesA( pszFileName, dwFlags ); hb_fsSetIOError( fResult, 0 ); hb_vmLock(); } @@ -1326,9 +1326,9 @@ BOOL hb_fsSetAttr( BYTE * pszFileName, ULONG ulAttr ) ulAttr &= ~( HB_FA_ARCHIVE | HB_FA_HIDDEN | HB_FA_READONLY | HB_FA_SYSTEM ); hb_vmUnlock(); # if defined( __DJGPP__ ) || defined( __BORLANDC__ ) - fResult = _chmod( ( char * ) pszFileName, 1, ulAttr ) != -1; + fResult = _chmod( pszFileName, 1, ulAttr ) != -1; # else - fResult = _dos_setfileattr( ( char * ) pszFileName, ulAttr ) != -1; + fResult = _dos_setfileattr( pszFileName, ulAttr ) != -1; # endif hb_fsSetIOError( fResult, 0 ); hb_vmLock(); @@ -1353,7 +1353,7 @@ BOOL hb_fsSetAttr( BYTE * pszFileName, ULONG ulAttr ) } } hb_vmUnlock(); - fResult = chmod( ( char * ) pszFileName, iAttr ) != -1; + fResult = chmod( pszFileName, iAttr ) != -1; hb_fsSetIOError( fResult, 0 ); hb_vmLock(); } @@ -1366,8 +1366,8 @@ BOOL hb_fsSetAttr( BYTE * pszFileName, ULONG ulAttr ) } #endif - if( fFree ) - hb_xfree( pszFileName ); + if( pszFree ) + hb_xfree( pszFree ); return fResult; } @@ -1590,7 +1590,7 @@ ULONG hb_fsWriteLarge( HB_FHANDLE hFileHandle, const BYTE * pBuff, ULONG ulCount ULONG ulLeftToWrite = ulCount; USHORT uiToWrite; USHORT uiWritten; - BYTE * pPtr = ( BYTE * ) pBuff; + const BYTE * pPtr = pBuff; ulWritten = 0; @@ -2382,26 +2382,26 @@ ULONG hb_fsTell( HB_FHANDLE hFileHandle ) return hb_fsSeek( hFileHandle, 0, FS_RELATIVE ); } -BOOL hb_fsDelete( BYTE * pFilename ) +BOOL hb_fsDelete( const char * pFilename ) { BOOL bResult; - BOOL fFree; + char * pszFree; - HB_TRACE(HB_TR_DEBUG, ("hb_fsDelete(%s)", (char*) pFilename)); + HB_TRACE(HB_TR_DEBUG, ("hb_fsDelete(%s)", pFilename)); - pFilename = hb_fsNameConv( pFilename, &fFree ); + pFilename = hb_fsNameConv( pFilename, &pszFree ); #if defined(HB_OS_WIN) hb_vmUnlock(); - bResult = DeleteFileA( ( char * ) pFilename ); + bResult = DeleteFileA( pFilename ); hb_fsSetIOError( bResult, 0 ); hb_vmLock(); #elif defined(HB_FS_FILE_IO) hb_vmUnlock(); - bResult = ( remove( ( char * ) pFilename ) == 0 ); + bResult = ( remove( pFilename ) == 0 ); hb_fsSetIOError( bResult, 0 ); hb_vmLock(); @@ -2412,33 +2412,33 @@ BOOL hb_fsDelete( BYTE * pFilename ) #endif - if( fFree ) - hb_xfree( pFilename ); + if( pszFree ) + hb_xfree( pszFree ); return bResult; } -BOOL hb_fsRename( BYTE * pOldName, BYTE * pNewName ) +BOOL hb_fsRename( const char * pOldName, const char * pNewName ) { BOOL bResult; - BOOL fFreeOld, fFreeNew; + char * pszFreeOld, * pszFreeNew; - HB_TRACE(HB_TR_DEBUG, ("hb_fsRename(%s, %s)", (char*) pOldName, (char*) pNewName)); + HB_TRACE(HB_TR_DEBUG, ("hb_fsRename(%s, %s)", pOldName, pNewName)); - pOldName = hb_fsNameConv( pOldName, &fFreeOld ); - pNewName = hb_fsNameConv( pNewName, &fFreeNew ); + pOldName = hb_fsNameConv( pOldName, &pszFreeOld ); + pNewName = hb_fsNameConv( pNewName, &pszFreeNew ); #if defined(HB_OS_WIN) hb_vmUnlock(); - bResult = MoveFileA( ( char * ) pOldName, ( char * ) pNewName ); + bResult = MoveFileA( pOldName, pNewName ); hb_fsSetIOError( bResult, 0 ); hb_vmLock(); #elif defined(HB_FS_FILE_IO) hb_vmUnlock(); - bResult = ( rename( ( char * ) pOldName, ( char * ) pNewName ) == 0 ); + bResult = ( rename( pOldName, pNewName ) == 0 ); hb_fsSetIOError( bResult, 0 ); hb_vmLock(); @@ -2449,29 +2449,29 @@ BOOL hb_fsRename( BYTE * pOldName, BYTE * pNewName ) #endif - if( fFreeOld ) - hb_xfree( pOldName ); - if( fFreeNew ) - hb_xfree( pNewName ); + if( pszFreeOld ) + hb_xfree( pszFreeOld ); + if( pszFreeNew ) + hb_xfree( pszFreeNew ); return bResult; } -BOOL hb_fsMkDir( BYTE * pDirname ) +BOOL hb_fsMkDir( const char * pDirname ) { BOOL bResult; - BOOL fFree; + char * pszFree; - HB_TRACE(HB_TR_DEBUG, ("hb_fsMkDir(%s)", (char*) pDirname)); + HB_TRACE(HB_TR_DEBUG, ("hb_fsMkDir(%s)", pDirname)); - pDirname = hb_fsNameConv( pDirname, &fFree ); + pDirname = hb_fsNameConv( pDirname, &pszFree ); - HB_TRACE(HB_TR_DEBUG, ("hb_fsMkDir(%s)", (char*) pDirname)); + HB_TRACE(HB_TR_DEBUG, ("hb_fsMkDir(%s)", pDirname)); #if defined(HB_OS_WIN) hb_vmUnlock(); - bResult = CreateDirectoryA( ( char * ) pDirname, NULL ); + bResult = CreateDirectoryA( pDirname, NULL ); hb_fsSetIOError( bResult, 0 ); hb_vmLock(); @@ -2481,9 +2481,9 @@ BOOL hb_fsMkDir( BYTE * pDirname ) # if ! defined(HB_OS_UNIX) && \ ( defined(__WATCOMC__) || defined(__BORLANDC__) || \ defined(__IBMCPP__) || defined(__MINGW32__) ) - bResult = ( mkdir( ( char * ) pDirname ) == 0 ); + bResult = ( mkdir( pDirname ) == 0 ); # else - bResult = ( mkdir( ( char * ) pDirname, S_IRWXU | S_IRWXG | S_IRWXO ) == 0 ); + bResult = ( mkdir( pDirname, S_IRWXU | S_IRWXG | S_IRWXO ) == 0 ); # endif hb_fsSetIOError( bResult, 0 ); hb_vmLock(); @@ -2495,32 +2495,32 @@ BOOL hb_fsMkDir( BYTE * pDirname ) #endif - if( fFree ) - hb_xfree( pDirname ); + if( pszFree ) + hb_xfree( pszFree ); return bResult; } -BOOL hb_fsChDir( BYTE * pDirname ) +BOOL hb_fsChDir( const char * pDirname ) { BOOL bResult; - BOOL fFree; + char * pszFree; - HB_TRACE(HB_TR_DEBUG, ("hb_fsChDir(%s)", (char*) pDirname)); + HB_TRACE(HB_TR_DEBUG, ("hb_fsChDir(%s)", pDirname)); - pDirname = hb_fsNameConv( pDirname, &fFree ); + pDirname = hb_fsNameConv( pDirname, &pszFree ); #if defined(HB_OS_WIN) hb_vmUnlock(); - bResult = SetCurrentDirectoryA( ( char * ) pDirname ); + bResult = SetCurrentDirectoryA( pDirname ); hb_fsSetIOError( bResult, 0 ); hb_vmLock(); #elif defined(HAVE_POSIX_IO) || defined(__MINGW32__) hb_vmUnlock(); - bResult = ( chdir( ( char * ) pDirname ) == 0 ); + bResult = ( chdir( pDirname ) == 0 ); hb_fsSetIOError( bResult, 0 ); hb_vmLock(); @@ -2531,32 +2531,32 @@ BOOL hb_fsChDir( BYTE * pDirname ) #endif - if( fFree ) - hb_xfree( pDirname ); + if( pszFree ) + hb_xfree( pszFree ); return bResult; } -BOOL hb_fsRmDir( BYTE * pDirname ) +BOOL hb_fsRmDir( const char * pDirname ) { BOOL bResult; - BOOL fFree; + char * pszFree; - HB_TRACE(HB_TR_DEBUG, ("hb_fsRmDir(%s)", (char*) pDirname)); + HB_TRACE(HB_TR_DEBUG, ("hb_fsRmDir(%s)", pDirname)); - pDirname = hb_fsNameConv( pDirname, &fFree ); + pDirname = hb_fsNameConv( pDirname, &pszFree ); #if defined(HB_OS_WIN) hb_vmUnlock(); - bResult = RemoveDirectoryA( ( char * ) pDirname ); + bResult = RemoveDirectoryA( pDirname ); hb_fsSetIOError( bResult, 0 ); hb_vmLock(); #elif defined(HAVE_POSIX_IO) || defined(__MINGW32__) hb_vmUnlock(); - bResult = ( rmdir( ( char * ) pDirname ) == 0 ); + bResult = ( rmdir( pDirname ) == 0 ); hb_fsSetIOError( bResult, 0 ); hb_vmLock(); @@ -2567,8 +2567,8 @@ BOOL hb_fsRmDir( BYTE * pDirname ) #endif - if( fFree ) - hb_xfree( pDirname ); + if( pszFree ) + hb_xfree( pszFree ); return bResult; } @@ -2576,30 +2576,31 @@ BOOL hb_fsRmDir( BYTE * pDirname ) /* NOTE: This is not thread safe function, it's there for compatibility. */ /* NOTE: 0 = current drive, 1 = A, 2 = B, 3 = C, etc. */ -BYTE * hb_fsCurDir( USHORT uiDrive ) +const char * hb_fsCurDir( USHORT uiDrive ) { - BYTE * pbyDirBuffer; + char * pszDirBuffer; HB_TRACE(HB_TR_DEBUG, ("hb_fsCurDir(%hu)", uiDrive)); - pbyDirBuffer = hb_stackDirBuffer(); - hb_fsCurDirBuff( uiDrive, pbyDirBuffer, HB_PATH_MAX ); + pszDirBuffer = hb_stackDirBuffer(); + hb_fsCurDirBuff( uiDrive, pszDirBuffer, HB_PATH_MAX ); - return ( BYTE * ) pbyDirBuffer; + return pszDirBuffer; } /* NOTE: Thread safe version of hb_fsCurDir() */ /* NOTE: 0 = current drive, 1 = A, 2 = B, 3 = C, etc. */ -USHORT hb_fsCurDirBuff( USHORT uiDrive, BYTE * pbyBuffer, ULONG ulLen ) +USHORT hb_fsCurDirBuff( USHORT uiDrive, char * pszBuffer, ULONG ulSize ) { USHORT uiCurDrv = uiDrive, usError; - BYTE * pbyStart; + char * pszStart; + ULONG ulLen; BOOL fResult; HB_TRACE(HB_TR_DEBUG, ("hb_fsCurDirBuff(%hu)", uiDrive)); - pbyBuffer[ 0 ] = '\0'; + pszBuffer[ 0 ] = '\0'; /* * do not cover this code by HB_OS_HAS_DRIVE_LETTER macro @@ -2620,28 +2621,28 @@ USHORT hb_fsCurDirBuff( USHORT uiDrive, BYTE * pbyBuffer, ULONG ulLen ) #if defined(HB_OS_WIN) hb_vmUnlock(); - fResult = GetCurrentDirectoryA( ulLen, ( char * ) pbyBuffer ); + fResult = GetCurrentDirectoryA( ulSize, pszBuffer ); hb_fsSetIOError( fResult, 0 ); hb_vmLock(); #elif defined(HB_OS_OS2) && defined(__GNUC__) hb_vmUnlock(); - fResult = ( _getcwd1( ( char * ) pbyBuffer, uiDrive + 'A' - 1 ) == 0 ); + fResult = ( _getcwd1( pszBuffer, uiDrive + 'A' - 1 ) == 0 ); hb_fsSetIOError( fResult, 0 ); hb_vmLock(); #elif defined(__MINGW32__) hb_vmUnlock(); - fResult = ( _getdcwd( uiDrive, pbyBuffer, ulLen ) != NULL ); + fResult = ( _getdcwd( uiDrive, pszBuffer, ulSize ) != NULL ); hb_fsSetIOError( fResult, 0 ); hb_vmLock(); #elif defined(HAVE_POSIX_IO) hb_vmUnlock(); - fResult = ( getcwd( ( char * ) pbyBuffer, ulLen ) != NULL ); + fResult = ( getcwd( pszBuffer, ulSize ) != NULL ); hb_fsSetIOError( fResult, 0 ); hb_vmLock(); @@ -2660,9 +2661,9 @@ USHORT hb_fsCurDirBuff( USHORT uiDrive, BYTE * pbyBuffer, ULONG ulLen ) hb_fsSetError( usError ); } - pbyBuffer[ ulLen - 1 ] = '\0'; + pszBuffer[ ulSize - 1 ] = '\0'; - if( usError == 0 && pbyBuffer[ 0 ] ) + if( usError == 0 && pszBuffer[ 0 ] ) { /* Strip the leading drive spec, and leading backslash if there's one. */ /* NOTE: A trailing underscore is not returned on this platform, @@ -2670,44 +2671,44 @@ USHORT hb_fsCurDirBuff( USHORT uiDrive, BYTE * pbyBuffer, ULONG ulLen ) #if defined(__DJGPP__) /* convert '/' to '\' */ - while( ( pbyStart = ( BYTE * ) strchr( ( char * ) pbyBuffer, '/' ) ) != NULL ) - *pbyStart = '\\'; + while( ( pszStart = strchr( pszBuffer, '/' ) ) != NULL ) + *pszStart = '\\'; #endif - pbyStart = pbyBuffer; - ulLen = strlen( ( char * ) pbyBuffer ); + pszStart = pszBuffer; + ulLen = strlen( pszBuffer ); #if defined(HB_OS_HAS_DRIVE_LETTER) - if( pbyStart[ 1 ] == HB_OS_DRIVE_DELIM_CHR ) + if( pszStart[ 1 ] == HB_OS_DRIVE_DELIM_CHR ) { - pbyStart += 2; + pszStart += 2; ulLen -= 2; } #endif - if( strchr( HB_OS_PATH_DELIM_CHR_LIST, pbyStart[ 0 ] ) ) + if( strchr( HB_OS_PATH_DELIM_CHR_LIST, ( UCHAR ) pszStart[ 0 ] ) ) { - pbyStart++; + pszStart++; ulLen--; } /* Strip the trailing (back)slash if there's one */ - if( ulLen && strchr( HB_OS_PATH_DELIM_CHR_LIST, pbyStart[ ulLen - 1 ] ) ) + if( ulLen && strchr( HB_OS_PATH_DELIM_CHR_LIST, ( UCHAR ) pszStart[ ulLen - 1 ] ) ) ulLen--; - if( ulLen && pbyBuffer != pbyStart ) - memmove( pbyBuffer, pbyStart, ulLen ); + if( ulLen && pszBuffer != pszStart ) + memmove( pszBuffer, pszStart, ulLen ); - pbyBuffer[ ulLen ] = '\0'; + pszBuffer[ ulLen ] = '\0'; /* Convert from OS codepage */ { - BOOL fFree; - BYTE * pbyResult = hb_osDecode( pbyBuffer, &fFree ); + char * pszFree; + const char * pszResult = hb_osDecode( pszBuffer, &pszFree ); - if( pbyResult != pbyBuffer ) - hb_strncpy( ( char * ) pbyBuffer, ( char * ) pbyResult, ulLen - 1 ); - if( fFree ) - hb_xfree( pbyResult ); + if( pszResult != pszBuffer ) + hb_strncpy( pszBuffer, pszResult, ulSize - 1 ); + if( pszFree ) + hb_xfree( pszFree ); } } @@ -2806,7 +2807,7 @@ USHORT hb_fsIsDrv( BYTE nDrive ) buffer[ 3 ] = '\0'; hb_vmUnlock(); - type = GetDriveTypeA( ( LPCSTR ) buffer ); + type = GetDriveTypeA( buffer ); hb_vmLock(); uiResult = ( type == DRIVE_UNKNOWN || type == DRIVE_NO_ROOT_DIR ) ? F_ERROR : 0; hb_fsSetError( 0 ); @@ -2885,35 +2886,35 @@ BOOL hb_fsIsDevice( HB_FHANDLE hFileHandle ) /* convert file name for hb_fsExtOpen * caller must free the returned buffer */ -BYTE * hb_fsExtName( BYTE * pFilename, BYTE * pDefExt, - USHORT uiExFlags, BYTE * pPaths ) +char * hb_fsExtName( const char * pFilename, const char * pDefExt, + USHORT uiExFlags, const char * pPaths ) { HB_PATHNAMES * pNextPath; PHB_FNAME pFilepath; BOOL fIsFile = FALSE; - BYTE * szPath; + char * szPath; - szPath = ( BYTE * ) hb_xgrab( HB_PATH_MAX ); + szPath = ( char * ) hb_xgrab( HB_PATH_MAX ); - pFilepath = hb_fsFNameSplit( ( char * ) pFilename ); + pFilepath = hb_fsFNameSplit( pFilename ); if( pDefExt && ( ( uiExFlags & FXO_FORCEEXT ) || !pFilepath->szExtension ) ) { - pFilepath->szExtension = ( char * ) pDefExt; + pFilepath->szExtension = pDefExt; } if( pFilepath->szPath ) { - hb_fsFNameMerge( ( char * ) szPath, pFilepath ); + hb_fsFNameMerge( szPath, pFilepath ); } else if( uiExFlags & FXO_DEFAULTS ) { - char * szDefault = hb_setGetDefault(); + const char * szDefault = hb_setGetDefault(); if( szDefault ) { pFilepath->szPath = szDefault; - hb_fsFNameMerge( ( char * ) szPath, pFilepath ); - fIsFile = hb_fsFileExists( ( const char * ) szPath ); + hb_fsFNameMerge( szPath, pFilepath ); + fIsFile = hb_fsFileExists( szPath ); } if( !fIsFile && ( uiExFlags & ( FXO_TRUNCATE | FXO_APPEND | FXO_UNIQUE ) ) == 0 && @@ -2923,52 +2924,52 @@ BYTE * hb_fsExtName( BYTE * pFilename, BYTE * pDefExt, while( !fIsFile && pNextPath ) { pFilepath->szPath = pNextPath->szPath; - hb_fsFNameMerge( ( char * ) szPath, pFilepath ); - fIsFile = hb_fsFileExists( ( const char * ) szPath ); + hb_fsFNameMerge( szPath, pFilepath ); + fIsFile = hb_fsFileExists( szPath ); pNextPath = pNextPath->pNext; } } if( !fIsFile ) { pFilepath->szPath = szDefault ? szDefault : NULL; - hb_fsFNameMerge( ( char * ) szPath, pFilepath ); + hb_fsFNameMerge( szPath, pFilepath ); } } else if( pPaths && *pPaths ) { HB_PATHNAMES * pSearchPath = NULL; - hb_fsAddSearchPath( ( char * ) pPaths, &pSearchPath ); + hb_fsAddSearchPath( pPaths, &pSearchPath ); pNextPath = pSearchPath; while( !fIsFile && pNextPath ) { pFilepath->szPath = pNextPath->szPath; - hb_fsFNameMerge( ( char * ) szPath, pFilepath ); - fIsFile = hb_fsFileExists( ( const char * ) szPath ); + hb_fsFNameMerge( szPath, pFilepath ); + fIsFile = hb_fsFileExists( szPath ); pNextPath = pNextPath->pNext; } hb_fsFreeSearchPath( pSearchPath ); if( !fIsFile ) { pFilepath->szPath = NULL; - hb_fsFNameMerge( ( char * ) szPath, pFilepath ); + hb_fsFNameMerge( szPath, pFilepath ); } } else { - hb_fsFNameMerge( ( char * ) szPath, pFilepath ); + hb_fsFNameMerge( szPath, pFilepath ); } hb_xfree( pFilepath ); return szPath; } -HB_FHANDLE hb_fsExtOpen( BYTE * pFilename, BYTE * pDefExt, - USHORT uiExFlags, BYTE * pPaths, - PHB_ITEM pError ) +HB_FHANDLE hb_fsExtOpen( const char * pFilename, const char * pDefExt, + USHORT uiExFlags, const char * pPaths, + PHB_ITEM pError ) { HB_FHANDLE hFile; USHORT uiFlags; - BYTE * szPath; + char * szPath; HB_TRACE(HB_TR_DEBUG, ("hb_fsExtOpen(%s, %s, %hu, %p, %p)", pFilename, pDefExt, uiExFlags, pPaths, pError)); @@ -3062,7 +3063,7 @@ HB_FHANDLE hb_fsExtOpen( BYTE * pFilename, BYTE * pDefExt, if( pError ) { - hb_errPutFileName( pError, ( char * ) szPath ); + hb_errPutFileName( pError, szPath ); if( hFile == FS_ERROR ) { hb_errPutOsCode( pError, hb_fsError() ); @@ -3071,7 +3072,7 @@ HB_FHANDLE hb_fsExtOpen( BYTE * pFilename, BYTE * pDefExt, } if( uiExFlags & FXO_COPYNAME && hFile != FS_ERROR ) - hb_strncpy( ( char * ) pFilename, ( char * ) szPath, HB_PATH_MAX - 1 ); + hb_strncpy( ( char * ) pFilename, szPath, HB_PATH_MAX - 1 ); hb_xfree( szPath ); return hFile; @@ -3116,12 +3117,13 @@ BOOL hb_fsEof( HB_FHANDLE hFileHandle ) return fResult; } -BYTE * hb_fsNameConv( BYTE * szFileName, BOOL * pfFree ) +const char * hb_fsNameConv( const char * szFileName, char ** pszFree ) { int iFileCase, iDirCase; + const char * pszCP; char cDirSep; BOOL fTrim; - BOOL bCPConv; + /* Convert file and dir case. The allowed SET options are: LOWER - Convert all caracters of file to lower @@ -3135,61 +3137,50 @@ BYTE * hb_fsNameConv( BYTE * szFileName, BOOL * pfFree ) TRIMFILENAME - strip trailing and leading spaces (also from extension) */ + if( pszFree ) + *pszFree = NULL; + if( !hb_stackId() ) - { - if( pfFree ) - *pfFree = FALSE; return szFileName; - } fTrim = hb_setGetTrimFileName(); cDirSep = ( char ) hb_setGetDirSeparator(); iFileCase = hb_setGetFileCase(); iDirCase = hb_setGetDirCase(); - bCPConv = hb_setGetOSCODEPAGE() && hb_setGetOSCODEPAGE()[ 0 ]; + pszCP = hb_setGetOSCODEPAGE(); + if( pszCP && *pszCP == 0 ) + pszCP = NULL; if( fTrim || cDirSep != HB_OS_PATH_DELIM_CHR || iFileCase != HB_SET_CASE_MIXED || iDirCase != HB_SET_CASE_MIXED || - bCPConv ) + pszCP ) { PHB_FNAME pFileName; ULONG ulLen; - if( pfFree ) + if( pszCP ) + szFileName = hb_osEncode( szFileName, pszFree ); + + if( pszFree && *pszFree == NULL ) { - BYTE * szNew = ( BYTE * ) hb_xgrab( HB_PATH_MAX ); - hb_strncpy( ( char * ) szNew, ( char * ) szFileName, HB_PATH_MAX - 1 ); - szFileName = szNew; - *pfFree = TRUE; + szFileName = *pszFree = hb_strncpy( ( char * ) hb_xgrab( HB_PATH_MAX ), + szFileName, HB_PATH_MAX - 1 ); } - if( cDirSep != HB_OS_PATH_DELIM_CHR || bCPConv ) + if( cDirSep != HB_OS_PATH_DELIM_CHR ) { - BYTE * p = szFileName; - + char * p = ( char * ) szFileName; while( *p ) { - if( cDirSep != HB_OS_PATH_DELIM_CHR && *p == cDirSep ) + if( *p == cDirSep ) *p = HB_OS_PATH_DELIM_CHR; p++; } } - if( bCPConv ) - { - BOOL fFree; - BYTE * pbyResult = hb_osEncode( ( BYTE * ) szFileName, &fFree ); - - if( fFree ) - { - hb_strncpy( ( char * ) szFileName, ( char * ) pbyResult, HB_PATH_MAX - 1 ); - hb_xfree( pbyResult ); - } - } - - pFileName = hb_fsFNameSplit( ( char * ) szFileName ); + pFileName = hb_fsFNameSplit( szFileName ); /* strip trailing and leading spaces */ if( fTrim ) @@ -3238,34 +3229,32 @@ BYTE * hb_fsNameConv( BYTE * szFileName, BOOL * pfFree ) hb_fsFNameMerge( ( char * ) szFileName, pFileName ); hb_xfree( pFileName ); } - else if( pfFree ) - *pfFree = FALSE; return szFileName; } -/* NOTE: pbyBuffer must be HB_PATH_MAX long. */ -void hb_fsBaseDirBuff( BYTE * pbyBuffer ) +/* NOTE: pszBuffer must be HB_PATH_MAX long. */ +void hb_fsBaseDirBuff( char * pszBuffer ) { const char * szBaseName = hb_cmdargARGVN( 0 ); if( szBaseName ) { PHB_FNAME pFName = hb_fsFNameSplit( szBaseName ); - BYTE * pbyResult; - BOOL fFree; + const char * pszResult; + char * pszFree; pFName->szName = NULL; pFName->szExtension = NULL; - hb_fsFNameMerge( ( char * ) pbyBuffer, pFName ); + hb_fsFNameMerge( pszBuffer, pFName ); hb_xfree( pFName ); /* Convert from OS codepage */ - pbyResult = hb_osDecode( pbyBuffer, &fFree ); - if( pbyResult != pbyBuffer ) - hb_strncpy( ( char * ) pbyBuffer, ( char * ) pbyResult, HB_PATH_MAX - 1 ); - if( fFree ) - hb_xfree( pbyResult ); + pszResult = hb_osDecode( pszBuffer, &pszFree ); + if( pszResult != pszBuffer ) + hb_strncpy( pszBuffer, pszResult, HB_PATH_MAX - 1 ); + if( pszFree ) + hb_xfree( pszFree ); } } diff --git a/harbour/source/rtl/fscopy.c b/harbour/source/rtl/fscopy.c index e8938f9ebc..e0a234841b 100644 --- a/harbour/source/rtl/fscopy.c +++ b/harbour/source/rtl/fscopy.c @@ -55,15 +55,15 @@ #define HB_FSCOPY_BUFFERSIZE 16384 -BOOL hb_fsCopy( const BYTE * pSource, const BYTE * pDest ) +BOOL hb_fsCopy( const char * pszSource, const char * pszDest ) { BOOL bRetVal = TRUE; HB_FHANDLE fhndSource; HB_FHANDLE fhndDest; - if( ( fhndSource = hb_fsOpen( ( BYTE * ) pSource, FO_READ | FO_DENYNONE ) ) != FS_ERROR ) + if( ( fhndSource = hb_fsOpen( pszSource, FO_READ | FO_DENYNONE ) ) != FS_ERROR ) { - if( ( fhndDest = hb_fsCreate( ( BYTE * ) pDest, FC_NORMAL ) ) != FS_ERROR ) + if( ( fhndDest = hb_fsCreate( pszDest, FC_NORMAL ) ) != FS_ERROR ) { USHORT nBytesRead; BYTE * pbyBuffer = ( BYTE * ) hb_xgrab( HB_FSCOPY_BUFFERSIZE ); @@ -95,11 +95,11 @@ BOOL hb_fsCopy( const BYTE * pSource, const BYTE * pDest ) HB_FUNC( HB_FCOPY ) { USHORT uiError = 2; + const char * pszSource = hb_parc( 1 ), * pszDest = hb_parc( 2 ); - if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) + if( pszSource && pszDest ) { - hb_retni( hb_fsCopy( ( BYTE * ) hb_parc( 1 ), - ( BYTE * ) hb_parc( 2 ) ) ? 0 : F_ERROR ); + hb_retni( hb_fsCopy( pszSource, pszDest ) ? 0 : F_ERROR ); uiError = hb_fsError(); } else diff --git a/harbour/source/rtl/fssize.c b/harbour/source/rtl/fssize.c index c433f33ce6..262451bad3 100644 --- a/harbour/source/rtl/fssize.c +++ b/harbour/source/rtl/fssize.c @@ -78,17 +78,17 @@ #endif -HB_FOFFSET hb_fsFSize( BYTE * pszFileName, BOOL bUseDirEntry ) +HB_FOFFSET hb_fsFSize( const char * pszFileName, BOOL bUseDirEntry ) { if( bUseDirEntry ) { #if defined(HB_OS_WIN_CE) - BOOL fFree; + char * pszFree; PHB_FFIND ffind; - pszFileName = hb_fsNameConv( pszFileName, &fFree ); - ffind = hb_fsFindFirst( ( char * ) pszFileName, HB_FA_ALL ); - if( fFree ) - hb_xfree( pszFileName ); + pszFileName = hb_fsNameConv( pszFileName, &pszFree ); + ffind = hb_fsFindFirst( pszFileName, HB_FA_ALL ); + if( pszFree ) + hb_xfree( pszFree ); hb_fsSetIOError( ffind != NULL, 0 ); if( ffind ) { @@ -97,27 +97,29 @@ HB_FOFFSET hb_fsFSize( BYTE * pszFileName, BOOL bUseDirEntry ) return size; } #elif defined( HB_USE_LARGEFILE64 ) - BOOL fResult, fFree; + char * pszFree; + BOOL fResult; struct stat64 statbuf; - pszFileName = hb_fsNameConv( pszFileName, &fFree ); + pszFileName = hb_fsNameConv( pszFileName, &pszFree ); hb_vmUnlock(); - fResult = stat64( ( char * ) pszFileName, &statbuf ) == 0; + fResult = stat64( pszFileName, &statbuf ) == 0; hb_fsSetIOError( fResult, 0 ); hb_vmLock(); - if( fFree ) - hb_xfree( pszFileName ); + if( pszFree ) + hb_xfree( pszFree ); if( fResult ) return ( HB_FOFFSET ) statbuf.st_size; #else - BOOL fResult, fFree; + char * pszFree; + BOOL fResult; struct stat statbuf; - pszFileName = hb_fsNameConv( pszFileName, &fFree ); + pszFileName = hb_fsNameConv( pszFileName, &pszFree ); hb_vmUnlock(); fResult = stat( ( char * ) pszFileName, &statbuf ) == 0; hb_fsSetIOError( fResult, 0 ); hb_vmLock(); - if( fFree ) - hb_xfree( pszFileName ); + if( pszFree ) + hb_xfree( pszFree ); if( fResult ) return ( HB_FOFFSET ) statbuf.st_size; #endif @@ -140,6 +142,6 @@ HB_FOFFSET hb_fsFSize( BYTE * pszFileName, BOOL bUseDirEntry ) HB_FUNC( HB_FSIZE ) { - hb_retnint( HB_ISCHAR( 1 ) ? hb_fsFSize( ( BYTE * ) hb_parc( 1 ), - HB_ISLOG( 2 ) ? hb_parl( 2 ) : TRUE ) : 0 ); + const char * pszFile = hb_parc( 1 ); + hb_retnint( pszFile ? hb_fsFSize( pszFile, HB_ISLOG( 2 ) ? hb_parl( 2 ) : TRUE ) : 0 ); } diff --git a/harbour/source/rtl/fstemp.c b/harbour/source/rtl/fstemp.c index c800b048d9..27791b3f5e 100644 --- a/harbour/source/rtl/fstemp.c +++ b/harbour/source/rtl/fstemp.c @@ -65,22 +65,22 @@ #endif #if !defined(HB_OS_WIN) -static BOOL fsGetTempDirByCase( BYTE * pszName, const char * pszTempDir ) +static BOOL fsGetTempDirByCase( char * pszName, const char * pszTempDir ) { BOOL fOK = FALSE; if( pszTempDir && *pszTempDir != '\0' ) { - hb_strncpy( ( char * ) pszName, ( char * ) pszTempDir, HB_PATH_MAX - 1 ); + hb_strncpy( pszName, pszTempDir, HB_PATH_MAX - 1 ); switch( hb_setGetDirCase() ) { case HB_SET_CASE_LOWER: - hb_strLower( ( char * ) pszName, strlen( ( char * ) pszName ) ); - fOK = strcmp( ( char * ) pszName, pszTempDir ) == 0; + hb_strLower( pszName, strlen( pszName ) ); + fOK = strcmp( pszName, pszTempDir ) == 0; break; case HB_SET_CASE_UPPER: - hb_strUpper( ( char * ) pszName, strlen( ( char * ) pszName ) ); - fOK = strcmp( ( char * ) pszName, pszTempDir ) == 0; + hb_strUpper( pszName, strlen( pszName ) ); + fOK = strcmp( pszName, pszTempDir ) == 0; break; default: fOK = TRUE; @@ -93,7 +93,7 @@ static BOOL fsGetTempDirByCase( BYTE * pszName, const char * pszTempDir ) { /* convert '/' to '\' */ char * pszDelim; - while( ( pszDelim = strchr( ( char * ) pszName, '/' ) ) != NULL ) + while( ( pszDelim = strchr( pszName, '/' ) ) != NULL ) *pszDelim = '\\'; } # endif @@ -102,7 +102,7 @@ static BOOL fsGetTempDirByCase( BYTE * pszName, const char * pszTempDir ) } #endif -static HB_FHANDLE hb_fsCreateTempLow( const BYTE * pszDir, const BYTE * pszPrefix, ULONG ulAttr, BYTE * pszName, const UCHAR * pszExt ) +static HB_FHANDLE hb_fsCreateTempLow( const char * pszDir, const char * pszPrefix, ULONG ulAttr, char * pszName, const char * pszExt ) { /* less attemps */ int iAttemptLeft = 99, iLen; @@ -114,12 +114,12 @@ static HB_FHANDLE hb_fsCreateTempLow( const BYTE * pszDir, const BYTE * pszPrefi if( pszDir && pszDir[ 0 ] != '\0' ) { - hb_strncpy( ( char * ) pszName, ( char * ) pszDir, HB_PATH_MAX - 1 ); + hb_strncpy( pszName, pszDir, HB_PATH_MAX - 1 ); } else { #if defined(HB_OS_WIN) - if( ! GetTempPathA( ( DWORD ) ( HB_PATH_MAX - 1 ), ( LPSTR ) pszName ) ) + if( ! GetTempPathA( ( DWORD ) ( HB_PATH_MAX - 1 ), pszName ) ) { pszName[ 0 ] = '.'; pszName[ 1 ] = '\0'; @@ -144,18 +144,18 @@ static HB_FHANDLE hb_fsCreateTempLow( const BYTE * pszDir, const BYTE * pszPrefi if( pszName[0] != '\0' ) { - int len = strlen( ( char * ) pszName ); - if( pszName[ len - 1 ] != ( BYTE ) HB_OS_PATH_DELIM_CHR ) + int len = strlen( pszName ); + if( pszName[ len - 1 ] != HB_OS_PATH_DELIM_CHR ) { - pszName[ len ] = ( BYTE ) HB_OS_PATH_DELIM_CHR; + pszName[ len ] = HB_OS_PATH_DELIM_CHR; pszName[ len + 1 ] = '\0'; } } if( pszPrefix ) - hb_strncat( ( char * ) pszName, ( char * ) pszPrefix, HB_PATH_MAX - 1 ); + hb_strncat( pszName, pszPrefix, HB_PATH_MAX - 1 ); - iLen = ( int ) strlen( ( char * ) pszName ); + iLen = ( int ) strlen( pszName ); if( iLen > ( HB_PATH_MAX - 1 ) - 6 ) return FS_ERROR; @@ -166,9 +166,9 @@ static HB_FHANDLE hb_fsCreateTempLow( const BYTE * pszDir, const BYTE * pszPrefi hb_setGetDirCase() != HB_SET_CASE_UPPER && pszExt == NULL ) { - hb_strncat( ( char * ) pszName, "XXXXXX", HB_PATH_MAX - 1 ); + hb_strncat( pszName, "XXXXXX", HB_PATH_MAX - 1 ); hb_vmUnlock(); - fd = ( HB_FHANDLE ) mkstemp( ( char * ) pszName ); + fd = ( HB_FHANDLE ) mkstemp( pszName ); hb_fsSetIOError( fd != ( HB_FHANDLE ) -1, 0 ); hb_vmLock(); } @@ -183,11 +183,11 @@ static HB_FHANDLE hb_fsCreateTempLow( const BYTE * pszDir, const BYTE * pszPrefi d = d * 36; n = ( int ) d; d = modf( d, &x ); - pszName[ iLen++ ] = ( BYTE ) ( n + ( n > 9 ? 'a' - 10 : '0' ) ); + pszName[ iLen++ ] = ( char ) ( n + ( n > 9 ? 'a' - 10 : '0' ) ); } pszName[ iLen ] = '\0'; if( pszExt ) - hb_strncat( ( char * ) pszName, ( char * ) pszExt, HB_PATH_MAX - 1 ); + hb_strncat( pszName, pszExt, HB_PATH_MAX - 1 ); hb_fsNameConv( pszName, NULL ); fd = hb_fsCreateEx( pszName, ulAttr, FO_EXCLUSIVE | FO_EXCL ); } @@ -203,7 +203,7 @@ static HB_FHANDLE hb_fsCreateTempLow( const BYTE * pszDir, const BYTE * pszPrefi /* NOTE: The buffer must be at least HB_PATH_MAX chars long */ #if !defined( HB_OS_UNIX ) -static BOOL hb_fsTempName( BYTE * pszBuffer, const BYTE * pszDir, const BYTE * pszPrefix ) +static BOOL hb_fsTempName( char * pszBuffer, const char * pszDir, const char * pszPrefix ) { BOOL fResult; @@ -211,21 +211,21 @@ static BOOL hb_fsTempName( BYTE * pszBuffer, const BYTE * pszDir, const BYTE * p #if defined(HB_IO_WIN) { - char cTempDir[ HB_PATH_MAX ]; + char szTempDir[ HB_PATH_MAX ]; if( pszDir && pszDir[ 0 ] != '\0' ) - hb_strncpy( ( char * ) cTempDir, ( const char * ) pszDir, sizeof( cTempDir ) - 1 ); + hb_strncpy( szTempDir, pszDir, sizeof( szTempDir ) - 1 ); else { - if( ! GetTempPathA( ( DWORD ) HB_PATH_MAX, cTempDir ) ) + if( ! GetTempPathA( ( DWORD ) HB_PATH_MAX, szTempDir ) ) { hb_fsSetIOError( FALSE, 0 ); return FALSE; } } - cTempDir[ HB_PATH_MAX - 1 ] = '\0'; + szTempDir[ HB_PATH_MAX - 1 ] = '\0'; - fResult = GetTempFileNameA( ( LPCSTR ) cTempDir, pszPrefix ? ( LPCSTR ) pszPrefix : ( LPCSTR ) "hb", 0, ( LPSTR ) pszBuffer ); + fResult = GetTempFileNameA( szTempDir, pszPrefix ? pszPrefix : "hb", 0, pszBuffer ); } #else @@ -238,13 +238,13 @@ static BOOL hb_fsTempName( BYTE * pszBuffer, const BYTE * pszDir, const BYTE * p at least this large. */ pszBuffer[ 0 ] = '\0'; - fResult = ( tmpnam( ( char * ) pszBuffer ) != NULL ); + fResult = ( tmpnam( pszBuffer ) != NULL ); # if defined(__DJGPP__) { /* convert '/' to '\' */ char * pszDelim; - while( ( pszDelim = strchr( ( char * ) pszBuffer, '/' ) ) != NULL ) + while( ( pszDelim = strchr( pszBuffer, '/' ) ) != NULL ) *pszDelim = '\\'; } # endif @@ -259,7 +259,7 @@ static BOOL hb_fsTempName( BYTE * pszBuffer, const BYTE * pszDir, const BYTE * p /* NOTE: The pszName buffer must be at least HB_PATH_MAX chars long */ -HB_FHANDLE hb_fsCreateTemp( const BYTE * pszDir, const BYTE * pszPrefix, ULONG ulAttr, BYTE * pszName ) +HB_FHANDLE hb_fsCreateTemp( const char * pszDir, const char * pszPrefix, ULONG ulAttr, char * pszName ) { USHORT nAttemptLeft = 999; @@ -287,7 +287,7 @@ HB_FHANDLE hb_fsCreateTemp( const BYTE * pszDir, const BYTE * pszPrefix, ULONG u } #else -HB_FHANDLE hb_fsCreateTemp( const BYTE * pszDir, const BYTE * pszPrefix, ULONG ulAttr, BYTE * pszName ) +HB_FHANDLE hb_fsCreateTemp( const char * pszDir, const char * pszPrefix, ULONG ulAttr, char * pszName ) { return hb_fsCreateTempLow( pszDir, pszPrefix, ulAttr, pszName, NULL ); } @@ -296,30 +296,30 @@ HB_FHANDLE hb_fsCreateTemp( const BYTE * pszDir, const BYTE * pszPrefix, ULONG u HB_FUNC( HB_FTEMPCREATE ) { - BYTE szName[ HB_PATH_MAX ]; + char szName[ HB_PATH_MAX ]; - hb_retnint( ( HB_NHANDLE ) hb_fsCreateTemp( ( BYTE * ) hb_parc( 1 ), - ( BYTE * ) hb_parc( 2 ), + hb_retnint( ( HB_NHANDLE ) hb_fsCreateTemp( hb_parc( 1 ), + hb_parc( 2 ), ( ULONG ) ( HB_ISNUM( 3 ) ? ( ULONG ) hb_parnl( 3 ) : FC_NORMAL ), szName ) ); - hb_storc( ( char * ) szName, 4 ); + hb_storc( szName, 4 ); } -HB_FHANDLE hb_fsCreateTempEx( BYTE * pszName, const BYTE * pszDir, const BYTE * pszPrefix, const BYTE * pszExt, ULONG ulAttr ) +HB_FHANDLE hb_fsCreateTempEx( char * pszName, const char * pszDir, const char * pszPrefix, const char * pszExt, ULONG ulAttr ) { return hb_fsCreateTempLow( pszDir, pszPrefix, ulAttr, pszName, pszExt ); } HB_FUNC( HB_FTEMPCREATEEX ) { - BYTE szName[ HB_PATH_MAX ]; + char szName[ HB_PATH_MAX ]; hb_retnint( ( HB_NHANDLE ) hb_fsCreateTempEx( szName, - ( BYTE * ) hb_parc( 2 ), - ( BYTE * ) hb_parc( 3 ), - ( BYTE * ) hb_parc( 4 ), + hb_parc( 2 ), + hb_parc( 3 ), + hb_parc( 4 ), ( ULONG ) ( HB_ISNUM( 5 ) ? ( ULONG ) hb_parnl( 5 ) : FC_NORMAL ) ) ); - hb_storc( ( char * ) szName, 1 ); + hb_storc( szName, 1 ); } diff --git a/harbour/source/rtl/gete.c b/harbour/source/rtl/gete.c index f078edb3a8..0a1d454986 100644 --- a/harbour/source/rtl/gete.c +++ b/harbour/source/rtl/gete.c @@ -91,23 +91,14 @@ HB_FUNC( GETENV ) /* NOTE: Convert the envvar name to uppercase. This is required for DOS and OS/2 systems. [vszakats] */ - - #if defined(HB_OS_DOS) || defined(HB_OS_OS2) - hb_strupr( pszName ); - #endif - +#if defined(HB_OS_DOS) || defined(HB_OS_OS2) + hb_strupr( pszName ); +#endif szValue = hb_getenv( pszName ); if( szValue && szValue[ 0 ] != '\0' ) { - { - /* Convert from OS codepage */ - BOOL fFree; - char * pbyResult = ( char * ) hb_osDecode( ( BYTE * ) szValue, &fFree ); - - hb_retc_buffer( pbyResult ); - if( fFree ) - hb_xfree( szValue ); - } + /* Convert from OS codepage */ + hb_retc_buffer( ( char * ) hb_osDecode( szValue, NULL ) ); } else { @@ -169,26 +160,15 @@ HB_FUNC( HB_GETENV ) /* NOTE: Convert the envvar name to uppercase. This is required for DOS and OS/2 systems. [vszakats] */ - - #if defined(HB_OS_DOS) || defined(HB_OS_OS2) - hb_strupr( pszName ); - #endif - +#if defined(HB_OS_DOS) || defined(HB_OS_OS2) + hb_strupr( pszName ); +#endif szValue = hb_getenv( pszName ); if( szValue && szValue[ 0 ] != '\0' ) { if( ! HB_ISLOG( 3 ) || hb_parl( 3 ) ) - { - /* Convert from OS codepage */ - BOOL fFree; - char * pbyResult = ( char * ) hb_osDecode( ( BYTE * ) szValue, &fFree ); - - hb_retc_buffer( pbyResult ); - if( fFree ) - hb_xfree( szValue ); - } - else - hb_retc_buffer( szValue ); + szValue = ( char * ) hb_osDecode( szValue, NULL ); + hb_retc_buffer( szValue ); } else { @@ -208,27 +188,27 @@ HB_FUNC( HB_GETENV ) HB_FUNC( HB_SETENV ) { - char * pszName = hb_parc( 1 ); + const char * pszName = hb_parc( 1 ); BOOL fResult = FALSE; if( pszName ) { - char * pszValue = hb_parc( 2 ); - BOOL fFreeName = FALSE, fFreeVal = FALSE; + const char * pszValue = hb_parc( 2 ); + char * pszFreeName = NULL, * pszFreeVal = NULL; if( ( ! HB_ISLOG( 3 ) || hb_parl( 3 ) ) ) { - pszName = ( char * ) hb_osEncode( ( BYTE * ) pszName, &fFreeName ); + pszName = hb_osEncode( pszName, &pszFreeName ); if( pszValue ) - pszValue = ( char * ) hb_osEncode( ( BYTE * ) pszValue, &fFreeVal ); + pszValue = hb_osEncode( pszValue, &pszFreeVal ); } fResult = hb_setenv( pszName, pszValue ); - if( fFreeName ) - hb_xfree( pszName ); - if( fFreeVal ) - hb_xfree( pszValue ); + if( pszFreeName ) + hb_xfree( pszFreeName ); + if( pszFreeVal ) + hb_xfree( pszFreeVal ); } hb_retl( fResult ); diff --git a/harbour/source/rtl/gtapi.c b/harbour/source/rtl/gtapi.c index d271d71910..43b854e3e8 100644 --- a/harbour/source/rtl/gtapi.c +++ b/harbour/source/rtl/gtapi.c @@ -165,7 +165,7 @@ int hb_gtReadKey( int iEventMask ) return iKey; } -HB_ERRCODE hb_gtBox( SHORT Top, SHORT Left, SHORT Bottom, SHORT Right, BYTE * pbyFrame ) +HB_ERRCODE hb_gtBox( SHORT Top, SHORT Left, SHORT Bottom, SHORT Right, const BYTE * pbyFrame ) { PHB_GT pGT; @@ -192,7 +192,7 @@ HB_ERRCODE hb_gtBoxD( SHORT Top, SHORT Left, SHORT Bottom, SHORT Right ) pGT = hb_gt_Base(); if( pGT ) { - HB_GTSELF_BOXD( pGT, Top, Left, Bottom, Right, ( BYTE * ) _B_DOUBLE, HB_GTSELF_GETCOLOR( pGT ) ); + HB_GTSELF_BOXD( pGT, Top, Left, Bottom, Right, ( const BYTE * ) _B_DOUBLE, HB_GTSELF_GETCOLOR( pGT ) ); HB_GTSELF_SETPOS( pGT, Top + 1, Left + 1 ); HB_GTSELF_FLUSH( pGT ); hb_gt_BaseFree( pGT ); @@ -210,7 +210,7 @@ HB_ERRCODE hb_gtBoxS( SHORT Top, SHORT Left, SHORT Bottom, SHORT Right ) pGT = hb_gt_Base(); if( pGT ) { - HB_GTSELF_BOXD( pGT, Top, Left, Bottom, Right, ( BYTE * ) _B_SINGLE, HB_GTSELF_GETCOLOR( pGT ) ); + HB_GTSELF_BOXD( pGT, Top, Left, Bottom, Right, ( const BYTE * ) _B_SINGLE, HB_GTSELF_GETCOLOR( pGT ) ); HB_GTSELF_SETPOS( pGT, Top + 1, Left + 1 ); HB_GTSELF_FLUSH( pGT ); hb_gt_BaseFree( pGT ); @@ -219,7 +219,7 @@ HB_ERRCODE hb_gtBoxS( SHORT Top, SHORT Left, SHORT Bottom, SHORT Right ) return HB_FAILURE; } -HB_ERRCODE hb_gtDrawBox( SHORT Top, SHORT Left, SHORT Bottom, SHORT Right, BYTE * pbyFrame, int iColor ) +HB_ERRCODE hb_gtDrawBox( SHORT Top, SHORT Left, SHORT Bottom, SHORT Right, const BYTE * pbyFrame, int iColor ) { PHB_GT pGT; @@ -630,7 +630,7 @@ HB_ERRCODE hb_gtRest( USHORT uiTop, USHORT uiLeft, USHORT uiBottom, USHORT uiRig pGT = hb_gt_Base(); if( pGT ) { - HB_GTSELF_REST( pGT, uiTop, uiLeft, uiBottom, uiRight, ( BYTE * ) pScrBuff ); + HB_GTSELF_REST( pGT, uiTop, uiLeft, uiBottom, uiRight, ( const BYTE * ) pScrBuff ); HB_GTSELF_FLUSH( pGT ); hb_gt_BaseFree( pGT ); return HB_SUCCESS; @@ -758,7 +758,7 @@ HB_ERRCODE hb_gtSetMode( USHORT uiRows, USHORT uiCols ) } HB_ERRCODE hb_gtPutText( USHORT uiRow, USHORT uiCol, - BYTE * pStr, ULONG ulLength, + const BYTE * pStr, ULONG ulLength, int iColor ) { PHB_GT pGT; @@ -780,7 +780,7 @@ HB_ERRCODE hb_gtPutText( USHORT uiRow, USHORT uiCol, return HB_FAILURE; } -HB_ERRCODE hb_gtWriteAt( USHORT uiRow, USHORT uiCol, BYTE * pStr, ULONG ulLength ) +HB_ERRCODE hb_gtWriteAt( USHORT uiRow, USHORT uiCol, const BYTE * pStr, ULONG ulLength ) { PHB_GT pGT; @@ -797,7 +797,7 @@ HB_ERRCODE hb_gtWriteAt( USHORT uiRow, USHORT uiCol, BYTE * pStr, ULONG ulLength return HB_FAILURE; } -HB_ERRCODE hb_gtWrite( BYTE * pStr, ULONG ulLength ) +HB_ERRCODE hb_gtWrite( const BYTE * pStr, ULONG ulLength ) { PHB_GT pGT; @@ -814,7 +814,7 @@ HB_ERRCODE hb_gtWrite( BYTE * pStr, ULONG ulLength ) return HB_FAILURE; } -HB_ERRCODE hb_gtWriteCon( BYTE * pStr, ULONG ulLength ) +HB_ERRCODE hb_gtWriteCon( const BYTE * pStr, ULONG ulLength ) { PHB_GT pGT; @@ -969,7 +969,7 @@ HB_ERRCODE hb_gtResume( void ) return errCode; } -HB_ERRCODE hb_gtOutStd( BYTE * pbyStr, ULONG ulLen ) +HB_ERRCODE hb_gtOutStd( const BYTE * pbyStr, ULONG ulLen ) { PHB_GT pGT; @@ -987,7 +987,7 @@ HB_ERRCODE hb_gtOutStd( BYTE * pbyStr, ULONG ulLen ) return HB_SUCCESS; } -HB_ERRCODE hb_gtOutErr( BYTE * pbyStr, ULONG ulLen ) +HB_ERRCODE hb_gtOutErr( const BYTE * pbyStr, ULONG ulLen ) { PHB_GT pGT; @@ -1260,7 +1260,7 @@ HB_ERRCODE hb_gtScrollEx( int iTop, int iLeft, int iBottom, int iRight, int iCol return HB_FAILURE; } -HB_ERRCODE hb_gtBoxEx( int iTop, int iLeft, int iBottom, int iRight, BYTE * pbyFrame, int iColor ) +HB_ERRCODE hb_gtBoxEx( int iTop, int iLeft, int iBottom, int iRight, const BYTE * pbyFrame, int iColor ) { PHB_GT pGT; diff --git a/harbour/source/rtl/gtcgi/gtcgi.c b/harbour/source/rtl/gtcgi/gtcgi.c index 3b784b9589..7966c8755b 100644 --- a/harbour/source/rtl/gtcgi/gtcgi.c +++ b/harbour/source/rtl/gtcgi/gtcgi.c @@ -105,7 +105,7 @@ static void hb_gt_cgi_termOut( PHB_GTCGI pGTCGI, const BYTE * pStr, ULONG ulLen static void hb_gt_cgi_newLine( PHB_GTCGI pGTCGI ) { - hb_gt_cgi_termOut( pGTCGI, ( BYTE * ) pGTCGI->szCrLf, pGTCGI->ulCrLf ); + hb_gt_cgi_termOut( pGTCGI, ( const BYTE * ) pGTCGI->szCrLf, pGTCGI->ulCrLf ); } static void hb_gt_cgi_Init( PHB_GT pGT, HB_FHANDLE hFilenoStdin, HB_FHANDLE hFilenoStdout, HB_FHANDLE hFilenoStderr ) @@ -254,7 +254,7 @@ static BOOL hb_gt_cgi_SetDispCP( PHB_GT pGT, const char *pszTermCDP, const char #ifdef HB_GT_CGI_RAWOUTPUT -static void hb_gt_cgi_WriteCon( PHB_GT pGT, BYTE * pText, ULONG ulLength ) +static void hb_gt_cgi_WriteCon( PHB_GT pGT, const BYTE * pText, ULONG ulLength ) { BYTE * buffer = NULL; PHB_GTCGI pGTCGI = HB_GTCGI_GET( pGT ); @@ -300,7 +300,7 @@ static void hb_gt_cgi_WriteCon( PHB_GT pGT, BYTE * pText, ULONG ulLength ) hb_xfree( buffer ); } -static void hb_gt_cgi_WriteAt( PHB_GT pGT, int iRow, int iCol, BYTE * pText, ULONG ulLength ) +static void hb_gt_cgi_WriteAt( PHB_GT pGT, int iRow, int iCol, const BYTE * pText, ULONG ulLength ) { int iLineFeed = 0, iSpace = 0; PHB_GTCGI pGTCGI = HB_GTCGI_GET( pGT ); diff --git a/harbour/source/rtl/gtcrs/gtcrs.c b/harbour/source/rtl/gtcrs/gtcrs.c index 9d9dbbb349..877202888d 100644 --- a/harbour/source/rtl/gtcrs/gtcrs.c +++ b/harbour/source/rtl/gtcrs/gtcrs.c @@ -2563,7 +2563,7 @@ static const char * hb_gt_crs_Version( PHB_GT pGT, int iType ) /* *********************************************************************** */ -static void hb_gt_crs_OutStd( PHB_GT pGT, BYTE * pbyStr, ULONG ulLen ) +static void hb_gt_crs_OutStd( PHB_GT pGT, const BYTE * pbyStr, ULONG ulLen ) { HB_TRACE( HB_TR_DEBUG, ( "hb_gt_crs_OutStd(%p,%s,%lu)", pGT, pbyStr, ulLen ) ); @@ -2580,7 +2580,7 @@ static void hb_gt_crs_OutStd( PHB_GT pGT, BYTE * pbyStr, ULONG ulLen ) /* *********************************************************************** */ -static void hb_gt_crs_OutErr( PHB_GT pGT, BYTE * pbyStr, ULONG ulLen ) +static void hb_gt_crs_OutErr( PHB_GT pGT, const BYTE * pbyStr, ULONG ulLen ) { HB_TRACE( HB_TR_DEBUG, ( "hb_gt_crs_OutErr(%p,%s,%lu)", pGT, pbyStr, ulLen ) ); if( s_ioBase ) diff --git a/harbour/source/rtl/gtdos/gtdos.c b/harbour/source/rtl/gtdos/gtdos.c index 46370fe450..5e6ccd17a3 100644 --- a/harbour/source/rtl/gtdos/gtdos.c +++ b/harbour/source/rtl/gtdos/gtdos.c @@ -680,7 +680,7 @@ static void hb_gt_dos_mouse_SaveState( PHB_GT pGT, BYTE * pBuffer ) } } -static void hb_gt_dos_mouse_RestoreState( PHB_GT pGT, BYTE * pBuffer ) +static void hb_gt_dos_mouse_RestoreState( PHB_GT pGT, const BYTE * pBuffer ) { if( s_fMousePresent ) { diff --git a/harbour/source/rtl/hbadler.c b/harbour/source/rtl/hbadler.c index bbdac84fa9..cea5f1053c 100644 --- a/harbour/source/rtl/hbadler.c +++ b/harbour/source/rtl/hbadler.c @@ -87,7 +87,7 @@ ULONG hb_adler32( ULONG adler, const BYTE *buf, ULONG len ) HB_FUNC( HB_ADLER32 ) { - char * szString = hb_parc( 1 ); + const char * szString = hb_parc( 1 ); if( szString ) hb_retnint( hb_adler32( ( ULONG ) hb_parnl( 2 ), ( BYTE * ) szString, hb_parclen( 1 ) ) ); diff --git a/harbour/source/rtl/hbcrc.c b/harbour/source/rtl/hbcrc.c index 02ceb7138f..dbb511b9d7 100644 --- a/harbour/source/rtl/hbcrc.c +++ b/harbour/source/rtl/hbcrc.c @@ -230,7 +230,7 @@ HB_ULONG hb_crcct( HB_ULONG crc, const BYTE * buf, ULONG len, HB_ULONG poly ) HB_FUNC( HB_CRC32 ) { - char * szString = hb_parc( 1 ); + const char * szString = hb_parc( 1 ); if( szString ) hb_retnint( hb_crc32( ( ULONG ) hb_parnl( 2 ), ( BYTE * ) szString, hb_parclen( 1 ) ) ); @@ -240,7 +240,7 @@ HB_FUNC( HB_CRC32 ) HB_FUNC( HB_CRC16 ) { - char * szString = hb_parc( 1 ); + const char * szString = hb_parc( 1 ); if( szString ) hb_retnint( hb_crc16( ( ULONG ) hb_parnl( 2 ), ( BYTE * ) szString, hb_parclen( 1 ) ) ); @@ -250,7 +250,7 @@ HB_FUNC( HB_CRC16 ) HB_FUNC( HB_CRC ) { - char * szString = hb_parc( 1 ); + const char * szString = hb_parc( 1 ); if( szString ) { @@ -265,7 +265,7 @@ HB_FUNC( HB_CRC ) HB_FUNC( HB_CRCCT ) { - char * szString = hb_parc( 1 ); + const char * szString = hb_parc( 1 ); if( szString ) { diff --git a/harbour/source/rtl/hbffind.c b/harbour/source/rtl/hbffind.c index 1da8d8e9d8..d4e75812ff 100644 --- a/harbour/source/rtl/hbffind.c +++ b/harbour/source/rtl/hbffind.c @@ -727,13 +727,13 @@ static BOOL hb_fsFindNextLow( PHB_FFIND ffind ) /* Convert from OS codepage */ { - BOOL fFree; - char * pbyResult = ( char * ) hb_osDecode( ( BYTE * ) ffind->szName, &fFree ); + char * pszFree; + const char * pszResult = hb_osDecode( ffind->szName, &pszFree ); - if( fFree ) + if( pszFree ) { - hb_strncpy( ffind->szName, pbyResult, sizeof( ffind->szName ) - 1 ); - hb_xfree( pbyResult ); + hb_strncpy( ffind->szName, pszResult, sizeof( ffind->szName ) - 1 ); + hb_xfree( pszFree ); } } diff --git a/harbour/source/rtl/hbgtcore.c b/harbour/source/rtl/hbgtcore.c index 2f6cbbbd37..1f90c15821 100644 --- a/harbour/source/rtl/hbgtcore.c +++ b/harbour/source/rtl/hbgtcore.c @@ -657,7 +657,7 @@ static BOOL hb_gt_def_Resume( PHB_GT pGT ) return HB_GTSELF_POSTEXT( pGT ); } -static void hb_gt_def_OutStd( PHB_GT pGT, BYTE * pbyStr, ULONG ulLen ) +static void hb_gt_def_OutStd( PHB_GT pGT, const BYTE * pbyStr, ULONG ulLen ) { if( ulLen ) { @@ -682,7 +682,7 @@ static void hb_gt_def_OutStd( PHB_GT pGT, BYTE * pbyStr, ULONG ulLen ) } } -static void hb_gt_def_OutErr( PHB_GT pGT, BYTE * pbyStr, ULONG ulLen ) +static void hb_gt_def_OutErr( PHB_GT pGT, const BYTE * pbyStr, ULONG ulLen ) { if( ulLen ) { @@ -763,7 +763,7 @@ static BOOL hb_gt_def_PutChar( PHB_GT pGT, int iRow, int iCol, return FALSE; } -static void hb_gt_def_PutText( PHB_GT pGT, int iRow, int iCol, BYTE bColor, BYTE * pText, ULONG ulLen ) +static void hb_gt_def_PutText( PHB_GT pGT, int iRow, int iCol, BYTE bColor, const BYTE * pText, ULONG ulLen ) { while( ulLen-- ) { @@ -792,7 +792,7 @@ static void hb_gt_def_Replicate( PHB_GT pGT, int iRow, int iCol, BYTE bColor, } } -static void hb_gt_def_WriteAt( PHB_GT pGT, int iRow, int iCol, BYTE * pText, ULONG ulLength ) +static void hb_gt_def_WriteAt( PHB_GT pGT, int iRow, int iCol, const BYTE * pText, ULONG ulLength ) { int iMaxCol = HB_GTSELF_MAXCOL( pGT ); @@ -804,7 +804,7 @@ static void hb_gt_def_WriteAt( PHB_GT pGT, int iRow, int iCol, BYTE * pText, ULO HB_GTSELF_SETPOS( pGT, iRow, iCol + ( int ) ulLength ); } -static void hb_gt_def_Write( PHB_GT pGT, BYTE * pText, ULONG ulLength ) +static void hb_gt_def_Write( PHB_GT pGT, const BYTE * pText, ULONG ulLength ) { int iRow, iCol; @@ -814,7 +814,7 @@ static void hb_gt_def_Write( PHB_GT pGT, BYTE * pText, ULONG ulLength ) #define WRITECON_BUFFER_SIZE 512 -static void hb_gt_def_WriteCon( PHB_GT pGT, BYTE * pText, ULONG ulLength ) +static void hb_gt_def_WriteCon( PHB_GT pGT, const BYTE * pText, ULONG ulLength ) { int iLen = 0; BOOL bDisp = FALSE; @@ -1001,7 +1001,7 @@ static void hb_gt_def_Save( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iR } static void hb_gt_def_Rest( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight, - BYTE * pBuffer ) + const BYTE * pBuffer ) { while( iTop <= iBottom ) { @@ -1269,7 +1269,7 @@ static void hb_gt_def_ScrollUp( PHB_GT pGT, int iRows, BYTE bColor, BYTE bChar ) } static void hb_gt_def_Box( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight, - BYTE * pbyFrame, BYTE bColor ) + const BYTE * pbyFrame, BYTE bColor ) { int iMaxRow, iMaxCol, iRows, iCols, iFirst, i; @@ -1352,17 +1352,17 @@ static void hb_gt_def_Box( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRi } static void hb_gt_def_BoxS( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight, - BYTE * pbyFrame, BYTE bColor ) + const BYTE * pbyFrame, BYTE bColor ) { HB_GTSELF_BOX( pGT, iTop, iLeft, iBottom, iRight, - pbyFrame ? pbyFrame : ( BYTE * ) _B_SINGLE, bColor ); + pbyFrame ? pbyFrame : ( const BYTE * ) _B_SINGLE, bColor ); } static void hb_gt_def_BoxD( PHB_GT pGT, int iTop, int iLeft, int iBottom, int iRight, - BYTE * pbyFrame, BYTE bColor ) + const BYTE * pbyFrame, BYTE bColor ) { HB_GTSELF_BOX( pGT, iTop, iLeft, iBottom, iRight, - pbyFrame ? pbyFrame : ( BYTE * ) _B_DOUBLE, bColor ); + pbyFrame ? pbyFrame : ( const BYTE * ) _B_DOUBLE, bColor ); } static void hb_gt_def_HorizLine( PHB_GT pGT, int iRow, int iLeft, int iRight, @@ -1535,7 +1535,7 @@ static BOOL hb_gt_def_Info( PHB_GT pGT, int iType, PHB_GT_INFO pInfo ) { HB_GTSELF_REST( pGT, 0, 0, hb_arrayGetNI( pInfo->pNewVal, 5 ), hb_arrayGetNI( pInfo->pNewVal, 6 ), - ( BYTE * ) hb_arrayGetCPtr( pInfo->pNewVal, 7 ) ); + ( const BYTE * ) hb_arrayGetCPtr( pInfo->pNewVal, 7 ) ); } HB_GTSELF_SETPOS( pGT, hb_arrayGetNI( pInfo->pNewVal, 1 ), hb_arrayGetNI( pInfo->pNewVal, 2 ) ); @@ -1773,7 +1773,7 @@ static int hb_gt_def_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions, HB_GTSELF_SAVE( pGT, iTop, iLeft, iBottom, iRight, pBuffer ); } HB_GTSELF_BOXS( pGT, iTop, iLeft, iBottom, iRight, NULL, iClrNorm ); - HB_GTSELF_BOXS( pGT, iTop + 1, iLeft + 1, iBottom - 1, iRight - 1, ( BYTE * ) " ", iClrNorm ); + HB_GTSELF_BOXS( pGT, iTop + 1, iLeft + 1, iBottom - 1, iRight - 1, ( const BYTE * ) " ", iClrNorm ); ulLast = 0; i = iTop + 1; for( ul = 0; ul < ulDst; ++ul ) @@ -1786,7 +1786,7 @@ static int hb_gt_def_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions, if( ulLen > ulWidth ) ulLen = ulWidth; HB_GTSELF_PUTTEXT( pGT, i, iLeft + ( ( ulWidth - ulLen + 1 ) >> 1 ) + 2, - iClrNorm, ( BYTE * ) szMsgDsp + ulLast, ulLen ); + iClrNorm, ( const BYTE * ) szMsgDsp + ulLast, ulLen ); } ulLast = ul + 1; if( ++i >= iBottom - 1 ) @@ -1799,7 +1799,7 @@ static int hb_gt_def_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions, if( ulLen > ulWidth ) ulLen = ulWidth; HB_GTSELF_PUTTEXT( pGT, i, iLeft + ( ( ulWidth - ulLen + 1 ) >> 1 ) + 2, - iClrNorm, ( BYTE * ) szMsgDsp + ulLast, ulLen ); + iClrNorm, ( const BYTE * ) szMsgDsp + ulLast, ulLen ); } iPos = 1; @@ -1811,10 +1811,10 @@ static int hb_gt_def_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions, { iClr = i == iPos ? iClrHigh : iClrNorm; ulLen = hb_arrayGetCLen( pOptions, i ); - HB_GTSELF_PUTTEXT( pGT, iBottom - 1, iMnuCol, iClr, ( BYTE * ) " ", 1 ); + HB_GTSELF_PUTTEXT( pGT, iBottom - 1, iMnuCol, iClr, ( const BYTE * ) " ", 1 ); HB_GTSELF_PUTTEXT( pGT, iBottom - 1, iMnuCol + 1, iClr, - ( BYTE * ) hb_arrayGetCPtr( pOptions, i ), ulLen ); - HB_GTSELF_PUTTEXT( pGT, iBottom - 1, iMnuCol + 1 + ulLen, iClr, ( BYTE * ) " ", 1 ); + ( const BYTE * ) hb_arrayGetCPtr( pOptions, i ), ulLen ); + HB_GTSELF_PUTTEXT( pGT, iBottom - 1, iMnuCol + 1 + ulLen, iClr, ( const BYTE * ) " ", 1 ); iMnuCol += ulLen + 4; } while( HB_GTSELF_DISPCOUNT( pGT ) ) @@ -1899,22 +1899,22 @@ static int hb_gt_def_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions, if( szMessage[ ul ] == '\n' ) { if( ul > ulStart ) - HB_GTSELF_WRITECON( pGT, ( BYTE * ) szMessage + ulStart, ul - ulStart ); - HB_GTSELF_WRITECON( pGT, ( BYTE * ) szEol, strlen( szEol ) ); + HB_GTSELF_WRITECON( pGT, ( const BYTE * ) szMessage + ulStart, ul - ulStart ); + HB_GTSELF_WRITECON( pGT, ( const BYTE * ) szEol, strlen( szEol ) ); ulStart = ul + 1; } } if( ul > ulStart ) - HB_GTSELF_WRITECON( pGT, ( BYTE * ) szMessage + ulStart, ul - ulStart ); - HB_GTSELF_WRITECON( pGT, ( BYTE * ) " (", 2 ); + HB_GTSELF_WRITECON( pGT, ( const BYTE * ) szMessage + ulStart, ul - ulStart ); + HB_GTSELF_WRITECON( pGT, ( const BYTE * ) " (", 2 ); for( i = 1; i <= iOptions; ++i ) { if( i > 1 ) - HB_GTSELF_WRITECON( pGT, ( BYTE * ) ", ", 2 ); - HB_GTSELF_WRITECON( pGT, ( BYTE * ) hb_arrayGetCPtr( pOptions, i ), + HB_GTSELF_WRITECON( pGT, ( const BYTE * ) ", ", 2 ); + HB_GTSELF_WRITECON( pGT, ( const BYTE * ) hb_arrayGetCPtr( pOptions, i ), hb_arrayGetCLen( pOptions, i ) ); } - HB_GTSELF_WRITECON( pGT, ( BYTE * ) ") ", 2 ); + HB_GTSELF_WRITECON( pGT, ( const BYTE * ) ") ", 2 ); while( iRet == 0 ) { iKey = fKeyBoard ? HB_GTSELF_INKEYGET( pGT, TRUE, dDelay, INKEY_ALL ) : 0; @@ -1941,7 +1941,7 @@ static int hb_gt_def_Alert( PHB_GT pGT, PHB_ITEM pMessage, PHB_ITEM pOptions, char szVal[2]; szVal[ 0 ] = ( char ) iKey; szVal[ 1 ] = '\0'; - HB_GTSELF_WRITECON( pGT, ( BYTE * ) szVal, 1 ); + HB_GTSELF_WRITECON( pGT, ( const BYTE * ) szVal, 1 ); } } } @@ -2703,7 +2703,7 @@ static void hb_gt_def_mouseSaveState( PHB_GT pGT, BYTE * pBuffer ) pStore->iRight = iRight; } -static void hb_gt_def_mouseRestoreState( PHB_GT pGT, BYTE * pBuffer ) +static void hb_gt_def_mouseRestoreState( PHB_GT pGT, const BYTE * pBuffer ) { _HB_MOUSE_STORAGE * pStore = ( _HB_MOUSE_STORAGE * ) pBuffer; diff --git a/harbour/source/rtl/hbhex.c b/harbour/source/rtl/hbhex.c index 05bd11f5cc..a4b2898fa0 100644 --- a/harbour/source/rtl/hbhex.c +++ b/harbour/source/rtl/hbhex.c @@ -56,7 +56,7 @@ HB_FUNC( HB_HEXTONUM ) { - char * szHex = hb_parc( 1 ); + const char * szHex = hb_parc( 1 ); if( szHex ) { @@ -173,7 +173,7 @@ HB_FUNC( HB_STRTOHEX ) HB_FUNC( HB_HEXTOSTR ) { - char * szStr = hb_parc( 1 ); + const char * szStr = hb_parc( 1 ); ULONG ulStr; if( !szStr ) @@ -186,14 +186,15 @@ HB_FUNC( HB_HEXTOSTR ) if( ulStr > 1 ) { ULONG ulDest, ul; + const char * szPtr; char * szDest; - szDest = szStr; + szPtr = szStr; ul = ulStr; ulDest = 0; do { - char c = *szDest++; + char c = *szPtr++; if( ( c >= '0' && c <= '9' ) || ( c >= 'A' && c <= 'F' ) || ( c >= 'a' && c <= 'f' ) ) diff --git a/harbour/source/rtl/hbi18n1.c b/harbour/source/rtl/hbi18n1.c index 40b05f5d96..103d9e60ff 100644 --- a/harbour/source/rtl/hbi18n1.c +++ b/harbour/source/rtl/hbi18n1.c @@ -589,54 +589,45 @@ static const char * hb_i18n_setcodepage( PHB_I18N_TRANS pI18N, for( ul = 1; ul <= ulLen; ++ul ) { PHB_ITEM pContext = hb_hashGetValueAt( pI18N->context_table, ul ); - PHB_ITEM pResult; - ULONG ulCount = hb_hashLen( pContext ), u; + ULONG ulCount = hb_hashLen( pContext ), ulLen, u; + char * szValue; for( u = 1; u <= ulCount; ++u ) { if( fBase ) { - pResult = hb_hashGetKeyAt( pContext, u ); - if( HB_IS_STRING( pResult ) ) + if( hb_itemGetWriteCL( hb_hashGetKeyAt( pContext, u ), + &szValue, &ulLen ) ) { - pResult = hb_itemUnShareString( pResult ); - hb_cdpnTranslate( hb_itemGetCPtr( pResult ), cdpage, cdp, - hb_itemGetCLen( pResult ) ); + hb_cdpnTranslate( szValue, cdpage, cdp, ulLen ); } } else { - pResult = hb_hashGetValueAt( pContext, u ); + PHB_ITEM pResult = hb_hashGetValueAt( pContext, u ); if( HB_IS_STRING( pResult ) ) { - pResult = hb_itemUnShareString( pResult ); - hb_cdpnTranslate( hb_itemGetCPtr( pResult ), cdpage, cdp, - hb_itemGetCLen( pResult ) ); + if( hb_itemGetWriteCL( pResult, &szValue, &ulLen ) ) + hb_cdpnTranslate( szValue, cdpage, cdp, ulLen ); } else if( HB_IS_ARRAY( pResult ) ) { ULONG ulTrans = hb_arrayLen( pResult ), u2; for( u2 = 1; u2 <= ulTrans; ++u2 ) { - PHB_ITEM pValue = hb_arrayGetItemPtr( pResult, u2 ); - if( HB_IS_STRING( pValue ) ) - { - pValue = hb_itemUnShareString( pValue ); - hb_cdpnTranslate( hb_itemGetCPtr( pValue ), cdpage, cdp, - hb_itemGetCLen( pValue ) ); - } + if( hb_itemGetWriteCL( hb_arrayGetItemPtr( pResult, u2 ), + &szValue, &ulLen ) ) + hb_cdpnTranslate( szValue, cdpage, cdp, ulLen ); } } } } if( fBase ) { - pResult = hb_hashGetKeyAt( pI18N->context_table, ul ); - if( HB_IS_STRING( pResult ) ) + if( hb_itemGetWriteCL( hb_hashGetKeyAt( pI18N->context_table, u ), + &szValue, &ulLen ) ) { - pResult = hb_itemUnShareString( pResult ); - hb_cdpnTranslate( hb_itemGetCPtr( pResult ), cdpage, cdp, - hb_itemGetCLen( pResult ) ); + hb_cdpnTranslate( szValue, cdpage, cdp, ulLen ); } hb_hashSetFlags( pContext, HB_HASH_RESORT ); } @@ -743,9 +734,12 @@ PHB_ITEM hb_i18n_gettext( PHB_ITEM pMsgID, PHB_ITEM pContext ) PHB_CODEPAGE cdp = hb_vmCDP(); if( cdp && cdp != cdpage ) { - pMsgID = hb_itemUnShareString( pMsgID ); - hb_cdpnTranslate( hb_itemGetCPtr( pMsgID ), cdpage, cdp, - hb_itemGetCLen( pMsgID ) ); + char * szValue; + ULONG ulLen; + if( hb_itemGetWriteCL( pMsgID, &szValue, &ulLen ) ) + { + hb_cdpnTranslate( szValue, cdpage, cdp, ulLen ); + } } } } @@ -824,9 +818,12 @@ PHB_ITEM hb_i18n_ngettext( PHB_ITEM pNum, PHB_ITEM pMsgID, PHB_ITEM pContext ) PHB_CODEPAGE cdp = hb_vmCDP(); if( cdp && cdp != cdpage ) { - pMsgID = hb_itemUnShareString( pMsgID ); - hb_cdpnTranslate( hb_itemGetCPtr( pMsgID ), cdpage, cdp, - hb_itemGetCLen( pMsgID ) ); + char * szValue; + ULONG ulLen; + if( hb_itemGetWriteCL( pMsgID, &szValue, &ulLen ) ) + { + hb_cdpnTranslate( szValue, cdpage, cdp, ulLen ); + } } } } diff --git a/harbour/source/rtl/hbinet.c b/harbour/source/rtl/hbinet.c index 75b34f5d00..51b4446249 100644 --- a/harbour/source/rtl/hbinet.c +++ b/harbour/source/rtl/hbinet.c @@ -381,7 +381,7 @@ static int hb_selectWriteExceptSocket( HB_SOCKET_STRUCT * Socket ) #endif /*** Utilty to access host DNS */ -static struct hostent * hb_getHosts( char * name, HB_SOCKET_STRUCT * Socket ) +static struct hostent * hb_getHosts( const char * name, HB_SOCKET_STRUCT * Socket ) { struct hostent * Host = NULL; @@ -944,6 +944,7 @@ static void s_inetRecvInternal( int iMode ) HB_SOCKET_STRUCT * Socket = HB_PARSOCKET( 1 ); PHB_ITEM pBuffer = hb_param( 2, HB_IT_STRING ); char *buffer; + ULONG ulLen; int iLen, iMaxLen, iReceived; int iTimeElapsed; @@ -958,11 +959,15 @@ static void s_inetRecvInternal( int iMode ) return; } - pBuffer = hb_itemUnShare( pBuffer ); - buffer = hb_itemGetCPtr( pBuffer ); - iLen = hb_itemGetCLen( pBuffer ); + if( hb_itemGetWriteCL( pBuffer, &buffer, &ulLen ) ) + iLen = ( int ) ulLen; + else + { + iLen = 0; + buffer = NULL; + } - if( HB_ISNIL( 3 ) ) + if( !HB_ISNUM( 3 ) ) { iMaxLen = iLen; } @@ -1205,7 +1210,7 @@ HB_FUNC( HB_INETRECVENDBLOCK ) char cChar = '\0'; char * Buffer; - char ** Proto; + const char ** Proto; int iAllocated, iBufferSize, iMax; int iLen; int iPos = 0; @@ -1241,7 +1246,7 @@ HB_FUNC( HB_INETRECVENDBLOCK ) return; } - Proto = ( char ** ) hb_xgrab( sizeof( char * ) * iprotos ); + Proto = ( const char ** ) hb_xgrab( sizeof( char * ) * iprotos ); iprotosize = ( int * ) hb_xgrab( sizeof( int ) * iprotos ); for( i = 0; i < iprotos; i++ ) @@ -1252,7 +1257,7 @@ HB_FUNC( HB_INETRECVENDBLOCK ) } else { - Proto = ( char ** ) hb_xgrab( sizeof( char * ) ); + Proto = ( const char ** ) hb_xgrab( sizeof( char * ) ); iprotosize = ( int * ) hb_xgrab( sizeof( int ) ); Proto[ 0 ] = hb_itemGetCPtr( pProto ); iprotosize[ 0 ] = hb_itemGetCLen( pProto ); @@ -1261,7 +1266,7 @@ HB_FUNC( HB_INETRECVENDBLOCK ) } else { - Proto = ( char ** ) hb_xgrab( sizeof( char * ) ); + Proto = ( const char ** ) hb_xgrab( sizeof( char * ) ); iprotosize = ( int * ) hb_xgrab( sizeof( int ) ); Proto[ 0 ] = ( char * ) "\r\n"; iprotos = 1; @@ -1451,7 +1456,7 @@ static void s_inetSendInternal( int iMode ) { HB_SOCKET_STRUCT * Socket = HB_PARSOCKET( 1 ); PHB_ITEM pBuffer = hb_param( 2, HB_IT_STRING ); - char * Buffer; + const char * Buffer; int iLen, iSent, iSend; if( Socket == NULL || pBuffer == NULL ) @@ -1528,7 +1533,7 @@ HB_FUNC( HB_INETSENDALL ) HB_FUNC( HB_INETGETHOSTS ) { - char * szHost = hb_parc( 1 ); + const char * szHost = hb_parc( 1 ); struct hostent * Host; char ** cHosts; int iCount = 0; @@ -1570,7 +1575,7 @@ HB_FUNC( HB_INETGETHOSTS ) HB_FUNC( HB_INETGETALIAS ) { - char * szHost = hb_parc( 1 ); + const char * szHost = hb_parc( 1 ); struct hostent * Host; char ** cHosts; int iCount = 0; @@ -1618,7 +1623,7 @@ HB_FUNC( HB_INETSERVER ) { HB_SOCKET_STRUCT * Socket = HB_PARSOCKET( 2 ); PHB_ITEM pSocket = NULL; - char * szAddress; + const char * szAddress; int iPort; int iOpt = 1; int iListen; @@ -1777,7 +1782,7 @@ HB_FUNC( HB_INETACCEPT ) HB_FUNC( HB_INETCONNECT ) { - char * szHost = hb_parc( 1 ); + const char * szHost = hb_parc( 1 ); HB_SOCKET_STRUCT * Socket = HB_PARSOCKET( 3 ); PHB_ITEM pSocket = NULL; struct hostent * Host; @@ -1839,7 +1844,7 @@ HB_FUNC( HB_INETCONNECT ) HB_FUNC( HB_INETCONNECTIP ) { - char * szHost = hb_parc( 1 ); + const char * szHost = hb_parc( 1 ); HB_SOCKET_STRUCT * Socket = HB_PARSOCKET( 3 ); PHB_ITEM pSocket = NULL; int iPort = hb_parni( 2 ); @@ -1902,7 +1907,7 @@ HB_FUNC( HB_INETDGRAMBIND ) PHB_ITEM pSocket = NULL; int iPort = hb_parni( 1 ); int iOpt = 1; - char * szAddress; + const char * szAddress; /* Parameter error checking */ if( iPort == 0 || ( hb_pcount() > 3 && ! HB_ISCHAR( 4 ) ) ) @@ -2030,11 +2035,11 @@ HB_FUNC( HB_INETDGRAM ) HB_FUNC( HB_INETDGRAMSEND ) { HB_SOCKET_STRUCT * Socket = HB_PARSOCKET( 1 ); - char * szAddress = hb_parc( 2 ); + const char * szAddress = hb_parc( 2 ); int iPort = hb_parni( 3 ); PHB_ITEM pBuffer = hb_param( 4, HB_IT_STRING ); int iLen; - char * szBuffer; + const char * szBuffer; if( Socket == NULL || szAddress == NULL || iPort == 0 || pBuffer == NULL ) @@ -2097,6 +2102,7 @@ HB_FUNC( HB_INETDGRAMRECV ) int iTimeElapsed = 0; int iLen, iMaxLen; char * Buffer; + ULONG ulLen; BOOL fRepeat; socklen_t iDtLen = ( socklen_t ) sizeof( struct sockaddr ); @@ -2112,10 +2118,24 @@ HB_FUNC( HB_INETDGRAMRECV ) return; } - pBuffer = hb_itemUnShare( pBuffer ); - Buffer = hb_itemGetCPtr( pBuffer ); + if( hb_itemGetWriteCL( pBuffer, &Buffer, &ulLen ) ) + iLen = ( int ) ulLen; + else + { + iLen = 0; + Buffer = NULL; + } - iMaxLen = HB_ISNUM( 3 ) ? hb_parni( 3 ) : ( int ) hb_itemGetCLen( pBuffer ); + if( !HB_ISNUM( 3 ) ) + { + iMaxLen = iLen; + } + else + { + iMaxLen = hb_parni( 3 ); + if( iLen < iMaxLen ) + iMaxLen = iLen; + } hb_vmUnlock(); diff --git a/harbour/source/rtl/hbmd5.c b/harbour/source/rtl/hbmd5.c index 078bea0478..c2118c91bb 100644 --- a/harbour/source/rtl/hbmd5.c +++ b/harbour/source/rtl/hbmd5.c @@ -371,7 +371,7 @@ void hb_md5file( HB_FHANDLE hFile, BYTE * ucDigest ) HB_FUNC( HB_MD5 ) { - char * pszStr = hb_parc( 1 ); + const char * pszStr = hb_parc( 1 ); if( pszStr ) { @@ -389,11 +389,11 @@ HB_FUNC( HB_MD5 ) HB_FUNC( HB_MD5FILE ) { - char * pszFile = hb_parc( 1 ); + const char * pszFile = hb_parc( 1 ); if( pszFile ) { - HB_FHANDLE hFile = hb_fsOpen( ( BYTE * ) pszFile, FO_READ ); + HB_FHANDLE hFile = hb_fsOpen( pszFile, FO_READ ); if( hFile != FS_ERROR ) { diff --git a/harbour/source/rtl/hbregex.c b/harbour/source/rtl/hbregex.c index 0472f873f6..2527f568d9 100644 --- a/harbour/source/rtl/hbregex.c +++ b/harbour/source/rtl/hbregex.c @@ -188,7 +188,7 @@ HB_FUNC( HB_ISREGEX ) HB_FUNC( HB_ATX ) { - char * pszString; + const char * pszString; ULONG ulLen, ulStart, ulEnd; PHB_REGEX pRegEx; PHB_ITEM pString; @@ -250,7 +250,7 @@ static BOOL hb_regex( int iRequest ) int i, iMatches, iMaxMatch; BOOL fResult = FALSE; PHB_REGEX pRegEx; - char * pszString; + const char * pszString; ULONG ulLen; pString = hb_param( 2, HB_IT_STRING ); diff --git a/harbour/source/rtl/hbregexc.c b/harbour/source/rtl/hbregexc.c index c2218d1601..1f8e2690c3 100644 --- a/harbour/source/rtl/hbregexc.c +++ b/harbour/source/rtl/hbregexc.c @@ -131,7 +131,7 @@ PHB_REGEX hb_regexGet( PHB_ITEM pRegExItm, int iFlags ) else if( HB_IS_STRING( pRegExItm ) ) { ULONG ulLen = hb_itemGetCLen( pRegExItm ); - char * szRegEx = hb_itemGetCPtr( pRegExItm ); + const char * szRegEx = hb_itemGetCPtr( pRegExItm ); if( ulLen > 0 ) pRegEx = hb_regexCompile( szRegEx, ulLen, iFlags ); } diff --git a/harbour/source/rtl/hbrunfun.c b/harbour/source/rtl/hbrunfun.c index bc6994e374..a60d1a0034 100644 --- a/harbour/source/rtl/hbrunfun.c +++ b/harbour/source/rtl/hbrunfun.c @@ -57,23 +57,20 @@ HB_FUNC( HB_RUN ) { - PHB_ITEM pCommand = hb_param( 1, HB_IT_STRING ); + const char * pszCommand = hb_parc( 1 ); - if( pCommand ) + if( pszCommand ) { int iResult = -1; if( hb_gtSuspend() == HB_SUCCESS ) { - char * pszCommand = hb_itemGetC( pCommand ); - BOOL fFree; - char * pszResult = ( char * ) hb_osEncode( ( BYTE * ) pszCommand, &fFree ); + char * pszFree; - iResult = system( pszResult ); + iResult = system( hb_osEncode( pszCommand, &pszFree ) ); - hb_itemFreeC( pszCommand ); - if( fFree ) - hb_xfree( pszResult ); + if( pszFree ) + hb_xfree( pszFree ); hb_gtResume(); } diff --git a/harbour/source/rtl/hbstrfmt.c b/harbour/source/rtl/hbstrfmt.c index 7bf5992645..36413e107e 100644 --- a/harbour/source/rtl/hbstrfmt.c +++ b/harbour/source/rtl/hbstrfmt.c @@ -76,7 +76,7 @@ PHB_ITEM hb_strFormat( PHB_ITEM pItemReturn, PHB_ITEM pItemFormat, int iCount, P { BUFFERTYPE buffer; PHB_ITEM pItem; - char *pFmt, *pFmtEnd, *pFmtSave; + const char *pFmt, *pFmtEnd, *pFmtSave; int i, iParam, iParamNo, iWidth, iDec; ULONG ulSize; BOOL fLeftAlign, fForceSign, fPadZero, fSpaceSign, fSign; @@ -432,7 +432,7 @@ PHB_ITEM hb_strFormat( PHB_ITEM pItemReturn, PHB_ITEM pItemFormat, int iCount, P case 's': { - char * pStr = hb_itemGetCPtr( pItem ); + const char * pStr = hb_itemGetCPtr( pItem ); ulSize = hb_itemGetCLen( pItem ); if( iDec >= 0 ) diff --git a/harbour/source/rtl/hbzlib.c b/harbour/source/rtl/hbzlib.c index e042193055..9386a91baa 100644 --- a/harbour/source/rtl/hbzlib.c +++ b/harbour/source/rtl/hbzlib.c @@ -128,7 +128,7 @@ HB_FUNC( HB_ZUNCOMPRESSLEN ) */ HB_FUNC( HB_ZCOMPRESS ) { - char * szData = hb_parc( 1 ); + const char * szData = hb_parc( 1 ); if( szData ) { ULONG ulLen = hb_parclen( 1 ); @@ -142,9 +142,8 @@ HB_FUNC( HB_ZCOMPRESS ) if( pBuffer ) { - pBuffer = hb_itemUnShareString( pBuffer ); - ulDstLen = hb_itemGetCLen( pBuffer ); - pDest = hb_itemGetCPtr( pBuffer ); + if( !hb_itemGetWriteCL( pBuffer, &pDest, &ulDstLen ) ) + pDest = NULL; } else { @@ -192,7 +191,7 @@ HB_FUNC( HB_ZCOMPRESS ) HB_FUNC( HB_ZUNCOMPRESS ) { PHB_ITEM pBuffer = HB_ISBYREF( 2 ) ? hb_param( 2, HB_IT_STRING ) : NULL; - char * szData = hb_parc( 1 ); + const char * szData = hb_parc( 1 ); if( szData ) { @@ -206,9 +205,8 @@ HB_FUNC( HB_ZUNCOMPRESS ) if( pBuffer ) { - pBuffer = hb_itemUnShareString( pBuffer ); - ulDstLen = hb_itemGetCLen( pBuffer ); - pDest = hb_itemGetCPtr( pBuffer ); + if( !hb_itemGetWriteCL( pBuffer, &pDest, &ulDstLen ) ) + pDest = NULL; } else { diff --git a/harbour/source/rtl/hbzlibgz.c b/harbour/source/rtl/hbzlibgz.c index e84645f250..b65f45656c 100644 --- a/harbour/source/rtl/hbzlibgz.c +++ b/harbour/source/rtl/hbzlibgz.c @@ -82,7 +82,7 @@ static gzFile hb_gzParam( int iParam ) */ HB_FUNC( HB_GZOPEN ) { - char * cFile = hb_parc( 1 ), * cMode = hb_parc( 2 ); + const char * cFile = hb_parc( 1 ), * cMode = hb_parc( 2 ); if( cFile && cMode ) { gzFile gz = gzopen( cFile, cMode ); @@ -103,7 +103,7 @@ HB_FUNC( HB_GZOPEN ) */ HB_FUNC( HB_GZDOPEN ) { - char * cMode = hb_parc( 2 ); + const char * cMode = hb_parc( 2 ); if( HB_ISNUM( 1 ) && cMode ) { gzFile gz = gzdopen( hb_parni( 1 ), cMode ); @@ -157,15 +157,21 @@ HB_FUNC( HB_GZSETPARAMS ) HB_FUNC( HB_GZREAD ) { PHB_ITEM pBuffer = HB_ISBYREF( 2 ) ? hb_param( 2, HB_IT_STRING ) : NULL; + char * szBuffer; + ULONG ulLen; - if( pBuffer ) + if( pBuffer && hb_itemGetWriteCL( pBuffer, &szBuffer, &ulLen ) ) { gzFile gz = hb_gzParam( 1 ); if( gz ) { - pBuffer = hb_itemUnShareString( pBuffer ); - hb_retni( gzread( gz, hb_itemGetCPtr( pBuffer ), HB_ISNUM( 3 ) ? - ( ULONG ) hb_parnl( 3 ) : hb_itemGetCLen( pBuffer ) ) ); + if( HB_ISNUM( 3 ) ) + { + ULONG ulLim = ( ULONG ) hb_parnl( 3 ); + if( ulLim < ulLen ) + ulLen = ulLim; + } + hb_retni( gzread( gz, szBuffer, ulLen ) ); } } else @@ -177,7 +183,7 @@ HB_FUNC( HB_GZREAD ) */ HB_FUNC( HB_GZWRITE ) { - char * szData = hb_parc( 2 ); + const char * szData = hb_parc( 2 ); if( szData ) { gzFile gz = hb_gzParam( 1 ); @@ -220,7 +226,7 @@ HB_FUNC( HB_GZGETS ) */ HB_FUNC( HB_GZPUTS ) { - char * szData = hb_parc( 2 ); + const char * szData = hb_parc( 2 ); if( szData ) { gzFile gz = hb_gzParam( 1 ); diff --git a/harbour/source/rtl/is.c b/harbour/source/rtl/is.c index 60ce524820..0e945defe7 100644 --- a/harbour/source/rtl/is.c +++ b/harbour/source/rtl/is.c @@ -114,7 +114,7 @@ BOOL hb_charIsUpper( int iChar ) HB_FUNC( ISALPHA ) { - char * szString = hb_parc( 1 ); + const char * szString = hb_parc( 1 ); if( szString ) { @@ -141,7 +141,7 @@ HB_FUNC( ISALPHA ) HB_FUNC( ISDIGIT ) { - char * szString = hb_parc( 1 ); + const char * szString = hb_parc( 1 ); hb_retl( szString && HB_ISDIGIT( ( unsigned char ) *szString ) ); } @@ -150,7 +150,7 @@ HB_FUNC( ISDIGIT ) HB_FUNC( ISUPPER ) { - char * szString = hb_parc( 1 ); + const char * szString = hb_parc( 1 ); if( szString ) { @@ -176,7 +176,7 @@ HB_FUNC( ISUPPER ) HB_FUNC( ISLOWER ) { - char * szString = hb_parc( 1 ); + const char * szString = hb_parc( 1 ); if( szString ) { diff --git a/harbour/source/rtl/isprint.c b/harbour/source/rtl/isprint.c index 701c10b206..13881382ea 100644 --- a/harbour/source/rtl/isprint.c +++ b/harbour/source/rtl/isprint.c @@ -110,7 +110,7 @@ BOOL hb_printerIsReady( const char * pszPrinterName ) if( pszPrinterName == NULL ) pszPrinterName = "LPT1"; - fhnd = hb_fsOpen( ( BYTE * ) pszPrinterName, FO_WRITE | FO_SHARED | FO_PRIVATE ); + fhnd = hb_fsOpen( pszPrinterName, FO_WRITE | FO_SHARED | FO_PRIVATE ); bIsPrinter = ( fhnd != FS_ERROR ); hb_fsClose( fhnd ); } diff --git a/harbour/source/rtl/langapi.c b/harbour/source/rtl/langapi.c index 767ddb1776..83b9fd1301 100644 --- a/harbour/source/rtl/langapi.c +++ b/harbour/source/rtl/langapi.c @@ -302,9 +302,9 @@ PHB_LANG hb_langSelect( PHB_LANG lang ) return langOld; } -char * hb_langSelectID( const char * pszID ) +const char * hb_langSelectID( const char * pszID ) { - char * pszIDOld = hb_langID(); + const char * pszIDOld = hb_langID(); HB_TRACE(HB_TR_DEBUG, ("hb_langSelectID(%s)", pszID)); @@ -313,7 +313,7 @@ char * hb_langSelectID( const char * pszID ) return pszIDOld; } -char * hb_langDGetItem( int iIndex ) +const char * hb_langDGetItem( int iIndex ) { PHB_LANG lang; @@ -321,12 +321,12 @@ char * hb_langDGetItem( int iIndex ) lang = hb_vmLang(); if( lang && iIndex >= 0 && iIndex < HB_LANG_ITEM_MAX_ ) - return ( char * ) lang->pItemList[ iIndex ]; + return ( const char * ) lang->pItemList[ iIndex ]; else return NULL; } -char * hb_langID( void ) +const char * hb_langID( void ) { HB_TRACE(HB_TR_DEBUG, ("hb_langID()")); @@ -345,9 +345,9 @@ char * hb_langName( void ) { pszName = ( char * ) hb_xgrab( 128 ); hb_snprintf( pszName, 128, "Harbour Language: %s %s (%s)", - ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_ID ), - ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_NAME ), - ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_NAMENAT ) ); + ( const char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_ID ), + ( const char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_NAME ), + ( const char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_ID + HB_LANG_ITEM_ID_NAMENAT ) ); } else pszName = hb_strdup( "Harbour Language: (not installed)" ); @@ -357,18 +357,18 @@ char * hb_langName( void ) /* Compatibility interface */ -char * hb_langDGetErrorDesc( ULONG ulIndex ) +const char * hb_langDGetErrorDesc( ULONG ulIndex ) { HB_TRACE(HB_TR_DEBUG, ("hb_langDGetErrorDesc(%lu)", ulIndex)); - return ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_ERRDESC + ulIndex ); + return hb_langDGetItem( HB_LANG_ITEM_BASE_ERRDESC + ulIndex ); } /* Harbour interface */ HB_FUNC( HB_LANGSELECT ) { - char * szNewLang; + const char * szNewLang; hb_retc( hb_langID() ); diff --git a/harbour/source/rtl/math.c b/harbour/source/rtl/math.c index ccdee6d608..cc3b3ccc55 100644 --- a/harbour/source/rtl/math.c +++ b/harbour/source/rtl/math.c @@ -286,7 +286,7 @@ int matherr( struct exception *err ) break; } - pExc->funcname = ( char * ) err->name; /* (char *) Avoid warning in DJGPP */ + pExc->funcname = err->name; pExc->arg1 = err->arg1; pExc->arg2 = err->arg2; pExc->retval = err->retval; diff --git a/harbour/source/rtl/memofile.c b/harbour/source/rtl/memofile.c index 5e8bf13c50..bc621ed5e6 100644 --- a/harbour/source/rtl/memofile.c +++ b/harbour/source/rtl/memofile.c @@ -64,7 +64,7 @@ static void hb_memoread( BOOL bHandleEOF ) if( pFileName ) { - HB_FHANDLE fhnd = hb_fsOpen( ( BYTE * ) hb_itemGetCPtr( pFileName ), FO_READ | FO_SHARED | FO_PRIVATE ); + HB_FHANDLE fhnd = hb_fsOpen( hb_itemGetCPtr( pFileName ), FO_READ | FO_SHARED | FO_PRIVATE ); if( fhnd != FS_ERROR ) { @@ -128,7 +128,7 @@ static BOOL hb_memowrit( BOOL bHandleEOF ) if( pFileName && pString ) { - HB_FHANDLE fhnd = hb_fsCreate( ( BYTE * ) hb_itemGetCPtr( pFileName ), FC_NORMAL ); + HB_FHANDLE fhnd = hb_fsCreate( hb_itemGetCPtr( pFileName ), FC_NORMAL ); if( fhnd != FS_ERROR ) { diff --git a/harbour/source/rtl/mlcfunc.c b/harbour/source/rtl/mlcfunc.c index 9cb4c9625e..17a6c6e17c 100644 --- a/harbour/source/rtl/mlcfunc.c +++ b/harbour/source/rtl/mlcfunc.c @@ -56,11 +56,11 @@ typedef struct { - char * szEOL; - ULONG ulLen; + const char * szEOL; + ULONG ulLen; } HB_EOL_INFO, * PHB_EOL_INFO; -static int hb_mlEol( char * pszString, ULONG ulLen, +static int hb_mlEol( const char * pszString, ULONG ulLen, PHB_EOL_INFO pEOLs, int iEOLs ) { int i; @@ -73,7 +73,7 @@ static int hb_mlEol( char * pszString, ULONG ulLen, return -1; } -static ULONG hb_mlGetLine( char * pszString, ULONG ulLen, ULONG ulOffset, +static ULONG hb_mlGetLine( const char * pszString, ULONG ulLen, ULONG ulOffset, ULONG ulLineLength, ULONG ulTabSize, ULONG ulMaxPos, BOOL fWordWrap, PHB_EOL_INFO pEOLs, int iEOLs, ULONG * pulLen, ULONG * pulEOL ) @@ -215,11 +215,12 @@ static PHB_EOL_INFO hb_mlGetEOLs( int iParam, int * piEOLs ) return pEOLs; } -static char * hb_mlGetParams( int iParAdd, ULONG * pulLen, ULONG * pulLineLength, - ULONG * pulTabSize, BOOL * pfWordWrap, - PHB_EOL_INFO * pEOLs, int * piEOLs ) +static const char * hb_mlGetParams( int iParAdd, ULONG * pulLen, + ULONG * pulLineLength, + ULONG * pulTabSize, BOOL * pfWordWrap, + PHB_EOL_INFO * pEOLs, int * piEOLs ) { - char * pszString = hb_parc( 1 ); + const char * pszString = hb_parc( 1 ); if( pszString ) { if( HB_ISNUM( 2 ) ) @@ -252,8 +253,9 @@ HB_FUNC( MEMOLINE ) BOOL fWordWrap; PHB_EOL_INFO pEOLs; int iEOLs; - char * pszString = hb_mlGetParams( 1, &ulLen, &ulLineLength, - &ulTabSize, &fWordWrap, &pEOLs, &iEOLs ); + const char * pszString = hb_mlGetParams( 1, &ulLen, &ulLineLength, + &ulTabSize, &fWordWrap, + &pEOLs, &iEOLs ); char * szLine; ULONG ulLine = hb_parnl( 3 ); ULONG ulOffset = 0; @@ -313,8 +315,9 @@ HB_FUNC( MLCOUNT ) BOOL fWordWrap; PHB_EOL_INFO pEOLs; int iEOLs; - char * pszString = hb_mlGetParams( 0, &ulLen, &ulLineLength, - &ulTabSize, &fWordWrap, &pEOLs, &iEOLs ); + const char * pszString = hb_mlGetParams( 0, &ulLen, &ulLineLength, + &ulTabSize, &fWordWrap, + &pEOLs, &iEOLs ); ULONG ulLines = 0; ULONG ulOffset = 0; ULONG ulCols = 0; @@ -339,8 +342,9 @@ HB_FUNC( MLPOS ) BOOL fWordWrap; PHB_EOL_INFO pEOLs; int iEOLs; - char * pszString = hb_mlGetParams( 1, &ulLen, &ulLineLength, - &ulTabSize, &fWordWrap, &pEOLs, &iEOLs ); + const char * pszString = hb_mlGetParams( 1, &ulLen, &ulLineLength, + &ulTabSize, &fWordWrap, + &pEOLs, &iEOLs ); ULONG ulLine = hb_parnl( 3 ); ULONG ulOffset = 0; ULONG ulCols = 0; @@ -366,8 +370,9 @@ HB_FUNC( MLCTOPOS ) BOOL fWordWrap; PHB_EOL_INFO pEOLs; int iEOLs; - char * pszString = hb_mlGetParams( 2, &ulLen, &ulLineLength, - &ulTabSize, &fWordWrap, &pEOLs, &iEOLs ); + const char * pszString = hb_mlGetParams( 2, &ulLen, &ulLineLength, + &ulTabSize, &fWordWrap, + &pEOLs, &iEOLs ); ULONG ulLine = hb_parnl( 3 ); ULONG ulCol = hb_parnl( 4 ); ULONG ulOffset = 0; @@ -398,8 +403,9 @@ HB_FUNC( MPOSTOLC ) BOOL fWordWrap; PHB_EOL_INFO pEOLs; int iEOLs; - char * pszString = hb_mlGetParams( 1, &ulLen, &ulLineLength, - &ulTabSize, &fWordWrap, &pEOLs, &iEOLs ); + const char * pszString = hb_mlGetParams( 1, &ulLen, &ulLineLength, + &ulTabSize, &fWordWrap, + &pEOLs, &iEOLs ); ULONG ulPos = hb_parnl( 3 ); ULONG ulOffset = 0; ULONG ulLine = 0; diff --git a/harbour/source/rtl/mouseapi.c b/harbour/source/rtl/mouseapi.c index 9e08c94743..26d77389a3 100644 --- a/harbour/source/rtl/mouseapi.c +++ b/harbour/source/rtl/mouseapi.c @@ -234,7 +234,7 @@ void hb_mouseSaveState( BYTE * pBuffer ) } } -void hb_mouseRestoreState( BYTE * pBuffer ) +void hb_mouseRestoreState( const BYTE * pBuffer ) { PHB_GT pGT; diff --git a/harbour/source/rtl/natmsg.c b/harbour/source/rtl/natmsg.c index 8ac229a71f..571e97106b 100644 --- a/harbour/source/rtl/natmsg.c +++ b/harbour/source/rtl/natmsg.c @@ -84,25 +84,25 @@ #define _LF_YN 12 /* "Y/N" */ /* NOTE: This must be in uppercase. [vszakats] */ #define _INVALID_EXPR 13 /* "INVALID EXPRESSION" */ -static char * hb_nationGetMsg( int iMsg ) +static const char * hb_nationGetMsg( int iMsg ) { HB_TRACE(HB_TR_DEBUG, ("hb_nationGetMsg(%hu)", iMsg)); - return ( iMsg >= 1 && iMsg <= 13 ) ? ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_NATMSG + iMsg - 1 ) : ( char * ) ""; + return ( iMsg >= 1 && iMsg <= 13 ) ? hb_langDGetItem( HB_LANG_ITEM_BASE_NATMSG + iMsg - 1 ) : ""; } HB_FUNC( __NATISAFFIRM ) { PHB_ITEM pItem = hb_param( 1, HB_IT_STRING ); - hb_retl( pItem && hb_itemGetCLen( pItem ) >= 1 && hb_charUpper( hb_itemGetCPtr( pItem )[ 0 ] ) == ( ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_NATMSG + _LF_YN - 1 ) )[ 0 ] ); + hb_retl( pItem && hb_itemGetCLen( pItem ) >= 1 && hb_charUpper( hb_itemGetCPtr( pItem )[ 0 ] ) == hb_langDGetItem( HB_LANG_ITEM_BASE_NATMSG + _LF_YN - 1 )[ 0 ] ); } HB_FUNC( __NATISNEGATIVE ) { PHB_ITEM pItem = hb_param( 1, HB_IT_STRING ); - hb_retl( pItem && hb_itemGetCLen( pItem ) >= 1 && hb_charUpper( hb_itemGetCPtr( pItem )[ 0 ] ) == ( ( char * ) hb_langDGetItem( HB_LANG_ITEM_BASE_NATMSG + _LF_YN - 1 ) )[ 2 ] ); + hb_retl( pItem && hb_itemGetCLen( pItem ) >= 1 && hb_charUpper( hb_itemGetCPtr( pItem )[ 0 ] ) == hb_langDGetItem( HB_LANG_ITEM_BASE_NATMSG + _LF_YN - 1 )[ 2 ] ); } HB_FUNC( __NATMSG ) diff --git a/harbour/source/rtl/oemansi.c b/harbour/source/rtl/oemansi.c index ef2a4e6f39..3649c52118 100644 --- a/harbour/source/rtl/oemansi.c +++ b/harbour/source/rtl/oemansi.c @@ -68,7 +68,7 @@ HB_FUNC( HB_ANSITOOEM ) DWORD ulLen = hb_itemGetCLen( pString ); char * pszDst = ( char * ) hb_xgrab( ulLen + 1 ); - CharToOemBuffA( ( LPCSTR ) hb_itemGetCPtr( pString ), ( LPSTR ) pszDst, ulLen ); + CharToOemBuffA( hb_itemGetCPtr( pString ), pszDst, ulLen ); hb_retclen_buffer( pszDst, ulLen ); } @@ -89,7 +89,7 @@ HB_FUNC( HB_OEMTOANSI ) DWORD ulLen = hb_itemGetCLen( pString ); char * pszDst = ( char * ) hb_xgrab( ulLen + 1 ); - OemToCharBuffA( ( LPCSTR ) hb_itemGetCPtr( pString ), ( LPSTR ) pszDst, ulLen ); + OemToCharBuffA( hb_itemGetCPtr( pString ), pszDst, ulLen ); hb_retclen_buffer( pszDst, ulLen ); } diff --git a/harbour/source/rtl/oldbox.c b/harbour/source/rtl/oldbox.c index 7e4d1b1f35..4e90af9d41 100644 --- a/harbour/source/rtl/oldbox.c +++ b/harbour/source/rtl/oldbox.c @@ -62,14 +62,14 @@ HB_FUNC( __BOX ) PHB_ITEM pLeft = hb_param( 2, HB_IT_NUMERIC ); PHB_ITEM pBottom = hb_param( 3, HB_IT_NUMERIC ); PHB_ITEM pRight = hb_param( 4, HB_IT_NUMERIC ); - char * pszBox = hb_parc( 5 ); + const char * pszBox = hb_parc( 5 ); if( pTop && pLeft && pBottom && pRight && pszBox ) hb_gtBox( ( SHORT ) hb_itemGetNI( pTop ), ( SHORT ) hb_itemGetNI( pLeft), ( SHORT ) hb_itemGetNI( pBottom ), ( SHORT ) hb_itemGetNI( pRight ), - ( BYTE * ) ( *pszBox ? pszBox : " " ) ); + ( const BYTE * ) ( *pszBox ? pszBox : " " ) ); } HB_FUNC( __BOXD ) diff --git a/harbour/source/rtl/philes.c b/harbour/source/rtl/philes.c index 125c6f0cbf..1e2c994b22 100644 --- a/harbour/source/rtl/philes.c +++ b/harbour/source/rtl/philes.c @@ -61,9 +61,10 @@ HB_FUNC( FOPEN ) { - if( HB_ISCHAR( 1 ) ) + const char * szFile = hb_parc( 1 ); + if( szFile ) { - hb_retnint( ( HB_NHANDLE ) hb_fsOpen( ( BYTE * ) hb_parc( 1 ), + hb_retnint( ( HB_NHANDLE ) hb_fsOpen( szFile, HB_ISNUM( 2 ) ? ( USHORT ) hb_parni( 2 ) : FO_READ | FO_COMPAT ) ); hb_fsSetFError( hb_fsError() ); } @@ -77,9 +78,10 @@ HB_FUNC( FOPEN ) HB_FUNC( FCREATE ) { - if( HB_ISCHAR( 1 ) ) + const char * szFile = hb_parc( 1 ); + if( szFile ) { - hb_retnint( ( HB_NHANDLE ) hb_fsCreate( ( BYTE * ) hb_parc( 1 ), + hb_retnint( ( HB_NHANDLE ) hb_fsCreate( szFile, HB_ISNUM( 2 ) ? hb_parni( 2 ) : FC_NORMAL ) ); hb_fsSetFError( hb_fsError() ); } @@ -92,9 +94,10 @@ HB_FUNC( FCREATE ) HB_FUNC( HB_FCREATE ) { - if( HB_ISCHAR( 1 ) ) + const char * szFile = hb_parc( 1 ); + if( szFile ) { - hb_retnint( ( HB_NHANDLE ) hb_fsCreateEx( ( BYTE * ) hb_parc( 1 ), + hb_retnint( ( HB_NHANDLE ) hb_fsCreateEx( szFile, HB_ISNUM( 2 ) ? hb_parni( 2 ) : FC_NORMAL, HB_ISNUM( 3 ) ? ( USHORT ) hb_parni( 3 ) : FO_COMPAT ) ); hb_fsSetFError( hb_fsError() ); @@ -110,7 +113,8 @@ HB_FUNC( FREAD ) { PHB_ITEM pBuffer = hb_param( 2, HB_IT_STRING ); USHORT uiError = 0; - ULONG ulRead = 0; + ULONG ulRead = 0, ulSize; + char * buffer; if( HB_ISNUM( 1 ) && pBuffer && HB_ISBYREF( 2 ) && HB_ISNUM( 3 ) ) { @@ -121,18 +125,11 @@ HB_FUNC( FREAD ) will be one more than the length of the passed buffer, because the terminating zero could be used if needed. [vszakats] */ - if( ulRead <= hb_parcsiz( 2 ) ) + if( ulRead <= hb_parcsiz( 2 ) && + hb_itemGetWriteCL( pBuffer, &buffer, &ulSize ) ) { - /* NOTE: Warning, the read buffer will be directly modified, - this is normal here ! [vszakats] */ - - /* Unshare the item to avoid GPF on static buffers and changing - other items which shares this buffer. [druzus] */ - pBuffer = hb_itemUnShareString( pBuffer ); - ulRead = hb_fsReadLarge( hb_numToHandle( hb_parnint( 1 ) ), - ( BYTE * ) hb_itemGetCPtr( pBuffer ), - ulRead ); + ( BYTE * ) buffer, ulRead ); uiError = hb_fsError(); } else @@ -159,8 +156,7 @@ HB_FUNC( FWRITE ) } hb_retnl( hb_fsWriteLarge( hb_numToHandle( hb_parnint( 1 ) ), - ( BYTE * ) hb_parc( 2 ), - nLen ) ); + ( const BYTE * ) hb_parc( 2 ), nLen ) ); uiError = hb_fsError(); } else @@ -190,10 +186,11 @@ HB_FUNC( FCLOSE ) HB_FUNC( FERASE ) { USHORT uiError = 3; + const char * szFile = hb_parc( 1 ); - if( HB_ISCHAR( 1 ) ) + if( szFile ) { - hb_retni( hb_fsDelete( ( BYTE * ) hb_parc( 1 ) ) ? 0 : F_ERROR ); + hb_retni( hb_fsDelete( szFile ) ? 0 : F_ERROR ); uiError = hb_fsError(); } else @@ -204,11 +201,12 @@ HB_FUNC( FERASE ) HB_FUNC( FRENAME ) { USHORT uiError = 2; + const char * szFileOld = hb_parc( 1 ), + * szFileNew = hb_parc( 1 ); - if( HB_ISCHAR( 1 ) && HB_ISCHAR( 2 ) ) + if( szFileOld && szFileNew ) { - hb_retni( hb_fsRename( ( BYTE * ) hb_parc( 1 ), - ( BYTE * ) hb_parc( 2 ) ) ? 0 : F_ERROR ); + hb_retni( hb_fsRename( szFileOld, szFileNew ) ? 0 : F_ERROR ); uiError = hb_fsError(); } else @@ -269,9 +267,9 @@ HB_FUNC( FREADSTR ) HB_FUNC( CURDIR ) { - BYTE byBuffer[ HB_PATH_MAX ]; + char szBuffer[ HB_PATH_MAX ]; USHORT uiDrive = 0; - char * szDrive; + const char * szDrive; szDrive = hb_parc( 1 ); if( szDrive ) @@ -281,9 +279,9 @@ HB_FUNC( CURDIR ) else if( *szDrive >= 'a' && *szDrive <= 'z' ) uiDrive = *szDrive - ( 'a' - 1 ); } - hb_fsCurDirBuff( uiDrive, byBuffer, sizeof( byBuffer ) ); + hb_fsCurDirBuff( uiDrive, szBuffer, sizeof( szBuffer ) ); - hb_retc( ( char * ) byBuffer ); + hb_retc( szBuffer ); } HB_FUNC( HB_PROGNAME ) @@ -293,13 +291,14 @@ HB_FUNC( HB_PROGNAME ) if( szBaseName ) { /* Convert from OS codepage */ - BOOL fFree; - char * pbyResult = ( char * ) hb_osDecode( ( BYTE * ) szBaseName, &fFree ); + char * pszFree; - if( fFree ) - hb_retc_buffer( pbyResult ); + szBaseName = hb_osDecode( szBaseName, &pszFree ); + + if( pszFree ) + hb_retc_buffer( pszFree ); else - hb_retc( pbyResult ); + hb_retc( szBaseName ); } else hb_retc( NULL ); @@ -307,11 +306,11 @@ HB_FUNC( HB_PROGNAME ) HB_FUNC( HB_DIRBASE ) { - BYTE byBuffer[ HB_PATH_MAX ]; + char szBuffer[ HB_PATH_MAX ]; - hb_fsBaseDirBuff( byBuffer ); + hb_fsBaseDirBuff( szBuffer ); - hb_retc( ( char * ) byBuffer ); + hb_retc( szBuffer ); } HB_FUNC( HB_FEOF ) @@ -379,14 +378,14 @@ HB_FUNC( HB_FGETATTR ) { ULONG nAttr; - hb_retl( hb_fsGetAttr( ( UCHAR * ) hb_parcx( 1 ), &nAttr ) ); + hb_retl( hb_fsGetAttr( hb_parcx( 1 ), &nAttr ) ); hb_stornl( nAttr, 2 ); } HB_FUNC( HB_FSETATTR ) { - hb_retl( hb_fsSetAttr( ( UCHAR * ) hb_parcx( 1 ), hb_parnl( 2 ) ) ); + hb_retl( hb_fsSetAttr( hb_parcx( 1 ), hb_parnl( 2 ) ) ); } HB_FUNC( HB_FSETDATETIME ) @@ -407,14 +406,14 @@ HB_FUNC( HB_FSETDATETIME ) } } - hb_retl( hb_fsSetFileTime( ( UCHAR * ) hb_parcx( 1 ), lDate, lTime ) ); + hb_retl( hb_fsSetFileTime( hb_parcx( 1 ), lDate, lTime ) ); } HB_FUNC( HB_FGETDATETIME ) { LONG lJulian, lMillisec; - if( hb_fsGetFileTime( ( UCHAR * ) hb_parcx( 1 ), &lJulian, &lMillisec ) ) + if( hb_fsGetFileTime( hb_parcx( 1 ), &lJulian, &lMillisec ) ) { if( HB_ISBYREF( 3 ) ) { diff --git a/harbour/source/rtl/philesx.c b/harbour/source/rtl/philesx.c index e955e7dce2..121642aae3 100644 --- a/harbour/source/rtl/philesx.c +++ b/harbour/source/rtl/philesx.c @@ -61,7 +61,8 @@ HB_FUNC( CURDRIVE ) { #if defined(HB_OS_HAS_DRIVE_LETTER) - char szCurDrive[ 1 ], * szDrive; + char szCurDrive[ 1 ]; + const char * szDrive; szCurDrive[ 0 ] = ( ( char ) hb_fsCurDrv() ) + 'A'; hb_retclen( szCurDrive, 1 ); diff --git a/harbour/source/rtl/rat.c b/harbour/source/rtl/rat.c index adecda5fdc..d6ca9cc1e6 100644 --- a/harbour/source/rtl/rat.c +++ b/harbour/source/rtl/rat.c @@ -62,8 +62,8 @@ HB_FUNC( RAT ) if( lPos >= 0 ) { - char * pszSub = hb_parc( 1 ); - char * pszText = hb_parc( 2 ); + const char * pszSub = hb_parc( 1 ); + const char * pszText = hb_parc( 2 ); BOOL bFound = FALSE; while( lPos >= 0 && !bFound ) @@ -93,8 +93,8 @@ HB_FUNC( HB_RAT ) if( lPos >= 0 ) { - char * pszSub = hb_parc( 1 ); - char * pszText = hb_parc( 2 ); + const char * pszSub = hb_parc( 1 ); + const char * pszText = hb_parc( 2 ); BOOL bFound = FALSE; long lStart; diff --git a/harbour/source/rtl/replic.c b/harbour/source/rtl/replic.c index ed96c4b70e..343b66d41a 100644 --- a/harbour/source/rtl/replic.c +++ b/harbour/source/rtl/replic.c @@ -68,7 +68,7 @@ HB_FUNC( REPLICATE ) if( ( double ) ( ( double ) ulLen * ( double ) lTimes ) < ( double ) ULONG_MAX ) { - char * szText = hb_parc( 1 ); + const char * szText = hb_parc( 1 ); char * szResult = ( char * ) hb_xgrab( ( ulLen * lTimes ) + 1 ); char * szPtr = szResult; long i; diff --git a/harbour/source/rtl/run.c b/harbour/source/rtl/run.c index 35f3acff91..8b5ba27613 100644 --- a/harbour/source/rtl/run.c +++ b/harbour/source/rtl/run.c @@ -60,17 +60,16 @@ HB_FUNC( __RUN ) { - if( HB_ISCHAR( 1 ) && hb_gtSuspend() == 0 ) + const char * pszCommand = hb_parc( 1 ); + + if( pszCommand && hb_gtSuspend() == 0 ) { - char * pszCommand = hb_itemGetC( hb_param( 1, HB_IT_STRING ) ); - BOOL fFree; - char * pszResult = ( char * ) hb_osEncode( ( BYTE * ) pszCommand, &fFree ); + char * pszFree; - if( system( pszResult ) != 0 ) {} + if( system( hb_osEncode( pszCommand, &pszFree ) ) != 0 ) {} - hb_itemFreeC( pszCommand ); - if( fFree ) - hb_xfree( pszResult ); + if( pszFree ) + hb_xfree( pszFree ); if( hb_gtResume() != 0 ) { diff --git a/harbour/source/rtl/samples.c b/harbour/source/rtl/samples.c index aef0911bda..9d4fc3710e 100644 --- a/harbour/source/rtl/samples.c +++ b/harbour/source/rtl/samples.c @@ -76,7 +76,7 @@ static char * hb_SecToTimeStr( char * pszTime, ULONG ulTime ) return pszTime; } -static ULONG hb_TimeStrToSec( char * pszTime ) +static ULONG hb_TimeStrToSec( const char * pszTime ) { ULONG ulLen; ULONG ulTime = 0; diff --git a/harbour/source/rtl/setcolor.c b/harbour/source/rtl/setcolor.c index acd84f5d4c..1480d0bd0b 100644 --- a/harbour/source/rtl/setcolor.c +++ b/harbour/source/rtl/setcolor.c @@ -54,7 +54,7 @@ #include "hbapigt.h" #include "hbset.h" -char * hb_conSetColor( const char * szColor ) +const char * hb_conSetColor( const char * szColor ) { char * szOldColor; @@ -63,7 +63,7 @@ char * hb_conSetColor( const char * szColor ) szOldColor = hb_setGetColor(); hb_gtGetColorStr( szOldColor ); - if( szColor != ( char * ) NULL ) + if( szColor != NULL ) hb_gtSetColorStr( szColor ); return szOldColor; diff --git a/harbour/source/rtl/soundex.c b/harbour/source/rtl/soundex.c index 14a1acaa2e..71f33954b4 100644 --- a/harbour/source/rtl/soundex.c +++ b/harbour/source/rtl/soundex.c @@ -68,7 +68,7 @@ HB_FUNC( SOUNDEX ) if( pString ) { - char * pszString = hb_itemGetCPtr( pString ); + const char * pszString = hb_itemGetCPtr( pString ); ULONG ulLen = hb_itemGetCLen( pString ); ULONG nPos = 0; ULONG nResultPos = 0; diff --git a/harbour/source/rtl/spfiles.c b/harbour/source/rtl/spfiles.c index d8594d2f7e..efafc86abd 100644 --- a/harbour/source/rtl/spfiles.c +++ b/harbour/source/rtl/spfiles.c @@ -53,33 +53,33 @@ #include "hbapifs.h" #include "hbset.h" -BOOL hb_spFile( BYTE * pFilename, BYTE * pRetPath ) +BOOL hb_spFile( const char * pFilename, char * pRetPath ) { - BYTE *Path; + char *Path; BOOL bIsFile = FALSE; PHB_FNAME pFilepath; - HB_TRACE(HB_TR_DEBUG, ("hb_spFile(%s, %p)", (char*) pFilename, pRetPath)); + HB_TRACE(HB_TR_DEBUG, ("hb_spFile(%s, %p)", pFilename, pRetPath)); if( pRetPath ) Path = pRetPath; else - Path = ( BYTE * ) hb_xgrab( HB_PATH_MAX ); + Path = ( char * ) hb_xgrab( HB_PATH_MAX ); - pFilepath = hb_fsFNameSplit( ( char * ) pFilename ); + pFilepath = hb_fsFNameSplit( pFilename ); if( pFilepath->szPath ) { - hb_fsFNameMerge( ( char * ) Path, pFilepath ); + hb_fsFNameMerge( Path, pFilepath ); bIsFile = hb_fsFile( Path ); } else { - char * szDefault = hb_setGetDefault(); + const char * szDefault = hb_setGetDefault(); if( szDefault ) { pFilepath->szPath = szDefault; - hb_fsFNameMerge( ( char * ) Path, pFilepath ); + hb_fsFNameMerge( Path, pFilepath ); bIsFile = hb_fsFile( Path ); } @@ -90,7 +90,7 @@ BOOL hb_spFile( BYTE * pFilename, BYTE * pRetPath ) while( bIsFile == FALSE && NextPath ) { pFilepath->szPath = NextPath->szPath; - hb_fsFNameMerge( ( char * ) Path, pFilepath ); + hb_fsFNameMerge( Path, pFilepath ); bIsFile = hb_fsFile( Path ); NextPath = NextPath->pNext; } @@ -104,8 +104,8 @@ BOOL hb_spFile( BYTE * pFilename, BYTE * pRetPath ) */ if( ! bIsFile ) { - pFilepath->szPath = szDefault ? szDefault : ( char * ) "."; - hb_fsFNameMerge( ( char * ) Path, pFilepath ); + pFilepath->szPath = szDefault ? szDefault : "."; + hb_fsFNameMerge( Path, pFilepath ); } } @@ -117,34 +117,34 @@ BOOL hb_spFile( BYTE * pFilename, BYTE * pRetPath ) return bIsFile; } -BOOL hb_spFileExists( BYTE * pFilename, BYTE * pRetPath ) +BOOL hb_spFileExists( const char * pFilename, char * pRetPath ) { - BYTE *Path; + char *Path; BOOL bIsFile = FALSE; PHB_FNAME pFilepath; - HB_TRACE(HB_TR_DEBUG, ("hb_spFile(%s, %p)", (char*) pFilename, pRetPath)); + HB_TRACE(HB_TR_DEBUG, ("hb_spFile(%s, %p)", pFilename, pRetPath)); if( pRetPath ) Path = pRetPath; else - Path = ( BYTE * ) hb_xgrab( HB_PATH_MAX ); + Path = ( char * ) hb_xgrab( HB_PATH_MAX ); - pFilepath = hb_fsFNameSplit( ( char * ) pFilename ); + pFilepath = hb_fsFNameSplit( pFilename ); if( pFilepath->szPath ) { - hb_fsFNameMerge( ( char * ) Path, pFilepath ); - bIsFile = hb_fsFileExists( ( const char * ) Path ); + hb_fsFNameMerge( Path, pFilepath ); + bIsFile = hb_fsFileExists( Path ); } else { - char * szDefault = hb_setGetDefault(); + const char * szDefault = hb_setGetDefault(); if( szDefault ) { pFilepath->szPath = szDefault; - hb_fsFNameMerge( ( char * ) Path, pFilepath ); - bIsFile = hb_fsFileExists( ( const char * ) Path ); + hb_fsFNameMerge( Path, pFilepath ); + bIsFile = hb_fsFileExists( Path ); } if( !bIsFile && hb_setGetPath() ) @@ -154,8 +154,8 @@ BOOL hb_spFileExists( BYTE * pFilename, BYTE * pRetPath ) while( bIsFile == FALSE && NextPath ) { pFilepath->szPath = NextPath->szPath; - hb_fsFNameMerge( ( char * ) Path, pFilepath ); - bIsFile = hb_fsFileExists( ( const char * ) Path ); + hb_fsFNameMerge( Path, pFilepath ); + bIsFile = hb_fsFileExists( Path ); NextPath = NextPath->pNext; } } @@ -168,8 +168,8 @@ BOOL hb_spFileExists( BYTE * pFilename, BYTE * pRetPath ) */ if( ! bIsFile ) { - pFilepath->szPath = szDefault ? szDefault : ( char * ) "."; - hb_fsFNameMerge( ( char * ) Path, pFilepath ); + pFilepath->szPath = szDefault ? szDefault : "."; + hb_fsFNameMerge( Path, pFilepath ); } } @@ -181,9 +181,9 @@ BOOL hb_spFileExists( BYTE * pFilename, BYTE * pRetPath ) return bIsFile; } -HB_FHANDLE hb_spOpen( BYTE * pFilename, USHORT uiFlags ) +HB_FHANDLE hb_spOpen( const char * pFilename, USHORT uiFlags ) { - BYTE path[ HB_PATH_MAX ]; + char path[ HB_PATH_MAX ]; HB_TRACE(HB_TR_DEBUG, ("hb_spOpen(%p, %hu)", pFilename, uiFlags)); @@ -193,35 +193,35 @@ HB_FHANDLE hb_spOpen( BYTE * pFilename, USHORT uiFlags ) return hb_fsOpen( pFilename, uiFlags ); } -HB_FHANDLE hb_spCreate( BYTE * pFilename, ULONG ulAttr ) +HB_FHANDLE hb_spCreate( const char * pFilename, ULONG ulAttr ) { - BYTE path[ HB_PATH_MAX ]; + char path[ HB_PATH_MAX ]; PHB_FNAME pFilepath; HB_TRACE(HB_TR_DEBUG, ("hb_spCreate(%p, %lu)", pFilename, ulAttr)); - pFilepath = hb_fsFNameSplit( ( char * ) pFilename ); + pFilepath = hb_fsFNameSplit( pFilename ); if( ! pFilepath->szPath ) pFilepath->szPath = hb_setGetDefault(); - hb_fsFNameMerge( ( char * ) path, pFilepath ); + hb_fsFNameMerge( path, pFilepath ); hb_xfree( pFilepath ); return hb_fsCreate( path, ulAttr ); } -HB_FHANDLE hb_spCreateEx( BYTE * pFilename, ULONG ulAttr, USHORT uiFlags ) +HB_FHANDLE hb_spCreateEx( const char * pFilename, ULONG ulAttr, USHORT uiFlags ) { - BYTE path[ HB_PATH_MAX ]; + char path[ HB_PATH_MAX ]; PHB_FNAME pFilepath; HB_TRACE(HB_TR_DEBUG, ("hb_spCreateEx(%p, %lu, %hu)", pFilename, ulAttr, uiFlags)); - pFilepath = hb_fsFNameSplit( ( char * ) pFilename ); + pFilepath = hb_fsFNameSplit( pFilename ); if( ! pFilepath->szPath ) pFilepath->szPath = hb_setGetDefault(); - hb_fsFNameMerge( ( char * ) path, pFilepath ); + hb_fsFNameMerge( path, pFilepath ); hb_xfree( pFilepath ); return hb_fsCreateEx( path, ulAttr, uiFlags ); diff --git a/harbour/source/rtl/strpeek.c b/harbour/source/rtl/strpeek.c index 7784fcb6c1..ea723ddba7 100644 --- a/harbour/source/rtl/strpeek.c +++ b/harbour/source/rtl/strpeek.c @@ -80,12 +80,13 @@ HB_FUNC( STRPOKE ) if( pText && HB_ISNUM( 2 ) && HB_ISNUM( 3 ) ) { - ULONG ulPos = hb_parnl( 2 ); + ULONG ulPos = hb_parnl( 2 ), ulLen; + char * pszText; - if( ulPos > 0 && ulPos <= hb_itemGetCLen( pText ) ) + if( ulPos > 0 && hb_itemGetWriteCL( pText, &pszText, &ulLen ) && + ulPos <= ulLen ) { - pText = hb_itemUnShareString( pText ); - hb_itemGetCPtr( pText )[ ulPos - 1 ] = (char) ( hb_parni( 3 ) & 0xff ); + pszText[ ulPos - 1 ] = ( char ) ( hb_parni( 3 ) & 0xff ); } hb_itemReturn( pText ); } diff --git a/harbour/source/rtl/stuff.c b/harbour/source/rtl/stuff.c index a7770d5098..9996a4c5aa 100644 --- a/harbour/source/rtl/stuff.c +++ b/harbour/source/rtl/stuff.c @@ -57,7 +57,7 @@ HB_FUNC( STUFF ) { if( HB_ISCHAR( 1 ) && HB_ISNUM( 2 ) && HB_ISNUM( 3 ) && HB_ISCHAR( 4 ) ) { - char * szText = hb_parc( 1 ); + const char * szText = hb_parc( 1 ); ULONG ulText = hb_parclen( 1 ); ULONG ulPos = hb_parnl( 2 ); ULONG ulDel = hb_parnl( 3 ); diff --git a/harbour/source/rtl/trace.c b/harbour/source/rtl/trace.c index 4c3580e61e..83ffbb99e1 100644 --- a/harbour/source/rtl/trace.c +++ b/harbour/source/rtl/trace.c @@ -65,7 +65,7 @@ HB_FUNC( HB_TRACELEVEL ) HB_FUNC( HB_TRACESTRING ) { - char * szMessage = hb_parcx( 1 ); + const char * szMessage = hb_parc( 1 ); if( szMessage ) { HB_TRACE(HB_TR_ALWAYS, ("%s", szMessage) ); diff --git a/harbour/source/rtl/transfrm.c b/harbour/source/rtl/transfrm.c index b0e00c2c8f..63ba96baa5 100644 --- a/harbour/source/rtl/transfrm.c +++ b/harbour/source/rtl/transfrm.c @@ -94,7 +94,7 @@ HB_FUNC( TRANSFORM ) if( pPic && hb_itemGetCLen( pPic ) > 0 ) { char szPicDate[ 11 ]; - char * szPic = hb_itemGetCPtr( pPic ); + const char * szPic = hb_itemGetCPtr( pPic ); ULONG ulPicLen = hb_itemGetCLen( pPic ); USHORT uiPicFlags; /* Function flags */ @@ -197,7 +197,7 @@ HB_FUNC( TRANSFORM ) if( HB_IS_STRING( pValue ) ) { - char * szExp = hb_itemGetCPtr( pValue ); + const char * szExp = hb_itemGetCPtr( pValue ); ULONG ulExpLen = hb_itemGetCLen( pValue ); ULONG ulExpPos = 0; BOOL bAnyPic = FALSE; @@ -654,9 +654,9 @@ HB_FUNC( TRANSFORM ) else if( HB_IS_DATE( pValue ) ) { - char szDate[ 9 ]; - char * szDateFormat; + const char * szDateFormat; char szNewFormat[ 11 ]; + char szDate[ 9 ]; UINT nFor; szResult = ( char * ) hb_xgrab( 13 ); @@ -755,7 +755,7 @@ HB_FUNC( TRANSFORM ) else if( HB_IS_TIMESTAMP( pValue ) ) { - char * szDateFormat = NULL, * szTimeFormat = NULL; + const char * szDateFormat = NULL, * szTimeFormat = NULL; char szNewFormat[ 11 ]; long lDate, lTime; UINT nFor; diff --git a/harbour/source/rtl/trim.c b/harbour/source/rtl/trim.c index e8f8426476..14490fdb36 100644 --- a/harbour/source/rtl/trim.c +++ b/harbour/source/rtl/trim.c @@ -56,7 +56,7 @@ /* trims from the left, and returns a new pointer to szText */ /* also returns the new length in lLen */ -char * hb_strLTrim( const char * szText, ULONG * ulLen ) +const char * hb_strLTrim( const char * szText, ULONG * ulLen ) { HB_TRACE(HB_TR_DEBUG, ("hb_strLTrim(%s, %p)", szText, ulLen)); @@ -66,7 +66,7 @@ char * hb_strLTrim( const char * szText, ULONG * ulLen ) ( *ulLen )--; } - return ( char * ) szText; + return szText; } /* return length of szText ignoring trailing white space (or true spaces) */ @@ -97,7 +97,7 @@ HB_FUNC( LTRIM ) if( pText ) { ULONG ulLen, ulSrc; - char * szText; + const char * szText; ulLen = ulSrc = hb_itemGetCLen( pText ); szText = hb_strLTrim( hb_itemGetCPtr( pText ), &ulLen ); @@ -122,7 +122,7 @@ HB_FUNC( RTRIM ) if( pText ) { ULONG ulLen, ulSrc; - char * szText = hb_itemGetCPtr( pText ); + const char * szText = hb_itemGetCPtr( pText ); ulSrc = hb_itemGetCLen( pText ); ulLen = hb_strRTrimLen( szText, ulSrc, FALSE ); @@ -154,7 +154,7 @@ HB_FUNC( ALLTRIM ) if( pText ) { ULONG ulLen, ulSrc; - char * szText = hb_itemGetCPtr( pText ); + const char * szText = hb_itemGetCPtr( pText ); ulSrc = hb_itemGetCLen( pText ); ulLen = hb_strRTrimLen( szText, ulSrc, FALSE ); diff --git a/harbour/source/rtl/val.c b/harbour/source/rtl/val.c index 4fde600656..a3731e42ab 100644 --- a/harbour/source/rtl/val.c +++ b/harbour/source/rtl/val.c @@ -61,7 +61,7 @@ HB_FUNC( VAL ) if( pText ) { - char * szText = hb_itemGetCPtr( pText ); + const char * szText = hb_itemGetCPtr( pText ); int iWidth, iDec, iLen = ( int ) hb_itemGetCLen( pText ); BOOL fDbl; HB_LONG lValue; diff --git a/harbour/source/vm/cmdarg.c b/harbour/source/vm/cmdarg.c index 0d951d4cc7..4c477a2544 100644 --- a/harbour/source/vm/cmdarg.c +++ b/harbour/source/vm/cmdarg.c @@ -204,7 +204,7 @@ void hb_cmdargUpdate( void ) pFName->szPath[ 1 ] == HB_OS_PATH_DELIM_CHR ) pFName->szPath += 2; s_szAppName[ 0 ] = HB_OS_PATH_DELIM_CHR; - hb_fsCurDirBuff( 0, ( BYTE * ) ( s_szAppName + 1 ), HB_PATH_MAX - 1 ); + hb_fsCurDirBuff( 0, s_szAppName + 1, HB_PATH_MAX - 1 ); if( s_szAppName[ 1 ] != 0 ) { hb_strncat( s_szAppName, HB_OS_PATH_DELIM_CHR_STRING, HB_PATH_MAX - 1 ); @@ -402,17 +402,7 @@ HB_FUNC( HB_ARGSTRING ) if( pszValue ) { /* Convert from OS codepage */ - BOOL fFree; - char * pbyResult = ( char * ) hb_osDecode( ( BYTE * ) pszValue, &fFree ); - - if( fFree ) - { - hb_retc_buffer( pbyResult ); - hb_xfree( pszValue ); - } - else - hb_retc_buffer( pszValue ); - + hb_retc_buffer( ( char * ) hb_osDecode( pszValue, NULL ) ); return; } } @@ -464,12 +454,7 @@ HB_FUNC( HB_CMDLINE ) *--ptr = '\0'; /* Convert from OS codepage */ - { - BOOL fFree; - hb_retc_buffer( ( char * ) hb_osDecode( ( BYTE * ) pszBuffer, &fFree ) ); - if( fFree ) - hb_xfree( pszBuffer ); - } + hb_retc_buffer( ( char * ) hb_osDecode( pszBuffer, NULL ) ); } else hb_retc_null(); diff --git a/harbour/source/vm/dynlibhb.c b/harbour/source/vm/dynlibhb.c index e66d8849a5..40131c5fa0 100644 --- a/harbour/source/vm/dynlibhb.c +++ b/harbour/source/vm/dynlibhb.c @@ -81,11 +81,11 @@ HB_FUNC( HB_LIBLOAD ) if( hb_parclen( 1 ) > 0 ) { int argc = hb_pcount() - 1, i; - char **argv = NULL; + const char ** argv = NULL; if( argc > 0 ) { - argv = ( char** ) hb_xgrab( sizeof( char* ) * argc ); + argv = ( const char** ) hb_xgrab( sizeof( char* ) * argc ); for( i = 0; i < argc; ++i ) argv[i] = hb_parcx( i + 2 ); } diff --git a/harbour/source/vm/estack.c b/harbour/source/vm/estack.c index 0d642e394c..d07e82dc4e 100644 --- a/harbour/source/vm/estack.c +++ b/harbour/source/vm/estack.c @@ -147,7 +147,7 @@ /* ------------------------------- */ -static BYTE s_byDirBuffer[ HB_PATH_MAX ]; +static char s_szDirBuffer[ HB_PATH_MAX ]; static HB_IOERRORS s_IOErrors; /* ------------------------------- */ @@ -229,10 +229,10 @@ static void hb_stack_free( PHB_STACK pStack ) hb_xfree( pStack->pItems ); pStack->pItems = pStack->pPos = pStack->pBase = NULL; #if defined( HB_MT_VM ) - if( pStack->byDirBuffer ) + if( pStack->pDirBuffer ) { - hb_xfree( pStack->byDirBuffer ); - pStack->byDirBuffer = NULL; + hb_xfree( pStack->pDirBuffer ); + pStack->pDirBuffer = NULL; } if( pStack->iDynH ) { @@ -832,18 +832,18 @@ char * hb_stackDateBuffer( void ) return hb_stack.szDate; } -BYTE * hb_stackDirBuffer( void ) +char * hb_stackDirBuffer( void ) { #if defined( HB_MT_VM ) if( hb_stack_ready() ) { HB_STACK_TLS_PRELOAD - if( !hb_stack.byDirBuffer ) - hb_stack.byDirBuffer = ( BYTE * ) hb_xgrab( HB_PATH_MAX ); - return hb_stack.byDirBuffer; + if( !hb_stack.pDirBuffer ) + hb_stack.pDirBuffer = ( char * ) hb_xgrab( HB_PATH_MAX ); + return hb_stack.pDirBuffer; } #endif - return s_byDirBuffer; + return s_szDirBuffer; } PHB_IOERRORS hb_stackIOErrors( void ) diff --git a/harbour/source/vm/hvm.c b/harbour/source/vm/hvm.c index 79487ca5fc..32ac94732a 100644 --- a/harbour/source/vm/hvm.c +++ b/harbour/source/vm/hvm.c @@ -216,7 +216,7 @@ static void hb_vmLocalName( USHORT uiLocal, char * szLocalName ); /* locals a static void hb_vmStaticName( BYTE bIsGlobal, USHORT uiStatic, char * szStaticName ); /* statics vars information for the debugger */ static void hb_vmModuleName( char * szModuleName ); /* PRG and function name information for the debugger */ -static void hb_vmDebugEntry( int nMode, int nLine, char *szName, int nIndex, PHB_ITEM pFrame ); +static void hb_vmDebugEntry( int nMode, int nLine, const char *szName, int nIndex, PHB_ITEM pFrame ); static void hb_vmDebuggerExit( BOOL fRemove ); /* shuts down the debugger */ static void hb_vmDebuggerShowLine( USHORT uiLine ); /* makes the debugger shows a specific source code line */ static void hb_vmDebuggerEndProc( void ); /* notifies the debugger for an endproc */ @@ -6011,7 +6011,7 @@ void hb_vmFunction( USHORT uiParams ) #ifndef HB_NO_DEBUG -static void hb_vmDebugEntry( int nMode, int nLine, char *szName, int nIndex, PHB_ITEM pFrame ) +static void hb_vmDebugEntry( int nMode, int nLine, const char *szName, int nIndex, PHB_ITEM pFrame ) { HB_STACK_TLS_PRELOAD @@ -6080,7 +6080,7 @@ static void hb_vmDebugEntry( int nMode, int nLine, char *szName, int nIndex, PHB } } -static void hb_vmDummyDebugEntry( int nMode, int nLine, char *szName, int nIndex, PHB_ITEM pFrame ) +static void hb_vmDummyDebugEntry( int nMode, int nLine, const char *szName, int nIndex, PHB_ITEM pFrame ) { HB_TRACE(HB_TR_DEBUG, ("hb_vmDummyDebugEntry")); @@ -7234,7 +7234,7 @@ void hb_vmUnlockModuleSymbols( void ) #endif } -char * hb_vmFindModuleSymbolName( PHB_SYMB pSym ) +const char * hb_vmFindModuleSymbolName( PHB_SYMB pSym ) { if( pSym ) { @@ -7479,7 +7479,7 @@ void hb_vmBeginSymbolGroup( void * hDynLib, BOOL fClone ) s_fCloneSym = fClone; } -void hb_vmInitSymbolGroup( void * hNewDynLib, int argc, char * argv[] ) +void hb_vmInitSymbolGroup( void * hNewDynLib, int argc, const char * argv[] ) { HB_TRACE(HB_TR_DEBUG, ("hb_vmInitSymbolGroup(%p,%d,%p)", hNewDynLib, argc, argv)); diff --git a/harbour/source/vm/itemapi.c b/harbour/source/vm/itemapi.c index 456d31b91b..78ef4b1c59 100644 --- a/harbour/source/vm/itemapi.c +++ b/harbour/source/vm/itemapi.c @@ -2028,6 +2028,26 @@ PHB_ITEM hb_itemUnShare( PHB_ITEM pItem ) return pItem; } +BOOL hb_itemGetWriteCL( PHB_ITEM pItem, char ** pszValue, ULONG * pulLen ) +{ + HB_TRACE_STEALTH(HB_TR_DEBUG, ("hb_itemGetWriteCL(%p,%p,%p)", pItem, pszValue, pulLen)); + + if( pItem ) + { + if( HB_IS_BYREF( pItem ) ) + pItem = hb_itemUnRef( pItem ); + + if( HB_IS_STRING( pItem ) ) + { + hb_itemUnShareString( pItem ); + *pulLen = pItem->item.asString.length; + *pszValue = pItem->item.asString.value; + return TRUE; + } + } + return FALSE; +} + /* Internal API, not standard Clipper */ /* clone the given item */ PHB_ITEM hb_itemClone( PHB_ITEM pItem ) diff --git a/harbour/source/vm/memvars.c b/harbour/source/vm/memvars.c index 06c89829f1..9fb96d2b66 100644 --- a/harbour/source/vm/memvars.c +++ b/harbour/source/vm/memvars.c @@ -1484,7 +1484,7 @@ HB_FUNC( __MVSAVE ) /* Create .mem file */ do { - fhnd = hb_fsExtOpen( ( BYTE * ) szFileName, NULL, + fhnd = hb_fsExtOpen( szFileName, NULL, FXO_TRUNCATE | FO_READWRITE | FO_EXCLUSIVE | FXO_DEFAULTS | FXO_SHARELOCK, NULL, pError ); @@ -1568,7 +1568,7 @@ HB_FUNC( __MVRESTORE ) /* Open .mem file */ do { - fhnd = hb_fsExtOpen( ( BYTE * ) szFileName, NULL, + fhnd = hb_fsExtOpen( szFileName, NULL, FO_READ | FXO_DEFAULTS | FXO_SHARELOCK, NULL, pError ); if( fhnd == FS_ERROR ) diff --git a/harbour/source/vm/runner.c b/harbour/source/vm/runner.c index b7e30345ef..3f58457762 100644 --- a/harbour/source/vm/runner.c +++ b/harbour/source/vm/runner.c @@ -573,7 +573,7 @@ static PHRB_BODY hb_hrbLoadFromFile( const char * szHrb, USHORT usMode ) do { - hFile = hb_fsOpen( ( BYTE * ) szFileName, FO_READ ); + hFile = hb_fsOpen( szFileName, FO_READ ); } while( hFile == FS_ERROR && hb_errRT_BASE_Ext1( EG_OPEN, 6102, NULL, szFileName, hb_fsError(), diff --git a/harbour/source/vm/set.c b/harbour/source/vm/set.c index b28dfad96d..794caefa05 100644 --- a/harbour/source/vm/set.c +++ b/harbour/source/vm/set.c @@ -220,7 +220,7 @@ static BOOL is_devicename( const char * szFileName ) else { ULONG ulAttr = 0; - if( hb_fsGetAttr( ( BYTE * ) szFileName, &ulAttr ) ) + if( hb_fsGetAttr( szFileName, &ulAttr ) ) { if( ulAttr & ( HB_FA_CHRDEVICE | HB_FA_BLKDEVICE | HB_FA_FIFO | HB_FA_SOCKET ) ) return TRUE; @@ -324,7 +324,7 @@ static void open_handle( PHB_SET_STRUCT pSet, const char * file_name, while( handle == FS_ERROR ) { if( bPipe ) - handle = hb_fsPOpen( ( BYTE * ) szFileName + 1, ( BYTE * ) "w" ); + handle = hb_fsPOpen( szFileName + 1, "w" ); else { BOOL bCreate = FALSE; @@ -334,7 +334,7 @@ static void open_handle( PHB_SET_STRUCT pSet, const char * file_name, if( hb_fsFileExists( szFileName ) ) { /* If the file already exists, open it (in read-write mode, in case of non-Unix and text modes). */ - handle = hb_fsOpen( ( BYTE * ) szFileName, FO_READWRITE | FO_DENYWRITE ); + handle = hb_fsOpen( szFileName, FO_READWRITE | FO_DENYWRITE ); if( handle != FS_ERROR ) { /* Position to EOF */ /* Special binary vs. text file handling - even for UN*X, now @@ -364,7 +364,7 @@ static void open_handle( PHB_SET_STRUCT pSet, const char * file_name, bCreate = TRUE; /* Always create a new file for overwrite mode. */ if( bCreate ) - handle = hb_fsCreate( ( BYTE * ) szFileName, FC_NORMAL ); + handle = hb_fsCreate( szFileName, FC_NORMAL ); } if( handle == FS_ERROR ) @@ -2026,7 +2026,7 @@ BOOL hb_setGetL( HB_set_enum set_specifier ) return FALSE; } -char * hb_setGetCPtr( HB_set_enum set_specifier ) +const char * hb_setGetCPtr( HB_set_enum set_specifier ) { HB_STACK_TLS_PRELOAD PHB_SET_STRUCT pSet = hb_stackSetStruct(); @@ -2273,7 +2273,7 @@ BOOL hb_setGetAlternate( void ) return hb_stackSetStruct()->HB_SET_ALTERNATE; } -char * hb_setGetAltFile( void ) +const char * hb_setGetAltFile( void ) { HB_STACK_TLS_PRELOAD return hb_stackSetStruct()->HB_SET_ALTFILE; @@ -2327,13 +2327,13 @@ BOOL hb_setGetConsole( void ) return hb_stackSetStruct()->HB_SET_CONSOLE; } -char * hb_setGetDateFormat( void ) +const char * hb_setGetDateFormat( void ) { HB_STACK_TLS_PRELOAD return hb_stackSetStruct()->HB_SET_DATEFORMAT; } -char * hb_setGetTimeFormat( void ) +const char * hb_setGetTimeFormat( void ) { HB_STACK_TLS_PRELOAD return hb_stackSetStruct()->HB_SET_TIMEFORMAT; @@ -2351,7 +2351,7 @@ int hb_setGetDecimals( void ) return hb_stackSetStruct()->HB_SET_DECIMALS; } -char * hb_setGetDefault( void ) +const char * hb_setGetDefault( void ) { HB_STACK_TLS_PRELOAD return hb_stackSetStruct()->HB_SET_DEFAULT; @@ -2363,7 +2363,7 @@ BOOL hb_setGetDeleted( void ) return hb_stackSetStruct()->HB_SET_DELETED; } -char * hb_setGetDelimChars( void ) +const char * hb_setGetDelimChars( void ) { HB_STACK_TLS_PRELOAD return hb_stackSetStruct()->HB_SET_DELIMCHARS; @@ -2375,7 +2375,7 @@ BOOL hb_setGetDelimiters( void ) return hb_stackSetStruct()->HB_SET_DELIMITERS; } -char * hb_setGetDevice( void ) +const char * hb_setGetDevice( void ) { HB_STACK_TLS_PRELOAD return hb_stackSetStruct()->HB_SET_DEVICE; @@ -2429,7 +2429,7 @@ BOOL hb_setGetExtra( void ) return hb_stackSetStruct()->HB_SET_EXTRA; } -char * hb_setGetExtraFile( void ) +const char * hb_setGetExtraFile( void ) { HB_STACK_TLS_PRELOAD return hb_stackSetStruct()->HB_SET_EXTRAFILE; @@ -2459,7 +2459,7 @@ BOOL hb_setGetIntensity( void ) return hb_stackSetStruct()->HB_SET_INTENSITY; } -char * hb_setGetPath( void ) +const char * hb_setGetPath( void ) { HB_STACK_TLS_PRELOAD return hb_stackSetStruct()->HB_SET_PATH; @@ -2489,7 +2489,7 @@ int hb_setGetMessage( void ) return hb_stackSetStruct()->HB_SET_MESSAGE; } -char * hb_setGetMFileExt( void ) +const char * hb_setGetMFileExt( void ) { HB_STACK_TLS_PRELOAD return hb_stackSetStruct()->HB_SET_MFILEEXT; @@ -2507,7 +2507,7 @@ BOOL hb_setGetPrinter( void ) return hb_stackSetStruct()->HB_SET_PRINTER; } -char * hb_setGetPrintFile( void ) +const char * hb_setGetPrintFile( void ) { HB_STACK_TLS_PRELOAD return hb_stackSetStruct()->HB_SET_PRINTFILE; @@ -2603,7 +2603,7 @@ BOOL hb_setGetDefExtension( void ) return hb_stackSetStruct()->HB_SET_DEFEXTENSIONS; } -char * hb_setGetEOL( void ) +const char * hb_setGetEOL( void ) { HB_STACK_TLS_PRELOAD return hb_stackSetStruct()->HB_SET_EOL; @@ -2615,39 +2615,48 @@ BOOL hb_setGetTrimFileName( void ) return hb_stackSetStruct()->HB_SET_TRIMFILENAME; } -char * hb_setGetHBOUTLOG( void ) +const char * hb_setGetHBOUTLOG( void ) { HB_STACK_TLS_PRELOAD return hb_stackSetStruct()->HB_SET_HBOUTLOG; } -char * hb_setGetHBOUTLOGINFO( void ) +const char * hb_setGetHBOUTLOGINFO( void ) { HB_STACK_TLS_PRELOAD return hb_stackSetStruct()->HB_SET_HBOUTLOGINFO; } -char * hb_setGetOSCODEPAGE( void ) +const char * hb_setGetOSCODEPAGE( void ) { HB_STACK_TLS_PRELOAD return hb_stackSetStruct()->HB_SET_OSCODEPAGE; } -UCHAR * hb_osEncode( UCHAR * szFileName, BOOL * pfFree ) +const char * hb_osEncode( const char * szName, char ** pszFree ) { HB_STACK_TLS_PRELOAD - *pfFree = FALSE; #if defined( HB_MT_VM ) - if( hb_stackId() ) + if( !hb_stackId() ) + { + if( pszFree ) + *pszFree = NULL; + } + else #endif { - BOOL bCPConv = hb_setGetOSCODEPAGE() && hb_setGetOSCODEPAGE()[ 0 ]; + const char * pszCP = hb_setGetOSCODEPAGE(); - if( bCPConv ) + if( pszCP && *pszCP ) { - UCHAR * p = szFileName; UCHAR * pCPTrans = hb_stackSetStruct()->hb_set_oscptransto; + char * p; + + if( pszFree ) + szName = *pszFree = p = hb_strdup( szName ); + else + p = ( char * ) szName; while( *p ) { @@ -2655,26 +2664,37 @@ UCHAR * hb_osEncode( UCHAR * szFileName, BOOL * pfFree ) p++; } } + else if( pszFree ) + *pszFree = NULL; } - return szFileName; + return szName; } -UCHAR * hb_osDecode( UCHAR * szFileName, BOOL * pfFree ) +const char * hb_osDecode( const char * szName, char ** pszFree ) { HB_STACK_TLS_PRELOAD - *pfFree = FALSE; #if defined( HB_MT_VM ) - if( hb_stackId() ) + if( !hb_stackId() ) + { + if( pszFree ) + *pszFree = NULL; + } + else #endif { - BOOL bCPConv = hb_setGetOSCODEPAGE() && hb_setGetOSCODEPAGE()[ 0 ]; + const char * pszCP = hb_setGetOSCODEPAGE(); - if( bCPConv ) + if( pszCP && *pszCP ) { - UCHAR * p = szFileName; UCHAR * pCPTrans = hb_stackSetStruct()->hb_set_oscptransfrom; + char * p; + + if( pszFree ) + szName = *pszFree = p = hb_strdup( szName ); + else + p = ( char * ) szName; while( *p ) { @@ -2682,9 +2702,11 @@ UCHAR * hb_osDecode( UCHAR * szFileName, BOOL * pfFree ) p++; } } + else if( pszFree ) + *pszFree = NULL; } - return szFileName; + return szName; } HB_FHANDLE hb_setGetPrinterHandle( int iType )