TPCCLIB
Loading...
Searching...
No Matches
statusmsg.c File Reference

Status information for library functions. More...

#include "tpcclibConfig.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <string.h>
#include "tpcextensions.h"

Go to the source code of this file.

Functions

char * errorMsg (tpcerror e)
 
void statusPrint (FILE *fp, TPCSTATUS *s)
 
void statusInit (TPCSTATUS *s)
 
void statusFree (TPCSTATUS *s)
 
void statusSet (TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error)
 

Detailed Description

Status information for library functions.

Definition in file statusmsg.c.

Function Documentation

◆ errorMsg()

char * errorMsg ( tpcerror e)

Return pointer to error message specified with the error code.

Returns
pointer to the error message string.
See also
tpcerror, statusPrint
Author
Vesa Oikonen
Parameters
eError code
See also
tpcerror.

Definition at line 68 of file statusmsg.c.

71 {
72 if(e<TPCERROR_OK || e>=TPCERROR_LAST) return NULL;
73 return tpcerrormsg[e];
74}
@ TPCERROR_LAST
marking the end of list

Referenced by imgRead(), and nloptIATGO().

◆ statusFree()

void statusFree ( TPCSTATUS * s)

After last use, free any memory allocated in the structure.

See also
errorMsg, statusSet, statusInit
Parameters
sPointer to status.

Definition at line 126 of file statusmsg.c.

129 {
130 if(s==NULL) return;
131 free(s->last_file); free(s->last_func);
132 free(s->current_file); free(s->current_func);
133 if(s->fp!=NULL && s->fp!=stdout && s->fp!=stderr) fclose(s->fp);
134 statusInit(s);
135}
void statusInit(TPCSTATUS *s)
Definition statusmsg.c:104
FILE * fp
File pointer for writing log information during development and testing.
char * current_func
Function where status was last time set.
char * last_file
Source file name where status previously set.
char * current_file
Source file name where status was last time set.
char * last_func
Function where status was previously set.

◆ statusInit()

void statusInit ( TPCSTATUS * s)

Before first use, initialize the structure contents using this function. After last use of status structure, call statusFree(), which also calls this function to re-initiate the structure contents.

See also
errorMsg, statusSet, statusFree
Parameters
sPointer to status.

Definition at line 104 of file statusmsg.c.

107 {
108 if(s==NULL) return;
109 s->last_line=0;
110 s->last_file=NULL;
111 s->last_func=NULL;
112 s->current_line=0;
113 s->current_file=NULL;
114 s->current_func=NULL;
115 s->verbose=0;
116 s->fp=stdout;
117 s->forgiving=0;
118 s->error=0;
119}
int verbose
Verbose level, used by statusPrint() etc.
int forgiving
Force level, 0 for strict tests for data units etc.
int current_line
Source line nr where status was last time set.
int last_line
Source line nr where status was previously set.
tpcerror error
Error code.

Referenced by statusFree().

◆ statusPrint()

void statusPrint ( FILE * fp,
TPCSTATUS * s )

Print the contents of status structure.

Author
Vesa Oikonen
See also
statusSet, errorMsg, statusInit, statusFree
Parameters
fpFile pointer for the output.
sPointer to status.

Definition at line 82 of file statusmsg.c.

87 {
88 if(fp==NULL || s==NULL) return;
89 if(s->current_file!=NULL && s->current_func!=0 && s->current_line>0)
90 fprintf(fp, "In %s() on line %d of file %s\n", s->current_func, s->current_line, s->current_file);
91 if(s->verbose<=0) return;
92 if(s->last_file!=NULL && s->last_func!=0 && s->last_line>0)
93 fprintf(fp, "called in %s() on line %d of file %s\n", s->last_func, s->last_line, s->last_file);
94 return;
95}

◆ statusSet()

void statusSet ( TPCSTATUS * s,
const char * func,
const char * srcfile,
int srcline,
tpcerror error )

Set the status contents.

See also
statusInit, statusFree, errorMsg, tpcProgramName, tpcProcessStdOptions
Parameters
sPointer to status.
funcPointer to function name, usually func.
srcfilePointer to source file name, usually FILE.
srclinePointer to source file line number, usually LINE.
errorError code, 0 if status is ok.

Definition at line 142 of file statusmsg.c.

