~ubuntu-branches/ubuntu/trusty/net-snmp/trusty

« back to all changes in this revision

Viewing changes to local/mib2c-conf.d/generic-ctx-get.m2i

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2007-05-10 22:20:23 UTC
  • mto: (1.4.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: james.westby@ubuntu.com-20070510222023-3fr07xb9i17xvq32
Tags: upstream-5.3.1
ImportĀ upstreamĀ versionĀ 5.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#############################################################  -*- c -*-
2
2
## generic include for XXX. Do not use directly.
3
3
##
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 $ */
8
8
@end@
9
9
########################################################################
10
10
##/*
31
31
@if "$m2c_data_context" ne "generated"@
32
32
    /** WARNING: this code might not work for $m2c_data_context */
33
33
@end@
 
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
 
36
##
 
37
##*/
 
38
@if ("$m2c_ctx_rhu" ne "elements") && ("$m2c_ctx_rhu" ne "bytes")@
 
39
@   print Invalid rh units '$m2c_ctx_rhu'@
 
40
@   exit@
 
41
@end@
 
42
@if ("$m2c_ctx_lhu" ne "elements") && ("$m2c_ctx_lhu" ne "bytes")@
 
43
@   print Invalid lh units '$m2c_ctx_lhu'@
 
44
@   exit@
 
45
@end@
 
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 = ""@
 
51
@   else@
 
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])"@
 
55
@   end@
 
56
@else@
 
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])"@
 
61
@   else@
 
62
##/*     bytes    = bytes,    length mod="",        copy mult="" */
 
63
@      eval $m2c_ctx_lm = ""@
 
64
@      eval $m2c_ctx_cm = ""@
 
65
@   end@
 
66
@end@
34
67
@if $m2c_node_needlength == 1@
35
68
    /*
36
69
     * make sure there is enough space for $node data
37
70
     */
38
71
    if ((NULL == $m2c_ctx_lh) ||
39
 
        ($m2c_ctx_lhs < ($m2c_ctx_rhs * sizeof(${m2c_ctx_lh}[0])))) {
 
72
        ($m2c_ctx_lhs <
 
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");
42
76
        return MFD_ERROR;
45
79
         * allocate space for $node data
46
80
         */
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 );
49
83
@      else@
50
 
        $m2c_ctx_lh = malloc($m2c_ctx_rhs * sizeof(${m2c_ctx_lh}[0]));
 
84
        $m2c_ctx_lh = malloc($m2c_ctx_rhs$m2c_ctx_cm);
51
85
@      end@
52
86
        if(NULL == $m2c_ctx_lh) {
53
87
            snmp_log(LOG_ERR,"could not allocate memory\n");
55
89
        }
56
90
@   end@
57
91
    }
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 );
60
94
@else@
61
95
@   if $node.decl =~ /U64/i@ #              ASN_COUNTER64
62
96
    ${m2c_ctx_lh}.high = ${m2c_ctx_rh}.high;
68
102
##
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 $ */
72
106
@end@