summaryrefslogtreecommitdiff
path: root/legacy/eet/src/bin
diff options
context:
space:
mode:
authorCarsten Haitzler <raster@rasterman.com>2006-10-28 06:32:53 +0000
committerCarsten Haitzler <raster@rasterman.com>2006-10-28 06:32:53 +0000
commit101ed1b320cc2775bb9457185750f2ee776776f1 (patch)
tree7f01295a91715c4063e8a9b37cb9d57adf710379 /legacy/eet/src/bin
parentfd40774d786f79c86f50e6bf3d8bec965419e352 (diff)
remove eet test progs
SVN revision: 26821
Diffstat (limited to 'legacy/eet/src/bin')
-rw-r--r--legacy/eet/src/bin/.cvsignore8
-rw-r--r--legacy/eet/src/bin/Makefile.am17
-rw-r--r--legacy/eet/src/bin/eet_bench_main.c122
-rw-r--r--legacy/eet/src/bin/eet_main.c446
4 files changed, 0 insertions, 593 deletions
diff --git a/legacy/eet/src/bin/.cvsignore b/legacy/eet/src/bin/.cvsignore
deleted file mode 100644
index 693972feb3..0000000000
--- a/legacy/eet/src/bin/.cvsignore
+++ /dev/null
@@ -1,8 +0,0 @@
1eet
2eet-config
3libeet.so.0.0.0
4.deps
5.libs
6Makefile
7Makefile.in
8eet_bench
diff --git a/legacy/eet/src/bin/Makefile.am b/legacy/eet/src/bin/Makefile.am
deleted file mode 100644
index 3fb463fb72..0000000000
--- a/legacy/eet/src/bin/Makefile.am
+++ /dev/null
@@ -1,17 +0,0 @@
1MAINTAINERCLEANFILES = Makefile.in
2
3INCLUDES = -I$(top_srcdir)/src/lib
4
5bin_PROGRAMS = eet eet_bench
6
7eet_SOURCES = \
8eet_main.c
9
10eet_LDADD = $(top_builddir)/src/lib/libeet.la
11eet_DEPENDENCIES = $(top_builddir)/src/lib/libeet.la
12
13eet_bench_SOURCES = \
14eet_bench_main.c
15
16eet_bench_LDADD = $(top_builddir)/src/lib/libeet.la
17eet_bench_DEPENDENCIES = $(top_builddir)/src/lib/libeet.la
diff --git a/legacy/eet/src/bin/eet_bench_main.c b/legacy/eet/src/bin/eet_bench_main.c
deleted file mode 100644
index cc13da36ef..0000000000
--- a/legacy/eet/src/bin/eet_bench_main.c
+++ /dev/null
@@ -1,122 +0,0 @@
1/* strdup requires BSD source */
2#define _BSD_SOURCE
3
4#include "Eet.h"
5#include <stdio.h>
6#include <unistd.h>
7#include <stdlib.h>
8#include <string.h>
9#include <sys/types.h>
10#include <sys/stat.h>
11#include <unistd.h>
12#include <dirent.h>
13#include <limits.h>
14#include <fnmatch.h>
15#include <sys/time.h>
16#include <time.h>
17
18double
19get_time(void)
20{
21 struct timeval timev;
22
23 gettimeofday(&timev, NULL);
24 return (double)timev.tv_sec + (((double)timev.tv_usec) / 1000000);
25}
26
27int
28main(int argc, char **argv)
29{
30 char *file;
31 Eet_File *ef;
32 char **items;
33 int items_num;
34 int i;
35 double t1, t2;
36
37 if (argc < 2)
38 exit(-1);
39
40 file = argv[1];
41 ef = eet_open(file, EET_FILE_MODE_READ);
42 if (ef)
43 {
44 items = eet_list(ef, "images/*", &items_num);
45 for (i = 0; i < items_num; i++)
46 items[i] = strdup(items[i]);
47 eet_close(ef);
48 }
49 else
50 {
51 printf("EEK. cannot load %s\n", file);
52 exit(-1);
53 }
54
55 t1 = get_time();
56 ef = eet_open(file, EET_FILE_MODE_READ);
57 if (ef)
58 {
59 for (i = 0; i < items_num; i++)
60 {
61 int alpha, compress, quality, lossy;
62 unsigned int w, h;
63 void *data;
64
65 if (eet_data_image_header_read(ef, items[i], &w, &h, &alpha, &compress, &quality, &lossy))
66 {
67 data = eet_data_image_read(ef, items[i], &w, &h, &alpha, &compress, &quality, &lossy);
68 if (data) free(data);
69 else
70 {
71 printf("failure reading %s (%i/%i\n", items[i], i, items_num);
72 exit(-1);
73 }
74 }
75 else
76 {
77 printf("failure reading header %s (%i/%i\n", items[i], i, items_num);
78 exit(-1);
79 }
80 }
81 }
82 eet_close(ef);
83 t2 = get_time();
84 printf("1 open/close: %i img headers + data in %3.3f sec (%3.3f img/sec)\n",
85 items_num,
86 t2 - t1,
87 (double)items_num / (t2 - t1));
88 t1 = get_time();
89 for (i = 0; i < items_num; i++)
90 {
91 int alpha, compress, quality, lossy;
92 unsigned int w, h;
93 void *data;
94
95 ef = eet_open(file, EET_FILE_MODE_READ);
96 if (ef)
97 {
98 if (eet_data_image_header_read(ef, items[i], &w, &h, &alpha, &compress, &quality, &lossy))
99 {
100 data = eet_data_image_read(ef, items[i], &w, &h, &alpha, &compress, &quality, &lossy);
101 if (data) free(data);
102 else
103 {
104 printf("failure reading %s (%i/%i\n", items[i], i, items_num);
105 exit(-1);
106 }
107 }
108 else
109 {
110 printf("failure reading header %s (%i/%i\n", items[i], i, items_num);
111 exit(-1);
112 }
113 eet_close(ef);
114 }
115 }
116 t2 = get_time();
117 printf("many open/close: %i img headers + data in %3.3f sec (%3.3f img/sec)\n",
118 items_num,
119 t2 - t1,
120 (double)items_num / (t2 - t1));
121 return 0;
122}
diff --git a/legacy/eet/src/bin/eet_main.c b/legacy/eet/src/bin/eet_main.c
deleted file mode 100644
index c468333e69..0000000000
--- a/legacy/eet/src/bin/eet_main.c
+++ /dev/null
@@ -1,446 +0,0 @@
1#include "Eet.h"
2#include <stdio.h>
3#include <unistd.h>
4#include <stdlib.h>
5#include <string.h>
6#include <sys/types.h>
7#include <sys/stat.h>
8#include <unistd.h>
9#include <dirent.h>
10#include <limits.h>
11#include <fnmatch.h>
12
13#ifndef PATH_MAX
14#define PATH_MAX 4096
15#endif
16
17/* just some sample code on how to use encoder/decoders */
18#if 0
19#include <Evas.h>
20
21typedef struct _blah2
22{
23 char *string;
24}
25Blah2;
26
27typedef struct _blah3
28{
29 char *string;
30}
31Blah3;
32
33typedef struct _blah
34{
35 char character;
36 short sixteen;
37 int integer;
38 long long lots;
39 float floating;
40 double floating_lots;
41 char *string;
42 Blah2 *blah2;
43 Evas_List *blah3;
44}
45Blah;
46
47void
48encdectest(void)
49{
50 Blah blah;
51 Blah2 blah2;
52 Blah3 blah3;
53 Eet_Data_Descriptor *edd, *edd2, *edd3;
54 void *data;
55 int size;
56 FILE *f;
57 Blah *blah_in;
58
59 edd3 = eet_data_descriptor_new("blah3", sizeof(Blah3),
60 evas_list_next,
61 evas_list_append,
62 evas_list_data,
63 evas_list_free,
64 evas_hash_foreach,
65 evas_hash_add,
66 evas_hash_free);
67 EET_DATA_DESCRIPTOR_ADD_BASIC(edd3, Blah3, "string3", string, EET_T_STRING);
68
69 edd2 = eet_data_descriptor_new("blah2", sizeof(Blah2),
70 evas_list_next,
71 evas_list_append,
72 evas_list_data,
73 evas_list_free,
74 evas_hash_foreach,
75 evas_hash_add,
76 evas_hash_free);
77 EET_DATA_DESCRIPTOR_ADD_BASIC(edd2, Blah2, "string2", string, EET_T_STRING);
78
79 edd = eet_data_descriptor_new("blah", sizeof(Blah),
80 evas_list_next,
81 evas_list_append,
82 evas_list_data,
83 evas_list_free,
84 evas_hash_foreach,
85 evas_hash_add,
86 evas_hash_free);
87 EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "character", character, EET_T_CHAR);
88 EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "sixteen", sixteen, EET_T_SHORT);
89 EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "integer", integer, EET_T_INT);
90 EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "lots", lots, EET_T_LONG_LONG);
91 EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "floating", floating, EET_T_FLOAT);
92 EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "floating_lots", floating_lots, EET_T_DOUBLE);
93 EET_DATA_DESCRIPTOR_ADD_BASIC(edd, Blah, "string", string, EET_T_STRING);
94 EET_DATA_DESCRIPTOR_ADD_SUB (edd, Blah, "blah2", blah2, edd2);
95 EET_DATA_DESCRIPTOR_ADD_LIST (edd, Blah, "blah3", blah3, edd3);
96
97 blah3.string="PANTS";
98
99 blah2.string="subtype string here!";
100
101 blah.character='7';
102 blah.sixteen=0x7777;
103 blah.integer=0xc0def00d;
104 blah.lots=0xdeadbeef31337777;
105 blah.floating=3.141592654;
106 blah.floating_lots=0.777777777777777;
107 blah.string="bite me like a turnip";
108 blah.blah2 = &blah2;
109 blah.blah3 = evas_list_append(NULL, &blah3);
110 blah.blah3 = evas_list_append(blah.blah3, &blah3);
111 blah.blah3 = evas_list_append(blah.blah3, &blah3);
112 blah.blah3 = evas_list_append(blah.blah3, &blah3);
113 blah.blah3 = evas_list_append(blah.blah3, &blah3);
114 blah.blah3 = evas_list_append(blah.blah3, &blah3);
115 blah.blah3 = evas_list_append(blah.blah3, &blah3);
116
117 data = eet_data_descriptor_encode(edd, &blah, &size);
118 f = fopen("out", "wb");
119 if (f)
120 {
121 fwrite(data, size, 1, f);
122 fclose(f);
123 }
124 printf("-----DECODING\n");
125 blah_in = eet_data_descriptor_decode(edd, data, size);
126 printf("-----DECODED!\n");
127 printf("%c\n", blah_in->character);
128 printf("%x\n", (int)blah_in->sixteen);
129 printf("%x\n", blah_in->integer);
130 printf("%lx\n", blah_in->lots);
131 printf("%f\n", (double)blah_in->floating);
132 printf("%f\n", (double)blah_in->floating_lots);
133 printf("%s\n", blah_in->string);
134 printf("%p\n", blah_in->blah2);
135 printf(" %s\n", blah_in->blah2->string);
136 {
137 Evas_List *l;
138
139 for (l = blah_in->blah3; l; l = l->next)
140 {
141 Blah3 *blah3_in;
142
143 blah3_in = l->data;
144 printf("%p\n", blah3_in);
145 printf(" %s\n", blah3_in->string);
146 }
147 }
148 eet_data_descriptor_free(edd);
149 eet_data_descriptor_free(edd2);
150 eet_data_descriptor_free(edd3);
151
152 exit(0);
153}
154#endif
155
156int eet_mkdir(char *dir);
157void eet_mkdirs(char *s);
158
159void depak_file(Eet_File *ef, char *file);
160void depack(char *pak_file);
161
162void list(char *pak_file);
163
164void pak_file(Eet_File *ef, char *file, char **noz, int noz_num);
165void pak_dir(Eet_File *ef, char *dir, char **noz, int noz_num);
166void pack(char *pak_file, char **files, int count, char **noz, int noz_num);
167
168int
169eet_mkdir(char *dir)
170{
171#ifdef __MINGW32__
172 if (mkdir(dir) < 0) return 0;
173#else
174 mode_t default_mode = S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP
175 | S_IROTH | S_IXOTH;
176
177 if (mkdir(dir, default_mode) < 0) return 0;
178#endif
179
180 return 1;
181}
182
183void
184eet_mkdirs(char *s)
185{
186 char ss[PATH_MAX];
187 int i, ii;
188
189 i = 0;
190 ii = 0;
191 while (s[i])
192 {
193 ss[ii++] = s[i];
194 ss[ii] = 0;
195 if (s[i] == '/') eet_mkdir(ss);
196 i++;
197 }
198}
199
200void
201depak_file(Eet_File *ef, char *file)
202{
203 void *data;
204 int size;
205 char *last;
206
207 data = eet_read(ef, file, &size);
208 if (data)
209 {
210 FILE *f;
211 char buf[PATH_MAX];
212 int len;
213
214 strncpy(buf, file, sizeof(buf) - 1);
215 buf[sizeof(buf) - 1] = 0;
216 if (buf[0] == '/') return;
217 if (!strcmp(buf, "..")) return;
218 if (!strncmp(buf, "../", 3)) return;
219 if (strstr(buf, "/../")) return;
220 len = strlen(buf);
221 if (len >= 3)
222 {
223 if (!strcmp(&(buf[len - 3]), "/..")) return;
224 }
225 last = strrchr(buf, '/');
226 if (last)
227 {
228 last[1] = 0;
229 eet_mkdirs(buf);
230 }
231
232 f = fopen(file, "wb");
233 if (f)
234 {
235 fwrite(data, 1, size, f);
236 fclose(f);
237 printf("exported: %s\n", file);
238 }
239 else
240 printf("error exporting: %s\n", file);
241 free(data);
242 }
243 else
244 {
245 printf("error reading: %s\n", file);
246 }
247}
248
249void
250depack(char *pak_file)
251{
252 int i, num;
253 char **list;
254 Eet_File *ef;
255
256 ef = eet_open(pak_file, EET_FILE_MODE_READ);
257 if (!ef)
258 {
259 printf("cannot open for reading: %s\n", pak_file);
260 return;
261 }
262 list = eet_list(ef, "*", &num);
263 if (list)
264 {
265 for (i = 0; i < num; i++)
266 depak_file(ef, list[i]);
267 free(list);
268 }
269 eet_close(ef);
270}
271
272void
273list(char *pak_file)
274{
275 int i, num;
276 char **list;
277 Eet_File *ef;
278
279 ef = eet_open(pak_file, EET_FILE_MODE_READ);
280 if (!ef)
281 {
282 printf("cannot open for reading: %s\n", pak_file);
283 return;
284 }
285 list = eet_list(ef, "*", &num);
286 if (list)
287 {
288 for (i = 0; i < num; i++)
289 printf("%s\n",list[i]);
290 free(list);
291 }
292 eet_close(ef);
293}
294
295void
296pak_file(Eet_File *ef, char *file, char **noz, int noz_num)
297{
298 struct stat st;
299
300 if (stat(file, &st) >= 0)
301 {
302 void *buf;
303
304 buf = malloc(st.st_size);
305 if (buf)
306 {
307 FILE *f;
308
309 f = fopen(file, "rb");
310 if (f)
311 {
312 int compress = 1;
313 int i;
314
315 for (i = 0; i < noz_num; i++)
316 {
317 if (!fnmatch(noz[i], file, 0))
318 {
319 compress = 0;
320 break;
321 }
322 }
323 fread(buf, 1, st.st_size, f);
324 if (!eet_write(ef, file, buf, st.st_size, compress))
325 printf("error importing: %s\n", file);
326 else
327 {
328 if (compress)
329 printf("compress: %s\n", file);
330 else
331 printf("imported: %s\n", file);
332 }
333 fclose(f);
334 }
335 free(buf);
336 }
337 }
338}
339
340void
341pak_dir(Eet_File *ef, char *dir, char **noz, int noz_num)
342{
343 DIR *dirp;
344 struct dirent *dp;
345
346 dirp = opendir(dir);
347 if (!dirp)
348 pak_file(ef, dir, noz, noz_num);
349 else
350 {
351 while ((dp = readdir(dirp)))
352 {
353 char buf[PATH_MAX];
354
355 if ((!strcmp(".", dp->d_name)) || (!strcmp("..", dp->d_name)))
356 {
357 }
358 else
359 {
360 snprintf(buf, sizeof(buf), "%s/%s", dir, dp->d_name);
361 pak_dir(ef, buf, noz, noz_num);
362 }
363 }
364 }
365}
366
367void
368pack(char *pak_file, char **files, int count, char **noz, int noz_num)
369{
370 Eet_File *ef;
371 int i;
372
373 ef = eet_open(pak_file, EET_FILE_MODE_WRITE);
374 if (!ef)
375 {
376 printf("cannot open for writing: %s\n", pak_file);
377 return;
378 }
379 for (i = 0; i < count; i++) pak_dir(ef, files[i], noz, noz_num);
380 printf("done.\n");
381 eet_close(ef);
382}
383
384int
385main(int argc, char **argv)
386{
387 if (argc == 3)
388 {
389 if (!strcmp(argv[1], "-d"))
390 {
391 depack(argv[2]);
392 return 0;
393 }
394 else if (!strcmp(argv[1], "-l"))
395 {
396 list(argv[2]);
397 return 0;
398 }
399 }
400 else if (argc > 3)
401 {
402 char **noz = NULL;
403 int noz_num = 0;
404
405 if (!strcmp(argv[1], "-c"))
406 {
407 int i;
408
409 for (i = 3; i < argc; i++)
410 {
411 if (!strcmp(argv[i], "-nz"))
412 {
413 if (i < (argc - 1))
414 {
415 i++;
416 noz_num++;
417 noz = realloc(noz, noz_num * sizeof(char *));
418 noz[noz_num - 1] = argv[i];
419 }
420 }
421 else
422 break;
423 }
424 pack(argv[2], &(argv[i]), argc - i, noz, noz_num);
425 return 0;
426 }
427 }
428 printf("usage:\n"
429 " %s -l in_file\n"
430 " %s -d in_file\n"
431 " %s -c out_file [-nz glob [-nz glob ...]] dir_file1 [dir_file2 ...]\n"
432 "\n"
433 "where:\n"
434 " -l in_file list contents of eet file\n"
435 " -d in_file unpack eet file\n"
436 " -c out_file pack up eet file\n"
437 " -nz match don't compress files matching match glob\n"
438 "\n"
439 "example:\n"
440 " %s -c out.eet -nz \"*.jpg\" things/\n"
441 " %s -l out.eet\n"
442 " %s -d out.eet\n",
443 argv[0], argv[0], argv[0],
444 argv[0], argv[0], argv[0]);
445 return -1;
446}