A very strange problem(about the code structure when set mib2c -S cache=0)
When my uit.h file is something like this:
[SKIP]
void initialize_table_hostInterFCTable(void);
Netsnmp_Node_Handler hostInterFCTable_handler;
Netsnmp_First_Data_Point hostInterFCTable_get_first_data_point;
Netsnmp_Next_Data_Point hostInterFCTable_get_next_data_point;
NetsnmpCacheLoad hostInterFCTable_load;
NetsnmpCacheFree hostInterFCTable_free;
#define HOSTINTERFCTABLE_TIMEOUT 60
[SKIP]
I got something like this:
[SKIP]
uit.c: In function ‘init_uit’:
uit.c:189: warning: useless type name in empty declaration
uit.c: At top level:
uit.c:2852: error: conflicting types for ‘hostInterFCTable_free’
uit.h:93: error: previous declaration of ‘hostInterFCTable_free’ was here
[SKIP]
and uit.c source code correspond like this:
[SKIP]
/* Typical data structure for a row entry */
struct hostInterFCTable_entry {
/* Index values */
[SKIP]
/* Illustrate using a simple linked list */
int valid;
struct hostInterFCTable_entry *next;
};
struct hostInterFCTable_entry *hostInterFCTable_head;
/* create a new row in the (unsorted) table */
struct hostInterFCTable_entry *
hostInterFCTable_createEntry(
[SKIP]
) {
struct hostInterFCTable_entry *entry;
entry = SNMP_MALLOC_TYPEDEF(struct hostInterFCTable_entry);
if (!entry)
return NULL;
[SKIP]
}
/* # Determine the first/last column names */
/** Initialize the hostInterFCTable table by defining its contents and how
it's structured */
void
initialize_table_hostInterFCTable(void)
{
PRINT_SNMP(__FUNCTION__,__LINE__);
static oid hostInterFCTable_oid[] = {1,3,6,1,4,1,30901,2090,7000,2,1,5,1};
size_t hostInterFCTable_oid_len = OID_LENGTH(hostInterFCTable_oid);
netsnmp_handler_registration *reg;
netsnmp_iterator_info *iinfo;
netsnmp_table_registration_info *table_info;
reg = netsnmp_create_handler_registration(
"hostInterFCTable", hostInterFCTable_handler,
hostInterFCTable_oid, hostInterFCTable_oid_len,
HANDLER_CAN_RONLY
);
table_info = SNMP_MALLOC_TYPEDEF( netsnmp_table_registration_info );
netsnmp_table_helper_add_indexes(table_info,
ASN_INTEGER, /* tableindex: fcIndexNum */
0);
table_info->min_column = COLUMN_FCPORT;
table_info->max_column = COLUMN_FCLOGINNUMS;
iinfo = SNMP_MALLOC_TYPEDEF( netsnmp_iterator_info );
iinfo->get_first_data_point = hostInterFCTable_get_first_data_point;
iinfo->get_next_data_point = hostInterFCTable_get_next_data_point;
iinfo->table_reginfo = table_info;
netsnmp_register_table_iterator( reg, iinfo );
PRINT_SNMP(__FUNCTION__,__LINE__);
netsnmp_inject_handler_before( reg,
netsnmp_get_cache_handler(HOSTINTERFCTABLE_TIMEOUT,
hostInterFCTable_load, hostInterFCTable_free,
hostInterFCTable_oid,
hostInterFCTable_oid_len),
TABLE_ITERATOR_NAME);
/* XXXX Initialise the contents of the table here. */
}
/* remove a row from the table */
void
hostInterFCTable_removeEntry( struct hostInterFCTable_entry *entry ) {
int
hostInterFCTable_load( netsnmp_cache *cache, void *vmagic ) {
FILE *fp;
struct hostInterFCTable_entry *this;
char buf[STRMAX];
fp = fopen( "/data/for/hostInterFCTable", "r" );
while ( fgets( buf, STRMAX, fp )) {
this = SNMP_MALLOC_TYPEDEF( struct hostInterFCTable_entry );
/* Unpick 'buf' and populate 'this' */
this->next = hostInterFCTable_head;
hostInterFCTable_head = this; /* Iterate helper is fine with
unordered lists! */
}
fclose(fp);
}
int
hostInterFCTable_free( netsnmp_cache *cache, void *vmagic ) {
struct hostInterFCTable_entry *this, *that;
for ( this = hostInterFCTable_head; this; this=that ) {
that = this->next;
SNMP_FREE( this ); /* XXX - release any other internal resources */
}
hostInterFCTable_head = NULL;
}
/* Example iterator hook routines - using 'get_next' to do most of the work */
netsnmp_variable_list *
hostInterFCTable_get_first_data_point([SKIP])
netsnmp_variable_list *
hostInterFCTable_get_next_data_point([SKIP])
int
hostInterFCTable_handler([SKIP])
[SKIP]
if I modified the uit.h like this
[SKIP]
void initialize_table_hostInterFCTable(void);
Netsnmp_Node_Handler hostInterFCTable_handler;
Netsnmp_First_Data_Point hostInterFCTable_get_first_data_point;
Netsnmp_Next_Data_Point hostInterFCTable_get_next_data_point;
NetsnmpCacheLoad hostInterFCTable_load;
// NetsnmpCacheFree hostInterFCTable_free;
#define HOSTINTERFCTABLE_TIMEOUT 60
[SKIP]
I got the wrong information like this:
[SKIP]
uit.c: In function ‘init_uit’:
uit.c:189: warning: useless type name in empty declaration
uit.c: In function ‘initialize_table_hostInterFCTable’:
uit.c:2766: error: ‘hostInterFCTable_free’ undeclared (first use in this
function)
uit.c:2766: error: (Each undeclared identifier is reported only once
uit.c:2766: error: for each function it appears in.)
uit.c: At top level:
[SKIP]
I was muddled by this situation,I didnot use -S cache=0 command got my
generated code first,and then I use the -S cache=0 got the generated code,and
modified the code file in order to testing the net-snmp cache up-to-date
problem,the previous code version worked perfect right.
Dave,tell me where I am wrong again.Thank you !
------------------------------------------------------------------------------
This SF.net email is sponsored by
Make an app they can't live without
Enter the BlackBerry Developer Challenge
http://p.sf.net/sfu/RIM-dev2dev
_______________________________________________
Net-snmp-users mailing list
Net-snmp-users@lists.sourceforge.net
Please see the following page to unsubscribe or change other options:
https://lists.sourceforge.net/lists/listinfo/net-snmp-users