aboutsummaryrefslogtreecommitdiff
path: root/src/plugins
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2005-03-20 23:56:28 +0000
committerChristian Grothoff <christian@grothoff.org>2005-03-20 23:56:28 +0000
commit1c28cb2260c09ddefde567313b8f54161bd3b969 (patch)
tree0249db41ef8e06c5ded1bda9705ffadcccdcd15c /src/plugins
parent20d2e51022f79e021a0ad27b97ac41d9543337ea (diff)
downloadlibextractor-1c28cb2260c09ddefde567313b8f54161bd3b969.tar.gz
libextractor-1c28cb2260c09ddefde567313b8f54161bd3b969.zip
removing tailing whitespace
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/asfextractor.c48
-rw-r--r--src/plugins/convert.c4
-rw-r--r--src/plugins/debextractor.c36
-rw-r--r--src/plugins/dviextractor.c16
-rw-r--r--src/plugins/elfextractor.c76
-rw-r--r--src/plugins/filenameextractor.c4
-rw-r--r--src/plugins/gifextractor.c22
-rw-r--r--src/plugins/hash/md5extractor.c12
-rw-r--r--src/plugins/hash/rmd160extractor.c8
-rw-r--r--src/plugins/hash/sha1extractor.c12
-rw-r--r--src/plugins/htmlextractor.c360
-rw-r--r--src/plugins/id3v23extractor.c12
-rw-r--r--src/plugins/id3v24extractor.c12
-rw-r--r--src/plugins/id3v2extractor.c8
-rw-r--r--src/plugins/jpegextractor.c30
-rw-r--r--src/plugins/lowerextractor.c2
-rw-r--r--src/plugins/manextractor.c28
-rw-r--r--src/plugins/mimeextractor.c28
-rw-r--r--src/plugins/mp3extractor.c188
-rw-r--r--src/plugins/mpegextractor.c24
-rw-r--r--src/plugins/oggextractor.c28
-rw-r--r--src/plugins/ole2/gsf-impl-utils.h2
-rw-r--r--src/plugins/ole2/gsf-infile-impl.h2
-rw-r--r--src/plugins/ole2/gsf-infile-msole.c10
-rw-r--r--src/plugins/ole2/gsf-infile-msole.h2
-rw-r--r--src/plugins/ole2/gsf-infile.h2
-rw-r--r--src/plugins/ole2/gsf-input-memory.c2
-rw-r--r--src/plugins/ole2/gsf-input.c10
-rw-r--r--src/plugins/ole2/gsf-msole-impl.h2
-rw-r--r--src/plugins/ole2/gsf-shared-memory.c2
-rw-r--r--src/plugins/ole2/gsf-utils.c2
-rw-r--r--src/plugins/ole2/gsf-utils.h2
-rw-r--r--src/plugins/ole2/gsf.h4
-rw-r--r--src/plugins/ole2/ole2extractor.c214
-rw-r--r--src/plugins/oo/ooextractor.c22
-rw-r--r--src/plugins/pack.c84
-rw-r--r--src/plugins/pack.h8
-rw-r--r--src/plugins/pdf/Decrypt.cc4
-rw-r--r--src/plugins/pdf/FontEncoding.cc2
-rw-r--r--src/plugins/pdf/Stream.cc6
-rw-r--r--src/plugins/pdf/gfile.cc2
-rw-r--r--src/plugins/pdf/pdfextractor.cc66
-rw-r--r--src/plugins/pngextractor.c32
-rw-r--r--src/plugins/printable/bloomfilter.c26
-rw-r--r--src/plugins/printable/bloomfilter.h4
-rw-r--r--src/plugins/printable/dictionary-builder.c26
-rw-r--r--src/plugins/printable/printableextractor.c36
-rw-r--r--src/plugins/printable/sha1.c6
-rw-r--r--src/plugins/psextractor.c38
-rw-r--r--src/plugins/qtextractor.c100
-rw-r--r--src/plugins/realextractor.c98
-rw-r--r--src/plugins/riffextractor.c30
-rw-r--r--src/plugins/rpm/rpmextractor.c82
-rw-r--r--src/plugins/splitextractor.c2
-rw-r--r--src/plugins/tarextractor.c16
-rw-r--r--src/plugins/templateextractor.c2
-rw-r--r--src/plugins/thumbnail/thumbnailextractor.c34
-rw-r--r--src/plugins/tiffextractor.c22
-rw-r--r--src/plugins/wavextractor.c38
59 files changed, 1000 insertions, 1000 deletions
diff --git a/src/plugins/asfextractor.c b/src/plugins/asfextractor.c
index 316f437..21979c0 100644
--- a/src/plugins/asfextractor.c
+++ b/src/plugins/asfextractor.c
@@ -88,7 +88,7 @@
88#define GUID_ASF_EXTENDED_CONTENT_DESCRIPTION 14 88#define GUID_ASF_EXTENDED_CONTENT_DESCRIPTION 14
89#define GUID_ASF_ERROR_CORRECTION 15 89#define GUID_ASF_ERROR_CORRECTION 15
90#define GUID_ASF_PADDING 16 90#define GUID_ASF_PADDING 16
91 91
92 /* stream properties object stream type */ 92 /* stream properties object stream type */
93#define GUID_ASF_AUDIO_MEDIA 17 93#define GUID_ASF_AUDIO_MEDIA 17
94#define GUID_ASF_VIDEO_MEDIA 18 94#define GUID_ASF_VIDEO_MEDIA 18
@@ -104,7 +104,7 @@
104 104
105 /* header extension */ 105 /* header extension */
106#define GUID_ASF_RESERVED_1 24 106#define GUID_ASF_RESERVED_1 24
107 107
108 /* script command */ 108 /* script command */
109#define GUID_ASF_RESERVED_SCRIPT_COMMNAND 25 109#define GUID_ASF_RESERVED_SCRIPT_COMMNAND 25
110 110
@@ -228,7 +228,7 @@ static const struct
228 { "mutex bitrate", 228 { "mutex bitrate",
229 { 0xd6e22a01, 0x35da, 0x11d1, { 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe }} }, 229 { 0xd6e22a01, 0x35da, 0x11d1, { 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe }} },
230 230
231 { "mutex unknown", 231 { "mutex unknown",
232 { 0xd6e22a02, 0x35da, 0x11d1, { 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe }} }, 232 { 0xd6e22a02, 0x35da, 0x11d1, { 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe }} },
233 233
234 234
@@ -289,7 +289,7 @@ typedef struct demux_asf_s {
289 ext_uint32_t packet_size; 289 ext_uint32_t packet_size;
290 ext_uint8_t packet_flags; 290 ext_uint8_t packet_flags;
291 ext_uint32_t data_size; 291 ext_uint32_t data_size;
292 292
293 ext_uint32_t bitrates[MAX_NUM_STREAMS]; 293 ext_uint32_t bitrates[MAX_NUM_STREAMS];
294 int num_streams; 294 int num_streams;
295 int num_audio_streams; 295 int num_audio_streams;
@@ -336,7 +336,7 @@ typedef struct demux_asf_s {
336 336
337 off_t header_size; 337 off_t header_size;
338 int buf_flag_seek; 338 int buf_flag_seek;
339 339
340 /* first packet position */ 340 /* first packet position */
341 int64_t first_packet_pos; 341 int64_t first_packet_pos;
342 342
@@ -347,12 +347,12 @@ static int readBuf(demux_asf_t * this,
347 void * buf, 347 void * buf,
348 int len) { 348 int len) {
349 int min; 349 int min;
350 350
351 min = len; 351 min = len;
352 if (this->inputLen - this->inputPos < min) 352 if (this->inputLen - this->inputPos < min)
353 min = this->inputLen - this->inputPos; 353 min = this->inputLen - this->inputPos;
354 memcpy(buf, 354 memcpy(buf,
355 &this->input[this->inputPos], 355 &this->input[this->inputPos],
356 min); 356 min);
357 this->inputPos += min; 357 this->inputPos += min;
358 return min; 358 return min;
@@ -363,7 +363,7 @@ static ext_uint8_t get_byte (demux_asf_t *this) {
363 int i; 363 int i;
364 364
365 i = readBuf (this, &buf, 1); 365 i = readBuf (this, &buf, 1);
366 if (i != 1) 366 if (i != 1)
367 this->status = DEMUX_FINISHED; 367 this->status = DEMUX_FINISHED;
368 return buf; 368 return buf;
369} 369}
@@ -373,7 +373,7 @@ static ext_uint16_t get_le16 (demux_asf_t *this) {
373 int i; 373 int i;
374 374
375 i = readBuf (this, buf, 2); 375 i = readBuf (this, buf, 2);
376 if (i != 2) 376 if (i != 2)
377 this->status = DEMUX_FINISHED; 377 this->status = DEMUX_FINISHED;
378 return buf[0] | (buf[1] << 8); 378 return buf[0] | (buf[1] << 8);
379} 379}
@@ -383,7 +383,7 @@ static ext_uint32_t get_le32 (demux_asf_t *this) {
383 int i; 383 int i;
384 384
385 i = readBuf (this, buf, 4); 385 i = readBuf (this, buf, 4);
386 if (i != 4) 386 if (i != 4)
387 this->status = DEMUX_FINISHED; 387 this->status = DEMUX_FINISHED;
388 return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24); 388 return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24);
389} 389}
@@ -393,9 +393,9 @@ static ext_uint64_t get_le64 (demux_asf_t *this) {
393 int i; 393 int i;
394 394
395 i = readBuf (this, buf, 8); 395 i = readBuf (this, buf, 8);
396 if (i != 8) 396 if (i != 8)
397 this->status = DEMUX_FINISHED; 397 this->status = DEMUX_FINISHED;
398 return (ext_uint64_t) buf[0] 398 return (ext_uint64_t) buf[0]
399 | ((ext_uint64_t) buf[1] << 8) 399 | ((ext_uint64_t) buf[1] << 8)
400 | ((ext_uint64_t) buf[2] << 16) 400 | ((ext_uint64_t) buf[2] << 16)
401 | ((ext_uint64_t) buf[3] << 24) 401 | ((ext_uint64_t) buf[3] << 24)
@@ -412,20 +412,20 @@ static int get_guid (demux_asf_t *this) {
412 g.v1 = get_le32(this); 412 g.v1 = get_le32(this);
413 g.v2 = get_le16(this); 413 g.v2 = get_le16(this);
414 g.v3 = get_le16(this); 414 g.v3 = get_le16(this);
415 for(i = 0; i < 8; i++) 415 for(i = 0; i < 8; i++)
416 g.v4[i] = get_byte(this); 416 g.v4[i] = get_byte(this);
417 if (this->status == DEMUX_FINISHED) 417 if (this->status == DEMUX_FINISHED)
418 return GUID_ERROR; 418 return GUID_ERROR;
419 for (i = 1; i < GUID_END; i++) 419 for (i = 1; i < GUID_END; i++)
420 if (!memcmp(&g, &guids[i].guid, sizeof(LE_GUID))) 420 if (!memcmp(&g, &guids[i].guid, sizeof(LE_GUID)))
421 return i; 421 return i;
422 422
423 return GUID_ERROR; 423 return GUID_ERROR;
424} 424}
425 425
426static void get_str16_nolen(demux_asf_t *this, 426static void get_str16_nolen(demux_asf_t *this,
427 int len, 427 int len,
428 char *buf, 428 char *buf,
429 int buf_size) { 429 int buf_size) {
430 430
431 int c; 431 int c;
@@ -446,8 +446,8 @@ static int asf_read_header(demux_asf_t *this) {
446 ext_uint64_t gsize; 446 ext_uint64_t gsize;
447 447
448 guid = get_guid(this); 448 guid = get_guid(this);
449 if (guid != GUID_ASF_HEADER) 449 if (guid != GUID_ASF_HEADER)
450 return 0; 450 return 0;
451 get_le64(this); 451 get_le64(this);
452 get_le32(this); 452 get_le32(this);
453 get_byte(this); 453 get_byte(this);
@@ -617,7 +617,7 @@ static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordType type,
617 if (keyword == NULL) 617 if (keyword == NULL)
618 return next; 618 return next;
619 result = malloc(sizeof(EXTRACTOR_KeywordList)); 619 result = malloc(sizeof(EXTRACTOR_KeywordList));
620 result->next = next; 620 result->next = next;
621 result->keyword = strdup(keyword); 621 result->keyword = strdup(keyword);
622 result->keywordType = type; 622 result->keywordType = type;
623 return result; 623 return result;
@@ -650,7 +650,7 @@ struct EXTRACTOR_Keywords * libextractor_asf_extract(char * filename,
650 free(this); 650 free(this);
651 return prev; 651 return prev;
652 } 652 }
653 653
654 if (strlen(this->title) > 0) 654 if (strlen(this->title) > 0)
655 prev = addKeyword(EXTRACTOR_TITLE, this->title, prev); 655 prev = addKeyword(EXTRACTOR_TITLE, this->title, prev);
656 if (strlen(this->author) > 0) 656 if (strlen(this->author) > 0)
@@ -663,7 +663,7 @@ struct EXTRACTOR_Keywords * libextractor_asf_extract(char * filename,
663 663
664 /* build a description from author and title */ 664 /* build a description from author and title */
665 if (strlen(this->author) * strlen(this->title) > 0) { 665 if (strlen(this->author) * strlen(this->title) > 0) {
666 EXTRACTOR_KeywordList * keyword = malloc(sizeof(EXTRACTOR_KeywordList)); 666 EXTRACTOR_KeywordList * keyword = malloc(sizeof(EXTRACTOR_KeywordList));
667 char * word; 667 char * word;
668 int len = 3 + strlen(this->author) + strlen(this->title); 668 int len = 3 + strlen(this->author) + strlen(this->title);
669 669
diff --git a/src/plugins/convert.c b/src/plugins/convert.c
index 5a788f9..d0cea19 100644
--- a/src/plugins/convert.c
+++ b/src/plugins/convert.c
@@ -40,7 +40,7 @@ char * convertToUtf8(const char * input,
40 char * itmp; 40 char * itmp;
41 const char * i; 41 const char * i;
42 iconv_t cd; 42 iconv_t cd;
43 43
44 i = input; 44 i = input;
45 cd = iconv_open("UTF-8", charset); 45 cd = iconv_open("UTF-8", charset);
46 if (cd == (iconv_t) -1) 46 if (cd == (iconv_t) -1)
@@ -52,7 +52,7 @@ char * convertToUtf8(const char * input,
52 if (iconv(cd, 52 if (iconv(cd,
53 (char**) &input, 53 (char**) &input,
54 &len, 54 &len,
55 &itmp, 55 &itmp,
56 &finSize) == (size_t)-1) { 56 &finSize) == (size_t)-1) {
57 iconv_close(cd); 57 iconv_close(cd);
58 free(tmp); 58 free(tmp);
diff --git a/src/plugins/debextractor.c b/src/plugins/debextractor.c
index c1f48e5..3eacc87 100644
--- a/src/plugins/debextractor.c
+++ b/src/plugins/debextractor.c
@@ -43,7 +43,7 @@ static EXTRACTOR_KeywordList * addKeyword(EXTRACTOR_KeywordType type,
43 if (keyword == NULL) 43 if (keyword == NULL)
44 return next; 44 return next;
45 result = malloc(sizeof(EXTRACTOR_KeywordList)); 45 result = malloc(sizeof(EXTRACTOR_KeywordList));
46 result->next = next; 46 result->next = next;
47 result->keyword = keyword; 47 result->keyword = keyword;
48 result->keywordType = type; 48 result->keywordType = type;
49 return result; 49 return result;
@@ -67,7 +67,7 @@ typedef struct {
67 67
68/* see also: "man 5 deb-control" */ 68/* see also: "man 5 deb-control" */
69static Matches tmap[] = { 69static Matches tmap[] = {
70 { "Package: ", EXTRACTOR_SOFTWARE }, 70 { "Package: ", EXTRACTOR_SOFTWARE },
71 { "Version: ", EXTRACTOR_VERSIONNUMBER }, 71 { "Version: ", EXTRACTOR_VERSIONNUMBER },
72 { "Section: ", EXTRACTOR_GENRE }, 72 { "Section: ", EXTRACTOR_GENRE },
73 { "Priority: ", EXTRACTOR_PRIORITY }, 73 { "Priority: ", EXTRACTOR_PRIORITY },
@@ -75,7 +75,7 @@ static Matches tmap[] = {
75 { "Depends: ", EXTRACTOR_DEPENDENCY }, 75 { "Depends: ", EXTRACTOR_DEPENDENCY },
76 { "Recommends: ", EXTRACTOR_RELATION }, 76 { "Recommends: ", EXTRACTOR_RELATION },
77 { "Suggests: ", EXTRACTOR_RELATION }, 77 { "Suggests: ", EXTRACTOR_RELATION },
78 { "Installed-Size: ", EXTRACTOR_SIZE }, 78 { "Installed-Size: ", EXTRACTOR_SIZE },
79 { "Maintainer: ", EXTRACTOR_PACKAGER }, 79 { "Maintainer: ", EXTRACTOR_PACKAGER },
80 { "Description: ", EXTRACTOR_DESCRIPTION }, 80 { "Description: ", EXTRACTOR_DESCRIPTION },
81 { "Source: ", EXTRACTOR_SOURCE }, 81 { "Source: ", EXTRACTOR_SOURCE },
@@ -118,7 +118,7 @@ static struct EXTRACTOR_Keywords * processControl(const char * data,
118 (data[eol] != '\n') || 118 (data[eol] != '\n') ||
119 ( (eol+1 < size) && 119 ( (eol+1 < size) &&
120 (data[eol+1] == ' ') ) ) 120 (data[eol+1] == ' ') ) )
121 eol++; 121 eol++;
122 if ( (eol == colon) || (eol > size) ) 122 if ( (eol == colon) || (eol > size) )
123 return prev; 123 return prev;
124 key = stndup(&data[pos], colon-pos); 124 key = stndup(&data[pos], colon-pos);
@@ -168,7 +168,7 @@ typedef struct {
168/** 168/**
169 * Process the control.tar file. 169 * Process the control.tar file.
170 */ 170 */
171static struct EXTRACTOR_Keywords * 171static struct EXTRACTOR_Keywords *
172processControlTar(const char * data, 172processControlTar(const char * data,
173 const size_t size, 173 const size_t size,
174 struct EXTRACTOR_Keywords * prev) { 174 struct EXTRACTOR_Keywords * prev) {
@@ -186,23 +186,23 @@ processControlTar(const char * data,
186 ustar = (USTarHeader*) &data[pos]; 186 ustar = (USTarHeader*) &data[pos];
187 if (0 == strncmp("ustar", 187 if (0 == strncmp("ustar",
188 &ustar->magic[0], 188 &ustar->magic[0],
189 strlen("ustar"))) 189 strlen("ustar")))
190 pos += 512; /* sizeof(USTarHeader); */ 190 pos += 512; /* sizeof(USTarHeader); */
191 else 191 else
192 pos += 257; /* sizeof(TarHeader); minus gcc alignment... */ 192 pos += 257; /* sizeof(TarHeader); minus gcc alignment... */
193 } else { 193 } else {
194 pos += 257; /* sizeof(TarHeader); minus gcc alignment... */ 194 pos += 257; /* sizeof(TarHeader); minus gcc alignment... */
195 } 195 }
196 196
197 memcpy(buf, &tar->filesize[0], 12); 197 memcpy(buf, &tar->filesize[0], 12);
198 buf[12] = '\0'; 198 buf[12] = '\0';
199 if (1 != sscanf(buf, "%12llo", &fsize)) /* octal! Yuck yuck! */ 199 if (1 != sscanf(buf, "%12llo", &fsize)) /* octal! Yuck yuck! */
200 return prev; 200 return prev;
201 if ( (pos + fsize > size) || 201 if ( (pos + fsize > size) ||
202 (fsize > size) || 202 (fsize > size) ||
203 (pos + fsize < pos) ) 203 (pos + fsize < pos) )
204 return prev; 204 return prev;
205 205
206 if (0 == strncmp(&tar->name[0], 206 if (0 == strncmp(&tar->name[0],
207 "./control", 207 "./control",
208 strlen("./control"))) { 208 strlen("./control"))) {
@@ -251,7 +251,7 @@ void * writeThread(void * arg) {
251/** 251/**
252 * Process the control.tar.gz file. 252 * Process the control.tar.gz file.
253 */ 253 */
254static struct EXTRACTOR_Keywords * 254static struct EXTRACTOR_Keywords *
255processControlTGZ(const unsigned char * data, 255processControlTGZ(const unsigned char * data,
256 size_t size, 256 size_t size,
257 struct EXTRACTOR_Keywords * prev) { 257 struct EXTRACTOR_Keywords * prev) {
@@ -286,7 +286,7 @@ processControlTGZ(const unsigned char * data,
286 pthread_join(pt, &error); 286 pthread_join(pt, &error);
287 return prev; 287 return prev;
288 } 288 }
289 buf = malloc(bufSize); 289 buf = malloc(bufSize);
290 if (buf == NULL) { 290 if (buf == NULL) {
291 gzclose(gzf); 291 gzclose(gzf);
292 close(fdes[1]); 292 close(fdes[1]);
@@ -302,11 +302,11 @@ processControlTGZ(const unsigned char * data,
302 } 302 }
303 close(fdes[1]); 303 close(fdes[1]);
304 pthread_join(pt, &error); 304 pthread_join(pt, &error);
305 gzclose(gzf); 305 gzclose(gzf);
306 prev = processControlTar(buf, 306 prev = processControlTar(buf,
307 bufSize, 307 bufSize,
308 prev); 308 prev);
309 free(buf); 309 free(buf);
310 return prev; 310 return prev;
311} 311}
312 312
@@ -319,8 +319,8 @@ typedef struct {
319 char filesize[10]; 319 char filesize[10];
320 char trailer[2]; 320 char trailer[2];
321} ObjectHeader; 321} ObjectHeader;
322 322
323struct EXTRACTOR_Keywords * 323struct EXTRACTOR_Keywords *
324libextractor_deb_extract(const char * filename, 324libextractor_deb_extract(const char * filename,
325 const char * data, 325 const char * data,
326 const size_t size, 326 const size_t size,
@@ -347,7 +347,7 @@ libextractor_deb_extract(const char * filename,
347 return prev; 347 return prev;
348 348
349 memcpy(buf, &hdr->filesize[0], 10); 349 memcpy(buf, &hdr->filesize[0], 10);
350 buf[10] = '\0'; 350 buf[10] = '\0';
351 if (1 != sscanf(buf, "%10llu", &fsize)) 351 if (1 != sscanf(buf, "%10llu", &fsize))
352 return prev; 352 return prev;
353 pos += sizeof(ObjectHeader); 353 pos += sizeof(ObjectHeader);
@@ -357,7 +357,7 @@ libextractor_deb_extract(const char * filename,
357 return prev; 357 return prev;
358 if (0 == strncmp(&hdr->name[0], 358 if (0 == strncmp(&hdr->name[0],
359 "control.tar.gz", 359 "control.tar.gz",
360 strlen("control.tar.gz"))) { 360 strlen("control.tar.gz"))) {
361 prev = processControlTGZ(&data[pos], 361 prev = processControlTGZ(&data[pos],
362 fsize, 362 fsize,
363 prev); 363 prev);
@@ -374,7 +374,7 @@ libextractor_deb_extract(const char * filename,
374 pos += fsize; 374 pos += fsize;
375 if (done == 2) 375 if (done == 2)
376 break; /* no need to process the rest of the archive */ 376 break; /* no need to process the rest of the archive */
377 } 377 }
378 return prev; 378 return prev;
379} 379}
380 380
diff --git a/src/plugins/dviextractor.c b/src/plugins/dviextractor.c
index 1d46e0e..badb5a9 100644
--- a/src/plugins/dviextractor.c
+++ b/src/plugins/dviextractor.c
@@ -29,7 +29,7 @@ static EXTRACTOR_KeywordList * addKeyword(EXTRACTOR_KeywordType type,
29 if (keyword == NULL) 29 if (keyword == NULL)
30 return next; 30 return next;
31 result = malloc(sizeof(EXTRACTOR_KeywordList)); 31 result = malloc(sizeof(EXTRACTOR_KeywordList));
32 result->next = next; 32 result->next = next;
33 result->keyword = keyword; 33 result->keyword = keyword;
34 result->keywordType = type; 34 result->keywordType = type;
35 return result; 35 return result;
@@ -88,7 +88,7 @@ static struct EXTRACTOR_Keywords * parseZZZ(unsigned char * data,
88 slen); 88 slen);
89 prev = addKeyword(tmap[i].type, 89 prev = addKeyword(tmap[i].type,
90 value, 90 value,
91 prev); 91 prev);
92 pos += slen + 1; 92 pos += slen + 1;
93 } 93 }
94 } 94 }
@@ -129,7 +129,7 @@ struct EXTRACTOR_Keywords * libextractor_dvi_extract(const char * filename,
129 return prev; 129 return prev;
130 if ( (data[0] != 247) || (data[1] != 2) ) 130 if ( (data[0] != 247) || (data[1] != 2) )
131 return prev; /* cannot be dvi or unsupported version */ 131 return prev; /* cannot be dvi or unsupported version */
132 klen = data[14]; 132 klen = data[14];
133 133
134 pos = size-1; 134 pos = size-1;
135 while ( (data[pos] == 223) && (pos > 0) ) 135 while ( (data[pos] == 223) && (pos > 0) )
@@ -140,10 +140,10 @@ struct EXTRACTOR_Keywords * libextractor_dvi_extract(const char * filename,
140 pos -= 4; 140 pos -= 4;
141 /* assert pos at 'post_post tag' */ 141 /* assert pos at 'post_post tag' */
142 if (data[pos] != 249) 142 if (data[pos] != 249)
143 return prev; 143 return prev;
144 opos = pos; 144 opos = pos;
145 pos = ntohl(getIntAt(&data[opos+1])); 145 pos = ntohl(getIntAt(&data[opos+1]));
146 if (pos+25 > size) 146 if (pos+25 > size)
147 return prev; 147 return prev;
148 /* assert pos at 'post' command */ 148 /* assert pos at 'post' command */
149 if (data[pos] != 248) 149 if (data[pos] != 248)
@@ -168,7 +168,7 @@ struct EXTRACTOR_Keywords * libextractor_dvi_extract(const char * filename,
168 } 168 }
169 /* ok, now we believe it's a dvi... */ 169 /* ok, now we believe it's a dvi... */
170 pages = malloc(16); 170 pages = malloc(16);
171 snprintf(pages, 171 snprintf(pages,
172 16, 172 16,
173 "%u", 173 "%u",
174 pageCount); 174 pageCount);
@@ -176,7 +176,7 @@ struct EXTRACTOR_Keywords * libextractor_dvi_extract(const char * filename,
176 comment[klen] = '\0'; 176 comment[klen] = '\0';
177 memcpy(comment, 177 memcpy(comment,
178 &data[15], 178 &data[15],
179 klen); 179 klen);
180 prev = addKeyword(EXTRACTOR_MIMETYPE, 180 prev = addKeyword(EXTRACTOR_MIMETYPE,
181 strdup("application/x-dvi"), 181 strdup("application/x-dvi"),
182 prev); 182 prev);
@@ -220,7 +220,7 @@ struct EXTRACTOR_Keywords * libextractor_dvi_extract(const char * filename,
220 len, 220 len,
221 prev); 221 prev);
222 pos += len+4; 222 pos += len+4;
223 break; 223 break;
224 case 242: /* zzz4, hurray! */ 224 case 242: /* zzz4, hurray! */
225 len = ntohl(getIntAt(&data[pos+1])); 225 len = ntohl(getIntAt(&data[pos+1]));
226 if (pos + 1 + len < size) 226 if (pos + 1 + len < size)
diff --git a/src/plugins/elfextractor.c b/src/plugins/elfextractor.c
index b117b07..62afcac 100644
--- a/src/plugins/elfextractor.c
+++ b/src/plugins/elfextractor.c
@@ -26,7 +26,7 @@ static void addKeyword(struct EXTRACTOR_Keywords ** list,
26 EXTRACTOR_KeywordType type) { 26 EXTRACTOR_KeywordType type) {
27 EXTRACTOR_KeywordList * next; 27 EXTRACTOR_KeywordList * next;
28 next = malloc(sizeof(EXTRACTOR_KeywordList)); 28 next = malloc(sizeof(EXTRACTOR_KeywordList));
29 next->next = *list; 29 next->next = *list;
30 next->keyword = strdup(keyword); 30 next->keyword = strdup(keyword);
31 next->keywordType = type; 31 next->keywordType = type;
32 *list = next; 32 *list = next;
@@ -79,16 +79,16 @@ typedef struct {
79 &(p)->e_phnum, \ 79 &(p)->e_phnum, \
80 &(p)->e_shentsize, \ 80 &(p)->e_shentsize, \
81 &(p)->e_shnum, \ 81 &(p)->e_shnum, \
82 &(p)->e_shstrndx 82 &(p)->e_shstrndx
83static char * ELF_HEADER_SPECS[] = { 83static char * ELF_HEADER_SPECS[] = {
84 "hhwwwwwhhhhhh", 84 "hhwwwwwhhhhhh",
85 "HHWWWWWHHHHHH", 85 "HHWWWWWHHHHHH",
86}; 86};
87 87
88 88
89typedef struct { 89typedef struct {
90 Elf32_Word sh_name; 90 Elf32_Word sh_name;
91 Elf32_Word sh_type; 91 Elf32_Word sh_type;
92 Elf32_Word sh_flags; 92 Elf32_Word sh_flags;
93 Elf32_Addr sh_addr; /* where loaded */ 93 Elf32_Addr sh_addr; /* where loaded */
94 Elf32_Off sh_offset; /* where in image (! sh_type==SHT_NOBITS) */ 94 Elf32_Off sh_offset; /* where in image (! sh_type==SHT_NOBITS) */
@@ -188,7 +188,7 @@ static char * ELF_DYN_SPECS[] = {
188#define SHT_NOTE 7 188#define SHT_NOTE 7
189#define SHT_NOBITS 8 189#define SHT_NOBITS 8
190#define SHT_REL 9 190#define SHT_REL 9
191#define SHT_SHLIB 10 191#define SHT_SHLIB 10
192#define SHT_DYNSYM 11 192#define SHT_DYNSYM 11
193#define SHT_LOPROC 0x70000000 193#define SHT_LOPROC 0x70000000
194#define SHT_HIPROC 0x7fffffff 194#define SHT_HIPROC 0x7fffffff
@@ -253,35 +253,35 @@ static char * ELF_DYN_SPECS[] = {
253/** 253/**
254 * @param ei_data ELFDATA2LSB or ELFDATA2MSB 254 * @param ei_data ELFDATA2LSB or ELFDATA2MSB
255 * @return 1 if we need to convert, 0 if not 255 * @return 1 if we need to convert, 0 if not
256 */ 256 */
257static int getByteorder(char ei_data) { 257static int getByteorder(char ei_data) {
258 if (ei_data == ELFDATA2LSB) { 258 if (ei_data == ELFDATA2LSB) {
259#if __BYTE_ORDER == __BIG_ENDIAN 259#if __BYTE_ORDER == __BIG_ENDIAN
260 return 1; 260 return 1;
261#else 261#else
262 return 0; 262 return 0;
263#endif 263#endif
264 } else { 264 } else {
265#if __BYTE_ORDER == __BIG_ENDIAN 265#if __BYTE_ORDER == __BIG_ENDIAN
266 return 0; 266 return 0;
267#else 267#else
268 return 1; 268 return 1;
269#endif 269#endif
270 } 270 }
271} 271}
272 272
273/** 273/**
274 * 274 *
275 * @return 0 on success, -1 on error 275 * @return 0 on success, -1 on error
276 */ 276 */
277static int getSectionHdr(char * data, 277static int getSectionHdr(char * data,
278 size_t size, 278 size_t size,
279 Elf32_Ehdr * ehdr, 279 Elf32_Ehdr * ehdr,
280 Elf32_Half idx, 280 Elf32_Half idx,
281 Elf32_Shdr * ret) { 281 Elf32_Shdr * ret) {
282 if (ehdr->e_shnum <= idx) 282 if (ehdr->e_shnum <= idx)
283 return -1; 283 return -1;
284 284
285 cat_unpack(&data[ehdr->e_shoff + ehdr->e_shentsize * idx], 285 cat_unpack(&data[ehdr->e_shoff + ehdr->e_shentsize * idx],
286 ELF_SECTION_SPECS[getByteorder(data[EI_CLASS])], 286 ELF_SECTION_SPECS[getByteorder(data[EI_CLASS])],
287 ELF_SECTION_FIELDS(ret)); 287 ELF_SECTION_FIELDS(ret));
@@ -289,19 +289,19 @@ static int getSectionHdr(char * data,
289} 289}
290 290
291/** 291/**
292 * 292 *
293 * @return 0 on success, -1 on error 293 * @return 0 on success, -1 on error
294 */ 294 */
295static int getDynTag(char * data, 295static int getDynTag(char * data,
296 size_t size, 296 size_t size,
297 Elf32_Ehdr * ehdr, 297 Elf32_Ehdr * ehdr,
298 Elf32_Off off, 298 Elf32_Off off,
299 Elf32_Word osize, 299 Elf32_Word osize,
300 unsigned int idx, 300 unsigned int idx,
301 Elf32_Dyn * ret) { 301 Elf32_Dyn * ret) {
302 if ( (off+osize > size) || 302 if ( (off+osize > size) ||
303 ((idx+1) * ELF_DYN_SIZE > osize) ) 303 ((idx+1) * ELF_DYN_SIZE > osize) )
304 return -1; 304 return -1;
305 cat_unpack(&data[off + idx*ELF_DYN_SIZE], 305 cat_unpack(&data[off + idx*ELF_DYN_SIZE],
306 ELF_DYN_SPECS[getByteorder(data[EI_CLASS])], 306 ELF_DYN_SPECS[getByteorder(data[EI_CLASS])],
307 ELF_DYN_FIELDS(ret)); 307 ELF_DYN_FIELDS(ret));
@@ -309,17 +309,17 @@ static int getDynTag(char * data,
309} 309}
310 310
311/** 311/**
312 * 312 *
313 * @return 0 on success, -1 on error 313 * @return 0 on success, -1 on error
314 */ 314 */
315static int getProgramHdr(char * data, 315static int getProgramHdr(char * data,
316 size_t size, 316 size_t size,
317 Elf32_Ehdr * ehdr, 317 Elf32_Ehdr * ehdr,
318 Elf32_Half idx, 318 Elf32_Half idx,
319 Elf32_Phdr * ret) { 319 Elf32_Phdr * ret) {
320 if (ehdr->e_phnum <= idx) 320 if (ehdr->e_phnum <= idx)
321 return -1; 321 return -1;
322 322
323 cat_unpack(&data[ehdr->e_phoff + ehdr->e_phensize * idx], 323 cat_unpack(&data[ehdr->e_phoff + ehdr->e_phensize * idx],
324 ELF_PHDR_SPECS[getByteorder(data[EI_CLASS])], 324 ELF_PHDR_SPECS[getByteorder(data[EI_CLASS])],
325 ELF_PHDR_FIELDS(ret)); 325 ELF_PHDR_FIELDS(ret));
@@ -340,7 +340,7 @@ static int getELFHdr(char * data,
340 elfMagic, 340 elfMagic,
341 sizeof(elfMagic))) 341 sizeof(elfMagic)))
342 return -1; /* not an elf */ 342 return -1; /* not an elf */
343 343
344 switch (data[EI_CLASS]) { 344 switch (data[EI_CLASS]) {
345 case ELFDATA2LSB: 345 case ELFDATA2LSB:
346 case ELFDATA2MSB: 346 case ELFDATA2MSB:
@@ -366,7 +366,7 @@ static int getELFHdr(char * data,
366 */ 366 */
367static const char * readStringTable(char * data, 367static const char * readStringTable(char * data,
368 size_t size, 368 size_t size,
369 Elf32_Ehdr * ehdr, 369 Elf32_Ehdr * ehdr,
370 Elf32_Half strTableOffset, 370 Elf32_Half strTableOffset,
371 Elf32_Word sh_name) { 371 Elf32_Word sh_name) {
372 Elf32_Shdr shrd; 372 Elf32_Shdr shrd;
@@ -389,7 +389,7 @@ static const char * readStringTable(char * data,
389/* application/x-executable, ELF */ 389/* application/x-executable, ELF */
390struct EXTRACTOR_Keywords * libextractor_elf_extract(char * filename, 390struct EXTRACTOR_Keywords * libextractor_elf_extract(char * filename,
391 char * data, 391 char * data,
392 size_t size, 392 size_t size,
393 struct EXTRACTOR_Keywords * prev) { 393 struct EXTRACTOR_Keywords * prev) {
394 Elf32_Ehdr ehdr; 394 Elf32_Ehdr ehdr;
395 Elf32_Half idx; 395 Elf32_Half idx;
@@ -400,24 +400,24 @@ struct EXTRACTOR_Keywords * libextractor_elf_extract(char * filename,
400 return prev; 400 return prev;
401 addKeyword(&prev, 401 addKeyword(&prev,
402 "application/x-executable", 402 "application/x-executable",
403 EXTRACTOR_MIMETYPE); 403 EXTRACTOR_MIMETYPE);
404 switch (ehdr.e_type) { 404 switch (ehdr.e_type) {
405 case ET_REL: 405 case ET_REL:
406 addKeyword(&prev, 406 addKeyword(&prev,
407 "Relocatable file", 407 "Relocatable file",
408 EXTRACTOR_RESOURCE_TYPE); 408 EXTRACTOR_RESOURCE_TYPE);
409 break; 409 break;
410 case ET_EXEC: 410 case ET_EXEC:
411 addKeyword(&prev, 411 addKeyword(&prev,
412 "Executable file", 412 "Executable file",
413 EXTRACTOR_RESOURCE_TYPE); 413 EXTRACTOR_RESOURCE_TYPE);
414 break; 414 break;
415 case ET_DYN: 415 case ET_DYN:
416 addKeyword(&prev, 416 addKeyword(&prev,
417 "Shared object file", 417 "Shared object file",
418 EXTRACTOR_RESOURCE_TYPE); 418 EXTRACTOR_RESOURCE_TYPE);
419 break; 419 break;
420 case ET_CORE: 420 case ET_CORE:
421 addKeyword(&prev, 421 addKeyword(&prev,
422 "Core file", 422 "Core file",
423 EXTRACTOR_RESOURCE_TYPE); 423 EXTRACTOR_RESOURCE_TYPE);
@@ -429,37 +429,37 @@ struct EXTRACTOR_Keywords * libextractor_elf_extract(char * filename,
429 case EM_M32: 429 case EM_M32:
430 addKeyword(&prev, 430 addKeyword(&prev,
431 "M32", 431 "M32",
432 EXTRACTOR_CREATED_FOR); 432 EXTRACTOR_CREATED_FOR);
433 break; 433 break;
434 case EM_386: 434 case EM_386:
435 addKeyword(&prev, 435 addKeyword(&prev,
436 "i386", 436 "i386",
437 EXTRACTOR_CREATED_FOR); 437 EXTRACTOR_CREATED_FOR);
438 break; 438 break;
439 case EM_68K: 439 case EM_68K:
440 addKeyword(&prev, 440 addKeyword(&prev,
441 "68K", 441 "68K",
442 EXTRACTOR_CREATED_FOR); 442 EXTRACTOR_CREATED_FOR);
443 break; 443 break;
444 case EM_88K: 444 case EM_88K:
445 addKeyword(&prev, 445 addKeyword(&prev,
446 "88K", 446 "88K",
447 EXTRACTOR_CREATED_FOR); 447 EXTRACTOR_CREATED_FOR);
448 break; 448 break;
449 case EM_SPARC: 449 case EM_SPARC:
450 addKeyword(&prev, 450 addKeyword(&prev,
451 "Sparc", 451 "Sparc",
452 EXTRACTOR_CREATED_FOR); 452 EXTRACTOR_CREATED_FOR);
453 break; 453 break;
454 case EM_860: 454 case EM_860:
455 addKeyword(&prev, 455 addKeyword(&prev,
456 "960", 456 "960",
457 EXTRACTOR_CREATED_FOR); 457 EXTRACTOR_CREATED_FOR);
458 break; 458 break;
459 case EM_MIPS: 459 case EM_MIPS:
460 addKeyword(&prev, 460 addKeyword(&prev,
461 "MIPS", 461 "MIPS",
462 EXTRACTOR_CREATED_FOR); 462 EXTRACTOR_CREATED_FOR);
463 break; 463 break;
464 default: 464 default:
465 break; /* oops */ 465 break; /* oops */
@@ -480,7 +480,7 @@ struct EXTRACTOR_Keywords * libextractor_elf_extract(char * filename,
480 Elf32_Addr stringPtr; 480 Elf32_Addr stringPtr;
481 Elf32_Half stringIdx; 481 Elf32_Half stringIdx;
482 Elf32_Half six; 482 Elf32_Half six;
483 483
484 stringPtr = 0; 484 stringPtr = 0;
485 485
486 for (id=0;id<dc;id++) { 486 for (id=0;id<dc;id++) {
@@ -491,7 +491,7 @@ struct EXTRACTOR_Keywords * libextractor_elf_extract(char * filename,
491 phdr.p_offset, 491 phdr.p_offset,
492 phdr.p_filesz, 492 phdr.p_filesz,
493 id, 493 id,
494 &dyn)) 494 &dyn))
495 return prev; 495 return prev;
496 if (DT_STRTAB == dyn.d_tag) { 496 if (DT_STRTAB == dyn.d_tag) {
497 stringPtr = dyn.d_un.d_ptr; 497 stringPtr = dyn.d_un.d_ptr;
@@ -523,7 +523,7 @@ struct EXTRACTOR_Keywords * libextractor_elf_extract(char * filename,
523 phdr.p_offset, 523 phdr.p_offset,
524 phdr.p_filesz, 524 phdr.p_filesz,
525 id, 525 id,
526 &dyn)) 526 &dyn))
527 return prev; 527 return prev;
528 switch(dyn.d_tag) { 528 switch(dyn.d_tag) {
529 case DT_RPATH: { 529 case DT_RPATH: {
@@ -542,7 +542,7 @@ struct EXTRACTOR_Keywords * libextractor_elf_extract(char * filename,
542 EXTRACTOR_SOURCE); 542 EXTRACTOR_SOURCE);
543 } 543 }
544 break; 544 break;
545 } 545 }
546 case DT_NEEDED: { 546 case DT_NEEDED: {
547 const char * needed; 547 const char * needed;
548 548
@@ -557,9 +557,9 @@ struct EXTRACTOR_Keywords * libextractor_elf_extract(char * filename,
557 EXTRACTOR_DEPENDENCY); 557 EXTRACTOR_DEPENDENCY);
558 } 558 }
559 break; 559 break;
560 }
561 } 560 }
562 } 561 }
562 }
563 563
564 } 564 }
565 } 565 }
diff --git a/src/plugins/filenameextractor.c b/src/plugins/filenameextractor.c
index d9cdf6c..0065e61 100644
--- a/src/plugins/filenameextractor.c
+++ b/src/plugins/filenameextractor.c
@@ -32,13 +32,13 @@ struct EXTRACTOR_Keywords * libextractor_filename_extract(const char * filename,
32 const char * filenameRoot = filename; 32 const char * filenameRoot = filename;
33 int res; 33 int res;
34 34
35 for (res=strlen(filename)-1;res>=0;res--) 35 for (res=strlen(filename)-1;res>=0;res--)
36 if (filename[res] == DIR_SEPARATOR) { 36 if (filename[res] == DIR_SEPARATOR) {
37 filenameRoot = &filename[res+1]; 37 filenameRoot = &filename[res+1];
38 break; 38 break;
39 } 39 }
40 keyword = malloc(sizeof(EXTRACTOR_KeywordList)); 40 keyword = malloc(sizeof(EXTRACTOR_KeywordList));
41 keyword->next = prev; 41 keyword->next = prev;
42 keyword->keyword = convertToUtf8(filenameRoot, 42 keyword->keyword = convertToUtf8(filenameRoot,
43 strlen(filenameRoot), 43 strlen(filenameRoot),
44 nl_langinfo(CODESET) 44 nl_langinfo(CODESET)
diff --git a/src/plugins/gifextractor.c b/src/plugins/gifextractor.c
index eedd88c..c6ec1af 100644
--- a/src/plugins/gifextractor.c
+++ b/src/plugins/gifextractor.c
@@ -26,7 +26,7 @@
26#if DEBUG_GIF 26#if DEBUG_GIF
27#define PRINT(a,b) fprintf(stderr,a,b) 27#define PRINT(a,b) fprintf(stderr,a,b)
28#else 28#else
29#define PRINT(a,b) 29#define PRINT(a,b)
30#endif 30#endif
31 31
32typedef struct { 32typedef struct {
@@ -90,7 +90,7 @@ static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordType type,
90 if (keyword == NULL) 90 if (keyword == NULL)
91 return next; 91 return next;
92 result = malloc(sizeof(EXTRACTOR_KeywordList)); 92 result = malloc(sizeof(EXTRACTOR_KeywordList));
93 result->next = next; 93 result->next = next;
94 result->keyword = keyword; 94 result->keyword = keyword;
95 result->keywordType = type; 95 result->keywordType = type;
96 return result; 96 return result;
@@ -127,7 +127,7 @@ static size_t skipGlobalColorMap(const unsigned char * data,
127 const size_t size, 127 const size_t size,
128 const GIF_HEADER * header) { 128 const GIF_HEADER * header) {
129 size_t gct_size; 129 size_t gct_size;
130 130
131 if ( (header->flags & HEADER_FLAGS__GLOBAL_COLOR_TABLE_FLAG) > 0) 131 if ( (header->flags & HEADER_FLAGS__GLOBAL_COLOR_TABLE_FLAG) > 0)
132 gct_size = 3*(1 << ((header->flags & HEADER_FLAGS__SIZE_OF_GLOBAL_COLOR_TABLE)+1)); 132 gct_size = 3*(1 << ((header->flags & HEADER_FLAGS__SIZE_OF_GLOBAL_COLOR_TABLE)+1));
133 else 133 else
@@ -150,7 +150,7 @@ static size_t skipLocalColorMap(const unsigned char * data,
150 lct_size = 3*(1 << ((descriptor->flags & DESCRIPTOR_FLAGS__PIXEL_SIZE)+1)); 150 lct_size = 3*(1 << ((descriptor->flags & DESCRIPTOR_FLAGS__PIXEL_SIZE)+1));
151 else 151 else
152 lct_size = 0; 152 lct_size = 0;
153 return pos + GIF_DESCRIPTOR_SIZE + lct_size; 153 return pos + GIF_DESCRIPTOR_SIZE + lct_size;
154} 154}
155 155
156static struct EXTRACTOR_Keywords * parseComment(const unsigned char * data, 156static struct EXTRACTOR_Keywords * parseComment(const unsigned char * data,
@@ -170,21 +170,21 @@ static struct EXTRACTOR_Keywords * parseComment(const unsigned char * data,
170 curr = pos; 170 curr = pos;
171 length = 0; 171 length = 0;
172 while ( (data[curr] != 0) && 172 while ( (data[curr] != 0) &&
173 (curr < size) ) { 173 (curr < size) ) {
174 length += data[curr]; 174 length += data[curr];
175 if (length >= size) 175 if (length >= size)
176 break; 176 break;
177 memcpy(&keyword[length-data[curr]], 177 memcpy(&keyword[length-data[curr]],
178 &data[curr]+1, 178 &data[curr]+1,
179 data[curr]); 179 data[curr]);
180 keyword[length] = 0; 180 keyword[length] = 0;
181 curr += data[curr] + 1; 181 curr += data[curr] + 1;
182 } 182 }
183 return addKeyword(EXTRACTOR_COMMENT, 183 return addKeyword(EXTRACTOR_COMMENT,
184 keyword, 184 keyword,
185 prev); 185 prev);
186} 186}
187 187
188 188
189struct EXTRACTOR_Keywords * libextractor_gif_extract(const char * filename, 189struct EXTRACTOR_Keywords * libextractor_gif_extract(const char * filename,
190 const unsigned char * data, 190 const unsigned char * data,
@@ -209,9 +209,9 @@ struct EXTRACTOR_Keywords * libextractor_gif_extract(const char * filename,
209 strdup("image/gif"), 209 strdup("image/gif"),
210 result); 210 result);
211 tmp = malloc(128); 211 tmp = malloc(128);
212 snprintf(tmp, 212 snprintf(tmp,
213 128, 213 128,
214 "%ux%u", 214 "%ux%u",
215 header.screen_width, 215 header.screen_width,
216 header.screen_height); 216 header.screen_height);
217 result = addKeyword(EXTRACTOR_SIZE, 217 result = addKeyword(EXTRACTOR_SIZE,
@@ -253,6 +253,6 @@ struct EXTRACTOR_Keywords * libextractor_gif_extract(const char * filename,
253 } 253 }
254 } 254 }
255 PRINT("returning at %d\n",pos); 255 PRINT("returning at %d\n",pos);
256 return result; 256 return result;
257} 257}
258 258
diff --git a/src/plugins/hash/md5extractor.c b/src/plugins/hash/md5extractor.c
index 76e7396..5c5cc0c 100644
--- a/src/plugins/hash/md5extractor.c
+++ b/src/plugins/hash/md5extractor.c
@@ -23,13 +23,13 @@
23 23
24#include "md5.h" 24#include "md5.h"
25 25
26static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead, 26static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead,
27 const char *phrase, 27 const char *phrase,
28 EXTRACTOR_KeywordType type) { 28 EXTRACTOR_KeywordType type) {
29 29
30 EXTRACTOR_KeywordList * keyword; 30 EXTRACTOR_KeywordList * keyword;
31 keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList)); 31 keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList));
32 keyword->next = oldhead; 32 keyword->next = oldhead;
33 keyword->keyword = strdup(phrase); 33 keyword->keyword = strdup(phrase);
34 keyword->keywordType = type; 34 keyword->keywordType = type;
35 return keyword; 35 return keyword;
@@ -40,7 +40,7 @@ static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead,
40#define DIGEST_BITS 128 40#define DIGEST_BITS 128
41#define DIGEST_HEX_BYTES (DIGEST_BITS / 4) 41#define DIGEST_HEX_BYTES (DIGEST_BITS / 4)
42#define DIGEST_BIN_BYTES (DIGEST_BITS / 8) 42#define DIGEST_BIN_BYTES (DIGEST_BITS / 8)
43#define MAX_DIGEST_BIN_BYTES DIGEST_BIN_BYTES 43#define MAX_DIGEST_BIN_BYTES DIGEST_BIN_BYTES
44 44
45struct EXTRACTOR_Keywords * libextractor_hash_md5_extract(const char * filename, 45struct EXTRACTOR_Keywords * libextractor_hash_md5_extract(const char * filename,
46 char * data, 46 char * data,
@@ -51,7 +51,7 @@ struct EXTRACTOR_Keywords * libextractor_hash_md5_extract(const char * filename,
51 char buf[16]; 51 char buf[16];
52 int i; 52 int i;
53 53
54 md5_buffer(data, size, bin_buffer); 54 md5_buffer(data, size, bin_buffer);
55 hash[0] = '\0'; 55 hash[0] = '\0';
56 for (i=0;i<DIGEST_HEX_BYTES / 2; i++) { 56 for (i=0;i<DIGEST_HEX_BYTES / 2; i++) {
57 snprintf(buf, 57 snprintf(buf,
@@ -63,6 +63,6 @@ struct EXTRACTOR_Keywords * libextractor_hash_md5_extract(const char * filename,
63 prev = addKeyword(prev, 63 prev = addKeyword(prev,
64 hash, 64 hash,
65 EXTRACTOR_HASH_MD5); 65 EXTRACTOR_HASH_MD5);
66 66
67 return prev; 67 return prev;
68} 68}
diff --git a/src/plugins/hash/rmd160extractor.c b/src/plugins/hash/rmd160extractor.c
index 90c6633..d2d1ddf 100644
--- a/src/plugins/hash/rmd160extractor.c
+++ b/src/plugins/hash/rmd160extractor.c
@@ -599,13 +599,13 @@ rmd160_sum_bytes (
599#undef FUNCTION_NAME 599#undef FUNCTION_NAME
600 600
601 601
602static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead, 602static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead,
603 const char *phrase, 603 const char *phrase,
604 EXTRACTOR_KeywordType type) { 604 EXTRACTOR_KeywordType type) {
605 605
606 EXTRACTOR_KeywordList * keyword; 606 EXTRACTOR_KeywordList * keyword;
607 keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList)); 607 keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList));
608 keyword->next = oldhead; 608 keyword->next = oldhead;
609 keyword->keyword = strdup(phrase); 609 keyword->keyword = strdup(phrase);
610 keyword->keywordType = type; 610 keyword->keywordType = type;
611 return keyword; 611 return keyword;
@@ -614,7 +614,7 @@ static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead,
614#define DIGEST_BITS 160 614#define DIGEST_BITS 160
615#define DIGEST_HEX_BYTES (DIGEST_BITS / 4) 615#define DIGEST_HEX_BYTES (DIGEST_BITS / 4)
616#define DIGEST_BIN_BYTES (DIGEST_BITS / 8) 616#define DIGEST_BIN_BYTES (DIGEST_BITS / 8)
617#define MAX_DIGEST_BIN_BYTES DIGEST_BIN_BYTES 617#define MAX_DIGEST_BIN_BYTES DIGEST_BIN_BYTES
618#define rmd160_init(t) rmd160_copy((t),NULL) 618#define rmd160_init(t) rmd160_copy((t),NULL)
619#define rmd160_new() rmd160_copy(NULL,NULL) 619#define rmd160_new() rmd160_copy(NULL,NULL)
620 620
diff --git a/src/plugins/hash/sha1extractor.c b/src/plugins/hash/sha1extractor.c
index 8e6e88f..0f7640e 100644
--- a/src/plugins/hash/sha1extractor.c
+++ b/src/plugins/hash/sha1extractor.c
@@ -22,13 +22,13 @@
22#include "extractor.h" 22#include "extractor.h"
23#include "sha1.h" 23#include "sha1.h"
24 24
25static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead, 25static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead,
26 const char *phrase, 26 const char *phrase,
27 EXTRACTOR_KeywordType type) { 27 EXTRACTOR_KeywordType type) {
28 28
29 EXTRACTOR_KeywordList * keyword; 29 EXTRACTOR_KeywordList * keyword;
30 keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList)); 30 keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList));
31 keyword->next = oldhead; 31 keyword->next = oldhead;
32 keyword->keyword = strdup(phrase); 32 keyword->keyword = strdup(phrase);
33 keyword->keywordType = type; 33 keyword->keywordType = type;
34 return keyword; 34 return keyword;
@@ -38,7 +38,7 @@ static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead,
38#define DIGEST_HEX_BYTES (DIGEST_BITS / 4) 38#define DIGEST_HEX_BYTES (DIGEST_BITS / 4)
39#define DIGEST_BIN_BYTES (DIGEST_BITS / 8) 39#define DIGEST_BIN_BYTES (DIGEST_BITS / 8)
40 40
41#define MAX_DIGEST_BIN_BYTES DIGEST_BIN_BYTES 41#define MAX_DIGEST_BIN_BYTES DIGEST_BIN_BYTES
42 42
43struct EXTRACTOR_Keywords * libextractor_hash_sha1_extract(const char * filename, 43struct EXTRACTOR_Keywords * libextractor_hash_sha1_extract(const char * filename,
44 char * data, 44 char * data,
@@ -50,7 +50,7 @@ struct EXTRACTOR_Keywords * libextractor_hash_sha1_extract(const char * filename
50 int i; 50 int i;
51 51
52 sha_buffer(data, size, bin_buffer); 52 sha_buffer(data, size, bin_buffer);
53 53
54 hash[0] = '\0'; 54 hash[0] = '\0';
55 for (i=0;i<DIGEST_HEX_BYTES / 2; i++) { 55 for (i=0;i<DIGEST_HEX_BYTES / 2; i++) {
56 snprintf(buf, 56 snprintf(buf,
@@ -61,6 +61,6 @@ struct EXTRACTOR_Keywords * libextractor_hash_sha1_extract(const char * filename
61 } 61 }
62 prev = addKeyword(prev, 62 prev = addKeyword(prev,
63 hash, 63 hash,
64 EXTRACTOR_HASH_SHA1); 64 EXTRACTOR_HASH_SHA1);
65 return prev; 65 return prev;
66} 66}
diff --git a/src/plugins/htmlextractor.c b/src/plugins/htmlextractor.c
index ab3805e..6a9db5e 100644
--- a/src/plugins/htmlextractor.c
+++ b/src/plugins/htmlextractor.c
@@ -38,18 +38,18 @@ struct ArgvTable {
38 * We now put them all in one big table that is passed 38 * We now put them all in one big table that is passed
39 * around inside the parser. 39 * around inside the parser.
40 * 40 *
41 * The CallBacks 41 * The CallBacks
42 * You may call one ore several or even all callbacks. Except of the 42 * You may call one ore several or even all callbacks. Except of the
43 * XHTMLCallBack, all CallBacks will work as expected and described 43 * XHTMLCallBack, all CallBacks will work as expected and described
44 * 44 *
45 * XHTMLCallBack: 45 * XHTMLCallBack:
46 * The XHTMLCallBack is a special case, because you can decide, if the 46 * The XHTMLCallBack is a special case, because you can decide, if the
47 * XHTML specific tags should be handeled as a start- AND endtag, or 47 * XHTML specific tags should be handeled as a start- AND endtag, or
48 * as an XHTML tag. If you call nothing, except start and endtag, the 48 * as an XHTML tag. If you call nothing, except start and endtag, the
49 * behaviour is, that you'll get a start AND an endtag called back. 49 * behaviour is, that you'll get a start AND an endtag called back.
50 * If you call XHTMLCallBack, it will only give you the XHTML call back. 50 * If you call XHTMLCallBack, it will only give you the XHTML call back.
51 * 51 *
52 * If you are in doubt or simply confused now, call XHTMLCallBack() 52 * If you are in doubt or simply confused now, call XHTMLCallBack()
53 */ 53 */
54typedef struct PC_ { 54typedef struct PC_ {
55/* handle comments and javascript */ 55/* handle comments and javascript */
@@ -65,7 +65,7 @@ typedef struct PC_ {
65 65
66 /* End tag e.g. </html>*/ 66 /* End tag e.g. </html>*/
67 int (*endCallBack) (char *tag, struct PC_ * pc); 67 int (*endCallBack) (char *tag, struct PC_ * pc);
68 68
69 /* handle plain text */ 69 /* handle plain text */
70 int (*textCallBack) (char *text, struct PC_ * pc); 70 int (*textCallBack) (char *text, struct PC_ * pc);
71 int (*textStartCallBack) (struct PC_ * pc); 71 int (*textStartCallBack) (struct PC_ * pc);
@@ -98,13 +98,13 @@ typedef struct PC_ {
98 * 0: ignore, 1: add keyword 98 * 0: ignore, 1: add keyword
99 */ 99 */
100 int nextTextAction; 100 int nextTextAction;
101 101
102 /** 102 /**
103 * If nextTextAction == 1, this gives the type of the 103 * If nextTextAction == 1, this gives the type of the
104 * keyword. 104 * keyword.
105 */ 105 */
106 EXTRACTOR_KeywordType nextKeywordType; 106 EXTRACTOR_KeywordType nextKeywordType;
107 107
108 /** 108 /**
109 * Result of the current pass. 109 * Result of the current pass.
110 */ 110 */
@@ -124,14 +124,14 @@ static struct ArgvTable *addArgToTable(struct ArgvTable *args, char *arg, char *
124 args = (struct ArgvTable*) calloc(1, sizeof(struct ArgvTable)*(pc->numArgs+1)); 124 args = (struct ArgvTable*) calloc(1, sizeof(struct ArgvTable)*(pc->numArgs+1));
125 } else { 125 } else {
126 args = (struct ArgvTable*) realloc(args, sizeof(struct ArgvTable)*(pc->numArgs+1)); 126 args = (struct ArgvTable*) realloc(args, sizeof(struct ArgvTable)*(pc->numArgs+1));
127 } 127 }
128 if (args == NULL) { 128 if (args == NULL) {
129 fprintf(stderr, 129 fprintf(stderr,
130 _("Fatal: could not allocate (%s at %s:%d).\n"), 130 _("Fatal: could not allocate (%s at %s:%d).\n"),
131 strerror(errno), 131 strerror(errno),
132 __FILE__, __LINE__); 132 __FILE__, __LINE__);
133 exit(EXIT_FAILURE); 133 exit(EXIT_FAILURE);
134 } 134 }
135 args[pc->numArgs-1].arg = arg; 135 args[pc->numArgs-1].arg = arg;
136 args[pc->numArgs-1].val = val; 136 args[pc->numArgs-1].val = val;
137 return args; 137 return args;
@@ -141,12 +141,12 @@ static struct ArgvTable *addArgToTable(struct ArgvTable *args, char *arg, char *
141static void freeArgs (struct ArgvTable *args, 141static void freeArgs (struct ArgvTable *args,
142 struct PC_ * pc) { 142 struct PC_ * pc) {
143 int i; 143 int i;
144 144
145 if (args != NULL) { 145 if (args != NULL) {
146 for(i=0; i<pc->numArgs; i++) { 146 for(i=0; i<pc->numArgs; i++) {
147 free(args[i].arg); 147 free(args[i].arg);
148 free(args[i].val); 148 free(args[i].val);
149 } 149 }
150 free(args); 150 free(args);
151 args=NULL; 151 args=NULL;
152 pc->numArgs=0; 152 pc->numArgs=0;
@@ -161,19 +161,19 @@ static const char *parseText(const char *html, struct PC_ * pc) {
161 char *tmp; 161 char *tmp;
162 const char *tmp2; 162 const char *tmp2;
163 int ret=0; 163 int ret=0;
164 164
165 while( (*html != '\0') && isspace((int) *html)) html++; 165 while( (*html != '\0') && isspace((int) *html)) html++;
166 166
167 if (*html == '<') return html; 167 if (*html == '<') return html;
168 168
169 tmp2 = html; 169 tmp2 = html;
170 while ( (*html != '\0') && (*html != '<') ) html++; 170 while ( (*html != '\0') && (*html != '<') ) html++;
171 171
172 tmp = (char *)calloc(1, (size_t)(html-tmp2+1)); 172 tmp = (char *)calloc(1, (size_t)(html-tmp2+1));
173 if (!tmp) return ""; 173 if (!tmp) return "";
174 174
175 memcpy(tmp, tmp2, (size_t)(html-tmp2)); 175 memcpy(tmp, tmp2, (size_t)(html-tmp2));
176 176
177 if (strlen(tmp) > 0) { 177 if (strlen(tmp) > 0) {
178 if (pc->textStartCallBack) { 178 if (pc->textStartCallBack) {
179 ret = pc->textStartCallBack(pc); 179 ret = pc->textStartCallBack(pc);
@@ -181,8 +181,8 @@ static const char *parseText(const char *html, struct PC_ * pc) {
181 free(tmp); 181 free(tmp);
182 return ""; 182 return "";
183 } 183 }
184 } 184 }
185 if (pc->textCallBack) { 185 if (pc->textCallBack) {
186 if (pc->entityCallBack){ /* that is textCallBack(text) 186 if (pc->entityCallBack){ /* that is textCallBack(text)
187 with entityCallBack(entity) as an extrabonus */ 187 with entityCallBack(entity) as an extrabonus */
188 /*printf("entity is here\n");*/ 188 /*printf("entity is here\n");*/
@@ -194,7 +194,7 @@ static const char *parseText(const char *html, struct PC_ * pc) {
194 return ""; 194 return "";
195 } 195 }
196 } 196 }
197 } 197 }
198 if (pc->textEndCallBack) { 198 if (pc->textEndCallBack) {
199 ret = pc->textEndCallBack(pc); 199 ret = pc->textEndCallBack(pc);
200 if (ret != 0) { 200 if (ret != 0) {
@@ -202,8 +202,8 @@ static const char *parseText(const char *html, struct PC_ * pc) {
202 return ""; 202 return "";
203 } 203 }
204 } 204 }
205 } 205 }
206 free(tmp); 206 free(tmp);
207 if (*html != '\0') 207 if (*html != '\0')
208 if (*(html+1) == '>') html += 2; 208 if (*(html+1) == '>') html += 2;
209 return html; 209 return html;
@@ -213,19 +213,19 @@ static const char *parseComment (const char *html, struct PC_ * pc) {
213 char *tmp; 213 char *tmp;
214 const char *tmp2; 214 const char *tmp2;
215 int ret=0; 215 int ret=0;
216 216
217 while ( (*html == '-') || isspace((int)*html))html++; 217 while ( (*html == '-') || isspace((int)*html))html++;
218 218
219 tmp2 = html; 219 tmp2 = html;
220 while ( (*html != '\0') && !(*html == '-' && *(html+1) == '-' && *(html+2) == '>')) html++; 220 while ( (*html != '\0') && !(*html == '-' && *(html+1) == '-' && *(html+2) == '>')) html++;
221 221
222 tmp = (char *)calloc(1, (size_t)(html-tmp2+1)); 222 tmp = (char *)calloc(1, (size_t)(html-tmp2+1));
223 if (!tmp) return ""; 223 if (!tmp) return "";
224 224
225 memcpy(tmp, tmp2, (size_t)(html-tmp2)); 225 memcpy(tmp, tmp2, (size_t)(html-tmp2));
226 226
227 if (*(html+3) != '\0') html += 3; 227 if (*(html+3) != '\0') html += 3;
228 228
229 if (pc->commentStartCallBack) { 229 if (pc->commentStartCallBack) {
230 ret = pc->commentStartCallBack(pc); 230 ret = pc->commentStartCallBack(pc);
231 if (ret != 0) { 231 if (ret != 0) {
@@ -239,7 +239,7 @@ static const char *parseComment (const char *html, struct PC_ * pc) {
239 free(tmp); 239 free(tmp);
240 return ""; 240 return "";
241 } 241 }
242 } 242 }
243 if (pc->commentEndCallBack) { 243 if (pc->commentEndCallBack) {
244 ret = pc->commentEndCallBack(pc); 244 ret = pc->commentEndCallBack(pc);
245 if (ret != 0) { 245 if (ret != 0) {
@@ -255,27 +255,27 @@ static const char *parseEndTag(const char *html, struct PC_ * pc) {
255 char *tmp; 255 char *tmp;
256 const char *tmp2; 256 const char *tmp2;
257 int ret=0; 257 int ret=0;
258 258
259 if (*html == '\0') 259 if (*html == '\0')
260 return html; 260 return html;
261 261
262 html++; 262 html++;
263 tmp2 = html; 263 tmp2 = html;
264 while(*html != '\0' && *html != '>') html++; 264 while(*html != '\0' && *html != '>') html++;
265 265
266 tmp =(char *) calloc(1, (size_t)(html-tmp2+1)); 266 tmp =(char *) calloc(1, (size_t)(html-tmp2+1));
267 if (!tmp) return ""; 267 if (!tmp) return "";
268 268
269 memcpy(tmp, tmp2, (size_t)(html-tmp2)); 269 memcpy(tmp, tmp2, (size_t)(html-tmp2));
270 270
271 if (pc->endCallBack) { 271 if (pc->endCallBack) {
272 ret = pc->endCallBack(tmp,pc); 272 ret = pc->endCallBack(tmp,pc);
273 if (ret != 0) { 273 if (ret != 0) {
274 free(tmp); 274 free(tmp);
275 return ""; 275 return "";
276 } 276 }
277 } 277 }
278 if (*html == '>') html++; 278 if (*html == '>') html++;
279 free(tmp); 279 free(tmp);
280 return html; 280 return html;
281} 281}
@@ -284,28 +284,28 @@ static const char *parsePHP(const char *html, struct PC_ * pc) {
284 const char *tmp; 284 const char *tmp;
285 char *tmp2; 285 char *tmp2;
286 int ret=0; 286 int ret=0;
287 287
288 html += 4; 288 html += 4;
289 while(*html != '\0' && isspace((int)*html)) html++; 289 while(*html != '\0' && isspace((int)*html)) html++;
290 290
291 tmp = html; 291 tmp = html;
292 292
293 while(*html != '\0' && !(*html == '?' && *(html+1) == '>')) html++; 293 while(*html != '\0' && !(*html == '?' && *(html+1) == '>')) html++;
294 tmp2 = (char *)calloc(1, (size_t)(html-tmp+1)); 294 tmp2 = (char *)calloc(1, (size_t)(html-tmp+1));
295 if (!tmp2) return ""; 295 if (!tmp2) return "";
296 296
297 memcpy(tmp2, tmp, (size_t)(html-tmp)); 297 memcpy(tmp2, tmp, (size_t)(html-tmp));
298 298
299 if (pc->phpCallBack) { 299 if (pc->phpCallBack) {
300 ret = pc->phpCallBack(tmp2, pc); 300 ret = pc->phpCallBack(tmp2, pc);
301 if (ret != 0) { 301 if (ret != 0) {
302 free(tmp2); 302 free(tmp2);
303 return ""; 303 return "";
304 } 304 }
305 } 305 }
306 free(tmp2); 306 free(tmp2);
307 html += 2; 307 html += 2;
308 return html; 308 return html;
309} 309}
310 310
311/* parse the XML tag itself */ 311/* parse the XML tag itself */
@@ -314,18 +314,18 @@ static const char *parseXMLtag(const char *html, struct PC_ * pc) {
314 const char *tmp; 314 const char *tmp;
315 int ret; 315 int ret;
316 struct ArgvTable *tmp2 = NULL; 316 struct ArgvTable *tmp2 = NULL;
317 317
318 pc->numArgs = 0; 318 pc->numArgs = 0;
319 tmp = html; 319 tmp = html;
320 while(*html != '\0' && !isspace((int)*html) && *html != '>') html++; 320 while(*html != '\0' && !isspace((int)*html) && *html != '>') html++;
321 321
322 /* you may want to upper/lower tags, so I leave the tag itself untouched */ 322 /* you may want to upper/lower tags, so I leave the tag itself untouched */
323 tag = (char *)calloc(1, (size_t)(html-tmp+1)); 323 tag = (char *)calloc(1, (size_t)(html-tmp+1));
324 if (!tag) { 324 if (!tag) {
325 return ""; 325 return "";
326 } 326 }
327 memcpy(tag, tmp, (size_t)(html-tmp)); 327 memcpy(tag, tmp, (size_t)(html-tmp));
328 328
329 if (*html == '>') { 329 if (*html == '>') {
330 if (pc->xmlCallBack != NULL) { 330 if (pc->xmlCallBack != NULL) {
331 ret = pc->xmlCallBack(tag, NULL, 0, pc); 331 ret = pc->xmlCallBack(tag, NULL, 0, pc);
@@ -333,13 +333,13 @@ static const char *parseXMLtag(const char *html, struct PC_ * pc) {
333 if (*html == '>') html++; 333 if (*html == '>') html++;
334 return((ret != 0) ? (char *) "" : html); 334 return((ret != 0) ? (char *) "" : html);
335 } 335 }
336 } 336 }
337 while(*html != '\0' && isspace((int)*html)) html++; 337 while(*html != '\0' && isspace((int)*html)) html++;
338 338
339 while(*html != '\0' && *html != '>' ) { 339 while(*html != '\0' && *html != '>' ) {
340 while(isspace((int)*html)) html++; 340 while(isspace((int)*html)) html++;
341 if (*html == '>') break; 341 if (*html == '>') break;
342 342
343 tmp = html; 343 tmp = html;
344 while(*html != '\0' && !isspace((int)*html) && *html != '=' && *html != '>') html++; 344 while(*html != '\0' && !isspace((int)*html) && *html != '=' && *html != '>') html++;
345 name = (char *)calloc(1, (size_t)(html-tmp+1)); 345 name = (char *)calloc(1, (size_t)(html-tmp+1));
@@ -347,18 +347,18 @@ static const char *parseXMLtag(const char *html, struct PC_ * pc) {
347 free(tag); 347 free(tag);
348 tag = NULL; 348 tag = NULL;
349 return ""; 349 return "";
350 } 350 }
351 memcpy(name, tmp, (size_t)(html-tmp)); 351 memcpy(name, tmp, (size_t)(html-tmp));
352 if (isspace((int)*html)) { 352 if (isspace((int)*html)) {
353 tmp2 = addArgToTable(tmp2, name, NULL, pc); 353 tmp2 = addArgToTable(tmp2, name, NULL, pc);
354 while(*html != '\0' && isspace((int)*html) && *html != '>') html++; 354 while(*html != '\0' && isspace((int)*html) && *html != '>') html++;
355 } 355 }
356 if (*html == '>') { 356 if (*html == '>') {
357 tmp2 = addArgToTable(tmp2, name, NULL, pc); 357 tmp2 = addArgToTable(tmp2, name, NULL, pc);
358 html++; 358 html++;
359 break; 359 break;
360 } 360 }
361 if (*html == '=') html++; 361 if (*html == '=') html++;
362 if (*html != '"' && *html != '\'') { 362 if (*html != '"' && *html != '\'') {
363 tmp = html; 363 tmp = html;
364 while(*html != '\0' && *html != '>' && !isspace((int)*html)) html++; 364 while(*html != '\0' && *html != '>' && !isspace((int)*html)) html++;
@@ -374,7 +374,7 @@ static const char *parseXMLtag(const char *html, struct PC_ * pc) {
374 tmp2 = NULL; 374 tmp2 = NULL;
375 } 375 }
376 return ""; 376 return "";
377 } 377 }
378 memcpy(value, tmp, (size_t)(html-tmp)); 378 memcpy(value, tmp, (size_t)(html-tmp));
379 tmp2 = addArgToTable(tmp2, name, value, pc); 379 tmp2 = addArgToTable(tmp2, name, value, pc);
380 } else if (*html == '"') { 380 } else if (*html == '"') {
@@ -393,7 +393,7 @@ static const char *parseXMLtag(const char *html, struct PC_ * pc) {
393 tmp2 = NULL; 393 tmp2 = NULL;
394 } 394 }
395 return ""; 395 return "";
396 } 396 }
397 memcpy(value, tmp, (size_t)(html-tmp)); 397 memcpy(value, tmp, (size_t)(html-tmp));
398 if (*html != '\0') 398 if (*html != '\0')
399 html++; 399 html++;
@@ -402,7 +402,7 @@ static const char *parseXMLtag(const char *html, struct PC_ * pc) {
402 html++; 402 html++;
403 tmp = html; 403 tmp = html;
404 while(*html != '\0' && !(*html == '\'' && *(html-1) != '\\')) html++; 404 while(*html != '\0' && !(*html == '\'' && *(html-1) != '\\')) html++;
405 405
406 value = (char *)calloc(1, (size_t)(html-tmp+1)); 406 value = (char *)calloc(1, (size_t)(html-tmp+1));
407 if (!value) { 407 if (!value) {
408 free(name); 408 free(name);
@@ -414,25 +414,25 @@ static const char *parseXMLtag(const char *html, struct PC_ * pc) {
414 tmp2 = NULL; 414 tmp2 = NULL;
415 } 415 }
416 return ""; 416 return "";
417 } 417 }
418 memcpy(value, tmp, (size_t)(html-tmp)); 418 memcpy(value, tmp, (size_t)(html-tmp));
419 if (*html != '\0') 419 if (*html != '\0')
420 html++; 420 html++;
421 tmp2 = addArgToTable(tmp2, name, value, pc); 421 tmp2 = addArgToTable(tmp2, name, value, pc);
422 } 422 }
423 tmp = NULL; 423 tmp = NULL;
424 value = NULL; 424 value = NULL;
425 name = NULL; 425 name = NULL;
426 } 426 }
427 if (*html != '\0') html++; 427 if (*html != '\0') html++;
428 ret = pc->xmlCallBack(tag, tmp2, pc->numArgs, pc); 428 ret = pc->xmlCallBack(tag, tmp2, pc->numArgs, pc);
429 if (tmp2 != NULL) { 429 if (tmp2 != NULL) {
430 freeArgs(tmp2, pc); 430 freeArgs(tmp2, pc);
431 tmp2 = NULL; 431 tmp2 = NULL;
432 } 432 }
433 free(tag); 433 free(tag);
434 tag = NULL; 434 tag = NULL;
435 pc->numArgsStatus=0; 435 pc->numArgsStatus=0;
436 return (ret != 0 ? "" : html); 436 return (ret != 0 ? "" : html);
437} 437}
438 438
@@ -442,7 +442,7 @@ static const char *eatUp(const char *html){
442 (*html != '\0') ) { 442 (*html != '\0') ) {
443 html++; 443 html++;
444 } 444 }
445 if (*html != '\0') 445 if (*html != '\0')
446 html++; 446 html++;
447 return html; 447 return html;
448} 448}
@@ -450,7 +450,7 @@ static const char *eatUp(const char *html){
450/* cannibalistic function, munches the actuall text */ 450/* cannibalistic function, munches the actuall text */
451static const char *eatUpText(const char *html){ 451static const char *eatUpText(const char *html){
452 while(*html != '\0' && *html != '<') 452 while(*html != '\0' && *html != '<')
453 html++; 453 html++;
454 return html; 454 return html;
455} 455}
456 456
@@ -459,10 +459,10 @@ static const char *eatUpText(const char *html){
459 otherwise it gormandizes them up. *burps* */ 459 otherwise it gormandizes them up. *burps* */
460static const char *parseXML(const char *html, struct PC_ * pc) { 460static const char *parseXML(const char *html, struct PC_ * pc) {
461 /* conditional expressions inside a conditional expression 461 /* conditional expressions inside a conditional expression
462 don't try _this_ at home kids! ;-) */ 462 don't try _this_ at home kids! ;-) */
463 html=(((tolower((int)(*(html+1))))==(int)('p')) ? 463 html=(((tolower((int)(*(html+1))))==(int)('p')) ?
464 ( (pc->phpCallBack) ? parsePHP (html, pc) : eatUp(html) ) : 464 ( (pc->phpCallBack) ? parsePHP (html, pc) : eatUp(html) ) :
465 ( (pc->xmlCallBack) ? parseXMLtag(html, pc) : eatUp(html) ) ); 465 ( (pc->xmlCallBack) ? parseXMLtag(html, pc) : eatUp(html) ) );
466 return html; 466 return html;
467} 467}
468 468
@@ -472,31 +472,31 @@ static const char *parseStartTag (const char *html, struct PC_ * pc) {
472 const char * start = html; 472 const char * start = html;
473 int ret = 0; 473 int ret = 0;
474 struct ArgvTable *tmp2 = NULL; 474 struct ArgvTable *tmp2 = NULL;
475 475
476 pc->numArgs = 0; 476 pc->numArgs = 0;
477 tmp = html; 477 tmp = html;
478 while(*html != '\0' && !isspace((int)*html) && 478 while(*html != '\0' && !isspace((int)*html) &&
479 *html != '>' && *html != '/') html++; 479 *html != '>' && *html != '/') html++;
480 480
481 tag = (char *)calloc(1, (size_t)(html-tmp+1)); 481 tag = (char *)calloc(1, (size_t)(html-tmp+1));
482 if (!tag) { 482 if (!tag) {
483 return ""; 483 return "";
484 } 484 }
485 memcpy(tag, tmp, (size_t)(html-tmp)); 485 memcpy(tag, tmp, (size_t)(html-tmp));
486 486
487 if (strncasecmp("script", tag, 6) == 0) { 487 if (strncasecmp("script", tag, 6) == 0) {
488 pc->lhtml_script_passthru = 1; 488 pc->lhtml_script_passthru = 1;
489 } 489 }
490 else if (strncasecmp("pre", tag, 3) == 0) { 490 else if (strncasecmp("pre", tag, 3) == 0) {
491 pc->lhtml_script_passthru = 2; 491 pc->lhtml_script_passthru = 2;
492 } 492 }
493 493
494 if (*html == '>') { 494 if (*html == '>') {
495 if (pc->startCallBack) { 495 if (pc->startCallBack) {
496 ret = pc->startCallBack(tag, NULL, 0, pc); 496 ret = pc->startCallBack(tag, NULL, 0, pc);
497 free(tag); 497 free(tag);
498 tag = NULL; 498 tag = NULL;
499 499
500 /* this check is redundant */ 500 /* this check is redundant */
501 /* if (*html == '>') */ html++; 501 /* if (*html == '>') */ html++;
502 return((ret != 0) ? "" : html); 502 return((ret != 0) ? "" : html);
@@ -518,26 +518,26 @@ static const char *parseStartTag (const char *html, struct PC_ * pc) {
518 if(pc->XHTMLCallBack){ 518 if(pc->XHTMLCallBack){
519 ret = pc->XHTMLCallBack(tag, NULL, 0, pc); 519 ret = pc->XHTMLCallBack(tag, NULL, 0, pc);
520 } 520 }
521 521
522 free(tag); 522 free(tag);
523 tag = NULL; 523 tag = NULL;
524 524
525 html += 2; 525 html += 2;
526 return((ret != 0) ? "" : html); 526 return((ret != 0) ? "" : html);
527 } 527 }
528 528
529 while(*html != '\0' && isspace((int)*html)) html++; 529 while(*html != '\0' && isspace((int)*html)) html++;
530 530
531 while(*html != '\0' && *html != '>' ) { 531 while(*html != '\0' && *html != '>' ) {
532 while(isspace((int)*html)) html++; 532 while(isspace((int)*html)) html++;
533 if (*html == '>') break; 533 if (*html == '>') break;
534 534
535 if (*html == '/' && *(html+1) == '>') { 535 if (*html == '/' && *(html+1) == '>') {
536 html++; break; 536 html++; break;
537 } 537 }
538 538
539 tmp = html; 539 tmp = html;
540 while(*html != '\0' && !isspace((int)*html) && 540 while(*html != '\0' && !isspace((int)*html) &&
541 *html != '=' && *html != '>') html++; 541 *html != '=' && *html != '>') html++;
542 name = (char *)calloc(1, (size_t)(html-tmp+1)); 542 name = (char *)calloc(1, (size_t)(html-tmp+1));
543 if (!name) { 543 if (!name) {
@@ -545,9 +545,9 @@ static const char *parseStartTag (const char *html, struct PC_ * pc) {
545 tag = NULL; 545 tag = NULL;
546 return ""; 546 return "";
547 } 547 }
548 548
549 memcpy(name, tmp, (size_t)(html-tmp)); 549 memcpy(name, tmp, (size_t)(html-tmp));
550 550
551 if (isspace((int)*html)) { 551 if (isspace((int)*html)) {
552 const char *x = html; 552 const char *x = html;
553 while(*x != '\0' && *x != '>' && *x != '=') x++; 553 while(*x != '\0' && *x != '>' && *x != '=') x++;
@@ -556,35 +556,35 @@ static const char *parseStartTag (const char *html, struct PC_ * pc) {
556 goto namevalue; 556 goto namevalue;
557 } 557 }
558 tmp2 = addArgToTable(tmp2, name, NULL, pc); 558 tmp2 = addArgToTable(tmp2, name, NULL, pc);
559 while(*html != '\0' && isspace((int)*html) && 559 while(*html != '\0' && isspace((int)*html) &&
560 *html != '>' && 560 *html != '>' &&
561 !(*html == '/' && *(html+1) == '>')) 561 !(*html == '/' && *(html+1) == '>'))
562 html++; 562 html++;
563 } else { 563 } else {
564 564
565 if (*html == '/') { 565 if (*html == '/') {
566 html++; 566 html++;
567 break; 567 break;
568 } 568 }
569 569
570 /* html++ is repeated after the while loop 570 /* html++ is repeated after the while loop
571 * and may cause deletion of important info */ 571 * and may cause deletion of important info */
572 if (*html == '>') { 572 if (*html == '>') {
573 tmp2 = addArgToTable(tmp2, name, NULL, pc); 573 tmp2 = addArgToTable(tmp2, name, NULL, pc);
574 /*html++;*/ 574 /*html++;*/
575 break; 575 break;
576 } 576 }
577 577
578 namevalue: 578 namevalue:
579 if (*html == '=') html++; 579 if (*html == '=') html++;
580 580
581 while(isspace(*html)) html++; 581 while(isspace(*html)) html++;
582 582
583 if (*html != '"' && *html != '\'') { 583 if (*html != '"' && *html != '\'') {
584 tmp = html; 584 tmp = html;
585 while(*html != '\0' && *html != '>' && 585 while(*html != '\0' && *html != '>' &&
586 !isspace((int)*html) && 586 !isspace((int)*html) &&
587 !(*html == '/' && *(html+1) == '>')) 587 !(*html == '/' && *(html+1) == '>'))
588 html++; 588 html++;
589 value = (char *)calloc(1, (size_t)(html-tmp+1)); 589 value = (char *)calloc(1, (size_t)(html-tmp+1));
590 if (value == NULL) { 590 if (value == NULL) {
@@ -592,7 +592,7 @@ static const char *parseStartTag (const char *html, struct PC_ * pc) {
592 name = NULL; 592 name = NULL;
593 free(tag); 593 free(tag);
594 tag = NULL; 594 tag = NULL;
595 595
596 freeArgs(tmp2, pc); 596 freeArgs(tmp2, pc);
597 return ""; 597 return "";
598 } 598 }
@@ -601,8 +601,8 @@ static const char *parseStartTag (const char *html, struct PC_ * pc) {
601 } else if (*html == '"') { 601 } else if (*html == '"') {
602 html++; 602 html++;
603 tmp = html; 603 tmp = html;
604 while (*html != '\0' && 604 while (*html != '\0' &&
605 !(*html == '"' && *(html-1) != '\\')) 605 !(*html == '"' && *(html-1) != '\\'))
606 html++; 606 html++;
607 value = (char *) calloc(1, (size_t)(html-tmp+1)); 607 value = (char *) calloc(1, (size_t)(html-tmp+1));
608 if (value == NULL) { 608 if (value == NULL) {
@@ -610,7 +610,7 @@ static const char *parseStartTag (const char *html, struct PC_ * pc) {
610 name = NULL; 610 name = NULL;
611 free(tag); 611 free(tag);
612 tag = NULL; 612 tag = NULL;
613 613
614 freeArgs(tmp2, pc); 614 freeArgs(tmp2, pc);
615 return ""; 615 return "";
616 } 616 }
@@ -622,7 +622,7 @@ static const char *parseStartTag (const char *html, struct PC_ * pc) {
622 } else if (*html == '\'') { 622 } else if (*html == '\'') {
623 html++; 623 html++;
624 tmp = html; 624 tmp = html;
625 while(*html != '\0' && !(*html == '\'' && 625 while(*html != '\0' && !(*html == '\'' &&
626 *(html-1) != '\\')) html++; 626 *(html-1) != '\\')) html++;
627 627
628 value = (char *)calloc(1, (size_t)(html-tmp+1)); 628 value = (char *)calloc(1, (size_t)(html-tmp+1));
@@ -631,7 +631,7 @@ static const char *parseStartTag (const char *html, struct PC_ * pc) {
631 name = NULL; 631 name = NULL;
632 free(tag); 632 free(tag);
633 tag = NULL; 633 tag = NULL;
634 634
635 freeArgs(tmp2, pc); 635 freeArgs(tmp2, pc);
636 return ""; 636 return "";
637 } 637 }
@@ -645,12 +645,12 @@ static const char *parseStartTag (const char *html, struct PC_ * pc) {
645 } 645 }
646 } 646 }
647 if (*html != '\0') html++; 647 if (*html != '\0') html++;
648 648
649 if (html - start > 2) { 649 if (html - start > 2) {
650 if (pc->startCallBack != NULL && (*(html-2)!='/')) { 650 if (pc->startCallBack != NULL && (*(html-2)!='/')) {
651 ret = pc->startCallBack(tag, tmp2, pc->numArgs, pc); 651 ret = pc->startCallBack(tag, tmp2, pc->numArgs, pc);
652 } 652 }
653 if (pc->endCallBack != NULL && ret==0 && *(html-2)=='/' 653 if (pc->endCallBack != NULL && ret==0 && *(html-2)=='/'
654 && !(pc->XHTMLCallBack)) { 654 && !(pc->XHTMLCallBack)) {
655 ret = pc->endCallBack(tag, pc); 655 ret = pc->endCallBack(tag, pc);
656 } 656 }
@@ -664,9 +664,9 @@ static const char *parseStartTag (const char *html, struct PC_ * pc) {
664 } 664 }
665 free(tag); 665 free(tag);
666 tag = NULL; 666 tag = NULL;
667 667
668 pc->numArgsStatus=0; 668 pc->numArgsStatus=0;
669 669
670 /* this is a bad hack, feel free to write a better one (maybe a more readable one? ;-)*/ 670 /* this is a bad hack, feel free to write a better one (maybe a more readable one? ;-)*/
671 return 671 return
672 (pc->XHTMLCallBack != NULL) ? 672 (pc->XHTMLCallBack != NULL) ?
@@ -679,90 +679,90 @@ static const char *parseDecl(const char *html, struct PC_ * pc) {
679 const char *tmp; 679 const char *tmp;
680 int ret=0; 680 int ret=0;
681 struct ArgvTable *tmp2 = NULL; 681 struct ArgvTable *tmp2 = NULL;
682 682
683 pc->numArgs = 0; 683 pc->numArgs = 0;
684 tmp = html; 684 tmp = html;
685 while(*html != '\0' && !isspace((int)*html) && *html != '>') html++; 685 while(*html != '\0' && !isspace((int)*html) && *html != '>') html++;
686 686
687 tag = (char *)calloc(1, (size_t)(html-tmp+1)); 687 tag = (char *)calloc(1, (size_t)(html-tmp+1));
688 if (!tag) { 688 if (!tag) {
689 return ""; 689 return "";
690 } 690 }
691 691
692 memcpy(tag, tmp, (size_t)(html-tmp)); 692 memcpy(tag, tmp, (size_t)(html-tmp));
693 693
694 if (*html == '>') { 694 if (*html == '>') {
695 if (pc->declCallBack) { 695 if (pc->declCallBack) {
696 ret = pc->declCallBack(tag, NULL, 0, pc); 696 ret = pc->declCallBack(tag, NULL, 0, pc);
697 free(tag); 697 free(tag);
698 tag = NULL; 698 tag = NULL;
699 699
700 if (*html == '>') html++; 700 if (*html == '>') html++;
701 return((ret != 0) ? "" : html); 701 return((ret != 0) ? "" : html);
702 } 702 }
703 } 703 }
704 704
705 while(*html != '\0' && isspace((int)*html)) html++; 705 while(*html != '\0' && isspace((int)*html)) html++;
706 706
707 while(*html != '\0' && *html != '>') { 707 while(*html != '\0' && *html != '>') {
708 while(isspace((int)*html)) html++; 708 while(isspace((int)*html)) html++;
709 if (*html == '>') break; 709 if (*html == '>') break;
710 tmp = html; 710 tmp = html;
711 switch(*tmp) { 711 switch(*tmp) {
712 case '\'' : 712 case '\'' :
713 html++; 713 html++;
714 tmp = html; 714 tmp = html;
715 while(*html != '\0' && !(*html == '\'' && *html != '\\')) 715 while(*html != '\0' && !(*html == '\'' && *html != '\\'))
716 html++; 716 html++;
717 break; 717 break;
718 case '"' : 718 case '"' :
719 html++; 719 html++;
720 tmp = html; 720 tmp = html;
721 while(*html != '\0' && !(*html == '"' && *html != '\\')) 721 while(*html != '\0' && !(*html == '"' && *html != '\\'))
722 html++; 722 html++;
723 break; 723 break;
724 default : 724 default :
725 while(*html != '\0' && !isspace((int)*html) && *html != '=' && *html != '>') 725 while(*html != '\0' && !isspace((int)*html) && *html != '=' && *html != '>')
726 html++; 726 html++;
727 break; 727 break;
728 } 728 }
729 729
730 name = (char *) calloc(1, (size_t)(html-tmp+1)); 730 name = (char *) calloc(1, (size_t)(html-tmp+1));
731 if (!name) { 731 if (!name) {
732 free(tag); 732 free(tag);
733 tag = NULL; 733 tag = NULL;
734 return ""; 734 return "";
735 } 735 }
736 736
737 memcpy(name, tmp, (size_t)(html-tmp)); 737 memcpy(name, tmp, (size_t)(html-tmp));
738 738
739 if (isspace((int)*html)) { 739 if (isspace((int)*html)) {
740 tmp2 = addArgToTable(tmp2, name, NULL, pc); 740 tmp2 = addArgToTable(tmp2, name, NULL, pc);
741 while(*html != '\0' && isspace((int)*html) && *html != '>') 741 while(*html != '\0' && isspace((int)*html) && *html != '>')
742 html++; 742 html++;
743 continue; 743 continue;
744 } 744 }
745 745
746 if (*html == '>') { 746 if (*html == '>') {
747 tmp2 = addArgToTable(tmp2, name, NULL, pc); 747 tmp2 = addArgToTable(tmp2, name, NULL, pc);
748 html++; 748 html++;
749 break; 749 break;
750 } 750 }
751 751
752 if (*(html+1) == '>') { 752 if (*(html+1) == '>') {
753 tmp2 = addArgToTable(tmp2, name, NULL, pc); 753 tmp2 = addArgToTable(tmp2, name, NULL, pc);
754 html += 2; 754 html += 2;
755 break; 755 break;
756 } 756 }
757 757
758 if (*html == '=') html++; 758 if (*html == '=') html++;
759 switch(*html){ 759 switch(*html){
760 case '\'' : 760 case '\'' :
761 html++; 761 html++;
762 tmp = html; 762 tmp = html;
763 while(*html != '\0' && !(*html == '\'' && *(html-1) != '\\')) 763 while(*html != '\0' && !(*html == '\'' && *(html-1) != '\\'))
764 html++; 764 html++;
765 765
766 value = (char *) calloc(1, (size_t)(html-tmp+1)); 766 value = (char *) calloc(1, (size_t)(html-tmp+1));
767 if (!value) { 767 if (!value) {
768 free(name); 768 free(name);
@@ -773,13 +773,13 @@ static const char *parseDecl(const char *html, struct PC_ * pc) {
773 freeArgs(tmp2, pc); 773 freeArgs(tmp2, pc);
774 return ""; 774 return "";
775 } 775 }
776 776
777 memcpy(value, tmp, (size_t)(html-tmp)); 777 memcpy(value, tmp, (size_t)(html-tmp));
778 if (*html != '\0') 778 if (*html != '\0')
779 html++; 779 html++;
780 tmp2 = addArgToTable(tmp2, name, value, pc); 780 tmp2 = addArgToTable(tmp2, name, value, pc);
781 break; 781 break;
782 case '"' : 782 case '"' :
783 html++; 783 html++;
784 tmp = html; 784 tmp = html;
785 while (*html != '\0' && !(*html == '"' && *(html-1) != '\\')) 785 while (*html != '\0' && !(*html == '"' && *(html-1) != '\\'))
@@ -794,16 +794,16 @@ static const char *parseDecl(const char *html, struct PC_ * pc) {
794 freeArgs(tmp2, pc); 794 freeArgs(tmp2, pc);
795 return ""; 795 return "";
796 } 796 }
797 797
798 memcpy(value, tmp, (size_t)(html-tmp)); 798 memcpy(value, tmp, (size_t)(html-tmp));
799 if (*html != '\0') 799 if (*html != '\0')
800 html++; 800 html++;
801 tmp2 = addArgToTable(tmp2, name, value, pc); 801 tmp2 = addArgToTable(tmp2, name, value, pc);
802 break; 802 break;
803 default : 803 default :
804 html++; 804 html++;
805 tmp = html; 805 tmp = html;
806 while(*html != '\0' && *html != '>' && !isspace((int)*html)) 806 while(*html != '\0' && *html != '>' && !isspace((int)*html))
807 html++; 807 html++;
808 value = (char *) calloc(1, (size_t)(html-tmp+1)); 808 value = (char *) calloc(1, (size_t)(html-tmp+1));
809 if (!value) { 809 if (!value) {
@@ -815,26 +815,26 @@ static const char *parseDecl(const char *html, struct PC_ * pc) {
815 freeArgs(tmp2, pc); 815 freeArgs(tmp2, pc);
816 return ""; 816 return "";
817 } 817 }
818 818
819 memcpy(value, tmp, (size_t)(html-tmp)); 819 memcpy(value, tmp, (size_t)(html-tmp));
820 tmp2 = addArgToTable(tmp2, name, value, pc); 820 tmp2 = addArgToTable(tmp2, name, value, pc);
821 break; 821 break;
822 } 822 }
823 tmp = NULL; 823 tmp = NULL;
824 } 824 }
825 825
826 if (*html != '\0') html++; 826 if (*html != '\0') html++;
827 827
828 if (pc->declCallBack) { 828 if (pc->declCallBack) {
829 ret = pc->declCallBack(tag, tmp2, pc->numArgs, pc); 829 ret = pc->declCallBack(tag, tmp2, pc->numArgs, pc);
830 freeArgs(tmp2, pc); 830 freeArgs(tmp2, pc);
831 free(tag); 831 free(tag);
832 tag = NULL; 832 tag = NULL;
833 return((ret != 0) ? "" : html); 833 return((ret != 0) ? "" : html);
834 } 834 }
835 freeArgs(tmp2, pc); 835 freeArgs(tmp2, pc);
836 pc->numArgsStatus=0; 836 pc->numArgsStatus=0;
837 837
838 return html; 838 return html;
839} 839}
840 840
@@ -845,12 +845,12 @@ static const char *parseForEntities (const char *tmp, struct PC_ * pc){
845 while(*tmp != '\0'){ 845 while(*tmp != '\0'){
846 tmp1 = tmp; 846 tmp1 = tmp;
847 while(*tmp != '\0' && *tmp != '&')tmp++; 847 while(*tmp != '\0' && *tmp != '&')tmp++;
848 848
849 text = (char *)calloc(1, (size_t)(tmp-tmp1+1)); 849 text = (char *)calloc(1, (size_t)(tmp-tmp1+1));
850 if (text == NULL) { 850 if (text == NULL) {
851 return ""; 851 return "";
852 } 852 }
853 853
854 memcpy(text, tmp1, (size_t)(tmp-tmp1)); 854 memcpy(text, tmp1, (size_t)(tmp-tmp1));
855 /* the chunk of text before the first entity will 855 /* the chunk of text before the first entity will
856 not be called, if it starts with an entity*/ 856 not be called, if it starts with an entity*/
@@ -859,9 +859,9 @@ static const char *parseForEntities (const char *tmp, struct PC_ * pc){
859 ret = pc->textCallBack(text, pc); 859 ret = pc->textCallBack(text, pc);
860 } 860 }
861 free(text); 861 free(text);
862 text = NULL; 862 text = NULL;
863 tmp1 = ""; 863 tmp1 = "";
864 } 864 }
865 if(*tmp == '&'){ 865 if(*tmp == '&'){
866 tmp++; 866 tmp++;
867 tmp2=tmp; 867 tmp2=tmp;
@@ -893,11 +893,11 @@ static void parse (const char *html, struct PC_ * pc) {
893 while(*html != '\0') { 893 while(*html != '\0') {
894 /* while(isspace(*html)){html++;} there may be leading blanks in some autogenerated files 894 /* while(isspace(*html)){html++;} there may be leading blanks in some autogenerated files
895 add this or not, that is the question ;-)) */ 895 add this or not, that is the question ;-)) */
896 896
897 if (pc->lhtml_script_passthru != 0) { 897 if (pc->lhtml_script_passthru != 0) {
898 const char *text; 898 const char *text;
899 char *tmp; 899 char *tmp;
900 900
901 text = html; 901 text = html;
902 if (pc->lhtml_script_passthru == 1 ){ 902 if (pc->lhtml_script_passthru == 1 ){
903 while(*text != '\0') { 903 while(*text != '\0') {
@@ -924,12 +924,12 @@ static void parse (const char *html, struct PC_ * pc) {
924 } 924 }
925 tmp = (char *) malloc((size_t)(text-html+1)); 925 tmp = (char *) malloc((size_t)(text-html+1));
926 if (tmp == NULL) { 926 if (tmp == NULL) {
927 fprintf(stderr, 927 fprintf(stderr,
928 _("Fatal: could not allocate (%s at %s:%d).\n"), 928 _("Fatal: could not allocate (%s at %s:%d).\n"),
929 strerror(errno), __FILE__, __LINE__); 929 strerror(errno), __FILE__, __LINE__);
930 return; 930 return;
931 } 931 }
932 932
933 strncpy(tmp, html, (size_t)(text-html)); 933 strncpy(tmp, html, (size_t)(text-html));
934 tmp[text-html] = '\0'; /* strncpy does not zero-terminate! */ 934 tmp[text-html] = '\0'; /* strncpy does not zero-terminate! */
935 if (pc->textCallBack != NULL) { 935 if (pc->textCallBack != NULL) {
@@ -937,21 +937,21 @@ static void parse (const char *html, struct PC_ * pc) {
937 if (ret != 0) { 937 if (ret != 0) {
938 free(tmp); 938 free(tmp);
939 tmp = NULL; 939 tmp = NULL;
940 940
941 return; 941 return;
942 } 942 }
943 } 943 }
944 944
945 free(tmp); 945 free(tmp);
946 tmp = NULL; 946 tmp = NULL;
947 947
948 pc->lhtml_script_passthru = 0; 948 pc->lhtml_script_passthru = 0;
949 html = text; 949 html = text;
950 } 950 }
951 951
952 if(*html == '<'){ 952 if(*html == '<'){
953 html++; 953 html++;
954 954
955 switch (*html){ 955 switch (*html){
956 case '!' : 956 case '!' :
957 html++; 957 html++;
@@ -1005,7 +1005,7 @@ static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordType type,
1005 if (keyword == NULL) 1005 if (keyword == NULL)
1006 return next; 1006 return next;
1007 result = (EXTRACTOR_KeywordList*)malloc(sizeof(EXTRACTOR_KeywordList)); 1007 result = (EXTRACTOR_KeywordList*)malloc(sizeof(EXTRACTOR_KeywordList));
1008 result->next = next; 1008 result->next = next;
1009 result->keyword = strdup(keyword); 1009 result->keyword = strdup(keyword);
1010 result->keywordType = type; 1010 result->keywordType = type;
1011 return result; 1011 return result;
@@ -1043,7 +1043,7 @@ static char * getTag(char * arg,
1043 struct ArgvTable * args, 1043 struct ArgvTable * args,
1044 int numargs) { 1044 int numargs) {
1045 int i; 1045 int i;
1046 for (i=0;i<numargs;i++) 1046 for (i=0;i<numargs;i++)
1047 if (0 == strcasecmp(args[i].arg, arg)) 1047 if (0 == strcasecmp(args[i].arg, arg))
1048 return args[i].val; 1048 return args[i].val;
1049 return NULL; 1049 return NULL;
@@ -1053,10 +1053,10 @@ static struct {
1053 char * name; 1053 char * name;
1054 EXTRACTOR_KeywordType type; 1054 EXTRACTOR_KeywordType type;
1055} tagmap[] = { 1055} tagmap[] = {
1056 { "author" , EXTRACTOR_AUTHOR}, 1056 { "author" , EXTRACTOR_AUTHOR},
1057 { "description" , EXTRACTOR_DESCRIPTION}, 1057 { "description" , EXTRACTOR_DESCRIPTION},
1058 { "language", EXTRACTOR_LANGUAGE}, 1058 { "language", EXTRACTOR_LANGUAGE},
1059 { "rights", EXTRACTOR_COPYRIGHT}, 1059 { "rights", EXTRACTOR_COPYRIGHT},
1060 { "publisher", EXTRACTOR_PUBLISHER}, 1060 { "publisher", EXTRACTOR_PUBLISHER},
1061 { "date", EXTRACTOR_DATE}, 1061 { "date", EXTRACTOR_DATE},
1062 { "keywords", EXTRACTOR_KEYWORDS}, 1062 { "keywords", EXTRACTOR_KEYWORDS},
@@ -1065,8 +1065,8 @@ static struct {
1065 1065
1066 1066
1067 1067
1068static int starttag(char *tag, 1068static int starttag(char *tag,
1069 struct ArgvTable *args, 1069 struct ArgvTable *args,
1070 int numargs, 1070 int numargs,
1071 struct PC_ * pc) { 1071 struct PC_ * pc) {
1072 int i; 1072 int i;
@@ -1075,11 +1075,11 @@ static int starttag(char *tag,
1075 pc->nextTextAction = 1; 1075 pc->nextTextAction = 1;
1076 pc->nextKeywordType = EXTRACTOR_TITLE; 1076 pc->nextKeywordType = EXTRACTOR_TITLE;
1077 return 0; 1077 return 0;
1078 } 1078 }
1079 if (0 == strcasecmp(tag,"meta")) { 1079 if (0 == strcasecmp(tag,"meta")) {
1080 i = 0; 1080 i = 0;
1081 while (tagmap[i].name != NULL) { 1081 while (tagmap[i].name != NULL) {
1082 if (hasTag("name",tagmap[i].name,args, numargs)) 1082 if (hasTag("name",tagmap[i].name,args, numargs))
1083 pc->result = addKeyword(tagmap[i].type, 1083 pc->result = addKeyword(tagmap[i].type,
1084 getTag("content", 1084 getTag("content",
1085 args, numargs), 1085 args, numargs),
@@ -1094,8 +1094,8 @@ static int starttag(char *tag,
1094 "text/html", 1094 "text/html",
1095 pc->result); 1095 pc->result);
1096 return 0; 1096 return 0;
1097 } 1097 }
1098#endif 1098#endif
1099 if ( (tag != NULL) && 1099 if ( (tag != NULL) &&
1100 ( (0 == strcasecmp(tag, "body")) || 1100 ( (0 == strcasecmp(tag, "body")) ||
1101 (0 == strcasecmp(tag, "/body")) ) ) 1101 (0 == strcasecmp(tag, "/body")) ) )
@@ -1174,7 +1174,7 @@ struct EXTRACTOR_Keywords * libextractor_html_extract(const char * filename,
1174 return prev; 1174 return prev;
1175 j++; 1175 j++;
1176 } 1176 }
1177 } 1177 }
1178 1178
1179 memset(&pc, 1179 memset(&pc,
1180 0, 1180 0,
@@ -1186,14 +1186,14 @@ struct EXTRACTOR_Keywords * libextractor_html_extract(const char * filename,
1186 if (size > 1024 * 32) 1186 if (size > 1024 * 32)
1187 xsize = 1024 * 32; 1187 xsize = 1024 * 32;
1188 else 1188 else
1189 xsize = size; 1189 xsize = size;
1190 /* the parser requires 0-termination. We just 1190 /* the parser requires 0-termination. We just
1191 overwrite the last character in data and 1191 overwrite the last character in data and
1192 restore it later, assuming that it can 1192 restore it later, assuming that it can
1193 hardly be a keyword in a valid HTML text... 1193 hardly be a keyword in a valid HTML text...
1194 */ 1194 */
1195 backup = data[xsize-1]; 1195 backup = data[xsize-1];
1196 data[xsize-1] = '\0'; 1196 data[xsize-1] = '\0';
1197 parse(data, &pc); 1197 parse(data, &pc);
1198 data[xsize-1] = backup; 1198 data[xsize-1] = backup;
1199 return pc.result; 1199 return pc.result;
diff --git a/src/plugins/id3v23extractor.c b/src/plugins/id3v23extractor.c
index 5edc7f0..94aabd5 100644
--- a/src/plugins/id3v23extractor.c
+++ b/src/plugins/id3v23extractor.c
@@ -36,13 +36,13 @@
36 36
37#include "convert.h" 37#include "convert.h"
38 38
39static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead, 39static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead,
40 char *phrase, 40 char *phrase,
41 EXTRACTOR_KeywordType type) { 41 EXTRACTOR_KeywordType type) {
42 EXTRACTOR_KeywordList * keyword; 42 EXTRACTOR_KeywordList * keyword;
43 43
44 keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList)); 44 keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList));
45 keyword->next = oldhead; 45 keyword->next = oldhead;
46 keyword->keyword = phrase; 46 keyword->keyword = phrase;
47 keyword->keywordType = type; 47 keyword->keywordType = type;
48 return keyword; 48 return keyword;
@@ -90,7 +90,7 @@ static Matches tmap[] = {
90 90
91 91
92/* mimetype = audio/mpeg */ 92/* mimetype = audio/mpeg */
93struct EXTRACTOR_Keywords * 93struct EXTRACTOR_Keywords *
94libextractor_id3v23_extract(const char * filename, 94libextractor_id3v23_extract(const char * filename,
95 const unsigned char * data, 95 const unsigned char * data,
96 const size_t size, 96 const size_t size,
@@ -125,12 +125,12 @@ libextractor_id3v23_extract(const char * filename,
125 ehdrSize = ( ( (data[10]) << 24 ) | 125 ehdrSize = ( ( (data[10]) << 24 ) |
126 ( (data[11]) << 16 ) | 126 ( (data[11]) << 16 ) |
127 ( (data[12]) << 8 ) | 127 ( (data[12]) << 8 ) |
128 ( (data[12]) << 0 ) ); 128 ( (data[12]) << 0 ) );
129 129
130 padding = ( ( (data[15]) << 24 ) | 130 padding = ( ( (data[15]) << 24 ) |
131 ( (data[16]) << 16 ) | 131 ( (data[16]) << 16 ) |
132 ( (data[17]) << 8 ) | 132 ( (data[17]) << 8 ) |
133 ( (data[18]) << 0 ) ); 133 ( (data[18]) << 0 ) );
134 pos += 4 + ehdrSize; 134 pos += 4 + ehdrSize;
135 if (padding < tsize) 135 if (padding < tsize)
136 tsize -= padding; 136 tsize -= padding;
diff --git a/src/plugins/id3v24extractor.c b/src/plugins/id3v24extractor.c
index 890d134..7df1626 100644
--- a/src/plugins/id3v24extractor.c
+++ b/src/plugins/id3v24extractor.c
@@ -36,13 +36,13 @@
36#include "convert.h" 36#include "convert.h"
37 37
38 38
39static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead, 39static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead,
40 char *phrase, 40 char *phrase,
41 EXTRACTOR_KeywordType type) { 41 EXTRACTOR_KeywordType type) {
42 EXTRACTOR_KeywordList * keyword; 42 EXTRACTOR_KeywordList * keyword;
43 43
44 keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList)); 44 keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList));
45 keyword->next = oldhead; 45 keyword->next = oldhead;
46 keyword->keyword = phrase; 46 keyword->keyword = phrase;
47 keyword->keywordType = type; 47 keyword->keywordType = type;
48 return keyword; 48 return keyword;
@@ -89,7 +89,7 @@ static Matches tmap[] = {
89 89
90 90
91/* mimetype = audio/mpeg */ 91/* mimetype = audio/mpeg */
92struct EXTRACTOR_Keywords * 92struct EXTRACTOR_Keywords *
93libextractor_id3v24_extract(const char * filename, 93libextractor_id3v24_extract(const char * filename,
94 const unsigned char * data, 94 const unsigned char * data,
95 const size_t size, 95 const size_t size,
@@ -143,7 +143,7 @@ libextractor_id3v24_extract(const char * filename,
143 ( (data[pos+5] & 0x7F) << 14 ) | 143 ( (data[pos+5] & 0x7F) << 14 ) |
144 ( (data[pos+6] & 0x7F) << 7 ) | 144 ( (data[pos+6] & 0x7F) << 7 ) |
145 ( (data[pos+7] & 0x7F) << 0 ) ); 145 ( (data[pos+7] & 0x7F) << 0 ) );
146 146
147 if ( (pos + 10 + csize > tsize) || 147 if ( (pos + 10 + csize > tsize) ||
148 (csize > tsize) || 148 (csize > tsize) ||
149 (csize == 0) ) 149 (csize == 0) )
@@ -186,7 +186,7 @@ libextractor_id3v24_extract(const char * filename,
186 "UTF-16BE"); 186 "UTF-16BE");
187 break; 187 break;
188 case 0x03 : 188 case 0x03 :
189 word = malloc(csize+1); 189 word = malloc(csize+1);
190 memcpy(word, 190 memcpy(word,
191 &data[pos+11], 191 &data[pos+11],
192 csize); 192 csize);
diff --git a/src/plugins/id3v2extractor.c b/src/plugins/id3v2extractor.c
index 7fc99dd..2f062cd 100644
--- a/src/plugins/id3v2extractor.c
+++ b/src/plugins/id3v2extractor.c
@@ -29,13 +29,13 @@
29#define DEBUG_EXTRACT_ID3v2 0 29#define DEBUG_EXTRACT_ID3v2 0
30 30
31 31
32static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead, 32static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead,
33 char *phrase, 33 char *phrase,
34 EXTRACTOR_KeywordType type) { 34 EXTRACTOR_KeywordType type) {
35 EXTRACTOR_KeywordList * keyword; 35 EXTRACTOR_KeywordList * keyword;
36 36
37 keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList)); 37 keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList));
38 keyword->next = oldhead; 38 keyword->next = oldhead;
39 keyword->keyword = phrase; 39 keyword->keyword = phrase;
40 keyword->keywordType = type; 40 keyword->keywordType = type;
41 return keyword; 41 return keyword;
@@ -104,7 +104,7 @@ struct EXTRACTOR_Keywords * libextractor_id3v2_extract(char * filename,
104 ( (data[7] & 0x7F) << 14 ) | 104 ( (data[7] & 0x7F) << 14 ) |
105 ( (data[8] & 0x7F) << 07 ) | 105 ( (data[8] & 0x7F) << 07 ) |
106 ( (data[9] & 0x7F) << 00 ) ); 106 ( (data[9] & 0x7F) << 00 ) );
107 107
108 if (tsize + 10 > size) 108 if (tsize + 10 > size)
109 return prev; 109 return prev;
110 pos = 10; 110 pos = 10;
diff --git a/src/plugins/jpegextractor.c b/src/plugins/jpegextractor.c
index 4b03c7a..210f1f2 100644
--- a/src/plugins/jpegextractor.c
+++ b/src/plugins/jpegextractor.c
@@ -37,7 +37,7 @@ static EXTRACTOR_KeywordList * addKeyword(EXTRACTOR_KeywordType type,
37 if (keyword == NULL) 37 if (keyword == NULL)
38 return next; 38 return next;
39 result = malloc(sizeof(EXTRACTOR_KeywordList)); 39 result = malloc(sizeof(EXTRACTOR_KeywordList));
40 result->next = next; 40 result->next = next;
41 result->keyword = keyword; 41 result->keyword = keyword;
42 result->keywordType = type; 42 result->keywordType = type;
43 return result; 43 return result;
@@ -56,14 +56,14 @@ unsigned int NEXTC(unsigned char ** data, char * end) {
56 char result = **data; 56 char result = **data;
57 (*data)++; 57 (*data)++;
58 return result; 58 return result;
59 } else 59 } else
60 return -1; 60 return -1;
61} 61}
62*/ 62*/
63 63
64/** 64/**
65 * Read length, convert to unsigned int. 65 * Read length, convert to unsigned int.
66 * All 2-byte quantities in JPEG markers are MSB first 66 * All 2-byte quantities in JPEG markers are MSB first
67 * @return -1 on error 67 * @return -1 on error
68 */ 68 */
69static int readLength(unsigned char ** data, 69static int readLength(unsigned char ** data,
@@ -83,19 +83,19 @@ static int readLength(unsigned char ** data,
83/** 83/**
84 * @return the next marker or -1 on error. 84 * @return the next marker or -1 on error.
85 */ 85 */
86static int next_marker(unsigned char ** data, 86static int next_marker(unsigned char ** data,
87 unsigned char * end) { 87 unsigned char * end) {
88 int c; 88 int c;
89 c = NEXTC(data, end); 89 c = NEXTC(data, end);
90 while ( (c != 0xFF) && (c != -1) ) 90 while ( (c != 0xFF) && (c != -1) )
91 c = NEXTC(data, end); 91 c = NEXTC(data, end);
92 do { 92 do {
93 c = NEXTC(data, end); 93 c = NEXTC(data, end);
94 } while ( (c == 0xFF) && (c != -1) ); 94 } while ( (c == 0xFF) && (c != -1) );
95 return c; 95 return c;
96} 96}
97 97
98static void skip_variable(unsigned char ** data, 98static void skip_variable(unsigned char ** data,
99 unsigned char * end) { 99 unsigned char * end) {
100 int length; 100 int length;
101 101
@@ -108,7 +108,7 @@ static void skip_variable(unsigned char ** data,
108 (*data) += length; 108 (*data) += length;
109} 109}
110 110
111static char * process_COM(unsigned char ** data, 111static char * process_COM(unsigned char ** data,
112 unsigned char * end) { 112 unsigned char * end) {
113 unsigned int length; 113 unsigned int length;
114 int ch; 114 int ch;
@@ -117,7 +117,7 @@ static char * process_COM(unsigned char ** data,
117 117
118 length = readLength(data, end); 118 length = readLength(data, end);
119 if (length <= 0) 119 if (length <= 0)
120 return NULL; 120 return NULL;
121 comment = malloc(length+1); 121 comment = malloc(length+1);
122 pos = 0; 122 pos = 0;
123 while (length > 0) { 123 while (length > 0) {
@@ -125,8 +125,8 @@ static char * process_COM(unsigned char ** data,
125 if ( (ch == '\r') || 125 if ( (ch == '\r') ||
126 (ch == '\n') ) 126 (ch == '\n') )
127 comment[pos++] = '\n'; 127 comment[pos++] = '\n';
128 else if (isprint(ch)) 128 else if (isprint(ch))
129 comment[pos++] = ch; 129 comment[pos++] = ch;
130 length--; 130 length--;
131 } 131 }
132 comment[pos] = '\0'; 132 comment[pos] = '\0';
@@ -160,12 +160,12 @@ struct EXTRACTOR_Keywords * libextractor_jpeg_extract(const char * filename,
160 case -1: /* end of file */ 160 case -1: /* end of file */
161 case M_SOS: 161 case M_SOS:
162 case M_EOI: 162 case M_EOI:
163 goto RETURN; /* this used to be "return result", but this 163 goto RETURN; /* this used to be "return result", but this
164 makes certain compilers unhappy...*/ 164 makes certain compilers unhappy...*/
165 case M_APP0: { 165 case M_APP0: {
166 int len = readLength(&data, end); 166 int len = readLength(&data, end);
167 if (len < 0x8) 167 if (len < 0x8)
168 goto RETURN; 168 goto RETURN;
169 if (0 == strncmp(data, 169 if (0 == strncmp(data,
170 "JFIF", 170 "JFIF",
171 4)) { 171 4)) {
@@ -213,7 +213,7 @@ struct EXTRACTOR_Keywords * libextractor_jpeg_extract(const char * filename,
213 char * val; 213 char * val;
214 int len = readLength(&data, end); 214 int len = readLength(&data, end);
215 if (len < 0x9) 215 if (len < 0x9)
216 goto RETURN; 216 goto RETURN;
217 val = malloc(128); 217 val = malloc(128);
218 snprintf(val, 128, 218 snprintf(val, 128,
219 "%ux%u", 219 "%ux%u",
@@ -222,7 +222,7 @@ struct EXTRACTOR_Keywords * libextractor_jpeg_extract(const char * filename,
222 result = addKeyword(EXTRACTOR_SIZE, 222 result = addKeyword(EXTRACTOR_SIZE,
223 val, 223 val,
224 result); 224 result);
225 data = &data[len]; 225 data = &data[len];
226 break; 226 break;
227 } 227 }
228 case M_COM: 228 case M_COM:
diff --git a/src/plugins/lowerextractor.c b/src/plugins/lowerextractor.c
index 6363ac7..02bb6a7 100644
--- a/src/plugins/lowerextractor.c
+++ b/src/plugins/lowerextractor.c
@@ -26,7 +26,7 @@ static void addKeyword(struct EXTRACTOR_Keywords ** list,
26 EXTRACTOR_KeywordType type) { 26 EXTRACTOR_KeywordType type) {
27 EXTRACTOR_KeywordList * next; 27 EXTRACTOR_KeywordList * next;
28 next = malloc(sizeof(EXTRACTOR_KeywordList)); 28 next = malloc(sizeof(EXTRACTOR_KeywordList));
29 next->next = *list; 29 next->next = *list;
30 next->keyword = strdup(keyword); 30 next->keyword = strdup(keyword);
31 next->keywordType = type; 31 next->keywordType = type;
32 *list = next; 32 *list = next;
diff --git a/src/plugins/manextractor.c b/src/plugins/manextractor.c
index 8ccffa9..3b60cb5 100644
--- a/src/plugins/manextractor.c
+++ b/src/plugins/manextractor.c
@@ -65,14 +65,14 @@ static void NEXT(size_t * end,
65 const char * buf, 65 const char * buf,
66 const size_t size) { 66 const size_t size) {
67 int quot; 67 int quot;
68 68
69 quot = 0; 69 quot = 0;
70 while ( (*end < size) && 70 while ( (*end < size) &&
71 ( ((quot & 1) != 0) || 71 ( ((quot & 1) != 0) ||
72 ( (buf[*end] != ' ') ) ) ) { 72 ( (buf[*end] != ' ') ) ) ) {
73 if (buf[*end] == '\"') 73 if (buf[*end] == '\"')
74 quot++; 74 quot++;
75 (*end)++; 75 (*end)++;
76 } 76 }
77 if ((quot & 1) == 1) 77 if ((quot & 1) == 1)
78 (*end) = size+1; 78 (*end) = size+1;
@@ -84,7 +84,7 @@ static struct EXTRACTOR_Keywords * tryParse(const char * buf,
84 int pos; 84 int pos;
85 size_t xsize; 85 size_t xsize;
86 const size_t xlen = strlen(".TH "); 86 const size_t xlen = strlen(".TH ");
87 87
88 pos = 0; 88 pos = 0;
89 if (size < xlen) 89 if (size < xlen)
90 return prev; 90 return prev;
@@ -100,12 +100,12 @@ static struct EXTRACTOR_Keywords * tryParse(const char * buf,
100 (buf[xsize] != '\n') ) 100 (buf[xsize] != '\n') )
101 xsize++; 101 xsize++;
102 size = xsize; 102 size = xsize;
103 103
104 if (0 == strncmp(".TH ", 104 if (0 == strncmp(".TH ",
105 &buf[pos], 105 &buf[pos],
106 xlen)) { 106 xlen)) {
107 int end; 107 int end;
108 108
109 pos += xlen; 109 pos += xlen;
110 end = pos; 110 end = pos;
111 NEXT(&end, buf, size); if (end > size) return prev; 111 NEXT(&end, buf, size); if (end > size) return prev;
@@ -113,19 +113,19 @@ static struct EXTRACTOR_Keywords * tryParse(const char * buf,
113 prev = addKeyword(EXTRACTOR_TITLE, 113 prev = addKeyword(EXTRACTOR_TITLE,
114 stndup(&buf[pos], 114 stndup(&buf[pos],
115 end - pos), 115 end - pos),
116 prev); 116 prev);
117 pos = end + 1; 117 pos = end + 1;
118 } 118 }
119 if (pos >= size) return prev; 119 if (pos >= size) return prev;
120 end = pos; 120 end = pos;
121 NEXT(&end, buf, size); if (end > size) return prev; 121 NEXT(&end, buf, size); if (end > size) return prev;
122 if (buf[pos] == '\"') 122 if (buf[pos] == '\"')
123 pos++; 123 pos++;
124 if ( (end-pos >= 1) && (end - pos <= 4) ) { 124 if ( (end-pos >= 1) && (end - pos <= 4) ) {
125 switch (buf[pos]) { 125 switch (buf[pos]) {
126 case '1': 126 case '1':
127 prev = addKeyword(EXTRACTOR_CATEGORY, 127 prev = addKeyword(EXTRACTOR_CATEGORY,
128 strdup(_("Commands")), 128 strdup(_("Commands")),
129 prev); 129 prev);
130 break; 130 break;
131 case '2': 131 case '2':
@@ -177,7 +177,7 @@ static struct EXTRACTOR_Keywords * tryParse(const char * buf,
177 prev = addKeyword(EXTRACTOR_DATE, 177 prev = addKeyword(EXTRACTOR_DATE,
178 stndup(&buf[pos], 178 stndup(&buf[pos],
179 end - pos), 179 end - pos),
180 prev); 180 prev);
181 pos = end + 1; 181 pos = end + 1;
182 } 182 }
183 end = pos; 183 end = pos;
@@ -186,7 +186,7 @@ static struct EXTRACTOR_Keywords * tryParse(const char * buf,
186 prev = addKeyword(EXTRACTOR_SOURCE, 186 prev = addKeyword(EXTRACTOR_SOURCE,
187 stndup(&buf[pos], 187 stndup(&buf[pos],
188 end - pos), 188 end - pos),
189 prev); 189 prev);
190 pos = end + 1; 190 pos = end + 1;
191 } 191 }
192 end = pos; 192 end = pos;
@@ -195,9 +195,9 @@ static struct EXTRACTOR_Keywords * tryParse(const char * buf,
195 prev = addKeyword(EXTRACTOR_BOOKTITLE, 195 prev = addKeyword(EXTRACTOR_BOOKTITLE,
196 stndup(&buf[pos], 196 stndup(&buf[pos],
197 end - pos), 197 end - pos),
198 prev); 198 prev);
199 pos = end + 1; 199 pos = end + 1;
200 } 200 }
201 } 201 }
202 202
203 return prev; 203 return prev;
@@ -216,7 +216,7 @@ struct EXTRACTOR_Keywords * libextractor_man_extract(const char * filename,
216 gzFile gz; 216 gzFile gz;
217 char * buf; 217 char * buf;
218 int len; 218 int len;
219 219
220 gz = gzopen(filename, "rb"); 220 gz = gzopen(filename, "rb");
221 buf = malloc(MAX_READ); 221 buf = malloc(MAX_READ);
222 len = gzread(gz, buf, MAX_READ); 222 len = gzread(gz, buf, MAX_READ);
diff --git a/src/plugins/mimeextractor.c b/src/plugins/mimeextractor.c
index c47ea2f..3ad05a2 100644
--- a/src/plugins/mimeextractor.c
+++ b/src/plugins/mimeextractor.c
@@ -30,7 +30,7 @@ static EXTRACTOR_KeywordList * addKeyword(EXTRACTOR_KeywordType type,
30 if (keyword == NULL) 30 if (keyword == NULL)
31 return next; 31 return next;
32 result = malloc(sizeof(EXTRACTOR_KeywordList)); 32 result = malloc(sizeof(EXTRACTOR_KeywordList));
33 result->next = next; 33 result->next = next;
34 result->keyword = keyword; 34 result->keyword = keyword;
35 result->keywordType = type; 35 result->keywordType = type;
36 return result; 36 return result;
@@ -53,7 +53,7 @@ typedef int (*Detector)(char * data,
53 * @param len the length of the file 53 * @param len the length of the file
54 * @return always 1 54 * @return always 1
55 **/ 55 **/
56static int defaultDetector(char * data, 56static int defaultDetector(char * data,
57 size_t len, 57 size_t len,
58 void * arg) { 58 void * arg) {
59 return 1; 59 return 1;
@@ -65,7 +65,7 @@ static int defaultDetector(char * data,
65 * @param len the length of the file 65 * @param len the length of the file
66 * @return always 0 66 * @return always 0
67 **/ 67 **/
68static int disableDetector(char * data, 68static int disableDetector(char * data,
69 size_t len, 69 size_t len,
70 void * arg) { 70 void * arg) {
71 return 0; 71 return 0;
@@ -101,7 +101,7 @@ static ExtraPattern xpatterns[] = {
101 { 0, 0, NULL }, 101 { 0, 0, NULL },
102#define ACON_XPATTERN 12 102#define ACON_XPATTERN 12
103 { 8, 4, "ACON"}, 103 { 8, 4, "ACON"},
104 { 0, 0, NULL}, 104 { 0, 0, NULL},
105}; 105};
106 106
107/** 107/**
@@ -110,7 +110,7 @@ static ExtraPattern xpatterns[] = {
110 * entries in the main table, so this "AND" (all match) semantics are 110 * entries in the main table, so this "AND" (all match) semantics are
111 * the only reasonable answer. 111 * the only reasonable answer.
112 **/ 112 **/
113static int xPatternMatcher(char * data, 113static int xPatternMatcher(char * data,
114 size_t len, 114 size_t len,
115 ExtraPattern * arg) { 115 ExtraPattern * arg) {
116 while (arg->pattern != NULL) { 116 while (arg->pattern != NULL) {
@@ -152,8 +152,8 @@ typedef struct Pattern {
152 152
153static Pattern patterns[] = { 153static Pattern patterns[] = {
154 { "\xFF\xD8", 2, "image/jpeg", DEFAULT}, 154 { "\xFF\xD8", 2, "image/jpeg", DEFAULT},
155 { "\211PNG\r\n\032\n", 8, "image/png", DEFAULT}, 155 { "\211PNG\r\n\032\n", 8, "image/png", DEFAULT},
156 { "/* XPM */", 9, "image/x-xpm", DEFAULT}, 156 { "/* XPM */", 9, "image/x-xpm", DEFAULT},
157 { "GIF8", 4, "image/gif", DEFAULT}, 157 { "GIF8", 4, "image/gif", DEFAULT},
158 { "P1", 2, "image/x-portable-bitmap", DEFAULT}, 158 { "P1", 2, "image/x-portable-bitmap", DEFAULT},
159 { "P2", 2, "image/x-portable-graymap", DEFAULT}, 159 { "P2", 2, "image/x-portable-graymap", DEFAULT},
@@ -168,9 +168,9 @@ static Pattern patterns[] = {
168 { "hsi1", 4, "image/x-jpeg-proprietary", DEFAULT}, 168 { "hsi1", 4, "image/x-jpeg-proprietary", DEFAULT},
169 { "\x2E\x52\x4d\x46", 4, "video/real", DEFAULT}, 169 { "\x2E\x52\x4d\x46", 4, "video/real", DEFAULT},
170 { "\x2e\x72\x61\xfd", 4, "audio/real", DEFAULT}, 170 { "\x2e\x72\x61\xfd", 4, "audio/real", DEFAULT},
171 { "\177ELF", 4, "application/elf", DEFAULT}, 171 { "\177ELF", 4, "application/elf", DEFAULT},
172 /* FIXME: correct MIME-type for an ELF!? */ 172 /* FIXME: correct MIME-type for an ELF!? */
173 { "\xca\xfe\xba\xbe", 4, "application/java", DEFAULT}, 173 { "\xca\xfe\xba\xbe", 4, "application/java", DEFAULT},
174 /* FIXME: correct MIME for a class-file? */ 174 /* FIXME: correct MIME for a class-file? */
175 { "gimp xcf", 8, "image/xcf", DEFAULT}, 175 { "gimp xcf", 8, "image/xcf", DEFAULT},
176 { "IIN1", 4, "image/tiff", DEFAULT}, 176 { "IIN1", 4, "image/tiff", DEFAULT},
@@ -183,13 +183,13 @@ static Pattern patterns[] = {
183 { "RIFF", 4, "audio/x-wav", XPATTERN(WAVE_XPATTERN)}, 183 { "RIFF", 4, "audio/x-wav", XPATTERN(WAVE_XPATTERN)},
184 { "RIFX", 4, "video/avi", XPATTERN(AVI_XPATTERN)}, 184 { "RIFX", 4, "video/avi", XPATTERN(AVI_XPATTERN)},
185 { "RIFX", 4, "audio/x-wav", XPATTERN(WAVE_XPATTERN)}, 185 { "RIFX", 4, "audio/x-wav", XPATTERN(WAVE_XPATTERN)},
186 { "RIFF", 4, "audio/midi", XPATTERN(RMID_XPATTERN)}, 186 { "RIFF", 4, "audio/midi", XPATTERN(RMID_XPATTERN)},
187 { "RIFX", 4, "audio/midi", XPATTERN(RMID_XPATTERN)}, 187 { "RIFX", 4, "audio/midi", XPATTERN(RMID_XPATTERN)},
188 { "RIFF", 4, "image/x-animated-cursor", XPATTERN(ACON_XPATTERN)}, 188 { "RIFF", 4, "image/x-animated-cursor", XPATTERN(ACON_XPATTERN)},
189 { "RIFX", 4, "image/x-animated-cursor", XPATTERN(ACON_XPATTERN)}, 189 { "RIFX", 4, "image/x-animated-cursor", XPATTERN(ACON_XPATTERN)},
190 { "\211GND\r\n\032\n", 8, "application/gnunet-directory", DEFAULT}, 190 { "\211GND\r\n\032\n", 8, "application/gnunet-directory", DEFAULT},
191 { "{\\rtf", 5, "application/rtf", DEFAULT}, 191 { "{\\rtf", 5, "application/rtf", DEFAULT},
192 { "\xf7\x02", 2, "application/x-dvi", DEFAULT}, 192 { "\xf7\x02", 2, "application/x-dvi", DEFAULT},
193 { "\x1F\x8B\x08\x00", 4, "application/x-gzip", DEFAULT}, 193 { "\x1F\x8B\x08\x00", 4, "application/x-gzip", DEFAULT},
194 { "BZh91AY&SY", 10, "application/bz2", DEFAULT}, 194 { "BZh91AY&SY", 10, "application/bz2", DEFAULT},
195 { "\xED\xAB\xEE\xDB", 4, "application/x-rpm", DEFAULT}, /* binary */ 195 { "\xED\xAB\xEE\xDB", 4, "application/x-rpm", DEFAULT}, /* binary */
diff --git a/src/plugins/mp3extractor.c b/src/plugins/mp3extractor.c
index e5a00d2..b61d181 100644
--- a/src/plugins/mp3extractor.c
+++ b/src/plugins/mp3extractor.c
@@ -18,7 +18,7 @@
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 19
20 20
21 Some of this code is based on AVInfo 1.0 alpha 11 21 Some of this code is based on AVInfo 1.0 alpha 11
22 (c) George Shuklin, gs]AT[shounen.ru, 2002-2004 22 (c) George Shuklin, gs]AT[shounen.ru, 2002-2004
23 http://shounen.ru/soft/avinfo/ 23 http://shounen.ru/soft/avinfo/
24 24
@@ -47,19 +47,19 @@ typedef struct {
47 47
48static const char *const genre_names[] = { 48static const char *const genre_names[] = {
49 gettext_noop("Blues"), 49 gettext_noop("Blues"),
50 gettext_noop("Classic Rock"), 50 gettext_noop("Classic Rock"),
51 gettext_noop("Country"), 51 gettext_noop("Country"),
52 gettext_noop("Dance"), 52 gettext_noop("Dance"),
53 gettext_noop("Disco"), 53 gettext_noop("Disco"),
54 gettext_noop("Funk"), 54 gettext_noop("Funk"),
55 gettext_noop("Grunge"), 55 gettext_noop("Grunge"),
56 gettext_noop("Hip-Hop"), 56 gettext_noop("Hip-Hop"),
57 gettext_noop("Jazz"), 57 gettext_noop("Jazz"),
58 gettext_noop("Metal"), 58 gettext_noop("Metal"),
59 gettext_noop("New Age"), 59 gettext_noop("New Age"),
60 gettext_noop("Oldies"), 60 gettext_noop("Oldies"),
61 gettext_noop("Other"), 61 gettext_noop("Other"),
62 gettext_noop("Pop"), 62 gettext_noop("Pop"),
63 gettext_noop("R&B"), 63 gettext_noop("R&B"),
64 gettext_noop("Rap"), 64 gettext_noop("Rap"),
65 gettext_noop("Reggae"), 65 gettext_noop("Reggae"),
@@ -68,57 +68,57 @@ static const char *const genre_names[] = {
68 gettext_noop("Industrial"), 68 gettext_noop("Industrial"),
69 gettext_noop("Alternative"), 69 gettext_noop("Alternative"),
70 gettext_noop("Ska"), 70 gettext_noop("Ska"),
71 gettext_noop("Death Metal"), 71 gettext_noop("Death Metal"),
72 gettext_noop("Pranks"), 72 gettext_noop("Pranks"),
73 gettext_noop("Soundtrack"), 73 gettext_noop("Soundtrack"),
74 gettext_noop("Euro-Techno"), 74 gettext_noop("Euro-Techno"),
75 gettext_noop("Ambient"), 75 gettext_noop("Ambient"),
76 gettext_noop("Trip-Hop"), 76 gettext_noop("Trip-Hop"),
77 gettext_noop("Vocal"), 77 gettext_noop("Vocal"),
78 gettext_noop("Jazz+Funk"), 78 gettext_noop("Jazz+Funk"),
79 gettext_noop("Fusion"), 79 gettext_noop("Fusion"),
80 gettext_noop("Trance"), 80 gettext_noop("Trance"),
81 gettext_noop("Classical"), 81 gettext_noop("Classical"),
82 gettext_noop("Instrumental"), 82 gettext_noop("Instrumental"),
83 gettext_noop("Acid"), 83 gettext_noop("Acid"),
84 gettext_noop("House"), 84 gettext_noop("House"),
85 gettext_noop("Game"), 85 gettext_noop("Game"),
86 gettext_noop("Sound Clip"), 86 gettext_noop("Sound Clip"),
87 gettext_noop("Gospel"), 87 gettext_noop("Gospel"),
88 gettext_noop("Noise"), 88 gettext_noop("Noise"),
89 gettext_noop("Alt. Rock"), 89 gettext_noop("Alt. Rock"),
90 gettext_noop("Bass"), 90 gettext_noop("Bass"),
91 gettext_noop("Soul"), 91 gettext_noop("Soul"),
92 gettext_noop("Punk"), 92 gettext_noop("Punk"),
93 gettext_noop("Space"), 93 gettext_noop("Space"),
94 gettext_noop("Meditative"), 94 gettext_noop("Meditative"),
95 gettext_noop("Instrumental Pop"), 95 gettext_noop("Instrumental Pop"),
96 gettext_noop("Instrumental Rock"), 96 gettext_noop("Instrumental Rock"),
97 gettext_noop("Ethnic"), 97 gettext_noop("Ethnic"),
98 gettext_noop("Gothic"), 98 gettext_noop("Gothic"),
99 gettext_noop("Darkwave"), 99 gettext_noop("Darkwave"),
100 gettext_noop("Techno-Industrial"), 100 gettext_noop("Techno-Industrial"),
101 gettext_noop("Electronic"), 101 gettext_noop("Electronic"),
102 gettext_noop("Pop-Folk"), 102 gettext_noop("Pop-Folk"),
103 gettext_noop("Eurodance"), 103 gettext_noop("Eurodance"),
104 gettext_noop("Dream"), 104 gettext_noop("Dream"),
105 gettext_noop("Southern Rock"), 105 gettext_noop("Southern Rock"),
106 gettext_noop("Comedy"), 106 gettext_noop("Comedy"),
107 gettext_noop("Cult"), 107 gettext_noop("Cult"),
108 gettext_noop("Gangsta Rap"), 108 gettext_noop("Gangsta Rap"),
109 gettext_noop("Top 40"), 109 gettext_noop("Top 40"),
110 gettext_noop("Christian Rap"), 110 gettext_noop("Christian Rap"),
111 gettext_noop("Pop/Funk"), 111 gettext_noop("Pop/Funk"),
112 gettext_noop("Jungle"), 112 gettext_noop("Jungle"),
113 gettext_noop("Native American"), 113 gettext_noop("Native American"),
114 gettext_noop("Cabaret"), 114 gettext_noop("Cabaret"),
115 gettext_noop("New Wave"), 115 gettext_noop("New Wave"),
116 gettext_noop("Psychedelic"), 116 gettext_noop("Psychedelic"),
117 gettext_noop("Rave"), 117 gettext_noop("Rave"),
118 gettext_noop("Showtunes"), 118 gettext_noop("Showtunes"),
119 gettext_noop("Trailer"), 119 gettext_noop("Trailer"),
120 gettext_noop("Lo-Fi"), 120 gettext_noop("Lo-Fi"),
121 gettext_noop("Tribal"), 121 gettext_noop("Tribal"),
122 gettext_noop("Acid Punk"), 122 gettext_noop("Acid Punk"),
123 gettext_noop("Acid Jazz"), 123 gettext_noop("Acid Jazz"),
124 gettext_noop("Polka"), 124 gettext_noop("Polka"),
@@ -130,53 +130,53 @@ static const char *const genre_names[] = {
130 gettext_noop("Folk/Rock"), 130 gettext_noop("Folk/Rock"),
131 gettext_noop("National Folk"), 131 gettext_noop("National Folk"),
132 gettext_noop("Swing"), 132 gettext_noop("Swing"),
133 gettext_noop("Fast-Fusion"), 133 gettext_noop("Fast-Fusion"),
134 gettext_noop("Bebob"), 134 gettext_noop("Bebob"),
135 gettext_noop("Latin"), 135 gettext_noop("Latin"),
136 gettext_noop("Revival"), 136 gettext_noop("Revival"),
137 gettext_noop("Celtic"), 137 gettext_noop("Celtic"),
138 gettext_noop("Bluegrass"), 138 gettext_noop("Bluegrass"),
139 gettext_noop("Avantgarde"), 139 gettext_noop("Avantgarde"),
140 gettext_noop("Gothic Rock"), 140 gettext_noop("Gothic Rock"),
141 gettext_noop("Progressive Rock"), 141 gettext_noop("Progressive Rock"),
142 gettext_noop("Psychedelic Rock"), 142 gettext_noop("Psychedelic Rock"),
143 gettext_noop("Symphonic Rock"), 143 gettext_noop("Symphonic Rock"),
144 gettext_noop("Slow Rock"), 144 gettext_noop("Slow Rock"),
145 gettext_noop("Big Band"), 145 gettext_noop("Big Band"),
146 gettext_noop("Chorus"), 146 gettext_noop("Chorus"),
147 gettext_noop("Easy Listening"), 147 gettext_noop("Easy Listening"),
148 gettext_noop("Acoustic"), 148 gettext_noop("Acoustic"),
149 gettext_noop("Humour"), 149 gettext_noop("Humour"),
150 gettext_noop("Speech"), 150 gettext_noop("Speech"),
151 gettext_noop("Chanson"), 151 gettext_noop("Chanson"),
152 gettext_noop("Opera"), 152 gettext_noop("Opera"),
153 gettext_noop("Chamber Music"), 153 gettext_noop("Chamber Music"),
154 gettext_noop("Sonata"), 154 gettext_noop("Sonata"),
155 gettext_noop("Symphony"), 155 gettext_noop("Symphony"),
156 gettext_noop("Booty Bass"), 156 gettext_noop("Booty Bass"),
157 gettext_noop("Primus"), 157 gettext_noop("Primus"),
158 gettext_noop("Porn Groove"), 158 gettext_noop("Porn Groove"),
159 gettext_noop("Satire"), 159 gettext_noop("Satire"),
160 gettext_noop("Slow Jam"), 160 gettext_noop("Slow Jam"),
161 gettext_noop("Club"), 161 gettext_noop("Club"),
162 gettext_noop("Tango"), 162 gettext_noop("Tango"),
163 gettext_noop("Samba"), 163 gettext_noop("Samba"),
164 gettext_noop("Folklore"), 164 gettext_noop("Folklore"),
165 gettext_noop("Ballad"), 165 gettext_noop("Ballad"),
166 gettext_noop("Power Ballad"), 166 gettext_noop("Power Ballad"),
167 gettext_noop("Rhythmic Soul"), 167 gettext_noop("Rhythmic Soul"),
168 gettext_noop("Freestyle"), 168 gettext_noop("Freestyle"),
169 gettext_noop("Duet"), 169 gettext_noop("Duet"),
170 gettext_noop("Punk Rock"), 170 gettext_noop("Punk Rock"),
171 gettext_noop("Drum Solo"), 171 gettext_noop("Drum Solo"),
172 gettext_noop("A Cappella"), 172 gettext_noop("A Cappella"),
173 gettext_noop("Euro-House"), 173 gettext_noop("Euro-House"),
174 gettext_noop("Dance Hall"), 174 gettext_noop("Dance Hall"),
175 gettext_noop("Goa"), 175 gettext_noop("Goa"),
176 gettext_noop("Drum & Bass"), 176 gettext_noop("Drum & Bass"),
177 gettext_noop("Club-House"), 177 gettext_noop("Club-House"),
178 gettext_noop("Hardcore"), 178 gettext_noop("Hardcore"),
179 gettext_noop("Terror"), 179 gettext_noop("Terror"),
180 gettext_noop("Indie"), 180 gettext_noop("Indie"),
181 gettext_noop("BritPop"), 181 gettext_noop("BritPop"),
182 gettext_noop("Negerpunk"), 182 gettext_noop("Negerpunk"),
@@ -187,7 +187,7 @@ static const char *const genre_names[] = {
187 gettext_noop("Black Metal"), 187 gettext_noop("Black Metal"),
188 gettext_noop("Crossover"), 188 gettext_noop("Crossover"),
189 gettext_noop("Contemporary Christian"), 189 gettext_noop("Contemporary Christian"),
190 gettext_noop("Christian Rock"), 190 gettext_noop("Christian Rock"),
191 gettext_noop("Merengue"), 191 gettext_noop("Merengue"),
192 gettext_noop("Salsa"), 192 gettext_noop("Salsa"),
193 gettext_noop("Thrash Metal"), 193 gettext_noop("Thrash Metal"),
@@ -244,11 +244,11 @@ int freq_table[4][3]={
244#define INVALID_ID3 2 244#define INVALID_ID3 2
245 245
246/** 246/**
247 * Remove trailing whitespace from the end of a string 247 * Remove trailing whitespace from the end of a string
248 */ 248 */
249static char * unpad(char * string) { 249static char * unpad(char * string) {
250 char * end = &string[strlen(string) - 1]; 250 char * end = &string[strlen(string) - 1];
251 while ( (end >= string) && 251 while ( (end >= string) &&
252 (' ' == end[0]) ) 252 (' ' == end[0]) )
253 (end--)[0]='\0'; 253 (end--)[0]='\0';
254 return string; 254 return string;
@@ -264,7 +264,7 @@ static int get_id3(unsigned char * data,
264 264
265 pos = &data[size - 128]; 265 pos = &data[size - 128];
266 if (0 != strncmp((const char *)"TAG",(const char *)pos, 3)) 266 if (0 != strncmp((const char *)"TAG",(const char *)pos, 3))
267 return INVALID_ID3; 267 return INVALID_ID3;
268 pos += 3; 268 pos += 3;
269 269
270 id3->title = convertToUtf8(pos, 270 id3->title = convertToUtf8(pos,
@@ -288,15 +288,15 @@ static int get_id3(unsigned char * data,
288 return OK; 288 return OK;
289} 289}
290 290
291static struct EXTRACTOR_Keywords * 291static struct EXTRACTOR_Keywords *
292addkword(EXTRACTOR_KeywordList *oldhead, 292addkword(EXTRACTOR_KeywordList *oldhead,
293 char *phrase, 293 char *phrase,
294 EXTRACTOR_KeywordType type) { 294 EXTRACTOR_KeywordType type) {
295 295
296 EXTRACTOR_KeywordList * keyword; 296 EXTRACTOR_KeywordList * keyword;
297 297
298 keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList)); 298 keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList));
299 keyword->next = oldhead; 299 keyword->next = oldhead;
300 keyword->keyword = strdup(phrase); 300 keyword->keyword = strdup(phrase);
301 keyword->keywordType = type; 301 keyword->keywordType = type;
302 return keyword; 302 return keyword;
@@ -304,7 +304,7 @@ addkword(EXTRACTOR_KeywordList *oldhead,
304 304
305 305
306 306
307static struct EXTRACTOR_Keywords * 307static struct EXTRACTOR_Keywords *
308mp3parse(char * data, 308mp3parse(char * data,
309 size_t size, 309 size_t size,
310 struct EXTRACTOR_Keywords * prev) { 310 struct EXTRACTOR_Keywords * prev) {
@@ -333,7 +333,7 @@ mp3parse(char * data,
333 memcpy(&header, 333 memcpy(&header,
334 &data[pos], 334 &data[pos],
335 sizeof(header)); 335 sizeof(header));
336 if ((header&sync_mask)==sync_mask) 336 if ((header&sync_mask)==sync_mask)
337 break;/*found header sync*/ 337 break;/*found header sync*/
338 pos++; 338 pos++;
339 counter++; /*next try*/ 339 counter++; /*next try*/
@@ -343,36 +343,36 @@ mp3parse(char * data,
343 };/*give up to find mp3 header*/ 343 };/*give up to find mp3 header*/
344 344
345 prev = addkword(prev, 345 prev = addkword(prev,
346 "audio/mpeg", 346 "audio/mpeg",
347 EXTRACTOR_MIMETYPE); 347 EXTRACTOR_MIMETYPE);
348 348
349 do { /*ok, now we found a mp3 frame header*/ 349 do { /*ok, now we found a mp3 frame header*/
350 frames++; 350 frames++;
351 switch (header & mpeg_ver_mask){ 351 switch (header & mpeg_ver_mask){
352 case 0x1000: 352 case 0x1000:
353 mpeg_ver = MPEG_ERR; /*error*/ 353 mpeg_ver = MPEG_ERR; /*error*/
354 break; 354 break;
355 case 0x800: 355 case 0x800:
356 prev = addkword(prev, 356 prev = addkword(prev,
357 "MPEG V2", 357 "MPEG V2",
358 EXTRACTOR_RESOURCE_TYPE); 358 EXTRACTOR_RESOURCE_TYPE);
359 mpeg_ver = MPEG_V2; 359 mpeg_ver = MPEG_V2;
360 break; 360 break;
361 case 0x1800: 361 case 0x1800:
362 prev = addkword(prev, 362 prev = addkword(prev,
363 "MPEG V1", 363 "MPEG V1",
364 EXTRACTOR_RESOURCE_TYPE); 364 EXTRACTOR_RESOURCE_TYPE);
365 mpeg_ver = MPEG_V1; 365 mpeg_ver = MPEG_V1;
366 break; 366 break;
367 case 0: 367 case 0:
368 prev = addkword(prev, 368 prev = addkword(prev,
369 "MPEG V25", 369 "MPEG V25",
370 EXTRACTOR_RESOURCE_TYPE); 370 EXTRACTOR_RESOURCE_TYPE);
371 mpeg_ver = MPEG_V25; 371 mpeg_ver = MPEG_V25;
372 break; 372 break;
373 } 373 }
374 switch(header&mpeg_layer_mask){ 374 switch(header&mpeg_layer_mask){
375 case 0x400: 375 case 0x400:
376 layer_ver=LAYER_2; 376 layer_ver=LAYER_2;
377 break; 377 break;
378 case 0x200: 378 case 0x200:
@@ -386,9 +386,9 @@ mp3parse(char * data,
386 } 386 }
387 if (!layer_ver||!mpeg_ver) 387 if (!layer_ver||!mpeg_ver)
388 return prev; /*unknown mpeg type*/ 388 return prev; /*unknown mpeg type*/
389 if (mpeg_ver<3) 389 if (mpeg_ver<3)
390 idx_num=(mpeg_ver-1)*3+layer_ver-1; 390 idx_num=(mpeg_ver-1)*3+layer_ver-1;
391 else 391 else
392 idx_num=2+layer_ver; 392 idx_num=2+layer_ver;
393 bitrate = 1000*bitrate_table[(header&bitrate_mask)>>20][idx_num]; 393 bitrate = 1000*bitrate_table[(header&bitrate_mask)>>20][idx_num];
394 if (bitrate<0) { 394 if (bitrate<0) {
@@ -400,15 +400,15 @@ mp3parse(char * data,
400 frames--; 400 frames--;
401 break; 401 break;
402 } /*error in header*/ 402 } /*error in header*/
403 if ((header&ch_mask)==ch_mask) 403 if ((header&ch_mask)==ch_mask)
404 ch=1; 404 ch=1;
405 else 405 else
406 ch=2; /*stereo non stereo select*/ 406 ch=2; /*stereo non stereo select*/
407 frame_size = 144*bitrate/(sample_rate?sample_rate:1)+((header&pad_mask)>>17); 407 frame_size = 144*bitrate/(sample_rate?sample_rate:1)+((header&pad_mask)>>17);
408 avg_bps += bitrate/1000; 408 avg_bps += bitrate/1000;
409 409
410 pos += frame_size-4; 410 pos += frame_size-4;
411 if (frames > max_frames_scan) 411 if (frames > max_frames_scan)
412 break; /*optimization*/ 412 break; /*optimization*/
413 if (avg_bps/frames!=bitrate/1000) 413 if (avg_bps/frames!=bitrate/1000)
414 vbr_flag=1; 414 vbr_flag=1;
@@ -419,7 +419,7 @@ mp3parse(char * data,
419 sizeof(header)); 419 sizeof(header));
420 } while ((header&sync_mask)==sync_mask); 420 } while ((header&sync_mask)==sync_mask);
421 421
422 if (!frames) 422 if (!frames)
423 return prev; /*no valid frames*/ 423 return prev; /*no valid frames*/
424 avg_bps = avg_bps/frames; 424 avg_bps = avg_bps/frames;
425 if (max_frames_scan){ /*if not all frames scaned*/ 425 if (max_frames_scan){ /*if not all frames scaned*/
@@ -427,7 +427,7 @@ mp3parse(char * data,
427 } else{ 427 } else{
428 length=1152*frames/(sample_rate?sample_rate:0xFFFFFFFF); 428 length=1152*frames/(sample_rate?sample_rate:0xFFFFFFFF);
429 } 429 }
430 430
431 format = malloc(512); 431 format = malloc(512);
432 snprintf(format, 432 snprintf(format,
433 512, 433 512,
@@ -439,14 +439,14 @@ mp3parse(char * data,
439 vbr_flag ? _("(variable bps)"):""); 439 vbr_flag ? _("(variable bps)"):"");
440 prev = addkword(prev, 440 prev = addkword(prev,
441 format, 441 format,
442 EXTRACTOR_FORMAT); 442 EXTRACTOR_FORMAT);
443 free(format); 443 free(format);
444 return prev; 444 return prev;
445} 445}
446 446
447 447
448/* mimetype = audio/mpeg */ 448/* mimetype = audio/mpeg */
449struct EXTRACTOR_Keywords * 449struct EXTRACTOR_Keywords *
450libextractor_mp3_extract(char * filename, 450libextractor_mp3_extract(char * filename,
451 char * data, 451 char * data,
452 size_t size, 452 size_t size,
@@ -454,29 +454,29 @@ libextractor_mp3_extract(char * filename,
454 id3tag info; 454 id3tag info;
455 char * word; 455 char * word;
456 456
457 if (0 != get_id3(data, size, &info)) 457 if (0 != get_id3(data, size, &info))
458 return klist; 458 return klist;
459 459
460 if (strlen(info.title) > 0) 460 if (strlen(info.title) > 0)
461 klist = addkword(klist, info.title, EXTRACTOR_TITLE); 461 klist = addkword(klist, info.title, EXTRACTOR_TITLE);
462 if (strlen(info.artist) > 0) 462 if (strlen(info.artist) > 0)
463 klist = addkword(klist, info.artist, EXTRACTOR_ARTIST); 463 klist = addkword(klist, info.artist, EXTRACTOR_ARTIST);
464 if (strlen(info.album) > 0) 464 if (strlen(info.album) > 0)
465 klist = addkword(klist, info.album, EXTRACTOR_ALBUM); 465 klist = addkword(klist, info.album, EXTRACTOR_ALBUM);
466 if (strlen(info.year) > 0) 466 if (strlen(info.year) > 0)
467 klist = addkword(klist, info.year, EXTRACTOR_DATE); 467 klist = addkword(klist, info.year, EXTRACTOR_DATE);
468 if (strlen(info.genre) > 0) 468 if (strlen(info.genre) > 0)
469 klist = addkword(klist, info.genre, EXTRACTOR_GENRE); 469 klist = addkword(klist, info.genre, EXTRACTOR_GENRE);
470 if (strlen(info.genre) > 0) 470 if (strlen(info.genre) > 0)
471 klist = addkword(klist, info.comment, EXTRACTOR_COMMENT); 471 klist = addkword(klist, info.comment, EXTRACTOR_COMMENT);
472 472
473 473
474 /* A keyword that has all of the information together) */ 474 /* A keyword that has all of the information together) */
475 word = (char*) malloc(strlen(info.artist) + strlen(info.title) + strlen(info.album) + 6); 475 word = (char*) malloc(strlen(info.artist) + strlen(info.title) + strlen(info.album) + 6);
476 sprintf(word, 476 sprintf(word,
477 "%s: %s (%s)", 477 "%s: %s (%s)",
478 info.artist, 478 info.artist,
479 info.title, 479 info.title,
480 info.album); 480 info.album);
481 klist = addkword(klist, word, EXTRACTOR_DESCRIPTION); 481 klist = addkword(klist, word, EXTRACTOR_DESCRIPTION);
482 free(word); 482 free(word);
diff --git a/src/plugins/mpegextractor.c b/src/plugins/mpegextractor.c
index c1c22ea..6e6332d 100644
--- a/src/plugins/mpegextractor.c
+++ b/src/plugins/mpegextractor.c
@@ -18,7 +18,7 @@
18 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20 20
21 This code was based on AVInfo 1.0 alpha 11 21 This code was based on AVInfo 1.0 alpha 11
22 (c) George Shuklin, gs]AT[shounen.ru, 2002-2004 22 (c) George Shuklin, gs]AT[shounen.ru, 2002-2004
23 http://shounen.ru/soft/avinfo/ 23 http://shounen.ru/soft/avinfo/
24 24
@@ -36,7 +36,7 @@ static void addKeyword(struct EXTRACTOR_Keywords ** list,
36 EXTRACTOR_KeywordType type) { 36 EXTRACTOR_KeywordType type) {
37 EXTRACTOR_KeywordList * next; 37 EXTRACTOR_KeywordList * next;
38 next = malloc(sizeof(EXTRACTOR_KeywordList)); 38 next = malloc(sizeof(EXTRACTOR_KeywordList));
39 next->next = *list; 39 next->next = *list;
40 next->keyword = keyword; 40 next->keyword = keyword;
41 next->keywordType = type; 41 next->keywordType = type;
42 *list = next; 42 *list = next;
@@ -54,9 +54,9 @@ static double round_double(double num) {
54static unsigned int fread_be(unsigned char * data) { 54static unsigned int fread_be(unsigned char * data) {
55 int x; 55 int x;
56 unsigned int result = 0; 56 unsigned int result = 0;
57 57
58 for (x=3;x>=0;x--) 58 for (x=3;x>=0;x--)
59 result |= data[4-x] << (x*8); 59 result |= data[4-x] << (x*8);
60 return result; 60 return result;
61} 61}
62 62
@@ -79,7 +79,7 @@ struct EXTRACTOR_Keywords * libextractor_mpeg_extract(char * filename,
79 return prev; 79 return prev;
80 80
81 if ( ! ( (xdata[0]==0x00) && 81 if ( ! ( (xdata[0]==0x00) &&
82 (xdata[1]==0x00) && 82 (xdata[1]==0x00) &&
83 (xdata[2]==0x01) && 83 (xdata[2]==0x01) &&
84 ( (xdata[3]==0xB3) || (xdata[3]==0xBA) ) ) ) 84 ( (xdata[3]==0xB3) || (xdata[3]==0xBA) ) ) )
85 return prev; 85 return prev;
@@ -94,7 +94,7 @@ struct EXTRACTOR_Keywords * libextractor_mpeg_extract(char * filename,
94 version = 2; 94 version = 2;
95 else 95 else
96 return prev; /* unsupported mpeg version */ 96 return prev; /* unsupported mpeg version */
97 97
98 if (version == 1) { 98 if (version == 1) {
99 bitrate = round_double((double)((fread_be(&xdata[8]) & 0x7FFFFE) >> 1) * 0.4); 99 bitrate = round_double((double)((fread_be(&xdata[8]) & 0x7FFFFE) >> 1) * 0.4);
100 pos = 12; 100 pos = 12;
@@ -113,7 +113,7 @@ struct EXTRACTOR_Keywords * libextractor_mpeg_extract(char * filename,
113 if (pos + 4 >= xsize) 113 if (pos + 4 >= xsize)
114 return prev; 114 return prev;
115 temp = fread_be(&xdata[pos]); 115 temp = fread_be(&xdata[pos]);
116 } 116 }
117 } else { 117 } else {
118 if (pos + 4 >= xsize) 118 if (pos + 4 >= xsize)
119 return prev; 119 return prev;
@@ -124,8 +124,8 @@ struct EXTRACTOR_Keywords * libextractor_mpeg_extract(char * filename,
124 temp = fread_be(&xdata[pos]); 124 temp = fread_be(&xdata[pos]);
125 } 125 }
126 } 126 }
127 pos += 4; 127 pos += 4;
128 128
129 if (pos + 4 >= xsize) 129 if (pos + 4 >= xsize)
130 return prev; 130 return prev;
131 /* Now read byte by byte until we find the 0x000001B3 instead of actually 131 /* Now read byte by byte until we find the 0x000001B3 instead of actually
@@ -140,14 +140,14 @@ struct EXTRACTOR_Keywords * libextractor_mpeg_extract(char * filename,
140 return prev; 140 return prev;
141 temp |= xdata[pos++]; 141 temp |= xdata[pos++];
142 } 142 }
143 } else 143 } else
144 pos = 4; /* video only */ 144 pos = 4; /* video only */
145 145
146 if (pos + 16 >= xsize) 146 if (pos + 16 >= xsize)
147 return prev; 147 return prev;
148 width = (xdata[pos] << 4) + (xdata[pos+1] & 0xF); 148 width = (xdata[pos] << 4) + (xdata[pos+1] & 0xF);
149 height = ((xdata[pos+1] & 0xF0) << 4) + xdata[pos+2]; 149 height = ((xdata[pos+1] & 0xF0) << 4) + xdata[pos+2];
150 150
151 addKeyword(&prev, 151 addKeyword(&prev,
152 strdup("video/mpeg"), 152 strdup("video/mpeg"),
153 EXTRACTOR_MIMETYPE); 153 EXTRACTOR_MIMETYPE);
diff --git a/src/plugins/oggextractor.c b/src/plugins/oggextractor.c
index 50ae4a2..c2a5d9c 100644
--- a/src/plugins/oggextractor.c
+++ b/src/plugins/oggextractor.c
@@ -46,7 +46,7 @@ static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordType type,
46 if (keyword == NULL) 46 if (keyword == NULL)
47 return next; 47 return next;
48 result = malloc(sizeof(EXTRACTOR_KeywordList)); 48 result = malloc(sizeof(EXTRACTOR_KeywordList));
49 result->next = next; 49 result->next = next;
50 result->keyword = strdup(keyword); 50 result->keyword = strdup(keyword);
51 result->keywordType = type; 51 result->keywordType = type;
52 return result; 52 return result;
@@ -86,9 +86,9 @@ struct EXTRACTOR_Keywords * libextractor_ogg_extract(char * filename,
86 return prev; 86 return prev;
87 } 87 }
88 if (OGG_HEADER != ntohl(*(int*)data)) { 88 if (OGG_HEADER != ntohl(*(int*)data)) {
89 return prev; 89 return prev;
90 } 90 }
91 91
92 callbacks.read_func = &readError; 92 callbacks.read_func = &readError;
93 callbacks.seek_func = &seekError; 93 callbacks.seek_func = &seekError;
94 callbacks.close_func = &closeOk; 94 callbacks.close_func = &closeOk;
@@ -101,7 +101,7 @@ struct EXTRACTOR_Keywords * libextractor_ogg_extract(char * filename,
101 return prev; 101 return prev;
102 } 102 }
103 comments = ov_comment(&vf, -1); 103 comments = ov_comment(&vf, -1);
104 104
105 if (NULL == comments) { 105 if (NULL == comments) {
106#if DEBUG_EXTRACT_OGG 106#if DEBUG_EXTRACT_OGG
107 fprintf(stderr, 107 fprintf(stderr,
@@ -125,17 +125,17 @@ struct EXTRACTOR_Keywords * libextractor_ogg_extract(char * filename,
125 prev = addKeyword(EXTRACTOR_LOCATION,get_comment(comments, "location"), prev); 125 prev = addKeyword(EXTRACTOR_LOCATION,get_comment(comments, "location"), prev);
126 prev = addKeyword(EXTRACTOR_DESCRIPTION, get_comment(comments, "description"), prev); 126 prev = addKeyword(EXTRACTOR_DESCRIPTION, get_comment(comments, "description"), prev);
127 prev = addKeyword(EXTRACTOR_VERSIONNUMBER, get_comment(comments, "version"), prev); 127 prev = addKeyword(EXTRACTOR_VERSIONNUMBER, get_comment(comments, "version"), prev);
128 prev = addKeyword(EXTRACTOR_RESOURCE_IDENTIFIER, get_comment(comments, "isrc"), prev); 128 prev = addKeyword(EXTRACTOR_RESOURCE_IDENTIFIER, get_comment(comments, "isrc"), prev);
129 prev = addKeyword(EXTRACTOR_ORGANIZATION, get_comment(comments, "organization"), prev); 129 prev = addKeyword(EXTRACTOR_ORGANIZATION, get_comment(comments, "organization"), prev);
130 prev = addKeyword(EXTRACTOR_COPYRIGHT, get_comment(comments, "copyright"), prev); 130 prev = addKeyword(EXTRACTOR_COPYRIGHT, get_comment(comments, "copyright"), prev);
131 /* we have determined for sure that this is an 131 /* we have determined for sure that this is an
132 ogg-vorbis stream, we should add this as a keyword, too */ 132 ogg-vorbis stream, we should add this as a keyword, too */
133 prev = addKeyword(EXTRACTOR_MIMETYPE, 133 prev = addKeyword(EXTRACTOR_MIMETYPE,
134 "application/ogg", 134 "application/ogg",
135 prev); 135 prev);
136 /* build a description from artist, title and album */ 136 /* build a description from artist, title and album */
137 { 137 {
138 EXTRACTOR_KeywordList * keyword = malloc(sizeof(EXTRACTOR_KeywordList)); 138 EXTRACTOR_KeywordList * keyword = malloc(sizeof(EXTRACTOR_KeywordList));
139 char * word; 139 char * word;
140 int len = 1+2+2+1; 140 int len = 1+2+2+1;
141 if (get_comment(comments, "artist") != NULL) 141 if (get_comment(comments, "artist") != NULL)
@@ -144,7 +144,7 @@ struct EXTRACTOR_Keywords * libextractor_ogg_extract(char * filename,
144 len += strlen(get_comment(comments, "title")); 144 len += strlen(get_comment(comments, "title"));
145 if (get_comment(comments, "album") != NULL) 145 if (get_comment(comments, "album") != NULL)
146 len += strlen(get_comment(comments, "album")); 146 len += strlen(get_comment(comments, "album"));
147 147
148 word = malloc(len); 148 word = malloc(len);
149 word[0] = 0; 149 word[0] = 0;
150 if (get_comment(comments, "artist") != NULL) { 150 if (get_comment(comments, "artist") != NULL) {
@@ -152,9 +152,9 @@ struct EXTRACTOR_Keywords * libextractor_ogg_extract(char * filename,
152 } 152 }
153 if (get_comment(comments, "title") != NULL) { 153 if (get_comment(comments, "title") != NULL) {
154 strcat(word,": "); 154 strcat(word,": ");
155 strcat(word, get_comment(comments, "title")); 155 strcat(word, get_comment(comments, "title"));
156 } 156 }
157 if (get_comment(comments, "album") != NULL) { 157 if (get_comment(comments, "album") != NULL) {
158 strcat(word," ("); 158 strcat(word," (");
159 strcat(word, get_comment(comments, "album")); 159 strcat(word, get_comment(comments, "album"));
160 strcat(word, ")"); 160 strcat(word, ")");
@@ -162,8 +162,8 @@ struct EXTRACTOR_Keywords * libextractor_ogg_extract(char * filename,
162 keyword->next = prev; 162 keyword->next = prev;
163 keyword->keyword = word; 163 keyword->keyword = word;
164 keyword->keywordType = EXTRACTOR_DESCRIPTION; 164 keyword->keywordType = EXTRACTOR_DESCRIPTION;
165 prev = keyword; 165 prev = keyword;
166 166
167 } 167 }
168 168
169 ov_clear(&vf); 169 ov_clear(&vf);
diff --git a/src/plugins/ole2/gsf-impl-utils.h b/src/plugins/ole2/gsf-impl-utils.h
index 9b106d0..9224867 100644
--- a/src/plugins/ole2/gsf-impl-utils.h
+++ b/src/plugins/ole2/gsf-impl-utils.h
@@ -1,6 +1,6 @@
1/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 1/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/* 2/*
3 * gsf-impl-utils.h: 3 * gsf-impl-utils.h:
4 * 4 *
5 * Copyright (C) 2002-2004 Jody Goldberg (jody@gnome.org) 5 * Copyright (C) 2002-2004 Jody Goldberg (jody@gnome.org)
6 * 6 *
diff --git a/src/plugins/ole2/gsf-infile-impl.h b/src/plugins/ole2/gsf-infile-impl.h
index cdf4f9b..133dc91 100644
--- a/src/plugins/ole2/gsf-infile-impl.h
+++ b/src/plugins/ole2/gsf-infile-impl.h
@@ -1,6 +1,6 @@
1/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 1/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/* 2/*
3 * gsf-infile-impl.h: 3 * gsf-infile-impl.h:
4 * 4 *
5 * Copyright (C) 2002-2004 Jody Goldberg (jody@gnome.org) 5 * Copyright (C) 2002-2004 Jody Goldberg (jody@gnome.org)
6 * 6 *
diff --git a/src/plugins/ole2/gsf-infile-msole.c b/src/plugins/ole2/gsf-infile-msole.c
index 26aa4bd..437884a 100644
--- a/src/plugins/ole2/gsf-infile-msole.c
+++ b/src/plugins/ole2/gsf-infile-msole.c
@@ -362,11 +362,11 @@ ole_dirent_new (GsfInfileMSOle *ole, guint32 entry, MSOleDirent *parent)
362 if (prev == entry) { 362 if (prev == entry) {
363 g_warning ("Invalid OLE file with a cycle in its directory tree"); 363 g_warning ("Invalid OLE file with a cycle in its directory tree");
364 } else 364 } else
365 ole_dirent_new (ole, prev, parent); 365 ole_dirent_new (ole, prev, parent);
366 if (next == entry) { 366 if (next == entry) {
367 g_warning ("Invalid OLE file with a cycle in its directory tree"); 367 g_warning ("Invalid OLE file with a cycle in its directory tree");
368 } else 368 } else
369 ole_dirent_new (ole, next, parent); 369 ole_dirent_new (ole, next, parent);
370 370
371 if (dirent->is_directory) 371 if (dirent->is_directory)
372 ole_dirent_new (ole, child, dirent); 372 ole_dirent_new (ole, child, dirent);
@@ -713,7 +713,7 @@ gsf_infile_msole_seek (GsfInput *input, gsf_off_t offset, GSeekType whence)
713{ 713{
714 GsfInfileMSOle *ole = GSF_INFILE_MSOLE (input); 714 GsfInfileMSOle *ole = GSF_INFILE_MSOLE (input);
715 715
716 (void) offset; 716 (void) offset;
717 (void) whence; 717 (void) whence;
718 718
719 ole->cur_block = BAT_MAGIC_UNUSED; 719 ole->cur_block = BAT_MAGIC_UNUSED;
@@ -776,7 +776,7 @@ gsf_infile_msole_new_child (GsfInfileMSOle *parent,
776 if (gsf_input_seek (GSF_INPUT (sb_file), 776 if (gsf_input_seek (GSF_INPUT (sb_file),
777 (gsf_off_t)(child->bat.block [i] << info->sb.shift), G_SEEK_SET) < 0 || 777 (gsf_off_t)(child->bat.block [i] << info->sb.shift), G_SEEK_SET) < 0 ||
778 (data = gsf_input_read (GSF_INPUT (sb_file), 778 (data = gsf_input_read (GSF_INPUT (sb_file),
779 info->sb.size, 779 info->sb.size,
780 child->stream.buf + (i << info->sb.shift))) == NULL) { 780 child->stream.buf + (i << info->sb.shift))) == NULL) {
781 781
782 g_warning ("failure reading block %d", i); 782 g_warning ("failure reading block %d", i);
@@ -851,7 +851,7 @@ gsf_infile_msole_init (GObject *obj)
851 ole->bat.num_blocks = 0; 851 ole->bat.num_blocks = 0;
852 ole->cur_block = BAT_MAGIC_UNUSED; 852 ole->cur_block = BAT_MAGIC_UNUSED;
853 ole->stream.buf = NULL; 853 ole->stream.buf = NULL;
854 ole->stream.buf_size = 0; 854 ole->stream.buf_size = 0;
855} 855}
856 856
857static void 857static void
diff --git a/src/plugins/ole2/gsf-infile-msole.h b/src/plugins/ole2/gsf-infile-msole.h
index 7f6548d..9a6d66e 100644
--- a/src/plugins/ole2/gsf-infile-msole.h
+++ b/src/plugins/ole2/gsf-infile-msole.h
@@ -1,6 +1,6 @@
1/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 1/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/* 2/*
3 * gsf-infile-msole.h: 3 * gsf-infile-msole.h:
4 * 4 *
5 * Copyright (C) 2002-2004 Jody Goldberg (jody@gnome.org) 5 * Copyright (C) 2002-2004 Jody Goldberg (jody@gnome.org)
6 * 6 *
diff --git a/src/plugins/ole2/gsf-infile.h b/src/plugins/ole2/gsf-infile.h
index b4bf1d6..83237e2 100644
--- a/src/plugins/ole2/gsf-infile.h
+++ b/src/plugins/ole2/gsf-infile.h
@@ -1,6 +1,6 @@
1/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 1/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/* 2/*
3 * gsf-infile.h: 3 * gsf-infile.h:
4 * 4 *
5 * Copyright (C) 2002-2004 Jody Goldberg (jody@gnome.org) 5 * Copyright (C) 2002-2004 Jody Goldberg (jody@gnome.org)
6 * 6 *
diff --git a/src/plugins/ole2/gsf-input-memory.c b/src/plugins/ole2/gsf-input-memory.c
index 2ab912b..953e295 100644
--- a/src/plugins/ole2/gsf-input-memory.c
+++ b/src/plugins/ole2/gsf-input-memory.c
@@ -1,6 +1,6 @@
1/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 1/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/* 2/*
3 * gsf-input-memory.c: 3 * gsf-input-memory.c:
4 * 4 *
5 * Copyright (C) 2002-2004 Jody Goldberg (jody@gnome.org) 5 * Copyright (C) 2002-2004 Jody Goldberg (jody@gnome.org)
6 * 6 *
diff --git a/src/plugins/ole2/gsf-input.c b/src/plugins/ole2/gsf-input.c
index aeb0aa7..4db630a 100644
--- a/src/plugins/ole2/gsf-input.c
+++ b/src/plugins/ole2/gsf-input.c
@@ -160,7 +160,7 @@ GSF_CLASS_ABSTRACT (GsfInput, gsf_input,
160 160
161/** 161/**
162 * gsf_input_name : 162 * gsf_input_name :
163 * @input : 163 * @input :
164 * 164 *
165 * Returns @input's name in utf8 form, DO NOT FREE THIS STRING 165 * Returns @input's name in utf8 form, DO NOT FREE THIS STRING
166 **/ 166 **/
@@ -173,7 +173,7 @@ gsf_input_name (GsfInput *input)
173 173
174/** 174/**
175 * gsf_input_container : 175 * gsf_input_container :
176 * @input : 176 * @input :
177 * 177 *
178 * Returns, but does not add a reference to @input's container. 178 * Returns, but does not add a reference to @input's container.
179 * Potentially NULL 179 * Potentially NULL
@@ -429,7 +429,7 @@ gsf_input_seek_emulate (GsfInput *input, gsf_off_t pos)
429 * 429 *
430 * Returns : A utility quark to flag a GError as being an input problem. 430 * Returns : A utility quark to flag a GError as being an input problem.
431 */ 431 */
432GQuark 432GQuark
433gsf_input_error (void) 433gsf_input_error (void)
434{ 434{
435 static GQuark quark; 435 static GQuark quark;
@@ -479,7 +479,7 @@ gsf_input_uncompress (GsfInput *src)
479 if (res) { 479 if (res) {
480 g_object_unref (G_OBJECT (src)); 480 g_object_unref (G_OBJECT (src));
481 return gsf_input_uncompress (res); 481 return gsf_input_uncompress (res);
482 } 482 }
483 } 483 }
484 } 484 }
485#endif 485#endif
@@ -536,7 +536,7 @@ gsf_input_new_for_uri (char const * uri, GError ** err)
536 if (len > 7 && !strncmp (uri, "file:/", 6)) { 536 if (len > 7 && !strncmp (uri, "file:/", 6)) {
537 /* dumb attempt to translate this into a local path */ 537 /* dumb attempt to translate this into a local path */
538 input = gsf_input_stdio_new (uri+7, err); 538 input = gsf_input_stdio_new (uri+7, err);
539 } 539 }
540 /* else: unknown or unhandled protocol - bail */ 540 /* else: unknown or unhandled protocol - bail */
541#endif 541#endif
542 } 542 }
diff --git a/src/plugins/ole2/gsf-msole-impl.h b/src/plugins/ole2/gsf-msole-impl.h
index d3e5f2b..b4d1b93 100644
--- a/src/plugins/ole2/gsf-msole-impl.h
+++ b/src/plugins/ole2/gsf-msole-impl.h
@@ -1,6 +1,6 @@
1/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 1/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/* 2/*
3 * gsf-msole-impl.h: 3 * gsf-msole-impl.h:
4 * 4 *
5 * Copyright (C) 2002-2004 Jody Goldberg (jody@gnome.org) 5 * Copyright (C) 2002-2004 Jody Goldberg (jody@gnome.org)
6 * 6 *
diff --git a/src/plugins/ole2/gsf-shared-memory.c b/src/plugins/ole2/gsf-shared-memory.c
index 49b6e7e..9a070d0 100644
--- a/src/plugins/ole2/gsf-shared-memory.c
+++ b/src/plugins/ole2/gsf-shared-memory.c
@@ -1,6 +1,6 @@
1/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 1/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/* 2/*
3 * gsf-shared-memory.c: 3 * gsf-shared-memory.c:
4 * 4 *
5 * Copyright (C) 2002-2004 Morten Welinder (terra@diku.dk) 5 * Copyright (C) 2002-2004 Morten Welinder (terra@diku.dk)
6 * 6 *
diff --git a/src/plugins/ole2/gsf-utils.c b/src/plugins/ole2/gsf-utils.c
index 2118d90..5b110a1 100644
--- a/src/plugins/ole2/gsf-utils.c
+++ b/src/plugins/ole2/gsf-utils.c
@@ -1,6 +1,6 @@
1/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 1/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/* 2/*
3 * gsf-utils.c: 3 * gsf-utils.c:
4 * 4 *
5 * Copyright (C) 2002-2004 Jody Goldberg (jody@gnome.org) 5 * Copyright (C) 2002-2004 Jody Goldberg (jody@gnome.org)
6 * 6 *
diff --git a/src/plugins/ole2/gsf-utils.h b/src/plugins/ole2/gsf-utils.h
index f671d0f..a5bdea5 100644
--- a/src/plugins/ole2/gsf-utils.h
+++ b/src/plugins/ole2/gsf-utils.h
@@ -1,6 +1,6 @@
1/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 1/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/* 2/*
3 * gsf-utils.h: 3 * gsf-utils.h:
4 * 4 *
5 * Copyright (C) 2002-2004 Jody Goldberg (jody@gnome.org) 5 * Copyright (C) 2002-2004 Jody Goldberg (jody@gnome.org)
6 * 6 *
diff --git a/src/plugins/ole2/gsf.h b/src/plugins/ole2/gsf.h
index 009a471..95e51e5 100644
--- a/src/plugins/ole2/gsf.h
+++ b/src/plugins/ole2/gsf.h
@@ -1,6 +1,6 @@
1/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ 1/* vim: set sw=8: -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2/* 2/*
3 * gsf.h: 3 * gsf.h:
4 * 4 *
5 * Copyright (C) 2002-2004 Jody Goldberg (jody@gnome.org) 5 * Copyright (C) 2002-2004 Jody Goldberg (jody@gnome.org)
6 * 6 *
@@ -39,7 +39,7 @@ typedef struct _GsfTimestamp GsfTimestamp;
39/* FIXME: 39/* FIXME:
40 * gsf_off_t is really supposed to be the widest type off_t can be configured 40 * gsf_off_t is really supposed to be the widest type off_t can be configured
41 * to on the platform 41 * to on the platform
42 */ 42 */
43typedef gint64 gsf_off_t; 43typedef gint64 gsf_off_t;
44#define GSF_OFF_T_FORMAT G_GINT64_FORMAT 44#define GSF_OFF_T_FORMAT G_GINT64_FORMAT
45 45
diff --git a/src/plugins/ole2/ole2extractor.c b/src/plugins/ole2/ole2extractor.c
index e68e440..8b442e3 100644
--- a/src/plugins/ole2/ole2extractor.c
+++ b/src/plugins/ole2/ole2extractor.c
@@ -44,11 +44,11 @@ void __attribute__ ((constructor)) ole_gobject_init(void) {
44 g_type_init(); /* really needed??? */ 44 g_type_init(); /* really needed??? */
45} 45}
46 46
47static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead, 47static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead,
48 const char *phrase, 48 const char *phrase,
49 EXTRACTOR_KeywordType type) { 49 EXTRACTOR_KeywordType type) {
50 50
51 EXTRACTOR_KeywordList * keyword; 51 EXTRACTOR_KeywordList * keyword;
52 if (strlen(phrase) == 0) 52 if (strlen(phrase) == 0)
53 return oldhead; 53 return oldhead;
54 if (0 == strcmp(phrase, "\"\"")) 54 if (0 == strcmp(phrase, "\"\""))
@@ -58,7 +58,7 @@ static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead,
58 if (0 == strcmp(phrase, " ")) 58 if (0 == strcmp(phrase, " "))
59 return oldhead; 59 return oldhead;
60 keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList)); 60 keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList));
61 keyword->next = oldhead; 61 keyword->next = oldhead;
62 keyword->keyword = strdup(phrase); 62 keyword->keyword = strdup(phrase);
63 keyword->keywordType = type; 63 keyword->keywordType = type;
64 return keyword; 64 return keyword;
@@ -229,21 +229,21 @@ msole_prop_id_to_gsf (GsfMSOleMetaDataSection *section, guint32 id)
229 char const *res = NULL; 229 char const *res = NULL;
230 GsfMSOleMetaDataPropMap const *map = NULL; 230 GsfMSOleMetaDataPropMap const *map = NULL;
231 unsigned i = 0; 231 unsigned i = 0;
232 232
233 if (section->dict != NULL) { 233 if (section->dict != NULL) {
234 if (id & 0x1000000) { 234 if (id & 0x1000000) {
235 id &= ~0x1000000; 235 id &= ~0x1000000;
236 d (printf ("LINKED ");); 236 d (printf ("LINKED "););
237 } 237 }
238 238
239 res = g_hash_table_lookup (section->dict, GINT_TO_POINTER (id)); 239 res = g_hash_table_lookup (section->dict, GINT_TO_POINTER (id));
240 240
241 if (res != NULL) { 241 if (res != NULL) {
242 d (printf (res);); 242 d (printf (res););
243 return res; 243 return res;
244 } 244 }
245 } 245 }
246 246
247 if (section->type == GSF_MSOLE_META_DATA_COMPONENT) { 247 if (section->type == GSF_MSOLE_META_DATA_COMPONENT) {
248 map = component_props; 248 map = component_props;
249 i = G_N_ELEMENTS (component_props); 249 i = G_N_ELEMENTS (component_props);
@@ -256,7 +256,7 @@ msole_prop_id_to_gsf (GsfMSOleMetaDataSection *section, guint32 id)
256 d (printf (map[i].name);); 256 d (printf (map[i].name););
257 return map[i].name; 257 return map[i].name;
258 } 258 }
259 259
260 map = common_props; 260 map = common_props;
261 i = G_N_ELEMENTS (common_props); 261 i = G_N_ELEMENTS (common_props);
262 while (i-- > 0) 262 while (i-- > 0)
@@ -264,16 +264,16 @@ msole_prop_id_to_gsf (GsfMSOleMetaDataSection *section, guint32 id)
264 d (printf (map[i].name);); 264 d (printf (map[i].name););
265 return map[i].name; 265 return map[i].name;
266 } 266 }
267 267
268 d (printf ("_UNKNOWN_(0x%x %d)", id, id);); 268 d (printf ("_UNKNOWN_(0x%x %d)", id, id););
269 269
270 return NULL; 270 return NULL;
271} 271}
272 272
273static GValue * 273static GValue *
274msole_prop_parse(GsfMSOleMetaDataSection *section, 274msole_prop_parse(GsfMSOleMetaDataSection *section,
275 guint32 type, 275 guint32 type,
276 guint8 const **data, 276 guint8 const **data,
277 guint8 const *data_end) 277 guint8 const *data_end)
278{ 278{
279 GValue *res; 279 GValue *res;
@@ -281,19 +281,19 @@ msole_prop_parse(GsfMSOleMetaDataSection *section,
281 guint32 len; 281 guint32 len;
282 gsize gslen; 282 gsize gslen;
283 gboolean const is_vector = type & LE_VT_VECTOR; 283 gboolean const is_vector = type & LE_VT_VECTOR;
284 284
285 g_return_val_if_fail (!(type & (unsigned)(~0x1fff)), NULL); /* not valid in a prop set */ 285 g_return_val_if_fail (!(type & (unsigned)(~0x1fff)), NULL); /* not valid in a prop set */
286 286
287 type &= 0xfff; 287 type &= 0xfff;
288 288
289 if (is_vector) { 289 if (is_vector) {
290 unsigned i, n; 290 unsigned i, n;
291 291
292 g_return_val_if_fail (*data + 4 <= data_end, NULL); 292 g_return_val_if_fail (*data + 4 <= data_end, NULL);
293 293
294 n = GSF_LE_GET_GUINT32 (*data); 294 n = GSF_LE_GET_GUINT32 (*data);
295 *data += 4; 295 *data += 4;
296 296
297 d (printf (" array with %d elem\n", n); 297 d (printf (" array with %d elem\n", n);
298 gsf_mem_dump (*data, (unsigned)(data_end - *data));); 298 gsf_mem_dump (*data, (unsigned)(data_end - *data)););
299 for (i = 0 ; i < n ; i++) { 299 for (i = 0 ; i < n ; i++) {
@@ -309,152 +309,152 @@ msole_prop_parse(GsfMSOleMetaDataSection *section,
309 } 309 }
310 return NULL; 310 return NULL;
311 } 311 }
312 312
313 res = g_new0 (GValue, 1); 313 res = g_new0 (GValue, 1);
314 switch (type) { 314 switch (type) {
315 case LE_VT_EMPTY : d (puts ("VT_EMPTY");); 315 case LE_VT_EMPTY : d (puts ("VT_EMPTY"););
316 /* value::unset == empty */ 316 /* value::unset == empty */
317 break; 317 break;
318 318
319 case LE_VT_NULL : d (puts ("VT_NULL");); 319 case LE_VT_NULL : d (puts ("VT_NULL"););
320 /* value::unset == null too :-) do we need to distinguish ? */ 320 /* value::unset == null too :-) do we need to distinguish ? */
321 break; 321 break;
322 322
323 case LE_VT_I2 : d (puts ("VT_I2");); 323 case LE_VT_I2 : d (puts ("VT_I2"););
324 g_return_val_if_fail (*data + 2 <= data_end, NULL); 324 g_return_val_if_fail (*data + 2 <= data_end, NULL);
325 g_value_init (res, G_TYPE_INT); 325 g_value_init (res, G_TYPE_INT);
326 g_value_set_int (res, GSF_LE_GET_GINT16 (*data)); 326 g_value_set_int (res, GSF_LE_GET_GINT16 (*data));
327 *data += 2; 327 *data += 2;
328 break; 328 break;
329 329
330 case LE_VT_I4 : d (puts ("VT_I4");); 330 case LE_VT_I4 : d (puts ("VT_I4"););
331 g_return_val_if_fail (*data + 4 <= data_end, NULL); 331 g_return_val_if_fail (*data + 4 <= data_end, NULL);
332 g_value_init (res, G_TYPE_INT); 332 g_value_init (res, G_TYPE_INT);
333 g_value_set_int (res, GSF_LE_GET_GINT32 (*data)); 333 g_value_set_int (res, GSF_LE_GET_GINT32 (*data));
334 *data += 4; 334 *data += 4;
335 break; 335 break;
336 336
337 case LE_VT_R4 : d (puts ("VT_R4");); 337 case LE_VT_R4 : d (puts ("VT_R4"););
338 g_return_val_if_fail (*data + 4 <= data_end, NULL); 338 g_return_val_if_fail (*data + 4 <= data_end, NULL);
339 g_value_init (res, G_TYPE_FLOAT); 339 g_value_init (res, G_TYPE_FLOAT);
340 g_value_set_float (res, GSF_LE_GET_FLOAT (*data)); 340 g_value_set_float (res, GSF_LE_GET_FLOAT (*data));
341 *data += 4; 341 *data += 4;
342 break; 342 break;
343 343
344 case LE_VT_R8 : d (puts ("VT_R8");); 344 case LE_VT_R8 : d (puts ("VT_R8"););
345 g_return_val_if_fail (*data + 8 <= data_end, NULL); 345 g_return_val_if_fail (*data + 8 <= data_end, NULL);
346 g_value_init (res, G_TYPE_DOUBLE); 346 g_value_init (res, G_TYPE_DOUBLE);
347 g_value_set_double (res, GSF_LE_GET_DOUBLE (*data)); 347 g_value_set_double (res, GSF_LE_GET_DOUBLE (*data));
348 *data += 8; 348 *data += 8;
349 break; 349 break;
350 350
351 case LE_VT_CY : d (puts ("VT_CY");); 351 case LE_VT_CY : d (puts ("VT_CY"););
352 break; 352 break;
353 353
354 case LE_VT_DATE : d (puts ("VT_DATE");); 354 case LE_VT_DATE : d (puts ("VT_DATE"););
355 break; 355 break;
356 356
357 case LE_VT_BSTR : d (puts ("VT_BSTR");); 357 case LE_VT_BSTR : d (puts ("VT_BSTR"););
358 break; 358 break;
359 359
360 case LE_VT_DISPATCH : d (puts ("VT_DISPATCH");); 360 case LE_VT_DISPATCH : d (puts ("VT_DISPATCH"););
361 break; 361 break;
362 362
363 case LE_VT_BOOL : d (puts ("VT_BOOL");); 363 case LE_VT_BOOL : d (puts ("VT_BOOL"););
364 g_return_val_if_fail (*data + 1 <= data_end, NULL); 364 g_return_val_if_fail (*data + 1 <= data_end, NULL);
365 g_value_init (res, G_TYPE_BOOLEAN); 365 g_value_init (res, G_TYPE_BOOLEAN);
366 g_value_set_boolean (res, **data ? TRUE : FALSE); 366 g_value_set_boolean (res, **data ? TRUE : FALSE);
367 *data += 1; 367 *data += 1;
368 break; 368 break;
369 369
370 case LE_VT_VARIANT : d (printf ("VT_VARIANT containing a ");); 370 case LE_VT_VARIANT : d (printf ("VT_VARIANT containing a "););
371 g_free (res); 371 g_free (res);
372 type = GSF_LE_GET_GUINT32 (*data); 372 type = GSF_LE_GET_GUINT32 (*data);
373 *data += 4; 373 *data += 4;
374 return msole_prop_parse (section, type, data, data_end); 374 return msole_prop_parse (section, type, data, data_end);
375 375
376 case LE_VT_UI1 : d (puts ("VT_UI1");); 376 case LE_VT_UI1 : d (puts ("VT_UI1"););
377 g_return_val_if_fail (*data + 1 <= data_end, NULL); 377 g_return_val_if_fail (*data + 1 <= data_end, NULL);
378 g_value_init (res, G_TYPE_UCHAR); 378 g_value_init (res, G_TYPE_UCHAR);
379 g_value_set_uchar (res, (guchar)(**data)); 379 g_value_set_uchar (res, (guchar)(**data));
380 *data += 1; 380 *data += 1;
381 break; 381 break;
382 382
383 case LE_VT_UI2 : d (puts ("VT_UI2");); 383 case LE_VT_UI2 : d (puts ("VT_UI2"););
384 g_return_val_if_fail (*data + 2 <= data_end, NULL); 384 g_return_val_if_fail (*data + 2 <= data_end, NULL);
385 g_value_init (res, G_TYPE_UINT); 385 g_value_init (res, G_TYPE_UINT);
386 g_value_set_uint (res, GSF_LE_GET_GUINT16 (*data)); 386 g_value_set_uint (res, GSF_LE_GET_GUINT16 (*data));
387 *data += 2; 387 *data += 2;
388 break; 388 break;
389 389
390 case LE_VT_UI4 : d (puts ("VT_UI4");); 390 case LE_VT_UI4 : d (puts ("VT_UI4"););
391 g_return_val_if_fail (*data + 4 <= data_end, NULL); 391 g_return_val_if_fail (*data + 4 <= data_end, NULL);
392 g_value_init (res, G_TYPE_UINT); 392 g_value_init (res, G_TYPE_UINT);
393 *data += 4; 393 *data += 4;
394 d (printf ("%u\n", GSF_LE_GET_GUINT32 (*data));); 394 d (printf ("%u\n", GSF_LE_GET_GUINT32 (*data)););
395 break; 395 break;
396 396
397 case LE_VT_I8 : d (puts ("VT_I8");); 397 case LE_VT_I8 : d (puts ("VT_I8"););
398 g_return_val_if_fail (*data + 8 <= data_end, NULL); 398 g_return_val_if_fail (*data + 8 <= data_end, NULL);
399 g_value_init (res, G_TYPE_INT64); 399 g_value_init (res, G_TYPE_INT64);
400 *data += 8; 400 *data += 8;
401 break; 401 break;
402 402
403 case LE_VT_UI8 : d (puts ("VT_UI8");); 403 case LE_VT_UI8 : d (puts ("VT_UI8"););
404 g_return_val_if_fail (*data + 8 <= data_end, NULL); 404 g_return_val_if_fail (*data + 8 <= data_end, NULL);
405 g_value_init (res, G_TYPE_UINT64); 405 g_value_init (res, G_TYPE_UINT64);
406 *data += 8; 406 *data += 8;
407 break; 407 break;
408 408
409 case LE_VT_LPSTR : d (puts ("VT_LPSTR");); 409 case LE_VT_LPSTR : d (puts ("VT_LPSTR"););
410 /* be anal and safe */ 410 /* be anal and safe */
411 g_return_val_if_fail (*data + 4 <= data_end, NULL); 411 g_return_val_if_fail (*data + 4 <= data_end, NULL);
412 412
413 len = GSF_LE_GET_GUINT32 (*data); 413 len = GSF_LE_GET_GUINT32 (*data);
414 414
415 g_return_val_if_fail (len < 0x10000, NULL); 415 g_return_val_if_fail (len < 0x10000, NULL);
416 g_return_val_if_fail (*data + 4 + len*section->char_size <= data_end, NULL); 416 g_return_val_if_fail (*data + 4 + len*section->char_size <= data_end, NULL);
417 417
418 gslen = 0; 418 gslen = 0;
419 str = g_convert_with_iconv (*data + 4, 419 str = g_convert_with_iconv (*data + 4,
420 len * section->char_size, 420 len * section->char_size,
421 section->iconv_handle, &gslen, NULL, NULL); 421 section->iconv_handle, &gslen, NULL, NULL);
422 len = (guint32)gslen; 422 len = (guint32)gslen;
423 423
424 g_value_init (res, G_TYPE_STRING); 424 g_value_init (res, G_TYPE_STRING);
425 g_value_set_string (res, str); 425 g_value_set_string (res, str);
426 g_free (str); 426 g_free (str);
427 *data += 4 + len; 427 *data += 4 + len;
428 break; 428 break;
429 429
430 case LE_VT_LPWSTR : d (puts ("VT_LPWSTR");); 430 case LE_VT_LPWSTR : d (puts ("VT_LPWSTR"););
431 /* be anal and safe */ 431 /* be anal and safe */
432 g_return_val_if_fail (*data + 4 <= data_end, NULL); 432 g_return_val_if_fail (*data + 4 <= data_end, NULL);
433 433
434 len = GSF_LE_GET_GUINT32 (*data); 434 len = GSF_LE_GET_GUINT32 (*data);
435 435
436 g_return_val_if_fail (len < 0x10000, NULL); 436 g_return_val_if_fail (len < 0x10000, NULL);
437 g_return_val_if_fail (*data + 4 + len <= data_end, NULL); 437 g_return_val_if_fail (*data + 4 + len <= data_end, NULL);
438 438
439 str = g_convert (*data + 4, len*2, 439 str = g_convert (*data + 4, len*2,
440 "UTF-8", "UTF-16LE", &gslen, NULL, NULL); 440 "UTF-8", "UTF-16LE", &gslen, NULL, NULL);
441 len = (guint32)gslen; 441 len = (guint32)gslen;
442 442
443 g_value_init (res, G_TYPE_STRING); 443 g_value_init (res, G_TYPE_STRING);
444 g_value_set_string (res, str); 444 g_value_set_string (res, str);
445 g_free (str); 445 g_free (str);
446 *data += 4 + len; 446 *data += 4 + len;
447 break; 447 break;
448 448
449 case LE_VT_FILETIME : d (puts ("VT_FILETIME");); 449 case LE_VT_FILETIME : d (puts ("VT_FILETIME"););
450 450
451 g_return_val_if_fail (*data + 8 <= data_end, NULL); 451 g_return_val_if_fail (*data + 8 <= data_end, NULL);
452 452
453 g_value_init (res, G_TYPE_STRING); 453 g_value_init (res, G_TYPE_STRING);
454 { 454 {
455 /* ft * 100ns since Jan 1 1601 */ 455 /* ft * 100ns since Jan 1 1601 */
456 guint64 ft = GSF_LE_GET_GUINT64 (*data); 456 guint64 ft = GSF_LE_GET_GUINT64 (*data);
457 457
458 ft /= 10000000; /* convert to seconds */ 458 ft /= 10000000; /* convert to seconds */
459#ifdef _MSC_VER 459#ifdef _MSC_VER
460 ft -= 11644473600i64; /* move to Jan 1 1970 */ 460 ft -= 11644473600i64; /* move to Jan 1 1970 */
@@ -463,7 +463,7 @@ msole_prop_parse(GsfMSOleMetaDataSection *section,
463#endif 463#endif
464 464
465 str = g_strdup(ctime((time_t*)&ft)); 465 str = g_strdup(ctime((time_t*)&ft));
466 466
467 g_value_set_string (res, str); 467 g_value_set_string (res, str);
468 468
469 *data += 8; 469 *data += 8;
@@ -486,7 +486,7 @@ msole_prop_parse(GsfMSOleMetaDataSection *section,
486 case LE_VT_CLSID : d (puts ("VT_CLSID");); 486 case LE_VT_CLSID : d (puts ("VT_CLSID"););
487 *data += 16; 487 *data += 16;
488 break; 488 break;
489 489
490 case LE_VT_ERROR : 490 case LE_VT_ERROR :
491 case LE_VT_UNKNOWN : 491 case LE_VT_UNKNOWN :
492 case LE_VT_DECIMAL : 492 case LE_VT_DECIMAL :
@@ -504,13 +504,13 @@ msole_prop_parse(GsfMSOleMetaDataSection *section,
504 g_free (res); 504 g_free (res);
505 res = NULL; 505 res = NULL;
506 break; 506 break;
507 507
508 default : 508 default :
509 warning ("Unknown property type %d (0x%x)", type, type); 509 warning ("Unknown property type %d (0x%x)", type, type);
510 g_free (res); 510 g_free (res);
511 res = NULL; 511 res = NULL;
512 }; 512 };
513 513
514 d ( if (res != NULL && G_IS_VALUE (res)) { 514 d ( if (res != NULL && G_IS_VALUE (res)) {
515 char *val = g_strdup_value_contents (res); 515 char *val = g_strdup_value_contents (res);
516 d(printf ("%s\n", val);); 516 d(printf ("%s\n", val););
@@ -533,52 +533,52 @@ msole_prop_read (GsfInput *in,
533 gsf_off_t size = ((i+1) >= section->num_props) 533 gsf_off_t size = ((i+1) >= section->num_props)
534 ? section->size-4 : props[i+1].offset; 534 ? section->size-4 : props[i+1].offset;
535 char const *prop_name; 535 char const *prop_name;
536 536
537 g_return_val_if_fail (i < section->num_props, NULL); 537 g_return_val_if_fail (i < section->num_props, NULL);
538 g_return_val_if_fail (size >= props[i].offset + 4, NULL); 538 g_return_val_if_fail (size >= props[i].offset + 4, NULL);
539 539
540 size -= props[i].offset; /* includes the type id */ 540 size -= props[i].offset; /* includes the type id */
541 if (gsf_input_seek (in, section->offset+props[i].offset, G_SEEK_SET) || 541 if (gsf_input_seek (in, section->offset+props[i].offset, G_SEEK_SET) ||
542 NULL == (data = gsf_input_read (in, size, NULL))) { 542 NULL == (data = gsf_input_read (in, size, NULL))) {
543 warning ("failed to read prop #%d", i); 543 warning ("failed to read prop #%d", i);
544 return NULL; 544 return NULL;
545 } 545 }
546 546
547 type = GSF_LE_GET_GUINT32 (data); 547 type = GSF_LE_GET_GUINT32 (data);
548 data += 4; 548 data += 4;
549 549
550 /* dictionary is magic */ 550 /* dictionary is magic */
551 if (props[i].id == 0) { 551 if (props[i].id == 0) {
552 guint32 len, id, i, n; 552 guint32 len, id, i, n;
553 gsize gslen; 553 gsize gslen;
554 char *name; 554 char *name;
555 guint8 const *start = data; 555 guint8 const *start = data;
556 556
557 g_return_val_if_fail (section->dict == NULL, NULL); 557 g_return_val_if_fail (section->dict == NULL, NULL);
558 558
559 section->dict = g_hash_table_new_full ( 559 section->dict = g_hash_table_new_full (
560 g_direct_hash, g_direct_equal, 560 g_direct_hash, g_direct_equal,
561 NULL, g_free); 561 NULL, g_free);
562 562
563 d (gsf_mem_dump (data-4, size);); 563 d (gsf_mem_dump (data-4, size););
564 n = type; 564 n = type;
565 for (i = 0 ; i < n ; i++) { 565 for (i = 0 ; i < n ; i++) {
566 id = GSF_LE_GET_GUINT32 (data); 566 id = GSF_LE_GET_GUINT32 (data);
567 len = GSF_LE_GET_GUINT32 (data + 4); 567 len = GSF_LE_GET_GUINT32 (data + 4);
568 568
569 g_return_val_if_fail (len < 0x10000, NULL); 569 g_return_val_if_fail (len < 0x10000, NULL);
570 570
571 gslen = 0; 571 gslen = 0;
572 name = g_convert_with_iconv (data + 8, 572 name = g_convert_with_iconv (data + 8,
573 len * section->char_size, 573 len * section->char_size,
574 section->iconv_handle, &gslen, NULL, NULL); 574 section->iconv_handle, &gslen, NULL, NULL);
575 len = (guint32)gslen; 575 len = (guint32)gslen;
576 data += 8 + len; 576 data += 8 + len;
577 577
578 d (printf ("\t%u == %s\n", id, name);); 578 d (printf ("\t%u == %s\n", id, name););
579 g_hash_table_replace (section->dict, 579 g_hash_table_replace (section->dict,
580 GINT_TO_POINTER (id), name); 580 GINT_TO_POINTER (id), name);
581 581
582 /* MS documentation blows goats ! 582 /* MS documentation blows goats !
583 * The docs claim there are padding bytes in the dictionary. 583 * The docs claim there are padding bytes in the dictionary.
584 * Their examples show padding bytes. 584 * Their examples show padding bytes.
@@ -587,13 +587,13 @@ msole_prop_read (GsfInput *in,
587 if (section->char_size != 1 && (data - start) % 4) 587 if (section->char_size != 1 && (data - start) % 4)
588 data += 4 - ((data - start) % 4); 588 data += 4 - ((data - start) % 4);
589 } 589 }
590 590
591 return NULL; 591 return NULL;
592 } 592 }
593 593
594 d (printf ("%u) ", i);); 594 d (printf ("%u) ", i););
595 prop_name = msole_prop_id_to_gsf (section, props[i].id); 595 prop_name = msole_prop_id_to_gsf (section, props[i].id);
596 596
597 d (printf (" @ %x %x = ", (unsigned)props[i].offset, (unsigned)size);); 597 d (printf (" @ %x %x = ", (unsigned)props[i].offset, (unsigned)size););
598 return msole_prop_parse (section, type, &data, data + size); 598 return msole_prop_parse (section, type, &data, data + size);
599} 599}
@@ -614,12 +614,12 @@ msole_prop_cmp (gconstpointer a, gconstpointer b)
614 * Returns an iconv converter for @codepage -> utf8. 614 * Returns an iconv converter for @codepage -> utf8.
615 **/ 615 **/
616static GIConv 616static GIConv
617gsf_msole_iconv_open_codepage_for_import(char const *to, 617gsf_msole_iconv_open_codepage_for_import(char const *to,
618 int codepage) 618 int codepage)
619{ 619{
620 GIConv iconv_handle; 620 GIConv iconv_handle;
621 g_return_val_if_fail (to != NULL, (GIConv)(-1)); 621 g_return_val_if_fail (to != NULL, (GIConv)(-1));
622 622
623 /* sometimes it is stored as signed short */ 623 /* sometimes it is stored as signed short */
624 if (codepage == 65001 || codepage == -535) { 624 if (codepage == 65001 || codepage == -535) {
625 iconv_handle = g_iconv_open (to, "UTF-8"); 625 iconv_handle = g_iconv_open (to, "UTF-8");
@@ -637,20 +637,20 @@ gsf_msole_iconv_open_codepage_for_import(char const *to,
637 if (iconv_handle != (GIConv)(-1)) 637 if (iconv_handle != (GIConv)(-1))
638 return iconv_handle; 638 return iconv_handle;
639 } 639 }
640 640
641 /* Try aliases. */ 641 /* Try aliases. */
642 if (codepage == 10000) { 642 if (codepage == 10000) {
643 /* gnu iconv. */ 643 /* gnu iconv. */
644 iconv_handle = g_iconv_open (to, "MACROMAN"); 644 iconv_handle = g_iconv_open (to, "MACROMAN");
645 if (iconv_handle != (GIConv)(-1)) 645 if (iconv_handle != (GIConv)(-1))
646 return iconv_handle; 646 return iconv_handle;
647 647
648 /* glibc. */ 648 /* glibc. */
649 iconv_handle = g_iconv_open (to, "MACINTOSH"); 649 iconv_handle = g_iconv_open (to, "MACINTOSH");
650 if (iconv_handle != (GIConv)(-1)) 650 if (iconv_handle != (GIConv)(-1))
651 return iconv_handle; 651 return iconv_handle;
652 } 652 }
653 653
654 warning ("Unable to open an iconv handle from codepage %d -> %s", 654 warning ("Unable to open an iconv handle from codepage %d -> %s",
655 codepage, to); 655 codepage, to);
656 return (GIConv)(-1); 656 return (GIConv)(-1);
@@ -683,18 +683,18 @@ static struct EXTRACTOR_Keywords * process(GsfInput * in,
683 GsfMSOleMetaDataSection *sections; 683 GsfMSOleMetaDataSection *sections;
684 GsfMSOleMetaDataProp *props; 684 GsfMSOleMetaDataProp *props;
685 685
686 if (NULL == data) 686 if (NULL == data)
687 return prev; 687 return prev;
688 688
689 /* NOTE : high word is the os, low word is the os version 689 /* NOTE : high word is the os, low word is the os version
690 * 0 = win16 690 * 0 = win16
691 * 1 = mac 691 * 1 = mac
692 * 2 = win32 692 * 2 = win32
693 */ 693 */
694 os = GSF_LE_GET_GUINT16 (data + 6); 694 os = GSF_LE_GET_GUINT16 (data + 6);
695 695
696 version = GSF_LE_GET_GUINT16 (data + 2); 696 version = GSF_LE_GET_GUINT16 (data + 2);
697 697
698 num_sections = GSF_LE_GET_GUINT32 (data + 24); 698 num_sections = GSF_LE_GET_GUINT32 (data + 24);
699 if (GSF_LE_GET_GUINT16 (data + 0) != 0xfffe 699 if (GSF_LE_GET_GUINT16 (data + 0) != 0xfffe
700 || (version != 0 && version != 1) 700 || (version != 0 && version != 1)
@@ -702,7 +702,7 @@ static struct EXTRACTOR_Keywords * process(GsfInput * in,
702 || num_sections > 100) { /* arbitrary sanity check */ 702 || num_sections > 100) { /* arbitrary sanity check */
703 return prev; 703 return prev;
704 } 704 }
705 705
706 /* extract the section info */ 706 /* extract the section info */
707 sections = (GsfMSOleMetaDataSection *)g_alloca (sizeof (GsfMSOleMetaDataSection)* num_sections); 707 sections = (GsfMSOleMetaDataSection *)g_alloca (sizeof (GsfMSOleMetaDataSection)* num_sections);
708 for (i = 0 ; i < num_sections ; i++) { 708 for (i = 0 ; i < num_sections ; i++) {
@@ -721,7 +721,7 @@ static struct EXTRACTOR_Keywords * process(GsfInput * in,
721 warning ("Unknown property section type, treating it as USER"); 721 warning ("Unknown property section type, treating it as USER");
722 d(gsf_mem_dump (data, 16);); 722 d(gsf_mem_dump (data, 16););
723 } 723 }
724 724
725 sections [i].offset = GSF_LE_GET_GUINT32 (data + 16); 725 sections [i].offset = GSF_LE_GET_GUINT32 (data + 16);
726#ifndef NO_DEBUG_OLE_PROPS 726#ifndef NO_DEBUG_OLE_PROPS
727 d(printf ("0x%x\n", (guint32)sections [i].offset);); 727 d(printf ("0x%x\n", (guint32)sections [i].offset););
@@ -732,7 +732,7 @@ static struct EXTRACTOR_Keywords * process(GsfInput * in,
732 NULL == (data = gsf_input_read (in, 8, NULL))) { 732 NULL == (data = gsf_input_read (in, 8, NULL))) {
733 return prev; 733 return prev;
734 } 734 }
735 735
736 sections[i].iconv_handle = (GIConv)-1; 736 sections[i].iconv_handle = (GIConv)-1;
737 sections[i].char_size = 1; 737 sections[i].char_size = 1;
738 sections[i].dict = NULL; 738 sections[i].dict = NULL;
@@ -746,16 +746,16 @@ static struct EXTRACTOR_Keywords * process(GsfInput * in,
746 g_free (props); 746 g_free (props);
747 return prev; 747 return prev;
748 } 748 }
749 749
750 props [j].id = GSF_LE_GET_GUINT32 (data); 750 props [j].id = GSF_LE_GET_GUINT32 (data);
751 props [j].offset = GSF_LE_GET_GUINT32 (data + 4); 751 props [j].offset = GSF_LE_GET_GUINT32 (data + 4);
752 } 752 }
753 753
754 /* order prop info by offset to facilitate bounds checking */ 754 /* order prop info by offset to facilitate bounds checking */
755 qsort (props, sections[i].num_props, 755 qsort (props, sections[i].num_props,
756 sizeof (GsfMSOleMetaDataProp), 756 sizeof (GsfMSOleMetaDataProp),
757 msole_prop_cmp); 757 msole_prop_cmp);
758 758
759 sections[i].iconv_handle = (GIConv)-1; 759 sections[i].iconv_handle = (GIConv)-1;
760 sections[i].char_size = 1; 760 sections[i].char_size = 1;
761 for (j = 0; j < sections[i].num_props; j++) /* first codepage */ 761 for (j = 0; j < sections[i].num_props; j++) /* first codepage */
@@ -776,7 +776,7 @@ static struct EXTRACTOR_Keywords * process(GsfInput * in,
776 } 776 }
777 if (sections[i].iconv_handle == (GIConv)-1) 777 if (sections[i].iconv_handle == (GIConv)-1)
778 sections[i].iconv_handle = gsf_msole_iconv_open_for_import (1252); 778 sections[i].iconv_handle = gsf_msole_iconv_open_for_import (1252);
779 779
780 for (j = 0; j < sections[i].num_props; j++) /* then dictionary */ 780 for (j = 0; j < sections[i].num_props; j++) /* then dictionary */
781 if (props[j].id == 0) { 781 if (props[j].id == 0) {
782 GValue *v = msole_prop_read (in, sections+i, props, j); 782 GValue *v = msole_prop_read (in, sections+i, props, j);
@@ -784,8 +784,8 @@ static struct EXTRACTOR_Keywords * process(GsfInput * in,
784 if (G_VALUE_TYPE(v) == G_TYPE_STRING) { 784 if (G_VALUE_TYPE(v) == G_TYPE_STRING) {
785 gchar * contents = g_strdup_value_contents(v); 785 gchar * contents = g_strdup_value_contents(v);
786 free(contents); 786 free(contents);
787 } else { 787 } else {
788 788
789 /* FIXME: do something with non-strings... */ 789 /* FIXME: do something with non-strings... */
790 } 790 }
791 if (G_IS_VALUE (v)) 791 if (G_IS_VALUE (v))
@@ -800,13 +800,13 @@ static struct EXTRACTOR_Keywords * process(GsfInput * in,
800 gchar * contents = NULL; 800 gchar * contents = NULL;
801 int pc; 801 int pc;
802 int ipc; 802 int ipc;
803 803
804 if (G_VALUE_TYPE(v) == G_TYPE_STRING) { 804 if (G_VALUE_TYPE(v) == G_TYPE_STRING) {
805 contents = g_strdup_value_contents(v); 805 contents = g_strdup_value_contents(v);
806 } else { 806 } else {
807 /* convert other formats? */ 807 /* convert other formats? */
808 contents = g_strdup_value_contents(v); 808 contents = g_strdup_value_contents(v);
809 } 809 }
810 pc = 0; 810 pc = 0;
811 if (contents != NULL) { 811 if (contents != NULL) {
812 for (ipc=strlen(contents)-1;ipc>=0;ipc--) 812 for (ipc=strlen(contents)-1;ipc>=0;ipc--)
@@ -819,7 +819,7 @@ static struct EXTRACTOR_Keywords * process(GsfInput * in,
819 } 819 }
820 if (pc > 0) { 820 if (pc > 0) {
821 int pos = 0; 821 int pos = 0;
822 const char * prop 822 const char * prop
823 = msole_prop_id_to_gsf(sections+i, props[j].id); 823 = msole_prop_id_to_gsf(sections+i, props[j].id);
824 if (prop != NULL) { 824 if (prop != NULL) {
825 while (tmap[pos].text != NULL) { 825 while (tmap[pos].text != NULL) {
@@ -833,7 +833,7 @@ static struct EXTRACTOR_Keywords * process(GsfInput * in,
833 contents, 833 contents,
834 tmap[pos].type); 834 tmap[pos].type);
835 } 835 }
836 } 836 }
837 if (contents != NULL) 837 if (contents != NULL)
838 free(contents); 838 free(contents);
839 } 839 }
@@ -843,7 +843,7 @@ static struct EXTRACTOR_Keywords * process(GsfInput * in,
843 g_free (v); 843 g_free (v);
844 } 844 }
845 } 845 }
846 846
847 gsf_iconv_close (sections[i].iconv_handle); 847 gsf_iconv_close (sections[i].iconv_handle);
848 g_free (props); 848 g_free (props);
849 if (sections[i].dict != NULL) 849 if (sections[i].dict != NULL)
@@ -865,7 +865,7 @@ static struct EXTRACTOR_Keywords * process(GsfInput * in,
865 "Win32", 865 "Win32",
866 EXTRACTOR_OS); 866 EXTRACTOR_OS);
867 break; 867 break;
868 } 868 }
869 return prev; 869 return prev;
870} 870}
871 871
@@ -876,12 +876,12 @@ static struct EXTRACTOR_Keywords * processSO(GsfInput * src,
876 876
877 size = gsf_input_size(src); 877 size = gsf_input_size(src);
878 if (size < 0x374) /* == 0x375?? */ 878 if (size < 0x374) /* == 0x375?? */
879 return prev; 879 return prev;
880 buf = malloc(size); 880 buf = malloc(size);
881 gsf_input_read(src, size, buf); 881 gsf_input_read(src, size, buf);
882 if ( (buf[0] != 0x0F) || 882 if ( (buf[0] != 0x0F) ||
883 (buf[1] != 0x0) || 883 (buf[1] != 0x0) ||
884 (0 != strncmp(&buf[2], 884 (0 != strncmp(&buf[2],
885 "SfxDocumentInfo", 885 "SfxDocumentInfo",
886 strlen("SfxDocumentInfo"))) || 886 strlen("SfxDocumentInfo"))) ||
887 (buf[0x11] != 0x0B) || 887 (buf[0x11] != 0x0B) ||
@@ -905,7 +905,7 @@ static struct EXTRACTOR_Keywords * processSO(GsfInput * src,
905 prev = addKeyword(prev, 905 prev = addKeyword(prev,
906 &buf[0x117], 906 &buf[0x117],
907 EXTRACTOR_COMMENT); 907 EXTRACTOR_COMMENT);
908 buf[0x296] = '\0'; 908 buf[0x296] = '\0';
909 if (buf[0x216] + buf[0x217] > 0) 909 if (buf[0x216] + buf[0x217] > 0)
910 prev = addKeyword(prev, 910 prev = addKeyword(prev,
911 &buf[0x218], 911 &buf[0x218],
@@ -926,17 +926,17 @@ struct EXTRACTOR_Keywords * libextractor_ole2_extract(const char * filename,
926 guint8 const *data; 926 guint8 const *data;
927 size_t len; 927 size_t len;
928 int i; 928 int i;
929 929
930 input = gsf_input_memory_new((guint8 const *) date, 930 input = gsf_input_memory_new((guint8 const *) date,
931 (gsf_off_t) size, 931 (gsf_off_t) size,
932 FALSE); 932 FALSE);
933 if (input == NULL) 933 if (input == NULL)
934 return prev; 934 return prev;
935 935
936 infile = gsf_infile_msole_new(input, NULL); 936 infile = gsf_infile_msole_new(input, NULL);
937 g_object_unref(G_OBJECT(input)); 937 g_object_unref(G_OBJECT(input));
938 938
939 if (infile == NULL) 939 if (infile == NULL)
940 return prev; 940 return prev;
941 941
942 if (GSF_IS_INFILE(infile) && 942 if (GSF_IS_INFILE(infile) &&
@@ -944,16 +944,16 @@ struct EXTRACTOR_Keywords * libextractor_ole2_extract(const char * filename,
944 GsfInfile * in = GSF_INFILE (infile); 944 GsfInfile * in = GSF_INFILE (infile);
945 GsfInput * src; 945 GsfInput * src;
946 const char * name; 946 const char * name;
947 947
948 for (i=0;i<gsf_infile_num_children(in);i++) { 948 for (i=0;i<gsf_infile_num_children(in);i++) {
949 src = gsf_infile_child_by_index (in, i); 949 src = gsf_infile_child_by_index (in, i);
950 name = gsf_infile_name_by_index (in, i); 950 name = gsf_infile_name_by_index (in, i);
951 951
952 if ( (0 == strcmp(name, "\005SummaryInformation")) 952 if ( (0 == strcmp(name, "\005SummaryInformation"))
953 || (0 == strcmp(name, "\005DocumentSummaryInformation")) ) { 953 || (0 == strcmp(name, "\005DocumentSummaryInformation")) ) {
954 prev = process(src, 954 prev = process(src,
955 prev); 955 prev);
956 } 956 }
957 if (0 == strcmp(name, "SfxDocumentInfo")) { 957 if (0 == strcmp(name, "SfxDocumentInfo")) {
958 prev = processSO(src, 958 prev = processSO(src,
959 prev); 959 prev);
diff --git a/src/plugins/oo/ooextractor.c b/src/plugins/oo/ooextractor.c
index c701d61..7f1fa4c 100644
--- a/src/plugins/oo/ooextractor.c
+++ b/src/plugins/oo/ooextractor.c
@@ -38,7 +38,7 @@ static EXTRACTOR_KeywordList * addKeyword(EXTRACTOR_KeywordType type,
38 if (keyword == NULL) 38 if (keyword == NULL)
39 return next; 39 return next;
40 result = malloc(sizeof(EXTRACTOR_KeywordList)); 40 result = malloc(sizeof(EXTRACTOR_KeywordList));
41 result->next = next; 41 result->next = next;
42 result->keyword = keyword; 42 result->keyword = keyword;
43 result->keywordType = type; 43 result->keywordType = type;
44 return result; 44 return result;
@@ -51,7 +51,7 @@ typedef struct {
51} Matches; 51} Matches;
52 52
53static Matches tmap[] = { 53static Matches tmap[] = {
54 { "meta:generator", EXTRACTOR_SOFTWARE }, 54 { "meta:generator", EXTRACTOR_SOFTWARE },
55 { "meta:page-count", EXTRACTOR_PAGE_COUNT }, 55 { "meta:page-count", EXTRACTOR_PAGE_COUNT },
56 { "meta:creation-date", EXTRACTOR_CREATION_DATE }, 56 { "meta:creation-date", EXTRACTOR_CREATION_DATE },
57 { "dc:date", EXTRACTOR_DATE }, 57 { "dc:date", EXTRACTOR_DATE },
@@ -59,7 +59,7 @@ static Matches tmap[] = {
59 { "dc:language", EXTRACTOR_LANGUAGE }, 59 { "dc:language", EXTRACTOR_LANGUAGE },
60 { "dc:title", EXTRACTOR_TITLE }, 60 { "dc:title", EXTRACTOR_TITLE },
61 { "dc:description", EXTRACTOR_DESCRIPTION }, 61 { "dc:description", EXTRACTOR_DESCRIPTION },
62 { "dc:subject", EXTRACTOR_SUBJECT }, 62 { "dc:subject", EXTRACTOR_SUBJECT },
63 { "meta:keyword", EXTRACTOR_KEYWORDS }, 63 { "meta:keyword", EXTRACTOR_KEYWORDS },
64 { "meta:user-defined meta:name=\"Info 1\"", EXTRACTOR_UNKNOWN }, 64 { "meta:user-defined meta:name=\"Info 1\"", EXTRACTOR_UNKNOWN },
65 { "meta:user-defined meta:name=\"Info 2\"", EXTRACTOR_UNKNOWN }, 65 { "meta:user-defined meta:name=\"Info 2\"", EXTRACTOR_UNKNOWN },
@@ -105,7 +105,7 @@ struct EXTRACTOR_Keywords * libextractor_oo_extract(const char * filename,
105 unzClose(uf); 105 unzClose(uf);
106 return prev; /* problems... */ 106 return prev; /* problems... */
107 } 107 }
108 108
109 if (UNZ_OK != unzOpenCurrentFilePassword(uf,NULL)) { 109 if (UNZ_OK != unzOpenCurrentFilePassword(uf,NULL)) {
110 unzClose(uf); 110 unzClose(uf);
111 return prev; /* problems... */ 111 return prev; /* problems... */
@@ -123,7 +123,7 @@ struct EXTRACTOR_Keywords * libextractor_oo_extract(const char * filename,
123 unzClose(uf); 123 unzClose(uf);
124 return prev; /* out of memory */ 124 return prev; /* out of memory */
125 } 125 }
126 126
127 if (buf_size != unzReadCurrentFile(uf,buf,buf_size)) { 127 if (buf_size != unzReadCurrentFile(uf,buf,buf_size)) {
128 free(buf); 128 free(buf);
129 unzCloseCurrentFile(uf); 129 unzCloseCurrentFile(uf);
@@ -150,10 +150,10 @@ struct EXTRACTOR_Keywords * libextractor_oo_extract(const char * filename,
150 150
151 pbuf = buf; 151 pbuf = buf;
152 152
153 while (1) { 153 while (1) {
154 strcpy(needle, "<"); 154 strcpy(needle, "<");
155 strcat(needle, tmap[i].text); 155 strcat(needle, tmap[i].text);
156 strcat(needle, ">"); 156 strcat(needle, ">");
157 spos = strstr(pbuf, needle); 157 spos = strstr(pbuf, needle);
158 if (NULL == spos) { 158 if (NULL == spos) {
159 strcpy(needle, tmap[i].text); 159 strcpy(needle, tmap[i].text);
@@ -165,7 +165,7 @@ struct EXTRACTOR_Keywords * libextractor_oo_extract(const char * filename,
165 epos = spos; 165 epos = spos;
166 while ( (epos[0] != '\0') && 166 while ( (epos[0] != '\0') &&
167 (epos[0] != '"') ) 167 (epos[0] != '"') )
168 epos++; 168 epos++;
169 } else { 169 } else {
170 oc = 0; 170 oc = 0;
171 spos += strlen(needle); 171 spos += strlen(needle);
@@ -191,13 +191,13 @@ struct EXTRACTOR_Keywords * libextractor_oo_extract(const char * filename,
191 key[epos-spos] = '\0'; 191 key[epos-spos] = '\0';
192 prev = addKeyword(tmap[i].type, 192 prev = addKeyword(tmap[i].type,
193 key, 193 key,
194 prev); 194 prev);
195 pbuf = epos; 195 pbuf = epos;
196 } else 196 } else
197 break; 197 break;
198 } 198 }
199 } 199 }
200 } 200 }
201 free(buf); 201 free(buf);
202 unzClose(uf); 202 unzClose(uf);
203 return prev; 203 return prev;
diff --git a/src/plugins/pack.c b/src/plugins/pack.c
index e7bae79..261dd98 100644
--- a/src/plugins/pack.c
+++ b/src/plugins/pack.c
@@ -2,7 +2,7 @@
2Catlib Copyright Notice 2Catlib Copyright Notice
3 3
4The author of this software is Christopher Adam Telfer 4The author of this software is Christopher Adam Telfer
5Copyright (c) 1998, 1999, 2000, 2001, 2002 5Copyright (c) 1998, 1999, 2000, 2001, 2002
6by Christopher Adam Telfer. All Rights Reserved. 6by Christopher Adam Telfer. All Rights Reserved.
7 7
8Permission to use, copy, modify, and distribute this software for any 8Permission to use, copy, modify, and distribute this software for any
@@ -23,10 +23,10 @@ OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
23MODIFICATIONS. 23MODIFICATIONS.
24 24
25*/ 25*/
26 26
27#include "platform.h" 27#include "platform.h"
28#include "pack.h" 28#include "pack.h"
29 29
30typedef unsigned char byte; 30typedef unsigned char byte;
31typedef unsigned short half; 31typedef unsigned short half;
32typedef unsigned long word; 32typedef unsigned long word;
@@ -35,7 +35,7 @@ typedef signed short shalf;
35typedef signed long sword; 35typedef signed long sword;
36 36
37 37
38/* 38/*
39 "bhwAcslPBHWCSL" 39 "bhwAcslPBHWCSL"
40 40
41 Small letters: do not convert (not implemented for arrays and P) 41 Small letters: do not convert (not implemented for arrays and P)
@@ -45,7 +45,7 @@ typedef signed long sword;
45 h - half-word 45 h - half-word
46 w - word 46 w - word
47 a - array (32-byte unsigned long + that many bytes) 47 a - array (32-byte unsigned long + that many bytes)
48 c - signed 8 bit value 48 c - signed 8 bit value
49 s - signed 16 bit value 49 s - signed 16 bit value
50 l - signed 32 bit value 50 l - signed 32 bit value
51 p - (unpack only) value is a pointer to a pointer. Generate the buffer 51 p - (unpack only) value is a pointer to a pointer. Generate the buffer
@@ -55,7 +55,7 @@ typedef signed long sword;
55 of the arguments specified by the letter 55 of the arguments specified by the letter
56 */ 56 */
57 57
58int cat_pack(void * buf, 58int cat_pack(void * buf,
59 const char *fmt, 59 const char *fmt,
60 ...) { 60 ...) {
61 va_list ap; 61 va_list ap;
@@ -68,15 +68,15 @@ int cat_pack(void * buf,
68 void * arr; 68 void * arr;
69 struct cat_bvec *cbvp; 69 struct cat_bvec *cbvp;
70 char *cp; 70 char *cp;
71 71
72 va_start(ap, fmt); 72 va_start(ap, fmt);
73 73
74 npacked = 0; 74 npacked = 0;
75 bp = (byte *)buf; 75 bp = (byte *)buf;
76 76
77 while( *fmt ) { 77 while( *fmt ) {
78 nreps = 0; 78 nreps = 0;
79 79
80 if ( isdigit(*fmt) ) { 80 if ( isdigit(*fmt) ) {
81 /* We use cp instead of fmt to keep the 'const' qualifier of fmt */ 81 /* We use cp instead of fmt to keep the 'const' qualifier of fmt */
82 nreps = strtoul(fmt, &cp, 0); 82 nreps = strtoul(fmt, &cp, 0);
@@ -98,7 +98,7 @@ int cat_pack(void * buf,
98 npacked += 1; 98 npacked += 1;
99 } 99 }
100 } 100 }
101 break; 101 break;
102 102
103 case 'h': 103 case 'h':
104 case 's': 104 case 's':
@@ -116,8 +116,8 @@ int cat_pack(void * buf,
116 npacked += 2; 116 npacked += 2;
117 } 117 }
118 } 118 }
119 break; 119 break;
120 120
121 case 'H': 121 case 'H':
122 case 'S': 122 case 'S':
123 if ( ! nreps ) { 123 if ( ! nreps ) {
@@ -134,8 +134,8 @@ int cat_pack(void * buf,
134 npacked += 2; 134 npacked += 2;
135 } 135 }
136 } 136 }
137 break; 137 break;
138 138
139 case 'l': 139 case 'l':
140 case 'w': 140 case 'w':
141 if ( ! nreps ) { 141 if ( ! nreps ) {
@@ -157,7 +157,7 @@ int cat_pack(void * buf,
157 } 157 }
158 } 158 }
159 break; 159 break;
160 160
161 case 'L': 161 case 'L':
162 case 'W': 162 case 'W':
163 if ( ! nreps ) { 163 if ( ! nreps ) {
@@ -179,7 +179,7 @@ int cat_pack(void * buf,
179 } 179 }
180 } 180 }
181 break; 181 break;
182 182
183 case 'A': 183 case 'A':
184 if ( ! nreps ) { 184 if ( ! nreps ) {
185 blen = va_arg(ap, word); 185 blen = va_arg(ap, word);
@@ -206,14 +206,14 @@ int cat_pack(void * buf,
206 } 206 }
207 } 207 }
208 break; 208 break;
209 209
210 default: 210 default:
211 va_end(ap); 211 va_end(ap);
212 return -1; 212 return -1;
213 } 213 }
214 ++fmt; 214 ++fmt;
215 } 215 }
216 216
217 va_end(ap); 217 va_end(ap);
218 return npacked; 218 return npacked;
219} 219}
@@ -235,7 +235,7 @@ int cat_unpack(const void * buf,
235 unsigned int nreps, i, isnonprefixed = 1; /* used for 'a' types only */ 235 unsigned int nreps, i, isnonprefixed = 1; /* used for 'a' types only */
236 struct cat_bvec *cbvp; 236 struct cat_bvec *cbvp;
237 char *cp; 237 char *cp;
238 238
239 bp = (byte *)buf; 239 bp = (byte *)buf;
240 npacked = 0; 240 npacked = 0;
241 241
@@ -243,15 +243,15 @@ int cat_unpack(const void * buf,
243 243
244 while ( *fmt ) { 244 while ( *fmt ) {
245 nreps = 1; 245 nreps = 1;
246 246
247 if ( isdigit(*fmt) ) { 247 if ( isdigit(*fmt) ) {
248 /* We use cp instead of format to keep the 'const' qualifier of fmt */ 248 /* We use cp instead of format to keep the 'const' qualifier of fmt */
249 nreps = strtoul(fmt, &cp, 0); 249 nreps = strtoul(fmt, &cp, 0);
250 fmt = cp; 250 fmt = cp;
251 if ( *fmt == 'a' ) 251 if ( *fmt == 'a' )
252 isnonprefixed = 0; 252 isnonprefixed = 0;
253 } 253 }
254 254
255 switch (*fmt) { 255 switch (*fmt) {
256 case 'B': 256 case 'B':
257 case 'b': 257 case 'b':
@@ -262,9 +262,9 @@ int cat_unpack(const void * buf,
262 npacked += 1; 262 npacked += 1;
263 } 263 }
264 break; 264 break;
265 265
266 266
267 267
268 case 'h': 268 case 'h':
269 halfp = va_arg(ap, half*); 269 halfp = va_arg(ap, half*);
270 for ( i = 0 ; i < nreps ; ++i ) { 270 for ( i = 0 ; i < nreps ; ++i ) {
@@ -274,7 +274,7 @@ int cat_unpack(const void * buf,
274 npacked += 2; 274 npacked += 2;
275 } 275 }
276 break; 276 break;
277 277
278 case 'H': 278 case 'H':
279 halfp = va_arg(ap, half*); 279 halfp = va_arg(ap, half*);
280 for ( i = 0 ; i < nreps ; ++i ) { 280 for ( i = 0 ; i < nreps ; ++i ) {
@@ -284,8 +284,8 @@ int cat_unpack(const void * buf,
284 npacked += 2; 284 npacked += 2;
285 } 285 }
286 break; 286 break;
287 287
288 288
289 case 'w': 289 case 'w':
290 wordp = va_arg(ap, word*); 290 wordp = va_arg(ap, word*);
291 for ( i = 0 ; i < nreps ; ++i ) { 291 for ( i = 0 ; i < nreps ; ++i ) {
@@ -297,7 +297,7 @@ int cat_unpack(const void * buf,
297 npacked += 4; 297 npacked += 4;
298 } 298 }
299 break; 299 break;
300 300
301 case 'W': 301 case 'W':
302 wordp = va_arg(ap, word*); 302 wordp = va_arg(ap, word*);
303 for ( i = 0 ; i < nreps ; ++i ) { 303 for ( i = 0 ; i < nreps ; ++i ) {
@@ -309,9 +309,9 @@ int cat_unpack(const void * buf,
309 npacked += 4; 309 npacked += 4;
310 } 310 }
311 break; 311 break;
312 312
313 case 'A': 313 case 'A':
314 if ( isnonprefixed ) { 314 if ( isnonprefixed ) {
315 maxlen = va_arg(ap, word); 315 maxlen = va_arg(ap, word);
316 arr = va_arg(ap, void *); 316 arr = va_arg(ap, void *);
317 317
@@ -332,26 +332,26 @@ int cat_unpack(const void * buf,
332 for ( i = 0 ; i < nreps ; ++i ) { 332 for ( i = 0 ; i < nreps ; ++i ) {
333 maxlen = cbvp->len; 333 maxlen = cbvp->len;
334 arr = cbvp->data; 334 arr = cbvp->data;
335 335
336 len = *bp++ << 24; 336 len = *bp++ << 24;
337 len |= *bp++ << 16; 337 len |= *bp++ << 16;
338 len |= *bp++ << 8; 338 len |= *bp++ << 8;
339 len |= *bp++; 339 len |= *bp++;
340 340
341 if ( len > maxlen ) 341 if ( len > maxlen )
342 return -1; 342 return -1;
343 343
344 memmove(arr, bp, len); 344 memmove(arr, bp, len);
345 cbvp->len = len; 345 cbvp->len = len;
346 bp += len; 346 bp += len;
347 347
348 ++cbvp; 348 ++cbvp;
349 npacked += len; 349 npacked += len;
350 } 350 }
351 isnonprefixed = 1; 351 isnonprefixed = 1;
352 } 352 }
353 break; 353 break;
354 354
355 case 'C': 355 case 'C':
356 case 'c': 356 case 'c':
357 sbytep = va_arg(ap, sbyte*); 357 sbytep = va_arg(ap, sbyte*);
@@ -365,8 +365,8 @@ int cat_unpack(const void * buf,
365 npacked += 1; 365 npacked += 1;
366 } 366 }
367 break; 367 break;
368 368
369 369
370 case 's': 370 case 's':
371 shalfp = va_arg(ap, shalf*); 371 shalfp = va_arg(ap, shalf*);
372 for ( i = 0 ; i < nreps ; ++i ) { 372 for ( i = 0 ; i < nreps ; ++i ) {
@@ -380,7 +380,7 @@ int cat_unpack(const void * buf,
380 npacked += 2; 380 npacked += 2;
381 } 381 }
382 break; 382 break;
383 383
384 case 'S': 384 case 'S':
385 shalfp = va_arg(ap, shalf*); 385 shalfp = va_arg(ap, shalf*);
386 for ( i = 0 ; i < nreps ; ++i ) { 386 for ( i = 0 ; i < nreps ; ++i ) {
@@ -394,7 +394,7 @@ int cat_unpack(const void * buf,
394 npacked += 2; 394 npacked += 2;
395 } 395 }
396 break; 396 break;
397 397
398 case 'l': 398 case 'l':
399 swordp = va_arg(ap, sword*); 399 swordp = va_arg(ap, sword*);
400 for ( i = 0 ; i < nreps ; ++i ) { 400 for ( i = 0 ; i < nreps ; ++i ) {
@@ -426,7 +426,7 @@ int cat_unpack(const void * buf,
426 npacked += 4; 426 npacked += 4;
427 } 427 }
428 break; 428 break;
429 429
430 case 'P': 430 case 'P':
431 cbvp = va_arg(ap, struct cat_bvec *); 431 cbvp = va_arg(ap, struct cat_bvec *);
432 for ( i = 0 ; i < nreps ; ++i ) { 432 for ( i = 0 ; i < nreps ; ++i ) {
@@ -452,7 +452,7 @@ int cat_unpack(const void * buf,
452 npacked += len; 452 npacked += len;
453 } 453 }
454 break; 454 break;
455 455
456 default: 456 default:
457 va_end(ap); 457 va_end(ap);
458 return -1; 458 return -1;
diff --git a/src/plugins/pack.h b/src/plugins/pack.h
index b1ce465..81824f2 100644
--- a/src/plugins/pack.h
+++ b/src/plugins/pack.h
@@ -2,7 +2,7 @@
2Catlib Copyright Notice 2Catlib Copyright Notice
3 3
4The author of this software is Christopher Adam Telfer 4The author of this software is Christopher Adam Telfer
5Copyright (c) 1998, 1999, 2000, 2001, 2002 5Copyright (c) 1998, 1999, 2000, 2001, 2002
6by Christopher Adam Telfer. All Rights Reserved. 6by Christopher Adam Telfer. All Rights Reserved.
7 7
8Permission to use, copy, modify, and distribute this software for any 8Permission to use, copy, modify, and distribute this software for any
@@ -28,7 +28,7 @@ MODIFICATIONS.
28#ifndef __CAT_PACK_H 28#ifndef __CAT_PACK_H
29#define __CAT_PACK_H 29#define __CAT_PACK_H
30 30
31/* 31/*
32 "bhwAcslPBHWCSL" 32 "bhwAcslPBHWCSL"
33 33
34 Small letters: do not convert (not implemented for arrays and P) 34 Small letters: do not convert (not implemented for arrays and P)
@@ -38,14 +38,14 @@ MODIFICATIONS.
38 h - half-word 38 h - half-word
39 w - word 39 w - word
40 a - array (32-byte unsigned long + that many bytes) 40 a - array (32-byte unsigned long + that many bytes)
41 c - signed 8 bit value 41 c - signed 8 bit value
42 s - signed 16 bit value 42 s - signed 16 bit value
43 l - signed 32 bit value 43 l - signed 32 bit value
44 p - (unpack only) value is a pointer to a pointer. Generate the buffer 44 p - (unpack only) value is a pointer to a pointer. Generate the buffer
45 to hold the data. 45 to hold the data.
46 */ 46 */
47 47
48int cat_pack(void * buf, const char *fmt, ... ); 48int cat_pack(void * buf, const char *fmt, ... );
49 49
50int cat_unpack(const void * buf, const char *fmt, ... ); 50int cat_unpack(const void * buf, const char *fmt, ... );
51 51
diff --git a/src/plugins/pdf/Decrypt.cc b/src/plugins/pdf/Decrypt.cc
index dab0750..4277b57 100644
--- a/src/plugins/pdf/Decrypt.cc
+++ b/src/plugins/pdf/Decrypt.cc
@@ -21,8 +21,8 @@ static void md5(Guchar *msg, int msgLen, Guchar *digest);
21 21
22static Guchar passwordPad[32] = { 22static Guchar passwordPad[32] = {
23 0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41, 23 0x28, 0xbf, 0x4e, 0x5e, 0x4e, 0x75, 0x8a, 0x41,
24 0x64, 0x00, 0x4e, 0x56, 0xff, 0xfa, 0x01, 0x08, 24 0x64, 0x00, 0x4e, 0x56, 0xff, 0xfa, 0x01, 0x08,
25 0x2e, 0x2e, 0x00, 0xb6, 0xd0, 0x68, 0x3e, 0x80, 25 0x2e, 0x2e, 0x00, 0xb6, 0xd0, 0x68, 0x3e, 0x80,
26 0x2f, 0x0c, 0xa9, 0xfe, 0x64, 0x53, 0x69, 0x7a 26 0x2f, 0x0c, 0xa9, 0xfe, 0x64, 0x53, 0x69, 0x7a
27}; 27};
28 28
diff --git a/src/plugins/pdf/FontEncoding.cc b/src/plugins/pdf/FontEncoding.cc
index 3d084cc..6916b59 100644
--- a/src/plugins/pdf/FontEncoding.cc
+++ b/src/plugins/pdf/FontEncoding.cc
@@ -97,7 +97,7 @@ void FontEncoding::addChar1(int code, char *name) {
97 int h, i, code2; 97 int h, i, code2;
98 98
99 // insert name in hash table 99 // insert name in hash table
100 h = hash(name); 100 h = hash(name);
101 for (i = 0; i < fontEncHashSize; ++i) { 101 for (i = 0; i < fontEncHashSize; ++i) {
102 code2 = hashTab[h]; 102 code2 = hashTab[h];
103 if (code2 < 0) { 103 if (code2 < 0) {
diff --git a/src/plugins/pdf/Stream.cc b/src/plugins/pdf/Stream.cc
index cf1e764..b7c4475 100644
--- a/src/plugins/pdf/Stream.cc
+++ b/src/plugins/pdf/Stream.cc
@@ -250,7 +250,7 @@ Stream *Stream::makeFilter(char *name, Stream *str, Object *params) {
250 obj.free(); 250 obj.free();
251 } 251 }
252 str = new FlateStream(str, pred, columns, colors, bits); 252 str = new FlateStream(str, pred, columns, colors, bits);
253 } 253 }
254#if 0 254#if 0
255else if (!strcmp(name, "JBIG2Decode")) { 255else if (!strcmp(name, "JBIG2Decode")) {
256 if (params->isDict()) { 256 if (params->isDict()) {
@@ -260,7 +260,7 @@ else if (!strcmp(name, "JBIG2Decode")) {
260 globals.free(); 260 globals.free();
261 } else if (!strcmp(name, "JPXDecode")) { 261 } else if (!strcmp(name, "JPXDecode")) {
262 str = new JPXStream(str); 262 str = new JPXStream(str);
263 } 263 }
264#endif 264#endif
265else { 265else {
266 error(getPos(), "Unknown filter '%s'", name); 266 error(getPos(), "Unknown filter '%s'", name);
@@ -1532,7 +1532,7 @@ int CCITTFaxStream::lookChar() {
1532 eatBits(1); 1532 eatBits(1);
1533 code1 = lookBits(13); 1533 code1 = lookBits(13);
1534 } while ((code1 >> 1) != 0x001); 1534 } while ((code1 >> 1) != 0x001);
1535 eatBits(12); 1535 eatBits(12);
1536 if (encoding > 0) { 1536 if (encoding > 0) {
1537 eatBits(1); 1537 eatBits(1);
1538 nextLine2D = !(code1 & 1); 1538 nextLine2D = !(code1 & 1);
diff --git a/src/plugins/pdf/gfile.cc b/src/plugins/pdf/gfile.cc
index 2600747..1b2e351 100644
--- a/src/plugins/pdf/gfile.cc
+++ b/src/plugins/pdf/gfile.cc
@@ -14,7 +14,7 @@
14#endif 14#endif
15#ifndef WIN32 15#ifndef WIN32
16#include <pwd.h> 16#include <pwd.h>
17#endif 17#endif
18#include "GString.h" 18#include "GString.h"
19#include "gfile.h" 19#include "gfile.h"
20#include <sys/types.h> 20#include <sys/types.h>
diff --git a/src/plugins/pdf/pdfextractor.cc b/src/plugins/pdf/pdfextractor.cc
index 70a75e0..829fe3b 100644
--- a/src/plugins/pdf/pdfextractor.cc
+++ b/src/plugins/pdf/pdfextractor.cc
@@ -48,25 +48,25 @@ extern "C" {
48 char * keyword, 48 char * keyword,
49 struct EXTRACTOR_Keywords * next) { 49 struct EXTRACTOR_Keywords * next) {
50 EXTRACTOR_KeywordList * result; 50 EXTRACTOR_KeywordList * result;
51 51
52 if (keyword == NULL) 52 if (keyword == NULL)
53 return next; 53 return next;
54 result = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList)); 54 result = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList));
55 result->next = next; 55 result->next = next;
56 result->keyword = keyword; 56 result->keyword = keyword;
57 result->keywordType = type; 57 result->keywordType = type;
58 return result; 58 return result;
59 } 59 }
60 60
61 61
62 static struct EXTRACTOR_Keywords * printInfoString(Dict *infoDict, 62 static struct EXTRACTOR_Keywords * printInfoString(Dict *infoDict,
63 char *key, 63 char *key,
64 EXTRACTOR_KeywordType type, 64 EXTRACTOR_KeywordType type,
65 struct EXTRACTOR_Keywords * next) { 65 struct EXTRACTOR_Keywords * next) {
66 Object obj; 66 Object obj;
67 GString *s1; 67 GString *s1;
68 char * s; 68 char * s;
69 69
70 if (infoDict->lookup(key, &obj)->isString()) { 70 if (infoDict->lookup(key, &obj)->isString()) {
71 s1 = obj.getString(); 71 s1 = obj.getString();
72 s = s1->getCString(); 72 s = s1->getCString();
@@ -87,13 +87,13 @@ extern "C" {
87 con = (char*) convertToUtf8((const char*) u, 2, "UNICODE"); 87 con = (char*) convertToUtf8((const char*) u, 2, "UNICODE");
88 strcat(result, con); 88 strcat(result, con);
89 free(con); 89 free(con);
90 } 90 }
91 next = addKeyword(type, 91 next = addKeyword(type,
92 strdup(result), 92 strdup(result),
93 next); 93 next);
94 free(result); 94 free(result);
95 } else { 95 } else {
96 next = addKeyword(type, 96 next = addKeyword(type,
97 convertToUtf8(s, 97 convertToUtf8(s,
98 strlen(s), 98 strlen(s),
99 "ISO-8859-1"), 99 "ISO-8859-1"),
@@ -103,9 +103,9 @@ extern "C" {
103 obj.free(); 103 obj.free();
104 return next; 104 return next;
105 } 105 }
106 106
107 static struct EXTRACTOR_Keywords * printInfoDate(Dict *infoDict, 107 static struct EXTRACTOR_Keywords * printInfoDate(Dict *infoDict,
108 char *key, 108 char *key,
109 EXTRACTOR_KeywordType type, 109 EXTRACTOR_KeywordType type,
110 struct EXTRACTOR_Keywords * next) { 110 struct EXTRACTOR_Keywords * next) {
111 Object obj; 111 Object obj;
@@ -134,7 +134,7 @@ extern "C" {
134 con = (char*) convertToUtf8((const char*) u, 2, "UNICODE"); 134 con = (char*) convertToUtf8((const char*) u, 2, "UNICODE");
135 strcat(result, con); 135 strcat(result, con);
136 free(con); 136 free(con);
137 } 137 }
138 next = addKeyword(type, 138 next = addKeyword(type,
139 strdup(result), 139 strdup(result),
140 next); 140 next);
@@ -151,7 +151,7 @@ extern "C" {
151 return next; 151 return next;
152 } 152 }
153 153
154 154
155 /* which mime-types should not be subjected to 155 /* which mime-types should not be subjected to
156 the PDF extractor? (no use trying!) */ 156 the PDF extractor? (no use trying!) */
157 static char * blacklist[] = { 157 static char * blacklist[] = {
@@ -178,8 +178,8 @@ extern "C" {
178 "video/asf", 178 "video/asf",
179 "video/quicktime", 179 "video/quicktime",
180 NULL, 180 NULL,
181 }; 181 };
182 182
183 183
184 static const char * 184 static const char *
185 extractLast (const EXTRACTOR_KeywordType type, 185 extractLast (const EXTRACTOR_KeywordType type,
@@ -204,7 +204,7 @@ extern "C" {
204 Object info; 204 Object info;
205 struct EXTRACTOR_Keywords * result; 205 struct EXTRACTOR_Keywords * result;
206 const char * mime; 206 const char * mime;
207 207
208 /* if the mime-type of the file is blacklisted, don't 208 /* if the mime-type of the file is blacklisted, don't
209 run the printable extactor! */ 209 run the printable extactor! */
210 mime = extractLast(EXTRACTOR_MIMETYPE, 210 mime = extractLast(EXTRACTOR_MIMETYPE,
@@ -218,7 +218,7 @@ extern "C" {
218 218
219 j++; 219 j++;
220 } 220 }
221 } 221 }
222 222
223 fileName = new GString(filename); 223 fileName = new GString(filename);
224 /* errorInit(); -- keep commented out, otherwise errors are printed to stderr for non-pdf files! */ 224 /* errorInit(); -- keep commented out, otherwise errors are printed to stderr for non-pdf files! */
@@ -229,34 +229,34 @@ extern "C" {
229 freeParams(); 229 freeParams();
230 return prev; 230 return prev;
231 } 231 }
232 232
233 result = addKeyword(EXTRACTOR_MIMETYPE, 233 result = addKeyword(EXTRACTOR_MIMETYPE,
234 strdup("application/pdf"), 234 strdup("application/pdf"),
235 prev); 235 prev);
236 doc->getDocInfo(&info); 236 doc->getDocInfo(&info);
237 if (info.isDict()) { 237 if (info.isDict()) {
238 result = printInfoString(info.getDict(), 238 result = printInfoString(info.getDict(),
239 "Title", 239 "Title",
240 EXTRACTOR_TITLE, 240 EXTRACTOR_TITLE,
241 result); 241 result);
242 result = printInfoString(info.getDict(), 242 result = printInfoString(info.getDict(),
243 "Subject", 243 "Subject",
244 EXTRACTOR_SUBJECT, 244 EXTRACTOR_SUBJECT,
245 result); 245 result);
246 result = printInfoString(info.getDict(), 246 result = printInfoString(info.getDict(),
247 "Keywords", 247 "Keywords",
248 EXTRACTOR_KEYWORDS, 248 EXTRACTOR_KEYWORDS,
249 result); 249 result);
250 result = printInfoString(info.getDict(), 250 result = printInfoString(info.getDict(),
251 "Author", 251 "Author",
252 EXTRACTOR_AUTHOR, 252 EXTRACTOR_AUTHOR,
253 result); 253 result);
254 result = printInfoString(info.getDict(), 254 result = printInfoString(info.getDict(),
255 "Creator", 255 "Creator",
256 EXTRACTOR_CREATOR, 256 EXTRACTOR_CREATOR,
257 result); 257 result);
258 result = printInfoString(info.getDict(), 258 result = printInfoString(info.getDict(),
259 "Producer", 259 "Producer",
260 EXTRACTOR_PRODUCER, 260 EXTRACTOR_PRODUCER,
261 result); 261 result);
262 { 262 {
@@ -273,11 +273,11 @@ extern "C" {
273 strdup(pcnt), 273 strdup(pcnt),
274 result); 274 result);
275 } 275 }
276 result = printInfoDate(info.getDict(), 276 result = printInfoDate(info.getDict(),
277 "CreationDate", 277 "CreationDate",
278 EXTRACTOR_CREATION_DATE, 278 EXTRACTOR_CREATION_DATE,
279 result); 279 result);
280 result = printInfoDate(info.getDict(), 280 result = printInfoDate(info.getDict(),
281 "ModDate", 281 "ModDate",
282 EXTRACTOR_MODIFICATION_DATE, 282 EXTRACTOR_MODIFICATION_DATE,
283 result); 283 result);
@@ -286,7 +286,7 @@ extern "C" {
286 info.free(); 286 info.free();
287 delete doc; 287 delete doc;
288 freeParams(); 288 freeParams();
289 289
290 return result; 290 return result;
291 } 291 }
292} 292}
diff --git a/src/plugins/pngextractor.c b/src/plugins/pngextractor.c
index 473065d..7e5e9a7 100644
--- a/src/plugins/pngextractor.c
+++ b/src/plugins/pngextractor.c
@@ -40,7 +40,7 @@ static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordType type,
40 if (keyword == NULL) 40 if (keyword == NULL)
41 return next; 41 return next;
42 result = malloc(sizeof(EXTRACTOR_KeywordList)); 42 result = malloc(sizeof(EXTRACTOR_KeywordList));
43 result->next = next; 43 result->next = next;
44 result->keyword = keyword; 44 result->keyword = keyword;
45 result->keywordType = type; 45 result->keywordType = type;
46 return result; 46 return result;
@@ -58,17 +58,17 @@ static struct {
58 char * name; 58 char * name;
59 EXTRACTOR_KeywordType type; 59 EXTRACTOR_KeywordType type;
60} tagmap[] = { 60} tagmap[] = {
61 { "Author" , EXTRACTOR_AUTHOR}, 61 { "Author" , EXTRACTOR_AUTHOR},
62 { "Description" , EXTRACTOR_DESCRIPTION}, 62 { "Description" , EXTRACTOR_DESCRIPTION},
63 { "Comment", EXTRACTOR_COMMENT}, 63 { "Comment", EXTRACTOR_COMMENT},
64 { "Copyright", EXTRACTOR_COPYRIGHT}, 64 { "Copyright", EXTRACTOR_COPYRIGHT},
65 { "Source", EXTRACTOR_SOURCE}, 65 { "Source", EXTRACTOR_SOURCE},
66 { "Creation Time", EXTRACTOR_DATE}, 66 { "Creation Time", EXTRACTOR_DATE},
67 { "Title", EXTRACTOR_TITLE}, 67 { "Title", EXTRACTOR_TITLE},
68 { "Software", EXTRACTOR_SOFTWARE}, 68 { "Software", EXTRACTOR_SOFTWARE},
69 { "Disclaimer", EXTRACTOR_DISCLAIMER}, 69 { "Disclaimer", EXTRACTOR_DISCLAIMER},
70 { "Warning", EXTRACTOR_WARNING}, 70 { "Warning", EXTRACTOR_WARNING},
71 { "Signature", EXTRACTOR_RESOURCE_IDENTIFIER}, 71 { "Signature", EXTRACTOR_RESOURCE_IDENTIFIER},
72 { NULL, EXTRACTOR_UNKNOWN}, 72 { NULL, EXTRACTOR_UNKNOWN},
73}; 73};
74 74
@@ -83,7 +83,7 @@ static struct EXTRACTOR_Keywords * processtEXt(const unsigned char * data,
83 off = strnlen(data, length) + 1; 83 off = strnlen(data, length) + 1;
84 if (off >= length) 84 if (off >= length)
85 return prev; /* failed to find '\0' */ 85 return prev; /* failed to find '\0' */
86 keyword = convertToUtf8(&data[off], 86 keyword = convertToUtf8(&data[off],
87 length-off, 87 length-off,
88 "ISO-8859-1"); 88 "ISO-8859-1");
89 i = 0; 89 i = 0;
@@ -111,7 +111,7 @@ static struct EXTRACTOR_Keywords * processiTXt(const unsigned char * data,
111 int compressed; 111 int compressed;
112 char * buf; 112 char * buf;
113 uLongf bufLen; 113 uLongf bufLen;
114 int ret; 114 int ret;
115 115
116 pos = strnlen(data, length)+1; 116 pos = strnlen(data, length)+1;
117 if (pos+3 >= length) 117 if (pos+3 >= length)
@@ -135,7 +135,7 @@ static struct EXTRACTOR_Keywords * processiTXt(const unsigned char * data,
135 pos += strnlen(translated, length-pos)+1; 135 pos += strnlen(translated, length-pos)+1;
136 if (pos >= length) 136 if (pos >= length)
137 return prev; 137 return prev;
138 138
139 if (compressed) { 139 if (compressed) {
140 bufLen = 1024 + 2 * (length - pos); 140 bufLen = 1024 + 2 * (length - pos);
141 while (1) { 141 while (1) {
@@ -167,10 +167,10 @@ static struct EXTRACTOR_Keywords * processiTXt(const unsigned char * data,
167 free(buf); 167 free(buf);
168 } else { 168 } else {
169 keyword = stndup(&data[pos], length - pos); 169 keyword = stndup(&data[pos], length - pos);
170 } 170 }
171 i = 0; 171 i = 0;
172 while (tagmap[i].name != NULL) { 172 while (tagmap[i].name != NULL) {
173 if (0 == strcmp(tagmap[i].name, 173 if (0 == strcmp(tagmap[i].name,
174 data)) 174 data))
175 return addKeyword(tagmap[i].type, 175 return addKeyword(tagmap[i].type,
176 keyword, /* already in utf-8 */ 176 keyword, /* already in utf-8 */
@@ -195,7 +195,7 @@ static struct EXTRACTOR_Keywords * processIHDR(const unsigned char * data,
195 128, 195 128,
196 "%ux%u", 196 "%ux%u",
197 htonl(getIntAt(&data[4])), 197 htonl(getIntAt(&data[4])),
198 htonl(getIntAt(&data[8]))); 198 htonl(getIntAt(&data[8])));
199 return addKeyword(EXTRACTOR_SIZE, 199 return addKeyword(EXTRACTOR_SIZE,
200 tmp, 200 tmp,
201 prev); 201 prev);
@@ -293,19 +293,19 @@ struct EXTRACTOR_Keywords * libextractor_png_extract(char * filename,
293 length = htonl(getIntAt(pos)); pos+=4; 293 length = htonl(getIntAt(pos)); pos+=4;
294 /* printf("Length: %u, pos %u\n", length, pos - data); */ 294 /* printf("Length: %u, pos %u\n", length, pos - data); */
295 if ( (pos+4+length+4 > end) || 295 if ( (pos+4+length+4 > end) ||
296 (pos+4+length+4 < pos + 4 + length) ) 296 (pos+4+length+4 < pos + 4 + length) )
297 break; 297 break;
298 298
299 if (0 == strncmp(pos, "IHDR", 4)) 299 if (0 == strncmp(pos, "IHDR", 4))
300 result = processIHDR(pos, length, result); 300 result = processIHDR(pos, length, result);
301 if (0 == strncmp(pos, "iTXt", 4)) 301 if (0 == strncmp(pos, "iTXt", 4))
302 result = processiTXt(pos, length, result); 302 result = processiTXt(pos, length, result);
303 if (0 == strncmp(pos, "tEXt", 4)) 303 if (0 == strncmp(pos, "tEXt", 4))
304 result = processtEXt(pos, length, result); 304 result = processtEXt(pos, length, result);
305 if (0 == strncmp(pos, "zTXt", 4)) 305 if (0 == strncmp(pos, "zTXt", 4))
306 result = processzTXt(pos, length, result); 306 result = processzTXt(pos, length, result);
307 pos += 4+length+4; /* Chunk type, data, crc */ 307 pos += 4+length+4; /* Chunk type, data, crc */
308 } 308 }
309 return result; 309 return result;
310} 310}
311 311
diff --git a/src/plugins/printable/bloomfilter.c b/src/plugins/printable/bloomfilter.c
index a446bcb..60cf52a 100644
--- a/src/plugins/printable/bloomfilter.c
+++ b/src/plugins/printable/bloomfilter.c
@@ -28,7 +28,7 @@
28 * 28 *
29 * A property of the bloom filter is that sometimes we will have 29 * A property of the bloom filter is that sometimes we will have
30 * a match even if the element is not on the disk (then we do 30 * a match even if the element is not on the disk (then we do
31 * an unnecessary disk access), but what's most important is that 31 * an unnecessary disk access), but what's most important is that
32 * we never get a single "false negative". 32 * we never get a single "false negative".
33 * 33 *
34 * @author Igor Wronsky 34 * @author Igor Wronsky
@@ -42,17 +42,17 @@
42/** 42/**
43 * Sets a bit active in the bitArray. Increment bit-specific 43 * Sets a bit active in the bitArray. Increment bit-specific
44 * usage counter on disk only if below 4bit max (==15). 44 * usage counter on disk only if below 4bit max (==15).
45 * 45 *
46 * @param bitArray memory area to set the bit in 46 * @param bitArray memory area to set the bit in
47 * @param bitIdx which bit to set 47 * @param bitIdx which bit to set
48 */ 48 */
49static void setBit(unsigned char * bitArray, 49static void setBit(unsigned char * bitArray,
50 unsigned int bitIdx) { 50 unsigned int bitIdx) {
51 unsigned int arraySlot; 51 unsigned int arraySlot;
52 unsigned int targetBit; 52 unsigned int targetBit;
53 53
54 arraySlot = bitIdx / 8; 54 arraySlot = bitIdx / 8;
55 targetBit = (1L << (bitIdx % 8)); 55 targetBit = (1L << (bitIdx % 8));
56 bitArray[arraySlot] |= targetBit; 56 bitArray[arraySlot] |= targetBit;
57} 57}
58 58
@@ -63,13 +63,13 @@ static void setBit(unsigned char * bitArray,
63 * @param bitIdx which bit to test 63 * @param bitIdx which bit to test
64 * @return 1 if the bit is set, 0 if not. 64 * @return 1 if the bit is set, 0 if not.
65 */ 65 */
66static int testBit(unsigned char * bitArray, 66static int testBit(unsigned char * bitArray,
67 unsigned int bitIdx) { 67 unsigned int bitIdx) {
68 unsigned int slot; 68 unsigned int slot;
69 unsigned int targetBit; 69 unsigned int targetBit;
70 70
71 slot = bitIdx / 8; 71 slot = bitIdx / 8;
72 targetBit = (1L << (bitIdx % 8)); 72 targetBit = (1L << (bitIdx % 8));
73 return (bitArray[slot] & targetBit) != 0; 73 return (bitArray[slot] & targetBit) != 0;
74} 74}
75 75
@@ -87,7 +87,7 @@ static int testBit(unsigned char * bitArray,
87typedef void (*BitIterator)(Bloomfilter * bf, 87typedef void (*BitIterator)(Bloomfilter * bf,
88 unsigned int bit, 88 unsigned int bit,
89 void * arg); 89 void * arg);
90 90
91/** 91/**
92 * Call an iterator for each bit that the bloomfilter 92 * Call an iterator for each bit that the bloomfilter
93 * must test or set for this element. 93 * must test or set for this element.
@@ -114,8 +114,8 @@ static void iterateBits(Bloomfilter * bf,
114 while (bitCount > 0) { 114 while (bitCount > 0) {
115 while (slot < (sizeof(HashCode160)/ 115 while (slot < (sizeof(HashCode160)/
116 sizeof(unsigned int))) { 116 sizeof(unsigned int))) {
117 callback(bf, 117 callback(bf,
118 (((unsigned int*)&tmp[round&1])[slot]) % (bf->bitArraySize*8), 118 (((unsigned int*)&tmp[round&1])[slot]) % (bf->bitArraySize*8),
119 arg); 119 arg);
120 slot++; 120 slot++;
121 bitCount--; 121 bitCount--;
@@ -149,7 +149,7 @@ static void setBitCallback(Bloomfilter * bf,
149/** 149/**
150 * Callback: test if all bits are set 150 * Callback: test if all bits are set
151 * 151 *
152 * @param bf the filter 152 * @param bf the filter
153 * @param bit the bit to test 153 * @param bit the bit to test
154 * @param arg pointer set to NO if bit is not set 154 * @param arg pointer set to NO if bit is not set
155 */ 155 */
@@ -174,10 +174,10 @@ int testBloomfilter(Bloomfilter * bf,
174 HashCode160 * e) { 174 HashCode160 * e) {
175 int res; 175 int res;
176 176
177 if (NULL == bf) 177 if (NULL == bf)
178 return 1; 178 return 1;
179 res = 1; 179 res = 1;
180 iterateBits(bf, 180 iterateBits(bf,
181 (BitIterator)&testBitCallback, 181 (BitIterator)&testBitCallback,
182 &res, 182 &res,
183 e); 183 e);
@@ -193,7 +193,7 @@ int testBloomfilter(Bloomfilter * bf,
193void addToBloomfilter(Bloomfilter * bf, 193void addToBloomfilter(Bloomfilter * bf,
194 HashCode160 * e) { 194 HashCode160 * e) {
195 195
196 if (NULL == bf) 196 if (NULL == bf)
197 return; 197 return;
198 iterateBits(bf, 198 iterateBits(bf,
199 &setBitCallback, 199 &setBitCallback,
diff --git a/src/plugins/printable/bloomfilter.h b/src/plugins/printable/bloomfilter.h
index 3813860..e5137bb 100644
--- a/src/plugins/printable/bloomfilter.h
+++ b/src/plugins/printable/bloomfilter.h
@@ -28,7 +28,7 @@
28#include "sha1.h" 28#include "sha1.h"
29 29
30typedef struct { 30typedef struct {
31 /** How many bits we set for each stored element */ 31 /** How many bits we set for each stored element */
32 unsigned int addressesPerElement; 32 unsigned int addressesPerElement;
33 /** The actual bloomfilter bit array */ 33 /** The actual bloomfilter bit array */
34 unsigned char * bitArray; 34 unsigned char * bitArray;
@@ -53,4 +53,4 @@ int testBloomfilter(Bloomfilter * bf,
53void addToBloomfilter(Bloomfilter * bf, 53void addToBloomfilter(Bloomfilter * bf,
54 HashCode160 * e); 54 HashCode160 * e);
55 55
56#endif 56#endif
diff --git a/src/plugins/printable/dictionary-builder.c b/src/plugins/printable/dictionary-builder.c
index f7b8d68..e405613 100644
--- a/src/plugins/printable/dictionary-builder.c
+++ b/src/plugins/printable/dictionary-builder.c
@@ -6,7 +6,7 @@
6#include "bloomfilter.h" 6#include "bloomfilter.h"
7 7
8#include "sha1.c" 8#include "sha1.c"
9#include "bloomfilter.c" 9#include "bloomfilter.c"
10 10
11#define ADDR_PER_ELEMENT 46 11#define ADDR_PER_ELEMENT 46
12 12
@@ -23,30 +23,30 @@ int main(int argc,
23 FILE *dictin; 23 FILE *dictin;
24 char * bn; 24 char * bn;
25#define ALLOCSIZE 1024*1024 25#define ALLOCSIZE 1024*1024
26 26
27 if (argc<2) { 27 if (argc<2) {
28 fprintf(stderr, 28 fprintf(stderr,
29 _("Please provide the name of the language you are building\n" 29 _("Please provide the name of the language you are building\n"
30 "a dictionary for. For example:\n")); 30 "a dictionary for. For example:\n"));
31 fprintf(stderr, "$ ./dictionary-builder en > en.c\n"); 31 fprintf(stderr, "$ ./dictionary-builder en > en.c\n");
32 exit(-1); 32 exit(-1);
33 } 33 }
34 34
35 fn = malloc(strlen(argv[1]) + 6); 35 fn = malloc(strlen(argv[1]) + 6);
36 strcpy(fn, argv[1]); 36 strcpy(fn, argv[1]);
37 strcat(fn, ".txt"); 37 strcat(fn, ".txt");
38 dictin=fopen(fn,"r"); 38 dictin=fopen(fn,"r");
39 free(fn); 39 free(fn);
40 if (dictin==NULL) { 40 if (dictin==NULL) {
41 fprintf(stderr, 41 fprintf(stderr,
42 _("Error opening file '%s': %s\n"), 42 _("Error opening file '%s': %s\n"),
43 argv[1],strerror(errno)); 43 argv[1],strerror(errno));
44 exit(-1); 44 exit(-1);
45 } 45 }
46 46
47 words = malloc(sizeof(char*) * ALLOCSIZE); /* don't we LOVE constant size buffers? */ 47 words = malloc(sizeof(char*) * ALLOCSIZE); /* don't we LOVE constant size buffers? */
48 if (words == NULL) { 48 if (words == NULL) {
49 fprintf(stderr, 49 fprintf(stderr,
50 _("Error allocating: %s\n."), 50 _("Error allocating: %s\n."),
51 strerror(errno)); 51 strerror(errno));
52 exit(-1); 52 exit(-1);
@@ -54,18 +54,18 @@ int main(int argc,
54 cnt = 0; 54 cnt = 0;
55 memset(&line[0], 0, 2048); 55 memset(&line[0], 0, 2048);
56 while (1 == fscanf(dictin, "%s", (char*)&line)) { 56 while (1 == fscanf(dictin, "%s", (char*)&line)) {
57 words[cnt] = strdup(line); 57 words[cnt] = strdup(line);
58 cnt++; 58 cnt++;
59 memset(&line[0], 0, 2048); 59 memset(&line[0], 0, 2048);
60 if (cnt > ALLOCSIZE) { 60 if (cnt > ALLOCSIZE) {
61 fprintf(stderr, 61 fprintf(stderr,
62 _("Increase ALLOCSIZE (in %s).\n"), 62 _("Increase ALLOCSIZE (in %s).\n"),
63 __FILE__); 63 __FILE__);
64 exit(-1); 64 exit(-1);
65 } 65 }
66 66
67 } 67 }
68 68
69 bf.addressesPerElement = ADDR_PER_ELEMENT; 69 bf.addressesPerElement = ADDR_PER_ELEMENT;
70 bf.bitArraySize = cnt*4; 70 bf.bitArraySize = cnt*4;
71 bf.bitArray = malloc(bf.bitArraySize); 71 bf.bitArray = malloc(bf.bitArraySize);
@@ -82,7 +82,7 @@ int main(int argc,
82 "#include \"bloomfilter.h\"\n"); 82 "#include \"bloomfilter.h\"\n");
83 83
84 /* use int[] instead of char[] since it cuts the memory use of 84 /* use int[] instead of char[] since it cuts the memory use of
85 gcc down to a quarter; don't use long long since various 85 gcc down to a quarter; don't use long long since various
86 gcc versions then output tons of warnings about "decimal constant 86 gcc versions then output tons of warnings about "decimal constant
87 is so large that it is unsigned" (even for unsigned long long[] 87 is so large that it is unsigned" (even for unsigned long long[]
88 that warning is generated and dramatically increases compile times). */ 88 that warning is generated and dramatically increases compile times). */
@@ -90,7 +90,7 @@ int main(int argc,
90 "static int bits[] = { "); 90 "static int bits[] = { ");
91 for (i=0;i<bf.bitArraySize/sizeof(int);i++) 91 for (i=0;i<bf.bitArraySize/sizeof(int);i++)
92 fprintf(stdout, 92 fprintf(stdout,
93 "%dL,", 93 "%dL,",
94 (((int*)bf.bitArray)[i])); 94 (((int*)bf.bitArray)[i]));
95 fprintf(stdout, 95 fprintf(stdout,
96 "};\n"); 96 "};\n");
diff --git a/src/plugins/printable/printableextractor.c b/src/plugins/printable/printableextractor.c
index c656c3a..fad0ea6 100644
--- a/src/plugins/printable/printableextractor.c
+++ b/src/plugins/printable/printableextractor.c
@@ -47,7 +47,7 @@ static struct EXTRACTOR_Keywords * addKeyword(struct EXTRACTOR_Keywords * list,
47 char * keyword) { 47 char * keyword) {
48 EXTRACTOR_KeywordList * next; 48 EXTRACTOR_KeywordList * next;
49 next = malloc(sizeof(EXTRACTOR_KeywordList)); 49 next = malloc(sizeof(EXTRACTOR_KeywordList));
50 next->next = list; 50 next->next = list;
51 next->keyword = keyword; 51 next->keyword = keyword;
52 next->keywordType = EXTRACTOR_UNKNOWN; 52 next->keywordType = EXTRACTOR_UNKNOWN;
53 return next; 53 return next;
@@ -55,7 +55,7 @@ static struct EXTRACTOR_Keywords * addKeyword(struct EXTRACTOR_Keywords * list,
55 55
56 56
57/** 57/**
58 * 58 *
59 * @param word (alphabetic characters without spaces) 59 * @param word (alphabetic characters without spaces)
60 * @return 0 if it is no word, 1 if it is 60 * @return 0 if it is no word, 1 if it is
61 **/ 61 **/
@@ -83,8 +83,8 @@ static int wordTest(char * word,
83 if (isupper(word[i])) 83 if (isupper(word[i]))
84 count++; 84 count++;
85 } 85 }
86 if ( ((count==1) && (isupper(word[0]))) || 86 if ( ((count==1) && (isupper(word[0]))) ||
87 (count == strlen(word)) ){ 87 (count == strlen(word)) ){
88 lower = strdup(word); 88 lower = strdup(word);
89 for (i=strlen(lower)-1;i>=0;i--) 89 for (i=strlen(lower)-1;i>=0;i--)
90 lower[i] = tolower(lower[i]); 90 lower[i] = tolower(lower[i]);
@@ -94,12 +94,12 @@ static int wordTest(char * word,
94 i = testBloomfilter(&FILTER_NAME, 94 i = testBloomfilter(&FILTER_NAME,
95 &hc); 95 &hc);
96 free(lower); 96 free(lower);
97 } else 97 } else
98 i=0; 98 i=0;
99 } 99 }
100 if (i) { 100 if (i) {
101 switch(strlen(word)) { 101 switch(strlen(word)) {
102 case 1: 102 case 1:
103 *strlenthreshold = 6 * (*strlenthreshold); 103 *strlenthreshold = 6 * (*strlenthreshold);
104 break; 104 break;
105 case 2: 105 case 2:
@@ -129,7 +129,7 @@ static int wordTest(char * word,
129 if (*strlenthreshold < 0.25) 129 if (*strlenthreshold < 0.25)
130 *strlenthreshold = 0.25; 130 *strlenthreshold = 0.25;
131 } 131 }
132 132
133 return i; 133 return i;
134} 134}
135 135
@@ -140,7 +140,7 @@ static void addKeywordToList(char * keyword,
140 if (*tail != NULL) { 140 if (*tail != NULL) {
141 (*tail)->next = addKeyword(NULL, keyword); 141 (*tail)->next = addKeyword(NULL, keyword);
142 *tail = (*tail)->next; 142 *tail = (*tail)->next;
143 } else { 143 } else {
144 *tail = addKeyword(NULL, keyword); 144 *tail = addKeyword(NULL, keyword);
145 *head = *tail; 145 *head = *tail;
146 } 146 }
@@ -180,7 +180,7 @@ static int process(char * keyword,
180 free(keyword); 180 free(keyword);
181 if (isprint(sxdup[0])) { 181 if (isprint(sxdup[0])) {
182 i=0; 182 i=0;
183 while ( (! isprint(sxdup[i+1])) 183 while ( (! isprint(sxdup[i+1]))
184 && (i<len-1) ) 184 && (i<len-1) )
185 i++; 185 i++;
186 free(sxdup); 186 free(sxdup);
@@ -191,7 +191,7 @@ static int process(char * keyword,
191 } 191 }
192 } 192 }
193 addKeywordToList(xstrndup(keyword, max), 193 addKeywordToList(xstrndup(keyword, max),
194 head, 194 head,
195 tail); 195 tail);
196 free(keyword); 196 free(keyword);
197 p=0; 197 p=0;
@@ -230,7 +230,7 @@ static void testKeyword(size_t start,
230 if (wordTest(keyword, thresh)) { 230 if (wordTest(keyword, thresh)) {
231 addKeywordToList(keyword, 231 addKeywordToList(keyword,
232 head, 232 head,
233 tail); 233 tail);
234 return; 234 return;
235 } 235 }
236 i = 0; 236 i = 0;
@@ -238,7 +238,7 @@ static void testKeyword(size_t start,
238 i += process(xstrndup(&keyword[i], MAXBLEN), 238 i += process(xstrndup(&keyword[i], MAXBLEN),
239 thresh, 239 thresh,
240 head, 240 head,
241 tail); 241 tail);
242 } 242 }
243 process(strdup(&keyword[i]), 243 process(strdup(&keyword[i]),
244 thresh, 244 thresh,
@@ -299,7 +299,7 @@ static void processSentences(struct EXTRACTOR_Keywords ** head,
299 numWords = 0; 299 numWords = 0;
300 continue; 300 continue;
301 } 301 }
302 } 302 }
303 303
304 /* found sentence! build & advance start! */ 304 /* found sentence! build & advance start! */
305 if (start == NULL) 305 if (start == NULL)
@@ -344,7 +344,7 @@ static void processSentences(struct EXTRACTOR_Keywords ** head,
344 pos = last->next; 344 pos = last->next;
345 numSentences++; 345 numSentences++;
346 numWords = 0; 346 numWords = 0;
347 continue; 347 continue;
348 } 348 }
349 *tail = last; 349 *tail = last;
350} 350}
@@ -396,7 +396,7 @@ struct EXTRACTOR_Keywords * EXTRACT_NAME (char * filename,
396 struct EXTRACTOR_Keywords * head = NULL; 396 struct EXTRACTOR_Keywords * head = NULL;
397 struct EXTRACTOR_Keywords * tail = NULL; 397 struct EXTRACTOR_Keywords * tail = NULL;
398 double thresh = 2.0; 398 double thresh = 2.0;
399 399
400 /* if the mime-type of the file is blacklisted, don't 400 /* if the mime-type of the file is blacklisted, don't
401 run the printable extactor! */ 401 run the printable extactor! */
402 mime = EXTRACTOR_extractLast(EXTRACTOR_MIMETYPE, 402 mime = EXTRACTOR_extractLast(EXTRACTOR_MIMETYPE,
@@ -409,8 +409,8 @@ struct EXTRACTOR_Keywords * EXTRACT_NAME (char * filename,
409 return prev; 409 return prev;
410 j++; 410 j++;
411 } 411 }
412 } 412 }
413 413
414 last = 0; 414 last = 0;
415 pos = 0; 415 pos = 0;
416 while (last < size) { 416 while (last < size) {
@@ -450,7 +450,7 @@ struct EXTRACTOR_Keywords * EXTRACT_NAME (char * filename,
450 &head, 450 &head,
451 &tail); 451 &tail);
452 while ( (last < size) && 452 while ( (last < size) &&
453 (isspace(data[last])) ) 453 (isspace(data[last])) )
454 last++; 454 last++;
455 } 455 }
456 processSentences(&head, &tail); 456 processSentences(&head, &tail);
diff --git a/src/plugins/printable/sha1.c b/src/plugins/printable/sha1.c
index 6e496b5..ced5702 100644
--- a/src/plugins/printable/sha1.c
+++ b/src/plugins/printable/sha1.c
@@ -269,11 +269,11 @@ void hash(void * data,
269 struct sha1_context ctx; 269 struct sha1_context ctx;
270 270
271 sha1_starts( &ctx ); 271 sha1_starts( &ctx );
272 sha1_update( &ctx, 272 sha1_update( &ctx,
273 data, 273 data,
274 size); 274 size);
275 275
276 sha1_finish( &ctx, hc->data ); 276 sha1_finish( &ctx, hc->data );
277} 277}
278 278
279#ifdef TEST 279#ifdef TEST
@@ -285,7 +285,7 @@ void hash(void * data,
285 * those are the standard FIPS 180-1 test vectors 285 * those are the standard FIPS 180-1 test vectors
286 */ 286 */
287 287
288static char *msg[] = 288static char *msg[] =
289{ 289{
290 "abc", 290 "abc",
291 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 291 "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
diff --git a/src/plugins/psextractor.c b/src/plugins/psextractor.c
index 0c321aa..dd972ad 100644
--- a/src/plugins/psextractor.c
+++ b/src/plugins/psextractor.c
@@ -29,7 +29,7 @@ static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordType type,
29 if (keyword == NULL) 29 if (keyword == NULL)
30 return next; 30 return next;
31 result = malloc(sizeof(EXTRACTOR_KeywordList)); 31 result = malloc(sizeof(EXTRACTOR_KeywordList));
32 result->next = next; 32 result->next = next;
33 result->keyword = strdup(keyword); 33 result->keyword = strdup(keyword);
34 result->keywordType = type; 34 result->keywordType = type;
35 return result; 35 return result;
@@ -42,10 +42,10 @@ static char * readline(char * data,
42 char * res; 42 char * res;
43 43
44 while ( ( pos < size) && 44 while ( ( pos < size) &&
45 ( (data[pos] == (char)0x0d) || 45 ( (data[pos] == (char)0x0d) ||
46 (data[pos] == (char)0x0a) ) ) 46 (data[pos] == (char)0x0a) ) )
47 pos++; 47 pos++;
48 48
49 if (pos >= size) 49 if (pos >= size)
50 return NULL; /* end of file */ 50 return NULL; /* end of file */
51 end = pos; 51 end = pos;
@@ -58,7 +58,7 @@ static char * readline(char * data,
58 &data[pos], 58 &data[pos],
59 end-pos); 59 end-pos);
60 res[end-pos] = '\0'; 60 res[end-pos] = '\0';
61 61
62 return res; 62 return res;
63} 63}
64 64
@@ -79,7 +79,7 @@ static struct EXTRACTOR_Keywords * testmeta(char * line,
79 } 79 }
80 prev = addKeyword(type, 80 prev = addKeyword(type,
81 key, 81 key,
82 prev); 82 prev);
83 } 83 }
84 return prev; 84 return prev;
85} 85}
@@ -103,9 +103,9 @@ static Matches tests[] = {
103 { "%%Magnification: ", EXTRACTOR_UNKNOWN }, 103 { "%%Magnification: ", EXTRACTOR_UNKNOWN },
104 104
105 /* Also widely used but not supported since they 105 /* Also widely used but not supported since they
106 probably make no sense: 106 probably make no sense:
107 "%%BoundingBox: ", 107 "%%BoundingBox: ",
108 "%%DocumentNeededResources: ", 108 "%%DocumentNeededResources: ",
109 "%%DocumentSuppliedResources: ", 109 "%%DocumentSuppliedResources: ",
110 "%%DocumentProcSets: ", 110 "%%DocumentProcSets: ",
111 "%%DocumentData: ", */ 111 "%%DocumentData: ", */
@@ -152,7 +152,7 @@ struct EXTRACTOR_Keywords * libextractor_ps_extract(char * filename,
152 int i; 152 int i;
153 int lastLine; 153 int lastLine;
154 const char * mime; 154 const char * mime;
155 155
156 /* if the mime-type of the file is blacklisted, don't 156 /* if the mime-type of the file is blacklisted, don't
157 run the printable extactor! */ 157 run the printable extactor! */
158 mime = EXTRACTOR_extractLast(EXTRACTOR_MIMETYPE, 158 mime = EXTRACTOR_extractLast(EXTRACTOR_MIMETYPE,
@@ -165,7 +165,7 @@ struct EXTRACTOR_Keywords * libextractor_ps_extract(char * filename,
165 return prev; 165 return prev;
166 j++; 166 j++;
167 } 167 }
168 } 168 }
169 169
170 170
171 pos = 0; 171 pos = 0;
@@ -176,15 +176,15 @@ struct EXTRACTOR_Keywords * libextractor_ps_extract(char * filename,
176 if (pos != strlen(psheader)) { 176 if (pos != strlen(psheader)) {
177 return prev; /* no ps */ 177 return prev; /* no ps */
178 } 178 }
179 179
180 prev = addKeyword(EXTRACTOR_MIMETYPE, 180 prev = addKeyword(EXTRACTOR_MIMETYPE,
181 "application/postscript", 181 "application/postscript",
182 prev); 182 prev);
183 183
184 /* skip rest of first line */ 184 /* skip rest of first line */
185 while ( (pos<size) && (data[pos] != '\n') ) 185 while ( (pos<size) && (data[pos] != '\n') )
186 pos++; 186 pos++;
187 187
188 lastLine = -1; 188 lastLine = -1;
189 line = strdup(psheader); 189 line = strdup(psheader);
190 190
@@ -192,22 +192,22 @@ struct EXTRACTOR_Keywords * libextractor_ps_extract(char * filename,
192 "%%EndComments", this should allow us to not read through most of 192 "%%EndComments", this should allow us to not read through most of
193 the file for all the sane applications... For Windows-generated 193 the file for all the sane applications... For Windows-generated
194 PS files, we will bail out at the end of the file. */ 194 PS files, we will bail out at the end of the file. */
195 while (0 != strncmp("%%EndComments", 195 while (0 != strncmp("%%EndComments",
196 line, 196 line,
197 strlen("%%EndComments"))) { 197 strlen("%%EndComments"))) {
198 free(line); 198 free(line);
199 line = readline(data, size, pos); 199 line = readline(data, size, pos);
200 if (line == NULL) 200 if (line == NULL)
201 break; 201 break;
202 i=0; 202 i=0;
203 while (tests[i].prefix != NULL) { 203 while (tests[i].prefix != NULL) {
204 prev = testmeta(line, 204 prev = testmeta(line,
205 tests[i].prefix, 205 tests[i].prefix,
206 tests[i].type, 206 tests[i].type,
207 prev); 207 prev);
208 i++; 208 i++;
209 } 209 }
210 210
211 /* %%+ continues previous meta-data type... */ 211 /* %%+ continues previous meta-data type... */
212 if ( (lastLine != -1) && 212 if ( (lastLine != -1) &&
213 (0 == strncmp(line, "%%+ ", strlen("%%+ "))) ) { 213 (0 == strncmp(line, "%%+ ", strlen("%%+ "))) ) {
@@ -225,7 +225,7 @@ struct EXTRACTOR_Keywords * libextractor_ps_extract(char * filename,
225 pos += strlen(line)+1; /* skip newline, too; guarantee progress! */ 225 pos += strlen(line)+1; /* skip newline, too; guarantee progress! */
226 } 226 }
227 free(line); 227 free(line);
228 228
229 return prev; 229 return prev;
230} 230}
231 231
diff --git a/src/plugins/qtextractor.c b/src/plugins/qtextractor.c
index 9d0478d..3057359 100644
--- a/src/plugins/qtextractor.c
+++ b/src/plugins/qtextractor.c
@@ -256,7 +256,7 @@ typedef struct {
256 256
257 /* flags that indicate how a trak is supposed to be used */ 257 /* flags that indicate how a trak is supposed to be used */
258 unsigned int flags; 258 unsigned int flags;
259 259
260 /* decoder data pass information to the AAC decoder */ 260 /* decoder data pass information to the AAC decoder */
261 void *decoder_config; 261 void *decoder_config;
262 int decoder_config_len; 262 int decoder_config_len;
@@ -307,7 +307,7 @@ typedef struct {
307 unsigned int modification_time; 307 unsigned int modification_time;
308 unsigned int timescale; /* base clock frequency is Hz */ 308 unsigned int timescale; /* base clock frequency is Hz */
309 unsigned int duration; 309 unsigned int duration;
310 310
311 int64_t moov_first_offset; 311 int64_t moov_first_offset;
312 312
313 int trak_count; 313 int trak_count;
@@ -335,15 +335,15 @@ static int readBuf(qt_info * this,
335 void * buf, 335 void * buf,
336 int len) { 336 int len) {
337 int min; 337 int min;
338 338
339 min = len; 339 min = len;
340 if ( (this->inputLen < this->inputPos) || 340 if ( (this->inputLen < this->inputPos) ||
341 (this->inputPos < 0) ) 341 (this->inputPos < 0) )
342 return -1; /* invalid pos/len */ 342 return -1; /* invalid pos/len */
343 if (this->inputLen - this->inputPos < min) 343 if (this->inputLen - this->inputPos < min)
344 min = this->inputLen - this->inputPos; 344 min = this->inputLen - this->inputPos;
345 memcpy(buf, 345 memcpy(buf,
346 &this->input[this->inputPos], 346 &this->input[this->inputPos],
347 min); 347 min);
348 this->inputPos += min; 348 this->inputPos += min;
349 return min; 349 return min;
@@ -353,7 +353,7 @@ static int readBuf(qt_info * this,
353 * lazyqt special debugging functions 353 * lazyqt special debugging functions
354 **********************************************************************/ 354 **********************************************************************/
355 355
356/* define DEBUG_ATOM_LOAD as 1 to get a verbose parsing of the relevant 356/* define DEBUG_ATOM_LOAD as 1 to get a verbose parsing of the relevant
357 * atoms */ 357 * atoms */
358#define DEBUG_ATOM_LOAD 0 358#define DEBUG_ATOM_LOAD 0
359 359
@@ -375,7 +375,7 @@ static int readBuf(qt_info * this,
375 375
376/* Define DEBUG_DUMP_MOOV as 1 to dump the raw moov atom to disk. This is 376/* Define DEBUG_DUMP_MOOV as 1 to dump the raw moov atom to disk. This is
377 * particularly useful in debugging a file with a compressed moov (cmov) 377 * particularly useful in debugging a file with a compressed moov (cmov)
378 * atom. The atom will be dumped to the filename specified as 378 * atom. The atom will be dumped to the filename specified as
379 * RAW_MOOV_FILENAME. */ 379 * RAW_MOOV_FILENAME. */
380#define DEBUG_DUMP_MOOV 0 380#define DEBUG_DUMP_MOOV 0
381#define RAW_MOOV_FILENAME "moovatom.raw" 381#define RAW_MOOV_FILENAME "moovatom.raw"
@@ -511,7 +511,7 @@ static void find_moov_atom(qt_info *input, off_t *moov_offset,
511 ATOM_PREAMBLE_SIZE) 511 ATOM_PREAMBLE_SIZE)
512 break; 512 break;
513 513
514 atom_size = BE_32(&atom_preamble[0]); 514 atom_size = BE_32(&atom_preamble[0]);
515 atom_size <<= 16; /* <<= 32 causes compiler warning if we */ 515 atom_size <<= 16; /* <<= 32 causes compiler warning if we */
516 atom_size <<= 16; /* are not running on 64 bit. */ 516 atom_size <<= 16; /* are not running on 64 bit. */
517 atom_size |= BE_32(&atom_preamble[4]); 517 atom_size |= BE_32(&atom_preamble[4]);
@@ -616,7 +616,7 @@ static void parse_mvhd_atom(qt_info *info, unsigned char *mvhd_atom) {
616static int mp4_read_descr_len(unsigned char *s, ext_uint32_t *length) { 616static int mp4_read_descr_len(unsigned char *s, ext_uint32_t *length) {
617 ext_uint8_t b; 617 ext_uint8_t b;
618 ext_uint8_t numBytes = 0; 618 ext_uint8_t numBytes = 0;
619 619
620 *length = 0; 620 *length = 0;
621 621
622 do { 622 do {
@@ -691,7 +691,7 @@ static qt_error parse_trak_atom (qt_trak *trak,
691 break; 691 break;
692 } 692 }
693 } 693 }
694 694
695 debug_atom_load(" qt: parsing %s trak atom\n", 695 debug_atom_load(" qt: parsing %s trak atom\n",
696 (trak->type == MEDIA_VIDEO) ? "video" : 696 (trak->type == MEDIA_VIDEO) ? "video" :
697 (trak->type == MEDIA_AUDIO) ? "audio" : "other"); 697 (trak->type == MEDIA_AUDIO) ? "audio" : "other");
@@ -712,7 +712,7 @@ static qt_error parse_trak_atom (qt_trak *trak,
712 trak->properties.video.width = 712 trak->properties.video.width =
713 BE_16(&trak_atom[i + 0x50]); 713 BE_16(&trak_atom[i + 0x50]);
714 trak->properties.video.height = 714 trak->properties.video.height =
715 BE_16(&trak_atom[i + 0x54]); 715 BE_16(&trak_atom[i + 0x54]);
716 } 716 }
717 } 717 }
718 } else if (current_atom == ELST_ATOM) { 718 } else if (current_atom == ELST_ATOM) {
@@ -784,7 +784,7 @@ static qt_error parse_trak_atom (qt_trak *trak,
784 * fix at the end of the stsd parser */ 784 * fix at the end of the stsd parser */
785 i += hack_adjust; 785 i += hack_adjust;
786 } 786 }
787 787
788 if (trak->type == MEDIA_VIDEO) { 788 if (trak->type == MEDIA_VIDEO) {
789 789
790 /* initialize to sane values */ 790 /* initialize to sane values */
@@ -796,7 +796,7 @@ static qt_error parse_trak_atom (qt_trak *trak,
796 trak->properties.video.palette_count = 0; 796 trak->properties.video.palette_count = 0;
797 797
798 /* fetch video parameters */ 798 /* fetch video parameters */
799 if( BE_16(&trak_atom[i + 0x2C]) && 799 if( BE_16(&trak_atom[i + 0x2C]) &&
800 BE_16(&trak_atom[i + 0x2E]) ) { 800 BE_16(&trak_atom[i + 0x2E]) ) {
801 trak->properties.video.width = 801 trak->properties.video.width =
802 BE_16(&trak_atom[i + 0x2C]); 802 BE_16(&trak_atom[i + 0x2C]);
@@ -824,9 +824,9 @@ static qt_error parse_trak_atom (qt_trak *trak,
824 824
825 /* compute the greyscale palette */ 825 /* compute the greyscale palette */
826 color_index = 255; 826 color_index = 255;
827 color_dec = 256 / 827 color_dec = 256 /
828 (trak->properties.video.palette_count - 1); 828 (trak->properties.video.palette_count - 1);
829 for (j = 0; 829 for (j = 0;
830 j < trak->properties.video.palette_count; 830 j < trak->properties.video.palette_count;
831 j++) { 831 j++) {
832 832
@@ -890,12 +890,12 @@ static qt_error parse_trak_atom (qt_trak *trak,
890 trak->properties.audio.bits / 8; 890 trak->properties.audio.bits / 8;
891 trak->properties.audio.samples_per_frame = 891 trak->properties.audio.samples_per_frame =
892 trak->properties.audio.channels; 892 trak->properties.audio.channels;
893 trak->properties.audio.bytes_per_frame = 893 trak->properties.audio.bytes_per_frame =
894 trak->properties.audio.bytes_per_sample * 894 trak->properties.audio.bytes_per_sample *
895 trak->properties.audio.samples_per_frame; 895 trak->properties.audio.samples_per_frame;
896 trak->properties.audio.samples_per_packet = 896 trak->properties.audio.samples_per_packet =
897 trak->properties.audio.samples_per_frame; 897 trak->properties.audio.samples_per_frame;
898 trak->properties.audio.bytes_per_packet = 898 trak->properties.audio.bytes_per_packet =
899 trak->properties.audio.bytes_per_sample; 899 trak->properties.audio.bytes_per_sample;
900 900
901 /* special case time: some ima4-encoded files don't have the 901 /* special case time: some ima4-encoded files don't have the
@@ -903,7 +903,7 @@ static qt_error parse_trak_atom (qt_trak *trak,
903 if (BE_32(&trak_atom[i + 0x10]) == IMA4_FOURCC) { 903 if (BE_32(&trak_atom[i + 0x10]) == IMA4_FOURCC) {
904 trak->properties.audio.samples_per_packet = 64; 904 trak->properties.audio.samples_per_packet = 64;
905 trak->properties.audio.bytes_per_packet = 34; 905 trak->properties.audio.bytes_per_packet = 34;
906 trak->properties.audio.bytes_per_frame = 34 * 906 trak->properties.audio.bytes_per_frame = 34 *
907 trak->properties.audio.channels; 907 trak->properties.audio.channels;
908 trak->properties.audio.bytes_per_sample = 2; 908 trak->properties.audio.bytes_per_sample = 2;
909 trak->properties.audio.samples_per_frame = 64 * 909 trak->properties.audio.samples_per_frame = 64 *
@@ -917,19 +917,19 @@ static qt_error parse_trak_atom (qt_trak *trak,
917 if (BE_32(&trak_atom[i + 0x0C]) > 0x24) { 917 if (BE_32(&trak_atom[i + 0x0C]) > 0x24) {
918 918
919 if (BE_32(&trak_atom[i + 0x30])) 919 if (BE_32(&trak_atom[i + 0x30]))
920 trak->properties.audio.samples_per_packet = 920 trak->properties.audio.samples_per_packet =
921 BE_32(&trak_atom[i + 0x30]); 921 BE_32(&trak_atom[i + 0x30]);
922 if (BE_32(&trak_atom[i + 0x34])) 922 if (BE_32(&trak_atom[i + 0x34]))
923 trak->properties.audio.bytes_per_packet = 923 trak->properties.audio.bytes_per_packet =
924 BE_32(&trak_atom[i + 0x34]); 924 BE_32(&trak_atom[i + 0x34]);
925 if (BE_32(&trak_atom[i + 0x38])) 925 if (BE_32(&trak_atom[i + 0x38]))
926 trak->properties.audio.bytes_per_frame = 926 trak->properties.audio.bytes_per_frame =
927 BE_32(&trak_atom[i + 0x38]); 927 BE_32(&trak_atom[i + 0x38]);
928 if (BE_32(&trak_atom[i + 0x3C])) 928 if (BE_32(&trak_atom[i + 0x3C]))
929 trak->properties.audio.bytes_per_sample = 929 trak->properties.audio.bytes_per_sample =
930 BE_32(&trak_atom[i + 0x3C]); 930 BE_32(&trak_atom[i + 0x3C]);
931 trak->properties.audio.samples_per_frame = 931 trak->properties.audio.samples_per_frame =
932 (trak->properties.audio.bytes_per_frame / 932 (trak->properties.audio.bytes_per_frame /
933 trak->properties.audio.bytes_per_packet) * 933 trak->properties.audio.bytes_per_packet) *
934 trak->properties.audio.samples_per_packet; 934 trak->properties.audio.samples_per_packet;
935 935
@@ -946,7 +946,7 @@ static qt_error parse_trak_atom (qt_trak *trak,
946 trak->properties.audio.vbr = 1; 946 trak->properties.audio.vbr = 1;
947 947
948 /* check for a MS-style WAVE format header */ 948 /* check for a MS-style WAVE format header */
949 if ((current_atom_size >= 0x48) && 949 if ((current_atom_size >= 0x48) &&
950 (BE_32(&trak_atom[i + 0x44]) == WAVE_ATOM)) { 950 (BE_32(&trak_atom[i + 0x44]) == WAVE_ATOM)) {
951 trak->properties.audio.wave_present = 1; 951 trak->properties.audio.wave_present = 1;
952 } else { 952 } else {
@@ -983,12 +983,12 @@ static qt_error parse_trak_atom (qt_trak *trak,
983 } else if (current_atom == ESDS_ATOM) { 983 } else if (current_atom == ESDS_ATOM) {
984 984
985 ext_uint32_t len; 985 ext_uint32_t len;
986 986
987 debug_atom_load(" qt/mpeg-4 esds atom\n"); 987 debug_atom_load(" qt/mpeg-4 esds atom\n");
988 988
989 if ((trak->type == MEDIA_VIDEO) || 989 if ((trak->type == MEDIA_VIDEO) ||
990 (trak->type == MEDIA_AUDIO)) { 990 (trak->type == MEDIA_AUDIO)) {
991 991
992 j = i + 8; 992 j = i + 8;
993 if( trak_atom[j++] == 0x03 ) { 993 if( trak_atom[j++] == 0x03 ) {
994 j += mp4_read_descr_len( &trak_atom[j], &len ); 994 j += mp4_read_descr_len( &trak_atom[j], &len );
@@ -1290,9 +1290,9 @@ static qt_error parse_reference_atom (reference_t *ref,
1290/* This is a little support function used to process the edit list when 1290/* This is a little support function used to process the edit list when
1291 * building a frame table. */ 1291 * building a frame table. */
1292#define MAX_DURATION 0x7FFFFFFF 1292#define MAX_DURATION 0x7FFFFFFF
1293static void get_next_edit_list_entry(qt_trak *trak, 1293static void get_next_edit_list_entry(qt_trak *trak,
1294 int *edit_list_index, 1294 int *edit_list_index,
1295 unsigned int *edit_list_media_time, 1295 unsigned int *edit_list_media_time,
1296 int64_t *edit_list_duration, 1296 int64_t *edit_list_duration,
1297 unsigned int global_timescale) { 1297 unsigned int global_timescale) {
1298 1298
@@ -1309,9 +1309,9 @@ static void get_next_edit_list_entry(qt_trak *trak,
1309 /* otherwise, find an edit list entries whose media time != -1 */ 1309 /* otherwise, find an edit list entries whose media time != -1 */
1310 if (trak->edit_list_table[*edit_list_index].media_time != -1) { 1310 if (trak->edit_list_table[*edit_list_index].media_time != -1) {
1311 1311
1312 *edit_list_media_time = 1312 *edit_list_media_time =
1313 trak->edit_list_table[*edit_list_index].media_time; 1313 trak->edit_list_table[*edit_list_index].media_time;
1314 *edit_list_duration = 1314 *edit_list_duration =
1315 trak->edit_list_table[*edit_list_index].track_duration; 1315 trak->edit_list_table[*edit_list_index].track_duration;
1316 1316
1317 /* duration is in global timescale units; convert to trak timescale */ 1317 /* duration is in global timescale units; convert to trak timescale */
@@ -1325,8 +1325,8 @@ static void get_next_edit_list_entry(qt_trak *trak,
1325 *edit_list_index = *edit_list_index + 1; 1325 *edit_list_index = *edit_list_index + 1;
1326 } 1326 }
1327 1327
1328 /* on the way out, check if this is the last edit list entry; if so, 1328 /* on the way out, check if this is the last edit list entry; if so,
1329 * don't let the duration expire (so set it to an absurdly large value) 1329 * don't let the duration expire (so set it to an absurdly large value)
1330 */ 1330 */
1331 if (*edit_list_index == trak->edit_list_count) 1331 if (*edit_list_index == trak->edit_list_count)
1332 *edit_list_duration = MAX_DURATION; 1332 *edit_list_duration = MAX_DURATION;
@@ -1353,7 +1353,7 @@ static qt_error build_frame_table(qt_trak *trak,
1353 1353
1354 /* AUDIO and OTHER frame types follow the same rules; VIDEO and vbr audio 1354 /* AUDIO and OTHER frame types follow the same rules; VIDEO and vbr audio
1355 * frame types follow a different set */ 1355 * frame types follow a different set */
1356 if ((trak->type == MEDIA_VIDEO) || 1356 if ((trak->type == MEDIA_VIDEO) ||
1357 (trak->properties.audio.vbr)) { 1357 (trak->properties.audio.vbr)) {
1358 1358
1359 /* in this case, the total number of frames is equal to the number of 1359 /* in this case, the total number of frames is equal to the number of
@@ -1448,11 +1448,11 @@ static qt_error build_frame_table(qt_trak *trak,
1448 1448
1449 debug_edit_list(" %d: (before) pts = %lld...", i, trak->frames[i].pts); 1449 debug_edit_list(" %d: (before) pts = %lld...", i, trak->frames[i].pts);
1450 1450
1451 if (trak->frames[i].pts < edit_list_media_time) 1451 if (trak->frames[i].pts < edit_list_media_time)
1452 trak->frames[i].pts = edit_list_pts_counter; 1452 trak->frames[i].pts = edit_list_pts_counter;
1453 else { 1453 else {
1454 if (i < trak->frame_count - 1) 1454 if (i < trak->frame_count - 1)
1455 frame_duration = 1455 frame_duration =
1456 (trak->frames[i + 1].pts - trak->frames[i].pts); 1456 (trak->frames[i + 1].pts - trak->frames[i].pts);
1457 1457
1458 debug_edit_list("duration = %lld...", frame_duration); 1458 debug_edit_list("duration = %lld...", frame_duration);
@@ -1521,7 +1521,7 @@ static qt_error build_frame_table(qt_trak *trak,
1521 1521
1522 /* compute the actual chunk size */ 1522 /* compute the actual chunk size */
1523 trak->frames[j].size = 1523 trak->frames[j].size =
1524 (trak->frames[j].size * 1524 (trak->frames[j].size *
1525 trak->properties.audio.channels) / 1525 trak->properties.audio.channels) /
1526 trak->properties.audio.samples_per_frame * 1526 trak->properties.audio.samples_per_frame *
1527 trak->properties.audio.bytes_per_frame; 1527 trak->properties.audio.bytes_per_frame;
@@ -1574,7 +1574,7 @@ static void parse_moov_atom(qt_info *info, unsigned char *moov_atom) {
1574 1574
1575 /* create a new trak structure */ 1575 /* create a new trak structure */
1576 info->trak_count++; 1576 info->trak_count++;
1577 info->traks = (qt_trak *)realloc(info->traks, 1577 info->traks = (qt_trak *)realloc(info->traks,
1578 info->trak_count * sizeof(qt_trak)); 1578 info->trak_count * sizeof(qt_trak));
1579 1579
1580 parse_trak_atom (&info->traks[info->trak_count - 1], &moov_atom[i - 4]); 1580 parse_trak_atom (&info->traks[info->trak_count - 1], &moov_atom[i - 4]);
@@ -1668,10 +1668,10 @@ static void parse_moov_atom(qt_info *info, unsigned char *moov_atom) {
1668 /* iterate through 1..n-1 reference entries and decide on the right one */ 1668 /* iterate through 1..n-1 reference entries and decide on the right one */
1669 for (i = 1; i < info->reference_count; i++) { 1669 for (i = 1; i < info->reference_count; i++) {
1670 1670
1671 if (info->references[i].qtim_version > 1671 if (info->references[i].qtim_version >
1672 info->references[info->chosen_reference].qtim_version) 1672 info->references[info->chosen_reference].qtim_version)
1673 info->chosen_reference = i; 1673 info->chosen_reference = i;
1674 else if ((info->references[i].data_rate > 1674 else if ((info->references[i].data_rate >
1675 info->references[info->chosen_reference].data_rate)) 1675 info->references[info->chosen_reference].data_rate))
1676 info->chosen_reference = i; 1676 info->chosen_reference = i;
1677 } 1677 }
@@ -1711,7 +1711,7 @@ static qt_error open_qt_file(qt_info *info) {
1711 1711
1712 /* seek to the start of moov atom */ 1712 /* seek to the start of moov atom */
1713 info->inputPos = info->moov_first_offset; 1713 info->inputPos = info->moov_first_offset;
1714 if (readBuf(info, moov_atom, moov_atom_size) != 1714 if (readBuf(info, moov_atom, moov_atom_size) !=
1715 moov_atom_size) { 1715 moov_atom_size) {
1716 free(moov_atom); 1716 free(moov_atom);
1717 info->last_error = QT_FILE_READ_ERROR; 1717 info->last_error = QT_FILE_READ_ERROR;
@@ -1896,29 +1896,29 @@ void parse_quicktime(FILE *file, Data *data)
1896 fseek(file, blockStart + blockLen, SEEK_SET); 1896 fseek(file, blockStart + blockLen, SEEK_SET);
1897 continue; 1897 continue;
1898 } 1898 }
1899 1899
1900 subBlockStart = ftell(file); 1900 subBlockStart = ftell(file);
1901 subBlockLen = fread_be(file, 4); /* tkhd length */ 1901 subBlockLen = fread_be(file, 4); /* tkhd length */
1902 fread(fourcc, sizeof(char), 4, file); 1902 fread(fourcc, sizeof(char), 4, file);
1903 if(memcmp(fourcc, "tkhd", 4)!=0) 1903 if(memcmp(fourcc, "tkhd", 4)!=0)
1904 return; 1904 return;
1905 1905
1906 /* Now in the track header */ 1906 /* Now in the track header */
1907 1907
1908 /* 84: width (2 bytes) */ 1908 /* 84: width (2 bytes) */
1909 fseek(file, subBlockStart + 84, SEEK_SET); 1909 fseek(file, subBlockStart + 84, SEEK_SET);
1910 width = fread_be(file, 2); 1910 width = fread_be(file, 2);
1911 1911
1912 /* 88: height (2 bytes) */ 1912 /* 88: height (2 bytes) */
1913 fseek(file, subBlockStart + 88, SEEK_SET); 1913 fseek(file, subBlockStart + 88, SEEK_SET);
1914 height = fread_be(file, 2); 1914 height = fread_be(file, 2);
1915 1915
1916 /* Note on above: Apple's docs say that width/height are 4-byte integers, 1916 /* Note on above: Apple's docs say that width/height are 4-byte integers,
1917 * but all files I've seen have the data stored in the high-order two 1917 * but all files I've seen have the data stored in the high-order two
1918 * bytes, with the low-order two being 0x0000. Interpreting it the 1918 * bytes, with the low-order two being 0x0000. Interpreting it the
1919 * "official" way would make width/height be thousands of pixels each. 1919 * "official" way would make width/height be thousands of pixels each.
1920 */ 1920 */
1921 1921
1922 /* Skip rest of tkhd */ 1922 /* Skip rest of tkhd */
1923 fseek(file, subBlockStart + subBlockLen, SEEK_SET); 1923 fseek(file, subBlockStart + subBlockLen, SEEK_SET);
1924 1924
@@ -1987,7 +1987,7 @@ static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordType type,
1987 if (keyword == NULL) 1987 if (keyword == NULL)
1988 return next; 1988 return next;
1989 result = malloc(sizeof(EXTRACTOR_KeywordList)); 1989 result = malloc(sizeof(EXTRACTOR_KeywordList));
1990 result->next = next; 1990 result->next = next;
1991 result->keyword = strdup(keyword); 1991 result->keyword = strdup(keyword);
1992 result->keywordType = type; 1992 result->keywordType = type;
1993 return result; 1993 return result;
@@ -1996,7 +1996,7 @@ static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordType type,
1996/* mimetypes: 1996/* mimetypes:
1997 video/quicktime: mov,qt: Quicktime animation; 1997 video/quicktime: mov,qt: Quicktime animation;
1998 video/x-quicktime: mov,qt: Quicktime animation; 1998 video/x-quicktime: mov,qt: Quicktime animation;
1999 application/x-quicktimeplayer: qtl: Quicktime list; 1999 application/x-quicktimeplayer: qtl: Quicktime list;
2000 */ 2000 */
2001struct EXTRACTOR_Keywords * libextractor_qt_extract(char * filename, 2001struct EXTRACTOR_Keywords * libextractor_qt_extract(char * filename,
2002 char * data, 2002 char * data,
diff --git a/src/plugins/realextractor.c b/src/plugins/realextractor.c
index dfae928..4bf5514 100644
--- a/src/plugins/realextractor.c
+++ b/src/plugins/realextractor.c
@@ -62,7 +62,7 @@ typedef struct {
62 UINT8[copyright_len] copyright; 62 UINT8[copyright_len] copyright;
63 UINT16 comment_len; 63 UINT16 comment_len;
64 UINT8[comment_len] comment; 64 UINT8[comment_len] comment;
65 */ 65 */
66} Content_Description; 66} Content_Description;
67/* author, copyright and comment are supposed to be ASCII */ 67/* author, copyright and comment are supposed to be ASCII */
68 68
@@ -72,7 +72,7 @@ typedef struct {
72 72
73#define RAFF4_HEADER 0x2E7261FD 73#define RAFF4_HEADER 0x2E7261FD
74 74
75static struct EXTRACTOR_Keywords * 75static struct EXTRACTOR_Keywords *
76addKeyword(EXTRACTOR_KeywordType type, 76addKeyword(EXTRACTOR_KeywordType type,
77 char * keyword, 77 char * keyword,
78 struct EXTRACTOR_Keywords * next) { 78 struct EXTRACTOR_Keywords * next) {
@@ -81,7 +81,7 @@ addKeyword(EXTRACTOR_KeywordType type,
81 if (keyword == NULL) 81 if (keyword == NULL)
82 return next; 82 return next;
83 result = malloc(sizeof(EXTRACTOR_KeywordList)); 83 result = malloc(sizeof(EXTRACTOR_KeywordList));
84 result->next = next; 84 result->next = next;
85 result->keyword = keyword; 85 result->keyword = keyword;
86 result->keywordType = type; 86 result->keywordType = type;
87 return result; 87 return result;
@@ -90,38 +90,38 @@ addKeyword(EXTRACTOR_KeywordType type,
90static struct EXTRACTOR_Keywords * 90static struct EXTRACTOR_Keywords *
91processMediaProperties(const Media_Properties * prop, 91processMediaProperties(const Media_Properties * prop,
92 struct EXTRACTOR_Keywords * prev) { 92 struct EXTRACTOR_Keywords * prev) {
93 93
94 UINT8 mime_type_size; 94 UINT8 mime_type_size;
95 UINT32 prop_size; 95 UINT32 prop_size;
96 char * data; 96 char * data;
97 97
98 prop_size = ntohl(prop->size); 98 prop_size = ntohl(prop->size);
99 if (prop_size <= sizeof(Media_Properties)) 99 if (prop_size <= sizeof(Media_Properties))
100 return prev; 100 return prev;
101 if (0 != prop->object_version) 101 if (0 != prop->object_version)
102 return prev; 102 return prev;
103 if (prop_size <= prop->stream_name_size + sizeof(UINT8) 103 if (prop_size <= prop->stream_name_size + sizeof(UINT8)
104 + sizeof(Media_Properties)) 104 + sizeof(Media_Properties))
105 return prev; 105 return prev;
106 106
107 mime_type_size = prop->data[prop->stream_name_size]; 107 mime_type_size = prop->data[prop->stream_name_size];
108 if (prop_size <= prop->stream_name_size + sizeof(UINT8) + 108 if (prop_size <= prop->stream_name_size + sizeof(UINT8) +
109 + mime_type_size + sizeof(Media_Properties)) 109 + mime_type_size + sizeof(Media_Properties))
110 return prev; 110 return prev;
111 111
112 data = malloc(mime_type_size+1); 112 data = malloc(mime_type_size+1);
113 memcpy(data,&prop->data[prop->stream_name_size+1],mime_type_size); 113 memcpy(data,&prop->data[prop->stream_name_size+1],mime_type_size);
114 data[mime_type_size]='\0'; 114 data[mime_type_size]='\0';
115 115
116 return addKeyword(EXTRACTOR_MIMETYPE, 116 return addKeyword(EXTRACTOR_MIMETYPE,
117 data, 117 data,
118 prev); 118 prev);
119} 119}
120 120
121static struct EXTRACTOR_Keywords * 121static struct EXTRACTOR_Keywords *
122processContentDescription(const Content_Description * prop, 122processContentDescription(const Content_Description * prop,
123 struct EXTRACTOR_Keywords * prev) { 123 struct EXTRACTOR_Keywords * prev) {
124 124
125 125
126 UINT16 author_len; 126 UINT16 author_len;
127 UINT16 copyright_len; 127 UINT16 copyright_len;
@@ -135,7 +135,7 @@ processContentDescription(const Content_Description * prop,
135 135
136 prop_size = ntohl(prop->size); 136 prop_size = ntohl(prop->size);
137 if (prop_size <= sizeof(Content_Description)) 137 if (prop_size <= sizeof(Content_Description))
138 return prev; 138 return prev;
139 if (0 != prop->object_version) 139 if (0 != prop->object_version)
140 return prev; 140 return prev;
141 title_len = ntohs(prop->title_len); 141 title_len = ntohs(prop->title_len);
@@ -145,33 +145,33 @@ processContentDescription(const Content_Description * prop,
145 145
146 146
147 author_len = ntohs( *(UINT16*)&prop->data[title_len]); 147 author_len = ntohs( *(UINT16*)&prop->data[title_len]);
148 148
149 if (prop_size <= title_len + sizeof(UINT16) 149 if (prop_size <= title_len + sizeof(UINT16)
150 + author_len + sizeof(Content_Description)) 150 + author_len + sizeof(Content_Description))
151 return prev; 151 return prev;
152 152
153 copyright_len =ntohs( *(UINT16*)&prop->data[title_len+ 153 copyright_len =ntohs( *(UINT16*)&prop->data[title_len+
154 author_len+ 154 author_len+
155 sizeof(UINT16)]); 155 sizeof(UINT16)]);
156 156
157 if (prop_size <= title_len + 2*sizeof(UINT16) 157 if (prop_size <= title_len + 2*sizeof(UINT16)
158 + author_len + copyright_len + sizeof(Content_Description)) 158 + author_len + copyright_len + sizeof(Content_Description))
159 return prev; 159 return prev;
160 160
161 comment_len = ntohs( *(UINT16*)&prop->data[title_len+ 161 comment_len = ntohs( *(UINT16*)&prop->data[title_len+
162 author_len+ 162 author_len+
163 copyright_len+ 163 copyright_len+
164 2*sizeof(UINT16)]); 164 2*sizeof(UINT16)]);
165 165
166 if (prop_size < title_len + 3*sizeof(UINT16) 166 if (prop_size < title_len + 3*sizeof(UINT16)
167 + author_len + copyright_len + comment_len 167 + author_len + copyright_len + comment_len
168 + sizeof(Content_Description)) 168 + sizeof(Content_Description))
169 return prev; 169 return prev;
170 170
171 title = malloc(title_len+1); 171 title = malloc(title_len+1);
172 memcpy(title,&prop->data[0],title_len); 172 memcpy(title,&prop->data[0],title_len);
173 title[title_len]='\0'; 173 title[title_len]='\0';
174 174
175 prev = addKeyword(EXTRACTOR_TITLE, 175 prev = addKeyword(EXTRACTOR_TITLE,
176 title, 176 title,
177 prev); 177 prev);
@@ -209,34 +209,34 @@ processContentDescription(const Content_Description * prop,
209 return prev; 209 return prev;
210} 210}
211 211
212typedef struct RAFF4_header { 212typedef struct RAFF4_header {
213 unsigned short version; 213 unsigned short version;
214 unsigned short revision; 214 unsigned short revision;
215 unsigned short header_length; 215 unsigned short header_length;
216 unsigned short compression_type; 216 unsigned short compression_type;
217 unsigned int granularity; 217 unsigned int granularity;
218 unsigned int total_bytes; 218 unsigned int total_bytes;
219 unsigned int bytes_per_minute; 219 unsigned int bytes_per_minute;
220 unsigned int bytes_per_minute2; 220 unsigned int bytes_per_minute2;
221 unsigned short interleave_factor; 221 unsigned short interleave_factor;
222 unsigned short interleave_block_size; 222 unsigned short interleave_block_size;
223 unsigned int user_data; 223 unsigned int user_data;
224 float sample_rate; 224 float sample_rate;
225 unsigned short sample_size; 225 unsigned short sample_size;
226 unsigned short channels; 226 unsigned short channels;
227 unsigned char interleave_code[5]; 227 unsigned char interleave_code[5];
228 unsigned char compression_code[5]; 228 unsigned char compression_code[5];
229 unsigned char is_interleaved; 229 unsigned char is_interleaved;
230 unsigned char copy_byte; 230 unsigned char copy_byte;
231 unsigned char stream_type; 231 unsigned char stream_type;
232 /* 232 /*
233 unsigned char tlen; 233 unsigned char tlen;
234 unsigned char title[tlen]; 234 unsigned char title[tlen];
235 unsigned char alen; 235 unsigned char alen;
236 unsigned char author[alen]; 236 unsigned char author[alen];
237 unsigned char clen; 237 unsigned char clen;
238 unsigned char copyright[clen]; 238 unsigned char copyright[clen];
239 unsigned char aplen; 239 unsigned char aplen;
240 unsigned char app[aplen]; */ 240 unsigned char app[aplen]; */
241} RAFF4_header; 241} RAFF4_header;
242 242
@@ -259,20 +259,20 @@ struct EXTRACTOR_Keywords * libextractor_real_extract(unsigned char * filename,
259 const unsigned char * pos; 259 const unsigned char * pos;
260 const unsigned char * end; 260 const unsigned char * end;
261 struct EXTRACTOR_Keywords * result; 261 struct EXTRACTOR_Keywords * result;
262 unsigned int length; 262 unsigned int length;
263 const RAFF4_header * hdr; 263 const RAFF4_header * hdr;
264 unsigned char tlen; 264 unsigned char tlen;
265 unsigned char alen; 265 unsigned char alen;
266 unsigned char clen; 266 unsigned char clen;
267 unsigned char aplen; 267 unsigned char aplen;
268 268
269 if (size <= 2*sizeof(int)) 269 if (size <= 2*sizeof(int))
270 return prev; 270 return prev;
271 271
272 if (RAFF4_HEADER == ntohl(*(int*)data)) { 272 if (RAFF4_HEADER == ntohl(*(int*)data)) {
273 /* HELIX */ 273 /* HELIX */
274 if (size <= RAFF4_HDR_SIZE + 16 + 4) 274 if (size <= RAFF4_HDR_SIZE + 16 + 4)
275 return prev; 275 return prev;
276 prev = addKeyword(EXTRACTOR_MIMETYPE, 276 prev = addKeyword(EXTRACTOR_MIMETYPE,
277 strdup("audio/vnd.rn-realaudio"), 277 strdup("audio/vnd.rn-realaudio"),
278 prev); 278 prev);
@@ -287,7 +287,7 @@ struct EXTRACTOR_Keywords * libextractor_real_extract(unsigned char * filename,
287 return prev; 287 return prev;
288 clen = data[18 + tlen + alen + RAFF4_HDR_SIZE]; 288 clen = data[18 + tlen + alen + RAFF4_HDR_SIZE];
289 if (tlen + alen + clen + RAFF4_HDR_SIZE + 20 > size) 289 if (tlen + alen + clen + RAFF4_HDR_SIZE + 20 > size)
290 return prev; 290 return prev;
291 aplen = data[19 + tlen + clen + alen + RAFF4_HDR_SIZE]; 291 aplen = data[19 + tlen + clen + alen + RAFF4_HDR_SIZE];
292 if (tlen + alen + clen + aplen + RAFF4_HDR_SIZE + 20 > size) 292 if (tlen + alen + clen + aplen + RAFF4_HDR_SIZE + 20 > size)
293 return prev; 293 return prev;
@@ -313,7 +313,7 @@ struct EXTRACTOR_Keywords * libextractor_real_extract(unsigned char * filename,
313 aplen), 313 aplen),
314 prev); 314 prev);
315 return prev; 315 return prev;
316 316
317 } 317 }
318 if (REAL_HEADER == ntohl(*(int*)data)) { 318 if (REAL_HEADER == ntohl(*(int*)data)) {
319 /* old real */ 319 /* old real */
@@ -347,8 +347,8 @@ struct EXTRACTOR_Keywords * libextractor_real_extract(unsigned char * filename,
347 break; 347 break;
348 } 348 }
349 } 349 }
350 return result; 350 return result;
351 } 351 }
352 return prev; 352 return prev;
353} 353}
354 354
diff --git a/src/plugins/riffextractor.c b/src/plugins/riffextractor.c
index 127acb0..5e6fb5b 100644
--- a/src/plugins/riffextractor.c
+++ b/src/plugins/riffextractor.c
@@ -17,7 +17,7 @@
17 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19 19
20 This code was based on AVInfo 1.0 alpha 11 20 This code was based on AVInfo 1.0 alpha 11
21 (c) George Shuklin, gs]AT[shounen.ru, 2002-2004 21 (c) George Shuklin, gs]AT[shounen.ru, 2002-2004
22 http://shounen.ru/soft/avinfo/ 22 http://shounen.ru/soft/avinfo/
23 23
@@ -35,7 +35,7 @@ static void addKeyword(struct EXTRACTOR_Keywords ** list,
35 EXTRACTOR_KeywordType type) { 35 EXTRACTOR_KeywordType type) {
36 EXTRACTOR_KeywordList * next; 36 EXTRACTOR_KeywordList * next;
37 next = malloc(sizeof(EXTRACTOR_KeywordList)); 37 next = malloc(sizeof(EXTRACTOR_KeywordList));
38 next->next = *list; 38 next->next = *list;
39 next->keyword = keyword; 39 next->keyword = keyword;
40 next->keywordType = type; 40 next->keywordType = type;
41 *list = next; 41 *list = next;
@@ -62,7 +62,7 @@ static struct EXTRACTOR_Keywords * riffparse_INFO(char * buffer,
62 word[c-8] = '\0'; 62 word[c-8] = '\0';
63 addKeyword(&prev, 63 addKeyword(&prev,
64 strdup(buffer+c), 64 strdup(buffer+c),
65 EXTRACTOR_UNKNOWN); /* eh, what exactly is it */ 65 EXTRACTOR_UNKNOWN); /* eh, what exactly is it */
66 } 66 }
67 return prev; 67 return prev;
68} 68}
@@ -71,12 +71,12 @@ static struct EXTRACTOR_Keywords * riffparse_INFO(char * buffer,
71 71
72/** 72/**
73 * Read the specified number of bytes as a little-endian (least 73 * Read the specified number of bytes as a little-endian (least
74 * significant byte first) integer. 74 * significant byte first) integer.
75 */ 75 */
76static unsigned int fread_le(char * data) { 76static unsigned int fread_le(char * data) {
77 int x; 77 int x;
78 unsigned int result = 0; 78 unsigned int result = 0;
79 79
80 for(x=0;x<4; x++) 80 for(x=0;x<4; x++)
81 result |= ((unsigned char)data[x]) << (x*8); 81 result |= ((unsigned char)data[x]) << (x*8);
82 return result; 82 return result;
@@ -103,17 +103,17 @@ struct EXTRACTOR_Keywords * libextractor_riff_extract(char * filename,
103 unsigned int height; 103 unsigned int height;
104 char codec[5]; 104 char codec[5];
105 char * format; 105 char * format;
106 106
107 if (xsize < 32) 107 if (xsize < 32)
108 return prev; 108 return prev;
109 109
110 if ( (memcmp(&xdata[0], 110 if ( (memcmp(&xdata[0],
111 "RIFF", 4) !=0) || 111 "RIFF", 4) !=0) ||
112 (memcmp(&xdata[8], 112 (memcmp(&xdata[8],
113 "AVI ", 113 "AVI ",
114 4) !=0) ) 114 4) !=0) )
115 return prev; 115 return prev;
116 116
117 if (memcmp(&xdata[12], 117 if (memcmp(&xdata[12],
118 "LIST", 118 "LIST",
119 4) != 0) 119 4) != 0)
@@ -132,11 +132,11 @@ struct EXTRACTOR_Keywords * libextractor_riff_extract(char * filename,
132 * 1000 / fps); 132 * 1000 / fps);
133 width = fread_le(&xdata[64]); 133 width = fread_le(&xdata[64]);
134 height = fread_le(&xdata[68]); 134 height = fread_le(&xdata[68]);
135 135
136 136
137 /* pos: begin of video stream header */ 137 /* pos: begin of video stream header */
138 pos = blockLen + 32; 138 pos = blockLen + 32;
139 139
140 if ( (pos < blockLen) || 140 if ( (pos < blockLen) ||
141 (pos + 32 > xsize) || 141 (pos + 32 > xsize) ||
142 (pos > xsize) ) 142 (pos > xsize) )
@@ -160,8 +160,8 @@ struct EXTRACTOR_Keywords * libextractor_riff_extract(char * filename,
160 &xdata[pos+24], 160 &xdata[pos+24],
161 4); 161 4);
162 codec[4] = '\0'; 162 codec[4] = '\0';
163 163
164 format = malloc(256); 164 format = malloc(256);
165 snprintf(format, 165 snprintf(format,
166 256, 166 256,
167 _("codec: %s, %u fps, %u ms"), 167 _("codec: %s, %u fps, %u ms"),
@@ -171,7 +171,7 @@ struct EXTRACTOR_Keywords * libextractor_riff_extract(char * filename,
171 addKeyword(&prev, 171 addKeyword(&prev,
172 format, 172 format,
173 EXTRACTOR_FORMAT); 173 EXTRACTOR_FORMAT);
174 format = malloc(256); 174 format = malloc(256);
175 snprintf(format, 175 snprintf(format,
176 256, 176 256,
177 "%ux%u", 177 "%ux%u",
diff --git a/src/plugins/rpm/rpmextractor.c b/src/plugins/rpm/rpmextractor.c
index 4f578d0..139dbcd 100644
--- a/src/plugins/rpm/rpmextractor.c
+++ b/src/plugins/rpm/rpmextractor.c
@@ -48,9 +48,9 @@ static int timedRead(FD_t f,
48 48
49 if (f->len - f->pos >= n) 49 if (f->len - f->pos >= n)
50 min = n; 50 min = n;
51 else 51 else
52 min = f->len - f->pos; 52 min = f->len - f->pos;
53 memcpy(dst, 53 memcpy(dst,
54 &f->data[f->pos], 54 &f->data[f->pos],
55 min); 55 min);
56 f->pos += min; 56 f->pos += min;
@@ -405,7 +405,7 @@ struct rpmlead {
405 * Alignment needs (and sizeof scalars types) for internal rpm data types. 405 * Alignment needs (and sizeof scalars types) for internal rpm data types.
406 */ 406 */
407/*@observer@*/ /*@unchecked@*/ 407/*@observer@*/ /*@unchecked@*/
408static int typeSizes[] = { 408static int typeSizes[] = {
409 0, /*!< RPM_NULL_TYPE */ 409 0, /*!< RPM_NULL_TYPE */
410 1, /*!< RPM_CHAR_TYPE */ 410 1, /*!< RPM_CHAR_TYPE */
411 1, /*!< RPM_INT8_TYPE */ 411 1, /*!< RPM_INT8_TYPE */
@@ -655,7 +655,7 @@ int (*HDRhdrwrite) (FD_t fd, /*@null@*/ Header h, enum hMagic magicp)
655 */ 655 */
656typedef 656typedef
657int (*HDRisentry) (/*@null@*/Header h, int_32 tag) 657int (*HDRisentry) (/*@null@*/Header h, int_32 tag)
658 /*@*/; 658 /*@*/;
659 659
660/** \ingroup header 660/** \ingroup header
661 * Free data allocated when retrieved from header. 661 * Free data allocated when retrieved from header.
@@ -1327,7 +1327,7 @@ indexEntry findEntry(/*@null@*/ Header h, int_32 tag, int_32 type)
1327 1327
1328 key.info.tag = tag; 1328 key.info.tag = tag;
1329 1329
1330 entry2 = entry = 1330 entry2 = entry =
1331 bsearch(&key, h->index, h->indexUsed, sizeof(*h->index), indexCmp); 1331 bsearch(&key, h->index, h->indexUsed, sizeof(*h->index), indexCmp);
1332 if (entry == NULL) 1332 if (entry == NULL)
1333 return NULL; 1333 return NULL;
@@ -1377,7 +1377,7 @@ static int copyEntry(const indexEntry entry,
1377{ 1377{
1378 int_32 count = entry->info.count; 1378 int_32 count = entry->info.count;
1379 int rc = 1; /* XXX 1 on success. */ 1379 int rc = 1; /* XXX 1 on success. */
1380 1380
1381 if (p) 1381 if (p)
1382 switch (entry->info.type) { 1382 switch (entry->info.type) {
1383 case RPM_BIN_TYPE: 1383 case RPM_BIN_TYPE:
@@ -1443,7 +1443,7 @@ static int copyEntry(const indexEntry entry,
1443 /*@=sizeoftype@*/ 1443 /*@=sizeoftype@*/
1444 char * t; 1444 char * t;
1445 int i; 1445 int i;
1446 1446
1447 /*@-mods@*/ 1447 /*@-mods@*/
1448 if (minMem) { 1448 if (minMem) {
1449 *p = malloc(tableSize); 1449 *p = malloc(tableSize);
@@ -1548,7 +1548,7 @@ int headerAddOrAppendEntry(Header h, int_32 tag, int_32 type,
1548 1548
1549/** 1549/**
1550 * Does locale match entry in header i18n table? 1550 * Does locale match entry in header i18n table?
1551 * 1551 *
1552 * \verbatim 1552 * \verbatim
1553 * The range [l,le) contains the next locale to match: 1553 * The range [l,le) contains the next locale to match:
1554 * ll[_CC][.EEEEE][@dddd] 1554 * ll[_CC][.EEEEE][@dddd]
@@ -1649,7 +1649,7 @@ headerFindI18NString(Header h, indexEntry entry)
1649 (lang = getenv("LC_MESSAGES")) == NULL && 1649 (lang = getenv("LC_MESSAGES")) == NULL &&
1650 (lang = getenv("LANG")) == NULL) 1650 (lang = getenv("LANG")) == NULL)
1651 return entry->data; 1651 return entry->data;
1652 1652
1653 /*@-mods@*/ 1653 /*@-mods@*/
1654 if ((table = findEntry(h, HEADER_I18NTABLE, RPM_STRING_ARRAY_TYPE)) == NULL) 1654 if ((table = findEntry(h, HEADER_I18NTABLE, RPM_STRING_ARRAY_TYPE)) == NULL)
1655 return entry->data; 1655 return entry->data;
@@ -1916,7 +1916,7 @@ int headerNextIterator(HeaderIterator hi,
1916 *tag = entry->info.tag; 1916 *tag = entry->info.tag;
1917 1917
1918 rc = copyEntry(entry, type, p, c, do_copy); 1918 rc = copyEntry(entry, type, p, c, do_copy);
1919 1919
1920 /* XXX 1 on success */ 1920 /* XXX 1 on success */
1921 return ((rc == 1) ? 1 : 0); 1921 return ((rc == 1) ? 1 : 0);
1922} 1922}
@@ -1975,13 +1975,13 @@ Header headerFree(/*@killref@*/ /*@null@*/ Header h)
1975/** 1975/**
1976 * Sanity check on no. of tags. 1976 * Sanity check on no. of tags.
1977 * This check imposes a limit of 65K tags, more than enough. 1977 * This check imposes a limit of 65K tags, more than enough.
1978 */ 1978 */
1979#define hdrchkTags(_ntags) ((_ntags) & 0xffff0000) 1979#define hdrchkTags(_ntags) ((_ntags) & 0xffff0000)
1980 1980
1981/** 1981/**
1982 * Sanity check on data size and/or offset. 1982 * Sanity check on data size and/or offset.
1983 * This check imposes a limit of 16Mb, more than enough. 1983 * This check imposes a limit of 16Mb, more than enough.
1984 */ 1984 */
1985#define hdrchkData(_nbytes) ((_nbytes) & 0xff000000) 1985#define hdrchkData(_nbytes) ((_nbytes) & 0xff000000)
1986 1986
1987 1987
@@ -2130,7 +2130,7 @@ Header headerLoad(/*@kept@*/ void * uh)
2130 Header h = NULL; 2130 Header h = NULL;
2131 entryInfo pe; 2131 entryInfo pe;
2132 char * dataStart; 2132 char * dataStart;
2133 indexEntry entry; 2133 indexEntry entry;
2134 int rdlen; 2134 int rdlen;
2135 int i; 2135 int i;
2136 2136
@@ -2330,7 +2330,7 @@ Header headerRead(FD_t fd, enum hMagic magicp)
2330 goto exit; 2330 goto exit;
2331 reserved = block[i++]; 2331 reserved = block[i++];
2332 } 2332 }
2333 2333
2334 il = ntohl(block[i]); i++; 2334 il = ntohl(block[i]); i++;
2335 dl = ntohl(block[i]); i++; 2335 dl = ntohl(block[i]); i++;
2336 2336
@@ -2351,7 +2351,7 @@ Header headerRead(FD_t fd, enum hMagic magicp)
2351 if (timedRead(fd, (char *)&ei[2], len) != len) 2351 if (timedRead(fd, (char *)&ei[2], len) != len)
2352 goto exit; 2352 goto exit;
2353 /*@=type@*/ 2353 /*@=type@*/
2354 2354
2355 h = headerLoad(ei); 2355 h = headerLoad(ei);
2356 2356
2357exit: 2357exit:
@@ -2546,7 +2546,7 @@ int headerRemoveEntry(Header h, int_32 tag)
2546 if (!entry) return 1; 2546 if (!entry) return 1;
2547 2547
2548 /* Make sure entry points to the first occurence of this tag. */ 2548 /* Make sure entry points to the first occurence of this tag. */
2549 while (entry > h->index && (entry - 1)->info.tag == tag) 2549 while (entry > h->index && (entry - 1)->info.tag == tag)
2550 entry--; 2550 entry--;
2551 2551
2552 /* Free data for tags being removed. */ 2552 /* Free data for tags being removed. */
@@ -2784,7 +2784,7 @@ static Header rpmFreeSignature(Header h);
2784 * @return rpmRC return code 2784 * @return rpmRC return code
2785 */ 2785 */
2786static rpmRC readPackageHeaders(FD_t fd, 2786static rpmRC readPackageHeaders(FD_t fd,
2787 /*@null@*/ /*@out@*/ struct rpmlead * leadPtr, 2787 /*@null@*/ /*@out@*/ struct rpmlead * leadPtr,
2788 /*@null@*/ /*@out@*/ Header * sigs, 2788 /*@null@*/ /*@out@*/ Header * sigs,
2789 /*@null@*/ /*@out@*/ Header * hdrPtr) 2789 /*@null@*/ /*@out@*/ Header * hdrPtr)
2790 /*@modifies fd, *leadPtr, *sigs, *hdrPtr @*/ 2790 /*@modifies fd, *leadPtr, *sigs, *hdrPtr @*/
@@ -2837,7 +2837,7 @@ static rpmRC readPackageHeaders(FD_t fd,
2837 2837
2838 /* 2838 /*
2839 * We switched the way we do relocateable packages. We fix some of 2839 * We switched the way we do relocateable packages. We fix some of
2840 * it up here, though the install code still has to be a bit 2840 * it up here, though the install code still has to be a bit
2841 * careful. This fixup makes queries give the new values though, 2841 * careful. This fixup makes queries give the new values though,
2842 * which is quite handy. 2842 * which is quite handy.
2843 */ 2843 */
@@ -2847,7 +2847,7 @@ static rpmRC readPackageHeaders(FD_t fd,
2847 defaultPrefix = 2847 defaultPrefix =
2848 stripTrailingChar(alloca_strdup(defaultPrefix), '/'); 2848 stripTrailingChar(alloca_strdup(defaultPrefix), '/');
2849 (void) headerAddEntry(*hdr, RPMTAG_PREFIXES, RPM_STRING_ARRAY_TYPE, 2849 (void) headerAddEntry(*hdr, RPMTAG_PREFIXES, RPM_STRING_ARRAY_TYPE,
2850 &defaultPrefix, 1); 2850 &defaultPrefix, 1);
2851 } 2851 }
2852 2852
2853 /* 2853 /*
@@ -2874,11 +2874,11 @@ static rpmRC readPackageHeaders(FD_t fd,
2874 default: 2874 default:
2875 return RPMRC_FAIL; 2875 return RPMRC_FAIL;
2876 /*@notreached@*/ break; 2876 /*@notreached@*/ break;
2877 } 2877 }
2878 2878
2879 if (hdrPtr == NULL) 2879 if (hdrPtr == NULL)
2880 *hdr = headerFree(*hdr); 2880 *hdr = headerFree(*hdr);
2881 2881
2882 return RPMRC_OK; 2882 return RPMRC_OK;
2883} 2883}
2884 2884
@@ -2956,13 +2956,13 @@ static rpmRC rpmReadPackageHeader(FD_t fd, Header * hdrp, int * isSource, int *
2956 headerMergeLegacySigs(*hdrp, sig); 2956 headerMergeLegacySigs(*hdrp, sig);
2957 sig = rpmFreeSignature(sig); 2957 sig = rpmFreeSignature(sig);
2958 } 2958 }
2959 2959
2960 if (isSource) *isSource = lead.type == RPMLEAD_SOURCE; 2960 if (isSource) *isSource = lead.type == RPMLEAD_SOURCE;
2961 /*@-mods@*/ 2961 /*@-mods@*/
2962 if (major) *major = lead.major; 2962 if (major) *major = lead.major;
2963 if (minor) *minor = lead.minor; 2963 if (minor) *minor = lead.minor;
2964 /*@=mods@*/ 2964 /*@=mods@*/
2965 2965
2966exit: 2966exit:
2967 return rc; 2967 return rc;
2968} 2968}
@@ -2978,7 +2978,7 @@ static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordType type,
2978 if (keyword == NULL) 2978 if (keyword == NULL)
2979 return next; 2979 return next;
2980 result = malloc(sizeof(EXTRACTOR_KeywordList)); 2980 result = malloc(sizeof(EXTRACTOR_KeywordList));
2981 result->next = next; 2981 result->next = next;
2982 result->keyword = strdup(keyword); 2982 result->keyword = strdup(keyword);
2983 result->keywordType = type; 2983 result->keywordType = type;
2984 return result; 2984 return result;
@@ -3028,13 +3028,13 @@ struct EXTRACTOR_Keywords * libextractor_rpm_extract(char * filename,
3028 int minor; 3028 int minor;
3029 int i; 3029 int i;
3030 char verb[40]; 3030 char verb[40];
3031 3031
3032 handle.data = data; 3032 handle.data = data;
3033 handle.pos = 0; 3033 handle.pos = 0;
3034 handle.len = size; 3034 handle.len = size;
3035 if (0 != rpmReadPackageHeader(&handle, 3035 if (0 != rpmReadPackageHeader(&handle,
3036 &hdr, 3036 &hdr,
3037 &isSource, 3037 &isSource,
3038 &major, 3038 &major,
3039 &minor)) { 3039 &minor)) {
3040 return prev; 3040 return prev;
@@ -3051,7 +3051,7 @@ struct EXTRACTOR_Keywords * libextractor_rpm_extract(char * filename,
3051 else 3051 else
3052 sprintf(verb, 3052 sprintf(verb,
3053 _("Binary RPM %d.%d"), 3053 _("Binary RPM %d.%d"),
3054 major, 3054 major,
3055 minor); 3055 minor);
3056 prev = addKeyword(EXTRACTOR_UNKNOWN, 3056 prev = addKeyword(EXTRACTOR_UNKNOWN,
3057 verb, 3057 verb,
@@ -3064,15 +3064,15 @@ struct EXTRACTOR_Keywords * libextractor_rpm_extract(char * filename,
3064 &c, 3064 &c,
3065 0)) { 3065 0)) {
3066 i=0; 3066 i=0;
3067 while (tests[i].rtype != 0) { 3067 while (tests[i].rtype != 0) {
3068 if (tests[i].rtype == tag) { 3068 if (tests[i].rtype == tag) {
3069 switch (type) { 3069 switch (type) {
3070 case RPM_STRING_ARRAY_TYPE: { 3070 case RPM_STRING_ARRAY_TYPE: {
3071 char * tmp; 3071 char * tmp;
3072 const char * p2; 3072 const char * p2;
3073 int c2; 3073 int c2;
3074 int size; 3074 int size;
3075 3075
3076 c2 = c; 3076 c2 = c;
3077 p2 = p; 3077 p2 = p;
3078 size = 0; 3078 size = 0;
@@ -3081,7 +3081,7 @@ struct EXTRACTOR_Keywords * libextractor_rpm_extract(char * filename,
3081 p2 = strchr(p2, 0); 3081 p2 = strchr(p2, 0);
3082 p2++; 3082 p2++;
3083 } 3083 }
3084 3084
3085 tmp = malloc(size+1); 3085 tmp = malloc(size+1);
3086 tmp[0] = '\0'; 3086 tmp[0] = '\0';
3087 while (c--) { 3087 while (c--) {
@@ -3091,11 +3091,11 @@ struct EXTRACTOR_Keywords * libextractor_rpm_extract(char * filename,
3091 } 3091 }
3092 prev = addKeyword(tests[i].type, 3092 prev = addKeyword(tests[i].type,
3093 tmp, 3093 tmp,
3094 prev); 3094 prev);
3095 free(tmp); 3095 free(tmp);
3096 break; 3096 break;
3097 } 3097 }
3098 case RPM_I18NSTRING_TYPE: { 3098 case RPM_I18NSTRING_TYPE: {
3099 char * tmp; 3099 char * tmp;
3100 const char * p2; 3100 const char * p2;
3101 int c2; 3101 int c2;
@@ -3110,7 +3110,7 @@ struct EXTRACTOR_Keywords * libextractor_rpm_extract(char * filename,
3110 p2 = strchr(p2, 0); 3110 p2 = strchr(p2, 0);
3111 p2++; 3111 p2++;
3112 } 3112 }
3113 3113
3114 tmp = malloc(size+1); 3114 tmp = malloc(size+1);
3115 tmp[0] = '\0'; 3115 tmp[0] = '\0';
3116 p2 = p; 3116 p2 = p;
@@ -3122,7 +3122,7 @@ struct EXTRACTOR_Keywords * libextractor_rpm_extract(char * filename,
3122 } 3122 }
3123 prev = addKeyword(tests[i].type, 3123 prev = addKeyword(tests[i].type,
3124 tmp, 3124 tmp,
3125 prev); 3125 prev);
3126 free(tmp); 3126 free(tmp);
3127 break; 3127 break;
3128 } 3128 }
@@ -3139,27 +3139,27 @@ struct EXTRACTOR_Keywords * libextractor_rpm_extract(char * filename,
3139 tmp[strlen(tmp)-1] = '\0'; /* eat linefeed */ 3139 tmp[strlen(tmp)-1] = '\0'; /* eat linefeed */
3140 prev = addKeyword(tests[i].type, 3140 prev = addKeyword(tests[i].type,
3141 tmp, 3141 tmp,
3142 prev); 3142 prev);
3143 } else { 3143 } else {
3144 char tmp[14]; 3144 char tmp[14];
3145 3145
3146 sprintf(tmp, "%d", *(int*)p); 3146 sprintf(tmp, "%d", *(int*)p);
3147 prev = addKeyword(tests[i].type, 3147 prev = addKeyword(tests[i].type,
3148 tmp, 3148 tmp,
3149 prev); 3149 prev);
3150 } 3150 }
3151 break; 3151 break;
3152 } 3152 }
3153 } 3153 }
3154 } 3154 }
3155 i++; 3155 i++;
3156 } 3156 }
3157 if ( ( (type == RPM_BIN_TYPE) || 3157 if ( ( (type == RPM_BIN_TYPE) ||
3158 (type == RPM_I18NSTRING_TYPE) || 3158 (type == RPM_I18NSTRING_TYPE) ||
3159 (type == RPM_STRING_ARRAY_TYPE) ) && 3159 (type == RPM_STRING_ARRAY_TYPE) ) &&
3160 (p != NULL) ) { 3160 (p != NULL) ) {
3161 free((void*)p); 3161 free((void*)p);
3162 } 3162 }
3163 } 3163 }
3164 headerFreeIterator(hi); 3164 headerFreeIterator(hi);
3165 headerFree(hdr); 3165 headerFree(hdr);
diff --git a/src/plugins/splitextractor.c b/src/plugins/splitextractor.c
index 1729476..55e9c74 100644
--- a/src/plugins/splitextractor.c
+++ b/src/plugins/splitextractor.c
@@ -29,7 +29,7 @@ static void addKeyword(struct EXTRACTOR_Keywords ** list,
29 EXTRACTOR_KeywordType type) { 29 EXTRACTOR_KeywordType type) {
30 EXTRACTOR_KeywordList * next; 30 EXTRACTOR_KeywordList * next;
31 next = malloc(sizeof(EXTRACTOR_KeywordList)); 31 next = malloc(sizeof(EXTRACTOR_KeywordList));
32 next->next = *list; 32 next->next = *list;
33 next->keyword = strdup(keyword); 33 next->keyword = strdup(keyword);
34 next->keywordType = type; 34 next->keywordType = type;
35 *list = next; 35 *list = next;
diff --git a/src/plugins/tarextractor.c b/src/plugins/tarextractor.c
index 4a2812f..8f17b57 100644
--- a/src/plugins/tarextractor.c
+++ b/src/plugins/tarextractor.c
@@ -42,7 +42,7 @@ static EXTRACTOR_KeywordList * addKeyword(EXTRACTOR_KeywordType type,
42 return next; 42 return next;
43 } 43 }
44 result = malloc(sizeof(EXTRACTOR_KeywordList)); 44 result = malloc(sizeof(EXTRACTOR_KeywordList));
45 result->next = next; 45 result->next = next;
46 result->keyword = keyword; 46 result->keyword = keyword;
47 result->keywordType = type; 47 result->keywordType = type;
48 return result; 48 return result;
@@ -81,19 +81,19 @@ typedef struct {
81} USTarHeader; 81} USTarHeader;
82 82
83 83
84static struct EXTRACTOR_Keywords * 84static struct EXTRACTOR_Keywords *
85tar_extract(const char * data, 85tar_extract(const char * data,
86 size_t size, 86 size_t size,
87 struct EXTRACTOR_Keywords * prev) { 87 struct EXTRACTOR_Keywords * prev) {
88 TarHeader * tar; 88 TarHeader * tar;
89 USTarHeader * ustar; 89 USTarHeader * ustar;
90 size_t pos; 90 size_t pos;
91 91
92 if (0 != (size % 512) ) 92 if (0 != (size % 512) )
93 return prev; /* cannot be tar! */ 93 return prev; /* cannot be tar! */
94 if (size < 1024) 94 if (size < 1024)
95 return prev; 95 return prev;
96 size -= 1024; /* last 2 blocks are all zeros */ 96 size -= 1024; /* last 2 blocks are all zeros */
97 /* fixme: we may want to check that the last 97 /* fixme: we may want to check that the last
98 1024 bytes are all zeros here... */ 98 1024 bytes are all zeros here... */
99 99
@@ -108,13 +108,13 @@ tar_extract(const char * data,
108 ustar = (USTarHeader*) &data[pos]; 108 ustar = (USTarHeader*) &data[pos];
109 if (0 == strncmp("ustar", 109 if (0 == strncmp("ustar",
110 &ustar->magic[0], 110 &ustar->magic[0],
111 strlen("ustar"))) 111 strlen("ustar")))
112 pos += 512; /* sizeof(USTarHeader); */ 112 pos += 512; /* sizeof(USTarHeader); */
113 else 113 else
114 pos += 257; /* sizeof(TarHeader); minus gcc alignment... */ 114 pos += 257; /* sizeof(TarHeader); minus gcc alignment... */
115 } else { 115 } else {
116 pos += 257; /* sizeof(TarHeader); minus gcc alignment... */ 116 pos += 257; /* sizeof(TarHeader); minus gcc alignment... */
117 } 117 }
118 memcpy(buf, &tar->filesize[0], 12); 118 memcpy(buf, &tar->filesize[0], 12);
119 buf[12] = '\0'; 119 buf[12] = '\0';
120 if (1 != sscanf(buf, "%12llo", &fsize)) /* octal! Yuck yuck! */ 120 if (1 != sscanf(buf, "%12llo", &fsize)) /* octal! Yuck yuck! */
@@ -188,11 +188,11 @@ struct EXTRACTOR_Keywords * libextractor_tar_extract(const char * filename,
188 } 188 }
189 gzclose(gzf); 189 gzclose(gzf);
190 prev = tar_extract(buf, bufSize, prev); 190 prev = tar_extract(buf, bufSize, prev);
191 free(buf); 191 free(buf);
192 return prev; 192 return prev;
193 } else { 193 } else {
194 /* try for uncompressed tar */ 194 /* try for uncompressed tar */
195 return tar_extract(data, size, prev); 195 return tar_extract(data, size, prev);
196 } 196 }
197} 197}
198 198
diff --git a/src/plugins/templateextractor.c b/src/plugins/templateextractor.c
index 4a03879..f9f890d 100644
--- a/src/plugins/templateextractor.c
+++ b/src/plugins/templateextractor.c
@@ -29,7 +29,7 @@ static EXTRACTOR_KeywordList * addKeyword(EXTRACTOR_KeywordType type,
29 if (keyword == NULL) 29 if (keyword == NULL)
30 return next; 30 return next;
31 result = malloc(sizeof(EXTRACTOR_KeywordList)); 31 result = malloc(sizeof(EXTRACTOR_KeywordList));
32 result->next = next; 32 result->next = next;
33 result->keyword = keyword; 33 result->keyword = keyword;
34 result->keywordType = type; 34 result->keywordType = type;
35 return result; 35 return result;
diff --git a/src/plugins/thumbnail/thumbnailextractor.c b/src/plugins/thumbnail/thumbnailextractor.c
index d959c4f..9b5fafd 100644
--- a/src/plugins/thumbnail/thumbnailextractor.c
+++ b/src/plugins/thumbnail/thumbnailextractor.c
@@ -41,7 +41,7 @@ static EXTRACTOR_KeywordList * addKeyword(EXTRACTOR_KeywordType type,
41 if (keyword == NULL) 41 if (keyword == NULL)
42 return next; 42 return next;
43 result = malloc(sizeof(EXTRACTOR_KeywordList)); 43 result = malloc(sizeof(EXTRACTOR_KeywordList));
44 result->next = next; 44 result->next = next;
45 result->keyword = keyword; 45 result->keyword = keyword;
46 result->keywordType = type; 46 result->keywordType = type;
47 return result; 47 return result;
@@ -49,9 +49,9 @@ static EXTRACTOR_KeywordList * addKeyword(EXTRACTOR_KeywordType type,
49 49
50 50
51/* which mime-types maybe subjected to 51/* which mime-types maybe subjected to
52 the thumbnail extractor (ImageMagick 52 the thumbnail extractor (ImageMagick
53 crashes and/or prints errors for bad 53 crashes and/or prints errors for bad
54 formats, so we need to be rather 54 formats, so we need to be rather
55 conservative here) */ 55 conservative here) */
56static char * whitelist[] = { 56static char * whitelist[] = {
57 "image/jpeg", 57 "image/jpeg",
@@ -87,12 +87,12 @@ struct EXTRACTOR_Keywords * libextractor_thumbnail_extract(const char * filename
87 unsigned char marker; 87 unsigned char marker;
88 const char * mime; 88 const char * mime;
89 int j; 89 int j;
90 90
91 /* if the mime-type of the file is not whitelisted 91 /* if the mime-type of the file is not whitelisted
92 do not run the thumbnail extactor! */ 92 do not run the thumbnail extactor! */
93 mime = EXTRACTOR_extractLast(EXTRACTOR_MIMETYPE, 93 mime = EXTRACTOR_extractLast(EXTRACTOR_MIMETYPE,
94 prev); 94 prev);
95 if (mime == NULL) 95 if (mime == NULL)
96 return prev; 96 return prev;
97 j = 0; 97 j = 0;
98 while (whitelist[j] != NULL) { 98 while (whitelist[j] != NULL) {
@@ -103,7 +103,7 @@ struct EXTRACTOR_Keywords * libextractor_thumbnail_extract(const char * filename
103 if (whitelist[j] == NULL) 103 if (whitelist[j] == NULL)
104 return prev; 104 return prev;
105 105
106 magick_wand = NewMagickWand(); 106 magick_wand = NewMagickWand();
107 status = MagickReadImageBlob(magick_wand, data, size); 107 status = MagickReadImageBlob(magick_wand, data, size);
108 if (status == MagickFalse) { 108 if (status == MagickFalse) {
109 DestroyMagickWand(magick_wand); 109 DestroyMagickWand(magick_wand);
@@ -124,7 +124,7 @@ struct EXTRACTOR_Keywords * libextractor_thumbnail_extract(const char * filename
124 DestroyMagickWand(magick_wand); 124 DestroyMagickWand(magick_wand);
125 return prev; 125 return prev;
126 } 126 }
127 127
128 128
129 if (height > THUMBSIZE) { 129 if (height > THUMBSIZE) {
130 width = width * THUMBSIZE / height; 130 width = width * THUMBSIZE / height;
@@ -140,7 +140,7 @@ struct EXTRACTOR_Keywords * libextractor_thumbnail_extract(const char * filename
140 MagickSetImageChannelDepth(magick_wand, 140 MagickSetImageChannelDepth(magick_wand,
141 RedChannel, 141 RedChannel,
142 2); 142 2);
143 MagickCommentImage(magick_wand, ""); 143 MagickCommentImage(magick_wand, "");
144 MagickSetImageChannelDepth(magick_wand, 144 MagickSetImageChannelDepth(magick_wand,
145 GreenChannel, 145 GreenChannel,
146 2); 146 2);
@@ -159,10 +159,10 @@ struct EXTRACTOR_Keywords * libextractor_thumbnail_extract(const char * filename
159 } 159 }
160 thumb = MagickGetImageBlob(magick_wand, &length); 160 thumb = MagickGetImageBlob(magick_wand, &length);
161 DestroyMagickWand(magick_wand); 161 DestroyMagickWand(magick_wand);
162 if (thumb == NULL) 162 if (thumb == NULL)
163 return prev; 163 return prev;
164 164
165 165
166 /* encode! */ 166 /* encode! */
167 binary = malloc(2 + length + (length+256) / 254); 167 binary = malloc(2 + length + (length+256) / 254);
168 if (binary == NULL) 168 if (binary == NULL)
@@ -179,8 +179,8 @@ struct EXTRACTOR_Keywords * libextractor_thumbnail_extract(const char * filename
179 if (end > length) 179 if (end > length)
180 end = length; 180 end = length;
181 memset(markers, 0, sizeof(markers)); 181 memset(markers, 0, sizeof(markers));
182 for (i=pos;i<end;i++) 182 for (i=pos;i<end;i++)
183 markers[thumb[i]&7] |= 1 << (thumb[i] >> 3); 183 markers[thumb[i]&7] |= 1 << (thumb[i] >> 3);
184 marker = 1; 184 marker = 1;
185 while (markers[marker&7] & (1 << (marker >> 3))) { 185 while (markers[marker&7] & (1 << (marker >> 3))) {
186 marker++; 186 marker++;
@@ -208,7 +208,7 @@ struct EXTRACTOR_Keywords * libextractor_thumbnail_extract(const char * filename
208 208
209/** 209/**
210 * This function can be used to decode the binary data 210 * This function can be used to decode the binary data
211 * stream produced by the thumbnailextractor. 211 * stream produced by the thumbnailextractor.
212 * 212 *
213 * @param in 0-terminated string from the meta-data 213 * @param in 0-terminated string from the meta-data
214 * @return 1 on error, 0 on success 214 * @return 1 on error, 0 on success
@@ -223,7 +223,7 @@ int decodeThumbnail(const unsigned char * in,
223 size_t i; 223 size_t i;
224 size_t end; 224 size_t end;
225 size_t inSize; 225 size_t inSize;
226 226
227 inSize = strlen(in); 227 inSize = strlen(in);
228 if (inSize == 0) { 228 if (inSize == 0) {
229 *out = NULL; 229 *out = NULL;
@@ -233,7 +233,7 @@ int decodeThumbnail(const unsigned char * in,
233 233
234 buf = malloc(inSize); /* slightly more than needed ;-) */ 234 buf = malloc(inSize); /* slightly more than needed ;-) */
235 *out = buf; 235 *out = buf;
236 236
237 pos = 0; 237 pos = 0;
238 wpos = 0; 238 wpos = 0;
239 while (pos < inSize) { 239 while (pos < inSize) {
@@ -241,7 +241,7 @@ int decodeThumbnail(const unsigned char * in,
241 if (end > inSize) 241 if (end > inSize)
242 end = inSize; 242 end = inSize;
243 marker = in[pos++]; 243 marker = in[pos++];
244 for (i=pos;i<end;i++) 244 for (i=pos;i<end;i++)
245 buf[wpos++] = (in[i] == marker) ? 0 : in[i]; 245 buf[wpos++] = (in[i] == marker) ? 0 : in[i];
246 pos = end; 246 pos = end;
247 } 247 }
diff --git a/src/plugins/tiffextractor.c b/src/plugins/tiffextractor.c
index 78dadba..3fcecbe 100644
--- a/src/plugins/tiffextractor.c
+++ b/src/plugins/tiffextractor.c
@@ -29,7 +29,7 @@ static void addKeyword(struct EXTRACTOR_Keywords ** list,
29 EXTRACTOR_KeywordType type) { 29 EXTRACTOR_KeywordType type) {
30 EXTRACTOR_KeywordList * next; 30 EXTRACTOR_KeywordList * next;
31 next = malloc(sizeof(EXTRACTOR_KeywordList)); 31 next = malloc(sizeof(EXTRACTOR_KeywordList));
32 next->next = *list; 32 next->next = *list;
33 next->keyword = keyword; 33 next->keyword = keyword;
34 next->keywordType = type; 34 next->keywordType = type;
35 *list = next; 35 *list = next;
@@ -64,7 +64,7 @@ typedef struct {
64 &(p)->value_or_offset 64 &(p)->value_or_offset
65static char * DIRECTORY_ENTRY_SPECS[] = { 65static char * DIRECTORY_ENTRY_SPECS[] = {
66 "hhww", 66 "hhww",
67 "HHWW" 67 "HHWW"
68}; 68};
69 69
70#define TAG_LENGTH 0x101 70#define TAG_LENGTH 0x101
@@ -115,7 +115,7 @@ struct EXTRACTOR_Keywords * libextractor_tiff_extract(char * filename,
115 int current_ifd; 115 int current_ifd;
116 long long length = -1; 116 long long length = -1;
117 long long width = -1; 117 long long width = -1;
118 118
119 if (size < TIFF_HEADER_SIZE) 119 if (size < TIFF_HEADER_SIZE)
120 return prev; /* can not be tiff */ 120 return prev; /* can not be tiff */
121 if ( (data[0] == 0x49) && 121 if ( (data[0] == 0x49) &&
@@ -128,7 +128,7 @@ struct EXTRACTOR_Keywords * libextractor_tiff_extract(char * filename,
128 return prev; /* can not be tiff */ 128 return prev; /* can not be tiff */
129#if __BYTE_ORDER == __BIG_ENDIAN 129#if __BYTE_ORDER == __BIG_ENDIAN
130 byteOrder = 1-byteOrder; 130 byteOrder = 1-byteOrder;
131#endif 131#endif
132 cat_unpack(data, 132 cat_unpack(data,
133 TIFF_HEADER_SPECS[byteOrder], 133 TIFF_HEADER_SPECS[byteOrder],
134 TIFF_HEADER_FIELDS(&hdr)); 134 TIFF_HEADER_FIELDS(&hdr));
@@ -159,7 +159,7 @@ struct EXTRACTOR_Keywords * libextractor_tiff_extract(char * filename,
159 for (i=0;i<len;i++) { 159 for (i=0;i<len;i++) {
160 DIRECTORY_ENTRY entry; 160 DIRECTORY_ENTRY entry;
161 off = current_ifd + 2 + DIRECTORY_ENTRY_SIZE*i; 161 off = current_ifd + 2 + DIRECTORY_ENTRY_SIZE*i;
162 162
163 cat_unpack(&data[off], 163 cat_unpack(&data[off],
164 DIRECTORY_ENTRY_SPECS[byteOrder], 164 DIRECTORY_ENTRY_SPECS[byteOrder],
165 DIRECTORY_ENTRY_FIELDS(&entry)); 165 DIRECTORY_ENTRY_FIELDS(&entry));
@@ -174,7 +174,7 @@ struct EXTRACTOR_Keywords * libextractor_tiff_extract(char * filename,
174 if (width != -1) { 174 if (width != -1) {
175 char * tmp; 175 char * tmp;
176 tmp = malloc(128); 176 tmp = malloc(128);
177 sprintf(tmp, "%ux%u", 177 sprintf(tmp, "%ux%u",
178 (unsigned int) width, 178 (unsigned int) width,
179 (unsigned int) length); 179 (unsigned int) length);
180 addKeyword(&prev, 180 addKeyword(&prev,
@@ -182,17 +182,17 @@ struct EXTRACTOR_Keywords * libextractor_tiff_extract(char * filename,
182 EXTRACTOR_SIZE); 182 EXTRACTOR_SIZE);
183 free(tmp); 183 free(tmp);
184 } 184 }
185 break; 185 break;
186 case TAG_WIDTH: 186 case TAG_WIDTH:
187 if ( (entry.type == TYPE_SHORT) && 187 if ( (entry.type == TYPE_SHORT) &&
188 (byteOrder == 1) ) 188 (byteOrder == 1) )
189 width = entry.value_or_offset >> 16; 189 width = entry.value_or_offset >> 16;
190 else 190 else
191 width = entry.value_or_offset; 191 width = entry.value_or_offset;
192 if (length != -1) { 192 if (length != -1) {
193 char * tmp; 193 char * tmp;
194 tmp = malloc(128); 194 tmp = malloc(128);
195 sprintf(tmp, "%ux%u", 195 sprintf(tmp, "%ux%u",
196 (unsigned int) width, 196 (unsigned int) width,
197 (unsigned int) length); 197 (unsigned int) length);
198 addKeyword(&prev, 198 addKeyword(&prev,
@@ -251,13 +251,13 @@ struct EXTRACTOR_Keywords * libextractor_tiff_extract(char * filename,
251 break; 251 break;
252 } 252 }
253 } 253 }
254 254
255 off = current_ifd + 2 + DIRECTORY_ENTRY_SIZE * len; 255 off = current_ifd + 2 + DIRECTORY_ENTRY_SIZE * len;
256 if (byteOrder == 0) 256 if (byteOrder == 0)
257 current_ifd = data[off+3]<<24|data[off+2]<<16|data[off+1]<<8|data[off]; 257 current_ifd = data[off+3]<<24|data[off+2]<<16|data[off+1]<<8|data[off];
258 else 258 else
259 current_ifd = data[off]<<24|data[off+1]<<16|data[off+2]<<8|data[off+3]; 259 current_ifd = data[off]<<24|data[off+1]<<16|data[off+2]<<8|data[off+3];
260 } 260 }
261 return prev; 261 return prev;
262} 262}
263 263
diff --git a/src/plugins/wavextractor.c b/src/plugins/wavextractor.c
index 86e34da..4aa89db 100644
--- a/src/plugins/wavextractor.c
+++ b/src/plugins/wavextractor.c
@@ -21,8 +21,8 @@
21 (PD) 2004 The Bitzi Corporation 21 (PD) 2004 The Bitzi Corporation
22 http://bitzi.com/ 22 http://bitzi.com/
23 (PD) 2001 The Bitzi Corporation 23 (PD) 2001 The Bitzi Corporation
24 Please see file COPYING or http://bitzi.com/publicdomain 24 Please see file COPYING or http://bitzi.com/publicdomain
25 for more info. 25 for more info.
26*/ 26*/
27 27
28 28
@@ -35,7 +35,7 @@ static void addKeyword(struct EXTRACTOR_Keywords ** list,
35 EXTRACTOR_KeywordType type) { 35 EXTRACTOR_KeywordType type) {
36 EXTRACTOR_KeywordList * next; 36 EXTRACTOR_KeywordList * next;
37 next = malloc(sizeof(EXTRACTOR_KeywordList)); 37 next = malloc(sizeof(EXTRACTOR_KeywordList));
38 next->next = *list; 38 next->next = *list;
39 next->keyword = keyword; 39 next->keyword = keyword;
40 next->keywordType = type; 40 next->keywordType = type;
41 *list = next; 41 *list = next;
@@ -44,14 +44,14 @@ static void addKeyword(struct EXTRACTOR_Keywords ** list,
44#if BIG_ENDIAN_HOST 44#if BIG_ENDIAN_HOST
45static short toLittleEndian16(short in) { 45static short toLittleEndian16(short in) {
46 char *ptr = (char *)&in; 46 char *ptr = (char *)&in;
47 47
48 return ((ptr[1] & 0xFF) << 8) | (ptr[0] & 0xFF); 48 return ((ptr[1] & 0xFF) << 8) | (ptr[0] & 0xFF);
49} 49}
50 50
51static unsigned int toLittleEndian32(unsigned int in) { 51static unsigned int toLittleEndian32(unsigned int in) {
52 char *ptr = (char *)&in; 52 char *ptr = (char *)&in;
53 53
54 return ((ptr[3] & 0xFF) << 24) | ((ptr[2] & 0xFF) << 16) | ((ptr[1] & 0xFF) << 8) | (ptr[0] & 0xFF); 54 return ((ptr[3] & 0xFF) << 24) | ((ptr[2] & 0xFF) << 16) | ((ptr[1] & 0xFF) << 8) | (ptr[0] & 0xFF);
55} 55}
56#endif 56#endif
57 57
@@ -74,20 +74,20 @@ struct EXTRACTOR_Keywords * libextractor_wav_extract(char * filename,
74 int bytesProcessed; 74 int bytesProcessed;
75 char * scratch; 75 char * scratch;
76 76
77 77
78 if ( (bufLen < 44) || 78 if ( (bufLen < 44) ||
79 (buf[0] != 'R' || buf[1] != 'I' || 79 (buf[0] != 'R' || buf[1] != 'I' ||
80 buf[2] != 'F' || buf[3] != 'F' || 80 buf[2] != 'F' || buf[3] != 'F' ||
81 buf[8] != 'W' || buf[9] != 'A' || 81 buf[8] != 'W' || buf[9] != 'A' ||
82 buf[10] != 'V' || buf[11] != 'E' || 82 buf[10] != 'V' || buf[11] != 'E' ||
83 buf[12] != 'f' || buf[13] != 'm' || 83 buf[12] != 'f' || buf[13] != 'm' ||
84 buf[14] != 't' || buf[15] != ' ') ) 84 buf[14] != 't' || buf[15] != ' ') )
85 return prev; /* not a WAV file */ 85 return prev; /* not a WAV file */
86 86
87 channels = *((unsigned short *)&buf[22]); 87 channels = *((unsigned short *)&buf[22]);
88 sampleRate = *((unsigned int *)&buf[24]); 88 sampleRate = *((unsigned int *)&buf[24]);
89 sampleSize = *((unsigned short *)&buf[34]); 89 sampleSize = *((unsigned short *)&buf[34]);
90 dataLen = *((unsigned int *)&buf[40]); 90 dataLen = *((unsigned int *)&buf[40]);
91 91
92#if BIG_ENDIAN_HOST 92#if BIG_ENDIAN_HOST
93 channels = toLittleEndian16(channels); 93 channels = toLittleEndian16(channels);
@@ -96,17 +96,17 @@ struct EXTRACTOR_Keywords * libextractor_wav_extract(char * filename,
96 dataLen = toLittleEndian32(dataLen); 96 dataLen = toLittleEndian32(dataLen);
97#endif 97#endif
98 98
99 if (sampleSize != 8 && sampleSize != 16) 99 if (sampleSize != 8 && sampleSize != 16)
100 return prev; /* invalid sample size found in wav file */ 100 return prev; /* invalid sample size found in wav file */
101 if (channels == 0) 101 if (channels == 0)
102 return prev; /* invalid channels value -- avoid division by 0! */ 102 return prev; /* invalid channels value -- avoid division by 0! */
103 samples = dataLen / (channels * (sampleSize >> 3)); 103 samples = dataLen / (channels * (sampleSize >> 3));
104 104
105 scratch = malloc(256); 105 scratch = malloc(256);
106 snprintf(scratch, 106 snprintf(scratch,
107 256, 107 256,
108 "%u ms, %d Hz, %s", 108 "%u ms, %d Hz, %s",
109 (samples < sampleRate) 109 (samples < sampleRate)
110 ? (samples * 1000 / sampleRate) 110 ? (samples * 1000 / sampleRate)
111 : (samples / sampleRate) * 1000, 111 : (samples / sampleRate) * 1000,
112 sampleRate, 112 sampleRate,