8#include "tpcclibConfig.h"
22static char *info[] = {
23 "List TAC names inside a TAC files.",
25 "Usage: @P [options] files",
29 " List only files that contain TAC(s) with missing name.",
31 " Return error code if TAC(s) with missing name.",
34 "See also: taclist, tacren, tacadd, tacformat, iftren",
36 "Keywords: TAC, tool, rename, simulation",
55int main(
int argc,
char **argv)
57 int ai, help=0, version=0, verbose=1;
58 int ret, listMissing=0, errorIfMissing=0;
65 if(argc==1) {
tpcPrintUsage(argv[0], info, stderr);
return(1);}
67 for(ai=1; ai<argc; ai++)
if(*argv[ai]==
'-') {
69 cptr=argv[ai]+1;
if(*cptr==
'-') cptr++;
if(!*cptr)
continue;
70 if(strncasecmp(cptr,
"MISSING", 3)==0) {
71 listMissing=1;
continue;
72 }
else if(strncasecmp(cptr,
"ERRORIFMISSING", 3)==0) {
73 errorIfMissing=1;
continue;
75 fprintf(stderr,
"Error: invalid option '%s'\n", argv[ai]);
84 if(help==2) {
tpcHtmlUsage(argv[0], info,
"");
return(0);}
89 if(ai>=argc) {fprintf(stderr,
"Error: missing filenames.\n");
return(1);}
91 for(; ai<argc; ai++)
iftPut(&fnames,
"", argv[ai], 0, &status);
96 printf(
"listMissing := %d\n", listMissing);
97 printf(
"errorIfMissing := %d\n", errorIfMissing);
98 printf(
"fileNr := %d\n", fnames.
keyNr);
107 char tacfile[FILENAME_MAX], tacname[256];
108 for(
int fi=0; fi<fnames.
keyNr; fi++) {
110 if(verbose>2) printf(
"reading %s\n", tacfile);
111 ret=
tacRead(&tac, tacfile, &status);
113 fprintf(stderr,
"Error: cannot read %s\n", tacfile);
118 for(
int ti=0; ti<tac.
tacNr; ti++) {
120 if(verbose>3) printf(
"\t%d\t%s\n", 1+ti, tacname);
121 if(!tacname[0] || strcmp(tacname,
".")==0) {missingNr++;
continue;}
123 if(
iftFindKey(&tnames, tacname, 0)>=0)
continue;
124 iftPut(&tnames, tacname,
"", 0, NULL);
130 printf(
"\n%d missing TAC names.\n", missingNr);
131 printf(
"\nTAC names:\n==========\n");
132 for(
int ti=0; ti<tnames.
keyNr; ti++) printf(
"%s\n", tnames.
item[ti].
key);
134 if(listMissing && missingNr==0) {
135 fprintf(stdout,
"Note: no missing TAC names.\n");
143 char tacfile[FILENAME_MAX], tacname[256];
145 if(listMissing==0)
for(
int ti=0; ti<tnames.
keyNr; ti++) {
147 printf(
"%s\n", tacname);
148 for(
int fi=0; fi<fnames.
keyNr; fi++) {
150 if(verbose>10) printf(
"reading %s\n", tacfile);
151 ret=
tacRead(&tac, tacfile, &status);
153 fprintf(stderr,
"Error: cannot read %s\n", tacfile);
158 for(
int ti=0; ti<tac.
tacNr; ti++) {
159 if(strcasecmp(tacname, tac.
c[ti].
name)==0) {
160 printf(
"\t%s\n", tacfile);
169 printf(
"Missing TAC name\n");
170 for(
int fi=0; fi<fnames.
keyNr; fi++) {
172 if(verbose>10) printf(
"reading %s\n", tacfile);
173 ret=
tacRead(&tac, tacfile, &status);
175 fprintf(stderr,
"Error: cannot read %s\n", tacfile);
180 for(
int ti=0; ti<tac.
tacNr; ti++) {
182 if(verbose>11) printf(
"\t%d\t%s\n", 1+ti, tacname);
183 if(!tacname[0] || strcmp(tacname,
".")==0) {
184 printf(
"\t%s\n", tacfile);
195 if(errorIfMissing!=0 && missingNr>0) {
196 fprintf(stderr,
"Error: missing TAC name(s).\n");
int iftPut(IFT *ift, const char *key, const char *value, char comment, TPCSTATUS *status)
int iftFindKey(IFT *ift, const char *key, int start_index)
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)
char name[MAX_TACNAME_LEN+1]
int verbose
Verbose level, used by statusPrint() etc.
tpcerror error
Error code.
int tacRead(TAC *d, const char *fname, TPCSTATUS *status)
Header file for library libtpcextensions.
Header file for library libtpcift.
Header file for library libtpctac.