rendered paste body#include "conf.h"int sort_cb(void *d1, void *d2);static int PATH_MAX = 256;static Eet_Data_Descriptor *_e_config_carrage_edd = NULL;static Eet_Data_Descriptor *_e_config_theme_edd = NULL;static Eet_Data_Descriptor *_e_config_theme_list_edd = NULL;/***************************************************/ Function: / Purpose: /// /*****************************************************/int_e_config_init(){ Evas_List *ts_list; _e_config_carrage_edd = NEWD("CarRageSettings", CarRageSettings); #undef T #undef D #define T CarRageSettings #define D _e_config_carrage_edd EL_CONFIG_VAL(D, T, theme, EET_T_STRING); EL_CONFIG_VAL(D, T, res_w, EET_T_INT); EL_CONFIG_VAL(D, T, res_v, EET_T_INT); _e_config_theme_edd = NEWD("Theme_Settings", Theme_Settings); #undef T #undef D #define T Theme_Settings #define D _e_config_theme_edd EL_CONFIG_VAL(D,T, but_id, EET_T_STRING); EL_CONFIG_VAL(D,T, screen_id, EET_T_STRING); EL_CONFIG_VAL(D,T, fun_id, EET_T_STRING); EL_CONFIG_VAL(D,T, screen_act, EET_T_STRING); _e_config_theme_list_edd = NEWD("ThemeSettingsList",ThemeSettingsList); #undef T #undef D #define T ThemeSettingsList #define D _e_config_theme_list_edd EL_CONFIG_LIST(D, T, ts_list, _e_config_theme_edd); return 1;}/***************************************************/ Function: / Purpose: /// /*****************************************************/int_e_config_load(CarRageSettings *ss, ThemeSettingsList *tsl){ Eet_File *ef; Eet_File *ef2; char buf[PATH_MAX]; char buf2[PATH_MAX]; char *home; int size; int starth = 800; int startw = 600; home = getenv("HOME"); snprintf(buf, sizeof(buf), "%s/.e/CarRage", home); if(!ecore_file_is_dir(buf)) { if(ecore_file_exists(buf)) { ss->res_v = starth; ss->res_w = startw; ss->theme = strdup("default"); return 0; } if(!ecore_file_mkdir(buf)) { ss->res_v = starth; ss->res_w = startw; ss->theme = strdup("default"); return 0; } } snprintf(buf, sizeof(buf), "%s/.e/CarRage/config.eet", home); snprintf(buf2, sizeof(buf2), "%s/.e/CarRage/", home); ef = eet_open(buf, EET_FILE_MODE_READ); if (!ef) { ss->res_v = starth; ss->res_w = startw; ss->theme = strdup("default"); int good = _e_config_save(ss, NULL); return 0; } ss = eet_data_read(ef,_e_config_carrage_edd, "sskey"); strcat(buf2,ss->theme); strcat(buf2,"/theme_config.eet"); if(!ecore_file_exists(buf2) || ecore_file_size(buf2) == 0) { /* no saved config */ return 0; } ef2 = eet_open(buf2, EET_FILE_MODE_READ); if(!ef2) { return 0; } tsl = eet_data_read(ef2, _e_config_theme_list_edd, "tskey"); eet_close(ef); eet_close(ef2);Theme_Settings *a1;Evas_List *l; for (l = tsl->ts_list; l; l = l->next) { a1 = l->data;} // tsl = evas_list_sort(tsl, evas_list_count(tsl), sort_cb);/* if (evas_list_alloc_error()) { fprintf(stderr, "ERROR: Memory is low. List Sorting failed.\n"); exit(-1); }*/ return 1;}/***************************************************/ Function: / Purpose: /// /*****************************************************/voidMakeConfig(char *buf ){ ThemeSettingsList *tsl; FILE *fp; char read_line[80]; unsigned int value; Eet_File *ef; char screenID[20] = ""; char butID[20]= ""; char funID[20] = ""; char screen_act[20] = ""; int ok; Theme_Settings *ts; char buf2[256] = "new_confg.eet"; tsl = calloc(1,sizeof(ThemeSettingsList)); ts = calloc(1,sizeof(Theme_Settings)); fp = fopen(buf,"r"); if (fp) { while ((fgets(read_line, sizeof(read_line), fp))) { sscanf(read_line, "%s %s %s %s", screenID, butID, funID, screen_act); ts->but_id = strdup(butID); ts->screen_id = strdup(screenID); ts->fun_id = strdup(funID); ts->screen_act = strdup(screen_act); tsl->ts_list = evas_list_append(tsl->ts_list, &ts); } } fclose(fp); ef = eet_open(buf2, EET_FILE_MODE_WRITE); if (ef) { ok = eet_data_write(ef, _e_config_theme_list_edd, "tskey", tsl, 0); eet_close(ef); } free(tsl); free(ts);}///////////////////////////////////////////////////////////////////////////////#ifndef _CONF_H#define _CONF_H#include "carrage.h"#define NEWD(str, typ) \ eet_data_descriptor_new(str, sizeof(typ), \ (void *(*) (void *))evas_list_next, \ (void *(*) (void *, void *))evas_list_append, \ (void *(*) (void *))evas_list_data, \ (void *(*) (void *))evas_list_free, \ (void (*) (void *, int (*) (void *, const char *, void *, void *), void *))evas_hash_foreach, \ (void *(*) (void *, const char *, void *))evas_hash_add, \ (void (*) (void *))evas_hash_free)#define EL_CONFIG_VAL(edd, type, member, dtype) EET_DATA_DESCRIPTOR_ADD_BASIC(edd, type, #member, member, dtype)#define EL_CONFIG_SUB(edd, type, member, eddtype) EET_DATA_DESCRIPTOR_ADD_SUB(edd, type, #member, member, eddtype)#define EL_CONFIG_LIST(edd, type, member, eddtype) EET_DATA_DESCRIPTOR_ADD_LIST(edd, type, #member, member, eddtype)#define FREED(eed) \ if (eed) \ { \ eet_data_descriptor_free((eed)); \ (eed) = NULL; \ }typedef struct _CarRageSettings CarRageSettings;typedef struct _theme_settings_list ThemeSettingsList;typedef Eet_Data_Descriptor EL_Config_DD; struct _CarRageSettings{ char *theme; int res_w; int res_v;};struct _theme_settings_list{ Evas_List *ts_list;};void MakeConfig(char *buf);int _e_config_init();int _e_config_shutdown();int _e_config_load(CarRageSettings *ss, ThemeSettingsList *tsl);int _e_config_save(CarRageSettings *ss, ThemeSettingsList *tsl);int _e_conf_init();#endif///////////////////////////////////////////////////////////////#ifndef _CARRAGE_H#define _CARRAGE_H#include <stdlib.h>#include <stdio.h>#include <string.h>#include <stdlib.h>#include <Evas.h>#include <Ecore.h>#include <Ecore_File.h>#include <Ecore_Evas.h>#include <Edje.h>#include <Emotion.h>#include <Eet.h>#include "conf.h"#include "button_func.h"typedef struct _theme_settings Theme_Settings;typedef struct _button Button;typedef struct _screen Screen;struct _button{ Evas_Object *but_o; char *butid;};struct _screen{ Evas_Object *screen_o; char *screenID; Evas_List *button_list;};struct _theme_settings{ char *but_id; char *screen_id; char *fun_id; char *screen_act;};#define CTXT_MAIN 0#define CTXT_VIDEO 1#endif