Basic Comm Interface Stuff (pipes)
authorPhilipp Dunkel <Philipp Dunkel@d4452222-2f33-11de-9270-010000000000>
Fri, 24 Apr 2009 18:04:33 +0000 (18:04 +0000)
committerPhilipp Dunkel <Philipp Dunkel@d4452222-2f33-11de-9270-010000000000>
Fri, 24 Apr 2009 18:04:33 +0000 (18:04 +0000)
git-svn-id: http://svn.cacert.cl/Software/BirdShack@16 d4452222-2f33-11de-9270-010000000000

TailFeather/trunk/src/Makefile [new file with mode: 0644]
TailFeather/trunk/src/comm/pipe.c [new file with mode: 0644]
TailFeather/trunk/src/comm/pipe.h [new file with mode: 0644]

diff --git a/TailFeather/trunk/src/Makefile b/TailFeather/trunk/src/Makefile
new file mode 100644 (file)
index 0000000..e0cbc3f
--- /dev/null
@@ -0,0 +1,7 @@
+AR=ar
+
+comm.a : comm.o comm/pipe.o
+       $(AR) r comm.a comm.o comm/pipe.o
+
+clean : 
+       rm -f *.o comm/*.o
diff --git a/TailFeather/trunk/src/comm/pipe.c b/TailFeather/trunk/src/comm/pipe.c
new file mode 100644 (file)
index 0000000..d73df31
--- /dev/null
@@ -0,0 +1,56 @@
+/* 
+ For copyright information see copyright.txt of the project 
+ Author: Philipp Dunkel
+*/
+
+#include "pipe.h"
+#include "../comm.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <fcntl.h>
+
+struct pipe_handles {
+       int readhandle;
+       int writehandle;
+};
+
+int pipe_open(struct comm_interface *interface) {
+       return 0;
+}
+int pipe_close(struct comm_interface *interface) {
+       return 0;
+}
+int pipe_read(struct comm_interface *interface, char *data, int length) {
+       return 0;
+}
+int pipe_write(struct comm_interface *interface, const char *data, const int length) {
+       return 0;
+}
+
+struct comm_interface *pipe_create_comm_interface(const char *readpipe, const char *writepipe) {
+       struct pipe_handles *handles = (struct pipe_handles *)malloc(sizeof(struct pipe_handles));
+       if (NULL == handles) {
+               return NULL;
+       }
+       handles->readhandle = open(readpipe, O_RDONLY);
+       if (handles->readhandle < 0) {
+               free(handles);
+               return NULL;
+       }
+       handles->writehandle = open(readpipe, O_WRONLY);
+       if (handles->writehandle < 0) {
+               close(handles->readhandle);
+               free(handles);
+               return NULL;
+       }
+       struct comm_interface *interface = (struct comm_interface *)malloc(sizeof(struct comm_interface));
+       if (NULL == interface) {
+               return NULL;
+       }
+       interface->data = handles;
+       interface->open = pipe_open;
+       interface->close = pipe_close;
+       interface->read = pipe_read; 
+       interface->write = pipe_write;
+}
diff --git a/TailFeather/trunk/src/comm/pipe.h b/TailFeather/trunk/src/comm/pipe.h
new file mode 100644 (file)
index 0000000..1574ef3
--- /dev/null
@@ -0,0 +1,13 @@
+/* 
+ For copyright information see copyright.txt of the project 
+ Author: Philipp Dunkel
+*/
+
+#ifndef pipe_h
+#define pipe_h
+
+#include "../comm.h"
+
+struct comm_interface *pipe_create_comm_interface(const char *readpipe, const char *writepipe);
+
+#endif