Give ``load'' optional context. It's now possible to
``link 1,2,3 load label'' for people that want to set up their links in a more mpd-like manner.
This commit is contained in:
parent
4ea5840027
commit
3f8652a301
@ -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.141 1998/06/12 20:12:25 brian Exp $
|
||||
* $Id: command.c,v 1.142 1998/06/15 19:05:12 brian Exp $
|
||||
*
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
@ -124,7 +124,7 @@
|
||||
#define NEG_DNS 50
|
||||
|
||||
const char Version[] = "2.0-beta";
|
||||
const char VersionDate[] = "$Date: 1998/06/12 20:12:25 $";
|
||||
const char VersionDate[] = "$Date: 1998/06/15 19:05:12 $";
|
||||
|
||||
static int ShowCommand(struct cmdargs const *);
|
||||
static int TerminalCommand(struct cmdargs const *);
|
||||
@ -275,7 +275,7 @@ LoadCommand(struct cmdargs const *arg)
|
||||
* we handle nested `load' commands.
|
||||
*/
|
||||
bundle_SetLabel(arg->bundle, arg->argc > arg->argn ? name : NULL);
|
||||
if (system_Select(arg->bundle, name, CONFFILE, arg->prompt) < 0) {
|
||||
if (system_Select(arg->bundle, name, CONFFILE, arg->prompt, arg->cx) < 0) {
|
||||
bundle_SetLabel(arg->bundle, NULL);
|
||||
log_Printf(LogWARN, "%s: label not found.\n", name);
|
||||
return -1;
|
||||
@ -467,7 +467,7 @@ static struct cmdtab const Commands[] = {
|
||||
"Enable option", "enable option .."},
|
||||
{"link", "datalink", LinkCommand, LOCAL_AUTH,
|
||||
"Link specific commands", "link name command ..."},
|
||||
{"load", NULL, LoadCommand, LOCAL_AUTH,
|
||||
{"load", NULL, LoadCommand, LOCAL_AUTH | LOCAL_CX_OPT,
|
||||
"Load settings", "load [remote]"},
|
||||
{"open", NULL, OpenCommand, LOCAL_AUTH | LOCAL_CX_OPT,
|
||||
"Open an FSM", "open [lcp|ccp]"},
|
||||
@ -750,7 +750,7 @@ arghidden(int argc, char const *const *argv, int n)
|
||||
|
||||
void
|
||||
command_Run(struct bundle *bundle, int argc, char const *const *argv,
|
||||
struct prompt *prompt, const char *label)
|
||||
struct prompt *prompt, const char *label, struct datalink *cx)
|
||||
{
|
||||
if (argc > 0) {
|
||||
if (log_IsKept(LogCOMMAND)) {
|
||||
@ -775,7 +775,7 @@ command_Run(struct bundle *bundle, int argc, char const *const *argv,
|
||||
}
|
||||
log_Printf(LogCOMMAND, "%s\n", buf);
|
||||
}
|
||||
FindExec(bundle, Commands, argc, 0, argv, prompt, NULL);
|
||||
FindExec(bundle, Commands, argc, 0, argv, prompt, cx);
|
||||
}
|
||||
}
|
||||
|
||||
@ -787,7 +787,7 @@ command_Decode(struct bundle *bundle, char *buff, int nb, struct prompt *prompt,
|
||||
char **argv;
|
||||
|
||||
command_Interpret(buff, nb, &argc, &argv);
|
||||
command_Run(bundle, argc, (char const *const *)argv, prompt, label);
|
||||
command_Run(bundle, argc, (char const *const *)argv, prompt, label, NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -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.12.2.13 1998/05/01 19:24:18 brian Exp $
|
||||
* $Id: command.h,v 1.13 1998/05/21 21:44:48 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -56,7 +56,7 @@ extern const char VersionDate[];
|
||||
|
||||
extern void command_Interpret(char *, int, int *, char ***);
|
||||
extern void command_Run(struct bundle *, int, char const *const *,
|
||||
struct prompt *, const char *);
|
||||
struct prompt *, const char *, struct datalink *);
|
||||
extern void command_Decode(struct bundle *, char *, int, struct prompt *,
|
||||
const char *);
|
||||
extern struct link *command_ChooseLink(struct cmdargs const *);
|
||||
|
@ -17,7 +17,7 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: ipcp.c,v 1.53 1998/05/29 18:32:11 brian Exp $
|
||||
* $Id: ipcp.c,v 1.54 1998/06/12 17:45:10 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
* o More RFC1772 backwoard compatibility
|
||||
@ -676,13 +676,13 @@ IpcpLayerDown(struct fsm *fp)
|
||||
* XXX this stuff should really live in the FSM. Our config should
|
||||
* associate executable sections in files with events.
|
||||
*/
|
||||
if (system_Select(fp->bundle, s, LINKDOWNFILE, NULL) < 0) {
|
||||
if (system_Select(fp->bundle, s, LINKDOWNFILE, NULL, NULL) < 0) {
|
||||
if (bundle_GetLabel(fp->bundle)) {
|
||||
if (system_Select(fp->bundle, bundle_GetLabel(fp->bundle),
|
||||
LINKDOWNFILE, NULL) < 0)
|
||||
system_Select(fp->bundle, "MYADDR", LINKDOWNFILE, NULL);
|
||||
LINKDOWNFILE, NULL, NULL) < 0)
|
||||
system_Select(fp->bundle, "MYADDR", LINKDOWNFILE, NULL, NULL);
|
||||
} else
|
||||
system_Select(fp->bundle, "MYADDR", LINKDOWNFILE, NULL);
|
||||
system_Select(fp->bundle, "MYADDR", LINKDOWNFILE, NULL, NULL);
|
||||
}
|
||||
|
||||
if (!(ipcp->fsm.bundle->phys_type.all & PHYS_AUTO))
|
||||
@ -726,14 +726,14 @@ IpcpLayerUp(struct fsm *fp)
|
||||
* XXX this stuff should really live in the FSM. Our config should
|
||||
* associate executable sections in files with events.
|
||||
*/
|
||||
if (system_Select(fp->bundle, inet_ntoa(ipcp->my_ifip), LINKUPFILE, NULL)
|
||||
< 0) {
|
||||
if (system_Select(fp->bundle, inet_ntoa(ipcp->my_ifip), LINKUPFILE,
|
||||
NULL, NULL) < 0) {
|
||||
if (bundle_GetLabel(fp->bundle)) {
|
||||
if (system_Select(fp->bundle, bundle_GetLabel(fp->bundle),
|
||||
LINKUPFILE, NULL) < 0)
|
||||
system_Select(fp->bundle, "MYADDR", LINKUPFILE, NULL);
|
||||
LINKUPFILE, NULL, NULL) < 0)
|
||||
system_Select(fp->bundle, "MYADDR", LINKUPFILE, NULL, NULL);
|
||||
} else
|
||||
system_Select(fp->bundle, "MYADDR", LINKUPFILE, NULL);
|
||||
system_Select(fp->bundle, "MYADDR", LINKUPFILE, NULL, NULL);
|
||||
}
|
||||
|
||||
throughput_start(&ipcp->throughput, "IPCP throughput",
|
||||
|
@ -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.130 1998/06/06 20:50:57 brian Exp $
|
||||
* $Id: main.c,v 1.131 1998/06/15 19:05:22 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -324,7 +324,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
SignalBundle = bundle;
|
||||
|
||||
if (system_Select(bundle, "default", CONFFILE, prompt) < 0)
|
||||
if (system_Select(bundle, "default", CONFFILE, prompt, NULL) < 0)
|
||||
prompt_Printf(prompt, "Warning: No default entry found in config file.\n");
|
||||
|
||||
sig_signal(SIGHUP, CloseSession);
|
||||
@ -347,7 +347,7 @@ main(int argc, char **argv)
|
||||
* commands.
|
||||
*/
|
||||
bundle_SetLabel(bundle, label);
|
||||
if (system_Select(bundle, label, CONFFILE, prompt) < 0) {
|
||||
if (system_Select(bundle, label, CONFFILE, prompt, NULL) < 0) {
|
||||
prompt_Printf(prompt, "Destination system (%s) not found.\n", label);
|
||||
AbortProgram(EX_START);
|
||||
}
|
||||
|
@ -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.35.2.10 1998/05/15 23:58:29 brian Exp $
|
||||
* $Id: systems.c,v 1.36 1998/05/21 21:48:33 brian Exp $
|
||||
*
|
||||
* TODO:
|
||||
*/
|
||||
@ -243,7 +243,7 @@ xgets(char *buf, int buflen, FILE *fp)
|
||||
|
||||
static int
|
||||
ReadSystem(struct bundle *bundle, const char *name, const char *file,
|
||||
int doexec, struct prompt *prompt)
|
||||
int doexec, struct prompt *prompt, struct datalink *cx)
|
||||
{
|
||||
FILE *fp;
|
||||
char *cp, *wp;
|
||||
@ -284,7 +284,7 @@ ReadSystem(struct bundle *bundle, const char *name, const char *file,
|
||||
switch (DecodeCtrlCommand(cp+1, arg)) {
|
||||
case CTRL_INCLUDE:
|
||||
log_Printf(LogCOMMAND, "%s: Including \"%s\"\n", filename, arg);
|
||||
n = ReadSystem(bundle, name, arg, doexec, prompt);
|
||||
n = ReadSystem(bundle, name, arg, doexec, prompt, cx);
|
||||
log_Printf(LogCOMMAND, "%s: Done include of \"%s\"\n", filename, arg);
|
||||
if (!n)
|
||||
return 0; /* got it */
|
||||
@ -322,7 +322,8 @@ ReadSystem(struct bundle *bundle, const char *name, const char *file,
|
||||
command_Interpret(cp, len, &argc, &argv);
|
||||
allowcmd = argc > 0 && !strcasecmp(*argv, "allow");
|
||||
if ((!doexec && allowcmd) || (doexec && !allowcmd))
|
||||
command_Run(bundle, argc, (char const *const *)argv, prompt, name);
|
||||
command_Run(bundle, argc, (char const *const *)argv, prompt,
|
||||
name, cx);
|
||||
}
|
||||
|
||||
fclose(fp); /* everything read - get out */
|
||||
@ -347,17 +348,17 @@ system_IsValid(const char *name, struct prompt *prompt, int mode)
|
||||
userok = 0;
|
||||
modeok = 1;
|
||||
modereq = mode;
|
||||
ReadSystem(NULL, "default", CONFFILE, 0, prompt);
|
||||
ReadSystem(NULL, "default", CONFFILE, 0, prompt, NULL);
|
||||
if (name != NULL)
|
||||
ReadSystem(NULL, name, CONFFILE, 0, prompt);
|
||||
ReadSystem(NULL, name, CONFFILE, 0, prompt, NULL);
|
||||
return userok && modeok;
|
||||
}
|
||||
|
||||
int
|
||||
system_Select(struct bundle *bundle, const char *name, const char *file,
|
||||
struct prompt *prompt)
|
||||
struct prompt *prompt, struct datalink *cx)
|
||||
{
|
||||
userok = modeok = 1;
|
||||
modereq = PHYS_ALL;
|
||||
return ReadSystem(bundle, name, file, 1, prompt);
|
||||
return ReadSystem(bundle, name, file, 1, prompt, cx);
|
||||
}
|
||||
|
@ -17,16 +17,17 @@
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*
|
||||
* $Id: systems.h,v 1.10.2.6 1998/05/15 23:58:30 brian Exp $
|
||||
* $Id: systems.h,v 1.11 1998/05/21 21:48:36 brian Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
struct prompt;
|
||||
struct datalink;
|
||||
struct bundle;
|
||||
struct cmdargs;
|
||||
|
||||
extern int system_Select(struct bundle *bundle, const char *, const char *,
|
||||
struct prompt *);
|
||||
struct prompt *, struct datalink *);
|
||||
extern int system_IsValid(const char *, struct prompt *, int);
|
||||
extern FILE *OpenSecret(const char *);
|
||||
extern void CloseSecret(FILE *);
|
||||
|
Loading…
Reference in New Issue
Block a user