aboutsummaryrefslogtreecommitdiffstats
path: root/libasn1parser/asn1p_module.c
diff options
context:
space:
mode:
authorLev Walkin <vlm@lionet.info>2004-06-03 03:38:44 +0000
committerLev Walkin <vlm@lionet.info>2004-06-03 03:38:44 +0000
commitf15320bf6b50a0c02636405561ac8323ae901abd (patch)
tree33461d45122896c6dde35f82f5c7d19b62004a6b /libasn1parser/asn1p_module.c
parent746cb60bbccf47019563665f4aec4b6c462c4163 (diff)
Initial revision
Diffstat (limited to 'libasn1parser/asn1p_module.c')
-rw-r--r--libasn1parser/asn1p_module.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/libasn1parser/asn1p_module.c b/libasn1parser/asn1p_module.c
new file mode 100644
index 00000000..d430844e
--- /dev/null
+++ b/libasn1parser/asn1p_module.c
@@ -0,0 +1,62 @@
+#include <stdlib.h>
+#include <string.h>
+
+#include "asn1parser.h"
+
+/*
+ * Construct a new empty module.
+ */
+asn1p_module_t *
+asn1p_module_new() {
+ asn1p_module_t *mod;
+
+ mod = calloc(1, sizeof *mod);
+ if(mod) {
+ TQ_INIT(&(mod->imports));
+ TQ_INIT(&(mod->exports));
+ TQ_INIT(&(mod->members));
+ }
+ return mod;
+}
+
+/*
+ * Destroy the module.
+ */
+void
+asn1p_module_free(asn1p_module_t *mod) {
+ if(mod) {
+ asn1p_expr_t *expr;
+
+ if(mod->Identifier)
+ free(mod->Identifier);
+
+ if(mod->module_oid)
+ asn1p_oid_free(mod->module_oid);
+
+ while((expr = TQ_REMOVE(&(mod->members), next)))
+ asn1p_expr_free(expr);
+
+ free(mod);
+ }
+}
+
+asn1p_t *
+asn1p_new() {
+ asn1p_t *asn;
+ asn = calloc(1, sizeof(*asn));
+ if(asn) {
+ TQ_INIT(&(asn->modules));
+ }
+ return asn;
+}
+
+
+void
+asn1p_free(asn1p_t *asn) {
+ if(asn) {
+ asn1p_module_t *mod;
+ while((mod = TQ_REMOVE(&(asn->modules), mod_next)))
+ asn1p_module_free(mod);
+ free(asn);
+ }
+}