*** empty log message ***
authorhachti <hachti>
Thu, 15 Mar 2007 06:54:02 +0000 (06:54 +0000)
committerhachti <hachti>
Thu, 15 Mar 2007 06:54:02 +0000 (06:54 +0000)
47 files changed:
pc-tools/ldc2/Makefile
pc-tools/ldc2/data/apfel3.f [new file with mode: 0644]
pc-tools/ldc2/doc/req_spec.tex
pc-tools/ldc2/ldc2.conf [new file with mode: 0644]
pc-tools/ldc2/src/config.cpp
pc-tools/ldc2/src/config.hh
pc-tools/ldc2/src/data_block.cpp
pc-tools/ldc2/src/data_block.hh
pc-tools/ldc2/src/data_block_0.cpp
pc-tools/ldc2/src/data_block_0.hh
pc-tools/ldc2/src/data_block_0_0.cpp
pc-tools/ldc2/src/data_block_0_0.hh
pc-tools/ldc2/src/data_block_0_1.cpp
pc-tools/ldc2/src/data_block_0_10.cpp
pc-tools/ldc2/src/data_block_0_14.cpp
pc-tools/ldc2/src/data_block_0_14.hh
pc-tools/ldc2/src/data_block_0_2.cpp
pc-tools/ldc2/src/data_block_0_24.cpp
pc-tools/ldc2/src/data_block_0_3.cpp
pc-tools/ldc2/src/data_block_0_30.cpp
pc-tools/ldc2/src/data_block_0_4.cpp
pc-tools/ldc2/src/data_block_0_44.cpp
pc-tools/ldc2/src/data_block_0_44.hh
pc-tools/ldc2/src/data_block_0_50.cpp
pc-tools/ldc2/src/data_block_0_54.cpp
pc-tools/ldc2/src/data_block_0_60.cpp
pc-tools/ldc2/src/data_block_0_64.cpp
pc-tools/ldc2/src/data_block_1.cpp
pc-tools/ldc2/src/data_block_2.cpp
pc-tools/ldc2/src/data_block_3.cpp
pc-tools/ldc2/src/data_block_3.hh
pc-tools/ldc2/src/data_block_4.cpp
pc-tools/ldc2/src/data_block_4.hh
pc-tools/ldc2/src/data_block_5.cpp
pc-tools/ldc2/src/data_block_5.hh
pc-tools/ldc2/src/data_block_6.cpp
pc-tools/ldc2/src/data_block_6.hh
pc-tools/ldc2/src/data_block_7.cpp
pc-tools/ldc2/src/data_block_7.hh
pc-tools/ldc2/src/eot_block.cpp
pc-tools/ldc2/src/eot_block.hh
pc-tools/ldc2/src/hw_constants.hh
pc-tools/ldc2/src/main.cpp
pc-tools/ldc2/src/tape_block.cpp
pc-tools/ldc2/src/tape_block.hh
pc-tools/ldc2/src/tool.cpp
pc-tools/ldc2/src/tool.hh

index e5b9c8aa3f3fac8a33f8df04decab4c46746d1c5..677621256b3736cc6ce878ddf0d911118412e4ae 100644 (file)
@@ -3,7 +3,6 @@ APP_OBJECTS= main.o  silent_code.o configuration_manager.o tool.o config.o
 CCFLAGS+=-Wall
 
 
-
 BUILD_STAMP="\"`uname -a`\""
 VERSION="\"0.7\""
 BUILD_DATE="\"`date` \""
@@ -27,6 +26,7 @@ SRC_DIR=src
 
 default: $(APP_NAME)
 
