annotate src/chain.h @ 1271:3e784a367043

Added a_Chain_bfcb() to the CCC API (fixed three bugs with it)
author Jorge Arellano Cid <jcid@dillo.org>
date Fri, 07 Aug 2009 18:27:48 -0400
parents 726937936aa0
children
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
215
726937936aa0 - CCC: added reentrancy control to the OpEnd and OpAbort operations.
jcid
parents: 0
diff changeset
19 /*
726937936aa0 - CCC: added reentrancy control to the OpEnd and OpAbort operations.
jcid
parents: 0
diff changeset
20 * CCC flags
726937936aa0 - CCC: added reentrancy control to the OpEnd and OpAbort operations.
jcid
parents: 0
diff changeset
21 */
726937936aa0 - CCC: added reentrancy control to the OpEnd and OpAbort operations.
jcid
parents: 0
diff changeset
22 #define CCC_Stopped (1 << 0)
726937936aa0 - CCC: added reentrancy control to the OpEnd and OpAbort operations.
jcid
parents: 0
diff changeset
23 #define CCC_Ended (1 << 1)
726937936aa0 - CCC: added reentrancy control to the OpEnd and OpAbort operations.
jcid
parents: 0
diff changeset
24 #define CCC_Aborted (1 << 2)
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
25
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
26 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
27 * Linking direction
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
28 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
29 #define FWD 1
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
30 #define BCK 2
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
31
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
32
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
33 typedef struct _ChainLink ChainLink;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
34 typedef struct _DataBuf DataBuf;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
35 typedef void (*ChainFunction_t)(int Op, int Branch, int Dir, ChainLink *Info,
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
36 void *Data1, void *Data2);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
37
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
38 /* This is the main data structure for CCC nodes */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
39 struct _ChainLink {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
40 void *LocalKey;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
41
215
726937936aa0 - CCC: added reentrancy control to the OpEnd and OpAbort operations.
jcid
parents: 0
diff changeset
42 int Flags;
726937936aa0 - CCC: added reentrancy control to the OpEnd and OpAbort operations.
jcid
parents: 0
diff changeset
43
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
44 ChainLink *FcbInfo;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
45 ChainFunction_t Fcb;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
46 int FcbBranch;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
47
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
48 ChainLink *BcbInfo;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
49 ChainFunction_t Bcb;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
50 int BcbBranch;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
51 };
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
52
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
53 /* A convenience data structure for passing data chunks between nodes */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
54 struct _DataBuf {
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
55 char *Buf;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
56 int Size;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
57 int Code;
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
58 };
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
59
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
60
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
61
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
62 /*
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
63 * Function prototypes
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
64 */
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
65 ChainLink *a_Chain_new(void);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
66 ChainLink *a_Chain_link_new(ChainLink *AInfo, ChainFunction_t AFunc,
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
67 int Direction, ChainFunction_t BFunc,
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
68 int AtoB_branch, int BtoA_branch);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
69 void a_Chain_unlink(ChainLink *Info, int Direction);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
70 int a_Chain_fcb(int Op, ChainLink *Info, void *Data1, void *Data2);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
71 int a_Chain_bcb(int Op, ChainLink *Info, void *Data1, void *Data2);
1271
3e784a367043 Added a_Chain_bfcb() to the CCC API (fixed three bugs with it)
Jorge Arellano Cid <jcid@dillo.org>
parents: 215
diff changeset
72 int a_Chain_bfcb(int Op, ChainLink *Info, void *Data1, void *Data2);
215
726937936aa0 - CCC: added reentrancy control to the OpEnd and OpAbort operations.
jcid
parents: 0
diff changeset
73 int a_Chain_check(char *FuncStr, int Op, int Branch, int Dir,
726937936aa0 - CCC: added reentrancy control to the OpEnd and OpAbort operations.
jcid
parents: 0
diff changeset
74 ChainLink *Info);
0
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
75
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
76 DataBuf *a_Chain_dbuf_new(void *buf, int size, int code);
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
77
6ee11bf9e3ea Initial revision
jcid
parents:
diff changeset
78 #endif /* __CHAIN_H__ */