/* $Id: lookup.c,v 1.3 2004/03/30 07:19:17 jmuelmen Exp $ */ #include #include #include #include int look_yyparse (); int look_set_input (FILE *); void look_gen (double Rd, double Rv, double Rw); static void usage () { fprintf(stderr, "lookup: usage: lookup -o out.file " "infile1 [infile2 [...] ]\n"); exit(1); } FILE *outfile; #define STRLEN 1024 #define NIN 4 int main (int argc, char **argv) { int i_in; int n_in; char outname[STRLEN]; char inname[NIN][STRLEN]; signed char c; i_in = 0; while ((c = getopt(argc, argv, "-o:")) != -1) { switch (c) { case 'o': outname[STRLEN - 1] = 0; strncpy(outname, optarg, STRLEN - 1); break; case 1: if (i_in == NIN) { fprintf(stderr, "Only %d infiles are allowed\n", NIN); exit(1); } inname[i_in][STRLEN - 1] = 0; strncpy(inname[i_in++], optarg, STRLEN - 1); break; default: usage(); break; } } if (!(outfile = fopen(outname, "w"))) { perror("Opening output file"); return -1; } n_in = i_in; for (i_in = 0; i_in < n_in; ++i_in) { FILE *infile; if (!(infile = fopen(inname[i_in], "r"))) { perror(inname[i_in]); exit(1); } look_set_input(infile); look_yyparse(); fclose(infile); } fclose(outfile); return 0; }