-
Notifications
You must be signed in to change notification settings - Fork 1
/
signumber.c
92 lines (73 loc) · 1.54 KB
/
signumber.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
/*********************************************************************
*** signumber.c
*** Copyright (c) 2001,2003,2005-2009 by Markus Winand <mws@fatalmind.com>
*** $Id$
********************************************************************/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <strings.h>
#include "hatimerun.h"
#ifndef HAVE_SYS_SIGNAME
#ifdef HATOOLS_SYS_SIGNAME_H
#include "sys_signame.h"
#else
#include "sys_signame_posix.h"
#endif
int signumber(const char *signame) {
int signum = 0;
int i = 0;
if (! strncasecmp(signame, "SIG", 3)) {
signame += 3;
}
while (signum == 0 && sys_signame2[i] != NULL) {
if (! strcasecmp(signame, sys_signame2[i])) {
signum = sys_signumber2[i];
}
i++;
}
return signum;
}
void siglist() {
int i;
for (i = 0; sys_signame2[i] != NULL; i++) {
fprintf(stderr, "SIG%s\n", sys_signame2[i]);
}
exit (FAIL_EXITCODE[0]);
}
#else
#include <signal.h>
#include <ctype.h>
int signumber(const char *signame) {
int i;
int signum = 0;
if (! strncasecmp(signame, "SIG", 3)) {
signame += 3;
}
for (i = 0; (i < NSIG) && (signum == 0); i++) {
if (! strcasecmp(signame, sys_signame[i])) {
signum = i;
}
}
return signum;
}
void sig_printUC(const char *signame) {
int i = 0;
fprintf(stderr, "SIG");
while (signame[i] != 0) {
fputc(toupper(signame[i]), stderr);
i++;
}
fputc('\n', stderr);
}
void siglist() {
int i;
for (i = 0; i < NSIG; i++) {
sig_printUC(sys_signame[i]);
}
exit (FAIL_EXITCODE[0]);
};
#endif