r4935 - in trunk/varnish-cache: bin/varnishstat bin/varnishtest include lib/libvarnishapi

phk at varnish-cache.org phk at varnish-cache.org
Tue Jun 8 12:31:30 CEST 2010


Author: phk
Date: 2010-06-08 12:31:30 +0200 (Tue, 08 Jun 2010)
New Revision: 4935

Modified:
   trunk/varnish-cache/bin/varnishstat/varnishstat.c
   trunk/varnish-cache/bin/varnishstat/varnishstat_curses.c
   trunk/varnish-cache/bin/varnishtest/vtc_varnish.c
   trunk/varnish-cache/include/varnishapi.h
   trunk/varnish-cache/lib/libvarnishapi/vsc.c
   trunk/varnish-cache/lib/libvarnishapi/vsl_arg.c
Log:
More wanton renaming, this time varnishapi::VSC



Modified: trunk/varnish-cache/bin/varnishstat/varnishstat.c
===================================================================
--- trunk/varnish-cache/bin/varnishstat/varnishstat.c	2010-06-08 10:19:34 UTC (rev 4934)
+++ trunk/varnish-cache/bin/varnishstat/varnishstat.c	2010-06-08 10:31:30 UTC (rev 4935)
@@ -52,7 +52,7 @@
 /*--------------------------------------------------------------------*/
 
 static int
-do_xml_cb(void *priv, const struct vsl_statpt * const pt)
+do_xml_cb(void *priv, const struct vsc_point * const pt)
 {
 	uint64_t val;
 
@@ -83,7 +83,7 @@
 	now = time(NULL);
 	(void)strftime(time_stamp, 20, "%Y-%m-%dT%H:%M:%S", localtime(&now));
 	printf("<varnishstat timestamp=\"%s\">\n", time_stamp);
-	(void)VSL_IterStat(vd, do_xml_cb, NULL);
+	(void)VSC_Iter(vd, do_xml_cb, NULL);
 	printf("</varnishstat>\n");
 }
 
@@ -95,7 +95,7 @@
 };
 
 static int
-do_once_cb(void *priv, const struct vsl_statpt * const pt)
+do_once_cb(void *priv, const struct vsc_point * const pt)
 {
 	struct once_priv *op;
 	uint64_t val;
@@ -129,13 +129,13 @@
 	op.up = VSL_stats->uptime;
 	op.pad = 18;
 
-	(void)VSL_IterStat(vd, do_once_cb, &op);
+	(void)VSC_Iter(vd, do_once_cb, &op);
 }
 
 /*--------------------------------------------------------------------*/
 
 static int
-do_list_cb(void *priv, const struct vsl_statpt * const pt)
+do_list_cb(void *priv, const struct vsc_point * const pt)
 {
 	int i;
 
@@ -159,7 +159,7 @@
 	fprintf(stderr, "Field name                     Description\n");
 	fprintf(stderr, "----------                     -----------\n");
 
-	(void)VSL_IterStat(vd, do_list_cb, NULL);
+	(void)VSC_Iter(vd, do_list_cb, NULL);
 }
 
 /*--------------------------------------------------------------------*/
@@ -204,7 +204,7 @@
 			once = 1;
 			break;
 		case 'f':
-			(void)VSL_Stat_Arg(vd, c, optarg);
+			(void)VSC_Arg(vd, c, optarg);
 			break;
 		case 'l':
 			if (VSM_Open(vd, 1))
@@ -221,7 +221,7 @@
 			xml = 1;
 			break;
 		default:
-			if (VSL_Stat_Arg(vd, c, optarg) > 0)
+			if (VSC_Arg(vd, c, optarg) > 0)
 				break;
 			usage();
 		}

Modified: trunk/varnish-cache/bin/varnishstat/varnishstat_curses.c
===================================================================
--- trunk/varnish-cache/bin/varnishstat/varnishstat_curses.c	2010-06-08 10:19:34 UTC (rev 4934)
+++ trunk/varnish-cache/bin/varnishstat/varnishstat_curses.c	2010-06-08 10:31:30 UTC (rev 4935)
@@ -66,7 +66,7 @@
 static VTAILQ_HEAD(, pt) pthead = VTAILQ_HEAD_INITIALIZER(pthead);
 
 static int
