diff Renderer/Engine/lindaapi.h @ 507:735f76483bb2

Reorganization..
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 12 Oct 2009 09:39:35 +0900
parents
children 2e1b6c5e4f8f
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Renderer/Engine/lindaapi.h	Mon Oct 12 09:39:35 2009 +0900
@@ -0,0 +1,86 @@
+//  $Id: lindaapi.h,v 1.8 2005/12/21 07:29:38 yasumura Exp $
+//
+
+/*----------------------------------------------------------------------
+ マクロ定義
+----------------------------------------------------------------------*/
+
+#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;
+} COMMAND, *COMMAND_PTR;
+
+/*----------------------------------------------------------------------
+ 静的関数テンプレート
+----------------------------------------------------------------------*/
+
+int start_linda(char *hostname);
+void unix_chkserv();
+extern void psx_free(char *tuple);
+
+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();                        /* 読み書きできるパケット数を求める */
+