EINTERN int e_dnd_init(void) { _type_text_uri_list = eina_stringshare_add("text/uri-list"); _type_xds = eina_stringshare_add("XdndDirectSave0"); _type_text_x_moz_url = eina_stringshare_add("text/x-moz-url"); _type_enlightenment_x_file = eina_stringshare_add("enlightenment/x-file"); #ifndef HAVE_WAYLAND_ONLY if (e_comp_util_has_x()) _text_atom = ecore_x_atom_get("text/plain"); #endif _drop_win_hash = eina_hash_int32_new(NULL); _drop_handlers_responsives = eina_hash_int32_new(NULL); E_LIST_HANDLER_APPEND(_event_handlers, ECORE_EVENT_MOUSE_BUTTON_UP, _e_dnd_cb_mouse_up, NULL); E_LIST_HANDLER_APPEND(_event_handlers, ECORE_EVENT_MOUSE_MOVE, _e_dnd_cb_mouse_move, NULL); E_LIST_HANDLER_APPEND(_event_handlers, ECORE_EVENT_KEY_DOWN, _e_dnd_cb_key_down, NULL); E_LIST_HANDLER_APPEND(_event_handlers, ECORE_EVENT_KEY_UP, _e_dnd_cb_key_up, NULL); if (e_comp->comp_type != E_PIXMAP_TYPE_X) return 1; #ifndef HAVE_WAYLAND_ONLY E_LIST_HANDLER_APPEND(_event_handlers, ECORE_X_EVENT_XDND_ENTER, _e_dnd_cb_event_dnd_enter, NULL); E_LIST_HANDLER_APPEND(_event_handlers, ECORE_X_EVENT_XDND_LEAVE, _e_dnd_cb_event_dnd_leave, NULL); E_LIST_HANDLER_APPEND(_event_handlers, ECORE_X_EVENT_XDND_POSITION, _e_dnd_cb_event_dnd_position, NULL); E_LIST_HANDLER_APPEND(_event_handlers, ECORE_X_EVENT_XDND_FINISHED, _e_dnd_cb_event_dnd_finished, NULL); E_LIST_HANDLER_APPEND(_event_handlers, ECORE_X_EVENT_XDND_DROP, _e_dnd_cb_event_dnd_drop, NULL); E_LIST_HANDLER_APPEND(_event_handlers, ECORE_X_EVENT_SELECTION_NOTIFY, _e_dnd_cb_event_dnd_selection, NULL); E_LIST_HANDLER_APPEND(_event_handlers, ECORE_X_EVENT_WINDOW_HIDE, _e_dnd_cb_event_hide, NULL); e_drop_xdnd_register_set(e_comp->ee_win, 1); _action = ECORE_X_ATOM_XDND_ACTION_PRIVATE; #endif return 1; }
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); } }
gint ed_curl_post(char *screen_name, char *password, http_request * request, char * post_fields, int account_id) { CURLcode res; CURL *ua=NULL; double content_length=0; char *key=NULL; if(!request) return 2; if(!request->url || strlen(request->url) <= 0) return 3; if(!user_agents) user_agents = eina_hash_int32_new(user_agent_free); res = asprintf(&key, "%d", account_id); if(res!=-1) { ua = (CURL*)eina_hash_find(user_agents, key); free(key); } else return(6); if(!ua) { ua = ed_curl_init(screen_name, password, request, account_id); if(!ua) return(6); curl_easy_setopt(ua, CURLOPT_HTTPGET, 0L ); curl_easy_setopt(ua, CURLOPT_POST, 1L ); } curl_easy_setopt(ua, CURLOPT_URL, request->url ); curl_easy_setopt(ua, CURLOPT_WRITEDATA, (void *)&(request->content) ); if(post_fields) curl_easy_setopt(ua, CURLOPT_POSTFIELDS, post_fields ); res = curl_easy_perform(ua); curl_easy_getinfo(ua, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &content_length); curl_easy_getinfo(ua, CURLINFO_REDIRECT_URL, &request->redir_url); if((res == 18 && content_length != -1) || res != 0) { show_curl_error(res, &(request->content)); return(4); } else { res = curl_easy_getinfo(ua, CURLINFO_RESPONSE_CODE, &request->response_code); return(0); } }
END_TEST START_TEST(eina_hash_all_int) { Eina_Hash *hash; int64_t j[] = { 4321312301243122, 6, 7, 128 }; int i[] = { 42, 6, 7, 0 }; int64_t *test2; int *test; int it; fail_if(eina_init() != 2); hash = eina_hash_int32_new(NULL); fail_if(hash == NULL); for (it = 0; it < 4; ++it) fail_if(eina_hash_add(hash, &i[it], &i[it]) != EINA_TRUE); fail_if(eina_hash_del(hash, &i[1], &i[1]) != EINA_TRUE); test = eina_hash_find(hash, &i[2]); fail_if(test != &i[2]); test = eina_hash_find(hash, &i[3]); fail_if(test != &i[3]); eina_hash_free(hash); hash = eina_hash_int64_new(NULL); fail_if(hash == NULL); for (it = 0; it < 4; ++it) fail_if(eina_hash_add(hash, &j[it], &j[it]) != EINA_TRUE); fail_if(eina_hash_del(hash, &j[1], &j[1]) != EINA_TRUE); test2 = eina_hash_find(hash, &j[0]); fail_if(test2 != &j[0]); eina_hash_free(hash); fail_if(eina_shutdown() != 1); }
/** * @brief Set a callback to free the return struct of @p id * * This function, when set, frees the returned user-type struct of a call. * @param client The client * @param id The transmission id * @param callback The free callback */ Eina_Bool azy_client_callback_free_set(Azy_Client *client, Azy_Client_Call_Id id, Ecore_Cb callback) { DBG("(client=%p, id=%u)", client, id); if (!AZY_MAGIC_CHECK(client, AZY_MAGIC_CLIENT)) { AZY_MAGIC_FAIL(client, AZY_MAGIC_CLIENT); return EINA_FALSE; } EINA_SAFETY_ON_NULL_RETURN_VAL(callback, EINA_FALSE); EINA_SAFETY_ON_TRUE_RETURN_VAL(id < 1, EINA_FALSE); if (!client->free_callbacks) client->free_callbacks = eina_hash_int32_new(NULL); EINA_SAFETY_ON_NULL_RETURN_VAL(client->free_callbacks, EINA_FALSE); return eina_hash_add(client->free_callbacks, &id, callback); }