Esempio n. 1
0
uim_bool
uim_notify_load(const char *name)
{
  if (!agent->quit || !agent->desc) {
    fprintf(stderr, "uim-notify: notification agent module is not loaded\n");
    uim_notify_load_stderr();
    return UIM_FALSE;
  }

  if (getenv("UIM_DISABLE_NOTIFY") != NULL || strcmp(agent->desc()->name, name) == 0) {
    return UIM_TRUE;
  } else if (strcmp(name, "stderr") == 0) {
    agent->quit();
    if (notify_dlhandle)
      dlclose(notify_dlhandle);
    uim_notify_load_stderr();
  } else {
    char path[PATH_MAX];
    const char *str;

    agent->quit();
    if (notify_dlhandle)
      dlclose(notify_dlhandle);

    snprintf(path, sizeof(path), "%s/%s%s%s", NOTIFY_PLUGIN_PATH,
	     NOTIFY_PLUGIN_PREFIX, name, NOTIFY_PLUGIN_SUFFIX);

    notify_dlhandle = dlopen(path, RTLD_NOW);
    if ((str = dlerror())) {
      fprintf(stderr, "uim-notify: load failed %s(%s)\n", path, str);
      uim_notify_load_stderr();
      return UIM_FALSE;
    }
    agent->desc = (const uim_notify_desc *(*)(void))load_func(path, "uim_notify_plugin_get_desc");
    if (!agent->desc)
      return UIM_FALSE;

    agent->init = (int (*)(void))load_func(path, "uim_notify_plugin_init");
    if (!agent->init)
      return UIM_FALSE;

    agent->quit = (void (*)(void))load_func(path, "uim_notify_plugin_quit");
    if (!agent->quit)
      return UIM_FALSE;

    agent->notify_info = (int (*)(const char *))load_func(path, "uim_notify_plugin_info");
    if (!agent->notify_info)
      return UIM_FALSE;

    agent->notify_fatal = (int (*)(const char *))load_func(path, "uim_notify_plugin_fatal");
    if (!agent->notify_fatal)
      return UIM_FALSE;

    agent->init();
  }
  return UIM_TRUE;
}
Esempio n. 2
0
void load_season_array( JsonIn &js, C &container, F load_func )
{
    if( js.test_array() ) {
        js.start_array();
        for( auto &season_entry : container ) {
            season_entry = load_func( js );
            js.end_array(); // consume separator
        }
    } else {
        container.fill( load_func( js ) );
    }
}
Esempio n. 3
0
bool CServer::LoadDLL(const std::string &name)
{
	int mode=RTLD_NOW | RTLD_GLOBAL;
	if(getServerParameter("leak_check")=="true")
	{
		mode|=RTLD_NODELETE;
	}
	HMODULE dll = dlopen( name.c_str(), mode);

	if(dll==NULL)
	{
		Server->Log("DLL not found: "+(std::string)dlerror(), LL_ERROR);
		return false;
	}

	unload_handles.push_back( dll );

	LOADACTIONS load_func=NULL;
	load_func=(LOADACTIONS)dlsym(dll,"LoadActions");
	unload_functs.insert(std::pair<std::string, UNLOADACTIONS>(name, (UNLOADACTIONS) dlsym(dll,"UnloadActions") ) );

	if(load_func==NULL)
	{
		Server->Log("Loading function in DLL not found", LL_ERROR);
		return false;
	}

	load_func(this);
	return true;
}
Esempio n. 4
0
  void PlugIn::load_library( const std::string &library_file_name )
  {
    try
    {
      this->release_library();
      m_libraryHandle = this->do_load_library( library_file_name );
      if ( m_libraryHandle == NULL )
      {
        THROW_YAT_ERROR("SHAREDLIBRARY_ERROR",
                        "Unable to load the specified shared library",
                        "PlugIn::load_library");
      }

      Symbol sym = this->find_symbol(kOnLoadSymbol);

      OnLoadFunc_t load_func = (OnLoadFunc_t)(sym);
      load_func();

    }
    catch(yat::Exception& ex)
    {
      RETHROW_YAT_ERROR(ex,
                        "SHAREDLIBRARY_ERROR",
                        "Error while loading library",
                        "PlugIn::load_library");
    }
    catch (...)
    {
      THROW_YAT_ERROR("SHAREDLIBRARY_ERROR",
                      "Unknown error while loading library",
                      "PlugIn::load_library");
    }

  }
