*** empty log message ***
[h316.git] / pc-tools / ldc2 / src / main.cpp
index 3e1244b19e98690c7456d1682e49238ebf4321bb..a86291b519c9ed0d5e2750050a6c091d3b6e8dec 100644 (file)
@@ -10,7 +10,7 @@
 #include <fcntl.h>
 
 #include "tape_block.hh"
-#include "argument_reader.hh"
+#include "configuration_manager.hh"
 
 using namespace std;
 
@@ -27,32 +27,110 @@ int dump_vector(vector<string> arguments){
 
 int main(int argc, char ** args){
   
+  /* Configuration data */
+  string config_file;
   string infile, outfile;
-  int infile_set, outfile_set;
-  int help_wanted;
+  int infile_set, outfile_set, config_file_set;
   
-  int greet_want;
-  string greetings;
+  int 
+    do_help,
+    output_info,
+    output_called,
+    output_exported,
+    output_unsatisfied,
+    split_objects,
+    split_objects_numbered,
+    ignore_block_errors,
+    ignore_checksum_errors,
+    pause_on_checksum_error,
+    ignore_unknown_block_errors,
+    ignore_object_integrity_errors;
   
   int in_fd, out_fd;
 
-  in_fd=0;  //stdin   {O _ \ 
-  out_fd=1; //stdout  {O ^ /
+  in_fd=0;  /* stdin   {O _ \ */
+  out_fd=1; /* stdout  {O ^ / */
 
-  argument_reader ar("ldc2");
-  ar.add_param("h","help","Output this help text.",&help_wanted);
-  ar.add_param("g","greet","Wonderful bla bla. It is here only to test the output\
-capabilities of the arg_reader.",&greet_want);
-
-  ar.add_argument("<input-file>","File from where data is read",&infile_set,&infile);
-  ar.add_argument("<output-file>","File to where output is redirected",&outfile_set,&outfile);
-
-
-  if((dump_vector(ar.read_args(argc,args))||help_wanted)){
+  configuration_manager ar("ldc2");
+  
+  /* Here come the configuration switches */
+  ar.add_option_switch("h","help",
+                      "Output this help text and exit.",
+                      &do_help,true,false);
+
+  ar.add_option_switch("a","output_info",
+                      "Print tape data information (default)",
+                      &output_info);
+
+  ar.add_option_switch("c","output_called",
+                      "Print all called symbols from the object(s).",
+                      &output_called);
+
+  ar.add_option_switch("e","output_exported",
+                      "Print all exported symbols from the object(s).",
+                      &output_exported);
+
+  ar.add_option_switch("u","output_unsatisfied",
+                      "List all unsatisfied symbols.",
+                      &output_unsatisfied);
+
+  ar.add_option_switch("s","split_objects",
+                      "Split input data into distinct object files.",
+                      &split_objects);
+
+  ar.add_option_switch("S","split_objects_numbered",
+                      "Split input data into distinct numbered files",
+                      &split_objects_numbered);
+
+  ar.add_option_switch("b","ignore_block_errors",
+                      "Ignore block integrity errors. This will output broken blocks,too",
+                      &ignore_block_errors);
+
+  ar.add_option_switch("k","ignore_checksum_errors",
+                      "Ignore block checksum errors. Errors will be converted to warnings.",
+                      &ignore_checksum_errors);
+
+  ar.add_option_switch("p","pause_on_checksum_error",
+                      "Wait for user input on checksum error.",
+                      &pause_on_checksum_error);
+  
+  ar.add_option_switch("n","ignore_unknown_block_errors",
+                      "Ignore errors caused by unknown block types. Errors will be converted to warnings.",
+                      &ignore_unknown_block_errors);
+
+  ar.add_option_switch("g","ignore_object_integrity_errors",
+                      "Ignore errors caused by objects without proper end block. \
+Errors will be converted to warnings.",
+                      &ignore_object_integrity_errors);
+  
+  ar.add_option_value("i","input_file",
+                     "specify input file",
+                 &infile_set,&infile,
+                 "<input-file>");
+                     
+  ar.add_option_value("o","output_file",
+                     "Specify output file.",
+                     &outfile_set,&outfile,
+                     "<output_file>");
+                     
+
+  ar.add_argument("File from where data is read",
+                 &infile_set,&infile,
+                 "<input-file>");
+
+  ar.add_argument("File to where output is redirected",
+                 &outfile_set,&outfile,
+                 "<output-file>");
+
+  ar.add_option_value("F","config_file",
+                     "Use the specified configuration file.", 
+                     &config_file_set,&config_file,
+                     "<file-name>");
+  
+  if((dump_vector(ar.read_args(argc,args))||do_help)){
     dump_vector(ar.get_help());
     exit(1);
   }
-  if(greet_want)printf("Hallo!\n");
   
   if (infile_set==1){
     printf("Opening file for input:%s\n",infile.c_str());
@@ -63,6 +141,9 @@ capabilities of the arg_reader.",&greet_want);
     }
   }
   
+  
+  
+  
   vector<tape_block*> tape;