ekg2
 All Struktury Danych Pliki Funkcje Zmienne Definicje typów Wyliczenia Wartości wyliczeń Definicje Grupay Strony
Struktury danych | Definicje | Definicje typów | Wyliczenia | Funkcje | Zmienne
Dokumentacja pliku plugins.h
#include <sys/types.h>
#include <stdarg.h>
#include "dynstuff.h"
#include "sessions.h"

Idź do kodu źródłowego tego pliku.

Struktury danych

struct  plugins_params_t
 
struct  protocol_plugin_priv
 
struct  plugin
 
struct  queryx
 
struct  watch
 

Definicje

#define EKG_ABI_VER   4921
 
#define EXPORT   __attribute__ ((visibility("default")))
 
#define PLUGIN_VAR_ADD(name, type, value, secret, notify)   { name, value, secret, type, notify }
 
#define PLUGIN_VAR_END()   { NULL, NULL, 0, -1, NULL }
 
#define PLUGIN_CHECK_VER(name)   { if (!plugin_abi_version(EKG_ABI_VER, name)) return -1; }
 
#define PLUGIN_DEFINE(x, y, z)
 
#define QUERY(x)   int x(void *data, va_list ap)
 
#define WATCHER(x)   int x(int type, int fd, watch_type_t watch, void *data)
 
#define WATCHER_LINE(x)   int x(int type, int fd, const char *watch, void *data)
 
#define WATCHER_SESSION(x)   int x(int type, int fd, watch_type_t watch, session_t *s)
 
#define WATCHER_SESSION_LINE(x)   int x(int type, int fd, const char *watch, session_t *s)
 
#define watch_add_line(p, fd, type, handler, data)   watch_add(p, fd, type, (watcher_handler_func_t *) (handler), data)
 
#define watch_add_session_line(s, fd, type, handler)   watch_add_session(s, fd, type, (watcher_session_handler_func_t *) (handler))
 

Definicje typów

typedef int(* plugin_destroy_func_t )(void)
 
typedef int(* plugin_theme_init_func_t )(void)
 
typedef void( plugin_notify_func_t )(session_t *, const char *)
 
typedef struct plugin plugin_t
 
typedef int query_handler_func_t (void *data, va_list ap)
 
typedef struct queryx query_t
 
typedef int watcher_handler_func_t (int type, int fd, watch_type_t watch, void *data)
 
typedef int watcher_session_handler_func_t (int type, int fd, watch_type_t watch, session_t *s)
 
typedef struct watch watch_t
 
typedef void * watch_handler_func_t
 

Wyliczenia

enum  plugin_class_t {
  PLUGIN_ANY = 0, PLUGIN_GENERIC, PLUGIN_PROTOCOL, PLUGIN_UI,
  PLUGIN_LOG, PLUGIN_SCRIPTING, PLUGIN_AUDIO, PLUGIN_CODEC,
  PLUGIN_CRYPT, PLUGIN_ANY = 0, PLUGIN_GENERIC, PLUGIN_PROTOCOL,
  PLUGIN_UI, PLUGIN_LOG, PLUGIN_SCRIPTING, PLUGIN_AUDIO,
  PLUGIN_CODEC, PLUGIN_CRYPT
}
 
enum  watch_type_t {
  WATCH_NONE = 0, WATCH_WRITE = 1, WATCH_READ = 2, WATCH_READ_LINE = 4,
  WATCH_WRITE_LINE = 8, WATCH_NONE = 0, WATCH_WRITE = 1, WATCH_READ = 2,
  WATCH_READ_LINE = 4, WATCH_WRITE_LINE = 8
}
 

Funkcje

int plugin_abi_version (int plugin_abi_ver, const char *plugin_name)
 
int plugin_load (const char *name, int prio, int quiet)
 
int plugin_unload (plugin_t *)
 
int plugin_register (plugin_t *, int prio)
 
int plugin_unregister (plugin_t *)
 
plugin_tplugin_find (const char *name)
 
plugin_tplugin_find_uid (const char *uid)
 
