asn1c/skeletons/xer_decoder.h

107 lines
3.3 KiB
C
Raw Permalink Normal View History

2004-10-20 15:50:55 +00:00
/*-
* Copyright (c) 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#ifndef _XER_DECODER_H_
#define _XER_DECODER_H_
#include <asn_application.h>
2005-07-24 09:03:44 +00:00
#ifdef __cplusplus
extern "C" {
#endif
2004-10-20 15:50:55 +00:00
struct asn_TYPE_descriptor_s; /* Forward declaration */
/*
2005-12-07 05:46:03 +00:00
* The XER decoder of any ASN.1 type. May be invoked by the application.
2004-10-20 15:50:55 +00:00
*/
asn_dec_rval_t xer_decode(struct asn_codec_ctx_s *opt_codec_ctx,
struct asn_TYPE_descriptor_s *type_descriptor,
void **struct_ptr, /* Pointer to a target structure's pointer */
2005-03-10 18:52:02 +00:00
const void *buffer, /* Data to be decoded */
2005-12-07 05:46:03 +00:00
size_t size /* Size of data buffer */
2004-10-20 15:50:55 +00:00
);
/*
* Type of the type-specific XER decoder function.
*/
typedef asn_dec_rval_t (xer_type_decoder_f)(asn_codec_ctx_t *opt_codec_ctx,
struct asn_TYPE_descriptor_s *type_descriptor,
void **struct_ptr,
const char *opt_mname, /* Member name */
2005-03-10 18:52:02 +00:00
const void *buf_ptr, size_t size
2004-10-20 15:50:55 +00:00
);
/*******************************
* INTERNALLY USEFUL FUNCTIONS *
*******************************/
/*
* Generalized function for decoding the primitive values.
* Used by more specialized functions, such as OCTET_STRING_decode_xer_utf8
* and others. This function should not be used by applications, as its API
* is subject to changes.
*/
asn_dec_rval_t xer_decode_general(asn_codec_ctx_t *opt_codec_ctx,
asn_struct_ctx_t *ctx, /* Type decoder context */
2004-10-21 11:22:12 +00:00
void *struct_key, /* Treated as opaque pointer */
2004-10-20 15:50:55 +00:00
const char *xml_tag, /* Expected XML tag name */
const void *buf_ptr, size_t size,
2004-10-20 15:50:55 +00:00
int (*opt_unexpected_tag_decoder)
(void *struct_key, const void *chunk_buf, size_t chunk_size),
2004-10-20 15:50:55 +00:00
ssize_t (*body_receiver)
(void *struct_key, const void *chunk_buf, size_t chunk_size,
2004-10-20 15:50:55 +00:00
int have_more)
);
/*
* Fetch the next XER (XML) token from the stream.
* The function returns the number of bytes occupied by the chunk type,
* returned in the _ch_type. The _ch_type is only set (and valid) when
2016-01-25 03:23:02 +00:00
* the return value is >= 0.
2004-10-20 15:50:55 +00:00
*/
typedef enum pxer_chunk_type {
2016-01-25 03:23:02 +00:00
PXER_WMORE, /* Chunk type is not clear, more data expected. */
PXER_TAG, /* Complete XER tag */
PXER_TEXT, /* Plain text between XER tags */
2005-03-10 18:52:02 +00:00
PXER_COMMENT /* A comment, may be part of */
2004-10-20 15:50:55 +00:00
} pxer_chunk_type_e;
2005-02-18 18:06:36 +00:00
ssize_t xer_next_token(int *stateContext,
const void *buffer, size_t size, pxer_chunk_type_e *_ch_type);
2004-10-20 15:50:55 +00:00
/*
* This function checks the buffer against the tag name is expected to occur.
*/
typedef enum xer_check_tag {
2005-02-18 14:23:48 +00:00
XCT_BROKEN = 0, /* The tag is broken */
XCT_OPENING = 1, /* This is the <opening> tag */
XCT_CLOSING = 2, /* This is the </closing> tag */
XCT_BOTH = 3, /* This is the <modified/> tag */
XCT__UNK__MASK = 4, /* Mask of everything unexpected */
XCT_UNKNOWN_OP = 5, /* Unexpected <opening> tag */
XCT_UNKNOWN_CL = 6, /* Unexpected </closing> tag */
2005-03-10 18:52:02 +00:00
XCT_UNKNOWN_BO = 7 /* Unexpected <modified/> tag */
2004-10-20 15:50:55 +00:00
} xer_check_tag_e;
xer_check_tag_e xer_check_tag(const void *buf_ptr, int size,
const char *need_tag);
2004-10-22 08:17:16 +00:00
/*
* Get the number of bytes consisting entirely of XER whitespace characters.
2004-10-22 08:17:16 +00:00
* RETURN VALUES:
* >=0: Number of whitespace characters in the string.
2004-10-22 08:17:16 +00:00
*/
size_t xer_whitespace_span(const void *chunk_buf, size_t chunk_size);
2004-10-22 08:17:16 +00:00
2005-02-18 16:10:40 +00:00
/*
* Skip the series of anticipated extensions.
*/
int xer_skip_unknown(xer_check_tag_e tcv, ber_tlv_len_t *depth);
2005-07-24 09:03:44 +00:00
#ifdef __cplusplus
}
#endif
2004-10-20 15:50:55 +00:00
#endif /* _XER_DECODER_H_ */