exit(1);
}
if (!(p = strchr(buf, ' '))) {
- fprintf(stderr, "An error occured in parsing of status code.\n");
+ fprintf(stderr,
+ "An error occured in parsing of status code.\n");
exit(1);
}
*p = '\0';
status = strtol(buf, &p, 10);
pp = p+1;
if (!(p = strchr(pp, '\n'))) {
- fprintf(stderr, "An error occured in parsing of number of bytes returned.\n");
+ fprintf(stderr, "An error occured "
+ "in parsing of number of bytes returned.\n");
exit(1);
}
*p = '\0';
# Turn the default.vcl file into a C-string we can include in the program.
#
default_vcl.h: default.vcl Makefile
- sed -e 's/"/\\"/g' -e 's/$$/\\n"/' -e 's/^/ "/' $(srcdir)/default.vcl > $@
+ sed -e 's/"/\\"/g' -e 's/$$/\\n"/' -e 's/^/ "/' $(srcdir)/default.vcl > $@
# Explicitly record dependency
mgt_vcc.c: default_vcl.h
struct ws *ws;
unsigned char conds; /* If-* headers present */
- enum httpwhence logtag;
+ enum httpwhence logtag;
int status;
double protover;
- txt hd[HTTP_HDR_MAX];
+ txt hd[HTTP_HDR_MAX];
unsigned char hdf[HTTP_HDR_MAX];
#define HDF_FILTER (1 << 0) /* Filtered by Connection */
unsigned nhd;
struct object {
unsigned magic;
#define OBJECT_MAGIC 0x32851d42
- unsigned refcnt;
+ unsigned refcnt;
unsigned xid;
struct objhead *objhead;
struct storage *objstore;
enum step step;
unsigned cur_method;
- unsigned handling;
+ unsigned handling;
unsigned char sendbody;
unsigned char wantbody;
int err_code;
void http_ClrHeader(struct http *to);
unsigned http_Write(struct worker *w, const struct http *hp, int resp);
void http_CopyResp(struct http *to, const struct http *fm);
-void http_SetResp(struct http *to, const char *proto, const char *status, const char *response);
-void http_FilterFields(struct worker *w, int fd, struct http *to, const struct http *fm, unsigned how);
+void http_SetResp(struct http *to, const char *proto, const char *status,
+ const char *response);
+void http_FilterFields(struct worker *w, int fd, struct http *to,
+ const struct http *fm, unsigned how);
void http_FilterHeader(struct sess *sp, unsigned how);
-void http_PutProtocol(struct worker *w, int fd, struct http *to, const char *protocol);
+void http_PutProtocol(struct worker *w, int fd, struct http *to,
+ const char *protocol);
void http_PutStatus(struct worker *w, int fd, struct http *to, int status);
-void http_PutResponse(struct worker *w, int fd, struct http *to, const char *response);
-void http_PrintfHeader(struct worker *w, int fd, struct http *to, const char *fmt, ...);
+void http_PutResponse(struct worker *w, int fd, struct http *to,
+ const char *response);
+void http_PrintfHeader(struct worker *w, int fd, struct http *to,
+ const char *fmt, ...);
void http_SetHeader(struct worker *w, int fd, struct http *to, const char *hdr);
void http_SetH(struct http *to, unsigned n, const char *fm);
void http_ForceGet(struct http *to);
void http_Setup(struct http *ht, struct ws *ws);
int http_GetHdr(const struct http *hp, const char *hdr, char **ptr);
-int http_GetHdrField(const struct http *hp, const char *hdr, const char *field, char **ptr);
+int http_GetHdrField(const struct http *hp, const char *hdr,
+ const char *field, char **ptr);
int http_GetStatus(const struct http *hp);
const char *http_GetReq(const struct http *hp);
const char *http_GetProto(const struct http *hp);
int http_HdrIs(const struct http *hp, const char *hdr, const char *val);
int http_DissectRequest(struct sess *sp);
-int http_DissectResponse(struct worker *w, const struct http_conn *htc, struct http *sp);
+int http_DissectResponse(struct worker *w, const struct http_conn *htc,
+ struct http *sp);
const char *http_DoConnection(struct http *hp);
void http_CopyHome(struct worker *w, int fd, struct http *hp);
void http_Unset(struct http *hp, const char *hdr);
void WSL(struct worker *w, enum shmlogtag tag, int id, const char *fmt, ...);
void WSL_Flush(struct worker *w, int overflow);
-#define DSL(flag, tag, id, ...) \
+#define DSL(flag, tag, id, ...) \
do { \
if (params->diag_bitmap & (flag)) \
VSL((tag), (id), __VA_ARGS__); \
} while (0)
-#define WSP(sess, tag, ...) \
+#define WSP(sess, tag, ...) \
WSL((sess)->wrk, tag, (sess)->fd, __VA_ARGS__)
-#define WSPR(sess, tag, txt) \
+#define WSPR(sess, tag, txt) \
WSLR((sess)->wrk, tag, (sess)->fd, txt)
#define INCOMPL() do { \
VSL(SLT_Debug, 0, "INCOMPLETE AT: %s(%d)", __func__, __LINE__); \
- fprintf(stderr,"INCOMPLETE AT: %s(%d)\n", (const char *)__func__, __LINE__); \
+ fprintf(stderr, \
+ "INCOMPLETE AT: %s(%d)\n", \
+ (const char *)__func__, __LINE__); \
abort(); \
} while (0)
#endif
__func__, __FILE__, __LINE__, (r)); \
} \
} while (0)
-#define LOCK(foo) \
-do { \
+#define LOCK(foo) \
+do { \
if (!(params->diag_bitmap & 0x18)) { \
- AZ(pthread_mutex_lock(foo)); \
+ AZ(pthread_mutex_lock(foo)); \
} else { \
int ixjd = pthread_mutex_trylock(foo); \
assert(ixjd == 0 || ixjd == EBUSY); \
VSL(SLT_Debug, 0, \
"MTX_CONTEST(%s,%s,%d," #foo ")", \
__func__, __FILE__, __LINE__); \
- AZ(pthread_mutex_lock(foo)); \
+ AZ(pthread_mutex_lock(foo)); \
} else if (params->diag_bitmap & 0x8) { \
VSL(SLT_Debug, 0, \
"MTX_LOCK(%s,%s,%d," #foo ")", \
- __func__, __FILE__, __LINE__); \
+ __func__, __FILE__, __LINE__); \
} \
} \
} while (0)
*
* $Id$
*
- * XXX: We need to pass sessions back into the event engine when they are
- * reused. Not sure what the most efficient way is for that. For now
- * write the session pointer to a pipe which the event engine monitors.
*/
#include "config.h"
static struct acceptor *vca_act;
-static pthread_t vca_thread_acct;
+static pthread_t vca_thread_acct;
static struct timeval tv_sndtimeo;
static struct timeval tv_rcvtimeo;
static struct linger linger;
break;
case EMFILE:
VSL(SLT_Debug, ls->sock,
- "Too many open files when accept(2)ing. Sleeping.");
- TIM_sleep(params->accept_fd_holdoff * 1000.0);
+ "Too many open files "
+ "when accept(2)ing. Sleeping.");
+ TIM_sleep(
+ params->accept_fd_holdoff * 1000.0);
break;
default:
VSL(SLT_Debug, ls->sock,
- "Accept failed: %s", strerror(errno));
+ "Accept failed: %s",
+ strerror(errno));
/* XXX: stats ? */
break;
}
(void)cli;
(void)av;
(void)priv;
-
+
if (vca_act == NULL)
vca_act = vca_acceptors[0];
cli_out(cli, "default");
else
cli_out(cli, "%s", vca_act->name);
-
+
cli_out(cli, " (");
for (i = 0; vca_acceptors[i] != NULL; i++)
cli_out(cli, "%s%s", i == 0 ? "" : ", ",
typedef void acceptor_pass_f(struct sess *);
struct acceptor {
- const char *name;
+ const char *name;
acceptor_init_f *init;
acceptor_pass_f *pass;
};
assert(sp->fd >= 0);
DSL(0x04, SLT_Debug, sp->fd, "KQ: EV_SET sp %p arm %x", sp, arm);
EV_SET(&ki[nki], sp->fd, EVFILT_READ, arm, 0, 0, sp);
- if (++nki == NKEV)
+ if (++nki == NKEV)
vca_kq_flush();
}
static void
vca_add(int fd, void *data)
{
- AZ(port_associate(solaris_dport, PORT_SOURCE_FD, fd, POLLIN | POLLERR | POLLPRI, data));
+ AZ(port_associate(solaris_dport, PORT_SOURCE_FD, fd,
+ POLLIN | POLLERR | POLLPRI, data));
}
static void
ts.tv_sec = 0L;
ts.tv_nsec = 50L /*ms*/ * 1000L /*us*/ * 1000L /*ns*/;
nevents = 1;
- if (port_getn(solaris_dport, ev, MAX_EVENTS, &nevents, &ts) == 0) {
+ if (port_getn(solaris_dport, ev, MAX_EVENTS, &nevents, &ts)
+ == 0) {
for (ei=0; ei<nevents; ei++) {
vca_port_ev(ev + ei);
}
*/
static int
-VBE_TryConnect(const struct sess *sp, int pf, const struct sockaddr *sa, socklen_t salen, const struct backend *bp)
+VBE_TryConnect(const struct sess *sp, int pf, const struct sockaddr *sa,
+ socklen_t salen, const struct backend *bp)
{
int s, i, tmo;
char abuf1[TCP_ADDRBUFSIZE], abuf2[TCP_ADDRBUFSIZE];
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
s = socket(pf, SOCK_STREAM, 0);
- if (s < 0)
+ if (s < 0)
return (s);
tmo = params->connect_timeout;
if (s < 0) {
LOCK(&bp->mtx);
- bp->n_conn--;
+ bp->n_conn--;
bp->refcount--; /* Only keep ref on success */
UNLOCK(&bp->mtx);
}
/*
* Copy over the sockaddrs
*/
- if (vb->ipv4_sockaddr != NULL)
+ if (vb->ipv4_sockaddr != NULL)
copy_sockaddr(&b->ipv4, &b->ipv4len, vb->ipv4_sockaddr);
- if (vb->ipv6_sockaddr != NULL)
+ if (vb->ipv6_sockaddr != NULL)
copy_sockaddr(&b->ipv6, &b->ipv6len, vb->ipv6_sockaddr);
assert(b->ipv4 != NULL || b->ipv6 != NULL);
#define VBP_TARGET_MAGIC 0x6b7cb656
struct backend *backend;
- struct vrt_backend_probe probe;
+ struct vrt_backend_probe probe;
int stop;
char *req;
int req_len;
char resp_buf[128];
unsigned good;
-
+
/* Collected statistics */
#define BITMAP(n, c, t, b) uint64_t n;
#include "cache_backend_poll.h"
static VTAILQ_HEAD(, vbp_target) vbp_list =
VTAILQ_HEAD_INITIALIZER(vbp_list);
-static char default_request[] =
+static char default_request[] =
"GET / HTTP/1.1\r\n"
"Connection: close\r\n"
"\r\n";
vt->backend->vcl_name, logmsg, bits,
vt->good, vt->probe.threshold, vt->probe.window,
vt->last, vt->avg, vt->resp_buf);
-
+
if (!vt->stop)
TIM_sleep(vt->probe.interval);
}
cli_out(cli, "Current states good: %2u threshold: %2u window: %2u\n",
vt->good, vt->probe.threshold, vt->probe.window);
cli_out(cli, "Average responsetime of good probes: %.6f\n", vt->avg);
- cli_out(cli,
+ cli_out(cli,
"Oldest "
" Newest\n");
- cli_out(cli,
+ cli_out(cli,
"============================="
"===================================\n");
#define BITMAP(n, c, t, b) \
- if ((vt->n != 0) || (b)) \
+ if ((vt->n != 0) || (b)) \
vbp_bitmap(cli, (c), vt->n, (t));
#include "cache_backend_poll.h"
#undef BITMAP
}
static struct cli_proto debug_cmds[] = {
- { "debug.health", "debug.health",
- "\tDump backend health stuff\n",
- 0, 0, vbp_health },
- { NULL }
+ { "debug.health", "debug.health",
+ "\tDump backend health stuff\n",
+ 0, 0, vbp_health },
+ { NULL }
};
/*--------------------------------------------------------------------
(void)av;
(void)priv;
/*
- * XXX: Strictly speaking, this loop traversal is not lock-safe
+ * XXX: Strictly speaking, this loop traversal is not lock-safe
* XXX: because we might inspect the last ban while it gets
* XXX: destroyed. To properly fix this, we would need to either
- * XXX: hold the lock over the entire loop, or grab refcounts
+ * XXX: hold the lock over the entire loop, or grab refcounts
* XXX: under lock for each element of the list.
* XXX: We do neither, and hope for the best.
*/
return (0);
}
-
/*--------------------------------------------------------------------
* We have a refcounted object on the session, now deliver it.
*
sp->director = NULL;
sp->restarts = 0;
-
+
RES_WriteObj(sp);
HSH_Deref(sp->obj);
sp->obj = NULL;
return (0);
}
-
/*--------------------------------------------------------------------
* This is the final state, figure out if we should close or recycle
* the client connection
AZ(sp->bereq);
sp->director = NULL;
sp->restarts = 0;
-
+
if (sp->vcl != NULL && sp->esis == 0) {
if (sp->wrk->vcl != NULL)
VCL_Rel(&sp->wrk->vcl);
return (1);
}
-
/*--------------------------------------------------------------------
* Emit an error
*
http_PutStatus(w, sp->fd, h, sp->err_code);
now = TIM_real();
TIM_format(now, date);
- http_PrintfHeader(w, sp->fd, h, "Date: %s", date);
- http_PrintfHeader(w, sp->fd, h, "Server: Varnish");
- http_PrintfHeader(w, sp->fd, h, "Retry-After: %d", params->err_ttl);
+ http_PrintfHeader(w, sp->fd, h, "Date: %s", date);
+ http_PrintfHeader(w, sp->fd, h, "Server: Varnish");
+ http_PrintfHeader(w, sp->fd, h, "Retry-After: %d", params->err_ttl);
if (sp->err_reason != NULL)
http_PutResponse(w, sp->fd, h, sp->err_reason);
return (0);
}
-
/*--------------------------------------------------------------------
* We have fetched the headers from the backend, ask the VCL code what
* to do next, then head off in that direction.
DOT vcl_fetch -> recv [label="restart"]
DOT vcl_fetch -> rstfetch [label="restart",color=purple]
DOT rstfetch [label="RESTART",shape=plaintext]
-DOT fetch -> errfetch
+DOT fetch -> errfetch
DOT vcl_fetch -> errfetch [label="error"]
DOT errfetch [label="ERROR",shape=plaintext]
*/
}
}
-
/*--------------------------------------------------------------------
* LOOKUP
* Hash things together and look object up in hash-table.
return (0);
}
-
/*--------------------------------------------------------------------
* We had a miss, ask VCL, proceed as instructed
*
}
}
-
/*--------------------------------------------------------------------
* Start pass processing by getting headers from backend, then
* continue in passbody.
return (0);
}
-
/*--------------------------------------------------------------------
* RECV
* We have a complete request, set everything up and start it.
sp->step == STP_START ||
sp->step == STP_LOOKUP ||
sp->step == STP_RECV);
-
+
/*
* Whenever we come in from the acceptor we need to set blocking
* mode, but there is no point in setting it when we come from
* ESI or when a parked sessions returns.
* It would be simpler to do this in the acceptor, but we'd rather
* do the syscall in the worker thread.
- */
+ */
if (sp->step == STP_FIRST || sp->step == STP_START)
TCP_blocking(sp->fd);
static void
cli_debug_xid(struct cli *cli, const char * const *av, void *priv)
{
- (void)priv;
- if (av[2] != NULL)
+ (void)priv;
+ if (av[2] != NULL)
xids = strtoul(av[2], NULL, 0);
cli_out(cli, "XID is %u", xids);
}
}
/*--------------------------------------------------------------------
- * Called when we have a full line, look through all three command
+ * Called when we have a full line, look through all three command
* lists to find it.
*/
#define SZOF(foo) cli_out(cli, \
"sizeof(%s) = %zd = 0x%zx\n", #foo, sizeof(foo), sizeof(foo));
- SZOF(struct ws);
- SZOF(struct http);
- SZOF(struct http_conn);
- SZOF(struct acct);
- SZOF(struct worker);
- SZOF(struct workreq);
- SZOF(struct bereq);
- SZOF(struct storage);
- SZOF(struct object);
- SZOF(struct objhead);
- SZOF(struct sess);
- SZOF(struct vbe_conn);
- SZOF(struct varnish_stats);
+ SZOF(struct ws);
+ SZOF(struct http);
+ SZOF(struct http_conn);
+ SZOF(struct acct);
+ SZOF(struct worker);
+ SZOF(struct workreq);
+ SZOF(struct bereq);
+ SZOF(struct storage);
+ SZOF(struct object);
+ SZOF(struct objhead);
+ SZOF(struct sess);
+ SZOF(struct vbe_conn);
+ SZOF(struct varnish_stats);
}
/*--------------------------------------------------------------------*/
continue;
s1 += vs->hosts[i].weight;
j++;
- }
+ }
if (j == 0) /* No healthy hosts */
return (NULL);
if (vbe != NULL)
return (vbe);
k++;
- }
+ }
return (NULL);
}
CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
CAST_OBJ_NOTNULL(vs, d->priv, VDI_RANDOM_MAGIC);
-
+
vh = vs->hosts;
for (i = 0; i < vs->nhosts; i++, vh++)
VBE_DropRef(vh->backend);
}
void
-VRT_init_dir_random(struct cli *cli, struct director **bp, const struct vrt_dir_random *t)
+VRT_init_dir_random(struct cli *cli, struct director **bp,
+ const struct vrt_dir_random *t)
{
struct vdi_random *vs;
const struct vrt_dir_random_entry *te;
struct vdi_random_host *vh;
int i;
-
+
(void)cli;
ALLOC_OBJ(vs, VDI_RANDOM_MAGIC);
CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
CAST_OBJ_NOTNULL(vs, d->priv, VDI_ROUND_ROBIN_MAGIC);
-
+
vh = vs->hosts;
for (i = 0; i < vs->nhosts; i++, vh++)
VBE_DropRef(vh->backend);
}
void
-VRT_init_dir_round_robin(struct cli *cli, struct director **bp, const struct vrt_dir_round_robin *t)
+VRT_init_dir_round_robin(struct cli *cli, struct director **bp,
+ const struct vrt_dir_round_robin *t)
{
struct vdi_round_robin *vs;
const struct vrt_dir_round_robin_entry *te;
struct vdi_round_robin_host *vh;
int i;
-
+
(void)cli;
ALLOC_OBJ(vs, VDI_ROUND_ROBIN_MAGIC);
CHECK_OBJ_NOTNULL(d, DIRECTOR_MAGIC);
CAST_OBJ_NOTNULL(vs, d->priv, VDI_SIMPLE_MAGIC);
-
+
VBE_DropRef(vs->backend);
free(vs->dir.vcl_name);
vs->dir.magic = 0;
}
void
-VRT_init_dir_simple(struct cli *cli, struct director **bp, const struct vrt_dir_simple *t)
+VRT_init_dir_simple(struct cli *cli, struct director **bp,
+ const struct vrt_dir_simple *t)
{
struct vdi_simple *vs;
-
+
(void)cli;
ALLOC_OBJ(vs, VDI_SIMPLE_MAGIC);
* Objects have sideways references in the binary heap and the LRU list
* and we want to avoid paging in a lot of objects just to move them up
* or down the binheap or to move a unrelated object on the LRU list.
- * To avoid this we use a proxy object, objexp, to hold the relevant
+ * To avoid this we use a proxy object, objexp, to hold the relevant
* housekeeping fields parts of an object.
*/
}
/*--------------------------------------------------------------------
- * We have changed one or more of the object timers, shuffle it
+ * We have changed one or more of the object timers, shuffle it
* accordingly in the binheap
*
* The VCL code can send us here on a non-cached object, just return.
t = TIM_real();
continue;
}
-
+
o = oe->obj;
CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC);
assert(oe->timer_idx != BINHEAP_NOIDX);
* with active references, likely means that it is already in core. An
* object with no active references will be prodded further anyway.
*
- * NB: Checking refcount here is no guarantee that it does not gain
+ * NB: Checking refcount here is no guarantee that it does not gain
* another ref while we ponder its destiny without the lock held.
*/
LOCK(&exp_mtx);
/* Insert in binheap and lru again */
LOCK(&exp_mtx);
- VSL_stats->n_lru_nuked--; /* It was premature */
+ VSL_stats->n_lru_nuked--; /* It was premature */
VSL_stats->n_lru_saved++;
binheap_insert(exp_heap, oe);
assert(oe->timer_idx != BINHEAP_NOIDX);
* header if one is necessary.
* XXX: This possibly ought to go into the default VCL
*/
- if (!http_GetHdr(hp, H_Host, &b))
+ if (!http_GetHdr(hp, H_Host, &b))
VBE_AddHostHeader(sp);
TCP_blocking(vc->fd); /* XXX: we should timeout instead */
static void
debug_fragfetch(struct cli *cli, const char * const *av, void *priv)
{
- (void)priv;
- (void)cli;
+ (void)priv;
+ (void)cli;
fetchfrag = strtoul(av[2], NULL, 0);
}
VTAILQ_INIT(&w->nobj->store);
VTAILQ_INIT(&w->nobj->esibits);
VSL_stats->n_object++;
-
+
} else
CHECK_OBJ_NOTNULL(w->nobj, OBJECT_MAGIC);
}
}
if (!o->cacheable)
continue;
- if (o->ttl == 0)
+ if (o->ttl == 0)
continue;
if (BAN_CheckObject(o, h->hd[HTTP_HDR_URL].b, oh->hash)) {
o->ttl = 0;
if (o->ws_o->overflow)
VSL_stats->n_objoverflow++;
if (params->diag_bitmap & 0x40)
- WSP(sp, SLT_Debug,
+ WSP(sp, SLT_Debug,
"Object %u workspace free %u", o->xid, WS_Free(o->ws_o));
-
+
oh = o->objhead;
if (oh != NULL) {
CHECK_OBJ(oh, OBJHEAD_MAGIC);
#undef HTTPH
/*lint -save -e773 not () */
-#define LOGMTX2(ax, bx, cx) [bx] = SLT_##ax##cx
+#define LOGMTX2(ax, bx, cx) [bx] = SLT_##ax##cx
-#define LOGMTX1(ax) { \
+#define LOGMTX1(ax) { \
LOGMTX2(ax, HTTP_HDR_REQ, Request), \
LOGMTX2(ax, HTTP_HDR_RESPONSE, Response), \
LOGMTX2(ax, HTTP_HDR_STATUS, Status), \
}
/*--------------------------------------------------------------------
- * Find a given headerfield, and if present and wanted, the beginning
+ * Find a given headerfield, and if present and wanted, the beginning
* of its value.
*/
int
-http_GetHdrField(const struct http *hp, const char *hdr, const char *field, char **ptr)
+http_GetHdrField(const struct http *hp, const char *hdr,
+ const char *field, char **ptr)
{
char *h, *e;
unsigned fl;
return (1);
}
/* Skip token */
- while (*h && !vct_issepctl(*h))
+ while (*h && !vct_issepctl(*h))
h++;
}
return (0);
*/
static int
-http_splitline(struct worker *w, int fd, struct http *hp, const struct http_conn *htc, int h1, int h2, int h3)
+http_splitline(struct worker *w, int fd, struct http *hp,
+ const struct http_conn *htc, int h1, int h2, int h3)
{
char *p;
/*--------------------------------------------------------------------*/
int
-http_DissectResponse(struct worker *w, const struct http_conn *htc, struct http *hp)
+http_DissectResponse(struct worker *w, const struct http_conn *htc,
+ struct http *hp)
{
int i;
if (hp->status == 0)
hp->status = i;
} else {
- hp->status =
+ hp->status =
strtoul(hp->hd[HTTP_HDR_STATUS].b, NULL /* XXX */, 10);
}
if (hp->hd[HTTP_HDR_RESPONSE].b == NULL ||
!Tlen(hp->hd[HTTP_HDR_RESPONSE])) {
/* Backend didn't send a response string, use the standard */
- hp->hd[HTTP_HDR_RESPONSE].b =
+ hp->hd[HTTP_HDR_RESPONSE].b =
TRUST_ME(http_StatusMessage(hp->status));
hp->hd[HTTP_HDR_RESPONSE].e =
strchr(hp->hd[HTTP_HDR_RESPONSE].b, '\0');
}
void
-http_SetResp(struct http *to, const char *proto, const char *status, const char *response)
+http_SetResp(struct http *to, const char *proto, const char *status,
+ const char *response)
{
CHECK_OBJ_NOTNULL(to, HTTP_MAGIC);
}
static void
-http_copyheader(struct worker *w, int fd, struct http *to, const struct http *fm, unsigned n)
+http_copyheader(struct worker *w, int fd, struct http *to,
+ const struct http *fm, unsigned n)
{
CHECK_OBJ_NOTNULL(fm, HTTP_MAGIC);
/*--------------------------------------------------------------------*/
void
-http_FilterFields(struct worker *w, int fd, struct http *to, const struct http *fm, unsigned how)
+http_FilterFields(struct worker *w, int fd, struct http *to,
+ const struct http *fm, unsigned how)
{
unsigned u;
struct bereq *bereq;
struct http *hp;
- bereq = VBE_new_bereq();
- AN(bereq);
- hp = bereq->http;
- hp->logtag = HTTP_Tx;
+ bereq = VBE_new_bereq();
+ AN(bereq);
+ hp = bereq->http;
+ hp->logtag = HTTP_Tx;
http_copyreq(hp, sp->http, how);
http_FilterFields(sp->wrk, sp->fd, hp, sp->http, how);
/*--------------------------------------------------------------------*/
static void
-http_PutField(struct worker *w, int fd, struct http *to, int field, const char *string)
+http_PutField(struct worker *w, int fd, struct http *to, int field,
+ const char *string)
{
char *p;
unsigned l;
}
void
-http_PutProtocol(struct worker *w, int fd, struct http *to, const char *protocol)
+http_PutProtocol(struct worker *w, int fd, struct http *to,
+ const char *protocol)
{
http_PutField(w, fd, to, HTTP_HDR_PROTO, protocol);
}
void
-http_PutResponse(struct worker *w, int fd, struct http *to, const char *response)
+http_PutResponse(struct worker *w, int fd, struct http *to,
+ const char *response)
{
http_PutField(w, fd, to, HTTP_HDR_RESPONSE, response);
}
void
-http_PrintfHeader(struct worker *w, int fd, struct http *to, const char *fmt, ...)
+http_PrintfHeader(struct worker *w, int fd, struct http *to,
+ const char *fmt, ...)
{
va_list ap;
unsigned l, n;
unsigned u, v;
for (v = u = HTTP_HDR_FIRST; u < hp->nhd; u++) {
- if (http_IsHdr(&hp->hd[u], hdr))
+ if (http_IsHdr(&hp->hd[u], hdr))
continue;
if (v != u) {
memcpy(&hp->hd[v], &hp->hd[u], sizeof hp->hd[v]);
CHECK_OBJ_NOTNULL(htc, HTTP_CONN_MAGIC);
i = htc_header_complete(&htc->rxbuf);
- if (i < 0)
+ if (i < 0)
htc->rxbuf.e = htc->rxbuf.b;
if (i <= 0)
return (0);
p += l;
len -= l;
htc->pipeline.b += l;
- if (htc->pipeline.b == htc->pipeline.e)
+ if (htc->pipeline.b == htc->pipeline.e)
htc->pipeline.b = htc->pipeline.e = NULL;
}
if (len == 0)
ws, ws->overflow ? "overflow" : "");
vsb_printf(vsp, "%*sid = \"%s\",\n", indent + 2, "", ws->id);
vsb_printf(vsp, "%*s{s,f,r,e} = {%p,", indent + 2, "", ws->s);
- if (ws->f > ws->s)
+ if (ws->f > ws->s)
vsb_printf(vsp, ",+%d", ws->f - ws->s);
else
vsb_printf(vsp, ",%p", ws->f);
- if (ws->r > ws->s)
+ if (ws->r > ws->s)
vsb_printf(vsp, ",+%d", ws->r - ws->s);
else
vsb_printf(vsp, ",%p", ws->r);
- if (ws->e > ws->s)
+ if (ws->e > ws->s)
vsb_printf(vsp, ",+%d", ws->e - ws->s);
else
vsb_printf(vsp, ",%p", ws->e);
/*--------------------------------------------------------------------*/
static void
-pan_ic(const char *func, const char *file, int line, const char *cond, int err, int xxx)
+pan_ic(const char *func, const char *file, int line, const char *cond,
+ int err, int xxx)
{
int l;
char *p;
vsb_printf(vsp, " thread = (%s)", q);
if (!(params->diag_bitmap & 0x2000)) {
sp = THR_GetSession();
- if (sp != NULL)
+ if (sp != NULL)
pan_sess(sp);
}
vsb_printf(vsp, "\n");
memcpy(p, panicstr, l);
if (params->diag_bitmap & 0x4000)
(void)fputs(panicstr, stderr);
-
+
#ifdef HAVE_ABORT2
if (params->diag_bitmap & 0x8000) {
void *arg[1];
fds[0].revents = 0;
fds[1].revents = 0;
i = poll(fds, 2, params->pipe_timeout * 1000);
- if (i < 1)
+ if (i < 1)
break;
if (fds[0].revents && rdf(vc->fd, sp->fd)) {
(void)shutdown(vc->fd, SHUT_RD);
struct wq {
unsigned magic;
#define WQ_MAGIC 0x606658fa
- MTX mtx;
+ MTX mtx;
struct workerhead idle;
VTAILQ_HEAD(, workreq) overflow;
unsigned nthr;
/*--------------------------------------------------------------------
* Periodic pool herding thread
- *
+ *
* Do things which we can do at our leisure:
* Add pools
* Scale constants
struct vcls *vcl, *vcl2;
ASSERT_CLI();
- VTAILQ_FOREACH_SAFE(vcl, &vcl_head, list, vcl2)
- if (vcl->conf->discard && vcl->conf->busy == 0)
+ VTAILQ_FOREACH_SAFE(vcl, &vcl_head, list, vcl2)
+ if (vcl->conf->discard && vcl->conf->busy == 0)
VCL_Nuke(vcl);
}
\
sp->handling = 0; \
sp->cur_method = VCL_MET_ ## upper; \
- WSP(sp, SLT_VCL_call, "%s", #func); \
+ WSP(sp, SLT_VCL_call, "%s", #func); \
sp->vcl->func##_func(sp); \
WSP(sp, SLT_VCL_return, "%s", vcl_handlingname(sp->handling)); \
sp->cur_method = 0; \
{ CLI_VCL_LIST, ccf_config_list },
{ CLI_VCL_DISCARD, ccf_config_discard },
{ CLI_VCL_USE, ccf_config_use },
- { NULL }
+ { NULL }
};
void
if (b + x < e)
memcpy(b, h, x);
b += x;
- if (b + 1 < e)
+ if (b + 1 < e)
*b++ = ' ';
}
while (p != vrt_magic_string_end) {
b += x;
p = va_arg(ap, const char *);
}
- if (b + 1 < e)
+ if (b + 1 < e)
*b++ = '\0';
if (b > e) {
WS_Release(hp->ws, 0);
/*--------------------------------------------------------------------*/
void
-VRT_SetHdr(const struct sess *sp , enum gethdr_e where, const char *hdr, const char *p, ...)
+VRT_SetHdr(const struct sess *sp , enum gethdr_e where, const char *hdr,
+ const char *p, ...)
{
struct http *hp;
va_list ap;
/*--------------------------------------------------------------------*/
static void
-vrt_do_string(struct worker *w, int fd, struct http *hp, int fld, const char *err, const char *p, va_list ap)
+vrt_do_string(struct worker *w, int fd, struct http *hp, int fld,
+ const char *err, const char *p, va_list ap)
{
char *b;
if (sp->mysockaddr->sa_family == AF_UNSPEC)
AZ(getsockname(sp->fd, sp->mysockaddr, &sp->mysockaddrlen));
- TCP_name(sp->mysockaddr, sp->mysockaddrlen, abuf, sizeof abuf, pbuf, sizeof pbuf);
+ TCP_name(sp->mysockaddr, sp->mysockaddrlen,
+ abuf, sizeof abuf, pbuf, sizeof pbuf);
return (atoi(pbuf));
}
*sp->http = *sp->http0;
WS_Reset(sp->ws, sp->ws_req);
}
-
+
/*--------------------------------------------------------------------*/
/*lint -e{818} sp could be const */
void
VRT_purge(const char *regexp, int hash)
{
-
+
if (regexp != NULL)
(void)BAN_Add(NULL, regexp, hash);
}
char buf[256], *q;
txt t;
- if (i == 0)
+ if (i == 0)
i = p - ew->t.b;
if (i > 20) {
i = 20;
/* Value, if any ? */
*val = *in;
- if (in->b >= in->e)
+ if (in->b >= in->e)
return (1);
if (*in->b == '"') {
tag.e - tag.b, tag.b,
val.e - val.b, val.b);
if (Tlen(tag) != 3 || memcmp(tag.b, "src", 3))
- continue;
+ continue;
if (Tlen(val) == 0) {
esi_error(ew, tag.b, Tlen(tag),
"ESI esi:include src attribute withou value");
/*--------------------------------------------------------------------
* Zoom over a piece of object and dike out all releveant esi: pieces.
- * The entire txt may not be processed because an interesting part
+ * The entire txt may not be processed because an interesting part
* could possibly span into the next chunk of storage.
* Return value: number of bytes processed.
*/
if (!memcmp(p, "]]>", 3)) {
ew->incdata = 0;
p += 3;
- } else
+ } else
p++;
}
continue;
ew->incdata = 1;
p += 9;
continue;
- }
+ }
/* Ignore non esi elements, if so instructed */
if ((params->esi_syntax & 0x02)) {
esi_error(ew, p, 1 + q - p, ew->remflg ?
"ESI 1.0 forbids nested esi:remove"
: "ESI 1.0 esi:remove not opened");
-
+
if (!ew->remflg) {
ew->o.e = p;
esi_addverbatim(ew);
continue;
}
if (r + 10 < q && !memcmp(r, "esi:include", 11)) {
-
+
ew->o.e = p;
esi_addverbatim(ew);
p = NULL;
continue;
}
- assert(t.e > t.b + u); /* XXX incredibly long element ? */
+ assert(t.e > t.b + u); /* XXX incredibly long element ? */
memcpy(t.b, p, u);
/* Peel start off next chunk, until and including '<' */
ew->t = t;
q = esi_parse(ew);
assert(q == ew->t.e); /* XXX */
-
+
/* 'p' is cached starting point for next storage part */
}
}
const char *
-VRT_regsub(const struct sess *sp, int all, const char *str, void *re, const char *sub)
+VRT_regsub(const struct sess *sp, int all, const char *str, void *re,
+ const char *sub)
{
regmatch_t pm[10];
regex_t *t;
if (res.b >= res.e) {
WS_Release(sp->http->ws, 0);
return (str);
- }
+ }
Tcheck(res);
WS_ReleaseP(sp->http->ws, res.b);
return (b0);
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id$
*
* The default VCL code.
*
- * NB! You do NOT need to copy & paste all of this into your won vcl code,
- * if you do not handle one of the functions, the compiler will automaticall
- * fall back to the default code.
+ * NB! You do NOT need to copy & paste all of these functions into your
+ * own vcl code, if you do not provide a definition of one of these
+ * functions, the compiler will automatically fall back to the default
+ * code from this file.
*
* This code will be prefixed with a backend declaration built from the
* -b argument.
<p>"} obj.response {"</p>
<h3>Guru Meditation:</h3>
<p>XID: "} req.xid {"</p>
- <address><a href="http://www.varnish-cache.org/">Varnish</a></address>
+ <address>
+ <a href="http://www.varnish-cache.org/">Varnish</a>
+ </address>
</body>
</html>
"};
/*--------------------------------------------------------------------*/
struct hash_slinger hcl_slinger = {
- .magic = SLINGER_MAGIC,
+ .magic = SLINGER_MAGIC,
.name = "classic",
.init = hcl_init,
.start = hcl_start,
UNLOCK(&hsl_mutex);
return (nobj);
}
- if (nobj == NULL) {
- UNLOCK(&hsl_mutex);
- return (NULL);
+ if (nobj != NULL) {
+ he2 = calloc(sizeof *he2, 1);
+ XXXAN(he2);
+ he2->obj = nobj;
+ he2->refcnt = 1;
+
+ nobj->hashpriv = he2;
+ nobj->hash = malloc(sp->lhashptr);
+ XXXAN(nobj->hash);
+ nobj->hashlen = sp->lhashptr;
+ HSH_Copy(sp, nobj);
+
+ if (he != NULL)
+ VTAILQ_INSERT_BEFORE(he, he2, list);
+ else
+ VTAILQ_INSERT_TAIL(&hsl_head, he2, list);
}
- he2 = calloc(sizeof *he2, 1);
- XXXAN(he2);
- he2->obj = nobj;
- he2->refcnt = 1;
-
- nobj->hashpriv = he2;
- nobj->hash = malloc(sp->lhashptr);
- XXXAN(nobj->hash);
- nobj->hashlen = sp->lhashptr;
- HSH_Copy(sp, nobj);
-
- if (he != NULL)
- VTAILQ_INSERT_BEFORE(he, he2, list);
- else
- VTAILQ_INSERT_TAIL(&hsl_head, he2, list);
UNLOCK(&hsl_mutex);
return (nobj);
}
.name = "simple",
.start = hsl_start,
.lookup = hsl_lookup,
- .deref = hsl_deref,
+ .deref = hsl_deref,
};
typedef void hash_init_f(int ac, char * const *av);
typedef void hash_start_f(void);
-typedef struct objhead *hash_lookup_f(const struct sess *sp, struct objhead *nobj);
+typedef struct objhead *
+ hash_lookup_f(const struct sess *sp, struct objhead *nobj);
typedef int hash_deref_f(const struct objhead *obj);
struct hash_slinger {
/* TTL used for lack of anything better */
unsigned default_ttl;
-
+
/* TTL used for synthesized error pages */
unsigned err_ttl;
void child_main(void);
-int varnish_instance(const char *n_arg, char *name, size_t namelen, char *dir, size_t dirlen);
+int varnish_instance(const char *n_arg, char *name, size_t namelen,
+ char *dir, size_t dirlen);
continue;
}
ls->sock = VSS_bind(ls->addr);
- if (ls->sock < 0)
+ if (ls->sock < 0)
continue;
mgt_child_inherit(ls->sock, "sock");
child_cli_in = cp[0];
/*
- * Open pipe for child stdout/err
+ * Open pipe for child stdout/err
* NB: not inherited, because we dup2() it to stdout/stderr in child
*/
AZ(pipe(cp));
AZ(sigaction(SIGPIPE, &sac, NULL));
AZ(sigaction(SIGHUP, &sac, NULL));
- if (!dflag && !mgt_has_vcl())
+ if (!dflag && !mgt_has_vcl())
REPORT0(LOG_ERR, "No VCL loaded yet");
else if (!dflag) {
start_child(NULL);
static int cli_i = -1, cli_o = -1;
struct telnet {
- int fd;
- struct vev *ev;
+ int fd;
+ struct vev *ev;
VTAILQ_ENTRY(telnet) list;
};
"help %s\n", av[2] != NULL ? av[2] : "")) {
cli_out(cli, "%s", p);
cli_result(cli, u);
- }
+ }
free(p);
}
}
{ CLI_PARAM_SHOW, mcf_param_show, NULL },
{ CLI_PARAM_SET, mcf_param_set, NULL },
- { CLI_QUIT, mcf_close, NULL},
+ { CLI_QUIT, mcf_close, NULL},
#if 0
{ CLI_SERVER_RESTART },
{ CLI_ZERO },
/*--------------------------------------------------------------------*/
static void
-tweak_generic_uint(struct cli *cli, volatile unsigned *dest, const char *arg, unsigned min, unsigned max)
+tweak_generic_uint(struct cli *cli, volatile unsigned *dest, const char *arg,
+ unsigned min, unsigned max)
{
unsigned u;
master.uid = getuid();
return;
}
- } else
+ } else
pw = getpwnam(arg);
if (pw == NULL) {
cli_out(cli, "Unknown user");
/* set group to user's primary group */
if ((gr = getgrgid(pw->pw_gid)) != NULL &&
(gr = getgrnam(gr->gr_name)) != NULL &&
- gr->gr_gid == pw->pw_gid)
+ gr->gr_gid == pw->pw_gid)
REPLACE(master.group, gr->gr_name);
} else if (master.user) {
cli_out(cli, "%s (%d)", master.user, (int)master.uid);
/*--------------------------------------------------------------------*/
static void
-tweak_thread_pool_min(struct cli *cli, const struct parspec *par, const char *arg)
+tweak_thread_pool_min(struct cli *cli, const struct parspec *par,
+ const char *arg)
{
tweak_generic_uint(cli, &master.wthread_min, arg,
/*--------------------------------------------------------------------*/
static void
-tweak_thread_pool_max(struct cli *cli, const struct parspec *par, const char *arg)
+tweak_thread_pool_max(struct cli *cli, const struct parspec *par,
+ const char *arg)
{
(void)par;
}
static void
-tweak_listen_address(struct cli *cli, const struct parspec *par, const char *arg)
+tweak_listen_address(struct cli *cli, const struct parspec *par,
+ const char *arg)
{
char **av;
int i;
struct vclprog {
VTAILQ_ENTRY(vclprog) list;
- char *name;
+ char *name;
char *fname;
int active;
};
cli_result(cli, CLIS_PARAM);
return;
}
-
+
sb = vsb_newauto();
XXXAN(sb);
vf = mgt_VccCompile(sb, av[3], NULL, 0);
vp = mcf_find_vcl(cli, av[2]);
if (vp == NULL)
return;
- if (vp->active != 0)
+ if (vp->active != 0)
return;
if (child_pid >= 0 &&
mgt_cli_askchild(&status, &p, "vcl.use %s\n", av[2])) {
p[__SHMLOG_ID_HIGH] = (id >> 8) & 0xff;
p[__SHMLOG_ID_LOW] = id & 0xff;
p[SHMLOG_DATA + len] = '\0';
- p[SHMLOG_NEXTTAG + len] = SLT_ENDMARKER;
+ p[SHMLOG_NEXTTAG + len] = SLT_ENDMARKER;
/* XXX: Write barrier here */
p[SHMLOG_TAG] = tag;
}
p = logstart + loghead->ptr;
n = vsnprintf((char *)(p + SHMLOG_DATA), 256, fmt, ap);
if (n > 255)
- n = 255; /* we truncate long fields */
+ n = 255; /* we truncate long fields */
vsl_hdr(tag, p, n, id);
loghead->ptr += SHMLOG_NEXTTAG + n;
assert(loghead->ptr < loghead->size);
p = w->wlp;
n = vsnprintf((char *)(p + SHMLOG_DATA), 256, fmt, ap);
if (n > 255)
- n = 255; /* we truncate long fields */
+ n = 255; /* we truncate long fields */
vsl_hdr(tag, p, n, id);
w->wlp += SHMLOG_NEXTTAG + n;
assert(w->wlp < w->wle);
if (stv->init != NULL)
stv->init(stv, ac, av);
- else if (ac != 0)
+ else if (ac != 0)
ARGV_ERR("(-s%s) too many arguments\n", stv->name);
VTAILQ_INSERT_TAIL(&stevedores, stv, list);
i = 0;
while(1) {
o = l;
- if (o == l && o > 0)
+ if (o == l && o > 0)
break;
l >>= 1;
i++;
if (S_ISREG(st.st_mode)) {
sc->fd = open(fn, O_RDWR);
- if (sc->fd < 0)
+ if (sc->fd < 0)
ARGV_ERR("(-sfile) \"%s\" could not open (%s)\n",
fn, strerror(errno));
AZ(fstat(sc->fd, &st));
(void)parent;
AZ(av[ac]);
- if (ac > 1)
+ if (ac > 1)
ARGV_ERR("(-smalloc) too many arguments\n");
if (ac == 0 || *av[0] == '\0')
e = str2bytes(av[0], &u, 0);
if (e != NULL)
ARGV_ERR("(-smalloc) size \"%s\": %s\n", av[0], e);
- if ((u != (uintmax_t)(size_t)u))
+ if ((u != (uintmax_t)(size_t)u))
ARGV_ERR("(-smalloc) size \"%s\": too big\n", av[0]);
sma_max = u;
}
(void)parent;
AZ(av[ac]);
- if (ac > 1)
+ if (ac > 1)
ARGV_ERR("(-sumem) too many arguments\n");
if (ac == 0 || *av[0] == '\0')
e = str2bytes(av[0], &u, 0);
if (e != NULL)
ARGV_ERR("(-sumem) size \"%s\": %s\n", av[0], e);
- if ((u != (uintmax_t)(size_t)u))
+ if ((u != (uintmax_t)(size_t)u))
ARGV_ERR("(-sumem) size \"%s\": too big\n", av[0]);
smu_max = u;
}
av = ParseArgv(spec, ARGV_COMMA);
AN(av);
- if (av[0] != NULL)
+ if (av[0] != NULL)
ARGV_ERR("%s\n", av[0]);
if (av[1] == NULL)
av = ParseArgv(h_arg, ARGV_COMMA);
AN(av);
- if (av[0] != NULL)
+ if (av[0] != NULL)
ARGV_ERR("%s\n", av[0]);
if (av[1] == NULL)
fprintf(stderr, FMT, "", " -s file [default: use /tmp]");
fprintf(stderr, FMT, "", " -s file,<dir_or_file>");
fprintf(stderr, FMT, "", " -s file,<dir_or_file>,<size>");
- fprintf(stderr, FMT, "", " -s file,<dir_or_file>,<size>,<granularity>");
+ fprintf(stderr, FMT, "",
+ " -s file,<dir_or_file>,<size>,<granularity>");
fprintf(stderr, FMT, "-t", "Default TTL");
fprintf(stderr, FMT, "-T address:port",
"Telnet listen address and port");
av = ParseArgv(argv, ARGV_COMMA);
AN(av);
- if (av[0] != NULL)
+ if (av[0] != NULL)
ARGV_ERR("%s\n", av[0]);
- if (av[1] == NULL)
+ if (av[1] == NULL)
usage();
u = arg_ul(av[1]);
MCF_ParamInit(cli);
cli_check(cli);
- while ((o = getopt(argc, argv, "a:b:Cdf:Fg:h:l:n:P:p:s:T:t:u:Vw:")) != -1)
+ while ((o = getopt(argc, argv,
+ "a:b:Cdf:Fg:h:l:n:P:p:s:T:t:u:Vw:")) != -1)
switch (o) {
case 'a':
MCF_ParamSet(cli, "listen_address", optarg);
exit(1);
}
- if (n_arg != NULL)
+ if (n_arg != NULL)
openlog(n_arg, LOG_PID, LOG_LOCAL0);
else
openlog("varnishd", LOG_PID, LOG_LOCAL0);
if (d_flag == 1)
printf("%d\n", getpid());
- if (pfh != NULL && vpf_write(pfh))
+ if (pfh != NULL && vpf_write(pfh))
fprintf(stderr, "NOTE: Could not write PID file\n");
mgt_run(d_flag, T_arg);
}
static int
-h_hist(void *priv, enum shmlogtag tag, unsigned fd, unsigned len, unsigned spec, const char *ptr)
+h_hist(void *priv, enum shmlogtag tag, unsigned fd, unsigned len,
+ unsigned spec, const char *ptr)
{
double b;
int i, j;
static void
usage(void)
{
- fprintf(stderr,
- "usage: varnishhist %s [-n varnish_name] [-V] [-w delay]\n", VSL_USAGE);
+ fprintf(stderr, "usage: varnishhist "
+ "%s [-n varnish_name] [-V] [-w delay]\n", VSL_USAGE);
exit(1);
}
}
static int
-h_order(void *priv, enum shmlogtag tag, unsigned fd, unsigned len, unsigned spec, const char *ptr)
+h_order(void *priv, enum shmlogtag tag, unsigned fd, unsigned len,
+ unsigned spec, const char *ptr)
{
char type;
flags = (a_flag ? O_APPEND : O_TRUNC) | O_WRONLY | O_CREAT;
#ifdef O_LARGEFILE
- flags |= O_LARGEFILE;
+ flags |= O_LARGEFILE;
#endif
if (!strcmp(w_arg, "-"))
fd = STDOUT_FILENO;
static void
usage(void)
{
- fprintf(stderr,
- "usage: varnishlog %s [-aDoV] [-n varnish_name] [-P file] [-w file]\n", VSL_USAGE);
+ fprintf(stderr, "usage: varnishlog "
+ "%s [-aDoV] [-n varnish_name] [-P file] [-w file]\n", VSL_USAGE);
exit(1);
}
static int prefer_x_forwarded_for = 0;
static int
-isprefix(const char *str, const char *prefix, const char *end, const char **next)
+isprefix(const char *str, const char *prefix, const char *end,
+ const char **next)
{
while (str < end && *str && *prefix &&
usage(void)
{
- fprintf(stderr, "usage: varnishncsa %s [-aDV] [-n varnish_name] [-P file] [-w file]\n", VSL_USAGE);
+ fprintf(stderr,
+ "usage: varnishncsa %s [-aDV] [-n varnish_name] "
+ "[-P file] [-w file]\n", VSL_USAGE);
exit(1);
}
while (fd >= newnthreads)
newnthreads += newnthreads + 1;
- newthreads = realloc(newthreads, newnthreads * sizeof *newthreads);
+ newthreads = realloc(newthreads,
+ newnthreads * sizeof *newthreads);
XXXAN(newthreads != NULL);
memset(newthreads + nthreads, 0,
(newnthreads - nthreads) * sizeof *newthreads);
if (!thr->method || !thr->url || !thr->proto) {
thr->bogus = 1;
- } else if (strcmp(thr->method, "GET") != 0 && strcmp(thr->method, "HEAD") != 0) {
+ } else if (strcmp(thr->method, "GET") != 0 &&
+ strcmp(thr->method, "HEAD") != 0) {
thr->bogus = 1;
} else if (strcmp(thr->proto, "HTTP/1.0") == 0) {
- reopen = !(thr->conn && strcasecmp(thr->conn, "keep-alive") == 0);
+ reopen = !(thr->conn &&
+ strcasecmp(thr->conn, "keep-alive") == 0);
} else if (strcmp(thr->proto, "HTTP/1.1") == 0) {
- reopen = (thr->conn && strcasecmp(thr->conn, "close") == 0);
+ reopen = (thr->conn &&
+ strcasecmp(thr->conn, "close") == 0);
} else {
thr->bogus = 1;
}
usage(void)
{
- fprintf(stderr, "usage: varnishreplay [-D] -a address:port -r logfile\n");
+ fprintf(stderr,
+ "usage: varnishreplay [-D] -a address:port -r logfile\n");
exit(1);
}
signal(SIGPIPE, SIG_IGN);
pthread_attr_init(&thread_attr);
- /* XXX: seting the stack size manually reduces the memory usasage and increases speed */
+
+ /*
+ * XXX: seting the stack size manually reduces the memory usage
+ * XXX: (allowing more threads) and increases speed (?)
+ */
pthread_attr_setstacksize(&thread_attr, 32768);
while (VSL_Dispatch(vd, gen_traffic, NULL) == 0)
while (field_start != NULL) {
field_end = field_start + field_length;
- if ((field_start == fields || *(field_start - 1) == ',') &&
- (*field_end == ',' || *field_end == '\0'))
- return (match_value);
+ if ((field_start == fields ||
+ *(field_start - 1) == ',') &&
+ (*field_end == ',' || *field_end == '\0'))
+ return (match_value);
field_start = strstr( field_end, field );
}
}
usage(void)
{
#define FMT " %-28s # %s\n"
- fprintf(stderr, "usage: varnishstat [-1lV] [-f field_list] [-n varnish_name] [-w delay]\n");
+ fprintf(stderr, "usage: varnishstat "
+ "[-1lV] [-f field_list] [-n varnish_name] [-w delay]\n");
fprintf(stderr, FMT, "-1", "Print the statistics once and exit");
- fprintf(stderr, FMT, "-f field_list", "Comma separated list of fields to display. ");
- fprintf(stderr, FMT, "", "If it starts with '^' it is used as an exclusion list");
- fprintf(stderr, FMT, "-l", "Lists the available fields to use with the -f option");
- fprintf(stderr, FMT, "-n varnish_name", "The varnishd instance to get logs from");
+ fprintf(stderr, FMT, "-f field_list",
+ "Comma separated list of fields to display. ");
+ fprintf(stderr, FMT, "",
+ "If it starts with '^' it is used as an exclusion list");
+ fprintf(stderr, FMT, "-l",
+ "Lists the available fields to use with the -f option");
+ fprintf(stderr, FMT, "-n varnish_name",
+ "The varnishd instance to get logs from");
fprintf(stderr, FMT, "-V", "Display the version number and exit");
- fprintf(stderr, FMT, "-w delay", "Wait delay seconds between updates. The default is 1.");
+ fprintf(stderr, FMT, "-w delay",
+ "Wait delay seconds between updates. The default is 1.");
#undef FMT
exit(1);
}
static void
list_fields(void)
{
- fprintf(stderr, "Available fields to use with the varnishstat -f option:\n");
+ fprintf(stderr, "Varnishstat -f option fields:\n");
fprintf(stderr, "Field name Description\n");
fprintf(stderr, "---------- -----------\n");
fprintf(stderr, "uptime Child uptime\n");
valid_field = 0;
for (i = 0; all_fields[i] != NULL; i++) {
- if (strncmp(field_start, all_fields[i], field_length) == 0 && field_length == strlen( all_fields[i] )) {
+ if (strncmp(field_start, all_fields[i], field_length)
+ == 0 && field_length == strlen( all_fields[i])) {
valid_field = 1;
break;
}
if ((VSL_stats = VSL_OpenStats(n_arg)) == NULL)
exit(1);
-
+
if (fields != NULL && !valid_fields(fields)) {
usage();
exit(1);
/*
* Copyright (c) 2006-2008 Linpro AS
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
p++;
} else {
if (*p == '\n')
- fprintf(stderr, "Unterminated quoted string in line:\n%s", p);
+ fprintf(stderr,
+ "Unterminated quoted string in line:\n%s", p);
assert(*p != '\n');
*q++ = *p;
}
fprintf(stderr, "Unknown command: \"%s\"", token_s[0]);
exit (1);
}
-
+
assert(cp->cmd != NULL);
cp->cmd(token_s, priv, cmd, vl);
}
*/
static struct cmds cmds[] = {
- { "server", cmd_server },
- { "client", cmd_client },
- { "varnish", cmd_varnish },
- { "delay", cmd_delay },
- { "test", cmd_test },
- { "shell", cmd_shell },
- { "sema", cmd_sema },
- { NULL, NULL }
+ { "server", cmd_server },
+ { "client", cmd_client },
+ { "varnish", cmd_varnish },
+ { "delay", cmd_delay },
+ { "test", cmd_test },
+ { "shell", cmd_shell },
+ { "sema", cmd_sema },
+ { NULL, NULL }
};
static void
}
/**********************************************************************
- * Main
+ * Main
*/
int
/*
* Copyright (c) 2006-2008 Linpro AS
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
- *
+ *
* $Id$
*/
struct vtclog;
struct cmds;
-#define CMD_ARGS char * const *av, void *priv, const struct cmds *cmd, struct vtclog *vl
+#define CMD_ARGS \
+ char * const *av, void *priv, const struct cmds *cmd, struct vtclog *vl
+
typedef void cmd_f(CMD_ARGS);
struct cmds {
cmd_f *cmd;
};
-void parse_string(char *buf, const struct cmds *cmd, void *priv, struct vtclog *vl);
+void parse_string(char *buf, const struct cmds *cmd, void *priv,
+ struct vtclog *vl);
cmd_f cmd_dump;
cmd_f cmd_delay;
struct vtclog *vtc_logopen(const char *id);
void vtc_logclose(struct vtclog *vl);
void vtc_log(struct vtclog *vl, unsigned lvl, const char *fmt, ...);
-void vtc_dump(struct vtclog *vl, unsigned lvl, const char *pfx, const char *str);
+void vtc_dump(struct vtclog *vl, unsigned lvl, const char *pfx,
+ const char *str);
/*
* Copyright (c) 2006-2008 Linpro AS
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
VTAILQ_ENTRY(client) list;
char *spec;
-
+
char *connect;
pthread_t tp;
VTAILQ_FOREACH(c, &clients, list)
if (!strcmp(c->name, av[0]))
break;
- if (c == NULL)
+ if (c == NULL)
c = client_new(av[0]);
av++;
/*
* Copyright (c) 2006-2008 Linpro AS
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
{
int i, j, k, l;
char *b;
-
-
+
+
AN(len);
i = strtoul(len, NULL, 0);
assert(i > 0);
{
char *p, *q;
int i, l, ll;
-
+
ll = 0;
p = http_find_header(hh, "content-length");
ll += i;
} while (i > 0);
vtc_dump(hp->vl, 4, "rxeof", hp->body);
- }
+ }
sprintf(hp->bodylen, "%d", ll);
}
p = hp->rxbuf + hp->prxbuf - 1;
i = 0;
for (i = 0; p > hp->rxbuf; p--) {
- if (*p != '\n')
+ if (*p != '\n')
break;
if (p - 1 > hp->rxbuf && p[-1] == '\r')
p--;
vtc_log(hp->vl, 3, "rxresp");
http_rxhdr(hp);
http_splitheader(hp, 0);
- if (!strcmp(hp->resp[1], "200"))
+ if (!strcmp(hp->resp[1], "200"))
http_swallow_body(hp, hp->resp, 1);
else
http_swallow_body(hp, hp->resp, 0);
if (!strcmp(*av, "-hdr")) {
vsb_printf(hp->vsb, "%s%s", av[1], nl);
av++;
- } else
+ } else
break;
}
for(; *av != NULL; av++) {
fprintf(stderr, "Unknown http txresp spec: %s\n", *av);
exit (1);
}
- if (body != NULL)
+ if (body != NULL)
vsb_printf(hp->vsb, "Content-Length: %d%s", strlen(body), nl);
vsb_cat(hp->vsb, nl);
if (body != NULL) {
fprintf(stderr, "Unknown http txreq spec: %s\n", *av);
exit (1);
}
- if (body != NULL)
+ if (body != NULL)
vsb_printf(hp->vsb, "Content-Length: %d%s", strlen(body), nl);
vsb_cat(hp->vsb, nl);
if (body != NULL) {
/*
* Copyright (c) 2006-2008 Linpro AS
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
struct vtclog *vl;
ALLOC_OBJ(vl, VTCLOG_MAGIC);
- AN(vl);
+ AN(vl);
vl->id = id;
vl->vsb = vsb_newauto();
return (vl);
vsb_clear(vl->vsb);
if (pfx == NULL)
pfx = "";
- if (str == NULL)
+ if (str == NULL)
vsb_printf(vl->vsb, "%s %-4s %s(null)\n",
lead[lvl], vl->id, pfx);
else
/*
* Copyright (c) 2006-2008 Linpro AS
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
VTAILQ_FOREACH(r, &semas, list)
if (!strcmp(r->name, av[0]))
break;
- if (r == NULL)
+ if (r == NULL)
r = sema_new(av[0], vl);
AZ(pthread_mutex_unlock(&sema_mtx));
av++;
/*
* Copyright (c) 2006-2008 Linpro AS
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
unsigned repeat;
char *spec;
-
+
int depth;
int sock;
char *listen;
/* Reset and free */
VTAILQ_FOREACH_SAFE(s, &servers, list, s2) {
VTAILQ_REMOVE(&servers, s, list);
- if (s->sock >= 0)
+ if (s->sock >= 0)
server_wait(s);
server_delete(s);
}
VTAILQ_FOREACH(s, &servers, list)
if (!strcmp(s->name, av[0]))
break;
- if (s == NULL)
+ if (s == NULL)
s = server_new(av[0]);
av++;
/*
* Copyright (c) 2006-2008 Linpro AS
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
for (i = 0; i < 10; i++, usleep(100000)) {
-#define MAC_STAT(n, t, f, d) \
+#define MAC_STAT(n, t, f, d) \
if (!strcmp(av[0], #n)) { \
val = v->stats->n; \
} else
VTAILQ_FOREACH(v, &varnishes, list)
if (!strcmp(v->name, av[0]))
break;
- if (v == NULL)
+ if (v == NULL)
v = varnish_new(av[0]);
av++;
static void
usage(void)
{
- fprintf(stderr, "usage: varnishtop %s [-1fV] [-n varnish_name]\n", VSL_USAGE);
+ fprintf(stderr,
+ "usage: varnishtop %s [-1fV] [-n varnish_name]\n", VSL_USAGE);
exit(1);
}
"url.query", \
"url.query <url>", \
"\tQuery the cache status of a specific URL.\n" \
- "\tReturns the TTL, size and checksum of the object.", \
+ "\tReturns the TTL, size and checksum of the object.", \
1, 1
#define CLI_PURGE_URL \
*
* $Id$
*
+ * Argument list:
+ * ---------------------------------------
* a Http header name
* b session field name
* c Request(1)/Response(2) bitfield
*
* see [RFC2616 13.5.1 End-to-end and Hop-by-hop Headers]
*
- * a b c d e f g
- *--------------------------------------------------------------------
*/
#ifndef HTTPH_R_PASS
#define HTTPH_A_DELIVER (1 << 5) /* Response (o->c) for deliver */
#endif
-HTTPH("Keep-Alive", H_Keep_Alive, 3, 3, HTTPH_R_PASS|HTTPH_A_PASS|HTTPH_R_FETCH, 0, 0) /* RFC2068 */
-
-HTTPH("Accept", H_Accept, 1, 0, 0, 0, 0) /* RFC2616 14.1 */
-HTTPH("Accept-Charset", H_Accept_Charset, 1, 0, 0, 0, 0) /* RFC2616 14.2 */
-HTTPH("Accept-Encoding", H_Accept_Encoding, 1, 0, 0, 0, 0) /* RFC2616 14.3 */
-HTTPH("Accept-Language", H_Accept_Language, 1, 0, 0, 0, 0) /* RFC2616 14.4 */
-HTTPH("Accept-Ranges", H_Accept_Ranges, 2, 3, HTTPH_R_PASS|HTTPH_A_PASS|HTTPH_R_FETCH|HTTPH_A_INS, 0, 0) /* RFC2616 14.5 */
-HTTPH("Age", H_Age, 2, 0, HTTPH_A_INS, 0, 0) /* RFC2616 14.6 */
-HTTPH("Allow", H_Allow, 2, 0, 0, 0, 0) /* RFC2616 14.7 */
-HTTPH("Authorization", H_Authorization, 1, 0, 0, 0, 0) /* RFC2616 14.8 */
-HTTPH("Cache-Control", H_Cache_Control, 3, 3, HTTPH_R_PASS|HTTPH_R_FETCH, 0, 0) /* RFC2616 14.9 */
-HTTPH("Connection", H_Connection, 3, 3, HTTPH_R_PASS|HTTPH_A_PASS|HTTPH_R_FETCH|HTTPH_A_INS, 0, 0) /* RFC2616 14.10 */
-HTTPH("Content-Encoding", H_Content_Encoding, 2, 0, 0, 0, 0) /* RFC2616 14.11 */
-HTTPH("Content-Langugae", H_Content_Language, 2, 0, 0, 0, 0) /* RFC2616 14.12 */
-HTTPH("Content-Length", H_Content_Length, 2, 2, HTTPH_R_FETCH|HTTPH_A_INS, 0, 0) /* RFC2616 14.13 */
-HTTPH("Content-Location", H_Content_Location, 2, 0, 0, 0, 0) /* RFC2616 14.14 */
-HTTPH("Content-MD5", H_Content_MD5, 2, 0, 0, 0, 0) /* RFC2616 14.15 */
-HTTPH("Content-Range", H_Content_Range, 2, 3, HTTPH_R_PASS|HTTPH_A_PASS|HTTPH_R_FETCH|HTTPH_A_INS, 0, 0) /* RFC2616 14.16 */
-HTTPH("Content-Type", H_Content_Type, 2, 0, 0, 0, 0) /* RFC2616 14.17 */
-HTTPH("Date", H_Date, 2, 0, HTTPH_A_DELIVER, 0, 0) /* RFC2616 14.18 */
-HTTPH("ETag", H_ETag, 2, 0, 0, 0, 0) /* RFC2616 14.19 */
-HTTPH("Expect", H_Expect, 1, 0, 0, 0, 0) /* RFC2616 14.20 */
-HTTPH("Expires", H_Expires, 2, 0, 0, 0, 0) /* RFC2616 14.21 */
-HTTPH("From", H_From, 1, 0, 0, 0, 0) /* RFC2616 14.22 */
-HTTPH("Host", H_Host, 1, 0, 0, 0, 0) /* RFC2616 14.23 */
-HTTPH("If-Match", H_If_Match, 1, 1, HTTPH_R_FETCH, 0, 0) /* RFC2616 14.24 */
-HTTPH("If-Modified-Since", H_If_Modified_Since, 1, 1, HTTPH_R_FETCH, 0, 0) /* RFC2616 14.25 */
-HTTPH("If-None-Match", H_If_None_Match, 1, 1, HTTPH_R_FETCH, 0, 0) /* RFC2616 14.26 */
-HTTPH("If-Range", H_If_Range, 1, 1, HTTPH_R_FETCH, 0, 0) /* RFC2616 14.27 */
-HTTPH("If-Unmodified-Since", H_If_Unmodifed_Since, 1, 1, HTTPH_R_FETCH, 0, 0) /* RFC2616 14.28 */
-HTTPH("Last-Modified", H_Last_Modified, 2, 0, 0, 0, 0) /* RFC2616 14.29 */
-HTTPH("Location", H_Location, 2, 0, 0, 0, 0) /* RFC2616 14.30 */
-HTTPH("Max-Forwards", H_Max_Forwards, 1, 0, 0, 0, 0) /* RFC2616 14.31 */
-HTTPH("Pragma", H_Pragma, 1, 0, 0, 0, 0) /* RFC2616 14.32 */
-HTTPH("Proxy-Authenticate", H_Proxy_Authenticate, 2, 3, HTTPH_R_FETCH|HTTPH_A_INS, 0, 0) /* RFC2616 14.33 */
-HTTPH("Proxy-Authorization", H_Proxy_Authorization, 1, 3, HTTPH_R_FETCH|HTTPH_A_INS, 0, 0) /* RFC2616 14.34 */
-HTTPH("Range", H_Range, 1, 0, 0, 0, 0) /* RFC2616 14.35 */
-HTTPH("Referer", H_Referer, 1, 0, 0, 0, 0) /* RFC2616 14.36 */
-HTTPH("Retry-After", H_Retry_After, 2, 0, 0, 0, 0) /* RFC2616 14.37 */
-HTTPH("Server", H_Server, 2, 0, 0, 0, 0) /* RFC2616 14.38 */
-HTTPH("TE", H_TE, 1, 3, HTTPH_R_PASS|HTTPH_A_PASS|HTTPH_R_FETCH|HTTPH_A_INS, 0, 0) /* RFC2616 14.39 */
-HTTPH("Trailer", H_Trailer, 1, 3, HTTPH_R_PASS|HTTPH_A_PASS|HTTPH_R_FETCH|HTTPH_A_INS, 0, 0) /* RFC2616 14.40 */
-HTTPH("Transfer-Encoding", H_Transfer_Encoding, 2, 3, HTTPH_R_PASS|HTTPH_A_PASS|HTTPH_R_FETCH|HTTPH_A_INS, 0, 0) /* RFC2616 14.41 */
-HTTPH("Upgrade", H_Upgrade, 2, 3, HTTPH_R_PASS|HTTPH_A_PASS|HTTPH_R_FETCH|HTTPH_A_INS, 0, 0) /* RFC2616 14.42 */
-HTTPH("User-Agent", H_User_Agent, 1, 0, 0, 0, 0) /* RFC2616 14.43 */
-HTTPH("Vary", H_Vary, 2, 0, 0, 0, 0) /* RFC2616 14.44 */
-HTTPH("Via", H_Via, 2, 0, 0, 0, 0) /* RFC2616 14.45 */
-HTTPH("Warning", H_Warning, 2, 0, 0, 0, 0) /* RFC2616 14.46 */
-HTTPH("WWW-Authenticate", H_WWW_Authenticate, 2, 0, 0, 0, 0) /* RFC2616 14.47 */
+HTTPH("Keep-Alive", H_Keep_Alive, 3, 3, HTTPH_R_PASS | HTTPH_A_PASS | HTTPH_R_FETCH, 0, 0) /* RFC2068 */
+HTTPH("Accept", H_Accept, 1, 0, 0, 0, 0) /* RFC2616 14.1 */
+HTTPH("Accept-Charset", H_Accept_Charset, 1, 0, 0, 0, 0) /* RFC2616 14.2 */
+HTTPH("Accept-Encoding", H_Accept_Encoding, 1, 0, 0, 0, 0) /* RFC2616 14.3 */
+HTTPH("Accept-Language", H_Accept_Language, 1, 0, 0, 0, 0) /* RFC2616 14.4 */
+HTTPH("Accept-Ranges", H_Accept_Ranges, 2, 3, HTTPH_R_PASS | HTTPH_A_PASS | HTTPH_R_FETCH | HTTPH_A_INS, 0, 0) /* RFC2616 14.5 */
+HTTPH("Age", H_Age, 2, 0, HTTPH_A_INS, 0, 0) /* RFC2616 14.6 */
+HTTPH("Allow", H_Allow, 2, 0, 0, 0, 0) /* RFC2616 14.7 */
+HTTPH("Authorization", H_Authorization, 1, 0, 0, 0, 0) /* RFC2616 14.8 */
+HTTPH("Cache-Control", H_Cache_Control, 3, 3, HTTPH_R_PASS | HTTPH_R_FETCH, 0, 0) /* RFC2616 14.9 */
+HTTPH("Connection", H_Connection, 3, 3, HTTPH_R_PASS | HTTPH_A_PASS | HTTPH_R_FETCH | HTTPH_A_INS, 0, 0) /* RFC2616 14.10 */
+HTTPH("Content-Encoding", H_Content_Encoding, 2, 0, 0, 0, 0) /* RFC2616 14.11 */
+HTTPH("Content-Langugae", H_Content_Language, 2, 0, 0, 0, 0) /* RFC2616 14.12 */
+HTTPH("Content-Length", H_Content_Length, 2, 2, HTTPH_R_FETCH | HTTPH_A_INS, 0, 0) /* RFC2616 14.13 */
+HTTPH("Content-Location", H_Content_Location, 2, 0, 0, 0, 0) /* RFC2616 14.14 */
+HTTPH("Content-MD5", H_Content_MD5, 2, 0, 0, 0, 0) /* RFC2616 14.15 */
+HTTPH("Content-Range", H_Content_Range, 2, 3, HTTPH_R_PASS | HTTPH_A_PASS | HTTPH_R_FETCH | HTTPH_A_INS, 0, 0) /* RFC2616 14.16 */
+HTTPH("Content-Type", H_Content_Type, 2, 0, 0, 0, 0) /* RFC2616 14.17 */
+HTTPH("Date", H_Date, 2, 0, HTTPH_A_DELIVER, 0, 0) /* RFC2616 14.18 */
+HTTPH("ETag", H_ETag, 2, 0, 0, 0, 0) /* RFC2616 14.19 */
+HTTPH("Expect", H_Expect, 1, 0, 0, 0, 0) /* RFC2616 14.20 */
+HTTPH("Expires", H_Expires, 2, 0, 0, 0, 0) /* RFC2616 14.21 */
+HTTPH("From", H_From, 1, 0, 0, 0, 0) /* RFC2616 14.22 */
+HTTPH("Host", H_Host, 1, 0, 0, 0, 0) /* RFC2616 14.23 */
+HTTPH("If-Match", H_If_Match, 1, 1, HTTPH_R_FETCH, 0, 0) /* RFC2616 14.24 */
+HTTPH("If-Modified-Since", H_If_Modified_Since, 1, 1, HTTPH_R_FETCH, 0, 0) /* RFC2616 14.25 */
+HTTPH("If-None-Match", H_If_None_Match, 1, 1, HTTPH_R_FETCH, 0, 0) /* RFC2616 14.26 */
+HTTPH("If-Range", H_If_Range, 1, 1, HTTPH_R_FETCH, 0, 0) /* RFC2616 14.27 */
+HTTPH("If-Unmodified-Since", H_If_Unmodifed_Since, 1, 1, HTTPH_R_FETCH, 0, 0) /* RFC2616 14.28 */
+HTTPH("Last-Modified", H_Last_Modified, 2, 0, 0, 0, 0) /* RFC2616 14.29 */
+HTTPH("Location", H_Location, 2, 0, 0, 0, 0) /* RFC2616 14.30 */
+HTTPH("Max-Forwards", H_Max_Forwards, 1, 0, 0, 0, 0) /* RFC2616 14.31 */
+HTTPH("Pragma", H_Pragma, 1, 0, 0, 0, 0) /* RFC2616 14.32 */
+HTTPH("Proxy-Authenticate", H_Proxy_Authenticate, 2, 3, HTTPH_R_FETCH | HTTPH_A_INS, 0, 0) /* RFC2616 14.33 */
+HTTPH("Proxy-Authorization", H_Proxy_Authorization, 1, 3, HTTPH_R_FETCH | HTTPH_A_INS, 0, 0) /* RFC2616 14.34 */
+HTTPH("Range", H_Range, 1, 0, 0, 0, 0) /* RFC2616 14.35 */
+HTTPH("Referer", H_Referer, 1, 0, 0, 0, 0) /* RFC2616 14.36 */
+HTTPH("Retry-After", H_Retry_After, 2, 0, 0, 0, 0) /* RFC2616 14.37 */
+HTTPH("Server", H_Server, 2, 0, 0, 0, 0) /* RFC2616 14.38 */
+HTTPH("TE", H_TE, 1, 3, HTTPH_R_PASS | HTTPH_A_PASS | HTTPH_R_FETCH | HTTPH_A_INS, 0, 0) /* RFC2616 14.39 */
+HTTPH("Trailer", H_Trailer, 1, 3, HTTPH_R_PASS | HTTPH_A_PASS | HTTPH_R_FETCH | HTTPH_A_INS, 0, 0) /* RFC2616 14.40 */
+HTTPH("Transfer-Encoding", H_Transfer_Encoding, 2, 3, HTTPH_R_PASS | HTTPH_A_PASS | HTTPH_R_FETCH | HTTPH_A_INS, 0, 0) /* RFC2616 14.41 */
+HTTPH("Upgrade", H_Upgrade, 2, 3, HTTPH_R_PASS | HTTPH_A_PASS | HTTPH_R_FETCH | HTTPH_A_INS, 0, 0) /* RFC2616 14.42 */
+HTTPH("User-Agent", H_User_Agent, 1, 0, 0, 0, 0) /* RFC2616 14.43 */
+HTTPH("Vary", H_Vary, 2, 0, 0, 0, 0) /* RFC2616 14.44 */
+HTTPH("Via", H_Via, 2, 0, 0, 0, 0) /* RFC2616 14.45 */
+HTTPH("Warning", H_Warning, 2, 0, 0, 0, 0) /* RFC2616 14.46 */
+HTTPH("WWW-Authenticate", H_WWW_Authenticate, 2, 0, 0, 0, 0) /* RFC2616 14.47 */
void TCP_blocking(int sock);
void TCP_nonblocking(int sock);
#ifdef SOL_SOCKET
-void TCP_name(const struct sockaddr *addr, unsigned l, char *abuf, unsigned alen, char *pbuf, unsigned plen);
-int TCP_connect(int s, const struct sockaddr *name, socklen_t namelen, int msec);
+void TCP_name(const struct sockaddr *addr, unsigned l, char *abuf,
+ unsigned alen, char *pbuf, unsigned plen);
+int TCP_connect(int s, const struct sockaddr *name, socklen_t namelen,
+ int msec);
void TCP_close(int *s);
#endif
* handle gracefully, such as malloc failure.
*/
-typedef void lbv_assert_f(const char *, const char *, int, const char *, int, int);
+typedef void lbv_assert_f(const char *, const char *, int, const char *,
+ int, int);
extern lbv_assert_f *lbv_assert;
#define assert(e) ((void)(e))
#else /* WITH_ASSERTS */
#define assert(e) \
-do { \
+do { \
if (!(e)) \
lbv_assert(__func__, __FILE__, __LINE__, #e, errno, 0); \
} while (0)
#endif
#define xxxassert(e) \
-do { \
+do { \
if (!(e)) \
lbv_assert(__func__, __FILE__, __LINE__, #e, errno, 1); \
} while (0)
#define XXXAZ(foo) do { xxxassert((foo) == 0); } while (0)
#define XXXAN(foo) do { xxxassert((foo) != 0); } while (0)
#define diagnostic(foo) assert(foo)
-#define WRONG(expl) \
+#define WRONG(expl) \
do { \
lbv_assert(__func__, __FILE__, __LINE__, expl, errno, 3); \
} while (0)
MAC_STAT(cache_miss, uint64_t, 'a', "Cache misses")
MAC_STAT(backend_conn, uint64_t, 'a', "Backend connections success")
-MAC_STAT(backend_unhealthy, uint64_t, 'a', "Backend connections not attempted")
+MAC_STAT(backend_unhealthy, uint64_t, 'a',
+ "Backend connections not attempted")
MAC_STAT(backend_busy, uint64_t, 'a', "Backend connections too many")
MAC_STAT(backend_fail, uint64_t, 'a', "Backend connections failures")
MAC_STAT(backend_reuse, uint64_t, 'a', "Backend connections reuses")
int base64_decode(char *d, unsigned dlen, const char *s);
/* shmlog.c */
-typedef int vsl_handler(void *priv, enum shmlogtag tag, unsigned fd, unsigned len, unsigned spec, const char *ptr);
+typedef int vsl_handler(void *priv, enum shmlogtag tag, unsigned fd,
+ unsigned len, unsigned spec, const char *ptr);
#define VSL_S_CLIENT (1 << 0)
#define VSL_S_BACKEND (1 << 1)
#define VSL_ARGS "bCcdI:i:k:r:s:X:x:"
-#define VSL_USAGE "[-bCcd] [-i tag] [-I regexp] [-k keep] [-r file] [-s skip] [-X regexp] [-x tag]"
+#define VSL_USAGE "[-bCcd] [-i tag] [-I regexp] [-k keep]" \
+ " [-r file] [-s skip] [-X regexp] [-x tag]"
vsl_handler VSL_H_Print;
struct VSL_data;
struct VSL_data *VSL_New(void);
extern const char *VSL_tags[256];
/* instance.c */
-int varnish_instance(const char *n_arg, char *name, size_t namelen, char *dir, size_t dirlen);
-
+int varnish_instance(const char *n_arg, char *name, size_t namelen, char *dir,
+ size_t dirlen);
#endif
unsigned nref;
unsigned busy;
unsigned discard;
-
+
unsigned nsrc;
const char **srcname;
const char **srcbody;
#endif
#ifdef VCL_MET_MAC
-VCL_MET_MAC(recv,RECV,(VCL_RET_ERROR|VCL_RET_PASS|VCL_RET_PIPE|VCL_RET_LOOKUP))
-VCL_MET_MAC(pipe,PIPE,(VCL_RET_ERROR|VCL_RET_PIPE))
-VCL_MET_MAC(pass,PASS,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS))
-VCL_MET_MAC(hash,HASH,(VCL_RET_HASH))
-VCL_MET_MAC(miss,MISS,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_FETCH))
-VCL_MET_MAC(hit,HIT,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_DELIVER))
-VCL_MET_MAC(fetch,FETCH,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_DELIVER))
-VCL_MET_MAC(deliver,DELIVER,(VCL_RET_RESTART|VCL_RET_DELIVER))
-VCL_MET_MAC(prefetch,PREFETCH,(VCL_RET_FETCH|VCL_RET_PASS))
-VCL_MET_MAC(timeout,TIMEOUT,(VCL_RET_FETCH|VCL_RET_DISCARD))
-VCL_MET_MAC(discard,DISCARD,(VCL_RET_DISCARD|VCL_RET_KEEP))
-VCL_MET_MAC(error,ERROR,(VCL_RET_DELIVER))
+VCL_MET_MAC(recv,RECV,(
+ VCL_RET_ERROR|VCL_RET_PASS|VCL_RET_PIPE|VCL_RET_LOOKUP))
+VCL_MET_MAC(pipe,PIPE,(
+ VCL_RET_ERROR|VCL_RET_PIPE))
+VCL_MET_MAC(pass,PASS,(
+ VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS))
+VCL_MET_MAC(hash,HASH,(
+ VCL_RET_HASH))
+VCL_MET_MAC(miss,MISS,(
+ VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_FETCH))
+VCL_MET_MAC(hit,HIT,(
+ VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_DELIVER))
+VCL_MET_MAC(fetch,FETCH,(
+ VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_DELIVER))
+VCL_MET_MAC(deliver,DELIVER,(
+ VCL_RET_RESTART|VCL_RET_DELIVER))
+VCL_MET_MAC(prefetch,PREFETCH,(
+ VCL_RET_FETCH|VCL_RET_PASS))
+VCL_MET_MAC(timeout,TIMEOUT,(
+ VCL_RET_FETCH|VCL_RET_DISCARD))
+VCL_MET_MAC(discard,DISCARD,(
+ VCL_RET_DISCARD|VCL_RET_KEEP))
+VCL_MET_MAC(error,ERROR,(
+ VCL_RET_DELIVER))
#else
#define VCL_MET_RECV (1 << 0)
#define VCL_MET_PIPE (1 << 1)
/* from libvarnish/vct.c */
-#define VCT_SP (1<<0)
-#define VCT_CRLF (1<<1)
-#define VCT_LWS (VCT_CRLF | VCT_SP)
-#define VCT_CTL (1<<2)
+#define VCT_SP (1<<0)
+#define VCT_CRLF (1<<1)
+#define VCT_LWS (VCT_CRLF | VCT_SP)
+#define VCT_CTL (1<<2)
#define VCT_ALPHA (1<<3)
#define VCT_SEPARATOR (1<<4)
#define VCT_DIGIT (1<<5)
static inline int
vct_is(unsigned char x, unsigned char y)
{
-
- return (vct_typtab[x] & (y));
+
+ return (vct_typtab[x] & (y));
}
#define vct_issp(x) vct_is(x, VCT_SP)
struct vev {
unsigned magic;
-#define VEV_MAGIC 0x46bbd419
+#define VEV_MAGIC 0x46bbd419
/* pub */
const char *name;
} while (0)
#define VSTAILQ_INSERT_AFTER(head, tqelm, elm, field) do { \
- if ((VSTAILQ_NEXT((elm), field) = VSTAILQ_NEXT((tqelm), field)) == NULL)\
+ if ((VSTAILQ_NEXT((elm), field) = \
+ VSTAILQ_NEXT((tqelm), field)) == NULL) \
(head)->vstqh_last = &VSTAILQ_NEXT((elm), field); \
VSTAILQ_NEXT((tqelm), field) = (elm); \
} while (0)
(VSTAILQ_EMPTY((head)) ? \
NULL : \
((struct type *)(void *) \
- ((char *)((head)->vstqh_last) - __offsetof(struct type, field))))
+ ((char *)((head)->vstqh_last) - \
+ __offsetof(struct type, field))))
#define VSTAILQ_NEXT(elm, field) ((elm)->field.vstqe_next)
#define VLIST_INSERT_HEAD(head, elm, field) do { \
if ((VLIST_NEXT((elm), field) = VLIST_FIRST((head))) != NULL) \
- VLIST_FIRST((head))->field.vle_prev = &VLIST_NEXT((elm), field);\
+ VLIST_FIRST((head))->field.vle_prev = \
+ &VLIST_NEXT((elm), field); \
VLIST_FIRST((head)) = (elm); \
(elm)->field.vle_prev = &VLIST_FIRST((head)); \
} while (0)
#define VLIST_REMOVE(elm, field) do { \
if (VLIST_NEXT((elm), field) != NULL) \
- VLIST_NEXT((elm), field)->field.vle_prev = \
+ VLIST_NEXT((elm), field)->field.vle_prev = \
(elm)->field.vle_prev; \
*(elm)->field.vle_prev = VLIST_NEXT((elm), field); \
} while (0)
} while (0)
#define VTAILQ_INSERT_AFTER(head, listelm, elm, field) do { \
- if ((VTAILQ_NEXT((elm), field) = VTAILQ_NEXT((listelm), field)) != NULL)\
- VTAILQ_NEXT((elm), field)->field.vtqe_prev = \
+ if ((VTAILQ_NEXT((elm), field) = \
+ VTAILQ_NEXT((listelm), field)) != NULL) \
+ VTAILQ_NEXT((elm), field)->field.vtqe_prev = \
&VTAILQ_NEXT((elm), field); \
else { \
(head)->vtqh_last = &VTAILQ_NEXT((elm), field); \
#define VTAILQ_REMOVE(head, elm, field) do { \
if ((VTAILQ_NEXT((elm), field)) != NULL) \
- VTAILQ_NEXT((elm), field)->field.vtqe_prev = \
+ VTAILQ_NEXT((elm), field)->field.vtqe_prev = \
(elm)->field.vtqe_prev; \
else { \
(head)->vtqh_last = (elm)->field.vtqe_prev; \
double connect_timeout;
unsigned max_connections;
- struct vrt_backend_probe probe;
+ struct vrt_backend_probe probe;
};
/*
};
struct vrt_dir_random {
- const char *name;
+ const char *name;
unsigned retries;
- unsigned nmember;
+ unsigned nmember;
const struct vrt_dir_random_entry *members;
};
struct vrt_dir_round_robin {
const char *name;
- unsigned nmember;
+ unsigned nmember;
const struct vrt_dir_round_robin_entry *members;
};
void VRT_re_fini(void *);
int VRT_re_match(const char *, void *re);
int VRT_re_test(struct vsb *, const char *, int sub);
-const char *VRT_regsub(const struct sess *sp, int all, const char *, void *, const char *);
+const char *VRT_regsub(const struct sess *sp, int all, const char *,
+ void *, const char *);
void VRT_panic(struct sess *sp, const char *, ...);
void VRT_purge(const char *, int hash);
enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BEREQ };
char *VRT_GetHdr(const struct sess *, enum gethdr_e where, const char *);
-void VRT_SetHdr(const struct sess *, enum gethdr_e where, const char *, const char *, ...);
+void VRT_SetHdr(const struct sess *, enum gethdr_e where, const char *,
+ const char *, ...);
void VRT_handling(struct sess *sp, unsigned hand);
/* Simple stuff */
void VRT_synth_page(struct sess *sp, unsigned flags, const char *, ...);
/* Backend related */
-void VRT_init_dir_simple(struct cli *, struct director **, const struct vrt_dir_simple *);
-void VRT_init_dir_random(struct cli *, struct director **, const struct vrt_dir_random *);
-void VRT_init_dir_round_robin(struct cli *, struct director **, const struct vrt_dir_round_robin *);
+void VRT_init_dir_simple(struct cli *, struct director **,
+ const struct vrt_dir_simple *);
+void VRT_init_dir_random(struct cli *, struct director **,
+ const struct vrt_dir_random *);
+void VRT_init_dir_round_robin(struct cli *, struct director **,
+ const struct vrt_dir_round_robin *);
void VRT_fini_dir(struct cli *, struct director *);
char *VRT_IP_string(const struct sess *sp, const struct sockaddr *sa);
int vsb_bcpy(struct vsb *, const void *, size_t);
int vsb_cat(struct vsb *, const char *);
int vsb_cpy(struct vsb *, const char *);
-int vsb_printf(struct vsb *, const char *, ...) /* __printflike(2, 3) */;
+int vsb_printf(struct vsb *, const char *, ...)
+ /* __printflike(2, 3) */;
#ifdef va_start
-int vsb_vprintf(struct vsb *, const char *, va_list) /* __printflike(2, 0) */;
+int vsb_vprintf(struct vsb *, const char *, va_list)
+ /* __printflike(2, 0) */;
#endif
int vsb_putc(struct vsb *, int);
int vsb_trim(struct vsb *);
#include "libvarnish.h"
static void
-lbv_assert_default(const char *func, const char *file, int line, const char *cond, int err, int xxx)
+lbv_assert_default(const char *func, const char *file, int line,
+ const char *cond, int err, int xxx)
{
if (xxx) {
#ifdef TEST_DRIVER
/* Test driver -------------------------------------------------------*/
-
#include <stdio.h>
#if 0
-
static int
cmp(void *priv, void *a, void *b)
{
dump(bh, "Delete", u);
}
printf("Deletes done\n");
-
return (0);
}
#else
-
struct foo {
unsigned idx;
unsigned key;
struct foo ff[N];
-
static int
cmp(void *priv, void *a, void *b)
{
struct binheap *bh;
unsigned u, v;
-#if 0
- srandomdev();
- u = random();
- printf("Seed %u\n", u);
- srandom(u);
-#endif
+ if (0) {
+ srandomdev();
+ u = random();
+ printf("Seed %u\n", u);
+ srandom(u);
+ }
bh = binheap_new(NULL, cmp, update);
for (u = 0; u < M; u++) {
v = random() % N;
{
cli_result(cli, CLIS_PARAM);
- cli_out(cli, "Parameter error, use \"help [command]\" for more info.\n");
+ cli_out(cli,
+ "Parameter error, use \"help [command]\" for more info.\n");
}
int
uintmax_t val;
const char *err;
} test_cases[] = {
- { "1", (uintmax_t)0, (uintmax_t)1 },
- { "1B", (uintmax_t)0, (uintmax_t)1<<0 },
- { "1 B", (uintmax_t)0, (uintmax_t)1<<0 },
- { "1.3B", (uintmax_t)0, (uintmax_t)1 },
- { "1.7B", (uintmax_t)0, (uintmax_t)2 },
-
- { "1024", (uintmax_t)0, (uintmax_t)1024 },
- { "1k", (uintmax_t)0, (uintmax_t)1<<10 },
- { "1kB", (uintmax_t)0, (uintmax_t)1<<10 },
- { "1.3kB", (uintmax_t)0, (uintmax_t)1331 },
- { "1.7kB", (uintmax_t)0, (uintmax_t)1741 },
-
- { "1048576", (uintmax_t)0, (uintmax_t)1048576 },
- { "1M", (uintmax_t)0, (uintmax_t)1<<20 },
- { "1MB", (uintmax_t)0, (uintmax_t)1<<20 },
- { "1.3MB", (uintmax_t)0, (uintmax_t)1363149 },
- { "1.7MB", (uintmax_t)0, (uintmax_t)1782579 },
-
- { "1073741824", (uintmax_t)0, (uintmax_t)1073741824 },
- { "1G", (uintmax_t)0, (uintmax_t)1<<30 },
- { "1GB", (uintmax_t)0, (uintmax_t)1<<30 },
- { "1.3GB", (uintmax_t)0, (uintmax_t)1395864371 },
- { "1.7GB", (uintmax_t)0, (uintmax_t)1825361101 },
-
- { "1099511627776", (uintmax_t)0, (uintmax_t)1099511627776ULL },
- { "1T", (uintmax_t)0, (uintmax_t)1<<40 },
- { "1TB", (uintmax_t)0, (uintmax_t)1<<40 },
- { "1.3TB", (uintmax_t)0, (uintmax_t)1429365116109ULL },
- { "1.7TB", (uintmax_t)0, (uintmax_t)1869169767219ULL },
+ { "1", (uintmax_t)0, (uintmax_t)1 },
+ { "1B", (uintmax_t)0, (uintmax_t)1<<0 },
+ { "1 B", (uintmax_t)0, (uintmax_t)1<<0 },
+ { "1.3B", (uintmax_t)0, (uintmax_t)1 },
+ { "1.7B", (uintmax_t)0, (uintmax_t)2 },
+
+ { "1024", (uintmax_t)0, (uintmax_t)1024 },
+ { "1k", (uintmax_t)0, (uintmax_t)1<<10 },
+ { "1kB", (uintmax_t)0, (uintmax_t)1<<10 },
+ { "1.3kB", (uintmax_t)0, (uintmax_t)1331 },
+ { "1.7kB", (uintmax_t)0, (uintmax_t)1741 },
+
+ { "1048576", (uintmax_t)0, (uintmax_t)1048576 },
+ { "1M", (uintmax_t)0, (uintmax_t)1<<20 },
+ { "1MB", (uintmax_t)0, (uintmax_t)1<<20 },
+ { "1.3MB", (uintmax_t)0, (uintmax_t)1363149 },
+ { "1.7MB", (uintmax_t)0, (uintmax_t)1782579 },
+
+ { "1073741824", (uintmax_t)0, (uintmax_t)1073741824 },
+ { "1G", (uintmax_t)0, (uintmax_t)1<<30 },
+ { "1GB", (uintmax_t)0, (uintmax_t)1<<30 },
+ { "1.3GB", (uintmax_t)0, (uintmax_t)1395864371 },
+ { "1.7GB", (uintmax_t)0, (uintmax_t)1825361101 },
+
+ { "1099511627776", (uintmax_t)0, (uintmax_t)1099511627776ULL },
+ { "1T", (uintmax_t)0, (uintmax_t)1<<40 },
+ { "1TB", (uintmax_t)0, (uintmax_t)1<<40 },
+ { "1.3TB", (uintmax_t)0, (uintmax_t)1429365116109ULL },
+ { "1.7TB", (uintmax_t)0, (uintmax_t)1869169767219ULL },
{ "1%", (uintmax_t)1024, (uintmax_t)10 },
{ "2%", (uintmax_t)1024, (uintmax_t)20 },
{ "3%", (uintmax_t)1024, (uintmax_t)31 },
/* Check the error checks */
- { "", 0, 0, err_miss_num },
- { "m", 0, 0, err_invalid_num },
- { "4%", 0, 0, err_abs_req },
- { "3*", 0, 0, err_invalid_suff },
+ { "", 0, 0, err_miss_num },
+ { "m", 0, 0, err_invalid_num },
+ { "4%", 0, 0, err_abs_req },
+ { "3*", 0, 0, err_invalid_suff },
/* TODO: add more */
/*--------------------------------------------------------------------*/
void
-TCP_name(const struct sockaddr *addr, unsigned l, char *abuf, unsigned alen, char *pbuf, unsigned plen)
+TCP_name(const struct sockaddr *addr, unsigned l, char *abuf, unsigned alen,
+ char *pbuf, unsigned plen)
{
int i;
/*--------------------------------------------------------------------
* Functions for controlling NONBLOCK mode.
- *
+ *
* We use FIONBIO because it is cheaper than fcntl(2), which requires
* us to do two syscalls, one to get and one to set, the latter of
* which mucks about a bit before it ends up calling ioctl(FIONBIO),
[0x1d] = VCT_CTL,
[0x1e] = VCT_CTL,
[0x1f] = VCT_CTL,
- [0x20] = VCT_SP | VCT_SEPARATOR,
- [0x22] = VCT_SEPARATOR,
- [0x28] = VCT_SEPARATOR,
- [0x29] = VCT_SEPARATOR,
- [0x2c] = VCT_SEPARATOR,
- [0x2f] = VCT_SEPARATOR,
+ [0x20] = VCT_SP | VCT_SEPARATOR,
+ [0x22] = VCT_SEPARATOR,
+ [0x28] = VCT_SEPARATOR,
+ [0x29] = VCT_SEPARATOR,
+ [0x2c] = VCT_SEPARATOR,
+ [0x2f] = VCT_SEPARATOR,
[0x30] = VCT_DIGIT | VCT_HEX,
[0x31] = VCT_DIGIT | VCT_HEX,
[0x32] = VCT_DIGIT | VCT_HEX,
[0x37] = VCT_DIGIT | VCT_HEX,
[0x38] = VCT_DIGIT | VCT_HEX,
[0x39] = VCT_DIGIT | VCT_HEX,
- [0x3a] = VCT_SEPARATOR,
- [0x3b] = VCT_SEPARATOR,
- [0x3c] = VCT_SEPARATOR,
- [0x3d] = VCT_SEPARATOR,
- [0x3e] = VCT_SEPARATOR,
- [0x3f] = VCT_SEPARATOR,
- [0x40] = VCT_SEPARATOR,
+ [0x3a] = VCT_SEPARATOR,
+ [0x3b] = VCT_SEPARATOR,
+ [0x3c] = VCT_SEPARATOR,
+ [0x3d] = VCT_SEPARATOR,
+ [0x3e] = VCT_SEPARATOR,
+ [0x3f] = VCT_SEPARATOR,
+ [0x40] = VCT_SEPARATOR,
[0x41] = VCT_UPALPHA | VCT_HEX,
[0x42] = VCT_UPALPHA | VCT_HEX,
[0x43] = VCT_UPALPHA | VCT_HEX,
[0x58] = VCT_UPALPHA,
[0x59] = VCT_UPALPHA,
[0x5a] = VCT_UPALPHA,
- [0x5b] = VCT_SEPARATOR,
- [0x5c] = VCT_SEPARATOR,
- [0x5d] = VCT_SEPARATOR,
+ [0x5b] = VCT_SEPARATOR,
+ [0x5c] = VCT_SEPARATOR,
+ [0x5d] = VCT_SEPARATOR,
[0x61] = VCT_LOALPHA | VCT_HEX,
[0x62] = VCT_LOALPHA | VCT_HEX,
[0x63] = VCT_LOALPHA | VCT_HEX,
[0x78] = VCT_LOALPHA,
[0x79] = VCT_LOALPHA,
[0x7a] = VCT_LOALPHA,
- [0x7b] = VCT_SEPARATOR,
- [0x7d] = VCT_SEPARATOR,
+ [0x7b] = VCT_SEPARATOR,
+ [0x7d] = VCT_SEPARATOR,
[0x7f] = VCT_CTL,
};
{
fprintf(stderr, "%s (%s-%s)\n", progname,
PACKAGE_TARNAME, PACKAGE_VERSION);
- fprintf(stderr, "Copyright (c) 2006-2008 Linpro AS / Verdens Gang AS\n");
+ fprintf(stderr,
+ "Copyright (c) 2006-2008 Linpro AS / Verdens Gang AS\n");
}
if (l->buf == NULL) {
FREE_OBJ(l);
l = NULL;
- }
+ }
}
return (l);
}
if (retval >= 0)
break;
}
- for (n = 0; n < nvaddr; n++)
+ for (n = 0; n < nvaddr; n++)
free(vaddr[n]);
free(vaddr);
free(addr);
int
varnish_instance(const char *n_arg,
- char *name, size_t namelen,
- char *dir, size_t dirlen)
+ char *name, size_t namelen, char *dir, size_t dirlen)
{
size_t len;
/*--------------------------------------------------------------------*/
int
-VSL_H_Print(void *priv, enum shmlogtag tag, unsigned fd, unsigned len, unsigned spec, const char *ptr)
+VSL_H_Print(void *priv, enum shmlogtag tag, unsigned fd, unsigned len,
+ unsigned spec, const char *ptr)
{
FILE *fo = priv;
int type;
struct acl_e {
VTAILQ_ENTRY(acl_e) list;
unsigned char data[VRT_ACL_MAXADDR + 1];
- unsigned mask;
+ unsigned mask;
unsigned not;
unsigned para;
struct token *t_addr;
if (ae2->mask < m)
m = ae2->mask;
for (; m >= 8; m -= 8) {
- if (*p1 < *p2)
+ if (*p1 < *p2)
return (-1);
- if (*p1 > *p2)
+ if (*p1 > *p2)
return (1);
p1++;
p2++;
}
static void
-vcc_acl_emit_entry(struct tokenlist *tl, const struct acl_e *ae, int l, const unsigned char *u, int fam)
+vcc_acl_emit_entry(struct tokenlist *tl, const struct acl_e *ae, int l,
+ const unsigned char *u, int fam)
{
struct acl_e *ae2;
Fh(tl, 1, "/* Ignored ACL entry: %s%s",
ae->para ? "\"(\" " : "", ae->not ? "\"!\" " : "");
EncToken(tl->fh, ae->t_addr);
- if (ae->t_mask)
+ if (ae->t_mask)
Fh(tl, 0, "/%u", ae->mask);
Fh(tl, 0, "%s\n", ae->para ? " \")\"" : "");
Fh(tl, 1, " * getaddrinfo: %s */\n",
}
static void
-vcc_acl_bot(const struct tokenlist *tl, const char *acln, int silent, const char *pfx)
+vcc_acl_bot(const struct tokenlist *tl, const char *acln, int silent,
+ const char *pfx)
{
struct acl_e *ae;
int depth, l, m, i;
Fh(tl, 0, "\tunsigned int fam;\n");
else
assert(0 == __LINE__);
-
+
Fh(tl, 0, "\n");
Fh(tl, 0, "\ta = p;\n");
Fh(tl, 0, "\tVRT_memmove(&fam, a + %d, sizeof fam);\n",
Fh(tl, 0, "\t%*sreturn (%d);\n", -i, "", ae->not ? 0 : 1);
}
- for (; 0 <= depth; depth--)
+ for (; 0 <= depth; depth--)
Fh(tl, 0, "\t%*.*s}\n", depth, depth, "");
if (!silent)
Fh(tl, 0, "\tVRT_acl_log(sp, \"NO_MATCH %s\");\n", acln);
vcc_NextToken(tl);
ExpectErr(tl, ID);
vcc_AddRef(tl, tl->t, R_ACL);
- Fb(tl, 1, "match_acl_named_%.*s(sp, %s)\n", PF(tl->t), vp->rname);
+ Fb(tl, 1, "match_acl_named_%.*s(sp, %s)\n",
+ PF(tl->t), vp->rname);
vcc_NextToken(tl);
break;
case T_EQ:
/*--------------------------------------------------------------------*/
-#define VCL_RET_MAC(l,u,b,i) \
+#define VCL_RET_MAC(l,u,b,i) \
static void \
parse_##l(struct tokenlist *tl) \
{ \
\
- Fb(tl, 1, "VRT_done(sp, VCL_RET_%s);\n", #u); \
- vcc_ProcAction(tl->curproc, i, tl->t); \
+ Fb(tl, 1, "VRT_done(sp, VCL_RET_%s);\n", #u); \
+ vcc_ProcAction(tl->curproc, i, tl->t); \
vcc_NextToken(tl); \
}
parse_restart_real(struct tokenlist *tl)
{
struct token *t1;
-
+
t1 = VTAILQ_NEXT(tl->t, list);
if (t1->tok == ID && vcc_IdIs(t1, "rollback")) {
Fb(tl, 1, "VRT_Rollback(sp);\n");
Fb(tl, 0, "%u", vcc_UintVal(tl));
vcc_NextToken(tl);
} else {
- vsb_printf(tl->sb, "Cannot assign this variable type.\n");
+ vsb_printf(tl->sb,
+ "Cannot assign this variable type.\n");
vcc_ErrWhere(tl, vt);
return;
}
vcc_ExpectedStringval(tl);
return;
}
- do
+ do
Fb(tl, 0, ", ");
while (vcc_StringVal(tl));
if (tl->t->tok != ';') {
{
vcc_NextToken(tl);
-
+
Fb(tl, 1, "VRT_purge(");
-
+
Expect(tl, '(');
vcc_NextToken(tl);
-
+
if (!vcc_StringVal(tl)) {
vcc_ExpectedStringval(tl);
return;
}
-
+
Expect(tl, ')');
vcc_NextToken(tl);
Fb(tl, 0, ", 0);\n");
{
vcc_NextToken(tl);
-
+
Fb(tl, 1, "VRT_purge(");
-
+
Expect(tl, '(');
vcc_NextToken(tl);
-
+
if (!vcc_StringVal(tl)) {
vcc_ExpectedStringval(tl);
return;
}
-
+
Expect(tl, ')');
vcc_NextToken(tl);
Fb(tl, 0, ", 1);\n");
parse_panic(struct tokenlist *tl)
{
vcc_NextToken(tl);
-
+
Fb(tl, 1, "VRT_panic(sp, ");
if (!vcc_StringVal(tl)) {
vcc_ExpectedStringval(tl);
return;
}
- do
+ do
Fb(tl, 0, ", ");
while (vcc_StringVal(tl));
Fb(tl, 0, " vrt_magic_string_end);\n");
parse_synthetic(struct tokenlist *tl)
{
vcc_NextToken(tl);
-
+
Fb(tl, 1, "VRT_synth_page(sp, 0, ");
if (!vcc_StringVal(tl)) {
vcc_ExpectedStringval(tl);
return;
}
- do
+ do
Fb(tl, 0, ", ");
while (vcc_StringVal(tl));
Fb(tl, 0, " vrt_magic_string_end);\n");
} action_table[] = {
{ "restart", parse_restart_real },
#define VCL_RET_MAC(l, u, b, i) { #l, parse_##l },
-#define VCL_RET_MAC_E(l, u, b, i) VCL_RET_MAC(l, u, b, i)
+#define VCL_RET_MAC_E(l, u, b, i) VCL_RET_MAC(l, u, b, i)
#include "vcl_returns.h"
#undef VCL_RET_MAC
#undef VCL_RET_MAC_E
/* Keep list sorted from here */
- { "call", parse_call },
+ { "call", parse_call },
{ "esi", parse_esi },
{ "panic", parse_panic },
{ "purge_hash", parse_purge_hash },
{ "purge_url", parse_purge_url },
- { "remove", parse_unset }, /* backward compatibility */
- { "set", parse_set },
- { "synthetic", parse_synthetic },
- { "unset", parse_unset },
+ { "remove", parse_unset }, /* backward compatibility */
+ { "set", parse_set },
+ { "synthetic", parse_synthetic },
+ { "unset", parse_unset },
{ NULL, NULL }
};
* A VCL backend therefore has an implicit director of type "simple" created
* by the compiler, but not visible in VCL.
*
- * A VCL backend is a "named host", these can be referenced by name form
+ * A VCL backend is a "named host", these can be referenced by name from
* VCL directors, but not from VCL backends.
*
* The reason for this quasimadness is that we want to collect statistics
}
/*--------------------------------------------------------------------
- * Struct sockaddr is not really designed to be a compile time
+ * Struct sockaddr is not really designed to be a compile time
* initialized data structure, so we encode it as a byte-string
* and put it in an official sockaddr when we load the VCL.
*/
static void
-Emit_Sockaddr(struct tokenlist *tl, const struct token *t_host, const char *port)
+Emit_Sockaddr(struct tokenlist *tl, const struct token *t_host,
+ const char *port)
{
struct addrinfo *res, *res0, hint;
int n4, n6, len, error, retval;
if (res->ai_family == PF_INET) {
if (n4++ == 0)
emit = "ipv4_sockaddr";
- else
+ else
multiple = "IPv4";
} else if (res->ai_family == PF_INET6) {
if (n6++ == 0)
Fh(tl, 0, " %3u, /* Length */\n", res->ai_addrlen);
u = (void*)res->ai_addr;
for (len = 0; len < res->ai_addrlen; len++) {
- if ((len % 8) == 0)
+ if ((len % 8) == 0)
Fh(tl, 0, " ");
Fh(tl, 0, " %3u", u[len]);
if (len + 1 < res->ai_addrlen)
Fh(tl, 0, ",");
- if ((len % 8) == 7)
+ if ((len % 8) == 7)
Fh(tl, 0, "\n");
}
Fh(tl, 0, "\n};\n");
*/
static void
-vcc_EmitBeIdent(struct vsb *v, const struct token *name, const struct token *qual, int serial, const struct token *first, const struct token *last)
+vcc_EmitBeIdent(struct vsb *v, const struct token *name,
+ const struct token *qual, int serial, const struct token *first,
+ const struct token *last)
{
AN(name);
vcc_NextToken(tl);
for (; fs->name != NULL; fs++) {
- if (!vcc_IdIs(t_field, fs->name + 1))
+ if (!vcc_IdIs(t_field, fs->name + 1))
continue;
if (fs->found == NULL) {
fs->found = t_field;
*/
static void
-vcc_ProbeRedef(struct tokenlist *tl, struct token **t_did, struct token *t_field)
+vcc_ProbeRedef(struct tokenlist *tl, struct token **t_did,
+ struct token *t_field)
{
/* .url and .request are mutually exclusive */
}
/*--------------------------------------------------------------------
- * Parse and emit a backend host definition
- *
- * The syntax is the following:
- *
- * backend_host_def:
- * '{' be_elements '}'
- *
- * be_elements:
- * be_element
- * be_element be_elements
- *
- * be_element:
- * '.' name '=' value ';'
+ * Parse and emit a backend host definition
*
* The struct vrt_backend is emitted to Fh().
*/
static void
-vcc_ParseHostDef(struct tokenlist *tl, int *nbh, const struct token *name, const struct token *qual, int serial)
+vcc_ParseHostDef(struct tokenlist *tl, int *nbh, const struct token *name,
+ const struct token *qual, int serial)
{
struct token *t_field;
struct token *t_first;
*/
void
-vcc_ParseBackendHost(struct tokenlist *tl, int *nbh, const struct token *name, const struct token *qual, int serial)
+vcc_ParseBackendHost(struct tokenlist *tl, int *nbh, const struct token *name,
+ const struct token *qual, int serial)
{
struct host *h;
struct token *t;
*/
static void
-vcc_ParseSimpleDirector(struct tokenlist *tl, const struct token *t_first, struct token *t_dir)
+vcc_ParseSimpleDirector(struct tokenlist *tl, const struct token *t_first,
+ struct token *t_dir)
{
struct host *h;
const char *name;
parsedirector_f *func;
} dirlist[] = {
- { "random", vcc_ParseRandomDirector },
- { "round-robin", vcc_ParseRoundRobinDirector },
+ { "random", vcc_ParseRandomDirector },
+ { "round-robin", vcc_ParseRoundRobinDirector },
{ NULL, NULL }
};
t_policy = tl->t;
vcc_NextToken(tl);
- for (dl = dirlist; dl->name != NULL; dl++)
+ for (dl = dirlist; dl->name != NULL; dl++)
if (vcc_IdIs(t_policy, dl->name))
break;
if (dl->name == NULL) {
vcc_default_vcl_b = default_vcl;
vcc_default_vcl_e = strchr(default_vcl, '\0');
assert(vcc_default_vcl_e != NULL);
-
- vcl_init_tnames();
}
/* vcc_backend.c */
struct fld_spec;
-typedef void parsedirector_f(struct tokenlist *tl, const struct token *t_policy, const struct token *t_dir);
+typedef void parsedirector_f(struct tokenlist *tl,
+ const struct token *t_policy, const struct token *t_dir);
void vcc_ParseDirector(struct tokenlist *tl);
-void vcc_ParseBackendHost(struct tokenlist *tl, int *nbr, const struct token *name, const struct token *qual, int serial);
+void vcc_ParseBackendHost(struct tokenlist *tl, int *nbr,
+ const struct token *name, const struct token *qual, int serial);
struct fld_spec * vcc_FldSpec(struct tokenlist *tl, const char *first, ...);
void vcc_ResetFldSpec(struct fld_spec *f);
void vcc_IsField(struct tokenlist *tl, struct token **t, struct fld_spec *fs);
void vcc_ExpectedStringval(struct tokenlist *tl);
/* vcc_token.c */
-void vcc_Coord(const struct tokenlist *tl, struct vsb *vsb, const struct token *t);
+void vcc_Coord(const struct tokenlist *tl, struct vsb *vsb,
+ const struct token *t);
void vcc_ErrToken(const struct tokenlist *tl, const struct token *t);
void vcc_ErrWhere(struct tokenlist *tl, const struct token *t);
void vcc__Expect(struct tokenlist *tl, unsigned tok, int line);
void vcc_ExpectCid(struct tokenlist *tl);
void vcc_Lexer(struct tokenlist *tl, struct source *sp);
void vcc_NextToken(struct tokenlist *tl);
-void vcc__ErrInternal(struct tokenlist *tl, const char *func, unsigned line);
-void vcc_AddToken(struct tokenlist *tl, unsigned tok, const char *b, const char *e);
+void vcc__ErrInternal(struct tokenlist *tl, const char *func,
+ unsigned line);
+void vcc_AddToken(struct tokenlist *tl, unsigned tok, const char *b,
+ const char *e);
/* vcc_var.c */
-struct var *vcc_FindVar(struct tokenlist *tl, const struct token *t, struct var *vl);
+struct var *vcc_FindVar(struct tokenlist *tl, const struct token *t,
+ struct var *vl);
/* vcc_xref.c */
void vcc_AddDef(struct tokenlist *tl, struct token *t, enum ref_type type);
*/
void
-vcc_ParseRandomDirector(struct tokenlist *tl, const struct token *t_policy, const struct token *t_dir)
+vcc_ParseRandomDirector(struct tokenlist *tl, const struct token *t_policy,
+ const struct token *t_dir)
{
struct token *t_field, *t_be;
int nbh, nelem;
ExpectErr(tl, '{');
vcc_NextToken(tl);
Fc(tl, 0, "\t{");
-
+
while (tl->t->tok != '}') { /* Member fields */
vcc_IsField(tl, &t_field, mfs);
ERRCHK(tl);
*/
void
-vcc_ParseRoundRobinDirector(struct tokenlist *tl, const struct token *t_policy, const struct token *t_dir)
+vcc_ParseRoundRobinDirector(struct tokenlist *tl, const struct token *t_policy,
+ const struct token *t_dir)
{
struct token *t_field, *t_be;
int nbh, nelem;
fs = vcc_FldSpec(tl, "!backend", NULL);
- Fc(tl, 0,
- "\nstatic const struct vrt_dir_round_robin_entry vdrre_%.*s[] = {\n",
- PF(t_dir));
+ Fc(tl, 0, "\nstatic const struct vrt_dir_round_robin_entry "
+ "vdrre_%.*s[] = {\n", PF(t_dir));
for (nelem = 0; tl->t->tok != '}'; nelem++) { /* List of members */
first = "";
ExpectErr(tl, '{');
vcc_NextToken(tl);
Fc(tl, 0, "\t{");
-
+
while (tl->t->tok != '}') { /* Member fields */
vcc_IsField(tl, &t_field, fs);
ERRCHK(tl);
Fc(tl, 0, "\t.nmember = %d,\n", nelem);
Fc(tl, 0, "\t.members = vdrre_%.*s,\n", PF(t_dir));
Fc(tl, 0, "};\n");
- Fi(tl, 0,
- "\tVRT_init_dir_round_robin(cli, &VGC_backend_%.*s , &vdrr_%.*s);\n",
- PF(t_dir), PF(t_dir));
+ Fi(tl, 0, "\tVRT_init_dir_round_robin("
+ "cli, &VGC_backend_%.*s , &vdrr_%.*s);\n", PF(t_dir), PF(t_dir));
Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend_%.*s);\n", PF(t_dir));
}
#include "vcc_priv.h"
#include "vsb.h"
+#define M1() do {*q = p + 1; return (p[0]); } while (0)
+#define M2(c, t) do {if (p[1] == (c)) { *q = p + 2; return (t); }} while (0)
+
unsigned
vcl_fixed_token(const char *p, const char **q)
{
switch (p[0]) {
case '!':
- if (p[1] == '=') {
- *q = p + 2;
- return (T_NEQ);
- }
- *q = p + 1;
- return (p[0]);
+ M2('=', T_NEQ);
+ M1();
case '%':
- *q = p + 1;
- return (p[0]);
+ M1();
case '&':
- if (p[1] == '&') {
- *q = p + 2;
- return (T_CAND);
- }
- *q = p + 1;
- return (p[0]);
+ M2('&', T_CAND);
+ M1();
case '(':
- *q = p + 1;
- return (p[0]);
+ M1();
case ')':
- *q = p + 1;
- return (p[0]);
+ M1();
case '*':
- if (p[1] == '=') {
- *q = p + 2;
- return (T_MUL);
- }
- *q = p + 1;
- return (p[0]);
+ M2('=', T_MUL);
+ M1();
case '+':
- if (p[1] == '=') {
- *q = p + 2;
- return (T_INCR);
- }
- if (p[1] == '+') {
- *q = p + 2;
- return (T_INC);
- }
- *q = p + 1;
- return (p[0]);
+ M2('=', T_INCR);
+ M2('+', T_INC);
+ M1();
case ',':
- *q = p + 1;
- return (p[0]);
+ M1();
case '-':
- if (p[1] == '=') {
- *q = p + 2;
- return (T_DECR);
- }
- if (p[1] == '-') {
- *q = p + 2;
- return (T_DEC);
- }
- *q = p + 1;
- return (p[0]);
+ M2('=', T_DECR);
+ M2('-', T_DEC);
+ M1();
case '.':
- *q = p + 1;
- return (p[0]);
+ M1();
case '/':
- if (p[1] == '=') {
- *q = p + 2;
- return (T_DIV);
- }
- *q = p + 1;
- return (p[0]);
+ M2('=', T_DIV);
+ M1();
case ';':
- *q = p + 1;
- return (p[0]);
+ M1();
case '<':
- if (p[1] == '=') {
- *q = p + 2;
- return (T_LEQ);
- }
- if (p[1] == '<') {
- *q = p + 2;
- return (T_SHL);
- }
- *q = p + 1;
- return (p[0]);
+ M2('=', T_LEQ);
+ M2('<', T_SHL);
+ M1();
case '=':
- if (p[1] == '=') {
- *q = p + 2;
- return (T_EQ);
- }
- *q = p + 1;
- return (p[0]);
+ M2('=', T_EQ);
+ M1();
case '>':
- if (p[1] == '>') {
- *q = p + 2;
- return (T_SHR);
- }
- if (p[1] == '=') {
- *q = p + 2;
- return (T_GEQ);
- }
- *q = p + 1;
- return (p[0]);
+ M2('>', T_SHR);
+ M2('=', T_GEQ);
+ M1();
case 'e':
- if (p[1] == 'l' && p[2] == 's' &&
- p[3] == 'i' && p[4] == 'f' && !isvar(p[5])) {
+ if (p[1] == 'l' && p[2] == 's' && p[3] == 'i' &&
+ p[4] == 'f' && !isvar(p[5])) {
*q = p + 5;
return (T_ELSIF);
}
- if (p[1] == 'l' && p[2] == 's' &&
- p[3] == 'e' && p[4] == 'i' && p[5] == 'f'
- && !isvar(p[6])) {
+ if (p[1] == 'l' && p[2] == 's' && p[3] == 'e' &&
+ p[4] == 'i' && p[5] == 'f' && !isvar(p[6])) {
*q = p + 6;
return (T_ELSEIF);
}
- if (p[1] == 'l' && p[2] == 's' &&
- p[3] == 'e' && !isvar(p[4])) {
+ if (p[1] == 'l' && p[2] == 's' && p[3] == 'e'
+ && !isvar(p[4])) {
*q = p + 4;
return (T_ELSE);
}
return (0);
case 'i':
- if (p[1] == 'n' && p[2] == 'c' &&
- p[3] == 'l' && p[4] == 'u' && p[5] == 'd' &&
- p[6] == 'e' && !isvar(p[7])) {
+ if (p[1] == 'n' && p[2] == 'c' && p[3] == 'l' &&
+ p[4] == 'u' && p[5] == 'd' && p[6] == 'e'
+ && !isvar(p[7])) {
*q = p + 7;
return (T_INCLUDE);
}
- if (p[1] == 'f' && !isvar(p[2])) {
- *q = p + 2;
- return (T_IF);
- }
+ M2('f', T_IF);
return (0);
case '{':
- *q = p + 1;
- return (p[0]);
+ M1();
case '|':
- if (p[1] == '|') {
- *q = p + 2;
- return (T_COR);
- }
- *q = p + 1;
- return (p[0]);
+ M2('|', T_COR);
+ M1();
case '}':
- *q = p + 1;
- return (p[0]);
+ M1();
case '~':
- *q = p + 1;
- return (p[0]);
+ M1();
default:
return (0);
}
}
-const char *vcl_tnames[256];
-
-void
-vcl_init_tnames(void)
-{
- vcl_tnames['!'] = "'!'";
- vcl_tnames['%'] = "'%'";
- vcl_tnames['&'] = "'&'";
- vcl_tnames['('] = "'('";
- vcl_tnames[')'] = "')'";
- vcl_tnames['*'] = "'*'";
- vcl_tnames['+'] = "'+'";
- vcl_tnames[','] = "','";
- vcl_tnames['-'] = "'-'";
- vcl_tnames['.'] = "'.'";
- vcl_tnames['/'] = "'/'";
- vcl_tnames['<'] = "'<'";
- vcl_tnames['='] = "'='";
- vcl_tnames['>'] = "'>'";
- vcl_tnames['{'] = "'{'";
- vcl_tnames['}'] = "'}'";
- vcl_tnames['|'] = "'|'";
- vcl_tnames['~'] = "'~'";
- vcl_tnames[';'] = "';'";
- vcl_tnames[CNUM] = "CNUM";
- vcl_tnames[CSRC] = "CSRC";
- vcl_tnames[CSTR] = "CSTR";
- vcl_tnames[EOI] = "EOI";
- vcl_tnames[ID] = "ID";
- vcl_tnames[T_CAND] = "&&";
- vcl_tnames[T_COR] = "||";
- vcl_tnames[T_DEC] = "--";
- vcl_tnames[T_DECR] = "-=";
- vcl_tnames[T_DIV] = "/=";
- vcl_tnames[T_ELSE] = "else";
- vcl_tnames[T_ELSEIF] = "elseif";
- vcl_tnames[T_ELSIF] = "elsif";
- vcl_tnames[T_EQ] = "==";
- vcl_tnames[T_GEQ] = ">=";
- vcl_tnames[T_IF] = "if";
- vcl_tnames[T_INC] = "++";
- vcl_tnames[T_INCLUDE] = "include";
- vcl_tnames[T_INCR] = "+=";
- vcl_tnames[T_LEQ] = "<=";
- vcl_tnames[T_MUL] = "*=";
- vcl_tnames[T_NEQ] = "!=";
- vcl_tnames[T_SHL] = "<<";
- vcl_tnames[T_SHR] = ">>";
- vcl_tnames[VAR] = "VAR";
-}
+const char *vcl_tnames[256] = {
+ ['!'] = "'!'",
+ ['%'] = "'%'",
+ ['&'] = "'&'",
+ ['('] = "'('",
+ [')'] = "')'",
+ ['*'] = "'*'",
+ ['+'] = "'+'",
+ [','] = "','",
+ ['-'] = "'-'",
+ ['.'] = "'.'",
+ ['/'] = "'/'",
+ ['<'] = "'<'",
+ ['='] = "'='",
+ ['>'] = "'>'",
+ ['{'] = "'{'",
+ ['}'] = "'}'",
+ ['|'] = "'|'",
+ ['~'] = "'~'",
+ [';'] = "';'",
+ [CNUM] = "CNUM",
+ [CSRC] = "CSRC",
+ [CSTR] = "CSTR",
+ [EOI] = "EOI",
+ [ID] = "ID",
+ [T_CAND] = "&&",
+ [T_COR] = "||",
+ [T_DEC] = "--",
+ [T_DECR] = "-=",
+ [T_DIV] = "/=",
+ [T_ELSE] = "else",
+ [T_ELSEIF] = "elseif",
+ [T_ELSIF] = "elsif",
+ [T_EQ] = "==",
+ [T_GEQ] = ">=",
+ [T_IF] = "if",
+ [T_INC] = "++",
+ [T_INCLUDE] = "include",
+ [T_INCR] = "+=",
+ [T_LEQ] = "<=",
+ [T_MUL] = "*=",
+ [T_NEQ] = "!=",
+ [T_SHL] = "<<",
+ [T_SHR] = ">>",
+ [VAR] = "VAR",
+};
void
vcl_output_lang_h(struct vsb *sb)
vsb_cat(sb, "#define VCL_RET_DISCARD (1 << 7)\n");
vsb_cat(sb, "#define VCL_RET_KEEP (1 << 8)\n");
vsb_cat(sb, "#define VCL_RET_RESTART (1 << 9)\n");
- vsb_cat(sb, "/*\n");
- vsb_cat(sb, " * $Id$\n");
- vsb_cat(sb, " *\n");
- vsb_cat(sb, " * NB: This file is machine generated, DO NOT EDIT!\n");
- vsb_cat(sb, " *\n");
- vsb_cat(sb, " * Edit vcc_gen_fixed_token.tcl instead\n");
- vsb_cat(sb, " */\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "struct sess;\n");
- vsb_cat(sb, "struct cli;\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "typedef void vcl_init_f(struct cli *);\n");
- vsb_cat(sb, "typedef void vcl_fini_f(struct cli *);\n");
- vsb_cat(sb, "typedef int vcl_func_f(struct sess *sp);\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "struct VCL_conf {\n");
- vsb_cat(sb, " unsigned magic;\n");
- vsb_cat(sb, "#define VCL_CONF_MAGIC 0x7406c509 /* from /dev/random */\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, " struct director **director;\n");
- vsb_cat(sb, " unsigned ndirector;\n");
- vsb_cat(sb, " struct vrt_ref *ref;\n");
- vsb_cat(sb, " unsigned nref;\n");
- vsb_cat(sb, " unsigned busy;\n");
- vsb_cat(sb, " unsigned discard;\n");
- vsb_cat(sb, " \n");
- vsb_cat(sb, " unsigned nsrc;\n");
- vsb_cat(sb, " const char **srcname;\n");
- vsb_cat(sb, " const char **srcbody;\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, " unsigned nhashcount;\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, " vcl_init_f *init_func;\n");
- vsb_cat(sb, " vcl_fini_f *fini_func;\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, " vcl_func_f *recv_func;\n");
- vsb_cat(sb, " vcl_func_f *pipe_func;\n");
- vsb_cat(sb, " vcl_func_f *pass_func;\n");
- vsb_cat(sb, " vcl_func_f *hash_func;\n");
- vsb_cat(sb, " vcl_func_f *miss_func;\n");
- vsb_cat(sb, " vcl_func_f *hit_func;\n");
- vsb_cat(sb, " vcl_func_f *fetch_func;\n");
- vsb_cat(sb, " vcl_func_f *deliver_func;\n");
- vsb_cat(sb, " vcl_func_f *prefetch_func;\n");
- vsb_cat(sb, " vcl_func_f *timeout_func;\n");
- vsb_cat(sb, " vcl_func_f *discard_func;\n");
- vsb_cat(sb, " vcl_func_f *error_func;\n");
- vsb_cat(sb, "};\n");
- vsb_cat(sb, "/*-\n");
- vsb_cat(sb, " * Copyright (c) 2006 Verdens Gang AS\n");
- vsb_cat(sb, " * Copyright (c) 2006-2008 Linpro AS\n");
- vsb_cat(sb, " * All rights reserved.\n");
- vsb_cat(sb, " *\n");
- vsb_cat(sb, " * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n");
- vsb_cat(sb, " *\n");
- vsb_cat(sb, " * Redistribution and use in source and binary forms, with or without\n");
- vsb_cat(sb, " * modification, are permitted provided that the following conditions\n");
- vsb_cat(sb, " * are met:\n");
- vsb_cat(sb, " * 1. Redistributions of source code must retain the above copyright\n");
- vsb_cat(sb, " * notice, this list of conditions and the following disclaimer.\n");
- vsb_cat(sb, " * 2. Redistributions in binary form must reproduce the above copyright\n");
- vsb_cat(sb, " * notice, this list of conditions and the following disclaimer in the\n");
- vsb_cat(sb, " * documentation and/or other materials provided with the distribution.\n");
- vsb_cat(sb, " *\n");
- vsb_cat(sb, " * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n");
- vsb_cat(sb, " * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n");
- vsb_cat(sb, " * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n");
- vsb_cat(sb, " * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n");
- vsb_cat(sb, " * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n");
- vsb_cat(sb, " * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n");
- vsb_cat(sb, " * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n");
- vsb_cat(sb, " * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n");
- vsb_cat(sb, " * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n");
- vsb_cat(sb, " * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n");
- vsb_cat(sb, " * SUCH DAMAGE.\n");
- vsb_cat(sb, " *\n");
- vsb_cat(sb, " * $Id$\n");
- vsb_cat(sb, " *\n");
- vsb_cat(sb, " * Runtime support for compiled VCL programs.\n");
- vsb_cat(sb, " *\n");
- vsb_cat(sb, " * XXX: When this file is changed, lib/libvcl/vcc_gen_fixed_token.tcl\n");
- vsb_cat(sb, " * XXX: *MUST* be rerun.\n");
- vsb_cat(sb, " */\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "struct sess;\n");
- vsb_cat(sb, "struct vsb;\n");
- vsb_cat(sb, "struct cli;\n");
- vsb_cat(sb, "struct director;\n");
- vsb_cat(sb, "struct VCL_conf;\n");
- vsb_cat(sb, "struct sockaddr;\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "/*\n");
- vsb_cat(sb, " * A backend probe specification\n");
- vsb_cat(sb, " */\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "extern void *vrt_magic_string_end;\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "struct vrt_backend_probe {\n");
- vsb_cat(sb, " const char *url;\n");
- vsb_cat(sb, " const char *request;\n");
- vsb_cat(sb, " double timeout;\n");
- vsb_cat(sb, " double interval;\n");
- vsb_cat(sb, " unsigned window;\n");
- vsb_cat(sb, " unsigned threshold;\n");
- vsb_cat(sb, "};\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "/*\n");
- vsb_cat(sb, " * A backend is a host+port somewhere on the network\n");
- vsb_cat(sb, " */\n");
- vsb_cat(sb, "struct vrt_backend {\n");
- vsb_cat(sb, " const char *vcl_name;\n");
- vsb_cat(sb, " const char *ident;\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, " const char *hosthdr;\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, " const unsigned char *ipv4_sockaddr;\n");
- vsb_cat(sb, " const unsigned char *ipv6_sockaddr;\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, " double connect_timeout;\n");
- vsb_cat(sb, " unsigned max_connections;\n");
- vsb_cat(sb, " struct vrt_backend_probe probe;\n");
- vsb_cat(sb, "};\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "/*\n");
- vsb_cat(sb, " * A director with a predictable reply\n");
- vsb_cat(sb, " */\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "struct vrt_dir_simple {\n");
- vsb_cat(sb, " const char *name;\n");
- vsb_cat(sb, " const struct vrt_backend *host;\n");
- vsb_cat(sb, "};\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "/*\n");
- vsb_cat(sb, " * A director with an unpredictable reply\n");
- vsb_cat(sb, " */\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "struct vrt_dir_random_entry {\n");
- vsb_cat(sb, " const struct vrt_backend *host;\n");
- vsb_cat(sb, " double weight;\n");
- vsb_cat(sb, "};\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "struct vrt_dir_random {\n");
- vsb_cat(sb, " const char *name;\n");
- vsb_cat(sb, " unsigned retries;\n");
- vsb_cat(sb, " unsigned nmember;\n");
- vsb_cat(sb, " const struct vrt_dir_random_entry *members;\n");
- vsb_cat(sb, "};\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "/*\n");
- vsb_cat(sb, " * A director with round robin selection\n");
- vsb_cat(sb, " */\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "struct vrt_dir_round_robin_entry {\n");
- vsb_cat(sb, " const struct vrt_backend *host;\n");
- vsb_cat(sb, "};\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "struct vrt_dir_round_robin {\n");
- vsb_cat(sb, " const char *name;\n");
- vsb_cat(sb, " unsigned nmember;\n");
- vsb_cat(sb, " const struct vrt_dir_round_robin_entry *members;\n");
- vsb_cat(sb, "};\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "/*\n");
- vsb_cat(sb, " * other stuff.\n");
- vsb_cat(sb, " * XXX: document when bored\n");
- vsb_cat(sb, " */\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "struct vrt_ref {\n");
- vsb_cat(sb, " unsigned source;\n");
- vsb_cat(sb, " unsigned offset;\n");
- vsb_cat(sb, " unsigned line;\n");
- vsb_cat(sb, " unsigned pos;\n");
- vsb_cat(sb, " unsigned count;\n");
- vsb_cat(sb, " const char *token;\n");
- vsb_cat(sb, "};\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "/* ACL related */\n");
- vsb_cat(sb, "#define VRT_ACL_MAXADDR 16 /* max(IPv4, IPv6) */\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "void VRT_acl_log(const struct sess *, const char *msg);\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "/* Regexp related */\n");
- vsb_cat(sb, "void VRT_re_init(void **, const char *, int sub);\n");
- vsb_cat(sb, "void VRT_re_fini(void *);\n");
- vsb_cat(sb, "int VRT_re_match(const char *, void *re);\n");
- vsb_cat(sb, "int VRT_re_test(struct vsb *, const char *, int sub);\n");
- vsb_cat(sb, "const char *VRT_regsub(const struct sess *sp, int all, const char *, void *, const char *);\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "void VRT_panic(struct sess *sp, const char *, ...);\n");
- vsb_cat(sb, "void VRT_purge(const char *, int hash);\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "void VRT_count(const struct sess *, unsigned);\n");
- vsb_cat(sb, "int VRT_rewrite(const char *, const char *);\n");
- vsb_cat(sb, "void VRT_error(struct sess *, unsigned, const char *);\n");
- vsb_cat(sb, "int VRT_switch_config(const char *);\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "enum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ, HDR_BEREQ };\n");
- vsb_cat(sb, "char *VRT_GetHdr(const struct sess *, enum gethdr_e where, const char *);\n");
- vsb_cat(sb, "void VRT_SetHdr(const struct sess *, enum gethdr_e where, const char *, const char *, ...);\n");
- vsb_cat(sb, "void VRT_handling(struct sess *sp, unsigned hand);\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "/* Simple stuff */\n");
- vsb_cat(sb, "int VRT_strcmp(const char *s1, const char *s2);\n");
- vsb_cat(sb, "void VRT_memmove(void *dst, const void *src, unsigned len);\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "void VRT_ESI(struct sess *sp);\n");
- vsb_cat(sb, "void VRT_Rollback(struct sess *sp);\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "/* Synthetic pages */\n");
- vsb_cat(sb, "void VRT_synth_page(struct sess *sp, unsigned flags, const char *, ...);\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "/* Backend related */\n");
- vsb_cat(sb, "void VRT_init_dir_simple(struct cli *, struct director **, const struct vrt_dir_simple *);\n");
- vsb_cat(sb, "void VRT_init_dir_random(struct cli *, struct director **, const struct vrt_dir_random *);\n");
- vsb_cat(sb, "void VRT_init_dir_round_robin(struct cli *, struct director **, const struct vrt_dir_round_robin *);\n");
- vsb_cat(sb, "void VRT_fini_dir(struct cli *, struct director *);\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "char *VRT_IP_string(const struct sess *sp, const struct sockaddr *sa);\n");
- vsb_cat(sb, "char *VRT_int_string(const struct sess *sp, int);\n");
- vsb_cat(sb, "char *VRT_double_string(const struct sess *sp, double);\n");
- vsb_cat(sb, "const char *VRT_backend_string(struct sess *sp);\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "#define VRT_done(sp, hand) \\\n");
- vsb_cat(sb, " do { \\\n");
- vsb_cat(sb, " VRT_handling(sp, hand); \\\n");
- vsb_cat(sb, " return (1); \\\n");
- vsb_cat(sb, " } while (0)\n");
- vsb_cat(sb, "/*\n");
- vsb_cat(sb, " * $Id$\n");
- vsb_cat(sb, " *\n");
- vsb_cat(sb, " * NB: This file is machine generated, DO NOT EDIT!\n");
- vsb_cat(sb, " *\n");
- vsb_cat(sb, " * Edit vcc_gen_obj.tcl instead\n");
- vsb_cat(sb, " */\n");
- vsb_cat(sb, "\n");
- vsb_cat(sb, "struct sockaddr * VRT_r_client_ip(const struct sess *);\n");
- vsb_cat(sb, "struct sockaddr * VRT_r_server_ip(struct sess *);\n");
- vsb_cat(sb, "int VRT_r_server_port(struct sess *);\n");
- vsb_cat(sb, "const char * VRT_r_req_request(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_req_request(const struct sess *, const char *, ...);\n");
- vsb_cat(sb, "const char * VRT_r_req_url(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_req_url(const struct sess *, const char *, ...);\n");
- vsb_cat(sb, "const char * VRT_r_req_proto(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_req_proto(const struct sess *, const char *, ...);\n");
- vsb_cat(sb, "void VRT_l_req_hash(struct sess *, const char *);\n");
- vsb_cat(sb, "struct director * VRT_r_req_backend(struct sess *);\n");
- vsb_cat(sb, "void VRT_l_req_backend(struct sess *, struct director *);\n");
- vsb_cat(sb, "int VRT_r_req_restarts(const struct sess *);\n");
- vsb_cat(sb, "double VRT_r_req_grace(struct sess *);\n");
- vsb_cat(sb, "void VRT_l_req_grace(struct sess *, double);\n");
- vsb_cat(sb, "const char * VRT_r_req_xid(struct sess *);\n");
- vsb_cat(sb, "const char * VRT_r_bereq_request(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_bereq_request(const struct sess *, const char *, ...);\n");
- vsb_cat(sb, "const char * VRT_r_bereq_url(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_bereq_url(const struct sess *, const char *, ...);\n");
- vsb_cat(sb, "const char * VRT_r_bereq_proto(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_bereq_proto(const struct sess *, const char *, ...);\n");
- vsb_cat(sb, "const char * VRT_r_obj_proto(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_obj_proto(const struct sess *, const char *, ...);\n");
- vsb_cat(sb, "int VRT_r_obj_status(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_obj_status(const struct sess *, int);\n");
- vsb_cat(sb, "const char * VRT_r_obj_response(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_obj_response(const struct sess *, const char *, ...);\n");
- vsb_cat(sb, "int VRT_r_obj_hits(const struct sess *);\n");
- vsb_cat(sb, "unsigned VRT_r_obj_cacheable(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_obj_cacheable(const struct sess *, unsigned);\n");
- vsb_cat(sb, "double VRT_r_obj_ttl(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_obj_ttl(const struct sess *, double);\n");
- vsb_cat(sb, "double VRT_r_obj_grace(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_obj_grace(const struct sess *, double);\n");
- vsb_cat(sb, "double VRT_r_obj_prefetch(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_obj_prefetch(const struct sess *, double);\n");
- vsb_cat(sb, "double VRT_r_obj_lastuse(const struct sess *);\n");
- vsb_cat(sb, "const char * VRT_r_obj_hash(const struct sess *);\n");
- vsb_cat(sb, "const char * VRT_r_resp_proto(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_resp_proto(const struct sess *, const char *, ...);\n");
- vsb_cat(sb, "int VRT_r_resp_status(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_resp_status(const struct sess *, int);\n");
- vsb_cat(sb, "const char * VRT_r_resp_response(const struct sess *);\n");
- vsb_cat(sb, "void VRT_l_resp_response(const struct sess *, const char *, ...);\n");
- vsb_cat(sb, "double VRT_r_now(const struct sess *);\n");
- vsb_cat(sb, "unsigned VRT_r_req_backend_healthy(const struct sess *);\n");
+
+ /* ../../include/vcl.h */
+
+ vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 3098 2008-08-18 08");
+ vsb_cat(sb, ":18:43Z phk $\n *\n * NB: This file is machine genera");
+ vsb_cat(sb, "ted, DO NOT EDIT!\n *\n * Edit vcc_gen_fixed_token.tcl");
+ vsb_cat(sb, " instead\n */\n\nstruct sess;\nstruct cli;\n\ntypedef ");
+ vsb_cat(sb, "void vcl_init_f(struct cli *);\ntypedef void vcl_fini_");
+ vsb_cat(sb, "f(struct cli *);\ntypedef int vcl_func_f(struct sess *");
+ vsb_cat(sb, "sp);\n\nstruct VCL_conf {\n\tunsigned magic;\n#");
+ vsb_cat(sb, "define VCL_CONF_MAGIC 0x7406c509 /* from /dev/ra");
+ vsb_cat(sb, "ndom */\n\n struct director **director;\n ");
+ vsb_cat(sb, " unsigned ndirector;\n struct vrt_ref ");
+ vsb_cat(sb, " *ref;\n unsigned nref;\n unsigne");
+ vsb_cat(sb, "d busy;\n unsigned discard;\n\n\t");
+ vsb_cat(sb, "unsigned\tnsrc;\n\tconst char\t**srcname;\n\tconst cha");
+ vsb_cat(sb, "r\t**srcbody;\n\n\tunsigned\tnhashcount;\n\n vc");
+ vsb_cat(sb, "l_init_f *init_func;\n vcl_fini_f *fi");
+ vsb_cat(sb, "ni_func;\n\n\tvcl_func_f\t*recv_func;\n\tvcl_func_f\t*");
+ vsb_cat(sb, "pipe_func;\n\tvcl_func_f\t*pass_func;\n\tvcl_func_f\t*");
+ vsb_cat(sb, "hash_func;\n\tvcl_func_f\t*miss_func;\n\tvcl_func_f\t*");
+ vsb_cat(sb, "hit_func;\n\tvcl_func_f\t*fetch_func;\n\tvcl_func_f\t*");
+ vsb_cat(sb, "deliver_func;\n\tvcl_func_f\t*prefetch_func;\n\tvcl_fu");
+ vsb_cat(sb, "nc_f\t*timeout_func;\n\tvcl_func_f\t*discard_func;\n\t");
+ vsb_cat(sb, "vcl_func_f\t*error_func;\n};\n");
+
+ /* ../../include/vrt.h */
+
+ vsb_cat(sb, "/*-\n * Copyright (c) 2006 Verdens Gang AS\n * Copyrig");
+ vsb_cat(sb, "ht (c) 2006-2008 Linpro AS\n * All rights reserved.\n ");
+ vsb_cat(sb, "*\n * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n");
+ vsb_cat(sb, " *\n * Redistribution and use in source and binary for");
+ vsb_cat(sb, "ms, with or without\n * modification, are permitted pr");
+ vsb_cat(sb, "ovided that the following conditions\n * are met:\n * ");
+ vsb_cat(sb, "1. Redistributions of source code must retain the abov");
+ vsb_cat(sb, "e copyright\n * notice, this list of conditions and");
+ vsb_cat(sb, " the following disclaimer.\n * 2. Redistributions in b");
+ vsb_cat(sb, "inary form must reproduce the above copyright\n * n");
+ vsb_cat(sb, "otice, this list of conditions and the following discl");
+ vsb_cat(sb, "aimer in the\n * documentation and/or other materia");
+ vsb_cat(sb, "ls provided with the distribution.\n *\n * THIS SOFTWA");
+ vsb_cat(sb, "RE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'");
+ vsb_cat(sb, "' AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING");
+ vsb_cat(sb, ", BUT NOT LIMITED TO, THE\n * IMPLIED WARRANTIES OF ME");
+ vsb_cat(sb, "RCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n *");
+ vsb_cat(sb, " ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBU");
+ vsb_cat(sb, "TORS BE LIABLE\n * FOR ANY DIRECT, INDIRECT, INCIDENTA");
+ vsb_cat(sb, "L, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n * DAMAGES (I");
+ vsb_cat(sb, "NCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUT");
+ vsb_cat(sb, "E GOODS\n * OR SERVICES; LOSS OF USE, DATA, OR PROFITS");
+ vsb_cat(sb, "; OR BUSINESS INTERRUPTION)\n * HOWEVER CAUSED AND ON ");
+ vsb_cat(sb, "ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n");
+ vsb_cat(sb, " * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWI");
+ vsb_cat(sb, "SE) ARISING IN ANY WAY\n * OUT OF THE USE OF THIS SOFT");
+ vsb_cat(sb, "WARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n * SUCH D");
+ vsb_cat(sb, "AMAGE.\n *\n * $Id: vrt.h 3234 2008-09-29 07:32:26Z ph");
+ vsb_cat(sb, "k $\n *\n * Runtime support for compiled VCL programs.");
+ vsb_cat(sb, "\n *\n * XXX: When this file is changed, lib/libvcl/vc");
+ vsb_cat(sb, "c_gen_fixed_token.tcl\n * XXX: *MUST* be rerun.\n */\n");
+ vsb_cat(sb, "\nstruct sess;\nstruct vsb;\nstruct cli;\nstruct direc");
+ vsb_cat(sb, "tor;\nstruct VCL_conf;\nstruct sockaddr;\n\n/*\n * A b");
+ vsb_cat(sb, "ackend probe specification\n */\n\nextern void *vrt_ma");
+ vsb_cat(sb, "gic_string_end;\n\nstruct vrt_backend_probe {\n\tconst");
+ vsb_cat(sb, " char\t*url;\n\tconst char\t*request;\n\tdouble\t\ttim");
+ vsb_cat(sb, "eout;\n\tdouble\t\tinterval;\n\tunsigned\twindow;\n\tu");
+ vsb_cat(sb, "nsigned\tthreshold;\n};\n\n/*\n * A backend is a host+");
+ vsb_cat(sb, "port somewhere on the network\n */\nstruct vrt_backend");
+ vsb_cat(sb, " {\n\tconst char\t\t\t*vcl_name;\n\tconst char\t\t\t*i");
+ vsb_cat(sb, "dent;\n\n\tconst char\t\t\t*hosthdr;\n\n\tconst unsign");
+ vsb_cat(sb, "ed char\t\t*ipv4_sockaddr;\n\tconst unsigned char\t\t*");
+ vsb_cat(sb, "ipv6_sockaddr;\n\n\tdouble\t\t\t\tconnect_timeout;\n\t");
+ vsb_cat(sb, "unsigned\t\t\tmax_connections;\n\tstruct vrt_backend_p");
+ vsb_cat(sb, "robe\tprobe;\n};\n\n/*\n * A director with a predictab");
+ vsb_cat(sb, "le reply\n */\n\nstruct vrt_dir_simple {\n\tconst char");
+ vsb_cat(sb, "\t\t\t\t*name;\n\tconst struct vrt_backend\t\t*host;\n");
+ vsb_cat(sb, "};\n\n/*\n * A director with an unpredictable reply\n ");
+ vsb_cat(sb, "*/\n\nstruct vrt_dir_random_entry {\n\tconst struct vr");
+ vsb_cat(sb, "t_backend\t\t*host;\n\tdouble\t\t\t\t\tweight;\n};\n\n");
+ vsb_cat(sb, "struct vrt_dir_random {\n\tconst char\t\t\t\t*name;\n\t");
+ vsb_cat(sb, "unsigned\t\t\t\tretries;\n\tunsigned\t\t\t\tnmember;\n");
+ vsb_cat(sb, "\tconst struct vrt_dir_random_entry\t*members;\n};\n\n");
+ vsb_cat(sb, "/*\n * A director with round robin selection\n */\n\ns");
+ vsb_cat(sb, "truct vrt_dir_round_robin_entry {\n\tconst struct vrt_");
+ vsb_cat(sb, "backend\t\t*host;\n};\n\nstruct vrt_dir_round_robin {\n");
+ vsb_cat(sb, "\tconst char\t\t\t\t*name;\n\tunsigned\t\t\t\tnmember;");
+ vsb_cat(sb, "\n\tconst struct vrt_dir_round_robin_entry\t*members;\n");
+ vsb_cat(sb, "};\n\n\n/*\n * other stuff.\n * XXX: document when bor");
+ vsb_cat(sb, "ed\n */\n\nstruct vrt_ref {\n\tunsigned\tsource;\n\tun");
+ vsb_cat(sb, "signed\toffset;\n\tunsigned\tline;\n\tunsigned\tpos;\n");
+ vsb_cat(sb, "\tunsigned\tcount;\n\tconst char\t*token;\n};\n\n/* AC");
+ vsb_cat(sb, "L related */\n#define VRT_ACL_MAXADDR\t\t16\t/* max(IP");
+ vsb_cat(sb, "v4, IPv6) */\n\nvoid VRT_acl_log(const struct sess *, ");
+ vsb_cat(sb, "const char *msg);\n\n/* Regexp related */\nvoid VRT_re");
+ vsb_cat(sb, "_init(void **, const char *, int sub);\nvoid VRT_re_fi");
+ vsb_cat(sb, "ni(void *);\nint VRT_re_match(const char *, void *re);");
+ vsb_cat(sb, "\nint VRT_re_test(struct vsb *, const char *, int sub)");
+ vsb_cat(sb, ";\nconst char *VRT_regsub(const struct sess *sp, int a");
+ vsb_cat(sb, "ll, const char *,\n void *, const char *);\n\nvoid ");
+ vsb_cat(sb, "VRT_panic(struct sess *sp, const char *, ...);\nvoid ");
+ vsb_cat(sb, "VRT_purge(const char *, int hash);\n\nvoid VRT_count(c");
+ vsb_cat(sb, "onst struct sess *, unsigned);\nint VRT_rewrite(const ");
+ vsb_cat(sb, "char *, const char *);\nvoid VRT_error(struct sess *, ");
+ vsb_cat(sb, "unsigned, const char *);\nint VRT_switch_config(const ");
+ vsb_cat(sb, "char *);\n\nenum gethdr_e { HDR_REQ, HDR_RESP, HDR_OBJ");
+ vsb_cat(sb, ", HDR_BEREQ };\nchar *VRT_GetHdr(const struct sess *, ");
+ vsb_cat(sb, "enum gethdr_e where, const char *);\nvoid VRT_SetHdr(c");
+ vsb_cat(sb, "onst struct sess *, enum gethdr_e where, const char *,");
+ vsb_cat(sb, "\n const char *, ...);\nvoid VRT_handling(struct se");
+ vsb_cat(sb, "ss *sp, unsigned hand);\n\n/* Simple stuff */\nint VRT");
+ vsb_cat(sb, "_strcmp(const char *s1, const char *s2);\nvoid VRT_mem");
+ vsb_cat(sb, "move(void *dst, const void *src, unsigned len);\n\nvoi");
+ vsb_cat(sb, "d VRT_ESI(struct sess *sp);\nvoid VRT_Rollback(struct ");
+ vsb_cat(sb, "sess *sp);\n\n/* Synthetic pages */\nvoid VRT_synth_pa");
+ vsb_cat(sb, "ge(struct sess *sp, unsigned flags, const char *, ...)");
+ vsb_cat(sb, ";\n\n/* Backend related */\nvoid VRT_init_dir_simple(s");
+ vsb_cat(sb, "truct cli *, struct director **,\n const struct vrt");
+ vsb_cat(sb, "_dir_simple *);\nvoid VRT_init_dir_random(struct cli *");
+ vsb_cat(sb, ", struct director **,\n const struct vrt_dir_random");
+ vsb_cat(sb, " *);\nvoid VRT_init_dir_round_robin(struct cli *, stru");
+ vsb_cat(sb, "ct director **,\n const struct vrt_dir_round_robin ");
+ vsb_cat(sb, "*);\nvoid VRT_fini_dir(struct cli *, struct director *");
+ vsb_cat(sb, ");\n\nchar *VRT_IP_string(const struct sess *sp, const");
+ vsb_cat(sb, " struct sockaddr *sa);\nchar *VRT_int_string(const str");
+ vsb_cat(sb, "uct sess *sp, int);\nchar *VRT_double_string(const str");
+ vsb_cat(sb, "uct sess *sp, double);\nconst char *VRT_backend_string");
+ vsb_cat(sb, "(struct sess *sp);\n\n#define VRT_done(sp, hand)\t\t\t");
+ vsb_cat(sb, "\\\n\tdo {\t\t\t\t\t\\\n\t\tVRT_handling(sp, hand);\t\t");
+ vsb_cat(sb, "\\\n\t\treturn (1);\t\t\t\\\n\t} while (0)\n");
+
+ /* ../../include/vrt_obj.h */
+
+ vsb_cat(sb, "/*\n * $Id: vcc_gen_obj.tcl 3169 2008-09-08 09:49:01Z ");
+ vsb_cat(sb, "tfheen $\n *\n * NB: This file is machine generated, ");
+ vsb_cat(sb, "DO NOT EDIT!\n *\n * Edit vcc_gen_obj.tcl instead\n */");
+ vsb_cat(sb, "\n\nstruct sockaddr * VRT_r_client_ip(const struct ses");
+ vsb_cat(sb, "s *);\nstruct sockaddr * VRT_r_server_ip(struct sess *");
+ vsb_cat(sb, ");\nint VRT_r_server_port(struct sess *);\nconst char ");
+ vsb_cat(sb, "* VRT_r_req_request(const struct sess *);\nvoid VRT_l_");
+ vsb_cat(sb, "req_request(const struct sess *, const char *, ...);\n");
+ vsb_cat(sb, "const char * VRT_r_req_url(const struct sess *);\nvoid");
+ vsb_cat(sb, " VRT_l_req_url(const struct sess *, const char *, ...)");
+ vsb_cat(sb, ";\nconst char * VRT_r_req_proto(const struct sess *);\n");
+ vsb_cat(sb, "void VRT_l_req_proto(const struct sess *, const char *");
+ vsb_cat(sb, ", ...);\nvoid VRT_l_req_hash(struct sess *, const char");
+ vsb_cat(sb, " *);\nstruct director * VRT_r_req_backend(struct sess ");
+ vsb_cat(sb, "*);\nvoid VRT_l_req_backend(struct sess *, struct dire");
+ vsb_cat(sb, "ctor *);\nint VRT_r_req_restarts(const struct sess *);");
+ vsb_cat(sb, "\ndouble VRT_r_req_grace(struct sess *);\nvoid VRT_l_r");
+ vsb_cat(sb, "eq_grace(struct sess *, double);\nconst char * VRT_r_r");
+ vsb_cat(sb, "eq_xid(struct sess *);\nconst char * VRT_r_bereq_reque");
+ vsb_cat(sb, "st(const struct sess *);\nvoid VRT_l_bereq_request(con");
+ vsb_cat(sb, "st struct sess *, const char *, ...);\nconst char * VR");
+ vsb_cat(sb, "T_r_bereq_url(const struct sess *);\nvoid VRT_l_bereq_");
+ vsb_cat(sb, "url(const struct sess *, const char *, ...);\nconst ch");
+ vsb_cat(sb, "ar * VRT_r_bereq_proto(const struct sess *);\nvoid VRT");
+ vsb_cat(sb, "_l_bereq_proto(const struct sess *, const char *, ...)");
+ vsb_cat(sb, ";\nconst char * VRT_r_obj_proto(const struct sess *);\n");
+ vsb_cat(sb, "void VRT_l_obj_proto(const struct sess *, const char *");
+ vsb_cat(sb, ", ...);\nint VRT_r_obj_status(const struct sess *);\nv");
+ vsb_cat(sb, "oid VRT_l_obj_status(const struct sess *, int);\nconst");
+ vsb_cat(sb, " char * VRT_r_obj_response(const struct sess *);\nvoid");
+ vsb_cat(sb, " VRT_l_obj_response(const struct sess *, const char *,");
+ vsb_cat(sb, " ...);\nint VRT_r_obj_hits(const struct sess *);\nunsi");
+ vsb_cat(sb, "gned VRT_r_obj_cacheable(const struct sess *);\nvoid V");
+ vsb_cat(sb, "RT_l_obj_cacheable(const struct sess *, unsigned);\ndo");
+ vsb_cat(sb, "uble VRT_r_obj_ttl(const struct sess *);\nvoid VRT_l_o");
+ vsb_cat(sb, "bj_ttl(const struct sess *, double);\ndouble VRT_r_obj");
+ vsb_cat(sb, "_grace(const struct sess *);\nvoid VRT_l_obj_grace(con");
+ vsb_cat(sb, "st struct sess *, double);\ndouble VRT_r_obj_prefetch(");
+ vsb_cat(sb, "const struct sess *);\nvoid VRT_l_obj_prefetch(const s");
+ vsb_cat(sb, "truct sess *, double);\ndouble VRT_r_obj_lastuse(const");
+ vsb_cat(sb, " struct sess *);\nconst char * VRT_r_obj_hash(const st");
+ vsb_cat(sb, "ruct sess *);\nconst char * VRT_r_resp_proto(const str");
+ vsb_cat(sb, "uct sess *);\nvoid VRT_l_resp_proto(const struct sess ");
+ vsb_cat(sb, "*, const char *, ...);\nint VRT_r_resp_status(const st");
+ vsb_cat(sb, "ruct sess *);\nvoid VRT_l_resp_status(const struct ses");
+ vsb_cat(sb, "s *, int);\nconst char * VRT_r_resp_response(const str");
+ vsb_cat(sb, "uct sess *);\nvoid VRT_l_resp_response(const struct se");
+ vsb_cat(sb, "ss *, const char *, ...);\ndouble VRT_r_now(const stru");
+ vsb_cat(sb, "ct sess *);\nunsigned VRT_r_req_backend_healthy(const ");
+ vsb_cat(sb, "struct sess *);\n");
}
# Generate various .c and .h files for the VCL compiler and the interfaces
# for it.
-# These are the metods which can be called in the VCL program.
+# These are the metods which can be called in the VCL program.
# Second element is list of valid return actions.
#
set methods {
# Language keywords
#
set keywords {
- include
+ include
if else elseif elsif
}
proc warns {fd} {
puts $fd "/*"
- puts $fd { * $Id$}
+ puts $fd \
+ { * $Id$}
puts $fd " *"
puts $fd " * NB: This file is machine generated, DO NOT EDIT!"
puts $fd " *"
unsigned nref;
unsigned busy;
unsigned discard;
-
+
unsigned nsrc;
const char **srcname;
const char **srcbody;
puts $for "#ifdef VCL_RET_MAC"
set i 0
foreach k $returns {
+ set u [string toupper $k]
if {$k == "error"} {
puts $for "#ifdef VCL_RET_MAC_E"
- puts $for "VCL_RET_MAC_E($k, [string toupper $k], (1 << $i), $i)"
+ puts $for "VCL_RET_MAC_E($k, $u, (1 << $i), $i)"
puts $for "#endif"
} else {
- puts $for "VCL_RET_MAC($k, [string toupper $k], (1 << $i), $i)"
+ puts $for "VCL_RET_MAC($k, $u, (1 << $i), $i)"
}
incr i
}
puts -nonewline $for "VCL_MET_MAC([lindex $m 0]"
puts -nonewline $for ",[string toupper [lindex $m 0]]"
set l [lindex $m 1]
- puts -nonewline $for ",(VCL_RET_[string toupper [lindex $l 0]]"
+ puts -nonewline $for ",(\n VCL_RET_[string toupper [lindex $l 0]]"
foreach r [lrange $l 1 end] {
puts -nonewline $for "|VCL_RET_[string toupper $r]"
}
set seq [lsort [array names xx]]
puts $fo {
+#define M1() do {*q = p + 1; return (p[0]); } while (0)
+#define M2(c, t) do {if (p[1] == (c)) { *q = p + 2; return (t); }} while (0)
+
unsigned
vcl_fixed_token(const char *p, const char **q)}
puts $fo "{"
scan "$ch" "%c" cx
puts $fo " case '$ch':"
set retval "0"
+ set m1 0
foreach tt $l {
set k [lindex $tt 0]
if {[string length $k] == 1} {
- puts $fo "\t\t*q = p + 1;"
- set retval {p[0]}
+ puts $fo "\t\tM1();"
+ set m1 1
continue;
}
+ if {[string length $k] == 2} {
+ puts -nonewline $fo " M2("
+ puts -nonewline $fo "'[string index $k 1]'"
+ puts $fo ", [lindex $tt 1]);"
+ continue;
+ }
puts -nonewline $fo " if ("
for {set i 1} {$i < [string length $k]} {incr i} {
if {$i > 1} {
- puts -nonewline $fo " && "
- if {![expr $i % 3]} {
- puts -nonewline $fo "\n\t\t "
+ puts -nonewline $fo " &&"
+ if {[expr $i % 3] == 1} {
+ puts -nonewline $fo "\n\t\t "
}
+ puts -nonewline $fo " "
}
puts -nonewline $fo "p\[$i\] == '[string index $k $i]'"
}
if {[lindex $tt 2]} {
- if {![expr $i % 3]} {
+ if {[expr $i % 3] == 1} {
puts -nonewline $fo "\n\t\t "
}
puts -nonewline $fo " && !isvar(p\[$i\])"
puts $fo "\t\t\treturn ([lindex $tt 1]);"
puts $fo "\t\t}"
}
- puts $fo "\t\treturn ($retval);"
-}
+ if {$m1 == 0} {
+ puts $fo "\t\treturn ($retval);"
+ }
+}
puts $fo " default:"
puts $fo " return (0);"
puts $fo "}"
puts $fo ""
-puts $fo "const char *vcl_tnames\[256\];\n"
-puts $fo "void"
-puts $fo "vcl_init_tnames(void)"
-puts $fo "{"
+puts $fo "const char *vcl_tnames\[256\] = {"
foreach i $token2 {
- puts $fo "\tvcl_tnames\[[lindex $i 0]\] = \"[lindex $i 0]\";"
+ puts $fo "\t\[[lindex $i 0]\] = \"[lindex $i 0]\","
}
foreach i $tokens {
- puts $fo "\tvcl_tnames\[[lindex $i 0]\] = \"[lindex $i 1]\";"
+ puts $fo "\t\[[lindex $i 0]\] = \"[lindex $i 1]\","
}
-puts $fo "}"
+puts $fo "};"
#----------------------------------------------------------------------
# Create the C-code which emits the boilerplate definitions for the
proc copy_include {n} {
global fo
+ puts $fo "\n\t/* $n */\n"
set fi [open $n]
+ set n 0
while {[gets $fi a] >= 0} {
- regsub -all {\\} $a {\\\\} a
- puts $fo "\tvsb_cat(sb, \"$a\\n\");"
+ for {set b 0} {$b < [string length $a]} {incr b} {
+ if {$n == 0} {
+ puts -nonewline $fo "\tvsb_cat(sb, \""
+ }
+ set c [string index $a $b]
+ if {"$c" == "\\"} {
+ puts -nonewline $fo "\\\\"
+ incr n
+ } elseif {"$c" == "\t"} {
+ puts -nonewline $fo "\\t"
+ incr n
+ } else {
+ puts -nonewline $fo "$c"
+ }
+ incr n
+ if {$n > 53} {
+ puts $fo "\");"
+ set n 0
+ }
+ }
+ if {$n == 0} {
+ puts -nonewline $fo "\tvsb_cat(sb, \""
+ }
+ puts -nonewline $fo "\\n"
+ incr n 2
+ if {$n > 53} {
+ puts $fo "\");"
+ set n 0
+ }
+ }
+ if {$n > 0} {
+ puts $fo "\");"
}
close $fi
}
puts $fo "{"
set i 0
foreach k $returns {
- puts $fo "\tvsb_cat(sb, \"#define VCL_RET_[string toupper $k] (1 << $i)\\n\");"
+ set u [string toupper $k]
+ puts $fo "\tvsb_cat(sb, \"#define VCL_RET_$u (1 << $i)\\n\");"
incr i
}
proc method_map {m} {
- set l ""
+ set l1 ""
+ set l2 ""
foreach i $m {
- append l " | "
- append l VCL_MET_[string toupper $i]
+ if {[string length $l2] > 55} {
+ if {$l1 != ""} {
+ append l1 "\n\t "
+ }
+ append l1 "$l2"
+ set l2 ""
+ }
+ if {$l2 != "" || $l1 != ""} {
+ append l2 " | "
+ }
+ append l2 VCL_MET_[string toupper $i]
}
- if {$l == ""} {
+ if {$l2 != ""} {
+ if {$l1 != ""} {
+ append l1 "\n\t "
+ }
+ append l1 "$l2"
+ }
+ if {$l1 == ""} {
return "0"
}
- return [string range $l 3 end]
+ return $l1
}
proc vars {v pa} {
puts $fo "\t\{ \"$n\", $t, [string length $n],"
}
if {$a == "RO" || $a == "RW"} {
- puts $fo "\t \"VRT_r_${m}($pa)\","
+ puts -nonewline $fo "\t \"VRT_r_${m}($pa)\","
if {![regexp HDR_ $t]} {
puts $fp "$tt($t) VRT_r_${m}($ty);"
}
} else {
- puts $fo "\t NULL,"
+ puts -nonewline $fo "\t NULL,"
}
if {$a == "WO" || $a == "RW"} {
puts $fo "\t \"VRT_l_${m}($pa, \","
} else {
puts $fo "\t NULL,"
}
- puts $fo "\t V_$a,"
+ puts -nonewline $fo "\t V_$a,"
if {![regexp HDR_ $t]} {
puts $fo "\t 0,"
} else {
struct var vcc_vars[] = {
{ "client.ip", IP, 9,
- "VRT_r_client_ip(sp)",
- NULL,
- V_RO,
- 0,
- VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_ERROR
+ "VRT_r_client_ip(sp)", NULL,
+ V_RO, 0,
+ VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH
+ | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+ | VCL_MET_ERROR
},
{ "server.ip", IP, 9,
- "VRT_r_server_ip(sp)",
- NULL,
- V_RO,
- 0,
- VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_ERROR
+ "VRT_r_server_ip(sp)", NULL,
+ V_RO, 0,
+ VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH
+ | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+ | VCL_MET_ERROR
},
{ "server.port", INT, 11,
- "VRT_r_server_port(sp)",
- NULL,
- V_RO,
- 0,
- VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_ERROR
+ "VRT_r_server_port(sp)", NULL,
+ V_RO, 0,
+ VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH
+ | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+ | VCL_MET_ERROR
},
{ "req.request", STRING, 11,
- "VRT_r_req_request(sp)",
- "VRT_l_req_request(sp, ",
- V_RW,
- 0,
- VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_ERROR
+ "VRT_r_req_request(sp)", "VRT_l_req_request(sp, ",
+ V_RW, 0,
+ VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH
+ | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_ERROR
},
{ "req.url", STRING, 7,
- "VRT_r_req_url(sp)",
- "VRT_l_req_url(sp, ",
- V_RW,
- 0,
- VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_ERROR
+ "VRT_r_req_url(sp)", "VRT_l_req_url(sp, ",
+ V_RW, 0,
+ VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH
+ | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_ERROR
},
{ "req.proto", STRING, 9,
- "VRT_r_req_proto(sp)",
- "VRT_l_req_proto(sp, ",
- V_RW,
- 0,
- VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_ERROR
+ "VRT_r_req_proto(sp)", "VRT_l_req_proto(sp, ",
+ V_RW, 0,
+ VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH
+ | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_ERROR
},
{ "req.http.", HEADER, 9,
- "VRT_r_req_http_(sp)",
- "VRT_l_req_http_(sp, ",
- V_RW,
- "HDR_REQ",
- VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_ERROR
+ "VRT_r_req_http_(sp)", "VRT_l_req_http_(sp, ",
+ V_RW, "HDR_REQ",
+ VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH
+ | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_ERROR
},
{ "req.hash", HASH, 8,
- NULL,
- "VRT_l_req_hash(sp, ",
- V_WO,
- 0,
+ NULL, "VRT_l_req_hash(sp, ",
+ V_WO, 0,
VCL_MET_HASH | VCL_MET_ERROR
},
{ "req.backend", BACKEND, 11,
- "VRT_r_req_backend(sp)",
- "VRT_l_req_backend(sp, ",
- V_RW,
- 0,
- VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_ERROR
+ "VRT_r_req_backend(sp)", "VRT_l_req_backend(sp, ",
+ V_RW, 0,
+ VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH
+ | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_ERROR
},
{ "req.restarts", INT, 12,
- "VRT_r_req_restarts(sp)",
- NULL,
- V_RO,
- 0,
- VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_ERROR
+ "VRT_r_req_restarts(sp)", NULL,
+ V_RO, 0,
+ VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH
+ | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+ | VCL_MET_ERROR
},
{ "req.grace", TIME, 9,
- "VRT_r_req_grace(sp)",
- "VRT_l_req_grace(sp, ",
- V_RW,
- 0,
- VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_ERROR
+ "VRT_r_req_grace(sp)", "VRT_l_req_grace(sp, ",
+ V_RW, 0,
+ VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH
+ | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+ | VCL_MET_ERROR
},
{ "req.xid", STRING, 7,
- "VRT_r_req_xid(sp)",
- NULL,
- V_RO,
- 0,
- VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_ERROR
+ "VRT_r_req_xid(sp)", NULL,
+ V_RO, 0,
+ VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH
+ | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+ | VCL_MET_ERROR
},
{ "bereq.request", STRING, 13,
- "VRT_r_bereq_request(sp)",
- "VRT_l_bereq_request(sp, ",
- V_RW,
- 0,
+ "VRT_r_bereq_request(sp)", "VRT_l_bereq_request(sp, ",
+ V_RW, 0,
VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS | VCL_MET_FETCH
},
{ "bereq.url", STRING, 9,
- "VRT_r_bereq_url(sp)",
- "VRT_l_bereq_url(sp, ",
- V_RW,
- 0,
+ "VRT_r_bereq_url(sp)", "VRT_l_bereq_url(sp, ",
+ V_RW, 0,
VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS | VCL_MET_FETCH
},
{ "bereq.proto", STRING, 11,
- "VRT_r_bereq_proto(sp)",
- "VRT_l_bereq_proto(sp, ",
- V_RW,
- 0,
+ "VRT_r_bereq_proto(sp)", "VRT_l_bereq_proto(sp, ",
+ V_RW, 0,
VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS | VCL_MET_FETCH
},
{ "bereq.http.", HEADER, 11,
- "VRT_r_bereq_http_(sp)",
- "VRT_l_bereq_http_(sp, ",
- V_RW,
- "HDR_BEREQ",
+ "VRT_r_bereq_http_(sp)", "VRT_l_bereq_http_(sp, ",
+ V_RW, "HDR_BEREQ",
VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_MISS | VCL_MET_FETCH
},
{ "obj.proto", STRING, 9,
- "VRT_r_obj_proto(sp)",
- "VRT_l_obj_proto(sp, ",
- V_RW,
- 0,
+ "VRT_r_obj_proto(sp)", "VRT_l_obj_proto(sp, ",
+ V_RW, 0,
VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_ERROR
},
{ "obj.status", INT, 10,
- "VRT_r_obj_status(sp)",
- "VRT_l_obj_status(sp, ",
- V_RW,
- 0,
+ "VRT_r_obj_status(sp)", "VRT_l_obj_status(sp, ",
+ V_RW, 0,
VCL_MET_FETCH | VCL_MET_ERROR
},
{ "obj.response", STRING, 12,
- "VRT_r_obj_response(sp)",
- "VRT_l_obj_response(sp, ",
- V_RW,
- 0,
+ "VRT_r_obj_response(sp)", "VRT_l_obj_response(sp, ",
+ V_RW, 0,
VCL_MET_FETCH | VCL_MET_ERROR
},
{ "obj.hits", INT, 8,
- "VRT_r_obj_hits(sp)",
- NULL,
- V_RO,
- 0,
+ "VRT_r_obj_hits(sp)", NULL,
+ V_RO, 0,
VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
},
{ "obj.http.", HEADER, 9,
- "VRT_r_obj_http_(sp)",
- "VRT_l_obj_http_(sp, ",
- V_RW,
- "HDR_OBJ",
+ "VRT_r_obj_http_(sp)", "VRT_l_obj_http_(sp, ",
+ V_RW, "HDR_OBJ",
VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_ERROR
},
{ "obj.cacheable", BOOL, 13,
- "VRT_r_obj_cacheable(sp)",
- "VRT_l_obj_cacheable(sp, ",
- V_RW,
- 0,
- VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DISCARD | VCL_MET_TIMEOUT | VCL_MET_ERROR
+ "VRT_r_obj_cacheable(sp)", "VRT_l_obj_cacheable(sp, ",
+ V_RW, 0,
+ VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DISCARD | VCL_MET_TIMEOUT
+ | VCL_MET_ERROR
},
{ "obj.ttl", TIME, 7,
- "VRT_r_obj_ttl(sp)",
- "VRT_l_obj_ttl(sp, ",
- V_RW,
- 0,
- VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DISCARD | VCL_MET_TIMEOUT | VCL_MET_ERROR
+ "VRT_r_obj_ttl(sp)", "VRT_l_obj_ttl(sp, ",
+ V_RW, 0,
+ VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DISCARD | VCL_MET_TIMEOUT
+ | VCL_MET_ERROR
},
{ "obj.grace", TIME, 9,
- "VRT_r_obj_grace(sp)",
- "VRT_l_obj_grace(sp, ",
- V_RW,
- 0,
- VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DISCARD | VCL_MET_TIMEOUT | VCL_MET_ERROR
+ "VRT_r_obj_grace(sp)", "VRT_l_obj_grace(sp, ",
+ V_RW, 0,
+ VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DISCARD | VCL_MET_TIMEOUT
+ | VCL_MET_ERROR
},
{ "obj.prefetch", RTIME, 12,
- "VRT_r_obj_prefetch(sp)",
- "VRT_l_obj_prefetch(sp, ",
- V_RW,
- 0,
+ "VRT_r_obj_prefetch(sp)", "VRT_l_obj_prefetch(sp, ",
+ V_RW, 0,
VCL_MET_FETCH | VCL_MET_PREFETCH
},
{ "obj.lastuse", TIME, 11,
- "VRT_r_obj_lastuse(sp)",
- NULL,
- V_RO,
- 0,
- VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_DISCARD | VCL_MET_TIMEOUT | VCL_MET_ERROR
+ "VRT_r_obj_lastuse(sp)", NULL,
+ V_RO, 0,
+ VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_DISCARD
+ | VCL_MET_TIMEOUT | VCL_MET_ERROR
},
{ "obj.hash", STRING, 8,
- "VRT_r_obj_hash(sp)",
- NULL,
- V_RO,
- 0,
- VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_ERROR
+ "VRT_r_obj_hash(sp)", NULL,
+ V_RO, 0,
+ VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+ | VCL_MET_ERROR
},
{ "resp.proto", STRING, 10,
- "VRT_r_resp_proto(sp)",
- "VRT_l_resp_proto(sp, ",
- V_RW,
- 0,
+ "VRT_r_resp_proto(sp)", "VRT_l_resp_proto(sp, ",
+ V_RW, 0,
VCL_MET_DELIVER
},
{ "resp.status", INT, 11,
- "VRT_r_resp_status(sp)",
- "VRT_l_resp_status(sp, ",
- V_RW,
- 0,
+ "VRT_r_resp_status(sp)", "VRT_l_resp_status(sp, ",
+ V_RW, 0,
VCL_MET_DELIVER
},
{ "resp.response", STRING, 13,
- "VRT_r_resp_response(sp)",
- "VRT_l_resp_response(sp, ",
- V_RW,
- 0,
+ "VRT_r_resp_response(sp)", "VRT_l_resp_response(sp, ",
+ V_RW, 0,
VCL_MET_DELIVER
},
{ "resp.http.", HEADER, 10,
- "VRT_r_resp_http_(sp)",
- "VRT_l_resp_http_(sp, ",
- V_RW,
- "HDR_RESP",
+ "VRT_r_resp_http_(sp)", "VRT_l_resp_http_(sp, ",
+ V_RW, "HDR_RESP",
VCL_MET_DELIVER
},
{ "now", TIME, 3,
- "VRT_r_now(sp)",
- NULL,
- V_RO,
- 0,
- VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_DISCARD | VCL_MET_TIMEOUT
+ "VRT_r_now(sp)", NULL,
+ V_RO, 0,
+ VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH
+ | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+ | VCL_MET_DISCARD | VCL_MET_TIMEOUT
},
{ "req.backend.healthy", BOOL, 19,
- "VRT_r_req_backend_healthy(sp)",
- NULL,
- V_RO,
- 0,
- VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER | VCL_MET_DISCARD | VCL_MET_TIMEOUT
+ "VRT_r_req_backend_healthy(sp)", NULL,
+ V_RO, 0,
+ VCL_MET_RECV | VCL_MET_PIPE | VCL_MET_PASS | VCL_MET_HASH
+ | VCL_MET_MISS | VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+ | VCL_MET_DISCARD | VCL_MET_TIMEOUT
},
{ NULL }
};
#define C(tl, sep) do { \
Fb(tl, 1, "VRT_count(sp, %u)%s\n", ++tl->cnt, sep); \
- tl->t->cnt = tl->cnt; \
+ tl->t->cnt = tl->cnt; \
} while (0)
/*--------------------------------------------------------------------
break;
case ID:
for (tp = toplev; tp->name != NULL; tp++) {
- if (!vcc_IdIs(tl->t, tp->name))
+ if (!vcc_IdIs(tl->t, tp->name))
continue;
tp->func(tl);
break;
#define isvar(c) (isident(c) || (c) == '.')
unsigned vcl_fixed_token(const char *p, const char **q);
extern const char *vcl_tnames[256];
-void vcl_init_tnames(void);
void vcl_output_lang_h(struct vsb *sb);
#define PF(t) (int)((t)->e - (t)->b), (t)->b
Expect(tl, ',');
vcc_NextToken(tl);
-
+
Expect(tl, CSTR);
p = vcc_regexp(tl, 1);
vcc_NextToken(tl);
Expect(tl, ',');
vcc_NextToken(tl);
-
+
if (!vcc_StringVal(tl)) {
vcc_ExpectedStringval(tl);
return (0);
*/
int
-vcc_StringVal(struct tokenlist *tl)
+vcc_StringVal(struct tokenlist *tl)
{
struct var *vp;
Fb(tl, 0, "VRT_backend_string(sp)");
break;
default:
- vsb_printf(tl->sb,
- "String representation of '%s' not implemented yet.\n",
- vp->name);
+ vsb_printf(tl->sb, "String representation of '%s'"
+ " not implemented yet.\n", vp->name);
vcc_ErrWhere(tl, tl->t);
return (0);
}
vcc_icoord(tl->sb, t, &l);
vsb_printf(tl->sb, "\n");
-
+
x = y = 0;
e = t->src->e;
for (p = l; p < e && *p != '\n'; p++) {
assert(t->tok == ID);
for (q = t->b; q < t->e; q++) {
- if (!isalnum(*q) && *q != '_')
+ if (!isalnum(*q) && *q != '_')
return (0);
}
return (1);
vcc_ErrWhere(tl, tl->t);
return;
}
-
+
/* Recognize long-strings */
if (*p == '{' && p[1] == '"') {
for (q = p + 2; q < sp->e; q++) {
if (q < sp->e) {
p = q + 2;
u = tl->t->e - tl->t->b;
- u -= 4; /* {" ... "} */
+ u -= 4; /* {" ... "} */
tl->t->dec = TlAlloc(tl, u + 1 );
AN(tl->t->dec);
memcpy(tl->t->dec, tl->t->b + 2, u);
struct procuse *pu;
VTAILQ_FOREACH(pu, &p->uses, list)
- if (!(pu->v->methods & m->bitval))
+ if (!(pu->v->methods & m->bitval))
return (pu);
return (NULL);
}
static int
-vcc_CheckUseRecurse(struct tokenlist *tl, const struct proc *p, struct method *m)
+vcc_CheckUseRecurse(struct tokenlist *tl, const struct proc *p,
+ struct method *m)
{
struct proccall *pc;
struct procuse *pu;
vsb_printf(tl->sb,
"Variable \"%.*s\" is not available in %s\n",
PF(pu->t), m->name);
- vcc_ErrWhere(tl, pu->t);
+ vcc_ErrWhere(tl, pu->t);
vsb_printf(tl->sb, "\n...in function \"%.*s\"\n",
PF(p->name));
vcc_ErrWhere(tl, p->name);