Skip to content

Commit

Permalink
Merge pull request networkupstools#85 from cdominguezm/DMF
Browse files Browse the repository at this point in the history
Debugged!!!
  • Loading branch information
vyskocilm authored Jun 16, 2016
2 parents 8672933 + f25ef63 commit 5237efb
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
14 changes: 14 additions & 0 deletions common/dmfsnmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,20 @@ mibdmf_get_aux_list_ptr(mibdmf_parser_t *dmp)
return &(dmp->list[dmp->sublist_elements - 1]);
}

alist_t **
mibdmf_get_initial_list_ptr(mibdmf_parser_t *dmp)
{
if (dmp==NULL) return NULL;
return dmp->list;
}

int
mibdmf_get_list_size(mibdmf_parser_t *dmp)
{
if (dmp==NULL) return 0;
return dmp->sublist_elements;
}

// Properly destroy the object hierarchy and NULLify the caller's pointer
void
mibdmf_parser_destroy(mibdmf_parser_t **self_p)
Expand Down
6 changes: 6 additions & 0 deletions include/dmfsnmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,12 @@ alist_t *
// be validly reallocated, freed, etc.
alist_t **
mibdmf_get_aux_list_ptr(mibdmf_parser_t *dmp);

alist_t **
mibdmf_get_initial_list_ptr(mibdmf_parser_t *dmp);

int
mibdmf_get_list_size(mibdmf_parser_t *dmp);

int *
mibdmf_get_device_table_counter_ptr(mibdmf_parser_t *dmp);
Expand Down
19 changes: 13 additions & 6 deletions scripts/DMF/dmf-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,19 @@ main ()
//mib2nut_info_t *m2n = get_mib2nut_table();
//print_mib2nut_memory_struct(m2n + 6);
//print_mib2nut_memory_struct(&pxgx_ups);
printf("=== DMF-Test: Loaded C structures (sample for 'eaton_epdu'):\n\n");
print_mib2nut_memory_struct((mib2nut_info_t *)
alist_get_element_by_name(mibdmf_get_aux_list(dmp), "eaton_marlin")->values[0]);
printf("\n\n");
printf("=== DMF-Test: Original C structures (sample for 'eaton_epdu'):\n\n");
print_mib2nut_memory_struct(&eaton_marlin);
alist_t **aux = mibdmf_get_initial_list_ptr(dmp);
alist_t *element;
int iterator = 0;

//printf("=== DMF-Test: Loaded C structures (sample for 'eaton_epdu'):\n\n");
while(!(element = alist_get_element_by_name(aux[iterator], "eaton_marlin"))&&(iterator < mibdmf_get_list_size(dmp)))
iterator++;

if(element)
print_mib2nut_memory_struct((mib2nut_info_t *) element->values[0]);
//printf("\n\n");
//printf("=== DMF-Test: Original C structures (sample for 'eaton_epdu'):\n\n");
//print_mib2nut_memory_struct(&eaton_marlin);
//End debugging

printf("=== DMF-Test: Freeing data...\n\n");
Expand Down

0 comments on commit 5237efb

Please sign in to comment.