From ae097da0d246debe7a6ff7ed1d9d3cd77c9e8b8b Mon Sep 17 00:00:00 2001 From: caro Date: Fri, 2 Oct 2009 03:59:17 +0000 Subject: [PATCH] remove useless Eina_Log macros. Patch by Mathieu Taillefumier. git-svn-id: http://svn.enlightenment.org/svn/e/trunk/eet@42850 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- ChangeLog | 4 +++ src/bin/eet_main.c | 84 ++++++++++++++++++++++++++++++++++++--------------- src/lib/Eet_private.h | 55 +++++---------------------------- src/lib/eet_cipher.c | 6 ++-- src/lib/eet_lib.c | 17 ++++++----- 5 files changed, 84 insertions(+), 82 deletions(-) diff --git a/ChangeLog b/ChangeLog index 98c199e..4ca946f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -238,3 +238,7 @@ Note: File saved with fixed point could be read by older version of eet library with EET_T_DOUBLE type. + +2009-10-01 Mathieu Taillefumier + + * remove useless Eina_Log macros. diff --git a/src/bin/eet_main.c b/src/bin/eet_main.c index 1ae39fe..43fac6f 100644 --- a/src/bin/eet_main.c +++ b/src/bin/eet_main.c @@ -19,6 +19,34 @@ #include + +static int _eet_main_log_dom = -1; + +#ifdef EET_DEFAULT_LOG_COLOR +#undef EET_DEFAULT_LOG_COLOR +#endif +#define EET_DEFAULT_LOG_COLOR EINA_COLOR_CYAN +#ifdef ERR +#undef ERR +#endif +#define ERR(...) EINA_LOG_DOM_ERR(_eet_main_log_dom, __VA_ARGS__) +#ifdef DBG +#undef DBG +#endif +#define DBG(...) EINA_LOG_DOM_DBG(_eet_main_log_dom, __VA_ARGS__) +#ifdef INF +#undef INF +#endif +#define INF(...) EINA_LOG_DOM_INFO(_eet_main_log_dom, __VA_ARGS__) +#ifdef WRN +#undef WRN +#endif +#define WRN(...) EINA_LOG_DOM_WARN(_eet_main_log_dom, __VA_ARGS__) +#ifdef CRIT +#undef CRIT +#endif +#define CRIT(...) EINA_LOG_DOM_CRIT(_eet_main_log_dom, __VA_ARGS__) + static void do_eet_list(const char *file) { @@ -29,7 +57,7 @@ do_eet_list(const char *file) ef = eet_open(file, EET_FILE_MODE_READ); if (!ef) { - printf("cannot open for reading: %s\n", file); + ERR("cannot open for reading: %s\n", file); exit(-1); } list = eet_list(ef, "*", &num); @@ -53,24 +81,24 @@ do_eet_extract(const char *file, const char *key, const char *out, const char *c ef = eet_open(file, EET_FILE_MODE_READ); if (!ef) { - printf("cannot open for reading: %s\n", file); + ERR("cannot open for reading: %s\n", file); exit(-1); } data = eet_read_cipher(ef, key, &size, crypto_key); if (!data) { - printf("cannot read key %s\n", key); + ERR("cannot read key %s\n", key); exit(-1); } f = fopen(out, "w"); if (!f) { - printf("cannot open %s\n", out); + ERR("cannot open %s\n", out); exit(-1); } if (fwrite(data, size, 1, f) != 1) { - printf("cannot write to %s\n", out); + ERR("cannot write to %s\n", out); exit(-1); } fclose(f); @@ -93,18 +121,18 @@ do_eet_decode(const char *file, const char *key, const char *out, const char *cr ef = eet_open(file, EET_FILE_MODE_READ); if (!ef) { - printf("cannot open for reading: %s\n", file); + ERR("cannot open for reading: %s\n", file); exit(-1); } f = fopen(out, "w"); if (!f) { - printf("cannot open %s\n", out); + ERR("cannot open %s\n", out); exit(-1); } if (!eet_data_dump_cipher(ef, key, crypto_key, do_eet_decode_dump, f)) { - printf("cannot write to %s\n", out); + ERR("cannot write to %s\n", out); exit(-1); } fclose(f); @@ -124,13 +152,13 @@ do_eet_insert(const char *file, const char *key, const char *out, int compress, ef = eet_open(file, EET_FILE_MODE_WRITE); if (!ef) { - printf("cannot open for read+write: %s\n", file); + ERR("cannot open for read+write: %s\n", file); exit(-1); } f = fopen(out, "r"); if (!f) { - printf("cannot open %s\n", out); + ERR("cannot open %s\n", out); exit(-1); } fseek(f, 0, SEEK_END); @@ -139,12 +167,12 @@ do_eet_insert(const char *file, const char *key, const char *out, int compress, data = malloc(size); if (!data) { - printf("cannot allocate %i bytes\n", size); + ERR("cannot allocate %i bytes\n", size); exit(-1); } if (fread(data, size, 1, f) != 1) { - printf("cannot read file %s\n", out); + ERR("cannot read file %s\n", out); exit(-1); } fclose(f); @@ -167,13 +195,13 @@ do_eet_encode(const char *file, const char *key, const char *out, int compress, ef = eet_open(file, EET_FILE_MODE_WRITE); if (!ef) { - printf("cannot open for read+write: %s\n", file); + ERR("cannot open for read+write: %s\n", file); exit(-1); } f = fopen(out, "r"); if (!f) { - printf("cannot open %s\n", out); + ERR("cannot open %s\n", out); exit(-1); } fseek(f, 0, SEEK_END); @@ -182,18 +210,18 @@ do_eet_encode(const char *file, const char *key, const char *out, int compress, text = malloc(textlen); if (!text) { - printf("cannot allocate %i bytes\n", size); + ERR("cannot allocate %i bytes\n", size); exit(-1); } if (fread(text, textlen, 1, f) != 1) { - printf("cannot read file %s\n", out); + ERR("cannot read file %s\n", out); exit(-1); } fclose(f); if (!eet_data_undump_cipher(ef, key, crypto_key, text, textlen, compress)) { - printf("cannot parse %s\n", out); + ERR("cannot parse %s\n", out); exit(-1); } free(text); @@ -208,7 +236,7 @@ do_eet_remove(const char *file, const char *key) ef = eet_open(file, EET_FILE_MODE_READ_WRITE); if (!ef) { - printf("cannot open for read+write: %s\n", file); + ERR("cannot open for read+write: %s\n", file); exit(-1); } eet_delete(ef, key); @@ -226,17 +254,17 @@ do_eet_check(const char *file) ef = eet_open(file, EET_FILE_MODE_READ); if (!ef) { - fprintf(stdout, "checking signature of `%s` failed\n", file); + ERR("checking signature of `%s` failed\n", file); exit(-1); } der = eet_identity_x509(ef, &der_length); - fprintf(stderr, "Certificate length %i.\n", der_length); + ERR("Certificate length %i.\n", der_length); eet_identity_certificate_print(der, der_length, stdout); eet_identity_signature(ef, &sign_length); - fprintf(stderr, "Signature length %i.\n", sign_length); + ERR("Signature length %i.\n", sign_length); eet_close(ef); } @@ -250,18 +278,18 @@ do_eet_sign(const char *file, const char *private_key, const char *public_key) ef = eet_open(file, EET_FILE_MODE_READ_WRITE); if (!ef) { - fprintf(stdout, "cannot open for read+write: %s.\n", file); + ERR("cannot open for read+write: %s.\n", file); exit(-1); } key = eet_identity_open(public_key, private_key, NULL); if (!key) { - fprintf(stdout, "cannot open key '%s:%s'.\n", public_key, private_key); + ERR("cannot open key '%s:%s'.\n", public_key, private_key); exit(-1); } - fprintf(stdout, "Using the following key to sign `%s`.\n", file); + ERR("Using the following key to sign `%s`.\n", file); eet_identity_print(key, stdout); eet_identity_set(ef, key); @@ -273,6 +301,13 @@ int main(int argc, char **argv) { eet_init(); + _eet_main_log_dom = eina_log_domain_register("Eet_Main",EINA_COLOR_CYAN); + if(_eet_main_log_dom < -1) + { + EINA_LOG_ERR("Impossible to create a log domain for eet_main.\n"); + eet_shutdown(); + return(-1); + } if (argc < 2) { help: @@ -341,6 +376,7 @@ main(int argc, char **argv) { goto help; } + eina_log_domain_unregister(_eet_main_log_dom); eet_shutdown(); return 0; } diff --git a/src/lib/Eet_private.h b/src/lib/Eet_private.h index 4c36980..0d6ed75 100644 --- a/src/lib/Eet_private.h +++ b/src/lib/Eet_private.h @@ -79,22 +79,13 @@ struct _Eet_Node } data; }; -/** +/* * variable and macros used for the eina_log module */ extern int _eet_log_dom_global; -#ifdef EET_DEFAULT_MODULE_LOG_DOMAIN -#undef EET_DEFAULT_MODULE_LOG_DOMAIN _eet_log_dom_global -#endif - -/** - * the default module log domain is the eet log domain - */ - -#define EET_DEFAULT_MODULE_LOG_DOMAIN _eet_log_dom_global - -/* Macros that are used everywhere +/* + * Macros that are used everywhere * * the first four macros are the general macros for the lib */ @@ -102,56 +93,26 @@ extern int _eet_log_dom_global; #undef EET_DEFAULT_LOG_COLOR #endif #define EET_DEFAULT_LOG_COLOR EINA_COLOR_CYAN -#ifdef ERROR -#undef ERROR -#endif -#define ERROR(...) EINA_LOG_DOM_ERR(_eet_log_dom_global, __VA_ARGS__) -#ifdef DEBUG -#undef DEBUG -#endif -#define DEBUG(...) EINA_LOG_DOM_DBG(_eet_log_dom_global, __VA_ARGS__) -#ifdef INFO -#undef INFO -#endif -#define INFO(...) EINA_LOG_DOM_INFO(_eet_log_dom_global, __VA_ARGS__) -#ifdef WARN -#undef WARN -#endif -#define WARN(...) EINA_LOG_DOM_WARN(_eet_log_dom_global, __VA_ARGS__) -#ifdef CRITICAL -#undef CRITICAL -#endif -#define CRITICAL(...) EINA_LOG_DOM_CRIT(_eet_log_dom_global, __VA_ARGS__) -/** - * macros that are used all around the code for message processing - * four macros are defined ERR, WRN, DGB, INF. - * EFREET_MODULE_LOG_DOM should be defined individually for each module - */ - -#ifdef _EET_MODULE_LOG_DOM -#undef _EET_MODULE_LOG_DOM -#endif -#define _EET_MODULE_LOG_DOM _eet_log_dom_global /*default log domain for each module. It can redefined inside each module */ #ifdef ERR #undef ERR #endif -#define ERR(...) EINA_LOG_DOM_ERR(_EET_MODULE_LOG_DOM, __VA_ARGS__) +#define ERR(...) EINA_LOG_DOM_ERR(_eet_log_dom_global, __VA_ARGS__) #ifdef DBG #undef DBG #endif -#define DBG(...) EINA_LOG_DOM_DBG(_EET_MODULE_LOG_DOM, __VA_ARGS__) +#define DBG(...) EINA_LOG_DOM_DBG(_eet_log_dom_global, __VA_ARGS__) #ifdef INF #undef INF #endif -#define INF(...) EINA_LOG_DOM_INFO(_EET_MODULE_LOG_DOM, __VA_ARGS__) +#define INF(...) EINA_LOG_DOM_INFO(_eet_log_dom_global, __VA_ARGS__) #ifdef WRN #undef WRN #endif -#define WRN(...) EINA_LOG_DOM_WARN(_EET_MODULE_LOG_DOM, __VA_ARGS__) +#define WRN(...) EINA_LOG_DOM_WARN(_eet_log_dom_global, __VA_ARGS__) #ifdef CRIT #undef CRIT #endif -#define CRIT(...) EINA_LOG_DOM_CRIT(_EET_MODULE_LOG_DOM, __VA_ARGS__) +#define CRIT(...) EINA_LOG_DOM_CRIT(_eet_log_dom_global, __VA_ARGS__) Eet_Dictionary *eet_dictionary_add(void); void eet_dictionary_free(Eet_Dictionary *ed); diff --git a/src/lib/eet_cipher.c b/src/lib/eet_cipher.c index f6ccb18..51b524e 100644 --- a/src/lib/eet_cipher.c +++ b/src/lib/eet_cipher.c @@ -340,7 +340,7 @@ eet_identity_print(Eet_Key *key, FILE *out) X509_print_fp(out, key->certificate); # endif #else - ERROR("You need to compile signature support in EET."); + ERR("You need to compile signature support in EET."); #endif } @@ -682,7 +682,7 @@ eet_identity_certificate_print(const unsigned char *certificate, int der_length, #ifdef HAVE_SIGNATURE if (!certificate || !out || der_length <= 0) { - ERROR("No certificate provided."); + ERR("No certificate provided."); return ; } # ifdef HAVE_GNUTLS @@ -725,7 +725,7 @@ eet_identity_certificate_print(const unsigned char *certificate, int der_length, X509_free(x509); # endif #else - ERROR("You need to compile signature support in EET."); + ERR("You need to compile signature support in EET."); #endif } diff --git a/src/lib/eet_lib.c b/src/lib/eet_lib.c index e8848fe..29038b8 100644 --- a/src/lib/eet_lib.c +++ b/src/lib/eet_lib.c @@ -224,7 +224,7 @@ static Eet_File **eet_readers = NULL; static int eet_initcount = 0; /* log domain variable */ -int _eet_log_dom_global=-1; +int _eet_log_dom_global = -1; /* Check to see its' an eet file pointer */ static inline int @@ -318,7 +318,7 @@ eet_cache_add(Eet_File *ef, Eet_File ***cache, int *cache_num, int *cache_alloc) new_cache = realloc(new_cache, new_cache_alloc * sizeof(Eet_File *)); if (!new_cache) { - CRITICAL("BAD ERROR! Eet realloc of cache list failed. Abort"); + CRIT("BAD ERROR! Eet realloc of cache list failed. Abort"); abort(); } } @@ -363,7 +363,7 @@ eet_cache_del(Eet_File *ef, Eet_File ***cache, int *cache_num, int *cache_alloc) new_cache = realloc(new_cache, new_cache_alloc * sizeof(Eet_File *)); if (!new_cache) { - CRITICAL("BAD ERROR! Eet realloc of cache list failed. Abort"); + CRIT("BAD ERROR! Eet realloc of cache list failed. Abort"); abort(); } } @@ -749,7 +749,7 @@ eet_init(void) allocated is currently 16384 bytes; you may thus use a value of 1 to request that default size. */ if (gcry_control(GCRYCTL_INIT_SECMEM, 16384, 0)) - fprintf(stderr, "BIG FAT WARNING: I AM UNABLE TO REQUEST SECMEM, Cryptographic operation are at risk !"); + WRN("BIG FAT WARNING: I AM UNABLE TO REQUEST SECMEM, Cryptographic operation are at risk !"); } if (gnutls_global_init()) return --eet_initcount; @@ -764,13 +764,14 @@ eet_init(void) fprintf(stderr,"Eet: Eina init failed"); goto erro_eet_eina_init; } - _eet_log_dom_global = eina_log_domain_register("Eet",EET_DEFAULT_LOG_COLOR); + _eet_log_dom_global = eina_log_domain_register("Eet", EET_DEFAULT_LOG_COLOR); if(_eet_log_dom_global < 0) { EINA_LOG_ERR("Eet Can not create a general log domain."); goto error_eet_eina_log; } return eet_initcount; + error_eet_eina_log: eina_shutdown(); erro_eet_eina_init: @@ -1074,7 +1075,7 @@ eet_internal_read2(Eet_File *ef) if (eet_test_close(ef->x509_der == NULL, ef)) return NULL; #else - ERROR("This file could be signed but you didn't compile the necessary code to check the signature."); + ERR("This file could be signed but you didn't compile the necessary code to check the signature."); #endif } @@ -1092,7 +1093,7 @@ eet_internal_read1(Eet_File *ef) int byte_entries; int i; - WARN("EET file format of '%s' is deprecated. You should just open it one time with mode == EET_FILE_MODE_READ_WRITE to solve this issue.", ef->path); + WRN("EET file format of '%s' is deprecated. You should just open it one time with mode == EET_FILE_MODE_READ_WRITE to solve this issue.", ef->path); /* build header table if read mode */ /* geat header */ @@ -1219,7 +1220,7 @@ eet_internal_read1(Eet_File *ef) strncpy(efn->name, (char *)p + HEADER_SIZE, name_size); efn->name[name_size] = 0; - WARN("File: %s is not up to date for key \"%s\" - needs rebuilding sometime", ef->path, efn->name); + WRN("File: %s is not up to date for key \"%s\" - needs rebuilding sometime", ef->path, efn->name); } else /* The only really usefull peace of code for efn->name (no backward compatibility) */ -- 2.7.4