Exemplo n.º 1
0
  void Module::set_name(STATE, Symbol* name, Module* under) {
    if(!module_name()->nil_p()) return;

    if(under == G(object)) {
      module_name(state, name);
    } else {
      Symbol* under_name = under->module_name();

      if(!under_name->nil_p()) {
        std::ostringstream path_name;
        path_name << under_name->cpp_str(state) << "::" << name->cpp_str(state);
        module_name(state, state->symbol(path_name.str()));

        LookupTable::iterator i(constants());

        while(i.advance()) {
          if(Module* m = try_as<Module>(i.value())) {
            if(m->module_name()->nil_p()) {
              m->set_name(state, as<Symbol>(i.key()), this);
            }
          }
        }
      }
    }
  }
Exemplo n.º 2
0
/* Replace all calls to to the target functions with calls to the 
 * replacement-functions in the module. 
 */
static void 
replace_calls_in_module(struct module* mod)
{
	BUG_ON(mod == NULL);
	BUG_ON(mod->module_core == NULL);

	if (mod->module_init != NULL)
	{
		KEDR_MSG(COMPONENT_STRING 
			"target module: \"%s\", processing \"init\" area\n",
			module_name(mod));
			
		do_process_area(mod->module_init, 
			mod->module_init + mod->init_text_size,
			repl_table.orig_addrs,
			repl_table.repl_addrs,
			repl_table.num_addrs);
	}

	KEDR_MSG(COMPONENT_STRING 
		"target module: \"%s\", processing \"core\" area\n",
		module_name(mod));
		
	do_process_area(mod->module_core, 
		mod->module_core + mod->core_text_size,
		repl_table.orig_addrs,
		repl_table.repl_addrs,
		repl_table.num_addrs);
	return;
}
Exemplo n.º 3
0
 String* Module::get_name(STATE) {
   if(module_name()->nil_p()) {
     if(LANGUAGE_18_ENABLED(state)) {
       return String::create(state, "");
     } else {
       return nil<String>();
     }
   } else {
     return module_name()->to_str(state);
   }
 }
Exemplo n.º 4
0
static int verify_export_symbols(struct module *mod)
{
	unsigned int i;
	struct module *owner;
	const struct kernel_symbol *s;
	struct {
		const struct kernel_symbol *sym;
		unsigned int num;
	} arr[] = {
		{
	mod->syms, mod->num_syms},};

	for (i = 0; i < ARRAY_SIZE(arr); i++) {
		for (s = arr[i].sym; s < arr[i].sym + arr[i].num; s++) {
			if (find_symbol(s->name, &owner, NULL, 0)) {
				kprintf("verify_export_symbols: "
					"%s: exports duplicate symbol %s"
					" (owned by %s)\n",
					mod->name, s->name, module_name(owner));
				return -1;
			}
		}
	}
	return 0;
}
Exemplo n.º 5
0
int main(int arg_count, char *args[])
{
  generator gen;
  int first_non_flag_index = process_options(gen, arg_count, args);
  int num_non_flag_args = arg_count - first_non_flag_index;

  if(num_non_flag_args != 1 && num_non_flag_args != 2)
  {
    std::cerr << "Usage: cppclassgen --<flags> <class_name> <module_name(optional)>" << std::endl;
    std::exit(-1);
  }

  std::string class_name(args[first_non_flag_index]);
  gen.m_tokens.push_back(std::make_pair("%CLASS_NAME%", class_name));
  auto class_name_upper = toupper(class_name);
  gen.m_tokens.push_back(std::make_pair("%CLASS_NAME_UPPER%", class_name_upper));

  if(num_non_flag_args == 2)
  {
    std::string module_name(args[first_non_flag_index + 1]);
    gen.m_tokens.push_back(std::make_pair("%MODULE_NAME%", module_name));
    toupper(module_name);
    auto module_name_upper = toupper(module_name);
    gen.m_tokens.push_back(std::make_pair("%MODULE_NAME_UPPER%", module_name_upper));
  }

  read_tokens_from_config_file(gen);
  create_new_file_from_template(gen, class_name, ".h");
  create_new_file_from_template(gen, class_name, ".cpp");

  return 0;
}
Exemplo n.º 6
0
/*
 * on_module_unload() should do real work when the target module is about to
 * be unloaded. 
 *
 * Note that this function is called with controller_mutex locked.
 *
 * [NB] This function is called even if initialization of the target module 
 * fails.
 * */
