Commit 0aea6955 authored by Adam Wujek's avatar Adam Wujek 💬

tools: add printing version of repo

with -V switch
Signed-off-by: Adam Wujek's avatarAdam Wujek <adam.wujek@cern.ch>
parent 07da0470
......@@ -2,6 +2,8 @@
# build user-space tools for zio
CFLAGS = -I$(M)/include/ -Wall $(ZIO_VERSION) $(EXTRACFLAGS)
CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
CC ?= $(CROSS_COMPILE)gcc
progs := zio-dump
......
......@@ -15,6 +15,8 @@
#include <linux/zio-user.h>
static char git_version[] = "version: " GIT_VERSION;
#define FNAME "/dev/zdtc-0000-0-0-ctrl"
void help(char *name)
......@@ -25,10 +27,17 @@ void help(char *name)
" -f <file> default: %s\n"
" -t <time> default: \"1.5\" (see code for details)\n"
" -p <period> default: \"0\"\n"
" -n <number> default: infinite\n", FNAME);
" -n <number> default: infinite\n"
" -v increase verbosity\n"
" -V print version information \n", FNAME);
exit(1);
}
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
}
/* Boring parsing separated to a separate function (same code as elsewhere) */
static int parse_ts(char *s, struct timespec *ts)
{
......@@ -77,7 +86,7 @@ int main(int argc, char **argv)
struct timespec period = {0, 0};
/* -f <filename> -t <[+][secs].frac> -p <.frac> -v */
while ((i = getopt (argc, argv, "f:t:p:n:v")) != -1) {
while ((i = getopt (argc, argv, "f:t:p:n:vV")) != -1) {
switch(i) {
case 'f':
fname = optarg;
......@@ -94,6 +103,9 @@ int main(int argc, char **argv)
case 'v':
verbose++;
break;
case 'V':
print_version(argv[0]);
exit(0);
default:
help(argv[0]);
}
......
......@@ -17,8 +17,15 @@
#include <linux/zio-user.h>
static char git_version[] = "version: " GIT_VERSION;
#define VERBOSE 0
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
}
int main(int argc, char **argv)
{
int cfd; /* control file descriptor */
......@@ -33,10 +40,15 @@ int main(int argc, char **argv)
void *map,*ptr;
struct timeval tv1, tv2;
if ((argc == 2) && (!strcmp(argv[1], "-V"))) {
print_version(argv[0]);
exit(0);
}
if (argc != 3) {
fprintf(stderr, "%s: Wrong number of arguments\n"
"Use: \"%s <data-file> <nblocks>\"\n",
argv[0], argv[0]);
fprintf(stderr, "Or -V for version details\n");
exit(1);
}
nblocks = atoi(argv[2]);
......
......@@ -15,6 +15,8 @@
#include <linux/zio-user.h>
static char git_version[] = "version: " GIT_VERSION;
unsigned char buf[1024*1024];
char *prgname;
int opt_print_attr;
......@@ -222,10 +224,16 @@ void help(char *name)
" -s sniff-device (array of controls)\n"
" -m print memory address (for mmap)\n"
" -n <number> stop after that many blocks\n"
" -r <number> shown bytes at buffer begin/end\n");
" -r <number> shown bytes at buffer begin/end\n"
" -V print version information \n");
exit(1);
}
static void print_version(char *pname)
{
printf("%s %s\n", pname, git_version);
}
int main(int argc, char **argv)
{
FILE *f;
......@@ -240,7 +248,7 @@ int main(int argc, char **argv)
prgname = argv[0];
while ((c = getopt (argc, argv, "aAcsmn:r:")) != -1) {
while ((c = getopt (argc, argv, "aAcsmn:r:V")) != -1) {
switch(c) {
case 'a':
opt_print_attr = 1;
......@@ -274,6 +282,9 @@ int main(int argc, char **argv)
help(prgname);
}
break;
case 'V':
print_version(argv[0]);
exit(0);
default:
help(prgname);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment