15    const char  *screen_name;
    19    unsigned int status_id;
    21    unsigned int timeline;
    48 static const char MY_CACHE_FILE_ENTRY[] = 
"cache";
    59 static Eet_File *_my_cache_file = NULL;
    63 _my_cache_descriptor_init(
void)
    85 #define ADD_BASIC(member, eet_type) \    86   EET_DATA_DESCRIPTOR_ADD_BASIC     \    87     (_my_message_descriptor, My_Message, # member, member, eet_type)    97 #define ADD_BASIC(member, eet_type) \    98   EET_DATA_DESCRIPTOR_ADD_BASIC     \    99     (_my_post_descriptor, My_Post, # member, member, eet_type)   104 #define ADD_BASIC(member, eet_type) \   105   EET_DATA_DESCRIPTOR_ADD_BASIC     \   106     (_my_account_descriptor, My_Account, # member, member, eet_type)   112      (_my_account_descriptor, My_Account, 
"messages", messages,
   113      _my_message_descriptor);
   115      (_my_account_descriptor, My_Account, 
"posts", posts,
   116      _my_post_descriptor);
   118 #define ADD_BASIC(member, eet_type) \   119   EET_DATA_DESCRIPTOR_ADD_BASIC     \   120     (_my_cache_descriptor, My_Cache, # member, member, eet_type)   125      (_my_cache_descriptor, My_Cache, 
