Adding initial code jy.oak@samsung.com
[ric-app/kpimon.git] / asn1c_defs / all-defs / constr_TYPE.c
diff --git a/asn1c_defs/all-defs/constr_TYPE.c b/asn1c_defs/all-defs/constr_TYPE.c
new file mode 100755 (executable)
index 0000000..cece6ce
--- /dev/null
@@ -0,0 +1,80 @@
+/*-\r
+ * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.\r
+ * Redistribution and modifications are permitted subject to BSD license.\r
+ */\r
+#include <asn_internal.h>\r
+#include <constr_TYPE.h>\r
+#include <errno.h>\r
+\r
+/*\r
+ * Version of the ASN.1 infrastructure shipped with compiler.\r
+ */\r
+int get_asn1c_environment_version() { return ASN1C_ENVIRONMENT_VERSION; }\r
+\r
+static asn_app_consume_bytes_f _print2fp;\r
+\r
+/*\r
+ * Return the outmost tag of the type.\r
+ */\r
+ber_tlv_tag_t\r
+asn_TYPE_outmost_tag(const asn_TYPE_descriptor_t *type_descriptor,\r
+               const void *struct_ptr, int tag_mode, ber_tlv_tag_t tag) {\r
+\r
+       if(tag_mode)\r
+               return tag;\r
+\r
+       if(type_descriptor->tags_count)\r
+               return type_descriptor->tags[0];\r
+\r
+       return type_descriptor->op->outmost_tag(type_descriptor, struct_ptr, 0, 0);\r
+}\r
+\r
+/*\r
+ * Print the target language's structure in human readable form.\r
+ */\r
+int\r
+asn_fprint(FILE *stream, const asn_TYPE_descriptor_t *td,\r
+           const void *struct_ptr) {\r
+    if(!stream) stream = stdout;\r
+    if(!td || !struct_ptr) {\r
+        errno = EINVAL;\r
+        return -1;\r
+       }\r
+\r
+       /* Invoke type-specific printer */\r
+    if(td->op->print_struct(td, struct_ptr, 1, _print2fp, stream)) {\r
+        return -1;\r
+    }\r
+\r
+    /* Terminate the output */\r
+    if(_print2fp("\n", 1, stream)) {\r
+        return -1;\r
+    }\r
+\r
+    return fflush(stream);\r
+}\r
+\r
+/* Dump the data into the specified stdio stream */\r
+static int\r
+_print2fp(const void *buffer, size_t size, void *app_key) {\r
+       FILE *stream = (FILE *)app_key;\r
+\r
+       if(fwrite(buffer, 1, size, stream) != size)\r
+               return -1;\r
+\r
+       return 0;\r
+}\r
+\r
+\r
+/*\r
+ * Some compilers do not support variable args macros.\r
+ * This function is a replacement of ASN_DEBUG() macro.\r
+ */\r
+void ASN_DEBUG_f(const char *fmt, ...);\r
+void ASN_DEBUG_f(const char *fmt, ...) {\r
+       va_list ap;\r
+       va_start(ap, fmt);\r
+       vfprintf(stderr, fmt, ap);\r
+       fprintf(stderr, "\n");\r
+       va_end(ap);\r
+}\r