00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifdef HAVE_CONFIG_H
00019 #include <config.h>
00020 #endif
00021
00022 #include <iostream>
00023 #include <cstdio>
00024 #include <list>
00025 #include <unistd.h>
00026
00027 using namespace std;
00028
00029 #include "messenger.h"
00030 #include "project.h"
00031 #include "projectFile.h"
00032
00033
00034 #if 0
00035 #define DEBUG 1
00036 #endif
00037
00039 typedef list<const char *> L_FILENAME;
00040
00044 static void usage(FILE *out, const char *progName)
00045 {
00046 fprintf(out, "USAGE: %s [-d] [-v] [-h] file1 [file2 file3 ...]\n", progName);
00047 }
00048
00050 void version (FILE * out)
00051 {
00052
00053 #if (defined(PACKAGE) && defined(VERSION))
00054 (void) fprintf (out, "%s %s\n", PACKAGE, VERSION);
00055 #else
00056 (void) fprintf (out,
00057 "No package-version available (due to generation).\n"
00058 "CVS/RCS informations: $RCSfile: main.cc,v $ $Revision: 1.8 $\n");
00059 #endif
00060
00061
00062 (void) fprintf (out,
00063 "Copyright (C) 2000 Idan Shoham\n"
00064 "This program comes with NO WARRANTY.\n"
00065 "You may redistribute copies of it under the terms of the\n"
00066 "GNU General Public License.\n"
00067 "For more information about these matters,\n"
00068 "see the files named COPYING.\n");
00069 }
00070
00071 int main(int argc, char **argv)
00072 {
00073 ProjectFile projectFile;
00074 L_FILENAME files;
00075 L_FILENAME::iterator file;
00076 extern char *optarg;
00077 extern int optind, opterr, optopt;
00078 int c;
00079 int nbErrors = 0;
00080
00081
00082 MESSENGER::setGlobalDebug(false);
00083
00084 while ((c = getopt(argc, argv, "vhd")) != -1)
00085 {
00086 switch (c)
00087 {
00088 case 'v':
00089 version(stdout);
00090 return EXIT_SUCCESS;
00091 break;
00092 case 'h':
00093 usage(stdout, argv[0]);
00094 return EXIT_SUCCESS;
00095 break;
00096 case 'd':
00097 MESSENGER::setGlobalDebug(true);
00098 break;
00099 case '?':
00100 default:
00101 nbErrors++;
00102 break;
00103 }
00104 }
00105
00106
00107
00108
00109
00110
00111
00112
00113 if (nbErrors > 0)
00114 {
00115 usage(stderr, argv[0]);
00116 return EXIT_FAILURE;
00117 }
00118
00119 while (optind < argc)
00120 {
00121 files.push_back(argv[optind]);
00122 optind++;
00123 }
00124
00125 try
00126 {
00127 if ( files.size() == 0 )
00128 {
00129 projectFile.Load("workplan.sched");
00130 }
00131 else
00132 {
00133 for (file = files.begin() ; file != files.end() ; file++)
00134 {
00135 projectFile.Load(*file);
00136 }
00137 }
00138 }
00139 catch ( ProjectFileException & e )
00140 {
00141 cerr << "Project not loaded: " << e.what() << endl;
00142 return EXIT_FAILURE;
00143 }
00144
00145 try
00146 {
00147 projectFile.checkComplete();
00148
00149 #ifdef DEBUG
00150 projectFile.Print();
00151 #endif
00152
00153 Project project = projectFile.project();
00154 project.DoScheduling();
00155
00156 Reporter reporter = projectFile.reporter();
00157 reporter.DoReports( &project );
00158
00159 }
00160 catch ( OpenschedException & e )
00161 {
00162 cerr << e.what() << endl;
00163 return EXIT_FAILURE;
00164 }
00165
00166 return EXIT_SUCCESS;
00167 }