DEADSOFTWARE

"--log" cli arg; fixed bug with console output (endless loop)
[d2df-sdl.git] / src / shared / conbuf.pas
index 751f39ad06596afbfec3df125271b2c30ca19f8f..1be01b2f80df2eb36fffd90ec3d380828a97ea5d 100644 (file)
@@ -1,3 +1,18 @@
+(* Copyright (C)  DooM 2D:Forever Developers
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ *)
 {$MODE OBJFPC}
 unit conbuf;
 
@@ -23,6 +38,9 @@ function cbufLineUp (var sp: LongWord; var ep: LongWord): Boolean;
 
 procedure cbufClear ();
 
+var
+  conbufDumpToStdOut: Boolean = false;
+
 
 implementation
 
@@ -45,6 +63,9 @@ function cbufLastChange (): LongWord; begin result := changeCount; end;
 
 
 // ////////////////////////////////////////////////////////////////////////// //
+var
+  needCon: Boolean = true;
+
 procedure cbufPutChars (buf: PChar; count: Integer);
 var
   np: LongWord;
@@ -52,6 +73,15 @@ var
 begin
   if count > 0 then
   begin
+    if conbufDumpToStdOut then
+    begin
+      for np := 0 to count-1 do
+      begin
+        if needCon then begin write(stdout, 'CON: '); needCon := false; end;
+        write(stdout, buf[np]);
+        needCon := (buf[np] = #10);
+      end;
+    end;
     Inc(changeCount);
     if changeCount = 0 then changeCount := 1;
     while count > 0 do