2010-05-16 00:02 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)

* contrib/hbwin/win_srv.c
    ! Fixed static variable types and usage.
    ! Fixed wrongly used string types.
    ! Fixed storing temporary pointers to static variables.
      Making a copy of the strings instead.
    % Deleted unnecessary function declarations.
    % Using HB_SIZEOFARRAY() instead of repeating size.
    ! Fixed variable names to reflect type.
    ; These fixed previously found errors.

  * contrib/hbwin/tests/testsrv.prg
    * Replaced ALERT() with '?'.
    ! Fixed to use HB_TR_ALWAYS to avoid Harbour warning.
    % FUNCTION -> PROCEDURE
This commit is contained in:
Viktor Szakats
2010-05-15 22:03:53 +00:00
parent 52f91ee823
commit 669d479980
3 changed files with 41 additions and 39 deletions

View File

@@ -17,6 +17,22 @@
past entries belonging to author(s): Viktor Szakats.
*/
2010-05-16 00:02 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbwin/win_srv.c
! Fixed static variable types and usage.
! Fixed wrongly used string types.
! Fixed storing temporary pointers to static variables.
Making a copy of the strings instead.
% Deleted unnecessary function declarations.
% Using HB_SIZEOFARRAY() instead of repeating size.
! Fixed variable names to reflect type.
; These fixed previously found errors.
* contrib/hbwin/tests/testsrv.prg
* Replaced ALERT() with '?'.
! Fixed to use HB_TR_ALWAYS to avoid Harbour warning.
% FUNCTION -> PROCEDURE
2010-15-15 14:29 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com)
* contrib/hbide/ideedit.prg
! Fixed: copy with Sh+Left was not working ok when employed backward in stream mode.
@@ -27,7 +43,7 @@
* contrib/hbwin/win_srv.c
! Fixed one TOFIX which was result of s&r on my part.
; TOFIX remaining:
; TOFIX remaining: [DONE]
---
../../../win_srv.c: In function 'hbwin_SrvFunction':
../../../win_srv.c:102:4: warning: passing argument 1 of 'RegisterServiceCtrlHandlerW' from incompatible pointer type

View File

@@ -66,28 +66,28 @@ PROCEDURE Main( cMode )
SWITCH Upper( cMode )
CASE "I"
IF win_serviceInstall( _SERVICE_NAME, "Win32 Harbour Service" )
Alert( "Service has been successfully installed" )
IF win_serviceInstall( _SERVICE_NAME, "Harbour Windows Service" )
? "Service has been successfully installed"
ELSE
Alert( "Error installing service:" + hb_ntos( wapi_GetLastError() ) )
? "Error installing service: " + hb_ntos( wapi_GetLastError() )
ENDIf
EXIT
CASE "U"
IF win_serviceDelete( _SERVICE_NAME )
Alert( "Service has been deleted" )
? "Service has been deleted"
ELSE
Alert( "Error deleting service:" + hb_ntos( wapi_GetLastError() ) )
? "Error deleting service:" + hb_ntos( wapi_GetLastError() )
ENDIf
EXIT
CASE "S"
IF win_serviceStart( _SERVICE_NAME, "SrvMain" )
HB_TRACE( HB_TR_INFO, "Service has worked Ok" )
? "Service has started OK"
ELSE
HB_TRACE( HB_TR_ERROR, "Service has had som problems : " + hb_ntos( wapi_GetLastError() ) )
? "Service has had some problems: " + hb_ntos( wapi_GetLastError() )
ENDIF
EXIT
@@ -95,17 +95,17 @@ PROCEDURE Main( cMode )
RETURN
FUNCTION SrvMain()
PROCEDURE SrvMain()
LOCAL n
n := 1
DO WHILE win_serviceGetStatus() == WIN_SERVICE_RUNNING
HB_TRACE( HB_TR_INFO, "Work in progress " + hb_ntos( n ) )
n := n + 1
HB_TRACE( HB_TR_ALWAYS, "Work in progress " + hb_ntos( n ) )
++n
Inkey( 0.1 )
ENDDO
win_serviceSetExitCode( 0 )
win_serviceStop()
RETURN NIL
RETURN

View File

