asn1c/skeletons/per_encoder.h

71 lines
2.4 KiB
C
Raw Permalink Normal View History

2006-08-18 01:34:18 +00:00
/*-
* Copyright (c) 2006-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
2006-08-18 01:34:18 +00:00
* Redistribution and modifications are permitted subject to BSD license.
*/
#ifndef _PER_ENCODER_H_
#define _PER_ENCODER_H_
#include <asn_application.h>
#include <per_support.h>
#ifdef __cplusplus
extern "C" {
#endif
struct asn_TYPE_descriptor_s; /* Forward declaration */
/*
* Unaligned PER encoder of any ASN.1 type. May be invoked by the application.
2007-06-23 23:50:25 +00:00
* WARNING: This function returns the number of encoded bits in the .encoded
* field of the return value. Use the following formula to convert to bytes:
* bytes = ((.encoded + 7) / 8)
2006-08-18 01:34:18 +00:00
*/
asn_enc_rval_t uper_encode(
const struct asn_TYPE_descriptor_s *type_descriptor,
2017-10-24 07:47:03 +00:00
const asn_per_constraints_t *constraints,
const void *struct_ptr, /* Structure to be encoded */
asn_app_consume_bytes_f *consume_bytes_cb, /* Data collector */
void *app_key /* Arbitrary callback argument */
2006-08-18 01:34:18 +00:00
);
2007-06-23 23:50:25 +00:00
/*
* A variant of uper_encode() which encodes data into the existing buffer
* WARNING: This function returns the number of encoded bits in the .encoded
* field of the return value.
*/
2006-08-18 01:34:18 +00:00
asn_enc_rval_t uper_encode_to_buffer(
const struct asn_TYPE_descriptor_s *type_descriptor,
2017-10-24 07:47:03 +00:00
const asn_per_constraints_t *constraints,
const void *struct_ptr, /* Structure to be encoded */
void *buffer, /* Pre-allocated buffer */
size_t buffer_size /* Initial buffer size (max) */
2006-08-18 01:34:18 +00:00
);
2007-06-23 23:50:25 +00:00
/*
* A variant of uper_encode_to_buffer() which allocates buffer itself.
* Returns the number of bytes in the buffer or -1 in case of failure.
* WARNING: This function produces a "Production of the complete encoding",
2007-06-26 23:56:54 +00:00
* with length of at least one octet. Contrast this to precise bit-packing
2007-06-23 23:50:25 +00:00
* encoding of uper_encode() and uper_encode_to_buffer().
*/
ssize_t uper_encode_to_new_buffer(
const struct asn_TYPE_descriptor_s *type_descriptor,
const asn_per_constraints_t *constraints,
const void *struct_ptr, /* Structure to be encoded */
void **buffer_r /* Buffer allocated and returned */
2007-06-23 23:50:25 +00:00
);
2006-08-18 01:34:18 +00:00
/*
* Type of the generic PER encoder function.
*/
typedef asn_enc_rval_t(per_type_encoder_f)(
const struct asn_TYPE_descriptor_s *type_descriptor,
const asn_per_constraints_t *constraints, const void *struct_ptr,
asn_per_outp_t *per_output);
2006-08-18 01:34:18 +00:00
#ifdef __cplusplus
}
#endif
#endif /* _PER_ENCODER_H_ */