int have_plugin_of_class (plugin_class_t pclass)
 
int plugin_var_add (plugin_t *pl, const char *name, int type, const char *value, int secret, plugin_notify_func_t *notify)
 
int plugin_var_find (plugin_t *pl, const char *name)
 
void plugins_unlink (plugin_t *pl)
 
query_tquery_connect (plugin_t *plugin, const char *name, query_handler_func_t *handler, void *data)
 
query_tquery_connect_id (plugin_t *plugin, const int id, query_handler_func_t *handler, void *data)
 
int query_free (query_t *q)
 
void query_external_free ()
 
int query_emit_id (plugin_t *, const int,...)
 
int query_emit (plugin_t *, const char *,...)
 
void queries_reconnect ()
 
const char * query_name (const int id)
 
struct query_defquery_struct (const int id)
 
int watch_write (watch_t *w, const char *format,...)
 
int watch_write_data (watch_t *w, const char *buf, int len)
 
watch_twatch_find (plugin_t *plugin, int fd, watch_type_t type)
 
void watch_free (watch_t *w)
 
int watch_timeout_set (watch_t *w, time_t timeout)
 
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)
 
void watch_handle (watch_t *w)
 
void watch_handle_line (watch_t *w)
 
int watch_handle_write (watch_t *w)
 
int ekg2_dlinit ()
 

Zmienne

plugin_tplugins
 
list_t watches
 
query_tqueries []
 

Dokumentacja definicji

#define EKG_ABI_VER   4921
#define EXPORT   __attribute__ ((visibility("default")))
#define PLUGIN_CHECK_VER (   name)    { if (!plugin_abi_version(EKG_ABI_VER, name)) return -1; }
#define PLUGIN_DEFINE (   x,
  y,
 
)
Wartość:
static int x##_plugin_destroy(); \
\
plugin_t x##_plugin = { \
.name = #x, \
.pclass = y, \
.destroy = x##_plugin_destroy, \
.theme_init = z \
}
#define PLUGIN_VAR_ADD (   name,
  type,
  value,
  secret,
  notify 
)    { name, value, secret, type, notify }
#define PLUGIN_VAR_END ( )    { NULL, NULL, 0, -1, NULL }
#define QUERY (   x)    int x(void *data, va_list ap)
#define watch_add_line (   p,
  fd,
  type,
  handler,
  data 
)    watch_add(p, fd, type, (watcher_handler_func_t *) (handler), data)
#define watch_add_session_line (   s,
  fd,
  type,
  handler 
)    watch_add_session(s, fd, type, (watcher_session_handler_func_t *) (handler))
#define WATCHER (   x)    int x(int type, int fd, watch_type_t watch, void *data)
#define WATCHER_LINE (   x)    int x(int type, int fd, const char *watch, void *data)
#define WATCHER_SESSION (   x)    int x(int type, int fd, watch_type_t watch, session_t *s)
#define WATCHER_SESSION_LINE (   x)    int x(int type, int fd, const char *watch, session_t *s)

Dokumentacja definicji typów

typedef int(* plugin_destroy_func_t)(void)
typedef void( plugin_notify_func_t)(session_t *, const char *)
typedef struct plugin plugin_t
typedef int(* plugin_theme_init_func_t)(void)
typedef int query_handler_func_t(void *data, va_list ap)
typedef struct queryx query_t
typedef void* watch_handler_func_t
typedef struct watch watch_t
typedef int watcher_handler_func_t(int type, int fd, watch_type_t watch, void *data)
typedef int watcher_session_handler_func_t(int type, int fd, watch_type_t watch, session_t *s)

Dokumentacja typów wyliczanych

