diff Renderer/Engine/lindaapi.h @ 565:2e1b6c5e4f8f

linda API
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 22 Oct 2009 23:45:05 +0900
parents 735f76483bb2
children cc989924f469
line wrap: on
line diff
--- a/Renderer/Engine/lindaapi.h	Thu Oct 22 23:07:16 2009 +0900
+++ b/Renderer/Engine/lindaapi.h	Thu Oct 22 23:45:05 2009 +0900
@@ -1,8 +1,15 @@
-//  $Id: lindaapi.h,v 1.8 2005/12/21 07:29:38 yasumura Exp $
-//
+#ifndef _LINDAAPI_H
+
+#define _LINDAAPI_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*  $Id$ */
 
 /*----------------------------------------------------------------------
- ¥Þ¥¯¥íÄêµÁ
+  マクロ定義
 ----------------------------------------------------------------------*/
 
 #define FAIL            (-1)
@@ -13,8 +20,10 @@
 
 #define INT_SIZE    4     // Byte = sizeof(int)
 
+#define LDSERV_PORT     11511
+
 /*----------------------------------------------------------------------
- ¥Ñ¥±¥Ã¥È¥Õ¥©¡¼¥Þ¥Ã¥È
+ パケットフォーマット
  char     short  int    int
  Mode +   ID   + Seq  + Data_len + Padding + Data
  0        1      3      7          11        12
@@ -24,63 +33,65 @@
 #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(*callback)(unsigned char * tuple, void * obj);
     void * obj;
-} REPLY, *REPLY_PTR;
-
+} REPLY;
+          
 typedef struct command_queue{
+    struct command_queue *next;
+    unsigned int tspace_id;        /* ID of destination Tuple Space */
+    unsigned int size;
     unsigned char *command;
-    struct command_queue *next;
-    unsigned int size;
-} COMMAND, *COMMAND_PTR;
+} COMMAND;
+
 
 /*----------------------------------------------------------------------
- ÀÅŪ´Ø¿ô¥Æ¥ó¥×¥ì¡¼¥È
+  Linda API
 ----------------------------------------------------------------------*/
 
-int start_linda(char *hostname);
-void unix_chkserv();
-extern void psx_free(char *tuple);
+extern void init_linda(void);
+extern int open_linda(char *hostname, int port);
+extern int open_linda_java(char *hostname, int port);
+extern int close_linda(int tspace_id);
 
-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);
+extern void psx_free(void*);
 
-#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)
+extern unsigned char *psx_reply(unsigned int seq);
+extern void psx_sync_n(void);
+extern unsigned int psx_get_datalength(unsigned char *);
+extern unsigned int psx_get_seq(unsigned char *);
+extern unsigned short psx_get_id(unsigned char *);
+extern unsigned char psx_get_mode(unsigned char *);
+extern unsigned char * psx_get_data(unsigned char *);
 
-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 *);
+extern int psx_out(unsigned int tspace_id, unsigned int id,
+                   unsigned char *data, unsigned int size);
+extern int psx_ld(unsigned int tspace_id, unsigned int id,
+                  char mode, void(*callback)(unsigned char *,void *),void * obj);
+
+#define psx_in(tid, id)      psx_ld(tid, id, 'i', NULL, NULL)
+#define psx_rd(tid, id)      psx_ld(tid, id, 'r', NULL, NULL)
+#define psx_ck(tid, id)      psx_ld(tid, id, 'c', NULL, NULL)
+#define psx_wait_rd(tid, id) psx_ld(tid, id, 'w', NULL, NULL)
 
-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();                        /* Æɤ߽ñ¤­¤Ç¤­¤ë¥Ñ¥±¥Ã¥È¿ô¤òµá¤á¤ë */
+#define psx_callback_in(tid, id,callback,obj)      psx_ld(tid, id, 'i', callback, obj)
+#define psx_callback_rd(tid, id,callback,obj)      psx_ld(tid, id, 'r', callback, obj)
+#define psx_callback_ck(tid, id,callback,obj)      psx_ld(tid, id, 'c', callback, obj)
+#define psx_callback_wait_rd(tid, id,callback,obj) psx_ld(tid, id, 'w', callback, obj)
+
 
+
+#ifdef __cplusplus
+};  // for extern "C"
+#endif
+#endif // _LINDAAPI_H