summaryrefslogtreecommitdiff
path: root/legacy/eet/src/bin
diff options
context:
space:
mode:
authorVincent Torri <vincent.torri@gmail.com>2009-10-02 03:59:17 +0000
committerVincent Torri <vincent.torri@gmail.com>2009-10-02 03:59:17 +0000
commitd26955c4327fdafa63456e82afe90ba135c57efc (patch)
treed6d018c150119e13b68aa3416e5b120e1ed25d8e /legacy/eet/src/bin
parent4cccce6dfeb0c284be71a06679825e9773bb7829 (diff)
remove useless Eina_Log macros. Patch by Mathieu Taillefumier.
SVN revision: 42850
Diffstat (limited to 'legacy/eet/src/bin')
-rw-r--r--legacy/eet/src/bin/eet_main.c84
1 files changed, 60 insertions, 24 deletions
diff --git a/legacy/eet/src/bin/eet_main.c b/legacy/eet/src/bin/eet_main.c
index 1ae39fea3f..43fac6f7a1 100644
--- a/legacy/eet/src/bin/eet_main.c
+++ b/legacy/eet/src/bin/eet_main.c
@@ -19,6 +19,34 @@
19 19
20#include <Eet.h> 20#include <Eet.h>
21 21
22
23static int _eet_main_log_dom = -1;
24
25#ifdef EET_DEFAULT_LOG_COLOR
26#undef EET_DEFAULT_LOG_COLOR
27#endif
28#define EET_DEFAULT_LOG_COLOR EINA_COLOR_CYAN
29#ifdef ERR
30#undef ERR
31#endif
32#define ERR(...) EINA_LOG_DOM_ERR(_eet_main_log_dom, __VA_ARGS__)
33#ifdef DBG
34#undef DBG
35#endif
36#define DBG(...) EINA_LOG_DOM_DBG(_eet_main_log_dom, __VA_ARGS__)
37#ifdef INF
38#undef INF
39#endif
40#define INF(...) EINA_LOG_DOM_INFO(_eet_main_log_dom, __VA_ARGS__)
41#ifdef WRN
42#undef WRN
43#endif
44#define WRN(...) EINA_LOG_DOM_WARN(_eet_main_log_dom, __VA_ARGS__)
45#ifdef CRIT
46#undef CRIT
47#endif
48#define CRIT(...) EINA_LOG_DOM_CRIT(_eet_main_log_dom, __VA_ARGS__)
49
22static void 50static void
23do_eet_list(const char *file) 51do_eet_list(const char *file)
24{ 52{
@@ -29,7 +57,7 @@ do_eet_list(const char *file)
29 ef = eet_open(file, EET_FILE_MODE_READ); 57 ef = eet_open(file, EET_FILE_MODE_READ);
30 if (!ef) 58 if (!ef)
31 { 59 {
32 printf("cannot open for reading: %s\n", file); 60 ERR("cannot open for reading: %s\n", file);
33 exit(-1); 61 exit(-1);
34 } 62 }
35 list = eet_list(ef, "*", &num); 63 list = eet_list(ef, "*", &num);
@@ -53,24 +81,24 @@ do_eet_extract(const char *file, const char *key, const char *out, const char *c
53 ef = eet_open(file, EET_FILE_MODE_READ); 81 ef = eet_open(file, EET_FILE_MODE_READ);
54 if (!ef) 82 if (!ef)
55 { 83 {
56 printf("cannot open for reading: %s\n", file); 84 ERR("cannot open for reading: %s\n", file);
57 exit(-1); 85 exit(-1);
58 } 86 }
59 data = eet_read_cipher(ef, key, &size, crypto_key); 87 data = eet_read_cipher(ef, key, &size, crypto_key);
60 if (!data) 88 if (!data)
61 { 89 {
62 printf("cannot read key %s\n", key); 90 ERR("cannot read key %s\n", key);
63 exit(-1); 91 exit(-1);
64 } 92 }
65 f = fopen(out, "w"); 93 f = fopen(out, "w");
66 if (!f) 94 if (!f)
67 { 95 {
68 printf("cannot open %s\n", out); 96 ERR("cannot open %s\n", out);
69 exit(-1); 97 exit(-1);
70 } 98 }
71 if (fwrite(data, size, 1, f) != 1) 99 if (fwrite(data, size, 1, f) != 1)
72 { 100 {
73 printf("cannot write to %s\n", out); 101 ERR("cannot write to %s\n", out);
74 exit(-1); 102 exit(-1);
75 } 103 }
76 fclose(f); 104 fclose(f);
@@ -93,18 +121,18 @@ do_eet_decode(const char *file, const char *key, const char *out, const char *cr
93 ef = eet_open(file, EET_FILE_MODE_READ); 121 ef = eet_open(file, EET_FILE_MODE_READ);
94 if (!ef) 122 if (!ef)
95 { 123 {
96 printf("cannot open for reading: %s\n", file); 124 ERR("cannot open for reading: %s\n", file);
97 exit(-1); 125 exit(-1);
98 } 126 }
99 f = fopen(out, "w"); 127 f = fopen(out, "w");
100 if (!f) 128 if (!f)
101 { 129 {
102 printf("cannot open %s\n", out); 130 ERR("cannot open %s\n", out);
103 exit(-1); 131 exit(-1);
104 } 132 }
105 if (!eet_data_dump_cipher(ef, key, crypto_key, do_eet_decode_dump, f)) 133 if (!eet_data_dump_cipher(ef, key, crypto_key, do_eet_decode_dump, f))
106 { 134 {
107 printf("cannot write to %s\n", out); 135 ERR("cannot write to %s\n", out);
108 exit(-1); 136 exit(-1);
109 } 137 }
110 fclose(f); 138 fclose(f);
@@ -124,13 +152,13 @@ do_eet_insert(const char *file, const char *key, const char *out, int compress,
124 ef = eet_open(file, EET_FILE_MODE_WRITE); 152 ef = eet_open(file, EET_FILE_MODE_WRITE);
125 if (!ef) 153 if (!ef)
126 { 154 {
127 printf("cannot open for read+write: %s\n", file); 155 ERR("cannot open for read+write: %s\n", file);
128 exit(-1); 156 exit(-1);
129 } 157 }
130 f = fopen(out, "r"); 158 f = fopen(out, "r");
131 if (!f) 159 if (!f)
132 { 160 {
133 printf("cannot open %s\n", out); 161 ERR("cannot open %s\n", out);
134 exit(-1); 162 exit(-1);
135 } 163 }
136 fseek(f, 0, SEEK_END); 164 fseek(f, 0, SEEK_END);
@@ -139,12 +167,12 @@ do_eet_insert(const char *file, const char *key, const char *out, int compress,
139 data = malloc(size); 167 data = malloc(size);
140 if (!data) 168 if (!data)
141 { 169 {
142 printf("cannot allocate %i bytes\n", size); 170 ERR("cannot allocate %i bytes\n", size);
143 exit(-1); 171 exit(-1);
144 } 172 }
145 if (fread(data, size, 1, f) != 1) 173 if (fread(data, size, 1, f) != 1)
146 { 174 {
147 printf("cannot read file %s\n", out); 175 ERR("cannot read file %s\n", out);
148 exit(-1); 176 exit(-1);
149 } 177 }
150 fclose(f); 178 fclose(f);
@@ -167,13 +195,13 @@ do_eet_encode(const char *file, const char *key, const char *out, int compress,
167 ef = eet_open(file, EET_FILE_MODE_WRITE); 195 ef = eet_open(file, EET_FILE_MODE_WRITE);
168 if (!ef) 196 if (!ef)
169 { 197 {
170 printf("cannot open for read+write: %s\n", file); 198 ERR("cannot open for read+write: %s\n", file);
171 exit(-1); 199 exit(-1);
172 } 200 }
173 f = fopen(out, "r"); 201 f = fopen(out, "r");
174 if (!f) 202 if (!f)
175 { 203 {
176 printf("cannot open %s\n", out); 204 ERR("cannot open %s\n", out);
177 exit(-1); 205 exit(-1);
178 } 206 }
179 fseek(f, 0, SEEK_END); 207 fseek(f, 0, SEEK_END);
@@ -182,18 +210,18 @@ do_eet_encode(const char *file, const char *key, const char *out, int compress,
182 text = malloc(textlen); 210 text = malloc(textlen);
183 if (!text) 211 if (!text)
184 { 212 {
185 printf("cannot allocate %i bytes\n", size); 213 ERR("cannot allocate %i bytes\n", size);
186 exit(-1); 214 exit(-1);
187 } 215 }
188 if (fread(text, textlen, 1, f) != 1) 216 if (fread(text, textlen, 1, f) != 1)
189 { 217 {
190 printf("cannot read file %s\n", out); 218 ERR("cannot read file %s\n", out);
191 exit(-1); 219 exit(-1);
192 } 220 }
193 fclose(f); 221 fclose(f);
194 if (!eet_data_undump_cipher(ef, key, crypto_key, text, textlen, compress)) 222 if (!eet_data_undump_cipher(ef, key, crypto_key, text, textlen, compress))
195 { 223 {
196 printf("cannot parse %s\n", out); 224 ERR("cannot parse %s\n", out);
197 exit(-1); 225 exit(-1);
198 } 226 }
199 free(text); 227 free(text);
@@ -208,7 +236,7 @@ do_eet_remove(const char *file, const char *key)
208 ef = eet_open(file, EET_FILE_MODE_READ_WRITE); 236 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
209 if (!ef) 237 if (!ef)
210 { 238 {
211 printf("cannot open for read+write: %s\n", file); 239 ERR("cannot open for read+write: %s\n", file);
212 exit(-1); 240 exit(-1);
213 } 241 }
214 eet_delete(ef, key); 242 eet_delete(ef, key);
@@ -226,17 +254,17 @@ do_eet_check(const char *file)
226 ef = eet_open(file, EET_FILE_MODE_READ); 254 ef = eet_open(file, EET_FILE_MODE_READ);
227 if (!ef) 255 if (!ef)
228 { 256 {
229 fprintf(stdout, "checking signature of `%s` failed\n", file); 257 ERR("checking signature of `%s` failed\n", file);
230 exit(-1); 258 exit(-1);
231 } 259 }
232 260
233 der = eet_identity_x509(ef, &der_length); 261 der = eet_identity_x509(ef, &der_length);
234 262
235 fprintf(stderr, "Certificate length %i.\n", der_length); 263 ERR("Certificate length %i.\n", der_length);
236 eet_identity_certificate_print(der, der_length, stdout); 264 eet_identity_certificate_print(der, der_length, stdout);
237 265
238 eet_identity_signature(ef, &sign_length); 266 eet_identity_signature(ef, &sign_length);
239 fprintf(stderr, "Signature length %i.\n", sign_length); 267 ERR("Signature length %i.\n", sign_length);
240 268
241 eet_close(ef); 269 eet_close(ef);
242} 270}
@@ -250,18 +278,18 @@ do_eet_sign(const char *file, const char *private_key, const char *public_key)
250 ef = eet_open(file, EET_FILE_MODE_READ_WRITE); 278 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
251 if (!ef) 279 if (!ef)
252 { 280 {
253 fprintf(stdout, "cannot open for read+write: %s.\n", file); 281 ERR("cannot open for read+write: %s.\n", file);
254 exit(-1); 282 exit(-1);
255 } 283 }
256 284
257 key = eet_identity_open(public_key, private_key, NULL); 285 key = eet_identity_open(public_key, private_key, NULL);
258 if (!key) 286 if (!key)
259 { 287 {
260 fprintf(stdout, "cannot open key '%s:%s'.\n", public_key, private_key); 288 ERR("cannot open key '%s:%s'.\n", public_key, private_key);
261 exit(-1); 289 exit(-1);
262 } 290 }
263 291
264 fprintf(stdout, "Using the following key to sign `%s`.\n", file); 292 ERR("Using the following key to sign `%s`.\n", file);
265 eet_identity_print(key, stdout); 293 eet_identity_print(key, stdout);
266 294
267 eet_identity_set(ef, key); 295 eet_identity_set(ef, key);
@@ -273,6 +301,13 @@ int
273main(int argc, char **argv) 301main(int argc, char **argv)
274{ 302{
275 eet_init(); 303 eet_init();
304 _eet_main_log_dom = eina_log_domain_register("Eet_Main",EINA_COLOR_CYAN);
305 if(_eet_main_log_dom < -1)
306 {
307 EINA_LOG_ERR("Impossible to create a log domain for eet_main.\n");
308 eet_shutdown();
309 return(-1);
310 }
276 if (argc < 2) 311 if (argc < 2)
277 { 312 {
278 help: 313 help:
@@ -341,6 +376,7 @@ main(int argc, char **argv)
341 { 376 {
342 goto help; 377 goto help;
343 } 378 }
379 eina_log_domain_unregister(_eet_main_log_dom);
344 eet_shutdown(); 380 eet_shutdown();
345 return 0; 381 return 0;
346} 382}