00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef __DICELIB_H
00027 #define __DICELIB_H
00028
00029 #ifdef __cplusplus
00030 extern "C" {
00031 #endif
00032
00033 #include <stdio.h>
00034 #include <stdlib.h>
00035 #include "dicelib.h"
00036
00046 #define _dice_debug(l,c) if ( l <= dice_data.verbose ) c
00047
00051 struct _dice_data {
00052 int verbose;
00053 int port;
00054 int max_connections;
00055 FILE *error;
00056 void *handle;
00057 char *color[2];
00058 int original_only;
00060
00061 int clientnum;
00062 struct _clients {
00063 char *address;
00064 char *path;
00065 char *function;
00066 } *clients;
00067 enum { NONE, RSH, SSH, BPROC } spawn;
00069
00070 int id;
00071 char *controlname;
00072 int controlsock;
00073 int (*function)(void *);
00074 };
00078 extern struct _dice_data dice_data;
00079
00083 enum _dice_packet_type {
00084 INVALID,
00085 SYNC,
00086 VARIABLE_ASYNC,
00087 VARIABLE_SYNC,
00088 VARIABLE_FREE_ASYNC,
00089 VARIABLE_FREE_SYNC,
00090 READY,
00091 CONTINUE,
00092 HELLO,
00093 GOODBYE
00094 };
00098 typedef enum _dice_packet_type dice_packet_type;
00099
00103 union _dice_packet {
00104 dice_packet_type packtype;
00107 struct {
00108 dice_packet_type packtype;
00109 } sync;
00110
00112 struct {
00113 dice_packet_type packtype;
00114 char *name;
00115 char *type;
00116 void *value;
00117 } variable;
00118
00120 struct {
00121 dice_packet_type packtype;
00122 char *name;
00123 } variable_free;
00124
00126 struct {
00127 dice_packet_type packtype;
00128 } ready;
00129
00131 struct {
00132 dice_packet_type packtype;
00133 } cont;
00134
00136 struct {
00137 dice_packet_type packtype;
00138 unsigned long id;
00139 char *function;
00140 } hello;
00141
00143 struct {
00144 dice_packet_type packtype;
00145 } goodbye;
00146 };
00150 typedef union _dice_packet dice_packet;
00151
00155
00156 extern int dice_type_init_defaults ( void );
00157 extern void dice_type_free_all ( void );
00158 extern int dice_sync_init ( void );
00159 extern void dice_sync_end ( void );
00160 extern int dice_async_init ( void );
00161 extern void dice_async_end ( void );
00162 extern int dice_init_client ( void );
00163 extern char *defaultpath;
00164
00165
00166 extern void dice_sync_update_send ( void );
00167 extern int dice_packet_send ( dice_packet *p, int sock );
00168 extern dice_packet dice_packet_get ( int sock );
00169 extern int dice_broadcast ( dice_packet *packet, int except );
00170 extern int dice_control_loop ( int argc, char **argv );
00171
00172
00173 extern int dice_type_register ( DICE_Type *t );
00174 extern int dice_control_hierarchy ( int a, int b );
00175 extern void dice_free ( void *data );
00176 extern char *dice_packet_name ( dice_packet_type t );
00177 extern void dice_printf(char *function, char *format, ...);
00178 extern int dice_type_is_valid ( char *name );
00179
00180 #define dice_is_server() (dice_data.clientnum != -1)
00181
00183 #ifdef __cplusplus
00184 }
00185 #endif
00186
00187
00188 #endif
00189