/* Enter the command-line interface. HEAP is used for the command-line buffer. Return only if FOREVER is nonzero and get_cmdline returns nonzero (ESC is pushed). */ void enter_cmdline (char *heap, int forever) { /* Initialize the data and print a message. */ init_cmdline (); grub_setjmp (restart_cmdline_env); init_page (); #ifdef SUPPORT_DISKLESS print_network_configuration (); grub_putchar ('\n'); #endif print_cmdline_message (forever); while (1) { struct builtin *builtin; char *arg; *heap = 0; print_error (); errnum = ERR_NONE; /* Get the command-line with the minimal BASH-like interface. */ if (get_cmdline (PACKAGE "> ", heap, 2048, 0, 1)) return; /* If there was no command, grab a new one. */ if (! heap[0]) continue; /* Find a builtin. */ builtin = find_command (heap); if (! builtin) continue; /* If BUILTIN cannot be run in the command-line, skip it. */ if (! (builtin->flags & BUILTIN_CMDLINE)) { errnum = ERR_UNRECOGNIZED; continue; } /* Invalidate the cache, because the user may exchange removable disks. */ buf_drive = -1; /* Start to count lines, only if the internal pager is in use. */ if (use_pager) count_lines = 0; /* Run BUILTIN->FUNC. */ arg = skip_to (1, heap); (builtin->func) (arg, BUILTIN_CMDLINE); /* Finish the line count. */ count_lines = -1; } }
void test::FSTestFixture::SetUp() { auto currentTest = ::testing::UnitTest::GetInstance()->current_test_info(); pushModDir(currentTest->name()); init_cmdline(); timer_init(); #ifndef NDEBUG outwnd_init(); mprintf(("TEST: Setting up test '%s.%s'\n", currentTest->test_case_name(), currentTest->name())); #endif os_init("Test", "Test"); if (_initFlags & INIT_CFILE) { SCP_string cfile_dir(TEST_DATA_PATH); cfile_dir += DIR_SEPARATOR_CHAR; cfile_dir += "test"; // Cfile expects something after the path if (cfile_init(cfile_dir.c_str())) { FAIL() << "Cfile init failed!"; } if (_initFlags & INIT_MOD_TABLE) { mod_table_init(); // load in all the mod dependent settings } lcl_init(-1); lcl_xstr_init(); if (_initFlags & INIT_MOD_TABLE) { mod_table_init(); // load in all the mod dependent settings } if (_initFlags & INIT_GRAPHICS) { if (!gr_init(nullptr, GR_STUB, 1024, 768)) { FAIL() << "Graphics init failed!"; } if (_initFlags & INIT_FONTS) { font::init(); } } if (_initFlags & INIT_SHIPS) { ship_init(); } } }
/* Run an entry from the script SCRIPT. HEAP is used for the command-line buffer. If an error occurs, return non-zero, otherwise return zero. */ int run_script (char *script, char *heap) { char *old_entry; char *cur_entry = script; /* Initialize the data. */ init_cmdline (); while (1) { struct builtin *builtin; char *arg; print_error (); if (errnum) { errnum = ERR_NONE; /* If a fallback entry is defined, don't prompt a user's intervention. */ if (fallback_entry < 0) { grub_printf ("\nPress any key to continue..."); (void) getkey (); } return 1; } /* Copy the first string in CUR_ENTRY to HEAP. */ old_entry = cur_entry; while (*cur_entry++) ; grub_memmove (heap, old_entry, (int) cur_entry - (int) old_entry); if (! *heap) { /* If there is no more command in SCRIPT... */ /* If any kernel is not loaded, just exit successfully. */ if (kernel_type == KERNEL_TYPE_NONE) return 0; /* Otherwise, the command boot is run implicitly. */ grub_memmove (heap, "boot", 5); } /* Find a builtin. */ builtin = find_command (heap); if (! builtin) { grub_printf ("%s\n", old_entry); continue; } if (! (builtin->flags & BUILTIN_NO_ECHO)) grub_printf ("%s\n", old_entry); /* If BUILTIN cannot be run in the command-line, skip it. */ if (! (builtin->flags & BUILTIN_CMDLINE)) { errnum = ERR_UNRECOGNIZED; continue; } /* Invalidate the cache, because the user may exchange removable disks. */ buf_drive = -1; /* Run BUILTIN->FUNC. */ arg = skip_to (1, heap); (builtin->func) (arg, BUILTIN_SCRIPT); } }