Initial snark14m import
[snark14.git] / src / snark / main.cpp
1 /*
2  ***********************************************************
3  $SNARK_Header: S N A R K  1 4 - A PICTURE RECONSTRUCTION PROGRAM $
4  $HeadURL: svn://dig.cs.gc.cuny.edu/snark/trunk/src/snark/main.cpp $
5  $LastChangedRevision: 118 $
6  $Date: 2014-07-09 14:22:29 -0400 (Wed, 09 Jul 2014) $
7  $Author: agulati $
8  ***********************************************************
9  */
10
11 #include <cstdio>
12
13 //jk 12/08/07  combining snark with experimenter into a single program
14 #include <unistd.h>         //provides routine for parsing the command line
15
16 #include "snark.h"
17 extern "C"
18 {
19 #include "experimenter.h"
20 }
21
22 int main(int argc, char *argv[])
23 {
24         int choice = 1;       //runs "plain snark" by default
25         int c;
26         extern int optind, optopt;
27
28         while ((c = getopt(argc, argv, "eh")) != -1)
29         {
30                 switch (c)
31                 {
32                 case 'e':
33                         choice = 2;
34                         break;
35                 case 'h':
36                         fprintf(stderr, "\nsnark14 [-e] [-h] [input_file] [>>output_file]\n");
37                         fprintf(stderr, "  \tRuns snark14 image reconstruction program.\n");
38                         fprintf(stderr, "  \nOPTIONS:\n");
39                         fprintf(stderr, "  -e \truns the experimenter\n");
40                         fprintf(stderr, "  -h \tdisplays this help message\n");
41                         fprintf(stderr, "  input_file \tcontains input for either snark14 or experimenter \n");
42                         fprintf(stderr, "  >>output_file \toutput is redirected to this file\n\n");
43                         return 0;
44                 case '?':
45                         fprintf(stderr,
46                                         "Unrecognized option: -%c\nRun \"snark14 -h\"  for more information.\n\n",
47                                         optopt);
48                         return -1;
49
50                 }
51         }
52
53         if (argc - optind + 1 > 2)
54         {
55                 fprintf(stderr, "ERROR: too many arguments on the command line.\n"
56                                 "Run \"snark14 -h\"  for more information.\n\n");
57                 return 0;
58         }
59
60         if (1 == choice)
61         {
62                 //call snark14 and pass the parameters
63                 snark(argc - optind + 1, argv);
64         }
65         else if (2 == choice)
66         {
67                 //call snark14Experimenter and pass the parameters
68                 experimenter(argc - optind + 1, argv);
69         }
70         else
71         {
72                 fprintf(stderr, "Error: Invalid choice entered. \n\n");
73         }
74
75         return 0;
76
77 } //end of main