static void 
on_module_unload(struct module *mod)
{
	int ret = 0;
	unsigned long flags;
	
	KEDR_MSG(COMPONENT_STRING 
		"target module \"%s\" is going to unload.\n",
		module_name(mod));
	
/* The replacement table may be used no longer. 
 * The base will take care of releasing its contents when appropriate.
 * [NB] The access to repl_table is already synchronized as on_module_unload()
 * is called with controller_mutex locked.
 */
	repl_table.num_addrs = 0;
	repl_table.orig_addrs = NULL;
	repl_table.repl_addrs = NULL;	 
	
	spin_lock_irqsave(&target_in_init_lock, flags);
	target_in_init = 0; 
	spin_unlock_irqrestore(&target_in_init_lock, flags);
	
	/* Notify the base */
	ret = kedr_impl_on_target_unload(target_module);
	if (ret != 0)
	{
		KEDR_MSG(COMPONENT_STRING
		"failed to handle unloading of the target module.\n");
		return;
	}
	
	trace_target_session_ends(target_name);
	return;
}
Exemplo n.º 7
0
/* A callback function to catch loading and unloading of module. 
 * Sets target_module pointer among other things. */
static int 
detector_notifier_call(struct notifier_block *nb,
	unsigned long mod_state, void *vmod)
{
	struct module* mod = (struct module *)vmod;
	BUG_ON(mod == NULL);
	
	/* handle module state change */
	switch(mod_state)
	{
	case MODULE_STATE_COMING: /* the module has just loaded */
		if(mutex_lock_killable(&target_module_mutex))
		{
			KEDR_MSG(COMPONENT_STRING
				"failed to lock target_module_mutex\n");
			return 0;
		}
		if((target_name != NULL)
			&& (strcmp(target_name, module_name(mod)) == 0))
		{
			BUG_ON(target_module != NULL);
			if((notifier->mod == NULL) || try_module_get(notifier->mod))
			{
				if(!notifier->on_target_load(notifier, mod))
				{
					target_module = mod;
				}
				else
				{
					if(notifier->mod)
						module_put(notifier->mod);
				}
			}
			else
			{
				pr_err("Fail to fix module of notifier.");
			}
		}
		mutex_unlock(&target_module_mutex);
	break;
	
	case MODULE_STATE_GOING: /* the module is going to unload */
	/* if the target module has already been unloaded, 
	 * target_module is NULL, so (mod != target_module) will
	 * be true. */
		mutex_lock(&target_module_mutex);
		if(mod == target_module)
		{
			notifier->on_target_unload(notifier, mod);
			target_module = NULL;
			
			if(notifier->mod != NULL)
				module_put(notifier->mod);
		}
		mutex_unlock(&target_module_mutex);
	break;
	}

	return 0;
}
Exemplo n.º 8
0
FrmTransportistas::FrmTransportistas(QWidget *parent) :
    MayaModule(module_zone(),module_name(),parent),
    ui(new Ui::FrmTransportistas),
    menuButton(QIcon(":/Icons/PNG/transport.png"),tr("Transportistas"),this)
{
    ui->setupUi(this);

    transportistas oTransportista(this);
    anadiendo = false;
    ui->txtCodigo_proveedor->installEventFilter(this);
    //------------------
    // Busqueda
    //------------------
    ui->stackedWidget->setCurrentIndex(0);
    m = new QSqlQueryModel(this);
    m->setQuery("select codigo,transportista from transportista",Configuracion_global->groupDB);
    ui->tablaBusqueda->setModel(m);

    //---------------
    // Cargo combos
    //---------------
    QSqlQueryModel *paises = new QSqlQueryModel(this);
    paises->setQuery("select pais from paises order by pais",Configuracion_global->groupDB);
    ui->cbopais->setModel(paises);
    Bloquear_campos(true);

    setUpBusqueda();
}
Exemplo n.º 9
0
/*
 * on_module_load() should do real work when the target module is loaded:
 * instrument it, etc.
 *
 * Note that this function is called with controller_mutex locked.
 */
