## prelude-plugin

prelude-plugin

## Synopsis

    #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;
    #define             PRELUDE_PLUGIN_SET_PRELOADED_SYMBOLS()
    #define             PRELUDE_PLUGIN_OPTION_DECLARE_STRING_CB(prefix, type, name)
    #define             prelude_plugin_get_name             (p)
    #define             prelude_plugin_set_name             (p, str)
    #define             prelude_plugin_set_destroy_func     (p, func)
    void                prelude_plugin_entry_set_plugin     (prelude_plugin_entry_t *pe,
                                                             prelude_plugin_generic_t *pl);
    int                 prelude_plugin_set_activation_option
                                                            (prelude_plugin_entry_t *pe,
                                                             prelude_option_t *opt,
                                                             int (commitprelude_plugin_instance_t *pi, prelude_string_t *err) ());
    int                 prelude_plugin_instance_subscribe   (prelude_plugin_instance_t *pi);
    int                 prelude_plugin_instance_unsubscribe (prelude_plugin_instance_t *pi);
    int                 prelude_plugin_new_instance         (prelude_plugin_instance_t **pi,
                                                             prelude_plugin_generic_t *plugin,
                                                             const char *name,
                                                             void *data);
    prelude_plugin_generic_t * prelude_plugin_search_by_name
                                                            (prelude_list_t *head,
                                                             const char *name);
    prelude_plugin_instance_t * prelude_plugin_search_instance_by_name
                                                            (prelude_list_t *head,
                                                             const char *pname,
                                                             const char *iname);
    void                prelude_plugin_instance_set_data    (prelude_plugin_instance_t *pi,
                                                             void *data);
    void *              prelude_plugin_instance_get_data    (prelude_plugin_instance_t *pi);
    void                prelude_plugin_instance_set_plugin_data
                                                            (prelude_plugin_instance_t *pi,
                                                             void *data);
    void *              prelude_plugin_instance_get_plugin_data
                                                            (prelude_plugin_instance_t *pi);
    const char *        prelude_plugin_instance_get_name    (prelude_plugin_instance_t *pi);
    prelude_plugin_generic_t * prelude_plugin_instance_get_plugin
                                                            (prelude_plugin_instance_t *pi);
    int                 prelude_plugin_load_from_dir        (prelude_list_t *head,
                                                             const char *dirname,
                                                             const char *symbol,
                                                             void *ptr,
                                                             int (subscribeprelude_plugin_instance_t *p) (),
                                                             void (unsubscribeprelude_plugin_instance_t *pi) ());
    int                 prelude_plugin_instance_add         (prelude_plugin_instance_t *pi,
                                                             prelude_list_t *h);
    void                prelude_plugin_instance_del         (prelude_plugin_instance_t *pi);
    void                prelude_plugin_instance_compute_time
                                                            (prelude_plugin_instance_t *pi,
                                                             struct timeval *start,
                                                             struct timeval *end);
    int                 prelude_plugin_instance_call_commit_func
                                                            (prelude_plugin_instance_t *pi,
                                                             prelude_string_t *err);
    prelude_bool_t      prelude_plugin_instance_has_commit_func
                                                            (prelude_plugin_instance_t *pi);
    void                prelude_plugin_set_preloaded_symbols
                                                            (void *symlist);
    prelude_plugin_generic_t * prelude_plugin_get_next      (prelude_list_t *head,
                                                             prelude_list_t **iter);
    void                prelude_plugin_unload               (prelude_plugin_generic_t *plugin);
    #define             prelude_plugin_compute_stats        (pi, func)
    #define             prelude_plugin_run                  (pi, type, member, ...)

## Description

## Details

### 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;

### 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)

`prefix` : |
`type` : |
`name` : |

### prelude_plugin_get_name()

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

`p` : |

### prelude_plugin_set_name()

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

`p` : |
`str` : |

### prelude_plugin_set_destroy_func()

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

`p` : |
`func` : |

### prelude_plugin_entry_set_plugin ()

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

`pe` : |
`pl` : |

### prelude_plugin_set_activation_option ()

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

`pe` : |
`opt` : |
`commit` : |
Returns : |

### prelude_plugin_instance_subscribe ()

    int                 prelude_plugin_instance_subscribe   (prelude_plugin_instance_t *pi);

`pi` : |
Returns : |

### 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.

`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);

`pi` : |
`plugin` : |
`name` : |
`data` : |
Returns : |

### 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`.

`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);

`head` : |
`pname` : |
`iname` : |
Returns : |

### prelude_plugin_instance_set_data ()

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

`pi` : |
`data` : |

### prelude_plugin_instance_get_data ()

    void *              prelude_plugin_instance_get_data    (prelude_plugin_instance_t *pi);

`pi` : |
Returns : |

### prelude_plugin_instance_set_plugin_data ()

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

`pi` : |
`data` : |

### prelude_plugin_instance_get_plugin_data ()

    void *              prelude_plugin_instance_get_plugin_data
                                                            (prelude_plugin_instance_t *pi);

`pi` : |
Returns : |

### prelude_plugin_instance_get_name ()

    const char *        prelude_plugin_instance_get_name    (prelude_plugin_instance_t *pi);

`pi` : |
Returns : |

### prelude_plugin_instance_get_plugin ()

    prelude_plugin_generic_t * prelude_plugin_instance_get_plugin
                                                            (prelude_plugin_instance_t *pi);

`pi` : |
Returns : |

### prelude_plugin_load_from_dir ()

    int                 prelude_plugin_load_from_dir        (prelude_list_t *head,
                                                             const char *dirname,
                                                             const char *symbol,
                                                             void *ptr,
                                                             int (subscribeprelude_plugin_instance_t *p) (),
                                                             void (unsubscribeprelude_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.

`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).

`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.

`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);

`pi` : |
`start` : |
`end` : |

### prelude_plugin_instance_call_commit_func ()

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

`pi` : |
`err` : |
Returns : |

### prelude_plugin_instance_has_commit_func ()

    prelude_bool_t      prelude_plugin_instance_has_commit_func
                                                            (prelude_plugin_instance_t *pi);

`pi` : |
Returns : |

### prelude_plugin_set_preloaded_symbols ()

    void                prelude_plugin_set_preloaded_symbols
                                                            (void *symlist);

`symlist` : |

### prelude_plugin_get_next ()

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

`head` : |
`iter` : |
Returns : |

### prelude_plugin_unload ()

    void                prelude_plugin_unload               (prelude_plugin_generic_t *plugin);

`plugin` : |

### prelude_plugin_compute_stats()

    #define             prelude_plugin_compute_stats(pi, func)

`pi` : |
`func` : |

### prelude_plugin_run()

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

`pi` : |
`type` : |
`member` : |
`...` : |