Commit | Line | Data |
---|---|---|
460b9539 | 1 | /* |
2 | * This file is part of DisOrder. | |
5db8461a | 3 | * Copyright (C) 2004, 2005, 2007-2009, 2013 Richard Kettlewell |
460b9539 | 4 | * |
e7eb3a27 | 5 | * This program is free software: you can redistribute it and/or modify |
460b9539 | 6 | * it under the terms of the GNU General Public License as published by |
e7eb3a27 | 7 | * the Free Software Foundation, either version 3 of the License, or |
460b9539 | 8 | * (at your option) any later version. |
e7eb3a27 RK |
9 | * |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
460b9539 | 15 | * You should have received a copy of the GNU General Public License |
e7eb3a27 | 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
460b9539 | 17 | */ |
132a5a4a RK |
18 | /** @file lib/syscalls.h |
19 | * @brief Error-checking library call wrappers | |
20 | */ | |
460b9539 | 21 | #ifndef SYSCALLS_H |
22 | #define SYSCALLS_H | |
23 | ||
24 | /* various error-handling wrappers. Not actually all system calls! */ | |
25 | ||
26 | struct sockaddr; | |
27 | struct sigaction; | |
28 | struct timezone; | |
29 | ||
cca89d7c RK |
30 | #if HAVE_SYS_SOCKET_H |
31 | # include <sys/socket.h> | |
32 | #endif | |
460b9539 | 33 | #include <signal.h> |
460b9539 | 34 | |
9e42afcd | 35 | #if !_WIN32 |
460b9539 | 36 | pid_t xfork(void); |
8bb67afe RK |
37 | void xclose_guts(const char *, int, int); |
38 | #define xclose(fd) xclose_guts(__FILE__, __LINE__, fd) | |
460b9539 | 39 | void xdup2(int, int); |
40 | void xpipe(int *); | |
41 | int xfcntl(int, int, long); | |
460b9539 | 42 | void xsigprocmask(int how, const sigset_t *set, sigset_t *oldset); |
43 | void xsigaction(int sig, const struct sigaction *sa, struct sigaction *oldsa); | |
9e42afcd RK |
44 | int xnice(int); |
45 | void xgettime(clockid_t clk_id, struct timespec *tp); | |
46 | void xnanosleep(const struct timespec *req, struct timespec *rem); | |
47 | #endif | |
48 | void xlisten(SOCKET, int); | |
49 | void xshutdown(SOCKET, int); | |
50 | void xsetsockopt(SOCKET, int, int, const void *, socklen_t); | |
51 | SOCKET xsocket(int, int, int); | |
52 | void xconnect(SOCKET, const struct sockaddr *, socklen_t); | |
460b9539 | 53 | int xprintf(const char *, ...) |
54 | attribute((format (printf, 1, 2))); | |
55 | void xfclose(FILE *); | |
460b9539 | 56 | void xgettimeofday(struct timeval *, struct timezone *); |
4265e5d3 | 57 | time_t xtime(time_t *when); |
460b9539 | 58 | /* the above all call @fatal@ if the system call fails */ |
59 | ||
60 | void nonblock(int fd); | |
937be4c0 | 61 | void blocking(int fd); |
460b9539 | 62 | void cloexec(int fd); |
937be4c0 | 63 | /* make @fd@ non-blocking/blocking/close-on-exec; call @fatal@ on error. */ |
460b9539 | 64 | |
65 | int mustnotbeminus1(const char *what, int value); | |
66 | /* If @value@ is -1, report an error including @what@. */ | |
67 | ||
68 | int xstrtol(long *n, const char *s, char **ep, int base); | |
69 | int xstrtoll(long_long *n, const char *s, char **ep, int base); | |
70 | /* like strtol() but returns errno on error, 0 on success */ | |
71 | ||
72 | #endif /* SYSCALLS_H */ | |
73 | ||
74 | /* | |
75 | Local Variables: | |
76 | c-basic-offset:2 | |
77 | comment-column:40 | |
78 | End: | |
79 | */ |