prelude-plugin: libprelude Reference Manual

## prelude-plugin prelude-plugin |

## Functions

#define | PRELUDE_PLUGIN_SET_PRELOADED_SYMBOLS
#define | PRELUDE_PLUGIN_OPTION_DECLARE_STRING_CB()
#define | prelude_plugin_get_name()
#define | prelude_plugin_set_name()
#define | prelude_plugin_set_destroy_func()
void | prelude_plugin_entry_set_plugin ()
int | prelude_plugin_set_activation_option ()
int | prelude_plugin_instance_subscribe ()
int | prelude_plugin_instance_unsubscribe ()
int | prelude_plugin_new_instance ()
prelude_plugin_generic_t * | prelude_plugin_search_by_name ()
prelude_plugin_instance_t * | prelude_plugin_search_instance_by_name ()
void | prelude_plugin_instance_set_data ()
void * | prelude_plugin_instance_get_data ()
void | prelude_plugin_instance_set_plugin_data ()
void * | prelude_plugin_instance_get_plugin_data ()
const char * | prelude_plugin_instance_get_name ()
prelude_plugin_generic_t * | prelude_plugin_instance_get_plugin ()
int | prelude_plugin_load_from_dir ()
int | prelude_plugin_instance_add ()
void | prelude_plugin_instance_del ()
void | prelude_plugin_instance_compute_time ()
int | prelude_plugin_instance_call_commit_func ()
prelude_bool_t | prelude_plugin_instance_has_commit_func ()
void | prelude_plugin_set_preloaded_symbols ()
prelude_plugin_generic_t * | prelude_plugin_get_next ()
void | prelude_plugin_unload ()
#define | prelude_plugin_compute_stats()
#define | prelude_plugin_run()

## Types and Values

#define | lt_preloaded_symbols
#define | PRELUDE_PLUGIN_API_VERSION
typedef | prelude_plugin_entry_t
typedef | prelude_plugin_instance_t
#define | PRELUDE_PLUGIN_GENERIC
| prelude_plugin_generic_t

## Description

## Functions

### PRELUDE_PLUGIN_SET_PRELOADED_SYMBOLS

    #define             PRELUDE_PLUGIN_SET_PRELOADED_SYMBOLS()

### PRELUDE_PLUGIN_OPTION_DECLARE_STRING_CB()

    #define             PRELUDE_PLUGIN_OPTION_DECLARE_STRING_CB(prefix, type, name)

### prelude_plugin_get_name()

    #define prelude_plugin_get_name(p) (p)->name

### prelude_plugin_set_name()

    #define prelude_plugin_set_name(p, str) (p)->name = (str)

### prelude_plugin_set_destroy_func()

    #define prelude_plugin_set_destroy_func(p, func) (p)->destroy = func

### prelude_plugin_entry_set_plugin ()

    void
    prelude_plugin_entry_set_plugin (prelude_plugin_entry_t *pe,
                                     prelude_plugin_generic_t *pl);

### prelude_plugin_set_activation_option ()

    int
    prelude_plugin_set_activation_option (prelude_plugin_entry_t *pe,
                                          prelude_option_t *opt,
                                          int (*commit) (prelude_plugin_instance_t *pi, prelude_string_t *err));

### prelude_plugin_instance_subscribe ()

    int
    prelude_plugin_instance_subscribe (prelude_plugin_instance_t *pi);

### prelude_plugin_instance_unsubscribe ()

    int
    prelude_plugin_instance_unsubscribe (prelude_plugin_instance_t *pi);

Set `pi` to be inactive.

The unsubscribe function specified in `plugin_load_from_dir()` is called for plugin un-registration and the instance for this plugin is freed.

#### Parameters

pi | Pointer to a plugin instance. |

#### Returns

0 on success, -1 if an error occured.

### prelude_plugin_new_instance ()

    int
    prelude_plugin_new_instance (prelude_plugin_instance_t **pi,
                                 prelude_plugin_generic_t *plugin,
                                 const char *name,
                                 void *data);

### prelude_plugin_search_by_name ()

    prelude_plugin_generic_t *
    prelude_plugin_search_by_name (prelude_list_t *head,
                                   const char *name);

Search `head` list of plugin for a plugin with name `name` .

#### Parameters

head | List where to search the plugin from. |
name | Name of the plugin to search. |

#### Returns

the a prelude_plugin_t on success, or NULL if the plugin does not exist.

### prelude_plugin_search_instance_by_name ()

    prelude_plugin_instance_t *
    prelude_plugin_search_instance_by_name
                                   (prelude_list_t *head,
                                    const char *pname,
                                    const char *iname);

