ekg2
GIT master
|
#include "ekg2.h"
#include "internal.h"
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/wait.h>
Struktury danych | |
struct | ekg_source |
struct | source_remove_data |
struct | source_find_data |
struct | timer_print_args |
Funkcje | |
static ekg_source_t | source_new (plugin_t *plugin, const gchar *name_format, gpointer data, GDestroyNotify destr, va_list args) |
static ekg_source_t | source_new_va (plugin_t *plugin, const gchar *name_format, gpointer data, GDestroyNotify destr,...) |
static void | source_set_id (struct ekg_source *s, guint id) |
static void | source_free (struct ekg_source *s) |
void | ekg_source_remove (ekg_source_t s) |
static void | source_remove_by_h (gpointer data, gpointer user_data) |
gboolean | ekg_source_remove_by_handler (gpointer handler, const gchar *name) |
static void | source_remove_by_d (gpointer data, gpointer user_data) |
gboolean | ekg_source_remove_by_data (gpointer priv_data, const gchar *name) |
static void | source_remove_by_p (gpointer data, gpointer user_data) |
gboolean | ekg_source_remove_by_plugin (plugin_t *plugin, const gchar *name) |
static void | source_remove (gpointer data, gpointer user_data) |
void | sources_destroy (void) |
static void | child_destroy_notify (gpointer data) |
static void | child_wrapper (GPid pid, gint status, gpointer data) |
ekg_child_t | ekg_child_add (plugin_t *plugin, const gchar *name_format, GPid pid, GChildWatchFunc handler, gpointer data, GDestroyNotify destr,...) |
static void | timer_wrapper_destroy_notify (gpointer data) |
static gboolean | timer_wrapper_old (gpointer data) |
ekg_timer_t | timer_add_ms (plugin_t *plugin, const gchar *name, guint period, gboolean persist, gint(*function)(gint, gpointer), gpointer data) |
ekg_timer_t | timer_add (plugin_t *plugin, const gchar *name, guint period, gboolean persist, gint(*function)(gint, gpointer), gpointer data) |
ekg_timer_t | timer_add_session (session_t *session, const gchar *name, guint period, gboolean persist, gint(*function)(gint, session_t *)) |
static void | timer_destroy_notify (gpointer data) |
static gboolean | timer_wrapper (gpointer data) |
ekg_timer_t | ekg_timer_add (plugin_t *plugin, const gchar *name_format, guint64 interval, GSourceFunc handler, gpointer data, GDestroyNotify destr,...) |
gint | timer_remove (plugin_t *plugin, const gchar *name) |
gint | timer_find_session_cmp (gconstpointer li, gconstpointer ui) |
ekg_timer_t | timer_find_session (session_t *session, const gchar *name) |
static void | timer_remove_session_iter (gpointer data, gpointer user_data) |
gint | timer_remove_session (session_t *session, const gchar *name) |
G_GNUC_INTERNAL gint | timer_remove_user (gint(*handler)(gint, gpointer)) |
static gchar * | timer_next_call (struct ekg_source *t) |
static gint | timer_match_name (gconstpointer li, gconstpointer ui) |
static void | child_print (gpointer data, gpointer user_data) |
gint | ekg_children_print (gint quiet) |
static void | timer_debug_print (gpointer data, gpointer user_data) |
int | cmd_debug_timers (const char *name, const char **params, session_t *session, const char *target, int quiet) |
gint | timer_handle_at (gint type, gpointer data) |
static void | timer_print (gpointer data, gpointer user_data) |
int | cmd_at (const char *name, const char **params, session_t *session, const char *target, int quiet) |
gint | timer_handle_command (gint type, gpointer data) |
static void | timer_print_list (gpointer data, gpointer user_data) |
int | cmd_timer (const char *name, const char **params, session_t *session, const char *target, int quiet) |
void | timers_write (GOutputStream *f) |
watch_t * | watch_find (plugin_t *plugin, int fd, watch_type_t type) |
static void | watch_free_data (watch_t *data) |
static int | watch_handle_line (watch_t *w) |
static gboolean | watch_old_wrapper (GIOChannel *f, GIOCondition cond, gpointer data) |
static int | watch_handle_write (watch_t *w) |
int | watch_write_data (watch_t *w, const char *buf, int len) |
int | watch_write (watch_t *w, const char *format,...) |
static int | watch_handle (watch_t *w) |
static void | watch_old_destroy_notify (gpointer data) |
void | watch_free (watch_t *w) |
watch_t * | watch_add (plugin_t *plugin, int fd, watch_type_t type, watcher_handler_func_t *handler, void *data) |
watch_t * | watch_add_session (session_t *session, int fd, watch_type_t type, watcher_session_handler_func_t *handler) |
int | watch_remove (plugin_t *plugin, int fd, watch_type_t type) |
Zmienne | |
static GSList * | children = NULL |
static GSList * | timers = NULL |
|
static |
|
static |
|
static |
int cmd_at | ( | const char * | name, |
const char ** | params, | ||
session_t * | session, | ||
const char * | target, | ||
int | quiet | ||
) |
int cmd_debug_timers | ( | const char * | name, |
const char ** | params, | ||
session_t * | session, | ||
const char * | target, | ||
int | quiet | ||
) |
int cmd_timer | ( | const char * | name, |
const char ** | params, | ||
session_t * | session, | ||
const char * | target, | ||
int | quiet | ||
) |
ekg_child_t ekg_child_add | ( | plugin_t * | plugin, |
const gchar * | name_format, | ||
GPid | pid, | ||
GChildWatchFunc | handler, | ||
gpointer | data, | ||
GDestroyNotify | destr, | ||
... | |||
) |
Add a watcher for the child process.
plugin | - plugin which contains handler funcs or NULL if in core. |
name_format | - format string for watcher name. Can be NULL, or simple string if the name is guaranteed not to contain ''. |
pid | - PID of the child process. |
handler | - the handler func called when the process exits. The handler func will be provided with the child PID, exit status (filtered through WEXITSTATUS()) and private data. |
data | - the private data passed to the handler. |
destr | - destructor for the private data. It will be called even if the handler isn't (i.e. when the watch is removed before process exits). Can be NULL. |
... | - arguments to name_format format string. |
gint ekg_children_print | ( | gint | quiet | ) |
void ekg_source_remove | ( | ekg_source_t | s | ) |
Remove a particular source (which can be ekg_child_t, ekg_timer_t...).
s | - the source identifier. |
gboolean ekg_source_remove_by_data | ( | gpointer | priv_data, |
const gchar * | name | ||
) |
gboolean ekg_source_remove_by_handler | ( | gpointer | handler, |
const gchar * | name | ||
) |
gboolean ekg_source_remove_by_plugin | ( | plugin_t * | plugin, |
const gchar * | name | ||
) |
ekg_timer_t ekg_timer_add | ( | plugin_t * | plugin, |
const gchar * | name_format, | ||
guint64 | interval, | ||
GSourceFunc | handler, | ||
gpointer | data, | ||
GDestroyNotify | destr, | ||
... | |||
) |
Add a timer.
plugin | - plugin which contains handler funcs or NULL if in core. |
name_format | - format string for timer name. Can be NULL, or simple string if the name is guaranteed not to contain ''. |
interval | - the interval between successive timer calls, in milliseconds. If it is a multiple of 1000, the timer will use glib second timeouts (more efficient); otherwise, the millisecond timeout will be used. |
handler | - the handler func. It will be passed the private data, and should either return TRUE or FALSE, depending on whether the timer should persist or be removed. |
data | - the private data passed to the handler. |
destr | - destructor for the private data. It will be called even if the handler is not. Can be NULL. |
... | - arguments to name_format format string. |
|
static |
|
static |
|
static |
|
static |
|
static |
Remove source(s) using a particular private data (and optionally matching the name).
priv_data | - private data pointer. |
name | - expected source name or NULL if any. |
|
static |
|
static |
Remove source(s) using a particular plugin (e.g. on plugin unload), and optionally bearing a name.
plugin | - plugin_t pointer. |
name | - expected source name or NULL if any. |
|
static |
void sources_destroy | ( | void | ) |
ekg_timer_t timer_add | ( | plugin_t * | plugin, |
const gchar * | name, | ||
guint | period, | ||
gboolean | persist, | ||
gint(*)(gint, gpointer) | function, | ||
gpointer | data | ||
) |
ekg_timer_t timer_add_ms | ( | plugin_t * | plugin, |
const gchar * | name, | ||
guint | period, | ||
gboolean | persist, | ||
gint(*)(gint, gpointer) | function, | ||
gpointer | data | ||
) |
ekg_timer_t timer_add_session | ( | session_t * | session, |
const gchar * | name, | ||
guint | period, | ||
gboolean | persist, | ||
gint(*)(gint, session_t *) | function | ||
) |
|
static |
|
static |
ekg_timer_t timer_find_session | ( | session_t * | session, |
const gchar * | name | ||
) |
gint timer_find_session_cmp | ( | gconstpointer | li, |
gconstpointer | ui | ||
) |
gint timer_handle_at | ( | gint | type, |
gpointer | data | ||
) |
gint timer_handle_command | ( | gint | type, |
gpointer | data | ||
) |
|
inlinestatic |
|
static |
|
static |
|
static |
gint timer_remove | ( | plugin_t * | plugin, |
const gchar * | name | ||
) |
gint timer_remove_session | ( | session_t * | session, |
const gchar * | name | ||
) |
|
static |
G_GNUC_INTERNAL gint timer_remove_user | ( | gint(*)(gint, gpointer) | handler | ) |
|
static |
|
static |
|
static |
void timers_write | ( | GOutputStream * | f | ) |
watch_t* watch_add | ( | plugin_t * | plugin, |
int | fd, | ||
watch_type_t | type, | ||
watcher_handler_func_t * | handler, | ||
void * | data | ||
) |
Create new watch_t and add it on the beginning of watches list.
plugin | - plugin |
fd | - fd to watch data for. |
type | - type of watch. |
handler | - handler of watch. |
data | - data which be passed to handler. |
watch_t* watch_add_session | ( | session_t * | session, |
int | fd, | ||
watch_type_t | type, | ||
watcher_session_handler_func_t * | handler | ||
) |
Create new session watch_t and add it on the beginning of watches list.
session | - session |
fd | - fd to watch data for |
type | - type of watch. |
handler | - handler of watch. |
watch_t* watch_find | ( | plugin_t * | plugin, |
int | fd, | ||
watch_type_t | type | ||
) |
void watch_free | ( | watch_t * | w | ) |
|
static |
|
static |
Handler for watches with type: WATCH_READ or WATCH_WRITE
Mark watch with w->removed = -1, to indicate that watch is in use. And it shouldn't be executed again. [If watch can or even must be executed twice from ekg_loop() than you must change w->removed by yourself.]
If handler of watch return -1 or watch was removed inside function [by watch_remove() or watch_free()]. Than it'll be removed.
ELSE Update w->started field to current time.
w | - watch_t to handler |
|
static |
|
static |
|
static |
|
static |
int watch_remove | ( | plugin_t * | plugin, |
int | fd, | ||
watch_type_t | type | ||
) |
int watch_write | ( | watch_t * | w, |
const char * | format, | ||
... | |||
) |
int watch_write_data | ( | watch_t * | w, |
const char * | buf, | ||
int | len | ||
) |
|
static |
|
static |