ekg2  GIT master
Struktury danych | Funkcje | Zmienne
Dokumentacja pliku sources.c
#include "ekg2.h"
#include "internal.h"
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <sys/wait.h>
Wykres zależności załączania dla sources.c:

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_twatch_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_twatch_add (plugin_t *plugin, int fd, watch_type_t type, watcher_handler_func_t *handler, void *data)
 
watch_twatch_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
 

Dokumentacja funkcji

◆ child_destroy_notify()

static void child_destroy_notify ( gpointer  data)
static

◆ child_print()

static void child_print ( gpointer  data,
gpointer  user_data 
)
static

◆ child_wrapper()

static void child_wrapper ( GPid  pid,
gint  status,
gpointer  data 
)
static

◆ cmd_at()

int cmd_at ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)

◆ cmd_debug_timers()

int cmd_debug_timers ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)

◆ cmd_timer()

int cmd_timer ( const char *  name,
const char **  params,
session_t session,
const char *  target,
int  quiet 
)

◆ ekg_child_add()

ekg_child_t ekg_child_add ( plugin_t plugin,
const gchar *  name_format,
GPid  pid,
GChildWatchFunc  handler,
gpointer  data,
GDestroyNotify  destr,
  ... 
)

ekg_child_add()

Add a watcher for the child process.

Parametry
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.
Zwraca
An unique ekg_child_t.

◆ ekg_children_print()

gint ekg_children_print ( gint  quiet)

◆ ekg_source_remove()

void ekg_source_remove ( ekg_source_t  s)

ekg_source_remove()

Remove a particular source (which can be ekg_child_t, ekg_timer_t...).

Parametry
s- the source identifier.

◆ ekg_source_remove_by_data()

gboolean ekg_source_remove_by_data ( gpointer  priv_data,
const gchar *  name 
)

◆ ekg_source_remove_by_handler()

gboolean ekg_source_remove_by_handler ( gpointer  handler,
const gchar *  name 
)

◆ ekg_source_remove_by_plugin()

gboolean ekg_source_remove_by_plugin ( plugin_t plugin,
const gchar *  name 
)

◆ ekg_timer_add()

ekg_timer_t ekg_timer_add ( plugin_t plugin,
const gchar *  name_format,
guint64  interval,
GSourceFunc  handler,
gpointer  data,
GDestroyNotify  destr,
  ... 
)

ekg_timer_add()

Add a timer.

Parametry
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.
Zwraca
An unique ekg_timer_t.

◆ source_free()

static void source_free ( struct ekg_source s)
static

◆ source_new()

static ekg_source_t source_new ( plugin_t plugin,
const gchar *  name_format,
gpointer  data,
GDestroyNotify  destr,
va_list  args 
)
static

◆ source_new_va()

static ekg_source_t source_new_va ( plugin_t plugin,
const gchar *  name_format,
gpointer  data,
GDestroyNotify  destr,
  ... 
)
static

◆ source_remove()

static void source_remove ( gpointer  data,
gpointer  user_data 
)
static

◆ source_remove_by_d()

static void source_remove_by_d ( gpointer  data,
gpointer  user_data 
)
static

ekg_source_remove_by_data()

Remove source(s) using a particular private data (and optionally matching the name).

Parametry
priv_data- private data pointer.
name- expected source name or NULL if any.
Zwraca
TRUE if any source found, FALSE otherwise.
Nota
This function doesn't do any source type checks. We assume that either one doesn't reuse the same private data with different source types or expects to remove all of them at once.

◆ source_remove_by_h()

static void source_remove_by_h ( gpointer  data,
gpointer  user_data 
)
static

◆ source_remove_by_p()

static void source_remove_by_p ( gpointer  data,
gpointer  user_data 
)
static

ekg_source_remove_by_plugin()

Remove source(s) using a particular plugin (e.g. on plugin unload), and optionally bearing a name.

Parametry
plugin- plugin_t pointer.
name- expected source name or NULL if any.
Zwraca
TRUE if any source found, FALSE otherwise.

◆ source_set_id()

static void source_set_id ( struct ekg_source s,
guint  id 
)
static

◆ sources_destroy()

void sources_destroy ( void  )

◆ timer_add()

ekg_timer_t timer_add ( plugin_t plugin,
const gchar *  name,
guint  period,
gboolean  persist,
gint(*)(gint, gpointer)  function,
gpointer  data 
)

◆ timer_add_ms()

