Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
hotkeys.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <signal.h>
#include <unistd.h>
#include "hotkeys.h"
#include "ev_mgr.h"
#include "net_multi.h"
#include "utils/rlutil.h"
#include "utils/utils.h"
#include "tr-udp_stat.h"
#include "utils/teo_memory.h"
#include "text-filter/text-filter.h"

Macros

#define MODULE   _ANSI_CYAN "event_manager" _ANSI_NONE
 File: hotkeys.c Author: Kirill Scherba kiril.nosp@m.l@sc.nosp@m.herba.nosp@m..ru More...
 
#define COLOR_DW   "\033[01;32m"
 
#define COLOR_END   "\033[0m"
 
#define kev   ((ksnetEvMgrClass*)ke)
 
#define khv   kev->kh
 
#define kc   kev->kc
 
#define switch_to_net(p_ke)
 
#define MONITOR_TIMER_INTERVAL   5.0
 
#define PEER_TIMER_INTERVAL   0.150
 
#define TR_UDP_TIMER_INTERVAL   0.150
 

Enumerations

enum  wait_y { Y_NONE, Y_QUIT }
 Yes answer action. More...
 

Functions

void stdin_cb (EV_P_ ev_io *w, int revents)
 STDIN (has data) callback. More...
 
void idle_stdin_cb (EV_P_ ev_idle *w, int revents)
 STDIN Idle callback: execute STDIN callback in idle time. More...
 
ping_timer_dataping_timer_init (ksnCoreClass *kn, char *peer)
 Initialize ping timer. More...
 
void ping_timer_stop (ping_timer_data **pt)
 Stop ping timer. More...
 
monitor_timer_datamonitor_timer_init (ksnCoreClass *kn)
 Initialize monitor timer. More...
 
void monitor_timer_stop (monitor_timer_data **mt)
 Stop monitor timer. More...
 
peer_timer_datapeer_timer_init (ksnCoreClass *kn)
 Initialize peer timer. More...
 
void peer_timer_stop (peer_timer_data **pet)
 Stop peer timer. More...
 
tr_udp_timer_datatr_udp_timer_init (ksnCoreClass *kn)
 Initialize tr_udp timer. More...
 
void tr_udp_timer_stop (tr_udp_timer_data **pet)
 Stop tr_udp timer. More...
 
void hotkeysResetFilter (ksnetHotkeysClass *hotkeys)
 
void teoHotkeySetFilter (ksnetHotkeysClass *hotkeys, char *filter)
 
unsigned char teoFilterFlagCheck (void *ke)
 
unsigned char teoLogCheck (void *ke, void *log)
 
int hotkeys_cb (ksnetEvMgrClass *ke, void *data, ev_idle *w)
 Callback procedure which called by event manager when STDIN FD has any data. More...
 
void _keys_non_blocking_start (ksnetHotkeysClass *kh)
 Start keyboard non-blocking mode. More...
 
ksnetHotkeysClassksnetHotkeysInit (void *ke)
 Initialize hot keys module. More...
 
void ksnetHotkeysDestroy (ksnetHotkeysClass *kh)
 De-initialize hot key module. More...
 
void ping_timer_cb (EV_P_ ev_timer *w, int revents)
 Ping timer callback. More...
 
int monitor_timer_one_cb (ksnetArpClass *ka, char *peer_name, ksnet_arp_data_ext *arp, void *data)
 Send network monitor ping to one peer. More...
 
void monitor_timer_cb (EV_P_ ev_timer *w, int revents)
 Monitor timer callback. More...
 
void peer_idle_cb (EV_P_ ev_idle *iw, int revents)
 Peer show idle callback. More...
 
void peer_timer_cb (EV_P_ ev_timer *tw, int revents)
 Peer timer callback. More...
 
void tr_udp_idle_cb (EV_P_ ev_idle *iw, int revents)
 TR-UDP show idle callback. More...
 
void tr_udp_timer_cb (EV_P_ ev_timer *tw, int revents)
 TR-UDP timer callback. More...
 

