module-dir.c revision 8e56d284c950a645cac5c4cb2a984b6e65b0cc6a
/* Copyright (C) 2003 Timo Sirainen */
#include "lib.h"
#include "array.h"
#include "module-dir.h"
#ifdef HAVE_MODULES
#include <stdlib.h>
#include <unistd.h>
#include <dirent.h>
#include <dlfcn.h>
#ifndef RTLD_GLOBAL
# define RTLD_GLOBAL 0
#endif
#ifndef RTLD_NOW
# define RTLD_NOW 0
#endif
{
const char *error;
void *ret;
/* get our init func */
i_error("module %s: dlsym(%s) failed: %s",
}
return ret;
}
const char *module_file_get_name(const char *fname)
{
const char *p;
/* [lib][nn_]name(.so) */
fname += 3;
for (p = fname; *p != '\0'; p++) {
if (*p < '0' || *p > '9')
break;
}
if (*p == '_')
fname = p + 1;
if (p == NULL)
return fname;
return t_strdup_until(fname, p);
}
{
if (quiet)
}
{
}
static struct module *
{
void *handle;
void (*init)(void);
return NULL;
}
/* get our init func */
init = (void (*)(void))
return NULL;
}
init();
return module;
}
{
s1 += 3;
s2 += 3;
}
{
return TRUE;
*names = "";
return TRUE;
}
}
return FALSE;
}
bool require_init_funcs)
{
struct dirent *d;
const char **module_names_arr;
unsigned int i, count;
return NULL;
}
if (name[0] == '.')
continue;
continue;
}
t_push();
if (module_names == NULL)
else {
/* allow giving the module names also in non-base form.
conver them in here. */
for (i = 0; module_names_arr[i] != NULL; i++) {
module_names_arr[i] =
}
}
for (i = 0; i < count; i++) {
t_push();
else {
}
t_pop();
}
}
if (module_names_arr != NULL) {
/* make sure all modules were found */
if (**module_names_arr != '\0') {
i_fatal("Plugin %s not found from directory %s",
*module_names_arr, dir);
}
}
}
t_pop();
return modules;
}
{
}
}
}
{
}
}
#else
{
i_error("Dynamically loadable module support not built in");
return NULL;
}
{
}
{
}
#endif