+
 clean: 
        @rm -rf $(APP_NAME) *.o doxy/ $(SRC_DIR)/*~ ul_timestamp *.dep
        @$(MAKE) -C doc clean
diff --git a/pc-tools/ldc2/data/apfel3.f b/pc-tools/ldc2/data/apfel3.f
new file mode 100644 (file)
index 0000000..9aa716b
--- /dev/null
@@ -0,0 +1,259 @@
+C    APFELMAENNCHEN-PROGRAMM, 02.APRIL.2006 PHILIPP HACHTMANN
+C    INTERMEDIATE VERSION
+C
+C    THIS VERSION SHOULD RUN A BIT FASTER BECAUSE THE SQUARE
+C    ROOT IS OMMITTED.
+C
+C    SWITCH SETTINGS:
+C    SENSE-SWITCH 1: IF SET, ASK FOR PARAMETERS
+C    SENSE-SWITCH 2: IF SET, DON'T PRINT PARAMETERS ON START
+C    SENSE-SWITCH 3: IF SET, RESTORE PARAMETERS TO DEFAULT VALUES
+C
+CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+C                        COMMON BLOCK DECLARATIONS
+C
+       INTEGER        MAXI,WIDTH,CR,LF,POSI,NEGA
+       COMMON /PARAM2/MAXI,WIDTH,CR,LF,POSI,NEGA
+C
+       REAL           LOWX,LOWY,HIGHX,HIGHY,MAXVAL,XSTEP,YSTEP
+       COMMON /PARAM1/LOWX,LOWY,HIGHX,HIGHY,MAXVAL,XSTEP,YSTEP
+C
+       INTEGER INIT
+       COMMON /PARAM3/INIT
+C
+CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+C                        START MESSAGE
+  100  WRITE (1,10)
+   10  FORMAT (46HMANDELBROT-DEMO 3RC1 02.04.2006, PH. HACHTMANN,
+     + 20H - PRELIMIMARY ISSUE)
+C
+CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+C                        CONFIGURATION
+CCCCCC RESET DO DEFAULT VALUES?
+  110  CALL SSWTCH(3,I)
+       IF (I.EQ.1) CALL RST
+C    
+CCCCCC ON THE FIRST START OR IF DESIRED
+       IF(INIT.EQ.0) CALL STVAL
+C
+CCCCCC DO WE HAVE TO ASK FOR PARAMETERS?
+       CALL SSWTCH(1,I)
+       IF (I.EQ.1) CALL GETCFG
+C
+CCCCCC OUTPUT SETTINGS?      
+       CALL SSWTCH(2,I)
+       IF(I.EQ.2) CALL OUTCFG
+C
+       WRITE  (1,55)
+   55  FORMAT (1H0)
+C
+       CALL CALC2
+C
+       WRITE(1, 60)
+   60  FORMAT (5HREADY)
+C
+CCCCCC BREAK WITH 7 in A REG, THEN START OVER
+C       CALL PWAIT
+       PAUSE 7
+       GO TO 100
+       END
+C      END OF MAIN PROGRAM
+C
+CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+CCCCCC THE MANDELBROT SET CALCULATION
+       SUBROUTINE CALC2
+C            
+       INTEGER        MAXI,WIDTH,CR,LF
+       COMMON /PARAM2/MAXI,WIDTH,CR,LF
+       REAL           LOWX,LOWY,HIGHX,HIGHY,MAXVAL,XSTEP,YSTEP
+       COMMON /PARAM1/LOWX,LOWY,HIGHX,HIGHY,MAXVAL,XSTEP,YSTEP
+       REAL CMPAVL
+       REAL ZR,ZI,ZRN
+       REAL X,Y
+       INTEGER COUNT
+C
+CCCCCC ENTER THE CALCULATION
+  299  CMPVAL=MAXVAL*MAXVAL
+       X=LOWX
+       Y=HIGHY
+C     
+CCCCCC EINSTIEG IN DEN AKTUELLEN PUNKT
+  300  COUNT=0
+       ZR=0.0
+       ZI=0.0
+C
+CCCCCC HIER DER ITERIERTE TEIL
+C
+  400 ZRN=ZR*ZR-ZI*ZI+X
+      ZI=2.0*ZR*ZI+Y
+      ZR=ZRN
+C
+       IF ((ZR*ZR+ZI*ZI).GE.CMPVAL) GO TO 410
+       COUNT=COUNT+1
+       IF (COUNT.GE.MAXI)     GO TO 410
+       GO TO 400
+C
+CCCCCC PUNKT FERTIG
+  410  NOUT=32
+C       IF (COUNT.GE.8) NOUT=46
+C       IF (COUNT.GE.23) NOUT=43
+C       IF (COUNT.EQ.MAXI) NOUT=64
+       IF (COUNT.GE.8) NOUT=46
+       IF (COUNT.GE.23) NOUT=43
+       IF (COUNT.EQ.MAXI) NOUT=64
+
+  411  CALL PCHAR(NOUT)
+       GO TO 500
+C
+CCCCCC NEUEN PUNKT MACHEN
+  500  X = X + XSTEP
+CCCCCC ZEILE NOCH NICHT VOLL?
+       IF (X.LE.HIGHX) GO TO 300
+CCCCCC X AN ANFANG SETZTEN, CR+LF DRUCKEN
+       X = LOWX
+       CALL PCHAR(CR)
+       CALL PCHAR(LF)
+CCCCCC Y WEITERRUECKEN - NEGATIV WEIL WIR VON OBEN KOMMEN
+       Y=Y-YSTEP
+       IF (Y.GE.LOWY) GO TO 300
+C
+CCCCCC HIER IST DAS BILD FERTIG.       
+       RETURN
+       END 
+CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+CCCCCC STARTWERTE AUSFUELLEN
+       SUBROUTINE STVAL
+C
+       INTEGER        MAXI,WIDTH,CR,LF
+       COMMON /PARAM2/MAXI,WIDTH,CR,LF
+       REAL           LOWX,LOWY,HIGHX,HIGHY,MAXVAL,XSTEP,YSTEP
+       COMMON /PARAM1/LOWX,LOWY,HIGHX,HIGHY,MAXVAL,XSTEP,YSTEP
+       INTEGER INIT
+       COMMON /PARAM3/INIT
+C
+       CR      = 13 
+       LF      = 10
+       WIDTH   = 68
+       MAXI    = 60
+       MAXVAL  = 2.0
+       LOWX    =-1.48
+       HIGHX   = 0.5
+       LOWY    =-1.2
+       HIGHY   = 1.2
+       INIT    =  1
+C  
+CCCCCC SCHRITTWEITEN AUSRECHNEN
+       XSTEP = (HIGHX-LOWX)/FLOAT(WIDTH)
+       YSTEP = 2.0 * XSTEP
+C
+       WRITE (1,1500)
+ 1500  FORMAT (20HDEFAULT VALUES USED.)
+       RETURN
+       END
+C
+C
+CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+CCCCCC EINSTELLUNGEN EINLESEN
+       SUBROUTINE GETCFG
+C
+       INTEGER        MAXI,WIDTH,CR,LF
+       COMMON /PARAM2/MAXI,WIDTH,CR,LF
+       REAL           LOWX,LOWY,HIGHX,HIGHY,MAXVAL,XSTEP,YSTEP
+       COMMON /PARAM1/LOWX,LOWY,HIGHX,HIGHY,MAXVAL,XSTEP,YSTEP
+C
+       REAL XIN1,XIN2,YIN1,YIN2
+C
+       WRITE(1,11)
+       READ (1,16) XIN1
+       WRITE(1,12)
+       READ (1,16) XIN2
+       WRITE(1,13)
+       READ (1,16) YIN1
+       WRITE(1,14)
+       READ (1,16) YIN2
+       WRITE(1,15)
+       READ (1,17) MAXI
+C
+   11  FORMAT(14H X FROM     : )
+   12  FORMAT(14H     TO     : )       
+   13  FORMAT(14H Y FROM     : )
+   14  FORMAT(14H     TO     : )
+   15  FORMAT(14H  MAXIT (I3): )
+   16  FORMAT(F12.0)
+   17  FORMAT(I3)
+C
+CCCCCC EVENTUELL STARTWERTE TAUSCHEN:
+CCCCCC WENN XIN2 GROESSER IST OK, ANSONSTEN TAUSCHEN
+  150  I F(XIN2.GT.XIN1) GO TO 200
+       TEMP = XIN1
+       XIN1 = XIN2
+       XIN2 = TEMP
+C       
+CCCCCC WENN YIN2 GROESSER IST OK, ANSONSTEN TAUSCHEN
+  200  IF(YIN2.GT.YIN1) GO TO 201
+       TEMP = YIN1
+       YIN1 = YIN2
+       YIN2 = TEMP
+C
+CCCCCC WERTE UEBERNEHMEN
+  201  LOWX  = XIN1
+       HIGHX = XIN2
+       LOWY  = YIN1
+       HIGHY = YIN2
+C
+CCCCCC SCHRITTWEITEN AUSRECHNEN
+       XSTEP = (HIGHX-LOWX)/FLOAT(WIDTH)
+       YSTEP = 2.0 * XSTEP
+C
+       RETURN
+       END       
+C
+C
+CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+CCCCCC EINSTELLUNGEN AUSGEBEN
+       SUBROUTINE OUTCFG
+C
+       INTEGER        MAXI,WIDTH,CR,LF
+       COMMON /PARAM2/MAXI,WIDTH,CR,LF
+       REAL           LOWX,LOWY,HIGHX,HIGHY,MAXVAL,XSTEP,YSTEP
+       COMMON /PARAM1/LOWX,LOWY,HIGHX,HIGHY,MAXVAL,XSTEP,YSTEP
+C
+       WRITE  (1,20)
+  20   FORMAT (9HSETTINGS:)
+       WRITE  (1,30) LOWX, HIGHX
+  30   FORMAT (12HX-WERTE VON ,1F8.5,5H BIS ,1F8.5)
+       WRITE  (1,40) LOWY, HIGHY
+   40  FORMAT (12HY-WERTE VON ,F8.5,5H BIS ,F8.5)     
+       WRITE  (1,50) MAXI, MAXVAL, XSTEP, YSTEP, WIDTH
+   50  FORMAT (   4HMAX:,I3,
+     +        8H MAXVAL:,F8.5,
+     +         7H XSTEP:,F8.5,
+     +         7H YSTEP:,F8.5,
+     +         7H WIDTH:,I2)
+       RETURN
+       END
+C
+C
+CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+CCCCCC RUECKSETZEN
+       SUBROUTINE RST
+C
+       INTEGER        MAXI,WIDTH,CR,LF
+       COMMON /PARAM2/MAXI,WIDTH,CR,LF
+C
+       WRITE(1,245)
+  245  FORMAT(25HPARAMETER RESET REQUESTED)
+       INIT=0
+       RETURN
+       END
+C
+C       
+CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
+C                        PRELOAD VALUE OF INIT
+       BLOCK DATA
+       INTEGER INIT
+       COMMON /PARAM3/INIT
+       DATA INIT/0/ 
+       END
+CCCCCCCCCCCCCCCCCCCCCCCC
+$0
index 38ec9c9d48e24960e18701b7b324b19ef8f4ab10..fb2cf5c641e6f4e50af24cec1dda981324b6a49a 100644 (file)
@@ -253,6 +253,11 @@ found in \cite{ser16:progref:bformats}.
        There shall be a possibility to suppress warning messages.
 }
 
+\rd{err006}{Informational messages}{
+       Any informational messages go to standard error.
+}
+
+
 %*******************************************************************************       
 \newpage
 \subsection{Program configuration}
@@ -323,6 +328,8 @@ found in \cite{ser16:progref:bformats}.
        ignore\_object\_integrity\_errors & g & Ignore errors caused by objects
                                                without proper end block 
                                                (\req{err001}\req{chk004}).\\
+       quiet                             & q & Suppress all non-critical  messages 
+                                                 to standard error (warnings, informatianal)\\
        \hline 
        \end{tabular}\end{center}
        \caption{Configuration switches}
@@ -360,7 +367,8 @@ ConfigurationLine = SwitchLine | StringLine | CommentLine ;
                     | "ignore_block_errors" | "ignore_checksum_errors
                     | "pause_on_checksum_error"
                     | "ignore_unknown_block_errors"
-                    | "ignore_object_integrity" ;
+                    | "ignore_object_integrity"
+                    | "quiet" ;
           StrLong = "out_file" | "in_file" ;
         BoolValue = TrueStr | FalseStr ;
            String = { ? Every character except newline ?} ;
@@ -385,14 +393,15 @@ ShortSwitch = "-" SwShort ;
  ShortParam = "-" StrShort String ;
   LongParam = "--" StrLong "=" String ;
     SwShort = "h" | "a" | "c" | "e" | "u" | "s" | "S"
-              | "b" | "k" | "p" | "n" | "g" ;
+              | "b" | "k" | "p" | "n" | "g" | "q";
      SwLong = "help"
               | "output_info" | "ouput_called" | "output_exported"
               | "output_unsatisfied" | "split_objects" [ _"numbered" ]
               | "ignore_block_errors" | "ignore_checksum_errors"
               | "pause_on_checksum_error"
               | "ignore_unknown_block_errors"
-              | "ignore_object_integrity" ;
+              | "ignore_object_integrity" 
+              | "quiet" ;
    StrShort = "o" ;
     StrLong = "out_file" ;
 \end{verbatim}
@@ -403,7 +412,8 @@ ShortSwitch = "-" SwShort ;
        \item \emph{pause\_on\_checksum\_errors} implies \emph{ignore\_checksum\_errors}.
        \item \emph{pause\_on\_checksum\_errors} is completely ignored when input 
        is read from standard input.
-       \item \emph{output\_*} inhibits tape information output (\req{da001}).
+       \item \emph{output\_*} and \emph{split\_*} inhibit 
+       tape information output (\req{da001}).
        \item \emph{help} inhibits all other actions.
        \end{itemize}
 }
@@ -413,8 +423,6 @@ ShortSwitch = "-" SwShort ;
        \item Data is read from standard input.
        \item All error conditions result in immediate program termination
                and an error message.
-       \item Tape information according to \req{da001} is output.
-       \item Normal Text is output to standard output.
-       \item Error messages are output to standard error.
+       \item Tape information according to \req{da001} is output to standard output.
        \end{itemize}
 }
diff --git a/pc-tools/ldc2/ldc2.conf b/pc-tools/ldc2/ldc2.conf
new file mode 100644 (file)
index 0000000..ad16677
--- /dev/null
@@ -0,0 +1,5 @@
+
+# This tells the program to be a bit more quiet.
+quiet=1
+
+verbose=1
\ No newline at end of file
index 974fc91581d90f70b9036c1f5e74426f0ead1014..1a10ac7722e6b860c4ac223ffe30aeee39da7a31 100644 (file)
@@ -26,8 +26,8 @@ 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_ignore_block_errors=0;
 int cfg_ignore_checksum_errors=0;
 int cfg_pause_on_checksum_error=0;
@@ -35,11 +35,12 @@ 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_version=0;
 
 int in_fd=0;  //! File descriptor for data input 
-int out_fd=1; //! File descriptor for text output
-
+int out_fd=2; //! File descriptor for text output
 
 void do_config(int argc, char ** args){
 
@@ -69,11 +70,11 @@ void do_config(int argc, char ** args){
 
   ar.add_option_switch("S","split_objects_numbered",
                       "Split input data into distinct numbered files",
-                      &cfg_splitobjects_numbered,true,true);
+                      &cfg_split_objects_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("b","ignore_block_errors",
                       "Ignore block integrity errors. This will output broken blocks,too",
@@ -97,9 +98,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 +136,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 +158,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,11 +192,16 @@ 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 (cfg_output_info||cfg_output_called||cfg_output_exported||cfg_output_unsatisfied)
+  if (cfg_output_info||cfg_output_called||cfg_output_exported||
+      cfg_output_unsatisfied||
+      cfg_split_objects||cfg_split_objects_numbered)
     cfg_list_contents=0;
 }
 
index fec7763b0229262066e7377fc832b89af96b8874..09d056e5ce7d7d4c0649b74e00e87ce9511bf97b 100644 (file)
@@ -17,8 +17,8 @@ extern int cfg_output_info;
 extern int cfg_output_called;
 extern int cfg_output_exported;
 extern int cfg_output_unsatisfied;
-extern int cfg_splitobjects;
-extern int cfg_splitobjects_numbered;
+extern int cfg_split_objects;
+extern int cfg_split_objects_numbered;
 extern int cfg_ignore_block_errors;
 extern int cfg_ignore_checksum_errors;
 extern int cfg_pause_on_checksum_error;
@@ -27,6 +27,7 @@ extern int cfg_ignore_object_integrity_errors;
 extern int cfg_list_contents;
 extern int cfg_verbose;
 extern int cfg_version;
+extern int cfg_quiet;
 
 extern int in_fd;  //! File descriptor for data input 
 extern int out_fd; //! File descriptor for text output
index 25abaa3faf99f81585c0b92712443b260cacc273..c83658519691addf8f3b0d5573edc5afbfca0915 100644 (file)
@@ -8,13 +8,17 @@
 
 using namespace std;
 
+/***************************************************************/
 /*!
  *\brief Specialisation constructor.
  */
 data_block::data_block(tape_block& org)
   :tape_block(org)
