asn1c/skeletons/ber_decoder.h

65 lines
2.0 KiB
C
Raw Normal View History

2004-06-03 03:38:44 +00:00
/*-
* Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#ifndef _BER_DECODER_H_
#define _BER_DECODER_H_
2004-09-24 21:00:50 +00:00
#include <asn_application.h>
2004-06-03 03:38:44 +00:00
2005-07-24 09:03:44 +00:00
#ifdef __cplusplus
extern "C" {
#endif
struct asn_TYPE_descriptor_s; /* Forward declaration */
struct asn_codec_ctx_s; /* Forward declaration */
2004-06-03 03:38:44 +00:00
/*
* The BER decoder of any type.
* This function may be invoked directly from the application.
2007-05-30 17:42:00 +00:00
* The der_encode() function (der_encoder.h) is an opposite to ber_decode().
2004-06-03 03:38:44 +00:00
*/
2004-10-20 15:50:55 +00:00
asn_dec_rval_t ber_decode(struct asn_codec_ctx_s *opt_codec_ctx,
struct asn_TYPE_descriptor_s *type_descriptor,
2004-06-03 03:38:44 +00:00
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 */
2004-06-03 03:38:44 +00:00
size_t size /* Size of that buffer */
);
/*
* Type of generic function which decodes the byte stream into the structure.
*/
2004-10-20 15:50:55 +00:00
typedef asn_dec_rval_t (ber_type_decoder_f)(
struct asn_codec_ctx_s *opt_codec_ctx,
struct asn_TYPE_descriptor_s *type_descriptor,
2005-03-10 18:52:02 +00:00
void **struct_ptr, const void *buf_ptr, size_t size,
2004-06-03 03:38:44 +00:00
int tag_mode);
/*******************************
* INTERNALLY USEFUL FUNCTIONS *
*******************************/
/*
* Check that all tags correspond to the type definition (as given in head).
* On return, last_length would contain either a non-negative length of the
* value part of the last TLV, or the negative number of expected
* "end of content" sequences. The number may only be negative if the
* head->last_tag_form is non-zero.
*/
2004-10-20 15:50:55 +00:00
asn_dec_rval_t ber_check_tags(
2005-12-07 05:46:03 +00:00
struct asn_codec_ctx_s *opt_codec_ctx, /* codec options */
struct asn_TYPE_descriptor_s *type_descriptor,
asn_struct_ctx_t *opt_ctx, /* saved decoding context */
2005-03-10 18:52:02 +00:00
const void *ptr, size_t size,
2004-06-03 03:38:44 +00:00
int tag_mode, /* {-1,0,1}: IMPLICIT, no, EXPLICIT */
int last_tag_form, /* {-1,0:1}: any, primitive, constr */
2004-06-03 03:38:44 +00:00
ber_tlv_len_t *last_length,
int *opt_tlv_form /* optional tag form */
);
2004-06-03 03:38:44 +00:00
2005-07-24 09:03:44 +00:00
#ifdef __cplusplus
}
#endif
2004-06-03 03:38:44 +00:00
#endif /* _BER_DECODER_H_ */