aboutsummaryrefslogtreecommitdiff
path: root/src/plugins/ps_extractor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/ps_extractor.c')
-rw-r--r--src/plugins/ps_extractor.c129
1 files changed, 65 insertions, 64 deletions
diff --git a/src/plugins/ps_extractor.c b/src/plugins/ps_extractor.c
index 3a7f26d..7b61410 100644
--- a/src/plugins/ps_extractor.c
+++ b/src/plugins/ps_extractor.c
@@ -137,81 +137,82 @@ EXTRACTOR_ps_extract_method (struct EXTRACTOR_ExtractContext *ec)
137 return; 137 return;
138 if ( (strlen (line) < strlen (PS_HEADER)) || 138 if ( (strlen (line) < strlen (PS_HEADER)) ||
139 (0 != memcmp (PS_HEADER, 139 (0 != memcmp (PS_HEADER,
140 line, 140 line,
141 strlen (PS_HEADER))) ) 141 strlen (PS_HEADER))) )
142 { 142 {
143 free (line); 143 free (line);
144 return; 144 return;
145 } 145 }
146 free (line); 146 free (line);
147 if (0 != ec->proc (ec->cls, 147 if (0 != ec->proc (ec->cls,
148 "ps", 148 "ps",
149 EXTRACTOR_METATYPE_MIMETYPE, 149 EXTRACTOR_METATYPE_MIMETYPE,
150 EXTRACTOR_METAFORMAT_UTF8, 150 EXTRACTOR_METAFORMAT_UTF8,
151 "text/plain", 151 "text/plain",
152 "application/postscript", 152 "application/postscript",
153 strlen ("application/postscript") + 1)) 153 strlen ("application/postscript") + 1))
154 return; 154 return;
155 155
156 line = NULL; 156 line = NULL;
157 next = readline (ec); 157 next = readline (ec);
158 while ( (NULL != next) && 158 while ( (NULL != next) &&
159 ('%' == next[0]) ) 159 ('%' == next[0]) )
160 {
161 line = next;
162 next = readline (ec);
163 for (i = 0; NULL != tests[i].prefix; i++)
160 { 164 {
161 line = next; 165 match = tests[i].prefix;
162 next = readline (ec); 166 if ( (strlen (line) < strlen (match)) ||
163 for (i = 0; NULL != tests[i].prefix; i++) 167 (0 != strncmp (line, match, strlen (match))) )
164 { 168 continue;
165 match = tests[i].prefix; 169 /* %%+ continues previous meta-data type... */
166 if ( (strlen (line) < strlen (match)) || 170 while ( (NULL != next) &&
167 (0 != strncmp (line, match, strlen (match))) ) 171 (0 == strncmp (next, "%%+", strlen ("%%+"))) )
168 continue; 172 {
169 /* %%+ continues previous meta-data type... */ 173 if (NULL == (acc = malloc (strlen (line) + strlen (next) - 1)))
170 while ( (NULL != next) && 174 break;
171 (0 == strncmp (next, "%%+", strlen ("%%+"))) ) 175 strcpy (acc, line);
172 { 176 strcat (acc, " ");
173 if (NULL == (acc = malloc (strlen (line) + strlen (next) - 1))) 177 strcat (acc, next + 3);
174 break; 178 free (line);
175 strcpy (acc, line); 179 line = acc;
176 strcat (acc, " "); 180 free (next);
177 strcat (acc, next + 3); 181 next = readline (ec);
178 free (line); 182 }
179 line = acc; 183 if ( (line[strlen (line) - 1] == ')') &&
180 free (next); 184 (line[strlen (match)] == '(') )
181 next = readline (ec); 185 {
182 } 186 acc = &line[strlen (match) + 1];
183 if ( (line[strlen (line) - 1] == ')') && 187 acc[strlen (acc) - 1] = '\0'; /* remove ")" */
184 (line[strlen (match)] == '(') ) 188 }
185 { 189 else
186 acc = &line[strlen (match) + 1]; 190 {
187 acc[strlen (acc) - 1] = '\0'; /* remove ")" */ 191 acc = &line[strlen (match)];
188 } 192 }
189 else 193 while (isspace ((unsigned char) acc[0]))
190 { 194 acc++;
191 acc = &line[strlen (match)]; 195 if ( (strlen (acc) > 0) &&
192 } 196 (0 != ec->proc (ec->cls,
193 while (isspace ((unsigned char) acc[0])) 197 "ps",
194 acc++; 198 tests[i].type,
195 if ( (strlen (acc) > 0) && 199 EXTRACTOR_METAFORMAT_UTF8,
196 (0 != ec->proc (ec->cls, 200 "text/plain",
197 "ps", 201 acc,
198 tests[i].type, 202 strlen (acc) + 1)) )
199 EXTRACTOR_METAFORMAT_UTF8, 203 {
200 "text/plain", 204 free (line);
201 acc, 205 if (NULL != next)
202 strlen (acc) + 1)) ) 206 free (next);
203 { 207 return;
204 free (line); 208 }
205 if (NULL != next) 209 break;
206 free (next);
207 return;
208 }
209 break;
210 }
211 free (line);
212 } 210 }
211 free (line);
212 }
213 if (NULL != next) 213 if (NULL != next)
214 free (next); 214 free (next);
215} 215}
216 216
217
217/* end of ps_extractor.c */ 218/* end of ps_extractor.c */