From b1993a6533dbd581a875e60678a99939b2ff39d0 Mon Sep 17 00:00:00 2001
From: Anthony Minessale <anthony.minessale@gmail.com>
Date: Wed, 16 May 2007 21:59:11 +0000
Subject: [PATCH] organizw

git-svn-id: http://svn.openzap.org/svn/openzap/trunk@6 a93c3328-9c30-0410-af19-c9cd2b2d52af
---
 libs/openzap/src/openzap.c     | 30 ++++++++++++++--
 libs/openzap/src/zap_skel.c    | 62 ++++++++++++++++++++++++++++++++++
 libs/openzap/src/zap_wanpipe.c | 62 ++++++++++++++++++++++++++++++++++
 libs/openzap/src/zap_zt.c      | 62 ++++++++++++++++++++++++++++++++++
 4 files changed, 214 insertions(+), 2 deletions(-)

diff --git a/libs/openzap/src/openzap.c b/libs/openzap/src/openzap.c
index 0ac20f533a..4905f230bb 100644
--- a/libs/openzap/src/openzap.c
+++ b/libs/openzap/src/openzap.c
@@ -139,10 +139,15 @@ zap_status_t zap_channel_close(zap_channel_t **zchan)
 zap_status_t zap_channel_set_codec(zap_channel_t *zchan, zap_codec_t codec)
 {
 	assert(zchan != NULL);
+	assert(zchan->zint != NULL);
 
 	if (!zap_test_flag(zchan, ZAP_CHANNEL_OPEN)) {
 		return ZAP_FAIL;
 	}
+	
+	if (!zchan->zint->set_codec) {
+		return ZAP_FAIL;
+	}
 
 	return zchan->zint->set_codec(zchan, codec);
 	
@@ -151,24 +156,34 @@ zap_status_t zap_channel_set_codec(zap_channel_t *zchan, zap_codec_t codec)
 zap_status_t zap_channel_set_interval(zap_channel_t *zchan, unsigned ms)
 {
 	assert(zchan != NULL);
+	assert(zchan->zint != NULL);
 
     if (!zap_test_flag(zchan, ZAP_CHANNEL_OPEN)) {
         return ZAP_FAIL;
     }
 
+	if (!zchan->zint->set_interval) {
+		return ZAP_FAIL;
+	}
+
     return zchan->zint->set_interval(zchan, ms);
 
 }
 
-zap_status_t zap_channel_wait(zap_channel_t *zchan, zap_wait_flag_t flags)
+zap_status_t zap_channel_wait(zap_channel_t *zchan, zap_wait_flag_t flags, unsigned to)
 {
 	assert(zchan != NULL);
+	assert(zchan->zint != NULL);
 
     if (!zap_test_flag(zchan, ZAP_CHANNEL_OPEN)) {
         return ZAP_FAIL;
     }
 
-    return zchan->zint->wait(zchan, flags);
+	if (!zchan->zint->wait) {
+		return ZAP_FAIL;
+	}
+
+    return zchan->zint->wait(zchan, flags, to);
 
 }
 
@@ -176,11 +191,17 @@ zap_status_t zap_channel_wait(zap_channel_t *zchan, zap_wait_flag_t flags)
 zap_status_t zap_channel_read(zap_channel_t *zchan, void *data, zap_size_t *datalen)
 {
 	assert(zchan != NULL);
+	assert(zchan->zint != NULL);
+	assert(zchan->zint != NULL);
 
     if (!zap_test_flag(zchan, ZAP_CHANNEL_OPEN)) {
         return ZAP_FAIL;
     }
 
+	if (!zchan->zint->read) {
+		return ZAP_FAIL;
+	}
+
     return zchan->zint->read(zchan, data, datalen);
 	
 }
@@ -189,11 +210,16 @@ zap_status_t zap_channel_read(zap_channel_t *zchan, void *data, zap_size_t *data
 zap_status_t zap_channel_write(zap_channel_t *zchan, void *data, zap_size_t *datalen)
 {
 	assert(zchan != NULL);
+	assert(zchan->zint != NULL);
 
     if (!zap_test_flag(zchan, ZAP_CHANNEL_OPEN)) {
         return ZAP_FAIL;
     }
 
+	if (!zchan->zint->write) {
+		return ZAP_FAIL;
+	}
+
     return zchan->zint->write(zchan, data, datalen);
 	
 }
diff --git a/libs/openzap/src/zap_skel.c b/libs/openzap/src/zap_skel.c
index 2cefd04603..4341309649 100644
--- a/libs/openzap/src/zap_skel.c
+++ b/libs/openzap/src/zap_skel.c
@@ -35,9 +35,71 @@
 #include "openzap.h"
 #include "zap_skel.h"
 
+static ZINT_CONFIGURE_FUNCTION(skel_configure)
+{
+	ZINT_CONFIGURE_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static ZINT_OPEN_FUNCTION(skel_open) 
+{
+	ZINT_OPEN_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static ZINT_CLOSE_FUNCTION(skel_close)
+{
+	ZINT_CLOSE_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static ZINT_SET_CODEC_FUNCTION(skel_set_codec)
+{
+	ZINT_SET_CODEC_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static ZINT_SET_INTERVAL_FUNCTION(skel_set_interval)
+{
+	ZINT_SET_INTERVAL_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static ZINT_WAIT_FUNCTION(skel_wait)
+{
+	ZINT_WAIT_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static ZINT_READ_FUNCTION(skel_read)
+{
+	ZINT_READ_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static ZINT_WRITE_FUNCTION(skel_write)
+{
+	ZINT_WRITE_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static zap_software_interface_t skel_interface;
+
 zap_status_t skel_init(zap_software_interface_t **zint)
 {
 	assert(zint != NULL);
+	memset(&skel_interface, 0, sizeof(skel_interface));
+
+	skel_interface.name = "skel";
+	skel_interface.configure =  skel_configure;
+	skel_interface.open = skel_open;
+	skel_interface.close = skel_close;
+	skel_interface.set_codec = skel_set_codec;
+	skel_interface.set_interval = skel_set_interval;
+	skel_interface.wait = skel_wait;
+	skel_interface.read = skel_read;
+	skel_interface.write = skel_write;
+	*zint = &skel_interface;
 
 	return ZAP_FAIL;
 }
diff --git a/libs/openzap/src/zap_wanpipe.c b/libs/openzap/src/zap_wanpipe.c
index 7cce6d6783..ba05bfd586 100644
--- a/libs/openzap/src/zap_wanpipe.c
+++ b/libs/openzap/src/zap_wanpipe.c
@@ -35,9 +35,71 @@
 #include "openzap.h"
 #include "zap_wanpipe.h"
 
+static ZINT_CONFIGURE_FUNCTION(wanpipe_configure)
+{
+	ZINT_CONFIGURE_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static ZINT_OPEN_FUNCTION(wanpipe_open) 
+{
+	ZINT_OPEN_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static ZINT_CLOSE_FUNCTION(wanpipe_close)
+{
+	ZINT_CLOSE_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static ZINT_SET_CODEC_FUNCTION(wanpipe_set_codec)
+{
+	ZINT_SET_CODEC_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static ZINT_SET_INTERVAL_FUNCTION(wanpipe_set_interval)
+{
+	ZINT_SET_INTERVAL_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static ZINT_WAIT_FUNCTION(wanpipe_wait)
+{
+	ZINT_WAIT_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static ZINT_READ_FUNCTION(wanpipe_read)
+{
+	ZINT_READ_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static ZINT_WRITE_FUNCTION(wanpipe_write)
+{
+	ZINT_WRITE_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static zap_software_interface_t wanpipe_interface;
+
 zap_status_t wanpipe_init(zap_software_interface_t **zint)
 {
 	assert(zint != NULL);
+	memset(&wanpipe_interface, 0, sizeof(wanpipe_interface));
+
+	wanpipe_interface.name = "wanpipe";
+	wanpipe_interface.configure =  wanpipe_configure;
+	wanpipe_interface.open = wanpipe_open;
+	wanpipe_interface.close = wanpipe_close;
+	wanpipe_interface.set_codec = wanpipe_set_codec;
+	wanpipe_interface.set_interval = wanpipe_set_interval;
+	wanpipe_interface.wait = wanpipe_wait;
+	wanpipe_interface.read = wanpipe_read;
+	wanpipe_interface.write = wanpipe_write;
+	*zint = &wanpipe_interface;
 
 	return ZAP_FAIL;
 }
diff --git a/libs/openzap/src/zap_zt.c b/libs/openzap/src/zap_zt.c
index 012abc76b7..802523d393 100644
--- a/libs/openzap/src/zap_zt.c
+++ b/libs/openzap/src/zap_zt.c
@@ -35,9 +35,71 @@
 #include "openzap.h"
 #include "zap_zt.h"
 
+static ZINT_CONFIGURE_FUNCTION(zt_configure)
+{
+	ZINT_CONFIGURE_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static ZINT_OPEN_FUNCTION(zt_open) 
+{
+	ZINT_OPEN_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static ZINT_CLOSE_FUNCTION(zt_close)
+{
+	ZINT_CLOSE_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static ZINT_SET_CODEC_FUNCTION(zt_set_codec)
+{
+	ZINT_SET_CODEC_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static ZINT_SET_INTERVAL_FUNCTION(zt_set_interval)
+{
+	ZINT_SET_INTERVAL_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static ZINT_WAIT_FUNCTION(zt_wait)
+{
+	ZINT_WAIT_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static ZINT_READ_FUNCTION(zt_read)
+{
+	ZINT_READ_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static ZINT_WRITE_FUNCTION(zt_write)
+{
+	ZINT_WRITE_MUZZLE;
+	return ZAP_FAIL;
+}
+
+static zap_software_interface_t zt_interface;
+
 zap_status_t zt_init(zap_software_interface_t **zint)
 {
 	assert(zint != NULL);
+	memset(&zt_interface, 0, sizeof(zt_interface));
+
+	zt_interface.name = "zt";
+	zt_interface.configure =  zt_configure;
+	zt_interface.open = zt_open;
+	zt_interface.close = zt_close;
+	zt_interface.set_codec = zt_set_codec;
+	zt_interface.set_interval = zt_set_interval;
+	zt_interface.wait = zt_wait;
+	zt_interface.read = zt_read;
+	zt_interface.write = zt_write;
+	*zint = &zt_interface;
 
 	return ZAP_FAIL;
 }