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