-{}
+{
+  m_has_known_type=false;
+}
 
+/***************************************************************/
 /*!
  *\brief Determine block type.
  *\return the block type extracted from the block's data.
@@ -23,6 +27,7 @@ int data_block::get_type(){
      return (word_data[0]&0xf000)>>12;
 }
 
+/***************************************************************/
 /*!
  *\brief Get the block's size in 16 bit words.
  *\return The block's 16-bit data buffer's size including
@@ -32,6 +37,7 @@ int data_block::get_word_size(){
   return word_size;
 }
 
+/***************************************************************/
 /*!
  *\brief Describe the block.
  *\return A vector of text lines describing this block.
@@ -44,15 +50,7 @@ vector<string> data_block::get_description(){
   return result;
 }
 
-/*!
- *\brief Determine if the block marks the end of an object
- *\retval true The block marks the end of an object.
- *\retval false The block does not mark the end of an object.
- */
-bool data_block::get_obj_end(){
-  return false;
-}
-
+/***************************************************************/
 /*!
  *\brief Extract 6 byte symbol name from word memory.
  *
@@ -76,3 +74,6 @@ string data_block::extract_label(int firstbyte){
   return result;
 }
 
+
+
+
index 415337bd6100b3497f79115b3eabca007fa3df3d..7a9e1bf907811960778615c58f7ebfa6d32c13f9 100644 (file)
@@ -23,7 +23,7 @@ public:
   int get_type();
   int get_word_size();
   virtual vector<string> get_description();
-  virtual bool get_obj_end();
+
 protected:
   string extract_label(int);
 };
index 84e630fd369fa3deabee28b3e3b52a28da04b096..91a7106955d7cec49e9f8516b8f89e1910a05a2d 100644 (file)
@@ -5,7 +5,10 @@
  */
 data_block_0::data_block_0(data_block & org)
   :data_block(org)
