summaryrefslogtreecommitdiff
path: root/legacy/eet/src/bin
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2011-10-21 05:40:01 +0000
committerCarsten Haitzler <raster@rasterman.com>2011-10-21 05:40:01 +0000
commit8893a9ff35f58e012be3cc838bd94268add13e10 (patch)
treee5c560542a70ccf657e1da45fb57d8dee99d3348 /legacy/eet/src/bin
parenta331fe3bca4816e3a45662afd986e364b3586eed (diff)
ran ecrustify on eet. this seems to do a good job of eet. comments?
SVN revision: 64237
Diffstat (limited to 'legacy/eet/src/bin')
-rw-r--r--legacy/eet/src/bin/eet_main.c147
1 files changed, 76 insertions, 71 deletions
diff --git a/legacy/eet/src/bin/eet_main.c b/legacy/eet/src/bin/eet_main.c
index a433bc5eca..7ab5555387 100644
--- a/legacy/eet/src/bin/eet_main.c
+++ b/legacy/eet/src/bin/eet_main.c
@@ -44,11 +44,11 @@ static int _eet_main_log_dom = -1;
44#define CRIT(...) EINA_LOG_DOM_CRIT(_eet_main_log_dom, __VA_ARGS__) 44#define CRIT(...) EINA_LOG_DOM_CRIT(_eet_main_log_dom, __VA_ARGS__)
45 45
46static void 46static void
47do_eet_list(const char * file) 47do_eet_list(const char *file)
48{ 48{
49 int i, num; 49 int i, num;
50 char ** list; 50 char **list;
51 Eet_File * ef; 51 Eet_File *ef;
52 52
53 ef = eet_open(file, EET_FILE_MODE_READ); 53 ef = eet_open(file, EET_FILE_MODE_READ);
54 if (!ef) 54 if (!ef)
@@ -61,7 +61,7 @@ do_eet_list(const char * file)
61 if (list) 61 if (list)
62 { 62 {
63 for (i = 0; i < num; i++) 63 for (i = 0; i < num; i++)
64 printf("%s\n",list[i]); 64 printf("%s\n", list[i]);
65 free(list); 65 free(list);
66 } 66 }
67 67
@@ -69,15 +69,15 @@ do_eet_list(const char * file)
69} /* do_eet_list */ 69} /* do_eet_list */
70 70
71static void 71static void
72do_eet_extract(const char * file, 72do_eet_extract(const char *file,
73 const char * key, 73 const char *key,
74 const char * out, 74 const char *out,
75 const char * crypto_key) 75 const char *crypto_key)
76{ 76{
77 Eet_File * ef; 77 Eet_File *ef;
78 void * data; 78 void *data;
79 int size = 0; 79 int size = 0;
80 FILE * f; 80 FILE *f;
81 81
82 ef = eet_open(file, EET_FILE_MODE_READ); 82 ef = eet_open(file, EET_FILE_MODE_READ);
83 if (!ef) 83 if (!ef)
@@ -112,19 +112,20 @@ do_eet_extract(const char * file,
112} /* do_eet_extract */ 112} /* do_eet_extract */
113 113
114static void 114static void
115do_eet_decode_dump(void * data, const char * str) 115do_eet_decode_dump(void *data,
116 const char *str)
116{ 117{
117 fputs(str, (FILE *)data); 118 fputs(str, (FILE *)data);
118} /* do_eet_decode_dump */ 119} /* do_eet_decode_dump */
119 120
120static void 121static void
121do_eet_decode(const char * file, 122do_eet_decode(const char *file,
122 const char * key, 123 const char *key,
123 const char * out, 124 const char *out,
124 const char * crypto_key) 125 const char *crypto_key)
125{ 126{
126 Eet_File * ef; 127 Eet_File *ef;
127 FILE * f; 128 FILE *f;
128 129
129 ef = eet_open(file, EET_FILE_MODE_READ); 130 ef = eet_open(file, EET_FILE_MODE_READ);
130 if (!ef) 131 if (!ef)
@@ -151,20 +152,20 @@ do_eet_decode(const char * file,
151} /* do_eet_decode */ 152} /* do_eet_decode */
152 153
153static void 154static void
154do_eet_insert(const char * file, 155do_eet_insert(const char *file,
155 const char * key, 156 const char *key,
156 const char * out, 157 const char *out,
157 int compress, 158 int compress,
158 const char * crypto_key) 159 const char *crypto_key)
159{ 160{
160 Eet_File * ef; 161 Eet_File *ef;
161 void * data; 162 void *data;
162 int size = 0; 163 int size = 0;
163 FILE * f; 164 FILE *f;
164 165
165 ef = eet_open(file, EET_FILE_MODE_READ_WRITE); 166 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
166 if (!ef) 167 if (!ef)
167 ef = eet_open(file, EET_FILE_MODE_WRITE); 168 ef = eet_open(file, EET_FILE_MODE_WRITE);
168 169
169 if (!ef) 170 if (!ef)
170 { 171 {
@@ -202,21 +203,21 @@ do_eet_insert(const char * file,
202} /* do_eet_insert */ 203} /* do_eet_insert */
203 204
204static void 205static void
205do_eet_encode(const char * file, 206do_eet_encode(const char *file,
206 const char * key, 207 const char *key,
207 const char * out, 208 const char *out,
208 int compress, 209 int compress,
209 const char * crypto_key) 210 const char *crypto_key)
210{ 211{
211 Eet_File * ef; 212 Eet_File *ef;
212 char * text; 213 char *text;
213 int textlen = 0; 214 int textlen = 0;
214 int size = 0; 215 int size = 0;
215 FILE * f; 216 FILE *f;
216 217
217 ef = eet_open(file, EET_FILE_MODE_READ_WRITE); 218 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
218 if (!ef) 219 if (!ef)
219 ef = eet_open(file, EET_FILE_MODE_WRITE); 220 ef = eet_open(file, EET_FILE_MODE_WRITE);
220 221
221 if (!ef) 222 if (!ef)
222 { 223 {
@@ -259,9 +260,10 @@ do_eet_encode(const char * file,
259} /* do_eet_encode */ 260} /* do_eet_encode */
260 261
261static void 262static void
262do_eet_remove(const char * file, const char * key) 263do_eet_remove(const char *file,
264 const char *key)
263{ 265{
264 Eet_File * ef; 266 Eet_File *ef;
265 267
266 ef = eet_open(file, EET_FILE_MODE_READ_WRITE); 268 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
267 if (!ef) 269 if (!ef)
@@ -275,10 +277,10 @@ do_eet_remove(const char * file, const char * key)
275} /* do_eet_remove */ 277} /* do_eet_remove */
276 278
277static void 279static void
278do_eet_check(const char * file) 280do_eet_check(const char *file)
279{ 281{
280 Eet_File * ef; 282 Eet_File *ef;
281 const void * der; 283 const void *der;
282 int der_length; 284 int der_length;
283 int sign_length; 285 int sign_length;
284 286
@@ -301,10 +303,12 @@ do_eet_check(const char * file)
301} /* do_eet_check */ 303} /* do_eet_check */
302 304
303static void 305static void
304do_eet_sign(const char * file, const char * private_key, const char * public_key) 306do_eet_sign(const char *file,
307 const char *private_key,
308 const char *public_key)
305{ 309{
306 Eet_File * ef; 310 Eet_File *ef;
307 Eet_Key * key; 311 Eet_Key *key;
308 312
309 ef = eet_open(file, EET_FILE_MODE_READ_WRITE); 313 ef = eet_open(file, EET_FILE_MODE_READ_WRITE);
310 if (!ef) 314 if (!ef)
@@ -329,77 +333,78 @@ do_eet_sign(const char * file, const char * private_key, const char * public_key
329} /* do_eet_sign */ 333} /* do_eet_sign */
330 334
331int 335int
332main(int argc, char ** argv) 336main(int argc,
337 char **argv)
333{ 338{
334 if (!eet_init()) 339 if (!eet_init())
335 return -1; 340 return -1;
336 341
337 _eet_main_log_dom = eina_log_domain_register("eet_main", EINA_COLOR_CYAN); 342 _eet_main_log_dom = eina_log_domain_register("eet_main", EINA_COLOR_CYAN);
338 if(_eet_main_log_dom < -1) 343 if(_eet_main_log_dom < -1)
339 { 344 {
340 EINA_LOG_ERR("Impossible to create a log domain for eet_main."); 345 EINA_LOG_ERR("Impossible to create a log domain for eet_main.");
341 eet_shutdown(); 346 eet_shutdown();
342 return(-1); 347 return -1;
343 } 348 }
344 349
345 if (argc < 2) 350 if (argc < 2)
346 { 351 {
347help: 352help:
348 printf( 353 printf(
349 "Usage:\n" 354 "Usage:\n"
350 " eet -l FILE.EET list all keys in FILE.EET\n" 355 " eet -l FILE.EET list all keys in FILE.EET\n"
351 " eet -x FILE.EET KEY OUT-FILE [CRYPTO_KEY] extract data stored in KEY in FILE.EET and write to OUT-FILE\n" 356 " eet -x FILE.EET KEY OUT-FILE [CRYPTO_KEY] extract data stored in KEY in FILE.EET and write to OUT-FILE\n"
352 " eet -d FILE.EET KEY OUT-FILE [CRYPTO_KEY] extract and decode data stored in KEY in FILE.EET and write to OUT-FILE\n" 357 " eet -d FILE.EET KEY OUT-FILE [CRYPTO_KEY] extract and decode data stored in KEY in FILE.EET and write to OUT-FILE\n"
353 " eet -i FILE.EET KEY IN-FILE COMPRESS [CRYPTO_KEY] insert data to KEY in FILE.EET from IN-FILE and if COMPRESS is 1, compress it\n" 358 " eet -i FILE.EET KEY IN-FILE COMPRESS [CRYPTO_KEY] insert data to KEY in FILE.EET from IN-FILE and if COMPRESS is 1, compress it\n"
354 " eet -e FILE.EET KEY IN-FILE COMPRESS [CRYPTO_KEY] insert and encode to KEY in FILE.EET from IN-FILE and if COMPRESS is 1, compress it\n" 359 " eet -e FILE.EET KEY IN-FILE COMPRESS [CRYPTO_KEY] insert and encode to KEY in FILE.EET from IN-FILE and if COMPRESS is 1, compress it\n"
355 " eet -r FILE.EET KEY remove KEY in FILE.EET\n" 360 " eet -r FILE.EET KEY remove KEY in FILE.EET\n"
356 " eet -c FILE.EET report and check the signature information of an eet file\n" 361 " eet -c FILE.EET report and check the signature information of an eet file\n"
357 " eet -s FILE.EET PRIVATE_KEY PUBLIC_KEY sign FILE.EET with PRIVATE_KEY and attach PUBLIC_KEY as it's certificate\n" 362 " eet -s FILE.EET PRIVATE_KEY PUBLIC_KEY sign FILE.EET with PRIVATE_KEY and attach PUBLIC_KEY as it's certificate\n"
358 ); 363 );
359 eet_shutdown(); 364 eet_shutdown();
360 return -1; 365 return -1;
361 } 366 }
362 367
363 if ((!strncmp(argv[1], "-h", 2))) 368 if ((!strncmp(argv[1], "-h", 2)))
364 goto help; 369 goto help;
365 else if ((!strcmp(argv[1], "-l")) && (argc > 2)) 370 else if ((!strcmp(argv[1], "-l")) && (argc > 2))
366 do_eet_list(argv[2]); 371 do_eet_list(argv[2]);
367 else if ((!strcmp(argv[1], "-x")) && (argc > 4)) 372 else if ((!strcmp(argv[1], "-x")) && (argc > 4))
368 { 373 {
369 if (argc > 5) 374 if (argc > 5)
370 do_eet_extract(argv[2], argv[3], argv[4], argv[5]); 375 do_eet_extract(argv[2], argv[3], argv[4], argv[5]);
371 else 376 else
372 do_eet_extract(argv[2], argv[3], argv[4], NULL); 377 do_eet_extract(argv[2], argv[3], argv[4], NULL);
373 } 378 }
374 else if ((!strcmp(argv[1], "-d")) && (argc > 4)) 379 else if ((!strcmp(argv[1], "-d")) && (argc > 4))
375 { 380 {
376 if (argc > 5) 381 if (argc > 5)
377 do_eet_decode(argv[2], argv[3], argv[4], argv[5]); 382 do_eet_decode(argv[2], argv[3], argv[4], argv[5]);
378 else 383 else
379 do_eet_decode(argv[2], argv[3], argv[4], NULL); 384 do_eet_decode(argv[2], argv[3], argv[4], NULL);
380 } 385 }
381 else if ((!strcmp(argv[1], "-i")) && (argc > 5)) 386 else if ((!strcmp(argv[1], "-i")) && (argc > 5))
382 { 387 {
383 if (argc > 6) 388 if (argc > 6)
384 do_eet_insert(argv[2], argv[3], argv[4], atoi(argv[5]), argv[6]); 389 do_eet_insert(argv[2], argv[3], argv[4], atoi(argv[5]), argv[6]);
385 else 390 else
386 do_eet_insert(argv[2], argv[3], argv[4], atoi(argv[5]), NULL); 391 do_eet_insert(argv[2], argv[3], argv[4], atoi(argv[5]), NULL);
387 } 392 }
388 else if ((!strcmp(argv[1], "-e")) && (argc > 5)) 393 else if ((!strcmp(argv[1], "-e")) && (argc > 5))
389 { 394 {
390 if (argc > 6) 395 if (argc > 6)
391 do_eet_encode(argv[2], argv[3], argv[4], atoi(argv[5]), argv[6]); 396 do_eet_encode(argv[2], argv[3], argv[4], atoi(argv[5]), argv[6]);
392 else 397 else
393 do_eet_encode(argv[2], argv[3], argv[4], atoi(argv[5]), NULL); 398 do_eet_encode(argv[2], argv[3], argv[4], atoi(argv[5]), NULL);
394 } 399 }
395 else if ((!strcmp(argv[1], "-r")) && (argc > 3)) 400 else if ((!strcmp(argv[1], "-r")) && (argc > 3))
396 do_eet_remove(argv[2], argv[3]); 401 do_eet_remove(argv[2], argv[3]);
397 else if ((!strcmp(argv[1], "-c")) && (argc > 2)) 402 else if ((!strcmp(argv[1], "-c")) && (argc > 2))
398 do_eet_check(argv[2]); 403 do_eet_check(argv[2]);
399 else if ((!strcmp(argv[1], "-s")) && (argc > 4)) 404 else if ((!strcmp(argv[1], "-s")) && (argc > 4))
400 do_eet_sign(argv[2], argv[3], argv[4]); 405 do_eet_sign(argv[2], argv[3], argv[4]);
401 else 406 else
402 goto help; 407 goto help;
403 408
404 eina_log_domain_unregister(_eet_main_log_dom); 409 eina_log_domain_unregister(_eet_main_log_dom);
405 eet_shutdown(); 410 eet_shutdown();