summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2013-09-10 12:52:20 +0200
committerDaniel Lezcano <daniel.lezcano@linaro.org>2013-09-10 12:52:20 +0200
commitc56b89942afc7472e975b7ed00025cdb2e1561fc (patch)
treed7b4942baff9a15e1afbf4b152103993851416ce
parente2f72c0b96eaaba4608527e69ce878b6903328b0 (diff)
Set version option -V and version number
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rw-r--r--idlestat.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/idlestat.c b/idlestat.c
index 53f4d8b..640a690 100644
--- a/idlestat.c
+++ b/idlestat.c
@@ -18,6 +18,8 @@
#include "list.h"
#include "topology.h"
+#define IDLESTAT_VERSION "0.1"
+
static char buffer[BUFSIZE];
static inline int error(const char *str)
@@ -425,9 +427,15 @@ struct cpuidle_cstates *physical_cluster_data(struct cpu_physical *s_phy)
return result;
}
-static int help(const char *cmd)
+static void help(const char *cmd)
+{
+ fprintf(stderr, "%s [-d/--dump] [-c/--cstate=x] <file>\n", basename(cmd));
+ exit(0);
+}
+
+static void version(const char *cmd)
{
- fprintf(stderr, "%s [-d/--dump] [-c/--cstate=x] <file>\n", cmd);
+ printf("%s version %s\n", basename(cmd), IDLESTAT_VERSION);
exit(0);
}
@@ -437,6 +445,7 @@ static struct option long_options[] = {
{ "cstate", 0, 0, 'c' },
{ "debug", 0, 0, 'g' },
{ "verbose", 0, 0, 'v' },
+ { "version", 0, 0, 'V' },
{ "help", 0, 0, 'h' },
{ 0, 0, 0, 0 }
};
@@ -460,7 +469,7 @@ int getoptions(int argc, char *argv[], struct idledebug_options *options)
int optindex = 0;
- c = getopt_long(argc, argv, "gdvhi:c:t:",
+ c = getopt_long(argc, argv, "gdvVhi:c:t:",
long_options, &optindex);
if (c == -1)
break;
@@ -484,6 +493,9 @@ int getoptions(int argc, char *argv[], struct idledebug_options *options)
case 'h':
help(argv[0]);
break;
+ case 'V':
+ version(argv[0]);
+ break;
case '?':
fprintf(stderr, "%s: Unknown option %c'.\n",
argv[0], optopt);