/* * Interactive mode */ void interact(const char *rc) { static char input[256]; /* big enough? */ #ifndef BOOT_FORTH int argc; char **argv; #endif #ifdef BOOT_FORTH bf_init((rc) ? "" : NULL); #endif if (rc == NULL) { /* Read our default configuration. */ if (include("/boot/loader.rc") != CMD_OK) include("/boot/boot.conf"); } else if (*rc != '\0') include(rc); printf("\n"); /* * Before interacting, we might want to autoboot. */ autoboot_maybe(); /* * Not autobooting, go manual */ printf("\nType '?' for a list of commands, 'help' for more detailed help.\n"); if (getenv("prompt") == NULL) setenv("prompt", "${interpret}", 1); if (getenv("interpret") == NULL) setenv("interpret", "OK", 1); for (;;) { input[0] = '\0'; prompt(); ngets(input, sizeof(input)); #ifdef BOOT_FORTH bf_vm->sourceID.i = 0; bf_run(input); #else if (!parse(&argc, &argv, input)) { if (perform(argc, argv)) printf("%s: %s\n", argv[0], command_errmsg); free(argv); } else { printf("parse error\n"); } #endif } }
/* * Interactive mode */ void interact(void) { char input[256]; /* big enough? */ int argc; char **argv; /* * We may be booting from the boot partition, or we may be booting * from the root partition with a /boot sub-directory. If the latter * chdir into /boot. Ignore any error. Only rel_open() uses the chdir * info. */ chdir("/boot"); setenv("base", DirBase, 1); /* * Read our default configuration */ if (include("dloader.rc") != CMD_OK) include("boot.conf"); printf("\n"); /* * Before interacting, we might want to autoboot. */ autoboot_maybe(); dloader_init_cmds(); /* * Not autobooting, go manual */ printf("\nType '?' for a list of commands, 'help' for more detailed help.\n"); if (getenv("prompt") == NULL) setenv("prompt", "OK", 1); for (;;) { input[0] = '\0'; prompt(); ngets(input, sizeof(input)); if (!parse(&argc, &argv, input)) { if (perform(argc, argv)) printf("%s: %s\n", argv[0], command_errmsg); free(argv); } else { printf("parse error\n"); } } }