blob: fbc557648d15b502afe31b6fa1a5b8a3e86afafd [file] [log] [blame]
Lev Walkin4fd73182004-10-21 11:20:50 +00001/*-
Lev Walkin20696a42017-10-17 21:27:33 -07002 * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.
Lev Walkin4fd73182004-10-21 11:20:50 +00003 * Redistribution and modifications are permitted subject to BSD license.
4 */
5#ifndef ASN_CODECS_PRIM_H
6#define ASN_CODECS_PRIM_H
7
8#include <asn_application.h>
9
Lev Walkin21b41ac2005-07-24 09:03:44 +000010#ifdef __cplusplus
11extern "C" {
12#endif
13
Lev Walkin4fd73182004-10-21 11:20:50 +000014typedef struct ASN__PRIMITIVE_TYPE_s {
Lev Walkinbbe79252017-11-18 12:06:49 -080015 uint8_t *buf; /* Buffer with consecutive primitive encoding bytes */
Lev Walkin494fb702017-08-07 20:07:00 -070016 size_t size; /* Size of the buffer */
Lev Walkin4fd73182004-10-21 11:20:50 +000017} ASN__PRIMITIVE_TYPE_t; /* Do not use this type directly! */
18
19asn_struct_free_f ASN__PRIMITIVE_TYPE_free;
20ber_type_decoder_f ber_decode_primitive;
21der_type_encoder_f der_encode_primitive;
22
23/*
Lev Walkin0fab1a62005-03-09 22:19:25 +000024 * A callback specification for the xer_decode_primitive() function below.
25 */
26enum xer_pbd_rval {
Lev Walkinbbe79252017-11-18 12:06:49 -080027 XPBD_SYSTEM_FAILURE, /* System failure (memory shortage, etc) */
28 XPBD_DECODER_LIMIT, /* Hit some decoder limitation or deficiency */
29 XPBD_BROKEN_ENCODING, /* Encoding of a primitive body is broken */
30 XPBD_NOT_BODY_IGNORE, /* Not a body format, but safe to ignore */
31 XPBD_BODY_CONSUMED /* Body is recognized and consumed */
Lev Walkin0fab1a62005-03-09 22:19:25 +000032};
Lev Walkin20696a42017-10-17 21:27:33 -070033typedef enum xer_pbd_rval(xer_primitive_body_decoder_f)(
Lev Walkinbbe79252017-11-18 12:06:49 -080034 const asn_TYPE_descriptor_t *td, void *struct_ptr, const void *chunk_buf,
35 size_t chunk_size);
Lev Walkin0fab1a62005-03-09 22:19:25 +000036
37/*
Lev Walkin8471cec2004-10-21 14:02:19 +000038 * Specific function to decode simple primitive types.
Lev Walkin4fd73182004-10-21 11:20:50 +000039 * Also see xer_decode_general() in xer_decoder.h
40 */
Lev Walkin20696a42017-10-17 21:27:33 -070041asn_dec_rval_t xer_decode_primitive(
42 const asn_codec_ctx_t *opt_codec_ctx,
43 const asn_TYPE_descriptor_t *type_descriptor, void **struct_ptr,
44 size_t struct_size, const char *opt_mname, const void *buf_ptr, size_t size,
45 xer_primitive_body_decoder_f *prim_body_decoder);
Lev Walkin4fd73182004-10-21 11:20:50 +000046
Lev Walkin21b41ac2005-07-24 09:03:44 +000047#ifdef __cplusplus
48}
49#endif
50
Lev Walkin4fd73182004-10-21 11:20:50 +000051#endif /* ASN_CODECS_PRIM_H */