Main Page   Compound List   File List   Compound Members   File Members  

_dicelib.h File Reference

Internal header. More...

#include <stdio.h>
#include <stdlib.h>
#include "dicelib.h"

Go to the source code of this file.

Compounds

struct  _dice_data
 Internal data. More...

struct  _dice_data::_clients
union  _dice_packet
 Packet structure. More...


Internal functions

#define dice_is_server()   (dice_data.clientnum != -1)
int dice_type_init_defaults (void)
void dice_type_free_all (void)
int dice_sync_init (void)
 Initializes synchronous variables.

void dice_sync_end (void)
 Frees synchronous variables.

int dice_async_init (void)
void dice_async_end (void)
int dice_init_client (void)
 Initialize this machine as client ("server"). More...

void dice_sync_update_send (void)
 Send all updates. More...

int dice_packet_send (dice_packet *p, int sock)
 Sends a packet to a list of sockets. More...

dice_packet dice_packet_get (int sock)
int dice_broadcast (dice_packet *packet, int except)
 Broadcast packet. More...

int dice_control_loop (int argc, char **argv)
int dice_type_register (DICE_Type *t)
 Registers a new variable type. More...

int dice_control_hierarchy (int a, int b)
 Which of the sockets has a higher patent. More...

void dice_free (void *data)
char * dice_packet_name (dice_packet_type t)
void dice_printf (char *function, char *format,...)
 Our own printf. Formats a string to be printed with colors (using dice_data.color[]), sends to dice_data.error, etc. More...

int dice_type_is_valid (char *name)
char * defaultpath

Defines

#define _dice_debug(l, c)   if ( l <= dice_data.verbose ) c
 Debug macro. More...


Typedefs

typedef enum _dice_packet_type dice_packet_type
 Typedef encapsulation.

typedef _dice_packet dice_packet
 Typedef encapsulation.


Enumerations

enum  _dice_packet_type {
  INVALID, SYNC, VARIABLE_ASYNC, VARIABLE_SYNC,
  VARIABLE_FREE_ASYNC, VARIABLE_FREE_SYNC, READY, CONTINUE,
  HELLO, GOODBYE
}
 Packet types. More...


Variables

_dice_data dice_data
 Internal data structure declaration.


Detailed Description

Internal header.

Definition in file _dicelib.h.


Define Documentation

#define _dice_debug l, c    if ( l <= dice_data.verbose ) c
 

Debug macro.

Parameters:
l   verbose level.
c   any command.

Definition at line 46 of file _dicelib.h.


Enumeration Type Documentation

enum _dice_packet_type
 

Packet types.

Enumeration values:
INVALID   Invalid packet.
SYNC   SYNC packet.
VARIABLE_ASYNC   Asynchronous VARIABLE packet.
VARIABLE_SYNC   Synchronous VARIABLE packet.
VARIABLE_FREE_ASYNC   Asynchronous FREE_VARIABLE packet.
VARIABLE_FREE_SYNC   Synchronous FREE_VARIABLE packet.
READY   READY packet.
CONTINUE   CONTINUE packet.
HELLO   HELLO packet.
GOODBYE   GOODBYE packet.

Definition at line 83 of file _dicelib.h.


Function Documentation

int dice_broadcast dice_packet * packet,
int except
 

Broadcast packet.

Broadcasts a packet to all clients, or to all except one.

Parameters:
packet   The packet.
except   Except to this socket; if -1, broadcast to all.
Return values:
0   OK
-1   error.

Definition at line 59 of file control.c.

int dice_control_hierarchy int a,
int b
 

Which of the sockets has a higher patent.

Parameters:
a   Socket a.
b   Socket b.
Return values:
0   a has priority.
1   b has priority.
-1   error.

Definition at line 119 of file control.c.

int dice_init_client void
 

Initialize this machine as client ("server").

Automatically called by DICE_init.

Return values:
0   OK
-1   error.

Definition at line 119 of file client.c.

int dice_packet_send dice_packet * p,
int socket
 

Sends a packet to a list of sockets.

Sends a packet to a list of sockets. All sockets must be already opened.

Parameters:
p   A pointer to the packet.
socket   The socket to send to.
Warning:
Maximum packet size is 16384 bytes.
Return values:
0   OK
-1   error.

Definition at line 53 of file net.c.

void dice_printf char * function,
char * format,
...
 

Our own printf. Formats a string to be printed with colors (using dice_data.color[]), sends to dice_data.error, etc.

Parameters:
function   The function name, may be NULL.
format   A printf-like format string.
...   Other arguments.

Definition at line 448 of file init.c.

void dice_sync_update_send void
 

Send all updates.

Long description

Definition at line 134 of file sync.c.

int dice_type_register DICE_Type * t
 

Registers a new variable type.

This functions registers a new variable type name. You should have in your executable or some library it's linked to these three functions:

  • char *[type]_pack (void *data, int *n);
  • void *[type]_unpack (char *data, int *n);
  • void [type]_free (void *data);
where [type] is the type you are registering. Example: if you are registering the type "FOO", you must provide FOO_pack, FOO_unpack and FOO_free. These functions are responsible, respectively, for packing the data it into a string, converting a packed string into data, and freeing the data.

Variable types are case sensitive.

You should (but don't have to) follow RFC 1014 (XDR: External Data Representation Standard) to pack and unpack data, assuring portability.

DICE supports by default the following types:

  • "unsigned_char"
  • "signed_char"
  • "unsigned_short"
  • "signed_short"
  • "unsigned_long"
  • "signed_long"
  • "float"
  • "double"
  • "string"
all use pointers to store the data, so pass by reference.
Parameters:
type   Variable type name.
See also:
DICE_async_new, DICE_sync_new.
Return values:
0   if OK.
-1   if error.

Definition at line 147 of file type.c.


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