view Linda/lindaapi.h~ @ 115:31dd5c07f7c1

class OBJECT:SceanGraph
author e085768
date Wed, 15 Jun 2011 23:31:59 +0900 (2011-06-15)
parents 0b65ca27f113
children
line wrap: on
line source
#ifndef LINDAAPI_H
#define LINDAAPI_H



/*----------------------------------------------------------------------
 �ޥ������
----------------------------------------------------------------------*/

#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();

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();                        /* �ɤ߽񤭤Ǥ���ѥ��åȿ������ */

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;




#endif