1 /****************************************************************************
2 * Copyright 2020,2021 Thomas E. Dickey *
3 * Copyright 1998-2012,2013 Free Software Foundation, Inc. *
5 * Permission is hereby granted, free of charge, to any person obtaining a *
6 * copy of this software and associated documentation files (the *
7 * "Software"), to deal in the Software without restriction, including *
8 * without limitation the rights to use, copy, modify, merge, publish, *
9 * distribute, distribute with modifications, sublicense, and/or sell *
10 * copies of the Software, and to permit persons to whom the Software is *
11 * furnished to do so, subject to the following conditions: *
13 * The above copyright notice and this permission notice shall be included *
14 * in all copies or substantial portions of the Software. *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS *
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF *
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. *
19 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, *
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR *
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR *
22 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
24 * Except as contained in this notice, the name(s) of the above copyright *
25 * holders shall not be used in advertising or otherwise to promote the *
26 * sale, use or other dealings in this Software without prior written *
28 ****************************************************************************/
30 /****************************************************************************
31 * Author: Juergen Pfeifer, 1995,1997 *
32 ****************************************************************************/
34 #include "form.priv.h"
36 MODULE_ID("$Id: frm_opts.c,v 1.21 2021/06/17 21:20:30 tom Exp $")
38 /*---------------------------------------------------------------------------
40 | Function : int set_form_opts(FORM *form, Form_Options opts)
42 | Description : Turns on the named options and turns off all the
43 | remaining options for that form.
45 | Return Values : E_OK - success
46 | E_BAD_ARGUMENT - invalid options
47 +--------------------------------------------------------------------------*/
49 set_form_opts(FORM *form, Form_Options opts)
51 T((T_CALLED("set_form_opts(%p,%d)"), (void *)form, opts));
53 opts &= (Form_Options)ALL_FORM_OPTS;
54 if ((unsigned)opts & ~ALL_FORM_OPTS)
55 RETURN(E_BAD_ARGUMENT);
58 Normalize_Form(form)->opts = opts;
63 /*---------------------------------------------------------------------------
65 | Function : Form_Options form_opts(const FORM *)
67 | Description : Retrieves the current form options.
69 | Return Values : The option flags.
70 +--------------------------------------------------------------------------*/
71 FORM_EXPORT(Form_Options)
72 form_opts(const FORM *form)
74 T((T_CALLED("form_opts(%p)"), (const void *)form));
75 returnCode((Form_Options)((unsigned)Normalize_Form(form)->opts & ALL_FORM_OPTS));
78 /*---------------------------------------------------------------------------
80 | Function : int form_opts_on(FORM *form, Form_Options opts)
82 | Description : Turns on the named options; no other options are
85 | Return Values : E_OK - success
86 | E_BAD_ARGUMENT - invalid options
87 +--------------------------------------------------------------------------*/
89 form_opts_on(FORM *form, Form_Options opts)
91 T((T_CALLED("form_opts_on(%p,%d)"), (void *)form, opts));
93 opts &= (Form_Options)ALL_FORM_OPTS;
94 if ((unsigned)opts & ~ALL_FORM_OPTS)
95 RETURN(E_BAD_ARGUMENT);
98 Normalize_Form(form)->opts |= opts;
103 /*---------------------------------------------------------------------------
104 | Facility : libnform
105 | Function : int form_opts_off(FORM *form, Form_Options opts)
107 | Description : Turns off the named options; no other options are
110 | Return Values : E_OK - success
111 | E_BAD_ARGUMENT - invalid options
112 +--------------------------------------------------------------------------*/
114 form_opts_off(FORM *form, Form_Options opts)
116 T((T_CALLED("form_opts_off(%p,%d)"), (void *)form, opts));
118 opts &= (Form_Options)ALL_FORM_OPTS;
119 if ((unsigned)opts & ~ALL_FORM_OPTS)
120 RETURN(E_BAD_ARGUMENT);
123 Normalize_Form(form)->opts &= ~opts;
128 /* frm_opts.c ends here */