Backout my previous commit, it appearantly doesn't work for asynchronous

messages.
This commit is contained in:
Poul-Henning Kamp 2001-03-17 08:59:31 +00:00
parent 49519c9bfb
commit 0c5c7719e6
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=74383
3 changed files with 8 additions and 55 deletions

View File

@ -6,7 +6,7 @@ SRCS= main.c mkpeer.c config.c connect.c name.c show.c list.c \
msg.c debug.c shutdown.c rmhook.c status.c types.c
MAN8= ngctl.8
DPADD+= ${LIBNETGRAPH}
LDADD+= -lnetgraph -ledit
LDADD+= -lnetgraph
COPTS+= -Wall
.include <bsd.prog.mk>

View File

@ -39,27 +39,23 @@
*/
#include "ngctl.h"
#include <histedit.h>
#define PROMPT "+ "
#define MAX_ARGS 512
#define WHITESPACE " \t\r\n\v\f"
#define DUMP_BYTES_PER_LINE 16
#define HISTSIZE 100
/* Internal functions */
static int ReadFile(FILE *fp);
static int DoParseCommand(char *line);
static int DoCommand(int ac, char **av);
static int DoInteractive(void);
static int DoEditLine(void);
static const struct ngcmd *FindCommand(const char *string);
static int MatchCommand(const struct ngcmd *cmd, const char *s);
static void Usage(const char *msg);
static int ReadCmd(int ac, char **av);
static int HelpCmd(int ac, char **av);
static int QuitCmd(int ac, char **av);
static char * prompt(EditLine *el);
/* List of commands */
static const struct ngcmd *const cmds[] = {
@ -107,18 +103,6 @@ const struct ngcmd quit_cmd = {
/* Our control and data sockets */
int csock, dsock;
/* Provide editline(3) functionality */
static EditLine *el = NULL;
/*
* EL_PROMPT expects a function for the prompt
*/
static char *
prompt(EditLine *el)
{
return PROMPT;
}
/*
* main()
*/
@ -268,7 +252,13 @@ DoInteractive(void)
/* Get any user input */
if (FD_ISSET(0, &rfds)) {
if (DoEditLine() == CMDRTN_QUIT)
char buf[LINE_MAX];
if (fgets(buf, sizeof(buf), stdin) == NULL) {
printf("\n");
break;
}
if (DoParseCommand(buf) == CMDRTN_QUIT)
break;
}
}
@ -311,42 +301,6 @@ DoCommand(int ac, char **av)
return(rtn);
}
/*
* Handle user input with editline(3)
*/
static int
DoEditLine(void)
{
int num;
char *av = "ngctl";
const char *buf;
History *hist;
hist = history_init(); /* Initialize history */
history(hist, H_EVENT, HISTSIZE); /* Size of history */
el = el_init(av, stdin, stdout); /* Initialize editline */
el_set(el, EL_PROMPT, prompt); /* Set the prompt */
el_set(el, EL_EDITOR, "vi"); /* Default editor is vi */
el_set(el, EL_HIST, history, hist); /* Use history */
el_set(el, EL_SIGNAL, 1); /* Handle signals properly */
el_source(el, NULL); /* Source user defaults */
while ((buf = el_gets(el, &num)) != NULL && num != 0) {
history(hist, H_ENTER, buf); /* Add command to history */
if (DoParseCommand((char *)buf) == CMDRTN_QUIT)
return (CMDRTN_QUIT); /* Handle "quit" command */
}
el_end(el); /* Clean up editline */
history_end(hist); /* and history */
return 0;
}
/*
* Find a command
*/

View File

@ -75,7 +75,6 @@ struct ngcmd {
#define CMDRTN_QUIT 3
/* Available commands */
extern const struct ngcmd config_cmd;
extern const struct ngcmd connect_cmd;
extern const struct ngcmd debug_cmd;
extern const struct ngcmd help_cmd;