diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-10-15 21:12:32 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2013-10-15 21:12:32 +0300 |
commit | 340802898d02bad367efc8f8ba1517d42fe4baad (patch) | |
tree | 8e3300600ddf02fd9d19d8c11a45b5eb87ba9717 | |
parent | 2afd00cc2bdbaa401edc7117965b3db658576719 (diff) | |
download | vmod-binlog-340802898d02bad367efc8f8ba1517d42fe4baad.tar.gz vmod-binlog-340802898d02bad367efc8f8ba1517d42fe4baad.tar.bz2 |
Minor change
Use 'format' instead of 'dataspec'
-rw-r--r-- | src/binlog.c | 22 | ||||
-rw-r--r-- | src/binlogcat.c | 14 | ||||
-rw-r--r-- | src/binlogsel.c | 12 | ||||
-rw-r--r-- | src/vmod-binlog.h | 2 |
4 files changed, 25 insertions, 25 deletions
diff --git a/src/binlog.c b/src/binlog.c index ea1aa65..57e2aa0 100644 --- a/src/binlog.c +++ b/src/binlog.c @@ -61,14 +61,14 @@ struct binlog_config { size_t recsize; /* record size */ time_t stoptime; /* when to rotate the current file */ pthread_mutex_t mutex; int debug; /* debug level */ int flags; /* flags (see BLF_* defines above) */ - char *dataspec; /* data format specification */ - struct packinst *inst_head; /* compiled dataspec */ + char *format; /* data format specification */ + struct packinst *inst_head; /* compiled format */ struct packinst *inst_cur; /* current instruction */ struct packenv *env; /* pack environment */ enum binlog_state state; /* binlog machine state */ time_t timestamp; /* timestamp for the entry being built */ }; @@ -206,13 +206,13 @@ getindexpat(const char *name) return p->pat; return NULL; } void vmod_init(struct sess *sp, struct vmod_priv *priv, - const char *dir, const char *dataspec, const char *param) + const char *dir, const char *format, const char *param) { struct binlog_config *conf = priv->priv; struct stat st; char *p, *q; unsigned long n; int user_pattern = 0; @@ -241,26 +241,26 @@ vmod_init(struct sess *sp, struct vmod_priv *priv, dir, strerror(errno)); abort(); } conf->dir = strdup(dir); AN(conf->dir); - conf->inst_head = packcomp(dataspec, &p); + conf->inst_head = packcomp(format, &p); if (!conf->inst_head) { if (errno == EINVAL) binlog_error("cannot compile data format near %s", p); else binlog_error("%s", strerror(errno)); abort(); } conf->recsize = packsize(conf->inst_head); conf->env = packenv_create(conf->recsize); AN(conf->env); conf->recsize += offsetof(struct binlog_record,data); - conf->dataspec = strdup(dataspec); - AN(conf->dataspec); + conf->format = strdup(format); + AN(conf->format); p = findparam(param, "pattern"); if (!p) { p = strdup(BINLOG_PATTERN); AN(p); } else @@ -515,23 +515,23 @@ checkheader(struct binlog_config *conf, size_t hdrsize) if (header.recsize != conf->recsize) { debug(conf,1,("%s/%s: record size mismatch", conf->dir, conf->fname)); return 1; } - p = conf->dataspec; + p = conf->format; while (*p) { if (read(conf->fd, &c, 1) != 1 || c != *p) { - debug(conf,1,("%s/%s: dataspec mismatch near %s: %c", + debug(conf,1,("%s/%s: format mismatch near %s: %c", conf->dir, conf->fname, p, c)); return 1; } ++p; } if (read(conf->fd, &c, 1) != 1 || c != 0) { - debug(conf,1,("%s/%s: dataspec mismatch at the end: %c", + debug(conf,1,("%s/%s: format mismatch at the end: %c", conf->dir, conf->fname, c)); return 1; } return 0; } @@ -547,13 +547,13 @@ newfile(struct sess *sp, struct binlog_config *conf) setstoptime(conf); if (createfile(sp, conf)) return -1; hdrsize = ((sizeof(struct binlog_file_header) + - strlen(conf->dataspec) + + strlen(conf->format) + conf->recsize - 1) / conf->recsize) * conf->recsize; if (fstat(conf->fd, &st) == 0) { /* File already exists */ if (st.st_size > 0 && !(conf->flags & BLF_TRUNCATE) && @@ -604,13 +604,13 @@ newfile(struct sess *sp, struct binlog_config *conf) } else { debug(conf,1,("created new log file %s",conf->fname)); memcpy(conf->base->magic, BINLOG_MAGIC_STR, BINLOG_MAGIC_LEN); conf->base->version = BINLOG_VERSION; conf->base->recsize = conf->recsize; conf->base->recnum = 0; - strcpy((char*)(conf->base + 1), conf->dataspec); + strcpy((char*)(conf->base + 1), conf->format); conf->base->hdrsize = hdrsize; } conf->recbase = (char *) conf->base + conf->base->hdrsize; conf->recnum = binlog_recnum(conf); diff --git a/src/binlogcat.c b/src/binlogcat.c index 6ab3daf..bc7df6c 100644 --- a/src/binlogcat.c +++ b/src/binlogcat.c @@ -40,13 +40,13 @@ catlog(const char *fname) FILE *fp; struct binlog_file_header header; struct binlog_record *rec; char timebuf[128]; size_t i; time_t start_ts; - char *dataspec; + char *format; size_t size; struct packenv *env; struct packinst *inst; char *p; if (strcmp(fname, "-") == 0) @@ -73,36 +73,36 @@ catlog(const char *fname) if (header.version != BINLOG_VERSION) { error("%s: unknown version", fname); exit(1); } size = header.hdrsize - sizeof(header); - dataspec = xmalloc(size); + format = xmalloc(size); - if (fread(dataspec, size, 1, fp) != 1) { + if (fread(format, size, 1, fp) != 1) { error("error reading header of %s: %s", fname, strerror(errno)); exit(1); } if (verbose_option) printf("# %s; format=%s; recsize=%lu; recnum=%lu\n", - fname, dataspec, (unsigned long) header.recsize, + fname, format, (unsigned long) header.recsize, (unsigned long) header.recnum); - inst = packcomp(dataspec, &p); + inst = packcomp(format, &p); if (!inst) { if (errno == EINVAL) { - error("%s: %s: bad dataspec near %s", fname, dataspec, p); + error("%s: %s: bad format near %s", fname, format, p); exit(1); } error("%s", strerror(errno)); exit(1); } - free(dataspec); + free(format); rec = xmalloc(header.recsize); env = packenv_create(header.recsize - offsetof(struct binlog_record,data)); env->fp = stdout; diff --git a/src/binlogsel.c b/src/binlogsel.c index e095347..63a35e7 100644 --- a/src/binlogsel.c +++ b/src/binlogsel.c @@ -157,13 +157,13 @@ selmem(const char *name, void *base) struct packenv *env; struct packinst *inst; char *p; size_t i, start; time_t start_ts; char timebuf[128]; - char *dataspec; + char *format; hdr = base; if (memcmp(hdr->magic, BINLOG_MAGIC_STR, BINLOG_MAGIC_LEN)) { error("%s is not a binlog file", name); return; @@ -171,24 +171,24 @@ selmem(const char *name, void *base) if (hdr->version != BINLOG_VERSION) { error("%s: unknown version", name); return; } - dataspec = (char*)(hdr + 1); + format = (char*)(hdr + 1); if (verbose_option) printf("# %s; format=%s; recsize=%lu; recnum=%lu\n", - name, dataspec, (unsigned long) hdr->recsize, + name, format, (unsigned long) hdr->recsize, (unsigned long) hdr->recnum); - inst = packcomp(dataspec, &p); + inst = packcomp(format, &p); if (!inst) { if (errno == EINVAL) { - error("%s: %s: bad dataspec near %s", name, - dataspec, p); + error("%s: %s: bad format near %s", name, + format, p); return; } error("%s", strerror(errno)); return; } diff --git a/src/vmod-binlog.h b/src/vmod-binlog.h index e39ccea..d67f1cd 100644 --- a/src/vmod-binlog.h +++ b/src/vmod-binlog.h @@ -64,11 +64,11 @@ struct binlog_file_header { char magic[BINLOG_MAGIC_LEN]; char pad[16 - BINLOG_MAGIC_LEN]; uint32_t version; size_t hdrsize; size_t recsize; size_t recnum; -/* char dataspec[X];*/ +/* char format[X];*/ }; #define binlog_size(hdr) ((hdr)->hdrsize + (hdr)->recnum * (hdr)->recsize) |