void cmd_help(int argc, char** argv) { OIBCommandIterator it = NULL; OPIBCommand *cmd; while((cmd = command_get_next(&it))) bufferPrintf("%-20s%s\r\n", cmd->name, cmd->description); }
static void ask_to_wipe_boot_sector(struct i_fn_args *a, struct commands *fcmds) { struct commands *cmds; struct command *cmd; char *disk; for (cmd = command_get_first(fcmds); cmd != NULL; cmd = command_get_next(cmd)) { disk = command_get_tag(cmd); if (disk != NULL && command_get_result(cmd) > 0 && command_get_result(cmd) < 256) { switch (dfui_be_present_dialog(a->c, _("Bootblock Install Failed"), _("Re-Initialize Bootblock|Cancel"), _("Warning: bootblocks were not successfully " "installed on the disk `%s'. This may be " "because the disk is new and not yet " "formatted. If this is the case, it might " "help to re-initialize the boot sector, " "then try installing the bootblock again. " "Note that this should not affect the " "partition table of the disk."), disk)) { case 1: cmds = commands_new(); command_add(cmds, "%s%s | %s%s -B /dev/%s", a->os_root, cmd_name(a, "YES"), a->os_root, cmd_name(a, "FDISK"), disk); if (commands_execute(a, cmds)) { inform(a->c, _("Boot sector successfully initialized.")); } else { inform(a->c, _("Some errors occurred. " "Boot sector was not successfully initialized.")); } commands_free(cmds); break; default: break; } } } }
int command_run(int argc, char **argv) { OIBCommandIterator cmdIt = NULL; OPIBCommand *cmd; if(*argv[0] == 0) return 0; // Hack to prevent empty lines erroring out. while((cmd = command_get_next(&cmdIt))) { if(strcmp(argv[0], cmd->name) == 0) { cmd->routine(argc, argv); return 0; } } return -1; }