summaryrefslogtreecommitdiff
path: root/legacy/eet/src
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2012-02-10 15:30:33 +0000
committerCedric BAIL <cedric.bail@free.fr>2012-02-10 15:30:33 +0000
commitef1e91430fe422bdaaebc42d32e8680d8fc3377b (patch)
tree8870e47534c6d89d4ca3b6b4584d9830212818a2 /legacy/eet/src
parentf6db68d6f57a4f21a1aa1cdd58ed4bb2724bf578 (diff)
eet: add support for statistique.
SVN revision: 67829
Diffstat (limited to 'legacy/eet/src')
-rw-r--r--legacy/eet/src/bin/eet_main.c60
-rw-r--r--legacy/eet/src/lib/Eet.h11
-rw-r--r--legacy/eet/src/lib/eet_dictionary.c6
3 files changed, 77 insertions, 0 deletions
diff --git a/legacy/eet/src/bin/eet_main.c b/legacy/eet/src/bin/eet_main.c
index 0d577adbf2..8a93d11b4f 100644
--- a/legacy/eet/src/bin/eet_main.c
+++ b/legacy/eet/src/bin/eet_main.c
@@ -69,6 +69,63 @@ do_eet_list(const char *file)
69} /* do_eet_list */ 69} /* do_eet_list */
70 70
71static void 71static void
72do_eet_stats(const char *file)
73{
74 int i, num;
75 int count[2] = { 0, 0 };
76 int size[2] = { 0, 0 };
77 char **list;
78 Eet_File *ef;
79 Eet_Dictionary *ed;
80
81 ef = eet_open(file, EET_FILE_MODE_READ);
82 if (!ef)
83 {
84 ERR("cannot open for reading: %s", file);
85 exit(-1);
86 }
87
88 printf("*** sections stats ***\n");
89 list = eet_list(ef, "*", &num);
90 if (list)
91 {
92 for (i = 0; i < num; i++)
93 {
94 const void *ro = NULL;
95 void *rw = NULL;
96 int tsize;
97
98 ro = eet_read_direct(ef, list[i], &tsize);
99 if (!ro) rw = eet_read(ef, list[i], &tsize);
100 printf(rw ? "%s of size %i is compressed.\n" : "%s of size %i is not compressed.\n", list[i], tsize);
101 count[rw ? 0 : 1]++;
102 size[rw ? 0 : 1] += tsize;
103 free(rw);
104 }
105 free(list);
106 }
107
108 printf("*** dictionary ***\n");
109 ed = eet_dictionary_get(ef);
110 if (ed)
111 {
112 printf("%i strings inside the dictionary.\n", eet_dictionary_count(ed));
113 }
114 else
115 {
116 printf("no dictionary in this file.\n");
117 }
118 printf("*** global ***\n");
119 printf("%i sections\n", num);
120 printf("- %i of them are compressed (%02.2f%%) expanding in %i bytes.\n",
121 count[0], (float) count[0] * 100 / (float) num, size[0]);
122 printf("- %i of them are directly mappable in memory (%02.2f%%) representing %i bytes.\n",
123 count[1], (float) count[1] * 100 / (float) num, size[1]);
124
125 eet_close(ef);
126}
127
128static void
72do_eet_extract(const char *file, 129do_eet_extract(const char *file,
73 const char *key, 130 const char *key,
74 const char *out, 131 const char *out,
@@ -366,6 +423,7 @@ help:
366 " eet -r FILE.EET KEY remove KEY in FILE.EET\n" 423 " eet -r FILE.EET KEY remove KEY in FILE.EET\n"
367 " eet -c FILE.EET report and check the signature information of an eet file\n" 424 " eet -c FILE.EET report and check the signature information of an eet file\n"
368 " eet -s FILE.EET PRIVATE_KEY PUBLIC_KEY sign FILE.EET with PRIVATE_KEY and attach PUBLIC_KEY as it's certificate\n" 425 " eet -s FILE.EET PRIVATE_KEY PUBLIC_KEY sign FILE.EET with PRIVATE_KEY and attach PUBLIC_KEY as it's certificate\n"
426 " eet -t FILE.EET give some statistic about a file\n"
369 ); 427 );
370 eet_shutdown(); 428 eet_shutdown();
371 return -1; 429 return -1;
@@ -437,6 +495,8 @@ help:
437 do_eet_check(argv[2]); 495 do_eet_check(argv[2]);
438 else if ((!strcmp(argv[1], "-s")) && (argc > 4)) 496 else if ((!strcmp(argv[1], "-s")) && (argc > 4))
439 do_eet_sign(argv[2], argv[3], argv[4]); 497 do_eet_sign(argv[2], argv[3], argv[4]);
498 else if ((!strcmp(argv[1], "-t")) && (argc > 2))
499 do_eet_stats(argv[2]);
440 else 500 else
441 goto help; 501 goto help;
442 502
diff --git a/legacy/eet/src/lib/Eet.h b/legacy/eet/src/lib/Eet.h
index db31767449..35dc18adde 100644
--- a/legacy/eet/src/lib/Eet.h
+++ b/legacy/eet/src/lib/Eet.h
@@ -645,6 +645,17 @@ eet_dictionary_string_check(Eet_Dictionary *ed,
645 const char *string); 645 const char *string);
646 646
647/** 647/**
648 * Return the number of strings inside a dictionary
649 * @param ed A valid dictionary handle
650 * @return the number of strings inside a dictionary
651 *
652 * @since 1.6.0
653 * @ingroup Eet_File_Group
654 */
655EAPI int
656eet_dictionary_count(const Eet_Dictionary *ed);
657
658/**
648 * Read a specified entry from an eet file and return data 659 * Read a specified entry from an eet file and return data
649 * @param ef A valid eet file handle opened for reading. 660 * @param ef A valid eet file handle opened for reading.
650 * @param name Name of the entry. eg: "/base/file_i_want". 661 * @param name Name of the entry. eg: "/base/file_i_want".
diff --git a/legacy/eet/src/lib/eet_dictionary.c b/legacy/eet/src/lib/eet_dictionary.c
index 287860d97b..c79239bc5d 100644
--- a/legacy/eet/src/lib/eet_dictionary.c
+++ b/legacy/eet/src/lib/eet_dictionary.c
@@ -169,6 +169,12 @@ eet_dictionary_string_get_size(const Eet_Dictionary *ed,
169 return 0; 169 return 0;
170} 170}
171 171
172EAPI int
173eet_dictionary_count(const Eet_Dictionary *ed)
174{
175 return ed->count;
176}
177
172int 178int
173eet_dictionary_string_get_hash(const Eet_Dictionary *ed, 179eet_dictionary_string_get_hash(const Eet_Dictionary *ed,
174 int idx) 180 int idx)