CTWM
Loading...
Searching...
No Matches
/usr/src/RPM/BUILD/ctwm-4.1.0/event_names.c
Go to the documentation of this file.
1/*
2 * Utils for translating X events between their names and numbers
3 */
4
5#include "ctwm.h"
6
7#include <stddef.h>
8#include <strings.h>
9
10#include "event_names.h"
11
12/* num->name lookup table (generated build-time) */
13#include "event_names_table.h"
14
15
16
17/* Need this for any iteration */
18size_t
20{
21 return(sizeof(event_names) / sizeof(*event_names));
22}
23
24
25/* Return the name for any event number */
26const char *
28{
29 /* Bounds */
31 return NULL;
32 }
33
34 /* Else it's whatever is[n't] there */
35 return event_names[evt];
36}
37
38
39/*
40 * Find the number for a name. Technically, the index of the array is a
41 * size_t. We'd need a ssize_t to allow -1 to mean "not found". But the
42 * numbers in the X definition are ints, so that's what we'll return.
43 */
44int
46{
47 int i;
48
49 if(ename == NULL) {
50 return -1;
51 }
52
53 for(i = 0 ; i < event_names_size() ; i++) {
54 if(event_names[i] != NULL && strcasecmp(ename, event_names[i]) == 0) {
55 return i;
56 }
57 }
58
59 /* Not found */
60 return -1;
61}
static int PlaceX
Definition add_window.c:82
const char * event_name_by_num(int evt)
Definition event_names.c:27
size_t event_names_size(void)
Definition event_names.c:19
int event_num_by_name(const char *ename)
Definition event_names.c:45