Nilorea Library

- Main Page
- Modules
- Data Structures
- Files

- File List
- Globals

All Data Structures Files Functions Variables Typedefs Macros Groups
n_network_msg.h
Go to the documentation of this file.
1
8 #ifndef N_NETWORK_MESSAGES
9
10 #define N_NETWORK_MESSAGES
11
12 #ifdef __cplusplus
13 extern "C"
14 {
15 #endif
16
22 #include <sys/param.h>
23 #include "n_str.h"
24 #include "n_network.h"
25
26
28 #define NETMSG_IDENT_REQUEST 0
29
30 #define NETMSG_IDENT_REPLY_OK 1
31
32 #define NETMSG_IDENT_REPLY_NOK 2
33
34 #define NETMSG_STRING 3
35
36 #define NETMSG_POSITION 4
37
38 #define NETMSG_PING_REQUEST 5
39
40 #define NETMSG_PING_REPLY 6
41
42 #define NETMSG_GET_BOX 7
43
44 #define NETMSG_BOX 8
45
46
48 typedef struct NETW_MSG
49 {
51 LIST *tabint;
53 LIST *tabstr;
55 LIST *tabflt ;
56 }NETW_MSG;
57
58 /* swap bytes */
59 double double_swap( double value );
60 /* host to network double */
61 double htond( double value );
62 /* network to host double */
63 double ntohd( double value );
64
65 /* Create a NETW_MSG *object */
66 int create_msg( NETW_MSG **msg );
67 /* Delete a NETW_MSG *object */
68 int delete_msg( NETW_MSG **msg );
69 /* Empty a NETW_MSG *object */
70 int empty_msg( NETW_MSG **msg );
71 /* Add an float to the the message */
72 int add_nb_to_msg( NETW_MSG *msg , double value );
73 /* Add an int to the the message */
74 int add_int_to_msg( NETW_MSG *msg , int value );
75 /* Add a string to the the message */
76 int add_nstrptr_to_msg( NETW_MSG *msg , N_STR *str );
77 /* Add a string to the the message */
78 int add_nstrdup_to_msg( NETW_MSG *msg , N_STR *str );
79 /* Add a char *string to the the message */
80 int add_strdup_to_msg( NETW_MSG *msg , char *str );
81 /* Get an int from the message */
82 int get_int_from_msg( NETW_MSG *msg , int *value );
83 /* Get a float value from the message */
84 int get_nb_from_msg( NETW_MSG *msg , double *value );
85 /* Get a N_STR *string from the message */
86 int get_nstr_from_msg( NETW_MSG *msg , N_STR **str );
87 /* Get a char *string from the message */
88 int get_str_from_msg( NETW_MSG *msg , char **str );
89 /* Make a single string of the message */
90 N_STR *make_str_from_msg( NETW_MSG *msg );
91 /* Make a message from a single string */
92 NETW_MSG *make_msg_from_str( N_STR *str );
93 /* Get the type of a message without modifying it */
94 int netw_msg_get_type( N_STR *msg );
95 /* Add a formatted NETWMSG_IDENT message to the specified network */
96 int netw_send_ident( NETWORK *netw , int type , int id , N_STR *name , N_STR *passwd );
97 /* Add a formatted NETWMSG_IDENT message to the specified network */
98 int netw_send_position( NETWORK *netw , int id , double X , double Y , double vx , double vy , double acc_x , double acc_y , int time_stamp );
99 /* Add a string to the network */
100 int netw_send_string_to_all( NETWORK *netw , int id , char *name , char *chan , char *txt , int color );
101 /* Add a string to the network, aiming a specific user */
102 int netw_send_string_to( NETWORK *netw , int id_from , int id_to , char *name , char *txt , int color );
103 /* Add a ping reply to the network */
104 int netw_send_ping( NETWORK *netw , int type , int id_from , int id_to , int time );
105 /* Retrieves identification from netwmsg */
106 int netw_get_ident( N_STR *msg , int *type ,int *ident , N_STR **name , N_STR **passwd );
107 /* Retrieves position from netwmsg */
108 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 );
109 /* Retrieves string from netwmsg */
110 int netw_get_string( N_STR *msg , int *id , N_STR **name , N_STR **chan , N_STR **txt , int *color );
111 /* Retrieves a ping travel elapsed time */
112 int netw_get_ping( N_STR *msg , int *type , int *from , int *to , int *time );
113
116 #ifdef __cplusplus
117 }
118 #endif
119
120 #endif /*#ifndef N_NETWORK*/
121
122
123
124
125