From 774bf60b435789da922ad8d63de220e82f489716 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Tue, 12 Jan 2010 12:08:46 +0000 Subject: [PATCH] 2010-01-12 13:08 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbnetio/utils/netiosrv.prg + Added new parameter parsing allowing to pass options in free order in any combination. --- harbour/ChangeLog | 5 ++ harbour/contrib/hbnetio/utils/netiosrv.prg | 70 ++++++++++++---------- 2 files changed, 45 insertions(+), 30 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 85fbbf2f64..c20e1306c0 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,11 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-01-12 13:08 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbnetio/utils/netiosrv.prg + + Added new parameter parsing allowing to pass options in free + order in any combination. + 2010-01-12 12:23 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbnetio/utils/netiosrv.hbp + Now includes hbmk.hbm so that the .hbp file works when diff --git a/harbour/contrib/hbnetio/utils/netiosrv.prg b/harbour/contrib/hbnetio/utils/netiosrv.prg index d78ff96d57..c73245fae5 100644 --- a/harbour/contrib/hbnetio/utils/netiosrv.prg +++ b/harbour/contrib/hbnetio/utils/netiosrv.prg @@ -18,49 +18,59 @@ REQUEST HB_MT /* enable this if you need all core functions in RPC support */ //REQUEST __HB_EXTERN__ -PROCEDURE Main( port, ifaddr, rootdir, rpc, passwd ) +PROCEDURE Main( ... ) LOCAL pListenSocket + LOCAL cParam + + LOCAL port := 2941 + LOCAL ifaddr := "0.0.0.0" + LOCAL rootdir := hb_dirBase() + LOCAL rpc := .F. + LOCAL passwd := NIL HB_Logo() - port := IIF( Empty( port ), 2941, Val( port ) ) - IF Empty( ifaddr ) - ifaddr := "0.0.0.0" - ENDIF - IF Empty( rootdir ) - rootdir := hb_dirBase() - ENDIF - rpc := !Empty( rpc ) - IF !Empty( passwd ) .AND. Len( passwd ) == 0 - passwd := NIL - ENDIF + FOR EACH cParam IN hb_AParams() + DO CASE + CASE Lower( Left( cParam, 6 ) ) == "-port=" + port := Val( SubStr( cParam, 7 ) ) + CASE Lower( Left( cParam, 6 ) ) == "-addr=" + ifaddr := SubStr( cParam, 7 ) + CASE Lower( Left( cParam, 9 ) ) == "-rootdir=" + rootdir := SubStr( cParam, 10 ) + CASE Lower( Left( cParam, 6 ) ) == "-pass=" + passwd := SubStr( cParam, 7 ) + CASE Lower( cParam ) == "-rpc" + rpc := .T. + CASE Lower( cParam ) == "-help" .OR. ; + Lower( cParam ) == "--help" + HB_Usage() + RETURN + ENDCASE + NEXT - IF port == 0 - HB_Usage() + pListenSocket := netio_mtserver( port, ifaddr, rootdir, rpc, passwd ) + IF Empty( pListenSocket ) + OutStd( "Cannot start server." + hb_osNewLine() ) ELSE - pListenSocket := netio_mtserver( port, ifaddr, rootdir, rpc, passwd ) - IF Empty( pListenSocket ) - OutStd( "Cannot start server." + hb_osNewLine() ) - ELSE - OutStd( "Listening on: " + ifaddr + ":" + hb_ntos( port ) + hb_osNewLine() ) - OutStd( "Root filesystem: " + rootdir + hb_osNewLine() ) - OutStd( "RPC support: " + iif( rpc, "enabled", "disabled" ) + hb_osNewLine() ) - OutStd( "Encryption: " + iif( passwd != NIL, "enabled", "disabled" ) + hb_osNewLine() ) + OutStd( "Listening on: " + ifaddr + ":" + hb_ntos( port ) + hb_osNewLine() ) + OutStd( "Root filesystem: " + rootdir + hb_osNewLine() ) + OutStd( "RPC support: " + iif( rpc, "enabled", "disabled" ) + hb_osNewLine() ) + OutStd( "Encryption: " + iif( passwd != NIL, "enabled", "disabled" ) + hb_osNewLine() ) - OutStd( hb_osNewLine() ) - OutStd( "Press any key to stop NETIO server." + hb_osNewLine() ) - Inkey( 0 ) + OutStd( hb_osNewLine() ) + OutStd( "Press any key to stop NETIO server." + hb_osNewLine() ) + Inkey( 0 ) - netio_serverstop( pListenSocket ) - pListenSocket := NIL - ENDIF + netio_serverstop( pListenSocket ) + pListenSocket := NIL ENDIF RETURN STATIC PROCEDURE HB_Logo() - OutStd( 'Harbour NETIO Server ' + HBRawVersion() + hb_osNewLine() +; + OutStd( "Harbour NETIO Server " + HBRawVersion() + hb_osNewLine() +; "Copyright (c) 2009, Przemyslaw Czerpak" + hb_osNewLine() + ; "http://www.harbour-project.org/" + hb_osNewLine() +; hb_osNewLine() ) @@ -69,7 +79,7 @@ STATIC PROCEDURE HB_Logo() STATIC PROCEDURE HB_Usage() - OutStd( "Syntax: netiosrv [] [] [] [] []" + hb_osNewLine() ) + OutStd( "Syntax: netiosrv [-port=] [-addr=] [-rootdir=] [-rpc] [-pass=]" + hb_osNewLine() ) RETURN