diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-10-13 12:44:12 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-10-13 12:48:04 +0300 |
commit | 23f262e8c6181465347c3bb47644f9d86fcb7432 (patch) | |
tree | cdf5ac3a861395ade00b71e7b8cdd641db67032c /src/binlogcat.c | |
parent | 510fc646f13b843d046323e3477edb6c1bc2258d (diff) | |
download | vmod-binlog-23f262e8c6181465347c3bb47644f9d86fcb7432.tar.gz vmod-binlog-23f262e8c6181465347c3bb47644f9d86fcb7432.tar.bz2 |
* src/Makefile.am: New convenience library libbinlog.a
* src/binlogcat.c: Use functions from libbinlog.a
* src/err.h: New file.
* src/err.c: New file.
* tests/.gitignore: Add binpack.c
* tests/Makefile.am: Build binpack.c
* tests/binpack.c: New file.
Diffstat (limited to 'src/binlogcat.c')
-rw-r--r-- | src/binlogcat.c | 34 |
1 files changed, 3 insertions, 31 deletions
diff --git a/src/binlogcat.c b/src/binlogcat.c index 8cdfaaa..bdeb992 100644 --- a/src/binlogcat.c +++ b/src/binlogcat.c @@ -23,48 +23,20 @@ #include <stdarg.h> #include <errno.h> #include <time.h> #include <string.h> #include "vmod-binlog.h" #include "pack.h" +#include "err.h" -char *progname; char *timefmt = "%c"; int number_option; int verbose_option; int timediff_option; void -verror(const char *fmt, va_list ap) -{ - fprintf(stderr, "%s: ", progname); - vfprintf(stderr, fmt, ap); - fputc('\n', stderr); -} - -void -error(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - verror(fmt, ap); - va_end(ap); -} - -void -packerror(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - verror(fmt, ap); - va_end(ap); -} - -void catlog(const char *fname) { FILE *fp; struct binlog_file_header header; struct binlog_record *rec; char timebuf[128]; @@ -95,13 +67,13 @@ catlog(const char *fname) if (memcmp(header.magic, BINLOG_MAGIC_STR, BINLOG_MAGIC_LEN)) { error("%s is not a binlog file", fname); exit(1); } if (header.version != BINLOG_VERSION) { - error("%s: unknown version", progname, fname); + error("%s: unknown version", fname); exit(1); } size = header.hdrsize - sizeof(header); dataspec = malloc(size); if (!dataspec) { @@ -173,15 +145,15 @@ help() printf("usage: %s [-dhnv] [t FORMAT] [FILE...]\n", progname); } int main(int argc, char **argv) { - progname = argv[0]; int c; + setprogname(argv[0]); while ((c = getopt(argc, argv, "dht:nv")) != EOF) switch (c) { case 'd': timediff_option = 1; timefmt = "%s"; break; |