Adding initial code jy.oak@samsung.com
[ric-app/kpimon.git] / asn1c_defs / all-defs / per_encoder.h
1 /*-\r
2  * Copyright (c) 2006-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.\r
3  * Redistribution and modifications are permitted subject to BSD license.\r
4  */\r
5 #ifndef _PER_ENCODER_H_\r
6 #define _PER_ENCODER_H_\r
7 \r
8 #include <asn_application.h>\r
9 #include <per_support.h>\r
10 \r
11 #ifdef __cplusplus\r
12 extern "C" {\r
13 #endif\r
14 \r
15 struct asn_TYPE_descriptor_s;   /* Forward declaration */\r
16 \r
17 /*\r
18  * Unaligned PER encoder of any ASN.1 type. May be invoked by the application.\r
19  * WARNING: This function returns the number of encoded bits in the .encoded\r
20  * field of the return value. Use the following formula to convert to bytes:\r
21  *      bytes = ((.encoded + 7) / 8)\r
22  */\r
23 asn_enc_rval_t uper_encode(\r
24     const struct asn_TYPE_descriptor_s *type_descriptor,\r
25     const asn_per_constraints_t *constraints,\r
26     const void *struct_ptr,                    /* Structure to be encoded */\r
27     asn_app_consume_bytes_f *consume_bytes_cb, /* Data collector */\r
28     void *app_key                              /* Arbitrary callback argument */\r
29 );\r
30 \r
31 asn_enc_rval_t aper_encode(\r
32     const struct asn_TYPE_descriptor_s *type_descriptor,\r
33     const asn_per_constraints_t *constraints,\r
34     const void *struct_ptr,                     /* Structure to be encoded */\r
35     asn_app_consume_bytes_f *consume_bytes_cb,  /* Data collector */\r
36     void *app_key                               /* Arbitrary callback argument */\r
37 );\r
38 \r
39 /*\r
40  * A variant of uper_encode() which encodes data into the existing buffer\r
41  * WARNING: This function returns the number of encoded bits in the .encoded\r
42  * field of the return value.\r
43  */\r
44 asn_enc_rval_t uper_encode_to_buffer(\r
45     const struct asn_TYPE_descriptor_s *type_descriptor,\r
46     const asn_per_constraints_t *constraints,\r
47     const void *struct_ptr, /* Structure to be encoded */\r
48     void *buffer,           /* Pre-allocated buffer */\r
49     size_t buffer_size      /* Initial buffer size (max) */\r
50 );\r
51 \r
52 asn_enc_rval_t aper_encode_to_buffer(\r
53     const struct asn_TYPE_descriptor_s *type_descriptor,\r
54     const asn_per_constraints_t *constraints,\r
55     const void *struct_ptr,  /* Structure to be encoded */\r
56     void *buffer,            /* Pre-allocated buffer */\r
57     size_t buffer_size       /* Initial buffer size (max) */\r
58 );\r
59 /*\r
60  * A variant of uper_encode_to_buffer() which allocates buffer itself.\r
61  * Returns the number of bytes in the buffer or -1 in case of failure.\r
62  * WARNING: This function produces a "Production of the complete encoding",\r
63  * with length of at least one octet. Contrast this to precise bit-packing\r
64  * encoding of uper_encode() and uper_encode_to_buffer().\r
65  */\r
66 ssize_t uper_encode_to_new_buffer(\r
67     const struct asn_TYPE_descriptor_s *type_descriptor,\r
68     const asn_per_constraints_t *constraints,\r
69     const void *struct_ptr, /* Structure to be encoded */\r
70     void **buffer_r         /* Buffer allocated and returned */\r
71 );\r
72 \r
73 ssize_t\r
74 aper_encode_to_new_buffer(\r
75     const struct asn_TYPE_descriptor_s *td,\r
76     const asn_per_constraints_t *constraints,\r
77     const void *sptr,\r
78     void **buffer_r\r
79 );\r
80 \r
81 /*\r
82  * Type of the generic PER encoder function.\r
83  */\r
84 typedef asn_enc_rval_t(per_type_encoder_f)(\r
85     const struct asn_TYPE_descriptor_s *type_descriptor,\r
86     const asn_per_constraints_t *constraints, const void *struct_ptr,\r
87     asn_per_outp_t *per_output);\r
88 \r
89 #ifdef __cplusplus\r
90 }\r
91 #endif\r
92 \r
93 #endif  /* _PER_ENCODER_H_ */\r