static int _evas_gl_common_shader_binary_init(Evas_GL_Shared *shared) { Eet_File *ef = NULL; char bin_dir_path[PATH_MAX]; char bin_file_path[PATH_MAX]; if (!shared || !shared->info.bin_program) return 1; if (shared->shaders_cache) return 1; if (!evas_gl_common_file_cache_dir_check(bin_dir_path, sizeof(bin_dir_path))) return 0; if (!evas_gl_common_file_cache_file_check(bin_dir_path, SHADER_EET_CACHENAME, bin_file_path, sizeof(bin_dir_path))) return 0; if (!eet_init()) return 0; ef = eet_open(bin_file_path, EET_FILE_MODE_READ); if (!_evas_gl_common_shader_binary_checksum_check(shared, ef)) goto error; shared->shaders_cache = ef; return 1; error: if (ef) eet_close(ef); eet_shutdown(); return 0; }
void evas_model_load_file_eet(Evas_Canvas3D_Mesh *mesh, Eina_File *file) { Eet_File *ef; Evas_Canvas3D_File_Eet* eet_file; Eet_Data_Descriptor *_file_descriptor; eet_init(); _file_descriptor = _evas_canvas3d_eet_file_get(); ef = eet_mmap(file); eet_file = eet_data_read(ef, _file_descriptor, EVAS_CANVAS3D_FILE_CACHE_FILE_ENTRY); eet_close(ef); if (!eet_file || !eet_file->mesh || !eet_file->header) { ERR("Failed to read model file"); goto on_error; } _set_geometry_to_mesh_from_eet_file(mesh, eet_file->mesh); _set_material_to_mesh_from_eet_file(mesh, eet_file->mesh); on_error: _evas_canvas3d_eet_file_free(eet_file); eet_shutdown(); }
/* externally accessible functions */ int main(int argc, char **argv) { int i; for (i = 1; i < argc; i++) { if ((!strcmp(argv[i], "-h")) || (!strcmp(argv[i], "-help")) || (!strcmp(argv[i], "--help"))) { printf( "This is an internal tool for Enlightenment.\n" "do not use it.\n" ); exit(0); } else if (!strncmp(argv[i], "--nice=", 7)) { const char *val; int ret = 0; val = argv[i] + 7; if (*val) ret = nice(atoi(val)); } } ecore_init(); ecore_app_args_set(argc, (const char **)argv); eet_init(); evas_init(); ecore_evas_init(); edje_init(); ecore_file_init(); ecore_ipc_init(); e_user_dir_concat_static(_thumbdir, "fileman/thumbnails"); ecore_file_mkpath(_thumbdir); if (_e_ipc_init()) ecore_main_loop_begin(); if (_e_ipc_server) { ecore_ipc_server_del(_e_ipc_server); _e_ipc_server = NULL; } ecore_ipc_shutdown(); ecore_file_shutdown(); ecore_evas_shutdown(); edje_shutdown(); evas_shutdown(); eet_shutdown(); ecore_shutdown(); return 0; }
Config::Config() { //Init eet for States file eet_init(); initEetDescriptors(); //read config hash table cache_states = eina_hash_string_superfast_new(_eina_hash_free_cb); loadStateCache(); saveCacheTimer = new EcoreTimer(60.0, [=]() { saveStateCache(); }); }
EAPI void evas_common_image_init(void) { if (!eci) eci = evas_cache_image_init(&_evas_common_image_func); reference++; //// ERR("REF++=%i", reference); #ifdef BUILD_LOADER_EET eet_init(); #endif evas_common_scalecache_init(); }
int main(int argc, char *argv[]) { My_Conf_Type *my_conf; int ret = 0; if (argc != 3) { fprintf(stderr, "Usage:\n\t%s <input> <output>\n\n", argv[0]); return -1; } eina_init(); eet_init(); _my_conf_descriptor_init(); my_conf = _my_conf_load(argv[1]); if (!my_conf) { printf("creating new configuration.\n"); my_conf = _my_conf_new(); if (!my_conf) { ret = -2; goto end; } } printf("My_Conf_Type:\n" "\tversion: %#x\n" "\tname...: '%s'\n" "\tid.....: %d\n" "\tenabled: %hhu\n", my_conf->version, my_conf->name ? my_conf->name : "", my_conf->id, my_conf->enabled); if (!_my_conf_save(my_conf, argv[2])) ret = -3; _my_conf_free(my_conf); end: _my_conf_descriptor_shutdown(); eet_shutdown(); eina_shutdown(); return ret; } /* main */
static int _evas_gl_common_shader_binary_save(Evas_GL_Shared *shared) { /* check eet */ Eet_File *et = NULL; //check eet file int tmpfd; int res = 0; char bin_dir_path[PATH_MAX]; char bin_file_path[PATH_MAX]; char tmp_file[PATH_MAX]; unsigned int i; if (!_evas_gl_shader_dir_check(bin_dir_path, sizeof(bin_dir_path))) { res = _evas_gl_shader_file_mkpath(bin_dir_path); if (!res) return 0; /* we can't make directory */ } _evas_gl_shader_file_check(bin_dir_path, bin_file_path, sizeof(bin_dir_path)); /* use mkstemp for writing */ snprintf(tmp_file, sizeof(tmp_file), "%s.XXXXXX", bin_file_path); tmpfd = mkstemp(tmp_file); if (tmpfd < 0) goto error; close(tmpfd); /* use eet */ if (!eet_init()) goto error; et = eet_open(tmp_file, EET_FILE_MODE_WRITE); if (!et) goto error; for (i = 0; i < sizeof (_shaders_source) / sizeof (_shaders_source[0]); ++i) if (!_evas_gl_common_shader_program_binary_save(&(shared->shader[_shaders_source[i].id]), _shaders_source[i].name, et)) goto error; if (eet_close(et) != EET_ERROR_NONE) goto error; if (rename(tmp_file,bin_file_path) < 0) goto error; eet_shutdown(); return 1; error: if (et) eet_close(et); if (_evas_gl_shader_file_exists(tmp_file)) unlink(tmp_file); eet_shutdown(); return 0; }
Eina_Bool eet_loader_init(void) { if (!elixir_loader_register(&eet_loader)) return EINA_FALSE; eina_init(); eet_init(); stack = eina_array_new(4); cache = eina_hash_string_superfast_new(EINA_FREE_CB(_elixir_eet_filename_free)); return EINA_TRUE; }
int main(int argc, char **argv) { em = E_MUSIC_NEW(Em_Smart_Data); /* Init Local */ char *curlocale=setlocale(LC_ALL, ""); curlocale=curlocale?curlocale:setlocale(LC_ALL, "C"); // mylocale = curlocale?strdup(curlocale):NULL; bindtextdomain("e_music", LOCALEDIR); textdomain("e_music"); /* have to init it */ if (!eina_init()) { fprintf(stderr, "ERROR: failed to init eina."); exit(-1); } _log_dom = eina_log_domain_register("E-music", EINA_COLOR_CYAN); if (_log_dom < 0) { EINA_LOG_ERR("could not register E-music log domain."); _log_dom = EINA_LOG_DOMAIN_GLOBAL; } eina_log_domain_level_set("E-music", 3); eet_init(); emusic_config_init(NULL); emusic_config_load_theme(); eina_log_domain_level_set("E-music", emusic_config->log_level); if (!emusic_playback_init(em)) { ERR("could not init playback.\n"); return 0; } elm_init(argc, argv); elm_main(); /* Main Loop*/ elm_run(); emusic_config_shutdown(); eina_log_domain_unregister(_log_dom); elm_shutdown(); return 0; }
Ecore_Config_DB_File * _ecore_config_db_open_write(const char *file) { Eet_File *ef; Ecore_Config_DB_File *db; eet_init(); db = malloc(sizeof(Ecore_Config_DB_File)); if (!db) return NULL; ef = eet_open((char*)file, EET_FILE_MODE_WRITE); if (!ef) { free(db); return NULL; } db->ef = ef; return db; }
/* externally accessible functions */ int main(int argc, char **argv) { if (argc > 1) { printf( "This is an internal tool for Enlightenment.\n" "do not use it.\n" ); exit(0); } eina_init(); eet_init(); ecore_init(); ecore_app_args_set(argc, (const char **)argv); ecore_file_init(); ecore_ipc_init(); _e_storage_volume_edd_init(); if (!_e_fm_ipc_init()) return -1; efm_log_dom = eina_log_domain_register("efm", EINA_COLOR_GREEN); _e_fm_init(); ecore_event_handler_add(ECORE_EXE_EVENT_DATA, _e_fm_ipc_slave_data_cb, NULL); ecore_event_handler_add(ECORE_EXE_EVENT_ERROR, _e_fm_ipc_slave_error_cb, NULL); ecore_event_handler_add(ECORE_EXE_EVENT_DEL, _e_fm_ipc_slave_del_cb, NULL); ecore_main_loop_begin(); if (_e_fm_ipc_server) { ecore_ipc_server_del(_e_fm_ipc_server); _e_fm_ipc_server = NULL; } _e_fm_shutdown(); _e_storage_volume_edd_shutdown(); ecore_ipc_shutdown(); ecore_file_shutdown(); ecore_shutdown(); eina_shutdown(); return 0; }
void histogram_cache_descriptor_init(void) { eina_init(); eet_init(); Eet_Data_Descriptor_Class eddc; EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, histogram_t); _histogram_descriptor = eet_data_descriptor_file_new(&eddc); EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, histogram_cache_t); _histogram_cache_descriptor = eet_data_descriptor_file_new(&eddc); EET_DATA_DESCRIPTOR_ADD_BASIC(_histogram_descriptor, histogram_t, "file", file, EET_T_STRING); EET_DATA_DESCRIPTOR_ADD_BASIC_ARRAY(_histogram_descriptor , histogram_t, "results", results, EET_T_FLOAT); EET_DATA_DESCRIPTOR_ADD_HASH(_histogram_cache_descriptor , histogram_cache_t, "map_histo" , map_histo, _histogram_descriptor); }
int main(void) { Eet_File *ef; char *ret; int size; char *entries[] = { "Entry 1", "Big text string here compared to others", "Eet is cool" }; eet_init(); // blindly open an file for output and write strings with their NUL char ef = eet_open("test.eet", EET_FILE_MODE_WRITE); eet_write(ef, "Entry 1", entries[0], strlen(entries[0]) + 1, 0); eet_write(ef, "Entry 2", entries[1], strlen(entries[1]) + 1, 1); eet_write(ef, "Entry 3", entries[2], strlen(entries[2]) + 1, 0); eet_close(ef); // open the file again and blindly get the entries we wrote ef = eet_open("test.eet", EET_FILE_MODE_READ); ret = eet_read(ef, "Entry 1", &size); printf("%s\n", ret); free(ret); ret = eet_read(ef, "Entry 2", &size); printf("%s\n", ret); free(ret); ret = eet_read(ef, "Entry 3", &size); printf("%s\n", ret); free(ret); eet_close(ef); eet_shutdown(); }
int main(int argc, char **argv) { eet_init(); enhance_init(); etk_init(argc, argv); en = enhance_new(); /* Load the main window */ enhance_file_load(en, "window", "emphasis_cover_editor.glade"); tree = enhance_var_get(en, "tree"); cover = enhance_var_get(en, "cover"); filechooser = enhance_var_get(en, "filechooserwidget"); filechooser_dialog = enhance_var_get(en, "filechooser_dialog"); add_dialog = enhance_var_get(en, "add_dialog"); entry_add_artist = enhance_var_get(en, "entry_add_artist"); entry_add_album = enhance_var_get(en, "entry_add_album"); fill_tree_with_db(ETK_TREE(tree)); etk_main(); return 0; }
static int _evas_gl_common_shader_binary_init(Evas_GL_Shared *shared) { /* check eet */ Eet_File *et = NULL; char bin_dir_path[PATH_MAX]; char bin_file_path[PATH_MAX]; unsigned int i; if (!_evas_gl_shader_dir_check(bin_dir_path, sizeof(bin_dir_path))) return 0; if (!_evas_gl_shader_file_check(bin_dir_path, bin_file_path, sizeof(bin_dir_path))) return 0; /* use eet */ if (!eet_init()) return 0; et = eet_open(bin_file_path, EET_FILE_MODE_READ); if (!et) goto error; for (i = 0; i < sizeof (_shaders_source) / sizeof (_shaders_source[0]); ++i) if (!_evas_gl_common_shader_program_binary_init(&(shared->shader[_shaders_source[i].id]), _shaders_source[i].name, et)) goto error; if (et) eet_close(et); eet_shutdown(); return 1; error: if (et) eet_close(et); eet_shutdown(); return 0; }
int main(int argc, char **argv) { Eet_Data_Descriptor *sedd; Eet_Data_Descriptor *dedd; Simple s = { .count = 5, .value = 98, .flags = 0x5 }; Flottant f = { .x = 3.14159264, .y = 42.0 }; Simple *rs; Flottant *rf; eina_init(); eet_init(); sedd = simple_edd(); dedd = flottant_edd(); config_save(sedd, "config", "simple", &s); config_save(dedd, "config", "flottant", &f); rs = config_load(sedd, "config", "simple"); rf = config_load(dedd, "config", "flottant"); if (!rs) fprintf(stderr, "Simple structure is empty !\n"); else fprintf(stderr, "Simpe = { .count = %i, .value = %i, .flags = %x }\n", rs->count, rs->value, rs->flags); if (!rf) fprintf(stderr, "Flottant is empty\n"); else fprintf(stderr, "Flottant = { .x = %f, .y = %f }\n", rf->x, rf->y); eet_data_descriptor_free(sedd); eet_data_descriptor_free(dedd); eet_shutdown(); return 0; }
StorageData *init_storage(AppData *ad) { CALLED(); StorageData *sd = CALLOC(1, sizeof(StorageData)); eet_init(); ecore_file_init(); sd->ef = eet_open(STORAGE_FILEPATH, EET_FILE_MODE_READ_WRITE); /* if (sd->ef) { int read_size; indexType *read_data; read_data = eet_read(sd->ef, STORAGE_KEY_INDEX, &read_size); int storage_size = sizeof(indexType) * STORAGE_ITEM_CNT; int copy_size = storage_size < read_size ? storage_size : read_size; if (read_data) { indexType *temp = MALLOC(read_size); if (!temp) return sd; memcpy(temp, read_data, read_size); int i; int copy_cnt = copy_size/sizeof(indexType); for (i = 0; i < copy_cnt; i++) { int maxIndex = getMaxIndex(temp, copy_cnt); if (temp[maxIndex] == STORAGE_INDEX_ITEM_NONE) break; sd->itemTable[i] = storage_item_load(sd, maxIndex); if (sd->itemTable[i]) sd->indexTable[i] = temp[maxIndex]; temp[maxIndex] = STORAGE_INDEX_ITEM_NONE; DMSG("load storage item index %d\n", i); } for (i = copy_cnt - 1; i >= 0; i--) { if (sd->itemTable[i]) item_add_by_CNP_ITEM(ad, sd->itemTable[i]); } } else { DMSG("load storage index failed\n"); } } else DMSG("storage ef is NULLd\n"); */ dump_items(sd); ad->storage_item_add = storage_item_write; ad->storage_item_del = storage_item_delete; // ad->storage_item_load = storage_item_load; return sd; }
/** * @return Returns > 0 if the initialization was successful, 0 otherwise * @brief Initializes the Efreet system */ EAPI int efreet_init(void) { if (++_efreet_init_count != 1) return _efreet_init_count; if (!eina_init()) return --_efreet_init_count; if (!eet_init()) goto shutdown_eina; if (!ecore_init()) goto shutdown_eet; if (!ecore_file_init()) goto shutdown_ecore; _efreet_log_domain_global = eina_log_domain_register("efreet", EFREET_DEFAULT_LOG_COLOR); if (_efreet_log_domain_global < 0) { EINA_LOG_ERR("Efreet could create a general log domain."); goto shutdown_ecore_file; } if (!efreet_base_init()) goto unregister_log_domain; if (!efreet_cache_init()) goto shutdown_efreet_base; if (!efreet_xml_init()) goto shutdown_efreet_cache; if (!efreet_icon_init()) goto shutdown_efreet_xml; if (!efreet_ini_init()) goto shutdown_efreet_icon; if (!efreet_desktop_init()) goto shutdown_efreet_ini; if (!efreet_menu_init()) goto shutdown_efreet_desktop; if (!efreet_util_init()) goto shutdown_efreet_menu; return _efreet_init_count; shutdown_efreet_menu: efreet_menu_shutdown(); shutdown_efreet_desktop: efreet_desktop_shutdown(); shutdown_efreet_ini: efreet_ini_shutdown(); shutdown_efreet_icon: efreet_icon_shutdown(); shutdown_efreet_xml: efreet_xml_shutdown(); shutdown_efreet_cache: efreet_cache_shutdown(); shutdown_efreet_base: efreet_base_shutdown(); unregister_log_domain: eina_log_domain_unregister(_efreet_log_domain_global); shutdown_ecore_file: ecore_file_shutdown(); shutdown_ecore: ecore_shutdown(); shutdown_eet: eet_shutdown(); shutdown_eina: eina_shutdown(); return --_efreet_init_count; }
int main(int argc, char **argv) { /* TODO: * - Add file monitor on files, so that we catch changes on files * during whilst this program runs. * - Maybe linger for a while to reduce number of cache re-creates. */ Efreet_Cache_Hash hash; Efreet_Cache_Version version; Eina_List *dirs = NULL; Eina_List *systemdirs = NULL; Eina_List *extra_dirs = NULL; Eina_List *l = NULL; Eina_Inarray *stack = NULL; int priority = 0; char *dir = NULL; char *path; int lockfd = -1, tmpfd; int changed = 0; int i; char file[PATH_MAX] = { '\0' }; char util_file[PATH_MAX] = { '\0' }; mode_t um; if (!eina_init()) goto eina_error; _efreet_desktop_cache_log_dom = eina_log_domain_register("efreet_desktop_cache", EFREET_DEFAULT_LOG_COLOR); if (_efreet_desktop_cache_log_dom < 0) { EINA_LOG_ERR("Efreet: Could not create a log domain for efreet_desktop_cache."); return -1; } for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-v")) eina_log_domain_level_set("efreet_desktop_cache", EINA_LOG_LEVEL_DBG); else if ((!strcmp(argv[i], "-h")) || (!strcmp(argv[i], "-help")) || (!strcmp(argv[i], "--h")) || (!strcmp(argv[i], "--help"))) { printf("Options:\n"); printf(" -v Verbose mode\n"); printf(" -d dir1 dir2 Extra dirs\n"); exit(0); } else if (!strcmp(argv[i], "-d")) { while ((i < (argc - 1)) && (argv[(i + 1)][0] != '-')) extra_dirs = eina_list_append(extra_dirs, argv[++i]); } } extra_dirs = eina_list_sort(extra_dirs, -1, EINA_COMPARE_CB(strcmp)); #ifdef HAVE_SYS_RESOURCE_H setpriority(PRIO_PROCESS, 0, 19); #elif _WIN32 SetPriorityClass(GetCurrentProcess(), IDLE_PRIORITY_CLASS); #endif /* init external subsystems */ if (!eet_init()) goto eet_error; if (!ecore_init()) goto ecore_error; efreet_cache_update = 0; /* finish efreet init */ if (!efreet_init()) goto efreet_error; /* create homedir */ snprintf(file, sizeof(file), "%s/efreet", efreet_cache_home_get()); if (!ecore_file_exists(file)) { if (!ecore_file_mkpath(file)) goto efreet_error; efreet_setowner(file); } /* lock process, so that we only run one copy of this program */ lockfd = cache_lock_file(); if (lockfd == -1) goto efreet_error; edd = efreet_desktop_edd(); if (!edd) goto edd_error; /* read user dirs from old cache */ ef = eet_open(efreet_desktop_util_cache_file(), EET_FILE_MODE_READ); if (ef) { old_file_ids = eet_data_read(ef, efreet_hash_string_edd(), "file_id"); eet_close(ef); } /* create cache */ snprintf(file, sizeof(file), "%s.XXXXXX", efreet_desktop_cache_file()); /* set secure umask for temporary files */ um = umask(0077); tmpfd = mkstemp(file); umask(um); if (tmpfd < 0) goto error; close(tmpfd); ef = eet_open(file, EET_FILE_MODE_READ_WRITE); if (!ef) goto error; snprintf(util_file, sizeof(util_file), "%s.XXXXXX", efreet_desktop_util_cache_file()); /* set secure umask for temporary files */ um = umask(0077); tmpfd = mkstemp(util_file); umask(um); if (tmpfd < 0) goto error; close(tmpfd); util_ef = eet_open(util_file, EET_FILE_MODE_READ_WRITE); if (!util_ef) goto error; /* write cache version */ version.major = EFREET_DESKTOP_UTILS_CACHE_MAJOR; version.minor = EFREET_DESKTOP_UTILS_CACHE_MINOR; eet_data_write(util_ef, efreet_version_edd(), EFREET_CACHE_VERSION, &version, 1); version.major = EFREET_DESKTOP_CACHE_MAJOR; version.minor = EFREET_DESKTOP_CACHE_MINOR; eet_data_write(ef, efreet_version_edd(), EFREET_CACHE_VERSION, &version, 1); desktops = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_desktop_free)); file_ids = eina_hash_string_superfast_new(NULL); paths = eina_hash_string_superfast_new(NULL); mime_types = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free)); categories = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free)); startup_wm_class = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free)); name = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free)); generic_name = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free)); comment = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free)); exec = eina_hash_string_superfast_new(EINA_FREE_CB(efreet_cache_array_string_free)); dirs = efreet_default_dirs_get(efreet_data_home_get(), efreet_data_dirs_get(), "applications"); if (!dirs) goto error; stack = eina_inarray_new(sizeof(struct stat), 16); if (!stack) goto error; EINA_LIST_FREE(dirs, path) { char file_id[PATH_MAX] = { '\0' }; eina_inarray_flush(stack); if (!cache_scan(stack, path, file_id, priority++, 1, &changed)) goto error; systemdirs = eina_list_append(systemdirs, path); }
END_TEST START_TEST(eet_test_file_fp) { char *file; Eet_Data_Descriptor_Class eddc; Eet_Data_Descriptor *edd_5FP; Eet_Data_Descriptor *edd_5DBL; Eet_File *ef; Eet_5FP origin; Eet_5DBL *convert; Eet_5FP *build; int tmpfd; file = strdup("/tmp/eet_suite_testXXXXXX"); eet_init(); EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Eet_5FP); edd_5FP = eet_data_descriptor_file_new(&eddc); EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "fp32", fp32, EET_T_F32P32); EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "fp16", fp16, EET_T_F16P16); EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "fp8", fp8, EET_T_F8P24); EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "f1", f1, EET_T_F32P32); EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5FP, Eet_5FP, "f0", f0, EET_T_F32P32); eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc), "Eet_5FP", sizeof (Eet_5DBL)); edd_5DBL = eet_data_descriptor_file_new(&eddc); EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "fp32", fp32, EET_T_DOUBLE); EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "fp16", fp16, EET_T_DOUBLE); EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "fp8", fp8, EET_T_FLOAT); EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "f1", f1, EET_T_DOUBLE); EET_DATA_DESCRIPTOR_ADD_BASIC(edd_5DBL, Eet_5DBL, "f0", f0, EET_T_DOUBLE); origin.fp32 = eina_f32p32_double_from(1.125); origin.fp16 = eina_f16p16_int_from(2000); origin.fp8 = eina_f8p24_int_from(125); origin.f1 = eina_f32p32_int_from(1); origin.f0 = 0; fail_if(-1 == (tmpfd = mkstemp(file))); fail_if(!!close(tmpfd)); ef = eet_open(file, EET_FILE_MODE_READ_WRITE); fail_if(!ef); fail_if(!eet_data_write(ef, edd_5FP, EET_TEST_FILE_KEY1, &origin, 1)); build = eet_data_read(ef, edd_5FP, EET_TEST_FILE_KEY1); fail_if(!build); convert = eet_data_read(ef, edd_5DBL, EET_TEST_FILE_KEY1); fail_if(!convert); fail_if(build->fp32 != eina_f32p32_double_from(1.125)); fail_if(build->fp16 != eina_f16p16_int_from(2000)); fail_if(build->fp8 != eina_f8p24_int_from(125)); fail_if(build->f1 != eina_f32p32_int_from(1)); fail_if(build->f0 != 0); fail_if(convert->fp32 != 1.125); fail_if(convert->fp16 != 2000); fail_if(convert->fp8 != 125); fail_if(convert->f1 != 1); fail_if(convert->f0 != 0); eet_close(ef); fail_if(unlink(file) != 0); eet_shutdown(); }
END_TEST START_TEST(eet_test_file_data_dump) { Eet_Data_Descriptor *edd; Eet_Test_Ex_Type *result; Eet_Data_Descriptor_Class eddc; Eet_Test_Ex_Type etbt; Eet_File *ef; char *string1; char *file; int test; int tmpfd; file = strdup("/tmp/eet_suite_testXXXXXX"); eet_init(); eet_test_ex_set(&etbt, 0); etbt.list = eina_list_prepend(etbt.list, eet_test_ex_set(NULL, 1)); etbt.list = eina_list_prepend(etbt.list, eet_test_ex_set(NULL, 1)); etbt.hash = eina_hash_string_superfast_new(NULL); eina_hash_add(etbt.hash, EET_TEST_KEY1, eet_test_ex_set(NULL, 2)); eina_hash_add(etbt.hash, EET_TEST_KEY2, eet_test_ex_set(NULL, 2)); etbt.ilist = eina_list_prepend(etbt.ilist, &i42); etbt.ilist = eina_list_prepend(etbt.ilist, &i42); etbt.ihash = eina_hash_string_superfast_new(NULL); eina_hash_add(etbt.ihash, EET_TEST_KEY1, &i7); eina_hash_add(etbt.ihash, EET_TEST_KEY2, &i7); etbt.slist = eina_list_prepend(NULL, "test"); etbt.shash = eina_hash_string_superfast_new(NULL); eina_hash_add(etbt.shash, EET_TEST_KEY1, "test"); memset(&etbt.charray, 0, sizeof(etbt.charray)); etbt.charray[0] = "test"; eet_eina_file_data_descriptor_class_set(&eddc, sizeof (eddc), "Eet_Test_Ex_Type", sizeof(Eet_Test_Ex_Type)); edd = eet_data_descriptor_file_new(&eddc); fail_if(!edd); eet_build_ex_descriptor(edd, EINA_FALSE); fail_if(-1 == (tmpfd = mkstemp(file))); fail_if(!!close(tmpfd)); /* Save the encoded data in a file. */ ef = eet_open(file, EET_FILE_MODE_WRITE); fail_if(!ef); fail_if(!eet_data_write(ef, edd, EET_TEST_FILE_KEY1, &etbt, 0)); eet_close(ef); /* Use dump/undump in the middle */ ef = eet_open(file, EET_FILE_MODE_READ_WRITE); fail_if(!ef); string1 = NULL; fail_if(eet_data_dump(ef, EET_TEST_FILE_KEY1, append_string, &string1) != 1); fail_if(eet_delete(ef, EET_TEST_FILE_KEY1) == 0); fail_if(!eet_data_undump(ef, EET_TEST_FILE_KEY1, string1, strlen(string1), 1)); eet_close(ef); /* Test the correctness of the reinsertion. */ ef = eet_open(file, EET_FILE_MODE_READ); fail_if(!ef); result = eet_data_read(ef, edd, EET_TEST_FILE_KEY1); fail_if(!result); eet_close(ef); /* Test the resulting data. */ fail_if(eet_test_ex_check(result, 0, EINA_TRUE) != 0); fail_if(eet_test_ex_check(eina_list_data_get(result->list), 1, EINA_TRUE) != 0); fail_if(eina_list_data_get(result->ilist) == NULL); fail_if(*((int *)eina_list_data_get(result->ilist)) != 42); fail_if(eina_list_data_get(result->slist) == NULL); fail_if(strcmp(eina_list_data_get(result->slist), "test") != 0); fail_if(eina_hash_find(result->shash, EET_TEST_KEY1) == NULL); fail_if(strcmp(eina_hash_find(result->shash, EET_TEST_KEY1), "test") != 0); fail_if(strcmp(result->charray[0], "test") != 0); test = 0; _dump_call = EINA_TRUE; if (result->hash) eina_hash_foreach(result->hash, func, &test); _dump_call = EINA_FALSE; fail_if(test != 0); if (result->ihash) eina_hash_foreach(result->ihash, func7, &test); fail_if(test != 0); fail_if(unlink(file) != 0); eet_shutdown(); }
END_TEST START_TEST(eet_test_file_data) { Eet_Data_Descriptor *edd; Eet_Test_Ex_Type *result; Eet_Dictionary *ed; Eet_File *ef; char **list; char *file; Eet_Data_Descriptor_Class eddc; Eet_Test_Ex_Type etbt; int size; int test; int tmpfd; file = strdup("/tmp/eet_suite_testXXXXXX"); eet_init(); eet_test_ex_set(&etbt, 0); etbt.list = eina_list_prepend(etbt.list, eet_test_ex_set(NULL, 1)); etbt.list = eina_list_prepend(etbt.list, eet_test_ex_set(NULL, 1)); etbt.hash = eina_hash_string_superfast_new(NULL); eina_hash_add(etbt.hash, EET_TEST_KEY1, eet_test_ex_set(NULL, 2)); etbt.hash = eina_hash_string_superfast_new(NULL); eina_hash_add(etbt.hash, EET_TEST_KEY2, eet_test_ex_set(NULL, 2)); etbt.ilist = eina_list_prepend(etbt.ilist, &i42); etbt.ilist = eina_list_prepend(etbt.ilist, &i42); etbt.ihash = eina_hash_string_superfast_new(NULL); eina_hash_add(etbt.ihash, EET_TEST_KEY1, &i7); etbt.ihash = eina_hash_string_superfast_new(NULL); eina_hash_add(etbt.ihash, EET_TEST_KEY2, &i7); etbt.slist = eina_list_prepend(NULL, "test"); etbt.shash = eina_hash_string_superfast_new(NULL); eina_hash_add(etbt.shash, EET_TEST_KEY1, "test"); memset(&etbt.charray, 0, sizeof(etbt.charray)); etbt.charray[0] = "test"; eet_test_setup_eddc(&eddc); eddc.name = "Eet_Test_Ex_Type"; eddc.size = sizeof(Eet_Test_Ex_Type); edd = eet_data_descriptor_file_new(&eddc); fail_if(!edd); eet_build_ex_descriptor(edd, EINA_FALSE); fail_if(-1 == (tmpfd = mkstemp(file))); fail_if(!!close(tmpfd)); /* Insert an error in etbt. */ etbt.i = 0; /* Save the encoded data in a file. */ ef = eet_open(file, EET_FILE_MODE_READ_WRITE); fail_if(!ef); fail_if(!eet_data_write(ef, edd, EET_TEST_FILE_KEY1, &etbt, 0)); result = eet_data_read(ef, edd, EET_TEST_FILE_KEY1); fail_if(!result); fail_if(eet_mode_get(ef) != EET_FILE_MODE_READ_WRITE); /* Test string space. */ ed = eet_dictionary_get(ef); fail_if(!eet_dictionary_string_check(ed, result->str)); fail_if(eet_dictionary_string_check(ed, result->istr)); eet_close(ef); /* Attempt to replace etbt by the correct one. */ etbt.i = EET_TEST_INT; ef = eet_open(file, EET_FILE_MODE_READ_WRITE); fail_if(!ef); fail_if(!eet_data_write(ef, edd, EET_TEST_FILE_KEY1, &etbt, 0)); result = eet_data_read(ef, edd, EET_TEST_FILE_KEY1); fail_if(!result); /* Test the resulting data. */ fail_if(eet_test_ex_check(result, 0, EINA_FALSE) != 0); eet_close(ef); /* Read back the data. */ ef = eet_open(file, EET_FILE_MODE_READ_WRITE); fail_if(!ef); fail_if(!eet_data_write(ef, edd, EET_TEST_FILE_KEY2, &etbt, 0)); result = eet_data_read(ef, edd, EET_TEST_FILE_KEY1); fail_if(!result); /* Test string space. */ ed = eet_dictionary_get(ef); fail_if(!ed); fail_if(!eet_dictionary_string_check(ed, result->str)); fail_if(eet_dictionary_string_check(ed, result->istr)); /* Test the resulting data. */ fail_if(eet_test_ex_check(result, 0, EINA_FALSE) != 0); fail_if(eet_test_ex_check(eina_list_data_get(result->list), 1, EINA_FALSE) != 0); fail_if(eina_list_data_get(result->ilist) == NULL); fail_if(*((int *)eina_list_data_get(result->ilist)) != 42); fail_if(eina_list_data_get(result->slist) == NULL); fail_if(strcmp(eina_list_data_get(result->slist), "test") != 0); fail_if(eina_hash_find(result->shash, EET_TEST_KEY1) == NULL); fail_if(strcmp(eina_hash_find(result->shash, EET_TEST_KEY1), "test") != 0); fail_if(strcmp(result->charray[0], "test") != 0); test = 0; if (result->hash) eina_hash_foreach(result->hash, func, &test); fail_if(test != 0); if (result->ihash) eina_hash_foreach(result->ihash, func7, &test); fail_if(test != 0); list = eet_list(ef, "keys/*", &size); fail_if(eet_num_entries(ef) != 2); fail_if(size != 2); fail_if(!(strcmp(list[0], EET_TEST_FILE_KEY1) == 0 && strcmp(list[1], EET_TEST_FILE_KEY2) == 0) && !(strcmp(list[0], EET_TEST_FILE_KEY2) == 0 && strcmp(list[1], EET_TEST_FILE_KEY1) == 0)); free(list); fail_if(eet_delete(ef, NULL) != 0); fail_if(eet_delete(NULL, EET_TEST_FILE_KEY1) != 0); fail_if(eet_delete(ef, EET_TEST_FILE_KEY1) == 0); list = eet_list(ef, "keys/*", &size); fail_if(size != 1); fail_if(eet_num_entries(ef) != 1); /* Test some more wrong case */ fail_if(eet_data_read(ef, edd, "plop") != NULL); fail_if(eet_data_read(ef, edd, EET_TEST_FILE_KEY1) != NULL); /* Reinsert and reread data */ fail_if(!eet_data_write(ef, edd, EET_TEST_FILE_KEY1, &etbt, 0)); fail_if(eet_data_read(ef, edd, EET_TEST_FILE_KEY1) == NULL); fail_if(eet_read_direct(ef, EET_TEST_FILE_KEY1, &size) == NULL); eet_close(ef); fail_if(unlink(file) != 0); eet_shutdown(); }
int main(int argc, char **argv) { Edje_Part_Collection_Directory_Entry *ce; Old_Edje_File *oef; Edje_File *nef; Eina_Iterator *it; Eet_File *ef; setlocale(LC_NUMERIC, "C"); ecore_app_no_system_modules(); if (!eina_init()) return -1; _edje_cc_log_dom = eina_log_domain_register ("edje_convert", EDJE_CC_DEFAULT_LOG_COLOR); if (_edje_cc_log_dom < 0) { EINA_LOG_ERR("Enable to create a log domain."); exit(-1); } eet_init(); progname = argv[0]; if (argc > 2 || argc < 2 || !strcmp(argv[1], "-h")) { main_help(); return 0; } _edje_edd_old_init(); _edje_edd_init(); ef = eet_open(argv[1], EET_FILE_MODE_READ_WRITE); if (!ef) { EINA_LOG_ERR("Unable to open `%s'.", argv[1]); return -1; } oef = eet_data_read(ef, _edje_edd_old_edje_file, "edje_file"); if (!oef) { EINA_LOG_ERR("Unable to get edje_file section from old file format, are you sure it's an old file ?"); return -1; } nef = _edje_file_convert(ef, oef); _edje_file_set(nef); /* convert old structure to new one */ it = eina_hash_iterator_data_new(nef->collection); EINA_ITERATOR_FOREACH(it, ce) { Old_Edje_Part_Collection *opc; Edje_Part_Collection *npc; char buf[1024]; int bytes = 0; snprintf(buf, sizeof (buf), "collections/%i", ce->id); opc = eet_data_read(ef, _edje_edd_old_edje_part_collection, buf); if (!opc) { EINA_LOG_ERR("Unable to find collection `%s'[%i] in `%s'.", ce->entry, ce->id, argv[1]); return -1; } npc = _edje_collection_convert(ef, ce, opc); snprintf(buf, sizeof (buf), "edje/collections/%i", ce->id); bytes = eet_data_write(ef, _edje_edd_edje_part_collection, buf, npc, 1); if (bytes <= 0) { EINA_LOG_ERR("Unable to save `%s' in section `%s' of `%s'.", ce->entry, buf, argv[1]); return -1; } }
EAPI int efreet_init(void) { #ifndef _WIN32 char *tmp; #endif if (++_efreet_init_count != 1) return _efreet_init_count; #ifndef _WIN32 /* Find users real uid and gid */ tmp = getenv("SUDO_UID"); if (tmp) ruid = strtoul(tmp, NULL, 10); else ruid = getuid(); tmp = getenv("SUDO_GID"); if (tmp) rgid = strtoul(tmp, NULL, 10); else rgid = getgid(); #endif if (!eina_init()) return --_efreet_init_count; if (!eet_init()) goto shutdown_eina; if (!ecore_init()) goto shutdown_eet; if (!ecore_file_init()) goto shutdown_ecore; if (!efreet_base_init()) goto shutdown_ecore_file; if (!efreet_cache_init()) goto shutdown_efreet_base; if (!efreet_xml_init()) goto shutdown_efreet_cache; if (!efreet_icon_init()) goto shutdown_efreet_xml; if (!efreet_ini_init()) goto shutdown_efreet_icon; if (!efreet_desktop_init()) goto shutdown_efreet_ini; if (!efreet_menu_init()) goto shutdown_efreet_desktop; if (!efreet_util_init()) goto shutdown_efreet_menu; #ifdef ENABLE_NLS bindtextdomain(PACKAGE, LOCALE_DIR); bind_textdomain_codeset(PACKAGE, "UTF-8"); #endif return _efreet_init_count; shutdown_efreet_menu: efreet_menu_shutdown(); shutdown_efreet_desktop: efreet_desktop_shutdown(); shutdown_efreet_ini: efreet_ini_shutdown(); shutdown_efreet_icon: efreet_icon_shutdown(); shutdown_efreet_xml: efreet_xml_shutdown(); shutdown_efreet_cache: efreet_cache_shutdown(); shutdown_efreet_base: efreet_base_shutdown(); shutdown_ecore_file: ecore_file_shutdown(); shutdown_ecore: ecore_shutdown(); shutdown_eet: eet_shutdown(); shutdown_eina: eina_shutdown(); return --_efreet_init_count; }
void eli_highscore_init(const char * app) { char buffer[1024]; char * home; Eet_File * ef; eet_init(); edd_entry = eet_data_descriptor_new("Eli_Highscore_Entry", sizeof(Eli_Highscore_Entry), (list_next) eina_list_next, (list_append) eina_list_append, (list_data) eina_list_data_get, (list_free) eina_list_free, (hash_foreach) eina_hash_foreach, (hash_add) eina_hash_add /* FIXME: YOU SHOULD NOT USE EINA_HASH_ADD DIRECTLY */, (hash_free) eina_hash_free); EET_DATA_DESCRIPTOR_ADD_BASIC(edd_entry, Eli_Highscore_Entry, "username", username, EET_T_STRING); EET_DATA_DESCRIPTOR_ADD_BASIC(edd_entry, Eli_Highscore_Entry, "points", points, EET_T_FLOAT); EET_DATA_DESCRIPTOR_ADD_BASIC(edd_entry, Eli_Highscore_Entry, "type", type, EET_T_INT); edd_hiscore = eet_data_descriptor_new("Eli_Highscore", sizeof(Eli_Highscore), (list_next) eina_list_next, (list_append) eina_list_append, (list_data) eina_list_data_get, (list_free) eina_list_free, (hash_foreach) eina_hash_foreach, (hash_add) eina_hash_add /* FIXME: YOU SHOULD NOT USE EINA_HASH_ADD DIRECTLY */, (hash_free) eina_hash_free); EET_DATA_DESCRIPTOR_ADD_LIST(edd_hiscore, Eli_Highscore, "entries", entries, edd_entry); /* this is just a temporally hack, the right path should be * some thing like /var/games/elitaire.score, but * for some reasons eet segv when the directory is not * writable, although the file is */ home = getenv("HOME"); if (!home) home = "/tmp"; snprintf(buffer, sizeof(buffer), "%s/.e/apps/%s/score.eet", home, app); eet_file_name = strdup(buffer); /* * setup the hiscore hash */ hiscore_hash = ecore_hash_new(ecore_str_hash, ecore_str_compare); ecore_hash_free_key_cb_set(hiscore_hash, free); /* * fill the hash */ ef = eet_open(eet_file_name, EET_FILE_MODE_READ); if (ef) { char **list; int num, i; list = eet_list(ef, "*", &num); for(i = 0; i < num; i++) { Eli_Highscore * hiscore; hiscore = eet_data_read(ef, edd_hiscore, list[i]); ecore_hash_set(hiscore_hash, strdup(list[i]), hiscore->entries); } free(list); eet_close(ef); } }
void _evas_3d_eet_file_init(void) { eina_init(); eet_init(); /* initialization of bonding between structure units in eet file */ Eet_Data_Descriptor_Class eddc; EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_3D_Vec2_Eet); _vec2_descriptor = eet_data_descriptor_file_new(&eddc); EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_3D_Vec3_Eet); _vec3_descriptor = eet_data_descriptor_file_new(&eddc); EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_3D_Vertex_Eet); _vertex_descriptor = eet_data_descriptor_file_new(&eddc); EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_3D_Geometry_Eet); _geometry_descriptor = eet_data_descriptor_file_new(&eddc); EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_3D_Color_Eet); _color_descriptor = eet_data_descriptor_file_new(&eddc); EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_3D_Frame_Eet); _frame_descriptor = eet_data_descriptor_file_new(&eddc); EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_3D_Material_Eet); _material_descriptor = eet_data_descriptor_file_new(&eddc); EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_3D_Mesh_Eet); _mesh_descriptor = eet_data_descriptor_file_new(&eddc); EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_3D_Header_Eet); _header_descriptor = eet_data_descriptor_file_new(&eddc); EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Evas_3D_File_Eet); _file_descriptor = eet_data_descriptor_file_new(&eddc); /* Vec_2 */ #define ADD_BASIC(member, eet_type) EET_DATA_DESCRIPTOR_ADD_BASIC \ (_vec2_descriptor, Evas_3D_Vec3_Eet, # member, member, eet_type); ADD_BASIC(x, EET_T_FLOAT); ADD_BASIC(y, EET_T_FLOAT); #undef ADD_BASIC /* Vec_3 */ #define ADD_BASIC(member, eet_type) EET_DATA_DESCRIPTOR_ADD_BASIC \ (_vec3_descriptor, Evas_3D_Vec3_Eet, # member, member, eet_type); ADD_BASIC(x, EET_T_FLOAT); ADD_BASIC(y, EET_T_FLOAT); ADD_BASIC(z, EET_T_FLOAT); #undef ADD_BASIC /* Vertex */ EET_DATA_DESCRIPTOR_ADD_SUB_NESTED(_vertex_descriptor, Evas_3D_Vertex_Eet, "position", position, _vec3_descriptor); EET_DATA_DESCRIPTOR_ADD_SUB_NESTED(_vertex_descriptor, Evas_3D_Vertex_Eet, "normal", normal, _vec3_descriptor); EET_DATA_DESCRIPTOR_ADD_SUB_NESTED(_vertex_descriptor, Evas_3D_Vertex_Eet, "texcoord", texcoord, _vec2_descriptor); /* Geometry */ EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_geometry_descriptor, Evas_3D_Geometry_Eet, "vertices", vertices, _vertex_descriptor); #define ADD_BASIC(member, eet_type) \ EET_DATA_DESCRIPTOR_ADD_BASIC \ (_geometry_descriptor, Evas_3D_Geometry_Eet, # member, member, eet_type); ADD_BASIC(vertices_count, EET_T_UINT); ADD_BASIC(id, EET_T_UINT); #undef ADD_BASIC /* Color */ #define ADD_BASIC(member, eet_type) EET_DATA_DESCRIPTOR_ADD_BASIC \ (_color_descriptor, Evas_3D_Color_Eet, # member, member, eet_type); ADD_BASIC(r, EET_T_FLOAT); ADD_BASIC(g, EET_T_FLOAT); ADD_BASIC(b, EET_T_FLOAT); ADD_BASIC(a, EET_T_FLOAT); #undef ADD_BASIC /* Material */ EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_material_descriptor, Evas_3D_Material_Eet, "colors", colors, _color_descriptor); #define ADD_BASIC(member, eet_type) \ EET_DATA_DESCRIPTOR_ADD_BASIC \ (_material_descriptor, Evas_3D_Material_Eet, # member, member, eet_type); ADD_BASIC(id, EET_T_UINT); ADD_BASIC(colors_count, EET_T_UINT); ADD_BASIC(shininess, EET_T_FLOAT); #undef ADD_BASIC /* Frame */ #define ADD_BASIC(member, eet_type) EET_DATA_DESCRIPTOR_ADD_BASIC \ (_frame_descriptor, Evas_3D_Frame_Eet, # member, member, eet_type); ADD_BASIC(id, EET_T_UINT); ADD_BASIC(geometry_id, EET_T_UINT); ADD_BASIC(material_id, EET_T_UINT); #undef ADD_BASIC /* Mesh */ EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_mesh_descriptor, Evas_3D_Mesh_Eet, "frames", frames, _frame_descriptor); EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_mesh_descriptor, Evas_3D_Mesh_Eet, "geometries", geometries, _geometry_descriptor); EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_mesh_descriptor, Evas_3D_Mesh_Eet, "materials", materials, _material_descriptor); #define ADD_BASIC(member, eet_type) \ EET_DATA_DESCRIPTOR_ADD_BASIC \ (_mesh_descriptor, Evas_3D_Mesh_Eet, # member, member, eet_type); ADD_BASIC(materials_count, EET_T_UINT); ADD_BASIC(frames_count, EET_T_UINT); ADD_BASIC(geometries_count, EET_T_UINT); #undef ADD_BASIC /* Header */ EET_DATA_DESCRIPTOR_ADD_BASIC_VAR_ARRAY(_header_descriptor, Evas_3D_Header_Eet, "materials", materials, EET_T_UINT); EET_DATA_DESCRIPTOR_ADD_BASIC_VAR_ARRAY(_header_descriptor, Evas_3D_Header_Eet, "geometries", geometries, EET_T_UINT); #define ADD_BASIC(member, eet_type) \ EET_DATA_DESCRIPTOR_ADD_BASIC \ (_header_descriptor, Evas_3D_Header_Eet, # member, member, eet_type); ADD_BASIC(version, EET_T_UINT); ADD_BASIC(materials_count, EET_T_UINT); ADD_BASIC(frames, EET_T_UINT); ADD_BASIC(geometries_count, EET_T_UINT); #undef ADD_BASIC /* File */ EET_DATA_DESCRIPTOR_ADD_SUB(_file_descriptor, Evas_3D_File_Eet, "mesh", mesh, _mesh_descriptor); EET_DATA_DESCRIPTOR_ADD_SUB(_file_descriptor, Evas_3D_File_Eet, "header", header, _header_descriptor); }
int main(int argc, char ** argv) { char *display = NULL; char *theme = NULL; int ret = 1; int i; if (!ecore_init()) { fprintf(stderr, "Error initing Ecore.\n"); goto SHUTDOWN; } ecore_app_args_set(argc, (const char **)argv); ecore_event_handler_add(ECORE_EVENT_SIGNAL_EXIT, entangle_cb_exit, NULL); for (i = 1; i < argc; i++) { if ((!strcmp(argv[i], "-display")) || (!strcmp(argv[i], "-d"))) { if (++i < argc) { IF_FREE(display); display = strdup(argv[i]); } else { fprintf(stderr, "ERROR: Missing argument to -display\n"); goto ECORE_SHUTDOWN; } } else if ((!strcmp(argv[i], "-theme")) || (!strcmp(argv[i], "-t"))) { if (++i < argc) { IF_FREE(theme); theme = strdup(argv[i]); } else { fprintf(stderr, "ERROR: Missing argument to -theme\n"); goto ECORE_SHUTDOWN; } } else if ((!strcmp(argv[i], "-help")) || (!strcmp(argv[i], "-h"))) { entangle_usage(argv); return 0; } } /* make sure the theme is valid */ if (theme) { char *p; p = strstr(theme, ".edj"); if (p && (strlen(theme) - (p - theme) == strlen(".edj"))) { if (!ecore_file_exists(theme)) { char tmp[PATH_MAX]; snprintf(tmp, PATH_MAX, PACKAGE_DATA_DIR"/data/entangle/%s", theme); FREE(theme); if (ecore_file_exists(tmp)) theme = strdup(tmp); } } else { char tmp[PATH_MAX]; snprintf(tmp, PATH_MAX, PACKAGE_DATA_DIR"/data/entangle/%s.edj", theme); FREE(theme); if (ecore_file_exists(tmp)) theme = strdup(tmp); } } if (!theme) theme = strdup(PACKAGE_DATA_DIR"/data/entangle/default.edj"); /* make sure the display is valid */ if (!display) { char *tmp = getenv("DISPLAY"); if (tmp) display = strdup(tmp); } if (display) { char *p; char buf[1024]; p = strrchr(display, ':'); if (!p) { snprintf(buf, sizeof(buf), "%s:0.0", display); FREE(display); display = strdup(buf); } else { p = strrchr(p, '.'); if (!p) { snprintf(buf, sizeof(buf), "%s.0", display); FREE(display); display = strdup(buf); } } } else display = strdup(":0.0"); if (!ecore_file_init()) { fprintf(stderr, "Error initing Ecore_File.\n"); goto ECORE_SHUTDOWN; } if (!ecore_evas_init()) { fprintf(stderr, "Error initing Ecore_Evas.\n"); goto ECORE_FILE_SHUTDOWN; } if (!edje_init()) { fprintf(stderr, "Error initing Edje.\n"); goto ECORE_EVAS_SHUTDOWN; } if (!eet_init()) { fprintf(stderr, "Error initing Eet.\n"); goto EDJE_SHUTDOWN; } if (!entangle_eapps_init()) { fprintf(stderr, "Error initing Entangle_Eapps.\n"); goto EET_SHUTDOWN; } if (!entangle_apps_init()) { fprintf(stderr, "Error initing Entangle_Apps.\n"); goto ENTANGLE_EAPPS_SHUTDOWN; } if (!entangle_ui_init(display, theme)) { fprintf(stderr, "Error initing Entangle_Ui.\n"); goto ENTANGLE_APPS_SHUTDOWN; } ecore_main_loop_begin(); ret = 0; entangle_ui_shutdown(); ENTANGLE_APPS_SHUTDOWN: entangle_apps_shutdown(); ENTANGLE_EAPPS_SHUTDOWN: entangle_eapps_shutdown(); EET_SHUTDOWN: eet_shutdown(); EDJE_SHUTDOWN: edje_shutdown(); ECORE_EVAS_SHUTDOWN: ecore_evas_shutdown(); ECORE_FILE_SHUTDOWN: ecore_file_shutdown(); ECORE_SHUTDOWN: ecore_shutdown(); SHUTDOWN: IF_FREE(display); IF_FREE(theme); return ret; }
static int _evas_gl_common_shader_binary_save(Evas_GL_Shared *shared) { char bin_dir_path[PATH_MAX]; char bin_file_path[PATH_MAX]; char tmp_file_name[PATH_MAX]; int tmpfd = -1, copy; Eina_Tmpstr *tmp_file_path = NULL; Eet_File *ef = NULL; Evas_GL_Program *p; Eina_Iterator *it; char pname[32]; /* use eet */ if (!eet_init()) return 0; if (!evas_gl_common_file_cache_dir_check(bin_dir_path, sizeof(bin_dir_path))) { if (!evas_gl_common_file_cache_mkpath(bin_dir_path)) return 0; /* we can't make directory */ } copy = evas_gl_common_file_cache_file_check(bin_dir_path, SHADER_EET_CACHENAME, bin_file_path, sizeof(bin_dir_path)); /* use mkstemp for writing */ snprintf(tmp_file_name, sizeof(tmp_file_name), "%s.XXXXXX.cache", bin_file_path); tmpfd = eina_file_mkstemp(tmp_file_name, &tmp_file_path); if (tmpfd < 0) goto error; /* copy old file */ if (copy) { ef = eet_open(tmp_file_path, EET_FILE_MODE_READ); if (!ef) goto save; if (!_evas_gl_common_shader_binary_checksum_check(shared, ef)) copy = EINA_FALSE; eet_close(ef); if (copy) eina_file_copy(bin_file_path, tmp_file_path, EINA_FILE_COPY_DATA, NULL, NULL); } save: ef = eet_open(tmp_file_path, copy ? EET_FILE_MODE_READ_WRITE : EET_FILE_MODE_WRITE); if (!ef) goto error; if (!_evas_gl_common_shader_binary_checksum_write(shared, ef)) goto error; it = eina_hash_iterator_data_new(shared->shaders_hash); EINA_ITERATOR_FOREACH(it, p) { if (!p->bin_saved) { int len = 0; sprintf(pname, SHADER_PROG_NAME_FMT, p->flags); eet_read_direct(ef, pname, &len); if (len > 0) p->bin_saved = 1; // assume bin data is correct else _evas_gl_common_shader_program_binary_save(p, ef); } } eina_iterator_free(it); if (shared->shaders_cache) { eet_close(shared->shaders_cache); shared->shaders_cache = NULL; eet_shutdown(); } if (eet_close(ef) != EET_ERROR_NONE) goto destroyed; if (rename(tmp_file_path, bin_file_path) < 0) goto destroyed; eina_tmpstr_del(tmp_file_path); close(tmpfd); eet_shutdown(); shared->needs_shaders_flush = 0; return 1; destroyed: ef = NULL; error: if (tmpfd >= 0) close(tmpfd); if (ef) eet_close(ef); if (evas_gl_common_file_cache_file_exists(tmp_file_path)) unlink(tmp_file_path); eina_tmpstr_del(tmp_file_path); eet_shutdown(); return 0; }
static Eina_Bool module_init(void) { eet_init(); return evas_cserve2_loader_register(&modapi); }