static void 
on_module_load(struct module *mod)
{
	int ret = 0;
	unsigned long flags;
	
	KEDR_MSG(COMPONENT_STRING 
		"target module \"%s\" has just loaded.\n",
		module_name(mod));
	
	spin_lock_irqsave(&target_in_init_lock, flags);
	target_in_init = 1;
	spin_unlock_irqrestore(&target_in_init_lock, flags);
	
	trace_target_session_begins(target_name);
    /* Until this function finishes, no replacement function will be called
	 * because the target module has not completed loading yet. That means,
	 * no tracepoint will be triggered in the target module before the 
	 * tracepoint above is triggered. The order of the messages in the trace
	 * is still up to the tracing system.
	 */
	
	/* Notify the base and request the combined replacement table */
	ret = kedr_impl_on_target_load(target_module, &repl_table);
	if (ret != 0)
	{
		KEDR_MSG(COMPONENT_STRING
		"failed to handle loading of the target module.\n");
		return;
	}
	
	replace_calls_in_module(mod);
	return;
}
Exemplo n.º 10
0
  Object* Class::allocate(STATE) {
    Object* obj = cNil;
    object_type obj_type = type_info()->type;

    if(obj_type == PackedObject::type) {
      obj = allocate_packed(state, this);
    } else if(!type_info()->allow_user_allocate || kind_of<SingletonClass>(this)) {
      std::ostringstream msg;
      msg << "direct allocation disabled for ";
      if(kind_of<SingletonClass>(this)) {
         msg << to_string(state);
      } else {
         msg << module_name()->debug_str(state);
      }
      Exception::raise_type_error(state, msg.str().c_str());
    } else if(obj_type == Object::type) {
      auto_pack(state);
      obj = allocate_packed(state, this);
    } else {
      // type_info()->type is neither PackedObject nor Object, so use the
      // generic path.
      obj = state->memory()->new_object<Object>(
          state, this, type_info()->instance_size, obj_type);
    }

#ifdef RBX_ALLOC_TRACKING
    if(unlikely(state->vm()->allocation_tracking())) {
      new_obj->setup_allocation_site(state);
    }
#endif

    return obj;
  }
Exemplo n.º 11
0
void
be_util::gen_nesting_open (TAO_OutStream &os, AST_Decl *node)
{
  AST_Decl::NodeType nt = node->node_type ();

  if (nt == AST_Decl::NT_root)
    {
      os << be_nl;
      return;
    }

  be_util::gen_nesting_open (
    os,
    ScopeAsDecl (node->defined_in ()));

  if (nt == AST_Decl::NT_module)
    {
      ACE_CString module_name (
        IdentifierHelper::try_escape (node->original_local_name ()));

      os << be_nl
         << "module " << module_name.c_str () << be_nl
         << "{" << be_idt;
   }
}
Exemplo n.º 12
0
void tLuaCOMEnumerator::push(lua_State* L)
{
  LUASTACK_SET(L);

  tStringBuffer module_name(tUtil::RegistryGetString(L, module_name_key));
  LUASTACK_DOCLEAN(L, 0);

  // creates table
  lua_newtable(L);
  luaCompat_pushTypeByName(L, 
    module_name, 
    tLuaCOMEnumerator::type_name);

  lua_setmetatable(L, -2);

  lua_pushstring(L, ENUMERATOR_FIELD);

  // pushes typed pointer
  luaCompat_pushTypeByName(L, 
    module_name, 
    tLuaCOMEnumerator::pointer_type_name);

  luaCompat_newTypedObject(L, this);

  // stores in the table
  lua_settable(L, -3);

  LUASTACK_CLEAN(L, 1);
}
Exemplo n.º 13
0
/* [NB] We do not check here if debugfs is supported because this is done 
 * when creating the directory for these files ('dir_klc_main'). */
