summaryrefslogtreecommitdiff
path: root/local/mib2c-conf.d/details-enums.m2i
blob: 3b0f152263a2029d239536914a7c3e833af0ef4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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@