| 155 | } |
| 156 | |
| 157 | int acl_xml_decode(const char *in, ACL_VSTRING *out) |
| 158 | { |
| 159 | int n = 0, len = (int) strlen(in); |
| 160 | const char *ptr = in, *pre; |
| 161 | const ACL_TOKEN *token; |
| 162 | const XML_SPEC *spec; |
| 163 | |
| 164 | ACL_VSTRING_SPACE(out, len); |
| 165 | |
| 166 | acl_pthread_once(&__token_once, xml_decode_init); |
| 167 | if (__token_tree == NULL) |
| 168 | acl_msg_fatal("__token_tree null"); |
| 169 | |
| 170 | while (*ptr != 0) { |
| 171 | pre = ptr; |
| 172 | token = acl_token_tree_match(__token_tree, &ptr, NULL, NULL); |
| 173 | if (token == NULL) { |
| 174 | pre = markup_unescape(pre, out); |
| 175 | len = (int) (ptr - pre); |
| 176 | if (len > 0) |
| 177 | acl_vstring_memcat(out, pre, len); |
| 178 | break; |
| 179 | } |
| 180 | |
| 181 | spec = (const XML_SPEC*) token->ctx; |
| 182 | acl_assert(spec != NULL); |
| 183 | |
| 184 | len = (int) (ptr - pre - spec->len); |
| 185 | if (len > 0) |
| 186 | acl_vstring_memcat(out, pre, len); |
| 187 | acl_vstring_strcat(out, spec->str); |
| 188 | n++; |
| 189 | } |
| 190 | |
| 191 | ACL_VSTRING_TERMINATE(out); |
| 192 | return n; |
| 193 | } |
| 194 | |
| 195 | /*--------------------------------------------------------------------------*/ |
| 196 |
no test coverage detected
searching dependent graphs…