29#include <glib/gi18n.h>
49 if(*entry ==
'.')
return FALSE;
63 gchar *contents = NULL;
66 if(!g_file_get_contents(manifest_path, &contents, NULL, &
error))
74 " No module will be loaded from that directory. This is an\n"
75 " incomplete or damaged installation -- reinstall Ansel.\n",
76 manifest_path,
error ?
error->message :
"unknown error");
78 g_free(manifest_path);
82 gchar **lines = g_strsplit(contents,
"\n", -1);
85 GPtrArray *
names = g_ptr_array_new();
86 for(gchar **line = lines; !
IS_NULL_PTR(*line); line++)
88 gchar *entry = g_strstrip(*line);
89 if(*entry ==
'\0' || *entry ==
'#')
continue;
94 manifest_path, entry);
97 g_ptr_array_add(
names, g_strdup(entry));
99 g_ptr_array_add(
names, NULL);
101 g_free(manifest_path);
103 return (gchar **)g_ptr_array_free(
names,
FALSE);
107 int (*load_module_so)(
void *module,
const char *libname,
const char *plugin_name),
108 void (*init_module)(
void *module),
109 gint (*sort_modules)(gconstpointer a, gconstpointer b))
111 GList *plugin_list = NULL;
119 const char *plugin_name = *
name;
120 void *
module = calloc(1, module_size);
121 gchar *libname = g_module_build_path(moduledir, plugin_name);
126 gchar *pref_line = g_strdup_printf(
"%s/%s/enable", subdir, plugin_name);
143 if(load)
res = load_module_so(module, libname, plugin_name);
153 plugin_list = g_list_prepend(plugin_list, module);
155 if(init_module) init_module(module);
158 g_strfreev(plugin_names);
161 plugin_list = g_list_sort(plugin_list, sort_modules);
163 plugin_list = g_list_reverse(plugin_list);
static void error(char *msg)
void dt_conf_set_bool(const char *name, int val)
int dt_conf_get_bool(const char *name)
int dt_conf_key_exists(const char *key)
Does key have a value?
#define DT_MODULE_MANIFEST_NAME
Name of the manifest each module directory must carry.
GHashTable * names
GtkWidget* -> the name the application knows it by.
void dt_loc_get_moduledir(char *moduledir, size_t bufsize)
void dt_print(dt_debug_thread_t thread, const char *msg,...) __attribute__((format(printf
Print to stdout when thread is enabled, prefixed with seconds since startup.
#define IS_NULL_PTR(p)
C is way too permissive with !=, == and if(var) checks, which can mean too many things depending on w...
#define dt_free(ptr)
g_free() ptr and set it to NULL, skipping both if it is already NULL.
GList * dt_module_load_modules(const char *subdir, size_t module_size, int(*load_module_so)(void *module, const char *libname, const char *plugin_name), void(*init_module)(void *module), gint(*sort_modules)(gconstpointer a, gconstpointer b))
Load every module the given directory's manifest lists.
gchar ** dt_module_read_manifest(const char *subdir, char *moduledir)
Read a module directory's manifest and return the module base names it lists.
static gboolean _manifest_entry_is_sane(const char *entry)
Is this manifest entry a plain module base name?
#define DT_PATH_MAX
Buffer size for a filesystem path anywhere in Ansel.