annotate src/chain.h @ 0:6ee11bf9e3ea

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