17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57c478bd9Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
67c478bd9Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
77c478bd9Sstevel@tonic-gate  * with the License.
87c478bd9Sstevel@tonic-gate  *
97c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
107c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
117c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
127c478bd9Sstevel@tonic-gate  * and limitations under the License.
137c478bd9Sstevel@tonic-gate  *
147c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
157c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
167c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
177c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
187c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
197c478bd9Sstevel@tonic-gate  *
207c478bd9Sstevel@tonic-gate  * CDDL HEADER END
217c478bd9Sstevel@tonic-gate  */
227c478bd9Sstevel@tonic-gate /*
237c478bd9Sstevel@tonic-gate  * Copyright (c) 1995, by Sun Microsystems, Inc.
247c478bd9Sstevel@tonic-gate  * All rights reserved.
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
277c478bd9Sstevel@tonic-gate /*
28*1da57d55SToomas Soome  * wgetn_ws.c
297c478bd9Sstevel@tonic-gate  *
307c478bd9Sstevel@tonic-gate  * XCurses Library
317c478bd9Sstevel@tonic-gate  *
327c478bd9Sstevel@tonic-gate  * Copyright 1990, 1995 by Mortice Kern Systems Inc.  All rights reserved.
337c478bd9Sstevel@tonic-gate  *
347c478bd9Sstevel@tonic-gate  */
357c478bd9Sstevel@tonic-gate 
367c478bd9Sstevel@tonic-gate #ifdef M_RCSID
377c478bd9Sstevel@tonic-gate #ifndef lint
387c478bd9Sstevel@tonic-gate static char rcsID[] = "$Header: /rd/src/libc/xcurses/rcs/wgetn_ws.c 1.3 1995/10/02 15:07:23 ant Exp $";
397c478bd9Sstevel@tonic-gate #endif
407c478bd9Sstevel@tonic-gate #endif
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #include <private.h>
437c478bd9Sstevel@tonic-gate #include <limits.h>
447c478bd9Sstevel@tonic-gate #include <stdlib.h>
457c478bd9Sstevel@tonic-gate #include <m_wio.h>
467c478bd9Sstevel@tonic-gate 
477c478bd9Sstevel@tonic-gate static wint_t fld_key;
487c478bd9Sstevel@tonic-gate static int fld_echo;		/* Software echo flag. */
497c478bd9Sstevel@tonic-gate static int fld_index;		/* Number of characters in fld_buffer. */
507c478bd9Sstevel@tonic-gate static int fld_bytes;		/* fld_index expressed in bytes. */
517c478bd9Sstevel@tonic-gate static int fld_mb;		/* Field is a multibyte character string. */
527c478bd9Sstevel@tonic-gate static wint_t *fld_buffer;	/* Wide character buffer. */
537c478bd9Sstevel@tonic-gate static int fld_maxlength;	/* Character length of buffer. */
547c478bd9Sstevel@tonic-gate static WINDOW *fld_window;
557c478bd9Sstevel@tonic-gate static int fld_row, fld_col;	/* Start of field in fld_window. */
567c478bd9Sstevel@tonic-gate 
577c478bd9Sstevel@tonic-gate STATIC int fld_done(void);
587c478bd9Sstevel@tonic-gate STATIC int fld_erase(void);
597c478bd9Sstevel@tonic-gate STATIC int fld_kill(void);
607c478bd9Sstevel@tonic-gate STATIC int fld_insert(void);
617c478bd9Sstevel@tonic-gate 
627c478bd9Sstevel@tonic-gate typedef struct t_key_entry {
637c478bd9Sstevel@tonic-gate 	int type;
647c478bd9Sstevel@tonic-gate 	wint_t code;
657c478bd9Sstevel@tonic-gate 	int (*func)(void);
667c478bd9Sstevel@tonic-gate } t_key_entry;
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate #define ERASE_KEY	0
697c478bd9Sstevel@tonic-gate #define KILL_KEY	1
707c478bd9Sstevel@tonic-gate #define EOF_KEY		2
717c478bd9Sstevel@tonic-gate #define EOL_KEY		3
727c478bd9Sstevel@tonic-gate 
737c478bd9Sstevel@tonic-gate static t_key_entry key_table[] = {
747c478bd9Sstevel@tonic-gate 	{ OK, 0, fld_erase },
757c478bd9Sstevel@tonic-gate 	{ OK, 0, fld_kill },
767c478bd9Sstevel@tonic-gate 	{ OK, 0, fld_done },
777c478bd9Sstevel@tonic-gate 	{ OK, 0, fld_done },
787c478bd9Sstevel@tonic-gate 	{ OK, '\n', fld_done },
797c478bd9Sstevel@tonic-gate 	{ OK, WEOF, fld_done },
807c478bd9Sstevel@tonic-gate 	{ KEY_CODE_YES, KEY_LEFT, fld_erase },
817c478bd9Sstevel@tonic-gate 	{ KEY_CODE_YES, KEY_BACKSPACE, fld_erase },
827c478bd9Sstevel@tonic-gate 	{ ERR, 0, fld_insert }
837c478bd9Sstevel@tonic-gate };
847c478bd9Sstevel@tonic-gate 
857c478bd9Sstevel@tonic-gate /*f
867c478bd9Sstevel@tonic-gate  * The effect of wgetnstr() is as though a series of calls to wgetch()
877c478bd9Sstevel@tonic-gate  * were made, until a <newline> or <return> are received.  The
887c478bd9Sstevel@tonic-gate  * resulting value is placed in the area pointed to by the character
897c478bd9Sstevel@tonic-gate  * pointer 's'.  wgetnstr() reads at most n characters, thus
907c478bd9Sstevel@tonic-gate  * preventing a possible overflow of the input buffer.  The user's
917c478bd9Sstevel@tonic-gate  * erase and kill characters are interpreted.
927c478bd9Sstevel@tonic-gate  *
937c478bd9Sstevel@tonic-gate  * If n < 0, wgetnstr() will read until a <newline> or <return> is
947c478bd9Sstevel@tonic-gate  * entered.  To accept functions keys, keypad() must be set for the
957c478bd9Sstevel@tonic-gate  * window.
967c478bd9Sstevel@tonic-gate  */
977c478bd9Sstevel@tonic-gate int
__m_wgetn_wstr(w,s,n,mb_flag)987c478bd9Sstevel@tonic-gate __m_wgetn_wstr(w, s, n, mb_flag)
997c478bd9Sstevel@tonic-gate WINDOW *w;
1007c478bd9Sstevel@tonic-gate void *s;
1017c478bd9Sstevel@tonic-gate int n, mb_flag;
1027c478bd9Sstevel@tonic-gate {
1037c478bd9Sstevel@tonic-gate 	int type;
1047c478bd9Sstevel@tonic-gate 	wchar_t wc;
1057c478bd9Sstevel@tonic-gate 	t_key_entry *k;
1067c478bd9Sstevel@tonic-gate 	struct termios saved;
1077c478bd9Sstevel@tonic-gate 
1087c478bd9Sstevel@tonic-gate #ifdef M_CURSES_TRACE
1097c478bd9Sstevel@tonic-gate 	__m_trace("__m_wgetn_wstr(%p, %p, %d, %d)", w, s, n, mb_flag);
1107c478bd9Sstevel@tonic-gate #endif
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate 	fld_window = w;
1137c478bd9Sstevel@tonic-gate 	fld_index = 0;
1147c478bd9Sstevel@tonic-gate 	fld_bytes = 0;
1157c478bd9Sstevel@tonic-gate 	fld_mb = mb_flag;
1167c478bd9Sstevel@tonic-gate 
1177c478bd9Sstevel@tonic-gate 	/* Read at most N bytes from the field. */
1187c478bd9Sstevel@tonic-gate 	fld_maxlength = n < 0 ? LINE_MAX : n;
1197c478bd9Sstevel@tonic-gate 
1207c478bd9Sstevel@tonic-gate 	/* Make sure there is enough to hold the largest characater. */
1217c478bd9Sstevel@tonic-gate 	if (fld_mb && fld_maxlength < MB_CUR_MAX)
1227c478bd9Sstevel@tonic-gate 		return __m_return_code("wgetn_wstr", ERR);
1237c478bd9Sstevel@tonic-gate 
1247c478bd9Sstevel@tonic-gate 	if (mb_flag) {
1257c478bd9Sstevel@tonic-gate 		/* Create a wint_t buffer, which makes it easier to
1267c478bd9Sstevel@tonic-gate 		 * handle erasing characters from the line.
1277c478bd9Sstevel@tonic-gate 		 */
1287c478bd9Sstevel@tonic-gate 		fld_buffer = (wint_t *) calloc(
1297c478bd9Sstevel@tonic-gate 			fld_maxlength+1, sizeof *fld_buffer
1307c478bd9Sstevel@tonic-gate 		);
1317c478bd9Sstevel@tonic-gate 		if (fld_buffer == (wint_t *) 0)
1327c478bd9Sstevel@tonic-gate 			return __m_return_code("wgetn_wstr", ERR);
1337c478bd9Sstevel@tonic-gate 	} else {
1347c478bd9Sstevel@tonic-gate 		fld_buffer = (wint_t *) s;
1357c478bd9Sstevel@tonic-gate 	}
136*1da57d55SToomas Soome 
1377c478bd9Sstevel@tonic-gate 	(void) __m_tty_wc(VEOL, &wc);
1387c478bd9Sstevel@tonic-gate 	key_table[EOL_KEY].code = (wint_t) wc;
1397c478bd9Sstevel@tonic-gate 	(void) __m_tty_wc(VEOF, &wc);
1407c478bd9Sstevel@tonic-gate 	key_table[EOF_KEY].code = (wint_t) wc;
1417c478bd9Sstevel@tonic-gate 	(void) __m_tty_wc(VKILL, &wc);
1427c478bd9Sstevel@tonic-gate 	key_table[KILL_KEY].code = (wint_t) wc;
1437c478bd9Sstevel@tonic-gate 	(void) __m_tty_wc(VERASE, &wc);
1447c478bd9Sstevel@tonic-gate 	key_table[ERASE_KEY].code = (wint_t) wc;
1457c478bd9Sstevel@tonic-gate 
1467c478bd9Sstevel@tonic-gate 	getyx(fld_window, fld_row, fld_col);
1477c478bd9Sstevel@tonic-gate 
1487c478bd9Sstevel@tonic-gate 	/* We remember if the user specified echo on or off, then disable it
1497c478bd9Sstevel@tonic-gate 	 * so that wgetch() doesn't perform any echoing before we've had a
1507c478bd9Sstevel@tonic-gate 	 * chance to process the key.  fld_insert() will handle the necessary
1517c478bd9Sstevel@tonic-gate 	 * echoing of characters.
1527c478bd9Sstevel@tonic-gate 	 */
1537c478bd9Sstevel@tonic-gate         fld_echo = __m_set_echo(0);
1547c478bd9Sstevel@tonic-gate 	saved = cur_term->_prog;
1557c478bd9Sstevel@tonic-gate 	(void) cbreak();
1567c478bd9Sstevel@tonic-gate 
1577c478bd9Sstevel@tonic-gate 	for (;;) {
1587c478bd9Sstevel@tonic-gate 		type = wget_wch(fld_window, &fld_key);
1597c478bd9Sstevel@tonic-gate 
1607c478bd9Sstevel@tonic-gate 		for (k = key_table; k->type != ERR; ++k)
1617c478bd9Sstevel@tonic-gate 			if (k->type == type && k->code == fld_key)
1627c478bd9Sstevel@tonic-gate 				break;
1637c478bd9Sstevel@tonic-gate 
1647c478bd9Sstevel@tonic-gate 		if (k->func != (int (*)(void)) 0 && !(*k->func)()) {
1657c478bd9Sstevel@tonic-gate 			/* If the edit function returned false then quit. */
1667c478bd9Sstevel@tonic-gate 			fld_buffer[fld_index] = '\0';
1677c478bd9Sstevel@tonic-gate 			break;
1687c478bd9Sstevel@tonic-gate 		}
1697c478bd9Sstevel@tonic-gate 	}
1707c478bd9Sstevel@tonic-gate 
1717c478bd9Sstevel@tonic-gate 	/* Restore the I/O settings. */
1727c478bd9Sstevel@tonic-gate 	(void) __m_set_echo(fld_echo);
1737c478bd9Sstevel@tonic-gate 	(void) __m_tty_set(&saved);
1747c478bd9Sstevel@tonic-gate 
1757c478bd9Sstevel@tonic-gate 	if (mb_flag) {
1767c478bd9Sstevel@tonic-gate 		(void) wistombs((char *) s, fld_buffer, fld_maxlength+1);
1777c478bd9Sstevel@tonic-gate 		free(fld_buffer);
1787c478bd9Sstevel@tonic-gate 	}
1797c478bd9Sstevel@tonic-gate 
1807c478bd9Sstevel@tonic-gate 	return __m_return_code("__m_wgetn_wstr", OK);
1817c478bd9Sstevel@tonic-gate }
1827c478bd9Sstevel@tonic-gate 
1837c478bd9Sstevel@tonic-gate STATIC int
wint_len(wc)1847c478bd9Sstevel@tonic-gate wint_len(wc)
1857c478bd9Sstevel@tonic-gate wint_t wc;
1867c478bd9Sstevel@tonic-gate {
1877c478bd9Sstevel@tonic-gate 	int len;
1887c478bd9Sstevel@tonic-gate 	char mb[MB_LEN_MAX];
1897c478bd9Sstevel@tonic-gate 
1907c478bd9Sstevel@tonic-gate 	if (wc == WEOF)
1917c478bd9Sstevel@tonic-gate 		return 0;
1927c478bd9Sstevel@tonic-gate 
1937c478bd9Sstevel@tonic-gate 	len = wctomb(mb, (wchar_t) wc);
1947c478bd9Sstevel@tonic-gate 
1957c478bd9Sstevel@tonic-gate 	return len < 0 ? 0 : len;
1967c478bd9Sstevel@tonic-gate }
1977c478bd9Sstevel@tonic-gate 
1987c478bd9Sstevel@tonic-gate STATIC int
fld_done()1997c478bd9Sstevel@tonic-gate fld_done()
2007c478bd9Sstevel@tonic-gate {
2017c478bd9Sstevel@tonic-gate 	return 0;
2027c478bd9Sstevel@tonic-gate }
2037c478bd9Sstevel@tonic-gate 
2047c478bd9Sstevel@tonic-gate STATIC int
fld_erase()2057c478bd9Sstevel@tonic-gate fld_erase()
2067c478bd9Sstevel@tonic-gate {
2077c478bd9Sstevel@tonic-gate 	int x, y, width;
2087c478bd9Sstevel@tonic-gate 
2097c478bd9Sstevel@tonic-gate 	if (fld_index <= 0)
2107c478bd9Sstevel@tonic-gate 		return 1;
2117c478bd9Sstevel@tonic-gate 
2127c478bd9Sstevel@tonic-gate 	width = wcwidth(fld_buffer[--fld_index]);
2137c478bd9Sstevel@tonic-gate 	fld_bytes -= wint_len(fld_buffer[fld_index]);
2147c478bd9Sstevel@tonic-gate 	fld_buffer[fld_index] = '\0';
2157c478bd9Sstevel@tonic-gate 	getyx(fld_window, y, x);
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate 	if (0 < x) {
2187c478bd9Sstevel@tonic-gate 		/* Rubout previous character. */
2197c478bd9Sstevel@tonic-gate 		x -= width;
2207c478bd9Sstevel@tonic-gate 	} else if (0 < y) {
2217c478bd9Sstevel@tonic-gate 		/* Reverse line wrap. */
2227c478bd9Sstevel@tonic-gate 		--y;
2237c478bd9Sstevel@tonic-gate 		x = fld_window->_maxx - 1;
2247c478bd9Sstevel@tonic-gate 
2257c478bd9Sstevel@tonic-gate 		/* Find end of previous character, skipping any background
226*1da57d55SToomas Soome 		 * character that may have been written by auto-wrap.
2277c478bd9Sstevel@tonic-gate 		 */
2287c478bd9Sstevel@tonic-gate 		while (fld_buffer[fld_index] != fld_window->_line[y][x]._wc[0])
2297c478bd9Sstevel@tonic-gate 			--x;
2307c478bd9Sstevel@tonic-gate 
2317c478bd9Sstevel@tonic-gate 		/* Find first column of character. */
2327c478bd9Sstevel@tonic-gate 		x = __m_cc_first(fld_window, y, x);
2337c478bd9Sstevel@tonic-gate 	}
2347c478bd9Sstevel@tonic-gate 
2357c478bd9Sstevel@tonic-gate 	(void) __m_cc_erase(fld_window, y, x, y, x);
2367c478bd9Sstevel@tonic-gate 
2377c478bd9Sstevel@tonic-gate 	fld_window->_cury = y;
2387c478bd9Sstevel@tonic-gate 	fld_window->_curx = x;
2397c478bd9Sstevel@tonic-gate 
2407c478bd9Sstevel@tonic-gate 	return 1;
2417c478bd9Sstevel@tonic-gate }
2427c478bd9Sstevel@tonic-gate 
2437c478bd9Sstevel@tonic-gate STATIC int
fld_kill()2447c478bd9Sstevel@tonic-gate fld_kill()
2457c478bd9Sstevel@tonic-gate {
2467c478bd9Sstevel@tonic-gate 	int y, x;
2477c478bd9Sstevel@tonic-gate 
2487c478bd9Sstevel@tonic-gate 	getyx(fld_window, y, x);
2497c478bd9Sstevel@tonic-gate 	(void) __m_cc_erase(fld_window, fld_row, fld_col, y, x);
2507c478bd9Sstevel@tonic-gate 
2517c478bd9Sstevel@tonic-gate 	fld_window->_cury = fld_row;
2527c478bd9Sstevel@tonic-gate 	fld_window->_curx = fld_col;
2537c478bd9Sstevel@tonic-gate 	fld_index = fld_bytes = 0;
2547c478bd9Sstevel@tonic-gate 	fld_buffer[0] = '\0';
2557c478bd9Sstevel@tonic-gate 
2567c478bd9Sstevel@tonic-gate 	return 1;
2577c478bd9Sstevel@tonic-gate }
2587c478bd9Sstevel@tonic-gate 
2597c478bd9Sstevel@tonic-gate STATIC int
fld_insert()2607c478bd9Sstevel@tonic-gate fld_insert()
2617c478bd9Sstevel@tonic-gate {
2627c478bd9Sstevel@tonic-gate 	cchar_t cc;
2637c478bd9Sstevel@tonic-gate 	t_wide_io *wio;
2647c478bd9Sstevel@tonic-gate 
2657c478bd9Sstevel@tonic-gate 	if (fld_maxlength < fld_index)
2667c478bd9Sstevel@tonic-gate 		/* Completely full, terminate input. */
2677c478bd9Sstevel@tonic-gate 		return 0;
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate 	wio = (t_wide_io *) __m_screen->_in;
2707c478bd9Sstevel@tonic-gate 
2717c478bd9Sstevel@tonic-gate 	/* Don't exceed the byte length for the field.
2727c478bd9Sstevel@tonic-gate 	 *
2737c478bd9Sstevel@tonic-gate 	 * m_wio_get() called by wget_wch(), records the
2747c478bd9Sstevel@tonic-gate 	 * number of bytes converted, when _next == _size.
2757c478bd9Sstevel@tonic-gate 	 *
2767c478bd9Sstevel@tonic-gate 	 * wget_wch() makes sure that _next == _size by
2777c478bd9Sstevel@tonic-gate 	 * pushing invalid multibyte characters on to an
2787c478bd9Sstevel@tonic-gate 	 * input stack.
2797c478bd9Sstevel@tonic-gate 	 */
2807c478bd9Sstevel@tonic-gate 	if (fld_mb && fld_maxlength < fld_bytes + wio->_size) {
2817c478bd9Sstevel@tonic-gate 		/* Is there still room for single-byte characters? */
2827c478bd9Sstevel@tonic-gate 		if (fld_bytes < fld_maxlength) {
2837c478bd9Sstevel@tonic-gate 			(void) beep();
2847c478bd9Sstevel@tonic-gate 			return 1;
2857c478bd9Sstevel@tonic-gate 		}
286*1da57d55SToomas Soome 
2877c478bd9Sstevel@tonic-gate 		/* Completely full, terminate input. */
2887c478bd9Sstevel@tonic-gate 		return 0;
2897c478bd9Sstevel@tonic-gate 	}
2907c478bd9Sstevel@tonic-gate 
2917c478bd9Sstevel@tonic-gate 	if (0 <= fld_key) {
2927c478bd9Sstevel@tonic-gate 		fld_buffer[fld_index++] = fld_key;
2937c478bd9Sstevel@tonic-gate 		fld_bytes += wio->_size;
2947c478bd9Sstevel@tonic-gate 
2957c478bd9Sstevel@tonic-gate 		if (fld_echo) {
2967c478bd9Sstevel@tonic-gate 			(void) __m_wc_cc(fld_key, &cc);
2977c478bd9Sstevel@tonic-gate 			(void) wadd_wch(fld_window, &cc);
2987c478bd9Sstevel@tonic-gate 		}
2997c478bd9Sstevel@tonic-gate 	} else {
3007c478bd9Sstevel@tonic-gate 		(void) beep();
3017c478bd9Sstevel@tonic-gate 	}
3027c478bd9Sstevel@tonic-gate 
3037c478bd9Sstevel@tonic-gate 	return 1;
3047c478bd9Sstevel@tonic-gate }
3057c478bd9Sstevel@tonic-gate 
3067c478bd9Sstevel@tonic-gate int
wgetnstr(w,s,n)3077c478bd9Sstevel@tonic-gate wgetnstr(w, s, n)
3087c478bd9Sstevel@tonic-gate WINDOW *w;
3097c478bd9Sstevel@tonic-gate char *s;
3107c478bd9Sstevel@tonic-gate int n;
3117c478bd9Sstevel@tonic-gate {
3127c478bd9Sstevel@tonic-gate 	int code;
3137c478bd9Sstevel@tonic-gate 
3147c478bd9Sstevel@tonic-gate #ifdef M_CURSES_TRACE
3157c478bd9Sstevel@tonic-gate 	__m_trace("wgetnstr(%p, %p, %d)", w, s, n);
3167c478bd9Sstevel@tonic-gate #endif
3177c478bd9Sstevel@tonic-gate 
3187c478bd9Sstevel@tonic-gate 	code = __m_wgetn_wstr(w, (void *) s, n, 1);
3197c478bd9Sstevel@tonic-gate 
3207c478bd9Sstevel@tonic-gate 	return __m_return_code("wgetnstr", code);
3217c478bd9Sstevel@tonic-gate }
3227c478bd9Sstevel@tonic-gate 
3237c478bd9Sstevel@tonic-gate int
wgetn_wstr(w,s,n)3247c478bd9Sstevel@tonic-gate wgetn_wstr(w, s, n)
3257c478bd9Sstevel@tonic-gate WINDOW *w;
3267c478bd9Sstevel@tonic-gate wint_t *s;
3277c478bd9Sstevel@tonic-gate int n;
3287c478bd9Sstevel@tonic-gate {
3297c478bd9Sstevel@tonic-gate 	int code;
3307c478bd9Sstevel@tonic-gate 
3317c478bd9Sstevel@tonic-gate #ifdef M_CURSES_TRACE
3327c478bd9Sstevel@tonic-gate 	__m_trace("wgetn_wstr(%p, %p, %d)", w, s, n);
3337c478bd9Sstevel@tonic-gate #endif
3347c478bd9Sstevel@tonic-gate 
3357c478bd9Sstevel@tonic-gate 	code = __m_wgetn_wstr(w, (void *) s, n, 0);
3367c478bd9Sstevel@tonic-gate 
3377c478bd9Sstevel@tonic-gate 	return __m_return_code("wgetn_wstr", code);
3387c478bd9Sstevel@tonic-gate }
339