TPCCLIB
Loading...
Searching...
No Matches
tacadd.c
Go to the documentation of this file.
1
8/*****************************************************************************/
9#include "tpcclibConfig.h"
10/*****************************************************************************/
11#include <stdio.h>
12#include <stdlib.h>
13#include <unistd.h>
14#include <string.h>
15#include <math.h>
16/*****************************************************************************/
17#include "tpcextensions.h"
18#include "tpcift.h"
19#include "tpctac.h"
20/*****************************************************************************/
21
22/*****************************************************************************/
23static char *info[] = {
24 "Insert one or more TACs from TAC file 2 into another, optionally new,",
25 "TAC file 1. Files must have the same number of samples (time frames).",
26 "If the TAC number or name is not specified, then all TACs in file2 are added.",
27 "If file1 does not exist, it will be created.",
28 "Alternatively, all TACs from several files can be added to file1.",
29 " ",
30 "Usage: @P [options] file1 file2 [tacname or tacnumber]",
31 "or",
32 "Usage: @P [options] file1 file2 [file3 [file4 ...]]",
33 " ",
34 "Options:",
35 " -sn",
36 " Copied region names are changed to contain the study number.",
37 " -namestart",
38 " TAC name must match the initial part of names in file2.",
39 " -ovr",
40 " Existing file1 is overwritten.",
41 " --force",
42 " Program does not mind if the time or calibration units do not match.",
43 " -move",
44 " Selected TAC(s) are removed from file2.",
45 " -stdoptions", // List standard options like --help, -v, etc
46 " ",
47 "Example 1: Add TACs with name 'striatum' from file a123_12.dat into",
48 "file a123_06.dat",
49 " @P a123_06.dat a123_12.dat striatum",
50 " ",
51 "Example 2a: Combine specified TAC files into a new file",
52 " @P combined.tac s6789*.tac",
53 " ",
54 "Example 2b: Combine specified TAC files into a new file",
55 "using for loop in MS Windows command prompt window",
56 " for %g in (s6789*.tac) do @P combined.tac %g",
57 " ",
58 "Example 2c: Combine all putamen TACs from TAC files into a new file,",
59 "storing study number as region name for each TAC,",
60 "using for loop in MS Windows command prompt window",
61 " for %g in (a*.tac) do @P -sn putamen.tac %g put",
62 " ",
63 "See also: taclist, tacdel, tacsplit, tacsort, tacblend, tacunit, tac2svg",
64 " ",
65 "Keywords: TAC, tool",
66 0};
67/*****************************************************************************/
68
69/*****************************************************************************/
70/* Turn on the globbing of the command line, since it is disabled by default in
71 mingw-w64 (_dowildcard=0); in MinGW32 define _CRT_glob instead, if necessary;
72 In Unix&Linux wildcard command line processing is enabled by default. */
73/*
74#undef _CRT_glob
75#define _CRT_glob -1
76*/
77int _dowildcard = -1;
78/*****************************************************************************/
79
80/*****************************************************************************/
84int main(int argc, char **argv)
85{
86 int ai, help=0, version=0, verbose=1;
87 int ret, addNr=0;
88 int newfile=0; // 0=TAC(s) are added; 1=new file is created
89 int sn2vn=0; // 0=TAC names are not changed; 1=TAC name is set to study number
90 int overwrite=0; // 0=TAC(s) are added; 1=existing file is overwritten
91 int tacmove=0; // 0=file2 is not modified; 1=selected TAC(s) are removed from file2
92 int checkunits=1; // 0=Units do not need to match; 1=units must match
93 int rnameStartGiven=0; // 1=Given TAC name needs to match the start of TAC names in file
94 char *cptr, tacfile1[FILENAME_MAX], tacfile2[FILENAME_MAX];
95 char rname[1024];
96 int firstfile=0, fileNr=0;
97
98
99 /*
100 * Get arguments
101 */
102 if(argc==1) {tpcPrintUsage(argv[0], info, stderr); return(1);}
103 tacfile1[0]=tacfile2[0]=rname[0]=(char)0;
104 /* Options */
105 for(ai=1; ai<argc; ai++) if(*argv[ai]=='-') {
106 if(tpcProcessStdOptions(argv[ai], &help, &version, &verbose)==0) continue;
107 cptr=argv[ai]+1; if(*cptr=='-') cptr++; if(!*cptr) continue;
108 if(strcasecmp(cptr, "SN")==0 || strncasecmp(cptr, "STUDYNUMBER", 5)==0) {
109 sn2vn=1; continue;
110 } else if(strncasecmp(cptr, "OVR", 2)==0) {
111 overwrite=1; continue;
112 } else if(strcasecmp(cptr, "MOVE")==0) {
113 tacmove=1; continue;
114 } else if(strncasecmp(cptr, "FORCE", 1)==0) {
115 checkunits=0; continue;
116 } else if(strncasecmp(cptr, "-FORCE", 2)==0) {
117 checkunits=0; continue;
118 } else if(strcasecmp(cptr, "NT")==0) {
119 checkunits=0; continue;
120 } else if(strcasecmp(cptr, "NAMESTART")==0) {
121 rnameStartGiven=1; continue;
122 }
123 fprintf(stderr, "Error: invalid option '%s'\n", argv[ai]);
124 return(1);
125 } else break; // tac name argument may start with '-'
126
127 TPCSTATUS status; statusInit(&status);
128 statusSet(&status, __func__, __FILE__, __LINE__, TPCERROR_OK);
129 status.verbose=verbose-1;
130
131 /* Print help or version? */
132 if(help==2) {tpcHtmlUsage(argv[0], info, ""); return(0);}
133 if(help) {tpcPrintUsage(argv[0], info, stdout); return(0);}
134 if(version) {tpcPrintBuild(argv[0], stdout); return(0);}
135
136 /* Process other arguments, starting from the first non-option */
137 if(ai<argc) {strlcpy(tacfile1, argv[ai++], FILENAME_MAX);}
138 if(ai<argc) {
139 firstfile=ai; fileNr=1;
140 strlcpy(tacfile2, argv[ai++], FILENAME_MAX);
141 } else {
142 fprintf(stderr, "Error: missing filename.\n"); return(1);
143 }
144 /* More file names? */
145 ret=0;
146 for(; ai<argc; ai++) {
147 if(access(argv[ai], 0) == -1) ret++; else fileNr++;
148 }
149 if(ret>0) { // at least not existing files, thus assuming those are TAC names
150 fileNr=1; ai=firstfile+1;
151 strlcpy(rname, argv[ai++], 1024);
152 for(int n=1; ai<argc && n<3; ai++, n++) {
153 if((strlen(rname)+strlen(argv[ai]))<1000) {
154 strlcat(rname, " ", 1024);
155 strlcat(rname, argv[ai], 1024);
156 }
157 }
158 }
159 if(ai<argc) {
160 fprintf(stderr, "Error: extra command-line argument.\n");
161 return(1);
162 }
163 /* Check that we got what we need */
164 if(!tacfile2[0]) {tpcPrintUsage(argv[0], info, stderr); return(1);}
165
166 /* If combining several files, check that user did not forget to enter the name for new file */
167 if(fileNr>1) {
168 for(ai=firstfile; ai<argc; ai++) {
169 /* Check that filename is not the same as the output filename */
170 if(strcasecmp(argv[ai], tacfile1)==0) {
171 fprintf(stderr, "Error: the same name for input and output file.\n");
172 return(1);
173 }
174 }
175 }
176 /* If combining several files, move mode is not applicable */
177 if(fileNr>1 && tacmove!=0) {
178 fprintf(stderr, "Warning: ignoring option -move.\n");
179 tacmove=0;
180 }
181
182 /* In verbose mode print arguments and options */
183 if(verbose>1) {
184 printf("tacfile1 := %s\n", tacfile1);
185 printf("tacfile2 := %s\n", tacfile2);
186 printf("overwrite := %d\n", overwrite);
187 printf("checkunits := %d\n", checkunits);
188 printf("sn2vn := %d\n", sn2vn);
189 if(rname[0]) printf("rname := %s\n", rname);
190 if(fileNr>1) printf("fileNr := %d\n", fileNr);
191 if(fileNr==1) printf("move := %d\n", tacmove);
192 }
193
194 /*
195 * Try to read the TAC file in which TACs should be added
196 */
197 if(verbose>1) printf("trying to read %s\n", tacfile1);
198 TAC tac1; tacInit(&tac1);
199 ret=tacRead(&tac1, tacfile1, &status);
200 if(ret==TPCERROR_OK) {
201 /* File 1 could be read */
202 if(overwrite!=0) {
203 if(verbose>=0) printf("File %s is overwritten.\n", tacfile1);
204 tacFree(&tac1); newfile=1;
205 } else if(verbose>1) {
206 printf("fileformat1 := %s\n", tacFormattxt(tac1.format));
207 printf("tacNr1 := %d\n", tac1.tacNr);
208 printf("sampleNr1 := %d\n", tac1.sampleNr);
209 }
210 } else if(ret==TPCERROR_CANNOT_OPEN) {
211 /* File 1 does not exist */
212 if(verbose>=0) printf("File %s did not exist and will be created.\n", tacfile1);
213 newfile=1;
214 } else if(overwrite==0) {
215 /* File 1 exists but cannot be read */
216 fprintf(stderr, "Error (%d): %s\n", ret, errorMsg(status.error));
217 tacFree(&tac1); return(2);
218 } else {
219 if(verbose>0) printf("File %s will be overwritten.\n", tacfile1);
220 tacFree(&tac1); newfile=1;
221 }
222
223
224 /*
225 * Read the (first) TAC file from where TAC(s) are imported
226 */
227 if(verbose>1) printf("reading %s\n", tacfile2);
228 TAC tac2; tacInit(&tac2);
229 ret=tacRead(&tac2, tacfile2, &status);
230 if(ret!=TPCERROR_OK) {
231 fprintf(stderr, "Error: %s\n", errorMsg(status.error));
232 tacFree(&tac1); tacFree(&tac2); return(3);
233 }
234 if(verbose>1) {
235 printf("fileformat2 := %s\n", tacFormattxt(tac2.format));
236 printf("tacNr2 := %d\n", tac2.tacNr);
237 printf("sampleNr2 := %d\n", tac2.sampleNr);
238 }
239
240 /* Check frames, unless new file is created */
241 if(!newfile && tac1.sampleNr!=tac2.sampleNr) {
242 fprintf(stderr, "Error: TAC files have different sample number.\n");
243 tacFree(&tac1); tacFree(&tac2); return(4);
244 }
245 /* If new file is created, set the units */
246 if(newfile) {
247 tac1.cunit=tac2.cunit;
248 tac1.tunit=tac2.tunit;
249 /* and do not try to check the units */
250 checkunits=0;
251 }
252
253
254 /*
255 * Select the TACs in file 2 to be copied
256 */
257 if(fileNr==1 && rname[0]) {
258 if(verbose>1) {printf("selecting regions to be copied.\n"); fflush(stdout);}
259 if(rnameStartGiven) {
260 char rname2[strlen(rname)+3];
261 strcpy(rname2, rname); strcat(rname2, "*");
262 addNr=tacSelectTACs(&tac2, rname2, 1, &status);
263 } else {
264 addNr=tacSelectTACs(&tac2, rname, 1, &status);
265 }
266 if(addNr<=0) {
267 fprintf(stderr, "Error: specified TACs not found in %s.\n", tacfile2);
268 tacFree(&tac1); tacFree(&tac2); return(5);
269 }
270 if(addNr==tac2.tacNr) {
271 fprintf(stderr, "Warning: adding all TACs from %s.\n", tacfile2);
272 /* Move mode is not supported in this case */
273 if(tacmove!=0) {
274 fprintf(stderr, "Warning: ignoring option -move.\n");
275 tacmove=0;
276 }
277 }
278 if(verbose>1) printf("%d tac(s) match name '%s'\n", addNr, rname);
279 } else {
280 /* TAC name(s) or number(s) not specified by user, so all TACs are selected to be copied */
281 for(int i=0; i<tac2.tacNr; i++) tac2.c[i].sw=1;
282 addNr=tac2.tacNr;
283 /* Move mode is not supported in this case */
284 if(tacmove!=0) {
285 fprintf(stderr, "Warning: ignoring option -move.\n");
286 tacmove=0;
287 }
288 }
289 if(verbose>1) printf(" %d TAC(s) will be added.\n", addNr);
290 int sumAddNr=addNr;
291
292
293 /*
294 * Change TAC name to contain study number, if required
295 */
296 if(sn2vn) {
297 if(verbose>1) printf("changing region name to include study number\n");
298 char studynr[MAX_STUDYNR_LEN+1];
299 ret=tacGetHeaderStudynr(&tac2.h, studynr, &status);
300 if(ret!=TPCERROR_OK) {
301 fprintf(stderr, "Error: TAC file does not contain valid studynumber.\n");
302 tacFree(&tac1); tacFree(&tac2); return(6);
303 }
304 if(verbose>2) printf("studynr2 := %s\n", studynr);
305 /* Add the study number to TAC names */
306 int len;
307 for(int i=0; i<tac2.tacNr; i++) if(tac2.c[i].sw) {
308 /* Check that TAC names have space to add the study number */
309 len=1+strlen(tac2.c[i].name);
310 len+=strlen(studynr);
311 if(len<MAX_TACNAME_LEN) {
312 /* yes, add it */
313 char tmp[MAX_TACNAME_LEN+1];
314 strcpy(tmp, studynr); strcat(tmp, "_"); strcat(tmp, tac2.c[i].name);
315 strcpy(tac2.c[i].name, tmp);
316 } else if(strlen(studynr)<=MAX_TACNAME_LEN) {
317 /* no, just put the study number */
318 strcpy(tac2.c[i].name, studynr);
319 }
320 } // next selected TAC
321 }
322
323
324 /*
325 * Allocate memory in TAC struct for the new TACs
326 */
327 if(newfile) {
328 if(verbose>2) printf("creating space for %d TACs\n", addNr);
329 /* New file ; allocate memory and copy header */
330 ret=tacAllocate(&tac1, tac2.sampleNr, addNr);
331 if(ret!=TPCERROR_OK) {
332 fprintf(stderr, "Error: cannot allocate memory.\n");
333 tacFree(&tac1); tacFree(&tac2); return(7);
334 }
335 tac1.sampleNr=tac2.sampleNr; tac1.tacNr=0;
336 ret=tacCopyHdr(&tac2, &tac1);
337 if(ret!=TPCERROR_OK) {
338 fprintf(stderr, "Error: cannot copy TAC header.\n");
339 tacFree(&tac1); tacFree(&tac2); return(7);
340 }
341 /* Copy sample times */
342 ret=tacXCopy(&tac2, &tac1, 0, tac1.sampleNr-1);
343 if(ret!=TPCERROR_OK) {
344 fprintf(stderr, "Error: cannot copy sample times.\n");
345 tacFree(&tac1); tacFree(&tac2); return(7);
346 }
347 } else {
348 if(verbose>2) printf("adding space for %d TACs\n", addNr);
349 /* Add memory to previous TAC struct */
350 ret=tacAllocateMore(&tac1, addNr);
351 if(ret!=TPCERROR_OK) {
352 fprintf(stderr, "Error: cannot allocate memory.\n");
353 tacFree(&tac1); tacFree(&tac2); return(7);
354 }
355 /* Convert y units */
356 ret=tacYUnitConvert(&tac2, tac1.cunit, &status);
358 if(ret!=TPCERROR_OK) { // failed
359 /* failing is a problem if units are to be verified */
360 if(checkunits!=0) {
361 fprintf(stderr, "Error: units do match.\n");
362 tacFree(&tac1); tacFree(&tac2); return(8);
363 } else {
364 /* Since units are NOT to be checked, that is not a problem.
365 But lets assume that if units are given, those are correct */
366 if(verbose>0) fprintf(stderr, "Warning: units do match.\n");
367 if(tac1.tunit==UNIT_UNKNOWN) tac1.tunit=tac2.tunit;
368 else tac2.tunit=tac1.tunit;
369 if(tac1.cunit==UNIT_UNKNOWN) tac1.cunit=tac2.cunit;
370 else tac2.cunit=tac1.cunit;
371 }
372 }
373 }
374
375 /* Add specified TAC(s) */
376 for(int i=0; i<tac2.tacNr; i++) if(tac2.c[i].sw) {
377 if(verbose>3) printf(" copying TAC %d\n", 1+i);
378 ret=tacCopyTacc(&tac2.c[i], &tac1.c[tac1.tacNr], tac2.sampleNr);
379 if(ret!=TPCERROR_OK) {
380 fprintf(stderr, "Error: cannot copy TAC.\n");
381 tacFree(&tac1); tacFree(&tac2); return(9);
382 }
383 tac1.tacNr++;
384 } // next selected TAC
385
386 /* Add weights, if necessary */
387 if(newfile || (!tacIsWeighted(&tac1) && tacIsWeighted(&tac2))) {
388 tac1.weighting=tac2.weighting;
389 for(int j=0; j<tac2.sampleNr; j++) tac1.w[j]=tac2.w[j];
390 }
391
392 /* Remove specified TAC(s) from the source file, if requested, and possible */
393 if(tacmove!=0) { // despite of user request, previously set to 0, if not applicable
394 int n=0;
395 int i=tac2.tacNr-1;
396 ret=TPCERROR_OK;
397 while(i>=0) {
398 if(tac2.c[i].sw) {
399 if(verbose>2) printf("%s deleted\n", tac2.c[i].name);
400 ret=tacDeleteTACC(&tac2, i); if(ret!=TPCERROR_OK) break; else n++;
401 }
402 i--;
403 }
404 if(ret!=TPCERROR_OK) {
405 fprintf(stderr, "Warning: cannot delete TAC.\n");
406 } else if(n>0 && tac2.tacNr>0) {
407 if(verbose>1) printf("writing %s\n", tacfile2);
408 FILE *fp; fp=fopen(tacfile2, "w");
409 if(fp==NULL) {
410 fprintf(stderr, "Warning: cannot open file for writing (%s)\n", tacfile2);
411 } else {
412 ret=tacWrite(&tac2, fp, TAC_FORMAT_UNKNOWN, 1, &status);
413 fclose(fp);
414 if(ret!=TPCERROR_OK) fprintf(stderr, "Warning: cannot write file %s\n", tacfile2);
415 }
416 }
417 }
418
419 tacFree(&tac2);
420
421
422 /*
423 * If more TAC files, then add data from those, too
424 */
425 ai=firstfile+1;
426 for(int tfi=1; tfi<fileNr; tfi++, ai++) {
427 /* Read the next TAC file from where TAC(s) are imported */
428 strlcpy(tacfile2, argv[ai], FILENAME_MAX);
429 if(verbose>1) printf("reading %s\n", tacfile2);
430 ret=tacRead(&tac2, tacfile2, &status);
431 if(ret!=TPCERROR_OK) {
432 fprintf(stderr, "Error (%d): %s\n", ret, errorMsg(status.error));
433 tacFree(&tac1); tacFree(&tac2); return(3);
434 }
435 if(verbose>1) {
436 printf("fileformat%d := %s\n", 1+tfi, tacFormattxt(tac2.format));
437 printf("tacNr%d := %d\n", 1+tfi, tac2.tacNr);
438 printf("sampleNr%d := %d\n", 1+tfi, tac2.sampleNr);
439 }
440 /* Check frames */
441 if(tac1.sampleNr!=tac2.sampleNr) {
442 fprintf(stderr, "Error: TAC files have different sample number.\n");
443 tacFree(&tac1); tacFree(&tac2); return(4);
444 }
445 addNr=tac2.tacNr;
446 if(verbose>1) printf(" %d TAC(s) will be added.\n", addNr);
447 sumAddNr+=addNr;
448
449 /* Change TAC name to contain study number, if required */
450 if(sn2vn) {
451 if(verbose>2) printf("changing region name to include study number\n");
452 char studynr[MAX_STUDYNR_LEN+1];
453 ret=tacGetHeaderStudynr(&tac2.h, studynr, &status);
454 if(ret!=TPCERROR_OK) {
455 fprintf(stderr, "Error: TAC file does not contain valid studynumber.\n");
456 tacFree(&tac1); tacFree(&tac2); return(6);
457 }
458 if(verbose>2) printf("studynr%d := %s\n", 1+tfi, studynr);
459 /* Add the study number to TAC names */
460 int len;
461 for(int i=0; i<tac2.tacNr; i++) {
462 /* Check that TAC names have space to add the study number */
463 len=1+strlen(tac2.c[i].name);
464 len+=strlen(studynr);
465 if(len<MAX_TACNAME_LEN) {
466 /* yes, add it */
467 char tmp[MAX_TACNAME_LEN+1];
468 strcpy(tmp, studynr); strcat(tmp, "_"); strcat(tmp, tac2.c[i].name);
469 strcpy(tac2.c[i].name, tmp);
470 } else if(strlen(studynr)<=MAX_TACNAME_LEN) {
471 /* no, just put the study number */
472 strcpy(tac2.c[i].name, studynr);
473 }
474 } // next TAC
475 }
476
477 /* Allocate memory in TAC struct for the new TACs */
478 if(verbose>2) printf("adding space for %d TACs\n", addNr);
479 /* Add memory to previous TAC struct */
480 ret=tacAllocateMore(&tac1, addNr);
481 if(ret!=TPCERROR_OK) {
482 fprintf(stderr, "Error: cannot allocate memory.\n");
483 tacFree(&tac1); tacFree(&tac2); return(7);
484 }
485 /* Convert y units */
486 ret=tacYUnitConvert(&tac2, tac1.cunit, &status);
488 if(ret!=TPCERROR_OK) { // failed
489 /* failing is a problem if units are to be verified */
490 if(checkunits!=0) {
491 fprintf(stderr, "Error: units do match.\n");
492 tacFree(&tac1); tacFree(&tac2); return(8);
493 } else {
494 /* Since units are NOT to be checked, that is not a problem.
495 But lets assume that if units are given, those are correct */
496 if(verbose>0) fprintf(stderr, "Warning: units do match.\n");
497 if(tac1.tunit==UNIT_UNKNOWN) tac1.tunit=tac2.tunit;
498 else tac2.tunit=tac1.tunit;
499 if(tac1.cunit==UNIT_UNKNOWN) tac1.cunit=tac2.cunit;
500 else tac2.cunit=tac1.cunit;
501 }
502 }
503
504 /* Add the TAC(s) */
505 for(int i=0; i<tac2.tacNr; i++) {
506 if(verbose>3) printf(" copying TAC %d\n", 1+i);
507 ret=tacCopyTacc(&tac2.c[i], &tac1.c[tac1.tacNr], tac2.sampleNr);
508 if(ret!=TPCERROR_OK) {
509 fprintf(stderr, "Error: cannot copy TAC.\n");
510 tacFree(&tac1); tacFree(&tac2); return(9);
511 }
512 tac1.tacNr++;
513 } // next TAC
514
515 /* Add weights, if necessary */
516 if(!tacIsWeighted(&tac1) && tacIsWeighted(&tac2)) {
517 tac1.weighting=tac2.weighting;
518 for(int j=0; j<tac2.sampleNr; j++) tac1.w[j]=tac2.w[j];
519 }
520
521 tacFree(&tac2);
522 } // next file
523
524
525 /* Save data */
526 if(verbose>1) printf("writing %s\n", tacfile1);
527 FILE *fp; fp=fopen(tacfile1, "w");
528 if(fp==NULL) {
529 fprintf(stderr, "Error: cannot open file for writing (%s)\n", tacfile1);
530 tacFree(&tac1); return(11);
531 }
532 if(tac1.format==TAC_FORMAT_UNKNOWN) tac1.format=tac2.format;
533 ret=tacWrite(&tac1, fp, TAC_FORMAT_UNKNOWN, 1, &status);
534 fclose(fp);
535 if(ret!=TPCERROR_OK) {
536 fprintf(stderr, "Error (%d): %s\n", ret, errorMsg(status.error));
537 tacFree(&tac1); return(12);
538 }
539
540 /* Free memory */
541 tacFree(&tac1);
542
543 if(verbose>=0) printf(" %d TAC(s) added to %s\n", sumAddNr, tacfile1);
544 return(0);
545}
546/*****************************************************************************/
547
548/*****************************************************************************/
int tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
Definition proginfo.c:47
int tpcHtmlUsage(const char *program, char *text[], const char *path)
Definition proginfo.c:169
void tpcPrintBuild(const char *program, FILE *fp)
Definition proginfo.c:339
void tpcPrintUsage(const char *program, char *text[], FILE *fp)
Definition proginfo.c:114
void statusInit(TPCSTATUS *s)
Definition statusmsg.c:104
char * errorMsg(tpcerror e)
Definition statusmsg.c:68
void statusSet(TPCSTATUS *s, const char *func, const char *srcfile, int srcline, tpcerror error)
Definition statusmsg.c:142
size_t strlcpy(char *dst, const char *src, size_t dstsize)
Definition stringext.c:632
size_t strlcat(char *dst, const char *src, size_t dstsize)
Definition stringext.c:592
char sw
Definition tpctac.h:77
char name[MAX_TACNAME_LEN+1]
Definition tpctac.h:81
Definition tpctac.h:87
unit cunit
Definition tpctac.h:105
tacformat format
Definition tpctac.h:93
int sampleNr
Definition tpctac.h:89
IFT h
Optional (but often useful) header information.
Definition tpctac.h:141
double * w
Definition tpctac.h:111
TACC * c
Definition tpctac.h:117
weights weighting
Definition tpctac.h:115
unit tunit
Definition tpctac.h:109
int tacNr
Definition tpctac.h:91
int verbose
Verbose level, used by statusPrint() etc.
tpcerror error
Error code.
void tacFree(TAC *tac)
Definition tac.c:106
int tacAllocate(TAC *tac, int sampleNr, int tacNr)
Definition tac.c:130
void tacInit(TAC *tac)
Definition tac.c:24
int tacAllocateMore(TAC *tac, int tacNr)
Definition tac.c:178
int tacCopyTacc(TACC *d1, TACC *d2, int sampleNr)
Definition tac.c:233
int tacCopyHdr(TAC *tac1, TAC *tac2)
Copy TAC header data from tac1 to tac2.
Definition tac.c:310
int tacGetHeaderStudynr(IFT *h, char *s, TPCSTATUS *status)
Definition tacift.c:26
int tacRead(TAC *d, const char *fname, TPCSTATUS *status)
Definition tacio.c:413
char * tacFormattxt(tacformat c)
Definition tacio.c:98
int tacWrite(TAC *tac, FILE *fp, tacformat format, int extra, TPCSTATUS *status)
Definition tacio.c:332
int tacDeleteTACC(TAC *d, int i)
Definition tacorder.c:310
int tacSelectTACs(TAC *d, const char *region_name, int reset, TPCSTATUS *status)
Definition tacselect.c:24
int tacYUnitConvert(TAC *tac, const int u, TPCSTATUS *status)
Definition tacunits.c:72
int tacIsWeighted(TAC *tac)
Definition tacw.c:24
int tacXCopy(TAC *tac1, TAC *tac2, int i1, int i2)
Definition tacx.c:24
Header file for library libtpcextensions.
#define MAX_TACNAME_LEN
Max length of TAC ID name (not including trailing zero).
@ UNIT_UNKNOWN
Unknown unit.
@ TPCERROR_UNKNOWN_UNIT
Unknown data unit.
@ TPCERROR_CANNOT_OPEN
Cannot open file.
@ TPCERROR_OK
No error.
#define MAX_STUDYNR_LEN
Define max study number length.
Header file for library libtpcift.
Header file for library libtpctac.
@ TAC_FORMAT_UNKNOWN
Unknown format.
Definition tpctac.h:28