fld_opts.c revision 76726
1/**************************************************************************** 2 * Copyright (c) 1998,2000 Free Software Foundation, Inc. * 3 * * 4 * Permission is hereby granted, free of charge, to any person obtaining a * 5 * copy of this software and associated documentation files (the * 6 * "Software"), to deal in the Software without restriction, including * 7 * without limitation the rights to use, copy, modify, merge, publish, * 8 * distribute, distribute with modifications, sublicense, and/or sell * 9 * copies of the Software, and to permit persons to whom the Software is * 10 * furnished to do so, subject to the following conditions: * 11 * * 12 * The above copyright notice and this permission notice shall be included * 13 * in all copies or substantial portions of the Software. * 14 * * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 18 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 21 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 22 * * 23 * Except as contained in this notice, the name(s) of the above copyright * 24 * holders shall not be used in advertising or otherwise to promote the * 25 * sale, use or other dealings in this Software without prior written * 26 * authorization. * 27 ****************************************************************************/ 28 29/**************************************************************************** 30 * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 * 31 ****************************************************************************/ 32#include "form.priv.h" 33 34MODULE_ID("$Id: fld_opts.c,v 1.7 2000/12/10 02:09:38 tom Exp $") 35 36/*---------------------------------------------------------------------------- 37 Field-Options manipulation routines 38 --------------------------------------------------------------------------*/ 39 40/*--------------------------------------------------------------------------- 41| Facility : libnform 42| Function : int set_field_opts(FIELD *field, Field_Options opts) 43| 44| Description : Turns on the named options for this field and turns 45| off all the remaining options. 46| 47| Return Values : E_OK - success 48| E_CURRENT - the field is the current field 49| E_BAD_ARGUMENT - invalid options 50| E_SYSTEM_ERROR - system error 51+--------------------------------------------------------------------------*/ 52NCURSES_EXPORT(int) 53set_field_opts (FIELD * field, Field_Options opts) 54{ 55 int res = E_BAD_ARGUMENT; 56 opts &= ALL_FIELD_OPTS; 57 if (!(opts & ~ALL_FIELD_OPTS)) 58 res = _nc_Synchronize_Options( Normalize_Field(field), opts ); 59 RETURN(res); 60} 61 62/*--------------------------------------------------------------------------- 63| Facility : libnform 64| Function : Field_Options field_opts(const FIELD *field) 65| 66| Description : Retrieve the fields options. 67| 68| Return Values : The options. 69+--------------------------------------------------------------------------*/ 70NCURSES_EXPORT(Field_Options) 71field_opts (const FIELD * field) 72{ 73 return ALL_FIELD_OPTS & Normalize_Field( field )->opts; 74} 75 76/*--------------------------------------------------------------------------- 77| Facility : libnform 78| Function : int field_opts_on(FIELD *field, Field_Options opts) 79| 80| Description : Turns on the named options for this field and all the 81| remaining options are unchanged. 82| 83| Return Values : E_OK - success 84| E_CURRENT - the field is the current field 85| E_BAD_ARGUMENT - invalid options 86| E_SYSTEM_ERROR - system error 87+--------------------------------------------------------------------------*/ 88NCURSES_EXPORT(int) 89field_opts_on (FIELD * field, Field_Options opts) 90{ 91 int res = E_BAD_ARGUMENT; 92 93 opts &= ALL_FIELD_OPTS; 94 if (!(opts & ~ALL_FIELD_OPTS)) 95 { 96 Normalize_Field( field ); 97 res = _nc_Synchronize_Options( field, field->opts | opts ); 98 } 99 RETURN(res); 100} 101 102/*--------------------------------------------------------------------------- 103| Facility : libnform 104| Function : int field_opts_off(FIELD *field, Field_Options opts) 105| 106| Description : Turns off the named options for this field and all the 107| remaining options are unchanged. 108| 109| Return Values : E_OK - success 110| E_CURRENT - the field is the current field 111| E_BAD_ARGUMENT - invalid options 112| E_SYSTEM_ERROR - system error 113+--------------------------------------------------------------------------*/ 114NCURSES_EXPORT(int) 115field_opts_off (FIELD * field, Field_Options opts) 116{ 117 int res = E_BAD_ARGUMENT; 118 119 opts &= ALL_FIELD_OPTS; 120 if (!(opts & ~ALL_FIELD_OPTS)) 121 { 122 Normalize_Field( field ); 123 res = _nc_Synchronize_Options( field, field->opts & ~opts ); 124 } 125 RETURN(res); 126} 127 128/* fld_opts.c ends here */ 129