Exemple #1
0
/* conf was used on the command line 
 * mysql and dbconf modules must be loaded
 * the command line will be processed with dbconf_cmd_line()
 */
int cmd_conf(int argc, char** argv)
{
/*  int* (*dbconf_cmd_line)(int argc, char **argv); */
  int* (*dbconf_cmd_line)(int, char **);

  if(module_load("mysql", 1) <0 )
  {
    errlog("Error loading mysql module !");
    return -1;
  }
  if(module_load("dbconf", 1) < 0)
  {
    errlog("Error loading dbconf module !");
    return -2;
  }

  dbconf_cmd_line = attach_to_function("dbconf_cmd_line", NULL);
  if(dbconf_cmd_line == NULL)
  {
    errlog("Missing dbconf_cmd_line() function !");
    return -2;
  }
  
  return (int)dbconf_cmd_line(argc, argv);
}
Exemple #2
0
char *
plugin_load (session *sess, char *filename, char *arg)
{
	GModule *handle = module_load (filename);
	hexchat_init_func *init_func;
	hexchat_deinit_func *deinit_func;

	if (handle == NULL)
		return (char *)g_module_error ();

	/* find the init routine hexchat_plugin_init */
	if (!g_module_symbol (handle, "hexchat_plugin_init", (gpointer *)&init_func))
	{
		g_module_close (handle);
		return _("No hexchat_plugin_init symbol; is this really a HexChat plugin?");
	}

	/* find the plugin's deinit routine, if any */
	if (!g_module_symbol (handle, "hexchat_plugin_deinit", (gpointer *)&deinit_func))
		deinit_func = NULL;

	/* add it to our linked list */
	plugin_add (sess, filename, handle, init_func, deinit_func, arg, FALSE);

	return NULL;
}
Exemple #3
0
/*
 * Loads the modules specified in the ramdisk. Loading follows this general
 * procedure:
 *
 * 1. Ensure the file is a valid ELF.
 * 2. Dynamically link with kernel functions from kernel symtab.
 * 3. Call module entry point
 */
void modules_ramdisk_load() {
	if(!ramdisk_loaded()) return;

	// Initialise some data structures
	loaded_module_map = hashmap_allocate();
	loaded_module_names = list_allocate();

	// Acquire initial placement address
	module_placement_addr = paging_get_memrange(kMemorySectionDrivers)[0];
	module_placement_end = paging_get_memrange(kMemorySectionDrivers)[1];

	// Get modules
	char *modulesToLoad = hal_config_get("modules");
	char *moduleName = strtok(modulesToLoad, " ");
	void *elf;

	// Find all modules
	while(moduleName) {
		// Attempt to load module from ramdisk
		if((elf = ramdisk_fopen(moduleName))) {
			module_load(elf, moduleName);
		}

		moduleName = strtok(NULL, " ");
	}

	KSUCCESS("Dynamically loaded modules initialised");
}
Exemple #4
0
int obs_load_module(const char *path)
{
	struct obs_module mod;
	bool (*module_load)(void) = NULL;

	mod.module = os_dlopen(path);
	if (!mod.module)
		return MODULE_FILENOTFOUND;

	module_load = os_dlsym(mod.module, "module_load");
	if (module_load) {
		if (!module_load()) {
			os_dlclose(mod.module);
			return MODULE_ERROR;
		}
	}

	mod.name = bstrdup(path);
	module_load_exports(&mod, &obs->input_types.da, "inputs",
			sizeof(struct source_info), get_source_info);
	module_load_exports(&mod, &obs->filter_types.da, "filters",
			sizeof(struct source_info), get_source_info);
	module_load_exports(&mod, &obs->transition_types.da, "transitions",
			sizeof(struct source_info), get_source_info);
	module_load_exports(&mod, &obs->output_types.da, "outputs",
			sizeof(struct output_info), get_output_info);

	da_push_back(obs->modules, &mod);
	return MODULE_SUCCESS;
}
Exemple #5
0
static void
module_on_scandir(uv_fs_t *req)
{
    uv_dirent_t dirEntry;
    char currentPath[512];
    size_t size;

    size = sizeof(currentPath);

    uv_cwd(currentPath, &size);
    uv_chdir(req->path);

    while(uv_fs_scandir_next(req, &dirEntry) != UV_EOF)
    {
        const char *extension;

        if(dirEntry.type != UV_DIRENT_FILE)
        {
            continue;
        }

        extension = module_get_extension(dirEntry.name);
        if(extension == NULL ||
           strcmp(module_get_extension(dirEntry.name), "so") != 0)
        {
            continue;
        }

        module_load(dirEntry.name);
    }

    uv_chdir(currentPath);
}
Exemple #6
0
/*
 * Reads the file from the path into a temporary buffer, and then attempt to
 * load it as a kernel module.
 *
 * @param path Path to the kernel module
 * @param err Pointer to an integer in which to store a more detailed error
 * @return true if success, false if error.
 */