static int
klc_create_debugfs_files(struct kedr_lc_output *output, 
	struct module *target, struct kedr_leak_check *lc)
{
	BUG_ON(output == NULL || target == NULL);
	BUG_ON(dir_klc_main == NULL);
	
	output->dir_klc = debugfs_create_dir(module_name(target),
		dir_klc_main);
	if (output->dir_klc == NULL)
		goto fail;
	
	output->file_leaks = debugfs_create_file("possible_leaks", 
		S_IRUGO, output->dir_klc, &output->ob_leaks, &klc_fops);
	if (output->file_leaks == NULL) 
		goto fail;
	
	output->file_bad_frees = debugfs_create_file("unallocated_frees", 
		S_IRUGO, output->dir_klc, &output->ob_bad_frees, &klc_fops);
	if (output->file_bad_frees == NULL) 
		goto fail;
	
	output->file_stats = debugfs_create_file("info", 
		S_IRUGO, output->dir_klc, &output->ob_other, &klc_fops);
	if (output->file_stats == NULL) 
		goto fail;

	output->file_flush = debugfs_create_file("flush",
		S_IWUSR | S_IWGRP, output->dir_klc, lc, &klc_flush_ops);
	if (output->file_flush == NULL)
		goto fail;

	output->file_clear = debugfs_create_file("clear",
		S_IWUSR | S_IWGRP, output->dir_klc, lc, &klc_clear_ops);
	if (output->file_clear == NULL)
		goto fail;

	return 0;

fail:
	pr_warning(KEDR_LC_MSG_PREFIX
	"failed to create output files in debugfs for module \"%s\"\n",
		module_name(target));
	klc_remove_debugfs_files(output);
	return -EINVAL;    
}
Exemplo n.º 14
0
static int __init jprobe_sys_mount_init(void)
{
	jprobe_sys_mount.kp.symbol_name = "sys_mount";
	jprobe_sys_mount.entry = (kprobe_opcode_t *) jprobe_sys_mount_handler;
	register_jprobe(&jprobe_sys_mount);
	printk(KERN_INFO "Register %s module\n", module_name(THIS_MODULE));
	return 0;
}
Exemplo n.º 15
0
RepDesignModule::RepDesignModule(QWidget *parent) :
    MayaModule(module_zone(),module_name(),parent),
    menuButton(QIcon(":/Icons/PNG/reports.png"),tr("Editar reportes"),this),
    _report(),
    _layout(this)
{
    _layout.setMargin(0);
    _layout.addWidget(&_report);
}
Exemplo n.º 16
0
  std::string Module::debug_str(STATE) {
    Symbol* name = module_name();

    if(name->nil_p()) {
      return "<anonymous module>";
    } else {
      return name->cpp_str(state);
    }
  }
