r4953 - in trunk/varnish-cache: bin/varnishadm bin/varnishhist bin/varnishlog bin/varnishncsa bin/varnishreplay bin/varnishsizes bin/varnishstat bin/varnishtest bin/varnishtop include lib/libvarnishapi
phk at varnish-cache.org
phk at varnish-cache.org
Mon Jun 14 10:03:45 CEST 2010
Author: phk
Date: 2010-06-14 10:03:45 +0200 (Mon, 14 Jun 2010)
New Revision: 4953
Modified:
trunk/varnish-cache/bin/varnishadm/varnishadm.c
trunk/varnish-cache/bin/varnishhist/varnishhist.c
trunk/varnish-cache/bin/varnishlog/varnishlog.c
trunk/varnish-cache/bin/varnishncsa/varnishncsa.c
trunk/varnish-cache/bin/varnishreplay/varnishreplay.c
trunk/varnish-cache/bin/varnishsizes/varnishsizes.c
trunk/varnish-cache/bin/varnishstat/varnishstat.c
trunk/varnish-cache/bin/varnishtest/vtc_varnish.c
trunk/varnish-cache/bin/varnishtop/varnishtop.c
trunk/varnish-cache/include/varnishapi.h
trunk/varnish-cache/lib/libvarnishapi/vsl_arg.c
Log:
Cleanup around arg processing. Need to think a bit more about
usage strings, before I continue.
Modified: trunk/varnish-cache/bin/varnishadm/varnishadm.c
===================================================================
--- trunk/varnish-cache/bin/varnishadm/varnishadm.c 2010-06-14 07:41:26 UTC (rev 4952)
+++ trunk/varnish-cache/bin/varnishadm/varnishadm.c 2010-06-14 08:03:45 UTC (rev 4953)
@@ -244,7 +244,7 @@
if (n_arg != NULL) {
vsd = VSM_New();
- assert(VSL_Log_Arg(vsd, 'n', n_arg));
+ assert(VSL_Arg(vsd, 'n', n_arg));
if (!VSM_Open(vsd, 1)) {
if (T_arg == NULL) {
p = VSM_Find_Chunk(vsd, "Arg", "-T", "", NULL);
Modified: trunk/varnish-cache/bin/varnishhist/varnishhist.c
===================================================================
--- trunk/varnish-cache/bin/varnishhist/varnishhist.c 2010-06-14 07:41:26 UTC (rev 4952)
+++ trunk/varnish-cache/bin/varnishhist/varnishhist.c 2010-06-14 08:03:45 UTC (rev 4953)
@@ -324,7 +324,7 @@
vd = VSM_New();
VSL_Setup(vd);
- while ((o = getopt(argc, argv, VSL_LOG_ARGS "Vw:")) != -1) {
+ while ((o = getopt(argc, argv, VSL_ARGS "Vw:")) != -1) {
switch (o) {
case 'V':
varnish_version("varnishhist");
@@ -333,7 +333,7 @@
delay = atoi(optarg);
break;
default:
- if (VSL_Log_Arg(vd, o, optarg) > 0)
+ if (VSL_Arg(vd, o, optarg) > 0)
break;
usage();
}
Modified: trunk/varnish-cache/bin/varnishlog/varnishlog.c
===================================================================
--- trunk/varnish-cache/bin/varnishlog/varnishlog.c 2010-06-14 07:41:26 UTC (rev 4952)
+++ trunk/varnish-cache/bin/varnishlog/varnishlog.c 2010-06-14 08:03:45 UTC (rev 4953)
@@ -320,18 +320,18 @@
vd = VSM_New();
VSL_Setup(vd);
- while ((c = getopt(argc, argv, VSL_LOG_ARGS "aDoP:uVw:")) != -1) {
+ while ((c = getopt(argc, argv, VSL_ARGS "aDoP:uVw:")) != -1) {
switch (c) {
case 'a':
a_flag = 1;
break;
case 'b':
b_flag = 1;
- AN(VSL_Log_Arg(vd, c, optarg));
+ AN(VSL_Arg(vd, c, optarg));
break;
case 'c':
c_flag = 1;
- AN(VSL_Log_Arg(vd, c, optarg));
+ AN(VSL_Arg(vd, c, optarg));
break;
case 'D':
D_flag = 1;
@@ -352,7 +352,7 @@
w_arg = optarg;
break;
default:
- if (VSL_Log_Arg(vd, c, optarg) > 0)
+ if (VSL_Arg(vd, c, optarg) > 0)
break;
usage();
}
Modified: trunk/varnish-cache/bin/varnishncsa/varnishncsa.c
===================================================================
--- trunk/varnish-cache/bin/varnishncsa/varnishncsa.c 2010-06-14 07:41:26 UTC (rev 4952)
+++ trunk/varnish-cache/bin/varnishncsa/varnishncsa.c 2010-06-14 08:03:45 UTC (rev 4953)
@@ -530,7 +530,7 @@
vd = VSM_New();
VSL_Setup(vd);
- while ((c = getopt(argc, argv, VSL_LOG_ARGS "aDP:Vw:f")) != -1) {
+ while ((c = getopt(argc, argv, VSL_ARGS "aDP:Vw:f")) != -1) {
switch (c) {
case 'a':
a_flag = 1;
@@ -558,13 +558,13 @@
/* XXX: Silently ignored: it's required anyway */
break;
default:
- if (VSL_Log_Arg(vd, c, optarg) > 0)
+ if (VSL_Arg(vd, c, optarg) > 0)
break;
usage();
}
}
- VSL_Log_Arg(vd, 'c', optarg);
+ VSL_Arg(vd, 'c', optarg);
if (VSL_Open(vd, 1))
exit(1);
Modified: trunk/varnish-cache/bin/varnishreplay/varnishreplay.c
===================================================================
--- trunk/varnish-cache/bin/varnishreplay/varnishreplay.c 2010-06-14 07:41:26 UTC (rev 4952)
+++ trunk/varnish-cache/bin/varnishreplay/varnishreplay.c 2010-06-14 08:03:45 UTC (rev 4953)
@@ -724,7 +724,7 @@
VSL_Setup(vd);
debug = 0;
- VSL_Log_Arg(vd, 'c', NULL);
+ VSL_Arg(vd, 'c', NULL);
while ((c = getopt(argc, argv, "a:Dr:n:")) != -1) {
switch (c) {
case 'a':
@@ -734,7 +734,7 @@
++debug;
break;
default:
- if (VSL_Log_Arg(vd, c, optarg) > 0)
+ if (VSL_Arg(vd, c, optarg) > 0)
break;
usage();
}
Modified: trunk/varnish-cache/bin/varnishsizes/varnishsizes.c
===================================================================
--- trunk/varnish-cache/bin/varnishsizes/varnishsizes.c 2010-06-14 07:41:26 UTC (rev 4952)
+++ trunk/varnish-cache/bin/varnishsizes/varnishsizes.c 2010-06-14 08:03:45 UTC (rev 4953)
@@ -325,7 +325,7 @@
vd = VSM_New();
VSL_Setup(vd);
- while ((o = getopt(argc, argv, VSL_LOG_ARGS "Vw:")) != -1) {
+ while ((o = getopt(argc, argv, VSL_ARGS "Vw:")) != -1) {
switch (o) {
case 'V':
varnish_version("varnishsizes");
@@ -334,7 +334,7 @@
delay = atoi(optarg);
break;
default:
- if (VSL_Log_Arg(vd, o, optarg) > 0)
+ if (VSL_Arg(vd, o, optarg) > 0)
break;
usage();
}
Modified: trunk/varnish-cache/bin/varnishstat/varnishstat.c
===================================================================
--- trunk/varnish-cache/bin/varnishstat/varnishstat.c 2010-06-14 07:41:26 UTC (rev 4952)
+++ trunk/varnish-cache/bin/varnishstat/varnishstat.c 2010-06-14 08:03:45 UTC (rev 4953)
@@ -169,7 +169,9 @@
{
#define FMT " %-28s # %s\n"
fprintf(stderr, "usage: varnishstat "
- "[-1lV] [-f field_list] [-n varnish_name] [-w delay]\n");
+ "[-1lV] [-f field_list] "
+ VSC_n_USAGE " "
+ "[-w delay]\n");
fprintf(stderr, FMT, "-1", "Print the statistics once and exit");
fprintf(stderr, FMT, "-f field_list",
"Comma separated list of fields to display. ");
@@ -199,7 +201,7 @@
vd = VSM_New();
VSC_Setup(vd);
- while ((c = getopt(argc, argv, VSL_STAT_ARGS "1f:lVw:x")) != -1) {
+ while ((c = getopt(argc, argv, VSC_ARGS "1f:lVw:x")) != -1) {
switch (c) {
case '1':
once = 1;
Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2010-06-14 07:41:26 UTC (rev 4952)
+++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c 2010-06-14 08:03:45 UTC (rev 4953)
@@ -361,7 +361,7 @@
vtc_log(v->vl, 0, "CLI auth command failed: %u %s", u, r);
free(r);
- (void)VSL_Log_Arg(v->vd, 'n', v->workdir);
+ (void)VSL_Arg(v->vd, 'n', v->workdir);
AZ(VSC_Open(v->vd, 1));
}
Modified: trunk/varnish-cache/bin/varnishtop/varnishtop.c
===================================================================
--- trunk/varnish-cache/bin/varnishtop/varnishtop.c 2010-06-14 07:41:26 UTC (rev 4952)
+++ trunk/varnish-cache/bin/varnishtop/varnishtop.c 2010-06-14 08:03:45 UTC (rev 4953)
@@ -310,10 +310,10 @@
vd = VSM_New();
VSL_Setup(vd);
- while ((o = getopt(argc, argv, VSL_LOG_ARGS "1fV")) != -1) {
+ while ((o = getopt(argc, argv, VSL_ARGS "1fV")) != -1) {
switch (o) {
case '1':
- AN(VSL_Log_Arg(vd, 'd', NULL));
+ AN(VSL_Arg(vd, 'd', NULL));
once = 1;
break;
case 'f':
@@ -323,7 +323,7 @@
varnish_version("varnishtop");
exit(0);
default:
- if (VSL_Log_Arg(vd, o, optarg) > 0)
+ if (VSL_Arg(vd, o, optarg) > 0)
break;
usage();
}
Modified: trunk/varnish-cache/include/varnishapi.h
===================================================================
--- trunk/varnish-cache/include/varnishapi.h 2010-06-14 07:41:26 UTC (rev 4952)
+++ trunk/varnish-cache/include/varnishapi.h 2010-06-14 08:03:45 UTC (rev 4953)
@@ -66,6 +66,8 @@
* If func is NULL, diagnostics are disabled.
*/
+#define VSM_n_USAGE "[-n varnish_name]"
+
int VSM_n_Arg(struct VSM_data *vd, const char *n_arg);
/*
* Configure which varnishd instance to access.
@@ -148,6 +150,10 @@
* Setup vd for use with VSC functions.
*/
+#define VSC_ARGS "L:n:"
+#define VSC_n_USAGE VSM_n_USAGE
+#define VSC_USAGE VSC_N_USAGE
+
int VSC_Arg(struct VSM_data *vd, int arg, const char *opt);
/*
* Handle standard stat-presenter arguments
@@ -204,22 +210,48 @@
* != 0 on failure
*/
+#define VSL_ARGS "bCcdI:i:k:L:n:r:s:X:x:"
+#define VSL_b_USAGE "[-b]"
+#define VSL_c_USAGE "[-c]"
+#define VSL_C_USAGE "[-C]"
+#define VSL_d_USAGE "[-d]"
+#define VSL_i_USAGE "[-i tag]"
+#define VSL_I_USAGE "[-I regexp]"
+#define VSL_k_USAGE "[-k keep]"
+#define VSL_n_USAGE VSM_n_USAGE
+#define VSL_r_USAGE "[-r file]"
+#define VSL_s_USAGE "[-s skip]"
+#define VSL_x_USAGE "[-x tag]"
+#define VSL_X_USAGE "[-X regexp]"
+#define VSL_USAGE "[-bCcd] " \
+ VSL_i_USAGE " " \
+ VSL_I_USAGE " " \
+ VSL_k_USAGE " " \
+ VSL_n_USAGE " " \
+ VSL_r_USAGE " " \
+ VSL_s_USAGE " " \
+ VSL_X_USAGE " " \
+ VSL_x_USAGE
+
+int VSL_Arg(struct VSM_data *vd, int arg, const char *opt);
+ /*
+ * Handle standard log-presenter arguments
+ * Return:
+ * -1 error
+ * 0 not handled
+ * 1 Handled.
+ */
typedef int vsl_handler(void *priv, enum vsl_tag tag, unsigned fd,
unsigned len, unsigned spec, const char *ptr);
#define VSL_S_CLIENT (1 << 0)
#define VSL_S_BACKEND (1 << 1)
-#define VSL_LOG_ARGS "bCcdI:i:k:L:n:r:s:X:x:"
-#define VSL_STAT_ARGS "L:n:"
-#define VSL_USAGE "[-bCcd] [-i tag] [-I regexp] [-k keep]" \
- " [-r file] [-s skip] [-X regexp] [-x tag]"
vsl_handler VSL_H_Print;
struct VSM_data;
void VSL_Select(const struct VSM_data *vd, unsigned tag);
void VSL_NonBlocking(const struct VSM_data *vd, int nb);
int VSL_Dispatch(const struct VSM_data *vd, vsl_handler *func, void *priv);
int VSL_NextLog(const struct VSM_data *lh, uint32_t **pp);
-int VSL_Log_Arg(struct VSM_data *vd, int arg, const char *opt);
extern const char *VSL_tags[256];
Modified: trunk/varnish-cache/lib/libvarnishapi/vsl_arg.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/vsl_arg.c 2010-06-14 07:41:26 UTC (rev 4952)
+++ trunk/varnish-cache/lib/libvarnishapi/vsl_arg.c 2010-06-14 08:03:45 UTC (rev 4953)
@@ -192,7 +192,7 @@
/*--------------------------------------------------------------------*/
int
-VSL_Log_Arg(struct VSM_data *vd, int arg, const char *opt)
+VSL_Arg(struct VSM_data *vd, int arg, const char *opt)
{
CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
More information about the varnish-commit
mailing list