26 #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
62 printf(
_(
"Usage:\tcpupower [-d|--debug] [-c|--cpu cpulist ] <command> [<args>]\n"));
64 printf(
_(
"Usage:\tcpupower [-c|--cpu cpulist ] <command> [<args>]\n"));
66 printf(
_(
"Supported commands are:\n"));
69 printf(
_(
"\nNot all commands can make use of the -c cpulist option.\n"));
70 printf(
_(
"\nUse 'cpupower help <command>' for getting help for above commands.\n"));
73 static int print_man_page(
const char *subpage)
87 if ((subpage !=
NULL) &&
strcmp(subpage,
"help")) {
92 execlp(
"man",
"man", page,
NULL);
101 print_man_page(argv[1]);
109 static void print_version(
void)
112 printf(
_(
"Report errors and bugs to %s, please.\n"), PACKAGE_BUGREPORT);
115 static void handle_options(
int *argc,
const char ***argv)
117 int ret,
x, new_argc = 0;
122 for (x = 0; x < *argc && ((*argv)[
x])[0] ==
'-'; x++) {
123 const char *
param = (*argv)[
x];
127 }
else if (!
strcmp(param,
"-c") || !
strcmp(param,
"--cpu")) {
132 if (!
strcmp((*argv)[x+1],
"all"))
136 (*argv)[x+1], cpus_chosen);
138 fprintf(stderr,
_(
"Error parsing cpu "
147 }
else if (!
strcmp(param,
"-v") ||
148 !
strcmp(param,
"--version")) {
152 }
else if (!
strcmp(param,
"-d") || !
strcmp(param,
"--debug")) {
158 fprintf(stderr,
"Unknown option: %s\n", param);
167 int main(
int argc,
const char *argv[])
177 handle_options(&argc, &argv);
186 setlocale(LC_ALL,
"");
190 if (argc > 1 && !
strcmp(argv[1],
"--help")) {
192 argv[0] = cmd =
"help";
203 fprintf(stderr,
_(
"Subcommand %s needs root "
204 "privileges\n"), cmd);
207 ret = p->
main(argc, argv);