From 8bdfa78a69bf543f55cc05940fa698262fcd1010 Mon Sep 17 00:00:00 2001 From: Pierre Humblet Date: Wed, 12 May 2004 01:44:11 +0000 Subject: 2004-05-12 Pierre Humblet * tty.h: Remove the %d or %x from all cygtty strings. (tty::open_output_mutex): Only declare. (tty::open_input_mutex): Ditto. (tty::open_mutex): New definition. * fhandlet_tty.cc (fhandler_tty_slave::open): Declare buf with size CYG_MAX_PATH and replace __small_printf calls by shared_name. * tty.cc (tty::create_inuse): Ditto. (tty::get_event): Ditto. (tty::common_init): Ditto. (tty::open_output_mutex): New method definition. (tty::open_input_mutex): Ditto. (tty::open_mutex): New method. --- winsup/cygwin/tty.cc | 38 +++++++++++++++++++++++++++++--------- 1 file changed, 29 insertions(+), 9 deletions(-) (limited to 'winsup/cygwin/tty.cc') diff --git a/winsup/cygwin/tty.cc b/winsup/cygwin/tty.cc index 7e3aeb9c4..000de2e6e 100644 --- a/winsup/cygwin/tty.cc +++ b/winsup/cygwin/tty.cc @@ -310,21 +310,41 @@ bool tty::alive (const char *fmt) { HANDLE ev; - char buf[sizeof (TTY_MASTER_ALIVE) + 16]; + char buf[CYG_MAX_PATH]; - __small_sprintf (buf, fmt, ntty); + shared_name (buf, fmt, ntty); if ((ev = OpenEvent (EVENT_ALL_ACCESS, FALSE, buf))) CloseHandle (ev); return ev != NULL; } +HANDLE +tty::open_output_mutex () +{ + return open_mutex (OUTPUT_MUTEX); +} + +HANDLE +tty::open_input_mutex () +{ + return open_mutex (INPUT_MUTEX); +} + +HANDLE +tty::open_mutex (const char *mutex) +{ + char buf[CYG_MAX_PATH]; + shared_name (buf, mutex, ntty); + return OpenMutex (MUTEX_ALL_ACCESS, TRUE, buf); +} + HANDLE tty::create_inuse (const char *fmt) { HANDLE h; - char buf[sizeof (TTY_MASTER_ALIVE) + 16]; + char buf[CYG_MAX_PATH]; - __small_sprintf (buf, fmt, ntty); + shared_name (buf, fmt, ntty); h = CreateEvent (&sec_all, TRUE, FALSE, buf); termios_printf ("%s = %p", buf, h); if (!h) @@ -348,9 +368,9 @@ HANDLE tty::get_event (const char *fmt, BOOL manual_reset) { HANDLE hev; - char buf[40]; + char buf[CYG_MAX_PATH]; - __small_sprintf (buf, fmt, ntty); + shared_name (buf, fmt, ntty); if (!(hev = CreateEvent (&sec_all, manual_reset, FALSE, buf))) { termios_printf ("couldn't create %s", buf); @@ -440,8 +460,8 @@ tty::common_init (fhandler_pty_master *ptym) if (!(ptym->input_available_event = get_event (INPUT_AVAILABLE_EVENT, TRUE))) return false; - char buf[40]; - __small_sprintf (buf, OUTPUT_MUTEX, ntty); + char buf[CYG_MAX_PATH]; + shared_name (buf, OUTPUT_MUTEX, ntty); if (!(ptym->output_mutex = CreateMutex (&sec_all, FALSE, buf))) { termios_printf ("can't create %s", buf); @@ -449,7 +469,7 @@ tty::common_init (fhandler_pty_master *ptym) return false; } - __small_sprintf (buf, INPUT_MUTEX, ntty); + shared_name (buf, INPUT_MUTEX, ntty); if (!(ptym->input_mutex = CreateMutex (&sec_all, FALSE, buf))) { termios_printf ("can't create %s", buf); -- cgit v1.2.3