Added some includes
[h316.git] / pc-tools / ldc2 / src / config.cpp
index 974fc91581d90f70b9036c1f5e74426f0ead1014..b5d3cdec94c4b9f772401678356ff2586bdf2b91 100644 (file)
@@ -1,3 +1,26 @@
+/******************************************************************************
+ * 
+ * LDC2 source code
+ *
+ * $Date: 2008/10/01 13:30:14 $
+ * $Author: hachti $
+ *
+ * $Log: config.cpp,v $
+ * Revision 2.3  2008/10/01 13:30:14  hachti
+ * Added some includes
+ *
+ * Revision 2.2  2008-08-25 21:02:24  hachti
+ * *** empty log message ***
+ *
+ * Revision 2.1  2007-12-23 15:25:11  hachti
+ * *** empty log message ***
+ *
+ * Revision 2.0  2007-03-26 01:00:38  hachti
+ * *** empty log message ***
+ *
+ *
+ ******************************************************************************/
 /*
  * Program configuration management
  */
@@ -7,9 +30,11 @@
 
 #include <stdio.h>
 #include <unistd.h>
+#include <stdlib.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <stdlib.h>
 
 #include "configuration_manager.hh"
 #include "tool.hh"
@@ -26,21 +51,24 @@ int cfg_output_info=0;
 int cfg_output_called=0;
 int cfg_output_exported=0;
 int cfg_output_unsatisfied=0;
-int cfg_splitobjects=0;
-int cfg_splitobjects_numbered=0;
+int cfg_split_objects=0;
+int cfg_split_objects_numbered=0;
+int cfg_split_blocks=0;
 int cfg_ignore_block_errors=0;
 int cfg_ignore_checksum_errors=0;
-int cfg_pause_on_checksum_error=0;
+//int cfg_pause_on_checksum_error=0;
 int cfg_ignore_unknown_block_errors=0;
 int cfg_ignore_object_integrity_errors=0;
 int cfg_list_contents=1;
 int cfg_verbose=0;
+int cfg_quiet=0;
+int cfg_dump_block_contents=0;
+
 int cfg_version=0;
 
 int in_fd=0;  //! File descriptor for data input 
 int out_fd=1; //! File descriptor for text output
 
-
 void do_config(int argc, char ** args){
 
   string cfg_config_file;
@@ -59,6 +87,10 @@ void do_config(int argc, char ** args){
                       "Print all called symbols from the object(s).",
                       &cfg_output_called,true,true);
 
+  ar.add_option_switch("d","dump_block_contents",
+                      "Dump block contents",
+                      &cfg_dump_block_contents,true,true);
+
   ar.add_option_switch("e","output_exported",
                       "Print all exported symbols from the object(s).",
                       &cfg_output_exported,true,true);
@@ -67,14 +99,18 @@ void do_config(int argc, char ** args){
                       "List all unsatisfied symbols.",
                       &cfg_output_unsatisfied,true,true);
 
-  ar.add_option_switch("S","split_objects_numbered",
-                      "Split input data into distinct numbered files",
-                      &cfg_splitobjects_numbered,true,true);
-
   ar.add_option_switch("s","split_objects",
                       "Split input data into distinct object files.",
-                      &cfg_splitobjects,true,true);
+                      &cfg_split_objects,true,true);
   
+  ar.add_option_switch("S","split_objects_numbered",
+                      "Split input data into distinct numbered files",
+                      &cfg_split_objects_numbered,true,true);
+
+  ar.add_option_switch("B","split_blocks",
+                      "Split tape into named and numbered block files",
+                      &cfg_split_blocks,true,true);
+
   ar.add_option_switch("b","ignore_block_errors",
                       "Ignore block integrity errors. This will output broken blocks,too",
                       &cfg_ignore_block_errors,true,true);
@@ -83,9 +119,9 @@ void do_config(int argc, char ** args){
                       "Ignore block checksum errors. Errors will be converted to warnings.",
                       &cfg_ignore_checksum_errors,true,true);
 