Variables

const char * SHOW = "show"
 
const char * DONT_SHOW = "don't show"
 
const char * START = "start"
 
const char * STOP = "stop"
 
const char * ON = "on"
 
const char * OFF = "off"
 
const char * PING = "ping"
 
const char * TRACE = "trace"
 
const char * MONITOR = "monitor"
 
const char * TRIPTIME = "triptime"
 

Macro Definition Documentation

#define COLOR_DW   "\033[01;32m"

Referenced by hotkeys_cb().

#define COLOR_END   "\033[0m"

Referenced by hotkeys_cb().

#define kev   ((ksnetEvMgrClass*)ke)

Referenced by hotkeys_cb().

#define khv   kev->kh
#define MODULE   _ANSI_CYAN "event_manager" _ANSI_NONE

File: hotkeys.c Author: Kirill Scherba kiril.nosp@m.l@sc.nosp@m.herba.nosp@m..ru

Created on April 16, 2015, 10:43 PM

Hot keys monitor module

Referenced by idle_stdin_cb(), and stdin_cb().

#define MONITOR_TIMER_INTERVAL   5.0

Referenced by monitor_timer_init().

#define PEER_TIMER_INTERVAL   0.150

Referenced by peer_timer_init().

#define switch_to_net (   p_ke)
Value:
p_ke->kh = ksnetHotkeysInit(p_ke); \
printf("Switched to network #%d\n", net_idx + 1); \
return 1
ksnetHotkeysClass * ksnetHotkeysInit(void *ke)
Initialize hot keys module.
Definition: hotkeys.c:604

Referenced by hotkeys_cb().

#define TR_UDP_TIMER_INTERVAL   0.150

Referenced by tr_udp_timer_init().

Enumeration Type Documentation

enum wait_y

Yes answer action.

Enumerator
Y_NONE 
Y_QUIT 

Function Documentation

void _keys_non_blocking_start ( ksnetHotkeysClass kh)

Start keyboard non-blocking mode.

Parameters
kh
Examples:
teoackm.c.

References ECHO, ksnetHotkeysClass::new_settings, and ksnetHotkeysClass::non_blocking.

Referenced by event_cb(), hotkeys_cb(), and ksnetHotkeysInit().

void hotkeysResetFilter ( ksnetHotkeysClass hotkeys)

References ksnetHotkeysClass::filter, and free().

Referenced by hotkeys_cb(), and teoHotkeySetFilter().

void idle_stdin_cb ( EV_P_ ev_idle *  w,
int  revents 
)

STDIN Idle callback: execute STDIN callback in idle time.

param loop

Parameters
w
revents

References stdin_idle_data::data, DEBUG_VV, free(), hotkeys_cb(), stdin_idle_data::ke, ksn_printf, MODULE, and stdin_idle_data::stdin_w.

Referenced by ksnetHotkeysInit().

void ksnetHotkeysDestroy ( ksnetHotkeysClass kh)
void monitor_timer_cb ( EV_P_ ev_timer *  w,
int  revents 
)

Monitor timer callback.

param loop

Parameters
w
revents

References ksnCoreClass::ka, monitor_timer_data::kn, ksnetArpGetAll(), and monitor_timer_one_cb().

Referenced by monitor_timer_init().

monitor_timer_data * monitor_timer_init ( ksnCoreClass kn)
int monitor_timer_one_cb ( ksnetArpClass ka,
char *  peer_name,
ksnet_arp_data_ext *  arp,
void *  data 
)

Send network monitor ping to one peer.

Parameters
ka
peer_name
arp_data
data

References ksnetArpClass::ke, ksnCommandSendCmdEcho(), ksnetArpAdd(), LIGHTGREEN, LIGHTRED, MONITOR, MONITOR_LEN, and NONE.

Referenced by monitor_timer_cb().

void monitor_timer_stop ( monitor_timer_data **  mt)

Stop monitor timer.

