Main Page | Data Structures | File List | Data Fields | Globals

plugins.h

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 1999-2003 Alex Scott
00003  *
00004  * This library is free software; you can redistribute it and/or modify it
00005  * under the terms of the GNU Library General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or (at
00007  * your option) any later version.
00008  *
00009  * This library is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this library; if not, write to the Free Software Foundation,
00016  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00023 #include <dlfcn.h>
00024 
00025 #include "llist.h"
00026 #include "array.h"
00027 #include "iparser.h"
00028 #include "plugins_macros.h"
00029 
00030 #ifndef _PLUGINS_H_
00031 # define _PLUGINS_H_
00032 
00037 typedef enum _PConfOptType {
00038         PConfBool,                      
00039         PConfChar,                      
00040         PConfInt,                       
00041         PConfLong,                      
00042         PConfFloat,                     
00043         PConfDouble,                    
00044         PConfString,                    
00045         PConfEnum                       
00046 } PConfOptType;
00047 
00053 typedef union _NumRange {
00054         PConfOptType ot;
00058         struct {
00059                 int minimum, maximum, step, def;
00060         } pcint;
00064         struct {
00065                 long minimum, maximum, step, def;
00066         } pclong;
00070         struct {
00071                 float minimum, maximum, step, def;
00072         } pcfloat;
00076         struct {
00077                 double minimum, maximum, step, def;
00078         } pcdouble;
00079 } NumRange;
00080 
00086 typedef struct _PluginConfig {
00087         char *name;                     
00088         char *desc;                     
00089         PConfOptType ot;                
00090         char *def;                      
00091         void *data;                     
00092         void *ref;                      
00093 } PluginConfig;
00094 
00099 typedef struct _PluginType {
00100         char *type_name;                // Type specific name
00101         char *type_desc;                // Type description
00102         char *info_func_name;           // Info function name
00103         Llist *plugins;                 // Linked list of loaded plugins
00104 } PluginType;
00105 
00110 typedef struct _Plugin {
00111         void *handle;                   // Shared object handle
00112         char *filename;                 // File name
00113         char *name;                     // Name of plugin
00114         char *desc;                     // Description of plugin
00115         unsigned int numofconfig;       // Number of configure options
00116         PluginConfig *config;           // Configure options
00117         int (*init) (void);             // Basic initalization func
00118         void (*cleanup) (void);         // Basic cleanup func
00119         void *ref;                      // Referance to functions structure
00120 } Plugin;
00121 
00122 typedef void *(*PluginInfoFunc) (void);
00123 
00124 
00125 /* Global */
00126 
00127 int plugins_object_load (char *filename);
00128 void plugins_scan_dir (char *directory);
00129 void plugins_unload (void);
00130 void plugins_reload (void);
00131 void plugins_free (void);
00132 void plugins_configs_add_all (IOpts *opts);
00133 void plugins_configs_default_all (void);
00134 void plugins_dump_all (void);
00135 
00136 /* Types */
00137 
00138 PluginType *plugin_type_select (char *type_name);
00139 int plugin_type_register (char *type_name, char *type_desc,
00140                           char *info_func_name);
00141 void plugin_type_unregister (char *type_name);
00142 void plugin_type_free (PluginType *pt);
00143 void plugin_type_dump (PluginType *pt);
00144 void plugin_type_list_dump (void);
00145 
00146 
00147 /* Lists */
00148 
00149 Llist *plugin_list_get (char *type_name);
00150 char **plugin_list_names_get (char *type_name);
00151 void plugin_list_dump (char *type_name);
00152 
00153 
00154 /* Plugins  */
00155 
00156 Plugin *plugin_select (char *type_name, char *plugin_name);
00157 void plugin_configs_init (Plugin *plugin);
00158 void plugin_configs_free (Plugin *plugin);
00159 void plugin_configs_add (Plugin *plugin, IOpts *opts);
00160 void plugin_configs_default (Plugin *plugin);
00161 void plugin_configs_dump (PluginConfig *pc, int numofconfig);
00162 void plugin_dump (Plugin *plugin);
00163 
00164 
00165 /* Configuration Helping Functions */
00166 
00167 void *plugin_config_data_get (int numofconfs, PluginConfig *pc, char *name);
00168 
00169 #endif /* _PLUGINS_H_ */

Generated on Fri Jun 4 18:35:18 2004 for cuf by doxygen 1.3.6