29 static const char MY_CONF_FILE_ENTRY[] =
"config";
37 _my_conf_descriptor_init(
void)
58 #define MY_CONF_ADD_BASIC(member, eet_type) \ 59 EET_DATA_DESCRIPTOR_ADD_BASIC \ 60 (_my_conf_descriptor, My_Conf_Type, # member, member, eet_type) 67 #undef MY_CONF_ADD_BASIC 71 _my_conf_descriptor_shutdown(
void)
79 My_Conf_Type *my_conf = calloc(1,
sizeof(My_Conf_Type));
82 fprintf(stderr,
"ERROR: could not calloc My_Conf_Type\n");
86 my_conf->version = 0x112233;
87 my_conf->enabled = EINA_TRUE;
92 _my_conf_free(My_Conf_Type *my_conf)
94 eina_stringshare_del(my_conf->name);
99 _my_conf_load(
const char *filename)
101 My_Conf_Type *my_conf;
105 fprintf(stderr,
"ERROR: could not open '%s' for read\n", filename);
109 my_conf =
eet_data_read(ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY);
113 if (my_conf->version < 0x112233)
116 "WARNING: version %#x was too old, upgrading it to %#x\n",
117 my_conf->version, 0x112233);
119 my_conf->version = 0x112233;
120 my_conf->enabled = EINA_TRUE;
129 _my_conf_save(
const My_Conf_Type *my_conf,
130 const char *filename)
138 len = eina_strlcpy(tmp, filename,
sizeof(tmp));
139 if (len + 12 >= (
int)
sizeof(tmp))
141 fprintf(stderr,
"ERROR: file name is too big: %s\n", filename);
148 snprintf(tmp + len, 12,
".%u", i);
151 while (stat(tmp, &st) == 0);
156 fprintf(stderr,
"ERROR: could not open '%s' for write\n", tmp);
161 (ef, _my_conf_descriptor, MY_CONF_FILE_ENTRY, my_conf, EINA_TRUE);
167 rename(tmp, filename);
177 My_Conf_Type *my_conf;
182 fprintf(stderr,
"Usage:\n\t%s <input> <output>\n\n", argv[0]);
188 _my_conf_descriptor_init();
190 my_conf = _my_conf_load(argv[1]);
193 printf(
"creating new configuration.\n");
194 my_conf = _my_conf_new();
202 printf(
"My_Conf_Type:\n" 208 my_conf->name ? my_conf->name :
"",
212 if (!_my_conf_save(my_conf, argv[2]))
215 _my_conf_free(my_conf);
218 _my_conf_descriptor_shutdown();
EAPI Eet_File * eet_open(const char *file, Eet_File_Mode mode)
Open an eet file on disk, and returns a handle to it.
Definition: eet_lib.c:1419
EAPI int eet_data_write(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const void *data, int compress)
Write a data structure from memory and store in an eet file.
Definition: eet_data.c:2164
Definition: Eet_private.h:74
File is read-only.
Definition: Eet.h:513
EAPI int eet_shutdown(void)
Shut down the EET library.
Definition: eet_lib.c:634
#define EET_EINA_STREAM_DATA_DESCRIPTOR_CLASS_SET(clas, type)
This macro is an helper that set all the parameter of an Eet_Data_Descriptor_Class correctly when you...
Definition: Eet.h:2661
EAPI void eet_data_descriptor_free(Eet_Data_Descriptor *edd)
This function frees a data descriptor when it is not needed anymore.
Definition: eet_data.c:1920
#define EET_T_STRING
Data type: char *.
Definition: Eet.h:2363
#define EET_T_UINT
Data type: unsigned int.
Definition: Eet.h:2361
#define EET_T_UCHAR
Data type: unsigned char.
Definition: Eet.h:2359
#define EET_T_INT
Data type: int.
Definition: Eet.h:2355
The file that provides the eet functions.
File is write-only.
Definition: Eet.h:514
EAPI Eet_Data_Descriptor * eet_data_descriptor_stream_new(const Eet_Data_Descriptor_Class *eddc)
This function creates a new data descriptor and returns a handle to the new data descriptor.
Definition: eet_data.c:1908
EAPI void * eet_data_read(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name)
Read a data structure from an eet file and decodes it.
Definition: eet_data.c:2132
Instructs Eet about memory management for different needs under serialization and parse process...
Definition: Eet.h:2455
EAPI Eet_Error eet_close(Eet_File *ef)
Close an eet file handle and flush pending writes.
Definition: eet_lib.c:1659
struct _Eet_Data_Descriptor Eet_Data_Descriptor
Opaque handle that have information on a type members.
Definition: Eet.h:2403
EAPI int eet_init(void)
Initialize the EET library.
Definition: eet_lib.c:553