aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorBrian Somers <brian@FreeBSD.org>1997-11-13 14:43:20 +0000
committerBrian Somers <brian@FreeBSD.org>1997-11-13 14:43:20 +0000
commitd9181b051285b6e652b845ea3b1b477d5746d744 (patch)
tree12563683fb7df6a3ca93f1424f0cbd91a7d9d120 /usr.sbin
parent04da22ce2db9bce2a769dde02f195a4b14e4273c (diff)
Notes
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/ppp/command.c32
-rw-r--r--usr.sbin/ppp/command.h6
-rw-r--r--usr.sbin/ppp/main.c13
-rw-r--r--usr.sbin/ppp/systems.c5
4 files changed, 33 insertions, 23 deletions
diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c
index 025fda01de61..5156962ac753 100644
--- a/usr.sbin/ppp/command.c
+++ b/usr.sbin/ppp/command.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: command.c,v 1.100 1997/11/12 16:34:50 brian Exp $
+ * $Id: command.c,v 1.101 1997/11/12 18:47:28 brian Exp $
*
*/
#include <sys/param.h>
@@ -707,23 +707,39 @@ InterpretCommand(char *buff, int nb, int *argc, char ***argv)
}
void
-RunCommand(int argc, char **argv, int prompt)
+RunCommand(int argc, char **argv, const char *label)
{
- if (argc > 0)
- FindExec(Commands, argc, argv);
+ if (argc > 0) {
+ if (LogIsKept(LogCOMMAND)) {
+ static char buf[LINE_LEN];
+ int f, n;
- if (prompt)
- Prompt();
+ *buf = '\0';
+ if (label) {
+ strcpy(buf, label);
+ strcat(buf, ": ");
+ }
+ n = strlen(buf);
+ for (f = 0; f < argc; f++) {
+ if (n < sizeof(buf)-1 && f)
+ buf[n++] = ' ';
+ strncpy(buf+n, argv[f], sizeof(buf)-n-1);
+ n += strlen(buf+n);
+ }
+ LogPrintf(LogCOMMAND, "%s\n", buf);
+ }
+ FindExec(Commands, argc, argv);
+ }
}
void
-DecodeCommand(char *buff, int nb, int prompt)
+DecodeCommand(char *buff, int nb, const char *label)
{
int argc;
char **argv;
InterpretCommand(buff, nb, &argc, &argv);
- RunCommand(argc, argv, prompt);
+ RunCommand(argc, argv, label);
}
static int
diff --git a/usr.sbin/ppp/command.h b/usr.sbin/ppp/command.h
index 37eddc440b3d..16954eedefd2 100644
--- a/usr.sbin/ppp/command.h
+++ b/usr.sbin/ppp/command.h
@@ -15,7 +15,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: command.h,v 1.9 1997/11/04 01:17:00 brian Exp $
+ * $Id: command.h,v 1.10 1997/11/11 22:58:10 brian Exp $
*
* TODO:
*/
@@ -49,5 +49,5 @@ extern int SetVariable(struct cmdtab const *, int, char **, int);
extern void Prompt(void);
extern int IsInteractive(int);
extern void InterpretCommand(char *, int, int *, char ***);
-extern void RunCommand(int, char **, int);
-extern void DecodeCommand(char *, int, int);
+extern void RunCommand(int, char **, const char *label);
+extern void DecodeCommand(char *, int, const char *label);
diff --git a/usr.sbin/ppp/main.c b/usr.sbin/ppp/main.c
index 0da1bf59b331..abe04a395b0d 100644
--- a/usr.sbin/ppp/main.c
+++ b/usr.sbin/ppp/main.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: main.c,v 1.94 1997/11/13 12:09:53 brian Exp $
+ * $Id: main.c,v 1.95 1997/11/13 12:10:50 brian Exp $
*
* TODO:
* o Add commands for traffic summary, version display, etc.
@@ -562,14 +562,9 @@ ReadTty()
aft_cmd = 1;
if (linebuff[n-1] == '\n')
linebuff[--n] = '\0';
- if (n) {
- if (IsInteractive(0))
- LogPrintf(LogCOMMAND, "%s\n", linebuff);
- else
- LogPrintf(LogCOMMAND, "Client: %s\n", linebuff);
- DecodeCommand(linebuff, n, 1);
- } else
- Prompt();
+ if (n)
+ DecodeCommand(linebuff, n, IsInteractive(0) ? NULL : "Client");
+ Prompt();
} else {
LogPrintf(LogPHASE, "client connection closed.\n");
oVarTerm = VarTerm;
diff --git a/usr.sbin/ppp/systems.c b/usr.sbin/ppp/systems.c
index b7ed109a6f12..53ad8de86d47 100644
--- a/usr.sbin/ppp/systems.c
+++ b/usr.sbin/ppp/systems.c
@@ -17,7 +17,7 @@
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
- * $Id: systems.c,v 1.24 1997/11/12 15:50:38 brian Exp $
+ * $Id: systems.c,v 1.25 1997/11/12 16:34:51 brian Exp $
*
* TODO:
*/
@@ -298,11 +298,10 @@ ReadSystem(const char *name, const char *file, int doexec)
InterpretCommand(cp, len, &argc, &argv);
allowcmd = argc > 0 && !strcasecmp(*argv, "allow");
if ((!doexec && allowcmd) || (doexec && !allowcmd)) {
- LogPrintf(LogCOMMAND, "%s: %s\n", name, cp);
olauth = VarLocalAuth;
if (VarLocalAuth == LOCAL_NO_AUTH)
VarLocalAuth = LOCAL_AUTH;
- RunCommand(argc, argv, 0);
+ RunCommand(argc, argv, name);
VarLocalAuth = olauth;
}
} else if (*cp == '#') {