summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sade/main.c
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1997-01-16 10:24:09 +0000
committerjkh <jkh@FreeBSD.org>1997-01-16 10:24:09 +0000
commitb5a526ab91ac8dc6d5b040394aa64dfa85a3a940 (patch)
treea8aea9644ebcfb3ee879869a388959c83e0bee35 /usr.sbin/sade/main.c
parent4a4bd14c4c5a8bd3eadd89f2fefc58ca8315b44d (diff)
downloadFreeBSD-src-b5a526ab91ac8dc6d5b040394aa64dfa85a3a940.zip
FreeBSD-src-b5a526ab91ac8dc6d5b040394aa64dfa85a3a940.tar.gz
Clean up a long-standing bug in the scripting code. You could set variables,
but you couldn't call functions! Now you can do both. Guard against whitespace pollution in variable names.
Diffstat (limited to 'usr.sbin/sade/main.c')
-rw-r--r--usr.sbin/sade/main.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/usr.sbin/sade/main.c b/usr.sbin/sade/main.c
index 36b9a73..fcf9b52 100644
--- a/usr.sbin/sade/main.c
+++ b/usr.sbin/sade/main.c
@@ -116,21 +116,19 @@ main(int argc, char **argv)
{
FILE *fp;
- Attribs *attrs;
+ char buf[BUFSIZ];
- attrs = alloca(sizeof(Attribs) * MAX_ATTRIBS);
fp = fopen("install.cfg", "r");
if (fp) {
msgNotify("Loading pre-configuration file");
- if (DITEM_STATUS(attr_parse(attrs, fp)) == DITEM_SUCCESS) {
- int i;
-
- for (i = 0; attrs[i].name; i++)
- variable_set2(attrs[i].name, attrs[i].value);
+ while (fgets(buf, sizeof buf, fp)) {
+ if (DITEM_STATUS(dispatchCommand(buf)) != DITEM_SUCCESS) {
+ msgDebug("Command `%s' failed - rest of script aborted.\n", buf);
+ break;
+ }
}
fclose(fp);
}
-
#if defined(LOAD_CONFIG_FILE)
else {
/* If we have a compiled-in startup config file name on
@@ -141,19 +139,15 @@ main(int argc, char **argv)
distWanted = (char *)1;
/* Try to open the floppy drive if we can do that first */
- if (DITEM_STATUS(mediaSetFloppy(NULL)) != DITEM_FAILURE &&
- mediaDevice->init(mediaDevice)) {
- int fd;
-
+ if (DITEM_STATUS(mediaSetFloppy(NULL)) != DITEM_FAILURE && mediaDevice->init(mediaDevice)) {
fp = mediaDevice->get(mediaDevice, LOAD_CONFIG_FILE, TRUE);
if (fp) {
- msgNotify("Loading %s pre-configuration file",
- LOAD_CONFIG_FILE);
- if (DITEM_STATUS(attr_parse(attrs, fp)) == DITEM_SUCCESS) {
- int i;
-
- for (i = 0; attrs[i].name; i++)
- variable_set2(attrs[i].name, attrs[i].value);
+ msgNotify("Loading %s pre-configuration file", LOAD_CONFIG_FILE);
+ while (fgets(buf, sizeof buf, fp)) {
+ if (DITEM_STATUS(dispatchCommand(buf)) != DITEM_SUCCESS) {
+ msgDebug("Command `%s' failed - rest of script aborted.\n", buf);
+ break;
+ }
}
fclose(fp);
}
OpenPOWER on IntegriCloud