Exemplo n.º 17
0
Object* Class::allocate(STATE, GCToken gct, CallFrame* calling_environment) {
    object_type obj_type = type_info_->type;

    if(obj_type == PackedObject::type) {
        Object* new_obj = allocate_packed(state, gct, this, calling_environment);
#ifdef RBX_ALLOC_TRACKING
        if(unlikely(state->vm()->allocation_tracking())) {
            new_obj->setup_allocation_site(state, calling_environment);
        }
#endif
#ifdef RBX_GC_STRESS
        state->shared().gc_soon();
#endif
        return new_obj;
    } else if(!type_info_->allow_user_allocate || kind_of<SingletonClass>(this)) {
        std::ostringstream msg;
        msg << "direct allocation disabled for ";
        if(kind_of<SingletonClass>(this)) {
            msg << to_string(state);
        } else {
            msg << module_name()->debug_str(state);
        }
        Exception::type_error(state, msg.str().c_str());
        return cNil;
    } else if(obj_type == Object::type) {
        // transition all normal object classes to PackedObject
        Class* self = this;
        OnStack<1> os(state, self);

        auto_pack(state, gct, calling_environment);
        Object* new_obj = allocate_packed(state, gct, self, calling_environment);
#ifdef RBX_ALLOC_TRACKING
        if(unlikely(state->vm()->allocation_tracking())) {
            new_obj->setup_allocation_site(state, calling_environment);
        }
#endif
#ifdef RBX_GC_STRESS
        state->shared().gc_soon();
#endif
        return new_obj;
    } else {
        // type_info_->type is neither PackedObject nor Object, so use the
        // generic path.
        Object* new_obj = state->vm()->new_object_typed(this,
                          type_info_->instance_size, obj_type);
#ifdef RBX_ALLOC_TRACKING
        if(unlikely(state->vm()->allocation_tracking())) {
            new_obj->setup_allocation_site(state, calling_environment);
        }
#endif
#ifdef RBX_GC_STRESS
        state->shared().gc_soon();
#endif
        return new_obj;
    }
}
Exemplo n.º 18
0
bool system_info_to_json(appender_fn append, void* append_data, hal_system_info_t& system)
{
    AppendJson json(append, append_data);
    bool result = true;
    result &= json.write_value("p", system.platform_id)
        && json.write_key_values(system.key_value_count, system.key_values)
        && json.write_attribute("m")
        && json.write('[');
    char buf[65];
    for (unsigned i=0; i<system.module_count; i++) {
        if (i) result &= json.write(',');
        const hal_module_t& module = system.modules[i];
        const module_info_t* info = module.info;
        buf[64] = 0;
        bool output_uuid = module.suffix && module_function(info)==MODULE_FUNCTION_USER_PART;
        result &= json.write('{') && json.write_value("s", module.bounds.maximum_size) && json.write_string("l", module_store_string(module.bounds.store))
                && json.write_value("vc",module.validity_checked) && json.write_value("vv", module.validity_result)
          && (!output_uuid || json.write_string("u", bytes2hexbuf(module.suffix->sha, 32, buf)))
          && (!info || (json.write_string("f", module_function_string(module_function(info)))
                        && json.write_string("n", module_name(module_index(info), buf))
                        && json.write_value("v", info->module_version)))
        // on the photon we have just one dependency, this will need generalizing for other platforms
          && json.write_attribute("d") && json.write('[');

        for (unsigned int d=0; d<1 && info; d++) {
            const module_dependency_t& dependency = info->dependency;
            module_function_t function = module_function_t(dependency.module_function);
            if (function==MODULE_FUNCTION_NONE) // skip empty dependents
                continue;
            if (d) result &= json.write(',');
            result &= json.write('{')
              && json.write_string("f", module_function_string(function))
              && json.write_string("n", module_name(dependency.module_index, buf))
              && json.write_value("v", dependency.module_version)
               && json.end_list() && json.write('}');
        }
        result &= json.write("]}");
    }

    result &= json.write(']');
    return result;
}
Exemplo n.º 19
0
 void implement_port(SC_PORT< bool  > &p, std::string name)
 {
   sc_module_name module_name((name + "_connector").c_str());
   connector<1, bool > *c =
     new connector<1, bool >(module_name, &p);
   std::vector<sc_inout_resolved *> *map = ports[name];
   for (int i=0;i<1;i++) {
     sc_inout_resolved *p = (*map)[i];
     (*p).bind(c->io_sig[i]);
   }
 }   