ekg_timer_t timer_add_ms ( plugin_t plugin,
const gchar *  name,
guint  period,
gboolean  persist,
gint(*)(gint, gpointer)  function,
gpointer  data 
)

◆ timer_add_session()

ekg_timer_t timer_add_session ( session_t session,
const gchar *  name,
guint  period,
gboolean  persist,
gint(*)(gint, session_t *)  function 
)

◆ timer_debug_print()

static void timer_debug_print ( gpointer  data,
gpointer  user_data 
)
static

◆ timer_destroy_notify()

static void timer_destroy_notify ( gpointer  data)
static

◆ timer_find_session()

ekg_timer_t timer_find_session ( session_t session,
const gchar *  name 
)

◆ timer_find_session_cmp()

gint timer_find_session_cmp ( gconstpointer  li,
gconstpointer  ui 
)

◆ timer_handle_at()

gint timer_handle_at ( gint  type,
gpointer  data 
)

◆ timer_handle_command()

gint timer_handle_command ( gint  type,
gpointer  data 
)

◆ timer_match_name()

static gint timer_match_name ( gconstpointer  li,
gconstpointer  ui 
)
inlinestatic

◆ timer_next_call()

static gchar* timer_next_call ( struct ekg_source t)
static

◆ timer_print()

static void timer_print ( gpointer  data,
gpointer  user_data 
)
static

◆ timer_print_list()

static void timer_print_list ( gpointer  data,
gpointer  user_data 
)
static

◆ timer_remove()

gint timer_remove ( plugin_t plugin,
const gchar *  name 
)

◆ timer_remove_session()

gint timer_remove_session ( session_t session,
const gchar *  name 
)

◆ timer_remove_session_iter()

static void timer_remove_session_iter ( gpointer  data,
gpointer  user_data 
)
static

◆ timer_remove_user()

G_GNUC_INTERNAL gint timer_remove_user ( gint(*)(gint, gpointer)  handler)

◆ timer_wrapper()

static gboolean timer_wrapper ( gpointer  data)
static

◆ timer_wrapper_destroy_notify()

static void timer_wrapper_destroy_notify ( gpointer  data)
static

◆ timer_wrapper_old()

static gboolean timer_wrapper_old ( gpointer  data)
static

◆ timers_write()

void timers_write ( GOutputStream *  f)

◆ watch_add()

watch_t* watch_add ( plugin_t plugin,
int  fd,
watch_type_t  type,
watcher_handler_func_t handler,
void *  data 
)

watch_add()

Create new watch_t and add it on the beginning of watches list.

Parametry
plugin- plugin
fd- fd to watch data for.
type- type of watch.
handler- handler of watch.
data- data which be passed to handler.
Zwraca
Created watch_t. if type is either WATCH_READ_LINE or WATCH_WRITE_LINE than also allocate memory for buffer

◆ watch_add_session()

watch_t* watch_add_session ( session_t session,
int  fd,
watch_type_t  type,
watcher_session_handler_func_t handler 
)

watch_add_session()

Create new session watch_t and add it on the beginning of watches list.

Parametry
session- session
fd- fd to watch data for
type- type of watch.
handler- handler of watch.
Zwraca
If session is NULL, or session->plugin is NULL, it return NULL.
else created watch_t

◆ watch_find()

watch_t* watch_find ( plugin_t plugin,
int  fd,
watch_type_t  type 
)

◆ watch_free()

void watch_free ( watch_t w)

◆ watch_free_data()

static void watch_free_data ( watch_t data)
static

◆ watch_handle()

static int watch_handle ( watch_t w)
static

watch_handle()

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.

Parametry
w- watch_t to handler
Do zrobienia:
We only check for w->removed == -1, maybe instead change it to: w->removed != 0

◆ watch_handle_line()

static int watch_handle_line ( watch_t w)
static

◆ watch_handle_write()

static int watch_handle_write ( watch_t w)
static

◆ watch_old_destroy_notify()

static void watch_old_destroy_notify ( gpointer  data)
static

◆ watch_old_wrapper()

static gboolean watch_old_wrapper ( GIOChannel *  f,
GIOCondition  cond,
gpointer  data 
)
static

◆ watch_remove()

int watch_remove ( plugin_t plugin,
int  fd,
watch_type_t  type 
)

◆ watch_write()

int watch_write ( watch_t w,
const char *  format,
  ... 
)

◆ watch_write_data()

int watch_write_data ( watch_t w,
const char *  buf,
int  len 
)

Dokumentacja zmiennych

◆ children

GSList* children = NULL
static

◆ timers

GSList* timers = NULL
static