r4137 - in trunk/varnish-tools/perl/Varnish-API: . t
sky at projects.linpro.no
sky at projects.linpro.no
Tue Jul 14 23:19:08 CEST 2009
Author: sky
Date: 2009-07-14 23:19:08 +0200 (Tue, 14 Jul 2009)
New Revision: 4137
Added:
trunk/varnish-tools/perl/Varnish-API/t/logtag.t
Modified:
trunk/varnish-tools/perl/Varnish-API/API.xs
Log:
Add support for
Varnish::API::SHMLOG_TAG
Varnish::API::SHMLOG_ID
Varnish::API::SHMLOG_DATA
Varnish::API::SHMLOG_LEN
And Varnish::API::VSL_NextLog
Modified: trunk/varnish-tools/perl/Varnish-API/API.xs
===================================================================
--- trunk/varnish-tools/perl/Varnish-API/API.xs 2009-07-14 17:01:26 UTC (rev 4136)
+++ trunk/varnish-tools/perl/Varnish-API/API.xs 2009-07-14 21:19:08 UTC (rev 4137)
@@ -37,7 +37,44 @@
INCLUDE: const-xs.inc
+
+unsigned int
+SHMLOG_ID(logentry)
+ SV* logentry;
+ CODE:
+ RETVAL = SHMLOG_ID((unsigned char*) SvPVbyte_nolen(logentry));
+ OUTPUT:
+ RETVAL
+
+unsigned int
+SHMLOG_LEN(logentry)
+ SV* logentry
+ CODE:
+ RETVAL = SHMLOG_LEN((unsigned char*) SvPVbyte_nolen(logentry));
+ OUTPUT:
+ RETVAL
+
+unsigned int
+SHMLOG_TAG(logentry)
+ unsigned char* logentry
+ CODE:
+ enum shmlogtag tag;
+ tag = logentry[SHMLOG_TAG];
+ RETVAL = tag;
+ OUTPUT:
+ RETVAL
+
+
+
char*
+SHMLOG_DATA(logentry)
+ unsigned char* logentry
+ CODE:
+ RETVAL = logentry + SHMLOG_DATA;
+ OUTPUT:
+ RETVAL
+
+char*
VSL_tags(tag)
int tag
CODE:
@@ -69,10 +106,11 @@
VSL_NextLog(vd)
SV* vd;
PPCODE:
+ STRLEN strlen;
struct VSL_data* data = (struct VSL_data*) SvIV(vd);
unsigned char *p;
VSL_NextLog(data, &p);
- ST(0) = newSVpv(p,SHMLOG_NEXTTAG + SHMLOG_LEN(p));
+ ST(0) = newSVpv(p, SHMLOG_DATA + SHMLOG_LEN(p));
sv_2mortal(ST(0));
XSRETURN(1);
Added: trunk/varnish-tools/perl/Varnish-API/t/logtag.t
===================================================================
--- trunk/varnish-tools/perl/Varnish-API/t/logtag.t (rev 0)
+++ trunk/varnish-tools/perl/Varnish-API/t/logtag.t 2009-07-14 21:19:08 UTC (rev 4137)
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+
+use Test::More tests => 6;
+BEGIN { use_ok('Varnish::API') };
+use Devel::Peek;
+
+use Sys::Hostname qw(hostname);
+
+my $vd = Varnish::API::VSL_New();
+Varnish::API::VSL_OpenLog($vd, hostname);
+
+my $log = Varnish::API::VSL_NextLog($vd);
+
+$log =~/^(.)..(..)/;
+
+is(Varnish::API::SHMLOG_TAG($log), ord($1));
+
+my $tag = Varnish::API::VSL_tags(Varnish::API::SHMLOG_TAG($log));
+my $fd = Varnish::API::SHMLOG_ID($log);
+my $text = Varnish::API::SHMLOG_DATA($log);
+
+like($fd, qr/^\d+$/);
+ok(1, "$tag");
+ok(1, "$text");
+use bytes;
+is(Varnish::API::SHMLOG_LEN($log), length($text));
+
More information about the varnish-commit
mailing list