1 /*-----------------------------------------------------------------------------+
2 | The ncurses menu library is Copyright (C) 1995-1997 |
3 | by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> |
4 | All Rights Reserved. |
6 | Permission to use, copy, modify, and distribute this software and its |
7 | documentation for any purpose and without fee is hereby granted, provided |
8 | that the above copyright notice appear in all copies and that both that |
9 | copyright notice and this permission notice appear in supporting |
10 | documentation, and that the name of the above listed copyright holder(s) not |
11 | be used in advertising or publicity pertaining to distribution of the |
12 | software without specific, written prior permission. |
14 | THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO |
15 | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT- |
16 | NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR |
17 | ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
18 | SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
19 | NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH |
20 | THE USE OR PERFORMANCE OF THIS SOFTWARE. |
21 +-----------------------------------------------------------------------------*/
23 /***************************************************************************
25 * Creation and destruction of new menus *
26 ***************************************************************************/
28 #include "menu.priv.h"
30 MODULE_ID("$Id: m_new.c,v 1.5 1997/05/01 16:47:26 juergen Exp $")
32 /*---------------------------------------------------------------------------
34 | Function : MENU *new_menu(ITEM **items)
36 | Description : Creates a new menu connected to the item pointer
37 | array items and returns a pointer to the new menu.
38 | The new menu is initialized with the values from the
41 | Return Values : NULL on error
42 +--------------------------------------------------------------------------*/
43 MENU *new_menu(ITEM ** items)
45 MENU *menu = (MENU *)calloc(1,sizeof(MENU));
49 *menu = _nc_Default_Menu;
50 menu->rows = menu->frows;
51 menu->cols = menu->fcols;
54 if (!_nc_Connect_Items(menu,items))
63 SET_ERROR(E_SYSTEM_ERROR);
68 /*---------------------------------------------------------------------------
70 | Function : int free_menu(MENU *menu)
72 | Description : Disconnects menu from its associated item pointer
73 | array and frees the storage allocated for the menu.
75 | Return Values : E_OK - success
76 | E_BAD_ARGUMENT - Invalid menu pointer passed
77 | E_POSTED - Menu is already posted
78 +--------------------------------------------------------------------------*/
79 int free_menu(MENU * menu)
82 RETURN(E_BAD_ARGUMENT);
84 if ( menu->status & _POSTED )
88 _nc_Disconnect_Items(menu);
90 if ((menu->status & _MARK_ALLOCATED) && menu->mark)
97 /* m_new.c ends here */