/* * @brief Create the eet descriptor for a list of interfaces (list of char*) * @return Return the descriptor */ Eet_Data_Descriptor * waiting_iface_edd_new() { Eet_Data_Descriptor *edd_elt, *edd_l; edd_elt = eet_data_descriptor_new("elt", sizeof(Boot_Process_Elt), evas_list_next, evas_list_append, evas_list_data, evas_list_free, evas_hash_foreach, evas_hash_add, evas_hash_free); EET_DATA_DESCRIPTOR_ADD_BASIC(edd_elt, Boot_Process_Elt, "interface", interface, EET_T_STRING); edd_l = eet_data_descriptor_new("boot process interface list", sizeof(Boot_Process_List), evas_list_next, evas_list_append, evas_list_data, evas_list_free, evas_hash_foreach, evas_hash_add, evas_hash_free); EET_DATA_DESCRIPTOR_ADD_BASIC(edd_l, Boot_Process_List, "timeout (sec)", timeout, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_LIST(edd_l, Boot_Process_List, "interface list", l, edd_elt); return edd_l; }
/** * @brief Create an eet descriptor for the structure Exalt_Eth_Save * @return Returns the descriptor */ Eet_Data_Descriptor * _exalt_eth_save_edd_new() { Eet_Data_Descriptor *edd, *edd_conn; edd_conn = exalt_conn_edd_new(); edd = eet_data_descriptor_new("Interface", sizeof(Exalt_Eth_Save), evas_list_next, evas_list_append, evas_list_data, evas_list_free, evas_hash_foreach, evas_hash_add, evas_hash_free); EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Exalt_Eth_Save, "up", state, EET_T_INT); EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Exalt_Eth_Save, "driver", driver, EET_T_STRING); EET_DATA_DESCRIPTOR_ADD_SUB(edd, Exalt_Eth_Save, "connection", connection, edd_conn); return edd; }
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); } }