Exemplo n.º 20
0
static int execdomains_proc_show(struct seq_file *m, void *v)
{
	struct exec_domain	*ep;

	read_lock(&exec_domains_lock);
	for (ep = exec_domains; ep; ep = ep->next)
		seq_printf(m, "%d-%d\t%-16s\t[%s]\n",
			       ep->pers_low, ep->pers_high, ep->name,
			       module_name(ep->module));
	read_unlock(&exec_domains_lock);
	return 0;
}
Exemplo n.º 21
0
  SEXP pycall__funname(SEXP Rmodule_name, SEXP Rfun_name, SEXP Rargv_list, SEXP Rargv_dict) {
#ifdef REMBEDPY_DEBUG
    Rprintf("funname\n");
#endif
    std::string 
  		fun_name(Rcpp::as<std::string>(Rfun_name)),
  		module_name(Rcpp::as<std::string>(Rmodule_name));
    boost::python::object callable(RembedPy::extract_pyobj(fun_name, module_name));
    boost::python::list argv_list(RembedPy::extract_argv_list(Rargv_list));
    boost::python::dict argv_dict(RembedPy::extract_argv_dict(Rargv_dict));
    return RembedPy::pycall(callable, argv_list, argv_dict);
  }
Exemplo n.º 22
0
        dsn_handle_t load_dynamic_library(const char* module, const std::vector<std::string>& search_dirs)
        {
            std::string module_name(module);
# if defined(_WIN32)
            module_name += ".dll";
# elif defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)
            module_name = "lib" + module_name + ".so";
# else
# error not implemented yet
# endif

            // search given dirs with priority
            std::vector<std::string> passes;
            for (auto & dr : search_dirs)
            {
                passes.push_back(utils::filesystem::path_combine(dr, module_name));
            }

            // search OS given passes
            passes.push_back(module_name);

            // try 
            dsn_handle_t hmod = nullptr;
            for (auto & m : passes)
            {
# if defined(_WIN32)
                hmod = (dsn_handle_t)::LoadLibraryA(m.c_str());
                if (hmod == nullptr)
                {
                    // ddebug("load dynamic library '%s' failed, err = %d", m.c_str(), ::GetLastError());
                }
# else
                hmod = (dsn_handle_t)dlopen(m.c_str(), RTLD_LAZY | RTLD_GLOBAL);
                if (nullptr == hmod)
                {
                    // ddebug("load dynamic library '%s' failed, err = %s", m.c_str(), dlerror());
                }
# endif 
                else
                    break;
            }

            if (hmod == nullptr)
            {
                derror("load dynamic library '%s' failed after trying all the following paths", module_name.c_str());
                for (auto& m : passes)
                {
                    derror("\t%s", m.c_str());
                }
            }
            return hmod;
        }
