# cpluff.h

Go to the documentation of this file.

    00001 /*-------------------------------------------------------------------------
    00002  * C-Pluff, a plug-in framework for C
    00003  * Copyright 2007 Johannes Lehtinen
    00004  *
    00005  * Permission is hereby granted, free of charge, to any person obtaining a
    00006  * copy of this software and associated documentation files (the "Software"),
    00007  * to deal in the Software without restriction, including without limitation
    00008  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
    00009  * and/or sell copies of the Software, and to permit persons to whom the
    00010  * Software is furnished to do so, subject to the following conditions:
    00011  *
    00012  * The above copyright notice and this permission notice shall be included
    00013  * in all copies or substantial portions of the Software.
    00014  *
    00015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
    00016  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
    00017  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
    00018  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
    00019  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
    00020  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
    00021  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    00022  *-----------------------------------------------------------------------*/
    00023
    00033 #ifndef CPLUFF_H_
    00034 #define CPLUFF_H_
    00035
    00041 #include <cpluffdef.h>
    00042
    00043 #ifdef __cplusplus
    00044 extern "C" {
    00045 #endif /*__cplusplus*/
    00046
    00047
    00048 /* ------------------------------------------------------------------------
    00049  * Defines
    00050  * ----------------------------------------------------------------------*/
    00051
    00060 #ifndef CP_C_API
    00061 #define CP_C_API CP_IMPORT
    00062 #endif
    00063
    00064
    00073
    00078 #define CP_SP_UPGRADE 0x01
    00079
    00084 #define CP_SP_STOP_ALL_ON_UPGRADE 0x02
    00085
    00091 #define CP_SP_STOP_ALL_ON_INSTALL 0x04
    00092
    00097 #define CP_SP_RESTART_ACTIVE 0x08
    00098
    00102 /* ------------------------------------------------------------------------
    00103  * Data types
    00104  * ----------------------------------------------------------------------*/
    00105
    00122 /* Enumerations */
    00123
    00133 enum cp_status_t {
    00134
    00139         CP_OK = 0,
    00140
    00142         CP_ERR_RESOURCE,
    00143
    00145         CP_ERR_UNKNOWN,
    00146
    00148         CP_ERR_IO,
    00149
    00151         CP_ERR_MALFORMED,
    00152
    00154         CP_ERR_CONFLICT,
    00155
    00157         CP_ERR_DEPENDENCY,
    00158
    00160         CP_ERR_RUNTIME
    00161
    00162 };
    00163
    00175 enum cp_plugin_state_t {
    00176
    00181         CP_PLUGIN_UNINSTALLED,
    00182
    00190         CP_PLUGIN_INSTALLED,
    00191
    00202         CP_PLUGIN_RESOLVED,
    00203
    00213         CP_PLUGIN_STARTING,
    00214
    00224         CP_PLUGIN_STOPPING,
    00225
    00230         CP_PLUGIN_ACTIVE
    00231
    00232 };
    00233
    00241 enum cp_log_severity_t {
    00242
    00244         CP_LOG_DEBUG,
    00245
    00247         CP_LOG_INFO,
    00248
    00250         CP_LOG_WARNING,
    00251
    00253         CP_LOG_ERROR
    00254
    00255 };
    00256
    00260 /* Typedefs */
    00261
    00268
    00281 typedef struct cp_context_t cp_context_t;
    00282
    00291
    00293 typedef struct cp_plugin_info_t cp_plugin_info_t;
    00294
    00296 typedef struct cp_plugin_import_t cp_plugin_import_t;
    00297
    00299 typedef struct cp_ext_point_t cp_ext_point_t;
    00300
    00302 typedef struct cp_extension_t cp_extension_t;
    00303
    00305 typedef struct cp_cfg_element_t cp_cfg_element_t;
    00306
    00308 typedef struct cp_plugin_runtime_t cp_plugin_runtime_t;
    00309
    00311 typedef enum cp_status_t cp_status_t;
    00312
    00314 typedef enum cp_plugin_state_t cp_plugin_state_t;
    00315
    00317 typedef enum cp_log_severity_t cp_log_severity_t;
    00318
    00327
    00344 typedef void (*cp_plugin_listener_func_t)(const char *plugin_id, cp_plugin_state_t old_state, cp_plugin_state_t new_state, void *user_data);
    00345
    00358 typedef void (*cp_logger_func_t)(cp_log_severity_t severity, const char *msg, const char *apid, void *user_data);
    00359
    00369 typedef void (*cp_fatal_error_func_t)(const char *msg);
    00370
    00381 typedef int (*cp_run_func_t)(void *plugin_data);
    00382
    00386 /* Data structures */
    00387
    00396 struct cp_plugin_info_t {
    00397
    00405         char *identifier;
    00406
    00413         char *name;
    00414
    00420         char *version;
    00421
    00429         char *provider_name;
    00430
    00438         char *plugin_path;
    00439
    00451         char *abi_bw_compatibility;
    00452
    00465         char *api_bw_compatibility;
    00466
    00475         char *req_cpluff_version;
    00476
    00478         unsigned int num_imports;
    00479
    00484         cp_plugin_import_t *imports;
    00485
    00493     char *runtime_lib_name;
    00494
    00501     char *runtime_funcs_symbol;
    00502
    00504         unsigned int num_ext_points;
    00505
    00511         cp_ext_point_t *ext_points;
    00512
    00514         unsigned int num_extensions;
    00515
    00521         cp_extension_t *extensions;
    00522
    00523 };
    00524
    00530 struct cp_plugin_import_t {
    00531
    00536         char *plugin_id;
    00537
    00546         char *version;
    00547
    00557         int optional;
    00558 };
    00559
    00566 struct cp_ext_point_t {
    00567
    00573         cp_plugin_info_t *plugin;
    00574
    00580         char *local_id;
    00581
    00587         char *identifier;
    00588
    00595         char *name;
    00596
    00603         char *schema_path;
    00604 };
    00605
    00611 struct cp_extension_t {
    00612
    00618         cp_plugin_info_t *plugin;
    00619
    00625         char *ext_point_id;
    00626
    00632         char *local_id;
    00633
    00639     char *identifier;
    00640
    00647         char *name;
    00648
    00655         cp_cfg_element_t *configuration;
    00656 };
    00657
    00667 struct cp_cfg_element_t {
    00668
    00673         char *name;
    00674
    00676         unsigned int num_atts;
    00677
    00682         char **atts;
    00683
    00689         char *value;
    00690
    00692         cp_cfg_element_t *parent;
    00693
    00695         unsigned int index;
    00696
    00698         unsigned int num_children;
    00699
    00704         cp_cfg_element_t *children;
    00705 };
    00706
    00734 struct cp_plugin_runtime_t {
    00735
    00753         void *(*create)(cp_context_t *ctx);
    00754
    00775         int (*start)(void *data);
    00776
    00800         void (*stop)(void *data);
    00801
    00814         void (*destroy)(void *data);
    00815
    00816 };
    00817
    00821 /* ------------------------------------------------------------------------
    00822  * Function declarations
    00823  * ----------------------------------------------------------------------*/
    00824
    00844
    00851 CP_C_API const char *cp_get_version(void) CP_GCC_PURE;
    00852
    00860 CP_C_API const char *cp_get_host_type(void) CP_GCC_PURE;
    00861
    00874
    00885 CP_C_API void cp_set_fatal_error_handler(cp_fatal_error_func_t error_handler);
    00886
    00902 CP_C_API cp_status_t cp_init(void);
    00903
    00914 CP_C_API void cp_destroy(void);
    00915
    00933
    00947 CP_C_API cp_context_t * cp_create_context(cp_status_t *status);
    00948
    00956 CP_C_API void cp_destroy_context(cp_context_t *ctx) CP_GCC_NONNULL(1);
    00957
    00970 CP_C_API cp_status_t cp_register_pcollection(cp_context_t *ctx, const char *dir) CP_GCC_NONNULL(1, 2);
    00971
    00981 CP_C_API void cp_unregister_pcollection(cp_context_t *ctx, const char *dir) CP_GCC_NONNULL(1, 2);
    00982
    00990 CP_C_API void cp_unregister_pcollections(cp_context_t *ctx) CP_GCC_NONNULL(1);
    00991
    01004
    01020 CP_C_API cp_status_t cp_register_logger(cp_context_t *ctx, cp_logger_func_t logger, void *user_data, cp_log_severity_t min_severity) CP_GCC_NONNULL(1, 2);
    01021
    01028 CP_C_API void cp_unregister_logger(cp_context_t *ctx, cp_logger_func_t logger) CP_GCC_NONNULL(1, 2);
    01029
    01037 CP_C_API void cp_log(cp_context_t *ctx, cp_log_severity_t severity, const char *msg) CP_GCC_NONNULL(1, 3);
    01038
    01046 CP_C_API int cp_is_logged(cp_context_t *ctx, cp_log_severity_t severity) CP_GCC_NONNULL(1);
    01047
    01059
    01076 CP_C_API cp_plugin_info_t * cp_load_plugin_descriptor(cp_context_t *ctx, const char *path, cp_status_t *status) CP_GCC_NONNULL(1, 2);
    01077
    01094 CP_C_API cp_status_t cp_install_plugin(cp_context_t *ctx, cp_plugin_info_t *pi) CP_GCC_NONNULL(1, 2);
    01095
    01119 CP_C_API cp_status_t cp_scan_plugins(cp_context_t *ctx, int flags) CP_GCC_NONNULL(1);
    01120
    01133 CP_C_API cp_status_t cp_start_plugin(cp_context_t *ctx, const char *id) CP_GCC_NONNULL(1, 2);
    01134
    01147 CP_C_API cp_status_t cp_stop_plugin(cp_context_t *ctx, const char *id) CP_GCC_NONNULL(1, 2);
    01148
    01154 CP_C_API void cp_stop_plugins(cp_context_t *ctx) CP_GCC_NONNULL(1);
    01155
    01164 CP_C_API cp_status_t cp_uninstall_plugin(cp_context_t *ctx, const char *id) CP_GCC_NONNULL(1, 2);
    01165
    01172 CP_C_API void cp_uninstall_plugins(cp_context_t *ctx) CP_GCC_NONNULL(1);
    01173
    01186
    01200 CP_C_API cp_plugin_info_t * cp_get_plugin_info(cp_context_t *ctx, const char *id, cp_status_t *status) CP_GCC_NONNULL(1);
    01201
    01214 CP_C_API cp_plugin_info_t ** cp_get_plugins_info(cp_context_t *ctx, cp_status_t *status, int *num) CP_GCC_NONNULL(1);
    01215
    01228 CP_C_API cp_ext_point_t ** cp_get_ext_points_info(cp_context_t *ctx, cp_status_t *status, int *num) CP_GCC_NONNULL(1);
    01229
    01243 CP_C_API cp_extension_t ** cp_get_extensions_info(cp_context_t *ctx, const char *extpt_id, cp_status_t *status, int *num) CP_GCC_NONNULL(1);
    01244
    01255 CP_C_API void cp_release_info(cp_context_t *ctx, void *info) CP_GCC_NONNULL(1, 2);
    01256
    01265 CP_C_API cp_plugin_state_t cp_get_plugin_state(cp_context_t *ctx, const char *id) CP_GCC_NONNULL(1, 2);
    01266
    01280 CP_C_API cp_status_t cp_register_plistener(cp_context_t *ctx, cp_plugin_listener_func_t listener, void *user_data) CP_GCC_NONNULL(1, 2);
    01281
    01289 CP_C_API void cp_unregister_plistener(cp_context_t *ctx, cp_plugin_listener_func_t listener) CP_GCC_NONNULL(1, 2);
    01290
    01304 CP_C_API cp_cfg_element_t * cp_lookup_cfg_element(cp_cfg_element_t *base, const char *path) CP_GCC_PURE CP_GCC_NONNULL(1, 2);
    01305
    01322 CP_C_API char * cp_lookup_cfg_value(cp_cfg_element_t *base, const char *path) CP_GCC_PURE CP_GCC_NONNULL(1, 2);
    01323
    01351
    01365 CP_C_API cp_status_t cp_run_function(cp_context_t *ctx, cp_run_func_t runfunc) CP_GCC_NONNULL(1, 2);
    01366
    01376 CP_C_API void cp_run_plugins(cp_context_t *ctx) CP_GCC_NONNULL(1);
    01377
    01389 CP_C_API int cp_run_plugins_step(cp_context_t *ctx) CP_GCC_NONNULL(1);
    01390
    01405 CP_C_API void cp_set_context_args(cp_context_t *ctx, char **argv) CP_GCC_NONNULL(1, 2);
    01406
    01418 CP_C_API char **cp_get_context_args(cp_context_t *ctx, int *argc) CP_GCC_NONNULL(1);
    01419
    01432
    01445 CP_C_API cp_status_t cp_define_symbol(cp_context_t *ctx, const char *name, void *ptr) CP_GCC_NONNULL(1, 2, 3);
    01446
    01477 CP_C_API void *cp_resolve_symbol(cp_context_t *ctx, const char *id, const char *name, cp_status_t *status) CP_GCC_NONNULL(1, 2, 3);
    01478
    01488 CP_C_API void cp_release_symbol(cp_context_t *ctx, const void *ptr) CP_GCC_NONNULL(1, 2);
    01489
    01493 #ifdef __cplusplus
    01494 }
    01495 #endif /*__cplusplus*/
    01496
    01497 #endif /*CPLUFF_H_*/

Generated on Fri Apr 6 15:40:55 2007 for C-Pluff C API by 1.5.1