forked from enlightenment/efl
parent
0ca47806af
commit
cf8a61527f
|
@ -52,3 +52,8 @@
|
|||
2012-10-19 Cedric Bail
|
||||
|
||||
* Add eina_thread API.
|
||||
|
||||
2012-10-31 Cedric Bail
|
||||
|
||||
* Add eet_list_entries().
|
||||
* Add eet -l -v to give more information about an eet file.
|
||||
|
|
1
NEWS
1
NEWS
|
@ -15,6 +15,7 @@ Improvements:
|
|||
* Single EFL tree now covring all EFL library components.
|
||||
* Speedup Eina Rbtree Iterator by recycling memory instead of
|
||||
massively calling malloc/free.
|
||||
* Display more information with eet -l -v.
|
||||
|
||||
Fixes:
|
||||
* Fix PPC (big endian) image codec bug.
|
||||
|
|
|
@ -44,11 +44,12 @@ static int _eet_main_log_dom = -1;
|
|||
#define CRIT(...) EINA_LOG_DOM_CRIT(_eet_main_log_dom, __VA_ARGS__)
|
||||
|
||||
static void
|
||||
do_eet_list(const char *file)
|
||||
do_eet_list(const char *file, Eina_Bool verbose)
|
||||
{
|
||||
int i, num;
|
||||
char **list;
|
||||
Eina_Iterator *it;
|
||||
Eet_Entry *entry;
|
||||
Eet_File *ef;
|
||||
unsigned long long total = 0;
|
||||
|
||||
ef = eet_open(file, EET_FILE_MODE_READ);
|
||||
if (!ef)
|
||||
|
@ -57,12 +58,38 @@ do_eet_list(const char *file)
|
|||
exit(-1);
|
||||
}
|
||||
|
||||
list = eet_list(ef, "*", &num);
|
||||
if (list)
|
||||
it = eet_list_entries(ef);
|
||||
EINA_ITERATOR_FOREACH(it, entry)
|
||||
{
|
||||
for (i = 0; i < num; i++)
|
||||
printf("%s\n", list[i]);
|
||||
free(list);
|
||||
if (verbose)
|
||||
{
|
||||
if (entry->alias)
|
||||
{
|
||||
printf("%s is an alias for %s\n",
|
||||
entry->name, eet_alias_get(ef, entry->name));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entry->compression)
|
||||
printf("%s start at %i with a size of %i Bytes with an uncompressed size of %i Bytes.\n",
|
||||
entry->name, entry->offset, entry->size, entry->data_size);
|
||||
else
|
||||
printf("%s start at %i with a size of %i Bytes.\n",
|
||||
entry->name, entry->offset, entry->size);
|
||||
total += entry->size;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("%s\n", entry->name);
|
||||
}
|
||||
}
|
||||
eina_iterator_free(it);
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
printf("*** ***\n");
|
||||
printf("Total payload size : %lli.\n", total);
|
||||
}
|
||||
|
||||
eet_close(ef);
|
||||
|
@ -415,7 +442,7 @@ main(int argc,
|
|||
help:
|
||||
printf(
|
||||
"Usage:\n"
|
||||
" eet -l FILE.EET list all keys in FILE.EET\n"
|
||||
" eet -l [-v] FILE.EET list all keys in FILE.EET\n"
|
||||
" eet -x FILE.EET KEY [OUT-FILE] [CRYPTO_KEY] extract data stored in KEY in FILE.EET and write to OUT-FILE or standard output\n"
|
||||
" eet -d FILE.EET KEY [OUT-FILE] [CRYPTO_KEY] extract and decode data stored in KEY in FILE.EET and write to OUT-FILE or standard output\n"
|
||||
" eet -i FILE.EET KEY IN-FILE COMPRESS [CRYPTO_KEY] insert data to KEY in FILE.EET from IN-FILE and if COMPRESS is 1, compress it\n"
|
||||
|
@ -431,8 +458,15 @@ help:
|
|||
|
||||
if ((!strncmp(argv[1], "-h", 2)))
|
||||
goto help;
|
||||
else if ((!strcmp(argv[1], "-l")) && (argc > 2))
|
||||
do_eet_list(argv[2]);
|
||||
else if (((!strcmp(argv[1], "-l")) || (!strcmp(argv[1], "-v"))) && (argc > 2))
|
||||
{
|
||||
if (argc == 3)
|
||||
do_eet_list(argv[2], EINA_FALSE);
|
||||
else if ((!strcmp(argv[2], "-l")) || (!strcmp(argv[2], "-v")))
|
||||
do_eet_list(argv[3], EINA_TRUE);
|
||||
else
|
||||
goto help;
|
||||
}
|
||||
else if ((!strcmp(argv[1], "-x")) && (argc > 3))
|
||||
{
|
||||
switch (argc)
|
||||
|
|
|
@ -537,6 +537,27 @@ typedef struct _Eet_File Eet_File;
|
|||
*/
|
||||
typedef struct _Eet_Dictionary Eet_Dictionary;
|
||||
|
||||
/**
|
||||
* @typedef Eet_Entries
|
||||
* Eet files may contains multiple Entries per file, this handle describe them. You can get that handle from an iterator given by eet_list_entries().
|
||||
*
|
||||
* @see eet_list_entries()
|
||||
* @since 1.8.0
|
||||
*/
|
||||
typedef struct _Eet_Entry Eet_Entry;
|
||||
struct _Eet_Entry
|
||||
{
|
||||
const char *name; /**< The entry name */
|
||||
|
||||
int offset; /**< Where it start in the file */
|
||||
int size; /**< The size on disk */
|
||||
int data_size; /**< The decompressed size if relevant */
|
||||
|
||||
Eina_Bool compression; /**< Is this data compressed ? */
|
||||
Eina_Bool ciphered; /**< Is it ciphered ? */
|
||||
Eina_Bool alias; /**< Is it an alias ? */
|
||||
};
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
@ -891,6 +912,17 @@ eet_list(Eet_File *ef,
|
|||
const char *glob,
|
||||
int *count_ret);
|
||||
|
||||
/**
|
||||
* Return an iterator that will describe each entry of an Eet_File.
|
||||
* @param ef A valid eet file handle.
|
||||
* @return An interator of Eet_Entry.
|
||||
*
|
||||
* @since 1.8.0
|
||||
* @ingroup Eet_File_Group
|
||||
*/
|
||||
|
||||
EAPI Eina_Iterator *eet_list_entries(Eet_File *ef);
|
||||
|
||||
/**
|
||||
* Return the number of entries in the specified eet file.
|
||||
* @param ef A valid eet file handle.
|
||||
|
|
|
@ -63,9 +63,6 @@ GCRY_THREAD_OPTION_PTHREAD_IMPL;
|
|||
# endif /* ifdef HAVE_GNUTLS */
|
||||
#endif /* ifdef EINA_HAVE_THREADS */
|
||||
|
||||
/* this has to be here until 2.0 */
|
||||
#define EET_OLD_EET_FILE_FORMAT 1
|
||||
|
||||
#include "Eet.h"
|
||||
#include "Eet_private.h"
|
||||
|
||||
|
@ -1045,7 +1042,7 @@ eet_internal_read2(Eet_File *ef)
|
|||
return ef;
|
||||
}
|
||||
|
||||
#ifdef EET_OLD_EET_FILE_FORMAT
|
||||
#if EET_OLD_EET_FILE_FORMAT
|
||||
static Eet_File *
|
||||
eet_internal_read1(Eet_File *ef)
|
||||
{
|
||||
|
@ -1227,7 +1224,7 @@ eet_internal_read1(Eet_File *ef)
|
|||
return ef;
|
||||
}
|
||||
|
||||
#endif /* ifdef EET_OLD_EET_FILE_FORMAT */
|
||||
#endif /* if EET_OLD_EET_FILE_FORMAT */
|
||||
|
||||
/*
|
||||
* this should only be called when the cache lock is already held
|
||||
|
@ -1248,11 +1245,11 @@ eet_internal_read(Eet_File *ef)
|
|||
|
||||
switch (ntohl(*data))
|
||||
{
|
||||
#ifdef EET_OLD_EET_FILE_FORMAT
|
||||
#if EET_OLD_EET_FILE_FORMAT
|
||||
case EET_MAGIC_FILE:
|
||||
return eet_internal_read1(ef);
|
||||
|
||||
#endif /* ifdef EET_OLD_EET_FILE_FORMAT */
|
||||
#endif /* if EET_OLD_EET_FILE_FORMAT */
|
||||
case EET_MAGIC_FILE2:
|
||||
return eet_internal_read2(ef);
|
||||
|
||||
|
@ -2678,6 +2675,122 @@ eet_num_entries(Eet_File *ef)
|
|||
return ret;
|
||||
}
|
||||
|
||||
typedef struct _Eet_Entries_Iterator Eet_Entries_Iterator;
|
||||
struct _Eet_Entries_Iterator
|
||||
{
|
||||
Eina_Iterator iterator;
|
||||
|
||||
Eet_File *ef;
|
||||
Eet_File_Node *efn;
|
||||
int index;
|
||||
|
||||
Eet_Entry entry;
|
||||
|
||||
Eina_Bool locked;
|
||||
};
|
||||
|
||||
Eina_Bool
|
||||
_eet_entries_iterator_next(Eet_Entries_Iterator *it, void **data)
|
||||
{
|
||||
if (it->efn == NULL)
|
||||
{
|
||||
int num;
|
||||
|
||||
num = (1 << it->ef->header->directory->size);
|
||||
|
||||
do
|
||||
{
|
||||
it->index++;
|
||||
|
||||
if (!(it->index < num))
|
||||
return EINA_FALSE;
|
||||
|
||||
it->efn = it->ef->header->directory->nodes[it->index];
|
||||
}
|
||||
while (!it->efn);
|
||||
}
|
||||
|
||||
/* copy info in public header */
|
||||
it->entry.name = it->efn->name;
|
||||
it->entry.offset = it->efn->offset;
|
||||
it->entry.size = it->efn->size;
|
||||
it->entry.data_size = it->efn->data_size;
|
||||
it->entry.compression = it->efn->compression;
|
||||
it->entry.ciphered = it->efn->ciphered;
|
||||
it->entry.alias = it->efn->alias;
|
||||
|
||||
*data = &it->entry;
|
||||
it->efn = it->efn->next;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
void *
|
||||
_eet_entries_iterator_container(Eet_Entries_Iterator *it)
|
||||
{
|
||||
return it->ef;
|
||||
}
|
||||
|
||||
void
|
||||
_eet_entries_iterator_free(Eet_Entries_Iterator *it)
|
||||
{
|
||||
if (it->locked)
|
||||
{
|
||||
CRIT("Iterator still LOCKED !");
|
||||
UNLOCK_FILE(it->ef);
|
||||
}
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
_eet_entries_iterator_lock(Eet_Entries_Iterator *it)
|
||||
{
|
||||
if (it->locked)
|
||||
{
|
||||
CRIT("Iterator already LOCKED !");
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
LOCK_FILE(it->ef);
|
||||
it->locked = EINA_TRUE;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
Eina_Bool
|
||||
_eet_entries_iterator_unlock(Eet_Entries_Iterator *it)
|
||||
{
|
||||
if (!it->locked)
|
||||
{
|
||||
CRIT("Iterator already UNLOCKED !");
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
UNLOCK_FILE(it->ef);
|
||||
it->locked = EINA_FALSE;
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EAPI Eina_Iterator *
|
||||
eet_list_entries(Eet_File *ef)
|
||||
{
|
||||
Eet_Entries_Iterator *it;
|
||||
|
||||
it = malloc(sizeof (Eet_Entries_Iterator));
|
||||
if (!it) return NULL;
|
||||
|
||||
EINA_MAGIC_SET(&it->iterator, EINA_MAGIC_ITERATOR);
|
||||
it->ef = ef;
|
||||
it->efn = NULL;
|
||||
it->index = -1;
|
||||
it->locked = EINA_FALSE;
|
||||
it->iterator.version = EINA_ITERATOR_VERSION;
|
||||
it->iterator.next = FUNC_ITERATOR_NEXT(_eet_entries_iterator_next);
|
||||
it->iterator.get_container = FUNC_ITERATOR_GET_CONTAINER(_eet_entries_iterator_container);
|
||||
it->iterator.free = FUNC_ITERATOR_FREE(_eet_entries_iterator_free);
|
||||
it->iterator.lock = FUNC_ITERATOR_LOCK(_eet_entries_iterator_lock);
|
||||
it->iterator.unlock = FUNC_ITERATOR_LOCK(_eet_entries_iterator_unlock);
|
||||
|
||||
return &it->iterator;
|
||||
}
|
||||
|
||||
static Eet_File_Node *
|
||||
find_node_by_name(Eet_File *ef,
|
||||
const char *name)
|
||||
|
|
Loading…
Reference in New Issue