Adding initial code jy.oak@samsung.com
[ric-app/kpimon.git] / asn1c_defs / all-defs / asn_SET_OF.h
diff --git a/asn1c_defs/all-defs/asn_SET_OF.h b/asn1c_defs/all-defs/asn_SET_OF.h
new file mode 100755 (executable)
index 0000000..4a21409
--- /dev/null
@@ -0,0 +1,72 @@
+/*-\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_SET_OF_H\r
+#define        ASN_SET_OF_H\r
+\r
+#ifdef __cplusplus\r
+#define A_SET_OF(type)                   \\r
+    struct {                             \\r
+        type **array;                    \\r
+        int count; /* Meaningful size */ \\r
+        int size;  /* Allocated size */  \\r
+        void (*free)(decltype(*array));  \\r
+    }\r
+#else   /* C */\r
+#define A_SET_OF(type)                   \\r
+    struct {                             \\r
+        type **array;                    \\r
+        int count; /* Meaningful size */ \\r
+        int size;  /* Allocated size */  \\r
+        void (*free)(type *);    \\r
+    }\r
+#endif\r
+\r
+#ifdef __cplusplus\r
+extern "C" {\r
+#endif\r
+\r
+#define        ASN_SET_ADD(headptr, ptr)               \\r
+       asn_set_add((headptr), (ptr))\r
+\r
+/*******************************************\r
+ * Implementation of the SET OF structure.\r
+ */\r
+\r
+/*\r
+ * Add another structure into the set by its pointer.\r
+ * RETURN VALUES:\r
+ * 0 for success and -1/errno for failure.\r
+ */\r
+int  asn_set_add(void *asn_set_of_x, void *ptr);\r
+\r
+/*\r
+ * Delete the element from the set by its number (base 0).\r
+ * This is a constant-time operation. The order of elements before the\r
+ * deleted ones is guaranteed, the order of elements after the deleted\r
+ * one is NOT guaranteed.\r
+ * If _do_free is given AND the (*free) is initialized, the element\r
+ * will be freed using the custom (*free) function as well.\r
+ */\r
+void asn_set_del(void *asn_set_of_x, int number, int _do_free);\r
+\r
+/*\r
+ * Empty the contents of the set. Will free the elements, if (*free) is given.\r
+ * Will NOT free the set itself.\r
+ */\r
+void asn_set_empty(void *asn_set_of_x);\r
+\r
+/*\r
+ * Cope with different conversions requirements to/from void in C and C++.\r
+ * This is mostly useful for support library.\r
+ */\r
+typedef A_SET_OF(void) asn_anonymous_set_;\r
+#define _A_SET_FROM_VOID(ptr)          ((asn_anonymous_set_ *)(ptr))\r
+#define _A_CSET_FROM_VOID(ptr)         ((const asn_anonymous_set_ *)(ptr))\r
+\r
+#ifdef __cplusplus\r
+}\r
+#endif\r
+\r
+#endif /* ASN_SET_OF_H */\r