... | ... |
@@ -2,7 +2,8 @@ |
2 | 2 |
rm -f gen_res.c gen_res.h |
3 | 3 |
cat >> gen_res.c <<'EoF' |
4 | 4 |
/* DO NOT EDIT. Automatically generated file. */ |
5 |
-typedef struct resindex { char *name; unsigned char *data; int len; } resindex; |
|
5 |
+#define ETAGSIZE 40 |
|
6 |
+typedef struct resindex { char *name; unsigned char *data; int len; char etag[ETAGSIZE+1];} resindex; |
|
6 | 7 |
EoF |
7 | 8 |
cp gen_res.c gen_res.h |
8 | 9 |
cat >> gen_res.h <<'EoF' |
... | ... |
@@ -26,7 +27,7 @@ echo "" |
26 | 27 |
echo "static resindex resindexstaticdata[]={" |
27 | 28 |
find . -type f | sed "s:^\./::g" | grep -v "^gen.sh\$\|^gen_res.c\$\|^gen_res.h\$" | while read f ; do |
28 | 29 |
name=`echo $f | tr -c "a-zA-Z0-9" "_" | sed "s/^\([0-9]\)/_\1/g"` |
29 |
- echo "{\"$f\",$name,`wc -c $f | cut -d ' ' -f 1`}," |
|
30 |
+ echo "{\"$f\",$name,`wc -c $f | cut -d ' ' -f 1`,{\"`sha1sum $f | cut -d ' ' -f 1 | tr -dc 0-9a-f`\"}}," |
|
30 | 31 |
done |
31 | 32 |
echo "{NULL,NULL,0}};" |
32 | 33 |
) >> gen_res.c |
... | ... |
@@ -13,7 +13,7 @@ cat >> gen_res.c <<'EoF' |
13 | 13 |
#include <string.h> |
14 | 14 |
EoF |
15 | 15 |
# generate the contents |
16 |
-ls -1 | grep -v "^gen.sh\$\|^gen_res.c\$\|^gen_res.h\$" | while read f ; do |
|
16 |
+find . -type f | sed "s:^\./::g" | grep -v "^gen.sh\$\|^gen_res.c\$\|^gen_res.h\$" | while read f ; do |
|
17 | 17 |
name=`echo $f | tr -c "a-zA-Z0-9" "_" | sed "s/^\([0-9]\)/_\1/g"` |
18 | 18 |
echo "static unsigned char $name[]={\"\\" >> gen_res.c |
19 | 19 |
cat $f | hexdump -v -e '"\\""x" 1/1 "%02X"' | sed "s/\(....................................................................\)/\1#@/g" | tr '#@' '\\ |
... | ... |
@@ -24,7 +24,7 @@ done |
24 | 24 |
( |
25 | 25 |
echo "" |
26 | 26 |
echo "static resindex resindexstaticdata[]={" |
27 |
-ls -1 | grep -v "^gen.sh\$\|^gen_res.c\$\|^gen_res.h\$" | while read f ; do |
|
27 |
+find . -type f | sed "s:^\./::g" | grep -v "^gen.sh\$\|^gen_res.c\$\|^gen_res.h\$" | while read f ; do |
|
28 | 28 |
name=`echo $f | tr -c "a-zA-Z0-9" "_" | sed "s/^\([0-9]\)/_\1/g"` |
29 | 29 |
echo "{\"$f\",$name,`wc -c $f | cut -d ' ' -f 1`}," |
30 | 30 |
done |
1 | 1 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,49 @@ |
1 |
+#!/bin/sh |
|
2 |
+rm -f gen_res.c gen_res.h |
|
3 |
+cat >> gen_res.c <<'EoF' |
|
4 |
+/* DO NOT EDIT. Automatically generated file. */ |
|
5 |
+typedef struct resindex { char *name; unsigned char *data; int len; } resindex; |
|
6 |
+EoF |
|
7 |
+cp gen_res.c gen_res.h |
|
8 |
+cat >> gen_res.h <<'EoF' |
|
9 |
+extern resindex *resindexdata; |
|
10 |
+resindex *res_find(resindex *index, char *name); |
|
11 |
+EoF |
|
12 |
+cat >> gen_res.c <<'EoF' |
|
13 |
+#include <string.h> |
|
14 |
+EoF |
|
15 |
+# generate the contents |
|
16 |
+ls -1 | grep -v "^gen.sh\$\|^gen_res.c\$\|^gen_res.h\$" | while read f ; do |
|
17 |
+ name=`echo $f | tr -c "a-zA-Z0-9" "_" | sed "s/^\([0-9]\)/_\1/g"` |
|
18 |
+ echo "static unsigned char $name[]={\"\\" >> gen_res.c |
|
19 |
+ cat $f | hexdump -v -e '"\\""x" 1/1 "%02X"' | sed "s/\(....................................................................\)/\1#@/g" | tr '#@' '\\ |
|
20 |
+' >> gen_res.c |
|
21 |
+ echo '"};' >> gen_res.c |
|
22 |
+done |
|
23 |
+# generate the listing |
|
24 |
+( |
|
25 |
+echo "" |
|
26 |
+echo "static resindex resindexstaticdata[]={" |
|
27 |
+ls -1 | grep -v "^gen.sh\$\|^gen_res.c\$\|^gen_res.h\$" | while read f ; do |
|
28 |
+ name=`echo $f | tr -c "a-zA-Z0-9" "_" | sed "s/^\([0-9]\)/_\1/g"` |
|
29 |
+ echo "{\"$f\",$name,`wc -c $f | cut -d ' ' -f 1`}," |
|
30 |
+done |
|
31 |
+echo "{NULL,NULL,0}};" |
|
32 |
+) >> gen_res.c |
|
33 |
+echo "resindex *resindexdata=resindexstaticdata;" >> gen_res.c |
|
34 |
+cat >>gen_res.c <<'EoF' |
|
35 |
+resindex * |
|
36 |
+res_find(resindex *index, char *name) |
|
37 |
+{ |
|
38 |
+ int i; |
|
39 |
+ if(index==NULL || name==NULL) |
|
40 |
+ return(NULL); |
|
41 |
+ for(i=0;index[i].name!=NULL;i++) { |
|
42 |
+ if(strcmp(index[i].name,name)==0) |
|
43 |
+ return(index+i); |
|
44 |
+ } |
|
45 |
+ return(NULL); |
|
46 |
+} |
|
47 |
+EoF |
|
48 |
+ |
|
49 |
+exit 0 |