NMD
Functions
nmdreport.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "nmd.h"
Include dependency graph for nmdreport.c:

Go to the source code of this file.

Functions

int NMDTabReportData (NMD_metadata nmd, char **rkey, char **rval, int separator)

Function Documentation

int NMDTabReportData ( NMD_metadata  nmd,
char **  rkey,
char **  rval,
int  separator 
)

Definition at line 8 of file nmdreport.c.

References NMD_MALLOC, NMDGetCategories(), NMDGetValue(), NMDIntarray, and NMDRealarray.

{
  char *key,*val; size_t lkey,lval;
  int ncat,icat,nmod,imod;
  char **categories,**modules; NMDDataType *types;
  int begun=0, ierr;

  NMD_MALLOC(key,2000,char,"keys");
  NMD_MALLOC(val,2000,char,"values");

  ierr = NMDGetCategories(nmd,&ncat,&categories); NMD_ERR_RETURN(ierr);
  for (icat=0; icat<ncat; icat++) {
    int first=1;
    ierr = NMDCategoryIGetComponents
      (nmd,icat,&nmod,&modules,&types); NMD_ERR_RETURN(ierr);
    for (imod=0; imod<nmod; imod++) {
      int f=0,is_array,trace_arrays;
      void *v; char *stringed;
      ierr = NMDGetValue
        (nmd,categories[icat],modules[imod],
         NULL,(void*)&v,(int*)&f); NMD_ERR_RETURN(ierr);
      lkey = strlen(key); lval = strlen(val);

      if (begun) {
        sprintf(key+lkey++,"\t");/*"%c", separator);*/
        sprintf(val+lval++,"\t");/*"%c", separator);*/
      } else begun=1;

      if (first) {
        sprintf(key+lkey,"%s:%s",categories[icat],modules[imod]);
        first=0;
      } else {
        sprintf(key+lkey,"%s",modules[imod]);
      }

      is_array = 
        ( types[imod]==NMDIntarray || types[imod]==NMDRealarray );
      /*ierr = AnaModTraceArrays(&trace_arrays); NMD_ERR_RETURN(ierr);*/
      trace_arrays = 0;
      if (f && (!is_array || trace_arrays) ) {
        ierr = QuantityAsString(&v,types[imod],&stringed); NMD_ERR_RETURN(ierr);
      } else stringed = "";
      sprintf(val+lval,"%s",stringed);
    }
  }
  *rkey = key; *rval = val;

return 0;
}

Here is the call graph for this function: