forked from wertarbyte/triggerhappy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ignore.c
41 lines (37 loc) · 824 Bytes
/
ignore.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* Copyright 2010 Stefan Tomanek <[email protected]>
* You have permission to copy, modify, and redistribute under the
* terms of the GPLv3 or any later version.
* For full license terms, see COPYING.
*/
#include <stdio.h>
#include <stdlib.h>
#include "ignore.h"
void ignore_key( int code, ignore **list ) {
ignore **p = list;
while ( *p != NULL ) {
p = &( (*p)->next );
}
*p = malloc( sizeof(ignore) );
if (*p) {
(*p)->next = NULL;
(*p)->code = code;
} else {
fprintf(stderr, "Unable to allocate memory for ignored key!\n");
}
}
void print_ignores( ignore *list ) {
ignore *p = list;
while ( p != NULL ) {
p = p->next;
}
}
int is_ignored( int code, ignore *list ) {
ignore *p = list;
while ( p != NULL ) {
if (p->code == code) {
return 1;
}
p = p->next;
}
return 0;
}