9#include "tpcclibConfig.h"
22static char *info[] = {
23 "Convert regional or input TAC data in filename1 into filename2",
24 "in specified file format.",
25 "Data can be written only in a few formats (listed below), but more",
26 "file formats can be read.",
28 "Usage: @P [options] filename1 [filename2]",
32 " Accepted format-id's:",
33 " CSV-INT - CSV format with semicolons and decimal commas.",
34 " CSV-UK - CSV format with commas and decimal points.",
35 " TSV-INT - TSV format with tabs and decimal commas.",
36 " TSV-UK - TSV format with tabs and decimal points.",
37 " PMOD - PMOD tac and bld format.",
38 " DFT - TPC TAC format.",
39 " SIMPLE - txt file with tabs and decimal points.",
40 " XML - MS Excel compatible XML format.",
41 " Without this option, only the format of the given TAC file is shown.",
43 " Extra information is (y, default) or is not stored (n) in lines",
44 " starting with '#' character; not effective with all formats.",
46 " Frame mid times are used instead of frame start and end times.",
49 "Example 1: convert DFT file into PMOD TAC format",
50 " @P -f=pmod -hdr=no iea446.dft iea446.tac",
52 "Example 2a: convert all TAC files into DFT format on Windows",
53 " for %g in (*.tac) do @P -f=DFT -hdr=no %g",
55 "Example 2b: the same on linux and macOS",
57 " for file in ./*.tac; do tacformat -f=dft -hdr=no $file; done",
59 "See also: taclist, tacunit, tacframe, tacnames, tac2xml",
61 "Keywords: TAC, tool, format, PMOD, CSV, DFT",
80int main(
int argc,
char **argv)
82 int ai, help=0, version=0, verbose=1;
87 char *cptr, tacfile1[FILENAME_MAX], tacfile2[FILENAME_MAX];
94 if(argc==1) {
tpcPrintUsage(argv[0], info, stderr);
return(1);}
96 tacfile1[0]=tacfile2[0]=(char)0;
98 for(ai=1; ai<argc; ai++)
if(*argv[ai]==
'-') {
100 cptr=argv[ai]+1;
if(*cptr==
'-') cptr++;
if(!*cptr)
continue;
101 if(strncasecmp(cptr,
"F=", 2)==0) {
104 }
else if(strncasecmp(cptr,
"FORMAT=", 7)==0) {
107 }
else if(strncasecmp(cptr,
"HDR=", 4)==0) {
109 if(strncasecmp(cptr,
"YES", 1)==0) {save_header=1;
continue;}
110 else if(strncasecmp(cptr,
"NO", 1)==0) {save_header=0;
continue;}
111 }
else if(strncasecmp(cptr,
"HEADER=", 7)==0) {
113 if(strncasecmp(cptr,
"YES", 1)==0) {save_header=1;
continue;}
114 else if(strncasecmp(cptr,
"NO", 1)==0) {save_header=0;
continue;}
115 }
else if(strncasecmp(cptr,
"MIDDLE", 3)==0) {
116 mid_time=1;
continue;
118 fprintf(stderr,
"Error: invalid option '%s'.\n", argv[ai]);
127 if(help==2) {
tpcHtmlUsage(argv[0], info,
"");
return(0);}
132 if(ai<argc) {
strlcpy(tacfile1, argv[ai++], FILENAME_MAX);}
133 if(ai<argc) {
strlcpy(tacfile2, argv[ai++], FILENAME_MAX);}
134 if(ai<argc) {fprintf(stderr,
"Error: too many arguments: '%s'.\n", argv[ai]);
return(1);}
137 if(!tacfile1[0]) {
tpcPrintUsage(argv[0], info, stdout);
return(1);}
142 printf(
"save_header := %d\n", save_header);
143 printf(
"tacfile1 := %s\n", tacfile1);
144 if(tacfile2[0]) printf(
"tacfile2 := %s\n", tacfile2);
152 if(verbose>1) printf(
"reading %s\n", tacfile1);
153 ret=
tacRead(&tac, tacfile1, &status);
158 fprintf(stderr,
"Error: %s (%s)\n",
errorMsg(status.
error), tacfile1);
164 fprintf(stderr,
"Error: %s (%s)\n",
errorMsg(status.
error), tacfile1);
180 strcpy(tacfile2, tacfile1);
185 printf(
"tacfile2 := %s\n", tacfile2);
196 printf(
"\n---- tac.h ----\n");
198 printf(
"---------------\n\n");
202 if(verbose>1) printf(
"writing %s\n", tacfile2);
203 FILE *fp; fp=fopen(tacfile2,
"w");
205 fprintf(stderr,
"Error: cannot open file for writing (%s)\n", tacfile2);
208 ret=
tacWrite(&tac, fp, new_format, save_header, &status);
212 fprintf(stderr,
"Error: writing format %s is not supported.\n",
tacFormattxt(new_format));
219 if(verbose>0) printf(
" %s written.\n", tacfile2);
void filenameRmPath(char *s)
int filenameRmExtension(char *s)
int iftWrite(IFT *ift, FILE *fp, TPCSTATUS *status)
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)
IFT h
Optional (but often useful) header information.
int verbose
Verbose level, used by statusPrint() etc.
tpcerror error
Error code.
int tacFormatDetermine(const char *fname, TPCSTATUS *status)
char * tacDefaultExtension(tacformat c)
int tacRead(TAC *d, const char *fname, TPCSTATUS *status)
int tacFormatIdentify(const char *s)
char * tacFormattxt(tacformat c)
int tacWrite(TAC *tac, FILE *fp, tacformat format, int extra, TPCSTATUS *status)
int tacSetX(TAC *d, TPCSTATUS *status)
Set TAC x values based on x1 and x2 values, or guess x1 and x2 values based on x values.
Header file for library libtpcextensions.
@ TPCERROR_UNSUPPORTED
Unsupported file type.
Header file for library libtpcift.
Header file for library libtpctac.
@ TAC_FORMAT_UNKNOWN
Unknown format.