9#include "tpcclibConfig.h"
22static char *info[] = {
23 "Replace specified TAC y (concentration) value(s) with given value.",
24 "If file does not exist, then a new file is created.",
26 "Usage: @P [Options] tacfile tac frame value",
31 "Tac and frame must be set to the sequence number of the TAC and frame;",
32 "set tac and/or frame to 0 to replace value in all TACs and/or frames.",
33 "To simulate missing value(s), set value to 'nan'.",
35 "See also: tacsetx, tacmultx, taclist, tacadd, taclkup, tacunit, taccuty",
37 "Keywords: TAC, tool, software testing",
56int main(
int argc,
char **argv)
58 int ai, help=0, version=0, verbose=1;
59 int ret, row=-1, col=-1;
62 char tacfile[FILENAME_MAX];
68 if(argc==1) {
tpcPrintUsage(argv[0], info, stderr);
return(1);}
69 tacInit(&tac); tacfile[0]=(char)0;
71 for(ai=1; ai<argc; ai++)
if(*argv[ai]==
'-') {
74 fprintf(stderr,
"Error: invalid option '%s'\n", argv[ai]);
83 if(help==2) {
tpcHtmlUsage(argv[0], info,
"");
return(0);}
89 for(; ai<argc; ai++) {
91 strlcpy(tacfile, argv[ai], FILENAME_MAX);
continue;
93 col=atoi(argv[ai]);
if(col>=0)
continue;
95 row=atoi(argv[ai]);
if(row>=0)
continue;
97 if(strncasecmp(argv[ai],
"NAN", 2)==0) v=nan(
"");
101 fprintf(stderr,
"Error: invalid argument '%s'.\n", argv[ai]);
105 if(ret==0) {
tpcPrintUsage(argv[0], info, stdout);
return(1);}
109 for(ai=0; ai<argc; ai++)
110 printf(
"%s ", argv[ai]);
112 printf(
"tacfile := %s\n", tacfile);
113 printf(
"row := %d\n", row);
114 printf(
"col := %d\n", col);
115 printf(
"value := %g\n", v);
122 if(access(tacfile, 0) == -1) {
123 if(verbose>1) printf(
"making TAC data\n");
126 fprintf(stderr,
"Error: invalid TAC or frame.\n");
131 fprintf(stderr,
"Error (%d): %s\n", ret,
errorMsg(status.
error));
138 if(verbose>1) printf(
"reading %s\n", tacfile);
139 ret=
tacRead(&tac, tacfile, &status);
141 fprintf(stderr,
"Error (%d): %s\n", ret,
errorMsg(status.
error));
146 printf(
"tacNr := %d\n", tac.
tacNr);
147 printf(
"sampleNr := %d\n", tac.
sampleNr);
153 fprintf(stderr,
"Error: TAC file does not contain frame %d.\n", row);
158 fprintf(stderr,
"Error: TAC file does not contain tac %d.\n", col);
166 for(
int i=0; i<tac.
tacNr; i++) {
167 if(col!=0 && col!=i+1)
continue;
169 if(row==0 || row==j+1) tac.
c[i].
y[j]=v;
177 if(verbose>2) printf(
"writing %s\n", tacfile);
178 FILE *fp; fp=fopen(tacfile,
"w");
180 fprintf(stderr,
"Error: cannot open file for writing (%s)\n", tacfile);
186 fprintf(stderr,
"Error (%d): %s\n", ret,
errorMsg(status.
error));
double atofVerified(const char *s)
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 tacAllocate(TAC *tac, int sampleNr, int tacNr)
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.
@ TAC_FORMAT_PMOD
PMOD TAC format.