2011-01-27 14:30 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)

* contrib/hbnetio/utils/hbnetio/hbnetio.hbp
  * contrib/hbnetio/utils/hbnetio/hbnetioc.hbp
  * contrib/hbnetio/utils/hbnetio/netiosrv.prg
  + contrib/hbnetio/utils/hbnetio/netiocon.prg
  - contrib/hbnetio/utils/hbnetio/netiocui.prg
  + contrib/hbnetio/utils/hbnetio/netiocmd.prg
    + Split netiocui.prg into cmdline tool and
      console logic. The latter is now used by both 
      the daemon tool and cmdline tool.
This commit is contained in:
Viktor Szakats
2011-01-27 13:30:44 +00:00
parent 9b10f7e0f3
commit 4ab21df05c
6 changed files with 185 additions and 150 deletions

View File

@@ -16,6 +16,17 @@
The license applies to all entries newer than 2009-04-28.
*/
2011-01-27 14:30 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbnetio/utils/hbnetio/hbnetio.hbp
* contrib/hbnetio/utils/hbnetio/hbnetioc.hbp
* contrib/hbnetio/utils/hbnetio/netiosrv.prg
+ contrib/hbnetio/utils/hbnetio/netiocon.prg
- contrib/hbnetio/utils/hbnetio/netiocui.prg
+ contrib/hbnetio/utils/hbnetio/netiocmd.prg
+ Split netiocui.prg into cmdline tool and
console logic. The latter is now used by both
the daemon tool and cmdline tool.
2011-01-27 13:55 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbplist
- contrib/hbnetio/utils/netiosrq

View File

@@ -9,10 +9,8 @@
-o${hb_name}
-D_CONSOLEUI_EMBEDDED
netiosrv.prg
netiocui.prg
netiocon.prg
-ldflag={allmsvc}-nxcompat
-ldflag={allmsvc}-dynamicbase

View File

@@ -8,4 +8,5 @@
-o${hb_name}
netiocui.prg
netiocmd.prg
netiocon.prg

View File

@@ -0,0 +1,95 @@
/*
* $Id$
*/
/*
* Harbour Project source code:
* Harbour NETIO server management cmdline tool
*
* Copyright 2009-2011 Viktor Szakats (harbour.01 syenar.hu)
* www - http://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 of the License, 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 program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA (or visit
* their web site at http://www.gnu.org/).
*
*/
#define _NETIOMGM_IPV4_DEF "127.0.0.1"
#define _NETIOMGM_PORT_DEF 2940
PROCEDURE Main( ... )
LOCAL cParam
LOCAL cIP := _NETIOMGM_IPV4_DEF
LOCAL nPort := _NETIOMGM_PORT_DEF
LOCAL cPassword := ""
SET DATE ANSI
SET CENTURY ON
SET CONFIRM ON
SET SCOREBOARD OFF
HB_Logo()
FOR EACH cParam IN { ... }
DO CASE
CASE Lower( Left( cParam, 6 ) ) == "-addr="
hbnetiocon_IPPortSplit( SubStr( cParam, 7 ), @cIP, @nPort )
IF Empty( nPort )
nPort := _NETIOMGM_PORT_DEF
ENDIF
CASE Lower( Left( cParam, 6 ) ) == "-pass="
cPassword := SubStr( cParam, 7 )
hb_StrClear( @cParam )
CASE Lower( cParam ) == "--version"
RETURN
CASE Lower( cParam ) == "-help" .OR. ;
Lower( cParam ) == "--help"
HB_Usage()
RETURN
OTHERWISE
OutStd( "Warning: Unkown parameter ignored: " + cParam + hb_eol() )
ENDCASE
NEXT
hbnetiocon_cmdUI( cIP, nPort, cPassword )
RETURN
STATIC PROCEDURE HB_Logo()
OutStd( "Harbour NETIO Server Management Console " + StrTran( Version(), "Harbour " ) + hb_eol() +;
"Copyright (c) 2009-2011, Viktor Szakats" + hb_eol() + ;
"http://harbour-project.org/" + hb_eol() +;
hb_eol() )
RETURN
STATIC PROCEDURE HB_Usage()
OutStd( "Syntax:" , hb_eol() )
OutStd( hb_eol() )
OutStd( " netiocui [options]" , hb_eol() )
OutStd( hb_eol() )
OutStd( "Options:" , hb_eol() )
OutStd( hb_eol() )
OutStd( " -addr=<ip[:port]> connect to netio server on IPv4 address <ip:port>" , hb_eol() )
OutStd( hb_StrFormat( " Default: %1$s:%2$d", _NETIOMGM_IPV4_DEF, _NETIOMGM_PORT_DEF ) , hb_eol() )
OutStd( " -pass=<passwd> connect to netio server with password" , hb_eol() )
OutStd( hb_eol() )
OutStd( " --version display version header only" , hb_eol() )
OutStd( " -help|--help this help" , hb_eol() )
RETURN

View File

