8#include "tpcclibConfig.h"
21static char *info[] = {
22 "Multiplies the x column(s) in TAC file by user-specified operand.",
23 "Resulting TAC can be written into new file, or original can be overwritten.",
25 "Usage: @P [Options] tacfile operand [outputfile]",
30 "See also: tacsetx, taclist, tacadd, tacframe, tacunit, tacformat",
32 "Keywords: TAC, tool, simulation, software testing",
51int main(
int argc,
char **argv)
53 int ai, help=0, version=0, verbose=1;
56 char tacfile[FILENAME_MAX], outfile[FILENAME_MAX];
64 if(argc==1) {
tpcPrintUsage(argv[0], info, stderr);
return(1);}
66 tacfile[0]=outfile[0]=(char)0;
68 for(ai=1; ai<argc; ai++)
if(*argv[ai]==
'-') {
71 fprintf(stderr,
"Error: invalid option '%s'\n", argv[ai]);
80 if(help==2) {
tpcHtmlUsage(argv[0], info,
"");
return(0);}
85 for(; ai<argc; ai++) {
87 strcpy(tacfile, argv[ai]);
continue;
88 }
else if(isnan(ov) || ov!=ov) {
90 }
else if(!outfile[0]) {
91 strcpy(outfile, argv[ai]);
continue;
93 fprintf(stderr,
"Error: invalid argument '%s'.\n", argv[ai]);
98 if(!tacfile[0] || isnan(ov)) {
tpcPrintUsage(argv[0], info, stdout);
return(1);}
99 if(!outfile[0]) strcpy(outfile, tacfile);
104 for(ai=0; ai<argc; ai++)
105 printf(
"%s ", argv[ai]);
107 printf(
"tacfile := %s\n", tacfile);
108 printf(
"outfile := %s\n", outfile);
109 printf(
"operand := %g\n", ov);
116 if(verbose>1) printf(
"reading %s\n", tacfile);
117 ret=
tacRead(&tac, tacfile, &status);
119 fprintf(stderr,
"Error (%d): %s\n", ret,
errorMsg(status.
error));
124 printf(
"tacNr := %d\n", tac.
tacNr);
125 printf(
"sampleNr := %d\n", tac.
sampleNr);
128 printf(
"isframe := %d\n", tac.
isframe);
133 if(verbose>1) printf(
"multiplying x by %g\n", ov);
135 tac.
x[i]*=ov; tac.
x1[i]*=ov; tac.
x2[i]*=ov;
141 if(verbose>1) printf(
"writing %s\n", outfile);
142 FILE *fp; fp=fopen(outfile,
"w");
144 fprintf(stderr,
"Error: cannot open file for writing (%s)\n", outfile);
150 fprintf(stderr,
"Error (%d): %s\n", ret,
errorMsg(status.
error));
153 if(verbose>0) printf(
"%s saved.\n", outfile);
int atofCheck(const char *s, double *v)
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)
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)
Header file for library libtpcextensions.
char * unitName(int unit_code)
Header file for library libtpctac.
@ TAC_FORMAT_UNKNOWN
Unknown format.