Parameters
mt

References free().

Referenced by hotkeys_cb().

void peer_idle_cb ( EV_P_ ev_idle *  iw,
int  revents 
)

Peer show idle callback.

param loop

Parameters
iw
revents

References ksnCoreClass::ka, peer_timer_data::kn, ksnetArpShow(), peer_timer_data::loop, peer_timer_data::num_lines, STOP, and peer_timer_data::tw.

Referenced by peer_timer_init().

void peer_timer_cb ( EV_P_ ev_timer *  tw,
int  revents 
)

Peer timer callback.

param loop

Parameters
tw
revents

References peer_timer_data::iw, and peer_timer_data::loop.

Referenced by peer_timer_init().

void peer_timer_stop ( peer_timer_data **  pet)

Stop peer timer.

Parameters
pet

References free().

Referenced by hotkeys_cb().

void ping_timer_cb ( EV_P_ ev_timer *  w,
int  revents 
)

Ping timer callback.

param loop

Parameters
w
revents
Todo:
: peer_send_cmd_echo(pt->kn, pt->peer_name, (void*)ping_buf, ping_buf_len, 0);

References ksnCoreClass::kco, ping_timer_data::kn, ksnCommandSendCmdEcho(), ping_timer_data::peer_name, PING, and PING_LEN.

Referenced by ping_timer_init().

ping_timer_data * ping_timer_init ( ksnCoreClass kn,
char *  peer 
)

Initialize ping timer.

Parameters
knPointer to ksnCoreClass
peerPeer name
Returns
Pointer to ping_timer_data. Should be free after use

References ksnCoreClass::ke, ping_timer_data::kn, ping_timer_data::loop, ping_timer_data::peer_name, ping_timer_data::peer_name_len, ping_timer_cb(), teo_malloc(), and ping_timer_data::w.

Referenced by hotkeys_cb().

void ping_timer_stop ( ping_timer_data **  pt)

Stop ping timer.

Parameters
pt

References free().

Referenced by hotkeys_cb().

void stdin_cb ( EV_P_ ev_io *  w,
int  revents 
)

STDIN (has data) callback.

param loop

Parameters
w
revents

References data, DEBUG_VV, KSN_BUFFER_SM_SIZE, ksn_puts, malloc(), MODULE, teo_malloc(), and w.

Referenced by ksnetHotkeysInit().

unsigned char teoFilterFlagCheck ( void *  ke)

References khv.

Referenced by ksnet_printf().

void teoHotkeySetFilter ( ksnetHotkeysClass hotkeys,
char *  filter 
)
unsigned char teoLogCheck ( void *  ke,
void *  log 
)

References khv, and log_string_match().

Referenced by ksnet_printf().

void tr_udp_idle_cb ( EV_P_ ev_idle *  iw,
int  revents 
)
void tr_udp_timer_cb ( EV_P_ ev_timer *  tw,
int  revents 
)

TR-UDP timer callback.

param loop

Parameters
tw
revents

References tr_udp_timer_data::iw, and tr_udp_timer_data::loop.

Referenced by tr_udp_timer_init().

void tr_udp_timer_stop ( tr_udp_timer_data **  pet)

Stop tr_udp timer.

Parameters
pet

References free().

Referenced by hotkeys_cb().

Variable Documentation

const char * DONT_SHOW = "don't show"

Referenced by hotkeys_cb().

const char * MONITOR = "monitor"

Referenced by monitor_timer_one_cb().

const char * OFF = "off"

Referenced by hotkeys_cb().

const char * ON = "on"

Referenced by hotkeys_cb().

const char * PING = "ping"

Referenced by hotkeys_cb(), and ping_timer_cb().

const char* SHOW = "show"

Referenced by hotkeys_cb().

const char * START = "start"

Referenced by hotkeys_cb().

const char * STOP = "stop"
const char * TRACE = "trace"

Referenced by hotkeys_cb().

const char * TRIPTIME = "triptime"

Referenced by check_connected_cb().