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 | |||
@@ -64,8 +64,8 @@ struct binlog_config { | |||
64 | int debug; /* debug level */ | 64 | int debug; /* debug level */ |
65 | int flags; /* flags (see BLF_* defines above) */ | 65 | int flags; /* flags (see BLF_* defines above) */ |
66 | 66 | ||
67 | char *dataspec; /* data format specification */ | 67 | char *format; /* data format specification */ |
68 | struct packinst *inst_head; /* compiled dataspec */ | 68 | struct packinst *inst_head; /* compiled format */ |
69 | struct packinst *inst_cur; /* current instruction */ | 69 | struct packinst *inst_cur; /* current instruction */ |
70 | struct packenv *env; /* pack environment */ | 70 | struct packenv *env; /* pack environment */ |
71 | enum binlog_state state; /* binlog machine state */ | 71 | enum binlog_state state; /* binlog machine state */ |
@@ -209,7 +209,7 @@ getindexpat(const char *name) | |||
209 | 209 | ||
210 | void | 210 | void |
211 | vmod_init(struct sess *sp, struct vmod_priv *priv, | 211 | vmod_init(struct sess *sp, struct vmod_priv *priv, |
212 | const char *dir, const char *dataspec, const char *param) | 212 | const char *dir, const char *format, const char *param) |
213 | { | 213 | { |
214 | struct binlog_config *conf = priv->priv; | 214 | struct binlog_config *conf = priv->priv; |
215 | struct stat st; | 215 | struct stat st; |
@@ -244,7 +244,7 @@ vmod_init(struct sess *sp, struct vmod_priv *priv, | |||
244 | conf->dir = strdup(dir); | 244 | conf->dir = strdup(dir); |
245 | AN(conf->dir); | 245 | AN(conf->dir); |
246 | 246 | ||
247 | conf->inst_head = packcomp(dataspec, &p); | 247 | conf->inst_head = packcomp(format, &p); |
248 | if (!conf->inst_head) { | 248 | if (!conf->inst_head) { |
249 | if (errno == EINVAL) | 249 | if (errno == EINVAL) |
250 | binlog_error("cannot compile data format near %s", p); | 250 | binlog_error("cannot compile data format near %s", p); |
@@ -256,8 +256,8 @@ vmod_init(struct sess *sp, struct vmod_priv *priv, | |||
256 | conf->env = packenv_create(conf->recsize); | 256 | conf->env = packenv_create(conf->recsize); |
257 | AN(conf->env); | 257 | AN(conf->env); |
258 | conf->recsize += offsetof(struct binlog_record,data); | 258 | conf->recsize += offsetof(struct binlog_record,data); |
259 | conf->dataspec = strdup(dataspec); | 259 | conf->format = strdup(format); |
260 | AN(conf->dataspec); | 260 | AN(conf->format); |
261 | 261 | ||
262 | p = findparam(param, "pattern"); | 262 | p = findparam(param, "pattern"); |
263 | if (!p) { | 263 | if (!p) { |
@@ -518,17 +518,17 @@ checkheader(struct binlog_config *conf, size_t hdrsize) | |||
518 | return 1; | 518 | return 1; |
519 | } | 519 | } |
520 | 520 | ||
521 | p = conf->dataspec; | 521 | p = conf->format; |
522 | while (*p) { | 522 | while (*p) { |
523 | if (read(conf->fd, &c, 1) != 1 || c != *p) { | 523 | if (read(conf->fd, &c, 1) != 1 || c != *p) { |
524 | debug(conf,1,("%s/%s: dataspec mismatch near %s: %c", | 524 | debug(conf,1,("%s/%s: format mismatch near %s: %c", |
525 | conf->dir, conf->fname, p, c)); | 525 | conf->dir, conf->fname, p, c)); |
526 | return 1; | 526 | return 1; |
527 | } | 527 | } |
528 | ++p; | 528 | ++p; |
529 | } | 529 | } |
530 | if (read(conf->fd, &c, 1) != 1 || c != 0) { | 530 | if (read(conf->fd, &c, 1) != 1 || c != 0) { |
531 | debug(conf,1,("%s/%s: dataspec mismatch at the end: %c", | 531 | debug(conf,1,("%s/%s: format mismatch at the end: %c", |
532 | conf->dir, conf->fname, c)); | 532 | conf->dir, conf->fname, c)); |
533 | return 1; | 533 | return 1; |
534 | } | 534 | } |
@@ -550,7 +550,7 @@ newfile(struct sess *sp, struct binlog_config *conf) | |||
550 | return -1; | 550 | return -1; |
551 | 551 | ||
552 | hdrsize = ((sizeof(struct binlog_file_header) + | 552 | hdrsize = ((sizeof(struct binlog_file_header) + |
553 | strlen(conf->dataspec) + | 553 | strlen(conf->format) + |
554 | conf->recsize - 1) / conf->recsize) * conf->recsize; | 554 | conf->recsize - 1) / conf->recsize) * conf->recsize; |
555 | 555 | ||
556 | if (fstat(conf->fd, &st) == 0) { | 556 | if (fstat(conf->fd, &st) == 0) { |
@@ -607,7 +607,7 @@ newfile(struct sess *sp, struct binlog_config *conf) | |||
607 | conf->base->version = BINLOG_VERSION; | 607 | conf->base->version = BINLOG_VERSION; |
608 | conf->base->recsize = conf->recsize; | 608 | conf->base->recsize = conf->recsize; |
609 | conf->base->recnum = 0; | 609 | conf->base->recnum = 0; |
610 | strcpy((char*)(conf->base + 1), conf->dataspec); | 610 | strcpy((char*)(conf->base + 1), conf->format); |
611 | 611 | ||
612 | conf->base->hdrsize = hdrsize; | 612 | conf->base->hdrsize = hdrsize; |
613 | } | 613 | } |
diff --git a/src/binlogcat.c b/src/binlogcat.c index 6ab3daf..bc7df6c 100644 --- a/src/binlogcat.c +++ b/src/binlogcat.c | |||
@@ -43,7 +43,7 @@ catlog(const char *fname) | |||
43 | char timebuf[128]; | 43 | char timebuf[128]; |
44 | size_t i; | 44 | size_t i; |
45 | time_t start_ts; | 45 | time_t start_ts; |
46 | char *dataspec; | 46 | char *format; |
47 | size_t size; | 47 | size_t size; |
48 | struct packenv *env; | 48 | struct packenv *env; |
49 | struct packinst *inst; | 49 | struct packinst *inst; |
@@ -76,9 +76,9 @@ catlog(const char *fname) | |||
76 | } | 76 | } |
77 | 77 | ||
78 | size = header.hdrsize - sizeof(header); | 78 | size = header.hdrsize - sizeof(header); |
79 | dataspec = xmalloc(size); | 79 | format = xmalloc(size); |
80 | 80 | ||
81 | if (fread(dataspec, size, 1, fp) != 1) { | 81 | if (fread(format, size, 1, fp) != 1) { |
82 | error("error reading header of %s: %s", | 82 | error("error reading header of %s: %s", |
83 | fname, strerror(errno)); | 83 | fname, strerror(errno)); |
84 | exit(1); | 84 | exit(1); |
@@ -86,20 +86,20 @@ catlog(const char *fname) | |||
86 | 86 | ||
87 | if (verbose_option) | 87 | if (verbose_option) |
88 | printf("# %s; format=%s; recsize=%lu; recnum=%lu\n", | 88 | printf("# %s; format=%s; recsize=%lu; recnum=%lu\n", |
89 | fname, dataspec, (unsigned long) header.recsize, | 89 | fname, format, (unsigned long) header.recsize, |
90 | (unsigned long) header.recnum); | 90 | (unsigned long) header.recnum); |
91 | 91 | ||
92 | inst = packcomp(dataspec, &p); | 92 | inst = packcomp(format, &p); |
93 | if (!inst) { | 93 | if (!inst) { |
94 | if (errno == EINVAL) { | 94 | if (errno == EINVAL) { |
95 | error("%s: %s: bad dataspec near %s", fname, dataspec, p); | 95 | error("%s: %s: bad format near %s", fname, format, p); |
96 | exit(1); | 96 | exit(1); |
97 | } | 97 | } |
98 | 98 | ||
99 | error("%s", strerror(errno)); | 99 | error("%s", strerror(errno)); |
100 | exit(1); | 100 | exit(1); |
101 | } | 101 | } |
102 | free(dataspec); | 102 | free(format); |
103 | 103 | ||
104 | rec = xmalloc(header.recsize); | 104 | rec = xmalloc(header.recsize); |
105 | env = packenv_create(header.recsize - | 105 | env = packenv_create(header.recsize - |
diff --git a/src/binlogsel.c b/src/binlogsel.c index e095347..63a35e7 100644 --- a/src/binlogsel.c +++ b/src/binlogsel.c | |||
@@ -160,7 +160,7 @@ selmem(const char *name, void *base) | |||
160 | size_t i, start; | 160 | size_t i, start; |
161 | time_t start_ts; | 161 | time_t start_ts; |
162 | char timebuf[128]; | 162 | char timebuf[128]; |
163 | char *dataspec; | 163 | char *format; |
164 | 164 | ||
165 | hdr = base; | 165 | hdr = base; |
166 | 166 | ||
@@ -174,18 +174,18 @@ selmem(const char *name, void *base) | |||
174 | return; | 174 | return; |
175 | } | 175 | } |
176 | 176 | ||
177 | dataspec = (char*)(hdr + 1); | 177 | format = (char*)(hdr + 1); |
178 | 178 | ||
179 | if (verbose_option) | 179 | if (verbose_option) |
180 | printf("# %s; format=%s; recsize=%lu; recnum=%lu\n", | 180 | printf("# %s; format=%s; recsize=%lu; recnum=%lu\n", |
181 | name, dataspec, (unsigned long) hdr->recsize, | 181 | name, format, (unsigned long) hdr->recsize, |
182 | (unsigned long) hdr->recnum); | 182 | (unsigned long) hdr->recnum); |
183 | 183 | ||
184 | inst = packcomp(dataspec, &p); | 184 | inst = packcomp(format, &p); |
185 | if (!inst) { | 185 | if (!inst) { |
186 | if (errno == EINVAL) { | 186 | if (errno == EINVAL) { |
187 | error("%s: %s: bad dataspec near %s", name, | 187 | error("%s: %s: bad format near %s", name, |
188 | dataspec, p); | 188 | format, p); |
189 | return; | 189 | return; |
190 | } | 190 | } |
191 | 191 | ||
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 | |||
@@ -67,7 +67,7 @@ struct binlog_file_header { | |||
67 | size_t hdrsize; | 67 | size_t hdrsize; |
68 | size_t recsize; | 68 | size_t recsize; |
69 | size_t recnum; | 69 | size_t recnum; |
70 | /* char dataspec[X];*/ | 70 | /* char format[X];*/ |
71 | }; | 71 | }; |
72 | 72 | ||
73 | #define binlog_size(hdr) ((hdr)->hdrsize + (hdr)->recnum * (hdr)->recsize) | 73 | #define binlog_size(hdr) ((hdr)->hdrsize + (hdr)->recnum * (hdr)->recsize) |