home *** CD-ROM | disk | FTP | other *** search
- /*
- This applies an lower bound to a var file
- The syntax is:
- lowerbound bound [input.var [output.var]]
- */
- #include <stream.h>
- #include <stdio.h>
- #include <vartools.h++>
-
-
- int
- main ( int argc , char *argv[] )
- {
- switch(argc)
- {
- // with 1 argument it acts as a pipe
- case 2:
- lower_bound(atof(argv[1]),stdin,stdout,"Bounding file from stdin\n");
- break;
- // with 2 arguments it reads from specified file and writes to stdout
- case 3:
- FILE *input;
- if(NULL == (input = fopen(argv[2],"r")))
- {
- perror(form("lowerbound problem with openning %s:",argv[2]));
- return 5;
- }
- lower_bound(atof(argv[1]),input,stdout,form("bounding file %s\n",argv[2]));
- break;
- // with 3 arguments it reads from specified file and writes to
- // specified file
- case 4:
- FILE *input;
- FILE *output;
- if(NULL == (input = fopen(argv[2],"r")))
- {
- perror(form("lowerbound problem with openning %s:",argv[2]));
- return 5;
- }
- if(NULL == (output = fopen(argv[3],"w")))
- {
- perror(form("lowerbound problem with openning %s:",argv[3]));
- return 6;
- }
- lower_bound(atof(argv[1]),input,output,form("bounding file %s to file %s\n",argv[2],argv[3]));
- break;
- // otherwise wrong number of arguments failure!
- default:
- cerr << "Syntax is: lowerbound bound [input.var [output.var]]";
- return 1;
- break;
- }
- return 0;
- }
- /*
- Copyright (C) 1986, David Sher in the University of Rochester
- Permission is granted to any individual or institution to use, copy, or
- redistribute this software so long as it is not sold for profit, provided
- this copyright notice is retained.
- */
-