Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
net_multi.h
Go to the documentation of this file.
1 
8 #ifndef NET_MULTI_H
9 #define NET_MULTI_H
10 
11 #include "ev_mgr.h"
12 
16 typedef struct ksnMultiClass {
17 
18  PblMap* list;
19  size_t net_count;
20  size_t last_net_idx;
21 
23 
24 
28 typedef struct ksnMultiData {
29 
30  int argc;
31  char** argv;
33 
34  size_t num;
35  const int *ports;
36  const char **names;
37  const char **networks;
38 
39  int run;
40 
41 } ksnMultiData;
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 ksnMultiClass *ksnMultiInit(ksnMultiData *md, void *user_data);
48 void teoMultiRun(ksnMultiClass *km);
50 void teoMultiAddNet(ksnMultiClass *km, ksn_event_cb_type e_cb, const char *host, int port, const char *network, void *user_data);
51 void teoMultiRemoveNet(ksnMultiClass *km, const char *network);
52 
54 ksnetEvMgrClass *teoMultiGetByNetwork(ksnMultiClass *km, char *network_name);
55 
56 #define ksnMultiGet(X, Y) _Generic((Y), \
57  int : teoMultiGetByNumber, \
58  char* : teoMultiGetByNetwork) \
59  ((X), (Y))
60 
61 bool teoMultiIsNetworkExist(ksnMultiClass *km, int number);
62 
64 
65 ksnet_arp_data *teoMultiSendCmdToNet(ksnMultiClass *km, char *peer, char *network,
66  uint8_t cmd, void *data, size_t data_len);
67 
68 //DEPRECATED! It will be new function for broadcast sending
69 ksnet_arp_data *ksnMultiSendCmdTo(ksnMultiClass *km, char *to, uint8_t cmd, void *data,
70  size_t data_len);
71 
72 #ifdef __cplusplus
73 }
74 #endif
75 
76 #endif /* NET_MULTI_H */
void ksnMultiDestroy(ksnMultiClass *km)
Destroy ksnMultiClass object and running networks.
Definition: net_multi.c:144
ksn_event_cb_type event_cb
Definition: net_multi.h:32
const char data[]
Make it with: gcc -o post-callback post-callback.c -lcurl.
Definition: post-callback.c:23
int run
Run inside init.
Definition: net_multi.h:39
int argc
Applications argc.
Definition: net_multi.h:30
void teoMultiRemoveNet(ksnMultiClass *km, const char *network)
Remove network.
Definition: net_multi.c:125
bool teoMultiIsNetworkExist(ksnMultiClass *km, int number)
Check if network with input number is exist.
Definition: net_multi.c:218
ksnMultiClass * ksnMultiInit(ksnMultiData *md, void *user_data)
Initialize ksnMultiClass object.
Definition: net_multi.c:27
struct ksnMultiClass ksnMultiClass
File: net_multi.h Author: Kirill Scherba kirill@scherba.ru
ksnMultiClass initialize input data
Definition: net_multi.h:28
File: net_multi.h Author: Kirill Scherba kirill@scherba.ru
Definition: net_multi.h:16
ksnetEvMgrClass * teoMultiGetByNumber(ksnMultiClass *km, int number)
Get network by number.
Definition: net_multi.c:176
const char ** names
Names arrays.
Definition: net_multi.h:36
char * ksnMultiShowListStr(ksnMultiClass *km)
Show list of networks.
Definition: net_multi.c:292
const int * ports
Ports arrays.
Definition: net_multi.h:35
ksnetEvMgrClass * teoMultiGetByNetwork(ksnMultiClass *km, char *network_name)
Get network by network name.
Definition: net_multi.c:204
void teoMultiAddNet(ksnMultiClass *km, ksn_event_cb_type e_cb, const char *host, int port, const char *network, void *user_data)
Add new network.
Definition: net_multi.c:87
PblMap * list
Pointer to network list.
Definition: net_multi.h:18
KSNet event manager functions data.
Definition: ev_mgr.h:245
struct ksnMultiData ksnMultiData
ksnMultiClass initialize input data
ksnet_arp_data * teoMultiSendCmdToNet(ksnMultiClass *km, char *peer, char *network, uint8_t cmd, void *data, size_t data_len)
Send command by name (or type) and by network.
Definition: net_multi.c:350
const char ** networks
Networks arrays.
Definition: net_multi.h:37
size_t num
Number of networks.
Definition: net_multi.h:34
void teoMultiRun(ksnMultiClass *km)
Start teonet event loop (for all functions added with ksnMultiInit)
Definition: net_multi.c:72
void(* ksn_event_cb_type)(ksnetEvMgrClass *ke, ksnetEvMgrEvents event, void *data, size_t data_len, void *user_data)
Definition: ev_mgr.h:352
size_t net_count
Number of networks.
Definition: net_multi.h:19
size_t last_net_idx
Last network index.
Definition: net_multi.h:20
ksnet_arp_data * ksnMultiSendCmdTo(ksnMultiClass *km, char *to, uint8_t cmd, void *data, size_t data_len)
: It will be new function for broadcast sending Send command by name to peer
Definition: net_multi.c:372
char ** argv
Applications argv.
Definition: net_multi.h:31