1 /* 2 * ============================================================================ 3 * Title: Event enumeration and related tables and helpers. 4 * Author: J. Zbiciak 5 * ============================================================================ 6 */ 7 #ifndef EVENT_TBL_H_ 8 #define EVENT_TBL_H_ 9 10 /* ======================================================================== */ 11 /* EVENT_NUM_T -- An enumeration of all of the event numbers supported. */ 12 /* */ 13 /* These event numbers are internal to jzIntv. Any platform-specific */ 14 /* code must map its event numbers to this enumeration before calling */ 15 /* into the event core. */ 16 /* ======================================================================== */ 17 typedef enum 18 { 19 /* -------------------------------------------------------------------- */ 20 /* Report errors with EVENT_BAD, the only negative event number. */ 21 /* -------------------------------------------------------------------- */ 22 EVENT_BAD = -1, 23 24 #define EVT_DECL(name, event) event, 25 #define EVT_DECL_A(name, event) /* empty */ 26 #include "event/event_tbl.inc" 27 #undef EVT_DECL_A 28 #undef EVT_DECL 29 30 /* -------------------------------------------------------------------- */ 31 /* The total number of valid event numbers. All valid event numbers */ 32 /* are below this value. */ 33 /* -------------------------------------------------------------------- */ 34 EVENT_COUNT, 35 36 /* -------------------------------------------------------------------- */ 37 /* And if we just want to ignore an event, we set it to this. */ 38 /* -------------------------------------------------------------------- */ 39 EVENT_IGNORE 40 } event_num_t; 41 42 /* ======================================================================== */ 43 /* EVENT_NAME_TO_NUM -- Convert an event name to an event_num_t. */ 44 /* */ 45 /* For now, a slow linear search. Do not place this in a critical path. */ 46 /* Returns EVENT_BAD if not found. EVENT_BAD is the only negative event. */ 47 /* ======================================================================== */ 48 int event_name_to_num(const char *const event_name); 49 50 /* ======================================================================== */ 51 /* EVENT_NUM_TO_NAME -- Convert an event number to a name, or NULL. */ 52 /* ======================================================================== */ 53 const char *event_num_to_name(const event_num_t event_num); 54 55 /* ======================================================================== */ 56 /* EVENT_VALID -- Returns true if the event number is valid. */ 57 /* ======================================================================== */ 58 #define EVENT_VALID(ev) ((ev) >= 0 && (ev) < EVENT_COUNT) 59 60 #endif /*EVENT_TBL_H*/ 61 /* ======================================================================== */ 62 /* This program is free software; you can redistribute it and/or modify */ 63 /* it under the terms of the GNU General Public License as published by */ 64 /* the Free Software Foundation; either version 2 of the License, or */ 65 /* (at your option) any later version. */ 66 /* */ 67 /* This program is distributed in the hope that it will be useful, */ 68 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 69 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */ 70 /* General Public License for more details. */ 71 /* */ 72 /* You should have received a copy of the GNU General Public License along */ 73 /* with this program; if not, write to the Free Software Foundation, Inc., */ 74 /* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ 75 /* ======================================================================== */ 76 /* Copyright (c) 1998-2020, Joseph Zbiciak */ 77 /* ======================================================================== */ 78