A multithreaded Linux IRC server project
HOSTED BY...
DATA STRUCTURES
Here are all
the important data structures used by JBTSERVER:
/*
* SERVER
information representation (manually synchronized)
*/
struct Serveur
{
pthread_t threadId;
/* Server thread ID (unique to machine domain) */
key_t cleServeur;
/* Server message queue key (unique to machine domain) */
char cheminTemporaire[TAILLECHEMINTEMPORAIRE]; /* Location
of key temporary file */
int idFichierTemp;
/* Key temporary file descriptor */
int socketNumber;
/* Server socket number */
unsigned int nombreClients;
/* Number of clients actually registered */
unsigned int nombreServeurs;
/* Number of servers actually connected */
unsigned int nombreChannels;
/* Number of channels actually formed */
char nom[MAXADDRESSNAMELENGTH];
/* Server name */
char shortHostname[MAXADDRESSNAMELENGTH];
/* Server hostname (short form) */
char longHostname[MAXADDRESSNAMELENGTH];
/* Server fully-qualified domain name (long form) */
fd_set descEcoute;
/* Listening descriptor set */
booleen portDynamique;
/* Dynamic main server port allocation indicator (true/false) */
booleen multiplesConnections;
/* Multiple server connections indicator (true/false) */
struct sockaddr_in addresse;
/* Server address */
struct hostent* entree;
/* Host entry */
};
/*
* CLIENT
information representation (automatically synchronized)
*/
typedef struct
InfoClient
{
char type;
/* Client type (C: client / S: server) */
pthread_t threadIdMachine;
/* Client thread ID (unique to machine domain) */
int threadIdJBT;
/* Client thread ID (assigned by JBTSERVER) */
key_t cleClient;
/* Client message queue ID (unique to machine domain) */
char cheminTemporaire[TAILLECHEMINTEMPORAIRE]; /* Location
of key temporary file */
int idFichierTemp;
/* Key temporary file descriptor */
int socketNumber; /* Client socket number */
booleen away;
/* Away flag */
booleen invisible;
/* Invisible flag */
booleen wallops;
/* Wallops messages reception flag */
booleen restreint;
/* Restricted connection flag */
booleen notices;
/* Notices reception flag */
time_t dateDernierMessage;
/* Date/time of last sent message */
time_t dateConnection;
/* Date/time of server connection */
struct sockaddr_in adresseClient;
/* Client address */
struct hostent* entreeClient;
/* Host entry */
char nickname[MAXNICKLENGTH];
/* Client nickname */
char hostname[MAXADDRESSNAMELENGTH];
/* Client hostname */
char username[MAXUSERNAMELENGTH];
/* Client username */
char servername[MAXADDRESSNAMELENGTH];
/* Client server name */
char fullname[MAXREALNAMELENGTH];
/* Client full name */
char messageAway[MAXAWAYMESSAGELENGTH];
/* Client away message */
GTree* listeCanaux;
/* Joined channels list */
} Client;
- The joined
channels tree will be indexed by the channel name and will contain Channel
structures as data.
/*
* Client/server
thread message representation
*/
typedef struct
{
long messageQId;
/* Client (source) message queue id */
char texteMessage[MAXCOMSIZE];
/* Message text */
int threadCID;
/* Client (source) thread id */
booleen* clientQF;
/* Client quit flag pointer */
} Message;
- Exchanged between
client and server threads to forward requests.
/*
* Client
thread list (context) block
*/
typedef struct
{
GTree* arbrePresents;
GList* listeQuittants;
} BLTC;
- The connecting
clients tree will be indexed by the clients's JBT thread ID and will contain
the clients's BPTC as data.
- The disconnecting
clients list will contain the clients's JBT thread ID.
/*
* Client
thread parameter (context) block
*/
typedef struct
{
pthread_t threadIdMachine;
/* Client thread ID (unique to machine domain) */
int threadIdJBT;
/* Client thread ID (assigned by JBTSERVER) */
key_t cleServeur;
/* Server message queue key */
key_t cleClient;
/* Client message queue key */
int socketClient;
/* Client socket number */
booleen* quitteFlag;
/* Client quit flag pointer */
char cheminTemporaire[TAILLECHEMINTEMPORAIRE]; /* Location of key
temporary file */
int idFichierTemp;
/* Temporary key file descriptor */
BLTC* bltc;
/* Pointer to BLTC structure */
} BPTC;
- Included in
the connecting clients tree as well as the disconnecting clients list.
/*
* Server
thread parameter (context) block
*/
typedef struct
{
key_t cleServeur;
/* Server message queue key */
struct Serveur* s;
/* Server structure pointer */
GTree* arbreClients;
/* Client tree pointer */
GTree* arbreCanaux;
/* Channel tree pointer */
struct Reseau* r;
/* Network structure pointer */
BLTC* bltc;
/* Pointer to BLTC structure */
booleen* finServiceFlag;
/* Server shutdown flag */
} BPTS;
- The client
tree will be indexed by the clients's nicknames and will contain Client
structures as data.
- The channel
tree will be indexed by the channel name and will contain Canal structures
as data.
/*
* Callback
(worker) thread parameter (context) block
*/
typedef struct
{
struct Serveur* s;
/* Server structure pointer */
GTree* arbreClients;
/* Client tree pointer */
GTree* arbreCanaux;
/* Channel tree pointer */
struct Reseau* r;
/* Network structure pointer */
const Message* m;
/* Parsed message pointer */
BLTC* bltc;
/* Pointeur to BLTC structure */
} BPCB;
- Will be passed
to callbacks (worker threads) for every request sent to the server thread.
/*
* Channel
member representation
*/
typedef struct
InfoMembre
{
char nickname[MAXNICKLENGTH];
/* Client nickname */
booleen createur;
/* Channel creator flag */
booleen operateur;
/* Channel operator flag */
booleen operateurLocal;
/* Local channel operator flag */
booleen voice;
/* Channel voice flag */
} Membre;
- Contains information
about a client who has joined a channel.
/*
* Channel
representation
*/
typedef struct
InfoCanal
{
char nom[MAXCHANNELNAMELENGTH];
/* Channel name */
unsigned int nombreMembres;
/* Number of members present */
char topic[MAXTOPICLENGTH];
/* Channel topic */
unsigned int limiteMembres;
/* Channel member limit */
char motCle[MAXKEYLENGTH];
/* Channel key */
long unsigned int flags;
/* Channel flags */
GTree* listeMembres;
/* Channel member list */
GTree* listeBannis;
/* Channel banned members list */
GTree* listeException;
/* Channel exception members list */
GTree* listeOverride;
/* Channel override members list */
} Canal;
- Contains information
about an existing channel.
/*
* Network
information representation
*/
struct Reseau
{
GTree* serveursReseau;
/* Network servers tree pointer */
GTree* clientsReseau;
/* Network clients tree pointer */
GTree* canauxReseau;
/* Network channels tree pointer */
};
- Contains information
about the IRC network which the server belongs to.
Page last updated 2002/05/30