xref: /openbsd-src/lib/libform/frm_opts.c (revision 43003dfe3ad45d1698bed8a37f2b0f5b14f20d4f)
1 /*	$OpenBSD: frm_opts.c,v 1.7 2001/01/22 18:02:15 millert Exp $	*/
2 
3 /****************************************************************************
4  * Copyright (c) 1998,2000 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: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997            *
33  ****************************************************************************/
34 
35 #include "form.priv.h"
36 
37 MODULE_ID("$From: frm_opts.c,v 1.9 2000/12/10 02:09:37 tom Exp $")
38 
39 /*---------------------------------------------------------------------------
40 |   Facility      :  libnform
41 |   Function      :  int set_form_opts(FORM *form, Form_Options opts)
42 |
43 |   Description   :  Turns on the named options and turns off all the
44 |                    remaining options for that form.
45 |
46 |   Return Values :  E_OK              - success
47 |                    E_BAD_ARGUMENT    - invalid options
48 +--------------------------------------------------------------------------*/
49 NCURSES_EXPORT(int)
50 set_form_opts (FORM * form, Form_Options  opts)
51 {
52   opts &= ALL_FORM_OPTS;
53   if (opts & ~ALL_FORM_OPTS)
54     RETURN(E_BAD_ARGUMENT);
55   else
56     {
57       Normalize_Form( form )->opts = opts;
58       RETURN(E_OK);
59     }
60 }
61 
62 /*---------------------------------------------------------------------------
63 |   Facility      :  libnform
64 |   Function      :  Form_Options form_opts(const FORM *)
65 |
66 |   Description   :  Retrieves the current form options.
67 |
68 |   Return Values :  The option flags.
69 +--------------------------------------------------------------------------*/
70 NCURSES_EXPORT(Form_Options)
71 form_opts (const FORM * form)
72 {
73   return (Normalize_Form(form)->opts & ALL_FORM_OPTS);
74 }
75 
76 /*---------------------------------------------------------------------------
77 |   Facility      :  libnform
78 |   Function      :  int form_opts_on(FORM *form, Form_Options opts)
79 |
80 |   Description   :  Turns on the named options; no other options are
81 |                    changed.
82 |
83 |   Return Values :  E_OK            - success
84 |                    E_BAD_ARGUMENT  - invalid options
85 +--------------------------------------------------------------------------*/
86 NCURSES_EXPORT(int)
87 form_opts_on (FORM * form, Form_Options opts)
88 {
89   opts &= ALL_FORM_OPTS;
90   if (opts & ~ALL_FORM_OPTS)
91     RETURN(E_BAD_ARGUMENT);
92   else
93     {
94       Normalize_Form( form )->opts |= opts;
95       RETURN(E_OK);
96     }
97 }
98 
99 /*---------------------------------------------------------------------------
100 |   Facility      :  libnform
101 |   Function      :  int form_opts_off(FORM *form, Form_Options opts)
102 |
103 |   Description   :  Turns off the named options; no other options are
104 |                    changed.
105 |
106 |   Return Values :  E_OK            - success
107 |                    E_BAD_ARGUMENT  - invalid options
108 +--------------------------------------------------------------------------*/
109 NCURSES_EXPORT(int)
110 form_opts_off (FORM * form, Form_Options opts)
111 {
112   opts &= ALL_FORM_OPTS;
113   if (opts & ~ALL_FORM_OPTS)
114     RETURN(E_BAD_ARGUMENT);
115   else
116     {
117       Normalize_Form(form)->opts &= ~opts;
118       RETURN(E_OK);
119     }
120 }
121 
122 /* frm_opts.c ends here */
123