Exemplo n.º 23
0
void 
kedr_payload_unregister(struct kedr_payload *payload)
{
	struct payload_elem *elem;
	
	BUG_ON(payload == NULL);

	if (mutex_lock_killable(&base_mutex))
	{
		KEDR_MSG(COMPONENT_STRING
			"failed to lock base_mutex\n");
		return;
	}
	
	elem = payload_elem_find(payload, &payload_list);
	if (elem == NULL)
	{
		KEDR_MSG(COMPONENT_STRING
			"module \"%s\" attempts to unregister the payload "
			"that was never registered\n",
			module_name(payload->mod));
		goto out;
	}
	
	KEDR_MSG(COMPONENT_STRING
		"unregistering payload from module \"%s\"\n",
		module_name(payload->mod));
	
	list_del(&elem->list);
	kfree(elem);
	
	payload_functions_unuse(payload);

	function_replacements_remove_payload(&replaced_functions_map, payload);

out:
	mutex_unlock(&base_mutex);
	return;
}
Exemplo n.º 24
0
int
get_exec_domain_list(char *page)
{
   struct exec_domain   *ep;
   int         len = 0;

   read_lock(&exec_domains_lock);
   for (ep = exec_domains; ep && len < PAGE_SIZE - 80; ep = ep->next)
      len += sprintf(page + len, "%d-%d\t%-16s\t[%s]\n",
                ep->pers_low, ep->pers_high, ep->name,
                module_name(ep->module));
   read_unlock(&exec_domains_lock);
   return (len);
}
Exemplo n.º 25
0
gboolean
blog_add (const GtkWidget *wid, const gchar *disname)
{
  GKeyFile *gkf;
  GtkEntry *entry;
  gchar *content, *token; 
  const gchar *entrytext;
  gsize size;
  renrenblog_t *blog;

  entry = g_object_get_data (G_OBJECT (wid), "token_entry");
  entrytext = gtk_entry_get_text (entry);

  token = get_token_from_uri (entrytext);
  g_return_val_if_fail (token, FALSE);

  blog = g_malloc (sizeof (renrenblog_t));
  g_return_val_if_fail (blog, FALSE);

  blog->core->name = g_strdup (disname);
  blog->core->plugin_name = g_strdup (module_name ());
  blog->core->enable = TRUE;

  blog->token = token;

#ifndef WIN32
  blog_list = g_list_append (blog_list, blog);
#else
  *blog_list_p = g_list_append (*blog_list_p, blog);
#endif

  if (g_inifile == NULL)
    {
      g_inifile = am_realpath ("~/.amblog/renrenblog");
    }
  g_return_val_if_fail (g_inifile, FALSE);

  gkf = g_key_file_new ();
  g_key_file_load_from_file (gkf, g_inifile, G_KEY_FILE_NONE, NULL);
  
  g_key_file_set_value (gkf, disname, "token", token);

  content = g_key_file_to_data (gkf, &size, NULL);
  g_file_set_contents (g_inifile, content, size, NULL);

  g_key_file_free (gkf);

  return TRUE;
}
Exemplo n.º 26
0
gboolean
module_init ()
{
  GKeyFile *gkf;
  renrenblog_t *blog;
  gchar **v;
  gsize i;

  if (g_inifile == NULL)
    {
      g_inifile = am_realpath ("~/.amblog/renrenblog");
    }
  g_return_val_if_fail (g_inifile, TRUE);

  gkf = g_key_file_new ();
  g_key_file_load_from_file (gkf, g_inifile, G_KEY_FILE_NONE, NULL);

  v = g_key_file_get_groups (gkf, NULL);
  if (v == NULL)
    {
      g_key_file_free (gkf);
      return TRUE;
    }

  for (i = 0; 
       v[i]; 
       ++ i
  )
    {
      blog = g_malloc (sizeof (renrenblog_t));

      blog->core->name = g_strdup (v[i]);
      blog->core->plugin_name = g_strdup (module_name ());
      blog->core->enable = TRUE;

      blog->token = g_key_file_get_value (gkf, v[i], "token", NULL);

#ifndef WIN32
      blog_list = g_list_append (blog_list, blog);
#else
      *blog_list_p = g_list_append (*blog_list_p, blog);
#endif

    }

  g_strfreev (v);

  return TRUE;
}
Exemplo n.º 27
0
bool Plugin::isAlreadyLoaded(const wchar_t* filename)
{
    const wchar_t *e = wcsrchr(filename, L'.');
    if (!e) return false;
    tstring module_name(filename, e);
    tstring ext(e+1);
    if (isLoadedPlugin(module_name.c_str()))
    {
        swprintf(plugin_buffer(), L"Плагин %s не загружен, так как место _G['%s'] занято модулем или другим плагином.", filename, 
            module_name.c_str());
        pluginOut(plugin_buffer());
        return true;
    }
    return false;
}
Exemplo n.º 28
0
void kedr_trace_marker_target(struct module* target_module,
    struct module* payload_module, bool is_begin)
{
    const char* target_name, *payload_name;
    void* id;
    size_t size;
    void* data;
    
    target_name = module_name(target_module);
    payload_name = module_name(payload_module);
    
    size = sizeof(bool) + strlen(target_name) + strlen(payload_name) + 2;
    
    id = kedr_trace_lock(kedr_trace_marker_target_pp_function,
        size, &data);
    
    if(id == NULL) return;
    
