Thu, 23 Mar 2023 11:43:25 +0000
stanzacmp: Support for captures
6
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 | -- This is my attempt at a utility library to compare two XMPP stanzas |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 | -- It is not testing for exact equivalency, but through some vague rules that felt right. |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 | -- For example, the second stanza passed to stanzas_match() is allowed to have unexpected |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 | -- elements and attributes at the top level. Beyond this, they must match exactly, except |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 | -- for whitespace differences only. |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 | -- |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 | -- There are probably bugs, and it can probably be smarter, but I don't want to spend too |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 | -- much time on it right now. |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 | |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 | local function trim(s) |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 | return (s:gsub("^%s+", ""):gsub("%s+$", "")); |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 | end |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 | |
153
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
14 | local function wants_strict(tag, default) |
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
15 | local opt = tag.attr["scansion:strict"] or default or "yes"; |
99
dc56d434e406
stanzacmp+tests: Add support for scansion:strict to allow override of default behaviour
Matthew Wild <mwild1@gmail.com>
parents:
92
diff
changeset
|
16 | if opt == "no" or opt == "false" or opt == "0" then |
dc56d434e406
stanzacmp+tests: Add support for scansion:strict to allow override of default behaviour
Matthew Wild <mwild1@gmail.com>
parents:
92
diff
changeset
|
17 | return false; |
dc56d434e406
stanzacmp+tests: Add support for scansion:strict to allow override of default behaviour
Matthew Wild <mwild1@gmail.com>
parents:
92
diff
changeset
|
18 | elseif opt == "yes" or opt == "true" or opt == "1" then |
dc56d434e406
stanzacmp+tests: Add support for scansion:strict to allow override of default behaviour
Matthew Wild <mwild1@gmail.com>
parents:
92
diff
changeset
|
19 | return true; |
dc56d434e406
stanzacmp+tests: Add support for scansion:strict to allow override of default behaviour
Matthew Wild <mwild1@gmail.com>
parents:
92
diff
changeset
|
20 | end |
dc56d434e406
stanzacmp+tests: Add support for scansion:strict to allow override of default behaviour
Matthew Wild <mwild1@gmail.com>
parents:
92
diff
changeset
|
21 | error("Unexpected scansion:strict value: "..opt); |
dc56d434e406
stanzacmp+tests: Add support for scansion:strict to allow override of default behaviour
Matthew Wild <mwild1@gmail.com>
parents:
92
diff
changeset
|
22 | end |
dc56d434e406
stanzacmp+tests: Add support for scansion:strict to allow override of default behaviour
Matthew Wild <mwild1@gmail.com>
parents:
92
diff
changeset
|
23 | |
170
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
24 | local function is_wildcard(k, v) |
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
25 | if v == "{scansion:any}" then |
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
26 | return "attr:"..k; |
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
27 | end |
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
28 | return (v:match("^{scansion:capture:([^}]+)}$")); |
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
29 | end |
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
30 | |
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
31 | -- stanza1 == expected, stanza2 == variable |
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
32 | -- captures is an optional table to store captures (captures["foo"] == {scansion:capture:foo}) |
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
33 | local function stanzas_strict_match(stanza1, stanza2, captures) |
6
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 | if stanza1.name ~= stanza2.name or stanza1.attr.xmlns ~= stanza2.attr.xmlns then |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 | return false; |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 | end |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 | |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
38 | for k, v in pairs(stanza1.attr) do |
170
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
39 | local wildcard = is_wildcard(k, v); |
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
40 | if not k:match("^scansion:") and not wildcard and stanza2.attr[k] ~= v then |
6
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 | return false; |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 | end |
170
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
43 | if wildcard and captures then |
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
44 | captures[wildcard] = stanza2.attr[k]; |
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
45 | end |
6
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
46 | end |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
47 | |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
48 | for k, v in pairs(stanza2.attr) do |
170
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
49 | local wildcard = is_wildcard(k, stanza1.attr[k]); |
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
50 | if not wildcard and stanza1.attr[k] ~= v then |
6
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
51 | return false; |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
52 | end |
170
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
53 | if wildcard and captures then |
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
54 | captures[wildcard] = v; |
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
55 | end |
6
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
56 | end |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
57 | |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
58 | if #stanza1.tags ~= #stanza2.tags then |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
59 | return false; |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
60 | end |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
61 | |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
62 | local stanza2_pos = 1; |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
63 | for _, child in ipairs(stanza1) do |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
64 | if type(child) == "table" or child:match("%S") then |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
65 | local match; |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
66 | local child2 = stanza2[stanza2_pos]; |
32
0eabed6c91e7
stanzacmp: Check the correct side of the comparsion for whitespace
Kim Alvefur <zash@zash.se>
parents:
6
diff
changeset
|
67 | while child2 and not(type(child2) == "table" or child2:match("%S")) do |
6
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
68 | stanza2_pos = stanza2_pos + 1; |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
69 | child2 = stanza2[stanza2_pos]; |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
70 | end |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
71 | if type(child) ~= type(child2) then |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
72 | return false; |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
73 | end |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
74 | if type(child) == "table" and child2.name == child.name and child2.attr.xmlns == child.attr.xmlns then |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
75 | -- Strict deep match |
170
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
76 | match = stanzas_strict_match(child, child2, captures); |
6
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
77 | elseif type(child) == "string" then -- Text nodes, must be equal, ignoring leading/trailing whitespace |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
78 | match = trim(child) == trim(child2); |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
79 | end |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
80 | if not match then |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
81 | return false; |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
82 | end |
101
91a9e557e0e5
stanzacmp + tests: Advance through matching stanza on successful match
Matthew Wild <mwild1@gmail.com>
parents:
99
diff
changeset
|
83 | stanza2_pos = stanza2_pos + 1; |
6
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
84 | end |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
85 | end |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
86 | return true; |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
87 | end |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
88 | |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
89 | -- Everything in stanza1 should be present in stanza2 |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
90 | |
170
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
91 | local function stanzas_match(stanza1, stanza2, captures) |
153
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
92 | if wants_strict(stanza1, stanza1.attr.xmlns == nil and "no" or "yes") then |
170
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
93 | return stanzas_strict_match(stanza1, stanza2, captures); |
153
f83ea6e5c3d8
stanzacmp: Allow scansion:strict at the top level of the stanza
Matthew Wild <mwild1@gmail.com>
parents:
151
diff
changeset
|
94 | end |
6
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
95 | if stanza1.name ~= stanza2.name or stanza1.attr.xmlns ~= stanza2.attr.xmlns then |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
96 | return false; |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
97 | end |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
98 | |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
99 | for k, v in pairs(stanza1.attr) do |
170
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
100 | local wildcard = is_wildcard(k, v); |
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
101 | if not k:match("^scansion:") and not wildcard and stanza2.attr[k] ~= v then |
6
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
102 | return false; |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
103 | end |
170
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
104 | if wildcard and captures then |
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
105 | captures[wildcard] = stanza2.attr[k]; |
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
106 | end |
6
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
107 | end |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
108 | |
92
9a58c8ee0757
stanzacmp: A new iteration of the stanza matching algorithm
Matthew Wild <mwild1@gmail.com>
parents:
91
diff
changeset
|
109 | local matched_children = {}; |
6
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
110 | for _, child in ipairs(stanza1) do |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
111 | if type(child) == "table" or child:match("%S") then |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
112 | local match; |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
113 | -- Iterate through remaining nodes in stanza2, looking for a match |
92
9a58c8ee0757
stanzacmp: A new iteration of the stanza matching algorithm
Matthew Wild <mwild1@gmail.com>
parents:
91
diff
changeset
|
114 | local stanza2_pos = 1; |
6
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
115 | while stanza2_pos <= #stanza2 do |
92
9a58c8ee0757
stanzacmp: A new iteration of the stanza matching algorithm
Matthew Wild <mwild1@gmail.com>
parents:
91
diff
changeset
|
116 | if not matched_children[stanza2_pos] then |
9a58c8ee0757
stanzacmp: A new iteration of the stanza matching algorithm
Matthew Wild <mwild1@gmail.com>
parents:
91
diff
changeset
|
117 | local child2 = stanza2[stanza2_pos]; |
9a58c8ee0757
stanzacmp: A new iteration of the stanza matching algorithm
Matthew Wild <mwild1@gmail.com>
parents:
91
diff
changeset
|
118 | stanza2_pos = stanza2_pos + 1; |
6
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
119 | |
92
9a58c8ee0757
stanzacmp: A new iteration of the stanza matching algorithm
Matthew Wild <mwild1@gmail.com>
parents:
91
diff
changeset
|
120 | if type(child2) == type(child) then |
9a58c8ee0757
stanzacmp: A new iteration of the stanza matching algorithm
Matthew Wild <mwild1@gmail.com>
parents:
91
diff
changeset
|
121 | if type(child) == "table" and child2.name == child.name and child2.attr.xmlns == child.attr.xmlns then |
170
db73c4c317ce
stanzacmp: Support for captures
Matthew Wild <mwild1@gmail.com>
parents:
153
diff
changeset
|
122 | match = stanzas_match(child, child2, captures); |
92
9a58c8ee0757
stanzacmp: A new iteration of the stanza matching algorithm
Matthew Wild <mwild1@gmail.com>
parents:
91
diff
changeset
|
123 | elseif type(child) == "string" then -- Text nodes, must be equal, ignoring leading/trailing whitespace |
9a58c8ee0757
stanzacmp: A new iteration of the stanza matching algorithm
Matthew Wild <mwild1@gmail.com>
parents:
91
diff
changeset
|
124 | match = trim(child) == trim(child2); |
9a58c8ee0757
stanzacmp: A new iteration of the stanza matching algorithm
Matthew Wild <mwild1@gmail.com>
parents:
91
diff
changeset
|
125 | end |
9a58c8ee0757
stanzacmp: A new iteration of the stanza matching algorithm
Matthew Wild <mwild1@gmail.com>
parents:
91
diff
changeset
|
126 | if match then |
9a58c8ee0757
stanzacmp: A new iteration of the stanza matching algorithm
Matthew Wild <mwild1@gmail.com>
parents:
91
diff
changeset
|
127 | break; |
9a58c8ee0757
stanzacmp: A new iteration of the stanza matching algorithm
Matthew Wild <mwild1@gmail.com>
parents:
91
diff
changeset
|
128 | end |
6
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
129 | end |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
130 | end |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
131 | end |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
132 | if not match then |
92
9a58c8ee0757
stanzacmp: A new iteration of the stanza matching algorithm
Matthew Wild <mwild1@gmail.com>
parents:
91
diff
changeset
|
133 | --print(_, "No match for ", child:pretty_print()) |
6
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
134 | return false; |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
135 | end |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
136 | end |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
137 | end |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
138 | return true; |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
139 | end |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
140 | |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
141 | |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
142 | return { |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
143 | stanzas_match = stanzas_match; |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
144 | stanzas_strict_match = stanzas_strict_match; |
0c94ea0cabec
client: Implement send/receive, including new stanzacmp library
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
145 | }; |