-{}
+{
+  m_has_known_type=false;
+}
+
 
 /*!
  * Determine the block's subtype.
index 86756b2affc0662d3b2782fdb04faf7367177b4c..626a2de8cb6c9a951ca2c08d083a8d5a534b51d0 100644 (file)
@@ -1,5 +1,5 @@
-#ifndef DATA_BLOCK_0_H
-#define DATA_BLOCK_0_H
+#ifndef DATA_BLOCK_0_HH
+#define DATA_BLOCK_0_HH
 
 #include <vector>
 #include <string>
index 5fc41eec639061c39919734ac8ed86ffe7a86e2d..86113d9dcf2fd881024ac9e07762e85514dd6bf9 100644 (file)
@@ -7,7 +7,10 @@
  */
 data_block_0_0::data_block_0_0(data_block_0 & org)
   :data_block_0_label_extractor(org)
-{}
+{
+  m_has_known_type=false;
+}
+
 
 /*!
  *\brief Describe the block.
@@ -26,3 +29,13 @@ vector<string> data_block_0_0::get_description(){
   return result;
 }
 
+/***************************************************************/
+/*!
+ *\brief Get exported symbols.
+ *\return A vector containing the symbol names exported by this
+ *        block.
+ */
+vector<string> data_block_0_0::get_exported_symbols(){
+  return get_labels();
+}
+
index c0f50ed51255d48f7a1eee159ead08df8a2a50f8..847863c26656ccb370ca89b52ff624a704331393 100644 (file)
@@ -16,6 +16,7 @@ class data_block_0_0
                                              void(*)(void*),void*);
 public:
   vector<string> get_description();
+  vector<string> get_exported_symbols();
 
 protected:
   data_block_0_0(data_block_0&);
index 33b3f28a919b83e840fe54a74f6b4fea79c64122..4a5d6397860b5d0304365c5b44717d683016a578 100644 (file)
@@ -7,7 +7,10 @@
  */
 data_block_0_1::data_block_0_1(data_block_0 & org)
   :data_block_0(org)
-{}
+{
+  m_has_known_type=false;
+}
+
 
 /*!
  *\brief Describe the block.
index 690fc12cbe89789bfa8fc4d66556d85022575c72..a75ca9ba12b3ac1b02c74d91947bce873be6a67b 100644 (file)
@@ -7,7 +7,9 @@
  */
 data_block_0_10::data_block_0_10(data_block_0 & org)
   :data_block_0(org)
-{}
+{
+  m_has_known_type=false;
+}
 
 /*!
  *\brief Describe the block.
index 7fbfdd224095435a8a7bce1908c8da2ffa8a122b..36863a8a940b0e3e6a9eeaa07ff2552380d74fda 100644 (file)
@@ -7,7 +7,9 @@
  */
 data_block_0_14::data_block_0_14(data_block_0 & org)
   :data_block_0(org)
-{}
+{
+  m_has_known_type=false;
+}
 
 /*!
  *\brief Describe the block.
@@ -19,3 +21,12 @@ vector<string> data_block_0_14::get_description(){
   return result;
 }
 
+/***************************************************************/
+/*!
+ *\brief Determine if the block marks the end of an object
+ *\return true because this block is an end block.
+ */
+bool data_block_0_14::is_endblock(){
+  return true;
+}
+
index d2de5c81e1ba998d41cd77ec382b6f4740c68c28..de8201abbf304460b1cb734a167bbd27841b227f 100644 (file)
@@ -16,6 +16,7 @@ class data_block_0_14
                                              void(*)(void*),void*);
 public:
   vector<string> get_description();
+  bool is_endblock();
 
 protected:
   data_block_0_14(data_block_0&);
index 9320a77ca204f9a180448f4283fb140b2c3c598f..469b7f97d31ec353c0acd4cf089b714d3d864d9d 100644 (file)
@@ -7,7 +7,10 @@
  */
 data_block_0_2::data_block_0_2(data_block_0 & org)
   :data_block_0(org)
-{}
+{
+  m_has_known_type=false;
+}
+
 
 /*!
  *\brief Describe the block.
index 7f622927ed6f60205eeeeec13fd7871739c15414..6ba7b6dbb639c9685a6489b0900df7b24a840106 100644 (file)
@@ -7,7 +7,9 @@
  */
 data_block_0_24::data_block_0_24(data_block_0 & org)
   :data_block_0(org)
-{}
+{
+  m_has_known_type=false;
+}
 
 /*!
  *\brief Describe the block.
index 0652862761c67ab5d57e1e26732102da2b78fc55..3b8a0749cafab7317abbda57979c1e1650c48e85 100644 (file)
@@ -7,7 +7,10 @@
  */
 data_block_0_3::data_block_0_3(data_block_0 & org)
   :data_block_0(org)
-{}
+{
+  m_has_known_type=false;
+}
+
 
 /*!
  *\brief Describe the block.
index 140ef3742a5318cea752662a85299f61054270df..f9eebb3d4d12cb9fab54115005209df869da5c4b 100644 (file)
@@ -7,7 +7,9 @@
  */
 data_block_0_30::data_block_0_30(data_block_0 & org)
   :data_block_0(org)
-{}
+{
+  m_has_known_type=false;
+}
 
 /*!
  *\brief Describe the block.
index e02e28bada80ec0eecc713902a8b88e33117337a..03fb6f61d6368c1b7ca2d90f44b426f495bf9b83 100644 (file)
@@ -7,7 +7,10 @@
  */
 data_block_0_4::data_block_0_4(data_block_0 & org)
   :data_block_0(org)
-{}
+{
+  m_has_known_type=false;
+}
+
 
 /*!
  *\brief Describe the block.
index b3bce3c83c4933ef92aba0c3a1c25e294a7a417e..c7660d809a452ac2316e5870e6fda85560ffaf5e 100644 (file)
@@ -7,7 +7,9 @@
  */
 data_block_0_44::data_block_0_44(data_block_0 & org)
   :data_block_0_label_extractor(org)
-{}
+{
+  m_has_known_type=false;
+}
 
 /*!
  *\brief Describe the block.
@@ -20,3 +22,15 @@ vector<string> data_block_0_44::get_description(){
                            label+"     "+get_typestring()+"Subprogram Call");
   return result;
 }
+
+/***************************************************************/
+/*!
+ *\brief Get called symbols.
+ *\return A vector containing the symbol names called by this
+ *        block.
+ */
+vector<string> data_block_0_44::get_called_symbols(){
+  vector<string> result;
+  result.insert(result.end(),get_labels()[0]);
+  return result;
+}
index 4384e148a6dd2b29d8420082e27c5de0909f3dc8..e95b6680d28c0c28f5fc9c0289085596ce450272 100644 (file)
@@ -16,6 +16,7 @@ class data_block_0_44
                                              void(*)(void*),void*);
 public:
   vector<string> get_description();
+  vector<string> get_called_symbols();
 
 protected:
   data_block_0_44(data_block_0&);
index 5fdf2150e67ea21c2ebf87915b9fe14ffdc0f90a..63fe321c48d424ff8844e47dc7cfa946164c438c 100644 (file)
@@ -7,7 +7,9 @@
  */
 data_block_0_50::data_block_0_50(data_block_0 & org)
   :data_block_0_label_extractor(org)
-{}
+{
+  m_has_known_type=false;
+}
 
 /*!
  *\brief Describe the block.
index e8bed988327eab0ab27492e0b459b3cab6b80c50..d61632bc8e3323cc42a81de1ad00a0f170c93f52 100644 (file)
@@ -7,7 +7,9 @@
  */
 data_block_0_54::data_block_0_54(data_block_0 & org)
   :data_block_0(org)
