commit 00072f35a3bd58eb2f9a734d3af1996370da9e0b parent 3a0ca0acb30ca5c49511d8d25e6d0a8e55851199 Author: Christian Grothoff <christian@grothoff.org> Date: Fri, 16 Sep 2005 06:49:37 +0000 gcc4 Diffstat:
21 files changed, 166 insertions(+), 293 deletions(-)
diff --git a/ChangeLog b/ChangeLog @@ -1,3 +1,6 @@ +Thu Sep 15 21:55:19 PDT 2005 + Fixing compiler warnings given by gcc 4.0. + Thu Sep 15 00:56:51 PDT 2005 Fixed incorrectly handled integer overflow in png extractor. diff --git a/configure.ac b/configure.ac @@ -20,9 +20,9 @@ AC_CANONICAL_HOST # So, instead, we do this crazyness globally. The list of compilers that # you see below is taken right out of the autoconf (version 2.57) sources, # so it should not impede our portability. -AC_PROG_CC(gcc-3.3 gcc2 gcc cc /usr/ucb/cc cl) +AC_PROG_CC(gcc-4.0 gcc-3.3 gcc2 gcc cc /usr/ucb/cc cl) AC_PROG_CPP -AC_PROG_CXX(g++-3.3 g++2 g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC) +AC_PROG_CXX(g++-4.0 g++-3.3 g++2 g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC) AC_PROG_INSTALL AC_PROG_LN_S diff --git a/src/include/extractor.h b/src/include/extractor.h @@ -29,7 +29,7 @@ extern "C" { * 0.2.6-1 => 0x00020601 * 4.5.2-0 => 0x04050200 */ -#define EXTRACTOR_VERSION 0x00050502 +#define EXTRACTOR_VERSION 0x00050503 #include <stdio.h> @@ -292,7 +292,7 @@ EXTRACTOR_getKeywords(EXTRACTOR_ExtractorList * extractor, */ EXTRACTOR_KeywordList * EXTRACTOR_getKeywords2(EXTRACTOR_ExtractorList * extractor, - const char * data, + const void * data, size_t size); @@ -381,7 +381,7 @@ unsigned int EXTRACTOR_countKeywords(EXTRACTOR_KeywordList * keywords); * @param in 0-terminated string from the meta-data * @return 1 on error, 0 on success */ -int EXTRACTOR_binaryDecode(const unsigned char * in, +int EXTRACTOR_binaryDecode(const char * in, unsigned char ** out, size_t * outSize); @@ -394,7 +394,7 @@ int EXTRACTOR_binaryDecode(const unsigned char * in, * @return NULL on error, the 0-terminated * encoding otherwise */ -char * EXTRACTOR_binaryEncode(const char * data, +char * EXTRACTOR_binaryEncode(const unsigned char * data, size_t size); diff --git a/src/main/extractor.c b/src/main/extractor.c @@ -641,7 +641,7 @@ getKeywords (EXTRACTOR_ExtractorList * extractor, const unsigned char * data, size_t size) { EXTRACTOR_KeywordList *result; - char * buf; + unsigned char * buf; size_t dsize; #if HAVE_ZLIB z_stream strm; @@ -721,10 +721,10 @@ getKeywords (EXTRACTOR_ExtractorList * extractor, gzip_header_length = 0; #endif if (size > gzip_header_length) { - strm.next_in = (char*) data + gzip_header_length; + strm.next_in = (Bytef*) data + gzip_header_length; strm.avail_in = size - gzip_header_length; } else { - strm.next_in = (char*) data; + strm.next_in = (Bytef*) data; strm.avail_in = 0; } strm.total_in = 0; @@ -754,7 +754,7 @@ getKeywords (EXTRACTOR_ExtractorList * extractor, if (buf == NULL) { inflateEnd(&strm); } else { - strm.next_out = buf; + strm.next_out = (Bytef*) buf; strm.avail_out = dsize; do { ret = inflate(&strm, @@ -768,7 +768,7 @@ getKeywords (EXTRACTOR_ExtractorList * extractor, if (dsize > MAX_DECOMPRESS) dsize = MAX_DECOMPRESS; buf = realloc(buf, dsize); - strm.next_out = &buf[pos]; + strm.next_out = (Bytef*) &buf[pos]; strm.avail_out = dsize - pos; } else if (ret != Z_STREAM_END) { /* error */ @@ -815,7 +815,7 @@ getKeywords (EXTRACTOR_ExtractorList * extractor, if (buf == NULL) { BZ2_bzDecompressEnd(&bstrm); } else { - bstrm.next_out = buf; + bstrm.next_out = (char*) buf; bstrm.avail_out = dsize; do { bret = BZ2_bzDecompress(&bstrm); @@ -828,7 +828,7 @@ getKeywords (EXTRACTOR_ExtractorList * extractor, if (dsize > MAX_DECOMPRESS) dsize = MAX_DECOMPRESS; buf = realloc(buf, dsize); - bstrm.next_out = &buf[bpos]; + bstrm.next_out = (char*) &buf[bpos]; bstrm.avail_out = dsize - bpos; } else if (bret != BZ_STREAM_END) { /* error */ @@ -876,10 +876,10 @@ getKeywords (EXTRACTOR_ExtractorList * extractor, */ EXTRACTOR_KeywordList * EXTRACTOR_getKeywords (EXTRACTOR_ExtractorList * extractor, - const char *filename) { + const char * filename) { EXTRACTOR_KeywordList *result; int file; - char * buffer; + void * buffer; struct stat fstatbuf; size_t size; @@ -931,7 +931,7 @@ EXTRACTOR_getKeywords (EXTRACTOR_ExtractorList * extractor, */ EXTRACTOR_KeywordList * EXTRACTOR_getKeywords2(EXTRACTOR_ExtractorList * extractor, - const char * data, + const void * data, size_t size) { if (data == NULL) return NULL; @@ -1227,7 +1227,7 @@ EXTRACTOR_countKeywords (EXTRACTOR_KeywordList * keywords) * @return NULL on error, the 0-terminated * encoding otherwise */ -char * EXTRACTOR_binaryEncode(const char * data, +char * EXTRACTOR_binaryEncode(const unsigned char * data, size_t size) { char * binary; @@ -1286,7 +1286,7 @@ char * EXTRACTOR_binaryEncode(const char * data, * @param in 0-terminated string from the meta-data * @return 1 on error, 0 on success */ -int EXTRACTOR_binaryDecode(const unsigned char * in, +int EXTRACTOR_binaryDecode(const char * in, unsigned char ** out, size_t * outSize) { unsigned char * buf; diff --git a/src/plugins/debextractor.c b/src/plugins/debextractor.c @@ -248,7 +248,7 @@ processControlTGZ(const unsigned char * data, 0, sizeof(z_stream)); - strm.next_in = (char*) data; + strm.next_in = (Bytef*) data; strm.avail_in = size; strm.total_in = 0; strm.zalloc = &Emalloc; @@ -262,7 +262,7 @@ processControlTGZ(const unsigned char * data, inflateEnd(&strm); return prev; } - strm.next_out = buf; + strm.next_out = (Bytef*) buf; strm.avail_out = bufSize; inflate(&strm, Z_FINISH); @@ -328,7 +328,7 @@ libextractor_deb_extract(const char * filename, if (0 == strncmp(&hdr->name[0], "control.tar.gz", strlen("control.tar.gz"))) { - prev = processControlTGZ(&data[pos], + prev = processControlTGZ((const unsigned char*) &data[pos], fsize, prev); done++; diff --git a/src/plugins/dviextractor.c b/src/plugins/dviextractor.c @@ -50,7 +50,7 @@ static Matches tmap[] = { { NULL, 0 }, }; -static struct EXTRACTOR_Keywords * parseZZZ(unsigned char * data, +static struct EXTRACTOR_Keywords * parseZZZ(const char * data, size_t pos, size_t len, struct EXTRACTOR_Keywords * prev) { @@ -99,14 +99,14 @@ static struct EXTRACTOR_Keywords * parseZZZ(unsigned char * data, return prev; } -static unsigned int getIntAt(char * data) { +static unsigned int getIntAt(const void * data) { char p[4]; memcpy(p, data, 4); /* ensure alignment! */ return *(unsigned int*)&p[0]; } -static unsigned int getShortAt(char * data) { +static unsigned int getShortAt(const void * data) { char p[2]; memcpy(p, data, 2); /* ensure alignment! */ @@ -114,7 +114,7 @@ static unsigned int getShortAt(char * data) { } struct EXTRACTOR_Keywords * libextractor_dvi_extract(const char * filename, - unsigned char * data, + const unsigned char * data, size_t size, struct EXTRACTOR_Keywords * prev) { unsigned int klen; @@ -197,7 +197,7 @@ struct EXTRACTOR_Keywords * libextractor_dvi_extract(const char * filename, case 239: /* zzz1 */ len = data[pos+1]; if (pos + 2 + len < size) - prev = parseZZZ(data, + prev = parseZZZ((const char*) data, pos+2, len, prev); @@ -206,7 +206,7 @@ struct EXTRACTOR_Keywords * libextractor_dvi_extract(const char * filename, case 240: /* zzz2 */ len = ntohs(getShortAt(&data[pos+1])); if (pos + 3 + len < size) - prev = parseZZZ(data, + prev = parseZZZ((const char*) data, pos+3, len, prev); @@ -215,7 +215,7 @@ struct EXTRACTOR_Keywords * libextractor_dvi_extract(const char * filename, case 241: /* zzz3, who uses that? */ len = (ntohs(getShortAt(&data[pos+1]))) + 65536 * data[pos+3]; if (pos + 4 + len < size) - prev = parseZZZ(data, + prev = parseZZZ((const char*) data, pos+4, len, prev); @@ -224,7 +224,7 @@ struct EXTRACTOR_Keywords * libextractor_dvi_extract(const char * filename, case 242: /* zzz4, hurray! */ len = ntohl(getIntAt(&data[pos+1])); if (pos + 1 + len < size) - prev = parseZZZ(data, + prev = parseZZZ((const char*) data, pos+5, len, prev); diff --git a/src/plugins/id3v23extractor.c b/src/plugins/id3v23extractor.c @@ -160,7 +160,7 @@ libextractor_id3v23_extract(const char * filename, i = 0; while (tmap[i].text != NULL) { if (0 == strncmp(tmap[i].text, - &data[pos], + (const char*) &data[pos], 4)) { char * word; if ( (flags & 0x20) > 0) { @@ -174,19 +174,19 @@ libextractor_id3v23_extract(const char * filename, if it fails, then forget it */ switch (data[pos+10]) { case 0x00 : - word = convertToUtf8(&data[pos+11], + word = convertToUtf8((const char*) &data[pos+11], csize, "ISO-8859-1"); break; case 0x01 : - word = convertToUtf8(&data[pos+11], + word = convertToUtf8((const char*) &data[pos+11], csize, "UCS-2"); break; default: /* bad encoding byte, try to convert from iso-8859-1 */ - word = convertToUtf8(&data[pos+11], + word = convertToUtf8((const char*) &data[pos+11], csize, "ISO-8859-1"); break; diff --git a/src/plugins/id3v24extractor.c b/src/plugins/id3v24extractor.c @@ -36,9 +36,10 @@ #include "convert.h" -static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead, - char *phrase, - EXTRACTOR_KeywordType type) { +static struct EXTRACTOR_Keywords * +addKeyword(EXTRACTOR_KeywordList *oldhead, + char *phrase, + EXTRACTOR_KeywordType type) { EXTRACTOR_KeywordList * keyword; keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList)); @@ -157,7 +158,7 @@ libextractor_id3v24_extract(const char * filename, i = 0; while (tmap[i].text != NULL) { if (0 == strncmp(tmap[i].text, - &data[pos], + (const char*) &data[pos], 4)) { char * word; if ( (flags & 0x20) > 0) { @@ -171,17 +172,17 @@ libextractor_id3v24_extract(const char * filename, if it fails, then forget it */ switch (data[pos+10]) { case 0x00 : - word = convertToUtf8(&data[pos+11], + word = convertToUtf8((const char*) &data[pos+11], csize, "ISO-8859-1"); break; case 0x01 : - word = convertToUtf8(&data[pos+11], + word = convertToUtf8((const char*) &data[pos+11], csize, "UTF-16"); break; case 0x02 : - word = convertToUtf8(&data[pos+11], + word = convertToUtf8((const char*) &data[pos+11], csize, "UTF-16BE"); break; @@ -195,7 +196,7 @@ libextractor_id3v24_extract(const char * filename, default: /* bad encoding byte, try to convert from iso-8859-1 */ - word = convertToUtf8(&data[pos+11], + word = convertToUtf8((const char*) &data[pos+11], csize, "ISO-8859-1"); break; diff --git a/src/plugins/id3v2extractor.c b/src/plugins/id3v2extractor.c @@ -84,10 +84,11 @@ static Matches tmap[] = { /* mimetype = audio/mpeg */ -struct EXTRACTOR_Keywords * libextractor_id3v2_extract(char * filename, - unsigned char * data, - size_t size, - struct EXTRACTOR_Keywords * prev) { +struct EXTRACTOR_Keywords * +libextractor_id3v2_extract(const char * filename, + const unsigned char * data, + size_t size, + struct EXTRACTOR_Keywords * prev) { int unsync; unsigned int tsize; unsigned int pos; @@ -122,7 +123,7 @@ struct EXTRACTOR_Keywords * libextractor_id3v2_extract(char * filename, i = 0; while (tmap[i].text != NULL) { if (0 == strncmp(tmap[i].text, - &data[pos], + (const char*) &data[pos], 3)) { char * word; /* this byte describes the encoding @@ -130,19 +131,19 @@ struct EXTRACTOR_Keywords * libextractor_id3v2_extract(char * filename, if it fails, then forget it */ switch (data[pos+6]) { case 0x00: - word = convertToUtf8(&data[pos+7], + word = convertToUtf8((const char*) &data[pos+7], csize, "ISO-8859-1"); break; case 0x01: - word = convertToUtf8(&data[pos+7], + word = convertToUtf8((const char*) &data[pos+7], csize, "UCS-2"); break; default: /* bad encoding byte, try to convert from iso-8859-1 */ - word = convertToUtf8(&data[pos+7], + word = convertToUtf8((const char*) &data[pos+7], csize, "ISO-8859-1"); break; diff --git a/src/plugins/jpegextractor.c b/src/plugins/jpegextractor.c @@ -166,7 +166,7 @@ struct EXTRACTOR_Keywords * libextractor_jpeg_extract(const char * filename, int len = readLength(&data, end); if (len < 0x8) goto RETURN; - if (0 == strncmp(data, + if (0 == strncmp((char*)data, "JFIF", 4)) { char * val; diff --git a/src/plugins/manextractor.c b/src/plugins/manextractor.c @@ -116,11 +116,13 @@ libextractor_man_extract(const char * filename, if (0 == strncmp(".TH ", &buf[pos], xlen)) { - int end; + size_t end; pos += xlen; end = pos; - NEXT(&end, buf, size); if (end > size) return prev; + NEXT(&end, buf, size); + if (end > size) + return prev; if (end - pos > 0) { prev = addKeyword(EXTRACTOR_TITLE, stndup(&buf[pos], diff --git a/src/plugins/mp3extractor.c b/src/plugins/mp3extractor.c @@ -243,48 +243,56 @@ int freq_table[4][3]={ #define SYSERR 1 #define INVALID_ID3 2 -static int get_id3(unsigned char * data, +static int get_id3(const char * data, size_t size, id3tag * id3) { - unsigned char * pos; + const char * pos; if (size < 128) return INVALID_ID3; pos = &data[size - 128]; - if (0 != strncmp((const char *)"TAG",(const char *)pos, 3)) + if (0 != strncmp("TAG", + pos, + 3)) return INVALID_ID3; pos += 3; id3->title = convertToUtf8(pos, 30, - "ISO-8859-1"); pos += 30; + "ISO-8859-1"); + pos += 30; id3->artist = convertToUtf8(pos, 30, - "ISO-8859-1"); pos += 30; + "ISO-8859-1"); + pos += 30; id3->album = convertToUtf8(pos, 30, - "ISO-8859-1"); pos += 30; + "ISO-8859-1"); + pos += 30; id3->year = convertToUtf8(pos, 4, - "ISO-8859-1"); pos += 4; + "ISO-8859-1"); + pos += 4; id3->comment = convertToUtf8(pos, 30, - "ISO-8859-1"); pos += 30; + "ISO-8859-1"); + pos += 30; id3->genre = ""; if (pos[0] < GENRE_NAME_COUNT) - id3->genre = dgettext(PACKAGE, genre_names[pos[0]]); + id3->genre = dgettext(PACKAGE, + genre_names[(unsigned) pos[0]]); return OK; } static struct EXTRACTOR_Keywords * addkword(EXTRACTOR_KeywordList *oldhead, - char *phrase, + const char * phrase, EXTRACTOR_KeywordType type) { EXTRACTOR_KeywordList * keyword; - keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList)); + keyword = malloc(sizeof(EXTRACTOR_KeywordList)); keyword->next = oldhead; keyword->keyword = strdup(phrase); keyword->keywordType = type; @@ -294,7 +302,7 @@ addkword(EXTRACTOR_KeywordList *oldhead, static struct EXTRACTOR_Keywords * -mp3parse(char * data, +mp3parse(const char * data, size_t size, struct EXTRACTOR_Keywords * prev) { unsigned int header; @@ -436,7 +444,7 @@ mp3parse(char * data, /* mimetype = audio/mpeg */ struct EXTRACTOR_Keywords * libextractor_mp3_extract(const char * filename, - char * data, + const char * data, size_t size, struct EXTRACTOR_Keywords * klist) { id3tag info; diff --git a/src/plugins/ole2/ole2extractor.c b/src/plugins/ole2/ole2extractor.c @@ -150,18 +150,6 @@ gsf_input_read (GsfInput * mem, size_t num_bytes, unsigned char * optional_buffe } /** - * gsf_input_name : - * @input : - * - * Returns @input's name in utf8 form, DO NOT FREE THIS STRING - **/ -static const char * -gsf_input_name (GsfInput *input) -{ - return input->name; -} - -/** * gsf_input_size : * @input : The input * @@ -177,50 +165,6 @@ gsf_input_size (GsfInput *input) } /** - * gsf_input_eof : - * @input : the input - * - * Are we at the end of the file ? - * - * Returns : TRUE if the input is at the eof. - **/ -static int -gsf_input_eof (GsfInput *input) -{ - g_return_val_if_fail (input != NULL, 0); - - return input->cur_offset >= input->size; -} - -/** - * gsf_input_remaining : - * @input : - * - * Returns the number of bytes left in the file. - **/ -static off_t -gsf_input_remaining (GsfInput *input) -{ - g_return_val_if_fail (input != NULL, 0); - - return input->size - input->cur_offset; -} - -/** - * gsf_input_tell : - * @input : - * - * Returns the current offset in the file. - **/ -static off_t -gsf_input_tell (GsfInput *input) -{ - g_return_val_if_fail (input != NULL, 0); - - return input->cur_offset; -} - -/** * gsf_input_seek : * @input : * @offset : @@ -256,22 +200,6 @@ gsf_input_seek (GsfInput *input, off_t offset, int whence) return 0; } -/** - * gsf_input_set_size : - * @input : - * @size : - * - * Returns : TRUE if the assignment was ok. - */ -static int -gsf_input_set_size (GsfInput *input, off_t size) -{ - g_return_val_if_fail (input != NULL, 0); - - input->size = size; - return 1; -} - @@ -309,8 +237,6 @@ gsf_input_set_size (GsfInput *input, off_t size) #define GSF_LE_SET_GINT8(p,dat) GSF_LE_SET_GUINT8((p),(dat)) #define GSF_LE_SET_GINT16(p,dat) GSF_LE_SET_GUINT16((p),(dat)) #define GSF_LE_SET_GINT32(p,dat) GSF_LE_SET_GUINT32((p),(dat)) -#define GSF_LE_SET_FLOAT(p,dat) gsf_le_set_float((p),(dat)) -#define GSF_LE_SET_DOUBLE(p,dat) gsf_le_set_double((p),(dat)) /* @@ -394,36 +320,6 @@ gsf_le_get_float (void const *p) #endif } -static void -gsf_le_set_float (void *p, float d) -{ -#if G_FLOAT_BYTE_ORDER == G_BIG_ENDIAN - if (sizeof (float) == 4) { - int i; - guint8 *t = (guint8 *)&d; - guint8 *p2 = (guint8 *)p; - int sd = sizeof (d); - - for (i = 0; i < sd; i++) - p2[sd - 1 - i] = t[i]; - } else { - g_error ("Big endian machine, but weird size of floats"); - } -#elif (G_FLOAT_BYTE_ORDER == G_LITTLE_ENDIAN) || (G_FLOAT_BYTE_ORDER == G_ARMFLOAT_ENDIAN) - if (sizeof (float) == 4) { - /* - * On i86, we could access directly, but Alphas require - * aligned access. - */ - memcpy (p, &d, sizeof (d)); - } else { - g_error ("Little endian machine, but weird size of floats"); - } -#else -#error "Floating-point byte order not recognised -- out of luck" -#endif -} - static double gsf_le_get_double (void const *p) { @@ -464,64 +360,6 @@ gsf_le_get_double (void const *p) #endif } -static void -gsf_le_set_double (void *p, double d) -{ -#if G_FLOAT_BYTE_ORDER == G_ARMFLOAT_ENDIAN - memcpy (p, (const char *)&d + 4, 4); - memcpy ((char *)p + 4, &d, 4); -#elif G_FLOAT_BYTE_ORDER == G_BIG_ENDIAN - if (sizeof (double) == 8) { - int i; - guint8 *t = (guint8 *)&d; - guint8 *p2 = (guint8 *)p; - int sd = sizeof (d); - - for (i = 0; i < sd; i++) - p2[sd - 1 - i] = t[i]; - } else { - g_error ("Big endian machine, but weird size of doubles"); - } -#elif G_FLOAT_BYTE_ORDER == G_LITTLE_ENDIAN - if (sizeof (double) == 8) { - /* - * On i86, we could access directly, but Alphas require - * aligned access. - */ - memcpy (p, &d, sizeof (d)); - } else { - g_error ("Little endian machine, but weird size of doubles"); - } -#else -#error "Floating-point byte order not recognised -- out of luck" -#endif -} - -/** - * gsf_extension_pointer: - * @path: A filename or file path. - * - * Extracts the extension from the end of a filename (the part after the final - * '.' in the filename). - * - * Returns: A pointer to the extension part of the filename, or a - * pointer to the end of the string if the filename does not - * have an extension. - */ -static char const * -gsf_extension_pointer (char const *path) -{ - char *s, *t; - - g_return_val_if_fail (path != NULL, NULL); - - t = strrchr (path, G_DIR_SEPARATOR); - s = strrchr ((t != NULL) ? t : path, '.'); - if (s != NULL) - return s + 1; - return path + strlen(path); -} - /** * gsf_iconv_close : A utility wrapper to safely close an iconv handle * @handle : @@ -889,7 +727,7 @@ ole_dirent_new (GsfInfileMSOle *ole, guint32 entry, MSOleDirent *parent) * Sometimes, rarely, people store the stream name as ascii * rather than utf16. Do a validation first just in case. */ - if (!g_utf8_validate (data, -1, &end) || + if (!g_utf8_validate ((const char*) data, -1, &end) || ((guint8 const *)end - data + 1) != name_len) { /* be wary about endianness */ for (i = 0 ; i < name_len ; i += 2) @@ -1198,7 +1036,9 @@ gsf_infile_msole_read (GsfInfileMSOle *ole, size_t num_bytes, guint8 *buffer) return NULL; } ole->cur_block = last_block; - return gsf_input_read (ole->input, num_bytes, buffer); + return gsf_input_read (ole->input, + num_bytes, + (unsigned char*) buffer); } /* damn, we need to copy it block by block */ @@ -1246,9 +1086,9 @@ gsf_infile_msole_new_child (GsfInfileMSOle *parent, (dirent->is_directory) ) { /* be wary. It seems as if some implementations pretend that the * directories contain data */ - return gsf_input_new("", - (off_t) 0, - 0); + return gsf_input_new((const unsigned char*) "", + (off_t) 0, + 0); } child = ole_dup (parent); if (child == NULL) @@ -1300,12 +1140,12 @@ gsf_infile_msole_new_child (GsfInfileMSOle *parent, } if (NULL == gsf_infile_msole_read(child, child->size, - buf)) { + (guint8*) buf)) { gsf_infile_msole_finalize(child); return NULL; } gsf_infile_msole_finalize(child); - return gsf_input_new(buf, + return gsf_input_new((const unsigned char*) buf, (off_t) dirent->size, 1); } @@ -1622,7 +1462,6 @@ msole_prop_parse(GsfMSOleMetaDataSection *section, GValue *res; char *str; guint32 len; - gsize gslen; gboolean const is_vector = type & LE_VT_VECTOR; GError * error; @@ -1773,7 +1612,7 @@ msole_prop_parse(GsfMSOleMetaDataSection *section, error = NULL; d (gsf_mem_dump (*data + 4, len * section->char_size);); - str = g_convert_with_iconv (*data + 4, + str = g_convert_with_iconv ((char*) *data + 4, len * section->char_size, section->iconv_handle, NULL, NULL, &error); @@ -1807,8 +1646,13 @@ msole_prop_parse(GsfMSOleMetaDataSection *section, error = NULL; d (gsf_mem_dump (*data + 4, len*2);); - str = g_convert (*data + 4, len*2, - "UTF-8", "UTF-16LE", NULL, NULL, &error); + str = g_convert ((char*) *data + 4, + len*2, + "UTF-8", + "UTF-16LE", + NULL, + NULL, + &error); g_value_init (res, G_TYPE_STRING); if (NULL != str) { @@ -1959,7 +1803,7 @@ msole_prop_read (struct GsfInput *in, g_return_val_if_fail (len < 0x10000, NULL); gslen = 0; - name = g_convert_with_iconv (data + 8, + name = g_convert_with_iconv ((char*) data + 8, len * section->char_size, section->iconv_handle, &gslen, NULL, NULL); @@ -2268,7 +2112,7 @@ static struct EXTRACTOR_Keywords * processSO(struct GsfInput * src, if (size < 0x374) /* == 0x375?? */ return prev; buf = malloc(size); - gsf_input_read(src, size, buf); + gsf_input_read(src, size, (unsigned char*) buf); if ( (buf[0] != 0x0F) || (buf[1] != 0x0) || (0 != strncmp(&buf[2], @@ -2309,7 +2153,7 @@ static struct EXTRACTOR_Keywords * processSO(struct GsfInput * src, struct EXTRACTOR_Keywords * libextractor_ole2_extract(const char * filename, - char * date, + const char * date, size_t size, struct EXTRACTOR_Keywords * prev) { struct GsfInput *input; diff --git a/src/plugins/pngextractor.c b/src/plugins/pngextractor.c @@ -60,7 +60,7 @@ static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordType type, return result; } -static int getIntAt(const char * pos) { +static int getIntAt(const void * pos) { char p[4]; memcpy(p, pos, 4); /* ensure alignment! */ @@ -86,7 +86,7 @@ static struct { { NULL, EXTRACTOR_UNKNOWN}, }; -static struct EXTRACTOR_Keywords * processtEXt(const unsigned char * data, +static struct EXTRACTOR_Keywords * processtEXt(const char * data, unsigned int length, struct EXTRACTOR_Keywords * prev) { char * keyword; @@ -114,7 +114,7 @@ static struct EXTRACTOR_Keywords * processtEXt(const unsigned char * data, prev); } -static struct EXTRACTOR_Keywords * processiTXt(const unsigned char * data, +static struct EXTRACTOR_Keywords * processiTXt(const char * data, unsigned int length, struct EXTRACTOR_Keywords * prev) { unsigned int pos; @@ -165,9 +165,9 @@ static struct EXTRACTOR_Keywords * processiTXt(const unsigned char * data, /* printf("out of memory"); */ return prev; /* out of memory */ } - ret = uncompress(buf, + ret = uncompress((Bytef*) buf, &bufLen, - &data[pos], + (const Bytef*) &data[pos], length - pos); if (ret == Z_OK) { /* printf("zlib ok"); */ @@ -196,7 +196,7 @@ static struct EXTRACTOR_Keywords * processiTXt(const unsigned char * data, prev); } -static struct EXTRACTOR_Keywords * processIHDR(const unsigned char * data, +static struct EXTRACTOR_Keywords * processIHDR(const char * data, unsigned int length, struct EXTRACTOR_Keywords * prev) { char * tmp; @@ -216,7 +216,7 @@ static struct EXTRACTOR_Keywords * processIHDR(const unsigned char * data, } /* not supported... */ -static struct EXTRACTOR_Keywords * processzTXt(const unsigned char * data, +static struct EXTRACTOR_Keywords * processzTXt(const char * data, unsigned int length, struct EXTRACTOR_Keywords * prev) { char * keyword; @@ -248,9 +248,9 @@ static struct EXTRACTOR_Keywords * processzTXt(const unsigned char * data, /* printf("out of memory"); */ return prev; /* out of memory */ } - ret = uncompress(buf, + ret = uncompress((Bytef*) buf, &bufLen, - &data[off], + (const Bytef*) &data[off], length - off); if (ret == Z_OK) { /* printf("zlib ok"); */ @@ -283,11 +283,11 @@ static struct EXTRACTOR_Keywords * processzTXt(const unsigned char * data, struct EXTRACTOR_Keywords * libextractor_png_extract(char * filename, - const unsigned char * data, + const char * data, size_t size, struct EXTRACTOR_Keywords * prev) { - const unsigned char * pos; - const unsigned char * end; + const char * pos; + const char * end; struct EXTRACTOR_Keywords * result; unsigned int length; diff --git a/src/plugins/printable/bloomfilter.h b/src/plugins/printable/bloomfilter.h @@ -30,7 +30,7 @@ #include "bloomfilter-def.h" typedef struct { - char data[20]; + unsigned char data[20]; } HashCode160; struct sha1_context @@ -269,7 +269,8 @@ static unsigned char sha1_padding[64] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -static void sha1_finish( struct sha1_context *ctx, unsigned char digest[20] ) +static void sha1_finish(struct sha1_context *ctx, + unsigned char digest[20] ) { unsigned int last, padn; unsigned char msglen[8]; @@ -291,7 +292,7 @@ static void sha1_finish( struct sha1_context *ctx, unsigned char digest[20] ) } void static hash(const void * data, - int size, + unsigned int size, HashCode160 * hc) { struct sha1_context ctx; diff --git a/src/plugins/qtextractor.c b/src/plugins/qtextractor.c @@ -205,7 +205,7 @@ typedef struct { } time_to_sample_table_t; typedef struct { - unsigned char *url; + char *url; int64_t data_rate; int qtim_version; } reference_t; @@ -1237,14 +1237,13 @@ static qt_error parse_reference_atom (reference_t *ref, break; current_atom = BE_32(&ref_atom[i]); - if (current_atom == RDRF_ATOM) { - + if (current_atom == RDRF_ATOM) { /* if the URL starts with "http://", copy it */ - if (strncmp(&ref_atom[i + 12], "http://", 7) == 0) { + if (strncmp((char*) &ref_atom[i + 12], "http://", 7) == 0) { /* URL is spec'd to terminate with a NULL; don't trust it */ - ref->url = malloc(BE_32(&ref_atom[i + 12]) + 1); - strncpy(ref->url, &ref_atom[i + 16], BE_32(&ref_atom[i + 12])); + ref->url = malloc(BE_32((char*) &ref_atom[i + 12]) + 1); + strncpy(ref->url, (char*) &ref_atom[i + 16], BE_32(&ref_atom[i + 12])); ref->url[BE_32(&ref_atom[i + 12]) - 1] = '\0'; } else { @@ -1253,7 +1252,7 @@ static qt_error parse_reference_atom (reference_t *ref, /* otherwise, append relative URL to base MRL */ ref->url = malloc(string_size); - strncpy(ref->url, &ref_atom[i + 16], BE_32(&ref_atom[i + 12])); + strncpy(ref->url, (char*) &ref_atom[i + 16], BE_32(&ref_atom[i + 12])); ref->url[string_size - 1] = '\0'; } @@ -1290,11 +1289,12 @@ static qt_error parse_reference_atom (reference_t *ref, /* This is a little support function used to process the edit list when * building a frame table. */ #define MAX_DURATION 0x7FFFFFFF -static void get_next_edit_list_entry(qt_trak *trak, - int *edit_list_index, - unsigned int *edit_list_media_time, - int64_t *edit_list_duration, - unsigned int global_timescale) { +static void +get_next_edit_list_entry(qt_trak *trak, + unsigned int *edit_list_index, + unsigned int *edit_list_media_time, + int64_t *edit_list_duration, + unsigned int global_timescale) { /* if there is no edit list, set to max duration and get out */ if (!trak->edit_list_table) { @@ -1439,8 +1439,11 @@ static qt_error build_frame_table(qt_trak *trak, /* initialize edit list considerations */ edit_list_index = 0; - get_next_edit_list_entry(trak, &edit_list_index, - &edit_list_media_time, &edit_list_duration, global_timescale); + get_next_edit_list_entry(trak, + &edit_list_index, + &edit_list_media_time, + &edit_list_duration, + global_timescale); /* fix up pts information w.r.t. the edit list table */ edit_list_pts_counter = 0; @@ -1588,28 +1591,36 @@ static void parse_moov_atom(qt_info *info, unsigned char *moov_atom) { string_size = BE_16(&moov_atom[i + 4]) + 1; info->copyright = realloc (info->copyright, string_size); - strncpy(info->copyright, &moov_atom[i + 8], string_size - 1); + strncpy(info->copyright, + (char*) &moov_atom[i + 8], + string_size - 1); info->copyright[string_size - 1] = 0; } else if (current_atom == NAM_ATOM) { string_size = BE_16(&moov_atom[i + 4]) + 1; info->name = realloc (info->name, string_size); - strncpy(info->name, &moov_atom[i + 8], string_size - 1); + strncpy(info->name, + (char*) &moov_atom[i + 8], + string_size - 1); info->name[string_size - 1] = 0; } else if (current_atom == DES_ATOM) { string_size = BE_16(&moov_atom[i + 4]) + 1; info->description = realloc (info->description, string_size); - strncpy(info->description, &moov_atom[i + 8], string_size - 1); + strncpy(info->description, + (char*) &moov_atom[i + 8], + string_size - 1); info->description[string_size - 1] = 0; } else if (current_atom == CMT_ATOM) { string_size = BE_16(&moov_atom[i + 4]) + 1; info->comment = realloc (info->comment, string_size); - strncpy(info->comment, &moov_atom[i + 8], string_size - 1); + strncpy(info->comment, + (char*) &moov_atom[i + 8], + string_size - 1); info->comment[string_size - 1] = 0; } else if (current_atom == RMDA_ATOM) { diff --git a/src/plugins/realextractor.c b/src/plugins/realextractor.c @@ -294,22 +294,22 @@ struct EXTRACTOR_Keywords * libextractor_real_extract(unsigned char * filename, if (tlen > 0) prev = addKeyword(EXTRACTOR_TITLE, - stndup(&data[17 + RAFF4_HDR_SIZE], + stndup((const char*) &data[17 + RAFF4_HDR_SIZE], tlen), prev); if (alen > 0) prev = addKeyword(EXTRACTOR_AUTHOR, - stndup(&data[18 + RAFF4_HDR_SIZE + tlen], + stndup((const char*) &data[18 + RAFF4_HDR_SIZE + tlen], alen), prev); if (clen > 0) prev = addKeyword(EXTRACTOR_COPYRIGHT, - stndup(&data[19 + RAFF4_HDR_SIZE + tlen + alen], + stndup((const char*) &data[19 + RAFF4_HDR_SIZE + tlen + alen], clen), prev); if (aplen > 0) prev = addKeyword(EXTRACTOR_SOFTWARE, - stndup(&data[20 + RAFF4_HDR_SIZE + tlen + alen + clen], + stndup((const char*) &data[20 + RAFF4_HDR_SIZE + tlen + alen + clen], aplen), prev); return prev; diff --git a/src/plugins/thumbnail/Makefile.am b/src/plugins/thumbnail/Makefile.am @@ -3,10 +3,10 @@ include ../Makefile-plugins.am plugin_LTLIBRARIES = \ libextractor_thumbnail.la -AM_CFLAGS = $(GLIB_CFLAGS) +AM_CFLAGS = $(GLIB_CFLAGS) $(GTK_CFLAGS) libextractor_thumbnail_la_CFLAGS = \ - $(GLIB_CFLAGS) + $(GLIB_CFLAGS) $(GTK_CFLAGS) libextractor_thumbnail_la_LIBADD = \ $(LIBADD) -lgobject-2.0 @GTK_LIBS@ \ $(top_builddir)/src/main/libextractor.la diff --git a/src/plugins/thumbnail/thumbnailextractor.c b/src/plugins/thumbnail/thumbnailextractor.c @@ -76,7 +76,7 @@ static char * whitelist[] = { }; struct EXTRACTOR_Keywords * libextractor_thumbnail_extract(const char * filename, - const char * data, + const unsigned char * data, size_t size, struct EXTRACTOR_Keywords * prev) { GdkPixbufLoader * loader; @@ -169,7 +169,7 @@ struct EXTRACTOR_Keywords * libextractor_thumbnail_extract(const char * filename return prev; binary - = EXTRACTOR_binaryEncode(thumb, + = EXTRACTOR_binaryEncode((const unsigned char*) thumb, length); free(thumb); if (binary == NULL) diff --git a/src/plugins/translitextractor.c b/src/plugins/translitextractor.c @@ -547,18 +547,19 @@ static void addKeyword(struct EXTRACTOR_Keywords ** list, *list = next; } -struct EXTRACTOR_Keywords * libextractor_translit_extract(char * filename, - char * data, - size_t size, - struct EXTRACTOR_Keywords * prev) { +struct EXTRACTOR_Keywords * +libextractor_translit_extract(const char * filename, + const char * data, + size_t size, + struct EXTRACTOR_Keywords * prev) { struct EXTRACTOR_Keywords * pos; unsigned int mem, src, dest, len; - unsigned char *transl; + char * transl; pos = prev; mem = 256; - transl = (char *) malloc(mem + 1); + transl = malloc(mem + 1); while (pos != NULL) diff --git a/src/plugins/zipextractor.c b/src/plugins/zipextractor.c @@ -80,15 +80,16 @@ typedef struct { /* mimetype = application/zip */ -struct EXTRACTOR_Keywords * libextractor_zip_extract(char * filename, - char * data, - size_t size, - struct EXTRACTOR_Keywords * prev) { +struct EXTRACTOR_Keywords * +libextractor_zip_extract(const char * filename, + const char * data, + size_t size, + struct EXTRACTOR_Keywords * prev) { void * tmp; zip_entry * info; zip_entry * start; char *filecomment = NULL; - unsigned char * pos; + const char * pos; unsigned int offset, stop; unsigned int name_length, extra_length, comment_length; unsigned int filecomment_length;