@@ -60,11 +60,8 @@
static SERVICE_STATUS s_ServiceStatus;
static SERVICE_STATUS_HANDLE s_hStatus;
static char * s_pszPrgFunction;
static char * s_pszSrvName;
static void hbwin_ControlHandler( DWORD request );
static void hbwin_SrvFunction( int argc, char ** argv );
static char s_szPrgFunction[ 64 ];
static TCHAR s_lpSrvName[ 64 ];
/* Control handler function */
static void hbwin_ControlHandler( DWORD request )
@@ -82,8 +79,7 @@ static void hbwin_ControlHandler( DWORD request )
return;
}
/* Report current status */
SetServiceStatus( s_hStatus, &s_ServiceStatus );
SetServiceStatus( s_hStatus, &s_ServiceStatus ); /* Report current status */
}
static void hbwin_SrvFunction( int argc, char** argv )
@@ -99,11 +95,11 @@ static void hbwin_SrvFunction( int argc, char** argv )
s_ServiceStatus.dwCheckPoint = 0;
s_ServiceStatus.dwWaitHint = 0;
s_hStatus = RegisterServiceCtrlHandler( s_pszSrvName, ( LPHANDLER_FUNCTION ) hbwin_ControlHandler );
s_hStatus = RegisterServiceCtrlHandler( s_lpSrvName, ( LPHANDLER_FUNCTION ) hbwin_ControlHandler );
if( s_hStatus != ( SERVICE_STATUS_HANDLE ) 0 )
{
PHB_DYNS pDynSym = hb_dynsymFindName( s_pszPrgFunction );
PHB_DYNS pDynSym = hb_dynsymFindName( s_szPrgFunction );
/* We report the running status to SCM. */
s_ServiceStatus.dwCurrentState = SERVICE_RUNNING;
@@ -122,7 +118,7 @@ static void hbwin_SrvFunction( int argc, char** argv )
}
else
{
HB_TRACE( HB_TR_DEBUG, ( "Error registering service\n" ) );
HB_TRACE( HB_TR_DEBUG, ("Error registering service") );
}
}
@@ -160,7 +156,7 @@ HB_FUNC( WIN_SERVICESETEXITCODE ) /* dwExitCode */
HB_FUNC( WIN_SERVICESTOP )
{
#if ! defined( HB_OS_WIN_CE )
s_ServiceStatus.dwCurrentState = SERVICE_STOPPED;
s_ServiceStatus.dwCurrentState = SERVICE_STOPPED;
SetServiceStatus( s_hStatus, &s_ServiceStatus );
#endif
}
@@ -169,9 +165,9 @@ HB_FUNC( WIN_SERVICEINSTALL )
{
HB_BOOL bRetVal = HB_FALSE;
#if ! defined( HB_OS_WIN_CE )
TCHAR szPath[ MAX_PATH ];
TCHAR lpPath[ MAX_PATH ];
if( GetModuleFileName( NULL, szPath, MAX_PATH ) )
if( GetModuleFileName( NULL, lpPath, HB_SIZEOFARRAY( lpPath ) ) )
{
SC_HANDLE schSCM = OpenSCManager( NULL, NULL, SC_MANAGER_ALL_ACCESS );
@@ -192,7 +188,7 @@ HB_FUNC( WIN_SERVICEINSTALL )
SERVICE_WIN32_OWN_PROCESS, /* service type */
SERVICE_DEMAND_START, /* start type */
SERVICE_ERROR_NORMAL, /* error control type */
szPath, /* path to service's binary */
lpPath, /* path to service's binary */
NULL, /* no load ordering group */
NULL, /* no tag identifier */
NULL, /* no dependencies */
@@ -262,26 +258,16 @@ HB_FUNC( WIN_SERVICESTART ) /* pszServiceName, pszPrgFunction */
{
#if ! defined( HB_OS_WIN_CE )
SERVICE_TABLE_ENTRY ServiceTable[ 2 ];
LPTSTR lpServiceName;
LPTSTR lpPrgFunction;
void * hServiceName;
void * hPrgFunction;
lpServiceName = ( LPTSTR ) HB_PARSTR( 1, &hServiceName, NULL );
lpPrgFunction = ( LPTSTR ) HB_PARSTR( 2, &hPrgFunction, NULL );
HB_TCHAR_COPYTO( s_lpSrvName, hb_parcx( 1 ), HB_SIZEOFARRAY( s_lpSrvName ) - 1 );
hb_strncpy( s_szPrgFunction, hb_parcx( 2 ), HB_SIZEOFARRAY( s_szPrgFunction ) - 1 );
ServiceTable[ 0 ].lpServiceName = lpServiceName;
ServiceTable[ 0 ].lpServiceName = s_lpSrvName;
ServiceTable[ 0 ].lpServiceProc = ( LPSERVICE_MAIN_FUNCTION ) hbwin_SrvFunction;
ServiceTable[ 1 ].lpServiceName = NULL;
ServiceTable[ 1 ].lpServiceProc = NULL;
s_pszPrgFunction = lpPrgFunction;
s_pszSrvName = lpServiceName;
hb_strfree( hServiceName );
hb_strfree( hPrgFunction );
hb_retl( ( HB_BOOL ) StartServiceCtrlDispatcher( ServiceTable ) );
#else
hb_retl( HB_FALSE );