ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/Unix/rpc.h
Revision: 1.1
Committed: 2006-04-16T21:25:41Z (18 years, 4 months ago) by gbeauche
Content type: text/plain
Branch: MAIN
Log Message:
Make Basilisk II main application not use GTK libraries when compiling with
STANDALONE_GUI. This is the second step towards a more interesting GUI alike
to VMware. Communication from/to the GUI is held by some lightweight RPC.

Note: The step should be enough to provide a tiny GTK GUI for MacOS X.

File Contents

# User Rev Content
1 gbeauche 1.1 /*
2     * rpc.h - Remote Procedure Calls
3     *
4     * Basilisk II (C) 1997-2006 Christian Bauer
5     * Contributed by Gwenole Beauchesne
6     *
7     * This program is free software; you can redistribute it and/or modify
8     * it under the terms of the GNU General Public License as published by
9     * the Free Software Foundation; either version 2 of the License, or
10     * (at your option) any later version.
11     *
12     * This program is distributed in the hope that it will be useful,
13     * but WITHOUT ANY WARRANTY; without even the implied warranty of
14     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15     * GNU General Public License for more details.
16     *
17     * You should have received a copy of the GNU General Public License
18     * along with this program; if not, write to the Free Software
19     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20     */
21    
22     #ifndef RPC_H
23     #define RPC_H
24    
25     // Error Types
26     enum {
27     RPC_ERROR_NO_ERROR = 0,
28     RPC_ERROR_GENERIC = -1000,
29     RPC_ERROR_ERRNO_SET = -1001,
30     RPC_ERROR_NO_MEMORY = -1002,
31     RPC_ERROR_CONNECTION_NULL = -1003,
32     RPC_ERROR_CONNECTION_TYPE_MISMATCH = -1004,
33     RPC_ERROR_MESSAGE_TRUNCATED = -1005,
34     RPC_ERROR_MESSAGE_ARGUMENT_MISMATCH = -1006,
35     RPC_ERROR_MESSAGE_ARGUMENT_UNKNOWN = -1007,
36     };
37    
38     // Connection Handling
39     typedef struct rpc_connection_t rpc_connection_t;
40     extern rpc_connection_t *rpc_init_server(const char *ident);
41     extern rpc_connection_t *rpc_init_client(const char *ident);
42     extern int rpc_exit(rpc_connection_t *connection);
43     extern int rpc_listen_socket(rpc_connection_t *connection);
44     extern int rpc_listen(rpc_connection_t *connection);
45     extern int rpc_dispatch(rpc_connection_t *connection);
46     extern int rpc_connection_busy(rpc_connection_t *connection);
47    
48     // Message Passing
49     enum {
50     RPC_TYPE_INVALID = 0,
51     RPC_TYPE_CHAR = -2000,
52     RPC_TYPE_BOOLEAN = -2001,
53     RPC_TYPE_INT32 = -2002,
54     RPC_TYPE_UINT32 = -2003,
55     RPC_TYPE_STRING = -2004,
56     RPC_TYPE_ARRAY = -2005,
57     };
58     typedef struct rpc_message_t rpc_message_t;
59     extern int rpc_message_send_char(rpc_message_t *message, char c);
60     extern int rpc_message_send_int32(rpc_message_t *message, int32_t value);
61     extern int rpc_message_send_uint32(rpc_message_t *message, uint32_t value);
62     extern int rpc_message_send_string(rpc_message_t *message, const char *str);
63     extern int rpc_message_send_bytes(rpc_message_t *message, unsigned char *bytes, int count);
64     extern int rpc_message_recv_char(rpc_message_t *message, char *ret);
65     extern int rpc_message_recv_int32(rpc_message_t *message, int32_t *ret);
66     extern int rpc_message_recv_uint32(rpc_message_t *message, uint32_t *ret);
67     extern int rpc_message_recv_string(rpc_message_t *message, char **ret);
68     extern int rpc_message_recv_bytes(rpc_message_t *message, unsigned char *bytes, int count);
69     typedef int (*rpc_message_callback_t)(rpc_message_t *message, void *p_value);
70     typedef struct {
71     int id;
72     int size;
73     rpc_message_callback_t send_callback;
74     rpc_message_callback_t recv_callback;
75     } rpc_message_descriptor_t;
76     extern int rpc_message_add_callbacks(const rpc_message_descriptor_t *descs, int n_descs);
77    
78     // Method Callbacks Handling
79     typedef int (*rpc_method_callback_t)(rpc_connection_t *connection);
80     typedef struct {
81     int id;
82     rpc_method_callback_t callback;
83     } rpc_method_descriptor_t;
84     extern int rpc_method_add_callbacks(rpc_connection_t *connection, const rpc_method_descriptor_t *descs, int n_descs);
85     extern int rpc_method_remove_callback_id(rpc_connection_t *connection, int id);
86     extern int rpc_method_remove_callbacks(rpc_connection_t *connection, const rpc_method_descriptor_t *descs, int n_descs);
87    
88     // Remote Procedure Call (method invocation)
89     extern int rpc_method_invoke(rpc_connection_t *connection, int method, ...);
90     extern int rpc_method_wait_for_reply(rpc_connection_t *connection, ...);
91     extern int rpc_method_get_args(rpc_connection_t *connection, ...);
92     extern int rpc_method_send_reply(rpc_connection_t *connection, ...);
93    
94     // Message Protocol
95     enum {
96     RPC_METHOD_ERROR_ALERT = 1,
97     RPC_METHOD_WARNING_ALERT,
98     RPC_METHOD_EXIT
99     };
100    
101     #endif /* RPC_H */