static Evas_Loader_Module_Api * loader_module_find(const char *type) { Evas_Loader_Module_Api *l; Eina_Module *em; char buf[PATH_MAX]; l = eina_hash_find(loaders, type); if (l) return l; /* FIXME: Look in every possible path, but what will those be? */ snprintf(buf, sizeof(buf), PACKAGE_LIB_DIR "/evas/cserve2/loaders/%s/%s/%s", type, MODULE_ARCH, EVAS_MODULE_NAME_IMAGE_LOADER); em = eina_module_new(buf); if (!em) return NULL; if (!eina_module_load(em)) { eina_module_free(em); return NULL; } l = eina_hash_find(loaders, type); if (l) { modules = eina_list_append(modules, em); return l; } eina_module_free(em); return NULL; }
static void deserialize_sinks_watcher(Pulse *conn, Pulse_Tag *tag) { pa_subscription_event_type_t e; uint32_t idx; EINA_SAFETY_ON_FALSE_RETURN(untag_uint32(tag, &e)); EINA_SAFETY_ON_FALSE_RETURN(untag_uint32(tag, &idx)); if (e & PA_SUBSCRIPTION_EVENT_CHANGE) { Pulse_Sink *sink; sink = eina_hash_find(pulse_sinks, &idx); if (sink) { if (pulse_sink_get(conn, idx)) sink->update = EINA_TRUE; } else { sink = eina_hash_find(pulse_sources, &idx); if (!sink) return; if (pulse_source_get(conn, idx)) sink->update = EINA_TRUE; } } }
/** * @internal * @param desktop: The Efreet_Desktop to work with * @return Returns no value * @brief Frees the Efreet_Desktop structure and all of it's data */ EAPI void efreet_desktop_free(Efreet_Desktop *desktop) { if (!desktop) return; desktop->ref--; if (desktop->ref > 0) return; if (desktop->cached) { if (efreet_desktop_cache && desktop == eina_hash_find(efreet_desktop_cache, desktop->orig_path)) { eina_hash_del_by_key(efreet_desktop_cache, desktop->orig_path); } else if (old_caches) { Efreet_Old_Cache *d; Efreet_Desktop *curr; Eina_List *l; EINA_LIST_FOREACH(old_caches, l, d) { curr = eina_hash_find(d->desktop_cache, desktop->orig_path); if (curr && curr == desktop) { eina_hash_del_by_key(d->desktop_cache, desktop->orig_path); break; } } } }
END_TEST START_TEST(eina_hash_int32_fuzze) { Eina_Hash *hash; Eina_List *added = NULL; unsigned int *r; unsigned int i; unsigned int j; unsigned int seed; eina_init(); seed = time(NULL); srand(seed); hash = eina_hash_int32_new(free); for (i = 0; i < 10000; ++i) { r = malloc(sizeof (unsigned int)); *r = rand(); eina_hash_direct_add(hash, r, r); } for (j = 0; j < 100; ++j) { for (i = 0; i < 1000; ++i) { do { unsigned int tr; tr = rand(); r = eina_hash_find(hash, &tr); if (r) { r = NULL; continue; } r = malloc(sizeof (unsigned int)); *r = tr; eina_hash_direct_add(hash, r, r); added = eina_list_append(added, r); } while (r == NULL); } EINA_LIST_FREE(added, r) { unsigned int *s; s = eina_hash_find(hash, r); fail_if(s != r); eina_hash_del(hash, r, r); } }
static Eldbus_Message * _cb_property_get(const Eldbus_Service_Interface *piface, const Eldbus_Message *msg) { const char *propname, *iface_name; Eldbus_Service_Object *obj = piface->obj; Eldbus_Service_Interface *iface; Property *prop; Eldbus_Message *reply, *error_reply = NULL; Eldbus_Message_Iter *main_iter, *variant; Eina_Bool ret; Eldbus_Property_Get_Cb getter = NULL; if (!eldbus_message_arguments_get(msg, "ss", &iface_name, &propname)) return NULL; iface = eina_hash_find(obj->interfaces, iface_name); if (!iface) return eldbus_message_error_new(msg, DBUS_ERROR_UNKNOWN_INTERFACE, "Interface not found."); prop = eina_hash_find(iface->properties, propname); if (!prop || prop->is_invalidate) goto not_found; if (prop->property->get_func) getter = prop->property->get_func; else if (iface->get_func) getter = iface->get_func; if (!getter) goto not_found; reply = eldbus_message_method_return_new(msg); EINA_SAFETY_ON_NULL_RETURN_VAL(reply, NULL); main_iter = eldbus_message_iter_get(reply); variant = eldbus_message_iter_container_new(main_iter, 'v', prop->property->type); ret = getter(iface, propname, variant, msg, &error_reply); if (ret) { eldbus_message_iter_container_close(main_iter, variant); return reply; } eldbus_message_unref(reply); return error_reply; not_found: return eldbus_message_error_new(msg, DBUS_ERROR_UNKNOWN_PROPERTY, "Property not found."); }
Evas_Module * evas_module_find_type(Evas_Module_Type type, const char *name) { const char *path; const char *format = NULL; char buffer[4096]; Evas_Module *em; Eina_Module *en; Eina_List *l; if ((unsigned int)type > 3) return NULL; em = eina_hash_find(evas_modules[type], name); if (em) return em; EINA_LIST_FOREACH(evas_module_paths, l, path) { switch (type) { case EVAS_MODULE_TYPE_ENGINE: format = "%s/engines/%s/%s/" EVAS_MODULE_NAME_ENGINE; break; case EVAS_MODULE_TYPE_IMAGE_LOADER: format = "%s/loaders/%s/%s/" EVAS_MODULE_NAME_IMAGE_LOADER; break; case EVAS_MODULE_TYPE_IMAGE_SAVER: format = "%s/savers/%s/%s/" EVAS_MODULE_NAME_IMAGE_SAVER; break; case EVAS_MODULE_TYPE_OBJECT: format = "%s/object/%s/%s/" EVAS_MODULE_NAME_OBJECT; break; } snprintf(buffer, sizeof (buffer), format, path, name, MODULE_ARCH, name); if (!evas_file_path_is_file(buffer)) continue; en = eina_module_new(buffer); if (!en) continue; if (!eina_module_load(en)) { eina_module_free(en); continue; } em = eina_hash_find(evas_modules[type], name); if (em) { eina_evas_modules = eina_list_append(eina_evas_modules, en); return em; } eina_module_free(en); } return NULL; }
static void _sub_path_process(Elm_App_Client *eo, Eldbus_Message_Iter *obj_iter, Elm_App_Client_Data *data, Eina_Bool loading_list) { const char *obj_path; Eldbus_Message_Iter *array_iface, *iface; eldbus_message_iter_arguments_get(obj_iter, "oa{sa{sv}}", &obj_path, &array_iface); while (eldbus_message_iter_get_and_next(array_iface, '{', &iface)) { const char *iface_name; Eldbus_Message_Iter *array_props; Elm_App_Client_View *view; eldbus_message_iter_arguments_get(iface, "sa{sv}", &iface_name, &array_props); if (strcmp(iface_name, "org.enlightenment.ApplicationView1")) continue; view = eina_hash_find(data->views, obj_path); if (view) continue; view = eo_add(ELM_APP_CLIENT_VIEW_CLASS, eo, elm_app_client_view_path_set(obj_path)); eina_hash_add(data->views, obj_path, view); if (!loading_list) eo_do(eo, eo_event_callback_call(ELM_APP_CLIENT_EVENT_VIEW_CREATED, view)); } }
void etam_packets_del(Etam_Collection *coll, const char *name) { Etam_Packets *r; if (!coll) return ; eina_rwlock_take_write(&coll->lock); r = eina_hash_find(coll->rows, name); if (!r) goto end; eina_hash_del(coll->rows, name, r); eina_rwlock_take_write(&r->lock); EINA_REFCOUNT_UNREF(r) { eina_rwlock_release(&r->lock); etam_packets_free(r); r = NULL; } if (r) eina_rwlock_release(&r->lock); end: eina_rwlock_release(&coll->lock); }
/** * @param ini The Efree_Ini to work with * @param key The key to lookup * @return Returns the string associated with the given key or NULL if not * found. * @brief Retrieves the value for the given key or NULL if none found. */ EAPI const char * efreet_ini_string_get(Efreet_Ini *ini, const char *key) { if (!ini || !key || !ini->section) return NULL; return eina_hash_find(ini->section, key); }
static Evas_GL_Program * evas_gl_common_shader_generate_and_compile(Evas_GL_Shared *shared, unsigned int flags) { char *vertex, *fragment; Evas_GL_Program *p; if (eina_hash_find(shared->shaders_hash, &flags)) return NULL; vertex = evas_gl_common_shader_glsl_get(flags, vertex_glsl); fragment = evas_gl_common_shader_glsl_get(flags, fragment_glsl); p = evas_gl_common_shader_compile(flags, vertex, fragment); if (p) { shared->needs_shaders_flush = 1; p->uniform.mvp = glGetUniformLocation(p->prog, "mvp"); p->uniform.rotation_id = glGetUniformLocation(p->prog, "rotation_id"); evas_gl_common_shader_textures_bind(p); eina_hash_add(shared->shaders_hash, &flags, p); } else WRN("Failed to compile a shader (flags: %08x)", flags); free(vertex); free(fragment); return p; }
static Eina_Bool trigger_run(void *data) { struct callback_trigger_data *trigger = data; struct connline_context *context; connline_callback_f callback; enum connline_event event; char **changed_property; Ecore_Timer *e_timer; Eina_Hash *context_ht; if (trigger == NULL) return EINA_FALSE; callback = trigger->callback; context = trigger->context; event = trigger->event; changed_property = trigger->changed_property; trigger->changed_property = NULL; e_timer = trigger->e_timer; trigger->e_timer = NULL; callback(context, event, changed_property, context->user_data); context_ht = eina_hash_find(triggers_table, context); if (context_ht != NULL) eina_hash_del(context_ht, e_timer, NULL); return FALSE; }
EINTERN const char * e_mod_comp_atoms_name_get(Ecore_X_Atom a) { E_CHECK_RETURN(a, NULL); return eina_hash_find(atoms_hash, e_util_winid_str_get(a)); }
EAPI Eina_Bool email_config_data_remove(Email_Config *cfg, const char *key) { EINA_SAFETY_ON_NULL_RETURN_VAL(cfg, EINA_FALSE); EINA_SAFETY_ON_NULL_RETURN_VAL(key, EINA_FALSE); Hash_Data *hd; Eina_Bool chk; _config_lock(cfg); /* * Set the free_cb to NULL, so the data will just be * removed from the hash table, not freed behind the * hood. */ hd = eina_hash_find(cfg->user_config, key); if (EINA_UNLIKELY(!hd)) { _config_unlock(cfg); ERR("No data found for key \"%s\"", key); return EINA_FALSE; } hd->free_cb = NULL; chk = eina_hash_del(cfg->user_config, key, hd); _config_unlock(cfg); if (EINA_UNLIKELY(!chk)) { ERR("Failed to delete item for key \"%s\"", key); return EINA_FALSE; } return EINA_TRUE; }
list_t * process_job_results(Eina_Hash *map_histo, list_t *files, float threshold) { list_t * similar_files = NULL; list_t * lst_files = NULL; list_t * list_histo = NULL; list_t * current = NULL; while(files) { histogram_t *cached_elem = eina_hash_find(map_histo, files->value); list_histo = list_append(list_histo, cached_elem); files = files->next; } printf("Looking for similarities in %i elements with threshold %.2f\n" , eina_hash_population(map_histo), threshold); current = list_histo; while(current) { lst_files = search_similar(current->value , current->next, threshold); current = current->next; similar_files = list_append(similar_files, lst_files); } list_release(list_histo); return similar_files; }
static bool ewk_js_method_invoke(NPObject* npObject, NPIdentifier name, const NPVariant* npArgs, uint32_t npArgCount, NPVariant* result) { Ewk_JS_Object* object = reinterpret_cast<Ewk_JS_Object*>(npObject); Ewk_JS_Method* method; Ewk_JS_Variant* args; Ewk_JS_Variant* ret_val; EINA_SAFETY_ON_NULL_RETURN_VAL(npObject, false); EINA_MAGIC_CHECK_OR_RETURN(object, false); if (!_NPN_IdentifierIsString(name)) { ERR("int NPIdentifier is not supported."); return false; } method = static_cast<Ewk_JS_Method*>(eina_hash_find(object->cls->methods, name)); if (!method) return false; args = static_cast<Ewk_JS_Variant*>(malloc(sizeof(Ewk_JS_Variant) *npArgCount)); if (!args) { ERR("Could not allocate memory for ewk_js_variant"); return false; } for (uint32_t i = 0; i < npArgCount; i++) ewk_js_npvariant_to_variant(&args[i], &npArgs[i]); ret_val = method->invoke(object, args, npArgCount); ewk_js_variant_to_npvariant(ret_val, result); ewk_js_variant_free(ret_val); return true; }
Eina_Bool evas_module_register(const Evas_Module_Api *module, Evas_Module_Type type) { Evas_Module *em; if ((unsigned int)type > 3) return EINA_FALSE; if (!module) return EINA_FALSE; if (module->version != EVAS_MODULE_API_VERSION) return EINA_FALSE; em = eina_hash_find(evas_modules[type], module->name); if (em) return EINA_FALSE; em = calloc(1, sizeof (Evas_Module)); if (!em) return EINA_FALSE; em->definition = module; if (type == EVAS_MODULE_TYPE_ENGINE) { eina_array_push(evas_engines, em); em->id_engine = eina_array_count(evas_engines); } eina_hash_direct_add(evas_modules[type], module->name, em); return EINA_TRUE; }
Eina_Module * _ecore_evas_engine_load(const char *engine) { const char *path; Eina_List *l; Eina_Module *em = NULL; EINA_SAFETY_ON_NULL_RETURN_VAL(engine, NULL); em = (Eina_Module *)eina_hash_find(_registered_engines, engine); if (em) return em; EINA_LIST_FOREACH(_engines_paths, l, path) { char tmp[PATH_MAX]; snprintf(tmp, sizeof (tmp), "%s/%s/%s/"ECORE_EVAS_ENGINE_NAME, path, engine, MODULE_ARCH); em = eina_module_new(tmp); if (!em) continue; if (!eina_module_load(em)) { eina_module_free(em); continue; } if (eina_hash_add(_registered_engines, engine, em)) return em; }
static bool ewk_js_property_remove(NPObject* npObject, NPIdentifier name) { Ewk_JS_Object* object = reinterpret_cast<Ewk_JS_Object*>(npObject); Ewk_JS_Property* prop; bool fail = false; EINA_SAFETY_ON_NULL_RETURN_VAL(npObject, false); EINA_MAGIC_CHECK_OR_RETURN(object, false); if (!_NPN_IdentifierIsString(name)) { ERR("int NPIdentifier is not supported."); return fail; } char* prop_name = _NPN_UTF8FromIdentifier(name); prop = static_cast<Ewk_JS_Property*>(eina_hash_find(object->cls->properties, prop_name)); if (prop && prop->del) fail = prop->del(object, prop->name); // Class has property and property has getter. else if (object->cls->default_prop.del) fail = object->cls->default_prop.del(object, prop_name); else fail = eina_hash_del(object->properties, prop_name, 0); free(prop_name); return fail; }
int connline_plugin_trigger_callback(struct connline_context *context, connline_callback_f callback, enum connline_event event, char **changed_property) { struct callback_trigger_data *trigger; Eina_Hash *context_ht; if (callback == NULL || context == NULL) return -EINVAL; trigger = calloc(1, sizeof(struct callback_trigger_data)); if (trigger == NULL) return -ENOMEM; trigger->callback = callback; trigger->context = context; trigger->event = event; trigger->changed_property = changed_property; trigger->e_timer = ecore_timer_add(0, trigger_run, trigger); context_ht = eina_hash_find(triggers_table, context); if (context_ht == NULL) { context_ht = eina_hash_pointer_new(remove_trigger); eina_hash_add(triggers_table, context, context_ht); } eina_hash_add(context_ht, trigger->e_timer, trigger); return 0; }
END_TEST START_TEST(eina_hash_extended) { Eina_Hash *hash = NULL; int i; fail_if(eina_init() != 2); hash = eina_hash_string_djb2_new(NULL); fail_if(hash == NULL); fail_if(eina_hash_direct_add(hash, "42", "42") != EINA_TRUE); for (i = 43; i < 3043; ++i) { char *tmp = malloc(10); fail_if(!tmp); eina_convert_itoa(i, tmp); fail_if(eina_hash_direct_add(hash, tmp, tmp) != EINA_TRUE); } fail_if(eina_hash_find(hash, "42") == NULL); eina_hash_free(hash); fail_if(eina_shutdown() != 1); }
struct enobj * enobj_get(uintptr_t id){ struct enobj *obj; obj = eina_hash_find(objdb, &id); assert(obj->magic == ENOBJMAGIC); assert(id == obj->id); return obj; }
/** * @param ini The Efreet_Ini to work with * @param section The section of the ini file we want to get values from * @return Returns 1 if the section exists, otherwise 0 * @brief Sets the current working section of the ini file to @a section */ EAPI int efreet_ini_section_set(Efreet_Ini *ini, const char *section) { if (!ini || !ini->data || !section) return 0; ini->section = eina_hash_find(ini->data, section); return (ini->section ? 1 : 0); }
static void win_emit(Ecore_Wl2_Display *d, const char *sig, uint32_t val) { Evas_Object *win; win = eina_list_data_get(eina_hash_find(wins, &d)); evas_object_smart_callback_call(win, sig, (uintptr_t*)(uintptr_t)val); }
EAPI void * ecore_event_window_match(Ecore_Window id) { Ecore_Input_Window *lookup; lookup = eina_hash_find(_window_hash, &id); if (lookup) return lookup->window; return NULL; }
EINA_ITERATOR_FOREACH(itr, dep) { if (!eina_hash_find(_parsingeos, dep) && !eolian_file_parse(dep)) { eina_iterator_free(itr); eina_hash_free_buckets(_defereos); goto error; } }
EAPI void ecore_event_window_ignore_events(Ecore_Window id, int ignore_event) { Ecore_Input_Window *lookup; lookup = eina_hash_find(_window_hash, &id); if (!lookup) return; lookup->ignore_event = ignore_event; }
/* externally accessible functions */ EAPI int e_stolen_win_get(Ecore_X_Window win) { E_Stolen_Window *esw; esw = eina_hash_find(_e_stolen_windows, e_util_winid_str_get(win)); if (esw) return 1; return 0; }
EAPI const char * efreet_ini_string_get(Efreet_Ini *ini, const char *key) { EINA_SAFETY_ON_NULL_RETURN_VAL(ini, NULL); EINA_SAFETY_ON_NULL_RETURN_VAL(ini->section, NULL); EINA_SAFETY_ON_NULL_RETURN_VAL(key, NULL); return eina_hash_find(ini->section, key); }
EAPI Evas_Object * evas_object_name_find(const Evas *e, const char *name) { MAGIC_CHECK(e, Evas, MAGIC_EVAS); return NULL; MAGIC_CHECK_END(); if (!name) return NULL; return (Evas_Object *)eina_hash_find(e->name_hash, name); }
EAPI int efreet_ini_section_set(Efreet_Ini *ini, const char *section) { EINA_SAFETY_ON_NULL_RETURN_VAL(ini, 0); EINA_SAFETY_ON_NULL_RETURN_VAL(ini->data, 0); EINA_SAFETY_ON_NULL_RETURN_VAL(section, 0); ini->section = eina_hash_find(ini->data, section); return (ini->section ? 1 : 0); }