chiark / gitweb /
Switch to GPL v3
[disorder] / lib / syscalls.h
CommitLineData
460b9539 1/*
2 * This file is part of DisOrder.
5aff007d 3 * Copyright (C) 2004, 2005, 2007, 2008 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 */
18
19#ifndef SYSCALLS_H
20#define SYSCALLS_H
21
22/* various error-handling wrappers. Not actually all system calls! */
23
24struct sockaddr;
25struct sigaction;
26struct timezone;
27
28#include <sys/socket.h>
29#include <signal.h>
460b9539 30
31pid_t xfork(void);
8bb67afe
RK
32void xclose_guts(const char *, int, int);
33#define xclose(fd) xclose_guts(__FILE__, __LINE__, fd)
460b9539 34void xdup2(int, int);
35void xpipe(int *);
36int xfcntl(int, int, long);
37void xlisten(int, int);
38void xshutdown(int, int);
39void xsetsockopt(int, int, int, const void *, socklen_t);
40int xsocket(int, int, int);
41void xconnect(int, const struct sockaddr *, socklen_t);
42void xsigprocmask(int how, const sigset_t *set, sigset_t *oldset);
43void xsigaction(int sig, const struct sigaction *sa, struct sigaction *oldsa);
44int xprintf(const char *, ...)
45 attribute((format (printf, 1, 2)));
46void xfclose(FILE *);
47int xnice(int);
48void xgettimeofday(struct timeval *, struct timezone *);
49/* the above all call @fatal@ if the system call fails */
50
51void nonblock(int fd);
937be4c0 52void blocking(int fd);
460b9539 53void cloexec(int fd);
937be4c0 54/* make @fd@ non-blocking/blocking/close-on-exec; call @fatal@ on error. */
460b9539 55
56int mustnotbeminus1(const char *what, int value);
57/* If @value@ is -1, report an error including @what@. */
58
59int xstrtol(long *n, const char *s, char **ep, int base);
60int xstrtoll(long_long *n, const char *s, char **ep, int base);
61/* like strtol() but returns errno on error, 0 on success */
62
63#endif /* SYSCALLS_H */
64
65/*
66Local Variables:
67c-basic-offset:2
68comment-column:40
69End:
70*/