From 0c62efa84b096f48f380364fa9b585694371e865 Mon Sep 17 00:00:00 2001 From: phk Date: Sat, 18 Oct 2008 20:50:10 +0000 Subject: [PATCH] White-space commit from hell. I need a printout for a code-walkthrough and this commit wraps lines, removes trailing space, space before TAB and other iregularities. Some generated files have been compacted a bit. A few changes to comments along the way. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@3324 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishadm/varnishadm.c | 6 +- varnish-cache/bin/varnishd/Makefile.am | 2 +- varnish-cache/bin/varnishd/cache.h | 49 +- varnish-cache/bin/varnishd/cache_acceptor.c | 18 +- varnish-cache/bin/varnishd/cache_acceptor.h | 2 +- .../bin/varnishd/cache_acceptor_kqueue.c | 2 +- .../bin/varnishd/cache_acceptor_ports.c | 6 +- varnish-cache/bin/varnishd/cache_backend.c | 7 +- .../bin/varnishd/cache_backend_cfg.c | 4 +- .../bin/varnishd/cache_backend_poll.c | 22 +- varnish-cache/bin/varnishd/cache_ban.c | 4 +- varnish-cache/bin/varnishd/cache_center.c | 28 +- varnish-cache/bin/varnishd/cache_cli.c | 28 +- varnish-cache/bin/varnishd/cache_dir_random.c | 11 +- .../bin/varnishd/cache_dir_round_robin.c | 7 +- varnish-cache/bin/varnishd/cache_dir_simple.c | 7 +- varnish-cache/bin/varnishd/cache_expire.c | 10 +- varnish-cache/bin/varnishd/cache_fetch.c | 6 +- varnish-cache/bin/varnishd/cache_hash.c | 8 +- varnish-cache/bin/varnishd/cache_http.c | 52 +- varnish-cache/bin/varnishd/cache_httpconn.c | 4 +- varnish-cache/bin/varnishd/cache_panic.c | 13 +- varnish-cache/bin/varnishd/cache_pipe.c | 2 +- varnish-cache/bin/varnishd/cache_pool.c | 4 +- varnish-cache/bin/varnishd/cache_vcl.c | 8 +- varnish-cache/bin/varnishd/cache_vrt.c | 17 +- varnish-cache/bin/varnishd/cache_vrt_esi.c | 20 +- varnish-cache/bin/varnishd/cache_vrt_re.c | 5 +- varnish-cache/bin/varnishd/default.vcl | 29 +- varnish-cache/bin/varnishd/hash_classic.c | 2 +- varnish-cache/bin/varnishd/hash_simple_list.c | 36 +- varnish-cache/bin/varnishd/hash_slinger.h | 3 +- varnish-cache/bin/varnishd/heritage.h | 5 +- varnish-cache/bin/varnishd/mgt_child.c | 6 +- varnish-cache/bin/varnishd/mgt_cli.c | 8 +- varnish-cache/bin/varnishd/mgt_param.c | 16 +- varnish-cache/bin/varnishd/mgt_vcc.c | 6 +- varnish-cache/bin/varnishd/shmlog.c | 6 +- varnish-cache/bin/varnishd/stevedore.c | 2 +- varnish-cache/bin/varnishd/storage_file.c | 4 +- varnish-cache/bin/varnishd/storage_malloc.c | 4 +- varnish-cache/bin/varnishd/storage_umem.c | 4 +- varnish-cache/bin/varnishd/varnishd.c | 18 +- varnish-cache/bin/varnishhist/varnishhist.c | 7 +- varnish-cache/bin/varnishlog/varnishlog.c | 9 +- varnish-cache/bin/varnishncsa/varnishncsa.c | 7 +- .../bin/varnishreplay/varnishreplay.c | 21 +- varnish-cache/bin/varnishstat/varnishstat.c | 32 +- varnish-cache/bin/varnishtest/vtc.c | 27 +- varnish-cache/bin/varnishtest/vtc.h | 16 +- varnish-cache/bin/varnishtest/vtc_client.c | 8 +- varnish-cache/bin/varnishtest/vtc_http.c | 22 +- varnish-cache/bin/varnishtest/vtc_log.c | 8 +- varnish-cache/bin/varnishtest/vtc_sema.c | 6 +- varnish-cache/bin/varnishtest/vtc_server.c | 10 +- varnish-cache/bin/varnishtest/vtc_varnish.c | 8 +- varnish-cache/bin/varnishtop/varnishtop.c | 3 +- varnish-cache/include/cli.h | 2 +- varnish-cache/include/http_headers.h | 101 ++- varnish-cache/include/libvarnish.h | 15 +- varnish-cache/include/stat_field.h | 3 +- varnish-cache/include/varnishapi.h | 10 +- varnish-cache/include/vcl.h | 2 +- varnish-cache/include/vcl_returns.h | 36 +- varnish-cache/include/vct.h | 12 +- varnish-cache/include/vev.h | 2 +- varnish-cache/include/vqueue.h | 18 +- varnish-cache/include/vrt.h | 23 +- varnish-cache/include/vsb.h | 6 +- varnish-cache/lib/libvarnish/assert.c | 3 +- varnish-cache/lib/libvarnish/binary_heap.c | 17 +- varnish-cache/lib/libvarnish/cli_common.c | 3 +- varnish-cache/lib/libvarnish/num.c | 66 +- varnish-cache/lib/libvarnish/tcp.c | 5 +- varnish-cache/lib/libvarnish/vct.c | 36 +- varnish-cache/lib/libvarnish/version.c | 3 +- varnish-cache/lib/libvarnish/vlu.c | 2 +- varnish-cache/lib/libvarnish/vss.c | 2 +- varnish-cache/lib/libvarnishapi/instance.c | 3 +- varnish-cache/lib/libvarnishapi/shmlog.c | 3 +- varnish-cache/lib/libvcl/vcc_acl.c | 21 +- varnish-cache/lib/libvcl/vcc_action.c | 49 +- varnish-cache/lib/libvcl/vcc_backend.c | 51 +- varnish-cache/lib/libvcl/vcc_compile.c | 2 - varnish-cache/lib/libvcl/vcc_compile.h | 18 +- varnish-cache/lib/libvcl/vcc_dir_random.c | 5 +- .../lib/libvcl/vcc_dir_round_robin.c | 15 +- varnish-cache/lib/libvcl/vcc_fixed_token.c | 714 +++++++----------- .../lib/libvcl/vcc_gen_fixed_token.tcl | 95 ++- varnish-cache/lib/libvcl/vcc_gen_obj.tcl | 32 +- varnish-cache/lib/libvcl/vcc_obj.c | 260 +++---- varnish-cache/lib/libvcl/vcc_parse.c | 4 +- varnish-cache/lib/libvcl/vcc_priv.h | 1 - varnish-cache/lib/libvcl/vcc_string.c | 11 +- varnish-cache/lib/libvcl/vcc_token.c | 8 +- varnish-cache/lib/libvcl/vcc_xref.c | 7 +- 96 files changed, 1147 insertions(+), 1204 deletions(-) diff --git a/varnish-cache/bin/varnishadm/varnishadm.c b/varnish-cache/bin/varnishadm/varnishadm.c index 1c8f8cef..45bccd0e 100644 --- a/varnish-cache/bin/varnishadm/varnishadm.c +++ b/varnish-cache/bin/varnishadm/varnishadm.c @@ -90,14 +90,16 @@ telnet_mgt(const char *T_arg, int argc, char *argv[]) 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'; diff --git a/varnish-cache/bin/varnishd/Makefile.am b/varnish-cache/bin/varnishd/Makefile.am index f43e2af2..b94a9d31 100644 --- a/varnish-cache/bin/varnishd/Makefile.am +++ b/varnish-cache/bin/varnishd/Makefile.am @@ -89,7 +89,7 @@ DISTCLEANFILES = default_vcl.h # 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 diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 39738f3f..78b1e90d 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -135,11 +135,11 @@ struct http { 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; @@ -246,7 +246,7 @@ struct storage { struct object { unsigned magic; #define OBJECT_MAGIC 0x32851d42 - unsigned refcnt; + unsigned refcnt; unsigned xid; struct objhead *objhead; struct storage *objstore; @@ -349,7 +349,7 @@ struct sess { enum step step; unsigned cur_method; - unsigned handling; + unsigned handling; unsigned char sendbody; unsigned char wantbody; int err_code; @@ -465,25 +465,32 @@ void HTTP_Init(void); 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); @@ -538,21 +545,23 @@ void WSLR(struct worker *w, enum shmlogtag tag, int id, txt t); 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 @@ -616,10 +625,10 @@ do { \ __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); \ @@ -627,11 +636,11 @@ do { \ 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) diff --git a/varnish-cache/bin/varnishd/cache_acceptor.c b/varnish-cache/bin/varnishd/cache_acceptor.c index cf47872a..119eda77 100644 --- a/varnish-cache/bin/varnishd/cache_acceptor.c +++ b/varnish-cache/bin/varnishd/cache_acceptor.c @@ -28,9 +28,6 @@ * * $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" @@ -68,7 +65,7 @@ static struct acceptor *vca_acceptors[] = { 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; @@ -227,12 +224,15 @@ vca_acct(void *arg) 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; } @@ -320,7 +320,7 @@ ccf_start(struct cli *cli, const char * const *av, void *priv) (void)cli; (void)av; (void)priv; - + if (vca_act == NULL) vca_act = vca_acceptors[0]; @@ -356,7 +356,7 @@ VCA_tweak_acceptor(struct cli *cli, const char *arg) 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 ? "" : ", ", diff --git a/varnish-cache/bin/varnishd/cache_acceptor.h b/varnish-cache/bin/varnishd/cache_acceptor.h index f885c1c3..f7921406 100644 --- a/varnish-cache/bin/varnishd/cache_acceptor.h +++ b/varnish-cache/bin/varnishd/cache_acceptor.h @@ -35,7 +35,7 @@ typedef void acceptor_init_f(void); typedef void acceptor_pass_f(struct sess *); struct acceptor { - const char *name; + const char *name; acceptor_init_f *init; acceptor_pass_f *pass; }; diff --git a/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c b/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c index 3cf319b9..8ffa1894 100644 --- a/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c +++ b/varnish-cache/bin/varnishd/cache_acceptor_kqueue.c @@ -85,7 +85,7 @@ vca_kq_sess(struct sess *sp, short arm) 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(); } diff --git a/varnish-cache/bin/varnishd/cache_acceptor_ports.c b/varnish-cache/bin/varnishd/cache_acceptor_ports.c index 12d29ece..6a099d69 100644 --- a/varnish-cache/bin/varnishd/cache_acceptor_ports.c +++ b/varnish-cache/bin/varnishd/cache_acceptor_ports.c @@ -61,7 +61,8 @@ static VTAILQ_HEAD(,sess) sesshead = VTAILQ_HEAD_INITIALIZER(sesshead); 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 @@ -120,7 +121,8 @@ vca_main(void *arg) 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; eiconnect_timeout; @@ -257,7 +258,7 @@ bes_conn_try(const struct sess *sp, struct backend *bp) if (s < 0) { LOCK(&bp->mtx); - bp->n_conn--; + bp->n_conn--; bp->refcount--; /* Only keep ref on success */ UNLOCK(&bp->mtx); } diff --git a/varnish-cache/bin/varnishd/cache_backend_cfg.c b/varnish-cache/bin/varnishd/cache_backend_cfg.c index af7c4eb9..330ca2b1 100644 --- a/varnish-cache/bin/varnishd/cache_backend_cfg.c +++ b/varnish-cache/bin/varnishd/cache_backend_cfg.c @@ -227,9 +227,9 @@ VBE_AddBackend(struct cli *cli, const struct vrt_backend *vb) /* * 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); diff --git a/varnish-cache/bin/varnishd/cache_backend_poll.c b/varnish-cache/bin/varnishd/cache_backend_poll.c index 6afce413..7a812ddf 100644 --- a/varnish-cache/bin/varnishd/cache_backend_poll.c +++ b/varnish-cache/bin/varnishd/cache_backend_poll.c @@ -62,14 +62,14 @@ struct vbp_target { #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" @@ -86,7 +86,7 @@ struct vbp_target { 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"; @@ -319,7 +319,7 @@ vbp_wrk_poll_backend(void *priv) 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); } @@ -358,15 +358,15 @@ vbp_health_one(struct cli *cli, const struct vbp_target *vt) 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 @@ -386,10 +386,10 @@ vbp_health(struct cli *cli, const char * const *av, void *priv) } 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 } }; /*-------------------------------------------------------------------- diff --git a/varnish-cache/bin/varnishd/cache_ban.c b/varnish-cache/bin/varnishd/cache_ban.c index 050d0983..77ca6324 100644 --- a/varnish-cache/bin/varnishd/cache_ban.c +++ b/varnish-cache/bin/varnishd/cache_ban.c @@ -217,10 +217,10 @@ ccf_purge_list(struct cli *cli, const char * const *av, void *priv) (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. */ diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index 21a9199a..57b16051 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -109,7 +109,6 @@ cnt_again(struct sess *sp) return (0); } - /*-------------------------------------------------------------------- * We have a refcounted object on the session, now deliver it. * @@ -175,7 +174,7 @@ cnt_deliver(struct sess *sp) sp->director = NULL; sp->restarts = 0; - + RES_WriteObj(sp); HSH_Deref(sp->obj); sp->obj = NULL; @@ -183,7 +182,6 @@ cnt_deliver(struct sess *sp) return (0); } - /*-------------------------------------------------------------------- * This is the final state, figure out if we should close or recycle * the client connection @@ -209,7 +207,7 @@ cnt_done(struct sess *sp) 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); @@ -282,7 +280,6 @@ cnt_done(struct sess *sp) return (1); } - /*-------------------------------------------------------------------- * Emit an error * @@ -327,9 +324,9 @@ cnt_error(struct sess *sp) 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); @@ -344,7 +341,6 @@ cnt_error(struct sess *sp) return (0); } - /*-------------------------------------------------------------------- * We have fetched the headers from the backend, ask the VCL code what * to do next, then head off in that direction. @@ -370,7 +366,7 @@ DOT vcl_fetch -> deliver [label="deliver",style=bold,color=blue,weight=2] 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] */ @@ -556,7 +552,6 @@ cnt_hit(struct sess *sp) } } - /*-------------------------------------------------------------------- * LOOKUP * Hash things together and look object up in hash-table. @@ -654,7 +649,6 @@ cnt_lookup(struct sess *sp) return (0); } - /*-------------------------------------------------------------------- * We had a miss, ask VCL, proceed as instructed * @@ -719,7 +713,6 @@ cnt_miss(struct sess *sp) } } - /*-------------------------------------------------------------------- * Start pass processing by getting headers from backend, then * continue in passbody. @@ -824,7 +817,6 @@ cnt_pipe(struct sess *sp) return (0); } - /*-------------------------------------------------------------------- * RECV * We have a complete request, set everything up and start it. @@ -1006,14 +998,14 @@ CNT_Session(struct sess *sp) 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); @@ -1058,8 +1050,8 @@ DOT } 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); } diff --git a/varnish-cache/bin/varnishd/cache_cli.c b/varnish-cache/bin/varnishd/cache_cli.c index 7bb8ec8c..13d0a7a1 100644 --- a/varnish-cache/bin/varnishd/cache_cli.c +++ b/varnish-cache/bin/varnishd/cache_cli.c @@ -90,7 +90,7 @@ CLI_AddFuncs(enum cli_set_e which, struct cli_proto *p) } /*-------------------------------------------------------------------- - * 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. */ @@ -182,19 +182,19 @@ cli_debug_sizeof(struct cli *cli, const char * const *av, void *priv) #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); } /*--------------------------------------------------------------------*/ diff --git a/varnish-cache/bin/varnishd/cache_dir_random.c b/varnish-cache/bin/varnishd/cache_dir_random.c index 35c08c92..7241899a 100644 --- a/varnish-cache/bin/varnishd/cache_dir_random.c +++ b/varnish-cache/bin/varnishd/cache_dir_random.c @@ -88,7 +88,7 @@ vdi_random_getfd(struct sess *sp) continue; s1 += vs->hosts[i].weight; j++; - } + } if (j == 0) /* No healthy hosts */ return (NULL); @@ -116,7 +116,7 @@ vdi_random_getfd(struct sess *sp) if (vbe != NULL) return (vbe); k++; - } + } return (NULL); } @@ -147,7 +147,7 @@ vdi_random_fini(struct director *d) 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); @@ -158,13 +158,14 @@ vdi_random_fini(struct director *d) } 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); diff --git a/varnish-cache/bin/varnishd/cache_dir_round_robin.c b/varnish-cache/bin/varnishd/cache_dir_round_robin.c index 479657c4..021d32b3 100644 --- a/varnish-cache/bin/varnishd/cache_dir_round_robin.c +++ b/varnish-cache/bin/varnishd/cache_dir_round_robin.c @@ -111,7 +111,7 @@ vdi_round_robin_fini(struct director *d) 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); @@ -123,13 +123,14 @@ vdi_round_robin_fini(struct director *d) } 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); diff --git a/varnish-cache/bin/varnishd/cache_dir_simple.c b/varnish-cache/bin/varnishd/cache_dir_simple.c index dc47fa0b..f3abb1b1 100644 --- a/varnish-cache/bin/varnishd/cache_dir_simple.c +++ b/varnish-cache/bin/varnishd/cache_dir_simple.c @@ -85,7 +85,7 @@ vdi_simple_fini(struct director *d) 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; @@ -93,10 +93,11 @@ vdi_simple_fini(struct director *d) } 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); diff --git a/varnish-cache/bin/varnishd/cache_expire.c b/varnish-cache/bin/varnishd/cache_expire.c index d6b2f2f1..feddd5d8 100644 --- a/varnish-cache/bin/varnishd/cache_expire.c +++ b/varnish-cache/bin/varnishd/cache_expire.c @@ -65,7 +65,7 @@ * 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. */ @@ -219,7 +219,7 @@ EXP_Touch(const struct object *o, double now) } /*-------------------------------------------------------------------- - * 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. @@ -289,7 +289,7 @@ exp_timer(void *arg) t = TIM_real(); continue; } - + o = oe->obj; CHECK_OBJ_NOTNULL(o, OBJECT_MAGIC); assert(oe->timer_idx != BINHEAP_NOIDX); @@ -364,7 +364,7 @@ EXP_NukeOne(struct sess *sp) * 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); @@ -415,7 +415,7 @@ EXP_NukeOne(struct sess *sp) /* 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); diff --git a/varnish-cache/bin/varnishd/cache_fetch.c b/varnish-cache/bin/varnishd/cache_fetch.c index ab273c45..f44489c9 100644 --- a/varnish-cache/bin/varnishd/cache_fetch.c +++ b/varnish-cache/bin/varnishd/cache_fetch.c @@ -342,7 +342,7 @@ Fetch(struct sess *sp) * 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 */ @@ -469,8 +469,8 @@ Fetch(struct sess *sp) 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); } diff --git a/varnish-cache/bin/varnishd/cache_hash.c b/varnish-cache/bin/varnishd/cache_hash.c index 7ef852cb..72090082 100644 --- a/varnish-cache/bin/varnishd/cache_hash.c +++ b/varnish-cache/bin/varnishd/cache_hash.c @@ -119,7 +119,7 @@ HSH_Prealloc(struct sess *sp) VTAILQ_INIT(&w->nobj->store); VTAILQ_INIT(&w->nobj->esibits); VSL_stats->n_object++; - + } else CHECK_OBJ_NOTNULL(w->nobj, OBJECT_MAGIC); } @@ -223,7 +223,7 @@ HSH_Lookup(struct sess *sp) } 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; @@ -327,9 +327,9 @@ HSH_Unbusy(const struct sess *sp) 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); diff --git a/varnish-cache/bin/varnishd/cache_http.c b/varnish-cache/bin/varnishd/cache_http.c index 360e5d8c..d35ab4e4 100644 --- a/varnish-cache/bin/varnishd/cache_http.c +++ b/varnish-cache/bin/varnishd/cache_http.c @@ -55,9 +55,9 @@ #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), \ @@ -229,12 +229,13 @@ http_GetHdr(const struct http *hp, const char *hdr, char **ptr) } /*-------------------------------------------------------------------- - * 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; @@ -271,7 +272,7 @@ http_GetHdrField(const struct http *hp, const char *hdr, const char *field, char return (1); } /* Skip token */ - while (*h && !vct_issepctl(*h)) + while (*h && !vct_issepctl(*h)) h++; } return (0); @@ -410,7 +411,8 @@ http_dissect_hdrs(struct worker *w, struct http *hp, int fd, char *p, txt t) */ 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; @@ -513,7 +515,8 @@ http_DissectRequest(struct sess *sp) /*--------------------------------------------------------------------*/ 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; @@ -530,13 +533,13 @@ http_DissectResponse(struct worker *w, const struct http_conn *htc, struct http 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'); @@ -606,7 +609,8 @@ http_CopyResp(struct http *to, const struct http *fm) } 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); @@ -616,7 +620,8 @@ http_SetResp(struct http *to, const char *proto, const char *status, const char } 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); @@ -636,7 +641,8 @@ http_copyheader(struct worker *w, int fd, struct http *to, const struct http *fm /*--------------------------------------------------------------------*/ 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; @@ -664,10 +670,10 @@ http_FilterHeader(struct sess *sp, unsigned how) 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); @@ -741,7 +747,8 @@ http_SetHeader(struct worker *w, int fd, struct http *to, const char *hdr) /*--------------------------------------------------------------------*/ 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; @@ -763,7 +770,8 @@ http_PutField(struct worker *w, int fd, struct http *to, int field, const char * } 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); @@ -781,14 +789,16 @@ 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) +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; @@ -818,7 +828,7 @@ http_Unset(struct http *hp, const char *hdr) 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]); diff --git a/varnish-cache/bin/varnishd/cache_httpconn.c b/varnish-cache/bin/varnishd/cache_httpconn.c index 073f38b6..58aaab10 100644 --- a/varnish-cache/bin/varnishd/cache_httpconn.c +++ b/varnish-cache/bin/varnishd/cache_httpconn.c @@ -133,7 +133,7 @@ HTC_Complete(struct http_conn *htc) 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); @@ -195,7 +195,7 @@ HTC_Read(struct http_conn *htc, void *d, unsigned len) 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) diff --git a/varnish-cache/bin/varnishd/cache_panic.c b/varnish-cache/bin/varnishd/cache_panic.c index 168627e9..f1e533b2 100644 --- a/varnish-cache/bin/varnishd/cache_panic.c +++ b/varnish-cache/bin/varnishd/cache_panic.c @@ -64,15 +64,15 @@ pan_ws(const struct ws *ws, int indent) 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); @@ -258,7 +258,8 @@ pan_sess(const struct sess *sp) /*--------------------------------------------------------------------*/ 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; @@ -296,7 +297,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond, int err, 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"); @@ -307,7 +308,7 @@ pan_ic(const char *func, const char *file, int line, const char *cond, int err, memcpy(p, panicstr, l); if (params->diag_bitmap & 0x4000) (void)fputs(panicstr, stderr); - + #ifdef HAVE_ABORT2 if (params->diag_bitmap & 0x8000) { void *arg[1]; diff --git a/varnish-cache/bin/varnishd/cache_pipe.c b/varnish-cache/bin/varnishd/cache_pipe.c index 4cfc7a93..438c97e2 100644 --- a/varnish-cache/bin/varnishd/cache_pipe.c +++ b/varnish-cache/bin/varnishd/cache_pipe.c @@ -111,7 +111,7 @@ PipeSession(struct sess *sp) 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); diff --git a/varnish-cache/bin/varnishd/cache_pool.c b/varnish-cache/bin/varnishd/cache_pool.c index 8fdec518..54facbaa 100644 --- a/varnish-cache/bin/varnishd/cache_pool.c +++ b/varnish-cache/bin/varnishd/cache_pool.c @@ -79,7 +79,7 @@ VTAILQ_HEAD(workerhead, worker); struct wq { unsigned magic; #define WQ_MAGIC 0x606658fa - MTX mtx; + MTX mtx; struct workerhead idle; VTAILQ_HEAD(, workreq) overflow; unsigned nthr; @@ -456,7 +456,7 @@ wrk_decimate_flock(struct wq *qp, double t_idle, struct varnish_stats *vs) /*-------------------------------------------------------------------- * Periodic pool herding thread - * + * * Do things which we can do at our leisure: * Add pools * Scale constants diff --git a/varnish-cache/bin/varnishd/cache_vcl.c b/varnish-cache/bin/varnishd/cache_vcl.c index e73d636c..fd06e81e 100644 --- a/varnish-cache/bin/varnishd/cache_vcl.c +++ b/varnish-cache/bin/varnishd/cache_vcl.c @@ -208,8 +208,8 @@ VCL_Poll(void) 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); } @@ -323,7 +323,7 @@ VCL_##func##_method(struct sess *sp) \ \ 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; \ @@ -342,7 +342,7 @@ static struct cli_proto vcl_cmds[] = { { CLI_VCL_LIST, ccf_config_list }, { CLI_VCL_DISCARD, ccf_config_discard }, { CLI_VCL_USE, ccf_config_use }, - { NULL } + { NULL } }; void diff --git a/varnish-cache/bin/varnishd/cache_vrt.c b/varnish-cache/bin/varnishd/cache_vrt.c index dc08fb46..2101b1f6 100644 --- a/varnish-cache/bin/varnishd/cache_vrt.c +++ b/varnish-cache/bin/varnishd/cache_vrt.c @@ -136,7 +136,7 @@ vrt_assemble_string(struct http *hp, const char *h, const char *p, va_list ap) 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) { @@ -148,7 +148,7 @@ vrt_assemble_string(struct http *hp, const char *h, const char *p, va_list ap) 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); @@ -164,7 +164,8 @@ vrt_assemble_string(struct http *hp, const char *h, const char *p, va_list ap) /*--------------------------------------------------------------------*/ 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; @@ -190,7 +191,8 @@ VRT_SetHdr(const struct sess *sp , enum gethdr_e where, const char *hdr, const c /*--------------------------------------------------------------------*/ 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; @@ -512,7 +514,8 @@ VRT_r_server_port(struct sess *sp) 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)); } @@ -665,7 +668,7 @@ VRT_Rollback(struct sess *sp) *sp->http = *sp->http0; WS_Reset(sp->ws, sp->ws_req); } - + /*--------------------------------------------------------------------*/ /*lint -e{818} sp could be const */ @@ -718,7 +721,7 @@ VRT_synth_page(struct sess *sp, unsigned flags, const char *str, ...) void VRT_purge(const char *regexp, int hash) { - + if (regexp != NULL) (void)BAN_Add(NULL, regexp, hash); } diff --git a/varnish-cache/bin/varnishd/cache_vrt_esi.c b/varnish-cache/bin/varnishd/cache_vrt_esi.c index c4975546..eaa8d5b7 100644 --- a/varnish-cache/bin/varnishd/cache_vrt_esi.c +++ b/varnish-cache/bin/varnishd/cache_vrt_esi.c @@ -95,7 +95,7 @@ esi_error(const struct esi_work *ew, const char *p, int i, const char *err) char buf[256], *q; txt t; - if (i == 0) + if (i == 0) i = p - ew->t.b; if (i > 20) { i = 20; @@ -234,7 +234,7 @@ esi_attrib(const struct esi_work *ew, txt *in, txt *attrib, txt *val) /* Value, if any ? */ *val = *in; - if (in->b >= in->e) + if (in->b >= in->e) return (1); if (*in->b == '"') { @@ -287,7 +287,7 @@ esi_addinclude(struct esi_work *ew, txt t) 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"); @@ -351,7 +351,7 @@ esi_addinclude(struct esi_work *ew, txt t) /*-------------------------------------------------------------------- * 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. */ @@ -385,7 +385,7 @@ esi_parse2(struct esi_work *ew) if (!memcmp(p, "]]>", 3)) { ew->incdata = 0; p += 3; - } else + } else p++; } continue; @@ -464,7 +464,7 @@ esi_parse2(struct esi_work *ew) ew->incdata = 1; p += 9; continue; - } + } /* Ignore non esi elements, if so instructed */ if ((params->esi_syntax & 0x02)) { @@ -510,7 +510,7 @@ esi_parse2(struct esi_work *ew) 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); @@ -561,7 +561,7 @@ esi_parse2(struct esi_work *ew) continue; } if (r + 10 < q && !memcmp(r, "esi:include", 11)) { - + ew->o.e = p; esi_addverbatim(ew); @@ -723,7 +723,7 @@ VRT_ESI(struct sess *sp) 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 '<' */ @@ -755,7 +755,7 @@ VRT_ESI(struct sess *sp) ew->t = t; q = esi_parse(ew); assert(q == ew->t.e); /* XXX */ - + /* 'p' is cached starting point for next storage part */ } diff --git a/varnish-cache/bin/varnishd/cache_vrt_re.c b/varnish-cache/bin/varnishd/cache_vrt_re.c index 4f1d8cce..fcaef593 100644 --- a/varnish-cache/bin/varnishd/cache_vrt_re.c +++ b/varnish-cache/bin/varnishd/cache_vrt_re.c @@ -104,7 +104,8 @@ VRT_re_test(struct vsb *sb, const char *re, int sub) } 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; @@ -161,7 +162,7 @@ VRT_regsub(const struct sess *sp, int all, const char *str, void *re, const char if (res.b >= res.e) { WS_Release(sp->http->ws, 0); return (str); - } + } Tcheck(res); WS_ReleaseP(sp->http->ws, res.b); return (b0); diff --git a/varnish-cache/bin/varnishd/default.vcl b/varnish-cache/bin/varnishd/default.vcl index febfa8b0..13e15b20 100644 --- a/varnish-cache/bin/varnishd/default.vcl +++ b/varnish-cache/bin/varnishd/default.vcl @@ -16,23 +16,24 @@ * * 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. @@ -134,7 +135,9 @@ sub vcl_error {

