author | Medo <smaxein@googlemail.com> |
Thu, 31 May 2012 18:32:01 +0200 | |
changeset 7158 | a0573014ff4f |
permissions | -rw-r--r-- |
7158
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
1 |
/* |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
2 |
* Low-level protocol support for the IPC connection to the engine. |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
3 |
*/ |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
4 |
|
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
5 |
#ifndef IPCCONN_H_ |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
6 |
#define IPCCONN_H_ |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
7 |
|
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
8 |
#include <stddef.h> |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
9 |
|
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
10 |
typedef enum {IPC_NOT_CONNECTED, IPC_LISTENING, IPC_CONNECTED} IpcConnState; |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
11 |
|
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
12 |
/** |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
13 |
* Called by flib_init(). Initialize everything related to ipc. |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
14 |
*/ |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
15 |
void flib_ipcconn_init(); |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
16 |
|
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
17 |
/** |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
18 |
* Called by flib_quit(). Free resources and shut down. |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
19 |
*/ |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
20 |
void flib_ipcconn_quit(); |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
21 |
|
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
22 |
/** |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
23 |
* Start listening for a connection from the engine. The system has to be in state |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
24 |
* IPC_NOT_CONNECTED when calling this function. |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
25 |
* |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
26 |
* Returns the port we started listening on, or a negative value if there is an error. |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
27 |
* |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
28 |
* We stop listening once a connection has been established, so if you want to start |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
29 |
* the engine again and talk to it you need to call this function again after the old |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
30 |
* connection is closed. |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
31 |
*/ |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
32 |
int flib_ipcconn_listen(); |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
33 |
|
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
34 |
/** |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
35 |
* Close the current IPC connection and/or stop listening for an incoming one. |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
36 |
* This also discards all unread messages. |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
37 |
*/ |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
38 |
void flib_ipcconn_close(); |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
39 |
|
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
40 |
/** |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
41 |
* Determine the current connection state |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
42 |
*/ |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
43 |
IpcConnState flib_ipcconn_state(); |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
44 |
|
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
45 |
/** |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
46 |
* Receive a single message (up to 255 bytes) and copy it into the data buffer. |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
47 |
* Returns the length of the received message, a negative value if no message could |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
48 |
* be read. |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
49 |
*/ |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
50 |
int flib_ipcconn_recv_message(void *data); |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
51 |
|
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
52 |
/** |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
53 |
* Write a single message (up to 255 bytes) to the engine. This call blocks until the |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
54 |
* message is completely written or the connection is closed or an error occurs. |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
55 |
* |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
56 |
* Calling this function in a state other than IPC_CONNECTED will fail immediately. |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
57 |
* Returns a negative value on failure. |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
58 |
*/ |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
59 |
int flib_ipcconn_send_message(void *data, size_t len); |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
60 |
|
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
61 |
/** |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
62 |
* Call regularly to allow background work to proceed |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
63 |
*/ |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
64 |
void flib_ipcconn_tick(); |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
65 |
|
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
66 |
#endif /* IPCCONN_H_ */ |
a0573014ff4f
Further work on the frontend library, restructuring, ...
Medo <smaxein@googlemail.com>
parents:
diff
changeset
|
67 |