15ca44d1cSRong-En Fan /****************************************************************************
2*e1865124SBaptiste Daroussin * Copyright 2018,2020 Thomas E. Dickey *
3*e1865124SBaptiste Daroussin * Copyright 2007-2009,2016 Free Software Foundation, Inc. *
45ca44d1cSRong-En Fan * *
55ca44d1cSRong-En Fan * Permission is hereby granted, free of charge, to any person obtaining a *
65ca44d1cSRong-En Fan * copy of this software and associated documentation files (the *
75ca44d1cSRong-En Fan * "Software"), to deal in the Software without restriction, including *
85ca44d1cSRong-En Fan * without limitation the rights to use, copy, modify, merge, publish, *
95ca44d1cSRong-En Fan * distribute, distribute with modifications, sublicense, and/or sell *
105ca44d1cSRong-En Fan * copies of the Software, and to permit persons to whom the Software is *
115ca44d1cSRong-En Fan * furnished to do so, subject to the following conditions: *
125ca44d1cSRong-En Fan * *
135ca44d1cSRong-En Fan * The above copyright notice and this permission notice shall be included *
145ca44d1cSRong-En Fan * in all copies or substantial portions of the Software. *
155ca44d1cSRong-En Fan * *
165ca44d1cSRong-En Fan * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
175ca44d1cSRong-En Fan * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
185ca44d1cSRong-En Fan * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
195ca44d1cSRong-En Fan * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
205ca44d1cSRong-En Fan * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
215ca44d1cSRong-En Fan * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
225ca44d1cSRong-En Fan * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
235ca44d1cSRong-En Fan * *
245ca44d1cSRong-En Fan * Except as contained in this notice, the name(s) of the above copyright *
255ca44d1cSRong-En Fan * holders shall not be used in advertising or otherwise to promote the *
265ca44d1cSRong-En Fan * sale, use or other dealings in this Software without prior written *
275ca44d1cSRong-En Fan * authorization. *
285ca44d1cSRong-En Fan ****************************************************************************/
295ca44d1cSRong-En Fan
305ca44d1cSRong-En Fan /****************************************************************************
315ca44d1cSRong-En Fan * Author: Thomas E. Dickey 2007 *
325ca44d1cSRong-En Fan ****************************************************************************/
335ca44d1cSRong-En Fan
345ca44d1cSRong-En Fan #include <curses.priv.h>
355ca44d1cSRong-En Fan
36*e1865124SBaptiste Daroussin MODULE_ID("$Id: use_window.c,v 1.13 2020/02/02 23:34:34 tom Exp $")
375ca44d1cSRong-En Fan
NCURSES_EXPORT(int)385ca44d1cSRong-En Fan NCURSES_EXPORT(int)
39aa59d4d4SRong-En Fan use_window(WINDOW *win, NCURSES_WINDOW_CB func, void *data)
405ca44d1cSRong-En Fan {
415ca44d1cSRong-En Fan int code = OK;
42aae38d10SBaptiste Daroussin TR_FUNC_BFR(1);
435ca44d1cSRong-En Fan
44aae38d10SBaptiste Daroussin T((T_CALLED("use_window(%p,%s,%p)"),
45aae38d10SBaptiste Daroussin (void *) win,
46aae38d10SBaptiste Daroussin TR_FUNC_ARG(0, func),
47aae38d10SBaptiste Daroussin data));
48aae38d10SBaptiste Daroussin
495d08fb1fSRong-En Fan _nc_lock_global(curses);
505ca44d1cSRong-En Fan code = func(win, data);
515d08fb1fSRong-En Fan _nc_unlock_global(curses);
525ca44d1cSRong-En Fan
535ca44d1cSRong-En Fan returnCode(code);
545ca44d1cSRong-En Fan }
55