cnping

Minimal Graphical Ping Tool
git clone https://git.sinitax.com/cnlohr/cnping
Log | Files | Refs | Submodules | README | LICENSE | sfeed.txt

commit d0369a7a6df228f01c8784fb3ca09ca0ca73a54d
parent 4ebd9e919daa22df274f7678eeea52537f9060aa
Author: hackrid <hack.rid@gmail.com>
Date:   Fri,  8 Apr 2016 15:33:54 +0200

unified parameter evaluation

Diffstat:
Mcnping.c | 41++++++++++++++++++++++++++++++++---------
1 file changed, 32 insertions(+), 9 deletions(-)

diff --git a/cnping.c b/cnping.c @@ -24,7 +24,7 @@ unsigned long iframeno = 0; short screenx, screeny; const char * pinghost; float pingperiod; -double GuiYScaleFactor; +float GuiYScaleFactor; uint8_t pattern[8]; @@ -36,7 +36,7 @@ double PingSendTimes[PINGCYCLEWIDTH]; double PingRecvTimes[PINGCYCLEWIDTH]; int current_cycle = 0; -int ExtraPingSize = 0; +int ExtraPingSize; void display(uint8_t *buf, int bytes) { @@ -222,6 +222,7 @@ int main( int argc, const char ** argv ) PingRecvTimes[i] = 0; } + if( argc < 2 ) { ERRM( "Usage: cnping [host] [period] [extra size] [y-axis scaling]\n" @@ -233,21 +234,43 @@ int main( int argc, const char ** argv ) return -1; } + + if( argc > 2 ) + { + pingperiod = atof( argv[2] ); + printf( "Extra ping period: %f\n", pingperiod ); + } + else + { + pingperiod = 0.02; + } + if( argc > 3 ) { ExtraPingSize = atoi( argv[3] ); - printf( "Extra ping size added: %d\n", ExtraPingSize ); + printf( "Extra ping size: %d\n", ExtraPingSize ); + } + else + { + ExtraPingSize = 0; } - sprintf( title, "%s - cnping", argv[1] ); - CNFGSetup( title, 320, 155 ); - - ping_setup(); + if( argc > 4 ) + { + GuiYScaleFactor = atof( argv[4] ); + printf( "GuiYScaleFactor: %f\n", GuiYScaleFactor ); + } + else + { + GuiYScaleFactor = 1; + } pinghost = argv[1]; - pingperiod = (argc>=3)?atof( argv[2] ):.02; - GuiYScaleFactor = (argc>4)?atof( argv[4] ):1; + sprintf( title, "%s - cnping", pinghost ); + CNFGSetup( title, 320, 155 ); + + ping_setup(); OGCreateThread( PingSend, 0 ); OGCreateThread( PingListen, 0 );