Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 1 | /**************************************************************************** |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 2 | * Copyright 2020,2021 Thomas E. Dickey * |
| 3 | * Copyright 1998-2012,2013 Free Software Foundation, Inc. * |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 4 | * * |
| 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: * |
| 12 | * * |
| 13 | * The above copyright notice and this permission notice shall be included * |
| 14 | * in all copies or substantial portions of the Software. * |
| 15 | * * |
| 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. * |
| 23 | * * |
| 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 * |
| 27 | * authorization. * |
| 28 | ****************************************************************************/ |
| 29 | |
| 30 | /**************************************************************************** |
| 31 | * Author: Juergen Pfeifer, 1995,1997 * |
| 32 | ****************************************************************************/ |
| 33 | |
| 34 | #include "form.priv.h" |
| 35 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 36 | MODULE_ID("$Id: frm_opts.c,v 1.21 2021/06/17 21:20:30 tom Exp $") |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 37 | |
| 38 | /*--------------------------------------------------------------------------- |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 39 | | Facility : libnform |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 40 | | Function : int set_form_opts(FORM *form, Form_Options opts) |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 41 | | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 42 | | Description : Turns on the named options and turns off all the |
| 43 | | remaining options for that form. |
| 44 | | |
| 45 | | Return Values : E_OK - success |
| 46 | | E_BAD_ARGUMENT - invalid options |
| 47 | +--------------------------------------------------------------------------*/ |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 48 | FORM_EXPORT(int) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 49 | set_form_opts(FORM *form, Form_Options opts) |
| 50 | { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 51 | T((T_CALLED("set_form_opts(%p,%d)"), (void *)form, opts)); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 52 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 53 | opts &= (Form_Options)ALL_FORM_OPTS; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 54 | if ((unsigned)opts & ~ALL_FORM_OPTS) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 55 | RETURN(E_BAD_ARGUMENT); |
| 56 | else |
| 57 | { |
| 58 | Normalize_Form(form)->opts = opts; |
| 59 | RETURN(E_OK); |
| 60 | } |
| 61 | } |
| 62 | |
| 63 | /*--------------------------------------------------------------------------- |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 64 | | Facility : libnform |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 65 | | Function : Form_Options form_opts(const FORM *) |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 66 | | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 67 | | Description : Retrieves the current form options. |
| 68 | | |
| 69 | | Return Values : The option flags. |
| 70 | +--------------------------------------------------------------------------*/ |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 71 | FORM_EXPORT(Form_Options) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 72 | form_opts(const FORM *form) |
| 73 | { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 74 | T((T_CALLED("form_opts(%p)"), (const void *)form)); |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 75 | returnCode((Form_Options)((unsigned)Normalize_Form(form)->opts & ALL_FORM_OPTS)); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | /*--------------------------------------------------------------------------- |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 79 | | Facility : libnform |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 80 | | Function : int form_opts_on(FORM *form, Form_Options opts) |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 81 | | |
| 82 | | Description : Turns on the named options; no other options are |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 83 | | changed. |
| 84 | | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 85 | | Return Values : E_OK - success |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 86 | | E_BAD_ARGUMENT - invalid options |
| 87 | +--------------------------------------------------------------------------*/ |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 88 | FORM_EXPORT(int) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 89 | form_opts_on(FORM *form, Form_Options opts) |
| 90 | { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 91 | T((T_CALLED("form_opts_on(%p,%d)"), (void *)form, opts)); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 92 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 93 | opts &= (Form_Options)ALL_FORM_OPTS; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 94 | if ((unsigned)opts & ~ALL_FORM_OPTS) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 95 | RETURN(E_BAD_ARGUMENT); |
| 96 | else |
| 97 | { |
| 98 | Normalize_Form(form)->opts |= opts; |
| 99 | RETURN(E_OK); |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | /*--------------------------------------------------------------------------- |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 104 | | Facility : libnform |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 105 | | Function : int form_opts_off(FORM *form, Form_Options opts) |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 106 | | |
| 107 | | Description : Turns off the named options; no other options are |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 108 | | changed. |
| 109 | | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 110 | | Return Values : E_OK - success |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 111 | | E_BAD_ARGUMENT - invalid options |
| 112 | +--------------------------------------------------------------------------*/ |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 113 | FORM_EXPORT(int) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 114 | form_opts_off(FORM *form, Form_Options opts) |
| 115 | { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 116 | T((T_CALLED("form_opts_off(%p,%d)"), (void *)form, opts)); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 117 | |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 118 | opts &= (Form_Options)ALL_FORM_OPTS; |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 119 | if ((unsigned)opts & ~ALL_FORM_OPTS) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 120 | RETURN(E_BAD_ARGUMENT); |
| 121 | else |
| 122 | { |
| 123 | Normalize_Form(form)->opts &= ~opts; |
| 124 | RETURN(E_OK); |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | /* frm_opts.c ends here */ |