summaryrefslogtreecommitdiff
path: root/legacy/eet/src/examples/eet-data-simple.c
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2010-07-31 01:54:48 +0000
committerCarsten Haitzler <raster@rasterman.com>2010-07-31 01:54:48 +0000
commitf7019f134dd8e8ae830eb1d39fb8570c74b730e9 (patch)
tree6fc137cbc4e6505629d2210cf11ace757d162490 /legacy/eet/src/examples/eet-data-simple.c
parent55d01901859bb2fcca1befeb1011e204d271d59f (diff)
formatting. <- uncrustify
SVN revision: 50698
Diffstat (limited to '')
-rw-r--r--legacy/eet/src/examples/eet-data-simple.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/legacy/eet/src/examples/eet-data-simple.c b/legacy/eet/src/examples/eet-data-simple.c
index a4efd4ad7a..14b0a869eb 100644
--- a/legacy/eet/src/examples/eet-data-simple.c
+++ b/legacy/eet/src/examples/eet-data-simple.c
@@ -14,10 +14,10 @@
14typedef struct 14typedef struct
15{ 15{
16 unsigned int version; // it is recommended to use versioned configuration! 16 unsigned int version; // it is recommended to use versioned configuration!
17 const char *name; 17 const char * name;
18 int id; 18 int id;
19 int not_saved_value; // example of not saved data inside! 19 int not_saved_value; // example of not saved data inside!
20 Eina_Bool enabled; 20 Eina_Bool enabled;
21} My_Conf_Type; 21} My_Conf_Type;
22 22
23// string that represents the entry in eet file, you might like to have 23// string that represents the entry in eet file, you might like to have
@@ -25,11 +25,10 @@ typedef struct
25// different strings 25// different strings
26static const char MY_CONF_FILE_ENTRY[] = "config"; 26static const char MY_CONF_FILE_ENTRY[] = "config";
27 27
28
29// keep the descriptor static global, so it can be 28// keep the descriptor static global, so it can be
30// shared by different functions (load/save) of this and only this 29// shared by different functions (load/save) of this and only this
31// file. 30// file.
32static Eet_Data_Descriptor *_my_conf_descriptor; 31static Eet_Data_Descriptor * _my_conf_descriptor;
33 32
34static void 33static void
35_my_conf_descriptor_init(void) 34_my_conf_descriptor_init(void)
@@ -53,8 +52,8 @@ _my_conf_descriptor_init(void)
53 52
54 // Describe the members to be saved: 53 // Describe the members to be saved:
55 // Use a temporary macro so we don't type a lot, also avoid errors: 54 // Use a temporary macro so we don't type a lot, also avoid errors:
56#define MY_CONF_ADD_BASIC(member, eet_type) \ 55#define MY_CONF_ADD_BASIC(member, eet_type)\
57 EET_DATA_DESCRIPTOR_ADD_BASIC \ 56 EET_DATA_DESCRIPTOR_ADD_BASIC\
58 (_my_conf_descriptor, My_Conf_Type, # member, member, eet_type) 57 (_my_conf_descriptor, My_Conf_Type, # member, member, eet_type)
59 58
60 MY_CONF_ADD_BASIC(version, EET_T_UINT); 59 MY_CONF_ADD_BASIC(version, EET_T_UINT);
@@ -63,18 +62,18 @@ _my_conf_descriptor_init(void)
63 MY_CONF_ADD_BASIC(enabled, EET_T_UCHAR); 62 MY_CONF_ADD_BASIC(enabled, EET_T_UCHAR);
64 63
65#undef MY_CONF_ADD_BASIC 64#undef MY_CONF_ADD_BASIC
66} 65} /* _my_conf_descriptor_init */
67 66
68static void 67static void
69_my_conf_descriptor_shutdown(void) 68_my_conf_descriptor_shutdown(void)
70{ 69{
71 eet_data_descriptor_free(_my_conf_descriptor); 70 eet_data_descriptor_free(_my_conf_descriptor);
72} 71} /* _my_conf_descriptor_shutdown */
73 72
74static My_Conf_Type * 73static My_Conf_Type *
75_my_conf_new(void) 74_my_conf_new(void)
76{ 75{
77 My_Conf_Type *my_conf = calloc(1, sizeof(My_Conf_Type)); 76 My_Conf_Type * my_conf = calloc(1, sizeof(My_Conf_Type));
78 if (!my_conf) 77 if (!my_conf)
79 { 78 {
80 fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n"); 79 fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n");
@@ -84,20 +83,20 @@ _my_conf_new(void)
84 my_conf->version = 0x112233; 83 my_conf->version = 0x112233;
85 my_conf->enabled = EINA_TRUE; 84 my_conf->enabled = EINA_TRUE;
86 return my_conf; 85 return my_conf;
87} 86} /* _my_conf_new */
88 87
89static void 88static void
90_my_conf_free(My_Conf_Type *my_conf) 89_my_conf_free(My_Conf_Type * my_conf)
91{ 90{
92 eina_stringshare_del(my_conf->name); 91 eina_stringshare_del(my_conf->name);
93 free(my_conf); 92 free(my_conf);
94} 93} /* _my_conf_free */
95 94
96static My_Conf_Type * 95static My_Conf_Type *
97_my_conf_load(const char *filename) 96_my_conf_load(const char * filename)
98{ 97{
99 My_Conf_Type *my_conf; 98 My_Conf_Type * my_conf;
100 Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ); 99 Eet_File * ef = eet_open(filename, EET_FILE_MODE_READ);
101 if (!ef) 100 if (!ef)
102 { 101 {
103 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename); 102 fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
@@ -121,13 +120,13 @@ _my_conf_load(const char *filename)
121end: 120end:
122 eet_close(ef); 121 eet_close(ef);
123 return my_conf; 122 return my_conf;
124} 123} /* _my_conf_load */
125 124
126static Eina_Bool 125static Eina_Bool
127_my_conf_save(const My_Conf_Type *my_conf, const char *filename) 126_my_conf_save(const My_Conf_Type * my_conf, const char * filename)
128{ 127{
129 char tmp[PATH_MAX]; 128 char tmp[PATH_MAX];
130 Eet_File *ef; 129 Eet_File * ef;
131 Eina_Bool ret; 130 Eina_Bool ret;
132 unsigned int i, len; 131 unsigned int i, len;
133 struct stat st; 132 struct stat st;
@@ -165,11 +164,11 @@ _my_conf_save(const My_Conf_Type *my_conf, const char *filename)
165 } 164 }
166 165
167 return ret; 166 return ret;
168} 167} /* _my_conf_save */
169 168
170int main(int argc, char *argv[]) 169int main(int argc, char * argv[])
171{ 170{
172 My_Conf_Type *my_conf; 171 My_Conf_Type * my_conf;
173 int ret = 0; 172 int ret = 0;
174 173
175 if (argc != 3) 174 if (argc != 3)
@@ -194,7 +193,7 @@ int main(int argc, char *argv[])
194 } 193 }
195 } 194 }
196 195
197 printf("My_Conf_Type:\n" 196 printf("My_Conf_Type:\n"
198 "\tversion: %#x\n" 197 "\tversion: %#x\n"
199 "\tname...: '%s'\n" 198 "\tname...: '%s'\n"
200 "\tid.....: %d\n" 199 "\tid.....: %d\n"
@@ -215,4 +214,5 @@ end:
215 eina_shutdown(); 214 eina_shutdown();
216 215
217 return ret; 216 return ret;
218} 217} /* main */
218