int Stat_Command(char **argv, // IN: Command line arguments int argc, // IN: Length of command line arguments gboolean quiet) // IN { if (toolbox_strcmp(argv[optind], "hosttime") == 0) { return StatHostTime(); } else if (toolbox_strcmp(argv[optind], "sessionid") == 0) { return StatGetSessionID(); } else if (toolbox_strcmp(argv[optind], "balloon") == 0) { return StatGetMemoryBallooned(); } else if (toolbox_strcmp(argv[optind], "swap") == 0) { return StatGetMemorySwapped(); } else if (toolbox_strcmp(argv[optind], "memlimit") == 0) { return StatGetMemoryLimit(); } else if (toolbox_strcmp(argv[optind], "memres") == 0) { return StatGetMemoryReservation(); } else if (toolbox_strcmp(argv[optind], "cpures") == 0) { return StatGetCpuReservation(); } else if (toolbox_strcmp(argv[optind], "cpulimit") == 0) { return StatGetCpuLimit(); } else if (toolbox_strcmp(argv[optind], "speed") == 0) { return StatProcessorSpeed(); } else if (toolbox_strcmp(argv[optind], "raw") == 0) { return StatGetRaw((optind + 1 < argc) ? argv[optind + 1] : "", // encoding (optind + 2 < argc) ? argv[optind + 2] : "", // stat (optind + 3 < argc) ? argv[optind + 3] : "");// param } else { ToolsCmd_UnknownEntityError(argv[0], SU_(arg.subcommand, "subcommand"), argv[optind]); return EX_USAGE; } }
static const char * GetConfName(const char *apm) // IN: apm name. { if (toolbox_strcmp(apm, SCRIPT_SUSPEND) == 0) { return CONFNAME_SUSPENDSCRIPT; } else if (toolbox_strcmp(apm, SCRIPT_RESUME) == 0) { return CONFNAME_RESUMESCRIPT; } else if (toolbox_strcmp(apm, SCRIPT_OFF) == 0) { return CONFNAME_POWEROFFSCRIPT; } else if (toolbox_strcmp(apm, SCRIPT_ON) == 0) { return CONFNAME_POWERONSCRIPT; } else { return NULL; } }
static int HelpCommand(char **argv, // IN: Command line arguments int argc, // IN: Length of argv gboolean quiet) // IN { int retval = EXIT_SUCCESS; if (++optind < argc) { int i; for (i = 0; i < ARRAYSIZE(commands); i++) { if (toolbox_strcmp(commands[i].command, argv[optind]) == 0) { commands[i].helpFunc(argv[0], commands[i].command); return EXIT_SUCCESS; } } ToolsCmd_UnknownEntityError(argv[0], SU_(arg.subcommand, "subcommand"), argv[optind]); retval = EX_USAGE; } ToolboxCmdHelp(argv[0], argv[optind - 1]); return retval; }
int Script_Command(char **argv, // IN: command line arguments. int argc, // IN: the length of the command line arguments. gboolean quiet) // IN { const char *apm; if (++optind >= argc) { ToolsCmd_MissingEntityError(argv[0], SU_(arg.scripttype, "script type")); return EX_USAGE; } apm = argv[optind++]; if (!ScriptCheckName(apm)) { ToolsCmd_UnknownEntityError(argv[0], SU_(arg.scripttype, "script type"), apm); return EX_USAGE; } if (optind >= argc) { ToolsCmd_MissingEntityError(argv[0], SU_(arg.subcommand, "subcommand")); return EX_USAGE; } if (toolbox_strcmp(argv[optind], "default") == 0) { return ScriptGetDefault(argv[0], apm); } else if (toolbox_strcmp(argv[optind], "current") == 0) { return ScriptGetCurrent(argv[0], apm); } else if (toolbox_strcmp(argv[optind], "set") == 0) { if (++optind >= argc) { ToolsCmd_MissingEntityError(argv[0], SU_(arg.scriptpath, "script path")); return EX_USAGE; } return ScriptSet(argv[0], apm, argv[optind]); } else if (toolbox_strcmp(argv[optind], "enable") == 0) { return ScriptToggle(argv[0], apm, TRUE); } else if (toolbox_strcmp(argv[optind], "disable") == 0) { return ScriptToggle(argv[0], apm, FALSE); } else { ToolsCmd_UnknownEntityError(argv[0], SU_(arg.subcommand, "subcommand"), argv[optind]); return EX_USAGE; } }
int TimeSync_Command(char **argv, // IN: command line arguments int argc, // IN: The length of the command line arguments gboolean quiet) // IN { if (toolbox_strcmp(argv[optind], "enable") == 0) { return TimeSyncEnable(); } else if (toolbox_strcmp(argv[optind], "disable") == 0) { return TimeSyncDisable(); } else if (toolbox_strcmp(argv[optind], "status") == 0) { return TimeSyncStatus(); } else { ToolsCmd_UnknownEntityError(argv[0], SU_(arg.subcommand, "subcommand"), argv[optind]); return EX_USAGE; } }
static CmdTable * ParseCommand(char **argv, // IN: Command line arguments int argc) // IN: Length of command line arguments { int i; for (i = 0; i < ARRAYSIZE(commands); i++) { if (toolbox_strcmp(commands[i].command, argv[optind]) == 0) { return &commands[i]; } } return NULL; }