Wartości wyliczeń
PLUGIN_ANY 
PLUGIN_GENERIC 
PLUGIN_PROTOCOL 
PLUGIN_UI 
PLUGIN_LOG 
PLUGIN_SCRIPTING 
PLUGIN_AUDIO 
PLUGIN_CODEC 
PLUGIN_CRYPT 
PLUGIN_ANY 
PLUGIN_GENERIC 
PLUGIN_PROTOCOL 
PLUGIN_UI 
PLUGIN_LOG 
PLUGIN_SCRIPTING 
PLUGIN_AUDIO 
PLUGIN_CODEC 
PLUGIN_CRYPT 
Wartości wyliczeń
WATCH_NONE 
WATCH_WRITE 
WATCH_READ 
WATCH_READ_LINE 
WATCH_WRITE_LINE 
WATCH_NONE 
WATCH_WRITE 
WATCH_READ 
WATCH_READ_LINE 
WATCH_WRITE_LINE 

Dokumentacja funkcji

int ekg2_dlinit ( )
int have_plugin_of_class ( plugin_class_t  pclass)

have_plugin_of_class()

Check if we have loaded plugin from pclass

Parametry
pclass
Zwraca
1 - If such plugin was founded
else 0
int plugin_abi_version ( int  plugin_abi_ver,
const char *  plugin_name 
)
plugin_t* plugin_find ( const char *  name)

plugin_find()

Find plugin by name

Parametry
name- name of plugin_t
Zwraca
plugin_t with given name, or NULL if not found.
plugin_t* plugin_find_uid ( const char *  uid)

plugin_find_uid()

Find PLUGIN_PROTOCOL plugin which can handle uid

Do zrobienia:
used only by session_add() in session.c move it there?
Zobacz również
valid_plugin_uid() - For function to check if given plugin can handle given uid
Zwraca
If such plugin was founded return it, or NULL if not found.
int plugin_load ( const char *  name,
int  prio,
int  quiet 
)
int plugin_register ( plugin_t ,
int  prio 
)
int plugin_unload ( plugin_t )
int plugin_unregister ( plugin_t )
int plugin_var_add ( plugin_t pl,
const char *  name,
int  type,
const char *  value,
int  secret,
plugin_notify_func_t notify 
)
int plugin_var_find ( plugin_t pl,
const char *  name 
)

plugin_var_find()

it looks for given variable name in given plugin

Parametry
pl- plugin
name- variable name

returns sequence number+1 of variable if found, else 0

void plugins_unlink ( plugin_t pl)
void queries_reconnect ( )

queries_reconnect()

Reconnect (resort) all queries, e.g. after plugin prio change.

query_t* query_connect ( plugin_t plugin,
const char *  name,
query_handler_func_t handler,
void *  data 
)
query_t* query_connect_id ( plugin_t plugin,
const int  id,
query_handler_func_t handler,
void *  data 
)
int query_emit ( plugin_t ,
const char *  ,
  ... 
)
int query_emit_id ( plugin_t ,
const int  ,
  ... 
)
void query_external_free ( )

query_external_free()

Free memory allocated by query_id() for not-known-in-core-query-names

Do zrobienia:
We don't destroy here queries which uses these ids >= QUERY_EXTERNAL.
It's quite correct in current api. But if you change it, you must clean after yourself.
int query_free ( query_t q)
const char* query_name ( const int  id)

query_name()

Get name of query, by passed id

Zwraca
  • If id is known for core (id < QUERY_EXTERNAL) than return it's name
  • If it was ,,seen'' by query_id() than return name registered.
  • else return NULL, and display info that smth really nasty happen.
struct query_def* query_struct ( const int  id)

query_struct()

Get struct of query, by passed id

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_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_t* watch_find ( plugin_t plugin,
int  fd,
watch_type_t  type 
)
void watch_free ( watch_t w)
void watch_handle ( watch_t w)

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
void watch_handle_line ( watch_t w)
int watch_handle_write ( watch_t w)
int watch_remove ( plugin_t plugin,
int  fd,
watch_type_t  type 
)
int watch_timeout_set ( watch_t w,
time_t  timeout 
)
int watch_write ( watch_t w,
const char *  format,
  ... 
)
int watch_write_data ( watch_t w,
const char *  buf,
int  len 
)

Dokumentacja zmiennych

plugin_t* plugins
query_t* queries[]
list_t watches