From 43997df6f19a09a2252f64a402671a0f593c0ac2 Mon Sep 17 00:00:00 2001 From: deuce <> Date: Sat, 6 Aug 2005 01:32:15 +0000 Subject: [PATCH] Add support for logging to cterm object (ASCII or ANSI) PR:25 --- src/conio/cterm.c | 6 ++++++ src/conio/cterm.h | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/conio/cterm.c b/src/conio/cterm.c index f8a8db4531..c463386094 100644 --- a/src/conio/cterm.c +++ b/src/conio/cterm.c @@ -870,6 +870,8 @@ void cterm_init(int height, int width, int xpos, int ypos, int backlines, unsign cterm.backpos=0; cterm.backlines=backlines; cterm.scrollback=scrollback; + cterm.log=LOG_NONE; + cterm.logfile=NULL; if(cterm.scrollback!=NULL) memset(cterm.scrollback,0,cterm.width*2*cterm.backlines); textattr(cterm.attr); @@ -893,6 +895,8 @@ void ctputs(char *buf) _wscroll=0; cx=wherex(); cy=wherey(); + if(cterm.log==LOG_ASCII) + fputs(buf, cterm.logfile); for(p=buf;*p;p++) { switch(*p) { case '\r': @@ -987,6 +991,8 @@ char *cterm_write(unsigned char *buf, int buflen, char *retbuf, int retsize, int case 0: break; default: + if(cterm.log==LOG_RAW) + fwrite(buf, buflen, 1, cterm.logfile); prn[0]=0; for(j=0;j<buflen;j++) { ch[0]=buf[j]; diff --git a/src/conio/cterm.h b/src/conio/cterm.h index 4149077c4d..61cf760ec6 100644 --- a/src/conio/cterm.h +++ b/src/conio/cterm.h @@ -34,12 +34,20 @@ #ifndef _CTERM_H_ #define _CTERM_H_ +#include <stdio.h> /* FILE* */ + enum { CTERM_MUSIC_NORMAL ,CTERM_MUSIC_LEGATO ,CTERM_MUSIC_STACATTO }; +enum { + LOG_NONE + ,LOG_ASCII + ,LOG_RAW +}; + struct cterminal { int height; int width; @@ -63,6 +71,8 @@ struct cterminal { int backlines; int xpos; int ypos; + int log; + FILE* logfile; }; #ifdef __cplusplus -- GitLab