summaryrefslogtreecommitdiff
path: root/legacy/eet/src/examples/eet-data-simple.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2011-10-21 05:40:01 +0000
committerCarsten Haitzler <raster@rasterman.com>2011-10-21 05:40:01 +0000
commit8893a9ff35f58e012be3cc838bd94268add13e10 (patch)
treee5c560542a70ccf657e1da45fb57d8dee99d3348 /legacy/eet/src/examples/eet-data-simple.c
parenta331fe3bca4816e3a45662afd986e364b3586eed (diff)
ran ecrustify on eet. this seems to do a good job of eet. comments?
SVN revision: 64237
Diffstat (limited to '')
-rw-r--r--legacy/eet/src/examples/eet-data-simple.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/legacy/eet/src/examples/eet-data-simple.c b/legacy/eet/src/examples/eet-data-simple.c
index 395a8d66ab..1951fc012b 100644
--- a/legacy/eet/src/examples/eet-data-simple.c
+++ b/legacy/eet/src/examples/eet-data-simple.c
@@ -17,7 +17,7 @@
17typedef struct 17typedef struct
18{ 18{
19 unsigned int version; // it is recommended to use versioned configuration! 19 unsigned int version; // it is recommended to use versioned configuration!
20 const char * name; 20 const char *name;
21 int id; 21 int id;
22 int not_saved_value; // example of not saved data inside! 22 int not_saved_value; // example of not saved data inside!
23 Eina_Bool enabled; 23 Eina_Bool enabled;
@@ -31,7 +31,7 @@ static const char MY_CONF_FILE_ENTRY[] = "config";
31// keep the descriptor static global, so it can be 31// keep the descriptor static global, so it can be
32// shared by different functions (load/save) of this and only this 32// shared by different functions (load/save) of this and only this
33// file. 33// file.
34static Eet_Data_Descriptor * _my_conf_descriptor; 34static Eet_Data_Descriptor *_my_conf_descriptor;
35 35
36static void 36static void
37_my_conf_descriptor_init(void) 37_my_conf_descriptor_init(void)
@@ -55,13 +55,13 @@ _my_conf_descriptor_init(void)
55 55
56 // Describe the members to be saved: 56 // Describe the members to be saved:
57 // Use a temporary macro so we don't type a lot, also avoid errors: 57 // Use a temporary macro so we don't type a lot, also avoid errors:
58#define MY_CONF_ADD_BASIC(member, eet_type)\ 58#define MY_CONF_ADD_BASIC(member, eet_type) \
59 EET_DATA_DESCRIPTOR_ADD_BASIC\ 59 EET_DATA_DESCRIPTOR_ADD_BASIC \
60 (_my_conf_descriptor, My_Conf_Type, # member, member, eet_type) 60 (_my_conf_descriptor, My_Conf_Type, # member, member, eet_type)
61 61
62 MY_CONF_ADD_BASIC(version, EET_T_UINT); 62 MY_CONF_ADD_BASIC(version, EET_T_UINT);
63 MY_CONF_ADD_BASIC(name, EET_T_STRING); 63 MY_CONF_ADD_BASIC(name, EET_T_STRING);
64 MY_CONF_ADD_BASIC(id, EET_T_INT); 64 MY_CONF_ADD_BASIC(id, EET_T_INT);
65 MY_CONF_ADD_BASIC(enabled, EET_T_UCHAR); 65 MY_CONF_ADD_BASIC(enabled, EET_T_UCHAR);
66 66
67#undef MY_CONF_ADD_BASIC 67#undef MY_CONF_ADD_BASIC
@@ -76,7 +76,7 @@ _my_conf_descriptor_shutdown(void)
76static My_Conf_Type * 76static My_Conf_Type *
77_my_conf_new(void) 77_my_conf_new(void)
78{ 78{
79 My_Conf_Type * my_conf = calloc(1, sizeof(My_Conf_Type)); 79 My_Conf_Type *my_conf = calloc(1, sizeof(My_Conf_Type));
80 if (!my_conf) 80 if (!my_conf)
81 { 81 {
82 fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n"); 82 fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n");
@@ -89,17 +89,17 @@ _my_conf_new(void)
89} /* _my_conf_new */ 89} /* _my_conf_new */
90 90
91static void 91static void
92_my_conf_free(My_Conf_Type * my_conf) 92_my_conf_free(My_Conf_Type *my_conf)
93{ 93{
94 eina_stringshare_del(my_conf->name); 94 eina_stringshare_del(my_conf->name);
95 free(my_conf); 95 free(my_conf);
96} /* _my_conf_free */ 96} /* _my_conf_free */
97 97
98static My_Conf_Type * 98static My_Conf_Type *
99_my_conf_load(const char * filename) 99_my_conf_load(const char *filename)
100{ 100{
101 My_Conf_Type * my_conf; 101 My_Conf_Type *my_conf;
102 Eet_File * ef = eet_open(filename, EET_FILE_MODE_READ); 102 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ);
103 if (!ef) 103 if (!ef)
104 { 104 {
105 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename); 105 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
@@ -108,7 +108,7 @@ _my_conf_load(const char * filename)
108 108
109 my_conf = eet_data_read(ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY); 109 my_conf = eet_data_read(ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY);
110 if (!my_conf) 110 if (!my_conf)
111 goto end; 111 goto end;
112 112
113 if (my_conf->version < 0x112233) 113 if (my_conf->version < 0x112233)
114 { 114 {
@@ -126,10 +126,11 @@ end:
126} /* _my_conf_load */ 126} /* _my_conf_load */
127 127
128static Eina_Bool 128static Eina_Bool
129_my_conf_save(const My_Conf_Type * my_conf, const char * filename) 129_my_conf_save(const My_Conf_Type *my_conf,
130 const char *filename)
130{ 131{
131 char tmp[PATH_MAX]; 132 char tmp[PATH_MAX];
132 Eet_File * ef; 133 Eet_File *ef;
133 Eina_Bool ret; 134 Eina_Bool ret;
134 unsigned int i, len; 135 unsigned int i, len;
135 struct stat st; 136 struct stat st;
@@ -157,7 +158,7 @@ _my_conf_save(const My_Conf_Type * my_conf, const char * filename)
157 } 158 }
158 159
159 ret = eet_data_write 160 ret = eet_data_write
160 (ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY, my_conf, EINA_TRUE); 161 (ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY, my_conf, EINA_TRUE);
161 eet_close(ef); 162 eet_close(ef);
162 163
163 if (ret) 164 if (ret)
@@ -169,9 +170,11 @@ _my_conf_save(const My_Conf_Type * my_conf, const char * filename)
169 return ret; 170 return ret;
170} /* _my_conf_save */ 171} /* _my_conf_save */
171 172
172int main(int argc, char * argv[]) 173int
174main(int argc,
175 char *argv[])
173{ 176{
174 My_Conf_Type * my_conf; 177 My_Conf_Type *my_conf;
175 int ret = 0; 178 int ret = 0;
176 179
177 if (argc != 3) 180 if (argc != 3)
@@ -207,7 +210,7 @@ int main(int argc, char * argv[])
207 my_conf->enabled); 210 my_conf->enabled);
208 211
209 if (!_my_conf_save(my_conf, argv[2])) 212 if (!_my_conf_save(my_conf, argv[2]))
210 ret = -3; 213 ret = -3;
211 214
212 _my_conf_free(my_conf); 215 _my_conf_free(my_conf);
213 216