bool module_load_from_file(char *path, int *err) {
	// Attempt to open file
	fs_file_handle_t *module = hal_vfs_fopen(path, kFSFileModeReadOnly);
	if(module) {
		// Reject modules > 1MB in size
		fs_file_t *file = hal_vfs_handle_to_file(module);
		if(file->size > MODULE_MAX_SIZE) {
			KERROR("%s is %u bytes, max %u bytes", path, (unsigned int) file->size, MODULE_MAX_SIZE);
			return false;
		}

		// Get buffer and zero it
		void *buf = (void *) paging_module_buffer();
		memclr(buf, MODULE_MAX_SIZE);

		// Read entire file
		hal_vfs_fread(buf, file->size, module);

		// Clean up
		hal_vfs_fclose(module);

		// Perform module loading
		module_load(buf, file->i.name);
	} else {
		KERROR("Can't open '%s' for module read", path);
	}

	return false;
}
Exemple #7
0
// Default (unloaded) function(s)
static void default_gui_grid_draw_osd(int force)
{
    // If load succeeded call module version of function
    if (conf.show_grid_lines)
        if (module_load(&h_grids))
            libgrids->gui_grid_draw_osd(force);
}
Exemple #8
0
int main(int argc, char **argv)
{
	static GOptionEntry options[] = {
		{ "load", 'l', 0, G_OPTION_ARG_STRING, &autoload_module, "Module to load (default = bot)", "MODULE" },
		{ NULL }
	};

	autoload_module = NULL;
	core_register_options();
	args_register(options);
	args_execute(argc, argv);
	core_preinit(argv[0]);

#ifdef HAVE_SOCKS
	SOCKSinit(argv[0]);
#endif
	noui_init();

	if (autoload_module == NULL)
		autoload_module = "bot";

	do {
		reload = FALSE;
		module_load(autoload_module, NULL);
		main_loop = g_main_new(TRUE);
		g_main_run(main_loop);
		g_main_destroy(main_loop);
	}
	while (reload);
	noui_deinit();

	return 0;
}
Exemple #9
0
int xmp_load_typed_module_from_memory(xmp_context opaque, void *mem, long size, const struct format_loader* format)
{
	struct context_data *ctx = (struct context_data *)opaque;
	struct module_data *m = &ctx->m;
	HIO_HANDLE *h;
	int ret;

	if ((h = hio_open_mem(mem, size)) == NULL)
		return -XMP_ERROR_SYSTEM;

	m->filename = NULL;
	m->basename = NULL;
	m->size = size;

	if (ctx->state > XMP_STATE_UNLOADED)
		xmp_release_module(opaque);

	load_prologue(ctx);

	D_(D_WARN "load");
	ret = -XMP_ERROR_FORMAT;
	if (format->test(h, NULL, 0) == 0) {
	  if ((ret = module_load(h, ctx, format)))
	    xmp_release_module(opaque);
	}
	hio_close(h);
  return ret;
}
Exemple #10
0
static
DECL_SYMBOL_ACTION(load_module_by_name)
{
	ModuleEntry *ent;
	char       *str;

	if (task == csa_READ) {  
		if (!iter && loaded_module) {
			command_arg_set_string(sym->args, loaded_module->name);
			return 1;
		}
		return 0;
	}

	command_arg_get_string(sym->args, &str);
	if (!str || !*str)
	{
		module_unload_entries();
		return 1;
	}

	ent = modules_find_tag_in_db(str);
	if (ent == NULL)
		ent = modules_search_str_in_db(str);

	if (ent == NULL) {
		command_logger(_L | LOG_ERROR | LOG_USER, _("No module matches '%s'\n"), str);
		return 0;
	}

	return module_load(ent);
}
Exemple #11
0
void module_init(multiboot_t *multiboot)
{
  /*
   * disable interrupts, module loading messes around with address space
   * switches so we don't want to confuse the scheduler
   */
  intr_lock();

  /* keep a copy of the old process */
  proc_t *old_proc = proc_get();

  multiboot_tag_t *tag = multiboot_get(multiboot, MULTIBOOT_TAG_MODULE);
  while (tag)
  {
    module_load(tag);
    tag = multiboot_get_after(multiboot, tag, MULTIBOOT_TAG_MODULE);
  }

  /* switch back to the correct address space */
  if (old_proc)
    proc_switch(old_proc);

  /* enable interrupts again */
  intr_unlock();
}
Exemple #12
0
// class stream
void stream(CLASS *oclass)
{
	stream("RTC");

	size_t count = class_get_runtimecount();
	stream(count);
	size_t n;
	for ( n=0 ; n<count ; n++ )
	{
		CLASSNAME name; if ( oclass ) strcpy(name,oclass->name);
		stream(name,sizeof(name));

		unsigned int size; if ( oclass ) size = oclass->size;
		stream(size);

		PASSCONFIG passconfig; if ( oclass ) passconfig = oclass->passconfig;
		stream(passconfig);

		if ( flags&SF_IN ) oclass = class_register(NULL,name,size,passconfig);

		// TODO parent

		stream(oclass,oclass->pmap);

		if ( flags&SF_OUT ) oclass = class_get_next_runtime(oclass);
		if ( flags&SF_IN ) module_load(oclass->name,0,NULL);
	}
	stream("/RTC");
}
Exemple #13
0
		inline void check(in_t::ptr_t const &) const {
			for(typeof(list._ptr()) lptr = list; lptr; ++lptr) {
				name_t const &name = lptr.val();

				// #dir "/mod_" #name ".so\0"

				if(module_info_t::lookup(name)) return;

				string_t fname_z = string_t::ctor_t(dir.size() + 5 + name.size() + 4)
					(dir)(CSTR("/mod_"))(name)(CSTR(".so\0"))
				;

				try {
					module_load(fname_z.ptr());
				}
				catch(string_t const &ex) {
					config::error(name.ptr, ex.ptr());
				}

				module_info_t *module_info = module_info_t::lookup(name);
				if(!module_info)
					config::error(name.ptr, "not a phantom module loaded");

				if(!*module_info)
					config::error(name.ptr, "illegal module version");
			}
		}
