xref: /netbsd/lib/libmenu/menu_item_value.3 (revision c4a72b64)
1.\"	$NetBSD: menu_item_value.3,v 1.10 2002/10/01 19:26:59 wiz Exp $ .\"
2.\" Copyright (c) 1999
3.\"	Brett Lymn - blymn@baea.com.au, brett_lymn@yahoo.com.au
4.\"
5.\" This code is donated to The NetBSD Foundation by the author.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. The name of the Author may not be used to endorse or promote
16.\"    products derived from this software without specific prior written
17.\"    permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.Dd September 10, 1999
32.Dt MENU_ITEM_VALUE 3
33.Os
34.Sh NAME
35.Nm item_value ,
36.Nm set_item_value ,
37.Nm item_selected
38.Nd get or set value for an item
39.Sh LIBRARY
40.Lb libmenu
41.Sh SYNOPSIS
42.Fd #include \*[Lt]menu.h\*[Gt]
43.Ft int
44.Fn item_value "ITEM *item"
45.Ft int
46.Fn set_item_value "ITEM *item" "int flag"
47.Ft int
48.Fn item_selected "MENU *menu" "int **array"
49.Sh DESCRIPTION
50The
51.Fn item_value
52function returns value of the item.
53If the item has been selected then this value will be TRUE.
54The value can also be set by calling
55.Fn set_item_value
56to set the value to a defined state.
57Setting the value to a value
58other than TRUE or FALSE will have undefined results.
59The
60.Fn item_selected
61function returns the number of items that are selected in the menu, that
62is the number of items whose value is TRUE.
63The indexes of the selected
64items will be returned in
65.Fa array
66which will be dynamically allocated to hold the number of indexes.
67It is the responsibility of the caller to release this storage by calling
68.Xr free 3
69when the storage is no longer required.
70If there are no elements selected in the items array then
71.Fn item_selected
72will return 0 and
73.Fa array
74will be NULL.
75If an error occurs
76.Fn item_selected
77will return one of the below return values which are less than 0.
78.Sh RETURN VALUES
79The functions return one of the following error values:
80.Pp
81.Bl -tag -width E_REQUEST_DENIED -compact
82.It Er E_OK
83The function was successful.
84.It Er E_NOT_CONNECTED
85The item is not connected to a menu.
86.It Er E_REQUEST_DENIED
87The menu driver could not process the request.
88.It Er E_SYSTEM_ERROR
89A system error occurred whilst processing the request.
90.El
91.Sh SEE ALSO
92.Xr curses 3 ,
93.Xr menus 3
94.Sh NOTES
95The header
96.Pa \*[Lt]menu.h\*[Gt]
97automatically includes both
98.Pa \*[Lt]curses.h\*[Gt]
99and
100.Pa \*[Lt]eti.h\*[Gt] .
101.Pp
102The function
103.Fn item_selected
104is a
105.Nx
106extension and must not be used in portable code.
107