153 {
154 if(s==NULL) return;
155 s->error=error;
156 /* Delete any previous content */
157 s->last_line=0;
158 free(s->last_file); free(s->last_func);
159 s->last_file=NULL; s->last_func=NULL;
160 /* Move current content to previous */
164 /* Set current contents */
165 s->current_line=srcline;
166 if(func!=NULL) s->current_func=strdup(func);
167 if(srcfile!=NULL) s->current_file=strdup(srcfile);
168 s->error=error;
169}
char * strdup(const char *s)
Definition stringext.c:185

Referenced by abssWrite(), anaExists(), bfm1TCM(), bfmSRTM(), csvPutLine(), csvPutLineWithSpaces(), csvRead(), csvReorg(), csvWrite(), dcmFileList(), dcmFileRead(), dcmFileRemove(), dcmFileWrite(), dcmMListRead(), dcmmlSortByPlane(), ecatMListRead(), ecatReadMainheader(), ecatWriteMainheader(), iftCopyItems(), iftDeleteDuplicateKeys(), iftPut(), iftPutFromString(), iftPutFromStringWithSpaceSeparator(), iftRead(), iftReplaceKey(), iftReplaceValue(), iftWrite(), iftWriteItem(), imgAllocate(), imgCompareConc(), imgCompareTimes(), imgCompareUnit(), imgFillOHeader(), imgRead(), imgReadDICOM(), imgReadNifti(), imgWrite(), imgWriteDICOM(), imgWriteNifti(), micropetExists(), micropetHeaderRead(), mtgaPlotSVG(), niftiExists(), nlopt1D(), nloptIATGO(), nloptITGO1(), nloptITGO2(), nloptMPSO(), nloptPowellBrent(), nloptSimplex(), nloptSimplexARRS(), parAllocateWithTAC(), parCombineTACs(), parCompareParameterNames(), parCompareParameters(), parCompareParameterUnits(), parCompareTacNames(), parCompareWSS(), parExamplePerfectBolus(), parExampleTTACs(), parFromIFT(), parRead(), parReadCSV(), parReadFIT(), parReadRES(), parSelectByAnother(), parSelectParameters(), parSelectTACs(), parSortByName(), parToIFT(), parWrite(), parWriteCSV(), parWriteFIT(), parWriteIFT(), parWriteRES(), parWriteXML(), roinameMatch(), sifWeight(), spectralDExp(), spectralKRange(), tacAddZeroSample(), tacAllocateWithPAR(), tacAUC(), tacCompareConc(), tacCompareNames(), tacCompareTimes(), tacCompareUnit(), tacCompareWeights(), tacCorrectFrameOverlap(), tacDecayCorrection(), tacDelay(), tacFittime(), tacFormatDetermine(), tacFramesToSteps(), tacGetHeaderInjectiontime(), tacGetHeaderIsotope(), tacGetHeaderScanstarttime(), tacGetHeaderStudynr(), tacGetHeaderTimeunit(), tacGetHeaderUnit(), tacInput2sim(), tacIntegrate(), tacInterpolate(), tacInterpolateInto(), tacInterpolateToEqualLengthFrames(), tacPlotFitSVG(), tacPlotHistogramSVG(), tacPlotLineSVG(), tacRead(), tacRead4DM(), tacReadAllogg(), tacReadCarimasTxt(), tacReadCSV(), tacReadDFT(), tacReadGEMS(), tacReadHRPLUSHC(), tacReadHRRTHC(), tacReadInveonCSV(), tacReadMat(), tacReadModelingData(), tacReadModelingInput(), tacReadOldAllogg(), tacReadPMOD(), tacReadQView(), tacReadReference(), tacReadScanditronics(), tacReadSIF(), tacReadSimple(), tacSelectTACs(), tacSetWeights(), tacSetX(), tacSortByAUC(), tacSortByConc(), tacSortByName(), tacSortByTime(), tacToPAR(), tacVb(), tacVerifyTimeOrder(), tacWByFreq(), tacWeightModerate(), tacWeightNorm(), tacWMove(), tacWrite(), tacWriteCSV(), tacWriteDFT(), tacWritePMOD(), tacWriteSheetIntoXML(), tacWriteSIF(), tacWriteSimple(), tacWriteXML(), tacXUnitConvert(), tacYUnitConvert(), tacYUnitMass2Volume(), and tacYUnitVolume2Mass().