annotate Linda/#lindaapi.h# @ 112:5106d8d12ded

Changing Magoroku.cc
author Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
date Thu, 09 Jun 2011 14:59:24 +0900
parents cb6c6de125dc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
91
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 // $Id$
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 //
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 /*----------------------------------------------------------------------
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 ’¥Þ’¥¯’¥í’Äê’µÁ
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 ----------------------------------------------------------------------*/
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 #define FAIL (-1)
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
9
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 #define PS_DEB 0xf8
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
11
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 #define MAX_QUEUE 1024
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
13
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 #define INT_SIZE 4 // Byte = sizeof(int)
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 /*----------------------------------------------------------------------
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 ’¥Ñ’¥±’¥Ã’¥È’¥Õ’¥©’¡¼’¥Þ’¥Ã’¥È
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 char short int int
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 Mode + ID + Seq + Data_len + Padding + Data
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 0 1 3 7 11 12
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 ----------------------------------------------------------------------*/
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
22
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #define LINDA_MODE_OFFSET 0
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 #define LINDA_ID_OFFSET 1
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 #define LINDA_SEQ_OFFSET 3
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 #define LINDA_DATA_LENGTH_OFFSET 7
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 #define LINDA_TID_OFFSET 11
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 #define LINDA_HEADER_SIZE 12
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
29
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 /*----------------------------------------------------------------------
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 ’¹½’¤’ÂÎ’Äê’µÁ
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 ----------------------------------------------------------------------*/
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 typedef struct psx_reply{
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 unsigned char *answer;
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 unsigned int seq;
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
36 struct psx_reply *next;
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 char mode;
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 void(*callback)(char * tuple, void * obj);
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 void * obj;
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 } REPLY, *REPLY_PTR;
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
41
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 typedef struct command_queue{
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
43 unsigned char *command;
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 struct command_queue *next;
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 unsigned int size;
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 INDA_H COMMAND, *COMMAND_PTR;
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
47
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 /*----------------------------------------------------------------------
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 ’ÀŒŪ’´Ø’¿ô’¥Æ’¥ó’¥×’¥ì’¡¼’¥È
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 ----------------------------------------------------------------------*/
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
51
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 int start_linda(char *hostname);
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 void unix_chkserv();
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
54
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 int psx_out(unsigned int id, unsigned char *data, unsigned int size);
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 int psx_ld(unsigned int id, char mode, void(*callback)(char *,void *),void * obj);
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
57
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 #define psx_in(id) psx_ld(id, 'i', NULL, NULL)
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 #define psx_rd(id) psx_ld(id, 'r', NULL, NULL)
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 #define psx_ck(id) psx_ld(id, 'c', NULL, NULL)
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 #define psx_wait_rd(id) psx_ld(id, 'w', NULL, NULL)
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
62
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 #define psx_callback_in(id,callback,obj) psx_ld(id, 'i', callback, obj)
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 #define psx_callback_rd(id,callback,obj) psx_ld(id, 'r', callback, obj)
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 #define psx_callback_ck(id,callback,obj) psx_ld(id, 'c', callback, obj)
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 #define psx_callback_wait_rd(id,callback,obj) psx_ld(id, 'w', callback, obj)
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
67
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 unsigned char *psx_reply(int seq);
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 void psx_sync_n();
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 void psx_free(unsigned char *);
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 int psx_queue(unsigned int id, unsigned int size, unsigned char *data, char mode,
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 void(*callback)(char *,void *),void * obj);
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 int psx_get_datalength(unsigned char *);
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 unsigned char *psx_get_data(unsigned char *);
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 int psx_get_seq(unsigned char *);
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 short psx_get_id(unsigned char *);
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 char psx_get_mode(unsigned char *);
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
78
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
79 int unix_open(); /* UNIX ’ÄÌ’¿®’¤ò’³«’Àß’¤¹’¤ë */
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 int unix_read(int,char *,unsigned int); /* UNIX ’¤«’¤é’ÆÉ’¤ß’¹þ’¤à */
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 int unix_read_w(int,char *,int); /* UNIX ’¤«’¤é’ÆÉ’¤ß’¹þ’¤à(non wait) */
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 int unix_write(int,unsigned char *,unsigned int);/* UNIX ’¤Ø’½ñ’¤­’¹þ’¤à */
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
83 int unix_write_w(int,unsigned char *,unsigned int);/* UNIX ’¤Ø’½ñ’¤­’¹þ’¤à(non wait) */
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 int send_able(); /* ’ÆÉ’¤ß’½ñ’¤­’¤Ç’¤­’¤ë’¥Ñ’¥±’¥Ã’¥È’¿ô’¤ò’µá’¤á’¤ë */
cb6c6de125dc halfway
Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
parents:
diff changeset
85