-{}
+{
+  m_has_known_type=false;
+}
 
 /*!
  *\brief Describe the block.
index 6bf2b61a470198ecec6924ebaca8db6cd6e88adb..5e19c8b5dd9f1ad8d14bea5fdce85134b1a72098 100644 (file)
@@ -7,7 +7,9 @@
  */
 data_block_0_60::data_block_0_60(data_block_0 & org)
   :data_block_0(org)
-{}
+{
+  m_has_known_type=false;
+}
 
 /*!
  *\brief Describe the block.
index 629b034c647c6a04386200f5181b11fd3b58e7b1..2c47ce618cffeaa823218189abaa3927e73359f7 100644 (file)
@@ -7,7 +7,9 @@
  */
 data_block_0_64::data_block_0_64(data_block_0 & org)
   :data_block_0(org)
-{}
+{
+  m_has_known_type=false;
+}
 
 /*!
  *\brief Describe the block.
index b6b0efa70855d470b98390979fd204c8c22397a1..11c7be1ec49eccb04bd4117688397ade2cf40937 100644 (file)
@@ -5,7 +5,10 @@
  */
 data_block_1::data_block_1(data_block & org)
   :data_block(org)
-{}
+{
+  m_has_known_type=false;
+}
+
 
 /*!
  *\brief Describe the block.
index 8fad9ee1e93d77bc8e0801590c6ecefccbb442cf..971fe23080f0664fb6f13de015a7987b0b853efa 100644 (file)
@@ -4,7 +4,11 @@
  *\brief Specialisation constructor.
  */
 data_block_2::data_block_2(data_block & org)
-  :data_block(org){}
+  :data_block(org)
+{
+  m_has_known_type=false;
+}
+
 
 /*!
  *\brief Describe the block.
index 3ae67a910b7b2370cf2536f28efb9052840ef892..23dded9d118dbdf4c6ddd1a9030875b526f6edcc 100644 (file)
@@ -5,7 +5,10 @@
  */
 data_block_3::data_block_3(data_block & org)
   :data_block(org)
-{}
+{
+  m_has_known_type=false;
+}
+
 
 /*!
  *\brief Describe the block.
@@ -17,6 +20,15 @@ vector<string> data_block_3::get_description(){
   return result;
 }
 
+/***************************************************************/
+/*!
+ *\brief Determine if the block marks the end of an object
+ *\return true because this block is an end block.
+ */
+bool data_block_3::is_endblock(){
+  return true;
+}
+
 
 
 
index 7a5b9026a7a4ff638ac37a271c8a16af752a713c..c6612311b2ec94493025f4e84a6361fcbc824bd5 100644 (file)
@@ -19,6 +19,7 @@ protected:
 
 public:  
   vector<string> get_description();
+  bool is_endblock();
 };
 
 #endif
index b325ed7b0c265634f99840b16ad5315dd538df88..3e11dcd5202fdb4f9b5a6abed6d1440e9420dde1 100644 (file)
@@ -5,7 +5,10 @@
  */
 data_block_4::data_block_4(data_block & org)
   :data_block(org)
-{}
+{
+  m_has_known_type=false;
+}
+
 
 /*!
  *\brief Describe the block.
@@ -17,6 +20,15 @@ vector<string> data_block_4::get_description(){
   return result;
 }
 
+/***************************************************************/
+/*!
+ *\brief Determine if the block marks the end of an object
+ *\return true because this block is an end block.
+ */
+bool data_block_4::is_endblock(){
+  return true;
+}
+
 
 
 
index 702f33d0543aff58e94d21d8d32c356e20f67daa..f73f80581e86703f72a262fc43b12361a539df6e 100644 (file)
@@ -19,6 +19,7 @@ protected:
 
 public:  
   vector<string> get_description();
+  bool is_endblock();
 };
 
 #endif
index 408759ad3f0736dcdb3be99c83a671eaf4cce1be..e52c2082af93b504a786decb4dafa7fef56b83c6 100644 (file)
@@ -5,7 +5,10 @@
  */
 data_block_5::data_block_5(data_block & org)
   :data_block(org)
-{}
+{
+  m_has_known_type=false;
+}
+
 
 /*!
  *\brief Describe the block.
@@ -17,6 +20,18 @@ vector<string> data_block_5::get_description(){
   return result;
 }
 
+/***************************************************************/
+/*!
+ *\brief Get called symbols.
+ *\return A vector containing the symbol names exported by this
+ *        block.
+ */
+vector<string> data_block_5::get_called_symbols(){
+  vector<string> result;
+  result.insert(result.end(),extract_label(3));
+  return result;
+}
+
 
 
 
index 83faa064496f7ba09bf351faefcd72feedb95dfe..5ffe7dd2ce3ea6c2b0996c17aa33b0935f10c152 100644 (file)
@@ -19,6 +19,7 @@ protected:
 
 public:  
   vector<string> get_description();
+  vector<string> get_called_symbols();
 };
 
 #endif
index f4124af56f7cf6b280b67607850561d6e2a270f7..58d303957cb2d3c2d03180ca8d5e426c5f525972 100644 (file)
@@ -5,7 +5,10 @@
  */
 data_block_6::data_block_6(data_block & org)
   :data_block(org)
-{}
+{
+  m_has_known_type=false;
+}
+
 
 /*!
  *\brief Describe the block.
@@ -17,6 +20,16 @@ vector<string> data_block_6::get_description(){
   return result;
 }
 
-
+/***************************************************************/
+/*!
+ *\brief Get exported symbols.
+ *\return A vector containing the symbol names exported by this
+ *        block.
+ */
+vector<string> data_block_6::get_exported_symbols(){
+  vector<string> result;
+  result.insert(result.end(),extract_label(3));
+  return result;
+}
 
 
index 4d5afbe835d319ee5dff37d9a26892467d7eb80e..2af9e16a93f31c5a828ce2b28b1fbe44bc805d2e 100644 (file)
@@ -19,6 +19,7 @@ protected:
 
 public:  
   vector<string> get_description();
+  vector<string> get_exported_symbols();
 };
 
 #endif
index 9481bee3d13bda4794ae7feb88e106464737ccd8..3a9766e0775d6361c4332c7a87aaa9533bdc447b 100644 (file)
@@ -5,7 +5,9 @@
  */
 data_block_7::data_block_7(data_block & org)
   :data_block(org)
-{}
+{
+  m_has_known_type=false;
+}
 
 /*!
  *\brief Describe the block.
@@ -17,6 +19,17 @@ vector<string> data_block_7::get_description(){
   return result;
 }
 
+/***************************************************************/
+/*!
+ *\brief Get called symbols.
+ *\return A vector containing the symbol names exported by this
+ *        block.
+ */
+vector<string> data_block_7::get_called_symbols(){
+  vector<string> result;
+  result.insert(result.end(),extract_label(3));
+  return result;
+}
 
 
 
index 59446f87bcc0cae2a60fc4533ab4e41e04a815db..dea27dda2db35196e71218c692cb8f9464f9279a 100644 (file)
@@ -19,6 +19,8 @@ protected:
 
 public:  
   vector<string> get_description();
+  vector<string> get_called_symbols();
+
 };
 
 #endif
index 4377225b96afa46afa4ac31205007886e3d38898..48bbff8716a65ad2f30fcda4eb6800eb761ad54d 100644 (file)
@@ -12,6 +12,7 @@ using namespace std;
  */
 eot_block::eot_block(eot_block & org){
   operator=(org);
+  m_has_known_type=true;
 }
 
 /***************************************************************/
index 8aa5a6d1851365797017ad03e5d9f2150880a93f..a022af77b0b5a9b9b63041130bfb24107187db9a 100644 (file)
@@ -18,7 +18,6 @@ class eot_block : public tape_block
 public: // methods
   eot_block(eot_block &);
   virtual vector<string> get_description();
-
 private:   // methods
   eot_block(tape_block &);
   eot_block();
