-
Notifications
You must be signed in to change notification settings - Fork 0
/
signal.c
56 lines (48 loc) · 980 Bytes
/
signal.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// -*- coding: utf-8 -*-
#include "signal.h"
#include <string.h>
bool verify_signal_pattern(const char *signal_pattern)
{
return true;
}
bool sigcmp(const char *signal_pattern, const char *signal)
{
if( signal_pattern[0] == '!' )
return (! sigcmp(signal_pattern+1, signal));
bool found;
const char *p=signal_pattern;
while(1){
found = false;
const char *s;
for(s=signal; *p && *s ; p++,s++){
char ptn = *p;
if( ptn == ',' ){
found = true;
break;
}
else if( ptn == '.' ){
break;
}
else if( ptn != '*' && ptn != *s ){
break;
}
}
if( found ){
break;
}else if( *p == '.'){
if( *s == '\0'){
found = true;
break;
}
}else if( *p == '\0' ){
found = true;
break;
}
const char *p_delim = strchr(p,',');
if( p_delim )
p = p_delim + 1;
else
break;
}
return found;
}