]> git.cworth.org Git - ttt/blobdiff - src/x.c
* PROTOCOL: Removed unused servername
[ttt] / src / x.c
diff --git a/src/x.c b/src/x.c
index 3e46abdd03fb0c388c60d5494cce359cdcaf2cc6..dc5c1dd38e807ee300f9a1d77cc1ef187ef79f7d 100644 (file)
--- a/src/x.c
+++ b/src/x.c
@@ -19,9 +19,7 @@
  * Author: Carl Worth <carl@theworths.org>
  */
 
  * Author: Carl Worth <carl@theworths.org>
  */
 
-#include "ttt.h"
-
-#include <stdarg.h>
+#include "x.h"
 
 void
 xasprintf (char **strp, const char *fmt, ...)
 
 void
 xasprintf (char **strp, const char *fmt, ...)
@@ -135,7 +133,7 @@ xfdopen (int filedes, const char *mode)
     return ret;
 }
 
     return ret;
 }
 
-FILE *
+void
 xfreopen (const char *path, const char *mode, FILE *stream)
 {
     FILE *ret;
 xfreopen (const char *path, const char *mode, FILE *stream)
 {
     FILE *ret;
@@ -146,8 +144,6 @@ xfreopen (const char *path, const char *mode, FILE *stream)
                 path, strerror (errno));
        exit (1);
     }
                 path, strerror (errno));
        exit (1);
     }
-
-    return ret;
 }
 
 char *
 }
 
 char *
@@ -155,6 +151,9 @@ xstrdup (const char *s)
 {
     char *ret;
 
 {
     char *ret;
 
+    if (s == NULL)
+       return NULL;
+
     ret = strdup (s);
 
     if (ret == NULL) {
     ret = strdup (s);
 
     if (ret == NULL) {
@@ -252,3 +251,33 @@ xselect (int                n,
 
     return ret;
 }
 
     return ret;
 }
+
+ssize_t
+xread (int fd, void *buf, size_t count)
+{
+    int ret;
+
+    ret = read (fd, buf, count);
+    if (ret == -1) {
+       fprintf (stderr, "Error: read failed: %s. Aborting.\n",
+                strerror (errno));
+       exit (1);
+    }
+
+    return ret;
+}
+
+ssize_t
+xwrite (int fd, const void *buf, size_t count)
+{
+    int ret;
+
+    ret = write (fd, buf, count);
+    if (ret == -1) {
+       fprintf (stderr, "Error: write failed: %s. Aborting.\n",
+                strerror (errno));
+       exit (1);
+    }
+
+    return ret;
+}