static char * evas_gl_common_shader_glsl_get(unsigned int flags, const char *base) { Eina_Strbuf *s = eina_strbuf_new(); unsigned int k; char *str; /* This is an env var to use for debugging purposes only */ static const char *evas_gl_shader_glsl_version = NULL; if (!evas_gl_shader_glsl_version) { evas_gl_shader_glsl_version = getenv("EVAS_GL_SHADER_GLSL_VERSION"); if (!evas_gl_shader_glsl_version) evas_gl_shader_glsl_version = ""; else WRN("Using GLSL version tag: '%s'", evas_gl_shader_glsl_version); } if (*evas_gl_shader_glsl_version) eina_strbuf_append_printf(s, "#version %s\n", evas_gl_shader_glsl_version); for (k = 0; k < SHADER_FLAG_COUNT; k++) { if (flags & (1 << k)) eina_strbuf_append_printf(s, "#define SHD_%s\n", _shader_flags[k]); } eina_strbuf_append(s, base); str = eina_strbuf_string_steal(s); eina_strbuf_free(s); return str; }
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 void _efl_net_control_technology_property_changed_internal(Eo *o, Efl_Net_Control_Technology_Data *pd, Eldbus_Message_Iter *itr) { Eldbus_Message_Iter *value; const char *name; if (!eldbus_message_iter_arguments_get(itr, "sv", &name, &value)) { ERR("Unexpected signature: %s", eldbus_message_iter_signature_get(itr)); return; } if (strcmp(name, "Powered") == 0) _efl_net_control_technology_property_powered_changed(o, pd, value); else if (strcmp(name, "Connected") == 0) _efl_net_control_technology_property_connected_changed(o, pd, value); else if (strcmp(name, "Name") == 0) _efl_net_control_technology_property_name_changed(o, pd, value); else if (strcmp(name, "Type") == 0) _efl_net_control_technology_property_type_changed(o, pd, value); else if (strcmp(name, "Tethering") == 0) _efl_net_control_technology_property_tethering_changed(o, pd, value); else if (strcmp(name, "TetheringIdentifier") == 0) _efl_net_control_technology_property_tethering_identifier_changed(o, pd, value); else if (strcmp(name, "TetheringPassphrase") == 0) _efl_net_control_technology_property_tethering_passphrase_changed(o, pd, value); else WRN("Unknown property name: %s", name); }
void unitTest() { // good case: 4 22 35 71 86 87 97 97 97 [expected = 7, actual = 6] clock_t start = clock(); clock_t elapsed = start; bool flag = true; while (flag && (elapsed - start) < 5 * CLOCKS_PER_SEC) { size_t size = rand() % 65536 + 1000; // 10 + 1; int* array = new int[size]; for (size_t i = 0; i < size; ++i) { array[i] = rand() % 100; } qsort(array, size, sizeof(int), compare); int x = rand() % 100; int* ptr = static_cast<int*>(bsearch(&x, array, size, sizeof(int), compare)); int expected = ptr != nullptr ? ptr - array : -1; int actual = binarySearch(x, array, size); if (expected >= 0 && actual >= 0 && expected != actual) { WRN("Found: x = %i, expected = %i, actual = %i", x, expected, actual); // print(array, size); // flag = false; } else if (expected == actual) { INF("OK: %zu", size); } else { ERR("Error: x = %i, expected = %i, actual = %i", x, expected, actual); print(array, size); flag = false; } delete [] array; array = nullptr; elapsed = clock(); } }
/* TODO: Documentation says "All implementations support the system-wide * real-time clock, which is identified by CLOCK_REALTIME. Check if the fallback * to unix time (without specifying the resolution) might be removed */ void _ecore_time_init(void) { #ifdef HAVE_CLOCK_GETTIME struct timespec t; if (_ecore_time_clock_id != -1) return; if (!clock_gettime(CLOCK_MONOTONIC, &t)) { _ecore_time_clock_id = CLOCK_MONOTONIC; DBG("using CLOCK_MONOTONIC."); } else if (!clock_gettime(CLOCK_REALTIME, &t)) { /* may go backwards */ _ecore_time_clock_id = CLOCK_REALTIME; WRN("CLOCK_MONOTONIC not available. Fallback to CLOCK_REALTIME."); } else { _ecore_time_clock_id = -2; CRIT("Cannot get a valid clock_gettime() clock id! " "Fallback to unix time."); } #else # ifndef HAVE_EVIL # warning "Your platform isn't supported yet" CRIT("Platform does not support clock_gettime. " "Fallback to unix time."); # endif #endif _ecore_time_loop_time = ecore_time_get(); }
Eldbus_Message * _eldbus_connection_send_and_block(Eldbus_Connection *conn, Eldbus_Message *msg, double timeout) { Eldbus_Message *reply = NULL; DBusError err; DBusMessage *dbus_msg; if (ecore_main_loop_nested_get()) WRN("Calling this function may result in dropped frames because the main loop is running"); dbus_error_init(&err); dbus_msg = dbus_connection_send_with_reply_and_block(conn->dbus_conn, msg->dbus_msg, timeout, &err); EINA_SAFETY_ON_TRUE_GOTO(dbus_error_is_set(&err), dbus_error_set); dbus_error_free(&err); reply = eldbus_message_new(EINA_FALSE); EINA_SAFETY_ON_NULL_GOTO(reply, fail); reply->dbus_msg = dbus_msg; dbus_message_iter_init(reply->dbus_msg, &reply->iterator->dbus_iterator); eldbus_message_unref(msg); return reply; dbus_error_set: reply = eldbus_message_error_new(msg, err.name, err.message); dbus_error_free(&err); fail: eldbus_message_unref(msg); return reply; }
D3DObjectFont::Glyph *D3DObjectFont::AddGlyph(D3DDevice *d3d, void *source, BYTE *data8, int width, int height, int pitch) { if (_image_id < 0) { WRN("Font is not initialized"); return NULL; } for (int i = 0; i < _glyphs.Length(); i++) { if (_glyphs[i]->Compare(source)) return _glyphs[i]; } Ref<Glyph> glyph = new Glyph(source); glyph->_data.Allocate(width * height); glyph->_width = width; glyph->_height = height; for (int i = 0; i < height; i++) CopyMemory(&glyph->_data[i * width], &data8[i * pitch], width); Log("Glyph added (%p) (%dx%d)", source, width, height); _glyphs.Add(glyph); return _glyphs.Last()->Addr(); }
static void _ecore_evas_vnc_server_update_clients(rfbScreenInfoPtr vnc_screen) { rfbClientIteratorPtr itr; rfbClientRec *client; itr = rfbGetClientIterator(vnc_screen); //No clients. if (!itr) return; while ((client = rfbClientIteratorNext(itr))) { rfbBool r; r = rfbUpdateClient(client); if (!r) { Ecore_Evas_Vnc_Server_Client_Data *cdata = client->clientData; WRN("Could not update the VNC client on seat '%s'\n", evas_device_name_get(cdata->seat)); } //Client disconnected if (client->sock == -1) rfbClientConnectionGone(client); } rfbReleaseClientIterator(itr); }
EAPI Eina_List * efreet_desktop_string_list_parse(const char *string) { Eina_List *list = NULL; char *tmp; char *s, *p; size_t len; EINA_SAFETY_ON_NULL_RETURN_VAL(string, NULL); len = strlen(string) + 1; tmp = alloca(len); memcpy(tmp, string, len); s = tmp; while ((p = strchr(s, ';'))) { if (p > tmp && *(p-1) == '\\') continue; *p = '\0'; list = eina_list_append(list, (void *)eina_stringshare_add(s)); s = p + 1; } /* If this is true, the .desktop file does not follow the standard */ if (*s) { #ifdef STRICT_SPEC WRN("[Efreet]: Found a string list without ';' " "at the end: %s", string); #endif list = eina_list_append(list, (void *)eina_stringshare_add(s)); } return list; }
Eina_Bool set_clip_name(char **name, char * text, int mode, int n) { Eina_Bool ret = EINA_TRUE; /* Sanity check */ if (!text) { WRN("ERROR: Text is NULL\n"); text = ""; } /* to be continued latter */ if (name) *name = _sanitize_ln(text, n, mode); else { ERR("Error: Clip name pointer is Null!!"); return EINA_FALSE; } if (!*name) { /* This is bad, leave it to calling function */ CRI("ERROR: Memory allocation Failed!!"); ret = EINA_FALSE; } return ret; }
Eina_Bool evas_bufmgr_init(int fd) { /* if we already have an interface, then we have been here before */ if (_ebi) return EINA_TRUE; /* try to allocate space for interface */ if (!(_ebi = calloc(1, sizeof(Evas_Bufmgr_Interface)))) return EINA_FALSE; /* save drm card fd for later use */ _ebi->fd = fd; /* try to find and link gbm library first */ if (!_evas_bufmgr_gbm_init()) { /* try to find and link tbm library */ if (!_evas_bufmgr_tbm_init()) { ERR("Could not init buffer library"); goto err; } } /* with the library open and functions linked, lets try to init */ if (_ebi->funcs.gbm.init) _ebi->mgr = _ebi->funcs.gbm.init(fd); else if (_ebi->funcs.tbm.init) _ebi->mgr = _ebi->funcs.tbm.init(fd); if (!_ebi->mgr) { ERR("Could not init buffer manager"); goto init_err; } /* with the manager initialized, we need to init egl */ if (!_evas_bufmgr_egl_init()) WRN("Could not init egl"); return EINA_TRUE; /* egl_err: */ /* if (_ebi->mgr) */ /* { */ /* if (_ebi->funcs.gbm.shutdown) _ebi->funcs.gbm.shutdown(_ebi->mgr); */ /* else if (_ebi->funcs.tbm.shutdown) _ebi->funcs.tbm.shutdown(_ebi->mgr); */ /* _ebi->mgr = NULL; */ /* } */ init_err: /* close library */ if (_ebi->lib) dlclose(_ebi->lib); _ebi->lib = NULL; err: /* free allocated space */ free(_ebi); _ebi = NULL; return EINA_FALSE; }
const char * ems_config_cache_dirname_get(void) { static const char *dir_name = NULL; char tmp[PATH_MAX]; if (dir_name) return dir_name; if (!ems_config) return NULL; /* cache path is not set or doesn't exist : save cache in $HOME/.cache/enna-media-server */ if (!ems_config->cache_path || !ems_config->cache_path[0] || !ecore_file_exists(ems_config->cache_path)) { snprintf(tmp, sizeof(tmp), "%s/.cache/enna-media-server", getenv("HOME")); WRN("Cache directory is not set, save cache data in %s", tmp); } else { /* create a directory enna-media-server into cache specified in config */ snprintf(tmp, sizeof(tmp), "%s/enna-media-server", ems_config->cache_path); INF("Save cache data in %s\n", tmp); } if (!ecore_file_is_dir(tmp)) ecore_file_mkpath(tmp); dir_name = eina_stringshare_add(tmp); return dir_name; }
static int _fallback(Eina_Prefix *pfx, const char *pkg_bin, const char *pkg_lib, const char *pkg_data, const char *pkg_locale, const char *envprefix) { char *p; STRDUP_REP(pfx->prefix_path, pkg_bin); if (!pfx->prefix_path) return 0; p = strrchr(pfx->prefix_path, DSEP_C); if (p) *p = 0; STRDUP_REP(pfx->prefix_path_bin, pkg_bin); STRDUP_REP(pfx->prefix_path_lib, pkg_lib); STRDUP_REP(pfx->prefix_path_data, pkg_data); STRDUP_REP(pfx->prefix_path_locale, pkg_locale); WRN("Could not determine its installed prefix for '%s'\n" " so am falling back on the compiled in default:\n" " %s\n" " implied by the following:\n" " bindir = %s\n" " libdir = %s\n" " datadir = %s\n" " localedir = %s\n" " Try setting the following environment variables:\n" " %s_PREFIX - points to the base prefix of install\n" " or the next 4 variables\n" " %s_BIN_DIR - provide a specific binary directory\n" " %s_LIB_DIR - provide a specific library directory\n" " %s_DATA_DIR - provide a specific data directory\n" " %s_LOCALE_DIR - provide a specific locale directory", envprefix, pfx->prefix_path, pkg_bin, pkg_lib, pkg_data, pkg_locale, envprefix, envprefix, envprefix, envprefix, envprefix); pfx->fallback = 1; return 1; }
/** * Get the exact tile for the given position and zoom. * * If the tile was unused then it's removed from the cache. * * After usage, please give it back using * ewk_tile_matrix_tile_put(). If you just want to check if it exists, * then use ewk_tile_matrix_tile_exact_exists(). * * @param tm the tile matrix to get tile from. * @param col the column number. * @param row the row number. * @param zoom the exact zoom to use. * * @return The tile instance or @c NULL if none is found. If the tile * was in the unused cache it will be @b removed (thus * considered used) and one should give it back with * ewk_tile_matrix_tile_put() afterwards. * * @see ewk_tile_matrix_tile_nearest_get() * @see ewk_tile_matrix_tile_exact_get() */ Ewk_Tile *ewk_tile_matrix_tile_exact_get(Ewk_Tile_Matrix *tm, unsigned long col, unsigned int row, float zoom) { Ewk_Tile *t, *item, *item_found = NULL; Eina_Inlist *inl; t = eina_matrixsparse_data_idx_get(tm->matrix, row, col); if (!t) return NULL; if (t->zoom == zoom) goto end; EINA_INLIST_FOREACH(EINA_INLIST_GET(t), item) { if (item->zoom != zoom) continue; item_found = item; break; } if (!item_found) return NULL; inl = eina_inlist_promote(EINA_INLIST_GET(t), EINA_INLIST_GET(item_found)); eina_matrixsparse_data_idx_replace(tm->matrix, row, col, inl, NULL); end: if (!t->visible) { if (!ewk_tile_unused_cache_tile_get(tm->tuc, t)) WRN("Ewk_Tile was unused but not in cache? bug!"); } return t; }
void wkb_ibus_input_context_create(struct wl_input_method_context *wl_ctx) { const char *ctx_name = "wayland"; if (!wkb_ibus) return; if (wkb_ibus->input_ctx) { WRN("Input context already exists"); wkb_ibus_input_context_destroy(); } wkb_ibus->input_ctx = calloc(1, sizeof(*(wkb_ibus->input_ctx))); wkb_ibus->input_ctx->wl_ctx = wl_ctx; if (!wkb_ibus->conn) { ERR("Not connected"); return; } if (!wkb_ibus->ibus) { ERR("No IBus proxy"); return; } wkb_ibus->input_ctx->pending = eldbus_proxy_call(wkb_ibus->ibus, "CreateInputContext", _ibus_input_ctx_create, NULL, -1, "s", ctx_name); }
/** * @internal * @param icon The icon name to strip extension * @return Extension removed if in list of extensions, else untouched. * @brief Removes extension from icon name if in list of extensions. */ static char * efreet_icon_remove_extension(const char *icon) { Eina_List *l; char *tmp = NULL, *ext = NULL; if (!icon) return NULL; tmp = strdup(icon); ext = strrchr(tmp, '.'); if (ext) { const char *ext2; EINA_LIST_FOREACH(efreet_icon_extensions, l, ext2) { if (!strcmp(ext, ext2)) { #ifdef STRICT_SPEC WRN("[Efreet]: Requesting an icon with an extension: %s", icon); #endif *ext = '\0'; break; } } } return tmp; }
void emotion_modules_shutdown(void) { Emotion_Engine_Registry_Entry *re; #ifdef EMOTION_STATIC_BUILD_XINE xine_module_shutdown(); #endif #if defined(EMOTION_STATIC_BUILD_GSTREAMER) || defined(EMOTION_STATIC_BUILD_GSTREAMER1) gstreamer_module_shutdown(); #endif #ifdef EMOTION_STATIC_BUILD_GENERIC generic_module_shutdown(); #endif if (_emotion_modules) { eina_module_list_free(_emotion_modules); eina_array_free(_emotion_modules); _emotion_modules = NULL; } EINA_LIST_FREE(_emotion_engine_registry, re) { WRN("Engine was not unregistered: %p", re->engine); _emotion_engine_registry_entry_free(re); }
EAPI Eina_Bool eina_module_load(Eina_Module *m) { #ifdef HAVE_DLOPEN void *dl_handle; Eina_Module_Init *initcall; EINA_SAFETY_ON_NULL_RETURN_VAL(m, EINA_FALSE); DBG("m=%p, handle=%p, file=%s, refs=%d", m, m->handle, m->file, m->ref); if (m->handle) goto loaded; dl_handle = dlopen(m->file, RTLD_NOW); if (!dl_handle) { WRN("could not dlopen(\"%s\", RTLD_NOW): %s", m->file, dlerror()); eina_error_set(EINA_ERROR_WRONG_MODULE); return EINA_FALSE; } initcall = dlsym(dl_handle, EINA_MODULE_SYMBOL_INIT); if ((!initcall) || (!(*initcall))) goto ok; if ((*initcall)() == EINA_TRUE) goto ok; WRN("could not find eina's entry symbol %s inside module %s", EINA_MODULE_SYMBOL_INIT, m->file); eina_error_set(EINA_ERROR_MODULE_INIT_FAILED); dlclose(dl_handle); return EINA_FALSE; ok: DBG("successfully loaded %s", m->file); m->handle = dl_handle; loaded: m->ref++; DBG("ref %d", m->ref); eina_error_set(0); return EINA_TRUE; #else (void) m; return EINA_FALSE; #endif }
Eina_Bool set_clip_content(char **content, char* text, int mode) { Eina_Bool ret = EINA_TRUE; char *temp, *trim; /* Sanity check */ if (!text) { WRN("ERROR: Text is NULL\n"); text = ""; } if (content) { switch (mode) { case 0: /* Don't trim */ temp = strdup(text); break; case 1: /* Trim new lines */ trim = strip_whitespace(text, TRIM_NEWLINES); temp = strdup(trim); break; case 2: /* Trim all white Space * since white space includes new lines * drop thru here */ case 3: /* Trim white space and new lines */ trim = strip_whitespace(text, TRIM_SPACES); temp = strdup(trim); break; default : /* Error Don't trim */ WRN("ERROR: Invalid strip_mode %d\n", mode); temp = strdup(text); break; } if (!temp) { /* This is bad, leave it to calling function */ CRI("ERROR: Memory allocation Failed!!"); ret = EINA_FALSE; } *content = temp; } else ERR("Error: Clip content pointer is Null!!"); return ret; }
/*============================================================================* * Global * *============================================================================*/ Efl_Egueb_IO_Request * efl_egueb_io_request_new(Egueb_Dom_String *location, const Efl_Egueb_IO_Request_Descriptor *descriptor, void *data) { Efl_Egueb_IO_Request *thiz; const char *filename; if (!location) return NULL; filename = egueb_dom_string_chars_get(location); thiz = calloc(1, sizeof(Efl_Egueb_IO_Request)); thiz->descriptor = descriptor; thiz->data = data; if (!strncmp(filename, "file://", 7)) { Enesim_Stream *s; s = enesim_stream_file_new(filename + 7, "r"); if (s) { DBG("Data '%s' loaded correctly", filename); thiz->in_event = EINA_TRUE; if (thiz->descriptor->completion) thiz->descriptor->completion(thiz, s); enesim_stream_unref(s); thiz->in_event = EINA_FALSE; } } else if (!strncmp(filename, "http://", 7)) { thiz->conn = ecore_con_url_new(filename); thiz->binbuf = eina_binbuf_new(); ecore_event_handler_add(ECORE_CON_EVENT_URL_COMPLETE, _efl_egueb_io_request_url_completion_cb, thiz); ecore_event_handler_add(ECORE_CON_EVENT_URL_DATA, _efl_egueb_io_request_url_data_cb, thiz); ecore_con_url_get(thiz->conn); } else { WRN("Unsupported schema '%s'", filename); free(thiz); thiz = NULL; goto done; } if (thiz->destroy) { efl_egueb_io_request_free(thiz); return NULL; } done: return thiz; }
/* * Client events. */ int v4c_cli_run(struct event_base *base, domid_t domid, unsigned long port) { struct sockaddr_v4v sa = { .sa_family = AF_V4V, .sa_addr = { .domain = domid, .port = port }, }; int rc; assert(!server); assert(!input); server = bufferevent_socket_new(base, -1, BEV_OPT_CLOSE_ON_FREE); if (!server) { rc = EVUTIL_SOCKET_ERROR(); WRN("Failed to open socket (%s).", evutil_socket_error_to_string(rc)); return -rc; } rc = bufferevent_socket_connect(server, (struct sockaddr*)&sa, sizeof (sa)); if (rc) { rc = EVUTIL_SOCKET_ERROR(); WRN("Failed to connect socket (%s).", evutil_socket_error_to_string(rc)); bufferevent_free(server); return -rc; } bufferevent_setcb(server, v4c_cli_recv, NULL, v4c_cli_event, NULL); bufferevent_enable(server, EV_READ | EV_WRITE); input = v4c_stdin_ev_new(base, server); if (!input) { bufferevent_free(server); } event_base_dispatch(base); event_free(input); /* v4c_cli_event will call bufferevent_free(server). */ return 0; }
void evas_fb_outbuf_fb_free(Outbuf *buf) { /* FIXME: impliment */ WRN("destroying fb info.. not implemented!!!! WARNING. LEAK!"); if (buf->priv.back_buf) evas_cache_image_drop(&buf->priv.back_buf->cache_entry); free(buf); }
int Seq_Read_Image_To_Buffer ( SeqReader *h, int index, void *buffer ) { size_t offset = 1024 + index * h->truesize; SEQ_ASSERT( fseek( h->fp, offset, SEEK_SET) ); SEQ_ASSERT( fread( buffer , 1, h->sizebytes, h->fp ) != h->sizebytes ); return 1; Error: WRN("Seq reader: Couldn't read image at index %d\n",index); return 0; }
static Eina_Bool user_setattr_check(Zentific_Ctx *ctx, const char *attribute, const char *value){ if (!zshare_strcmp(attribute, "name")){ if (eina_strlen_bounded(value, MAX_USERNAME_LENGTH + 1) > MAX_USERNAME_LENGTH){ ctx->error = AZY_ERR(INVALID_PARAMETER); CTX_RETURN; } if (!ctx->count){ db->isUserName(db, ctx, value); CTX_CB_ADD(user_cb_name); CTX_RETURN; } } else if (!zshare_strcmp(attribute, "email")){ char *at, *dot; //FIXME: add email validation function or is this lazy attempt enough? if (!(at = strrchr(value, '@')) || !(dot = strrchr(value, '.')) || (dot - at < 0)){ ctx->error = AZY_ERR(INVALID_PARAMETER); CTX_RETURN; } } else if (!zshare_strcmp(attribute, "active")){ if (zshare_strcmp(value, "0") || zshare_strcmp(value, "1")){ ctx->error = AZY_ERR(INVALID_PARAMETER); CTX_RETURN; } } else if (!zshare_strcmp(attribute, "type")){ int t; if (value[1]){ ctx->error = AZY_ERR(INVALID_PARAMETER); CTX_RETURN; } errno = 0; t = strtol(value, NULL, 10); if (errno){ WRN("Failed to convert '%s' to int because of error: %s", value, strerror(errno)); ctx->error = AZY_ERR(INVALID_PARAMETER); CTX_RETURN; } if ((t < USER_TYPE_SUPER_USER) || (t > USER_TYPE_NODE)){ ctx->error = AZY_ERR(INVALID_PARAMETER); CTX_RETURN; } } else if (!zshare_strcmp(attribute, "language")){ if (ctx->count < 2){ db->getLanguageCode(db, ctx, strtol(value, NULL, 10)); CTX_CB_ADD(user_cb_lang); CTX_RETURN; } } else { ctx->error = AZY_ERR(INVALID_PARAMETER); CTX_RETURN; } CTX_RETURN; }
static int _keytable_property_list_get(Ecore_X_Window win, Ecore_X_Atom atom, unsigned int **plst) { unsigned char *prop_ret; Atom type_ret; unsigned long bytes_after, num_ret; int format_ret; unsigned int i, *val; int num; *plst = NULL; prop_ret = NULL; if (XGetWindowProperty(_ecore_x_disp, win, atom, 0, 0x7fffffff, False, XA_CARDINAL, &type_ret, &format_ret, &num_ret, &bytes_after, &prop_ret) != Success) { WRN("XGetWindowProperty failed"); return -1; } else if ((num_ret == 0) || (!prop_ret)) num = 0; else { val = malloc(num_ret * sizeof(unsigned int)); if (!val) { if (prop_ret) XFree(prop_ret); WRN("Memory alloc failed"); return -1; } for (i = 0; i < num_ret; i++) val[i] = ((unsigned long *)prop_ret)[i]; num = num_ret; *plst = val; } if (_ecore_xlib_sync) ecore_x_sync(); if (prop_ret) XFree(prop_ret); return num; }
bool D3DVertexBufferCache::InitBuffer(D3DDevice *d3d, BYTE *data, int size, CacheEntryInfo &info) { assert(d3d != NULL); assert(data != NULL); assert(size > 0); int best = FindBestEntry(size); CacheEntry *ce = NULL; // Reallocate if (best >= 0 && _cache[best].size < size) { DeleteEntry(best); best = -1; } // New if (best < 0) { CacheEntry new_entry; if (!CreateEntry(d3d, new_entry, size)) { WRN("Failed to create new vbcache entry"); return false; } _cache.Add(new_entry); info.id = _cache.Length() - 1; ce = _cache.Last(); } else { info.id = best; ce = &_cache[best]; } assert(ce != NULL); if (!InsertData(*ce, data, size)) { WRN("Failed to insert vbcache data"); return false; } return true; }
static Eina_Bool _ecore_x_window_keytable_possible_global_exclusiveness_get(int keycode) { int ret = 0; Ecore_X_Window_Key_Table keytable; keytable.win = ecore_x_window_root_first_get(); keytable.key_list = NULL; keytable.key_cnt = 0; if(_atom_grab_excl_win == None ) _atom_grab_excl_win = XInternAtom(_ecore_x_disp, STR_ATOM_GRAB_EXCL_WIN, False); ret = _keytable_property_list_get(keytable.win, _atom_grab_excl_win, (unsigned int **)&(keytable.key_list)); if (ret < 0) { return EINA_FALSE; } keytable.key_cnt = ret; if (keytable.key_cnt == 0) { WRN("There is no keygrab entry in the table"); return EINA_TRUE; } //check keycode exists in the global exclusiveness keytable ret = _ecore_x_window_keytable_key_search(&keytable, keycode); if (ret != -1) { WRN("Can't search keygrab entry in the table"); _keytable_free(&keytable); return EINA_FALSE; } _keytable_free(&keytable); return EINA_TRUE; }
EAPI void ecore_print_warning(const char *function, const char *sparam) { WRN("***** Developer Warning ***** :\n" "\tThis program is calling:\n\n" "\t%s();\n\n" "\tWith the parameter:\n\n" "\t%s\n\n" "\tbeing NULL. Please fix your program.", function, sparam); if (getenv("ECORE_ERROR_ABORT")) abort(); }
EAPI Eina_Bool eupnp_service_parse_buffer(const char *buffer, int buffer_len, Eupnp_Service_Proxy *s) { Eina_Bool ret = EINA_FALSE; if ((!buffer) || (!buffer_len) || (!s)) return ret; Eupnp_Service_Parser *parser; if (!s->xml_parser) { /* Creates the parser, which parses the first chunk */ DBG("Creating service parser."); s->xml_parser = eupnp_service_parser_new(buffer, buffer_len, s); if (!s->xml_parser) { ERR("Failed to parse first chunk"); goto parse_ret; } ret = EINA_TRUE; goto parse_ret; } parser = s->xml_parser; if (!parser->ctx) { // first_chunk_len < 4 case eina_error_set(EUPNP_ERROR_SERVICE_PARSER_INSUFFICIENT_FEED); return EINA_FALSE; } // Progressive feeds if (parser->state.state == FINISH) { WRN("Already finished parsing"); ret = EINA_TRUE; goto parse_ret; } DBG("Parsing XML (%d) at %p", buffer_len, buffer); if (!xmlParseChunk(parser->ctx, buffer, buffer_len, 0)) { ret = EINA_TRUE; goto parse_ret; } parse_ret: eupnp_service_parse_check_finished(s); return ret; }
/** * Get the contents of a defined structure property and load it into the passed * C struct * @param key The name of the structure property to look up. * @param data The struct to write into. * @return @c ECORE_CONFIG_ERR_SUCC if the structure is written successfully. * @ingroup Ecore_Config_Struct_Group */ EAPI int ecore_config_struct_get(const char *key, void *data) { Ecore_Config_Prop *e, *f; Eina_List *l; unsigned char *ptr; long argb; e = ecore_config_get(key); if (!e) return ECORE_CONFIG_ERR_NODATA; l = e->data; ptr = data; while (l) { f = (Ecore_Config_Prop *) l->data; switch (f->type) { case ECORE_CONFIG_INT: *((int *) ptr) = _ecore_config_int_get(f); ptr += sizeof(int); break; case ECORE_CONFIG_BLN: *((int *) ptr) = _ecore_config_boolean_get(f); ptr += sizeof(int); break; case ECORE_CONFIG_FLT: *((float *) ptr) = _ecore_config_float_get(f); ptr += sizeof(float); break; case ECORE_CONFIG_STR: case ECORE_CONFIG_THM: *((char **) ptr) = _ecore_config_string_get(f); ptr += sizeof(char *); break; case ECORE_CONFIG_RGB: argb = _ecore_config_argbint_get(f); *((int *) ptr) = (argb >> 24) & 0xff; ptr += sizeof(int); *((int *) ptr) = (argb >> 16) & 0xff; ptr += sizeof(int); *((int *) ptr) = (argb >> 8) & 0xff; ptr += sizeof(int); *((int *) ptr) = argb & 0xff; ptr += sizeof(int); break; default: WRN("ARGH - STRUCT coding not implemented yet"); } l = eina_list_next(l); } return ECORE_CONFIG_ERR_SUCC; }