fld_opts.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /****************************************************************************
  2. * Copyright (c) 1998 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. * Author: Juergen Pfeifer <juergen.pfeifer@gmx.net> 1995,1997 *
  30. ****************************************************************************/
  31. #include "form.priv.h"
  32. MODULE_ID("$Id$")
  33. /*----------------------------------------------------------------------------
  34. Field-Options manipulation routines
  35. --------------------------------------------------------------------------*/
  36. /*---------------------------------------------------------------------------
  37. | Facility : libnform
  38. | Function : int set_field_opts(FIELD *field, Field_Options opts)
  39. |
  40. | Description : Turns on the named options for this field and turns
  41. | off all the remaining options.
  42. |
  43. | Return Values : E_OK - success
  44. | E_CURRENT - the field is the current field
  45. | E_BAD_ARGUMENT - invalid options
  46. | E_SYSTEM_ERROR - system error
  47. +--------------------------------------------------------------------------*/
  48. int set_field_opts(FIELD * field, Field_Options opts)
  49. {
  50. int res = E_BAD_ARGUMENT;
  51. opts &= ALL_FIELD_OPTS;
  52. if (!(opts & ~ALL_FIELD_OPTS))
  53. res = _nc_Synchronize_Options( Normalize_Field(field), opts );
  54. RETURN(res);
  55. }
  56. /*---------------------------------------------------------------------------
  57. | Facility : libnform
  58. | Function : Field_Options field_opts(const FIELD *field)
  59. |
  60. | Description : Retrieve the fields options.
  61. |
  62. | Return Values : The options.
  63. +--------------------------------------------------------------------------*/
  64. Field_Options field_opts(const FIELD * field)
  65. {
  66. return ALL_FIELD_OPTS & Normalize_Field( field )->opts;
  67. }
  68. /*---------------------------------------------------------------------------
  69. | Facility : libnform
  70. | Function : int field_opts_on(FIELD *field, Field_Options opts)
  71. |
  72. | Description : Turns on the named options for this field and all the
  73. | remaining options are unchanged.
  74. |
  75. | Return Values : E_OK - success
  76. | E_CURRENT - the field is the current field
  77. | E_BAD_ARGUMENT - invalid options
  78. | E_SYSTEM_ERROR - system error
  79. +--------------------------------------------------------------------------*/
  80. int field_opts_on(FIELD * field, Field_Options opts)
  81. {
  82. int res = E_BAD_ARGUMENT;
  83. opts &= ALL_FIELD_OPTS;
  84. if (!(opts & ~ALL_FIELD_OPTS))
  85. {
  86. Normalize_Field( field );
  87. res = _nc_Synchronize_Options( field, field->opts | opts );
  88. }
  89. RETURN(res);
  90. }
  91. /*---------------------------------------------------------------------------
  92. | Facility : libnform
  93. | Function : int field_opts_off(FIELD *field, Field_Options opts)
  94. |
  95. | Description : Turns off the named options for this field and all the
  96. | remaining options are unchanged.
  97. |
  98. | Return Values : E_OK - success
  99. | E_CURRENT - the field is the current field
  100. | E_BAD_ARGUMENT - invalid options
  101. | E_SYSTEM_ERROR - system error
  102. +--------------------------------------------------------------------------*/
  103. int field_opts_off(FIELD * field, Field_Options opts)
  104. {
  105. int res = E_BAD_ARGUMENT;
  106. opts &= ALL_FIELD_OPTS;
  107. if (!(opts & ~ALL_FIELD_OPTS))
  108. {
  109. Normalize_Field( field );
  110. res = _nc_Synchronize_Options( field, field->opts & ~opts );
  111. }
  112. RETURN(res);
  113. }
  114. /* fld_opts.c ends here */