#ifndef __MESSAGE_H
#define __MESSAGE_H

#include <ubixos/schedule.h>
#include <ubixos/types.h>
#include <lib/Queue.h>

#ifdef __cplusplus
extern "C" {
#endif

int connectionCreate(char * cname, uInt32 * cid, uInt8 flags);
int connectionOpen(char * cname, uInt32 * cid);
int messageRecv(uInt32 cid, uInt32 * sender, uInt32 * cmd, uInt32 * size, uInt8 * data);
int messageSend(uInt32 cid, uInt32 * cmd, uInt32 * size, uInt8 * data);
int messageReply(uInt32 cid, uInt32 mid, uInt32 cmd, uInt32 size, uInt8 * data);

enum {
    MSG_SEND = 0x1,
    MSG_REPLY = 0x2
};

#ifdef __cplusplus
}

class message_t {
  public:
    uInt32 send_taskId;
    uInt32 id;
    uInt32 cmd;
    uInt8 flags;
    uInt8 size;
    uInt8 data[256];
};


class connection_t {
  public:  
    uInt32 used;
    pid_t owning_pid;
    Int8   unique_string[256];
    //waitQueue_t message_queue;
    Queue<message_t *> * message_queue;
    //waitQueue_t old_queue;
    Queue<message_t *> * old_queue;
};


#endif

#endif
