--- /dev/null
+/* Gateway kernel
+ * Europagate, 1995
+ *
+ * $Log: gip.c,v $
+ * Revision 1.1 1995/03/27 08:24:58 adam
+ * New module gip: Gateway IPc module.
+ * New module gw-db: Gateway hash-db module (user information table).
+ *
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+
+#include <gip.h>
+
+GIP gip_initialize (const char *name)
+{
+ GIP gip = malloc (sizeof(*gip));
+
+ if (!gip)
+ return NULL;
+ if (!(gip->name = malloc (strlen(name)+1)))
+ {
+ free (gip);
+ return NULL;
+ }
+ strcpy (gip->name, name);
+ gip->ret = mknod (gip->name, S_IFIFO|0666, 0);
+ gip->errno = errno;
+ return gip;
+}
+
+int gip_destroy (GIP gip)
+{
+ assert (gip);
+
+ free (gip->name);
+ free (gip);
+ return 0;
+}
+
+int gip_infileno (GIP gip)
+{
+ return gip->rfd;
+}
+
+int gip_errno (GIP gip)
+{
+ return gip->errno;
+}
+
+int gip_read (GIP gip, char *buf, size_t count)
+{
+ int r, no = 0;
+ while (no < count)
+ {
+ r = read (gip->rfd, buf+no, count-no);
+ if (r == -1)
+ {
+ gip->errno = errno;
+ return -1;
+ }
+ no += r;
+ }
+ return 0;
+}
+
+int gip_write (GIP gip, const char *buf, size_t count)
+{
+ int r, no = 0;
+ while (no < count)
+ {
+ r = write (gip->wfd, buf+no, count-no);
+ if (r == -1)
+ {
+ gip->errno = errno;
+ return -1;
+ }
+ no += r;
+ }
+ return 0;
+}
+
+int gip_wline (GIP gip, const char *buf)
+{
+ return gip_write (gip, buf, strlen(buf));
+}
+