formatting. <- uncrustify

SVN revision: 50698
This commit is contained in:
Carsten Haitzler 2010-07-31 01:54:48 +00:00
parent 55d0190185
commit f7019f134d
17 changed files with 3675 additions and 3639 deletions

View File

@ -4,55 +4,54 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include <config.h> # include <config.h>
#endif #endif /* ifdef HAVE_CONFIG_H */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifndef _MSC_VER #ifndef _MSC_VER
# include <unistd.h> # include <unistd.h>
#endif #endif /* ifndef _MSC_VER */
#ifdef HAVE_EVIL #ifdef HAVE_EVIL
# include <Evil.h> # include <Evil.h>
#endif #endif /* ifdef HAVE_EVIL */
#include <Eet.h> #include <Eet.h>
static int _eet_main_log_dom = -1; static int _eet_main_log_dom = -1;
#ifdef EET_DEFAULT_LOG_COLOR #ifdef EET_DEFAULT_LOG_COLOR
#undef EET_DEFAULT_LOG_COLOR #undef EET_DEFAULT_LOG_COLOR
#endif #endif /* ifdef EET_DEFAULT_LOG_COLOR */
#define EET_DEFAULT_LOG_COLOR EINA_COLOR_CYAN #define EET_DEFAULT_LOG_COLOR EINA_COLOR_CYAN
#ifdef ERR #ifdef ERR
#undef ERR #undef ERR
#endif #endif /* ifdef ERR */
#define ERR(...) EINA_LOG_DOM_ERR(_eet_main_log_dom, __VA_ARGS__) #define ERR(...) EINA_LOG_DOM_ERR(_eet_main_log_dom, __VA_ARGS__)
#ifdef DBG #ifdef DBG
#undef DBG #undef DBG
#endif #endif /* ifdef DBG */
#define DBG(...) EINA_LOG_DOM_DBG(_eet_main_log_dom, __VA_ARGS__) #define DBG(...) EINA_LOG_DOM_DBG(_eet_main_log_dom, __VA_ARGS__)
#ifdef INF #ifdef INF
#undef INF #undef INF
#endif #endif /* ifdef INF */
#define INF(...) EINA_LOG_DOM_INFO(_eet_main_log_dom, __VA_ARGS__) #define INF(...) EINA_LOG_DOM_INFO(_eet_main_log_dom, __VA_ARGS__)
#ifdef WRN #ifdef WRN
#undef WRN #undef WRN
#endif #endif /* ifdef WRN */
#define WRN(...) EINA_LOG_DOM_WARN(_eet_main_log_dom, __VA_ARGS__) #define WRN(...) EINA_LOG_DOM_WARN(_eet_main_log_dom, __VA_ARGS__)
#ifdef CRIT #ifdef CRIT
#undef CRIT #undef CRIT
#endif #endif /* ifdef CRIT */
#define CRIT(...) EINA_LOG_DOM_CRIT(_eet_main_log_dom, __VA_ARGS__) #define CRIT(...) EINA_LOG_DOM_CRIT(_eet_main_log_dom, __VA_ARGS__)
static void static void
do_eet_list(const char *file) do_eet_list(const char * file)
{ {
int i, num; int i, num;
char **list; char ** list;
Eet_File *ef; Eet_File * ef;
ef = eet_open(file, EET_FILE_MODE_READ); ef = eet_open(file, EET_FILE_MODE_READ);
if (!ef) if (!ef)
@ -70,18 +69,18 @@ do_eet_list(const char *file)
} }
eet_close(ef); eet_close(ef);
} } /* do_eet_list */
static void static void
do_eet_extract(const char *file, do_eet_extract(const char * file,
const char *key, const char * key,
const char *out, const char * out,
const char *crypto_key) const char * crypto_key)
{ {
Eet_File *ef; Eet_File * ef;
void *data; void * data;
int size = 0; int size = 0;
FILE *f; FILE * f;
ef = eet_open(file, EET_FILE_MODE_READ); ef = eet_open(file, EET_FILE_MODE_READ);
if (!ef) if (!ef)
@ -113,22 +112,22 @@ do_eet_extract(const char *file,
fclose(f); fclose(f);
free(data); free(data);
eet_close(ef); eet_close(ef);
} } /* do_eet_extract */
static void static void
do_eet_decode_dump(void *data, const char *str) do_eet_decode_dump(void * data, const char * str)
{ {
fputs(str, (FILE *)data); fputs(str, (FILE *)data);
} } /* do_eet_decode_dump */
static void static void
do_eet_decode(const char *file, do_eet_decode(const char * file,
const char *key, const char * key,
const char *out, const char * out,
const char *crypto_key) const char * crypto_key)
{ {
Eet_File *ef; Eet_File * ef;
FILE *f; FILE * f;
ef = eet_open(file, EET_FILE_MODE_READ); ef = eet_open(file, EET_FILE_MODE_READ);
if (!ef) if (!ef)
@ -152,19 +151,19 @@ do_eet_decode(const char *file,
fclose(f); fclose(f);
eet_close(ef); eet_close(ef);
} } /* do_eet_decode */
static void static void
do_eet_insert(const char *file, do_eet_insert(const char * file,
const char *key, const char * key,
const char *out, const char * out,
int compress, int compress,
const char *crypto_key) const char * crypto_key)
{ {
Eet_File *ef; Eet_File * ef;
void *data; void * data;
int size = 0; int size = 0;
FILE *f; FILE * f;
ef = eet_open(file, EET_FILE_MODE_READ_WRITE); ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
if (!ef) if (!ef)
@ -203,20 +202,20 @@ do_eet_insert(const char *file,
eet_write_cipher(ef, key, data, size, compress, crypto_key); eet_write_cipher(ef, key, data, size, compress, crypto_key);
free(data); free(data);
eet_close(ef); eet_close(ef);
} } /* do_eet_insert */
static void static void
do_eet_encode(const char *file, do_eet_encode(const char * file,
const char *key, const char * key,
const char *out, const char * out,
int compress, int compress,
const char *crypto_key) const char * crypto_key)
{ {
Eet_File *ef; Eet_File * ef;
char *text; char * text;
int textlen = 0; int textlen = 0;
int size = 0; int size = 0;
FILE *f; FILE * f;
ef = eet_open(file, EET_FILE_MODE_READ_WRITE); ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
if (!ef) if (!ef)
@ -260,12 +259,12 @@ do_eet_encode(const char *file,
free(text); free(text);
eet_close(ef); eet_close(ef);
} } /* do_eet_encode */
static void static void
do_eet_remove(const char *file, const char *key) do_eet_remove(const char * file, const char * key)
{ {
Eet_File *ef; Eet_File * ef;
ef = eet_open(file, EET_FILE_MODE_READ_WRITE); ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
if (!ef) if (!ef)
@ -276,13 +275,13 @@ do_eet_remove(const char *file, const char *key)
eet_delete(ef, key); eet_delete(ef, key);
eet_close(ef); eet_close(ef);
} } /* do_eet_remove */
static void static void
do_eet_check(const char *file) do_eet_check(const char * file)
{ {
Eet_File *ef; Eet_File * ef;
const void *der; const void * der;
int der_length; int der_length;
int sign_length; int sign_length;
@ -302,13 +301,13 @@ do_eet_check(const char *file)
fprintf(stdout, "Signature length %i.\n", sign_length); fprintf(stdout, "Signature length %i.\n", sign_length);
eet_close(ef); eet_close(ef);
} } /* do_eet_check */
static void static void
do_eet_sign(const char *file, const char *private_key, const char *public_key) do_eet_sign(const char * file, const char * private_key, const char * public_key)
{ {
Eet_File *ef; Eet_File * ef;
Eet_Key *key; Eet_Key * key;
ef = eet_open(file, EET_FILE_MODE_READ_WRITE); ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
if (!ef) if (!ef)
@ -330,10 +329,10 @@ do_eet_sign(const char *file, const char *private_key, const char *public_key)
eet_identity_set(ef, key); eet_identity_set(ef, key);
eet_close(ef); eet_close(ef);
} } /* do_eet_sign */
int int
main(int argc, char **argv) main(int argc, char ** argv)
{ {
if (!eet_init()) if (!eet_init())
return -1; return -1;
@ -397,7 +396,7 @@ help:
do_eet_encode(argv[2], argv[3], argv[4], atoi(argv[5]), NULL); do_eet_encode(argv[2], argv[3], argv[4], atoi(argv[5]), NULL);
} }
else if ((!strcmp(argv[1], "-r")) && (argc > 3)) else if ((!strcmp(argv[1], "-r")) && (argc > 3))
do_eet_remove(argv[2], argv[3]); do_eet_remove(argv[2], argv[3]);
else if ((!strcmp(argv[1], "-c")) && (argc > 2)) else if ((!strcmp(argv[1], "-c")) && (argc > 2))
do_eet_check(argv[2]); do_eet_check(argv[2]);
else if ((!strcmp(argv[1], "-s")) && (argc > 4)) else if ((!strcmp(argv[1], "-s")) && (argc > 4))
@ -408,4 +407,5 @@ help:
eina_log_domain_unregister(_eet_main_log_dom); eina_log_domain_unregister(_eet_main_log_dom);
eet_shutdown(); eet_shutdown();
return 0; return 0;
} } /* main */

View File

@ -9,9 +9,9 @@
// complex real-world structures based on elmdentica database // complex real-world structures based on elmdentica database
typedef struct typedef struct
{ {
const char *screen_name; const char * screen_name;
const char *name; const char * name;
const char *message; const char * message;
unsigned int id; unsigned int id;
unsigned int status_id; unsigned int status_id;
unsigned int date; unsigned int date;
@ -20,22 +20,22 @@ typedef struct
typedef struct typedef struct
{ {
const char *dm_to; const char * dm_to;
const char *message; const char * message;
} My_Post; } My_Post;
typedef struct typedef struct
{ {
unsigned int id; unsigned int id;
const char *name; const char * name;
Eina_List *messages; Eina_List * messages;
Eina_List *posts; Eina_List * posts;
} My_Account; } My_Account;
typedef struct typedef struct
{ {
unsigned int version; // it is recommended to use versioned configuration! unsigned int version; // it is recommended to use versioned configuration!
Eina_List *accounts; Eina_List * accounts;
} My_Cache; } My_Cache;
// string that represents the entry in eet file, you might like to have // string that represents the entry in eet file, you might like to have
@ -46,14 +46,14 @@ static const char MY_CACHE_FILE_ENTRY[] = "cache";
// keep the descriptor static global, so it can be // keep the descriptor static global, so it can be
// shared by different functions (load/save) of this and only this // shared by different functions (load/save) of this and only this
// file. // file.
static Eet_Data_Descriptor *_my_cache_descriptor; static Eet_Data_Descriptor * _my_cache_descriptor;
static Eet_Data_Descriptor *_my_account_descriptor; static Eet_Data_Descriptor * _my_account_descriptor;
static Eet_Data_Descriptor *_my_message_descriptor; static Eet_Data_Descriptor * _my_message_descriptor;
static Eet_Data_Descriptor *_my_post_descriptor; static Eet_Data_Descriptor * _my_post_descriptor;
// keep file handle alive, so mmap()ed strings are all alive as well // keep file handle alive, so mmap()ed strings are all alive as well
static Eet_File *_my_cache_file = NULL; static Eet_File * _my_cache_file = NULL;
static Eet_Dictionary *_my_cache_dict = NULL; static Eet_Dictionary * _my_cache_dict = NULL;
static void static void
_my_cache_descriptor_init(void) _my_cache_descriptor_init(void)
@ -78,8 +78,8 @@ _my_cache_descriptor_init(void)
// Describe the members to be saved: // Describe the members to be saved:
// Use a temporary macro so we don't type a lot, also avoid errors: // Use a temporary macro so we don't type a lot, also avoid errors:
#define ADD_BASIC(member, eet_type) \ #define ADD_BASIC(member, eet_type)\
EET_DATA_DESCRIPTOR_ADD_BASIC \ EET_DATA_DESCRIPTOR_ADD_BASIC\
(_my_message_descriptor, My_Message, # member, member, eet_type) (_my_message_descriptor, My_Message, # member, member, eet_type)
ADD_BASIC(screen_name, EET_T_STRING); ADD_BASIC(screen_name, EET_T_STRING);
ADD_BASIC(name, EET_T_STRING); ADD_BASIC(name, EET_T_STRING);
@ -90,15 +90,15 @@ _my_cache_descriptor_init(void)
ADD_BASIC(timeline, EET_T_UINT); ADD_BASIC(timeline, EET_T_UINT);
#undef ADD_BASIC #undef ADD_BASIC
#define ADD_BASIC(member, eet_type) \ #define ADD_BASIC(member, eet_type)\
EET_DATA_DESCRIPTOR_ADD_BASIC \ EET_DATA_DESCRIPTOR_ADD_BASIC\
(_my_post_descriptor, My_Post, # member, member, eet_type) (_my_post_descriptor, My_Post, # member, member, eet_type)
ADD_BASIC(dm_to, EET_T_STRING); ADD_BASIC(dm_to, EET_T_STRING);
ADD_BASIC(message, EET_T_STRING); ADD_BASIC(message, EET_T_STRING);
#undef ADD_BASIC #undef ADD_BASIC
#define ADD_BASIC(member, eet_type) \ #define ADD_BASIC(member, eet_type)\
EET_DATA_DESCRIPTOR_ADD_BASIC \ EET_DATA_DESCRIPTOR_ADD_BASIC\
(_my_account_descriptor, My_Account, # member, member, eet_type) (_my_account_descriptor, My_Account, # member, member, eet_type)
ADD_BASIC(name, EET_T_STRING); ADD_BASIC(name, EET_T_STRING);
ADD_BASIC(id, EET_T_UINT); ADD_BASIC(id, EET_T_UINT);
@ -111,8 +111,8 @@ _my_cache_descriptor_init(void)
(_my_account_descriptor, My_Account, "posts", posts, (_my_account_descriptor, My_Account, "posts", posts,
_my_post_descriptor); _my_post_descriptor);
#define ADD_BASIC(member, eet_type) \ #define ADD_BASIC(member, eet_type)\
EET_DATA_DESCRIPTOR_ADD_BASIC \ EET_DATA_DESCRIPTOR_ADD_BASIC\
(_my_cache_descriptor, My_Cache, # member, member, eet_type) (_my_cache_descriptor, My_Cache, # member, member, eet_type)
ADD_BASIC(version, EET_T_UINT); ADD_BASIC(version, EET_T_UINT);
#undef ADD_BASIC #undef ADD_BASIC
@ -120,7 +120,7 @@ _my_cache_descriptor_init(void)
EET_DATA_DESCRIPTOR_ADD_LIST EET_DATA_DESCRIPTOR_ADD_LIST
(_my_cache_descriptor, My_Cache, "accounts", accounts, (_my_cache_descriptor, My_Cache, "accounts", accounts,
_my_account_descriptor); _my_account_descriptor);
} } /* _my_cache_descriptor_init */
static void static void
_my_cache_descriptor_shutdown(void) _my_cache_descriptor_shutdown(void)
@ -129,12 +129,12 @@ _my_cache_descriptor_shutdown(void)
eet_data_descriptor_free(_my_account_descriptor); eet_data_descriptor_free(_my_account_descriptor);
eet_data_descriptor_free(_my_message_descriptor); eet_data_descriptor_free(_my_message_descriptor);
eet_data_descriptor_free(_my_post_descriptor); eet_data_descriptor_free(_my_post_descriptor);
} } /* _my_cache_descriptor_shutdown */
// need to check if the pointer came from mmaped area in eet_dictionary // need to check if the pointer came from mmaped area in eet_dictionary
// or it was allocated with eina_stringshare_add() // or it was allocated with eina_stringshare_add()
static void static void
_eet_string_free(const char *str) _eet_string_free(const char * str)
{ {
if (!str) if (!str)
return; return;
@ -143,12 +143,12 @@ _eet_string_free(const char *str)
return; return;
eina_stringshare_del(str); eina_stringshare_del(str);
} } /* _eet_string_free */
static My_Message * static My_Message *
_my_message_new(const char *message) _my_message_new(const char * message)
{ {
My_Message *msg = calloc(1, sizeof(My_Message)); My_Message * msg = calloc(1, sizeof(My_Message));
if (!msg) if (!msg)
{ {
fprintf(stderr, "ERROR: could not calloc My_Message\n"); fprintf(stderr, "ERROR: could not calloc My_Message\n");
@ -157,21 +157,21 @@ _my_message_new(const char *message)
msg->message = eina_stringshare_add(message); msg->message = eina_stringshare_add(message);
return msg; return msg;
} } /* _my_message_new */
static void static void
_my_message_free(My_Message *msg) _my_message_free(My_Message * msg)
{ {
_eet_string_free(msg->screen_name); _eet_string_free(msg->screen_name);
_eet_string_free(msg->name); _eet_string_free(msg->name);
_eet_string_free(msg->message); _eet_string_free(msg->message);
free(msg); free(msg);
} } /* _my_message_free */
static My_Post * static My_Post *
_my_post_new(const char *message) _my_post_new(const char * message)
{ {
My_Post *post = calloc(1, sizeof(My_Post)); My_Post * post = calloc(1, sizeof(My_Post));
if (!post) if (!post)
{ {
fprintf(stderr, "ERROR: could not calloc My_Post\n"); fprintf(stderr, "ERROR: could not calloc My_Post\n");
@ -180,20 +180,20 @@ _my_post_new(const char *message)
post->message = eina_stringshare_add(message); post->message = eina_stringshare_add(message);
return post; return post;
} } /* _my_post_new */
static void static void
_my_post_free(My_Post *post) _my_post_free(My_Post * post)
{ {
_eet_string_free(post->dm_to); _eet_string_free(post->dm_to);
_eet_string_free(post->message); _eet_string_free(post->message);
free(post); free(post);
} } /* _my_post_free */
static My_Account * static My_Account *
_my_account_new(const char *name) _my_account_new(const char * name)
{ {
My_Account *acc = calloc(1, sizeof(My_Account)); My_Account * acc = calloc(1, sizeof(My_Account));
if (!acc) if (!acc)
{ {
fprintf(stderr, "ERROR: could not calloc My_Account\n"); fprintf(stderr, "ERROR: could not calloc My_Account\n");
@ -202,13 +202,13 @@ _my_account_new(const char *name)
acc->name = eina_stringshare_add(name); acc->name = eina_stringshare_add(name);
return acc; return acc;
} } /* _my_account_new */
static void static void
_my_account_free(My_Account *acc) _my_account_free(My_Account * acc)
{ {
My_Message *m; My_Message * m;
My_Post *p; My_Post * p;
_eet_string_free(acc->name); _eet_string_free(acc->name);
@ -219,12 +219,12 @@ _my_account_free(My_Account *acc)
_my_post_free(p); _my_post_free(p);
free(acc); free(acc);
} } /* _my_account_free */
static My_Cache * static My_Cache *
_my_cache_new(void) _my_cache_new(void)
{ {
My_Cache *my_cache = calloc(1, sizeof(My_Cache)); My_Cache * my_cache = calloc(1, sizeof(My_Cache));
if (!my_cache) if (!my_cache)
{ {
fprintf(stderr, "ERROR: could not calloc My_Cache\n"); fprintf(stderr, "ERROR: could not calloc My_Cache\n");
@ -233,34 +233,34 @@ _my_cache_new(void)
my_cache->version = 1; my_cache->version = 1;
return my_cache; return my_cache;
} } /* _my_cache_new */
static void static void
_my_cache_free(My_Cache *my_cache) _my_cache_free(My_Cache * my_cache)
{ {
My_Account *acc; My_Account * acc;
EINA_LIST_FREE(my_cache->accounts, acc) EINA_LIST_FREE(my_cache->accounts, acc)
_my_account_free(acc); _my_account_free(acc);
free(my_cache); free(my_cache);
} } /* _my_cache_free */
static My_Account * static My_Account *
_my_cache_account_find(My_Cache *my_cache, const char *name) _my_cache_account_find(My_Cache * my_cache, const char * name)
{ {
My_Account *acc; My_Account * acc;
Eina_List *l; Eina_List * l;
EINA_LIST_FOREACH(my_cache->accounts, l, acc) EINA_LIST_FOREACH(my_cache->accounts, l, acc)
if (strcmp(acc->name, name) == 0) if (strcmp(acc->name, name) == 0)
return acc; return acc;
return NULL; return NULL;
} } /* _my_cache_account_find */
static My_Cache * static My_Cache *
_my_cache_load(const char *filename) _my_cache_load(const char * filename)
{ {
My_Cache *my_cache; My_Cache * my_cache;
Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ); Eet_File * ef = eet_open(filename, EET_FILE_MODE_READ);
if (!ef) if (!ef)
{ {
fprintf(stderr, "ERROR: could not open '%s' for read\n", filename); fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
@ -290,13 +290,13 @@ _my_cache_load(const char *filename)
_my_cache_dict = eet_dictionary_get(ef); _my_cache_dict = eet_dictionary_get(ef);
return my_cache; return my_cache;
} } /* _my_cache_load */
static Eina_Bool static Eina_Bool
_my_cache_save(const My_Cache *my_cache, const char *filename) _my_cache_save(const My_Cache * my_cache, const char * filename)
{ {
char tmp[PATH_MAX]; char tmp[PATH_MAX];
Eet_File *ef; Eet_File * ef;
Eina_Bool ret; Eina_Bool ret;
unsigned int i, len; unsigned int i, len;
struct stat st; struct stat st;
@ -343,13 +343,13 @@ _my_cache_save(const My_Cache *my_cache, const char *filename)
} }
return ret; return ret;
} } /* _my_cache_save */
int main(int argc, char *argv[]) int main(int argc, char * argv[])
{ {
My_Cache *my_cache; My_Cache * my_cache;
const Eina_List *l_acc; const Eina_List * l_acc;
My_Account *acc; My_Account * acc;
int ret = 0; int ret = 0;
if (argc < 3) if (argc < 3)
@ -387,7 +387,7 @@ int main(int argc, char *argv[])
{ {
if (argc == 5) if (argc == 5)
{ {
My_Account *acc = _my_cache_account_find(my_cache, argv[4]); My_Account * acc = _my_cache_account_find(my_cache, argv[4]);
if (!acc) if (!acc)
{ {
acc = _my_account_new(argv[4]); acc = _my_account_new(argv[4]);
@ -399,7 +399,7 @@ int main(int argc, char *argv[])
argv[4]); argv[4]);
} }
else else
fprintf(stderr, fprintf(stderr,
"ERROR: wrong number of parameters (%d).\n", "ERROR: wrong number of parameters (%d).\n",
argc); argc);
} }
@ -407,17 +407,17 @@ int main(int argc, char *argv[])
{ {
if (argc == 6) if (argc == 6)
{ {
My_Account *acc = _my_cache_account_find(my_cache, argv[4]); My_Account * acc = _my_cache_account_find(my_cache, argv[4]);
if (acc) if (acc)
{ {
My_Post *post = _my_post_new(argv[5]); My_Post * post = _my_post_new(argv[5]);
acc->posts = eina_list_append(acc->posts, post); acc->posts = eina_list_append(acc->posts, post);
} }
else else
fprintf(stderr, "ERROR: unknown account: '%s'\n", argv[4]); fprintf(stderr, "ERROR: unknown account: '%s'\n", argv[4]);
} }
else else
fprintf(stderr, fprintf(stderr,
"ERROR: wrong number of parameters (%d).\n", "ERROR: wrong number of parameters (%d).\n",
argc); argc);
} }
@ -425,32 +425,32 @@ int main(int argc, char *argv[])
{ {
if (argc == 6) if (argc == 6)
{ {
My_Account *acc = _my_cache_account_find(my_cache, argv[4]); My_Account * acc = _my_cache_account_find(my_cache, argv[4]);
if (acc) if (acc)
{ {
My_Message *msg = _my_message_new(argv[5]); My_Message * msg = _my_message_new(argv[5]);
acc->messages = eina_list_append(acc->messages, msg); acc->messages = eina_list_append(acc->messages, msg);
} }
else else
fprintf(stderr, "ERROR: unknown account: '%s'\n", argv[4]); fprintf(stderr, "ERROR: unknown account: '%s'\n", argv[4]);
} }
else else
fprintf(stderr, fprintf(stderr,
"ERROR: wrong number of parameters (%d).\n", "ERROR: wrong number of parameters (%d).\n",
argc); argc);
} }
else else
fprintf(stderr, "ERROR: unknown action '%s'\n", argv[2]); fprintf(stderr, "ERROR: unknown action '%s'\n", argv[2]);
} }
printf("My_Cache:\n" printf("My_Cache:\n"
"\tversion.: %#x\n" "\tversion.: %#x\n"
"\taccounts: %u\n", "\taccounts: %u\n",
my_cache->version, my_cache->version,
eina_list_count(my_cache->accounts)); eina_list_count(my_cache->accounts));
EINA_LIST_FOREACH(my_cache->accounts, l_acc, acc) EINA_LIST_FOREACH(my_cache->accounts, l_acc, acc)
{ {
const My_Post *post; const My_Post * post;
printf("\t > %-#8x '%.20s' stats: m=%u, p=%u\n", printf("\t > %-#8x '%.20s' stats: m=%u, p=%u\n",
acc->id, acc->name ? acc->name : "", acc->id, acc->name ? acc->name : "",
@ -459,8 +459,8 @@ int main(int argc, char *argv[])
if (eina_list_count(acc->messages)) if (eina_list_count(acc->messages))
{ {
const Eina_List *l; const Eina_List * l;
const My_Message *msg; const My_Message * msg;
printf("\t |messages:\n"); printf("\t |messages:\n");
EINA_LIST_FOREACH(acc->messages, l, msg) EINA_LIST_FOREACH(acc->messages, l, msg)
@ -475,11 +475,11 @@ int main(int argc, char *argv[])
if (eina_list_count(acc->posts)) if (eina_list_count(acc->posts))
{ {
const Eina_List *l; const Eina_List * l;
const My_Post *post; const My_Post * post;
printf("\t |posts:\n"); printf("\t |posts:\n");
EINA_LIST_FOREACH(acc->posts, l, post) EINA_LIST_FOREACH(acc->posts, l, post)
{ {
if (post->dm_to) if (post->dm_to)
printf("\t | @%s: '%.20s'\n", post->dm_to, post->message); printf("\t | @%s: '%.20s'\n", post->dm_to, post->message);
@ -488,7 +488,7 @@ int main(int argc, char *argv[])
} }
} }
printf("\n"); printf("\n");
} }
if (!_my_cache_save(my_cache, argv[2])) if (!_my_cache_save(my_cache, argv[2]))
@ -502,4 +502,5 @@ end:
eina_shutdown(); eina_shutdown();
return ret; return ret;
} } /* main */

View File

@ -14,17 +14,17 @@
typedef struct typedef struct
{ {
unsigned int version; // it is recommended to use versioned configuration! unsigned int version; // it is recommended to use versioned configuration!
const char *name; const char * name;
int id; int id;
int not_saved_value; // example of not saved data inside! int not_saved_value; // example of not saved data inside!
Eina_Bool enabled; Eina_Bool enabled;
Eina_List *subs; Eina_List * subs;
} My_Conf_Type; } My_Conf_Type;
typedef struct typedef struct
{ {
const char *server; const char * server;
int port; int port;
} My_Conf_Subtype; } My_Conf_Subtype;
// string that represents the entry in eet file, you might like to have // string that represents the entry in eet file, you might like to have
@ -32,12 +32,11 @@ typedef struct
// different strings // different strings
static const char MY_CONF_FILE_ENTRY[] = "config"; static const char MY_CONF_FILE_ENTRY[] = "config";
// keep the descriptor static global, so it can be // keep the descriptor static global, so it can be
// shared by different functions (load/save) of this and only this // shared by different functions (load/save) of this and only this
// file. // file.
static Eet_Data_Descriptor *_my_conf_descriptor; static Eet_Data_Descriptor * _my_conf_descriptor;
static Eet_Data_Descriptor *_my_conf_sub_descriptor; static Eet_Data_Descriptor * _my_conf_sub_descriptor;
static void static void
_my_conf_descriptor_init(void) _my_conf_descriptor_init(void)
@ -64,11 +63,11 @@ _my_conf_descriptor_init(void)
// Describe the members to be saved: // Describe the members to be saved:
// Use a temporary macro so we don't type a lot, also avoid errors: // Use a temporary macro so we don't type a lot, also avoid errors:
#define MY_CONF_ADD_BASIC(member, eet_type) \ #define MY_CONF_ADD_BASIC(member, eet_type)\
EET_DATA_DESCRIPTOR_ADD_BASIC \ EET_DATA_DESCRIPTOR_ADD_BASIC\
(_my_conf_descriptor, My_Conf_Type, # member, member, eet_type) (_my_conf_descriptor, My_Conf_Type, # member, member, eet_type)
#define MY_CONF_SUB_ADD_BASIC(member, eet_type) \ #define MY_CONF_SUB_ADD_BASIC(member, eet_type)\
EET_DATA_DESCRIPTOR_ADD_BASIC \ EET_DATA_DESCRIPTOR_ADD_BASIC\
(_my_conf_sub_descriptor, My_Conf_Subtype, # member, member, eet_type) (_my_conf_sub_descriptor, My_Conf_Subtype, # member, member, eet_type)
MY_CONF_SUB_ADD_BASIC(server, EET_T_STRING); MY_CONF_SUB_ADD_BASIC(server, EET_T_STRING);
@ -85,20 +84,20 @@ _my_conf_descriptor_init(void)
#undef MY_CONF_ADD_BASIC #undef MY_CONF_ADD_BASIC
#undef MY_CONF_SUB_ADD_BASIC #undef MY_CONF_SUB_ADD_BASIC
} } /* _my_conf_descriptor_init */
static void static void
_my_conf_descriptor_shutdown(void) _my_conf_descriptor_shutdown(void)
{ {
eet_data_descriptor_free(_my_conf_sub_descriptor); eet_data_descriptor_free(_my_conf_sub_descriptor);
eet_data_descriptor_free(_my_conf_descriptor); eet_data_descriptor_free(_my_conf_descriptor);
} } /* _my_conf_descriptor_shutdown */
static My_Conf_Type * static My_Conf_Type *
_my_conf_new(void) _my_conf_new(void)
{ {
My_Conf_Type *my_conf = calloc(1, sizeof(My_Conf_Type)); My_Conf_Type * my_conf = calloc(1, sizeof(My_Conf_Type));
My_Conf_Subtype *sub; My_Conf_Subtype * sub;
if (!my_conf) if (!my_conf)
{ {
fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n"); fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n");
@ -117,12 +116,12 @@ _my_conf_new(void)
} }
return my_conf; return my_conf;
} } /* _my_conf_new */
static void static void
_my_conf_free(My_Conf_Type *my_conf) _my_conf_free(My_Conf_Type * my_conf)
{ {
My_Conf_Subtype *sub; My_Conf_Subtype * sub;
EINA_LIST_FREE(my_conf->subs, sub) EINA_LIST_FREE(my_conf->subs, sub)
{ {
eina_stringshare_del(sub->server); eina_stringshare_del(sub->server);
@ -131,13 +130,13 @@ _my_conf_free(My_Conf_Type *my_conf)
eina_stringshare_del(my_conf->name); eina_stringshare_del(my_conf->name);
free(my_conf); free(my_conf);
} } /* _my_conf_free */
static My_Conf_Type * static My_Conf_Type *
_my_conf_load(const char *filename) _my_conf_load(const char * filename)
{ {
My_Conf_Type *my_conf; My_Conf_Type * my_conf;
Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ); Eet_File * ef = eet_open(filename, EET_FILE_MODE_READ);
if (!ef) if (!ef)
{ {
fprintf(stderr, "ERROR: could not open '%s' for read\n", filename); fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
@ -161,13 +160,13 @@ _my_conf_load(const char *filename)
end: end:
eet_close(ef); eet_close(ef);
return my_conf; return my_conf;
} } /* _my_conf_load */
static Eina_Bool static Eina_Bool
_my_conf_save(const My_Conf_Type *my_conf, const char *filename) _my_conf_save(const My_Conf_Type * my_conf, const char * filename)
{ {
char tmp[PATH_MAX]; char tmp[PATH_MAX];
Eet_File *ef; Eet_File * ef;
Eina_Bool ret; Eina_Bool ret;
unsigned int i, len; unsigned int i, len;
struct stat st; struct stat st;
@ -205,13 +204,13 @@ _my_conf_save(const My_Conf_Type *my_conf, const char *filename)
} }
return ret; return ret;
} } /* _my_conf_save */
int main(int argc, char *argv[]) int main(int argc, char * argv[])
{ {
My_Conf_Type *my_conf; My_Conf_Type * my_conf;
const My_Conf_Subtype *sub; const My_Conf_Subtype * sub;
const Eina_List *l; const Eina_List * l;
int ret = 0; int ret = 0;
if (argc != 3) if (argc != 3)
@ -236,7 +235,7 @@ int main(int argc, char *argv[])
} }
} }
printf("My_Conf_Type:\n" printf("My_Conf_Type:\n"
"\tversion: %#x\n" "\tversion: %#x\n"
"\tname...: '%s'\n" "\tname...: '%s'\n"
"\tid.....: %d\n" "\tid.....: %d\n"
@ -263,4 +262,5 @@ end:
eina_shutdown(); eina_shutdown();
return ret; return ret;
} } /* main */

View File

@ -14,10 +14,10 @@
typedef struct typedef struct
{ {
unsigned int version; // it is recommended to use versioned configuration! unsigned int version; // it is recommended to use versioned configuration!
const char *name; const char * name;
int id; int id;
int not_saved_value; // example of not saved data inside! int not_saved_value; // example of not saved data inside!
Eina_Bool enabled; Eina_Bool enabled;
} My_Conf_Type; } My_Conf_Type;
// string that represents the entry in eet file, you might like to have // string that represents the entry in eet file, you might like to have
@ -25,11 +25,10 @@ typedef struct
// different strings // different strings
static const char MY_CONF_FILE_ENTRY[] = "config"; static const char MY_CONF_FILE_ENTRY[] = "config";
// keep the descriptor static global, so it can be // keep the descriptor static global, so it can be
// shared by different functions (load/save) of this and only this // shared by different functions (load/save) of this and only this
// file. // file.
static Eet_Data_Descriptor *_my_conf_descriptor; static Eet_Data_Descriptor * _my_conf_descriptor;
static void static void
_my_conf_descriptor_init(void) _my_conf_descriptor_init(void)
@ -53,8 +52,8 @@ _my_conf_descriptor_init(void)
// Describe the members to be saved: // Describe the members to be saved:
// Use a temporary macro so we don't type a lot, also avoid errors: // Use a temporary macro so we don't type a lot, also avoid errors:
#define MY_CONF_ADD_BASIC(member, eet_type) \ #define MY_CONF_ADD_BASIC(member, eet_type)\
EET_DATA_DESCRIPTOR_ADD_BASIC \ EET_DATA_DESCRIPTOR_ADD_BASIC\
(_my_conf_descriptor, My_Conf_Type, # member, member, eet_type) (_my_conf_descriptor, My_Conf_Type, # member, member, eet_type)
MY_CONF_ADD_BASIC(version, EET_T_UINT); MY_CONF_ADD_BASIC(version, EET_T_UINT);
@ -63,18 +62,18 @@ _my_conf_descriptor_init(void)
MY_CONF_ADD_BASIC(enabled, EET_T_UCHAR); MY_CONF_ADD_BASIC(enabled, EET_T_UCHAR);
#undef MY_CONF_ADD_BASIC #undef MY_CONF_ADD_BASIC
} } /* _my_conf_descriptor_init */
static void static void
_my_conf_descriptor_shutdown(void) _my_conf_descriptor_shutdown(void)
{ {
eet_data_descriptor_free(_my_conf_descriptor); eet_data_descriptor_free(_my_conf_descriptor);
} } /* _my_conf_descriptor_shutdown */
static My_Conf_Type * static My_Conf_Type *
_my_conf_new(void) _my_conf_new(void)
{ {
My_Conf_Type *my_conf = calloc(1, sizeof(My_Conf_Type)); My_Conf_Type * my_conf = calloc(1, sizeof(My_Conf_Type));
if (!my_conf) if (!my_conf)
{ {
fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n"); fprintf(stderr, "ERROR: could not calloc My_Conf_Type\n");
@ -84,20 +83,20 @@ _my_conf_new(void)
my_conf->version = 0x112233; my_conf->version = 0x112233;
my_conf->enabled = EINA_TRUE; my_conf->enabled = EINA_TRUE;
return my_conf; return my_conf;
} } /* _my_conf_new */
static void static void
_my_conf_free(My_Conf_Type *my_conf) _my_conf_free(My_Conf_Type * my_conf)
{ {
eina_stringshare_del(my_conf->name); eina_stringshare_del(my_conf->name);
free(my_conf); free(my_conf);
} } /* _my_conf_free */
static My_Conf_Type * static My_Conf_Type *
_my_conf_load(const char *filename) _my_conf_load(const char * filename)
{ {
My_Conf_Type *my_conf; My_Conf_Type * my_conf;
Eet_File *ef = eet_open(filename, EET_FILE_MODE_READ); Eet_File * ef = eet_open(filename, EET_FILE_MODE_READ);
if (!ef) if (!ef)
{ {
fprintf(stderr, "ERROR: could not open '%s' for read\n", filename); fprintf(stderr, "ERROR: could not open '%s' for read\n", filename);
@ -121,13 +120,13 @@ _my_conf_load(const char *filename)
end: end:
eet_close(ef); eet_close(ef);
return my_conf; return my_conf;
} } /* _my_conf_load */
static Eina_Bool static Eina_Bool
_my_conf_save(const My_Conf_Type *my_conf, const char *filename) _my_conf_save(const My_Conf_Type * my_conf, const char * filename)
{ {
char tmp[PATH_MAX]; char tmp[PATH_MAX];
Eet_File *ef; Eet_File * ef;
Eina_Bool ret; Eina_Bool ret;
unsigned int i, len; unsigned int i, len;
struct stat st; struct stat st;
@ -165,11 +164,11 @@ _my_conf_save(const My_Conf_Type *my_conf, const char *filename)
} }
return ret; return ret;
} } /* _my_conf_save */
int main(int argc, char *argv[]) int main(int argc, char * argv[])
{ {
My_Conf_Type *my_conf; My_Conf_Type * my_conf;
int ret = 0; int ret = 0;
if (argc != 3) if (argc != 3)
@ -194,7 +193,7 @@ int main(int argc, char *argv[])
} }
} }
printf("My_Conf_Type:\n" printf("My_Conf_Type:\n"
"\tversion: %#x\n" "\tversion: %#x\n"
"\tname...: '%s'\n" "\tname...: '%s'\n"
"\tid.....: %d\n" "\tid.....: %d\n"
@ -215,4 +214,5 @@ end:
eina_shutdown(); eina_shutdown();
return ret; return ret;
} } /* main */

File diff suppressed because it is too large Load Diff

View File

@ -7,60 +7,60 @@
#include <Eina.h> #include <Eina.h>
typedef enum _Eet_Convert_Type Eet_Convert_Type; typedef enum _Eet_Convert_Type Eet_Convert_Type;
enum _Eet_Convert_Type enum _Eet_Convert_Type
{ {
EET_D_NOT_CONVERTED = 0, EET_D_NOT_CONVERTED = 0,
EET_D_FLOAT = 1 << 1, EET_D_FLOAT = 1 << 1,
EET_D_DOUBLE = 1 << 2, EET_D_DOUBLE = 1 << 2,
EET_D_FIXED_POINT = 1 << 4 EET_D_FIXED_POINT = 1 << 4
}; };
typedef struct _Eet_String Eet_String; typedef struct _Eet_String Eet_String;
struct _Eet_String struct _Eet_String
{ {
const char *mmap; const char * mmap;
char *str; char * str;
int hash; int hash;
int len; int len;
int next; int next;
int prev; int prev;
float f; float f;
double d; double d;
Eina_F32p32 fp; Eina_F32p32 fp;
Eet_Convert_Type type; Eet_Convert_Type type;
}; };
struct _Eet_Dictionary struct _Eet_Dictionary
{ {
Eet_String *all; Eet_String * all;
int size; int size;
int offset; int offset;
int hash[256]; int hash[256];
int count; int count;
int total; int total;
const char *start; const char * start;
const char *end; const char * end;
}; };
struct _Eet_Node struct _Eet_Node
{ {
int type; int type;
int count; int count;
const char *name; const char * name;
const char *key; const char * key;
Eet_Node *values; Eet_Node * values;
Eet_Node *next; Eet_Node * next;
Eet_Node *parent; Eet_Node * parent;
Eet_Node_Data data; Eet_Node_Data data;
}; };
@ -76,92 +76,93 @@ extern int _eet_log_dom_global;
*/ */
#ifdef EET_DEFAULT_LOG_COLOR #ifdef EET_DEFAULT_LOG_COLOR
# undef EET_DEFAULT_LOG_COLOR # undef EET_DEFAULT_LOG_COLOR
#endif #endif /* ifdef EET_DEFAULT_LOG_COLOR */
#define EET_DEFAULT_LOG_COLOR EINA_COLOR_CYAN #define EET_DEFAULT_LOG_COLOR EINA_COLOR_CYAN
#ifdef ERR #ifdef ERR
# undef ERR # undef ERR
#endif #endif /* ifdef ERR */
#define ERR(...) EINA_LOG_DOM_ERR(_eet_log_dom_global, __VA_ARGS__) #define ERR(...) EINA_LOG_DOM_ERR(_eet_log_dom_global, __VA_ARGS__)
#ifdef DBG #ifdef DBG
# undef DBG # undef DBG
#endif #endif /* ifdef DBG */
#define DBG(...) EINA_LOG_DOM_DBG(_eet_log_dom_global, __VA_ARGS__) #define DBG(...) EINA_LOG_DOM_DBG(_eet_log_dom_global, __VA_ARGS__)
#ifdef INF #ifdef INF
# undef INF # undef INF
#endif #endif /* ifdef INF */
#define INF(...) EINA_LOG_DOM_INFO(_eet_log_dom_global, __VA_ARGS__) #define INF(...) EINA_LOG_DOM_INFO(_eet_log_dom_global, __VA_ARGS__)
#ifdef WRN #ifdef WRN
# undef WRN # undef WRN
#endif #endif /* ifdef WRN */
#define WRN(...) EINA_LOG_DOM_WARN(_eet_log_dom_global, __VA_ARGS__) #define WRN(...) EINA_LOG_DOM_WARN(_eet_log_dom_global, __VA_ARGS__)
#ifdef CRIT #ifdef CRIT
# undef CRIT # undef CRIT
#endif #endif /* ifdef CRIT */
#define CRIT(...) EINA_LOG_DOM_CRIT(_eet_log_dom_global, __VA_ARGS__) #define CRIT(...) EINA_LOG_DOM_CRIT(_eet_log_dom_global, __VA_ARGS__)
Eet_Dictionary *eet_dictionary_add(void); Eet_Dictionary * eet_dictionary_add(void);
void eet_dictionary_free(Eet_Dictionary *ed); void eet_dictionary_free(Eet_Dictionary * ed);
int eet_dictionary_string_add(Eet_Dictionary *ed, int eet_dictionary_string_add(Eet_Dictionary * ed,
const char *string); const char * string);
int eet_dictionary_string_get_size(const Eet_Dictionary *ed, int eet_dictionary_string_get_size(const Eet_Dictionary * ed,
int index); int index);
const char * eet_dictionary_string_get_char(const Eet_Dictionary *ed, const char * eet_dictionary_string_get_char(const Eet_Dictionary * ed,
int index); int index);
Eina_Bool eet_dictionary_string_get_float(const Eet_Dictionary *ed, Eina_Bool eet_dictionary_string_get_float(const Eet_Dictionary * ed,
int index, int index,
float *result); float * result);
Eina_Bool eet_dictionary_string_get_double(const Eet_Dictionary *ed, Eina_Bool eet_dictionary_string_get_double(const Eet_Dictionary * ed,
int index, int index,
double *result); double * result);
Eina_Bool eet_dictionary_string_get_fp(const Eet_Dictionary *ed, Eina_Bool eet_dictionary_string_get_fp(const Eet_Dictionary * ed,
int index, int index,
Eina_F32p32 *result); Eina_F32p32 * result);
int eet_dictionary_string_get_hash(const Eet_Dictionary *ed, int eet_dictionary_string_get_hash(const Eet_Dictionary * ed,
int index); int index);
int _eet_hash_gen(const char *key, int hash_size); int _eet_hash_gen(const char * key, int hash_size);
const void * eet_identity_check(const void *data_base, const void * eet_identity_check(const void * data_base,
unsigned int data_length, unsigned int data_length,
void **sha1, void ** sha1,
int *sha1_length, int * sha1_length,
const void *signature_base, const void * signature_base,
unsigned int signature_length, unsigned int signature_length,
const void **raw_signature_base, const void ** raw_signature_base,
unsigned int *raw_signature_length, unsigned int * raw_signature_length,
int *x509_length); int * x509_length);
void * eet_identity_compute_sha1(const void *data_base, void * eet_identity_compute_sha1(const void * data_base,
unsigned int data_length, unsigned int data_length,
int *sha1_length); int * sha1_length);
Eet_Error eet_cipher(const void *data, Eet_Error eet_cipher(const void * data,
unsigned int size, unsigned int size,
const char *key, const char * key,
unsigned int length, unsigned int length,
void **result, void ** result,
unsigned int *result_length); unsigned int * result_length);
Eet_Error eet_decipher(const void *data, Eet_Error eet_decipher(const void * data,
unsigned int size, unsigned int size,
const char *key, const char * key,
unsigned int length, unsigned int length,
void **result, void ** result,
unsigned int *result_length); unsigned int * result_length);
Eet_Error eet_identity_sign(FILE *fp, Eet_Key *key); Eet_Error eet_identity_sign(FILE * fp,
void eet_identity_unref(Eet_Key *key); Eet_Key * key);
void eet_identity_ref(Eet_Key *key); void eet_identity_unref(Eet_Key * key);
void eet_identity_ref(Eet_Key * key);
void eet_node_shutdown(void); void eet_node_shutdown(void);
int eet_node_init(void); int eet_node_init(void);
Eet_Node *eet_node_new(void); Eet_Node * eet_node_new(void);
void eet_node_free(Eet_Node *node); void eet_node_free(Eet_Node * node);
#ifndef PATH_MAX #ifndef PATH_MAX
# define PATH_MAX 4096 # define PATH_MAX 4096
#endif #endif /* ifndef PATH_MAX */
#ifdef DNDEBUG #ifdef DNDEBUG
# define EET_ASSERT(Test, Do) if (Test == 0) {Do; } # define EET_ASSERT(Test, Do) if (Test == 0) {Do; }
#else #else /* ifdef DNDEBUG */
# define EET_ASSERT(Test, Do) if (Test == 0) {abort(); } # define EET_ASSERT(Test, Do) if (Test == 0) {abort(); }
#endif #endif /* ifdef DNDEBUG */
#endif #endif /* ifndef _EET_PRIVATE_H */

View File

@ -1,6 +1,6 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include <config.h> # include <config.h>
#endif #endif /* ifdef HAVE_CONFIG_H */
#ifdef HAVE_ALLOCA_H #ifdef HAVE_ALLOCA_H
# include <alloca.h> # include <alloca.h>
@ -11,13 +11,13 @@
#elif defined _MSC_VER #elif defined _MSC_VER
# include <malloc.h> # include <malloc.h>
# define alloca _alloca # define alloca _alloca
#else #else /* ifdef HAVE_ALLOCA_H */
# include <stddef.h> # include <stddef.h>
# ifdef __cplusplus # ifdef __cplusplus
extern "C" extern "C"
# endif # endif /* ifdef __cplusplus */
void *alloca (size_t); void * alloca (size_t);
#endif #endif /* ifdef HAVE_ALLOCA_H */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -27,17 +27,17 @@ void *alloca (size_t);
#ifndef _MSC_VER #ifndef _MSC_VER
# include <unistd.h> # include <unistd.h>
#endif #endif /* ifndef _MSC_VER */
#ifdef HAVE_NETINET_IN_H #ifdef HAVE_NETINET_IN_H
# include <netinet/in.h> # include <netinet/in.h>
#endif #endif /* ifdef HAVE_NETINET_IN_H */
#ifdef HAVE_SIGNATURE #ifdef HAVE_SIGNATURE
# ifdef HAVE_GNUTLS # ifdef HAVE_GNUTLS
# include <gnutls/gnutls.h> # include <gnutls/gnutls.h>
# include <gnutls/x509.h> # include <gnutls/x509.h>
# else # else /* ifdef HAVE_GNUTLS */
# include <openssl/rsa.h> # include <openssl/rsa.h>
# include <openssl/objects.h> # include <openssl/objects.h>
# include <openssl/err.h> # include <openssl/err.h>
@ -47,23 +47,23 @@ void *alloca (size_t);
# include <openssl/evp.h> # include <openssl/evp.h>
# include <openssl/x509.h> # include <openssl/x509.h>
# include <openssl/pem.h> # include <openssl/pem.h>
# endif # endif /* ifdef HAVE_GNUTLS */
#endif #endif /* ifdef HAVE_SIGNATURE */
#ifdef HAVE_OPENSSL #ifdef HAVE_OPENSSL
# include <openssl/sha.h> # include <openssl/sha.h>
#endif #endif /* ifdef HAVE_OPENSSL */
#ifdef HAVE_CIPHER #ifdef HAVE_CIPHER
# ifdef HAVE_GNUTLS # ifdef HAVE_GNUTLS
# include <gnutls/x509.h> # include <gnutls/x509.h>
# include <gcrypt.h> # include <gcrypt.h>
# else # else /* ifdef HAVE_GNUTLS */
# include <openssl/evp.h> # include <openssl/evp.h>
# include <openssl/hmac.h> # include <openssl/hmac.h>
# include <openssl/rand.h> # include <openssl/rand.h>
# endif # endif /* ifdef HAVE_GNUTLS */
#endif #endif /* ifdef HAVE_CIPHER */
#include "Eet.h" #include "Eet.h"
#include "Eet_private.h" #include "Eet_private.h"
@ -71,58 +71,58 @@ void *alloca (size_t);
#define EET_MAGIC_SIGN 0x1ee74271 #define EET_MAGIC_SIGN 0x1ee74271
#ifdef HAVE_GNUTLS #ifdef HAVE_GNUTLS
# define MAX_KEY_LEN 32 # define MAX_KEY_LEN 32
# define MAX_IV_LEN 16 # define MAX_IV_LEN 16
#else #else /* ifdef HAVE_GNUTLS */
# define MAX_KEY_LEN EVP_MAX_KEY_LENGTH # define MAX_KEY_LEN EVP_MAX_KEY_LENGTH
# define MAX_IV_LEN EVP_MAX_IV_LENGTH # define MAX_IV_LEN EVP_MAX_IV_LENGTH
#endif #endif /* ifdef HAVE_GNUTLS */
#ifdef HAVE_CIPHER #ifdef HAVE_CIPHER
# ifdef HAVE_GNUTLS # ifdef HAVE_GNUTLS
static Eet_Error eet_hmac_sha1(const void *key, static Eet_Error eet_hmac_sha1(const void * key,
size_t key_len, size_t key_len,
const void *data, const void * data,
size_t data_len, size_t data_len,
unsigned char *res); unsigned char * res);
# endif # endif /* ifdef HAVE_GNUTLS */
static Eet_Error eet_pbkdf2_sha1(const char *key, static Eet_Error eet_pbkdf2_sha1(const char * key,
int key_len, int key_len,
const unsigned char *salt, const unsigned char * salt,
unsigned int salt_len, unsigned int salt_len,
int iter, int iter,
unsigned char *res, unsigned char * res,
int res_len); int res_len);
#endif #endif /* ifdef HAVE_CIPHER */
struct _Eet_Key struct _Eet_Key
{ {
int references; int references;
#ifdef HAVE_SIGNATURE #ifdef HAVE_SIGNATURE
# ifdef HAVE_GNUTLS # ifdef HAVE_GNUTLS
gnutls_x509_crt_t certificate; gnutls_x509_crt_t certificate;
gnutls_x509_privkey_t private_key; gnutls_x509_privkey_t private_key;
# else # else /* ifdef HAVE_GNUTLS */
X509 *certificate; X509 * certificate;
EVP_PKEY *private_key; EVP_PKEY * private_key;
# endif # endif /* ifdef HAVE_GNUTLS */
#endif #endif /* ifdef HAVE_SIGNATURE */
}; };
EAPI Eet_Key * EAPI Eet_Key *
eet_identity_open(const char *certificate_file, eet_identity_open(const char * certificate_file,
const char *private_key_file, const char * private_key_file,
Eet_Key_Password_Callback cb) Eet_Key_Password_Callback cb)
{ {
#ifdef HAVE_SIGNATURE #ifdef HAVE_SIGNATURE
/* Signature declarations */ /* Signature declarations */
Eet_Key *key = NULL; Eet_Key * key = NULL;
FILE *fp = NULL; FILE * fp = NULL;
# ifdef HAVE_GNUTLS # ifdef HAVE_GNUTLS
/* Gnutls private declarations */ /* Gnutls private declarations */
int fd = -1; int fd = -1;
struct stat st; struct stat st;
void *data = NULL; void * data = NULL;
gnutls_datum_t load_file = { NULL, 0 }; gnutls_datum_t load_file = { NULL, 0 };
char pass[1024]; char pass[1024];
@ -208,7 +208,7 @@ eet_identity_open(const char *certificate_file,
if (munmap(data, st.st_size)) if (munmap(data, st.st_size))
goto on_error; goto on_error;
fclose(fp); fclose(fp);
return key; return key;
@ -230,10 +230,10 @@ on_error:
if (data) if (data)
munmap(data, st.st_size); munmap(data, st.st_size);
# else # else /* ifdef HAVE_GNUTLS */
/* Openssl private declarations */ /* Openssl private declarations */
EVP_PKEY *pkey = NULL; EVP_PKEY * pkey = NULL;
X509 *cert = NULL; X509 * cert = NULL;
/* Load the X509 certificate in memory. */ /* Load the X509 certificate in memory. */
fp = fopen(certificate_file, "r"); fp = fopen(certificate_file, "r");
@ -278,13 +278,13 @@ on_error:
if (pkey) if (pkey)
EVP_PKEY_free(pkey); EVP_PKEY_free(pkey);
# endif # endif /* ifdef HAVE_GNUTLS */
#endif #endif /* ifdef HAVE_SIGNATURE */
return NULL; return NULL;
} } /* eet_identity_open */
EAPI void EAPI void
eet_identity_close(Eet_Key *key) eet_identity_close(Eet_Key * key)
{ {
#ifdef HAVE_SIGNATURE #ifdef HAVE_SIGNATURE
if (!key || (key->references > 0)) if (!key || (key->references > 0))
@ -293,20 +293,21 @@ eet_identity_close(Eet_Key *key)
# ifdef HAVE_GNUTLS # ifdef HAVE_GNUTLS
gnutls_x509_crt_deinit(key->certificate); gnutls_x509_crt_deinit(key->certificate);
gnutls_x509_privkey_deinit(key->private_key); gnutls_x509_privkey_deinit(key->private_key);
# else # else /* ifdef HAVE_GNUTLS */
X509_free(key->certificate); X509_free(key->certificate);
EVP_PKEY_free(key->private_key); EVP_PKEY_free(key->private_key);
# endif # endif /* ifdef HAVE_GNUTLS */
free(key); free(key);
#endif #endif /* ifdef HAVE_SIGNATURE */
} } /* eet_identity_close */
EAPI void EAPI void
eet_identity_print(Eet_Key *key, FILE *out) eet_identity_print(Eet_Key * key,
FILE * out)
{ {
#ifdef HAVE_SIGNATURE #ifdef HAVE_SIGNATURE
# ifdef HAVE_GNUTLS # ifdef HAVE_GNUTLS
const char *names[6] = { const char * names[6] = {
"Modulus", "Modulus",
"Public exponent", "Public exponent",
"Private exponent", "Private exponent",
@ -318,7 +319,7 @@ eet_identity_print(Eet_Key *key, FILE *out)
gnutls_datum_t data = { NULL, 0 }; gnutls_datum_t data = { NULL, 0 };
gnutls_datum_t rsa_raw[6]; gnutls_datum_t rsa_raw[6];
size_t size = 128; size_t size = 128;
char *res = NULL; char * res = NULL;
char buf[33]; char buf[33];
unsigned int i, j; unsigned int i, j;
@ -344,9 +345,7 @@ eet_identity_print(Eet_Key *key, FILE *out)
for (i = 0; i < 6; i++) for (i = 0; i < 6; i++)
{ {
while ((err = while ((err = gnutls_hex_encode(rsa_raw + i, res, &size)) ==
gnutls_hex_encode(rsa_raw + i, res,
&size)) ==
GNUTLS_E_SHORT_MEMORY_BUFFER) GNUTLS_E_SHORT_MEMORY_BUFFER)
{ {
size += 128; size += 128;
@ -370,7 +369,8 @@ eet_identity_print(Eet_Key *key, FILE *out)
if (key->certificate) if (key->certificate)
{ {
fprintf(out, "Public certificate:\n"); fprintf(out, "Public certificate:\n");
if (gnutls_x509_crt_print(key->certificate, GNUTLS_X509_CRT_FULL, &data)) if (gnutls_x509_crt_print(key->certificate, GNUTLS_X509_CRT_FULL,
&data))
goto on_error; goto on_error;
fprintf(out, "%s\n", data.data); fprintf(out, "%s\n", data.data);
@ -386,10 +386,10 @@ on_error:
gnutls_free(data.data); gnutls_free(data.data);
return; return;
# else # else /* ifdef HAVE_GNUTLS */
RSA *rsa; RSA * rsa;
DSA *dsa; DSA * dsa;
DH *dh; DH * dh;
if (!key) if (!key)
return; return;
@ -417,39 +417,40 @@ on_error:
fprintf(out, "Public certificate:\n"); fprintf(out, "Public certificate:\n");
X509_print_fp(out, key->certificate); X509_print_fp(out, key->certificate);
# endif # endif /* ifdef HAVE_GNUTLS */
#else #else /* ifdef HAVE_SIGNATURE */
ERR("You need to compile signature support in EET."); ERR("You need to compile signature support in EET.");
#endif #endif /* ifdef HAVE_SIGNATURE */
} } /* eet_identity_print */
void void
eet_identity_ref(Eet_Key *key) eet_identity_ref(Eet_Key * key)
{ {
if (key == NULL) if (key == NULL)
return; return;
key->references++; key->references++;
} } /* eet_identity_ref */
void void
eet_identity_unref(Eet_Key *key) eet_identity_unref(Eet_Key * key)
{ {
if (key == NULL) if (key == NULL)
return; return;
key->references--; key->references--;
eet_identity_close(key); eet_identity_close(key);
} } /* eet_identity_unref */
void * void *
eet_identity_compute_sha1(const void *data_base, unsigned int data_length, eet_identity_compute_sha1(const void * data_base,
int *sha1_length) unsigned int data_length,
int * sha1_length)
{ {
void *result; void * result;
#ifdef HAVE_SIGNATURE #ifdef HAVE_SIGNATURE
# ifdef HAVE_GNUTLS # ifdef HAVE_GNUTLS
result = malloc(gcry_md_get_algo_dlen(GCRY_MD_SHA1)); result = malloc(gcry_md_get_algo_dlen(GCRY_MD_SHA1));
if (!result) if (!result)
return NULL; return NULL;
@ -458,8 +459,8 @@ eet_identity_compute_sha1(const void *data_base, unsigned int data_length,
if (sha1_length) if (sha1_length)
*sha1_length = gcry_md_get_algo_dlen(GCRY_MD_SHA1); *sha1_length = gcry_md_get_algo_dlen(GCRY_MD_SHA1);
# else # else /* ifdef HAVE_GNUTLS */
# ifdef HAVE_OPENSSL # ifdef HAVE_OPENSSL
result = malloc(SHA_DIGEST_LENGTH); result = malloc(SHA_DIGEST_LENGTH);
if (!result) if (!result)
return NULL; return NULL;
@ -468,37 +469,38 @@ eet_identity_compute_sha1(const void *data_base, unsigned int data_length,
if (sha1_length) if (sha1_length)
*sha1_length = SHA_DIGEST_LENGTH; *sha1_length = SHA_DIGEST_LENGTH;
# else # else /* ifdef HAVE_OPENSSL */
result = NULL; result = NULL;
# endif # endif /* ifdef HAVE_OPENSSL */
# endif # endif /* ifdef HAVE_GNUTLS */
#else #else /* ifdef HAVE_SIGNATURE */
result = NULL; result = NULL;
#endif #endif /* ifdef HAVE_SIGNATURE */
return result; return result;
} } /* eet_identity_compute_sha1 */
Eet_Error Eet_Error
eet_identity_sign(FILE *fp, Eet_Key *key) eet_identity_sign(FILE * fp,
Eet_Key * key)
{ {
#ifdef HAVE_SIGNATURE #ifdef HAVE_SIGNATURE
Eet_Error err = EET_ERROR_NONE; Eet_Error err = EET_ERROR_NONE;
struct stat st_buf; struct stat st_buf;
void *data; void * data;
int fd; int fd;
int head[3]; int head[3];
unsigned char *sign = NULL; unsigned char * sign = NULL;
unsigned char *cert = NULL; unsigned char * cert = NULL;
# ifdef HAVE_GNUTLS # ifdef HAVE_GNUTLS
gnutls_datum_t datum = { NULL, 0 }; gnutls_datum_t datum = { NULL, 0 };
size_t sign_len = 0; size_t sign_len = 0;
size_t cert_len = 0; size_t cert_len = 0;
# else # else /* ifdef HAVE_GNUTLS */
EVP_MD_CTX md_ctx; EVP_MD_CTX md_ctx;
unsigned int sign_len = 0; unsigned int sign_len = 0;
int cert_len = 0; int cert_len = 0;
# endif # endif /* ifdef HAVE_GNUTLS */
/* A few check and flush pending write. */ /* A few check and flush pending write. */
if (!fp || !key || !key->certificate || !key->private_key) if (!fp || !key || !key->certificate || !key->private_key)
@ -568,7 +570,7 @@ eet_identity_sign(FILE *fp, Eet_Key *key)
goto on_error; goto on_error;
} }
# else # else /* ifdef HAVE_GNUTLS */
sign_len = EVP_PKEY_size(key->private_key); sign_len = EVP_PKEY_size(key->private_key);
sign = malloc(sign_len); sign = malloc(sign_len);
if (sign == NULL) if (sign == NULL)
@ -600,7 +602,7 @@ eet_identity_sign(FILE *fp, Eet_Key *key)
goto on_error; goto on_error;
} }
# endif # endif /* ifdef HAVE_GNUTLS */
/* Append the signature at the end of the file. */ /* Append the signature at the end of the file. */
head[0] = (int)htonl ((unsigned int)EET_MAGIC_SIGN); head[0] = (int)htonl ((unsigned int)EET_MAGIC_SIGN);
head[1] = (int)htonl ((unsigned int)sign_len); head[1] = (int)htonl ((unsigned int)sign_len);
@ -629,36 +631,36 @@ on_error:
if (cert) if (cert)
free(cert); free(cert);
# else # else /* ifdef HAVE_GNUTLS */
if (cert) if (cert)
OPENSSL_free(cert); OPENSSL_free(cert);
# endif # endif /* ifdef HAVE_GNUTLS */
if (sign) if (sign)
free(sign); free(sign);
munmap(data, st_buf.st_size); munmap(data, st_buf.st_size);
return err; return err;
#else #else /* ifdef HAVE_SIGNATURE */
return EET_ERROR_NOT_IMPLEMENTED; return EET_ERROR_NOT_IMPLEMENTED;
#endif #endif /* ifdef HAVE_SIGNATURE */
} } /* eet_identity_sign */
const void * const void *
eet_identity_check(const void *data_base, eet_identity_check(const void * data_base,
unsigned int data_length, unsigned int data_length,
void **sha1, void ** sha1,
int *sha1_length, int * sha1_length,
const void *signature_base, const void * signature_base,
unsigned int signature_length, unsigned int signature_length,
const void **raw_signature_base, const void ** raw_signature_base,
unsigned int *raw_signature_length, unsigned int * raw_signature_length,
int *x509_length) int * x509_length)
{ {
#ifdef HAVE_SIGNATURE #ifdef HAVE_SIGNATURE
const int *header = signature_base; const int * header = signature_base;
const unsigned char *sign; const unsigned char * sign;
const unsigned char *cert_der; const unsigned char * cert_der;
int sign_len; int sign_len;
int cert_len; int cert_len;
int magic; int magic;
@ -688,10 +690,10 @@ eet_identity_check(const void *data_base,
gnutls_datum_t datum; gnutls_datum_t datum;
gnutls_datum_t signature; gnutls_datum_t signature;
# if EET_USE_NEW_GNUTLS_API # if EET_USE_NEW_GNUTLS_API
unsigned char *hash; unsigned char * hash;
gcry_md_hd_t md; gcry_md_hd_t md;
int err; int err;
# endif # endif /* if EET_USE_NEW_GNUTLS_API */
/* Create an understanding certificate structure for gnutls */ /* Create an understanding certificate structure for gnutls */
datum.data = (void *)cert_der; datum.data = (void *)cert_der;
@ -717,7 +719,7 @@ eet_identity_check(const void *data_base,
hash = gcry_md_read(md, GCRY_MD_SHA1); hash = gcry_md_read(md, GCRY_MD_SHA1);
if (hash == NULL) if (hash == NULL)
{ {
gcry_md_close(md); gcry_md_close(md);
return NULL; return NULL;
} }
@ -726,7 +728,7 @@ eet_identity_check(const void *data_base,
if (!gnutls_x509_crt_verify_hash(cert, 0, &datum, &signature)) if (!gnutls_x509_crt_verify_hash(cert, 0, &datum, &signature))
{ {
gcry_md_close(md); gcry_md_close(md);
return NULL; return NULL;
} }
@ -744,7 +746,7 @@ eet_identity_check(const void *data_base,
} }
gcry_md_close(md); gcry_md_close(md);
# else # else /* if EET_USE_NEW_GNUTLS_API */
datum.data = (void *)data_base; datum.data = (void *)data_base;
datum.size = data_length; datum.size = data_length;
@ -757,13 +759,13 @@ eet_identity_check(const void *data_base,
*sha1_length = -1; *sha1_length = -1;
} }
# endif # endif /* if EET_USE_NEW_GNUTLS_API */
gnutls_x509_crt_deinit(cert); gnutls_x509_crt_deinit(cert);
# else # else /* ifdef HAVE_GNUTLS */
const unsigned char *tmp; const unsigned char * tmp;
EVP_PKEY *pkey; EVP_PKEY * pkey;
X509 *x509; X509 * x509;
EVP_MD_CTX md_ctx; EVP_MD_CTX md_ctx;
int err; int err;
@ -799,7 +801,7 @@ eet_identity_check(const void *data_base,
if (err != 1) if (err != 1)
return NULL; return NULL;
# endif # endif /* ifdef HAVE_GNUTLS */
if (x509_length) if (x509_length)
*x509_length = cert_len; *x509_length = cert_len;
@ -810,15 +812,15 @@ eet_identity_check(const void *data_base,
*raw_signature_length = sign_len; *raw_signature_length = sign_len;
return cert_der; return cert_der;
#else #else /* ifdef HAVE_SIGNATURE */
return NULL; return NULL;
#endif #endif /* ifdef HAVE_SIGNATURE */
} } /* eet_identity_check */
EAPI void EAPI void
eet_identity_certificate_print(const unsigned char *certificate, eet_identity_certificate_print(const unsigned char * certificate,
int der_length, int der_length,
FILE *out) FILE * out)
{ {
#ifdef HAVE_SIGNATURE #ifdef HAVE_SIGNATURE
if (!certificate || !out || der_length <= 0) if (!certificate || !out || der_length <= 0)
@ -854,9 +856,9 @@ on_error:
gnutls_free(datum.data); gnutls_free(datum.data);
gnutls_x509_crt_deinit(cert); gnutls_x509_crt_deinit(cert);
# else # else /* ifdef HAVE_GNUTLS */
const unsigned char *tmp; const unsigned char * tmp;
X509 *x509; X509 * x509;
/* Strange but d2i_X509 seems to put 0 all over the place. */ /* Strange but d2i_X509 seems to put 0 all over the place. */
tmp = alloca(der_length); tmp = alloca(der_length);
@ -868,27 +870,27 @@ on_error:
return; return;
} }
INF("Public certificate :"); INF("Public certificate :");
X509_print_fp(out, x509); X509_print_fp(out, x509);
X509_free(x509); X509_free(x509);
# endif # endif /* ifdef HAVE_GNUTLS */
#else #else /* ifdef HAVE_SIGNATURE */
ERR("You need to compile signature support in EET."); ERR("You need to compile signature support in EET.");
#endif #endif /* ifdef HAVE_SIGNATURE */
} } /* eet_identity_certificate_print */
Eet_Error Eet_Error
eet_cipher(const void *data, eet_cipher(const void * data,
unsigned int size, unsigned int size,
const char *key, const char * key,
unsigned int length, unsigned int length,
void **result, void ** result,
unsigned int *result_length) unsigned int * result_length)
{ {
#ifdef HAVE_CIPHER #ifdef HAVE_CIPHER
/* Cipher declarations */ /* Cipher declarations */
unsigned int *ret = NULL; unsigned int * ret = NULL;
unsigned char iv[MAX_IV_LEN]; unsigned char iv[MAX_IV_LEN];
unsigned char ik[MAX_KEY_LEN]; unsigned char ik[MAX_KEY_LEN];
unsigned char key_material[MAX_IV_LEN + MAX_KEY_LEN]; unsigned char key_material[MAX_IV_LEN + MAX_KEY_LEN];
@ -900,22 +902,22 @@ eet_cipher(const void *data,
/* Gcrypt declarations */ /* Gcrypt declarations */
gcry_error_t err = 0; gcry_error_t err = 0;
gcry_cipher_hd_t cipher; gcry_cipher_hd_t cipher;
# else # else /* ifdef HAVE_GNUTLS */
/* Openssl declarations*/ /* Openssl declarations*/
EVP_CIPHER_CTX ctx; EVP_CIPHER_CTX ctx;
unsigned int *buffer; unsigned int * buffer;
int tmp_len; int tmp_len;
# endif # endif /* ifdef HAVE_GNUTLS */
# ifdef HAVE_GNUTLS # ifdef HAVE_GNUTLS
/* Gcrypt salt generation */ /* Gcrypt salt generation */
gcry_create_nonce((unsigned char *)&salt, sizeof(salt)); gcry_create_nonce((unsigned char *)&salt, sizeof(salt));
# else # else /* ifdef HAVE_GNUTLS */
/* Openssl salt generation */ /* Openssl salt generation */
if (!RAND_bytes((unsigned char *)&salt, sizeof (unsigned int))) if (!RAND_bytes((unsigned char *)&salt, sizeof (unsigned int)))
return EET_ERROR_PRNG_NOT_SEEDED; return EET_ERROR_PRNG_NOT_SEEDED;
#endif # endif /* ifdef HAVE_GNUTLS */
eet_pbkdf2_sha1(key, eet_pbkdf2_sha1(key,
length, length,
@ -925,10 +927,10 @@ eet_cipher(const void *data,
key_material, key_material,
MAX_KEY_LEN + MAX_IV_LEN); MAX_KEY_LEN + MAX_IV_LEN);
memcpy(iv, key_material, MAX_IV_LEN); memcpy(iv, key_material, MAX_IV_LEN);
memcpy(ik, key_material + MAX_IV_LEN, MAX_KEY_LEN); memcpy(ik, key_material + MAX_IV_LEN, MAX_KEY_LEN);
memset(key_material, 0, sizeof (key_material)); memset(key_material, 0, sizeof (key_material));
crypted_length = ((((size + sizeof (unsigned int)) >> 5) + 1) << 5); crypted_length = ((((size + sizeof (unsigned int)) >> 5) + 1) << 5);
ret = malloc(crypted_length + sizeof(unsigned int)); ret = malloc(crypted_length + sizeof(unsigned int));
@ -941,10 +943,10 @@ eet_cipher(const void *data,
} }
*ret = salt; *ret = salt;
memset(&salt, 0, sizeof (salt)); memset(&salt, 0, sizeof (salt));
tmp = htonl(size); tmp = htonl(size);
#ifdef HAVE_GNUTLS # ifdef HAVE_GNUTLS
*(ret + 1) = tmp; *(ret + 1) = tmp;
memcpy(ret + 2, data, size); memcpy(ret + 2, data, size);
@ -977,7 +979,7 @@ eet_cipher(const void *data,
/* Gcrypt close the cipher */ /* Gcrypt close the cipher */
gcry_cipher_close(cipher); gcry_cipher_close(cipher);
# else # else /* ifdef HAVE_GNUTLS */
buffer = alloca(crypted_length); buffer = alloca(crypted_length);
*buffer = tmp; *buffer = tmp;
@ -996,7 +998,8 @@ eet_cipher(const void *data,
/* Openssl encrypt */ /* Openssl encrypt */
if (!EVP_EncryptUpdate(&ctx, (unsigned char *)(ret + 1), &tmp_len, if (!EVP_EncryptUpdate(&ctx, (unsigned char *)(ret + 1), &tmp_len,
(unsigned char *)buffer, size + sizeof (unsigned int))) (unsigned char *)buffer,
size + sizeof(unsigned int)))
goto on_error; goto on_error;
/* Openssl close the cipher */ /* Openssl close the cipher */
@ -1005,7 +1008,7 @@ eet_cipher(const void *data,
goto on_error; goto on_error;
EVP_CIPHER_CTX_cleanup(&ctx); EVP_CIPHER_CTX_cleanup(&ctx);
# endif # endif /* ifdef HAVE_GNUTLS */
/* Set return values */ /* Set return values */
if (result_length) if (result_length)
@ -1027,12 +1030,12 @@ on_error:
if (opened) if (opened)
gcry_cipher_close(cipher); gcry_cipher_close(cipher);
# else # else /* ifdef HAVE_GNUTLS */
/* Openssl error */ /* Openssl error */
if (opened) if (opened)
EVP_CIPHER_CTX_cleanup(&ctx); EVP_CIPHER_CTX_cleanup(&ctx);
# endif # endif /* ifdef HAVE_GNUTLS */
/* General error */ /* General error */
free(ret); free(ret);
if (result) if (result)
@ -1042,8 +1045,8 @@ on_error:
*result_length = 0; *result_length = 0;
return EET_ERROR_ENCRYPT_FAILED; return EET_ERROR_ENCRYPT_FAILED;
#else #else /* ifdef HAVE_CIPHER */
/* Cipher not supported */ /* Cipher not supported */
(void)data; (void)data;
(void)size; (void)size;
(void)key; (void)key;
@ -1051,20 +1054,20 @@ on_error:
(void)result; (void)result;
(void)result_length; (void)result_length;
return EET_ERROR_NOT_IMPLEMENTED; return EET_ERROR_NOT_IMPLEMENTED;
#endif #endif /* ifdef HAVE_CIPHER */
} } /* eet_cipher */
Eet_Error Eet_Error
eet_decipher(const void *data, eet_decipher(const void * data,
unsigned int size, unsigned int size,
const char *key, const char * key,
unsigned int length, unsigned int length,
void **result, void ** result,
unsigned int *result_length) unsigned int * result_length)
{ {
#ifdef HAVE_CIPHER #ifdef HAVE_CIPHER
const unsigned int *over = data; const unsigned int * over = data;
unsigned int *ret = NULL; unsigned int * ret = NULL;
unsigned char ik[MAX_KEY_LEN]; unsigned char ik[MAX_KEY_LEN];
unsigned char iv[MAX_IV_LEN]; unsigned char iv[MAX_IV_LEN];
unsigned char key_material[MAX_KEY_LEN + MAX_IV_LEN]; unsigned char key_material[MAX_KEY_LEN + MAX_IV_LEN];
@ -1080,12 +1083,8 @@ eet_decipher(const void *data,
salt = *over; salt = *over;
/* Generate the iv and the key with the salt */ /* Generate the iv and the key with the salt */
eet_pbkdf2_sha1(key, eet_pbkdf2_sha1(key, length, (unsigned char *)&salt,
length, sizeof(unsigned int), 2048, key_material,
(unsigned char *)&salt,
sizeof(unsigned int),
2048,
key_material,
MAX_KEY_LEN + MAX_IV_LEN); MAX_KEY_LEN + MAX_IV_LEN);
memcpy(iv, key_material, MAX_IV_LEN); memcpy(iv, key_material, MAX_IV_LEN);
@ -1124,18 +1123,15 @@ eet_decipher(const void *data,
memset(ik, 0, sizeof (ik)); memset(ik, 0, sizeof (ik));
/* Gcrypt decrypt */ /* Gcrypt decrypt */
err = gcry_cipher_decrypt(cipher, err = gcry_cipher_decrypt(cipher, ret, tmp_len,
ret, ((unsigned int *)data) + 1, tmp_len);
tmp_len,
((unsigned int *)data) + 1,
tmp_len);
if (err) if (err)
goto on_error; goto on_error;
/* Gcrypt close the cipher */ /* Gcrypt close the cipher */
gcry_cipher_close(cipher); gcry_cipher_close(cipher);
# else # else /* ifdef HAVE_GNUTLS */
EVP_CIPHER_CTX ctx; EVP_CIPHER_CTX ctx;
int opened = 0; int opened = 0;
@ -1156,7 +1152,7 @@ eet_decipher(const void *data,
/* Openssl close the cipher*/ /* Openssl close the cipher*/
EVP_CIPHER_CTX_cleanup(&ctx); EVP_CIPHER_CTX_cleanup(&ctx);
# endif # endif /* ifdef HAVE_GNUTLS */
/* Get the decrypted data size */ /* Get the decrypted data size */
tmp = *ret; tmp = *ret;
tmp = ntohl(tmp); tmp = ntohl(tmp);
@ -1190,7 +1186,7 @@ on_error:
if (opened) if (opened)
EVP_CIPHER_CTX_cleanup(&ctx); EVP_CIPHER_CTX_cleanup(&ctx);
# endif # endif /* ifdef HAVE_GNUTLS */
if (result) if (result)
*result = NULL; *result = NULL;
@ -1201,7 +1197,7 @@ on_error:
free(ret); free(ret);
return EET_ERROR_DECRYPT_FAILED; return EET_ERROR_DECRYPT_FAILED;
#else #else /* ifdef HAVE_CIPHER */
(void)data; (void)data;
(void)size; (void)size;
(void)key; (void)key;
@ -1209,18 +1205,21 @@ on_error:
(void)result; (void)result;
(void)result_length; (void)result_length;
return EET_ERROR_NOT_IMPLEMENTED; return EET_ERROR_NOT_IMPLEMENTED;
#endif #endif /* ifdef HAVE_CIPHER */
} } /* eet_decipher */
#ifdef HAVE_CIPHER #ifdef HAVE_CIPHER
# ifdef HAVE_GNUTLS # ifdef HAVE_GNUTLS
static Eet_Error static Eet_Error
eet_hmac_sha1(const void *key, size_t key_len, eet_hmac_sha1(const void * key,
const void *data, size_t data_len, unsigned char *res) size_t key_len,
const void * data,
size_t data_len,
unsigned char * res)
{ {
size_t hlen = gcry_md_get_algo_dlen (GCRY_MD_SHA1); size_t hlen = gcry_md_get_algo_dlen (GCRY_MD_SHA1);
gcry_md_hd_t mdh; gcry_md_hd_t mdh;
unsigned char *hash; unsigned char * hash;
gpg_error_t err; gpg_error_t err;
err = gcry_md_open(&mdh, GCRY_MD_SHA1, GCRY_MD_FLAG_HMAC); err = gcry_md_open(&mdh, GCRY_MD_SHA1, GCRY_MD_FLAG_HMAC);
@ -1248,22 +1247,23 @@ eet_hmac_sha1(const void *key, size_t key_len,
gcry_md_close(mdh); gcry_md_close(mdh);
return 0; return 0;
} } /* eet_hmac_sha1 */
# endif
# endif /* ifdef HAVE_GNUTLS */
static Eet_Error static Eet_Error
eet_pbkdf2_sha1(const char *key, eet_pbkdf2_sha1(const char * key,
int key_len, int key_len,
const unsigned char *salt, const unsigned char * salt,
unsigned int salt_len, unsigned int salt_len,
int iter, int iter,
unsigned char *res, unsigned char * res,
int res_len) int res_len)
{ {
unsigned char digest[20]; unsigned char digest[20];
unsigned char tab[4]; unsigned char tab[4];
unsigned char *p = res; unsigned char * p = res;
unsigned char *buf; unsigned char * buf;
unsigned long i; unsigned long i;
int digest_len = 20; int digest_len = 20;
int len = res_len; int len = res_len;
@ -1272,7 +1272,7 @@ eet_pbkdf2_sha1(const char *key,
# ifdef HAVE_GNUTLS # ifdef HAVE_GNUTLS
# else # else
HMAC_CTX hctx; HMAC_CTX hctx;
# endif # endif /* ifdef HAVE_GNUTLS */
buf = alloca(salt_len + 4); buf = alloca(salt_len + 4);
if (!buf) if (!buf)
@ -1294,21 +1294,21 @@ eet_pbkdf2_sha1(const char *key,
memcpy(buf, salt, salt_len); memcpy(buf, salt, salt_len);
memcpy(buf + salt_len, tab, 4); memcpy(buf + salt_len, tab, 4);
eet_hmac_sha1(key, key_len, buf, salt_len + 4, digest); eet_hmac_sha1(key, key_len, buf, salt_len + 4, digest);
# else # else /* ifdef HAVE_GNUTLS */
HMAC_Init(&hctx, key, key_len, EVP_sha1()); HMAC_Init(&hctx, key, key_len, EVP_sha1());
HMAC_Update(&hctx, salt, salt_len); HMAC_Update(&hctx, salt, salt_len);
HMAC_Update(&hctx, tab, 4); HMAC_Update(&hctx, tab, 4);
HMAC_Final(&hctx, digest, NULL); HMAC_Final(&hctx, digest, NULL);
# endif # endif /* ifdef HAVE_GNUTLS */
memcpy(p, digest, tmp_len); memcpy(p, digest, tmp_len);
for (j = 1; j < iter; j++) for (j = 1; j < iter; j++)
{ {
# ifdef HAVE_GNUTLS # ifdef HAVE_GNUTLS
eet_hmac_sha1(key, key_len, digest, 20, digest); eet_hmac_sha1(key, key_len, digest, 20, digest);
# else # else /* ifdef HAVE_GNUTLS */
HMAC(EVP_sha1(), key, key_len, digest, 20, digest, NULL); HMAC(EVP_sha1(), key, key_len, digest, 20, digest, NULL);
# endif # endif /* ifdef HAVE_GNUTLS */
for (k = 0; k < tmp_len; k++) for (k = 0; k < tmp_len; k++)
p[k] ^= digest[k]; p[k] ^= digest[k];
} }
@ -1317,7 +1317,8 @@ eet_pbkdf2_sha1(const char *key,
# ifdef HAVE_GNUTLS # ifdef HAVE_GNUTLS
# else # else
HMAC_cleanup(&hctx); HMAC_cleanup(&hctx);
# endif # endif /* ifdef HAVE_GNUTLS */
return 0; return 0;
} } /* eet_pbkdf2_sha1 */
#endif
#endif /* ifdef HAVE_CIPHER */

View File

@ -4,7 +4,7 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include <config.h> # include <config.h>
#endif #endif /* ifdef HAVE_CONFIG_H */
#ifdef HAVE_ALLOCA_H #ifdef HAVE_ALLOCA_H
# include <alloca.h> # include <alloca.h>
@ -15,24 +15,24 @@
#elif defined _MSC_VER #elif defined _MSC_VER
# include <malloc.h> # include <malloc.h>
# define alloca _alloca # define alloca _alloca
#else #else /* ifdef HAVE_ALLOCA_H */
# include <stddef.h> # include <stddef.h>
# ifdef __cplusplus # ifdef __cplusplus
extern "C" extern "C"
# endif # endif /* ifdef __cplusplus */
void *alloca (size_t); void * alloca (size_t);
#endif #endif /* ifdef HAVE_ALLOCA_H */
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#ifdef HAVE_NETINET_IN_H #ifdef HAVE_NETINET_IN_H
# include <netinet/in.h> # include <netinet/in.h>
#endif #endif /* ifdef HAVE_NETINET_IN_H */
#ifdef _WIN32 #ifdef _WIN32
# include <winsock2.h> # include <winsock2.h>
#endif #endif /* ifdef _WIN32 */
#include <Eina.h> #include <Eina.h>
@ -41,7 +41,7 @@ void *alloca (size_t);
#define MAGIC_EET_DATA_PACKET 0x4270ACE1 #define MAGIC_EET_DATA_PACKET 0x4270ACE1
typedef struct _Eet_Message Eet_Message; typedef struct _Eet_Message Eet_Message;
struct _Eet_Message struct _Eet_Message
{ {
int magic; int magic;
@ -50,23 +50,23 @@ struct _Eet_Message
struct _Eet_Connection struct _Eet_Connection
{ {
Eet_Read_Cb *eet_read_cb; Eet_Read_Cb * eet_read_cb;
Eet_Write_Cb *eet_write_cb; Eet_Write_Cb * eet_write_cb;
void *user_data; void * user_data;
size_t allocated; size_t allocated;
size_t size; size_t size;
size_t received; size_t received;
void *buffer; void * buffer;
}; };
EAPI Eet_Connection * EAPI Eet_Connection *
eet_connection_new(Eet_Read_Cb *eet_read_cb, eet_connection_new(Eet_Read_Cb * eet_read_cb,
Eet_Write_Cb *eet_write_cb, Eet_Write_Cb * eet_write_cb,
const void *user_data) const void * user_data)
{ {
Eet_Connection *conn; Eet_Connection * conn;
if (!eet_read_cb || !eet_write_cb) if (!eet_read_cb || !eet_write_cb)
return NULL; return NULL;
@ -80,12 +80,14 @@ eet_connection_new(Eet_Read_Cb *eet_read_cb,
conn->user_data = (void *)user_data; conn->user_data = (void *)user_data;
return conn; return conn;
} } /* eet_connection_new */
EAPI int EAPI int
eet_connection_received(Eet_Connection *conn, const void *data, size_t size) eet_connection_received(Eet_Connection * conn,
const void * data,
size_t size)
{ {
if (!conn || !data || !size) if ((!conn) || (!data) || (!size))
return size; return size;
do { do {
@ -93,7 +95,7 @@ eet_connection_received(Eet_Connection *conn, const void *data, size_t size)
if (conn->size == 0) if (conn->size == 0)
{ {
const Eet_Message *msg; const Eet_Message * msg;
size_t packet_size; size_t packet_size;
if (size < sizeof (Eet_Message)) if (size < sizeof (Eet_Message))
@ -127,7 +129,7 @@ eet_connection_received(Eet_Connection *conn, const void *data, size_t size)
conn->size = packet_size; conn->size = packet_size;
if (conn->allocated < conn->size) if (conn->allocated < conn->size)
{ {
void *tmp; void * tmp;
tmp = realloc(conn->buffer, conn->size); tmp = realloc(conn->buffer, conn->size);
if (!tmp) if (!tmp)
@ -167,12 +169,14 @@ eet_connection_received(Eet_Connection *conn, const void *data, size_t size)
} while (size > 0); } while (size > 0);
return size; return size;
} } /* eet_connection_received */
static Eina_Bool static Eina_Bool
_eet_connection_raw_send(Eet_Connection *conn, void *data, int data_size) _eet_connection_raw_send(Eet_Connection * conn,
void * data,
int data_size)
{ {
Eet_Message *message; Eet_Message * message;
/* Message should never be above 64K */ /* Message should never be above 64K */
if (data_size > 64 * 1024) if (data_size > 64 * 1024)
@ -182,21 +186,21 @@ _eet_connection_raw_send(Eet_Connection *conn, void *data, int data_size)
message->magic = htonl(MAGIC_EET_DATA_PACKET); message->magic = htonl(MAGIC_EET_DATA_PACKET);
message->size = htonl(data_size); message->size = htonl(data_size);
memcpy(message + 1, data, data_size); memcpy(message + 1, data, data_size);
conn->eet_write_cb(message, conn->eet_write_cb(message,
data_size + sizeof (Eet_Message), data_size + sizeof (Eet_Message),
conn->user_data); conn->user_data);
return EINA_TRUE; return EINA_TRUE;
} } /* _eet_connection_raw_send */
EAPI Eina_Bool EAPI Eina_Bool
eet_connection_send(Eet_Connection *conn, eet_connection_send(Eet_Connection * conn,
Eet_Data_Descriptor *edd, Eet_Data_Descriptor * edd,
const void *data_in, const void * data_in,
const char *cipher_key) const char * cipher_key)
{ {
void *flat_data; void * flat_data;
int data_size; int data_size;
Eina_Bool ret = EINA_FALSE; Eina_Bool ret = EINA_FALSE;
@ -212,14 +216,14 @@ eet_connection_send(Eet_Connection *conn,
free(flat_data); free(flat_data);
return ret; return ret;
} } /* eet_connection_send */
EAPI Eina_Bool EAPI Eina_Bool
eet_connection_node_send(Eet_Connection *conn, eet_connection_node_send(Eet_Connection * conn,
Eet_Node *node, Eet_Node * node,
const char *cipher_key) const char * cipher_key)
{ {
void *data; void * data;
int data_size; int data_size;
Eina_Bool ret = EINA_FALSE; Eina_Bool ret = EINA_FALSE;
@ -232,12 +236,13 @@ eet_connection_node_send(Eet_Connection *conn,
free(data); free(data);
return ret; return ret;
} } /* eet_connection_node_send */
EAPI void * EAPI void *
eet_connection_close(Eet_Connection *conn, Eina_Bool *on_going) eet_connection_close(Eet_Connection * conn,
Eina_Bool * on_going)
{ {
void *user_data; void * user_data;
if (!conn) if (!conn)
return NULL; return NULL;
@ -251,4 +256,5 @@ eet_connection_close(Eet_Connection *conn, Eina_Bool *on_going)
free(conn); free(conn);
return user_data; return user_data;
} } /* eet_connection_close */

File diff suppressed because it is too large Load Diff

View File

@ -4,7 +4,7 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include <config.h> # include <config.h>
#endif #endif /* ifdef HAVE_CONFIG_H */
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
@ -18,7 +18,7 @@
Eet_Dictionary * Eet_Dictionary *
eet_dictionary_add(void) eet_dictionary_add(void)
{ {
Eet_Dictionary *new; Eet_Dictionary * new;
new = calloc(1, sizeof (Eet_Dictionary)); new = calloc(1, sizeof (Eet_Dictionary));
if (!new) if (!new)
@ -27,10 +27,10 @@ eet_dictionary_add(void)
memset(new->hash, -1, sizeof (int) * 256); memset(new->hash, -1, sizeof (int) * 256);
return new; return new;
} } /* eet_dictionary_add */
void void
eet_dictionary_free(Eet_Dictionary *ed) eet_dictionary_free(Eet_Dictionary * ed)
{ {
if (ed) if (ed)
{ {
@ -41,14 +41,16 @@ eet_dictionary_free(Eet_Dictionary *ed)
free(ed->all[i].str); free(ed->all[i].str);
if (ed->all) if (ed->all)
free(ed->all); free(ed->all);
free(ed); free(ed);
} }
} } /* eet_dictionary_free */
static int static int
_eet_dictionary_lookup(Eet_Dictionary *ed, const char *string, int hash) _eet_dictionary_lookup(Eet_Dictionary * ed,
const char * string,
int hash)
{ {
int prev = -1; int prev = -1;
int current; int current;
@ -73,13 +75,14 @@ _eet_dictionary_lookup(Eet_Dictionary *ed, const char *string, int hash)
return prev; return prev;
return current; return current;
} } /* _eet_dictionary_lookup */
int int
eet_dictionary_string_add(Eet_Dictionary *ed, const char *string) eet_dictionary_string_add(Eet_Dictionary * ed,
const char * string)
{ {
Eet_String *current; Eet_String * current;
char *str; char * str;
int hash; int hash;
int idx; int idx;
int len; int len;
@ -105,7 +108,7 @@ eet_dictionary_string_add(Eet_Dictionary *ed, const char *string)
if (ed->total == ed->count) if (ed->total == ed->count)
{ {
Eet_String *new; Eet_String * new;
int total; int total;
total = ed->total + 8; total = ed->total + 8;
@ -154,10 +157,11 @@ eet_dictionary_string_add(Eet_Dictionary *ed, const char *string)
} }
return ed->count++; return ed->count++;
} } /* eet_dictionary_string_add */
int int
eet_dictionary_string_get_size(const Eet_Dictionary *ed, int idx) eet_dictionary_string_get_size(const Eet_Dictionary * ed,
int idx)
{ {
if (!ed) if (!ed)
return 0; return 0;
@ -169,10 +173,11 @@ eet_dictionary_string_get_size(const Eet_Dictionary *ed, int idx)
return ed->all[idx].len; return ed->all[idx].len;
return 0; return 0;
} } /* eet_dictionary_string_get_size */
int int
eet_dictionary_string_get_hash(const Eet_Dictionary *ed, int idx) eet_dictionary_string_get_hash(const Eet_Dictionary * ed,
int idx)
{ {
if (!ed) if (!ed)
return -1; return -1;
@ -184,10 +189,11 @@ eet_dictionary_string_get_hash(const Eet_Dictionary *ed, int idx)
return ed->all[idx].hash; return ed->all[idx].hash;
return -1; return -1;
} } /* eet_dictionary_string_get_hash */
const char * const char *
eet_dictionary_string_get_char(const Eet_Dictionary *ed, int idx) eet_dictionary_string_get_char(const Eet_Dictionary * ed,
int idx)
{ {
if (!ed) if (!ed)
return NULL; return NULL;
@ -205,22 +211,22 @@ eet_dictionary_string_get_char(const Eet_Dictionary *ed, int idx)
ed->all[idx].mmap = NULL; ed->all[idx].mmap = NULL;
} }
#else #else /* ifdef _WIN32 */
if (ed->all[idx].mmap) if (ed->all[idx].mmap)
return ed->all[idx].mmap; return ed->all[idx].mmap;
#endif #endif /* ifdef _WIN32 */
return ed->all[idx].str; return ed->all[idx].str;
} }
return NULL; return NULL;
} } /* eet_dictionary_string_get_char */
static inline Eina_Bool static inline Eina_Bool
_eet_dictionary_string_get_me_cache(const char *s, _eet_dictionary_string_get_me_cache(const char * s,
int len, int len,
int *mantisse, int * mantisse,
int *exponent) int * exponent)
{ {
if ((len == 6) && (s[0] == '0') && (s[1] == 'x') && (s[3] == 'p')) if ((len == 6) && (s[0] == '0') && (s[1] == 'x') && (s[3] == 'p'))
{ {
@ -231,10 +237,12 @@ _eet_dictionary_string_get_me_cache(const char *s,
} }
return EINA_FALSE; return EINA_FALSE;
} } /* _eet_dictionary_string_get_me_cache */
static inline Eina_Bool static inline Eina_Bool
_eet_dictionary_string_get_float_cache(const char *s, int len, float *result) _eet_dictionary_string_get_float_cache(const char * s,
int len,
float * result)
{ {
int mantisse; int mantisse;
int exponent; int exponent;
@ -250,10 +258,12 @@ _eet_dictionary_string_get_float_cache(const char *s, int len, float *result)
} }
return EINA_FALSE; return EINA_FALSE;
} } /* _eet_dictionary_string_get_float_cache */
static inline Eina_Bool static inline Eina_Bool
_eet_dictionary_string_get_double_cache(const char *s, int len, double *result) _eet_dictionary_string_get_double_cache(const char * s,
int len,
double * result)
{ {
int mantisse; int mantisse;
int exponent; int exponent;
@ -269,10 +279,12 @@ _eet_dictionary_string_get_double_cache(const char *s, int len, double *result)
} }
return EINA_FALSE; return EINA_FALSE;
} } /* _eet_dictionary_string_get_double_cache */
static inline Eina_Bool static inline Eina_Bool
_eet_dictionary_test(const Eet_Dictionary *ed, int idx, void *result) _eet_dictionary_test(const Eet_Dictionary * ed,
int idx,
void * result)
{ {
if (!result) if (!result)
return EINA_FALSE; return EINA_FALSE;
@ -287,19 +299,19 @@ _eet_dictionary_test(const Eet_Dictionary *ed, int idx, void *result)
return EINA_FALSE; return EINA_FALSE;
return EINA_TRUE; return EINA_TRUE;
} } /* _eet_dictionary_test */
Eina_Bool Eina_Bool
eet_dictionary_string_get_float(const Eet_Dictionary *ed, eet_dictionary_string_get_float(const Eet_Dictionary * ed,
int idx, int idx,
float *result) float * result)
{ {
if (!_eet_dictionary_test(ed, idx, result)) if (!_eet_dictionary_test(ed, idx, result))
return EINA_FALSE; return EINA_FALSE;
if (!(ed->all[idx].type & EET_D_FLOAT)) if (!(ed->all[idx].type & EET_D_FLOAT))
{ {
const char *str; const char * str;
str = ed->all[idx].str ? ed->all[idx].str : ed->all[idx].mmap; str = ed->all[idx].str ? ed->all[idx].str : ed->all[idx].mmap;
@ -321,19 +333,19 @@ eet_dictionary_string_get_float(const Eet_Dictionary *ed,
*result = ed->all[idx].f; *result = ed->all[idx].f;
return EINA_TRUE; return EINA_TRUE;
} } /* eet_dictionary_string_get_float */
Eina_Bool Eina_Bool
eet_dictionary_string_get_double(const Eet_Dictionary *ed, eet_dictionary_string_get_double(const Eet_Dictionary * ed,
int idx, int idx,
double *result) double * result)
{ {
if (!_eet_dictionary_test(ed, idx, result)) if (!_eet_dictionary_test(ed, idx, result))
return EINA_FALSE; return EINA_FALSE;
if (!(ed->all[idx].type & EET_D_DOUBLE)) if (!(ed->all[idx].type & EET_D_DOUBLE))
{ {
const char *str; const char * str;
str = ed->all[idx].str ? ed->all[idx].str : ed->all[idx].mmap; str = ed->all[idx].str ? ed->all[idx].str : ed->all[idx].mmap;
@ -355,19 +367,19 @@ eet_dictionary_string_get_double(const Eet_Dictionary *ed,
*result = ed->all[idx].d; *result = ed->all[idx].d;
return EINA_TRUE; return EINA_TRUE;
} } /* eet_dictionary_string_get_double */
Eina_Bool Eina_Bool
eet_dictionary_string_get_fp(const Eet_Dictionary *ed, eet_dictionary_string_get_fp(const Eet_Dictionary * ed,
int idx, int idx,
Eina_F32p32 *result) Eina_F32p32 * result)
{ {
if (!_eet_dictionary_test(ed, idx, result)) if (!_eet_dictionary_test(ed, idx, result))
return EINA_FALSE; return EINA_FALSE;
if (!(ed->all[idx].type & EET_D_FIXED_POINT)) if (!(ed->all[idx].type & EET_D_FIXED_POINT))
{ {
const char *str; const char * str;
Eina_F32p32 fp; Eina_F32p32 fp;
str = ed->all[idx].str ? ed->all[idx].str : ed->all[idx].mmap; str = ed->all[idx].str ? ed->all[idx].str : ed->all[idx].mmap;
@ -381,19 +393,18 @@ eet_dictionary_string_get_fp(const Eet_Dictionary *ed,
*result = ed->all[idx].fp; *result = ed->all[idx].fp;
return EINA_TRUE; return EINA_TRUE;
} } /* eet_dictionary_string_get_fp */
EAPI int EAPI int
eet_dictionary_string_check(Eet_Dictionary *ed, const char *string) eet_dictionary_string_check(Eet_Dictionary * ed,
const char * string)
{ {
int i; int i;
if (ed == NULL if ((ed == NULL) || (string == NULL))
|| string == NULL)
return 0; return 0;
if (ed->start <= string if ((ed->start <= string) && (string < ed->end))
&& string < ed->end)
return 1; return 1;
for (i = 0; i < ed->count; ++i) for (i = 0; i < ed->count; ++i)
@ -401,4 +412,5 @@ eet_dictionary_string_check(Eet_Dictionary *ed, const char *string)
return 1; return 1;
return 0; return 0;
} } /* eet_dictionary_string_check */

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -4,26 +4,26 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include <config.h> # include <config.h>
#endif #endif /* ifdef HAVE_CONFIG_H */
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#ifdef HAVE_EVIL #ifdef HAVE_EVIL
# include <Evil.h> # include <Evil.h>
#endif #endif /* ifdef HAVE_EVIL */
#include <Eina.h> #include <Eina.h>
#include "Eet.h" #include "Eet.h"
#include "Eet_private.h" #include "Eet_private.h"
static Eina_Mempool *_eet_node_mp = NULL; static Eina_Mempool * _eet_node_mp = NULL;
Eet_Node * Eet_Node *
eet_node_new(void) eet_node_new(void)
{ {
Eet_Node *result; Eet_Node * result;
result = eina_mempool_malloc(_eet_node_mp, sizeof (Eet_Node)); result = eina_mempool_malloc(_eet_node_mp, sizeof (Eet_Node));
if (!result) if (!result)
@ -31,18 +31,19 @@ eet_node_new(void)
memset(result, 0, sizeof (Eet_Node)); memset(result, 0, sizeof (Eet_Node));
return result; return result;
} } /* eet_node_new */
void void
eet_node_free(Eet_Node *node) eet_node_free(Eet_Node * node)
{ {
eina_mempool_free(_eet_node_mp, node); eina_mempool_free(_eet_node_mp, node);
} } /* eet_node_free */
static Eet_Node * static Eet_Node *
_eet_node_new(const char *name, int type) _eet_node_new(const char * name,
int type)
{ {
Eet_Node *n; Eet_Node * n;
n = eet_node_new(); n = eet_node_new();
if (!n) if (!n)
@ -52,47 +53,47 @@ _eet_node_new(const char *name, int type)
n->name = eina_stringshare_add(name); n->name = eina_stringshare_add(name);
return n; return n;
} } /* _eet_node_new */
static void static void
_eet_node_append(Eet_Node *n, Eina_List *nodes) _eet_node_append(Eet_Node * n, Eina_List * nodes)
{ {
Eet_Node *value; Eet_Node * value;
Eina_List *l; Eina_List * l;
EINA_LIST_REVERSE_FOREACH(nodes, l, value) EINA_LIST_REVERSE_FOREACH(nodes, l, value)
{ {
value->next = n->values; value->next = n->values;
n->values = value; n->values = value;
} }
} } /* _eet_node_append */
#define EET_NODE_NEW(Eet_type, Name, Value, Type) \ #define EET_NODE_NEW(Eet_type, Name, Value, Type)\
EAPI Eet_Node * \ EAPI Eet_Node *\
eet_node_ ## Name ## _new(const char *name, Type Value) \ eet_node_ ## Name ## _new(const char * name, Type Value)\
{ \ {\
Eet_Node *n; \ Eet_Node * n;\
\ \
n = _eet_node_new(name, Eet_type); \ n = _eet_node_new(name, Eet_type);\
if (!n) { return NULL; } \ if (!n) { return NULL; }\
\ \
n->data.value.Value = Value; \ n->data.value.Value = Value;\
\ \
return n; \ return n;\
} }
#define EET_NODE_STR_NEW(Eet_type, Name, Value, Type) \ #define EET_NODE_STR_NEW(Eet_type, Name, Value, Type)\
EAPI Eet_Node * \ EAPI Eet_Node *\
eet_node_ ## Name ## _new(const char *name, Type Value) \ eet_node_ ## Name ## _new(const char * name, Type Value)\
{ \ {\
Eet_Node *n; \ Eet_Node * n;\
\ \
n = _eet_node_new(name, Eet_type); \ n = _eet_node_new(name, Eet_type);\
if (!n) { return NULL; } \ if (!n) { return NULL; }\
\ \
n->data.value.Value = eina_stringshare_add(Value); \ n->data.value.Value = eina_stringshare_add(Value);\
\ \
return n; \ return n;\
} }
EET_NODE_NEW(EET_T_CHAR, char, c, char) EET_NODE_NEW(EET_T_CHAR, char, c, char)
@ -109,9 +110,9 @@ EET_NODE_STR_NEW(EET_T_STRING, string, str, const char *)
EET_NODE_STR_NEW(EET_T_INLINED_STRING, inlined_string, str, const char *) EET_NODE_STR_NEW(EET_T_INLINED_STRING, inlined_string, str, const char *)
Eet_Node * Eet_Node *
eet_node_null_new(const char *name) eet_node_null_new(const char * name)
{ {
Eet_Node *n; Eet_Node * n;
n = _eet_node_new(name, EET_T_NULL); n = _eet_node_new(name, EET_T_NULL);
if (!n) if (!n)
@ -123,9 +124,10 @@ eet_node_null_new(const char *name)
} }
Eet_Node * Eet_Node *
eet_node_list_new(const char *name, Eina_List *nodes) eet_node_list_new(const char * name,
Eina_List * nodes)
{ {
Eet_Node *n; Eet_Node * n;
n = _eet_node_new(name, EET_G_LIST); n = _eet_node_new(name, EET_G_LIST);
if (!n) if (!n)
@ -134,12 +136,14 @@ eet_node_list_new(const char *name, Eina_List *nodes)
_eet_node_append(n, nodes); _eet_node_append(n, nodes);
return n; return n;
} } /* eet_node_list_new */
Eet_Node * Eet_Node *
eet_node_array_new(const char *name, int count, Eina_List *nodes) eet_node_array_new(const char * name,
int count,
Eina_List * nodes)
{ {
Eet_Node *n; Eet_Node * n;
n = _eet_node_new(name, EET_G_ARRAY); n = _eet_node_new(name, EET_G_ARRAY);
if (!n) if (!n)
@ -150,12 +154,13 @@ eet_node_array_new(const char *name, int count, Eina_List *nodes)
_eet_node_append(n, nodes); _eet_node_append(n, nodes);
return n; return n;
} } /* eet_node_array_new */
Eet_Node * Eet_Node *
eet_node_var_array_new(const char *name, Eina_List *nodes) eet_node_var_array_new(const char * name,
Eina_List * nodes)
{ {
Eet_Node *n; Eet_Node * n;
n = _eet_node_new(name, EET_G_VAR_ARRAY); n = _eet_node_new(name, EET_G_VAR_ARRAY);
if (!n) if (!n)
@ -166,13 +171,15 @@ eet_node_var_array_new(const char *name, Eina_List *nodes)
_eet_node_append(n, nodes); _eet_node_append(n, nodes);
return n; return n;
} } /* eet_node_var_array_new */
Eet_Node * Eet_Node *
eet_node_hash_new(const char *name, const char *key, Eet_Node *node) eet_node_hash_new(const char * name,
const char * key,
Eet_Node * node)
{ {
Eina_List *nodes; Eina_List * nodes;
Eet_Node *n; Eet_Node * n;
if (!node) if (!node)
return NULL; return NULL;
@ -187,12 +194,13 @@ eet_node_hash_new(const char *name, const char *key, Eet_Node *node)
_eet_node_append(n, nodes); _eet_node_append(n, nodes);
return n; return n;
} } /* eet_node_hash_new */
Eet_Node * Eet_Node *
eet_node_struct_new(const char *name, Eina_List *nodes) eet_node_struct_new(const char * name,
Eina_List * nodes)
{ {
Eet_Node *n; Eet_Node * n;
n = _eet_node_new(name, EET_G_UNKNOWN); n = _eet_node_new(name, EET_G_UNKNOWN);
if (!n) if (!n)
@ -201,12 +209,13 @@ eet_node_struct_new(const char *name, Eina_List *nodes)
_eet_node_append(n, nodes); _eet_node_append(n, nodes);
return n; return n;
} } /* eet_node_struct_new */
Eet_Node * Eet_Node *
eet_node_struct_child_new(const char *parent, Eet_Node *child) eet_node_struct_child_new(const char * parent,
Eet_Node * child)
{ {
Eet_Node *n; Eet_Node * n;
if (child->type != EET_G_UNKNOWN) if (child->type != EET_G_UNKNOWN)
return child; return child;
@ -218,20 +227,22 @@ eet_node_struct_child_new(const char *parent, Eet_Node *child)
_eet_node_append(n, eina_list_prepend(NULL, child)); _eet_node_append(n, eina_list_prepend(NULL, child));
return n; return n;
} } /* eet_node_struct_child_new */
void void
eet_node_list_append(Eet_Node *parent, const char *name, Eet_Node *child) eet_node_list_append(Eet_Node * parent,
const char * name,
Eet_Node * child)
{ {
const char *tmp; const char * tmp;
Eet_Node *nn; Eet_Node * nn;
tmp = eina_stringshare_add(name); tmp = eina_stringshare_add(name);
for (nn = parent->values; nn; nn = nn->next) for (nn = parent->values; nn; nn = nn->next)
if (nn->name == tmp && nn->type == EET_G_LIST) if (nn->name == tmp && nn->type == EET_G_LIST)
{ {
Eet_Node *n; Eet_Node * n;
if (!nn->values) if (!nn->values)
nn->values = child; nn->values = child;
@ -256,22 +267,24 @@ eet_node_list_append(Eet_Node *parent, const char *name, Eet_Node *child)
nn->next = parent->values; nn->next = parent->values;
parent->values = nn; parent->values = nn;
eina_stringshare_del(tmp); eina_stringshare_del(tmp);
} } /* eet_node_list_append */
void void
eet_node_struct_append(Eet_Node *parent, const char *name, Eet_Node *child) eet_node_struct_append(Eet_Node * parent,
const char * name,
Eet_Node * child)
{ {
const char *tmp; const char * tmp;
Eet_Node *prev; Eet_Node * prev;
Eet_Node *nn; Eet_Node * nn;
if (parent->type != EET_G_UNKNOWN) if (parent->type != EET_G_UNKNOWN)
{ {
ERR("[%s] is not a structure. Will not insert [%s] in it", ERR("[%s] is not a structure. Will not insert [%s] in it",
parent->name, parent->name,
name); name);
eet_node_del(child); eet_node_del(child);
return; return;
} }
@ -302,16 +315,16 @@ eet_node_struct_append(Eet_Node *parent, const char *name, Eet_Node *child)
parent->values = child; parent->values = child;
} }
eina_stringshare_del(tmp); eina_stringshare_del(tmp);
} } /* eet_node_struct_append */
void void
eet_node_hash_add(Eet_Node *parent, eet_node_hash_add(Eet_Node * parent,
const char *name, const char * name,
const char *key, const char * key,
Eet_Node *child) Eet_Node * child)
{ {
Eet_Node *nn; Eet_Node * nn;
/* No list found, so create it. */ /* No list found, so create it. */
nn = eet_node_hash_new(name, key, child); nn = eet_node_hash_new(name, key, child);
@ -319,13 +332,13 @@ eet_node_hash_add(Eet_Node *parent,
/* And add it to the parent. */ /* And add it to the parent. */
nn->next = parent->values; nn->next = parent->values;
parent->values = nn; parent->values = nn;
} } /* eet_node_hash_add */
void void
eet_node_del(Eet_Node *n) eet_node_del(Eet_Node * n)
{ {
Eet_Node *nn; Eet_Node * nn;
Eet_Node *tmp; Eet_Node * tmp;
if (!n) if (!n)
return; return;
@ -362,13 +375,13 @@ eet_node_del(Eet_Node *n)
case EET_T_USHORT: case EET_T_USHORT:
case EET_T_UINT: case EET_T_UINT:
break; break;
} } /* switch */
eina_stringshare_del(n->name); eina_stringshare_del(n->name);
eet_node_free(n); eet_node_free(n);
} } /* eet_node_del */
static const char *eet_node_dump_g_name[6] = { static const char * eet_node_dump_g_name[6] = {
"struct", "struct",
"array", "array",
"var_array", "var_array",
@ -377,7 +390,7 @@ static const char *eet_node_dump_g_name[6] = {
"???" "???"
}; };
static const char *eet_node_dump_t_name[14][2] = { static const char * eet_node_dump_t_name[14][2] = {
{ "???: ", "???" }, { "???: ", "???" },
{ "char: ", "%hhi" }, { "char: ", "%hhi" },
{ "short: ", "%hi" }, { "short: ", "%hi" },
@ -393,20 +406,20 @@ static const char *eet_node_dump_t_name[14][2] = {
}; };
static void static void
eet_node_dump_level(int level, void (*dumpfunc)(void *data, eet_node_dump_level(int level,
const char *str), void (* dumpfunc)(void * data, const char * str),
void *dumpdata) void * dumpdata)
{ {
int i; int i;
for (i = 0; i < level; i++) dumpfunc(dumpdata, " "); for (i = 0; i < level; i++) dumpfunc(dumpdata, " ");
} } /* eet_node_dump_level */
static char * static char *
eet_node_string_escape(const char *str) eet_node_string_escape(const char * str)
{ {
char *s, *sp; char * s, * sp;
const char *strp; const char * strp;
int sz = 0; int sz = 0;
for (strp = str; *strp; strp++) for (strp = str; *strp; strp++)
@ -441,14 +454,14 @@ eet_node_string_escape(const char *str)
} }
*sp = 0; *sp = 0;
return s; return s;
} } /* eet_node_string_escape */
static void static void
eet_node_dump_string_escape(void *dumpdata, void dumpfunc(void *data, eet_node_dump_string_escape(void * dumpdata,
const char *str), void dumpfunc(void * data, const char * str),
const char *str) const char * str)
{ {
char *s; char * s;
s = eet_node_string_escape(str); s = eet_node_string_escape(str);
if (!s) if (!s)
@ -456,35 +469,35 @@ eet_node_dump_string_escape(void *dumpdata, void dumpfunc(void *data,
dumpfunc(dumpdata, s); dumpfunc(dumpdata, s);
free(s); free(s);
} } /* eet_node_dump_string_escape */
static void static void
eet_node_dump_simple_type(Eet_Node *n, int level, eet_node_dump_simple_type(Eet_Node * n, int level,
void (*dumpfunc)(void *data, void (* dumpfunc)(void * data, const char * str),
const char *str), void *dumpdata) void * dumpdata)
{ {
const char *type_name = NULL; const char * type_name = NULL;
char tbuf[256]; char tbuf[256];
eet_node_dump_level(level, dumpfunc, dumpdata); eet_node_dump_level(level, dumpfunc, dumpdata);
dumpfunc(dumpdata, "value \""); dumpfunc(dumpdata, "value \"");
eet_node_dump_string_escape(dumpdata, dumpfunc, n->name); eet_node_dump_string_escape(dumpdata, dumpfunc, n->name);
dumpfunc(dumpdata, "\" "); dumpfunc(dumpdata, "\" ");
#ifdef EET_T_TYPE #ifdef EET_T_TYPE
# undef EET_T_TYPE # undef EET_T_TYPE
#endif #endif /* ifdef EET_T_TYPE */
#define EET_T_TYPE(Eet_Type, Type) \ #define EET_T_TYPE(Eet_Type, Type)\
case Eet_Type: \ case Eet_Type:\
{ \ {\
dumpfunc(dumpdata, eet_node_dump_t_name[Eet_Type][0]); \ dumpfunc(dumpdata, eet_node_dump_t_name[Eet_Type][0]);\
snprintf(tbuf, \ snprintf(tbuf,\
sizeof (tbuf), \ sizeof (tbuf),\
eet_node_dump_t_name[Eet_Type][1], \ eet_node_dump_t_name[Eet_Type][1],\
n->data.value.Type); \ n->data.value.Type);\
dumpfunc(dumpdata, tbuf); \ dumpfunc(dumpdata, tbuf);\
break; \ break;\
} }
switch (n->type) switch (n->type)
@ -519,16 +532,17 @@ eet_node_dump_simple_type(Eet_Node *n, int level,
default: default:
dumpfunc(dumpdata, "???: ???"); dumpfunc(dumpdata, "???: ???");
break; break;
} } /* switch */
dumpfunc(dumpdata, ";\n"); dumpfunc(dumpdata, ";\n");
} } /* eet_node_dump_simple_type */
static void static void
eet_node_dump_group_start(int level, void (*dumpfunc)(void *data, eet_node_dump_group_start(int level,
const char *str), void (* dumpfunc)(void * data, const char * str),
void *dumpdata, void * dumpdata,
int group_type, const char *name) int group_type,
const char * name)
{ {
int chnk_type; int chnk_type;
@ -542,23 +556,24 @@ eet_node_dump_group_start(int level, void (*dumpfunc)(void *data,
dumpfunc(dumpdata, eet_node_dump_g_name[chnk_type - EET_G_UNKNOWN]); dumpfunc(dumpdata, eet_node_dump_g_name[chnk_type - EET_G_UNKNOWN]);
dumpfunc(dumpdata, " {\n"); dumpfunc(dumpdata, " {\n");
} } /* eet_node_dump_group_start */
static void static void
eet_node_dump_group_end(int level, void (*dumpfunc)(void *data, eet_node_dump_group_end(int level,
const char *str), void (* dumpfunc)(void * data, const char * str),
void *dumpdata) void * dumpdata)
{ {
eet_node_dump_level(level, dumpfunc, dumpdata); eet_node_dump_level(level, dumpfunc, dumpdata);
dumpfunc(dumpdata, "}\n"); dumpfunc(dumpdata, "}\n");
} } /* eet_node_dump_group_end */
void void
eet_node_dump(Eet_Node *n, int dumplevel, void (*dumpfunc)(void *data, eet_node_dump(Eet_Node * n,
const char *str), int dumplevel,
void *dumpdata) void (* dumpfunc)(void * data, const char * str),
void * dumpdata)
{ {
Eet_Node *it; Eet_Node * it;
if (!n) if (!n)
return; return;
@ -615,18 +630,18 @@ eet_node_dump(Eet_Node *n, int dumplevel, void (*dumpfunc)(void *data,
case EET_T_ULONG_LONG: case EET_T_ULONG_LONG:
eet_node_dump_simple_type(n, dumplevel, dumpfunc, dumpdata); eet_node_dump_simple_type(n, dumplevel, dumpfunc, dumpdata);
break; break;
} } /* switch */
} } /* eet_node_dump */
void * void *
eet_node_walk(void *parent, eet_node_walk(void * parent,
const char *name, const char * name,
Eet_Node *root, Eet_Node * root,
Eet_Node_Walk *cb, Eet_Node_Walk * cb,
void *user_data) void * user_data)
{ {
Eet_Node *it; Eet_Node * it;
void *me = NULL; void * me = NULL;
int i; int i;
if (!root) if (!root)
@ -643,7 +658,7 @@ eet_node_walk(void *parent,
me = cb->struct_alloc(root->name, user_data); me = cb->struct_alloc(root->name, user_data);
for (it = root->values; it != NULL; it = it->next) for (it = root->values; it != NULL; it = it->next)
eet_node_walk(me, it->name, it, cb, user_data); eet_node_walk(me, it->name, it, cb, user_data);
break; break;
@ -698,19 +713,19 @@ eet_node_walk(void *parent,
case EET_T_ULONG_LONG: case EET_T_ULONG_LONG:
me = cb->simple(root->type, &root->data, user_data); me = cb->simple(root->type, &root->data, user_data);
break; break;
} } /* switch */
if (parent) if (parent)
cb->struct_add(parent, name, me, user_data); cb->struct_add(parent, name, me, user_data);
return me; return me;
} } /* eet_node_walk */
int int
eet_node_init(void) eet_node_init(void)
{ {
const char *choice; const char * choice;
const char *tmp; const char * tmp;
choice = "chained_mempool"; choice = "chained_mempool";
tmp = getenv("EET_MEMPOOL"); tmp = getenv("EET_MEMPOOL");
@ -721,11 +736,12 @@ eet_node_init(void)
eina_mempool_add(choice, "eet-node-alloc", NULL, sizeof(Eet_Node), 1024); eina_mempool_add(choice, "eet-node-alloc", NULL, sizeof(Eet_Node), 1024);
return _eet_node_mp ? 1 : 0; return _eet_node_mp ? 1 : 0;
} } /* eet_node_init */
void void
eet_node_shutdown(void) eet_node_shutdown(void)
{ {
eina_mempool_del(_eet_node_mp); eina_mempool_del(_eet_node_mp);
_eet_node_mp = NULL; _eet_node_mp = NULL;
} } /* eet_node_shutdown */

View File

@ -4,7 +4,7 @@
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include <config.h> # include <config.h>
#endif #endif /* ifdef HAVE_CONFIG_H */
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
@ -13,12 +13,13 @@
#include "Eet_private.h" #include "Eet_private.h"
int int
_eet_hash_gen(const char *key, int hash_size) _eet_hash_gen(const char * key,
int hash_size)
{ {
int hash_num = 0; int hash_num = 0;
int value, i; int value, i;
int mask; int mask;
unsigned char *ptr; unsigned char * ptr;
/* no string - index 0 */ /* no string - index 0 */
if (!key) if (!key)
@ -35,5 +36,5 @@ _eet_hash_gen(const char *key, int hash_size)
hash_num &= mask; hash_num &= mask;
/* return it */ /* return it */
return hash_num; return hash_num;
} } /* _eet_hash_gen */

View File

@ -6,28 +6,28 @@
#include "eet_suite.h" #include "eet_suite.h"
static char * static char *
_eet_str_direct_alloc(const char *str) _eet_str_direct_alloc(const char * str)
{ {
return (char *)str; return (char *)str;
} } /* _eet_str_direct_alloc */
static void static void
_eet_str_direct_free(const char *str) _eet_str_direct_free(const char * str)
{ {
/* FIXME: Use attribute unused */ /* FIXME: Use attribute unused */
(void)str; (void)str;
} } /* _eet_str_direct_free */
static void static void
_eet_eina_hash_foreach(void *hash, Eina_Hash_Foreach cb, void *fdata) _eet_eina_hash_foreach(void * hash, Eina_Hash_Foreach cb, void * fdata)
{ {
if (hash) if (hash)
eina_hash_foreach(hash, cb, fdata); eina_hash_foreach(hash, cb, fdata);
} } /* _eet_eina_hash_foreach */
/* Internal wrapper for eina_hash */ /* Internal wrapper for eina_hash */
static Eina_Hash * static Eina_Hash *
_eet_eina_hash_add(Eina_Hash *hash, const char *key, const void *data) _eet_eina_hash_add(Eina_Hash * hash, const char * key, const void * data)
{ {
if (!hash) if (!hash)
hash = eina_hash_string_superfast_new(NULL); hash = eina_hash_string_superfast_new(NULL);
@ -37,17 +37,17 @@ _eet_eina_hash_add(Eina_Hash *hash, const char *key, const void *data)
eina_hash_add(hash, key, data); eina_hash_add(hash, key, data);
return hash; return hash;
} } /* _eet_eina_hash_add */
static void static void
_eet_eina_hash_free(Eina_Hash *hash) _eet_eina_hash_free(Eina_Hash * hash)
{ {
if (hash) if (hash)
eina_hash_free(hash); eina_hash_free(hash);
} } /* _eet_eina_hash_free */
void void
eet_test_setup_eddc(Eet_Data_Descriptor_Class *eddc) eet_test_setup_eddc(Eet_Data_Descriptor_Class * eddc)
{ {
eddc->version = EET_DATA_DESCRIPTOR_CLASS_VERSION; eddc->version = EET_DATA_DESCRIPTOR_CLASS_VERSION;
eddc->func.mem_alloc = NULL; eddc->func.mem_alloc = NULL;
@ -63,5 +63,5 @@ eet_test_setup_eddc(Eet_Data_Descriptor_Class *eddc)
eddc->func.hash_free = (void *)_eet_eina_hash_free; eddc->func.hash_free = (void *)_eet_eina_hash_free;
eddc->func.str_direct_alloc = (void *)_eet_str_direct_alloc; eddc->func.str_direct_alloc = (void *)_eet_str_direct_alloc;
eddc->func.str_direct_free = (void *)_eet_str_direct_free; eddc->func.str_direct_free = (void *)_eet_str_direct_free;
} } /* eet_test_setup_eddc */

File diff suppressed because it is too large Load Diff

View File

@ -3,7 +3,6 @@
#include "Eet.h" #include "Eet.h"
void eet_test_setup_eddc(Eet_Data_Descriptor_Class *eddc); void eet_test_setup_eddc(Eet_Data_Descriptor_Class * eddc);
#endif /* _EET_SUITE_H */ #endif /* _EET_SUITE_H */