varnish-cache/lib/libvcc/vcc_types.c
1
/*-
2
 * Copyright (c) 2006 Verdens Gang AS
3
 * Copyright (c) 2006-2011 Varnish Software AS
4
 * All rights reserved.
5
 *
6
 * Author: Poul-Henning Kamp <phk@phk.freebsd.dk>
7
 *
8
 * Redistribution and use in source and binary forms, with or without
9
 * modification, are permitted provided that the following conditions
10
 * are met:
11
 * 1. Redistributions of source code must retain the above copyright
12
 *    notice, this list of conditions and the following disclaimer.
13
 * 2. Redistributions in binary form must reproduce the above copyright
14
 *    notice, this list of conditions and the following disclaimer in the
15
 *    documentation and/or other materials provided with the distribution.
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20
 * ARE DISCLAIMED.  IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
21
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27
 * SUCH DAMAGE.
28
 *
29
 */
30
31
#include "config.h"
32
33
#include <string.h>
34
35
#include "vcc_compile.h"
36
37
const struct type ACL[1] = {{
38
        .magic =                TYPE_MAGIC,
39
        .name =                 "ACL",
40
}};
41
42
const struct type BACKEND[1] = {{
43
        .magic =                TYPE_MAGIC,
44
        .name =                 "BACKEND",
45
        .tostring =             "VRT_BACKEND_string(\v1)",
46
}};
47
48
const struct type BLOB[1] = {{
49
        .magic =                TYPE_MAGIC,
50
        .name =                 "BLOB",
51
}};
52
53
const struct type BODY[1] = {{
54
        .magic =                TYPE_MAGIC,
55
        .name =                 "BODY",
56
}};
57
58
const struct type BOOL[1] = {{
59
        .magic =                TYPE_MAGIC,
60
        .name =                 "BOOL",
61
        .tostring =             "VRT_BOOL_string(\v1)",
62
}};
63
64
const struct type BYTES[1] = {{
65
        .magic =                TYPE_MAGIC,
66
        .name =                 "BYTES",
67
        .tostring =             "VRT_REAL_string(ctx, \v1)", // XXX: wrong
68
        .multype =              REAL,   // XXX: wrong
69
}};
70
71
const struct type DURATION[1] = {{
72
        .magic =                TYPE_MAGIC,
73
        .name =                 "DURATION",
74
        .tostring =             "VRT_REAL_string(ctx, \v1)", // XXX 's' suff?
75
        .multype =              REAL,
76
}};
77
78
const struct type ENUM[1] = {{
79
        .magic =                TYPE_MAGIC,
80
        .name =                 "ENUM",
81
        .tostring =             "",
82
}};
83
84
const struct type HEADER[1] = {{
85
        .magic =                TYPE_MAGIC,
86
        .name =                 "HEADER",
87
        .tostring =             "VRT_GetHdr(ctx, \v1)",
88
}};
89
90
const struct type HTTP[1] = {{
91
        .magic =                TYPE_MAGIC,
92
        .name =                 "HTTP",
93
}};
94
95
const struct type INSTANCE[1] = {{
96
        .magic =                TYPE_MAGIC,
97
        .name =                 "INSTANCE",
98
}};
99
100
const struct type INT[1] = {{
101
        .magic =                TYPE_MAGIC,
102
        .name =                 "INT",
103
        .multype =              INT,
104
        .tostring =             "VRT_INT_string(ctx, \v1)",
105
}};
106
107
const struct type IP[1] = {{
108
        .magic =                TYPE_MAGIC,
109
        .name =                 "IP",
110
        .tostring =             "VRT_IP_string(ctx, \v1)",
111
}};
112
113
const struct type PROBE[1] = {{
114
        .magic =                TYPE_MAGIC,
115
        .name =                 "PROBE",
116
}};
117
118
const struct type REAL[1] = {{
119
        .magic =                TYPE_MAGIC,
120
        .name =                 "REAL",
121
        .tostring =             "VRT_REAL_string(ctx, \v1)",
122
        .multype =              REAL,
123
}};
124
125
const struct type STEVEDORE[1] = {{
126
        .magic =                TYPE_MAGIC,
127
        .name =                 "STEVEDORE",
128
        .tostring =             "VRT_STEVEDORE_string(\v1)",
129
}};
130
131
const struct type STRING[1] = {{
132
        .magic =                TYPE_MAGIC,
133
        .name =                 "STRING",
134
}};
135
136
const struct type STRANDS[1] = {{
137
        .magic =                TYPE_MAGIC,
138
        .name =                 "STRANDS",
139
}};
140
141
const struct type STRINGS[1] = {{
142
        .magic =                TYPE_MAGIC,
143
        .name =                 "STRINGS",
144
        .tostring =             "",
145
}};
146
147
const struct type STRING_LIST[1] = {{
148
        .magic =                TYPE_MAGIC,
149
        .name =                 "STRING_LIST",
150
}};
151
152
const struct type SUB[1] = {{
153
        .magic =                TYPE_MAGIC,
154
        .name =                 "SUB",
155
}};
156
157
const struct type TIME[1] = {{
158
        .magic =                TYPE_MAGIC,
159
        .name =                 "TIME",
160
        .tostring =             "VRT_TIME_string(ctx, \v1)",
161
}};
162
163
const struct type VCL[1] = {{
164
        .magic =                TYPE_MAGIC,
165
        .name =                 "VCL",
166
}};
167
168
const struct type VOID[1] = {{
169
        .magic =                TYPE_MAGIC,
170
        .name =                 "VOID",
171
}};
172
173
vcc_type_t
174 23806
VCC_Type(const char *p)
175
{
176
177
#define VCC_TYPE(foo)   if (!strcmp(p, #foo)) return (foo);
178
#include "tbl/vcc_types.h"
179 0
        return (NULL);
180
}
181