### prelude_plugin_instance_set_data ()

    void
    prelude_plugin_instance_set_data (prelude_plugin_instance_t *pi,
                                      void *data);

### prelude_plugin_instance_get_data ()

    void *
    prelude_plugin_instance_get_data (prelude_plugin_instance_t *pi);

### prelude_plugin_instance_set_plugin_data ()

    void
    prelude_plugin_instance_set_plugin_data
                                   (prelude_plugin_instance_t *pi,
                                    void *data);

### prelude_plugin_instance_get_plugin_data ()

    void *
    prelude_plugin_instance_get_plugin_data
                                   (prelude_plugin_instance_t *pi);

### prelude_plugin_instance_get_name ()

    const char *
    prelude_plugin_instance_get_name (prelude_plugin_instance_t *pi);

### prelude_plugin_instance_get_plugin ()

    prelude_plugin_generic_t *
    prelude_plugin_instance_get_plugin (prelude_plugin_instance_t *pi);

### prelude_plugin_load_from_dir ()

    int
    prelude_plugin_load_from_dir (prelude_list_t *head,
                                  const char *dirname,
                                  const char *symbol,
                                  void *ptr,
                                  int (*subscribe) (prelude_plugin_instance_t *p),
                                  void (*unsubscribe) (prelude_plugin_instance_t *pi));

Load all plugins in directory 'dirname', using `symbol` entry point. Each plugin have a `subscribe` and `unsubscribe` callback associated with it.

The plugins are loaded, but not active, until someone call `prelude_plugin_subscribe()` on one of the plugin. Which'll call `subscribe` in order to register it.

`ptr` is an extra argument provided to the plugin at initialization time.

#### Parameters

head | List where the loaded plugin should be added. |
dirname | The directory to load the plugin from. |
symbol | Symbol to lookup within loaded plugin. |
ptr | Extra pointer to provide to the plugin initialization function. |
subscribe | Pointer to a callback function for plugin subscribtion. |
unsubscribe | Pointer to a callback function for plugin un-subscribtion. |

#### Returns

The number of loaded plugins on success, -1 on error.

### prelude_plugin_instance_add ()

    int
    prelude_plugin_instance_add (prelude_plugin_instance_t *pi,
                                 prelude_list_t *h);

This function add the plugin instance associated with `pi` to the linked list specified by `h` . If this instance is already used somewhere else, a copy is made, since instance does not share information).

#### Parameters

pi | Pointer to a plugin instance |
h | Pointer to a linked list |

#### Returns

0 on success or -1 if an error occured.

### prelude_plugin_instance_del ()

    void
    prelude_plugin_instance_del (prelude_plugin_instance_t *pi);

Delete `pi` from the list specified at `prelude_plugin_instance_add()` time.

#### Parameters

pi | Pointer to a plugin instance. |

### prelude_plugin_instance_compute_time ()

    void
    prelude_plugin_instance_compute_time (prelude_plugin_instance_t *pi,
                                          struct timeval *start,
                                          struct timeval *end);

### prelude_plugin_instance_call_commit_func ()

    int
    prelude_plugin_instance_call_commit_func
                                   (prelude_plugin_instance_t *pi,
                                    prelude_string_t *err);

### prelude_plugin_instance_has_commit_func ()

    prelude_bool_t
    prelude_plugin_instance_has_commit_func
                                   (prelude_plugin_instance_t *pi);

### prelude_plugin_set_preloaded_symbols ()

    void
    prelude_plugin_set_preloaded_symbols (void *symlist);

### prelude_plugin_get_next ()

    prelude_plugin_generic_t *
    prelude_plugin_get_next (prelude_list_t *head,
                             prelude_list_t **iter);

### prelude_plugin_unload ()

    void
    prelude_plugin_unload (prelude_plugin_generic_t *plugin);

### prelude_plugin_compute_stats()

    #define             prelude_plugin_compute_stats(pi, func)

### prelude_plugin_run()

    #define             prelude_plugin_run(pi, type, member, ...)

## Types and Values

### lt_preloaded_symbols

    # define lt_preloaded_symbols lt__PROGRAM__LTX_preloaded_symbols

### PRELUDE_PLUGIN_API_VERSION

    #define PRELUDE_PLUGIN_API_VERSION 1

### prelude_plugin_entry_t

    typedef struct prelude_plugin_entry prelude_plugin_entry_t;

### prelude_plugin_instance_t

    typedef struct prelude_plugin_instance prelude_plugin_instance_t;

### PRELUDE_PLUGIN_GENERIC

    #define             PRELUDE_PLUGIN_GENERIC

### prelude_plugin_generic_t

    typedef struct {
            PRELUDE_PLUGIN_GENERIC;
    } prelude_plugin_generic_t;