diff Linda/#lindaapi.h# @ 91:cb6c6de125dc

halfway
author Atuto SHIROMA <e095729@ie.u-ryukyu.ac.jp>
date Thu, 26 May 2011 14:44:03 +0900
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Linda/#lindaapi.h#	Thu May 26 14:44:03 2011 +0900
@@ -0,0 +1,85 @@
+//  $Id$
+//
+
+/*----------------------------------------------------------------------
+ ’¥Þ’¥¯’¥í’Äê’µÁ
+----------------------------------------------------------------------*/
+
+#define FAIL            (-1)
+
+#define PS_DEB          0xf8
+
+#define MAX_QUEUE       1024
+
+#define INT_SIZE    4     // Byte = sizeof(int)
+
+/*----------------------------------------------------------------------
+ ’¥Ñ’¥±’¥Ã’¥È’¥Õ’¥©’¡¼’¥Þ’¥Ã’¥È
+ char     short  int    int
+ Mode +   ID   + Seq  + Data_len + Padding + Data
+ 0        1      3      7          11        12
+----------------------------------------------------------------------*/
+
+#define LINDA_MODE_OFFSET          0
+#define LINDA_ID_OFFSET            1
+#define LINDA_SEQ_OFFSET           3
+#define LINDA_DATA_LENGTH_OFFSET   7
+#define LINDA_TID_OFFSET           11
+#define LINDA_HEADER_SIZE          12
+
+/*----------------------------------------------------------------------
+ ’¹½’¤’ÂÎ’Äê’µÁ
+----------------------------------------------------------------------*/
+typedef struct psx_reply{
+    unsigned char *answer;
+    unsigned int seq;
+    struct psx_reply *next;
+    char mode;
+    void(*callback)(char * tuple, void * obj);
+    void * obj;
+} REPLY, *REPLY_PTR;
+          
+typedef struct command_queue{
+    unsigned char *command;
+    struct command_queue *next;
+    unsigned int size;
+INDA_H COMMAND, *COMMAND_PTR;
+
+/*----------------------------------------------------------------------
+ ’ÀŒŪ’´Ø’¿ô’¥Æ’¥ó’¥×’¥ì’¡¼’¥È
+----------------------------------------------------------------------*/
+
+int start_linda(char *hostname);
+void unix_chkserv();
+
+int psx_out(unsigned int id, unsigned char *data, unsigned int size);
+int psx_ld(unsigned int id, char mode, void(*callback)(char *,void *),void * obj);
+
+#define psx_in(id)      psx_ld(id, 'i', NULL, NULL)
+#define psx_rd(id)      psx_ld(id, 'r', NULL, NULL)
+#define psx_ck(id)      psx_ld(id, 'c', NULL, NULL)
+#define psx_wait_rd(id) psx_ld(id, 'w', NULL, NULL)
+
+#define psx_callback_in(id,callback,obj)       psx_ld(id, 'i', callback, obj)
+#define psx_callback_rd(id,callback,obj)       psx_ld(id, 'r', callback, obj)
+#define psx_callback_ck(id,callback,obj)       psx_ld(id, 'c', callback, obj)
+#define psx_callback_wait_rd(id,callback,obj)  psx_ld(id, 'w', callback, obj)
+
+unsigned char *psx_reply(int seq);
+void psx_sync_n();
+void psx_free(unsigned char *);
+int psx_queue(unsigned int id, unsigned int size, unsigned char *data, char mode,
+              void(*callback)(char *,void *),void * obj);
+int psx_get_datalength(unsigned char *);
+unsigned char *psx_get_data(unsigned char *);
+int psx_get_seq(unsigned char *);
+short psx_get_id(unsigned char *);
+char psx_get_mode(unsigned char *);
+
+int unix_open();                        /* UNIX ’ÄÌ’¿®’¤ò’³«’Àß’¤¹’¤ë */
+int unix_read(int,char *,unsigned int); /* UNIX ’¤«’¤é’ÆÉ’¤ß’¹þ’¤à */
+int unix_read_w(int,char *,int);        /* UNIX ’¤«’¤é’ÆÉ’¤ß’¹þ’¤à(non wait) */
+int unix_write(int,unsigned char *,unsigned int);/* UNIX ’¤Ø’½ñ’¤­’¹þ’¤à */
+int unix_write_w(int,unsigned char *,unsigned int);/* UNIX ’¤Ø’½ñ’¤­’¹þ’¤à(non wait) */
+int send_able();                        /* ’ÆÉ’¤ß’½ñ’¤­’¤Ç’¤­’¤ë’¥Ñ’¥±’¥Ã’¥È’¿ô’¤ò’µá’¤á’¤ë */
+