]> git.cworth.org Git - ttt/blob - src/x.h
58f1297e864ec80e25170b8d57d0b7a902725f20
[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 #include "ttt.h"
26
27 void
28 xasprintf (char **strp, const char *fmt, ...) TTT_PRINTF_FORMAT(2, 3);
29
30 void
31 xvasprintf (char **strp, const char *fmt, va_list ap);
32
33 void
34 xpipe (int filedes[2]);
35
36 pid_t
37 xfork (void);
38
39 void *
40 xmalloc (size_t size);
41
42 void *
43 xcalloc (size_t nmemb, size_t size);
44
45 void *
46 xrealloc (void *ptr, size_t size);
47
48 FILE *
49 xfdopen (int filedes, const char *mode);
50
51 FILE *
52 xfreopen (const char *path, const char *mode, FILE *stream);
53
54 char *
55 xstrdup (const char *s);
56
57 void
58 xfwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream);
59
60 int
61 xsocket (int domain, int type, int protocol);
62
63 void
64 xbind (int sockfd, const struct sockaddr *my_addr, socklen_t addrlen);
65
66 void
67 xlisten (int s, int backlog);
68
69 int
70 xfcntl (int fd, int cmd, long arg);
71
72 int
73 xselect (int             n,
74          fd_set         *readfds,
75          fd_set         *writefds,
76          fd_set         *exceptfds,
77          struct timeval *timeout);
78
79 #endif /* _X_H_ */