Main Page   Compound List   File List   Compound Members   File Members  

_dicelib.h

Go to the documentation of this file.
00001 /* DICElib (DIstributed CAVE Engine library) 
00002  * Copyright (c) 2001 Bruno Barberi Gnecco <brunobg@lsi.usp.br>
00003  *
00004  * Permission is hereby granted, free of charge, to any person obtaining a copy
00005  * of this software and associated documentation files (the "Software"), to
00006  * deal in the Software without restriction, including without limitation the
00007  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
00008  * sell copies of the Software, and to permit persons to whom the Software is
00009  * furnished to do so, subject to the following conditions:
00010  *
00011  * The above copyright notice and this permission notice shall be included in
00012  * all copies of the Software, its documentation and marketing & publicity
00013  * materials, and acknowledgment shall be given in the documentation, materials
00014  * and software packages that this Software was used.
00015  *
00016  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00017  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00018  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
00019  * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
00020  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00021  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00022  */
00023 
00024 /* internal data */
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         /* server only */
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         /* client only */
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 /* initialization */
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 /*net*/
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 /* utils */
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 

Generated at Sun Dec 9 16:13:18 2001 for dicelib by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001