1 /* $OpenBSD: mf_common.h,v 1.8 2023/10/17 09:52:10 nicm Exp $ */ 2 3 /**************************************************************************** 4 * Copyright 2020 Thomas E. Dickey * 5 * Copyright 1998-2005,2012 Free Software Foundation, Inc. * 6 * * 7 * Permission is hereby granted, free of charge, to any person obtaining a * 8 * copy of this software and associated documentation files (the * 9 * "Software"), to deal in the Software without restriction, including * 10 * without limitation the rights to use, copy, modify, merge, publish, * 11 * distribute, distribute with modifications, sublicense, and/or sell * 12 * copies of the Software, and to permit persons to whom the Software is * 13 * furnished to do so, subject to the following conditions: * 14 * * 15 * The above copyright notice and this permission notice shall be included * 16 * in all copies or substantial portions of the Software. * 17 * * 18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * 19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * 20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * 21 * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, * 22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR * 23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR * 24 * THE USE OR OTHER DEALINGS IN THE SOFTWARE. * 25 * * 26 * Except as contained in this notice, the name(s) of the above copyright * 27 * holders shall not be used in advertising or otherwise to promote the * 28 * sale, use or other dealings in this Software without prior written * 29 * authorization. * 30 ****************************************************************************/ 31 32 /**************************************************************************** 33 * Author: Juergen Pfeifer, 1995,1997 * 34 ****************************************************************************/ 35 36 /* $Id: mf_common.h,v 1.8 2023/10/17 09:52:10 nicm Exp $ */ 37 38 /* Common internal header for menu and form library */ 39 40 #ifndef MF_COMMON_H_incl 41 #define MF_COMMON_H_incl 1 42 43 #include <ncurses_cfg.h> 44 #include <curses.h> 45 46 #include <stdlib.h> 47 #include <sys/types.h> 48 #include <assert.h> 49 #include <string.h> 50 #include <ctype.h> 51 #include <errno.h> 52 53 #if DECL_ERRNO 54 extern int errno; 55 #endif 56 57 /* in case of debug version we ignore the suppression of assertions */ 58 #ifdef TRACE 59 # ifdef NDEBUG 60 # undef NDEBUG 61 # endif 62 #endif 63 64 #include <nc_alloc.h> 65 66 #if USE_RCS_IDS 67 #define MODULE_ID(id) static const char Ident[] = id; 68 #else 69 #define MODULE_ID(id) /*nothing */ 70 #endif 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 #define SetStatus(target,mask) (target)->status |= (unsigned short) (mask) 89 #define ClrStatus(target,mask) (target)->status = (unsigned short) (target->status & (~mask)) 90 91 /* Call object hook */ 92 #define Call_Hook( object, handler ) \ 93 if ( (object) != 0 && ((object)->handler) != (void *) 0 )\ 94 {\ 95 SetStatus(object, _IN_DRIVER);\ 96 (object)->handler(object);\ 97 ClrStatus(object, _IN_DRIVER);\ 98 } 99 100 #endif /* MF_COMMON_H_incl */ 101