index 19246863f3c744ed838c8d14c7adfd2bddcca915..171e331810d0d47ff70a8396089dea9dee8f5645 100644 (file)
@@ -11,7 +11,6 @@
 #define BLOCK_END_DELIMITER_1 0223 // XOFF 0x93
 #define BLOCK_END_DELIMITER_2 0xFF
 
-
 /* End of Tape sequence
  * If EOT_LENGTH is set to 2, EOT_1 becomes insignificant and so on
  */
@@ -20,5 +19,4 @@
 #define EOT_SEQ_2  0x93
 #define EOT_SEQ_3  0xff
 
-
 #endif
index ba8a36c7a28da538f525590f6dc148c182ced7e7..34f2279b29a479e04191030fa77c47e986175156 100644 (file)
@@ -20,69 +20,62 @@ using namespace std;
 #define VERSION "0.0"
 #endif
 
-#define ID_STRING "\n     ldc2 - The X16 object analyser\n\
+#define ID_STRING "\n     ldc2 - The X16 object tape analyser\n\
             (C) 2007 Philipp Hachtmann\n\n\
      Version %s, built %s\n     %s\n\n"
 
+/******************************************************************************/
 
+static FILE * stdwarn; //! Suppressable warning output file pointer.
+static vector<tape_block*> tape; //! Represents the whole tape contents.
+static vector<vector<tape_block*> > objects; //! Tape content in objects.
 
