From c36db7615076108c78da09c210d16b43da803e57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Fillod=2C=20F8CFE?= Date: Fri, 6 Sep 2002 10:43:59 +0000 Subject: [PATCH] added ability to enter long command names in interactive mode, by prefixing them with a \ git-svn-id: https://hamlib.svn.sourceforge.net/svnroot/hamlib/trunk@1158 7ae35d74-ebe9-4afe-98af-79ac388436b8 --- tests/rigctl.c | 21 ++++++++++++++++++--- tests/rotctl.c | 25 ++++++++++++++++++++----- 2 files changed, 38 insertions(+), 8 deletions(-) diff --git a/tests/rigctl.c b/tests/rigctl.c index faf7ac507..b7c2903d8 100644 --- a/tests/rigctl.c +++ b/tests/rigctl.c @@ -5,7 +5,7 @@ * It takes commands in interactive mode as well as * from command line options. * - * $Id: rigctl.c,v 1.35 2002-08-26 21:26:06 fillods Exp $ + * $Id: rigctl.c,v 1.36 2002-09-06 10:43:59 fillods Exp $ * * * This program is free software; you can redistribute it and/or @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -135,7 +136,7 @@ declare_proto_rig(get_info); * TODO: add missing rig_set_/rig_get_: [rx]it, ant, sql, dcd, etc. * NB: 'q' 'Q' '?' are reserved by interactive mode interface * - * Available letters: -.--------K-----*-----W-YZ + * Available alphabetic letters: -.--------K-----*-----W-YZ */ struct test_table test_list[] = { { 'F', "set_freq", set_freq, ARG_IN, "Frequency" }, @@ -453,6 +454,20 @@ int main (int argc, char *argv[]) do { scanf("%c", &cmd); + + /* command by name */ + if (cmd == '\\') { + char cmd_name[MAXNAMSIZ], *pcmd = cmd_name; + int c_len = MAXNAMSIZ; + + scanf("%c", pcmd); + while(c_len-- && (isalnum(*pcmd) || *pcmd == '_' )) + scanf("%c", ++pcmd); + *pcmd = '\0'; + cmd = parse_arg(cmd_name); + break; + } + if (cmd == 0x0a || cmd == 0x0d) { if (last_was_ret) { printf("? for help, q to quit.\n"); @@ -465,12 +480,12 @@ int main (int argc, char *argv[]) last_was_ret = 0; + /* comment line */ if (cmd == '#' || cmd == ';') { while( cmd != '\n' && cmd != '\r') scanf("%c", &cmd); continue; } - if (cmd == 'Q' || cmd == 'q') break; if (cmd == '?') { diff --git a/tests/rotctl.c b/tests/rotctl.c index 5a5348edb..a5095decd 100644 --- a/tests/rotctl.c +++ b/tests/rotctl.c @@ -1,11 +1,11 @@ /* - * rotctl.c - (C) Stephane Fillod 2000,2001 + * rotctl.c - (C) Stephane Fillod 2000-2002 * * This program test/control a rotator using Hamlib. * It takes commands in interactive mode as well as * from command line options. * - * $Id: rotctl.c,v 1.3 2002-01-16 17:08:31 fgretief Exp $ + * $Id: rotctl.c,v 1.4 2002-09-06 10:43:59 fillods Exp $ * * * This program is free software; you can redistribute it and/or @@ -32,6 +32,7 @@ #include #include #include +#include #include @@ -297,14 +298,28 @@ int main (int argc, char *argv[]) static int last_was_ret = 1; if (interactive) { - printf("\nRig command: "); + printf("\nRot command: "); do { scanf("%c", &cmd); + + /* command by name */ + if (cmd == '\\') { + char cmd_name[MAXNAMSIZ], *pcmd = cmd_name; + int c_len = MAXNAMSIZ; + + scanf("%c", pcmd); + while(c_len-- && (isalnum(*pcmd) || *pcmd == '_' )) + scanf("%c", ++pcmd); + *pcmd = '\0'; + cmd = parse_arg(cmd_name); + break; + } + if (cmd == 0x0a || cmd == 0x0d) { if (last_was_ret) { printf("? for help, q to quit.\n"); - printf("\nRig command: "); + printf("\nRot command: "); continue; } last_was_ret = 1; @@ -489,7 +504,7 @@ void list_models() rot_load_all_backends(); - printf("Rig#\tMfg Model Vers.\n"); + printf("Rot#\tMfg Model Vers.\n"); status = rot_list_foreach(print_model_list, NULL); if (status != RIG_OK ) { printf("rot_list_foreach: error = %s \n", rigerror(status));