]> git.sur5r.net Git - cc65/blobdiff - src/cc65/output.c
Merge remote-tracking branch 'upstream/master' into a5200
[cc65] / src / cc65 / output.c
index 1c40e04a2471c71577c4d63768a6140912390b2f..fdde36467b3844ec790fce996cb33b74db68a1c6 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2009,     Ullrich von Bassewitz                                       */
-/*               Roemerstrasse 52                                            */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 2009-2012, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -52,7 +52,7 @@
 
 
 /*****************************************************************************/
-/*                                          Data                                    */
+/*                                   Data                                    */
 /*****************************************************************************/
 
 
@@ -66,7 +66,7 @@ FILE* OutputFile = 0;
 
 
 /*****************************************************************************/
-/*                                          Code                                    */
+/*                                   Code                                    */
 /*****************************************************************************/
 
 
@@ -109,6 +109,24 @@ void OpenOutputFile ()
 
 
 
+void OpenDebugOutputFile (const char* Name)
+/* Open an output file for debugging purposes. Will call Fatal() in case of
+ * failures.
+ */
+{
+    /* Output file must not be open and we must have a name*/
+    PRECONDITION (OutputFile == 0);
+
+    /* Open the file */
+    OutputFile = fopen (Name, "w");
+    if (OutputFile == 0) {
+        Fatal ("Cannot open debug output file `%s': %s", Name, strerror (errno));
+    }
+    Print (stdout, 1, "Opened debug output file `%s'\n", Name);
+}
+
+
+
 void CloseOutputFile ()
 /* Close the output file. Will call Fatal() in case of failures. */
 {
@@ -121,6 +139,8 @@ void CloseOutputFile ()
         Fatal ("Cannot write to output file (disk full?)");
     }
     Print (stdout, 1, "Closed output file `%s'\n", OutputFilename);
+
+    OutputFile = 0;
 }
 
 
@@ -144,6 +164,3 @@ int WriteOutput (const char* Format, ...)
     /* Return the number of chars written */
     return CharCount;
 }
-
-
-