int main(const int argc, const char *argv[]) { char version_string[256]; static struct s_hardware hardware; snprintf(version_string, sizeof version_string, "%s %s (%s)", PRODUCT_NAME, VERSION, CODENAME); /* Cleaning structures */ init_hardware(&hardware); /* Detecting Syslinux version */ detect_syslinux(&hardware); /* Detecting parameters */ detect_parameters(argc, argv, &hardware); /* Opening the Syslinux console */ init_console(&hardware); /* Detect hardware */ detect_hardware(&hardware); /* Clear the screen and reset position of the cursor */ clear_screen(); printf("\033[1;1H"); more_printf("%s\n", version_string); int return_code = 0; if (!menumode || automode) start_cli_mode(&hardware); else { return_code = start_menu_mode(&hardware, version_string); if (return_code == HDT_RETURN_TO_CLI) start_cli_mode(&hardware); } /* Do we got request to do something at exit time ? */ if (strlen(hardware.postexec)>0) { more_printf("Executing postexec instructions : %s\n",hardware.postexec); runsyslinuxcmd(hardware.postexec); } return return_code; }
int start_menu_mode(struct s_hardware *hardware, char *version_string) { struct s_hdt_menu hdt_menu; memset(&hdt_menu, 0, sizeof(hdt_menu)); /* Detect every kind of hardware */ detect_hardware(hardware); /* Setup the menu system */ setup_menu(version_string); /* Compute all submenus */ compute_submenus(&hdt_menu, hardware); /* Compute the main menu */ compute_main_menu(&hdt_menu, hardware); #ifdef WITH_MENU_DISPLAY t_menuitem *curr; char cmd[160]; if (!quiet) more_printf("Starting Menu (%d menus)\n", hdt_menu.total_menu_count); curr = showmenus(hdt_menu.main_menu.menu); /* When we exit the menu, do we have something to do? */ if (curr) { /* When want to execute something */ if (curr->action == OPT_RUN) { /* Tweak, we want to switch to the cli */ if (!strncmp (curr->data, HDT_SWITCH_TO_CLI, sizeof(HDT_SWITCH_TO_CLI))) { return HDT_RETURN_TO_CLI; } strcpy(cmd, curr->data); /* Use specific syslinux call if needed */ if (issyslinux()) runsyslinuxcmd(cmd); else csprint(cmd, 0x07); return 1; // Should not happen when run from SYSLINUX } } #endif return 0; }