Browse Source

[console] Do not share ANSI escape context between lineconsole users

An ANSI escape sequence context cannot be shared between multiple
users.  Make the ANSI escape sequence context part of the line console
definition and provide individual contexts for each user.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 years ago
parent
commit
c2875ae329

+ 8
- 0
src/arch/i386/interface/vmware/vmconsole.c View File

51
 	.prefix = "log ",
51
 	.prefix = "log ",
52
 };
52
 };
53
 
53
 
54
+/** VMware logfile console ANSI escape sequence handlers */
55
+static struct ansiesc_handler vmconsole_handlers[] = {
56
+	{ 0, NULL }
57
+};
58
+
54
 /** VMware logfile line console */
59
 /** VMware logfile line console */
55
 static struct line_console vmconsole_line = {
60
 static struct line_console vmconsole_line = {
56
 	.buffer = vmconsole_buffer.message,
61
 	.buffer = vmconsole_buffer.message,
57
 	.len = sizeof ( vmconsole_buffer.message ),
62
 	.len = sizeof ( vmconsole_buffer.message ),
63
+	.ctx = {
64
+		.handlers = vmconsole_handlers,
65
+	},
58
 };
66
 };
59
 
67
 
60
 /** VMware logfile console recursion marker */
68
 /** VMware logfile console recursion marker */

+ 1
- 11
src/core/lineconsole.c View File

29
 #include <ipxe/ansiesc.h>
29
 #include <ipxe/ansiesc.h>
30
 #include <ipxe/lineconsole.h>
30
 #include <ipxe/lineconsole.h>
31
 
31
 
32
-/** Line-based console ANSI escape sequence handlers */
33
-static struct ansiesc_handler line_ansiesc_handlers[] = {
34
-	{ 0, NULL }
35
-};
36
-
37
-/** Line-based console ANSI escape sequence context */
38
-static struct ansiesc_context line_ansiesc_ctx = {
39
-	.handlers = line_ansiesc_handlers,
40
-};
41
-
42
 /**
32
 /**
43
  * Print a character to a line-based console
33
  * Print a character to a line-based console
44
  *
34
  *
48
 size_t line_putchar ( struct line_console *line, int character ) {
38
 size_t line_putchar ( struct line_console *line, int character ) {
49
 
39
 
50
 	/* Strip ANSI escape sequences */
40
 	/* Strip ANSI escape sequences */
51
-	character = ansiesc_process ( &line_ansiesc_ctx, character );
41
+	character = ansiesc_process ( &line->ctx, character );
52
 	if ( character < 0 )
42
 	if ( character < 0 )
53
 		return 0;
43
 		return 0;
54
 
44
 

+ 3
- 0
src/include/ipxe/lineconsole.h View File

10
 FILE_LICENCE ( GPL2_OR_LATER );
10
 FILE_LICENCE ( GPL2_OR_LATER );
11
 
11
 
12
 #include <stdint.h>
12
 #include <stdint.h>
13
+#include <ipxe/ansiesc.h>
13
 
14
 
14
 /** A line-based console */
15
 /** A line-based console */
15
 struct line_console {
16
 struct line_console {
26
 	 * a potential terminating NUL.
27
 	 * a potential terminating NUL.
27
 	 */
28
 	 */
28
 	size_t len;
29
 	size_t len;
30
+	/** ANSI escape sequence context */
31
+	struct ansiesc_context ctx;
29
 };
32
 };
30
 
33
 
31
 extern size_t line_putchar ( struct line_console *line, int character );
34
 extern size_t line_putchar ( struct line_console *line, int character );

+ 8
- 0
src/net/udp/syslog.c View File

68
 /** Syslog line buffer */
68
 /** Syslog line buffer */
69
 static char syslog_buffer[SYSLOG_BUFSIZE];
69
 static char syslog_buffer[SYSLOG_BUFSIZE];
70
 
70
 
71
+/** Syslog ANSI escape sequence handlers */
72
+static struct ansiesc_handler syslog_handlers[] = {
73
+	{ 0, NULL }
74
+};
75
+
71
 /** Syslog line console */
76
 /** Syslog line console */
72
 static struct line_console syslog_line = {
77
 static struct line_console syslog_line = {
73
 	.buffer = syslog_buffer,
78
 	.buffer = syslog_buffer,
74
 	.len = sizeof ( syslog_buffer ),
79
 	.len = sizeof ( syslog_buffer ),
80
+	.ctx = {
81
+		.handlers = syslog_handlers,
82
+	},
75
 };
83
 };
76
 
84
 
77
 /** Syslog recursion marker */
85
 /** Syslog recursion marker */

Loading…
Cancel
Save