On Fri, 12 Nov 2010 10:49:21 +0100
Cedric BAIL <cedric.b...@free.fr> wrote:
> On Fri, Nov 12, 2010 at 6:13 AM, Mike Blumenkrantz <m...@zentific.com> wrote:
> > Do the eet_data_read/write_cipher calls work? I have been trying to read
> > and write a small amount of data using them and am unable to. The data
> > written is not enciphered and I cannot read the file back.
>
> It's working for me. What is your setup ? How much data do you want to
> cipher ? Do you compress them ?
Attached is a small app which demonstrates this 100% of the time on my system.
I'm guessing it's a bug, because it works fine when not using read/write_cipher.
--
Mike Blumenkrantz
Zentific: Our boolean values are huge.
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <Eet.h>
typedef struct _Zcli Zcli;
struct _Zcli
{
const char *cookie;
double timestamp;
};
static void _eet_setup(void);
static void _eet_setup_read(void);
static void _eet_setup_write(void);
Zcli *client = NULL;
Eet_Data_Descriptor *zcli_edd;
static char *cipher = NULL;
static void
_eet_setup(void)
{
Eet_Data_Descriptor_Class eddc;
char ciph[16];
char hash[64];
if (!eet_eina_stream_data_descriptor_class_set(&eddc, sizeof(eddc), "zcli", sizeof(Zcli)))
{
printf("Could not create eet data descriptor!\n");
exit(1);
}
snprintf(hash, sizeof(hash), "%s%u", "sup test string", 123412345);
snprintf(ciph, sizeof(ciph), "%i", eina_hash_djb2(hash, strlen(hash)));
cipher = strdup(ciph);
if (!cipher)
{
printf("Mem allocation error!\n");
exit(1);
}
else
printf("Cipher generated from environment: %s\n", cipher);
zcli_edd = eet_data_descriptor_stream_new(&eddc);
#define DAT(MEMBER, TYPE) EET_DATA_DESCRIPTOR_ADD_BASIC(zcli_edd, Zcli, #MEMBER, MEMBER, EET_T_##TYPE)
DAT(cookie, INLINED_STRING);
DAT(timestamp, DOUBLE);
#undef DAT
}
static void
_eet_setup_read(void)
{
Eet_File *ef;
struct stat st;
if (stat("session", &st) < 0)
{
printf("Session file does not exist\n");
return;
}
ef = eet_open("session", EET_FILE_MODE_READ);
if (!ef)
{
printf("Could not open session file!\n");
exit(1);
}
client = eet_data_read_cipher(ef, zcli_edd, "current", cipher);
eet_close(ef);
if (!client)
{
printf("Could not retrieve old session data!\n");
return;
}
printf("Keeping old session id %s\n", (client->cookie) ? client->cookie : "");
}
static void
_eet_setup_write(void)
{
Eet_File *ef;
char buf[16];
int ret, ret2;
snprintf(buf, sizeof(buf), "%s~", "session");
ef = eet_open(buf, EET_FILE_MODE_WRITE);
if (!ef)
{
printf("Could not open session file!\n");
exit(1);
}
ret = eet_data_write_cipher(ef, zcli_edd, "current", cipher, client, EINA_TRUE);
ret2 = eet_sync(ef);
eet_close(ef);
if ((!ret) || ret2)
{
printf("Could not write session file!\n");
unlink("session");
}
else
{
printf("Wrote session to disk at %s\n", "session");
unlink("session");
rename(buf, "session");
}
}
int
main(void)
{
eina_init();
eet_init();
_eet_setup();
_eet_setup_read();
if (!client)
client = calloc(sizeof(Zcli), 1);
client->timestamp = 23413424;
client->cookie = eina_stringshare_add("test string");
_eet_setup_write();
return 0;
}
------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture
Simplifying enterprise desktop deployment and management using
Dell EqualLogic storage and VMware View: A highly scalable, end-to-end
client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
enlightenment-devel mailing list
enlightenment-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/enlightenment-devel