8#include "tpcclibConfig.h"
21static char *info[] = {
22 "Ensure that TAC time frames are continuous, without overlaps or gaps.",
23 "Program return code is 0, if time frames are contiguous, or optionally",
24 "were made contiguous.",
26 "Usage: @P [options] file",
30 " Gaps and overlaps between time frames are fixed, when possible.",
31 " Tiny gaps/overlaps are fixed by editing frame times.",
32 " Larger gaps are filled with new frames, based on linear interpolation",
33 " between frame middle points of adjacent frames.",
36 "See also: tacframe, tacdelna, simframe, tacsetx",
38 "Keywords: TAC, tool, time",
57int main(
int argc,
char **argv)
59 int ai, help=0, version=0, verbose=1;
61 char *cptr, tacfile[FILENAME_MAX];
66 if(argc==1) {
tpcPrintUsage(argv[0], info, stderr);
return(1);}
69 for(ai=1; ai<argc; ai++)
if(*argv[ai]==
'-') {
71 cptr=argv[ai]+1;
if(*cptr==
'-') cptr++;
if(!*cptr)
continue;
72 if(strcasecmp(cptr,
"FIX")==0) {
75 fprintf(stderr,
"Error: invalid option '%s'\n", argv[ai]);
84 if(help==2) {
tpcHtmlUsage(argv[0], info,
"");
return(0);}
89 if(ai<argc) {
strlcpy(tacfile, argv[ai], FILENAME_MAX); ai++;}
90 else {fprintf(stderr,
"Error: missing filename.\n");
return(1);}
91 if(ai<argc) {fprintf(stderr,
"Error: extra command-line argument.\n");
return(1);}
95 printf(
"tacfile := %s\n", tacfile);
96 printf(
"fixMode := %d\n", fixMode);
100 if(verbose>1) printf(
"reading %s\n", tacfile);
102 ret=
tacRead(&tac, tacfile, &status);
104 fprintf(stderr,
"Error (%d): %s\n", ret,
errorMsg(status.
error));
109 printf(
"tacNr := %d\n", tac.
tacNr);
110 printf(
"sampleNr := %d\n", tac.
sampleNr);
118 fprintf(stdout,
"Note: frame times are contiguous.\n");
122 fprintf(stderr,
"Warning: frame times are not contiguous.\n");
126 fprintf(stderr,
"Error: time frames cannot be fixed.\n");
133 fprintf(stdout,
"Note: fixing frame times that are not contiguous.\n");
136 fprintf(stderr,
"Error: large frame overlap.\n");
140 fprintf(stderr,
"Error: cannot fix frame times.\n");
148 if(verbose>1) printf(
"writing fixed %s\n", tacfile);
149 FILE *fp; fp=fopen(tacfile,
"w");
151 fprintf(stderr,
"Error: cannot open file for writing (%s)\n", tacfile);
157 fprintf(stderr,
"Error (%d): %s\n", ret,
errorMsg(status.
error));
int tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
int tpcHtmlUsage(const char *program, char *text[], const char *path)
void tpcPrintBuild(const char *program, FILE *fp)
void tpcPrintUsage(const char *program, char *text[], FILE *fp)
void statusInit(TPCSTATUS *s)
char * errorMsg(tpcerror e)
void statusSet(TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error)
size_t strlcpy(char *dst, const char *src, size_t dstsize)
int verbose
Verbose level, used by statusPrint() etc.
tpcerror error
Error code.
int tacRead(TAC *d, const char *fname, TPCSTATUS *status)
char * tacFormattxt(tacformat c)
int tacWrite(TAC *tac, FILE *fp, tacformat format, int extra, TPCSTATUS *status)
int tacIsXContiguous(TAC *d)
Check that PET TAC frame times are contiguous, without even tiny overlap or gaps in between.
int tacSetXContiguous(TAC *d)
Set PET TAC frame times contiguous, without even tiny overlap or gaps in between.
Header file for library libtpcextensions.
@ TPCERROR_OVERLAPPING_DATA
Overlapping data.
@ TPCERROR_LARGE_GAP
Large gap in data.
Header file for library libtpcift.
Header file for library libtpctac.
@ TAC_FORMAT_UNKNOWN
Unknown format.