comparison src/chain.h @ 0:6ee11bf9e3ea

Initial revision
author jcid
date Sun, 07 Oct 2007 00:36:34 +0200
parents
children 726937936aa0
comparison
equal deleted inserted replaced
-1:000000000000 0:6ee11bf9e3ea
1 #ifndef __CHAIN_H__
2 #define __CHAIN_H__
3
4 /*
5 * Concomitant control chain (CCC)
6 * Theory and code by Jorge Arellano Cid <jcid@dillo.org>
7 */
8
9
10 /*
11 * Supported CCC operations
12 */
13 #define OpStart 1
14 #define OpSend 2
15 #define OpStop 3
16 #define OpEnd 4
17 #define OpAbort 5
18
19
20 /*
21 * Linking direction
22 */
23 #define FWD 1
24 #define BCK 2
25
26
27 typedef struct _ChainLink ChainLink;
28 typedef struct _DataBuf DataBuf;
29 typedef void (*ChainFunction_t)(int Op, int Branch, int Dir, ChainLink *Info,
30 void *Data1, void *Data2);
31
32 /* This is the main data structure for CCC nodes */
33 struct _ChainLink {
34 void *LocalKey;
35
36 ChainLink *FcbInfo;
37 ChainFunction_t Fcb;
38 int FcbBranch;
39
40 ChainLink *BcbInfo;
41 ChainFunction_t Bcb;
42 int BcbBranch;
43 };
44
45 /* A convenience data structure for passing data chunks between nodes */
46 struct _DataBuf {
47 char *Buf;
48 int Size;
49 int Code;
50 };
51
52
53
54 /*
55 * Function prototypes
56 */
57 ChainLink *a_Chain_new(void);
58 ChainLink *a_Chain_link_new(ChainLink *AInfo, ChainFunction_t AFunc,
59 int Direction, ChainFunction_t BFunc,
60 int AtoB_branch, int BtoA_branch);
61 void a_Chain_unlink(ChainLink *Info, int Direction);
62 int a_Chain_fcb(int Op, ChainLink *Info, void *Data1, void *Data2);
63 int a_Chain_bcb(int Op, ChainLink *Info, void *Data1, void *Data2);
64
65 DataBuf *a_Chain_dbuf_new(void *buf, int size, int code);
66 void a_Chain_debug_msg(char *FuncStr, int Op, int Branch, int Dir);
67
68
69 #endif /* __CHAIN_H__ */