GZCore ggzcore.h(3)
NAME
ggzcore.h - The interface for the ggzcore library used by
GZ clients.
SYNOPSIS
#include
#include
#include
Defines
#define GZCOREVERSIONMAJOR 0
#define GZCOREVERSIONMINOR 0
#define GZCOREVERSIONMICRO 11
#define GZCOREVERSIONIFACE '7:0:0'
#define GZCOREDBGCONF 'GZCORE:CONF'
ggzdebug debugging type for configuration system.
#define GZCOREDBGAME 'GZCORE:GAME'
ggzdebug debugging type for game communication.
#define GZCOREDBGHOK 'GZCORE:HOK'
ggzdebug debugging type for hook system.
#define GZCOREDBGMODULE 'GZCORE:MODULE'
ggzdebug debugging type for accessing modules.
#define GZCOREDBGNET 'GZCORE:NET'
ggzdebug debugging type for network interaction.
#define GZCOREDBGPOL 'GZCORE:POL'
ggzdebug debugging type for debugging while polling.
#define GZCOREDBGROM 'GZCORE:ROM'
ggzdebug debugging type for room events and data.
#define GZCOREDBGSERVER 'GZCORE:SERVER'
ggzdebug debugging type for server events and data.
#define GZCOREDBGSTATE 'GZCORE:STATE'
ggzdebug debugging type for state changes.
#define GZCOREDBGTABLE 'GZCORE:TABLE'
ggzdebug debugging type for table data.
#define GZCOREDBGXML 'GZCORE:XML'
ggzdebug debugging type for XML processing.
#define ggzcoreservergetchannel(server) (-1)
Deprecated function. Do not use.
#define ggzcoreservercreatechannel(server) (void)0
Deprecated function. Do not use.
#define ggzcoremodulelaunch(m) ((int)(-1))
#define ggzcoregamesetserverfd(game, fd) (void)0
Deprecated function. Do not use.
Typedefs
typedef GZOptions GZOptions
typedef GZHookReturn(* GZHookFunc )(unsigned int id, const
void *eventdata, const void *userdata)
typedef void(* GZDestroyFunc )(void *data)
GZ object destroy function type.
typedef GZServer GZServer
Version 0.0.11 Last change: 21 May 2005 1
GZCore ggzcore.h(3)
A server object containing all information about a
connection.
typedef GZRoom GZRoom
Contains information about a single room on a server.
typedef GZPlayer GZPlayer
Contains information about a single player.
typedef GZTable GZTable
Contains information about a single table.
typedef GZGameType GZGameType
Contains information about a game type.
typedef GZModule GZModule
Contains information about a single module. A game
module, on the client, is an executable designed to play
a game. Each game type may have many modules that play
it.
typedef GZGame GZGame
Contains information about a single game table. This
contains information about a table we are present at or
are about to launch. It is thus associated with both a
GZTable and a GZModule.
Enumerations
enum GZOptionFlags { GZOPTPARSER = 0x0001,
GZOPTMODULES = 0x0002, GZOPTHREADEDIO =
0x0004, GZOPTEMBEDED = 0x0008, GZOPTRECONECT =
0
enum GZHookReturn { GZHOKOK, GZHOKREMOVE,
GZHOKEROR, GZHOKCRISIS }
enum GZLoginType { GZLOGIN, GZLOGINGUEST,
GZLOGINEW }
enum GZServerEvent { GZCONECTED, GZCONECTFAIL,
GZNEGOTIATED, GZNEGOTIATEFAIL, GZLOGEDIN,
GZLOGINFAIL, GZMOTDLOADED, G
enum GZRoomEvent { GZPLAYERLIST, GZTABLELIST,
GZCHATEVENT, GZROMENTER, GZROMLEAVE,
GZTABLEUPDATE, GZTABLELAUNCHED, G
enum GZGameEvent { GZGAMELAUNCHED, GZGAMELAUNCHFAIL,
GZGAMENEGOTIATED, GZGAMENEGOTIATEFAIL,
GZGAMEPLAYING }
enum GZStateID { GZSTATEOFLINE, GZSTATECONECTING,
GZSTATERECONECTING, GZSTATEONLINE,
GZSTATELOGINGIN, GZSTATELOGEDIN, GZ
The states a server connection may be in.
enum GZModuleEnvironment { GZENVIRONMENTPASIVE,
GZENVIRONMENTCONSOLE, GZENVIRONMENTFRAMEBUFER,
GZENVIRONMENTXWINDOW, GZENVIRONMENTXFULSCREN
The environment a game frontend expects.
Functions
int ggzcoreinit (GZOptions options)
void ggzcorereload (void)
void ggzcoredestroy (void)
Version 0.0.11 Last change: 21 May 2005 2
GZCore ggzcore.h(3)
GZServer * ggzcoreservernew (void)
Create a new server object.
int ggzcoreserverreset (GZServer *server)
Reset the server object.
int ggzcoreserveraddeventhook (GZServer *server, const
GZServerEvent event, const GZHookFunc func)
Register a callback handler for a server event.
int ggzcoreserveraddeventhookfull (GZServer *server,
const GZServerEvent event, const GZHookFunc func,
const void *data)
Register a callback handler for a server event.
int ggzcoreserverremoveeventhook (GZServer *server,
const GZServerEvent event, const GZHookFunc func)
Remove a single hook function from an event's hook list.
int ggzcoreserverremoveeventhookid (GZServer *server,
const GZServerEvent event, const unsigned int hookid)
Remove a hook function with given ID from the event's
hook list.
int ggzcoreserversethostinfo (GZServer *server, const
char *host, const unsigned int port, const unsigned int
usetls)
Set host info for connecting to the server.
int ggzcoreserversetlogininfo (GZServer *server, const
GZLoginType type, const char *handle, const char
*password, const char *email)
Set login info for logging in to the server.
int ggzcoreserverlogsession (GZServer *server, const
char *filename)
Initiate logging of ggzcore events.
const char * ggzcoreservergethost (const GZServer
*server)
Get the hostname of the server.
int ggzcoreservergetport (const GZServer *server)
Get the port of the server.
GZLoginType ggzcoreservergettype (const GZServer
*server)
Get the login type being used for this server.
const char * ggzcoreservergethandle (const GZServer
*server)
Get the handle being used for this server.
const char * ggzcoreservergetpassword (const GZServer
*server)
Get the password being used for this server.
int ggzcoreservergetfd (const GZServer *server)
Get the socket used for connection with the server.
GZStateID ggzcoreservergetstate (const GZServer
*server)
Get the state of the server connection.
int ggzcoreservergettls (const GZServer *server)
Get the current TLS status of this server.
int ggzcoreservergetnumplayers (const GZServer *server)
Get the total number of players on the server.
Version 0.0.11 Last change: 21 May 2005 3
GZCore ggzcore.h(3)
int ggzcoreservergetnumrooms (const GZServer *server)
Return the number of rooms on the server, or -1 on
error.
GZRoom * ggzcoreservergetcurroom (const GZServer
*server)
Return the current room, or NUL if there is none.
GZRoom * ggzcoreservergetnthroom (const GZServer
*server, const unsigned int num)
Return the nth room on the server, or NUL on error.
int ggzcoreservergetnumgametypes (const GZServer
*server)
Return the overall number of game types on the server.
GZGameType * ggzcoreservergetnthgametype (const
GZServer *server, const unsigned int num)
Get the nth gametype, or NUL on error.
GZGame * ggzcoreservergetcurgame (const GZServer
*server)
Return the player's current game.
int ggzcoreserverisonline (const GZServer *server)
Return TRUE iff the server is online (connected?).
int ggzcoreserverisloggedin (const GZServer *server)
Return TRUE iff we are logged into the server.
int ggzcoreserverisinroom (const GZServer *server)
Return TRUE iff we are in a room on the server.
int ggzcoreserverisattable (const GZServer *server)
Return TRUE iff we are at a table on the server.
int ggzcoreserverconnect (GZServer *server)
Connect to the server.
int ggzcoreserverlogin (GZServer *server)
Log in to the server.
int ggzcoreservermotd (GZServer *server)
Request the MOTD from the server.
int ggzcoreserverlistrooms (GZServer *server, const int
type, const char verbose)
Request room list.
int ggzcoreserverlistgametypes (GZServer *server, const
char verbose)
Request game type list.
int ggzcoreserverjoinroom (GZServer *server, const
unsigned int room)
Join a room on the server.
int ggzcoreserverlogout (GZServer *server)
Log out of a server.
int ggzcoreserverdisconnect (GZServer *server)
Disconnect from a server after having logged out.
int ggzcoreserverdataispending (GZServer *server)
Check for data pending from the server socket.
int ggzcoreserverreaddata (GZServer *server, int fd)
Read data for the server on the specified FD.
void ggzcoreserverfree (GZServer *server)
Free GZServer object and accompanying data.
GZRoom * ggzcoreroomnew (void)
Version 0.0.11 Last change: 21 May 2005 4
GZCore ggzcore.h(3)
Allocate space for a new room object.
int ggzcoreroominit (GZRoom *room, GZServer *server,
const unsigned int id, const char *name, const unsigned
int game, const char *desc)
Initialize room object.
void ggzcoreroomfree (GZRoom *room)
De-allocate room object and its children.
GZServer * ggzcoreroomgetserver (GZRoom *room)
Return the server for this room (or NUL on error).
int ggzcoreroomgetid (const GZRoom *room)
Return the ID number of the room (or negative on error).
char * ggzcoreroomgetname (GZRoom *room)
Return the name of the room (or NUL on error).
char * ggzcoreroomgetdesc (GZRoom *room)
Return the description of the room (or NUL on error).
GZGameType * ggzcoreroomgetgametype (GZRoom *room)
Return the type of game played in this room (or NUL on
error).
int ggzcoreroomgetnumplayers (GZRoom *room)
Return the number of players in the room (or negative on
error).
GZPlayer * ggzcoreroomgetnthplayer (GZRoom *room,
const unsigned int num)
Return the nth player in the room (or NUL on error).
int ggzcoreroomgetnumtables (GZRoom *room)
Return the number of tables in the room (or negative on
error).
GZTable * ggzcoreroomgetnthtable (GZRoom *room, const
unsigned int num)
Return the nth table in the room (or NUL on error).
GZTable * ggzcoreroomgettablebyid (GZRoom *room,
const unsigned int id)
Return the table in this room with matching ID (NUL on
error).
int ggzcoreroomaddeventhook (GZRoom *room, const
GZRoomEvent event, const GZHookFunc func)
Register a handler (hook) for the room event.
int ggzcoreroomaddeventhookfull (GZRoom *room, const
GZRoomEvent event, const GZHookFunc func, const void
*data)
Register a handler (hook) for thee room event, with
data.
int ggzcoreroomremoveeventhook (GZRoom *room, const
GZRoomEvent event, const GZHookFunc func)
Remove a hook from an event.
int ggzcoreroomremoveeventhookid (GZRoom *room, const
GZRoomEvent event, const unsigned int hookid)
Remove a hook from an event, by ID.
int ggzcoreroomlistplayers (GZRoom *room)
Call to request a list of players in the room.
int ggzcoreroomlisttables (GZRoom *room, const int type,
const char global)
Version 0.0.11 Last change: 21 May 2005 5
GZCore ggzcore.h(3)
Call to request a list of tables in the room.
int ggzcoreroomchat (GZRoom *room, const GZChatType
opcode, const char *player, const char *msg)
Chat!
int ggzcoreroomlaunchtable (GZRoom *room, GZTable
*table)
Launch a table in the room.
int ggzcoreroomjointable (GZRoom *room, const unsigned
int tableid, int spectator)
Join a table in the room, so that you can then play at
it.
int ggzcoreroomleavetable (GZRoom *room, int force)
Leave the table you are currently playing at.
char * ggzcoreplayergetname (const GZPlayer *player)
Return the name of the player.
GZPlayerType ggzcoreplayergettype (const GZPlayer
*player)
Return the type of the player (admin/registered/guest).
GZRoom * ggzcoreplayergetroom (const GZPlayer *player)
Return the player's room, or NUL if none.
GZTable * ggzcoreplayergettable (const GZPlayer
*player)
Return the player's table, or NUL if none.
int ggzcoreplayergetlag (const GZPlayer *player)
Return the player's lag class (1..5).
int ggzcoreplayergetrecord (const GZPlayer *player, int
*wins, int *losses, int *ties, int *forfeits)
Get the player's win-loss record.
int ggzcoreplayergetrating (const GZPlayer *player, int
*rating)
Get the player's rating.
int ggzcoreplayergetranking (const GZPlayer *player, int
*ranking)
Get the player's ranking.
int ggzcoreplayergethighscore (const GZPlayer *player,
int *highscore)
Get the player's highscore.
GZTable * ggzcoretablenew (void)
Create a new table object.
int ggzcoretableinit (GZTable *table, const GZGameType
*gametype, const char *desc, const unsigned int
numseats)
Set data on a table object.
void ggzcoretablefree (GZTable *table)
Free the table object.
int ggzcoretablesetseat (GZTable *table, const unsigned
int seat, GZSeatType type, const char *name)
Set a seat type at a table, pre-launch.
int ggzcoretableremoveplayer (GZTable *table, char
*name)
Find and remove the player from the table.
int ggzcoretablegetid (const GZTable *table)
Version 0.0.11 Last change: 21 May 2005 6
GZCore ggzcore.h(3)
Return the ID of the table.
const GZRoom * ggzcoretablegetroom (const GZTable
*table)
Return the room this table is in.
const GZGameType * ggzcoretablegettype (const GZTable
*table)
Return the game type of the table.
const char * ggzcoretablegetdesc (const GZTable *table)
Return the table's description (or NUL).
GZTableState ggzcoretablegetstate (const GZTable
*table)
Return the state of the table.
int ggzcoretablegetnumseats (const GZTable *table)
Return the number of seats at the table.
int ggzcoretablesetdesc (GZTable *table, const char
*desc)
Set the table description.
int ggzcoretablegetseatcount (const GZTable *table,
GZSeatType type)
Count the seats of the given type.
const char * ggzcoretablegetnthplayername (const
GZTable *table, const unsigned int num)
Return the name of a player at the table, or NUL on
error.
int ggzcoretablegetnumspectatorseats (const GZTable
*table)
Return the number of spectator seats at the table, or
-1.
const char * ggzcoretablegetnthspectatorname (const
GZTable *table, const unsigned int num)
Return the name of the nth spectator, or NUL if seat is
empty.
GZSeatType ggzcoretablegetnthplayertype (const
GZTable *table, const unsigned int num)
Return the type of a player at the table, or
GZPLAYERNONE on error.
unsigned int ggzcoregametypegetid (const GZGameType
*type)
Get the ID of this gametype.
const char * ggzcoregametypegetname (const GZGameType
*type)
Get the name of the game type.
const char * ggzcoregametypegetprotengine (const
GZGameType *type)
Get the protocol 'engine' used by the game type.
const char * ggzcoregametypegetprotversion (const
GZGameType *type)
Get the version of the protocol the game uses.
const char * ggzcoregametypegetversion (const GZGameType
*type)
Get the version of the game itself.
const char * ggzcoregametypegetauthor (const GZGameType
Version 0.0.11 Last change: 21 May 2005 7
GZCore ggzcore.h(3)
*type)
Get the author of the game.
const char * ggzcoregametypegeturl (const GZGameType
*type)
Get a URL for more info about the game.
const char * ggzcoregametypegetdesc (const GZGameType
*type)
Get a description of the game.
int ggzcoregametypegetmaxplayers (const GZGameType
*type)
Get the maximum number of players the game can support.
int ggzcoregametypegetmaxbots (const GZGameType *type)
Get the maximum number of bots the game can support.
int ggzcoregametypegetspectatorsallowed (const
GZGameType *type)
Return TRUE iff spectators are allowed for this game
type.
int ggzcoregametypenumplayersisvalid (const GZGameType
*type, unsigned int num)
Return TRUE iff the given number of players is valid.
int ggzcoregametypenumbotsisvalid (const GZGameType
*type, unsigned int num)
Return TRUE iff the given number of bots is valid.
int ggzcoreconfinitialize (const char *gpath, const char
*upath)
int ggzcoreconfwritestring (const char *section, const
char *key, const char *value)
int ggzcoreconfwriteint (const char *section, const char
*key, int value)
int ggzcoreconfwritelist (const char *section, const char
*key, int argc, char **argv)
char * ggzcoreconfreadstring (const char *section, const
char *key, const char *def)
int ggzcoreconfreadint (const char *section, const char
*key, int def)
int ggzcoreconfreadlist (const char *section, const char
*key, int *argcp, char ***argvp)
int ggzcoreconfremovesection (const char *section)
int ggzcoreconfremovekey (const char *section, const char
*key)
int ggzcoreconfcommit (void)
unsigned int ggzcoremodulegetnum (void)
This returns the number of registered modules.
int ggzcoremoduleadd (const char *name, const char
*version, const char *protengine, const char
*protversion, const char *author, const char *frontend,
const char *url, const char *e
int ggzcoremodulegetnumbytype (const char *game, const
char *engine, const char *version)
Returns how many modules support this game and protocol.
GZModule * ggzcoremodulegetnthbytype (const char
*game, const char *engine, const char *version, const
Version 0.0.11 Last change: 21 May 2005 8
GZCore ggzcore.h(3)
unsigned int num)
Returns n-th module that supports this game and
protocol.
const char * ggzcoremodulegetname (GZModule *module)
Return the name of the module.
const char * ggzcoremodulegetversion (GZModule *module)
Return the (game?) version of the module.
const char * ggzcoremodulegetprotengine (GZModule
*module)
Return the name of the module's protocol engine.
const char * ggzcoremodulegetprotversion (GZModule
*module)
Return the version of the module's protocol engine.
const char * ggzcoremodulegetauthor (GZModule *module)
Return the author of the module.
const char * ggzcoremodulegetfrontend (GZModule *module)
Return the module's frontend type.
const char * ggzcoremodulegeturl (GZModule *module)
Return the URL associated with the module.
const char * ggzcoremodulegeticonpath (GZModule
*module)
const char * ggzcoremodulegethelppath (GZModule
*module)
Return the help path of the module (?).
char ** ggzcoremodulegetargv (GZModule *module)
Return the executable arguments for the module. See
exec().
GZModuleEnvironment ggzcoremodulegetenvironment
(GZModule *module)
Return the preferred environment type.
GZGame * ggzcoregamenew (void)
Make a new game object.
int ggzcoregameinit (GZGame *game, GZServer *server,
GZModule *module)
Initialize the game object.
void ggzcoregamefree (GZGame *game)
Free the game object.
int ggzcoregameaddeventhook (GZGame *game, const
GZGameEvent event, const GZHookFunc func)
Register a hook for a game event.
int ggzcoregameaddeventhookfull (GZGame *game, const
GZGameEvent event, const GZHookFunc func, const void
*data)
Register a hook for a game event.
int ggzcoregameremoveeventhook (GZGame *game, const
GZGameEvent event, const GZHookFunc func)
Remove a hook from a game event.
int ggzcoregameremoveeventhookid (GZGame *game, const
GZGameEvent event, const unsigned int hookid)
Remove a specified hook from a game event.
int ggzcoregamegetcontrolfd (GZGame *game)
Return the control (ggzmod) socket for the game.
Version 0.0.11 Last change: 21 May 2005 9
GZCore ggzcore.h(3)
GZModule * ggzcoregamegetmodule (GZGame *game)
Return the module set for the game.
int ggzcoregamelaunch (GZGame *game)
Launch thee game!
int ggzcoregamereaddata (GZGame *game)
Read data from the game. When data is pending on the
control socket, call this function.
Detailed Description
The interface for the ggzcore library used by GZ clients.
Define Documentation
#define ggzcoremodulelaunch(m) ((int)(-1))
This attempts to launch the specified module and returns 0
if successful or -1 on error.
Typedef Documentation
typedef void(* GZDestroyFunc)(void *data)
GZ object destroy function type.
Todo
This is not currently used.
typedef struct GZGameType GZGameType
Contains information about a game type.
Note:
Each room has one game type; a game may be used in
multiple rooms.
typedef GZHookReturn(* GZHookFunc)(unsigned int id, const
void *eventdata, const void *userdata)
GZ Event hook function type, used as a vallback for events
typedef struct GZOptions GZOptions
Options structure for ggzcore library
Enumeration Type Documentation
enum GZGameEvent
A GZGameEvent is an event associated with the game, that is
triggered by a communication from the server or from the
game. When a game event occurs, the associated event handle
will be called, and will be passed the event data (a void*)
along with the (optional) user data. All game events apply
to the current game. Game events are usually triggered by
calling ggzcoreserverreaddata or ggzcoregamereaddata.
See also:
ggzcoregameaddeventhook
Version 0.0.11 Last change: 21 May 2005 10
GZCore ggzcore.h(3)
ggzcoreserverreaddata
Enumeration values:
GZGAMELAUNCHED
A game was launched by the player (you). After this the
core client should call ggzcoregamegetcontrolfd,
monitor the socket that function returns, and call
ggzcoregamereaddata when there is data pending. This
event is triggered inside of ggzcoregamelaunch.
Parameters:
data NUL
See also:
ggzcoregamelaunch
GZGAMELAUNCHFAIL
Your game launch has failed. Triggered instead of
GZGAMELAUNCHED when there's a failure somewhere.
Parameters:
data NUL
See also:
GZGAMELAUNCHED
GZGAMENEGOTIATED
Negotiation with server was successful. This should
happen some time after the launch succeeds. The core
client need do nothing at this point.
Parameters:
data NUL
GZGAMENEGOTIATEFAIL
Negotiation was not successful, game launch failed.
Todo
Currently this can't actually happen...
GZGAMEPLAYING
Game reached the 'playing' state. When this happens the
core client should call ggzcoreroomlaunchtable or
ggzcoreroomjointable to finalize the game join.
Parameters:
data NUL
enum GZHookReturn
GZ Hook function return types
Version 0.0.11 Last change: 21 May 2005 11
GZCore ggzcore.h(3)
Enumeration values:
GZHOKOK
Success!
GZHOKREMOVE
Remove this hook immediately.
GZHOKEROR
A localized error.
GZHOKCRISIS
A major error; stop processing the event.
enum GZLoginType
This controls the type of login a user chooses. A different
value will require different information to be sent to the
server.
Enumeration values:
GZLOGIN
Standard login; uname and correct passwd needed.
GZLOGINGUEST
Guest login; only a uname is required.
GZLOGINEW
New user login; only a uname is required. Password will
be assigned by the server (but can be passed along).
enum GZModuleEnvironment
The environment a game frontend expects.
Core clients should offer those game modules which fit their
own environment.
Enumeration values:
GZENVIRONMENTPASIVE
No GUI, no interaction with user
GZENVIRONMENTCONSOLE
Text console
GZENVIRONMENTFRAMEBUFER
VESA or framebuffer
GZENVIRONMENTXWINDOW
X11 windowed mode (default)
GZENVIRONMENTXFULSCREN
Version 0.0.11 Last change: 21 May 2005 12
GZCore ggzcore.h(3)
X11 fullscreen mode
enum GZOptionFlags
Enumeration values:
GZOPTMODULES
Load the default configuration file (unused).
GZOPTHREADEDIO
Load the game module list.
GZOPTEMBEDED
Provide multi-threaded network IO (unused).
GZOPTRECONECT
Reconnect automatically after connection loss.
enum GZRoomEvent
A GZRoomEvent is an event associated with the room, that is
triggered by a communication from the server. When a room
event occurs, the associated event handler will be called,
and will be passed the event data (a void*), along with the
(optional) user data. All room events apply to the current
room unless a room number is given. Room events are almost
always triggered by calling ggzcoreserverreaddata.
See also:
ggzcoreroomaddeventhook
ggzcoreserverreaddata
Enumeration values:
GZPLAYERLIST
The list of players in a room has arrived.
Parameters:
data The room id (int *)
Note:
This will only be issued for the current room.
See also:
ggzcoreroomlistplayers
GZTABLELIST
Received the list of active tables.
Parameters:
data NUL
Version 0.0.11 Last change: 21 May 2005 13
GZCore ggzcore.h(3)
See also:
ggzcoreroomlisttables
GZCHATEVENT
Received a chat message of any kind. This can happen at
any time when you're in a room.
Parameters:
data The GZChatEventData associated with the chat.
See also:
GZChatEventData
GZROMENTER
A player has entered the room with you.
Parameters:
data A GZRoomChangeEventData structure.
GZROMLEAVE
A player has left your room.
Parameters:
data A GZRoomChangeEventData structure.
GZTABLEUPDATE
One of the tables in the current room has changed.
Todo
How are you supposed to know which table has changed?
Parameters:
data NUL
GZTABLELAUNCHED
The table you tried to launch has launched!
See also:
ggzcoreroomlaunchtable
Parameters:
data NUL
GZTABLELAUNCHFAIL
The table you tried to launch couldn't be launched
See also:
GZTABLELAUNCHED
Parameters:
data A pointer to a GZErrorEventData
Version 0.0.11 Last change: 21 May 2005 14
GZCore ggzcore.h(3)
GZTABLEJOINED
Your table join attempt has succeeded.
See also:
ggzcoreroomjointable
Parameters:
data The table index (int*) of the table we joined.
GZTABLEJOINFAIL
Joining a table did not succeed.
See also:
GZTABLEJOINED
Parameters:
data A helpful error string.
GZTABLELEFT
You have successfully left the table you were at.
See also:
ggzcoreroomleavetable
Parameters:
data The GZTableLeaveEventData associated with the
leave.
See also:
GZTableLeaveEventData
GZTABLELEAVEFAIL
Your attempt to leave the table has failed.
See also:
GZTABLELEFT
Parameters:
data A helpful error string.
GZPLAYERLAG
A player's lag (measure of connection speed) has been
updated
See also:
ggzcoreplayergetlag
Parameters:
data The name of the player whose lag has changed.
GZPLAYERSTATS
A player's stats have been updated.
Version 0.0.11 Last change: 21 May 2005 15
GZCore ggzcore.h(3)
See also:
GZPLAYERLIST
ggzcoreplayergetrecord
ggzcoreplayergetrating
ggzcoreplayergetranking
ggzcoreplayergethighscore
Parameters:
data The name of the player whose stats have changed.
GZPLAYERCOUNT
The number of players in a room has arrived.
Parameters:
data The room id (int *)
enum GZServerEvent
A GZServerEvent is an event triggered by a communication
from the server. Each time an event occurs, the associated
event handler will be called, and will be passed the event
data (a void*). Most events are generated as a result of
ggzcoreserverreaddata.
See also:
ggzcoreserveraddeventhook
Enumeration values:
GZCONECTED
We have just made a connection to the server. After
this point the server's socket should be accessible and
should be monitored for data. It happens in direct
response to ggzcoreserverconnect. Note that most
events after this will only happen by calling
ggzcoreserverreaddata on the server's FD!
Parameters:
data NUL
See also:
ggzcoreserverconnect
GZCONECTFAIL
Error: we have failed to connect to the server. This is
generated in place of GZCONECTED if the connection
could not be made. The server object is otherwise
unaffected.
Version 0.0.11 Last change: 21 May 2005 16
GZCore ggzcore.h(3)
Parameters:
data An error string (created by strerror)
See also:
ggzcoreserverconnect
GZNEGOTIATED
We have negotiated a connection to the server. This
will happen automatically once a connection has been
established, if the server socket is monitored.
Note:
This just means we've determined ggzd is at the other
end.
Parameters:
data NUL
See also:
ggzcoreserverreaddata
GZNEGOTIATEFAIL
Error: negotiation failure. Could be the wrong version.
This will happen in place of a GZNEGOTIATED if the
server could not be negotiated with.
Parameters:
data A useless error string.
See also:
ggzcoreserverreaddata
GZLOGEDIN
We have successfully logged in. We can now start doing
stuff. This will not happen until the client sends
their login information.
See also:
ggzcoreserverlogin
Parameters:
data NUL
See also:
ggzcoreserverreaddata
GZLOGINFAIL
Error: login failure. This will happen in place of
GZLOGEDIN if the login failed. The server object
will be otherwise unaffected.
Version 0.0.11 Last change: 21 May 2005 17
GZCore ggzcore.h(3)
Parameters:
data A pointer to a GZErrorEventData.
See also:
GZErrorEventData
ggzcoreserverreaddata
GZMOTDLOADED
The MOTD has been read from the server and can be
displayed. The server will send us the MOTD
automatically after login; it can also be requested by
ggzcoreservermotd. It is up to the client whether or
not to display it. See the online documentation
(somewhere?) about the MOTD markup format.
Parameters:
data Pointer to a GZMotdEventData including the full
MOTD text.
See also:
ggzcoreservermotd
Todo
The MOTD cannot be accessed outside of this event
See also:
ggzcoreserverreaddata!
GZROMLIST
The room list arrived. This will only happen after the
list is requested by ggzcoreserverlistrooms(). The
list may be accessed through
ggzcoreservergetnumrooms() and
ggzcoreservergetnthroom(). Until this event arrives
these functions will be useless!
Parameters:
data NUL
See also:
ggzcoreserverreaddata
GZTYPELIST
The list of game types is available. This will only
happen after the list is requested by
ggzcoreserverlisttypes(). The list may be accessed
through ggzcoreservergetnumgametypes() and
ggzcoreservergetnthgametype(). Until this event
arrives these functions will be useless!
Version 0.0.11 Last change: 21 May 2005 18
GZCore ggzcore.h(3)
Parameters:
data NUL
See also:
ggzcoreserverreaddata
GZSERVERPLAYERSCHANGED
The number of players on the server has changed. This
event is issued rather frequently every time players
enter or leave.
Parameters:
data NUL
See also:
ggzcoreservergetnumplayers
ggzcoreserverreaddata
GZENTERED
We have successfully entered a room. This will be
issued to tell us a room join has succeeded, after it
has been requested.
Parameters:
data NUL
See also:
ggzcoreserverjoinroom
ggzcoreserverreaddata
GZENTERFAIL
Error: we have tried to enter a room and failed. This
will be issued to tell us a room join has failed.
Parameters:
data A pointer to a GZErrorEventData.
See also:
GZErrorEventData
ggzcoreserverjoinroom
ggzcoreserverreaddata
GZLOGOUT
Logged out of the server. This will happen when the
server completes the communication; usually after
ggzcorenetsendlogout is called.
Version 0.0.11 Last change: 21 May 2005 19
GZCore ggzcore.h(3)
Parameters:
data NUL
See also:
ggzcoreserverreaddata
GZNETEROR
Error: a network (transmission) error occurred. The
server will automatically disconnect.
Parameters:
data A generally unhelpful error string.
See also:
ggzcoreserverreaddata
GZPROTOCOLEROR
Error: a communication protocol error occured. This can
happen in a variety of situations when the server sends
us something we can't handle. The server will be
automatically disconnected.
Parameters:
data A technical error string.
See also:
ggzcoreserverreaddata
GZCHATFAIL
Error: A chat message could not be sent. This will
happen when we try to send a chat and the server
rejects it.
Parameters:
data A pointer to a GZErrorEventData.
See also:
GZErrorEventData
ggzcoreserverreaddata
GZSTATECHANGE
The internal state of ggzcore has changed. This may
happen at any time.
Parameters:
data NUL
See also:
GZStateID
Version 0.0.11 Last change: 21 May 2005 20
GZCore ggzcore.h(3)
ggzcoreservergetstate
GZCHANELCONECTED
Status event: a requested direct game connection has
been established. To start a game (table), a channel
must be created. This event will alert that the channel
has been established. The channel's FD should then be
monitored for input, which should then be passed back
to the server object for handling.
Parameters:
data NUL
Note:
This event is deprecated and should not be used.
See also:
ggzcoreservergetchannel
ggzcoreserverreaddata
GZCHANELREADY
Game channel is ready for read/write operations. After
the channel has been connected, if we continue to
monitor the socket eventually it will be negotiated and
ready to use. At this point it is ready for the game
client to use.
Parameters:
data NUL
Note:
This event is deprecated and should not be used.
See also:
ggzcoreserverreaddata
GZCHANELFAIL
Error: Failure during setup of direct connection to
game server. If the channel could not be prepared, this
event will happen instead of GZCHANELREADY or
GZCHANELCONECTED event. At this point the channel
is no longer useful (I think).
Parameters:
data An unhelpful error string
Note:
This event is deprecated and should not be used.
See also:
ggzcoreserverreaddata
Version 0.0.11 Last change: 21 May 2005 21
GZCore ggzcore.h(3)
GZNUMSERVEREVENTS
Terminator. Do not use.
enum GZStateID
The states a server connection may be in.
On the client side, a simplistic state maching is used to
tell what's going on. A game client should usually consult
the current state when determining what actions are
possible.
Enumeration values:
GZSTATEOFLINE
Not connected (at all)
GZSTATECONECTING
In the process of connecting.
GZSTATERECONECTING
Continuous reconnection attempts.
GZSTATEONLINE
Connected, but not doing anything.
GZSTATELOGINGIN
In the process of logging in.
GZSTATELOGEDIN
Online and logged in!
GZSTATENTERINGROM
Moving into a room.
GZSTATEINROM
Online, logged in, and in a room.
GZSTATEBETWENROMS
Moving between rooms.
GZSTATELAUNCHINGTABLE
Trying to launch a table.
GZSTATEJOININGTABLE
Trying to join a table.
GZSTATEATABLE
Online, loggied in, in a room, at a table.
GZSTATELEAVINGTABLE
Waiting to leave a table.
Version 0.0.11 Last change: 21 May 2005 22
GZCore ggzcore.h(3)
GZSTATELOGINGOUT
In the process of logging out.
Function Documentation
int ggzcoreconfcommit (void)
ggzcoreconfcommit() - Commits the core user config file to
disk
Returns:
: int : 0 if successful, -1 on error
int ggzcoreconfinitialize (const char * gpath, const char *
upath)
ggzcoreconfinitialize() Opens the global and/or user
configuration files for the frontend. Either gpath or
upath can be NUL if the file is not to be used. The user
config file will be created if it does not exist.
Returns:
: 0 on success, negative on failure
int ggzcoreconfreadint (const char * section, const char *
key, int def)
ggzcoreconfreadint() - Read a integer from the
configuration file(s)
Parameters:
section section to get value from
key key value was stored under
def default value to return if none is found
Returns:
an integer from the configuration file OR the default
value
Note:
There is no guaranteed way to find if the call failed.
If you must know, call ggzcoreconfreadstring with a
NUL default value and check for the NUL return.
int ggzcoreconfreadlist (const char * section, const char *
key, int * argcp, char *** argvp)
ggzcoreconfreadlist() - Read a list from the
configuration file(s)
Parameters:
section section to get value from
key key value was stored under
argcp ptr to int which will receive the list entry count
argvp a pointer to a dynamically allocated array that
ggzcoreconfreadlist() will build
Version 0.0.11 Last change: 21 May 2005 23
GZCore ggzcore.h(3)
Returns:
int : 0 if successful, -1 on error
char* ggzcoreconfreadstring (const char * section, const
char * key, const char * def)
ggzcoreconfreadstring() - Read a string from the
configuration file(s)
Parameters:
section section to get value from
key key value was stored under
def default value to return if none is found
Returns:
a dynamically allocated string from the configuration
file OR a dynamically allocated copy of the default
string
Note:
The default may be set to NUL, in which case a NUL
will be returned if the value could not be found in
either configuration file.
int ggzcoreconfremovekey (const char * section, const char *
key)
ggzcoreconfremovekey() - Removes a key entry from the
user config file
Parameters:
section section to remove
key key entry to remove
Returns:
int : 0 if success, -1 on error, 1 on soft error
(section/key didn't exist)
int ggzcoreconfremovesection (const char * section)
ggzcoreconfremovesection() - Removes a section from the
user config file
Parameters:
section section to remove
Returns:
int : 0 if successful, -1 on error, 1 on soft error
(section did not exist)
int ggzcoreconfwriteint (const char * section, const char *
key, int value)
ggzcoreconfwriteint() - Write a integer to the user
config file
Version 0.0.11 Last change: 21 May 2005 24
GZCore ggzcore.h(3)
Parameters:
section section to store value in
key key to store value under
value value to store
Returns:
int : 0 if successful, -1 on error
int ggzcoreconfwritelist (const char * section, const char *
key, int argc, char ** argv)
ggzcoreconfwritelist() - Write a list to the user config
file
Parameters:
section section to store value in
key key to store value under
argc count of string arguments in list
argv array of NUL terminated strings
Returns:
int : 0 if successful, -1 on error
int ggzcoreconfwritestring (const char * section, const char
* key, const char * value)
ggzcoreconfwritestring() - Write a string to the user
config file
Parameters:
section section to store value in
key key to store value under
value value to store
Returns:
int : 0 if successful, -1 on error
void ggzcoredestroy (void)
ggzcoredestroy() - Cleanup function for ggzcore lib.
int ggzcoregameaddeventhook (GZGame * game, const
GZGameEvent event, const GZHookFunc func)
Register a hook for a game event.
See also:
ggzcoreserveraddeventhook
ggzcoreroomaddeventhook
int ggzcoregameaddeventhookfull (GZGame * game, const
GZGameEvent event, const GZHookFunc func, const void *
data)
Register a hook for a game event.
Version 0.0.11 Last change: 21 May 2005 25
GZCore ggzcore.h(3)
See also:
ggzcoreserveraddeventhookfull
ggzcoreroomaddeventhookfull
int ggzcoregamereaddata (GZGame * game)
Read data from the game. When data is pending on the control
socket, call this function.
Returns:
negative on error
See also:
ggzcoregamegetcontrolfd
int ggzcoregameremoveeventhook (GZGame * game, const
GZGameEvent event, const GZHookFunc func)
Remove a hook from a game event.
See also:
ggzcoreserverremoveeventhook
ggzcoreroomremoveeventhook
int ggzcoregameremoveeventhookid (GZGame * game, const
GZGameEvent event, const unsigned int hookid)
Remove a specified hook from a game event.
See also:
ggzcoreserverremoveeventhookid
ggzcoreroomremoveeventhookid
unsigned int ggzcoregametypegetid (const GZGameType * type)
Get the ID of this gametype.
Note:
This is not normally useful for a GZ client to know.
int ggzcoregametypegetmaxbots (const GZGameType * type)
Get the maximum number of bots the game can support.
See also:
ggzcoregametypebotsisvalid
int ggzcoregametypegetmaxplayers (const GZGameType * type)
Get the maximum number of players the game can support.
See also:
ggzcoregametypenumplayersisvalid
Version 0.0.11 Last change: 21 May 2005 26
GZCore ggzcore.h(3)
int ggzcoreinit (GZOptions options)
ggzcoreinit() - Initializtion function for ggzcore lib.
Parameters:
options options structure
Returns:
int : 0 if successful, -1 on failure
int ggzcoremoduleadd (const char * name, const char *
version, const char * protengine, const char *
protversion, const char * author, const char * frontend,
const char * url, const char * exepath, const char *
iconpath, const char * helppath, GZModuleEnvironment
environment)
This adds a local module to the list. It returns 0 if
successful or -1 on failure.
const char* ggzcoremodulegeticonpath (GZModule * module)
This is (intended to be) an optional xpm file that the
module can provide to use for representing the game
graphically.
int ggzcoreplayergethighscore (const GZPlayer * player, int
* highscore)
Get the player's highscore.
Returns:
TRUE if there is a highscore; FALSE if not or on error.
int ggzcoreplayergetranking (const GZPlayer * player, int *
ranking)
Get the player's ranking.
Returns:
TRUE if there is a ranking; FALSE if not or on error.
int ggzcoreplayergetrating (const GZPlayer * player, int *
rating)
Get the player's rating.
Returns:
TRUE if there is a rating; FALSE if not or on error.
int ggzcoreplayergetrecord (const GZPlayer * player, int *
wins, int * losses, int * ties, int * forfeits)
Get the player's win-loss record.
Returns:
TRUE if there is a record; FALSE if not or on error.
Version 0.0.11 Last change: 21 May 2005 27
GZCore ggzcore.h(3)
void ggzcorereload (void)
ggzcorereload() - Reload game module database
int ggzcoreroomaddeventhook (GZRoom * room, const
GZRoomEvent event, const GZHookFunc func)
Register a handler (hook) for the room event.
A room event will happen when data is received from the
server. To make updates to the frontend, the client will
need to register a hook function to handle the event. This
hook function will be called each time the room event
occurrs. More than one hook function may be specified, in
which case they will all be called (in FIFO order).
Parameters:
room The room object to associate the hook with.
event The event the handler is going to be 'hooked'
onto.
func The event handler itself. This is called during the
event.
Returns:
The hook ID, or negative on error.
See also:
ggzcoreroomaddeventhookfull
ggzcoreroomremoveeventhook
ggzcoreroomremoveeventhookid
int ggzcoreroomaddeventhookfull (GZRoom * room, const
GZRoomEvent event, const GZHookFunc func, const void *
data)
Register a handler (hook) for thee room event, with data.
This function is similar to ggzcoreroomaddeventhook,
except that user data will be associated with the hook. This
data will be passed back to the function each time it is
invoked on this event.
Parameters:
room The room object to associate the hook with.
event The event the handler is going to be 'hooked'
onto.
func The event handler itself. This is called during the
event.
data The user data associated with the hook.
Returns:
The hook ID, or negative on error.
Version 0.0.11 Last change: 21 May 2005 28
GZCore ggzcore.h(3)
See also:
ggzcoreroomaddeventhook
int ggzcoreroomchat (GZRoom * room, const GZChatType
opcode, const char * player, const char * msg)
Chat!
Parameters:
room Your current room.
opcode The chat type.
player The name of the target player (only for certain
chat types)
msg The text of the chat message (some chat types don't
need it)
Returns:
0 on success, negative on (any) failure
Note:
The chat message should be in UTF-8.
int ggzcoreroomjointable (GZRoom * room, const unsigned int
tableid, int spectator)
Join a table in the room, so that you can then play at it.
Parameters:
room Your current room.
tableid The table to join.
spectator TRUE if you wish to spectate, FALSE if you
want to play
Returns:
0 on success, negative on (any) failure
int ggzcoreroomlaunchtable (GZRoom * room, GZTable *
table)
Launch a table in the room.
When a player wants to launch a new table, this is the
function to do it. You must first create the table and set
up the number and type of seats. Then call this function to
initiate the launch.
Parameters:
room Your current room.
table The table to launch.
Returns:
0 on success, negative on (any) failure
int ggzcoreroomleavetable (GZRoom * room, int force)
Version 0.0.11 Last change: 21 May 2005 29
GZCore ggzcore.h(3)
Leave the table you are currently playing at.
This function tries to leave your current table. You should
'force' the leave only if the game client is inoperable,
since for some games this will destroy the game server as
well.
Parameters:
room Your current room.
force TRUE to force the leave, FALSE to leave it up to
ggzd
Returns:
0 on success, negative on (any) failure
int ggzcoreroomlistplayers (GZRoom * room)
Call to request a list of players in the room.
See also:
GZPLAYERLIST
int ggzcoreroomlisttables (GZRoom * room, const int type,
const char global)
Call to request a list of tables in the room.
Parameters:
room Your current room
type currently ignored (???)
global currently ignored (???)
See also:
GZTABLELIST
int ggzcoreroomremoveeventhook (GZRoom * room, const
GZRoomEvent event, const GZHookFunc func)
Remove a hook from an event.
Removes a specific hook function from the hook list for the
given room event. If more than one copy of the function
exists in the list, the oldest one will be removed.
Parameters:
room The room object to associate the hook with.
event The event the handler is to be unhooked from.
func The event handler function to remove.
Returns:
0 on success, negative on failure.
See also:
ggzcoreroomaddeventhook
Version 0.0.11 Last change: 21 May 2005 30
GZCore ggzcore.h(3)
int ggzcoreroomremoveeventhookid (GZRoom * room, const
GZRoomEvent event, const unsigned int hookid)
Remove a hook from an event, by ID.
Removes a specific hook from the hook list for the given
room. The 'ID' should be the same as that returned when the
hook was added.
Parameters:
room The room object to associate the hook with.
event The event the handler is to be unhooked from.
id The ID of the hook to remove, as returned by the add
function return 0 on success, negative on failure
See also:
ggzcoreroomaddeventhook
int ggzcoreserveraddeventhook (GZServer * server, const
GZServerEvent event, const GZHookFunc func)
Register a callback handler for a server event.
Call this function to register the given GZHookFunc as a
handler for the given event. Then any time that event
happens the handler function will be called.
Parameters:
server The GZ server object.
event The server event to be handled.
func The handler function to be called when the event
occurs.
Returns:
A hook ID value to identify this handler.
Note:
Equivalent to ggzcoreserveraddeventhookfull with
data==NUL.
More than one handler can be registered for each event.
int ggzcoreserveraddeventhookfull (GZServer * server,
const GZServerEvent event, const GZHookFunc func, const
void * data)
Register a callback handler for a server event.
See also:
ggzcoreserveraddeventhook
Parameters:
data An arbitrary pointer that will be passed to the
hook function.
Version 0.0.11 Last change: 21 May 2005 31
GZCore ggzcore.h(3)
int ggzcoreserverconnect (GZServer * server)
Connect to the server.
Call this function to initially connect to a GZ server.
Connection info is set using the ggzcoreserversethostinfo
function.
The function is asynchronous and will return very quickly.
After the connection is (hopefully) established we will
receive either a GZCONECTED or GZCONECTFAIL server
event. If the connection succeeds, negotiations with the GZ
server will begin automatically. Once this is complete, we
will receive either a GZNEGOTIATED or GZNEGOTIATEFAIL
event.
Parameters:
server The GZ server object.
Returns:
0 on success, -1 on failure.
Note:
On success a GZCONECTED event will be generated.
On failure a GZCONECTFAIL event may or may not be
generated.
int ggzcoreservergetfd (const GZServer * server)
Get the socket used for connection with the server.
This returns the file descriptor of the primary socket for
the TCP connection to the server. All GZ data goes across
this socket.
Parameters:
server The GZ server object.
Returns:
The file descriptor of the connection socket.
See also:
ggzcoreserverconnect
const char* ggzcoreservergethandle (const GZServer *
server)
Get the handle being used for this server.
Parameters:
server The GZ server object.
Returns:
A string containing the handle, or NUL on error.
Version 0.0.11 Last change: 21 May 2005 32
GZCore ggzcore.h(3)
See also:
ggzcoreserversetlogininfo
const char* ggzcoreservergethost (const GZServer * server)
Get the hostname of the server.
Parameters:
server The GZ server object.
Returns:
A string containing the host name, or NUL on error.
See also:
ggzcoreserversethostinfo
int ggzcoreservergetnumgametypes (const GZServer * server)
Return the overall number of game types on the server.
Parameters:
server The GZ server object.
Returns:
The number of game types on this server, or -1 on error.
Note:
This number is 0 until
See also:
GZTYPELIST.
int ggzcoreservergetnumplayers (const GZServer * server)
Get the total number of players on the server.
Parameters:
server The GZ server object return An approximate
number of players in all rooms of the server.
int ggzcoreservergetnumrooms (const GZServer * server)
Return the number of rooms on the server, or -1 on error.
Note:
Until we retrieve the list of rooms, this will return 0.
const char* ggzcoreservergetpassword (const GZServer *
server)
Get the password being used for this server.
Parameters:
server The GZ server object.
Returns:
A string containing the password, or NUL on error.
Version 0.0.11 Last change: 21 May 2005 33
GZCore ggzcore.h(3)
See also:
ggzcoreserversetlogininfo
int ggzcoreservergetport (const GZServer * server)
Get the port of the server.
Parameters:
server The GZ server object.
Returns:
The port number of the server, or -1 on error.
See also:
ggzcoreserversethostinfo
GZStateID ggzcoreservergetstate (const GZServer * server)
Get the state of the server connection.
Parameters:
server The GZ server object.
Returns:
The state of the connection, or -1 on error.
int ggzcoreservergettls (const GZServer * server)
Get the current TLS status of this server.
Parameters:
server The GZ server object
Returns:
Whether TLS is active or not
GZLoginType ggzcoreservergettype (const GZServer * server)
Get the login type being used for this server.
Parameters:
server The GZ server object.
Returns:
The login type set for the server, or -1 on error.
See also:
ggzcoreserversetlogininfo
int ggzcoreserverjoinroom (GZServer * server, const
unsigned int room)
Join a room on the server.
Parameters:
server The GZ server object.
room The number of the room to join.
Version 0.0.11 Last change: 21 May 2005 34
GZCore ggzcore.h(3)
Returns:
0 on success, -1 on failure (e.g. non-existing room
number).
int ggzcoreserverlistgametypes (GZServer * server, const
char verbose)
Request game type list.
Parameters:
server The GZ server object.
verbose Receive detailed gametype information or not.
Returns:
0 on success, -1 on failure.
Note:
A GZTYPELIST event will be the asynchronous response
on success.
int ggzcoreserverlistrooms (GZServer * server, const int
type, const char verbose)
Request room list.
Parameters:
server The GZ server object.
type Not used yet.
verbose Receive all information about a room or only the
essentials.
Returns:
0 on success, -1 on failure.
Note:
A GZROMLIST might be generated thereafter.
int ggzcoreserverlogsession (GZServer * server, const char
* filename)
Initiate logging of ggzcore events.
Normally, ggzcore traffic is not logged anywhere. With this
functions, such output can be directed into a file. It
contains all the network messages received from the server.
Parameters:
server The GZ server object.
filename The file the messages are written to.
Returns:
0 on success, -1 on error.
int ggzcoreserverlogin (GZServer * server)
Version 0.0.11 Last change: 21 May 2005 35
GZCore ggzcore.h(3)
Log in to the server.
Call this function to log in to the server once a connection
has been established. Typically you must first connect to
the server, then wait to receive the GZCONECTED and
GZNEGOTIATED events before attempting to log in. Login
info is set using the ggzcoreserversetlogininfo function.
The function is asynchronous and will return immediately.
After the login request is sent, we will wait to receive
either a GZLOGEDIN or GZLOGINFAIL server event.
Parameters:
server The GZ server object.
Returns:
0 on success, -1 on failure.
Note:
On failure no events will be generated.
GZServer* ggzcoreservernew (void)
Create a new server object.
Call this function to create a server object. This object
holds all state data for communicating with a ggz server. It
is necessary for any kind of connection.
int ggzcoreserverreaddata (GZServer * server, int fd)
Read data for the server on the specified FD.
Returns:
negative on error
int ggzcoreserverremoveeventhook (GZServer * server, const
GZServerEvent event, const GZHookFunc func)
Remove a single hook function from an event's hook list.
Parameters:
server The GZ server object.
event The server event the hook is associated with.
func The function to be removed from the hook list.
Returns:
0 on success (hook removed); -1 on failure (no hook
removed)
Note:
At most one copy of the function will be removed.
See also:
ggzcoreserverremoveeventhookid
Version 0.0.11 Last change: 21 May 2005 36
GZCore ggzcore.h(3)
int ggzcoreserverremoveeventhookid (GZServer * server,
const GZServerEvent event, const unsigned int hookid)
Remove a hook function with given ID from the event's hook
list.
Parameters:
server The GZ server object.
event The server event the hook is associated with.
hookid The ID of the hook event.
Returns:
0 on success (hook removed); -1 on failure (no hook
removed)
Note:
The hook ID is given by ggzcoreserveraddeventhook
int ggzcoreserverreset (GZServer * server)
Reset the server object.
After you've disconnected, call this function to discard all
state data and reset the state of the server object. You can
then connect again.
Note:
You should disconnect before resetting.
int ggzcoreserversethostinfo (GZServer * server, const char
* host, const unsigned int port, const unsigned int usetls)
Set host info for connecting to the server.
Call this function to set host info for the GZ server
before trying to connect to it.
Parameters:
server The GZ server object.
host A string containing the hostname.
port The port to connect to.
usetls If set, the connection will be encrypted.
Returns:
0 on success, -1 on error.
Note:
Should never fail when given valid input.
See also:
ggzcoreserverconnect
int ggzcoreserversetlogininfo (GZServer * server, const
GZLoginType type, const char * handle, const char *
password, const char * email)
Version 0.0.11 Last change: 21 May 2005 37
GZCore ggzcore.h(3)
Set login info for logging in to the server.
Call this function to set login info for the GZ server
before trying to login. This should only be called when the
server is in certain states.
Parameters:
server The GZ server object.
type The type of login to attempt.
handle The username to use with the server.
password The password to use (may be NUL with some
login types).
email The email address to use (may be NUL with some
login types).
Returns:
0 on success, -1 on error.
int ggzcoretablegetseatcount (const GZTable * table,
GZSeatType type)
Count the seats of the given type.
Given a table and a seat type, this function returns the
number of seats at the table that match the type.
Parameters:
table A GZ table.
type A GZSeatType.
Returns:
The number of seats matching the type, or -1 on error.
int ggzcoretableinit (GZTable * table, const GZGameType *
gametype, const char * desc, const unsigned int numseats)
Set data on a table object.
Note:
Useful when launching a game.
GZTable* ggzcoretablenew (void)
Create a new table object.
Note:
Useful when launching a game.
int ggzcoretablesetseat (GZTable * table, const unsigned
int seat, GZSeatType type, const char * name)
Set a seat type at a table, pre-launch.
When launching a table, call this function to set up a
particular seat at the table. It can also be used to fiddle
with already existing tables, but that would be extremely
Version 0.0.11 Last change: 21 May 2005 38
GZCore ggzcore.h(3)
unwise.
Parameters:
table The table object to change.
seat The seat number at the table to change.
type The type of seat to make it (open, reserved, or
bot).
name The name of the seat (must be valid for reserved
seats).
Returns:
0 on success, -1 on error.
Todo
How do we stop the GZ client from fiddling with random
tables?
Author
Generated automatically by Doxygen for GZCore from the
source code.
Version 0.0.11 Last change: 21 May 2005 39
|