view src/chain.h @ 0:6ee11bf9e3ea

Initial revision
author jcid
date Sun, 07 Oct 2007 00:36:34 +0200
children 726937936aa0
line wrap: on
line source
#ifndef __CHAIN_H__
#define __CHAIN_H__

 * Concomitant control chain (CCC)
 * Theory and code by Jorge Arellano Cid <>

 * Supported CCC operations
#define OpStart  1
#define OpSend   2
#define OpStop   3
#define OpEnd    4
#define OpAbort  5

 * Linking direction
#define FWD 1
#define BCK 2

typedef struct _ChainLink ChainLink;
typedef struct _DataBuf DataBuf;
typedef void (*ChainFunction_t)(int Op, int Branch, int Dir, ChainLink *Info,
                                void *Data1, void *Data2);

/* This is the main data structure for CCC nodes */
struct _ChainLink {
   void *LocalKey;

   ChainLink *FcbInfo;
   ChainFunction_t Fcb;
   int FcbBranch;

   ChainLink *BcbInfo;
   ChainFunction_t Bcb;
   int BcbBranch;

/* A convenience data structure for passing data chunks between nodes */
struct _DataBuf {
   char *Buf;
   int Size;
   int Code;

 * Function prototypes
ChainLink *a_Chain_new(void);
ChainLink *a_Chain_link_new(ChainLink *AInfo, ChainFunction_t AFunc,
                            int Direction, ChainFunction_t BFunc,
                            int AtoB_branch, int BtoA_branch);
void a_Chain_unlink(ChainLink *Info, int Direction);
int a_Chain_fcb(int Op, ChainLink *Info, void *Data1, void *Data2);
int a_Chain_bcb(int Op, ChainLink *Info, void *Data1, void *Data2);

DataBuf *a_Chain_dbuf_new(void *buf, int size, int code);
void a_Chain_debug_msg(char *FuncStr, int Op, int Branch, int Dir);

#endif /* __CHAIN_H__ */