"accounts", accounts,
   126      _my_account_descriptor);
   130 _my_cache_descriptor_shutdown(
void)
   141 _eet_string_free(
const char *str)
   153 _my_message_new(
const char *message)
   155    My_Message *msg = calloc(1, 
sizeof(My_Message));
   158         fprintf(stderr, 
"ERROR: could not calloc My_Message\n");
   167 _my_message_free(My_Message *msg)
   169    _eet_string_free(msg->screen_name);
   170    _eet_string_free(msg->name);
   171    _eet_string_free(msg->message);
   176 _my_post_add(My_Account *acc,
   179    int new_count = acc->posts_count + 1;
   180    My_Post *post = realloc(acc->posts, new_count * 
sizeof(My_Post));
   183         fprintf(stderr, 
"ERROR: could add My_Post\n");
   188    post[acc->posts_count].dm_to = NULL;
   189    acc->posts_count = new_count;
   195 _my_post_free(My_Post *post)
   197    _eet_string_free(post->dm_to);
   198    _eet_string_free(post->message);
   202 _my_account_new(
const char *name)
   204    My_Account *acc = calloc(1, 
sizeof(My_Account));
   207         fprintf(stderr, 
"ERROR: could not calloc My_Account\n");
   216 _my_account_free(My_Account *acc)
   221    _eet_string_free(acc->name);
   226    for (i = 0; i < acc->posts_count; i++)
   227      _my_post_free(&acc->posts[i]);
   236    My_Cache *my_cache = calloc(1, 
sizeof(My_Cache));
   239         fprintf(stderr, 
"ERROR: could not calloc My_Cache\n");
   245    my_cache->version = 1;
   250 _my_cache_account_free_cb(
const Eina_Hash *hash EINA_UNUSED,
   251                           const void      *key EINA_UNUSED,
   253                           void            *fdata EINA_UNUSED)
   255    _my_account_free(data);
   260 _my_cache_free(My_Cache *my_cache)
   268 _my_cache_account_find(My_Cache   *my_cache,
   275 _my_cache_load(
const char *filename)
   281         fprintf(stderr, 
"ERROR: could not open '%s' for read\n", filename);
   285    my_cache = 
eet_data_read(ef, _my_cache_descriptor, MY_CACHE_FILE_ENTRY);
   292    if (my_cache->version < 1)
   295                 "WARNING: version %#x was too old, upgrading it to %#x\n",
   296                 my_cache->version, 1);
   298         my_cache->version = 1;
   311 _my_cache_save(
const My_Cache *my_cache,
   312                const char     *filename)
   321    if (len + 12 >= (
int)
sizeof(tmp))
   323         fprintf(stderr, 
"ERROR: file name is too big: %s\n", filename);
   330         snprintf(tmp + len, 12, 
".%u", i);
   333    while (stat(tmp, &st) == 0);
   338         fprintf(stderr, 
"ERROR: could not open '%s' for write\n", tmp);
   343        (ef, _my_cache_descriptor, MY_CACHE_FILE_ENTRY, my_cache, 
EINA_TRUE);
   358         rename(tmp, filename);
   376                 "Usage:\n\t%s <input> <output> [action] [action-params]\n\n"   377                 "Where actions and their parameters:\n"   379                 "\tpost <account-name> <message>\n"   380                 "\tmessage <account-name> <message>\n"   388    _my_cache_descriptor_init();
   390    my_cache = _my_cache_load(argv[1]);
   393         printf(
"creating new cache.\n");
   394         my_cache = _my_cache_new();
   404         if (strcmp(argv[3], 
"acc") == 0)
   408                   My_Account *acc_ = _my_cache_account_find(my_cache, argv[4]);
   411                        acc_ = _my_account_new(argv[4]);
   415                     fprintf(stderr, 
"ERROR: account '%s' already exists.\n",
   420                        "ERROR: wrong number of parameters (%d).\n",
   423         else if (strcmp(argv[3], 
"post") == 0)
   427                   My_Account *acc_ = _my_cache_account_find(my_cache, argv[4]);
   430                        _my_post_add(acc_, argv[5]);
   433                     fprintf(stderr, 
"ERROR: unknown account: '%s'\n", argv[4]);
   437                        "ERROR: wrong number of parameters (%d).\n",
   440         else if (strcmp(argv[3], 
"message") == 0)
   444                   My_Account *acc_ = _my_cache_account_find(my_cache, argv[4]);
   447                        My_Message *msg = _my_message_new(argv[5]);
   451                     fprintf(stderr, 
"ERROR: unknown account: '%s'\n", argv[4]);
   455                        "ERROR: wrong number of parameters (%d).\n",
   459           fprintf(stderr, 
"ERROR: unknown action '%s'\n", argv[2]);
   470         printf(
"\t  > %-#8x '%.20s' stats: m=%u, p=%u\n",
   471                acc->id, acc->name ? acc->name : 
"",
   478              const My_Message *msg;
   479              printf(
"\t  |messages:\n");
   483                   printf(
"\t  |   %-8x '%s' [%s]: '%.20s'\n",
   485                          msg->name ? msg->name : 
"",
   486                          msg->screen_name ? msg->screen_name : 
"",
   487                          msg->message ? msg->message : 
"");
   491         if (acc->posts_count)
   495              printf(
"\t  |posts:\n");
   497              for (i = 0; i < acc->posts_count; i++)
   499                   post = &acc->posts[i];
   501                     printf(
"\t  |  @%s: '%.20s'\n", post->dm_to, post->message);
   503                     printf(
"\t  |  '%.20s'\n", post->message);
   511    if (!_my_cache_save(my_cache, argv[2]))
   514    _my_cache_free(my_cache);
   519    _my_cache_descriptor_shutdown();
 #define EINA_ITERATOR_FOREACH(itr, data)
Definition for the macro to iterate over all elements easily. 
Definition: eina_iterator.h:363
#define EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(edd, struct_type, name, member, subtype)
Adds a variable size array type to a data descriptor. 
Definition: Eet.h:3718
EAPI Eet_File * eet_open(const char *file, Eet_File_Mode mode)
Opens an eet file on disk, and returns a handle to it. 
Definition: eet_lib.c:1491
EAPI int eet_data_write(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name, const void *data, int compress)
Writes a data structure from memory and store in an eet file. 
Definition: eet_data.c:2414
#define EINA_FALSE
boolean value FALSE (numerical value 0) 
Definition: eina_types.h:450
struct _Eet_File Eet_File
Opaque handle that defines an Eet file (or memory). 
Definition: Eet.h:518
Eina_Bool eina_hash_direct_add(Eina_Hash *hash, const void *key, const void *data)
Adds an entry to the given hash table without duplicating the string. 
Definition: eina_hash.c:940
Eina_Hash * eina_hash_string_small_new(Eina_Free_Cb data_free_cb)
Creates a new hash table for use with strings with small bucket size. 
Definition: eina_hash.c:791
void eina_iterator_free(Eina_Iterator *iterator)
Frees an iterator. 
Definition: eina_iterator.c:96
File is read-only. 
Definition: Eet.h:475
EAPI int eet_shutdown(void)
Shuts down the EET library. 
Definition: eet_lib.c:607
EAPI int eina_init(void)
Initializes the Eina library. 
Definition: eina_main.c:247
static unsigned int eina_list_count(const Eina_List *list)
Gets the count of the number of items in a list. 
#define EET_DATA_DESCRIPTOR_ADD_HASH(edd, struct_type, name, member, subtype)
Adds a hash type to a data descriptor. 
Definition: Eet.h:3550
void eina_hash_foreach(const Eina_Hash *hash, Eina_Hash_Foreach func, const void *fdata)
Calls a function on every member stored in the hash table. 
Definition: eina_hash.c:1216
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:2112
#define EET_T_STRING
Data type: char *. 
Definition: Eet.h:2580
#define EET_T_UINT
Data type: unsigned int. 
Definition: Eet.h:2578
void eina_hash_free(Eina_Hash *hash)
Frees the given hash table resources. 
Definition: eina_hash.c:859
struct _Eet_Dictionary Eet_Dictionary
Opaque handle that defines a file-backed (mmaped) dictionary of strings. 
Definition: Eet.h:524
EAPI int eet_dictionary_string_check(Eet_Dictionary *ed, const char *string)
Checks if a given string comes from a given dictionary. 
Definition: eet_dictionary.c:489
#define EINA_TRUE
boolean value TRUE (numerical value 1) 
Definition: eina_types.h:456
EAPI int eina_shutdown(void)
Shuts down the Eina library. 
Definition: eina_main.c:315
EAPI Eina_List * eina_list_append(Eina_List *list, const void *data)
Appends the given data to the given linked list. 
Definition: eina_list.c:587
The file that provides the eet functions. 
struct _Eina_Hash Eina_Hash
Type for a generic hash table. 
Definition: eina_hash.h:288
File is write-only. 
Definition: Eet.h:476
EAPI size_t eina_strlcpy(char *dst, const char *src, size_t siz) EINA_ARG_NONNULL(1
Copies a c-string to another. 
EAPI void * eet_data_read(Eet_File *ef, Eet_Data_Descriptor *edd, const char *name)
Reads a data structure from an eet file and decodes it. 
Definition: eet_data.c:2379
void eina_stringshare_del(Eina_Stringshare *str)
Notes that the given string has lost an instance. 
Definition: eina_stringshare.c:537
Instructs Eet about memory management for different needs under serialization and parse process...
Definition: Eet.h:2818
unsigned char Eina_Bool
Type to mimic a boolean. 
Definition: eina_types.h:444
#define EINA_LIST_FOREACH(list, l, _data)
Definition for the macro to iterate over a list. 
Definition: eina_list.h:1414
#define EET_DATA_DESCRIPTOR_ADD_LIST(edd, struct_type, name, member, subtype)
Adds a linked list type to a data descriptor. 
Definition: Eet.h:3500
EAPI Eet_Error eet_close(Eet_File *ef)
Closes an eet file handle and flush pending writes. 
Definition: eet_lib.c:1891
struct _Eet_Data_Descriptor Eet_Data_Descriptor
Opaque handle that have information on a type members. 
Definition: Eet.h:2622
#define EINA_LIST_FREE(list, data)
Definition for the macro to remove each list node while having access to each node's data...
Definition: eina_list.h:1640
void * eina_hash_find(const Eina_Hash *hash, const void *key)
Retrieves a specific entry in the given hash table. 
Definition: eina_hash.c:1062
Eina_Iterator * eina_hash_iterator_data_new(const Eina_Hash *hash)
Returns a new iterator associated to hash data. 
Definition: eina_hash.c:1239
EAPI Eet_Data_Descriptor * eet_data_descriptor_file_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:2098
structure of an iterator 
Definition: eina_iterator.h:158
int eina_hash_population(const Eina_Hash *hash)
Returns the number of entries in the given hash table. 
Definition: eina_hash.c:849
Type for a generic double linked list. 
Definition: eina_list.h:320
Eina_Stringshare * eina_stringshare_add(const char *str)
Retrieves an instance of a string for use in a program. 
Definition: eina_stringshare.c:610
#define EET_EINA_FILE_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:3066
EAPI Eet_Dictionary * eet_dictionary_get(Eet_File *ef)
Returns a handle to the shared string dictionary of the Eet file. 
Definition: eet_lib.c:2552
EAPI int eet_init(void)
Initializes the EET library. 
Definition: eet_lib.c:553