@@ -18,133 +18,7 @@
#include "hbgtinfo.ch"
#define _NETIOMGM_IPV4_DEF "127.0.0.1"
#define _NETIOMGM_PORT_DEF 2940
#if ! defined( _CONSOLEUI_EMBEDDED )
PROCEDURE Main( ... )
LOCAL cParam
LOCAL cIP := _NETIOMGM_IPV4_DEF
LOCAL nPort := _NETIOMGM_PORT_DEF
LOCAL cPassword := ""
SET DATE ANSI
SET CENTURY ON
SET CONFIRM ON
SET SCOREBOARD OFF
HB_Logo()
FOR EACH cParam IN { ... }
DO CASE
CASE Lower( Left( cParam, 6 ) ) == "-addr="
IPPortSplit( SubStr( cParam, 7 ), @cIP, @nPort )
IF Empty( nPort )
nPort := _NETIOMGM_PORT_DEF
ENDIF
CASE Lower( Left( cParam, 6 ) ) == "-pass="
cPassword := SubStr( cParam, 7 )
hb_StrClear( @cParam )
CASE Lower( cParam ) == "--version"
RETURN
CASE Lower( cParam ) == "-help" .OR. ;
Lower( cParam ) == "--help"
HB_Usage()
RETURN
OTHERWISE
OutStd( "Warning: Unkown parameter ignored: " + cParam + hb_eol() )
ENDCASE
NEXT
netiosrv_cmdUI( cIP, nPort, cPassword )
RETURN
STATIC PROCEDURE HB_Logo()
OutStd( "Harbour NETIO Server Management Console " + StrTran( Version(), "Harbour " ) + hb_eol() +;
"Copyright (c) 2009-2011, Viktor Szakats" + hb_eol() + ;
"http://harbour-project.org/" + hb_eol() +;
hb_eol() )
RETURN
STATIC PROCEDURE HB_Usage()
OutStd( "Syntax:" , hb_eol() )
OutStd( hb_eol() )
OutStd( " netiocui [options]" , hb_eol() )
OutStd( hb_eol() )
OutStd( "Options:" , hb_eol() )
OutStd( hb_eol() )
OutStd( " -addr=<ip[:port]> connect to netio server on IPv4 address <ip:port>" , hb_eol() )
OutStd( hb_StrFormat( " Default: %1$s:%2$d", _NETIOMGM_IPV4_DEF, _NETIOMGM_PORT_DEF ) , hb_eol() )
OutStd( " -pass=<passwd> connect to netio server with password" , hb_eol() )
OutStd( hb_eol() )
OutStd( " --version display version header only" , hb_eol() )
OutStd( " -help|--help this help" , hb_eol() )
RETURN
#endif
STATIC PROCEDURE cmdHelp( hCommands )
LOCAL aTexts := {}
LOCAL n, c, m
m := 0
hb_HEval( hCommands, {| k, l | m := Max( m, Len( k + iif( Empty( l[ 1 ] ), "", " " + l[ 1 ] ) ) ) } )
AAdd( aTexts, "Commands:" )
/* Processing commands */
FOR EACH n IN hCommands
AAdd( aTexts, " " + PadR( n:__enumKey() + iif( Empty( n[ 1 ] ), "", " " + n[ 1 ] ), m ) + " - " + n[ 2 ] )
NEXT
ASort( aTexts, 2 )
AAdd( aTexts, "" )
AAdd( aTexts, "Keyboard shortcuts:" )
AAdd( aTexts, PadR( " <Up>", m ) + " - Move up on historic list." )
AAdd( aTexts, PadR( " <Down>", m ) + " - Move down on historic list." )
AAdd( aTexts, PadR( " <Tab>", m ) + " - Complete command." )
AAdd( aTexts, PadR( " <Alt+V>", m ) + " - Paste from clipboard." )
c := 0
m := MaxRow()
FOR EACH n IN aTexts
QQOut( n, hb_eol() )
IF ++c == m
c := 0
QQOut( "Press any key to continue..." )
Inkey( 0 )
Scroll( Row(), 0, Row(), MaxCol(), 0 )
SetPos( Row(), 0 )
ENDIF
NEXT
RETURN
STATIC FUNCTION netiosrv_clientinfo()
LOCAL hInfo := { => }
hb_hKeepOrder( hInfo, .T. )
hInfo[ "OS()" ] := OS()
hInfo[ "Version()" ] := Version()
hInfo[ "hb_Compiler()" ] := hb_Compiler()
hInfo[ "NetName()" ] := NetName()
hInfo[ "hb_UserName()" ] := hb_UserName()
RETURN hInfo
PROCEDURE netiosrv_cmdUI( cIP, nPort, cPassword )
PROCEDURE hbnetiocon_cmdUI( cIP, nPort, cPassword )
LOCAL GetList := {}
LOCAL hCommands
LOCAL nSavedRow
@@ -283,6 +157,21 @@ PROCEDURE netiosrv_cmdUI( cIP, nPort, cPassword )
RETURN
PROCEDURE hbnetiocon_IPPortSplit( cAddr, /* @ */ cIP, /* @ */ nPort )
LOCAL tmp
IF ! Empty( cAddr )
cIP := cAddr
IF ( tmp := At( ":", cIP ) ) > 0
nPort := Val( SubStr( cIP, tmp + Len( ":" ) ) )
cIP := Left( cIP, tmp - 1 )
ELSE
nPort := NIL
ENDIF
ENDIF
RETURN
/* connect to the server */
STATIC FUNCTION ConnectLow( cIP, nPort, cPassword )
LOCAL pConnection
@@ -294,7 +183,7 @@ STATIC FUNCTION ConnectLow( cIP, nPort, cPassword )
IF ! Empty( pConnection )
netio_funcexec( pConnection, "hbnetiomgm_setclientinfo", netiosrv_clientinfo() )
netio_funcexec( pConnection, "hbnetiomgm_setclientinfo", MyClientInfo() )
netio_OpenItemStream( pConnection, "hbnetiomgm_cargo", "netiocui" )
QQOut( "Connected.", hb_eol() )
@@ -304,6 +193,19 @@ STATIC FUNCTION ConnectLow( cIP, nPort, cPassword )
RETURN pConnection
STATIC FUNCTION MyClientInfo()
LOCAL hInfo := { => }
hb_hKeepOrder( hInfo, .T. )
hInfo[ "OS()" ] := OS()
hInfo[ "Version()" ] := Version()
hInfo[ "hb_Compiler()" ] := hb_Compiler()
hInfo[ "NetName()" ] := NetName()
hInfo[ "hb_UserName()" ] := hb_UserName()
RETURN hInfo
STATIC FUNCTION GetPassword()
LOCAL GetList := {}
LOCAL cPassword := Space( 128 )
@@ -355,21 +257,6 @@ STATIC PROCEDURE CompleteCmd( cCommand, hCommands )
RETURN
STATIC PROCEDURE IPPortSplit( cAddr, /* @ */ cIP, /* @ */ nPort )
LOCAL tmp
IF ! Empty( cAddr )
cIP := cAddr
IF ( tmp := At( ":", cIP ) ) > 0
nPort := Val( SubStr( cIP, tmp + Len( ":" ) ) )
cIP := Left( cIP, tmp - 1 )
ELSE
nPort := NIL
ENDIF
ENDIF
RETURN
STATIC FUNCTION XToStrX( xValue )
LOCAL cType := ValType( xValue )
@@ -427,18 +314,61 @@ STATIC FUNCTION XToStrX( xValue )
/* Commands */
STATIC PROCEDURE cmdHelp( hCommands )
LOCAL aTexts := {}
LOCAL n, c, m
m := 0
hb_HEval( hCommands, {| k, l | m := Max( m, Len( k + iif( Empty( l[ 1 ] ), "", " " + l[ 1 ] ) ) ) } )
AAdd( aTexts, "Commands:" )
/* Processing commands */
FOR EACH n IN hCommands
AAdd( aTexts, " " + PadR( n:__enumKey() + iif( Empty( n[ 1 ] ), "", " " + n[ 1 ] ), m ) + " - " + n[ 2 ] )
NEXT
ASort( aTexts, 2 )
AAdd( aTexts, "" )
AAdd( aTexts, "Keyboard shortcuts:" )
AAdd( aTexts, PadR( " <Up>", m ) + " - Move up on historic list." )
AAdd( aTexts, PadR( " <Down>", m ) + " - Move down on historic list." )
AAdd( aTexts, PadR( " <Tab>", m ) + " - Complete command." )
AAdd( aTexts, PadR( " <Alt+V>", m ) + " - Paste from clipboard." )
c := 0
m := MaxRow()
FOR EACH n IN aTexts
QQOut( n, hb_eol() )
IF ++c == m
c := 0
QQOut( "Press any key to continue..." )
Inkey( 0 )
Scroll( Row(), 0, Row(), MaxCol(), 0 )
SetPos( Row(), 0 )
ENDIF
NEXT
RETURN
STATIC PROCEDURE cmdConnect( cCommand, /* @ */ pConnection, /* @ */ cIP, /* @ */ nPort )
LOCAL aToken
LOCAL cPassword
LOCAL nPortOld
IF Empty( pConnection )
aToken := hb_ATokens( cCommand, " " )
IF Len( aToken ) >= 2
IPPortSplit( aToken[ 2 ], @cIP, @nPort )
nPortOld := nPort
hbnetiocon_IPPortSplit( aToken[ 2 ], @cIP, @nPort )
IF Empty( nPort )
nPort := _NETIOMGM_PORT_DEF
nPort := nPortOld
ENDIF
ENDIF
IF Len( aToken ) >= 3

View File

@@ -216,7 +216,7 @@ PROCEDURE Main( ... )
OutStd( "Warning: Cannot start server management." + hb_eol() )
ELSE
IF lUI
hb_threadDetach( hb_threadStart( {|| netiosrv_cmdUI( netiomgm[ _NETIOSRV_cIFAddr ], netiomgm[ _NETIOSRV_nPort ], cPasswordManagement ) } ) )
hb_threadDetach( hb_threadStart( {|| hbnetiocon_cmdUI( netiomgm[ _NETIOSRV_cIFAddr ], netiomgm[ _NETIOSRV_nPort ], cPasswordManagement ) } ) )
ENDIF
ENDIF
ENDIF