Explorar el Código

[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 hace 12 años
padre
commit
c2875ae329

+ 8
- 0
src/arch/i386/interface/vmware/vmconsole.c Ver fichero

@@ -51,10 +51,18 @@ static struct {
51 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 59
 /** VMware logfile line console */
55 60
 static struct line_console vmconsole_line = {
56 61
 	.buffer = vmconsole_buffer.message,
57 62
 	.len = sizeof ( vmconsole_buffer.message ),
63
+	.ctx = {
64
+		.handlers = vmconsole_handlers,
65
+	},
58 66
 };
59 67
 
60 68
 /** VMware logfile console recursion marker */

+ 1
- 11
src/core/lineconsole.c Ver fichero

@@ -29,16 +29,6 @@ FILE_LICENCE ( GPL2_OR_LATER );
29 29
 #include <ipxe/ansiesc.h>
30 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 33
  * Print a character to a line-based console
44 34
  *
@@ -48,7 +38,7 @@ static struct ansiesc_context line_ansiesc_ctx = {
48 38
 size_t line_putchar ( struct line_console *line, int character ) {
49 39
 
50 40
 	/* Strip ANSI escape sequences */
51
-	character = ansiesc_process ( &line_ansiesc_ctx, character );
41
+	character = ansiesc_process ( &line->ctx, character );
52 42
 	if ( character < 0 )
53 43
 		return 0;
54 44
 

+ 3
- 0
src/include/ipxe/lineconsole.h Ver fichero

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

+ 8
- 0
src/net/udp/syslog.c Ver fichero

@@ -68,10 +68,18 @@ static struct interface syslogger = INTF_INIT ( syslogger_desc );
68 68
 /** Syslog line buffer */
69 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 76
 /** Syslog line console */
72 77
 static struct line_console syslog_line = {
73 78
 	.buffer = syslog_buffer,
74 79
 	.len = sizeof ( syslog_buffer ),
80
+	.ctx = {
81
+		.handlers = syslog_handlers,
82
+	},
75 83
 };
76 84
 
77 85
 /** Syslog recursion marker */

Loading…
Cancelar
Guardar