1
1
############################################################# -*- c -*-
2
2
## generic include for XXX. Do not use directly.
4
## $Id: generic-ctx-get.m2i,v 1.10.2.1 2005/07/25 23:13:52 rstory Exp $
4
## $Id: generic-ctx-get.m2i,v 1.13 2005/09/27 17:05:53 rstory Exp $
5
5
########################################################################
6
6
@if $m2c_mark_boundary == 1@
7
/** START code generated by $RCSfile: generic-ctx-get.m2i,v $ $Revision: 1.10.2.1 $ */
7
/** START code generated by $RCSfile: generic-ctx-get.m2i,v $ $Revision: 1.13 $ */
9
9
########################################################################
31
31
@if "$m2c_data_context" ne "generated"@
32
32
/** WARNING: this code might not work for $m2c_data_context */
34
##/* set up for length/copy conversions for various cases.
35
## length mod applies to left hand side. copy mod applies to right hand side
38
@if ("$m2c_ctx_rhu" ne "elements") && ("$m2c_ctx_rhu" ne "bytes")@
39
@ print Invalid rh units '$m2c_ctx_rhu'@
42
@if ("$m2c_ctx_lhu" ne "elements") && ("$m2c_ctx_lhu" ne "bytes")@
43
@ print Invalid lh units '$m2c_ctx_lhu'@
46
@if "$m2c_ctx_rhu" ne "$m2c_ctx_lhu"@
47
##/* elements = bytes, length mod="/sizeof", copy mult="" */
48
@ if "$m2c_ctx_lhu" eq "elements"@
49
@ eval $m2c_ctx_lm = "/ sizeof($m2c_ctx_rh[0])"@
50
@ eval $m2c_ctx_cm = ""@
52
##/* bytes = elements, length mod="*sizeof", copy mult="sizeof" */
53
@ eval $m2c_ctx_lm = "* sizeof($m2c_ctx_rh[0])"@
54
@ eval $m2c_ctx_cm = "* sizeof($m2c_ctx_rh[0])"@
57
##/* elements = elements, length mod="", copy mult="sizeof" */
58
@ if "$m2c_ctx_lhu" eq "elements"@
59
@ eval $m2c_ctx_lm = ""@
60
@ eval $m2c_ctx_cm = "* sizeof($m2c_ctx_rh[0])"@
62
##/* bytes = bytes, length mod="", copy mult="" */
63
@ eval $m2c_ctx_lm = ""@
64
@ eval $m2c_ctx_cm = ""@
34
67
@if $m2c_node_needlength == 1@
36
69
* make sure there is enough space for $node data
38
71
if ((NULL == $m2c_ctx_lh) ||
39
($m2c_ctx_lhs < ($m2c_ctx_rhs * sizeof(${m2c_ctx_lh}[0])))) {
73
($m2c_ctx_rhs$m2c_ctx_lm))) {
40
74
@ if $m2c_node_realloc == 0@
41
75
snmp_log(LOG_ERR,"not enough space for value\n");
45
79
* allocate space for $node data
47
81
@ if $m2c_node_realloc == 1@
48
$m2c_ctx_lh = realloc($m2c_ctx_lh, $m2c_ctx_rhs * sizeof(${m2c_ctx_lh}[0]));
82
$m2c_ctx_lh = realloc($m2c_ctx_lh, $m2c_ctx_rhs$m2c_ctx_cm );
50
$m2c_ctx_lh = malloc($m2c_ctx_rhs * sizeof(${m2c_ctx_lh}[0]));
84
$m2c_ctx_lh = malloc($m2c_ctx_rhs$m2c_ctx_cm);
52
86
if(NULL == $m2c_ctx_lh) {
53
87
snmp_log(LOG_ERR,"could not allocate memory\n");
58
$m2c_ctx_lhs = $m2c_ctx_rhs * sizeof(${m2c_ctx_lh}[0]);
59
memcpy( $m2c_ctx_lh, $m2c_ctx_rh, $m2c_ctx_lhs );
92
$m2c_ctx_lhs = $m2c_ctx_rhs$m2c_ctx_lm;
93
memcpy( $m2c_ctx_lh, $m2c_ctx_rh, $m2c_ctx_rhs$m2c_ctx_cm );
61
95
@ if $node.decl =~ /U64/i@ # ASN_COUNTER64
62
96
${m2c_ctx_lh}.high = ${m2c_ctx_rh}.high;
69
103
########################################################################
70
104
@if $m2c_mark_boundary == 1@
71
/** END code generated by $RCSfile: generic-ctx-get.m2i,v $ $Revision: 1.10.2.1 $ */
105
/** END code generated by $RCSfile: generic-ctx-get.m2i,v $ $Revision: 1.13 $ */