nvtsrv: Optionally echo all input from client
This commit is contained in:
+13
-2
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
#include <poll.h>
|
||||
#include <signal.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -14,7 +15,7 @@
|
||||
|
||||
|
||||
#define HELP \
|
||||
"Usage: nvtsrv -dq\n"
|
||||
"Usage: nvtsrv -deq\n"
|
||||
|
||||
|
||||
struct {
|
||||
@@ -116,10 +117,12 @@ int main(int argc, char **argv)
|
||||
char buf[128];
|
||||
int rc, nr, i, len;
|
||||
int debug, quiet;
|
||||
bool do_echo;
|
||||
|
||||
debug = quiet = 0;
|
||||
do_echo = false;
|
||||
|
||||
while ((opt = getopt(argc, argv, "dq")) != -1)
|
||||
while ((opt = getopt(argc, argv, "deq")) != -1)
|
||||
{
|
||||
switch (opt)
|
||||
{
|
||||
@@ -129,6 +132,9 @@ int main(int argc, char **argv)
|
||||
case 'd':
|
||||
debug += 1;
|
||||
break;
|
||||
case 'e': /* Echo received data */
|
||||
do_echo = true;
|
||||
break;
|
||||
case 'q':
|
||||
quiet = 1;
|
||||
break;
|
||||
@@ -205,6 +211,11 @@ int main(int argc, char **argv)
|
||||
DBG2_BUF("Rx", buf, nr);
|
||||
len = nr;
|
||||
rc = telnet_rx(dd.tnct, buf, &len);
|
||||
if (do_echo)
|
||||
{
|
||||
/* Echo received */
|
||||
_tn_tx(NULL, buf, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user