Skip to content

Instantly share code, notes, and snippets.

@rezan
Created November 9, 2016 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rezan/76f92f76d31ee2d2105501b63612db43 to your computer and use it in GitHub Desktop.
Save rezan/76f92f76d31ee2d2105501b63612db43 to your computer and use it in GitHub Desktop.
C code for m00026.vtc (scoped object support)
/* ---===### include/vdef.h ###===--- */
/*-
* Copyright (c) 2006 Verdens Gang AS
* Copyright (c) 2012 Fastly Inc
* Copyright (c) 2006-2015 Varnish Software AS
* All rights reserved.
*
* Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
* Author: Rogier 'DocWilco' Mulhuijzen <rogier@fastly.com>
*
* Inspired by FreeBSD's <sys/cdefs.h>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
* 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.
*
*/
#ifndef VDEF_H_INCLUDED
#define VDEF_H_INCLUDED
/* Safe printf into a fixed-size buffer */
#define bprintf(buf, fmt, ...) \
do { \
assert(snprintf(buf, sizeof buf, fmt, __VA_ARGS__) \
< sizeof buf); \
} while (0)
/* Safe printf into a fixed-size buffer */
#define vbprintf(buf, fmt, ap) \
do { \
assert(vsnprintf(buf, sizeof buf, fmt, ap) \
< sizeof buf); \
} while (0)
#ifndef __GNUC_PREREQ
# if defined __GNUC__ && defined __GNUC_MINOR__
# define __GNUC_PREREQ(maj, min) \
(__GNUC__ > (maj) || (__GNUC__ == (maj) && __GNUC_MINOR__ >= (min)))
# else
# define __GNUC_PREREQ(maj, min) 0
# endif
#endif
#ifdef __printflike
# define __v_printflike(f,a) __printflike(f,a)
#elif __GNUC_PREREQ(2, 95) || defined(__INTEL_COMPILER)
# define __v_printflike(f,a) __attribute__((format(printf, f, a)))
#else
# define __v_printflike(f,a)
#endif
/*********************************************************************
* Pointer alignment magic
*/
#if defined(__sparc__)
/* NB: Overbroad test for 32bit userland on 64bit SPARC cpus. */
# define PALGN (sizeof(double) - 1) /* size of alignment */
#else
# define PALGN (sizeof(void *) - 1) /* size of alignment */
#endif
#define PAOK(p) (((uintptr_t)(p) & PALGN) == 0) /* is aligned */
#define PRNDDN(p) ((uintptr_t)(p) & ~PALGN) /* Round down */
#define PRNDUP(p) (((uintptr_t)(p) + PALGN) & ~PALGN) /* Round up */
/*********************************************************************
* To be used as little as possible to wash off const/volatile etc.
*/
#define TRUST_ME(ptr) ((void*)(uintptr_t)(ptr))
/**********************************************************************
* Generic power-2 rounding macros
*/
#define PWR2(x) ((((x)-1UL)&(x))==0) /* Is a power of two */
#define RDN2(x, y) ((x)&(~((uintptr_t)(y)-1UL))) /* PWR2(y) true */
#define RUP2(x, y) (((x)+((y)-1))&(~((uintptr_t)(y)-1UL))) /* PWR2(y) true */
/**********************************************************************
* FlexeLint and compiler shutuppery
*/
/*
* In OO-light situations, functions have to match their prototype
* even if that means not const'ing a const'able argument.
* The typedef should be specified as argument to the macro.
*/
#define __match_proto__(xxx) /*lint -e{818} */
/*
* State variables may change value before we have considered the
* previous value
*/
#define __state_variable__(varname) varname /*lint -esym(838,varname) */
#define NEEDLESS_RETURN return
#endif /* VDEF_H_INCLUDED */
/* ---===### include/vcl.h ###===--- */
/*
* NB: This file is machine generated, DO NOT EDIT!
*
* Edit and run generate.py instead.
*/
struct vrt_ctx;
#define VRT_CTX const struct vrt_ctx *ctx
struct req;
struct busyobj;
struct ws;
struct cli;
struct worker;
enum vcl_event_e {
VCL_EVENT_LOAD,
VCL_EVENT_WARM,
VCL_EVENT_COLD,
VCL_EVENT_DISCARD,
};
typedef int vcl_event_f(VRT_CTX, enum vcl_event_e);
typedef int vcl_init_f(VRT_CTX);
typedef void vcl_fini_f(VRT_CTX);
typedef int vcl_func_f(VRT_CTX);
/* VCL Methods */
#define VCL_MET_RECV (1U << 1)
#define VCL_MET_PIPE (1U << 2)
#define VCL_MET_PASS (1U << 3)
#define VCL_MET_HASH (1U << 4)
#define VCL_MET_PURGE (1U << 5)
#define VCL_MET_MISS (1U << 6)
#define VCL_MET_HIT (1U << 7)
#define VCL_MET_DELIVER (1U << 8)
#define VCL_MET_SYNTH (1U << 9)
#define VCL_MET_BACKEND_FETCH (1U << 10)
#define VCL_MET_BACKEND_RESPONSE (1U << 11)
#define VCL_MET_BACKEND_ERROR (1U << 12)
#define VCL_MET_INIT (1U << 13)
#define VCL_MET_FINI (1U << 14)
#define VCL_MET_MAX 15
#define VCL_MET_MASK 0x7fff
/* VCL Returns */
#define VCL_RET_ABANDON 1
#define VCL_RET_DELIVER 2
#define VCL_RET_FAIL 3
#define VCL_RET_FETCH 4
#define VCL_RET_HASH 5
#define VCL_RET_LOOKUP 6
#define VCL_RET_MISS 7
#define VCL_RET_OK 8
#define VCL_RET_PASS 9
#define VCL_RET_PIPE 10
#define VCL_RET_PURGE 11
#define VCL_RET_RESTART 12
#define VCL_RET_RETRY 13
#define VCL_RET_SYNTH 14
#define VCL_RET_VCL 15
#define VCL_RET_MAX 16
struct VCL_conf {
unsigned magic;
#define VCL_CONF_MAGIC 0x7406c509 /* from /dev/random */
struct director **default_director;
const struct vrt_backend_probe *default_probe;
unsigned nref;
struct vrt_ref *ref;
unsigned nsrc;
const char **srcname;
const char **srcbody;
vcl_event_f *event_vcl;
vcl_func_f *recv_func;
vcl_func_f *pipe_func;
vcl_func_f *pass_func;
vcl_func_f *hash_func;
vcl_func_f *purge_func;
vcl_func_f *miss_func;
vcl_func_f *hit_func;
vcl_func_f *deliver_func;
vcl_func_f *synth_func;
vcl_func_f *backend_fetch_func;
vcl_func_f *backend_response_func;
vcl_func_f *backend_error_func;
vcl_func_f *init_func;
vcl_func_f *fini_func;
};
/* ---===### include/vrt.h ###===--- */
/*-
* Copyright (c) 2006 Verdens Gang AS
* Copyright (c) 2006-2015 Varnish Software AS
* All rights reserved.
*
* Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 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
* 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.
*
* Runtime support for compiled VCL programs and VMODs.
*
* NB: When this file is changed, lib/libvcc/generate.py *MUST* be rerun.
*/
/***********************************************************************
* Major and minor VRT API versions.
*
* Whenever something is added, increment MINOR version
* Whenever something is deleted or changed in a way which is not
* binary/load-time compatible, increment MAJOR version
*
*
* 5.0:
* Varnish 5.0 release "better safe than sorry" bump
* 4.0:
* VCL_BYTES changed to long long
* 3.2:
* vrt_backend grew .proxy_header field
* vrt_ctx grew .sp field.
*
* older version:
* Bump VRT_MINOR_VERSION due to:
* - VCL_ACL type added
* Bump VRT_MAJOR_VERSION due to:
* - VRT_CacheReqBody changed signature
*
*/
#define VRT_MAJOR_VERSION 5U
#define VRT_MINOR_VERSION 0U
/***********************************************************************/
struct VCL_conf;
struct vrt_acl;
struct busyobj;
struct director;
struct http;
struct req;
struct stevedore;
struct suckaddr;
struct vcl;
struct vmod;
struct vsb;
struct vsl_log;
struct ws;
/***********************************************************************
* This is the central definition of the mapping from VCL types to
* C-types. The python scripts read these from here.
* (alphabetic order)
*/
typedef const struct vrt_acl * VCL_ACL;
typedef const struct director * VCL_BACKEND;
typedef const struct vmod_priv * VCL_BLOB;
typedef const char * VCL_BODY;
typedef unsigned VCL_BOOL;
typedef long long VCL_BYTES;
typedef double VCL_DURATION;
typedef const char * VCL_ENUM;
typedef const struct gethdr_s * VCL_HEADER;
typedef struct http * VCL_HTTP;
typedef void VCL_INSTANCE;
typedef long VCL_INT;
typedef const struct suckaddr * VCL_IP;
typedef const struct vrt_backend_probe * VCL_PROBE;
typedef double VCL_REAL;
typedef const struct stevedore * VCL_STEVEDORE;
typedef const char * VCL_STRING;
typedef double VCL_TIME;
typedef struct vcl * VCL_VCL;
typedef void VCL_VOID;
/***********************************************************************
* This is the composite argument we pass to compiled VCL and VRT
* functions.
*/
struct vrt_ctx {
unsigned magic;
#define VRT_CTX_MAGIC 0x6bb8f0db
unsigned method;
unsigned *handling;
struct vsb *msg; // Only in ...init()
struct vsl_log *vsl;
struct vcl *vcl;
struct ws *ws;
struct sess *sp;
struct req *req;
struct http *http_req;
struct http *http_req_top;
struct http *http_resp;
struct busyobj *bo;
struct http *http_bereq;
struct http *http_beresp;
double now;
/*
* method specific argument:
* hash: struct SHA256Context
* synth+error: struct vsb *
*/
void *specific;
};
#define VRT_CTX const struct vrt_ctx *ctx
/***********************************************************************/
struct vmod_data {
/* The version/id fields must be first, they protect the rest */
unsigned vrt_major;
unsigned vrt_minor;
const char *file_id;
const char *name;
const void *func;
int func_len;
const char *proto;
const char * const *spec;
const char *abi;
};
/***********************************************************************/
enum gethdr_e { HDR_REQ, HDR_REQ_TOP, HDR_RESP, HDR_OBJ, HDR_BEREQ,
HDR_BERESP };
struct gethdr_s {
enum gethdr_e where;
const char *what;
};
extern const void * const vrt_magic_string_end;
extern const void * const vrt_magic_string_unset;
/***********************************************************************
* We want the VCC to spit this structs out as const, but when VMODs
* come up with them we want to clone them into malloc'ed space which
* we can free again.
* We collect all the knowledge here by macroizing the fields and make
* a macro for handling them all.
* See also: cache_backend.h & cache_backend_cfg.c
* One of those things...
*/
#define VRT_BACKEND_FIELDS(rigid) \
rigid char *vcl_name; \
rigid char *ipv4_addr; \
rigid char *ipv6_addr; \
rigid char *port; \
rigid char *hosthdr; \
double connect_timeout; \
double first_byte_timeout; \
double between_bytes_timeout; \
unsigned max_connections; \
unsigned proxy_header;
#define VRT_BACKEND_HANDLE() \
do { \
DA(vcl_name); \
DA(ipv4_addr); \
DA(ipv6_addr); \
DA(port); \
DA(hosthdr); \
DN(connect_timeout); \
DN(first_byte_timeout); \
DN(between_bytes_timeout); \
DN(max_connections); \
DN(proxy_header); \
} while(0)
struct vrt_backend {
unsigned magic;
#define VRT_BACKEND_MAGIC 0x4799ce6b
VRT_BACKEND_FIELDS(const)
const struct suckaddr *ipv4_suckaddr;
const struct suckaddr *ipv6_suckaddr;
const struct vrt_backend_probe *probe;
};
#define VRT_BACKEND_PROBE_FIELDS(rigid) \
double timeout; \
double interval; \
unsigned exp_status; \
unsigned window; \
unsigned threshold; \
unsigned initial;
#define VRT_BACKEND_PROBE_HANDLE() \
do { \
DN(timeout); \
DN(interval); \
DN(exp_status); \
DN(window); \
DN(threshold); \
DN(initial); \
} while (0)
struct vrt_backend_probe {
unsigned magic;
#define VRT_BACKEND_PROBE_MAGIC 0x84998490
const char *url;
const char *request;
VRT_BACKEND_PROBE_FIELDS(const)
};
/***********************************************************************/
/*
* other stuff.
* XXX: document when bored
*/
struct vrt_ref {
unsigned source;
unsigned offset;
unsigned line;
unsigned pos;
const char *token;
};
/* ACL related */
#define VRT_ACL_MAXADDR 16 /* max(IPv4, IPv6) */
typedef int acl_match_f(VRT_CTX, const VCL_IP);
struct vrt_acl {
unsigned magic;
#define VRT_ACL_MAGIC 0x78329d96
acl_match_f *match;
};
void VRT_acl_log(VRT_CTX, const char *msg);
int VRT_acl_match(VRT_CTX, VCL_ACL, VCL_IP);
/* req related */
VCL_BYTES VRT_CacheReqBody(VRT_CTX, VCL_BYTES maxsize);
/* Regexp related */
void VRT_re_init(void **, const char *);
void VRT_re_fini(void *);
int VRT_re_match(VRT_CTX, const char *, void *re);
const char *VRT_regsub(VRT_CTX, int all, const char *, void *, const char *);
void VRT_ban_string(VRT_CTX, const char *);
void VRT_purge(VRT_CTX, double ttl, double grace, double keep);
void VRT_count(VRT_CTX, unsigned);
void VRT_synth(VRT_CTX, unsigned, const char *);
void VRT_hit_for_pass(VRT_CTX, VCL_DURATION);
struct http *VRT_selecthttp(VRT_CTX, enum gethdr_e);
const char *VRT_GetHdr(VRT_CTX, const struct gethdr_s *);
void VRT_SetHdr(VRT_CTX, const struct gethdr_s *, const char *, ...);
void VRT_handling(VRT_CTX, unsigned hand);
void VRT_hashdata(VRT_CTX, const char *str, ...);
/* Simple stuff */
int VRT_strcmp(const char *s1, const char *s2);
void VRT_memmove(void *dst, const void *src, unsigned len);
void VRT_Rollback(VRT_CTX, const struct http *);
/* Synthetic pages */
void VRT_synth_page(VRT_CTX, const char *, ...);
/* Backend related */
struct director *VRT_new_backend(VRT_CTX, const struct vrt_backend *);
void VRT_delete_backend(VRT_CTX, struct director **);
/* Suckaddr related */
int VRT_VSA_GetPtr(const struct suckaddr *sua, const unsigned char ** dst);
/* VMOD/Modules related */
int VRT_Vmod_Init(struct vmod **hdl, void *ptr, int len, const char *nm,
const char *path, const char *file_id, VRT_CTX);
void VRT_Vmod_Fini(struct vmod **hdl);
/* VCL program related */
VCL_VCL VRT_vcl_lookup(const char *);
void VRT_vcl_select(VRT_CTX, VCL_VCL);
struct vmod_priv;
typedef void vmod_priv_free_f(void *);
struct vmod_priv {
void *priv;
int len;
vmod_priv_free_f *free;
};
#ifdef VCL_RET_MAX
typedef int vmod_event_f(VRT_CTX, struct vmod_priv *, enum vcl_event_e);
#endif
struct vclref;
struct vclref * VRT_ref_vcl(VRT_CTX, const char *);
void VRT_rel_vcl(VRT_CTX, struct vclref **);
void VRT_priv_fini(const struct vmod_priv *p);
struct vmod_priv *VRT_priv_task(VRT_CTX, void *vmod_id);
struct vmod_priv *VRT_priv_top(VRT_CTX, void *vmod_id);
void **VRT_priv_task_object(VRT_CTX, void *vmod_id, vmod_priv_free_f *free);
void **VRT_priv_top_object(VRT_CTX, void *vmod_id, vmod_priv_free_f *free);
/* Stevedore related functions */
int VRT_Stv(const char *nm);
VCL_STEVEDORE VRT_stevedore(const char *nm);
/* Convert things to string */
char *VRT_IP_string(VRT_CTX, VCL_IP);
char *VRT_INT_string(VRT_CTX, VCL_INT);
char *VRT_REAL_string(VRT_CTX, VCL_REAL);
char *VRT_TIME_string(VRT_CTX, VCL_TIME);
const char *VRT_BOOL_string(VCL_BOOL);
const char *VRT_BACKEND_string(VCL_BACKEND);
const char *VRT_STEVEDORE_string(VCL_STEVEDORE);
const char *VRT_CollectString(VRT_CTX, const char *p, ...);
/* ---===### include/vrt_obj.h ###===--- */
/*
* NB: This file is machine generated, DO NOT EDIT!
*
* Edit and run generate.py instead.
*/
VCL_HTTP VRT_r_bereq(VRT_CTX);
VCL_BACKEND VRT_r_bereq_backend(VRT_CTX);
void VRT_l_bereq_backend(VRT_CTX, VCL_BACKEND);
VCL_DURATION VRT_r_bereq_between_bytes_timeout(VRT_CTX);
void VRT_l_bereq_between_bytes_timeout(VRT_CTX, VCL_DURATION);
void VRT_l_bereq_body(VRT_CTX, const char *, ...);
VCL_DURATION VRT_r_bereq_connect_timeout(VRT_CTX);
void VRT_l_bereq_connect_timeout(VRT_CTX, VCL_DURATION);
VCL_DURATION VRT_r_bereq_first_byte_timeout(VRT_CTX);
void VRT_l_bereq_first_byte_timeout(VRT_CTX, VCL_DURATION);
VCL_STRING VRT_r_bereq_method(VRT_CTX);
void VRT_l_bereq_method(VRT_CTX, const char *, ...);
VCL_STRING VRT_r_bereq_proto(VRT_CTX);
void VRT_l_bereq_proto(VRT_CTX, const char *, ...);
VCL_INT VRT_r_bereq_retries(VRT_CTX);
VCL_BOOL VRT_r_bereq_uncacheable(VRT_CTX);
VCL_STRING VRT_r_bereq_url(VRT_CTX);
void VRT_l_bereq_url(VRT_CTX, const char *, ...);
VCL_STRING VRT_r_bereq_xid(VRT_CTX);
VCL_HTTP VRT_r_beresp(VRT_CTX);
VCL_DURATION VRT_r_beresp_age(VRT_CTX);
VCL_BACKEND VRT_r_beresp_backend(VRT_CTX);
VCL_IP VRT_r_beresp_backend_ip(VRT_CTX);
VCL_STRING VRT_r_beresp_backend_name(VRT_CTX);
void VRT_l_beresp_body(VRT_CTX, const char *, ...);
VCL_BOOL VRT_r_beresp_do_esi(VRT_CTX);
void VRT_l_beresp_do_esi(VRT_CTX, VCL_BOOL);
VCL_BOOL VRT_r_beresp_do_gunzip(VRT_CTX);
void VRT_l_beresp_do_gunzip(VRT_CTX, VCL_BOOL);
VCL_BOOL VRT_r_beresp_do_gzip(VRT_CTX);
void VRT_l_beresp_do_gzip(VRT_CTX, VCL_BOOL);
VCL_BOOL VRT_r_beresp_do_stream(VRT_CTX);
void VRT_l_beresp_do_stream(VRT_CTX, VCL_BOOL);
VCL_DURATION VRT_r_beresp_grace(VRT_CTX);
void VRT_l_beresp_grace(VRT_CTX, VCL_DURATION);
VCL_DURATION VRT_r_beresp_keep(VRT_CTX);
void VRT_l_beresp_keep(VRT_CTX, VCL_DURATION);
VCL_STRING VRT_r_beresp_proto(VRT_CTX);
void VRT_l_beresp_proto(VRT_CTX, const char *, ...);
VCL_STRING VRT_r_beresp_reason(VRT_CTX);
void VRT_l_beresp_reason(VRT_CTX, const char *, ...);
VCL_INT VRT_r_beresp_status(VRT_CTX);
void VRT_l_beresp_status(VRT_CTX, VCL_INT);
VCL_STEVEDORE VRT_r_beresp_storage(VRT_CTX);
void VRT_l_beresp_storage(VRT_CTX, VCL_STEVEDORE);
VCL_STRING VRT_r_beresp_storage_hint(VRT_CTX);
void VRT_l_beresp_storage_hint(VRT_CTX, const char *, ...);
VCL_DURATION VRT_r_beresp_ttl(VRT_CTX);
void VRT_l_beresp_ttl(VRT_CTX, VCL_DURATION);
VCL_BOOL VRT_r_beresp_uncacheable(VRT_CTX);
void VRT_l_beresp_uncacheable(VRT_CTX, VCL_BOOL);
VCL_BOOL VRT_r_beresp_was_304(VRT_CTX);
VCL_STRING VRT_r_client_identity(VRT_CTX);
void VRT_l_client_identity(VRT_CTX, const char *, ...);
VCL_IP VRT_r_client_ip(VRT_CTX);
VCL_IP VRT_r_local_ip(VRT_CTX);
VCL_TIME VRT_r_now(VRT_CTX);
VCL_DURATION VRT_r_obj_age(VRT_CTX);
VCL_DURATION VRT_r_obj_grace(VRT_CTX);
VCL_INT VRT_r_obj_hits(VRT_CTX);
VCL_DURATION VRT_r_obj_keep(VRT_CTX);
VCL_STRING VRT_r_obj_proto(VRT_CTX);
VCL_STRING VRT_r_obj_reason(VRT_CTX);
VCL_INT VRT_r_obj_status(VRT_CTX);
VCL_DURATION VRT_r_obj_ttl(VRT_CTX);
VCL_BOOL VRT_r_obj_uncacheable(VRT_CTX);
VCL_IP VRT_r_remote_ip(VRT_CTX);
VCL_HTTP VRT_r_req(VRT_CTX);
VCL_BACKEND VRT_r_req_backend_hint(VRT_CTX);
void VRT_l_req_backend_hint(VRT_CTX, VCL_BACKEND);
VCL_BOOL VRT_r_req_can_gzip(VRT_CTX);
VCL_BOOL VRT_r_req_esi(VRT_CTX);
void VRT_l_req_esi(VRT_CTX, VCL_BOOL);
VCL_INT VRT_r_req_esi_level(VRT_CTX);
VCL_BOOL VRT_r_req_hash_always_miss(VRT_CTX);
void VRT_l_req_hash_always_miss(VRT_CTX, VCL_BOOL);
VCL_BOOL VRT_r_req_hash_ignore_busy(VRT_CTX);
void VRT_l_req_hash_ignore_busy(VRT_CTX, VCL_BOOL);
VCL_STRING VRT_r_req_method(VRT_CTX);
void VRT_l_req_method(VRT_CTX, const char *, ...);
VCL_STRING VRT_r_req_proto(VRT_CTX);
void VRT_l_req_proto(VRT_CTX, const char *, ...);
VCL_INT VRT_r_req_restarts(VRT_CTX);
VCL_STEVEDORE VRT_r_req_storage(VRT_CTX);
void VRT_l_req_storage(VRT_CTX, VCL_STEVEDORE);
VCL_DURATION VRT_r_req_ttl(VRT_CTX);
void VRT_l_req_ttl(VRT_CTX, VCL_DURATION);
VCL_STRING VRT_r_req_url(VRT_CTX);
void VRT_l_req_url(VRT_CTX, const char *, ...);
VCL_STRING VRT_r_req_xid(VRT_CTX);
VCL_STRING VRT_r_req_top_method(VRT_CTX);
VCL_STRING VRT_r_req_top_proto(VRT_CTX);
VCL_STRING VRT_r_req_top_url(VRT_CTX);
VCL_HTTP VRT_r_resp(VRT_CTX);
void VRT_l_resp_body(VRT_CTX, const char *, ...);
VCL_BOOL VRT_r_resp_is_streaming(VRT_CTX);
VCL_STRING VRT_r_resp_proto(VRT_CTX);
void VRT_l_resp_proto(VRT_CTX, const char *, ...);
VCL_STRING VRT_r_resp_reason(VRT_CTX);
void VRT_l_resp_reason(VRT_CTX, const char *, ...);
VCL_INT VRT_r_resp_status(VRT_CTX);
void VRT_l_resp_status(VRT_CTX, VCL_INT);
VCL_STRING VRT_r_server_hostname(VRT_CTX);
VCL_STRING VRT_r_server_identity(VRT_CTX);
VCL_IP VRT_r_server_ip(VRT_CTX);
long long VRT_Stv_free_space(const char *);
long long VRT_Stv_used_space(const char *);
unsigned VRT_Stv_happy(const char *);
/* ---===### Source Code ###===---*/
#define VGC_NSRCS 2
static const char *srcname[VGC_NSRCS] = {
"m00026.vcl",
"Builtin",
};
static const char *srcbody[2] = {
/* "m00026.vcl"*/
"vcl 4.0;\n"
"\n"
"import debug from \"/home/reza/Code/varnish/open-source/varnish-PRs/lib/libvmod_debug/.libs/libvmod_debug.so\";\n"
"\n"
"backend default { .host = \"0.0.0.0\"; }\n"
"\n"
"sub vcl_init {\n"
"\tnew g0 = debug.obj(\"g0\");\n"
"}\n"
"\n"
"sub vcl_recv {\n"
"\tnew (req) r0 = debug.obj(\"r0\");\n"
"\tnew (req) r1 = debug.obj(req.http.r1);\n"
"\tnew (top) t0 = debug.obj(\"t0\");\n"
"}\n"
"\n"
"sub vcl_backend_response {\n"
"\tnew (bereq) b0 = debug.obj(\"b0\");\n"
"\tset beresp.http.b0 = b0.string();\n"
"}\n"
"\n"
"sub vcl_deliver {\n"
"\tset resp.http.g0 = g0.string();\n"
"\tset resp.http.r0 = r0.string();\n"
"\tset resp.http.r1 = r1.string();\n"
"\tset resp.http.t0 = t0.string();\n"
"}\n"
"",
/* "Builtin"*/
"/*-\n"
" * Copyright (c) 2006 Verdens Gang AS\n"
" * Copyright (c) 2006-2015 Varnish Software AS\n"
" * All rights reserved.\n"
" *\n"
" * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>\n"
" *\n"
" * Redistribution and use in source and binary forms, with or without\n"
" * modification, are permitted provided that the following conditions\n"
" * are met:\n"
" * 1. Redistributions of source code must retain the above copyright\n"
" * notice, this list of conditions and the following disclaimer.\n"
" * 2. Redistributions in binary form must reproduce the above copyright\n"
" * notice, this list of conditions and the following disclaimer in the\n"
" * documentation and/or other materials provided with the distribution.\n"
" *\n"
" * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND\n"
" * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n"
" * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n"
" * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE\n"
" * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL\n"
" * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS\n"
" * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\n"
" * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT\n"
" * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY\n"
" * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF\n"
" * SUCH DAMAGE.\n"
" *\n"
"\n"
" *\n"
" * The built-in (previously called default) VCL code.\n"
" *\n"
" * NB! You do NOT need to copy & paste all of these functions into your\n"
" * own vcl code, if you do not provide a definition of one of these\n"
" * functions, the compiler will automatically fall back to the default\n"
" * code from this file.\n"
" *\n"
" * This code will be prefixed with a backend declaration built from the\n"
" * -b argument.\n"
" */\n"
"\n"
"vcl 4.0;\n"
"\n"
"#######################################################################\n"
"# Client side\n"
"\n"
"sub vcl_recv {\n"
" if (req.method == \"PRI\") {\n"
"\t/* We do not support SPDY or HTTP/2.0 */\n"
"\treturn (synth(405));\n"
" }\n"
" if (req.method != \"GET\" &&\n"
" req.method != \"HEAD\" &&\n"
" req.method != \"PUT\" &&\n"
" req.method != \"POST\" &&\n"
" req.method != \"TRACE\" &&\n"
" req.method != \"OPTIONS\" &&\n"
" req.method != \"DELETE\" &&\n"
" req.method != \"PATCH\") {\n"
" /* Non-RFC2616 or CONNECT which is weird. */\n"
" return (pipe);\n"
" }\n"
"\n"
" if (req.method != \"GET\" && req.method != \"HEAD\") {\n"
" /* We only deal with GET and HEAD by default */\n"
" return (pass);\n"
" }\n"
" if (req.http.Authorization || req.http.Cookie) {\n"
" /* Not cacheable by default */\n"
" return (pass);\n"
" }\n"
" return (hash);\n"
"}\n"
"\n"
"sub vcl_pipe {\n"
" # By default Connection: close is set on all piped requests, to stop\n"
" # connection reuse from sending future requests directly to the\n"
" # (potentially) wrong backend. If you do want this to happen, you can undo\n"
" # it here.\n"
" # unset bereq.http.connection;\n"
" return (pipe);\n"
"}\n"
"\n"
"sub vcl_pass {\n"
" return (fetch);\n"
"}\n"
"\n"
"sub vcl_hash {\n"
" hash_data(req.url);\n"
" if (req.http.host) {\n"
" hash_data(req.http.host);\n"
" } else {\n"
" hash_data(server.ip);\n"
" }\n"
" return (lookup);\n"
"}\n"
"\n"
"sub vcl_purge {\n"
" return (synth(200, \"Purged\"));\n"
"}\n"
"\n"
"sub vcl_hit {\n"
" if (obj.ttl >= 0s) {\n"
" // A pure unadultered hit, deliver it\n"
" return (deliver);\n"
" }\n"
" if (obj.ttl + obj.grace > 0s) {\n"
" // Object is in grace, deliver it\n"
" // Automatically triggers a background fetch\n"
" return (deliver);\n"
" }\n"
" // fetch & deliver once we get the result\n"
" return (miss);\n"
"}\n"
"\n"
"sub vcl_miss {\n"
" return (fetch);\n"
"}\n"
"\n"
"sub vcl_deliver {\n"
" return (deliver);\n"
"}\n"
"\n"
"/*\n"
" * We can come here \"invisibly\" with the following errors: 500 & 503\n"
" */\n"
"sub vcl_synth {\n"
" set resp.http.Content-Type = \"text/html; charset=utf-8\";\n"
" set resp.http.Retry-After = \"5\";\n"
" set resp.body = {\"<!DOCTYPE html>\n"
"<html>\n"
" <head>\n"
" <title>\"} + resp.status + \" \" + resp.reason + {\"</title>\n"
" </head>\n"
" <body>\n"
" <h1>Error \"} + resp.status + \" \" + resp.reason + {\"</h1>\n"
" <p>\"} + resp.reason + {\"</p>\n"
" <h3>Guru Meditation:</h3>\n"
" <p>XID: \"} + req.xid + {\"</p>\n"
" <hr>\n"
" <p>Varnish cache server</p>\n"
" </body>\n"
"</html>\n"
"\"};\n"
" return (deliver);\n"
"}\n"
"\n"
"#######################################################################\n"
"# Backend Fetch\n"
"\n"
"sub vcl_backend_fetch {\n"
" if (bereq.method == \"GET\") {\n"
" unset bereq.body;\n"
" }\n"
" return (fetch);\n"
"}\n"
"\n"
"sub vcl_backend_response {\n"
" if (bereq.uncacheable) {\n"
" return (deliver);\n"
" } else if (beresp.ttl <= 0s ||\n"
" beresp.http.Set-Cookie ||\n"
" beresp.http.Surrogate-control ~ \"no-store\" ||\n"
" (!beresp.http.Surrogate-Control &&\n"
" beresp.http.Cache-Control ~ \"no-cache|no-store|private\") ||\n"
" beresp.http.Vary == \"*\") {\n"
" # Mark as \"Hit-For-Pass\" for the next 2 minutes\n"
" set beresp.ttl = 120s;\n"
" set beresp.uncacheable = true;\n"
" }\n"
" return (deliver);\n"
"}\n"
"\n"
"sub vcl_backend_error {\n"
" set beresp.http.Content-Type = \"text/html; charset=utf-8\";\n"
" set beresp.http.Retry-After = \"5\";\n"
" set beresp.body = {\"<!DOCTYPE html>\n"
"<html>\n"
" <head>\n"
" <title>\"} + beresp.status + \" \" + beresp.reason + {\"</title>\n"
" </head>\n"
" <body>\n"
" <h1>Error \"} + beresp.status + \" \" + beresp.reason + {\"</h1>\n"
" <p>\"} + beresp.reason + {\"</p>\n"
" <h3>Guru Meditation:</h3>\n"
" <p>XID: \"} + bereq.xid + {\"</p>\n"
" <hr>\n"
" <p>Varnish cache server</p>\n"
" </body>\n"
"</html>\n"
"\"};\n"
" return (deliver);\n"
"}\n"
"\n"
"#######################################################################\n"
"# Housekeeping\n"
"\n"
"sub vcl_init {\n"
"}\n"
"\n"
"sub vcl_fini {\n"
" return (ok);\n"
"}\n"
"",
};
/* ---===### Location Counters ###===---*/
#define VGC_NREFS 38
static struct vrt_ref VGC_ref[VGC_NREFS] = {
[ 1] = { 0, 177, 8, 9, "new" },
[ 2] = { 0, 222, 12, 9, "new" },
[ 3] = { 0, 358, 18, 9, "new" },
[ 4] = { 0, 449, 23, 9, "set" },
[ 5] = { 1, 1960, 48, 5, "if" },
[ 6] = { 1, 2030, 50, 9, "return" },
[ 7] = { 1, 2061, 52, 5, "if" },
[ 8] = { 1, 2365, 61, 9, "return" },
[ 9] = { 1, 2391, 64, 5, "if" },
[ 10] = { 1, 2506, 66, 9, "return" },
[ 11] = { 1, 2531, 68, 5, "if" },
[ 12] = { 1, 2627, 70, 9, "return" },
[ 13] = { 1, 2652, 72, 5, "return" },
[ 14] = { 1, 2959, 81, 5, "return" },
[ 15] = { 1, 2996, 85, 5, "return" },
[ 16] = { 1, 3034, 89, 5, "hash_data" },
[ 17] = { 1, 3087, 91, 9, "hash_data" },
[ 18] = { 1, 3134, 93, 9, "hash_data" },
[ 19] = { 1, 3206, 99, 5, "return" },
[ 20] = { 1, 3258, 103, 5, "if" },
[ 21] = { 1, 3333, 105, 9, "return" },
[ 22] = { 1, 3361, 107, 5, "if" },
[ 23] = { 1, 3496, 110, 9, "return" },
[ 24] = { 1, 3570, 113, 5, "return" },
[ 25] = { 1, 3607, 117, 5, "return" },
[ 26] = { 1, 3648, 121, 5, "return" },
[ 27] = { 1, 3765, 128, 5, "set" },
[ 28] = { 1, 4356, 152, 5, "if" },
[ 29] = { 1, 4393, 153, 9, "unset" },
[ 30] = { 1, 4421, 155, 5, "return" },
[ 31] = { 1, 4471, 159, 5, "if" },
[ 32] = { 1, 4504, 160, 9, "return" },
[ 33] = { 1, 4847, 168, 9, "set" },
[ 34] = { 1, 4919, 171, 5, "return" },
[ 35] = { 1, 4968, 175, 5, "set" },
[ 36] = { 1, 5563, 199, 1, "}" },
[ 37] = { 1, 5585, 202, 5, "return" },
};
/* ---===### VCC generated .h code ###===---*/
extern const struct VCL_conf VCL_conf;
/* --- BEGIN VMOD debug --- */
static struct vmod *VGC_vmod_debug;
static struct vmod_priv vmod_priv_debug;
struct vmod_debug_obj;
typedef VCL_VOID td_debug_obj__init(VRT_CTX,
struct vmod_debug_obj **, const char *, VCL_STRING, VCL_ENUM);
typedef VCL_VOID td_debug_obj__fini(struct vmod_debug_obj **);
typedef VCL_VOID td_debug_obj_enum(VRT_CTX,
struct vmod_debug_obj *, VCL_ENUM);
typedef VCL_STRING td_debug_obj_string(VRT_CTX,
struct vmod_debug_obj *);
typedef VCL_STRING td_debug_obj_number(VRT_CTX,
struct vmod_debug_obj *);
typedef VCL_STRING td_debug_obj_foo(VRT_CTX,
struct vmod_debug_obj *, VCL_STRING);
typedef VCL_TIME td_debug_obj_date(VRT_CTX,
struct vmod_debug_obj *);
typedef VCL_VOID td_debug_obj_test_priv_call(VRT_CTX,
struct vmod_debug_obj *, struct vmod_priv *);
typedef VCL_VOID td_debug_obj_test_priv_vcl(VRT_CTX,
struct vmod_debug_obj *, struct vmod_priv *);
typedef VCL_STRING td_debug_obj_test_priv_task(VRT_CTX,
struct vmod_debug_obj *, struct vmod_priv *, VCL_STRING);
typedef VCL_STRING td_debug_obj_test_priv_top(VRT_CTX,
struct vmod_debug_obj *, struct vmod_priv *, VCL_STRING);
struct vmod_debug_dyn;
typedef VCL_VOID td_debug_dyn__init(VRT_CTX,
struct vmod_debug_dyn **, const char *, VCL_STRING, VCL_STRING);
typedef VCL_VOID td_debug_dyn__fini(struct vmod_debug_dyn **);
typedef VCL_BACKEND td_debug_dyn_backend(VRT_CTX,
struct vmod_debug_dyn *);
typedef VCL_VOID td_debug_dyn_refresh(VRT_CTX,
struct vmod_debug_dyn *, VCL_STRING, VCL_STRING);
/* Functions */
typedef VCL_VOID td_debug_panic(VRT_CTX, const char *, ...);
typedef VCL_STRING td_debug_author(VRT_CTX, VCL_ENUM);
typedef VCL_VOID td_debug_test_priv_call(VRT_CTX,
struct vmod_priv *);
typedef VCL_VOID td_debug_test_priv_vcl(VRT_CTX,
struct vmod_priv *);
typedef VCL_STRING td_debug_test_priv_task(VRT_CTX,
struct vmod_priv *, VCL_STRING);
typedef VCL_STRING td_debug_test_priv_top(VRT_CTX,
struct vmod_priv *, VCL_STRING);
typedef VCL_BLOB td_debug_str2blob(VRT_CTX, VCL_STRING);
typedef VCL_STRING td_debug_blob2hex(VRT_CTX, VCL_BLOB);
typedef VCL_BACKEND td_debug_no_backend(VRT_CTX);
typedef VCL_STEVEDORE td_debug_no_stevedore(VRT_CTX);
typedef VCL_VOID td_debug_rot52(VRT_CTX, VCL_HTTP);
typedef VCL_STRING td_debug_argtest(VRT_CTX, VCL_STRING,
VCL_REAL, VCL_STRING, VCL_STRING, VCL_INT);
typedef VCL_INT td_debug_vre_limit(VRT_CTX);
typedef VCL_VOID td_debug_register_obj_events(VRT_CTX,
struct vmod_priv *);
typedef VCL_VOID td_debug_init_fail(VRT_CTX);
typedef VCL_VOID td_debug_sleep(VRT_CTX, VCL_DURATION);
typedef VCL_VOID td_debug_workspace_allocate(VRT_CTX, VCL_ENUM,
VCL_INT);
typedef VCL_BOOL td_debug_workspace_overflowed(VRT_CTX,
VCL_ENUM);
typedef VCL_VOID td_debug_workspace_overflow(VRT_CTX, VCL_ENUM);
typedef VCL_INT td_debug_workspace_free(VRT_CTX, VCL_ENUM);
typedef VCL_VOID td_debug_workspace_snap(VRT_CTX, VCL_ENUM);
typedef VCL_VOID td_debug_workspace_reset(VRT_CTX, VCL_ENUM);
typedef VCL_VOID td_debug_vcl_release_delay(VRT_CTX,
VCL_DURATION);
typedef VCL_BOOL td_debug_match_acl(VRT_CTX, VCL_ACL, VCL_IP);
typedef VCL_BOOL td_debug_barrier_sync(VRT_CTX, VCL_STRING);
typedef VCL_VOID td_debug_test_probe(VRT_CTX, VCL_PROBE,
VCL_PROBE);
struct Vmod_debug_Func {
vmod_event_f *_event;
td_debug_panic *panic;
td_debug_author *author;
td_debug_test_priv_call *test_priv_call;
td_debug_test_priv_vcl *test_priv_vcl;
td_debug_test_priv_task *test_priv_task;
td_debug_test_priv_top *test_priv_top;
td_debug_str2blob *str2blob;
td_debug_blob2hex *blob2hex;
td_debug_no_backend *no_backend;
td_debug_no_stevedore *no_stevedore;
td_debug_obj__init *obj__init;
td_debug_obj__fini *obj__fini;
td_debug_obj_enum *obj_enum;
td_debug_obj_string *obj_string;
td_debug_obj_number *obj_number;
td_debug_obj_foo *obj_foo;
td_debug_obj_date *obj_date;
td_debug_obj_test_priv_call *obj_test_priv_call;
td_debug_obj_test_priv_vcl *obj_test_priv_vcl;
td_debug_obj_test_priv_task *obj_test_priv_task;
td_debug_obj_test_priv_top *obj_test_priv_top;
td_debug_rot52 *rot52;
td_debug_argtest *argtest;
td_debug_vre_limit *vre_limit;
td_debug_register_obj_events *register_obj_events;
td_debug_init_fail *init_fail;
td_debug_sleep *sleep;
td_debug_dyn__init *dyn__init;
td_debug_dyn__fini *dyn__fini;
td_debug_dyn_backend *dyn_backend;
td_debug_dyn_refresh *dyn_refresh;
td_debug_workspace_allocate *workspace_allocate;
td_debug_workspace_overflowed *workspace_overflowed;
td_debug_workspace_overflow *workspace_overflow;
td_debug_workspace_free *workspace_free;
td_debug_workspace_snap *workspace_snap;
td_debug_workspace_reset *workspace_reset;
td_debug_vcl_release_delay *vcl_release_delay;
td_debug_match_acl *match_acl;
td_debug_barrier_sync *barrier_sync;
td_debug_test_probe *test_probe;
};
static struct Vmod_debug_Func Vmod_debug_Func;
/* --- END VMOD debug --- */
static struct director *vgc_backend_default;
/* "0.0.0.0" -> 0.0.0.0 */
static const unsigned long long suckaddr_0[4] = {
0x500000024b1e9335ULL,
0x0000000000000000ULL,
0x0000000000000000ULL,
0x0000000000000000ULL
};
static const struct vrt_backend vgc_dir_priv_vgc_backend_default = {
.magic = VRT_BACKEND_MAGIC,
.vcl_name = "default",
.ipv4_suckaddr = (const struct suckaddr *)(const void*)suckaddr_0,
.ipv4_addr = "0.0.0.0",
.port = "80",
.hosthdr = "0.0.0.0",
};
static struct vmod_debug_obj *vo_g0;
static struct vmod_debug_obj *vo_r0;
void vo_free_r0(void *);
static struct vmod_debug_obj *vo_r1;
void vo_free_r1(void *);
static const struct gethdr_s VGC_HDR_REQ_r1 =
{ HDR_REQ, "\003r1:"};
static struct vmod_debug_obj *vo_t0;
void vo_free_t0(void *);
static struct vmod_debug_obj *vo_b0;
void vo_free_b0(void *);
static const struct gethdr_s VGC_HDR_BERESP_b0 =
{ HDR_BERESP, "\003b0:"};
static const struct gethdr_s VGC_HDR_RESP_g0 =
{ HDR_RESP, "\003g0:"};
static const struct gethdr_s VGC_HDR_RESP_r0 =
{ HDR_RESP, "\003r0:"};
static const struct gethdr_s VGC_HDR_RESP_r1 =
{ HDR_RESP, "\003r1:"};
static const struct gethdr_s VGC_HDR_RESP_t0 =
{ HDR_RESP, "\003t0:"};
static const struct gethdr_s VGC_HDR_REQ_Authorization =
{ HDR_REQ, "\016Authorization:"};
static const struct gethdr_s VGC_HDR_REQ_Cookie =
{ HDR_REQ, "\007Cookie:"};
static const struct gethdr_s VGC_HDR_REQ_host =
{ HDR_REQ, "\005host:"};
static const struct gethdr_s VGC_HDR_RESP_Content_2d_Type =
{ HDR_RESP, "\015Content-Type:"};
static const struct gethdr_s VGC_HDR_RESP_Retry_2d_After =
{ HDR_RESP, "\014Retry-After:"};
static const struct gethdr_s VGC_HDR_BERESP_Set_2d_Cookie =
{ HDR_BERESP, "\013Set-Cookie:"};
static const struct gethdr_s VGC_HDR_BERESP_Surrogate_2d_control =
{ HDR_BERESP, "\022Surrogate-control:"};
static void *VGC_re_1;
static const struct gethdr_s VGC_HDR_BERESP_Surrogate_2d_Control =
{ HDR_BERESP, "\022Surrogate-Control:"};
static const struct gethdr_s VGC_HDR_BERESP_Cache_2d_Control =
{ HDR_BERESP, "\016Cache-Control:"};
static void *VGC_re_2;
static const struct gethdr_s VGC_HDR_BERESP_Vary =
{ HDR_BERESP, "\005Vary:"};
static const struct gethdr_s VGC_HDR_BERESP_Content_2d_Type =
{ HDR_BERESP, "\015Content-Type:"};
static const struct gethdr_s VGC_HDR_BERESP_Retry_2d_After =
{ HDR_BERESP, "\014Retry-After:"};
int __match_proto__(vcl_func_f) VGC_function_vcl_backend_error(VRT_CTX);
int __match_proto__(vcl_func_f) VGC_function_vcl_backend_fetch(VRT_CTX);
int __match_proto__(vcl_func_f) VGC_function_vcl_backend_response(VRT_CTX);
int __match_proto__(vcl_func_f) VGC_function_vcl_deliver(VRT_CTX);
int __match_proto__(vcl_func_f) VGC_function_vcl_fini(VRT_CTX);
int __match_proto__(vcl_func_f) VGC_function_vcl_hash(VRT_CTX);
int __match_proto__(vcl_func_f) VGC_function_vcl_hit(VRT_CTX);
int __match_proto__(vcl_func_f) VGC_function_vcl_init(VRT_CTX);
int __match_proto__(vcl_func_f) VGC_function_vcl_miss(VRT_CTX);
int __match_proto__(vcl_func_f) VGC_function_vcl_pass(VRT_CTX);
int __match_proto__(vcl_func_f) VGC_function_vcl_pipe(VRT_CTX);
int __match_proto__(vcl_func_f) VGC_function_vcl_purge(VRT_CTX);
int __match_proto__(vcl_func_f) VGC_function_vcl_recv(VRT_CTX);
int __match_proto__(vcl_func_f) VGC_function_vcl_synth(VRT_CTX);
static unsigned vgc_inistep;
static unsigned vgc_warmupstep;
/* ---===### VCC generated .c code ###===---*/
void vo_free_r0(void *priv) {
Vmod_debug_Func.obj__fini((struct vmod_debug_obj**)&priv);
}
void vo_free_r1(void *priv) {
Vmod_debug_Func.obj__fini((struct vmod_debug_obj**)&priv);
}
void vo_free_t0(void *priv) {
Vmod_debug_Func.obj__fini((struct vmod_debug_obj**)&priv);
}
void vo_free_b0(void *priv) {
Vmod_debug_Func.obj__fini((struct vmod_debug_obj**)&priv);
}
int __match_proto__(vcl_func_f)
VGC_function_vcl_backend_error(VRT_CTX)
{
/* ... from ('Builtin' Line 174 Pos 5) */
{
{
VRT_count(ctx, 35);
VRT_SetHdr(ctx, &VGC_HDR_BERESP_Content_2d_Type,
"text/html; charset=utf-8",
vrt_magic_string_end
);
VRT_SetHdr(ctx, &VGC_HDR_BERESP_Retry_2d_After,
"5",
vrt_magic_string_end
);
VRT_l_beresp_body(ctx,
"<!DOCTYPE html>\n"
"<html>\n"
" <head>\n"
" <title>",
VRT_INT_string(ctx, VRT_r_beresp_status(ctx)),
" ",
VRT_r_beresp_reason(ctx),
"</title>\n"
" </head>\n"
" <body>\n"
" <h1>Error ",
VRT_INT_string(ctx, VRT_r_beresp_status(ctx)),
" ",
VRT_r_beresp_reason(ctx),
"</h1>\n"
" <p>",
VRT_r_beresp_reason(ctx),
"</p>\n"
" <h3>Guru Meditation:</h3>\n"
" <p>XID: ",
VRT_r_bereq_xid(ctx),
"</p>\n"
" <hr>\n"
" <p>Varnish cache server</p>\n"
" </body>\n"
"</html>\n"
"",
vrt_magic_string_end
);
VRT_handling(ctx, VCL_RET_DELIVER);
return (1);
}
}
}
int __match_proto__(vcl_func_f)
VGC_function_vcl_backend_fetch(VRT_CTX)
{
/* ... from ('Builtin' Line 151 Pos 5) */
{
{
VRT_count(ctx, 28);
if (
!VRT_strcmp(VRT_r_bereq_method(ctx), "GET")
)
{
VRT_count(ctx, 29);
VRT_l_bereq_body(ctx, vrt_magic_string_unset);
}
VRT_count(ctx, 30);
VRT_handling(ctx, VCL_RET_FETCH);
return (1);
}
}
}
int __match_proto__(vcl_func_f)
VGC_function_vcl_backend_response(VRT_CTX)
{
/* ... from ('m00026.vcl' Line 17 Pos 5) */
{
{
VRT_count(ctx, 3);
Vmod_debug_Func.obj__init(ctx, (struct vmod_debug_obj**)
VRT_priv_task_object(ctx, &vo_b0, &vo_free_b0),
"b0",
"b0",
"one");
VRT_SetHdr(ctx, &VGC_HDR_BERESP_b0,
Vmod_debug_Func.obj_string(ctx, (struct vmod_debug_obj*)
((VRT_priv_task(ctx, &vo_b0))->priv)),
vrt_magic_string_end
);
}
}
/* ... from ('Builtin' Line 158 Pos 5) */
{
{
VRT_count(ctx, 31);
if (
VRT_r_bereq_uncacheable(ctx)
)
{
VRT_count(ctx, 32);
VRT_handling(ctx, VCL_RET_DELIVER);
return (1);
}
else if (
(
(VRT_r_beresp_ttl(ctx) <= 0)||
(VRT_GetHdr(ctx, &VGC_HDR_BERESP_Set_2d_Cookie) != 0)||
VRT_re_match(ctx, VRT_GetHdr(ctx, &VGC_HDR_BERESP_Surrogate_2d_control), VGC_re_1)||
((
!((VRT_GetHdr(ctx, &VGC_HDR_BERESP_Surrogate_2d_Control) != 0))&&
VRT_re_match(ctx, VRT_GetHdr(ctx, &VGC_HDR_BERESP_Cache_2d_Control), VGC_re_2)))||
!VRT_strcmp(VRT_GetHdr(ctx, &VGC_HDR_BERESP_Vary), "*"))
)
{
VRT_count(ctx, 33);
VRT_l_beresp_ttl(ctx,
120
);
VRT_l_beresp_uncacheable(ctx,
(0==0)
);
}
VRT_count(ctx, 34);
VRT_handling(ctx, VCL_RET_DELIVER);
return (1);
}
}
}
int __match_proto__(vcl_func_f)
VGC_function_vcl_deliver(VRT_CTX)
{
/* ... from ('m00026.vcl' Line 22 Pos 5) */
{
{
VRT_count(ctx, 4);
VRT_SetHdr(ctx, &VGC_HDR_RESP_g0,
Vmod_debug_Func.obj_string(ctx, vo_g0),
vrt_magic_string_end
);
VRT_SetHdr(ctx, &VGC_HDR_RESP_r0,
Vmod_debug_Func.obj_string(ctx, (struct vmod_debug_obj*)
((VRT_priv_task(ctx, &vo_r0))->priv)),
vrt_magic_string_end
);
VRT_SetHdr(ctx, &VGC_HDR_RESP_r1,
Vmod_debug_Func.obj_string(ctx, (struct vmod_debug_obj*)
((VRT_priv_task(ctx, &vo_r1))->priv)),
vrt_magic_string_end
);
VRT_SetHdr(ctx, &VGC_HDR_RESP_t0,
Vmod_debug_Func.obj_string(ctx, (struct vmod_debug_obj*)
((VRT_priv_top(ctx, &vo_t0))->priv)),
vrt_magic_string_end
);
}
}
/* ... from ('Builtin' Line 120 Pos 5) */
{
{
VRT_count(ctx, 26);
VRT_handling(ctx, VCL_RET_DELIVER);
return (1);
}
}
}
int __match_proto__(vcl_func_f)
VGC_function_vcl_fini(VRT_CTX)
{
/* ... from ('Builtin' Line 201 Pos 5) */
{
{
VRT_count(ctx, 37);
VRT_handling(ctx, VCL_RET_OK);
return (1);
}
}
}
int __match_proto__(vcl_func_f)
VGC_function_vcl_hash(VRT_CTX)
{
/* ... from ('Builtin' Line 88 Pos 5) */
{
{
VRT_count(ctx, 16);
VRT_hashdata(ctx,
VRT_r_req_url(ctx),
vrt_magic_string_end
);
if (
(VRT_GetHdr(ctx, &VGC_HDR_REQ_host) != 0)
)
{
VRT_count(ctx, 17);
VRT_hashdata(ctx,
VRT_GetHdr(ctx, &VGC_HDR_REQ_host),
vrt_magic_string_end
);
}
else
{
VRT_count(ctx, 18);
VRT_hashdata(ctx,
VRT_IP_string(ctx, VRT_r_server_ip(ctx)),
vrt_magic_string_end
);
}
VRT_handling(ctx, VCL_RET_LOOKUP);
return (1);
}
}
}
int __match_proto__(vcl_func_f)
VGC_function_vcl_hit(VRT_CTX)
{
/* ... from ('Builtin' Line 102 Pos 5) */
{
{
VRT_count(ctx, 20);
if (
(VRT_r_obj_ttl(ctx) >= 0)
)
{
VRT_count(ctx, 21);
VRT_handling(ctx, VCL_RET_DELIVER);
return (1);
}
VRT_count(ctx, 22);
if (
((VRT_r_obj_ttl(ctx)+VRT_r_obj_grace(ctx)) > 0)
)
{
VRT_count(ctx, 23);
VRT_handling(ctx, VCL_RET_DELIVER);
return (1);
}
VRT_count(ctx, 24);
VRT_handling(ctx, VCL_RET_MISS);
return (1);
}
}
}
int __match_proto__(vcl_func_f)
VGC_function_vcl_init(VRT_CTX)
{
VRT_handling(ctx, VCL_RET_OK);
/* ... from ('m00026.vcl' Line 7 Pos 5) */
{
{
VRT_count(ctx, 1);
Vmod_debug_Func.obj__init(ctx, &vo_g0, "g0",
"g0",
"one");
}
}
/* ... from ('Builtin' Line 198 Pos 5) */
{
{
VRT_count(ctx, 36);
}
}
return (1);
}
int __match_proto__(vcl_func_f)
VGC_function_vcl_miss(VRT_CTX)
{
/* ... from ('Builtin' Line 116 Pos 5) */
{
{
VRT_count(ctx, 25);
VRT_handling(ctx, VCL_RET_FETCH);
return (1);
}
}
}
int __match_proto__(vcl_func_f)
VGC_function_vcl_pass(VRT_CTX)
{
/* ... from ('Builtin' Line 84 Pos 5) */
{
{
VRT_count(ctx, 15);
VRT_handling(ctx, VCL_RET_FETCH);
return (1);
}
}
}
int __match_proto__(vcl_func_f)
VGC_function_vcl_pipe(VRT_CTX)
{
/* ... from ('Builtin' Line 75 Pos 5) */
{
{
VRT_count(ctx, 14);
VRT_handling(ctx, VCL_RET_PIPE);
return (1);
}
}
}
int __match_proto__(vcl_func_f)
VGC_function_vcl_purge(VRT_CTX)
{
/* ... from ('Builtin' Line 98 Pos 5) */
{
{
VRT_count(ctx, 19);
VRT_synth(ctx,
200
,
"Purged"
);
VRT_handling(ctx, VCL_RET_SYNTH);
return (1);
}
}
}
int __match_proto__(vcl_func_f)
VGC_function_vcl_recv(VRT_CTX)
{
/* ... from ('m00026.vcl' Line 11 Pos 5) */
{
{
VRT_count(ctx, 2);
Vmod_debug_Func.obj__init(ctx, (struct vmod_debug_obj**)
VRT_priv_task_object(ctx, &vo_r0, &vo_free_r0),
"r0",
"r0",
"one");
Vmod_debug_Func.obj__init(ctx, (struct vmod_debug_obj**)
VRT_priv_task_object(ctx, &vo_r1, &vo_free_r1),
"r1",
VRT_GetHdr(ctx, &VGC_HDR_REQ_r1),
"one");
if (VRT_r_req_esi_level(ctx) == 0) {
Vmod_debug_Func.obj__init(ctx, (struct vmod_debug_obj**)
VRT_priv_top_object(ctx, &vo_t0, &vo_free_t0),
"t0",
"t0",
"one");
}
}
}
/* ... from ('Builtin' Line 47 Pos 5) */
{
{
VRT_count(ctx, 5);
if (
!VRT_strcmp(VRT_r_req_method(ctx), "PRI")
)
{
VRT_count(ctx, 6);
VRT_synth(ctx,
405
,
(const char*)0
);
VRT_handling(ctx, VCL_RET_SYNTH);
return (1);
}
VRT_count(ctx, 7);
if (
(
VRT_strcmp(VRT_r_req_method(ctx), "GET")&&
VRT_strcmp(VRT_r_req_method(ctx), "HEAD")&&
VRT_strcmp(VRT_r_req_method(ctx), "PUT")&&
VRT_strcmp(VRT_r_req_method(ctx), "POST")&&
VRT_strcmp(VRT_r_req_method(ctx), "TRACE")&&
VRT_strcmp(VRT_r_req_method(ctx), "OPTIONS")&&
VRT_strcmp(VRT_r_req_method(ctx), "DELETE")&&
VRT_strcmp(VRT_r_req_method(ctx), "PATCH"))
)
{
VRT_count(ctx, 8);
VRT_handling(ctx, VCL_RET_PIPE);
return (1);
}
VRT_count(ctx, 9);
if (
(
VRT_strcmp(VRT_r_req_method(ctx), "GET")&&
VRT_strcmp(VRT_r_req_method(ctx), "HEAD"))
)
{
VRT_count(ctx, 10);
VRT_handling(ctx, VCL_RET_PASS);
return (1);
}
VRT_count(ctx, 11);
if (
(
(VRT_GetHdr(ctx, &VGC_HDR_REQ_Authorization) != 0)||
(VRT_GetHdr(ctx, &VGC_HDR_REQ_Cookie) != 0))
)
{
VRT_count(ctx, 12);
VRT_handling(ctx, VCL_RET_PASS);
return (1);
}
VRT_count(ctx, 13);
VRT_handling(ctx, VCL_RET_HASH);
return (1);
}
}
}
int __match_proto__(vcl_func_f)
VGC_function_vcl_synth(VRT_CTX)
{
/* ... from ('Builtin' Line 127 Pos 5) */
{
{
VRT_count(ctx, 27);
VRT_SetHdr(ctx, &VGC_HDR_RESP_Content_2d_Type,
"text/html; charset=utf-8",
vrt_magic_string_end
);
VRT_SetHdr(ctx, &VGC_HDR_RESP_Retry_2d_After,
"5",
vrt_magic_string_end
);
VRT_l_resp_body(ctx,
"<!DOCTYPE html>\n"
"<html>\n"
" <head>\n"
" <title>",
VRT_INT_string(ctx, VRT_r_resp_status(ctx)),
" ",
VRT_r_resp_reason(ctx),
"</title>\n"
" </head>\n"
" <body>\n"
" <h1>Error ",
VRT_INT_string(ctx, VRT_r_resp_status(ctx)),
" ",
VRT_r_resp_reason(ctx),
"</h1>\n"
" <p>",
VRT_r_resp_reason(ctx),
"</p>\n"
" <h3>Guru Meditation:</h3>\n"
" <p>XID: ",
VRT_r_req_xid(ctx),
"</p>\n"
" <hr>\n"
" <p>Varnish cache server</p>\n"
" </body>\n"
"</html>\n"
"",
vrt_magic_string_end
);
VRT_handling(ctx, VCL_RET_DELIVER);
return (1);
}
}
}
static int
VGC_Load(VRT_CTX)
{
vgc_inistep = 0;
/* 1 */
if (VRT_Vmod_Init(&VGC_vmod_debug,
&Vmod_debug_Func,
sizeof(Vmod_debug_Func),
"debug",
"/home/reza/Code/varnish/open-source/varnish-PRs/lib/libvmod_debug/.libs/libvmod_debug.so",
"SIVIREECREZPGWRMPYATQXRHTNSZRLAW",
ctx))
return(1);
vgc_inistep = 1;
/* 2 */
if (Vmod_debug_Func._event(ctx, &vmod_priv_debug, VCL_EVENT_LOAD))
return(1);
vgc_inistep = 2;
/* 3 */
vgc_backend_default =
VRT_new_backend(ctx, &vgc_dir_priv_vgc_backend_default);
vgc_inistep = 3;
vgc_inistep = 4;
/* 5 */
VRT_re_init(&VGC_re_1, "no-store");
vgc_inistep = 5;
/* 6 */
VRT_re_init(&VGC_re_2, "no-cache|no-store|private");
vgc_inistep = 6;
(void)VGC_function_vcl_init(ctx);
return (*ctx->handling == VCL_RET_OK ? 0: -1);
}
static int
VGC_Discard(VRT_CTX)
{
(void)VGC_function_vcl_fini(ctx);
switch (vgc_inistep) {
case 6 :
VRT_re_fini(VGC_re_2);
/* FALLTHROUGH */
case 5 :
VRT_re_fini(VGC_re_1);
/* FALLTHROUGH */
case 4 :
Vmod_debug_Func.obj__fini(&vo_g0);
/* FALLTHROUGH */
case 2 :
(void)Vmod_debug_Func._event(ctx, &vmod_priv_debug,
VCL_EVENT_DISCARD);
/* FALLTHROUGH */
case 1 :
VRT_priv_fini(&vmod_priv_debug);
VRT_Vmod_Fini(&VGC_vmod_debug);
/* FALLTHROUGH */
}
return (0);
}
static int
VGC_Warmup(VRT_CTX, enum vcl_event_e ev)
{
vgc_warmupstep = 0;
/* 2 */
if ( Vmod_debug_Func._event(ctx, &vmod_priv_debug, ev))
return (1);
vgc_warmupstep = 2;
return (0);
}
static int
VGC_Cooldown(VRT_CTX, enum vcl_event_e ev)
{
int retval = 0;
/* 2 */
if (vgc_warmupstep >= 2 &&
Vmod_debug_Func._event(ctx, &vmod_priv_debug, ev) != 0)
retval = 1;
return (retval);
}
static int
VGC_Event(VRT_CTX, enum vcl_event_e ev)
{
if (ev == VCL_EVENT_LOAD)
return (VGC_Load(ctx));
if (ev == VCL_EVENT_WARM)
return (VGC_Warmup(ctx, ev));
if (ev == VCL_EVENT_COLD)
return (VGC_Cooldown(ctx, ev));
if (ev == VCL_EVENT_DISCARD)
return (VGC_Discard(ctx));
return (1);
}
const struct VCL_conf VCL_conf = {
.magic = VCL_CONF_MAGIC,
.event_vcl = VGC_Event,
.default_director = &vgc_backend_default,
.ref = VGC_ref,
.nref = VGC_NREFS,
.nsrc = VGC_NSRCS,
.srcname = srcname,
.srcbody = srcbody,
.backend_error_func = VGC_function_vcl_backend_error,
.backend_fetch_func = VGC_function_vcl_backend_fetch,
.backend_response_func = VGC_function_vcl_backend_response,
.deliver_func = VGC_function_vcl_deliver,
.fini_func = VGC_function_vcl_fini,
.hash_func = VGC_function_vcl_hash,
.hit_func = VGC_function_vcl_hit,
.init_func = VGC_function_vcl_init,
.miss_func = VGC_function_vcl_miss,
.pass_func = VGC_function_vcl_pass,
.pipe_func = VGC_function_vcl_pipe,
.purge_func = VGC_function_vcl_purge,
.recv_func = VGC_function_vcl_recv,
.synth_func = VGC_function_vcl_synth,
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment