]> ncurses.scripts.mit.edu Git - ncurses.git/blob - menu/mf_common.h
ncurses 4.1
[ncurses.git] / menu / mf_common.h
1 /*-----------------------------------------------------------------------------+
2 |           The ncurses menu library is  Copyright (C) 1995-1997               |
3 |             by Juergen Pfeifer <Juergen.Pfeifer@T-Online.de>                 |
4 |                          All Rights Reserved.                                |
5 |                                                                              |
6 | Permission to use, copy, modify, and distribute this software and its        |
7 | documentation for any purpose and without fee is hereby granted, provided    |
8 | that the above copyright notice appear in all copies and that both that      |
9 | copyright notice and this permission notice appear in supporting             |
10 | documentation, and that the name of the above listed copyright holder(s) not |
11 | be used in advertising or publicity pertaining to distribution of the        |
12 | software without specific, written prior permission.                         | 
13 |                                                                              |
14 | THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO  |
15 | THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-  |
16 | NESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR   |
17 | ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RE- |
18 | SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, |
19 | NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH    |
20 | THE USE OR PERFORMANCE OF THIS SOFTWARE.                                     |
21 +-----------------------------------------------------------------------------*/
22
23 /* Common internal header for menu and form library */
24
25 #if HAVE_CONFIG_H
26 #  include <ncurses_cfg.h>
27 #endif
28
29 #include <stdlib.h>
30 #include <sys/types.h>
31 #include <assert.h>
32 #include <string.h>
33 #include <ctype.h>
34
35 #if !HAVE_EXTERN_ERRNO
36 extern int errno;
37 #endif
38
39 #if HAVE_EXTERN_ERRNO
40 #include <errno.h>
41 #endif
42
43 /* in case of debug version we ignore the suppression of assertions */
44 #ifdef TRACE
45 #  ifdef NDEBUG
46 #    undef NDEBUG
47 #  endif
48 #endif
49
50 #include <nc_alloc.h>
51
52 #ifdef USE_RCS_IDS
53 #define MODULE_ID(id) static const char Ident[] = id;
54 #else
55 #define MODULE_ID(id) /*nothing*/
56 #endif
57
58
59 /* Maximum regular 8-bit character code */
60 #define MAX_REGULAR_CHARACTER (0xff)
61
62 #define SET_ERROR(code) (errno=(code))
63 #define RETURN(code) return( SET_ERROR(code) )
64
65 /* The few common values in the status fields for menus and forms */
66 #define _POSTED         (0x01)  /* menu or form is posted                  */
67 #define _IN_DRIVER      (0x02)  /* menu or form is processing hook routine */
68
69 /* Call object hook */
70 #define Call_Hook( object, handler ) \
71    if ( (object) && ((object)->handler) )\
72    {\
73         (object)->status |= _IN_DRIVER;\
74         (object)->handler(object);\
75         (object)->status &= ~_IN_DRIVER;\
76    }
77
78 #define INLINE
79
80 #ifndef TRACE
81 #  if CC_HAS_INLINE_FUNCS
82 #    undef INLINE
83 #    define INLINE inline
84 #  endif
85 #endif