typedef int vsl_handler(void *priv, enum shmlogtag tag, unsigned fd, unsigned len, unsigned spec, const char *ptr);
#define VSL_S_CLIENT (1 << 0)
#define VSL_S_BACKEND (1 << 1)
-#define VSL_ARGS "bCcdI:i:r:s:X:x:"
-#define VSL_USAGE "[-bCcd] [-i tag] [-I regexp] [-r file] [-s skip] [-X regexp] [-x tag]"
+#define VSL_ARGS "bCcdI:i:k:r:s:X:x:"
+#define VSL_USAGE "[-bCcd] [-i tag] [-I regexp] [-k keep] [-r file] [-s skip] [-X regexp] [-x tag]"
vsl_handler VSL_H_Print;
struct VSL_data;
struct VSL_data *VSL_New(void);
regex_t *regexcl;
unsigned long skip;
+ unsigned long keep;
};
#ifndef MAP_HASSEMAPHORE
if (vd->skip) {
--vd->skip;
continue;
+ } else if (vd->keep) {
+ if (--vd->keep == 0)
+ return (0);
}
if (vd->map[p[SHMLOG_TAG]] & M_SELECT) {
*pp = p;
}
return (1);
}
+/*--------------------------------------------------------------------*/
+
+static int
+vsl_k_arg(struct VSL_data *vd, const char *opt)
+{
+ char *end;
+
+ CHECK_OBJ_NOTNULL(vd, VSL_MAGIC);
+ if (*opt == '\0') {
+ fprintf(stderr, "number required for -k\n");
+ return (-1);
+ }
+ vd->keep = strtoul(opt, &end, 10);
+ if (*end != '\0') {
+ fprintf(stderr, "invalid number for -k\n");
+ return (-1);
+ }
+ return (1);
+}
/*--------------------------------------------------------------------*/
case 'I': case 'X': return (vsl_IX_arg(vd, opt, arg));
case 'C': vd->regflags = REG_ICASE; return (1);
case 's': return (vsl_s_arg(vd, opt));
+ case 'k': return (vsl_k_arg(vd, opt));
default:
return (0);
}