Revert "Revert "and added files""
[bcm963xx.git] / userapps / opensource / net-snmp / local / mib2c.int_watch.conf
1 ## -*- c -*-
2 ######################################################################
3 ## Do the .h file
4 ######################################################################
5 @open -@
6 *** Warning: only generating code for nodes of MIB type INTEGER
7 @open ${name}.h@
8 /*
9  * Note: this file originally auto-generated by mib2c using
10  *        $Id: mib2c.int_watch.conf,v 1.2 2002/07/17 14:41:53 dts12 Exp $
11  */
12 #ifndef $name.uc_H
13 #define $name.uc_H
14
15 /* function declarations */
16 void init_$name(void);
17
18 #endif /* $name.uc_H */
19 ######################################################################
20 ## Do the .c file
21 ######################################################################
22 @open ${name}.c@
23 /*
24  * Note: this file originally auto-generated by mib2c using
25  *        $Id: mib2c.int_watch.conf,v 1.2 2002/07/17 14:41:53 dts12 Exp $
26  */
27
28 #include <net-snmp/net-snmp-config.h>
29 #include <net-snmp/net-snmp-includes.h>
30 #include <net-snmp/agent/net-snmp-agent-includes.h>
31 #include "${name}.h"
32
33 /* the variable we want to tie an OID to.  The agent will handle all
34  * GET and SET requests to this variable changing its value as needed.
35  */
36
37 @foreach $i scalar@
38     @if $i.type eq "ASN_INTEGER"@
39 static int      $i = 0;  /* XXX: set default value */
40     @end@
41 @end@
42
43 /*
44  * our initialization routine, automatically called by the agent 
45  * (to get called, the function name must match init_FILENAME()) 
46  */
47 void
48 init_${name}(void)
49 {
50   @foreach $i scalar@
51     @if $i.type eq "ASN_INTEGER"@
52     static oid ${i}_oid[] = { $i.commaoid, 0 };
53     @end@
54   @end@
55
56   /*
57    * a debugging statement.  Run the agent with -D$name to see
58    * the output of this debugging statement. 
59    */
60   DEBUGMSGTL(("$name", "Initializing the $name module\n"));
61
62
63     /*
64      * the line below registers our variables defined above as
65      * accessible and makes them writable.  A read only version of any
66      * of these registrations would merely call
67      * register_read_only_int_instance() instead.  The functions
68      * called below should be consistent with your MIB, however.
69      * 
70      * If you wanted a callback when the value was retrieved or set
71      * (even though the details of doing this are handled for you),
72      * you could change the NULL pointer below to a valid handler
73      * function. 
74      */
75   @foreach $i scalar@
76     @if $i.type eq "ASN_INTEGER"@
77     DEBUGMSGTL(("$name",
78                 "Initializing $i scalar integer.  Default value = %d\n",
79                 $i));
80     @if $i.settable@
81       netsnmp_register_int_instance("$i",
82                                     ${i}_oid,
83                                     OID_LENGTH(${i}_oid),
84                                     &$i, NULL);
85     @end@
86     @if !$i.settable@
87       netsnmp_register_read_only_int_instance("$i",
88                                               ${i}_oid,
89                                               OID_LENGTH(${i}_oid),
90                                               &$i, NULL);
91     @end@
92     @end@
93   @end@
94
95   DEBUGMSGTL(("$name",
96               "Done initalizing $name module\n"));
97 }