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-2004,2010 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: fld_opts.c,v 1.16 2021/06/17 21:20:30 tom Exp $") |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 37 | |
| 38 | /*---------------------------------------------------------------------------- |
| 39 | Field-Options manipulation routines |
| 40 | --------------------------------------------------------------------------*/ |
| 41 | |
| 42 | /*--------------------------------------------------------------------------- |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 43 | | Facility : libnform |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 44 | | Function : int set_field_opts(FIELD *field, Field_Options opts) |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 45 | | |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 46 | | Description : Turns on the named options for this field and turns |
| 47 | | off all the remaining options. |
| 48 | | |
| 49 | | Return Values : E_OK - success |
| 50 | | E_CURRENT - the field is the current field |
| 51 | | E_BAD_ARGUMENT - invalid options |
| 52 | | E_SYSTEM_ERROR - system error |
| 53 | +--------------------------------------------------------------------------*/ |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 54 | FORM_EXPORT(int) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 55 | set_field_opts(FIELD *field, Field_Options opts) |
| 56 | { |
| 57 | int res = E_BAD_ARGUMENT; |
| 58 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 59 | T((T_CALLED("set_field_opts(%p,%d)"), (void *)field, opts)); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 60 | |
| 61 | opts &= ALL_FIELD_OPTS; |
| 62 | if (!(opts & ~ALL_FIELD_OPTS)) |
| 63 | res = _nc_Synchronize_Options(Normalize_Field(field), opts); |
| 64 | RETURN(res); |
| 65 | } |
| 66 | |
| 67 | /*--------------------------------------------------------------------------- |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 68 | | Facility : libnform |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 69 | | Function : Field_Options field_opts(const FIELD *field) |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 70 | | |
| 71 | | Description : Retrieve the field's options. |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 72 | | |
| 73 | | Return Values : The options. |
| 74 | +--------------------------------------------------------------------------*/ |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 75 | FORM_EXPORT(Field_Options) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 76 | field_opts(const FIELD *field) |
| 77 | { |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 78 | T((T_CALLED("field_opts(%p)"), (const void *)field)); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 79 | |
| 80 | returnCode(ALL_FIELD_OPTS & Normalize_Field(field)->opts); |
| 81 | } |
| 82 | |
| 83 | /*--------------------------------------------------------------------------- |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 84 | | Facility : libnform |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 85 | | Function : int field_opts_on(FIELD *field, Field_Options opts) |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 86 | | |
| 87 | | Description : Turns on the named options for this field and all the |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 88 | | remaining options are unchanged. |
| 89 | | |
| 90 | | Return Values : E_OK - success |
| 91 | | E_CURRENT - the field is the current field |
| 92 | | E_BAD_ARGUMENT - invalid options |
| 93 | | E_SYSTEM_ERROR - system error |
| 94 | +--------------------------------------------------------------------------*/ |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 95 | FORM_EXPORT(int) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 96 | field_opts_on(FIELD *field, Field_Options opts) |
| 97 | { |
| 98 | int res = E_BAD_ARGUMENT; |
| 99 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 100 | T((T_CALLED("field_opts_on(%p,%d)"), (void *)field, opts)); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 101 | |
| 102 | opts &= ALL_FIELD_OPTS; |
| 103 | if (!(opts & ~ALL_FIELD_OPTS)) |
| 104 | { |
| 105 | Normalize_Field(field); |
| 106 | res = _nc_Synchronize_Options(field, field->opts | opts); |
| 107 | } |
| 108 | RETURN(res); |
| 109 | } |
| 110 | |
| 111 | /*--------------------------------------------------------------------------- |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 112 | | Facility : libnform |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 113 | | Function : int field_opts_off(FIELD *field, Field_Options opts) |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 114 | | |
| 115 | | Description : Turns off the named options for this field and all the |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 116 | | remaining options are unchanged. |
| 117 | | |
| 118 | | Return Values : E_OK - success |
| 119 | | E_CURRENT - the field is the current field |
| 120 | | E_BAD_ARGUMENT - invalid options |
| 121 | | E_SYSTEM_ERROR - system error |
| 122 | +--------------------------------------------------------------------------*/ |
micky387 | 9b9f5e7 | 2025-07-08 18:04:53 -0400 | [diff] [blame] | 123 | FORM_EXPORT(int) |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 124 | field_opts_off(FIELD *field, Field_Options opts) |
| 125 | { |
| 126 | int res = E_BAD_ARGUMENT; |
| 127 | |
Steve Kondik | ae271bc | 2015-11-15 02:50:53 +0100 | [diff] [blame] | 128 | T((T_CALLED("field_opts_off(%p,%d)"), (void *)field, opts)); |
Amit Daniel Kachhap | e6a01f5 | 2011-07-20 11:45:59 +0530 | [diff] [blame] | 129 | |
| 130 | opts &= ALL_FIELD_OPTS; |
| 131 | if (!(opts & ~ALL_FIELD_OPTS)) |
| 132 | { |
| 133 | Normalize_Field(field); |
| 134 | res = _nc_Synchronize_Options(field, field->opts & ~opts); |
| 135 | } |
| 136 | RETURN(res); |
| 137 | } |
| 138 | |
| 139 | /* fld_opts.c ends here */ |