]> git.cworth.org Git - ttt/blob - src/x.h
2005-11-09 Carl Worth <cworth@cworth.org>
[ttt] / src / x.h
1 /* x.c - Some wrappers for various functions to check and exit on out-of-memory
2  *
3  * Copyright © 2005 Carl Worth
4  *
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 2, or (at your option)
8  * any later version.
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  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software Foundation,
17  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18  *
19  * Author: Carl Worth <carl@theworths.org>
20  */
21
22 #ifndef _X_H_
23 #define _X_H_
24
25 void
26 xasprintf (char **strp, const char *fmt, ...) TTT_PRINTF_FORMAT(2, 3);
27
28 void
29 xvasprintf (char **strp, const char *fmt, va_list ap);
30
31 void
32 xpipe (int filedes[2]);
33
34 pid_t
35 xfork (void);
36
37 void *
38 xmalloc (size_t size);
39
40 void *
41 xcalloc (size_t nmemb, size_t size);
42
43 void *
44 xrealloc (void *ptr, size_t size);
45
46 FILE *
47 xfdopen (int filedes, const char *mode);
48
49 FILE *
50 xfreopen (const char *path, const char *mode, FILE *stream);
51
52 char *
53 xstrdup (const char *s);
54
55 void
56 xfwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream);
57
58 int
59 xsocket (int domain, int type, int protocol);
60
61 void
62 xbind (int sockfd, const struct sockaddr *my_addr, socklen_t addrlen);
63
64 void
65 xlisten (int s, int backlog);
66
67 int
68 xfcntl (int fd, int cmd, long arg);
69
70 int
71 xselect (int             n,
72          fd_set         *readfds,
73          fd_set         *writefds,
74          fd_set         *exceptfds,
75          struct timeval *timeout);
76
77 #endif /* _X_H_ */