Commit d7458d72 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Split VSL_Arg() into VSL_Log_Arg() and VSL_Stat_Arg()



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4909 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 6fd5ace7
......@@ -244,7 +244,7 @@ main(int argc, char * const *argv)
if (n_arg != NULL) {
vsd = VSL_New();
assert(VSL_Arg(vsd, 'n', n_arg));
assert(VSL_Log_Arg(vsd, 'n', n_arg));
if (!VSL_Open(vsd)) {
if (T_arg == NULL) {
p = VSL_Find_Alloc(vsd, "Arg", "-T", "", NULL);
......
......@@ -332,7 +332,7 @@ main(int argc, char **argv)
delay = atoi(optarg);
break;
default:
if (VSL_Arg(vd, o, optarg) > 0)
if (VSL_Log_Arg(vd, o, optarg) > 0)
break;
usage();
}
......
......@@ -325,11 +325,11 @@ main(int argc, char **argv)
break;
case 'b':
b_flag = 1;
VSL_Arg(vd, c, optarg);
VSL_Log_Arg(vd, c, optarg);
break;
case 'c':
c_flag = 1;
VSL_Arg(vd, c, optarg);
VSL_Log_Arg(vd, c, optarg);
break;
case 'D':
D_flag = 1;
......@@ -350,7 +350,7 @@ main(int argc, char **argv)
w_arg = optarg;
break;
default:
if (VSL_Arg(vd, c, optarg) > 0)
if (VSL_Log_Arg(vd, c, optarg) > 0)
break;
usage();
}
......
......@@ -557,13 +557,13 @@ main(int argc, char *argv[])
/* XXX: Silently ignored: it's required anyway */
break;
default:
if (VSL_Arg(vd, c, optarg) > 0)
if (VSL_Log_Arg(vd, c, optarg) > 0)
break;
usage();
}
}
VSL_Arg(vd, 'c', optarg);
VSL_Log_Arg(vd, 'c', optarg);
if (VSL_OpenLog(vd))
exit(1);
......
......@@ -723,7 +723,7 @@ main(int argc, char *argv[])
vd = VSL_New();
debug = 0;
VSL_Arg(vd, 'c', NULL);
VSL_Log_Arg(vd, 'c', NULL);
while ((c = getopt(argc, argv, "a:Dr:n:")) != -1) {
switch (c) {
case 'a':
......@@ -733,7 +733,7 @@ main(int argc, char *argv[])
++debug;
break;
default:
if (VSL_Arg(vd, c, optarg) > 0)
if (VSL_Log_Arg(vd, c, optarg) > 0)
break;
usage();
}
......
......@@ -333,7 +333,7 @@ main(int argc, char **argv)
delay = atoi(optarg);
break;
default:
if (VSL_Arg(vd, o, optarg) > 0)
if (VSL_Log_Arg(vd, o, optarg) > 0)
break;
usage();
}
......
......@@ -296,7 +296,7 @@ main(int argc, char * const *argv)
xml = 1;
break;
default:
if (VSL_Arg(vd, c, optarg) > 0)
if (VSL_Stat_Arg(vd, c, optarg) > 0)
break;
usage();
}
......
......@@ -364,7 +364,7 @@ varnish_launch(struct varnish *v)
if (v->stats != NULL)
VSL_Close(v->vd);
(void)VSL_Arg(v->vd, 'n', v->workdir);
(void)VSL_Log_Arg(v->vd, 'n', v->workdir);
v->stats = VSL_OpenStats(v->vd);
}
......
......@@ -309,7 +309,7 @@ main(int argc, char **argv)
while ((o = getopt(argc, argv, VSL_LOG_ARGS "1fV")) != -1) {
switch (o) {
case '1':
VSL_Arg(vd, 'd', NULL);
VSL_Log_Arg(vd, 'd', NULL);
once = 1;
break;
case 'f':
......@@ -319,7 +319,7 @@ main(int argc, char **argv)
varnish_version("varnishtop");
exit(0);
default:
if (VSL_Arg(vd, o, optarg) > 0)
if (VSL_Log_Arg(vd, o, optarg) > 0)
break;
usage();
}
......
......@@ -55,7 +55,8 @@ int VSL_OpenLog(struct VSL_data *vd);
void VSL_NonBlocking(struct VSL_data *vd, int nb);
int VSL_Dispatch(struct VSL_data *vd, vsl_handler *func, void *priv);
int VSL_NextLog(struct VSL_data *lh, unsigned char **pp);
int VSL_Arg(struct VSL_data *vd, int arg, const char *opt);
int VSL_Log_Arg(struct VSL_data *vd, int arg, const char *opt);
int VSL_Stat_Arg(struct VSL_data *vd, int arg, const char *opt);
void VSL_Close(struct VSL_data *vd);
int VSL_Open(struct VSL_data *vd);
void VSL_Delete(struct VSL_data *vd);
......
......@@ -167,6 +167,7 @@ vsl_s_arg(struct VSL_data *vd, const char *opt)
}
return (1);
}
/*--------------------------------------------------------------------*/
static int
......@@ -187,15 +188,26 @@ vsl_k_arg(struct VSL_data *vd, const char *opt)
return (1);
}
/*--------------------------------------------------------------------
* XXX: Should really be split into three:
* VSL_Arg() for generic args for all programs (-n)
* VSL_Log_Arg() for log readers.
* VSL_Stat_Arg() for stat reporters.
*/
/*--------------------------------------------------------------------*/
static int
vsl_n_arg(struct VSL_data *vd, const char *opt)
{
REPLACE(vd->n_opt, opt);
AN(vd->n_opt);
if (vin_n_arg(vd->n_opt, NULL, NULL, &vd->fname)) {
fprintf(stderr, "Invalid instance name: %s\n",
strerror(errno));
return (-1);
}
return (1);
}
/*--------------------------------------------------------------------*/
int
VSL_Arg(struct VSL_data *vd, int arg, const char *opt)
VSL_Log_Arg(struct VSL_data *vd, int arg, const char *opt)
{
CHECK_OBJ_NOTNULL(vd, VSL_MAGIC);
......@@ -208,16 +220,7 @@ VSL_Arg(struct VSL_data *vd, int arg, const char *opt)
return (1);
case 'i': case 'x': return (vsl_ix_arg(vd, opt, arg));
case 'k': return (vsl_k_arg(vd, opt));
case 'n':
free(vd->n_opt);
vd->n_opt = strdup(opt);
assert(vd->n_opt != NULL);
if (vin_n_arg(vd->n_opt, NULL, NULL, &vd->fname)) {
fprintf(stderr, "Invalid instance name: %s\n",
strerror(errno));
return (-1);
}
return (1);
case 'n': return (vsl_n_arg(vd, opt));
case 'r': return (vsl_r_arg(vd, opt));
case 's': return (vsl_s_arg(vd, opt));
case 'I': case 'X': return (vsl_IX_arg(vd, opt, arg));
......@@ -236,3 +239,17 @@ VSL_Arg(struct VSL_data *vd, int arg, const char *opt)
return (0);
}
}
/*--------------------------------------------------------------------*/
int
VSL_Stat_Arg(struct VSL_data *vd, int arg, const char *opt)
{
CHECK_OBJ_NOTNULL(vd, VSL_MAGIC);
switch (arg) {
case 'n': return (vsl_n_arg(vd, opt));
default:
return (0);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment