]> code.citadel.org Git - citadel.git/commitdiff
All screen output now goes through scr_putc().
authorArt Cancro <ajc@citadel.org>
Thu, 2 Sep 2010 15:42:24 +0000 (11:42 -0400)
committerArt Cancro <ajc@citadel.org>
Thu, 2 Sep 2010 15:42:24 +0000 (11:42 -0400)
This is deliberate.  Please do not optimize this out because I will be writing code that depends on
it.

citadel/textclient/screen.c

index 6b4243d8dc155298d1504b281bf976f3a2a8391e..d20a0d170d5b758cdff054fefcbc6a1603f97cd0 100644 (file)
@@ -86,11 +86,19 @@ int screen_reset(void)
  */
 int scr_printf(char *fmt, ...)
 {
+       static char outbuf[4096];       /* static for performance -- not re-entrant -- change if needed */
        va_list ap;
        register int retval;
+       int i, len;
+
        va_start(ap, fmt);
-       retval = vprintf(fmt, ap);
+       retval = vsnprintf(outbuf, sizeof outbuf, fmt, ap);
        va_end(ap);
+
+       len = strlen(outbuf);
+       for (i=0; i<len; ++i) {
+               scr_putc(outbuf[i]);
+       }
        return retval;
 }
 
@@ -101,6 +109,9 @@ int scr_printf(char *fmt, ...)
 int scr_getc(int delay)
 {
        unsigned char buf;
+
+       scr_flush();
+
        buf = '\0';
        if (!read (0, &buf, 1))
                logoff(NULL, 3);
@@ -112,8 +123,9 @@ int scr_getc(int delay)
  */
 int scr_putc(int c)
 {
-       if (putc(c, stdout) == EOF)
+       if (putc(c, stdout) == EOF) {
                logoff(NULL, 3);
+       }
        return c;
 }