GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: lib/libpanel/p_new.c Lines: 0 22 0.0 %
Date: 2017-11-13 Branches: 0 12 0.0 %

Line Branch Exec Source
1
/* $OpenBSD: p_new.c,v 1.5 2010/01/12 23:22:08 nicm Exp $ */
2
3
/****************************************************************************
4
 * Copyright (c) 1998-2005,2008 Free Software Foundation, Inc.              *
5
 *                                                                          *
6
 * Permission is hereby granted, free of charge, to any person obtaining a  *
7
 * copy of this software and associated documentation files (the            *
8
 * "Software"), to deal in the Software without restriction, including      *
9
 * without limitation the rights to use, copy, modify, merge, publish,      *
10
 * distribute, distribute with modifications, sublicense, and/or sell       *
11
 * copies of the Software, and to permit persons to whom the Software is    *
12
 * furnished to do so, subject to the following conditions:                 *
13
 *                                                                          *
14
 * The above copyright notice and this permission notice shall be included  *
15
 * in all copies or substantial portions of the Software.                   *
16
 *                                                                          *
17
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
18
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
19
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
20
 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
21
 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
22
 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
23
 * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
24
 *                                                                          *
25
 * Except as contained in this notice, the name(s) of the above copyright   *
26
 * holders shall not be used in advertising or otherwise to promote the     *
27
 * sale, use or other dealings in this Software without prior written       *
28
 * authorization.                                                           *
29
 ****************************************************************************/
30
31
/****************************************************************************
32
 *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1995                    *
33
 *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
34
 *     and: Juergen Pfeifer                         1997-1999               *
35
 *     and: Thomas E. Dickey                        2000-on                 *
36
 ****************************************************************************/
37
38
/* p_new.c
39
 * Creation of a new panel
40
 */
41
#include "panel.priv.h"
42
43
MODULE_ID("$Id: p_new.c,v 1.5 2010/01/12 23:22:08 nicm Exp $")
44
45
#ifdef TRACE
46
static char *stdscr_id;
47
static char *new_id;
48
#endif
49
50
/*+-------------------------------------------------------------------------
51
  Get root (i.e. stdscr's) panel.
52
  Establish the pseudo panel for stdscr if necessary.
53
--------------------------------------------------------------------------*/
54
static PANEL *
55
root_panel(void)
56
{
57
  if (_nc_stdscr_pseudo_panel == (PANEL *) 0)
58
    {
59
60
      assert(stdscr && !_nc_bottom_panel && !_nc_top_panel);
61
#if NO_LEAKS
62
      _nc_panelhook()->destroy = del_panel;
63
#endif
64
      _nc_stdscr_pseudo_panel = (PANEL *) malloc(sizeof(PANEL));
65
      if (_nc_stdscr_pseudo_panel != 0)
66
	{
67
	  PANEL *pan = _nc_stdscr_pseudo_panel;
68
	  WINDOW *win = stdscr;
69
70
	  pan->win = win;
71
	  pan->below = (PANEL *) 0;
72
	  pan->above = (PANEL *) 0;
73
#ifdef TRACE
74
	  if (!stdscr_id)
75
	    stdscr_id = strdup("stdscr");
76
	  pan->user = stdscr_id;
77
#else
78
	  pan->user = (void *)0;
79
#endif
80
	  _nc_bottom_panel = _nc_top_panel = pan;
81
	}
82
    }
83
  return _nc_stdscr_pseudo_panel;
84
}
85
86
NCURSES_EXPORT(PANEL *)
87
new_panel(WINDOW *win)
88
{
89
  PANEL *pan = (PANEL *) 0;
90
91
  T((T_CALLED("new_panel(%p)"), win));
92
93
  if (!win)
94
    returnPanel(pan);
95
96
  if (!_nc_stdscr_pseudo_panel)
97
    (void)root_panel();
98
  assert(_nc_stdscr_pseudo_panel);
99
100
  if (!(win->_flags & _ISPAD) && (pan = (PANEL *) malloc(sizeof(PANEL))))
101
    {
102
      pan->win = win;
103
      pan->above = (PANEL *) 0;
104
      pan->below = (PANEL *) 0;
105
#ifdef TRACE
106
      if (!new_id)
107
	new_id = strdup("new");
108
      pan->user = new_id;
109
#else
110
      pan->user = (char *)0;
111
#endif
112
      (void)show_panel(pan);
113
    }
114
  returnPanel(pan);
115
}