"} obj.response {"

Guru Meditation:

XID: "} req.xid {"

-
Varnish
+
+ Varnish +
"}; diff --git a/varnish-cache/bin/varnishd/hash_classic.c b/varnish-cache/bin/varnishd/hash_classic.c index bd2841c1..eebba600 100644 --- a/varnish-cache/bin/varnishd/hash_classic.c +++ b/varnish-cache/bin/varnishd/hash_classic.c @@ -249,7 +249,7 @@ hcl_deref(const struct objhead *oh) /*--------------------------------------------------------------------*/ struct hash_slinger hcl_slinger = { - .magic = SLINGER_MAGIC, + .magic = SLINGER_MAGIC, .name = "classic", .init = hcl_init, .start = hcl_start, diff --git a/varnish-cache/bin/varnishd/hash_simple_list.c b/varnish-cache/bin/varnishd/hash_simple_list.c index a86ac910..b1a5c203 100644 --- a/varnish-cache/bin/varnishd/hash_simple_list.c +++ b/varnish-cache/bin/varnishd/hash_simple_list.c @@ -90,25 +90,23 @@ hsl_lookup(const struct sess *sp, struct objhead *nobj) 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); } @@ -143,5 +141,5 @@ struct hash_slinger hsl_slinger = { .name = "simple", .start = hsl_start, .lookup = hsl_lookup, - .deref = hsl_deref, + .deref = hsl_deref, }; diff --git a/varnish-cache/bin/varnishd/hash_slinger.h b/varnish-cache/bin/varnishd/hash_slinger.h index 16dec690..1131ae90 100644 --- a/varnish-cache/bin/varnishd/hash_slinger.h +++ b/varnish-cache/bin/varnishd/hash_slinger.h @@ -33,7 +33,8 @@ struct sess; 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 { diff --git a/varnish-cache/bin/varnishd/heritage.h b/varnish-cache/bin/varnishd/heritage.h index 9cf61337..14d482e3 100644 --- a/varnish-cache/bin/varnishd/heritage.h +++ b/varnish-cache/bin/varnishd/heritage.h @@ -77,7 +77,7 @@ struct params { /* TTL used for lack of anything better */ unsigned default_ttl; - + /* TTL used for synthesized error pages */ unsigned err_ttl; @@ -190,4 +190,5 @@ extern struct heritage heritage; 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); diff --git a/varnish-cache/bin/varnishd/mgt_child.c b/varnish-cache/bin/varnishd/mgt_child.c index 88aeb7a5..2ded8506 100644 --- a/varnish-cache/bin/varnishd/mgt_child.c +++ b/varnish-cache/bin/varnishd/mgt_child.c @@ -194,7 +194,7 @@ open_sockets(void) continue; } ls->sock = VSS_bind(ls->addr); - if (ls->sock < 0) + if (ls->sock < 0) continue; mgt_child_inherit(ls->sock, "sock"); @@ -269,7 +269,7 @@ start_child(struct cli *cli) 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)); @@ -548,7 +548,7 @@ mgt_run(int dflag, const char *T_arg) 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); diff --git a/varnish-cache/bin/varnishd/mgt_cli.c b/varnish-cache/bin/varnishd/mgt_cli.c index 9418a679..d4358861 100644 --- a/varnish-cache/bin/varnishd/mgt_cli.c +++ b/varnish-cache/bin/varnishd/mgt_cli.c @@ -66,8 +66,8 @@ static int cli_i = -1, cli_o = -1; struct telnet { - int fd; - struct vev *ev; + int fd; + struct vev *ev; VTAILQ_ENTRY(telnet) list; }; @@ -108,7 +108,7 @@ mcf_help(struct cli *cli, const char * const *av, void *priv) "help %s\n", av[2] != NULL ? av[2] : "")) { cli_out(cli, "%s", p); cli_result(cli, u); - } + } free(p); } } @@ -144,7 +144,7 @@ static struct cli_proto cli_proto[] = { { 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 }, diff --git a/varnish-cache/bin/varnishd/mgt_param.c b/varnish-cache/bin/varnishd/mgt_param.c index ddf9691d..02bee682 100644 --- a/varnish-cache/bin/varnishd/mgt_param.c +++ b/varnish-cache/bin/varnishd/mgt_param.c @@ -155,7 +155,8 @@ tweak_bool(struct cli *cli, const struct parspec *par, const char *arg) /*--------------------------------------------------------------------*/ 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; @@ -215,7 +216,7 @@ tweak_user(struct cli *cli, const struct parspec *par, const char *arg) master.uid = getuid(); return; } - } else + } else pw = getpwnam(arg); if (pw == NULL) { cli_out(cli, "Unknown user"); @@ -229,7 +230,7 @@ tweak_user(struct cli *cli, const struct parspec *par, const char *arg) /* 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); @@ -276,7 +277,8 @@ tweak_group(struct cli *cli, const struct parspec *par, const char *arg) /*--------------------------------------------------------------------*/ 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, @@ -286,7 +288,8 @@ tweak_thread_pool_min(struct cli *cli, const struct parspec *par, const char *ar /*--------------------------------------------------------------------*/ 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; @@ -310,7 +313,8 @@ clean_listen_sock_head(struct listen_sock_head *lsh) } 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; diff --git a/varnish-cache/bin/varnishd/mgt_vcc.c b/varnish-cache/bin/varnishd/mgt_vcc.c index c51afb1a..7ce416c6 100644 --- a/varnish-cache/bin/varnishd/mgt_vcc.c +++ b/varnish-cache/bin/varnishd/mgt_vcc.c @@ -65,7 +65,7 @@ struct vclprog { VTAILQ_ENTRY(vclprog) list; - char *name; + char *name; char *fname; int active; }; @@ -487,7 +487,7 @@ mcf_config_inline(struct cli *cli, const char * const *av, void *priv) cli_result(cli, CLIS_PARAM); return; } - + sb = vsb_newauto(); XXXAN(sb); vf = mgt_VccCompile(sb, av[3], NULL, 0); @@ -577,7 +577,7 @@ mcf_config_use(struct cli *cli, const char * const *av, void *priv) 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])) { diff --git a/varnish-cache/bin/varnishd/shmlog.c b/varnish-cache/bin/varnishd/shmlog.c index 47a99247..f5ce1222 100644 --- a/varnish-cache/bin/varnishd/shmlog.c +++ b/varnish-cache/bin/varnishd/shmlog.c @@ -86,7 +86,7 @@ vsl_hdr(enum shmlogtag tag, unsigned char *p, unsigned len, unsigned id) 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; } @@ -159,7 +159,7 @@ VSL(enum shmlogtag tag, int id, const char *fmt, ...) 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); @@ -254,7 +254,7 @@ WSL(struct worker *w, enum shmlogtag tag, int id, const char *fmt, ...) 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); diff --git a/varnish-cache/bin/varnishd/stevedore.c b/varnish-cache/bin/varnishd/stevedore.c index 2e206857..d3c4b3c3 100644 --- a/varnish-cache/bin/varnishd/stevedore.c +++ b/varnish-cache/bin/varnishd/stevedore.c @@ -105,7 +105,7 @@ STV_add(const struct stevedore *stv2, int ac, char * const *av) 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); diff --git a/varnish-cache/bin/varnishd/storage_file.c b/varnish-cache/bin/varnishd/storage_file.c index 33d3b9cb..a16b1de3 100644 --- a/varnish-cache/bin/varnishd/storage_file.c +++ b/varnish-cache/bin/varnishd/storage_file.c @@ -185,7 +185,7 @@ smf_calcsize(struct smf_sc *sc, const char *size, int newfile) i = 0; while(1) { o = l; - if (o == l && o > 0) + if (o == l && o > 0) break; l >>= 1; i++; @@ -303,7 +303,7 @@ smf_init(struct stevedore *parent, int ac, char * const *av) 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)); diff --git a/varnish-cache/bin/varnishd/storage_malloc.c b/varnish-cache/bin/varnishd/storage_malloc.c index 6cde5d43..3c4860fb 100644 --- a/varnish-cache/bin/varnishd/storage_malloc.c +++ b/varnish-cache/bin/varnishd/storage_malloc.c @@ -132,7 +132,7 @@ sma_init(struct stevedore *parent, int ac, char * const *av) (void)parent; AZ(av[ac]); - if (ac > 1) + if (ac > 1) ARGV_ERR("(-smalloc) too many arguments\n"); if (ac == 0 || *av[0] == '\0') @@ -141,7 +141,7 @@ sma_init(struct stevedore *parent, int ac, char * const *av) 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; } diff --git a/varnish-cache/bin/varnishd/storage_umem.c b/varnish-cache/bin/varnishd/storage_umem.c index e3bb8a16..e4d27b56 100644 --- a/varnish-cache/bin/varnishd/storage_umem.c +++ b/varnish-cache/bin/varnishd/storage_umem.c @@ -139,7 +139,7 @@ smu_init(struct stevedore *parent, int ac, char * const *av) (void)parent; AZ(av[ac]); - if (ac > 1) + if (ac > 1) ARGV_ERR("(-sumem) too many arguments\n"); if (ac == 0 || *av[0] == '\0') @@ -148,7 +148,7 @@ smu_init(struct stevedore *parent, int ac, char * const *av) 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; } diff --git a/varnish-cache/bin/varnishd/varnishd.c b/varnish-cache/bin/varnishd/varnishd.c index dd1f3bc1..fdce14fb 100644 --- a/varnish-cache/bin/varnishd/varnishd.c +++ b/varnish-cache/bin/varnishd/varnishd.c @@ -136,7 +136,7 @@ setup_storage(const char *spec) 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) @@ -175,7 +175,7 @@ setup_hash(const char *h_arg) 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) @@ -226,7 +226,8 @@ usage(void) fprintf(stderr, FMT, "", " -s file [default: use /tmp]"); fprintf(stderr, FMT, "", " -s file,"); fprintf(stderr, FMT, "", " -s file,,"); - fprintf(stderr, FMT, "", " -s file,,,"); + fprintf(stderr, FMT, "", + " -s file,,,"); fprintf(stderr, FMT, "-t", "Default TTL"); fprintf(stderr, FMT, "-T address:port", "Telnet listen address and port"); @@ -252,10 +253,10 @@ tackle_warg(const char *argv) 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]); @@ -462,7 +463,8 @@ main(int argc, char * const *argv) 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); @@ -580,7 +582,7 @@ main(int argc, char * const *argv) exit(1); } - if (n_arg != NULL) + if (n_arg != NULL) openlog(n_arg, LOG_PID, LOG_LOCAL0); else openlog("varnishd", LOG_PID, LOG_LOCAL0); @@ -624,7 +626,7 @@ main(int argc, char * const *argv) 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); diff --git a/varnish-cache/bin/varnishhist/varnishhist.c b/varnish-cache/bin/varnishhist/varnishhist.c index a84d581e..94036b36 100644 --- a/varnish-cache/bin/varnishhist/varnishhist.c +++ b/varnish-cache/bin/varnishhist/varnishhist.c @@ -147,7 +147,8 @@ update(void) } 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; @@ -308,8 +309,8 @@ do_curses(struct VSL_data *vd) 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); } diff --git a/varnish-cache/bin/varnishlog/varnishlog.c b/varnish-cache/bin/varnishlog/varnishlog.c index 215ea1ca..f7c6227a 100644 --- a/varnish-cache/bin/varnishlog/varnishlog.c +++ b/varnish-cache/bin/varnishlog/varnishlog.c @@ -120,7 +120,8 @@ clean_order(void) } 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; @@ -261,7 +262,7 @@ open_log(const char *w_arg, int a_flag) 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; @@ -308,8 +309,8 @@ do_write(struct VSL_data *vd, const char *w_arg, int a_flag) 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); } diff --git a/varnish-cache/bin/varnishncsa/varnishncsa.c b/varnish-cache/bin/varnishncsa/varnishncsa.c index 69b8df56..517adb0f 100644 --- a/varnish-cache/bin/varnishncsa/varnishncsa.c +++ b/varnish-cache/bin/varnishncsa/varnishncsa.c @@ -105,7 +105,8 @@ static size_t nll; 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 && @@ -511,7 +512,9 @@ static void 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); } diff --git a/varnish-cache/bin/varnishreplay/varnishreplay.c b/varnish-cache/bin/varnishreplay/varnishreplay.c index cc7bf835..1111eb39 100644 --- a/varnish-cache/bin/varnishreplay/varnishreplay.c +++ b/varnish-cache/bin/varnishreplay/varnishreplay.c @@ -251,7 +251,8 @@ thread_get(int fd, void *(*thread_main)(void *)) 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); @@ -557,12 +558,15 @@ replay_thread(void *arg) 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; } @@ -701,7 +705,8 @@ static void 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); } @@ -743,7 +748,11 @@ main(int argc, char *argv[]) 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) diff --git a/varnish-cache/bin/varnishstat/varnishstat.c b/varnish-cache/bin/varnishstat/varnishstat.c index 3e6151ca..f2477d48 100644 --- a/varnish-cache/bin/varnishstat/varnishstat.c +++ b/varnish-cache/bin/varnishstat/varnishstat.c @@ -81,9 +81,10 @@ show_field(const char* field, const char *fields) 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 ); } } @@ -237,14 +238,20 @@ static void 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); } @@ -252,7 +259,7 @@ usage(void) 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"); @@ -290,7 +297,8 @@ valid_fields(const char* fields) 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; } @@ -346,7 +354,7 @@ main(int argc, char **argv) if ((VSL_stats = VSL_OpenStats(n_arg)) == NULL) exit(1); - + if (fields != NULL && !valid_fields(fields)) { usage(); exit(1); diff --git a/varnish-cache/bin/varnishtest/vtc.c b/varnish-cache/bin/varnishtest/vtc.c index fb8b135c..7109a6b5 100644 --- a/varnish-cache/bin/varnishtest/vtc.c +++ b/varnish-cache/bin/varnishtest/vtc.c @@ -1,7 +1,7 @@ /* * 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: @@ -10,7 +10,7 @@ * 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 @@ -138,7 +138,8 @@ parse_string(char *buf, const struct cmds *cmd, void *priv, struct vtclog *vl) 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; } @@ -182,7 +183,7 @@ parse_string(char *buf, const struct cmds *cmd, void *priv, struct vtclog *vl) fprintf(stderr, "Unknown command: \"%s\"", token_s[0]); exit (1); } - + assert(cp->cmd != NULL); cp->cmd(token_s, priv, cmd, vl); } @@ -286,14 +287,14 @@ cmd_dump(CMD_ARGS) */ 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 @@ -325,7 +326,7 @@ usage(void) } /********************************************************************** - * Main + * Main */ int diff --git a/varnish-cache/bin/varnishtest/vtc.h b/varnish-cache/bin/varnishtest/vtc.h index 5ee4156f..5eb6a47c 100644 --- a/varnish-cache/bin/varnishtest/vtc.h +++ b/varnish-cache/bin/varnishtest/vtc.h @@ -1,7 +1,7 @@ /* * 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: @@ -10,7 +10,7 @@ * 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 @@ -22,7 +22,7 @@ * 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$ */ @@ -30,7 +30,9 @@ struct vsb; 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 { @@ -38,7 +40,8 @@ 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; @@ -60,4 +63,5 @@ void cmd_server_genvcl(struct vsb *vsb); 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); diff --git a/varnish-cache/bin/varnishtest/vtc_client.c b/varnish-cache/bin/varnishtest/vtc_client.c index 3f93984a..2668343c 100644 --- a/varnish-cache/bin/varnishtest/vtc_client.c +++ b/varnish-cache/bin/varnishtest/vtc_client.c @@ -1,7 +1,7 @@ /* * 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: @@ -10,7 +10,7 @@ * 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 @@ -50,7 +50,7 @@ struct client { VTAILQ_ENTRY(client) list; char *spec; - + char *connect; pthread_t tp; @@ -208,7 +208,7 @@ cmd_client(CMD_ARGS) VTAILQ_FOREACH(c, &clients, list) if (!strcmp(c->name, av[0])) break; - if (c == NULL) + if (c == NULL) c = client_new(av[0]); av++; diff --git a/varnish-cache/bin/varnishtest/vtc_http.c b/varnish-cache/bin/varnishtest/vtc_http.c index 67633579..74341739 100644 --- a/varnish-cache/bin/varnishtest/vtc_http.c +++ b/varnish-cache/bin/varnishtest/vtc_http.c @@ -1,7 +1,7 @@ /* * 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: @@ -10,7 +10,7 @@ * 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 @@ -75,8 +75,8 @@ synth_body(const char *len) { int i, j, k, l; char *b; - - + + AN(len); i = strtoul(len, NULL, 0); assert(i > 0); @@ -347,7 +347,7 @@ http_swallow_body(struct http *hp, char * const *hh, int body) { char *p, *q; int i, l, ll; - + ll = 0; p = http_find_header(hh, "content-length"); @@ -397,7 +397,7 @@ http_swallow_body(struct http *hp, char * const *hh, int body) ll += i; } while (i > 0); vtc_dump(hp->vl, 4, "rxeof", hp->body); - } + } sprintf(hp->bodylen, "%d", ll); } @@ -419,7 +419,7 @@ http_rxhdr(struct http *hp) 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--; @@ -456,7 +456,7 @@ cmd_http_rxresp(CMD_ARGS) 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); @@ -506,7 +506,7 @@ cmd_http_txresp(CMD_ARGS) if (!strcmp(*av, "-hdr")) { vsb_printf(hp->vsb, "%s%s", av[1], nl); av++; - } else + } else break; } for(; *av != NULL; av++) { @@ -525,7 +525,7 @@ cmd_http_txresp(CMD_ARGS) 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) { @@ -621,7 +621,7 @@ cmd_http_txreq(CMD_ARGS) 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) { diff --git a/varnish-cache/bin/varnishtest/vtc_log.c b/varnish-cache/bin/varnishtest/vtc_log.c index 506e6d88..b7f8dabe 100644 --- a/varnish-cache/bin/varnishtest/vtc_log.c +++ b/varnish-cache/bin/varnishtest/vtc_log.c @@ -1,7 +1,7 @@ /* * 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: @@ -10,7 +10,7 @@ * 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 @@ -56,7 +56,7 @@ vtc_logopen(const char *id) struct vtclog *vl; ALLOC_OBJ(vl, VTCLOG_MAGIC); - AN(vl); + AN(vl); vl->id = id; vl->vsb = vsb_newauto(); return (vl); @@ -125,7 +125,7 @@ vtc_dump(struct vtclog *vl, unsigned lvl, const char *pfx, const char *str) 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 diff --git a/varnish-cache/bin/varnishtest/vtc_sema.c b/varnish-cache/bin/varnishtest/vtc_sema.c index 959492d1..a5d70afa 100644 --- a/varnish-cache/bin/varnishtest/vtc_sema.c +++ b/varnish-cache/bin/varnishtest/vtc_sema.c @@ -1,7 +1,7 @@ /* * 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: @@ -10,7 +10,7 @@ * 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 @@ -141,7 +141,7 @@ cmd_sema(CMD_ARGS) 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++; diff --git a/varnish-cache/bin/varnishtest/vtc_server.c b/varnish-cache/bin/varnishtest/vtc_server.c index e01a04ba..0f128d97 100644 --- a/varnish-cache/bin/varnishtest/vtc_server.c +++ b/varnish-cache/bin/varnishtest/vtc_server.c @@ -1,7 +1,7 @@ /* * 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: @@ -10,7 +10,7 @@ * 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 @@ -54,7 +54,7 @@ struct server { unsigned repeat; char *spec; - + int depth; int sock; char *listen; @@ -233,7 +233,7 @@ cmd_server(CMD_ARGS) /* 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); } @@ -246,7 +246,7 @@ cmd_server(CMD_ARGS) VTAILQ_FOREACH(s, &servers, list) if (!strcmp(s->name, av[0])) break; - if (s == NULL) + if (s == NULL) s = server_new(av[0]); av++; diff --git a/varnish-cache/bin/varnishtest/vtc_varnish.c b/varnish-cache/bin/varnishtest/vtc_varnish.c index aa3a4c6f..c8ac4695 100644 --- a/varnish-cache/bin/varnishtest/vtc_varnish.c +++ b/varnish-cache/bin/varnishtest/vtc_varnish.c @@ -1,7 +1,7 @@ /* * 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: @@ -10,7 +10,7 @@ * 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 @@ -446,7 +446,7 @@ varnish_expect(const struct varnish *v, char * const *av) { 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 @@ -510,7 +510,7 @@ cmd_varnish(CMD_ARGS) VTAILQ_FOREACH(v, &varnishes, list) if (!strcmp(v->name, av[0])) break; - if (v == NULL) + if (v == NULL) v = varnish_new(av[0]); av++; diff --git a/varnish-cache/bin/varnishtop/varnishtop.c b/varnish-cache/bin/varnishtop/varnishtop.c index db69e529..fe10ed21 100644 --- a/varnish-cache/bin/varnishtop/varnishtop.c +++ b/varnish-cache/bin/varnishtop/varnishtop.c @@ -286,7 +286,8 @@ do_once(struct VSL_data *vd) 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); } diff --git a/varnish-cache/include/cli.h b/varnish-cache/include/cli.h index be3d7311..41b8d10e 100644 --- a/varnish-cache/include/cli.h +++ b/varnish-cache/include/cli.h @@ -57,7 +57,7 @@ "url.query", \ "url.query ", \ "\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 \ diff --git a/varnish-cache/include/http_headers.h b/varnish-cache/include/http_headers.h index e4b1f511..3f0a7d01 100644 --- a/varnish-cache/include/http_headers.h +++ b/varnish-cache/include/http_headers.h @@ -28,6 +28,8 @@ * * $Id$ * + * Argument list: + * --------------------------------------- * a Http header name * b session field name * c Request(1)/Response(2) bitfield @@ -38,8 +40,6 @@ * * see [RFC2616 13.5.1 End-to-end and Hop-by-hop Headers] * - * a b c d e f g - *-------------------------------------------------------------------- */ #ifndef HTTPH_R_PASS @@ -51,52 +51,51 @@ #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 */ diff --git a/varnish-cache/include/libvarnish.h b/varnish-cache/include/libvarnish.h index a7ddb470..277cc534 100644 --- a/varnish-cache/include/libvarnish.h +++ b/varnish-cache/include/libvarnish.h @@ -60,8 +60,10 @@ int TCP_filter_http(int sock); 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 @@ -88,7 +90,8 @@ int vtmpfile(char *); * 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; @@ -96,14 +99,14 @@ 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) @@ -114,7 +117,7 @@ do { \ #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) diff --git a/varnish-cache/include/stat_field.h b/varnish-cache/include/stat_field.h index 0ae47223..b0f496b1 100644 --- a/varnish-cache/include/stat_field.h +++ b/varnish-cache/include/stat_field.h @@ -37,7 +37,8 @@ MAC_STAT(cache_hitpass, uint64_t, 'a', "Cache hits for pass") 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") diff --git a/varnish-cache/include/varnishapi.h b/varnish-cache/include/varnishapi.h index e7c7f647..e6ef4e51 100644 --- a/varnish-cache/include/varnishapi.h +++ b/varnish-cache/include/varnishapi.h @@ -41,11 +41,13 @@ void base64_init(void); 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); @@ -60,6 +62,6 @@ const char *VSL_Name(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 diff --git a/varnish-cache/include/vcl.h b/varnish-cache/include/vcl.h index f80aed7d..71977b74 100644 --- a/varnish-cache/include/vcl.h +++ b/varnish-cache/include/vcl.h @@ -23,7 +23,7 @@ struct VCL_conf { unsigned nref; unsigned busy; unsigned discard; - + unsigned nsrc; const char **srcname; const char **srcbody; diff --git a/varnish-cache/include/vcl_returns.h b/varnish-cache/include/vcl_returns.h index 318f27b9..b93928a9 100644 --- a/varnish-cache/include/vcl_returns.h +++ b/varnish-cache/include/vcl_returns.h @@ -34,18 +34,30 @@ VCL_RET_MAC(restart, RESTART, (1 << 9), 9) #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) diff --git a/varnish-cache/include/vct.h b/varnish-cache/include/vct.h index 323c49dc..4eb321ad 100644 --- a/varnish-cache/include/vct.h +++ b/varnish-cache/include/vct.h @@ -31,10 +31,10 @@ /* 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) @@ -45,8 +45,8 @@ extern unsigned char vct_typtab[256]; 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) diff --git a/varnish-cache/include/vev.h b/varnish-cache/include/vev.h index 50e83d94..80bca51c 100644 --- a/varnish-cache/include/vev.h +++ b/varnish-cache/include/vev.h @@ -40,7 +40,7 @@ typedef int vev_cb_f(const struct vev *, int what); struct vev { unsigned magic; -#define VEV_MAGIC 0x46bbd419 +#define VEV_MAGIC 0x46bbd419 /* pub */ const char *name; diff --git a/varnish-cache/include/vqueue.h b/varnish-cache/include/vqueue.h index 89f1780f..729c94ce 100644 --- a/varnish-cache/include/vqueue.h +++ b/varnish-cache/include/vqueue.h @@ -220,7 +220,8 @@ struct { \ } 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) @@ -241,7 +242,8 @@ struct { \ (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) @@ -320,7 +322,8 @@ struct { \ #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) @@ -329,7 +332,7 @@ struct { \ #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) @@ -394,8 +397,9 @@ struct { \ } 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); \ @@ -438,7 +442,7 @@ struct { \ #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; \ diff --git a/varnish-cache/include/vrt.h b/varnish-cache/include/vrt.h index 2ea6550c..4d675eb9 100644 --- a/varnish-cache/include/vrt.h +++ b/varnish-cache/include/vrt.h @@ -70,7 +70,7 @@ struct vrt_backend { double connect_timeout; unsigned max_connections; - struct vrt_backend_probe probe; + struct vrt_backend_probe probe; }; /* @@ -92,9 +92,9 @@ struct vrt_dir_random_entry { }; struct vrt_dir_random { - const char *name; + const char *name; unsigned retries; - unsigned nmember; + unsigned nmember; const struct vrt_dir_random_entry *members; }; @@ -108,7 +108,7 @@ struct vrt_dir_round_robin_entry { struct vrt_dir_round_robin { const char *name; - unsigned nmember; + unsigned nmember; const struct vrt_dir_round_robin_entry *members; }; @@ -137,7 +137,8 @@ void VRT_re_init(void **, const char *, int sub); 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); @@ -149,7 +150,8 @@ int VRT_switch_config(const char *); 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 */ @@ -163,9 +165,12 @@ void VRT_Rollback(struct sess *sp); 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); diff --git a/varnish-cache/include/vsb.h b/varnish-cache/include/vsb.h index 64d0f8a0..797a2e42 100644 --- a/varnish-cache/include/vsb.h +++ b/varnish-cache/include/vsb.h @@ -65,9 +65,11 @@ int vsb_bcat(struct vsb *, const void *, size_t); 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 *); diff --git a/varnish-cache/lib/libvarnish/assert.c b/varnish-cache/lib/libvarnish/assert.c index bce3ddb4..4ec51079 100644 --- a/varnish-cache/lib/libvarnish/assert.c +++ b/varnish-cache/lib/libvarnish/assert.c @@ -41,7 +41,8 @@ #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) { diff --git a/varnish-cache/lib/libvarnish/binary_heap.c b/varnish-cache/lib/libvarnish/binary_heap.c index b0798a35..048e86a5 100644 --- a/varnish-cache/lib/libvarnish/binary_heap.c +++ b/varnish-cache/lib/libvarnish/binary_heap.c @@ -225,11 +225,9 @@ binheap_delete(struct binheap *bh, unsigned idx) #ifdef TEST_DRIVER /* Test driver -------------------------------------------------------*/ - #include #if 0 - static int cmp(void *priv, void *a, void *b) { @@ -295,11 +293,9 @@ main(int argc, char **argv) dump(bh, "Delete", u); } printf("Deletes done\n"); - return (0); } #else - struct foo { unsigned idx; unsigned key; @@ -310,7 +306,6 @@ struct foo { struct foo ff[N]; - static int cmp(void *priv, void *a, void *b) { @@ -359,12 +354,12 @@ main(int argc, char **argv) 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; diff --git a/varnish-cache/lib/libvarnish/cli_common.c b/varnish-cache/lib/libvarnish/cli_common.c index e0097ca1..30bf511d 100644 --- a/varnish-cache/lib/libvarnish/cli_common.c +++ b/varnish-cache/lib/libvarnish/cli_common.c @@ -132,7 +132,8 @@ cli_param(struct cli *cli) { 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 diff --git a/varnish-cache/lib/libvarnish/num.c b/varnish-cache/lib/libvarnish/num.c index 2c201d2a..489a9cd4 100644 --- a/varnish-cache/lib/libvarnish/num.c +++ b/varnish-cache/lib/libvarnish/num.c @@ -125,45 +125,45 @@ struct test_case { 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 */ diff --git a/varnish-cache/lib/libvarnish/tcp.c b/varnish-cache/lib/libvarnish/tcp.c index 159098d6..ecd18a59 100644 --- a/varnish-cache/lib/libvarnish/tcp.c +++ b/varnish-cache/lib/libvarnish/tcp.c @@ -58,7 +58,8 @@ /*--------------------------------------------------------------------*/ 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; @@ -119,7 +120,7 @@ TCP_filter_http(int sock) /*-------------------------------------------------------------------- * 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), diff --git a/varnish-cache/lib/libvarnish/vct.c b/varnish-cache/lib/libvarnish/vct.c index d0fc49d2..add5bce7 100644 --- a/varnish-cache/lib/libvarnish/vct.c +++ b/varnish-cache/lib/libvarnish/vct.c @@ -70,12 +70,12 @@ unsigned char vct_typtab[256] = { [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, @@ -86,13 +86,13 @@ unsigned char vct_typtab[256] = { [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, @@ -119,9 +119,9 @@ unsigned char vct_typtab[256] = { [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, @@ -148,7 +148,7 @@ unsigned char vct_typtab[256] = { [0x78] = VCT_LOALPHA, [0x79] = VCT_LOALPHA, [0x7a] = VCT_LOALPHA, - [0x7b] = VCT_SEPARATOR, - [0x7d] = VCT_SEPARATOR, + [0x7b] = VCT_SEPARATOR, + [0x7d] = VCT_SEPARATOR, [0x7f] = VCT_CTL, }; diff --git a/varnish-cache/lib/libvarnish/version.c b/varnish-cache/lib/libvarnish/version.c index 4a6631de..51911469 100644 --- a/varnish-cache/lib/libvarnish/version.c +++ b/varnish-cache/lib/libvarnish/version.c @@ -43,5 +43,6 @@ varnish_version(const char *progname) { 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"); } diff --git a/varnish-cache/lib/libvarnish/vlu.c b/varnish-cache/lib/libvarnish/vlu.c index 3f016ecd..10937947 100644 --- a/varnish-cache/lib/libvarnish/vlu.c +++ b/varnish-cache/lib/libvarnish/vlu.c @@ -63,7 +63,7 @@ VLU_New(void *priv, vlu_f *func, unsigned bufsize) if (l->buf == NULL) { FREE_OBJ(l); l = NULL; - } + } } return (l); } diff --git a/varnish-cache/lib/libvarnish/vss.c b/varnish-cache/lib/libvarnish/vss.c index f24190c8..274289f5 100644 --- a/varnish-cache/lib/libvarnish/vss.c +++ b/varnish-cache/lib/libvarnish/vss.c @@ -283,7 +283,7 @@ VSS_open(const char *str) if (retval >= 0) break; } - for (n = 0; n < nvaddr; n++) + for (n = 0; n < nvaddr; n++) free(vaddr[n]); free(vaddr); free(addr); diff --git a/varnish-cache/lib/libvarnishapi/instance.c b/varnish-cache/lib/libvarnishapi/instance.c index 1587f1a4..76df4408 100644 --- a/varnish-cache/lib/libvarnishapi/instance.c +++ b/varnish-cache/lib/libvarnishapi/instance.c @@ -39,8 +39,7 @@ 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; diff --git a/varnish-cache/lib/libvarnishapi/shmlog.c b/varnish-cache/lib/libvarnishapi/shmlog.c index f9399860..673aa64c 100644 --- a/varnish-cache/lib/libvarnishapi/shmlog.c +++ b/varnish-cache/lib/libvarnishapi/shmlog.c @@ -362,7 +362,8 @@ VSL_Dispatch(struct VSL_data *vd, vsl_handler *func, void *priv) /*--------------------------------------------------------------------*/ 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; diff --git a/varnish-cache/lib/libvcl/vcc_acl.c b/varnish-cache/lib/libvcl/vcc_acl.c index a3e43925..a440b5a0 100644 --- a/varnish-cache/lib/libvcl/vcc_acl.c +++ b/varnish-cache/lib/libvcl/vcc_acl.c @@ -52,7 +52,7 @@ 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; @@ -74,9 +74,9 @@ vcl_acl_cmp(struct tokenlist *tl, struct acl_e *ae1, struct acl_e *ae2) 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++; @@ -135,7 +135,8 @@ vcl_acl_add_entry(struct tokenlist *tl, struct acl_e *ae) } 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; @@ -186,7 +187,7 @@ vcc_acl_try_getaddrinfo(struct tokenlist *tl, struct acl_e *ae) 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", @@ -322,7 +323,8 @@ vcc_acl_entry(struct tokenlist *tl) } 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; @@ -346,7 +348,7 @@ vcc_acl_bot(const struct tokenlist *tl, const char *acln, int silent, const char 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", @@ -421,7 +423,7 @@ vcc_acl_bot(const struct tokenlist *tl, const char *acln, int silent, const char 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); @@ -439,7 +441,8 @@ vcc_Cond_Ip(const struct var *vp, struct tokenlist *tl) 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: diff --git a/varnish-cache/lib/libvcl/vcc_action.c b/varnish-cache/lib/libvcl/vcc_action.c index 00d29e27..3385e5d6 100644 --- a/varnish-cache/lib/libvcl/vcc_action.c +++ b/varnish-cache/lib/libvcl/vcc_action.c @@ -42,13 +42,13 @@ /*--------------------------------------------------------------------*/ -#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); \ } @@ -61,7 +61,7 @@ static void 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"); @@ -201,7 +201,8 @@ parse_set(struct tokenlist *tl) 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; } @@ -269,7 +270,7 @@ parse_set(struct tokenlist *tl) vcc_ExpectedStringval(tl); return; } - do + do Fb(tl, 0, ", "); while (vcc_StringVal(tl)); if (tl->t->tok != ';') { @@ -338,17 +339,17 @@ parse_purge_url(struct tokenlist *tl) { 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"); @@ -362,17 +363,17 @@ parse_purge_hash(struct tokenlist *tl) { 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"); @@ -392,13 +393,13 @@ static void 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"); @@ -410,13 +411,13 @@ static void 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"); @@ -432,21 +433,21 @@ static struct action_table { } 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 } }; diff --git a/varnish-cache/lib/libvcl/vcc_backend.c b/varnish-cache/lib/libvcl/vcc_backend.c index 0a8d2b90..c5edfc46 100644 --- a/varnish-cache/lib/libvcl/vcc_backend.c +++ b/varnish-cache/lib/libvcl/vcc_backend.c @@ -37,7 +37,7 @@ * 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 @@ -90,13 +90,14 @@ CheckHostPort(const char *host, const char *port) } /*-------------------------------------------------------------------- - * 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; @@ -118,7 +119,7 @@ Emit_Sockaddr(struct tokenlist *tl, const struct token *t_host, const char *port 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) @@ -155,12 +156,12 @@ Emit_Sockaddr(struct tokenlist *tl, const struct token *t_host, const char *port 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"); @@ -188,7 +189,9 @@ Emit_Sockaddr(struct tokenlist *tl, const struct token *t_host, const char *port */ 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); @@ -276,7 +279,7 @@ vcc_IsField(struct tokenlist *tl, struct token **t, struct fld_spec *fs) 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; @@ -315,7 +318,8 @@ vcc_FieldsOk(struct tokenlist *tl, const struct fld_spec *fs) */ 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 */ @@ -446,25 +450,14 @@ vcc_ParseProbe(struct tokenlist *tl) } /*-------------------------------------------------------------------- - * 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; @@ -627,7 +620,8 @@ vcc_ParseHostDef(struct tokenlist *tl, int *nbh, const struct token *name, const */ 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; @@ -674,7 +668,8 @@ vcc_ParseBackendHost(struct tokenlist *tl, int *nbh, const struct token *name, c */ 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; @@ -707,8 +702,8 @@ static const struct dirlist { const char *name; parsedirector_f *func; } dirlist[] = { - { "random", vcc_ParseRandomDirector }, - { "round-robin", vcc_ParseRoundRobinDirector }, + { "random", vcc_ParseRandomDirector }, + { "round-robin", vcc_ParseRoundRobinDirector }, { NULL, NULL } }; @@ -738,7 +733,7 @@ vcc_ParseDirector(struct tokenlist *tl) 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) { diff --git a/varnish-cache/lib/libvcl/vcc_compile.c b/varnish-cache/lib/libvcl/vcc_compile.c index d7a5e0ab..3ef118c0 100644 --- a/varnish-cache/lib/libvcl/vcc_compile.c +++ b/varnish-cache/lib/libvcl/vcc_compile.c @@ -700,6 +700,4 @@ VCC_InitCompile(const char *default_vcl) vcc_default_vcl_b = default_vcl; vcc_default_vcl_e = strchr(default_vcl, '\0'); assert(vcc_default_vcl_e != NULL); - - vcl_init_tnames(); } diff --git a/varnish-cache/lib/libvcl/vcc_compile.h b/varnish-cache/lib/libvcl/vcc_compile.h index 90008c42..78d3d6d8 100644 --- a/varnish-cache/lib/libvcl/vcc_compile.h +++ b/varnish-cache/lib/libvcl/vcc_compile.h @@ -158,10 +158,12 @@ void vcc_ParseAction(struct tokenlist *tl); /* 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); @@ -203,7 +205,8 @@ int vcc_StringVal(struct tokenlist *tl); 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); @@ -212,11 +215,14 @@ int vcc_IdIs(const struct token *t, const char *p); 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); diff --git a/varnish-cache/lib/libvcl/vcc_dir_random.c b/varnish-cache/lib/libvcl/vcc_dir_random.c index 29bb6dd5..37081d5c 100644 --- a/varnish-cache/lib/libvcl/vcc_dir_random.c +++ b/varnish-cache/lib/libvcl/vcc_dir_random.c @@ -50,7 +50,8 @@ */ 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; @@ -91,7 +92,7 @@ vcc_ParseRandomDirector(struct tokenlist *tl, const struct token *t_policy, cons ExpectErr(tl, '{'); vcc_NextToken(tl); Fc(tl, 0, "\t{"); - + while (tl->t->tok != '}') { /* Member fields */ vcc_IsField(tl, &t_field, mfs); ERRCHK(tl); diff --git a/varnish-cache/lib/libvcl/vcc_dir_round_robin.c b/varnish-cache/lib/libvcl/vcc_dir_round_robin.c index 512ce2ae..71c38b65 100644 --- a/varnish-cache/lib/libvcl/vcc_dir_round_robin.c +++ b/varnish-cache/lib/libvcl/vcc_dir_round_robin.c @@ -49,7 +49,8 @@ */ 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; @@ -58,9 +59,8 @@ vcc_ParseRoundRobinDirector(struct tokenlist *tl, const struct token *t_policy, 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 = ""; @@ -71,7 +71,7 @@ vcc_ParseRoundRobinDirector(struct tokenlist *tl, const struct token *t_policy, ExpectErr(tl, '{'); vcc_NextToken(tl); Fc(tl, 0, "\t{"); - + while (tl->t->tok != '}') { /* Member fields */ vcc_IsField(tl, &t_field, fs); ERRCHK(tl); @@ -103,8 +103,7 @@ vcc_ParseRoundRobinDirector(struct tokenlist *tl, const struct token *t_policy, 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)); } diff --git a/varnish-cache/lib/libvcl/vcc_fixed_token.c b/varnish-cache/lib/libvcl/vcc_fixed_token.c index b9db2b95..f2d05a16 100644 --- a/varnish-cache/lib/libvcl/vcc_fixed_token.c +++ b/varnish-cache/lib/libvcl/vcc_fixed_token.c @@ -13,209 +13,143 @@ #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) @@ -230,287 +164,185 @@ 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 \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 \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"); } diff --git a/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl b/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl index 2e69c874..bba59273 100755 --- a/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl +++ b/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl @@ -30,7 +30,7 @@ # 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 { @@ -66,7 +66,7 @@ set returns { # Language keywords # set keywords { - include + include if else elseif elsif } @@ -104,7 +104,8 @@ set extras {ID VAR CNUM CSTR EOI CSRC} 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 " *" @@ -135,7 +136,7 @@ puts $fo { unsigned magic; unsigned nref; unsigned busy; unsigned discard; - + unsigned nsrc; const char **srcname; const char **srcbody; @@ -160,12 +161,13 @@ warns $for 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 } @@ -184,7 +186,7 @@ foreach m $methods { 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]" } @@ -260,6 +262,9 @@ foreach t $fixed { 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 "{" @@ -279,25 +284,33 @@ foreach ch "$seq" { 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\])" @@ -307,8 +320,10 @@ foreach ch "$seq" { 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);" @@ -316,17 +331,14 @@ puts $fo " }" 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 @@ -335,10 +347,42 @@ puts $fo "}" 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 } @@ -349,7 +393,8 @@ puts $fo "vcl_output_lang_h(struct vsb *sb)" 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 } diff --git a/varnish-cache/lib/libvcl/vcc_gen_obj.tcl b/varnish-cache/lib/libvcl/vcc_gen_obj.tcl index 5d728e48..28e76c4e 100755 --- a/varnish-cache/lib/libvcl/vcc_gen_obj.tcl +++ b/varnish-cache/lib/libvcl/vcc_gen_obj.tcl @@ -261,15 +261,31 @@ warns $fp 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} { @@ -289,12 +305,12 @@ 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, \"," @@ -307,7 +323,7 @@ proc vars {v 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 { diff --git a/varnish-cache/lib/libvcl/vcc_obj.c b/varnish-cache/lib/libvcl/vcc_obj.c index a2d9ac8a..37f14364 100644 --- a/varnish-cache/lib/libvcl/vcc_obj.c +++ b/varnish-cache/lib/libvcl/vcc_obj.c @@ -12,235 +12,195 @@ 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 } }; diff --git a/varnish-cache/lib/libvcl/vcc_parse.c b/varnish-cache/lib/libvcl/vcc_parse.c index 648f775b..0cd36907 100644 --- a/varnish-cache/lib/libvcl/vcc_parse.c +++ b/varnish-cache/lib/libvcl/vcc_parse.c @@ -56,7 +56,7 @@ static void Cond_0(struct tokenlist *tl); #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) /*-------------------------------------------------------------------- @@ -614,7 +614,7 @@ vcc_Parse(struct tokenlist *tl) 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; diff --git a/varnish-cache/lib/libvcl/vcc_priv.h b/varnish-cache/lib/libvcl/vcc_priv.h index 91da4cfe..52ce2323 100644 --- a/varnish-cache/lib/libvcl/vcc_priv.h +++ b/varnish-cache/lib/libvcl/vcc_priv.h @@ -40,7 +40,6 @@ struct vsb; #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 diff --git a/varnish-cache/lib/libvcl/vcc_string.c b/varnish-cache/lib/libvcl/vcc_string.c index 0d9641f1..cd584f43 100644 --- a/varnish-cache/lib/libvcl/vcc_string.c +++ b/varnish-cache/lib/libvcl/vcc_string.c @@ -88,7 +88,7 @@ vcc_regsub(struct tokenlist *tl, int all) Expect(tl, ','); vcc_NextToken(tl); - + Expect(tl, CSTR); p = vcc_regexp(tl, 1); vcc_NextToken(tl); @@ -96,7 +96,7 @@ vcc_regsub(struct tokenlist *tl, int all) Expect(tl, ','); vcc_NextToken(tl); - + if (!vcc_StringVal(tl)) { vcc_ExpectedStringval(tl); return (0); @@ -119,7 +119,7 @@ vcc_regsub(struct tokenlist *tl, int all) */ int -vcc_StringVal(struct tokenlist *tl) +vcc_StringVal(struct tokenlist *tl) { struct var *vp; @@ -154,9 +154,8 @@ vcc_StringVal(struct tokenlist *tl) 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); } diff --git a/varnish-cache/lib/libvcl/vcc_token.c b/varnish-cache/lib/libvcl/vcc_token.c index d8960760..c0ac0f94 100644 --- a/varnish-cache/lib/libvcl/vcc_token.c +++ b/varnish-cache/lib/libvcl/vcc_token.c @@ -113,7 +113,7 @@ vcc_ErrWhere(struct tokenlist *tl, const struct token *t) 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++) { @@ -221,7 +221,7 @@ vcc_isCid(const struct token *t) assert(t->tok == ID); for (q = t->b; q < t->e; q++) { - if (!isalnum(*q) && *q != '_') + if (!isalnum(*q) && *q != '_') return (0); } return (1); @@ -394,7 +394,7 @@ vcc_Lexer(struct tokenlist *tl, struct source *sp) vcc_ErrWhere(tl, tl->t); return; } - + /* Recognize long-strings */ if (*p == '{' && p[1] == '"') { for (q = p + 2; q < sp->e; q++) { @@ -406,7 +406,7 @@ vcc_Lexer(struct tokenlist *tl, struct source *sp) 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); diff --git a/varnish-cache/lib/libvcl/vcc_xref.c b/varnish-cache/lib/libvcl/vcc_xref.c index 5e8145e7..51220a5b 100644 --- a/varnish-cache/lib/libvcl/vcc_xref.c +++ b/varnish-cache/lib/libvcl/vcc_xref.c @@ -340,13 +340,14 @@ vcc_FindIllegalUse(const struct proc *p, const struct method *m) 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; @@ -356,7 +357,7 @@ vcc_CheckUseRecurse(struct tokenlist *tl, const struct proc *p, struct method *m 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); -- 2.39.5