-  ar.add_option_switch("p","pause_on_checksum_error",
-                      "Wait for user input on checksum error.",
-                      &cfg_pause_on_checksum_error,true,true);
+//   ar.add_option_switch("p","pause_on_checksum_error",
+//                    "Wait for user input on checksum error.",
+//                    &cfg_pause_on_checksum_error,true,true);
   
   ar.add_option_switch("n","ignore_unknown_block_errors",
                       "Ignore errors caused by unknown block types. Errors will be converted to warnings.",
@@ -97,9 +133,13 @@ Errors will be converted to warnings.",
                       &cfg_ignore_object_integrity_errors,true,true);
 
   ar.add_option_switch("v","verbose",
-                      "Be a bit more verbose.",
+                      "Be a bit more verbose. This overrides -q.",
                       &cfg_verbose,true,true);
 
+  ar.add_option_switch("q","quiet",
+                      "Be quiet. All warning messages are suppressed.",
+                      &cfg_quiet,true,true);
+
   ar.add_option_switch("V","version",
                       "Output version information and exit.",
                       &cfg_version,false,true);
@@ -131,21 +171,21 @@ Errors will be converted to warnings.",
   // If there's a config file mentioned in the environment, take it!
   char * env_ldc_config=getenv("LDC_CONFIG");
   if(env_ldc_config){
-    fprintf(stderr,"Using config file: \"%s\"\n",env_ldc_config);
-    if(dump_vector_err(ar.read_file(env_ldc_config))){
-      dump_vector_err(ar.get_help());
+    if (cfg_verbose) fprintf(stderr,"Using config file: \"%s\"\n",env_ldc_config);
+    if(dump_vector_fp(ar.read_file(env_ldc_config),stderr)){
+      dump_vector_fp(ar.get_help(),stderr);
       exit(1);
     }
   }
 
   // Process command line first time
-  if(dump_vector_err(ar.read_args(argc,args))){
-    dump_vector_err(ar.get_help());
+  if(dump_vector_fp(ar.read_args(argc,args),stderr)){
+    dump_vector_fp(ar.get_help(),stderr);
     exit(7);
   }
   
   if (cfg_do_help) {
-    dump_vector_err(ar.get_help());
+    dump_vector_fp(ar.get_help(),stderr);
     exit(0);
   }
 
@@ -153,14 +193,14 @@ Errors will be converted to warnings.",
   if (cfg_config_file_set){
     if (cfg_verbose) 
       fprintf(stderr,"Using config file: \"%s\"\n",cfg_config_file.c_str());
-    if(dump_vector_err(ar.read_file(cfg_config_file))){
-      dump_vector_err(ar.get_help());
+    if(dump_vector_fp(ar.read_file(cfg_config_file),stderr)){
+      dump_vector_fp(ar.get_help(),stderr);
       exit(7);
     }
 
     // Process command line a second time to override values from config file.
-    if(dump_vector_err(ar.read_args(argc,args))||cfg_do_help){
-      dump_vector_err(ar.get_help());
+    if(dump_vector_fp(ar.read_args(argc,args),stderr)||cfg_do_help){
+      dump_vector_fp(ar.get_help(),stderr);
       exit(7);
     }
   }
@@ -187,12 +227,15 @@ Errors will be converted to warnings.",
     }
   }
   
+  // Verbose overrides quiet:
+  if (cfg_verbose)cfg_quiet=0;
+
   // The configuration implications according to /cfg007/
-  if (in_fd==0) cfg_pause_on_checksum_error=0;
-  if (cfg_pause_on_checksum_error==1) cfg_ignore_checksum_errors=1;
+  //  if (in_fd==0) cfg_pause_on_checksum_error=0;
+  // if (cfg_pause_on_checksum_error==1) cfg_ignore_checksum_errors=1;
 
-  if (cfg_output_info||cfg_output_called||cfg_output_exported||cfg_output_unsatisfied)
-    cfg_list_contents=0;
+  if (cfg_output_info||cfg_output_called||cfg_output_exported||
+      cfg_output_unsatisfied) cfg_list_contents=0;
 }