Exemple #14
0
static void irc_proc_cmd_privmsg_user_cmd_admin (struct irc_t * irc)
{
    char * t;
    char tokens[2][MAX_IRC_MSG];
    char str[MAX_IRC_MSG];

    strncpy(str, irc->request, MAX_IRC_MSG);
    
    if ( !(t = strtok(str, " ")) )
        return;

    strncpy(tokens[0], t, MAX_IRC_MSG);

    if ( (t = strtok(NULL, "\r\n")) )
        strncpy(tokens[1], t, MAX_IRC_MSG);
        
    if ( !strncmp(".join", tokens[0], strlen(".join")) )
        sprintf(irc->response, "JOIN %s\r\n", tokens[1]);
    else if (!strncmp(".part", tokens[0], strlen(".part")))
        sprintf(irc->response, "PART %s\r\n", tokens[1] );
    else if ( !strncmp(".raw", tokens[0], strlen(".raw")) )
        sprintf(irc->response, "%s\r\n", tokens[1]);
    else if ( !strncmp(".reload", tokens[0], strlen(".reload")) ) {
        module_load();
#ifdef USE_PYTHON_MODULES
        py_load_mod_hash();
#endif
    }
}
Exemple #15
0
mytbf_t *mytbf_init(int cps, int burst){
	struct mytbf_st *me;
	int pos;
	if (inited) {
		module_load();
		inited = 0;
	}

	me = malloc(sizeof(*me));
	if (NULL == me) {
		return NULL;
	}

	me->cps = cps;
	me->burst = burst;
	me->token = 0;

	pos = get_free_pos();
	if (pos < 0) {
		free(me);
		return NULL;
	}
	me->pos = pos;
	job[pos] = me;
	return me;
}
Exemple #16
0
int main(int argc, char **argv)
{
	core_init_paths(argc, argv);

#ifdef HAVE_SOCKS
	SOCKSinit(argv[0]);
#endif
	noui_init();
	args_execute(argc, argv);

	if (autoload_module == NULL)
		autoload_module = "bot";

	do {
		reload = FALSE;
		module_load(autoload_module, NULL);
		main_loop = g_main_new(TRUE);
		g_main_run(main_loop);
		g_main_destroy(main_loop);
	}
	while (reload);
	noui_deinit();

	return 0;
}
Exemple #17
0
int64 stream_in_module(FILE *fp)
{
	int64 count=0;
	MODULE *m;

	while (GETBT && B(MODULE) && T(BEGIN))
	{
		char name[1024]; 
		memset(name,0,sizeof(name));
		OK;
		while (GETBT && B(MODULE) && !T(END))
		{
			OK;
			if T(NAME) 
			{
				GETD(name,sizeof(name));
				m = module_load(name,0,NULL);
				if (m==NULL)
					return stream_error("module %s version is not found", name);
			}
			else if T(VERSION) 
			{
				unsigned short major, minor;
				GETS(major);
				GETS(minor);
				if (m->major!=major || m->minor!=minor)
					return stream_error("module %s version %d.%02d specified does not match version %d.%02d found", name, major, minor, m->major, m->minor);
			}
			else
				stream_warning("ignoring token %d in module stream", t);
		}
Exemple #18
0
/* SYNTAX: LOAD <module> [<submodule>] */
static void cmd_load(const char *data)
{
    char *rootmodule, *submodule;
    char **module_prefixes;
    void *free_arg;

    g_return_if_fail(data != NULL);

    if (!cmd_get_params(data, &free_arg, 2 , &rootmodule, &submodule))
        return;

    if (*rootmodule == '\0')
        cmd_load_list();
    else {
        module_prefixes = module_prefixes_get();
        if (*submodule == '\0')
            module_load(rootmodule, module_prefixes);
        else {
            module_load_sub(rootmodule, submodule,
                            module_prefixes);
        }
        module_prefixes_free(module_prefixes);
    }

    cmd_params_free(free_arg);
}
STATUS test_start(int argc, char *argv[])
{
	int mod_test_num = 1;
	char mod_test[100];
	char *mod_name;
	int test_result = 0;
	sprintf(mod_test,"mod_test%d",mod_test_num++);
	mod_name = global_getvar(mod_test, NULL, 0);
	module_load("tape",argc,argv);
	while(mod_name != NULL)
	{
		MODULE *mod = module_load(mod_name,argc,argv);
		
		if(mod == NULL)
		{
			output_fatal("Invalid module name");
			/*	TROUBLESHOOT
				The test_start procedure was given an invalid module name.
				Check the command line argument and/or the unit test sequence
				to be sure the test is requested properly.
			 */
			return FAILED;
		}

		if (mod->module_test==NULL)
		{
			output_fatal("Module %s does not implement cppunit test", mod->name);
			/*	TROUBLESHOOT
				The test_start procedure was given the name of a module that doesn't
				implement unit testing.
				Check the command line argument and/or the test configuration file
				to be sure the test is requested properly.				
			 */
			return FAILED;
		}

		test_result = mod->module_test(&callbacks,argc,argv);
		
		if(test_result == 0)
			return FAILED;
		sprintf(mod_test,"mod_test%d",mod_test_num++);
		mod_name = global_getvar(mod_test, NULL, 0);
	}
	
	return SUCCESS;

}
Exemple #20
0
/* modprobe failing doesn't necessarily prevent from working, so this
   returns void */
static void modprobe(void)
{
	int r;

	r = module_load("ceph", NULL);
	if (r)
		printf("failed to load ceph kernel module (%d)\n", r);
}
Exemple #21
0
static int default_shot_histogram_set(int enable)
{
    // If enabling shot histogram, then load module, otherwise nothing to do
    if (enable)
        if (module_load(&h_shothisto))
            return libshothisto->shot_histogram_set(enable);
    return 1;
}
Exemple #22
0
static int symbol_import0(void *Ignore, const char *Name, int *IsRef, void **Data) {
	module_t *LangSymbol = module_load(0, "Lang/Symbol");
	int IsRef0;
	module_import(LangSymbol, "_new_string", &IsRef0, (void **)&make_symbol);
	module_import(LangSymbol, "_add_methods", &IsRef0, (void **)&add_methods);
	module_setup(Symbol, 0, symbol_import);
	return symbol_import(0, Name, IsRef, Data);
};
Exemple #23
0
// Default (unloaded) function(s)
static int default_script_start(char const* script, int is_ptp)
{
    // If load succeeded call module version of function
    if (module_load(&h_script))
        return libscriptapi->script_start(script, is_ptp);

    // Failure
    return 0;
}
Exemple #24
0
// Default (unloaded) function
static int default_hexbox_init(int *num, char *title, int flags)
{
    // If load succeeded call module version of function
    if (module_load(&h_hexbox))
        return libhexbox->hexbox_init(num, title, flags);

    // Failure
    return 0;
}
Exemple #25
0
// Default (unloaded) function
static int default_textbox_init(int title, int msg, const char* defaultstr, unsigned int maxsize, void (*on_select)(const char* newstr), char *input_buffer)
{
    // If load succeeded call module version of function
    if (module_load(&h_textbox))
        return libtextbox->textbox_init(title,msg,defaultstr,maxsize,on_select,input_buffer);

    // Failure
    return 0;
}
Exemple #26
0
// Default (unloaded) function
static int default_read_file(const char *fn)
{
    // If load succeeded call module version of function
    if (module_load(&h_txtread))
        return libtxtread->read_file(fn);

    // Failure
    return 0;
}
Exemple #27
0
static int default_script_start_file(char const* filename)
{
    // If load succeeded call module version of function
    if (module_load(&h_script))
        return libscriptapi->script_start_file(filename);

    // Failure
    return 0;
}
Exemple #28
0
static int default_convert_dng_to_chdk_raw(char* fn)
{
    // If load succeeded call module version of function
    if (module_load(&h_dng))
        return libdng->convert_dng_to_chdk_raw(fn);

    // Failure
    return 0;
}
Exemple #29
0
// Default (unloaded) function(s)
static int default_gui_osd_draw_zebra(int show)
{
    // If load succeeded call module version of function
    if (module_load(&h_zebra))
        return libzebra->gui_osd_draw_zebra(show);

    // Failure
    return 0;
}
Exemple #30
0
int module_reload(const char *modules_path)
{
	if (module_unload() == 0)
	{
		return module_load(modules_path);
	}
	
	return -1;
}