summaryrefslogtreecommitdiff
path: root/local/mib2c-conf.d/details-enums.m2i
diff options
context:
space:
mode:
Diffstat (limited to 'local/mib2c-conf.d/details-enums.m2i')
-rw-r--r--local/mib2c-conf.d/details-enums.m2i80
1 files changed, 80 insertions, 0 deletions
diff --git a/local/mib2c-conf.d/details-enums.m2i b/local/mib2c-conf.d/details-enums.m2i
new file mode 100644
index 0000000..3b0f152
--- /dev/null
+++ b/local/mib2c-conf.d/details-enums.m2i
@@ -0,0 +1,80 @@
+############################################################# -*- c -*-
+## generic include for enums. Do not use directly.
+##
+## $Id$
+########################################################################
+@if $m2c_mark_boundary == 1@
+/** START code generated by $RCSfile$ $Revision$ */
+@end@
+########################################################################
+@ifconf $node.syntax.m2i@
+@ include $node.syntax.m2i@
+@else@
+##
+## Generating enums
+##
+## Examples:
+##
+## enums syntax perltype net-snmp type cdecl m2c_decl
+## ----- -------- -------- ------------- ----- -------
+## 1 SomeTC BITS ASN_OCTET_STR char u_long
+## 1 INTEGER INTEGER ASN_INTEGER long u_long
+## 1 RowStatus INTEGER ASN_INTEGER long u_long
+##
+/*************************************************************
+ * constants for enums for the MIB node
+ * $node ($node.syntax / $node.type)
+ *
+ * since a Textual Convention may be referenced more than once in a
+ * MIB, protect againt redefinitions of the enum values.
+ */
+##
+#ifndef ${m2c_de_pfx}_ENUMS
+#define ${m2c_de_pfx}_ENUMS
+
+@ eval $m2c_mask=""@
+@ foreach $e $v enum@
+@ include m2c_setup_enum.m2i@
+@ if "$node.perltype" eq "BITS"@
+@ if $v > 31@
+@ print ** ACK! I cannot handle BITS longer than 4 bytes!@
+@ exit@
+@ end@
+@ if "x$m2c_mask" eq "x"@
+@ eval $m2c_mask="$m2c_ename"@
+@ else@
+@ eval $m2c_mask="$m2c_mask | $m2c_ename"@
+@ end@
+$m2c_const_dcl $m2c_ename $m2c_const_del (1 << (31-$v)) $m2c_const_sfx
+@ else@
+$m2c_const_dcl $m2c_ename $m2c_const_del $v $m2c_const_sfx
+@ end@
+@ end@ # for each
+
+#endif /* ${m2c_de_pfx}_ENUMS */
+
+@ if "$node.perltype" eq "BITS"@
+$m2c_const_dcl $m2c_enum_mask $m2c_const_del ($m2c_mask)
+
+@ end@
+@ if ($m2c_node_skip_mapping != 1) && ($node.enums == 1)@
+ /*
+ * TODO:140:o: Define your interal representation of $node enums.
+ * (used for value mapping; see notes at top of file)
+ */
+@ foreach $e $v enum@
+@ include m2c_setup_enum.m2i@
+@ if ("$node.perltype" ne "BITS")@
+$m2c_const_dcl INTERNAL_$context.uc_$m2c_iname $m2c_const_del $v $m2c_const_sfx
+@ else@
+$m2c_const_dcl INTERNAL_$context.uc_$m2c_iname $m2c_const_del (0x01 << $v) $m2c_const_sfx
+@ end@
+@ end@ // foreach
+
+@ end@ // skip mapping / enums
+
+@end@ # ! syntax include
+########################################################################
+@if $m2c_mark_boundary == 1@
+/** END code generated by $RCSfile$ $Revision$ */
+@end@