*** empty log message ***
[h316.git] / pc-tools / ldc2 / src / main.cpp
index eabe7fb8cca7d2c0ea78dba908910408c07368e8..dc2d12473ce6e5ccd2501f1b2d6b1baa6d8f3779 100644 (file)
@@ -2,25 +2,26 @@
  * 
  * LDC2 source code
  *
- * $Date: 2007/03/26 01:00:40 $
+ * $Date: 2007/03/26 01:15:21 $
  * $Author: hachti $
  *
  * $Log: main.cpp,v $
- * Revision 2.0  2007/03/26 01:00:40  hachti
+ * Revision 2.1  2007/03/26 01:15:21  hachti
+ * *** empty log message ***
+ *
+ * Revision 2.0  2007-03-26 01:00:40  hachti
  * *** empty log message ***
  *
  *
  ******************************************************************************/
  
-/* ldc2 preliminary main program */
-
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 
 #include <vector>
 #include <string>
-
+  
 #include "config.hh"
 #include "tool.hh"
 
@@ -51,7 +52,13 @@ static int errors=0;
 static int warnings=0;
 static int errcode=0;  //! Variable for error codes.
 
-
+/******************************************************************************/
+/*!
+ *\brief Error exit routine.
+ *
+ * This routine tests the global error counter and terminates the program
+ * if necessary.
+ */
 void exit_on_error(){
   if (errors){
     fprintf(stderr,"Failed. (%i)\n",errcode);
@@ -264,7 +271,9 @@ void process_tape(){
        if (fd<0){
          fprintf(stderr,"Error: could not open file \"%s\" for writing!\n",
                  filename);
-       exit (1);
+         errors++;
+         errcode=1;
+         return;
        }
       }
 
@@ -276,7 +285,9 @@ void process_tape(){
        if (fd_numbered<0){
          fprintf(stderr,"Error: could not open file \"%s\" for writing!\n",
                  filename_numbered);
-       exit (1);
+         errors++;
+         errcode=1;
+         return;
        }
       }
       in_object=true;
@@ -291,7 +302,9 @@ void process_tape(){
       catch (tape_block::io_error_exception e){
        fprintf(stderr,"Error: could write to file \"%s\"!\n",
                filename);
-       exit (1);
+       errors++;
+       errcode=1;
+       return;
       }
     } // if (cfg_split_objects)
 
@@ -303,7 +316,9 @@ void process_tape(){
       catch (tape_block::io_error_exception e){
        fprintf(stderr,"Error: could write to file \"%s\"!\n",
                filename_numbered);
-       exit (1);
+         errors++;
+         errcode=1;
+         return;
       }
     } // if (cfg_split_objects_numbered)
 
@@ -315,7 +330,9 @@ void process_tape(){
       if (fd_block<0){
          fprintf(stderr,"Error: could not open file \"%s\" for writing!\n",
                  fname);
-       exit (1);
+         errors++;
+         errcode=1;
+         return;
       }
       try{
        block->dump_to_fd(fd_block);
@@ -323,7 +340,9 @@ void process_tape(){
       catch (tape_block::io_error_exception e){
        fprintf(stderr,"Error: could write to file \"%s\"!\n",
                fname);
-       exit (1);
+       errors++;
+       errcode=1;
+       return;
       }
       close(fd_block);
     }
@@ -346,10 +365,12 @@ void process_tape(){
       return;
     }
   }
-   
-
 } // process_tape()
 
+/******************************************************************************/
+/*!
+ *\brief Everything that has to do with symbol listing.
+ */
 void process_called_imports(){
   vector<string>exported;
   vector<string>called;
@@ -399,6 +420,7 @@ void process_called_imports(){
 /******************************************************************************/
 /*!
  *\brief The main routine.
+ *
  */
 int main(int argc, char ** args){