mongrel_esi 0.5.2 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ext/esi/esi_parser.c +1 -0
- data/ext/esi/extconf.rb +2 -0
- data/ext/esi/parser.c +2 -2
- data/ext/esi/parser.h +2 -0
- data/ext/esi/parser.rl +2 -2
- data/ext/esi/test/common.rl +46 -0
- data/ext/esi/test/parser.c +1901 -0
- data/ext/esi/test/parser.h +127 -0
- data/ext/esi/test/parser.rl +611 -0
- data/ext/esi/test/test.c +2 -2
- data/lib/esi/cache.rb +1 -1
- data/lib/esi/version.rb +1 -1
- data/test/benchmarks/perf-trunk-n1000-c1.csv +100 -100
- data/test/benchmarks/perf-trunk-n1000-c2.csv +100 -100
- data/test/benchmarks/perf-trunk-n1000-c3.csv +100 -100
- data/test/benchmarks/perf-trunk-n1000-c4.csv +100 -100
- data/test/benchmarks/perf-trunk-n1000-c5.csv +100 -100
- data/test/integration/docs/large-no-cache.html +688 -0
- data/test/integration/handler_test.rb +7 -2
- data/test/load_test_ab.rb +1 -1
- metadata +7 -222
- data/doc/rdoc/classes/ESI/CParser.html +0 -122
- data/doc/rdoc/classes/ESI/Cache.html +0 -178
- data/doc/rdoc/classes/ESI/Cache.src/M000087.html +0 -17
- data/doc/rdoc/classes/ESI/Cache.src/M000088.html +0 -20
- data/doc/rdoc/classes/ESI/Config.html +0 -314
- data/doc/rdoc/classes/ESI/Config.src/M000049.html +0 -18
- data/doc/rdoc/classes/ESI/Config.src/M000050.html +0 -18
- data/doc/rdoc/classes/ESI/Config.src/M000051.html +0 -35
- data/doc/rdoc/classes/ESI/Config.src/M000052.html +0 -40
- data/doc/rdoc/classes/ESI/Config.src/M000053.html +0 -23
- data/doc/rdoc/classes/ESI/Config.src/M000054.html +0 -18
- data/doc/rdoc/classes/ESI/Config.src/M000055.html +0 -20
- data/doc/rdoc/classes/ESI/Config.src/M000056.html +0 -24
- data/doc/rdoc/classes/ESI/Config/CacheConfig.html +0 -212
- data/doc/rdoc/classes/ESI/Config/CacheConfig.src/M000060.html +0 -19
- data/doc/rdoc/classes/ESI/Config/CacheConfig.src/M000061.html +0 -19
- data/doc/rdoc/classes/ESI/Config/CacheConfig.src/M000062.html +0 -18
- data/doc/rdoc/classes/ESI/Config/CacheConfig.src/M000063.html +0 -18
- data/doc/rdoc/classes/ESI/Config/CacheConfig.src/M000064.html +0 -18
- data/doc/rdoc/classes/ESI/Config/ConfigRouter.html +0 -187
- data/doc/rdoc/classes/ESI/Config/ConfigRouter.src/M000057.html +0 -19
- data/doc/rdoc/classes/ESI/Config/ConfigRouter.src/M000058.html +0 -21
- data/doc/rdoc/classes/ESI/Config/ConfigRouter.src/M000059.html +0 -21
- data/doc/rdoc/classes/ESI/Dispatcher.html +0 -174
- data/doc/rdoc/classes/ESI/Dispatcher.src/M000092.html +0 -19
- data/doc/rdoc/classes/ESI/Dispatcher.src/M000093.html +0 -27
- data/doc/rdoc/classes/ESI/Fragment.html +0 -218
- data/doc/rdoc/classes/ESI/Fragment.src/M000111.html +0 -20
- data/doc/rdoc/classes/ESI/Fragment.src/M000112.html +0 -18
- data/doc/rdoc/classes/ESI/Fragment.src/M000113.html +0 -18
- data/doc/rdoc/classes/ESI/Invalidator.html +0 -131
- data/doc/rdoc/classes/ESI/Invalidator.src/M000004.html +0 -41
- data/doc/rdoc/classes/ESI/Log.html +0 -221
- data/doc/rdoc/classes/ESI/Log.src/M000030.html +0 -18
- data/doc/rdoc/classes/ESI/Log.src/M000031.html +0 -18
- data/doc/rdoc/classes/ESI/Log.src/M000032.html +0 -18
- data/doc/rdoc/classes/ESI/Log.src/M000033.html +0 -18
- data/doc/rdoc/classes/ESI/Log.src/M000034.html +0 -18
- data/doc/rdoc/classes/ESI/Log.src/M000035.html +0 -18
- data/doc/rdoc/classes/ESI/Log.src/M000036.html +0 -18
- data/doc/rdoc/classes/ESI/MemcachedCache.html +0 -314
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000037.html +0 -24
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000038.html +0 -22
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000039.html +0 -19
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000040.html +0 -23
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000041.html +0 -18
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000042.html +0 -19
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000043.html +0 -18
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000044.html +0 -18
- data/doc/rdoc/classes/ESI/MemcachedCache.src/M000045.html +0 -17
- data/doc/rdoc/classes/ESI/OutputAdapter.html +0 -204
- data/doc/rdoc/classes/ESI/OutputAdapter.src/M000094.html +0 -37
- data/doc/rdoc/classes/ESI/OutputAdapter.src/M000095.html +0 -18
- data/doc/rdoc/classes/ESI/OutputAdapter.src/M000096.html +0 -18
- data/doc/rdoc/classes/ESI/OutputAdapter.src/M000097.html +0 -18
- data/doc/rdoc/classes/ESI/Parser.html +0 -184
- data/doc/rdoc/classes/ESI/Parser.src/M000065.html +0 -51
- data/doc/rdoc/classes/ESI/Parser.src/M000066.html +0 -39
- data/doc/rdoc/classes/ESI/Parser.src/M000067.html +0 -19
- data/doc/rdoc/classes/ESI/Processor.html +0 -194
- data/doc/rdoc/classes/ESI/Processor.src/M000046.html +0 -26
- data/doc/rdoc/classes/ESI/Processor.src/M000047.html +0 -44
- data/doc/rdoc/classes/ESI/Processor.src/M000048.html +0 -26
- data/doc/rdoc/classes/ESI/Proxy.html +0 -304
- data/doc/rdoc/classes/ESI/Proxy.src/M000071.html +0 -20
- data/doc/rdoc/classes/ESI/Proxy.src/M000072.html +0 -63
- data/doc/rdoc/classes/ESI/Proxy.src/M000073.html +0 -62
- data/doc/rdoc/classes/ESI/Proxy.src/M000074.html +0 -24
- data/doc/rdoc/classes/ESI/Proxy.src/M000075.html +0 -19
- data/doc/rdoc/classes/ESI/Proxy.src/M000076.html +0 -22
- data/doc/rdoc/classes/ESI/Proxy.src/M000077.html +0 -18
- data/doc/rdoc/classes/ESI/Proxy.src/M000078.html +0 -28
- data/doc/rdoc/classes/ESI/Proxy.src/M000079.html +0 -29
- data/doc/rdoc/classes/ESI/RackAdapter.html +0 -214
- data/doc/rdoc/classes/ESI/RackAdapter.src/M000068.html +0 -18
- data/doc/rdoc/classes/ESI/RackAdapter.src/M000069.html +0 -34
- data/doc/rdoc/classes/ESI/RackAdapter.src/M000070.html +0 -17
- data/doc/rdoc/classes/ESI/RackConfig.html +0 -173
- data/doc/rdoc/classes/ESI/RackConfig.src/M000089.html +0 -28
- data/doc/rdoc/classes/ESI/RackConfig.src/M000090.html +0 -18
- data/doc/rdoc/classes/ESI/RackConfig.src/M000091.html +0 -20
- data/doc/rdoc/classes/ESI/Request.html +0 -158
- data/doc/rdoc/classes/ESI/Request.src/M000098.html +0 -18
- data/doc/rdoc/classes/ESI/Request.src/M000099.html +0 -18
- data/doc/rdoc/classes/ESI/Response.html +0 -250
- data/doc/rdoc/classes/ESI/Response.src/M000080.html +0 -23
- data/doc/rdoc/classes/ESI/Response.src/M000081.html +0 -18
- data/doc/rdoc/classes/ESI/Response.src/M000082.html +0 -21
- data/doc/rdoc/classes/ESI/Response.src/M000083.html +0 -20
- data/doc/rdoc/classes/ESI/Response.src/M000084.html +0 -25
- data/doc/rdoc/classes/ESI/Response.src/M000085.html +0 -18
- data/doc/rdoc/classes/ESI/Response.src/M000086.html +0 -33
- data/doc/rdoc/classes/ESI/Router.html +0 -212
- data/doc/rdoc/classes/ESI/Router.src/M000109.html +0 -36
- data/doc/rdoc/classes/ESI/Router.src/M000110.html +0 -25
- data/doc/rdoc/classes/ESI/RubyCache.html +0 -278
- data/doc/rdoc/classes/ESI/RubyCache.src/M000100.html +0 -20
- data/doc/rdoc/classes/ESI/RubyCache.src/M000101.html +0 -20
- data/doc/rdoc/classes/ESI/RubyCache.src/M000102.html +0 -20
- data/doc/rdoc/classes/ESI/RubyCache.src/M000103.html +0 -22
- data/doc/rdoc/classes/ESI/RubyCache.src/M000104.html +0 -18
- data/doc/rdoc/classes/ESI/RubyCache.src/M000105.html +0 -22
- data/doc/rdoc/classes/ESI/RubyCache.src/M000106.html +0 -18
- data/doc/rdoc/classes/ESI/RubyCache.src/M000107.html +0 -18
- data/doc/rdoc/classes/ESI/RubyCache.src/M000108.html +0 -18
- data/doc/rdoc/classes/ESI/Tag.html +0 -141
- data/doc/rdoc/classes/ESI/Tag/Attempt.html +0 -113
- data/doc/rdoc/classes/ESI/Tag/Base.html +0 -237
- data/doc/rdoc/classes/ESI/Tag/Base.src/M000026.html +0 -23
- data/doc/rdoc/classes/ESI/Tag/Base.src/M000027.html +0 -22
- data/doc/rdoc/classes/ESI/Tag/Base.src/M000028.html +0 -22
- data/doc/rdoc/classes/ESI/Tag/Base.src/M000029.html +0 -17
- data/doc/rdoc/classes/ESI/Tag/Container.html +0 -206
- data/doc/rdoc/classes/ESI/Tag/Container.src/M000015.html +0 -20
- data/doc/rdoc/classes/ESI/Tag/Container.src/M000016.html +0 -22
- data/doc/rdoc/classes/ESI/Tag/Container.src/M000017.html +0 -25
- data/doc/rdoc/classes/ESI/Tag/Except.html +0 -184
- data/doc/rdoc/classes/ESI/Tag/Except.src/M000018.html +0 -21
- data/doc/rdoc/classes/ESI/Tag/Except.src/M000019.html +0 -20
- data/doc/rdoc/classes/ESI/Tag/Except.src/M000020.html +0 -18
- data/doc/rdoc/classes/ESI/Tag/Include.html +0 -257
- data/doc/rdoc/classes/ESI/Tag/Include.src/M000005.html +0 -20
- data/doc/rdoc/classes/ESI/Tag/Include.src/M000006.html +0 -18
- data/doc/rdoc/classes/ESI/Tag/Include.src/M000007.html +0 -34
- data/doc/rdoc/classes/ESI/Tag/Include.src/M000008.html +0 -22
- data/doc/rdoc/classes/ESI/Tag/Include.src/M000009.html +0 -27
- data/doc/rdoc/classes/ESI/Tag/Include.src/M000010.html +0 -30
- data/doc/rdoc/classes/ESI/Tag/Include.src/M000011.html +0 -51
- data/doc/rdoc/classes/ESI/Tag/Include/Request.html +0 -199
- data/doc/rdoc/classes/ESI/Tag/Include/Request.src/M000012.html +0 -18
- data/doc/rdoc/classes/ESI/Tag/Include/Request.src/M000013.html +0 -44
- data/doc/rdoc/classes/ESI/Tag/Include/Request/Error.html +0 -155
- data/doc/rdoc/classes/ESI/Tag/Include/Request/Error.src/M000014.html +0 -19
- data/doc/rdoc/classes/ESI/Tag/Invalidate.html +0 -171
- data/doc/rdoc/classes/ESI/Tag/Invalidate.src/M000023.html +0 -19
- data/doc/rdoc/classes/ESI/Tag/Invalidate.src/M000024.html +0 -51
- data/doc/rdoc/classes/ESI/Tag/Invalidate.src/M000025.html +0 -19
- data/doc/rdoc/classes/ESI/Tag/Try.html +0 -154
- data/doc/rdoc/classes/ESI/Tag/Try.src/M000021.html +0 -38
- data/doc/rdoc/classes/ESI/Tag/Try.src/M000022.html +0 -18
- data/doc/rdoc/classes/MultiDirHandler.html +0 -198
- data/doc/rdoc/classes/MultiDirHandler.src/M000001.html +0 -20
- data/doc/rdoc/classes/MultiDirHandler.src/M000002.html +0 -28
- data/doc/rdoc/classes/MultiDirHandler.src/M000003.html +0 -22
- data/doc/rdoc/created.rid +0 -1
- data/doc/rdoc/files/COPYING.html +0 -167
- data/doc/rdoc/files/LICENSE.html +0 -605
- data/doc/rdoc/files/README.html +0 -361
- data/doc/rdoc/files/ext/esi/common_rl.html +0 -160
- data/doc/rdoc/files/ext/esi/esi_parser_c.html +0 -101
- data/doc/rdoc/files/ext/esi/parser_c.html +0 -101
- data/doc/rdoc/files/ext/esi/parser_h.html +0 -101
- data/doc/rdoc/files/ext/esi/parser_rl.html +0 -867
- data/doc/rdoc/files/ext/esi/test/test_c.html +0 -101
- data/doc/rdoc/files/lib/esi/cache_rb.html +0 -120
- data/doc/rdoc/files/lib/esi/config_rb.html +0 -115
- data/doc/rdoc/files/lib/esi/dispatcher_rb.html +0 -110
- data/doc/rdoc/files/lib/esi/invalidator_rb.html +0 -114
- data/doc/rdoc/files/lib/esi/logger_rb.html +0 -108
- data/doc/rdoc/files/lib/esi/parser_rb.html +0 -120
- data/doc/rdoc/files/lib/esi/processor_rb.html +0 -115
- data/doc/rdoc/files/lib/esi/proxy_rb.html +0 -123
- data/doc/rdoc/files/lib/esi/rack_adapter_rb.html +0 -117
- data/doc/rdoc/files/lib/esi/response_rb.html +0 -116
- data/doc/rdoc/files/lib/esi/router_rb.html +0 -107
- data/doc/rdoc/files/lib/esi/tag/attempt_rb.html +0 -114
- data/doc/rdoc/files/lib/esi/tag/base_rb.html +0 -114
- data/doc/rdoc/files/lib/esi/tag/container_rb.html +0 -115
- data/doc/rdoc/files/lib/esi/tag/except_rb.html +0 -114
- data/doc/rdoc/files/lib/esi/tag/include_rb.html +0 -116
- data/doc/rdoc/files/lib/esi/tag/invalidate_rb.html +0 -115
- data/doc/rdoc/files/lib/esi/tag/try_rb.html +0 -115
- data/doc/rdoc/files/lib/esi/version_rb.html +0 -101
- data/doc/rdoc/files/lib/multi_dirhandler_rb.html +0 -109
- data/doc/rdoc/fr_class_index.html +0 -57
- data/doc/rdoc/fr_file_index.html +0 -55
- data/doc/rdoc/fr_method_index.html +0 -139
- data/doc/rdoc/index.html +0 -24
- data/doc/rdoc/rdoc-style.css +0 -208
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
-
<!DOCTYPE html
|
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
-
|
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
7
|
-
<head>
|
|
8
|
-
<title>File: esi_parser.c</title>
|
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
|
11
|
-
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
|
12
|
-
<script type="text/javascript">
|
|
13
|
-
// <![CDATA[
|
|
14
|
-
|
|
15
|
-
function popupCode( url ) {
|
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function toggleCode( id ) {
|
|
20
|
-
if ( document.getElementById )
|
|
21
|
-
elem = document.getElementById( id );
|
|
22
|
-
else if ( document.all )
|
|
23
|
-
elem = eval( "document.all." + id );
|
|
24
|
-
else
|
|
25
|
-
return false;
|
|
26
|
-
|
|
27
|
-
elemStyle = elem.style;
|
|
28
|
-
|
|
29
|
-
if ( elemStyle.display != "block" ) {
|
|
30
|
-
elemStyle.display = "block"
|
|
31
|
-
} else {
|
|
32
|
-
elemStyle.display = "none"
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Make codeblocks hidden by default
|
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
|
40
|
-
|
|
41
|
-
// ]]>
|
|
42
|
-
</script>
|
|
43
|
-
|
|
44
|
-
</head>
|
|
45
|
-
<body>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<div id="fileHeader">
|
|
50
|
-
<h1>esi_parser.c</h1>
|
|
51
|
-
<table class="header-table">
|
|
52
|
-
<tr class="top-aligned-row">
|
|
53
|
-
<td><strong>Path:</strong></td>
|
|
54
|
-
<td>ext/esi/esi_parser.c
|
|
55
|
-
</td>
|
|
56
|
-
</tr>
|
|
57
|
-
<tr class="top-aligned-row">
|
|
58
|
-
<td><strong>Last Update:</strong></td>
|
|
59
|
-
<td>Mon Jun 23 15:57:37 -0400 2008</td>
|
|
60
|
-
</tr>
|
|
61
|
-
</table>
|
|
62
|
-
</div>
|
|
63
|
-
<!-- banner header -->
|
|
64
|
-
|
|
65
|
-
<div id="bodyContent">
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
<div id="contextContent">
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
</div>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
</div>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
<!-- if includes -->
|
|
80
|
-
|
|
81
|
-
<div id="section">
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
<!-- if method_list -->
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
</div>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
<div id="validator-badges">
|
|
97
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
98
|
-
</div>
|
|
99
|
-
|
|
100
|
-
</body>
|
|
101
|
-
</html>
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
-
<!DOCTYPE html
|
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
-
|
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
7
|
-
<head>
|
|
8
|
-
<title>File: parser.c</title>
|
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
|
11
|
-
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
|
12
|
-
<script type="text/javascript">
|
|
13
|
-
// <![CDATA[
|
|
14
|
-
|
|
15
|
-
function popupCode( url ) {
|
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function toggleCode( id ) {
|
|
20
|
-
if ( document.getElementById )
|
|
21
|
-
elem = document.getElementById( id );
|
|
22
|
-
else if ( document.all )
|
|
23
|
-
elem = eval( "document.all." + id );
|
|
24
|
-
else
|
|
25
|
-
return false;
|
|
26
|
-
|
|
27
|
-
elemStyle = elem.style;
|
|
28
|
-
|
|
29
|
-
if ( elemStyle.display != "block" ) {
|
|
30
|
-
elemStyle.display = "block"
|
|
31
|
-
} else {
|
|
32
|
-
elemStyle.display = "none"
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Make codeblocks hidden by default
|
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
|
40
|
-
|
|
41
|
-
// ]]>
|
|
42
|
-
</script>
|
|
43
|
-
|
|
44
|
-
</head>
|
|
45
|
-
<body>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<div id="fileHeader">
|
|
50
|
-
<h1>parser.c</h1>
|
|
51
|
-
<table class="header-table">
|
|
52
|
-
<tr class="top-aligned-row">
|
|
53
|
-
<td><strong>Path:</strong></td>
|
|
54
|
-
<td>ext/esi/parser.c
|
|
55
|
-
</td>
|
|
56
|
-
</tr>
|
|
57
|
-
<tr class="top-aligned-row">
|
|
58
|
-
<td><strong>Last Update:</strong></td>
|
|
59
|
-
<td>Mon Jun 23 15:57:37 -0400 2008</td>
|
|
60
|
-
</tr>
|
|
61
|
-
</table>
|
|
62
|
-
</div>
|
|
63
|
-
<!-- banner header -->
|
|
64
|
-
|
|
65
|
-
<div id="bodyContent">
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
<div id="contextContent">
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
</div>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
</div>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
<!-- if includes -->
|
|
80
|
-
|
|
81
|
-
<div id="section">
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
<!-- if method_list -->
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
</div>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
<div id="validator-badges">
|
|
97
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
98
|
-
</div>
|
|
99
|
-
|
|
100
|
-
</body>
|
|
101
|
-
</html>
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
-
<!DOCTYPE html
|
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
-
|
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
7
|
-
<head>
|
|
8
|
-
<title>File: parser.h</title>
|
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
|
11
|
-
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
|
12
|
-
<script type="text/javascript">
|
|
13
|
-
// <![CDATA[
|
|
14
|
-
|
|
15
|
-
function popupCode( url ) {
|
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function toggleCode( id ) {
|
|
20
|
-
if ( document.getElementById )
|
|
21
|
-
elem = document.getElementById( id );
|
|
22
|
-
else if ( document.all )
|
|
23
|
-
elem = eval( "document.all." + id );
|
|
24
|
-
else
|
|
25
|
-
return false;
|
|
26
|
-
|
|
27
|
-
elemStyle = elem.style;
|
|
28
|
-
|
|
29
|
-
if ( elemStyle.display != "block" ) {
|
|
30
|
-
elemStyle.display = "block"
|
|
31
|
-
} else {
|
|
32
|
-
elemStyle.display = "none"
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Make codeblocks hidden by default
|
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
|
40
|
-
|
|
41
|
-
// ]]>
|
|
42
|
-
</script>
|
|
43
|
-
|
|
44
|
-
</head>
|
|
45
|
-
<body>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<div id="fileHeader">
|
|
50
|
-
<h1>parser.h</h1>
|
|
51
|
-
<table class="header-table">
|
|
52
|
-
<tr class="top-aligned-row">
|
|
53
|
-
<td><strong>Path:</strong></td>
|
|
54
|
-
<td>ext/esi/parser.h
|
|
55
|
-
</td>
|
|
56
|
-
</tr>
|
|
57
|
-
<tr class="top-aligned-row">
|
|
58
|
-
<td><strong>Last Update:</strong></td>
|
|
59
|
-
<td>Mon Jun 23 15:57:37 -0400 2008</td>
|
|
60
|
-
</tr>
|
|
61
|
-
</table>
|
|
62
|
-
</div>
|
|
63
|
-
<!-- banner header -->
|
|
64
|
-
|
|
65
|
-
<div id="bodyContent">
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
<div id="contextContent">
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
</div>
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
</div>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
<!-- if includes -->
|
|
80
|
-
|
|
81
|
-
<div id="section">
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
<!-- if method_list -->
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
</div>
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
<div id="validator-badges">
|
|
97
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
98
|
-
</div>
|
|
99
|
-
|
|
100
|
-
</body>
|
|
101
|
-
</html>
|
|
@@ -1,867 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
2
|
-
<!DOCTYPE html
|
|
3
|
-
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
4
|
-
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
5
|
-
|
|
6
|
-
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
|
7
|
-
<head>
|
|
8
|
-
<title>File: parser.rl</title>
|
|
9
|
-
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
|
10
|
-
<meta http-equiv="Content-Script-Type" content="text/javascript" />
|
|
11
|
-
<link rel="stylesheet" href="../../.././rdoc-style.css" type="text/css" media="screen" />
|
|
12
|
-
<script type="text/javascript">
|
|
13
|
-
// <![CDATA[
|
|
14
|
-
|
|
15
|
-
function popupCode( url ) {
|
|
16
|
-
window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function toggleCode( id ) {
|
|
20
|
-
if ( document.getElementById )
|
|
21
|
-
elem = document.getElementById( id );
|
|
22
|
-
else if ( document.all )
|
|
23
|
-
elem = eval( "document.all." + id );
|
|
24
|
-
else
|
|
25
|
-
return false;
|
|
26
|
-
|
|
27
|
-
elemStyle = elem.style;
|
|
28
|
-
|
|
29
|
-
if ( elemStyle.display != "block" ) {
|
|
30
|
-
elemStyle.display = "block"
|
|
31
|
-
} else {
|
|
32
|
-
elemStyle.display = "none"
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// Make codeblocks hidden by default
|
|
39
|
-
document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
|
|
40
|
-
|
|
41
|
-
// ]]>
|
|
42
|
-
</script>
|
|
43
|
-
|
|
44
|
-
</head>
|
|
45
|
-
<body>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
<div id="fileHeader">
|
|
50
|
-
<h1>parser.rl</h1>
|
|
51
|
-
<table class="header-table">
|
|
52
|
-
<tr class="top-aligned-row">
|
|
53
|
-
<td><strong>Path:</strong></td>
|
|
54
|
-
<td>ext/esi/parser.rl
|
|
55
|
-
</td>
|
|
56
|
-
</tr>
|
|
57
|
-
<tr class="top-aligned-row">
|
|
58
|
-
<td><strong>Last Update:</strong></td>
|
|
59
|
-
<td>Mon Jun 23 15:57:37 -0400 2008</td>
|
|
60
|
-
</tr>
|
|
61
|
-
</table>
|
|
62
|
-
</div>
|
|
63
|
-
<!-- banner header -->
|
|
64
|
-
|
|
65
|
-
<div id="bodyContent">
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
<div id="contextContent">
|
|
70
|
-
|
|
71
|
-
<div id="description">
|
|
72
|
-
<p>
|
|
73
|
-
/**
|
|
74
|
-
</p>
|
|
75
|
-
<pre>
|
|
76
|
-
* Copyright (c) 2008 Todd A. Fisher
|
|
77
|
-
* see LICENSE
|
|
78
|
-
*/
|
|
79
|
-
</pre>
|
|
80
|
-
<p>
|
|
81
|
-
include <stdio.h> include <stdlib.h> include <string.h>
|
|
82
|
-
include <ctype.h> include "parser.h"
|
|
83
|
-
</p>
|
|
84
|
-
<p>
|
|
85
|
-
ifdef DEBUG static void debug_string( const char *msg, const char *str,
|
|
86
|
-
size_t len ) {
|
|
87
|
-
</p>
|
|
88
|
-
<pre>
|
|
89
|
-
char *pstr = esi_strndup( str, len );
|
|
90
|
-
printf( "%s :'%s'\n", msg, pstr );
|
|
91
|
-
free( pstr );
|
|
92
|
-
</pre>
|
|
93
|
-
<p>
|
|
94
|
-
} else define debug_string(m,s,l) endif
|
|
95
|
-
</p>
|
|
96
|
-
<p>
|
|
97
|
-
/* define default callbacks */ static void esi_parser_default_start_cb(
|
|
98
|
-
const void *data,
|
|
99
|
-
</p>
|
|
100
|
-
<pre>
|
|
101
|
-
const char *name_start,
|
|
102
|
-
size_t name_length,
|
|
103
|
-
ESIAttribute *attributes,
|
|
104
|
-
void *user_data )
|
|
105
|
-
</pre>
|
|
106
|
-
<p>
|
|
107
|
-
{ } static void esi_parser_default_end_cb( const void *data,
|
|
108
|
-
</p>
|
|
109
|
-
<pre>
|
|
110
|
-
const char *name_start,
|
|
111
|
-
size_t name_length,
|
|
112
|
-
void *user_data )
|
|
113
|
-
</pre>
|
|
114
|
-
<p>
|
|
115
|
-
{ } static void esi_parser_default_output_cp(const void *data,
|
|
116
|
-
</p>
|
|
117
|
-
<pre>
|
|
118
|
-
size_t length,
|
|
119
|
-
void *user_data)
|
|
120
|
-
</pre>
|
|
121
|
-
<p>
|
|
122
|
-
{ }
|
|
123
|
-
</p>
|
|
124
|
-
<p>
|
|
125
|
-
/*
|
|
126
|
-
</p>
|
|
127
|
-
<pre>
|
|
128
|
-
* flush output buffer
|
|
129
|
-
*/
|
|
130
|
-
</pre>
|
|
131
|
-
<p>
|
|
132
|
-
static void esi_parser_flush_output( ESIParser *parser ) {
|
|
133
|
-
</p>
|
|
134
|
-
<pre>
|
|
135
|
-
if( parser->output_buffer_size > 0 ) {
|
|
136
|
-
//debug_string( "esi_parser_flush_output:", parser->output_buffer, parser->output_buffer_size );
|
|
137
|
-
parser->output_handler( (void*)parser->output_buffer, parser->output_buffer_size, parser->user_data );
|
|
138
|
-
parser->output_buffer_size = 0;
|
|
139
|
-
}
|
|
140
|
-
</pre>
|
|
141
|
-
<p>
|
|
142
|
-
} /* send the character to the output handler marking it
|
|
143
|
-
</p>
|
|
144
|
-
<pre>
|
|
145
|
-
* as ready for consumption, e.g. not an esi tag
|
|
146
|
-
*/
|
|
147
|
-
</pre>
|
|
148
|
-
<p>
|
|
149
|
-
static void esi_parser_echo_char( ESIParser *parser, char ch ) {
|
|
150
|
-
</p>
|
|
151
|
-
<pre>
|
|
152
|
-
parser->output_buffer[parser->output_buffer_size++] = ch;
|
|
153
|
-
if( parser->output_buffer_size == ESI_OUTPUT_BUFFER_SIZE ) {
|
|
154
|
-
// flush the buffer to the consumer
|
|
155
|
-
esi_parser_flush_output( parser );
|
|
156
|
-
}
|
|
157
|
-
</pre>
|
|
158
|
-
<p>
|
|
159
|
-
} static void esi_parser_send_buffer( ESIParser *parser, const char *seq,
|
|
160
|
-
size_t len ) {
|
|
161
|
-
</p>
|
|
162
|
-
<pre>
|
|
163
|
-
const char *nseq = seq + len;
|
|
164
|
-
size_t nlen = parser->output_buffer_size + len;
|
|
165
|
-
|
|
166
|
-
if( nlen < ESI_OUTPUT_BUFFER_SIZE ) {
|
|
167
|
-
memcpy( parser->output_buffer + parser->output_buffer_size, seq, len );
|
|
168
|
-
parser->output_buffer_size += len;
|
|
169
|
-
}
|
|
170
|
-
else if( nlen > ESI_OUTPUT_BUFFER_SIZE ) {
|
|
171
|
-
while( seq != nseq ) {
|
|
172
|
-
esi_parser_echo_char( parser, *seq++ );
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
</pre>
|
|
176
|
-
<p>
|
|
177
|
-
} /* send any buffered characters to the output handler.
|
|
178
|
-
</p>
|
|
179
|
-
<pre>
|
|
180
|
-
* This happens when we enter a case such as <em> where the
|
|
181
|
-
* first two characters < and e match the <esi: expression
|
|
182
|
-
*/
|
|
183
|
-
</pre>
|
|
184
|
-
<p>
|
|
185
|
-
static void esi_parser_echo_buffer( ESIParser *parser ) {
|
|
186
|
-
</p>
|
|
187
|
-
<pre>
|
|
188
|
-
size_t i = 0, len = parser->echobuffer_index + 1;;
|
|
189
|
-
//debug_string( "echobuffer", parser->echobuffer, parser->echobuffer_index+1 );
|
|
190
|
-
//parser->output_handler( parser->echobuffer, parser->echobuffer_index+1, parser->user_data );
|
|
191
|
-
for( ; i < len; ++i ) {
|
|
192
|
-
esi_parser_echo_char( parser, parser->echobuffer[i] );
|
|
193
|
-
}
|
|
194
|
-
</pre>
|
|
195
|
-
<p>
|
|
196
|
-
} /*
|
|
197
|
-
</p>
|
|
198
|
-
<pre>
|
|
199
|
-
* clear the buffer, no buffered characters should be emitted .
|
|
200
|
-
* e.g. we matched an esi tag completely and all buffered characters can be tossed out
|
|
201
|
-
*/
|
|
202
|
-
</pre>
|
|
203
|
-
<p>
|
|
204
|
-
static void esi_parser_echobuffer_clear( ESIParser *parser ) {
|
|
205
|
-
</p>
|
|
206
|
-
<pre>
|
|
207
|
-
parser->echobuffer_index = -1;
|
|
208
|
-
</pre>
|
|
209
|
-
<p>
|
|
210
|
-
}
|
|
211
|
-
</p>
|
|
212
|
-
<p>
|
|
213
|
-
/*
|
|
214
|
-
</p>
|
|
215
|
-
<pre>
|
|
216
|
-
* add a character to the echobuffer.
|
|
217
|
-
* this happens when we can't determine if the character is allowed to be sent to the client device
|
|
218
|
-
* e.g. matching <e it's not yet determined if these characters are safe to send or not
|
|
219
|
-
*/
|
|
220
|
-
</pre>
|
|
221
|
-
<p>
|
|
222
|
-
static void esi_parser_concat_to_echobuffer( ESIParser *parser, char ch ) {
|
|
223
|
-
</p>
|
|
224
|
-
<pre>
|
|
225
|
-
parser->echobuffer_index++;
|
|
226
|
-
|
|
227
|
-
if( parser->echobuffer_allocated <= parser->echobuffer_index ) {
|
|
228
|
-
/* double the echobuffer size
|
|
229
|
-
* we're getting some crazy input if this case ever happens
|
|
230
|
-
*/
|
|
231
|
-
printf( "increase echobuffer: %d, %s\n", parser->echobuffer_allocated, parser->echobuffer );
|
|
232
|
-
parser->echobuffer_allocated *= 2;
|
|
233
|
-
parser->echobuffer = (char*)realloc( parser->echobuffer, parser->echobuffer_allocated );
|
|
234
|
-
}
|
|
235
|
-
parser->echobuffer[parser->echobuffer_index] = ch;
|
|
236
|
-
</pre>
|
|
237
|
-
<p>
|
|
238
|
-
// debug_string( "echo buffer", parser->echobuffer,
|
|
239
|
-
parser->echobuffer_index+1 ); } /*
|
|
240
|
-
</p>
|
|
241
|
-
<pre>
|
|
242
|
-
* the mark boundary is not always going to be exactly on the attribute or tag name boundary
|
|
243
|
-
* this trims characters from the left to right, advancing *ptr and reducing *len
|
|
244
|
-
*/
|
|
245
|
-
</pre>
|
|
246
|
-
<p>
|
|
247
|
-
static void ltrim_pointer( const char **ptr, const char *bounds, size_t
|
|
248
|
-
*len ) {
|
|
249
|
-
</p>
|
|
250
|
-
<pre>
|
|
251
|
-
// remove any spaces or = at the before the value
|
|
252
|
-
while( (isspace( **ptr ) ||
|
|
253
|
-
**ptr == '=' ||
|
|
254
|
-
**ptr == '"' ||
|
|
255
|
-
**ptr == '<' ||
|
|
256
|
-
**ptr == '\'' ) && (*len > 0) && (*ptr != bounds) ) {
|
|
257
|
-
(*ptr)++;
|
|
258
|
-
(*len)--;
|
|
259
|
-
}
|
|
260
|
-
</pre>
|
|
261
|
-
<p>
|
|
262
|
-
} /*
|
|
263
|
-
</p>
|
|
264
|
-
<pre>
|
|
265
|
-
* similar to ltrim_pointer, this walks from bounds to *ptr, reducing *len
|
|
266
|
-
*/
|
|
267
|
-
</pre>
|
|
268
|
-
<p>
|
|
269
|
-
static void rtrim_pointer( const char **ptr, const char *bounds, size_t
|
|
270
|
-
*len ) {
|
|
271
|
-
</p>
|
|
272
|
-
<pre>
|
|
273
|
-
bounds = (*ptr+(*len-1));
|
|
274
|
-
// remove any spaces or = at the before the value
|
|
275
|
-
while( (isspace( *bounds ) ||
|
|
276
|
-
*bounds == '=' ||
|
|
277
|
-
*bounds == '"' ||
|
|
278
|
-
*bounds == '>' ||
|
|
279
|
-
*bounds == '\'') && (*len > 0) && (*ptr != bounds) ){
|
|
280
|
-
bounds--;
|
|
281
|
-
(*len)--;
|
|
282
|
-
}
|
|
283
|
-
</pre>
|
|
284
|
-
<p>
|
|
285
|
-
}
|
|
286
|
-
</p>
|
|
287
|
-
<p>
|
|
288
|
-
%%{
|
|
289
|
-
</p>
|
|
290
|
-
<pre>
|
|
291
|
-
machine esi;
|
|
292
|
-
|
|
293
|
-
action begin {
|
|
294
|
-
parser->mark = p;
|
|
295
|
-
//debug_string( "begin", p, 1 );
|
|
296
|
-
}
|
|
297
|
-
action finish {
|
|
298
|
-
</pre>
|
|
299
|
-
<p>
|
|
300
|
-
// printf( "finish\n" );
|
|
301
|
-
</p>
|
|
302
|
-
<pre>
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
# record the position of the start tag
|
|
306
|
-
action see_start_tag {
|
|
307
|
-
parser->tag_text = parser->mark+1;
|
|
308
|
-
parser->tag_text_length = p - (parser->mark+1);
|
|
309
|
-
parser->mark = p;
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
# detected an inline tag end, sends the start tag and end tag callback
|
|
313
|
-
action see_end_tag {
|
|
314
|
-
/* trim the tag text */
|
|
315
|
-
ltrim_pointer( &(parser->tag_text), p, &(parser->tag_text_length) );
|
|
316
|
-
rtrim_pointer( &(parser->tag_text), p, &(parser->tag_text_length) );
|
|
317
|
-
|
|
318
|
-
/* send the start tag and end tag message */
|
|
319
|
-
esi_parser_flush_output( parser );
|
|
320
|
-
parser->start_tag_handler( data, parser->tag_text, parser->tag_text_length, parser->attributes, parser->user_data );
|
|
321
|
-
parser->end_tag_handler( data, parser->tag_text, parser->tag_text_length, parser->user_data );
|
|
322
|
-
//printf("\t[see inline tag]\n");
|
|
323
|
-
|
|
324
|
-
/* mark the position */
|
|
325
|
-
parser->tag_text = NULL;
|
|
326
|
-
parser->tag_text_length = 0;
|
|
327
|
-
parser->mark = p;
|
|
328
|
-
|
|
329
|
-
/* clear out the echo buffer */
|
|
330
|
-
esi_parser_echobuffer_clear( parser );
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
# block tag start, with attributes
|
|
334
|
-
action see_block_start_with_attributes {
|
|
335
|
-
/* trim tag text */
|
|
336
|
-
ltrim_pointer( &(parser->tag_text), p, &(parser->tag_text_length) );
|
|
337
|
-
rtrim_pointer( &(parser->tag_text), p, &(parser->tag_text_length) );
|
|
338
|
-
|
|
339
|
-
/* send the start and end tag message */
|
|
340
|
-
esi_parser_flush_output( parser );
|
|
341
|
-
parser->start_tag_handler( data, parser->tag_text, parser->tag_text_length, parser->attributes, parser->user_data );
|
|
342
|
-
//printf("\t[see start tag with attributes]\n");
|
|
343
|
-
|
|
344
|
-
parser->tag_text = NULL;
|
|
345
|
-
parser->tag_text_length = 0;
|
|
346
|
-
parser->mark = p;
|
|
347
|
-
|
|
348
|
-
/* clear out the echo buffer */
|
|
349
|
-
esi_parser_echobuffer_clear( parser );
|
|
350
|
-
}
|
|
351
|
-
|
|
352
|
-
# see an attribute key, /foo\s*=/
|
|
353
|
-
action see_attribute_key {
|
|
354
|
-
/* save the attribute key start */
|
|
355
|
-
parser->attr_key = parser->mark;
|
|
356
|
-
/* compute the length of the key */
|
|
357
|
-
parser->attr_key_length = p - parser->mark;
|
|
358
|
-
/* save the position following the key */
|
|
359
|
-
parser->mark = p;
|
|
360
|
-
|
|
361
|
-
/* trim the attribute key */
|
|
362
|
-
ltrim_pointer( &(parser->attr_key), p, &(parser->attr_key_length) );
|
|
363
|
-
rtrim_pointer( &(parser->attr_key), p, &(parser->attr_key_length) );
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
# see an attribute value, aprox ~= /['"].*['"]/
|
|
367
|
-
action see_attribute_value {
|
|
368
|
-
ESIAttribute *attr;
|
|
369
|
-
|
|
370
|
-
/* save the attribute value start */
|
|
371
|
-
parser->attr_value = parser->mark;
|
|
372
|
-
/* compute the length of the value */
|
|
373
|
-
parser->attr_value_length = p - parser->mark;
|
|
374
|
-
/* svae the position following the value */
|
|
375
|
-
parser->mark = p;
|
|
376
|
-
|
|
377
|
-
/* trim the attribute value */
|
|
378
|
-
ltrim_pointer( &(parser->attr_value), p, &(parser->attr_value_length) );
|
|
379
|
-
rtrim_pointer( &(parser->attr_value), p, &(parser->attr_value_length) );
|
|
380
|
-
|
|
381
|
-
/* using the attr_key and attr_value, allocate a new attribute object */
|
|
382
|
-
attr = esi_attribute_new( parser->attr_key, parser->attr_key_length,
|
|
383
|
-
parser->attr_value, parser->attr_value_length );
|
|
384
|
-
|
|
385
|
-
/* add the new attribute to the list of attributes */
|
|
386
|
-
if( parser->attributes ) {
|
|
387
|
-
parser->last->next = attr;
|
|
388
|
-
parser->last = attr;
|
|
389
|
-
}
|
|
390
|
-
else {
|
|
391
|
-
parser->last = parser->attributes = attr;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
# simple block start tag detected, e.g. <esi:try> no attributes
|
|
396
|
-
action block_start_tag {
|
|
397
|
-
|
|
398
|
-
parser->tag_text = parser->mark;
|
|
399
|
-
parser->tag_text_length = p - parser->mark;
|
|
400
|
-
|
|
401
|
-
parser->mark = p;
|
|
402
|
-
|
|
403
|
-
ltrim_pointer( &(parser->tag_text), p, &(parser->tag_text_length) );
|
|
404
|
-
rtrim_pointer( &(parser->tag_text), p, &(parser->tag_text_length) );
|
|
405
|
-
|
|
406
|
-
esi_parser_flush_output( parser );
|
|
407
|
-
parser->start_tag_handler( data, parser->tag_text, parser->tag_text_length, NULL, parser->user_data );
|
|
408
|
-
//printf("\t[see start tag]\n");
|
|
409
|
-
|
|
410
|
-
esi_parser_echobuffer_clear( parser );
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
# block end tag detected, e.g. </esi:try>
|
|
414
|
-
action block_end_tag {
|
|
415
|
-
/* offset by 2 to account for the </ characters */
|
|
416
|
-
parser->tag_text = parser->mark+2;
|
|
417
|
-
parser->tag_text_length = p - (parser->mark+2);
|
|
418
|
-
|
|
419
|
-
parser->mark = p;
|
|
420
|
-
|
|
421
|
-
ltrim_pointer( &(parser->tag_text), p, &(parser->tag_text_length) );
|
|
422
|
-
rtrim_pointer( &(parser->tag_text), p, &(parser->tag_text_length) );
|
|
423
|
-
|
|
424
|
-
esi_parser_flush_output( parser );
|
|
425
|
-
parser->end_tag_handler( data, parser->tag_text, parser->tag_text_length, parser->user_data );
|
|
426
|
-
//printf("\t[see end tag]\n");
|
|
427
|
-
|
|
428
|
-
esi_parser_echobuffer_clear( parser );
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
# process each character in the input stream for output
|
|
432
|
-
action echo {
|
|
433
|
-
//printf( "[%c:%d],", *p, cs );
|
|
434
|
-
switch( cs ) {
|
|
435
|
-
case 0: /* non matching state */
|
|
436
|
-
if( parser->prev_state != 12 && parser->prev_state != 7 ){ /* states following a possible end state for a tag */
|
|
437
|
-
if( parser->echobuffer && parser->echobuffer_index != -1 ){
|
|
438
|
-
/* send the echo buffer */
|
|
439
|
-
esi_parser_echo_buffer( parser );
|
|
440
|
-
}
|
|
441
|
-
/* send the current character */
|
|
442
|
-
esi_parser_echo_char( parser, *p );
|
|
443
|
-
}
|
|
444
|
-
/* clear the echo buffer */
|
|
445
|
-
esi_parser_echobuffer_clear( parser );
|
|
446
|
-
break;
|
|
447
|
-
default:
|
|
448
|
-
/* append to the echo buffer */
|
|
449
|
-
esi_parser_concat_to_echobuffer( parser, *p );
|
|
450
|
-
}
|
|
451
|
-
/* save the previous state, necessary for end case detection such as /> and </esi:try> the trailing > character
|
|
452
|
-
is state 12 and 7
|
|
453
|
-
*/
|
|
454
|
-
parser->prev_state = cs;
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
include esi_common_parser "common.rl";
|
|
458
|
-
</pre>
|
|
459
|
-
<p>
|
|
460
|
-
}%%
|
|
461
|
-
</p>
|
|
462
|
-
<p>
|
|
463
|
-
%%write data;
|
|
464
|
-
</p>
|
|
465
|
-
<p>
|
|
466
|
-
/* dup the string up to len */ char *esi_strndup( const char *str, size_t
|
|
467
|
-
len ) {
|
|
468
|
-
</p>
|
|
469
|
-
<pre>
|
|
470
|
-
char *s = (char*)malloc(sizeof(char)*(len+1));
|
|
471
|
-
memcpy( s, str, len );
|
|
472
|
-
s[len] = '\0';
|
|
473
|
-
return s;
|
|
474
|
-
</pre>
|
|
475
|
-
<p>
|
|
476
|
-
}
|
|
477
|
-
</p>
|
|
478
|
-
<p>
|
|
479
|
-
ESIAttribute *esi_attribute_new( const char *name, size_t name_length,
|
|
480
|
-
const char *value, size_t value_length ) {
|
|
481
|
-
</p>
|
|
482
|
-
<pre>
|
|
483
|
-
ESIAttribute *attr = (ESIAttribute*)malloc(sizeof(ESIAttribute));
|
|
484
|
-
attr->name = name;//esi_strndup(name, name_length);
|
|
485
|
-
attr->value = value;//esi_strndup(value, value_length);
|
|
486
|
-
attr->name_length = name_length;
|
|
487
|
-
attr->value_length = value_length;
|
|
488
|
-
attr->next = NULL;
|
|
489
|
-
return attr;
|
|
490
|
-
</pre>
|
|
491
|
-
<p>
|
|
492
|
-
}
|
|
493
|
-
</p>
|
|
494
|
-
<p>
|
|
495
|
-
ESIAttribute *esi_attribute_copy( ESIAttribute *attribute ) {
|
|
496
|
-
</p>
|
|
497
|
-
<pre>
|
|
498
|
-
ESIAttribute *head, *nattr;
|
|
499
|
-
if( !attribute ){ return NULL; }
|
|
500
|
-
|
|
501
|
-
// copy the first attribute
|
|
502
|
-
nattr = esi_attribute_new( attribute->name, attribute->name_length,
|
|
503
|
-
attribute->value, attribute->value_length );
|
|
504
|
-
// save a pointer for return
|
|
505
|
-
head = nattr;
|
|
506
|
-
// copy next attributes
|
|
507
|
-
attribute = attribute->next;
|
|
508
|
-
while( attribute ) {
|
|
509
|
-
// set the next attribute
|
|
510
|
-
nattr->next = esi_attribute_new( attribute->name, attribute->name_length,
|
|
511
|
-
attribute->value, attribute->value_length );
|
|
512
|
-
// next attribute
|
|
513
|
-
nattr = nattr->next;
|
|
514
|
-
attribute = attribute->next;
|
|
515
|
-
}
|
|
516
|
-
return head;
|
|
517
|
-
</pre>
|
|
518
|
-
<p>
|
|
519
|
-
}
|
|
520
|
-
</p>
|
|
521
|
-
<p>
|
|
522
|
-
void esi_attribute_free( ESIAttribute *attribute ) {
|
|
523
|
-
</p>
|
|
524
|
-
<pre>
|
|
525
|
-
ESIAttribute *ptr;
|
|
526
|
-
while( attribute ){
|
|
527
|
-
</pre>
|
|
528
|
-
<p>
|
|
529
|
-
// free( attribute->name ); // free( attribute->value );
|
|
530
|
-
</p>
|
|
531
|
-
<pre>
|
|
532
|
-
ptr = attribute->next;
|
|
533
|
-
free( attribute );
|
|
534
|
-
attribute = ptr;
|
|
535
|
-
}
|
|
536
|
-
</pre>
|
|
537
|
-
<p>
|
|
538
|
-
}
|
|
539
|
-
</p>
|
|
540
|
-
<p>
|
|
541
|
-
ESIParser *esi_parser_new() {
|
|
542
|
-
</p>
|
|
543
|
-
<pre>
|
|
544
|
-
ESIParser *parser = (ESIParser*)malloc(sizeof(ESIParser));
|
|
545
|
-
parser->cs = esi_start;
|
|
546
|
-
parser->mark = NULL;
|
|
547
|
-
parser->tag_text = NULL;
|
|
548
|
-
parser->attr_key = NULL;
|
|
549
|
-
parser->attr_value = NULL;
|
|
550
|
-
parser->overflow_data_size = 0;
|
|
551
|
-
parser->overflow_data = NULL;
|
|
552
|
-
parser->overflow_data_allocated = 0;
|
|
553
|
-
parser->using_overflow = 0;
|
|
554
|
-
|
|
555
|
-
/* allocate ESI_OUTPUT_BUFFER_SIZE bytes for the echobuffer */
|
|
556
|
-
parser->echobuffer_allocated = ESI_ECHOBUFFER_SIZE;
|
|
557
|
-
parser->echobuffer_index = -1;
|
|
558
|
-
parser->echobuffer = (char*)malloc(sizeof(char)*parser->echobuffer_allocated);
|
|
559
|
-
|
|
560
|
-
parser->attributes = NULL;
|
|
561
|
-
parser->last = NULL;
|
|
562
|
-
|
|
563
|
-
parser->start_tag_handler = esi_parser_default_start_cb;
|
|
564
|
-
parser->end_tag_handler = esi_parser_default_end_cb;
|
|
565
|
-
parser->output_handler = esi_parser_default_output_cp;
|
|
566
|
-
|
|
567
|
-
parser->output_buffer_size = 0;
|
|
568
|
-
memset( parser->output_buffer, 0, ESI_OUTPUT_BUFFER_SIZE );
|
|
569
|
-
|
|
570
|
-
return parser;
|
|
571
|
-
</pre>
|
|
572
|
-
<p>
|
|
573
|
-
} void esi_parser_free( ESIParser *parser ) {
|
|
574
|
-
</p>
|
|
575
|
-
<pre>
|
|
576
|
-
if( parser->overflow_data ){ free( parser->overflow_data ); }
|
|
577
|
-
|
|
578
|
-
free( parser->echobuffer );
|
|
579
|
-
|
|
580
|
-
esi_attribute_free( parser->attributes );
|
|
581
|
-
|
|
582
|
-
free( parser );
|
|
583
|
-
</pre>
|
|
584
|
-
<p>
|
|
585
|
-
}
|
|
586
|
-
</p>
|
|
587
|
-
<p>
|
|
588
|
-
void esi_parser_output_handler( ESIParser *parser, output_cb output_handler
|
|
589
|
-
) {
|
|
590
|
-
</p>
|
|
591
|
-
<pre>
|
|
592
|
-
parser->output_handler = output_handler;
|
|
593
|
-
</pre>
|
|
594
|
-
<p>
|
|
595
|
-
}
|
|
596
|
-
</p>
|
|
597
|
-
<p>
|
|
598
|
-
int esi_parser_init( ESIParser *parser ) {
|
|
599
|
-
</p>
|
|
600
|
-
<pre>
|
|
601
|
-
int cs;
|
|
602
|
-
%% write init;
|
|
603
|
-
parser->prev_state = parser->cs = cs;
|
|
604
|
-
return 0;
|
|
605
|
-
</pre>
|
|
606
|
-
<p>
|
|
607
|
-
}
|
|
608
|
-
</p>
|
|
609
|
-
<p>
|
|
610
|
-
static int compute_offset( const char *mark, const char *data ) {
|
|
611
|
-
</p>
|
|
612
|
-
<pre>
|
|
613
|
-
if( mark ) {
|
|
614
|
-
return mark - data;
|
|
615
|
-
}
|
|
616
|
-
return -1;
|
|
617
|
-
</pre>
|
|
618
|
-
<p>
|
|
619
|
-
}
|
|
620
|
-
</p>
|
|
621
|
-
<p>
|
|
622
|
-
/*
|
|
623
|
-
</p>
|
|
624
|
-
<pre>
|
|
625
|
-
* scans the data buffer for a start sequence /<$/, /<e$/, /<es$/, /<esi$/, /<esi:$/
|
|
626
|
-
* returns index of if start sequence found else returns -1
|
|
627
|
-
*/
|
|
628
|
-
</pre>
|
|
629
|
-
<p>
|
|
630
|
-
static int esi_parser_scan_for_start( ESIParser *parser, const char *data,
|
|
631
|
-
size_t length ) {
|
|
632
|
-
</p>
|
|
633
|
-
<pre>
|
|
634
|
-
size_t i, f = -2, s = -2;
|
|
635
|
-
char ch;
|
|
636
|
-
|
|
637
|
-
for( i = 0; i < length; ++i ) {
|
|
638
|
-
ch = data[i];
|
|
639
|
-
switch( ch ) {
|
|
640
|
-
case '<':
|
|
641
|
-
f = s = i;
|
|
642
|
-
break;
|
|
643
|
-
case '/':
|
|
644
|
-
if( s == (i-1) && f != -2 ) { s = i; }
|
|
645
|
-
break;
|
|
646
|
-
case 'e':
|
|
647
|
-
if( s == (i-1) && f != -2 ) { s = i; }
|
|
648
|
-
break;
|
|
649
|
-
case 's':
|
|
650
|
-
if( s == (i-1) && f != -2 ) { s = i; }
|
|
651
|
-
break;
|
|
652
|
-
case 'i':
|
|
653
|
-
if( s == (i-1) && f != -2 ) { s = i; }
|
|
654
|
-
break;
|
|
655
|
-
case ':':
|
|
656
|
-
if( s == (i-1) && f != -2 ) { s = i; return f; }
|
|
657
|
-
break;
|
|
658
|
-
default:
|
|
659
|
-
f = s = -2;
|
|
660
|
-
break;
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
// if s and f are still valid at end of input return f
|
|
665
|
-
if( f != -2 && s != -2 ) {
|
|
666
|
-
return f;
|
|
667
|
-
}
|
|
668
|
-
else {
|
|
669
|
-
return -1;
|
|
670
|
-
}
|
|
671
|
-
</pre>
|
|
672
|
-
<p>
|
|
673
|
-
}
|
|
674
|
-
</p>
|
|
675
|
-
<p>
|
|
676
|
-
static void esi_parser_append_data_to_overflow_data( ESIParser *parser,
|
|
677
|
-
const char *data, size_t length ) {
|
|
678
|
-
</p>
|
|
679
|
-
<pre>
|
|
680
|
-
int mark_offset = 0;
|
|
681
|
-
int tag_text_offset = 0;
|
|
682
|
-
int attr_key_offset = 0;
|
|
683
|
-
int attr_value_offset = 0;
|
|
684
|
-
|
|
685
|
-
if( parser->using_overflow ) {
|
|
686
|
-
// recompute mark, tag_text, attr_key, and attr_value as they all exist within overflow_data
|
|
687
|
-
mark_offset = compute_offset( parser->mark, parser->overflow_data );
|
|
688
|
-
tag_text_offset = compute_offset( parser->tag_text, parser->overflow_data );
|
|
689
|
-
attr_key_offset = compute_offset( parser->attr_key, parser->overflow_data );
|
|
690
|
-
attr_value_offset = compute_offset( parser->attr_value, parser->overflow_data );
|
|
691
|
-
}
|
|
692
|
-
else {
|
|
693
|
-
// recompute mark, tag_text, attr_key, and attr_value as they all exist within data
|
|
694
|
-
mark_offset = compute_offset( parser->mark, data );
|
|
695
|
-
tag_text_offset = compute_offset( parser->tag_text, data );
|
|
696
|
-
attr_key_offset = compute_offset( parser->attr_key, data );
|
|
697
|
-
attr_value_offset = compute_offset( parser->attr_value, data );
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
if( parser->overflow_data ) {
|
|
701
|
-
// check if we need to resize or grow the buffer
|
|
702
|
-
if( (parser->overflow_data_size + length) > parser->overflow_data_allocated ) {
|
|
703
|
-
parser->overflow_data_allocated += length;
|
|
704
|
-
</pre>
|
|
705
|
-
<p>
|
|
706
|
-
// printf( "realloc: %d bytes, using %d\n",
|
|
707
|
-
(int)parser->overflow_data_allocated,
|
|
708
|
-
(int)(parser->overflow_data_size+length) );
|
|
709
|
-
</p>
|
|
710
|
-
<pre>
|
|
711
|
-
parser->overflow_data = (char*)realloc( parser->overflow_data, sizeof(char)*(parser->overflow_data_allocated) );
|
|
712
|
-
}
|
|
713
|
-
memcpy( parser->overflow_data+parser->overflow_data_size, data, length );
|
|
714
|
-
parser->overflow_data_size += length;
|
|
715
|
-
}
|
|
716
|
-
else {
|
|
717
|
-
parser->overflow_data_allocated = ESI_OUTPUT_BUFFER_SIZE > length ? ESI_OUTPUT_BUFFER_SIZE : length;
|
|
718
|
-
parser->overflow_data = (char*)malloc( sizeof( char ) * parser->overflow_data_allocated );
|
|
719
|
-
memcpy( parser->overflow_data, data, length );
|
|
720
|
-
parser->overflow_data_size = length;
|
|
721
|
-
</pre>
|
|
722
|
-
<p>
|
|
723
|
-
// printf( "malloc: %d for %d bytes\n",
|
|
724
|
-
(int)parser->overflow_data_allocated, (int)length );
|
|
725
|
-
</p>
|
|
726
|
-
<pre>
|
|
727
|
-
}
|
|
728
|
-
|
|
729
|
-
// in our new memory space mark will now be
|
|
730
|
-
parser->mark = ( mark_offset >= 0 ) ? parser->overflow_data + mark_offset : NULL;
|
|
731
|
-
parser->tag_text = ( tag_text_offset >= 0 ) ? parser->overflow_data + tag_text_offset : NULL;
|
|
732
|
-
parser->attr_key = ( attr_key_offset >= 0 ) ? parser->overflow_data + attr_key_offset : NULL;
|
|
733
|
-
parser->attr_value = ( attr_value_offset >= 0 ) ? parser->overflow_data + attr_value_offset : NULL;
|
|
734
|
-
</pre>
|
|
735
|
-
<p>
|
|
736
|
-
}
|
|
737
|
-
</p>
|
|
738
|
-
<p>
|
|
739
|
-
/* accept an arbitrary length string buffer
|
|
740
|
-
</p>
|
|
741
|
-
<pre>
|
|
742
|
-
* when this methods exits it determines if an end state was reached
|
|
743
|
-
* if no end state was reached it saves the full input into an internal buffer
|
|
744
|
-
* when invoked next, it reuses that internable buffer copying all pointers into the
|
|
745
|
-
* newly allocated buffer. if it exits in a terminal state, e.g. 0 then it will dump these buffers
|
|
746
|
-
*/
|
|
747
|
-
</pre>
|
|
748
|
-
<p>
|
|
749
|
-
int esi_parser_execute( ESIParser *parser, const char *data, size_t length
|
|
750
|
-
) {
|
|
751
|
-
</p>
|
|
752
|
-
<pre>
|
|
753
|
-
int cs = parser->cs;
|
|
754
|
-
const char *p = data;
|
|
755
|
-
const char *eof = NULL; // ragel 6.x compat
|
|
756
|
-
const char *pe = data + length;
|
|
757
|
-
int pindex;
|
|
758
|
-
|
|
759
|
-
if( length == 0 ){ return cs; }
|
|
760
|
-
|
|
761
|
-
/* scan data for any '<esi:' start sequences, /<$/, /<e$/, /<es$/, /<esi$/, /<esi:$/ */
|
|
762
|
-
if( cs == esi_start || cs == 0 ) {
|
|
763
|
-
pindex = esi_parser_scan_for_start( parser, data, length );
|
|
764
|
-
if( pindex == -1 ) { /* this means there are no start sequences in the buffer we recieved */
|
|
765
|
-
esi_parser_send_buffer( parser, data, length );
|
|
766
|
-
return cs; /* no esi start sequences send it all out and break out early */
|
|
767
|
-
}
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
/* there's an existing overflow buffer and it's being used, append the new data */
|
|
771
|
-
//if( parser->overflow_data && parser->overflow_data_size > 0 ) {
|
|
772
|
-
if( parser->using_overflow ) {
|
|
773
|
-
int prev_overflow_size = parser->overflow_data_size; // save the current overflow size
|
|
774
|
-
esi_parser_append_data_to_overflow_data( parser, data, length );
|
|
775
|
-
|
|
776
|
-
/* set parser variables */
|
|
777
|
-
p = parser->overflow_data + prev_overflow_size;
|
|
778
|
-
data = parser->overflow_data;
|
|
779
|
-
length = parser->overflow_data_size;
|
|
780
|
-
pe = data + length;
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
if( !parser->mark ) {
|
|
784
|
-
parser->mark = p;
|
|
785
|
-
}
|
|
786
|
-
|
|
787
|
-
%% write exec;
|
|
788
|
-
|
|
789
|
-
parser->cs = cs;
|
|
790
|
-
|
|
791
|
-
if( cs != esi_start && cs != 0 ) {
|
|
792
|
-
|
|
793
|
-
/* reached the end and we're not at a termination point save the buffer as overflow */
|
|
794
|
-
if( !parser->using_overflow ) {
|
|
795
|
-
esi_parser_append_data_to_overflow_data( parser, data, length );
|
|
796
|
-
parser->using_overflow = 1;
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
} else if ( parser->using_overflow ) {
|
|
800
|
-
parser->using_overflow = 0;
|
|
801
|
-
parser->overflow_data_size = 0;
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
return cs;
|
|
805
|
-
</pre>
|
|
806
|
-
<p>
|
|
807
|
-
} int esi_parser_finish( ESIParser *parser ) {
|
|
808
|
-
</p>
|
|
809
|
-
<pre>
|
|
810
|
-
esi_parser_flush_output( parser );
|
|
811
|
-
return 0;
|
|
812
|
-
</pre>
|
|
813
|
-
<p>
|
|
814
|
-
}
|
|
815
|
-
</p>
|
|
816
|
-
<p>
|
|
817
|
-
void esi_parser_start_tag_handler( ESIParser *parser, start_tag_cb callback
|
|
818
|
-
) {
|
|
819
|
-
</p>
|
|
820
|
-
<pre>
|
|
821
|
-
parser->start_tag_handler = callback;
|
|
822
|
-
</pre>
|
|
823
|
-
<p>
|
|
824
|
-
}
|
|
825
|
-
</p>
|
|
826
|
-
<p>
|
|
827
|
-
void esi_parser_end_tag_handler( ESIParser *parser, end_tag_cb callback ) {
|
|
828
|
-
</p>
|
|
829
|
-
<pre>
|
|
830
|
-
parser->end_tag_handler = callback;
|
|
831
|
-
</pre>
|
|
832
|
-
<p>
|
|
833
|
-
}
|
|
834
|
-
</p>
|
|
835
|
-
|
|
836
|
-
</div>
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
</div>
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
</div>
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
<!-- if includes -->
|
|
846
|
-
|
|
847
|
-
<div id="section">
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
<!-- if method_list -->
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
</div>
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
<div id="validator-badges">
|
|
863
|
-
<p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
|
|
864
|
-
</div>
|
|
865
|
-
|
|
866
|
-
</body>
|
|
867
|
-
</html>
|