]> git.cworth.org Git - ttt/blob - src/x.h
2005-12-02 Richard D. Worth <richard@theworths.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 #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 void
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 ttt_status_t
67 xconnect (int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen);
68
69 void
70 xlisten (int s, int backlog);
71
72 int
73 xfcntl (int fd, int cmd, long arg);
74
75 int
76 xselect (int             n,
77          fd_set         *readfds,
78          fd_set         *writefds,
79          fd_set         *exceptfds,
80          struct timeval *timeout);
81
82 ssize_t
83 xread (int fd, void *buf, size_t count);
84
85 ssize_t
86 xwrite (int fd, const void *buf, size_t count);
87
88 #endif /* _X_H_ */