-/*!
- *\brief The main routine.
- */
-int main(int argc, char ** args){
+static int errors=0;
+static int warnings=0;
+static int errcode=0;  //! Variable for error codes.
 
-  
-  // Do all the configuration stuff
-  do_config(argc,args);
-  if (cfg_version){
-    fprintf(stderr, ID_STRING, VERSION, BUILD_DATE, BUILD_STAMP);
-    exit(0);
+
+void exit_on_error(){
+  if (errors){
+    fprintf(stderr,"Failed. (%i)\n",errcode);
+    exit(errcode);
   }
+}
   
-  vector<tape_block*> tape;
-  vector<vector<tape_block *> > objects;
-  vector<tape_block *> current_object;  
+/******************************************************************************/
+/*!
+ *\brief Read in Tape data and do some checks and messages.
+ *
+ * This routine reads in the tape data.
+ * During reading in, checksums are checked and
+ * /da001/ information is generated. No object integrity test.
+ * Tape block object pointers are put into the global vector 
+ * tape.
+ */
+void read_tape(){
+
+  tape_block * block=0;  //! Pointer to current block.
+  bool read_ahead=true;  //! Continue scanning for blocks.
+  int read_pointer=0;    //! Read position in input.
+  int block_start=0;     //! Start of block position in input.
+  int block_end=0;       //! End of block position in input.
+  int blocks_read=0;     //! Number of blocks read in.
   
-  tape_block * block=0;
-  bool read_ahead=true;
-
-  int read_pointer=0;
-  int block_start=0;
-  int block_end=0;
-  int blocks_read=0;
-
-  bool in_object=false;
-
-  int errors=0;
-  int warnings=0;
-  int errcode=0;
-
-  bool spaced=false;
+  bool spaced=false;     //! Help flag for spaced messages. 
+  
+  string message;        //! A warning or help message.
 
+  
   while(read_ahead){
+
+    bool err_checksum=false;
+    bool err_integrity=false;
+    
+    bool warning=false;
+    bool error=false;
+    
     try{
       block=tape_block::gen_from_fd(in_fd);
-      blocks_read++;
-      tape.insert(tape.end(),block);
-      block_start=read_pointer+block->get_discarded_bytes();
-      block_end=block_start+block->get_raw_size()-1;
-      read_pointer=block_end+1;
-      
-      if (cfg_verbose) {
-       char buffer[200];
-       if (!spaced) fprintf(stderr,"\n");
-       spaced=false;
-       
-       snprintf(buffer,200,"Block No.%03i:  Start:0x%04x  End:0x%04x  Size:0x%02x\n",
-                blocks_read-1,
-                block_start,
-                block_end,
-                block->get_raw_size());
-       fprintf(stderr,buffer);
-      }
-      if(cfg_list_contents)
-       dump_vector(block->get_description());
     }
     
     catch(tape_block::eof_legal_exception &e){
@@ -96,180 +89,157 @@ int main(int argc, char ** args){
       } else {
        fprintf(stderr,"Error: Could not read from stdin!\n");
       }
-      errors++;
+      error=true;
       errcode=2;
       break; // Immediately leave read loop.
     }
     
     catch(tape_block::eof_illegal_exception &e){
       block=e.get_block();
-      blocks_read++;
-      tape.insert(tape.end(),block);
-      block_start=read_pointer+block->get_discarded_bytes();
-      block_end=block_start+block->get_raw_size()-1;
-      read_pointer=block_end+1;
-      
-      if (!spaced) fprintf(stderr,"\n");
-      spaced=false;
-      char buffer[200];
-      snprintf(buffer,200,"Block No.%03i:  Start:0x%04x  End:0x%04x  Size:0x%02x\n",
-              blocks_read-1,
-              block_start,
-              block_end,
-              block->get_raw_size());
-      fprintf(stderr,buffer);
-      
+      err_integrity=true;
+      read_ahead=false;
       if (cfg_ignore_block_errors){
-       fprintf(stderr,"Warning: Block integrity check failed!\n");
-       warnings++;
+       message="Warning: Block integrity check failed!\n";
+       warning=true;
       } else {
-       fprintf(stderr,"Error: Block integrity check failed!\n");
-       errors++;
+       message="Error: Block integrity check failed!\n";
+       error=true;
        errcode=3;
-       read_ahead=false;
       }
-      if(cfg_list_contents)
-       dump_vector(block->get_description());
-      fprintf(stderr,"\n");
-      spaced=true;
     }
     
     catch(tape_block::checksum_error_exception &e){
       block=e.get_block();
-      blocks_read++;
-      tape.insert(tape.end(),block);
-      block_start=read_pointer+block->get_discarded_bytes();
-      block_end=block_start+block->get_raw_size()-1;
-      read_pointer=block_end+1;
-      
-      
-      if (!spaced) fprintf(stderr,"\n");
-      spaced=false;
-      char buffer[200];
-      snprintf(buffer,200,"Block No.%03i:  Start:0x%04x  End:0x%04x  Size:0x%02x\n",
-              blocks_read-1,
-              block_start,
-              block_end,
-              block->get_raw_size());
-      fprintf(stderr,buffer);
-      
+      err_checksum=true;
       if (cfg_ignore_checksum_errors){
-       fprintf(stderr,"Warning: Block checksum wrong!\n");
-       warnings++;
+       message="Warning: Block checksum wrong!\n";
+       warning=true;
       } else {
-       fprintf(stderr,"Error: Block checksum wrong!\n");
-       errors++;
+       message="Error: Block checksum wrong!\n";
+       error=true;
        read_ahead=false;
        errcode=4;
       }
-      if(cfg_list_contents)
-       dump_vector(block->get_description());
-      fprintf(stderr,"\n");
-      spaced=true;
     }
     
-        
-  } // while (read_ahead)
-
-  // Now we have our blocks, tell the user about that!
-  if (!spaced) fprintf(stderr,"\n");
-  spaced=false;
-  char buffer[200];
-  sprintf(buffer,"Bytes read:%i Blocks read:%i\nErrors:%i Warnings:%i\n",
-         read_pointer,blocks_read,errors,warnings);
-  if(cfg_output_info){
-    write (out_fd,buffer,strlen(buffer));
-  } else {
-    fprintf(stderr,buffer);
-  }
+    // Now let's check for block type
+    if ((!error)&&(!warning)&&!block->has_known_type()){
+      if (cfg_ignore_unknown_block_errors){
+       message="Warning: Unknown Block type!";
+       warning=true;
+      }else{
+       message="Error: Unknown Block type!";
+       error=true;
+       read_ahead=false;
+       errcode=5;
+      }
+    }
+    
+    // Count block.
+    blocks_read++;
+    tape.insert(tape.end(),block);
+    block_start=read_pointer+block->get_discarded_bytes();
+    block_end=block_start+block->get_raw_size()-1;
+    read_pointer=block_end+1;
+
+    FILE * fp=stdwarn;
+    if (error) fp=stderr;
+         
+    if (cfg_verbose||error||warning){
+      if (!spaced) fprintf(fp,"\n");
+      spaced=false;
+      fprintf(fp,"Block No.%03i:  Start:0x%04x  End:0x%04x  Size:0x%02x\n",
+             blocks_read-1,
+             block_start,
+             block_end,
+             block->get_raw_size());
+    }
+    
+    if (error)   fprintf(stderr,message.c_str());
+    if (warning) fprintf(stdwarn,message.c_str());
+    
+    if(cfg_list_contents){
+      dump_vector(block->get_description());
+      if (!error&&!warning) spaced=false;
+    }
 
-  if (errors>0){
-    fprintf(stderr,"Failed. (%i)\n",errcode);
-    exit(errcode);
-  }
-  
+    if (error||warning||cfg_verbose){
+      fprintf(fp,"\n");
+      spaced=true;
+    }
+    if (error) errors++;
+    if (warning) warnings++;
+  } // while....
   if (cfg_verbose){
-    fprintf(stderr,"Data read successfully.\n");
+    close(in_fd);
+    fprintf(stderr,"Reading finished.\n");
+    fprintf(stderr,"Bytes read:%i, Blocks read:%i\n",read_pointer,blocks_read);
+    }
+} // read_tape()
+
+/******************************************************************************/
+
+void type_check(){
+  bool warning=false;
+  bool error=false;
+
+  for (unsigned int i=0; i<tape.size();i++){
+    bool spaced=false;
+    if (!tape[i]->has_known_type()){
+      FILE * fp;
+      if (cfg_ignore_unknown_block_errors){
+       fp=stdwarn;
+       warning=true;
+      } else {
+       fp=stderr;
+       error=true;
+      }        
+      if (!spaced) {
+       spaced=false;fprintf(fp,"\n");
+       fprintf(fp,"Warning: Unknown Block type! Block No.%i\n",i);
+       dump_vector_fp(tape[i]->get_description(),fp);
+       fprintf(fp,"\n");
+       spaced=true;
+      }
+      if (!cfg_ignore_unknown_block_errors){
+       int errcode=5;
+       fprintf(stdwarn,"Failed. (%i)\n",errcode);
+       exit(errcode);
+      }
+    }
   }
-  close(in_fd);
-//     switch(block->get_state()){ // switchy
-//     case tape_block::TBS_EOF_LEGAL: 
-//       delete block;
-//       if (!in_object){
-//     fprintf(stderr,"File successfully read.\n");
-//       } else {
-//     if (cfg_ignore_object_integrity_errors){
-//       fprintf(stderr,"Warning: Object integrity check failed!\n");
-//       warnings++;
-//     } else {
-//       fprintf(stderr,"Error: Object integrity check failed!\n");
-//       errors++;
-//       errcode=6;
-//     }
-//       }
-//       read_ahead=false;
-//       break;
-//     case tape_block::TBS_EOF_ILLEGAL:
-//       break;
-//     case tape_block::TBS_CHECKSUM:
-//       break;
-//     case tape_block::TBS_DEFAULT:
-//       delete block;
-//       fprintf(stderr,"TBS_DEFAULT encountered ->> SEVERE INTERNAL ERROR!\n");
-//       errors++;
-//       errcode=100;
-//       read_ahead=false;
-//       break;
-//     case tape_block::TBS_IOERR:
-//     case tape_block::TBS_OK:
-//       tape.insert(tape.end(),block);
-//       blocks_read++;
-      
-//       if (cfg_verbose){
-//     char buffer[200];
-//     snprintf(buffer,200,"Block No. %3i: Start(hex):%5x End(hex):%5x Size(hex):%3x\n",
-//              blocks_read-1,
-//              block_start,
-//              block_end,
-//              block->get_raw_size());
-//     write (out_fd,buffer,strlen(buffer));
-//       }
+} // type_check()
 
-//       if(cfg_list_contents)
-//     dump_vector(block->get_description());
-      
-//       if (block->get_type()==0x10){ // Unknown data block!
-//     if (cfg_ignore_unknown_block_errors){
-//       fprintf(stderr,"Warning: Unknown block type!\n");
-//       warnings++;
-//     }else {
-//       fprintf(stderr,"Error: Unknown block type!\n");
-//       errors++;
-//       errcode=5;
-//       read_ahead=false;
-//     }
-//       }
-      
-//       current_object.insert(current_object.end(),block);
-      
-//       if ((block->get_type()==data_block::TBT_EOT)
-//       ||((block->get_type()==0)&&(block->get_subtype()==3))
-//       ||((block->get_type()==4)||(block->get_type()==3))
-//       ||((block->get_type()==0)&&(block->get_subtype()==014))){
-//     in_object=false;
-//     objects.insert(objects.end(),current_object);
-//     current_object.clear();
-//       } else {
-//     in_object=true;
-//       }
-      
-//       break;
-//     } // switch
-//   } // generate loop
+/******************************************************************************/
+/*!
+ *\brief The main routine.
+ */
+int main(int argc, char ** args){
 
 
-//   }
+  // Do all the configuration stuff
+  do_config(argc,args);
+
+  // Output a version message if desired
+  if (cfg_version){
+    fprintf(stderr, ID_STRING, VERSION, BUILD_DATE, BUILD_STAMP);
+    exit(0);
+  }
+  
+  // Assign warning output according to configuration
+  if (cfg_quiet) stdwarn=fopen("/dev/null","w");
+  else stdwarn=stderr;
+  
+  read_tape(); // Process input to completion.
+  exit_on_error();
+  
+  
+  
+  if (cfg_split_objects){
+    for (unsigned int i=0; i<tape.size();i++){
+      tape[i]->dump_to_fd(out_fd);
+    }
+  }
   
  
   return 0;
index 3de7bfb5af1155ff906e1e7ee6c05bcccba6269c..b759a1266473f2d3606153ebf2fad0425c1079f6 100644 (file)
@@ -152,6 +152,77 @@ unsigned char * tape_block::get_raw_data(){
   return raw_data;
 }
 
+/***************************************************************/
+/*!
+ *\brief Dump contents of the block to a file descriptor.
+ *
+ *\param fd A writable file descriptor.
+ *\return Always zero.
+ *\throw io_error_exception A write error occured.
+ */
+int tape_block::dump_to_fd(int fd){
+  int to_write=raw_size;
+  unsigned char * dump_ptr=raw_data;
+  int written;
+  while (to_write) {
+    written=write(fd,dump_ptr,to_write);
+    if (written < 0) throw io_error_exception();
+    to_write-=written;
+    dump_ptr+=written;
+  }
+  return 0;
+}
+
+/***************************************************************/
+/*!
+ *\brief Determine if the block marks the end of an object
+ *\retval true The block marks the end of an object.
+ *\retval false The block does not mark the end of an object.
+ *\note This is only a virtual method returning always false.
+ *      Classes which can be the legal last block of an object
+ *      will overwrite this method so that it returns true.
+ */
+bool tape_block::is_endblock(){
+  return false;
+}
+
+/***************************************************************/
+/*!
+ *\brief Get exported symbols.
+ *\return A vector containing any symbols exported in this block.
+ *\note This is only a virtual method returning always an empty
+ *      vector. Classes describing appropriate data blocks
+ *      will override this method.
+ */
+vector<string> tape_block::get_exported_symbols(){
+  vector<string> result;
+  return result;
+}
+
+/***************************************************************/
+/*!
+ *\brief Get called symbols.
+ *\return A vector containing any symbols called in this block.
+ *\note This is only a virtual method returning always an empty
+ *      vector. Classes describing appropriate data blocks
+ *      will override this method.
+ */
+vector<string> tape_block::get_called_symbols(){
+  vector<string> result;
+  return result;
+}
+
+/***************************************************************/
+/*!
+ *\brief Determine if the block has a known type.
+ *\return true if type and subtype are known.
+ *\return false if the block type is not one of the valid end
+ *        nodes of the type tree.
+ */
+bool tape_block::has_known_type(){
+  return m_has_known_type;
+}
+
 /***************************************************************/
 /*!
  *\brief Static factory method for tape blocks.
@@ -235,6 +306,7 @@ tape_block * tape_block::gen_from_fd(int  fd,
   case tape_block::TBT_EOT:
     n_eot_block=new eot_block(*n_tape_block); 
     delete n_tape_block;
+    n_eot_block->m_has_known_type=true;
     return n_eot_block;
   default: // Unknown block, a bad thing!         
     return n_tape_block; 
@@ -257,6 +329,7 @@ tape_block * tape_block::gen_from_fd(int  fd,
   }
   if (n_data_block_0==0){ // So we must have found another one
     delete n_data_block;
+    n_data_block_x->m_has_known_type=true;
     return n_data_block_x;
   }
   
@@ -266,7 +339,7 @@ tape_block * tape_block::gen_from_fd(int  fd,
   case 001: n_data_block_0_x=new data_block_0_1(*n_data_block_0); break;
   case 002: n_data_block_0_x=new data_block_0_2(*n_data_block_0); break;
   case 003: n_data_block_0_x=new data_block_0_3(*n_data_block_0); break;
-  case 004: n_data_block_0_x=new data_block_0_4(*n_data_block_0); break;
+    // case 004: n_data_block_0_x=new data_block_0_4(*n_data_block_0); break;
   case 010: n_data_block_0_x=new data_block_0_10(*n_data_block_0); break;
   case 014: n_data_block_0_x=new data_block_0_14(*n_data_block_0); break;
   case 024: n_data_block_0_x=new data_block_0_24(*n_data_block_0); break;
@@ -280,6 +353,7 @@ tape_block * tape_block::gen_from_fd(int  fd,
     return n_data_block_0;
   }
   delete n_data_block_0;
+  n_data_block_0_x->m_has_known_type=true;
   return n_data_block_0_x;
 }
 
@@ -390,11 +464,14 @@ tape_block::tape_block (int  fd,
       break;
     }
   } while (buffer != (unsigned char) BLOCK_START_DELIMITER);
-  discarded_bytes--; // Dont want to declare the start delimiter discarded!
+  discarded_bytes--; // Don't want to declare the start delimiter discarded!
   raw_size=1;        // But we want to account it here!
-
+  
   /* Now input the block data */
   block_complete = 0;
+
+  raw_data[0]=buffer; // Put the start delimiter in!
+
   do {
     retval = read (fd, &buffer, 1);
 
@@ -411,12 +488,12 @@ tape_block::tape_block (int  fd,
     /* sort in the new byte */
     raw_size++;
     // Need more memory??
-    if (raw_size==poolsize){
+    if (raw_size>poolsize){
       poolsize+=1024;
       raw_data=(unsigned char*)realloc(raw_data,poolsize);
     }
 
-    raw_data[raw_size-2]=buffer;
+    raw_data[raw_size-1]=buffer;
 
     /* Look for end ot block sequence */
     switch(eob_needed){
@@ -462,11 +539,11 @@ tape_block::tape_block (int  fd,
  *\retval 1 on error.
  */
 int tape_block::init_words(){
-  word_size=(raw_size-EOB_LENGTH)/3;
+  word_size=(raw_size-EOB_LENGTH-1)/3;
   if (word_size<MINIMUM_DATA_BLOCK_WORDSIZE) return 1; // Block too short!
   word_data=(unsigned short *)malloc(word_size*sizeof(unsigned short));
   for (int pos=0; pos<word_size; pos++)
-    word_data[pos]=combine466(raw_data+3*pos);
+    word_data[pos]=combine466(raw_data+1+3*pos);
   return 0;
 }
 
index 3022a6a46d64210ec42df912de98e10ef730a5f9..2d42100445bc9ef86705e58d9ece04df2bcacff4 100644 (file)
@@ -89,7 +89,12 @@ public: // methods
   int get_raw_size();
   int get_discarded_bytes();
   unsigned char * get_raw_data();
-  
+  virtual int dump_to_fd(int fd);
+  virtual bool is_endblock();
+  virtual vector<string> get_exported_symbols();
+  virtual vector<string> get_called_symbols();
+  virtual bool has_known_type();
+
   static tape_block * gen_from_fd(int  fd,
                                  void(*input_start)(void *)=0,
                                  void (*input_stop)(void *)=0,
@@ -112,6 +117,7 @@ private:   // methods
   
 protected: // members
   int block_type;             //!< Type of this block.
+  bool m_has_known_type;      //!< Block is of a documented type.
   int discarded_bytes;        //!< Amount of bytes discarded before beginning.
   unsigned char * raw_data;   //!< Raw block data in bytes.
   int raw_size;               //!< Size of the raw data.
index acebb5efc57573635a0d91f1a96885f36cfc16e8..cc04868ac8e7b663ac9f6308e0c7f54a143c5ae5 100644 (file)
@@ -25,18 +25,36 @@ int dump_vector(vector<string> strings){
 }
 
 /*!
- *\brief Output a vector of strings to stderr.
+ *\brief Output a vector of strings.
  *\arg strings A vector containing text.
+ *\arg fp A FILE pointer where to write to.
  *\retval 0 The vector was empty.
  *\retval 1 The vector contained text.
  */
-int dump_vector_err(vector<string> strings){
+int dump_vector_fp(vector<string> strings, FILE * fp){
   int res=0;
   for (vector<string>::iterator iter=strings.begin();iter<strings.end();iter++){
-    char buffer[50000];
-    snprintf(buffer,50000,"%s\n",(*iter).c_str());
-    write (2,buffer,strlen(buffer));
+    fprintf(fp,"%s\n",(*iter).c_str());
     res=1;
   }
   return res;
 }
+
+/*!
+ *\brief add contents of one vector to another vector uniquely.
+ *\param target Reference to the target vector.
+ *\param source Reference to the vector whose contents are to be added
+ *       to target.
+ */
+template<typename T>
+void merge_vector_unique(vector<T> &target, const vector<T> & source){
+  for (unsigned int isource=0; isource<source.size();isource++){
+    bool already_present=false;
+    for (int itarget=0;itarget<target.size();itarget++)
+      if (target[itarget]==source[isource]){
+       already_present=true;
+       break;
+      }
+    if (!already_present) target.insert(target.end().source[isource]);
+  }
+}
index acb30ec35eb585840b350dfb7a0513387a88cc31..cfc31bb057875094089a6844f5aec18eeeb42874 100644 (file)
@@ -7,6 +7,10 @@
 using namespace std;
 
 extern int dump_vector(vector<string> strings);
-extern int dump_vector_err(vector<string> strings);
+extern int dump_vector_fp(vector<string> strings, FILE * fp);
+
+template<typename T>
+extern void merge_vector_unique(vector<T> &target, const vector<T> & source);
+
 
 #endif