1 /*
2 This file is part of SLRN.
3
4 Copyright (c) 1994, 1999, 2007-2016 John E. Davis <jed@jedsoft.org>
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the Free
8 Software Foundation; either version 2 of the License, or (at your option)
9 any later version.
10
11 This program is distributed in the hope that it will be useful, but WITHOUT
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 more details.
15
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19 */
20 #include "config.h"
21 #include "slrnfeat.h"
22
23 #include <stdio.h>
24 #include <string.h>
25 #include <slang.h>
26
27 #include "jdmacros.h"
28
29 #include "ttymsg.h"
30 #include "common.h"
31
slrn_tty_vmessage(FILE * fp,char * fmt,va_list ap)32 void slrn_tty_vmessage (FILE *fp, char *fmt, va_list ap)
33 {
34 static FILE *last_fp;
35 char *b, buf[1024];
36
37 if ((fp == stdout) || (last_fp == stdout)) fputc ('\n', fp);
38
39 /* Use SLvsnprintf to write to a buffer so that any \001 highlight
40 * indicators can be stripped.
41 */
42 /* (void) vfprintf(fp, fmt, ap); */
43 (void) SLvsnprintf (buf, sizeof(buf), fmt, ap);
44 b = buf;
45 while (*b != 0)
46 {
47 if (*b != '\001')
48 (void) fputc (*b, fp);
49 b++;
50 }
51
52 if (fp == stderr) (void) fputc ('\n', fp);
53 fflush (fp);
54
55 last_fp = fp;
56 }
57
slrn_tty_message(char * fmt,...)58 void slrn_tty_message (char *fmt, ...)
59 {
60 va_list ap;
61
62 va_start (ap, fmt);
63 slrn_tty_vmessage (stdout, fmt, ap);
64 va_end (ap);
65 }
66
slrn_tty_error(char * fmt,...)67 void slrn_tty_error (char *fmt, ...)
68 {
69 va_list ap;
70
71 va_start (ap, fmt);
72 slrn_tty_vmessage (stderr, fmt, ap);
73 va_end (ap);
74 }
75
76