-do_curses_cb(void *priv, const struct vsl_statpt * const sp)
+do_curses_cb(void *priv, const struct vsc_point * const sp)
 {
 	struct pt *pt;
 	char buf[128];
@@ -110,7 +110,7 @@
 		free(pt);
 	}
 
-	(void)VSL_IterStat(vd, do_curses_cb, NULL);
+	(void)VSC_Iter(vd, do_curses_cb, NULL);
 }
 
 static void

Modified: trunk/varnish-cache/bin/varnishtest/vtc_varnish.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc_varnish.c	2010-06-08 10:19:34 UTC (rev 4934)
+++ trunk/varnish-cache/bin/varnishtest/vtc_varnish.c	2010-06-08 10:31:30 UTC (rev 4935)
@@ -607,7 +607,7 @@
 };
 
 static int
-do_stat_cb(void *priv, const struct vsl_statpt * const pt)
+do_stat_cb(void *priv, const struct vsc_point * const pt)
 {
 	struct stat_priv *sp = priv;
 	const char *p = sp->target;
@@ -655,7 +655,7 @@
 	for (i = 0; i < 10; i++, (void)usleep(100000)) {
 
 		good = -1;
-		if (!VSL_IterStat(v->vd, do_stat_cb, &sp))
+		if (!VSC_Iter(v->vd, do_stat_cb, &sp))
 			continue;
 		good = 0;
 

Modified: trunk/varnish-cache/include/varnishapi.h
===================================================================
--- trunk/varnish-cache/include/varnishapi.h	2010-06-08 10:19:34 UTC (rev 4934)
+++ trunk/varnish-cache/include/varnishapi.h	2010-06-08 10:31:30 UTC (rev 4935)
@@ -68,7 +68,7 @@
 	/*
 	 * Configure which varnishd instance to access.
 	 * Can also be, and normally is done through the VSL_Log_arg()
-	 * and VSL_Stat_Arg() functions.
+	 * and VSC_Arg() functions.
 	 * Returns:
 	 *	 1 on success
 	 *	 -1 on failure, with diagnostic on stderr.
@@ -121,7 +121,31 @@
 #define VSM_FOREACH(var, vd) \
 	for((var) = vsm_iter0((vd)); (var) != NULL; vsm_itern((vd), &(var)))
 
+/*---------------------------------------------------------------------
+ * VSC level access functions
+ */
 
+int VSC_Arg(struct VSM_data *vd, int arg, const char *opt);
+struct vsc_main *VSM_OpenStats(struct VSM_data *vd);
+
+struct vsc_point {
+	const char *class;		/* stat struct type		*/
+	const char *ident;		/* stat struct ident		*/
+	const char *name;		/* field name			*/
+	const char *fmt;		/* field format ("uint64_t")	*/
+	int flag;			/* 'a' = counter, 'i' = gauge	*/
+	const char *desc;		/* description			*/
+	const volatile void *ptr;	/* field value			*/
+};
+
+typedef int vsc_iter_f(void *priv, const struct vsc_point *const pt);
+
+int VSC_Iter(const struct VSM_data *vd, vsc_iter_f *func, void *priv);
+
+/*---------------------------------------------------------------------
+ * VSL level access functions
+ */
+
 /* shmlog.c */
 typedef int vsl_handler(void *priv, enum vsl_tag tag, unsigned fd,
     unsigned len, unsigned spec, const char *ptr);
@@ -139,25 +163,9 @@
 int VSL_Dispatch(struct VSM_data *vd, vsl_handler *func, void *priv);
 int VSL_NextLog(struct VSM_data *lh, uint32_t **pp);
 int VSL_Log_Arg(struct VSM_data *vd, int arg, const char *opt);
-int VSL_Stat_Arg(struct VSM_data *vd, int arg, const char *opt);
-struct vsc_main *VSM_OpenStats(struct VSM_data *vd);
 extern const char *VSL_tags[256];
 
 
-struct vsl_statpt {
-	const char *class;	/* stat struct type			*/
-	const char *ident;	/* stat struct ident			*/
-	const char *name;	/* field name				*/
-	const char *fmt;	/* field format ("uint64_t")		*/
-	int flag;		/* 'a' = counter, 'i' = gauge		*/
-	const char *desc;	/* description				*/
-	const volatile void *ptr;	/* field value		*/
-};
-
-typedef int vsl_stat_f(void *priv, const struct vsl_statpt *const pt);
-
-int VSL_IterStat(const struct VSM_data *vd, vsl_stat_f *func, void *priv);
-
 /* base64.c */
 void base64_init(void);
 int base64_decode(char *d, unsigned dlen, const char *s);

Modified: trunk/varnish-cache/lib/libvarnishapi/vsc.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/vsc.c	2010-06-08 10:19:34 UTC (rev 4934)
+++ trunk/varnish-cache/lib/libvarnishapi/vsc.c	2010-06-08 10:31:30 UTC (rev 4935)
@@ -35,11 +35,14 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
 
 #include "vas.h"
 #include "vsm.h"
 #include "vsc.h"
 #include "vre.h"
+#include "argv.h"
 #include "vqueue.h"
 #include "miniobj.h"
 #include "varnishapi.h"
@@ -48,6 +51,101 @@
 
 /*--------------------------------------------------------------------*/
 
+static int
+vsc_sf_arg(struct VSM_data *vd, const char *opt)
+{
+	struct vsl_sf *sf;
+	char **av, *q, *p;
+	int i;
+
+	CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
+
+	if (VTAILQ_EMPTY(&vd->sf_list)) {
+		if (*opt == '^')
+			vd->sf_init = 1;
+	}
+
+	av = ParseArgv(opt, ARGV_COMMA);
+	AN(av);
+	if (av[0] != NULL) {
+		fprintf(stderr, "Parse error: %s", av[0]);
+		exit (1);
+	}
+	for (i = 1; av[i] != NULL; i++) {
+		ALLOC_OBJ(sf, VSL_SF_MAGIC);
+		AN(sf);
+		VTAILQ_INSERT_TAIL(&vd->sf_list, sf, next);
+
+		p = av[i];
+		if (*p == '^') {
+			sf->flags |= VSL_SF_EXCL;
+			p++;
+		}
+
+		q = strchr(p, '.');
+		if (q != NULL) {
+			*q++ = '\0';
+			if (*p != '\0')
+				REPLACE(sf->class, p);
+			p = q;
+			if (*p != '\0') {
+				q = strchr(p, '.');
+				if (q != NULL) {
+					*q++ = '\0';
+					if (*p != '\0')
+						REPLACE(sf->ident, p);
+					p = q;
+				}
+			}
+		}
+		if (*p != '\0') {
+			REPLACE(sf->name, p);
+		}
+
+		/* Check for wildcards */
+		if (sf->class != NULL) {
+			q = strchr(sf->class, '*');
+			if (q != NULL && q[1] == '\0') {
+				*q = '\0';
+				sf->flags |= VSL_SF_CL_WC;
+			}
+		}
+		if (sf->ident != NULL) {
+			q = strchr(sf->ident, '*');
+			if (q != NULL && q[1] == '\0') {
+				*q = '\0';
+				sf->flags |= VSL_SF_ID_WC;
+			}
+		}
+		if (sf->name != NULL) {
+			q = strchr(sf->name, '*');
+			if (q != NULL && q[1] == '\0') {
+				*q = '\0';
+				sf->flags |= VSL_SF_NM_WC;
+			}
+		}
+	}
+	FreeArgv(av);
+	return (1);
+}
+
+/*--------------------------------------------------------------------*/
+
+int
+VSC_Arg(struct VSM_data *vd, int arg, const char *opt)
+{
+
+	CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
+	switch (arg) {
+	case 'f': return (vsc_sf_arg(vd, opt));
+	case 'n': return (VSM_n_Arg(vd, opt));
+	default:
+		return (0);
+	}
+}
+
+/*--------------------------------------------------------------------*/
+
 struct vsc_main *
 VSM_OpenStats(struct VSM_data *vd)
 {
@@ -78,8 +176,8 @@
 }
 
 static int
-iter_call(const struct VSM_data *vd, vsl_stat_f *func, void *priv,
-    const struct vsl_statpt *const sp)
+iter_call(const struct VSM_data *vd, vsc_iter_f *func, void *priv,
+    const struct vsc_point *const sp)
 {
 	struct vsl_sf *sf;
 	int good = vd->sf_init;
@@ -105,11 +203,11 @@
 }
 
 static int
-iter_main(const struct VSM_data *vd, struct vsm_chunk *sha, vsl_stat_f *func,
+iter_main(const struct VSM_data *vd, struct vsm_chunk *sha, vsc_iter_f *func,
     void *priv)
 {
 	struct vsc_main *st = VSM_PTR(sha);
-	struct vsl_statpt sp;
+	struct vsc_point sp;
 	int i;
 
 	sp.class = "";
@@ -129,11 +227,11 @@
 }
 
 static int
-iter_sma(const struct VSM_data *vd, struct vsm_chunk *sha, vsl_stat_f *func,
+iter_sma(const struct VSM_data *vd, struct vsm_chunk *sha, vsc_iter_f *func,
     void *priv)
 {
 	struct vsc_sma *st = VSM_PTR(sha);
-	struct vsl_statpt sp;
+	struct vsc_point sp;
 	int i;
 
 	sp.class = VSC_TYPE_SMA;
@@ -153,7 +251,7 @@
 }
 
 int
-VSL_IterStat(const struct VSM_data *vd, vsl_stat_f *func, void *priv)
+VSC_Iter(const struct VSM_data *vd, vsc_iter_f *func, void *priv)
 {
 	struct vsm_chunk *sha;
 	int i;

Modified: trunk/varnish-cache/lib/libvarnishapi/vsl_arg.c
===================================================================
--- trunk/varnish-cache/lib/libvarnishapi/vsl_arg.c	2010-06-08 10:19:34 UTC (rev 4934)
+++ trunk/varnish-cache/lib/libvarnishapi/vsl_arg.c	2010-06-08 10:31:30 UTC (rev 4935)
@@ -225,98 +225,3 @@
 		return (0);
 	}
 }
-
-/*--------------------------------------------------------------------*/
-
-static int
-vsl_sf_arg(struct VSM_data *vd, const char *opt)
-{
-	struct vsl_sf *sf;
-	char **av, *q, *p;
-	int i;
-
-	CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
-
-	if (VTAILQ_EMPTY(&vd->sf_list)) {
-		if (*opt == '^')
-			vd->sf_init = 1;
-	}
-
-	av = ParseArgv(opt, ARGV_COMMA);
-	AN(av);
-	if (av[0] != NULL) {
-		fprintf(stderr, "Parse error: %s", av[0]);
-		exit (1);
-	}
-	for (i = 1; av[i] != NULL; i++) {
-		ALLOC_OBJ(sf, VSL_SF_MAGIC);
-		AN(sf);
-		VTAILQ_INSERT_TAIL(&vd->sf_list, sf, next);
-
-		p = av[i];
-		if (*p == '^') {
-			sf->flags |= VSL_SF_EXCL;
-			p++;
-		}
-
-		q = strchr(p, '.');
-		if (q != NULL) {
-			*q++ = '\0';
-			if (*p != '\0')
-				REPLACE(sf->class, p);
-			p = q;
-			if (*p != '\0') {
-				q = strchr(p, '.');
-				if (q != NULL) {
-					*q++ = '\0';
-					if (*p != '\0')
-						REPLACE(sf->ident, p);
-					p = q;
-				}
-			}
-		}
-		if (*p != '\0') {
-			REPLACE(sf->name, p);
-		}
-
-		/* Check for wildcards */
-		if (sf->class != NULL) {
-			q = strchr(sf->class, '*');
-			if (q != NULL && q[1] == '\0') {
-				*q = '\0';
-				sf->flags |= VSL_SF_CL_WC;
-			}
-		}
-		if (sf->ident != NULL) {
-			q = strchr(sf->ident, '*');
-			if (q != NULL && q[1] == '\0') {
-				*q = '\0';
-				sf->flags |= VSL_SF_ID_WC;
-			}
-		}
-		if (sf->name != NULL) {
-			q = strchr(sf->name, '*');
-			if (q != NULL && q[1] == '\0') {
-				*q = '\0';
-				sf->flags |= VSL_SF_NM_WC;
-			}
-		}
-	}
-	FreeArgv(av);
-	return (1);
-}
-
-/*--------------------------------------------------------------------*/
-
-int
-VSL_Stat_Arg(struct VSM_data *vd, int arg, const char *opt)
-{
-
-	CHECK_OBJ_NOTNULL(vd, VSM_MAGIC);
-	switch (arg) {
-	case 'f': return (vsl_sf_arg(vd, opt));
-	case 'n': return (VSM_n_Arg(vd, opt));
-	default:
-		return (0);
-	}
-}




More information about the varnish-commit mailing list