From faf75dbc3f06c1c92f4059cfbfae9381d508183b Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Wed, 9 Mar 2011 19:05:21 +0000 Subject: [PATCH] 2011-03-09 20:00 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbnetio/utils/hbnetio/hbnetio.hbp * contrib/hbnetio/utils/hbnetio/netiosrv.prg + contrib/hbnetio/utils/hbnetio/netiosvc.prg + hbnetio will act as a service on Windows platform. To run it interactively from console, use: 'hbnetio -a' ; TOFIX: I'm getting 'error 1067' when starting up the service. It get resolved when I build hbnetio in -st mode. (I use mingw and did a full rebuild) * contrib/rddads/rddads.hbp ! Suppressing annoying mingw warning in ace.h. ; TOFIX: hbmk2 overrides this ATM. --- harbour/ChangeLog | 14 +++++ .../contrib/hbnetio/utils/hbnetio/hbnetio.hbp | 3 + .../hbnetio/utils/hbnetio/netiosrv.prg | 8 ++- .../hbnetio/utils/hbnetio/netiosvc.prg | 61 +++++++++++++++++++ harbour/contrib/rddads/rddads.hbp | 3 + 5 files changed, 87 insertions(+), 2 deletions(-) create mode 100644 harbour/contrib/hbnetio/utils/hbnetio/netiosvc.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 973e48ef00..16faee0de0 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,20 @@ The license applies to all entries newer than 2009-04-28. */ +2011-03-09 20:00 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbnetio/utils/hbnetio/hbnetio.hbp + * contrib/hbnetio/utils/hbnetio/netiosrv.prg + + contrib/hbnetio/utils/hbnetio/netiosvc.prg + + hbnetio will act as a service on Windows platform. + To run it interactively from console, use: 'hbnetio -a' + ; TOFIX: I'm getting 'error 1067' when starting up the + service. It get resolved when I build hbnetio in + -st mode. (I use mingw and did a full rebuild) + + * contrib/rddads/rddads.hbp + ! Suppressing annoying mingw warning in ace.h. + ; TOFIX: hbmk2 overrides this ATM. + 2011-03-09 18:30 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbwin/win_svc.c * contrib/hbwin/tests/testsvc.prg diff --git a/harbour/contrib/hbnetio/utils/hbnetio/hbnetio.hbp b/harbour/contrib/hbnetio/utils/hbnetio/hbnetio.hbp index 952f434652..8cdd3416e4 100644 --- a/harbour/contrib/hbnetio/utils/hbnetio/hbnetio.hbp +++ b/harbour/contrib/hbnetio/utils/hbnetio/hbnetio.hbp @@ -12,5 +12,8 @@ netiosrv.prg netiocon.prg netiomgm.prg +netiosvc.prg{win} +-main=WinMain{win} +hbwin.hbc{win} #-prgflag=-DHB_EXTERN diff --git a/harbour/contrib/hbnetio/utils/hbnetio/netiosrv.prg b/harbour/contrib/hbnetio/utils/hbnetio/netiosrv.prg index 87d28c3792..6d11b2470b 100644 --- a/harbour/contrib/hbnetio/utils/hbnetio/netiosrv.prg +++ b/harbour/contrib/hbnetio/utils/hbnetio/netiosrv.prg @@ -86,6 +86,10 @@ REQUEST HB_MT #define _NETIOSRV_CONN_MAX_ 4 PROCEDURE Main( ... ) + netiosrv_Main( .T., ... ) + RETURN + +PROCEDURE netiosrv_Main( lUI, ... ) LOCAL netiosrv[ _NETIOSRV_MAX_ ] LOCAL netiomgm[ _NETIOSRV_MAX_ ] @@ -96,8 +100,6 @@ PROCEDURE Main( ... ) LOCAL cExt LOCAL cFile - LOCAL lUI := .T. - Set( _SET_DATEFORMAT, "yyyy.mm.dd" ) Set( _SET_TIMEFORMAT, "HH:MM:SS.FFF" ) @@ -142,6 +144,8 @@ PROCEDURE Main( ... ) FOR EACH cParam IN { ... } DO CASE + CASE Lower( cParam ) == "-a" + /* Ignore */ CASE Lower( Left( cParam, 5 ) ) == "-noui" lUI := .F. CASE Lower( Left( cParam, 6 ) ) == "-port=" diff --git a/harbour/contrib/hbnetio/utils/hbnetio/netiosvc.prg b/harbour/contrib/hbnetio/utils/hbnetio/netiosvc.prg new file mode 100644 index 0000000000..f9dcbc8d1e --- /dev/null +++ b/harbour/contrib/hbnetio/utils/hbnetio/netiosvc.prg @@ -0,0 +1,61 @@ + +#include "hbwin.ch" + +#define _SERVICE_NAME "Harbour_NetIO_Service" + +PROCEDURE WinMain( ... ) + LOCAL cMode := hb_PValue( 1 ) + + IF cMode == NIL + cMode := "-s" /* NOTE: Must be the default action */ + ENDIF + + SWITCH Lower( cMode ) + CASE "-i" + CASE "-install" + + IF win_serviceInstall( _SERVICE_NAME, "Harbour NetIO Service" ) + OutStd( "Service has been successfully installed" + hb_eol() ) + ELSE + OutStd( "Error installing service: " + hb_ntos( wapi_GetLastError() ) + hb_eol() ) + ENDIf + EXIT + + CASE "-u" + CASE "-uninstall" + + IF win_serviceDelete( _SERVICE_NAME ) + OutStd( "Service has been deleted" + hb_eol() ) + ELSE + OutStd( "Error deleting service: " + hb_ntos( wapi_GetLastError() ) + hb_eol() ) + ENDIf + EXIT + + CASE "-a" + + netiosrv_Main( .T., ... ) /* Interactive */ + EXIT + + CASE "-s" + CASE "-service" + + IF win_serviceStart( _SERVICE_NAME, @hbnetio_WinServiceEntry() ) + OutStd( "Service has started OK" + hb_eol() ) + ELSE + OutStd( "Service has had some problems: " + hb_ntos( wapi_GetLastError() ) + hb_eol() ) + ENDIF + EXIT + + ENDSWITCH + + RETURN + +PROCEDURE hbnetio_WinServiceEntry( ... ) +// LOCAL bSignal := {|| win_serviceGetStatus() != WIN_SERVICE_RUNNING } + + netiosrv_Main( .F., ... ) /* Non-interactive */ + + win_serviceSetExitCode( 0 ) + win_serviceStop() + + RETURN diff --git a/harbour/contrib/rddads/rddads.hbp b/harbour/contrib/rddads/rddads.hbp index 0403de68d4..c954cb870b 100644 --- a/harbour/contrib/rddads/rddads.hbp +++ b/harbour/contrib/rddads/rddads.hbp @@ -24,6 +24,9 @@ -instfile=inc:adsextrn.ch -instfile=inc:rddads.hbx +# To avoid a warning in ACE header +-cflag=-Wno-pragmas{allmingw} + rddads.hbx ads1.c