Nilorea Library
C utilities for networking, threading, graphics
|
Data Structures | |
struct | NETW_MSG |
network message, array of char and int More... | |
Macros | |
#define | NETMSG_BOX 8 |
Network Message is box retrieving reply: (int x , int y , int z , N_STR *data ) More... | |
#define | NETMSG_GET_BOX 7 |
Network Message is box retrieve: int x , int y , int z. More... | |
#define | NETMSG_IDENT_REPLY_NOK 2 |
Network Message is identification reply NON OK: (int)type , (int)id , (N_STR *)name , (N_STR *)password. More... | |
#define | NETMSG_IDENT_REPLY_OK 1 |
Network Message is identification reply OK : (int)type , (int)id , (N_STR *)name , (N_STR *)password. More... | |
#define | NETMSG_IDENT_REQUEST 0 |
Network Message is identification request: (int)type , (int)id , (N_STR *)name , (N_STR *)password. More... | |
#define | NETMSG_PING_REPLY 6 |
Network Message is ping reply: (int)type , (int)id_from , (int)id_to. More... | |
#define | NETMSG_PING_REQUEST 5 |
Network Message is ping request: (int)type , (int)id_from , (int)id_to. More... | |
#define | NETMSG_POSITION 4 |
Network Message position: (int)type , (int)id , (int)X , (int)Y , (int)x_shift , (int)y_shift ,(int)vx ,(int)vy , (int)speed , (int)acceleration , (int)time_stamp. More... | |
#define | NETMSG_QUIT 9 |
Network asking for exit. More... | |
#define | NETMSG_STRING 3 |
Network Message is string: (int)type , (int)id , (N_STR *)name , (N_STR *)chan , (N_STR *)text , (int)color. More... | |
Functions | |
int | add_int_to_msg (NETW_MSG *msg, int value) |
Add an int to the int list int the message. More... | |
int | add_nb_to_msg (NETW_MSG *msg, double value) |
Add an float to the message. More... | |
int | add_nstrdup_to_msg (NETW_MSG *msg, N_STR *str) |
Add a copy of str to the string list in the message. More... | |
int | add_nstrptr_to_msg (NETW_MSG *msg, N_STR *str) |
Add a string to the string list in the message. More... | |
int | add_strdup_to_msg (NETW_MSG *msg, const char *str) |
Add a copy of char *str to the string list in the message. More... | |
int | create_msg (NETW_MSG **msg) |
Create a NETW_MSG *object. More... | |
int | delete_msg (NETW_MSG **msg) |
Delete a NETW_MSG *object. More... | |
double | double_swap (double value) |
Swap bytes endiannes for a double. More... | |
int | empty_msg (NETW_MSG **msg) |
Empty a NETW_MSG *object. More... | |
int | get_int_from_msg (NETW_MSG *msg, int *value) |
Get a number from a message number list. More... | |
int | get_nb_from_msg (NETW_MSG *msg, double *value) |
Get a number from a message number list. More... | |
int | get_nstr_from_msg (NETW_MSG *msg, N_STR **str) |
Get a string from a message string list. More... | |
int | get_str_from_msg (NETW_MSG *msg, char **str) |
Get a string from a message string list. More... | |
double | htond (double value) |
If needed swap bytes for a double. More... | |
NETW_MSG * | make_msg_from_str (N_STR *str) |
Make a single message of the string. More... | |
N_STR * | make_str_from_msg (NETW_MSG *msg) |
Make a single string of the message. More... | |
N_STR * | netmsg_make_ident (int type, int id, N_STR *name, N_STR *passwd) |
Add a formatted NETWMSG_IDENT message to the specified network. More... | |
N_STR * | netmsg_make_ping (int type, int id_from, int id_to, int time) |
Make a ping message to send to a network. More... | |
N_STR * | netmsg_make_position_msg (int id, double X, double Y, double vx, double vy, double acc_x, double acc_y, int time_stamp) |
make a network NETMSG_POSITION message with given parameters More... | |
N_STR * | netmsg_make_quit_msg (void) |
make a generic network NETMSG_QUIT message More... | |
N_STR * | netmsg_make_string_msg (int id_from, int id_to, N_STR *name, N_STR *chan, N_STR *txt, int color) |
make a network NETMSG_STRING message with given parameters More... | |
int | netw_get_ident (N_STR *msg, int *type, int *ident, N_STR **name, N_STR **passwd) |
Retrieves identification from netwmsg. More... | |
int | netw_get_ping (N_STR *msg, int *type, int *from, int *to, int *time) |
Retrieves a ping travel elapsed time. More... | |
int | netw_get_position (N_STR *msg, int *id, double *X, double *Y, double *vx, double *vy, double *acc_x, double *acc_y, int *time_stamp) |
Retrieves position from netwmsg. More... | |
int | netw_get_quit (N_STR *msg) |
get a formatted NETWMSG_QUIT message from the specified network More... | |
int | netw_get_string (N_STR *msg, int *id, N_STR **name, N_STR **chan, N_STR **txt, int *color) |
Retrieves string from netwmsg. More... | |
int | netw_msg_get_type (N_STR *msg) |
Get the type of message without killing the first number. Use with netw_get_XXX. More... | |
double | ntohd (double value) |
If needed swap bytes for a double. More... | |
struct NETW_MSG |
#define NETMSG_BOX 8 |
Network Message is box retrieving reply: (int x , int y , int z , N_STR *data )
Definition at line 43 of file n_network_msg.h.
#define NETMSG_GET_BOX 7 |
Network Message is box retrieve: int x , int y , int z.
Definition at line 41 of file n_network_msg.h.
#define NETMSG_IDENT_REPLY_NOK 2 |
Network Message is identification reply NON OK: (int)type , (int)id , (N_STR *)name , (N_STR *)password.
Definition at line 31 of file n_network_msg.h.
#define NETMSG_IDENT_REPLY_OK 1 |
Network Message is identification reply OK : (int)type , (int)id , (N_STR *)name , (N_STR *)password.
Definition at line 29 of file n_network_msg.h.
#define NETMSG_IDENT_REQUEST 0 |
Network Message is identification request: (int)type , (int)id , (N_STR *)name , (N_STR *)password.
Definition at line 27 of file n_network_msg.h.
#define NETMSG_PING_REPLY 6 |
Network Message is ping reply: (int)type , (int)id_from , (int)id_to.
Definition at line 39 of file n_network_msg.h.
#define NETMSG_PING_REQUEST 5 |
Network Message is ping request: (int)type , (int)id_from , (int)id_to.
Definition at line 37 of file n_network_msg.h.
#define NETMSG_POSITION 4 |
Network Message position: (int)type , (int)id , (int)X , (int)Y , (int)x_shift , (int)y_shift ,(int)vx ,(int)vy , (int)speed , (int)acceleration , (int)time_stamp.
Definition at line 35 of file n_network_msg.h.
#define NETMSG_QUIT 9 |
Network asking for exit.
Definition at line 45 of file n_network_msg.h.
#define NETMSG_STRING 3 |
Network Message is string: (int)type , (int)id , (N_STR *)name , (N_STR *)chan , (N_STR *)text , (int)color.
Definition at line 33 of file n_network_msg.h.
int add_int_to_msg | ( | NETW_MSG * | msg, |
int | value | ||
) |
Add an int to the int list int the message.
msg | A NETW_MSG *object to complete with the value |
value | The value to add to the message |
Definition at line 181 of file n_network_msg.c.
References __n_assert, list_push(), and Malloc.
Referenced by make_msg_from_str(), netmsg_make_ident(), netmsg_make_ping(), netmsg_make_position_msg(), netmsg_make_quit_msg(), netmsg_make_string_msg(), and send_net_datas().
int add_nb_to_msg | ( | NETW_MSG * | msg, |
double | value | ||
) |
Add an float to the message.
msg | A NETW_MSG *object to complete with the value |
value | The value to add to the message |
Definition at line 159 of file n_network_msg.c.
References __n_assert, list_push(), and Malloc.
Referenced by make_msg_from_str(), and netmsg_make_position_msg().
Add a copy of str to the string list in the message.
msg | A NETW_MSG *object to complete with the string |
str | The string to add to the message |
Definition at line 219 of file n_network_msg.c.
References __n_assert, free_nstr_ptr(), list_push(), and nstrdup().
Referenced by netmsg_make_ident(), netmsg_make_string_msg(), and send_net_datas().
Add a string to the string list in the message.
msg | A NETW_MSG *object to complete with the string |
str | The string to add to the message |
Definition at line 203 of file n_network_msg.c.
References __n_assert, free_nstr_ptr(), and list_push().
Referenced by make_msg_from_str(), and send_net_datas().
int add_strdup_to_msg | ( | NETW_MSG * | msg, |
const char * | str | ||
) |
Add a copy of char *str to the string list in the message.
msg | A NETW_MSG *object to complete with the string |
str | The string to add to the message |
Definition at line 237 of file n_network_msg.c.
References __n_assert, char_to_nstr(), free_nstr_ptr(), and list_push().
int create_msg | ( | NETW_MSG ** | msg | ) |
Create a NETW_MSG *object.
msg | A NETW_MSG *object |
Definition at line 78 of file n_network_msg.c.
References __n_assert, LOG_ERR, Malloc, n_log, and new_generic_list().
Referenced by make_msg_from_str(), netmsg_make_ident(), netmsg_make_ping(), netmsg_make_position_msg(), netmsg_make_quit_msg(), netmsg_make_string_msg(), and send_net_datas().
int delete_msg | ( | NETW_MSG ** | msg | ) |
Delete a NETW_MSG *object.
msg | A NETW_MSG *object to delete |
Definition at line 106 of file n_network_msg.c.
References Free, list_destroy(), LOG_ERR, and n_log.
Referenced by get_net_datas(), netmsg_make_ident(), netmsg_make_ping(), netmsg_make_position_msg(), netmsg_make_quit_msg(), netmsg_make_string_msg(), netw_get_ident(), netw_get_ping(), netw_get_position(), netw_get_quit(), netw_get_string(), and send_net_datas().
double double_swap | ( | double | value | ) |
Swap bytes endiannes for a double.
value | The double to swap |
Definition at line 18 of file n_network_msg.c.
Referenced by htond(), and ntohd().
int empty_msg | ( | NETW_MSG ** | msg | ) |
Empty a NETW_MSG *object.
msg | A NETW_MSG **object |
Definition at line 139 of file n_network_msg.c.
References __n_assert, and list_empty().
int get_int_from_msg | ( | NETW_MSG * | msg, |
int * | value | ||
) |
Get a number from a message number list.
msg | A NETW_MSG *object for extracting number |
value | A int value where you want to store the result |
Definition at line 281 of file n_network_msg.c.
References __n_assert, Free, and list_shift.
Referenced by get_net_datas(), netw_get_ident(), netw_get_ping(), netw_get_position(), netw_get_quit(), and netw_get_string().
int get_nb_from_msg | ( | NETW_MSG * | msg, |
double * | value | ||
) |
Get a number from a message number list.
msg | A NETW_MSG *object for extracting number |
value | A int value where you want to store the result |
Definition at line 257 of file n_network_msg.c.
References __n_assert, Free, and list_shift.
Referenced by netw_get_position().
Get a string from a message string list.
Definition at line 306 of file n_network_msg.c.
References __n_assert, list_shift, LOG_ERR, and n_log.
Referenced by get_net_datas(), netw_get_ident(), and netw_get_string().
int get_str_from_msg | ( | NETW_MSG * | msg, |
char ** | value | ||
) |
Get a string from a message string list.
Definition at line 333 of file n_network_msg.c.
References __n_assert, Free, list_shift, LOG_ERR, and n_log.
double htond | ( | double | value | ) |
If needed swap bytes for a double.
value | The value to eventually swap |
Definition at line 44 of file n_network_msg.c.
References double_swap().
Referenced by make_str_from_msg().
Make a single message of the string.
Definition at line 475 of file n_network_msg.c.
References __n_assert, add_int_to_msg(), add_nb_to_msg(), add_nstrptr_to_msg(), create_msg(), Malloc, and ntohd().
Referenced by get_net_datas(), netw_get_ident(), netw_get_ping(), netw_get_position(), netw_get_quit(), and netw_get_string().
Make a single string of the message.
Definition at line 361 of file n_network_msg.c.
References __n_assert, htond(), and Malloc.
Referenced by netmsg_make_ident(), netmsg_make_ping(), netmsg_make_position_msg(), netmsg_make_quit_msg(), netmsg_make_string_msg(), and send_net_datas().
Add a formatted NETWMSG_IDENT message to the specified network.
type | type of identification ( NETW_IDENT_REQUEST , NETW_IDENT_NEW ) |
id | The ID of the sending client |
name | Username |
passwd | Password |
Definition at line 620 of file n_network_msg.c.
References __n_assert, add_int_to_msg(), add_nstrdup_to_msg(), create_msg(), delete_msg(), and make_str_from_msg().
Referenced by netw_send_ident().
N_STR * netmsg_make_ping | ( | int | type, |
int | id_from, | ||
int | id_to, | ||
int | time | ||
) |
Make a ping message to send to a network.
type | NETW_PING_REQUEST or NETW_PING_REPLY |
id_from | Identifiant of the sender |
id_to | Identifiant of the destination, -1 if the serveur itslef is targetted |
time | The time it was when the ping was sended |
Definition at line 573 of file n_network_msg.c.
References __n_assert, add_int_to_msg(), create_msg(), delete_msg(), and make_str_from_msg().
Referenced by netw_send_ping().
N_STR * netmsg_make_position_msg | ( | int | id, |
double | X, | ||
double | Y, | ||
double | vx, | ||
double | vy, | ||
double | acc_x, | ||
double | acc_y, | ||
int | time_stamp | ||
) |
make a network NETMSG_POSITION message with given parameters
id | The ID of the sending client |
X | x position |
Y | y position |
vx | x speed |
vy | y speed |
acc_x | x acceleration |
acc_y | y acceleration |
time_stamp | time when the position were copier |
Definition at line 670 of file n_network_msg.c.
References __n_assert, add_int_to_msg(), add_nb_to_msg(), create_msg(), delete_msg(), make_str_from_msg(), and NETMSG_POSITION.
Referenced by netw_send_position().
N_STR * netmsg_make_quit_msg | ( | void | ) |
make a generic network NETMSG_QUIT message
Definition at line 742 of file n_network_msg.c.
References __n_assert, add_int_to_msg(), create_msg(), delete_msg(), make_str_from_msg(), and NETMSG_QUIT.
Referenced by netw_send_quit().
N_STR * netmsg_make_string_msg | ( | int | id_from, |
int | id_to, | ||
N_STR * | name, | ||
N_STR * | chan, | ||
N_STR * | txt, | ||
int | color | ||
) |
make a network NETMSG_STRING message with given parameters
id_from | The ID of the sending client |
id_to | id of the destination |
name | name of the user |
chan | targeted channel |
txt | text to send |
color | color of the text |
Definition at line 708 of file n_network_msg.c.
References __n_assert, add_int_to_msg(), add_nstrdup_to_msg(), create_msg(), delete_msg(), make_str_from_msg(), NETMSG_STRING, and nstrdup().
Referenced by netw_send_string_to(), and netw_send_string_to_all().
Retrieves identification from netwmsg.
msg | The source string from which we are going to extract the data |
type | NETMSG_IDENT_NEW , NETMSG_IDENT_REPLY_OK , NETMSG_IDENT_REPLY_NOK , NETMSG_IDENT_REQUEST |
ident | ID for the user |
name | Name of the user |
passwd | Password of the user |
Definition at line 794 of file n_network_msg.c.
References __n_assert, delete_msg(), get_int_from_msg(), get_nstr_from_msg(), LOG_ERR, make_msg_from_str(), n_log, NETMSG_IDENT_REPLY_NOK, NETMSG_IDENT_REPLY_OK, and NETMSG_IDENT_REQUEST.
int netw_get_ping | ( | N_STR * | msg, |
int * | type, | ||
int * | from, | ||
int * | to, | ||
int * | time | ||
) |
Retrieves a ping travel elapsed time.
msg | The source string from which we are going to extract the data |
type | NETW_PING_REQUEST or NETW_PING_REPLY |
from | Identifiant of the sender |
to | Targetted Identifiant, -1 for server ping |
time | The time it was when the ping was sended |
Definition at line 928 of file n_network_msg.c.
References __n_assert, delete_msg(), get_int_from_msg(), make_msg_from_str(), NETMSG_PING_REPLY, and NETMSG_PING_REQUEST.
int netw_get_position | ( | N_STR * | msg, |
int * | id, | ||
double * | X, | ||
double * | Y, | ||
double * | vx, | ||
double * | vy, | ||
double * | acc_x, | ||
double * | acc_y, | ||
int * | time_stamp | ||
) |
Retrieves position from netwmsg.
msg | The source string from which we are going to extract the data |
id | |
X | X position inside a big grid |
Y | Y position inside a big grid |
vx | X speed |
vy | Y speed |
acc_x | X acceleration |
acc_y | Y acceleration |
time_stamp | Current Time when it was sended (for some delta we would want to compute ) |
Definition at line 837 of file n_network_msg.c.
References __n_assert, delete_msg(), get_int_from_msg(), get_nb_from_msg(), make_msg_from_str(), and NETMSG_POSITION.
int netw_get_quit | ( | N_STR * | msg | ) |
get a formatted NETWMSG_QUIT message from the specified network
msg | The source string from which we are going to extract the data |
Definition at line 963 of file n_network_msg.c.
References __n_assert, delete_msg(), get_int_from_msg(), make_msg_from_str(), and NETMSG_QUIT.
int netw_get_string | ( | N_STR * | msg, |
int * | id, | ||
N_STR ** | name, | ||
N_STR ** | chan, | ||
N_STR ** | txt, | ||
int * | color | ||
) |
Retrieves string from netwmsg.
msg | The source string from which we are going to extract the data |
id | The ID of the sending client |
name | Name of user |
chan | Target Channel, if any. Pass "ALL" to target the default channel |
txt | The text to send |
color | The color of the text |
Definition at line 884 of file n_network_msg.c.
References __n_assert, delete_msg(), get_int_from_msg(), get_nstr_from_msg(), make_msg_from_str(), and NETMSG_STRING.
int netw_msg_get_type | ( | N_STR * | msg | ) |
Get the type of message without killing the first number. Use with netw_get_XXX.
msg | A char *msg_object you want to have type |
Definition at line 765 of file n_network_msg.c.
References __n_assert.
Referenced by manage_client().
double ntohd | ( | double | value | ) |
If needed swap bytes for a double.
value | The value to eventually swap |
Definition at line 61 of file n_network_msg.c.
References double_swap().
Referenced by make_msg_from_str().