[Pkg-e-commits] [SCM] Enlightenment DR17 file chunk reading/writing library branch, master, updated. debian/1.0.1-1-616-g7d4cc9c
Albin Tonnerre
albin.tonnerre at gmail.com
Fri Jun 19 10:51:56 UTC 2009
The following commit has been merged in the master branch:
commit afbc933ba4e29455339c8a094f91a59462e447fe
Author: Albin Tonnerre <albin.tonnerre at gmail.com>
Date: Fri Jun 19 12:05:33 2009 +0200
Import upstream release 1.2.1
diff --git a/ChangeLog b/ChangeLog
index 54dfd51..11de2be 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -173,3 +173,16 @@
2009-04-22 Carsten Haitzler (The Rasterman)
* Release eet 1.2.0
+
+2009-05-18 Cedric BAIL
+
+ * Cleanup Eet_Data code.
+
+2009-06-02 Cedric BAIL
+
+ * Make eet_node API usable.
+
+2009-06-14 Carsten Haitzler (The Rasterman)
+
+ * Release eet 1.2.1
+
diff --git a/README b/README
index 89e6add..5e2cf59 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Eet 1.2.0
+Eet 1.2.1
Requirements:
-------------
@@ -38,7 +38,7 @@ BUILDING PACKAGES:
RPM: To build rpm packages:
- sudo rpm -ta eet-1.2.0.tar.gz
+ sudo rpm -ta eet-1.2.1.tar.gz
You will find rpm packages in your system /usr/src/redhat/* dirs (note you may
not need to use sudo or root if you have your own ~/.rpmrc. see rpm documents
diff --git a/configure b/configure
index 9dd7ca2..805d1db 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.61 for eet 1.2.0.
+# Generated by GNU Autoconf 2.61 for eet 1.2.1.
#
# Report bugs to <enlightenment-devel at lists.sourceforge.net>.
#
@@ -723,8 +723,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='eet'
PACKAGE_TARNAME='eet'
-PACKAGE_VERSION='1.2.0'
-PACKAGE_STRING='eet 1.2.0'
+PACKAGE_VERSION='1.2.1'
+PACKAGE_STRING='eet 1.2.1'
PACKAGE_BUGREPORT='enlightenment-devel at lists.sourceforge.net'
ac_unique_file="configure.ac"
@@ -1428,7 +1428,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures eet 1.2.0 to adapt to many kinds of systems.
+\`configure' configures eet 1.2.1 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1498,7 +1498,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of eet 1.2.0:";;
+ short | recursive ) echo "Configuration of eet 1.2.1:";;
esac
cat <<\_ACEOF
@@ -1624,7 +1624,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-eet configure 1.2.0
+eet configure 1.2.1
generated by GNU Autoconf 2.61
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1638,7 +1638,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by eet $as_me 1.2.0, which was
+It was created by eet $as_me 1.2.1, which was
generated by GNU Autoconf 2.61. Invocation command line was
$ $0 $@
@@ -3480,7 +3480,7 @@ fi
# Define the identity of the package.
PACKAGE='eet'
- VERSION='1.2.0'
+ VERSION='1.2.1'
cat >>confdefs.h <<_ACEOF
@@ -12460,10 +12460,14 @@ if test "${enable_doc+set}" = set; then
else
efl_enable_doc="yes"
-
fi
+{ echo "$as_me:$LINENO: checking whether to build documentation" >&5
+echo $ECHO_N "checking whether to build documentation... $ECHO_C" >&6; }
+{ echo "$as_me:$LINENO: result: ${efl_enable_doc}" >&5
+echo "${ECHO_T}${efl_enable_doc}" >&6; }
+
if test "x${efl_enable_doc}" = "xyes" ; then
@@ -12514,11 +12518,11 @@ fi
if test "x${efl_have_doxygen}" = "xno" ; then
echo "WARNING:"
echo "The doxygen program you specified:"
- echo "$efl_doxygen"
+ echo "${efl_doxygen}"
echo "was not found. Please check the path and make sure "
echo "the program exists and is executable."
- { echo "$as_me:$LINENO: WARNING: Warning: no doxygen detected. Documentation will not be built" >&5
-echo "$as_me: WARNING: Warning: no doxygen detected. Documentation will not be built" >&2;}
+ { echo "$as_me:$LINENO: WARNING: no doxygen detected. Documentation will not be built" >&5
+echo "$as_me: WARNING: no doxygen detected. Documentation will not be built" >&2;}
fi
else
@@ -12562,18 +12566,17 @@ fi
if test "x${efl_have_doxygen}" = "xno" ; then
echo "WARNING:"
- echo "The doxygen program was not found in your execute"
+ echo "The doxygen program was not found in your execute path."
echo "You may have doxygen installed somewhere not covered by your path."
echo ""
echo "If this is the case make sure you have the packages installed, AND"
echo "that the doxygen program is in your execute path (see your"
echo "shell manual page on setting the \$PATH environment variable), OR"
echo "alternatively, specify the program to use with --with-doxygen."
- { echo "$as_me:$LINENO: WARNING: Warning: no doxygen detected. Documentation will not be built" >&5
-echo "$as_me: WARNING: Warning: no doxygen detected. Documentation will not be built" >&2;}
+ { echo "$as_me:$LINENO: WARNING: no doxygen detected. Documentation will not be built" >&5
+echo "$as_me: WARNING: no doxygen detected. Documentation will not be built" >&2;}
fi
-
fi
fi
@@ -15624,7 +15627,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by eet $as_me 1.2.0, which was
+This file was extended by eet $as_me 1.2.1, which was
generated by GNU Autoconf 2.61. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -15677,7 +15680,7 @@ Report bugs to <bug-autoconf at gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF
ac_cs_version="\\
-eet config.status 1.2.0
+eet config.status 1.2.1
configured by $0, generated by GNU Autoconf 2.61,
with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
diff --git a/configure.ac b/configure.ac
index 40de32f..81e8e38 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
# get rid of that stupid cache mechanism
rm -f config.cache
-AC_INIT([eet], [1.2.0], [enlightenment-devel at lists.sourceforge.net])
+AC_INIT([eet], [1.2.1], [enlightenment-devel at lists.sourceforge.net])
AC_PREREQ([2.52])
AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_MACRO_DIR([m4])
diff --git a/eet.spec b/eet.spec
index a80161f..df3298e 100644
--- a/eet.spec
+++ b/eet.spec
@@ -2,7 +2,7 @@
Summary: Library for speedy data storage, retrieval, and compression.
Name: eet
-Version: 1.2.0
+Version: 1.2.1
Release: 0.%(date '+%Y%m%d')
License: BSD
Group: System Environment/Libraries
diff --git a/m4/efl_doxygen.m4 b/m4/efl_doxygen.m4
index 0c1452f..dd6bc3e 100644
--- a/m4/efl_doxygen.m4
+++ b/m4/efl_doxygen.m4
@@ -25,13 +25,15 @@ AC_ARG_ENABLE([doc],
efl_enable_doc="no"
fi
],
- [efl_enable_doc="yes"]
-)
+ [efl_enable_doc="yes"])
+
+AC_MSG_CHECKING([whether to build documentation])
+AC_MSG_RESULT([${efl_enable_doc}])
if test "x${efl_enable_doc}" = "xyes" ; then
dnl
-dnl Specify the full file name, with path
+dnl Specify the file name, without path
dnl
efl_doxygen="doxygen"
@@ -51,10 +53,10 @@ dnl
if test "x${efl_have_doxygen}" = "xno" ; then
echo "WARNING:"
echo "The doxygen program you specified:"
- echo "$efl_doxygen"
+ echo "${efl_doxygen}"
echo "was not found. Please check the path and make sure "
echo "the program exists and is executable."
- AC_MSG_WARN([Warning: no doxygen detected. Documentation will not be built])
+ AC_MSG_WARN([no doxygen detected. Documentation will not be built])
fi
],
[AC_CHECK_PROG([efl_have_doxygen],
@@ -63,17 +65,16 @@ dnl
[no])
if test "x${efl_have_doxygen}" = "xno" ; then
echo "WARNING:"
- echo "The doxygen program was not found in your execute"
+ echo "The doxygen program was not found in your execute path."
echo "You may have doxygen installed somewhere not covered by your path."
echo ""
echo "If this is the case make sure you have the packages installed, AND"
echo "that the doxygen program is in your execute path (see your"
echo "shell manual page on setting the \$PATH environment variable), OR"
echo "alternatively, specify the program to use with --with-doxygen."
- AC_MSG_WARN([Warning: no doxygen detected. Documentation will not be built])
+ AC_MSG_WARN([no doxygen detected. Documentation will not be built])
fi
- ]
- )
+ ])
fi
dnl
@@ -88,9 +89,9 @@ fi
AM_CONDITIONAL(EFL_BUILD_DOC, test "x${efl_enable_doc}" = "xyes")
if test "x${efl_enable_doc}" = "xyes" ; then
- ifelse([$1], , :, [$1])
+ m4_default([$1], [:])
else
- ifelse([$2], , :, [$2])
+ m4_default([$2], [:])
fi
])
diff --git a/src/lib/Eet.h b/src/lib/Eet.h
index 79e64bd..30d6881 100644
--- a/src/lib/Eet.h
+++ b/src/lib/Eet.h
@@ -1367,13 +1367,14 @@ eet_dictionary_string_check * example: values), and @p type is the basic data
EAPI Eet_Node *eet_node_unsigned_char_new(const char *name, unsigned char uc);
EAPI Eet_Node *eet_node_unsigned_short_new(const char *name, unsigned short us);
EAPI Eet_Node *eet_node_unsigned_int_new(const char *name, unsigned int ui);
+ EAPI Eet_Node *eet_node_unsigned_long_long_new(const char *name, unsigned long long l);
EAPI Eet_Node *eet_node_string_new(const char *name, const char *str);
EAPI Eet_Node *eet_node_inlined_string_new(const char *name, const char *str);
EAPI Eet_Node *eet_node_null_new(const char *name);
EAPI Eet_Node *eet_node_list_new(const char *name, Eina_List *nodes);
EAPI Eet_Node *eet_node_array_new(const char *name, int count, Eina_List *nodes);
- EAPI Eet_Node *eet_node_var_array_new(const char *name, int count, Eina_List *nodes);
- EAPI Eet_Node *eet_node_hash_new(const char *name, const char *key, Eina_List *nodes);
+ EAPI Eet_Node *eet_node_var_array_new(const char *name, Eina_List *nodes);
+ EAPI Eet_Node *eet_node_hash_new(const char *name, const char *key, Eet_Node *node);
EAPI Eet_Node *eet_node_struct_new(const char *name, Eina_List *nodes);
EAPI void eet_node_del(Eet_Node *n);
diff --git a/src/lib/eet_data.c b/src/lib/eet_data.c
index 8df4b75..452c435 100644
--- a/src/lib/eet_data.c
+++ b/src/lib/eet_data.c
@@ -219,6 +219,13 @@ static void *eet_data_put_null(Eet_Dictionary *ed, const void *src, int *size_re
static int eet_data_get_type(const Eet_Dictionary *ed, int type, const void *src, const void *src_end, void *dest);
static void *eet_data_put_type(Eet_Dictionary *ed, int type, const void *src, int *size_ret);
+static void eet_data_dump_group_start(int level, void (*dumpfunc) (void *data, const char *str), void *dumpdata, int group_type, const char *name);
+static void eet_data_dump_group_end(int level, void (*dumpfunc) (void *data, const char *str), void *dumpdata);
+static void eet_data_dump_level(int level, void (*dumpfunc) (void *data, const char *str), void *dumpdata);
+static void eet_data_dump_simple_type(int type, const char *name, void *dd,
+ int level, void (*dumpfunc) (void *data, const char *str), void *dumpdata);
+
+
static int eet_data_get_unknown(Eet_Free_Context *context, const Eet_Dictionary *ed, Eet_Data_Descriptor *edd, Eet_Data_Element *ede, Eet_Data_Chunk *echnk, int type, int group_type, void *data_in, int level, void (*dumpfunc) (void *data, const char *str), void *dumpdata, char **p, int *size);
static void eet_data_put_unknown(Eet_Dictionary *ed, Eet_Data_Descriptor *edd, Eet_Data_Element *ede, Eet_Data_Stream *ds, void *data_in);
static void eet_data_put_array(Eet_Dictionary *ed, Eet_Data_Descriptor *edd, Eet_Data_Element *ede, Eet_Data_Stream *ds, void *data_in);
@@ -732,31 +739,17 @@ eet_data_chunk_get(const Eet_Dictionary *ed, Eet_Data_Chunk *chnk,
const char *s;
int ret1, ret2;
- if (!src)
- {
- fprintf(stderr, "stiouf -3\n");
- return;
- }
- if (size <= 8)
- {
- fprintf(stderr, "stiouf -2 %i\n", size);
- return;
- }
+ if (!src) return;
+ if (size <= 8) return;
- if (!chnk)
- {
- fprintf(stderr, "stiouf -1\n");
- return;
- }
+ if (!chnk) return;
s = src;
if (s[2] == 'K')
{
if ((s[0] != 'C') || (s[1] != 'H') || (s[2] != 'K'))
- {
- fprintf(stderr, "stiouf 0\n");
- return;
- }
+ return;
+
chnk->type = (unsigned char)(s[3]);
if (chnk->type > EET_T_LAST)
{
@@ -775,28 +768,13 @@ eet_data_chunk_get(const Eet_Dictionary *ed, Eet_Data_Chunk *chnk,
else
{
if ((s[0] != 'C') || (s[1] != 'H') || (s[2] != 'n') || (s[3] != 'K'))
- {
- fprintf(stderr, "stiouf 1\n");
- return;
- }
+ return;
}
ret1 = eet_data_get_type(ed, EET_T_INT, (s + 4), (s + size), &(chnk->size));
- if (ret1 <= 0)
- {
- fprintf(stderr, "stiouf 2\n");
- return;
- }
- if ((chnk->size < 0) || ((chnk->size + 8) > size))
- {
- fprintf(stderr, "stiouf 3\n");
- return;
- }
+ if (ret1 <= 0) return;
+ if ((chnk->size < 0) || ((chnk->size + 8) > size)) return;
ret2 = eet_data_get_type(ed, EET_T_STRING, (s + 8), (s + size), &(chnk->name));
- if (ret2 <= 0)
- {
- fprintf(stderr, "stiouf 4\n");
- return;
- }
+ if (ret2 <= 0) return;
chnk->len = ret2;
@@ -1693,6 +1671,8 @@ _eet_data_dump_encode(Eet_Dictionary *ed,
else words_bigendian = 0;
}
+ if (node == NULL) return NULL;
+
ds = eet_data_stream_new();
if (!ds) return NULL;
@@ -2199,9 +2179,8 @@ _eet_data_descriptor_decode(Eet_Free_Context *context,
void *dumpdata)
{
void *data = NULL;
- char *p, tbuf[256];
+ char *p;
int size, i, dump;
- int chnk_type;
Eet_Data_Chunk chnk;
if (words_bigendian == -1)
@@ -2247,23 +2226,15 @@ _eet_data_descriptor_decode(Eet_Free_Context *context,
{
dump = 1;
if (chnk.type == EET_T_UNKNOW)
- {
- for (i = 0; i < level; i++) dumpfunc(dumpdata, " ");
- dumpfunc(dumpdata, "group \"");
- _eet_data_dump_string_escape(dumpdata, dumpfunc, chnk.name);
- dumpfunc(dumpdata, "\" ");
-
- chnk_type = (chnk.group_type >= EET_G_UNKNOWN && chnk.group_type <= EET_G_HASH) ?
- chnk.group_type : EET_G_LAST;
-
- dumpfunc(dumpdata, _dump_g_name[chnk_type - EET_G_UNKNOWN]);
- dumpfunc(dumpdata, " {\n");
- }
+ eet_data_dump_group_start(level, dumpfunc, dumpdata, chnk.group_type, chnk.name);
}
while (size > 0)
{
Eet_Data_Chunk echnk;
- Eet_Data_Element *ede;
+ Eet_Data_Element *ede = NULL;
+ unsigned char dd[128];
+ int group_type = EET_G_UNKNOWN, type = EET_T_UNKNOW;
+ int ret = 0;
/* get next data chunk */
memset(&echnk, 0, sizeof(Eet_Data_Chunk));
@@ -2275,9 +2246,6 @@ _eet_data_descriptor_decode(Eet_Free_Context *context,
ede = _eet_descriptor_hash_find(edd, echnk.name, echnk.hash);
if (ede)
{
- int group_type = EET_G_UNKNOWN, type = EET_T_UNKNOW;
- int ret = 0;
-
group_type = ede->group_type;
type = ede->type;
if ((echnk.type == 0) && (echnk.group_type == 0))
@@ -2295,244 +2263,43 @@ _eet_data_descriptor_decode(Eet_Free_Context *context,
(echnk.group_type == ede->group_type))
group_type = echnk.group_type;
}
- /* hashes doesnt fit well with the table */
- ret = eet_group_codec[group_type - 100].get(context, ed, edd, ede, &echnk, type, group_type, ((char *)data) + ede->offset, level, dumpfunc, dumpdata, &p, &size);
- if (ret <= 0) goto error;
}
}
/*...... dump func */
else if (dumpfunc)
{
- unsigned char dd[128];
- int group_type = EET_G_UNKNOWN, type = EET_T_UNKNOW;
-
if ((echnk.type > EET_T_UNKNOW) &&
(echnk.type < EET_T_LAST))
type = echnk.type;
else if ((echnk.group_type > EET_G_UNKNOWN) &&
(echnk.group_type < EET_G_LAST))
group_type = echnk.group_type;
- if (group_type == EET_G_UNKNOWN)
- {
- int ret;
- void *data_ret;
-
- if (IS_SIMPLE_TYPE(type))
- {
- const char *type_name = NULL;
-
- ret = eet_data_get_type(ed,
- type,
- echnk.data,
- ((char *)echnk.data) + echnk.size,
- dd);
- if (ret <= 0) goto error;
-
- for (i = 0; i < level; i++) dumpfunc(dumpdata, " ");
- dumpfunc(dumpdata, " value \"");
- _eet_data_dump_string_escape(dumpdata, dumpfunc, echnk.name);
- dumpfunc(dumpdata, "\" ");
-
-#define EET_T_TYPE(Eet_Type, Type) \
- case Eet_Type: \
- { \
- dumpfunc(dumpdata, _dump_t_name[Eet_Type][0]); \
- snprintf(tbuf, sizeof (tbuf), _dump_t_name[Eet_Type][1], *((Type *)dd)); \
- dumpfunc(dumpdata, tbuf); \
- break; \
- }
-
- switch (type)
- {
- EET_T_TYPE(EET_T_CHAR, char);
- EET_T_TYPE(EET_T_SHORT, short);
- EET_T_TYPE(EET_T_INT, int);
- EET_T_TYPE(EET_T_LONG_LONG, long long);
- EET_T_TYPE(EET_T_FLOAT, float);
- EET_T_TYPE(EET_T_DOUBLE, double);
- EET_T_TYPE(EET_T_UCHAR, unsigned char);
- EET_T_TYPE(EET_T_USHORT, unsigned short);
- EET_T_TYPE(EET_T_UINT, unsigned int);
- EET_T_TYPE(EET_T_ULONG_LONG, unsigned long long);
- case EET_T_INLINED_STRING:
- type_name = "inlined: \"";
- case EET_T_STRING:
- if (!type_name) type_name = "string: \"";
-
- {
- char *s;
-
- s = *((char **)dd);
- if (s)
- {
- dumpfunc(dumpdata, type_name);
- _eet_data_dump_string_escape(dumpdata, dumpfunc, s);
- dumpfunc(dumpdata, "\"");
- }
- }
- break;
- case EET_T_NULL:
- dumpfunc(dumpdata, "null");
- break;
- default:
- dumpfunc(dumpdata, "???: ???"); break;
- break;
- }
- dumpfunc(dumpdata, ";\n");
- }
- else
- {
- data_ret = _eet_data_descriptor_decode(context,
- ed,
- NULL,
- echnk.data,
- echnk.size,
- level + 1,
- dumpfunc,
- dumpdata);
- if (!data_ret) goto error;
- }
- }
- else
- {
- for (i = 0; i < level; i++) dumpfunc(dumpdata, " ");
- dumpfunc(dumpdata, " group \"");
- _eet_data_dump_string_escape(dumpdata, dumpfunc, echnk.name);
- dumpfunc(dumpdata, "\" ");
-
- chnk_type = (echnk.group_type >= EET_G_UNKNOWN && echnk.group_type <= EET_G_HASH) ?
- echnk.group_type : EET_G_LAST;
+ }
- dumpfunc(dumpdata, _dump_g_name[chnk_type - EET_G_UNKNOWN]);
- dumpfunc(dumpdata, " {\n");
- switch (group_type)
- {
- case EET_G_ARRAY:
- case EET_G_VAR_ARRAY:
- {
- int count;
- int ret;
- int i;
-
- EET_ASSERT(!IS_SIMPLE_TYPE(type), goto error);
-
- ret = eet_data_get_type(ed,
- EET_T_INT,
- echnk.data,
- ((char *)echnk.data) + echnk.size,
- &count);
- if (ret <= 0) goto error;
-
- for (i = 0; i < level; i++) dumpfunc(dumpdata, " ");
- dumpfunc(dumpdata, " count ");
- snprintf(tbuf, sizeof(tbuf), "%i", count);
- dumpfunc(dumpdata, tbuf);
- dumpfunc(dumpdata, ";\n");
-
- /* get all array elements */
- for (i = 0; i < count; i++)
- {
- void *data_ret = NULL;
-
- /* Advance to next chunk */
- NEXT_CHUNK(p, size, echnk, ed);
- memset(&echnk, 0, sizeof(Eet_Data_Chunk));
-
- eet_data_chunk_get(ed, &echnk, p, size);
- if (!echnk.name) goto error;
- /* get the data */
- data_ret = _eet_data_descriptor_decode(context,
- ed,
- NULL,
- echnk.data,
- echnk.size,
- level + 2,
- dumpfunc,
- dumpdata);
- if (!data_ret) goto error;
- }
- }
- break;
- case EET_G_LIST:
- {
- void *data_ret = NULL;
-
- EET_ASSERT(!IS_SIMPLE_TYPE(type), goto error);
-
- data_ret = _eet_data_descriptor_decode(context,
- ed,
- NULL,
- echnk.data,
- echnk.size,
- level + 2,
- dumpfunc,
- dumpdata);
- if (!data_ret) goto error;
- }
- break;
- case EET_G_HASH:
- {
- int ret;
- char *key = NULL;
- void *data_ret = NULL;
-
- /* Read key */
- ret = eet_data_get_type(ed,
- EET_T_STRING,
- echnk.data,
- ((char *)echnk.data) + echnk.size,
- &key);
- if (ret <= 0) goto error;
-
- /* Advance to next chunk */
- NEXT_CHUNK(p, size, echnk, ed);
- memset(&echnk, 0, sizeof(Eet_Data_Chunk));
-
- /* Read value */
- eet_data_chunk_get(ed, &echnk, p, size);
- if (!echnk.name) goto error;
-
- EET_ASSERT(!IS_SIMPLE_TYPE(type), goto error);
-
- {
- char *s;
-
- s = key;
- if (s)
- {
- for (i = 0; i < level; i++) dumpfunc(dumpdata, " ");
- dumpfunc(dumpdata, " key \"");
- _eet_data_dump_string_escape(dumpdata, dumpfunc, s);
- dumpfunc(dumpdata, "\";\n");
- }
- data_ret = _eet_data_descriptor_decode(context,
- ed,
- NULL,
- echnk.data,
- echnk.size,
- level + 2,
- dumpfunc,
- dumpdata);
- }
- if (!data_ret)
- {
- goto error;
- }
- }
- break;
- default:
- break;
- }
- if (dumpfunc)
- {
- for (i = 0; i < level; i++) dumpfunc(dumpdata, " ");
- dumpfunc(dumpdata, " }\n");
- }
- }
+ if (dumpfunc && group_type == EET_G_UNKNOWN && IS_SIMPLE_TYPE(type))
+ {
+ ret = eet_data_get_type(ed,
+ type,
+ echnk.data,
+ ((char *)echnk.data) + echnk.size,
+ dd);
+ if (ret <= 0) goto error;
+
+ eet_data_dump_simple_type(type, echnk.name, dd, level, dumpfunc, dumpdata);
+ }
+ else
+ {
+ ret = eet_group_codec[group_type - 100].get(context,
+ ed, edd, ede, &echnk,
+ type, group_type, ede ? (void*) (((char *)data) + ede->offset) : dd,
+ level, dumpfunc, dumpdata,
+ &p, &size);
+ if (ret <= 0) goto error;
}
/* advance to next chunk */
NEXT_CHUNK(p, size, echnk, ed);
}
+
_eet_freelist_all_unref(context);
if (dumpfunc)
{
@@ -2588,39 +2355,91 @@ error:
return NULL;
}
+static void
+eet_data_dump_level(int level, void (*dumpfunc) (void *data, const char *str), void *dumpdata)
+{
+ int i;
+
+ for (i = 0; i < level; i++) dumpfunc(dumpdata, " ");
+}
+
+static void
+eet_data_dump_group_start(int level, void (*dumpfunc) (void *data, const char *str), void *dumpdata,
+ int group_type, const char *name)
+{
+ int chnk_type;
+
+ chnk_type = (group_type >= EET_G_UNKNOWN && group_type <= EET_G_HASH) ?
+ group_type : EET_G_LAST;
+
+ eet_data_dump_level(level, dumpfunc, dumpdata);
+ dumpfunc(dumpdata, "group \"");
+ _eet_data_dump_string_escape(dumpdata, dumpfunc, name);
+ dumpfunc(dumpdata, "\" ");
+
+ dumpfunc(dumpdata, _dump_g_name[chnk_type - EET_G_UNKNOWN]);
+ dumpfunc(dumpdata, " {\n");
+}
+
+static void
+eet_data_dump_group_end(int level, void (*dumpfunc) (void *data, const char *str), void *dumpdata)
+{
+ eet_data_dump_level(level, dumpfunc, dumpdata);
+ dumpfunc(dumpdata, " }\n");
+}
+
static int
eet_data_get_list(Eet_Free_Context *context, const Eet_Dictionary *ed, Eet_Data_Descriptor *edd, Eet_Data_Element *ede, Eet_Data_Chunk *echnk,
- int type __UNUSED__, int group_type __UNUSED__, void *data,
+ int type, int group_type __UNUSED__, void *data,
int level, void (*dumpfunc) (void *data, const char *str), void *dumpdata,
- char **p __UNUSED__, int *size __UNUSED__)
+ char **p, int *size)
{
+ Eet_Data_Descriptor *subtype = NULL;
void *list = NULL;
void **ptr;
void *data_ret;
+ int et = EET_T_UNKNOW;
EET_ASSERT(!((type > EET_T_UNKNOW) && (type < EET_T_STRING)), return 0);
+ if (edd)
+ {
+ subtype = ede->subtype;
+ et = ede->type;
+ }
+ else if (dumpfunc)
+ {
+ eet_data_dump_group_start(level + 1, dumpfunc, dumpdata, echnk->group_type, echnk->name);
+ }
+
ptr = (void **)data;
list = *ptr;
data_ret = NULL;
- if (ede->type >= EET_T_STRING)
+ if (et >= EET_T_STRING)
{
int ret;
- ret = eet_data_get_unknown(context, ed, edd, ede, echnk, ede->type, EET_G_UNKNOWN,
+ ret = eet_data_get_unknown(context, ed, edd, ede, echnk, et, EET_G_UNKNOWN,
&data_ret, level, dumpfunc, dumpdata, p, size);
if (!ret) return 0;
}
else
{
- data_ret = _eet_data_descriptor_decode(context, ed, ede->subtype, echnk->data, echnk->size, level + 2, dumpfunc, dumpdata);
+ data_ret = _eet_data_descriptor_decode(context, ed, subtype,
+ echnk->data, echnk->size,
+ level + 2, dumpfunc, dumpdata);
if (!data_ret) return 0;
}
- list = edd->func.list_append(list, data_ret);
- *ptr = list;
- _eet_freelist_list_add(context, ptr);
+ if (edd)
+ {
+ list = edd->func.list_append(list, data_ret);
+ *ptr = list;
+ _eet_freelist_list_add(context, ptr);
+ }
+ else if (dumpfunc)
+ eet_data_dump_group_end(level, dumpfunc, dumpdata);
return 1;
}
@@ -2658,11 +2477,21 @@ eet_data_get_hash(Eet_Free_Context *context, const Eet_Dictionary *ed, Eet_Data_
eet_data_chunk_get(ed, echnk, *p, *size);
if (!echnk->name) goto on_error;
+ if (dumpfunc && key)
+ {
+ eet_data_dump_group_start(level + 1, dumpfunc, dumpdata, echnk->group_type, echnk->name);
+
+ eet_data_dump_level(level, dumpfunc, dumpdata);
+ dumpfunc(dumpdata, " key \"");
+ _eet_data_dump_string_escape(dumpdata, dumpfunc, key);
+ dumpfunc(dumpdata, "\";\n");
+ }
+
if (type >= EET_T_STRING)
{
int ret;
- ret = eet_data_get_unknown(context, ed, edd, ede, echnk, ede->type, EET_G_UNKNOWN,
+ ret = eet_data_get_unknown(context, ed, edd, ede, echnk, ede ? ede->type : type, EET_G_UNKNOWN,
&data_ret, level, dumpfunc, dumpdata, p, size);
if (!ret) return 0;
}
@@ -2670,7 +2499,7 @@ eet_data_get_hash(Eet_Free_Context *context, const Eet_Dictionary *ed, Eet_Data_
{
data_ret = _eet_data_descriptor_decode(context,
ed,
- ede->subtype,
+ ede ? ede->subtype : NULL,
echnk->data,
echnk->size,
level + 2,
@@ -2679,9 +2508,15 @@ eet_data_get_hash(Eet_Free_Context *context, const Eet_Dictionary *ed, Eet_Data_
if (!data_ret) goto on_error;
}
- hash = edd->func.hash_add(hash, key, data_ret);
- *ptr = hash;
- _eet_freelist_hash_add(context, ptr);
+ if (edd)
+ {
+ hash = edd->func.hash_add(hash, key, data_ret);
+ *ptr = hash;
+ _eet_freelist_hash_add(context, ptr);
+ }
+ else if (dumpfunc)
+ eet_data_dump_group_end(level, dumpfunc, dumpdata);
+
return 1;
on_error:
@@ -2709,7 +2544,7 @@ eet_data_get_array(Eet_Free_Context *context, const Eet_Dictionary *ed, Eet_Data
void *ptr;
int count;
int ret;
- int subsize;
+ int subsize = 0;
int i;
EET_ASSERT(!((type > EET_T_UNKNOW) && (type < EET_T_STRING)), return 0);
@@ -2723,32 +2558,47 @@ eet_data_get_array(Eet_Free_Context *context, const Eet_Dictionary *ed, Eet_Data
&count);
if (ret <= 0) return ret;
- if (type >= EET_T_STRING)
- subsize = eet_basic_codec[ede->type].size;
- else
- subsize = ede->subtype->size;
-
name = echnk->name;
- if (group_type == EET_G_VAR_ARRAY)
+ if (ede)
{
- /* store the number of elements
- * on the counter offset */
- *(int *)(((char *)data) + ede->count - ede->offset) = count;
- /* allocate space for the array of elements */
- *(void **)ptr = edd->func.mem_alloc(count * subsize);
+ if (type >= EET_T_STRING)
+ subsize = eet_basic_codec[ede->type].size;
+ else
+ subsize = ede->subtype->size;
+
+ if (group_type == EET_G_VAR_ARRAY)
+ {
+ /* store the number of elements
+ * on the counter offset */
+ *(int *)(((char *)data) + ede->count - ede->offset) = count;
+ /* allocate space for the array of elements */
+ *(void **)ptr = edd->func.mem_alloc(count * subsize);
+
+ if (!*(void **)ptr) return 0;
- if (!*(void **)ptr) return 0;
+ memset(*(void **)ptr, 0, count * subsize);
- memset(*(void **)ptr, 0, count * subsize);
+ _eet_freelist_add(context, *(void **)ptr);
+ }
+ }
+ else
+ {
+ char tbuf[256];
+
+ eet_data_dump_group_start(level + 1, dumpfunc, dumpdata, echnk->group_type, echnk->name);
- _eet_freelist_add(context, *(void **)ptr);
+ eet_data_dump_level(level, dumpfunc, dumpdata);
+ dumpfunc(dumpdata, " count ");
+ eina_convert_itoa(count, tbuf);
+ dumpfunc(dumpdata, tbuf);
+ dumpfunc(dumpdata, ";\n");
}
/* get all array elements */
for (i = 0; i < count; i++)
{
- void *dst;
+ void *dst = NULL;
void *data_ret = NULL;
/* Advance to next chunk */
@@ -2760,49 +2610,103 @@ eet_data_get_array(Eet_Free_Context *context, const Eet_Dictionary *ed, Eet_Data
/* get the data */
/* get the destination pointer */
- if (group_type == EET_G_ARRAY)
- dst = (char *)ptr + (subsize * i);
- else
- dst = *(char **)ptr + (subsize * i);
+ if (ede)
+ {
+ if (group_type == EET_G_ARRAY)
+ dst = (char *)ptr + (subsize * i);
+ else
+ dst = *(char **)ptr + (subsize * i);
+ }
if (type >= EET_T_STRING)
{
int ret;
- ret = eet_data_get_unknown(context,
- ed,
- edd,
- ede,
- echnk,
- ede->type,
- EET_G_UNKNOWN,
- &data_ret,
- level,
- dumpfunc,
- dumpdata,
- p,
- size);
+ ret = eet_data_get_unknown(context, ed, edd, ede, echnk, ede ? ede->type : type, EET_G_UNKNOWN,
+ &data_ret, level, dumpfunc, dumpdata, p, size);
if (!ret) return 0;
- memcpy(dst, &data_ret, subsize);
+ if (dst) memcpy(dst, &data_ret, subsize);
}
else
{
- data_ret = _eet_data_descriptor_decode(context,
- ed,
- ede->subtype,
- echnk->data,
- echnk->size,
- level + 2,
- dumpfunc,
- dumpdata);
+ data_ret = _eet_data_descriptor_decode(context, ed, ede ? ede->subtype : NULL,
+ echnk->data, echnk->size,
+ level + 2, dumpfunc, dumpdata);
if (!data_ret) return 0;
- memcpy(dst, data_ret, subsize);
- _eet_freelist_add(context, data_ret);
+ if (dst)
+ {
+ memcpy(dst, data_ret, subsize);
+ _eet_freelist_add(context, data_ret);
+ }
}
}
+
+ if (dumpfunc)
+ eet_data_dump_group_end(level, dumpfunc, dumpdata);
+
return 1;
}
+static void
+eet_data_dump_simple_type(int type, const char *name, void *dd,
+ int level, void (*dumpfunc) (void *data, const char *str), void *dumpdata)
+{
+ const char *type_name = NULL;
+ char tbuf[256];
+
+ eet_data_dump_level(level, dumpfunc, dumpdata);
+ dumpfunc(dumpdata, " value \"");
+ _eet_data_dump_string_escape(dumpdata, dumpfunc, name);
+ dumpfunc(dumpdata, "\" ");
+
+#define EET_T_TYPE(Eet_Type, Type) \
+ case Eet_Type: \
+ { \
+ dumpfunc(dumpdata, _dump_t_name[Eet_Type][0]); \
+ snprintf(tbuf, sizeof (tbuf), _dump_t_name[Eet_Type][1], *((Type *)dd)); \
+ dumpfunc(dumpdata, tbuf); \
+ break; \
+ }
+
+ switch (type)
+ {
+ EET_T_TYPE(EET_T_CHAR, char);
+ EET_T_TYPE(EET_T_SHORT, short);
+ EET_T_TYPE(EET_T_INT, int);
+ EET_T_TYPE(EET_T_LONG_LONG, long long);
+ EET_T_TYPE(EET_T_FLOAT, float);
+ EET_T_TYPE(EET_T_DOUBLE, double);
+ EET_T_TYPE(EET_T_UCHAR, unsigned char);
+ EET_T_TYPE(EET_T_USHORT, unsigned short);
+ EET_T_TYPE(EET_T_UINT, unsigned int);
+ EET_T_TYPE(EET_T_ULONG_LONG, unsigned long long);
+ case EET_T_INLINED_STRING:
+ type_name = "inlined: \"";
+ case EET_T_STRING:
+ if (!type_name) type_name = "string: \"";
+
+ {
+ char *s;
+
+ s = *((char **)dd);
+ if (s)
+ {
+ dumpfunc(dumpdata, type_name);
+ _eet_data_dump_string_escape(dumpdata, dumpfunc, s);
+ dumpfunc(dumpdata, "\"");
+ }
+ }
+ break;
+ case EET_T_NULL:
+ dumpfunc(dumpdata, "null");
+ break;
+ default:
+ dumpfunc(dumpdata, "???: ???");
+ break;
+ }
+ dumpfunc(dumpdata, ";\n");
+}
+
static int
eet_data_get_unknown(Eet_Free_Context *context, const Eet_Dictionary *ed, Eet_Data_Descriptor *edd, Eet_Data_Element *ede, Eet_Data_Chunk *echnk,
int type, int group_type __UNUSED__, void *data,
@@ -2817,7 +2721,11 @@ eet_data_get_unknown(Eet_Free_Context *context, const Eet_Dictionary *ed, Eet_Da
ret = eet_data_get_type(ed, type, echnk->data, ((char *)echnk->data) + echnk->size, ((char *)data));
if (ret <= 0) return ret;
- if (type == EET_T_STRING)
+ if (!edd && dumpfunc)
+ {
+ eet_data_dump_simple_type(type, echnk->name, data, level, dumpfunc, dumpdata);
+ }
+ else if (type == EET_T_STRING)
{
char **str;
@@ -2848,15 +2756,22 @@ eet_data_get_unknown(Eet_Free_Context *context, const Eet_Dictionary *ed, Eet_Da
}
}
}
- else if (ede->subtype)
+ else
{
- void **ptr;
+ Eet_Data_Descriptor *subtype;
- data_ret = _eet_data_descriptor_decode(context, ed, ede->subtype, echnk->data, echnk->size, level + 1, dumpfunc, dumpdata);
- if (!data_ret) return 0;
+ subtype = ede ? ede->subtype : NULL;
- ptr = (void **)(((char *)data));
- *ptr = (void *)data_ret;
+ if (subtype || dumpfunc)
+ {
+ void **ptr;
+
+ data_ret = _eet_data_descriptor_decode(context, ed, subtype, echnk->data, echnk->size, level + 1, dumpfunc, dumpdata);
+ if (!data_ret) return 0;
+
+ ptr = (void **)(((char *)data));
+ *ptr = (void *)data_ret;
+ }
}
return 1;
diff --git a/src/lib/eet_node.c b/src/lib/eet_node.c
index ee4fe0c..0514026 100644
--- a/src/lib/eet_node.c
+++ b/src/lib/eet_node.c
@@ -68,6 +68,7 @@ EET_NODE_NEW(EET_T_DOUBLE, double, d, double);
EET_NODE_NEW(EET_T_UCHAR, unsigned_char, uc, unsigned char);
EET_NODE_NEW(EET_T_USHORT, unsigned_short, us, unsigned short);
EET_NODE_NEW(EET_T_UINT, unsigned_int, ui, unsigned int);
+EET_NODE_NEW(EET_T_ULONG_LONG, unsigned_long_long, ul, unsigned long long);
EET_NODE_STR_NEW(EET_T_STRING, string, str, const char *);
EET_NODE_STR_NEW(EET_T_INLINED_STRING, inlined_string, str, const char *);
@@ -113,14 +114,14 @@ eet_node_array_new(const char *name, int count, Eina_List *nodes)
}
Eet_Node *
-eet_node_var_array_new(const char *name, int count, Eina_List *nodes)
+eet_node_var_array_new(const char *name, Eina_List *nodes)
{
Eet_Node *n;
n = _eet_node_new(name, EET_G_VAR_ARRAY);
if (!n) return NULL;
- n->count = count;
+ n->count = eina_list_count(nodes);
_eet_node_append(n, nodes);
@@ -128,14 +129,18 @@ eet_node_var_array_new(const char *name, int count, Eina_List *nodes)
}
Eet_Node *
-eet_node_hash_new(const char *name, const char *key, Eina_List *nodes)
+eet_node_hash_new(const char *name, const char *key, Eet_Node *node)
{
+ Eina_List *nodes;
Eet_Node *n;
+ if (!node) return NULL;
+
n = _eet_node_new(name, EET_G_HASH);
if (!n) return NULL;
n->key = eina_stringshare_add(key);
+ nodes = eina_list_append(NULL, node);
_eet_node_append(n, nodes);
@@ -195,3 +200,161 @@ eet_node_del(Eet_Node *n)
eina_stringshare_del(n->name);
free(n);
}
+
+
+static const char *eet_node_dump_g_name[6] = {
+ "struct",
+ "array",
+ "var_array",
+ "list",
+ "hash",
+ "???"
+};
+
+static const char *eet_node_dump_t_name[14][2] = {
+ { "???: ", "???" },
+ { "char: ", "%hhi" },
+ { "short: ", "%hi" },
+ { "int: ", "%i" },
+ { "long_long: ", "%lli" },
+ { "float: ", "%1.25f" },
+ { "double: ", "%1.25f" },
+ { "uchar: ", "%hhu" },
+ { "ushort: ", "%i" },
+ { "uint: ", "%u" },
+ { "ulong_long: ", "%llu" },
+ { "null", "" }
+};
+
+static void
+eet_node_dump_level(int level, void (*dumpfunc) (void *data, const char *str), void *dumpdata)
+{
+ int i;
+
+ for (i = 0; i < level; i++) dumpfunc(dumpdata, " ");
+}
+
+static char *
+eet_node_string_escape(const char *str)
+{
+ char *s, *sp;
+ const char *strp;
+ int sz = 0;
+
+ for (strp = str; *strp; strp++)
+ {
+ if (*strp == '\"') sz += 2;
+ else if (*strp == '\\') sz += 2;
+ else sz += 1;
+ }
+ s = malloc(sz + 1);
+ if (!s) return NULL;
+ for (strp = str, sp = s; *strp; strp++, sp++)
+ {
+ if (*strp == '\"')
+ {
+ *sp = '\\';
+ sp++;
+ }
+ else if (*strp == '\\')
+ {
+ *sp = '\\';
+ sp++;
+ }
+ *sp = *strp;
+ }
+ *sp = 0;
+ return s;
+}
+
+static void
+eet_node_dump_string_escape(void *dumpdata, void dumpfunc(void *data, const char *str), const char *str)
+{
+ char *s;
+
+ s = eet_node_string_escape(str);
+ if (!s) return ;
+
+ dumpfunc(dumpdata, s);
+ free(s);
+}
+
+static void
+eet_node_dump_simple_type(Eet_Node *n, int level,
+ void (*dumpfunc) (void *data, const char *str), void *dumpdata)
+{
+ const char *type_name = NULL;
+ char tbuf[256];
+
+ eet_node_dump_level(level, dumpfunc, dumpdata);
+ dumpfunc(dumpdata, " value \"");
+ eet_node_dump_string_escape(dumpdata, dumpfunc, n->name);
+ dumpfunc(dumpdata, "\" ");
+
+#define EET_T_TYPE(Eet_Type, Type) \
+ case Eet_Type: \
+ { \
+ dumpfunc(dumpdata, eet_node_dump_t_name[Eet_Type][0]); \
+ snprintf(tbuf, sizeof (tbuf), eet_node_dump_t_name[Eet_Type][1], n->data.Type); \
+ dumpfunc(dumpdata, tbuf); \
+ break; \
+ }
+
+ switch (n->type)
+ {
+ EET_T_TYPE(EET_T_CHAR, c);
+ EET_T_TYPE(EET_T_SHORT, s);
+ EET_T_TYPE(EET_T_INT, i);
+ EET_T_TYPE(EET_T_LONG_LONG, l);
+ EET_T_TYPE(EET_T_FLOAT, f);
+ EET_T_TYPE(EET_T_DOUBLE, d);
+ EET_T_TYPE(EET_T_UCHAR, uc);
+ EET_T_TYPE(EET_T_USHORT, us);
+ EET_T_TYPE(EET_T_UINT, ui);
+ EET_T_TYPE(EET_T_ULONG_LONG, ul);
+ case EET_T_INLINED_STRING:
+ type_name = "inlined: \"";
+ case EET_T_STRING:
+ if (!type_name) type_name = "string: \"";
+
+ dumpfunc(dumpdata, type_name);
+ eet_node_dump_string_escape(dumpdata, dumpfunc, n->data.str);
+ dumpfunc(dumpdata, "\"");
+ break;
+ case EET_T_NULL:
+ dumpfunc(dumpdata, "null");
+ break;
+ default:
+ dumpfunc(dumpdata, "???: ???");
+ break;
+ }
+
+ dumpfunc(dumpdata, ";\n");
+}
+
+void
+eet_node_dump(Eet_Node *n, int dumplevel, void (*dumpfunc) (void *data, const char *str), void *dumpdata)
+{
+ switch (n->type)
+ {
+ case EET_G_HASH:
+ case EET_G_UNKNOWN:
+ case EET_G_VAR_ARRAY:
+ case EET_G_ARRAY:
+ case EET_G_LIST:
+ break;
+ case EET_T_STRING:
+ case EET_T_INLINED_STRING:
+ case EET_T_CHAR:
+ case EET_T_SHORT:
+ case EET_T_INT:
+ case EET_T_LONG_LONG:
+ case EET_T_FLOAT:
+ case EET_T_DOUBLE:
+ case EET_T_UCHAR:
+ case EET_T_USHORT:
+ case EET_T_UINT:
+ eet_node_dump_simple_type(n, dumplevel, dumpfunc, dumpdata);
+ break;
+ }
+}
--
Enlightenment DR17 file chunk reading/writing library
More information about the Pkg-e-commits
mailing list