Enlightenment CVS committal

Author  : raster
Project : e17
Module  : libs/eet

Dir     : e17/libs/eet/src/lib


Modified Files:
        Eet.h eet_data.c 


Log Message:


cedrics eet -d fixes.. yay!

===================================================================
RCS file: /cvs/e/e17/libs/eet/src/lib/Eet.h,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -3 -r1.52 -r1.53
--- Eet.h       31 Mar 2008 15:48:59 -0000      1.52
+++ Eet.h       10 Apr 2008 08:57:03 -0000      1.53
@@ -914,6 +914,45 @@
    EAPI void *eet_data_text_undump(const char *text, int textlen, int 
*size_ret);
 
    /**
+    * Dump an eet encoded data structure from an eet file into ascii text
+    * @param ef A valid eet file handle.
+    * @param name Name of the entry. eg: "/base/file_i_want".
+    * @param dumpfunc The function to call passed a string when new data is 
converted to text
+    * @param dumpdata The data to pass to the @p dumpfunc callback.
+    * @return 1 on success, 0 on failure
+    *
+    * This function will take an open and valid eet file from eet_open() 
request
+    * the data encoded by eet_data_descriptor_encode() corresponding to the 
key @p name
+    * and convert it into human readable ascii text. It does this by calling 
the
+    * @p dumpfunc callback for all new text that is generated. This callback 
should
+    * append to any existing text buffer and will be passed the pointer @p 
dumpdata
+    * as a parameter as well as a string with new text to be appended.
+    *
+    * @since 1.0.0
+    */
+   EAPI int eet_data_dump(Eet_File *ef, const char *name, void (*dumpfunc) 
(void *data, const char *str), void *dumpdata);
+
+   /**
+    * Take an ascii encoding from eet_data_dump() and re-encode in binary.
+    * @param ef A valid eet file handle.
+    * @param name Name of the entry. eg: "/base/file_i_want".
+    * @param text The pointer to the string data to parse and encode.
+    * @param textlen The size of the string in bytes (not including 0 byte 
terminator).
+    * @param compress Compression flags (1 == compress, 0 = don't compress).
+    * @return 1 on success, 0 on failure
+    *
+    * This function will parse the string pointed to by @p text, encode it the 
same
+    * way eet_data_descriptor_encode() takes an in-memory data struct and 
encodes into a
+    * binary blob.
+    *
+    * The data (optionally compressed) will be in ram, pending a flush to
+    * disk (it will stay in ram till the eet file handle is closed though).
+    *
+    * @since 1.0.0
+    */
+   EAPI int eet_data_undump(Eet_File *ef, const char *name, const char *text, 
int textlen, int compress);
+
+   /**
     * Decode a data structure from an arbitary location in memory.
     * @param edd The data  descriptor to use when decoding.
     * @param data_in The pointer to the data to decode into a struct.
===================================================================
RCS file: /cvs/e/e17/libs/eet/src/lib/eet_data.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -3 -r1.71 -r1.72
--- eet_data.c  9 Apr 2008 08:27:17 -0000       1.71
+++ eet_data.c  10 Apr 2008 08:57:03 -0000      1.72
@@ -2494,6 +2494,39 @@
 }
 
 EAPI int
+eet_data_dump(Eet_File *ef,
+             const char *name,
+             void (*dumpfunc) (void *data, const char *str),
+             void *dumpdata)
+{
+   const Eet_Dictionary *ed = NULL;
+   const void          *data;
+   int                  ret = 0;
+   int                  required_free = 0;
+   int                  size;
+
+   ed = eet_dictionary_get(ef);
+
+   data = eet_read_direct(ef, name, &size);
+   if (!data)
+     {
+       required_free = 1;
+       data = eet_read(ef, name, &size);
+       if (!data) return 0;
+     }
+
+   if (_eet_data_descriptor_decode(ed, NULL, data, size, 0,
+                                  dumpfunc, dumpdata))
+     ret = 1;
+
+   if (required_free)
+     free((void*)data);
+
+   return ret;
+}
+
+
+EAPI int
 eet_data_text_dump(const void *data_in,
                   int size_in,
                   void (*dumpfunc) (void *data, const char *str),
@@ -2511,6 +2544,27 @@
                     int *size_ret)
 {
    return _eet_data_dump_parse(NULL, size_ret, text, textlen);
+}
+
+EAPI int
+eet_data_undump(Eet_File *ef,
+               const char *name,
+               const char *text,
+               int textlen,
+               int compress)
+{
+   Eet_Dictionary       *ed;
+   void                 *data_enc;
+   int                   size;
+   int                   val;
+
+   ed = eet_dictionary_get(ef);
+
+   data_enc = _eet_data_dump_parse(ed, &size, text, textlen);
+   if (!data_enc) return 0;
+   val = eet_write(ef, name, data_enc, size, compress);
+   free(data_enc);
+   return val;
 }
 
 EAPI void *



-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
enlightenment-cvs mailing list
enlightenment-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs

Reply via email to