summaryrefslogtreecommitdiffstats
path: root/src/asn1c/xer_decoder.h
diff options
context:
space:
mode:
authorSimo Sorce <simo@redhat.com>2015-06-09 13:30:57 -0400
committerSimo Sorce <simo@redhat.com>2015-06-09 17:53:34 -0400
commitabd7c2e0ce5bd17997fb4c05eb2c7453060c0a3a (patch)
treef314e3a13669997c31a50511031298eba661566e /src/asn1c/xer_decoder.h
parent9cfa62da9119d2cd62314e5328215f8ea45c64b1 (diff)
Use a compiler to marshall/unmarshall the sessions
This way changes are easier, all is needed is to change the session.asn1 file to add or remove elements, and different session types can also be supported at the same time.
Diffstat (limited to 'src/asn1c/xer_decoder.h')
-rw-r--r--src/asn1c/xer_decoder.h105
1 files changed, 105 insertions, 0 deletions
diff --git a/src/asn1c/xer_decoder.h b/src/asn1c/xer_decoder.h
new file mode 100644
index 0000000..6988648
--- /dev/null
+++ b/src/asn1c/xer_decoder.h
@@ -0,0 +1,105 @@
+/*-
+ * 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>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct asn_TYPE_descriptor_s; /* Forward declaration */
+
+/*
+ * The XER decoder of any ASN.1 type. May be invoked by the application.
+ */
+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 */
+ const void *buffer, /* Data to be decoded */
+ size_t size /* Size of data buffer */
+ );
+
+/*
+ * 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 */
+ const void *buf_ptr, size_t size
+ );
+
+/*******************************
+ * 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 */
+ void *struct_key, /* Treated as opaque pointer */
+ const char *xml_tag, /* Expected XML tag name */
+ 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)
+ );
+
+
+/*
+ * 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
+ * the return value is greater than 0.
+ */
+ typedef enum pxer_chunk_type {
+ PXER_TAG, /* Complete XER tag */
+ PXER_TEXT, /* Plain text between XER tags */
+ PXER_COMMENT /* A comment, may be part of */
+ } pxer_chunk_type_e;
+ssize_t xer_next_token(int *stateContext,
+ const void *buffer, size_t size, pxer_chunk_type_e *_ch_type);
+
+/*
+ * This function checks the buffer against the tag name is expected to occur.
+ */
+ typedef enum xer_check_tag {
+ 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 */
+ XCT_UNKNOWN_BO = 7 /* Unexpected <modified/> tag */
+ } xer_check_tag_e;
+xer_check_tag_e xer_check_tag(const void *buf_ptr, int size,
+ const char *need_tag);
+
+/*
+ * Get the number of bytes consisting entirely of XER whitespace characters.
+ * RETURN VALUES:
+ * >=0: Number of whitespace characters in the string.
+ */
+size_t xer_whitespace_span(const void *chunk_buf, size_t chunk_size);
+
+/*
+ * Skip the series of anticipated extensions.
+ */
+int xer_skip_unknown(xer_check_tag_e tcv, ber_tlv_len_t *depth);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _XER_DECODER_H_ */