mf_common.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. /****************************************************************************
  2. * Copyright (c) 1998-2003,2004 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, 1995,1997 *
  30. ****************************************************************************/
  31. /* $Id: mf_common.h,v 0.22 2005/11/26 15:26:52 tom Exp $ */
  32. /* Common internal header for menu and form library */
  33. #ifndef MF_COMMON_H_incl
  34. #define MF_COMMON_H_incl 1
  35. #include <ncurses_cfg.h>
  36. #include <curses.h>
  37. #include <stdlib.h>
  38. #include <sys/types.h>
  39. #include <assert.h>
  40. #include <string.h>
  41. #include <ctype.h>
  42. #include <errno.h>
  43. #if DECL_ERRNO
  44. extern int errno;
  45. #endif
  46. /* in case of debug version we ignore the suppression of assertions */
  47. #ifdef TRACE
  48. # ifdef NDEBUG
  49. # undef NDEBUG
  50. # endif
  51. #endif
  52. #include <nc_alloc.h>
  53. #if USE_RCS_IDS
  54. #define MODULE_ID(id) static const char Ident[] = id;
  55. #else
  56. #define MODULE_ID(id) /*nothing*/
  57. #endif
  58. /* Maximum regular 8-bit character code */
  59. #define MAX_REGULAR_CHARACTER (0xff)
  60. #define SET_ERROR(code) (errno=(code))
  61. #define GET_ERROR() (errno)
  62. #ifdef TRACE
  63. #define RETURN(code) returnCode( SET_ERROR(code) )
  64. #else
  65. #define RETURN(code) return( SET_ERROR(code) )
  66. #endif
  67. /* The few common values in the status fields for menus and forms */
  68. #define _POSTED (0x01U) /* menu or form is posted */
  69. #define _IN_DRIVER (0x02U) /* menu or form is processing hook routine */
  70. /* Call object hook */
  71. #define Call_Hook( object, handler ) \
  72. if ( (object) != 0 && ((object)->handler) != (void *) 0 )\
  73. {\
  74. (object)->status |= _IN_DRIVER;\
  75. (object)->handler(object);\
  76. (object)->status &= ~_IN_DRIVER;\
  77. }
  78. #endif /* MF_COMMON_H_incl */