m_items.c revision 1.2
1/*-----------------------------------------------------------------------------+ 2| The ncurses menu library is Copyright (C) 1995-1997 | 3| by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de> | 4| All Rights Reserved. | 5| | 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. | 13| | 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+-----------------------------------------------------------------------------*/ 22 23/*************************************************************************** 24* Module menu_items * 25* Connect and disconnect items to and from menus * 26***************************************************************************/ 27 28#include "menu.priv.h" 29 30MODULE_ID("Id: m_items.c,v 1.4 1997/05/01 16:47:26 juergen Exp $") 31 32/*--------------------------------------------------------------------------- 33| Facility : libnmenu 34| Function : int set_menu_items(MENU *menu, ITEM **items) 35| 36| Description : Sets the item pointer array connected to menu. 37| 38| Return Values : E_OK - success 39| E_POSTED - menu is already posted 40| E_CONNECTED - one or more items are already connected 41| to another menu. 42| E_BAD_ARGUMENT - An incorrect menu or item array was 43| passed to the function 44+--------------------------------------------------------------------------*/ 45int set_menu_items(MENU * menu, ITEM ** items) 46{ 47 if (!menu || (items && !(*items))) 48 RETURN(E_BAD_ARGUMENT); 49 50 if ( menu->status & _POSTED ) 51 RETURN(E_POSTED); 52 53 if (menu->items) 54 _nc_Disconnect_Items(menu); 55 56 if (items) 57 { 58 if(!_nc_Connect_Items( menu, items )) 59 RETURN(E_CONNECTED); 60 } 61 62 menu->items = items; 63 RETURN(E_OK); 64} 65 66/*--------------------------------------------------------------------------- 67| Facility : libnmenu 68| Function : ITEM **menu_items(const MENU *menu) 69| 70| Description : Returns a pointer to the item pointer arry of the menu 71| 72| Return Values : NULL on error 73+--------------------------------------------------------------------------*/ 74ITEM **menu_items(const MENU *menu) 75{ 76 return(menu ? menu->items : (ITEM **)0); 77} 78 79/*--------------------------------------------------------------------------- 80| Facility : libnmenu 81| Function : int item_count(const MENU *menu) 82| 83| Description : Get the number of items connected to the menu. If the 84| menu pointer is NULL we return -1. 85| 86| Return Values : Number of items or -1 to indicate error. 87+--------------------------------------------------------------------------*/ 88int item_count(const MENU *menu) 89{ 90 return(menu ? menu->nitems : -1); 91} 92 93/* m_items.c ends here */ 94