15 void **struct_ptr,
const void *buffer,
size_t size) {
24 s_codec_ctx = *opt_codec_ctx;
25 opt_codec_ctx = &s_codec_ctx;
29 memset(&s_codec_ctx, 0,
sizeof(s_codec_ctx));
31 opt_codec_ctx = &s_codec_ctx;
37 return td->
xer_decoder(opt_codec_ctx, td, struct_ptr, 0, buffer, size);
65 int new_stateContext = *stateContext;
70 if(ret < 0)
return -1;
96 *stateContext = new_stateContext;
106 const char *buf = (
const char *)buf_ptr;
110 if(size < 2 || buf[0] !=
LANGLE || buf[size-1] !=
RANGLE) {
113 buf[0], buf[size - 1]);
124 if(size > 0 && buf[size-1] ==
CSLASH)
129 if(size > 0 && buf[size-1] ==
CSLASH) {
136 if(!need_tag || !*need_tag)
142 for(end = buf + size; buf < end; buf++, need_tag++) {
143 int b = *buf, n = *need_tag;
147 case 0x09:
case 0x0a:
case 0x0c:
case 0x0d:
166 #define ADVANCE(num_bytes) do { \ 167 size_t num = (num_bytes); \ 168 buf_ptr = ((const char *)buf_ptr) + num; \ 170 consumed_myself += num; \ 174 #define RETURN(_code) do { \ 176 rval.consumed = consumed_myself; \ 177 if(rval.code != RC_OK) \ 178 ASN_DEBUG("Failed with %d", rval.code); \ 182 #define XER_GOT_BODY(chunk_buf, chunk_size, size) do { \ 183 ssize_t converted_size = body_receiver \ 184 (struct_key, chunk_buf, chunk_size, \ 185 (size_t)chunk_size < size); \ 186 if(converted_size == -1) RETURN(RC_FAIL); \ 187 if(converted_size == 0 \ 188 && size == (size_t)chunk_size) \ 190 chunk_size = converted_size; \ 192 #define XER_GOT_EMPTY() do { \ 193 if(body_receiver(struct_key, 0, 0, size > 0) == -1) \ 205 const void *buf_ptr,
size_t size,
206 int (*opt_unexpected_tag_decoder)
208 ssize_t (*body_receiver)
214 ssize_t consumed_myself = 0;
244 if(ctx->
phase == 0) {
261 assert(ch_type ==
PXER_TAG && size);
273 if(ctx->
phase)
break;
280 if(ctx->
phase)
break;
285 if(!ctx->
phase)
break;
293 if(opt_unexpected_tag_decoder
294 && opt_unexpected_tag_decoder(struct_key,
295 buf_ptr, ch_size) >= 0) {
311 ASN_DEBUG(
"Unexpected XML tag (expected \"%s\")", xml_tag);
324 for(; p < pend; p++) {
332 case 0x09:
case 0x0a:
case 0x0d:
case 0x20:
#define _ASN_DEFAULT_STACK_MAX
size_t xer_whitespace_span(const void *chunk_buf, size_t chunk_size)
xer_check_tag_e xer_check_tag(const void *buf_ptr, int size, const char *need_tag)
static int xer__token_cb(pxml_chunk_type_e type, const void *_chunk_data, size_t _chunk_size, void *key)
ssize_t pxml_parse(int *_stateContext, const void *_buf, size_t _size, pxml_callback_f *cb, void *_key)
pxml_chunk_type_e chunk_type
int xer_skip_unknown(xer_check_tag_e tcv, ber_tlv_len_t *depth)
ssize_t xer_next_token(int *stateContext, const void *buffer, size_t size, pxer_chunk_type_e *ch_type)
enum xer_check_tag xer_check_tag_e
asn_dec_rval_t xer_decode_general(asn_codec_ctx_t *opt_codec_ctx, asn_struct_ctx_t *ctx, void *struct_key, const char *xml_tag, const void *buf_ptr, size_t size, int(*opt_unexpected_tag_decoder)(void *struct_key, const void *chunk_buf, size_t chunk_size), ssize_t(*body_receiver)(void *struct_key, const void *chunk_buf, size_t chunk_size, int have_more))
xer_type_decoder_f * xer_decoder
static void ASN_DEBUG(const char *fmt,...)
#define XER_GOT_BODY(chunk_buf, chunk_size, size)
asn_dec_rval_t xer_decode(asn_codec_ctx_t *opt_codec_ctx, asn_TYPE_descriptor_t *td, void **struct_ptr, const void *buffer, size_t size)
#define ADVANCE(num_bytes)
enum pxer_chunk_type pxer_chunk_type_e