]> git.cworth.org Git - ttt/blob - src/x.h
Add a dependency of ttt-client.c on ttt-lex.h to fix the build.
[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 xfopen (const char *path, const char *mode);
50
51 FILE *
52 xfdopen (int filedes, const char *mode);
53
54 void
55 xdup2 (int oldfd, int newfd);
56
57 char *
58 xstrdup (const char *s);
59
60 void
61 xfwrite (const void *ptr, size_t size, size_t nmemb, FILE *stream);
62
63 int
64 xsocket (int domain, int type, int protocol);
65
66 void
67 xbind (int sockfd, const struct sockaddr *my_addr, socklen_t addrlen);
68
69 ttt_status_t
70 xconnect (int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen);
71
72 void
73 xlisten (int s, int backlog);
74
75 int
76 xfcntl (int fd, int cmd, long arg);
77
78 int
79 xselect (int             n,
80          fd_set         *readfds,
81          fd_set         *writefds,
82          fd_set         *exceptfds,
83          struct timeval *timeout);
84
85 ssize_t
86 xread (int fd, void *buf, size_t count);
87
88 ssize_t
89 xwrite (int fd, const void *buf, size_t count);
90
91 #endif /* _X_H_ */