diff --git a/legacy/eet/src/lib/Eet_private.h b/legacy/eet/src/lib/Eet_private.h index 1052889679..9e8c09e5f2 100644 --- a/legacy/eet/src/lib/Eet_private.h +++ b/legacy/eet/src/lib/Eet_private.h @@ -70,6 +70,80 @@ 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 + * + * the first four macros are the general macros for the lib + */ +#ifdef EET_DEFAULT_LOG_COLOR +#undef EET_DEFAULT_LOG_COLOR +#endif +#define EET_DEFAULT_LOG_COLOR "\033[36m" +#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__) +#ifdef DBG +#undef DBG +#endif +#define DBG(...) EINA_LOG_DOM_DBG(_EET_MODULE_LOG_DOM, __VA_ARGS__) +#ifdef INF +#undef INF +#endif +#define INF(...) EINA_LOG_DOM_INFO(_EET_MODULE_LOG_DOM, __VA_ARGS__) +#ifdef WRN +#undef WRN +#endif +#define WRN(...) EINA_LOG_DOM_WARN(_EET_MODULE_LOG_DOM, __VA_ARGS__) +#ifdef CRIT +#undef CRIT +#endif +#define CRIT(...) EINA_LOG_DOM_CRIT(_EET_MODULE_LOG_DOM, __VA_ARGS__) + Eet_Dictionary *eet_dictionary_add(void); void eet_dictionary_free(Eet_Dictionary *ed); int eet_dictionary_string_add(Eet_Dictionary *ed, const char *string); diff --git a/legacy/eet/src/lib/eet_cipher.c b/legacy/eet/src/lib/eet_cipher.c index 3bc0b5ad2b..eae971a18d 100644 --- a/legacy/eet/src/lib/eet_cipher.c +++ b/legacy/eet/src/lib/eet_cipher.c @@ -272,7 +272,7 @@ eet_identity_print(Eet_Key *key, FILE *out) goto on_error; if (!(res = malloc(size))) goto on_error; - fprintf(out, "Private Key:\n"); + INF("Private Key:\n"); buf[32] = '\0'; for (i = 0; i < 6; i++) @@ -284,11 +284,11 @@ eet_identity_print(Eet_Key *key, FILE *out) } if (err) goto on_error; - fprintf(out, "\t%s:\n", names[i]); + INF("\t%s:\n", names[i]); for (j = 0; strlen(res) > j; j += 32) { snprintf(buf, 32, "%s", res + j); - fprintf(out, "\t\t%s\n", buf); + INF("\t\t%s\n", buf); } } free(res); @@ -297,9 +297,9 @@ eet_identity_print(Eet_Key *key, FILE *out) if (key->certificate) { - fprintf(out, "Public certificate:\n"); + INF("Public certificate:\n"); if (gnutls_x509_crt_print(key->certificate, GNUTLS_X509_CRT_FULL, &data)) goto on_error; - fprintf(out, "%s", data.data); + INF("%s", data.data); gnutls_free(data.data); data.data = NULL; } @@ -318,29 +318,29 @@ eet_identity_print(Eet_Key *key, FILE *out) rsa = EVP_PKEY_get1_RSA(key->private_key); if (rsa) { - fprintf(out, "Private key (RSA):\n"); + INF("Private key (RSA):\n"); RSA_print_fp(out, rsa, 0); } dsa = EVP_PKEY_get1_DSA(key->private_key); if (dsa) { - fprintf(out, "Private key (DSA):\n"); + INF("Private key (DSA):\n"); DSA_print_fp(out, dsa, 0); } dh = EVP_PKEY_get1_DH(key->private_key); if (dh) { - fprintf(out, "Private key (DH):\n"); + INF("Private key (DH):\n"); DHparams_print_fp(out, dh); } - fprintf(out, "Public certificate:\n"); + INF("Public certificate:\n"); X509_print_fp(out, key->certificate); # endif #else - fprintf(out, "You need to compile signature support in EET.\n"); + INF("You need to compile signature support in EET.\n"); #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) { - fprintf(out, "No certificate provided.\n"); + INFO("No certificate provided.\n"); return ; } # ifdef HAVE_GNUTLS @@ -699,8 +699,8 @@ eet_identity_certificate_print(const unsigned char *certificate, int der_length, datum.data = NULL; datum.size = 0; if (gnutls_x509_crt_print(cert, GNUTLS_X509_CRT_FULL, &datum)) goto on_error; - fprintf(out, "Public certificate :\n"); - fprintf(out, "%s", datum.data); + INF("Public certificate :\n"); + INF("%s", datum.data); on_error: if (datum.data) gnutls_free(datum.data); @@ -715,17 +715,17 @@ eet_identity_certificate_print(const unsigned char *certificate, int der_length, x509 = d2i_X509(NULL, &tmp, der_length); if (x509 == NULL) { - fprintf(out, "Not a valid certificate.\n"); + INF("Not a valid certificate.\n"); return ; } - fprintf(out, "Public certificate :\n"); + INF("Public certificate :\n"); X509_print_fp(out, x509); X509_free(x509); # endif #else - fprintf(out, "You need to compile signature support in EET.\n"); + INF("You need to compile signature support in EET.\n"); #endif } diff --git a/legacy/eet/src/lib/eet_data.c b/legacy/eet/src/lib/eet_data.c index c5c3fc8f31..a9214f60be 100644 --- a/legacy/eet/src/lib/eet_data.c +++ b/legacy/eet/src/lib/eet_data.c @@ -2020,7 +2020,7 @@ _eet_data_dump_parse(Eet_Dictionary *ed, else if (!strcmp(tok3, "hash")) n->type = EET_G_HASH; else { - printf("ERROR: group type '%s' invalid.\n", tok3); + ERR("ERROR: group type '%s' invalid.\n", tok3); } node = n; } @@ -2132,7 +2132,7 @@ _eet_data_dump_parse(Eet_Dictionary *ed, } else { - printf("ERROR: value type '%s' invalid.\n", tok4); + ERR("ERROR: value type '%s' invalid.\n", tok4); } } } diff --git a/legacy/eet/src/lib/eet_lib.c b/legacy/eet/src/lib/eet_lib.c index d4ff121f31..88e91ac399 100644 --- a/legacy/eet/src/lib/eet_lib.c +++ b/legacy/eet/src/lib/eet_lib.c @@ -142,6 +142,7 @@ struct _Eet_File_Node unsigned char ciphered : 1; }; + #if 0 /* Version 2 */ /* NB: all int's are stored in network byte order on disk */ @@ -223,6 +224,9 @@ static int eet_readers_alloc = 0; static Eet_File **eet_readers = NULL; static int eet_initcount = 0; +/* log domain variable */ +int _eet_log_dom_global=-1; + /* Check to see its' an eet file pointer */ static inline int eet_check_pointer(const Eet_File *ef) @@ -315,7 +319,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) { - fprintf(stderr, "BAD ERROR! Eet realloc of cache list failed. Abort\n"); + CRITICAL("BAD ERROR! Eet realloc of cache list failed. Abort\n"); abort(); } } @@ -360,7 +364,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) { - fprintf(stderr, "BAD ERROR! Eet realloc of cache list failed. Abort\n"); + CRITICAL("BAD ERROR! Eet realloc of cache list failed. Abort\n"); abort(); } } @@ -758,17 +762,27 @@ eet_init(void) if (!eina_init()) { + fprintf(stderr,"Eet: Eina init failed"); + goto erro_eet_eina_init; + } + _eet_log_dom_global = eina_log_domain_register("Eet",EET_DEFAULT_LOG_COLOR); + if(_eet_log_dom_global < 0) + { + fprintf(stderr,"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: #ifdef HAVE_GNUTLS - gnutls_global_deinit(); + gnutls_global_deinit(); #endif #ifdef HAVE_OPENSSL - EVP_cleanup(); - ERR_free_strings(); + EVP_cleanup(); + ERR_free_strings(); #endif - return 0; - } - - return eet_initcount; + return 0; } EAPI int @@ -779,7 +793,7 @@ eet_shutdown(void) if (eet_initcount > 0) return eet_initcount; eet_clearcache(); - + eina_log_domain_unregister(_eet_log_dom_global); eina_shutdown(); #ifdef HAVE_GNUTLS gnutls_global_deinit(); @@ -1060,7 +1074,7 @@ eet_internal_read2(Eet_File *ef) if (eet_test_close(ef->x509_der == NULL, ef)) return NULL; #else - fprintf(stderr, "This file could be signed but you didn't compile the necessary code to check the signature.\n"); + ERROR("This file could be signed but you didn't compile the necessary code to check the signature.\n"); #endif } @@ -1078,7 +1092,7 @@ eet_internal_read1(Eet_File *ef) int byte_entries; int i; - fprintf(stderr, "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.\n", ef->path); + 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.\n", ef->path); /* build header table if read mode */ /* geat header */ @@ -1205,7 +1219,7 @@ eet_internal_read1(Eet_File *ef) strncpy(efn->name, (char *)p + HEADER_SIZE, name_size); efn->name[name_size] = 0; - printf("File: %s is not up to date for key \"%s\" - needs rebuilding sometime\n", ef->path, efn->name); + WARN("File: %s is not up to date for key \"%s\" - needs rebuilding sometime\n", ef->path, efn->name); } else /* The only really usefull peace of code for efn->name (no backward compatibility) */