TPCCLIB
Loading...
Searching...
No Matches
reslist.c
Go to the documentation of this file.
1
7/*****************************************************************************/
8#include "tpcclibConfig.h"
9/*****************************************************************************/
10#include <stdio.h>
11#include <stdlib.h>
12#include <string.h>
13#include <math.h>
14#include <time.h>
15/*****************************************************************************/
16#include "libtpcmisc.h"
17#include "libtpccurveio.h"
18/*****************************************************************************/
19
20/*****************************************************************************/
21static char *info[] = {
22 "Lists the user-specified regional results on screen.",
23 "Note: result file must not be in HTML format.",
24 " ",
25 "Usage: @P [Options] filename [tacid]",
26 " ",
27 "Options:",
28 " -n",
29 " CL or SD values are not listed.",
30 " -ift",
31 " Results are listed in IFT format.",
32 " -stdoptions", // List standard options like --help, -v, etc
33 " ",
34 "Example:",
35 " @P ut6789ki.res put",
36 " ",
37 "See also: resdel, rescoll, resmatch, fit2res, resrmdpl, parformat, parget",
38 " ",
39 "Keywords: results, IFT, software testing",
40 0};
41/*****************************************************************************/
42
43/*****************************************************************************/
44/* Turn on the globbing of the command line, since it is disabled by default in
45 mingw-w64 (_dowildcard=0); in MinGW32 define _CRT_glob instead, if necessary;
46 In Unix&Linux wildcard command line processing is enabled by default. */
47/*
48#undef _CRT_glob
49#define _CRT_glob -1
50*/
51int _dowildcard = -1;
52/*****************************************************************************/
53
54/*****************************************************************************/
58int main(int argc, char **argv)
59{
60 int ai, help=0, version=0, verbose=1;
61 int pi, ri, ret, m, n, listStat=1, toIFT=0;
62 RES res;
63 char resfile[FILENAME_MAX], *cptr;
64
65
66 /*
67 * Get arguments
68 */
69 if(argc==1) {tpcPrintUsage(argv[0], info, stderr); return(1);}
70 resfile[0]=(char)0;
71 resInit(&res);
72 for(ai=1; ai<argc; ai++) if(*argv[ai]=='-') {
73 if(tpcProcessStdOptions(argv[ai], &help, &version, &verbose)==0) continue;
74 cptr=argv[ai]+1; if(*cptr=='-') cptr++; if(!cptr[0]) continue;
75 if(*cptr=='N' || *cptr=='n') {
76 listStat=0; continue;
77 } else if(strcasecmp(cptr, "IFT")==0) {
78 toIFT=1; continue;
79 }
80 fprintf(stderr, "Error: invalid option '%s'.\n", argv[ai]);
81 return(1);
82 } else break;
83
84 /* Print help or version? */
85 if(help==2) {tpcHtmlUsage(argv[0], info, ""); return(0);}
86 if(help) {tpcPrintUsage(argv[0], info, stdout); return(0);}
87 if(version) {tpcPrintBuild(argv[0], stdout); return(0);}
88
89 /* Get the name of result file */
90 if(ai<argc) {
91 strlcpy(resfile, argv[ai], FILENAME_MAX); ai++;
92 } else {
93 fprintf(stderr, "Error: missing command-line argument; use option --help\n");
94 return(1);
95 }
96
97 /* In verbose mode print arguments and options */
98 if(verbose>1) {
99 printf("resfile := %s\n", resfile);
100 printf("listStat := %d\n", listStat);
101 printf("toIFT := %d\n", toIFT);
102 }
103
104
105 /*
106 * Read result file
107 */
108 if(verbose>1) printf("reading %s\n", resfile);
109 ret=resRead(resfile, &res, verbose-2);
110 if(ret) {
111 fprintf(stderr, "Error in reading '%s': %s\n", resfile, reserrmsg);
112 resEmpty(&res);
113 return(2);
114 }
115
116
117 /*
118 * Select the regions with user-defined IDs, or, if not defined,
119 * then select all for listing.
120 */
121 if(ai>=argc) {
122 for(ri=0; ri<res.voiNr; ri++) res.voi[ri].sw=1;
123 } else {
124 m=0;
125 for(; ai<argc; ai++) {
126 if(verbose>2) printf("searching for region %s\n", argv[ai]);
127 n=0; ri=atoi(argv[ai])-1; /* maybe its the region number? */
128 if(ri<res.voiNr && ri>=0) { /* select that region if it exists */
129 res.voi[ri].sw=1; n=1;
130 } else { /* if not then it is the region name */
131 n=resSelectRegions(&res, argv[ai], 0);
132 }
133 m+=n;
134 }
135 if(m==0) {
136 fprintf(stderr, "Error: TAC IDs did not match with any of the regions.\n");
137 resEmpty(&res); return(1);
138 }
139 }
140
141
142
143
144 /*
145 * Delete those regions that were not selected
146 */
147 ri=res.voiNr-1;
148 while(ri>=0) {
149 if(res.voi[ri].sw!=1) ret=resDelete(&res, ri);
150 ri--;
151 }
152
153
154 /*
155 * Set SDs and CVs to NaN, if they are not to be printed
156 */
157 if(listStat==0) for(ri=0; ri<res.voiNr; ri++) for(pi=0; pi<res.parNr; pi++) {
158 res.voi[ri].sd[pi]=nan("");
159 res.voi[ri].cl1[pi]=nan("");
160 res.voi[ri].cl2[pi]=nan("");
161 }
162
163
164 /*
165 * Print the ones that are left
166 */
167 if(toIFT==0) {
168 resPrint(&res);
169 } else {
170 IFT ift;
171 iftInit(&ift);
172 ret=res2ift(&res, &ift, verbose-1);
173 if(ret==0) iftWrite(&ift, "stdout", 0);
174 iftEmpty(&ift);
175 }
176 fprintf(stdout, "\n");
177
178 resEmpty(&res);
179
180 return(0);
181}
182/*****************************************************************************/
184/*****************************************************************************/
void iftEmpty(IFT *ift)
Definition ift.c:60
void iftInit(IFT *ift)
Definition ift.c:45
int iftWrite(IFT *ift, char *filename, int verbose)
Definition iftfile.c:282
Header file for libtpccurveio.
char reserrmsg[64]
Definition result.c:6
void resInit(RES *res)
Definition result.c:52
int resSelectRegions(RES *res, char *region_name, int reset)
Definition result.c:1417
void resPrint(RES *res)
Definition result.c:186
int resDelete(RES *res, int voi)
Definition result.c:1342
int resRead(char *filename, RES *res, int verbose)
Definition result.c:199
int res2ift(RES *res, IFT *ift, int verbose)
Definition resift.c:14
void resEmpty(RES *res)
Definition result.c:22
Header file for libtpcmisc.
int tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
Definition proginfo.c:40
size_t strlcpy(char *dst, const char *src, size_t dstsize)
Definition strext.c:245
int tpcHtmlUsage(const char *program, char *text[], const char *path)
Definition proginfo.c:213
void tpcPrintBuild(const char *program, FILE *fp)
Definition proginfo.c:383
void tpcPrintUsage(const char *program, char *text[], FILE *fp)
Definition proginfo.c:158
int parNr
int voiNr
ResVOI * voi
double cl2[MAX_RESPARAMS]
double cl1[MAX_RESPARAMS]
double sd[MAX_RESPARAMS]