[experimental-ims] 878036c Revert "Add support for JSON output format". Work in progress, pushed in wrong direction.

Geoff Simmons geoff at varnish-cache.org
Mon Jan 9 21:52:29 CET 2012


commit 878036c77425393f58a53d05b5de97d063a7cddf
Author: Lasse Karstensen <lasse at varnish-software.com>
Date:   Thu Nov 3 19:24:37 2011 +0100

    Revert "Add support for JSON output format". Work in progress, pushed in wrong direction.
    
    This reverts commit 5f45e4ca4996027638a0b28949aed68ffe7eaf8c.

diff --git a/bin/varnishstat/varnishstat.c b/bin/varnishstat/varnishstat.c
index 00ddda8..3c6c4b5 100644
--- a/bin/varnishstat/varnishstat.c
+++ b/bin/varnishstat/varnishstat.c
@@ -82,60 +82,6 @@ do_xml(struct VSM_data *vd)
 	printf("</varnishstat>\n");
 }
 
-
-/*--------------------------------------------------------------------*/
-
-struct json_priv {
-	int first;
-};
-
-static int
-do_json_cb(void *priv, const struct VSC_point * const pt)
-{
-	uint64_t val;
-	struct json_priv *jp;
-	jp = priv;
-
-	assert(!strcmp(pt->fmt, "uint64_t"));
-	val = *(const volatile uint64_t*)pt->ptr;
-
-	if (jp->first ) jp->first = 0; else printf(",\n");
-	printf("\t\"%s\": {", pt->name);
-	if (strcmp(pt->class, ""))
-		printf("\t\t\"type\": \"%s\",\n", pt->class);
-	if (strcmp(pt->ident, ""))
-		printf("\t\t\"ident\": \"%s\",\n", pt->ident);
-	printf("\"value\": %ju, ", val);
-
-	printf("\"flag\": \"%c\",", pt->flag);
-	printf("\"description\": \"%s\"", pt->desc);
-	printf("}"); // closes name section.
-	if (jp->first) printf("\n");
-	return (0);
-}
-
-static void
-do_json(struct VSM_data *vd)
-{
-	/// TODO: support jsonp?
-	char time_stamp[20];
-	time_t now;
-
-	struct json_priv jp;
-
-	memset(&jp, 0, sizeof jp);
-	jp.first = 1;
-
-	printf("{\n"); 
-	now = time(NULL);
-
-	(void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now));
-	printf("\t\"timestamp\": \"%s\",\n", time_stamp);
-	(void)VSC_Iter(vd, do_json_cb, &jp);
-	printf("\n}");
-}
-
-
 /*--------------------------------------------------------------------*/
 
 struct once_priv {
@@ -143,7 +89,6 @@ struct once_priv {
 	int pad;
 };
 
-
 static int
 do_once_cb(void *priv, const struct VSC_point * const pt)
 {
@@ -246,12 +191,12 @@ main(int argc, char * const *argv)
 	int c;
 	struct VSM_data *vd;
 	const struct VSC_C_main *VSC_C_main;
-	int delay = 1, once = 0, xml = 0, json = 0;
+	int delay = 1, once = 0, xml = 0;
 
 	vd = VSM_New();
 	VSC_Setup(vd);
 
-	while ((c = getopt(argc, argv, VSC_ARGS "1f:lVw:xj")) != -1) {
+	while ((c = getopt(argc, argv, VSC_ARGS "1f:lVw:x")) != -1) {
 		switch (c) {
 		case '1':
 			once = 1;
@@ -270,9 +215,6 @@ main(int argc, char * const *argv)
 		case 'x':
 			xml = 1;
 			break;
-		case 'j':
-			json = 1;
-			break;
 		default:
 			if (VSC_Arg(vd, c, optarg) > 0)
 				break;
@@ -287,8 +229,6 @@ main(int argc, char * const *argv)
 
 	if (xml)
 		do_xml(vd);
-	else if (json)
-		do_json(vd);
 	else if (once)
 		do_once(vd, VSC_C_main);
 	else



More information about the varnish-commit mailing list