Adding initial code jy.oak@samsung.com
[ric-app/kpimon.git] / asn1c_defs / all-defs / asn_codecs.h
diff --git a/asn1c_defs/all-defs/asn_codecs.h b/asn1c_defs/all-defs/asn_codecs.h
new file mode 100755 (executable)
index 0000000..5a6d9f7
--- /dev/null
@@ -0,0 +1,108 @@
+/*\r
+ * Copyright (c) 2003-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.\r
+ * Redistribution and modifications are permitted subject to BSD license.\r
+ */\r
+#ifndef        ASN_CODECS_H\r
+#define        ASN_CODECS_H\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+struct asn_TYPE_descriptor_s;  /* Forward declaration */\r
+\r
+/*\r
+ * This structure defines a set of parameters that may be passed\r
+ * to every ASN.1 encoder or decoder function.\r
+ * WARNING: if max_stack_size member is set, and you are calling the\r
+ *   function pointers of the asn_TYPE_descriptor_t directly,\r
+ *   this structure must be ALLOCATED ON THE STACK!\r
+ *   If you can't always satisfy this requirement, use ber_decode(),\r
+ *   xer_decode() and uper_decode() functions instead.\r
+ */\r
+typedef struct asn_codec_ctx_s {\r
+       /*\r
+        * Limit the decoder routines to use no (much) more stack than a given\r
+        * number of bytes. Most of decoders are stack-based, and this\r
+        * would protect against stack overflows if the number of nested\r
+        * encodings is high.\r
+        * The OCTET STRING, BIT STRING and ANY BER decoders are heap-based,\r
+        * and are safe from this kind of overflow.\r
+        * A value from getrlimit(RLIMIT_STACK) may be used to initialize\r
+        * this variable. Be careful in multithreaded environments, as the\r
+        * stack size is rather limited.\r
+        */\r
+       size_t  max_stack_size; /* 0 disables stack bounds checking */\r
+} asn_codec_ctx_t;\r
+\r
+/*\r
+ * Type of the return value of the encoding functions (der_encode, xer_encode).\r
+ */\r
+typedef struct asn_enc_rval_s {\r
+       /*\r
+        * Number of bytes encoded.\r
+        * -1 indicates failure to encode the structure.\r
+        * In this case, the members below this one are meaningful.\r
+        */\r
+       ssize_t encoded;\r
+\r
+       /*\r
+        * Members meaningful when (encoded == -1), for post mortem analysis.\r
+        */\r
+\r
+       /* Type which cannot be encoded */\r
+       const struct asn_TYPE_descriptor_s *failed_type;\r
+\r
+       /* Pointer to the structure of that type */\r
+       const void *structure_ptr;\r
+} asn_enc_rval_t;\r
+#define        ASN__ENCODE_FAILED do {                                 \\r
+       asn_enc_rval_t tmp_error;                               \\r
+       tmp_error.encoded = -1;                                 \\r
+       tmp_error.failed_type = td;                             \\r
+       tmp_error.structure_ptr = sptr;                         \\r
+       ASN_DEBUG("Failed to encode element %s", td ? td->name : "");   \\r
+       return tmp_error;                                       \\r
+} while(0)\r
+#define        ASN__ENCODED_OK(rval) do {                              \\r
+       rval.structure_ptr = 0;                                 \\r
+       rval.failed_type = 0;                                   \\r
+       return rval;                                            \\r
+} while(0)\r
+\r
+/*\r
+ * Type of the return value of the decoding functions (ber_decode, xer_decode)\r
+ * \r
+ * Please note that the number of consumed bytes is ALWAYS meaningful,\r
+ * even if code==RC_FAIL. This is to indicate the number of successfully\r
+ * decoded bytes, hence providing a possibility to fail with more diagnostics\r
+ * (i.e., print the offending remainder of the buffer).\r
+ */\r
+enum asn_dec_rval_code_e {\r
+       RC_OK,          /* Decoded successfully */\r
+       RC_WMORE,       /* More data expected, call again */\r
+       RC_FAIL         /* Failure to decode data */\r
+};\r
+typedef struct asn_dec_rval_s {\r
+       enum asn_dec_rval_code_e code;  /* Result code */\r
+       size_t consumed;                /* Number of bytes consumed */\r
+} asn_dec_rval_t;\r
+#define        ASN__DECODE_FAILED do {                                 \\r
+       asn_dec_rval_t tmp_error;                               \\r
+       tmp_error.code = RC_FAIL;                               \\r
+       tmp_error.consumed = 0;                                 \\r
+       ASN_DEBUG("Failed to decode element %s", td ? td->name : "");   \\r
+       return tmp_error;                                       \\r
+} while(0)\r
+#define        ASN__DECODE_STARVED do {                                \\r
+       asn_dec_rval_t tmp_error;                               \\r
+       tmp_error.code = RC_WMORE;                              \\r
+       tmp_error.consumed = 0;                                 \\r
+       return tmp_error;                                       \\r
+} while(0)\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* ASN_CODECS_H */\r