From 9d4023b751919cdcca651198cfeda36a776f2c91 Mon Sep 17 00:00:00 2001 From: Morten Rolland Date: Wed, 6 Jan 1999 00:08:46 +0000 Subject: [PATCH] Extended module framework to enable demanding data from upstream modules. --- include/ifax/module.h | 18 +++++++++++++++++- lib/Makefile | 2 +- lib/module.c | 8 ++++++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/include/ifax/module.h b/include/ifax/module.h index c6a1c3c..2ac93cc 100644 --- a/include/ifax/module.h +++ b/include/ifax/module.h @@ -27,6 +27,12 @@ typedef struct ifax_module { */ int (*handle_input)(struct ifax_module *self, void *data, size_t len); + /* This function is called to request data from the previous module + * in the chain. The resulting data is delivered by means of the + * 'handle_input' method. + */ + void (*handle_demand)(struct ifax_module *self, size_t len); + /* Use this to implement "commands" to modules like changing operating * parameters "on-the-fly". */ @@ -41,7 +47,13 @@ typedef struct ifax_module { * Some modules (like replicate.c) have their own ideas about that. */ struct ifax_module *sendto; - + + /* We need a reverse chain as well, to be able to request data from + * from the previous module. The 'replicate' module and similar + * will have to know which chain to request data from. + */ + struct ifax_module *recvfrom; + } ifax_module; /* A module instance is identified by that handle type. @@ -83,6 +95,10 @@ ifax_modp ifax_create_module(ifax_module_id what_kind,...); */ int ifax_handle_input(struct ifax_module *self,void *data,size_t len); +/* Request data from previous modules. + */ +void ifax_handle_demand(struct ifax_module *self, size_t len); + /* Send a command to a module. Semantics are defined by the module. */ int ifax_command(struct ifax_module *self, int command, ...); diff --git a/lib/Makefile b/lib/Makefile index 937e18e..b459928 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -10,4 +10,4 @@ isdnlib.a: $(LIBOBJS) $(AR) rcs $@ $^ clean: - rm -f $(LIBOBJS) *~ + rm -f $(LIBOBJS) isdnlib.a *~ diff --git a/lib/module.c b/lib/module.c index 9ff6023..e594796 100644 --- a/lib/module.c +++ b/lib/module.c @@ -100,6 +100,14 @@ int ifax_handle_input(struct ifax_module *self,void *data,size_t len) return self->handle_input(self, data,len); } +/* Request data from a module. Length is specified by the module, + * just like the 'handle_input' method. + */ +void ifax_handle_demand(struct ifax_module *self, size_t len) +{ + self->handle_demand(self,len); +} + /* Send a command to a module. Note, that commands and data are defined * by the module. */