0
|
1 /* $Id$ */
|
|
2
|
|
3 /*----------------------------------------------------------------------
|
|
4 マクロ定義
|
|
5 ----------------------------------------------------------------------*/
|
|
6
|
|
7 #define FAIL (-1)
|
|
8
|
|
9 #define PS_DEB 0xf8
|
|
10
|
|
11 #define MAX_QUEUE 1024
|
|
12
|
|
13 #define INT_SIZE 4 // Byte = sizeof(int)
|
|
14
|
|
15 #define LDSERV_PORT 11511
|
|
16
|
|
17 /*----------------------------------------------------------------------
|
|
18 パケットフォーマット
|
|
19 char short int int
|
|
20 Mode + ID + Seq + Data_len + Padding + Data
|
|
21 0 1 3 7 11 12
|
|
22 ----------------------------------------------------------------------*/
|
|
23
|
|
24 #define LINDA_MODE_OFFSET 0
|
|
25 #define LINDA_ID_OFFSET 1
|
|
26 #define LINDA_SEQ_OFFSET 3
|
|
27 #define LINDA_DATA_LENGTH_OFFSET 7
|
|
28 #define LINDA_HEADER_SIZE 12
|
|
29
|
|
30 /*----------------------------------------------------------------------
|
|
31 構造体定義
|
|
32 ----------------------------------------------------------------------*/
|
|
33 typedef struct psx_reply{
|
|
34 unsigned char *answer;
|
|
35 unsigned int seq;
|
|
36 struct psx_reply *next;
|
|
37 char mode;
|
|
38 void(*callback)(unsigned char * tuple, void * obj);
|
|
39 void * obj;
|
|
40 } REPLY;
|
|
41
|
|
42 typedef struct command_queue{
|
|
43 struct command_queue *next;
|
|
44 unsigned int tspace_id; /* ID of destination Tuple Space */
|
|
45 unsigned int size;
|
|
46 unsigned char *command;
|
|
47 } COMMAND;
|
|
48
|
|
49
|
|
50 /*----------------------------------------------------------------------
|
|
51 Linda API
|
|
52 ----------------------------------------------------------------------*/
|
|
53
|
|
54 extern void init_linda(void);
|
|
55 extern int open_linda(const char *hostname, int port);
|
|
56 extern int open_linda_java(const char *hostname, int port);
|
|
57 extern int close_linda(int tspace_id);
|
|
58
|
|
59 extern void psx_free(void*);
|
|
60
|
|
61 extern unsigned char *psx_reply(unsigned int seq);
|
|
62 extern void psx_sync_n(void);
|
|
63 extern void psx_sync_n_timeout(int time);
|
|
64 extern unsigned int psx_get_datalength(unsigned char *);
|
|
65 extern unsigned int psx_get_seq(unsigned char *);
|
|
66 extern unsigned short psx_get_id(unsigned char *);
|
|
67 extern unsigned char psx_get_mode(unsigned char *);
|
|
68 extern unsigned char * psx_get_data(unsigned char *);
|
|
69
|
|
70 extern int psx_out(unsigned int tspace_id, unsigned int id,
|
|
71 unsigned char *data, unsigned int size);
|
|
72 extern int psx_callback_update(unsigned int tspace_id, unsigned int id,
|
|
73 unsigned char *data, unsigned int size,
|
|
74 void(*callback)(unsigned char *,void *),void * obj);
|
|
75 extern int psx_ld(unsigned int tspace_id, unsigned int id,
|
|
76 char mode, void(*callback)(unsigned char *,void *),void * obj);
|
|
77
|
|
78 #define psx_in(tid, id) psx_ld(tid, id, 'i', NULL, NULL)
|
|
79 #define psx_rd(tid, id) psx_ld(tid, id, 'r', NULL, NULL)
|
|
80 #define psx_ck(tid, id) psx_ld(tid, id, 'c', NULL, NULL)
|
|
81 #define psx_wait_rd(tid, id) psx_ld(tid, id, 'w', NULL, NULL)
|
|
82 #define psx_update(tid, id, data, size) psx_callback_update(tid, id, data, size, NULL, NULL)
|
|
83
|
|
84 #define psx_callback_in(tid, id,callback,obj) psx_ld(tid, id, 'i', callback, obj)
|
|
85 #define psx_callback_rd(tid, id,callback,obj) psx_ld(tid, id, 'r', callback, obj)
|
|
86 #define psx_callback_ck(tid, id,callback,obj) psx_ld(tid, id, 'c', callback, obj)
|
|
87 #define psx_callback_wait_rd(tid, id,callback,obj) psx_ld(tid, id, 'w', callback, obj)
|