diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-10-15 20:07:26 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-10-15 20:07:26 +0300 |
commit | 7d0beb6599c53544739409ca4aec104bf27a3f35 (patch) | |
tree | b561fbba7c9acedec17cbc398cee12a465faad6e /src/binlogsel.c | |
parent | ef3f928cc712f6774e19f8cb8f880cbeac15e8ff (diff) | |
download | vmod-binlog-7d0beb6599c53544739409ca4aec104bf27a3f35.tar.gz vmod-binlog-7d0beb6599c53544739409ca4aec104bf27a3f35.tar.bz2 |
Add version and help output to command line utilities.
Diffstat (limited to 'src/binlogsel.c')
-rw-r--r-- | src/binlogsel.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/src/binlogsel.c b/src/binlogsel.c index 8f1cfce..b05b12c 100644 --- a/src/binlogsel.c +++ b/src/binlogsel.c @@ -50,13 +50,31 @@ time_t from_time, to_time; static int matchnames(const char *dir, const char *pat, glob_t *gl); 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 */ char * convpattern(const char *dir) { @@ -404,13 +422,13 @@ selidx_day(const char *dir) } to_day = filename_to_int(gl.gl_pathv[gl.gl_pathc - 1]); } 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); } free(dirbuf); if (glinit) globfree(&gl); @@ -455,13 +473,13 @@ selidx_month(const char *dir) } to_month = filename_to_int(gl.gl_pathv[gl.gl_pathc - 1]); } 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); } free(dirbuf); if (glinit) globfree(&gl); @@ -501,23 +519,23 @@ selidx_year(const char *dir) } to_year = filename_to_int(gl.gl_pathv[gl.gl_pathc - 1]); } 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); } free(dirbuf); if (glinit) globfree(&gl); } int -globerrfunc (const char *epath, int eerrno) +globerrfunc(const char *epath, int eerrno) { error("%s: %s", epath, strerror(eerrno)); return 0; } static int @@ -611,13 +629,13 @@ int main(int argc, char **argv) { int c; 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; break; case 'd': timediff_option = 1; @@ -655,12 +673,15 @@ main(int argc, char **argv) case 't': timefmt = optarg; break; case 'n': number_option = 1; break; + case 'V': + version(); + exit(0); case 'v': verbose_option = 1; break; default: exit(1); } |