2 * This file is part of DisOrder.
3 * Copyright (C) 2004, 2005, 2007, 2008 Richard Kettlewell
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
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.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
22 /* various error-handling wrappers. Not actually all system calls! */
28 #include <sys/socket.h>
32 void xclose_guts(const char *, int, int);
33 #define xclose(fd) xclose_guts(__FILE__, __LINE__, fd)
36 int xfcntl(int, int, long);
37 void xlisten(int, int);
38 void xshutdown(int, int);
39 void xsetsockopt(int, int, int, const void *, socklen_t
);
40 int xsocket(int, int, int);
41 void xconnect(int, const struct sockaddr
*, socklen_t
);
42 void xsigprocmask(int how
, const sigset_t
*set
, sigset_t
*oldset
);
43 void xsigaction(int sig
, const struct sigaction
*sa
, struct sigaction
*oldsa
);
44 int xprintf(const char *, ...)
45 attribute((format (printf
, 1, 2)));
48 void xgettimeofday(struct timeval
*, struct timezone
*);
49 /* the above all call @fatal@ if the system call fails */
51 void nonblock(int fd
);
52 void blocking(int fd
);
54 /* make @fd@ non-blocking/blocking/close-on-exec; call @fatal@ on error. */
56 int mustnotbeminus1(const char *what
, int value
);
57 /* If @value@ is -1, report an error including @what@. */
59 int xstrtol(long *n
, const char *s
, char **ep
, int base
);
60 int xstrtoll(long_long
*n
, const char *s
, char **ep
, int base
);
61 /* like strtol() but returns errno on error, 0 on success */
63 #endif /* SYSCALLS_H */