1 /* $OpenBSD: lib_wunctrl.c,v 1.2 2023/10/17 09:52:09 nicm Exp $ */
2
3 /****************************************************************************
4 * Copyright 2020 Thomas E. Dickey *
5 * Copyright 2001-2011,2012 Free Software Foundation, Inc. *
6 * *
7 * Permission is hereby granted, free of charge, to any person obtaining a *
8 * copy of this software and associated documentation files (the *
9 * "Software"), to deal in the Software without restriction, including *
10 * without limitation the rights to use, copy, modify, merge, publish, *
11 * distribute, distribute with modifications, sublicense, and/or sell *
12 * copies of the Software, and to permit persons to whom the Software is *
13 * furnished to do so, subject to the following conditions: *
14 * *
15 * The above copyright notice and this permission notice shall be included *
16 * in all copies or substantial portions of the Software. *
17 * *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
21 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
24 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
25 * *
26 * Except as contained in this notice, the name(s) of the above copyright *
27 * holders shall not be used in advertising or otherwise to promote the *
28 * sale, use or other dealings in this Software without prior written *
29 * authorization. *
30 ****************************************************************************/
31
32 /*
33 ** lib_wunctrl.c
34 **
35 ** The routine wunctrl().
36 **
37 */
38
39 #include <curses.priv.h>
40
41 MODULE_ID("$Id: lib_wunctrl.c,v 1.2 2023/10/17 09:52:09 nicm Exp $")
42
NCURSES_EXPORT(wchar_t *)43 NCURSES_EXPORT(wchar_t *)
44 NCURSES_SP_NAME(wunctrl) (NCURSES_SP_DCLx cchar_t *wc)
45 {
46 static wchar_t str[CCHARW_MAX + 1], *wsp;
47 wchar_t *result;
48
49 if (wc == 0) {
50 result = 0;
51 } else if (SP_PARM != 0 && Charable(*wc)) {
52 const char *p =
53 NCURSES_SP_NAME(unctrl) (NCURSES_SP_ARGx
54 (unsigned) _nc_to_char((wint_t)CharOf(*wc)));
55
56 for (wsp = str; *p; ++p) {
57 *wsp++ = (wchar_t) _nc_to_widechar(*p);
58 }
59 *wsp = 0;
60 result = str;
61 } else {
62 result = wc->chars;
63 }
64 return result;
65 }
66
67 #if NCURSES_SP_FUNCS
68 NCURSES_EXPORT(wchar_t *)
wunctrl(cchar_t * wc)69 wunctrl(cchar_t *wc)
70 {
71 return NCURSES_SP_NAME(wunctrl) (CURRENT_SCREEN, wc);
72 }
73 #endif
74