    *(bool*)data = is_begin;
    strcpy(data + sizeof(bool), target_name);
    strcpy(data + sizeof(bool) + strlen(target_name) + 1, payload_name);
    
    kedr_trace_unlock_commit(id);
}
Exemplo n.º 29
0
void sword_logic_installmgr_list_remote_modules (string source_name, vector <string> & modules)
{
  (void) source_name;
  (void) modules;
#ifdef HAVE_SWORD
  sword::SWMgr *mgr = new sword::SWMgr();
  
  sword::SWBuf baseDir = sword_logic_get_path ().c_str ();
  
  sword::InstallMgr *installMgr = new sword::InstallMgr (baseDir, NULL);
  installMgr->setUserDisclaimerConfirmed (true);
  
  sword::InstallSourceMap::iterator source = installMgr->sources.find(source_name.c_str ());
  if (source == installMgr->sources.end()) {
    Database_Logs::log ("Could not find remote source " + source_name);
  } else {
    sword::SWMgr *otherMgr = source->second->getMgr();
    sword::SWModule *module;
    if (!otherMgr) otherMgr = mgr;
    std::map<sword::SWModule *, int> mods = sword::InstallMgr::getModuleStatus(*mgr, *otherMgr);
    for (std::map<sword::SWModule *, int>::iterator it = mods.begin(); it != mods.end(); it++) {
      module = it->first;
      sword::SWBuf version = module->getConfigEntry("Version");
      sword::SWBuf status = " ";
      if (it->second & sword::InstallMgr::MODSTAT_NEW) status = "*";
      if (it->second & sword::InstallMgr::MODSTAT_OLDER) status = "-";
      if (it->second & sword::InstallMgr::MODSTAT_UPDATED) status = "+";
      string module_name (status);
      module_name.append ("[");
      module_name.append (module->getName());
      module_name.append ("]  \t(");
      module_name.append (version);
      module_name.append (")  \t- ");
      module_name.append (module->getDescription());
      // Check if the module is a verse-based Bible or commentary.
      bool verse_based = false;
      string module_type = module->getType ();
      if (module_type == "Biblical Texts") verse_based = true;
      if (module_type == "Commentaries") verse_based = true;
      if (verse_based) modules.push_back (module_name);
    }
  }
  
  delete installMgr;
  delete mgr;
#endif
}
Exemplo n.º 30
0
void module_init(module_t *handle)
{
    dsme_log(LOG_DEBUG, "DSME %s starting up", STRINGIFY(PRG_VERSION));

    char * modulename;
    char * path;
    char name[1024];  /* TODO more dynamic length */
    const char **names;
    FILE *conffile = fopen(MODULES_CONF, "r");

        modulename = strdup(module_name(handle));
	if (!modulename) {
		dsme_log(LOG_CRIT, "strdup failed");
		exit(EXIT_FAILURE);
	}

    path = dirname(modulename);

	if (!conffile) {
		dsme_log(LOG_DEBUG, "Unable to read conffile (%s), using compiled-in startup list", MODULES_CONF);
		for (names = modules ; *names ; names++) {
			snprintf(name, sizeof(name), "%s/%s", path, *names);
			if(load_module(name, 0) == NULL) {
				dsme_log(LOG_ERR, "error loading module %s", name);
			}
		}
	} else {
		size_t len = 0;
		char * line = NULL;
		
		dsme_log(LOG_DEBUG, "Conf file exists, reading modulenames from %s", MODULES_CONF);

		while (getline(&line, &len, conffile) > 0) { 
			snprintf(name, sizeof(name), "%s/%s", path, line);
			name[strlen(name) - 1] = '\0'; /* Remove newline */
			if (load_module(name, 0) == NULL) {
				dsme_log(LOG_ERR, "error loading module %s", name);
			}
		} 
		if (line)
			free(line);
		fclose(conffile);
	}

	free(modulename);
    dsme_log(LOG_DEBUG, "Module loading finished.");
}