| | varnish-cache/bin/varnishd/mgt/mgt_param.c |
0 |
|
/*- |
1 |
|
* Copyright (c) 2006 Verdens Gang AS |
2 |
|
* Copyright (c) 2006-2011 Varnish Software AS |
3 |
|
* All rights reserved. |
4 |
|
* |
5 |
|
* Author: Poul-Henning Kamp <phk@phk.freebsd.dk> |
6 |
|
* |
7 |
|
* SPDX-License-Identifier: BSD-2-Clause |
8 |
|
* |
9 |
|
* Redistribution and use in source and binary forms, with or without |
10 |
|
* modification, are permitted provided that the following conditions |
11 |
|
* are met: |
12 |
|
* 1. Redistributions of source code must retain the above copyright |
13 |
|
* notice, this list of conditions and the following disclaimer. |
14 |
|
* 2. Redistributions in binary form must reproduce the above copyright |
15 |
|
* notice, this list of conditions and the following disclaimer in the |
16 |
|
* documentation and/or other materials provided with the distribution. |
17 |
|
* |
18 |
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND |
19 |
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 |
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 |
|
* ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE |
22 |
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
23 |
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
24 |
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
25 |
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
26 |
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
27 |
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
28 |
|
* SUCH DAMAGE. |
29 |
|
*/ |
30 |
|
|
31 |
|
#include "config.h" |
32 |
|
|
33 |
|
#include <ctype.h> |
34 |
|
#include <stdarg.h> |
35 |
|
#include <stdio.h> |
36 |
|
#include <stdlib.h> |
37 |
|
#include <string.h> |
38 |
|
#include <unistd.h> |
39 |
|
|
40 |
|
#include "mgt/mgt.h" |
41 |
|
#include "common/heritage.h" |
42 |
|
|
43 |
|
#include "mgt/mgt_param.h" |
44 |
|
#include "vav.h" |
45 |
|
#include "vcli_serve.h" |
46 |
|
|
47 |
|
struct plist { |
48 |
|
unsigned magic; |
49 |
|
#define PLIST_MAGIC 0xbfc3ea16 |
50 |
|
VTAILQ_ENTRY(plist) list; |
51 |
|
struct parspec *spec; |
52 |
|
}; |
53 |
|
|
54 |
|
static VTAILQ_HEAD(, plist) phead = VTAILQ_HEAD_INITIALIZER(phead); |
55 |
|
|
56 |
|
struct params mgt_param; |
57 |
|
static const int margin1 = 8; |
58 |
|
static int margin2 = 0; |
59 |
|
static const int wrap_at = 72; |
60 |
|
static const int tab0 = 3; |
61 |
|
|
62 |
|
/*--------------------------------------------------------------------*/ |
63 |
|
|
64 |
|
static const char TYPE_TIMEOUT_TEXT[] = |
65 |
|
"\n\n" |
66 |
|
"NB: This parameter can be disabled with the value \"never\"."; |
67 |
|
|
68 |
|
static const char OBJ_STICKY_TEXT[] = |
69 |
|
"\n\n" |
70 |
|
"NB: This parameter is evaluated only when objects are created. " |
71 |
|
"To change it for all objects, restart or ban everything."; |
72 |
|
|
73 |
|
static const char DELAYED_EFFECT_TEXT[] = |
74 |
|
"\n\n" |
75 |
|
"NB: This parameter may take quite some time to take (full) effect."; |
76 |
|
|
77 |
|
static const char MUST_RESTART_TEXT[] = |
78 |
|
"\n\n" |
79 |
|
"NB: This parameter will not take any effect until the " |
80 |
|
"child process has been restarted."; |
81 |
|
|
82 |
|
static const char MUST_RELOAD_TEXT[] = |
83 |
|
"\n\n" |
84 |
|
"NB: This parameter will not take any effect until the " |
85 |
|
"VCL programs have been reloaded."; |
86 |
|
|
87 |
|
static const char EXPERIMENTAL_TEXT[] = |
88 |
|
"\n\n" |
89 |
|
"NB: We do not know yet if it is a good idea to change " |
90 |
|
"this parameter, or if the default value is even sensible. " |
91 |
|
"Caution is advised, and feedback is most welcome."; |
92 |
|
|
93 |
|
static const char WIZARD_TEXT[] = |
94 |
|
"\n\n" |
95 |
|
"NB: Do not change this parameter, unless a developer tell " |
96 |
|
"you to do so."; |
97 |
|
|
98 |
|
static const char PROTECTED_TEXT[] = |
99 |
|
"\n\n" |
100 |
|
"NB: This parameter is protected and cannot be changed."; |
101 |
|
|
102 |
|
static const char ONLY_ROOT_TEXT[] = |
103 |
|
"\n\n" |
104 |
|
"NB: This parameter only works if varnishd is run as root."; |
105 |
|
|
106 |
|
static const char NOT_IMPLEMENTED_TEXT[] = |
107 |
|
"\n\n" |
108 |
|
"NB: This parameter depends on a feature which is not available" |
109 |
|
" on this platform."; |
110 |
|
|
111 |
|
static const char PLATFORM_DEPENDENT_TEXT[] = |
112 |
|
"\n\n" |
113 |
|
"NB: This parameter depends on a feature which is not available" |
114 |
|
" on all platforms."; |
115 |
|
|
116 |
|
static const char BUILD_OPTIONS_TEXT[] = |
117 |
|
"\n\n" |
118 |
|
"NB: The actual default value for this parameter depends on the" |
119 |
|
" Varnish build environment and options."; |
120 |
|
|
121 |
|
/*--------------------------------------------------------------------*/ |
122 |
|
|
123 |
|
static struct parspec * |
124 |
46724 |
mcf_findpar(const char *name) |
125 |
|
{ |
126 |
|
struct plist *pl; |
127 |
|
|
128 |
46724 |
AN(name); |
129 |
4443782 |
VTAILQ_FOREACH(pl, &phead, list) |
130 |
4443778 |
if (!strcmp(pl->spec->name, name)) |
131 |
46720 |
return (pl->spec); |
132 |
4 |
return (NULL); |
133 |
46724 |
} |
134 |
|
|
135 |
|
static void |
136 |
129084 |
mcf_addpar(struct parspec *ps) |
137 |
|
{ |
138 |
|
struct plist *pl, *pl2; |
139 |
|
int i; |
140 |
|
|
141 |
129084 |
ALLOC_OBJ(pl, PLIST_MAGIC); |
142 |
129084 |
AN(pl); |
143 |
129084 |
pl->spec = ps; |
144 |
6161679 |
VTAILQ_FOREACH(pl2, &phead, list) { |
145 |
6141900 |
i = strcmp(pl2->spec->name, pl->spec->name); |
146 |
6141900 |
if (i == 0) { |
147 |
0 |
fprintf(stderr, "Duplicate param: %s\n", ps->name); |
148 |
0 |
exit(4); |
149 |
6141900 |
} else if (i > 0) { |
150 |
109305 |
VTAILQ_INSERT_BEFORE(pl2, pl, list); |
151 |
109305 |
return; |
152 |
|
} |
153 |
6032595 |
} |
154 |
19779 |
VTAILQ_INSERT_TAIL(&phead, pl, list); |
155 |
129084 |
} |
156 |
|
|
157 |
|
static const struct parspec * |
158 |
6 |
mcf_alias(struct parspec *alias, const struct parspec *pp) |
159 |
|
{ |
160 |
|
const struct parspec *orig; |
161 |
|
|
162 |
6 |
orig = TRUST_ME(pp->priv); |
163 |
6 |
AN(orig); |
164 |
6 |
memcpy(alias, orig, sizeof *alias); |
165 |
6 |
alias->priv = TRUST_ME(orig); |
166 |
6 |
return (alias); |
167 |
|
} |
168 |
|
|
169 |
|
/*-------------------------------------------------------------------- |
170 |
|
* Wrap the text nicely. |
171 |
|
* Lines are allowed to contain two TABS and we render that as a table |
172 |
|
* taking the width of the first column into account. |
173 |
|
*/ |
174 |
|
|
175 |
|
static void |
176 |
2621 |
mcf_wrap_line(struct cli *cli, const char *b, const char *e, int tabs, int m0) |
177 |
|
{ |
178 |
2621 |
int n, hadtabs = 0; |
179 |
|
const char *w; |
180 |
|
|
181 |
2621 |
n = m0; |
182 |
2621 |
VCLI_Out(cli, "%*s", n, ""); |
183 |
|
|
184 |
38755 |
while (b < e) { |
185 |
37439 |
if (!isspace(*b)) { |
186 |
18173 |
VCLI_Out(cli, "%c", *b); |
187 |
18173 |
b++; |
188 |
18173 |
n++; |
189 |
37439 |
} else if (*b == '\t') { |
190 |
564 |
assert(tabs); |
191 |
564 |
assert(hadtabs < 2); |
192 |
564 |
do { |
193 |
4407 |
VCLI_Out(cli, " "); |
194 |
4407 |
n++; |
195 |
4407 |
} while ((n % tabs) != (m0 + tab0) % tabs); |
196 |
564 |
b++; |
197 |
564 |
hadtabs++; |
198 |
564 |
} else { |
199 |
18702 |
assert (*b == ' '); |
200 |
112113 |
for (w = b + 1; w < e; w++) |
201 |
110797 |
if (isspace(*w)) |
202 |
17386 |
break; |
203 |
18702 |
if (n + (w - b) < wrap_at) { |
204 |
17397 |
VCLI_Out(cli, "%.*s", (int)(w - b), b); |
205 |
17397 |
n += (w - b); |
206 |
17397 |
b = w; |
207 |
17397 |
} else { |
208 |
1305 |
assert(hadtabs == 0 || hadtabs == 2); |
209 |
1305 |
VCLI_Out(cli, "\n"); |
210 |
2610 |
mcf_wrap_line(cli, b + 1, e, 0, |
211 |
1305 |
hadtabs ? m0 + tab0 + tabs : m0); |
212 |
1305 |
return; |
213 |
|
} |
214 |
|
} |
215 |
|
} |
216 |
1316 |
assert(b == e); |
217 |
2621 |
} |
218 |
|
|
219 |
|
static void |
220 |
641 |
mcf_wrap(struct cli *cli, const char *text) |
221 |
|
{ |
222 |
|
const char *p, *q, *r; |
223 |
641 |
int tw = 0; |
224 |
|
|
225 |
641 |
if (strchr(text, '\t') != NULL) { |
226 |
318 |
for (p = text; *p != '\0'; ) { |
227 |
318 |
q = strstr(p, "\n\t"); |
228 |
318 |
if (q == NULL) |
229 |
36 |
break; |
230 |
282 |
q += 2; |
231 |
282 |
r = strchr(q, '\t'); |
232 |
282 |
if (r == NULL) { |
233 |
0 |
fprintf(stderr, |
234 |
0 |
"LINE with just one TAB: <%s>\n", text); |
235 |
0 |
exit(4); |
236 |
|
} |
237 |
282 |
if (r - q > tw) |
238 |
101 |
tw = r - q; |
239 |
282 |
p = q; |
240 |
|
} |
241 |
36 |
tw += 2; |
242 |
36 |
if (tw < 20) |
243 |
31 |
tw = 20; |
244 |
36 |
} |
245 |
|
|
246 |
3359 |
for (p = text; *p != '\0'; ) { |
247 |
2718 |
if (*p == '\n') { |
248 |
1402 |
VCLI_Out(cli, "\n"); |
249 |
1402 |
p++; |
250 |
1402 |
continue; |
251 |
|
} |
252 |
1316 |
q = strchr(p, '\n'); |
253 |
1316 |
if (q == NULL) |
254 |
641 |
q = strchr(p, '\0'); |
255 |
1316 |
mcf_wrap_line(cli, p, q, tw, margin1); |
256 |
1316 |
p = q; |
257 |
|
} |
258 |
641 |
} |
259 |
|
|
260 |
|
/*--------------------------------------------------------------------*/ |
261 |
|
|
262 |
|
static void v_matchproto_(cli_func_t) |
263 |
33 |
mcf_param_show(struct cli *cli, const char * const *av, void *priv) |
264 |
|
{ |
265 |
|
struct plist *pl; |
266 |
|
const struct parspec *pp, *pa; |
267 |
|
struct parspec alias[1]; |
268 |
33 |
int n, lfmt = 0, chg = 0; |
269 |
|
struct vsb *vsb; |
270 |
33 |
const char *show = NULL; |
271 |
|
|
272 |
33 |
(void)priv; |
273 |
|
|
274 |
60 |
for (n = 2; av[n] != NULL; n++) { |
275 |
28 |
if (strcmp(av[n], "-l") == 0) { |
276 |
3 |
lfmt = 1; |
277 |
3 |
continue; |
278 |
|
} |
279 |
25 |
if (strcmp(av[n], "changed") == 0) { |
280 |
1 |
chg = 1; |
281 |
1 |
continue; |
282 |
|
} |
283 |
24 |
if (show != NULL) { |
284 |
1 |
VCLI_SetResult(cli, CLIS_TOOMANY); |
285 |
1 |
VCLI_Out(cli, "Too many parameters"); |
286 |
1 |
return; |
287 |
|
} |
288 |
23 |
show = av[n]; |
289 |
23 |
lfmt = 1; |
290 |
23 |
} |
291 |
|
|
292 |
32 |
vsb = VSB_new_auto(); |
293 |
32 |
AN(vsb); |
294 |
|
|
295 |
32 |
n = 0; |
296 |
4000 |
VTAILQ_FOREACH(pl, &phead, list) { |
297 |
3968 |
pp = pl->spec; |
298 |
3968 |
if (lfmt && show != NULL && strcmp(pp->name, show)) |
299 |
2707 |
continue; |
300 |
1261 |
if (pp->func == tweak_alias) { |
301 |
44 |
if (show == NULL) |
302 |
40 |
continue; |
303 |
4 |
if (strcmp(pp->name, show)) |
304 |
0 |
continue; |
305 |
4 |
pp = mcf_alias(alias, pp); |
306 |
4 |
} |
307 |
1221 |
n++; |
308 |
|
|
309 |
1221 |
VSB_clear(vsb); |
310 |
1221 |
if (pp->func(vsb, pp, NULL)) |
311 |
0 |
VCLI_SetResult(cli, CLIS_PARAM); |
312 |
1221 |
AZ(VSB_finish(vsb)); |
313 |
1221 |
if (chg && pp->def != NULL && !strcmp(pp->def, VSB_data(vsb))) |
314 |
108 |
continue; |
315 |
|
|
316 |
1113 |
if (pp->flags & NOT_IMPLEMENTED) { |
317 |
0 |
if (lfmt) { |
318 |
0 |
VCLI_Out(cli, "%s\n", pp->name); |
319 |
0 |
VCLI_Out(cli, "%-*sNot available", margin1, " "); |
320 |
0 |
} else { |
321 |
0 |
VCLI_Out(cli, "%-*s-", margin2, pp->name); |
322 |
|
} |
323 |
0 |
} else { |
324 |
1113 |
if (lfmt) { |
325 |
381 |
VCLI_Out(cli, "%s\n", pp->name); |
326 |
381 |
VCLI_Out(cli, "%-*sValue is: ", margin1, " "); |
327 |
381 |
} else { |
328 |
732 |
VCLI_Out(cli, "%-*s", margin2, pp->name); |
329 |
|
} |
330 |
|
|
331 |
1113 |
VCLI_Out(cli, "%s", VSB_data(vsb)); |
332 |
1113 |
if (pp->units != NULL && *pp->units != '\0') |
333 |
890 |
VCLI_Out(cli, " [%s]", pp->units); |
334 |
1113 |
if (pp->def != NULL && !strcmp(pp->def, VSB_data(vsb))) |
335 |
999 |
VCLI_Out(cli, " (default)"); |
336 |
|
} |
337 |
1113 |
VCLI_Out(cli, "\n"); |
338 |
|
|
339 |
1113 |
if (lfmt && pp->func == tweak_alias) { |
340 |
0 |
pa = TRUST_ME(pp->priv); |
341 |
0 |
VCLI_Out(cli, "%-*sAlias of: %s\n", |
342 |
0 |
margin1, " ", pa->name); |
343 |
0 |
} |
344 |
1113 |
if (lfmt && pp->flags & NOT_IMPLEMENTED) { |
345 |
0 |
VCLI_Out(cli, "\n"); |
346 |
0 |
mcf_wrap(cli, NOT_IMPLEMENTED_TEXT); |
347 |
0 |
VCLI_Out(cli, "\n\n"); |
348 |
1113 |
} else if (lfmt) { |
349 |
381 |
if (pp->def != NULL && strcmp(pp->def, VSB_data(vsb))) |
350 |
86 |
VCLI_Out(cli, "%-*sDefault is: %s\n", |
351 |
43 |
margin1, "", pp->def); |
352 |
381 |
if (pp->min != NULL) |
353 |
592 |
VCLI_Out(cli, "%-*sMinimum is: %s\n", |
354 |
296 |
margin1, "", pp->min); |
355 |
381 |
if (pp->max != NULL) |
356 |
174 |
VCLI_Out(cli, "%-*sMaximum is: %s\n", |
357 |
87 |
margin1, "", pp->max); |
358 |
381 |
VCLI_Out(cli, "\n"); |
359 |
381 |
mcf_wrap(cli, pp->descr); |
360 |
381 |
if (pp->func == tweak_timeout) |
361 |
40 |
mcf_wrap(cli, TYPE_TIMEOUT_TEXT); |
362 |
381 |
if (pp->flags & OBJ_STICKY) |
363 |
13 |
mcf_wrap(cli, OBJ_STICKY_TEXT); |
364 |
381 |
if (pp->flags & DELAYED_EFFECT) |
365 |
54 |
mcf_wrap(cli, DELAYED_EFFECT_TEXT); |
366 |
381 |
if (pp->flags & EXPERIMENTAL) |
367 |
90 |
mcf_wrap(cli, EXPERIMENTAL_TEXT); |
368 |
381 |
if (pp->flags & MUST_RELOAD) |
369 |
7 |
mcf_wrap(cli, MUST_RELOAD_TEXT); |
370 |
381 |
if (pp->flags & MUST_RESTART) |
371 |
24 |
mcf_wrap(cli, MUST_RESTART_TEXT); |
372 |
381 |
if (pp->flags & WIZARD) |
373 |
18 |
mcf_wrap(cli, WIZARD_TEXT); |
374 |
381 |
if (pp->flags & PROTECTED) |
375 |
1 |
mcf_wrap(cli, PROTECTED_TEXT); |
376 |
381 |
if (pp->flags & ONLY_ROOT) |
377 |
0 |
mcf_wrap(cli, ONLY_ROOT_TEXT); |
378 |
381 |
if (pp->flags & BUILD_OPTIONS) |
379 |
13 |
mcf_wrap(cli, BUILD_OPTIONS_TEXT); |
380 |
381 |
VCLI_Out(cli, "\n\n"); |
381 |
381 |
} |
382 |
1113 |
} |
383 |
32 |
if (show != NULL && n == 0) { |
384 |
1 |
VCLI_SetResult(cli, CLIS_PARAM); |
385 |
1 |
VCLI_Out(cli, "Unknown parameter \"%s\".", show); |
386 |
1 |
} |
387 |
32 |
VSB_destroy(&vsb); |
388 |
33 |
} |
389 |
|
|
390 |
|
static inline void |
391 |
1248 |
mcf_json_key_valstr(struct cli *cli, const char *key, const char *val) |
392 |
|
{ |
393 |
1248 |
VCLI_Out(cli, "\"%s\": ", key); |
394 |
1248 |
VCLI_JSON_str(cli, val); |
395 |
1248 |
VCLI_Out(cli, ",\n"); |
396 |
1248 |
} |
397 |
|
|
398 |
|
static void v_matchproto_(cli_func_t) |
399 |
15 |
mcf_param_show_json(struct cli *cli, const char * const *av, void *priv) |
400 |
|
{ |
401 |
15 |
int n, comma = 0, chg = 0; |
402 |
|
struct plist *pl; |
403 |
|
const struct parspec *pp, *pa; |
404 |
|
struct parspec alias[1]; |
405 |
|
struct vsb *vsb, *def; |
406 |
15 |
const char *show = NULL, *sep; |
407 |
|
|
408 |
15 |
(void)priv; |
409 |
|
|
410 |
42 |
for (int i = 2; av[i] != NULL; i++) { |
411 |
29 |
if (strcmp(av[i], "-l") == 0) { |
412 |
1 |
VCLI_SetResult(cli, CLIS_PARAM); |
413 |
1 |
VCLI_Out(cli, "-l not permitted with param.show -j"); |
414 |
1 |
return; |
415 |
|
} |
416 |
28 |
if (strcmp(av[i], "changed") == 0) { |
417 |
1 |
chg = 1; |
418 |
1 |
continue; |
419 |
|
} |
420 |
27 |
if (strcmp(av[i], "-j") == 0) |
421 |
15 |
continue; |
422 |
12 |
if (show != NULL) { |
423 |
1 |
VCLI_SetResult(cli, CLIS_TOOMANY); |
424 |
1 |
VCLI_Out(cli, "Too many parameters"); |
425 |
1 |
return; |
426 |
|
} |
427 |
11 |
show = av[i]; |
428 |
11 |
} |
429 |
|
|
430 |
13 |
vsb = VSB_new_auto(); |
431 |
13 |
AN(vsb); |
432 |
13 |
def = VSB_new_auto(); |
433 |
13 |
AN(def); |
434 |
|
|
435 |
13 |
n = 0; |
436 |
13 |
VCLI_JSON_begin(cli, 2, av); |
437 |
13 |
VCLI_Out(cli, ",\n"); |
438 |
1625 |
VTAILQ_FOREACH(pl, &phead, list) { |
439 |
1612 |
pp = pl->spec; |
440 |
1612 |
if (show != NULL && strcmp(pp->name, show) != 0) |
441 |
1231 |
continue; |
442 |
381 |
if (pp->func == tweak_alias) { |
443 |
13 |
if (show == NULL) |
444 |
12 |
continue; |
445 |
1 |
if (strcmp(pp->name, show)) |
446 |
0 |
continue; |
447 |
1 |
pp = mcf_alias(alias, pp); |
448 |
1 |
} |
449 |
369 |
n++; |
450 |
|
|
451 |
369 |
VSB_clear(vsb); |
452 |
369 |
if (pp->func(vsb, pp, JSON_FMT)) |
453 |
0 |
VCLI_SetResult(cli, CLIS_PARAM); |
454 |
369 |
AZ(VSB_finish(vsb)); |
455 |
369 |
VSB_clear(def); |
456 |
369 |
if (pp->func(def, pp, NULL)) |
457 |
0 |
VCLI_SetResult(cli, CLIS_PARAM); |
458 |
369 |
AZ(VSB_finish(def)); |
459 |
369 |
if (chg && pp->def != NULL && !strcmp(pp->def, VSB_data(def))) |
460 |
108 |
continue; |
461 |
|
|
462 |
261 |
VCLI_Out(cli, "%s", comma ? ",\n" : ""); |
463 |
261 |
comma++; |
464 |
261 |
VCLI_Out(cli, "{\n"); |
465 |
261 |
VSB_indent(cli->sb, 2); |
466 |
261 |
mcf_json_key_valstr(cli, "name", pp->name); |
467 |
261 |
if (pp->func == tweak_alias) { |
468 |
0 |
pa = TRUST_ME(pp->priv); |
469 |
0 |
mcf_json_key_valstr(cli, "alias", pa->name); |
470 |
0 |
} |
471 |
261 |
if (pp->flags & NOT_IMPLEMENTED) { |
472 |
0 |
VCLI_Out(cli, "\"implemented\": false\n"); |
473 |
0 |
VSB_indent(cli->sb, -2); |
474 |
0 |
VCLI_Out(cli, "}"); |
475 |
0 |
continue; |
476 |
|
} |
477 |
261 |
VCLI_Out(cli, "\"implemented\": true,\n"); |
478 |
261 |
VCLI_Out(cli, "\"value\": %s,\n", VSB_data(vsb)); |
479 |
261 |
if (pp->units != NULL && *pp->units != '\0') |
480 |
204 |
mcf_json_key_valstr(cli, "units", pp->units); |
481 |
|
|
482 |
261 |
if (pp->def != NULL) |
483 |
261 |
mcf_json_key_valstr(cli, "default", pp->def); |
484 |
261 |
if (pp->min != NULL) |
485 |
199 |
mcf_json_key_valstr(cli, "minimum", pp->min); |
486 |
261 |
if (pp->max != NULL) |
487 |
62 |
mcf_json_key_valstr(cli, "maximum", pp->max); |
488 |
261 |
mcf_json_key_valstr(cli, "description", pp->descr); |
489 |
|
|
490 |
261 |
VCLI_Out(cli, "\"flags\": ["); |
491 |
261 |
VSB_indent(cli->sb, 2); |
492 |
261 |
sep = ""; |
493 |
|
|
494 |
|
#define flag_out(flag, string) do { \ |
495 |
|
if (pp->flags & flag) { \ |
496 |
|
VCLI_Out(cli, "%s\n", sep); \ |
497 |
|
VCLI_Out(cli, "\"%s\"", #string); \ |
498 |
|
sep = ","; \ |
499 |
|
} \ |
500 |
|
} while(0) |
501 |
|
|
502 |
261 |
flag_out(OBJ_STICKY, obj_sticky); |
503 |
261 |
flag_out(DELAYED_EFFECT, delayed_effect); |
504 |
261 |
flag_out(EXPERIMENTAL, experimental); |
505 |
261 |
flag_out(MUST_RELOAD, must_reload); |
506 |
261 |
flag_out(MUST_RESTART, must_restart); |
507 |
261 |
flag_out(WIZARD, wizard); |
508 |
261 |
flag_out(PROTECTED, protected); |
509 |
261 |
flag_out(ONLY_ROOT, only_root); |
510 |
261 |
flag_out(BUILD_OPTIONS, build_options); |
511 |
|
|
512 |
|
#undef flag_out |
513 |
|
|
514 |
261 |
if (pp->flags) |
515 |
133 |
VCLI_Out(cli, "\n"); |
516 |
261 |
VSB_indent(cli->sb, -2); |
517 |
261 |
VCLI_Out(cli, "]\n"); |
518 |
261 |
VSB_indent(cli->sb, -2); |
519 |
261 |
VCLI_Out(cli, "}"); |
520 |
261 |
} |
521 |
13 |
VCLI_JSON_end(cli); |
522 |
13 |
if (show != NULL && n == 0) { |
523 |
1 |
VSB_clear(cli->sb); |
524 |
1 |
VCLI_SetResult(cli, CLIS_PARAM); |
525 |
1 |
VCLI_Out(cli, "Unknown parameter \"%s\".", show); |
526 |
1 |
} |
527 |
13 |
VSB_destroy(&vsb); |
528 |
13 |
VSB_destroy(&def); |
529 |
15 |
} |
530 |
|
|
531 |
|
/*-------------------------------------------------------------------- |
532 |
|
* Mark parameters as protected |
533 |
|
*/ |
534 |
|
|
535 |
|
void |
536 |
3 |
MCF_ParamProtect(struct cli *cli, const char *args) |
537 |
|
{ |
538 |
|
const struct parspec *orig; |
539 |
|
struct parspec *pp; |
540 |
|
char **av; |
541 |
|
int i; |
542 |
|
|
543 |
3 |
av = VAV_Parse(args, NULL, ARGV_COMMA); |
544 |
3 |
if (av[0] != NULL) { |
545 |
0 |
VCLI_Out(cli, "Parse error: %s", av[0]); |
546 |
0 |
VCLI_SetResult(cli, CLIS_PARAM); |
547 |
0 |
VAV_Free(av); |
548 |
0 |
return; |
549 |
|
} |
550 |
5 |
for (i = 1; av[i] != NULL; i++) { |
551 |
3 |
pp = mcf_findpar(av[i]); |
552 |
3 |
if (pp == NULL) { |
553 |
0 |
VCLI_Out(cli, "Unknown parameter %s", av[i]); |
554 |
0 |
VCLI_SetResult(cli, CLIS_PARAM); |
555 |
0 |
break; |
556 |
|
} |
557 |
3 |
if (pp->func == tweak_alias) { |
558 |
1 |
orig = TRUST_ME(pp->priv); |
559 |
1 |
AN(orig); |
560 |
2 |
VCLI_Out(cli, |
561 |
|
"Cannot mark alias %s read only.\n" |
562 |
|
"Did you mean to mark %s read only?", |
563 |
1 |
pp->name, orig->name); |
564 |
1 |
VCLI_SetResult(cli, CLIS_PARAM); |
565 |
1 |
break; |
566 |
|
} |
567 |
2 |
pp->flags |= PROTECTED; |
568 |
2 |
} |
569 |
3 |
VAV_Free(av); |
570 |
3 |
} |
571 |
|
|
572 |
|
/*--------------------------------------------------------------------*/ |
573 |
|
|
574 |
|
void |
575 |
9293 |
MCF_ParamSet(struct cli *cli, const char *param, const char *val) |
576 |
|
{ |
577 |
|
const struct parspec *pp; |
578 |
|
struct parspec alias[1]; |
579 |
|
|
580 |
9293 |
pp = mcf_findpar(param); |
581 |
9293 |
if (pp == NULL) { |
582 |
4 |
VCLI_SetResult(cli, CLIS_PARAM); |
583 |
4 |
VCLI_Out(cli, "Unknown parameter \"%s\".", param); |
584 |
4 |
return; |
585 |
|
} |
586 |
9289 |
if (pp->flags & NOT_IMPLEMENTED) { |
587 |
0 |
VCLI_SetResult(cli, CLIS_CANT); |
588 |
0 |
VCLI_Out(cli, |
589 |
|
"parameter \"%s\" is not available on this platform.", |
590 |
0 |
param |
591 |
|
); |
592 |
0 |
return; |
593 |
|
} |
594 |
9289 |
if (!val) |
595 |
35 |
val = pp->def; |
596 |
9289 |
if (pp->func == tweak_alias) { |
597 |
1 |
pp = mcf_alias(alias, pp); |
598 |
1 |
alias->name = param; |
599 |
1 |
} |
600 |
9289 |
if (pp->flags & PROTECTED) { |
601 |
3 |
VCLI_SetResult(cli, CLIS_AUTH); |
602 |
3 |
VCLI_Out(cli, "parameter \"%s\" is protected.", param); |
603 |
3 |
return; |
604 |
|
} |
605 |
9286 |
if (pp->func(cli->sb, pp, val)) |
606 |
29 |
VCLI_SetResult(cli, CLIS_PARAM); |
607 |
|
|
608 |
9286 |
if (cli->result == CLIS_OK && heritage.param != NULL) |
609 |
341 |
*heritage.param = mgt_param; |
610 |
|
|
611 |
9286 |
if (cli->result != CLIS_OK) { |
612 |
58 |
VCLI_Out(cli, "\n(attempting to set param '%s' to '%s')", |
613 |
29 |
pp->name, val); |
614 |
9286 |
} else if (MCH_Running() && pp->flags & MUST_RESTART) { |
615 |
0 |
VCLI_Out(cli, |
616 |
|
"\nChange will take effect when child is restarted"); |
617 |
9257 |
} else if (pp->flags & MUST_RELOAD) { |
618 |
2 |
VCLI_Out(cli, |
619 |
|
"\nChange will take effect when VCL script is reloaded"); |
620 |
2 |
} |
621 |
9293 |
} |
622 |
|
|
623 |
|
|
624 |
|
/*--------------------------------------------------------------------*/ |
625 |
|
|
626 |
|
static void v_matchproto_(cli_func_t) |
627 |
536 |
mcf_param_set(struct cli *cli, const char * const *av, void *priv) |
628 |
|
{ |
629 |
|
|
630 |
536 |
(void)priv; |
631 |
536 |
MCF_ParamSet(cli, av[2], av[3]); |
632 |
536 |
} |
633 |
|
|
634 |
|
static void v_matchproto_(cli_func_t) |
635 |
6 |
mcf_param_set_json(struct cli *cli, const char * const *av, void *priv) |
636 |
|
{ |
637 |
6 |
const char *const avs[] = { av[0], av[1], av[2], av[3], NULL }; |
638 |
|
|
639 |
6 |
MCF_ParamSet(cli, av[3], av[4]); |
640 |
6 |
if (cli->result == CLIS_OK) |
641 |
6 |
mcf_param_show_json(cli, avs, priv); |
642 |
6 |
} |
643 |
|
|
644 |
|
/*--------------------------------------------------------------------*/ |
645 |
|
|
646 |
|
static void v_matchproto_(cli_func_t) |
647 |
34 |
mcf_param_reset(struct cli *cli, const char * const *av, void *priv) |
648 |
|
{ |
649 |
|
|
650 |
34 |
(void)priv; |
651 |
34 |
MCF_ParamSet(cli, av[2], NULL); |
652 |
34 |
} |
653 |
|
|
654 |
|
/*-------------------------------------------------------------------- |
655 |
|
* Initialize parameters and sort by name. |
656 |
|
*/ |
657 |
|
|
658 |
|
static struct parspec mgt_parspec[] = { |
659 |
|
#define PARAM_ALL |
660 |
|
#define PARAM_PRE { |
661 |
|
#define PARAM(typ, fld, nm, ...) #nm, __VA_ARGS__ |
662 |
|
#define PARAM_POST }, |
663 |
|
#include "tbl/params.h" |
664 |
|
{ NULL, NULL, NULL } |
665 |
|
}; |
666 |
|
|
667 |
|
static void |
668 |
1041 |
mcf_init_params(void) |
669 |
|
{ |
670 |
|
struct parspec *pp; |
671 |
|
const char *s; |
672 |
|
|
673 |
130125 |
for (pp = mgt_parspec; pp->name != NULL; pp++) { |
674 |
129084 |
AN(pp->func); |
675 |
129084 |
s = strchr(pp->descr, '\0'); |
676 |
129084 |
if (isspace(s[-1])) { |
677 |
0 |
fprintf(stderr, |
678 |
0 |
"Param->descr has trailing space: %s\n", pp->name); |
679 |
0 |
exit(4); |
680 |
|
} |
681 |
129084 |
mcf_addpar(pp); |
682 |
129084 |
margin2 = vmax_t(int, margin2, strlen(pp->name) + 1); |
683 |
129084 |
} |
684 |
1041 |
} |
685 |
|
|
686 |
|
/*-------------------------------------------------------------------- |
687 |
|
* Wash a min/max/default value |
688 |
|
*/ |
689 |
|
|
690 |
|
static void |
691 |
89478 |
mcf_dyn_vsb(enum mcf_which_e which, struct parspec *pp, struct vsb *vsb) |
692 |
|
{ |
693 |
|
|
694 |
89478 |
switch (which) { |
695 |
|
case MCF_DEFAULT: |
696 |
29148 |
REPLACE(pp->dyn_def, VSB_data(vsb)); |
697 |
29148 |
pp->def = pp->dyn_def; |
698 |
29148 |
break; |
699 |
|
case MCF_MINIMUM: |
700 |
37434 |
REPLACE(pp->dyn_min, VSB_data(vsb)); |
701 |
37434 |
pp->min = pp->dyn_min; |
702 |
37434 |
break; |
703 |
|
case MCF_MAXIMUM: |
704 |
22896 |
REPLACE(pp->dyn_max, VSB_data(vsb)); |
705 |
22896 |
pp->max = pp->dyn_max; |
706 |
22896 |
break; |
707 |
|
default: |
708 |
0 |
WRONG("bad 'which'"); |
709 |
0 |
} |
710 |
89478 |
} |
711 |
|
|
712 |
|
static void |
713 |
258168 |
mcf_wash_param(struct cli *cli, struct parspec *pp, enum mcf_which_e which, |
714 |
|
const char *name, struct vsb *vsb) |
715 |
|
{ |
716 |
|
const char *val; |
717 |
|
int err; |
718 |
|
|
719 |
258168 |
switch (which) { |
720 |
129084 |
case MCF_DEFAULT: val = pp->def; break; |
721 |
98895 |
case MCF_MINIMUM: val = pp->min; break; |
722 |
30189 |
case MCF_MAXIMUM: val = pp->max; break; |
723 |
|
default: |
724 |
0 |
WRONG("bad 'which'"); |
725 |
0 |
} |
726 |
258168 |
AN(val); |
727 |
|
|
728 |
258168 |
if (pp->func == tweak_alias) { |
729 |
4164 |
assert(which == MCF_DEFAULT); |
730 |
4164 |
pp->priv = mcf_findpar(pp->def); |
731 |
4164 |
pp->def = NULL; |
732 |
4164 |
return; |
733 |
|
} |
734 |
|
|
735 |
254004 |
VSB_clear(vsb); |
736 |
508008 |
VSB_printf(vsb, "FAILED to set %s for param %s: %s\n", |
737 |
254004 |
name, pp->name, val); |
738 |
254004 |
err = pp->func(vsb, pp, val); |
739 |
254004 |
AZ(VSB_finish(vsb)); |
740 |
254004 |
if (err) { |
741 |
0 |
VCLI_Out(cli, "%s\n", VSB_data(vsb)); |
742 |
0 |
VCLI_SetResult(cli, CLIS_CANT); |
743 |
0 |
return; |
744 |
|
} |
745 |
254004 |
VSB_clear(vsb); |
746 |
254004 |
err = pp->func(vsb, pp, NULL); |
747 |
254004 |
AZ(err); |
748 |
254004 |
AZ(VSB_finish(vsb)); |
749 |
254004 |
if (strcmp(val, VSB_data(vsb))) |
750 |
56214 |
mcf_dyn_vsb(which, pp, vsb); |
751 |
258168 |
} |
752 |
|
|
753 |
|
/*--------------------------------------------------------------------*/ |
754 |
|
|
755 |
|
static struct cli_proto cli_params[] = { |
756 |
|
{ CLICMD_PARAM_SHOW, "", mcf_param_show, mcf_param_show_json }, |
757 |
|
{ CLICMD_PARAM_SET, "", mcf_param_set, mcf_param_set_json }, |
758 |
|
{ CLICMD_PARAM_RESET, "", mcf_param_reset, mcf_param_set_json }, |
759 |
|
{ NULL } |
760 |
|
}; |
761 |
|
|
762 |
|
/*-------------------------------------------------------------------- |
763 |
|
* Configure the parameters |
764 |
|
*/ |
765 |
|
|
766 |
|
void |
767 |
1041 |
MCF_InitParams(struct cli *cli) |
768 |
|
{ |
769 |
|
struct plist *pl; |
770 |
|
struct parspec *pp; |
771 |
|
struct vsb *vsb; |
772 |
|
ssize_t def, low; |
773 |
|
|
774 |
1041 |
mcf_init_params(); |
775 |
1041 |
MCF_TcpParams(); |
776 |
|
|
777 |
1041 |
def = 80 * 1024; |
778 |
|
|
779 |
|
if (sizeof(void *) < 8) { /*lint !e506 !e774 */ |
780 |
|
/* |
781 |
|
* Adjust default parameters for 32 bit systems to conserve |
782 |
|
* VM space. |
783 |
|
* |
784 |
|
* Reflect changes in doc/sphinx/reference/varnishd.rst ! |
785 |
|
*/ |
786 |
|
MCF_ParamConf(MCF_DEFAULT, "workspace_client", "24k"); |
787 |
|
MCF_ParamConf(MCF_DEFAULT, "workspace_backend", "20k"); |
788 |
|
MCF_ParamConf(MCF_DEFAULT, "http_resp_size", "8k"); |
789 |
|
MCF_ParamConf(MCF_DEFAULT, "http_req_size", "12k"); |
790 |
|
MCF_ParamConf(MCF_DEFAULT, "gzip_buffer", "4k"); |
791 |
|
MCF_ParamConf(MCF_DEFAULT, "vsl_buffer", "4k"); |
792 |
|
MCF_ParamConf(MCF_MAXIMUM, "vsl_space", "1G"); |
793 |
|
def = 64 * 1024; |
794 |
|
} |
795 |
|
|
796 |
1041 |
low = sysconf(_SC_THREAD_STACK_MIN); |
797 |
1041 |
MCF_ParamConf(MCF_MINIMUM, "thread_pool_stack", "%jdb", (intmax_t)low); |
798 |
|
|
799 |
|
#if defined(ENABLE_SANITIZER) || defined(ENABLE_COVERAGE) |
800 |
1041 |
def = 192 * 1024; |
801 |
|
#endif |
802 |
|
|
803 |
1041 |
if (def < low) |
804 |
0 |
def = low; |
805 |
1041 |
MCF_ParamConf(MCF_DEFAULT, "thread_pool_stack", "%jdb", (intmax_t)def); |
806 |
|
|
807 |
|
#if !defined(MAX_THREAD_POOLS) |
808 |
|
# define MAX_THREAD_POOLS 32 |
809 |
|
#endif |
810 |
|
|
811 |
1041 |
MCF_ParamConf(MCF_MAXIMUM, "thread_pools", "%d", MAX_THREAD_POOLS); |
812 |
|
|
813 |
|
#if !defined(HAVE_ACCEPT_FILTERS) || defined(__linux) |
814 |
|
MCF_ParamConf(MCF_DEFAULT, "accept_filter", "off"); |
815 |
|
#endif |
816 |
|
|
817 |
1041 |
VCLS_AddFunc(mgt_cls, MCF_AUTH, cli_params); |
818 |
|
|
819 |
1041 |
vsb = VSB_new_auto(); |
820 |
1041 |
AN(vsb); |
821 |
|
|
822 |
130125 |
VTAILQ_FOREACH(pl, &phead, list) { |
823 |
129084 |
pp = pl->spec; |
824 |
|
|
825 |
129084 |
if (pp->flags & NOT_IMPLEMENTED) |
826 |
0 |
continue; |
827 |
129084 |
if (pp->min != NULL) |
828 |
98895 |
mcf_wash_param(cli, pp, MCF_MINIMUM, "minimum", vsb); |
829 |
129084 |
if (pp->max != NULL) |
830 |
30189 |
mcf_wash_param(cli, pp, MCF_MAXIMUM, "maximum", vsb); |
831 |
129084 |
AN(pp->def); |
832 |
129084 |
mcf_wash_param(cli, pp, MCF_DEFAULT, "default", vsb); |
833 |
129084 |
} |
834 |
1041 |
VSB_destroy(&vsb); |
835 |
|
|
836 |
1041 |
AN(mgt_cc_cmd); |
837 |
1041 |
REPLACE(mgt_cc_cmd_def, mgt_cc_cmd); |
838 |
1041 |
} |
839 |
|
|
840 |
|
/*--------------------------------------------------------------------*/ |
841 |
|
|
842 |
|
void |
843 |
33264 |
MCF_ParamConf(enum mcf_which_e which, const char * const param, |
844 |
|
const char *fmt, ...) |
845 |
|
{ |
846 |
|
struct parspec *pp; |
847 |
|
struct vsb *vsb; |
848 |
|
va_list ap; |
849 |
|
|
850 |
33264 |
pp = mcf_findpar(param); |
851 |
33264 |
AN(pp); |
852 |
33264 |
vsb = VSB_new_auto(); |
853 |
33264 |
AN(vsb); |
854 |
33264 |
va_start(ap, fmt); |
855 |
33264 |
VSB_vprintf(vsb, fmt, ap); |
856 |
33264 |
va_end(ap); |
857 |
33264 |
AZ(VSB_finish(vsb)); |
858 |
33264 |
mcf_dyn_vsb(which, pp, vsb); |
859 |
33264 |
VSB_destroy(&vsb); |
860 |
33264 |
} |
861 |
|
|
862 |
|
/*--------------------------------------------------------------------*/ |
863 |
|
|
864 |
|
void |
865 |
2 |
MCF_DumpRstParam(void) |
866 |
|
{ |
867 |
|
struct plist *pl; |
868 |
|
const struct parspec *pp; |
869 |
|
const char *p, *q, *t1, *t2; |
870 |
|
unsigned flags; |
871 |
|
size_t z; |
872 |
|
|
873 |
2 |
printf("\n.. The following is the autogenerated " |
874 |
|
"output from varnishd -x parameter\n\n"); |
875 |
250 |
VTAILQ_FOREACH(pl, &phead, list) { |
876 |
248 |
pp = pl->spec; |
877 |
248 |
if (!strcmp("deprecated_dummy", pp->name)) |
878 |
2 |
continue; |
879 |
246 |
printf(".. _ref_param_%s:\n\n", pp->name); |
880 |
246 |
printf("%s\n", pp->name); |
881 |
3934 |
for (z = 0; z < strlen(pp->name); z++) |
882 |
3688 |
printf("~"); |
883 |
246 |
printf("\n"); |
884 |
|
|
885 |
246 |
if (pp->flags && pp->flags & PLATFORM_DEPENDENT) |
886 |
10 |
printf("\n%s\n\n", PLATFORM_DEPENDENT_TEXT); |
887 |
|
|
888 |
246 |
if (pp->flags && pp->flags & BUILD_OPTIONS) |
889 |
8 |
printf("\n%s\n\n", BUILD_OPTIONS_TEXT); |
890 |
|
|
891 |
246 |
if (pp->units != NULL && *pp->units != '\0') |
892 |
194 |
printf("\t* Units: %s\n", pp->units); |
893 |
|
#define MCF_DYN_REASON(lbl, nm) \ |
894 |
|
if (pp->dyn_ ## nm ## _reason != NULL) \ |
895 |
|
printf("\t* " #lbl ": %s\n", \ |
896 |
|
pp->dyn_ ## nm ## _reason); \ |
897 |
|
else if (pp->nm != NULL) \ |
898 |
|
printf("\t* " #lbl ": %s\n", pp->nm); |
899 |
246 |
MCF_DYN_REASON(Default, def); |
900 |
246 |
MCF_DYN_REASON(Minimum, min); |
901 |
246 |
MCF_DYN_REASON(Maximum, max); |
902 |
|
#undef MCF_DYN_REASON |
903 |
246 |
flags = pp->flags & ~DOCS_FLAGS; |
904 |
246 |
if (pp->func == tweak_timeout) |
905 |
22 |
flags |= TYPE_TIMEOUT; |
906 |
246 |
if (flags) { |
907 |
136 |
printf("\t* Flags: "); |
908 |
136 |
q = ""; |
909 |
|
|
910 |
136 |
if (flags & TYPE_TIMEOUT) { |
911 |
22 |
printf("%stimeout", q); |
912 |
22 |
q = ", "; |
913 |
22 |
} |
914 |
136 |
if (flags & DELAYED_EFFECT) { |
915 |
36 |
printf("%sdelayed", q); |
916 |
36 |
q = ", "; |
917 |
36 |
} |
918 |
136 |
if (flags & MUST_RESTART) { |
919 |
16 |
printf("%smust_restart", q); |
920 |
16 |
q = ", "; |
921 |
16 |
} |
922 |
136 |
if (flags & MUST_RELOAD) { |
923 |
4 |
printf("%smust_reload", q); |
924 |
4 |
q = ", "; |
925 |
4 |
} |
926 |
136 |
if (flags & EXPERIMENTAL) { |
927 |
60 |
printf("%sexperimental", q); |
928 |
60 |
q = ", "; |
929 |
60 |
} |
930 |
136 |
if (flags & WIZARD) { |
931 |
12 |
printf("%swizard", q); |
932 |
12 |
q = ", "; |
933 |
12 |
} |
934 |
136 |
if (flags & ONLY_ROOT) { |
935 |
0 |
printf("%sonly_root", q); |
936 |
0 |
q = ", "; |
937 |
0 |
} |
938 |
136 |
if (flags & OBJ_STICKY) { |
939 |
8 |
printf("%sobj_sticky", q); |
940 |
8 |
q = ", "; |
941 |
8 |
} |
942 |
136 |
printf("\n"); |
943 |
136 |
} |
944 |
246 |
printf("\n"); |
945 |
246 |
p = pp->descr; |
946 |
978 |
while (*p != '\0') { |
947 |
732 |
q = strchr(p, '\n'); |
948 |
732 |
if (q == NULL) |
949 |
246 |
q = strchr(p, '\0'); |
950 |
732 |
t1 = strchr(p, '\t'); |
951 |
732 |
if (t1 != NULL && t1 < q) { |
952 |
110 |
t2 = strchr(t1 + 1, '\t'); |
953 |
110 |
AN(t2); |
954 |
110 |
printf("\n\t*"); |
955 |
110 |
(void)fwrite(t1 + 1, (t2 - 1) - t1, 1, stdout); |
956 |
110 |
printf("*\n\t\t"); |
957 |
110 |
p = t2 + 1; |
958 |
110 |
} |
959 |
732 |
(void)fwrite(p, q - p, 1, stdout); |
960 |
732 |
p = q; |
961 |
732 |
if (*p == '\n') { |
962 |
486 |
printf("\n"); |
963 |
486 |
p++; |
964 |
486 |
} |
965 |
732 |
continue; |
966 |
|
} |
967 |
246 |
printf("\n\n"); |
968 |
246 |
} |
969 |
2 |
} |