Files
harbour-core/harbour/source/vm/cmdarg.c
Viktor Szakats 9738d0bef5 ; Merging changes to trunk from branches/harbour-1.0 r9377.
2008-09-14 11:14 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
  * contrib/gtalleg/ssf.h
    ! Fixed to compile with Cygwin.

  * contrib/hbwhat/whtsock.c
    ! Fixed for PellesC 4.5 where the inclusion order of 
      Windows headers needs to be the opposite of what 5.0 needs.

  * contrib/hbwhat/whtilst.c
    ! Fixed to compile with Cygwin.

  * contrib/hbwhat/whtinet.c
    ! Added missing Windows macro for Cygwin.
    ! Fixed three warnings with Cygwin.

  * contrib/hbwhat/whtseria.c
  * contrib/hbwhat/whtreg.c
  * contrib/hbwhat/whtini.c
    ! Removed #include "tchar.h", because it's unnecessary, 
      and breaks Cygwin.

  * contrib/hbwhat/whtsys.c
    ! Removed #include "htmlhelp.h", because it's unnecessary, 
      and breaks Cygwin.

2008-09-13 19:30 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
  * contrib/gtalleg/ssf.h
    ! Turned off ASM for MSVC AMD64 mode.

  * contrib/gtalleg/Makefile
    ! Disabled for OpenWatcom. (maybe compilation could be 
      fixed somehow, if someone is interested pls look into it.)

  * doc/whatsnew.txt
  * contrib/hbfimage/fi_winfu.c
  * contrib/hbfimage/fi_wrp.c
    ! Fixed for OpenWatcom.

  * contrib/gtwvg/wvgutils.c
  * contrib/gtwvg/wvgcore.c
    ! Silenced some MinGW/PelleC cast warnings.

  * contrib/hbw32/win_prt.c
    ! Fixed GCC (MinGW/Cygwin) warnings. The solution I choose is 
      pretty ugly, if someone knows the right one, please help.
      Warning was:
      ../../win_prt.c:70: warning: missing initializer
      ../../win_prt.c:70: warning: (near initialization for `s_PortData[0].OldDCB')
    ! Fixed few remaining warnings / minor bugs.

  * contrib/hbwhat/whtlv.c
  * contrib/hbwhat/whtcomm.c
  * contrib/hbwhat/whttab.c
  * contrib/hbwhat/whttree.c
    ! Silenced MinGW 4.12 warnings.

  * contrib/hbwhat/whtdate.c
    ! Removed #include "tchar.h", which seems unnecessary and 
      fixed Cygwin compilation.

  * contrib/hbwhat/whtsock.c
    ! Changed #include order of Windows headers to satisfy PellesC 5.

  ; TOFIX1: hbct / SETFDATI() has a possible bug here (shown in PelleC 64 bit):
    ../../files.c(264): warning #2006: [ISO] Conversion from 'void *' to 'int' is compiler dependent.
    ../../files.c(264): warning #2052: Conversion from 'void *' to 'int' is undefined.
    Problem is with HFILE / HANDLE conversion.

  ; TOFIX2: Here are some remaining 64-bit problems:
    ../../hb_btree.c(643): warning #2006: [ISO] Conversion from 'void *' to 'unsigned long int' is compiler dependent.
    ../../hb_btree.c(643): warning #2052: Conversion from 'void *' to 'unsigned long int' is undefined.
    ../../hb_btree.c(739): warning #2006: [ISO] Conversion from 'ioBuffer_T *' to 'unsigned long int' is compiler dependent.
    ../../hb_btree.c(739): warning #2052: Conversion from 'ioBuffer_T *' to 'unsigned long int' is undefined.
    ../../win_dll.c(511): warning #2006: [ISO] Conversion from 'void *' to 'unsigned long int' is compiler dependent.
    ../../win_dll.c(511): warning #2052: Conversion from 'void *' to 'unsigned long int' is undefined.
    ../../win_ole.c(761): warning #2006: [ISO] Conversion from 'LPDISPATCH' to 'long int' is compiler dependent.
    ../../win_ole.c(761): warning #2052: Conversion from 'LPDISPATCH' to 'long int' is undefined.
    ../../win_ole.c(1091): warning #2006: [ISO] Conversion from 'LPDISPATCH' to 'long int' is compiler dependent.
    ../../win_ole.c(1091): warning #2052: Conversion from 'LPDISPATCH' to 'long int' is undefined.
    ../../win_ole.c(1425): warning #2006: [ISO] Conversion from 'void *' to 'long int' is compiler dependent.
    ../../win_ole.c(1425): warning #2052: Conversion from 'void *' to 'long int' is undefined.
    ../../win_ole.c(1478): warning #2006: [ISO] Conversion from 'void *' to 'long int' is compiler dependent.
    ../../win_ole.c(1478): warning #2052: Conversion from 'void *' to 'long int' is undefined.
    ../../win_regc.c(94): warning #2006: [ISO] Conversion from 'HKEY' to 'unsigned long int' is compiler dependent.
    ../../win_regc.c(94): warning #2052: Conversion from 'HKEY' to 'unsigned long int' is undefined.
    ../../win_regc.c(116): warning #2006: [ISO] Conversion from 'HKEY' to 'unsigned long int' is compiler dependent.
    ../../win_regc.c(116): warning #2052: Conversion from 'HKEY' to 'unsigned long int' is undefined.

2008-09-13 13:34 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
  * doc/dirstruc.txt
    * Updated.

  - contrib/hbgf/hbgfw32
  + contrib/hbgf/hbgfwin
  * contrib/hbgf/tests/bld_b32.bat
  * contrib/hbgf/tests/bld_vc.bat
  * contrib/hbgf/Makefile
  * contrib/hbgf/hbgfwin/common.mak
  * contrib/hbgf/hbgfwin/button.prg
  * contrib/hbgf/hbgfwin/winctrl.prg
  * contrib/hbgf/hbgfwin/form.prg
  * contrib/hbgf/hbgfwin/menuitem.prg
  * contrib/hbgf/hbgfwin/menu.prg
  * contrib/hbgf/hbgfwin/edit.prg
  * contrib/hbgf/hbgfwin/Makefile
  - contrib/hbgf/hbgfwin/win32.c
  + contrib/hbgf/hbgfwin/winapi.c
  - contrib/hbgf/hbgfwin/hbgfw32.ch
  + contrib/hbgf/hbgfwin/hbgfwin.ch
    * Removed some '32's.

2008-09-13 12:28 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
  * doc/whatsnew.txt
    * Updated.

2008-09-13 12:28 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
  * contrib/hbw32/Makefile
  * contrib/hbw32/common.mak
  * contrib/hbw32/hbw32.ch
  + contrib/hbw32/hbwin.h
  + contrib/hbw32/win_prt.c
  + contrib/hbw32/win_tprt.prg
  + contrib/hbw32/tests/testprt1.prg
  + contrib/hbw32/tests/testprt2.prg
    + Added Windows COM port handling functions.
      Contributed by Alex Strickland.
    ; I did some changes to clean warnings, few 64-bit issues, 
      changed to use safe string functions, integrated 
      the header into hbw32.ch, added a new general C level 
      header, split BEGINDUMP into separate .c function, 
      changed to ANSI C comments, marked statics with s_, 
      fixed a few trashed string buffers and leaks in some 
      error cases. Separated tests into distinct .prgs.
      Fixed for UNICODE mode. Minor optimizations, formatting.
    ; TODO: Test WinCE build.
    ; Please test, I don't have any COM ports on my system.

2008-09-13 10:28 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
  * contrib/gtwvg/wvgcore.c
  * contrib/gtwvg/wvgutils.c
    ! Fixed 64-bit problems.
    ; Pritpal, could you please review and test these changes?

2008-09-13 09:37 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
  * contrib/hbvpdf/hbvpdf.prg
    ! Generic support functions made STATIC to avoid collision 
      with similarly named functions in other libs (like hbct).

  * contrib/hbvpdf/hbvpdf.prg
  * contrib/hbvpdf/hbvpdft.prg
    * Using hb_run() instead of RUN and __run().

2008-09-12 19:30 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
  * contrib/gtalleg/Makefile
    * Excluded Cygwin.

  * contrib/hbwhat/Makefile
  * contrib/hbwhat/common.mak
  - contrib/hbwhat/whtdll.c
  - contrib/hbwhat/whtcall.c
    - Removed DLL related stuff from hbwhat, since we're 
      maintaining (a better working) one already in hbw32, 
      and hbwhat by itself doesn't seem to need this 
      functionality internally. Users should migrate to 
      the hbw32 functions, which work mostly similarly.

2008-09-12 19:08 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
  * doc/whatsnew.txt
    * Added some build notes.

  * contrib/gtalleg/Makefile
    ! Fixed POCC, XCC compiler exlusions.
    * Excluded DMC compiler.

  * contrib/hbwhat/Makefile
    * Excluded DMC compiler.

  * contrib/hbwhat/wincorec.c
    ! Workaround for a wrong Windows API declaration in 
      __DMC__ headers.

2008-09-12 11:01 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
  * contrib/hbole/tests/bld_vc.bat
  * contrib/hbw32/tests/bld_vc.bat
    ! Added missing system libs.

2008-09-12 04:03 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
  * contrib/gtwvg/wvgutils.c
    ! Fix to previous fix, so it works again in 64-bit builds.
         hb_retclen( ( LPSTR ) pdlgtemplate, ( ( ULONG ) p - ( ULONG ) pdlgtemplate ) ) ; =>
         hb_retclen( ( LPSTR ) pdlgtemplate, ( ( HB_PTRDIFF ) p - ( HB_PTRDIFF ) pdlgtemplate ) ) ;
    ; This way it's now in sync with similar function in hbwhat.

2008-09-12 01:14 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
  * source/rdd/usrrdd/rdds/Makefile
  + source/rdd/usrrdd/rdds/arrayrdd.prg
  + source/rdd/usrrdd/rdds/vfpcdx.prg
    + Added two usrrdd based RDDs. Borrowed from xhb.
      Works of: Francesco Saverio Giudice and 
                Miguel Angel Marchuet Frutos
    ; These were adapted to compile and link in Harbour, but 
      I did no tests, so some more - hopefully minor - changes 
      may happen to be needed.

2008-09-12 00:53 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
  * contrib/rddado/adordd.prg
  * contrib/rddado/adordd.ch
    * Merged changes from xhb.
      Some hbusrrdd.ch values seem to be missing from Harbour, 
      related features will be automatically enabled if we 
      implement them in our usrrdd.
      Please test.

2008-09-11 22:55 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
  * doc/whatsnew.txt
  * source/vm/cmdarg.c
    * Legacy undocumented symbols hb_hInstance and 
      hb_hPrevInstance reenabled for 1.0.1, when HB_LEGACY_LEVEL 
      is #defined. This is the default in 1.0.x. It will be 
      turned off in 1.1.0.
      I did this to not break binary compatibility of 1.0.1 
      with 1.0.0 for those apps that rely on these symbols
      (like gtwvg).

2008-09-11 21:29 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
  * contrib/gtwvg/tests/bld_vc.bat
    ! Added required list of system libs.

2008-09-11 14:08 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
  * source/rtl/gtpca/gtpca.c
  * source/rtl/gtwin/gtwin.c
  * source/rtl/gtwvt/gtwvt.c
  * source/rtl/gttone.c
    ! Fixed some core MSVC -W4 warnings.

  * contrib/hbnf/getenvrn.c
    ! Fixed compile problem in MSVC C++ mode surfaced after 
      recent UNICODE fix.

2008-09-11 13:13 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
  * contrib/gtwvg/wvgutils.c
    ! Fixed last MSVC -W4 warnings.
    ; NOTE: Only these contribs have remaining -W4 warnings:
            hbbmcdx, hbbtree, hbct (in screen*.c).
            Plus core.

2008-09-11 12:00 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
  * contrib/hbnf/fttext.c
  * contrib/hbwhat/whtdate.c
  * contrib/hbwhat/wincorec.c
  * contrib/hbwhat/whtsock.c
  * contrib/hbwhat/whtseria.c
  * contrib/hbwhat/whtdlg.c
  * contrib/hbwhat/whtsys.c
  * contrib/hbwhat/whtmisc.c
  * contrib/hbwhat/whtcdlg.c
    ! Fixed all MinGW 4.3x warnings.
    ! Added workaround for slightly wrong MinGW definition for 
      Windows DateTime_GetMonthCal() macro.

  * contrib/gtwvg/gtwvg.c
  * contrib/gtwvg/wvgutils.c
  * contrib/gtwvg/wvgcore.c
    ! Fixed all MSVC -W4 warnings.

  * contrib/gtwvg/gtwvg.h
    ! Fixed old bug, which surfaced after recently 
      fixing __MINGW__ to __MINGW32__.
      Apparently, comctl32.h is never needed here.

  * config/rules.cf
  * contrib/hbbtree/tests/bld_djgp.bat
    % Removed -gc0. Now default.

  * contrib/make_b32_all.bat
  * contrib/make_vc_all.bat
    * Minor formatting.

  * contrib/hbgt/asciisgt.c
  * utils/hbdoc/hbdoc.prg
    - Removed unnecessary version strings. This was good 
      in CVS times, but for SVN there is not much point.

  * utils/hbmake/hbmake.prg
    + Another patch session from Bill Robertson.
      Besides some further cleanups, this should fix 
      some problems with the previous version.

  * source/lang/msghuiso.c
  * source/lang/msgskiso.c
  * source/lang/msgrukoi.c
  * source/lang/msghuwin.c
  * source/lang/msgzhgb.c
  * source/lang/msgskwin.c
  * source/lang/msg_tpl.c
  * source/lang/msgruwin.c
  * source/lang/msgelwin.c
  * source/lang/msgro.c
  * source/lang/msgpt.c
  * source/lang/msghriso.c
  * source/lang/msghrwin.c
  * source/lang/msgsliso.c
  * source/lang/msgbe866.c
  * source/lang/msgslwin.c
  * source/lang/msghe862.c
  * source/lang/msgcskam.c
  * source/lang/msggl.c
  * source/lang/msgtrwin.c
  * source/lang/msgeo.c
  * source/lang/msgbgiso.c
  * source/lang/msgbgwin.c
  * source/lang/msgskkam.c
  * source/lang/msges.c
  * source/lang/msguakoi.c
  * source/lang/msgzhb5.c
  * source/lang/msgeu.c
  * source/lang/msgpl852.c
  * source/lang/msgsr852.c
  * source/lang/msguawin.c
  * source/lang/msgde.c
  * source/lang/msgtr857.c
  * source/lang/msgru866.c
  * source/lang/msgcs852.c
  * source/lang/msgfr.c
  * source/lang/msgis850.c
  * source/lang/msgnl.c
  * source/lang/msghu852.c
  * source/lang/msgsk852.c
  * source/lang/msgca.c
  * source/lang/msgplmaz.c
  * source/lang/msgpliso.c
  * source/lang/msgplwin.c
  * source/lang/msgbgmik.c
  * source/lang/msgid.c
  * source/lang/msgbg866.c
  * source/lang/msgltwin.c
  * source/lang/msgsriso.c
  * source/lang/msgel.c
  * source/lang/msgsrwin.c
  * source/lang/msgbewin.c
  * source/lang/msgdewin.c
  * source/lang/msghr437.c
  * source/lang/msghr852.c
  * source/lang/msgko.c
  * source/lang/msgua866.c
  * source/lang/msghewin.c
  * source/lang/msgit.c
  * source/lang/msgsl437.c
  * source/lang/msgsl852.c
  * source/lang/msghucwi.c
  * source/lang/msgcsiso.c
  * source/lang/msgcswin.c
  * source/lang/msgeswin.c
  * source/rtl/langapi.c
    - Cleared unnecessary version strings. This was good 
      in CVS times, but for SVN there is not much point.
2008-09-14 10:19:59 +00:00

471 lines
12 KiB
C

/*
* $Id$
*/
/*
* Harbour Project source code:
* Command line and environment argument management
*
* Copyright 1999-2001 Viktor Szakats <viktor.szakats@syenar.hu>
* www - http://www.harbour-project.org
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
*
* As a special exception, the Harbour Project gives permission for
* additional uses of the text contained in its release of Harbour.
*
* The exception is that, if you link the Harbour libraries with other
* files to produce an executable, this does not by itself cause the
* resulting executable to be covered by the GNU General Public License.
* Your use of that executable is in no way restricted on account of
* linking the Harbour library code into it.
*
* This exception does not however invalidate any other reasons why
* the executable file might be covered by the GNU General Public License.
*
* This exception applies only to the code released by the Harbour
* Project under the name Harbour. If you copy code from other
* Harbour Project or Free Software Foundation releases into a copy of
* Harbour, as the General Public License permits, the exception does
* not apply to the code that you add in this way. To avoid misleading
* anyone as to the status of such modified files, you must delete
* this exception notice from them.
*
* If you write modifications of your own for Harbour, it is your choice
* whether to permit this exception to apply to your modifications.
* If you do not wish that, delete this exception notice.
*
*/
#define HB_OS_WIN_32_USED
#include "hbvmopt.h"
#include "hbapi.h"
#include "hbapiitm.h"
#include "hbvm.h"
#include "hbmemory.ch"
#include "hbstack.h"
#include "hbverbld.h"
/* Command line argument management */
static int s_argc = 0;
static char ** s_argv = NULL;
#if defined( HB_OS_WIN_32 ) && defined( HB_OS_WIN_32_USED )
HB_EXTERN_BEGIN
#ifdef HB_LEGACY_LEVEL
/* NOTE: 1.0 compatibility stuff. Will be removed in 1.1 [vszakats]. */
#define s_hInstance hb_hInstance
#define s_hPrevInstance hb_hPrevInstance
HANDLE s_hInstance = 0;
HANDLE s_hPrevInstance = 0;
int s_iCmdShow = 0;
BOOL s_WinMainParam = FALSE;
#else
static HANDLE s_hInstance = 0;
static HANDLE s_hPrevInstance = 0;
static int s_iCmdShow = 0;
static BOOL s_WinMainParam = FALSE;
#endif
HB_EXTERN_END
HB_EXPORT void hb_winmainArgInit( HANDLE hInstance, HANDLE hPrevInstance, int iCmdShow )
{
s_hInstance = hInstance;
s_hPrevInstance = hPrevInstance;
s_iCmdShow = iCmdShow;
s_WinMainParam = TRUE;
}
HB_EXPORT BOOL hb_winmainArgGet( HANDLE * phInstance, HANDLE * phPrevInstance, int * piCmdShow )
{
if( phInstance )
*phInstance = s_hInstance;
if( phPrevInstance )
*phPrevInstance = s_hPrevInstance;
if( piCmdShow )
*piCmdShow = s_iCmdShow;
return s_WinMainParam;
}
#endif
HB_EXPORT void hb_cmdargInit( int argc, char * argv[] )
{
HB_TRACE(HB_TR_DEBUG, ("hb_cmdargInit(%d, %p)", argc, argv));
s_argc = argc;
s_argv = argv;
}
int hb_cmdargARGC( void )
{
return s_argc;
}
char ** hb_cmdargARGV( void )
{
return s_argv;
}
BOOL hb_cmdargIsInternal( const char * szArg, int * piLen )
{
HB_TRACE(HB_TR_DEBUG, ("hb_cmdargIsInternal(%s, %p)", szArg, piLen));
/* NOTE: Not checking for '--' here, as it would filter out
valid command line options used by applications. [vszakats] */
if( hb_strnicmp( szArg, "--hb:", 5 ) == 0 ||
hb_strnicmp( szArg, "//hb:", 5 ) == 0 )
{
if( piLen )
*piLen = 5;
return TRUE;
}
else if( strlen( szArg ) >= 2 &&
szArg[ 0 ] == '/' &&
szArg[ 1 ] == '/' )
{
if( piLen )
*piLen = 2;
return TRUE;
}
return FALSE;
}
static char * hb_cmdargGet( const char * pszName, BOOL bRetValue )
{
char * pszRetVal = NULL;
char * pszEnvVar;
int i;
int iPrefixLen;
HB_TRACE(HB_TR_DEBUG, ("hb_cmdargGet(%s, %d)", pszName, (int) bRetValue));
/* Check the command line first */
for( i = 1; i < s_argc; i++ )
{
if( hb_cmdargIsInternal( s_argv[ i ], &iPrefixLen ) &&
hb_strnicmp( s_argv[ i ] + iPrefixLen, pszName, strlen( pszName ) ) == 0 )
{
if( bRetValue )
{
char * pszPos = s_argv[ i ] + iPrefixLen + strlen( pszName );
if( *pszPos == ':' )
pszPos++;
return hb_strdup( pszPos );
}
else
return "";
}
}
/* Check the environment variable */
pszEnvVar = hb_getenv( "HARBOUR" );
if( !pszEnvVar || pszEnvVar[ 0 ] == '\0' )
{
if( pszEnvVar )
hb_xfree( ( void * ) pszEnvVar );
pszEnvVar = hb_getenv( "CLIPPER" );
}
if( pszEnvVar && pszEnvVar[ 0 ] != '\0' )
{
char * pszNext = pszEnvVar;
/* Step through all envvar switches. */
/* NOTE: CA-Cl*pper doesn't need the switches to be separated by any
chars at all, Harbour is more strict/standard in this respect,
it requires the switches to be separated. */
i = strlen( pszName );
while( *pszNext )
{
static const char * szSeparator = " ;,\t";
char * pszEnd;
/* Skip the separators */
while( *pszNext && strchr( szSeparator, *pszNext ) )
pszNext++;
/* The // is optional in the envvar */
if( hb_cmdargIsInternal( pszNext, &iPrefixLen ) )
pszNext += iPrefixLen;
pszEnd = pszNext;
/* Search for the end of this switch */
while( *pszEnd && strchr( szSeparator, *pszEnd ) == NULL )
pszEnd++;
/* Check the switch */
if( hb_strnicmp( pszNext, pszName, i ) == 0 )
{
if( bRetValue )
{
ULONG ulLen;
pszNext += i;
/* Skip value separator colon. */
if( *pszNext == ':' )
pszNext++;
ulLen = pszEnd > pszNext ? pszEnd - pszNext : 0;
pszRetVal = ( char * ) hb_xgrab( ulLen + 1 );
hb_strncpy( pszRetVal, pszNext, ulLen );
}
else
pszRetVal = "";
break;
}
/* Step to the next switch */
pszNext = pszEnd;
}
}
if( pszEnvVar )
hb_xfree( ( void * ) pszEnvVar );
return pszRetVal;
}
BOOL hb_cmdargCheck( const char * pszName )
{
return hb_cmdargGet( pszName, FALSE ) != NULL;
}
/* NOTE: Pointer must be freed with hb_xfree() if not NULL */
char * hb_cmdargString( const char * pszName )
{
return hb_cmdargGet( pszName, TRUE );
}
int hb_cmdargNum( const char * pszName )
{
char * pszValue;
HB_TRACE(HB_TR_DEBUG, ("hb_cmdargNum(%s)", pszName));
pszValue = hb_cmdargGet( pszName, TRUE );
if( pszValue )
{
int iValue = atoi( pszValue );
hb_xfree( pszValue );
return iValue;
}
else
return -1;
}
/* Check if an internal switch has been set */
HB_FUNC( HB_ARGCHECK )
{
hb_retl( ISCHAR( 1 ) ? hb_cmdargCheck( hb_parc( 1 ) ) : FALSE );
}
/* Returns the value of an internal switch */
HB_FUNC( HB_ARGSTRING )
{
if( ISCHAR( 1 ) )
{
char * pszValue = hb_cmdargString( hb_parc( 1 ) );
if( pszValue )
{
hb_retc( pszValue );
hb_xfree( pszValue );
}
}
else
hb_retc( NULL );
}
/* Returns the number of command line arguments passed to the application, this
also includes the internal arguments. */
HB_FUNC( HB_ARGC )
{
hb_retni( s_argc - 1 );
}
/* Returns a command line argument passed to the application. Calling it with
the parameter zero, it will return the name of the executable, as written
in the command line. */
HB_FUNC( HB_ARGV )
{
if( ISNUM( 1 ) )
{
int argc = hb_parni( 1 );
hb_retc( ( argc >= 0 && argc < s_argc ) ? s_argv[ argc ] : NULL );
}
else
hb_retc( NULL );
}
/* Check for command line internal arguments */
ULONG hb_cmdargProcessVM( int *pCancelKey, int *pCancelKeyEx )
{
char * cFlags;
ULONG ulFlags = HB_VMFLAG_HARBOUR;
if( hb_cmdargCheck( "INFO" ) )
{
{
char * pszVersion = hb_verHarbour();
hb_conOutErr( pszVersion, 0 );
hb_conOutErr( hb_conNewLine(), 0 );
hb_xfree( pszVersion );
}
{
char * pszVersion = hb_verPlatform();
hb_conOutErr( pszVersion, 0 );
hb_conOutErr( hb_conNewLine(), 0 );
hb_xfree( pszVersion );
}
{
char buffer[ 128 ];
/* snprintf( buffer, sizeof( buffer ), "DS avail=%luKB OS avail=%luKB EMM avail=%luKB", hb_xquery( HB_MEM_BLOCK ), hb_xquery( HB_MEM_VM ), hb_xquery( HB_MEM_EMS ) ); */
snprintf( buffer, sizeof( buffer ), "DS avail=%luKB OS avail=%luKB EMM avail=%luKB MemStat:%s", hb_xquery( HB_MEM_BLOCK ), hb_xquery( HB_MEM_VM ), hb_xquery( HB_MEM_EMS ), hb_xquery( HB_MEM_USEDMAX ) ? "On" : "Off" );
hb_conOutErr( buffer, 0 );
hb_conOutErr( hb_conNewLine(), 0 );
}
}
if( hb_cmdargCheck( "BUILD" ) )
hb_verBuildInfo();
if( ( cFlags = hb_cmdargString( "FLAGS" ) ) != NULL )
{
int i = 0;
while( cFlags[ i ] )
{
switch( cFlags[ i++ ] )
{
case 'c':
/* clear all flags - minimal set of features */
ulFlags = 0;
break;
case 'h':
/* default Harbour mode */
ulFlags |= HB_VMFLAG_HARBOUR;
break;
/*
case 'x':
ulFlags |= HB_VMFLAG_XBASE;
break;
case 'r':
ulFlags |= HB_VMFLAG_RT_MACRO;
break;
*/
case 's':
ulFlags |= HB_VMFLAG_ARRSTR;
break;
}
}
hb_xfree( cFlags );
}
if( ( cFlags = hb_cmdargString( "CANCEL" ) ) != NULL )
{
int iVal = atoi( cFlags );
if( iVal )
*pCancelKey = iVal;
hb_xfree( cFlags );
}
if( ( cFlags = hb_cmdargString( "CANCELEX" ) ) != NULL )
{
int iVal = atoi( cFlags );
if( iVal )
*pCancelKeyEx = iVal;
hb_xfree( cFlags );
}
return ulFlags;
}
/* ChangeLog SVN revision number */
int hb_verSvnID( void )
{
return HB_VER_SVNID;
}
/* ChangeLog ID string */
const char * hb_verSvnChangeLogID( void )
{
return HB_VER_CHLID;
}
/* ChangeLog last entry string */
const char * hb_verSvnLastEntry( void )
{
return HB_VER_LENTRY;
}
/* build time C compiler flags in C_USR envvar */
const char * hb_verFlagsC( void )
{
#ifdef HB_VER_C_USR
return HB_VER_C_USR;
#else
return "";
#endif
}
/* build time linker flags in L_USR envvar */
const char * hb_verFlagsL( void )
{
#ifdef HB_VER_L_USR
return HB_VER_L_USR;
#else
return "";
#endif
}
/* build time Harbour compiler flags in PRG_USR envvar */
const char * hb_verFlagsPRG( void )
{
#ifdef HB_VER_PRG_USR
return HB_VER_PRG_USR;
#else
return "";
#endif
}