#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "nmd.h"
Go to the source code of this file.
Functions | |
int | NMDTabReportData (NMD_metadata nmd, char **rkey, char **rval, int separator) |
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.
00009 { 00010 char *key,*val; size_t lkey,lval; 00011 int ncat,icat,nmod,imod; 00012 char **categories,**modules; NMDDataType *types; 00013 int begun=0, ierr; 00014 00015 NMD_MALLOC(key,2000,char,"keys"); 00016 NMD_MALLOC(val,2000,char,"values"); 00017 00018 ierr = NMDGetCategories(nmd,&ncat,&categories); NMD_ERR_RETURN(ierr); 00019 for (icat=0; icat<ncat; icat++) { 00020 int first=1; 00021 ierr = NMDCategoryIGetComponents 00022 (nmd,icat,&nmod,&modules,&types); NMD_ERR_RETURN(ierr); 00023 for (imod=0; imod<nmod; imod++) { 00024 int f=0,is_array,trace_arrays; 00025 void *v; char *stringed; 00026 ierr = NMDGetValue 00027 (nmd,categories[icat],modules[imod], 00028 NULL,(void*)&v,(int*)&f); NMD_ERR_RETURN(ierr); 00029 lkey = strlen(key); lval = strlen(val); 00030 00031 if (begun) { 00032 sprintf(key+lkey++,"\t");/*"%c", separator);*/ 00033 sprintf(val+lval++,"\t");/*"%c", separator);*/ 00034 } else begun=1; 00035 00036 if (first) { 00037 sprintf(key+lkey,"%s:%s",categories[icat],modules[imod]); 00038 first=0; 00039 } else { 00040 sprintf(key+lkey,"%s",modules[imod]); 00041 } 00042 00043 is_array = 00044 ( types[imod]==NMDIntarray || types[imod]==NMDRealarray ); 00045 /*ierr = AnaModTraceArrays(&trace_arrays); NMD_ERR_RETURN(ierr);*/ 00046 trace_arrays = 0; 00047 if (f && (!is_array || trace_arrays) ) { 00048 ierr = QuantityAsString(&v,types[imod],&stringed); NMD_ERR_RETURN(ierr); 00049 } else stringed = ""; 00050 sprintf(val+lval,"%s",stringed); 00051 } 00052 } 00053 *rkey = key; *rval = val; 00054 00055 return 0; 00056 }