r5504 - trunk/varnish-cache/bin/varnishtest

phk at varnish-cache.org phk at varnish-cache.org
Thu Nov 4 11:28:58 CET 2010


Author: phk
Date: 2010-11-04 11:28:58 +0100 (Thu, 04 Nov 2010)
New Revision: 5504

Modified:
   trunk/varnish-cache/bin/varnishtest/vtc.c
Log:
Add a magic ${date} macro, which inserts a RFC2616 format timestamp
of the present time.



Modified: trunk/varnish-cache/bin/varnishtest/vtc.c
===================================================================
--- trunk/varnish-cache/bin/varnishtest/vtc.c	2010-11-04 10:13:32 UTC (rev 5503)
+++ trunk/varnish-cache/bin/varnishtest/vtc.c	2010-11-04 10:28:58 UTC (rev 5504)
@@ -134,10 +134,19 @@
 {
 	struct macro *m;
 	int l;
+	char *retval = NULL;
 
-	char *retval = NULL;
+	l = e - b;
+
+	if (l == 4 && !memcmp(b, "date", l)) {
+		double t = TIM_real();
+		retval = malloc(64);
+		AN(retval);
+		TIM_format(t, retval);
+		return (retval);
+	}
+
 	AZ(pthread_mutex_lock(&macro_mtx));
-	l = e - b;
 	VTAILQ_FOREACH(m, &macro_list, list)
 		if (!memcmp(b, m->name, l) && m->name[l] == '\0')
 			break;




More information about the varnish-commit mailing list