Esempio n. 5
0
void load_season_array( JsonObject &jo, const std::string &key, C &container, F load_func )
{
    if( jo.has_string( key ) ) {
        container.fill( load_func( jo.get_string( key ) ) );

    } else if( jo.has_array( key ) ) {
        auto arr = jo.get_array( key );
        if( arr.size() == 1 ) {
            container.fill( load_func( arr.get_string( 0 ) ) );

        } else if( arr.size() == container.size() ) {
            for( auto &e : container ) {
                e = load_func( arr.next_string() );
            }

        } else {
            jo.throw_error( "Incorrect number of entries", key );
        }

    } else {
        jo.throw_error( "Expected string or array", key );
    }
}
Esempio n. 6
0
void geInitVideo(){
/*
	load_func(glClear);
	load_func(glClearColor);
	load_func(glGetError);
	load_func(glEnable);
	load_func(glDisable);
	load_func(glViewport);
	load_func(glScissor);
	load_func(glFrontFace);
	load_func(glCullFace);
	load_func(glPolygonMode);
	load_func(glLineWidth);

	load_func(glDepthFunc);
	load_func(glDepthMask);
	load_func(glDepthRange);
	load_func(glClearDepth);
	load_func(glColorMask);

	load_func(glGenTextures);
	load_func(glDeleteTextures);
	load_func(glBindTexture);
	load_func(glTexImage2D);
	load_func(glTexSubImage2D);
	load_func(glCopyTexSubImage2D);
	load_func(glTexImage3D);
	load_func(glTexSubImage3D);
	load_func(glTexParameteri);
	load_func(glTexParameterf);

	load_func(glDrawArrays);
	load_func(glDrawElements);

	load_func(glBlendFunc);
	load_func(glBlendEquation);
	load_func(glBlendColor);
*/

#if (!defined(GL_GLEXT_PROTOTYPES) && !defined(PLATFORM_mac))
#ifdef WIN32
	load_func(glBlendEquation);
	load_func(glTexImage3D);
	load_func(glTexSubImage3D);
	load_func(glTexImage2DMultisample);
#endif
	load_func(glActiveTexture);

	load_func(glGenBuffers);
	load_func(glDeleteBuffers);
	load_func(glBindBuffer);
	load_func(glBufferData);
	load_func(glBufferSubData);
	load_func(glGetBufferParameteriv);

	load_func(glGenFramebuffers);
	load_func(glDeleteFramebuffers);
	load_func(glBindFramebuffer);
	load_func(glFramebufferTexture);
	load_func(glFramebufferTexture2D);
	load_func(glFramebufferTexture3D);
	load_func(glFramebufferTextureLayer);

	load_func(glDrawBuffers);
	load_func(glBlitFramebuffer);

	load_func(glGenRenderbuffers);
	load_func(glBindRenderbuffer);
	load_func(glRenderbufferStorageMultisample);
	load_func(glFramebufferRenderbuffer);

	load_func(glPatchParameteri);
#endif
}
Esempio n. 7
0
int
main (int argc, char **argv)
{
  int i = 0, ret = 0;
  int maxfd = -1;
  char buf[256];
  fd_set orig, fds;
  struct server server_info;
  struct protocol_module *(*load_func) (void) = NULL;
  lt_dlhandle module = NULL;

  memset (buf, 0, sizeof (buf));
  FD_ZERO (&orig);
  FD_ZERO (&fds);

  if (argc != 3)
    {
      fprintf (stderr, "Bad arguments: use madoka-server <ipaddr> <port>\n");
      exit (EXIT_FAILURE);
    }

  server_info.port_num = strtol (argv[2], NULL, 10);

  if (errno)
    {
      perror ("Bad port value");
      exit (EXIT_FAILURE);
    }

  /* Prepare server */
  openlog (MADOKA_LOG_NAME, LOG_PID, LOG_DAEMON);
  skeleton_daemon ();
  syslog (LOG_NOTICE, "Start madoka-server with ip and port: %s:%d", argv[1],
	  server_info.port_num);

#if defined (HAVE_GNUTLS)
  /* Enable SSL */
  gnutls_global_init ();
#endif

  /* Check module list and alloc memory for this. */
  modules = malloc (sizeof (*modules) * modules_list_num);
  memset (modules, 0, sizeof (*modules) * modules_list_num);

  if (!modules)
    {
      syslog (LOG_ERR, "Error in malloc(): %s", strerror (errno));
      exit (EXIT_FAILURE);
    }

  /* Prepare all modules to load */

  lt_dlinit ();

  for (i = 0; i < modules_list_num; i++)
    {

      /* Put module filename */
      strcpy (buf, MADOKA_MODULE_DIR);
      strcat (buf, "/");
      strcat (buf, modules_list_name[i]);
      strcat (buf, LT_MODULE_EXT);

      module = lt_dlopen (buf);

      if (!module)
	{
	  syslog (LOG_WARNING,
		  "Error while loading module in lt_dlopen(): %s\n",
		  lt_dlerror ());
	  continue;		/* Check next module */
	}

      load_func = lt_dlsym (module, "module_init");

      if (!load_func)
	{
	  syslog (LOG_WARNING,
		  "Error while loading module function in lt_dlsym(): %s\n",
		  lt_dlerror ());
	  continue;		/* Check next module */
	}

      modules[i] = load_func ();

      if (!modules[i])
	{
	  syslog (LOG_WARNING,
		  "Error while executing module preinit function");
	  continue;		/* Check next module */
	}

      ret = modules[i]->init (&server_info);

      if (ret < 0)
	{
	  syslog (LOG_WARNING, "Error while executing module init function");
	  modules[i]->is_loaded = 0;
	  continue;		/* Invalid module and check next */
	}

      FD_SET (ret, &orig);
      modules[i]->fd = ret;

      if (maxfd < ret)
	maxfd = ret;

      modules[i]->is_loaded = 1;
      syslog (LOG_NOTICE, "Module %s loaded successfully",
	      modules_list_name[i]);

      /* Set run_server if some module is loaded successfully */
      run_server = 1;
    }

  /* If we can't run server, exit it with code 1 */
  if (!run_server)
    quit_server (0, 1);

  /* Prepare monitor socket */
  while (run_server)
    {
      fds = orig;

      ret = select (maxfd + 1, &fds, NULL, NULL, NULL);

      for (i = 0; (i < modules_list_num && ret > 0); i++)
	if (FD_ISSET (modules[i]->fd, &fds))
	  {
	    modules[i]->worker (modules[i]->fd);
	    ret--;
	  }
    }

  quit_server (0, 0);

  return 0;
}
Esempio n. 8
0
Room *load_RoomData(char *filename, unsigned int number, int flags) {
Room *r;
File *f;
int (*load_func)(File *, Room *, int) = NULL;
int version;

	if (filename == NULL || !*filename || (r = new_Room()) == NULL)
		return NULL;

	if ((f = Fopen(filename)) == NULL) {
		destroy_Room(r);
		return NULL;
	}
	r->number = number;

	version = fileformat_version(f);
	switch(version) {
		case -1:
			log_err("load_RoomData(): error trying to determine file format version of %s", filename);
			load_func = NULL;
			break;

		case 0:
			Frewind(f);
			load_func = load_RoomData_version0;
			break;

		case 1:
			load_func = load_RoomData_version1;
			break;

		default:
			log_err("load_RoomData(): don't know how to load version %d of %s", version, filename);
	}
	if (load_func != NULL && !load_func(f, r, flags)) {
		Fclose(f);
		r->flags &= ROOM_ALL;
/*
	force the room name for Mail> and Home>
	so that find_abbrevRoom() won't act strangely when these names are different in the files
	for some strange reason
*/
		if (r->number == MAIL_ROOM) {
			Free(r->name);
			r->name = cstrdup("Mail");
		}
		if (r->number == HOME_ROOM) {
			Free(r->name);
			r->name = cstrdup("Home");
		}
		if (r->number == MAIL_ROOM)
			r->max_msgs = PARAM_MAX_MAIL_MSGS;
		else
			if (r->max_msgs < 1)
				r->max_msgs = PARAM_MAX_MESSAGES;

		if (PARAM_HAVE_CHATROOMS && (r->flags & ROOM_CHATROOM) && r->chat_history == NULL)
			r->chat_history = new_StringQueue();

		if (!PARAM_HAVE_CHATROOMS && (r->flags & ROOM_CHATROOM) && r->number != HOME_ROOM) {
			r->flags &= ~ROOM_CHATROOM;
			r->flags |= ROOM_DIRTY;
		}
		(void)sort_StringList(&r->room_aides, alphasort_StringList);
		(void)sort_StringList(&r->invited, alphasort_StringList);
		(void)sort_StringList(&r->kicked, alphasort_StringList);
		return r;
	}
	destroy_Room(r);
	Fclose(f);
	return NULL;
}
void sieve_plugins_load
(struct sieve_instance *svinst, const char *path, const char *plugins)
{
	struct module *module;
	struct module_dir_load_settings mod_set;
	const char **module_names;
	unsigned int i;

	/* Determine what to load */

	if ( path == NULL && plugins == NULL ) {
		path = sieve_setting_get(svinst, "sieve_plugin_dir");
		plugins = sieve_setting_get(svinst, "sieve_plugins");
	}

	if ( plugins == NULL || *plugins == '\0' )
		return;

	if ( path == NULL || *path == '\0' )
		path = MODULEDIR"/sieve";

	memset(&mod_set, 0, sizeof(mod_set));
	mod_set.abi_version = PIGEONHOLE_ABI_VERSION;
	mod_set.require_init_funcs = TRUE;
	mod_set.debug = FALSE;

	/* Load missing plugin modules */

	sieve_modules = module_dir_load_missing
		(sieve_modules, path, plugins, &mod_set);

	/* Call plugin load functions for this Sieve instance */

	if ( svinst->plugins == NULL ) {
		sieve_modules_refcount++;
	}

	module_names = t_strsplit_spaces(plugins, ", ");

	for (i = 0; module_names[i] != NULL; i++) {
		/* Allow giving the module names also in non-base form. */
		module_names[i] = module_file_get_name(module_names[i]);
	}

 	for (i = 0; module_names[i] != NULL; i++) {
		struct sieve_plugin *plugin;
		const char *name = module_names[i];
		sieve_plugin_load_func_t load_func;

		/* Find the module */
		module = sieve_plugin_module_find(name);
		i_assert(module != NULL);

		/* Check whether the plugin is already loaded in this instance */
		plugin = svinst->plugins;
		while ( plugin != NULL ) {
			if ( plugin->module == module )
				break;
			plugin = plugin->next;
		}

		/* Skip it if it is loaded already */
		if ( plugin != NULL )
			continue;

		/* Create plugin list item */
		plugin = p_new(svinst->pool, struct sieve_plugin, 1);
		plugin->module = module;

		/* Call load function */
		load_func = (sieve_plugin_load_func_t) module_get_symbol
			(module, t_strdup_printf("%s_load", module->name));
		if ( load_func != NULL ) {
			load_func(svinst, &plugin->context);
		}

		/* Add plugin to the instance */
		if ( svinst->plugins == NULL )
			svinst->plugins = plugin;
		else {
			struct sieve_plugin *plugin_last;

			plugin_last = svinst->plugins;
			while ( plugin_last->next != NULL )
				plugin_last = plugin_last->next;

			plugin_last->next = plugin;
		}
	}
}