Blame src/asn1c/xer_decoder.h

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