2 * Structures and prototypes related to parameterization
4 #ifndef ASN1_NAMESPACE_H
5 #define ASN1_NAMESPACE_H
7 struct asn1p_ref_s; /* Forward declaration */
8 struct asn1p_expr_s; /* Forward declaration */
9 struct asn1p_module_s; /* Forward declaration */
11 typedef struct asn1_namespace_s {
12 struct asn1_namespace_element_s {
14 NAM_SPACE, /* The whole search space (e.g. Module) */
15 NAM_SYMBOL, /* A particular symbol */
19 struct asn1p_module_s *module;
20 int stop_search; /* This module MUST contain the symbol */
23 struct asn1p_ref_s *opt_governor; /* optional */
25 struct asn1p_expr_s *resolution;
29 size_t elements_count;
34 * Set callback used to initialize standard namespaces.
36 void asn1_namespace_add_standard_namespaces_callback(
37 void (*)(asn1_namespace_t *));
39 asn1_namespace_t *asn1_namespace_new(void);
40 void asn1_namespace_free(asn1_namespace_t *);
42 asn1_namespace_t *asn1_namespace_clone(const asn1_namespace_t *);
44 asn1_namespace_t *asn1_namespace_new_from_module(struct asn1p_module_s *mod, int stop_search);
46 void asn1_namespace_add_module(asn1_namespace_t *,
47 struct asn1p_module_s *module, int stop_search);
49 void asn1_namespace_add_symbol(asn1_namespace_t *,
50 struct asn1p_ref_s *opt_governor,
51 const char *identifier,
52 struct asn1p_expr_s *resolved_argument);
55 * Human-readable namespace layout.
56 * Returns a reference to a statically allocated string.
58 const char *asn1_namespace_string(const asn1_namespace_t *);
61 * Create a new namespace by cloning (ns1) and adding (ns2) on top.
64 asn1_namespace_t *asn1_namespace_new_ND(const asn1_namespace_t *ns1,
65 asn1_namespace_t *ns2);
68 * Introduce and destroy namespace around the given code.
69 * This aids memory management around dynamic namespaces.
71 #define WITH_MODULE_NAMESPACE(mod, ns_var, code) \
73 struct asn1_namespace_s *ns_var = \
74 asn1_namespace_new_from_module(mod, 1); \
75 typeof(code) ret = code; \
76 asn1_namespace_free(ns_var); \
80 #endif /* ASN1_NAMESPACE_H */