Adding initial code jy.oak@samsung.com
[ric-app/kpimon.git] / asn1c_defs / all-defs / constraints.h
diff --git a/asn1c_defs/all-defs/constraints.h b/asn1c_defs/all-defs/constraints.h
new file mode 100755 (executable)
index 0000000..37b89b1
--- /dev/null
@@ -0,0 +1,62 @@
+/*-\r
+ * Copyright (c) 2004-2017 Lev Walkin <vlm@lionet.info>. All rights reserved.\r
+ * Redistribution and modifications are permitted subject to BSD license.\r
+ */\r
+#ifndef        ASN1_CONSTRAINTS_VALIDATOR_H\r
+#define        ASN1_CONSTRAINTS_VALIDATOR_H\r
+\r
+#include <asn_system.h>                /* Platform-dependent types */\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+struct asn_TYPE_descriptor_s;          /* Forward declaration */\r
+\r
+/*\r
+ * Validate the structure according to the ASN.1 constraints.\r
+ * If errbuf and errlen are given, they shall be pointing to the appropriate\r
+ * buffer space and its length before calling this function. Alternatively,\r
+ * they could be passed as NULL's. If constraints validation fails,\r
+ * errlen will contain the actual number of bytes taken from the errbuf\r
+ * to encode an error message (properly 0-terminated).\r
+ * \r
+ * RETURN VALUES:\r
+ * This function returns 0 in case all ASN.1 constraints are met\r
+ * and -1 if one or more constraints were failed.\r
+ */\r
+int asn_check_constraints(\r
+    const struct asn_TYPE_descriptor_s *type_descriptor,\r
+    const void *struct_ptr, /* Target language's structure */\r
+    char *errbuf,           /* Returned error description */\r
+    size_t *errlen          /* Length of the error description */\r
+);\r
+\r
+\r
+/*\r
+ * Generic type for constraint checking callback,\r
+ * associated with every type descriptor.\r
+ */\r
+typedef int(asn_constr_check_f)(\r
+    const struct asn_TYPE_descriptor_s *type_descriptor, const void *struct_ptr,\r
+    asn_app_constraint_failed_f *optional_callback, /* Log the error */\r
+    void *optional_app_key /* Opaque key passed to a callback */\r
+);\r
+\r
+/*******************************\r
+ * INTERNALLY USEFUL FUNCTIONS *\r
+ *******************************/\r
+\r
+asn_constr_check_f asn_generic_no_constraint;  /* No constraint whatsoever */\r
+asn_constr_check_f asn_generic_unknown_constraint; /* Not fully supported */\r
+\r
+/*\r
+ * Invoke the callback with a complete error message.\r
+ */\r
+#define        ASN__CTFAIL     if(ctfailcb) ctfailcb\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* ASN1_CONSTRAINTS_VALIDATOR_H */\r