#include <Eet.h>
+
+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)
{
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);
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);
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);
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);
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);
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);
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);
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);
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);
}
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);
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:
{
goto help;
}
+ eina_log_domain_unregister(_eet_main_log_dom);
eet_shutdown();
return 0;
}
} 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
*/
#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);
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
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();
}
}
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();
}
}
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;
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:
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
}
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 */
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) */