2008-10-28 00:57 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
* include/hbextern.ch
* source/vm/cmdarg.c
+ Added HB_CMDLINE() .prg level function to return
the full command line. Currently it does reassemble
it from hb_argc/hb_argv.
* contrib/rddsql/mysqldd.c
! Fixed MSVC casting errors in C++ mode.
* include/hbwmain.c
* source/vm/cmdarg.c
* Moved argv[ 0 ] generation on Windows platform, so
that it now gets properly filled with the full
executable file path for console mode (GTWIN)
apps in all situations (f.e. when run from a
batch file using '%~n1.exe' macro).
* source/rtl/hbinet.c
! Fixed to use safe strerror() (named strerror_s())
under MSVS 2005 and upper.
Please test.
* source/hbzlib/gzio.c
+ Added _CRT_SECURE_NO_DEPRECATE locally to suppress
various MSVC unsafe CRT API usage warnings. Maybe it'd
be better to fix these by using Harbour APIs.
* utils/hbdoc/gentrf.prg
! Fixed missing "common.ch"
This commit is contained in:
@@ -8,6 +8,37 @@
|
||||
2008-12-31 13:59 UTC+0100 Foo Bar (foo.bar foobar.org)
|
||||
*/
|
||||
|
||||
2008-10-28 00:57 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
|
||||
* include/hbextern.ch
|
||||
* source/vm/cmdarg.c
|
||||
+ Added HB_CMDLINE() .prg level function to return
|
||||
the full command line. Currently it does reassemble
|
||||
it from hb_argc/hb_argv.
|
||||
|
||||
* contrib/rddsql/mysqldd.c
|
||||
! Fixed MSVC casting errors in C++ mode.
|
||||
|
||||
* include/hbwmain.c
|
||||
* source/vm/cmdarg.c
|
||||
* Moved argv[ 0 ] generation on Windows platform, so
|
||||
that it now gets properly filled with the full
|
||||
executable file path for console mode (GTWIN)
|
||||
apps in all situations (f.e. when run from a
|
||||
batch file using '%~n1.exe' macro).
|
||||
|
||||
* source/rtl/hbinet.c
|
||||
! Fixed to use safe strerror() (named strerror_s())
|
||||
under MSVS 2005 and upper.
|
||||
Please test.
|
||||
|
||||
* source/hbzlib/gzio.c
|
||||
+ Added _CRT_SECURE_NO_DEPRECATE locally to suppress
|
||||
various MSVC unsafe CRT API usage warnings. Maybe it'd
|
||||
be better to fix these by using Harbour APIs.
|
||||
|
||||
* utils/hbdoc/gentrf.prg
|
||||
! Fixed missing "common.ch"
|
||||
|
||||
2008-10-27 23:38 UTC+0200 Viktor Szakats (harbour.01 syenar hu)
|
||||
* contrib/hbmysql/tmysql.prg
|
||||
* contrib/xhb/hbcompat.ch
|
||||
|
||||
@@ -190,7 +190,7 @@ static ERRCODE mysqlConnect( SQLDDCONNECTION* pConnection, PHB_ITEM pItem )
|
||||
|
||||
static ERRCODE mysqlDisconnect( SQLDDCONNECTION* pConnection )
|
||||
{
|
||||
mysql_close( pConnection->hConnection );
|
||||
mysql_close( ( MYSQL * ) pConnection->hConnection );
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@@ -206,9 +206,9 @@ static ERRCODE mysqlExecute( SQLDDCONNECTION* pConnection, PHB_ITEM pItem )
|
||||
pConnection->iError = (int) mysql_errno( (MYSQL*) pConnection->hConnection );
|
||||
szError = mysql_error( (MYSQL*) pConnection->hConnection );
|
||||
if ( pConnection->szError )
|
||||
pConnection->szError = hb_xrealloc( pConnection->szError, strlen( szError ) + 1 );
|
||||
pConnection->szError = ( char * ) hb_xrealloc( pConnection->szError, strlen( szError ) + 1 );
|
||||
else
|
||||
pConnection->szError = hb_xgrab( strlen( szError ) + 1 );
|
||||
pConnection->szError = ( char * ) hb_xgrab( strlen( szError ) + 1 );
|
||||
hb_strncpy( pConnection->szError, szError, strlen( szError ) );
|
||||
return FAILURE;
|
||||
}
|
||||
@@ -234,9 +234,9 @@ static ERRCODE mysqlExecute( SQLDDCONNECTION* pConnection, PHB_ITEM pItem )
|
||||
pConnection->iError = (int) mysql_errno( (MYSQL*) pConnection->hConnection );
|
||||
szError = mysql_error( (MYSQL*) pConnection->hConnection );
|
||||
if ( pConnection->szError )
|
||||
pConnection->szError = hb_xrealloc( pConnection->szError, strlen( szError ) + 1 );
|
||||
pConnection->szError = ( char * ) hb_xrealloc( pConnection->szError, strlen( szError ) + 1 );
|
||||
else
|
||||
pConnection->szError = hb_xgrab( strlen( szError ) + 1 );
|
||||
pConnection->szError = ( char * ) hb_xgrab( strlen( szError ) + 1 );
|
||||
hb_strncpy( pConnection->szError, szError, strlen( szError ) );
|
||||
return FAILURE;
|
||||
}
|
||||
@@ -466,9 +466,9 @@ static ERRCODE mysqlGoTo( SQLBASEAREAP pArea, ULONG ulRecNo )
|
||||
|
||||
if ( ! ( pArea->bRecordFlags & SQLDD_FLAG_CACHED ) )
|
||||
{
|
||||
mysql_row_seek( (MYSQL_RES*) pArea->pResult, pArea->pRecord );
|
||||
pArea->pNatRecord = (void*) mysql_fetch_row( (MYSQL_RES*) pArea->pResult );
|
||||
pArea->pNatLength = (void*) mysql_fetch_lengths( (MYSQL_RES*) pArea->pResult );
|
||||
mysql_row_seek( ( MYSQL_RES * ) pArea->pResult, ( MYSQL_ROW_OFFSET ) pArea->pRecord );
|
||||
pArea->pNatRecord = ( void * ) mysql_fetch_row( ( MYSQL_RES * ) pArea->pResult );
|
||||
pArea->pNatLength = ( void * ) mysql_fetch_lengths( ( MYSQL_RES * ) pArea->pResult );
|
||||
}
|
||||
|
||||
pArea->fPositioned = TRUE;
|
||||
|
||||
@@ -793,6 +793,7 @@ EXTERNAL HB_ARGC
|
||||
EXTERNAL HB_ARGCHECK
|
||||
EXTERNAL HB_ARGSTRING
|
||||
EXTERNAL HB_ARGV
|
||||
EXTERNAL HB_CMDLINE
|
||||
EXTERNAL HB_COLORINDEX
|
||||
EXTERNAL HB_COMPILER
|
||||
EXTERNAL HB_PCODEVER
|
||||
|
||||
@@ -56,8 +56,6 @@
|
||||
|
||||
static int s_argc = 0;
|
||||
static char * s_argv[ HB_MAX_ARGS ];
|
||||
static char s_szAppName[ MAX_PATH ];
|
||||
static TCHAR s_lpAppName[ MAX_PATH ];
|
||||
|
||||
#if defined( HB_WINCE )
|
||||
# define HB_LPSTR LPWSTR
|
||||
@@ -76,9 +74,7 @@ int WINAPI WinMain( HINSTANCE hInstance, /* handle to current instance */
|
||||
|
||||
/* HB_TRACE(HB_TR_DEBUG, ("WinMain(%p, %p, %s, %d)", hInstance, hPrevInstance, lpCmdLine, iCmdShow)); */
|
||||
|
||||
GetModuleFileName( hInstance, s_lpAppName, MAX_PATH );
|
||||
HB_TCHAR_GETFROM( s_szAppName, s_lpAppName, MAX_PATH );
|
||||
s_argv[ s_argc++ ] = s_szAppName;
|
||||
s_argv[ s_argc++ ] = "";
|
||||
|
||||
pArg = NULL;
|
||||
|
||||
|
||||
@@ -7,6 +7,11 @@
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
/* Harbour addition */
|
||||
#if defined( _MSC_VER ) && _MSC_VER >= 1400 && ! defined( _CRT_SECURE_NO_DEPRECATE )
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "zutil.h"
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
#include "hbvm.h"
|
||||
|
||||
/* Compile in Unix mode under Cygwin */
|
||||
#ifdef HB_OS_UNIX_COMPATIBLE
|
||||
#if defined( HB_OS_UNIX_COMPATIBLE )
|
||||
#undef HB_OS_WIN_32
|
||||
#endif
|
||||
|
||||
@@ -113,42 +113,67 @@
|
||||
|
||||
typedef struct _HB_SOCKET_STRUCT
|
||||
{
|
||||
HB_SOCKET_T com;
|
||||
const char *errorDesc;
|
||||
int errorCode;
|
||||
struct sockaddr_in remote;
|
||||
LONG count;
|
||||
int timeout;
|
||||
int timelimit;
|
||||
PHB_ITEM caPeriodic;
|
||||
HB_SOCKET_T com;
|
||||
char errorDesc_buffer[ 128 ];
|
||||
const char * errorDesc;
|
||||
int errorCode;
|
||||
struct sockaddr_in remote;
|
||||
LONG count;
|
||||
int timeout;
|
||||
int timelimit;
|
||||
PHB_ITEM caPeriodic;
|
||||
} HB_SOCKET_STRUCT;
|
||||
|
||||
#define HB_PARSOCKET( n ) ( ( HB_SOCKET_STRUCT * ) hb_parptrGC( hb_inetSocketFinalize, n ) )
|
||||
|
||||
#define HB_SOCKET_ZERO_ERROR( s ) \
|
||||
do { s->errorCode = 0; s->errorDesc = ""; } while( 0 )
|
||||
do { s->errorCode = 0; s->errorDesc = ""; } while( 0 )
|
||||
|
||||
#if defined( HB_OS_WIN_32 )
|
||||
#define HB_SOCKET_SET_ERROR( s ) \
|
||||
do { \
|
||||
s->errorCode = WSAGetLastError(); \
|
||||
s->errorDesc = strerror( s->errorCode );\
|
||||
WSASetLastError( 0 ); \
|
||||
} while( 0 )
|
||||
|
||||
#if defined( _MSC_VER ) && _MSC_VER >= 1400
|
||||
#define HB_SOCKET_SET_ERROR( s ) \
|
||||
do { \
|
||||
s->errorCode = WSAGetLastError(); \
|
||||
strerror_s( s->errorDesc_buffer, sizeof( s->errorDesc_buffer ), s->errorCode ); \
|
||||
s->errorDesc = s->errorDesc_buffer; \
|
||||
WSASetLastError( 0 ); \
|
||||
} while( 0 )
|
||||
#else
|
||||
#define HB_SOCKET_SET_ERROR( s ) \
|
||||
do { \
|
||||
s->errorCode = WSAGetLastError(); \
|
||||
s->errorDesc = strerror( s->errorCode ); \
|
||||
WSASetLastError( 0 ); \
|
||||
} while( 0 )
|
||||
#endif
|
||||
#else
|
||||
#define HB_SOCKET_SET_ERROR( s ) \
|
||||
do { s->errorCode = errno; s->errorDesc = strerror( errno ); } while( 0 )
|
||||
#define HB_SOCKET_SET_ERROR( s ) \
|
||||
do { s->errorCode = errno; s->errorDesc = strerror( errno ); } while( 0 )
|
||||
#endif
|
||||
|
||||
#define HB_SOCKET_SET_ERROR1( s, code ) \
|
||||
do { s->errorCode = code; s->errorDesc = strerror( code ); } while( 0 )
|
||||
#if defined( _MSC_VER ) && _MSC_VER >= 1400
|
||||
#define HB_SOCKET_SET_ERROR1( s, code ) \
|
||||
do { \
|
||||
s->errorCode = code; \
|
||||
strerror_s( s->errorDesc_buffer, sizeof( s->errorDesc_buffer ), code ); \
|
||||
s->errorDesc = s->errorDesc_buffer; \
|
||||
} while( 0 )
|
||||
#else
|
||||
#define HB_SOCKET_SET_ERROR1( s, code ) \
|
||||
do { \
|
||||
s->errorCode = code; \
|
||||
s->errorDesc = strerror( code ); \
|
||||
} while( 0 )
|
||||
#endif
|
||||
#define HB_SOCKET_SET_ERROR2( s, code, desc ) \
|
||||
do { s->errorCode = code; s->errorDesc = desc; } while( 0 )
|
||||
do { \
|
||||
s->errorCode = code; \
|
||||
s->errorDesc = desc; \
|
||||
} while( 0 )
|
||||
|
||||
#define HB_SOCKET_INIT( s, p ) \
|
||||
do { \
|
||||
s = ( HB_SOCKET_STRUCT *) hb_gcAlloc( sizeof( HB_SOCKET_STRUCT ), hb_inetSocketFinalize );\
|
||||
s = ( HB_SOCKET_STRUCT * ) hb_gcAlloc( sizeof( HB_SOCKET_STRUCT ), hb_inetSocketFinalize );\
|
||||
memset( s, '\0', sizeof( HB_SOCKET_STRUCT ) );\
|
||||
s->com = ( HB_SOCKET_T ) -1;\
|
||||
s->timeout = -1;\
|
||||
@@ -223,7 +248,7 @@
|
||||
#define FD_ISSET( s, f ) ( 0 )
|
||||
#endif
|
||||
|
||||
#ifdef HB_OS_LINUX
|
||||
#if defined( HB_OS_LINUX )
|
||||
#include <signal.h>
|
||||
/* #define HB_INET_LINUX_INTERRUPT SIGUSR1+90 */
|
||||
# ifdef HB_INET_LINUX_INTERRUPT
|
||||
@@ -396,7 +421,7 @@ static struct hostent * hb_getHosts( char * name, HB_SOCKET_STRUCT *Socket )
|
||||
|
||||
static void hb_socketSetNonBlocking( HB_SOCKET_STRUCT *Socket )
|
||||
{
|
||||
#ifdef HB_OS_WIN_32
|
||||
#if defined( HB_OS_WIN_32 )
|
||||
ULONG mode = 1;
|
||||
ioctlsocket( Socket->com, FIONBIO, &mode );
|
||||
|
||||
@@ -415,7 +440,7 @@ static void hb_socketSetNonBlocking( HB_SOCKET_STRUCT *Socket )
|
||||
|
||||
static void hb_socketSetBlocking( HB_SOCKET_STRUCT *Socket )
|
||||
{
|
||||
#ifdef HB_OS_WIN_32
|
||||
#if defined( HB_OS_WIN_32 )
|
||||
ULONG mode = 0;
|
||||
ioctlsocket( Socket->com, FIONBIO, &mode );
|
||||
#else
|
||||
|
||||
@@ -64,6 +64,11 @@
|
||||
static int s_argc = 0;
|
||||
static char ** s_argv = NULL;
|
||||
|
||||
#if defined( HB_OS_WIN_32 )
|
||||
static char s_szAppName[ MAX_PATH ];
|
||||
static TCHAR s_lpAppName[ MAX_PATH ];
|
||||
#endif
|
||||
|
||||
#if defined( HB_OS_WIN_32 ) && defined( HB_OS_WIN_32_USED )
|
||||
|
||||
HB_EXTERN_BEGIN
|
||||
@@ -114,6 +119,20 @@ HB_EXPORT void hb_cmdargInit( int argc, char * argv[] )
|
||||
|
||||
s_argc = argc;
|
||||
s_argv = argv;
|
||||
|
||||
#if defined( HB_OS_WIN_32 )
|
||||
|
||||
/* NOTE: Manually setup the executable name in Windows,
|
||||
because in console apps the name may be truncated
|
||||
in some cases, and in GUI apps it's not filled
|
||||
at all. [vszakats] */
|
||||
if( GetModuleFileName( NULL, s_lpAppName, MAX_PATH ) != 0 )
|
||||
{
|
||||
HB_TCHAR_GETFROM( s_szAppName, s_lpAppName, MAX_PATH );
|
||||
s_argv[ 0 ] = s_szAppName;
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
int hb_cmdargARGC( void )
|
||||
@@ -331,6 +350,32 @@ HB_FUNC( HB_ARGV )
|
||||
hb_retc( ( argc >= 0 && argc < s_argc ) ? s_argv[ argc ] : NULL );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_CMDLINE )
|
||||
{
|
||||
char * pszBuffer;
|
||||
|
||||
int nLen;
|
||||
int nPos;
|
||||
|
||||
int argc = hb_cmdargARGC();
|
||||
char** argv = hb_cmdargARGV();
|
||||
|
||||
nLen = 1;
|
||||
for( nPos = 1; nPos < argc; nPos++ )
|
||||
nLen += ( int ) strlen( argv[ nPos ] ) + 1;
|
||||
|
||||
pszBuffer = ( char * ) hb_xgrab( nLen + 1 );
|
||||
|
||||
pszBuffer[ 0 ] = '\0';
|
||||
for( nPos = 1; nPos < argc; nPos++ )
|
||||
{
|
||||
hb_strncat( pszBuffer, argv[ nPos ], nLen );
|
||||
hb_strncat( pszBuffer, " ", nLen );
|
||||
}
|
||||
|
||||
hb_retc_buffer( pszBuffer );
|
||||
}
|
||||
|
||||
/* Check for command line internal arguments */
|
||||
ULONG hb_cmdargProcessVM( int *pCancelKey, int *pCancelKeyEx )
|
||||
{
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include "directry.ch"
|
||||
#include "fileio.ch"
|
||||
#include "inkey.ch"
|
||||
#include "common.ch"
|
||||
|
||||
#include "hbclass.ch"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user