aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2013-10-15 20:07:26 +0300
committerSergey Poznyakoff <gray@gnu.org.ua>2013-10-15 20:07:26 +0300
commit7d0beb6599c53544739409ca4aec104bf27a3f35 (patch)
treeb561fbba7c9acedec17cbc398cee12a465faad6e /src
parentef3f928cc712f6774e19f8cb8f880cbeac15e8ff (diff)
downloadvmod-binlog-7d0beb6599c53544739409ca4aec104bf27a3f35.tar.gz
vmod-binlog-7d0beb6599c53544739409ca4aec104bf27a3f35.tar.bz2
Add version and help output to command line utilities.
Diffstat (limited to 'src')
-rw-r--r--src/binlogcat.c20
-rw-r--r--src/binlogsel.c33
-rw-r--r--src/err.c9
-rw-r--r--src/err.h1
4 files changed, 55 insertions, 8 deletions
diff --git a/src/binlogcat.c b/src/binlogcat.c
index 656d8f2..ada8efe 100644
--- a/src/binlogcat.c
+++ b/src/binlogcat.c
@@ -140,7 +140,20 @@ catlog(const char *fname)
void
help()
{
- printf("usage: %s [-dhnv] [-t FORMAT] [FILE...]\n", progname);
+ printf("usage: %s [-dhnVv] [-t FORMAT] [FILE...]\n", progname);
+ printf("Format binary log files in human-readable form\n");
+ printf("\nOptions are:\n\n");
+ printf(" -d print timestamps relative to first record in the file\n");
+ printf(" -n output record numbers\n");
+ printf(" -v print information about each file\n");
+ printf(" -t FORMAT format timestamps according to FORMAT\n");
+ printf("\n");
+ printf(" -h print this help summary\n");
+ printf(" -V show program version\n");
+ printf("\n");
+ printf("Report bugs and suggestions to <%s>\n", PACKAGE_BUGREPORT);
+ if (sizeof(PACKAGE_URL) > 1)
+ printf("%s home page: <%s>\n", PACKAGE_NAME, PACKAGE_URL);
}
int
@@ -149,7 +162,7 @@ main(int argc, char **argv)
int c;
setprogname(argv[0]);
- while ((c = getopt(argc, argv, "dht:nv")) != EOF)
+ while ((c = getopt(argc, argv, "dht:nVv")) != EOF)
switch (c) {
case 'd':
timediff_option = 1;
@@ -164,6 +177,9 @@ main(int argc, char **argv)
case 'n':
number_option = 1;
break;
+ case 'V':
+ version();
+ exit(0);
case 'v':
verbose_option = 1;
break;
diff --git a/src/binlogsel.c b/src/binlogsel.c
index 8f1cfce..b05b12c 100644
--- a/src/binlogsel.c
+++ b/src/binlogsel.c
@@ -53,7 +53,25 @@ void selglob(const char *dir, const char *pattern);
void
help()
{
- printf("usage: %s [-dhnv] [-t FORMAT] [-F FROMTIME] [-T TOTIME] [-p PATTERN] [-D DIR] [FILE...]\n", progname);
+ printf("usage: %s [-dhnVv] [-t FORMAT] [-F TIME] [-T TIME] [-p PATTERN] [-D DIR] [FILE...]\n", progname);
+ printf("Select records from binary logs\n");
+ printf("\nOptions are:\n\n");
+ printf(" -D DIR log file storage directory\n");
+ printf(" -F TIME print records starting from TIME\n");
+ printf(" -T TIME print records starting up to TIME\n");
+ printf(" -p PATTERN select files matching PATTERN\n");
+ printf("\n");
+ printf(" -d print timestamps relative to first record in the file\n");
+ printf(" -n output record numbers\n");
+ printf(" -v print information about each file\n");
+ printf(" -t FMT format timestamps according to FMT\n");
+ printf("\n");
+ printf(" -h print this help summary\n");
+ printf(" -V show program version\n");
+ printf("\n");
+ printf("Report bugs and suggestions to <%s>\n", PACKAGE_BUGREPORT);
+ if (sizeof(PACKAGE_URL) > 1)
+ printf("%s home page: <%s>\n", PACKAGE_NAME, PACKAGE_URL);
}
/* Convert strftime-like pattern into globbing pattern */
@@ -407,7 +425,7 @@ selidx_day(const char *dir)
dirlen = strlen(dir) + 4;
dirbuf = xmalloc(dirlen);
- for (;from_day <= to_day; from_day++) {
+ for (; from_day <= to_day; from_day++) {
snprintf(dirbuf, dirlen, "%s/%02d", dir, from_day);
selglob(dirbuf, BINLOG_GLOB_PATTERN);
}
@@ -458,7 +476,7 @@ selidx_month(const char *dir)
dirlen = strlen(dir) + 4;
dirbuf = xmalloc(dirlen);
- for (;from_month <= to_month; from_month++) {
+ for (; from_month <= to_month; from_month++) {
snprintf(dirbuf, dirlen, "%s/%02d", dir, from_month);
selidx_day(dirbuf);
}
@@ -504,7 +522,7 @@ selidx_year(const char *dir)
dirlen = strlen(dir) + 6;
dirbuf = xmalloc(dirlen);
- for (;from_year <= to_year; from_year++) {
+ for (; from_year <= to_year; from_year++) {
snprintf(dirbuf, dirlen, "%s/%04d", dir, from_year);
selidx_month(dirbuf);
}
@@ -514,7 +532,7 @@ selidx_year(const char *dir)
}
int
-globerrfunc (const char *epath, int eerrno)
+globerrfunc(const char *epath, int eerrno)
{
error("%s: %s", epath, strerror(eerrno));
return 0;
@@ -614,7 +632,7 @@ main(int argc, char **argv)
struct timespec ts;
setprogname(argv[0]);
- while ((c = getopt(argc, argv, "D:dF:hi:p:T:t:nv")) != EOF)
+ while ((c = getopt(argc, argv, "D:dF:hi:p:T:t:nV")) != EOF)
switch (c) {
case 'D':
directory = optarg;
@@ -658,6 +676,9 @@ main(int argc, char **argv)
case 'n':
number_option = 1;
break;
+ case 'V':
+ version();
+ exit(0);
case 'v':
verbose_option = 1;
break;
diff --git a/src/err.c b/src/err.c
index 73aaba7..5c4d8d8 100644
--- a/src/err.c
+++ b/src/err.c
@@ -60,3 +60,12 @@ packerror(const char *fmt, ...)
va_end(ap);
}
+void
+version(void)
+{
+ printf("%s (%s) %s\n", progname, PACKAGE_TARNAME, PACKAGE_VERSION);
+ printf("Copyright (C) 2013 Sergey Poznyakoff\n");
+ printf("License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>\n");
+ printf("This is free software: you are free to change and redistribute it.\n");
+ printf("There is NO WARRANTY, to the extent permitted by law.\n");
+}
diff --git a/src/err.h b/src/err.h
index 69139fd..aab01be 100644
--- a/src/err.h
+++ b/src/err.h
@@ -19,3 +19,4 @@ extern const char *progname;
void setprogname(const char *);
void error(const char *fmt, ...);
void packerror(const char *fmt, ...);
+void version(void);

Return to:

Send suggestions and report system problems to the System administrator.