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