1 /* $OpenBSD: fld_opts.c,v 1.5 2001/01/22 18:02:13 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 #include "form.priv.h" 35 36 MODULE_ID("$From: fld_opts.c,v 1.7 2000/12/10 02:09:38 tom Exp $") 37 38 /*---------------------------------------------------------------------------- 39 Field-Options manipulation routines 40 --------------------------------------------------------------------------*/ 41 42 /*--------------------------------------------------------------------------- 43 | Facility : libnform 44 | Function : int set_field_opts(FIELD *field, Field_Options opts) 45 | 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 +--------------------------------------------------------------------------*/ 54 NCURSES_EXPORT(int) 55 set_field_opts (FIELD * field, Field_Options opts) 56 { 57 int res = E_BAD_ARGUMENT; 58 opts &= ALL_FIELD_OPTS; 59 if (!(opts & ~ALL_FIELD_OPTS)) 60 res = _nc_Synchronize_Options( Normalize_Field(field), opts ); 61 RETURN(res); 62 } 63 64 /*--------------------------------------------------------------------------- 65 | Facility : libnform 66 | Function : Field_Options field_opts(const FIELD *field) 67 | 68 | Description : Retrieve the fields options. 69 | 70 | Return Values : The options. 71 +--------------------------------------------------------------------------*/ 72 NCURSES_EXPORT(Field_Options) 73 field_opts (const FIELD * field) 74 { 75 return ALL_FIELD_OPTS & Normalize_Field( field )->opts; 76 } 77 78 /*--------------------------------------------------------------------------- 79 | Facility : libnform 80 | Function : int field_opts_on(FIELD *field, Field_Options opts) 81 | 82 | Description : Turns on the named options for this field and all the 83 | remaining options are unchanged. 84 | 85 | Return Values : E_OK - success 86 | E_CURRENT - the field is the current field 87 | E_BAD_ARGUMENT - invalid options 88 | E_SYSTEM_ERROR - system error 89 +--------------------------------------------------------------------------*/ 90 NCURSES_EXPORT(int) 91 field_opts_on (FIELD * field, Field_Options opts) 92 { 93 int res = E_BAD_ARGUMENT; 94 95 opts &= ALL_FIELD_OPTS; 96 if (!(opts & ~ALL_FIELD_OPTS)) 97 { 98 Normalize_Field( field ); 99 res = _nc_Synchronize_Options( field, field->opts | opts ); 100 } 101 RETURN(res); 102 } 103 104 /*--------------------------------------------------------------------------- 105 | Facility : libnform 106 | Function : int field_opts_off(FIELD *field, Field_Options opts) 107 | 108 | Description : Turns off the named options for this field and all the 109 | remaining options are unchanged. 110 | 111 | Return Values : E_OK - success 112 | E_CURRENT - the field is the current field 113 | E_BAD_ARGUMENT - invalid options 114 | E_SYSTEM_ERROR - system error 115 +--------------------------------------------------------------------------*/ 116 NCURSES_EXPORT(int) 117 field_opts_off (FIELD * field, Field_Options opts) 118 { 119 int res = E_BAD_ARGUMENT; 120 121 opts &= ALL_FIELD_OPTS; 122 if (!(opts & ~ALL_FIELD_OPTS)) 123 { 124 Normalize_Field( field ); 125 res = _nc_Synchronize_Options( field, field->opts & ~opts ); 126 } 127 RETURN(res); 128 } 129 130 /* fld_opts.c ends here */ 131