aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/zip_extractor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/zip_extractor.c')
-rw-r--r--src/plugins/zip_extractor.c131
1 files changed, 66 insertions, 65 deletions
diff --git a/src/plugins/zip_extractor.c b/src/plugins/zip_extractor.c
index 717d76d..1ffa5f6 100644
--- a/src/plugins/zip_extractor.c
+++ b/src/plugins/zip_extractor.c
@@ -44,86 +44,87 @@ EXTRACTOR_zip_extract_method (struct EXTRACTOR_ExtractContext *ec)
44 if (NULL == (uf = EXTRACTOR_common_unzip_open (ec))) 44 if (NULL == (uf = EXTRACTOR_common_unzip_open (ec)))
45 return; 45 return;
46 if ( (EXTRACTOR_UNZIP_OK == 46 if ( (EXTRACTOR_UNZIP_OK ==
47 EXTRACTOR_common_unzip_go_find_local_file (uf, 47 EXTRACTOR_common_unzip_go_find_local_file (uf,
48 "meta.xml", 48 "meta.xml",
49 2)) || 49 2)) ||
50 (EXTRACTOR_UNZIP_OK == 50 (EXTRACTOR_UNZIP_OK ==
51 EXTRACTOR_common_unzip_go_find_local_file (uf, 51 EXTRACTOR_common_unzip_go_find_local_file (uf,
52 "META-INF/MANIFEST.MF", 52 "META-INF/MANIFEST.MF",
53 2)) ) 53 2)) )
54 { 54 {
55 /* not a normal zip, might be odf, jar, etc. */ 55 /* not a normal zip, might be odf, jar, etc. */
56 goto CLEANUP; 56 goto CLEANUP;
57 } 57 }
58 if (EXTRACTOR_UNZIP_OK != 58 if (EXTRACTOR_UNZIP_OK !=
59 EXTRACTOR_common_unzip_go_to_first_file (uf)) 59 EXTRACTOR_common_unzip_go_to_first_file (uf))
60 { 60 {
61 /* zip malformed? */ 61 /* zip malformed? */
62 goto CLEANUP; 62 goto CLEANUP;
63 } 63 }
64 if (0 != 64 if (0 !=
65 ec->proc (ec->cls, 65 ec->proc (ec->cls,
66 "zip", 66 "zip",
67 EXTRACTOR_METATYPE_MIMETYPE, 67 EXTRACTOR_METATYPE_MIMETYPE,
68 EXTRACTOR_METAFORMAT_UTF8, 68 EXTRACTOR_METAFORMAT_UTF8,
69 "text/plain", 69 "text/plain",
70 "application/zip", 70 "application/zip",
71 strlen ("application/zip") + 1)) 71 strlen ("application/zip") + 1))
72 goto CLEANUP; 72 goto CLEANUP;
73 if (EXTRACTOR_UNZIP_OK == 73 if (EXTRACTOR_UNZIP_OK ==
74 EXTRACTOR_common_unzip_get_global_comment (uf, 74 EXTRACTOR_common_unzip_get_global_comment (uf,
75 fcomment, 75 fcomment,
76 sizeof (fcomment))) 76 sizeof (fcomment)))
77 { 77 {
78 if ( (0 != strlen (fcomment)) && 78 if ( (0 != strlen (fcomment)) &&
79 (0 != 79 (0 !=
80 ec->proc (ec->cls, 80 ec->proc (ec->cls,
81 "zip", 81 "zip",
82 EXTRACTOR_METATYPE_COMMENT, 82 EXTRACTOR_METATYPE_COMMENT,
83 EXTRACTOR_METAFORMAT_C_STRING, 83 EXTRACTOR_METAFORMAT_C_STRING,
84 "text/plain", 84 "text/plain",
85 fcomment, 85 fcomment,
86 strlen (fcomment) + 1))) 86 strlen (fcomment) + 1)))
87 goto CLEANUP; 87 goto CLEANUP;
88 } 88 }
89 do 89 do
90 {
91 if (EXTRACTOR_UNZIP_OK ==
92 EXTRACTOR_common_unzip_get_current_file_info (uf,
93 &fi,
94 fname,
95 sizeof (fname),
96 NULL, 0,
97 fcomment,
98 sizeof (fcomment)))
90 { 99 {
91 if (EXTRACTOR_UNZIP_OK == 100 if ( (0 != strlen (fname)) &&
92 EXTRACTOR_common_unzip_get_current_file_info (uf, 101 (0 !=
93 &fi, 102 ec->proc (ec->cls,
94 fname, 103 "zip",
95 sizeof (fname), 104 EXTRACTOR_METATYPE_FILENAME,
96 NULL, 0, 105 EXTRACTOR_METAFORMAT_C_STRING,
97 fcomment, 106 "text/plain",
98 sizeof (fcomment))) 107 fname,
99 { 108 strlen (fname) + 1)))
100 if ( (0 != strlen (fname)) && 109 goto CLEANUP;
101 (0 != 110 if ( (0 != strlen (fcomment)) &&
102 ec->proc (ec->cls, 111 (0 !=
103 "zip", 112 ec->proc (ec->cls,
104 EXTRACTOR_METATYPE_FILENAME, 113 "zip",
105 EXTRACTOR_METAFORMAT_C_STRING, 114 EXTRACTOR_METATYPE_COMMENT,
106 "text/plain", 115 EXTRACTOR_METAFORMAT_C_STRING,
107 fname, 116 "text/plain",
108 strlen (fname) + 1))) 117 fcomment,
109 goto CLEANUP; 118 strlen (fcomment) + 1)))
110 if ( (0 != strlen (fcomment)) && 119 goto CLEANUP;
111 (0 !=
112 ec->proc (ec->cls,
113 "zip",
114 EXTRACTOR_METATYPE_COMMENT,
115 EXTRACTOR_METAFORMAT_C_STRING,
116 "text/plain",
117 fcomment,
118 strlen (fcomment) + 1)))
119 goto CLEANUP;
120 }
121 } 120 }
121 }
122 while (EXTRACTOR_UNZIP_OK == 122 while (EXTRACTOR_UNZIP_OK ==
123 EXTRACTOR_common_unzip_go_to_next_file (uf)); 123 EXTRACTOR_common_unzip_go_to_next_file (uf));
124 124
125CLEANUP: 125CLEANUP:
126 (void) EXTRACTOR_common_unzip_close (uf); 126 (void) EXTRACTOR_common_unzip_close (uf);
127} 127}
128 128
129
129/* end of zip_extractor.c */ 130/* end of zip_extractor.c */