From: phk Date: Fri, 24 Mar 2006 08:43:48 +0000 (+0000) Subject: Move the SHM tags into a resuable .h file. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c3db3506e31efc75de0797c6c14a7f8f292a81c;p=varnish Move the SHM tags into a resuable .h file. Minor nits git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@63 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/include/cli.h b/varnish-cache/include/cli.h index c79350aa..0d910682 100644 --- a/varnish-cache/include/cli.h +++ b/varnish-cache/include/cli.h @@ -3,6 +3,12 @@ * * Public definition of the CLI protocol, part of the published Varnish-API. * + * The overall structure of the protocol is a command-line like + * "command+arguments" request and a IETF style "number + string" response. + * + * Arguments can contain arbitrary sequences of bytes which are encoded + * in back-slash notation in double-quoted, if necessary. + * */ /* diff --git a/varnish-cache/include/libvarnish.h b/varnish-cache/include/libvarnish.h index b50fcd25..4ce0313e 100644 --- a/varnish-cache/include/libvarnish.h +++ b/varnish-cache/include/libvarnish.h @@ -5,3 +5,8 @@ /* from libvarnish/argv.c */ void FreeArgv(char **argv); char **ParseArgv(const char *s, int comment); + + +/* Assert zero return value */ +#define AZ(foo) do { assert((foo) == 0); } while (0) + diff --git a/varnish-cache/include/shmlog.h b/varnish-cache/include/shmlog.h new file mode 100644 index 00000000..52603afb --- /dev/null +++ b/varnish-cache/include/shmlog.h @@ -0,0 +1,48 @@ +/* + * $Id$ + * + * Define the layout of the shared memory log segment. + * + * NB: THIS IS NOT A PUBLIC API TO VARNISH! + * + */ + +#define SHMLOG_FILENAME "/tmp/_.vsl" + +struct shmloghead { +#define SHMLOGHEAD_MAGIC 4185512498U /* From /dev/random */ + unsigned magic; + + /* + * Byte offset into the file where the fifolog starts + * This allows the header to expand later. + */ + unsigned start; + + /* Length of the fifolog area in bytes */ + unsigned size; + + /* Current write position relative to the beginning of start */ + unsigned ptr; +}; + +/* + * Record format is as follows: + * + * 1 byte field type (enum shmlogtag) + * 1 byte length of contents + * 2 byte record identifier + * n bytes field contents (isgraph(c) || isspace(c)) allowed. + */ + +/* + * The identifiers in shmlogtag are "SLT_" + XML tag. A script may be run + * on this file to extract the table rather than handcode it + */ +enum shmlogtag { + SLT_ENDMARKER = 0, +#define SLTM(foo) SLT_##foo, +#include "shmlog_tags.h" +#undef SLTM + SLT_WRAPMARKER = 255 +}; diff --git a/varnish-cache/include/shmlog_tags.h b/varnish-cache/include/shmlog_tags.h new file mode 100644 index 00000000..ce4885cc --- /dev/null +++ b/varnish-cache/include/shmlog_tags.h @@ -0,0 +1,14 @@ +/* + * $Id$ + * + * Define the tags in the shared memory in a reusable format. + * Whoever includes this get to define what the SLTM macro does. + * + */ + +SLTM(CLI) +SLTM(SessionId) +SLTM(ClientAddr) +SLTM(Request) +SLTM(URL) +SLTM(Protocol)