From 40f09ce3a4e83bb0944e2352e9c0019892d0b164 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Sat, 24 Aug 2013 16:32:20 -0400 Subject: [PATCH] Second stage or varargs fixups. Messages to all three info lines tested. --- extern.h | 4 ++-- term.c | 35 +++++++++++++++++++++-------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/extern.h b/extern.h index 81cea50..92e1611 100644 --- a/extern.h +++ b/extern.h @@ -226,8 +226,8 @@ void extra (char *buf, int a, int b, int c, int d, int e, int f, int g, int h); void huh (void); void help (char **text, int nlines); void set_need_delay (void); -void ksend (char *buf, int a, int b, int c, int d, int e, int f, int g, int h); -void ksend1 (char *buf, char *a, int b, int c, int d, int e, int f, int g, int h); +void ksend (char *buf, ...); +void ksend1 (char *buf, ...); /* utility routines */ void ttinit (void); diff --git a/term.c b/term.c index 654c5a7..b4b3004 100644 --- a/term.c +++ b/term.c @@ -210,34 +210,41 @@ comment1(char *buf, char *a, } /* kermyt begin */ + void -ksend(char *buf, - int a, int b, int c, int d, int e, int f, int g, int h) +vksend(const char *fmt, va_list varglist) { if(!(my_stream=fopen("info_list.txt","a"))) { - error("Cannot open info_list.txt",0,0,0,0,0,0,0,0); + error("Cannot open info_list.txt",0,0,0,0,0,0,0,0); return; } - fprintf(my_stream, buf, a, b, c, d, e, f, g, h); + vfprintf(my_stream, fmt, varglist); fclose(my_stream); return; } void -ksend1(char *buf, char *a, - int b, int c, int d, int e, int f, int g, int h) +ksend(char *fmt, ...) { - if(!(my_stream=fopen("info_list.txt","a"))) - { - error("Cannot open info_list.txt",0,0,0,0,0,0,0,0); - return; - } - fprintf(my_stream, buf, a, b, c, d, e, f, g, h); - fclose(my_stream); - return; + va_list ap; + + va_start(ap, fmt); + vksend(fmt, ap); + va_end(ap); +} + +void +ksend1(char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vksend(fmt, ap); + va_end(ap); } /* kermyt end */ + /* Get a string from the user, echoing characters all the while. */ -- 2.43.0