commit f22abb4d1339fe55f5c10545de4b80fe3ac6aebe
parent 0f3f4f01cce39f83f029caa4c285035c409c0ced
Author: Christian Grothoff <christian@grothoff.org>
Date: Tue, 3 Mar 2020 12:55:36 +0100
uncrustifying indentation
Diffstat:
129 files changed, 16203 insertions(+), 15146 deletions(-)
diff --git a/bootstrap b/bootstrap
@@ -1,4 +1,34 @@
#!/bin/sh
-# This file is in the public domain.
-rm -rf libltdl
-autoreconf -if
+unset bs_srcdir
+if test X"`dirname / 2>/dev/null`" = X"/"; then
+ bs_scrdir=`dirname $0`
+else
+ bs_scrdir="${0%/*}"
+fi
+
+test -n "$bs_scrdir" && cd "$bs_scrdir" || echo "Warning: cannot get sources directory" 1>&2
+
+# This is more portable than `which' but comes with
+# the caveat of not(?) properly working on busybox's ash:
+existence()
+{
+ command -v "$1" >/dev/null 2>&1
+}
+
+
+if existence uncrustify; then
+ echo "Installing uncrustify hook and configuration"
+ # Install uncrustify format symlink (if possible)
+ ln -s contrib/uncrustify.cfg uncrustify.cfg 2> /dev/null
+ # Install pre-commit hook (if possible)
+ ln -s ../../contrib/uncrustify_precommit .git/hooks/pre-commit 2> /dev/null
+else
+ echo "Uncrustify not detected, hook not installed. Please install uncrustify if you plan on doing development"
+fi
+
+if existence libtool || existence libtoolize || existence glibtoolize || existence slibtool; then
+ autoreconf -I m4 -i ${1+"$@"}
+else
+ echo "*** No libtoolize (libtool) or libtool found, please install it ***" >&2;
+ exit 1
+fi
diff --git a/contrib/uncrustify.cfg b/contrib/uncrustify.cfg
@@ -0,0 +1,95 @@
+input_tab_size = 2
+output_tab_size = 2
+
+indent_columns = 2
+indent_with_tabs = 0
+indent_case_brace = 2
+indent_label=-16
+
+code_width=80
+#cmd_width=80
+
+# Leave most comments alone for now
+cmt_indent_multi=false
+sp_cmt_cpp_start=add
+
+sp_not=add
+
+sp_func_call_user_paren_paren=remove
+sp_inside_fparen=remove
+sp_after_cast=add
+
+ls_for_split_full=true
+ls_func_split_full=true
+ls_code_width=true
+
+# Arithmetic operations in wrapped expressions should be at the start
+# of the line.
+pos_arith=lead
+
+# Fully parenthesize boolean exprs
+mod_full_paren_if_bool=true
+
+# Braces should be on their own line
+nl_fdef_brace=add
+nl_enum_brace=add
+nl_struct_brace=add
+nl_union_brace=add
+nl_if_brace=add
+nl_brace_else=add
+nl_elseif_brace=add
+nl_while_brace=add
+nl_switch_brace=add
+
+# no newline between "else" and "if"
+nl_else_if=remove
+
+nl_func_paren=remove
+nl_assign_brace=remove
+
+# No extra newlines that cause noisy diffs
+nl_start_of_file=remove
+nl_after_func_proto = 2
+nl_after_func_body = 3
+# If there's no new line, it's not a text file!
+nl_end_of_file=add
+nl_max_blank_in_func = 3
+nl_max = 3
+
+sp_inside_paren = remove
+
+sp_arith = add
+sp_arith_additive = add
+
+# We want spaces before and after "="
+sp_before_assign = add
+sp_after_assign = add
+
+# we want "char *foo;"
+sp_after_ptr_star = remove
+sp_between_ptr_star = remove
+
+# we want "if (foo) { ... }"
+sp_before_sparen = add
+
+sp_inside_fparen = remove
+sp_inside_sparen = remove
+
+# add space before function call and decl: "foo (x)"
+sp_func_call_paren = add
+sp_func_proto_paren = add
+sp_func_proto_paren_empty = add
+sp_func_def_paren = add
+sp_func_def_paren_empty = add
+
+# We'd want it for "if ( (foo) || (bar) )", but not for "if (m())",
+# so as uncrustify doesn't give exactly what we want => ignore
+sp_paren_paren = ignore
+sp_inside_paren = remove
+sp_bool = force
+
+nl_func_type_name = force
+#nl_branch_else = add
+nl_else_brace = add
+nl_elseif_brace = add
+nl_for_brace = add
diff --git a/contrib/uncrustify.sh b/contrib/uncrustify.sh
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+
+set -eu
+
+DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
+
+if ! uncrustify --version >/dev/null; then
+ echo "you need to install uncrustify for indentation"
+ exit 1
+fi
+
+find "$DIR/../src" \( -name "*.cpp" -o -name "*.c" -o -name "*.h" \) \
+ -exec uncrustify -c "$DIR/uncrustify.cfg" --replace --no-backup {} + \
+ || true
diff --git a/contrib/uncrustify_precommit b/contrib/uncrustify_precommit
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# use as .git/hooks/pre-commit
+
+exec 1>&2
+
+RET=0
+changed=$(git diff --cached --name-only)
+crustified=""
+
+for f in $changed;
+do
+ if echo $f | grep \\.[c,h]\$ > /dev/null
+ then
+ # compare result of uncrustify with changes
+ #
+ # only change any of the invocations here if
+ # they are portable across all cmp and shell
+ # implementations !
+ uncrustify -q -c uncrustify.cfg -f $f | cmp -s $f -
+ if test $? = 1 ;
+ then
+ crustified=" $crustified $f"
+ RET=1
+ fi
+ fi
+done
+
+if [ $RET = 1 ];
+then
+ echo "Run"
+ echo "uncrustify --no-backup -c uncrustify.cfg ${crustified}"
+ echo "before commiting."
+fi
+exit $RET
diff --git a/src/common/convert.c b/src/common/convert.c
@@ -37,8 +37,8 @@
*/
char *
EXTRACTOR_common_convert_to_utf8 (const char *input,
- size_t len,
- const char *charset)
+ size_t len,
+ const char *charset)
{
#if HAVE_ICONV
size_t tmpSize;
@@ -51,35 +51,35 @@ EXTRACTOR_common_convert_to_utf8 (const char *input,
i = input;
cd = iconv_open ("UTF-8", charset);
- if (cd == (iconv_t) - 1)
+ if (cd == (iconv_t) -1)
return strndup (i, len);
if (len > 1024 * 1024)
- {
- iconv_close (cd);
- return NULL; /* too big for meta data */
- }
+ {
+ iconv_close (cd);
+ return NULL; /* too big for meta data */
+ }
tmpSize = 3 * len + 4;
tmp = malloc (tmpSize);
if (tmp == NULL)
- {
- iconv_close (cd);
- return NULL;
- }
+ {
+ iconv_close (cd);
+ return NULL;
+ }
itmp = tmp;
finSize = tmpSize;
if (iconv (cd, (char **) &input, &len, &itmp, &finSize) == ((size_t) -1))
- {
- iconv_close (cd);
- free (tmp);
- return strndup (i, len);
- }
+ {
+ iconv_close (cd);
+ free (tmp);
+ return strndup (i, len);
+ }
ret = malloc (tmpSize - finSize + 1);
if (ret == NULL)
- {
- iconv_close (cd);
- free (tmp);
- return NULL;
- }
+ {
+ iconv_close (cd);
+ free (tmp);
+ return NULL;
+ }
memcpy (ret, tmp, tmpSize - finSize);
ret[tmpSize - finSize] = '\0';
free (tmp);
@@ -95,4 +95,5 @@ EXTRACTOR_common_convert_to_utf8 (const char *input,
#endif
}
+
/* end of convert.c */
diff --git a/src/common/convert.h b/src/common/convert.h
@@ -38,10 +38,10 @@ extern "C" {
* @param charset input character set
* @return the converted string (0-terminated), NULL on error
*/
-char *
-EXTRACTOR_common_convert_to_utf8 (const char * input,
- size_t len,
- const char *charset);
+char *
+EXTRACTOR_common_convert_to_utf8 (const char *input,
+ size_t len,
+ const char *charset);
#ifdef __cplusplus
}
diff --git a/src/common/le_architecture.h b/src/common/le_architecture.h
@@ -108,13 +108,13 @@
* gcc 4.x-ism to pack structures even on W32 (to be used before structs)
*/
#define LE_NETWORK_STRUCT_BEGIN \
- _Pragma("pack(push)") \
- _Pragma("pack(1)")
+ _Pragma ("pack(push)") \
+ _Pragma ("pack(1)")
/**
* gcc 4.x-ism to pack structures even on W32 (to be used after structs)
*/
-#define LE_NETWORK_STRUCT_END _Pragma("pack(pop)")
+#define LE_NETWORK_STRUCT_END _Pragma ("pack(pop)")
#else
#error gcc 4.x or higher required on W32 systems
#endif
@@ -122,7 +122,7 @@
/**
* Good luck, LE_PACKED should suffice, but this won't work on W32
*/
-#define LE_NETWORK_STRUCT_BEGIN
+#define LE_NETWORK_STRUCT_BEGIN
/**
* Good luck, LE_PACKED should suffice, but this won't work on W32
diff --git a/src/common/unzip.c b/src/common/unzip.c
@@ -87,7 +87,7 @@ struct FileFuncDefs
/**
* Callback for reading 'size' bytes from the ZIP archive into buf.
*/
- uLong (*zread_file) (voidpf opaque, void* buf, uLong size);
+ uLong (*zread_file) (voidpf opaque, void*buf, uLong size);
/**
* Callback to obtain the current read offset in the ZIP archive.
@@ -114,7 +114,8 @@ struct FileFuncDefs
* @param size number of bytes to read
* @return number of bytes copied to buf
*/
-#define ZREAD(filefunc,buf,size) ((*((filefunc).zread_file)) ((filefunc).opaque, buf, size))
+#define ZREAD(filefunc,buf,size) ((*((filefunc).zread_file))((filefunc).opaque, \
+ buf, size))
/**
* Macro to obtain current offset in file using filefunc API.
@@ -122,7 +123,7 @@ struct FileFuncDefs
* @param filefunc filefunc struct
* @return current offset in file
*/
-#define ZTELL(filefunc) ((*((filefunc).ztell_file)) ((filefunc).opaque))
+#define ZTELL(filefunc) ((*((filefunc).ztell_file))((filefunc).opaque))
/**
* Macro to seek using filefunc API.
@@ -132,7 +133,8 @@ struct FileFuncDefs
* @param mode seek mode
* @return 0 on success
*/
-#define ZSEEK(filefunc,pos,mode) ((*((filefunc).zseek_file)) ((filefunc).opaque, pos, mode))
+#define ZSEEK(filefunc,pos,mode) ((*((filefunc).zseek_file))((filefunc).opaque, \
+ pos, mode))
/**
@@ -208,7 +210,7 @@ struct FileInZipReadInfo
/**
* size of the local extra field
*/
- uInt size_local_extrafield;
+ uInt size_local_extrafield;
/**
* position in the local extra field in read
@@ -337,7 +339,7 @@ struct EXTRACTOR_UnzipFile
*/
static int
read_byte_from_ffd (const struct FileFuncDefs *ffd,
- int *pi)
+ int *pi)
{
unsigned char c;
@@ -359,7 +361,7 @@ read_byte_from_ffd (const struct FileFuncDefs *ffd,
*/
static int
read_short_from_ffd (const struct FileFuncDefs *ffd,
- uLong *pX)
+ uLong *pX)
{
uLong x;
int i;
@@ -388,7 +390,7 @@ read_short_from_ffd (const struct FileFuncDefs *ffd,
*/
static int
read_long_from_ffd (const struct FileFuncDefs *ffd,
- uLong *pX)
+ uLong *pX)
{
uLong x;
int i;
@@ -413,7 +415,7 @@ read_long_from_ffd (const struct FileFuncDefs *ffd,
#ifndef CASESENSITIVITYDEFAULT_NO
-#if !defined(unix) && !defined(CASESENSITIVITYDEFAULT_YES)
+#if ! defined(unix) && ! defined(CASESENSITIVITYDEFAULT_YES)
#define CASESENSITIVITYDEFAULT_NO
#endif
#endif
@@ -436,14 +438,14 @@ read_long_from_ffd (const struct FileFuncDefs *ffd,
* @return 0 if names are equal
*/
static int
-EXTRACTOR_common_unzip_string_file_name_compare (const char* fileName1,
- const char* fileName2,
- int iCaseSensitivity)
+EXTRACTOR_common_unzip_string_file_name_compare (const char*fileName1,
+ const char*fileName2,
+ int iCaseSensitivity)
{
if (0 == iCaseSensitivity)
iCaseSensitivity = CASESENSITIVITYDEFAULTVALUE;
if (1 == iCaseSensitivity)
- return strcmp(fileName1, fileName2);
+ return strcmp (fileName1, fileName2);
return strcasecmp (fileName1, fileName2);
}
@@ -474,31 +476,31 @@ locate_central_directory (const struct FileFuncDefs *ffd)
uMaxBack = uSizeFile;
uBackRead = 4;
while (uBackRead < uMaxBack)
- {
- uLong uReadSize;
- uLong uReadPos;
- int i;
-
- if (uBackRead + BUFREADCOMMENT > uMaxBack)
- uBackRead = uMaxBack;
- else
- uBackRead += BUFREADCOMMENT;
- uReadPos = uSizeFile - uBackRead;
- uReadSize = ((BUFREADCOMMENT + 4) < (uSizeFile - uReadPos))
- ? (BUFREADCOMMENT + 4)
- : (uSizeFile - uReadPos);
- if (0 != ZSEEK (*ffd, uReadPos, SEEK_SET))
- break;
- if (ZREAD (*ffd, buf, uReadSize) != uReadSize)
- break;
- i = (int) uReadSize - 3;
- while (i-- > 0)
- if ( (0x50 == (*(buf+i))) &&
- (0x4b == (*(buf+i+1))) &&
- (0x05 == (*(buf+i+2))) &&
- (0x06 == (*(buf+i+3))) )
- return uReadPos + i;
- }
+ {
+ uLong uReadSize;
+ uLong uReadPos;
+ int i;
+
+ if (uBackRead + BUFREADCOMMENT > uMaxBack)
+ uBackRead = uMaxBack;
+ else
+ uBackRead += BUFREADCOMMENT;
+ uReadPos = uSizeFile - uBackRead;
+ uReadSize = ((BUFREADCOMMENT + 4) < (uSizeFile - uReadPos))
+ ? (BUFREADCOMMENT + 4)
+ : (uSizeFile - uReadPos);
+ if (0 != ZSEEK (*ffd, uReadPos, SEEK_SET))
+ break;
+ if (ZREAD (*ffd, buf, uReadSize) != uReadSize)
+ break;
+ i = (int) uReadSize - 3;
+ while (i-- > 0)
+ if ( (0x50 == (*(buf + i))) &&
+ (0x4b == (*(buf + i + 1))) &&
+ (0x05 == (*(buf + i + 2))) &&
+ (0x06 == (*(buf + i + 3))) )
+ return uReadPos + i;
+ }
return 0;
}
@@ -512,7 +514,7 @@ locate_central_directory (const struct FileFuncDefs *ffd)
*/
static void
dos_date_to_tmu_date (uLong ulDosDate,
- struct EXTRACTOR_UnzipDateTimeInfo* ptm)
+ struct EXTRACTOR_UnzipDateTimeInfo*ptm)
{
uLong uDate;
@@ -543,14 +545,14 @@ dos_date_to_tmu_date (uLong ulDosDate,
*/
static int
get_current_file_info (struct EXTRACTOR_UnzipFile *file,
- struct EXTRACTOR_UnzipFileInfo *pfile_info,
- struct UnzipFileInfoInternal *pfile_info_internal,
- char *szFileName,
- uLong fileNameBufferSize,
- void *extraField,
- uLong extraFieldBufferSize,
- char *szComment,
- uLong commentBufferSize)
+ struct EXTRACTOR_UnzipFileInfo *pfile_info,
+ struct UnzipFileInfoInternal *pfile_info_internal,
+ char *szFileName,
+ uLong fileNameBufferSize,
+ void *extraField,
+ uLong extraFieldBufferSize,
+ char *szComment,
+ uLong commentBufferSize)
{
struct EXTRACTOR_UnzipFileInfo file_info;
struct UnzipFileInfoInternal file_info_internal;
@@ -560,128 +562,130 @@ get_current_file_info (struct EXTRACTOR_UnzipFile *file,
if (NULL == file)
return EXTRACTOR_UNZIP_PARAMERROR;
if (0 != ZSEEK (file->z_filefunc,
- file->pos_in_central_dir + file->byte_before_the_zipfile,
- SEEK_SET))
+ file->pos_in_central_dir + file->byte_before_the_zipfile,
+ SEEK_SET))
return EXTRACTOR_UNZIP_ERRNO;
/* we check the magic */
if (EXTRACTOR_UNZIP_OK !=
- read_long_from_ffd(&file->z_filefunc, &uMagic))
+ read_long_from_ffd (&file->z_filefunc, &uMagic))
return EXTRACTOR_UNZIP_ERRNO;
if (0x02014b50 != uMagic)
return EXTRACTOR_UNZIP_BADZIPFILE;
if ( (EXTRACTOR_UNZIP_OK !=
- read_short_from_ffd (&file->z_filefunc, &file_info.version)) ||
+ read_short_from_ffd (&file->z_filefunc, &file_info.version)) ||
(EXTRACTOR_UNZIP_OK !=
- read_short_from_ffd (&file->z_filefunc, &file_info.version_needed)) ||
+ read_short_from_ffd (&file->z_filefunc, &file_info.version_needed)) ||
(EXTRACTOR_UNZIP_OK !=
- read_short_from_ffd (&file->z_filefunc, &file_info.flag)) ||
+ read_short_from_ffd (&file->z_filefunc, &file_info.flag)) ||
(EXTRACTOR_UNZIP_OK !=
- read_short_from_ffd (&file->z_filefunc, &file_info.compression_method)) ||
+ read_short_from_ffd (&file->z_filefunc,
+ &file_info.compression_method)) ||
(EXTRACTOR_UNZIP_OK !=
- read_long_from_ffd (&file->z_filefunc, &file_info.dosDate)) )
+ read_long_from_ffd (&file->z_filefunc, &file_info.dosDate)) )
return EXTRACTOR_UNZIP_ERRNO;
dos_date_to_tmu_date (file_info.dosDate,
- &file_info.tmu_date);
+ &file_info.tmu_date);
if ( (EXTRACTOR_UNZIP_OK !=
- read_long_from_ffd(&file->z_filefunc, &file_info.crc)) ||
+ read_long_from_ffd (&file->z_filefunc, &file_info.crc)) ||
(EXTRACTOR_UNZIP_OK !=
- read_long_from_ffd(&file->z_filefunc, &file_info.compressed_size)) ||
+ read_long_from_ffd (&file->z_filefunc, &file_info.compressed_size)) ||
(EXTRACTOR_UNZIP_OK !=
- read_long_from_ffd(&file->z_filefunc, &file_info.uncompressed_size)) ||
+ read_long_from_ffd (&file->z_filefunc, &file_info.uncompressed_size)) ||
(EXTRACTOR_UNZIP_OK !=
- read_short_from_ffd(&file->z_filefunc, &file_info.size_filename)) ||
+ read_short_from_ffd (&file->z_filefunc, &file_info.size_filename)) ||
(EXTRACTOR_UNZIP_OK !=
- read_short_from_ffd(&file->z_filefunc, &file_info.size_file_extra)) ||
+ read_short_from_ffd (&file->z_filefunc, &file_info.size_file_extra)) ||
(EXTRACTOR_UNZIP_OK !=
- read_short_from_ffd(&file->z_filefunc, &file_info.size_file_comment)) ||
+ read_short_from_ffd (&file->z_filefunc,
+ &file_info.size_file_comment)) ||
(EXTRACTOR_UNZIP_OK !=
- read_short_from_ffd(&file->z_filefunc, &file_info.disk_num_start)) ||
+ read_short_from_ffd (&file->z_filefunc, &file_info.disk_num_start)) ||
(EXTRACTOR_UNZIP_OK !=
- read_short_from_ffd(&file->z_filefunc, &file_info.internal_fa)) ||
+ read_short_from_ffd (&file->z_filefunc, &file_info.internal_fa)) ||
(EXTRACTOR_UNZIP_OK !=
- read_long_from_ffd(&file->z_filefunc, &file_info.external_fa)) ||
+ read_long_from_ffd (&file->z_filefunc, &file_info.external_fa)) ||
(EXTRACTOR_UNZIP_OK !=
- read_long_from_ffd (&file->z_filefunc,
- &file_info_internal.offset_curfile)) )
+ read_long_from_ffd (&file->z_filefunc,
+ &file_info_internal.offset_curfile)) )
return EXTRACTOR_UNZIP_ERRNO;
lSeek += file_info.size_filename;
if (NULL != szFileName)
- {
- uLong uSizeRead;
+ {
+ uLong uSizeRead;
- if (file_info.size_filename < fileNameBufferSize)
- {
- *(szFileName + file_info.size_filename) = '\0';
- uSizeRead = file_info.size_filename;
- }
- else
- uSizeRead = fileNameBufferSize;
-
- if ( (file_info.size_filename > 0) &&
- (fileNameBufferSize > 0) )
- if (ZREAD(file->z_filefunc, szFileName, uSizeRead) != uSizeRead)
- return EXTRACTOR_UNZIP_ERRNO;
- lSeek -= uSizeRead;
+ if (file_info.size_filename < fileNameBufferSize)
+ {
+ *(szFileName + file_info.size_filename) = '\0';
+ uSizeRead = file_info.size_filename;
}
+ else
+ uSizeRead = fileNameBufferSize;
+
+ if ( (file_info.size_filename > 0) &&
+ (fileNameBufferSize > 0) )
+ if (ZREAD (file->z_filefunc, szFileName, uSizeRead) != uSizeRead)
+ return EXTRACTOR_UNZIP_ERRNO;
+ lSeek -= uSizeRead;
+ }
if (NULL != extraField)
- {
- uLong uSizeRead;
+ {
+ uLong uSizeRead;
+
+ if (file_info.size_file_extra<extraFieldBufferSize)
+ uSizeRead = file_info.size_file_extra;
+ else
+ uSizeRead = extraFieldBufferSize;
- if (file_info.size_file_extra<extraFieldBufferSize)
- uSizeRead = file_info.size_file_extra;
+ if (0 != lSeek)
+ {
+ if (0 == ZSEEK (file->z_filefunc, lSeek, SEEK_CUR))
+ lSeek = 0;
else
- uSizeRead = extraFieldBufferSize;
-
- if (0 != lSeek)
- {
- if (0 == ZSEEK (file->z_filefunc, lSeek, SEEK_CUR))
- lSeek = 0;
- else
- return EXTRACTOR_UNZIP_ERRNO;
- }
- if ( (file_info.size_file_extra > 0) &&
- (extraFieldBufferSize > 0) &&
- (ZREAD (file->z_filefunc,
- extraField,
- uSizeRead) != uSizeRead) )
- return EXTRACTOR_UNZIP_ERRNO;
- lSeek += file_info.size_file_extra - uSizeRead;
+ return EXTRACTOR_UNZIP_ERRNO;
}
+ if ( (file_info.size_file_extra > 0) &&
+ (extraFieldBufferSize > 0) &&
+ (ZREAD (file->z_filefunc,
+ extraField,
+ uSizeRead) != uSizeRead) )
+ return EXTRACTOR_UNZIP_ERRNO;
+ lSeek += file_info.size_file_extra - uSizeRead;
+ }
else
lSeek += file_info.size_file_extra;
if (NULL != szComment)
+ {
+ uLong uSizeRead;
+
+ if (file_info.size_file_comment < commentBufferSize)
{
- uLong uSizeRead;
+ *(szComment + file_info.size_file_comment) = '\0';
+ uSizeRead = file_info.size_file_comment;
+ }
+ else
+ {
+ *(szComment + commentBufferSize - 1) = '\0';
+ uSizeRead = commentBufferSize - 1;
+ }
- if (file_info.size_file_comment < commentBufferSize)
- {
- *(szComment+file_info.size_file_comment) = '\0';
- uSizeRead = file_info.size_file_comment;
- }
+ if (0 != lSeek)
+ {
+ if (0 == ZSEEK (file->z_filefunc, lSeek, SEEK_CUR))
+ lSeek = 0;
else
- {
- *(szComment+commentBufferSize - 1) = '\0';
- uSizeRead = commentBufferSize - 1;
- }
-
- if (0 != lSeek)
- {
- if (0 == ZSEEK (file->z_filefunc, lSeek, SEEK_CUR))
- lSeek = 0;
- else
- return EXTRACTOR_UNZIP_ERRNO;
- }
- if ( (file_info.size_file_comment > 0) &&
- (commentBufferSize > 0) &&
- (ZREAD (file->z_filefunc, szComment, uSizeRead) != uSizeRead) )
- return EXTRACTOR_UNZIP_ERRNO;
- lSeek += file_info.size_file_comment - uSizeRead;
+ return EXTRACTOR_UNZIP_ERRNO;
}
+ if ( (file_info.size_file_comment > 0) &&
+ (commentBufferSize > 0) &&
+ (ZREAD (file->z_filefunc, szComment, uSizeRead) != uSizeRead) )
+ return EXTRACTOR_UNZIP_ERRNO;
+ lSeek += file_info.size_file_comment - uSizeRead;
+ }
else
lSeek += file_info.size_file_comment;
@@ -709,9 +713,9 @@ EXTRACTOR_common_unzip_go_to_first_file (struct EXTRACTOR_UnzipFile *file)
file->pos_in_central_dir = file->offset_central_dir;
file->num_file = 0;
err = get_current_file_info (file,
- &file->cur_file_info,
- &file->cur_file_info_internal,
- NULL, 0, NULL, 0, NULL, 0);
+ &file->cur_file_info,
+ &file->cur_file_info_internal,
+ NULL, 0, NULL, 0, NULL, 0);
file->current_file_ok = (EXTRACTOR_UNZIP_OK == err);
return err;
}
@@ -731,12 +735,12 @@ unzip_open_using_ffd (struct FileFuncDefs *ffd)
uLong central_pos;
uLong uL;
uLong number_disk; /* number of the current dist, used for
- spaning ZIP, unsupported, always 0*/
+ spaning ZIP, unsupported, always 0*/
uLong number_disk_with_CD; /* number of the disk with central dir, used
- for spaning ZIP, unsupported, always 0*/
+ for spaning ZIP, unsupported, always 0*/
uLong number_entry_CD; /* total number of entries in
- the central dir
- (same than number_entry on nospan) */
+ the central dir
+ (same than number_entry on nospan) */
memset (&us, 0, sizeof(us));
us.z_filefunc = *ffd;
@@ -744,7 +748,7 @@ unzip_open_using_ffd (struct FileFuncDefs *ffd)
if (0 == central_pos)
return NULL;
if (0 != ZSEEK (us.z_filefunc,
- central_pos, SEEK_SET))
+ central_pos, SEEK_SET))
return NULL;
/* the signature, already checked */
@@ -796,8 +800,8 @@ unzip_open_using_ffd (struct FileFuncDefs *ffd)
if ((central_pos < us.offset_central_dir + us.size_central_dir))
return NULL;
- us.byte_before_the_zipfile = central_pos -
- (us.offset_central_dir + us.size_central_dir);
+ us.byte_before_the_zipfile = central_pos
+ - (us.offset_central_dir + us.size_central_dir);
us.central_pos = central_pos;
us.pfile_in_zip_read = NULL;
us.encrypted = 0;
@@ -818,7 +822,7 @@ unzip_open_using_ffd (struct FileFuncDefs *ffd)
int
EXTRACTOR_common_unzip_close_current_file (struct EXTRACTOR_UnzipFile *file)
{
- struct FileInZipReadInfo* pfile_in_zip_read_info;
+ struct FileInZipReadInfo*pfile_in_zip_read_info;
int err = EXTRACTOR_UNZIP_OK;
if (NULL == file)
@@ -868,8 +872,8 @@ EXTRACTOR_common_unzip_close (struct EXTRACTOR_UnzipFile *file)
*/
int
EXTRACTOR_common_unzip_get_global_comment (struct EXTRACTOR_UnzipFile *file,
- char *comment,
- size_t comment_len)
+ char *comment,
+ size_t comment_len)
{
if (NULL == file)
return EXTRACTOR_UNZIP_PARAMERROR;
@@ -901,19 +905,20 @@ EXTRACTOR_common_unzip_get_global_comment (struct EXTRACTOR_UnzipFile *file,
* @return #EXTRACTOR_UNZIP_OK if there is no problem.
*/
int
-EXTRACTOR_common_unzip_get_current_file_info (struct EXTRACTOR_UnzipFile * file,
- struct EXTRACTOR_UnzipFileInfo *pfile_info,
- char *szFileName,
- uLong fileNameBufferSize,
- void *extraField,
- uLong extraFieldBufferSize,
- char *szComment,
- uLong commentBufferSize)
+EXTRACTOR_common_unzip_get_current_file_info (struct EXTRACTOR_UnzipFile *file,
+ struct EXTRACTOR_UnzipFileInfo *
+ pfile_info,
+ char *szFileName,
+ uLong fileNameBufferSize,
+ void *extraField,
+ uLong extraFieldBufferSize,
+ char *szComment,
+ uLong commentBufferSize)
{
return get_current_file_info (file, pfile_info, NULL,
- szFileName, fileNameBufferSize,
- extraField, extraFieldBufferSize,
- szComment, commentBufferSize);
+ szFileName, fileNameBufferSize,
+ extraField, extraFieldBufferSize,
+ szComment, commentBufferSize);
}
@@ -935,13 +940,15 @@ EXTRACTOR_common_unzip_go_to_next_file (struct EXTRACTOR_UnzipFile *file)
return EXTRACTOR_UNZIP_END_OF_LIST_OF_FILE;
if (file->num_file + 1 == file->gi.number_entry)
return EXTRACTOR_UNZIP_END_OF_LIST_OF_FILE;
- file->pos_in_central_dir += SIZECENTRALDIRITEM + file->cur_file_info.size_filename +
- file->cur_file_info.size_file_extra + file->cur_file_info.size_file_comment;
+ file->pos_in_central_dir += SIZECENTRALDIRITEM
+ + file->cur_file_info.size_filename
+ + file->cur_file_info.size_file_extra
+ + file->cur_file_info.size_file_comment;
file->num_file++;
err = get_current_file_info (file,
- &file->cur_file_info,
- &file->cur_file_info_internal,
- NULL, 0, NULL, 0, NULL, 0);
+ &file->cur_file_info,
+ &file->cur_file_info_internal,
+ NULL, 0, NULL, 0, NULL, 0);
file->current_file_ok = (EXTRACTOR_UNZIP_OK == err);
return err;
}
@@ -960,8 +967,8 @@ EXTRACTOR_common_unzip_go_to_next_file (struct EXTRACTOR_UnzipFile *file)
*/
int
EXTRACTOR_common_unzip_go_find_local_file (struct EXTRACTOR_UnzipFile *file,
- const char *szFileName,
- int iCaseSensitivity)
+ const char *szFileName,
+ int iCaseSensitivity)
{
int err;
/* We remember the 'current' position in the file so that we can jump
@@ -987,22 +994,24 @@ EXTRACTOR_common_unzip_go_find_local_file (struct EXTRACTOR_UnzipFile *file,
err = EXTRACTOR_common_unzip_go_to_first_file (file);
while (EXTRACTOR_UNZIP_OK == err)
- {
- char szCurrentFileName[UNZ_MAXFILENAMEINZIP + 1];
-
- if (EXTRACTOR_UNZIP_OK !=
- (err = EXTRACTOR_common_unzip_get_current_file_info (file, NULL,
- szCurrentFileName,
- sizeof (szCurrentFileName) - 1,
- NULL, 0, NULL, 0)))
- break;
- if (0 ==
- EXTRACTOR_common_unzip_string_file_name_compare (szCurrentFileName,
- szFileName,
- iCaseSensitivity))
- return EXTRACTOR_UNZIP_OK;
- err = EXTRACTOR_common_unzip_go_to_next_file (file);
- }
+ {
+ char szCurrentFileName[UNZ_MAXFILENAMEINZIP + 1];
+
+ if (EXTRACTOR_UNZIP_OK !=
+ (err = EXTRACTOR_common_unzip_get_current_file_info (file, NULL,
+ szCurrentFileName,
+ sizeof (
+ szCurrentFileName)
+ - 1,
+ NULL, 0, NULL, 0)))
+ break;
+ if (0 ==
+ EXTRACTOR_common_unzip_string_file_name_compare (szCurrentFileName,
+ szFileName,
+ iCaseSensitivity))
+ return EXTRACTOR_UNZIP_OK;
+ err = EXTRACTOR_common_unzip_go_to_next_file (file);
+ }
/* We failed, so restore the state of the 'current file' to where we
* were.
@@ -1027,8 +1036,8 @@ EXTRACTOR_common_unzip_go_find_local_file (struct EXTRACTOR_UnzipFile *file,
*/
ssize_t
EXTRACTOR_common_unzip_read_current_file (struct EXTRACTOR_UnzipFile *file,
- void *buf,
- size_t len)
+ void *buf,
+ size_t len)
{
int err = EXTRACTOR_UNZIP_OK;
uInt iRead = 0;
@@ -1050,97 +1059,97 @@ EXTRACTOR_common_unzip_read_current_file (struct EXTRACTOR_UnzipFile *file,
(uInt) pfile_in_zip_read_info->rest_read_uncompressed;
while (pfile_in_zip_read_info->stream.avail_out > 0)
+ {
+ if ( (0 == pfile_in_zip_read_info->stream.avail_in) &&
+ (pfile_in_zip_read_info->rest_read_compressed > 0) )
{
+ uInt uReadThis = UNZ_BUFSIZE;
+ if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
+ uReadThis = (uInt) pfile_in_zip_read_info->rest_read_compressed;
+ if (0 == uReadThis)
+ return EXTRACTOR_UNZIP_EOF;
+ if (0 !=
+ ZSEEK (pfile_in_zip_read_info->z_filefunc,
+ pfile_in_zip_read_info->pos_in_zipfile
+ + pfile_in_zip_read_info->byte_before_the_zipfile,
+ SEEK_SET))
+ return EXTRACTOR_UNZIP_ERRNO;
+ if (ZREAD (pfile_in_zip_read_info->z_filefunc,
+ pfile_in_zip_read_info->read_buffer,
+ uReadThis) != uReadThis)
+ return EXTRACTOR_UNZIP_ERRNO;
+
+ pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
+ pfile_in_zip_read_info->rest_read_compressed -= uReadThis;
+ pfile_in_zip_read_info->stream.next_in =
+ (Bytef *) pfile_in_zip_read_info->read_buffer;
+ pfile_in_zip_read_info->stream.avail_in = (uInt) uReadThis;
+ }
+
+ if (0 == pfile_in_zip_read_info->compression_method)
+ {
+ uInt uDoCopy;
+
if ( (0 == pfile_in_zip_read_info->stream.avail_in) &&
- (pfile_in_zip_read_info->rest_read_compressed > 0) )
- {
- uInt uReadThis = UNZ_BUFSIZE;
- if (pfile_in_zip_read_info->rest_read_compressed<uReadThis)
- uReadThis = (uInt) pfile_in_zip_read_info->rest_read_compressed;
- if (0 == uReadThis)
- return EXTRACTOR_UNZIP_EOF;
- if (0 !=
- ZSEEK (pfile_in_zip_read_info->z_filefunc,
- pfile_in_zip_read_info->pos_in_zipfile +
- pfile_in_zip_read_info->byte_before_the_zipfile,
- SEEK_SET))
- return EXTRACTOR_UNZIP_ERRNO;
- if (ZREAD (pfile_in_zip_read_info->z_filefunc,
- pfile_in_zip_read_info->read_buffer,
- uReadThis) != uReadThis)
- return EXTRACTOR_UNZIP_ERRNO;
-
- pfile_in_zip_read_info->pos_in_zipfile += uReadThis;
- pfile_in_zip_read_info->rest_read_compressed -= uReadThis;
- pfile_in_zip_read_info->stream.next_in =
- (Bytef *) pfile_in_zip_read_info->read_buffer;
- pfile_in_zip_read_info->stream.avail_in = (uInt) uReadThis;
- }
-
- if (0 == pfile_in_zip_read_info->compression_method)
- {
- uInt uDoCopy;
-
- if ( (0 == pfile_in_zip_read_info->stream.avail_in) &&
- (0 == pfile_in_zip_read_info->rest_read_compressed) )
- return (0 == iRead) ? EXTRACTOR_UNZIP_EOF : iRead;
-
- if (pfile_in_zip_read_info->stream.avail_out <
- pfile_in_zip_read_info->stream.avail_in)
- uDoCopy = pfile_in_zip_read_info->stream.avail_out;
- else
- uDoCopy = pfile_in_zip_read_info->stream.avail_in;
- memcpy (pfile_in_zip_read_info->stream.next_out,
- pfile_in_zip_read_info->stream.next_in,
- uDoCopy);
- pfile_in_zip_read_info->crc32 = crc32 (pfile_in_zip_read_info->crc32,
- pfile_in_zip_read_info->stream.next_out,
- uDoCopy);
- pfile_in_zip_read_info->rest_read_uncompressed -= uDoCopy;
- pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
- pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
- pfile_in_zip_read_info->stream.next_out += uDoCopy;
- pfile_in_zip_read_info->stream.next_in += uDoCopy;
- pfile_in_zip_read_info->stream.total_out += uDoCopy;
- iRead += uDoCopy;
- }
+ (0 == pfile_in_zip_read_info->rest_read_compressed) )
+ return (0 == iRead) ? EXTRACTOR_UNZIP_EOF : iRead;
+
+ if (pfile_in_zip_read_info->stream.avail_out <
+ pfile_in_zip_read_info->stream.avail_in)
+ uDoCopy = pfile_in_zip_read_info->stream.avail_out;
else
- {
- uLong uTotalOutBefore;
- uLong uTotalOutAfter;
- const Bytef *bufBefore;
- uLong uOutThis;
- int flush = Z_SYNC_FLUSH;
-
- uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
- bufBefore = pfile_in_zip_read_info->stream.next_out;
-
- /*
- if ((pfile_in_zip_read_info->rest_read_uncompressed ==
- pfile_in_zip_read_info->stream.avail_out) &&
- (pfile_in_zip_read_info->rest_read_compressed == 0))
- flush = Z_FINISH;
- */
- err = inflate (&pfile_in_zip_read_info->stream, flush);
-
- uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
- uOutThis = uTotalOutAfter-uTotalOutBefore;
-
- pfile_in_zip_read_info->crc32 =
- crc32 (pfile_in_zip_read_info->crc32, bufBefore,
- (uInt) (uOutThis));
-
- pfile_in_zip_read_info->rest_read_uncompressed -=
- uOutThis;
-
- iRead += (uInt) (uTotalOutAfter - uTotalOutBefore);
-
- if (Z_STREAM_END == err)
- return (0 == iRead) ? EXTRACTOR_UNZIP_EOF : iRead;
- if (Z_OK != err)
- break;
- }
+ uDoCopy = pfile_in_zip_read_info->stream.avail_in;
+ memcpy (pfile_in_zip_read_info->stream.next_out,
+ pfile_in_zip_read_info->stream.next_in,
+ uDoCopy);
+ pfile_in_zip_read_info->crc32 = crc32 (pfile_in_zip_read_info->crc32,
+ pfile_in_zip_read_info->stream.
+ next_out,
+ uDoCopy);
+ pfile_in_zip_read_info->rest_read_uncompressed -= uDoCopy;
+ pfile_in_zip_read_info->stream.avail_in -= uDoCopy;
+ pfile_in_zip_read_info->stream.avail_out -= uDoCopy;
+ pfile_in_zip_read_info->stream.next_out += uDoCopy;
+ pfile_in_zip_read_info->stream.next_in += uDoCopy;
+ pfile_in_zip_read_info->stream.total_out += uDoCopy;
+ iRead += uDoCopy;
+ }
+ else
+ {
+ uLong uTotalOutBefore;
+ uLong uTotalOutAfter;
+ const Bytef *bufBefore;
+ uLong uOutThis;
+ int flush = Z_SYNC_FLUSH;
+
+ uTotalOutBefore = pfile_in_zip_read_info->stream.total_out;
+ bufBefore = pfile_in_zip_read_info->stream.next_out;
+
+ /*
+ if ((pfile_in_zip_read_info->rest_read_uncompressed ==
+ pfile_in_zip_read_info->stream.avail_out) &&
+ (pfile_in_zip_read_info->rest_read_compressed == 0))
+ flush = Z_FINISH;
+ */err = inflate (&pfile_in_zip_read_info->stream, flush);
+
+ uTotalOutAfter = pfile_in_zip_read_info->stream.total_out;
+ uOutThis = uTotalOutAfter - uTotalOutBefore;
+
+ pfile_in_zip_read_info->crc32 =
+ crc32 (pfile_in_zip_read_info->crc32, bufBefore,
+ (uInt) (uOutThis));
+
+ pfile_in_zip_read_info->rest_read_uncompressed -=
+ uOutThis;
+
+ iRead += (uInt) (uTotalOutAfter - uTotalOutBefore);
+
+ if (Z_STREAM_END == err)
+ return (0 == iRead) ? EXTRACTOR_UNZIP_EOF : iRead;
+ if (Z_OK != err)
+ break;
}
+ }
if (Z_OK == err)
return iRead;
@@ -1162,9 +1171,9 @@ EXTRACTOR_common_unzip_read_current_file (struct EXTRACTOR_UnzipFile *file,
*/
static int
parse_current_file_coherency_header (struct EXTRACTOR_UnzipFile *file,
- uInt *piSizeVar,
- uLong *poffset_local_extrafield,
- uInt *psize_local_extrafield)
+ uInt *piSizeVar,
+ uLong *poffset_local_extrafield,
+ uInt *psize_local_extrafield)
{
uLong uMagic;
uLong uData;
@@ -1177,20 +1186,20 @@ parse_current_file_coherency_header (struct EXTRACTOR_UnzipFile *file,
*psize_local_extrafield = 0;
if (0 != ZSEEK (file->z_filefunc,
- file->cur_file_info_internal.offset_curfile +
- file->byte_before_the_zipfile,
- SEEK_SET))
+ file->cur_file_info_internal.offset_curfile
+ + file->byte_before_the_zipfile,
+ SEEK_SET))
return EXTRACTOR_UNZIP_ERRNO;
if (EXTRACTOR_UNZIP_OK !=
read_long_from_ffd (&file->z_filefunc,
- &uMagic))
+ &uMagic))
return EXTRACTOR_UNZIP_ERRNO;
if (0x04034b50 != uMagic)
return EXTRACTOR_UNZIP_BADZIPFILE;
if ( (EXTRACTOR_UNZIP_OK !=
- read_short_from_ffd (&file->z_filefunc, &uData)) ||
+ read_short_from_ffd (&file->z_filefunc, &uData)) ||
(EXTRACTOR_UNZIP_OK !=
- read_short_from_ffd (&file->z_filefunc, &uFlags)) )
+ read_short_from_ffd (&file->z_filefunc, &uFlags)) )
return EXTRACTOR_UNZIP_ERRNO;
if (EXTRACTOR_UNZIP_OK != read_short_from_ffd (&file->z_filefunc, &uData))
return EXTRACTOR_UNZIP_ERRNO;
@@ -1209,14 +1218,14 @@ parse_current_file_coherency_header (struct EXTRACTOR_UnzipFile *file,
(0 == (uFlags & 8)) )
return EXTRACTOR_UNZIP_BADZIPFILE;
if (EXTRACTOR_UNZIP_OK !=
- read_long_from_ffd(&file->z_filefunc, &uData)) /* size compr */
+ read_long_from_ffd (&file->z_filefunc, &uData)) /* size compr */
return EXTRACTOR_UNZIP_ERRNO;
if ( (uData != file->cur_file_info.compressed_size) &&
(0 == (uFlags & 8)) )
return EXTRACTOR_UNZIP_BADZIPFILE;
if (EXTRACTOR_UNZIP_OK !=
read_long_from_ffd (&file->z_filefunc,
- &uData)) /* size uncompr */
+ &uData)) /* size uncompr */
return EXTRACTOR_UNZIP_ERRNO;
if ( (uData != file->cur_file_info.uncompressed_size) &&
(0 == (uFlags & 8)))
@@ -1229,12 +1238,12 @@ parse_current_file_coherency_header (struct EXTRACTOR_UnzipFile *file,
*piSizeVar += (uInt) size_filename;
if (EXTRACTOR_UNZIP_OK !=
read_short_from_ffd (&file->z_filefunc,
- &size_extra_field))
+ &size_extra_field))
return EXTRACTOR_UNZIP_ERRNO;
- *poffset_local_extrafield = file->cur_file_info_internal.offset_curfile +
- SIZEZIPLOCALHEADER + size_filename;
+ *poffset_local_extrafield = file->cur_file_info_internal.offset_curfile
+ + SIZEZIPLOCALHEADER + size_filename;
*psize_local_extrafield = (uInt) size_extra_field;
- *piSizeVar += (uInt)size_extra_field;
+ *piSizeVar += (uInt) size_extra_field;
return EXTRACTOR_UNZIP_OK;
}
@@ -1253,7 +1262,7 @@ EXTRACTOR_common_unzip_open_current_file (struct EXTRACTOR_UnzipFile *file)
uInt iSizeVar;
struct FileInZipReadInfo *pfile_in_zip_read_info;
uLong offset_local_extrafield; /* offset of the local extra field */
- uInt size_local_extrafield; /* size of the local extra field */
+ uInt size_local_extrafield; /* size of the local extra field */
if (NULL == file)
return EXTRACTOR_UNZIP_PARAMERROR;
@@ -1263,17 +1272,18 @@ EXTRACTOR_common_unzip_open_current_file (struct EXTRACTOR_UnzipFile *file)
EXTRACTOR_common_unzip_close_current_file (file);
if (EXTRACTOR_UNZIP_OK !=
parse_current_file_coherency_header (file,
- &iSizeVar,
- &offset_local_extrafield,
- &size_local_extrafield))
+ &iSizeVar,
+ &offset_local_extrafield,
+ &size_local_extrafield))
return EXTRACTOR_UNZIP_BADZIPFILE;
- if (NULL == (pfile_in_zip_read_info = malloc (sizeof(struct FileInZipReadInfo))))
+ if (NULL == (pfile_in_zip_read_info = malloc (sizeof(struct
+ FileInZipReadInfo))))
return EXTRACTOR_UNZIP_INTERNALERROR;
if (NULL == (pfile_in_zip_read_info->read_buffer = malloc (UNZ_BUFSIZE)))
- {
- free (pfile_in_zip_read_info);
- return EXTRACTOR_UNZIP_INTERNALERROR;
- }
+ {
+ free (pfile_in_zip_read_info);
+ return EXTRACTOR_UNZIP_INTERNALERROR;
+ }
pfile_in_zip_read_info->offset_local_extrafield = offset_local_extrafield;
pfile_in_zip_read_info->size_local_extrafield = size_local_extrafield;
pfile_in_zip_read_info->pos_local_extrafield = 0;
@@ -1281,45 +1291,49 @@ EXTRACTOR_common_unzip_open_current_file (struct EXTRACTOR_UnzipFile *file)
if ( (0 != file->cur_file_info.compression_method) &&
(Z_DEFLATED != file->cur_file_info.compression_method) )
- {
- // err = EXTRACTOR_UNZIP_BADZIPFILE;
- // FIXME: we don't do anything with this 'err' code.
- // Can this happen? Should we abort in this case?
- }
+ {
+ // err = EXTRACTOR_UNZIP_BADZIPFILE;
+ // FIXME: we don't do anything with this 'err' code.
+ // Can this happen? Should we abort in this case?
+ }
pfile_in_zip_read_info->crc32_wait = file->cur_file_info.crc;
pfile_in_zip_read_info->crc32 = 0;
- pfile_in_zip_read_info->compression_method = file->cur_file_info.compression_method;
+ pfile_in_zip_read_info->compression_method =
+ file->cur_file_info.compression_method;
pfile_in_zip_read_info->z_filefunc = file->z_filefunc;
- pfile_in_zip_read_info->byte_before_the_zipfile = file->byte_before_the_zipfile;
+ pfile_in_zip_read_info->byte_before_the_zipfile =
+ file->byte_before_the_zipfile;
pfile_in_zip_read_info->stream.total_out = 0;
if (Z_DEFLATED == file->cur_file_info.compression_method)
+ {
+ pfile_in_zip_read_info->stream.zalloc = (alloc_func) NULL;
+ pfile_in_zip_read_info->stream.zfree = (free_func) NULL;
+ pfile_in_zip_read_info->stream.opaque = NULL;
+ pfile_in_zip_read_info->stream.next_in = NULL;
+ pfile_in_zip_read_info->stream.avail_in = 0;
+ if (Z_OK != (err = inflateInit2 (&pfile_in_zip_read_info->stream,
+ -MAX_WBITS)))
{
- pfile_in_zip_read_info->stream.zalloc = (alloc_func) NULL;
- pfile_in_zip_read_info->stream.zfree = (free_func) NULL;
- pfile_in_zip_read_info->stream.opaque = NULL;
- pfile_in_zip_read_info->stream.next_in = NULL;
- pfile_in_zip_read_info->stream.avail_in = 0;
- if (Z_OK != (err = inflateInit2 (&pfile_in_zip_read_info->stream, -MAX_WBITS)))
- {
- free (pfile_in_zip_read_info->read_buffer);
- free (pfile_in_zip_read_info);
- return err;
- }
- pfile_in_zip_read_info->stream_initialised = 1;
- /* windowBits is passed < 0 to tell that there is no zlib header.
- * Note that in this case inflate *requires* an extra "dummy" byte
- * after the compressed stream in order to complete decompression and
- * return Z_STREAM_END.
- * In unzip, i don't wait absolutely Z_STREAM_END because I known the
- * size of both compressed and uncompressed data
- */
+ free (pfile_in_zip_read_info->read_buffer);
+ free (pfile_in_zip_read_info);
+ return err;
}
- pfile_in_zip_read_info->rest_read_compressed = file->cur_file_info.compressed_size;
- pfile_in_zip_read_info->rest_read_uncompressed = file->cur_file_info.uncompressed_size;
+ pfile_in_zip_read_info->stream_initialised = 1;
+ /* windowBits is passed < 0 to tell that there is no zlib header.
+ * Note that in this case inflate *requires* an extra "dummy" byte
+ * after the compressed stream in order to complete decompression and
+ * return Z_STREAM_END.
+ * In unzip, i don't wait absolutely Z_STREAM_END because I known the
+ * size of both compressed and uncompressed data
+ */}
+ pfile_in_zip_read_info->rest_read_compressed =
+ file->cur_file_info.compressed_size;
+ pfile_in_zip_read_info->rest_read_uncompressed =
+ file->cur_file_info.uncompressed_size;
pfile_in_zip_read_info->pos_in_zipfile =
- file->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER +
- iSizeVar;
+ file->cur_file_info_internal.offset_curfile + SIZEZIPLOCALHEADER
+ + iSizeVar;
pfile_in_zip_read_info->stream.avail_in = 0;
file->pfile_in_zip_read = pfile_in_zip_read_info;
return EXTRACTOR_UNZIP_OK;
@@ -1337,8 +1351,8 @@ EXTRACTOR_common_unzip_open_current_file (struct EXTRACTOR_UnzipFile *file)
*/
static uLong
ec_read_file_func (voidpf opaque,
- void* buf,
- uLong size)
+ void*buf,
+ uLong size)
{
struct EXTRACTOR_ExtractContext *ec = opaque;
void *ptr;
@@ -1347,15 +1361,15 @@ ec_read_file_func (voidpf opaque,
done = 0;
while (done < size)
- {
- ret = ec->read (ec->cls,
- &ptr,
- size - done);
- if (ret <= 0)
- return done;
- memcpy (buf + done, ptr, ret);
- done += ret;
- }
+ {
+ ret = ec->read (ec->cls,
+ &ptr,
+ size - done);
+ if (ret <= 0)
+ return done;
+ memcpy (buf + done, ptr, ret);
+ done += ret;
+ }
return done;
}
@@ -1385,8 +1399,8 @@ ec_tell_file_func (voidpf opaque)
*/
static long
ec_seek_file_func (voidpf opaque,
- uLong offset,
- int origin)
+ uLong offset,
+ int origin)
{
struct EXTRACTOR_ExtractContext *ec = opaque;
@@ -1416,4 +1430,5 @@ EXTRACTOR_common_unzip_open (struct EXTRACTOR_ExtractContext *ec)
return unzip_open_using_ffd (&ffd);
}
+
/* end of unzip.c */
diff --git a/src/common/unzip.h b/src/common/unzip.h
@@ -21,7 +21,7 @@
* @file common/unzip.h
* @brief API to access ZIP archives
* @author Christian Grothoff
- *
+ *
* This code is based in part on
* unzip 1.00 Copyright 1998-2003 Gilles Vollant
* http://www.winimage.com/zLibDll"
@@ -83,112 +83,112 @@ struct EXTRACTOR_UnzipFile;
struct EXTRACTOR_UnzipDateTimeInfo
{
/**
- * seconds after the minute - [0,59]
+ * seconds after the minute - [0,59]
*/
- uInt tm_sec;
+ uInt tm_sec;
/**
- * minutes after the hour - [0,59]
+ * minutes after the hour - [0,59]
*/
- uInt tm_min;
-
+ uInt tm_min;
+
/**
- * hours since midnight - [0,23]
+ * hours since midnight - [0,23]
*/
- uInt tm_hour;
+ uInt tm_hour;
/**
- * day of the month - [1,31]
+ * day of the month - [1,31]
*/
- uInt tm_mday;
-
+ uInt tm_mday;
+
/**
- * months since January - [0,11]
+ * months since January - [0,11]
*/
- uInt tm_mon;
+ uInt tm_mon;
/**
- * years - [1980..2044]
+ * years - [1980..2044]
*/
- uInt tm_year;
+ uInt tm_year;
};
/**
- * Information about a file in the zipfile
+ * Information about a file in the zipfile
*/
struct EXTRACTOR_UnzipFileInfo
{
/**
- * version made by 2 bytes
+ * version made by 2 bytes
*/
- uLong version;
+ uLong version;
/**
- * version needed to extract 2 bytes
+ * version needed to extract 2 bytes
*/
- uLong version_needed;
+ uLong version_needed;
/**
- * general purpose bit flag 2 bytes
+ * general purpose bit flag 2 bytes
*/
- uLong flag;
+ uLong flag;
/**
- * compression method 2 bytes
+ * compression method 2 bytes
*/
- uLong compression_method;
+ uLong compression_method;
/**
- * last mod file date in Dos fmt 4 bytes
+ * last mod file date in Dos fmt 4 bytes
*/
- uLong dosDate;
+ uLong dosDate;
/**
- * crc-32 4 bytes
+ * crc-32 4 bytes
*/
- uLong crc;
+ uLong crc;
/**
* compressed size 4 bytes
*/
- uLong compressed_size;
+ uLong compressed_size;
/**
- * uncompressed size 4 bytes
+ * uncompressed size 4 bytes
*/
- uLong uncompressed_size;
+ uLong uncompressed_size;
/**
- * filename length 2 bytes
+ * filename length 2 bytes
*/
- uLong size_filename;
+ uLong size_filename;
/**
- * extra field length 2 bytes
+ * extra field length 2 bytes
*/
- uLong size_file_extra;
+ uLong size_file_extra;
/**
- * file comment length 2 bytes
+ * file comment length 2 bytes
*/
- uLong size_file_comment;
-
+ uLong size_file_comment;
+
/**
- * disk number start 2 bytes
+ * disk number start 2 bytes
*/
- uLong disk_num_start;
+ uLong disk_num_start;
/**
- * internal file attributes 2 bytes
+ * internal file attributes 2 bytes
*/
- uLong internal_fa;
+ uLong internal_fa;
/**
- * external file attributes 4 bytes
+ * external file attributes 4 bytes
*/
- uLong external_fa;
-
+ uLong external_fa;
+
/**
* Time and date of last modification.
*/
@@ -203,7 +203,7 @@ struct EXTRACTOR_UnzipFileInfo
* @param ec extract context to use
* @return handle to zip data, NULL on error
*/
-struct EXTRACTOR_UnzipFile *
+struct EXTRACTOR_UnzipFile *
EXTRACTOR_common_unzip_open (struct EXTRACTOR_ExtractContext *ec);
@@ -217,15 +217,15 @@ EXTRACTOR_common_unzip_open (struct EXTRACTOR_ExtractContext *ec);
*/
int
EXTRACTOR_common_unzip_get_global_comment (struct EXTRACTOR_UnzipFile *file,
- char *comment,
- size_t comment_len);
+ char *comment,
+ size_t comment_len);
/**
* Close a ZipFile.
*
* @param file zip file to close
- * @return EXTRACTOR_UNZIP_OK if there is no problem.
+ * @return EXTRACTOR_UNZIP_OK if there is no problem.
*/
int
EXTRACTOR_common_unzip_close (struct EXTRACTOR_UnzipFile *file);
@@ -237,7 +237,7 @@ EXTRACTOR_common_unzip_close (struct EXTRACTOR_UnzipFile *file);
* @param file zipfile to manipulate
* @return UNZ_OK if there is no problem
*/
-int
+int
EXTRACTOR_common_unzip_go_to_first_file (struct EXTRACTOR_UnzipFile *file);
@@ -254,7 +254,7 @@ EXTRACTOR_common_unzip_go_to_next_file (struct EXTRACTOR_UnzipFile *file);
/**
* Try locate the file szFileName in the zipfile.
- *
+ *
* @param file zipfile to manipulate
* @param szFileName name to find
* @param iCaseSensitivity, use 1 for case sensitivity (like strcmp);
@@ -264,9 +264,9 @@ EXTRACTOR_common_unzip_go_to_next_file (struct EXTRACTOR_UnzipFile *file);
* EXTRACTOR_UNZIP_END_OF_LIST_OF_FILE if the file is not found
*/
int
-EXTRACTOR_common_unzip_go_find_local_file (struct EXTRACTOR_UnzipFile *file,
- const char *szFileName,
- int iCaseSensitivity);
+EXTRACTOR_common_unzip_go_find_local_file (struct EXTRACTOR_UnzipFile *file,
+ const char *szFileName,
+ int iCaseSensitivity);
/**
@@ -278,20 +278,21 @@ EXTRACTOR_common_unzip_go_find_local_file (struct EXTRACTOR_UnzipFile *file,
* @param szFileName where to write the name of the current file
* @param fileNameBufferSize number of bytes available in szFileName
* @param extraField where to write extra data
- * @param extraFieldBufferSize number of bytes available in extraField
+ * @param extraFieldBufferSize number of bytes available in extraField
* @param szComment where to write the comment on the current file
* @param commentBufferSize number of bytes available in szComment
* @return EXTRACTOR_UNZIP_OK if there is no problem.
*/
-int
+int
EXTRACTOR_common_unzip_get_current_file_info (struct EXTRACTOR_UnzipFile *file,
- struct EXTRACTOR_UnzipFileInfo *pfile_info,
- char *szFileName,
- uLong fileNameBufferSize,
- void *extraField,
- uLong extraFieldBufferSize,
- char *szComment,
- uLong commentBufferSize);
+ struct EXTRACTOR_UnzipFileInfo *
+ pfile_info,
+ char *szFileName,
+ uLong fileNameBufferSize,
+ void *extraField,
+ uLong extraFieldBufferSize,
+ char *szComment,
+ uLong commentBufferSize);
/**
@@ -314,10 +315,10 @@ EXTRACTOR_common_unzip_open_current_file (struct EXTRACTOR_UnzipFile *file);
* <0 with error code if there is an error
* (EXTRACTOR_UNZIP_ERRNO for IO error, or zLib error for uncompress error)
*/
-ssize_t
+ssize_t
EXTRACTOR_common_unzip_read_current_file (struct EXTRACTOR_UnzipFile *file,
- void *buf,
- size_t len);
+ void *buf,
+ size_t len);
/**
@@ -325,9 +326,9 @@ EXTRACTOR_common_unzip_read_current_file (struct EXTRACTOR_UnzipFile *file,
*
* @return EXTRACTOR_UNZIP_CRCERROR if all the file was read but the CRC is not good
*/
-int
+int
EXTRACTOR_common_unzip_close_current_file (struct EXTRACTOR_UnzipFile *file);
-#endif
+#endif
/* LE_COMMON_UNZIP_H */
diff --git a/src/include/extractor.h b/src/include/extractor.h
@@ -54,65 +54,65 @@ extern "C" {
* Options for how plugin execution should be done.
*/
enum EXTRACTOR_Options
- {
+{
- /**
- * Run plugin out-of-process, starting the process once the plugin
- * is to be run. If a plugin crashes, automatically restart the
- * respective process for the same file and try once more
- * (since the crash may be caused by the previous file). If
- * the process crashes immediately again, it is not restarted
- * until the next file.
- */
- EXTRACTOR_OPTION_DEFAULT_POLICY = 0,
+ /**
+ * Run plugin out-of-process, starting the process once the plugin
+ * is to be run. If a plugin crashes, automatically restart the
+ * respective process for the same file and try once more
+ * (since the crash may be caused by the previous file). If
+ * the process crashes immediately again, it is not restarted
+ * until the next file.
+ */
+ EXTRACTOR_OPTION_DEFAULT_POLICY = 0,
- /**
- * Deprecated option. Ignored.
- */
- EXTRACTOR_OPTION_OUT_OF_PROCESS_NO_RESTART = 1,
+ /**
+ * Deprecated option. Ignored.
+ */
+ EXTRACTOR_OPTION_OUT_OF_PROCESS_NO_RESTART = 1,
- /**
- * Run plugins in-process. Unsafe, not recommended,
- * can be nice for debugging.
- */
- EXTRACTOR_OPTION_IN_PROCESS = 2,
+ /**
+ * Run plugins in-process. Unsafe, not recommended,
+ * can be nice for debugging.
+ */
+ EXTRACTOR_OPTION_IN_PROCESS = 2,
- /**
- * Internal value for plugins that have been disabled.
- */
- EXTRACTOR_OPTION_DISABLED = 3
+ /**
+ * Internal value for plugins that have been disabled.
+ */
+ EXTRACTOR_OPTION_DISABLED = 3
- };
+};
/**
* Format in which the extracted meta data is presented.
*/
enum EXTRACTOR_MetaFormat
- {
- /**
- * Format is unknown.
- */
- EXTRACTOR_METAFORMAT_UNKNOWN = 0,
+{
+ /**
+ * Format is unknown.
+ */
+ EXTRACTOR_METAFORMAT_UNKNOWN = 0,
- /**
- * 0-terminated, UTF-8 encoded string. "data_len"
- * is strlen(data)+1.
- */
- EXTRACTOR_METAFORMAT_UTF8 = 1,
+ /**
+ * 0-terminated, UTF-8 encoded string. "data_len"
+ * is strlen(data)+1.
+ */
+ EXTRACTOR_METAFORMAT_UTF8 = 1,
- /**
- * Some kind of binary format, see given Mime type.
- */
- EXTRACTOR_METAFORMAT_BINARY = 2,
+ /**
+ * Some kind of binary format, see given Mime type.
+ */
+ EXTRACTOR_METAFORMAT_BINARY = 2,
- /**
- * 0-terminated string. The specific encoding is unknown.
- * "data_len" is strlen (data)+1.
- */
- EXTRACTOR_METAFORMAT_C_STRING = 3
+ /**
+ * 0-terminated string. The specific encoding is unknown.
+ * "data_len" is strlen (data)+1.
+ */
+ EXTRACTOR_METAFORMAT_C_STRING = 3
- };
+};
/**
@@ -123,283 +123,283 @@ enum EXTRACTOR_MetaFormat
* @{
*/
enum EXTRACTOR_MetaType
- {
- /* fundamental types */
- EXTRACTOR_METATYPE_RESERVED = 0,
- EXTRACTOR_METATYPE_MIMETYPE = 1,
- EXTRACTOR_METATYPE_FILENAME = 2,
- EXTRACTOR_METATYPE_COMMENT = 3,
-
- /* Standard types from bibtex */
- EXTRACTOR_METATYPE_TITLE = 4,
- EXTRACTOR_METATYPE_BOOK_TITLE = 5,
- EXTRACTOR_METATYPE_BOOK_EDITION = 6,
- EXTRACTOR_METATYPE_BOOK_CHAPTER_NUMBER = 7,
- EXTRACTOR_METATYPE_JOURNAL_NAME = 8,
- EXTRACTOR_METATYPE_JOURNAL_VOLUME = 9,
- EXTRACTOR_METATYPE_JOURNAL_NUMBER = 10,
- EXTRACTOR_METATYPE_PAGE_COUNT = 11,
- EXTRACTOR_METATYPE_PAGE_RANGE = 12,
- EXTRACTOR_METATYPE_AUTHOR_NAME = 13,
- EXTRACTOR_METATYPE_AUTHOR_EMAIL = 14,
- EXTRACTOR_METATYPE_AUTHOR_INSTITUTION = 15,
- EXTRACTOR_METATYPE_PUBLISHER = 16,
- EXTRACTOR_METATYPE_PUBLISHER_ADDRESS = 17,
- EXTRACTOR_METATYPE_PUBLISHER_INSTITUTION = 18,
- EXTRACTOR_METATYPE_PUBLISHER_SERIES = 19,
- EXTRACTOR_METATYPE_PUBLICATION_TYPE = 20,
- EXTRACTOR_METATYPE_PUBLICATION_YEAR = 21,
- EXTRACTOR_METATYPE_PUBLICATION_MONTH = 22,
- EXTRACTOR_METATYPE_PUBLICATION_DAY = 23,
- EXTRACTOR_METATYPE_PUBLICATION_DATE = 24,
- EXTRACTOR_METATYPE_BIBTEX_EPRINT = 25,
- EXTRACTOR_METATYPE_BIBTEX_ENTRY_TYPE = 26,
- EXTRACTOR_METATYPE_LANGUAGE = 27,
- EXTRACTOR_METATYPE_CREATION_TIME = 28,
- EXTRACTOR_METATYPE_URL = 29,
-
- /* "unique" document identifiers */
- EXTRACTOR_METATYPE_URI = 30,
- EXTRACTOR_METATYPE_ISRC = 31,
- EXTRACTOR_METATYPE_HASH_MD4 = 32,
- EXTRACTOR_METATYPE_HASH_MD5 = 33,
- EXTRACTOR_METATYPE_HASH_SHA0 = 34,
- EXTRACTOR_METATYPE_HASH_SHA1 = 35,
- EXTRACTOR_METATYPE_HASH_RMD160 = 36,
-
- /* identifiers of a location */
- EXTRACTOR_METATYPE_GPS_LATITUDE_REF = 37,
- EXTRACTOR_METATYPE_GPS_LATITUDE = 38,
- EXTRACTOR_METATYPE_GPS_LONGITUDE_REF = 39,
- EXTRACTOR_METATYPE_GPS_LONGITUDE = 40,
- EXTRACTOR_METATYPE_LOCATION_CITY = 41,
- EXTRACTOR_METATYPE_LOCATION_SUBLOCATION = 42,
- EXTRACTOR_METATYPE_LOCATION_COUNTRY = 43,
- EXTRACTOR_METATYPE_LOCATION_COUNTRY_CODE = 44,
-
- /* generic attributes */
- EXTRACTOR_METATYPE_UNKNOWN = 45,
- EXTRACTOR_METATYPE_DESCRIPTION = 46,
- EXTRACTOR_METATYPE_COPYRIGHT = 47,
- EXTRACTOR_METATYPE_RIGHTS = 48,
- EXTRACTOR_METATYPE_KEYWORDS = 49,
- EXTRACTOR_METATYPE_ABSTRACT = 50,
- EXTRACTOR_METATYPE_SUMMARY = 51,
- EXTRACTOR_METATYPE_SUBJECT = 52,
- EXTRACTOR_METATYPE_CREATOR = 53,
- EXTRACTOR_METATYPE_FORMAT = 54,
- EXTRACTOR_METATYPE_FORMAT_VERSION = 55,
-
- /* processing history */
- EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE = 56,
- EXTRACTOR_METATYPE_UNKNOWN_DATE = 57,
- EXTRACTOR_METATYPE_CREATION_DATE = 58,
- EXTRACTOR_METATYPE_MODIFICATION_DATE = 59,
- EXTRACTOR_METATYPE_LAST_PRINTED = 60,
- EXTRACTOR_METATYPE_LAST_SAVED_BY = 61,
- EXTRACTOR_METATYPE_TOTAL_EDITING_TIME = 62,
- EXTRACTOR_METATYPE_EDITING_CYCLES = 63,
- EXTRACTOR_METATYPE_MODIFIED_BY_SOFTWARE = 64,
- EXTRACTOR_METATYPE_REVISION_HISTORY = 65,
-
- EXTRACTOR_METATYPE_EMBEDDED_FILE_SIZE = 66,
- EXTRACTOR_METATYPE_FINDER_FILE_TYPE = 67,
- EXTRACTOR_METATYPE_FINDER_FILE_CREATOR = 68,
-
- /* software package specifics (deb, rpm, tgz, elf) */
- EXTRACTOR_METATYPE_PACKAGE_NAME = 69,
- EXTRACTOR_METATYPE_PACKAGE_VERSION = 70,
- EXTRACTOR_METATYPE_SECTION = 71,
- EXTRACTOR_METATYPE_UPLOAD_PRIORITY = 72,
- EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY = 73,
- EXTRACTOR_METATYPE_PACKAGE_CONFLICTS = 74,
- EXTRACTOR_METATYPE_PACKAGE_REPLACES = 75,
- EXTRACTOR_METATYPE_PACKAGE_PROVIDES = 76,
- EXTRACTOR_METATYPE_PACKAGE_RECOMMENDS = 77,
- EXTRACTOR_METATYPE_PACKAGE_SUGGESTS = 78,
- EXTRACTOR_METATYPE_PACKAGE_MAINTAINER = 79,
- EXTRACTOR_METATYPE_PACKAGE_INSTALLED_SIZE = 80,
- EXTRACTOR_METATYPE_PACKAGE_SOURCE = 81,
- EXTRACTOR_METATYPE_PACKAGE_ESSENTIAL = 82,
- EXTRACTOR_METATYPE_TARGET_ARCHITECTURE = 83,
- EXTRACTOR_METATYPE_PACKAGE_PRE_DEPENDENCY = 84,
- EXTRACTOR_METATYPE_LICENSE = 85,
- EXTRACTOR_METATYPE_PACKAGE_DISTRIBUTION = 86,
- EXTRACTOR_METATYPE_BUILDHOST = 87,
- EXTRACTOR_METATYPE_VENDOR = 88,
- EXTRACTOR_METATYPE_TARGET_OS = 89,
- EXTRACTOR_METATYPE_SOFTWARE_VERSION = 90,
- EXTRACTOR_METATYPE_TARGET_PLATFORM = 91,
- EXTRACTOR_METATYPE_RESOURCE_TYPE = 92,
- EXTRACTOR_METATYPE_LIBRARY_SEARCH_PATH = 93,
- EXTRACTOR_METATYPE_LIBRARY_DEPENDENCY = 94,
-
- /* photography specifics */
- EXTRACTOR_METATYPE_CAMERA_MAKE = 95,
- EXTRACTOR_METATYPE_CAMERA_MODEL = 96,
- EXTRACTOR_METATYPE_EXPOSURE = 97,
- EXTRACTOR_METATYPE_APERTURE = 98,
- EXTRACTOR_METATYPE_EXPOSURE_BIAS = 99,
- EXTRACTOR_METATYPE_FLASH = 100,
- EXTRACTOR_METATYPE_FLASH_BIAS = 101,
- EXTRACTOR_METATYPE_FOCAL_LENGTH = 102,
- EXTRACTOR_METATYPE_FOCAL_LENGTH_35MM = 103,
- EXTRACTOR_METATYPE_ISO_SPEED = 104,
- EXTRACTOR_METATYPE_EXPOSURE_MODE = 105,
- EXTRACTOR_METATYPE_METERING_MODE = 106,
- EXTRACTOR_METATYPE_MACRO_MODE = 107,
- EXTRACTOR_METATYPE_IMAGE_QUALITY = 108,
- EXTRACTOR_METATYPE_WHITE_BALANCE = 109,
- EXTRACTOR_METATYPE_ORIENTATION = 110,
- EXTRACTOR_METATYPE_MAGNIFICATION = 111,
-
- /* image specifics */
- EXTRACTOR_METATYPE_IMAGE_DIMENSIONS = 112,
- EXTRACTOR_METATYPE_PRODUCED_BY_SOFTWARE = 113,
- EXTRACTOR_METATYPE_THUMBNAIL = 114,
- EXTRACTOR_METATYPE_IMAGE_RESOLUTION = 115,
- EXTRACTOR_METATYPE_SOURCE = 116,
-
- /* (text) document processing specifics */
- EXTRACTOR_METATYPE_CHARACTER_SET = 117,
- EXTRACTOR_METATYPE_LINE_COUNT = 118,
- EXTRACTOR_METATYPE_PARAGRAPH_COUNT = 119,
- EXTRACTOR_METATYPE_WORD_COUNT = 120,
- EXTRACTOR_METATYPE_CHARACTER_COUNT = 121,
- EXTRACTOR_METATYPE_PAGE_ORIENTATION = 122,
- EXTRACTOR_METATYPE_PAPER_SIZE = 123,
- EXTRACTOR_METATYPE_TEMPLATE = 124,
- EXTRACTOR_METATYPE_COMPANY = 125,
- EXTRACTOR_METATYPE_MANAGER = 126,
- EXTRACTOR_METATYPE_REVISION_NUMBER = 127,
-
- /* music / video specifics */
- EXTRACTOR_METATYPE_DURATION = 128,
- EXTRACTOR_METATYPE_ALBUM = 129,
- EXTRACTOR_METATYPE_ARTIST = 130,
- EXTRACTOR_METATYPE_GENRE = 131,
- EXTRACTOR_METATYPE_TRACK_NUMBER = 132,
- EXTRACTOR_METATYPE_DISC_NUMBER = 133,
- EXTRACTOR_METATYPE_PERFORMER = 134,
- EXTRACTOR_METATYPE_CONTACT_INFORMATION = 135,
- EXTRACTOR_METATYPE_SONG_VERSION = 136,
- EXTRACTOR_METATYPE_PICTURE = 137,
- EXTRACTOR_METATYPE_COVER_PICTURE = 138,
- EXTRACTOR_METATYPE_CONTRIBUTOR_PICTURE = 139,
- EXTRACTOR_METATYPE_EVENT_PICTURE = 140,
- EXTRACTOR_METATYPE_LOGO = 141,
- EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM = 142,
- EXTRACTOR_METATYPE_SOURCE_DEVICE = 143,
- EXTRACTOR_METATYPE_DISCLAIMER = 144,
- EXTRACTOR_METATYPE_WARNING = 145,
- EXTRACTOR_METATYPE_PAGE_ORDER = 146,
- EXTRACTOR_METATYPE_WRITER = 147,
- EXTRACTOR_METATYPE_PRODUCT_VERSION = 148,
- EXTRACTOR_METATYPE_CONTRIBUTOR_NAME = 149,
- EXTRACTOR_METATYPE_MOVIE_DIRECTOR = 150,
- EXTRACTOR_METATYPE_NETWORK_NAME = 151,
- EXTRACTOR_METATYPE_SHOW_NAME = 152,
- EXTRACTOR_METATYPE_CHAPTER_NAME = 153,
- EXTRACTOR_METATYPE_SONG_COUNT = 154,
- EXTRACTOR_METATYPE_STARTING_SONG = 155,
- EXTRACTOR_METATYPE_PLAY_COUNTER = 156,
- EXTRACTOR_METATYPE_CONDUCTOR = 157,
- EXTRACTOR_METATYPE_INTERPRETATION = 158,
- EXTRACTOR_METATYPE_COMPOSER = 159,
- EXTRACTOR_METATYPE_BEATS_PER_MINUTE = 160,
- EXTRACTOR_METATYPE_ENCODED_BY = 161,
- EXTRACTOR_METATYPE_ORIGINAL_TITLE = 162,
- EXTRACTOR_METATYPE_ORIGINAL_ARTIST = 163,
- EXTRACTOR_METATYPE_ORIGINAL_WRITER = 164,
- EXTRACTOR_METATYPE_ORIGINAL_RELEASE_YEAR = 165,
- EXTRACTOR_METATYPE_ORIGINAL_PERFORMER = 166,
- EXTRACTOR_METATYPE_LYRICS = 167,
- EXTRACTOR_METATYPE_POPULARITY_METER = 168,
- EXTRACTOR_METATYPE_LICENSEE = 169,
- EXTRACTOR_METATYPE_MUSICIAN_CREDITS_LIST = 170,
- EXTRACTOR_METATYPE_MOOD = 171,
- EXTRACTOR_METATYPE_SUBTITLE = 172,
-
- /* GNUnet specific values (never extracted) */
- EXTRACTOR_METATYPE_GNUNET_DISPLAY_TYPE = 173,
- EXTRACTOR_METATYPE_GNUNET_FULL_DATA = 174,
- EXTRACTOR_METATYPE_RATING = 175,
- EXTRACTOR_METATYPE_ORGANIZATION = 176,
- EXTRACTOR_METATYPE_RIPPER = 177,
- EXTRACTOR_METATYPE_PRODUCER = 178,
- EXTRACTOR_METATYPE_GROUP = 179,
- EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME = 180,
-
- EXTRACTOR_METATYPE_DISC_COUNT = 181,
-
- EXTRACTOR_METATYPE_CODEC = 182,
- EXTRACTOR_METATYPE_VIDEO_CODEC = 183,
- EXTRACTOR_METATYPE_AUDIO_CODEC = 184,
- EXTRACTOR_METATYPE_SUBTITLE_CODEC = 185,
-
- EXTRACTOR_METATYPE_CONTAINER_FORMAT = 186,
-
- EXTRACTOR_METATYPE_BITRATE = 187,
- EXTRACTOR_METATYPE_NOMINAL_BITRATE = 188,
- EXTRACTOR_METATYPE_MINIMUM_BITRATE = 189,
- EXTRACTOR_METATYPE_MAXIMUM_BITRATE = 190,
-
- EXTRACTOR_METATYPE_SERIAL = 191,
-
- EXTRACTOR_METATYPE_ENCODER = 192,
- EXTRACTOR_METATYPE_ENCODER_VERSION = 193,
-
- EXTRACTOR_METATYPE_TRACK_GAIN = 194,
- EXTRACTOR_METATYPE_TRACK_PEAK = 195,
- EXTRACTOR_METATYPE_ALBUM_GAIN = 196,
- EXTRACTOR_METATYPE_ALBUM_PEAK = 197,
- EXTRACTOR_METATYPE_REFERENCE_LEVEL = 198,
-
- EXTRACTOR_METATYPE_LOCATION_NAME = 199,
- EXTRACTOR_METATYPE_LOCATION_ELEVATION = 200,
- EXTRACTOR_METATYPE_LOCATION_HORIZONTAL_ERROR = 201,
- EXTRACTOR_METATYPE_LOCATION_MOVEMENT_SPEED = 202,
- EXTRACTOR_METATYPE_LOCATION_MOVEMENT_DIRECTION = 203,
- EXTRACTOR_METATYPE_LOCATION_CAPTURE_DIRECTION = 204,
-
- EXTRACTOR_METATYPE_SHOW_EPISODE_NUMBER = 205,
- EXTRACTOR_METATYPE_SHOW_SEASON_NUMBER = 206,
-
- EXTRACTOR_METATYPE_GROUPING = 207,
-
- EXTRACTOR_METATYPE_DEVICE_MANUFACTURER = 208,
- EXTRACTOR_METATYPE_DEVICE_MODEL = 209,
-
- EXTRACTOR_METATYPE_AUDIO_LANGUAGE = 210,
- EXTRACTOR_METATYPE_CHANNELS = 211,
- EXTRACTOR_METATYPE_SAMPLE_RATE = 212,
- EXTRACTOR_METATYPE_AUDIO_DEPTH = 213,
- EXTRACTOR_METATYPE_AUDIO_BITRATE = 214,
- EXTRACTOR_METATYPE_MAXIMUM_AUDIO_BITRATE = 215,
-
- EXTRACTOR_METATYPE_VIDEO_DIMENSIONS = 216,
- EXTRACTOR_METATYPE_VIDEO_DEPTH = 217,
- EXTRACTOR_METATYPE_FRAME_RATE = 218,
- EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO = 219,
- EXTRACTOR_METATYPE_VIDEO_BITRATE = 220,
- EXTRACTOR_METATYPE_MAXIMUM_VIDEO_BITRATE = 221,
-
- EXTRACTOR_METATYPE_SUBTITLE_LANGUAGE = 222,
- EXTRACTOR_METATYPE_VIDEO_LANGUAGE = 223,
-
- EXTRACTOR_METATYPE_TOC = 224,
-
- EXTRACTOR_METATYPE_VIDEO_DURATION = 225,
- EXTRACTOR_METATYPE_AUDIO_DURATION = 226,
- EXTRACTOR_METATYPE_SUBTITLE_DURATION = 227,
-
- EXTRACTOR_METATYPE_AUDIO_PREVIEW = 228,
-
- EXTRACTOR_METATYPE_NARINFO = 229,
- EXTRACTOR_METATYPE_NAR = 230,
-
- EXTRACTOR_METATYPE_LAST = 231
- };
+{
+ /* fundamental types */
+ EXTRACTOR_METATYPE_RESERVED = 0,
+ EXTRACTOR_METATYPE_MIMETYPE = 1,
+ EXTRACTOR_METATYPE_FILENAME = 2,
+ EXTRACTOR_METATYPE_COMMENT = 3,
+
+ /* Standard types from bibtex */
+ EXTRACTOR_METATYPE_TITLE = 4,
+ EXTRACTOR_METATYPE_BOOK_TITLE = 5,
+ EXTRACTOR_METATYPE_BOOK_EDITION = 6,
+ EXTRACTOR_METATYPE_BOOK_CHAPTER_NUMBER = 7,
+ EXTRACTOR_METATYPE_JOURNAL_NAME = 8,
+ EXTRACTOR_METATYPE_JOURNAL_VOLUME = 9,
+ EXTRACTOR_METATYPE_JOURNAL_NUMBER = 10,
+ EXTRACTOR_METATYPE_PAGE_COUNT = 11,
+ EXTRACTOR_METATYPE_PAGE_RANGE = 12,
+ EXTRACTOR_METATYPE_AUTHOR_NAME = 13,
+ EXTRACTOR_METATYPE_AUTHOR_EMAIL = 14,
+ EXTRACTOR_METATYPE_AUTHOR_INSTITUTION = 15,
+ EXTRACTOR_METATYPE_PUBLISHER = 16,
+ EXTRACTOR_METATYPE_PUBLISHER_ADDRESS = 17,
+ EXTRACTOR_METATYPE_PUBLISHER_INSTITUTION = 18,
+ EXTRACTOR_METATYPE_PUBLISHER_SERIES = 19,
+ EXTRACTOR_METATYPE_PUBLICATION_TYPE = 20,
+ EXTRACTOR_METATYPE_PUBLICATION_YEAR = 21,
+ EXTRACTOR_METATYPE_PUBLICATION_MONTH = 22,
+ EXTRACTOR_METATYPE_PUBLICATION_DAY = 23,
+ EXTRACTOR_METATYPE_PUBLICATION_DATE = 24,
+ EXTRACTOR_METATYPE_BIBTEX_EPRINT = 25,
+ EXTRACTOR_METATYPE_BIBTEX_ENTRY_TYPE = 26,
+ EXTRACTOR_METATYPE_LANGUAGE = 27,
+ EXTRACTOR_METATYPE_CREATION_TIME = 28,
+ EXTRACTOR_METATYPE_URL = 29,
+
+ /* "unique" document identifiers */
+ EXTRACTOR_METATYPE_URI = 30,
+ EXTRACTOR_METATYPE_ISRC = 31,
+ EXTRACTOR_METATYPE_HASH_MD4 = 32,
+ EXTRACTOR_METATYPE_HASH_MD5 = 33,
+ EXTRACTOR_METATYPE_HASH_SHA0 = 34,
+ EXTRACTOR_METATYPE_HASH_SHA1 = 35,
+ EXTRACTOR_METATYPE_HASH_RMD160 = 36,
+
+ /* identifiers of a location */
+ EXTRACTOR_METATYPE_GPS_LATITUDE_REF = 37,
+ EXTRACTOR_METATYPE_GPS_LATITUDE = 38,
+ EXTRACTOR_METATYPE_GPS_LONGITUDE_REF = 39,
+ EXTRACTOR_METATYPE_GPS_LONGITUDE = 40,
+ EXTRACTOR_METATYPE_LOCATION_CITY = 41,
+ EXTRACTOR_METATYPE_LOCATION_SUBLOCATION = 42,
+ EXTRACTOR_METATYPE_LOCATION_COUNTRY = 43,
+ EXTRACTOR_METATYPE_LOCATION_COUNTRY_CODE = 44,
+
+ /* generic attributes */
+ EXTRACTOR_METATYPE_UNKNOWN = 45,
+ EXTRACTOR_METATYPE_DESCRIPTION = 46,
+ EXTRACTOR_METATYPE_COPYRIGHT = 47,
+ EXTRACTOR_METATYPE_RIGHTS = 48,
+ EXTRACTOR_METATYPE_KEYWORDS = 49,
+ EXTRACTOR_METATYPE_ABSTRACT = 50,
+ EXTRACTOR_METATYPE_SUMMARY = 51,
+ EXTRACTOR_METATYPE_SUBJECT = 52,
+ EXTRACTOR_METATYPE_CREATOR = 53,
+ EXTRACTOR_METATYPE_FORMAT = 54,
+ EXTRACTOR_METATYPE_FORMAT_VERSION = 55,
+
+ /* processing history */
+ EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE = 56,
+ EXTRACTOR_METATYPE_UNKNOWN_DATE = 57,
+ EXTRACTOR_METATYPE_CREATION_DATE = 58,
+ EXTRACTOR_METATYPE_MODIFICATION_DATE = 59,
+ EXTRACTOR_METATYPE_LAST_PRINTED = 60,
+ EXTRACTOR_METATYPE_LAST_SAVED_BY = 61,
+ EXTRACTOR_METATYPE_TOTAL_EDITING_TIME = 62,
+ EXTRACTOR_METATYPE_EDITING_CYCLES = 63,
+ EXTRACTOR_METATYPE_MODIFIED_BY_SOFTWARE = 64,
+ EXTRACTOR_METATYPE_REVISION_HISTORY = 65,
+
+ EXTRACTOR_METATYPE_EMBEDDED_FILE_SIZE = 66,
+ EXTRACTOR_METATYPE_FINDER_FILE_TYPE = 67,
+ EXTRACTOR_METATYPE_FINDER_FILE_CREATOR = 68,
+
+ /* software package specifics (deb, rpm, tgz, elf) */
+ EXTRACTOR_METATYPE_PACKAGE_NAME = 69,
+ EXTRACTOR_METATYPE_PACKAGE_VERSION = 70,
+ EXTRACTOR_METATYPE_SECTION = 71,
+ EXTRACTOR_METATYPE_UPLOAD_PRIORITY = 72,
+ EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY = 73,
+ EXTRACTOR_METATYPE_PACKAGE_CONFLICTS = 74,
+ EXTRACTOR_METATYPE_PACKAGE_REPLACES = 75,
+ EXTRACTOR_METATYPE_PACKAGE_PROVIDES = 76,
+ EXTRACTOR_METATYPE_PACKAGE_RECOMMENDS = 77,
+ EXTRACTOR_METATYPE_PACKAGE_SUGGESTS = 78,
+ EXTRACTOR_METATYPE_PACKAGE_MAINTAINER = 79,
+ EXTRACTOR_METATYPE_PACKAGE_INSTALLED_SIZE = 80,
+ EXTRACTOR_METATYPE_PACKAGE_SOURCE = 81,
+ EXTRACTOR_METATYPE_PACKAGE_ESSENTIAL = 82,
+ EXTRACTOR_METATYPE_TARGET_ARCHITECTURE = 83,
+ EXTRACTOR_METATYPE_PACKAGE_PRE_DEPENDENCY = 84,
+ EXTRACTOR_METATYPE_LICENSE = 85,
+ EXTRACTOR_METATYPE_PACKAGE_DISTRIBUTION = 86,
+ EXTRACTOR_METATYPE_BUILDHOST = 87,
+ EXTRACTOR_METATYPE_VENDOR = 88,
+ EXTRACTOR_METATYPE_TARGET_OS = 89,
+ EXTRACTOR_METATYPE_SOFTWARE_VERSION = 90,
+ EXTRACTOR_METATYPE_TARGET_PLATFORM = 91,
+ EXTRACTOR_METATYPE_RESOURCE_TYPE = 92,
+ EXTRACTOR_METATYPE_LIBRARY_SEARCH_PATH = 93,
+ EXTRACTOR_METATYPE_LIBRARY_DEPENDENCY = 94,
+
+ /* photography specifics */
+ EXTRACTOR_METATYPE_CAMERA_MAKE = 95,
+ EXTRACTOR_METATYPE_CAMERA_MODEL = 96,
+ EXTRACTOR_METATYPE_EXPOSURE = 97,
+ EXTRACTOR_METATYPE_APERTURE = 98,
+ EXTRACTOR_METATYPE_EXPOSURE_BIAS = 99,
+ EXTRACTOR_METATYPE_FLASH = 100,
+ EXTRACTOR_METATYPE_FLASH_BIAS = 101,
+ EXTRACTOR_METATYPE_FOCAL_LENGTH = 102,
+ EXTRACTOR_METATYPE_FOCAL_LENGTH_35MM = 103,
+ EXTRACTOR_METATYPE_ISO_SPEED = 104,
+ EXTRACTOR_METATYPE_EXPOSURE_MODE = 105,
+ EXTRACTOR_METATYPE_METERING_MODE = 106,
+ EXTRACTOR_METATYPE_MACRO_MODE = 107,
+ EXTRACTOR_METATYPE_IMAGE_QUALITY = 108,
+ EXTRACTOR_METATYPE_WHITE_BALANCE = 109,
+ EXTRACTOR_METATYPE_ORIENTATION = 110,
+ EXTRACTOR_METATYPE_MAGNIFICATION = 111,
+
+ /* image specifics */
+ EXTRACTOR_METATYPE_IMAGE_DIMENSIONS = 112,
+ EXTRACTOR_METATYPE_PRODUCED_BY_SOFTWARE = 113,
+ EXTRACTOR_METATYPE_THUMBNAIL = 114,
+ EXTRACTOR_METATYPE_IMAGE_RESOLUTION = 115,
+ EXTRACTOR_METATYPE_SOURCE = 116,
+
+ /* (text) document processing specifics */
+ EXTRACTOR_METATYPE_CHARACTER_SET = 117,
+ EXTRACTOR_METATYPE_LINE_COUNT = 118,
+ EXTRACTOR_METATYPE_PARAGRAPH_COUNT = 119,
+ EXTRACTOR_METATYPE_WORD_COUNT = 120,
+ EXTRACTOR_METATYPE_CHARACTER_COUNT = 121,
+ EXTRACTOR_METATYPE_PAGE_ORIENTATION = 122,
+ EXTRACTOR_METATYPE_PAPER_SIZE = 123,
+ EXTRACTOR_METATYPE_TEMPLATE = 124,
+ EXTRACTOR_METATYPE_COMPANY = 125,
+ EXTRACTOR_METATYPE_MANAGER = 126,
+ EXTRACTOR_METATYPE_REVISION_NUMBER = 127,
+
+ /* music / video specifics */
+ EXTRACTOR_METATYPE_DURATION = 128,
+ EXTRACTOR_METATYPE_ALBUM = 129,
+ EXTRACTOR_METATYPE_ARTIST = 130,
+ EXTRACTOR_METATYPE_GENRE = 131,
+ EXTRACTOR_METATYPE_TRACK_NUMBER = 132,
+ EXTRACTOR_METATYPE_DISC_NUMBER = 133,
+ EXTRACTOR_METATYPE_PERFORMER = 134,
+ EXTRACTOR_METATYPE_CONTACT_INFORMATION = 135,
+ EXTRACTOR_METATYPE_SONG_VERSION = 136,
+ EXTRACTOR_METATYPE_PICTURE = 137,
+ EXTRACTOR_METATYPE_COVER_PICTURE = 138,
+ EXTRACTOR_METATYPE_CONTRIBUTOR_PICTURE = 139,
+ EXTRACTOR_METATYPE_EVENT_PICTURE = 140,
+ EXTRACTOR_METATYPE_LOGO = 141,
+ EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM = 142,
+ EXTRACTOR_METATYPE_SOURCE_DEVICE = 143,
+ EXTRACTOR_METATYPE_DISCLAIMER = 144,
+ EXTRACTOR_METATYPE_WARNING = 145,
+ EXTRACTOR_METATYPE_PAGE_ORDER = 146,
+ EXTRACTOR_METATYPE_WRITER = 147,
+ EXTRACTOR_METATYPE_PRODUCT_VERSION = 148,
+ EXTRACTOR_METATYPE_CONTRIBUTOR_NAME = 149,
+ EXTRACTOR_METATYPE_MOVIE_DIRECTOR = 150,
+ EXTRACTOR_METATYPE_NETWORK_NAME = 151,
+ EXTRACTOR_METATYPE_SHOW_NAME = 152,
+ EXTRACTOR_METATYPE_CHAPTER_NAME = 153,
+ EXTRACTOR_METATYPE_SONG_COUNT = 154,
+ EXTRACTOR_METATYPE_STARTING_SONG = 155,
+ EXTRACTOR_METATYPE_PLAY_COUNTER = 156,
+ EXTRACTOR_METATYPE_CONDUCTOR = 157,
+ EXTRACTOR_METATYPE_INTERPRETATION = 158,
+ EXTRACTOR_METATYPE_COMPOSER = 159,
+ EXTRACTOR_METATYPE_BEATS_PER_MINUTE = 160,
+ EXTRACTOR_METATYPE_ENCODED_BY = 161,
+ EXTRACTOR_METATYPE_ORIGINAL_TITLE = 162,
+ EXTRACTOR_METATYPE_ORIGINAL_ARTIST = 163,
+ EXTRACTOR_METATYPE_ORIGINAL_WRITER = 164,
+ EXTRACTOR_METATYPE_ORIGINAL_RELEASE_YEAR = 165,
+ EXTRACTOR_METATYPE_ORIGINAL_PERFORMER = 166,
+ EXTRACTOR_METATYPE_LYRICS = 167,
+ EXTRACTOR_METATYPE_POPULARITY_METER = 168,
+ EXTRACTOR_METATYPE_LICENSEE = 169,
+ EXTRACTOR_METATYPE_MUSICIAN_CREDITS_LIST = 170,
+ EXTRACTOR_METATYPE_MOOD = 171,
+ EXTRACTOR_METATYPE_SUBTITLE = 172,
+
+ /* GNUnet specific values (never extracted) */
+ EXTRACTOR_METATYPE_GNUNET_DISPLAY_TYPE = 173,
+ EXTRACTOR_METATYPE_GNUNET_FULL_DATA = 174,
+ EXTRACTOR_METATYPE_RATING = 175,
+ EXTRACTOR_METATYPE_ORGANIZATION = 176,
+ EXTRACTOR_METATYPE_RIPPER = 177,
+ EXTRACTOR_METATYPE_PRODUCER = 178,
+ EXTRACTOR_METATYPE_GROUP = 179,
+ EXTRACTOR_METATYPE_GNUNET_ORIGINAL_FILENAME = 180,
+
+ EXTRACTOR_METATYPE_DISC_COUNT = 181,
+
+ EXTRACTOR_METATYPE_CODEC = 182,
+ EXTRACTOR_METATYPE_VIDEO_CODEC = 183,
+ EXTRACTOR_METATYPE_AUDIO_CODEC = 184,
+ EXTRACTOR_METATYPE_SUBTITLE_CODEC = 185,
+
+ EXTRACTOR_METATYPE_CONTAINER_FORMAT = 186,
+
+ EXTRACTOR_METATYPE_BITRATE = 187,
+ EXTRACTOR_METATYPE_NOMINAL_BITRATE = 188,
+ EXTRACTOR_METATYPE_MINIMUM_BITRATE = 189,
+ EXTRACTOR_METATYPE_MAXIMUM_BITRATE = 190,
+
+ EXTRACTOR_METATYPE_SERIAL = 191,
+
+ EXTRACTOR_METATYPE_ENCODER = 192,
+ EXTRACTOR_METATYPE_ENCODER_VERSION = 193,
+
+ EXTRACTOR_METATYPE_TRACK_GAIN = 194,
+ EXTRACTOR_METATYPE_TRACK_PEAK = 195,
+ EXTRACTOR_METATYPE_ALBUM_GAIN = 196,
+ EXTRACTOR_METATYPE_ALBUM_PEAK = 197,
+ EXTRACTOR_METATYPE_REFERENCE_LEVEL = 198,
+
+ EXTRACTOR_METATYPE_LOCATION_NAME = 199,
+ EXTRACTOR_METATYPE_LOCATION_ELEVATION = 200,
+ EXTRACTOR_METATYPE_LOCATION_HORIZONTAL_ERROR = 201,
+ EXTRACTOR_METATYPE_LOCATION_MOVEMENT_SPEED = 202,
+ EXTRACTOR_METATYPE_LOCATION_MOVEMENT_DIRECTION = 203,
+ EXTRACTOR_METATYPE_LOCATION_CAPTURE_DIRECTION = 204,
+
+ EXTRACTOR_METATYPE_SHOW_EPISODE_NUMBER = 205,
+ EXTRACTOR_METATYPE_SHOW_SEASON_NUMBER = 206,
+
+ EXTRACTOR_METATYPE_GROUPING = 207,
+
+ EXTRACTOR_METATYPE_DEVICE_MANUFACTURER = 208,
+ EXTRACTOR_METATYPE_DEVICE_MODEL = 209,
+
+ EXTRACTOR_METATYPE_AUDIO_LANGUAGE = 210,
+ EXTRACTOR_METATYPE_CHANNELS = 211,
+ EXTRACTOR_METATYPE_SAMPLE_RATE = 212,
+ EXTRACTOR_METATYPE_AUDIO_DEPTH = 213,
+ EXTRACTOR_METATYPE_AUDIO_BITRATE = 214,
+ EXTRACTOR_METATYPE_MAXIMUM_AUDIO_BITRATE = 215,
+
+ EXTRACTOR_METATYPE_VIDEO_DIMENSIONS = 216,
+ EXTRACTOR_METATYPE_VIDEO_DEPTH = 217,
+ EXTRACTOR_METATYPE_FRAME_RATE = 218,
+ EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO = 219,
+ EXTRACTOR_METATYPE_VIDEO_BITRATE = 220,
+ EXTRACTOR_METATYPE_MAXIMUM_VIDEO_BITRATE = 221,
+
+ EXTRACTOR_METATYPE_SUBTITLE_LANGUAGE = 222,
+ EXTRACTOR_METATYPE_VIDEO_LANGUAGE = 223,
+
+ EXTRACTOR_METATYPE_TOC = 224,
+
+ EXTRACTOR_METATYPE_VIDEO_DURATION = 225,
+ EXTRACTOR_METATYPE_AUDIO_DURATION = 226,
+ EXTRACTOR_METATYPE_SUBTITLE_DURATION = 227,
+
+ EXTRACTOR_METATYPE_AUDIO_PREVIEW = 228,
+
+ EXTRACTOR_METATYPE_NARINFO = 229,
+ EXTRACTOR_METATYPE_NAR = 230,
+
+ EXTRACTOR_METATYPE_LAST = 231
+};
/** @} */ /* end of meta data types */
@@ -492,8 +492,8 @@ struct EXTRACTOR_ExtractContext
* -1 on error
*/
ssize_t (*read) (void *cls,
- void **data,
- size_t size);
+ void **data,
+ size_t size);
/**
@@ -507,8 +507,8 @@ struct EXTRACTOR_ExtractContext
* does not exist)
*/
int64_t (*seek) (void *cls,
- int64_t pos,
- int whence);
+ int64_t pos,
+ int whence);
/**
@@ -581,10 +581,10 @@ EXTRACTOR_plugin_add_defaults (enum EXTRACTOR_Options flags);
* @return the new list of libraries, equal to prev iff an error occured
*/
_EXTRACTOR_EXTERN struct EXTRACTOR_PluginList *
-EXTRACTOR_plugin_add (struct EXTRACTOR_PluginList * prev,
- const char *library,
- const char *options,
- enum EXTRACTOR_Options flags);
+EXTRACTOR_plugin_add (struct EXTRACTOR_PluginList *prev,
+ const char *library,
+ const char *options,
+ enum EXTRACTOR_Options flags);
/**
@@ -604,8 +604,8 @@ EXTRACTOR_plugin_add (struct EXTRACTOR_PluginList * prev,
*/
_EXTRACTOR_EXTERN struct EXTRACTOR_PluginList *
EXTRACTOR_plugin_add_config (struct EXTRACTOR_PluginList *prev,
- const char *config,
- enum EXTRACTOR_Options flags);
+ const char *config,
+ enum EXTRACTOR_Options flags);
/**
@@ -617,7 +617,7 @@ EXTRACTOR_plugin_add_config (struct EXTRACTOR_PluginList *prev,
*/
_EXTRACTOR_EXTERN struct EXTRACTOR_PluginList *
EXTRACTOR_plugin_remove (struct EXTRACTOR_PluginList *prev,
- const char *library);
+ const char *library);
/**
@@ -642,11 +642,11 @@ EXTRACTOR_plugin_remove_all (struct EXTRACTOR_PluginList *plugins);
*/
_EXTRACTOR_EXTERN void
EXTRACTOR_extract (struct EXTRACTOR_PluginList *plugins,
- const char *filename,
- const void *data,
- size_t size,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls);
+ const char *filename,
+ const void *data,
+ size_t size,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls);
/**
@@ -667,12 +667,12 @@ EXTRACTOR_extract (struct EXTRACTOR_PluginList *plugins,
*/
_EXTRACTOR_EXTERN int
EXTRACTOR_meta_data_print (void *handle,
- const char *plugin_name,
- enum EXTRACTOR_MetaType type,
- enum EXTRACTOR_MetaFormat format,
- const char *data_mime_type,
- const char *data,
- size_t data_len);
+ const char *plugin_name,
+ enum EXTRACTOR_MetaType type,
+ enum EXTRACTOR_MetaFormat format,
+ const char *data_mime_type,
+ const char *data,
+ size_t data_len);
#if 0 /* keep Emacsens' auto-indent happy */
diff --git a/src/include/gettext.h b/src/include/gettext.h
@@ -46,11 +46,11 @@
# define dgettext(Domainname, Msgid) ((const char *) (Msgid))
# define dcgettext(Domainname, Msgid, Category) ((const char *) (Msgid))
# define ngettext(Msgid1, Msgid2, N) \
- ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
+ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
# define dngettext(Domainname, Msgid1, Msgid2, N) \
- ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
+ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
# define dcngettext(Domainname, Msgid1, Msgid2, N, Category) \
- ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
+ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2))
/* slight modification here to avoid warnings: generate NO code,
not even the cast... */
# define textdomain(Domainname)
diff --git a/src/include/platform.h b/src/include/platform.h
@@ -29,10 +29,10 @@
#include "config.h"
#ifndef FRAMEWORK_BUILD
#include "gettext.h"
-#define _(a) dgettext(PACKAGE, a)
+#define _(a) dgettext (PACKAGE, a)
#else
#include "libintlemu.h"
-#define _(a) dgettext("org.gnunet.libextractor", a)
+#define _(a) dgettext ("org.gnunet.libextractor", a)
#endif
#include "plibc.h"
@@ -67,7 +67,7 @@
#include <langinfo.h>
#ifndef SIZE_MAX
-#define SIZE_MAX ((size_t)-1)
+#define SIZE_MAX ((size_t) -1)
#endif
#if DARWIN
@@ -75,12 +75,11 @@
#include <mach-o/ldsyms.h>
#endif
-#if !WINDOWS
-#define ABORT() abort()
+#if ! WINDOWS
+#define ABORT() abort ()
#else
#define ABORT() DebugBreak ()
#endif
-
#endif
diff --git a/src/include/plibc.h b/src/include/plibc.h
@@ -2,19 +2,19 @@
This file is part of PlibC.
Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Nils Durner (and other contributing authors)
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
@@ -68,27 +68,28 @@ extern "C" {
#define __G_WIN32_H__
/* Convert LARGE_INTEGER to double */
-#define Li2Double(x) ((double)((x).HighPart) * 4.294967296E9 + \
- (double)((x).LowPart))
+#define Li2Double(x) ((double) ((x).HighPart) * 4.294967296E9 \
+ + (double) ((x).LowPart))
#ifndef HAVE_DECL__STATI64
struct _stati64
{
- _dev_t st_dev;
- _ino_t st_ino;
- _mode_t st_mode;
- short st_nlink;
- short st_uid;
- short st_gid;
- _dev_t st_rdev;
- __int64 st_size;
- time_t st_atime;
- time_t st_mtime;
- time_t st_ctime;
+ _dev_t st_dev;
+ _ino_t st_ino;
+ _mode_t st_mode;
+ short st_nlink;
+ short st_uid;
+ short st_gid;
+ _dev_t st_rdev;
+ __int64 st_size;
+ time_t st_atime;
+ time_t st_mtime;
+ time_t st_ctime;
};
#endif
typedef unsigned int sa_family_t;
-struct sockaddr_un {
+struct sockaddr_un
+{
short sun_family; /*AF_UNIX*/
char sun_path[108]; /*path name */
};
@@ -102,7 +103,7 @@ struct sockaddr_un {
#endif
#ifndef WEXITSTATUS
- #define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
+ #define WEXITSTATUS(status) (((status) & 0xff00) >> 8)
#endif
#ifndef MSG_DONTWAIT
@@ -115,258 +116,258 @@ enum
_SC_PAGE_SIZE = 30
};
-#if !defined(EACCESS)
+#if ! defined(EACCESS)
# define EACCESS EACCES
#endif
/* Thanks to the Cygwin project */
-#if !defined(ENOCSI)
-# define ENOCSI 43 /* No CSI structure available */
+#if ! defined(ENOCSI)
+# define ENOCSI 43 /* No CSI structure available */
#endif
-#if !defined(EL2HLT)
-# define EL2HLT 44 /* Level 2 halted */
+#if ! defined(EL2HLT)
+# define EL2HLT 44 /* Level 2 halted */
#endif
-#if !defined(EDEADLK)
-# define EDEADLK 45 /* Deadlock condition */
+#if ! defined(EDEADLK)
+# define EDEADLK 45 /* Deadlock condition */
#endif
-#if !defined(ENOLCK)
-# define ENOLCK 46 /* No record locks available */
+#if ! defined(ENOLCK)
+# define ENOLCK 46 /* No record locks available */
#endif
-#if !defined(EBADE)
-# define EBADE 50 /* Invalid exchange */
+#if ! defined(EBADE)
+# define EBADE 50 /* Invalid exchange */
#endif
-#if !defined(EBADR)
-# define EBADR 51 /* Invalid request descriptor */
+#if ! defined(EBADR)
+# define EBADR 51 /* Invalid request descriptor */
#endif
-#if !defined(EXFULL)
-# define EXFULL 52 /* Exchange full */
+#if ! defined(EXFULL)
+# define EXFULL 52 /* Exchange full */
#endif
-#if !defined(ENOANO)
-# define ENOANO 53 /* No anode */
+#if ! defined(ENOANO)
+# define ENOANO 53 /* No anode */
#endif
-#if !defined(EBADRQC)
-# define EBADRQC 54 /* Invalid request code */
+#if ! defined(EBADRQC)
+# define EBADRQC 54 /* Invalid request code */
#endif
-#if !defined(EBADSLT)
-# define EBADSLT 55 /* Invalid slot */
+#if ! defined(EBADSLT)
+# define EBADSLT 55 /* Invalid slot */
#endif
-#if !defined(EDEADLOCK)
-# define EDEADLOCK EDEADLK /* File locking deadlock error */
+#if ! defined(EDEADLOCK)
+# define EDEADLOCK EDEADLK /* File locking deadlock error */
#endif
-#if !defined(EBFONT)
-# define EBFONT 57 /* Bad font file fmt */
+#if ! defined(EBFONT)
+# define EBFONT 57 /* Bad font file fmt */
#endif
-#if !defined(ENOSTR)
-# define ENOSTR 60 /* Device not a stream */
+#if ! defined(ENOSTR)
+# define ENOSTR 60 /* Device not a stream */
#endif
-#if !defined(ENODATA)
-# define ENODATA 61 /* No data (for no delay io) */
+#if ! defined(ENODATA)
+# define ENODATA 61 /* No data (for no delay io) */
#endif
-#if !defined(ETIME)
-# define ETIME 62 /* Timer expired */
+#if ! defined(ETIME)
+# define ETIME 62 /* Timer expired */
#endif
-#if !defined(ENOSR)
-# define ENOSR 63 /* Out of streams resources */
+#if ! defined(ENOSR)
+# define ENOSR 63 /* Out of streams resources */
#endif
-#if !defined(ENONET)
-# define ENONET 64 /* Machine is not on the network */
+#if ! defined(ENONET)
+# define ENONET 64 /* Machine is not on the network */
#endif
-#if !defined(ENOPKG)
-# define ENOPKG 65 /* Package not installed */
+#if ! defined(ENOPKG)
+# define ENOPKG 65 /* Package not installed */
#endif
-#if !defined(EREMOTE)
-# define EREMOTE 66 /* The object is remote */
+#if ! defined(EREMOTE)
+# define EREMOTE 66 /* The object is remote */
#endif
-#if !defined(ENOLINK)
-# define ENOLINK 67 /* The link has been severed */
+#if ! defined(ENOLINK)
+# define ENOLINK 67 /* The link has been severed */
#endif
-#if !defined(EADV)
-# define EADV 68 /* Advertise error */
+#if ! defined(EADV)
+# define EADV 68 /* Advertise error */
#endif
-#if !defined(ESRMNT)
-# define ESRMNT 69 /* Srmount error */
+#if ! defined(ESRMNT)
+# define ESRMNT 69 /* Srmount error */
#endif
-#if !defined(ECOMM)
-# define ECOMM 70 /* Communication error on send */
+#if ! defined(ECOMM)
+# define ECOMM 70 /* Communication error on send */
#endif
-#if !defined(EMULTIHOP)
-# define EMULTIHOP 74 /* Multihop attempted */
+#if ! defined(EMULTIHOP)
+# define EMULTIHOP 74 /* Multihop attempted */
#endif
-#if !defined(ELBIN)
-# define ELBIN 75 /* Inode is remote (not really error) */
+#if ! defined(ELBIN)
+# define ELBIN 75 /* Inode is remote (not really error) */
#endif
-#if !defined(EDOTDOT)
-# define EDOTDOT 76 /* Cross mount point (not really error) */
+#if ! defined(EDOTDOT)
+# define EDOTDOT 76 /* Cross mount point (not really error) */
#endif
-#if !defined(EBADMSG)
-# define EBADMSG 77 /* Trying to read unreadable message */
+#if ! defined(EBADMSG)
+# define EBADMSG 77 /* Trying to read unreadable message */
#endif
-#if !defined(ENOTUNIQ)
-# define ENOTUNIQ 80 /* Given log. name not unique */
+#if ! defined(ENOTUNIQ)
+# define ENOTUNIQ 80 /* Given log. name not unique */
#endif
-#if !defined(EBADFD)
-# define EBADFD 81 /* f.d. invalid for this operation */
+#if ! defined(EBADFD)
+# define EBADFD 81 /* f.d. invalid for this operation */
#endif
-#if !defined(EREMCHG)
-# define EREMCHG 82 /* Remote address changed */
+#if ! defined(EREMCHG)
+# define EREMCHG 82 /* Remote address changed */
#endif
-#if !defined(ELIBACC)
-# define ELIBACC 83 /* Can't access a needed shared lib */
+#if ! defined(ELIBACC)
+# define ELIBACC 83 /* Can't access a needed shared lib */
#endif
-#if !defined(ELIBBAD)
-# define ELIBBAD 84 /* Accessing a corrupted shared lib */
+#if ! defined(ELIBBAD)
+# define ELIBBAD 84 /* Accessing a corrupted shared lib */
#endif
-#if !defined(ELIBSCN)
-# define ELIBSCN 85 /* .lib section in a.out corrupted */
+#if ! defined(ELIBSCN)
+# define ELIBSCN 85 /* .lib section in a.out corrupted */
#endif
-#if !defined(ELIBMAX)
-# define ELIBMAX 86 /* Attempting to link in too many libs */
+#if ! defined(ELIBMAX)
+# define ELIBMAX 86 /* Attempting to link in too many libs */
#endif
-#if !defined(ELIBEXEC)
-# define ELIBEXEC 87 /* Attempting to exec a shared library */
+#if ! defined(ELIBEXEC)
+# define ELIBEXEC 87 /* Attempting to exec a shared library */
#endif
-#if !defined(ENOSYS)
-# define ENOSYS 88 /* Function not implemented */
+#if ! defined(ENOSYS)
+# define ENOSYS 88 /* Function not implemented */
#endif
-#if !defined(ENMFILE)
+#if ! defined(ENMFILE)
# define ENMFILE 89 /* No more files */
#endif
-#if !defined(ENOTEMPTY)
-# define ENOTEMPTY 90 /* Directory not empty */
+#if ! defined(ENOTEMPTY)
+# define ENOTEMPTY 90 /* Directory not empty */
#endif
-#if !defined(ENAMETOOLONG)
-# define ENAMETOOLONG 91 /* File or path name too long */
+#if ! defined(ENAMETOOLONG)
+# define ENAMETOOLONG 91 /* File or path name too long */
#endif
-#if !defined(EPFNOSUPPORT)
+#if ! defined(EPFNOSUPPORT)
# define EPFNOSUPPORT 96 /* Protocol family not supported */
#endif
-#if !defined(ENOSHARE)
+#if ! defined(ENOSHARE)
# define ENOSHARE 97 /* No such host or network path */
#endif
-#if !defined(ENOMEDIUM)
+#if ! defined(ENOMEDIUM)
# define ENOMEDIUM 98 /* No medium (in tape drive) */
#endif
-#if !defined(ESHUTDOWN)
-# define ESHUTDOWN 99 /* Can't send after socket shutdown */
+#if ! defined(ESHUTDOWN)
+# define ESHUTDOWN 99 /* Can't send after socket shutdown */
#endif
-#if !defined(EADDRINUSE)
-# define EADDRINUSE 100 /* Address already in use */
+#if ! defined(EADDRINUSE)
+# define EADDRINUSE 100 /* Address already in use */
#endif
-#if !defined(EADDRNOTAVAIL)
-# define EADDRNOTAVAIL 101 /* Address not available */
+#if ! defined(EADDRNOTAVAIL)
+# define EADDRNOTAVAIL 101 /* Address not available */
#endif
-#if !defined(EAFNOSUPPORT)
+#if ! defined(EAFNOSUPPORT)
# define EAFNOSUPPORT 102 /* Address family not supported by protocol family */
#endif
-#if !defined(EALREADY)
-# define EALREADY 103 /* Socket already connected */
+#if ! defined(EALREADY)
+# define EALREADY 103 /* Socket already connected */
#endif
-#if !defined(ECANCELED)
-# define ECANCELED 105 /* Connection cancelled */
+#if ! defined(ECANCELED)
+# define ECANCELED 105 /* Connection cancelled */
#endif
-#if !defined(ECONNABORTED)
-# define ECONNABORTED 106 /* Connection aborted */
+#if ! defined(ECONNABORTED)
+# define ECONNABORTED 106 /* Connection aborted */
#endif
-#if !defined(ECONNREFUSED)
-# define ECONNREFUSED 107 /* Connection refused */
+#if ! defined(ECONNREFUSED)
+# define ECONNREFUSED 107 /* Connection refused */
#endif
-#if !defined(ECONNRESET)
+#if ! defined(ECONNRESET)
# define ECONNRESET 108 /* Connection reset by peer */
#endif
-#if !defined(EDESTADDRREQ)
-# define EDESTADDRREQ 109 /* Destination address required */
+#if ! defined(EDESTADDRREQ)
+# define EDESTADDRREQ 109 /* Destination address required */
#endif
-#if !defined(EHOSTUNREACH)
-# define EHOSTUNREACH 110 /* Host is unreachable */
+#if ! defined(EHOSTUNREACH)
+# define EHOSTUNREACH 110 /* Host is unreachable */
#endif
-#if !defined(ECONNABORTED)
-# define ECONNABORTED 111 /* Connection aborted */
+#if ! defined(ECONNABORTED)
+# define ECONNABORTED 111 /* Connection aborted */
#endif
-#if !defined(EINPROGRESS)
-# define EINPROGRESS 112 /* Connection already in progress */
+#if ! defined(EINPROGRESS)
+# define EINPROGRESS 112 /* Connection already in progress */
#endif
-#if !defined(EISCONN)
-# define EISCONN 113 /* Socket is already connected */
+#if ! defined(EISCONN)
+# define EISCONN 113 /* Socket is already connected */
#endif
-#if !defined(ELOOP)
-# define ELOOP 114 /* Too many symbolic links */
+#if ! defined(ELOOP)
+# define ELOOP 114 /* Too many symbolic links */
#endif
-#if !defined(EMSGSIZE)
-# define EMSGSIZE 115 /* Message too long */
+#if ! defined(EMSGSIZE)
+# define EMSGSIZE 115 /* Message too long */
#endif
-#if !defined(ENETDOWN)
-# define ENETDOWN 116 /* Network interface is not configured */
+#if ! defined(ENETDOWN)
+# define ENETDOWN 116 /* Network interface is not configured */
#endif
-#if !defined(ENETRESET)
-# define ENETRESET 117 /* Connection aborted by network */
+#if ! defined(ENETRESET)
+# define ENETRESET 117 /* Connection aborted by network */
#endif
-#if !defined(ENETUNREACH)
-# define ENETUNREACH 118 /* Network is unreachable */
+#if ! defined(ENETUNREACH)
+# define ENETUNREACH 118 /* Network is unreachable */
#endif
-#if !defined(ENOBUFS)
-# define ENOBUFS 119 /* No buffer space available */
+#if ! defined(ENOBUFS)
+# define ENOBUFS 119 /* No buffer space available */
#endif
-#if !defined(EHOSTDOWN)
-# define EHOSTDOWN 120 /* Host is down */
+#if ! defined(EHOSTDOWN)
+# define EHOSTDOWN 120 /* Host is down */
#endif
-#if !defined(EPROCLIM)
-# define EPROCLIM 121 /* Too many processes */
+#if ! defined(EPROCLIM)
+# define EPROCLIM 121 /* Too many processes */
#endif
-#if !defined(EDQUOT)
-# define EDQUOT 122 /* Disk quota exceeded */
+#if ! defined(EDQUOT)
+# define EDQUOT 122 /* Disk quota exceeded */
#endif
-#if !defined(ENOPROTOOPT)
-# define ENOPROTOOPT 123 /* Protocol not available */
+#if ! defined(ENOPROTOOPT)
+# define ENOPROTOOPT 123 /* Protocol not available */
#endif
-#if !defined(ESOCKTNOSUPPORT)
-# define ESOCKTNOSUPPORT 124 /* Socket type not supported */
+#if ! defined(ESOCKTNOSUPPORT)
+# define ESOCKTNOSUPPORT 124 /* Socket type not supported */
#endif
-#if !defined(ESTALE)
+#if ! defined(ESTALE)
# define ESTALE 125 /* Unknown error */
#endif
-#if !defined(ENOTCONN)
-# define ENOTCONN 126 /* Socket is not connected */
+#if ! defined(ENOTCONN)
+# define ENOTCONN 126 /* Socket is not connected */
#endif
-#if !defined(ETOOMANYREFS)
-# define ETOOMANYREFS 127 /* Too many references: cannot splice */
+#if ! defined(ETOOMANYREFS)
+# define ETOOMANYREFS 127 /* Too many references: cannot splice */
#endif
-#if !defined(ENOTSOCK)
-# define ENOTSOCK 128 /* Socket operation on non-socket */
+#if ! defined(ENOTSOCK)
+# define ENOTSOCK 128 /* Socket operation on non-socket */
#endif
-#if !defined(ENOTSUP)
-# define ENOTSUP 129 /* Not supported */
+#if ! defined(ENOTSUP)
+# define ENOTSUP 129 /* Not supported */
#endif
-#if !defined(EOPNOTSUPP)
-# define EOPNOTSUPP 130 /* Operation not supported on transport endpoint */
+#if ! defined(EOPNOTSUPP)
+# define EOPNOTSUPP 130 /* Operation not supported on transport endpoint */
#endif
-#if !defined(EUSERS)
-# define EUSERS 131 /* Too many users */
+#if ! defined(EUSERS)
+# define EUSERS 131 /* Too many users */
#endif
-#if !defined(EOVERFLOW)
+#if ! defined(EOVERFLOW)
# define EOVERFLOW 132 /* Value too large for defined data type */
#endif
-#if !defined(EOWNERDEAD)
+#if ! defined(EOWNERDEAD)
# define EOWNERDEAD 133 /* Unknown error */
#endif
-#if !defined(EPROTO)
-# define EPROTO 134 /* Protocol error */
+#if ! defined(EPROTO)
+# define EPROTO 134 /* Protocol error */
#endif
-#if !defined(EPROTONOSUPPORT)
-# define EPROTONOSUPPORT 135 /* Unknown protocol */
+#if ! defined(EPROTONOSUPPORT)
+# define EPROTONOSUPPORT 135 /* Unknown protocol */
#endif
-#if !defined(EPROTOTYPE)
-# define EPROTOTYPE 136 /* Protocol wrong type for socket */
+#if ! defined(EPROTOTYPE)
+# define EPROTOTYPE 136 /* Protocol wrong type for socket */
#endif
-#if !defined(ECASECLASH)
+#if ! defined(ECASECLASH)
# define ECASECLASH 137 /* Filename exists with different case */
#endif
-#if !defined(ETIMEDOUT)
+#if ! defined(ETIMEDOUT)
/* Make sure it's the same as WSATIMEDOUT */
-# define ETIMEDOUT 138 /* Connection timed out */
+# define ETIMEDOUT 138 /* Connection timed out */
#endif
-#if !defined(EWOULDBLOCK) || EWOULDBLOCK == 140
+#if ! defined(EWOULDBLOCK) || EWOULDBLOCK == 140
# undef EWOULDBLOCK /* MinGW-w64 defines it as 140, but we want it as EAGAIN */
-# define EWOULDBLOCK EAGAIN /* Operation would block */
+# define EWOULDBLOCK EAGAIN /* Operation would block */
#endif
#undef HOST_NOT_FOUND
@@ -384,7 +385,7 @@ enum
#define MAP_PRIVATE 0x2 /* unsupported */
#define MAP_FIXED 0x10
#define MAP_ANONYMOUS 0x20 /* unsupported */
-#define MAP_FAILED ((void *)-1)
+#define MAP_FAILED ((void *) -1)
#define MS_ASYNC 1 /* sync memory asynchronously */
#define MS_INVALIDATE 2 /* invalidate the caches */
@@ -403,7 +404,7 @@ struct statfs
long f_namelen; /* maximum length of filenames */
long f_spare[6]; /* spare for later */
};
-#define sleep(secs) (Sleep(secs * 1000))
+#define sleep(secs) (Sleep (secs * 1000))
/*********************** statfs *****************************/
/* fake block size */
@@ -466,159 +467,265 @@ struct statfs
#define SIGKILL 9
#define SIGTERM 15
-#define SetErrnoFromWinError(e) _SetErrnoFromWinError(e, __FILE__, __LINE__)
+#define SetErrnoFromWinError(e) _SetErrnoFromWinError (e, __FILE__, __LINE__)
+
+BOOL _plibc_CreateShortcut (const char *pszSrc, const char *pszDest);
+
+BOOL _plibc_CreateShortcutW (const wchar_t *pwszSrc, const wchar_t *pwszDest);
+
+BOOL _plibc_DereferenceShortcut (char *pszShortcut);
+
+BOOL _plibc_DereferenceShortcutW (wchar_t *pwszShortcut);
+
+char *plibc_ChooseDir (char *pszTitle, unsigned long ulFlags);
+
+wchar_t *plibc_ChooseDirW (wchar_t *pwszTitle, unsigned long ulFlags);
+
+char *plibc_ChooseFile (char *pszTitle, unsigned long ulFlags);
+
+wchar_t *plibc_ChooseFileW (wchar_t *pwszTitle, unsigned long ulFlags);
+
+long QueryRegistry (HKEY hMainKey, const char *pszKey, const char *pszSubKey,
+ char *pszBuffer, long *pdLength);
+
+long QueryRegistryW (HKEY hMainKey, const wchar_t *pszKey, const
+ wchar_t *pszSubKey,
+ wchar_t *pszBuffer, long *pdLength);
+
+BOOL __win_IsHandleMarkedAsBlocking (int hHandle);
+
+void __win_SetHandleBlockingMode (int s, BOOL bBlocking);
+
+void __win_DiscardHandleBlockingMode (int s);
+
+int _win_isSocketValid (int s);
-BOOL _plibc_CreateShortcut(const char *pszSrc, const char *pszDest);
-BOOL _plibc_CreateShortcutW(const wchar_t *pwszSrc, const wchar_t *pwszDest);
-BOOL _plibc_DereferenceShortcut(char *pszShortcut);
-BOOL _plibc_DereferenceShortcutW(wchar_t *pwszShortcut);
-char *plibc_ChooseDir(char *pszTitle, unsigned long ulFlags);
-wchar_t *plibc_ChooseDirW(wchar_t *pwszTitle, unsigned long ulFlags);
-char *plibc_ChooseFile(char *pszTitle, unsigned long ulFlags);
-wchar_t *plibc_ChooseFileW(wchar_t *pwszTitle, unsigned long ulFlags);
+int plibc_conv_to_win_path (const char *pszUnix, char *pszWindows);
-long QueryRegistry(HKEY hMainKey, const char *pszKey, const char *pszSubKey,
- char *pszBuffer, long *pdLength);
-long QueryRegistryW(HKEY hMainKey, const wchar_t *pszKey, const wchar_t *pszSubKey,
- wchar_t *pszBuffer, long *pdLength);
+int plibc_conv_to_win_pathw (const wchar_t *pszUnix, wchar_t *pwszWindows);
-BOOL __win_IsHandleMarkedAsBlocking(int hHandle);
-void __win_SetHandleBlockingMode(int s, BOOL bBlocking);
-void __win_DiscardHandleBlockingMode(int s);
-int _win_isSocketValid(int s);
-int plibc_conv_to_win_path(const char *pszUnix, char *pszWindows);
-int plibc_conv_to_win_pathw(const wchar_t *pszUnix, wchar_t *pwszWindows);
+int plibc_conv_to_win_pathwconv (const char *pszUnix, wchar_t *pwszWindows);
-int plibc_conv_to_win_pathwconv(const char *pszUnix, wchar_t *pwszWindows);
-int plibc_conv_to_win_pathwconv_ex(const char *pszUnix, wchar_t *pszWindows, int derefLinks);
+int plibc_conv_to_win_pathwconv_ex (const char *pszUnix, wchar_t *pszWindows,
+ int derefLinks);
-unsigned plibc_get_handle_count();
+unsigned plibc_get_handle_count ();
typedef void (*TPanicProc) (int, char *);
-void plibc_set_panic_proc(TPanicProc proc);
-void plibc_set_stat_size_size(int iLength);
-void plibc_set_stat_time_size(int iLength);
-
-int flock(int fd, int operation);
-int fsync(int fildes);
-int inet_pton(int af, const char *src, void *dst);
-int inet_pton4(const char *src, u_char *dst, int pton);
+void plibc_set_panic_proc (TPanicProc proc);
+
+void plibc_set_stat_size_size (int iLength);
+
+void plibc_set_stat_time_size (int iLength);
+
+int flock (int fd, int operation);
+
+int fsync (int fildes);
+
+int inet_pton (int af, const char *src, void *dst);
+
+int inet_pton4 (const char *src, u_char *dst, int pton);
+
#if USE_IPV6
-int inet_pton6(const char *src, u_char *dst);
+int inet_pton6 (const char *src, u_char *dst);
+
#endif
-int statfs(const char *path, struct statfs *buf);
-const char *hstrerror(int err);
-int mkstemp(char *tmplate);
+int statfs (const char *path, struct statfs *buf);
+
+const char *hstrerror (int err);
+
+int mkstemp (char *tmplate);
+
char *strptime (const char *buf, const char *format, struct tm *tm);
-const char *inet_ntop(int af, const void *src, char *dst, size_t size);
+
+const char *inet_ntop (int af, const void *src, char *dst, size_t size);
+
#ifndef gmtime_r
-struct tm *gmtime_r(const time_t *clock, struct tm *result);
-#endif
-
-int plibc_init(char *pszOrg, char *pszApp);
-int plibc_init_utf8(char *pszOrg, char *pszApp, int utf8_mode);
-void plibc_shutdown();
-int plibc_initialized();
-
-void _SetErrnoFromWinError(long lWinError, char *pszCaller, int iLine);
-void SetErrnoFromWinsockError(long lWinError);
-void SetHErrnoFromWinError(long lWinError);
-void SetErrnoFromHRESULT(HRESULT hRes);
-int GetErrnoFromWinsockError(long lWinError);
-FILE *_win_fopen(const char *filename, const char *mode);
-int _win_fclose(FILE *);
-DIR *_win_opendir(const char *dirname);
-struct dirent *_win_readdir(DIR *dirp);
-int _win_closedir(DIR *dirp);
-int _win_open(const char *filename, int oflag, ...);
+struct tm *gmtime_r (const time_t *clock, struct tm *result);
+
+#endif
+
+int plibc_init (char *pszOrg, char *pszApp);
+
+int plibc_init_utf8 (char *pszOrg, char *pszApp, int utf8_mode);
+
+void plibc_shutdown ();
+
+int plibc_initialized ();
+
+void _SetErrnoFromWinError (long lWinError, char *pszCaller, int iLine);
+
+void SetErrnoFromWinsockError (long lWinError);
+
+void SetHErrnoFromWinError (long lWinError);
+
+void SetErrnoFromHRESULT (HRESULT hRes);
+
+int GetErrnoFromWinsockError (long lWinError);
+
+FILE *_win_fopen (const char *filename, const char *mode);
+
+int _win_fclose (FILE *);
+
+DIR *_win_opendir (const char *dirname);
+
+struct dirent *_win_readdir (DIR *dirp);
+
+int _win_closedir (DIR *dirp);
+
+int _win_open (const char *filename, int oflag, ...);
+
#ifdef ENABLE_NLS
-char *_win_bindtextdomain(const char *domainname, const char *dirname);
-#endif
-int _win_chdir(const char *path);
-int _win_close(int fd);
-int _win_creat(const char *path, mode_t mode);
-char *_win_ctime(const time_t *clock);
-char *_win_ctime_r(const time_t *clock, char *buf);
-int _win_fstat(int handle, struct stat *buffer);
-int _win_ftruncate(int fildes, off_t length);
-int _win_truncate(const char *fname, int distance);
-int _win_kill(pid_t pid, int sig);
-int _win_pipe(int *phandles);
-int _win_mkfifo(const char *path, mode_t mode);
-int _win_rmdir(const char *path);
-int _win_access( const char *path, int mode );
-int _win_chmod(const char *filename, int pmode);
-char *realpath(const char *file_name, char *resolved_name);
-long _win_random(void);
-void _win_srandom(unsigned int seed);
-int _win_remove(const char *path);
-int _win_rename(const char *oldname, const char *newname);
-int _win_stat(const char *path, struct stat *buffer);
-int _win_stati64(const char *path, struct _stati64 *buffer);
-long _win_sysconf(int name);
-int _win_unlink(const char *filename);
-int _win_write(int fildes, const void *buf, size_t nbyte);
-int _win_read(int fildes, void *buf, size_t nbyte);
-size_t _win_fwrite(const void *buffer, size_t size, size_t count, FILE *stream);
-size_t _win_fread( void *buffer, size_t size, size_t count, FILE *stream );
-int _win_symlink(const char *path1, const char *path2);
-void *_win_mmap(void *start, size_t len, int access, int flags, int fd,
- unsigned long long offset);
-int _win_msync(void *start, size_t length, int flags);
-int _win_munmap(void *start, size_t length);
-int _win_lstat(const char *path, struct stat *buf);
-int _win_lstati64(const char *path, struct _stati64 *buf);
-int _win_readlink(const char *path, char *buf, size_t bufsize);
-int _win_accept(int s, struct sockaddr *addr, int *addrlen);
-
-pid_t _win_waitpid(pid_t pid, int *stat_loc, int options);
-int _win_bind(int s, const struct sockaddr *name, int namelen);
-int _win_connect(int s,const struct sockaddr *name, int namelen);
-int _win_getpeername(int s, struct sockaddr *name,
- int *namelen);
-int _win_getsockname(int s, struct sockaddr *name,
- int *namelen);
-int _win_getsockopt(int s, int level, int optname, char *optval,
- int *optlen);
-int _win_listen(int s, int backlog);
-int _win_recv(int s, char *buf, int len, int flags);
-int _win_recvfrom(int s, void *buf, int len, int flags,
- struct sockaddr *from, int *fromlen);
-int _win_select(int max_fd, fd_set * rfds, fd_set * wfds, fd_set * efds,
- const struct timeval *tv);
-int _win_send(int s, const char *buf, int len, int flags);
-int _win_sendto(int s, const char *buf, int len, int flags,
- const struct sockaddr *to, int tolen);
-int _win_setsockopt(int s, int level, int optname, const void *optval,
- int optlen);
-int _win_shutdown(int s, int how);
-int _win_socket(int af, int type, int protocol);
-int _win_socketpair(int af, int type, int protocol, int socket_vector[2]);
-struct hostent *_win_gethostbyaddr(const char *addr, int len, int type);
-struct hostent *_win_gethostbyname(const char *name);
-struct hostent *gethostbyname2(const char *name, int af);
-char *_win_strerror(int errnum);
-int IsWinNT();
-char *index(const char *s, int c);
+char *_win_bindtextdomain (const char *domainname, const char *dirname);
+
+#endif
+int _win_chdir (const char *path);
+
+int _win_close (int fd);
+
+int _win_creat (const char *path, mode_t mode);
+
+char *_win_ctime (const time_t *clock);
+
+char *_win_ctime_r (const time_t *clock, char *buf);
+
+int _win_fstat (int handle, struct stat *buffer);
+
+int _win_ftruncate (int fildes, off_t length);
+
+int _win_truncate (const char *fname, int distance);
+
+int _win_kill (pid_t pid, int sig);
+
+int _win_pipe (int *phandles);
+
+int _win_mkfifo (const char *path, mode_t mode);
+
+int _win_rmdir (const char *path);
+
+int _win_access (const char *path, int mode);
+
+int _win_chmod (const char *filename, int pmode);
+
+char *realpath (const char *file_name, char *resolved_name);
+
+long _win_random (void);
+
+void _win_srandom (unsigned int seed);
+
+int _win_remove (const char *path);
+
+int _win_rename (const char *oldname, const char *newname);
+
+int _win_stat (const char *path, struct stat *buffer);
+
+int _win_stati64 (const char *path, struct _stati64 *buffer);
+
+long _win_sysconf (int name);
+
+int _win_unlink (const char *filename);
+
+int _win_write (int fildes, const void *buf, size_t nbyte);
+
+int _win_read (int fildes, void *buf, size_t nbyte);
+
+size_t _win_fwrite (const void *buffer, size_t size, size_t count,
+ FILE *stream);
+
+size_t _win_fread (void *buffer, size_t size, size_t count, FILE *stream);
+
+int _win_symlink (const char *path1, const char *path2);
+
+void *_win_mmap (void *start, size_t len, int access, int flags, int fd,
+ unsigned long long offset);
+
+int _win_msync (void *start, size_t length, int flags);
+
+int _win_munmap (void *start, size_t length);
+
+int _win_lstat (const char *path, struct stat *buf);
+
+int _win_lstati64 (const char *path, struct _stati64 *buf);
+
+int _win_readlink (const char *path, char *buf, size_t bufsize);
+
+int _win_accept (int s, struct sockaddr *addr, int *addrlen);
+
+pid_t _win_waitpid (pid_t pid, int *stat_loc, int options);
+
+int _win_bind (int s, const struct sockaddr *name, int namelen);
+
+int _win_connect (int s,const struct sockaddr *name, int namelen);
+
+int _win_getpeername (int s, struct sockaddr *name,
+ int *namelen);
+
+int _win_getsockname (int s, struct sockaddr *name,
+ int *namelen);
+
+int _win_getsockopt (int s, int level, int optname, char *optval,
+ int *optlen);
+
+int _win_listen (int s, int backlog);
+
+int _win_recv (int s, char *buf, int len, int flags);
+
+int _win_recvfrom (int s, void *buf, int len, int flags,
+ struct sockaddr *from, int *fromlen);
+
+int _win_select (int max_fd, fd_set *rfds, fd_set *wfds, fd_set *efds,
+ const struct timeval *tv);
+
+int _win_send (int s, const char *buf, int len, int flags);
+
+int _win_sendto (int s, const char *buf, int len, int flags,
+ const struct sockaddr *to, int tolen);
+
+int _win_setsockopt (int s, int level, int optname, const void *optval,
+ int optlen);
+
+int _win_shutdown (int s, int how);
+
+int _win_socket (int af, int type, int protocol);
+
+int _win_socketpair (int af, int type, int protocol, int socket_vector[2]);
+
+struct hostent *_win_gethostbyaddr (const char *addr, int len, int type);
+
+struct hostent *_win_gethostbyname (const char *name);
+
+struct hostent *gethostbyname2 (const char *name, int af);
+
+char *_win_strerror (int errnum);
+
+int IsWinNT ();
+
+char *index (const char *s, int c);
+
char *_win_strtok_r (char *ptr, const char *sep, char **end);
-#if !HAVE_STRNDUP
+#if ! HAVE_STRNDUP
char *strndup (const char *s, size_t n);
+
#endif
-#if !HAVE_STRNLEN && (!defined(__MINGW64_VERSION_MAJOR) || !defined(_INC_STRING))
+#if ! HAVE_STRNLEN && (! defined(__MINGW64_VERSION_MAJOR) || \
+ ! defined(_INC_STRING))
size_t strnlen (const char *str, size_t maxlen);
+
#endif
-char *stpcpy(char *dest, const char *src);
-char *strcasestr(const char *haystack_start, const char *needle_start);
+char *stpcpy (char *dest, const char *src);
+
+char *strcasestr (const char *haystack_start, const char *needle_start);
+
#ifndef __MINGW64_VERSION_MAJOR
-#define strcasecmp(a, b) stricmp(a, b)
-#define strncasecmp(a, b, c) strnicmp(a, b, c)
+#define strcasecmp(a, b) stricmp (a, b)
+#define strncasecmp(a, b, c) strnicmp (a, b, c)
#endif
#ifndef wcscasecmp
-#define wcscasecmp(a, b) wcsicmp(a, b)
+#define wcscasecmp(a, b) wcsicmp (a, b)
#endif
#ifndef wcsncasecmp
-#define wcsncasecmp(a, b, c) wcsnicmp(a, b, c)
+#define wcsncasecmp(a, b, c) wcsnicmp (a, b, c)
#endif
#ifndef strtok_r /* winpthreads defines it in pthread.h */
#define strtok_r _win_strtok_r
@@ -633,99 +740,99 @@ char *strcasestr(const char *haystack_start, const char *needle_start);
#define NEWLINE "\n"
#ifdef ENABLE_NLS
- #define BINDTEXTDOMAIN(d, n) bindtextdomain(d, n)
+ #define BINDTEXTDOMAIN(d, n) bindtextdomain (d, n)
#endif
- #define CREAT(p, m) creat(p, m)
- #define PLIBC_CTIME(c) ctime(c)
- #define CTIME_R(c, b) ctime_r(c, b)
+ #define CREAT(p, m) creat (p, m)
+ #define PLIBC_CTIME(c) ctime (c)
+ #define CTIME_R(c, b) ctime_r (c, b)
#undef FOPEN
- #define FOPEN(f, m) fopen(f, m)
- #define FCLOSE(f) fclose(f)
- #define FTRUNCATE(f, l) ftruncate(f, l)
- #define TRUNCATE(f, l) truncate(f, l)
- #define OPENDIR(d) opendir(d)
- #define CLOSEDIR(d) closedir(d)
- #define READDIR(d) readdir(d)
+ #define FOPEN(f, m) fopen (f, m)
+ #define FCLOSE(f) fclose (f)
+ #define FTRUNCATE(f, l) ftruncate (f, l)
+ #define TRUNCATE(f, l) truncate (f, l)
+ #define OPENDIR(d) opendir (d)
+ #define CLOSEDIR(d) closedir (d)
+ #define READDIR(d) readdir (d)
#define OPEN open
- #define CHDIR(d) chdir(d)
- #define CLOSE(f) close(f)
- #define LSEEK(f, o, w) lseek(f, o, w)
- #define RMDIR(f) rmdir(f)
- #define ACCESS(p, m) access(p, m)
- #define CHMOD(f, p) chmod(f, p)
- #define FSTAT(h, b) fstat(h, b)
- #define PLIBC_KILL(p, s) kill(p, s)
- #define PIPE(h) pipe(h)
- #define REMOVE(p) remove(p)
- #define RENAME(o, n) rename(o, n)
- #define STAT(p, b) stat(p, b)
- #define STAT64(p, b) stat64(p, b)
- #define SYSCONF(n) sysconf(n)
- #define UNLINK(f) unlink(f)
- #define WRITE(f, b, n) write(f, b, n)
- #define READ(f, b, n) read(f, b, n)
- #define GN_FREAD(b, s, c, f) fread(b, s, c, f)
- #define GN_FWRITE(b, s, c, f) fwrite(b, s, c, f)
- #define SYMLINK(a, b) symlink(a, b)
- #define MMAP(s, l, p, f, d, o) mmap(s, l, p, f, d, o)
- #define MKFIFO(p, m) mkfifo(p, m)
- #define MSYNC(s, l, f) msync(s, l, f)
- #define MUNMAP(s, l) munmap(s, l)
- #define STRERROR(i) strerror(i)
- #define RANDOM() random()
- #define SRANDOM(s) srandom(s)
- #define READLINK(p, b, s) readlink(p, b, s)
- #define LSTAT(p, b) lstat(p, b)
- #define LSTAT64(p, b) lstat64(p, b)
+ #define CHDIR(d) chdir (d)
+ #define CLOSE(f) close (f)
+ #define LSEEK(f, o, w) lseek (f, o, w)
+ #define RMDIR(f) rmdir (f)
+ #define ACCESS(p, m) access (p, m)
+ #define CHMOD(f, p) chmod (f, p)
+ #define FSTAT(h, b) fstat (h, b)
+ #define PLIBC_KILL(p, s) kill (p, s)
+ #define PIPE(h) pipe (h)
+ #define REMOVE(p) remove (p)
+ #define RENAME(o, n) rename (o, n)
+ #define STAT(p, b) stat (p, b)
+ #define STAT64(p, b) stat64 (p, b)
+ #define SYSCONF(n) sysconf (n)
+ #define UNLINK(f) unlink (f)
+ #define WRITE(f, b, n) write (f, b, n)
+ #define READ(f, b, n) read (f, b, n)
+ #define GN_FREAD(b, s, c, f) fread (b, s, c, f)
+ #define GN_FWRITE(b, s, c, f) fwrite (b, s, c, f)
+ #define SYMLINK(a, b) symlink (a, b)
+ #define MMAP(s, l, p, f, d, o) mmap (s, l, p, f, d, o)
+ #define MKFIFO(p, m) mkfifo (p, m)
+ #define MSYNC(s, l, f) msync (s, l, f)
+ #define MUNMAP(s, l) munmap (s, l)
+ #define STRERROR(i) strerror (i)
+ #define RANDOM() random ()
+ #define SRANDOM(s) srandom (s)
+ #define READLINK(p, b, s) readlink (p, b, s)
+ #define LSTAT(p, b) lstat (p, b)
+ #define LSTAT64(p, b) lstat64 (p, b)
#define PRINTF printf
#define FPRINTF fprintf
- #define VPRINTF(f, a) vprintf(f, a)
- #define VFPRINTF(s, f, a) vfprintf(s, f, a)
- #define VSPRINTF(d, f, a) vsprintf(d, f, a)
- #define VSNPRINTF(str, size, fmt, a) vsnprintf(str, size, fmt, a)
+ #define VPRINTF(f, a) vprintf (f, a)
+ #define VFPRINTF(s, f, a) vfprintf (s, f, a)
+ #define VSPRINTF(d, f, a) vsprintf (d, f, a)
+ #define VSNPRINTF(str, size, fmt, a) vsnprintf (str, size, fmt, a)
#define _REAL_SNPRINTF snprintf
#define SPRINTF sprintf
- #define VSSCANF(s, f, a) vsscanf(s, f, a)
+ #define VSSCANF(s, f, a) vsscanf (s, f, a)
#define SSCANF sscanf
- #define VFSCANF(s, f, a) vfscanf(s, f, a)
- #define VSCANF(f, a) vscanf(f, a)
+ #define VFSCANF(s, f, a) vfscanf (s, f, a)
+ #define VSCANF(f, a) vscanf (f, a)
#define SCANF scanf
#define FSCANF fscanf
- #define WAITPID(p, s, o) waitpid(p, s, o)
- #define ACCEPT(s, a, l) accept(s, a, l)
- #define BIND(s, n, l) bind(s, n, l)
- #define CONNECT(s, n, l) connect(s, n, l)
- #define GETPEERNAME(s, n, l) getpeername(s, n, l)
- #define GETSOCKNAME(s, n, l) getsockname(s, n, l)
- #define GETSOCKOPT(s, l, o, v, p) getsockopt(s, l, o, v, p)
- #define LISTEN(s, b) listen(s, b)
- #define RECV(s, b, l, f) recv(s, b, l, f)
- #define RECVFROM(s, b, l, f, r, o) recvfrom(s, b, l, f, r, o)
- #define SELECT(n, r, w, e, t) select(n, r, w, e, t)
- #define SEND(s, b, l, f) send(s, b, l, f)
- #define SENDTO(s, b, l, f, o, n) sendto(s, b, l, f, o, n)
- #define SETSOCKOPT(s, l, o, v, n) setsockopt(s, l, o, v, n)
- #define SHUTDOWN(s, h) shutdown(s, h)
- #define SOCKET(a, t, p) socket(a, t, p)
- #define SOCKETPAIR(a, t, p, v) socketpair(a, t, p, v)
- #define GETHOSTBYADDR(a, l, t) gethostbyaddr(a, l, t)
- #define GETHOSTBYNAME(n) gethostbyname(n)
- #define GETTIMEOFDAY(t, n) gettimeofday(t, n)
- #define INSQUE(e, p) insque(e, p)
- #define REMQUE(e) remque(e)
- #define HSEARCH(i, a) hsearch(i, a)
- #define HCREATE(n) hcreate(n)
- #define HDESTROY() hdestroy()
- #define HSEARCH_R(i, a, r, h) hsearch_r(i, a, r, h)
- #define HCREATE_R(n, h) hcreate_r(n, h)
- #define HDESTROY_R(h) hdestroy_r(h)
- #define TSEARCH(k, r, c) tsearch(k, r, c)
- #define TFIND(k, r, c) tfind(k, r, c)
- #define TDELETE(k, r, c) tdelete(k, r, c)
- #define TWALK(r, a) twalk(r, a)
- #define TDESTROY(r, f) tdestroy(r, f)
- #define LFIND(k, b, n, s, c) lfind(k, b, n, s, c)
- #define LSEARCH(k, b, n, s, c) lsearch(k, b, n, s, c)
+ #define WAITPID(p, s, o) waitpid (p, s, o)
+ #define ACCEPT(s, a, l) accept (s, a, l)
+ #define BIND(s, n, l) bind (s, n, l)
+ #define CONNECT(s, n, l) connect (s, n, l)
+ #define GETPEERNAME(s, n, l) getpeername (s, n, l)
+ #define GETSOCKNAME(s, n, l) getsockname (s, n, l)
+ #define GETSOCKOPT(s, l, o, v, p) getsockopt (s, l, o, v, p)
+ #define LISTEN(s, b) listen (s, b)
+ #define RECV(s, b, l, f) recv (s, b, l, f)
+ #define RECVFROM(s, b, l, f, r, o) recvfrom (s, b, l, f, r, o)
+ #define SELECT(n, r, w, e, t) select (n, r, w, e, t)
+ #define SEND(s, b, l, f) send (s, b, l, f)
+ #define SENDTO(s, b, l, f, o, n) sendto (s, b, l, f, o, n)
+ #define SETSOCKOPT(s, l, o, v, n) setsockopt (s, l, o, v, n)
+ #define SHUTDOWN(s, h) shutdown (s, h)
+ #define SOCKET(a, t, p) socket (a, t, p)
+ #define SOCKETPAIR(a, t, p, v) socketpair (a, t, p, v)
+ #define GETHOSTBYADDR(a, l, t) gethostbyaddr (a, l, t)
+ #define GETHOSTBYNAME(n) gethostbyname (n)
+ #define GETTIMEOFDAY(t, n) gettimeofday (t, n)
+ #define INSQUE(e, p) insque (e, p)
+ #define REMQUE(e) remque (e)
+ #define HSEARCH(i, a) hsearch (i, a)
+ #define HCREATE(n) hcreate (n)
+ #define HDESTROY() hdestroy ()
+ #define HSEARCH_R(i, a, r, h) hsearch_r (i, a, r, h)
+ #define HCREATE_R(n, h) hcreate_r (n, h)
+ #define HDESTROY_R(h) hdestroy_r (h)
+ #define TSEARCH(k, r, c) tsearch (k, r, c)
+ #define TFIND(k, r, c) tfind (k, r, c)
+ #define TDELETE(k, r, c) tdelete (k, r, c)
+ #define TWALK(r, a) twalk (r, a)
+ #define TDESTROY(r, f) tdestroy (r, f)
+ #define LFIND(k, b, n, s, c) lfind (k, b, n, s, c)
+ #define LSEARCH(k, b, n, s, c) lsearch (k, b, n, s, c)
#define STRUCT_STAT64 struct stat64
#else
#define DIR_SEPARATOR '\\'
@@ -735,98 +842,98 @@ char *strcasestr(const char *haystack_start, const char *needle_start);
#define NEWLINE "\r\n"
#ifdef ENABLE_NLS
- #define BINDTEXTDOMAIN(d, n) _win_bindtextdomain(d, n)
-#endif
- #define CREAT(p, m) _win_creat(p, m)
- #define PLIBC_CTIME(c) _win_ctime(c)
- #define CTIME_R(c, b) _win_ctime_r(c, b)
- #define FOPEN(f, m) _win_fopen(f, m)
- #define FCLOSE(f) _win_fclose(f)
- #define FTRUNCATE(f, l) _win_ftruncate(f, l)
- #define TRUNCATE(f, l) _win_truncate(f, l)
- #define OPENDIR(d) _win_opendir(d)
- #define CLOSEDIR(d) _win_closedir(d)
- #define READDIR(d) _win_readdir(d)
+ #define BINDTEXTDOMAIN(d, n) _win_bindtextdomain (d, n)
+#endif
+ #define CREAT(p, m) _win_creat (p, m)
+ #define PLIBC_CTIME(c) _win_ctime (c)
+ #define CTIME_R(c, b) _win_ctime_r (c, b)
+ #define FOPEN(f, m) _win_fopen (f, m)
+ #define FCLOSE(f) _win_fclose (f)
+ #define FTRUNCATE(f, l) _win_ftruncate (f, l)
+ #define TRUNCATE(f, l) _win_truncate (f, l)
+ #define OPENDIR(d) _win_opendir (d)
+ #define CLOSEDIR(d) _win_closedir (d)
+ #define READDIR(d) _win_readdir (d)
#define OPEN _win_open
- #define CHDIR(d) _win_chdir(d)
- #define CLOSE(f) _win_close(f)
- #define PLIBC_KILL(p, s) _win_kill(p, s)
- #define LSEEK(f, o, w) lseek(f, o, w)
- #define FSTAT(h, b) _win_fstat(h, b)
- #define RMDIR(f) _win_rmdir(f)
- #define ACCESS(p, m) _win_access(p, m)
- #define CHMOD(f, p) _win_chmod(f, p)
- #define PIPE(h) _win_pipe(h)
- #define RANDOM() _win_random()
- #define SRANDOM(s) _win_srandom(s)
- #define REMOVE(p) _win_remove(p)
- #define RENAME(o, n) _win_rename(o, n)
- #define STAT(p, b) _win_stat(p, b)
- #define STAT64(p, b) _win_stati64(p, b)
- #define SYSCONF(n) _win_sysconf(n)
- #define UNLINK(f) _win_unlink(f)
- #define WRITE(f, b, n) _win_write(f, b, n)
- #define READ(f, b, n) _win_read(f, b, n)
- #define GN_FREAD(b, s, c, f) _win_fread(b, s, c, f)
- #define GN_FWRITE(b, s, c, f) _win_fwrite(b, s, c, f)
- #define SYMLINK(a, b) _win_symlink(a, b)
- #define MMAP(s, l, p, f, d, o) _win_mmap(s, l, p, f, d, o)
- #define MKFIFO(p, m) _win_mkfifo(p, m)
- #define MSYNC(s, l, f) _win_msync(s, l, f)
- #define MUNMAP(s, l) _win_munmap(s, l)
- #define STRERROR(i) _win_strerror(i)
- #define READLINK(p, b, s) _win_readlink(p, b, s)
- #define LSTAT(p, b) _win_lstat(p, b)
- #define LSTAT64(p, b) _win_lstati64(p, b)
+ #define CHDIR(d) _win_chdir (d)
+ #define CLOSE(f) _win_close (f)
+ #define PLIBC_KILL(p, s) _win_kill (p, s)
+ #define LSEEK(f, o, w) lseek (f, o, w)
+ #define FSTAT(h, b) _win_fstat (h, b)
+ #define RMDIR(f) _win_rmdir (f)
+ #define ACCESS(p, m) _win_access (p, m)
+ #define CHMOD(f, p) _win_chmod (f, p)
+ #define PIPE(h) _win_pipe (h)
+ #define RANDOM() _win_random ()
+ #define SRANDOM(s) _win_srandom (s)
+ #define REMOVE(p) _win_remove (p)
+ #define RENAME(o, n) _win_rename (o, n)
+ #define STAT(p, b) _win_stat (p, b)
+ #define STAT64(p, b) _win_stati64 (p, b)
+ #define SYSCONF(n) _win_sysconf (n)
+ #define UNLINK(f) _win_unlink (f)
+ #define WRITE(f, b, n) _win_write (f, b, n)
+ #define READ(f, b, n) _win_read (f, b, n)
+ #define GN_FREAD(b, s, c, f) _win_fread (b, s, c, f)
+ #define GN_FWRITE(b, s, c, f) _win_fwrite (b, s, c, f)
+ #define SYMLINK(a, b) _win_symlink (a, b)
+ #define MMAP(s, l, p, f, d, o) _win_mmap (s, l, p, f, d, o)
+ #define MKFIFO(p, m) _win_mkfifo (p, m)
+ #define MSYNC(s, l, f) _win_msync (s, l, f)
+ #define MUNMAP(s, l) _win_munmap (s, l)
+ #define STRERROR(i) _win_strerror (i)
+ #define READLINK(p, b, s) _win_readlink (p, b, s)
+ #define LSTAT(p, b) _win_lstat (p, b)
+ #define LSTAT64(p, b) _win_lstati64 (p, b)
#define PRINTF printf
#define FPRINTF fprintf
- #define VPRINTF(f, a) vprintf(f, a)
- #define VFPRINTF(s, f, a) vfprintf(s, f, a)
- #define VSPRINTF(d, f, a) vsprintf(d, f, a)
- #define VSNPRINTF(str, size, fmt, a) vsnprintf(str, size, fmt, a)
+ #define VPRINTF(f, a) vprintf (f, a)
+ #define VFPRINTF(s, f, a) vfprintf (s, f, a)
+ #define VSPRINTF(d, f, a) vsprintf (d, f, a)
+ #define VSNPRINTF(str, size, fmt, a) vsnprintf (str, size, fmt, a)
#define _REAL_SNPRINTF snprintf
#define SPRINTF sprintf
- #define VSSCANF(s, f, a) vsscanf(s, f, a)
+ #define VSSCANF(s, f, a) vsscanf (s, f, a)
#define SSCANF sscanf
- #define VFSCANF(s, f, a) vfscanf(s, f, a)
- #define VSCANF(f, a) vscanf(f, a)
+ #define VFSCANF(s, f, a) vfscanf (s, f, a)
+ #define VSCANF(f, a) vscanf (f, a)
#define SCANF scanf
#define FSCANF fscanf
- #define WAITPID(p, s, o) _win_waitpid(p, s, o)
- #define ACCEPT(s, a, l) _win_accept(s, a, l)
- #define BIND(s, n, l) _win_bind(s, n, l)
- #define CONNECT(s, n, l) _win_connect(s, n, l)
- #define GETPEERNAME(s, n, l) _win_getpeername(s, n, l)
- #define GETSOCKNAME(s, n, l) _win_getsockname(s, n, l)
- #define GETSOCKOPT(s, l, o, v, p) _win_getsockopt(s, l, o, v, p)
- #define LISTEN(s, b) _win_listen(s, b)
- #define RECV(s, b, l, f) _win_recv(s, b, l, f)
- #define RECVFROM(s, b, l, f, r, o) _win_recvfrom(s, b, l, f, r, o)
- #define SELECT(n, r, w, e, t) _win_select(n, r, w, e, t)
- #define SEND(s, b, l, f) _win_send(s, b, l, f)
- #define SENDTO(s, b, l, f, o, n) _win_sendto(s, b, l, f, o, n)
- #define SETSOCKOPT(s, l, o, v, n) _win_setsockopt(s, l, o, v, n)
- #define SHUTDOWN(s, h) _win_shutdown(s, h)
- #define SOCKET(a, t, p) _win_socket(a, t, p)
- #define SOCKETPAIR(a, t, p, v) _win_socketpair(a, t, p, v)
- #define GETHOSTBYADDR(a, l, t) _win_gethostbyaddr(a, l, t)
- #define GETHOSTBYNAME(n) _win_gethostbyname(n)
- #define GETTIMEOFDAY(t, n) gettimeofday(t, n)
- #define INSQUE(e, p) _win_insque(e, p)
- #define REMQUE(e) _win_remque(e)
- #define HSEARCH(i, a) _win_hsearch(i, a)
- #define HCREATE(n) _win_hcreate(n)
- #define HDESTROY() _win_hdestroy()
- #define HSEARCH_R(i, a, r, h) _win_hsearch_r(i, a, r, h)
- #define HCREATE_R(n, h) _win_hcreate_r(n, h)
- #define HDESTROY_R(h) _win_hdestroy_r(h)
- #define TSEARCH(k, r, c) _win_tsearch(k, r, c)
- #define TFIND(k, r, c) _win_tfind(k, r, c)
- #define TDELETE(k, r, c) _win_tdelete(k, r, c)
- #define TWALK(r, a) _win_twalk(r, a)
- #define TDESTROY(r, f) _win_tdestroy(r, f)
- #define LFIND(k, b, n, s, c) _win_lfind(k, b, n, s, c)
- #define LSEARCH(k, b, n, s, c) _win_lsearch(k, b, n, s, c)
+ #define WAITPID(p, s, o) _win_waitpid (p, s, o)
+ #define ACCEPT(s, a, l) _win_accept (s, a, l)
+ #define BIND(s, n, l) _win_bind (s, n, l)
+ #define CONNECT(s, n, l) _win_connect (s, n, l)
+ #define GETPEERNAME(s, n, l) _win_getpeername (s, n, l)
+ #define GETSOCKNAME(s, n, l) _win_getsockname (s, n, l)
+ #define GETSOCKOPT(s, l, o, v, p) _win_getsockopt (s, l, o, v, p)
+ #define LISTEN(s, b) _win_listen (s, b)
+ #define RECV(s, b, l, f) _win_recv (s, b, l, f)
+ #define RECVFROM(s, b, l, f, r, o) _win_recvfrom (s, b, l, f, r, o)
+ #define SELECT(n, r, w, e, t) _win_select (n, r, w, e, t)
+ #define SEND(s, b, l, f) _win_send (s, b, l, f)
+ #define SENDTO(s, b, l, f, o, n) _win_sendto (s, b, l, f, o, n)
+ #define SETSOCKOPT(s, l, o, v, n) _win_setsockopt (s, l, o, v, n)
+ #define SHUTDOWN(s, h) _win_shutdown (s, h)
+ #define SOCKET(a, t, p) _win_socket (a, t, p)
+ #define SOCKETPAIR(a, t, p, v) _win_socketpair (a, t, p, v)
+ #define GETHOSTBYADDR(a, l, t) _win_gethostbyaddr (a, l, t)
+ #define GETHOSTBYNAME(n) _win_gethostbyname (n)
+ #define GETTIMEOFDAY(t, n) gettimeofday (t, n)
+ #define INSQUE(e, p) _win_insque (e, p)
+ #define REMQUE(e) _win_remque (e)
+ #define HSEARCH(i, a) _win_hsearch (i, a)
+ #define HCREATE(n) _win_hcreate (n)
+ #define HDESTROY() _win_hdestroy ()
+ #define HSEARCH_R(i, a, r, h) _win_hsearch_r (i, a, r, h)
+ #define HCREATE_R(n, h) _win_hcreate_r (n, h)
+ #define HDESTROY_R(h) _win_hdestroy_r (h)
+ #define TSEARCH(k, r, c) _win_tsearch (k, r, c)
+ #define TFIND(k, r, c) _win_tfind (k, r, c)
+ #define TDELETE(k, r, c) _win_tdelete (k, r, c)
+ #define TWALK(r, a) _win_twalk (r, a)
+ #define TDESTROY(r, f) _win_tdestroy (r, f)
+ #define LFIND(k, b, n, s, c) _win_lfind (k, b, n, s, c)
+ #define LSEARCH(k, b, n, s, c) _win_lsearch (k, b, n, s, c)
#define STRUCT_STAT64 struct _stati64
#endif
@@ -836,11 +943,11 @@ char *strcasestr(const char *haystack_start, const char *needle_start);
This is the type used by the `insque' and `remque' functions. */
struct PLIBC_SEARCH_QELEM
- {
- struct qelem *q_forw;
- struct qelem *q_back;
- char q_data[1];
- };
+{
+ struct qelem *q_forw;
+ struct qelem *q_back;
+ char q_data[1];
+};
/* Insert ELEM into a doubly-linked list, after PREV. */
@@ -857,17 +964,17 @@ typedef PLIBC_SEARCH__compar_fn_t _win_comparison_fn_t;
/* Action which shall be performed in the call the hsearch. */
typedef enum
- {
- PLIBC_SEARCH_FIND,
- PLIBC_SEARCH_ENTER
- }
+{
+ PLIBC_SEARCH_FIND,
+ PLIBC_SEARCH_ENTER
+}
PLIBC_SEARCH_ACTION;
typedef struct PLIBC_SEARCH_entry
- {
- char *key;
- void *data;
- }
+{
+ char *key;
+ void *data;
+}
PLIBC_SEARCH_ENTRY;
/* The reentrant version has no static variables to maintain the state.
@@ -889,7 +996,8 @@ _PLIBC_SEARCH_ENTRY;
ACTION is `FIND' return found entry or signal error by returning
NULL. If ACTION is `ENTER' replace existing data (if any) with
ITEM.data. */
-PLIBC_SEARCH_ENTRY *_win_hsearch (PLIBC_SEARCH_ENTRY __item, PLIBC_SEARCH_ACTION __action);
+PLIBC_SEARCH_ENTRY *_win_hsearch (PLIBC_SEARCH_ENTRY __item, PLIBC_SEARCH_ACTION
+ __action);
/* Create a new hashing table which will at most contain NEL elements. */
int _win_hcreate (size_t __nel);
@@ -899,17 +1007,20 @@ void _win_hdestroy (void);
/* Data type for reentrant functions. */
struct PLIBC_SEARCH_hsearch_data
- {
- struct _PLIBC_SEARCH_ENTRY *table;
- unsigned int size;
- unsigned int filled;
- };
+{
+ struct _PLIBC_SEARCH_ENTRY *table;
+ unsigned int size;
+ unsigned int filled;
+};
/* Reentrant versions which can handle multiple hashing tables at the
same time. */
-int _win_hsearch_r (PLIBC_SEARCH_ENTRY __item, PLIBC_SEARCH_ACTION __action, PLIBC_SEARCH_ENTRY **__retval,
- struct PLIBC_SEARCH_hsearch_data *__htab);
+int _win_hsearch_r (PLIBC_SEARCH_ENTRY __item, PLIBC_SEARCH_ACTION __action,
+ PLIBC_SEARCH_ENTRY **__retval,
+ struct PLIBC_SEARCH_hsearch_data *__htab);
+
int _win_hcreate_r (size_t __nel, struct PLIBC_SEARCH_hsearch_data *__htab);
+
void _win_hdestroy_r (struct PLIBC_SEARCH_hsearch_data *__htab);
@@ -930,20 +1041,21 @@ PLIBC_SEARCH_VISIT;
/* Search for an entry matching the given KEY in the tree pointed to
by *ROOTP and insert a new element if not found. */
void *_win_tsearch (__const void *__key, void **__rootp,
- PLIBC_SEARCH__compar_fn_t __compar);
+ PLIBC_SEARCH__compar_fn_t __compar);
/* Search for an entry matching the given KEY in the tree pointed to
by *ROOTP. If no matching entry is available return NULL. */
void *_win_tfind (__const void *__key, void *__const *__rootp,
- PLIBC_SEARCH__compar_fn_t __compar);
+ PLIBC_SEARCH__compar_fn_t __compar);
/* Remove the element matching KEY from the tree pointed to by *ROOTP. */
void *_win_tdelete (__const void *__restrict __key,
- void **__restrict __rootp,
- PLIBC_SEARCH__compar_fn_t __compar);
+ void **__restrict __rootp,
+ PLIBC_SEARCH__compar_fn_t __compar);
-typedef void (*PLIBC_SEARCH__action_fn_t) (__const void *__nodep, PLIBC_SEARCH_VISIT __value,
- int __level);
+typedef void (*PLIBC_SEARCH__action_fn_t) (__const void *__nodep,
+ PLIBC_SEARCH_VISIT __value,
+ int __level);
/* Walk through the whole tree and call the ACTION callback for every node
or leaf. */
@@ -960,12 +1072,14 @@ void _win_tdestroy (void *__root, PLIBC_SEARCH__free_fn_t __freefct);
/* Perform linear search for KEY by comparing by COMPAR in an array
[BASE,BASE+NMEMB*SIZE). */
void *_win_lfind (__const void *__key, __const void *__base,
- size_t *__nmemb, size_t __size, PLIBC_SEARCH__compar_fn_t __compar);
+ size_t *__nmemb, size_t __size, PLIBC_SEARCH__compar_fn_t
+ __compar);
/* Perform linear search for KEY by comparing by COMPAR function in
array [BASE,BASE+NMEMB*SIZE) and insert entry if not found. */
void *_win_lsearch (__const void *__key, void *__base,
- size_t *__nmemb, size_t __size, PLIBC_SEARCH__compar_fn_t __compar);
+ size_t *__nmemb, size_t __size, PLIBC_SEARCH__compar_fn_t
+ __compar);
#ifdef __cplusplus
@@ -973,6 +1087,6 @@ void *_win_lsearch (__const void *__key, void *__base,
#endif
-#endif //_PLIBC_H_
+#endif // _PLIBC_H_
/* end of plibc.h */
diff --git a/src/intlemu/intlemu.c b/src/intlemu/intlemu.c
@@ -15,132 +15,145 @@
static pthread_mutex_t intlemu_lock;
static CFMutableDictionaryRef intlemu_dict;
-static void intlemu_cstring_release(CFAllocatorRef allocator, const void *value)
+static void
+intlemu_cstring_release (CFAllocatorRef allocator, const void *value)
{
- free((void *)value);
+ free ((void *) value);
}
-void __attribute__ ((constructor)) intlemu_init_() {
- CFDictionaryValueCallBacks cstring_value_callbacks =
- {
- 0, /* version */
- NULL, /* retain callback */
- &intlemu_cstring_release, /* release callback */
- NULL, /* copy description */
- NULL /* equal */
- };
- if (pthread_mutex_init(&intlemu_lock, NULL) != 0)
- abort();
-
- intlemu_dict = CFDictionaryCreateMutable(
- kCFAllocatorDefault,
- 0,
- &kCFCopyStringDictionaryKeyCallBacks,
- &cstring_value_callbacks);
- if (intlemu_dict == NULL)
- abort();
-}
-void __attribute__ ((destructor)) intlemu_fini_() {
- if (intlemu_dict)
- CFRelease(intlemu_dict);
+void __attribute__ ((constructor))
+intlemu_init_ ()
+{
+ CFDictionaryValueCallBacks cstring_value_callbacks = {
+ 0, /* version */
+ NULL, /* retain callback */
+ &intlemu_cstring_release, /* release callback */
+ NULL, /* copy description */
+ NULL /* equal */
+ };
+ if (pthread_mutex_init (&intlemu_lock, NULL) != 0)
+ abort ();
- pthread_mutex_destroy(&intlemu_lock);
+ intlemu_dict = CFDictionaryCreateMutable (
+ kCFAllocatorDefault,
+ 0,
+ &kCFCopyStringDictionaryKeyCallBacks,
+ &cstring_value_callbacks);
+ if (intlemu_dict == NULL)
+ abort ();
}
-char * intlemu_bgettext (CFBundleRef bundle, const char *msgid)
+
+void __attribute__ ((destructor))
+intlemu_fini_ ()
{
- CFStringRef key;
- const char *value;
- CFStringRef s;
- CFRange r;
- CFIndex len;
- CFIndex clen;
- char *buf;
-
- if (msgid == NULL)
- return NULL;
- if (bundle == NULL)
- return msgid;
-
- key = CFStringCreateWithBytes(
- kCFAllocatorDefault,
- (const UInt8 *)msgid,
- (CFIndex)strlen(msgid),
- kCFStringEncodingUTF8,
- false);
-
- if (pthread_mutex_lock(&intlemu_lock) != 0)
- abort();
- value = (char *)CFDictionaryGetValue(intlemu_dict, key);
- if (pthread_mutex_unlock(&intlemu_lock) != 0)
- abort();
- if (value != NULL) {
- CFRelease(key);
- return (char *)value;
- }
-
- /* no cached translaation, so, find one from the bundle */
- s = CFBundleCopyLocalizedString(
- bundle,
- key,
- NULL,
- NULL);
- if (s == key) {
- CFRelease(key);
- return (char *)msgid;
- }
- /* get the length in bytes */
- r.location = 0;
- r.length = CFStringGetLength(s);
- len = 0;
- clen = CFStringGetBytes(
- s,
- r,
- kCFStringEncodingUTF8,
- 0,
- false,
- NULL,
- 0,
- &len);
- buf = NULL;
- if (clen == r.length) {
- buf = malloc(len + 1);
- }
-
- if (buf == NULL) {
- CFRelease(s);
- CFRelease(key);
- return (char *)msgid;
- }
-
- clen = CFStringGetBytes(
- s,
- r,
- kCFStringEncodingUTF8,
- 0,
- false,
- (UInt8 *)buf,
- len,
- &len);
- buf[len] = '\0';
- if (clen == r.length) {
- if (pthread_mutex_lock(&intlemu_lock) != 0)
- abort();
- CFDictionaryAddValue(intlemu_dict, key, buf);
- if (pthread_mutex_unlock(&intlemu_lock) != 0)
- abort();
- value = buf;
- }
- else {
- free(buf);
- value = msgid;
- }
-
- CFRelease(s);
-
- CFRelease(key);
-
- return (char *)value;
+ if (intlemu_dict)
+ CFRelease (intlemu_dict);
+
+ pthread_mutex_destroy (&intlemu_lock);
}
+
+char *
+intlemu_bgettext (CFBundleRef bundle, const char *msgid)
+{
+ CFStringRef key;
+ const char *value;
+ CFStringRef s;
+ CFRange r;
+ CFIndex len;
+ CFIndex clen;
+ char *buf;
+
+ if (msgid == NULL)
+ return NULL;
+ if (bundle == NULL)
+ return msgid;
+
+ key = CFStringCreateWithBytes (
+ kCFAllocatorDefault,
+ (const UInt8 *) msgid,
+ (CFIndex) strlen (msgid),
+ kCFStringEncodingUTF8,
+ false);
+
+ if (pthread_mutex_lock (&intlemu_lock) != 0)
+ abort ();
+ value = (char *) CFDictionaryGetValue (intlemu_dict, key);
+ if (pthread_mutex_unlock (&intlemu_lock) != 0)
+ abort ();
+ if (value != NULL)
+ {
+ CFRelease (key);
+ return (char *) value;
+ }
+
+ /* no cached translaation, so, find one from the bundle */
+ s = CFBundleCopyLocalizedString (
+ bundle,
+ key,
+ NULL,
+ NULL);
+ if (s == key)
+ {
+ CFRelease (key);
+ return (char *) msgid;
+ }
+ /* get the length in bytes */
+ r.location = 0;
+ r.length = CFStringGetLength (s);
+ len = 0;
+ clen = CFStringGetBytes (
+ s,
+ r,
+ kCFStringEncodingUTF8,
+ 0,
+ false,
+ NULL,
+ 0,
+ &len);
+ buf = NULL;
+ if (clen == r.length)
+ {
+ buf = malloc (len + 1);
+ }
+
+ if (buf == NULL)
+ {
+ CFRelease (s);
+ CFRelease (key);
+ return (char *) msgid;
+ }
+
+ clen = CFStringGetBytes (
+ s,
+ r,
+ kCFStringEncodingUTF8,
+ 0,
+ false,
+ (UInt8 *) buf,
+ len,
+ &len);
+ buf[len] = '\0';
+ if (clen == r.length)
+ {
+ if (pthread_mutex_lock (&intlemu_lock) != 0)
+ abort ();
+ CFDictionaryAddValue (intlemu_dict, key, buf);
+ if (pthread_mutex_unlock (&intlemu_lock) != 0)
+ abort ();
+ value = buf;
+ }
+ else
+ {
+ free (buf);
+ value = msgid;
+ }
+
+ CFRelease (s);
+
+ CFRelease (key);
+
+ return (char *) value;
+}
diff --git a/src/intlemu/libintlemu.h b/src/intlemu/libintlemu.h
@@ -14,13 +14,13 @@
#include <CoreFoundation/CoreFoundation.h>
#define gettext(msgid) \
- intlemu_bgettext(CFBundleGetMainBundle(), msgid)
+ intlemu_bgettext (CFBundleGetMainBundle (), msgid)
#define dgettext(domainname, msgid) \
- intlemu_bgettext(CFBundleGetBundleWithIdentifier(CFSTR(domainname)), msgid)
+ intlemu_bgettext (CFBundleGetBundleWithIdentifier (CFSTR (domainname)), msgid)
#define gettext_noop(s) s
-extern char * intlemu_bgettext (CFBundleRef bundle, const char *msgid);
+extern char *intlemu_bgettext (CFBundleRef bundle, const char *msgid);
#endif
diff --git a/src/main/extract.c b/src/main/extract.c
@@ -73,6 +73,8 @@ ignore_sigpipe ()
FPRINTF (stderr,
"Failed to install SIGPIPE handler: %s\n", strerror (errno));
}
+
+
#endif
@@ -89,17 +91,17 @@ struct Help
/**
* Long name of the option.
*/
- const char * longArg;
+ const char *longArg;
/**
* Name of the mandatory argument, NULL for no argument.
*/
- const char * mandatoryArg;
+ const char *mandatoryArg;
/**
* Help text for the option.
*/
- const char * description;
+ const char *description;
};
@@ -118,8 +120,8 @@ struct Help
*/
static void
format_help (const char *general,
- const char *description,
- const struct Help *opt)
+ const char *description,
+ const struct Help *opt)
{
size_t slen;
unsigned int i;
@@ -129,79 +131,80 @@ format_help (const char *general,
char scp[80];
const char *trans;
- printf (_("Usage: %s\n%s\n\n"),
- gettext(general),
- gettext(description));
- printf (_("Arguments mandatory for long options are also mandatory for short options.\n"));
+ printf (_ ("Usage: %s\n%s\n\n"),
+ gettext (general),
+ gettext (description));
+ printf (_ (
+ "Arguments mandatory for long options are also mandatory for short options.\n"));
slen = 0;
i = 0;
while (NULL != opt[i].description)
+ {
+ if (0 == opt[i].shortArg)
+ printf (" ");
+ else
+ printf (" -%c, ",
+ opt[i].shortArg);
+ printf ("--%s",
+ opt[i].longArg);
+ slen = 8 + strlen (opt[i].longArg);
+ if (NULL != opt[i].mandatoryArg)
{
- if (0 == opt[i].shortArg)
- printf (" ");
- else
- printf (" -%c, ",
- opt[i].shortArg);
- printf ("--%s",
- opt[i].longArg);
- slen = 8 + strlen(opt[i].longArg);
- if (NULL != opt[i].mandatoryArg)
- {
- printf ("=%s",
- opt[i].mandatoryArg);
- slen += 1+strlen(opt[i].mandatoryArg);
- }
- if (slen > BORDER)
- {
- printf ("\n%*s", BORDER, "");
- slen = BORDER;
- }
- if (slen < BORDER)
- {
- printf ("%*s", (int) (BORDER - slen), "");
- slen = BORDER;
- }
- trans = gettext(opt[i].description);
- ml = strlen(trans);
- p = 0;
- OUTER:
- while (ml - p > 78 - slen)
- {
- for (j=p+78-slen;j>p;j--)
- {
- if (isspace( (unsigned char) trans[j]))
- {
- memcpy(scp,
- &trans[p],
- j-p);
- scp[j-p] = '\0';
- printf ("%s\n%*s",
- scp,
- BORDER + 2,
- "");
- p = j+1;
- slen = BORDER + 2;
- goto OUTER;
- }
- }
- /* could not find space to break line */
- memcpy (scp,
- &trans[p],
- 78 - slen);
- scp[78 - slen] = '\0';
- printf ("%s\n%*s",
- scp,
- BORDER+2,
- "");
- slen = BORDER+2;
- p = p + 78 - slen;
- }
- /* print rest */
- if (p < ml)
- printf("%s\n",
- &trans[p]);
- i++;
+ printf ("=%s",
+ opt[i].mandatoryArg);
+ slen += 1 + strlen (opt[i].mandatoryArg);
+ }
+ if (slen > BORDER)
+ {
+ printf ("\n%*s", BORDER, "");
+ slen = BORDER;
+ }
+ if (slen < BORDER)
+ {
+ printf ("%*s", (int) (BORDER - slen), "");
+ slen = BORDER;
+ }
+ trans = gettext (opt[i].description);
+ ml = strlen (trans);
+ p = 0;
+OUTER:
+ while (ml - p > 78 - slen)
+ {
+ for (j = p + 78 - slen; j>p; j--)
+ {
+ if (isspace ( (unsigned char) trans[j]))
+ {
+ memcpy (scp,
+ &trans[p],
+ j - p);
+ scp[j - p] = '\0';
+ printf ("%s\n%*s",
+ scp,
+ BORDER + 2,
+ "");
+ p = j + 1;
+ slen = BORDER + 2;
+ goto OUTER;
+ }
+ }
+ /* could not find space to break line */
+ memcpy (scp,
+ &trans[p],
+ 78 - slen);
+ scp[78 - slen] = '\0';
+ printf ("%s\n%*s",
+ scp,
+ BORDER + 2,
+ "");
+ slen = BORDER + 2;
+ p = p + 78 - slen;
}
+ /* print rest */
+ if (p < ml)
+ printf ("%s\n",
+ &trans[p]);
+ i++;
+ }
}
@@ -211,40 +214,43 @@ format_help (const char *general,
static void
print_help ()
{
- static struct Help help[] =
- {
- { 'b', "bibtex", NULL,
- gettext_noop("print output in bibtex format") },
- { 'g', "grep-friendly", NULL,
- gettext_noop("produce grep-friendly output (all results on one line per file)") },
- { 'h', "help", NULL,
- gettext_noop("print this help") },
- { 'i', "in-process", NULL,
- gettext_noop("run plugins in-process (simplifies debugging)") },
- { 'm', "from-memory", NULL,
- gettext_noop("read data from file into memory and extract from memory") },
- { 'l', "library", "LIBRARY",
- gettext_noop("load an extractor plugin named LIBRARY") },
- { 'L', "list", NULL,
- gettext_noop("list all keyword types") },
- { 'n', "nodefault", NULL,
- gettext_noop("do not use the default set of extractor plugins") },
- { 'p', "print", "TYPE",
- gettext_noop("print only keywords of the given TYPE (use -L to get a list)") },
- { 'v', "version", NULL,
- gettext_noop("print the version number") },
- { 'V', "verbose", NULL,
- gettext_noop("be verbose") },
- { 'x', "exclude", "TYPE",
- gettext_noop("do not print keywords of the given TYPE") },
- { 0, NULL, NULL, NULL },
- };
- format_help (_("extract [OPTIONS] [FILENAME]*"),
- _("Extract metadata from files."),
- help);
+ static struct Help help[] = {
+ { 'b', "bibtex", NULL,
+ gettext_noop ("print output in bibtex format") },
+ { 'g', "grep-friendly", NULL,
+ gettext_noop (
+ "produce grep-friendly output (all results on one line per file)") },
+ { 'h', "help", NULL,
+ gettext_noop ("print this help") },
+ { 'i', "in-process", NULL,
+ gettext_noop ("run plugins in-process (simplifies debugging)") },
+ { 'm', "from-memory", NULL,
+ gettext_noop (
+ "read data from file into memory and extract from memory") },
+ { 'l', "library", "LIBRARY",
+ gettext_noop ("load an extractor plugin named LIBRARY") },
+ { 'L', "list", NULL,
+ gettext_noop ("list all keyword types") },
+ { 'n', "nodefault", NULL,
+ gettext_noop ("do not use the default set of extractor plugins") },
+ { 'p', "print", "TYPE",
+ gettext_noop (
+ "print only keywords of the given TYPE (use -L to get a list)") },
+ { 'v', "version", NULL,
+ gettext_noop ("print the version number") },
+ { 'V', "verbose", NULL,
+ gettext_noop ("be verbose") },
+ { 'x', "exclude", "TYPE",
+ gettext_noop ("do not print keywords of the given TYPE") },
+ { 0, NULL, NULL, NULL },
+ };
+ format_help (_ ("extract [OPTIONS] [FILENAME]*"),
+ _ ("Extract metadata from files."),
+ help);
}
+
#if HAVE_ICONV
#include "iconv.c"
#endif
@@ -267,12 +273,12 @@ print_help ()
*/
static int
print_selected_keywords (void *cls,
- const char *plugin_name,
- enum EXTRACTOR_MetaType type,
- enum EXTRACTOR_MetaFormat format,
- const char *data_mime_type,
- const char *data,
- size_t data_len)
+ const char *plugin_name,
+ enum EXTRACTOR_MetaType type,
+ enum EXTRACTOR_MetaFormat format,
+ const char *data_mime_type,
+ const char *data,
+ size_t data_len)
{
char *keyword;
#if HAVE_ICONV
@@ -285,59 +291,59 @@ print_selected_keywords (void *cls,
return 0;
if (verbose > 3)
FPRINTF (stdout,
- _("Found by `%s' plugin:\n"),
- plugin_name);
+ _ ("Found by `%s' plugin:\n"),
+ plugin_name);
mt = EXTRACTOR_metatype_to_string (type);
- stype = (NULL == mt) ? _("unknown") : gettext(mt);
+ stype = (NULL == mt) ? _ ("unknown") : gettext (mt);
switch (format)
- {
- case EXTRACTOR_METAFORMAT_UNKNOWN:
- FPRINTF (stdout,
- _("%s - (unknown, %u bytes)\n"),
- stype,
- (unsigned int) data_len);
+ {
+ case EXTRACTOR_METAFORMAT_UNKNOWN:
+ FPRINTF (stdout,
+ _ ("%s - (unknown, %u bytes)\n"),
+ stype,
+ (unsigned int) data_len);
+ break;
+ case EXTRACTOR_METAFORMAT_UTF8:
+ if (0 == data_len)
break;
- case EXTRACTOR_METAFORMAT_UTF8:
- if (0 == data_len)
- break;
-#if HAVE_ICONV
- cd = iconv_open (nl_langinfo(CODESET), "UTF-8");
- if (((iconv_t) -1) != cd)
- keyword = iconv_helper (cd,
- data,
- data_len);
- else
-#endif
- keyword = strdup (data);
- if (NULL != keyword)
- {
- FPRINTF (stdout,
- "%s - %s\n",
- stype,
- keyword);
- free (keyword);
- }
#if HAVE_ICONV
- if (((iconv_t) -1) != cd)
- iconv_close (cd);
+ cd = iconv_open (nl_langinfo (CODESET), "UTF-8");
+ if (((iconv_t) -1) != cd)
+ keyword = iconv_helper (cd,
+ data,
+ data_len);
+ else
#endif
- break;
- case EXTRACTOR_METAFORMAT_BINARY:
- FPRINTF (stdout,
- _("%s - (binary, %u bytes)\n"),
- stype,
- (unsigned int) data_len);
- break;
- case EXTRACTOR_METAFORMAT_C_STRING:
+ keyword = strdup (data);
+ if (NULL != keyword)
+ {
FPRINTF (stdout,
- "%s - %.*s\n",
- stype,
- (int) data_len,
- data);
- break;
- default:
- break;
+ "%s - %s\n",
+ stype,
+ keyword);
+ free (keyword);
}
+#if HAVE_ICONV
+ if (((iconv_t) -1) != cd)
+ iconv_close (cd);
+#endif
+ break;
+ case EXTRACTOR_METAFORMAT_BINARY:
+ FPRINTF (stdout,
+ _ ("%s - (binary, %u bytes)\n"),
+ stype,
+ (unsigned int) data_len);
+ break;
+ case EXTRACTOR_METAFORMAT_C_STRING:
+ FPRINTF (stdout,
+ "%s - %.*s\n",
+ stype,
+ (int) data_len,
+ data);
+ break;
+ default:
+ break;
+ }
return 0;
}
@@ -360,12 +366,12 @@ print_selected_keywords (void *cls,
*/
static int
print_selected_keywords_grep_friendly (void *cls,
- const char *plugin_name,
- enum EXTRACTOR_MetaType type,
- enum EXTRACTOR_MetaFormat format,
- const char *data_mime_type,
- const char *data,
- size_t data_len)
+ const char *plugin_name,
+ enum EXTRACTOR_MetaType type,
+ enum EXTRACTOR_MetaFormat format,
+ const char *data_mime_type,
+ const char *data,
+ size_t data_len)
{
char *keyword;
#if HAVE_ICONV
@@ -379,51 +385,51 @@ print_selected_keywords_grep_friendly (void *cls,
if (NULL == mt)
mt = gettext_noop ("unknown");
switch (format)
- {
- case EXTRACTOR_METAFORMAT_UNKNOWN:
- break;
- case EXTRACTOR_METAFORMAT_UTF8:
- if (0 == data_len)
- return 0;
- if (verbose > 1)
- FPRINTF (stdout,
- "%s: ",
- gettext(mt));
+ {
+ case EXTRACTOR_METAFORMAT_UNKNOWN:
+ break;
+ case EXTRACTOR_METAFORMAT_UTF8:
+ if (0 == data_len)
+ return 0;
+ if (verbose > 1)
+ FPRINTF (stdout,
+ "%s: ",
+ gettext (mt));
#if HAVE_ICONV
- cd = iconv_open (nl_langinfo (CODESET), "UTF-8");
- if (((iconv_t) -1) != cd)
- keyword = iconv_helper (cd,
- data,
- data_len);
- else
+ cd = iconv_open (nl_langinfo (CODESET), "UTF-8");
+ if (((iconv_t) -1) != cd)
+ keyword = iconv_helper (cd,
+ data,
+ data_len);
+ else
#endif
- keyword = strdup (data);
- if (NULL != keyword)
- {
- FPRINTF (stdout,
- "`%s' ",
- keyword);
- free (keyword);
- }
+ keyword = strdup (data);
+ if (NULL != keyword)
+ {
+ FPRINTF (stdout,
+ "`%s' ",
+ keyword);
+ free (keyword);
+ }
#if HAVE_ICONV
- if (((iconv_t) -1) != cd)
- iconv_close (cd);
+ if (((iconv_t) -1) != cd)
+ iconv_close (cd);
#endif
- break;
- case EXTRACTOR_METAFORMAT_BINARY:
- break;
- case EXTRACTOR_METAFORMAT_C_STRING:
- if (verbose > 1)
- FPRINTF (stdout,
- "%s ",
- gettext(mt));
+ break;
+ case EXTRACTOR_METAFORMAT_BINARY:
+ break;
+ case EXTRACTOR_METAFORMAT_C_STRING:
+ if (verbose > 1)
FPRINTF (stdout,
- "`%s'",
- data);
- break;
- default:
- break;
- }
+ "%s ",
+ gettext (mt));
+ FPRINTF (stdout,
+ "`%s'",
+ data);
+ break;
+ default:
+ break;
+ }
return 0;
}
@@ -459,31 +465,30 @@ static char *entry_type;
* Mapping between bibTeX strings, libextractor
* meta data types and values for the current document.
*/
-static struct BibTexMap btm[] =
- {
- { "title", EXTRACTOR_METATYPE_TITLE, NULL},
- { "year", EXTRACTOR_METATYPE_PUBLICATION_YEAR, NULL },
- { "author", EXTRACTOR_METATYPE_AUTHOR_NAME, NULL },
- { "book", EXTRACTOR_METATYPE_BOOK_TITLE, NULL},
- { "edition", EXTRACTOR_METATYPE_BOOK_EDITION, NULL},
- { "chapter", EXTRACTOR_METATYPE_BOOK_CHAPTER_NUMBER, NULL},
- { "journal", EXTRACTOR_METATYPE_JOURNAL_NAME, NULL},
- { "volume", EXTRACTOR_METATYPE_JOURNAL_VOLUME, NULL},
- { "number", EXTRACTOR_METATYPE_JOURNAL_NUMBER, NULL},
- { "pages", EXTRACTOR_METATYPE_PAGE_COUNT, NULL },
- { "pages", EXTRACTOR_METATYPE_PAGE_RANGE, NULL },
- { "school", EXTRACTOR_METATYPE_AUTHOR_INSTITUTION, NULL},
- { "publisher", EXTRACTOR_METATYPE_PUBLISHER, NULL },
- { "address", EXTRACTOR_METATYPE_PUBLISHER_ADDRESS, NULL },
- { "institution", EXTRACTOR_METATYPE_PUBLISHER_INSTITUTION, NULL },
- { "series", EXTRACTOR_METATYPE_PUBLISHER_SERIES, NULL},
- { "month", EXTRACTOR_METATYPE_PUBLICATION_MONTH, NULL },
- { "url", EXTRACTOR_METATYPE_URL, NULL},
- { "note", EXTRACTOR_METATYPE_COMMENT, NULL},
- { "eprint", EXTRACTOR_METATYPE_BIBTEX_EPRINT, NULL },
- { "type", EXTRACTOR_METATYPE_PUBLICATION_TYPE, NULL },
- { NULL, 0, NULL }
- };
+static struct BibTexMap btm[] = {
+ { "title", EXTRACTOR_METATYPE_TITLE, NULL},
+ { "year", EXTRACTOR_METATYPE_PUBLICATION_YEAR, NULL },
+ { "author", EXTRACTOR_METATYPE_AUTHOR_NAME, NULL },
+ { "book", EXTRACTOR_METATYPE_BOOK_TITLE, NULL},
+ { "edition", EXTRACTOR_METATYPE_BOOK_EDITION, NULL},
+ { "chapter", EXTRACTOR_METATYPE_BOOK_CHAPTER_NUMBER, NULL},
+ { "journal", EXTRACTOR_METATYPE_JOURNAL_NAME, NULL},
+ { "volume", EXTRACTOR_METATYPE_JOURNAL_VOLUME, NULL},
+ { "number", EXTRACTOR_METATYPE_JOURNAL_NUMBER, NULL},
+ { "pages", EXTRACTOR_METATYPE_PAGE_COUNT, NULL },
+ { "pages", EXTRACTOR_METATYPE_PAGE_RANGE, NULL },
+ { "school", EXTRACTOR_METATYPE_AUTHOR_INSTITUTION, NULL},
+ { "publisher", EXTRACTOR_METATYPE_PUBLISHER, NULL },
+ { "address", EXTRACTOR_METATYPE_PUBLISHER_ADDRESS, NULL },
+ { "institution", EXTRACTOR_METATYPE_PUBLISHER_INSTITUTION, NULL },
+ { "series", EXTRACTOR_METATYPE_PUBLISHER_SERIES, NULL},
+ { "month", EXTRACTOR_METATYPE_PUBLICATION_MONTH, NULL },
+ { "url", EXTRACTOR_METATYPE_URL, NULL},
+ { "note", EXTRACTOR_METATYPE_COMMENT, NULL},
+ { "eprint", EXTRACTOR_METATYPE_BIBTEX_EPRINT, NULL },
+ { "type", EXTRACTOR_METATYPE_PUBLICATION_TYPE, NULL },
+ { NULL, 0, NULL }
+};
/**
@@ -495,10 +500,10 @@ cleanup_bibtex ()
unsigned int i;
for (i = 0; NULL != btm[i].bibTexName; i++)
- {
- free (btm[i].value);
- btm[i].value = NULL;
- }
+ {
+ free (btm[i].value);
+ btm[i].value = NULL;
+ }
free (entry_type);
entry_type = NULL;
}
@@ -522,12 +527,12 @@ cleanup_bibtex ()
*/
static int
print_bibtex (void *cls,
- const char *plugin_name,
- enum EXTRACTOR_MetaType type,
- enum EXTRACTOR_MetaFormat format,
- const char *data_mime_type,
- const char *data,
- size_t data_len)
+ const char *plugin_name,
+ enum EXTRACTOR_MetaType type,
+ enum EXTRACTOR_MetaFormat format,
+ const char *data_mime_type,
+ const char *data,
+ size_t data_len)
{
unsigned int i;
@@ -538,13 +543,13 @@ print_bibtex (void *cls,
if (EXTRACTOR_METAFORMAT_UTF8 != format)
return 0;
if (EXTRACTOR_METATYPE_BIBTEX_ENTRY_TYPE == type)
- {
- entry_type = strdup (data);
- return 0;
- }
+ {
+ entry_type = strdup (data);
+ return 0;
+ }
for (i = 0; NULL != btm[i].bibTexName; i++)
if ( (NULL == btm[i].value) &&
- (btm[i].le_type == type) )
+ (btm[i].le_type == type) )
btm[i].value = strdup (data);
return 0;
}
@@ -571,33 +576,33 @@ finish_bibtex (const char *fn)
(NULL == btm[1].value) ||
(NULL == btm[2].value) )
FPRINTF (stdout,
- "@%s %s { ",
- et,
- fn);
+ "@%s %s { ",
+ et,
+ fn);
else
- {
- snprintf (temp,
- sizeof (temp),
- "%.5s%.5s%.5s",
- btm[2].value,
- btm[1].value,
- btm[0].value);
- for (n=strlen (temp)-1;n>=0;n-- )
- if (! isalnum ( (unsigned char) temp[n]) )
- temp[n] = '_';
- else
- temp[n] = tolower ( (unsigned char) temp[n]);
- FPRINTF (stdout,
- "@%s %s { ",
- et,
- temp);
- }
- for (i=0; NULL != btm[i].bibTexName; i++)
+ {
+ snprintf (temp,
+ sizeof (temp),
+ "%.5s%.5s%.5s",
+ btm[2].value,
+ btm[1].value,
+ btm[0].value);
+ for (n = strlen (temp) - 1; n>=0; n--)
+ if (! isalnum ( (unsigned char) temp[n]) )
+ temp[n] = '_';
+ else
+ temp[n] = tolower ( (unsigned char) temp[n]);
+ FPRINTF (stdout,
+ "@%s %s { ",
+ et,
+ temp);
+ }
+ for (i = 0; NULL != btm[i].bibTexName; i++)
if (NULL != btm[i].value)
FPRINTF (stdout,
- "\t%s = {%s},\n",
- btm[i].bibTexName,
- btm[i].value);
+ "\t%s = {%s},\n",
+ btm[i].bibTexName,
+ btm[i].value);
FPRINTF (stdout, "%s", "}\n\n");
}
@@ -612,7 +617,9 @@ _wchar_to_str (const wchar_t *wstr, char **retstr, UINT cp)
DWORD error;
SetLastError (0);
- len = WideCharToMultiByte (cp, 0, wstr, -1, NULL, 0, NULL, (cp == CP_UTF8 || cp == CP_UTF7) ? NULL : &lossy);
+ len = WideCharToMultiByte (cp, 0, wstr, -1, NULL, 0, NULL, (cp == CP_UTF8 ||
+ cp == CP_UTF7) ?
+ NULL : &lossy);
error = GetLastError ();
if (len <= 0)
return -1;
@@ -620,7 +627,9 @@ _wchar_to_str (const wchar_t *wstr, char **retstr, UINT cp)
str = malloc (sizeof (char) * len);
SetLastError (0);
- lenc = WideCharToMultiByte (cp, 0, wstr, -1, str, len, NULL, (cp == CP_UTF8 || cp == CP_UTF7) ? NULL : &lossy);
+ lenc = WideCharToMultiByte (cp, 0, wstr, -1, str, len, NULL, (cp == CP_UTF8 ||
+ cp == CP_UTF7) ?
+ NULL : &lossy);
error = GetLastError ();
if (lenc != len)
{
@@ -632,6 +641,8 @@ _wchar_to_str (const wchar_t *wstr, char **retstr, UINT cp)
return 1;
return 0;
}
+
+
#endif
@@ -711,10 +722,10 @@ _get_utf8_args (int argc, char *const *argv, int *u8argc, char ***u8argv)
*u8argv = _make_continuous_arg_copy (wargc, split_u8argv);
if (NULL == *u8argv)
- {
- free (split_u8argv);
- return -1;
- }
+ {
+ free (split_u8argv);
+ return -1;
+ }
*u8argc = wargc;
for (i = 0; i < wargc; i++)
@@ -756,21 +767,21 @@ main (int argc, char *argv[])
int utf8_argc;
#if ENABLE_NLS
- setlocale(LC_ALL, "");
- textdomain(PACKAGE);
+ setlocale (LC_ALL, "");
+ textdomain (PACKAGE);
#endif
#ifndef WINDOWS
ignore_sigpipe ();
#endif
if (NULL == (print = malloc (sizeof (int) * EXTRACTOR_metatype_get_max ())))
- {
- FPRINTF (stderr,
- "malloc failed: %s\n",
- strerror (errno));
- return 1;
- }
+ {
+ FPRINTF (stderr,
+ "malloc failed: %s\n",
+ strerror (errno));
+ return 1;
+ }
for (i = 0; i < EXTRACTOR_metatype_get_max (); i++)
- print[i] = YES; /* default: print everything */
+ print[i] = YES; /* default: print everything */
if (0 != _get_utf8_args (argc, argv, &utf8_argc, &utf8_argv))
{
@@ -779,249 +790,252 @@ main (int argc, char *argv[])
}
while (1)
+ {
+ static struct option long_options[] = {
+ {"bibtex", 0, 0, 'b'},
+ {"grep-friendly", 0, 0, 'g'},
+ {"help", 0, 0, 'h'},
+ {"in-process", 0, 0, 'i'},
+ {"from-memory", 0, 0, 'm'},
+ {"list", 0, 0, 'L'},
+ {"library", 1, 0, 'l'},
+ {"nodefault", 0, 0, 'n'},
+ {"print", 1, 0, 'p'},
+ {"verbose", 0, 0, 'V'},
+ {"version", 0, 0, 'v'},
+ {"exclude", 1, 0, 'x'},
+ {0, 0, 0, 0}
+ };
+ option_index = 0;
+ c = getopt_long (utf8_argc,
+ utf8_argv,
+ "abghiml:Lnp:vVx:",
+ long_options,
+ &option_index);
+
+ if (c == -1)
+ break; /* No more flags to process */
+ switch (c)
{
- static struct option long_options[] = {
- {"bibtex", 0, 0, 'b'},
- {"grep-friendly", 0, 0, 'g'},
- {"help", 0, 0, 'h'},
- {"in-process", 0, 0, 'i'},
- {"from-memory", 0, 0, 'm'},
- {"list", 0, 0, 'L'},
- {"library", 1, 0, 'l'},
- {"nodefault", 0, 0, 'n'},
- {"print", 1, 0, 'p'},
- {"verbose", 0, 0, 'V'},
- {"version", 0, 0, 'v'},
- {"exclude", 1, 0, 'x'},
- {0, 0, 0, 0}
- };
- option_index = 0;
- c = getopt_long (utf8_argc,
- utf8_argv,
- "abghiml:Lnp:vVx:",
- long_options,
- &option_index);
-
- if (c == -1)
- break; /* No more flags to process */
- switch (c)
- {
- case 'b':
- bibtex = YES;
- if (NULL != processor)
- {
- FPRINTF (stderr,
- "%s",
- _("Illegal combination of options, cannot combine multiple styles of printing.\n"));
- free (utf8_argv);
- return 0;
- }
- processor = &print_bibtex;
- break;
- case 'g':
- grepfriendly = YES;
- if (NULL != processor)
- {
- FPRINTF (stderr,
- "%s",
- _("Illegal combination of options, cannot combine multiple styles of printing.\n"));
- free (utf8_argv);
- return 0;
- }
- processor = &print_selected_keywords_grep_friendly;
- break;
- case 'h':
- print_help ();
- free (utf8_argv);
- return 0;
- case 'i':
- in_process = YES;
- break;
- case 'm':
- from_memory = YES;
+ case 'b':
+ bibtex = YES;
+ if (NULL != processor)
+ {
+ FPRINTF (stderr,
+ "%s",
+ _ (
+ "Illegal combination of options, cannot combine multiple styles of printing.\n"));
+ free (utf8_argv);
+ return 0;
+ }
+ processor = &print_bibtex;
+ break;
+ case 'g':
+ grepfriendly = YES;
+ if (NULL != processor)
+ {
+ FPRINTF (stderr,
+ "%s",
+ _ (
+ "Illegal combination of options, cannot combine multiple styles of printing.\n"));
+ free (utf8_argv);
+ return 0;
+ }
+ processor = &print_selected_keywords_grep_friendly;
+ break;
+ case 'h':
+ print_help ();
+ free (utf8_argv);
+ return 0;
+ case 'i':
+ in_process = YES;
+ break;
+ case 'm':
+ from_memory = YES;
+ break;
+ case 'l':
+ libraries = optarg;
+ break;
+ case 'L':
+ i = 0;
+ while (NULL != EXTRACTOR_metatype_to_string (i))
+ printf ("%s\n",
+ gettext (EXTRACTOR_metatype_to_string (i++)));
+ free (utf8_argv);
+ return 0;
+ case 'n':
+ nodefault = YES;
+ break;
+ case 'p':
+ if (NULL == optarg)
+ {
+ FPRINTF (stderr,
+ _ (
+ "You must specify an argument for the `%s' option (option ignored).\n"),
+ "-p");
+ break;
+ }
+ if (YES == defaultAll)
+ {
+ defaultAll = NO;
+ i = 0;
+ while (NULL != EXTRACTOR_metatype_to_string (i))
+ print[i++] = NO;
+ }
+ i = 0;
+ while (NULL != EXTRACTOR_metatype_to_string (i))
+ {
+ if ( (0 == strcmp (optarg,
+ EXTRACTOR_metatype_to_string (i))) ||
+ (0 == strcmp (optarg,
+ gettext (EXTRACTOR_metatype_to_string (i)))) )
+
+ {
+ print[i] = YES;
break;
- case 'l':
- libraries = optarg;
- break;
- case 'L':
- i = 0;
- while (NULL != EXTRACTOR_metatype_to_string (i))
- printf ("%s\n",
- gettext(EXTRACTOR_metatype_to_string (i++)));
- free (utf8_argv);
- return 0;
- case 'n':
- nodefault = YES;
- break;
- case 'p':
- if (NULL == optarg)
- {
- FPRINTF(stderr,
- _("You must specify an argument for the `%s' option (option ignored).\n"),
- "-p");
- break;
- }
- if (YES == defaultAll)
- {
- defaultAll = NO;
- i = 0;
- while (NULL != EXTRACTOR_metatype_to_string (i))
- print[i++] = NO;
- }
- i = 0;
- while (NULL != EXTRACTOR_metatype_to_string (i))
- {
- if ( (0 == strcmp (optarg,
- EXTRACTOR_metatype_to_string (i))) ||
- (0 == strcmp (optarg,
- gettext(EXTRACTOR_metatype_to_string (i)))) )
-
- {
- print[i] = YES;
- break;
- }
- i++;
- }
- if (NULL == EXTRACTOR_metatype_to_string (i))
- {
- FPRINTF(stderr,
- "Unknown keyword type `%s', use option `%s' to get a list.\n",
- optarg,
- "-L");
- free (utf8_argv);
- return -1;
- }
- break;
- case 'v':
- printf ("extract v%s\n", PACKAGE_VERSION);
- free (utf8_argv);
- return 0;
- case 'V':
- verbose++;
- break;
- case 'x':
- i = 0;
- while (NULL != EXTRACTOR_metatype_to_string (i))
- {
- if ( (0 == strcmp (optarg,
- EXTRACTOR_metatype_to_string (i))) ||
- (0 == strcmp (optarg,
- gettext(EXTRACTOR_metatype_to_string (i)))) )
- {
- print[i] = NO;
- break;
- }
- i++;
- }
- if (NULL == EXTRACTOR_metatype_to_string (i))
- {
- FPRINTF (stderr,
- "Unknown keyword type `%s', use option `%s' to get a list.\n",
- optarg,
- "-L");
- free (utf8_argv);
- return -1;
- }
- break;
- default:
- FPRINTF (stderr,
- "%s",
- _("Use --help to get a list of options.\n"));
- free (utf8_argv);
- return -1;
- } /* end of parsing commandline */
- } /* while (1) */
- if (optind < 0)
- {
- FPRINTF (stderr,
- "%s", "Unknown error parsing options\n");
- free (print);
+ }
+ i++;
+ }
+ if (NULL == EXTRACTOR_metatype_to_string (i))
+ {
+ FPRINTF (stderr,
+ "Unknown keyword type `%s', use option `%s' to get a list.\n",
+ optarg,
+ "-L");
+ free (utf8_argv);
+ return -1;
+ }
+ break;
+ case 'v':
+ printf ("extract v%s\n", PACKAGE_VERSION);
free (utf8_argv);
- return -1;
- }
- if (utf8_argc - optind < 1)
- {
+ return 0;
+ case 'V':
+ verbose++;
+ break;
+ case 'x':
+ i = 0;
+ while (NULL != EXTRACTOR_metatype_to_string (i))
+ {
+ if ( (0 == strcmp (optarg,
+ EXTRACTOR_metatype_to_string (i))) ||
+ (0 == strcmp (optarg,
+ gettext (EXTRACTOR_metatype_to_string (i)))) )
+ {
+ print[i] = NO;
+ break;
+ }
+ i++;
+ }
+ if (NULL == EXTRACTOR_metatype_to_string (i))
+ {
+ FPRINTF (stderr,
+ "Unknown keyword type `%s', use option `%s' to get a list.\n",
+ optarg,
+ "-L");
+ free (utf8_argv);
+ return -1;
+ }
+ break;
+ default:
FPRINTF (stderr,
- "%s", "Invoke with list of filenames to extract keywords form!\n");
- free (print);
+ "%s",
+ _ ("Use --help to get a list of options.\n"));
free (utf8_argv);
return -1;
- }
+ } /* end of parsing commandline */
+ } /* while (1) */
+ if (optind < 0)
+ {
+ FPRINTF (stderr,
+ "%s", "Unknown error parsing options\n");
+ free (print);
+ free (utf8_argv);
+ return -1;
+ }
+ if (utf8_argc - optind < 1)
+ {
+ FPRINTF (stderr,
+ "%s", "Invoke with list of filenames to extract keywords form!\n");
+ free (print);
+ free (utf8_argv);
+ return -1;
+ }
/* build list of libraries */
if (NO == nodefault)
plugins = EXTRACTOR_plugin_add_defaults (in_process
- ? EXTRACTOR_OPTION_IN_PROCESS
- : EXTRACTOR_OPTION_DEFAULT_POLICY);
+ ? EXTRACTOR_OPTION_IN_PROCESS
+ : EXTRACTOR_OPTION_DEFAULT_POLICY);
else
plugins = NULL;
if (NULL != libraries)
plugins = EXTRACTOR_plugin_add_config (plugins,
- libraries,
- in_process
- ? EXTRACTOR_OPTION_IN_PROCESS
- : EXTRACTOR_OPTION_DEFAULT_POLICY);
+ libraries,
+ in_process
+ ? EXTRACTOR_OPTION_IN_PROCESS
+ : EXTRACTOR_OPTION_DEFAULT_POLICY);
if (NULL == processor)
processor = &print_selected_keywords;
/* extract keywords */
if (YES == bibtex)
- FPRINTF(stdout,
- "%s", _("% BiBTeX file\n"));
+ FPRINTF (stdout,
+ "%s", _ ("% BiBTeX file\n"));
for (i = optind; i < utf8_argc; i++)
+ {
+ errno = 0;
+ if (YES == grepfriendly)
+ FPRINTF (stdout, "%s ", utf8_argv[i]);
+ else if (NO == bibtex)
+ FPRINTF (stdout,
+ _ ("Keywords for file %s:\n"),
+ utf8_argv[i]);
+ else
+ cleanup_bibtex ();
+ if (NO == from_memory)
+ EXTRACTOR_extract (plugins,
+ utf8_argv[i],
+ NULL, 0,
+ processor,
+ NULL);
+ else
{
- errno = 0;
- if (YES == grepfriendly)
- FPRINTF (stdout, "%s ", utf8_argv[i]);
- else if (NO == bibtex)
- FPRINTF (stdout,
- _("Keywords for file %s:\n"),
- utf8_argv[i]);
- else
- cleanup_bibtex ();
- if (NO == from_memory)
- EXTRACTOR_extract (plugins,
- utf8_argv[i],
- NULL, 0,
- processor,
- NULL);
- else
- {
- struct stat sb;
- unsigned char *data = NULL;
- int f = OPEN (utf8_argv[i], O_RDONLY
+ struct stat sb;
+ unsigned char *data = NULL;
+ int f = OPEN (utf8_argv[i], O_RDONLY
#if WINDOWS
- | O_BINARY
+ | O_BINARY
#endif
- );
- if ( (-1 != f) &&
- (0 == FSTAT (f, &sb)) &&
- (NULL != (data = malloc ((size_t) sb.st_size))) &&
- (sb.st_size == READ (f, data, (size_t) sb.st_size) ) )
- {
- EXTRACTOR_extract (plugins,
- NULL,
- data, sb.st_size,
- processor,
- NULL);
- }
- else
- {
- if (verbose > 0)
- FPRINTF(stderr,
- "%s: %s: %s\n",
- utf8_argv[0], utf8_argv[i], strerror(errno));
- ret = 1;
- }
- if (NULL != data)
- free (data);
- if (-1 != f)
- (void) CLOSE (f);
- }
- if (YES == grepfriendly)
- FPRINTF (stdout, "%s", "\n");
- continue;
+ );
+ if ( (-1 != f) &&
+ (0 == FSTAT (f, &sb)) &&
+ (NULL != (data = malloc ((size_t) sb.st_size))) &&
+ (sb.st_size == READ (f, data, (size_t) sb.st_size) ) )
+ {
+ EXTRACTOR_extract (plugins,
+ NULL,
+ data, sb.st_size,
+ processor,
+ NULL);
+ }
+ else
+ {
+ if (verbose > 0)
+ FPRINTF (stderr,
+ "%s: %s: %s\n",
+ utf8_argv[0], utf8_argv[i], strerror (errno));
+ ret = 1;
+ }
+ if (NULL != data)
+ free (data);
+ if (-1 != f)
+ (void) CLOSE (f);
}
+ if (YES == grepfriendly)
+ FPRINTF (stdout, "%s", "\n");
+ continue;
+ }
if (YES == grepfriendly)
FPRINTF (stdout, "%s", "\n");
if (bibtex)
@@ -1036,4 +1050,5 @@ main (int argc, char *argv[])
return ret;
}
+
/* end of extract.c */
diff --git a/src/main/extractor.c b/src/main/extractor.c
@@ -71,9 +71,9 @@ struct PluginReplyProcessor
*/
static void
send_update_message (struct EXTRACTOR_PluginList *plugin,
- int64_t shm_off,
- size_t data_available,
- struct EXTRACTOR_Datasource *ds)
+ int64_t shm_off,
+ size_t data_available,
+ struct EXTRACTOR_Datasource *ds)
{
struct UpdateMessage um;
@@ -85,14 +85,14 @@ send_update_message (struct EXTRACTOR_PluginList *plugin,
um.file_size = EXTRACTOR_datasource_get_size_ (ds, 0);
if (sizeof (um) !=
EXTRACTOR_IPC_channel_send_ (plugin->channel,
- &um,
- sizeof (um)) )
- {
- LOG ("Failed to send UPDATED_SHM message to plugin\n");
- EXTRACTOR_IPC_channel_destroy_ (plugin->channel);
- plugin->channel = NULL;
- plugin->round_finished = 1;
- }
+ &um,
+ sizeof (um)) )
+ {
+ LOG ("Failed to send UPDATED_SHM message to plugin\n");
+ EXTRACTOR_IPC_channel_destroy_ (plugin->channel);
+ plugin->channel = NULL;
+ plugin->round_finished = 1;
+ }
}
@@ -109,14 +109,14 @@ send_discard_message (struct EXTRACTOR_PluginList *plugin)
if (sizeof (disc_msg) !=
EXTRACTOR_IPC_channel_send_ (plugin->channel,
- &disc_msg,
- sizeof (disc_msg)) )
- {
- LOG ("Failed to send DISCARD_STATE message to plugin\n");
- EXTRACTOR_IPC_channel_destroy_ (plugin->channel);
- plugin->channel = NULL;
- plugin->round_finished = 1;
- }
+ &disc_msg,
+ sizeof (disc_msg)) )
+ {
+ LOG ("Failed to send DISCARD_STATE message to plugin\n");
+ EXTRACTOR_IPC_channel_destroy_ (plugin->channel);
+ plugin->channel = NULL;
+ plugin->round_finished = 1;
+ }
}
@@ -131,12 +131,12 @@ abort_all_channels (struct EXTRACTOR_PluginList *plugins)
struct EXTRACTOR_PluginList *pos;
for (pos = plugins; NULL != pos; pos = pos->next)
- {
- if (NULL == pos->channel)
- continue;
- EXTRACTOR_IPC_channel_destroy_ (pos->channel);
- pos->channel = NULL;
- }
+ {
+ if (NULL == pos->channel)
+ continue;
+ EXTRACTOR_IPC_channel_destroy_ (pos->channel);
+ pos->channel = NULL;
+ }
}
@@ -153,46 +153,46 @@ abort_all_channels (struct EXTRACTOR_PluginList *plugins)
*/
static void
process_plugin_reply (void *cls,
- struct EXTRACTOR_PluginList *plugin,
- enum EXTRACTOR_MetaType meta_type,
- enum EXTRACTOR_MetaFormat meta_format,
- const char *mime,
- const void *value,
+ struct EXTRACTOR_PluginList *plugin,
+ enum EXTRACTOR_MetaType meta_type,
+ enum EXTRACTOR_MetaFormat meta_format,
+ const char *mime,
+ const void *value,
size_t value_len)
{
static unsigned char cont_msg = MESSAGE_CONTINUE_EXTRACTING;
struct PluginReplyProcessor *prp = cls;
if (0 != prp->file_finished)
- {
- /* client already aborted, ignore message, tell plugin about abort */
- return;
- }
+ {
+ /* client already aborted, ignore message, tell plugin about abort */
+ return;
+ }
if (0 != prp->proc (prp->proc_cls,
- plugin->short_libname,
- meta_type,
- meta_format,
- mime,
- value,
- value_len))
- {
- prp->file_finished = 1;
+ plugin->short_libname,
+ meta_type,
+ meta_format,
+ mime,
+ value,
+ value_len))
+ {
+ prp->file_finished = 1;
#if DEBUG
- fprintf (stderr, "Sending ABRT\n");
+ fprintf (stderr, "Sending ABRT\n");
#endif
- send_discard_message (plugin);
- return;
- }
+ send_discard_message (plugin);
+ return;
+ }
if (sizeof (cont_msg) !=
EXTRACTOR_IPC_channel_send_ (plugin->channel,
- &cont_msg,
- sizeof (cont_msg)) )
- {
- LOG ("Failed to send CONTINUE_EXTRACTING message to plugin\n");
- EXTRACTOR_IPC_channel_destroy_ (plugin->channel);
- plugin->channel = NULL;
- plugin->round_finished = 1;
- }
+ &cont_msg,
+ sizeof (cont_msg)) )
+ {
+ LOG ("Failed to send CONTINUE_EXTRACTING message to plugin\n");
+ EXTRACTOR_IPC_channel_destroy_ (plugin->channel);
+ plugin->channel = NULL;
+ plugin->round_finished = 1;
+ }
}
@@ -245,8 +245,8 @@ struct InProcessContext
*/
static ssize_t
in_process_read (void *cls,
- void **data,
- size_t size)
+ void **data,
+ size_t size)
{
struct InProcessContext *ctx = cls;
ssize_t ret;
@@ -256,8 +256,8 @@ in_process_read (void *cls,
if (size < bsize)
bsize = size;
ret = EXTRACTOR_datasource_read_ (ctx->ds,
- ctx->buf,
- bsize);
+ ctx->buf,
+ bsize);
if (-1 == ret)
*data = NULL;
else
@@ -279,14 +279,14 @@ in_process_read (void *cls,
*/
static int64_t
in_process_seek (void *cls,
- int64_t pos,
- int whence)
+ int64_t pos,
+ int whence)
{
struct InProcessContext *ctx = cls;
return EXTRACTOR_datasource_seek_ (ctx->ds,
- pos,
- whence);
+ pos,
+ whence);
}
@@ -326,12 +326,12 @@ in_process_get_size (void *cls)
*/
static int
in_process_proc (void *cls,
- const char *plugin_name,
- enum EXTRACTOR_MetaType type,
- enum EXTRACTOR_MetaFormat format,
- const char *data_mime_type,
- const char *data,
- size_t data_len)
+ const char *plugin_name,
+ enum EXTRACTOR_MetaType type,
+ enum EXTRACTOR_MetaFormat format,
+ const char *data_mime_type,
+ const char *data,
+ size_t data_len)
{
struct InProcessContext *ctx = cls;
int ret;
@@ -339,12 +339,12 @@ in_process_proc (void *cls,
if (0 != ctx->finished)
return 1;
ret = ctx->proc (ctx->proc_cls,
- plugin_name,
- type,
- format,
- data_mime_type,
- data,
- data_len);
+ plugin_name,
+ type,
+ format,
+ data_mime_type,
+ data,
+ data_len);
if (0 != ret)
ctx->finished = 1;
return ret;
@@ -363,9 +363,9 @@ in_process_proc (void *cls,
*/
static void
do_extract (struct EXTRACTOR_PluginList *plugins,
- struct EXTRACTOR_SharedMemory *shm,
- struct EXTRACTOR_Datasource *ds,
- EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
+ struct EXTRACTOR_SharedMemory *shm,
+ struct EXTRACTOR_Datasource *ds,
+ EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
{
unsigned int plugin_count;
unsigned int plugin_off;
@@ -406,153 +406,153 @@ do_extract (struct EXTRACTOR_PluginList *plugins,
start.shm_ready_bytes = (uint32_t) ready;
start.file_size = EXTRACTOR_datasource_get_size_ (ds, 0);
for (pos = plugins; NULL != pos; pos = pos->next)
+ {
+ if (EXTRACTOR_OPTION_IN_PROCESS == pos->flags)
+ have_in_memory = 1;
+ if ( (NULL != pos->channel) &&
+ (-1 == EXTRACTOR_IPC_channel_send_ (pos->channel,
+ &start,
+ sizeof (start)) ) )
{
- if (EXTRACTOR_OPTION_IN_PROCESS == pos->flags)
- have_in_memory = 1;
- if ( (NULL != pos->channel) &&
- (-1 == EXTRACTOR_IPC_channel_send_ (pos->channel,
- &start,
- sizeof (start)) ) )
- {
- LOG ("Failed to send EXTRACT_START message to plugin\n");
- EXTRACTOR_IPC_channel_destroy_ (pos->channel);
- pos->channel = NULL;
- }
+ LOG ("Failed to send EXTRACT_START message to plugin\n");
+ EXTRACTOR_IPC_channel_destroy_ (pos->channel);
+ pos->channel = NULL;
}
+ }
if (-1 == ready)
- {
- LOG ("Failed to initialize IPC shared memory, cannot extract\n");
- done = 1;
- }
+ {
+ LOG ("Failed to initialize IPC shared memory, cannot extract\n");
+ done = 1;
+ }
else
done = 0;
while (! done)
+ {
+ struct EXTRACTOR_Channel *channels[plugin_count];
+
+ /* calculate current 'channels' array */
+ plugin_off = 0;
+ for (pos = plugins; NULL != pos; pos = pos->next)
{
- struct EXTRACTOR_Channel *channels[plugin_count];
-
- /* calculate current 'channels' array */
- plugin_off = 0;
- for (pos = plugins; NULL != pos; pos = pos->next)
- {
- if (-1 == pos->seek_request)
- {
- /* channel is not seeking, must be running or done */
- channels[plugin_off] = pos->channel;
- }
- else
- {
- /* not running this round, seeking! */
- channels[plugin_off] = NULL;
- }
- plugin_off++;
- }
- /* give plugins chance to send us meta data, seek or finished messages */
- if (-1 ==
- EXTRACTOR_IPC_channel_recv_ (channels,
- plugin_count,
- &process_plugin_reply,
- &prp))
- {
- /* serious problem in IPC; reset *all* channels */
- LOG ("Failed to receive message from channels; full reset\n");
- abort_all_channels (plugins);
- break;
- }
-
- /* calculate minimum seek request (or set done=0 to continue here) */
- done = 1;
- min_seek = -1;
- plugin_off = 0;
- for (pos = plugins; NULL != pos; pos = pos->next)
- {
- plugin_off++;
- if ( (1 == pos->round_finished) ||
- (NULL == pos->channel) )
+ if (-1 == pos->seek_request)
+ {
+ /* channel is not seeking, must be running or done */
+ channels[plugin_off] = pos->channel;
+ }
+ else
+ {
+ /* not running this round, seeking! */
+ channels[plugin_off] = NULL;
+ }
+ plugin_off++;
+ }
+ /* give plugins chance to send us meta data, seek or finished messages */
+ if (-1 ==
+ EXTRACTOR_IPC_channel_recv_ (channels,
+ plugin_count,
+ &process_plugin_reply,
+ &prp))
+ {
+ /* serious problem in IPC; reset *all* channels */
+ LOG ("Failed to receive message from channels; full reset\n");
+ abort_all_channels (plugins);
+ break;
+ }
+
+ /* calculate minimum seek request (or set done=0 to continue here) */
+ done = 1;
+ min_seek = -1;
+ plugin_off = 0;
+ for (pos = plugins; NULL != pos; pos = pos->next)
+ {
+ plugin_off++;
+ if ( (1 == pos->round_finished) ||
+ (NULL == pos->channel) )
+ {
+ continue; /* inactive plugin */
+ }
+ if (-1 == pos->seek_request)
+ {
+ /* possibly more meta data at current position, at least
+ this plugin is still working on it... */
+ done = 0;
+ break;
+ }
+ if (-1 != pos->seek_request)
+ {
+ if (SEEK_END == pos->seek_whence)
+ {
+ /* convert distance from end to absolute position */
+ pos->seek_whence = 0;
+ end = EXTRACTOR_datasource_get_size_ (ds, 1);
+ if (pos->seek_request > end)
{
- continue; /* inactive plugin */
+ LOG ("Cannot seek to before the beginning of the file!\n");
+ pos->seek_request = 0;
}
- if (-1 == pos->seek_request)
- {
- /* possibly more meta data at current position, at least
- this plugin is still working on it... */
- done = 0;
- break;
- }
- if (-1 != pos->seek_request)
- {
- if (SEEK_END == pos->seek_whence)
- {
- /* convert distance from end to absolute position */
- pos->seek_whence = 0;
- end = EXTRACTOR_datasource_get_size_ (ds, 1);
- if (pos->seek_request > end)
- {
- LOG ("Cannot seek to before the beginning of the file!\n");
- pos->seek_request = 0;
- }
- else
- {
- pos->seek_request = end - pos->seek_request;
- }
- }
- if ( (-1 == min_seek) ||
- (min_seek > pos->seek_request) )
- {
- min_seek = pos->seek_request;
- }
- }
- }
- data_available = -1;
- if ( (1 == done) &&
- (-1 != min_seek) &&
- (NULL != shm) )
- {
- /* current position done, but seek requested */
- done = 0;
- if (-1 ==
- (data_available = EXTRACTOR_IPC_shared_memory_set_ (shm,
- ds,
- min_seek,
- DEFAULT_SHM_SIZE)))
- {
- LOG ("Failed to seek; full reset\n");
- abort_all_channels (plugins);
- break;
- }
- }
- /* if 'prp.file_finished', send 'abort' to plugins;
- if not, send 'seek' notification to plugins in range */
- for (pos = plugins; NULL != pos; pos = pos->next)
- {
- if (NULL == (channel = pos->channel))
- {
- /* Skipping plugin: channel down */
- continue;
- }
- if ( (-1 != pos->seek_request) &&
- (1 == prp.file_finished) )
- {
- send_discard_message (pos);
- pos->round_finished = 1;
- pos->seek_request = -1;
- }
- if ( (-1 != data_available) &&
- (-1 != pos->seek_request) &&
- (min_seek <= pos->seek_request) &&
- ( (min_seek + data_available > pos->seek_request) ||
- (min_seek == EXTRACTOR_datasource_get_size_ (ds, 0))) )
- {
- /* Notify plugin about seek to 'min_seek' */
- send_update_message (pos,
- min_seek,
- data_available,
- ds);
- pos->seek_request = -1;
- }
- if (0 == pos->round_finished)
- done = 0; /* can't be done, plugin still active */
- }
+ else
+ {
+ pos->seek_request = end - pos->seek_request;
+ }
+ }
+ if ( (-1 == min_seek) ||
+ (min_seek > pos->seek_request) )
+ {
+ min_seek = pos->seek_request;
+ }
+ }
+ }
+ data_available = -1;
+ if ( (1 == done) &&
+ (-1 != min_seek) &&
+ (NULL != shm) )
+ {
+ /* current position done, but seek requested */
+ done = 0;
+ if (-1 ==
+ (data_available = EXTRACTOR_IPC_shared_memory_set_ (shm,
+ ds,
+ min_seek,
+ DEFAULT_SHM_SIZE)))
+ {
+ LOG ("Failed to seek; full reset\n");
+ abort_all_channels (plugins);
+ break;
+ }
+ }
+ /* if 'prp.file_finished', send 'abort' to plugins;
+ if not, send 'seek' notification to plugins in range */
+ for (pos = plugins; NULL != pos; pos = pos->next)
+ {
+ if (NULL == (channel = pos->channel))
+ {
+ /* Skipping plugin: channel down */
+ continue;
+ }
+ if ( (-1 != pos->seek_request) &&
+ (1 == prp.file_finished) )
+ {
+ send_discard_message (pos);
+ pos->round_finished = 1;
+ pos->seek_request = -1;
+ }
+ if ( (-1 != data_available) &&
+ (-1 != pos->seek_request) &&
+ (min_seek <= pos->seek_request) &&
+ ( (min_seek + data_available > pos->seek_request) ||
+ (min_seek == EXTRACTOR_datasource_get_size_ (ds, 0))) )
+ {
+ /* Notify plugin about seek to 'min_seek' */
+ send_update_message (pos,
+ min_seek,
+ data_available,
+ ds);
+ pos->seek_request = -1;
+ }
+ if (0 == pos->round_finished)
+ done = 0; /* can't be done, plugin still active */
}
+ }
if (0 == have_in_memory)
return;
@@ -567,22 +567,22 @@ do_extract (struct EXTRACTOR_PluginList *plugins,
ec.get_size = &in_process_get_size;
ec.proc = &in_process_proc;
for (pos = plugins; NULL != pos; pos = pos->next)
+ {
+ if (EXTRACTOR_OPTION_IN_PROCESS != pos->flags)
+ continue;
+ if (-1 == EXTRACTOR_plugin_load_ (pos))
+ continue;
+ ctx.plugin = pos;
+ ec.config = pos->plugin_options;
+ if (-1 == EXTRACTOR_datasource_seek_ (ds, 0, SEEK_SET))
{
- if (EXTRACTOR_OPTION_IN_PROCESS != pos->flags)
- continue;
- if (-1 == EXTRACTOR_plugin_load_ (pos))
- continue;
- ctx.plugin = pos;
- ec.config = pos->plugin_options;
- if (-1 == EXTRACTOR_datasource_seek_ (ds, 0, SEEK_SET))
- {
- LOG ("Failed to seek to 0 for in-memory plugins\n");
- return;
- }
- pos->extract_method (&ec);
- if (1 == ctx.finished)
- break;
+ LOG ("Failed to seek to 0 for in-memory plugins\n");
+ return;
}
+ pos->extract_method (&ec);
+ if (1 == ctx.finished)
+ break;
+ }
}
@@ -602,11 +602,11 @@ do_extract (struct EXTRACTOR_PluginList *plugins,
*/
void
EXTRACTOR_extract (struct EXTRACTOR_PluginList *plugins,
- const char *filename,
- const void *data,
- size_t size,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls)
+ const char *filename,
+ const void *data,
+ size_t size,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
struct EXTRACTOR_Datasource *datasource;
struct EXTRACTOR_SharedMemory *shm;
@@ -617,47 +617,47 @@ EXTRACTOR_extract (struct EXTRACTOR_PluginList *plugins,
return;
if (NULL == filename)
datasource = EXTRACTOR_datasource_create_from_buffer_ (data, size,
- proc, proc_cls);
+ proc, proc_cls);
else
datasource = EXTRACTOR_datasource_create_from_file_ (filename,
- proc, proc_cls);
+ proc, proc_cls);
if (NULL == datasource)
return;
shm = NULL;
have_oop = 0;
for (pos = plugins; NULL != pos; pos = pos->next)
- {
- if (NULL == shm)
- shm = pos->shm;
- if (EXTRACTOR_OPTION_IN_PROCESS != pos->flags)
- have_oop = 1;
- pos->round_finished = 0;
- }
+ {
+ if (NULL == shm)
+ shm = pos->shm;
+ if (EXTRACTOR_OPTION_IN_PROCESS != pos->flags)
+ have_oop = 1;
+ pos->round_finished = 0;
+ }
if ( (NULL == shm) &&
(1 == have_oop) )
+ {
+ /* need to create shared memory segment */
+ shm = EXTRACTOR_IPC_shared_memory_create_ (DEFAULT_SHM_SIZE);
+ if (NULL == shm)
{
- /* need to create shared memory segment */
- shm = EXTRACTOR_IPC_shared_memory_create_ (DEFAULT_SHM_SIZE);
- if (NULL == shm)
- {
- LOG ("Failed to setup IPC\n");
- EXTRACTOR_datasource_destroy_ (datasource);
- return;
- }
+ LOG ("Failed to setup IPC\n");
+ EXTRACTOR_datasource_destroy_ (datasource);
+ return;
}
+ }
for (pos = plugins; NULL != pos; pos = pos->next)
if ( (NULL == pos->channel) &&
(NULL != shm) &&
- (EXTRACTOR_OPTION_IN_PROCESS != pos->flags) )
+ (EXTRACTOR_OPTION_IN_PROCESS != pos->flags) )
+ {
+ if (NULL == pos->shm)
{
- if (NULL == pos->shm)
- {
- pos->shm = shm;
- (void) EXTRACTOR_IPC_shared_memory_change_rc_ (shm, 1);
- }
- pos->channel = EXTRACTOR_IPC_channel_create_ (pos,
- shm);
+ pos->shm = shm;
+ (void) EXTRACTOR_IPC_shared_memory_change_rc_ (shm, 1);
}
+ pos->channel = EXTRACTOR_IPC_channel_create_ (pos,
+ shm);
+ }
do_extract (plugins,
shm,
datasource,
@@ -680,14 +680,14 @@ EXTRACTOR_ltdl_init ()
#endif
err = lt_dlinit ();
if (err > 0)
- {
+ {
#if DEBUG
- fprintf (stderr,
- _("Initialization of plugin mechanism failed: %s!\n"),
- lt_dlerror ());
+ fprintf (stderr,
+ _ ("Initialization of plugin mechanism failed: %s!\n"),
+ lt_dlerror ());
#endif
- return;
- }
+ return;
+ }
#if WINDOWS
plibc_init_utf8 ("GNU", PACKAGE, 1);
plibc_set_stat_size_size (sizeof (((struct stat *) 0)->st_size));
@@ -700,11 +700,13 @@ EXTRACTOR_ltdl_init ()
* Deinit.
*/
void __attribute__ ((destructor))
-EXTRACTOR_ltdl_fini () {
+EXTRACTOR_ltdl_fini ()
+{
#if WINDOWS
plibc_shutdown ();
#endif
lt_dlexit ();
}
+
/* end of extractor.c */
diff --git a/src/main/extractor_common.c b/src/main/extractor_common.c
@@ -39,27 +39,27 @@
* @param buf buffer to read from
* @param size number of bytes to write
* @return number of bytes written (that is 'size'), or -1 on error
- */
+ */
ssize_t
EXTRACTOR_write_all_ (int fd,
- const void *buf,
- size_t size)
+ const void *buf,
+ size_t size)
{
const char *data = buf;
size_t off = 0;
ssize_t ret;
-
+
while (off < size)
+ {
+ ret = write (fd, &data[off], size - off);
+ if (ret <= 0)
{
- ret = write (fd, &data[off], size - off);
- if (ret <= 0)
- {
- if (-1 == ret)
- LOG_STRERROR ("write");
- return -1;
- }
- off += ret;
+ if (-1 == ret)
+ LOG_STRERROR ("write");
+ return -1;
}
+ off += ret;
+ }
return size;
}
@@ -74,28 +74,27 @@ EXTRACTOR_write_all_ (int fd,
*/
ssize_t
EXTRACTOR_read_all_ (int fd,
- void *buf,
- size_t size)
+ void *buf,
+ size_t size)
{
char *data = buf;
size_t off = 0;
ssize_t ret;
-
+
while (off < size)
+ {
+ ret = read (fd, &data[off], size - off);
+ if (ret <= 0)
{
- ret = read (fd, &data[off], size - off);
- if (ret <= 0)
- {
- if (-1 == ret)
- LOG_STRERROR ("write");
- return -1;
- }
- off += ret;
+ if (-1 == ret)
+ LOG_STRERROR ("write");
+ return -1;
}
+ off += ret;
+ }
return size;
-
-}
+}
/* end of extractor_common.c */
diff --git a/src/main/extractor_common.h b/src/main/extractor_common.h
@@ -35,11 +35,11 @@
* @param buf buffer to read from
* @param size number of bytes to write
* @return number of bytes written (that is 'size'), or -1 on error
- */
+ */
ssize_t
EXTRACTOR_write_all_ (int fd,
- const void *buf,
- size_t size);
+ const void *buf,
+ size_t size);
/**
@@ -52,8 +52,8 @@ EXTRACTOR_write_all_ (int fd,
*/
ssize_t
EXTRACTOR_read_all_ (int fd,
- void *buf,
- size_t size);
+ void *buf,
+ size_t size);
#endif
diff --git a/src/main/extractor_datasource.c b/src/main/extractor_datasource.c
@@ -214,35 +214,35 @@ struct CompressedFileSource
*/
static int
bfds_pick_next_buffer_at (struct BufferedFileDataSource *bfds,
- uint64_t pos)
+ uint64_t pos)
{
int64_t position;
ssize_t rd;
if (pos > bfds->fsize)
- {
- LOG ("Invalid seek operation\n");
- return -1; /* invalid */
- }
+ {
+ LOG ("Invalid seek operation\n");
+ return -1; /* invalid */
+ }
if (NULL == bfds->buffer)
- {
- bfds->buffer_pos = pos;
- return 0;
- }
+ {
+ bfds->buffer_pos = pos;
+ return 0;
+ }
position = (int64_t) LSEEK (bfds->fd, pos, SEEK_SET);
if (position < 0)
- {
- LOG_STRERROR ("lseek");
- return -1;
- }
+ {
+ LOG_STRERROR ("lseek");
+ return -1;
+ }
bfds->fpos = position;
bfds->buffer_pos = 0;
rd = read (bfds->fd, bfds->buffer, bfds->buffer_size);
if (rd < 0)
- {
- LOG_STRERROR ("read");
- return -1;
- }
+ {
+ LOG_STRERROR ("read");
+ return -1;
+ }
bfds->buffer_bytes = rd;
return 0;
}
@@ -258,8 +258,8 @@ bfds_pick_next_buffer_at (struct BufferedFileDataSource *bfds,
*/
static struct BufferedFileDataSource *
bfds_new (const void *data,
- int fd,
- int64_t fsize)
+ int fd,
+ int64_t fsize)
{
struct BufferedFileDataSource *result;
size_t xtra;
@@ -269,19 +269,19 @@ bfds_new (const void *data,
else
xtra = (size_t) fsize;
if ( (-1 == fd) && (NULL == data) )
- {
- LOG ("Invalid arguments\n");
- return NULL;
- }
+ {
+ LOG ("Invalid arguments\n");
+ return NULL;
+ }
if ( (-1 != fd) && (NULL != data) )
fd = -1; /* don't need fd */
if (NULL != data)
xtra = 0;
if (NULL == (result = malloc (sizeof (struct BufferedFileDataSource) + xtra)))
- {
- LOG_STRERROR ("malloc");
- return NULL;
- }
+ {
+ LOG_STRERROR ("malloc");
+ return NULL;
+ }
memset (result, 0, sizeof (struct BufferedFileDataSource));
result->data = (NULL != data) ? data : &result[1];
result->buffer = (NULL != data) ? NULL : &result[1];
@@ -318,79 +318,79 @@ bfds_delete (struct BufferedFileDataSource *bfds)
*/
static int64_t
bfds_seek (struct BufferedFileDataSource *bfds,
- int64_t pos, int whence)
+ int64_t pos, int whence)
{
uint64_t npos;
size_t nbpos;
switch (whence)
+ {
+ case SEEK_CUR:
+ npos = bfds->fpos + bfds->buffer_pos + pos;
+ if (npos > bfds->fsize)
{
- case SEEK_CUR:
- npos = bfds->fpos + bfds->buffer_pos + pos;
- if (npos > bfds->fsize)
- {
- LOG ("Invalid seek operation to %lld from %llu (max is %llu)\n",
- (long long) pos,
- bfds->fpos + bfds->buffer_pos,
- (unsigned long long) bfds->fsize);
- return -1;
- }
- nbpos = bfds->buffer_pos + pos;
- if ( (NULL == bfds->buffer) ||
- (nbpos < bfds->buffer_bytes) )
- {
- bfds->buffer_pos = nbpos;
- return npos;
- }
- if (0 != bfds_pick_next_buffer_at (bfds,
- npos))
- {
- LOG ("seek operation failed\n");
- return -1;
- }
+ LOG ("Invalid seek operation to %lld from %llu (max is %llu)\n",
+ (long long) pos,
+ bfds->fpos + bfds->buffer_pos,
+ (unsigned long long) bfds->fsize);
+ return -1;
+ }
+ nbpos = bfds->buffer_pos + pos;
+ if ( (NULL == bfds->buffer) ||
+ (nbpos < bfds->buffer_bytes) )
+ {
+ bfds->buffer_pos = nbpos;
return npos;
- case SEEK_END:
- if (pos > 0)
- {
- LOG ("Invalid seek operation\n");
- return -1;
- }
- if (bfds->fsize < - pos)
- {
- LOG ("Invalid seek operation\n");
- return -1;
- }
- pos = bfds->fsize + pos;
- /* fall-through! */
- case SEEK_SET:
- if (pos < 0)
- {
- LOG ("Invalid seek operation\n");
- return -1;
- }
- if (pos > bfds->fsize)
- {
- LOG ("Invalid seek operation (%lld > %llu) %d\n",
- (long long) pos,
- (unsigned long long) bfds->fsize,
- SEEK_SET == whence);
- return -1;
- }
- if ( (NULL == bfds->buffer) ||
- ( (bfds->fpos <= pos) &&
- (bfds->fpos + bfds->buffer_bytes > pos) ) )
- {
- bfds->buffer_pos = pos - bfds->fpos;
- return pos;
- }
- if (0 != bfds_pick_next_buffer_at (bfds, pos))
- {
- LOG ("seek operation failed\n");
- return -1;
- }
- ASSERT (pos == bfds->fpos + bfds->buffer_pos);
+ }
+ if (0 != bfds_pick_next_buffer_at (bfds,
+ npos))
+ {
+ LOG ("seek operation failed\n");
+ return -1;
+ }
+ return npos;
+ case SEEK_END:
+ if (pos > 0)
+ {
+ LOG ("Invalid seek operation\n");
+ return -1;
+ }
+ if (bfds->fsize < -pos)
+ {
+ LOG ("Invalid seek operation\n");
+ return -1;
+ }
+ pos = bfds->fsize + pos;
+ /* fall-through! */
+ case SEEK_SET:
+ if (pos < 0)
+ {
+ LOG ("Invalid seek operation\n");
+ return -1;
+ }
+ if (pos > bfds->fsize)
+ {
+ LOG ("Invalid seek operation (%lld > %llu) %d\n",
+ (long long) pos,
+ (unsigned long long) bfds->fsize,
+ SEEK_SET == whence);
+ return -1;
+ }
+ if ( (NULL == bfds->buffer) ||
+ ( (bfds->fpos <= pos) &&
+ (bfds->fpos + bfds->buffer_bytes > pos) ) )
+ {
+ bfds->buffer_pos = pos - bfds->fpos;
return pos;
}
+ if (0 != bfds_pick_next_buffer_at (bfds, pos))
+ {
+ LOG ("seek operation failed\n");
+ return -1;
+ }
+ ASSERT (pos == bfds->fpos + bfds->buffer_pos);
+ return pos;
+ }
return -1;
}
@@ -407,8 +407,8 @@ bfds_seek (struct BufferedFileDataSource *bfds,
*/
static ssize_t
bfds_read (struct BufferedFileDataSource *bfds,
- void *buf_ptr,
- size_t count)
+ void *buf_ptr,
+ size_t count)
{
char *cbuf = buf_ptr;
uint64_t old_off;
@@ -420,28 +420,28 @@ bfds_read (struct BufferedFileDataSource *bfds,
return 0; /* end of stream */
ret = 0;
while (count > 0)
+ {
+ if ( (bfds->buffer_bytes == bfds->buffer_pos) &&
+ (0 != bfds_pick_next_buffer_at (bfds,
+ bfds->fpos + bfds->buffer_bytes)) )
{
- if ( (bfds->buffer_bytes == bfds->buffer_pos) &&
- (0 != bfds_pick_next_buffer_at (bfds,
- bfds->fpos + bfds->buffer_bytes)) )
- {
- /* revert to original position, invalidate buffer */
- bfds->fpos = old_off;
- bfds->buffer_bytes = 0;
- bfds->buffer_pos = 0;
- LOG ("read operation failed\n");
- return -1; /* getting more failed */
- }
- avail = bfds->buffer_bytes - bfds->buffer_pos;
- if (avail > count)
- avail = count;
- if (0 == avail)
- break;
- memcpy (&cbuf[ret], bfds->data + bfds->buffer_pos, avail);
- bfds->buffer_pos += avail;
- count -= avail;
- ret += avail;
+ /* revert to original position, invalidate buffer */
+ bfds->fpos = old_off;
+ bfds->buffer_bytes = 0;
+ bfds->buffer_pos = 0;
+ LOG ("read operation failed\n");
+ return -1; /* getting more failed */
}
+ avail = bfds->buffer_bytes - bfds->buffer_pos;
+ if (avail > count)
+ avail = count;
+ if (0 == avail)
+ break;
+ memcpy (&cbuf[ret], bfds->data + bfds->buffer_pos, avail);
+ bfds->buffer_pos += avail;
+ count -= avail;
+ ret += avail;
+ }
return ret;
}
@@ -458,17 +458,17 @@ bfds_read (struct BufferedFileDataSource *bfds,
*/
static int
cfs_init_decompressor_zlib (struct CompressedFileSource *cfs,
- EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
+ EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
{
unsigned int gzip_header_length = 10;
unsigned char hdata[12];
ssize_t rsize;
if (0 != bfds_seek (cfs->bfds, 0, SEEK_SET))
- {
- LOG ("Failed to seek to offset 0!\n");
- return -1;
- }
+ {
+ LOG ("Failed to seek to offset 0!\n");
+ return -1;
+ }
/* Process gzip header */
rsize = bfds_read (cfs->bfds, hdata, sizeof (hdata));
if ( (-1 == rsize) ||
@@ -478,72 +478,74 @@ cfs_init_decompressor_zlib (struct CompressedFileSource *cfs,
gzip_header_length += 2 + (hdata[10] & 0xff) + ((hdata[11] & 0xff) * 256);
if (0 != (hdata[3] & 0x8))
+ {
+ /* FNAME set */
+ char fname[1024];
+ char *cptr;
+ size_t len;
+ ssize_t buf_bytes;
+
+ if (gzip_header_length > bfds_seek (cfs->bfds, gzip_header_length,
+ SEEK_SET))
{
- /* FNAME set */
- char fname[1024];
- char *cptr;
- size_t len;
- ssize_t buf_bytes;
-
- if (gzip_header_length > bfds_seek (cfs->bfds, gzip_header_length, SEEK_SET))
- {
- LOG ("Corrupt gzip, failed to seek to end of header\n");
- return -1;
- }
- buf_bytes = bfds_read (cfs->bfds, fname, sizeof (fname));
- if (buf_bytes <= 0)
- {
- LOG ("Corrupt gzip, failed to read filename\n");
- return -1;
- }
- if (NULL == (cptr = memchr (fname, 0, buf_bytes)))
- {
- LOG ("Corrupt gzip, failed to read filename terminator\n");
- return -1;
- }
- len = cptr - fname;
- if ( (NULL != proc) &&
- (0 != proc (proc_cls, "<zlib>", EXTRACTOR_METATYPE_FILENAME,
- EXTRACTOR_METAFORMAT_C_STRING, "text/plain",
- fname,
- len)) )
- return 0; /* done */
- gzip_header_length += len + 1;
+ LOG ("Corrupt gzip, failed to seek to end of header\n");
+ return -1;
}
+ buf_bytes = bfds_read (cfs->bfds, fname, sizeof (fname));
+ if (buf_bytes <= 0)
+ {
+ LOG ("Corrupt gzip, failed to read filename\n");
+ return -1;
+ }
+ if (NULL == (cptr = memchr (fname, 0, buf_bytes)))
+ {
+ LOG ("Corrupt gzip, failed to read filename terminator\n");
+ return -1;
+ }
+ len = cptr - fname;
+ if ( (NULL != proc) &&
+ (0 != proc (proc_cls, "<zlib>", EXTRACTOR_METATYPE_FILENAME,
+ EXTRACTOR_METAFORMAT_C_STRING, "text/plain",
+ fname,
+ len)) )
+ return 0; /* done */
+ gzip_header_length += len + 1;
+ }
if (0 != (hdata[3] & 0x16))
+ {
+ /* FCOMMENT set */
+ char fcomment[1024];
+ char *cptr;
+ ssize_t buf_bytes;
+ size_t len;
+
+ if (gzip_header_length > bfds_seek (cfs->bfds, gzip_header_length,
+ SEEK_SET))
{
- /* FCOMMENT set */
- char fcomment[1024];
- char *cptr;
- ssize_t buf_bytes;
- size_t len;
-
- if (gzip_header_length > bfds_seek (cfs->bfds, gzip_header_length, SEEK_SET))
- {
- LOG ("Corrupt gzip, failed to seek to end of header\n");
- return -1;
- }
- buf_bytes = bfds_read (cfs->bfds, fcomment, sizeof (fcomment));
- if (buf_bytes <= 0)
- {
- LOG ("Corrupt gzip, failed to read comment\n");
- return -1;
- }
- if (NULL == (cptr = memchr (fcomment, 0, buf_bytes)))
- {
- LOG ("Corrupt gzip, failed to read comment terminator\n");
- return -1;
- }
- len = cptr - fcomment;
- if ( (NULL != proc) &&
- (0 != proc (proc_cls, "<zlib>", EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_C_STRING, "text/plain",
- (const char *) fcomment,
- len)) )
- return 0; /* done */
- gzip_header_length += len + 1;
+ LOG ("Corrupt gzip, failed to seek to end of header\n");
+ return -1;
+ }
+ buf_bytes = bfds_read (cfs->bfds, fcomment, sizeof (fcomment));
+ if (buf_bytes <= 0)
+ {
+ LOG ("Corrupt gzip, failed to read comment\n");
+ return -1;
+ }
+ if (NULL == (cptr = memchr (fcomment, 0, buf_bytes)))
+ {
+ LOG ("Corrupt gzip, failed to read comment terminator\n");
+ return -1;
}
+ len = cptr - fcomment;
+ if ( (NULL != proc) &&
+ (0 != proc (proc_cls, "<zlib>", EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METAFORMAT_C_STRING, "text/plain",
+ (const char *) fcomment,
+ len)) )
+ return 0; /* done */
+ gzip_header_length += len + 1;
+ }
if (0 != (hdata[3] & 0x2)) /* FCHRC set */
gzip_header_length += 2;
memset (&cfs->strm, 0, sizeof (z_stream));
@@ -556,10 +558,10 @@ cfs_init_decompressor_zlib (struct CompressedFileSource *cfs,
if (cfs->gzip_header_length !=
bfds_seek (cfs->bfds, cfs->gzip_header_length, SEEK_SET))
- {
- LOG ("Failed to seek to start to initialize gzip decompressor\n");
- return -1;
- }
+ {
+ LOG ("Failed to seek to start to initialize gzip decompressor\n");
+ return -1;
+ }
cfs->strm.avail_out = COM_CHUNK_SIZE;
/*
* note: maybe plain inflateInit(&strm) is adequate,
@@ -567,20 +569,21 @@ cfs_init_decompressor_zlib (struct CompressedFileSource *cfs,
*
* ZLIB_VERNUM isn't defined by zlib version 1.1.4 ;
* there might be a better check.
- */
- if (Z_OK != inflateInit2 (&cfs->strm,
+ */if (Z_OK != inflateInit2 (&cfs->strm,
#ifdef ZLIB_VERNUM
- 15 + 32
+ 15 + 32
#else
- - MAX_WBITS
+ -MAX_WBITS
#endif
- ))
- {
- LOG ("Failed to initialize zlib decompression\n");
- return -1;
- }
+ ))
+ {
+ LOG ("Failed to initialize zlib decompression\n");
+ return -1;
+ }
return 1;
}
+
+
#endif
@@ -596,24 +599,26 @@ cfs_init_decompressor_zlib (struct CompressedFileSource *cfs,
*/
static int
cfs_init_decompressor_bz2 (struct CompressedFileSource *cfs,
- EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
+ EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
{
if (0 !=
bfds_seek (cfs->bfds, 0, SEEK_SET))
- {
- LOG ("Failed to seek to start to initialize BZ2 decompressor\n");
- return -1;
- }
+ {
+ LOG ("Failed to seek to start to initialize BZ2 decompressor\n");
+ return -1;
+ }
memset (&cfs->bstrm, 0, sizeof (bz_stream));
if (BZ_OK !=
BZ2_bzDecompressInit (&cfs->bstrm, 0, 0))
- {
- LOG ("Failed to initialize BZ2 decompressor\n");
- return -1;
- }
+ {
+ LOG ("Failed to initialize BZ2 decompressor\n");
+ return -1;
+ }
cfs->bstrm.avail_out = COM_CHUNK_SIZE;
return 1;
}
+
+
#endif
@@ -628,24 +633,24 @@ cfs_init_decompressor_bz2 (struct CompressedFileSource *cfs,
*/
static int
cfs_init_decompressor (struct CompressedFileSource *cfs,
- EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
+ EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
{
cfs->result_pos = 0;
cfs->fpos = 0;
switch (cfs->compression_type)
- {
+ {
#if HAVE_ZLIB
- case COMP_TYPE_ZLIB:
- return cfs_init_decompressor_zlib (cfs, proc, proc_cls);
+ case COMP_TYPE_ZLIB:
+ return cfs_init_decompressor_zlib (cfs, proc, proc_cls);
#endif
#if HAVE_LIBBZ2
- case COMP_TYPE_BZ2:
- return cfs_init_decompressor_bz2 (cfs, proc, proc_cls);
+ case COMP_TYPE_BZ2:
+ return cfs_init_decompressor_bz2 (cfs, proc, proc_cls);
#endif
- default:
- LOG ("invalid compression type selected\n");
- return -1;
- }
+ default:
+ LOG ("invalid compression type selected\n");
+ return -1;
+ }
}
@@ -662,6 +667,8 @@ cfs_deinit_decompressor_zlib (struct CompressedFileSource *cfs)
inflateEnd (&cfs->strm);
return 1;
}
+
+
#endif
@@ -678,6 +685,8 @@ cfs_deinit_decompressor_bz2 (struct CompressedFileSource *cfs)
BZ2_bzDecompressEnd (&cfs->bstrm);
return 1;
}
+
+
#endif
@@ -691,19 +700,19 @@ static int
cfs_deinit_decompressor (struct CompressedFileSource *cfs)
{
switch (cfs->compression_type)
- {
+ {
#if HAVE_ZLIB
- case COMP_TYPE_ZLIB:
- return cfs_deinit_decompressor_zlib (cfs);
+ case COMP_TYPE_ZLIB:
+ return cfs_deinit_decompressor_zlib (cfs);
#endif
#if HAVE_LIBBZ2
- case COMP_TYPE_BZ2:
- return cfs_deinit_decompressor_bz2 (cfs);
+ case COMP_TYPE_BZ2:
+ return cfs_deinit_decompressor_bz2 (cfs);
#endif
- default:
- LOG ("invalid compression type selected\n");
- return -1;
- }
+ default:
+ LOG ("invalid compression type selected\n");
+ return -1;
+ }
}
@@ -750,28 +759,28 @@ cfs_destroy (struct CompressedFileSource *cfs)
*/
struct CompressedFileSource *
cfs_new (struct BufferedFileDataSource *bfds,
- int64_t fsize,
- enum ExtractorCompressionType compression_type,
- EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
+ int64_t fsize,
+ enum ExtractorCompressionType compression_type,
+ EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
{
struct CompressedFileSource *cfs;
if (NULL == (cfs = malloc (sizeof (struct CompressedFileSource))))
- {
- LOG_STRERROR ("malloc");
- return NULL;
- }
+ {
+ LOG_STRERROR ("malloc");
+ return NULL;
+ }
memset (cfs, 0, sizeof (struct CompressedFileSource));
cfs->compression_type = compression_type;
cfs->bfds = bfds;
cfs->fsize = fsize;
cfs->uncompressed_size = -1;
if (1 != cfs_init_decompressor (cfs,
- proc, proc_cls))
- {
- free (cfs);
- return NULL;
- }
+ proc, proc_cls))
+ {
+ free (cfs);
+ return NULL;
+ }
return cfs;
}
@@ -789,8 +798,8 @@ cfs_new (struct BufferedFileDataSource *bfds,
*/
static ssize_t
cfs_read_zlib (struct CompressedFileSource *cfs,
- void *data,
- size_t size)
+ void *data,
+ size_t size)
{
char *dst = data;
int ret;
@@ -799,77 +808,79 @@ cfs_read_zlib (struct CompressedFileSource *cfs,
unsigned char buf[COM_CHUNK_SIZE];
if (cfs->fpos == cfs->uncompressed_size)
- {
- /* end of file */
- return 0;
- }
+ {
+ /* end of file */
+ return 0;
+ }
rc = 0;
if (COM_CHUNK_SIZE > cfs->strm.avail_out + cfs->result_pos)
- {
- /* got left-over decompressed data from previous round! */
- in = COM_CHUNK_SIZE - (cfs->strm.avail_out + cfs->result_pos);
- if (in > size)
- in = size;
- memcpy (&dst[rc], &cfs->result[cfs->result_pos], in);
- cfs->fpos += in;
- cfs->result_pos += in;
- rc += in;
- }
+ {
+ /* got left-over decompressed data from previous round! */
+ in = COM_CHUNK_SIZE - (cfs->strm.avail_out + cfs->result_pos);
+ if (in > size)
+ in = size;
+ memcpy (&dst[rc], &cfs->result[cfs->result_pos], in);
+ cfs->fpos += in;
+ cfs->result_pos += in;
+ rc += in;
+ }
ret = Z_OK;
while ( (rc < size) && (Z_STREAM_END != ret) )
+ {
+ /* read block from original data source */
+ in = bfds_read (cfs->bfds,
+ buf, sizeof (buf));
+ if (in < 0)
{
- /* read block from original data source */
- in = bfds_read (cfs->bfds,
- buf, sizeof (buf));
- if (in < 0)
- {
- LOG ("unexpected EOF\n");
- return -1; /* unexpected EOF */
- }
- if (0 == in)
- {
- cfs->uncompressed_size = cfs->fpos;
- return rc;
- }
- cfs->strm.next_in = buf;
- cfs->strm.avail_in = (uInt) in;
- cfs->strm.next_out = (unsigned char *) cfs->result;
- cfs->strm.avail_out = COM_CHUNK_SIZE;
- cfs->result_pos = 0;
- ret = inflate (&cfs->strm, Z_SYNC_FLUSH);
- if ( (Z_OK != ret) && (Z_STREAM_END != ret) )
- {
- LOG ("unexpected gzip inflate error: %d\n", ret);
- return -1; /* unexpected error */
- }
- /* go backwards by the number of bytes left in the buffer */
- if (-1 == bfds_seek (cfs->bfds, - (int64_t) cfs->strm.avail_in, SEEK_CUR))
- {
- LOG ("seek failed\n");
- return -1;
- }
- /* copy decompressed bytes to target buffer */
- in = COM_CHUNK_SIZE - cfs->strm.avail_out;
- if (in > size - rc)
- {
- if (Z_STREAM_END == ret)
- {
- cfs->uncompressed_size = cfs->fpos + in;
- ret = Z_OK;
- }
- in = size - rc;
- }
- memcpy (&dst[rc], &cfs->result[cfs->result_pos], in);
- cfs->fpos += in;
- cfs->result_pos += in;
- rc += in;
+ LOG ("unexpected EOF\n");
+ return -1; /* unexpected EOF */
}
- if (Z_STREAM_END == ret)
+ if (0 == in)
{
cfs->uncompressed_size = cfs->fpos;
+ return rc;
+ }
+ cfs->strm.next_in = buf;
+ cfs->strm.avail_in = (uInt) in;
+ cfs->strm.next_out = (unsigned char *) cfs->result;
+ cfs->strm.avail_out = COM_CHUNK_SIZE;
+ cfs->result_pos = 0;
+ ret = inflate (&cfs->strm, Z_SYNC_FLUSH);
+ if ( (Z_OK != ret) && (Z_STREAM_END != ret) )
+ {
+ LOG ("unexpected gzip inflate error: %d\n", ret);
+ return -1; /* unexpected error */
+ }
+ /* go backwards by the number of bytes left in the buffer */
+ if (-1 == bfds_seek (cfs->bfds, -(int64_t) cfs->strm.avail_in, SEEK_CUR))
+ {
+ LOG ("seek failed\n");
+ return -1;
+ }
+ /* copy decompressed bytes to target buffer */
+ in = COM_CHUNK_SIZE - cfs->strm.avail_out;
+ if (in > size - rc)
+ {
+ if (Z_STREAM_END == ret)
+ {
+ cfs->uncompressed_size = cfs->fpos + in;
+ ret = Z_OK;
+ }
+ in = size - rc;
}
+ memcpy (&dst[rc], &cfs->result[cfs->result_pos], in);
+ cfs->fpos += in;
+ cfs->result_pos += in;
+ rc += in;
+ }
+ if (Z_STREAM_END == ret)
+ {
+ cfs->uncompressed_size = cfs->fpos;
+ }
return rc;
}
+
+
#endif
@@ -886,8 +897,8 @@ cfs_read_zlib (struct CompressedFileSource *cfs,
*/
static ssize_t
cfs_read_bz2 (struct CompressedFileSource *cfs,
- void *data,
- size_t size)
+ void *data,
+ size_t size)
{
char *dst = data;
int ret;
@@ -896,77 +907,79 @@ cfs_read_bz2 (struct CompressedFileSource *cfs,
char buf[COM_CHUNK_SIZE];
if (cfs->fpos == cfs->uncompressed_size)
- {
- /* end of file */
- return 0;
- }
+ {
+ /* end of file */
+ return 0;
+ }
rc = 0;
if (COM_CHUNK_SIZE > cfs->bstrm.avail_out + cfs->result_pos)
- {
- /* got left-over decompressed data from previous round! */
- in = COM_CHUNK_SIZE - (cfs->bstrm.avail_out + cfs->result_pos);
- if (in > size)
- in = size;
- memcpy (&dst[rc], &cfs->result[cfs->result_pos], in);
- cfs->fpos += in;
- cfs->result_pos += in;
- rc += in;
- }
+ {
+ /* got left-over decompressed data from previous round! */
+ in = COM_CHUNK_SIZE - (cfs->bstrm.avail_out + cfs->result_pos);
+ if (in > size)
+ in = size;
+ memcpy (&dst[rc], &cfs->result[cfs->result_pos], in);
+ cfs->fpos += in;
+ cfs->result_pos += in;
+ rc += in;
+ }
ret = BZ_OK;
while ( (rc < size) && (BZ_STREAM_END != ret) )
+ {
+ /* read block from original data source */
+ in = bfds_read (cfs->bfds,
+ buf, sizeof (buf));
+ if (in < 0)
{
- /* read block from original data source */
- in = bfds_read (cfs->bfds,
- buf, sizeof (buf));
- if (in < 0)
- {
- LOG ("unexpected EOF\n");
- return -1; /* unexpected EOF */
- }
- if (0 == in)
- {
- cfs->uncompressed_size = cfs->fpos;
- return rc;
- }
- cfs->bstrm.next_in = buf;
- cfs->bstrm.avail_in = (unsigned int) in;
- cfs->bstrm.next_out = cfs->result;
- cfs->bstrm.avail_out = COM_CHUNK_SIZE;
- cfs->result_pos = 0;
- ret = BZ2_bzDecompress (&cfs->bstrm);
- if ( (BZ_OK != ret) && (BZ_STREAM_END != ret) )
- {
- LOG ("unexpected bzip2 decompress error: %d\n", ret);
- return -1; /* unexpected error */
- }
- /* go backwards by the number of bytes left in the buffer */
- if (-1 == bfds_seek (cfs->bfds, - (int64_t) cfs->bstrm.avail_in, SEEK_CUR))
- {
- LOG ("seek failed\n");
- return -1;
- }
- /* copy decompressed bytes to target buffer */
- in = COM_CHUNK_SIZE - cfs->bstrm.avail_out;
- if (in > size - rc)
- {
- if (BZ_STREAM_END == ret)
- {
- cfs->uncompressed_size = cfs->fpos + in;
- ret = BZ_OK;
- }
- in = size - rc;
- }
- memcpy (&dst[rc], &cfs->result[cfs->result_pos], in);
- cfs->fpos += in;
- cfs->result_pos += in;
- rc += in;
+ LOG ("unexpected EOF\n");
+ return -1; /* unexpected EOF */
}
- if (BZ_STREAM_END == ret)
+ if (0 == in)
{
cfs->uncompressed_size = cfs->fpos;
+ return rc;
+ }
+ cfs->bstrm.next_in = buf;
+ cfs->bstrm.avail_in = (unsigned int) in;
+ cfs->bstrm.next_out = cfs->result;
+ cfs->bstrm.avail_out = COM_CHUNK_SIZE;
+ cfs->result_pos = 0;
+ ret = BZ2_bzDecompress (&cfs->bstrm);
+ if ( (BZ_OK != ret) && (BZ_STREAM_END != ret) )
+ {
+ LOG ("unexpected bzip2 decompress error: %d\n", ret);
+ return -1; /* unexpected error */
+ }
+ /* go backwards by the number of bytes left in the buffer */
+ if (-1 == bfds_seek (cfs->bfds, -(int64_t) cfs->bstrm.avail_in, SEEK_CUR))
+ {
+ LOG ("seek failed\n");
+ return -1;
}
+ /* copy decompressed bytes to target buffer */
+ in = COM_CHUNK_SIZE - cfs->bstrm.avail_out;
+ if (in > size - rc)
+ {
+ if (BZ_STREAM_END == ret)
+ {
+ cfs->uncompressed_size = cfs->fpos + in;
+ ret = BZ_OK;
+ }
+ in = size - rc;
+ }
+ memcpy (&dst[rc], &cfs->result[cfs->result_pos], in);
+ cfs->fpos += in;
+ cfs->result_pos += in;
+ rc += in;
+ }
+ if (BZ_STREAM_END == ret)
+ {
+ cfs->uncompressed_size = cfs->fpos;
+ }
return rc;
}
+
+
#endif
@@ -982,23 +995,23 @@ cfs_read_bz2 (struct CompressedFileSource *cfs,
*/
static ssize_t
cfs_read (struct CompressedFileSource *cfs,
- void *data,
- size_t size)
+ void *data,
+ size_t size)
{
switch (cfs->compression_type)
- {
+ {
#if HAVE_ZLIB
- case COMP_TYPE_ZLIB:
- return cfs_read_zlib (cfs, data, size);
+ case COMP_TYPE_ZLIB:
+ return cfs_read_zlib (cfs, data, size);
#endif
#if HAVE_LIBBZ2
- case COMP_TYPE_BZ2:
- return cfs_read_bz2 (cfs, data, size);
+ case COMP_TYPE_BZ2:
+ return cfs_read_bz2 (cfs, data, size);
#endif
- default:
- LOG ("invalid compression type selected\n");
- return -1;
- }
+ default:
+ LOG ("invalid compression type selected\n");
+ return -1;
+ }
}
@@ -1014,104 +1027,105 @@ cfs_read (struct CompressedFileSource *cfs,
*/
static int64_t
cfs_seek (struct CompressedFileSource *cfs,
- int64_t position,
- int whence)
+ int64_t position,
+ int whence)
{
uint64_t nposition;
int64_t delta;
switch (whence)
+ {
+ case SEEK_CUR:
+ if (cfs->fpos + position < 0)
+ {
+ /* underflow */
+ LOG ("Invalid seek operation\n");
+ return -1;
+ }
+ if ( (-1 != cfs->uncompressed_size) &&
+ (cfs->fpos + position > cfs->uncompressed_size) )
+ {
+ LOG ("Invalid seek operation\n");
+ return -1;
+ }
+ nposition = cfs->fpos + position;
+ break;
+ case SEEK_END:
+ ASSERT (-1 != cfs->uncompressed_size);
+ if (position > 0)
{
- case SEEK_CUR:
- if (cfs->fpos + position < 0)
- {
- /* underflow */
- LOG ("Invalid seek operation\n");
- return -1;
- }
- if ( (-1 != cfs->uncompressed_size) &&
- (cfs->fpos + position > cfs->uncompressed_size) )
- {
- LOG ("Invalid seek operation\n");
- return -1;
- }
- nposition = cfs->fpos + position;
- break;
- case SEEK_END:
- ASSERT (-1 != cfs->uncompressed_size);
- if (position > 0)
- {
- LOG ("Invalid seek operation\n");
- return -1;
- }
- if (cfs->uncompressed_size < - position)
- {
- LOG ("Invalid seek operation\n");
- return -1;
- }
- nposition = cfs->uncompressed_size + position;
- break;
- case SEEK_SET:
- if (position < 0)
- {
- LOG ("Invalid seek operation\n");
- return -1;
- }
- if ( (-1 != cfs->uncompressed_size) &&
- (cfs->uncompressed_size < position ) )
- {
- LOG ("Invalid seek operation\n");
- return -1;
- }
- nposition = (uint64_t) position;
- break;
- default:
LOG ("Invalid seek operation\n");
return -1;
}
+ if (cfs->uncompressed_size < -position)
+ {
+ LOG ("Invalid seek operation\n");
+ return -1;
+ }
+ nposition = cfs->uncompressed_size + position;
+ break;
+ case SEEK_SET:
+ if (position < 0)
+ {
+ LOG ("Invalid seek operation\n");
+ return -1;
+ }
+ if ( (-1 != cfs->uncompressed_size) &&
+ (cfs->uncompressed_size < position) )
+ {
+ LOG ("Invalid seek operation\n");
+ return -1;
+ }
+ nposition = (uint64_t) position;
+ break;
+ default:
+ LOG ("Invalid seek operation\n");
+ return -1;
+ }
delta = nposition - cfs->fpos;
if (delta < 0)
+ {
+ if (cfs->result_pos >= -delta)
{
- if (cfs->result_pos >= - delta)
- {
- cfs->result_pos += delta;
- cfs->fpos += delta;
- delta = 0;
- }
- else
- {
- if (-1 == cfs_reset_stream (cfs))
- {
- LOG ("Failed to restart compressed stream for seek operation\n");
- return -1;
- }
- delta = nposition;
- }
+ cfs->result_pos += delta;
+ cfs->fpos += delta;
+ delta = 0;
}
+ else
+ {
+ if (-1 == cfs_reset_stream (cfs))
+ {
+ LOG ("Failed to restart compressed stream for seek operation\n");
+ return -1;
+ }
+ delta = nposition;
+ }
+ }
while (delta > 0)
+ {
+ char buf[COM_CHUNK_SIZE];
+ size_t max;
+ int64_t ret;
+
+ max = (sizeof (buf) > delta) ? delta : sizeof (buf);
+ ret = cfs_read (cfs, buf, max);
+ if (-1 == ret)
+ {
+ LOG ("Failed to read decompressed stream for seek operation\n");
+ return -1;
+ }
+ if (0 == ret)
{
- char buf[COM_CHUNK_SIZE];
- size_t max;
- int64_t ret;
-
- max = (sizeof (buf) > delta) ? delta : sizeof (buf);
- ret = cfs_read (cfs, buf, max);
- if (-1 == ret)
- {
- LOG ("Failed to read decompressed stream for seek operation\n");
- return -1;
- }
- if (0 == ret)
- {
- LOG ("Reached unexpected end of stream at %llu during seek operation to %llu (%d left)\n",
- (unsigned long long) cfs->fpos,
- (unsigned long long) nposition,
- delta);
- return -1;
- }
- ASSERT (ret <= delta);
- delta -= ret;
+ LOG (
+ "Reached unexpected end of stream at %llu during seek operation to %llu (%d left)\n",
+ (unsigned long long) cfs->fpos,
+ (unsigned long long) nposition,
+ delta);
+ return -1;
}
+ ASSERT (ret <= delta);
+ delta -= ret;
+ }
return cfs->fpos;
}
@@ -1186,8 +1200,8 @@ struct EXTRACTOR_Datasource
*/
struct EXTRACTOR_Datasource *
EXTRACTOR_datasource_create_from_file_ (const char *filename,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls)
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
struct BufferedFileDataSource *bfds;
struct EXTRACTOR_Datasource *ds;
@@ -1201,56 +1215,56 @@ EXTRACTOR_datasource_create_from_file_ (const char *filename,
#endif
if (-1 == (fd = OPEN (filename, O_RDONLY | O_LARGEFILE | winmode)))
- {
- LOG_STRERROR_FILE ("open", filename);
- return NULL;
- }
+ {
+ LOG_STRERROR_FILE ("open", filename);
+ return NULL;
+ }
if ( (0 != FSTAT (fd, &sb)) ||
(S_ISDIR (sb.st_mode)) )
- {
- if (! S_ISDIR (sb.st_mode))
- LOG_STRERROR_FILE ("fstat", filename);
- else
- LOG ("Skipping directory `%s'\n", filename);
- (void) CLOSE (fd);
- return NULL;
- }
+ {
+ if (! S_ISDIR (sb.st_mode))
+ LOG_STRERROR_FILE ("fstat", filename);
+ else
+ LOG ("Skipping directory `%s'\n", filename);
+ (void) CLOSE (fd);
+ return NULL;
+ }
fsize = (int64_t) sb.st_size;
if (0 == fsize)
- {
- (void) CLOSE (fd);
- return NULL;
- }
+ {
+ (void) CLOSE (fd);
+ return NULL;
+ }
bfds = bfds_new (NULL, fd, fsize);
if (NULL == bfds)
- {
- (void) CLOSE (fd);
- return NULL;
- }
+ {
+ (void) CLOSE (fd);
+ return NULL;
+ }
if (NULL == (ds = malloc (sizeof (struct EXTRACTOR_Datasource))))
- {
- LOG_STRERROR ("malloc");
- bfds_delete (bfds);
- (void) CLOSE (fd);
- return NULL;
- }
+ {
+ LOG_STRERROR ("malloc");
+ bfds_delete (bfds);
+ (void) CLOSE (fd);
+ return NULL;
+ }
ds->bfds = bfds;
ds->fd = fd;
ds->cfs = NULL;
ct = get_compression_type (bfds);
if ( (COMP_TYPE_ZLIB == ct) ||
(COMP_TYPE_BZ2 == ct) )
+ {
+ ds->cfs = cfs_new (bfds, fsize, ct, proc, proc_cls);
+ if (NULL == ds->cfs)
{
- ds->cfs = cfs_new (bfds, fsize, ct, proc, proc_cls);
- if (NULL == ds->cfs)
- {
- LOG ("Failed to initialize decompressor\n");
- bfds_delete (bfds);
- free (ds);
- (void) CLOSE (fd);
- return NULL;
- }
+ LOG ("Failed to initialize decompressor\n");
+ bfds_delete (bfds);
+ free (ds);
+ (void) CLOSE (fd);
+ return NULL;
}
+ }
return ds;
}
@@ -1266,8 +1280,9 @@ EXTRACTOR_datasource_create_from_file_ (const char *filename,
*/
struct EXTRACTOR_Datasource *
EXTRACTOR_datasource_create_from_buffer_ (const char *buf,
- size_t size,
- EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
+ size_t size,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
struct BufferedFileDataSource *bfds;
struct EXTRACTOR_Datasource *ds;
@@ -1276,32 +1291,32 @@ EXTRACTOR_datasource_create_from_buffer_ (const char *buf,
if (0 == size)
return NULL;
if (NULL == (bfds = bfds_new (buf, -1, size)))
- {
- LOG ("Failed to initialize buffer data source\n");
- return NULL;
- }
+ {
+ LOG ("Failed to initialize buffer data source\n");
+ return NULL;
+ }
if (NULL == (ds = malloc (sizeof (struct EXTRACTOR_Datasource))))
- {
- LOG_STRERROR ("malloc");
- bfds_delete (bfds);
- return NULL;
- }
+ {
+ LOG_STRERROR ("malloc");
+ bfds_delete (bfds);
+ return NULL;
+ }
ds->bfds = bfds;
ds->fd = -1;
ds->cfs = NULL;
ct = get_compression_type (bfds);
if ( (COMP_TYPE_ZLIB == ct) ||
(COMP_TYPE_BZ2 == ct) )
+ {
+ ds->cfs = cfs_new (bfds, size, ct, proc, proc_cls);
+ if (NULL == ds->cfs)
{
- ds->cfs = cfs_new (bfds, size, ct, proc, proc_cls);
- if (NULL == ds->cfs)
- {
- LOG ("Failed to initialize decompressor\n");
- bfds_delete (bfds);
- free (ds);
- return NULL;
- }
+ LOG ("Failed to initialize decompressor\n");
+ bfds_delete (bfds);
+ free (ds);
+ return NULL;
}
+ }
return ds;
}
@@ -1334,8 +1349,8 @@ EXTRACTOR_datasource_destroy_ (struct EXTRACTOR_Datasource *ds)
*/
ssize_t
EXTRACTOR_datasource_read_ (void *cls,
- void *data,
- size_t size)
+ void *data,
+ size_t size)
{
struct EXTRACTOR_Datasource *ds = cls;
@@ -1357,23 +1372,23 @@ EXTRACTOR_datasource_read_ (void *cls,
*/
int64_t
EXTRACTOR_datasource_seek_ (void *cls,
- int64_t pos,
- int whence)
+ int64_t pos,
+ int whence)
{
struct EXTRACTOR_Datasource *ds = cls;
if (NULL != ds->cfs)
+ {
+ if ( (SEEK_END == whence) &&
+ (-1 == ds->cfs->uncompressed_size) )
{
- if ( (SEEK_END == whence) &&
- (-1 == ds->cfs->uncompressed_size) )
- {
- /* need to obtain uncompressed size */
- (void) EXTRACTOR_datasource_get_size_ (ds, 1);
- if (-1 == ds->cfs->uncompressed_size)
- return -1;
- }
- return cfs_seek (ds->cfs, pos, whence);
+ /* need to obtain uncompressed size */
+ (void) EXTRACTOR_datasource_get_size_ (ds, 1);
+ if (-1 == ds->cfs->uncompressed_size)
+ return -1;
}
+ return cfs_seek (ds->cfs, pos, whence);
+ }
return bfds_seek (ds->bfds, pos, whence);
}
@@ -1387,30 +1402,32 @@ EXTRACTOR_datasource_seek_ (void *cls,
*/
int64_t
EXTRACTOR_datasource_get_size_ (void *cls,
- int force)
+ int force)
{
struct EXTRACTOR_Datasource *ds = cls;
char buf[32 * 1024];
uint64_t pos;
if (NULL != ds->cfs)
+ {
+ if ( (force) &&
+ (-1 == ds->cfs->uncompressed_size) )
{
- if ( (force) &&
- (-1 == ds->cfs->uncompressed_size) )
- {
- pos = ds->cfs->fpos;
- while ( (-1 == ds->cfs->uncompressed_size) &&
- (-1 != cfs_read (ds->cfs, buf, sizeof (buf))) ) ;
- if (-1 == cfs_seek (ds->cfs, pos, SEEK_SET))
- {
- LOG ("Serious problem, I moved the buffer to determine the file size but could not restore it...\n");
- return -1;
- }
- if (-1 == ds->cfs->uncompressed_size)
- return -1;
- }
- return ds->cfs->uncompressed_size;
+ pos = ds->cfs->fpos;
+ while ( (-1 == ds->cfs->uncompressed_size) &&
+ (-1 != cfs_read (ds->cfs, buf, sizeof (buf))) )
+ ;
+ if (-1 == cfs_seek (ds->cfs, pos, SEEK_SET))
+ {
+ LOG (
+ "Serious problem, I moved the buffer to determine the file size but could not restore it...\n");
+ return -1;
+ }
+ if (-1 == ds->cfs->uncompressed_size)
+ return -1;
}
+ return ds->cfs->uncompressed_size;
+ }
return ds->bfds->fsize;
}
diff --git a/src/main/extractor_datasource.h b/src/main/extractor_datasource.h
@@ -29,7 +29,7 @@
/**
* Handle to a datasource we can use for the plugins.
- */
+ */
struct EXTRACTOR_Datasource;
@@ -43,7 +43,8 @@ struct EXTRACTOR_Datasource;
*/
struct EXTRACTOR_Datasource *
EXTRACTOR_datasource_create_from_file_ (const char *filename,
- EXTRACTOR_MetaDataProcessor proc, void *proc_cls);
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls);
/**
@@ -57,8 +58,9 @@ EXTRACTOR_datasource_create_from_file_ (const char *filename,
*/
struct EXTRACTOR_Datasource *
EXTRACTOR_datasource_create_from_buffer_ (const char *buf,
- size_t size,
- EXTRACTOR_MetaDataProcessor proc, void *proc_cls);
+ size_t size,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls);
/**
@@ -81,14 +83,14 @@ EXTRACTOR_datasource_destroy_ (struct EXTRACTOR_Datasource *ds);
*/
ssize_t
EXTRACTOR_datasource_read_ (void *cls,
- void *data,
- size_t size);
+ void *data,
+ size_t size);
/**
* Seek in the datasource. Use 'SEEK_CUR' for whence and 'pos' of 0 to
* obtain the current position in the file.
- *
+ *
* @param cls must be a 'struct EXTRACTOR_Datasource'
* @param pos position to seek (see 'man lseek')o
* @param whence how to see (absolute to start, relative, absolute to end)
@@ -97,20 +99,20 @@ EXTRACTOR_datasource_read_ (void *cls,
*/
int64_t
EXTRACTOR_datasource_seek_ (void *cls,
- int64_t pos,
- int whence);
+ int64_t pos,
+ int whence);
/**
* Determine the overall size of the data source (after compression).
- *
+ *
* @param cls must be a 'struct EXTRACTOR_Datasource'
* @param force force computing the size if it is unavailable
* @return overall file size, -1 on error or unknown
- */
-int64_t
+ */
+int64_t
EXTRACTOR_datasource_get_size_ (void *cls,
- int force);
+ int force);
#endif
diff --git a/src/main/extractor_ipc.c b/src/main/extractor_ipc.c
@@ -40,10 +40,10 @@
*/
ssize_t
EXTRACTOR_IPC_process_reply_ (struct EXTRACTOR_PluginList *plugin,
- const void *data,
- size_t size,
- EXTRACTOR_ChannelMessageProcessor proc,
- void *proc_cls)
+ const void *data,
+ size_t size,
+ EXTRACTOR_ChannelMessageProcessor proc,
+ void *proc_cls)
{
const char *cdata;
unsigned char code;
@@ -55,83 +55,84 @@ EXTRACTOR_IPC_process_reply_ (struct EXTRACTOR_PluginList *plugin,
ret = 0;
while (size > 0)
+ {
+ cdata = data;
+ code = (unsigned char) cdata[0];
+ switch (code)
{
- cdata = data;
- code = (unsigned char) cdata[0];
- switch (code)
- {
- case MESSAGE_DONE: /* Done */
- plugin->seek_request = -1;
- plugin->round_finished = 1;
- ret++;
- size--;
- data++;
- continue;
- case MESSAGE_SEEK: /* Seek */
- if (size < sizeof (struct SeekRequestMessage))
- {
- plugin->seek_request = -1;
- return ret;
- }
- memcpy (&seek, cdata, sizeof (seek));
- plugin->seek_request = (int64_t) seek.file_offset;
- plugin->seek_whence = seek.whence;
- ret += sizeof (struct SeekRequestMessage);
- data += sizeof (struct SeekRequestMessage);
- size -= sizeof (struct SeekRequestMessage);
- continue;
- case MESSAGE_META: /* Meta */
- if (size < sizeof (struct MetaMessage))
- {
- plugin->seek_request = -1;
- return ret;
- }
- memcpy (&meta, cdata, sizeof (meta));
- /* check hdr for sanity */
- if (meta.value_size > MAX_META_DATA)
- {
- LOG ("Meta data exceeds size limit\n");
- return -1; /* not allowing more than MAX_META_DATA meta data */
- }
- if (size < sizeof (meta) + meta.mime_length + meta.value_size)
- {
- plugin->seek_request = -1;
- return ret;
- }
- if (0 == meta.mime_length)
- {
- mime_type = NULL;
- }
- else
- {
- mime_type = &cdata[sizeof (struct MetaMessage)];
- if ('\0' != mime_type[meta.mime_length - 1])
- {
- LOG ("Mime type not 0-terminated\n");
- return -1;
- }
- }
- if (0 == meta.value_size)
- value = NULL;
- else
- value = &cdata[sizeof (struct MetaMessage) + meta.mime_length];
- if (meta.meta_type >= EXTRACTOR_metatype_get_max ())
- meta.meta_type = EXTRACTOR_METATYPE_UNKNOWN;
- proc (proc_cls,
- plugin,
- (enum EXTRACTOR_MetaType) meta.meta_type,
- (enum EXTRACTOR_MetaFormat) meta.meta_format,
- mime_type, value, meta.value_size);
- ret += sizeof (struct MetaMessage) + meta.mime_length + meta.value_size;
- size -= sizeof (struct MetaMessage) + meta.mime_length + meta.value_size;
- data += sizeof (struct MetaMessage) + meta.mime_length + meta.value_size;
- continue;
- default:
- LOG ("Invalid message type %d\n", (int) code);
- return -1;
- }
+ case MESSAGE_DONE: /* Done */
+ plugin->seek_request = -1;
+ plugin->round_finished = 1;
+ ret++;
+ size--;
+ data++;
+ continue;
+ case MESSAGE_SEEK: /* Seek */
+ if (size < sizeof (struct SeekRequestMessage))
+ {
+ plugin->seek_request = -1;
+ return ret;
+ }
+ memcpy (&seek, cdata, sizeof (seek));
+ plugin->seek_request = (int64_t) seek.file_offset;
+ plugin->seek_whence = seek.whence;
+ ret += sizeof (struct SeekRequestMessage);
+ data += sizeof (struct SeekRequestMessage);
+ size -= sizeof (struct SeekRequestMessage);
+ continue;
+ case MESSAGE_META: /* Meta */
+ if (size < sizeof (struct MetaMessage))
+ {
+ plugin->seek_request = -1;
+ return ret;
+ }
+ memcpy (&meta, cdata, sizeof (meta));
+ /* check hdr for sanity */
+ if (meta.value_size > MAX_META_DATA)
+ {
+ LOG ("Meta data exceeds size limit\n");
+ return -1; /* not allowing more than MAX_META_DATA meta data */
+ }
+ if (size < sizeof (meta) + meta.mime_length + meta.value_size)
+ {
+ plugin->seek_request = -1;
+ return ret;
+ }
+ if (0 == meta.mime_length)
+ {
+ mime_type = NULL;
+ }
+ else
+ {
+ mime_type = &cdata[sizeof (struct MetaMessage)];
+ if ('\0' != mime_type[meta.mime_length - 1])
+ {
+ LOG ("Mime type not 0-terminated\n");
+ return -1;
+ }
+ }
+ if (0 == meta.value_size)
+ value = NULL;
+ else
+ value = &cdata[sizeof (struct MetaMessage) + meta.mime_length];
+ if (meta.meta_type >= EXTRACTOR_metatype_get_max ())
+ meta.meta_type = EXTRACTOR_METATYPE_UNKNOWN;
+ proc (proc_cls,
+ plugin,
+ (enum EXTRACTOR_MetaType) meta.meta_type,
+ (enum EXTRACTOR_MetaFormat) meta.meta_format,
+ mime_type, value, meta.value_size);
+ ret += sizeof (struct MetaMessage) + meta.mime_length + meta.value_size;
+ size -= sizeof (struct MetaMessage) + meta.mime_length + meta.value_size;
+ data += sizeof (struct MetaMessage) + meta.mime_length + meta.value_size;
+ continue;
+ default:
+ LOG ("Invalid message type %d\n", (int) code);
+ return -1;
}
+ }
return ret;
}
+
/* end of extractor_ipc.c */
diff --git a/src/main/extractor_ipc.h b/src/main/extractor_ipc.h
@@ -27,7 +27,7 @@
* as follows. Each message begins with a 1-character opcode which
* specifies the message type. The main library starts the plugins
* by forking the helper process and establishes two pipes for
- * communication in both directions.
+ * communication in both directions.
* First, the main library send an 'INIT_STATE' message
* to the plugin. The start message specifies the name (and size)
* of a shared memory segment which will contain parts of the (uncompressed)
@@ -39,7 +39,7 @@
* size of the file (or -1 if unknown) and the number of bytes
* ready in the shared memory segment. The plugin then answers
* with either:
- * 1) MESSAGE_DONE to indicate that no further processing is
+ * 1) MESSAGE_DONE to indicate that no further processing is
* required for this file; the IPC continues with the
* EXTRACT_START message for the next file afterwards;
* 2) MESSAGE_SEEK to indicate that the plugin would like to
@@ -161,7 +161,7 @@ struct StartMessage
/**
* Sent from LE to a plugin to tell it that shm contents
- * were updated.
+ * were updated.
*/
#define MESSAGE_UPDATED_SHM 0x02
@@ -245,7 +245,7 @@ struct SeekRequestMessage
/**
* Requested offset; a positive value from the end of the
* file is used of 'whence' is SEEK_END; a postive value
- * from the start is used of 'whence' is SEEK_SET.
+ * from the start is used of 'whence' is SEEK_SET.
* 'SEEK_CUR' is never used.
*/
uint64_t file_offset;
@@ -292,9 +292,9 @@ struct MetaMessage
*/
uint32_t value_size;
- /* followed by mime_length bytes of 0-terminated
+ /* followed by mime_length bytes of 0-terminated
mime-type (unless mime_length is 0) */
-
+
/* followed by value_size bytes of value */
};
@@ -355,7 +355,7 @@ EXTRACTOR_IPC_shared_memory_destroy_ (struct EXTRACTOR_SharedMemory *shm);
*/
unsigned int
EXTRACTOR_IPC_shared_memory_change_rc_ (struct EXTRACTOR_SharedMemory *shm,
- int delta);
+ int delta);
/**
@@ -369,9 +369,9 @@ EXTRACTOR_IPC_shared_memory_change_rc_ (struct EXTRACTOR_SharedMemory *shm,
*/
ssize_t
EXTRACTOR_IPC_shared_memory_set_ (struct EXTRACTOR_SharedMemory *shm,
- struct EXTRACTOR_Datasource *ds,
- uint64_t off,
- size_t size);
+ struct EXTRACTOR_Datasource *ds,
+ uint64_t off,
+ size_t size);
/**
@@ -391,10 +391,10 @@ EXTRACTOR_datasource_get_pos_ (struct EXTRACTOR_Datasource *ds);
* @param plugin the plugin
* @param shm memory to share with the process
* @return NULL on error, otherwise IPC channel
- */
+ */
struct EXTRACTOR_Channel *
EXTRACTOR_IPC_channel_create_ (struct EXTRACTOR_PluginList *plugin,
- struct EXTRACTOR_SharedMemory *shm);
+ struct EXTRACTOR_SharedMemory *shm);
/**
@@ -418,8 +418,8 @@ EXTRACTOR_IPC_channel_destroy_ (struct EXTRACTOR_Channel *channel);
*/
ssize_t
EXTRACTOR_IPC_channel_send_ (struct EXTRACTOR_Channel *channel,
- const void *data,
- size_t size);
+ const void *data,
+ size_t size);
/**
@@ -434,12 +434,15 @@ EXTRACTOR_IPC_channel_send_ (struct EXTRACTOR_Channel *channel,
* @param value_len number of bytes in 'value'
*/
typedef void (*EXTRACTOR_ChannelMessageProcessor) (void *cls,
- struct EXTRACTOR_PluginList *plugin,
- enum EXTRACTOR_MetaType meta_type,
- enum EXTRACTOR_MetaFormat meta_format,
- const char *mime,
- const void *value,
- size_t value_len);
+ struct EXTRACTOR_PluginList *
+ plugin,
+ enum EXTRACTOR_MetaType
+ meta_type,
+ enum EXTRACTOR_MetaFormat
+ meta_format,
+ const char *mime,
+ const void *value,
+ size_t value_len);
/**
@@ -454,10 +457,10 @@ typedef void (*EXTRACTOR_ChannelMessageProcessor) (void *cls,
*/
ssize_t
EXTRACTOR_IPC_process_reply_ (struct EXTRACTOR_PluginList *plugin,
- const void *data,
- size_t size,
- EXTRACTOR_ChannelMessageProcessor proc,
- void *proc_cls);
+ const void *data,
+ size_t size,
+ EXTRACTOR_ChannelMessageProcessor proc,
+ void *proc_cls);
/**
@@ -473,9 +476,9 @@ EXTRACTOR_IPC_process_reply_ (struct EXTRACTOR_PluginList *plugin,
*/
int
EXTRACTOR_IPC_channel_recv_ (struct EXTRACTOR_Channel **channels,
- unsigned int num_channels,
- EXTRACTOR_ChannelMessageProcessor proc,
- void *proc_cls);
+ unsigned int num_channels,
+ EXTRACTOR_ChannelMessageProcessor proc,
+ void *proc_cls);
#endif
diff --git a/src/main/extractor_ipc_gnu.c b/src/main/extractor_ipc_gnu.c
@@ -138,10 +138,10 @@ EXTRACTOR_IPC_shared_memory_create_ (size_t size)
const char *tpath;
if (NULL == (shm = malloc (sizeof (struct EXTRACTOR_SharedMemory))))
- {
- LOG_STRERROR ("malloc");
- return NULL;
- }
+ {
+ LOG_STRERROR ("malloc");
+ return NULL;
+ }
#if SOMEBSD
/* this works on FreeBSD, not sure about others... */
tpath = getenv ("TMPDIR");
@@ -151,24 +151,24 @@ EXTRACTOR_IPC_shared_memory_create_ (size_t size)
tpath = "/"; /* Linux */
#endif
snprintf (shm->shm_name,
- MAX_SHM_NAME,
- "%sLE-%u-%u",
- tpath, getpid (),
- (unsigned int) RANDOM());
+ MAX_SHM_NAME,
+ "%sLE-%u-%u",
+ tpath, getpid (),
+ (unsigned int) RANDOM ());
if (-1 == (shm->shm_id = shm_open (shm->shm_name,
- O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)))
- {
- LOG_STRERROR_FILE ("shm_open",
- shm->shm_name);
- free (shm);
- return NULL;
- }
+ O_RDWR | O_CREAT, S_IRUSR | S_IWUSR)))
+ {
+ LOG_STRERROR_FILE ("shm_open",
+ shm->shm_name);
+ free (shm);
+ return NULL;
+ }
if ( (0 != ftruncate (shm->shm_id, size)) ||
(NULL == (shm->shm_ptr = mmap (NULL,
size,
- PROT_WRITE,
+ PROT_WRITE,
MAP_SHARED,
- shm->shm_id,
+ shm->shm_id,
0))) ||
(((void*) -1) == shm->shm_ptr) )
{
@@ -193,7 +193,7 @@ EXTRACTOR_IPC_shared_memory_create_ (size_t size)
*/
unsigned int
EXTRACTOR_IPC_shared_memory_change_rc_ (struct EXTRACTOR_SharedMemory *shm,
- int delta)
+ int delta)
{
shm->rc += delta;
return shm->rc;
@@ -228,23 +228,23 @@ EXTRACTOR_IPC_shared_memory_destroy_ (struct EXTRACTOR_SharedMemory *shm)
*/
ssize_t
EXTRACTOR_IPC_shared_memory_set_ (struct EXTRACTOR_SharedMemory *shm,
- struct EXTRACTOR_Datasource *ds,
- uint64_t off,
- size_t size)
+ struct EXTRACTOR_Datasource *ds,
+ uint64_t off,
+ size_t size)
{
if (-1 ==
EXTRACTOR_datasource_seek_ (ds,
off,
SEEK_SET))
- {
- LOG ("Failed to set IPC memory due to seek error\n");
- return -1;
- }
+ {
+ LOG ("Failed to set IPC memory due to seek error\n");
+ return -1;
+ }
if (size > shm->shm_size)
size = shm->shm_size;
return EXTRACTOR_datasource_read_ (ds,
- shm->shm_ptr,
- size);
+ shm->shm_ptr,
+ size);
}
@@ -277,7 +277,7 @@ EXTRACTOR_datasource_get_pos_ (struct EXTRACTOR_Datasource *ds)
*/
struct EXTRACTOR_Channel *
EXTRACTOR_IPC_channel_create_ (struct EXTRACTOR_PluginList *plugin,
- struct EXTRACTOR_SharedMemory *shm)
+ struct EXTRACTOR_SharedMemory *shm)
{
struct EXTRACTOR_Channel *channel;
int p1[2];
@@ -287,74 +287,74 @@ EXTRACTOR_IPC_channel_create_ (struct EXTRACTOR_PluginList *plugin,
size_t slen;
if (NULL == (channel = malloc (sizeof (struct EXTRACTOR_Channel))))
- {
- LOG_STRERROR ("malloc");
- return NULL;
- }
+ {
+ LOG_STRERROR ("malloc");
+ return NULL;
+ }
channel->mdata_size = 1024;
if (NULL == (channel->mdata = malloc (channel->mdata_size)))
- {
- LOG_STRERROR ("malloc");
- free (channel);
- return NULL;
- }
+ {
+ LOG_STRERROR ("malloc");
+ free (channel);
+ return NULL;
+ }
channel->shm = shm;
channel->plugin = plugin;
channel->size = 0;
if (0 != pipe (p1))
- {
- LOG_STRERROR ("pipe");
- free (channel->mdata);
- free (channel);
- return NULL;
- }
+ {
+ LOG_STRERROR ("pipe");
+ free (channel->mdata);
+ free (channel);
+ return NULL;
+ }
if (0 != pipe (p2))
- {
- LOG_STRERROR ("pipe");
- (void) close (p1[0]);
- (void) close (p1[1]);
- free (channel->mdata);
- free (channel);
- return NULL;
- }
+ {
+ LOG_STRERROR ("pipe");
+ (void) close (p1[0]);
+ (void) close (p1[1]);
+ free (channel->mdata);
+ free (channel);
+ return NULL;
+ }
pid = fork ();
if (pid == -1)
- {
- LOG_STRERROR ("fork");
- (void) close (p1[0]);
- (void) close (p1[1]);
- (void) close (p2[0]);
- (void) close (p2[1]);
- free (channel->mdata);
- free (channel);
- return NULL;
- }
+ {
+ LOG_STRERROR ("fork");
+ (void) close (p1[0]);
+ (void) close (p1[1]);
+ (void) close (p2[0]);
+ (void) close (p2[1]);
+ free (channel->mdata);
+ free (channel);
+ return NULL;
+ }
if (0 == pid)
- {
- (void) close (p1[1]);
- (void) close (p2[0]);
- free (channel->mdata);
- free (channel);
+ {
+ (void) close (p1[1]);
+ (void) close (p2[0]);
+ free (channel->mdata);
+ free (channel);
#if HAVE_SYS_APPARMOR_H
#if HAVE_APPARMOR
- if (0 > aa_change_profile("libextractor"))
+ if (0 > aa_change_profile ("libextractor"))
+ {
+ int eno = errno;
+
+ if ( (EINVAL != eno) &&
+ (ENOENT != eno) )
{
- int eno = errno;
-
- if ( (EINVAL != eno) &&
- (ENOENT != eno) )
- {
- fprintf (stderr,
- "Failure changing AppArmor profile: %s\n",
- strerror (errno));
- _exit(1);
- }
+ fprintf (stderr,
+ "Failure changing AppArmor profile: %s\n",
+ strerror (errno));
+ _exit (1);
}
+ }
#endif
#endif
- EXTRACTOR_plugin_main_ (plugin, p1[0], p2[1]);
- _exit (0);
- }
+ EXTRACTOR_plugin_main_ (plugin, p1[0], p2[1]);
+ _exit (0);
+ }
(void) close (p1[0]);
(void) close (p2[1]);
channel->cpipe_in = p1[1];
@@ -362,11 +362,11 @@ EXTRACTOR_IPC_channel_create_ (struct EXTRACTOR_PluginList *plugin,
channel->cpid = pid;
slen = strlen (shm->shm_name) + 1;
if (NULL == (init = malloc (sizeof (struct InitMessage) + slen)))
- {
- LOG_STRERROR ("malloc");
- EXTRACTOR_IPC_channel_destroy_ (channel);
- return NULL;
- }
+ {
+ LOG_STRERROR ("malloc");
+ EXTRACTOR_IPC_channel_destroy_ (channel);
+ return NULL;
+ }
init->opcode = MESSAGE_INIT_STATE;
init->reserved = 0;
init->reserved2 = 0;
@@ -375,14 +375,14 @@ EXTRACTOR_IPC_channel_create_ (struct EXTRACTOR_PluginList *plugin,
memcpy (&init[1], shm->shm_name, slen);
if (sizeof (struct InitMessage) + slen !=
EXTRACTOR_IPC_channel_send_ (channel,
- init,
- sizeof (struct InitMessage) + slen) )
- {
- LOG ("Failed to send INIT_STATE message to plugin\n");
- EXTRACTOR_IPC_channel_destroy_ (channel);
- free (init);
- return NULL;
- }
+ init,
+ sizeof (struct InitMessage) + slen) )
+ {
+ LOG ("Failed to send INIT_STATE message to plugin\n");
+ EXTRACTOR_IPC_channel_destroy_ (channel);
+ free (init);
+ return NULL;
+ }
free (init);
return channel;
}
@@ -425,24 +425,24 @@ EXTRACTOR_IPC_channel_destroy_ (struct EXTRACTOR_Channel *channel)
*/
ssize_t
EXTRACTOR_IPC_channel_send_ (struct EXTRACTOR_Channel *channel,
- const void *data,
- size_t size)
+ const void *data,
+ size_t size)
{
const char *cdata = data;
size_t off = 0;
ssize_t ret;
while (off < size)
+ {
+ ret = write (channel->cpipe_in, &cdata[off], size - off);
+ if (ret <= 0)
{
- ret = write (channel->cpipe_in, &cdata[off], size - off);
- if (ret <= 0)
- {
- if (-1 == ret)
- LOG_STRERROR ("write");
- return -1;
- }
- off += ret;
+ if (-1 == ret)
+ LOG_STRERROR ("write");
+ return -1;
}
+ off += ret;
+ }
return size;
}
@@ -464,9 +464,9 @@ EXTRACTOR_IPC_channel_send_ (struct EXTRACTOR_Channel *channel,
*/
int
EXTRACTOR_IPC_channel_recv_ (struct EXTRACTOR_Channel **channels,
- unsigned int num_channels,
- EXTRACTOR_ChannelMessageProcessor proc,
- void *proc_cls)
+ unsigned int num_channels,
+ EXTRACTOR_ChannelMessageProcessor proc,
+ void *proc_cls)
{
struct timeval tv;
fd_set to_check;
@@ -480,105 +480,106 @@ EXTRACTOR_IPC_channel_recv_ (struct EXTRACTOR_Channel **channels,
FD_ZERO (&to_check);
max = -1;
- for (i=0;i<num_channels;i++)
+ for (i = 0; i<num_channels; i++)
+ {
+ channel = channels[i];
+ if (NULL == channel)
+ continue;
+ FD_SET (channel->cpipe_out, &to_check);
+ if (max < channel->cpipe_out)
+ max = channel->cpipe_out;
+ }
+ if (-1 == max)
+ {
+ return 1; /* nothing left to do! */
+ }
+ tv.tv_sec = 0;
+ tv.tv_usec = 500000; /* 500 ms */
+ if (0 >= select (max + 1, &to_check, NULL, NULL, &tv))
+ {
+ /* an error or timeout -> something's wrong or all plugins hung up */
+ closed_channel = 0;
+ for (i = 0; i<num_channels; i++)
{
channel = channels[i];
if (NULL == channel)
- continue;
- FD_SET (channel->cpipe_out, &to_check);
- if (max < channel->cpipe_out)
- max = channel->cpipe_out;
+ continue;
+ if (-1 == channel->plugin->seek_request)
+ {
+ /* plugin blocked for too long, kill channel */
+ LOG ("Channel blocked, closing channel to %s\n",
+ channel->plugin->libname);
+ channel->plugin->channel = NULL;
+ channel->plugin->round_finished = 1;
+ EXTRACTOR_IPC_channel_destroy_ (channel);
+ channels[i] = NULL;
+ closed_channel = 1;
+ }
}
- if (-1 == max)
+ if (1 == closed_channel)
+ return 1;
+ /* strange, no channel is to blame, let's die just to be safe */
+ if ((EINTR != errno) && (0 != errno))
+ LOG_STRERROR ("select");
+ return -1;
+ }
+ for (i = 0; i<num_channels; i++)
+ {
+ channel = channels[i];
+ if (NULL == channel)
+ continue;
+ if (! FD_ISSET (channel->cpipe_out, &to_check))
+ continue;
+ if (channel->mdata_size == channel->size)
{
- return 1; /* nothing left to do! */
+ /* not enough space, need to grow allocation (if allowed) */
+ if (MAX_META_DATA == channel->mdata_size)
+ {
+ LOG ("Inbound message from channel too large, aborting\n");
+ EXTRACTOR_IPC_channel_destroy_ (channel);
+ channels[i] = NULL;
+ continue;
+ }
+ channel->mdata_size *= 2;
+ if (channel->mdata_size > MAX_META_DATA)
+ channel->mdata_size = MAX_META_DATA;
+ if (NULL == (ndata = realloc (channel->mdata,
+ channel->mdata_size)))
+ {
+ LOG_STRERROR ("realloc");
+ EXTRACTOR_IPC_channel_destroy_ (channel);
+ channels[i] = NULL;
+ continue;
+ }
+ channel->mdata = ndata;
}
- tv.tv_sec = 0;
- tv.tv_usec = 500000; /* 500 ms */
- if (0 >= select (max + 1, &to_check, NULL, NULL, &tv))
+ if ( (-1 == (iret = read (channel->cpipe_out,
+ &channel->mdata[channel->size],
+ channel->mdata_size - channel->size)) ) ||
+ (0 == iret) ||
+ (-1 == (ret = EXTRACTOR_IPC_process_reply_ (channel->plugin,
+ channel->mdata,
+ channel->size + iret,
+ proc, proc_cls)) ) )
{
- /* an error or timeout -> something's wrong or all plugins hung up */
- closed_channel = 0;
- for (i=0;i<num_channels;i++)
- {
- channel = channels[i];
- if (NULL == channel)
- continue;
- if (-1 == channel->plugin->seek_request)
- {
- /* plugin blocked for too long, kill channel */
- LOG ("Channel blocked, closing channel to %s\n",
- channel->plugin->libname);
- channel->plugin->channel = NULL;
- channel->plugin->round_finished = 1;
- EXTRACTOR_IPC_channel_destroy_ (channel);
- channels[i] = NULL;
- closed_channel = 1;
- }
- }
- if (1 == closed_channel)
- return 1;
- /* strange, no channel is to blame, let's die just to be safe */
- if ((EINTR != errno) && (0 != errno))
- LOG_STRERROR ("select");
- return -1;
+ if (-1 == iret)
+ LOG_STRERROR ("read");
+ LOG ("Read error from channel, closing channel %s\n",
+ channel->plugin->libname);
+ EXTRACTOR_IPC_channel_destroy_ (channel);
+ channels[i] = NULL;
+ continue;
}
- for (i=0;i<num_channels;i++)
+ else
{
- channel = channels[i];
- if (NULL == channel)
- continue;
- if (! FD_ISSET (channel->cpipe_out, &to_check))
- continue;
- if (channel->mdata_size == channel->size)
- {
- /* not enough space, need to grow allocation (if allowed) */
- if (MAX_META_DATA == channel->mdata_size)
- {
- LOG ("Inbound message from channel too large, aborting\n");
- EXTRACTOR_IPC_channel_destroy_ (channel);
- channels[i] = NULL;
- continue;
- }
- channel->mdata_size *= 2;
- if (channel->mdata_size > MAX_META_DATA)
- channel->mdata_size = MAX_META_DATA;
- if (NULL == (ndata = realloc (channel->mdata,
- channel->mdata_size)))
- {
- LOG_STRERROR ("realloc");
- EXTRACTOR_IPC_channel_destroy_ (channel);
- channels[i] = NULL;
- continue;
- }
- channel->mdata = ndata;
- }
- if ( (-1 == (iret = read (channel->cpipe_out,
- &channel->mdata[channel->size],
- channel->mdata_size - channel->size)) ) ||
- (0 == iret) ||
- (-1 == (ret = EXTRACTOR_IPC_process_reply_ (channel->plugin,
- channel->mdata,
- channel->size + iret,
- proc, proc_cls)) ) )
- {
- if (-1 == iret)
- LOG_STRERROR ("read");
- LOG ("Read error from channel, closing channel %s\n",
- channel->plugin->libname);
- EXTRACTOR_IPC_channel_destroy_ (channel);
- channels[i] = NULL;
- continue;
- }
- else
- {
- channel->size = channel->size + iret - ret;
- memmove (channel->mdata,
- &channel->mdata[ret],
- channel->size);
- }
+ channel->size = channel->size + iret - ret;
+ memmove (channel->mdata,
+ &channel->mdata[ret],
+ channel->size);
}
+ }
return 1;
}
+
/* end of extractor_ipc_gnu.c */
diff --git a/src/main/extractor_ipc_w32.c b/src/main/extractor_ipc_w32.c
@@ -34,32 +34,32 @@ struct EXTRACTOR_SharedMemory
/**
* W32 handle of the shm into which data is uncompressed
- */
+ */
HANDLE map;
/**
* Name of the shm
- */
+ */
char shm_name[MAX_SHM_NAME + 1];
/**
* Pointer to the mapped region of the shm (covers the whole shm)
- */
+ */
void *ptr;
/**
* Position within shm
- */
+ */
int64_t pos;
/**
* Allocated size of the shm
- */
+ */
int64_t shm_size;
/**
* Number of bytes in shm (<= shm_size)
- */
+ */
size_t shm_buf_size;
size_t shm_map_size;
@@ -132,11 +132,11 @@ struct EXTRACTOR_Channel
*/
char *mdata;
- /**
- * Size of the 'mdata' buffer.
- */
- size_t mdata_size;
-
+ /**
+ * Size of the 'mdata' buffer.
+ */
+ size_t mdata_size;
+
/**
* Number of valid bytes in the channel's buffer.
*/
@@ -159,11 +159,12 @@ EXTRACTOR_IPC_shared_memory_create_ (size_t size)
if (NULL == (shm = malloc (sizeof (struct EXTRACTOR_SharedMemory))))
return NULL;
- snprintf (shm->shm_name, MAX_SHM_NAME,
- "%slibextractor-shm-%u-%u",
- tpath, getpid(),
- (unsigned int) RANDOM());
- shm->map = CreateFileMapping (INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, size, shm->shm_name);
+ snprintf (shm->shm_name, MAX_SHM_NAME,
+ "%slibextractor-shm-%u-%u",
+ tpath, getpid (),
+ (unsigned int) RANDOM ());
+ shm->map = CreateFileMapping (INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0,
+ size, shm->shm_name);
shm->ptr = MapViewOfFile (shm->map, FILE_MAP_WRITE, 0, 0, size);
if (shm->ptr == NULL)
{
@@ -176,6 +177,7 @@ EXTRACTOR_IPC_shared_memory_create_ (size_t size)
return shm;
}
+
/**
* Change the reference counter for this shm instance.
*
@@ -185,7 +187,7 @@ EXTRACTOR_IPC_shared_memory_create_ (size_t size)
*/
unsigned int
EXTRACTOR_IPC_shared_memory_change_rc_ (struct EXTRACTOR_SharedMemory *shm,
- int delta)
+ int delta)
{
shm->rc += delta;
return shm->rc;
@@ -200,7 +202,7 @@ EXTRACTOR_IPC_shared_memory_change_rc_ (struct EXTRACTOR_SharedMemory *shm,
*/
void
EXTRACTOR_IPC_shared_memory_destroy_ (struct EXTRACTOR_SharedMemory *shm)
-{
+{
if (shm->ptr != NULL)
UnmapViewOfFile (shm->ptr);
if (shm->map != 0)
@@ -208,6 +210,7 @@ EXTRACTOR_IPC_shared_memory_destroy_ (struct EXTRACTOR_SharedMemory *shm)
free (shm);
}
+
/**
* Initialize shared memory area from data source.
*
@@ -219,21 +222,21 @@ EXTRACTOR_IPC_shared_memory_destroy_ (struct EXTRACTOR_SharedMemory *shm)
*/
ssize_t
EXTRACTOR_IPC_shared_memory_set_ (struct EXTRACTOR_SharedMemory *shm,
- struct EXTRACTOR_Datasource *ds,
- uint64_t off,
- size_t size)
+ struct EXTRACTOR_Datasource *ds,
+ uint64_t off,
+ size_t size)
{
if (-1 ==
EXTRACTOR_datasource_seek_ (ds, off, SEEK_SET))
- {
- LOG ("Failed to set IPC memory due to seek error\n");
- return -1;
- }
+ {
+ LOG ("Failed to set IPC memory due to seek error\n");
+ return -1;
+ }
if (size > shm->shm_size)
size = shm->shm_size;
return EXTRACTOR_datasource_read_ (ds,
- shm->ptr,
- size);
+ shm->ptr,
+ size);
}
@@ -291,7 +294,7 @@ create_selectable_pipe (PHANDLE read_pipe_ptr, PHANDLE write_pipe_ptr,
static volatile LONG pipe_unique_id;
snprintf (pipename, sizeof pipename, "\\\\.\\pipe\\gnunet-%d-%ld",
- getpid (), InterlockedIncrement ((LONG *) & pipe_unique_id));
+ getpid (), InterlockedIncrement ((LONG *) &pipe_unique_id));
/* Use CreateNamedPipe instead of CreatePipe, because the latter
* returns a write handle that does not permit FILE_READ_ATTRIBUTES
* access, on versions of win32 earlier than WinXP SP2.
@@ -300,8 +303,8 @@ create_selectable_pipe (PHANDLE read_pipe_ptr, PHANDLE write_pipe_ptr,
* It's important to only allow a single instance, to ensure that
* the pipe was not created earlier by some other process, even if
* the pid has been reused. We avoid FILE_FLAG_FIRST_PIPE_INSTANCE
- * because that is only available for Win2k SP2 and WinXP. */
- read_pipe = CreateNamedPipeA (pipename, PIPE_ACCESS_INBOUND | dwReadMode, PIPE_TYPE_BYTE | PIPE_READMODE_BYTE, 1, /* max instances */
+ * because that is only available for Win2k SP2 and WinXP. */read_pipe = CreateNamedPipeA (pipename, PIPE_ACCESS_INBOUND | dwReadMode,
+ PIPE_TYPE_BYTE | PIPE_READMODE_BYTE, 1, /* max instances */
psize, /* output buffer size */
psize, /* input buffer size */
NMPWAIT_USE_DEFAULT_WAIT, sa_ptr);
@@ -359,6 +362,7 @@ create_selectable_pipe (PHANDLE read_pipe_ptr, PHANDLE write_pipe_ptr,
return 0;
}
+
/**
* Communicates plugin data (library name, options) to the plugin
* process. This is only necessary on W32, where this information
@@ -367,10 +371,10 @@ create_selectable_pipe (PHANDLE read_pipe_ptr, PHANDLE write_pipe_ptr,
* @param plugin plugin context
*
* @return 0 on success, -1 on failure
- */
+ */
static int
write_plugin_data (struct EXTRACTOR_PluginList *plugin,
- struct EXTRACTOR_Channel *channel)
+ struct EXTRACTOR_Channel *channel)
{
size_t libname_len, shortname_len, opts_len;
DWORD len;
@@ -418,6 +422,7 @@ write_plugin_data (struct EXTRACTOR_PluginList *plugin,
return total_len == write_result;
}
+
/**
* Create a channel to communicate with a process wrapping
* the plugin of the given name. Starts the process as well.
@@ -425,10 +430,10 @@ write_plugin_data (struct EXTRACTOR_PluginList *plugin,
* @param plugin the plugin
* @param shm memory to share with the process
* @return NULL on error, otherwise IPC channel
- */
+ */
struct EXTRACTOR_Channel *
EXTRACTOR_IPC_channel_create_ (struct EXTRACTOR_PluginList *plugin,
- struct EXTRACTOR_SharedMemory *shm)
+ struct EXTRACTOR_SharedMemory *shm)
{
struct EXTRACTOR_Channel *channel;
HANDLE p1[2];
@@ -445,18 +450,19 @@ EXTRACTOR_IPC_channel_create_ (struct EXTRACTOR_PluginList *plugin,
SECURITY_ATTRIBUTES sa;
if (NULL == (channel = malloc (sizeof (struct EXTRACTOR_Channel))))
- {
- LOG_STRERROR ("malloc");
- return NULL;
- }
+ {
+ LOG_STRERROR ("malloc");
+ return NULL;
+ }
memset (channel, 0, sizeof (struct EXTRACTOR_Channel));
- channel->mdata_size = 1024;
- if (NULL == (channel->mdata = malloc (channel->mdata_size)))
- {
- LOG_STRERROR ("malloc");
- free (channel);
- return NULL;
- } channel->shm = shm;
+ channel->mdata_size = 1024;
+ if (NULL == (channel->mdata = malloc (channel->mdata_size)))
+ {
+ LOG_STRERROR ("malloc");
+ free (channel);
+ return NULL;
+ }
+ channel->shm = shm;
channel->plugin = plugin;
channel->size = 0;
@@ -464,13 +470,15 @@ EXTRACTOR_IPC_channel_create_ (struct EXTRACTOR_PluginList *plugin,
sa.lpSecurityDescriptor = NULL;
sa.bInheritHandle = FALSE;
- if (0 != create_selectable_pipe (&p1[0], &p1[1], &sa, 1024, FILE_FLAG_OVERLAPPED, FILE_FLAG_OVERLAPPED))
+ if (0 != create_selectable_pipe (&p1[0], &p1[1], &sa, 1024,
+ FILE_FLAG_OVERLAPPED, FILE_FLAG_OVERLAPPED))
{
LOG_STRERROR ("pipe");
free (channel);
return NULL;
}
- if (0 != create_selectable_pipe (&p2[0], &p2[1], &sa, 1024, FILE_FLAG_OVERLAPPED, FILE_FLAG_OVERLAPPED))
+ if (0 != create_selectable_pipe (&p2[0], &p2[1], &sa, 1024,
+ FILE_FLAG_OVERLAPPED, FILE_FLAG_OVERLAPPED))
{
LOG_STRERROR ("pipe");
CloseHandle (p1[0]);
@@ -479,10 +487,10 @@ EXTRACTOR_IPC_channel_create_ (struct EXTRACTOR_PluginList *plugin,
return NULL;
}
- if (!DuplicateHandle (GetCurrentProcess (), p1[0], GetCurrentProcess (),
- &p10_os_inh, 0, TRUE, DUPLICATE_SAME_ACCESS)
- || !DuplicateHandle (GetCurrentProcess (), p2[1], GetCurrentProcess (),
- &p21_os_inh, 0, TRUE, DUPLICATE_SAME_ACCESS))
+ if (! DuplicateHandle (GetCurrentProcess (), p1[0], GetCurrentProcess (),
+ &p10_os_inh, 0, TRUE, DUPLICATE_SAME_ACCESS)
+ || ! DuplicateHandle (GetCurrentProcess (), p2[1], GetCurrentProcess (),
+ &p21_os_inh, 0, TRUE, DUPLICATE_SAME_ACCESS))
{
LOG_STRERROR ("DuplicateHandle");
if (p10_os_inh != INVALID_HANDLE_VALUE)
@@ -506,13 +514,13 @@ EXTRACTOR_IPC_channel_create_ (struct EXTRACTOR_PluginList *plugin,
* Also, users might freak out seeing over 9000 rundll32 processes (seeing over 9000 processes named
* "libextractor_plugin_helper" is probably less confusing).
*/
- snprintf(cmd, MAX_PATH,
- "rundll32.exe libextractor-3.dll,RundllEntryPoint@16 %lu %lu",
- p10_os_inh, p21_os_inh);
+ snprintf (cmd, MAX_PATH,
+ "rundll32.exe libextractor-3.dll,RundllEntryPoint@16 %lu %lu",
+ p10_os_inh, p21_os_inh);
cmd[MAX_PATH] = '\0';
startup.cb = sizeof (STARTUPINFOA);
if (CreateProcessA (NULL, cmd, NULL, NULL, TRUE, CREATE_SUSPENDED, NULL, NULL,
- &startup, &proc))
+ &startup, &proc))
{
channel->hProcess = proc.hProcess;
ResumeThread (proc.hThread);
@@ -544,7 +552,7 @@ EXTRACTOR_IPC_channel_create_ (struct EXTRACTOR_PluginList *plugin,
channel->ov_write.hEvent = CreateEvent (NULL, TRUE, TRUE, NULL);
channel->ov_read.hEvent = CreateEvent (NULL, TRUE, TRUE, NULL);
- if (!write_plugin_data (plugin, channel))
+ if (! write_plugin_data (plugin, channel))
{
LOG_STRERROR ("write_plugin_data");
EXTRACTOR_IPC_channel_destroy_ (channel);
@@ -553,11 +561,11 @@ EXTRACTOR_IPC_channel_create_ (struct EXTRACTOR_PluginList *plugin,
slen = strlen (shm->shm_name) + 1;
if (NULL == (init = malloc (sizeof (struct InitMessage) + slen)))
- {
- LOG_STRERROR ("malloc");
- EXTRACTOR_IPC_channel_destroy_ (channel);
- return NULL;
- }
+ {
+ LOG_STRERROR ("malloc");
+ EXTRACTOR_IPC_channel_destroy_ (channel);
+ return NULL;
+ }
init->opcode = MESSAGE_INIT_STATE;
init->reserved = 0;
init->reserved2 = 0;
@@ -566,17 +574,18 @@ EXTRACTOR_IPC_channel_create_ (struct EXTRACTOR_PluginList *plugin,
memcpy (&init[1], shm->shm_name, slen);
if (sizeof (struct InitMessage) + slen !=
EXTRACTOR_IPC_channel_send_ (channel, init,
- sizeof (struct InitMessage) + slen))
- {
- LOG ("Failed to send INIT_STATE message to plugin\n");
- EXTRACTOR_IPC_channel_destroy_ (channel);
- free (init);
- return NULL;
- }
+ sizeof (struct InitMessage) + slen))
+ {
+ LOG ("Failed to send INIT_STATE message to plugin\n");
+ EXTRACTOR_IPC_channel_destroy_ (channel);
+ free (init);
+ return NULL;
+ }
free (init);
return channel;
}
+
/**
* Destroy communication channel with a plugin/process. Also
* destroys the process.
@@ -606,6 +615,7 @@ EXTRACTOR_IPC_channel_destroy_ (struct EXTRACTOR_Channel *channel)
free (channel);
}
+
/**
* Send data via the given IPC channel (blocking).
*
@@ -617,8 +627,8 @@ EXTRACTOR_IPC_channel_destroy_ (struct EXTRACTOR_Channel *channel)
*/
ssize_t
EXTRACTOR_IPC_channel_send_ (struct EXTRACTOR_Channel *channel,
- const void *data,
- size_t size)
+ const void *data,
+ size_t size)
{
DWORD written;
DWORD err;
@@ -644,7 +654,8 @@ EXTRACTOR_IPC_channel_send_ (struct EXTRACTOR_Channel *channel,
channel->ov_write.Pointer = 0;
channel->ov_write.Internal = 0;
channel->ov_write.InternalHigh = 0;
- bresult = WriteFile (channel->cpipe_in, channel->old_buf, size, &written, &channel->ov_write);
+ bresult = WriteFile (channel->cpipe_in, channel->old_buf, size, &written,
+ &channel->ov_write);
if (bresult == TRUE)
{
@@ -682,9 +693,9 @@ EXTRACTOR_IPC_channel_send_ (struct EXTRACTOR_Channel *channel,
*/
int
EXTRACTOR_IPC_channel_recv_ (struct EXTRACTOR_Channel **channels,
- unsigned int num_channels,
- EXTRACTOR_ChannelMessageProcessor proc,
- void *proc_cls)
+ unsigned int num_channels,
+ EXTRACTOR_ChannelMessageProcessor proc,
+ void *proc_cls)
{
DWORD ms;
DWORD first_ready;
@@ -707,7 +718,8 @@ EXTRACTOR_IPC_channel_recv_ (struct EXTRACTOR_Channel **channels,
if (WaitForSingleObject (channels[i]->ov_read.hEvent, 0) == WAIT_OBJECT_0)
{
ResetEvent (channels[i]->ov_read.hEvent);
- bresult = ReadFile (channels[i]->cpipe_out, &i, 0, &bytes_read, &channels[i]->ov_read);
+ bresult = ReadFile (channels[i]->cpipe_out, &i, 0, &bytes_read,
+ &channels[i]->ov_read);
if (bresult == TRUE)
{
SetEvent (channels[i]->ov_read.hEvent);
@@ -728,7 +740,7 @@ EXTRACTOR_IPC_channel_recv_ (struct EXTRACTOR_Channel **channels,
ms = 500;
first_ready = WaitForMultipleObjects (c, events, FALSE, ms);
- if (first_ready == WAIT_TIMEOUT || first_ready == WAIT_FAILED)
+ if ((first_ready == WAIT_TIMEOUT) || (first_ready == WAIT_FAILED))
{
/* an error or timeout -> something's wrong or all plugins hung up */
closed_channel = 0;
@@ -765,37 +777,40 @@ EXTRACTOR_IPC_channel_recv_ (struct EXTRACTOR_Channel **channels,
{
int ret;
if (channels[i]->mdata_size == channels[i]->size)
- {
- /* not enough space, need to grow allocation (if allowed) */
- if (MAX_META_DATA == channels[i]->mdata_size)
- {
- LOG ("Inbound message from channel too large, aborting\n");
- EXTRACTOR_IPC_channel_destroy_ (channels[i]);
- channels[i] = NULL;
- }
- channels[i]->mdata_size *= 2;
- if (channels[i]->mdata_size > MAX_META_DATA)
- channels[i]->mdata_size = MAX_META_DATA;
- if (NULL == (ndata = realloc (channels[i]->mdata,
- channels[i]->mdata_size)))
- {
- LOG_STRERROR ("realloc");
- EXTRACTOR_IPC_channel_destroy_ (channels[i]);
- channels[i] = NULL;
- }
- channels[i]->mdata = ndata;
- }
+ {
+ /* not enough space, need to grow allocation (if allowed) */
+ if (MAX_META_DATA == channels[i]->mdata_size)
+ {
+ LOG ("Inbound message from channel too large, aborting\n");
+ EXTRACTOR_IPC_channel_destroy_ (channels[i]);
+ channels[i] = NULL;
+ }
+ channels[i]->mdata_size *= 2;
+ if (channels[i]->mdata_size > MAX_META_DATA)
+ channels[i]->mdata_size = MAX_META_DATA;
+ if (NULL == (ndata = realloc (channels[i]->mdata,
+ channels[i]->mdata_size)))
+ {
+ LOG_STRERROR ("realloc");
+ EXTRACTOR_IPC_channel_destroy_ (channels[i]);
+ channels[i] = NULL;
+ }
+ channels[i]->mdata = ndata;
+ }
bresult = ReadFile (channels[i]->cpipe_out,
- &channels[i]->mdata[channels[i]->size],
- channels[i]->mdata_size - channels[i]->size, &bytes_read, NULL);
+ &channels[i]->mdata[channels[i]->size],
+ channels[i]->mdata_size - channels[i]->size,
+ &bytes_read, NULL);
if (bresult)
ret = EXTRACTOR_IPC_process_reply_ (channels[i]->plugin,
- channels[i]->mdata, channels[i]->size + bytes_read, proc, proc_cls);
- if (!bresult || -1 == ret)
+ channels[i]->mdata,
+ channels[i]->size + bytes_read,
+ proc, proc_cls);
+ if (! bresult || (-1 == ret))
{
DWORD error = GetLastError ();
SetErrnoFromWinError (error);
- if (!bresult)
+ if (! bresult)
LOG_STRERROR ("ReadFile");
EXTRACTOR_IPC_channel_destroy_ (channels[i]);
channels[i] = NULL;
@@ -803,12 +818,10 @@ EXTRACTOR_IPC_channel_recv_ (struct EXTRACTOR_Channel **channels,
else
{
memmove (channels[i]->mdata, &channels[i]->mdata[ret],
- channels[i]->size + bytes_read - ret);
- channels[i]->size = channels[i]->size + bytes_read- ret;
+ channels[i]->size + bytes_read - ret);
+ channels[i]->size = channels[i]->size + bytes_read - ret;
}
}
}
return 1;
}
-
-
diff --git a/src/main/extractor_logging.c b/src/main/extractor_logging.c
@@ -39,13 +39,15 @@ EXTRACTOR_log_ (const char *file, int line, const char *format, ...)
va_list va;
fprintf (stderr,
- "EXTRACTOR %s:%d ",
- file, line);
- va_start (va, format);
+ "EXTRACTOR %s:%d ",
+ file, line);
+ va_start (va, format);
vfprintf (stderr, format, va);
va_end (va);
fflush (stderr);
}
+
+
#endif
@@ -57,7 +59,7 @@ EXTRACTOR_log_ (const char *file, int line, const char *format, ...)
*/
void
EXTRACTOR_abort_ (const char *file,
- int line)
+ int line)
{
#if DEBUG
EXTRACTOR_log_ (file, line, "Assertion failed.\n");
@@ -65,4 +67,5 @@ EXTRACTOR_abort_ (const char *file,
ABORT ();
}
+
/* end of extractor_logging.c */
diff --git a/src/main/extractor_logging.h b/src/main/extractor_logging.h
@@ -44,7 +44,7 @@ EXTRACTOR_log_ (const char *file, int line, const char *format, ...);
*
* @param ... format string and arguments for fmt (printf-style)
*/
-#define LOG(...) EXTRACTOR_log_(__FILE__, __LINE__, __VA_ARGS__)
+#define LOG(...) EXTRACTOR_log_ (__FILE__, __LINE__, __VA_ARGS__)
#else
@@ -64,7 +64,8 @@ EXTRACTOR_log_ (const char *file, int line, const char *format, ...);
*
* @param syscall name of the syscall that failed
*/
-#define LOG_STRERROR(syscall) LOG("System call `%s' failed: %s\n", syscall, STRERROR (errno))
+#define LOG_STRERROR(syscall) LOG ("System call `%s' failed: %s\n", syscall, \
+ STRERROR (errno))
/**
@@ -74,7 +75,9 @@ EXTRACTOR_log_ (const char *file, int line, const char *format, ...);
* @param syscall name of the syscall that failed
* @param filename name of the file that was involved
*/
-#define LOG_STRERROR_FILE(syscall,filename) LOG("System call `%s' failed for file `%s': %s\n", syscall, filename, STRERROR (errno))
+#define LOG_STRERROR_FILE(syscall,filename) LOG ( \
+ "System call `%s' failed for file `%s': %s\n", syscall, filename, STRERROR ( \
+ errno))
/**
@@ -85,7 +88,7 @@ EXTRACTOR_log_ (const char *file, int line, const char *format, ...);
*/
void
EXTRACTOR_abort_ (const char *file,
- int line);
+ int line);
/**
@@ -93,7 +96,8 @@ EXTRACTOR_abort_ (const char *file,
*
* @param cond assertion that must hold.
*/
-#define ASSERT(cond) do { if (! (cond)) EXTRACTOR_abort_ (__FILE__, __LINE__); } while (0)
+#define ASSERT(cond) do { if (! (cond)) EXTRACTOR_abort_ (__FILE__, __LINE__); \
+} while (0)
#endif
diff --git a/src/main/extractor_metatypes.c b/src/main/extractor_metatypes.c
@@ -30,7 +30,7 @@ struct MetaTypeDescription
* Short (typically 1-word) description.
*/
const char *short_description;
-
+
/**
* More detailed description.
*/
@@ -48,7 +48,8 @@ static const struct MetaTypeDescription meta_type_descriptions[] = {
{ gettext_noop ("mimetype"),
gettext_noop ("mime type") },
{ gettext_noop ("embedded filename"),
- gettext_noop ("filename that was embedded (not necessarily the current filename)") },
+ gettext_noop (
+ "filename that was embedded (not necessarily the current filename)") },
{ gettext_noop ("comment"),
gettext_noop ("comment about the content") },
{ gettext_noop ("title"),
@@ -62,15 +63,16 @@ static const struct MetaTypeDescription meta_type_descriptions[] = {
gettext_noop ("chapter number") },
{ gettext_noop ("journal name"),
gettext_noop ("journal or magazine the work was published in") },
- { gettext_noop ("journal volume"),
+ { gettext_noop ("journal volume"),
gettext_noop ("volume of a journal or multi-volume book") },
/* 10 */
- { gettext_noop ("journal number"),
+ { gettext_noop ("journal number"),
gettext_noop ("number of a journal, magazine or tech-report") },
{ gettext_noop ("page count"),
gettext_noop ("total number of pages of the work") },
{ gettext_noop ("page range"),
- gettext_noop ("page numbers of the publication in the respective journal or book") },
+ gettext_noop (
+ "page numbers of the publication in the respective journal or book") },
{ gettext_noop ("author name"),
gettext_noop ("name of the author(s)") },
{ gettext_noop ("author email"),
@@ -83,20 +85,25 @@ static const struct MetaTypeDescription meta_type_descriptions[] = {
{ gettext_noop ("publisher's address"),
gettext_noop ("Address of the publisher (often only the city)") },
{ gettext_noop ("publishing institution"),
- gettext_noop ("institution that was involved in the publishing, but not necessarily the publisher") },
+ gettext_noop (
+ "institution that was involved in the publishing, but not necessarily the publisher") },
{ gettext_noop ("publication series"),
gettext_noop ("series of books the book was published in") },
/* 20 */
{ gettext_noop ("publication type"),
gettext_noop ("type of the tech-report") },
{ gettext_noop ("publication year"),
- gettext_noop ("year of publication (or, if unpublished, the year of creation)") },
+ gettext_noop (
+ "year of publication (or, if unpublished, the year of creation)") },
{ gettext_noop ("publication month"),
- gettext_noop ("month of publication (or, if unpublished, the month of creation)") },
+ gettext_noop (
+ "month of publication (or, if unpublished, the month of creation)") },
{ gettext_noop ("publication day"),
- gettext_noop ("day of publication (or, if unpublished, the day of creation), relative to the given month") },
+ gettext_noop (
+ "day of publication (or, if unpublished, the day of creation), relative to the given month") },
{ gettext_noop ("publication date"),
- gettext_noop ("date of publication (or, if unpublished, the date of creation)") },
+ gettext_noop (
+ "date of publication (or, if unpublished, the date of creation)") },
/* 25 */
{ gettext_noop ("bibtex eprint"),
gettext_noop ("specification of an electronic publication") },
@@ -107,7 +114,8 @@ static const struct MetaTypeDescription meta_type_descriptions[] = {
{ gettext_noop ("creation time"),
gettext_noop ("time and date of creation") },
{ gettext_noop ("URL"),
- gettext_noop ("universal resource location (where the work is made available)") },
+ gettext_noop (
+ "universal resource location (where the work is made available)") },
/* 30 */
{ gettext_noop ("URI"),
gettext_noop ("universal resource identifier") },
@@ -120,7 +128,7 @@ static const struct MetaTypeDescription meta_type_descriptions[] = {
{ gettext_noop ("SHA-0"),
gettext_noop ("SHA-0 hash") },
/* 35 */
- { gettext_noop ("SHA-1"),
+ { gettext_noop ("SHA-1"),
gettext_noop ("SHA-1 hash") },
{ gettext_noop ("RipeMD160"),
gettext_noop ("RipeMD150 hash") },
@@ -135,7 +143,7 @@ static const struct MetaTypeDescription meta_type_descriptions[] = {
gettext_noop ("GPS longitude") },
{ gettext_noop ("city"),
gettext_noop ("name of the city where the document originated") },
- { gettext_noop ("sublocation"),
+ { gettext_noop ("sublocation"),
gettext_noop ("more specific location of the geographic origin") },
{ gettext_noop ("country"),
gettext_noop ("name of the country where the document originated") },
@@ -169,7 +177,8 @@ static const struct MetaTypeDescription meta_type_descriptions[] = {
{ gettext_noop ("created by software"),
gettext_noop ("name of the software that created the document") },
{ gettext_noop ("unknown date"),
- gettext_noop ("ambiguous date (could specify creation time, modification time or access time)") },
+ gettext_noop (
+ "ambiguous date (could specify creation time, modification time or access time)") },
{ gettext_noop ("creation date"),
gettext_noop ("date the document was created") },
{ gettext_noop ("modification date"),
@@ -189,7 +198,8 @@ static const struct MetaTypeDescription meta_type_descriptions[] = {
{ gettext_noop ("revision history"),
gettext_noop ("information about the revision history") },
{ gettext_noop ("embedded file size"),
- gettext_noop ("size of the contents of the container as embedded in the file") },
+ gettext_noop (
+ "size of the contents of the container as embedded in the file") },
{ gettext_noop ("file type"),
gettext_noop ("standard Macintosh Finder file type information") },
{ gettext_noop ("creator"),
@@ -213,9 +223,11 @@ static const struct MetaTypeDescription meta_type_descriptions[] = {
{ gettext_noop ("provides"),
gettext_noop ("functionality provided by this package") },
{ gettext_noop ("recommendations"),
- gettext_noop ("packages recommended for installation in conjunction with this package") },
+ gettext_noop (
+ "packages recommended for installation in conjunction with this package") },
{ gettext_noop ("suggestions"),
- gettext_noop ("packages suggested for installation in conjunction with this package") },
+ gettext_noop (
+ "packages suggested for installation in conjunction with this package") },
{ gettext_noop ("maintainer"),
gettext_noop ("name of the maintainer") },
/* 80 */
@@ -228,208 +240,218 @@ static const struct MetaTypeDescription meta_type_descriptions[] = {
{ gettext_noop ("target architecture"),
gettext_noop ("hardware architecture the contents can be used for") },
{ gettext_noop ("pre-dependency"),
- gettext_noop ("dependency that must be satisfied before installation") },
+ gettext_noop ("dependency that must be satisfied before installation") },
/* 85 */
{ gettext_noop ("license"),
- gettext_noop ("applicable copyright license") },
+ gettext_noop ("applicable copyright license") },
{ gettext_noop ("distribution"),
- gettext_noop ("distribution the package is a part of") },
+ gettext_noop ("distribution the package is a part of") },
{ gettext_noop ("build host"),
- gettext_noop ("machine the package was build on") },
+ gettext_noop ("machine the package was build on") },
{ gettext_noop ("vendor"),
- gettext_noop ("name of the software vendor") },
+ gettext_noop ("name of the software vendor") },
{ gettext_noop ("target operating system"),
- gettext_noop ("operating system for which this package was made") },
+ gettext_noop ("operating system for which this package was made") },
/* 90 */
{ gettext_noop ("software version"),
- gettext_noop ("version of the software contained in the file") },
+ gettext_noop ("version of the software contained in the file") },
{ gettext_noop ("target platform"),
- gettext_noop ("name of the architecture, operating system and distribution this package is for") },
+ gettext_noop (
+ "name of the architecture, operating system and distribution this package is for") },
{ gettext_noop ("resource type"),
- gettext_noop ("categorization of the nature of the resource that is more specific than the file format") },
+ gettext_noop (
+ "categorization of the nature of the resource that is more specific than the file format") },
{ gettext_noop ("library search path"),
- gettext_noop ("path in the file system to be considered when looking for required libraries") },
+ gettext_noop (
+ "path in the file system to be considered when looking for required libraries") },
{ gettext_noop ("library dependency"),
- gettext_noop ("name of a library that this file depends on") },
+ gettext_noop ("name of a library that this file depends on") },
/* 95 */
{ gettext_noop ("camera make"),
- gettext_noop ("camera make") },
+ gettext_noop ("camera make") },
{ gettext_noop ("camera model"),
- gettext_noop ("camera model") },
+ gettext_noop ("camera model") },
{ gettext_noop ("exposure"),
- gettext_noop ("exposure") },
+ gettext_noop ("exposure") },
{ gettext_noop ("aperture"),
- gettext_noop ("aperture") },
+ gettext_noop ("aperture") },
{ gettext_noop ("exposure bias"),
- gettext_noop ("exposure bias") },
+ gettext_noop ("exposure bias") },
/* 100 */
{ gettext_noop ("flash"),
- gettext_noop ("flash") },
+ gettext_noop ("flash") },
{ gettext_noop ("flash bias"),
- gettext_noop ("flash bias") },
+ gettext_noop ("flash bias") },
{ gettext_noop ("focal length"),
- gettext_noop ("focal length") },
+ gettext_noop ("focal length") },
{ gettext_noop ("focal length 35mm"),
- gettext_noop ("focal length 35mm") },
+ gettext_noop ("focal length 35mm") },
{ gettext_noop ("iso speed"),
- gettext_noop ("iso speed") },
+ gettext_noop ("iso speed") },
/* 105 */
{ gettext_noop ("exposure mode"),
- gettext_noop ("exposure mode") },
+ gettext_noop ("exposure mode") },
{ gettext_noop ("metering mode"),
- gettext_noop ("metering mode") },
+ gettext_noop ("metering mode") },
{ gettext_noop ("macro mode"),
- gettext_noop ("macro mode") },
+ gettext_noop ("macro mode") },
{ gettext_noop ("image quality"),
- gettext_noop ("image quality") },
+ gettext_noop ("image quality") },
{ gettext_noop ("white balance"),
- gettext_noop ("white balance") },
+ gettext_noop ("white balance") },
/* 110 */
{ gettext_noop ("orientation"),
- gettext_noop ("orientation") },
+ gettext_noop ("orientation") },
{ gettext_noop ("magnification"),
- gettext_noop ("magnification") },
+ gettext_noop ("magnification") },
{ gettext_noop ("image dimensions"),
- gettext_noop ("size of the image in pixels (width times height)") },
+ gettext_noop ("size of the image in pixels (width times height)") },
{ gettext_noop ("produced by software"),
gettext_noop ("produced by software") }, /* what is the exact difference between the software
- creator and the software producer? PDF and DVI
- both have this distinction (i.e., Writer vs.
- OpenOffice) */
+ creator and the software producer? PDF and DVI
+ both have this distinction (i.e., Writer vs.
+ OpenOffice) */
{ gettext_noop ("thumbnail"),
- gettext_noop ("smaller version of the image for previewing") },
+ gettext_noop ("smaller version of the image for previewing") },
/* 115 */
{ gettext_noop ("image resolution"),
- gettext_noop ("resolution in dots per inch") },
+ gettext_noop ("resolution in dots per inch") },
{ gettext_noop ("source"),
- gettext_noop ("Originating entity") },
+ gettext_noop ("Originating entity") },
{ gettext_noop ("character set"),
- gettext_noop ("character encoding used") },
+ gettext_noop ("character encoding used") },
{ gettext_noop ("line count"),
- gettext_noop ("number of lines") },
+ gettext_noop ("number of lines") },
{ gettext_noop ("paragraph count"),
- gettext_noop ("number of paragraphs") },
+ gettext_noop ("number of paragraphs") },
/* 120 */
{ gettext_noop ("word count"),
- gettext_noop ("number of words") },
+ gettext_noop ("number of words") },
{ gettext_noop ("character count"),
- gettext_noop ("number of characters") },
+ gettext_noop ("number of characters") },
{ gettext_noop ("page orientation"),
- gettext_noop ("page orientation") },
+ gettext_noop ("page orientation") },
{ gettext_noop ("paper size"),
- gettext_noop ("paper size") },
+ gettext_noop ("paper size") },
{ gettext_noop ("template"),
- gettext_noop ("template the document uses or is based on") },
+ gettext_noop ("template the document uses or is based on") },
/* 125 */
{ gettext_noop ("company"),
- gettext_noop ("company") },
+ gettext_noop ("company") },
{ gettext_noop ("manager"),
- gettext_noop ("manager") },
+ gettext_noop ("manager") },
{ gettext_noop ("revision number"),
- gettext_noop ("revision number") },
+ gettext_noop ("revision number") },
{ gettext_noop ("duration"),
- gettext_noop ("play time for the medium") },
+ gettext_noop ("play time for the medium") },
{ gettext_noop ("album"),
- gettext_noop ("name of the album") },
+ gettext_noop ("name of the album") },
/* 130 */
{ gettext_noop ("artist"),
- gettext_noop ("name of the artist or band") },
+ gettext_noop ("name of the artist or band") },
{ gettext_noop ("genre"),
- gettext_noop ("genre") },
+ gettext_noop ("genre") },
{ gettext_noop ("track number"),
- gettext_noop ("original number of the track on the distribution medium") },
+ gettext_noop ("original number of the track on the distribution medium") },
{ gettext_noop ("disk number"),
- gettext_noop ("number of the disk in a multi-disk (or volume) distribution") },
+ gettext_noop (
+ "number of the disk in a multi-disk (or volume) distribution") },
{ gettext_noop ("performer"),
- gettext_noop ("The artist(s) who performed the work (conductor, orchestra, soloists, actor, etc.)") },
+ gettext_noop (
+ "The artist(s) who performed the work (conductor, orchestra, soloists, actor, etc.)") },
/* 135 */
{ gettext_noop ("contact"),
- gettext_noop ("Contact information for the creator or distributor") },
+ gettext_noop ("Contact information for the creator or distributor") },
{ gettext_noop ("song version"),
- gettext_noop ("name of the version of the song (i.e. remix information)") },
+ gettext_noop ("name of the version of the song (i.e. remix information)") },
{ gettext_noop ("picture"),
- gettext_noop ("associated misc. picture") },
+ gettext_noop ("associated misc. picture") },
{ gettext_noop ("cover picture"),
- gettext_noop ("picture of the cover of the distribution medium") },
+ gettext_noop ("picture of the cover of the distribution medium") },
{ gettext_noop ("contributor picture"),
- gettext_noop ("picture of one of the contributors") },
+ gettext_noop ("picture of one of the contributors") },
/* 140 */
{ gettext_noop ("event picture"),
- gettext_noop ("picture of an associated event") },
+ gettext_noop ("picture of an associated event") },
{ gettext_noop ("logo"),
- gettext_noop ("logo of an associated organization") },
+ gettext_noop ("logo of an associated organization") },
{ gettext_noop ("broadcast television system"),
- gettext_noop ("name of the television system for which the data is coded") },
+ gettext_noop (
+ "name of the television system for which the data is coded") },
{ gettext_noop ("source device"),
- gettext_noop ("device used to create the object") },
+ gettext_noop ("device used to create the object") },
{ gettext_noop ("disclaimer"),
- gettext_noop ("legal disclaimer") },
+ gettext_noop ("legal disclaimer") },
/* 145 */
{ gettext_noop ("warning"),
- gettext_noop ("warning about the nature of the content") },
+ gettext_noop ("warning about the nature of the content") },
{ gettext_noop ("page order"),
- gettext_noop ("order of the pages") },
+ gettext_noop ("order of the pages") },
{ gettext_noop ("writer"),
- gettext_noop ("contributing writer") },
+ gettext_noop ("contributing writer") },
{ gettext_noop ("product version"),
- gettext_noop ("product version") },
+ gettext_noop ("product version") },
{ gettext_noop ("contributor"),
- gettext_noop ("name of a contributor") },
+ gettext_noop ("name of a contributor") },
/* 150 */
{ gettext_noop ("movie director"),
- gettext_noop ("name of the director") },
+ gettext_noop ("name of the director") },
{ gettext_noop ("network"),
- gettext_noop ("name of the broadcasting network or station") },
+ gettext_noop ("name of the broadcasting network or station") },
{ gettext_noop ("show"),
- gettext_noop ("name of the show") },
+ gettext_noop ("name of the show") },
{ gettext_noop ("chapter name"),
- gettext_noop ("name of the chapter") },
+ gettext_noop ("name of the chapter") },
{ gettext_noop ("song count"),
- gettext_noop ("number of songs") },
+ gettext_noop ("number of songs") },
/* 155 */
{ gettext_noop ("starting song"),
- gettext_noop ("number of the first song to play") },
+ gettext_noop ("number of the first song to play") },
{ gettext_noop ("play counter"),
- gettext_noop ("number of times the media has been played") },
+ gettext_noop ("number of times the media has been played") },
{ gettext_noop ("conductor"),
- gettext_noop ("name of the conductor") },
+ gettext_noop ("name of the conductor") },
{ gettext_noop ("interpretation"),
- gettext_noop ("information about the people behind interpretations of an existing piece") },
+ gettext_noop (
+ "information about the people behind interpretations of an existing piece") },
{ gettext_noop ("composer"),
- gettext_noop ("name of the composer") },
+ gettext_noop ("name of the composer") },
/* 160 */
{ gettext_noop ("beats per minute"),
- gettext_noop ("beats per minute") },
+ gettext_noop ("beats per minute") },
{ gettext_noop ("encoded by"),
- gettext_noop ("name of person or organization that encoded the file") },
+ gettext_noop ("name of person or organization that encoded the file") },
{ gettext_noop ("original title"),
- gettext_noop ("title of the original work") },
+ gettext_noop ("title of the original work") },
{ gettext_noop ("original artist"),
- gettext_noop ("name of the original artist") },
+ gettext_noop ("name of the original artist") },
{ gettext_noop ("original writer"),
- gettext_noop ("name of the original lyricist or writer") },
+ gettext_noop ("name of the original lyricist or writer") },
/* 165 */
{ gettext_noop ("original release year"),
- gettext_noop ("year of the original release") },
+ gettext_noop ("year of the original release") },
{ gettext_noop ("original performer"),
- gettext_noop ("name of the original performer") },
+ gettext_noop ("name of the original performer") },
{ gettext_noop ("lyrics"),
- gettext_noop ("lyrics of the song or text description of vocal activities") },
+ gettext_noop (
+ "lyrics of the song or text description of vocal activities") },
{ gettext_noop ("popularity"),
- gettext_noop ("information about the file's popularity") },
+ gettext_noop ("information about the file's popularity") },
{ gettext_noop ("licensee"),
- gettext_noop ("name of the owner or licensee of the file") },
+ gettext_noop ("name of the owner or licensee of the file") },
/* 170 */
{ gettext_noop ("musician credit list"),
- gettext_noop ("names of contributing musicians") },
+ gettext_noop ("names of contributing musicians") },
{ gettext_noop ("mood"),
- gettext_noop ("keywords reflecting the mood of the piece") },
+ gettext_noop ("keywords reflecting the mood of the piece") },
{ gettext_noop ("subtitle"),
- gettext_noop ("subtitle of this part") },
+ gettext_noop ("subtitle of this part") },
{ gettext_noop ("display type"),
- gettext_noop ("what rendering method should be used to display this item") },
+ gettext_noop (
+ "what rendering method should be used to display this item") },
{ gettext_noop ("full data"),
- gettext_noop ("entry that contains the full, original binary data (not really meta data)") },
+ gettext_noop (
+ "entry that contains the full, original binary data (not really meta data)") },
/* 175 */
{ gettext_noop ("rating"),
gettext_noop ("rating of the content") },
@@ -437,9 +459,9 @@ static const struct MetaTypeDescription meta_type_descriptions[] = {
gettext_noop ("organization") },
{ gettext_noop ("ripper"), /* any difference to "encoded by"? */
gettext_noop ("ripper") },
- { gettext_noop ("producer"),
+ { gettext_noop ("producer"),
gettext_noop ("producer") },
- { gettext_noop ("group"),
+ { gettext_noop ("group"),
gettext_noop ("name of the group or band") },
/* 180 */
{ gettext_noop ("original filename"),
@@ -460,7 +482,8 @@ static const struct MetaTypeDescription meta_type_descriptions[] = {
{ gettext_noop ("bitrate"),
gettext_noop ("exact or average bitrate in bits/s") },
{ gettext_noop ("nominal bitrate"),
- gettext_noop ("nominal bitrate in bits/s. The actual bitrate might be different from this target bitrate.") },
+ gettext_noop (
+ "nominal bitrate in bits/s. The actual bitrate might be different from this target bitrate.") },
{ gettext_noop ("minimum bitrate"),
gettext_noop ("minimum bitrate in bits/s") },
/* 190 */
@@ -484,25 +507,32 @@ static const struct MetaTypeDescription meta_type_descriptions[] = {
{ gettext_noop ("reference level"),
gettext_noop ("reference level of track and album gain values") },
{ gettext_noop ("location name"),
- gettext_noop ("human readable descriptive location of where the media has been recorded or produced") },
+ gettext_noop (
+ "human readable descriptive location of where the media has been recorded or produced") },
/* 200 */
{ gettext_noop ("location elevation"),
- gettext_noop ("geo elevation of where the media has been recorded or produced in meters according to WGS84 (zero is average sea level)") },
+ gettext_noop (
+ "geo elevation of where the media has been recorded or produced in meters according to WGS84 (zero is average sea level)") },
{ gettext_noop ("location horizontal error"),
- gettext_noop ("represents the expected error on the horizontal positioning in meters") },
+ gettext_noop (
+ "represents the expected error on the horizontal positioning in meters") },
{ gettext_noop ("location movement speed"),
- gettext_noop ("speed of the capturing device when performing the capture. Represented in m/s") },
+ gettext_noop (
+ "speed of the capturing device when performing the capture. Represented in m/s") },
{ gettext_noop ("location movement direction"),
- gettext_noop ("indicates the movement direction of the device performing the capture of a media. It is represented as degrees in floating point representation, 0 means the geographic north, and increases clockwise") },
+ gettext_noop (
+ "indicates the movement direction of the device performing the capture of a media. It is represented as degrees in floating point representation, 0 means the geographic north, and increases clockwise") },
{ gettext_noop ("location capture direction"),
- gettext_noop ("indicates the direction the device is pointing to when capturing a media. It is represented as degrees in floating point representation, 0 means the geographic north, and increases clockwise") },
+ gettext_noop (
+ "indicates the direction the device is pointing to when capturing a media. It is represented as degrees in floating point representation, 0 means the geographic north, and increases clockwise") },
/* 205 */
{ gettext_noop ("show episode number"),
gettext_noop ("number of the episode within a season/show") },
{ gettext_noop ("show season number"),
gettext_noop ("number of the season of a show/series") },
{ gettext_noop ("grouping"),
- gettext_noop ("groups together media that are related and spans multiple tracks. An example are multiple pieces of a concerto") },
+ gettext_noop (
+ "groups together media that are related and spans multiple tracks. An example are multiple pieces of a concerto") },
{ gettext_noop ("device manufacturer"),
gettext_noop ("manufacturer of the device used to create the media") },
{ gettext_noop ("device model"),
@@ -552,7 +582,8 @@ static const struct MetaTypeDescription meta_type_descriptions[] = {
gettext_noop ("a preview of the file audio stream") },
{ gettext_noop ("narinfo"),
- gettext_noop ("file containing information about contents of a normalized archive (nar)") },
+ gettext_noop (
+ "file containing information about contents of a normalized archive (nar)") },
/* 230 */
{ gettext_noop ("nar"),
gettext_noop ("normalized archive") },
@@ -562,9 +593,10 @@ static const struct MetaTypeDescription meta_type_descriptions[] = {
};
/**
- * Total number of keyword types (for bounds-checking)
+ * Total number of keyword types (for bounds-checking)
*/
-#define HIGHEST_METATYPE_NUMBER (sizeof (meta_type_descriptions) / sizeof(*meta_type_descriptions))
+#define HIGHEST_METATYPE_NUMBER (sizeof (meta_type_descriptions) \
+ / sizeof(*meta_type_descriptions))
/**
diff --git a/src/main/extractor_plugin_main.c b/src/main/extractor_plugin_main.c
@@ -116,8 +116,8 @@ struct ProcessingContext
*/
static int64_t
plugin_env_seek (void *cls,
- int64_t pos,
- int whence)
+ int64_t pos,
+ int whence)
{
struct ProcessingContext *pc = cls;
struct SeekRequestMessage srm;
@@ -127,117 +127,118 @@ plugin_env_seek (void *cls,
uint16_t wval;
switch (whence)
+ {
+ case SEEK_CUR:
+ if ( (pos < 0) && (pc->read_position < -pos) )
{
- case SEEK_CUR:
- if ( (pos < 0) && (pc->read_position < - pos) )
- {
- LOG ("Invalid seek operation\n");
- return -1;
- }
- if ((pos > 0) && ((pc->read_position + pos < pc->read_position) ||
- (pc->read_position + pos > pc->file_size)))
- {
- LOG ("Invalid seek operation\n");
- return -1;
- }
- npos = (uint64_t) (pc->read_position + pos);
- wval = 0;
- break;
- case SEEK_END:
- if (pos > 0)
- {
- LOG ("Invalid seek operation\n");
- return -1;
- }
- if (UINT64_MAX == pc->file_size)
- {
- wval = 2;
- npos = (uint64_t) - pos;
- break;
- }
- pos = (int64_t) (pc->file_size + pos);
- /* fall-through! */
- case SEEK_SET:
- if ( (pos < 0) || (pc->file_size < pos) )
- {
- LOG ("Invalid seek operation\n");
- return -1;
- }
- npos = (uint64_t) pos;
- wval = 0;
+ LOG ("Invalid seek operation\n");
+ return -1;
+ }
+ if ((pos > 0) && ((pc->read_position + pos < pc->read_position) ||
+ (pc->read_position + pos > pc->file_size)))
+ {
+ LOG ("Invalid seek operation\n");
+ return -1;
+ }
+ npos = (uint64_t) (pc->read_position + pos);
+ wval = 0;
+ break;
+ case SEEK_END:
+ if (pos > 0)
+ {
+ LOG ("Invalid seek operation\n");
+ return -1;
+ }
+ if (UINT64_MAX == pc->file_size)
+ {
+ wval = 2;
+ npos = (uint64_t) -pos;
break;
- default:
+ }
+ pos = (int64_t) (pc->file_size + pos);
+ /* fall-through! */
+ case SEEK_SET:
+ if ( (pos < 0) || (pc->file_size < pos) )
+ {
LOG ("Invalid seek operation\n");
return -1;
}
+ npos = (uint64_t) pos;
+ wval = 0;
+ break;
+ default:
+ LOG ("Invalid seek operation\n");
+ return -1;
+ }
if ( (pc->shm_off <= npos) &&
(pc->shm_off + pc->shm_ready_bytes > npos) &&
(0 == wval) )
- {
- pc->read_position = npos;
- return (int64_t) npos;
- }
+ {
+ pc->read_position = npos;
+ return (int64_t) npos;
+ }
/* need to seek */
srm.opcode = MESSAGE_SEEK;
srm.reserved = 0;
srm.whence = wval;
srm.requested_bytes = pc->shm_map_size;
if (0 == wval)
- {
- if (srm.requested_bytes > pc->file_size - npos)
- srm.requested_bytes = pc->file_size - npos;
- }
+ {
+ if (srm.requested_bytes > pc->file_size - npos)
+ srm.requested_bytes = pc->file_size - npos;
+ }
else
- {
- srm.requested_bytes = npos;
- }
+ {
+ srm.requested_bytes = npos;
+ }
srm.file_offset = npos;
if (-1 == EXTRACTOR_write_all_ (pc->out, &srm, sizeof (srm)))
- {
- LOG ("Failed to send MESSAGE_SEEK\n");
- return -1;
- }
+ {
+ LOG ("Failed to send MESSAGE_SEEK\n");
+ return -1;
+ }
if (-1 ==
EXTRACTOR_read_all_ (pc->in,
- &reply, sizeof (reply)))
- {
- LOG ("Plugin `%s' failed to read response to MESSAGE_SEEK\n",
- pc->plugin->short_libname);
- return -1;
- }
+ &reply, sizeof (reply)))
+ {
+ LOG ("Plugin `%s' failed to read response to MESSAGE_SEEK\n",
+ pc->plugin->short_libname);
+ return -1;
+ }
if (MESSAGE_UPDATED_SHM != reply)
- {
- LOG ("Unexpected reply %d to seek\n", reply);
- return -1; /* was likely a MESSAGE_DISCARD_STATE */
- }
+ {
+ LOG ("Unexpected reply %d to seek\n", reply);
+ return -1; /* was likely a MESSAGE_DISCARD_STATE */
+ }
if (-1 == EXTRACTOR_read_all_ (pc->in, &um.reserved, sizeof (um) - 1))
- {
- LOG ("Failed to read MESSAGE_UPDATED_SHM\n");
- return -1;
- }
+ {
+ LOG ("Failed to read MESSAGE_UPDATED_SHM\n");
+ return -1;
+ }
pc->shm_off = um.shm_off;
pc->shm_ready_bytes = um.shm_ready_bytes;
pc->file_size = um.file_size;
if (2 == wval)
- {
- /* convert offset to be absolute from beginning of the file */
- npos = pc->file_size - npos;
- }
- if ( (pc->shm_off <= npos) &&
+ {
+ /* convert offset to be absolute from beginning of the file */
+ npos = pc->file_size - npos;
+ }
+ if ( (pc->shm_off <= npos) &&
((pc->shm_off + pc->shm_ready_bytes > npos) ||
- (pc->file_size == pc->shm_off)) )
- {
- pc->read_position = npos;
- return (int64_t) npos;
- }
+ (pc->file_size == pc->shm_off)) )
+ {
+ pc->read_position = npos;
+ return (int64_t) npos;
+ }
/* oops, serious missunderstanding, we asked to seek
and then were notified about a different position!? */
- LOG ("Plugin `%s' got invalid MESSAGE_UPDATED_SHM in response to my %d-seek (%llu not in %llu-%llu)\n",
- pc->plugin->short_libname,
- (int) wval,
- (unsigned long long) npos,
- (unsigned long long) pc->shm_off,
- (unsigned long long) pc->shm_off + pc->shm_ready_bytes);
+ LOG (
+ "Plugin `%s' got invalid MESSAGE_UPDATED_SHM in response to my %d-seek (%llu not in %llu-%llu)\n",
+ pc->plugin->short_libname,
+ (int) wval,
+ (unsigned long long) npos,
+ (unsigned long long) pc->shm_off,
+ (unsigned long long) pc->shm_off + pc->shm_ready_bytes);
return -1;
}
@@ -252,7 +253,7 @@ plugin_env_seek (void *cls,
*/
static ssize_t
plugin_env_read (void *cls,
- void **data,
+ void **data,
size_t count)
{
struct ProcessingContext *pc = cls;
@@ -266,10 +267,10 @@ plugin_env_read (void *cls,
(pc->read_position < pc->file_size)) ||
(pc->read_position < pc->shm_off) ) &&
(-1 == plugin_env_seek (pc, pc->read_position, SEEK_SET) ) )
- {
- LOG ("Failed to seek to satisfy read\n");
- return -1;
- }
+ {
+ LOG ("Failed to seek to satisfy read\n");
+ return -1;
+ }
if (pc->read_position + count > pc->shm_off + pc->shm_ready_bytes)
count = pc->shm_off + pc->shm_ready_bytes - pc->read_position;
dp = pc->shm;
@@ -313,12 +314,12 @@ plugin_env_get_size (void *cls)
*/
static int
plugin_env_send_proc (void *cls,
- const char *plugin_name,
- enum EXTRACTOR_MetaType type,
- enum EXTRACTOR_MetaFormat format,
- const char *data_mime_type,
- const char *data,
- size_t data_len)
+ const char *plugin_name,
+ enum EXTRACTOR_MetaType type,
+ enum EXTRACTOR_MetaFormat format,
+ const char *data_mime_type,
+ const char *data,
+ size_t data_len)
{
struct ProcessingContext *pc = cls;
struct MetaMessage mm;
@@ -340,32 +341,32 @@ plugin_env_send_proc (void *cls,
mm.mime_length = (uint16_t) mime_len;
mm.value_size = (uint32_t) data_len;
if ( (sizeof (mm) !=
- EXTRACTOR_write_all_ (pc->out,
- &mm, sizeof (mm))) ||
+ EXTRACTOR_write_all_ (pc->out,
+ &mm, sizeof (mm))) ||
(mime_len !=
- EXTRACTOR_write_all_ (pc->out,
- data_mime_type, mime_len)) ||
+ EXTRACTOR_write_all_ (pc->out,
+ data_mime_type, mime_len)) ||
(data_len !=
- EXTRACTOR_write_all_ (pc->out,
- data, data_len)) )
- {
- LOG ("Failed to send meta message\n");
- return 1;
- }
+ EXTRACTOR_write_all_ (pc->out,
+ data, data_len)) )
+ {
+ LOG ("Failed to send meta message\n");
+ return 1;
+ }
if (-1 ==
EXTRACTOR_read_all_ (pc->in,
- &reply, sizeof (reply)))
- {
- LOG ("Failed to read response to meta message\n");
- return 1;
- }
+ &reply, sizeof (reply)))
+ {
+ LOG ("Failed to read response to meta message\n");
+ return 1;
+ }
if (MESSAGE_DISCARD_STATE == reply)
return 1;
if (MESSAGE_CONTINUE_EXTRACTING != reply)
- {
- LOG ("Received unexpected reply to meta data: %d\n", reply);
- return 1;
- }
+ {
+ LOG ("Received unexpected reply to meta data: %d\n", reply);
+ return 1;
+ }
return 0;
}
@@ -382,34 +383,34 @@ handle_init_message (struct ProcessingContext *pc)
struct InitMessage init;
if (NULL != pc->shm)
- {
- LOG ("Cannot handle 'init' message, have already been initialized\n");
- return -1;
- }
+ {
+ LOG ("Cannot handle 'init' message, have already been initialized\n");
+ return -1;
+ }
if (sizeof (struct InitMessage) - 1
!= EXTRACTOR_read_all_ (pc->in,
- &init.reserved,
- sizeof (struct InitMessage) - 1))
- {
- LOG ("Failed to read 'init' message\n");
- return -1;
- }
+ &init.reserved,
+ sizeof (struct InitMessage) - 1))
+ {
+ LOG ("Failed to read 'init' message\n");
+ return -1;
+ }
if (init.shm_name_length > MAX_SHM_NAME)
- {
- LOG ("Invalid 'init' message\n");
- return -1;
- }
+ {
+ LOG ("Invalid 'init' message\n");
+ return -1;
+ }
{
char shm_name[init.shm_name_length + 1];
if (init.shm_name_length
- != EXTRACTOR_read_all_ (pc->in,
- shm_name,
- init.shm_name_length))
- {
- LOG ("Failed to read 'init' message\n");
- return -1;
- }
+ != EXTRACTOR_read_all_ (pc->in,
+ shm_name,
+ init.shm_name_length))
+ {
+ LOG ("Failed to read 'init' message\n");
+ return -1;
+ }
shm_name[init.shm_name_length] = '\0';
pc->shm_map_size = init.shm_map_size;
@@ -427,20 +428,20 @@ handle_init_message (struct ProcessingContext *pc)
#else
pc->shm_id = shm_open (shm_name, O_RDONLY, 0);
if (-1 == pc->shm_id)
- {
- LOG_STRERROR_FILE ("open", shm_name);
- return -1;
- }
+ {
+ LOG_STRERROR_FILE ("open", shm_name);
+ return -1;
+ }
pc->shm = mmap (NULL,
- pc->shm_map_size,
- PROT_READ,
- MAP_SHARED,
- pc->shm_id, 0);
+ pc->shm_map_size,
+ PROT_READ,
+ MAP_SHARED,
+ pc->shm_id, 0);
if ( ((void*) -1) == pc->shm)
- {
- LOG_STRERROR_FILE ("mmap", shm_name);
- return -1;
- }
+ {
+ LOG_STRERROR_FILE ("mmap", shm_name);
+ return -1;
+ }
#endif
}
return 0;
@@ -462,12 +463,12 @@ handle_start_message (struct ProcessingContext *pc)
if (sizeof (struct StartMessage) - 1
!= EXTRACTOR_read_all_ (pc->in,
- &start.reserved,
- sizeof (struct StartMessage) - 1))
- {
- LOG ("Failed to read 'start' message\n");
- return -1;
- }
+ &start.reserved,
+ sizeof (struct StartMessage) - 1))
+ {
+ LOG ("Failed to read 'start' message\n");
+ return -1;
+ }
pc->shm_ready_bytes = start.shm_ready_bytes;
pc->file_size = start.file_size;
pc->read_position = 0;
@@ -481,22 +482,22 @@ handle_start_message (struct ProcessingContext *pc)
pc->plugin->extract_method (&ec);
done = MESSAGE_DONE;
if (-1 == EXTRACTOR_write_all_ (pc->out, &done, sizeof (done)))
- {
- LOG ("Failed to write 'done' message\n");
- return -1;
- }
+ {
+ LOG ("Failed to write 'done' message\n");
+ return -1;
+ }
if ( (NULL != pc->plugin->specials) &&
(NULL != strstr (pc->plugin->specials, "force-kill")) )
- {
- /* we're required to die after each file since this
- plugin only supports a single file at a time */
-#if !WINDOWS
- fsync (pc->out);
+ {
+ /* we're required to die after each file since this
+ plugin only supports a single file at a time */
+#if ! WINDOWS
+ fsync (pc->out);
#else
- _commit (pc->out);
+ _commit (pc->out);
#endif
- _exit (0);
- }
+ _exit (0);
+ }
return 0;
}
@@ -511,43 +512,43 @@ static void
process_requests (struct ProcessingContext *pc)
{
while (1)
+ {
+ unsigned char code;
+
+ if (1 != EXTRACTOR_read_all_ (pc->in, &code, 1))
{
- unsigned char code;
-
- if (1 != EXTRACTOR_read_all_ (pc->in, &code, 1))
- {
- LOG ("Failed to read next request\n");
- break;
- }
- switch (code)
- {
- case MESSAGE_INIT_STATE:
- if (0 != handle_init_message (pc))
- {
- LOG ("Failure to handle INIT\n");
- return;
- }
- break;
- case MESSAGE_EXTRACT_START:
- if (0 != handle_start_message (pc))
- {
- LOG ("Failure to handle START\n");
- return;
- }
- break;
- case MESSAGE_UPDATED_SHM:
- LOG ("Illegal message\n");
- /* not allowed here, we're not waiting for SHM to move! */
- return;
- case MESSAGE_DISCARD_STATE:
- /* odd, we're already in the start state... */
- continue;
- default:
- LOG ("Received invalid messag %d\n", (int) code);
- /* error, unexpected message */
- return;
- }
+ LOG ("Failed to read next request\n");
+ break;
}
+ switch (code)
+ {
+ case MESSAGE_INIT_STATE:
+ if (0 != handle_init_message (pc))
+ {
+ LOG ("Failure to handle INIT\n");
+ return;
+ }
+ break;
+ case MESSAGE_EXTRACT_START:
+ if (0 != handle_start_message (pc))
+ {
+ LOG ("Failure to handle START\n");
+ return;
+ }
+ break;
+ case MESSAGE_UPDATED_SHM:
+ LOG ("Illegal message\n");
+ /* not allowed here, we're not waiting for SHM to move! */
+ return;
+ case MESSAGE_DISCARD_STATE:
+ /* odd, we're already in the start state... */
+ continue;
+ default:
+ LOG ("Received invalid messag %d\n", (int) code);
+ /* error, unexpected message */
+ return;
+ }
+ }
}
@@ -560,7 +561,7 @@ process_requests (struct ProcessingContext *pc)
*/
static void
open_dev_null (int target_fd,
- int flags)
+ int flags)
{
int fd;
@@ -570,10 +571,10 @@ open_dev_null (int target_fd,
fd = open ("\\\\?\\NUL", flags);
#endif
if (-1 == fd)
- {
- LOG_STRERROR_FILE ("open", "/dev/null");
- return; /* good luck */
- }
+ {
+ LOG_STRERROR_FILE ("open", "/dev/null");
+ return; /* good luck */
+ }
if (fd == target_fd)
return; /* already done */
if (-1 == dup2 (fd, target_fd))
@@ -598,32 +599,32 @@ open_dev_null (int target_fd,
*/
void
EXTRACTOR_plugin_main_ (struct EXTRACTOR_PluginList *plugin,
- int in, int out)
+ int in, int out)
{
struct ProcessingContext pc;
if (0 != EXTRACTOR_plugin_load_ (plugin))
- {
+ {
#if DEBUG
- fprintf (stderr, "Plugin `%s' failed to load!\n",
- plugin->short_libname);
+ fprintf (stderr, "Plugin `%s' failed to load!\n",
+ plugin->short_libname);
#endif
- return;
- }
+ return;
+ }
if ( (NULL != plugin->specials) &&
(NULL != strstr (plugin->specials, "close-stderr")))
- {
- if (0 != close (2))
- LOG_STRERROR ("close");
- open_dev_null (2, O_WRONLY);
- }
+ {
+ if (0 != close (2))
+ LOG_STRERROR ("close");
+ open_dev_null (2, O_WRONLY);
+ }
if ( (NULL != plugin->specials) &&
(NULL != strstr (plugin->specials, "close-stdout")))
- {
- if (0 != close (1))
- LOG_STRERROR ("close");
- open_dev_null (1, O_WRONLY);
- }
+ {
+ if (0 != close (1))
+ LOG_STRERROR ("close");
+ open_dev_null (1, O_WRONLY);
+ }
pc.plugin = plugin;
pc.in = in;
pc.out = out;
@@ -643,10 +644,10 @@ EXTRACTOR_plugin_main_ (struct EXTRACTOR_PluginList *plugin,
(((void*) 1) != pc.shm) )
munmap (pc.shm, pc.shm_map_size);
if (-1 != pc.shm_id)
- {
- if (0 != close (pc.shm_id))
- LOG_STRERROR ("close");
- }
+ {
+ if (0 != close (pc.shm_id))
+ LOG_STRERROR ("close");
+ }
#endif
}
@@ -668,43 +669,43 @@ read_plugin_data (int fd)
// FIXME: check for errors from 'EXTRACTOR_read_all_'!
if (NULL == (ret = malloc (sizeof (struct EXTRACTOR_PluginList))))
- {
- LOG_STRERROR ("malloc");
- return NULL;
- }
+ {
+ LOG_STRERROR ("malloc");
+ return NULL;
+ }
memset (ret, 0, sizeof (struct EXTRACTOR_PluginList));
/*GetSystemInfo (&si);
ret->allocation_granularity = si.dwAllocationGranularity;*/
EXTRACTOR_read_all_ (fd, &i, sizeof (size_t));
if (NULL == (ret->libname = malloc (i)))
- {
- free (ret);
- return NULL;
- }
+ {
+ free (ret);
+ return NULL;
+ }
EXTRACTOR_read_all_ (fd, ret->libname, i);
ret->libname[i - 1] = '\0';
EXTRACTOR_read_all_ (fd, &i, sizeof (size_t));
if (NULL == (ret->short_libname = malloc (i)))
- {
- free (ret->libname);
- free (ret);
- return NULL;
- }
+ {
+ free (ret->libname);
+ free (ret);
+ return NULL;
+ }
EXTRACTOR_read_all_ (fd, ret->short_libname, i);
ret->short_libname[i - 1] = '\0';
EXTRACTOR_read_all_ (fd, &i, sizeof (size_t));
if (0 == i)
- {
- ret->plugin_options = NULL;
- return ret;
- }
+ {
+ ret->plugin_options = NULL;
+ return ret;
+ }
if (NULL == (ret->plugin_options = malloc (i)))
- {
- free (ret->short_libname);
- free (ret->libname);
- free (ret);
- return NULL;
- }
+ {
+ free (ret->short_libname);
+ free (ret->libname);
+ free (ret);
+ return NULL;
+ }
EXTRACTOR_read_all_ (fd, ret->plugin_options, i);
ret->plugin_options[i - 1] = '\0';
return ret;
@@ -716,9 +717,9 @@ read_plugin_data (int fd)
*/
void CALLBACK
RundllEntryPoint (HWND hwnd,
- HINSTANCE hinst,
- LPSTR lpszCmdLine,
- int nCmdShow)
+ HINSTANCE hinst,
+ LPSTR lpszCmdLine,
+ int nCmdShow)
{
struct EXTRACTOR_PluginList *plugin;
intptr_t in_h;
@@ -732,11 +733,11 @@ RundllEntryPoint (HWND hwnd,
setmode (in, _O_BINARY);
setmode (out, _O_BINARY);
if (NULL == (plugin = read_plugin_data (in)))
- {
- close (in);
- close (out);
- return;
- }
+ {
+ close (in);
+ close (out);
+ return;
+ }
EXTRACTOR_plugin_main_ (plugin, in, out);
close (in);
close (out);
@@ -745,8 +746,7 @@ RundllEntryPoint (HWND hwnd,
* called by the OS) or call FreeLibrary() on it directly or
* indirectly.
* By terminating here we alleviate that problem.
- */
- TerminateProcess (GetCurrentProcess (), 0);
+ */TerminateProcess (GetCurrentProcess (), 0);
}
@@ -755,9 +755,9 @@ RundllEntryPoint (HWND hwnd,
*/
void CALLBACK
RundllEntryPointA (HWND hwnd,
- HINSTANCE hinst,
- LPSTR lpszCmdLine,
- int nCmdShow)
+ HINSTANCE hinst,
+ LPSTR lpszCmdLine,
+ int nCmdShow)
{
return RundllEntryPoint (hwnd, hinst, lpszCmdLine, nCmdShow);
}
diff --git a/src/main/extractor_plugin_main.h b/src/main/extractor_plugin_main.h
@@ -37,7 +37,7 @@
* @param out stream to write to
*/
void
-EXTRACTOR_plugin_main_ (struct EXTRACTOR_PluginList *plugin,
- int in, int out);
+ EXTRACTOR_plugin_main_ (struct EXTRACTOR_PluginList *plugin,
+ int in, int out);
#endif
diff --git a/src/main/extractor_plugins.c b/src/main/extractor_plugins.c
@@ -39,9 +39,9 @@
*/
static void *
get_symbol_with_prefix (void *lib_handle,
- const char *template,
- const char *prefix,
- const char **options)
+ const char *template,
+ const char *prefix,
+ const char **options)
{
char *name;
void *symbol;
@@ -56,55 +56,55 @@ get_symbol_with_prefix (void *lib_handle,
return NULL;
sym_name++;
if (NULL == (sym = strdup (sym_name)))
- {
- LOG_STRERROR ("strdup");
- return NULL;
- }
+ {
+ LOG_STRERROR ("strdup");
+ return NULL;
+ }
if (NULL != (dot = strchr (sym, '.')))
*dot = '\0';
- if (NULL == (name = malloc(strlen(sym) + strlen(template) + 1)))
- {
- free (sym);
- return NULL;
- }
- sprintf(name,
- template,
- sym);
+ if (NULL == (name = malloc (strlen (sym) + strlen (template) + 1)))
+ {
+ free (sym);
+ return NULL;
+ }
+ sprintf (name,
+ template,
+ sym);
/* try without '_' first */
symbol = lt_dlsym (lib_handle, name + 1);
if (NULL == symbol)
+ {
+ /* now try with the '_' */
+ char *first_error = strdup (lt_dlerror ());
+ symbol = lt_dlsym (lib_handle, name);
+ if (NULL == symbol)
{
- /* now try with the '_' */
- char *first_error = strdup (lt_dlerror ());
- symbol = lt_dlsym (lib_handle, name);
- if (NULL == symbol)
- {
- LOG ("Resolving symbol `%s' failed, "
- "so I tried `%s', but that failed also. Errors are: "
- "`%s' and `%s'.\n",
- name+1,
- name,
- first_error == NULL ? "out of memory" : first_error,
- lt_dlerror ());
- }
- if (NULL != first_error)
- free (first_error);
+ LOG ("Resolving symbol `%s' failed, "
+ "so I tried `%s', but that failed also. Errors are: "
+ "`%s' and `%s'.\n",
+ name + 1,
+ name,
+ first_error == NULL ? "out of memory" : first_error,
+ lt_dlerror ());
}
+ if (NULL != first_error)
+ free (first_error);
+ }
if ( (NULL != symbol) &&
(NULL != options) )
- {
- /* get special options */
- sprintf (name,
- "_EXTRACTOR_%s_options",
- sym);
- /* try without '_' first */
- opt_fun = lt_dlsym (lib_handle, name + 1);
- if (NULL == opt_fun)
- opt_fun = lt_dlsym (lib_handle, name);
- if (NULL != opt_fun)
- *options = opt_fun ();
- }
+ {
+ /* get special options */
+ sprintf (name,
+ "_EXTRACTOR_%s_options",
+ sym);
+ /* try without '_' first */
+ opt_fun = lt_dlsym (lib_handle, name + 1);
+ if (NULL == opt_fun)
+ opt_fun = lt_dlsym (lib_handle, name);
+ if (NULL != opt_fun)
+ *options = opt_fun ();
+ }
free (sym);
free (name);
return symbol;
@@ -131,12 +131,12 @@ EXTRACTOR_plugin_load_ (struct EXTRACTOR_PluginList *plugin)
if (NULL == plugin->libname)
plugin->libname = EXTRACTOR_find_plugin_ (plugin->short_libname);
if (NULL == plugin->libname)
- {
- LOG ("Failed to find plugin `%s'\n",
- plugin->short_libname);
- plugin->flags = EXTRACTOR_OPTION_DISABLED;
- return -1;
- }
+ {
+ LOG ("Failed to find plugin `%s'\n",
+ plugin->short_libname);
+ plugin->flags = EXTRACTOR_OPTION_DISABLED;
+ return -1;
+ }
lt_dladvise_init (&advise);
lt_dladvise_ext (&advise);
lt_dladvise_local (&advise);
@@ -144,51 +144,51 @@ EXTRACTOR_plugin_load_ (struct EXTRACTOR_PluginList *plugin)
wlibname[0] = L'\0';
llibname[0] = '\0';
if ( (MultiByteToWideChar (CP_UTF8, 0, plugin->libname, -1,
- wlibname, sizeof (wlibname)) <= 0) ||
+ wlibname, sizeof (wlibname)) <= 0) ||
(WideCharToMultiByte (CP_ACP, 0, wlibname, -1,
- llibname, sizeof (llibname), NULL, NULL) < 0) )
- {
- LOG ("Loading `%s' plugin failed: %s\n",
- plugin->short_libname,
- "can't convert plugin name to local encoding");
- free (plugin->libname);
- plugin->libname = NULL;
- plugin->flags = EXTRACTOR_OPTION_DISABLED;
- return -1;
+ llibname, sizeof (llibname), NULL, NULL) < 0) )
+ {
+ LOG ("Loading `%s' plugin failed: %s\n",
+ plugin->short_libname,
+ "can't convert plugin name to local encoding");
+ free (plugin->libname);
+ plugin->libname = NULL;
+ plugin->flags = EXTRACTOR_OPTION_DISABLED;
+ return -1;
}
plugin->libraryHandle = lt_dlopenadvise (llibname,
- advise);
+ advise);
#else
plugin->libraryHandle = lt_dlopenadvise (plugin->libname,
- advise);
+ advise);
#endif
lt_dladvise_destroy (&advise);
if (NULL == plugin->libraryHandle)
- {
- LOG ("Loading `%s' plugin failed (using name `%s'): %s\n",
- plugin->short_libname,
- plugin->libname,
- lt_dlerror ());
- free (plugin->libname);
- plugin->libname = NULL;
- plugin->flags = EXTRACTOR_OPTION_DISABLED;
- return -1;
- }
+ {
+ LOG ("Loading `%s' plugin failed (using name `%s'): %s\n",
+ plugin->short_libname,
+ plugin->libname,
+ lt_dlerror ());
+ free (plugin->libname);
+ plugin->libname = NULL;
+ plugin->flags = EXTRACTOR_OPTION_DISABLED;
+ return -1;
+ }
plugin->extract_method = get_symbol_with_prefix (plugin->libraryHandle,
- "_EXTRACTOR_%s_extract_method",
- plugin->libname,
- &plugin->specials);
+ "_EXTRACTOR_%s_extract_method",
+ plugin->libname,
+ &plugin->specials);
if (NULL == plugin->extract_method)
- {
- LOG ("Resolving `extract' method of plugin `%s' failed: %s\n",
- plugin->short_libname,
- lt_dlerror ());
- lt_dlclose (plugin->libraryHandle);
- free (plugin->libname);
- plugin->libname = NULL;
- plugin->flags = EXTRACTOR_OPTION_DISABLED;
- return -1;
- }
+ {
+ LOG ("Resolving `extract' method of plugin `%s' failed: %s\n",
+ plugin->short_libname,
+ lt_dlerror ());
+ lt_dlclose (plugin->libraryHandle);
+ free (plugin->libname);
+ plugin->libname = NULL;
+ plugin->flags = EXTRACTOR_OPTION_DISABLED;
+ return -1;
+ }
return 0;
}
@@ -204,9 +204,9 @@ EXTRACTOR_plugin_load_ (struct EXTRACTOR_PluginList *plugin)
*/
struct EXTRACTOR_PluginList *
EXTRACTOR_plugin_add (struct EXTRACTOR_PluginList *prev,
- const char *library,
- const char *options,
- enum EXTRACTOR_Options flags)
+ const char *library,
+ const char *options,
+ enum EXTRACTOR_Options flags)
{
struct EXTRACTOR_PluginList *plugin;
struct EXTRACTOR_PluginList *pos;
@@ -214,22 +214,23 @@ EXTRACTOR_plugin_add (struct EXTRACTOR_PluginList *prev,
for (pos = prev; NULL != pos; pos = pos->next)
if (0 == strcmp (pos->short_libname, library))
- return prev; /* no change, library already loaded */
- if (NULL == (libname = EXTRACTOR_find_plugin_ (library)))
- {
- LOG ("Could not load plugin `%s'\n",
- library);
return prev;
- }
+ /* no change, library already loaded */
+ if (NULL == (libname = EXTRACTOR_find_plugin_ (library)))
+ {
+ LOG ("Could not load plugin `%s'\n",
+ library);
+ return prev;
+ }
if (NULL == (plugin = malloc (sizeof (struct EXTRACTOR_PluginList))))
return prev;
memset (plugin, 0, sizeof (struct EXTRACTOR_PluginList));
plugin->next = prev;
if (NULL == (plugin->short_libname = strdup (library)))
- {
- free (plugin);
- return NULL;
- }
+ {
+ free (plugin);
+ return NULL;
+ }
plugin->libname = libname;
plugin->flags = flags;
if (NULL != options)
@@ -258,8 +259,8 @@ EXTRACTOR_plugin_add (struct EXTRACTOR_PluginList *prev,
*/
struct EXTRACTOR_PluginList *
EXTRACTOR_plugin_add_config (struct EXTRACTOR_PluginList *prev,
- const char *config,
- enum EXTRACTOR_Options flags)
+ const char *config,
+ enum EXTRACTOR_Options flags)
{
char *cpy;
size_t pos;
@@ -276,55 +277,55 @@ EXTRACTOR_plugin_add_config (struct EXTRACTOR_PluginList *prev,
last = 0;
lastconf = 0;
while (pos < len)
+ {
+ while ( (':' != cpy[pos]) &&
+ ('\0' != cpy[pos]) &&
+ ('(' != cpy[pos]) )
+ pos++;
+ switch (cpy[pos])
{
- while ( (':' != cpy[pos]) &&
- ('\0' != cpy[pos]) &&
- ('(' != cpy[pos]) )
- pos++;
- switch (cpy[pos])
- {
- case '(':
- cpy[pos++] = '\0'; /* replace '(' by termination */
- lastconf = pos; /* start config from here, after (. */
- while ( ('\0' != cpy[pos]) &&
- (')' != cpy[pos]))
- pos++; /* config until ) or EOS. */
- if (')' == cpy[pos])
- {
- cpy[pos++] = '\0'; /* write end of config here. */
- while ( (':' != cpy[pos]) &&
- ('\0' != cpy[pos]) )
- pos++; /* forward until real end of string found. */
- cpy[pos++] = '\0';
- }
- else
- {
- cpy[pos++] = '\0'; /* end of string. */
- }
- break;
- case ':':
- case '\0':
- lastconf = -1; /* NULL config when no (). */
- cpy[pos++] = '\0'; /* replace ':' by termination */
- break;
- default:
- ABORT ();
- }
- if ('-' == cpy[last])
- {
- last++;
- prev = EXTRACTOR_plugin_remove (prev,
- &cpy[last]);
- }
+ case '(':
+ cpy[pos++] = '\0'; /* replace '(' by termination */
+ lastconf = pos; /* start config from here, after (. */
+ while ( ('\0' != cpy[pos]) &&
+ (')' != cpy[pos]))
+ pos++; /* config until ) or EOS. */
+ if (')' == cpy[pos])
+ {
+ cpy[pos++] = '\0'; /* write end of config here. */
+ while ( (':' != cpy[pos]) &&
+ ('\0' != cpy[pos]) )
+ pos++; /* forward until real end of string found. */
+ cpy[pos++] = '\0';
+ }
else
- {
- prev = EXTRACTOR_plugin_add (prev,
- &cpy[last],
- (-1 != lastconf) ? &cpy[lastconf] : NULL,
- flags);
- }
- last = pos;
+ {
+ cpy[pos++] = '\0'; /* end of string. */
+ }
+ break;
+ case ':':
+ case '\0':
+ lastconf = -1; /* NULL config when no (). */
+ cpy[pos++] = '\0'; /* replace ':' by termination */
+ break;
+ default:
+ ABORT ();
}
+ if ('-' == cpy[last])
+ {
+ last++;
+ prev = EXTRACTOR_plugin_remove (prev,
+ &cpy[last]);
+ }
+ else
+ {
+ prev = EXTRACTOR_plugin_add (prev,
+ &cpy[last],
+ (-1 != lastconf) ? &cpy[lastconf] : NULL,
+ flags);
+ }
+ last = pos;
+ }
free (cpy);
return prev;
}
@@ -339,7 +340,7 @@ EXTRACTOR_plugin_add_config (struct EXTRACTOR_PluginList *prev,
*/
struct EXTRACTOR_PluginList *
EXTRACTOR_plugin_remove (struct EXTRACTOR_PluginList *prev,
- const char *library)
+ const char *library)
{
struct EXTRACTOR_PluginList *pos;
struct EXTRACTOR_PluginList *first;
@@ -347,17 +348,17 @@ EXTRACTOR_plugin_remove (struct EXTRACTOR_PluginList *prev,
pos = prev;
first = prev;
while ( (NULL != pos) &&
- (0 != strcmp (pos->short_libname, library)) )
- {
- prev = pos;
- pos = pos->next;
- }
+ (0 != strcmp (pos->short_libname, library)) )
+ {
+ prev = pos;
+ pos = pos->next;
+ }
if (NULL == pos)
- {
- LOG ("Unloading plugin `%s' failed!\n",
- library);
- return first;
- }
+ {
+ LOG ("Unloading plugin `%s' failed!\n",
+ library);
+ return first;
+ }
/* found, close library */
if (first == pos)
first = pos->next;
@@ -374,7 +375,7 @@ EXTRACTOR_plugin_remove (struct EXTRACTOR_PluginList *prev,
free (pos->libname);
free (pos->plugin_options);
if (NULL != pos->libraryHandle)
- lt_dlclose (pos->libraryHandle);
+ lt_dlclose (pos->libraryHandle);
free (pos);
return first;
}
diff --git a/src/main/extractor_plugins.h b/src/main/extractor_plugins.h
@@ -59,7 +59,7 @@ struct EXTRACTOR_PluginList
* Short name of the plugin (i.e., 'foo')
*/
char *short_libname;
-
+
/**
* Pointer to the function used for meta data extraction.
*/
diff --git a/src/main/extractor_plugpath.c b/src/main/extractor_plugpath.c
@@ -41,7 +41,7 @@
* @param path a directory path
*/
typedef void (*EXTRACTOR_PathProcessor) (void *cls,
- const char *path);
+ const char *path);
/**
@@ -51,7 +51,7 @@ typedef void (*EXTRACTOR_PathProcessor) (void *cls,
* @return NULL if 'in' is NULL, otherwise 'in' with '/bin/' removed
*/
static char *
-cut_bin (char * in)
+cut_bin (char *in)
{
size_t p;
@@ -60,21 +60,21 @@ cut_bin (char * in)
p = strlen (in);
if (p < 4)
return in;
- if ( ('/' == in[p-1]) ||
- ('\\' == in[p-1]) )
+ if ( ('/' == in[p - 1]) ||
+ ('\\' == in[p - 1]) )
in[--p] = '\0';
- if (0 == strcmp (&in[p-4],
- "/bin"))
- {
- in[p-4] = '\0';
- p -= 4;
- }
- else if (0 == strcmp (&in[p-4],
- "\\bin"))
- {
- in[p-4] = '\0';
- p -= 4;
- }
+ if (0 == strcmp (&in[p - 4],
+ "/bin"))
+ {
+ in[p - 4] = '\0';
+ p -= 4;
+ }
+ else if (0 == strcmp (&in[p - 4],
+ "\\bin"))
+ {
+ in[p - 4] = '\0';
+ p -= 4;
+ }
return in;
}
@@ -100,60 +100,62 @@ get_path_from_proc_exe ()
FILE *f;
snprintf (fn,
- sizeof (fn),
- "/proc/%u/maps",
- getpid ());
+ sizeof (fn),
+ "/proc/%u/maps",
+ getpid ());
if (NULL != (f = FOPEN (fn, "r")))
+ {
+ while (NULL != fgets (line, 1024, f))
{
- while (NULL != fgets (line, 1024, f))
- {
- if ( (1 == sscanf (line,
- "%*x-%*x %*c%*c%*c%*c %*x %*2x:%*2x %*u%*[ ]%s",
- dir)) &&
- (NULL != (lestr = strstr (dir,
- "libextractor")) ) )
- {
- lestr[0] = '\0';
- fclose (f);
- return strdup (dir);
- }
- }
- fclose (f);
+ if ( (1 == sscanf (line,
+ "%*x-%*x %*c%*c%*c%*c %*x %*2x:%*2x %*u%*[ ]%s",
+ dir)) &&
+ (NULL != (lestr = strstr (dir,
+ "libextractor")) ) )
+ {
+ lestr[0] = '\0';
+ fclose (f);
+ return strdup (dir);
+ }
}
+ fclose (f);
+ }
snprintf (fn,
- sizeof (fn),
- "/proc/%u/exe",
- getpid ());
+ sizeof (fn),
+ "/proc/%u/exe",
+ getpid ());
if (NULL == (lnk = malloc (1029))) /* 1024 + 6 for "/lib/" catenation */
return NULL;
size = readlink (fn, lnk, 1023);
if ( (size <= 0) || (size >= 1024) )
- {
- free (lnk);
- return NULL;
- }
+ {
+ free (lnk);
+ return NULL;
+ }
lnk[size] = '\0';
while ( ('/' != lnk[size]) &&
- (size > 0) )
+ (size > 0) )
size--;
if ( (size < 4) ||
- ('/' != lnk[size-4]) )
- {
- /* not installed in "/bin/" -- binary path probably useless */
- free (lnk);
- return NULL;
- }
+ ('/' != lnk[size - 4]) )
+ {
+ /* not installed in "/bin/" -- binary path probably useless */
+ free (lnk);
+ return NULL;
+ }
lnk[size] = '\0';
lnk = cut_bin (lnk);
- if (NULL == (ret = realloc (lnk, strlen(lnk) + 6)))
- {
- LOG_STRERROR ("realloc");
- free (lnk);
- return NULL;
- }
+ if (NULL == (ret = realloc (lnk, strlen (lnk) + 6)))
+ {
+ LOG_STRERROR ("realloc");
+ free (lnk);
+ return NULL;
+ }
strcat (ret, "/lib/"); /* guess "lib/" as the library dir */
return ret;
}
+
+
#endif
@@ -162,8 +164,8 @@ static HMODULE le_dll = NULL;
BOOL WINAPI
DllMain (HINSTANCE hinstDLL,
- DWORD fdwReason,
- LPVOID lpvReserved)
+ DWORD fdwReason,
+ LPVOID lpvReserved)
{
switch (fdwReason)
{
@@ -175,6 +177,7 @@ DllMain (HINSTANCE hinstDLL,
return TRUE;
}
+
/**
* Try to determine path with win32-specific function
*/
@@ -190,20 +193,22 @@ get_path_from_module_filename ()
GetModuleFileName (le_dll, path, 4096);
idx = path + strlen (path);
while ( (idx > path) &&
- ('\\' != *idx) &&
- ('/' != *idx) )
+ ('\\' != *idx) &&
+ ('/' != *idx) )
idx--;
*idx = '\0';
path = cut_bin (path);
- if (NULL == (ret = realloc (path, strlen(path) + 6)))
- {
- LOG_STRERROR ("realloc");
- free (path);
- return NULL;
- }
+ if (NULL == (ret = realloc (path, strlen (path) + 6)))
+ {
+ LOG_STRERROR ("realloc");
+ free (path);
+ return NULL;
+ }
strcat (ret, "/lib/"); /* guess "lib/" as the library dir */
return ret;
}
+
+
#endif
@@ -239,8 +244,8 @@ get_path_from_NSGetExecutablePath ()
path = NULL;
if (NULL == (func =
- (MyNSGetExecutablePathProto) dlsym (RTLD_DEFAULT,
- "_NSGetExecutablePath")))
+ (MyNSGetExecutablePathProto) dlsym (RTLD_DEFAULT,
+ "_NSGetExecutablePath")))
return NULL;
path = &zero;
len = 0;
@@ -249,10 +254,10 @@ get_path_from_NSGetExecutablePath ()
if (0 == len)
return NULL;
if (NULL == (path = malloc (len)))
- {
- LOG_STRERROR ("malloc");
- return NULL;
- }
+ {
+ LOG_STRERROR ("malloc");
+ return NULL;
+ }
if (0 != func (path, &len))
{
free (path);
@@ -267,9 +272,9 @@ get_path_from_NSGetExecutablePath ()
path = cut_bin (path);
if (NULL == (ret = realloc (path, strlen (path) + 5)))
{
- LOG_STRERROR ("realloc");
- free (path);
- return NULL;
+ LOG_STRERROR ("realloc");
+ free (path);
+ return NULL;
}
strcat (ret, "/lib/");
return ret;
@@ -292,26 +297,28 @@ get_path_from_dyld_image ()
c = _dyld_image_count ();
for (i = 0; i < c; i++)
+ {
+ if (((void *) _dyld_get_image_header (i)) != (void *) &_mh_dylib_header)
+ continue;
+ path = _dyld_get_image_name (i);
+ if ( (NULL == path) || (0 == strlen (path)) )
+ continue;
+ if (NULL == (p = strdup (path)))
{
- if (((void *) _dyld_get_image_header (i)) != (void *) &_mh_dylib_header)
- continue;
- path = _dyld_get_image_name (i);
- if ( (NULL == path) || (0 == strlen (path)) )
- continue;
- if (NULL == (p = strdup (path)))
- {
- LOG_STRERROR ("strdup");
- return NULL;
- }
- s = p + strlen (p);
- while ( (s > p) && ('/' != *s) )
- s--;
- s++;
- *s = '\0';
- return p;
+ LOG_STRERROR ("strdup");
+ return NULL;
}
+ s = p + strlen (p);
+ while ( (s > p) && ('/' != *s) )
+ s--;
+ s++;
+ *s = '\0';
+ return p;
+ }
return NULL;
}
+
+
#endif
@@ -322,7 +329,7 @@ get_path_from_dyld_image ()
* @return path to binary, NULL if not found
*/
static char *
-get_path_from_PATH()
+get_path_from_PATH ()
{
struct stat sbuf;
char *path;
@@ -335,61 +342,61 @@ get_path_from_PATH()
if (NULL == (p = getenv ("PATH")))
return NULL;
if (NULL == (path = strdup (p))) /* because we write on it */
- {
- LOG_STRERROR ("strdup");
- return NULL;
- }
+ {
+ LOG_STRERROR ("strdup");
+ return NULL;
+ }
if (NULL == (buf = malloc (strlen (path) + 20)))
- {
- LOG_STRERROR ("malloc");
- free (path);
- return NULL;
- }
+ {
+ LOG_STRERROR ("malloc");
+ free (path);
+ return NULL;
+ }
pos = path;
- while (NULL != (end = strchr(pos, ':')))
- {
- *end = '\0';
- sprintf (buf, "%s/%s", pos, "extract");
- if (0 == stat(buf, &sbuf))
- {
- free (buf);
- if (NULL == (pos = strdup (pos)))
- {
- LOG_STRERROR ("strdup");
- free (path);
- return NULL;
- }
- free (path);
- pos = cut_bin (pos);
- if (NULL == (ret = realloc (pos, strlen (pos) + 6)))
- {
- LOG_STRERROR ("realloc");
- free (pos);
- return NULL;
- }
- strcat (ret, "/lib/");
- return ret;
- }
- pos = end + 1;
- }
- sprintf (buf, "%s/%s", pos, "extract");
- if (0 == stat (buf, &sbuf))
+ while (NULL != (end = strchr (pos, ':')))
+ {
+ *end = '\0';
+ sprintf (buf, "%s/%s", pos, "extract");
+ if (0 == stat (buf, &sbuf))
{
- pos = strdup (pos);
free (buf);
+ if (NULL == (pos = strdup (pos)))
+ {
+ LOG_STRERROR ("strdup");
+ free (path);
+ return NULL;
+ }
free (path);
- if (NULL == pos)
- return NULL;
pos = cut_bin (pos);
if (NULL == (ret = realloc (pos, strlen (pos) + 6)))
- {
- LOG_STRERROR ("realloc");
- free (pos);
- return NULL;
- }
+ {
+ LOG_STRERROR ("realloc");
+ free (pos);
+ return NULL;
+ }
strcat (ret, "/lib/");
return ret;
}
+ pos = end + 1;
+ }
+ sprintf (buf, "%s/%s", pos, "extract");
+ if (0 == stat (buf, &sbuf))
+ {
+ pos = strdup (pos);
+ free (buf);
+ free (path);
+ if (NULL == pos)
+ return NULL;
+ pos = cut_bin (pos);
+ if (NULL == (ret = realloc (pos, strlen (pos) + 6)))
+ {
+ LOG_STRERROR ("realloc");
+ free (pos);
+ return NULL;
+ }
+ strcat (ret, "/lib/");
+ return ret;
+ }
free (buf);
free (path);
return NULL;
@@ -405,7 +412,7 @@ get_path_from_PATH()
*/
static char *
append_to_dir (const char *path,
- const char *fname)
+ const char *fname)
{
char *ret;
size_t slen;
@@ -414,31 +421,31 @@ append_to_dir (const char *path,
return NULL;
if (DIR_SEPARATOR == fname[0])
fname++;
- ret = malloc (slen + strlen(fname) + 2);
+ ret = malloc (slen + strlen (fname) + 2);
if (NULL == ret)
return NULL;
#ifdef MINGW
- if ('\\' == path[slen-1])
+ if ('\\' == path[slen - 1])
sprintf (ret,
- "%s%s",
- path,
- fname);
+ "%s%s",
+ path,
+ fname);
else
sprintf (ret,
- "%s\\%s",
- path,
- fname);
+ "%s\\%s",
+ path,
+ fname);
#else
- if ('/' == path[slen-1])
+ if ('/' == path[slen - 1])
sprintf (ret,
- "%s%s",
- path,
- fname);
+ "%s%s",
+ path,
+ fname);
else
sprintf (ret,
- "%s/%s",
- path,
- fname);
+ "%s/%s",
+ path,
+ fname);
#endif
return ret;
}
@@ -453,7 +460,7 @@ append_to_dir (const char *path,
*/
static void
get_installation_paths (EXTRACTOR_PathProcessor pp,
- void *pp_cls)
+ void *pp_cls)
{
const char *p;
char *path;
@@ -463,19 +470,19 @@ get_installation_paths (EXTRACTOR_PathProcessor pp,
prefix = NULL;
if (NULL != (p = getenv ("LIBEXTRACTOR_PREFIX")))
+ {
+ if (NULL == (d = strdup (p)))
{
- if (NULL == (d = strdup (p)))
- {
- LOG_STRERROR ("strdup");
- return;
- }
- for (prefix = strtok_r (d, PATH_SEPARATOR_STR, &saveptr);
- NULL != prefix;
- prefix = strtok_r (NULL, PATH_SEPARATOR_STR, &saveptr))
- pp (pp_cls, prefix);
- free (d);
+ LOG_STRERROR ("strdup");
return;
}
+ for (prefix = strtok_r (d, PATH_SEPARATOR_STR, &saveptr);
+ NULL != prefix;
+ prefix = strtok_r (NULL, PATH_SEPARATOR_STR, &saveptr))
+ pp (pp_cls, prefix);
+ free (d);
+ return;
+ }
#if GNU_LINUX
if (NULL == prefix)
prefix = get_path_from_proc_exe ();
@@ -497,12 +504,12 @@ get_installation_paths (EXTRACTOR_PathProcessor pp,
return;
path = append_to_dir (prefix, PLUGINDIR);
if (NULL != path)
- {
- if (0 != strcmp (path,
- PLUGININSTDIR))
- pp (pp_cls, path);
- free (path);
- }
+ {
+ if (0 != strcmp (path,
+ PLUGININSTDIR))
+ pp (pp_cls, path);
+ free (path);
+ }
free (prefix);
}
@@ -532,7 +539,7 @@ struct SearchContext
*/
static void
find_plugin_in_path (void *cls,
- const char *path)
+ const char *path)
{
struct SearchContext *sc = cls;
DIR *dir;
@@ -547,34 +554,34 @@ find_plugin_in_path (void *cls,
if (NULL == (dir = OPENDIR (path)))
return;
while (NULL != (ent = READDIR (dir)))
+ {
+ if ('.' == ent->d_name[0])
+ continue;
+ dlen = strlen (ent->d_name);
+ if ( (dlen < 4) ||
+ ( (0 != strcmp (&ent->d_name[dlen - 3], ".so")) &&
+ (0 != strcasecmp (&ent->d_name[dlen - 4], ".dll")) ) )
+ continue; /* only load '.so' and '.dll' */
+ if (NULL == (sym_name = strrchr (ent->d_name, '_')))
+ continue;
+ sym_name++;
+ if (NULL == (sym = strdup (sym_name)))
+ {
+ LOG_STRERROR ("strdup");
+ CLOSEDIR (dir);
+ return;
+ }
+ dot = strchr (sym, '.');
+ if (NULL != dot)
+ *dot = '\0';
+ if (0 == strcmp (sym, sc->short_name))
{
- if ('.' == ent->d_name[0])
- continue;
- dlen = strlen (ent->d_name);
- if ( (dlen < 4) ||
- ( (0 != strcmp (&ent->d_name[dlen-3], ".so")) &&
- (0 != strcasecmp (&ent->d_name[dlen-4], ".dll")) ) )
- continue; /* only load '.so' and '.dll' */
- if (NULL == (sym_name = strrchr (ent->d_name, '_')))
- continue;
- sym_name++;
- if (NULL == (sym = strdup (sym_name)))
- {
- LOG_STRERROR ("strdup");
- CLOSEDIR (dir);
- return;
- }
- dot = strchr (sym, '.');
- if (NULL != dot)
- *dot = '\0';
- if (0 == strcmp (sym, sc->short_name))
- {
- sc->path = append_to_dir (path, ent->d_name);
- free (sym);
- break;
- }
+ sc->path = append_to_dir (path, ent->d_name);
free (sym);
+ break;
}
+ free (sym);
+ }
CLOSEDIR (dir);
}
@@ -591,7 +598,7 @@ EXTRACTOR_find_plugin_ (const char *short_name)
sc.path = NULL;
sc.short_name = short_name;
get_installation_paths (&find_plugin_in_path,
- &sc);
+ &sc);
return sc.path;
}
@@ -621,7 +628,7 @@ struct DefaultLoaderContext
*/
static void
load_plugins_from_dir (void *cls,
- const char *path)
+ const char *path)
{
struct DefaultLoaderContext *dlc = cls;
DIR *dir;
@@ -634,31 +641,31 @@ load_plugins_from_dir (void *cls,
if (NULL == (dir = opendir (path)))
return;
while (NULL != (ent = readdir (dir)))
+ {
+ if (ent->d_name[0] == '.')
+ continue;
+ dlen = strlen (ent->d_name);
+ if ( (dlen < 4) ||
+ ( (0 != strcmp (&ent->d_name[dlen - 3], ".so")) &&
+ (0 != strcasecmp (&ent->d_name[dlen - 4], ".dll")) ) )
+ continue; /* only load '.so' and '.dll' */
+ if (NULL == (sym_name = strrchr (ent->d_name, '_')))
+ continue;
+ sym_name++;
+ if (NULL == (sym = strdup (sym_name)))
{
- if (ent->d_name[0] == '.')
- continue;
- dlen = strlen (ent->d_name);
- if ( (dlen < 4) ||
- ( (0 != strcmp (&ent->d_name[dlen-3], ".so")) &&
- (0 != strcasecmp (&ent->d_name[dlen-4], ".dll")) ) )
- continue; /* only load '.so' and '.dll' */
- if (NULL == (sym_name = strrchr (ent->d_name, '_')))
- continue;
- sym_name++;
- if (NULL == (sym = strdup (sym_name)))
- {
- LOG_STRERROR ("strdup");
- closedir (dir);
- return;
- }
- if (NULL != (dot = strchr (sym, '.')))
- *dot = '\0';
- dlc->res = EXTRACTOR_plugin_add (dlc->res,
- sym,
- NULL,
- dlc->flags);
- free (sym);
+ LOG_STRERROR ("strdup");
+ closedir (dir);
+ return;
}
+ if (NULL != (dot = strchr (sym, '.')))
+ *dot = '\0';
+ dlc->res = EXTRACTOR_plugin_add (dlc->res,
+ sym,
+ NULL,
+ dlc->flags);
+ free (sym);
+ }
closedir (dir);
}
@@ -685,7 +692,7 @@ EXTRACTOR_plugin_add_defaults (enum EXTRACTOR_Options flags)
dlc.res = NULL;
dlc.flags = flags;
get_installation_paths (&load_plugins_from_dir,
- &dlc);
+ &dlc);
return dlc.res;
}
diff --git a/src/main/extractor_plugpath.h b/src/main/extractor_plugpath.h
@@ -29,9 +29,9 @@
* Given a short name of a library (i.e. "mime"), find
* the full path of the respective plugin.
*/
-char *
+char *
EXTRACTOR_find_plugin_ (const char *short_name);
-#endif
+#endif
/* EXTRACTOR_PLUGPATH_H */
diff --git a/src/main/extractor_print.c b/src/main/extractor_print.c
@@ -33,72 +33,73 @@
* Simple EXTRACTOR_MetaDataProcessor implementation that simply
* prints the extracted meta data to the given file. Only prints
* those keywords that are in UTF-8 format.
- *
+ *
* @param handle the file to write to (stdout, stderr), must NOT be NULL,
* must be of type "FILE *".
* @param plugin_name name of the plugin that produced this value
* @param type libextractor-type describing the meta data
- * @param format basic format information about data
+ * @param format basic format information about data
* @param data_mime_type mime-type of data (not of the original file);
* can be NULL (if mime-type is not known)
* @param data actual meta-data found
* @param data_len number of bytes in data
* @return non-zero if printing failed, otherwise 0.
*/
-int
+int
EXTRACTOR_meta_data_print (void *handle,
- const char *plugin_name,
- enum EXTRACTOR_MetaType type,
- enum EXTRACTOR_MetaFormat format,
- const char *data_mime_type,
- const char *data,
- size_t data_len)
+ const char *plugin_name,
+ enum EXTRACTOR_MetaType type,
+ enum EXTRACTOR_MetaFormat format,
+ const char *data_mime_type,
+ const char *data,
+ size_t data_len)
{
#if HAVE_ICONV
iconv_t cd;
#endif
- char * buf;
+ char *buf;
int ret;
const char *mt;
if (EXTRACTOR_METAFORMAT_UTF8 != format)
return 0;
#if HAVE_ICONV
- cd = iconv_open (nl_langinfo(CODESET),
- "UTF-8");
+ cd = iconv_open (nl_langinfo (CODESET),
+ "UTF-8");
if (((iconv_t) -1) == cd)
- {
- LOG_STRERROR ("iconv_open");
- return 1;
- }
+ {
+ LOG_STRERROR ("iconv_open");
+ return 1;
+ }
buf = iconv_helper (cd, data, data_len);
if (NULL == buf)
- {
- LOG_STRERROR ("iconv_helper");
- ret = -1;
- }
+ {
+ LOG_STRERROR ("iconv_helper");
+ ret = -1;
+ }
else
- {
- mt = EXTRACTOR_metatype_to_string (type);
- ret = fprintf (handle,
- "%s - %s\n",
- (NULL == mt)
- ? dgettext ("libextractor", gettext_noop ("unknown"))
- : dgettext ("libextractor", mt),
- buf);
- free(buf);
- }
- iconv_close(cd);
+ {
+ mt = EXTRACTOR_metatype_to_string (type);
+ ret = fprintf (handle,
+ "%s - %s\n",
+ (NULL == mt)
+ ? dgettext ("libextractor", gettext_noop ("unknown"))
+ : dgettext ("libextractor", mt),
+ buf);
+ free (buf);
+ }
+ iconv_close (cd);
#else
ret = fprintf (handle,
- "%s - %.*s\n",
- (NULL == mt)
- ? dgettext ("libextractor", gettext_noop ("unknown"))
- : dgettext ("libextractor", mt),
- (int) data_len,
- data);
+ "%s - %.*s\n",
+ (NULL == mt)
+ ? dgettext ("libextractor", gettext_noop ("unknown"))
+ : dgettext ("libextractor", mt),
+ (int) data_len,
+ data);
#endif
return (ret < 0) ? 1 : 0;
}
+
/* end of extractor_print.c */
diff --git a/src/main/getopt.c b/src/main/getopt.c
@@ -4,7 +4,7 @@
before changing it!
Copyright Copyright (C) 1987, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97
- Free Software Foundation, Inc.
+ Free Software Foundation, Inc.
NOTE: The canonical source of this file is maintained with the GNU C Library.
Bugs can be reported to bug-glibc@prep.ai.mit.edu.
@@ -32,7 +32,7 @@ USA. */
#include "config.h"
-#if !defined (__STDC__) || !__STDC__
+#if ! defined (__STDC__) || ! __STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const
@@ -51,7 +51,7 @@ USA. */
it is simpler to just do this in the source for each such file. */
#define GETOPT_INTERFACE_VERSION 2
-#if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2
+#if ! defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2
#include <gnu-versions.h>
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
#define ELIDE_CODE
@@ -63,7 +63,7 @@ USA. */
/* This needs to come after some library #include
to get __GNU_LIBRARY__ defined. */
-#ifdef __GNU_LIBRARY__
+#ifdef __GNU_LIBRARY__
/* Don't include stdlib.h for non-GNU C libraries because some of them
contain conflicting prototypes for getopt. */
#include <stdlib.h>
@@ -77,10 +77,10 @@ USA. */
#include <string.h>
#endif
-#if defined (WIN32) && !defined (__CYGWIN32__)
+#if defined (WIN32) && ! defined (__CYGWIN32__)
/* It's not Unix, really. See? Capital letters. */
#include <windows.h>
-#define getpid() GetCurrentProcessId()
+#define getpid() GetCurrentProcessId ()
#endif
#ifndef _
@@ -88,9 +88,9 @@ USA. */
When compiling libc, the _ macro is predefined. */
#ifdef NEVER_HAVE_LIBINTL_H
# include <libintl.h>
-# define _(msgid) gettext (msgid)
+# define _(msgid) gettext (msgid)
#else
-# define _(msgid) (msgid)
+# define _(msgid) (msgid)
#endif
#endif
@@ -195,14 +195,14 @@ static enum
/* Value of POSIXLY_CORRECT environment variable. */
static char *posixly_correct;
-
-#ifdef __GNU_LIBRARY__
+
+#ifdef __GNU_LIBRARY__
/* We want to avoid inclusion of string.h with non-GNU libraries
because there are many ways it can cause trouble.
On some systems, it contains special magic macros that don't work
in GCC. */
#include <string.h>
-#define my_index strchr
+#define my_index strchr
#else
/* Avoid depending on library functions or files
@@ -212,15 +212,16 @@ char *getenv ();
static char *
my_index (str, chr)
- const char *str;
- int chr;
+const char *str;
+
+int chr;
{
while (*str)
- {
- if (*str == chr)
- return (char *) str;
- str++;
- }
+ {
+ if (*str == chr)
+ return (char *) str;
+ str++;
+ }
return 0;
}
@@ -229,18 +230,20 @@ my_index (str, chr)
#ifdef __GNUC__
/* Note that Motorola Delta 68k R3V7 comes with GCC but not stddef.h.
That was relevant to code that was here before. */
-#if !defined (__STDC__) || !__STDC__
+#if ! defined (__STDC__) || ! __STDC__
/* gcc with -traditional declares the built-in strlen to return int,
and has done so at least since version 2.4.5. -- rms. */
extern int strlen (const char *);
+
#endif /* not __STDC__ */
#if defined(__APPLE__)
extern size_t strlen (const char *);
+
#endif
#endif /* __GNUC__ */
#endif /* not __GNU_LIBRARY__ */
-
+
/* Handle permutation of arguments. */
/* Describe the part of ARGV that contains non-options that have
@@ -269,7 +272,8 @@ extern pid_t __libc_pid;
is valid for the getopt call we must make sure that the ARGV passed
to getopt is that one passed to the process. */
static void
- __attribute__ ((unused)) store_args_and_env (int argc, char *const *argv)
+__attribute__ ((unused))
+store_args_and_env (int argc, char *const *argv)
{
/* XXX This is no good solution. We should rather copy the args so
that we can compare them later. But we must not use malloc(3). */
@@ -277,15 +281,16 @@ static void
original_argv = argv;
}
+
text_set_element (__libc_subinit, store_args_and_env);
# define SWAP_FLAGS(ch1, ch2) \
- if (nonoption_flags_len > 0) \
- { \
- char __tmp = __getopt_nonoption_flags[ch1]; \
- __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
- __getopt_nonoption_flags[ch2] = __tmp; \
- }
+ if (nonoption_flags_len > 0) \
+ { \
+ char __tmp = __getopt_nonoption_flags[ch1]; \
+ __getopt_nonoption_flags[ch1] = __getopt_nonoption_flags[ch2]; \
+ __getopt_nonoption_flags[ch2] = __tmp; \
+ }
#else /* !_LIBC */
# define SWAP_FLAGS(ch1, ch2)
#endif /* _LIBC */
@@ -301,11 +306,13 @@ text_set_element (__libc_subinit, store_args_and_env);
#if defined (__STDC__) && __STDC__
static void exchange (char **);
+
#endif
static void
exchange (argv)
- char **argv;
+char **argv;
+
{
int bottom = first_nonopt;
int middle = last_nonopt;
@@ -321,61 +328,61 @@ exchange (argv)
/* First make sure the handling of the `__getopt_nonoption_flags'
string can work normally. Our top argument must be in the range
of the string. */
- if (nonoption_flags_len > 0 && top >= nonoption_flags_max_len)
+ if ((nonoption_flags_len > 0) && (top >= nonoption_flags_max_len))
+ {
+ /* We must extend the array. The user plays games with us and
+ presents new arguments. */
+ char *new_str = malloc (top + 1);
+ if (new_str == NULL)
+ nonoption_flags_len = nonoption_flags_max_len = 0;
+ else
{
- /* We must extend the array. The user plays games with us and
- presents new arguments. */
- char *new_str = malloc (top + 1);
- if (new_str == NULL)
- nonoption_flags_len = nonoption_flags_max_len = 0;
- else
- {
- memcpy (new_str, __getopt_nonoption_flags, nonoption_flags_max_len);
- memset (&new_str[nonoption_flags_max_len], '\0',
- top + 1 - nonoption_flags_max_len);
- nonoption_flags_max_len = top + 1;
- __getopt_nonoption_flags = new_str;
- }
+ memcpy (new_str, __getopt_nonoption_flags, nonoption_flags_max_len);
+ memset (&new_str[nonoption_flags_max_len], '\0',
+ top + 1 - nonoption_flags_max_len);
+ nonoption_flags_max_len = top + 1;
+ __getopt_nonoption_flags = new_str;
}
+ }
#endif
while (top > middle && middle > bottom)
+ {
+ if (top - middle > middle - bottom)
{
- if (top - middle > middle - bottom)
- {
- /* Bottom segment is the short one. */
- int len = middle - bottom;
- register int i;
-
- /* Swap it with the top part of the top segment. */
- for (i = 0; i < len; i++)
- {
- tem = argv[bottom + i];
- argv[bottom + i] = argv[top - (middle - bottom) + i];
- argv[top - (middle - bottom) + i] = tem;
- SWAP_FLAGS (bottom + i, top - (middle - bottom) + i);
- }
- /* Exclude the moved bottom segment from further swapping. */
- top -= len;
- }
- else
- {
- /* Top segment is the short one. */
- int len = top - middle;
- register int i;
-
- /* Swap it with the bottom part of the bottom segment. */
- for (i = 0; i < len; i++)
- {
- tem = argv[bottom + i];
- argv[bottom + i] = argv[middle + i];
- argv[middle + i] = tem;
- SWAP_FLAGS (bottom + i, middle + i);
- }
- /* Exclude the moved top segment from further swapping. */
- bottom += len;
- }
+ /* Bottom segment is the short one. */
+ int len = middle - bottom;
+ register int i;
+
+ /* Swap it with the top part of the top segment. */
+ for (i = 0; i < len; i++)
+ {
+ tem = argv[bottom + i];
+ argv[bottom + i] = argv[top - (middle - bottom) + i];
+ argv[top - (middle - bottom) + i] = tem;
+ SWAP_FLAGS (bottom + i, top - (middle - bottom) + i);
+ }
+ /* Exclude the moved bottom segment from further swapping. */
+ top -= len;
+ }
+ else
+ {
+ /* Top segment is the short one. */
+ int len = top - middle;
+ register int i;
+
+ /* Swap it with the bottom part of the bottom segment. */
+ for (i = 0; i < len; i++)
+ {
+ tem = argv[bottom + i];
+ argv[bottom + i] = argv[middle + i];
+ argv[middle + i] = tem;
+ SWAP_FLAGS (bottom + i, middle + i);
+ }
+ /* Exclude the moved top segment from further swapping. */
+ bottom += len;
}
+ }
/* Update records for the slots the non-options now occupy. */
@@ -387,12 +394,14 @@ exchange (argv)
#if defined (__STDC__) && __STDC__
static const char *_getopt_initialize (int, char *const *, const char *);
+
#endif
static const char *
_getopt_initialize (argc, argv, optstring)
- int argc;
- char *const *argv;
- const char *optstring;
+int argc;
+
+char *const *argv;
+const char *optstring;
{
/* Start processing options with ARGV-element 1 (since ARGV-element 0
is the program name); the sequence of previously skipped
@@ -407,56 +416,56 @@ _getopt_initialize (argc, argv, optstring)
/* Determine how to handle the ordering of options and nonoptions. */
if (optstring[0] == '-')
- {
- ordering = RETURN_IN_ORDER;
- ++optstring;
- }
+ {
+ ordering = RETURN_IN_ORDER;
+ ++optstring;
+ }
else if (optstring[0] == '+')
- {
- ordering = REQUIRE_ORDER;
- ++optstring;
- }
+ {
+ ordering = REQUIRE_ORDER;
+ ++optstring;
+ }
else if (posixly_correct != NULL)
ordering = REQUIRE_ORDER;
else
ordering = PERMUTE;
#ifdef _LIBC
- if (posixly_correct == NULL
- && argc == original_argc && argv == original_argv)
+ if ((posixly_correct == NULL)
+ && (argc == original_argc) && (argv == original_argv))
+ {
+ if (nonoption_flags_max_len == 0)
{
- if (nonoption_flags_max_len == 0)
- {
- if (__getopt_nonoption_flags == NULL
- || __getopt_nonoption_flags[0] == '\0')
- nonoption_flags_max_len = -1;
- else
- {
- const char *orig_str = __getopt_nonoption_flags;
- int len = nonoption_flags_max_len = strlen (orig_str);
- if (nonoption_flags_max_len < argc)
- nonoption_flags_max_len = argc;
- __getopt_nonoption_flags =
- (char *) malloc (nonoption_flags_max_len);
- if (__getopt_nonoption_flags == NULL)
- nonoption_flags_max_len = -1;
- else
- {
- memcpy (__getopt_nonoption_flags, orig_str, len);
- memset (&__getopt_nonoption_flags[len], '\0',
- nonoption_flags_max_len - len);
- }
- }
- }
- nonoption_flags_len = nonoption_flags_max_len;
+ if ((__getopt_nonoption_flags == NULL)
+ || (__getopt_nonoption_flags[0] == '\0') )
+ nonoption_flags_max_len = -1;
+ else
+ {
+ const char *orig_str = __getopt_nonoption_flags;
+ int len = nonoption_flags_max_len = strlen (orig_str);
+ if (nonoption_flags_max_len < argc)
+ nonoption_flags_max_len = argc;
+ __getopt_nonoption_flags =
+ (char *) malloc (nonoption_flags_max_len);
+ if (__getopt_nonoption_flags == NULL)
+ nonoption_flags_max_len = -1;
+ else
+ {
+ memcpy (__getopt_nonoption_flags, orig_str, len);
+ memset (&__getopt_nonoption_flags[len], '\0',
+ nonoption_flags_max_len - len);
+ }
+ }
}
+ nonoption_flags_len = nonoption_flags_max_len;
+ }
else
nonoption_flags_len = 0;
#endif
return optstring;
}
-
+
/* Scan elements of ARGV (whose length is ARGC) for option characters
given in OPTSTRING.
@@ -515,112 +524,113 @@ _getopt_initialize (argc, argv, optstring)
int
_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
- int argc;
- char *const *argv;
- const char *optstring;
- const struct option *longopts;
- int *longind;
- int long_only;
+int argc;
+
+char *const *argv;
+const char *optstring;
+const struct option *longopts;
+int *longind;
+int long_only;
{
optarg = NULL;
- if (optind == 0 || !__getopt_initialized)
- {
- if (optind == 0)
- optind = 1; /* Don't scan ARGV[0], the program name. */
- optstring = _getopt_initialize (argc, argv, optstring);
- __getopt_initialized = 1;
- }
+ if ((optind == 0) || ! __getopt_initialized)
+ {
+ if (optind == 0)
+ optind = 1; /* Don't scan ARGV[0], the program name. */
+ optstring = _getopt_initialize (argc, argv, optstring);
+ __getopt_initialized = 1;
+ }
/* Test whether ARGV[optind] points to a non-option argument.
Either it does not have option syntax, or there is an environment flag
from the shell indicating it is not an option. The later information
is only used when the used in the GNU libc. */
#ifdef _LIBC
-#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \
- || (optind < nonoption_flags_len \
- && __getopt_nonoption_flags[optind] == '1'))
+#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0' \
+ || (optind < nonoption_flags_len \
+ && __getopt_nonoption_flags[optind] == '1'))
#else
#define NONOPTION_P (argv[optind][0] != '-' || argv[optind][1] == '\0')
#endif
- if (nextchar == NULL || *nextchar == '\0')
+ if ((nextchar == NULL) || (*nextchar == '\0'))
+ {
+ /* Advance to the next ARGV-element. */
+
+ /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
+ moved back by the user (who may also have changed the arguments). */
+ if (last_nonopt > optind)
+ last_nonopt = optind;
+ if (first_nonopt > optind)
+ first_nonopt = optind;
+
+ if (ordering == PERMUTE)
{
- /* Advance to the next ARGV-element. */
-
- /* Give FIRST_NONOPT & LAST_NONOPT rational values if OPTIND has been
- moved back by the user (who may also have changed the arguments). */
- if (last_nonopt > optind)
- last_nonopt = optind;
- if (first_nonopt > optind)
- first_nonopt = optind;
-
- if (ordering == PERMUTE)
- {
- /* If we have just processed some options following some non-options,
- exchange them so that the options come first. */
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange ((char **) argv);
- else if (last_nonopt != optind)
- first_nonopt = optind;
-
- /* Skip any additional non-options
- and extend the range of non-options previously skipped. */
-
- while (optind < argc && NONOPTION_P)
- optind++;
- last_nonopt = optind;
- }
-
- /* The special ARGV-element `--' means premature end of options.
- Skip it like a null option,
- then exchange with previous non-options as if it were an option,
- then skip everything else like a non-option. */
-
- if (optind != argc && !strcmp (argv[optind], "--"))
- {
- optind++;
-
- if (first_nonopt != last_nonopt && last_nonopt != optind)
- exchange ((char **) argv);
- else if (first_nonopt == last_nonopt)
- first_nonopt = optind;
- last_nonopt = argc;
-
- optind = argc;
- }
-
- /* If we have done all the ARGV-elements, stop the scan
- and back over any non-options that we skipped and permuted. */
-
- if (optind == argc)
- {
- /* Set the next-arg-index to point at the non-options
- that we previously skipped, so the caller will digest them. */
- if (first_nonopt != last_nonopt)
- optind = first_nonopt;
- return -1;
- }
-
- /* If we have come to a non-option and did not permute it,
- either stop the scan or describe it to the caller and pass it by. */
-
- if (NONOPTION_P)
- {
- if (ordering == REQUIRE_ORDER)
- return -1;
- optarg = argv[optind++];
- return 1;
- }
-
- /* We have found another option-ARGV-element.
- Skip the initial punctuation. */
-
- nextchar = (argv[optind] + 1
- + (longopts != NULL && argv[optind][1] == '-'));
+ /* If we have just processed some options following some non-options,
+ exchange them so that the options come first. */
+
+ if ((first_nonopt != last_nonopt) && (last_nonopt != optind) )
+ exchange ((char **) argv);
+ else if (last_nonopt != optind)
+ first_nonopt = optind;
+
+ /* Skip any additional non-options
+ and extend the range of non-options previously skipped. */
+
+ while (optind < argc && NONOPTION_P)
+ optind++;
+ last_nonopt = optind;
}
+ /* The special ARGV-element `--' means premature end of options.
+ Skip it like a null option,
+ then exchange with previous non-options as if it were an option,
+ then skip everything else like a non-option. */
+
+ if ((optind != argc) && ! strcmp (argv[optind], "--"))
+ {
+ optind++;
+
+ if ((first_nonopt != last_nonopt) && (last_nonopt != optind) )
+ exchange ((char **) argv);
+ else if (first_nonopt == last_nonopt)
+ first_nonopt = optind;
+ last_nonopt = argc;
+
+ optind = argc;
+ }
+
+ /* If we have done all the ARGV-elements, stop the scan
+ and back over any non-options that we skipped and permuted. */
+
+ if (optind == argc)
+ {
+ /* Set the next-arg-index to point at the non-options
+ that we previously skipped, so the caller will digest them. */
+ if (first_nonopt != last_nonopt)
+ optind = first_nonopt;
+ return -1;
+ }
+
+ /* If we have come to a non-option and did not permute it,
+ either stop the scan or describe it to the caller and pass it by. */
+
+ if (NONOPTION_P)
+ {
+ if (ordering == REQUIRE_ORDER)
+ return -1;
+ optarg = argv[optind++];
+ return 1;
+ }
+
+ /* We have found another option-ARGV-element.
+ Skip the initial punctuation. */
+
+ nextchar = (argv[optind] + 1
+ + (longopts != NULL && argv[optind][1] == '-'));
+ }
+
/* Decode the current option-ARGV-element. */
/* Check whether the ARGV-element is a long option.
@@ -636,141 +646,141 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
This distinction seems to be the most useful approach. */
- if (longopts != NULL
- && (argv[optind][1] == '-'
- || (long_only
- && (argv[optind][2]
- || !my_index (optstring, argv[optind][1])))))
- {
- char *nameend;
- const struct option *p;
- const struct option *pfound = NULL;
- int exact = 0;
- int ambig = 0;
- int indfound = -1;
- int option_index;
+ if ((longopts != NULL)
+ && ((argv[optind][1] == '-')
+ || (long_only
+ && (argv[optind][2]
+ || ! my_index (optstring, argv[optind][1])))))
+ {
+ char *nameend;
+ const struct option *p;
+ const struct option *pfound = NULL;
+ int exact = 0;
+ int ambig = 0;
+ int indfound = -1;
+ int option_index;
+
+ for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
+ /* Do nothing. */;
+
+ /* Test all long options for either exact match
+ or abbreviated matches. */
+ for (p = longopts, option_index = 0; p->name; p++, option_index++)
+ if (! strncmp (p->name, nextchar, nameend - nextchar))
+ {
+ if ((unsigned int) (nameend - nextchar)
+ == (unsigned int) strlen (p->name))
+ {
+ /* Exact match found. */
+ pfound = p;
+ indfound = option_index;
+ exact = 1;
+ break;
+ }
+ else if (pfound == NULL)
+ {
+ /* First nonexact match found. */
+ pfound = p;
+ indfound = option_index;
+ }
+ else
+ /* Second or later nonexact match found. */
+ ambig = 1;
+ }
- for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
- /* Do nothing. */ ;
+ if (ambig && ! exact)
+ {
+ if (opterr)
+ fprintf (stderr, _ ("%s: option `%s' is ambiguous\n"),
+ argv[0], argv[optind]);
+ nextchar += strlen (nextchar);
+ optind++;
+ optopt = 0;
+ return '?';
+ }
- /* Test all long options for either exact match
- or abbreviated matches. */
- for (p = longopts, option_index = 0; p->name; p++, option_index++)
- if (!strncmp (p->name, nextchar, nameend - nextchar))
- {
- if ((unsigned int) (nameend - nextchar)
- == (unsigned int) strlen (p->name))
- {
- /* Exact match found. */
- pfound = p;
- indfound = option_index;
- exact = 1;
- break;
- }
- else if (pfound == NULL)
- {
- /* First nonexact match found. */
- pfound = p;
- indfound = option_index;
- }
- else
- /* Second or later nonexact match found. */
- ambig = 1;
- }
-
- if (ambig && !exact)
- {
- if (opterr)
- fprintf (stderr, _("%s: option `%s' is ambiguous\n"),
- argv[0], argv[optind]);
- nextchar += strlen (nextchar);
- optind++;
- optopt = 0;
- return '?';
- }
+ if (pfound != NULL)
+ {
+ option_index = indfound;
+ optind++;
+ if (*nameend)
+ {
+ /* Don't test has_arg with >, because some C compilers don't
+ allow it to be used on enums. */
+ if (pfound->has_arg)
+ optarg = nameend + 1;
+ else
+ {
+ if (opterr)
+ if (argv[optind - 1][1] == '-')
+ /* --option */
+ fprintf (stderr,
+ _
+ ("%s: option `--%s' doesn't allow an argument\n"),
+ argv[0], pfound->name);
+ else
+ /* +option or -option */
+ fprintf (stderr,
+ _
+ ("%s: option `%c%s' doesn't allow an argument\n"),
+ argv[0], argv[optind - 1][0], pfound->name);
+
+ nextchar += strlen (nextchar);
+
+ optopt = pfound->val;
+ return '?';
+ }
+ }
+ else if (pfound->has_arg == 1)
+ {
+ if (optind < argc)
+ optarg = argv[optind++];
+ else
+ {
+ if (opterr)
+ fprintf (stderr,
+ _ ("%s: option `%s' requires an argument\n"),
+ argv[0], argv[optind - 1]);
+ nextchar += strlen (nextchar);
+ optopt = pfound->val;
+ return optstring[0] == ':' ? ':' : '?';
+ }
+ }
+ nextchar += strlen (nextchar);
+ if (longind != NULL)
+ *longind = option_index;
+ if (pfound->flag)
+ {
+ *(pfound->flag) = pfound->val;
+ return 0;
+ }
+ return pfound->val;
+ }
- if (pfound != NULL)
- {
- option_index = indfound;
- optind++;
- if (*nameend)
- {
- /* Don't test has_arg with >, because some C compilers don't
- allow it to be used on enums. */
- if (pfound->has_arg)
- optarg = nameend + 1;
- else
- {
- if (opterr)
- if (argv[optind - 1][1] == '-')
- /* --option */
- fprintf (stderr,
- _
- ("%s: option `--%s' doesn't allow an argument\n"),
- argv[0], pfound->name);
- else
- /* +option or -option */
- fprintf (stderr,
- _
- ("%s: option `%c%s' doesn't allow an argument\n"),
- argv[0], argv[optind - 1][0], pfound->name);
-
- nextchar += strlen (nextchar);
-
- optopt = pfound->val;
- return '?';
- }
- }
- else if (pfound->has_arg == 1)
- {
- if (optind < argc)
- optarg = argv[optind++];
- else
- {
- if (opterr)
- fprintf (stderr,
- _("%s: option `%s' requires an argument\n"),
- argv[0], argv[optind - 1]);
- nextchar += strlen (nextchar);
- optopt = pfound->val;
- return optstring[0] == ':' ? ':' : '?';
- }
- }
- nextchar += strlen (nextchar);
- if (longind != NULL)
- *longind = option_index;
- if (pfound->flag)
- {
- *(pfound->flag) = pfound->val;
- return 0;
- }
- return pfound->val;
- }
-
- /* Can't find it as a long option. If this is not getopt_long_only,
- or the option starts with '--' or is not a valid short
- option, then it's an error.
- Otherwise interpret it as a short option. */
- if (!long_only || argv[optind][1] == '-'
- || my_index (optstring, *nextchar) == NULL)
- {
- if (opterr)
- {
- if (argv[optind][1] == '-')
- /* --option */
- fprintf (stderr, _("%s: unrecognized option `--%s'\n"),
- argv[0], nextchar);
- else
- /* +option or -option */
- fprintf (stderr, _("%s: unrecognized option `%c%s'\n"),
- argv[0], argv[optind][0], nextchar);
- }
- nextchar = (char *) "";
- optind++;
- optopt = 0;
- return '?';
- }
+ /* Can't find it as a long option. If this is not getopt_long_only,
+ or the option starts with '--' or is not a valid short
+ option, then it's an error.
+ Otherwise interpret it as a short option. */
+ if (! long_only || (argv[optind][1] == '-')
+ || (my_index (optstring, *nextchar) == NULL) )
+ {
+ if (opterr)
+ {
+ if (argv[optind][1] == '-')
+ /* --option */
+ fprintf (stderr, _ ("%s: unrecognized option `--%s'\n"),
+ argv[0], nextchar);
+ else
+ /* +option or -option */
+ fprintf (stderr, _ ("%s: unrecognized option `%c%s'\n"),
+ argv[0], argv[optind][0], nextchar);
+ }
+ nextchar = (char *) "";
+ optind++;
+ optopt = 0;
+ return '?';
}
+ }
/* Look at and handle the next short option-character. */
@@ -782,205 +792,207 @@ _getopt_internal (argc, argv, optstring, longopts, longind, long_only)
if (*nextchar == '\0')
++optind;
- if (temp == NULL || c == ':')
+ if ((temp == NULL) || (c == ':'))
+ {
+ if (opterr)
{
- if (opterr)
- {
- if (posixly_correct)
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr, _("%s: illegal option -- %c\n"), argv[0], c);
- else
- fprintf (stderr, _("%s: invalid option -- %c\n"), argv[0], c);
- }
- optopt = c;
- return '?';
+ if (posixly_correct)
+ /* 1003.2 specifies the format of this message. */
+ fprintf (stderr, _ ("%s: illegal option -- %c\n"), argv[0], c);
+ else
+ fprintf (stderr, _ ("%s: invalid option -- %c\n"), argv[0], c);
}
+ optopt = c;
+ return '?';
+ }
/* Convenience. Treat POSIX -W foo same as long option --foo */
- if (temp[0] == 'W' && temp[1] == ';')
+ if ((temp[0] == 'W') && (temp[1] == ';'))
+ {
+ char *nameend;
+ const struct option *p;
+ const struct option *pfound = NULL;
+ int exact = 0;
+ int ambig = 0;
+ int indfound = 0;
+ int option_index;
+
+ /* This is an option that requires an argument. */
+ if (*nextchar != '\0')
+ {
+ optarg = nextchar;
+ /* If we end this ARGV-element by taking the rest as an arg,
+ we must advance to the next element now. */
+ optind++;
+ }
+ else if (optind == argc)
+ {
+ if (opterr)
+ {
+ /* 1003.2 specifies the format of this message. */
+ fprintf (stderr, _ ("%s: option requires an argument -- %c\n"),
+ argv[0], c);
+ }
+ optopt = c;
+ if (optstring[0] == ':')
+ c = ':';
+ else
+ c = '?';
+ return c;
+ }
+ else
+ /* We already incremented `optind' once;
+ increment it again when taking next ARGV-elt as argument. */
+ optarg = argv[optind++];
+
+ /* optarg is now the argument, see if it's in the
+ table of longopts. */
+
+ for (nextchar = nameend = optarg; *nameend && *nameend != '=';
+ nameend++)
+ /* Do nothing. */;
+
+ /* Test all long options for either exact match
+ or abbreviated matches. */
+ for (p = longopts, option_index = 0; p->name; p++, option_index++)
+ if (! strncmp (p->name, nextchar, nameend - nextchar))
+ {
+ if ((unsigned int) (nameend - nextchar) == strlen (p->name))
+ {
+ /* Exact match found. */
+ pfound = p;
+ indfound = option_index;
+ exact = 1;
+ break;
+ }
+ else if (pfound == NULL)
+ {
+ /* First nonexact match found. */
+ pfound = p;
+ indfound = option_index;
+ }
+ else
+ /* Second or later nonexact match found. */
+ ambig = 1;
+ }
+ if (ambig && ! exact)
+ {
+ if (opterr)
+ fprintf (stderr, _ ("%s: option `-W %s' is ambiguous\n"),
+ argv[0], argv[optind]);
+ nextchar += strlen (nextchar);
+ optind++;
+ return '?';
+ }
+ if (pfound != NULL)
{
- char *nameend;
- const struct option *p;
- const struct option *pfound = NULL;
- int exact = 0;
- int ambig = 0;
- int indfound = 0;
- int option_index;
-
- /* This is an option that requires an argument. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- /* If we end this ARGV-element by taking the rest as an arg,
- we must advance to the next element now. */
- optind++;
- }
- else if (optind == argc)
- {
- if (opterr)
- {
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr, _("%s: option requires an argument -- %c\n"),
- argv[0], c);
- }
- optopt = c;
- if (optstring[0] == ':')
- c = ':';
- else
- c = '?';
- return c;
- }
- else
- /* We already incremented `optind' once;
- increment it again when taking next ARGV-elt as argument. */
- optarg = argv[optind++];
-
- /* optarg is now the argument, see if it's in the
- table of longopts. */
-
- for (nextchar = nameend = optarg; *nameend && *nameend != '=';
- nameend++)
- /* Do nothing. */ ;
-
- /* Test all long options for either exact match
- or abbreviated matches. */
- for (p = longopts, option_index = 0; p->name; p++, option_index++)
- if (!strncmp (p->name, nextchar, nameend - nextchar))
- {
- if ((unsigned int) (nameend - nextchar) == strlen (p->name))
- {
- /* Exact match found. */
- pfound = p;
- indfound = option_index;
- exact = 1;
- break;
- }
- else if (pfound == NULL)
- {
- /* First nonexact match found. */
- pfound = p;
- indfound = option_index;
- }
- else
- /* Second or later nonexact match found. */
- ambig = 1;
- }
- if (ambig && !exact)
- {
- if (opterr)
- fprintf (stderr, _("%s: option `-W %s' is ambiguous\n"),
- argv[0], argv[optind]);
- nextchar += strlen (nextchar);
- optind++;
- return '?';
- }
- if (pfound != NULL)
- {
- option_index = indfound;
- if (*nameend)
- {
- /* Don't test has_arg with >, because some C compilers don't
- allow it to be used on enums. */
- if (pfound->has_arg)
- optarg = nameend + 1;
- else
- {
- if (opterr)
- fprintf (stderr, _("\
+ option_index = indfound;
+ if (*nameend)
+ {
+ /* Don't test has_arg with >, because some C compilers don't
+ allow it to be used on enums. */
+ if (pfound->has_arg)
+ optarg = nameend + 1;
+ else
+ {
+ if (opterr)
+ fprintf (stderr, _ (
+ "\
%s: option `-W %s' doesn't allow an argument\n"), argv[0], pfound->name);
- nextchar += strlen (nextchar);
- return '?';
- }
- }
- else if (pfound->has_arg == 1)
- {
- if (optind < argc)
- optarg = argv[optind++];
- else
- {
- if (opterr)
- fprintf (stderr,
- _("%s: option `%s' requires an argument\n"),
- argv[0], argv[optind - 1]);
- nextchar += strlen (nextchar);
- return optstring[0] == ':' ? ':' : '?';
- }
- }
- nextchar += strlen (nextchar);
- if (longind != NULL)
- *longind = option_index;
- if (pfound->flag)
- {
- *(pfound->flag) = pfound->val;
- return 0;
- }
- return pfound->val;
- }
- nextchar = NULL;
- return 'W'; /* Let the application handle it. */
+ nextchar += strlen (nextchar);
+ return '?';
+ }
+ }
+ else if (pfound->has_arg == 1)
+ {
+ if (optind < argc)
+ optarg = argv[optind++];
+ else
+ {
+ if (opterr)
+ fprintf (stderr,
+ _ ("%s: option `%s' requires an argument\n"),
+ argv[0], argv[optind - 1]);
+ nextchar += strlen (nextchar);
+ return optstring[0] == ':' ? ':' : '?';
+ }
+ }
+ nextchar += strlen (nextchar);
+ if (longind != NULL)
+ *longind = option_index;
+ if (pfound->flag)
+ {
+ *(pfound->flag) = pfound->val;
+ return 0;
+ }
+ return pfound->val;
}
+ nextchar = NULL;
+ return 'W'; /* Let the application handle it. */
+ }
if (temp[1] == ':')
+ {
+ if (temp[2] == ':')
+ {
+ /* This is an option that accepts an argument optionally. */
+ if (*nextchar != '\0')
+ {
+ optarg = nextchar;
+ optind++;
+ }
+ else
+ optarg = NULL;
+ nextchar = NULL;
+ }
+ else
{
- if (temp[2] == ':')
- {
- /* This is an option that accepts an argument optionally. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- optind++;
- }
- else
- optarg = NULL;
- nextchar = NULL;
- }
- else
- {
- /* This is an option that requires an argument. */
- if (*nextchar != '\0')
- {
- optarg = nextchar;
- /* If we end this ARGV-element by taking the rest as an arg,
- we must advance to the next element now. */
- optind++;
- }
- else if (optind == argc)
- {
- if (opterr)
- {
- /* 1003.2 specifies the format of this message. */
- fprintf (stderr,
- _("%s: option requires an argument -- %c\n"),
- argv[0], c);
- }
- optopt = c;
- if (optstring[0] == ':')
- c = ':';
- else
- c = '?';
- }
- else
- /* We already incremented `optind' once;
- increment it again when taking next ARGV-elt as argument. */
- optarg = argv[optind++];
- nextchar = NULL;
- }
+ /* This is an option that requires an argument. */
+ if (*nextchar != '\0')
+ {
+ optarg = nextchar;
+ /* If we end this ARGV-element by taking the rest as an arg,
+ we must advance to the next element now. */
+ optind++;
+ }
+ else if (optind == argc)
+ {
+ if (opterr)
+ {
+ /* 1003.2 specifies the format of this message. */
+ fprintf (stderr,
+ _ ("%s: option requires an argument -- %c\n"),
+ argv[0], c);
+ }
+ optopt = c;
+ if (optstring[0] == ':')
+ c = ':';
+ else
+ c = '?';
+ }
+ else
+ /* We already incremented `optind' once;
+ increment it again when taking next ARGV-elt as argument. */
+ optarg = argv[optind++];
+ nextchar = NULL;
}
+ }
return c;
}
}
int
getopt (argc, argv, optstring)
- int argc;
- char *const *argv;
- const char *optstring;
+int argc;
+
+char *const *argv;
+const char *optstring;
{
return _getopt_internal (argc, argv, optstring,
- (const struct option *) 0, (int *) 0, 0);
+ (const struct option *) 0, (int *) 0, 0);
}
#endif /* Not ELIDE_CODE. */
-
+
#ifdef TEST
/* Compile with -DTEST to make an executable for use in testing
@@ -988,65 +1000,66 @@ getopt (argc, argv, optstring)
int
main (argc, argv)
- int argc;
- char **argv;
+int argc;
+
+char **argv;
{
int c;
int digit_optind = 0;
while (1)
+ {
+ int this_option_optind = optind ? optind : 1;
+
+ c = getopt (argc, argv, "abc:d:0123456789");
+ if (c == -1)
+ break;
+
+ switch (c)
{
- int this_option_optind = optind ? optind : 1;
-
- c = getopt (argc, argv, "abc:d:0123456789");
- if (c == -1)
- break;
-
- switch (c)
- {
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (digit_optind != 0 && digit_optind != this_option_optind)
- printf ("digits occur in two different argv-elements.\n");
- digit_optind = this_option_optind;
- printf ("option %c\n", c);
- break;
-
- case 'a':
- printf ("option a\n");
- break;
-
- case 'b':
- printf ("option b\n");
- break;
-
- case 'c':
- printf ("option c with value `%s'\n", optarg);
- break;
-
- case '?':
- break;
-
- default:
- printf ("?? getopt returned character code 0%o ??\n", c);
- }
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ if ((digit_optind != 0) && (digit_optind != this_option_optind) )
+ printf ("digits occur in two different argv-elements.\n");
+ digit_optind = this_option_optind;
+ printf ("option %c\n", c);
+ break;
+
+ case 'a':
+ printf ("option a\n");
+ break;
+
+ case 'b':
+ printf ("option b\n");
+ break;
+
+ case 'c':
+ printf ("option c with value `%s'\n", optarg);
+ break;
+
+ case '?':
+ break;
+
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
}
+ }
if (optind < argc)
- {
- printf ("non-option ARGV-elements: ");
- while (optind < argc)
- printf ("%s ", argv[optind++]);
- printf ("\n");
- }
+ {
+ printf ("non-option ARGV-elements: ");
+ while (optind < argc)
+ printf ("%s ", argv[optind++]);
+ printf ("\n");
+ }
exit (0);
}
diff --git a/src/main/getopt.h b/src/main/getopt.h
@@ -24,7 +24,7 @@ USA. */
#include "config.h"
-#ifdef __cplusplus
+#ifdef __cplusplus
extern "C" {
#endif
@@ -67,7 +67,7 @@ extern int optopt;
The field `has_arg' is:
no_argument (or 0) if the option does not take an argument,
required_argument (or 1) if the option requires an argument,
- optional_argument (or 2) if the option takes an optional argument.
+ optional_argument (or 2) if the option takes an optional argument.
If the field `flag' is not NULL, it points to a variable that is set
to the value given in the field `val' when the option is found, but
@@ -96,9 +96,9 @@ struct option
/* Names for the values of the `has_arg' field of `struct option'. */
-#define no_argument 0
-#define required_argument 1
-#define optional_argument 2
+#define no_argument 0
+#define required_argument 1
+#define optional_argument 2
#if defined (__STDC__) && __STDC__
#ifdef __GNU_LIBRARY__
@@ -106,29 +106,36 @@ struct option
differences in the consts, in stdlib.h. To avoid compilation
errors, only prototype getopt for the GNU C library. */
extern int getopt (int argc, char *const *argv, const char *shortopts);
+
#else /* not __GNU_LIBRARY__ */
extern int getopt ();
+
#endif /* __GNU_LIBRARY__ */
extern int getopt_long (int argc, char *const *argv, const char *shortopts,
- const struct option *longopts, int *longind);
+ const struct option *longopts, int *longind);
+
extern int getopt_long_only (int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind);
+ const char *shortopts,
+ const struct option *longopts, int *longind);
/* Internal only. Users should not call this directly. */
extern int _getopt_internal (int argc, char *const *argv,
- const char *shortopts,
- const struct option *longopts, int *longind,
- int long_only);
+ const char *shortopts,
+ const struct option *longopts, int *longind,
+ int long_only);
+
#else /* not __STDC__ */
extern int getopt ();
+
extern int getopt_long ();
+
extern int getopt_long_only ();
extern int _getopt_internal ();
+
#endif /* __STDC__ */
-#ifdef __cplusplus
+#ifdef __cplusplus
}
#endif
diff --git a/src/main/getopt1.c b/src/main/getopt1.c
@@ -21,7 +21,7 @@ USA. */
#include "config.h"
#include "getopt.h"
-#if !defined (__STDC__) || !__STDC__
+#if ! defined (__STDC__) || ! __STDC__
/* This is a separate conditional since some stdc systems
reject `defined (const)'. */
#ifndef const
@@ -40,7 +40,7 @@ USA. */
it is simpler to just do this in the source for each such file. */
#define GETOPT_INTERFACE_VERSION 2
-#if !defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2
+#if ! defined (_LIBC) && defined (__GLIBC__) && __GLIBC__ >= 2
#include <gnu-versions.h>
#if _GNU_GETOPT_INTERFACE_VERSION == GETOPT_INTERFACE_VERSION
#define ELIDE_CODE
@@ -56,17 +56,18 @@ USA. */
#include <stdlib.h>
#endif
-#ifndef NULL
+#ifndef NULL
#define NULL 0
#endif
int
getopt_long (argc, argv, options, long_options, opt_index)
- int argc;
- char *const *argv;
- const char *options;
- const struct option *long_options;
- int *opt_index;
+int argc;
+
+char *const *argv;
+const char *options;
+const struct option *long_options;
+int *opt_index;
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 0);
}
@@ -78,105 +79,107 @@ getopt_long (argc, argv, options, long_options, opt_index)
int
getopt_long_only (argc, argv, options, long_options, opt_index)
- int argc;
- char *const *argv;
- const char *options;
- const struct option *long_options;
- int *opt_index;
+int argc;
+
+char *const *argv;
+const char *options;
+const struct option *long_options;
+int *opt_index;
{
return _getopt_internal (argc, argv, options, long_options, opt_index, 1);
}
#endif /* Not ELIDE_CODE. */
-
+
#ifdef TEST
#include <stdio.h>
int
main (argc, argv)
- int argc;
- char **argv;
+int argc;
+
+char **argv;
{
int c;
int digit_optind = 0;
while (1)
+ {
+ int this_option_optind = optind ? optind : 1;
+ int option_index = 0;
+ static struct option long_options[] = {
+ {"add", 1, 0, 0},
+ {"append", 0, 0, 0},
+ {"delete", 1, 0, 0},
+ {"verbose", 0, 0, 0},
+ {"create", 0, 0, 0},
+ {"file", 1, 0, 0},
+ {0, 0, 0, 0}
+ };
+
+ c = getopt_long (argc, argv, "abc:d:0123456789",
+ long_options, &option_index);
+ if (c == -1)
+ break;
+
+ switch (c)
{
- int this_option_optind = optind ? optind : 1;
- int option_index = 0;
- static struct option long_options[] = {
- {"add", 1, 0, 0},
- {"append", 0, 0, 0},
- {"delete", 1, 0, 0},
- {"verbose", 0, 0, 0},
- {"create", 0, 0, 0},
- {"file", 1, 0, 0},
- {0, 0, 0, 0}
- };
-
- c = getopt_long (argc, argv, "abc:d:0123456789",
- long_options, &option_index);
- if (c == -1)
- break;
-
- switch (c)
- {
- case 0:
- printf ("option %s", long_options[option_index].name);
- if (optarg)
- printf (" with arg %s", optarg);
- printf ("\n");
- break;
-
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- if (digit_optind != 0 && digit_optind != this_option_optind)
- printf ("digits occur in two different argv-elements.\n");
- digit_optind = this_option_optind;
- printf ("option %c\n", c);
- break;
-
- case 'a':
- printf ("option a\n");
- break;
-
- case 'b':
- printf ("option b\n");
- break;
-
- case 'c':
- printf ("option c with value `%s'\n", optarg);
- break;
-
- case 'd':
- printf ("option d with value `%s'\n", optarg);
- break;
-
- case '?':
- break;
-
- default:
- printf ("?? getopt returned character code 0%o ??\n", c);
- }
+ case 0:
+ printf ("option %s", long_options[option_index].name);
+ if (optarg)
+ printf (" with arg %s", optarg);
+ printf ("\n");
+ break;
+
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ if ((digit_optind != 0) && (digit_optind != this_option_optind) )
+ printf ("digits occur in two different argv-elements.\n");
+ digit_optind = this_option_optind;
+ printf ("option %c\n", c);
+ break;
+
+ case 'a':
+ printf ("option a\n");
+ break;
+
+ case 'b':
+ printf ("option b\n");
+ break;
+
+ case 'c':
+ printf ("option c with value `%s'\n", optarg);
+ break;
+
+ case 'd':
+ printf ("option d with value `%s'\n", optarg);
+ break;
+
+ case '?':
+ break;
+
+ default:
+ printf ("?? getopt returned character code 0%o ??\n", c);
}
+ }
if (optind < argc)
- {
- printf ("non-option ARGV-elements: ");
- while (optind < argc)
- printf ("%s ", argv[optind++]);
- printf ("\n");
- }
+ {
+ printf ("non-option ARGV-elements: ");
+ while (optind < argc)
+ printf ("%s ", argv[optind++]);
+ printf ("\n");
+ }
exit (0);
}
diff --git a/src/main/iconv.c b/src/main/iconv.c
@@ -33,10 +33,10 @@
* @param inSize number of bytes in 'in'
* @return NULL on error, otherwise the converted string (to be free'd by caller)
*/
-static char *
+static char *
iconv_helper (iconv_t cd,
- const char *in,
- size_t inSize)
+ const char *in,
+ size_t inSize)
{
#if HAVE_ICONV
char *buf;
@@ -57,24 +57,25 @@ iconv_helper (iconv_t cd,
ibuf = buf;
memset (buf, 0, outSize);
if (iconv (cd,
- (char**) &in,
- &inSize,
- &ibuf,
- &outLeft) == SIZE_MAX)
- {
- /* conversion failed */
- free (buf);
- return strdup (i);
- }
+ (char**) &in,
+ &inSize,
+ &ibuf,
+ &outLeft) == SIZE_MAX)
+ {
+ /* conversion failed */
+ free (buf);
+ return strdup (i);
+ }
return buf;
#else
/* good luck, just copying string... */
char *buf;
-
+
buf = malloc (inSize + 1);
memcpy (buf, in, inSize);
buf[inSize] = '\0';
#endif
}
+
/* end of iconv.c */
diff --git a/src/main/test2_extractor.c b/src/main/test2_extractor.c
@@ -36,7 +36,6 @@
#include <unistd.h>
#include <stdlib.h>
-
/**
* Signature of the extract method that each plugin
@@ -52,77 +51,78 @@ EXTRACTOR_test2_extract_method (struct EXTRACTOR_ExtractContext *ec)
if ((NULL == ec->config) || (0 != strcmp (ec->config, "test2")))
return; /* only run in test mode */
if (4 != ec->read (ec->cls, &dp, 4))
- {
- fprintf (stderr, "Reading at offset 0 failed\n");
- ABORT ();
- }
+ {
+ fprintf (stderr, "Reading at offset 0 failed\n");
+ ABORT ();
+ }
if (0 != strncmp ("test", dp, 4))
- {
- fprintf (stderr, "Unexpected data at offset 0\n");
- ABORT ();
- }
+ {
+ fprintf (stderr, "Unexpected data at offset 0\n");
+ ABORT ();
+ }
if ( (1024 * 150 != ec->get_size (ec->cls)) &&
(UINT64_MAX != ec->get_size (ec->cls)) )
- {
- fprintf (stderr, "Unexpected file size returned (expected 150k)\n");
- ABORT ();
- }
+ {
+ fprintf (stderr, "Unexpected file size returned (expected 150k)\n");
+ ABORT ();
+ }
if (1024 * 100 + 4 != ec->seek (ec->cls, 1024 * 100 + 4, SEEK_SET))
- {
- fprintf (stderr, "Failure to seek (SEEK_SET)\n");
- ABORT ();
- }
+ {
+ fprintf (stderr, "Failure to seek (SEEK_SET)\n");
+ ABORT ();
+ }
if (1 != ec->read (ec->cls, &dp, 1))
- {
- fprintf (stderr, "Failure to read at 100k + 4\n");
- ABORT ();
- }
- if ((1024 * 100 + 4) % 256 != * (unsigned char *) dp)
- {
- fprintf (stderr, "Unexpected data at offset 100k + 4\n");
- ABORT ();
- }
+ {
+ fprintf (stderr, "Failure to read at 100k + 4\n");
+ ABORT ();
+ }
+ if ((1024 * 100 + 4) % 256 != *(unsigned char *) dp)
+ {
+ fprintf (stderr, "Unexpected data at offset 100k + 4\n");
+ ABORT ();
+ }
if (((1024 * 100 + 4) + 1 - (1024 * 50 + 7)) !=
- ec->seek (ec->cls, - (1024 * 50 + 7), SEEK_CUR))
- {
- fprintf (stderr, "Failure to seek (SEEK_SET)\n");
- ABORT ();
- }
+ ec->seek (ec->cls, -(1024 * 50 + 7), SEEK_CUR))
+ {
+ fprintf (stderr, "Failure to seek (SEEK_SET)\n");
+ ABORT ();
+ }
if (1 != ec->read (ec->cls, &dp, 1))
- {
- fprintf (stderr, "Failure to read at 50k - 3\n");
- ABORT ();
- }
- if (((1024 * 100 + 4) + 1 - (1024 * 50 + 7)) % 256 != * (unsigned char *) dp)
- {
- fprintf (stderr, "Unexpected data at offset 100k - 3\n");
- ABORT ();
- }
+ {
+ fprintf (stderr, "Failure to read at 50k - 3\n");
+ ABORT ();
+ }
+ if (((1024 * 100 + 4) + 1 - (1024 * 50 + 7)) % 256 != *(unsigned char *) dp)
+ {
+ fprintf (stderr, "Unexpected data at offset 100k - 3\n");
+ ABORT ();
+ }
if (1024 * 150 != ec->seek (ec->cls, 0, SEEK_END))
- {
- fprintf (stderr, "Failure to seek (SEEK_END)\n");
- ABORT ();
- }
+ {
+ fprintf (stderr, "Failure to seek (SEEK_END)\n");
+ ABORT ();
+ }
if (0 != ec->read (ec->cls, &dp, 1))
- {
- fprintf (stderr, "Failed to receive EOF at 150k\n");
- ABORT ();
- }
+ {
+ fprintf (stderr, "Failed to receive EOF at 150k\n");
+ ABORT ();
+ }
if (1024 * 150 - 2 != ec->seek (ec->cls, -2, SEEK_END))
- {
- fprintf (stderr, "Failure to seek (SEEK_END - 2)\n");
- ABORT ();
- }
+ {
+ fprintf (stderr, "Failure to seek (SEEK_END - 2)\n");
+ ABORT ();
+ }
if (1 != ec->read (ec->cls, &dp, 1))
- {
- fprintf (stderr, "Failure to read at 150k - 3\n");
- ABORT ();
- }
- if ((1024 * 150 - 2) % 256 != * (unsigned char *) dp)
- {
- fprintf (stderr, "Unexpected data at offset 150k - 3\n");
- ABORT ();
- }
+ {
+ fprintf (stderr, "Failure to read at 150k - 3\n");
+ ABORT ();
+ }
+ if ((1024 * 150 - 2) % 256 != *(unsigned char *) dp)
+ {
+ fprintf (stderr, "Unexpected data at offset 150k - 3\n");
+ ABORT ();
+ }
}
+
/* end of test2_extractor.c */
diff --git a/src/main/test_bzip2.c b/src/main/test_bzip2.c
@@ -46,74 +46,74 @@ static int ret = 2;
* @param data hello world or good bye
* @param data_len number of bytes in data
* @return 0 on hello world, 1 on goodbye
- */
+ */
static int
process_replies (void *cls,
- const char *plugin_name,
- enum EXTRACTOR_MetaType type,
- enum EXTRACTOR_MetaFormat format,
- const char *data_mime_type,
- const char *data,
- size_t data_len)
+ const char *plugin_name,
+ enum EXTRACTOR_MetaType type,
+ enum EXTRACTOR_MetaFormat format,
+ const char *data_mime_type,
+ const char *data,
+ size_t data_len)
{
if (0 != strcmp (cls,
- "main-cls"))
- {
- fprintf (stderr, "closure invalid\n");
- ret = 3;
- return 1;
- }
+ "main-cls"))
+ {
+ fprintf (stderr, "closure invalid\n");
+ ret = 3;
+ return 1;
+ }
if (0 != strcmp (plugin_name,
- "test"))
- {
- fprintf (stderr, "plugin name invalid\n");
- ret = 4;
- return 1;
- }
+ "test"))
+ {
+ fprintf (stderr, "plugin name invalid\n");
+ ret = 4;
+ return 1;
+ }
if (EXTRACTOR_METATYPE_COMMENT != type)
- {
- fprintf (stderr, "type invalid\n");
- ret = 5;
- return 1;
- }
+ {
+ fprintf (stderr, "type invalid\n");
+ ret = 5;
+ return 1;
+ }
if (EXTRACTOR_METAFORMAT_UTF8 != format)
- {
- fprintf (stderr, "format invalid\n");
- ret = 6;
- return 1;
- }
+ {
+ fprintf (stderr, "format invalid\n");
+ ret = 6;
+ return 1;
+ }
if ( (NULL == data_mime_type) ||
(0 != strcmp ("<no mime>",
- data_mime_type) ) )
- {
- fprintf (stderr, "bad mime type\n");
- ret = 7;
- return 1;
- }
+ data_mime_type) ) )
+ {
+ fprintf (stderr, "bad mime type\n");
+ ret = 7;
+ return 1;
+ }
if ( (2 == ret) &&
(data_len == strlen (HLO) + 1) &&
(0 == strncmp (data,
- HLO,
- strlen (HLO))) )
- {
+ HLO,
+ strlen (HLO))) )
+ {
#if 0
- fprintf (stderr, "Received '%s'\n", HLO);
+ fprintf (stderr, "Received '%s'\n", HLO);
#endif
- ret = 1;
- return 0;
- }
+ ret = 1;
+ return 0;
+ }
if ( (1 == ret) &&
(data_len == strlen (GOB) + 1) &&
(0 == strncmp (data,
- GOB,
- strlen (GOB))) )
- {
+ GOB,
+ strlen (GOB))) )
+ {
#if 0
- fprintf (stderr, "Received '%s'\n", GOB);
+ fprintf (stderr, "Received '%s'\n", GOB);
#endif
- ret = 0;
- return 1;
- }
+ ret = 0;
+ return 1;
+ }
fprintf (stderr, "Invalid meta data\n");
ret = 8;
return 1;
@@ -132,23 +132,25 @@ main (int argc, char *argv[])
{
struct EXTRACTOR_PluginList *pl;
- /* change environment to find 'extractor_test' plugin which is
+ /* change environment to find 'extractor_test' plugin which is
not installed but should be in the current directory (or .libs)
on 'make check' */
if (0 != putenv ("LIBEXTRACTOR_PREFIX=." PATH_SEPARATOR_STR ".libs/"))
- fprintf (stderr,
- "Failed to update my environment, plugin loading may fail: %s\n",
- strerror (errno));
+ fprintf (stderr,
+ "Failed to update my environment, plugin loading may fail: %s\n",
+ strerror (errno));
pl = EXTRACTOR_plugin_add_config (NULL, "test(test)",
- EXTRACTOR_OPTION_DEFAULT_POLICY);
+ EXTRACTOR_OPTION_DEFAULT_POLICY);
if (NULL == pl)
- {
- fprintf (stderr, "failed to load test plugin\n");
- return 1;
- }
- EXTRACTOR_extract (pl, "test_file.dat.bz2", NULL, 0, &process_replies, "main-cls");
+ {
+ fprintf (stderr, "failed to load test plugin\n");
+ return 1;
+ }
+ EXTRACTOR_extract (pl, "test_file.dat.bz2", NULL, 0, &process_replies,
+ "main-cls");
EXTRACTOR_plugin_remove_all (pl);
return ret;
}
+
/* end of test_bzip2.c */
diff --git a/src/main/test_extractor.c b/src/main/test_extractor.c
@@ -37,7 +37,6 @@
#include <stdlib.h>
-
/**
* Signature of the extract method that each plugin
* must provide.
@@ -52,94 +51,95 @@ EXTRACTOR_test_extract_method (struct EXTRACTOR_ExtractContext *ec)
if ((NULL == ec->config) || (0 != strcmp (ec->config, "test")))
return; /* only run in test mode */
if (4 != ec->read (ec->cls, &dp, 4))
- {
- fprintf (stderr, "Reading at offset 0 failed\n");
- ABORT ();
- }
+ {
+ fprintf (stderr, "Reading at offset 0 failed\n");
+ ABORT ();
+ }
if (0 != strncmp ("test", dp, 4))
- {
- fprintf (stderr, "Unexpected data at offset 0\n");
- ABORT ();
- }
+ {
+ fprintf (stderr, "Unexpected data at offset 0\n");
+ ABORT ();
+ }
if ( (1024 * 150 != ec->get_size (ec->cls)) &&
(UINT64_MAX != ec->get_size (ec->cls)) )
- {
- fprintf (stderr, "Unexpected file size returned (expected 150k)\n");
- ABORT ();
- }
+ {
+ fprintf (stderr, "Unexpected file size returned (expected 150k)\n");
+ ABORT ();
+ }
if (1024 * 100 + 4 != ec->seek (ec->cls, 1024 * 100 + 4, SEEK_SET))
- {
- fprintf (stderr, "Failure to seek (SEEK_SET)\n");
- ABORT ();
- }
+ {
+ fprintf (stderr, "Failure to seek (SEEK_SET)\n");
+ ABORT ();
+ }
if (1 != ec->read (ec->cls, &dp, 1))
- {
- fprintf (stderr, "Failure to read at 100k + 4\n");
- ABORT ();
- }
- if ((1024 * 100 + 4) % 256 != * (unsigned char *) dp)
- {
- fprintf (stderr, "Unexpected data at offset 100k + 4\n");
- ABORT ();
- }
+ {
+ fprintf (stderr, "Failure to read at 100k + 4\n");
+ ABORT ();
+ }
+ if ((1024 * 100 + 4) % 256 != *(unsigned char *) dp)
+ {
+ fprintf (stderr, "Unexpected data at offset 100k + 4\n");
+ ABORT ();
+ }
if (((1024 * 100 + 4) + 1 - (1024 * 50 + 7)) !=
- ec->seek (ec->cls, - (1024 * 50 + 7), SEEK_CUR))
- {
- fprintf (stderr, "Failure to seek (SEEK_SET)\n");
- ABORT ();
- }
+ ec->seek (ec->cls, -(1024 * 50 + 7), SEEK_CUR))
+ {
+ fprintf (stderr, "Failure to seek (SEEK_SET)\n");
+ ABORT ();
+ }
if (1 != ec->read (ec->cls, &dp, 1))
- {
- fprintf (stderr, "Failure to read at 50k - 3\n");
- ABORT ();
- }
- if (((1024 * 100 + 4) + 1 - (1024 * 50 + 7)) % 256 != * (unsigned char *) dp)
- {
- fprintf (stderr, "Unexpected data at offset 100k - 3\n");
- ABORT ();
- }
+ {
+ fprintf (stderr, "Failure to read at 50k - 3\n");
+ ABORT ();
+ }
+ if (((1024 * 100 + 4) + 1 - (1024 * 50 + 7)) % 256 != *(unsigned char *) dp)
+ {
+ fprintf (stderr, "Unexpected data at offset 100k - 3\n");
+ ABORT ();
+ }
if (1024 * 150 != ec->seek (ec->cls, 0, SEEK_END))
- {
- fprintf (stderr, "Failure to seek (SEEK_END)\n");
- ABORT ();
- }
+ {
+ fprintf (stderr, "Failure to seek (SEEK_END)\n");
+ ABORT ();
+ }
if (0 != ec->read (ec->cls, &dp, 1))
- {
- fprintf (stderr, "Failed to receive EOF at 150k\n");
- ABORT ();
- }
+ {
+ fprintf (stderr, "Failed to receive EOF at 150k\n");
+ ABORT ();
+ }
if (1024 * 150 - 2 != ec->seek (ec->cls, -2, SEEK_END))
- {
- fprintf (stderr, "Failure to seek (SEEK_END - 2)\n");
- ABORT ();
- }
+ {
+ fprintf (stderr, "Failure to seek (SEEK_END - 2)\n");
+ ABORT ();
+ }
if (1 != ec->read (ec->cls, &dp, 1))
- {
- fprintf (stderr, "Failure to read at 150k - 3\n");
- ABORT ();
- }
- if ((1024 * 150 - 2) % 256 != * (unsigned char *) dp)
- {
- fprintf (stderr, "Unexpected data at offset 150k - 3\n");
- ABORT ();
- }
+ {
+ fprintf (stderr, "Failure to read at 150k - 3\n");
+ ABORT ();
+ }
+ if ((1024 * 150 - 2) % 256 != *(unsigned char *) dp)
+ {
+ fprintf (stderr, "Unexpected data at offset 150k - 3\n");
+ ABORT ();
+ }
if (0 != ec->proc (ec->cls, "test", EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_UTF8, "<no mime>", "Hello world!",
- strlen ("Hello world!") + 1))
- {
- fprintf (stderr, "Unexpected return value from 'proc'\n");
- ABORT ();
- }
+ EXTRACTOR_METAFORMAT_UTF8, "<no mime>", "Hello world!",
+ strlen ("Hello world!") + 1))
+ {
+ fprintf (stderr, "Unexpected return value from 'proc'\n");
+ ABORT ();
+ }
/* The test assumes that client orders us to stop extraction
* after seeing "Goodbye!".
*/
if (1 != ec->proc (ec->cls, "test", EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_UTF8, "<no mime>", "Goodbye!",
- strlen ("Goodbye!") + 1))
- {
- fprintf (stderr, "Unexpected return value from 'proc'\n");
- ABORT ();
- }
+ EXTRACTOR_METAFORMAT_UTF8, "<no mime>", "Goodbye!",
+ strlen ("Goodbye!") + 1))
+ {
+ fprintf (stderr, "Unexpected return value from 'proc'\n");
+ ABORT ();
+ }
}
+
/* end of test_extractor.c */
diff --git a/src/main/test_file.c b/src/main/test_file.c
@@ -46,74 +46,74 @@ static int ret = 2;
* @param data hello world or good bye
* @param data_len number of bytes in data
* @return 0 on hello world, 1 on goodbye
- */
+ */
static int
process_replies (void *cls,
- const char *plugin_name,
- enum EXTRACTOR_MetaType type,
- enum EXTRACTOR_MetaFormat format,
- const char *data_mime_type,
- const char *data,
- size_t data_len)
+ const char *plugin_name,
+ enum EXTRACTOR_MetaType type,
+ enum EXTRACTOR_MetaFormat format,
+ const char *data_mime_type,
+ const char *data,
+ size_t data_len)
{
if (0 != strcmp (cls,
- "main-cls"))
- {
- fprintf (stderr, "closure invalid\n");
- ret = 3;
- return 1;
- }
+ "main-cls"))
+ {
+ fprintf (stderr, "closure invalid\n");
+ ret = 3;
+ return 1;
+ }
if (0 != strcmp (plugin_name,
- "test"))
- {
- fprintf (stderr, "plugin name invalid\n");
- ret = 4;
- return 1;
- }
+ "test"))
+ {
+ fprintf (stderr, "plugin name invalid\n");
+ ret = 4;
+ return 1;
+ }
if (EXTRACTOR_METATYPE_COMMENT != type)
- {
- fprintf (stderr, "type invalid\n");
- ret = 5;
- return 1;
- }
+ {
+ fprintf (stderr, "type invalid\n");
+ ret = 5;
+ return 1;
+ }
if (EXTRACTOR_METAFORMAT_UTF8 != format)
- {
- fprintf (stderr, "format invalid\n");
- ret = 6;
- return 1;
- }
+ {
+ fprintf (stderr, "format invalid\n");
+ ret = 6;
+ return 1;
+ }
if ( (NULL == data_mime_type) ||
(0 != strcmp ("<no mime>",
- data_mime_type) ) )
- {
- fprintf (stderr, "bad mime type\n");
- ret = 7;
- return 1;
- }
+ data_mime_type) ) )
+ {
+ fprintf (stderr, "bad mime type\n");
+ ret = 7;
+ return 1;
+ }
if ( (2 == ret) &&
(data_len == strlen (HLO) + 1) &&
(0 == strncmp (data,
- HLO,
- strlen (HLO))) )
- {
+ HLO,
+ strlen (HLO))) )
+ {
#if 0
- fprintf (stderr, "Received '%s'\n", HLO);
+ fprintf (stderr, "Received '%s'\n", HLO);
#endif
- ret = 1;
- return 0;
- }
+ ret = 1;
+ return 0;
+ }
if ( (1 == ret) &&
(data_len == strlen (GOB) + 1) &&
(0 == strncmp (data,
- GOB,
- strlen (GOB))) )
- {
+ GOB,
+ strlen (GOB))) )
+ {
#if 0
- fprintf (stderr, "Received '%s'\n", GOB);
+ fprintf (stderr, "Received '%s'\n", GOB);
#endif
- ret = 0;
- return 1;
- }
+ ret = 0;
+ return 1;
+ }
fprintf (stderr, "Invalid meta data\n");
ret = 8;
return 1;
@@ -132,23 +132,25 @@ main (int argc, char *argv[])
{
struct EXTRACTOR_PluginList *pl;
- /* change environment to find 'extractor_test' plugin which is
+ /* change environment to find 'extractor_test' plugin which is
not installed but should be in the current directory (or .libs)
on 'make check' */
if (0 != putenv ("LIBEXTRACTOR_PREFIX=." PATH_SEPARATOR_STR ".libs/"))
- fprintf (stderr,
- "Failed to update my environment, plugin loading may fail: %s\n",
- strerror (errno));
+ fprintf (stderr,
+ "Failed to update my environment, plugin loading may fail: %s\n",
+ strerror (errno));
pl = EXTRACTOR_plugin_add_config (NULL, "test(test)",
- EXTRACTOR_OPTION_DEFAULT_POLICY);
+ EXTRACTOR_OPTION_DEFAULT_POLICY);
if (NULL == pl)
- {
- fprintf (stderr, "failed to load test plugin\n");
- return 1;
- }
- EXTRACTOR_extract (pl, "test_file.dat", NULL, 0, &process_replies, "main-cls");
+ {
+ fprintf (stderr, "failed to load test plugin\n");
+ return 1;
+ }
+ EXTRACTOR_extract (pl, "test_file.dat", NULL, 0, &process_replies,
+ "main-cls");
EXTRACTOR_plugin_remove_all (pl);
return ret;
}
+
/* end of test_file.c */
diff --git a/src/main/test_gzip.c b/src/main/test_gzip.c
@@ -46,78 +46,78 @@ static int ret = 2;
* @param data hello world or good bye
* @param data_len number of bytes in data
* @return 0 on hello world, 1 on goodbye
- */
+ */
static int
process_replies (void *cls,
- const char *plugin_name,
- enum EXTRACTOR_MetaType type,
- enum EXTRACTOR_MetaFormat format,
- const char *data_mime_type,
- const char *data,
- size_t data_len)
+ const char *plugin_name,
+ enum EXTRACTOR_MetaType type,
+ enum EXTRACTOR_MetaFormat format,
+ const char *data_mime_type,
+ const char *data,
+ size_t data_len)
{
if (0 != strcmp (cls,
- "main-cls"))
- {
- fprintf (stderr, "closure invalid\n");
- ret = 3;
- return 1;
- }
+ "main-cls"))
+ {
+ fprintf (stderr, "closure invalid\n");
+ ret = 3;
+ return 1;
+ }
if (0 == strcmp (plugin_name,
- "<zlib>"))
+ "<zlib>"))
return 0; /* skip this one */
if (0 != strcmp (plugin_name,
- "test"))
- {
- fprintf (stderr, "plugin name invalid: `%s'\n",
- plugin_name);
- ret = 4;
- return 1;
- }
+ "test"))
+ {
+ fprintf (stderr, "plugin name invalid: `%s'\n",
+ plugin_name);
+ ret = 4;
+ return 1;
+ }
if (EXTRACTOR_METATYPE_COMMENT != type)
- {
- fprintf (stderr, "type invalid\n");
- ret = 5;
- return 1;
- }
+ {
+ fprintf (stderr, "type invalid\n");
+ ret = 5;
+ return 1;
+ }
if (EXTRACTOR_METAFORMAT_UTF8 != format)
- {
- fprintf (stderr, "format invalid\n");
- ret = 6;
- return 1;
- }
+ {
+ fprintf (stderr, "format invalid\n");
+ ret = 6;
+ return 1;
+ }
if ( (NULL == data_mime_type) ||
(0 != strcmp ("<no mime>",
- data_mime_type) ) )
- {
- fprintf (stderr, "bad mime type\n");
- ret = 7;
- return 1;
- }
+ data_mime_type) ) )
+ {
+ fprintf (stderr, "bad mime type\n");
+ ret = 7;
+ return 1;
+ }
if ( (2 == ret) &&
(data_len == strlen (HLO) + 1) &&
(0 == strncmp (data,
- HLO,
- strlen (HLO))) )
- {
+ HLO,
+ strlen (HLO))) )
+ {
#if 0
- fprintf (stderr, "Received '%s'\n", HLO);
+ fprintf (stderr, "Received '%s'\n", HLO);
#endif
- ret = 1;
- return 0;
- }
+ ret = 1;
+ return 0;
+ }
if ( (1 == ret) &&
(data_len == strlen (GOB) + 1) &&
(0 == strncmp (data,
- GOB,
- strlen (GOB))) )
- {
+ GOB,
+ strlen (GOB))) )
+ {
#if 0
- fprintf (stderr, "Received '%s'\n", GOB);
+ fprintf (stderr, "Received '%s'\n", GOB);
#endif
- ret = 0;
- return 1;
- }
+ ret = 0;
+ return 1;
+ }
fprintf (stderr, "Invalid meta data\n");
ret = 8;
return 1;
@@ -136,23 +136,25 @@ main (int argc, char *argv[])
{
struct EXTRACTOR_PluginList *pl;
- /* change environment to find 'extractor_test' plugin which is
+ /* change environment to find 'extractor_test' plugin which is
not installed but should be in the current directory (or .libs)
on 'make check' */
if (0 != putenv ("LIBEXTRACTOR_PREFIX=." PATH_SEPARATOR_STR ".libs/"))
- fprintf (stderr,
- "Failed to update my environment, plugin loading may fail: %s\n",
- strerror (errno));
+ fprintf (stderr,
+ "Failed to update my environment, plugin loading may fail: %s\n",
+ strerror (errno));
pl = EXTRACTOR_plugin_add_config (NULL, "test(test)",
- EXTRACTOR_OPTION_DEFAULT_POLICY);
+ EXTRACTOR_OPTION_DEFAULT_POLICY);
if (NULL == pl)
- {
- fprintf (stderr, "failed to load test plugin\n");
- return 1;
- }
- EXTRACTOR_extract (pl, "test_file.dat.gz", NULL, 0, &process_replies, "main-cls");
+ {
+ fprintf (stderr, "failed to load test plugin\n");
+ return 1;
+ }
+ EXTRACTOR_extract (pl, "test_file.dat.gz", NULL, 0, &process_replies,
+ "main-cls");
EXTRACTOR_plugin_remove_all (pl);
return ret;
}
+
/* end of test_gzip.c */
diff --git a/src/main/test_ipc.c b/src/main/test_ipc.c
@@ -46,77 +46,77 @@ static int ret = 2;
* @param data hello world or good bye
* @param data_len number of bytes in data
* @return 0 on hello world, 1 on goodbye
- */
+ */
static int
process_replies (void *cls,
- const char *plugin_name,
- enum EXTRACTOR_MetaType type,
- enum EXTRACTOR_MetaFormat format,
- const char *data_mime_type,
- const char *data,
- size_t data_len)
+ const char *plugin_name,
+ enum EXTRACTOR_MetaType type,
+ enum EXTRACTOR_MetaFormat format,
+ const char *data_mime_type,
+ const char *data,
+ size_t data_len)
{
if (0 != strcmp (cls,
- "main-cls"))
- {
- fprintf (stderr, "closure invalid\n");
- ret = 3;
- return 1;
- }
+ "main-cls"))
+ {
+ fprintf (stderr, "closure invalid\n");
+ ret = 3;
+ return 1;
+ }
if (0 == strcmp (plugin_name,
- "test2"))
+ "test2"))
return 0; /* ignore 'test2' plugins */
if (0 != strcmp (plugin_name,
- "test"))
- {
- fprintf (stderr, "plugin name invalid\n");
- ret = 4;
- return 1;
- }
+ "test"))
+ {
+ fprintf (stderr, "plugin name invalid\n");
+ ret = 4;
+ return 1;
+ }
if (EXTRACTOR_METATYPE_COMMENT != type)
- {
- fprintf (stderr, "type invalid\n");
- ret = 5;
- return 1;
- }
+ {
+ fprintf (stderr, "type invalid\n");
+ ret = 5;
+ return 1;
+ }
if (EXTRACTOR_METAFORMAT_UTF8 != format)
- {
- fprintf (stderr, "format invalid\n");
- ret = 6;
- return 1;
- }
+ {
+ fprintf (stderr, "format invalid\n");
+ ret = 6;
+ return 1;
+ }
if ( (NULL == data_mime_type) ||
(0 != strcmp ("<no mime>",
- data_mime_type) ) )
- {
- fprintf (stderr, "bad mime type\n");
- ret = 7;
- return 1;
- }
+ data_mime_type) ) )
+ {
+ fprintf (stderr, "bad mime type\n");
+ ret = 7;
+ return 1;
+ }
if ( (2 == ret) &&
(data_len == strlen (HLO) + 1) &&
(0 == strncmp (data,
- HLO,
- strlen (HLO))) )
- {
+ HLO,
+ strlen (HLO))) )
+ {
#if 0
- fprintf (stderr, "Received '%s'\n", HLO);
+ fprintf (stderr, "Received '%s'\n", HLO);
#endif
- ret = 1;
- return 0;
- }
+ ret = 1;
+ return 0;
+ }
if ( (1 == ret) &&
(data_len == strlen (GOB) + 1) &&
(0 == strncmp (data,
- GOB,
- strlen (GOB))) )
- {
+ GOB,
+ strlen (GOB))) )
+ {
#if 0
- fprintf (stderr, "Received '%s'\n", GOB);
+ fprintf (stderr, "Received '%s'\n", GOB);
#endif
- ret = 0;
- return 1;
- }
+ ret = 0;
+ return 1;
+ }
fprintf (stderr, "Invalid meta data\n");
ret = 8;
return 1;
@@ -138,35 +138,37 @@ main (int argc, char *argv[])
size_t i;
/* initialize test buffer as expected by test plugin */
- for (i=0;i<sizeof(buf);i++)
+ for (i = 0; i<sizeof(buf); i++)
buf[i] = (unsigned char) (i % 256);
memcpy (buf, "test", 4);
- /* change environment to find 'extractor_test' plugin which is
+ /* change environment to find 'extractor_test' plugin which is
not installed but should be in the current directory (or .libs)
on 'make check' */
if (0 != putenv ("LIBEXTRACTOR_PREFIX=." PATH_SEPARATOR_STR ".libs/"))
- fprintf (stderr,
- "Failed to update my environment, plugin loading may fail: %s\n",
- strerror (errno));
+ fprintf (stderr,
+ "Failed to update my environment, plugin loading may fail: %s\n",
+ strerror (errno));
pl = EXTRACTOR_plugin_add_config (NULL, "test(test)",
- EXTRACTOR_OPTION_DEFAULT_POLICY);
+ EXTRACTOR_OPTION_DEFAULT_POLICY);
pl = EXTRACTOR_plugin_add_config (pl, "test2(test2)",
- EXTRACTOR_OPTION_DEFAULT_POLICY);
+ EXTRACTOR_OPTION_DEFAULT_POLICY);
if (NULL == pl)
- {
- fprintf (stderr, "failed to load test plugin\n");
- return 1;
- }
+ {
+ fprintf (stderr, "failed to load test plugin\n");
+ return 1;
+ }
EXTRACTOR_extract (pl, NULL, buf, sizeof (buf), &process_replies, "main-cls");
if (0 == ret)
- {
- /* do it again... */
- ret = 2;
- EXTRACTOR_extract (pl, NULL, buf, sizeof (buf), &process_replies, "main-cls");
- }
+ {
+ /* do it again... */
+ ret = 2;
+ EXTRACTOR_extract (pl, NULL, buf, sizeof (buf), &process_replies,
+ "main-cls");
+ }
EXTRACTOR_plugin_remove_all (pl);
return ret;
}
+
/* end of test_ipc.c */
diff --git a/src/main/test_plugin_load_multi.c b/src/main/test_plugin_load_multi.c
@@ -37,15 +37,15 @@ testLoadPlugins ()
el1 = EXTRACTOR_plugin_add_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY);
el2 = EXTRACTOR_plugin_add_defaults (EXTRACTOR_OPTION_DEFAULT_POLICY);
if ((NULL == el1) || (NULL == el2))
- {
- fprintf (stderr,
- "Failed to load default plugins!\n");
- if (NULL != el1)
- EXTRACTOR_plugin_remove_all (el1);
- if (NULL != el2)
- EXTRACTOR_plugin_remove_all (el2);
- return 1;
- }
+ {
+ fprintf (stderr,
+ "Failed to load default plugins!\n");
+ if (NULL != el1)
+ EXTRACTOR_plugin_remove_all (el1);
+ if (NULL != el2)
+ EXTRACTOR_plugin_remove_all (el2);
+ return 1;
+ }
EXTRACTOR_plugin_remove_all (el1);
EXTRACTOR_plugin_remove_all (el2);
return 0;
@@ -57,16 +57,17 @@ main (int argc, char *argv[])
{
int ret = 0;
- /* change environment to find 'extractor_test' plugin which is
+ /* change environment to find 'extractor_test' plugin which is
not installed but should be in the current directory (or .libs)
on 'make check' */
if (0 != putenv ("LIBEXTRACTOR_PREFIX=." PATH_SEPARATOR_STR ".libs/"))
- fprintf (stderr,
- "Failed to update my environment, plugin loading may fail: %s\n",
- strerror (errno));
+ fprintf (stderr,
+ "Failed to update my environment, plugin loading may fail: %s\n",
+ strerror (errno));
ret += testLoadPlugins ();
ret += testLoadPlugins ();
return ret;
}
+
/* end of test_plugin_load_multi.c */
diff --git a/src/main/test_plugin_loading.c b/src/main/test_plugin_loading.c
@@ -30,29 +30,32 @@ main (int argc, char *argv[])
{
struct EXTRACTOR_PluginList *arg;
- /* change environment to find 'extractor_test' plugin which is
+ /* change environment to find 'extractor_test' plugin which is
not installed but should be in the current directory (or .libs)
on 'make check' */
if (0 != putenv ("LIBEXTRACTOR_PREFIX=." PATH_SEPARATOR_STR ".libs/"))
- fprintf (stderr,
- "Failed to update my environment, plugin loading may fail: %s\n",
- strerror (errno));
+ fprintf (stderr,
+ "Failed to update my environment, plugin loading may fail: %s\n",
+ strerror (errno));
/* do some load/unload tests */
- arg = EXTRACTOR_plugin_add (NULL, "test", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY);
- if (arg != EXTRACTOR_plugin_add (arg, "test", NULL, EXTRACTOR_OPTION_DEFAULT_POLICY))
- {
- fprintf (stderr,
- "Could load plugin twice, that should not be allowed\n");
- }
+ arg = EXTRACTOR_plugin_add (NULL, "test", NULL,
+ EXTRACTOR_OPTION_DEFAULT_POLICY);
+ if (arg != EXTRACTOR_plugin_add (arg, "test", NULL,
+ EXTRACTOR_OPTION_DEFAULT_POLICY))
+ {
+ fprintf (stderr,
+ "Could load plugin twice, that should not be allowed\n");
+ }
arg = EXTRACTOR_plugin_remove (arg, "test");
if (NULL != arg)
- {
- fprintf (stderr,
- "add-remove test failed!\n");
- return -1;
- }
+ {
+ fprintf (stderr,
+ "add-remove test failed!\n");
+ return -1;
+ }
return 0;
}
+
/* end of test_plugin_loading.c */
diff --git a/src/main/test_trivial.c b/src/main/test_trivial.c
@@ -30,34 +30,36 @@ static int
testLoadPlugins (enum EXTRACTOR_Options policy)
{
struct EXTRACTOR_PluginList *pl;
-
+
if (NULL == (pl = EXTRACTOR_plugin_add_defaults (policy)))
- {
- fprintf (stderr,
- "Failed to load default plugins!\n");
- return 1;
- }
+ {
+ fprintf (stderr,
+ "Failed to load default plugins!\n");
+ return 1;
+ }
EXTRACTOR_plugin_remove_all (pl);
return 0;
}
+
int
main (int argc, char *argv[])
{
int ret = 0;
- /* change environment to find 'extractor_test' plugin which is
+ /* change environment to find 'extractor_test' plugin which is
not installed but should be in the current directory (or .libs)
on 'make check' */
if (0 != putenv ("LIBEXTRACTOR_PREFIX=." PATH_SEPARATOR_STR ".libs/"))
- fprintf (stderr,
- "Failed to update my environment, plugin loading may fail: %s\n",
- strerror (errno));
+ fprintf (stderr,
+ "Failed to update my environment, plugin loading may fail: %s\n",
+ strerror (errno));
ret += testLoadPlugins (EXTRACTOR_OPTION_DEFAULT_POLICY);
ret += testLoadPlugins (EXTRACTOR_OPTION_DEFAULT_POLICY);
ret += testLoadPlugins (EXTRACTOR_OPTION_DEFAULT_POLICY);
return ret;
}
+
/* end of test_trivial.c */
diff --git a/src/plugins/archive_extractor.c b/src/plugins/archive_extractor.c
@@ -36,9 +36,9 @@
* @return number of bytes read
*/
static ssize_t
-read_cb (struct archive *a,
- void *client_data,
- const void **buff)
+read_cb (struct archive *a,
+ void *client_data,
+ const void **buff)
{
struct EXTRACTOR_ExtractContext *ec = client_data;
ssize_t ret;
@@ -71,9 +71,9 @@ read_cb (struct archive *a,
* @return number of bytes skipped
*/
static __LA_INT64_T
-skip_cb (struct archive *a,
- void *client_data,
- __LA_INT64_T request)
+skip_cb (struct archive *a,
+ void *client_data,
+ __LA_INT64_T request)
{
struct EXTRACTOR_ExtractContext *ec = client_data;
@@ -84,11 +84,11 @@ skip_cb (struct archive *a,
/**
- * Main entry method for the ARCHIVE extraction plugin.
+ * Main entry method for the ARCHIVE extraction plugin.
*
* @param ec extraction context provided to the plugin
*/
-void
+void
EXTRACTOR_archive_extract_method (struct EXTRACTOR_ExtractContext *ec)
{
struct archive *a;
@@ -105,41 +105,41 @@ EXTRACTOR_archive_extract_method (struct EXTRACTOR_ExtractContext *ec)
archive_read_support_compression_all (a);
#endif
archive_read_support_format_all (a);
- if(archive_read_open2 (a, ec, NULL, &read_cb, &skip_cb, NULL)!= ARCHIVE_OK)
- return;
-
- while (ARCHIVE_OK == archive_read_next_header(a, &entry))
- {
- if ( (NULL == format) &&
- (NULL != (fname = archive_format_name (a))) )
- format = strdup (fname);
- s = archive_entry_pathname (entry);
- if (0 != ec->proc (ec->cls,
- "tar",
- EXTRACTOR_METATYPE_FILENAME,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- s, strlen (s) + 1))
- break;
- }
+ if (archive_read_open2 (a, ec, NULL, &read_cb, &skip_cb, NULL)!= ARCHIVE_OK)
+ return;
+
+ while (ARCHIVE_OK == archive_read_next_header (a, &entry))
+ {
+ if ( (NULL == format) &&
+ (NULL != (fname = archive_format_name (a))) )
+ format = strdup (fname);
+ s = archive_entry_pathname (entry);
+ if (0 != ec->proc (ec->cls,
+ "tar",
+ EXTRACTOR_METATYPE_FILENAME,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ s, strlen (s) + 1))
+ break;
+ }
#if ARCHIVE_VERSION_NUMBER >= 3000000
archive_read_free (a);
#else
archive_read_finish (a);
#endif
if (NULL != format)
+ {
+ if (0 != ec->proc (ec->cls,
+ "tar",
+ EXTRACTOR_METATYPE_FORMAT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain", format, strlen (format) + 1))
{
- if (0 != ec->proc (ec->cls,
- "tar",
- EXTRACTOR_METATYPE_FORMAT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain", format, strlen (format) + 1))
- {
- free (format);
- return;
- }
free (format);
+ return;
}
+ free (format);
+ }
}
diff --git a/src/plugins/deb_extractor.c b/src/plugins/deb_extractor.c
@@ -122,8 +122,8 @@ static struct Matches tmap[] = {
static int
processControl (const char *data,
const size_t size,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls)
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
size_t pos;
char *key;
@@ -134,49 +134,49 @@ processControl (const char *data,
pos = 0;
while (pos < size)
- {
- for (colon = pos; ':' != data[colon]; colon++)
- if ((colon > size) || ('\n' == data[colon]))
- return 0;
+ {
+ for (colon = pos; ':' != data[colon]; colon++)
+ if ((colon > size) || ('\n' == data[colon]))
+ return 0;
+ colon++;
+ while ((colon < size) && (isspace ((unsigned char) data[colon])))
colon++;
- while ((colon < size) && (isspace ((unsigned char) data[colon])))
- colon++;
- eol = colon;
- while ((eol < size) &&
- (('\n' != data[eol]) ||
- ((eol + 1 < size) && (' ' == data[eol + 1]))))
- eol++;
- if ((eol == colon) || (eol > size))
+ eol = colon;
+ while ((eol < size) &&
+ (('\n' != data[eol]) ||
+ ((eol + 1 < size) && (' ' == data[eol + 1]))))
+ eol++;
+ if ((eol == colon) || (eol > size))
+ return 0;
+ if (NULL == (key = stndup (&data[pos], colon - pos)))
+ return 0;
+ for (i = 0; NULL != tmap[i].text; i++)
+ {
+ if (0 != strcmp (key, tmap[i].text))
+ continue;
+ if (NULL == (val = stndup (&data[colon], eol - colon)))
+ {
+ free (key);
return 0;
- if (NULL == (key = stndup (&data[pos], colon - pos)))
- return 0;
- for (i = 0; NULL != tmap[i].text; i++)
- {
- if (0 != strcmp (key, tmap[i].text))
- continue;
- if (NULL == (val = stndup (&data[colon], eol - colon)))
- {
- free (key);
- return 0;
- }
- if (0 != proc (proc_cls,
- "deb",
- tmap[i].type,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- val,
- strlen(val) + 1))
- {
- free (val);
- free (key);
- return 1;
- }
- free (val);
- break;
- }
- free (key);
- pos = eol + 1;
+ }
+ if (0 != proc (proc_cls,
+ "deb",
+ tmap[i].type,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ val,
+ strlen (val) + 1))
+ {
+ free (val);
+ free (key);
+ return 1;
+ }
+ free (val);
+ break;
}
+ free (key);
+ pos = eol + 1;
+ }
return 0;
}
@@ -291,9 +291,9 @@ struct USTarHeader
*/
static int
processControlTar (const char *data,
- size_t size,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls)
+ size_t size,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
struct TarHeader *tar;
struct USTarHeader *ustar;
@@ -301,42 +301,42 @@ processControlTar (const char *data,
pos = 0;
while (pos + sizeof (struct TarHeader) < size)
+ {
+ unsigned long long fsize;
+ char buf[13];
+
+ tar = (struct TarHeader *) &data[pos];
+ if (pos + sizeof (struct USTarHeader) < size)
{
- unsigned long long fsize;
- char buf[13];
-
- tar = (struct TarHeader *) & data[pos];
- if (pos + sizeof (struct USTarHeader) < size)
- {
- ustar = (struct USTarHeader *) & data[pos];
- if (0 == strncmp ("ustar", &ustar->magic[0], strlen ("ustar")))
- pos += 512; /* sizeof (struct USTarHeader); */
- else
- pos += 257; /* sizeof (struct TarHeader); minus gcc alignment... */
- }
+ ustar = (struct USTarHeader *) &data[pos];
+ if (0 == strncmp ("ustar", &ustar->magic[0], strlen ("ustar")))
+ pos += 512; /* sizeof (struct USTarHeader); */
else
- {
- pos += 257; /* sizeof (struct TarHeader); minus gcc alignment... */
- }
+ pos += 257; /* sizeof (struct TarHeader); minus gcc alignment... */
+ }
+ else
+ {
+ pos += 257; /* sizeof (struct TarHeader); minus gcc alignment... */
+ }
- memcpy (buf, &tar->filesize[0], 12);
- buf[12] = '\0';
- if (1 != sscanf (buf, "%12llo", &fsize)) /* octal! Yuck yuck! */
- return 0;
- if ((pos + fsize > size) || (fsize > size) || (pos + fsize < pos))
- return 0;
+ memcpy (buf, &tar->filesize[0], 12);
+ buf[12] = '\0';
+ if (1 != sscanf (buf, "%12llo", &fsize)) /* octal! Yuck yuck! */
+ return 0;
+ if ((pos + fsize > size) || (fsize > size) || (pos + fsize < pos))
+ return 0;
- if (0 == strncmp (&tar->name[0], "./control", strlen ("./control")))
- {
- /* found the 'control' file we were looking for */
- return processControl (&data[pos], fsize, proc, proc_cls);
- }
- if (0 != (fsize & 511))
- fsize = (fsize | 511) + 1; /* round up! */
- if (pos + fsize < pos)
- return 0;
- pos += fsize;
+ if (0 == strncmp (&tar->name[0], "./control", strlen ("./control")))
+ {
+ /* found the 'control' file we were looking for */
+ return processControl (&data[pos], fsize, proc, proc_cls);
}
+ if (0 != (fsize & 511))
+ fsize = (fsize | 511) + 1; /* round up! */
+ if (pos + fsize < pos)
+ return 0;
+ pos += fsize;
+ }
return 0;
}
@@ -371,42 +371,43 @@ processControlTGZ (struct EXTRACTOR_ExtractContext *ec,
return 0;
off = 0;
while (off < size)
- {
- if (0 >= (sret = ec->read (ec->cls, &data, size - off)))
- {
- free (cdata);
- return 0;
- }
- memcpy (&cdata[off],
- data,
- sret);
- off += sret;
- }
- bufSize = cdata[size - 4] + (cdata[size - 3] << 8) + (cdata[size - 2] << 16) + (cdata[size - 1] << 24);
- if (bufSize > MAX_CONTROL_SIZE)
+ {
+ if (0 >= (sret = ec->read (ec->cls, &data, size - off)))
{
free (cdata);
return 0;
}
+ memcpy (&cdata[off],
+ data,
+ sret);
+ off += sret;
+ }
+ bufSize = cdata[size - 4] + (cdata[size - 3] << 8) + (cdata[size - 2] << 16)
+ + (cdata[size - 1] << 24);
+ if (bufSize > MAX_CONTROL_SIZE)
+ {
+ free (cdata);
+ return 0;
+ }
if (NULL == (buf = malloc (bufSize)))
- {
- free (cdata);
- return 0;
- }
+ {
+ free (cdata);
+ return 0;
+ }
ret = 0;
memset (&strm, 0, sizeof (z_stream));
strm.next_in = (Bytef *) data;
strm.avail_in = size;
if (Z_OK == inflateInit2 (&strm, 15 + 32))
- {
- strm.next_out = (Bytef *) buf;
- strm.avail_out = bufSize;
- inflate (&strm, Z_FINISH);
- if (strm.total_out > 0)
- ret = processControlTar (buf, strm.total_out,
- ec->proc, ec->cls);
- inflateEnd (&strm);
- }
+ {
+ strm.next_out = (Bytef *) buf;
+ strm.avail_out = bufSize;
+ inflate (&strm, Z_FINISH);
+ if (strm.total_out > 0)
+ ret = processControlTar (buf, strm.total_out,
+ ec->proc, ec->cls);
+ inflateEnd (&strm);
+ }
free (buf);
free (cdata);
return ret;
@@ -481,49 +482,50 @@ EXTRACTOR_deb_extract_method (struct EXTRACTOR_ExtractContext *ec)
return;
pos = 8;
while (pos + sizeof (struct ObjectHeader) < fsize)
+ {
+ if (pos !=
+ ec->seek (ec->cls, pos, SEEK_SET))
+ return;
+ if (sizeof (struct ObjectHeader) !=
+ ec->read (ec->cls, &data, sizeof (struct ObjectHeader)))
+ return;
+ hdr = data;
+ if (0 != strncmp (&hdr->trailer[0], "`\n", 2))
+ return;
+ memcpy (buf, &hdr->filesize[0], 10);
+ buf[10] = '\0';
+ if (1 != sscanf (buf, "%10llu", &csize))
+ return;
+ pos += sizeof (struct ObjectHeader);
+ if ((pos + csize > fsize) || (csize > fsize) || (pos + csize < pos))
+ return;
+ if (0 == strncmp (&hdr->name[0],
+ "control.tar.gz",
+ strlen ("control.tar.gz")))
{
- if (pos !=
- ec->seek (ec->cls, pos, SEEK_SET))
- return;
- if (sizeof (struct ObjectHeader) !=
- ec->read (ec->cls, &data, sizeof (struct ObjectHeader)))
- return;
- hdr = data;
- if (0 != strncmp (&hdr->trailer[0], "`\n", 2))
+ if (0 != processControlTGZ (ec,
+ csize))
return;
- memcpy (buf, &hdr->filesize[0], 10);
- buf[10] = '\0';
- if (1 != sscanf (buf, "%10llu", &csize))
- return;
- pos += sizeof (struct ObjectHeader);
- if ((pos + csize > fsize) || (csize > fsize) || (pos + csize < pos))
+ done++;
+ }
+ if (0 == strncmp (&hdr->name[0],
+ "debian-binary", strlen ("debian-binary")))
+ {
+ if (0 != ec->proc (ec->cls,
+ "deb",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "application/x-debian-package",
+ strlen ("application/x-debian-package") + 1))
return;
- if (0 == strncmp (&hdr->name[0],
- "control.tar.gz",
- strlen ("control.tar.gz")))
- {
- if (0 != processControlTGZ (ec,
- csize))
- return;
- done++;
- }
- if (0 == strncmp (&hdr->name[0],
- "debian-binary", strlen ("debian-binary")))
- {
- if (0 != ec->proc (ec->cls,
- "deb",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "application/x-debian-package",
- strlen ("application/x-debian-package")+1))
- return;
- done++;
- }
- pos += csize;
- if (2 == done)
- break; /* no need to process the rest of the archive */
+ done++;
}
+ pos += csize;
+ if (2 == done)
+ break; /* no need to process the rest of the archive */
+ }
}
+
/* end of deb_extractor.c */
diff --git a/src/plugins/dvi_extractor.c b/src/plugins/dvi_extractor.c
@@ -53,12 +53,12 @@ static struct Matches tmap[] = {
{ "/Keywords (", EXTRACTOR_METATYPE_KEYWORDS },
{ "/Creator (", EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE },
{ "/Producer (", EXTRACTOR_METATYPE_PRODUCED_BY_SOFTWARE },
- { NULL, 0 }
+ { NULL, 0 }
};
/**
- * Parse a "ZZZ" tag. Specifically, the data may contain a
+ * Parse a "ZZZ" tag. Specifically, the data may contain a
* postscript dictionary with metadata.
*
* @param data overall input stream
@@ -71,8 +71,8 @@ static struct Matches tmap[] = {
static int
parseZZZ (const char *data,
size_t pos, size_t len,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls)
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
size_t slen;
size_t end;
@@ -85,37 +85,37 @@ parseZZZ (const char *data,
return 0;
pos += slen;
while (pos < end)
+ {
+ for (i = 0; NULL != tmap[i].text; i++)
{
- for (i = 0; NULL != tmap[i].text; i++)
- {
- slen = strlen (tmap[i].text);
- if ( (pos + slen > end) ||
- (0 != strncmp (&data[pos], tmap[i].text, slen)) )
- continue;
- pos += slen;
- slen = pos;
- while ((slen < end) && (data[slen] != ')'))
- slen++;
- slen = slen - pos;
- {
- char value[slen + 1];
-
- value[slen] = '\0';
- memcpy (value, &data[pos], slen);
- if (0 != proc (proc_cls,
- "dvi",
- tmap[i].type,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- value,
- slen + 1))
- return 1;
- }
- pos += slen + 1;
- break;
- }
- pos++;
+ slen = strlen (tmap[i].text);
+ if ( (pos + slen > end) ||
+ (0 != strncmp (&data[pos], tmap[i].text, slen)) )
+ continue;
+ pos += slen;
+ slen = pos;
+ while ((slen < end) && (data[slen] != ')'))
+ slen++;
+ slen = slen - pos;
+ {
+ char value[slen + 1];
+
+ value[slen] = '\0';
+ memcpy (value, &data[pos], slen);
+ if (0 != proc (proc_cls,
+ "dvi",
+ tmap[i].type,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ value,
+ slen + 1))
+ return 1;
+ }
+ pos += slen + 1;
+ break;
}
+ pos++;
+ }
return 0;
}
@@ -153,7 +153,7 @@ getShortAt (const void *data)
/**
- * Main entry method for the 'application/x-dvi' extraction plugin.
+ * Main entry method for the 'application/x-dvi' extraction plugin.
*
* @param ec extraction context provided to the plugin
*/
@@ -171,7 +171,7 @@ EXTRACTOR_dvi_extract_method (struct EXTRACTOR_ExtractContext *ec)
uint64_t size;
uint64_t off;
ssize_t iret;
-
+
if (40 >= (iret = ec->read (ec->cls, &buf, 1024)))
return;
data = buf;
@@ -189,15 +189,15 @@ EXTRACTOR_dvi_extract_method (struct EXTRACTOR_ExtractContext *ec)
memcpy (data, buf, iret);
off = iret;
while (off < size)
+ {
+ if (0 >= (iret = ec->read (ec->cls, &buf, 16 * 1024)))
{
- if (0 >= (iret = ec->read (ec->cls, &buf, 16 * 1024)))
- {
- free (data);
- return;
- }
- memcpy (&data[off], buf, iret);
- off += iret;
+ free (data);
+ return;
}
+ memcpy (&data[off], buf, iret);
+ off += iret;
+ }
pos = size - 1;
while ( (223 == data[pos]) &&
(pos > 0) )
@@ -222,28 +222,28 @@ EXTRACTOR_dvi_extract_method (struct EXTRACTOR_ExtractContext *ec)
opos = pos;
pos = getIntAt (&data[opos + 1]);
while (1)
- {
- if (UINT32_MAX == pos)
- break;
- if ( (pos + 45 > size) ||
- (pos + 45 < pos) )
- goto CLEANUP;
- if (data[pos] != 139) /* expect 'bop' */
- goto CLEANUP;
- pageCount++;
- opos = pos;
- pos = getIntAt (&data[opos + 41]);
- if (UINT32_MAX == pos)
- break;
- if (pos >= opos)
- goto CLEANUP; /* invalid! */
- }
+ {
+ if (UINT32_MAX == pos)
+ break;
+ if ( (pos + 45 > size) ||
+ (pos + 45 < pos) )
+ goto CLEANUP;
+ if (data[pos] != 139) /* expect 'bop' */
+ goto CLEANUP;
+ pageCount++;
+ opos = pos;
+ pos = getIntAt (&data[opos + 41]);
+ if (UINT32_MAX == pos)
+ break;
+ if (pos >= opos)
+ goto CLEANUP; /* invalid! */
+ }
/* ok, now we believe it's a dvi... */
snprintf (pages,
sizeof (pages),
- "%u",
+ "%u",
pageCount);
- if (0 != ec->proc (ec->cls,
+ if (0 != ec->proc (ec->cls,
"dvi",
EXTRACTOR_METATYPE_PAGE_COUNT,
EXTRACTOR_METAFORMAT_UTF8,
@@ -251,7 +251,7 @@ EXTRACTOR_dvi_extract_method (struct EXTRACTOR_ExtractContext *ec)
pages,
strlen (pages) + 1))
goto CLEANUP;
- if (0 != ec->proc (ec->cls,
+ if (0 != ec->proc (ec->cls,
"dvi",
EXTRACTOR_METATYPE_MIMETYPE,
EXTRACTOR_METAFORMAT_UTF8,
@@ -261,10 +261,10 @@ EXTRACTOR_dvi_extract_method (struct EXTRACTOR_ExtractContext *ec)
goto CLEANUP;
{
char comment[klen + 1];
-
+
comment[klen] = '\0';
memcpy (comment, &data[15], klen);
- if (0 != ec->proc (ec->cls,
+ if (0 != ec->proc (ec->cls,
"dvi",
EXTRACTOR_METATYPE_COMMENT,
EXTRACTOR_METAFORMAT_C_STRING,
@@ -277,47 +277,52 @@ EXTRACTOR_dvi_extract_method (struct EXTRACTOR_ExtractContext *ec)
pos = opos;
while ( (size >= 100) &&
(pos < size - 100) )
+ {
+ switch (data[pos])
{
- switch (data[pos])
- {
- case 139: /* begin page 'bop', we typically have to skip that one to
+ case 139: /* begin page 'bop', we typically have to skip that one to
find the zzz's */
- pos += 45; /* skip bop */
- break;
- case 239: /* zzz1 */
- len = data[pos + 1];
- if ( (pos + 2 + len < size) &&
- (0 != parseZZZ ((const char *) data, pos + 2, len, ec->proc, ec->cls)) )
- goto CLEANUP;
- pos += len + 2;
- break;
- case 240: /* zzz2 */
- len = getShortAt (&data[pos + 1]);
- if ( (pos + 3 + len < size) &&
- (0 != parseZZZ ((const char *) data, pos + 3, len, ec->proc, ec->cls)) )
- goto CLEANUP;
- pos += len + 3;
- break;
- case 241: /* zzz3, who uses that? */
- len = (getShortAt (&data[pos + 1])) + 65536 * data[pos + 3];
- if ( (pos + 4 + len < size) &&
- (0 != parseZZZ ((const char *) data, pos + 4, len, ec->proc, ec->cls)) )
- goto CLEANUP;
- pos += len + 4;
- break;
- case 242: /* zzz4, hurray! */
- len = getIntAt (&data[pos + 1]);
- if ( (pos + 1 + len < size) &&
- (0 != parseZZZ ((const char *) data, pos + 5, len, ec->proc, ec->cls)) )
- goto CLEANUP;
- pos += len + 5;
- break;
- default: /* unsupported opcode, abort scan */
- goto CLEANUP;
- }
+ pos += 45; /* skip bop */
+ break;
+ case 239: /* zzz1 */
+ len = data[pos + 1];
+ if ( (pos + 2 + len < size) &&
+ (0 != parseZZZ ((const char *) data, pos + 2, len, ec->proc,
+ ec->cls)) )
+ goto CLEANUP;
+ pos += len + 2;
+ break;
+ case 240: /* zzz2 */
+ len = getShortAt (&data[pos + 1]);
+ if ( (pos + 3 + len < size) &&
+ (0 != parseZZZ ((const char *) data, pos + 3, len, ec->proc,
+ ec->cls)) )
+ goto CLEANUP;
+ pos += len + 3;
+ break;
+ case 241: /* zzz3, who uses that? */
+ len = (getShortAt (&data[pos + 1])) + 65536 * data[pos + 3];
+ if ( (pos + 4 + len < size) &&
+ (0 != parseZZZ ((const char *) data, pos + 4, len, ec->proc,
+ ec->cls)) )
+ goto CLEANUP;
+ pos += len + 4;
+ break;
+ case 242: /* zzz4, hurray! */
+ len = getIntAt (&data[pos + 1]);
+ if ( (pos + 1 + len < size) &&
+ (0 != parseZZZ ((const char *) data, pos + 5, len, ec->proc,
+ ec->cls)) )
+ goto CLEANUP;
+ pos += len + 5;
+ break;
+ default: /* unsupported opcode, abort scan */
+ goto CLEANUP;
}
- CLEANUP:
+ }
+CLEANUP:
free (data);
}
+
/* end of dvi_extractor.c */
diff --git a/src/plugins/flac_extractor.c b/src/plugins/flac_extractor.c
@@ -47,9 +47,9 @@
*/
static FLAC__StreamDecoderReadStatus
flac_read (const FLAC__StreamDecoder *decoder,
- FLAC__byte buffer[],
- size_t *bytes,
- void *client_data)
+ FLAC__byte buffer[],
+ size_t *bytes,
+ void *client_data)
{
struct EXTRACTOR_ExtractContext *ec = client_data;
void *data;
@@ -57,15 +57,15 @@ flac_read (const FLAC__StreamDecoder *decoder,
data = NULL;
ret = ec->read (ec->cls,
- &data,
- *bytes);
+ &data,
+ *bytes);
if (-1 == ret)
return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
if (0 == ret)
- {
- errno = 0;
- return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
- }
+ {
+ errno = 0;
+ return FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM;
+ }
memcpy (buffer, data, ret);
*bytes = ret;
errno = 0;
@@ -83,8 +83,8 @@ flac_read (const FLAC__StreamDecoder *decoder,
*/
static FLAC__StreamDecoderSeekStatus
flac_seek (const FLAC__StreamDecoder *decoder,
- FLAC__uint64 absolute_byte_offset,
- void *client_data)
+ FLAC__uint64 absolute_byte_offset,
+ void *client_data)
{
struct EXTRACTOR_ExtractContext *ec = client_data;
@@ -105,14 +105,14 @@ flac_seek (const FLAC__StreamDecoder *decoder,
*/
static FLAC__StreamDecoderTellStatus
flac_tell (const FLAC__StreamDecoder *decoder,
- FLAC__uint64 *absolute_byte_offset,
- void *client_data)
+ FLAC__uint64 *absolute_byte_offset,
+ void *client_data)
{
struct EXTRACTOR_ExtractContext *ec = client_data;
*absolute_byte_offset = ec->seek (ec->cls,
- 0,
- SEEK_CUR);
+ 0,
+ SEEK_CUR);
return FLAC__STREAM_DECODER_TELL_STATUS_OK;
}
@@ -127,8 +127,8 @@ flac_tell (const FLAC__StreamDecoder *decoder,
*/
static FLAC__StreamDecoderLengthStatus
flac_length (const FLAC__StreamDecoder *decoder,
- FLAC__uint64 *stream_length,
- void *client_data)
+ FLAC__uint64 *stream_length,
+ void *client_data)
{
struct EXTRACTOR_ExtractContext *ec = client_data;
@@ -147,7 +147,7 @@ flac_length (const FLAC__StreamDecoder *decoder,
*/
static FLAC__bool
flac_eof (const FLAC__StreamDecoder *decoder,
- void *client_data)
+ void *client_data)
{
struct EXTRACTOR_ExtractContext *ec = client_data;
uint64_t size;
@@ -175,9 +175,9 @@ flac_eof (const FLAC__StreamDecoder *decoder,
*/
static FLAC__StreamDecoderWriteStatus
flac_write (const FLAC__StreamDecoder *decoder,
- const FLAC__Frame *frame,
- const FLAC__int32 *const buffer[],
- void *client_data)
+ const FLAC__Frame *frame,
+ const FLAC__int32 *const buffer[],
+ void *client_data)
{
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
}
@@ -230,7 +230,8 @@ static struct Matches tmap[] = {
* @param t type of the meta data
* @param s meta data value in utf8 format
*/
-#define ADD(t,s) do { ec->proc (ec->cls, "flac", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1); } while (0)
+#define ADD(t,s) do { ec->proc (ec->cls, "flac", t, EXTRACTOR_METAFORMAT_UTF8, \
+ "text/plain", s, strlen (s) + 1); } while (0)
/**
@@ -242,9 +243,9 @@ static struct Matches tmap[] = {
*/
static char *
xstrndup (const char *s,
- size_t n)
+ size_t n)
{
- char * d;
+ char *d;
if (NULL == (d = malloc (n + 1)))
return NULL;
@@ -274,21 +275,21 @@ check (const char *type,
unsigned int i;
char *tmp;
- for (i=0; NULL != tmap[i].text; i++)
- {
- if ( (type_length != strlen (tmap[i].text)) ||
- (0 != strncasecmp (tmap[i].text,
- type,
- type_length)) )
- continue;
- if (NULL ==
- (tmp = xstrndup (value,
- value_length)))
- continue;
- ADD (tmap[i].type, tmp);
- free (tmp);
- break;
- }
+ for (i = 0; NULL != tmap[i].text; i++)
+ {
+ if ( (type_length != strlen (tmap[i].text)) ||
+ (0 != strncasecmp (tmap[i].text,
+ type,
+ type_length)) )
+ continue;
+ if (NULL ==
+ (tmp = xstrndup (value,
+ value_length)))
+ continue;
+ ADD (tmap[i].type, tmp);
+ free (tmp);
+ break;
+ }
}
@@ -301,117 +302,117 @@ check (const char *type,
*/
static void
flac_metadata (const FLAC__StreamDecoder *decoder,
- const FLAC__StreamMetadata *metadata,
- void *client_data)
+ const FLAC__StreamMetadata *metadata,
+ void *client_data)
{
struct EXTRACTOR_ExtractContext *ec = client_data;
enum EXTRACTOR_MetaType type;
- const FLAC__StreamMetadata_VorbisComment * vc;
+ const FLAC__StreamMetadata_VorbisComment *vc;
unsigned int count;
- const FLAC__StreamMetadata_VorbisComment_Entry * entry;
- const char * eq;
+ const FLAC__StreamMetadata_VorbisComment_Entry *entry;
+ const char *eq;
unsigned int len;
unsigned int ilen;
char buf[128];
switch (metadata->type)
+ {
+ case FLAC__METADATA_TYPE_STREAMINFO:
{
- case FLAC__METADATA_TYPE_STREAMINFO:
- {
- snprintf (buf, sizeof (buf),
- _("%u Hz, %u channels"),
- metadata->data.stream_info.sample_rate,
- metadata->data.stream_info.channels);
- ADD (EXTRACTOR_METATYPE_RESOURCE_TYPE, buf);
- break;
- }
- case FLAC__METADATA_TYPE_APPLICATION:
- /* FIXME: could find out generator application here:
- http://flac.sourceforge.net/api/structFLAC____StreamMetadata__Application.html and
- http://flac.sourceforge.net/id.html
- */
+ snprintf (buf, sizeof (buf),
+ _ ("%u Hz, %u channels"),
+ metadata->data.stream_info.sample_rate,
+ metadata->data.stream_info.channels);
+ ADD (EXTRACTOR_METATYPE_RESOURCE_TYPE, buf);
break;
- case FLAC__METADATA_TYPE_VORBIS_COMMENT:
+ }
+ case FLAC__METADATA_TYPE_APPLICATION:
+ /* FIXME: could find out generator application here:
+ http://flac.sourceforge.net/api/structFLAC____StreamMetadata__Application.html and
+ http://flac.sourceforge.net/id.html
+ */
+ break;
+ case FLAC__METADATA_TYPE_VORBIS_COMMENT:
+ {
+ vc = &metadata->data.vorbis_comment;
+ count = vc->num_comments;
+ while (count-- > 0)
{
- vc = &metadata->data.vorbis_comment;
- count = vc->num_comments;
- while (count-- > 0)
- {
- entry = &vc->comments[count];
- eq = (const char*) entry->entry;
- if (NULL == eq)
- break;
- len = entry->length;
- ilen = 0;
- while ( ('=' != *eq) && ('\0' != *eq) &&
- (ilen < len) )
- {
- eq++;
- ilen++;
- }
- if ( ('=' != *eq) ||
- (ilen == len) )
- break;
- eq++;
- check ((const char*) entry->entry,
- ilen,
- eq,
- len - ilen,
- ec);
- }
- break;
+ entry = &vc->comments[count];
+ eq = (const char*) entry->entry;
+ if (NULL == eq)
+ break;
+ len = entry->length;
+ ilen = 0;
+ while ( ('=' != *eq) && ('\0' != *eq) &&
+ (ilen < len) )
+ {
+ eq++;
+ ilen++;
+ }
+ if ( ('=' != *eq) ||
+ (ilen == len) )
+ break;
+ eq++;
+ check ((const char*) entry->entry,
+ ilen,
+ eq,
+ len - ilen,
+ ec);
}
- case FLAC__METADATA_TYPE_PICTURE:
+ break;
+ }
+ case FLAC__METADATA_TYPE_PICTURE:
+ {
+ switch (metadata->data.picture.type)
{
- switch (metadata->data.picture.type)
- {
- case FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER:
- case FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD:
- case FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON:
- type = EXTRACTOR_METATYPE_THUMBNAIL;
- break;
- case FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER:
- case FLAC__STREAM_METADATA_PICTURE_TYPE_BACK_COVER:
- type = EXTRACTOR_METATYPE_COVER_PICTURE;
- break;
- case FLAC__STREAM_METADATA_PICTURE_TYPE_LEAD_ARTIST:
- case FLAC__STREAM_METADATA_PICTURE_TYPE_ARTIST:
- case FLAC__STREAM_METADATA_PICTURE_TYPE_CONDUCTOR:
- case FLAC__STREAM_METADATA_PICTURE_TYPE_BAND:
- case FLAC__STREAM_METADATA_PICTURE_TYPE_COMPOSER:
- case FLAC__STREAM_METADATA_PICTURE_TYPE_LYRICIST:
- type = EXTRACTOR_METATYPE_CONTRIBUTOR_PICTURE;
- break;
- case FLAC__STREAM_METADATA_PICTURE_TYPE_RECORDING_LOCATION:
- case FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_RECORDING:
- case FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_PERFORMANCE:
- case FLAC__STREAM_METADATA_PICTURE_TYPE_VIDEO_SCREEN_CAPTURE:
- type = EXTRACTOR_METATYPE_EVENT_PICTURE;
- break;
- case FLAC__STREAM_METADATA_PICTURE_TYPE_BAND_LOGOTYPE:
- case FLAC__STREAM_METADATA_PICTURE_TYPE_PUBLISHER_LOGOTYPE:
- type = EXTRACTOR_METATYPE_LOGO;
- break;
- case FLAC__STREAM_METADATA_PICTURE_TYPE_LEAFLET_PAGE:
- case FLAC__STREAM_METADATA_PICTURE_TYPE_MEDIA:
- case FLAC__STREAM_METADATA_PICTURE_TYPE_FISH:
- case FLAC__STREAM_METADATA_PICTURE_TYPE_ILLUSTRATION:
- default:
- type = EXTRACTOR_METATYPE_PICTURE;
- break;
- }
- ec->proc (ec->cls,
- "flac",
- type,
- EXTRACTOR_METAFORMAT_BINARY,
- metadata->data.picture.mime_type,
- (const char*) metadata->data.picture.data,
- metadata->data.picture.data_length);
- break;
+ case FLAC__STREAM_METADATA_PICTURE_TYPE_OTHER:
+ case FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON_STANDARD:
+ case FLAC__STREAM_METADATA_PICTURE_TYPE_FILE_ICON:
+ type = EXTRACTOR_METATYPE_THUMBNAIL;
+ break;
+ case FLAC__STREAM_METADATA_PICTURE_TYPE_FRONT_COVER:
+ case FLAC__STREAM_METADATA_PICTURE_TYPE_BACK_COVER:
+ type = EXTRACTOR_METATYPE_COVER_PICTURE;
+ break;
+ case FLAC__STREAM_METADATA_PICTURE_TYPE_LEAD_ARTIST:
+ case FLAC__STREAM_METADATA_PICTURE_TYPE_ARTIST:
+ case FLAC__STREAM_METADATA_PICTURE_TYPE_CONDUCTOR:
+ case FLAC__STREAM_METADATA_PICTURE_TYPE_BAND:
+ case FLAC__STREAM_METADATA_PICTURE_TYPE_COMPOSER:
+ case FLAC__STREAM_METADATA_PICTURE_TYPE_LYRICIST:
+ type = EXTRACTOR_METATYPE_CONTRIBUTOR_PICTURE;
+ break;
+ case FLAC__STREAM_METADATA_PICTURE_TYPE_RECORDING_LOCATION:
+ case FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_RECORDING:
+ case FLAC__STREAM_METADATA_PICTURE_TYPE_DURING_PERFORMANCE:
+ case FLAC__STREAM_METADATA_PICTURE_TYPE_VIDEO_SCREEN_CAPTURE:
+ type = EXTRACTOR_METATYPE_EVENT_PICTURE;
+ break;
+ case FLAC__STREAM_METADATA_PICTURE_TYPE_BAND_LOGOTYPE:
+ case FLAC__STREAM_METADATA_PICTURE_TYPE_PUBLISHER_LOGOTYPE:
+ type = EXTRACTOR_METATYPE_LOGO;
+ break;
+ case FLAC__STREAM_METADATA_PICTURE_TYPE_LEAFLET_PAGE:
+ case FLAC__STREAM_METADATA_PICTURE_TYPE_MEDIA:
+ case FLAC__STREAM_METADATA_PICTURE_TYPE_FISH:
+ case FLAC__STREAM_METADATA_PICTURE_TYPE_ILLUSTRATION:
+ default:
+ type = EXTRACTOR_METATYPE_PICTURE;
+ break;
}
- default:
+ ec->proc (ec->cls,
+ "flac",
+ type,
+ EXTRACTOR_METAFORMAT_BINARY,
+ metadata->data.picture.mime_type,
+ (const char*) metadata->data.picture.data,
+ metadata->data.picture.data_length);
break;
}
+ default:
+ break;
+ }
}
@@ -424,8 +425,8 @@ flac_metadata (const FLAC__StreamDecoder *decoder,
*/
static void
flac_error (const FLAC__StreamDecoder *decoder,
- FLAC__StreamDecoderErrorStatus status,
- void *client_data)
+ FLAC__StreamDecoderErrorStatus status,
+ void *client_data)
{
/* ignore errors */
}
@@ -439,55 +440,57 @@ flac_error (const FLAC__StreamDecoder *decoder,
void
EXTRACTOR_flac_extract_method (struct EXTRACTOR_ExtractContext *ec)
{
- FLAC__StreamDecoder * decoder;
+ FLAC__StreamDecoder *decoder;
if (NULL == (decoder = FLAC__stream_decoder_new ()))
return;
FLAC__stream_decoder_set_md5_checking (decoder, false);
FLAC__stream_decoder_set_metadata_ignore_all (decoder);
if (false == FLAC__stream_decoder_set_metadata_respond_all (decoder))
- {
- FLAC__stream_decoder_delete (decoder);
- return;
- }
+ {
+ FLAC__stream_decoder_delete (decoder);
+ return;
+ }
if (FLAC__STREAM_DECODER_INIT_STATUS_OK !=
FLAC__stream_decoder_init_stream (decoder,
- &flac_read,
- &flac_seek,
- &flac_tell,
- &flac_length,
- &flac_eof,
- &flac_write,
- &flac_metadata,
- &flac_error,
- ec))
- {
- FLAC__stream_decoder_delete (decoder);
- return;
- }
- if (FLAC__STREAM_DECODER_SEARCH_FOR_METADATA != FLAC__stream_decoder_get_state(decoder))
- {
- FLAC__stream_decoder_delete (decoder);
- return;
- }
- if (! FLAC__stream_decoder_process_until_end_of_metadata(decoder))
- {
- FLAC__stream_decoder_delete (decoder);
- return;
- }
+ &flac_read,
+ &flac_seek,
+ &flac_tell,
+ &flac_length,
+ &flac_eof,
+ &flac_write,
+ &flac_metadata,
+ &flac_error,
+ ec))
+ {
+ FLAC__stream_decoder_delete (decoder);
+ return;
+ }
+ if (FLAC__STREAM_DECODER_SEARCH_FOR_METADATA !=
+ FLAC__stream_decoder_get_state (decoder))
+ {
+ FLAC__stream_decoder_delete (decoder);
+ return;
+ }
+ if (! FLAC__stream_decoder_process_until_end_of_metadata (decoder))
+ {
+ FLAC__stream_decoder_delete (decoder);
+ return;
+ }
switch (FLAC__stream_decoder_get_state (decoder))
- {
- case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
- case FLAC__STREAM_DECODER_READ_METADATA:
- case FLAC__STREAM_DECODER_END_OF_STREAM:
- case FLAC__STREAM_DECODER_READ_FRAME:
- break;
- default:
- /* not so sure... */
- break;
- }
+ {
+ case FLAC__STREAM_DECODER_SEARCH_FOR_FRAME_SYNC:
+ case FLAC__STREAM_DECODER_READ_METADATA:
+ case FLAC__STREAM_DECODER_END_OF_STREAM:
+ case FLAC__STREAM_DECODER_READ_FRAME:
+ break;
+ default:
+ /* not so sure... */
+ break;
+ }
FLAC__stream_decoder_finish (decoder);
FLAC__stream_decoder_delete (decoder);
}
+
/* end of flac_extractor.c */
diff --git a/src/plugins/gif_extractor.c b/src/plugins/gif_extractor.c
@@ -37,16 +37,16 @@
*/
static int
gif_read_func (GifFileType *ft,
- GifByteType *bt,
- int arg)
+ GifByteType *bt,
+ int arg)
{
struct EXTRACTOR_ExtractContext *ec = ft->UserData;
void *data;
ssize_t ret;
ret = ec->read (ec->cls,
- &data,
- arg);
+ &data,
+ arg);
if (-1 == ret)
return -1;
memcpy (bt, data, ret);
@@ -75,7 +75,7 @@ EXTRACTOR_gif_extract_method (struct EXTRACTOR_ExtractContext *ec)
gif_error = 0;
gif_file = DGifOpen (ec, &gif_read_func, &gif_error);
- if (gif_file == NULL || gif_error != 0)
+ if ((gif_file == NULL) || (gif_error != 0))
{
if (gif_file != NULL)
#if GIFLIB_MAJOR < 5 || GIFLIB_MINOR < 1
@@ -88,57 +88,58 @@ EXTRACTOR_gif_extract_method (struct EXTRACTOR_ExtractContext *ec)
#endif
if (0 !=
ec->proc (ec->cls,
- "gif",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "image/gif",
- strlen ("image/gif") + 1))
+ "gif",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "image/gif",
+ strlen ("image/gif") + 1))
return;
snprintf (dims,
- sizeof (dims),
- "%dx%d",
- gif_file->SHeight,
- gif_file->SWidth);
+ sizeof (dims),
+ "%dx%d",
+ gif_file->SHeight,
+ gif_file->SWidth);
if (0 !=
ec->proc (ec->cls,
- "gif",
- EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- dims,
- strlen (dims) + 1))
+ "gif",
+ EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ dims,
+ strlen (dims) + 1))
return;
while (1)
+ {
+ if (GIF_OK !=
+ DGifGetRecordType (gif_file,
+ &gif_type))
+ break;
+ if (UNDEFINED_RECORD_TYPE == gif_type)
+ break;
+ if (EXTENSION_RECORD_TYPE != gif_type)
+ continue;
+ if (GIF_OK !=
+ DGifGetExtension (gif_file, &et, &ext))
+ continue;
+ if (NULL == ext)
+ continue;
+ if (COMMENT_EXT_FUNC_CODE == et)
{
- if (GIF_OK !=
- DGifGetRecordType (gif_file,
- &gif_type))
- break;
- if (UNDEFINED_RECORD_TYPE == gif_type)
- break;
- if (EXTENSION_RECORD_TYPE != gif_type)
- continue;
- if (GIF_OK !=
- DGifGetExtension (gif_file, &et, &ext))
- continue;
- if (NULL == ext)
- continue;
- if (COMMENT_EXT_FUNC_CODE == et)
- {
- ec->proc (ec->cls,
- "gif",
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- (char*) &ext[1],
- (uint8_t) ext[0]);
- break;
- }
- while ( (GIF_ERROR !=
- DGifGetExtensionNext(gif_file, &ext)) &&
- (NULL != ext) ) ; /* keep going */
+ ec->proc (ec->cls,
+ "gif",
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ (char*) &ext[1],
+ (uint8_t) ext[0]);
+ break;
}
+ while ( (GIF_ERROR !=
+ DGifGetExtensionNext (gif_file, &ext)) &&
+ (NULL != ext) )
+ ; /* keep going */
+ }
#if defined (GIF_LIB_VERSION) || GIFLIB_MAJOR < 5 || GIFLIB_MINOR < 1
DGifCloseFile (gif_file);
#else
@@ -146,4 +147,5 @@ EXTRACTOR_gif_extract_method (struct EXTRACTOR_ExtractContext *ec)
#endif
}
+
/* end of gif_extractor.c */
diff --git a/src/plugins/gstreamer_extractor.c b/src/plugins/gstreamer_extractor.c
@@ -64,8 +64,7 @@ struct KnownTag
/**
* Struct mapping known tags (that do occur in GST API) to LE tags.
*/
-static struct KnownTag __known_tags[] =
-{
+static struct KnownTag __known_tags[] = {
/**
* GST_TAG_TITLE:
*
@@ -562,7 +561,8 @@ static struct KnownTag __known_tags[] =
* Represents the expected error on the horizontal positioning in
* meters (double).
*/
- {GST_TAG_GEO_LOCATION_HORIZONTAL_ERROR, EXTRACTOR_METATYPE_LOCATION_HORIZONTAL_ERROR},
+ {GST_TAG_GEO_LOCATION_HORIZONTAL_ERROR,
+ EXTRACTOR_METATYPE_LOCATION_HORIZONTAL_ERROR},
/**
* GST_TAG_GEO_LOCATION_MOVEMENT_SPEED:
@@ -572,7 +572,8 @@ static struct KnownTag __known_tags[] =
*
* See also #GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION
*/
- {GST_TAG_GEO_LOCATION_MOVEMENT_SPEED, EXTRACTOR_METATYPE_LOCATION_MOVEMENT_SPEED},
+ {GST_TAG_GEO_LOCATION_MOVEMENT_SPEED,
+ EXTRACTOR_METATYPE_LOCATION_MOVEMENT_SPEED},
/**
* GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION:
@@ -583,7 +584,8 @@ static struct KnownTag __known_tags[] =
*
* See also #GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION
*/
- {GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION, EXTRACTOR_METATYPE_LOCATION_MOVEMENT_DIRECTION},
+ {GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION,
+ EXTRACTOR_METATYPE_LOCATION_MOVEMENT_DIRECTION},
/**
* GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION:
@@ -594,7 +596,8 @@ static struct KnownTag __known_tags[] =
*
* See also #GST_TAG_GEO_LOCATION_MOVEMENT_DIRECTION
*/
- {GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION, EXTRACTOR_METATYPE_LOCATION_CAPTURE_DIRECTION},
+ {GST_TAG_GEO_LOCATION_CAPTURE_DIRECTION,
+ EXTRACTOR_METATYPE_LOCATION_CAPTURE_DIRECTION},
/**
* GST_TAG_SHOW_NAME:
@@ -735,23 +738,22 @@ struct NamedTag
* Mapping from GST tag names to LE types for tags that are not in
* the public GST API.
*/
-struct NamedTag named_tags[] =
- {
- { "FPS", EXTRACTOR_METATYPE_FRAME_RATE },
- { "PLAY_COUNTER", EXTRACTOR_METATYPE_PLAY_COUNTER },
- { "RATING", EXTRACTOR_METATYPE_RATING },
- { "SUMMARY", EXTRACTOR_METATYPE_SUMMARY },
- { "SUBJECT", EXTRACTOR_METATYPE_SUBJECT },
- { "MOOD", EXTRACTOR_METATYPE_MOOD },
- { "LEAD_PERFORMER", EXTRACTOR_METATYPE_PERFORMER },
- { "DIRECTOR", EXTRACTOR_METATYPE_MOVIE_DIRECTOR },
- { "WRITTEN_BY", EXTRACTOR_METATYPE_WRITER },
- { "PRODUCER", EXTRACTOR_METATYPE_PRODUCER },
- { "PUBLISHER", EXTRACTOR_METATYPE_PUBLISHER },
- { "ORIGINAL/ARTIST", EXTRACTOR_METATYPE_ORIGINAL_ARTIST },
- { "ORIGINAL/TITLE", EXTRACTOR_METATYPE_ORIGINAL_TITLE },
- { NULL, EXTRACTOR_METATYPE_UNKNOWN }
- };
+struct NamedTag named_tags[] = {
+ { "FPS", EXTRACTOR_METATYPE_FRAME_RATE },
+ { "PLAY_COUNTER", EXTRACTOR_METATYPE_PLAY_COUNTER },
+ { "RATING", EXTRACTOR_METATYPE_RATING },
+ { "SUMMARY", EXTRACTOR_METATYPE_SUMMARY },
+ { "SUBJECT", EXTRACTOR_METATYPE_SUBJECT },
+ { "MOOD", EXTRACTOR_METATYPE_MOOD },
+ { "LEAD_PERFORMER", EXTRACTOR_METATYPE_PERFORMER },
+ { "DIRECTOR", EXTRACTOR_METATYPE_MOVIE_DIRECTOR },
+ { "WRITTEN_BY", EXTRACTOR_METATYPE_WRITER },
+ { "PRODUCER", EXTRACTOR_METATYPE_PRODUCER },
+ { "PUBLISHER", EXTRACTOR_METATYPE_PUBLISHER },
+ { "ORIGINAL/ARTIST", EXTRACTOR_METATYPE_ORIGINAL_ARTIST },
+ { "ORIGINAL/TITLE", EXTRACTOR_METATYPE_ORIGINAL_TITLE },
+ { NULL, EXTRACTOR_METATYPE_UNKNOWN }
+};
/**
@@ -914,9 +916,9 @@ _data_timeout (struct PrivStruct *ps)
* @param ps our execution context
*/
static void
-feed_data (GstElement * appsrc,
- guint size,
- struct PrivStruct * ps)
+feed_data (GstElement *appsrc,
+ guint size,
+ struct PrivStruct *ps)
{
ssize_t data_len;
uint8_t *le_data;
@@ -929,7 +931,8 @@ feed_data (GstElement * appsrc,
if (ps->timeout_id > 0)
g_source_remove (ps->timeout_id);
- ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout, ps);
+ ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout,
+ ps);
if ( (ps->length > 0) && (ps->offset >= ps->length) )
{
@@ -938,11 +941,11 @@ feed_data (GstElement * appsrc,
return;
}
- if (ps->length > 0 && ps->offset + size > ps->length)
+ if ((ps->length > 0) && (ps->offset + size > ps->length))
size = ps->length - ps->offset;
mem = gst_allocator_alloc (NULL, size, NULL);
- if (!gst_memory_map (mem, &mi, GST_MAP_WRITE))
+ if (! gst_memory_map (mem, &mi, GST_MAP_WRITE))
{
gst_memory_unref (mem);
GST_DEBUG ("Failed to map the memory");
@@ -955,7 +958,8 @@ feed_data (GstElement * appsrc,
pthread_mutex_lock (&pipe_mutex);
while ( (accumulated < size) && (data_len > 0) )
{
- data_len = ps->ec->read (ps->ec->cls, (void **) &le_data, size - accumulated);
+ data_len = ps->ec->read (ps->ec->cls, (void **) &le_data, size
+ - accumulated);
if (data_len > 0)
{
memcpy (&mi.data[accumulated], le_data, data_len);
@@ -974,7 +978,7 @@ feed_data (GstElement * appsrc,
GST_BUFFER_OFFSET_END (buffer) = ps->offset + size;
GST_DEBUG ("feed buffer %p, offset %" G_GUINT64_FORMAT "-%u",
- buffer, ps->offset, size);
+ buffer, ps->offset, size);
gst_app_src_push_buffer (GST_APP_SRC (ps->source), buffer);
ps->offset += size;
}
@@ -987,7 +991,8 @@ feed_data (GstElement * appsrc,
if (ps->timeout_id > 0)
g_source_remove (ps->timeout_id);
- ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout, ps);
+ ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout,
+ ps);
}
@@ -1001,9 +1006,9 @@ feed_data (GstElement * appsrc,
* @return TRUE if seeking succeeded, FALSE if not
*/
static gboolean
-seek_data (GstElement * appsrc,
- guint64 position,
- struct PrivStruct * ps)
+seek_data (GstElement *appsrc,
+ guint64 position,
+ struct PrivStruct *ps)
{
GST_DEBUG ("seek to offset %" G_GUINT64_FORMAT, position);
pthread_mutex_lock (&pipe_mutex);
@@ -1011,7 +1016,8 @@ seek_data (GstElement * appsrc,
pthread_mutex_unlock (&pipe_mutex);
if (ps->timeout_id > 0)
g_source_remove (ps->timeout_id);
- ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout, ps);
+ ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout,
+ ps);
return ps->offset == position;
}
@@ -1026,8 +1032,8 @@ seek_data (GstElement * appsrc,
*/
static gboolean
send_structure_foreach (GQuark field_id,
- const GValue *value,
- gpointer user_data)
+ const GValue *value,
+ gpointer user_data)
{
struct PrivStruct *ps = user_data;
gchar *str;
@@ -1095,20 +1101,21 @@ send_structure_foreach (GQuark field_id,
{
unsigned int i;
- for (i=0; NULL != named_tags[i].tag; i++)
+ for (i = 0; NULL != named_tags[i].tag; i++)
if (0 == strcmp (named_tags[i].tag, field_name))
- {
- ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
- named_tags[i].le_type,
- EXTRACTOR_METAFORMAT_UTF8, "text/plain",
- (const char *) str, strlen (str) + 1);
- if (NULL != str)
- {
- g_free (str);
- str = NULL;
- }
- break;
- }
+ {
+ ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
+ named_tags[i].le_type,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ (const char *) str, strlen (str) + 1);
+ if (NULL != str)
+ {
+ g_free (str);
+ str = NULL;
+ }
+ break;
+ }
}
if (NULL != str)
{
@@ -1116,16 +1123,16 @@ send_structure_foreach (GQuark field_id,
field_name,
str);
if (NULL != senddata)
- {
- ps->time_to_leave = ps->ec->proc (ps->ec->cls,
- "gstreamer",
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- (const char *) senddata,
- strlen (senddata) + 1);
- g_free (senddata);
- }
+ {
+ ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+ "gstreamer",
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ (const char *) senddata,
+ strlen (senddata) + 1);
+ g_free (senddata);
+ }
}
if (NULL != str)
g_free (str);
@@ -1143,7 +1150,7 @@ send_structure_foreach (GQuark field_id,
*/
static gboolean
send_audio_info (GstDiscovererAudioInfo *info,
- struct PrivStruct *ps)
+ struct PrivStruct *ps)
{
gchar *tmp;
const gchar *ctmp;
@@ -1152,10 +1159,11 @@ send_audio_info (GstDiscovererAudioInfo *info,
ctmp = gst_discoverer_audio_info_get_language (info);
if (ctmp)
if ((ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
- EXTRACTOR_METATYPE_AUDIO_LANGUAGE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- (const char *) ctmp, strlen (ctmp) + 1)))
+ EXTRACTOR_METATYPE_AUDIO_LANGUAGE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ (const char *) ctmp, strlen (ctmp)
+ + 1)))
return TRUE;
u = gst_discoverer_audio_info_get_channels (info);
@@ -1163,16 +1171,16 @@ send_audio_info (GstDiscovererAudioInfo *info,
{
tmp = g_strdup_printf ("%u", u);
if (NULL != tmp)
- {
- ps->time_to_leave = ps->ec->proc (ps->ec->cls,
- "gstreamer",
- EXTRACTOR_METATYPE_CHANNELS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- (const char *) tmp,
- strlen (tmp) + 1);
- g_free (tmp);
- }
+ {
+ ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+ "gstreamer",
+ EXTRACTOR_METATYPE_CHANNELS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ (const char *) tmp,
+ strlen (tmp) + 1);
+ g_free (tmp);
+ }
if (ps->time_to_leave)
return TRUE;
}
@@ -1182,16 +1190,16 @@ send_audio_info (GstDiscovererAudioInfo *info,
{
tmp = g_strdup_printf ("%u", u);
if (NULL != tmp)
- {
- ps->time_to_leave = ps->ec->proc (ps->ec->cls,
- "gstreamer",
- EXTRACTOR_METATYPE_SAMPLE_RATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- (const char *) tmp,
- strlen (tmp) + 1);
- g_free (tmp);
- }
+ {
+ ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+ "gstreamer",
+ EXTRACTOR_METATYPE_SAMPLE_RATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ (const char *) tmp,
+ strlen (tmp) + 1);
+ g_free (tmp);
+ }
if (ps->time_to_leave)
return TRUE;
}
@@ -1201,16 +1209,16 @@ send_audio_info (GstDiscovererAudioInfo *info,
{
tmp = g_strdup_printf ("%u", u);
if (NULL != tmp)
- {
- ps->time_to_leave = ps->ec->proc (ps->ec->cls,
- "gstreamer",
- EXTRACTOR_METATYPE_AUDIO_DEPTH,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- (const char *) tmp,
- strlen (tmp) + 1);
- g_free (tmp);
- }
+ {
+ ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+ "gstreamer",
+ EXTRACTOR_METATYPE_AUDIO_DEPTH,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ (const char *) tmp,
+ strlen (tmp) + 1);
+ g_free (tmp);
+ }
if (ps->time_to_leave)
return TRUE;
}
@@ -1220,16 +1228,16 @@ send_audio_info (GstDiscovererAudioInfo *info,
{
tmp = g_strdup_printf ("%u", u);
if (NULL != tmp)
- {
- ps->time_to_leave = ps->ec->proc (ps->ec->cls,
- "gstreamer",
- EXTRACTOR_METATYPE_AUDIO_BITRATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- (const char *) tmp,
- strlen (tmp) + 1);
- g_free (tmp);
- }
+ {
+ ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+ "gstreamer",
+ EXTRACTOR_METATYPE_AUDIO_BITRATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ (const char *) tmp,
+ strlen (tmp) + 1);
+ g_free (tmp);
+ }
if (ps->time_to_leave)
return TRUE;
}
@@ -1239,16 +1247,16 @@ send_audio_info (GstDiscovererAudioInfo *info,
{
tmp = g_strdup_printf ("%u", u);
if (NULL != tmp)
- {
- ps->time_to_leave = ps->ec->proc (ps->ec->cls,
- "gstreamer",
- EXTRACTOR_METATYPE_MAXIMUM_AUDIO_BITRATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- (const char *) tmp,
- strlen (tmp) + 1);
- g_free (tmp);
- }
+ {
+ ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+ "gstreamer",
+ EXTRACTOR_METATYPE_MAXIMUM_AUDIO_BITRATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ (const char *) tmp,
+ strlen (tmp) + 1);
+ g_free (tmp);
+ }
if (ps->time_to_leave)
return TRUE;
}
@@ -1266,7 +1274,7 @@ send_audio_info (GstDiscovererAudioInfo *info,
*/
static int
send_video_info (GstDiscovererVideoInfo *info,
- struct PrivStruct *ps)
+ struct PrivStruct *ps)
{
gchar *tmp;
guint u;
@@ -1278,16 +1286,16 @@ send_video_info (GstDiscovererVideoInfo *info,
{
tmp = g_strdup_printf ("%ux%u", u, u2);
if (NULL != tmp)
- {
- ps->time_to_leave = ps->ec->proc (ps->ec->cls,
- "gstreamer",
- EXTRACTOR_METATYPE_VIDEO_DIMENSIONS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- (const char *) tmp,
- strlen (tmp) + 1);
- g_free (tmp);
- }
+ {
+ ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+ "gstreamer",
+ EXTRACTOR_METATYPE_VIDEO_DIMENSIONS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ (const char *) tmp,
+ strlen (tmp) + 1);
+ g_free (tmp);
+ }
if (ps->time_to_leave)
return TRUE;
}
@@ -1297,16 +1305,16 @@ send_video_info (GstDiscovererVideoInfo *info,
{
tmp = g_strdup_printf ("%u", u);
if (NULL != tmp)
- {
- ps->time_to_leave = ps->ec->proc (ps->ec->cls,
- "gstreamer",
- EXTRACTOR_METATYPE_VIDEO_DEPTH,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- (const char *) tmp,
- strlen (tmp) + 1);
- g_free (tmp);
- }
+ {
+ ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+ "gstreamer",
+ EXTRACTOR_METATYPE_VIDEO_DEPTH,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ (const char *) tmp,
+ strlen (tmp) + 1);
+ g_free (tmp);
+ }
if (ps->time_to_leave)
return TRUE;
}
@@ -1317,16 +1325,16 @@ send_video_info (GstDiscovererVideoInfo *info,
{
tmp = g_strdup_printf ("%u/%u", u, u2);
if (NULL != tmp)
- {
- ps->time_to_leave = ps->ec->proc (ps->ec->cls,
- "gstreamer",
- EXTRACTOR_METATYPE_FRAME_RATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- (const char *) tmp,
- strlen (tmp) + 1);
- g_free (tmp);
- }
+ {
+ ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+ "gstreamer",
+ EXTRACTOR_METATYPE_FRAME_RATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ (const char *) tmp,
+ strlen (tmp) + 1);
+ g_free (tmp);
+ }
if (ps->time_to_leave)
return TRUE;
}
@@ -1337,16 +1345,16 @@ send_video_info (GstDiscovererVideoInfo *info,
{
tmp = g_strdup_printf ("%u/%u", u, u2);
if (NULL != tmp)
- {
- ps->time_to_leave = ps->ec->proc (ps->ec->cls,
- "gstreamer",
- EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- (const char *) tmp,
- strlen (tmp) + 1);
- g_free (tmp);
- }
+ {
+ ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+ "gstreamer",
+ EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ (const char *) tmp,
+ strlen (tmp) + 1);
+ g_free (tmp);
+ }
if (ps->time_to_leave)
return TRUE;
}
@@ -1358,16 +1366,16 @@ send_video_info (GstDiscovererVideoInfo *info,
{
tmp = g_strdup_printf ("%u", u);
if (NULL != tmp)
- {
- ps->time_to_leave = ps->ec->proc (ps->ec->cls,
- "gstreamer",
- EXTRACTOR_METATYPE_VIDEO_BITRATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- (const char *) tmp,
- strlen (tmp) + 1);
- g_free (tmp);
- }
+ {
+ ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+ "gstreamer",
+ EXTRACTOR_METATYPE_VIDEO_BITRATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ (const char *) tmp,
+ strlen (tmp) + 1);
+ g_free (tmp);
+ }
if (ps->time_to_leave)
return TRUE;
}
@@ -1377,16 +1385,16 @@ send_video_info (GstDiscovererVideoInfo *info,
{
tmp = g_strdup_printf ("%u", u);
if (NULL != tmp)
- {
- ps->time_to_leave = ps->ec->proc (ps->ec->cls,
- "gstreamer",
- EXTRACTOR_METATYPE_MAXIMUM_VIDEO_BITRATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- (const char *) tmp,
- strlen (tmp) + 1);
- g_free (tmp);
- }
+ {
+ ps->time_to_leave = ps->ec->proc (ps->ec->cls,
+ "gstreamer",
+ EXTRACTOR_METATYPE_MAXIMUM_VIDEO_BITRATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ (const char *) tmp,
+ strlen (tmp) + 1);
+ g_free (tmp);
+ }
if (ps->time_to_leave)
return TRUE;
}
@@ -1404,26 +1412,27 @@ send_video_info (GstDiscovererVideoInfo *info,
*/
static int
send_subtitle_info (GstDiscovererSubtitleInfo *info,
- struct PrivStruct *ps)
+ struct PrivStruct *ps)
{
const gchar *ctmp;
ctmp = gst_discoverer_subtitle_info_get_language (info);
if ( (NULL != ctmp) &&
(0 != (ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
- EXTRACTOR_METATYPE_SUBTITLE_LANGUAGE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- (const char *) ctmp, strlen (ctmp) + 1))) )
+ EXTRACTOR_METATYPE_SUBTITLE_LANGUAGE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ (const char *) ctmp, strlen (
+ ctmp) + 1))) )
return TRUE;
return FALSE;
}
static void
-send_tag_foreach (const GstTagList * tags,
- const gchar * tag,
- gpointer user_data)
+send_tag_foreach (const GstTagList *tags,
+ const gchar *tag,
+ gpointer user_data)
{
static struct KnownTag unknown_tag = {NULL, EXTRACTOR_METATYPE_UNKNOWN};
struct PrivStruct *ps = user_data;
@@ -1480,7 +1489,9 @@ send_tag_foreach (const GstTagList * tags,
str = gst_value_serialize (&val);
break;
default:
- if (G_VALUE_TYPE (&val) == GST_TYPE_SAMPLE && (sample = gst_value_get_sample (&val)))
+ if ((G_VALUE_TYPE (&val) == GST_TYPE_SAMPLE) && (sample =
+ gst_value_get_sample (
+ &val)))
{
GstMapInfo mi;
GstCaps *caps;
@@ -1498,7 +1509,9 @@ send_tag_foreach (const GstTagList * tags,
info = gst_sample_get_info (sample);
if ( (NULL == info) ||
- (!gst_structure_get (info, "image-type", GST_TYPE_TAG_IMAGE_TYPE, &imagetype, NULL)) )
+ (! gst_structure_get (info, "image-type",
+ GST_TYPE_TAG_IMAGE_TYPE, &imagetype,
+ NULL)) )
le_type = EXTRACTOR_METATYPE_PICTURE;
else
{
@@ -1545,12 +1558,12 @@ send_tag_foreach (const GstTagList * tags,
le_type,
EXTRACTOR_METAFORMAT_BINARY,
mime_type,
- (const char *) mi.data, mi.size);
+ (const char *) mi.data, mi.size);
gst_buffer_unmap (buf, &mi);
}
}
else if ((G_VALUE_TYPE (&val) == G_TYPE_UINT64) &&
- (tag_quark == duration_quark))
+ (tag_quark == duration_quark))
{
GstClockTime duration = (GstClockTime) g_value_get_uint64 (&val);
if ((GST_CLOCK_TIME_IS_VALID (duration)) && (duration > 0))
@@ -1566,14 +1579,12 @@ send_tag_foreach (const GstTagList * tags,
* ignore these tags to avoid duplicates.
* This MIGHT be fixed in new GStreamer versions, but won't affect
* this code (we simply won't get the tags that we think we should skip).
- */
- gboolean skip = FALSE;
+ */gboolean skip = FALSE;
/* We have one tag-processing routine and use it for different
* stream types. However, tags themselves don't know the type of the
* stream they are attached to. We remember that before listing the
* tags, and adjust LE type accordingly.
- */
- enum EXTRACTOR_MetaType le_type = kt->le_type;
+ */enum EXTRACTOR_MetaType le_type = kt->le_type;
switch (kt->le_type)
{
case EXTRACTOR_METATYPE_LANGUAGE:
@@ -1662,7 +1673,7 @@ send_tag_foreach (const GstTagList * tags,
{
gchar *new_str;
/* GST_TAG_EXTENDED_COMMENT is already in key=value form */
- if ((0 != strcmp (tag, "extended-comment")) || !strchr (str, '='))
+ if ((0 != strcmp (tag, "extended-comment")) || ! strchr (str, '='))
{
new_str = g_strdup_printf ("%s=%s", tag, str);
if (NULL != str)
@@ -1693,12 +1704,12 @@ send_tag_foreach (const GstTagList * tags,
static void
send_streams (GstDiscovererStreamInfo *info,
- struct PrivStruct *ps);
+ struct PrivStruct *ps);
static void
-send_stream_info (GstDiscovererStreamInfo * info,
- struct PrivStruct *ps)
+send_stream_info (GstDiscovererStreamInfo *info,
+ struct PrivStruct *ps)
{
const GstStructure *misc;
GstCaps *caps;
@@ -1722,9 +1733,11 @@ send_stream_info (GstDiscovererStreamInfo * info,
if (g_str_has_prefix (structname, "image/"))
ps->st = STREAM_TYPE_IMAGE;
ps->time_to_leave = ps->ec->proc (ps->ec->cls, "gstreamer",
- EXTRACTOR_METATYPE_MIMETYPE, EXTRACTOR_METAFORMAT_UTF8, "text/plain",
- (const char *) structname, strlen (structname) + 1);
- if (!ps->time_to_leave)
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8, "text/plain",
+ (const char *) structname, strlen (
+ structname) + 1);
+ if (! ps->time_to_leave)
{
gst_structure_foreach (structure, send_structure_foreach, ps);
}
@@ -1770,8 +1783,8 @@ send_stream_info (GstDiscovererStreamInfo * info,
GList *child;
GstDiscovererContainerInfo *c = GST_DISCOVERER_CONTAINER_INFO (info);
GList *children = gst_discoverer_container_info_get_streams (c);
- for (child = children; (NULL != child) && (!ps->time_to_leave);
- child = child->next)
+ for (child = children; (NULL != child) && (! ps->time_to_leave);
+ child = child->next)
{
GstDiscovererStreamInfo *sinfo = child->data;
/* send_streams () will unref it */
@@ -1786,7 +1799,7 @@ send_stream_info (GstDiscovererStreamInfo * info,
static void
send_streams (GstDiscovererStreamInfo *info,
- struct PrivStruct *ps)
+ struct PrivStruct *ps)
{
GstDiscovererStreamInfo *next;
@@ -1808,9 +1821,9 @@ send_streams (GstDiscovererStreamInfo *info,
* @param user_data the 'struct PrivStruct' with the 'toc' string we are assembling
*/
static void
-send_toc_tags_foreach (const GstTagList * tags,
- const gchar * tag,
- gpointer user_data)
+send_toc_tags_foreach (const GstTagList *tags,
+ const gchar *tag,
+ gpointer user_data)
{
struct PrivStruct *ps = user_data;
GValue val = { 0 };
@@ -1899,9 +1912,11 @@ send_toc_foreach (gpointer data, gpointer user_data)
return;
gst_toc_entry_get_start_stop_times (entry, &start, &stop);
s = g_strdup_printf ("%*.*s<%s start=\"%" GST_TIME_FORMAT "\" stop=\"%"
- GST_TIME_FORMAT"\">\n", ps->toc_depth * 2, ps->toc_depth * 2, " ",
- gst_toc_entry_type_get_nick (entype), GST_TIME_ARGS (start),
- GST_TIME_ARGS (stop));
+ GST_TIME_FORMAT "\">\n", ps->toc_depth * 2,
+ ps->toc_depth * 2, " ",
+ gst_toc_entry_type_get_nick (entype), GST_TIME_ARGS (
+ start),
+ GST_TIME_ARGS (stop));
if (NULL != s)
{
if (ps->toc_print_phase)
@@ -1916,21 +1931,25 @@ send_toc_foreach (gpointer data, gpointer user_data)
ps->toc_depth++;
tags = gst_toc_entry_get_tags (entry);
if (tags)
- {
- if (ps->toc_print_phase)
- ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length - ps->toc_pos,
- "%*.*s<tags>\n", ps->toc_depth * 2, ps->toc_depth * 2, " ");
- else
- ps->toc_length += strlen ("<tags>\n") + ps->toc_depth * 2;
- ps->toc_depth++;
- gst_tag_list_foreach (tags, &send_toc_tags_foreach, ps);
- ps->toc_depth--;
- if (ps->toc_print_phase)
- ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length - ps->toc_pos,
- "%*.*s</tags>\n", ps->toc_depth * 2, ps->toc_depth * 2, " ");
- else
- ps->toc_length += strlen ("</tags>\n") + ps->toc_depth * 2;
- }
+ {
+ if (ps->toc_print_phase)
+ ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length
+ - ps->toc_pos,
+ "%*.*s<tags>\n", ps->toc_depth * 2,
+ ps->toc_depth * 2, " ");
+ else
+ ps->toc_length += strlen ("<tags>\n") + ps->toc_depth * 2;
+ ps->toc_depth++;
+ gst_tag_list_foreach (tags, &send_toc_tags_foreach, ps);
+ ps->toc_depth--;
+ if (ps->toc_print_phase)
+ ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length
+ - ps->toc_pos,
+ "%*.*s</tags>\n", ps->toc_depth * 2,
+ ps->toc_depth * 2, " ");
+ else
+ ps->toc_length += strlen ("</tags>\n") + ps->toc_depth * 2;
+ }
subentries = gst_toc_entry_get_sub_entries (entry);
g_list_foreach (subentries, send_toc_foreach, ps);
@@ -1939,11 +1958,12 @@ send_toc_foreach (gpointer data, gpointer user_data)
s = g_strdup_printf ("%*.*s</%s>\n",
ps->toc_depth * 2,
ps->toc_depth * 2, " ",
- gst_toc_entry_type_get_nick (entype));
+ gst_toc_entry_type_get_nick (entype));
if (NULL != s)
{
if (ps->toc_print_phase)
- ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length - ps->toc_pos, "%s", s);
+ ps->toc_pos += g_snprintf (&ps->toc[ps->toc_pos], ps->toc_length
+ - ps->toc_pos, "%s", s);
else
ps->toc_length += strlen (s);
g_free (s);
@@ -1958,8 +1978,8 @@ send_toc_foreach (gpointer data, gpointer user_data)
static void
-send_info (GstDiscovererInfo * info,
- struct PrivStruct *ps)
+send_info (GstDiscovererInfo *info,
+ struct PrivStruct *ps)
{
const GstToc *toc;
gchar *s;
@@ -1992,9 +2012,7 @@ send_info (GstDiscovererInfo * info,
{
gst_tag_list_foreach (tags, send_tag_foreach, ps);
}
- */
-
- if (ps->time_to_leave)
+ */if (ps->time_to_leave)
return;
if ((toc = gst_discoverer_info_get_toc (info)))
@@ -2040,8 +2058,8 @@ send_info (GstDiscovererInfo * info,
static void
-send_discovered_info (GstDiscovererInfo * info,
- struct PrivStruct * ps)
+send_discovered_info (GstDiscovererInfo *info,
+ struct PrivStruct *ps)
{
GstDiscovererResult result;
@@ -2051,20 +2069,20 @@ send_discovered_info (GstDiscovererInfo * info,
result = gst_discoverer_info_get_result (info);
switch (result)
- {
- case GST_DISCOVERER_OK:
- break;
- case GST_DISCOVERER_URI_INVALID:
- break;
- case GST_DISCOVERER_ERROR:
- break;
- case GST_DISCOVERER_TIMEOUT:
- break;
- case GST_DISCOVERER_BUSY:
- break;
- case GST_DISCOVERER_MISSING_PLUGINS:
- break;
- }
+ {
+ case GST_DISCOVERER_OK:
+ break;
+ case GST_DISCOVERER_URI_INVALID:
+ break;
+ case GST_DISCOVERER_ERROR:
+ break;
+ case GST_DISCOVERER_TIMEOUT:
+ break;
+ case GST_DISCOVERER_BUSY:
+ break;
+ case GST_DISCOVERER_MISSING_PLUGINS:
+ break;
+ }
pthread_mutex_lock (&pipe_mutex);
send_info (info, ps);
pthread_mutex_unlock (&pipe_mutex);
@@ -2072,20 +2090,21 @@ send_discovered_info (GstDiscovererInfo * info,
static void
-_new_discovered_uri (GstDiscoverer * dc,
- GstDiscovererInfo * info,
- GError * err,
- struct PrivStruct *ps)
+_new_discovered_uri (GstDiscoverer *dc,
+ GstDiscovererInfo *info,
+ GError *err,
+ struct PrivStruct *ps)
{
send_discovered_info (info, ps);
if (ps->timeout_id > 0)
g_source_remove (ps->timeout_id);
- ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout, ps);
+ ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout,
+ ps);
}
static void
-_discoverer_finished (GstDiscoverer * dc, struct PrivStruct *ps)
+_discoverer_finished (GstDiscoverer *dc, struct PrivStruct *ps)
{
if (ps->timeout_id > 0)
g_source_remove (ps->timeout_id);
@@ -2105,9 +2124,9 @@ _discoverer_finished (GstDiscoverer * dc, struct PrivStruct *ps)
* @param ps
*/
static void
-_source_setup (GstDiscoverer * dc,
- GstElement * source,
- struct PrivStruct *ps)
+_source_setup (GstDiscoverer *dc,
+ GstElement *source,
+ struct PrivStruct *ps)
{
if (ps->source)
gst_object_unref (GST_OBJECT (ps->source));
@@ -2120,7 +2139,8 @@ _source_setup (GstDiscoverer * dc,
if (ps->length > 0)
{
g_object_set (ps->source, "size", (gint64) ps->length, NULL);
- gst_util_set_object_arg (G_OBJECT (ps->source), "stream-type", "random-access");
+ gst_util_set_object_arg (G_OBJECT (ps->source), "stream-type",
+ "random-access");
}
else
gst_util_set_object_arg (G_OBJECT (ps->source), "stream-type", "seekable");
@@ -2129,16 +2149,16 @@ _source_setup (GstDiscoverer * dc,
* data */
g_signal_connect (ps->source, "need-data", G_CALLBACK (feed_data), ps);
g_signal_connect (ps->source, "seek-data", G_CALLBACK (seek_data), ps);
- ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout, ps);
+ ps->timeout_id = g_timeout_add (DATA_TIMEOUT, (GSourceFunc) _data_timeout,
+ ps);
}
-
static void
log_handler (const gchar *log_domain,
- GLogLevelFlags log_level,
- const gchar *message,
- gpointer unused_data)
+ GLogLevelFlags log_level,
+ const gchar *message,
+ gpointer unused_data)
{
/* do nothing */
}
@@ -2151,11 +2171,12 @@ log_handler (const gchar *log_domain,
* @return FALSE (always)
*/
static gboolean
-_run_async (struct PrivStruct * ps)
+_run_async (struct PrivStruct *ps)
{
g_log_set_default_handler (&log_handler, NULL);
- g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
- &log_handler, NULL);
+ g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
+ | G_LOG_FLAG_RECURSION,
+ &log_handler, NULL);
gst_discoverer_discover_uri_async (ps->dc, "appsrc://");
return FALSE;
}
@@ -2178,11 +2199,11 @@ EXTRACTOR_gstreamer_extract_method (struct EXTRACTOR_ExtractContext *ec)
memset (&ps, 0, sizeof (ps));
ps.dc = gst_discoverer_new (8 * GST_SECOND, &err);
if (NULL == ps.dc)
- {
- if (NULL != err)
- g_error_free (err);
- return;
- }
+ {
+ if (NULL != err)
+ g_error_free (err);
+ return;
+ }
if (NULL != err)
g_error_free (err);
/* connect signals */
@@ -2195,10 +2216,11 @@ EXTRACTOR_gstreamer_extract_method (struct EXTRACTOR_ExtractContext *ec)
if (ps.length == UINT_MAX)
ps.length = 0;
g_log_set_default_handler (&log_handler, NULL);
- g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
- &log_handler, NULL);
+ g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
+ | G_LOG_FLAG_RECURSION,
+ &log_handler, NULL);
gst_discoverer_start (ps.dc);
- g_idle_add ((GSourceFunc) &_run_async, &ps);
+ g_idle_add ((GSourceFunc) & _run_async, &ps);
g_main_loop_run (ps.loop);
if (ps.timeout_id > 0)
g_source_remove (ps.timeout_id);
@@ -2216,35 +2238,36 @@ gstreamer_init ()
{
gst_init (NULL, NULL);
g_log_set_default_handler (&log_handler, NULL);
- g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
- &log_handler, NULL);
+ g_log_set_handler (NULL, G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL
+ | G_LOG_FLAG_RECURSION,
+ &log_handler, NULL);
GST_DEBUG_CATEGORY_INIT (gstreamer_extractor, "GstExtractor",
- 0, "GStreamer-based libextractor plugin");
+ 0, "GStreamer-based libextractor plugin");
audio_quarks = g_new0 (GQuark, 4);
if (NULL != audio_quarks)
- {
- audio_quarks[0] = g_quark_from_string ("rate");
- audio_quarks[1] = g_quark_from_string ("channels");
- audio_quarks[2] = g_quark_from_string ("depth");
- audio_quarks[3] = g_quark_from_string (NULL);
- }
+ {
+ audio_quarks[0] = g_quark_from_string ("rate");
+ audio_quarks[1] = g_quark_from_string ("channels");
+ audio_quarks[2] = g_quark_from_string ("depth");
+ audio_quarks[3] = g_quark_from_string (NULL);
+ }
video_quarks = g_new0 (GQuark, 6);
if (NULL != video_quarks)
- {
- video_quarks[0] = g_quark_from_string ("width");
- video_quarks[1] = g_quark_from_string ("height");
- video_quarks[2] = g_quark_from_string ("framerate");
- video_quarks[3] = g_quark_from_string ("max-framerate");
- video_quarks[4] = g_quark_from_string ("pixel-aspect-ratio");
- video_quarks[5] = g_quark_from_string (NULL);
- }
+ {
+ video_quarks[0] = g_quark_from_string ("width");
+ video_quarks[1] = g_quark_from_string ("height");
+ video_quarks[2] = g_quark_from_string ("framerate");
+ video_quarks[3] = g_quark_from_string ("max-framerate");
+ video_quarks[4] = g_quark_from_string ("pixel-aspect-ratio");
+ video_quarks[5] = g_quark_from_string (NULL);
+ }
subtitle_quarks = g_new0 (GQuark, 2);
if (NULL != subtitle_quarks)
- {
- subtitle_quarks[0] = g_quark_from_string ("language-code");
- subtitle_quarks[1] = g_quark_from_string (NULL);
- }
+ {
+ subtitle_quarks[0] = g_quark_from_string ("language-code");
+ subtitle_quarks[1] = g_quark_from_string (NULL);
+ }
duration_quark = g_quark_from_string ("duration");
diff --git a/src/plugins/html_extractor.c b/src/plugins/html_extractor.c
@@ -87,9 +87,9 @@ tag_to_type (const char *tag)
{
unsigned int i;
- for (i=0; NULL != tagmap[i].name; i++)
+ for (i = 0; NULL != tagmap[i].name; i++)
if (0 == strcasecmp (tag,
- tagmap[i].name))
+ tagmap[i].name))
return tagmap[i].type;
return EXTRACTOR_METATYPE_RESERVED;
}
@@ -107,10 +107,10 @@ tag_to_type (const char *tag)
*/
static Bool TIDY_CALL
report_cb (TidyDoc doc,
- TidyReportLevel lvl,
- uint line,
- uint col,
- ctmbstr mssg)
+ TidyReportLevel lvl,
+ uint line,
+ uint col,
+ ctmbstr mssg)
{
return 0;
}
@@ -130,7 +130,7 @@ get_byte_cb (void *sourceData)
if (1 !=
ec->read (ec->cls,
- &data, 1))
+ &data, 1))
return EndOfStream;
return *(unsigned char*) data;
}
@@ -188,130 +188,129 @@ EXTRACTOR_html_extract_method (struct EXTRACTOR_ExtractContext *ec)
const char *mime;
if (-1 == (iret = ec->read (ec->cls,
- &data,
- 16 * 1024)))
+ &data,
+ 16 * 1024)))
return;
if (NULL == (mime = magic_buffer (magic, data, iret)))
return;
if (0 != strncmp (mime,
- "text/html",
- strlen ("text/html")))
+ "text/html",
+ strlen ("text/html")))
return; /* not HTML */
if (0 != ec->seek (ec->cls, 0, SEEK_SET))
return; /* seek failed !? */
tidyInitSource (&src, ec,
- &get_byte_cb,
- &unget_byte_cb,
- &eof_cb);
+ &get_byte_cb,
+ &unget_byte_cb,
+ &eof_cb);
if (NULL == (doc = tidyCreate ()))
return;
tidySetReportFilter (doc, &report_cb);
tidySetAppData (doc, ec);
if (0 > tidyParseSource (doc, &src))
- {
- tidyRelease (doc);
- return;
- }
+ {
+ tidyRelease (doc);
+ return;
+ }
if (1 != tidyStatus (doc))
- {
- tidyRelease (doc);
- return;
- }
+ {
+ tidyRelease (doc);
+ return;
+ }
if (NULL == (head = tidyGetHead (doc)))
- {
- fprintf (stderr, "no head\n");
- tidyRelease (doc);
- return;
- }
+ {
+ fprintf (stderr, "no head\n");
+ tidyRelease (doc);
+ return;
+ }
for (child = tidyGetChild (head); NULL != child; child = tidyGetNext (child))
+ {
+ switch (tidyNodeGetType (child))
{
- switch (tidyNodeGetType(child))
- {
- case TidyNode_Root:
- break;
- case TidyNode_DocType:
- break;
- case TidyNode_Comment:
- break;
- case TidyNode_ProcIns:
- break;
- case TidyNode_Text:
- break;
- case TidyNode_CDATA:
- break;
- case TidyNode_Section:
- break;
- case TidyNode_Asp:
- break;
- case TidyNode_Jste:
- break;
- case TidyNode_Php:
- break;
- case TidyNode_XmlDecl:
- break;
- case TidyNode_Start:
- case TidyNode_StartEnd:
- name = tidyNodeGetName (child);
- if ( (0 == strcasecmp (name, "title")) &&
- (NULL != (title = tidyGetChild (child))) )
- {
- tidyBufInit (&tbuf);
- tidyNodeGetValue (doc, title, &tbuf);
- /* add 0-termination */
- tidyBufPutByte (&tbuf, 0);
- if (0 !=
- ec->proc (ec->cls,
- "html",
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- (const char *) tbuf.bp,
- tbuf.size))
- {
- tidyBufFree (&tbuf);
- goto CLEANUP;
- }
- tidyBufFree (&tbuf);
- break;
- }
- if (0 == strcasecmp (name, "meta"))
- {
- if (NULL == (attr = tidyAttrGetById (child,
- TidyAttr_NAME)))
- break;
- if (EXTRACTOR_METATYPE_RESERVED ==
- (type = tag_to_type (tidyAttrValue (attr))))
- break;
- if (NULL == (attr = tidyAttrGetById (child,
- TidyAttr_CONTENT)))
- break;
- name = tidyAttrValue (attr);
- if (0 !=
- ec->proc (ec->cls,
- "html",
- type,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- name,
- strlen (name) + 1))
- goto CLEANUP;
- break;
- }
- break;
- case TidyNode_End:
- break;
- default:
- break;
- }
+ case TidyNode_Root:
+ break;
+ case TidyNode_DocType:
+ break;
+ case TidyNode_Comment:
+ break;
+ case TidyNode_ProcIns:
+ break;
+ case TidyNode_Text:
+ break;
+ case TidyNode_CDATA:
+ break;
+ case TidyNode_Section:
+ break;
+ case TidyNode_Asp:
+ break;
+ case TidyNode_Jste:
+ break;
+ case TidyNode_Php:
+ break;
+ case TidyNode_XmlDecl:
+ break;
+ case TidyNode_Start:
+ case TidyNode_StartEnd:
+ name = tidyNodeGetName (child);
+ if ( (0 == strcasecmp (name, "title")) &&
+ (NULL != (title = tidyGetChild (child))) )
+ {
+ tidyBufInit (&tbuf);
+ tidyNodeGetValue (doc, title, &tbuf);
+ /* add 0-termination */
+ tidyBufPutByte (&tbuf, 0);
+ if (0 !=
+ ec->proc (ec->cls,
+ "html",
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ (const char *) tbuf.bp,
+ tbuf.size))
+ {
+ tidyBufFree (&tbuf);
+ goto CLEANUP;
+ }
+ tidyBufFree (&tbuf);
+ break;
+ }
+ if (0 == strcasecmp (name, "meta"))
+ {
+ if (NULL == (attr = tidyAttrGetById (child,
+ TidyAttr_NAME)))
+ break;
+ if (EXTRACTOR_METATYPE_RESERVED ==
+ (type = tag_to_type (tidyAttrValue (attr))))
+ break;
+ if (NULL == (attr = tidyAttrGetById (child,
+ TidyAttr_CONTENT)))
+ break;
+ name = tidyAttrValue (attr);
+ if (0 !=
+ ec->proc (ec->cls,
+ "html",
+ type,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ name,
+ strlen (name) + 1))
+ goto CLEANUP;
+ break;
+ }
+ break;
+ case TidyNode_End:
+ break;
+ default:
+ break;
}
- CLEANUP:
+ }
+CLEANUP:
tidyRelease (doc);
}
-
#if OLD
@@ -323,66 +322,71 @@ tagMatch (const char *tag, const char *s, const char *e)
return (((e - s) == strlen (tag)) && (0 == strncasecmp (tag, s, e - s)));
}
+
static int
-lookFor (char c, size_t * pos, const char *data, size_t size)
+lookFor (char c, size_t *pos, const char *data, size_t size)
{
size_t p = *pos;
while ((p < size) && (data[p] != c))
- {
- if (data[p] == '\0')
- return 0;
- p++;
- }
+ {
+ if (data[p] == '\0')
+ return 0;
+ p++;
+ }
*pos = p;
return p < size;
}
+
static int
-skipWhitespace (size_t * pos, const char *data, size_t size)
+skipWhitespace (size_t *pos, const char *data, size_t size)
{
size_t p = *pos;
while ((p < size) && (isspace ( (unsigned char) data[p])))
- {
- if (data[p] == '\0')
- return 0;
- p++;
- }
+ {
+ if (data[p] == '\0')
+ return 0;
+ p++;
+ }
*pos = p;
return p < size;
}
+
static int
-skipLetters (size_t * pos, const char *data, size_t size)
+skipLetters (size_t *pos, const char *data, size_t size)
{
size_t p = *pos;
while ((p < size) && (isalpha ( (unsigned char) data[p])))
- {
- if (data[p] == '\0')
- return 0;
- p++;
- }
+ {
+ if (data[p] == '\0')
+ return 0;
+ p++;
+ }
*pos = p;
return p < size;
}
+
static int
-lookForMultiple (const char *c, size_t * pos, const char *data, size_t size)
+lookForMultiple (const char *c, size_t *pos, const char *data, size_t size)
{
size_t p = *pos;
while ((p < size) && (strchr (c, data[p]) == NULL))
- {
- if (data[p] == '\0')
- return 0;
- p++;
- }
+ {
+ if (data[p] == '\0')
+ return 0;
+ p++;
+ }
*pos = p;
return p < size;
}
+
static void
findEntry (const char *key,
const char *start,
@@ -394,32 +398,33 @@ findEntry (const char *key,
*mend = NULL;
len = strlen (key);
while (start < end - len - 1)
+ {
+ start++;
+ if (start[len] != '=')
+ continue;
+ if (0 == strncasecmp (start, key, len))
{
- start++;
- if (start[len] != '=')
- continue;
- if (0 == strncasecmp (start, key, len))
- {
- start += len + 1;
- *mstart = start;
- if ((*start == '\"') || (*start == '\''))
- {
- start++;
- while ((start < end) && (*start != **mstart))
- start++;
- (*mstart)++; /* skip quote */
- }
- else
- {
- while ((start < end) && (!isspace ( (unsigned char) *start)))
- start++;
- }
- *mend = start;
- return;
- }
+ start += len + 1;
+ *mstart = start;
+ if ((*start == '\"') || (*start == '\''))
+ {
+ start++;
+ while ((start < end) && (*start != **mstart))
+ start++;
+ (*mstart)++; /* skip quote */
+ }
+ else
+ {
+ while ((start < end) && (! isspace ( (unsigned char) *start)))
+ start++;
+ }
+ *mend = start;
+ return;
}
+ }
}
+
/**
* Search all tags that correspond to "tagname". Example:
* If the tag is <meta name="foo" desc="bar">, and
@@ -430,7 +435,7 @@ findEntry (const char *key,
* @return NULL if nothing is found
*/
static char *
-findInTags (struct TagInfo * t,
+findInTags (struct TagInfo *t,
const char *tagname,
const char *keyname, const char *keyvalue, const char *searchname)
{
@@ -438,26 +443,26 @@ findInTags (struct TagInfo * t,
const char *pend;
while (t != NULL)
+ {
+ if (tagMatch (tagname, t->tagStart, t->tagEnd))
{
- if (tagMatch (tagname, t->tagStart, t->tagEnd))
+ findEntry (keyname, t->tagEnd, t->dataStart, &pstart, &pend);
+ if ((pstart != NULL) && (tagMatch (keyvalue, pstart, pend)))
+ {
+ findEntry (searchname, t->tagEnd, t->dataStart, &pstart, &pend);
+ if (pstart != NULL)
{
- findEntry (keyname, t->tagEnd, t->dataStart, &pstart, &pend);
- if ((pstart != NULL) && (tagMatch (keyvalue, pstart, pend)))
- {
- findEntry (searchname, t->tagEnd, t->dataStart, &pstart, &pend);
- if (pstart != NULL)
- {
- char *ret = malloc (pend - pstart + 1);
- if (ret == NULL)
- return NULL;
- memcpy (ret, pstart, pend - pstart);
- ret[pend - pstart] = '\0';
- return ret;
- }
- }
+ char *ret = malloc (pend - pstart + 1);
+ if (ret == NULL)
+ return NULL;
+ memcpy (ret, pstart, pend - pstart);
+ ret[pend - pstart] = '\0';
+ return ret;
}
- t = t->next;
+ }
}
+ t = t->next;
+ }
return NULL;
}
@@ -465,10 +470,10 @@ findInTags (struct TagInfo * t,
/* mimetype = text/html */
int
EXTRACTOR_html_extract (const char *data,
- size_t size,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls,
- const char *options)
+ size_t size,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls,
+ const char *options)
{
size_t xsize;
struct TagInfo *tags;
@@ -494,60 +499,60 @@ EXTRACTOR_html_extract (const char *data,
tag.next = NULL;
pos = 0;
while (pos < xsize)
+ {
+ if (! lookFor ('<', &pos, data, size))
+ break;
+ tag.tagStart = &data[++pos];
+ if (! skipLetters (&pos, data, size))
+ break;
+ tag.tagEnd = &data[pos];
+ if (! skipWhitespace (&pos, data, size))
+ break;
+STEP3:
+ if (! lookForMultiple (">\"\'", &pos, data, size))
+ break;
+ if (data[pos] != '>')
{
- if (!lookFor ('<', &pos, data, size))
- break;
- tag.tagStart = &data[++pos];
- if (!skipLetters (&pos, data, size))
- break;
- tag.tagEnd = &data[pos];
- if (!skipWhitespace (&pos, data, size))
- break;
- STEP3:
- if (!lookForMultiple (">\"\'", &pos, data, size))
- break;
- if (data[pos] != '>')
- {
- /* find end-quote, ignore escaped quotes (\') */
- do
- {
- tpos = pos;
- pos++;
- if (!lookFor (data[tpos], &pos, data, size))
- break;
- }
- while (data[pos - 1] == '\\');
- pos++;
- goto STEP3;
- }
+ /* find end-quote, ignore escaped quotes (\') */
+ do
+ {
+ tpos = pos;
+ pos++;
+ if (! lookFor (data[tpos], &pos, data, size))
+ break;
+ }
+ while (data[pos - 1] == '\\');
pos++;
- if (!skipWhitespace (&pos, data, size))
- break;
- tag.dataStart = &data[pos];
- if (!lookFor ('<', &pos, data, size))
- break;
- tag.dataEnd = &data[pos];
- i = 0;
- while (relevantTags[i] != NULL)
- {
- if ((strlen (relevantTags[i]) == tag.tagEnd - tag.tagStart) &&
- (0 == strncasecmp (relevantTags[i],
- tag.tagStart, tag.tagEnd - tag.tagStart)))
- {
- t = malloc (sizeof (struct TagInfo));
- if (t == NULL)
- return 0;
- *t = tag;
- t->next = tags;
- tags = t;
- break;
- }
- i++;
- }
- /* abort early if we hit the body tag */
- if (tagMatch ("body", tag.tagStart, tag.tagEnd))
+ goto STEP3;
+ }
+ pos++;
+ if (! skipWhitespace (&pos, data, size))
+ break;
+ tag.dataStart = &data[pos];
+ if (! lookFor ('<', &pos, data, size))
+ break;
+ tag.dataEnd = &data[pos];
+ i = 0;
+ while (relevantTags[i] != NULL)
+ {
+ if ((strlen (relevantTags[i]) == tag.tagEnd - tag.tagStart) &&
+ (0 == strncasecmp (relevantTags[i],
+ tag.tagStart, tag.tagEnd - tag.tagStart)))
+ {
+ t = malloc (sizeof (struct TagInfo));
+ if (t == NULL)
+ return 0;
+ *t = tag;
+ t->next = tags;
+ tags = t;
break;
+ }
+ i++;
}
+ /* abort early if we hit the body tag */
+ if (tagMatch ("body", tag.tagStart, tag.tagEnd))
+ break;
+ }
/* fast exit */
if (tags == NULL)
@@ -557,110 +562,112 @@ EXTRACTOR_html_extract (const char *data,
/* first, try to determine mime type and/or character set */
tmp = findInTags (tags, "meta", "http-equiv", "content-type", "content");
if (tmp != NULL)
- {
- /* ideally, tmp == "test/html; charset=ISO-XXXX-Y" or something like that;
- if text/html is present, we take that as the mime-type; if charset=
- is present, we try to use that for character set conversion. */
- if (0 == strncasecmp (tmp, "text/html", strlen ("text/html")))
- ret = proc (proc_cls,
- "html",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "text/html",
- strlen ("text/html")+1);
- charset = strcasestr (tmp, "charset=");
- if (charset != NULL)
- charset = strdup (&charset[strlen ("charset=")]);
- free (tmp);
- }
+ {
+ /* ideally, tmp == "test/html; charset=ISO-XXXX-Y" or something like that;
+ if text/html is present, we take that as the mime-type; if charset=
+ is present, we try to use that for character set conversion. */
+ if (0 == strncasecmp (tmp, "text/html", strlen ("text/html")))
+ ret = proc (proc_cls,
+ "html",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "text/html",
+ strlen ("text/html") + 1);
+ charset = strcasestr (tmp, "charset=");
+ if (charset != NULL)
+ charset = strdup (&charset[strlen ("charset=")]);
+ free (tmp);
+ }
i = 0;
while (tagmap[i].name != NULL)
+ {
+ tmp = findInTags (tags, "meta", "name", tagmap[i].name, "content");
+ if ( (tmp != NULL) &&
+ (ret == 0) )
{
- tmp = findInTags (tags, "meta", "name", tagmap[i].name, "content");
- if ( (tmp != NULL) &&
- (ret == 0) )
+ if (charset == NULL)
+ {
+ ret = proc (proc_cls,
+ "html",
+ tagmap[i].type,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ tmp,
+ strlen (tmp) + 1);
+ }
+ else
+ {
+ xtmp = EXTRACTOR_common_convert_to_utf8 (tmp,
+ strlen (tmp),
+ charset);
+ if (xtmp != NULL)
{
- if (charset == NULL)
- {
- ret = proc (proc_cls,
- "html",
- tagmap[i].type,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- tmp,
- strlen (tmp) + 1);
- }
- else
- {
- xtmp = EXTRACTOR_common_convert_to_utf8 (tmp,
- strlen (tmp),
- charset);
- if (xtmp != NULL)
- {
- ret = proc (proc_cls,
- "html",
- tagmap[i].type,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- xtmp,
- strlen (xtmp) + 1);
- free (xtmp);
- }
- }
+ ret = proc (proc_cls,
+ "html",
+ tagmap[i].type,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ xtmp,
+ strlen (xtmp) + 1);
+ free (xtmp);
}
- if (tmp != NULL)
- free (tmp);
- i++;
+ }
}
+ if (tmp != NULL)
+ free (tmp);
+ i++;
+ }
while (tags != NULL)
+ {
+ t = tags;
+ if ( (tagMatch ("title", t->tagStart, t->tagEnd)) &&
+ (ret == 0) )
{
- t = tags;
- if ( (tagMatch ("title", t->tagStart, t->tagEnd)) &&
- (ret == 0) )
- {
- if (charset == NULL)
- {
- xtmp = malloc (t->dataEnd - t->dataStart + 1);
- if (xtmp != NULL)
- {
- memcpy (xtmp, t->dataStart, t->dataEnd - t->dataStart);
- xtmp[t->dataEnd - t->dataStart] = '\0';
- ret = proc (proc_cls,
- "html",
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- xtmp,
- strlen (xtmp) + 1);
- free (xtmp);
- }
- }
- else
- {
- xtmp = EXTRACTOR_common_convert_to_utf8 (t->dataStart,
- t->dataEnd - t->dataStart,
- charset);
- if (xtmp != NULL)
- {
- ret = proc (proc_cls,
- "html",
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- xtmp,
- strlen (xtmp) + 1);
- free (xtmp);
- }
- }
- }
- tags = t->next;
- free (t);
+ if (charset == NULL)
+ {
+ xtmp = malloc (t->dataEnd - t->dataStart + 1);
+ if (xtmp != NULL)
+ {
+ memcpy (xtmp, t->dataStart, t->dataEnd - t->dataStart);
+ xtmp[t->dataEnd - t->dataStart] = '\0';
+ ret = proc (proc_cls,
+ "html",
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ xtmp,
+ strlen (xtmp) + 1);
+ free (xtmp);
+ }
+ }
+ else
+ {
+ xtmp = EXTRACTOR_common_convert_to_utf8 (t->dataStart,
+ t->dataEnd - t->dataStart,
+ charset);
+ if (xtmp != NULL)
+ {
+ ret = proc (proc_cls,
+ "html",
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ xtmp,
+ strlen (xtmp) + 1);
+ free (xtmp);
+ }
+ }
}
+ tags = t->next;
+ free (t);
+ }
if (charset != NULL)
free (charset);
return ret;
}
+
+
#endif
@@ -672,9 +679,9 @@ html_gobject_init ()
{
magic = magic_open (MAGIC_MIME_TYPE);
if (0 != magic_load (magic, NULL))
- {
- /* FIXME: how to deal with errors? */
- }
+ {
+ /* FIXME: how to deal with errors? */
+ }
}
@@ -685,10 +692,11 @@ void __attribute__ ((destructor))
html_ltdl_fini ()
{
if (NULL != magic)
- {
- magic_close (magic);
- magic = NULL;
- }
+ {
+ magic_close (magic);
+ magic = NULL;
+ }
}
+
/* end of html_extractor.c */
diff --git a/src/plugins/it_extractor.c b/src/plugins/it_extractor.c
@@ -72,8 +72,8 @@ EXTRACTOR_it_extract_method (struct EXTRACTOR_ExtractContext *ec)
if ((ssize_t) HEADER_SIZE >
ec->read (ec->cls,
- &data,
- HEADER_SIZE))
+ &data,
+ HEADER_SIZE))
return;
head = (struct Header *) data;
/* Check "magic" id bytes */
@@ -81,40 +81,41 @@ EXTRACTOR_it_extract_method (struct EXTRACTOR_ExtractContext *ec)
return;
/* Mime-type */
if (0 != ec->proc (ec->cls,
- "it",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "audio/x-mod",
- strlen ("audio/x-mod") + 1))
+ "it",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "audio/x-mod",
+ strlen ("audio/x-mod") + 1))
return;
/* Version of Tracker */
snprintf (itversion,
- sizeof (itversion),
- "%d.%d",
- (head->version[0] & 0x01),
- head->version[1]);
+ sizeof (itversion),
+ "%d.%d",
+ (head->version[0] & 0x01),
+ head->version[1]);
if (0 != ec->proc (ec->cls,
- "it",
- EXTRACTOR_METATYPE_FORMAT_VERSION,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- itversion,
- strlen (itversion) + 1))
+ "it",
+ EXTRACTOR_METATYPE_FORMAT_VERSION,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ itversion,
+ strlen (itversion) + 1))
return;
/* Song title */
memcpy (&title, head->title, 26);
title[26] = '\0';
if (0 != ec->proc (ec->cls,
- "it",
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- title,
- strlen (title) + 1))
+ "it",
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ title,
+ strlen (title) + 1))
return;
}
+
/* end of it_extractor.c */
diff --git a/src/plugins/jpeg_extractor.c b/src/plugins/jpeg_extractor.c
@@ -112,71 +112,73 @@ EXTRACTOR_jpeg_extract_method (struct EXTRACTOR_ExtractContext *ec)
jpeg_create_decompress (&jds);
jpeg_save_markers (&jds, JPEG_COM, 1024 * 8);
while ( (1 == is_jpeg) || (rounds++ < 8) )
+ {
+ if (-1 == (size = ec->read (ec->cls,
+ &buf,
+ 16 * 1024)))
+ break;
+ if (0 == size)
+ break;
+ jpeg_mem_src (&jds, buf, size);
+ if (0 == is_jpeg)
{
- if (-1 == (size = ec->read (ec->cls,
- &buf,
- 16 * 1024)))
- break;
- if (0 == size)
- break;
- jpeg_mem_src (&jds, buf, size);
- if (0 == is_jpeg)
- {
- if (JPEG_HEADER_OK == jpeg_read_header (&jds, 1))
- is_jpeg = 1; /* ok, really a jpeg, keep going until the end */
- continue;
- }
- jpeg_consume_input (&jds);
+ if (JPEG_HEADER_OK == jpeg_read_header (&jds, 1))
+ is_jpeg = 1; /* ok, really a jpeg, keep going until the end */
+ continue;
}
+ jpeg_consume_input (&jds);
+ }
if (1 != is_jpeg)
goto EXIT;
if (0 !=
ec->proc (ec->cls,
- "jpeg",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "image/jpeg",
- strlen ("image/jpeg") + 1))
+ "jpeg",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "image/jpeg",
+ strlen ("image/jpeg") + 1))
goto EXIT;
snprintf (format,
- sizeof (format),
- "%ux%u",
- (unsigned int) jds.image_width,
- (unsigned int) jds.image_height);
+ sizeof (format),
+ "%ux%u",
+ (unsigned int) jds.image_width,
+ (unsigned int) jds.image_height);
if (0 !=
ec->proc (ec->cls,
- "jpeg",
- EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- format,
- strlen (format) + 1))
+ "jpeg",
+ EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ format,
+ strlen (format) + 1))
goto EXIT;
for (mptr = jds.marker_list; NULL != mptr; mptr = mptr->next)
- {
- size_t off;
-
- if (JPEG_COM != mptr->marker)
- continue;
- off = 0;
- while ( (off < mptr->data_length) &&
- (isspace (((const unsigned char *)mptr->data)[mptr->data_length - 1 - off])) )
- off++;
- if (0 !=
- ec->proc (ec->cls,
- "jpeg",
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- (const char *) mptr->data,
- mptr->data_length - off))
- goto EXIT;
- }
-
- EXIT:
+ {
+ size_t off;
+
+ if (JPEG_COM != mptr->marker)
+ continue;
+ off = 0;
+ while ( (off < mptr->data_length) &&
+ (isspace (((const unsigned char *) mptr->data)[mptr->data_length
+ - 1 - off])) )
+ off++;
+ if (0 !=
+ ec->proc (ec->cls,
+ "jpeg",
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ (const char *) mptr->data,
+ mptr->data_length - off))
+ goto EXIT;
+ }
+
+EXIT:
jpeg_destroy_decompress (&jds);
}
+
/* end of jpeg_extractor.c */
diff --git a/src/plugins/man_extractor.c b/src/plugins/man_extractor.c
@@ -59,35 +59,35 @@ stndup (const char *str, size_t n)
*/
static int
add_keyword (enum EXTRACTOR_MetaType type,
- char *keyword,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls)
+ char *keyword,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
int ret;
char *value;
-
+
if (NULL == keyword)
return 0;
- if ( (keyword[0] == '\"') &&
+ if ( (keyword[0] == '\"') &&
(keyword[strlen (keyword) - 1] == '\"') )
- {
- keyword[strlen (keyword) - 1] = '\0';
- value = &keyword[1];
- }
+ {
+ keyword[strlen (keyword) - 1] = '\0';
+ value = &keyword[1];
+ }
else
value = keyword;
if (0 == strlen (value))
- {
- free (keyword);
- return 0;
- }
- ret = proc (proc_cls,
- "man",
- type,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- value,
- strlen (value)+1);
+ {
+ free (keyword);
+ return 0;
+ }
+ ret = proc (proc_cls,
+ "man",
+ type,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ value,
+ strlen (value) + 1);
free (keyword);
return ret;
}
@@ -102,20 +102,20 @@ add_keyword (enum EXTRACTOR_MetaType type,
*/
static void
find_end_of_token (size_t *end,
- const char *buf,
- const size_t size)
+ const char *buf,
+ const size_t size)
{
int quot;
quot = 0;
while ( (*end < size) &&
- ( (0 != (quot & 1)) ||
- ((' ' != buf[*end])) ) )
- {
- if ('\"' == buf[*end])
- quot++;
- (*end)++;
- }
+ ( (0 != (quot & 1)) ||
+ ((' ' != buf[*end])) ) )
+ {
+ if ('\"' == buf[*end])
+ quot++;
+ (*end)++;
+ }
if (1 == (quot & 1))
(*end) = size + 1;
}
@@ -130,15 +130,16 @@ find_end_of_token (size_t *end,
/**
* Add a keyword to LE.
- *
+ *
* @param t type to use
* @param s keyword to give to LE
*/
-#define ADD(t,s) do { if (0 != add_keyword (t, s, ec->proc, ec->cls)) return; } while (0)
+#define ADD(t,s) do { if (0 != add_keyword (t, s, ec->proc, ec->cls)) return; \
+} while (0)
/**
- * Main entry method for the man page extraction plugin.
+ * Main entry method for the man page extraction plugin.
*
* @param ec extraction context provided to the plugin
*/
@@ -152,7 +153,7 @@ EXTRACTOR_man_extract_method (struct EXTRACTOR_ExtractContext *ec)
void *data;
ssize_t size;
char *buf;
-
+
if (0 >= (size = ec->read (ec->cls, &data, MAX_READ)))
return;
buf = data;
@@ -162,17 +163,17 @@ EXTRACTOR_man_extract_method (struct EXTRACTOR_ExtractContext *ec)
/* find actual beginning of the man page (.TH);
abort if we find non-printable characters */
while ( (pos < size - xlen) &&
- ( (0 != strncmp (".TH ",
- &buf[pos],
- xlen)) ||
- ( (0 != pos) &&
- (buf[pos - 1] != '\n') ) ) )
- {
- if ( (! isgraph ((unsigned char) buf[pos])) &&
- (! isspace ((unsigned char) buf[pos])) )
- return;
- pos++;
- }
+ ( (0 != strncmp (".TH ",
+ &buf[pos],
+ xlen)) ||
+ ( (0 != pos) &&
+ (buf[pos - 1] != '\n') ) ) )
+ {
+ if ( (! isgraph ((unsigned char) buf[pos])) &&
+ (! isspace ((unsigned char) buf[pos])) )
+ return;
+ pos++;
+ }
if (0 != strncmp (".TH ", &buf[pos], xlen))
return;
@@ -192,13 +193,13 @@ EXTRACTOR_man_extract_method (struct EXTRACTOR_ExtractContext *ec)
if (end > size)
return;
if (end > pos)
- {
- ADD (EXTRACTOR_METATYPE_TITLE, stndup (&buf[pos], end - pos));
- pos = end + 1;
- }
+ {
+ ADD (EXTRACTOR_METATYPE_TITLE, stndup (&buf[pos], end - pos));
+ pos = end + 1;
+ }
if (pos >= size)
return;
-
+
/* next token is the section */
end = pos;
find_end_of_token (&end, buf, size);
@@ -207,62 +208,62 @@ EXTRACTOR_man_extract_method (struct EXTRACTOR_ExtractContext *ec)
if ('\"' == buf[pos])
pos++;
if ((end - pos >= 1) && (end - pos <= 4))
+ {
+ switch (buf[pos])
{
- switch (buf[pos])
- {
- case '1':
- ADD (EXTRACTOR_METATYPE_SECTION,
- strdup (_("Commands")));
- break;
- case '2':
- ADD (EXTRACTOR_METATYPE_SECTION,
- strdup (_("System calls")));
- break;
- case '3':
- ADD (EXTRACTOR_METATYPE_SECTION,
- strdup (_("Library calls")));
- break;
- case '4':
- ADD (EXTRACTOR_METATYPE_SECTION,
- strdup (_("Special files")));
- break;
- case '5':
- ADD (EXTRACTOR_METATYPE_SECTION,
- strdup (_("File formats and conventions")));
- break;
- case '6':
- ADD (EXTRACTOR_METATYPE_SECTION,
- strdup (_("Games")));
- break;
- case '7':
- ADD (EXTRACTOR_METATYPE_SECTION,
- strdup (_("Conventions and miscellaneous")));
- break;
- case '8':
- ADD (EXTRACTOR_METATYPE_SECTION,
- strdup (_("System management commands")));
- break;
- case '9':
- ADD (EXTRACTOR_METATYPE_SECTION,
- strdup (_("Kernel routines")));
- break;
- default:
- ADD (EXTRACTOR_METATYPE_SECTION,
- stndup (&buf[pos], 1));
- }
- pos = end + 1;
+ case '1':
+ ADD (EXTRACTOR_METATYPE_SECTION,
+ strdup (_ ("Commands")));
+ break;
+ case '2':
+ ADD (EXTRACTOR_METATYPE_SECTION,
+ strdup (_ ("System calls")));
+ break;
+ case '3':
+ ADD (EXTRACTOR_METATYPE_SECTION,
+ strdup (_ ("Library calls")));
+ break;
+ case '4':
+ ADD (EXTRACTOR_METATYPE_SECTION,
+ strdup (_ ("Special files")));
+ break;
+ case '5':
+ ADD (EXTRACTOR_METATYPE_SECTION,
+ strdup (_ ("File formats and conventions")));
+ break;
+ case '6':
+ ADD (EXTRACTOR_METATYPE_SECTION,
+ strdup (_ ("Games")));
+ break;
+ case '7':
+ ADD (EXTRACTOR_METATYPE_SECTION,
+ strdup (_ ("Conventions and miscellaneous")));
+ break;
+ case '8':
+ ADD (EXTRACTOR_METATYPE_SECTION,
+ strdup (_ ("System management commands")));
+ break;
+ case '9':
+ ADD (EXTRACTOR_METATYPE_SECTION,
+ strdup (_ ("Kernel routines")));
+ break;
+ default:
+ ADD (EXTRACTOR_METATYPE_SECTION,
+ stndup (&buf[pos], 1));
}
+ pos = end + 1;
+ }
end = pos;
/* next token is the modification date */
find_end_of_token (&end, buf, size);
if (end > size)
- return;
+ return;
if (end > pos)
- {
- ADD (EXTRACTOR_METATYPE_MODIFICATION_DATE, stndup (&buf[pos], end - pos));
- pos = end + 1;
- }
+ {
+ ADD (EXTRACTOR_METATYPE_MODIFICATION_DATE, stndup (&buf[pos], end - pos));
+ pos = end + 1;
+ }
/* next token is the source of the man page */
end = pos;
@@ -270,11 +271,11 @@ EXTRACTOR_man_extract_method (struct EXTRACTOR_ExtractContext *ec)
if (end > size)
return;
if (end > pos)
- {
- ADD (EXTRACTOR_METATYPE_SOURCE,
- stndup (&buf[pos], end - pos));
- pos = end + 1;
- }
+ {
+ ADD (EXTRACTOR_METATYPE_SOURCE,
+ stndup (&buf[pos], end - pos));
+ pos = end + 1;
+ }
/* last token is the title of the book the man page belongs to */
end = pos;
@@ -282,11 +283,12 @@ EXTRACTOR_man_extract_method (struct EXTRACTOR_ExtractContext *ec)
if (end > size)
return;
if (end > pos)
- {
- ADD (EXTRACTOR_METATYPE_BOOK_TITLE,
- stndup (&buf[pos], end - pos));
- pos = end + 1;
- }
+ {
+ ADD (EXTRACTOR_METATYPE_BOOK_TITLE,
+ stndup (&buf[pos], end - pos));
+ pos = end + 1;
+ }
}
+
/* end of man_extractor.c */
diff --git a/src/plugins/midi_extractor.c b/src/plugins/midi_extractor.c
@@ -31,27 +31,27 @@
* Types of events in MIDI.
*/
enum EventType
- {
- ET_SEQUENCE_NUMBER = 0,
- ET_TEXT_EVENT = 1,
- ET_COPYRIGHT_NOTICE = 2,
- ET_TRACK_NAME = 3,
- ET_INSTRUMENT_NAME = 4,
- ET_LYRIC_TEXT = 5,
- ET_MARKER_TEXT = 6,
- ET_CUE_POINT = 7,
- ET_CHANNEL_PREFIX_ASSIGNMENT = 0x20,
- ET_END_OF_TRACK = 0x2F,
- ET_TEMPO_SETTING = 0x51,
- ET_SMPTE_OFFSET = 0x54,
- ET_TIME_SIGNATURE = 0x58,
- ET_KEY_SIGNATURE = 0x59,
- ET_SEQUENCE_SPECIRFIC_EVENT = 0x7F
- };
+{
+ ET_SEQUENCE_NUMBER = 0,
+ ET_TEXT_EVENT = 1,
+ ET_COPYRIGHT_NOTICE = 2,
+ ET_TRACK_NAME = 3,
+ ET_INSTRUMENT_NAME = 4,
+ ET_LYRIC_TEXT = 5,
+ ET_MARKER_TEXT = 6,
+ ET_CUE_POINT = 7,
+ ET_CHANNEL_PREFIX_ASSIGNMENT = 0x20,
+ ET_END_OF_TRACK = 0x2F,
+ ET_TEMPO_SETTING = 0x51,
+ ET_SMPTE_OFFSET = 0x54,
+ ET_TIME_SIGNATURE = 0x58,
+ ET_KEY_SIGNATURE = 0x59,
+ ET_SEQUENCE_SPECIRFIC_EVENT = 0x7F
+};
/**
- * Main entry method for the 'audio/midi' extraction plugin.
+ * Main entry method for the 'audio/midi' extraction plugin.
*
* @param ec extraction context provided to the plugin
*/
@@ -66,7 +66,7 @@ EXTRACTOR_midi_extract_method (struct EXTRACTOR_ExtractContext *ec)
smf_t *m = NULL;
smf_event_t *event;
uint8_t len;
-
+
if (4 >= (iret = ec->read (ec->cls, &buf, 1024)))
return;
data = buf;
@@ -81,103 +81,103 @@ EXTRACTOR_midi_extract_method (struct EXTRACTOR_ExtractContext *ec)
memcpy (data, buf, iret);
off = iret;
while (off < size)
+ {
+ if (0 >= (iret = ec->read (ec->cls, &buf, 16 * 1024)))
{
- if (0 >= (iret = ec->read (ec->cls, &buf, 16 * 1024)))
- {
- free (data);
- return;
- }
- memcpy (&data[off], buf, iret);
- off += iret;
- }
- if (0 != ec->proc (ec->cls,
- "midi",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "audio/midi",
- strlen ("audio/midi") + 1))
+ free (data);
+ return;
+ }
+ memcpy (&data[off], buf, iret);
+ off += iret;
+ }
+ if (0 != ec->proc (ec->cls,
+ "midi",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "audio/midi",
+ strlen ("audio/midi") + 1))
goto CLEANUP;
if (NULL == (m = smf_load_from_memory (data, size)))
goto CLEANUP;
while (NULL != (event = smf_get_next_event (m)))
- {
- if (! smf_event_is_metadata (event))
- break;
- len = event->midi_buffer[2];
- if ( (len > 0) &&
- isspace (event->midi_buffer[2 + len]))
- len--;
+ {
+ if (! smf_event_is_metadata (event))
+ break;
+ len = event->midi_buffer[2];
+ if ( (len > 0) &&
+ isspace (event->midi_buffer[2 + len]))
+ len--;
#if 0
- fprintf (stderr,
- "type: %d, len: %d value: %.*s\n",
- event->midi_buffer[1],
- event->midi_buffer[2],
- (int) event->midi_buffer_length - 3,
- (char *) &event->midi_buffer[3]);
+ fprintf (stderr,
+ "type: %d, len: %d value: %.*s\n",
+ event->midi_buffer[1],
+ event->midi_buffer[2],
+ (int) event->midi_buffer_length - 3,
+ (char *) &event->midi_buffer[3]);
#endif
- if (1 != event->track_number)
- continue; /* heuristic to not get instruments */
- if (0 == len)
- continue;
- switch (event->midi_buffer[1])
- {
- case ET_TEXT_EVENT:
- if (0 != ec->proc (ec->cls,
- "midi",
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- (void*) &event->midi_buffer[3],
- len))
- goto CLEANUP;
- break;
- case ET_COPYRIGHT_NOTICE:
- if (0 != ec->proc (ec->cls,
- "midi",
- EXTRACTOR_METATYPE_COPYRIGHT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- (void*) &event->midi_buffer[3],
- len))
- goto CLEANUP;
- break;
- case ET_TRACK_NAME:
- if (0 != ec->proc (ec->cls,
- "midi",
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- (void*) &event->midi_buffer[3],
- len))
- goto CLEANUP;
- break;
- case ET_INSTRUMENT_NAME:
- if (0 != ec->proc (ec->cls,
- "midi",
- EXTRACTOR_METATYPE_SOURCE_DEVICE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- (void*) &event->midi_buffer[3],
- len))
- goto CLEANUP;
- break;
- case ET_LYRIC_TEXT:
- if (0 != ec->proc (ec->cls,
- "midi",
- EXTRACTOR_METATYPE_LYRICS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- (void*) &event->midi_buffer[3],
- len))
- goto CLEANUP;
- break;
- default:
- break;
- }
+ if (1 != event->track_number)
+ continue; /* heuristic to not get instruments */
+ if (0 == len)
+ continue;
+ switch (event->midi_buffer[1])
+ {
+ case ET_TEXT_EVENT:
+ if (0 != ec->proc (ec->cls,
+ "midi",
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ (void*) &event->midi_buffer[3],
+ len))
+ goto CLEANUP;
+ break;
+ case ET_COPYRIGHT_NOTICE:
+ if (0 != ec->proc (ec->cls,
+ "midi",
+ EXTRACTOR_METATYPE_COPYRIGHT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ (void*) &event->midi_buffer[3],
+ len))
+ goto CLEANUP;
+ break;
+ case ET_TRACK_NAME:
+ if (0 != ec->proc (ec->cls,
+ "midi",
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ (void*) &event->midi_buffer[3],
+ len))
+ goto CLEANUP;
+ break;
+ case ET_INSTRUMENT_NAME:
+ if (0 != ec->proc (ec->cls,
+ "midi",
+ EXTRACTOR_METATYPE_SOURCE_DEVICE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ (void*) &event->midi_buffer[3],
+ len))
+ goto CLEANUP;
+ break;
+ case ET_LYRIC_TEXT:
+ if (0 != ec->proc (ec->cls,
+ "midi",
+ EXTRACTOR_METATYPE_LYRICS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ (void*) &event->midi_buffer[3],
+ len))
+ goto CLEANUP;
+ break;
+ default:
+ break;
}
-
- CLEANUP:
+ }
+
+CLEANUP:
if (NULL != m)
smf_delete (m);
free (data);
diff --git a/src/plugins/mime_extractor.c b/src/plugins/mime_extractor.c
@@ -36,7 +36,7 @@ static magic_t magic;
* Path we used for loading magic data, NULL is used for 'default'.
*/
static char *magic_path;
-
+
/**
* Main entry method for the 'application/ogg' extraction plugin. The
@@ -54,74 +54,75 @@ EXTRACTOR_mime_extract_method (struct EXTRACTOR_ExtractContext *ec)
const char *mime;
ret = ec->read (ec->cls,
- &buf,
- 16 * 1024);
+ &buf,
+ 16 * 1024);
if (-1 == ret)
return;
if ( ( (NULL == magic_path) &&
- (NULL != ec->config) ) ||
+ (NULL != ec->config) ) ||
( (NULL != magic_path) &&
- (NULL == ec->config) ) ||
+ (NULL == ec->config) ) ||
( (NULL != magic_path) &&
- (NULL != ec->config) &&
- (0 != strcmp (magic_path,
- ec->config) )) )
+ (NULL != ec->config) &&
+ (0 != strcmp (magic_path,
+ ec->config) )) )
+ {
+ if (NULL != magic_path)
+ free (magic_path);
+ magic_close (magic);
+ magic = magic_open (MAGIC_MIME_TYPE);
+ if (0 != magic_load (magic, ec->config))
{
- if (NULL != magic_path)
- free (magic_path);
- magic_close (magic);
- magic = magic_open (MAGIC_MIME_TYPE);
- if (0 != magic_load (magic, ec->config))
- {
- /* FIXME: report errors? */
- }
- if (NULL != ec->config)
- magic_path = strdup (ec->config);
- else
- magic_path = NULL;
+ /* FIXME: report errors? */
}
+ if (NULL != ec->config)
+ magic_path = strdup (ec->config);
+ else
+ magic_path = NULL;
+ }
if (NULL == (mime = magic_buffer (magic, buf, ret)))
return;
ec->proc (ec->cls,
- "mime",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- mime,
- strlen (mime) + 1);
+ "mime",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ mime,
+ strlen (mime) + 1);
}
/**
* Constructor for the library. Loads the magic file.
*/
-void __attribute__ ((constructor))
-mime_ltdl_init ()
+void __attribute__ ((constructor))
+mime_ltdl_init ()
{
magic = magic_open (MAGIC_MIME_TYPE);
if (0 != magic_load (magic, magic_path))
- {
- /* FIXME: how to deal with errors? */
- }
+ {
+ /* FIXME: how to deal with errors? */
+ }
}
/**
* Destructor for the library, cleans up.
*/
-void __attribute__ ((destructor))
-mime_ltdl_fini ()
+void __attribute__ ((destructor))
+mime_ltdl_fini ()
{
if (NULL != magic)
- {
- magic_close (magic);
- magic = NULL;
- }
+ {
+ magic_close (magic);
+ magic = NULL;
+ }
if (NULL != magic_path)
- {
- free (magic_path);
- magic_path = NULL;
- }
+ {
+ free (magic_path);
+ magic_path = NULL;
+ }
}
+
/* end of mime_extractor.c */
diff --git a/src/plugins/mp4_extractor.c b/src/plugins/mp4_extractor.c
@@ -29,7 +29,7 @@
/**
- * Callback invoked by libmp4v2 to open the file.
+ * Callback invoked by libmp4v2 to open the file.
* We cheated and passed our extractor context as
* the filename (fingers crossed) and will simply
* return it again to make it the handle.
@@ -40,7 +40,7 @@
*/
static void*
open_cb (const char *name,
- MP4FileMode mode)
+ MP4FileMode mode)
{
void *ecp;
@@ -61,15 +61,15 @@ open_cb (const char *name,
*/
static int
seek_cb (void *handle,
- int64_t pos)
+ int64_t pos)
{
struct EXTRACTOR_ExtractContext *ec = handle;
fprintf (stderr, "Seek: %lld!\n", (long long) pos);
- if (-1 ==
+ if (-1 ==
ec->seek (ec->cls,
- pos,
- SEEK_CUR))
+ pos,
+ SEEK_CUR))
return true; /* failure */
return false;
}
@@ -85,23 +85,23 @@ seek_cb (void *handle,
* @param maxChunkSize some chunk size (ignored)
* @return true on failure, false on success
*/
-static int
+static int
read_cb (void *handle,
- void *buffer,
- int64_t size,
- int64_t *nin,
- int64_t maxChunkSize)
+ void *buffer,
+ int64_t size,
+ int64_t *nin,
+ int64_t maxChunkSize)
{
struct EXTRACTOR_ExtractContext *ec = handle;
void *buf;
ssize_t ret;
-
- fprintf (stderr, "read!\n");
+
+ fprintf (stderr, "read!\n");
*nin = 0;
- if (-1 ==
+ if (-1 ==
(ret = ec->read (ec->cls,
- &buf,
- size)))
+ &buf,
+ size)))
return true; /* failure */
memcpy (buffer, buf, ret);
*nin = ret;
@@ -121,10 +121,10 @@ read_cb (void *handle,
*/
static int
write_cb (void *handle,
- const void *buffer,
- int64_t size,
- int64_t *nout,
- int64_t maxChunkSize)
+ const void *buffer,
+ int64_t size,
+ int64_t *nout,
+ int64_t maxChunkSize)
{
fprintf (stderr, "Write!?\n");
return true; /* failure */
@@ -149,24 +149,26 @@ close_cb (void *handle)
/**
* Wrapper to replace 'stat64' call by libmp4v2.
*/
-int
-stat_cb (const char * path,
- struct stat64 * buf)
+int
+stat_cb (const char *path,
+ struct stat64 *buf)
{
void *ecp;
struct EXTRACTOR_ExtractContext *ec;
fprintf (stderr, "stat!\n");
if (1 != sscanf (path, "%p", &ecp))
- {
- errno = EINVAL;
- return -1;
- }
+ {
+ errno = EINVAL;
+ return -1;
+ }
ec = ecp;
memset (buf, 0, sizeof (struct stat));
buf->st_size = ec->get_size (ec->cls);
return 0;
}
+
+
#endif
@@ -175,7 +177,7 @@ stat_cb (const char * path,
*
* @param ec extraction context provided to the plugin
*/
-void
+void
EXTRACTOR_mp4_extract_method (struct EXTRACTOR_ExtractContext *ec)
{
MP4FileProvider fp;
@@ -185,7 +187,7 @@ EXTRACTOR_mp4_extract_method (struct EXTRACTOR_ExtractContext *ec)
if (1)
return; /* plugin is known not to work yet;
- see issue 138 filed against MP4v2 lib */
+ see issue 138 filed against MP4v2 lib */
snprintf (ecp, sizeof (ecp), "%p", ec);
fp.open = &open_cb;
fp.seek = &seek_cb;
@@ -193,14 +195,15 @@ EXTRACTOR_mp4_extract_method (struct EXTRACTOR_ExtractContext *ec)
fp.write = &write_cb;
fp.close = &close_cb;
if (NULL == (mp4 = MP4ReadProvider (ecp,
- &fp)))
+ &fp)))
return;
tags = MP4TagsAlloc ();
if (MP4TagsFetch (tags, mp4))
- {
- fprintf (stderr, "got tags!\n");
- }
+ {
+ fprintf (stderr, "got tags!\n");
+ }
MP4Close (mp4, 0);
}
+
/* end of mp4_extractor.c */
diff --git a/src/plugins/mpeg_extractor.c b/src/plugins/mpeg_extractor.c
@@ -34,7 +34,11 @@
* @param t type of the meta data
* @param s meta data value in utf8 format
*/
-#define ADD(s,t) do { if (0 != ec->proc (ec->cls, "mpeg", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1)) goto EXIT; } while (0)
+#define ADD(s,t) do { if (0 != ec->proc (ec->cls, "mpeg", t, \
+ EXTRACTOR_METAFORMAT_UTF8, \
+ "text/plain", s, strlen (s) \
+ + 1)) goto EXIT; \
+} while (0)
/**
@@ -68,10 +72,10 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec)
if (NULL == (handle = mpeg2_init ()))
return;
if (NULL == (info = mpeg2_info (handle)))
- {
- mpeg2_close (handle);
- return;
- }
+ {
+ mpeg2_close (handle);
+ return;
+ }
fsize = ec->get_size (ec->cls);
buf = NULL;
have_gop = 0;
@@ -86,130 +90,131 @@ EXTRACTOR_mpeg_extract_method (struct EXTRACTOR_ExtractContext *ec)
fmac = 0;
lformat[0] = '\0';
while (1)
+ {
+ state = mpeg2_parse (handle);
+ switch (state)
{
- state = mpeg2_parse (handle);
- switch (state)
- {
- case STATE_BUFFER:
- if (fail_count > 16)
- goto EXIT; /* do not read large non-mpeg files */
- fail_count++;
- if (0 >= (avail = ec->read (ec->cls,
- &buf,
- 16 * 1024)))
- goto EXIT;
- mpeg2_buffer (handle, buf, buf + avail);
- break;
- case STATE_SEQUENCE:
- fail_count = 0;
- format[0] = fsize;
- format[0]++;
- if (0 == mime)
- {
- mime = 1;
- ADD ("video/mpeg", EXTRACTOR_METATYPE_MIMETYPE);
- }
- snprintf (format,
- sizeof(format), "%ux%u",
- info->sequence->width, info->sequence->height);
- if (0 != strcmp (lformat,
- format))
- {
- strcpy (lformat,
- format);
- ADD (format, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS);
- }
- switch (info->sequence->flags & SEQ_VIDEO_FORMAT_UNSPECIFIED)
- {
- case SEQ_VIDEO_FORMAT_PAL:
- if (0 == fpal)
- {
- fpal = 1;
- ADD ("PAL", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
- }
- break;
- case SEQ_VIDEO_FORMAT_NTSC:
- if (0 == fntsc)
- {
- fntsc = 1;
- ADD ("NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
- }
- break;
- case SEQ_VIDEO_FORMAT_SECAM:
- if (0 == fsecam)
- {
- fsecam = 1;
- ADD ("SECAM", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
- }
- break;
- case SEQ_VIDEO_FORMAT_MAC:
- if (0 == fmac)
- {
- fmac = 1;
- ADD ("MAC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
- }
- break;
- default:
- break;
- }
- if ((info->sequence->flags & SEQ_FLAG_MPEG2) > 0)
- {
- if (0 == fmt1)
- {
- fmt1 = 1;
- ADD ("MPEG2", EXTRACTOR_METATYPE_FORMAT_VERSION);
- }
- }
- else
- {
- if (0 == fmt2)
- {
- fmt2 = 1;
- ADD ("MPEG1", EXTRACTOR_METATYPE_FORMAT_VERSION);
- }
- }
- if ( (0 == did_seek) &&
- (fsize != -1) &&
- (fsize > 1024 * 256 * 2) )
- {
- /* skip to the end of the mpeg for speed */
- did_seek = 1;
- ec->seek (ec->cls,
- fsize - 256 * 1024,
- SEEK_SET);
- }
- break;
- case STATE_GOP:
- fail_count = 0;
- if ( (NULL != info->gop) &&
- (0 != info->gop->pictures) )
- {
- snprintf (gop_format,
- sizeof (gop_format),
- "%02u:%02u:%02u (%u frames)",
- info->gop->hours,
- info->gop->minutes,
- info->gop->seconds,
- info->gop->pictures);
- have_gop = 1;
- }
- break;
- case STATE_SLICE:
- fail_count = 0;
- break;
- case STATE_END:
- fail_count = 0;
- break;
- case STATE_INVALID:
- goto EXIT;
- default:
- break;
- }
+ case STATE_BUFFER:
+ if (fail_count > 16)
+ goto EXIT; /* do not read large non-mpeg files */
+ fail_count++;
+ if (0 >= (avail = ec->read (ec->cls,
+ &buf,
+ 16 * 1024)))
+ goto EXIT;
+ mpeg2_buffer (handle, buf, buf + avail);
+ break;
+ case STATE_SEQUENCE:
+ fail_count = 0;
+ format[0] = fsize;
+ format[0]++;
+ if (0 == mime)
+ {
+ mime = 1;
+ ADD ("video/mpeg", EXTRACTOR_METATYPE_MIMETYPE);
+ }
+ snprintf (format,
+ sizeof(format), "%ux%u",
+ info->sequence->width, info->sequence->height);
+ if (0 != strcmp (lformat,
+ format))
+ {
+ strcpy (lformat,
+ format);
+ ADD (format, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS);
+ }
+ switch (info->sequence->flags & SEQ_VIDEO_FORMAT_UNSPECIFIED)
+ {
+ case SEQ_VIDEO_FORMAT_PAL:
+ if (0 == fpal)
+ {
+ fpal = 1;
+ ADD ("PAL", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+ }
+ break;
+ case SEQ_VIDEO_FORMAT_NTSC:
+ if (0 == fntsc)
+ {
+ fntsc = 1;
+ ADD ("NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+ }
+ break;
+ case SEQ_VIDEO_FORMAT_SECAM:
+ if (0 == fsecam)
+ {
+ fsecam = 1;
+ ADD ("SECAM", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+ }
+ break;
+ case SEQ_VIDEO_FORMAT_MAC:
+ if (0 == fmac)
+ {
+ fmac = 1;
+ ADD ("MAC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+ }
+ break;
+ default:
+ break;
+ }
+ if ((info->sequence->flags & SEQ_FLAG_MPEG2) > 0)
+ {
+ if (0 == fmt1)
+ {
+ fmt1 = 1;
+ ADD ("MPEG2", EXTRACTOR_METATYPE_FORMAT_VERSION);
+ }
+ }
+ else
+ {
+ if (0 == fmt2)
+ {
+ fmt2 = 1;
+ ADD ("MPEG1", EXTRACTOR_METATYPE_FORMAT_VERSION);
+ }
+ }
+ if ( (0 == did_seek) &&
+ (fsize != -1) &&
+ (fsize > 1024 * 256 * 2) )
+ {
+ /* skip to the end of the mpeg for speed */
+ did_seek = 1;
+ ec->seek (ec->cls,
+ fsize - 256 * 1024,
+ SEEK_SET);
+ }
+ break;
+ case STATE_GOP:
+ fail_count = 0;
+ if ( (NULL != info->gop) &&
+ (0 != info->gop->pictures) )
+ {
+ snprintf (gop_format,
+ sizeof (gop_format),
+ "%02u:%02u:%02u (%u frames)",
+ info->gop->hours,
+ info->gop->minutes,
+ info->gop->seconds,
+ info->gop->pictures);
+ have_gop = 1;
+ }
+ break;
+ case STATE_SLICE:
+ fail_count = 0;
+ break;
+ case STATE_END:
+ fail_count = 0;
+ break;
+ case STATE_INVALID:
+ goto EXIT;
+ default:
+ break;
}
- EXIT:
+ }
+EXIT:
if (1 == have_gop)
ADD (gop_format, EXTRACTOR_METATYPE_DURATION);
mpeg2_close (handle);
}
+
/* end of mpeg_extractor.c */
diff --git a/src/plugins/nsf_extractor.c b/src/plugins/nsf_extractor.c
@@ -28,7 +28,6 @@
#include "extractor.h"
-
/* television system flags */
#define PAL_FLAG 0x01
#define DUAL_FLAG 0x02
@@ -130,7 +129,11 @@ struct header
* @param s metadata value as UTF8
* @param t metadata type to use
*/
-#define ADD(s,t) do { if (0 != ec->proc (ec->cls, "nsf", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1)) return; } while (0)
+#define ADD(s,t) do { if (0 != ec->proc (ec->cls, "nsf", t, \
+ EXTRACTOR_METAFORMAT_UTF8, \
+ "text/plain", s, strlen (s) \
+ + 1)) return; \
+} while (0)
/**
@@ -167,19 +170,19 @@ EXTRACTOR_nsf_extract_method (struct EXTRACTOR_ExtractContext *ec)
return;
ADD ("audio/x-nsf", EXTRACTOR_METATYPE_MIMETYPE);
snprintf (nsfversion,
- sizeof(nsfversion),
- "%d",
- head->nsfversion);
+ sizeof(nsfversion),
+ "%d",
+ head->nsfversion);
ADD (nsfversion, EXTRACTOR_METATYPE_FORMAT_VERSION);
snprintf (songs,
- sizeof(songs),
- "%d",
- (int) head->songs);
+ sizeof(songs),
+ "%d",
+ (int) head->songs);
ADD (songs, EXTRACTOR_METATYPE_SONG_COUNT);
snprintf (startingsong,
- sizeof(startingsong),
- "%d",
- (int) head->firstsong);
+ sizeof(startingsong),
+ "%d",
+ (int) head->firstsong);
ADD (startingsong, EXTRACTOR_METATYPE_STARTING_SONG);
memcpy (&album, head->title, 32);
album[32] = '\0';
@@ -192,16 +195,16 @@ EXTRACTOR_nsf_extract_method (struct EXTRACTOR_ExtractContext *ec)
ADD (copyright, EXTRACTOR_METATYPE_COPYRIGHT);
if (0 != (head->tvflags & DUAL_FLAG))
- {
- ADD ("PAL/NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
- }
+ {
+ ADD ("PAL/NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+ }
else
- {
- if (0 != (head->tvflags & PAL_FLAG))
- ADD ("PAL", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
- else
- ADD ("NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
- }
+ {
+ if (0 != (head->tvflags & PAL_FLAG))
+ ADD ("PAL", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+ else
+ ADD ("NTSC", EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM);
+ }
/* Detect Extra Sound Chips needed to play the files */
if (0 != (head->chipflags & VRCVI_FLAG))
@@ -218,4 +221,5 @@ EXTRACTOR_nsf_extract_method (struct EXTRACTOR_ExtractContext *ec)
ADD ("Sunsoft FME-07", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
}
+
/* end of nsf_extractor.c */
diff --git a/src/plugins/nsfe_extractor.c b/src/plugins/nsfe_extractor.c
@@ -396,4 +396,5 @@ EXTRACTOR_nsfe_extract_method (struct EXTRACTOR_ExtractContext *ec)
}
}
+
/* end of nsfe_extractor.c */
diff --git a/src/plugins/odf_extractor.c b/src/plugins/odf_extractor.c
@@ -41,12 +41,12 @@
/**
* Mapping from ODF meta data strings to LE types.
*/
-struct Matches
+struct Matches
{
/**
* ODF description.
*/
- const char * text;
+ const char *text;
/**
* Corresponding LE type.
@@ -85,7 +85,7 @@ static struct Matches tmap[] = {
* @return NULL if no mimetype could be found, otherwise the mime type
*/
static char *
-libextractor_oo_getmimetype (struct EXTRACTOR_UnzipFile * uf)
+libextractor_oo_getmimetype (struct EXTRACTOR_UnzipFile *uf)
{
char filename_inzip[MAXFILENAME];
struct EXTRACTOR_UnzipFileInfo file_info;
@@ -94,61 +94,61 @@ libextractor_oo_getmimetype (struct EXTRACTOR_UnzipFile * uf)
if (EXTRACTOR_UNZIP_OK !=
EXTRACTOR_common_unzip_go_find_local_file (uf,
- "mimetype",
- 2))
+ "mimetype",
+ 2))
return NULL;
- if (EXTRACTOR_UNZIP_OK !=
+ if (EXTRACTOR_UNZIP_OK !=
EXTRACTOR_common_unzip_get_current_file_info (uf,
- &file_info,
- filename_inzip,
- sizeof (filename_inzip),
- NULL,
- 0,
- NULL,
- 0))
+ &file_info,
+ filename_inzip,
+ sizeof (filename_inzip),
+ NULL,
+ 0,
+ NULL,
+ 0))
return NULL;
- if (EXTRACTOR_UNZIP_OK !=
+ if (EXTRACTOR_UNZIP_OK !=
EXTRACTOR_common_unzip_open_current_file (uf))
return NULL;
- buf_size = file_info.uncompressed_size;
- if (buf_size > 1024)
- {
- /* way too large! */
- EXTRACTOR_common_unzip_close_current_file (uf);
- return NULL;
- }
- if (NULL == (buf = malloc (1 + buf_size)))
- {
- /* memory exhausted! */
- EXTRACTOR_common_unzip_close_current_file (uf);
- return NULL;
- }
- if (buf_size !=
- (size_t) EXTRACTOR_common_unzip_read_current_file (uf,
- buf,
- buf_size))
- {
- free(buf);
- EXTRACTOR_common_unzip_close_current_file(uf);
- return NULL;
- }
+ buf_size = file_info.uncompressed_size;
+ if (buf_size > 1024)
+ {
+ /* way too large! */
+ EXTRACTOR_common_unzip_close_current_file (uf);
+ return NULL;
+ }
+ if (NULL == (buf = malloc (1 + buf_size)))
+ {
+ /* memory exhausted! */
+ EXTRACTOR_common_unzip_close_current_file (uf);
+ return NULL;
+ }
+ if (buf_size !=
+ (size_t) EXTRACTOR_common_unzip_read_current_file (uf,
+ buf,
+ buf_size))
+ {
+ free (buf);
+ EXTRACTOR_common_unzip_close_current_file (uf);
+ return NULL;
+ }
/* found something */
buf[buf_size] = '\0';
while ( (0 < buf_size) &&
- isspace( (unsigned char) buf[buf_size - 1]))
+ isspace ( (unsigned char) buf[buf_size - 1]))
buf[--buf_size] = '\0';
- if ('\0' == buf[0])
- {
- free (buf);
- buf = NULL;
- }
+ if ('\0' == buf[0])
+ {
+ free (buf);
+ buf = NULL;
+ }
EXTRACTOR_common_unzip_close_current_file (uf);
return buf;
}
/**
- * Main entry method for the ODF extraction plugin.
+ * Main entry method for the ODF extraction plugin.
*
* @param ec extraction context provided to the plugin
*/
@@ -167,154 +167,157 @@ EXTRACTOR_odf_extract_method (struct EXTRACTOR_ExtractContext *ec)
if (NULL == (uf = EXTRACTOR_common_unzip_open (ec)))
return;
if (NULL != (mimetype = libextractor_oo_getmimetype (uf)))
+ {
+ if (0 != ec->proc (ec->cls,
+ "odf",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ mimetype,
+ strlen (mimetype) + 1))
{
- if (0 != ec->proc (ec->cls,
- "odf",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- mimetype,
- strlen (mimetype) + 1))
- {
- EXTRACTOR_common_unzip_close (uf);
- free (mimetype);
- return;
- }
+ EXTRACTOR_common_unzip_close (uf);
free (mimetype);
+ return;
}
+ free (mimetype);
+ }
if (EXTRACTOR_UNZIP_OK !=
EXTRACTOR_common_unzip_go_find_local_file (uf,
- METAFILE,
- 2))
- {
- /* metafile not found */
- EXTRACTOR_common_unzip_close (uf);
- return;
- }
- if (EXTRACTOR_UNZIP_OK !=
+ METAFILE,
+ 2))
+ {
+ /* metafile not found */
+ EXTRACTOR_common_unzip_close (uf);
+ return;
+ }
+ if (EXTRACTOR_UNZIP_OK !=
EXTRACTOR_common_unzip_get_current_file_info (uf,
- &file_info,
- filename_inzip,
- sizeof (filename_inzip),
- NULL, 0, NULL, 0))
- {
- /* problems accessing metafile */
- EXTRACTOR_common_unzip_close (uf);
- return;
- }
- if (EXTRACTOR_UNZIP_OK !=
- EXTRACTOR_common_unzip_open_current_file (uf))
- {
- /* problems with unzip */
- EXTRACTOR_common_unzip_close (uf);
- return;
- }
+ &file_info,
+ filename_inzip,
+ sizeof (filename_inzip),
+ NULL, 0, NULL, 0))
+ {
+ /* problems accessing metafile */
+ EXTRACTOR_common_unzip_close (uf);
+ return;
+ }
+ if (EXTRACTOR_UNZIP_OK !=
+ EXTRACTOR_common_unzip_open_current_file (uf))
+ {
+ /* problems with unzip */
+ EXTRACTOR_common_unzip_close (uf);
+ return;
+ }
buf_size = file_info.uncompressed_size;
- if (buf_size > 128 * 1024)
- {
- /* too big to be meta-data! */
- EXTRACTOR_common_unzip_close_current_file (uf);
- EXTRACTOR_common_unzip_close (uf);
- return;
- }
- if (NULL == (buf = malloc (buf_size+1)))
- {
- /* out of memory */
- EXTRACTOR_common_unzip_close_current_file (uf);
- EXTRACTOR_common_unzip_close (uf);
- return;
- }
- if (buf_size != EXTRACTOR_common_unzip_read_current_file (uf, buf, buf_size))
- {
- EXTRACTOR_common_unzip_close_current_file (uf);
- goto CLEANUP;
- }
+ if (buf_size > 128 * 1024)
+ {
+ /* too big to be meta-data! */
+ EXTRACTOR_common_unzip_close_current_file (uf);
+ EXTRACTOR_common_unzip_close (uf);
+ return;
+ }
+ if (NULL == (buf = malloc (buf_size + 1)))
+ {
+ /* out of memory */
+ EXTRACTOR_common_unzip_close_current_file (uf);
+ EXTRACTOR_common_unzip_close (uf);
+ return;
+ }
+ if (buf_size != EXTRACTOR_common_unzip_read_current_file (uf, buf, buf_size))
+ {
+ EXTRACTOR_common_unzip_close_current_file (uf);
+ goto CLEANUP;
+ }
EXTRACTOR_common_unzip_close_current_file (uf);
/* we don't do "proper" parsing of the meta-data but rather use some heuristics
to get values out that we understand */
buf[buf_size] = '\0';
/* printf("%s\n", buf); */
/* try to find some of the typical OO xml headers */
- if ( (strstr (buf, "xmlns:meta=\"http://openoffice.org/2000/meta\"") != NULL) ||
- (strstr (buf, "xmlns:dc=\"http://purl.org/dc/elements/1.1/\"") != NULL) ||
- (strstr (buf, "xmlns:xlink=\"http://www.w3.org/1999/xlink\"") != NULL) )
+ if ( (strstr (buf, "xmlns:meta=\"http://openoffice.org/2000/meta\"") !=
+ NULL) ||
+ (strstr (buf, "xmlns:dc=\"http://purl.org/dc/elements/1.1/\"") !=
+ NULL) ||
+ (strstr (buf, "xmlns:xlink=\"http://www.w3.org/1999/xlink\"") != NULL) )
+ {
+ /* accept as meta-data */
+ for (i = 0; NULL != tmap[i].text; i++)
{
- /* accept as meta-data */
- for (i = 0; NULL != tmap[i].text; i++)
- {
- char * spos;
- char * epos;
- char needle[256];
- int oc;
-
- pbuf = buf;
-
- while (1)
- {
- strcpy(needle, "<");
- strcat(needle, tmap[i].text);
- strcat(needle, ">");
- spos = strstr(pbuf, needle);
- if (NULL == spos)
- {
- strcpy(needle, tmap[i].text);
- strcat(needle, "=\"");
- spos = strstr(pbuf, needle);
- if (spos == NULL)
- break;
- spos += strlen(needle);
- epos = spos;
- while ( (epos[0] != '\0') &&
- (epos[0] != '"') )
- epos++;
- }
- else
- {
- oc = 0;
- spos += strlen(needle);
- while ( (spos[0] != '\0') &&
- ( (spos[0] == '<') ||
- (oc > 0) ) )
- {
- if (spos[0] == '<')
- oc++;
- if (spos[0] == '>')
- oc--;
- spos++;
- }
- epos = spos;
- while ( (epos[0] != '\0') &&
- (epos[0] != '<') &&
- (epos[0] != '>') )
- {
- epos++;
- }
- }
- if (spos != epos)
- {
- char key[epos - spos + 1];
-
- memcpy(key, spos, epos-spos);
- key[epos-spos] = '\0';
- if (0 != ec->proc (ec->cls,
- "odf",
- tmap[i].type,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- key,
- epos - spos + 1))
- goto CLEANUP;
- pbuf = epos;
- }
- else
- break;
- }
- }
+ char *spos;
+ char *epos;
+ char needle[256];
+ int oc;
+
+ pbuf = buf;
+
+ while (1)
+ {
+ strcpy (needle, "<");
+ strcat (needle, tmap[i].text);
+ strcat (needle, ">");
+ spos = strstr (pbuf, needle);
+ if (NULL == spos)
+ {
+ strcpy (needle, tmap[i].text);
+ strcat (needle, "=\"");
+ spos = strstr (pbuf, needle);
+ if (spos == NULL)
+ break;
+ spos += strlen (needle);
+ epos = spos;
+ while ( (epos[0] != '\0') &&
+ (epos[0] != '"') )
+ epos++;
+ }
+ else
+ {
+ oc = 0;
+ spos += strlen (needle);
+ while ( (spos[0] != '\0') &&
+ ( (spos[0] == '<') ||
+ (oc > 0) ) )
+ {
+ if (spos[0] == '<')
+ oc++;
+ if (spos[0] == '>')
+ oc--;
+ spos++;
+ }
+ epos = spos;
+ while ( (epos[0] != '\0') &&
+ (epos[0] != '<') &&
+ (epos[0] != '>') )
+ {
+ epos++;
+ }
+ }
+ if (spos != epos)
+ {
+ char key[epos - spos + 1];
+
+ memcpy (key, spos, epos - spos);
+ key[epos - spos] = '\0';
+ if (0 != ec->proc (ec->cls,
+ "odf",
+ tmap[i].type,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ key,
+ epos - spos + 1))
+ goto CLEANUP;
+ pbuf = epos;
+ }
+ else
+ break;
+ }
}
- CLEANUP:
+ }
+CLEANUP:
free (buf);
EXTRACTOR_common_unzip_close (uf);
}
+
/* end of odf_extractor.c */
diff --git a/src/plugins/ogg_extractor.c b/src/plugins/ogg_extractor.c
@@ -52,15 +52,15 @@ read_ogg (void *ptr, size_t size, size_t nmemb, void *datasource)
data = NULL;
ret = ec->read (ec->cls,
- &data,
- size * nmemb);
+ &data,
+ size * nmemb);
if (-1 == ret)
return 0;
if (0 == ret)
- {
- errno = 0;
- return 0;
- }
+ {
+ errno = 0;
+ return 0;
+ }
memcpy (ptr, data, ret);
errno = 0;
return ret;
@@ -77,8 +77,8 @@ read_ogg (void *ptr, size_t size, size_t nmemb, void *datasource)
*/
static int
seek_ogg (void *datasource,
- ogg_int64_t offset,
- int whence)
+ ogg_int64_t offset,
+ int whence)
{
struct EXTRACTOR_ExtractContext *ec = datasource;
int64_t new_position;
@@ -100,12 +100,11 @@ tell_ogg (void *datasource)
struct EXTRACTOR_ExtractContext *ec = datasource;
return (long) ec->seek (ec->cls,
- 0,
- SEEK_CUR);
+ 0,
+ SEEK_CUR);
}
-
/**
* Extract the associated meta data for a given label from vorbis.
*
@@ -115,7 +114,7 @@ tell_ogg (void *datasource)
*/
static char *
get_comment (vorbis_comment *vc,
- const char *label)
+ const char *label)
{
if (NULL == vc)
return NULL;
@@ -129,7 +128,11 @@ get_comment (vorbis_comment *vc,
* @param t LE meta data type
* @param s meta data to add
*/
-#define ADD(t,s) do { if (0 != (ret = ec->proc (ec->cls, "ogg", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen(s)+1))) goto FINISH; } while (0)
+#define ADD(t,s) do { if (0 != (ret = ec->proc (ec->cls, "ogg", t, \
+ EXTRACTOR_METAFORMAT_UTF8, \
+ "text/plain", s, strlen (s) \
+ + 1))) goto FINISH; \
+} while (0)
/**
@@ -138,7 +141,8 @@ get_comment (vorbis_comment *vc,
* @param t LE meta data type
* @param d vorbis meta data label
*/
-#define ADDG(t,d) do { m = get_comment (comments, d); if (NULL != m) ADD(t,m); } while (0)
+#define ADDG(t,d) do { m = get_comment (comments, d); if (NULL != m) ADD (t,m); \
+} while (0)
/**
@@ -200,4 +204,5 @@ FINISH:
ov_clear (&vf);
}
+
/* end of ogg_extractor.c */
diff --git a/src/plugins/old/applefile_extractor.c b/src/plugins/old/applefile_extractor.c
@@ -42,10 +42,10 @@ typedef struct
#define APPLEFILE_HEADER_SIZE 26
#define APPLEFILE_HEADER_SPEC "4bW16bH"
#define APPLEFILE_HEADER_FIELDS(p) \
- &(p)->magic, \
- &(p)->version, \
- &(p)->homeFileSystem, \
- &(p)->entries
+ & (p)->magic, \
+ &(p)->version, \
+ &(p)->homeFileSystem, \
+ &(p)->entries
typedef struct
{
@@ -57,9 +57,9 @@ typedef struct
#define APPLEFILE_ENTRY_DESCRIPTOR_SIZE 12
#define APPLEFILE_ENTRY_DESCRIPTOR_SPEC "WWW"
#define APPLEFILE_ENTRY_DESCRIPTOR_FIELDS(p) \
- &(p)->id, \
- &(p)->offset, \
- &(p)->length
+ & (p)->id, \
+ &(p)->offset, \
+ &(p)->length
#define AED_ID_DATA_FORK 1
#define AED_ID_RESOURCE_FORK 2
@@ -76,43 +76,47 @@ typedef struct
#define AED_ID_AFP_FILE_INFO 14
#define AED_ID_DIRECTORY_ID 15
-static int readApplefileHeader(const unsigned char *data,
- size_t *offset,
- size_t size,
- ApplefileHeader *hdr)
+static int
+readApplefileHeader (const unsigned char *data,
+ size_t *offset,
+ size_t size,
+ ApplefileHeader *hdr)
{
if ((*offset + APPLEFILE_HEADER_SIZE) > size)
return -1;
- EXTRACTOR_common_cat_unpack(data + *offset,
- APPLEFILE_HEADER_SPEC,
- APPLEFILE_HEADER_FIELDS(hdr));
+ EXTRACTOR_common_cat_unpack (data + *offset,
+ APPLEFILE_HEADER_SPEC,
+ APPLEFILE_HEADER_FIELDS (hdr));
*offset += APPLEFILE_HEADER_SIZE;
return 0;
}
-static int readEntryDescriptor(const unsigned char *data,
- size_t *offset,
- size_t size,
- ApplefileEntryDescriptor *dsc)
+
+static int
+readEntryDescriptor (const unsigned char *data,
+ size_t *offset,
+ size_t size,
+ ApplefileEntryDescriptor *dsc)
{
if ((*offset + APPLEFILE_ENTRY_DESCRIPTOR_SIZE) > size)
return -1;
- EXTRACTOR_common_cat_unpack(data + *offset,
- APPLEFILE_ENTRY_DESCRIPTOR_SPEC,
- APPLEFILE_ENTRY_DESCRIPTOR_FIELDS(dsc));
+ EXTRACTOR_common_cat_unpack (data + *offset,
+ APPLEFILE_ENTRY_DESCRIPTOR_SPEC,
+ APPLEFILE_ENTRY_DESCRIPTOR_FIELDS (dsc));
*offset += APPLEFILE_ENTRY_DESCRIPTOR_SIZE;
return 0;
}
+
/* mimetype = application/applefile */
-int
+int
EXTRACTOR_applefile_extract (const char *sdata,
- size_t size,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls,
- const char *options)
+ size_t size,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls,
+ const char *options)
{
const unsigned char *data = (const unsigned char*) sdata;
size_t offset;
@@ -121,129 +125,134 @@ EXTRACTOR_applefile_extract (const char *sdata,
int i;
offset = 0;
- if (readApplefileHeader(data, &offset, size, &header) == -1)
+ if (readApplefileHeader (data, &offset, size, &header) == -1)
return 0;
- if ( (memcmp(header.magic, APPLESINGLE_SIGNATURE, 4) != 0) &&
- (memcmp(header.magic, APPLEDOUBLE_SIGNATURE, 4) != 0) )
+ if ( (memcmp (header.magic, APPLESINGLE_SIGNATURE, 4) != 0) &&
+ (memcmp (header.magic, APPLEDOUBLE_SIGNATURE, 4) != 0) )
return 0;
- if (0 != proc (proc_cls,
- "applefile",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "application/applefile",
- strlen ("application/applefile")+1))
+ if (0 != proc (proc_cls,
+ "applefile",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "application/applefile",
+ strlen ("application/applefile") + 1))
return 1;
#if DEBUG
- fprintf(stderr,
- "applefile header: %08x %d\n", header.version, header.entries);
+ fprintf (stderr,
+ "applefile header: %08x %d\n", header.version, header.entries);
#endif
- if ( (header.version != 0x00010000) &&
+ if ( (header.version != 0x00010000) &&
(header.version != 0x00020000) )
return 0;
- for (i = 0; i < header.entries; i++) {
- if (readEntryDescriptor(data, &offset, size, &dsc) == -1)
+ for (i = 0; i < header.entries; i++)
+ {
+ if (readEntryDescriptor (data, &offset, size, &dsc) == -1)
break;
#if DEBUG
- fprintf(stderr,
- "applefile entry: %u %u %u\n", dsc.id, dsc.offset, dsc.length);
+ fprintf (stderr,
+ "applefile entry: %u %u %u\n", dsc.id, dsc.offset, dsc.length);
#endif
- switch (dsc.id)
+ switch (dsc.id)
+ {
+ case AED_ID_DATA_FORK:
{
- case AED_ID_DATA_FORK:
- {
- /* same as in filenameextractor.c */
- char s[14];
+ /* same as in filenameextractor.c */
+ char s[14];
if (dsc.length >= 1000000000)
snprintf (s, 13, "%.2f %s", dsc.length / 1000000000.0,
- _("GB"));
+ _ ("GB"));
else if (dsc.length >= 1000000)
- snprintf (s, 13, "%.2f %s", dsc.length / 1000000.0, _("MB"));
+ snprintf (s, 13, "%.2f %s", dsc.length / 1000000.0, _ ("MB"));
else if (dsc.length >= 1000)
- snprintf (s, 13, "%.2f %s", dsc.length / 1000.0, _("KB"));
+ snprintf (s, 13, "%.2f %s", dsc.length / 1000.0, _ ("KB"));
else
- snprintf (s, 13, "%.2f %s", (double) dsc.length, _("Bytes"));
-
- if (0 != proc (proc_cls,
- "applefile",
- EXTRACTOR_METATYPE_EMBEDDED_FILE_SIZE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- s,
- strlen (s) + 1))
- return 1;
- }
- break;
- case AED_ID_REAL_NAME:
- {
- char s[2048];
- if ( (dsc.length < sizeof(s)) &&
- ((dsc.offset + dsc.length) < size) ) {
- memcpy(s, data + dsc.offset, dsc.length);
- s[dsc.length] = '\0';
- if (0 != proc (proc_cls,
- "applefile",
- EXTRACTOR_METATYPE_FILENAME,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- s,
- dsc.length + 1))
- return 1;
- }
- }
- break;
- case AED_ID_COMMENT:
- if ( (dsc.length < 65536) && ((dsc.offset + dsc.length) < size) ) {
- char *s = malloc(dsc.length + 1);
- if (s != NULL) {
- memcpy(s, data + dsc.offset, dsc.length);
- s[dsc.length] = '\0';
- if (0 != proc (proc_cls,
- "applefile",
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- s,
- dsc.length + 1))
- {
- free (s);
- return 1;
- }
- free (s);
- }
- }
- break;
- case AED_ID_FINDER_INFO:
- if (dsc.length >= 16 && (dsc.offset + dsc.length) < size) {
- char s[5];
- memcpy(s, data + dsc.offset, 4);
- s[4] = '\0';
- if (0 != proc (proc_cls,
- "applefile",
- EXTRACTOR_METATYPE_FINDER_FILE_TYPE,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- s,
- strlen(s) + 1))
- return 1;
-
- memcpy(s, data + dsc.offset + 4, 4);
- s[4] = '\0';
- if (0 != proc (proc_cls,
- "applefile",
- EXTRACTOR_METATYPE_FINDER_FILE_CREATOR,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- s,
- strlen(s) + 1))
- return 1;
+ snprintf (s, 13, "%.2f %s", (double) dsc.length, _ ("Bytes"));
+
+ if (0 != proc (proc_cls,
+ "applefile",
+ EXTRACTOR_METATYPE_EMBEDDED_FILE_SIZE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ s,
+ strlen (s) + 1))
+ return 1;
+ }
+ break;
+ case AED_ID_REAL_NAME:
+ {
+ char s[2048];
+ if ( (dsc.length < sizeof(s)) &&
+ ((dsc.offset + dsc.length) < size) )
+ {
+ memcpy (s, data + dsc.offset, dsc.length);
+ s[dsc.length] = '\0';
+ if (0 != proc (proc_cls,
+ "applefile",
+ EXTRACTOR_METATYPE_FILENAME,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ s,
+ dsc.length + 1))
+ return 1;
+ }
+ }
+ break;
+ case AED_ID_COMMENT:
+ if ( (dsc.length < 65536) && ((dsc.offset + dsc.length) < size) )
+ {
+ char *s = malloc (dsc.length + 1);
+ if (s != NULL)
+ {
+ memcpy (s, data + dsc.offset, dsc.length);
+ s[dsc.length] = '\0';
+ if (0 != proc (proc_cls,
+ "applefile",
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ s,
+ dsc.length + 1))
+ {
+ free (s);
+ return 1;
+ }
+ free (s);
}
- break;
- default:
- break;
+ }
+ break;
+ case AED_ID_FINDER_INFO:
+ if ((dsc.length >= 16) && ( (dsc.offset + dsc.length) < size) )
+ {
+ char s[5];
+ memcpy (s, data + dsc.offset, 4);
+ s[4] = '\0';
+ if (0 != proc (proc_cls,
+ "applefile",
+ EXTRACTOR_METATYPE_FINDER_FILE_TYPE,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ s,
+ strlen (s) + 1))
+ return 1;
+
+ memcpy (s, data + dsc.offset + 4, 4);
+ s[4] = '\0';
+ if (0 != proc (proc_cls,
+ "applefile",
+ EXTRACTOR_METATYPE_FINDER_FILE_CREATOR,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ s,
+ strlen (s) + 1))
+ return 1;
+ }
+ break;
+ default:
+ break;
}
}
return 0;
diff --git a/src/plugins/old/asf_extractor.c b/src/plugins/old/asf_extractor.c
@@ -110,199 +110,288 @@ static const struct
{
const char *name;
const LE_GUID guid;
-} guids[] =
-{
+} guids[] = {
{
"error",
{
- 0x0,}},
- /* base ASF objects */
+ 0x0,
+ }
+ },
+ /* base ASF objects */
{
"header",
{
0x75b22630, 0x668e, 0x11cf,
{
- 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}}},
+ 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c
+ }
+ }
+ },
{
"data",
{
0x75b22636, 0x668e, 0x11cf,
{
- 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}}},
+ 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c
+ }
+ }
+ },
{
"simple index",
{
0x33000890, 0xe5b1, 0x11cf,
{
- 0x89, 0xf4, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb}}},
- /* header ASF objects */
+ 0x89, 0xf4, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb
+ }
+ }
+ },
+ /* header ASF objects */
{
"file properties",
{
0x8cabdca1, 0xa947, 0x11cf,
{
- 0x8e, 0xe4, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65}}},
+ 0x8e, 0xe4, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65
+ }
+ }
+ },
{
"stream header",
{
0xb7dc0791, 0xa9b7, 0x11cf,
{
- 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65}}},
+ 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65
+ }
+ }
+ },
{
"stream bitrate properties", /* (http://get.to/sdp) */
{
0x7bf875ce, 0x468d, 0x11d1,
{
- 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2}}},
+ 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2
+ }
+ }
+ },
{
"content description",
{
0x75b22633, 0x668e, 0x11cf,
{
- 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}}},
+ 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c
+ }
+ }
+ },
{
"extended content encryption",
{
0x298ae614, 0x2622, 0x4c17,
{
- 0xb9, 0x35, 0xda, 0xe0, 0x7e, 0xe9, 0x28, 0x9c}}},
+ 0xb9, 0x35, 0xda, 0xe0, 0x7e, 0xe9, 0x28, 0x9c
+ }
+ }
+ },
{
"script command",
{
0x1efb1a30, 0x0b62, 0x11d0,
{
- 0xa3, 0x9b, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6}}},
+ 0xa3, 0x9b, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6
+ }
+ }
+ },
{
"marker",
{
0xf487cd01, 0xa951, 0x11cf,
{
- 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65}}},
+ 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65
+ }
+ }
+ },
{
"header extension",
{
0x5fbf03b5, 0xa92e, 0x11cf,
{
- 0x8e, 0xe3, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65}}},
+ 0x8e, 0xe3, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65
+ }
+ }
+ },
{
"bitrate mutual exclusion",
{
0xd6e229dc, 0x35da, 0x11d1,
{
- 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe}}},
+ 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe
+ }
+ }
+ },
{
"codec list",
{
0x86d15240, 0x311d, 0x11d0,
{
- 0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6}}},
+ 0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6
+ }
+ }
+ },
{
"extended content description",
{
0xd2d0a440, 0xe307, 0x11d2,
{
- 0x97, 0xf0, 0x00, 0xa0, 0xc9, 0x5e, 0xa8, 0x50}}},
+ 0x97, 0xf0, 0x00, 0xa0, 0xc9, 0x5e, 0xa8, 0x50
+ }
+ }
+ },
{
"error correction",
{
0x75b22635, 0x668e, 0x11cf,
{
- 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}}},
+ 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c
+ }
+ }
+ },
{
"padding",
{
0x1806d474, 0xcadf, 0x4509,
{
- 0xa4, 0xba, 0x9a, 0xab, 0xcb, 0x96, 0xaa, 0xe8}}},
- /* stream properties object stream type */
+ 0xa4, 0xba, 0x9a, 0xab, 0xcb, 0x96, 0xaa, 0xe8
+ }
+ }
+ },
+ /* stream properties object stream type */
{
"audio media",
{
0xf8699e40, 0x5b4d, 0x11cf,
{
- 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b}}},
+ 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b
+ }
+ }
+ },
{
"video media",
{
0xbc19efc0, 0x5b4d, 0x11cf,
{
- 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b}}},
+ 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b
+ }
+ }
+ },
{
"command media",
{
0x59dacfc0, 0x59e6, 0x11d0,
{
- 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6}}},
- /* stream properties object error correction */
+ 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6
+ }
+ }
+ },
+ /* stream properties object error correction */
{
"no error correction",
{
0x20fb5700, 0x5b55, 0x11cf,
{
- 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b}}},
+ 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b
+ }
+ }
+ },
{
"audio spread",
{
0xbfc3cd50, 0x618f, 0x11cf,
{
- 0x8b, 0xb2, 0x00, 0xaa, 0x00, 0xb4, 0xe2, 0x20}}},
- /* mutual exclusion object exlusion type */
+ 0x8b, 0xb2, 0x00, 0xaa, 0x00, 0xb4, 0xe2, 0x20
+ }
+ }
+ },
+ /* mutual exclusion object exlusion type */
{
"mutex bitrate",
{
0xd6e22a01, 0x35da, 0x11d1,
{
- 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe}}},
+ 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe
+ }
+ }
+ },
{
"mutex unknown",
{
0xd6e22a02, 0x35da, 0x11d1,
{
- 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe}}},
- /* header extension */
+ 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe
+ }
+ }
+ },
+ /* header extension */
{
"reserved_1",
{
0xabd3d211, 0xa9ba, 0x11cf,
{
- 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65}}},
- /* script command */
+ 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65
+ }
+ }
+ },
+ /* script command */
{
"reserved script command",
{
0x4B1ACBE3, 0x100B, 0x11D0,
{
- 0xA3, 0x9B, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6}}},
- /* marker object */
+ 0xA3, 0x9B, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6
+ }
+ }
+ },
+ /* marker object */
{
"reserved marker",
{
0x4CFEDB20, 0x75F6, 0x11CF,
{
- 0x9C, 0x0F, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xCB}}},
- /* various */
- /* Already defined (reserved_1)
- { "head2",
- { 0xabd3d211, 0xa9ba, 0x11cf, { 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 }} },
- */
+ 0x9C, 0x0F, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xCB
+ }
+ }
+ },
+ /* various */
+ /* Already defined (reserved_1)
+ { "head2",
+ { 0xabd3d211, 0xa9ba, 0x11cf, { 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65 }} },
+ */
{
"audio conceal none",
{
0x49f1a440, 0x4ece, 0x11d0,
{
- 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6}}},
+ 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6
+ }
+ }
+ },
{
"codec comment1 header",
{
0x86d15241, 0x311d, 0x11d0,
{
- 0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6}}},
+ 0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6
+ }
+ }
+ },
{
"asf 2.0 header",
{
0xd6e229d1, 0x35da, 0x11d1,
{
-0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe}}},};
+ 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe
+ }
+ }
+ },
+};
struct demux_asf_s
@@ -326,7 +415,7 @@ struct demux_asf_s
};
static int
-readBuf (struct demux_asf_s * this, void *buf, int len)
+readBuf (struct demux_asf_s *this, void *buf, int len)
{
int min;
@@ -338,8 +427,9 @@ readBuf (struct demux_asf_s * this, void *buf, int len)
return min;
}
+
static uint8_t
-get_byte (struct demux_asf_s * this)
+get_byte (struct demux_asf_s *this)
{
uint8_t buf;
int i;
@@ -350,8 +440,9 @@ get_byte (struct demux_asf_s * this)
return buf;
}
+
static uint16_t
-get_le16 (struct demux_asf_s * this)
+get_le16 (struct demux_asf_s *this)
{
uint8_t buf[2];
int i;
@@ -362,8 +453,9 @@ get_le16 (struct demux_asf_s * this)
return buf[0] | (buf[1] << 8);
}
+
static uint32_t
-get_le32 (struct demux_asf_s * this)
+get_le32 (struct demux_asf_s *this)
{
uint8_t buf[4];
int i;
@@ -374,8 +466,9 @@ get_le32 (struct demux_asf_s * this)
return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24);
}
+
static uint64_t
-get_le64 (struct demux_asf_s * this)
+get_le64 (struct demux_asf_s *this)
{
uint8_t buf[8];
int i;
@@ -384,16 +477,17 @@ get_le64 (struct demux_asf_s * this)
if (i != 8)
this->status = DEMUX_FINISHED;
return (uint64_t) buf[0]
- | ((uint64_t) buf[1] << 8)
- | ((uint64_t) buf[2] << 16)
- | ((uint64_t) buf[3] << 24)
- | ((uint64_t) buf[4] << 32)
- | ((uint64_t) buf[5] << 40)
- | ((uint64_t) buf[6] << 48) | ((uint64_t) buf[7] << 54);
+ | ((uint64_t) buf[1] << 8)
+ | ((uint64_t) buf[2] << 16)
+ | ((uint64_t) buf[3] << 24)
+ | ((uint64_t) buf[4] << 32)
+ | ((uint64_t) buf[5] << 40)
+ | ((uint64_t) buf[6] << 48) | ((uint64_t) buf[7] << 54);
}
+
static int
-get_guid (struct demux_asf_s * this)
+get_guid (struct demux_asf_s *this)
{
int i;
LE_GUID g;
@@ -406,7 +500,7 @@ get_guid (struct demux_asf_s * this)
if (this->status == DEMUX_FINISHED)
return GUID_ERROR;
for (i = 1; i < GUID_END; i++)
- if (!memcmp (&g, &guids[i].guid, sizeof (LE_GUID)))
+ if (! memcmp (&g, &guids[i].guid, sizeof (LE_GUID)))
return i;
return GUID_ERROR;
@@ -414,7 +508,7 @@ get_guid (struct demux_asf_s * this)
static int
-asf_read_header (struct demux_asf_s * this)
+asf_read_header (struct demux_asf_s *this)
{
int guid;
uint64_t gsize;
@@ -426,62 +520,67 @@ asf_read_header (struct demux_asf_s * this)
get_le64 (this); /* object size */
get_le32 (this); /* number of header objects */
get_byte (this); /* reserved 1 */
- get_byte (this); /* reserved 2 */
+ get_byte (this); /* reserved 2 */
while (this->status != DEMUX_FINISHED)
+ {
+ guid = get_guid (this); /* object ID */
+ gsize = get_le64 (this); /* object size */
+ if (gsize < 24)
+ goto fail;
+ switch (guid)
{
- guid = get_guid (this); /* object ID */
- gsize = get_le64 (this); /* object size */
- if (gsize < 24)
- goto fail;
- switch (guid)
- {
- case GUID_ASF_FILE_PROPERTIES:
- guid = get_guid (this); /* file ID */
- get_le64 (this); /* file size */
- get_le64 (this); /* creation date */
- get_le64 (this); /* nb_packets */
- this->length = get_le64 (this); /* play duration in 100 ns units */
- get_le64 (this); /* send duration */
- get_le64 (this); /* preroll */
- get_le32 (this); /* flags */
- get_le32 (this); /* min size */
- get_le32 (this); /* max size */
- get_le32 (this); /* max bitrate */
- break;
- case GUID_ASF_DATA:
- goto headers_ok;
- break;
- case GUID_ASF_CONTENT_DESCRIPTION:
- len1 = get_le16 (this);
- len2 = get_le16 (this);
- len3 = get_le16 (this);
- len4 = get_le16 (this);
- len5 = get_le16 (this);
- this->title = EXTRACTOR_common_convert_to_utf8 (&this->input[this->inputPos],
- len1,
- "UTF-16");
- this->inputPos += len1;
- this->author = EXTRACTOR_common_convert_to_utf8 (&this->input[this->inputPos],
- len2,
- "UTF-16");
- this->inputPos += len2;
- this->copyright = EXTRACTOR_common_convert_to_utf8 (&this->input[this->inputPos],
- len3,
- "UTF-16");
- this->inputPos += len3;
- this->comment = EXTRACTOR_common_convert_to_utf8 (&this->input[this->inputPos],
- len4,
- "UTF-16");
- this->inputPos += len4;
- this->rating = EXTRACTOR_common_convert_to_utf8 (&this->input[this->inputPos],
- len5,
- "UTF-16");
- this->inputPos += len5;
- break;
- default:
- this->inputPos += gsize - 24;
- }
+ case GUID_ASF_FILE_PROPERTIES:
+ guid = get_guid (this); /* file ID */
+ get_le64 (this); /* file size */
+ get_le64 (this); /* creation date */
+ get_le64 (this); /* nb_packets */
+ this->length = get_le64 (this); /* play duration in 100 ns units */
+ get_le64 (this); /* send duration */
+ get_le64 (this); /* preroll */
+ get_le32 (this); /* flags */
+ get_le32 (this); /* min size */
+ get_le32 (this); /* max size */
+ get_le32 (this); /* max bitrate */
+ break;
+ case GUID_ASF_DATA:
+ goto headers_ok;
+ break;
+ case GUID_ASF_CONTENT_DESCRIPTION:
+ len1 = get_le16 (this);
+ len2 = get_le16 (this);
+ len3 = get_le16 (this);
+ len4 = get_le16 (this);
+ len5 = get_le16 (this);
+ this->title = EXTRACTOR_common_convert_to_utf8 (
+ &this->input[this->inputPos],
+ len1,
+ "UTF-16");
+ this->inputPos += len1;
+ this->author = EXTRACTOR_common_convert_to_utf8 (
+ &this->input[this->inputPos],
+ len2,
+ "UTF-16");
+ this->inputPos += len2;
+ this->copyright = EXTRACTOR_common_convert_to_utf8 (
+ &this->input[this->inputPos],
+ len3,
+ "UTF-16");
+ this->inputPos += len3;
+ this->comment = EXTRACTOR_common_convert_to_utf8 (
+ &this->input[this->inputPos],
+ len4,
+ "UTF-16");
+ this->inputPos += len4;
+ this->rating = EXTRACTOR_common_convert_to_utf8 (
+ &this->input[this->inputPos],
+ len5,
+ "UTF-16");
+ this->inputPos += len5;
+ break;
+ default:
+ this->inputPos += gsize - 24;
}
+ }
headers_ok:
this->inputPos += sizeof (LE_GUID) + 10;
@@ -502,12 +601,12 @@ fail:
video/x-ms-wax: wva: wma metafile; */
/* mimetype = application/applefile */
-int
+int
EXTRACTOR_asf_extract (const char *data,
- size_t size,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls,
- const char *options)
+ size_t size,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls,
+ const char *options)
{
struct demux_asf_s this;
size_t slen;
@@ -521,60 +620,60 @@ EXTRACTOR_asf_extract (const char *data,
ret = 0;
if (1 == asf_read_header (&this))
{
- snprintf (duration_str,
- sizeof (duration_str),
- "%llu ms", (unsigned long long) (this.length / 10000LL));
+ snprintf (duration_str,
+ sizeof (duration_str),
+ "%llu ms", (unsigned long long) (this.length / 10000LL));
if ( ( (this.title != NULL) &&
- (0 < (slen = strlen(this.title))) &&
- (0 != proc (proc_cls,
- "asf",
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- this.title,
- slen + 1)) ) ||
- ( (this.author != NULL) &&
- (0 < (slen = strlen(this.author))) &&
- (0 != proc (proc_cls,
- "asf",
- EXTRACTOR_METATYPE_AUTHOR_NAME,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- this.author,
- slen + 1)) ) ||
- ( (this.comment != NULL) &&
- (0 < (slen = strlen(this.comment))) &&
- (0 != proc (proc_cls,
- "asf",
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- this.comment,
- slen + 1)) ) ||
- ( (this.copyright != NULL) &&
- (0 < (slen = strlen(this.copyright))) &&
- (0 != proc (proc_cls,
- "asf",
- EXTRACTOR_METATYPE_COPYRIGHT,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- this.copyright,
- slen + 1)) ) ||
- (0 != proc (proc_cls,
- "asf",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- "video/x-ms-asf",
- strlen("video/x-ms-asf") + 1)) ||
- (0 != proc (proc_cls,
- "asf",
- EXTRACTOR_METATYPE_DURATION,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- duration_str,
- strlen(duration_str) + 1)) )
- ret = 1;
+ (0 < (slen = strlen (this.title))) &&
+ (0 != proc (proc_cls,
+ "asf",
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ this.title,
+ slen + 1)) ) ||
+ ( (this.author != NULL) &&
+ (0 < (slen = strlen (this.author))) &&
+ (0 != proc (proc_cls,
+ "asf",
+ EXTRACTOR_METATYPE_AUTHOR_NAME,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ this.author,
+ slen + 1)) ) ||
+ ( (this.comment != NULL) &&
+ (0 < (slen = strlen (this.comment))) &&
+ (0 != proc (proc_cls,
+ "asf",
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ this.comment,
+ slen + 1)) ) ||
+ ( (this.copyright != NULL) &&
+ (0 < (slen = strlen (this.copyright))) &&
+ (0 != proc (proc_cls,
+ "asf",
+ EXTRACTOR_METATYPE_COPYRIGHT,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ this.copyright,
+ slen + 1)) ) ||
+ (0 != proc (proc_cls,
+ "asf",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ "video/x-ms-asf",
+ strlen ("video/x-ms-asf") + 1)) ||
+ (0 != proc (proc_cls,
+ "asf",
+ EXTRACTOR_METATYPE_DURATION,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ duration_str,
+ strlen (duration_str) + 1)) )
+ ret = 1;
}
free (this.title);
free (this.author);
@@ -584,4 +683,5 @@ EXTRACTOR_asf_extract (const char *data,
return ret;
}
+
/* end of asf_extractor.c */
diff --git a/src/plugins/old/convert_numeric.c b/src/plugins/old/convert_numeric.c
@@ -61,45 +61,44 @@ static unsigned long get_field (const unsigned char *,
unsigned int,
unsigned int,
unsigned int);
+
static int floatformat_always_valid (const struct EXTRACTOR_floatformat *fmt,
const void *from);
static int
-floatformat_always_valid (const struct EXTRACTOR_floatformat *fmt /*ATTRIBUTE_UNUSED*/,
+floatformat_always_valid (const struct
+ EXTRACTOR_floatformat *fmt /*ATTRIBUTE_UNUSED*/,
const void *from /*ATTRIBUTE_UNUSED*/)
{
return 1;
}
+
/* The odds that CHAR_BIT will be anything but 8 are low enough that I'm not
going to bother with trying to muck around with whether it is defined in
a system header, what we do if not, etc. */
#define FLOATFORMAT_CHAR_BIT 8
/* floatformats for IEEE single and double, big and little endian. */
-const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_single_big =
-{
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_single_big = {
floatformat_big, 32, 0, 1, 8, 127, 255, 9, 23,
floatformat_intbit_no,
"floatformat_ieee_single_big",
floatformat_always_valid
};
-const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_single_little =
-{
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_single_little = {
floatformat_little, 32, 0, 1, 8, 127, 255, 9, 23,
floatformat_intbit_no,
"floatformat_ieee_single_little",
floatformat_always_valid
};
-const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_big =
-{
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_big = {
floatformat_big, 64, 0, 1, 11, 1023, 2047, 12, 52,
floatformat_intbit_no,
"floatformat_ieee_double_big",
floatformat_always_valid
};
-const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_little =
-{
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_little = {
floatformat_little, 64, 0, 1, 11, 1023, 2047, 12, 52,
floatformat_intbit_no,
"floatformat_ieee_double_little",
@@ -109,8 +108,8 @@ const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_little =
/* floatformat for IEEE double, little endian byte order, with big endian word
ordering, as on the ARM. */
-const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_littlebyte_bigword =
-{
+const struct EXTRACTOR_floatformat
+ EXTRACTOR_floatformat_ieee_double_littlebyte_bigword = {
floatformat_littlebyte_bigword, 64, 0, 1, 11, 1023, 2047, 12, 52,
floatformat_intbit_no,
"floatformat_ieee_double_littlebyte_bigword",
@@ -119,33 +118,32 @@ const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_littlebyte_
/* floatformat for VAX. Not quite IEEE, but close enough. */
-const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_vax_f =
-{
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_vax_f = {
floatformat_vax, 32, 0, 1, 8, 129, 0, 9, 23,
floatformat_intbit_no,
"floatformat_vax_f",
floatformat_always_valid
};
-const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_vax_d =
-{
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_vax_d = {
floatformat_vax, 64, 0, 1, 8, 129, 0, 9, 55,
floatformat_intbit_no,
"floatformat_vax_d",
floatformat_always_valid
};
-const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_vax_g =
-{
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_vax_g = {
floatformat_vax, 64, 0, 1, 11, 1025, 0, 12, 52,
floatformat_intbit_no,
"floatformat_vax_g",
floatformat_always_valid
};
-static int floatformat_i387_ext_is_valid (const struct EXTRACTOR_floatformat *fmt,
- const void *from);
+static int floatformat_i387_ext_is_valid (const struct
+ EXTRACTOR_floatformat *fmt,
+ const void *from);
static int
-floatformat_i387_ext_is_valid (const struct EXTRACTOR_floatformat *fmt, const void *from)
+floatformat_i387_ext_is_valid (const struct EXTRACTOR_floatformat *fmt, const
+ void *from)
{
/* In the i387 double-extended format, if the exponent is all ones,
then the integer bit must be set. If the exponent is neither 0
@@ -155,9 +153,9 @@ floatformat_i387_ext_is_valid (const struct EXTRACTOR_floatformat *fmt, const vo
const unsigned char *ufrom = (const unsigned char *) from;
exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize,
- fmt->exp_start, fmt->exp_len);
+ fmt->exp_start, fmt->exp_len);
int_bit = get_field (ufrom, fmt->byteorder, fmt->totalsize,
- fmt->man_start, 1);
+ fmt->man_start, 1);
if ((exponent == 0) != (int_bit == 0))
return 0;
@@ -165,38 +163,34 @@ floatformat_i387_ext_is_valid (const struct EXTRACTOR_floatformat *fmt, const vo
return 1;
}
-const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_i387_ext =
-{
+
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_i387_ext = {
floatformat_little, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,
floatformat_intbit_yes,
"floatformat_i387_ext",
floatformat_i387_ext_is_valid
};
-const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m68881_ext =
-{
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m68881_ext = {
/* Note that the bits from 16 to 31 are unused. */
floatformat_big, 96, 0, 1, 15, 0x3fff, 0x7fff, 32, 64,
floatformat_intbit_yes,
"floatformat_m68881_ext",
floatformat_always_valid
};
-const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_i960_ext =
-{
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_i960_ext = {
/* Note that the bits from 0 to 15 are unused. */
floatformat_little, 96, 16, 17, 15, 0x3fff, 0x7fff, 32, 64,
floatformat_intbit_yes,
"floatformat_i960_ext",
floatformat_always_valid
};
-const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m88110_ext =
-{
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m88110_ext = {
floatformat_big, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,
floatformat_intbit_yes,
"floatformat_m88110_ext",
floatformat_always_valid
};
-const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m88110_harris_ext =
-{
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m88110_harris_ext = {
/* Harris uses raw format 128 bytes long, but the number is just an ieee
double, and the last 64 bits are wasted. */
floatformat_big,128, 0, 1, 11, 0x3ff, 0x7ff, 12, 52,
@@ -204,45 +198,40 @@ const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m88110_harris_ext =
"floatformat_m88110_ext_harris",
floatformat_always_valid
};
-const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_arm_ext_big =
-{
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_arm_ext_big = {
/* Bits 1 to 16 are unused. */
floatformat_big, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64,
floatformat_intbit_yes,
"floatformat_arm_ext_big",
floatformat_always_valid
};
-const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_arm_ext_littlebyte_bigword =
-{
+const struct EXTRACTOR_floatformat
+ EXTRACTOR_floatformat_arm_ext_littlebyte_bigword = {
/* Bits 1 to 16 are unused. */
floatformat_littlebyte_bigword, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64,
floatformat_intbit_yes,
"floatformat_arm_ext_littlebyte_bigword",
floatformat_always_valid
};
-const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_spill_big =
-{
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_spill_big = {
floatformat_big, 128, 0, 1, 17, 65535, 0x1ffff, 18, 64,
floatformat_intbit_yes,
"floatformat_ia64_spill_big",
floatformat_always_valid
};
-const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_spill_little =
-{
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_spill_little = {
floatformat_little, 128, 0, 1, 17, 65535, 0x1ffff, 18, 64,
floatformat_intbit_yes,
"floatformat_ia64_spill_little",
floatformat_always_valid
};
-const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_quad_big =
-{
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_quad_big = {
floatformat_big, 128, 0, 1, 15, 16383, 0x7fff, 16, 112,
floatformat_intbit_no,
"floatformat_ia64_quad_big",
floatformat_always_valid
};
-const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_quad_little =
-{
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_quad_little = {
floatformat_little, 128, 0, 1, 15, 16383, 0x7fff, 16, 112,
floatformat_intbit_no,
"floatformat_ia64_quad_little",
@@ -257,7 +246,8 @@ const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_quad_little =
/* Extract a field which starts at START and is LEN bits long. DATA and
TOTAL_LEN are the thing we are extracting it from, in byteorder ORDER. */
static unsigned long
-get_field (const unsigned char *data, enum EXTRACTOR_floatformat_byteorders order,
+get_field (const unsigned char *data, enum EXTRACTOR_floatformat_byteorders
+ order,
unsigned int total_len, unsigned int start, unsigned int len)
{
unsigned long result = 0;
@@ -278,29 +268,30 @@ get_field (const unsigned char *data, enum EXTRACTOR_floatformat_byteorders orde
hi_bit = min (lo_bit + len, FLOATFORMAT_CHAR_BIT);
do
- {
- unsigned int shifted = *(data + cur_byte) >> lo_bit;
- unsigned int bits = hi_bit - lo_bit;
- unsigned int mask = (1 << bits) - 1;
- result |= (shifted & mask) << cur_bitshift;
- len -= bits;
- cur_bitshift += bits;
- cur_byte += nextbyte;
- lo_bit = 0;
- hi_bit = min (len, FLOATFORMAT_CHAR_BIT);
- }
+ {
+ unsigned int shifted = *(data + cur_byte) >> lo_bit;
+ unsigned int bits = hi_bit - lo_bit;
+ unsigned int mask = (1 << bits) - 1;
+ result |= (shifted & mask) << cur_bitshift;
+ len -= bits;
+ cur_bitshift += bits;
+ cur_byte += nextbyte;
+ lo_bit = 0;
+ hi_bit = min (len, FLOATFORMAT_CHAR_BIT);
+ }
while (len != 0);
return result;
}
+
/* Convert from FMT to a double.
FROM is the address of the extended float.
Store the double in *TO. */
void
EXTRACTOR_common_floatformat_to_double (const struct EXTRACTOR_floatformat *fmt,
- const void *from, double *to)
+ const void *from, double *to)
{
const unsigned char *ufrom = (const unsigned char *) from;
double dto;
@@ -308,65 +299,65 @@ EXTRACTOR_common_floatformat_to_double (const struct EXTRACTOR_floatformat *fmt,
unsigned long mant;
unsigned int mant_bits, mant_off;
int mant_bits_left;
- int special_exponent; /* It's a NaN, denorm or zero */
+ int special_exponent; /* It's a NaN, denorm or zero */
exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize,
- fmt->exp_start, fmt->exp_len);
+ fmt->exp_start, fmt->exp_len);
/* If the exponent indicates a NaN, we don't have information to
decide what to do. So we handle it like IEEE, except that we
don't try to preserve the type of NaN. FIXME. */
if ((unsigned long) exponent == fmt->exp_nan)
+ {
+ int nan;
+
+ mant_off = fmt->man_start;
+ mant_bits_left = fmt->man_len;
+ nan = 0;
+ while (mant_bits_left > 0)
{
- int nan;
-
- mant_off = fmt->man_start;
- mant_bits_left = fmt->man_len;
- nan = 0;
- while (mant_bits_left > 0)
- {
- mant_bits = min (mant_bits_left, 32);
-
- if (get_field (ufrom, fmt->byteorder, fmt->totalsize,
- mant_off, mant_bits) != 0)
- {
- /* This is a NaN. */
- nan = 1;
- break;
- }
-
- mant_off += mant_bits;
- mant_bits_left -= mant_bits;
- }
-
- /* On certain systems (such as GNU/Linux), the use of the
- INFINITY macro below may generate a warning that can not be
- silenced due to a bug in GCC (PR preprocessor/11931). The
- preprocessor fails to recognise the __extension__ keyword in
- conjunction with the GNU/C99 extension for hexadecimal
- floating point constants and will issue a warning when
- compiling with -pedantic. */
- if (nan)
- dto = NAN;
- else
- dto = INFINITY;
-
- if (get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1))
- dto = -dto;
-
- *to = dto;
-
- return;
+ mant_bits = min (mant_bits_left, 32);
+
+ if (get_field (ufrom, fmt->byteorder, fmt->totalsize,
+ mant_off, mant_bits) != 0)
+ {
+ /* This is a NaN. */
+ nan = 1;
+ break;
+ }
+
+ mant_off += mant_bits;
+ mant_bits_left -= mant_bits;
}
+ /* On certain systems (such as GNU/Linux), the use of the
+ INFINITY macro below may generate a warning that can not be
+ silenced due to a bug in GCC (PR preprocessor/11931). The
+ preprocessor fails to recognise the __extension__ keyword in
+ conjunction with the GNU/C99 extension for hexadecimal
+ floating point constants and will issue a warning when
+ compiling with -pedantic. */if (nan)
+ dto = NAN;
+ else
+ dto = INFINITY;
+
+ if (get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1))
+ dto = -dto;
+
+ *to = dto;
+
+ return;
+ }
+
mant_bits_left = fmt->man_len;
mant_off = fmt->man_start;
dto = 0.0;
- special_exponent = (exponent == 0) || ((unsigned long) exponent == fmt->exp_nan);
+ special_exponent = (exponent == 0) || ((unsigned long) exponent ==
+ fmt->exp_nan);
/* Don't bias zero's, denorms or NaNs. */
- if (!special_exponent)
+ if (! special_exponent)
exponent -= fmt->exp_bias;
/* Build the result algebraically. Might go infinite, underflow, etc;
@@ -375,36 +366,36 @@ EXTRACTOR_common_floatformat_to_double (const struct EXTRACTOR_floatformat *fmt,
/* If this format uses a hidden bit, explicitly add it in now. Otherwise,
increment the exponent by one to account for the integer bit. */
- if (!special_exponent)
- {
- if (fmt->intbit == floatformat_intbit_no)
- dto = ldexp (1.0, exponent);
- else
- exponent++;
- }
+ if (! special_exponent)
+ {
+ if (fmt->intbit == floatformat_intbit_no)
+ dto = ldexp (1.0, exponent);
+ else
+ exponent++;
+ }
while (mant_bits_left > 0)
- {
- mant_bits = min (mant_bits_left, 32);
-
- mant = get_field (ufrom, fmt->byteorder, fmt->totalsize,
- mant_off, mant_bits);
-
- /* Handle denormalized numbers. FIXME: What should we do for
- non-IEEE formats? */
- if (special_exponent && exponent == 0 && mant != 0)
- dto += ldexp ((double)mant,
- (- fmt->exp_bias
- - mant_bits
- - (mant_off - fmt->man_start)
- + 1));
- else
- dto += ldexp ((double)mant, exponent - mant_bits);
- if (exponent != 0)
- exponent -= mant_bits;
- mant_off += mant_bits;
- mant_bits_left -= mant_bits;
- }
+ {
+ mant_bits = min (mant_bits_left, 32);
+
+ mant = get_field (ufrom, fmt->byteorder, fmt->totalsize,
+ mant_off, mant_bits);
+
+ /* Handle denormalized numbers. FIXME: What should we do for
+ non-IEEE formats? */
+ if (special_exponent && (exponent == 0) && (mant != 0) )
+ dto += ldexp ((double) mant,
+ (-fmt->exp_bias
+ - mant_bits
+ - (mant_off - fmt->man_start)
+ + 1));
+ else
+ dto += ldexp ((double) mant, exponent - mant_bits);
+ if (exponent != 0)
+ exponent -= mant_bits;
+ mant_off += mant_bits;
+ mant_bits_left -= mant_bits;
+ }
/* Negate it if negative. */
if (get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1))
@@ -412,6 +403,7 @@ EXTRACTOR_common_floatformat_to_double (const struct EXTRACTOR_floatformat *fmt,
*to = dto;
}
+
static void put_field (unsigned char *, enum EXTRACTOR_floatformat_byteorders,
unsigned int,
unsigned int,
@@ -442,27 +434,29 @@ put_field (unsigned char *data, enum EXTRACTOR_floatformat_byteorders order,
hi_bit = min (lo_bit + len, FLOATFORMAT_CHAR_BIT);
do
- {
- unsigned char *byte_ptr = data + cur_byte;
- unsigned int bits = hi_bit - lo_bit;
- unsigned int mask = ((1 << bits) - 1) << lo_bit;
- *byte_ptr = (*byte_ptr & ~mask) | ((stuff_to_put << lo_bit) & mask);
- stuff_to_put >>= bits;
- len -= bits;
- cur_byte += nextbyte;
- lo_bit = 0;
- hi_bit = min (len, FLOATFORMAT_CHAR_BIT);
- }
+ {
+ unsigned char *byte_ptr = data + cur_byte;
+ unsigned int bits = hi_bit - lo_bit;
+ unsigned int mask = ((1 << bits) - 1) << lo_bit;
+ *byte_ptr = (*byte_ptr & ~mask) | ((stuff_to_put << lo_bit) & mask);
+ stuff_to_put >>= bits;
+ len -= bits;
+ cur_byte += nextbyte;
+ lo_bit = 0;
+ hi_bit = min (len, FLOATFORMAT_CHAR_BIT);
+ }
while (len != 0);
}
+
/* The converse: convert the double *FROM to an extended float
and store where TO points. Neither FROM nor TO have any alignment
restrictions. */
void
-EXTRACTOR_common_floatformat_from_double (const struct EXTRACTOR_floatformat *fmt,
- const double *from, void *to)
+EXTRACTOR_common_floatformat_from_double (const struct
+ EXTRACTOR_floatformat *fmt,
+ const double *from, void *to)
{
double dfrom;
int exponent;
@@ -476,88 +470,90 @@ EXTRACTOR_common_floatformat_from_double (const struct EXTRACTOR_floatformat *fm
/* If negative, set the sign bit. */
if (dfrom < 0)
- {
- put_field (uto, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1, 1);
- dfrom = -dfrom;
- }
+ {
+ put_field (uto, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1, 1);
+ dfrom = -dfrom;
+ }
if (dfrom == 0)
- {
- /* 0.0. */
- return;
- }
+ {
+ /* 0.0. */
+ return;
+ }
if (dfrom != dfrom)
- {
- /* NaN. */
- put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
- fmt->exp_len, fmt->exp_nan);
- /* Be sure it's not infinity, but NaN value is irrelevant. */
- put_field (uto, fmt->byteorder, fmt->totalsize, fmt->man_start,
- 32, 1);
- return;
- }
+ {
+ /* NaN. */
+ put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
+ fmt->exp_len, fmt->exp_nan);
+ /* Be sure it's not infinity, but NaN value is irrelevant. */
+ put_field (uto, fmt->byteorder, fmt->totalsize, fmt->man_start,
+ 32, 1);
+ return;
+ }
if (dfrom + dfrom == dfrom)
- {
- /* This can only happen for an infinite value (or zero, which we
- already handled above). */
- put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
- fmt->exp_len, fmt->exp_nan);
- return;
- }
+ {
+ /* This can only happen for an infinite value (or zero, which we
+ already handled above). */
+ put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
+ fmt->exp_len, fmt->exp_nan);
+ return;
+ }
mant = frexp (dfrom, &exponent);
if (exponent + fmt->exp_bias - 1 > 0)
put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
- fmt->exp_len, exponent + fmt->exp_bias - 1);
+ fmt->exp_len, exponent + fmt->exp_bias - 1);
else
- {
- /* Handle a denormalized number. FIXME: What should we do for
- non-IEEE formats? */
- put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
- fmt->exp_len, 0);
- mant = ldexp (mant, exponent + fmt->exp_bias - 1);
- }
+ {
+ /* Handle a denormalized number. FIXME: What should we do for
+ non-IEEE formats? */
+ put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
+ fmt->exp_len, 0);
+ mant = ldexp (mant, exponent + fmt->exp_bias - 1);
+ }
mant_bits_left = fmt->man_len;
mant_off = fmt->man_start;
while (mant_bits_left > 0)
+ {
+ unsigned long mant_long;
+ mant_bits = mant_bits_left < 32 ? mant_bits_left : 32;
+
+ mant *= 4294967296.0;
+ mant_long = (unsigned long) mant;
+ mant -= mant_long;
+
+ /* If the integer bit is implicit, and we are not creating a
+ denormalized number, then we need to discard it. */
+ if (( (unsigned int) mant_bits_left == fmt->man_len)
+ && (fmt->intbit == floatformat_intbit_no)
+ && (exponent + fmt->exp_bias - 1 > 0) )
{
- unsigned long mant_long;
- mant_bits = mant_bits_left < 32 ? mant_bits_left : 32;
-
- mant *= 4294967296.0;
- mant_long = (unsigned long)mant;
- mant -= mant_long;
-
- /* If the integer bit is implicit, and we are not creating a
- denormalized number, then we need to discard it. */
- if ((unsigned int) mant_bits_left == fmt->man_len
- && fmt->intbit == floatformat_intbit_no
- && exponent + fmt->exp_bias - 1 > 0)
- {
- mant_long &= 0x7fffffff;
- mant_bits -= 1;
- }
- else if (mant_bits < 32)
- {
- /* The bits we want are in the most significant MANT_BITS bits of
- mant_long. Move them to the least significant. */
- mant_long >>= 32 - mant_bits;
- }
-
- put_field (uto, fmt->byteorder, fmt->totalsize,
- mant_off, mant_bits, mant_long);
- mant_off += mant_bits;
- mant_bits_left -= mant_bits;
+ mant_long &= 0x7fffffff;
+ mant_bits -= 1;
}
+ else if (mant_bits < 32)
+ {
+ /* The bits we want are in the most significant MANT_BITS bits of
+ mant_long. Move them to the least significant. */
+ mant_long >>= 32 - mant_bits;
+ }
+
+ put_field (uto, fmt->byteorder, fmt->totalsize,
+ mant_off, mant_bits, mant_long);
+ mant_off += mant_bits;
+ mant_bits_left -= mant_bits;
+ }
}
+
/* Return non-zero iff the data at FROM is a valid number in format FMT. */
int
-EXTRACTOR_common_floatformat_is_valid (const struct EXTRACTOR_floatformat *fmt, const void *from)
+EXTRACTOR_common_floatformat_is_valid (const struct EXTRACTOR_floatformat *fmt,
+ const void *from)
{
return fmt->is_valid (fmt, from);
}
@@ -575,15 +571,15 @@ ieee_test (double n)
double result;
floatformat_to_double (&floatformat_ieee_double_little, &n, &result);
- if ((n != result && (! isnan (n) || ! isnan (result)))
- || (n < 0 && result >= 0)
- || (n >= 0 && result < 0))
+ if (((n != result) && (! isnan (n) || ! isnan (result)))
+ || ((n < 0) && (result >= 0))
+ || ((n >= 0) && (result < 0)))
printf ("Differ(to): %.20g -> %.20g\n", n, result);
floatformat_from_double (&floatformat_ieee_double_little, &n, &result);
- if ((n != result && (! isnan (n) || ! isnan (result)))
- || (n < 0 && result >= 0)
- || (n >= 0 && result < 0))
+ if (((n != result) && (! isnan (n) || ! isnan (result)))
+ || ((n < 0) && (result >= 0))
+ || ((n >= 0) && (result < 0)))
printf ("Differ(from): %.20g -> %.20g\n", n, result);
#if 0
@@ -600,13 +596,14 @@ ieee_test (double n)
#if IEEE_DEBUG > 1
/* This is to be run on a host which uses 68881 format. */
{
- long double ex = *(long double *)exten;
+ long double ex = *(long double *) exten;
if (ex != n)
printf ("Differ(from vs. extended): %.20g\n", n);
}
#endif
}
+
int
main (void)
{
@@ -620,12 +617,14 @@ main (void)
ieee_test (1.2E-70);
ieee_test (1.2E-316);
ieee_test (4.9406564584124654E-324);
- ieee_test (- 4.9406564584124654E-324);
- ieee_test (- 0.0);
- ieee_test (- INFINITY);
- ieee_test (- NAN);
+ ieee_test (-4.9406564584124654E-324);
+ ieee_test (-0.0);
+ ieee_test (-INFINITY);
+ ieee_test (-NAN);
ieee_test (INFINITY);
ieee_test (NAN);
return 0;
}
+
+
#endif
diff --git a/src/plugins/old/convert_numeric.h b/src/plugins/old/convert_numeric.h
@@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
-#if !defined (FLOATFORMAT_H)
+#if ! defined (FLOATFORMAT_H)
#define FLOATFORMAT_H 1
/*#include "ansidecl.h"*/
@@ -31,7 +31,8 @@ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
/* What is the order of the bytes? */
-enum EXTRACTOR_floatformat_byteorders {
+enum EXTRACTOR_floatformat_byteorders
+{
/* Standard little endian byte order.
EX: 1.2345678e10 => 00 00 80 c5 e0 fe 06 42 */
floatformat_little,
@@ -51,12 +52,13 @@ enum EXTRACTOR_floatformat_byteorders {
floatformat_vax
};
-enum EXTRACTOR_floatformat_intbit { floatformat_intbit_yes, floatformat_intbit_no };
+enum EXTRACTOR_floatformat_intbit { floatformat_intbit_yes,
+ floatformat_intbit_no };
struct EXTRACTOR_floatformat
{
enum EXTRACTOR_floatformat_byteorders byteorder;
- unsigned int totalsize; /* Total size of number in bits */
+ unsigned int totalsize; /* Total size of number in bits */
/* Sign bit is always one bit long. 1 means negative, 0 means positive. */
unsigned int sign_start;
@@ -90,13 +92,16 @@ struct EXTRACTOR_floatformat
/* floatformats for IEEE single and double, big and little endian. */
extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_single_big;
-extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_single_little;
+extern const struct EXTRACTOR_floatformat
+ EXTRACTOR_floatformat_ieee_single_little;
extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_big;
-extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_little;
+extern const struct EXTRACTOR_floatformat
+ EXTRACTOR_floatformat_ieee_double_little;
/* floatformat for ARM IEEE double, little endian bytes and big endian words */
-extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_littlebyte_bigword;
+extern const struct EXTRACTOR_floatformat
+ EXTRACTOR_floatformat_ieee_double_littlebyte_bigword;
/* floatformats for VAX. */
@@ -110,31 +115,38 @@ extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_i387_ext;
extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m68881_ext;
extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_i960_ext;
extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m88110_ext;
-extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m88110_harris_ext;
+extern const struct EXTRACTOR_floatformat
+ EXTRACTOR_floatformat_m88110_harris_ext;
extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_arm_ext_big;
-extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_arm_ext_littlebyte_bigword;
+extern const struct EXTRACTOR_floatformat
+ EXTRACTOR_floatformat_arm_ext_littlebyte_bigword;
/* IA-64 Floating Point register spilt into memory. */
extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_spill_big;
-extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_spill_little;
+extern const struct EXTRACTOR_floatformat
+ EXTRACTOR_floatformat_ia64_spill_little;
extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_quad_big;
-extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_quad_little;
+extern const struct EXTRACTOR_floatformat
+ EXTRACTOR_floatformat_ia64_quad_little;
/* Convert from FMT to a double.
FROM is the address of the extended float.
Store the double in *TO. */
extern void
-EXTRACTOR_common_floatformat_to_double (const struct EXTRACTOR_floatformat *, const void *, double *);
+EXTRACTOR_common_floatformat_to_double (const struct EXTRACTOR_floatformat *,
+ const void *, double *);
/* The converse: convert the double *FROM to FMT
and store where TO points. */
extern void
-EXTRACTOR_common_floatformat_from_double (const struct EXTRACTOR_floatformat *, const double *, void *);
+EXTRACTOR_common_floatformat_from_double (const struct EXTRACTOR_floatformat *,
+ const double *, void *);
/* Return non-zero iff the data at FROM is a valid number in format FMT. */
extern int
-EXTRACTOR_common_floatformat_is_valid (const struct EXTRACTOR_floatformat *fmt, const void *from);
+EXTRACTOR_common_floatformat_is_valid (const struct EXTRACTOR_floatformat *fmt,
+ const void *from);
-#endif /* defined (FLOATFORMAT_H) */
+#endif /* defined (FLOATFORMAT_H) */
diff --git a/src/plugins/old/ebml_extractor.c b/src/plugins/old/ebml_extractor.c
@@ -18,11 +18,11 @@
Boston, MA 02110-1301, USA.
*/
- /*
- * Made by Gabriel Peixoto
- * Using AVInfo 1.x code. Copyright (c) 2004 George Shuklin.
- * Nearly complete rewrite by LRN, Copyright (c) 2012
- */
+/*
+ * Made by Gabriel Peixoto
+ * Using AVInfo 1.x code. Copyright (c) 2004 George Shuklin.
+ * Nearly complete rewrite by LRN, Copyright (c) 2012
+ */
#include "platform.h"
#include "extractor.h"
@@ -44,20 +44,25 @@
struct tm *
gmtime_undocumented_64_r (const __time64_t *timer, struct tm *result)
{
- struct tm *local_result = NULL;//_gmtime64 (timer);
+ struct tm *local_result = NULL; // _gmtime64 (timer);
- if (local_result == NULL || result == NULL)
- return NULL;
+ if ((local_result == NULL) || (result == NULL) )
+ return NULL;
- memcpy (result, local_result, sizeof (*result));
- return result;
+ memcpy (result, local_result, sizeof (*result));
+ return result;
}
+
+
#endif
#include "extractor_plugins.h"
-#define ADD_EBML(s,t) do { proc (proc_cls, "ebml", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen(s)+1); } while (0)
-#define ADD_MATROSKA(s,t) do { proc (proc_cls, "matroska", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen(s)+1); } while (0)
+#define ADD_EBML(s,t) do { proc (proc_cls, "ebml", t, EXTRACTOR_METAFORMAT_UTF8, \
+ "text/plain", s, strlen (s) + 1); } while (0)
+#define ADD_MATROSKA(s,t) do { proc (proc_cls, "matroska", t, \
+ EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, \
+ strlen (s) + 1); } while (0)
/**
* String length limit. The spec does not limit the strings,
@@ -162,9 +167,9 @@ struct MatroskaTagMap tag_map[] = {
{"KEYWORDS", EXTRACTOR_METATYPE_KEYWORDS},
{"SUMMARY", EXTRACTOR_METATYPE_SUMMARY},
/*
- SYNOPSIS UTF-8 A description of the story line of the item.
+ SYNOPSIS UTF-8 A description of the story line of the item.
INITIAL_KEY UTF-8 The initial key that a musical track starts in. The format is identical to ID3.
- PERIOD UTF-8 Describes the period that the piece is from or about. For example, "Renaissance".
+ PERIOD UTF-8 Describes the period that the piece is from or about. For example, "Renaissance".
LAW_RATING UTF-8 Depending on the country it's the format of the rating of a movie (P, R, X in the USA, an age in other countries or a URI defining a logo).
ICRA binary The ICRA content rating for parental control. (Previously RSACi)
*/
@@ -176,7 +181,7 @@ struct MatroskaTagMap tag_map[] = {
{"DATE_WRITTEN", EXTRACTOR_METATYPE_UNKNOWN_DATE},
{"DATE_PURCHASED", EXTRACTOR_METATYPE_UNKNOWN_DATE},
/*
- RECORDING_LOCATION UTF-8 The location where the item was recorded. The countries corresponding to the string, same 2 octets as in Internet domains, or possibly ISO-3166. This code is followed by a comma, then more detailed information such as state/province, another comma, and then city. For example, "US, Texas, Austin". This will allow for easy sorting. It is okay to only store the country, or the country and the state/province. More detailed information can be added after the city through the use of additional commas. In cases where the province/state is unknown, but you want to store the city, simply leave a space between the two commas. For example, "US, , Austin".
+ RECORDING_LOCATION UTF-8 The location where the item was recorded. The countries corresponding to the string, same 2 octets as in Internet domains, or possibly ISO-3166. This code is followed by a comma, then more detailed information such as state/province, another comma, and then city. For example, "US, Texas, Austin". This will allow for easy sorting. It is okay to only store the country, or the country and the state/province. More detailed information can be added after the city through the use of additional commas. In cases where the province/state is unknown, but you want to store the city, simply leave a space between the two commas. For example, "US, , Austin".
COMPOSITION_LOCATION UTF-8 Location that the item was originaly designed/written. The countries corresponding to the string, same 2 octets as in Internet domains, or possibly ISO-3166. This code is followed by a comma, then more detailed information such as state/province, another comma, and then city. For example, "US, Texas, Austin". This will allow for easy sorting. It is okay to only store the country, or the country and the state/province. More detailed information can be added after the city through the use of additional commas. In cases where the province/state is unknown, but you want to store the city, simply leave a space between the two commas. For example, "US, , Austin".
COMPOSER_NATIONALITY UTF-8 Nationality of the main composer of the item, mostly for classical music. The countries corresponding to the string, same 2 octets as in Internet domains, or possibly ISO-3166.
*/
@@ -188,7 +193,7 @@ struct MatroskaTagMap tag_map[] = {
ENCODER UTF-8 The software or hardware used to encode this item. ("LAME" or "XviD")
ENCODER_SETTINGS UTF-8 A list of the settings used for encoding this item. No specific format.
BPS UTF-8 The average bits per second of the specified item. This is only the data in the Blocks, and excludes headers and any container overhead.
- FPS UTF-8 The average frames per second of the specified item. This is typically the average number of Blocks per second. In the event that lacing is used, each laced chunk is to be counted as a seperate frame.
+ FPS UTF-8 The average frames per second of the specified item. This is typically the average number of Blocks per second. In the event that lacing is used, each laced chunk is to be counted as a seperate frame.
*/
{"BPM", EXTRACTOR_METATYPE_BEATS_PER_MINUTE},
/*
@@ -201,7 +206,7 @@ struct MatroskaTagMap tag_map[] = {
/*
MCDI binary This is a binary dump of the TOC of the CDROM that this item was taken from. This holds the same information as the MCDI in ID3.
ISBN UTF-8 International Standard Book Number
- BARCODE UTF-8 EAN-13 (European Article Numbering) or UPC-A (Universal Product Code) bar code identifier
+ BARCODE UTF-8 EAN-13 (European Article Numbering) or UPC-A (Universal Product Code) bar code identifier
CATALOG_NUMBER UTF-8 A label-specific string used to identify the release (TIC 01 for example).
LABEL_CODE UTF-8 A 4-digit or 5-digit number to identify the record label, typically printed as (LC) xxxx or (LC) 0xxxx on CDs medias or covers (only the number is stored).
LCCN UTF-8 Library of Congress Control Number
@@ -281,7 +286,6 @@ enum
MatroskaID_Tracks_Audio_BitDepth = 0x6264, /* not 0, UINT. Bits per sample, mostly used for PCM. */
-
MatroskaID_Tags = 0x1254C367, /* can appear more than once. Element containing elements specific to Tracks/Chapters. A list of valid tags can be found here. */
MatroskaID_Tags_Tag = 0x7373, /* mandatory, can appear more than once. Element containing elements specific to Tracks/Chapters. */
MatroskaID_Tags_Tag_SimpleTag = 0x67C8, /* mandatory, can appear more than once, recursive. Contains general information about the target. */
@@ -315,12 +319,14 @@ enum VINTParseMode
*/
static ssize_t
VINTparse (struct EXTRACTOR_PluginList *plugin,
- int64_t * result, enum VINTParseMode mode)
+ int64_t *result, enum VINTParseMode mode)
{
/* 10000000 01000000 00100000 00010000 00001000 00000100 00000010 00000001 */
- static const unsigned char mask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, 0x01 };
+ static const unsigned char mask[8] = { 0x80, 0x40, 0x20, 0x10, 0x08, 0x04,
+ 0x02, 0x01 };
/* 01111111 00111111 00011111 00001111 00000111 00000011 00000001 00000000 */
- static const unsigned char imask[8] = { 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03, 0x01, 0x00 };
+ static const unsigned char imask[8] = { 0x7F, 0x3F, 0x1F, 0x0F, 0x07, 0x03,
+ 0x01, 0x00 };
static const int64_t int_negative_limits[8] = {
-0x00000000000040LL, /* 7-bit integer */
-0x00000000002000LL, /* 14-bit integer */
@@ -374,13 +380,11 @@ VINTparse (struct EXTRACTOR_PluginList *plugin,
* 1-byte integer has 2^7 different values,
* 2-byte integer has 2^14 different values,
* etc
- */
- /*
+ *//*
* Examine the first byte and see how many 0-bytes are at its beginning.
- */
- vint_width = 0;
+ */vint_width = 0;
for (c = 0; c < 8; c++)
- if (!(first_byte & mask[c]))
+ if (! (first_byte & mask[c]))
vint_width++;
else
break;
@@ -403,7 +407,7 @@ VINTparse (struct EXTRACTOR_PluginList *plugin,
* 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
* 4-bit signed integer:
* 0 1 2 3 4 5 6 7 -8 -7 -6 -5 -4 -3 -2 -1
- *
+ *
* 3 here is 0011b, and -3 is 1101b
* However, writing 1101b into int8_t memory location will NOT make
* the machine interpret it as -3, it will be interpreted as 00001101b,
@@ -427,9 +431,7 @@ VINTparse (struct EXTRACTOR_PluginList *plugin,
* which is outside of the signed integer range (remember, we're in 4-bit space here).
* on the other hand, 5 and -3 both are within the range.
* 4) if the number does not exceed the signed integer maximum (7), store it as-is
- */
-
- result_u = 0;
+ */result_u = 0;
/* Copy the extra bytes into a temporary buffer, in the right order */
for (c = 0; c < vint_width; c++)
result_u += ((uint64_t) int_bytes[vint_width - c]) << (c * 8);
@@ -439,7 +441,8 @@ VINTparse (struct EXTRACTOR_PluginList *plugin,
{
case VINT_READ_UINT:
/* Unset the 1-bit marker */
- result_u += ((uint64_t) int_bytes[0] & imask[vint_width]) << (vint_width * 8);
+ result_u += ((uint64_t) int_bytes[0] & imask[vint_width]) << (vint_width
+ * 8);
memcpy (result, &result_u, sizeof (uint64_t));
break;
case VINT_READ_ID:
@@ -449,7 +452,8 @@ VINTparse (struct EXTRACTOR_PluginList *plugin,
break;
case VINT_READ_SIZE:
/* Unset the 1-bit marker */
- result_u += ((uint64_t) int_bytes[0] & imask[vint_width]) << (vint_width * 8);
+ result_u += ((uint64_t) int_bytes[0] & imask[vint_width]) << (vint_width
+ * 8);
/* Special case: all-1 size means "size is unknown". We indicate this
* in the return value by setting it to UINT64_MAX.
*/
@@ -459,7 +463,8 @@ VINTparse (struct EXTRACTOR_PluginList *plugin,
break;
case VINT_READ_SINT:
/* Unset the 1-bit marker */
- result_u += ((uint64_t) int_bytes[0] & imask[vint_width]) << (vint_width * 8);
+ result_u += ((uint64_t) int_bytes[0] & imask[vint_width]) << (vint_width
+ * 8);
/* Interpret large values as negative signed values */
if (result_u > int_positive_limits[vint_width])
{
@@ -492,7 +497,7 @@ VINTparse (struct EXTRACTOR_PluginList *plugin,
*/
static ssize_t
elementRead (struct EXTRACTOR_PluginList *plugin,
- uint32_t *id, int64_t * size)
+ uint32_t *id, int64_t *size)
{
int64_t tempID;
int64_t tempsize;
@@ -519,6 +524,7 @@ elementRead (struct EXTRACTOR_PluginList *plugin,
return id_offset + size_offset;
}
+
static ssize_t
idRead (struct EXTRACTOR_PluginList *plugin,
uint64_t length, uint32_t *id)
@@ -537,8 +543,10 @@ idRead (struct EXTRACTOR_PluginList *plugin,
return id_offset;
}
+
static ssize_t
-uintRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, uint64_t *result)
+uintRead (struct EXTRACTOR_PluginList *plugin, uint64_t length,
+ uint64_t *result)
{
size_t c;
unsigned char *data;
@@ -552,6 +560,7 @@ uintRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, uint64_t *result
return (ssize_t) length;
}
+
static ssize_t
sintRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, int64_t *result)
{
@@ -579,6 +588,7 @@ sintRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, int64_t *result)
return (ssize_t) length;
}
+
static ssize_t
stringRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, char *result)
{
@@ -601,8 +611,10 @@ stringRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, char *result)
return 1;
}
+
static ssize_t
-floatRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, long double *result)
+floatRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, long
+ double *result)
{
size_t c;
unsigned char t[8];
@@ -612,7 +624,7 @@ floatRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, long double *re
return -1;
/* we don't support 10-byte floats, because not all C compilers will guarantee that long double is stored in 10 bytes in a IEEE-conformant format */
- if (length != 4 && length != 8 /* && length != 10 */)
+ if ((length != 4) && (length != 8) /* && length != 10 */)
return 0;
for (c = 0; c < length; c++)
@@ -624,14 +636,15 @@ floatRead (struct EXTRACTOR_PluginList *plugin, uint64_t length, long double *re
#endif
}
if (length == 4)
- *result = * ((float *) t);
+ *result = *((float *) t);
else if (length == 8)
- *result = * ((double *) t);
+ *result = *((double *) t);
else
- *result = * ((long double *) t);
+ *result = *((long double *) t);
return (ssize_t) length;
}
+
static const char stream_type_letters[] = "?vat"; /*[0]-no, [1]-video,[2]-audio,[3]-text */
enum EBMLState
@@ -791,6 +804,7 @@ clean_ebml_state_ebml (struct ebml_state *state)
state->doctype_read_version = 0;
}
+
static void
clean_ebml_state_matroska_simpletags (struct ebml_state *state)
{
@@ -809,7 +823,7 @@ clean_ebml_state_matroska_simpletags (struct ebml_state *state)
if (el->string != NULL)
free (el->string);
free (el);
- if (parent != NULL && parent->child == el)
+ if ((parent != NULL) && (parent->child == el))
parent->child = next;
el = next;
if (next == NULL)
@@ -820,8 +834,10 @@ clean_ebml_state_matroska_simpletags (struct ebml_state *state)
state->tag_current = NULL;
}
+
void
-matroska_add_tag (struct ebml_state *state, struct matroska_simpletag *parent, char *name, char *string)
+matroska_add_tag (struct ebml_state *state, struct matroska_simpletag *parent,
+ char *name, char *string)
{
struct matroska_simpletag *el = malloc (sizeof (struct matroska_simpletag));
el->parent = parent;
@@ -839,6 +855,7 @@ matroska_add_tag (struct ebml_state *state, struct matroska_simpletag *parent, c
state->tag_last = el;
}
+
static void
clean_ebml_state_matroska_seeks (struct ebml_state *state)
{
@@ -852,6 +869,7 @@ clean_ebml_state_matroska_seeks (struct ebml_state *state)
state->matroska_seeks_tail = NULL;
}
+
static void
clean_ebml_state_matroska_segment (struct ebml_state *state)
{
@@ -862,6 +880,7 @@ clean_ebml_state_matroska_segment (struct ebml_state *state)
clean_ebml_state_matroska_simpletags (state);
}
+
static void
clean_ebml_state_matroska_seek (struct ebml_state *state)
{
@@ -869,6 +888,7 @@ clean_ebml_state_matroska_seek (struct ebml_state *state)
state->matroska_seek_position = 0;
}
+
static void
clean_ebml_state_matroska_info (struct ebml_state *state)
{
@@ -889,6 +909,7 @@ clean_ebml_state_matroska_info (struct ebml_state *state)
state->matroska_info_writing_app = NULL;
}
+
static void
clean_ebml_state_matroska_track_video (struct ebml_state *state)
{
@@ -902,6 +923,7 @@ clean_ebml_state_matroska_track_video (struct ebml_state *state)
state->matroska_track_video_display_unit = 0;
}
+
static void
clean_ebml_state_matroska_track_audio (struct ebml_state *state)
{
@@ -912,6 +934,7 @@ clean_ebml_state_matroska_track_audio (struct ebml_state *state)
state->matroska_track_audio_bit_depth = 0;
}
+
static void
clean_ebml_state_matroska_track (struct ebml_state *state)
{
@@ -935,6 +958,7 @@ clean_ebml_state_matroska_track (struct ebml_state *state)
clean_ebml_state_matroska_track_audio (state);
}
+
static struct ebml_state *
EXTRACTOR_ebml_init_state_method ()
{
@@ -952,14 +976,17 @@ EXTRACTOR_ebml_init_state_method ()
return state;
}
+
static void
-report_simpletag (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
+report_simpletag (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
struct matroska_simpletag *el, *next;
char format[MAX_STRING_SIZE + 1];
for (el = state->tag_tree; el != NULL; el = next)
{
- if (el->name != NULL && el->name[0] != '\0' && el->string != NULL && el->string[0] != '\0')
+ if ((el->name != NULL) && (el->name[0] != '\0') && (el->string != NULL) &&
+ (el->string[0] != '\0') )
{
enum EXTRACTOR_MetaType metatype = EXTRACTOR_METATYPE_RESERVED;
struct MatroskaTagMap *map_item;
@@ -975,10 +1002,10 @@ report_simpletag (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, vo
{
snprintf (format, MAX_STRING_SIZE, "%s=%s", el->name, el->string);
format[MAX_STRING_SIZE] = '\0';
- ADD_MATROSKA(format, EXTRACTOR_METATYPE_UNKNOWN);
+ ADD_MATROSKA (format, EXTRACTOR_METATYPE_UNKNOWN);
}
else
- ADD_MATROSKA(el->string, metatype);
+ ADD_MATROSKA (el->string, metatype);
}
next = el->child;
while (next == NULL && el != NULL)
@@ -991,18 +1018,21 @@ report_simpletag (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, vo
clean_ebml_state_matroska_simpletags (state);
}
+
static void
-report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
+report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
char format[MAX_STRING_SIZE + 1];
report_simpletag (state, proc, proc_cls);
- if (state->valid_ebml && !state->reported_ebml)
+ if (state->valid_ebml && ! state->reported_ebml)
{
state->reported_ebml = 1;
- snprintf (format, MAX_STRING_SIZE, "%llu", (unsigned long long) state->ebml_version);
+ snprintf (format, MAX_STRING_SIZE, "%llu", (unsigned long
+ long) state->ebml_version);
format[MAX_STRING_SIZE] = '\0';
- ADD_EBML(format, EXTRACTOR_METATYPE_FORMAT_VERSION);
- snprintf (format, MAX_STRING_SIZE, "%s %llu (EBML %llu)", state->doctype,
+ ADD_EBML (format, EXTRACTOR_METATYPE_FORMAT_VERSION);
+ snprintf (format, MAX_STRING_SIZE, "%s %llu (EBML %llu)", state->doctype,
(unsigned long long) state->doctype_version,
(unsigned long long) state->ebml_version);
format[MAX_STRING_SIZE] = '\0';
@@ -1012,21 +1042,25 @@ report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void *
clean_ebml_state_ebml (state);
if (state->valid_matroska_info == -1)
{
- if ((state->matroska_info_duration > 0 || state->matroska_info_duration == -1.0) &&
- state->matroska_info_muxing_app != NULL && state->matroska_info_writing_app != NULL)
+ if (((state->matroska_info_duration > 0) ||
+ (state->matroska_info_duration == -1.0) ) &&
+ (state->matroska_info_muxing_app != NULL) &&
+ (state->matroska_info_writing_app != NULL) )
state->valid_matroska_info = 1;
else
state->valid_matroska_info = 0;
}
- if (state->valid_matroska_info == 1 && !state->reported_matroska_info)
+ if ((state->valid_matroska_info == 1) && ! state->reported_matroska_info)
{
state->reported_matroska_info = 1;
if (state->matroska_info_duration != -1.0)
{
- uint64_t seconds = (uint64_t) ((state->matroska_info_duration * (float) state->matroska_info_timecode_scale) / 1e+9);
+ uint64_t seconds = (uint64_t) ((state->matroska_info_duration
+ * (float) state->
+ matroska_info_timecode_scale) / 1e+9);
snprintf (format, MAX_STRING_SIZE, "%llus", (unsigned long long) seconds);
format[MAX_STRING_SIZE] = '\0';
- ADD_MATROSKA(format, EXTRACTOR_METATYPE_DURATION);
+ ADD_MATROSKA (format, EXTRACTOR_METATYPE_DURATION);
}
if (state->matroska_info_date_utc_is_set)
{
@@ -1052,8 +1086,7 @@ report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void *
* millenium is known and never changes), but we want to use 64-bit integer to
* manipulate time. If it gets trimmed later, when assigning back to a TIME_TYPE
* that happens to be 32-bit long - well, tough luck.
- */
- errno = 0;
+ */errno = 0;
#if WINDOWS
millenium_start_stamp = _mktime64 (&millenium_start);
#else
@@ -1061,58 +1094,69 @@ report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void *
#endif
if (millenium_start_stamp == -1)
printf ("Failed to convert time: %d\n", errno);
- matroska_date_stamp = millenium_start_stamp * 1000000000 + state->matroska_info_date_utc;
+ matroska_date_stamp = millenium_start_stamp * 1000000000
+ + state->matroska_info_date_utc;
/* Now matroska_date_stamp is the number of nanoseconds since UNIX Epoch */
matroska_date_stamp_time_t = matroska_date_stamp / 1000000000;
/* Now matroska_date_stamp_time_t is the number of seconds since UNIX Epoch */
#if WINDOWS
- if (NULL != gmtime_undocumented_64_r (&matroska_date_stamp_time_t, &matroska_date))
+ if (NULL != gmtime_undocumented_64_r (&matroska_date_stamp_time_t,
+ &matroska_date))
#else
/* We want to be thread-safe. If you have no gmtime_r(), think of something! */
if (NULL != gmtime_r (&matroska_date_stamp_time_t, &matroska_date))
#endif
{
- if (0 != strftime (format, MAX_STRING_SIZE, "%Y.%m.%d %H:%M:%S UTC", &matroska_date))
- ADD_MATROSKA(format, EXTRACTOR_METATYPE_CREATION_DATE);
+ if (0 != strftime (format, MAX_STRING_SIZE, "%Y.%m.%d %H:%M:%S UTC",
+ &matroska_date))
+ ADD_MATROSKA (format, EXTRACTOR_METATYPE_CREATION_DATE);
}
}
if (state->matroska_info_title != NULL)
- ADD_MATROSKA(state->matroska_info_title, EXTRACTOR_METATYPE_TITLE);
- if (strcmp (state->matroska_info_writing_app, state->matroska_info_muxing_app) == 0)
- snprintf (format, MAX_STRING_SIZE, "Written and muxed with %s", state->matroska_info_writing_app);
+ ADD_MATROSKA (state->matroska_info_title, EXTRACTOR_METATYPE_TITLE);
+ if (strcmp (state->matroska_info_writing_app,
+ state->matroska_info_muxing_app) == 0)
+ snprintf (format, MAX_STRING_SIZE, "Written and muxed with %s",
+ state->matroska_info_writing_app);
else
- snprintf (format, MAX_STRING_SIZE, "Written with %s, muxed with %s", state->matroska_info_writing_app, state->matroska_info_muxing_app);
+ snprintf (format, MAX_STRING_SIZE, "Written with %s, muxed with %s",
+ state->matroska_info_writing_app,
+ state->matroska_info_muxing_app);
format[MAX_STRING_SIZE] = '\0';
- ADD_MATROSKA(format, EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE);
+ ADD_MATROSKA (format, EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE);
}
if (state->valid_matroska_info == 1)
clean_ebml_state_matroska_info (state);
if (state->valid_matroska_track == -1)
{
- if ((state->matroska_track_type > 0 && state->matroska_track_type < 255) &&
- state->matroska_track_codec_id != NULL)
+ if (((state->matroska_track_type > 0) && (state->matroska_track_type <
+ 255) ) &&
+ (state->matroska_track_codec_id != NULL) )
state->valid_matroska_track = 1;
else
state->valid_matroska_track = 0;
}
if (state->valid_matroska_track_video == -1)
{
- if ((state->matroska_track_video_flag_interlaced == 0 || state->matroska_track_video_flag_interlaced == 1) &&
- (state->matroska_track_video_stereo_mode >= 0 && state->matroska_track_video_stereo_mode <= 14) &&
- state->matroska_track_video_pixel_width > 0 && state->matroska_track_video_pixel_height > 0)
+ if (((state->matroska_track_video_flag_interlaced == 0) ||
+ (state->matroska_track_video_flag_interlaced == 1) ) &&
+ ((state->matroska_track_video_stereo_mode >= 0) &&
+ (state->matroska_track_video_stereo_mode <= 14) ) &&
+ (state->matroska_track_video_pixel_width > 0) &&
+ (state->matroska_track_video_pixel_height > 0) )
state->valid_matroska_track_video = 1;
else
state->valid_matroska_track_video = 0;
}
if (state->valid_matroska_track_audio == -1)
{
- if (state->matroska_track_audio_sampling_frequency > 0 &&
- state->matroska_track_audio_channels > 0)
+ if ((state->matroska_track_audio_sampling_frequency > 0) &&
+ (state->matroska_track_audio_channels > 0) )
state->valid_matroska_track_audio = 1;
else
state->valid_matroska_track_audio = 0;
}
- if (state->valid_matroska_track == 1 && !state->reported_matroska_track)
+ if ((state->valid_matroska_track == 1) && ! state->reported_matroska_track)
{
char name_part[MAX_STRING_SIZE + 1];
char codec_part[MAX_STRING_SIZE + 1];
@@ -1142,28 +1186,32 @@ report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void *
if (state->matroska_track_name == NULL)
snprintf (name_part, MAX_STRING_SIZE, "%s", "");
else
- snprintf (name_part, MAX_STRING_SIZE, "`%s' ", state->matroska_track_name);
+ snprintf (name_part, MAX_STRING_SIZE, "`%s' ",
+ state->matroska_track_name);
name_part[MAX_STRING_SIZE] = '\0';
if (state->matroska_track_codec_name == NULL)
- snprintf (codec_part, MAX_STRING_SIZE, "%s", state->matroska_track_codec_id);
+ snprintf (codec_part, MAX_STRING_SIZE, "%s",
+ state->matroska_track_codec_id);
else
- snprintf (codec_part, MAX_STRING_SIZE, "%s [%s]", state->matroska_track_codec_id, state->matroska_track_codec_name);
+ snprintf (codec_part, MAX_STRING_SIZE, "%s [%s]",
+ state->matroska_track_codec_id,
+ state->matroska_track_codec_name);
codec_part[MAX_STRING_SIZE] = '\0';
- if (use_video && state->valid_matroska_track_video == 1)
+ if (use_video && (state->valid_matroska_track_video == 1))
{
/* Ignore Display* for now. Aspect ratio correction could be
* done either way (stretching horizontally or squishing vertically),
* so let's stick to hard cold pixel counts.
*/
- snprintf (format, MAX_STRING_SIZE, "%llux%llu",
+ snprintf (format, MAX_STRING_SIZE, "%llux%llu",
(unsigned long long) state->matroska_track_video_pixel_width,
(unsigned long long) state->matroska_track_video_pixel_height);
format[MAX_STRING_SIZE] = '\0';
ADD_MATROSKA (format, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS);
}
- if (use_audio && state->valid_matroska_track_audio == 1)
+ if (use_audio && (state->valid_matroska_track_audio == 1))
{
double freq = state->matroska_track_audio_sampling_frequency;
double rfreq = freq;
@@ -1176,20 +1224,24 @@ report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void *
hz_part[MAX_STRING_SIZE] = '\0';
if (state->matroska_track_audio_bit_depth > 0)
- snprintf (bit_part, MAX_STRING_SIZE, "%llu-bit ", (unsigned long long) state->matroska_track_audio_bit_depth);
+ snprintf (bit_part, MAX_STRING_SIZE, "%llu-bit ", (unsigned long
+ long) state->
+ matroska_track_audio_bit_depth);
else
bit_part[0] = '\0';
bit_part[MAX_STRING_SIZE] = '\0';
- snprintf (format, MAX_STRING_SIZE, "%s track %s(%s, %llu-channel %sat %s) [%s]",
- track_type_string, name_part, codec_part,
- (unsigned long long) state->matroska_track_audio_channels,
- bit_part, hz_part, state->matroska_track_language);
+ snprintf (format, MAX_STRING_SIZE,
+ "%s track %s(%s, %llu-channel %sat %s) [%s]",
+ track_type_string, name_part, codec_part,
+ (unsigned long long) state->matroska_track_audio_channels,
+ bit_part, hz_part, state->matroska_track_language);
}
else
{
snprintf (format, MAX_STRING_SIZE, "%s track %s(%s) [%s]",
- track_type_string, name_part, codec_part, state->matroska_track_language);
+ track_type_string, name_part, codec_part,
+ state->matroska_track_language);
}
format[MAX_STRING_SIZE] = '\0';
ADD_EBML (format, EXTRACTOR_METATYPE_RESOURCE_TYPE);
@@ -1199,7 +1251,7 @@ report_state (struct ebml_state *state, EXTRACTOR_MetaDataProcessor proc, void *
}
-static int
+static int
EXTRACTOR_ebml_discard_state_method (struct ebml_state *state)
{
if (state != NULL)
@@ -1214,6 +1266,7 @@ EXTRACTOR_ebml_discard_state_method (struct ebml_state *state)
return 1;
}
+
static struct ebml_element *
ebml_stack_pop (struct ebml_state *state)
{
@@ -1227,7 +1280,10 @@ ebml_stack_pop (struct ebml_state *state)
static void
-ebml_stack_push_new (struct ebml_state *state, uint64_t position, uint32_t id, uint64_t size, uint64_t header_size, int finish_state, int prev_state, int bail_state, int bail_next_state)
+ebml_stack_push_new (struct ebml_state *state, uint64_t position, uint32_t id,
+ uint64_t size, uint64_t header_size, int finish_state, int
+ prev_state, int
+ bail_state, int bail_next_state)
{
struct ebml_element *element = malloc (sizeof (struct ebml_element));
element->parent = state->stack_top;
@@ -1242,8 +1298,10 @@ ebml_stack_push_new (struct ebml_state *state, uint64_t position, uint32_t id, u
element->bail_next_state = bail_next_state;
}
+
static int
-check_result (struct EXTRACTOR_PluginList *plugin, ssize_t read_result, struct ebml_state *state)
+check_result (struct EXTRACTOR_PluginList *plugin, ssize_t read_result, struct
+ ebml_state *state)
{
if (read_result == 0)
{
@@ -1256,7 +1314,7 @@ check_result (struct EXTRACTOR_PluginList *plugin, ssize_t read_result, struct e
return 0;
}
offset = parent->position + parent->header_size + parent->size;
- if (offset < 0 || offset != pl_seek (plugin, offset, SEEK_SET))
+ if ((offset < 0) || (offset != pl_seek (plugin, offset, SEEK_SET)))
{
state->state = EBML_BAD_STATE;
return 0;
@@ -1269,12 +1327,16 @@ check_result (struct EXTRACTOR_PluginList *plugin, ssize_t read_result, struct e
return 1;
}
+
static int
-maybe_rise_up (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state, int *do_break, int64_t read_result)
+maybe_rise_up (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state,
+ int *do_break, int64_t read_result)
{
int64_t offset;
offset = pl_get_pos (plugin) - read_result;
- if (state->stack_top != NULL && offset >= state->stack_top->position + state->stack_top->header_size + state->stack_top->size)
+ if ((state->stack_top != NULL) && (offset >= state->stack_top->position
+ + state->stack_top->header_size
+ + state->stack_top->size) )
{
state->state = state->stack_top->finish_state;
pl_seek (plugin, -read_result, SEEK_CUR);
@@ -1284,24 +1346,29 @@ maybe_rise_up (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state, in
return 0;
}
+
static void
-rise_up_after_value (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state, int next_state)
+rise_up_after_value (struct EXTRACTOR_PluginList *plugin, struct
+ ebml_state *state, int next_state)
{
int64_t offset;
state->state = EBML_READ_ELEMENT;
- offset = state->stack_top->position + state->stack_top->header_size + state->stack_top->size;
+ offset = state->stack_top->position + state->stack_top->header_size
+ + state->stack_top->size;
free (ebml_stack_pop (state));
state->next_state = next_state;
pl_seek (plugin, offset, SEEK_SET);
}
+
static void
try_to_find_pos (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state)
{
if (state->matroska_seeks != NULL)
{
struct matroska_seek_list *el, *pos = NULL;
- int64_t segment_position = pl_get_pos (plugin) - state->segment_contents_start;
+ int64_t segment_position = pl_get_pos (plugin)
+ - state->segment_contents_start;
for (el = state->matroska_seeks; el != NULL; el = el->next)
{
if (el->position <= segment_position)
@@ -1314,8 +1381,10 @@ try_to_find_pos (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state)
}
}
+
static void
-maybe_seek_to_something_interesting (struct EXTRACTOR_PluginList *plugin, struct ebml_state *state)
+maybe_seek_to_something_interesting (struct EXTRACTOR_PluginList *plugin, struct
+ ebml_state *state)
{
int64_t offset;
struct matroska_seek_list *el;
@@ -1350,12 +1419,14 @@ maybe_seek_to_something_interesting (struct EXTRACTOR_PluginList *plugin, struct
* the one we've got from seek table. If it doesn't match - stop parsing the file.
*/
#if DEBUG_EBML
- printf ("Seeking from %llu to %llu\n", offset, el->position + state->segment_contents_start);
+ printf ("Seeking from %llu to %llu\n", offset, el->position
+ + state->segment_contents_start);
#endif
pl_seek (plugin, el->position + state->segment_contents_start, SEEK_SET);
}
}
+
static void
sort_seeks (struct ebml_state *state)
{
@@ -1363,7 +1434,7 @@ sort_seeks (struct ebml_state *state)
int64_t position;
struct matroska_seek_list *el;
char sorted = 0;
- while (!sorted)
+ while (! sorted)
{
sorted = 1;
for (el = state->matroska_seeks; el != NULL; el = el->next)
@@ -1386,7 +1457,8 @@ sort_seeks (struct ebml_state *state)
int
-EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
+EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin,
+ EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
{
uint64_t offset = 0;
ssize_t read_result;
@@ -1406,7 +1478,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
if (plugin == NULL)
return 1;
-
+
state = EXTRACTOR_ebml_init_state_method ();
if (state == NULL)
return 1;
@@ -1421,7 +1493,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
return EXTRACTOR_ebml_discard_state_method (state);
case EBML_LOOKING_FOR_HEADER:
offset = pl_get_pos (plugin);
- sint_value = pl_read (plugin, &data, 1024*1024);
+ sint_value = pl_read (plugin, &data, 1024 * 1024);
if (sint_value < 4)
return EXTRACTOR_ebml_discard_state_method (state);
start = NULL;
@@ -1433,12 +1505,13 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
offset = pl_get_pos (plugin) - 3;
if (offset != pl_seek (plugin, offset, SEEK_SET))
return EXTRACTOR_ebml_discard_state_method (state);
- sint_value = pl_read (plugin, &data, 1024*1024);
+ sint_value = pl_read (plugin, &data, 1024 * 1024);
if (sint_value < 4)
return EXTRACTOR_ebml_discard_state_method (state);
}
}
- if (offset + start - data != pl_seek (plugin, offset + start - data, SEEK_SET))
+ if (offset + start - data != pl_seek (plugin, offset + start - data,
+ SEEK_SET))
return EXTRACTOR_ebml_discard_state_method (state);
state->state = EBML_READING_HEADER;
break;
@@ -1458,7 +1531,9 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
}
state->state = EBML_READ_ELEMENT;
state->next_state = EBML_READING_HEADER_ELEMENTS;
- ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_HEADER, EBML_BAD_STATE, EBML_FINISHED_READING_HEADER, EBML_BAD_STATE);
+ ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result,
+ EBML_FINISHED_READING_HEADER, EBML_BAD_STATE,
+ EBML_FINISHED_READING_HEADER, EBML_BAD_STATE);
break;
case EBML_READ_ELEMENT:
#if DEBUG_EBML
@@ -1475,19 +1550,14 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
}
state->state = state->next_state;
break;
- */
- /* while the following code crashes with SIGILL.
- */
- /*
+ *//* while the following code crashes with SIGILL.
+ *//*
read_result = elementRead (plugin, &eID, &eSize);
state->state = state->next_state;
if (read_result < 0)
state->state = EBML_BAD_STATE;
break;
- */
- /* but the following code works as intended */
- /* All three code snippets were compiled with -O0 */
- {
+ *//* but the following code works as intended *//* All three code snippets were compiled with -O0 */{
enum EBMLState next_state = state->next_state;
state->state = EBML_BAD_STATE;
read_result = elementRead (plugin, &eID, (int64_t*) &eSize);
@@ -1506,7 +1576,8 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
read_result = 0;
else
{
- if (0 > (read_result = uintRead (plugin, state->stack_top->size, &uint_value)))
+ if (0 > (read_result = uintRead (plugin, state->stack_top->size,
+ &uint_value)))
{
state->state = EBML_BAD_STATE;
break;
@@ -1516,7 +1587,8 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
state->state = state->next_state;
break;
case EBML_READ_ID:
- if (0 > (read_result = idRead (plugin, state->stack_top->size, &id_value)))
+ if (0 > (read_result = idRead (plugin, state->stack_top->size,
+ &id_value)))
{
state->state = EBML_BAD_STATE;
break;
@@ -1534,7 +1606,8 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
read_result = 0;
else
{
- if (0 > (read_result = sintRead (plugin, state->stack_top->size, &sint_value)))
+ if (0 > (read_result = sintRead (plugin, state->stack_top->size,
+ &sint_value)))
{
state->state = EBML_BAD_STATE;
break;
@@ -1554,7 +1627,8 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
read_result = 0;
else
{
- if (0 > (read_result = floatRead (plugin, state->stack_top->size, &float_value)))
+ if (0 > (read_result = floatRead (plugin, state->stack_top->size,
+ &float_value)))
{
state->state = EBML_BAD_STATE;
break;
@@ -1571,7 +1645,8 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
}
else
{
- if (0 > (read_result = stringRead (plugin, state->stack_top->size, (char *) &string_value)))
+ if (0 > (read_result = stringRead (plugin, state->stack_top->size,
+ (char *) &string_value)))
{
state->state = EBML_BAD_STATE;
break;
@@ -1581,7 +1656,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
state->state = state->next_state;
break;
case EBML_READING_HEADER_ELEMENTS:
- if (!check_result (plugin, read_result, state))
+ if (! check_result (plugin, read_result, state))
break;
do_break = 0;
switch (eID)
@@ -1609,10 +1684,13 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
if (do_break)
break;
state->next_state = EBML_READING_HEADER_ELEMENT_VALUE;
- ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_BAD_STATE, EBML_READING_HEADER_ELEMENTS, EBML_READ_ELEMENT, EBML_READING_HEADER_ELEMENTS);
+ ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result,
+ EBML_BAD_STATE, EBML_READING_HEADER_ELEMENTS,
+ EBML_READ_ELEMENT,
+ EBML_READING_HEADER_ELEMENTS);
break;
case EBML_READING_HEADER_ELEMENT_VALUE:
- if (!check_result (plugin, read_result, state))
+ if (! check_result (plugin, read_result, state))
break;
switch (state->stack_top->id)
@@ -1632,8 +1710,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
* We also stop right here and do not assume that somewhere further
* in the file there's another EBML header that is, maybe, readable
* by us. If you think this is worth correcting - patches are welcome.
- */
- continue;
+ */continue;
}
break;
case EBMLID_MAX_ID_LENGTH:
@@ -1658,7 +1735,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
rise_up_after_value (plugin, state, EBML_READING_HEADER_ELEMENTS);
break;
case EBML_FINISHED_READING_HEADER:
- if (!state->valid_ebml)
+ if (! state->valid_ebml)
{
/* Header was invalid (lacking doctype). */
state->next_state = EBML_SKIP_UNTIL_NEXT_HEADER;
@@ -1680,8 +1757,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
* metadata from it!), we do not care about these differences
* (which means that this code will happily read webm files that do
* not conform to Webm spec, but conform to Matroska spec).
- */
- state->next_state = EBML_READING_MATROSKA_SEGMENT;
+ */state->next_state = EBML_READING_MATROSKA_SEGMENT;
}
else
{
@@ -1727,11 +1803,14 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
state->state = EBML_READ_ELEMENT;
state->next_state = EBML_READING_MATROSKA_SEGMENT_CONTENTS;
clean_ebml_state_matroska_segment (state);
- ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_SEGMENT_CONTENTS, EBML_READING_MATROSKA_SEGMENT, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SEGMENT);
+ ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result,
+ EBML_FINISHED_READING_MATROSKA_SEGMENT_CONTENTS,
+ EBML_READING_MATROSKA_SEGMENT, EBML_READ_ELEMENT,
+ EBML_READING_MATROSKA_SEGMENT);
state->segment_contents_start = pl_get_pos (plugin);
break;
case EBML_READING_MATROSKA_SEGMENT_CONTENTS:
- if (!check_result (plugin, read_result, state))
+ if (! check_result (plugin, read_result, state))
break;
state->state = EBML_READ_ELEMENT;
@@ -1739,20 +1818,40 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
{
case MatroskaID_SeekHead:
state->next_state = EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS;
- ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_SEEK_HEAD_CONTENTS, EBML_READING_MATROSKA_SEGMENT_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SEGMENT_CONTENTS);
+ ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize,
+ read_result,
+ EBML_FINISHED_READING_MATROSKA_SEEK_HEAD_CONTENTS,
+ EBML_READING_MATROSKA_SEGMENT_CONTENTS,
+ EBML_READ_ELEMENT,
+ EBML_READING_MATROSKA_SEGMENT_CONTENTS);
break;
case MatroskaID_Info:
state->next_state = EBML_READING_MATROSKA_INFO_CONTENTS;
clean_ebml_state_matroska_info (state);
- ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_INFO_CONTENTS, EBML_READING_MATROSKA_SEGMENT_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SEGMENT_CONTENTS);
+ ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize,
+ read_result,
+ EBML_FINISHED_READING_MATROSKA_INFO_CONTENTS,
+ EBML_READING_MATROSKA_SEGMENT_CONTENTS,
+ EBML_READ_ELEMENT,
+ EBML_READING_MATROSKA_SEGMENT_CONTENTS);
break;
case MatroskaID_Tracks:
state->next_state = EBML_READING_MATROSKA_TRACKS_CONTENTS;
- ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_TRACKS_CONTENTS, EBML_READING_MATROSKA_SEGMENT_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SEGMENT_CONTENTS);
+ ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize,
+ read_result,
+ EBML_FINISHED_READING_MATROSKA_TRACKS_CONTENTS,
+ EBML_READING_MATROSKA_SEGMENT_CONTENTS,
+ EBML_READ_ELEMENT,
+ EBML_READING_MATROSKA_SEGMENT_CONTENTS);
break;
case MatroskaID_Tags:
state->next_state = EBML_READING_MATROSKA_TAGS_CONTENTS;
- ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_TAGS_CONTENTS, EBML_READING_MATROSKA_SEGMENT_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SEGMENT_CONTENTS);
+ ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize,
+ read_result,
+ EBML_FINISHED_READING_MATROSKA_TAGS_CONTENTS,
+ EBML_READING_MATROSKA_SEGMENT_CONTENTS,
+ EBML_READ_ELEMENT,
+ EBML_READING_MATROSKA_SEGMENT_CONTENTS);
break;
default:
if (maybe_rise_up (plugin, state, &do_break, read_result))
@@ -1763,7 +1862,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
}
break;
case EBML_READING_MATROSKA_TAGS_CONTENTS:
- if (!check_result (plugin, read_result, state))
+ if (! check_result (plugin, read_result, state))
break;
state->state = EBML_READ_ELEMENT;
switch (eID)
@@ -1771,7 +1870,12 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
case MatroskaID_Tags_Tag:
state->next_state = EBML_READING_MATROSKA_TAG_CONTENTS;
clean_ebml_state_matroska_seek (state);
- ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_TAG_CONTENTS, EBML_READING_MATROSKA_TAGS_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TAGS_CONTENTS);
+ ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize,
+ read_result,
+ EBML_FINISHED_READING_MATROSKA_TAG_CONTENTS,
+ EBML_READING_MATROSKA_TAGS_CONTENTS,
+ EBML_READ_ELEMENT,
+ EBML_READING_MATROSKA_TAGS_CONTENTS);
break;
default:
if (maybe_rise_up (plugin, state, &do_break, read_result))
@@ -1781,7 +1885,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
}
break;
case EBML_READING_MATROSKA_TAG_CONTENTS:
- if (!check_result (plugin, read_result, state))
+ if (! check_result (plugin, read_result, state))
break;
state->state = EBML_READ_ELEMENT;
@@ -1793,7 +1897,12 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
matroska_add_tag (state, NULL, NULL, NULL);
state->tag_current = state->tag_last;
state->tag_tree = state->tag_current;
- ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_SIMPLETAG_CONTENTS, EBML_READING_MATROSKA_TAG_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TAG_CONTENTS);
+ ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize,
+ read_result,
+ EBML_FINISHED_READING_MATROSKA_SIMPLETAG_CONTENTS,
+ EBML_READING_MATROSKA_TAG_CONTENTS,
+ EBML_READ_ELEMENT,
+ EBML_READING_MATROSKA_TAG_CONTENTS);
break;
default:
if (maybe_rise_up (plugin, state, &do_break, read_result))
@@ -1803,7 +1912,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
}
break;
case EBML_READING_MATROSKA_SIMPLETAG_CONTENTS:
- if (!check_result (plugin, read_result, state))
+ if (! check_result (plugin, read_result, state))
break;
do_break = 0;
@@ -1823,7 +1932,12 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
state->next_state = EBML_READING_MATROSKA_SIMPLETAG_CONTENTS;
matroska_add_tag (state, state->tag_current, NULL, NULL);
state->tag_current = state->tag_last;
- ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_SIMPLETAG_CONTENTS, EBML_READING_MATROSKA_SIMPLETAG_CONTENTS, EBML_READ_ELEMENT, EBML_FINISHED_READING_MATROSKA_SIMPLETAG_CONTENTS);
+ ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize,
+ read_result,
+ EBML_FINISHED_READING_MATROSKA_SIMPLETAG_CONTENTS,
+ EBML_READING_MATROSKA_SIMPLETAG_CONTENTS,
+ EBML_READ_ELEMENT,
+ EBML_FINISHED_READING_MATROSKA_SIMPLETAG_CONTENTS);
do_break = 1;
break;
default:
@@ -1838,10 +1952,14 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
if (do_break)
break;
state->next_state = EBML_READING_MATROSKA_SIMPLETAG_CONTENTS_VALUE;
- ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_BAD_STATE, EBML_READING_MATROSKA_SIMPLETAG_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SIMPLETAG_CONTENTS);
+ ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result,
+ EBML_BAD_STATE,
+ EBML_READING_MATROSKA_SIMPLETAG_CONTENTS,
+ EBML_READ_ELEMENT,
+ EBML_READING_MATROSKA_SIMPLETAG_CONTENTS);
break;
case EBML_READING_MATROSKA_SIMPLETAG_CONTENTS_VALUE:
- if (!check_result (plugin, read_result, state))
+ if (! check_result (plugin, read_result, state))
break;
/* This breaks the specs, as there should be only one instance of each
@@ -1861,10 +1979,11 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
state->tag_current->string = strdup (string_value);
break;
}
- rise_up_after_value (plugin, state, EBML_READING_MATROSKA_SIMPLETAG_CONTENTS);
+ rise_up_after_value (plugin, state,
+ EBML_READING_MATROSKA_SIMPLETAG_CONTENTS);
break;
case EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS:
- if (!check_result (plugin, read_result, state))
+ if (! check_result (plugin, read_result, state))
break;
state->state = EBML_READ_ELEMENT;
@@ -1873,7 +1992,12 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
case MatroskaID_Seek:
state->next_state = EBML_READING_MATROSKA_SEEK_CONTENTS;
clean_ebml_state_matroska_seek (state);
- ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_SEEK_CONTENTS, EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS);
+ ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize,
+ read_result,
+ EBML_FINISHED_READING_MATROSKA_SEEK_CONTENTS,
+ EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS,
+ EBML_READ_ELEMENT,
+ EBML_READING_MATROSKA_SEEK_HEAD_CONTENTS);
break;
default:
if (maybe_rise_up (plugin, state, &do_break, read_result))
@@ -1883,7 +2007,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
}
break;
case EBML_READING_MATROSKA_SEEK_CONTENTS:
- if (!check_result (plugin, read_result, state))
+ if (! check_result (plugin, read_result, state))
break;
do_break = 0;
@@ -1907,10 +2031,13 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
if (do_break)
break;
state->next_state = EBML_READING_MATROSKA_SEEK_CONTENTS_VALUE;
- ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_BAD_STATE, EBML_READING_MATROSKA_SEEK_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_SEEK_CONTENTS);
+ ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result,
+ EBML_BAD_STATE, EBML_READING_MATROSKA_SEEK_CONTENTS,
+ EBML_READ_ELEMENT,
+ EBML_READING_MATROSKA_SEEK_CONTENTS);
break;
case EBML_READING_MATROSKA_SEEK_CONTENTS_VALUE:
- if (!check_result (plugin, read_result, state))
+ if (! check_result (plugin, read_result, state))
break;
/* This breaks the specs, as there should be only one instance of each
@@ -1929,7 +2056,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
rise_up_after_value (plugin, state, EBML_READING_MATROSKA_SEEK_CONTENTS);
break;
case EBML_READING_MATROSKA_TRACKS_CONTENTS:
- if (!check_result (plugin, read_result, state))
+ if (! check_result (plugin, read_result, state))
break;
state->state = EBML_READ_ELEMENT;
@@ -1938,7 +2065,12 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
case MatroskaID_Tracks_TrackEntry:
state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS;
clean_ebml_state_matroska_track (state);
- ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_CONTENTS, EBML_READING_MATROSKA_TRACKS_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TRACKS_CONTENTS);
+ ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize,
+ read_result,
+ EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_CONTENTS,
+ EBML_READING_MATROSKA_TRACKS_CONTENTS,
+ EBML_READ_ELEMENT,
+ EBML_READING_MATROSKA_TRACKS_CONTENTS);
break;
default:
if (maybe_rise_up (plugin, state, &do_break, read_result))
@@ -1948,7 +2080,7 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
}
break;
case EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS:
- if (!check_result (plugin, read_result, state))
+ if (! check_result (plugin, read_result, state))
break;
do_break = 0;
@@ -1967,14 +2099,24 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
state->state = EBML_READ_ELEMENT;
state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS;
clean_ebml_state_matroska_track_video (state);
- ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS, EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS);
+ ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize,
+ read_result,
+ EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS,
+ EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS,
+ EBML_READ_ELEMENT,
+ EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS);
do_break = 1;
break;
case MatroskaID_Tracks_Audio:
state->state = EBML_READ_ELEMENT;
state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS;
clean_ebml_state_matroska_track_audio (state);
- ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS, EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS);
+ ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize,
+ read_result,
+ EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS,
+ EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS,
+ EBML_READ_ELEMENT,
+ EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS);
do_break = 1;
break;
default:
@@ -1989,10 +2131,14 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
if (do_break)
break;
state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS_VALUE;
- ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_BAD_STATE, EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS);
+ ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result,
+ EBML_BAD_STATE,
+ EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS,
+ EBML_READ_ELEMENT,
+ EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS);
break;
case EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS:
- if (!check_result (plugin, read_result, state))
+ if (! check_result (plugin, read_result, state))
break;
do_break = 0;
@@ -2017,11 +2163,16 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
}
if (do_break)
break;
- state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS_VALUE;
- ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_BAD_STATE, EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS);
+ state->next_state =
+ EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS_VALUE;
+ ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result,
+ EBML_BAD_STATE,
+ EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS,
+ EBML_READ_ELEMENT,
+ EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS);
break;
case EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS_VALUE:
- if (!check_result (plugin, read_result, state))
+ if (! check_result (plugin, read_result, state))
break;
/* This breaks the specs, as there should be only one instance of each
@@ -2043,10 +2194,11 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
state->matroska_track_audio_bit_depth = uint_value;
break;
}
- rise_up_after_value (plugin, state, EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS);
+ rise_up_after_value (plugin, state,
+ EBML_READING_MATROSKA_TRACK_ENTRY_AUDIO_CONTENTS);
break;
case EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS:
- if (!check_result (plugin, read_result, state))
+ if (! check_result (plugin, read_result, state))
break;
do_break = 0;
@@ -2072,11 +2224,16 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
}
if (do_break)
break;
- state->next_state = EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS_VALUE;
- ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_BAD_STATE, EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS);
+ state->next_state =
+ EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS_VALUE;
+ ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result,
+ EBML_BAD_STATE,
+ EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS,
+ EBML_READ_ELEMENT,
+ EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS);
break;
case EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS_VALUE:
- if (!check_result (plugin, read_result, state))
+ if (! check_result (plugin, read_result, state))
break;
/* This breaks the specs, as there should be only one instance of each
@@ -2107,10 +2264,11 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
state->matroska_track_video_display_unit = uint_value;
break;
}
- rise_up_after_value (plugin, state, EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS);
+ rise_up_after_value (plugin, state,
+ EBML_READING_MATROSKA_TRACK_ENTRY_VIDEO_CONTENTS);
break;
case EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS_VALUE:
- if (!check_result (plugin, read_result, state))
+ if (! check_result (plugin, read_result, state))
break;
/* This breaks the specs, as there should be only one instance of each
@@ -2143,10 +2301,11 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
state->matroska_track_codec_name = strdup (string_value);
break; /* UTF-8-encoded. A human-readable string specifying the codec. */
}
- rise_up_after_value (plugin, state, EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS);
+ rise_up_after_value (plugin, state,
+ EBML_READING_MATROSKA_TRACK_ENTRY_CONTENTS);
break;
case EBML_READING_MATROSKA_INFO_CONTENTS:
- if (!check_result (plugin, read_result, state))
+ if (! check_result (plugin, read_result, state))
break;
do_break = 0;
@@ -2178,10 +2337,13 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
if (do_break)
break;
state->next_state = EBML_READING_MATROSKA_INFO_CONTENTS_VALUE;
- ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result, EBML_BAD_STATE, EBML_READING_MATROSKA_INFO_CONTENTS, EBML_READ_ELEMENT, EBML_READING_MATROSKA_INFO_CONTENTS);
+ ebml_stack_push_new (state, pl_get_pos (plugin), eID, eSize, read_result,
+ EBML_BAD_STATE, EBML_READING_MATROSKA_INFO_CONTENTS,
+ EBML_READ_ELEMENT,
+ EBML_READING_MATROSKA_INFO_CONTENTS);
break;
case EBML_READING_MATROSKA_INFO_CONTENTS_VALUE:
- if (!check_result (plugin, read_result, state))
+ if (! check_result (plugin, read_result, state))
break;
/* This breaks the specs, as there should be only one instance of each
@@ -2219,7 +2381,10 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
rise_up_after_value (plugin, state, EBML_READING_MATROSKA_INFO_CONTENTS);
break;
case EBML_FINISHED_READING_MATROSKA_INFO_CONTENTS:
- if (state->stack_top != NULL && pl_get_pos (plugin) >= state->stack_top->position + state->stack_top->header_size + state->stack_top->size)
+ if ((state->stack_top != NULL) && (pl_get_pos (plugin) >=
+ state->stack_top->position
+ + state->stack_top->header_size
+ + state->stack_top->size) )
report_state (state, proc, proc_cls);
maybe_seek_to_something_interesting (plugin, state);
state->state = EBML_READ_ELEMENT;
@@ -2227,7 +2392,10 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
free (ebml_stack_pop (state));
break;
case EBML_FINISHED_READING_MATROSKA_TRACK_ENTRY_CONTENTS:
- if (state->stack_top != NULL && pl_get_pos (plugin) >= state->stack_top->position + state->stack_top->header_size + state->stack_top->size)
+ if ((state->stack_top != NULL) && (pl_get_pos (plugin) >=
+ state->stack_top->position
+ + state->stack_top->header_size
+ + state->stack_top->size) )
report_state (state, proc, proc_cls);
state->state = EBML_READ_ELEMENT;
state->next_state = state->stack_top->prev_state;
@@ -2235,7 +2403,8 @@ EXTRACTOR_ebml_extract_method (struct EXTRACTOR_PluginList *plugin, EXTRACTOR_Me
break;
case EBML_FINISHED_READING_MATROSKA_SEEK_CONTENTS:
if ((state->matroska_seek_id != 0) &&
- ((state->matroska_seek_position > 0) || state->matroska_seeks_tail == NULL))
+ ((state->matroska_seek_position > 0) || (state->matroska_seeks_tail ==
+ NULL) ))
{
struct matroska_seek_list *el;
el = malloc (sizeof (struct matroska_seek_list));
diff --git a/src/plugins/old/elf_extractor.c b/src/plugins/old/elf_extractor.c
@@ -26,7 +26,7 @@
typedef uint32_t Elf32_Addr;
typedef uint16_t Elf32_Half;
typedef uint32_t Elf32_Off;
-typedef int32_t Elf32_Sword;
+typedef int32_t Elf32_Sword;
typedef uint32_t Elf32_Word;
typedef uint16_t Elf64_Half;
@@ -64,57 +64,58 @@ typedef struct
#define ELF_HEADER_SIZE sizeof (Elf32_Ehdr)
#define ELF_HEADER_FIELDS(p) \
- &(p)->e_type, \
- &(p)->e_machine, \
- &(p)->e_version, \
- &(p)->e_entry, \
- &(p)->e_phoff, \
- &(p)->e_shoff, \
- &(p)->e_flags, \
- &(p)->e_ehsize, \
- &(p)->e_phensize, \
- &(p)->e_phnum, \
- &(p)->e_shentsize, \
- &(p)->e_shnum, \
- &(p)->e_shstrndx
+ & (p)->e_type, \
+ &(p)->e_machine, \
+ &(p)->e_version, \
+ &(p)->e_entry, \
+ &(p)->e_phoff, \
+ &(p)->e_shoff, \
+ &(p)->e_flags, \
+ &(p)->e_ehsize, \
+ &(p)->e_phensize, \
+ &(p)->e_phnum, \
+ &(p)->e_shentsize, \
+ &(p)->e_shnum, \
+ &(p)->e_shstrndx
static char *ELF_HEADER_SPECS[] = {
"hhwwwwwhhhhhh",
"HHWWWWWHHHHHH",
};
-typedef struct {
- Elf64_Half e_type;
- Elf64_Half e_machine;
- Elf64_Word e_version;
- Elf64_Addr e_entry;
- Elf64_Off e_phoff;
- Elf64_Off e_shoff;
- Elf64_Word e_flags;
- Elf64_Half e_ehsize;
- Elf64_Half e_phensize;
- Elf64_Half e_phnum;
- Elf64_Half e_shentsize;
- Elf64_Half e_shnum;
- Elf64_Half e_shstrndx;
+typedef struct
+{
+ Elf64_Half e_type;
+ Elf64_Half e_machine;
+ Elf64_Word e_version;
+ Elf64_Addr e_entry;
+ Elf64_Off e_phoff;
+ Elf64_Off e_shoff;
+ Elf64_Word e_flags;
+ Elf64_Half e_ehsize;
+ Elf64_Half e_phensize;
+ Elf64_Half e_phnum;
+ Elf64_Half e_shentsize;
+ Elf64_Half e_shnum;
+ Elf64_Half e_shstrndx;
} Elf64_Ehdr;
/* elf-header minus e_ident */
#define ELF64_HEADER_SIZE sizeof (Elf64_Ehdr)
#define ELF64_HEADER_FIELDS(p) \
- &(p)->e_type, \
- &(p)->e_machine, \
- &(p)->e_version, \
- &(p)->e_entry, \
- &(p)->e_phoff, \
- &(p)->e_shoff, \
- &(p)->e_flags, \
- &(p)->e_ehsize, \
- &(p)->e_phensize, \
- &(p)->e_phnum, \
- &(p)->e_shentsize, \
- &(p)->e_shnum, \
- &(p)->e_shstrndx
+ & (p)->e_type, \
+ &(p)->e_machine, \
+ &(p)->e_version, \
+ &(p)->e_entry, \
+ &(p)->e_phoff, \
+ &(p)->e_shoff, \
+ &(p)->e_flags, \
+ &(p)->e_ehsize, \
+ &(p)->e_phensize, \
+ &(p)->e_phnum, \
+ &(p)->e_shentsize, \
+ &(p)->e_shnum, \
+ &(p)->e_shstrndx
static char *ELF64_HEADER_SPECS[] = {
"hhwxxxwhhhhhh",
"HHWXXXWHHHHHH",
@@ -137,16 +138,16 @@ typedef struct
#define ELF_SECTION_SIZE 40
#define ELF_SECTION_FIELDS(p) \
- &(p)->sh_name, \
- &(p)->sh_type, \
- &(p)->sh_flags, \
- &(p)->sh_addr, \
- &(p)->sh_offset, \
- &(p)->sh_size, \
- &(p)->sh_link, \
- &(p)->sh_info, \
- &(p)->sh_addralign, \
- &(p)->sh_entsize
+ & (p)->sh_name, \
+ &(p)->sh_type, \
+ &(p)->sh_flags, \
+ &(p)->sh_addr, \
+ &(p)->sh_offset, \
+ &(p)->sh_size, \
+ &(p)->sh_link, \
+ &(p)->sh_info, \
+ &(p)->sh_addralign, \
+ &(p)->sh_entsize
static char *ELF_SECTION_SPECS[] = {
"wwwwwwwwww",
"WWWWWWWWWW",
@@ -164,15 +165,15 @@ typedef struct
Elf32_Word p_align;
} Elf32_Phdr;
#define ELF_PDHR_SIZE 32
-#define ELF_PHDR_FIELDS(p) \
- &(p)->p_type, \
- &(p)->p_offset, \
- &(p)->p_vaddr, \
- &(p)->p_paddr, \
- &(p)->p_filesz, \
- &(p)->p_memsz, \
- &(p)->p_flags, \
- &(p)->p_align
+#define ELF_PHDR_FIELDS(p) \
+ & (p)->p_type, \
+ &(p)->p_offset, \
+ &(p)->p_vaddr, \
+ &(p)->p_paddr, \
+ &(p)->p_filesz, \
+ &(p)->p_memsz, \
+ &(p)->p_flags, \
+ &(p)->p_align
static char *ELF_PHDR_SPECS[] = {
"wwwwwwww",
"WWWWWWWW",
@@ -188,9 +189,9 @@ typedef struct
} d_un;
} Elf32_Dyn;
#define ELF_DYN_SIZE 8
-#define ELF_DYN_FIELDS(p) \
- &(p)->d_tag, \
- &(p)->d_un
+#define ELF_DYN_FIELDS(p) \
+ & (p)->d_tag, \
+ &(p)->d_un
static char *ELF_DYN_SPECS[] = {
"ww",
"WW",
@@ -292,8 +293,6 @@ static char *ELF_DYN_SPECS[] = {
#define PT_HIPROC 0x7fffffff
-
-
#define ELFCLASSNONE 0
#define ELFCLASS32 1
#define ELFCLASS64 2
@@ -312,23 +311,24 @@ static int
getByteorder (char ei_data)
{
if (ei_data == ELFDATA2LSB)
- {
+ {
#if __BYTE_ORDER == __BIG_ENDIAN
- return 1;
+ return 1;
#else
- return 0;
+ return 0;
#endif
- }
+ }
else
- {
+ {
#if __BYTE_ORDER == __BIG_ENDIAN
- return 0;
+ return 0;
#else
- return 1;
+ return 1;
#endif
- }
+ }
}
+
/**
*
* @return 0 on success, -1 on error
@@ -336,17 +336,18 @@ getByteorder (char ei_data)
static int
getSectionHdr (const char *data,
size_t size,
- Elf32_Ehdr * ehdr, Elf32_Half idx, Elf32_Shdr * ret)
+ Elf32_Ehdr *ehdr, Elf32_Half idx, Elf32_Shdr *ret)
{
if (ehdr->e_shnum <= idx)
return -1;
EXTRACTOR_common_cat_unpack (&data[ehdr->e_shoff + ehdr->e_shentsize * idx],
- ELF_SECTION_SPECS[getByteorder (data[EI_CLASS])],
- ELF_SECTION_FIELDS (ret));
+ ELF_SECTION_SPECS[getByteorder (data[EI_CLASS])],
+ ELF_SECTION_FIELDS (ret));
return 0;
}
+
/**
*
* @return 0 on success, -1 on error
@@ -354,17 +355,18 @@ getSectionHdr (const char *data,
static int
getDynTag (const char *data,
size_t size,
- Elf32_Ehdr * ehdr,
- Elf32_Off off, Elf32_Word osize, unsigned int idx, Elf32_Dyn * ret)
+ Elf32_Ehdr *ehdr,
+ Elf32_Off off, Elf32_Word osize, unsigned int idx, Elf32_Dyn *ret)
{
if ((off + osize > size) || ((idx + 1) * ELF_DYN_SIZE > osize))
return -1;
EXTRACTOR_common_cat_unpack (&data[off + idx * ELF_DYN_SIZE],
- ELF_DYN_SPECS[getByteorder (data[EI_CLASS])],
- ELF_DYN_FIELDS (ret));
+ ELF_DYN_SPECS[getByteorder (data[EI_CLASS])],
+ ELF_DYN_FIELDS (ret));
return 0;
}
+
/**
*
* @return 0 on success, -1 on error
@@ -372,26 +374,27 @@ getDynTag (const char *data,
static int
getProgramHdr (const char *data,
size_t size,
- Elf32_Ehdr * ehdr, Elf32_Half idx, Elf32_Phdr * ret)
+ Elf32_Ehdr *ehdr, Elf32_Half idx, Elf32_Phdr *ret)
{
if (ehdr->e_phnum <= idx)
return -1;
EXTRACTOR_common_cat_unpack (&data[ehdr->e_phoff + ehdr->e_phensize * idx],
- ELF_PHDR_SPECS[getByteorder (data[EI_CLASS])],
- ELF_PHDR_FIELDS (ret));
+ ELF_PHDR_SPECS[getByteorder (data[EI_CLASS])],
+ ELF_PHDR_FIELDS (ret));
return 0;
}
+
/**
* Parse ELF header.
* @return 0 on success for 32 bit, 1 on success for 64 bit, -1 on error
*/
static int
-getELFHdr (const char *data,
- size_t size,
- Elf32_Ehdr * ehdr,
- Elf64_Ehdr * ehdr64)
+getELFHdr (const char *data,
+ size_t size,
+ Elf32_Ehdr *ehdr,
+ Elf64_Ehdr *ehdr64)
{
/* catlib */
if (size < EI_NIDENT)
@@ -400,43 +403,47 @@ getELFHdr (const char *data,
return -1; /* not an elf */
switch (data[EI_CLASS])
- {
- case ELFCLASS32:
- if (size < sizeof (Elf32_Ehdr) + EI_NIDENT)
- return -1;
- EXTRACTOR_common_cat_unpack (&data[EI_NIDENT],
- ELF_HEADER_SPECS[getByteorder (data[EI_DATA])],
- ELF_HEADER_FIELDS (ehdr));
- if (ehdr->e_shoff + ehdr->e_shentsize * ehdr->e_shnum > size)
- return -1; /* invalid offsets... */
- if (ehdr->e_shentsize < ELF_SECTION_SIZE)
- return -1; /* huh? */
- if (ehdr->e_phoff + ehdr->e_phensize * ehdr->e_phnum > size)
- return -1;
- return 0;
- case ELFCLASS64:
- if (size < sizeof (Elf64_Ehdr) + EI_NIDENT)
- return -1;
- EXTRACTOR_common_cat_unpack (&data[EI_NIDENT],
- ELF64_HEADER_SPECS[getByteorder (data[EI_DATA])],
- ELF64_HEADER_FIELDS (ehdr64));
- if (ehdr64->e_shoff + ((uint32_t) ehdr64->e_shentsize * ehdr64->e_shnum) > size)
- return -1; /* invalid offsets... */
- if (ehdr64->e_phoff + ((uint32_t) ehdr64->e_phensize * ehdr64->e_phnum) > size)
- return -1;
- return 1;
- default:
+ {
+ case ELFCLASS32:
+ if (size < sizeof (Elf32_Ehdr) + EI_NIDENT)
return -1;
- }
+ EXTRACTOR_common_cat_unpack (&data[EI_NIDENT],
+ ELF_HEADER_SPECS[getByteorder (data[EI_DATA])],
+ ELF_HEADER_FIELDS (ehdr));
+ if (ehdr->e_shoff + ehdr->e_shentsize * ehdr->e_shnum > size)
+ return -1; /* invalid offsets... */
+ if (ehdr->e_shentsize < ELF_SECTION_SIZE)
+ return -1; /* huh? */
+ if (ehdr->e_phoff + ehdr->e_phensize * ehdr->e_phnum > size)
+ return -1;
+ return 0;
+ case ELFCLASS64:
+ if (size < sizeof (Elf64_Ehdr) + EI_NIDENT)
+ return -1;
+ EXTRACTOR_common_cat_unpack (&data[EI_NIDENT],
+ ELF64_HEADER_SPECS[getByteorder (
+ data[EI_DATA])],
+ ELF64_HEADER_FIELDS (ehdr64));
+ if (ehdr64->e_shoff + ((uint32_t) ehdr64->e_shentsize * ehdr64->e_shnum) >
+ size)
+ return -1; /* invalid offsets... */
+ if (ehdr64->e_phoff + ((uint32_t) ehdr64->e_phensize * ehdr64->e_phnum) >
+ size)
+ return -1;
+ return 1;
+ default:
+ return -1;
+ }
}
+
/**
* @return the string (offset into data, do NOT free), NULL on error
*/
static const char *
readStringTable (const char *data,
size_t size,
- Elf32_Ehdr * ehdr,
+ Elf32_Ehdr *ehdr,
Elf32_Half strTableOffset, Elf32_Word sh_name)
{
Elf32_Shdr shrd;
@@ -450,15 +457,19 @@ readStringTable (const char *data,
return &data[shrd.sh_offset + sh_name];
}
-#define ADD(s, type) do { if (0!=proc(proc_cls, "elf", type, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen(s)+1)) return 1; } while (0)
+
+#define ADD(s, type) do { if (0!=proc (proc_cls, "elf", type, \
+ EXTRACTOR_METAFORMAT_UTF8, "text/plain", \
+ s, strlen (s) + 1)) return 1; \
+} while (0)
/* application/x-executable, ELF */
-int
+int
EXTRACTOR_elf_extract (const char *data,
- size_t size,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls,
- const char *options)
+ size_t size,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls,
+ const char *options)
{
Elf32_Ehdr ehdr;
Elf32_Half idx;
@@ -470,186 +481,186 @@ EXTRACTOR_elf_extract (const char *data,
return 0;
ADD ("application/x-executable", EXTRACTOR_METATYPE_MIMETYPE);
switch ( ((unsigned char*) data)[EI_OSABI])
- {
- case ELFOSABI_LINUX:
- ADD ("Linux", EXTRACTOR_METATYPE_TARGET_OS);
- break;
- case ELFOSABI_FREEBSD:
- ADD ("FreeBSD", EXTRACTOR_METATYPE_TARGET_OS);
- break;
- case ELFOSABI_NETBSD:
- ADD ("NetBSD", EXTRACTOR_METATYPE_TARGET_OS);
- break;
- case ELFOSABI_OPENBSD:
- ADD ("OpenBSD", EXTRACTOR_METATYPE_TARGET_OS);
- break;
- case ELFOSABI_IRIX:
- ADD ("IRIX", EXTRACTOR_METATYPE_TARGET_OS);
- break;
- default:
- break;
- }
- switch ( (ret == 0) ? ehdr.e_type : ehdr64.e_type)
- {
- case ET_REL:
- ADD ("Relocatable file", EXTRACTOR_METATYPE_RESOURCE_TYPE);
- break;
- case ET_EXEC:
- ADD ("Executable file", EXTRACTOR_METATYPE_RESOURCE_TYPE);
- break;
- case ET_DYN:
- ADD ("Shared object file", EXTRACTOR_METATYPE_RESOURCE_TYPE);
- break;
- case ET_CORE:
- ADD ("Core file", EXTRACTOR_METATYPE_RESOURCE_TYPE);
- break;
- default:
- break; /* unknown */
- }
+ {
+ case ELFOSABI_LINUX:
+ ADD ("Linux", EXTRACTOR_METATYPE_TARGET_OS);
+ break;
+ case ELFOSABI_FREEBSD:
+ ADD ("FreeBSD", EXTRACTOR_METATYPE_TARGET_OS);
+ break;
+ case ELFOSABI_NETBSD:
+ ADD ("NetBSD", EXTRACTOR_METATYPE_TARGET_OS);
+ break;
+ case ELFOSABI_OPENBSD:
+ ADD ("OpenBSD", EXTRACTOR_METATYPE_TARGET_OS);
+ break;
+ case ELFOSABI_IRIX:
+ ADD ("IRIX", EXTRACTOR_METATYPE_TARGET_OS);
+ break;
+ default:
+ break;
+ }
+ switch ( (ret == 0) ? ehdr.e_type : ehdr64.e_type)
+ {
+ case ET_REL:
+ ADD ("Relocatable file", EXTRACTOR_METATYPE_RESOURCE_TYPE);
+ break;
+ case ET_EXEC:
+ ADD ("Executable file", EXTRACTOR_METATYPE_RESOURCE_TYPE);
+ break;
+ case ET_DYN:
+ ADD ("Shared object file", EXTRACTOR_METATYPE_RESOURCE_TYPE);
+ break;
+ case ET_CORE:
+ ADD ("Core file", EXTRACTOR_METATYPE_RESOURCE_TYPE);
+ break;
+ default:
+ break; /* unknown */
+ }
switch ( (ret == 0) ? ehdr.e_machine : ehdr64.e_machine)
- {
- case EM_M32:
- ADD ("M32", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
- break;
- case EM_386:
- ADD ("i386", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
- break;
- case EM_68K:
- ADD ("68K", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
- break;
- case EM_88K:
- ADD ("88K", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
- break;
- case EM_SPARC:
- ADD ("Sparc", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
- break;
- case EM_860:
- ADD ("960", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
- break;
- case EM_MIPS:
- ADD ("MIPS", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
- break;
- case EM_PPC:
- ADD ("PPC", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
- break;
- case EM_PPC64:
- ADD ("PPC64", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
- break;
- case EM_S390:
- ADD ("S390", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
- break;
- case EM_ARM:
- ADD ("ARM", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
- break;
- case EM_ALPHA:
- ADD ("ALPHA", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
- break;
- case EM_IA_64:
- ADD ("IA-64", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
- break;
- case EM_X86_64:
- ADD ("x86_64", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
- break;
- case EM_CUDA:
- ADD ("NVIDIA CUDA", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
- break;
- default:
- break; /* oops */
- }
+ {
+ case EM_M32:
+ ADD ("M32", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
+ break;
+ case EM_386:
+ ADD ("i386", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
+ break;
+ case EM_68K:
+ ADD ("68K", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
+ break;
+ case EM_88K:
+ ADD ("88K", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
+ break;
+ case EM_SPARC:
+ ADD ("Sparc", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
+ break;
+ case EM_860:
+ ADD ("960", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
+ break;
+ case EM_MIPS:
+ ADD ("MIPS", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
+ break;
+ case EM_PPC:
+ ADD ("PPC", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
+ break;
+ case EM_PPC64:
+ ADD ("PPC64", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
+ break;
+ case EM_S390:
+ ADD ("S390", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
+ break;
+ case EM_ARM:
+ ADD ("ARM", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
+ break;
+ case EM_ALPHA:
+ ADD ("ALPHA", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
+ break;
+ case EM_IA_64:
+ ADD ("IA-64", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
+ break;
+ case EM_X86_64:
+ ADD ("x86_64", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
+ break;
+ case EM_CUDA:
+ ADD ("NVIDIA CUDA", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
+ break;
+ default:
+ break; /* oops */
+ }
if (ret != 0)
return 0; /* FIXME: full support for 64-bit ELF... */
for (idx = 0; idx < ehdr.e_phnum; idx++)
- {
- Elf32_Phdr phdr;
+ {
+ Elf32_Phdr phdr;
- if (0 != getProgramHdr (data, size, &ehdr, idx, &phdr))
+ if (0 != getProgramHdr (data, size, &ehdr, idx, &phdr))
+ return 0;
+ if (phdr.p_type == PT_DYNAMIC)
+ {
+ unsigned int dc = phdr.p_filesz / ELF_DYN_SIZE;
+ unsigned int id;
+ Elf32_Addr stringPtr;
+ Elf32_Half stringIdx;
+ Elf32_Half six;
+
+ stringPtr = 0;
+
+ for (id = 0; id < dc; id++)
+ {
+ Elf32_Dyn dyn;
+ if (0 != getDynTag (data,
+ size,
+ &ehdr,
+ phdr.p_offset, phdr.p_filesz, id, &dyn))
+ return 0;
+ if (DT_STRTAB == dyn.d_tag)
+ {
+ stringPtr = dyn.d_un.d_ptr;
+ break;
+ }
+ }
+ if (stringPtr == 0)
return 0;
- if (phdr.p_type == PT_DYNAMIC)
+ for (six = 0; six < ehdr.e_shnum; six++)
+ {
+ Elf32_Shdr sec;
+ if (-1 == getSectionHdr (data, size, &ehdr, six, &sec))
+ return 0;
+ if ((sec.sh_addr == stringPtr) && (sec.sh_type == SHT_STRTAB))
{
- unsigned int dc = phdr.p_filesz / ELF_DYN_SIZE;
- unsigned int id;
- Elf32_Addr stringPtr;
- Elf32_Half stringIdx;
- Elf32_Half six;
-
- stringPtr = 0;
-
- for (id = 0; id < dc; id++)
- {
- Elf32_Dyn dyn;
- if (0 != getDynTag (data,
- size,
- &ehdr,
- phdr.p_offset, phdr.p_filesz, id, &dyn))
- return 0;
- if (DT_STRTAB == dyn.d_tag)
- {
- stringPtr = dyn.d_un.d_ptr;
- break;
- }
- }
- if (stringPtr == 0)
- return 0;
- for (six = 0; six < ehdr.e_shnum; six++)
+ stringIdx = six;
+ break;
+ }
+ }
+ if (six == ehdr.e_shnum)
+ return 0; /* stringIdx not found */
+
+ for (id = 0; id < dc; id++)
+ {
+ Elf32_Dyn dyn;
+ if (0 != getDynTag (data,
+ size,
+ &ehdr,
+ phdr.p_offset, phdr.p_filesz, id, &dyn))
+ return 0;
+ switch (dyn.d_tag)
+ {
+ case DT_RPATH:
+ {
+ const char *rpath;
+
+ rpath = readStringTable (data,
+ size,
+ &ehdr,
+ stringIdx, dyn.d_un.d_val);
+ /* "source" of the dependencies: path
+ to dynamic libraries */
+ if (rpath != NULL)
{
- Elf32_Shdr sec;
- if (-1 == getSectionHdr (data, size, &ehdr, six, &sec))
- return 0;
- if ((sec.sh_addr == stringPtr) && (sec.sh_type == SHT_STRTAB))
- {
- stringIdx = six;
- break;
- }
+ ADD (rpath, EXTRACTOR_METATYPE_LIBRARY_SEARCH_PATH);
}
- if (six == ehdr.e_shnum)
- return 0; /* stringIdx not found */
-
- for (id = 0; id < dc; id++)
+ break;
+ }
+ case DT_NEEDED:
+ {
+ const char *needed;
+
+ needed = readStringTable (data,
+ size,
+ &ehdr,
+ stringIdx, dyn.d_un.d_val);
+ if (needed != NULL)
{
- Elf32_Dyn dyn;
- if (0 != getDynTag (data,
- size,
- &ehdr,
- phdr.p_offset, phdr.p_filesz, id, &dyn))
- return 0;
- switch (dyn.d_tag)
- {
- case DT_RPATH:
- {
- const char *rpath;
-
- rpath = readStringTable (data,
- size,
- &ehdr,
- stringIdx, dyn.d_un.d_val);
- /* "source" of the dependencies: path
- to dynamic libraries */
- if (rpath != NULL)
- {
- ADD (rpath, EXTRACTOR_METATYPE_LIBRARY_SEARCH_PATH);
- }
- break;
- }
- case DT_NEEDED:
- {
- const char *needed;
-
- needed = readStringTable (data,
- size,
- &ehdr,
- stringIdx, dyn.d_un.d_val);
- if (needed != NULL)
- {
- ADD (needed, EXTRACTOR_METATYPE_LIBRARY_DEPENDENCY);
- }
- break;
- }
- }
+ ADD (needed, EXTRACTOR_METATYPE_LIBRARY_DEPENDENCY);
}
-
+ break;
+ }
}
+ }
+
}
+ }
return 0;
}
diff --git a/src/plugins/old/flv_extractor.c b/src/plugins/old/flv_extractor.c
@@ -55,16 +55,18 @@
#define ASTYPE_TYPEDOBJECT 0x10
#define ASTYPE_AMF3DATA 0x11
-typedef struct {
- void * userdata;
- void (*as_begin_callback)(unsigned char type, void * userdata);
- void (*as_key_callback)(char * key, void * userdata);
- void (*as_end_callback)(unsigned char type, void * value, void * userdata);
+typedef struct
+{
+ void *userdata;
+ void (*as_begin_callback)(unsigned char type, void *userdata);
+ void (*as_key_callback)(char *key, void *userdata);
+ void (*as_end_callback)(unsigned char type, void *value, void *userdata);
} AMFParserHandler;
/* core datatypes */
-static uint32_t readInt32(const unsigned char **data)
+static uint32_t
+readInt32 (const unsigned char **data)
{
const unsigned char *ptr = *data;
uint32_t val;
@@ -75,7 +77,9 @@ static uint32_t readInt32(const unsigned char **data)
return val;
}
-static uint32_t readInt24(const unsigned char **data)
+
+static uint32_t
+readInt24 (const unsigned char **data)
{
const unsigned char *ptr = *data;
uint32_t val;
@@ -86,7 +90,9 @@ static uint32_t readInt24(const unsigned char **data)
return val;
}
-static uint16_t readInt16(const unsigned char **data)
+
+static uint16_t
+readInt16 (const unsigned char **data)
{
const unsigned char *ptr = *data;
uint16_t val;
@@ -97,14 +103,17 @@ static uint16_t readInt16(const unsigned char **data)
return val;
}
-static double readDouble(const unsigned char **data)
+
+static double
+readDouble (const unsigned char **data)
{
const unsigned char *ptr = *data;
double val;
- EXTRACTOR_common_floatformat_to_double(&EXTRACTOR_floatformat_ieee_double_big,
- (const void *)ptr,
- &val);
+ EXTRACTOR_common_floatformat_to_double (
+ &EXTRACTOR_floatformat_ieee_double_big,
+ (const void *) ptr,
+ &val);
ptr += 8;
*data = ptr;
return val;
@@ -113,9 +122,10 @@ static double readDouble(const unsigned char **data)
/* actionscript types */
-static int readASNumber(const unsigned char **data,
- size_t *len,
- double *retval)
+static int
+readASNumber (const unsigned char **data,
+ size_t *len,
+ double *retval)
{
const unsigned char *ptr = *data;
double val;
@@ -123,7 +133,7 @@ static int readASNumber(const unsigned char **data,
if (*len < 8)
return -1;
- val = readDouble(&ptr);
+ val = readDouble (&ptr);
*len -= 8;
*retval = val;
@@ -131,9 +141,11 @@ static int readASNumber(const unsigned char **data,
return 0;
}
-static int readASBoolean(const unsigned char **data,
- size_t *len,
- int *retval)
+
+static int
+readASBoolean (const unsigned char **data,
+ size_t *len,
+ int *retval)
{
const unsigned char *ptr = *data;
int val;
@@ -150,29 +162,33 @@ static int readASBoolean(const unsigned char **data,
return 0;
}
-static int readASDate(const unsigned char **data,
- size_t *len,
- double *millis,
- short *zone)
+
+static int
+readASDate (const unsigned char **data,
+ size_t *len,
+ double *millis,
+ short *zone)
{
const unsigned char *ptr = *data;
if (*len < 10)
return -1;
- *millis = readDouble(&ptr);
+ *millis = readDouble (&ptr);
*len -= 8;
- *zone = readInt16(&ptr);
+ *zone = readInt16 (&ptr);
*len -= 2;
*data = ptr;
return 0;
}
-static int readASString(const unsigned char **data,
- size_t *len,
- char **retval)
+
+static int
+readASString (const unsigned char **data,
+ size_t *len,
+ char **retval)
{
const unsigned char *ptr = *data;
char *ret;
@@ -181,15 +197,15 @@ static int readASString(const unsigned char **data,
if (*len < 2)
return -1;
- slen = readInt16(&ptr);
+ slen = readInt16 (&ptr);
if (*len < (2 + slen))
return -1;
- ret = malloc(slen+1);
+ ret = malloc (slen + 1);
if (ret == NULL)
return -1;
- memcpy(ret, ptr, slen);
+ memcpy (ret, ptr, slen);
ret[slen] = '\0';
ptr += slen;
*len -= (2 + slen);
@@ -199,9 +215,11 @@ static int readASString(const unsigned char **data,
return 0;
}
-static int parse_amf(const unsigned char **data,
- size_t *len,
- AMFParserHandler *handler)
+
+static int
+parse_amf (const unsigned char **data,
+ size_t *len,
+ AMFParserHandler *handler)
{
const unsigned char *ptr = *data;
unsigned char astype;
@@ -210,45 +228,47 @@ static int parse_amf(const unsigned char **data,
ret = 0;
astype = *ptr++;
(*(handler->as_begin_callback))(astype, handler->userdata);
- switch (astype) {
- case ASTYPE_NUMBER:
+ switch (astype)
+ {
+ case ASTYPE_NUMBER:
{
double val;
- ret = readASNumber(&ptr, len, &val);
+ ret = readASNumber (&ptr, len, &val);
if (ret == 0)
(*(handler->as_end_callback))(astype,
&val,
handler->userdata);
break;
}
- case ASTYPE_BOOLEAN:
+ case ASTYPE_BOOLEAN:
{
int val;
- ret = readASBoolean(&ptr, len, &val);
+ ret = readASBoolean (&ptr, len, &val);
if (ret == 0)
(*(handler->as_end_callback))(astype,
&val,
handler->userdata);
break;
}
- case ASTYPE_STRING:
+ case ASTYPE_STRING:
{
char *val;
- ret = readASString(&ptr, len, &val);
- if (ret == 0) {
+ ret = readASString (&ptr, len, &val);
+ if (ret == 0)
+ {
(*(handler->as_end_callback))(astype,
val,
handler->userdata);
- free(val);
+ free (val);
}
break;
}
- case ASTYPE_DATE:
+ case ASTYPE_DATE:
{
void *tmp[2];
double millis;
short tz;
- ret = readASDate(&ptr, len, &millis, &tz);
+ ret = readASDate (&ptr, len, &millis, &tz);
tmp[0] = &millis;
tmp[1] = &tz;
if (ret == 0)
@@ -257,53 +277,56 @@ static int parse_amf(const unsigned char **data,
handler->userdata);
break;
}
- case ASTYPE_NULL:
- case ASTYPE_UNDEFINED:
- case ASTYPE_UNSUPPORTED:
- case ASTYPE_ENDOFOBJECT:
- (*(handler->as_end_callback))(astype, NULL, handler->userdata);
- break;
- case ASTYPE_ARRAY:
+ case ASTYPE_NULL:
+ case ASTYPE_UNDEFINED:
+ case ASTYPE_UNSUPPORTED:
+ case ASTYPE_ENDOFOBJECT:
+ (*(handler->as_end_callback))(astype, NULL, handler->userdata);
+ break;
+ case ASTYPE_ARRAY:
{
long i, alen;
- if (*len < 4) {
+ if (*len < 4)
+ {
ret = -1;
break;
}
- alen = readInt32(&ptr);
+ alen = readInt32 (&ptr);
*len -= 4;
- for (i = 0; i < alen; i++) {
- ret = parse_amf(&ptr, len, handler);
+ for (i = 0; i < alen; i++)
+ {
+ ret = parse_amf (&ptr, len, handler);
if (ret == -1)
- break;
+ break;
}
(*(handler->as_end_callback))(ASTYPE_ARRAY,
NULL,
handler->userdata);
break;
}
- case ASTYPE_OBJECT:
+ case ASTYPE_OBJECT:
{
char *key;
unsigned char type;
- ret = readASString(&ptr, len, &key);
+ ret = readASString (&ptr, len, &key);
if (ret == -1)
break;
(*(handler->as_key_callback))(key,
handler->userdata);
- free(key);
+ free (key);
type = *ptr;
- while (type != ASTYPE_ENDOFOBJECT) {
- ret = parse_amf(&ptr, len, handler);
+ while (type != ASTYPE_ENDOFOBJECT)
+ {
+ ret = parse_amf (&ptr, len, handler);
if (ret == -1)
break;
- ret = readASString(&ptr, len, &key);
+ ret = readASString (&ptr, len, &key);
if (ret == -1)
break;
(*(handler->as_key_callback))(key,
handler->userdata);
- free(key);
+ free (key);
type = *ptr;
}
if (ret == 0)
@@ -312,34 +335,36 @@ static int parse_amf(const unsigned char **data,
handler->userdata);
break;
}
- case ASTYPE_MIXEDARRAY:
+ case ASTYPE_MIXEDARRAY:
{
char *key;
unsigned char type;
-
- if (*len < 4) {
+
+ if (*len < 4)
+ {
ret = -1;
break;
}
- /* max_index */ readInt32(&ptr);
+ /* max_index */ readInt32 (&ptr);
*len -= 4;
- ret = readASString(&ptr, len, &key);
+ ret = readASString (&ptr, len, &key);
if (ret == -1)
break;
(*(handler->as_key_callback))(key,
handler->userdata);
- free(key);
+ free (key);
type = *ptr;
- while (type != ASTYPE_ENDOFOBJECT) {
- ret = parse_amf(&ptr, len, handler);
+ while (type != ASTYPE_ENDOFOBJECT)
+ {
+ ret = parse_amf (&ptr, len, handler);
if (ret == -1)
break;
- ret = readASString(&ptr, len, &key);
+ ret = readASString (&ptr, len, &key);
if (ret == -1)
break;
(*(handler->as_key_callback))(key,
handler->userdata);
- free(key);
+ free (key);
type = *ptr;
}
if (ret == 0)
@@ -348,21 +373,22 @@ static int parse_amf(const unsigned char **data,
handler->userdata);
break;
}
- default:
- ret = -1;
- (*(handler->as_end_callback))(astype,
- NULL,
- handler->userdata);
+ default:
+ ret = -1;
+ (*(handler->as_end_callback))(astype,
+ NULL,
+ handler->userdata);
#if DEBUG
- printf("parse_amf: Unknown type %02x", astype);
+ printf ("parse_amf: Unknown type %02x", astype);
#endif
- break;
+ break;
}
*data = ptr;
return ret;
}
+
/*
* FLV parser
*/
@@ -379,8 +405,9 @@ flv_to_iso_date (double timeval, short timezone,
* shift epoch to proleptic times
* to make subsequent modulo operations safer.
*/
- long long my_timeval = (timeval/1000)
- + ((long long) ((1970 * 365) + 478) * (long long) 86400);
+ long long my_timeval = (timeval / 1000)
+ + ((long long) ((1970 * 365) + 478) * (long
+ long) 86400);
unsigned int seconds = (unsigned int) (my_timeval % 60);
unsigned int minutes = (unsigned int) ((my_timeval / 60) % 60);
@@ -396,7 +423,7 @@ flv_to_iso_date (double timeval, short timezone,
unsigned int days = (unsigned int) (my_timeval / (24 * 3600));
unsigned int days_in_month[] =
- { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+ { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
unsigned int diff = 0;
if ((long long) 0 > my_timeval)
@@ -413,15 +440,15 @@ flv_to_iso_date (double timeval, short timezone,
*/
diff = (days / ((365 * 100) + 24));
if (4 <= diff)
- {
- year += 399;
- days = 364;
- }
+ {
+ year += 399;
+ days = 364;
+ }
else
- {
- year += (100 * diff);
- days %= ((365 * 100) + 24);
- }
+ {
+ year += (100 * diff);
+ days %= ((365 * 100) + 24);
+ }
/*
* remaining leap years
@@ -430,32 +457,32 @@ flv_to_iso_date (double timeval, short timezone,
days %= ((365 * 4) + 1);
while (1)
+ {
+ if ((0 == (year % 400)) || ((0 == (year % 4)) && (0 != (year % 100))))
{
- if ((0 == (year % 400)) || ((0 == (year % 4)) && (0 != (year % 100))))
- {
- if (366 > days)
- {
- break;
- }
- else
- {
- days -= 366;
- year++;
- }
- }
+ if (366 > days)
+ {
+ break;
+ }
else
- {
- if (365 > days)
- {
- break;
- }
- else
- {
- days -= 365;
- year++;
- }
- }
+ {
+ days -= 366;
+ year++;
+ }
+ }
+ else
+ {
+ if (365 > days)
+ {
+ break;
+ }
+ else
+ {
+ days -= 365;
+ year++;
+ }
}
+ }
if ((0 == (year % 400)) || ((0 == (year % 4)) && (0 != (year % 100))))
days_in_month[1] = 29;
@@ -465,12 +492,12 @@ flv_to_iso_date (double timeval, short timezone,
zone_sign = 0;
if (timezone < 0)
- {
- zone_sign = -1;
- timezone = -timezone;
- }
- zone_hours = timezone/60;
- zone_minutes = timezone - zone_hours*60;
+ {
+ zone_sign = -1;
+ timezone = -timezone;
+ }
+ zone_hours = timezone / 60;
+ zone_minutes = timezone - zone_hours * 60;
retval = snprintf (rtime, rsize, "%04u-%02u-%02uT%02u:%02u:%02u%c%02d:%02u",
year, month + 1, days + 1, hours, minutes, seconds,
@@ -479,6 +506,7 @@ flv_to_iso_date (double timeval, short timezone,
return (retval < rsize) ? 0 : EOVERFLOW;
}
+
typedef struct
{
char signature[3];
@@ -503,20 +531,21 @@ typedef struct
#define FLV_TAG_HEADER_SIZE 11
-static int readFLVHeader(const unsigned char **data,
- const unsigned char *end,
- FLVHeader *hdr)
+static int
+readFLVHeader (const unsigned char **data,
+ const unsigned char *end,
+ FLVHeader *hdr)
{
const unsigned char *ptr = *data;
if ((ptr + FLV_HEADER_SIZE) > end)
return -1;
- memcpy(hdr->signature, ptr, 3);
+ memcpy (hdr->signature, ptr, 3);
ptr += 3;
hdr->version = *ptr++;
hdr->flags = *ptr++;
- hdr->offset = readInt32(&ptr);
+ hdr->offset = readInt32 (&ptr);
if (hdr->offset != FLV_HEADER_SIZE)
return -1;
@@ -524,24 +553,28 @@ static int readFLVHeader(const unsigned char **data,
return 0;
}
-static int readPreviousTagSize(const unsigned char **data,
- const unsigned char *end,
- unsigned long *prev_size)
+
+static int
+readPreviousTagSize (const unsigned char **data,
+ const unsigned char *end,
+ unsigned long *prev_size)
{
const unsigned char *ptr = *data;
if ((ptr + 4) > end)
return -1;
- *prev_size = readInt32(&ptr);
+ *prev_size = readInt32 (&ptr);
*data = ptr;
return 0;
}
-static int readFLVTagHeader(const unsigned char **data,
- const unsigned char *end,
- FLVTagHeader *hdr)
+
+static int
+readFLVTagHeader (const unsigned char **data,
+ const unsigned char *end,
+ FLVTagHeader *hdr)
{
const unsigned char *ptr = *data;
@@ -549,15 +582,17 @@ static int readFLVTagHeader(const unsigned char **data,
return -1;
hdr->type = *ptr++;
- hdr->bodyLength = readInt24(&ptr);
- hdr->timestamp = readInt32(&ptr);
- hdr->streamId = readInt24(&ptr);
+ hdr->bodyLength = readInt24 (&ptr);
+ hdr->timestamp = readInt32 (&ptr);
+ hdr->streamId = readInt24 (&ptr);
*data = ptr;
return 0;
}
-typedef struct {
+
+typedef struct
+{
int videoCodec;
char *videoCodecStr;
int videoWidth;
@@ -573,7 +608,8 @@ typedef struct {
int audioRate;
} FLVStreamInfo;
-typedef enum {
+typedef enum
+{
FLV_NONE = 0,
FLV_WIDTH,
FLV_HEIGHT,
@@ -586,7 +622,8 @@ typedef enum {
FLV_ACODECID
} FLVStreamAttribute;
-typedef struct {
+typedef struct
+{
const char *key;
FLVStreamAttribute attribute;
} MetaKeyToStreamAttribute;
@@ -605,7 +642,8 @@ static MetaKeyToStreamAttribute key_to_attribute_map[] = {
{ NULL, FLV_NONE }
};
-typedef struct {
+typedef struct
+{
const char *key;
enum EXTRACTOR_MetaType type;
} MetaKeyToExtractorItem;
@@ -619,7 +657,8 @@ static MetaKeyToExtractorItem key_to_extractor_map[] = {
{ NULL, EXTRACTOR_METATYPE_RESERVED }
};
-typedef struct {
+typedef struct
+{
int onMetaData;
int parsingDepth;
int ret;
@@ -632,22 +671,25 @@ typedef struct {
FLVStreamInfo *streamInfo;
} FLVMetaParserState;
-static void handleASBegin(unsigned char type, void * userdata)
+static void
+handleASBegin (unsigned char type, void *userdata)
{
- FLVMetaParserState *state = (FLVMetaParserState *)userdata;
+ FLVMetaParserState *state = (FLVMetaParserState *) userdata;
- if (state->onMetaData && state->parsingDepth == 0 &&
- type != ASTYPE_MIXEDARRAY)
+ if (state->onMetaData && (state->parsingDepth == 0) &&
+ (type != ASTYPE_MIXEDARRAY) )
state->onMetaData = 0;
- if (type == ASTYPE_ARRAY || type == ASTYPE_MIXEDARRAY ||
- type == ASTYPE_OBJECT)
+ if ((type == ASTYPE_ARRAY) || (type == ASTYPE_MIXEDARRAY) ||
+ (type == ASTYPE_OBJECT) )
state->parsingDepth++;
}
-static void handleASKey(char * key, void * userdata)
+
+static void
+handleASKey (char *key, void *userdata)
{
- FLVMetaParserState *state = (FLVMetaParserState *)userdata;
+ FLVMetaParserState *state = (FLVMetaParserState *) userdata;
int i;
if (key == NULL)
@@ -655,26 +697,29 @@ static void handleASKey(char * key, void * userdata)
i = 0;
while ((key_to_extractor_map[i].key != NULL) &&
- (strcasecmp(key, key_to_extractor_map[i].key) != 0))
+ (strcasecmp (key, key_to_extractor_map[i].key) != 0))
i++;
state->currentKeyType = key_to_extractor_map[i].type;
i = 0;
while ((key_to_attribute_map[i].key != NULL) &&
- (strcasecmp(key, key_to_attribute_map[i].key) != 0))
+ (strcasecmp (key, key_to_attribute_map[i].key) != 0))
i++;
state->currentAttribute = key_to_attribute_map[i].attribute;
}
-static void handleASEnd(unsigned char type, void * value, void * userdata)
+
+static void
+handleASEnd (unsigned char type, void *value, void *userdata)
{
- FLVMetaParserState *state = (FLVMetaParserState *)userdata;
+ FLVMetaParserState *state = (FLVMetaParserState *) userdata;
const char *s;
char tmpstr[30];
- if ((state->parsingDepth == 0) && (type == ASTYPE_STRING)) {
- s = (const char *)value;
- if (!strcmp(s, "onMetaData"))
+ if ((state->parsingDepth == 0) && (type == ASTYPE_STRING))
+ {
+ s = (const char *) value;
+ if (! strcmp (s, "onMetaData"))
state->onMetaData = 1;
}
@@ -686,50 +731,53 @@ static void handleASEnd(unsigned char type, void * value, void * userdata)
(state->currentAttribute != FLV_NONE) &&
(type == ASTYPE_NUMBER))
{
- double n = *((double *)value);
- switch (state->currentAttribute) {
- case FLV_NONE: /* make gcc happy */
- break;
- case FLV_STEREO:
- break;
- case FLV_ACHANNELS:
- state->streamInfo->audioChannels = n;
- break;
- case FLV_WIDTH:
- if (state->streamInfo->videoWidth == -1)
- state->streamInfo->videoWidth = n;
- break;
- case FLV_HEIGHT:
- if (state->streamInfo->videoHeight == -1)
- state->streamInfo->videoHeight = n;
- break;
- case FLV_FRAMERATE:
- state->streamInfo->videoFrameRate = n;
- break;
- case FLV_VDATARATE:
- state->streamInfo->videoDataRate = n;
- break;
- case FLV_ADATARATE:
- state->streamInfo->audioDataRate = n;
- break;
- case FLV_VCODECID:
- if (state->streamInfo->videoCodec == -1)
- state->streamInfo->videoCodec = n;
- /* prefer codec ids to fourcc codes */
- if (state->streamInfo->videoCodecStr != NULL) {
- free(state->streamInfo->videoCodecStr);
- state->streamInfo->videoCodecStr = NULL;
- }
- break;
- case FLV_ACODECID:
- if (state->streamInfo->audioCodec == -1)
- state->streamInfo->audioCodec = n;
- /* prefer codec ids to fourcc codes */
- if (state->streamInfo->audioCodecStr != NULL) {
- free(state->streamInfo->audioCodecStr);
- state->streamInfo->audioCodecStr = NULL;
- }
- break;
+ double n = *((double *) value);
+ switch (state->currentAttribute)
+ {
+ case FLV_NONE: /* make gcc happy */
+ break;
+ case FLV_STEREO:
+ break;
+ case FLV_ACHANNELS:
+ state->streamInfo->audioChannels = n;
+ break;
+ case FLV_WIDTH:
+ if (state->streamInfo->videoWidth == -1)
+ state->streamInfo->videoWidth = n;
+ break;
+ case FLV_HEIGHT:
+ if (state->streamInfo->videoHeight == -1)
+ state->streamInfo->videoHeight = n;
+ break;
+ case FLV_FRAMERATE:
+ state->streamInfo->videoFrameRate = n;
+ break;
+ case FLV_VDATARATE:
+ state->streamInfo->videoDataRate = n;
+ break;
+ case FLV_ADATARATE:
+ state->streamInfo->audioDataRate = n;
+ break;
+ case FLV_VCODECID:
+ if (state->streamInfo->videoCodec == -1)
+ state->streamInfo->videoCodec = n;
+ /* prefer codec ids to fourcc codes */
+ if (state->streamInfo->videoCodecStr != NULL)
+ {
+ free (state->streamInfo->videoCodecStr);
+ state->streamInfo->videoCodecStr = NULL;
+ }
+ break;
+ case FLV_ACODECID:
+ if (state->streamInfo->audioCodec == -1)
+ state->streamInfo->audioCodec = n;
+ /* prefer codec ids to fourcc codes */
+ if (state->streamInfo->audioCodecStr != NULL)
+ {
+ free (state->streamInfo->audioCodecStr);
+ state->streamInfo->audioCodecStr = NULL;
+ }
+ break;
}
}
@@ -738,20 +786,21 @@ static void handleASEnd(unsigned char type, void * value, void * userdata)
(state->currentAttribute != FLV_NONE) &&
(type == ASTYPE_STRING))
{
- s = (const char *)value;
- switch (state->currentAttribute) {
- case FLV_VCODECID:
- if (s != NULL && state->streamInfo->videoCodecStr == NULL &&
- state->streamInfo->videoCodec == -1)
- state->streamInfo->videoCodecStr = strdup(s);
- break;
- case FLV_ACODECID:
- if (s != NULL && state->streamInfo->audioCodecStr == NULL &&
- state->streamInfo->audioCodec == -1)
- state->streamInfo->audioCodecStr = strdup(s);
- break;
- default:
- break;
+ s = (const char *) value;
+ switch (state->currentAttribute)
+ {
+ case FLV_VCODECID:
+ if ((s != NULL) && (state->streamInfo->videoCodecStr == NULL) &&
+ (state->streamInfo->videoCodec == -1) )
+ state->streamInfo->videoCodecStr = strdup (s);
+ break;
+ case FLV_ACODECID:
+ if ((s != NULL) && (state->streamInfo->audioCodecStr == NULL) &&
+ (state->streamInfo->audioCodec == -1) )
+ state->streamInfo->audioCodecStr = strdup (s);
+ break;
+ default:
+ break;
}
}
@@ -759,7 +808,7 @@ static void handleASEnd(unsigned char type, void * value, void * userdata)
(state->currentAttribute == FLV_STEREO) &&
(type == ASTYPE_BOOLEAN))
{
- int n = *((int *)value);
+ int n = *((int *) value);
if (state->streamInfo->audioChannels == -1)
state->streamInfo->audioChannels = (n == 0) ? 1 : 2;
}
@@ -769,57 +818,59 @@ static void handleASEnd(unsigned char type, void * value, void * userdata)
(state->currentKeyType != EXTRACTOR_METATYPE_RESERVED))
{
s = NULL;
- switch (type) {
- case ASTYPE_NUMBER:
+ switch (type)
+ {
+ case ASTYPE_NUMBER:
{
- double n = *((double *)value);
+ double n = *((double *) value);
s = tmpstr;
- if (state->currentKeyType == EXTRACTOR_METATYPE_DURATION)
- snprintf(tmpstr, sizeof(tmpstr), "%.2f s", n);
- else
- snprintf(tmpstr, sizeof(tmpstr), "%f", n);
- break;
+ if (state->currentKeyType == EXTRACTOR_METATYPE_DURATION)
+ snprintf (tmpstr, sizeof(tmpstr), "%.2f s", n);
+ else
+ snprintf (tmpstr, sizeof(tmpstr), "%f", n);
+ break;
}
- case ASTYPE_STRING:
+ case ASTYPE_STRING:
{
- s = (char *)value;
+ s = (char *) value;
break;
}
- case ASTYPE_DATE:
+ case ASTYPE_DATE:
{
- void **tmp = (void **)value;
- double *millis;
- short *tz;
- millis = (double *)tmp[0];
- tz = (short *)tmp[1];
- if (0 == flv_to_iso_date(*millis, *tz, tmpstr, sizeof(tmpstr)))
- s = tmpstr;
+ void **tmp = (void **) value;
+ double *millis;
+ short *tz;
+ millis = (double *) tmp[0];
+ tz = (short *) tmp[1];
+ if (0 == flv_to_iso_date (*millis, *tz, tmpstr, sizeof(tmpstr)))
+ s = tmpstr;
break;
}
}
if ( (s != NULL) &&
- (state->ret == 0) )
+ (state->ret == 0) )
state->ret = state->proc (state->proc_cls,
- "flv",
- state->currentKeyType,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- s,
- strlen (s) + 1);
+ "flv",
+ state->currentKeyType,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ s,
+ strlen (s) + 1);
}
state->currentKeyType = EXTRACTOR_METATYPE_RESERVED;
state->currentAttribute = FLV_NONE;
- if (type == ASTYPE_ARRAY || type == ASTYPE_MIXEDARRAY ||
- type == ASTYPE_OBJECT)
+ if ((type == ASTYPE_ARRAY) || (type == ASTYPE_MIXEDARRAY) ||
+ (type == ASTYPE_OBJECT) )
state->parsingDepth--;
}
+
static int
-handleMetaBody(const unsigned char *data, size_t len,
- FLVStreamInfo *stinfo,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls)
+handleMetaBody (const unsigned char *data, size_t len,
+ FLVStreamInfo *stinfo,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
AMFParserHandler handler;
FLVMetaParserState pstate;
@@ -836,12 +887,14 @@ handleMetaBody(const unsigned char *data, size_t len,
handler.as_key_callback = &handleASKey;
handler.as_end_callback = &handleASEnd;
- while (len > 0 && parse_amf(&data, &len, &handler) == 0);
+ while (len > 0 && parse_amf (&data, &len, &handler) == 0)
+ ;
if (pstate.ret != 0)
return 1;
return 0;
}
+
static char *FLVAudioCodecs[] = {
"Uncompressed",
"ADPCM",
@@ -875,19 +928,21 @@ static char *FLVAudioSampleRates[] = {
};
static void
-handleAudioBody(const unsigned char *data, size_t len,
- FLVStreamInfo *stinfo)
+handleAudioBody (const unsigned char *data, size_t len,
+ FLVStreamInfo *stinfo)
{
stinfo->audioChannels = (*data & 0x01) + 1;
stinfo->audioSampleBits = (*data & 0x02) >> 1;
stinfo->audioRate = (*data & 0x0C) >> 2;
stinfo->audioCodec = (*data & 0xF0) >> 4;
- if (stinfo->audioCodecStr != NULL) {
- free(stinfo->audioCodecStr);
+ if (stinfo->audioCodecStr != NULL)
+ {
+ free (stinfo->audioCodecStr);
stinfo->audioCodecStr = NULL;
}
}
+
static char *FLVVideoCodecs[] = {
NULL,
NULL,
@@ -911,8 +966,8 @@ static int sorenson_predefined_res[][2] = {
};
static void
-handleVideoBody(const unsigned char *data, size_t len,
- FLVStreamInfo *stinfo)
+handleVideoBody (const unsigned char *data, size_t len,
+ FLVStreamInfo *stinfo)
{
int codecId, frameType;
@@ -921,84 +976,94 @@ handleVideoBody(const unsigned char *data, size_t len,
data++;
/* try to get video dimensions */
- switch (codecId) {
- case 0x02: /* Sorenson */
- if (len < 9)
- break;
- if (frameType == 1) {
- int start_code = (data[0] << 9) | (data[1] << 1) | ((data[2] >> 7)&0x1);
- int version = (data[2] & 0x7C) >> 2;
- int frame_size = ((data[3] & 0x03) << 1) | (data[4] >> 7);
- if (start_code != 0x00000001)
- break;
- if (!(version == 0 || version == 1))
- break;
- if (frame_size == 0) {
- stinfo->videoWidth = ((data[4] & 0x7F) >> 1) | (data[5] >> 7);
- stinfo->videoHeight = ((data[5] & 0x7F) >> 1) | (data[6] >> 7);
- }
- else if (frame_size == 1) {
- stinfo->videoWidth = ((data[4] & 0x7F) << 9) | (data[5] << 1) |
- (data[6] >> 7);
- stinfo->videoHeight = ((data[6] & 0x7F) << 9) | (data[7] << 1) |
- (data[8] >> 7);
- }
- else {
- stinfo->videoWidth = sorenson_predefined_res[frame_size][0];
- stinfo->videoHeight = sorenson_predefined_res[frame_size][1];
- }
- }
+ switch (codecId)
+ {
+ case 0x02: /* Sorenson */
+ if (len < 9)
break;
- case 0x03: /* ScreenVideo */
- if (len < 5)
+ if (frameType == 1)
+ {
+ int start_code = (data[0] << 9) | (data[1] << 1) | ((data[2] >> 7) & 0x1);
+ int version = (data[2] & 0x7C) >> 2;
+ int frame_size = ((data[3] & 0x03) << 1) | (data[4] >> 7);
+ if (start_code != 0x00000001)
break;
- stinfo->videoWidth = readInt16(&data) & 0x0FFF;
- stinfo->videoHeight = readInt16(&data) & 0x0FFF;
+ if (! ((version == 0) || (version == 1) ))
+ break;
+ if (frame_size == 0)
+ {
+ stinfo->videoWidth = ((data[4] & 0x7F) >> 1) | (data[5] >> 7);
+ stinfo->videoHeight = ((data[5] & 0x7F) >> 1) | (data[6] >> 7);
+ }
+ else if (frame_size == 1)
+ {
+ stinfo->videoWidth = ((data[4] & 0x7F) << 9) | (data[5] << 1)
+ | (data[6] >> 7);
+ stinfo->videoHeight = ((data[6] & 0x7F) << 9) | (data[7] << 1)
+ | (data[8] >> 7);
+ }
+ else
+ {
+ stinfo->videoWidth = sorenson_predefined_res[frame_size][0];
+ stinfo->videoHeight = sorenson_predefined_res[frame_size][1];
+ }
+ }
+ break;
+ case 0x03: /* ScreenVideo */
+ if (len < 5)
break;
- case 0x04: /* On2 VP6 */
- case 0x05:
+ stinfo->videoWidth = readInt16 (&data) & 0x0FFF;
+ stinfo->videoHeight = readInt16 (&data) & 0x0FFF;
+ break;
+ case 0x04: /* On2 VP6 */
+ case 0x05:
{
unsigned char dim_adj;
if (len < 10)
break;
dim_adj = *data++;
- if ((frameType == 1) && ((data[0] & 0x80) == 0)) {
+ if ((frameType == 1) && ((data[0] & 0x80) == 0))
+ {
/* see ffmpeg vp6 decoder */
int separated_coeff = data[0] & 0x01;
int filter_header = data[1] & 0x06;
/*int interlaced = data[1] & 0x01; TODO: used in flv ever? */
- if (separated_coeff || !filter_header) {
+ if (separated_coeff || ! filter_header)
+ {
data += 2;
}
/* XXX encoded/displayed dimensions might vary, but which are the
* right ones? */
- stinfo->videoWidth = (data[3]*16) - (dim_adj>>4);
- stinfo->videoHeight = (data[2]*16) - (dim_adj&0x0F);
+ stinfo->videoWidth = (data[3] * 16) - (dim_adj >> 4);
+ stinfo->videoHeight = (data[2] * 16) - (dim_adj & 0x0F);
}
break;
}
- default:
- break;
+ default:
+ break;
}
stinfo->videoCodec = codecId;
- if (stinfo->videoCodecStr != NULL) {
- free(stinfo->videoCodecStr);
+ if (stinfo->videoCodecStr != NULL)
+ {
+ free (stinfo->videoCodecStr);
stinfo->videoCodecStr = NULL;
}
}
-static int readFLVTag(const unsigned char **data,
- const unsigned char *end,
- FLVStreamInfo *stinfo,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls)
+
+static int
+readFLVTag (const unsigned char **data,
+ const unsigned char *end,
+ FLVStreamInfo *stinfo,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
const unsigned char *ptr = *data;
FLVTagHeader header;
int ret = 0;
- if (readFLVTagHeader(&ptr, end, &header) == -1)
+ if (readFLVTagHeader (&ptr, end, &header) == -1)
return -1;
if ((ptr + header.bodyLength) > end)
@@ -1006,17 +1071,17 @@ static int readFLVTag(const unsigned char **data,
switch (header.type)
{
- case FLV_TAG_TYPE_AUDIO:
- handleAudioBody(ptr, header.bodyLength, stinfo);
- break;
- case FLV_TAG_TYPE_VIDEO:
- handleVideoBody(ptr, header.bodyLength, stinfo);
- break;
- case FLV_TAG_TYPE_META:
- ret = handleMetaBody(ptr, header.bodyLength, stinfo, proc, proc_cls);
- break;
- default:
- break;
+ case FLV_TAG_TYPE_AUDIO:
+ handleAudioBody (ptr, header.bodyLength, stinfo);
+ break;
+ case FLV_TAG_TYPE_VIDEO:
+ handleVideoBody (ptr, header.bodyLength, stinfo);
+ break;
+ case FLV_TAG_TYPE_META:
+ ret = handleMetaBody (ptr, header.bodyLength, stinfo, proc, proc_cls);
+ break;
+ default:
+ break;
}
ptr += header.bodyLength;
@@ -1024,129 +1089,149 @@ static int readFLVTag(const unsigned char **data,
return ret;
}
+
#define MAX_FLV_FORMAT_LINE 80
-static char * printVideoFormat(FLVStreamInfo *stinfo)
+static char *
+printVideoFormat (FLVStreamInfo *stinfo)
{
- char s[MAX_FLV_FORMAT_LINE+1];
+ char s[MAX_FLV_FORMAT_LINE + 1];
int n;
size_t len = MAX_FLV_FORMAT_LINE;
n = 0;
/* some files seem to specify only the width or the height, print '?' for
* the unknown dimension */
- if (stinfo->videoWidth != -1 || stinfo->videoHeight != -1) {
- if (n < len) {
+ if ((stinfo->videoWidth != -1) || (stinfo->videoHeight != -1))
+ {
+ if (n < len)
+ {
if (stinfo->videoWidth != -1)
- n += snprintf(s+n, len-n, "%d", stinfo->videoWidth);
+ n += snprintf (s + n, len - n, "%d", stinfo->videoWidth);
else
- n += snprintf(s+n, len-n, "?");
+ n += snprintf (s + n, len - n, "?");
}
- if (n < len) {
+ if (n < len)
+ {
if (stinfo->videoHeight != -1)
- n += snprintf(s+n, len-n, "x%d", stinfo->videoHeight);
+ n += snprintf (s + n, len - n, "x%d", stinfo->videoHeight);
else
- n += snprintf(s+n, len-n, "x?");
+ n += snprintf (s + n, len - n, "x?");
}
}
- if (stinfo->videoFrameRate != 0.0 && n < len) {
+ if ((stinfo->videoFrameRate != 0.0) && (n < len))
+ {
if (n > 0)
- n += snprintf(s+n, len-n, ", ");
+ n += snprintf (s + n, len - n, ", ");
if (n < len)
- n += snprintf(s+n, len-n, "%0.2f fps", stinfo->videoFrameRate);
+ n += snprintf (s + n, len - n, "%0.2f fps", stinfo->videoFrameRate);
}
- if (stinfo->videoCodec > -1 && stinfo->videoCodec < 8 &&
- FLVVideoCodecs[stinfo->videoCodec] != NULL && n < len) {
+ if ((stinfo->videoCodec > -1) && (stinfo->videoCodec < 8) &&
+ (FLVVideoCodecs[stinfo->videoCodec] != NULL) && (n < len) )
+ {
if (n > 0)
- n += snprintf(s+n, len-n, ", ");
+ n += snprintf (s + n, len - n, ", ");
if (n < len)
- n += snprintf(s+n, len-n, "%s", FLVVideoCodecs[stinfo->videoCodec]);
+ n += snprintf (s + n, len - n, "%s", FLVVideoCodecs[stinfo->videoCodec]);
}
- else if (stinfo->videoCodecStr != NULL && n < len) {
+ else if ((stinfo->videoCodecStr != NULL) && (n < len))
+ {
if (n > 0)
- n += snprintf(s+n, len-n, ", ");
+ n += snprintf (s + n, len - n, ", ");
if (n < len)
- n += snprintf(s+n, len-n, "%s", stinfo->videoCodecStr);
+ n += snprintf (s + n, len - n, "%s", stinfo->videoCodecStr);
}
- if (stinfo->videoDataRate != 0.0 && n < len) {
+ if ((stinfo->videoDataRate != 0.0) && (n < len))
+ {
if (n > 0)
- n += snprintf(s+n, len-n, ", ");
+ n += snprintf (s + n, len - n, ", ");
if (n < len)
- n += snprintf(s+n, len-n, "%.4f kbps", stinfo->videoDataRate);
+ n += snprintf (s + n, len - n, "%.4f kbps", stinfo->videoDataRate);
}
if (n == 0)
return NULL;
- return strdup(s);
+ return strdup (s);
}
-static char * printAudioFormat(FLVStreamInfo *stinfo)
+
+static char *
+printAudioFormat (FLVStreamInfo *stinfo)
{
- char s[MAX_FLV_FORMAT_LINE+1];
+ char s[MAX_FLV_FORMAT_LINE + 1];
int n;
size_t len = MAX_FLV_FORMAT_LINE;
n = 0;
- if ( (stinfo->audioRate != -1) && (n < len)) {
- n += snprintf(s+n, len-n, "%s Hz", FLVAudioSampleRates[stinfo->audioRate]);
+ if ( (stinfo->audioRate != -1) && (n < len))
+ {
+ n += snprintf (s + n, len - n, "%s Hz",
+ FLVAudioSampleRates[stinfo->audioRate]);
}
- if ((stinfo->audioSampleBits != -1) && (n < len)) {
+ if ((stinfo->audioSampleBits != -1) && (n < len))
+ {
if (n > 0)
- n += snprintf(s+n, len-n, ", ");
+ n += snprintf (s + n, len - n, ", ");
if (n < len)
- n += snprintf(s+n, len-n, "%s",
- FLVAudioSampleSizes[stinfo->audioSampleBits]);
+ n += snprintf (s + n, len - n, "%s",
+ FLVAudioSampleSizes[stinfo->audioSampleBits]);
}
- if ((stinfo->audioChannels != -1) && (n < len)) {
+ if ((stinfo->audioChannels != -1) && (n < len))
+ {
if (n > 0)
- n += snprintf(s+n, len-n, ", ");
- if (n < len) {
- if (stinfo->audioChannels >= 1 && stinfo->audioChannels <= 2)
- n += snprintf(s+n, len-n, "%s",
- FLVAudioChannels[stinfo->audioChannels-1]);
+ n += snprintf (s + n, len - n, ", ");
+ if (n < len)
+ {
+ if ((stinfo->audioChannels >= 1) && (stinfo->audioChannels <= 2))
+ n += snprintf (s + n, len - n, "%s",
+ FLVAudioChannels[stinfo->audioChannels - 1]);
else
- n += snprintf(s+n, len-n, "%d",
- stinfo->audioChannels);
+ n += snprintf (s + n, len - n, "%d",
+ stinfo->audioChannels);
}
}
if ((stinfo->audioCodec > -1) && (stinfo->audioCodec < 12) &&
- (FLVAudioCodecs[stinfo->audioCodec] != NULL) && (n < len)) {
+ (FLVAudioCodecs[stinfo->audioCodec] != NULL) && (n < len))
+ {
if (n > 0)
- n += snprintf(s+n, len-n, ", ");
+ n += snprintf (s + n, len - n, ", ");
if (n < len)
- n += snprintf(s+n, len-n, "%s", FLVAudioCodecs[stinfo->audioCodec]);
+ n += snprintf (s + n, len - n, "%s", FLVAudioCodecs[stinfo->audioCodec]);
}
- else if ((stinfo->audioCodecStr != NULL) && (n < len)) {
+ else if ((stinfo->audioCodecStr != NULL) && (n < len))
+ {
if (n > 0)
- n += snprintf(s+n, len-n, ", ");
+ n += snprintf (s + n, len - n, ", ");
if (n < len)
- n += snprintf(s+n, len-n, "%s", stinfo->audioCodecStr);
+ n += snprintf (s + n, len - n, "%s", stinfo->audioCodecStr);
}
- if ((stinfo->audioDataRate != 0.0) && (n < len)) {
+ if ((stinfo->audioDataRate != 0.0) && (n < len))
+ {
if (n > 0)
- n += snprintf(s+n, len-n, ", ");
+ n += snprintf (s + n, len - n, ", ");
if (n < len)
- n += snprintf(s+n, len-n, "%.4f kbps", stinfo->audioDataRate);
+ n += snprintf (s + n, len - n, "%.4f kbps", stinfo->audioDataRate);
}
if (n == 0)
return NULL;
- return strdup(s);
+ return strdup (s);
}
-int
+
+int
EXTRACTOR_flv_extract (const unsigned char *data,
- size_t size,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls,
- const char *options)
+ size_t size,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls,
+ const char *options)
{
const unsigned char *ptr;
const unsigned char *end;
@@ -1159,19 +1244,19 @@ EXTRACTOR_flv_extract (const unsigned char *data,
ptr = data;
end = ptr + size;
- if (readFLVHeader(&ptr, end, &header) == -1)
+ if (readFLVHeader (&ptr, end, &header) == -1)
return 0;
- if (memcmp(header.signature, FLV_SIGNATURE, 3) != 0)
+ if (memcmp (header.signature, FLV_SIGNATURE, 3) != 0)
return 0;
if (0 != proc (proc_cls,
- "flv",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "video/x-flv",
- strlen ("video/x-flv") + 1))
+ "flv",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "video/x-flv",
+ strlen ("video/x-flv") + 1))
return 0;
if (header.version != 1)
return 0;
@@ -1191,7 +1276,8 @@ EXTRACTOR_flv_extract (const unsigned char *data,
stinfo.audioChannels = -1;
stinfo.audioDataRate = 0.0;
ret = 0;
- while (ptr < end) {
+ while (ptr < end)
+ {
if (-1 == (ret = readFLVTag (&ptr, end, &stinfo, proc, proc_cls)))
break;
if (readPreviousTagSize (&ptr, end, &prev_tag_size) == -1)
@@ -1201,35 +1287,35 @@ EXTRACTOR_flv_extract (const unsigned char *data,
return 1;
s = printVideoFormat (&stinfo);
if (s != NULL)
+ {
+ if (0 != proc (proc_cls,
+ "flv",
+ EXTRACTOR_METATYPE_RESOURCE_TYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ s,
+ strlen (s) + 1))
{
- if (0 != proc (proc_cls,
- "flv",
- EXTRACTOR_METATYPE_RESOURCE_TYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- s,
- strlen (s)+1))
- {
- free (s);
- return 1;
- }
free (s);
+ return 1;
}
+ free (s);
+ }
s = printAudioFormat (&stinfo);
if (s != NULL)
+ {
+ if (0 != proc (proc_cls,
+ "flv",
+ EXTRACTOR_METATYPE_RESOURCE_TYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ s,
+ strlen (s) + 1))
{
- if (0 != proc (proc_cls,
- "flv",
- EXTRACTOR_METATYPE_RESOURCE_TYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- s,
- strlen (s)+1))
- {
- free (s);
- return 1;
- }
free (s);
+ return 1;
}
+ free (s);
+ }
return 0;
}
diff --git a/src/plugins/old/mkv_extractor.c b/src/plugins/old/mkv_extractor.c
@@ -18,17 +18,21 @@
Boston, MA 02110-1301, USA.
*/
- /*
- * Made by Gabriel Peixoto
- * Using AVInfo 1.x code. Copyright (c) 2004 George Shuklin.
- *
- */
+/*
+ * Made by Gabriel Peixoto
+ * Using AVInfo 1.x code. Copyright (c) 2004 George Shuklin.
+ *
+ */
#include "platform.h"
#include "extractor.h"
#include <stdint.h>
-#define ADD(s,t) do { if (0 != (ret = proc (proc_cls, "mkv", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen(s)+1))) goto EXIT; } while (0)
+#define ADD(s,t) do { if (0 != (ret = proc (proc_cls, "mkv", t, \
+ EXTRACTOR_METAFORMAT_UTF8, \
+ "text/plain", s, strlen (s) \
+ + 1))) goto EXIT; \
+} while (0)
/**
* FIXME: document
@@ -98,27 +102,29 @@ enum
*/
static size_t
VINTparse (const unsigned char *buffer, size_t start, size_t end,
- int64_t * result, int flag)
+ int64_t *result, int flag)
{
- static const unsigned char mask[8] = { 0x80, 0x40, 0x20, 0x10, 0x8, 0x4, 0x2, 0x1 };
- static const unsigned char imask[8] = { 0x7F, 0x3F, 0x1F, 0xF, 0x7, 0x3, 0x1, 00 };
+ static const unsigned char mask[8] = { 0x80, 0x40, 0x20, 0x10, 0x8, 0x4, 0x2,
+ 0x1 };
+ static const unsigned char imask[8] = { 0x7F, 0x3F, 0x1F, 0xF, 0x7, 0x3, 0x1,
+ 00 };
int vint_width;
unsigned int c;
int64_t temp;
unsigned char tempc;
- if (end - start < 2)
- return 0; /*ops */
-
+ if (end - start < 2)
+ return 0; /*ops */
+
vint_width = 0;
for (c = 0; c < 8; c++)
- if (!(buffer[start] & mask[c]))
+ if (! (buffer[start] & mask[c]))
vint_width++;
else
break;
if ( (vint_width >= 8) || (vint_width + start + 1 >= end) )
return 0;
-
+
*result = 0;
for (c = 0; c < vint_width; c++)
{
@@ -139,7 +145,7 @@ VINTparse (const unsigned char *buffer, size_t start, size_t end,
*/
static unsigned int
elementRead (const unsigned char *buffer, size_t start, size_t end,
- uint32_t *id, int64_t * size)
+ uint32_t *id, int64_t *size)
{
int64_t tempID;
int64_t tempsize;
@@ -147,12 +153,12 @@ elementRead (const unsigned char *buffer, size_t start, size_t end,
size_t size_offset;
tempID = 0;
-
+
id_offset = VINTparse (buffer, start, end, &tempID, 0);
- if (!id_offset)
+ if (! id_offset)
return 0;
size_offset = VINTparse (buffer, start + id_offset, end, &tempsize, 1);
- if (!size_offset)
+ if (! size_offset)
return 0;
*id = (uint32_t) tempID;
*size = tempsize;
@@ -172,10 +178,11 @@ getInt (const unsigned char *buffer, size_t start, size_t size)
result = 0;
for (c = 1; c <= size; c++)
- result += ((uint64_t)buffer[start + c - 1]) << (8 * (size - c));
+ result += ((uint64_t) buffer[start + c - 1]) << (8 * (size - c));
return result;
}
+
static float
getFloat (const unsigned char *buffer, size_t start, size_t size)
{
@@ -194,7 +201,8 @@ getFloat (const unsigned char *buffer, size_t start, size_t size)
return 0.0;
}
-static const unsigned int MKV_Parse_list[] = {
+
+static const unsigned int MKV_Parse_list[] = {
/*Elements, containing requed information (sub-elements), see enum in mkv.h for values */
MKVID_Segment,
MKVID_Info,
@@ -244,14 +252,14 @@ EXTRACTOR_mkv_extract (const unsigned char *data, size_t size,
if (NULL == start)
return 0;
p = start - data;
-
+
/*main loop*/
ret = 0;
do
{
offs = elementRead (data, p, size, &eID, &eSize);
p += offs;
- if (!offs || p >= size)
+ if (! offs || (p >= size))
break;
if (MKVID_EBML == eID)
{
@@ -262,8 +270,8 @@ EXTRACTOR_mkv_extract (const unsigned char *data, size_t size,
if (! is_mkv)
return 0;
for (c = 0; c < sizeof (MKV_Parse_list) / sizeof (*MKV_Parse_list); c++)
- if (MKV_Parse_list[c] == eID)
- break;
+ if (MKV_Parse_list[c] == eID)
+ break;
if (c < sizeof (MKV_Parse_list) / sizeof (*MKV_Parse_list))
continue;
@@ -272,7 +280,7 @@ EXTRACTOR_mkv_extract (const unsigned char *data, size_t size,
if ( (eSize == 4) || (eSize == 8) || (eSize == 1) || (eSize == 2))
value = getInt (data, p, eSize);
-
+
switch (eID)
{
case MKVID_TrackType: /*detect a stream type (video/audio/text) */
@@ -286,9 +294,9 @@ EXTRACTOR_mkv_extract (const unsigned char *data, size_t size,
have_audio = 1;
break;
case MKV_Track_subtitle:
- break;
+ break;
case MKV_Track_subtitle_orig:
- break;
+ break;
}
break;
case MKVID_DefaultDuration:
@@ -298,11 +306,11 @@ EXTRACTOR_mkv_extract (const unsigned char *data, size_t size,
fps = 0;
break;
case MKVID_Language:
- snprintf (buffer,
- sizeof (buffer),
- "%.*s",
- (int) eSize,
- data + p);
+ snprintf (buffer,
+ sizeof (buffer),
+ "%.*s",
+ (int) eSize,
+ data + p);
ADD (buffer, EXTRACTOR_METATYPE_LANGUAGE);
break;
case MKVID_CodecName:
@@ -340,10 +348,10 @@ EXTRACTOR_mkv_extract (const unsigned char *data, size_t size,
if (eSize > MAX_STRING_SIZE)
break;
snprintf (buffer,
- sizeof (buffer),
- "%.*s",
- (int) eSize,
- (const char*) data + p);
+ sizeof (buffer),
+ "%.*s",
+ (int) eSize,
+ (const char*) data + p);
ADD (buffer, EXTRACTOR_METATYPE_TITLE);
break;
default:
@@ -354,20 +362,20 @@ EXTRACTOR_mkv_extract (const unsigned char *data, size_t size,
while (1);
snprintf (buffer,
- sizeof (buffer),
- "%u s (%s%s%s)",
- (unsigned int) (duration / 1e+9 * (float) timescale),
- (have_audio ? "audio" : ""),
- ((have_audio && have_video) ? "/" : ""),
- (have_video ? "video" : ""));
+ sizeof (buffer),
+ "%u s (%s%s%s)",
+ (unsigned int) (duration / 1e+9 * (float) timescale),
+ (have_audio ? "audio" : ""),
+ ((have_audio && have_video) ? "/" : ""),
+ (have_video ? "video" : ""));
if ( (have_audio || have_video) && (duration >= 0.0) )
ADD (buffer, EXTRACTOR_METATYPE_DURATION);
- if ( (value_width != 0) && (value_height != 0) )
+ if ( (value_width != 0) && (value_height != 0) )
{
snprintf (buffer,
- sizeof(buffer),
- "%ux%u",
- value_width, value_height);
+ sizeof(buffer),
+ "%ux%u",
+ value_width, value_height);
ADD (buffer, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS);
}
@@ -375,34 +383,34 @@ EXTRACTOR_mkv_extract (const unsigned char *data, size_t size,
{
if ( (fps != 0) && (bit_depth != 0) )
snprintf (buffer,
- sizeof (buffer),
- "%.*s (%u fps, %u bit)",
- codec_strlen,
- codec,
- fps,
- bit_depth);
+ sizeof (buffer),
+ "%.*s (%u fps, %u bit)",
+ codec_strlen,
+ codec,
+ fps,
+ bit_depth);
else if (fps != 0)
snprintf (buffer,
- sizeof (buffer),
- "%.*s (%u fps)",
- codec_strlen,
- codec,
- fps);
+ sizeof (buffer),
+ "%.*s (%u fps)",
+ codec_strlen,
+ codec,
+ fps);
else if (bit_depth != 0)
snprintf (buffer,
- sizeof (buffer),
- "%.*s (%u bit)",
- codec_strlen,
- codec,
- bit_depth);
+ sizeof (buffer),
+ "%.*s (%u bit)",
+ codec_strlen,
+ codec,
+ bit_depth);
else
snprintf (buffer,
- sizeof (buffer),
- "%.*s",
- codec_strlen,
- codec);
- ADD (buffer,
- EXTRACTOR_METATYPE_FORMAT);
+ sizeof (buffer),
+ "%.*s",
+ codec_strlen,
+ codec);
+ ADD (buffer,
+ EXTRACTOR_METATYPE_FORMAT);
}
EXIT:
return ret;
diff --git a/src/plugins/old/mp3_extractor.c b/src/plugins/old/mp3_extractor.c
@@ -91,21 +91,21 @@ static const int freq_table[4][3] = {
{48000, 24000, 12000},
{32000, 16000, 8000}
};
-static const char * const channel_modes[4] = {
- gettext_noop("stereo"),
- gettext_noop("joint stereo"),
- gettext_noop("dual channel"),
- gettext_noop("mono")
+static const char *const channel_modes[4] = {
+ gettext_noop ("stereo"),
+ gettext_noop ("joint stereo"),
+ gettext_noop ("dual channel"),
+ gettext_noop ("mono")
};
-static const char * const mpeg_versions[3] = {
- gettext_noop("MPEG-1"),
- gettext_noop("MPEG-2"),
- gettext_noop("MPEG-2.5")
+static const char *const mpeg_versions[3] = {
+ gettext_noop ("MPEG-1"),
+ gettext_noop ("MPEG-2"),
+ gettext_noop ("MPEG-2.5")
};
-static const char * const layer_names[3] = {
- gettext_noop("Layer I"),
- gettext_noop("Layer II"),
- gettext_noop("Layer III")
+static const char *const layer_names[3] = {
+ gettext_noop ("Layer I"),
+ gettext_noop ("Layer II"),
+ gettext_noop ("Layer III")
};
@@ -113,7 +113,10 @@ static const char * const layer_names[3] = {
#define SYSERR 1
#define INVALID_ID3 2
-#define ADDR(s,t) do { if (0 != proc (proc_cls, "mp3", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen(s)+1)) return 1; } while (0)
+#define ADDR(s,t) do { if (0 != proc (proc_cls, "mp3", t, \
+ EXTRACTOR_METAFORMAT_UTF8, "text/plain", \
+ s, strlen (s) + 1)) return 1; \
+} while (0)
struct mp3_state
{
@@ -163,6 +166,7 @@ EXTRACTOR_mp3_init_state_method ()
return state;
}
+
static int
EXTRACTOR_mp3_discard_state_method (struct mp3_state *state)
{
@@ -173,51 +177,58 @@ EXTRACTOR_mp3_discard_state_method (struct mp3_state *state)
return 1;
}
+
static int
-calculate_frame_statistics_and_maybe_report_it (struct EXTRACTOR_PluginList *plugin,
- struct mp3_state *state, EXTRACTOR_MetaDataProcessor proc, void *proc_cls)
+calculate_frame_statistics_and_maybe_report_it (struct
+ EXTRACTOR_PluginList *plugin,
+ struct mp3_state *state,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
int length;
char format[512];
- if (((double) state->number_of_valid_frames / (double) state->number_of_frames) < 0.8 ||
- state->number_of_valid_frames <= 2)
+ if ((((double) state->number_of_valid_frames
+ / (double) state->number_of_frames) < 0.8) ||
+ (state->number_of_valid_frames <= 2) )
/* Unlikely to be an mp3 file */
return 0;
ADDR ("audio/mpeg", EXTRACTOR_METATYPE_MIMETYPE);
state->avg_bps = state->avg_bps / state->number_of_valid_frames;
if (state->sample_rate > 0)
length = 1152 * state->number_of_valid_frames / state->sample_rate;
- else if (state->avg_bps > 0 || state->bitrate > 0)
- length = plugin->fsize / (state->avg_bps ? state->avg_bps : state->bitrate ? state->bitrate : 1) / 125;
+ else if ((state->avg_bps > 0) || (state->bitrate > 0))
+ length = plugin->fsize / (state->avg_bps ? state->avg_bps : state->bitrate ?
+ state->bitrate : 1) / 125;
else
length = 0;
ADDR (mpeg_versions[state->mpeg_ver - 1], EXTRACTOR_METATYPE_FORMAT_VERSION);
snprintf (format,
- sizeof (format),
- "%s %s audio, %d kbps (%s), %d Hz, %s, %s, %s",
+ sizeof (format),
+ "%s %s audio, %d kbps (%s), %d Hz, %s, %s, %s",
mpeg_versions[state->mpeg_ver - 1],
layer_names[state->layer - 1],
state->avg_bps,
- state->vbr_flag ? _("VBR") : _("CBR"),
+ state->vbr_flag ? _ ("VBR") : _ ("CBR"),
state->sample_rate,
channel_modes[state->ch],
- state->copyright_flag ? _("copyright") : _("no copyright"),
- state->original_flag ? _("original") : _("copy") );
+ state->copyright_flag ? _ ("copyright") : _ ("no copyright"),
+ state->original_flag ? _ ("original") : _ ("copy") );
ADDR (format, EXTRACTOR_METATYPE_RESOURCE_TYPE);
snprintf (format,
- sizeof (format), "%dm%02d",
+ sizeof (format), "%dm%02d",
length / 60, length % 60);
ADDR (format, EXTRACTOR_METATYPE_DURATION);
return 0;
}
+
int
EXTRACTOR_mp3_extract_method (struct EXTRACTOR_PluginList *plugin,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls)
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
int64_t offset = 0;
int64_t round_offset;
@@ -255,24 +266,29 @@ EXTRACTOR_mp3_extract_method (struct EXTRACTOR_PluginList *plugin,
while (1)
{
pl_seek (plugin, offset, SEEK_SET);
- read_result = pl_read (plugin, &data, 1024*1024);
+ read_result = pl_read (plugin, &data, 1024 * 1024);
if (read_result < 4)
{
- calculate_frame_statistics_and_maybe_report_it (plugin, state, proc, proc_cls);
+ calculate_frame_statistics_and_maybe_report_it (plugin, state, proc,
+ proc_cls);
return EXTRACTOR_mp3_discard_state_method (state);
}
for (i = 0; i + 3 < read_result; i++)
- if (((*((uint32_t *) &data[i])) & MPA_SYNC_MASK_MEM) == MPA_SYNC_MASK_MEM)
+ if (((*((uint32_t *) &data[i])) & MPA_SYNC_MASK_MEM) ==
+ MPA_SYNC_MASK_MEM)
break;
- if (i + 3 >= 1024*1024)
+ if (i + 3 >= 1024 * 1024)
offset += read_result - 3;
else
break;
- if (offset > round_offset + 31*1024*1024)
+ if (offset > round_offset + 31 * 1024 * 1024)
{
- if (((state->number_of_valid_frames > 2) && ((double) state->number_of_valid_frames / (double) state->number_of_frames) < 0.8))
+ if (((state->number_of_valid_frames > 2) &&
+ ( ((double) state->number_of_valid_frames
+ / (double) state->number_of_frames) < 0.8) ))
{
- calculate_frame_statistics_and_maybe_report_it (plugin, state, proc, proc_cls);
+ calculate_frame_statistics_and_maybe_report_it (plugin, state, proc,
+ proc_cls);
}
return EXTRACTOR_mp3_discard_state_method (state);
}
@@ -280,11 +296,12 @@ EXTRACTOR_mp3_extract_method (struct EXTRACTOR_PluginList *plugin,
pl_seek (plugin, offset + i, SEEK_SET);
if (4 != pl_read (plugin, &data, 4))
{
- calculate_frame_statistics_and_maybe_report_it (plugin, state, proc, proc_cls);
+ calculate_frame_statistics_and_maybe_report_it (plugin, state, proc,
+ proc_cls);
return EXTRACTOR_mp3_discard_state_method (state);
}
- state->header = (data[0] << 24) | (data[1] << 16) |
- (data[2] << 8) | data[3];
+ state->header = (data[0] << 24) | (data[1] << 16)
+ | (data[2] << 8) | data[3];
if ((state->header & MPA_SYNC_MASK) == MPA_SYNC_MASK)
{
state->state = MP3_READING_FRAME;
@@ -336,8 +353,8 @@ EXTRACTOR_mp3_extract_method (struct EXTRACTOR_PluginList *plugin,
idx_num = (mpeg_ver - 1) * 3 + layer - 1;
else
idx_num = 2 + layer;
- bitrate = 1000 * bitrate_table[(state->header >> MPA_BITRATE_SHIFT) &
- MPA_BITRATE_MASK][idx_num];
+ bitrate = 1000 * bitrate_table[(state->header >> MPA_BITRATE_SHIFT)
+ & MPA_BITRATE_MASK][idx_num];
if (bitrate < 0)
{
/*error in header */
@@ -345,8 +362,8 @@ EXTRACTOR_mp3_extract_method (struct EXTRACTOR_PluginList *plugin,
offset += 1;
break;
}
- sample_rate = freq_table[(state->header >> MPA_FREQ_SHIFT) &
- MPA_FREQ_MASK][mpeg_ver - 1];
+ sample_rate = freq_table[(state->header >> MPA_FREQ_SHIFT)
+ & MPA_FREQ_MASK][mpeg_ver - 1];
if (sample_rate <= 0)
{
/*error in header */
@@ -358,9 +375,13 @@ EXTRACTOR_mp3_extract_method (struct EXTRACTOR_PluginList *plugin,
copyright_flag = (state->header >> MPA_COPYRIGHT_SHIFT) & 0x1;
original_flag = (state->header >> MPA_ORIGINAL_SHIFT) & 0x1;
if (layer == LAYER_1)
- frame_size = (12 * bitrate / sample_rate + ((state->header >> MPA_PADDING_SHIFT) & 0x1)) * 4;
+ frame_size = (12 * bitrate / sample_rate + ((state->header
+ >> MPA_PADDING_SHIFT)
+ & 0x1)) * 4;
else
- frame_size = 144 * bitrate / sample_rate + ((state->header >> MPA_PADDING_SHIFT) & 0x1);
+ frame_size = 144 * bitrate / sample_rate + ((state->header
+ >> MPA_PADDING_SHIFT)
+ & 0x1);
if (frame_size < 8)
{
/*error in header */
@@ -390,4 +411,5 @@ EXTRACTOR_mp3_extract_method (struct EXTRACTOR_PluginList *plugin,
return 1;
}
+
/* end of mp3_extractor.c */
diff --git a/src/plugins/old/pack.c b/src/plugins/old/pack.c
@@ -27,7 +27,7 @@ MODIFICATIONS.
#include "platform.h"
#include "pack.h"
-#if !(defined(_WIN32) && defined(cbNDRContext))
+#if ! (defined(_WIN32) && defined(cbNDRContext))
typedef unsigned char byte;
#endif
typedef unsigned short half;
@@ -37,11 +37,10 @@ typedef signed short shalf;
typedef signed int sword;
-
int
-EXTRACTOR_common_cat_unpack (const void *buf,
- const char *fmt,
- ...)
+EXTRACTOR_common_cat_unpack (const void *buf,
+ const char *fmt,
+ ...)
{
va_list ap;
word maxlen, len, *wordp;
@@ -63,283 +62,282 @@ EXTRACTOR_common_cat_unpack (const void *buf,
va_start (ap, fmt);
while (*fmt)
+ {
+ nreps = 1;
+
+ if (isdigit ( (unsigned char) *fmt))
{
- nreps = 1;
+ /* We use cp instead of format to keep the 'const' qualifier of fmt */
+ nreps = strtoul (fmt, &cp, 0);
+ fmt = cp;
+ if (*fmt == 'a')
+ isnonprefixed = 0;
+ }
- if (isdigit ( (unsigned char) *fmt))
+ switch (*fmt)
+ {
+ case 'B':
+ case 'b':
+ bytep = va_arg (ap, byte *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *bytep = *bp++;
+ ++bytep;
+ npacked += 1;
+ }
+ break;
+
+
+ case 'h':
+ halfp = va_arg (ap, half *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *halfp = *bp++;
+ *halfp |= *bp++ << 8;
+ ++halfp;
+ npacked += 2;
+ }
+ break;
+
+ case 'H':
+ halfp = va_arg (ap, half *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *halfp = *bp++ << 8;
+ *halfp |= *bp++;
+ ++halfp;
+ npacked += 2;
+ }
+ break;
+
+
+ case 'w':
+ wordp = va_arg (ap, word *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *wordp = *bp++;
+ *wordp |= *bp++ << 8;
+ *wordp |= *bp++ << 16;
+ *wordp |= *bp++ << 24;
+ ++wordp;
+ npacked += 4;
+ }
+ break;
+
+ case 'x':
+ ll = va_arg (ap, long long *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *ll = ((long long) *bp++);
+ *ll |= ((long long) *bp++) << 8;
+ *ll |= ((long long) *bp++) << 16;
+ *ll |= ((long long) *bp++) << 24;
+ *ll |= ((long long) *bp++) << 32;
+ *ll |= ((long long) *bp++) << 40;
+ *ll |= ((long long) *bp++) << 48;
+ *ll |= ((long long) *bp++) << 56;
+ ++ll;
+ npacked += 8;
+ }
+ break;
+
+ case 'W':
+ wordp = va_arg (ap, word *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *wordp = *bp++ << 24;
+ *wordp |= *bp++ << 16;
+ *wordp |= *bp++ << 8;
+ *wordp |= *bp++;
+ ++wordp;
+ npacked += 4;
+ }
+ break;
+
+ case 'X':
+ ll = va_arg (ap, long long *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *ll = ((long long) *bp++) << 56;
+ *ll |= ((long long) *bp++) << 48;
+ *ll |= ((long long) *bp++) << 40;
+ *ll |= ((long long) *bp++) << 32;
+ *ll |= ((long long) *bp++) << 24;
+ *ll |= ((long long) *bp++) << 18;
+ *ll |= ((long long) *bp++) << 8;
+ *ll |= ((long long) *bp++);
+ ++ll;
+ npacked += 8;
+ }
+ break;
+
+
+ case 'A':
+ if (isnonprefixed)
+ {
+ maxlen = va_arg (ap, word);
+ arr = va_arg (ap, void *);
+
+ len = *bp++ << 24;
+ len |= *bp++ << 16;
+ len |= *bp++ << 8;
+ len |= *bp++;
+
+ if (len > maxlen)
{
- /* We use cp instead of format to keep the 'const' qualifier of fmt */
- nreps = strtoul (fmt, &cp, 0);
- fmt = cp;
- if (*fmt == 'a')
- isnonprefixed = 0;
+ va_end (ap);
+ return -1;
}
- switch (*fmt)
+ memmove (arr, bp, len);
+ bp += len;
+
+ npacked += len;
+ }
+ else
+ {
+ cbvp = va_arg (ap, struct cat_bvec *);
+ for (i = 0; i < nreps; ++i)
+ {
+ maxlen = cbvp->len;
+ arr = cbvp->data;
+
+ len = *bp++ << 24;
+ len |= *bp++ << 16;
+ len |= *bp++ << 8;
+ len |= *bp++;
+
+ if (len > maxlen)
+ return -1;
+
+ memmove (arr, bp, len);
+ cbvp->len = len;
+ bp += len;
+
+ ++cbvp;
+ npacked += len;
+ }
+ isnonprefixed = 1;
+ }
+ break;
+
+ case 'C':
+ case 'c':
+ sbytep = va_arg (ap, sbyte *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *sbytep = *bp++;
+
+ if ((sizeof (sbyte) > 1) && (*sbytep & 0x80))
+ *sbytep |= (~0) << ((sizeof (sbyte) - 1) * 8);
+
+ ++sbytep;
+ npacked += 1;
+ }
+ break;
+
+
+ case 's':
+ shalfp = va_arg (ap, shalf *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *shalfp = *bp++;
+ *shalfp |= *bp++ << 8;
+
+ if ((sizeof (shalf) > 2) && (*shalfp & 0x8000))
+ *shalfp |= (~0) << ((sizeof (shalf) - 2) * 8);
+
+ ++shalfp;
+ npacked += 2;
+ }
+ break;
+
+ case 'S':
+ shalfp = va_arg (ap, shalf *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *shalfp = *bp++ << 8;
+ *shalfp |= *bp++;
+
+ if ((sizeof (shalf) > 2) && (*shalfp & 0x8000))
+ *shalfp |= (~0) << ((sizeof (shalf) - 2) * 8);
+
+ ++shalfp;
+ npacked += 2;
+ }
+ break;
+
+ case 'l':
+ swordp = va_arg (ap, sword *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *swordp = *bp++;
+ *swordp |= *bp++ << 8;
+ *swordp |= *bp++ << 16;
+ *swordp |= *bp++ << 24;
+
+ if ((sizeof (swordp) > 4) && (*swordp & 0x80000000))
+ *swordp |= (~0) << ((sizeof (sword) - 4) * 8);
+
+ ++swordp;
+ npacked += 4;
+ }
+ break;
+
+ case 'L':
+ swordp = va_arg (ap, sword *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *swordp = *bp++ << 24;
+ *swordp |= *bp++ << 16;
+ *swordp |= *bp++ << 8;
+ *swordp |= *bp++;
+
+ if ((sizeof (swordp) > 4) && (*swordp & 0x80000000))
+ *swordp |= (~0) << ((sizeof (sword) - 4) * 8);
+
+ ++swordp;
+ npacked += 4;
+ }
+ break;
+
+ case 'P':
+ cbvp = va_arg (ap, struct cat_bvec *);
+ for (i = 0; i < nreps; ++i)
+ {
+ len = *bp++ << 24;
+ len |= *bp++ << 16;
+ len |= *bp++ << 8;
+ len |= *bp++;
+
+ newbuf = (byte *) malloc (len);
+
+ if (! newbuf)
{
- case 'B':
- case 'b':
- bytep = va_arg (ap, byte *);
- for (i = 0; i < nreps; ++i)
- {
- *bytep = *bp++;
- ++bytep;
- npacked += 1;
- }
- break;
-
-
-
- case 'h':
- halfp = va_arg (ap, half *);
- for (i = 0; i < nreps; ++i)
- {
- *halfp = *bp++;
- *halfp |= *bp++ << 8;
- ++halfp;
- npacked += 2;
- }
- break;
-
- case 'H':
- halfp = va_arg (ap, half *);
- for (i = 0; i < nreps; ++i)
- {
- *halfp = *bp++ << 8;
- *halfp |= *bp++;
- ++halfp;
- npacked += 2;
- }
- break;
-
-
- case 'w':
- wordp = va_arg (ap, word *);
- for (i = 0; i < nreps; ++i)
- {
- *wordp = *bp++;
- *wordp |= *bp++ << 8;
- *wordp |= *bp++ << 16;
- *wordp |= *bp++ << 24;
- ++wordp;
- npacked += 4;
- }
- break;
-
- case 'x':
- ll = va_arg (ap, long long *);
- for (i = 0; i < nreps; ++i)
- {
- *ll = ((long long) *bp++);
- *ll |= ((long long) *bp++) << 8;
- *ll |= ((long long) *bp++) << 16;
- *ll |= ((long long) *bp++) << 24;
- *ll |= ((long long) *bp++) << 32;
- *ll |= ((long long) *bp++) << 40;
- *ll |= ((long long) *bp++) << 48;
- *ll |= ((long long) *bp++) << 56;
- ++ll;
- npacked += 8;
- }
- break;
-
- case 'W':
- wordp = va_arg (ap, word *);
- for (i = 0; i < nreps; ++i)
- {
- *wordp = *bp++ << 24;
- *wordp |= *bp++ << 16;
- *wordp |= *bp++ << 8;
- *wordp |= *bp++;
- ++wordp;
- npacked += 4;
- }
- break;
-
- case 'X':
- ll = va_arg (ap, long long *);
- for (i = 0; i < nreps; ++i)
- {
- *ll = ((long long) *bp++) << 56;
- *ll |= ((long long) *bp++) << 48;
- *ll |= ((long long) *bp++) << 40;
- *ll |= ((long long) *bp++) << 32;
- *ll |= ((long long) *bp++) << 24;
- *ll |= ((long long) *bp++) << 18;
- *ll |= ((long long) *bp++) << 8;
- *ll |= ((long long) *bp++);
- ++ll;
- npacked += 8;
- }
- break;
-
-
- case 'A':
- if (isnonprefixed)
- {
- maxlen = va_arg (ap, word);
- arr = va_arg (ap, void *);
-
- len = *bp++ << 24;
- len |= *bp++ << 16;
- len |= *bp++ << 8;
- len |= *bp++;
-
- if (len > maxlen)
- {
- va_end (ap);
- return -1;
- }
-
- memmove (arr, bp, len);
- bp += len;
-
- npacked += len;
- }
- else
- {
- cbvp = va_arg (ap, struct cat_bvec *);
- for (i = 0; i < nreps; ++i)
- {
- maxlen = cbvp->len;
- arr = cbvp->data;
-
- len = *bp++ << 24;
- len |= *bp++ << 16;
- len |= *bp++ << 8;
- len |= *bp++;
-
- if (len > maxlen)
- return -1;
-
- memmove (arr, bp, len);
- cbvp->len = len;
- bp += len;
-
- ++cbvp;
- npacked += len;
- }
- isnonprefixed = 1;
- }
- break;
-
- case 'C':
- case 'c':
- sbytep = va_arg (ap, sbyte *);
- for (i = 0; i < nreps; ++i)
- {
- *sbytep = *bp++;
-
- if ((sizeof (sbyte) > 1) && (*sbytep & 0x80))
- *sbytep |= (~0) << ((sizeof (sbyte) - 1) * 8);
-
- ++sbytep;
- npacked += 1;
- }
- break;
-
-
- case 's':
- shalfp = va_arg (ap, shalf *);
- for (i = 0; i < nreps; ++i)
- {
- *shalfp = *bp++;
- *shalfp |= *bp++ << 8;
-
- if ((sizeof (shalf) > 2) && (*shalfp & 0x8000))
- *shalfp |= (~0) << ((sizeof (shalf) - 2) * 8);
-
- ++shalfp;
- npacked += 2;
- }
- break;
-
- case 'S':
- shalfp = va_arg (ap, shalf *);
- for (i = 0; i < nreps; ++i)
- {
- *shalfp = *bp++ << 8;
- *shalfp |= *bp++;
-
- if ((sizeof (shalf) > 2) && (*shalfp & 0x8000))
- *shalfp |= (~0) << ((sizeof (shalf) - 2) * 8);
-
- ++shalfp;
- npacked += 2;
- }
- break;
-
- case 'l':
- swordp = va_arg (ap, sword *);
- for (i = 0; i < nreps; ++i)
- {
- *swordp = *bp++;
- *swordp |= *bp++ << 8;
- *swordp |= *bp++ << 16;
- *swordp |= *bp++ << 24;
-
- if ((sizeof (swordp) > 4) && (*swordp & 0x80000000))
- *swordp |= (~0) << ((sizeof (sword) - 4) * 8);
-
- ++swordp;
- npacked += 4;
- }
- break;
-
- case 'L':
- swordp = va_arg (ap, sword *);
- for (i = 0; i < nreps; ++i)
- {
- *swordp = *bp++ << 24;
- *swordp |= *bp++ << 16;
- *swordp |= *bp++ << 8;
- *swordp |= *bp++;
-
- if ((sizeof (swordp) > 4) && (*swordp & 0x80000000))
- *swordp |= (~0) << ((sizeof (sword) - 4) * 8);
-
- ++swordp;
- npacked += 4;
- }
- break;
-
- case 'P':
- cbvp = va_arg (ap, struct cat_bvec *);
- for (i = 0; i < nreps; ++i)
- {
- len = *bp++ << 24;
- len |= *bp++ << 16;
- len |= *bp++ << 8;
- len |= *bp++;
-
- newbuf = (byte *) malloc (len);
-
- if (!newbuf)
- {
- int j;
- for (j = 0; j < i; j++)
- free (cbvp[i].data);
- va_end (ap);
- return -1;
- }
-
- memmove (newbuf, bp, len);
- cbvp[i].data = newbuf;
- cbvp[i].len = len;
-
- bp += len;
- npacked += len;
- }
- break;
-
- default:
+ int j;
+ for (j = 0; j < i; j++)
+ free (cbvp[i].data);
va_end (ap);
return -1;
}
- ++fmt;
+ memmove (newbuf, bp, len);
+ cbvp[i].data = newbuf;
+ cbvp[i].len = len;
+
+ bp += len;
+ npacked += len;
+ }
+ break;
+
+ default:
+ va_end (ap);
+ return -1;
}
+ ++fmt;
+ }
+
va_end (ap);
return 0;
}
diff --git a/src/plugins/old/pack.h b/src/plugins/old/pack.h
@@ -45,18 +45,16 @@ MODIFICATIONS.
p - (unpack only) value is a pointer to a pointer. Generate the buffer
to hold the data.
*/
-int
-EXTRACTOR_common_cat_unpack(const void * buf,
- const char *fmt,
- ...);
+int
+EXTRACTOR_common_cat_unpack (const void *buf,
+ const char *fmt,
+ ...);
-struct cat_bvec
+struct cat_bvec
{
unsigned long len;
- void * data;
+ void *data;
};
#endif /* __CAT_PACK_H */
-
-
diff --git a/src/plugins/old/qt_extractor.c b/src/plugins/old/qt_extractor.c
@@ -178,7 +178,7 @@ static const char *const genre_names[] = {
};
#define GENRE_NAME_COUNT \
- ((unsigned int)(sizeof genre_names / sizeof (const char *const)))
+ ((unsigned int) (sizeof genre_names / sizeof (const char *const)))
static const char *languages[] = {
@@ -299,7 +299,7 @@ typedef struct
const char *mime;
} C2M;
-/* see http://www.mp4ra.org/filetype.html
+/* see http://www.mp4ra.org/filetype.html
* http://www.ftyps.com/ */
static C2M ftMap[] = {
{"qt ", "video/quicktime"},
@@ -356,7 +356,7 @@ static CHE cHm[] = {
{"src", EXTRACTOR_METATYPE_CONTRIBUTOR_NAME},
{"prf", EXTRACTOR_METATYPE_PERFORMER },
{"prd", EXTRACTOR_METATYPE_PRODUCER},
- {"PRD", EXTRACTOR_METATYPE_PRODUCT_VERSION},
+ {"PRD", EXTRACTOR_METATYPE_PRODUCT_VERSION},
{"swr", EXTRACTOR_METATYPE_PRODUCED_BY_SOFTWARE},
{"isr", EXTRACTOR_METATYPE_ISRC},
{"wrt", EXTRACTOR_METATYPE_WRITER},
@@ -396,7 +396,7 @@ static ITTagConversionEntry it_to_extr_table[] = {
{"keyw", EXTRACTOR_METATYPE_KEYWORDS},
{"desc", EXTRACTOR_METATYPE_DESCRIPTION},
{"tvnn", EXTRACTOR_METATYPE_NETWORK_NAME},
- {"tvsh", EXTRACTOR_METATYPE_SHOW_NAME},
+ {"tvsh", EXTRACTOR_METATYPE_SHOW_NAME},
{"tven", EXTRACTOR_METATYPE_NETWORK_NAME},
{NULL, EXTRACTOR_METATYPE_RESERVED}
};
@@ -441,25 +441,26 @@ checkAtomValid (const char *buffer, size_t size, size_t pos)
return 0;
atom = (const Atom *) &buffer[pos];
if (ntohl (atom->size) == 1)
- {
- if ((pos + sizeof (LongAtom) > size) || (pos + sizeof (LongAtom) < pos))
- return 0;
- latom = (const LongAtom *) &buffer[pos];
- atomSize = ntohll (latom->size);
- if ((atomSize < sizeof (LongAtom)) ||
- (atomSize + pos > size) || (atomSize + pos < atomSize))
- return 0;
- }
+ {
+ if ((pos + sizeof (LongAtom) > size) || (pos + sizeof (LongAtom) < pos))
+ return 0;
+ latom = (const LongAtom *) &buffer[pos];
+ atomSize = ntohll (latom->size);
+ if ((atomSize < sizeof (LongAtom)) ||
+ (atomSize + pos > size) || (atomSize + pos < atomSize))
+ return 0;
+ }
else
- {
- atomSize = ntohl (atom->size);
- if ((atomSize < sizeof (Atom)) ||
- (atomSize + pos > size) || (atomSize + pos < atomSize))
- return 0;
- }
+ {
+ atomSize = ntohl (atom->size);
+ if ((atomSize < sizeof (Atom)) ||
+ (atomSize + pos > size) || (atomSize + pos < atomSize))
+ return 0;
+ }
return 1;
}
+
/**
* Assumes that checkAtomValid has already been called.
*/
@@ -470,13 +471,14 @@ getAtomSize (const char *buf)
const LongAtom *latom;
atom = (const Atom *) buf;
if (ntohl (atom->size) == 1)
- {
- latom = (const LongAtom *) buf;
- return ntohll (latom->size);
- }
+ {
+ latom = (const LongAtom *) buf;
+ return ntohll (latom->size);
+ }
return ntohl (atom->size);
}
+
/**
* Assumes that checkAtomValid has already been called.
*/
@@ -491,6 +493,7 @@ getAtomHeaderSize (const char *buf)
return sizeof (Atom);
}
+
struct ExtractContext
{
EXTRACTOR_MetaDataProcessor proc;
@@ -500,22 +503,21 @@ struct ExtractContext
static void
addKeyword (enum EXTRACTOR_MetaType type,
- const char *str,
- struct ExtractContext *ec)
+ const char *str,
+ struct ExtractContext *ec)
{
if (ec->ret != 0)
return;
ec->ret = ec->proc (ec->proc_cls,
- "qt",
- type,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- str,
- strlen(str)+1);
+ "qt",
+ type,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ str,
+ strlen (str) + 1);
}
-
/**
* Assumes that checkAtomValid has already been called.
*/
@@ -538,8 +540,8 @@ typedef struct
static int handleAtom (HandlerEntry *handlers,
const char *input,
size_t size,
- size_t pos,
- struct ExtractContext *ec);
+ size_t pos,
+ struct ExtractContext *ec);
static HandlerEntry all_handlers[];
static HandlerEntry ilst_handlers[];
@@ -550,7 +552,7 @@ static HandlerEntry ilst_handlers[];
*/
static int
processAtoms (HandlerEntry *handlers, const char *input,
- size_t size, struct ExtractContext *ec)
+ size_t size, struct ExtractContext *ec)
{
size_t pos;
@@ -558,14 +560,15 @@ processAtoms (HandlerEntry *handlers, const char *input,
return 1;
pos = 0;
while (pos < size - sizeof (Atom))
- {
- if (0 == handleAtom (handlers, input, size, pos, ec))
- return 0;
- pos += getAtomSize (&input[pos]);
- }
+ {
+ if (0 == handleAtom (handlers, input, size, pos, ec))
+ return 0;
+ pos += getAtomSize (&input[pos]);
+ }
return 1;
}
+
/**
* Process all atoms.
* @return 0 on error, 1 for success, -1 for unknown atom type
@@ -574,9 +577,10 @@ static int
processAllAtoms (const char *input,
size_t size, struct ExtractContext *ec)
{
- return processAtoms(all_handlers, input, size, ec);
+ return processAtoms (all_handlers, input, size, ec);
}
+
/**
* Handle the moov atom.
* @return 0 on error, 1 for success, -1 for unknown atom type
@@ -590,6 +594,7 @@ moovHandler (const char *input,
getAtomSize (&input[pos]) - hdr, ec);
}
+
/* see http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap1/chapter_2_section_5.html */
typedef struct
{
@@ -609,7 +614,8 @@ ftypHandler (const char *input,
const FileType *ft;
int i;
- if (getAtomSize (&input[pos]) < sizeof (FileType)) {
+ if (getAtomSize (&input[pos]) < sizeof (FileType))
+ {
return 0;
}
ft = (const FileType *) &input[pos];
@@ -622,6 +628,7 @@ ftypHandler (const char *input,
return 1;
}
+
typedef struct
{
Atom hdr;
@@ -662,13 +669,14 @@ mvhdHandler (const char *input,
return 0;
m = (const MovieHeaderAtom *) &input[pos];
snprintf (duration,
- sizeof(duration),
- "%us",
- ntohl (m->duration) / ntohl (m->timeScale));
+ sizeof(duration),
+ "%us",
+ ntohl (m->duration) / ntohl (m->timeScale));
addKeyword (EXTRACTOR_METATYPE_DURATION, duration, ec);
return 1;
}
+
typedef struct
{
Atom cmovAtom;
@@ -699,9 +707,9 @@ cmovHandler (const char *input,
(0 != memcmp (&c->cmvdAtom.type, "cmvd", 4)) ||
(ntohl (c->cmvdAtom.size) !=
getAtomSize (&input[pos]) - sizeof (Atom) * 2 - 4))
- {
- return 0; /* dcom must be 12 bytes */
- }
+ {
+ return 0; /* dcom must be 12 bytes */
+ }
s = ntohl (c->decompressedSize);
if (s > 16 * 1024 * 1024)
return 1; /* ignore, too big! */
@@ -718,27 +726,28 @@ cmovHandler (const char *input,
z_state.opaque = (voidpf) 0;
z_ret_code = inflateInit (&z_state);
if (Z_OK != z_ret_code)
- {
- free (buf);
- return 0; /* crc error? */
- }
+ {
+ free (buf);
+ return 0; /* crc error? */
+ }
z_ret_code = inflate (&z_state, Z_NO_FLUSH);
if ((z_ret_code != Z_OK) && (z_ret_code != Z_STREAM_END))
- {
- free (buf);
- return 0; /* decode error? */
- }
+ {
+ free (buf);
+ return 0; /* decode error? */
+ }
z_ret_code = inflateEnd (&z_state);
if (Z_OK != z_ret_code)
- {
- free (buf);
- return 0; /* decode error? */
- }
+ {
+ free (buf);
+ return 0; /* decode error? */
+ }
ret = handleAtom (all_handlers, buf, s, 0, ec);
free (buf);
return ret;
}
+
typedef struct
{
short integer;
@@ -780,18 +789,19 @@ tkhdHandler (const char *input,
return 0;
m = (const TrackAtom *) &input[pos];
if (ntohs (m->track_width.integer) != 0)
- {
- /* if actually a/the video track */
- snprintf (dimensions,
- sizeof(dimensions),
- "%dx%d",
- ntohs (m->track_width.integer),
- ntohs (m->track_height.integer));
- addKeyword (EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, dimensions, ec);
- }
+ {
+ /* if actually a/the video track */
+ snprintf (dimensions,
+ sizeof(dimensions),
+ "%dx%d",
+ ntohs (m->track_width.integer),
+ ntohs (m->track_height.integer));
+ addKeyword (EXTRACTOR_METATYPE_IMAGE_DIMENSIONS, dimensions, ec);
+ }
return 1;
}
+
static int
trakHandler (const char *input,
size_t size, size_t pos, struct ExtractContext *ec)
@@ -801,6 +811,7 @@ trakHandler (const char *input,
getAtomSize (&input[pos]) - hdr, ec);
}
+
static int
metaHandler (const char *input,
size_t size, size_t pos, struct ExtractContext *ec)
@@ -812,6 +823,7 @@ metaHandler (const char *input,
getAtomSize (&input[pos]) - hdr - 4, ec);
}
+
typedef struct
{
Atom header;
@@ -873,13 +885,14 @@ c_Handler (const char *input,
int i;
i = 0;
- while ((cHm[i].pfx != NULL) && (0 != memcmp (&input[pos+5], cHm[i].pfx, 3)))
+ while ((cHm[i].pfx != NULL) && (0 != memcmp (&input[pos + 5], cHm[i].pfx, 3)))
i++;
if (cHm[i].pfx != NULL)
return processTextTag (input, size, pos, cHm[i].type, ec);
return -1; /* not found */
}
+
static int
udtaHandler (const char *input,
size_t size, size_t pos, struct ExtractContext *ec)
@@ -889,13 +902,14 @@ udtaHandler (const char *input,
getAtomSize (&input[pos]) - hdr, ec);
}
+
static int
processDataAtom (const char *input,
- size_t size, /* parent atom size */
- size_t pos,
- const char *patom,
- enum EXTRACTOR_MetaType type,
- struct ExtractContext *ec)
+ size_t size, /* parent atom size */
+ size_t pos,
+ const char *patom,
+ enum EXTRACTOR_MetaType type,
+ struct ExtractContext *ec)
{
char *meta;
unsigned char version;
@@ -907,55 +921,62 @@ processDataAtom (const char *input,
hdr = getAtomHeaderSize (&input[pos]);
asize = getAtomSize (&input[pos]);
- if (memcmp(&input[pos+4], "data", 4) != 0)
+ if (memcmp (&input[pos + 4], "data", 4) != 0)
return -1;
- if (asize < hdr + 8 || /* header + u32 flags + u32 reserved */
- asize > (getAtomSize(&patom[0]) - 8))
+ if ((asize < hdr + 8) || /* header + u32 flags + u32 reserved */
+ (asize > (getAtomSize (&patom[0]) - 8)) )
return 0;
- len = (unsigned int)(asize - (hdr + 8));
+ len = (unsigned int) (asize - (hdr + 8));
- version = input[pos+8];
- flags = ((unsigned char)input[pos+9]<<16) |
- ((unsigned char)input[pos+10]<<8) |
- (unsigned char)input[pos+11];
+ version = input[pos + 8];
+ flags = ((unsigned char) input[pos + 9] << 16)
+ | ((unsigned char) input[pos + 10] << 8)
+ | (unsigned char) input[pos + 11];
#if DEBUG
- printf("[data] version:%02x flags:%08x txtlen:%d\n", version, flags, len);
+ printf ("[data] version:%02x flags:%08x txtlen:%d\n", version, flags, len);
#endif
if (version != 0)
return -1;
- if (flags == 0x0) { /* binary data */
- if (memcmp(&patom[4], "gnre", 4) == 0) {
- if (len >= 2) {
- unsigned short genre = ((unsigned char)input[pos+16] << 8) |
- (unsigned char)input[pos+17];
- if (genre > 0 && genre < GENRE_NAME_COUNT)
- addKeyword(type, genre_names[genre-1], ec);
+ if (flags == 0x0) /* binary data */
+ {
+ if (memcmp (&patom[4], "gnre", 4) == 0)
+ {
+ if (len >= 2)
+ {
+ unsigned short genre = ((unsigned char) input[pos + 16] << 8)
+ | (unsigned char) input[pos + 17];
+ if ((genre > 0) && (genre < GENRE_NAME_COUNT))
+ addKeyword (type, genre_names[genre - 1], ec);
}
return 1;
}
- else if ((memcmp(&patom[4], "trkn", 4) == 0) ||
- (memcmp(&patom[4], "disk", 4) == 0)) {
- if (len >= 4) {
- unsigned short n = ((unsigned char)input[pos+18] << 8) |
- (unsigned char)input[pos+19];
+ else if ((memcmp (&patom[4], "trkn", 4) == 0) ||
+ (memcmp (&patom[4], "disk", 4) == 0))
+ {
+ if (len >= 4)
+ {
+ unsigned short n = ((unsigned char) input[pos + 18] << 8)
+ | (unsigned char) input[pos + 19];
char s[8];
- snprintf(s, 8, "%d", n);
- addKeyword(type, s, ec);
+ snprintf (s, 8, "%d", n);
+ addKeyword (type, s, ec);
}
}
- else {
+ else
+ {
return -1;
}
}
- else if (flags == 0x1) { /* text data */
+ else if (flags == 0x1) /* text data */
+ {
meta = malloc (len + 1);
if (meta == NULL)
return 0;
- memcpy (meta, &input[pos+16], len);
+ memcpy (meta, &input[pos + 16], len);
meta[len] = '\0';
for (i = 0; i < len; i++)
if (meta[i] == '\r')
@@ -968,12 +989,13 @@ processDataAtom (const char *input,
return -1;
}
+
/* NOTE: iTunes tag processing should, in theory, be limited to iTunes
* file types (from ftyp), but, in reality, it seems that there are other
* files, like 3gpp, out in the wild with iTunes tags. */
static int
iTunesTagHandler (const char *input,
- size_t size, size_t pos, struct ExtractContext *ec)
+ size_t size, size_t pos, struct ExtractContext *ec)
{
unsigned long long asize;
unsigned int hdr;
@@ -986,24 +1008,24 @@ iTunesTagHandler (const char *input,
return 0;
i = 0;
- while ((it_to_extr_table[i].atom_type != NULL) &&
- (0 != memcmp (&input[pos+4], it_to_extr_table[i].atom_type, 4)))
+ while ((it_to_extr_table[i].atom_type != NULL) &&
+ (0 != memcmp (&input[pos + 4], it_to_extr_table[i].atom_type, 4)))
i++;
if (it_to_extr_table[i].atom_type != NULL)
- return processDataAtom(input, asize, pos+hdr, &input[pos],
- it_to_extr_table[i].type, ec);
+ return processDataAtom (input, asize, pos + hdr, &input[pos],
+ it_to_extr_table[i].type, ec);
return -1;
}
-static int
+static int
ilstHandler (const char *input,
size_t size, size_t pos, struct ExtractContext *ec)
{
unsigned int hdr = getAtomHeaderSize (&input[pos]);
- return processAtoms(ilst_handlers, &input[pos + hdr],
- getAtomSize(&input[pos]) - hdr, ec);
+ return processAtoms (ilst_handlers, &input[pos + hdr],
+ getAtomSize (&input[pos]) - hdr, ec);
}
@@ -1099,23 +1121,23 @@ handleAtom (HandlerEntry *handlers, const char *input,
{
int i;
if (0 == checkAtomValid (input, size, pos))
- {
- return 0;
- }
+ {
+ return 0;
+ }
i = 0;
while ((handlers[i].name != NULL) &&
(0 != memcmp (&input[pos + 4], handlers[i].name, 4)))
i++;
if (handlers[i].name == NULL)
- {
+ {
#if DEBUG
- char b[5];
- memcpy (b, &input[pos + 4], 4);
- b[4] = '\0';
- printf ("No handler for `%s'\n", b);
+ char b[5];
+ memcpy (b, &input[pos + 4], 4);
+ b[4] = '\0';
+ printf ("No handler for `%s'\n", b);
#endif
- return -1;
- }
+ return -1;
+ }
i = handlers[i].handler (input, size, pos, ec);
#if DEBUG
printf ("Running handler for `%4s' at %u completed with result %d\n",
@@ -1124,18 +1146,19 @@ handleAtom (HandlerEntry *handlers, const char *input,
return i;
}
+
/* mimetypes:
video/quicktime: mov,qt: Quicktime animation;
video/x-quicktime: mov,qt: Quicktime animation;
application/x-quicktimeplayer: qtl: Quicktime list;
*/
-int
+int
EXTRACTOR_qt_extract (const char *data,
- size_t size,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls,
- const char *options)
+ size_t size,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls,
+ const char *options)
{
struct ExtractContext ec;
ec.proc = proc;
@@ -1145,4 +1168,5 @@ EXTRACTOR_qt_extract (const char *data,
return ec.ret;
}
+
/* end of qt_extractor.c */
diff --git a/src/plugins/old/real_extractor.c b/src/plugins/old/real_extractor.c
@@ -77,9 +77,9 @@ typedef struct
static int
-processMediaProperties (const Media_Properties * prop,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls)
+processMediaProperties (const Media_Properties *prop,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
UINT8 mime_type_size;
@@ -95,28 +95,29 @@ processMediaProperties (const Media_Properties * prop,
return 0;
mime_type_size = prop->data[prop->stream_name_size];
- if (prop_size > prop->stream_name_size + sizeof (UINT8) +
- +mime_type_size + sizeof (Media_Properties))
- {
- char data[mime_type_size + 1];
- memcpy (data, &prop->data[prop->stream_name_size + 1], mime_type_size);
- data[mime_type_size] = '\0';
-
- return proc (proc_cls,
- "real",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- data,
- strlen (data));
- }
+ if (prop_size > prop->stream_name_size + sizeof (UINT8)
+ + +mime_type_size + sizeof (Media_Properties))
+ {
+ char data[mime_type_size + 1];
+ memcpy (data, &prop->data[prop->stream_name_size + 1], mime_type_size);
+ data[mime_type_size] = '\0';
+
+ return proc (proc_cls,
+ "real",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ data,
+ strlen (data));
+ }
return 0;
}
+
static int
-processContentDescription (const Content_Description * prop,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls)
+processContentDescription (const Content_Description *prop,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
UINT16 author_len;
UINT16 copyright_len;
@@ -137,23 +138,23 @@ processContentDescription (const Content_Description * prop,
title_len = ntohs (prop->title_len);
if (prop_size <= title_len + sizeof (UINT16) + sizeof (Content_Description))
return 0;
- author_len = ntohs (*(UINT16 *) & prop->data[title_len]);
+ author_len = ntohs (*(UINT16 *) &prop->data[title_len]);
if (prop_size <= title_len + sizeof (UINT16)
+ author_len + sizeof (Content_Description))
return 0;
- copyright_len = ntohs (*(UINT16 *) & prop->data[title_len +
- author_len +
- sizeof (UINT16)]);
+ copyright_len = ntohs (*(UINT16 *) &prop->data[title_len
+ + author_len
+ + sizeof (UINT16)]);
if (prop_size <= title_len + 2 * sizeof (UINT16)
+ author_len + copyright_len + sizeof (Content_Description))
return 0;
- comment_len = ntohs (*(UINT16 *) & prop->data[title_len +
- author_len +
- copyright_len +
- 2 * sizeof (UINT16)]);
+ comment_len = ntohs (*(UINT16 *) &prop->data[title_len
+ + author_len
+ + copyright_len
+ + 2 * sizeof (UINT16)]);
if (prop_size < title_len + 3 * sizeof (UINT16)
+ author_len + copyright_len + comment_len
@@ -163,78 +164,79 @@ processContentDescription (const Content_Description * prop,
ret = 0;
title = malloc (title_len + 1);
if (title != NULL)
- {
- memcpy (title, &prop->data[0], title_len);
- title[title_len] = '\0';
- ret = proc (proc_cls,
- "real",
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- title,
- strlen (title)+1);
- free (title);
- }
+ {
+ memcpy (title, &prop->data[0], title_len);
+ title[title_len] = '\0';
+ ret = proc (proc_cls,
+ "real",
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ title,
+ strlen (title) + 1);
+ free (title);
+ }
if (ret != 0)
return ret;
author = malloc (author_len + 1);
if (author != NULL)
- {
- memcpy (author, &prop->data[title_len + sizeof (UINT16)], author_len);
- author[author_len] = '\0';
- ret = proc (proc_cls,
- "real",
- EXTRACTOR_METATYPE_AUTHOR_NAME,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- author,
- strlen (author)+1);
- free (author);
- }
+ {
+ memcpy (author, &prop->data[title_len + sizeof (UINT16)], author_len);
+ author[author_len] = '\0';
+ ret = proc (proc_cls,
+ "real",
+ EXTRACTOR_METATYPE_AUTHOR_NAME,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ author,
+ strlen (author) + 1);
+ free (author);
+ }
if (ret != 0)
return ret;
copyright = malloc (copyright_len + 1);
if (copyright != NULL)
- {
- memcpy (copyright,
- &prop->data[title_len + sizeof (UINT16) * 2 + author_len],
- copyright_len);
- copyright[copyright_len] = '\0';
- ret = proc (proc_cls,
- "real",
- EXTRACTOR_METATYPE_COPYRIGHT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- copyright,
- strlen (copyright)+1);
- free (copyright);
- }
+ {
+ memcpy (copyright,
+ &prop->data[title_len + sizeof (UINT16) * 2 + author_len],
+ copyright_len);
+ copyright[copyright_len] = '\0';
+ ret = proc (proc_cls,
+ "real",
+ EXTRACTOR_METATYPE_COPYRIGHT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ copyright,
+ strlen (copyright) + 1);
+ free (copyright);
+ }
if (ret != 0)
return ret;
comment = malloc (comment_len + 1);
if (comment != NULL)
- {
- memcpy (comment,
- &prop->data[title_len + sizeof (UINT16) * 3 + author_len +
- copyright_len], comment_len);
- comment[comment_len] = '\0';
- ret = proc (proc_cls,
- "real",
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- comment,
- strlen (comment)+1);
- free (comment);
- }
+ {
+ memcpy (comment,
+ &prop->data[title_len + sizeof (UINT16) * 3 + author_len
+ + copyright_len], comment_len);
+ comment[comment_len] = '\0';
+ ret = proc (proc_cls,
+ "real",
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ comment,
+ strlen (comment) + 1);
+ free (comment);
+ }
if (ret != 0)
return ret;
return 0;
}
+
typedef struct RAFF4_header
{
unsigned short version;
@@ -281,13 +283,14 @@ stndup (const char *str, size_t n)
return tmp;
}
+
/* audio/vnd.rn-realaudio */
-int
+int
EXTRACTOR_real_extract (const unsigned char *data,
- size_t size,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls,
- const char *options)
+ size_t size,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls,
+ const char *options)
{
const unsigned char *pos;
const unsigned char *end;
@@ -303,132 +306,134 @@ EXTRACTOR_real_extract (const unsigned char *data,
if (size <= 2 * sizeof (int))
return 0;
if (RAFF4_HEADER == ntohl (*(int *) data))
+ {
+ /* HELIX */
+ if (size <= RAFF4_HDR_SIZE + 16 + 4)
+ return 0;
+ if (0 != proc (proc_cls,
+ "real",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "audio/vnd.rn-realaudio",
+ strlen ("audio/vnd.rn-realaudio") + 1))
+ return 1;
+ hdr = (const RAFF4_header *) &data[16];
+ if (ntohs (hdr->header_length) + 16 > size)
+ return 0;
+ tlen = data[16 + RAFF4_HDR_SIZE];
+ if (tlen + RAFF4_HDR_SIZE + 20 > size)
+ return 0;
+ alen = data[17 + tlen + RAFF4_HDR_SIZE];
+ if (tlen + alen + RAFF4_HDR_SIZE + 20 > size)
+ return 0;
+ clen = data[18 + tlen + alen + RAFF4_HDR_SIZE];
+ if (tlen + alen + clen + RAFF4_HDR_SIZE + 20 > size)
+ return 0;
+ aplen = data[19 + tlen + clen + alen + RAFF4_HDR_SIZE];
+ if (tlen + alen + clen + aplen + RAFF4_HDR_SIZE + 20 > size)
+ return 0;
+ ret = 0;
+ if ( (tlen > 0) && (ret == 0) )
{
- /* HELIX */
- if (size <= RAFF4_HDR_SIZE + 16 + 4)
- return 0;
- if (0 != proc (proc_cls,
- "real",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "audio/vnd.rn-realaudio",
- strlen ("audio/vnd.rn-realaudio")+1))
- return 1;
- hdr = (const RAFF4_header *) &data[16];
- if (ntohs (hdr->header_length) + 16 > size)
- return 0;
- tlen = data[16 + RAFF4_HDR_SIZE];
- if (tlen + RAFF4_HDR_SIZE + 20 > size)
- return 0;
- alen = data[17 + tlen + RAFF4_HDR_SIZE];
- if (tlen + alen + RAFF4_HDR_SIZE + 20 > size)
- return 0;
- clen = data[18 + tlen + alen + RAFF4_HDR_SIZE];
- if (tlen + alen + clen + RAFF4_HDR_SIZE + 20 > size)
- return 0;
- aplen = data[19 + tlen + clen + alen + RAFF4_HDR_SIZE];
- if (tlen + alen + clen + aplen + RAFF4_HDR_SIZE + 20 > size)
- return 0;
- ret = 0;
- if ( (tlen > 0) && (ret == 0) )
- {
- x = stndup ((const char *) &data[17 + RAFF4_HDR_SIZE], tlen);
- if (x != NULL)
- {
- ret = proc (proc_cls,
- "real",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- x,
- strlen (x)+1);
- free (x);
- }
- }
- if ( (alen > 0) && (ret == 0) )
- {
- x = stndup ((const char *) &data[18 + RAFF4_HDR_SIZE + tlen], alen);
- if (x != NULL)
- {
- ret = proc (proc_cls,
- "real",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- x,
- strlen (x)+1);
- free (x);
- }
- }
- if ( (clen > 0) && (ret == 0) )
- {
- x = stndup ((const char *) &data[19 + RAFF4_HDR_SIZE + tlen + alen], clen);
- if (x != NULL)
- {
- ret = proc (proc_cls,
- "real",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- x,
- strlen (x)+1);
- free (x);
- }
- }
- if ( (aplen > 0) && (ret == 0) )
- {
- x = stndup ((const char *) &data[20 + RAFF4_HDR_SIZE + tlen + alen + clen], aplen);
- if (x != NULL)
- {
- ret = proc (proc_cls,
- "real",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- x,
- strlen (x)+1);
- free (x);
- }
- }
- return ret;
+ x = stndup ((const char *) &data[17 + RAFF4_HDR_SIZE], tlen);
+ if (x != NULL)
+ {
+ ret = proc (proc_cls,
+ "real",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ x,
+ strlen (x) + 1);
+ free (x);
+ }
}
+ if ( (alen > 0) && (ret == 0) )
+ {
+ x = stndup ((const char *) &data[18 + RAFF4_HDR_SIZE + tlen], alen);
+ if (x != NULL)
+ {
+ ret = proc (proc_cls,
+ "real",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ x,
+ strlen (x) + 1);
+ free (x);
+ }
+ }
+ if ( (clen > 0) && (ret == 0) )
+ {
+ x = stndup ((const char *) &data[19 + RAFF4_HDR_SIZE + tlen + alen],
+ clen);
+ if (x != NULL)
+ {
+ ret = proc (proc_cls,
+ "real",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ x,
+ strlen (x) + 1);
+ free (x);
+ }
+ }
+ if ( (aplen > 0) && (ret == 0) )
+ {
+ x = stndup ((const char *) &data[20 + RAFF4_HDR_SIZE + tlen + alen
+ + clen], aplen);
+ if (x != NULL)
+ {
+ ret = proc (proc_cls,
+ "real",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ x,
+ strlen (x) + 1);
+ free (x);
+ }
+ }
+ return ret;
+ }
if (REAL_HEADER == ntohl (*(int *) data))
+ {
+ /* old real */
+ end = &data[size];
+ pos = &data[0];
+ ret = 0;
+ while (0 == ret)
{
- /* old real */
- end = &data[size];
- pos = &data[0];
- ret = 0;
- while (0 == ret)
- {
- if ((pos + 8 >= end) || (pos + 8 < pos))
- break;
- length = ntohl (*(((unsigned int *) pos) + 1));
- if (length <= 0)
- break;
- if ((pos + length >= end) || (pos + length < pos))
- break;
- switch (ntohl (*((unsigned int *) pos)))
- {
- case MDPR_HEADER:
- ret = processMediaProperties ((Media_Properties *) pos,
- proc,
- proc_cls);
- pos += length;
- break;
- case CONT_HEADER:
- ret = processContentDescription ((Content_Description *) pos,
- proc,
- proc_cls);
- pos += length;
- break;
- case REAL_HEADER: /* treat like default */
- default:
- pos += length;
- break;
- }
- }
- return ret;
+ if ((pos + 8 >= end) || (pos + 8 < pos))
+ break;
+ length = ntohl (*(((unsigned int *) pos) + 1));
+ if (length <= 0)
+ break;
+ if ((pos + length >= end) || (pos + length < pos))
+ break;
+ switch (ntohl (*((unsigned int *) pos)))
+ {
+ case MDPR_HEADER:
+ ret = processMediaProperties ((Media_Properties *) pos,
+ proc,
+ proc_cls);
+ pos += length;
+ break;
+ case CONT_HEADER:
+ ret = processContentDescription ((Content_Description *) pos,
+ proc,
+ proc_cls);
+ pos += length;
+ break;
+ case REAL_HEADER: /* treat like default */
+ default:
+ pos += length;
+ break;
+ }
}
+ return ret;
+ }
return 0;
}
diff --git a/src/plugins/ole2_extractor.c b/src/plugins/ole2_extractor.c
@@ -66,9 +66,9 @@
*/
static int
add_metadata (EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls,
- const char *phrase,
- enum EXTRACTOR_MetaType type)
+ void *proc_cls,
+ const char *phrase,
+ enum EXTRACTOR_MetaType type)
{
char *tmp;
int ret;
@@ -85,15 +85,15 @@ add_metadata (EXTRACTOR_MetaDataProcessor proc,
return 0;
while ( (strlen (tmp) > 0) &&
- (isblank ((unsigned char) tmp [strlen (tmp) - 1])) )
+ (isblank ((unsigned char) tmp [strlen (tmp) - 1])) )
tmp [strlen (tmp) - 1] = '\0';
ret = proc (proc_cls,
- "ole2",
- type,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- tmp,
- strlen (tmp) + 1);
+ "ole2",
+ type,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ tmp,
+ strlen (tmp) + 1);
free (tmp);
return ret;
}
@@ -133,7 +133,7 @@ static struct Matches tmap[] = {
{ "RevisionNumber", EXTRACTOR_METATYPE_REVISION_NUMBER },
{ "NumBytes", EXTRACTOR_METATYPE_EMBEDDED_FILE_SIZE },
{ "CreatedTime", EXTRACTOR_METATYPE_CREATION_DATE },
- { "LastSavedTime" , EXTRACTOR_METATYPE_MODIFICATION_DATE },
+ { "LastSavedTime", EXTRACTOR_METATYPE_MODIFICATION_DATE },
{ "gsf:company", EXTRACTOR_METATYPE_COMPANY },
{ "gsf:character-count", EXTRACTOR_METATYPE_CHARACTER_COUNT },
{ "gsf:page-count", EXTRACTOR_METATYPE_PAGE_COUNT },
@@ -194,8 +194,8 @@ struct ProcContext
*/
static void
process_metadata (gpointer key,
- gpointer value,
- gpointer user_data)
+ gpointer value,
+ gpointer user_data)
{
const char *type = key;
const GsfDocProp *prop = value;
@@ -211,75 +211,76 @@ process_metadata (gpointer key,
return;
gval = gsf_doc_prop_get_val (prop);
- if (G_VALUE_TYPE(gval) == G_TYPE_STRING)
- {
- const char *gvals;
+ if (G_VALUE_TYPE (gval) == G_TYPE_STRING)
+ {
+ const char *gvals;
- gvals = g_value_get_string (gval);
- if (NULL == gvals)
- return;
- contents = strdup (gvals);
- }
+ gvals = g_value_get_string (gval);
+ if (NULL == gvals)
+ return;
+ contents = strdup (gvals);
+ }
else
- {
- /* convert other formats? */
- contents = g_strdup_value_contents (gval);
- }
+ {
+ /* convert other formats? */
+ contents = g_strdup_value_contents (gval);
+ }
if (NULL == contents)
return;
if (0 == strcmp (type,
"meta:generator"))
+ {
+ const char *mimetype = "application/vnd.ms-files";
+ struct
{
- const char *mimetype = "application/vnd.ms-files";
- struct {
- const char *v;
- const char *m;
- } mm[] = {
- { "Microsoft Word", "application/msword" },
- { "Microsoft Office Word", "application/msword" },
- { "Microsoft Excel", "application/vnd.ms-excel" },
- { "Microsoft Office Excel", "application/vnd.ms-excel" },
- { "Microsoft PowerPoint", "application/vnd.ms-powerpoint" },
- { "Microsoft Office PowerPoint", "application/vnd.ms-powerpoint"},
- { "Microsoft Project", "application/vnd.ms-project" },
- { "Microsoft Visio", "application/vnd.visio" },
- { "Microsoft Office", "application/vnd.ms-office" },
- { NULL, NULL }
- };
- int i;
-
- for (i=0;NULL != mm[i].v; i++)
- if (0 == strncmp (value,
- mm[i].v,
- strlen (mm[i].v) + 1))
- {
- mimetype = mm[i].m;
- break;
- }
- if (0 != add_metadata (pc->proc,
- pc->proc_cls,
- mimetype,
- EXTRACTOR_METATYPE_MIMETYPE))
- {
- free (contents);
- pc->ret = 1;
- return;
- }
+ const char *v;
+ const char *m;
+ } mm[] = {
+ { "Microsoft Word", "application/msword" },
+ { "Microsoft Office Word", "application/msword" },
+ { "Microsoft Excel", "application/vnd.ms-excel" },
+ { "Microsoft Office Excel", "application/vnd.ms-excel" },
+ { "Microsoft PowerPoint", "application/vnd.ms-powerpoint" },
+ { "Microsoft Office PowerPoint", "application/vnd.ms-powerpoint"},
+ { "Microsoft Project", "application/vnd.ms-project" },
+ { "Microsoft Visio", "application/vnd.visio" },
+ { "Microsoft Office", "application/vnd.ms-office" },
+ { NULL, NULL }
+ };
+ int i;
+
+ for (i = 0; NULL != mm[i].v; i++)
+ if (0 == strncmp (value,
+ mm[i].v,
+ strlen (mm[i].v) + 1))
+ {
+ mimetype = mm[i].m;
+ break;
+ }
+ if (0 != add_metadata (pc->proc,
+ pc->proc_cls,
+ mimetype,
+ EXTRACTOR_METATYPE_MIMETYPE))
+ {
+ free (contents);
+ pc->ret = 1;
+ return;
}
+ }
for (pos = 0; NULL != tmap[pos].text; pos++)
if (0 == strcmp (tmap[pos].text,
- type))
+ type))
break;
if ( (NULL != tmap[pos].text) &&
(0 != add_metadata (pc->proc, pc->proc_cls,
- contents,
- tmap[pos].type)) )
- {
- free (contents);
- pc->ret = 1;
- return;
- }
- free(contents);
+ contents,
+ tmap[pos].type)) )
+ {
+ free (contents);
+ pc->ret = 1;
+ return;
+ }
+ free (contents);
}
@@ -294,8 +295,8 @@ process_metadata (gpointer key,
*/
static int
process (GsfInput *in,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls)
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
struct ProcContext pc;
GsfDocMetaData *sections;
@@ -311,15 +312,15 @@ process (GsfInput *in,
error = gsf_msole_metadata_read (in, sections);
#endif
if (NULL == error)
- {
- gsf_doc_meta_data_foreach (sections,
- &process_metadata,
- &pc);
- }
+ {
+ gsf_doc_meta_data_foreach (sections,
+ &process_metadata,
+ &pc);
+ }
else
- {
- g_error_free (error);
- }
+ {
+ g_error_free (error);
+ }
g_object_unref (G_OBJECT (sections));
return pc.ret;
}
@@ -336,50 +337,50 @@ process (GsfInput *in,
*/
static int
process_star_office (GsfInput *src,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls)
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
off_t size = gsf_input_size (src);
if ( (size < 0x374) ||
- (size > 4*1024*1024) ) /* == 0x375?? */
+ (size > 4 * 1024 * 1024) ) /* == 0x375?? */
return 0;
{
char buf[size];
gsf_input_read (src, size, (unsigned char*) buf);
if ( (buf[0] != 0x0F) ||
- (buf[1] != 0x0) ||
- (0 != strncmp (&buf[2],
- "SfxDocumentInfo",
- strlen ("SfxDocumentInfo"))) ||
- (buf[0x11] != 0x0B) ||
- (buf[0x13] != 0x00) || /* pw protected! */
- (buf[0x12] != 0x00) )
+ (buf[1] != 0x0) ||
+ (0 != strncmp (&buf[2],
+ "SfxDocumentInfo",
+ strlen ("SfxDocumentInfo"))) ||
+ (buf[0x11] != 0x0B) ||
+ (buf[0x13] != 0x00) || /* pw protected! */
+ (buf[0x12] != 0x00) )
return 0;
buf[0xd3] = '\0';
if ( (buf[0x94] + buf[0x93] > 0) &&
- (0 != add_metadata (proc, proc_cls,
- &buf[0x95],
- EXTRACTOR_METATYPE_TITLE)) )
+ (0 != add_metadata (proc, proc_cls,
+ &buf[0x95],
+ EXTRACTOR_METATYPE_TITLE)) )
return 1;
buf[0x114] = '\0';
if ( (buf[0xd5] + buf[0xd4] > 0) &&
- (0 != add_metadata (proc, proc_cls,
- &buf[0xd6],
- EXTRACTOR_METATYPE_SUBJECT)) )
+ (0 != add_metadata (proc, proc_cls,
+ &buf[0xd6],
+ EXTRACTOR_METATYPE_SUBJECT)) )
return 1;
buf[0x215] = '\0';
if ( (buf[0x115] + buf[0x116] > 0) &&
- (0 != add_metadata (proc, proc_cls,
- &buf[0x117],
- EXTRACTOR_METATYPE_COMMENT)) )
+ (0 != add_metadata (proc, proc_cls,
+ &buf[0x117],
+ EXTRACTOR_METATYPE_COMMENT)) )
return 1;
buf[0x296] = '\0';
if ( (buf[0x216] + buf[0x217] > 0) &&
- (0 != add_metadata(proc, proc_cls,
- &buf[0x218],
- EXTRACTOR_METATYPE_KEYWORDS)) )
+ (0 != add_metadata (proc, proc_cls,
+ &buf[0x218],
+ EXTRACTOR_METATYPE_KEYWORDS)) )
return 1;
/* fixme: do timestamps,
mime-type, user-defined info's */
@@ -394,7 +395,7 @@ process_star_office (GsfInput *src,
* @param a string to translate
* @return translated string
*/
-#define __(a) dgettext("iso-639", a)
+#define __(a) dgettext ("iso-639", a)
/**
@@ -408,126 +409,126 @@ static const char *
lid_to_language (unsigned int lid)
{
switch (lid)
- {
- case 0x0400:
- return _("No Proofing");
- case 0x0401:
- return __("Arabic");
- case 0x0402:
- return __("Bulgarian");
- case 0x0403:
- return __("Catalan");
- case 0x0404:
- return _("Traditional Chinese");
- case 0x0804:
- return _("Simplified Chinese");
- case 0x0405:
- return __("Chechen");
- case 0x0406:
- return __("Danish");
- case 0x0407:
- return __("German");
- case 0x0807:
- return _("Swiss German");
- case 0x0408:
- return __("Greek");
- case 0x0409:
- return _("U.S. English");
- case 0x0809:
- return _("U.K. English");
- case 0x0c09:
- return _("Australian English");
- case 0x040a:
- return _("Castilian Spanish");
- case 0x080a:
- return _("Mexican Spanish");
- case 0x040b:
- return __("Finnish");
- case 0x040c:
- return __("French");
- case 0x080c:
- return _("Belgian French");
- case 0x0c0c:
- return _("Canadian French");
- case 0x100c:
- return _("Swiss French");
- case 0x040d:
- return __("Hebrew");
- case 0x040e:
- return __("Hungarian");
- case 0x040f:
- return __("Icelandic");
- case 0x0410:
- return __("Italian");
- case 0x0810:
- return _("Swiss Italian");
- case 0x0411:
- return __("Japanese");
- case 0x0412:
- return __("Korean");
- case 0x0413:
- return __("Dutch");
- case 0x0813:
- return _("Belgian Dutch");
- case 0x0414:
- return _("Norwegian Bokmal");
- case 0x0814:
- return __("Norwegian Nynorsk");
- case 0x0415:
- return __("Polish");
- case 0x0416:
- return __("Brazilian Portuguese");
- case 0x0816:
- return __("Portuguese");
- case 0x0417:
- return _("Rhaeto-Romanic");
- case 0x0418:
- return __("Romanian");
- case 0x0419:
- return __("Russian");
- case 0x041a:
- return _("Croato-Serbian (Latin)");
- case 0x081a:
- return _("Serbo-Croatian (Cyrillic)");
- case 0x041b:
- return __("Slovak");
- case 0x041c:
- return __("Albanian");
- case 0x041d:
- return __("Swedish");
- case 0x041e:
- return __("Thai");
- case 0x041f:
- return __("Turkish");
- case 0x0420:
- return __("Urdu");
- case 0x0421:
- return __("Bahasa");
- case 0x0422:
- return __("Ukrainian");
- case 0x0423:
- return __("Byelorussian");
- case 0x0424:
- return __("Slovenian");
- case 0x0425:
- return __("Estonian");
- case 0x0426:
- return __("Latvian");
- case 0x0427:
- return __("Lithuanian");
- case 0x0429:
- return _("Farsi");
- case 0x042D:
- return __("Basque");
- case 0x042F:
- return __("Macedonian");
- case 0x0436:
- return __("Afrikaans");
- case 0x043E:
- return __("Malayalam");
- default:
- return NULL;
- }
+ {
+ case 0x0400:
+ return _ ("No Proofing");
+ case 0x0401:
+ return __ ("Arabic");
+ case 0x0402:
+ return __ ("Bulgarian");
+ case 0x0403:
+ return __ ("Catalan");
+ case 0x0404:
+ return _ ("Traditional Chinese");
+ case 0x0804:
+ return _ ("Simplified Chinese");
+ case 0x0405:
+ return __ ("Chechen");
+ case 0x0406:
+ return __ ("Danish");
+ case 0x0407:
+ return __ ("German");
+ case 0x0807:
+ return _ ("Swiss German");
+ case 0x0408:
+ return __ ("Greek");
+ case 0x0409:
+ return _ ("U.S. English");
+ case 0x0809:
+ return _ ("U.K. English");
+ case 0x0c09:
+ return _ ("Australian English");
+ case 0x040a:
+ return _ ("Castilian Spanish");
+ case 0x080a:
+ return _ ("Mexican Spanish");
+ case 0x040b:
+ return __ ("Finnish");
+ case 0x040c:
+ return __ ("French");
+ case 0x080c:
+ return _ ("Belgian French");
+ case 0x0c0c:
+ return _ ("Canadian French");
+ case 0x100c:
+ return _ ("Swiss French");
+ case 0x040d:
+ return __ ("Hebrew");
+ case 0x040e:
+ return __ ("Hungarian");
+ case 0x040f:
+ return __ ("Icelandic");
+ case 0x0410:
+ return __ ("Italian");
+ case 0x0810:
+ return _ ("Swiss Italian");
+ case 0x0411:
+ return __ ("Japanese");
+ case 0x0412:
+ return __ ("Korean");
+ case 0x0413:
+ return __ ("Dutch");
+ case 0x0813:
+ return _ ("Belgian Dutch");
+ case 0x0414:
+ return _ ("Norwegian Bokmal");
+ case 0x0814:
+ return __ ("Norwegian Nynorsk");
+ case 0x0415:
+ return __ ("Polish");
+ case 0x0416:
+ return __ ("Brazilian Portuguese");
+ case 0x0816:
+ return __ ("Portuguese");
+ case 0x0417:
+ return _ ("Rhaeto-Romanic");
+ case 0x0418:
+ return __ ("Romanian");
+ case 0x0419:
+ return __ ("Russian");
+ case 0x041a:
+ return _ ("Croato-Serbian (Latin)");
+ case 0x081a:
+ return _ ("Serbo-Croatian (Cyrillic)");
+ case 0x041b:
+ return __ ("Slovak");
+ case 0x041c:
+ return __ ("Albanian");
+ case 0x041d:
+ return __ ("Swedish");
+ case 0x041e:
+ return __ ("Thai");
+ case 0x041f:
+ return __ ("Turkish");
+ case 0x0420:
+ return __ ("Urdu");
+ case 0x0421:
+ return __ ("Bahasa");
+ case 0x0422:
+ return __ ("Ukrainian");
+ case 0x0423:
+ return __ ("Byelorussian");
+ case 0x0424:
+ return __ ("Slovenian");
+ case 0x0425:
+ return __ ("Estonian");
+ case 0x0426:
+ return __ ("Latvian");
+ case 0x0427:
+ return __ ("Lithuanian");
+ case 0x0429:
+ return _ ("Farsi");
+ case 0x042D:
+ return __ ("Basque");
+ case 0x042F:
+ return __ ("Macedonian");
+ case 0x0436:
+ return __ ("Afrikaans");
+ case 0x043E:
+ return __ ("Malayalam");
+ default:
+ return NULL;
+ }
}
@@ -543,10 +544,10 @@ lid_to_language (unsigned int lid)
*/
static int
history_extract (GsfInput *stream,
- unsigned int lcbSttbSavedBy,
- unsigned int fcSttbSavedBy,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls)
+ unsigned int lcbSttbSavedBy,
+ unsigned int fcSttbSavedBy,
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
unsigned int where;
unsigned char *lbuffer;
@@ -570,64 +571,64 @@ history_extract (GsfInput *stream,
nRev = (lbuffer[2] + (lbuffer[3] << 8)) / 2;
where = 6;
ret = 0;
- for (i=0; i < nRev; i++)
+ for (i = 0; i < nRev; i++)
+ {
+ if (where >= lcbSttbSavedBy)
+ break;
+ length = lbuffer[where++];
+ if ( (where + 2 * length + 2 >= lcbSttbSavedBy) ||
+ (where + 2 * length + 2 <= where) )
+ break;
+ author = EXTRACTOR_common_convert_to_utf8 ((const char*) &lbuffer[where],
+ length * 2,
+ "UTF-16BE");
+ where += length * 2 + 1;
+ length = lbuffer[where++];
+ if ( (where + 2 * length >= lcbSttbSavedBy) ||
+ (where + 2 * length + 1 <= where) )
{
- if (where >= lcbSttbSavedBy)
- break;
- length = lbuffer[where++];
- if ( (where + 2 * length + 2 >= lcbSttbSavedBy) ||
- (where + 2 * length + 2 <= where) )
- break;
- author = EXTRACTOR_common_convert_to_utf8 ((const char*) &lbuffer[where],
- length * 2,
- "UTF-16BE");
- where += length * 2 + 1;
- length = lbuffer[where++];
- if ( (where + 2 * length >= lcbSttbSavedBy) ||
- (where + 2 * length + 1 <= where) )
- {
- if (NULL != author)
- free(author);
- break;
- }
- filename = EXTRACTOR_common_convert_to_utf8 ((const char*) &lbuffer[where],
- length * 2,
- "UTF-16BE");
- where += length * 2 + 1;
- if ( (NULL != author) &&
- (NULL != filename) )
- {
- size_t bsize;
-
- bsize = strlen (author) + strlen (filename) + 512;
- if (NULL != (rbuf = malloc (bsize)))
- {
- int snret;
-
- snret = snprintf (rbuf,
- bsize,
- _("Revision #%u: Author `%s' worked on `%s'"),
- i,
- author,
- filename);
- if ( (-1 != snret) &&
- (bsize > (size_t) snret) )
- {
- ret = add_metadata (proc,
- proc_cls,
- rbuf,
- EXTRACTOR_METATYPE_REVISION_HISTORY);
- }
- free (rbuf);
- }
- }
if (NULL != author)
- free (author);
- if (NULL != filename)
- free (filename);
- if (0 != ret)
- break;
+ free (author);
+ break;
+ }
+ filename = EXTRACTOR_common_convert_to_utf8 ((const char*) &lbuffer[where],
+ length * 2,
+ "UTF-16BE");
+ where += length * 2 + 1;
+ if ( (NULL != author) &&
+ (NULL != filename) )
+ {
+ size_t bsize;
+
+ bsize = strlen (author) + strlen (filename) + 512;
+ if (NULL != (rbuf = malloc (bsize)))
+ {
+ int snret;
+
+ snret = snprintf (rbuf,
+ bsize,
+ _ ("Revision #%u: Author `%s' worked on `%s'"),
+ i,
+ author,
+ filename);
+ if ( (-1 != snret) &&
+ (bsize > (size_t) snret) )
+ {
+ ret = add_metadata (proc,
+ proc_cls,
+ rbuf,
+ EXTRACTOR_METATYPE_REVISION_HISTORY);
+ }
+ free (rbuf);
+ }
}
+ if (NULL != author)
+ free (author);
+ if (NULL != filename)
+ free (filename);
+ if (0 != ret)
+ break;
+ }
free (lbuffer);
return ret;
}
@@ -636,11 +637,19 @@ history_extract (GsfInput *stream,
/* *************************** custom GSF input method ***************** */
#define LE_TYPE_INPUT (le_input_get_type ())
-#define LE_INPUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), LE_TYPE_INPUT, LeInput))
-#define LE_INPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), LE_TYPE_INPUT, LeInputClass))
-#define IS_LE_INPUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), LE_TYPE_INPUT))
-#define IS_LE_INPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), LE_TYPE_INPUT))
-#define LE_INPUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), LE_TYPE_INPUT, LeInputClass))
+#define LE_INPUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), \
+ LE_TYPE_INPUT, \
+ LeInput))
+#define LE_INPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), \
+ LE_TYPE_INPUT, \
+ LeInputClass))
+#define IS_LE_INPUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), \
+ LE_TYPE_INPUT))
+#define IS_LE_INPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), \
+ LE_TYPE_INPUT))
+#define LE_INPUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), \
+ LE_TYPE_INPUT, \
+ LeInputClass))
/**
* Internal state of an "LeInput" object.
@@ -683,10 +692,10 @@ typedef struct _LeInputClass
GsfInputClass parent_class;
/* Padding for future expansion */
- void (*_gtk_reserved1) (void);
- void (*_gtk_reserved2) (void);
- void (*_gtk_reserved3) (void);
- void (*_gtk_reserved4) (void);
+ void (*_gtk_reserved1)(void);
+ void (*_gtk_reserved2)(void);
+ void (*_gtk_reserved3)(void);
+ void (*_gtk_reserved4)(void);
} LeInputClass;
@@ -721,7 +730,8 @@ le_input_init (LeInput *input);
/**
* Macro to create LeInput type definition and register the class.
*/
-GSF_CLASS (LeInput, le_input, le_input_class_init, le_input_init, GSF_INPUT_TYPE)
+GSF_CLASS (LeInput, le_input, le_input_class_init, le_input_init,
+ GSF_INPUT_TYPE)
/**
@@ -732,12 +742,12 @@ GSF_CLASS (LeInput, le_input, le_input_class_init, le_input_init, GSF_INPUT_TYPE
* @return NULL on error (always)
*/
static GsfInput *
-le_input_dup (GsfInput *input,
- GError **err)
+le_input_dup (GsfInput * input,
+ GError * *err)
{
if (NULL != err)
*err = g_error_new (gsf_input_error_id (), 0,
- "dup not supported on LeInput");
+ "dup not supported on LeInput");
return NULL;
}
@@ -755,8 +765,8 @@ le_input_dup (GsfInput *input,
*/
static const guint8 *
le_input_read (GsfInput *input,
- size_t num_bytes,
- guint8 *optional_buffer)
+ size_t num_bytes,
+ guint8 *optional_buffer)
{
LeInput *li = LE_INPUT (input);
struct EXTRACTOR_ExtractContext *ec;
@@ -768,21 +778,21 @@ le_input_read (GsfInput *input,
old_off = ec->seek (ec->cls, 0, SEEK_CUR);
if (num_bytes
!= (ret = ec->read (ec->cls,
- &buf,
- num_bytes)))
- {
- /* we don't support partial reads;
- most other GsfInput implementations in this case
- allocate some huge temporary buffer just to avoid
- the partial read; we might need to do that as well!? */
- ec->seek (ec->cls, SEEK_SET, old_off);
- return NULL;
- }
+ &buf,
+ num_bytes)))
+ {
+ /* we don't support partial reads;
+ most other GsfInput implementations in this case
+ allocate some huge temporary buffer just to avoid
+ the partial read; we might need to do that as well!? */
+ ec->seek (ec->cls, SEEK_SET, old_off);
+ return NULL;
+ }
if (NULL != optional_buffer)
- {
- memcpy (optional_buffer, buf, num_bytes);
- return optional_buffer;
- }
+ {
+ memcpy (optional_buffer, buf, num_bytes);
+ return optional_buffer;
+ }
return buf;
}
@@ -797,8 +807,8 @@ le_input_read (GsfInput *input,
*/
static gboolean
le_input_seek (GsfInput *input,
- gsf_off_t offset,
- GSeekType whence)
+ gsf_off_t offset,
+ GSeekType whence)
{
LeInput *li = LE_INPUT (input);
struct EXTRACTOR_ExtractContext *ec;
@@ -807,23 +817,23 @@ le_input_seek (GsfInput *input,
ec = li->priv->ec;
switch (whence)
- {
- case G_SEEK_SET:
- w = SEEK_SET;
- break;
- case G_SEEK_CUR:
- w = SEEK_CUR;
- break;
- case G_SEEK_END:
- w = SEEK_END;
- break;
- default:
- return TRUE;
- }
+ {
+ case G_SEEK_SET:
+ w = SEEK_SET;
+ break;
+ case G_SEEK_CUR:
+ w = SEEK_CUR;
+ break;
+ case G_SEEK_END:
+ w = SEEK_END;
+ break;
+ default:
+ return TRUE;
+ }
if (-1 ==
(ret = ec->seek (ec->cls,
- offset,
- w)))
+ offset,
+ w)))
return TRUE;
return FALSE;
}
@@ -859,7 +869,7 @@ le_input_init (LeInput *input)
input->priv =
G_TYPE_INSTANCE_GET_PRIVATE (input, LE_TYPE_INPUT,
- LeInputPrivate);
+ LeInputPrivate);
priv = input->priv;
priv->ec = NULL;
}
@@ -878,9 +888,9 @@ le_input_new (struct EXTRACTOR_ExtractContext *ec)
input = g_object_new (LE_TYPE_INPUT, NULL);
gsf_input_set_size (GSF_INPUT (input),
- ec->get_size (ec->cls));
+ ec->get_size (ec->cls));
gsf_input_seek_emulate (GSF_INPUT (input),
- 0);
+ 0);
input->input.name = NULL;
input->input.container = NULL;
input->priv->ec = ec;
@@ -889,8 +899,6 @@ le_input_new (struct EXTRACTOR_ExtractContext *ec)
}
-
-
/* *********************** end of custom GSF input method ************* */
@@ -919,90 +927,92 @@ EXTRACTOR_ole2_extract_method (struct EXTRACTOR_ExtractContext *ec)
fsize = ec->get_size (ec->cls);
if (fsize < 512 + 898)
- {
- /* File too small for OLE2 */
- return; /* can hardly be OLE2 */
- }
+ {
+ /* File too small for OLE2 */
+ return; /* can hardly be OLE2 */
+ }
if (512 + 898 > (data_size = ec->read (ec->cls, &data, fsize)))
- {
- /* Failed to read minimum file size to buffer */
- return;
- }
+ {
+ /* Failed to read minimum file size to buffer */
+ return;
+ }
data512 = (const unsigned char*) data + 512;
lid = data512[6] + (data512[7] << 8);
if ( (NULL != (lang = lid_to_language (lid))) &&
(0 != (ret = add_metadata (ec->proc, ec->cls,
- lang,
- EXTRACTOR_METATYPE_LANGUAGE))) )
+ lang,
+ EXTRACTOR_METATYPE_LANGUAGE))) )
return;
- lcb = data512[726] + (data512[727] << 8) + (data512[728] << 16) + (data512[729] << 24);
- fcb = data512[722] + (data512[723] << 8) + (data512[724] << 16) + (data512[725] << 24);
+ lcb = data512[726] + (data512[727] << 8) + (data512[728] << 16)
+ + (data512[729] << 24);
+ fcb = data512[722] + (data512[723] << 8) + (data512[724] << 16)
+ + (data512[725] << 24);
if (0 != ec->seek (ec->cls, 0, SEEK_SET))
- {
- /* seek failed!? */
- return;
- }
+ {
+ /* seek failed!? */
+ return;
+ }
#if USE_LE_INPUT
if (NULL == (input = le_input_new (ec)))
- {
- fprintf (stderr, "le_input_new failed\n");
- return;
- }
+ {
+ fprintf (stderr, "le_input_new failed\n");
+ return;
+ }
#else
input = gsf_input_memory_new ((const guint8 *) data,
- data_size,
- FALSE);
+ data_size,
+ FALSE);
#endif
if (NULL == (infile = gsf_infile_msole_new (input, NULL)))
- {
- g_object_unref (G_OBJECT (input));
- return;
- }
+ {
+ g_object_unref (G_OBJECT (input));
+ return;
+ }
ret = 0;
- for (i=0;i<gsf_infile_num_children (infile);i++)
- {
- if (0 != ret)
- break;
- if (NULL == (name = gsf_infile_name_by_index (infile, i)))
- continue;
- src = NULL;
- if ( ( (0 == strcmp (name, "\005SummaryInformation")) ||
- (0 == strcmp (name, "\005DocumentSummaryInformation")) ) &&
- (NULL != (src = gsf_infile_child_by_index (infile, i))) )
- ret = process (src,
- ec->proc,
- ec->cls);
- if ( (0 == strcmp (name, "SfxDocumentInfo")) &&
- (NULL != (src = gsf_infile_child_by_index (infile, i))) )
- ret = process_star_office (src,
- ec->proc,
- ec->cls);
- if (NULL != src)
- g_object_unref (G_OBJECT (src));
- }
+ for (i = 0; i<gsf_infile_num_children (infile); i++)
+ {
+ if (0 != ret)
+ break;
+ if (NULL == (name = gsf_infile_name_by_index (infile, i)))
+ continue;
+ src = NULL;
+ if ( ( (0 == strcmp (name, "\005SummaryInformation")) ||
+ (0 == strcmp (name, "\005DocumentSummaryInformation")) ) &&
+ (NULL != (src = gsf_infile_child_by_index (infile, i))) )
+ ret = process (src,
+ ec->proc,
+ ec->cls);
+ if ( (0 == strcmp (name, "SfxDocumentInfo")) &&
+ (NULL != (src = gsf_infile_child_by_index (infile, i))) )
+ ret = process_star_office (src,
+ ec->proc,
+ ec->cls);
+ if (NULL != src)
+ g_object_unref (G_OBJECT (src));
+ }
if (0 != ret)
goto CLEANUP;
if (lcb < 6)
goto CLEANUP;
- for (i=0;i<gsf_infile_num_children (infile);i++)
+ for (i = 0; i<gsf_infile_num_children (infile); i++)
+ {
+ if (ret != 0)
+ break;
+ if (NULL == (name = gsf_infile_name_by_index (infile, i)))
+ continue;
+ if ( ( (0 == strcmp (name, "1Table")) ||
+ (0 == strcmp (name, "0Table")) ) &&
+ (NULL != (src = gsf_infile_child_by_index (infile, i))) )
{
- if (ret != 0)
- break;
- if (NULL == (name = gsf_infile_name_by_index (infile, i)))
- continue;
- if ( ( (0 == strcmp (name, "1Table")) ||
- (0 == strcmp (name, "0Table")) ) &&
- (NULL != (src = gsf_infile_child_by_index (infile, i))) )
- {
- ret = history_extract (src,
- lcb,
- fcb,
- ec->proc, ec->cls);
- g_object_unref (G_OBJECT (src));
- }
+ ret = history_extract (src,
+ lcb,
+ fcb,
+ ec->proc, ec->cls);
+ g_object_unref (G_OBJECT (src));
}
- CLEANUP:
+ }
+CLEANUP:
g_object_unref (G_OBJECT (infile));
g_object_unref (G_OBJECT (input));
}
@@ -1031,18 +1041,18 @@ nolog (const gchar *log_domain,
* gsf logging is disabled.
*/
void __attribute__ ((constructor))
-ole2_ltdl_init()
+ole2_ltdl_init ()
{
-#if !GLIB_CHECK_VERSION(2, 35, 0)
+#if ! GLIB_CHECK_VERSION (2, 35, 0)
g_type_init ();
#endif
#ifdef HAVE_GSF_INIT
- gsf_init();
+ gsf_init ();
#endif
/* disable logging -- thanks, Jody! */
g_log_set_handler ("libgsf:msole",
- G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING,
- &nolog, NULL);
+ G_LOG_LEVEL_CRITICAL | G_LOG_LEVEL_WARNING,
+ &nolog, NULL);
}
@@ -1050,10 +1060,10 @@ ole2_ltdl_init()
* OLE2 plugin destructor. Shutdown of gsf.
*/
void __attribute__ ((destructor))
-ole2_ltdl_fini()
+ole2_ltdl_fini ()
{
#ifdef HAVE_GSF_INIT
- gsf_shutdown();
+ gsf_shutdown ();
#endif
}
diff --git a/src/plugins/pdf_extractor.c b/src/plugins/pdf_extractor.c
@@ -80,8 +80,8 @@ static struct Matches tmap[] = {
*/
static void
process_stdout (FILE *fout,
- EXTRACTOR_MetaDataProcessor proc,
- void *proc_cls)
+ EXTRACTOR_MetaDataProcessor proc,
+ void *proc_cls)
{
unsigned int i;
char line[1025];
@@ -89,38 +89,38 @@ process_stdout (FILE *fout,
const char *colon;
while (! feof (fout))
+ {
+ if (NULL == fgets (line, sizeof (line) - 1, fout))
+ break;
+ if (0 == strlen (line))
+ continue;
+ if ('\n' == line[strlen (line) - 1])
+ line[strlen (line) - 1] = '\0';
+ colon = strchr (line, (int) ':');
+ if (NULL == colon)
+ break;
+ psuffix = colon + 1;
+ while (isblank ((unsigned char) psuffix[0]))
+ psuffix++;
+ if (0 == strlen (psuffix))
+ continue;
+ for (i = 0; NULL != tmap[i].text; i++)
{
- if (NULL == fgets (line, sizeof (line) - 1, fout))
- break;
- if (0 == strlen (line))
- continue;
- if ('\n' == line[strlen(line)-1])
- line[strlen(line)-1] = '\0';
- colon = strchr (line, (int) ':');
- if (NULL == colon)
- break;
- psuffix = colon + 1;
- while (isblank ((unsigned char) psuffix[0]))
- psuffix++;
- if (0 == strlen (psuffix))
+ if (0 != strncasecmp (line,
+ tmap[i].text,
+ colon - line))
continue;
- for (i = 0; NULL != tmap[i].text; i++)
- {
- if (0 != strncasecmp (line,
- tmap[i].text,
- colon - line))
- continue;
- if (0 != proc (proc_cls,
- "pdf",
- tmap[i].type,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- psuffix,
- strlen(psuffix) + 1))
- return;
- break;
- }
+ if (0 != proc (proc_cls,
+ "pdf",
+ tmap[i].type,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ psuffix,
+ strlen (psuffix) + 1))
+ return;
+ break;
}
+ }
}
@@ -154,79 +154,79 @@ EXTRACTOR_pdf_extract_method (struct EXTRACTOR_ExtractContext *ec)
if (0 != pipe (in))
return;
if (0 != pipe (out))
- {
- close (in[0]);
- close (in[1]);
- return;
- }
+ {
+ close (in[0]);
+ close (in[1]);
+ return;
+ }
pid = fork ();
if (-1 == pid)
- {
- close (in[0]);
- close (in[1]);
- close (out[0]);
- close (out[1]);
- return;
- }
+ {
+ close (in[0]);
+ close (in[1]);
+ close (out[0]);
+ close (out[1]);
+ return;
+ }
if (0 == pid)
- {
- char *const args[] = {
- "pdfinfo",
- "-",
- NULL
- };
- /* am child, exec 'pdfinfo' */
- close (0);
- close (1);
- if ( (-1 == dup2 (in[0], 0)) ||
- (-1 == dup2 (out[1], 1)) )
- exit (1);
- close (in[0]);
- close (in[1]);
- close (out[0]);
- close (out[1]);
- execvp ("pdfinfo", args);
+ {
+ char *const args[] = {
+ "pdfinfo",
+ "-",
+ NULL
+ };
+ /* am child, exec 'pdfinfo' */
+ close (0);
+ close (1);
+ if ( (-1 == dup2 (in[0], 0)) ||
+ (-1 == dup2 (out[1], 1)) )
exit (1);
- }
+ close (in[0]);
+ close (in[1]);
+ close (out[0]);
+ close (out[1]);
+ execvp ("pdfinfo", args);
+ exit (1);
+ }
/* am parent, send file */
close (in[0]);
close (out[1]);
fout = fdopen (out[0], "r");
if (NULL == fout)
- {
- close (in[1]);
- close (out[0]);
- kill (pid, SIGKILL);
- waitpid (pid, NULL, 0);
- return;
- }
+ {
+ close (in[1]);
+ close (out[0]);
+ kill (pid, SIGKILL);
+ waitpid (pid, NULL, 0);
+ return;
+ }
pos = 0;
while (pos < fsize)
+ {
+ ssize_t got;
+ size_t wpos;
+
+ data = NULL;
+ got = ec->read (ec->cls,
+ &data,
+ fsize - pos);
+ if ( (-1 == got) ||
+ (NULL == data) )
+ break;
+ wpos = 0;
+ while (wpos < got)
{
- ssize_t got;
- size_t wpos;
-
- data = NULL;
- got = ec->read (ec->cls,
- &data,
- fsize - pos);
- if ( (-1 == got) ||
- (NULL == data) )
- break;
- wpos = 0;
- while (wpos < got)
- {
- ssize_t out;
-
- out = write (in[1], data + wpos, got - wpos);
- if (out <= 0)
- break;
- wpos += out;
- }
- if (wpos < got)
+ ssize_t out;
+
+ out = write (in[1], data + wpos, got - wpos);
+ if (out <= 0)
break;
- pos += got;
+ wpos += out;
}
+ if (wpos < got)
+ break;
+ pos += got;
+ }
close (in[1]);
process_stdout (fout, ec->proc, ec->cls);
fclose (fout);
@@ -234,4 +234,5 @@ EXTRACTOR_pdf_extract_method (struct EXTRACTOR_ExtractContext *ec)
waitpid (pid, NULL, 0);
}
+
/* end of pdf_extractor.c */
diff --git a/src/plugins/png_extractor.c b/src/plugins/png_extractor.c
@@ -43,7 +43,7 @@
*/
static char *
stndup (const char *str,
- size_t n)
+ size_t n)
{
char *tmp;
@@ -67,13 +67,13 @@ stndup (const char *str,
*/
static size_t
stnlen (const char *str,
- size_t maxlen)
+ size_t maxlen)
{
size_t ret;
ret = 0;
while ( (ret < maxlen) &&
- ('\0' != str[ret]) )
+ ('\0' != str[ret]) )
ret++;
return ret;
}
@@ -111,8 +111,7 @@ static struct
* Corresponding LE type.
*/
enum EXTRACTOR_MetaType type;
-} tagmap[] =
-{
+} tagmap[] = {
{ "Author", EXTRACTOR_METATYPE_AUTHOR_NAME },
{ "Description", EXTRACTOR_METATYPE_DESCRIPTION },
{ "Comment", EXTRACTOR_METATYPE_COMMENT },
@@ -135,7 +134,11 @@ static struct
* @param t type of the metadata
* @param s utf8 string with the metadata
*/
-#define ADD(t,s) do { if (0 != (ret = ec->proc (ec->cls, "png", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1))) goto FINISH; } while (0)
+#define ADD(t,s) do { if (0 != (ret = ec->proc (ec->cls, "png", t, \
+ EXTRACTOR_METAFORMAT_UTF8, \
+ "text/plain", s, strlen (s) \
+ + 1))) goto FINISH; \
+} while (0)
/**
@@ -145,7 +148,14 @@ static struct
* @param t type of the metadata
* @param s utf8 string with the metadata, to be freed afterwards
*/
-#define ADDF(t,s) do { if ( (NULL != s) && (0 != (ret = ec->proc (ec->cls, "png", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1))) ) { free (s); goto FINISH; } if (NULL != s) free (s); } while (0)
+#define ADDF(t,s) do { if ( (NULL != s) && (0 != (ret = ec->proc (ec->cls, \
+ "png", t, \
+ EXTRACTOR_METAFORMAT_UTF8, \
+ "text/plain", \
+ s, strlen (s) \
+ + 1))) ) { \
+ free (s); goto FINISH; } if (NULL != s) free (s); \
+} while (0)
/**
@@ -173,16 +183,16 @@ processtEXt (struct EXTRACTOR_ExtractContext *ec,
if (off >= length)
return 0; /* failed to find '\0' */
if (NULL == (keyword = EXTRACTOR_common_convert_to_utf8 ((char*) &data[off],
- length - off,
- "ISO-8859-1")))
+ length - off,
+ "ISO-8859-1")))
return 0;
ret = 0;
for (i = 0; NULL != tagmap[i].name; i++)
if (0 == strcmp (tagmap[i].name, (char*) data))
- {
- ADDF (tagmap[i].type, keyword);
- return 0;
- }
+ {
+ ADDF (tagmap[i].type, keyword);
+ return 0;
+ }
ADDF (EXTRACTOR_METATYPE_KEYWORDS, keyword);
FINISH:
return ret;
@@ -242,50 +252,50 @@ processiTXt (struct EXTRACTOR_ExtractContext *ec,
return 0;
if (compressed)
+ {
+ bufLen = 1024 + 2 * (length - pos);
+ while (1)
{
- bufLen = 1024 + 2 * (length - pos);
- while (1)
- {
- if (bufLen * 2 < bufLen)
- return 0;
- bufLen *= 2;
- if (bufLen > 50 * (length - pos))
- {
- /* printf("zlib problem"); */
- return 0;
- }
- if (NULL == (buf = malloc (bufLen)))
- {
- /* printf("out of memory"); */
- return 0; /* out of memory */
- }
- if (Z_OK ==
- (zret = uncompress ((Bytef *) buf,
- &bufLen,
- (const Bytef *) &data[pos], length - pos)))
- {
- /* printf("zlib ok"); */
- break;
- }
- free (buf);
- if (Z_BUF_ERROR != zret)
- return 0; /* unknown error, abort */
- }
- keyword = stndup (buf, bufLen);
+ if (bufLen * 2 < bufLen)
+ return 0;
+ bufLen *= 2;
+ if (bufLen > 50 * (length - pos))
+ {
+ /* printf("zlib problem"); */
+ return 0;
+ }
+ if (NULL == (buf = malloc (bufLen)))
+ {
+ /* printf("out of memory"); */
+ return 0; /* out of memory */
+ }
+ if (Z_OK ==
+ (zret = uncompress ((Bytef *) buf,
+ &bufLen,
+ (const Bytef *) &data[pos], length - pos)))
+ {
+ /* printf("zlib ok"); */
+ break;
+ }
free (buf);
+ if (Z_BUF_ERROR != zret)
+ return 0; /* unknown error, abort */
}
+ keyword = stndup (buf, bufLen);
+ free (buf);
+ }
else
- {
- keyword = stndup ((char *) &data[pos], length - pos);
- }
+ {
+ keyword = stndup ((char *) &data[pos], length - pos);
+ }
if (NULL == keyword)
return ret;
for (i = 0; NULL != tagmap[i].name; i++)
if (0 == strcmp (tagmap[i].name, (char*) data))
- {
- ADDF (tagmap[i].type, keyword /* already in utf8 */);
- return 0;
- }
+ {
+ ADDF (tagmap[i].type, keyword /* already in utf8 */);
+ return 0;
+ }
ADDF (EXTRACTOR_METATYPE_COMMENT, keyword);
FINISH:
return ret;
@@ -357,43 +367,43 @@ processzTXt (struct EXTRACTOR_ExtractContext *ec,
ret = 0;
bufLen = 1024 + 2 * (length - off);
while (1)
+ {
+ if (bufLen * 2 < bufLen)
+ return 0;
+ bufLen *= 2;
+ if (bufLen > 50 * (length - off))
{
- if (bufLen * 2 < bufLen)
- return 0;
- bufLen *= 2;
- if (bufLen > 50 * (length - off))
- {
- /* printf("zlib problem"); */
- return 0;
- }
- if (NULL == (buf = malloc (bufLen)))
- {
- /* printf("out of memory"); */
- return 0; /* out of memory */
- }
- if (Z_OK ==
- (zret = uncompress ((Bytef *) buf,
- &bufLen,
- (const Bytef *) &data[off],
- length - off)))
- {
- /* printf("zlib ok"); */
- break;
- }
- free (buf);
- if (Z_BUF_ERROR != zret)
- return 0; /* unknown error, abort */
+ /* printf("zlib problem"); */
+ return 0;
+ }
+ if (NULL == (buf = malloc (bufLen)))
+ {
+ /* printf("out of memory"); */
+ return 0; /* out of memory */
+ }
+ if (Z_OK ==
+ (zret = uncompress ((Bytef *) buf,
+ &bufLen,
+ (const Bytef *) &data[off],
+ length - off)))
+ {
+ /* printf("zlib ok"); */
+ break;
}
+ free (buf);
+ if (Z_BUF_ERROR != zret)
+ return 0; /* unknown error, abort */
+ }
keyword = EXTRACTOR_common_convert_to_utf8 (buf,
- bufLen,
- "ISO-8859-1");
+ bufLen,
+ "ISO-8859-1");
free (buf);
for (i = 0; NULL != tagmap[i].name; i++)
if (0 == strcmp (tagmap[i].name, (char*) data))
- {
- ADDF (tagmap[i].type, keyword);
- return 0;
- }
+ {
+ ADDF (tagmap[i].type, keyword);
+ return 0;
+ }
ADDF (EXTRACTOR_METATYPE_COMMENT, keyword);
FINISH:
return ret;
@@ -437,9 +447,9 @@ processtIME (struct EXTRACTOR_ExtractContext *ec,
m = (unsigned char) data[9];
s = (unsigned char) data[10];
snprintf (val,
- sizeof (val),
- "%04u-%02u-%02u %02d:%02d:%02d",
- year, mo, day, h, m, s);
+ sizeof (val),
+ "%04u-%02u-%02u %02d:%02d:%02d",
+ year, mo, day, h, m, s);
ADD (EXTRACTOR_METATYPE_MODIFICATION_DATE, val);
FINISH:
return ret;
@@ -468,32 +478,33 @@ EXTRACTOR_png_extract_method (struct EXTRACTOR_ExtractContext *ec)
ADD (EXTRACTOR_METATYPE_MIMETYPE, "image/png");
ret = 0;
while (0 == ret)
- {
- if (sizeof (uint32_t) + 4 != ec->read (ec->cls,
- &data,
- sizeof (uint32_t) + 4))
- break;
- length = get_int_at (data);
- if (0 > (pos = ec->seek (ec->cls, 0, SEEK_CUR)))
- break;
- pos += length + 4; /* Chunk type, data, crc */
- if (0 == strncmp ((char*) data + sizeof (uint32_t), "IHDR", 4))
- ret = processIHDR (ec, length);
- if (0 == strncmp ((char*) data + sizeof (uint32_t), "iTXt", 4))
- ret = processiTXt (ec, length);
- if (0 == strncmp ((char*) data + sizeof (uint32_t), "tEXt", 4))
- ret = processtEXt (ec, length);
- if (0 == strncmp ((char*) data + sizeof (uint32_t), "zTXt", 4))
- ret = processzTXt (ec, length);
- if (0 == strncmp ((char*) data + sizeof (uint32_t), "tIME", 4))
- ret = processtIME (ec, length);
- if (ret != 0)
- break;
- if (pos != ec->seek (ec->cls, pos, SEEK_SET))
- break;
- }
+ {
+ if (sizeof (uint32_t) + 4 != ec->read (ec->cls,
+ &data,
+ sizeof (uint32_t) + 4))
+ break;
+ length = get_int_at (data);
+ if (0 > (pos = ec->seek (ec->cls, 0, SEEK_CUR)))
+ break;
+ pos += length + 4; /* Chunk type, data, crc */
+ if (0 == strncmp ((char*) data + sizeof (uint32_t), "IHDR", 4))
+ ret = processIHDR (ec, length);
+ if (0 == strncmp ((char*) data + sizeof (uint32_t), "iTXt", 4))
+ ret = processiTXt (ec, length);
+ if (0 == strncmp ((char*) data + sizeof (uint32_t), "tEXt", 4))
+ ret = processtEXt (ec, length);
+ if (0 == strncmp ((char*) data + sizeof (uint32_t), "zTXt", 4))
+ ret = processzTXt (ec, length);
+ if (0 == strncmp ((char*) data + sizeof (uint32_t), "tIME", 4))
+ ret = processtIME (ec, length);
+ if (ret != 0)
+ break;
+ if (pos != ec->seek (ec->cls, pos, SEEK_SET))
+ break;
+ }
FINISH:
return;
}
+
/* end of png_extractor.c */
diff --git a/src/plugins/previewopus_extractor.c b/src/plugins/previewopus_extractor.c
@@ -65,15 +65,10 @@
#include <ffmpeg/swscale.h>
#endif
-//TODO: Check for ffmpeg
+// TODO: Check for ffmpeg
#include <libavresample/avresample.h>
-
-
-
-
-
/**
* Set to 1 to enable debug output.
*/
@@ -85,16 +80,15 @@
#define OUTPUT_FILE 0
-
/**
* Maximum size in bytes for the preview.
*/
-#define MAX_SIZE (28*1024)
+#define MAX_SIZE (28 * 1024)
/**
* HardLimit for file
*/
-#define HARD_LIMIT_SIZE (50*1024)
+#define HARD_LIMIT_SIZE (50 * 1024)
/** The output bit rate in kbit/s */
@@ -116,11 +110,12 @@ static int totalSize;
* @param error Error code to be converted
* @return Corresponding error text (not thread-safe)
*/
-static char *const get_error_text(const int error)
+static char *const
+get_error_text (const int error)
{
- static char error_buffer[255];
- av_strerror(error, error_buffer, sizeof(error_buffer));
- return error_buffer;
+ static char error_buffer[255];
+ av_strerror (error, error_buffer, sizeof(error_buffer));
+ return error_buffer;
}
@@ -134,8 +129,8 @@ static char *const get_error_text(const int error)
*/
static int
read_cb (void *opaque,
- uint8_t *buf,
- int buf_size)
+ uint8_t *buf,
+ int buf_size)
{
struct EXTRACTOR_ExtractContext *ec = opaque;
void *data;
@@ -159,8 +154,8 @@ read_cb (void *opaque,
*/
static int64_t
seek_cb (void *opaque,
- int64_t offset,
- int whence)
+ int64_t offset,
+ int whence)
{
struct EXTRACTOR_ExtractContext *ec = opaque;
@@ -185,7 +180,7 @@ writePacket (void *opaque,
{
int sizeToCopy = pBufferSize;
- if( (totalSize + pBufferSize) > HARD_LIMIT_SIZE)
+ if ( (totalSize + pBufferSize) > HARD_LIMIT_SIZE)
sizeToCopy = HARD_LIMIT_SIZE - totalSize;
memcpy (buffer + totalSize, pBuffer, sizeToCopy);
@@ -199,10 +194,11 @@ writePacket (void *opaque,
* Also set some basic encoder parameters.
* Some of these parameters are based on the input file's parameters.
*/
-static int open_output_file(
- AVCodecContext *input_codec_context,
- AVFormatContext **output_format_context,
- AVCodecContext **output_codec_context)
+static int
+open_output_file (
+ AVCodecContext *input_codec_context,
+ AVFormatContext **output_format_context,
+ AVCodecContext **output_codec_context)
{
AVStream *stream = NULL;
AVCodec *output_codec = NULL;
@@ -213,50 +209,50 @@ static int open_output_file(
if (NULL == (iob = av_malloc (16 * 1024)))
return AVERROR_EXIT;
if (NULL == (io_ctx = avio_alloc_context (iob, 16 * 1024,
- AVIO_FLAG_WRITE, NULL,
+ AVIO_FLAG_WRITE, NULL,
NULL,
- &writePacket /* no writing */,
- NULL)))
- {
- av_free (iob);
- return AVERROR_EXIT;
- }
+ &writePacket /* no writing */,
+ NULL)))
+ {
+ av_free (iob);
+ return AVERROR_EXIT;
+ }
if (NULL == ((*output_format_context) = avformat_alloc_context ()))
- {
- av_free (io_ctx);
- return AVERROR_EXIT;
- }
+ {
+ av_free (io_ctx);
+ return AVERROR_EXIT;
+ }
(*output_format_context)->pb = io_ctx;
- /** Guess the desired container format based on the file extension. */
- if (!((*output_format_context)->oformat = av_guess_format (NULL,
- "file.ogg",
- NULL)))
- {
+ /** Guess the desired container format based on the file extension. */
+ if (! ((*output_format_context)->oformat = av_guess_format (NULL,
+ "file.ogg",
+ NULL)))
+ {
#if DEBUG
- fprintf(stderr, "Could not find output file format\n");
+ fprintf (stderr, "Could not find output file format\n");
#endif
- goto cleanup;
- }
+ goto cleanup;
+ }
/** Find the encoder to be used by its name. */
- if (!(output_codec = avcodec_find_encoder(AV_CODEC_ID_OPUS)))
- {
+ if (! (output_codec = avcodec_find_encoder (AV_CODEC_ID_OPUS)))
+ {
#if DEBUG
- fprintf(stderr, "Could not find an OPUS encoder.\n");
+ fprintf (stderr, "Could not find an OPUS encoder.\n");
#endif
- goto cleanup;
- }
+ goto cleanup;
+ }
/** Create a new audio stream in the output file container. */
- if (!(stream = avformat_new_stream(*output_format_context, output_codec)))
- {
+ if (! (stream = avformat_new_stream (*output_format_context, output_codec)))
+ {
#if DEBUG
- fprintf(stderr, "Could not create new stream\n");
+ fprintf (stderr, "Could not create new stream\n");
#endif
- error = AVERROR(ENOMEM);
- goto cleanup;
- }
+ error = AVERROR (ENOMEM);
+ goto cleanup;
+ }
/** Save the encoder context for easiert access later. */
*output_codec_context = stream->codec;
@@ -266,20 +262,21 @@ static int open_output_file(
* The input file's sample rate is used to avoid a sample rate conversion.
*/
(*output_codec_context)->channels = OUTPUT_CHANNELS;
- (*output_codec_context)->channel_layout = av_get_default_channel_layout(OUTPUT_CHANNELS);
- (*output_codec_context)->sample_rate = 48000; //Opus need 48000
+ (*output_codec_context)->channel_layout = av_get_default_channel_layout (
+ OUTPUT_CHANNELS);
+ (*output_codec_context)->sample_rate = 48000; // Opus need 48000
(*output_codec_context)->sample_fmt = AV_SAMPLE_FMT_S16;
(*output_codec_context)->bit_rate = OUTPUT_BIT_RATE;
/** Open the encoder for the audio stream to use it later. */
- if ((error = avcodec_open2(*output_codec_context, output_codec, NULL)) < 0)
- {
+ if ((error = avcodec_open2 (*output_codec_context, output_codec, NULL)) < 0)
+ {
#if DEBUG
- fprintf(stderr, "Could not open output codec (error '%s')\n",
- get_error_text(error));
+ fprintf (stderr, "Could not open output codec (error '%s')\n",
+ get_error_text (error));
#endif
- goto cleanup;
- }
+ goto cleanup;
+ }
return 0;
cleanup:
@@ -290,9 +287,9 @@ cleanup:
/** Initialize one data packet for reading or writing. */
static void
-init_packet(AVPacket *packet)
+init_packet (AVPacket *packet)
{
- av_init_packet(packet);
+ av_init_packet (packet);
/** Set the packet data and size so that it is recognized as being empty. */
packet->data = NULL;
packet->size = 0;
@@ -301,20 +298,20 @@ init_packet(AVPacket *packet)
/** Initialize one audio frame for reading from the input file */
static int
-init_input_frame(AVFrame **frame)
+init_input_frame (AVFrame **frame)
{
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
*frame = av_frame_alloc ();
#else
- *frame = avcodec_alloc_frame();
+ *frame = avcodec_alloc_frame ();
#endif
if (NULL == *frame)
- {
+ {
#if DEBUG
- fprintf(stderr, "Could not allocate input frame\n");
+ fprintf (stderr, "Could not allocate input frame\n");
#endif
- return AVERROR(ENOMEM);
- }
+ return AVERROR (ENOMEM);
+ }
return 0;
}
@@ -329,527 +326,591 @@ init_resampler (AVCodecContext *input_codec_context,
AVCodecContext *output_codec_context,
AVAudioResampleContext **resample_context)
{
- /**
- * Only initialize the resampler if it is necessary, i.e.,
- * if and only if the sample formats differ.
- */
- if (input_codec_context->sample_fmt != output_codec_context->sample_fmt ||
- input_codec_context->channels != output_codec_context->channels) {
- int error;
+ /**
+ * Only initialize the resampler if it is necessary, i.e.,
+ * if and only if the sample formats differ.
+ */
+ if ((input_codec_context->sample_fmt != output_codec_context->sample_fmt) ||
+ (input_codec_context->channels != output_codec_context->channels) )
+ {
+ int error;
- /** Create a resampler context for the conversion. */
- if (!(*resample_context = avresample_alloc_context())) {
+ /** Create a resampler context for the conversion. */
+ if (! (*resample_context = avresample_alloc_context ()))
+ {
#if DEBUG
- fprintf(stderr, "Could not allocate resample context\n");
+ fprintf (stderr, "Could not allocate resample context\n");
#endif
- return AVERROR(ENOMEM);
- }
-
-
- /**
- * Set the conversion parameters.
- * Default channel layouts based on the number of channels
- * are assumed for simplicity (they are sometimes not detected
- * properly by the demuxer and/or decoder).
- */
- av_opt_set_int(*resample_context, "in_channel_layout",
- av_get_default_channel_layout(input_codec_context->channels), 0);
- av_opt_set_int(*resample_context, "out_channel_layout",
- av_get_default_channel_layout(output_codec_context->channels), 0);
- av_opt_set_int(*resample_context, "in_sample_rate",
- input_codec_context->sample_rate, 0);
- av_opt_set_int(*resample_context, "out_sample_rate",
- output_codec_context->sample_rate, 0);
- av_opt_set_int(*resample_context, "in_sample_fmt",
- input_codec_context->sample_fmt, 0);
- av_opt_set_int(*resample_context, "out_sample_fmt",
- output_codec_context->sample_fmt, 0);
-
- /** Open the resampler with the specified parameters. */
- if ((error = avresample_open(*resample_context)) < 0) {
+ return AVERROR (ENOMEM);
+ }
+
+
+ /**
+ * Set the conversion parameters.
+ * Default channel layouts based on the number of channels
+ * are assumed for simplicity (they are sometimes not detected
+ * properly by the demuxer and/or decoder).
+ */av_opt_set_int (*resample_context, "in_channel_layout",
+ av_get_default_channel_layout (
+ input_codec_context->channels), 0);
+ av_opt_set_int (*resample_context, "out_channel_layout",
+ av_get_default_channel_layout (
+ output_codec_context->channels), 0);
+ av_opt_set_int (*resample_context, "in_sample_rate",
+ input_codec_context->sample_rate, 0);
+ av_opt_set_int (*resample_context, "out_sample_rate",
+ output_codec_context->sample_rate, 0);
+ av_opt_set_int (*resample_context, "in_sample_fmt",
+ input_codec_context->sample_fmt, 0);
+ av_opt_set_int (*resample_context, "out_sample_fmt",
+ output_codec_context->sample_fmt, 0);
+
+ /** Open the resampler with the specified parameters. */
+ if ((error = avresample_open (*resample_context)) < 0)
+ {
#if DEBUG
- fprintf(stderr, "Could not open resample context\n");
+ fprintf (stderr, "Could not open resample context\n");
#endif
- avresample_free(resample_context);
- return error;
- }
+ avresample_free (resample_context);
+ return error;
}
- return 0;
+ }
+ return 0;
}
+
/** Initialize a FIFO buffer for the audio samples to be encoded. */
-static int init_fifo(AVAudioFifo **fifo)
+static int
+init_fifo (AVAudioFifo **fifo)
{
- /** Create the FIFO buffer based on the specified output sample format. */
- if (!(*fifo = av_audio_fifo_alloc(OUTPUT_SAMPLE_FORMAT, OUTPUT_CHANNELS, 1))) {
+ /** Create the FIFO buffer based on the specified output sample format. */
+ if (! (*fifo = av_audio_fifo_alloc (OUTPUT_SAMPLE_FORMAT, OUTPUT_CHANNELS,
+ 1)))
+ {
#if DEBUG
- fprintf(stderr, "Could not allocate FIFO\n");
+ fprintf (stderr, "Could not allocate FIFO\n");
#endif
- return AVERROR(ENOMEM);
- }
- return 0;
+ return AVERROR (ENOMEM);
+ }
+ return 0;
}
+
/** Write the header of the output file container. */
-static int write_output_file_header(AVFormatContext *output_format_context)
+static int
+write_output_file_header (AVFormatContext *output_format_context)
{
- int error;
- if ((error = avformat_write_header(output_format_context, NULL)) < 0) {
+ int error;
+ if ((error = avformat_write_header (output_format_context, NULL)) < 0)
+ {
#if DEBUG
- fprintf(stderr, "Could not write output file header (error '%s')\n",
- get_error_text(error));
+ fprintf (stderr, "Could not write output file header (error '%s')\n",
+ get_error_text (error));
#endif
- return error;
- }
- return 0;
+ return error;
+ }
+ return 0;
}
+
/** Decode one audio frame from the input file. */
-static int decode_audio_frame(AVFrame *frame,
- AVFormatContext *input_format_context,
- AVCodecContext *input_codec_context, int audio_stream_index,
- int *data_present, int *finished)
+static int
+decode_audio_frame (AVFrame *frame,
+ AVFormatContext *input_format_context,
+ AVCodecContext *input_codec_context, int audio_stream_index,
+ int *data_present, int *finished)
{
- /** Packet used for temporary storage. */
- AVPacket input_packet;
- int error;
- init_packet(&input_packet);
+ /** Packet used for temporary storage. */
+ AVPacket input_packet;
+ int error;
+ init_packet (&input_packet);
- /** Read one audio frame from the input file into a temporary packet. */
- while(1){
- if ((error = av_read_frame(input_format_context, &input_packet)) < 0) {
- /** If we are the the end of the file, flush the decoder below. */
- if (error == AVERROR_EOF){
+ /** Read one audio frame from the input file into a temporary packet. */
+ while (1)
+ {
+ if ((error = av_read_frame (input_format_context, &input_packet)) < 0)
+ {
+ /** If we are the the end of the file, flush the decoder below. */
+ if (error == AVERROR_EOF)
+ {
#if DEBUG
- fprintf(stderr, "EOF in decode_audio\n");
+ fprintf (stderr, "EOF in decode_audio\n");
#endif
- *finished = 1;
- }
- else {
+ *finished = 1;
+ }
+ else
+ {
#if DEBUG
- fprintf(stderr, "Could not read frame (error '%s')\n",
- get_error_text(error));
+ fprintf (stderr, "Could not read frame (error '%s')\n",
+ get_error_text (error));
#endif
- return error;
- }
- }
+ return error;
+ }
+ }
- if(input_packet.stream_index == audio_stream_index)
- break;
- }
+ if (input_packet.stream_index == audio_stream_index)
+ break;
+ }
- /**
- * Decode the audio frame stored in the temporary packet.
- * The input audio stream decoder is used to do this.
- * If we are at the end of the file, pass an empty packet to the decoder
- * to flush it.
- */
- if ((error = avcodec_decode_audio4(input_codec_context, frame,
- data_present, &input_packet)) < 0) {
+ /**
+ * Decode the audio frame stored in the temporary packet.
+ * The input audio stream decoder is used to do this.
+ * If we are at the end of the file, pass an empty packet to the decoder
+ * to flush it.
+ */if ((error = avcodec_decode_audio4 (input_codec_context, frame,
+ data_present, &input_packet)) < 0)
+ {
#if DEBUG
- fprintf(stderr, "Could not decode frame (error '%s')\n",
- get_error_text(error));
+ fprintf (stderr, "Could not decode frame (error '%s')\n",
+ get_error_text (error));
#endif
- av_free_packet(&input_packet);
- return error;
- }
+ av_free_packet (&input_packet);
+ return error;
+ }
- /**
- * If the decoder has not been flushed completely, we are not finished,
- * so that this function has to be called again.
- */
- if (*finished && *data_present)
- *finished = 0;
- av_free_packet(&input_packet);
- return 0;
+ /**
+ * If the decoder has not been flushed completely, we are not finished,
+ * so that this function has to be called again.
+ */
+ if (*finished && *data_present)
+ *finished = 0;
+ av_free_packet (&input_packet);
+ return 0;
}
+
/**
* Initialize a temporary storage for the specified number of audio samples.
* The conversion requires temporary storage due to the different format.
* The number of audio samples to be allocated is specified in frame_size.
*/
-static int init_converted_samples(uint8_t ***converted_input_samples, int* out_linesize,
- AVCodecContext *output_codec_context,
- int frame_size)
+static int
+init_converted_samples (uint8_t ***converted_input_samples, int*out_linesize,
+ AVCodecContext *output_codec_context,
+ int frame_size)
{
- int error;
+ int error;
- /**
- * Allocate as many pointers as there are audio channels.
- * Each pointer will later point to the audio samples of the corresponding
- * channels (although it may be NULL for interleaved formats).
- */
- if (!(*converted_input_samples = calloc(output_codec_context->channels,
- sizeof(**converted_input_samples)))) {
+ /**
+ * Allocate as many pointers as there are audio channels.
+ * Each pointer will later point to the audio samples of the corresponding
+ * channels (although it may be NULL for interleaved formats).
+ */if (! (*converted_input_samples = calloc (output_codec_context->channels,
+ sizeof(**converted_input_samples))))
+ {
#if DEBUG
- fprintf(stderr, "Could not allocate converted input sample pointers\n");
+ fprintf (stderr, "Could not allocate converted input sample pointers\n");
#endif
- return AVERROR(ENOMEM);
- }
+ return AVERROR (ENOMEM);
+ }
- /**
- * Allocate memory for the samples of all channels in one consecutive
- * block for convenience.
- */
- if ((error = av_samples_alloc(*converted_input_samples, out_linesize,
- output_codec_context->channels,
- frame_size,
- output_codec_context->sample_fmt, 0)) < 0) {
+ /**
+ * Allocate memory for the samples of all channels in one consecutive
+ * block for convenience.
+ */
+ if ((error = av_samples_alloc (*converted_input_samples, out_linesize,
+ output_codec_context->channels,
+ frame_size,
+ output_codec_context->sample_fmt, 0)) < 0)
+ {
#if DEBUG
- fprintf(stderr,
- "Could not allocate converted input samples (error '%s')\n",
- get_error_text(error));
+ fprintf (stderr,
+ "Could not allocate converted input samples (error '%s')\n",
+ get_error_text (error));
#endif
- av_freep(&(*converted_input_samples)[0]);
- free(*converted_input_samples);
- return error;
- }
- return 0;
+ av_freep (&(*converted_input_samples)[0]);
+ free (*converted_input_samples);
+ return error;
+ }
+ return 0;
}
+
/**
* Convert the input audio samples into the output sample format.
* The conversion happens on a per-frame basis, the size of which is specified
* by frame_size.
*/
-static int convert_samples(uint8_t **input_data,
- uint8_t **converted_data, const int in_sample, const int out_sample, const int out_linesize,
- AVAudioResampleContext *resample_context)
+static int
+convert_samples (uint8_t **input_data,
+ uint8_t **converted_data, const int in_sample, const int
+ out_sample, const int out_linesize,
+ AVAudioResampleContext *resample_context)
{
- int error;
+ int error;
- /** Convert the samples using the resampler. */
- if ((error = avresample_convert(resample_context, converted_data, out_linesize,
- out_sample, input_data, 0, in_sample)) < 0) {
+ /** Convert the samples using the resampler. */
+ if ((error = avresample_convert (resample_context, converted_data,
+ out_linesize,
+ out_sample, input_data, 0, in_sample)) < 0)
+ {
#if DEBUG
- fprintf(stderr, "Could not convert input samples (error '%s')\n",
- get_error_text(error));
+ fprintf (stderr, "Could not convert input samples (error '%s')\n",
+ get_error_text (error));
#endif
- return error;
- }
+ return error;
+ }
- /**
- * Perform a sanity check so that the number of converted samples is
- * not greater than the number of samples to be converted.
- * If the sample rates differ, this case has to be handled differently
- */
- if (avresample_available(resample_context)) {
+ /**
+ * Perform a sanity check so that the number of converted samples is
+ * not greater than the number of samples to be converted.
+ * If the sample rates differ, this case has to be handled differently
+ */if (avresample_available (resample_context))
+ {
#if DEBUG
- fprintf(stderr, "%i Converted samples left over\n",avresample_available(resample_context));
+ fprintf (stderr, "%i Converted samples left over\n",avresample_available (
+ resample_context));
#endif
- }
+ }
- return 0;
+ return 0;
}
+
/** Add converted input audio samples to the FIFO buffer for later processing. */
-static int add_samples_to_fifo(AVAudioFifo *fifo,
- uint8_t **converted_input_samples,
- const int frame_size)
+static int
+add_samples_to_fifo (AVAudioFifo *fifo,
+ uint8_t **converted_input_samples,
+ const int frame_size)
{
- int error;
+ int error;
- /**
- * Make the FIFO as large as it needs to be to hold both,
- * the old and the new samples.
- */
- if ((error = av_audio_fifo_realloc(fifo, av_audio_fifo_size(fifo) + frame_size)) < 0) {
+ /**
+ * Make the FIFO as large as it needs to be to hold both,
+ * the old and the new samples.
+ */
+ if ((error = av_audio_fifo_realloc (fifo, av_audio_fifo_size (fifo)
+ + frame_size)) < 0)
+ {
#if DEBUG
- fprintf(stderr, "Could not reallocate FIFO\n");
+ fprintf (stderr, "Could not reallocate FIFO\n");
#endif
- return error;
- }
+ return error;
+ }
- /** Store the new samples in the FIFO buffer. */
- if (av_audio_fifo_write(fifo, (void **)converted_input_samples,
- frame_size) < frame_size) {
+ /** Store the new samples in the FIFO buffer. */
+ if (av_audio_fifo_write (fifo, (void **) converted_input_samples,
+ frame_size) < frame_size)
+ {
#if DEBUG
- fprintf(stderr, "Could not write data to FIFO\n");
+ fprintf (stderr, "Could not write data to FIFO\n");
#endif
- return AVERROR_EXIT;
- }
- return 0;
+ return AVERROR_EXIT;
+ }
+ return 0;
}
+
/**
* Read one audio frame from the input file, decodes, converts and stores
* it in the FIFO buffer.
*/
-static int read_decode_convert_and_store(AVAudioFifo *fifo,
- AVFormatContext *input_format_context,
- AVCodecContext *input_codec_context,
- AVCodecContext *output_codec_context,
- AVAudioResampleContext *resampler_context, int audio_stream_index,
- int *finished)
+static int
+read_decode_convert_and_store (AVAudioFifo *fifo,
+ AVFormatContext *input_format_context,
+ AVCodecContext *input_codec_context,
+ AVCodecContext *output_codec_context,
+ AVAudioResampleContext *resampler_context, int
+ audio_stream_index,
+ int *finished)
{
- /** Temporary storage of the input samples of the frame read from the file. */
- AVFrame *input_frame = NULL;
- /** Temporary storage for the converted input samples. */
- uint8_t **converted_input_samples = NULL;
- int data_present;
- int ret = AVERROR_EXIT;
-
- /** Initialize temporary storage for one input frame. */
- if (init_input_frame(&input_frame)){
+ /** Temporary storage of the input samples of the frame read from the file. */
+ AVFrame *input_frame = NULL;
+ /** Temporary storage for the converted input samples. */
+ uint8_t **converted_input_samples = NULL;
+ int data_present;
+ int ret = AVERROR_EXIT;
+
+ /** Initialize temporary storage for one input frame. */
+ if (init_input_frame (&input_frame))
+ {
#if DEBUG
- fprintf(stderr, "Failed at init frame\n");
+ fprintf (stderr, "Failed at init frame\n");
#endif
- goto cleanup;
+ goto cleanup;
- }
- /** Decode one frame worth of audio samples. */
- if (decode_audio_frame(input_frame, input_format_context,
- input_codec_context, audio_stream_index, &data_present, finished)){
+ }
+ /** Decode one frame worth of audio samples. */
+ if (decode_audio_frame (input_frame, input_format_context,
+ input_codec_context, audio_stream_index,
+ &data_present, finished))
+ {
#if DEBUG
- fprintf(stderr, "Failed at decode audio\n");
+ fprintf (stderr, "Failed at decode audio\n");
#endif
- goto cleanup;
+ goto cleanup;
- }
- /**
- * If we are at the end of the file and there are no more samples
- * in the decoder which are delayed, we are actually finished.
- * This must not be treated as an error.
- */
- if (*finished && !data_present) {
- ret = 0;
+ }
+ /**
+ * If we are at the end of the file and there are no more samples
+ * in the decoder which are delayed, we are actually finished.
+ * This must not be treated as an error.
+ */if (*finished && ! data_present)
+ {
+ ret = 0;
#if DEBUG
- fprintf(stderr, "Failed at finished or no data\n");
+ fprintf (stderr, "Failed at finished or no data\n");
#endif
- goto cleanup;
- }
- /** If there is decoded data, convert and store it */
- if (data_present) {
- int out_linesize;
- //FIX ME: I'm losing samples, but can't get it to work.
- int out_samples = avresample_available(resampler_context) + avresample_get_delay(resampler_context) + input_frame->nb_samples;
+ goto cleanup;
+ }
+ /** If there is decoded data, convert and store it */
+ if (data_present)
+ {
+ int out_linesize;
+ // FIX ME: I'm losing samples, but can't get it to work.
+ int out_samples = avresample_available (resampler_context)
+ + avresample_get_delay (resampler_context)
+ + input_frame->nb_samples;
- //fprintf(stderr, "Input nbsamples %i out_samples: %i \n",input_frame->nb_samples,out_samples);
+ // fprintf(stderr, "Input nbsamples %i out_samples: %i \n",input_frame->nb_samples,out_samples);
- /** Initialize the temporary storage for the converted input samples. */
- if (init_converted_samples(&converted_input_samples, &out_linesize, output_codec_context,
- out_samples)){
+ /** Initialize the temporary storage for the converted input samples. */
+ if (init_converted_samples (&converted_input_samples, &out_linesize,
+ output_codec_context,
+ out_samples))
+ {
#if DEBUG
- fprintf(stderr, "Failed at init_converted_samples\n");
+ fprintf (stderr, "Failed at init_converted_samples\n");
#endif
- goto cleanup;
- }
+ goto cleanup;
+ }
- /**
- * Convert the input samples to the desired output sample format.
- * This requires a temporary storage provided by converted_input_samples.
- */
- if (convert_samples(input_frame->extended_data, converted_input_samples,
- input_frame->nb_samples, out_samples, out_linesize ,resampler_context)){
+ /**
+ * Convert the input samples to the desired output sample format.
+ * This requires a temporary storage provided by converted_input_samples.
+ */
+ if (convert_samples (input_frame->extended_data, converted_input_samples,
+ input_frame->nb_samples, out_samples, out_linesize,
+ resampler_context))
+ {
#if DEBUG
- fprintf(stderr, "Failed at convert_samples, input frame %i \n",input_frame->nb_samples);
+ fprintf (stderr, "Failed at convert_samples, input frame %i \n",
+ input_frame->nb_samples);
#endif
- goto cleanup;
- }
- /** Add the converted input samples to the FIFO buffer for later processing. */
- if (add_samples_to_fifo(fifo, converted_input_samples,
- out_samples)){
+ goto cleanup;
+ }
+ /** Add the converted input samples to the FIFO buffer for later processing. */
+ if (add_samples_to_fifo (fifo, converted_input_samples,
+ out_samples))
+ {
#if DEBUG
- fprintf(stderr, "Failed at add_samples_to_fifo\n");
+ fprintf (stderr, "Failed at add_samples_to_fifo\n");
#endif
- goto cleanup;
- }
- ret = 0;
+ goto cleanup;
}
ret = 0;
+ }
+ ret = 0;
cleanup:
- if (converted_input_samples) {
- av_freep(&converted_input_samples[0]);
- free(converted_input_samples);
- }
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
- av_frame_free (&input_frame);
+ if (converted_input_samples)
+ {
+ av_freep (&converted_input_samples[0]);
+ free (converted_input_samples);
+ }
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
+ av_frame_free (&input_frame);
#else
- avcodec_free_frame(&input_frame);
+ avcodec_free_frame (&input_frame);
#endif
- return ret;
+ return ret;
}
+
/**
* Initialize one input frame for writing to the output file.
* The frame will be exactly frame_size samples large.
*/
-static int init_output_frame(AVFrame **frame,
- AVCodecContext *output_codec_context,
- int frame_size)
+static int
+init_output_frame (AVFrame **frame,
+ AVCodecContext *output_codec_context,
+ int frame_size)
{
- int error;
+ int error;
- /** Create a new frame to store the audio samples. */
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
- *frame = av_frame_alloc ();
+ /** Create a new frame to store the audio samples. */
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
+ *frame = av_frame_alloc ();
#else
- *frame = avcodec_alloc_frame();
+ *frame = avcodec_alloc_frame ();
#endif
- if (NULL == *frame) {
+ if (NULL == *frame)
+ {
#if DEBUG
- fprintf(stderr, "Could not allocate output frame\n");
+ fprintf (stderr, "Could not allocate output frame\n");
#endif
- return AVERROR_EXIT;
- }
-
- /**
- * Set the frame's parameters, especially its size and format.
- * av_frame_get_buffer needs this to allocate memory for the
- * audio samples of the frame.
- * Default channel layouts based on the number of channels
- * are assumed for simplicity.
- */
- (*frame)->nb_samples = frame_size;
- (*frame)->channel_layout = output_codec_context->channel_layout;
- (*frame)->format = output_codec_context->sample_fmt;
- (*frame)->sample_rate = output_codec_context->sample_rate;
+ return AVERROR_EXIT;
+ }
+ /**
+ * Set the frame's parameters, especially its size and format.
+ * av_frame_get_buffer needs this to allocate memory for the
+ * audio samples of the frame.
+ * Default channel layouts based on the number of channels
+ * are assumed for simplicity.
+ */(*frame)->nb_samples = frame_size;
+ (*frame)->channel_layout = output_codec_context->channel_layout;
+ (*frame)->format = output_codec_context->sample_fmt;
+ (*frame)->sample_rate = output_codec_context->sample_rate;
- //fprintf(stderr, "%i %i \n",frame_size , (*frame)->format,(*frame)->sample_rate);
+ // fprintf(stderr, "%i %i \n",frame_size , (*frame)->format,(*frame)->sample_rate);
- /**
- * Allocate the samples of the created frame. This call will make
- * sure that the audio frame can hold as many samples as specified.
- */
- if ((error = av_frame_get_buffer(*frame, 0)) < 0) {
+ /**
+ * Allocate the samples of the created frame. This call will make
+ * sure that the audio frame can hold as many samples as specified.
+ */
+ if ((error = av_frame_get_buffer (*frame, 0)) < 0)
+ {
#if DEBUG
- fprintf(stderr, "Could allocate output frame samples (error '%s')\n", get_error_text(error));
+ fprintf (stderr, "Could allocate output frame samples (error '%s')\n",
+ get_error_text (error));
#endif
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
- av_frame_free (frame);
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
+ av_frame_free (frame);
#else
- avcodec_free_frame(frame);
+ avcodec_free_frame (frame);
#endif
- return error;
- }
+ return error;
+ }
- return 0;
+ return 0;
}
+
/** Encode one frame worth of audio to the output file. */
-static int encode_audio_frame(AVFrame *frame,
- AVFormatContext *output_format_context,
- AVCodecContext *output_codec_context,
- int *data_present)
+static int
+encode_audio_frame (AVFrame *frame,
+ AVFormatContext *output_format_context,
+ AVCodecContext *output_codec_context,
+ int *data_present)
{
- /** Packet used for temporary storage. */
- AVPacket output_packet;
- int error;
- init_packet(&output_packet);
+ /** Packet used for temporary storage. */
+ AVPacket output_packet;
+ int error;
+ init_packet (&output_packet);
- /**
- * Encode the audio frame and store it in the temporary packet.
- * The output audio stream encoder is used to do this.
- */
- if ((error = avcodec_encode_audio2(output_codec_context, &output_packet,
- frame, data_present)) < 0) {
+ /**
+ * Encode the audio frame and store it in the temporary packet.
+ * The output audio stream encoder is used to do this.
+ */
+ if ((error = avcodec_encode_audio2 (output_codec_context, &output_packet,
+ frame, data_present)) < 0)
+ {
#if DEBUG
- fprintf(stderr, "Could not encode frame (error '%s')\n",
- get_error_text(error));
+ fprintf (stderr, "Could not encode frame (error '%s')\n",
+ get_error_text (error));
#endif
- av_free_packet(&output_packet);
- return error;
- }
+ av_free_packet (&output_packet);
+ return error;
+ }
- /** Write one audio frame from the temporary packet to the output file. */
- if (*data_present) {
- if ((error = av_write_frame(output_format_context, &output_packet)) < 0) {
+ /** Write one audio frame from the temporary packet to the output file. */
+ if (*data_present)
+ {
+ if ((error = av_write_frame (output_format_context, &output_packet)) < 0)
+ {
#if DEBUG
- fprintf(stderr, "Could not write frame (error '%s')\n",
- get_error_text(error));
+ fprintf (stderr, "Could not write frame (error '%s')\n",
+ get_error_text (error));
#endif
- av_free_packet(&output_packet);
- return error;
- }
-
- av_free_packet(&output_packet);
+ av_free_packet (&output_packet);
+ return error;
}
- return 0;
+ av_free_packet (&output_packet);
+ }
+
+ return 0;
}
+
/**
* Load one audio frame from the FIFO buffer, encode and write it to the
* output file.
*/
-static int load_encode_and_write(AVAudioFifo *fifo,
- AVFormatContext *output_format_context,
- AVCodecContext *output_codec_context)
+static int
+load_encode_and_write (AVAudioFifo *fifo,
+ AVFormatContext *output_format_context,
+ AVCodecContext *output_codec_context)
{
- /** Temporary storage of the output samples of the frame written to the file. */
- AVFrame *output_frame;
- /**
- * Use the maximum number of possible samples per frame.
- * If there is less than the maximum possible frame size in the FIFO
- * buffer use this number. Otherwise, use the maximum possible frame size
- */
- const int frame_size = FFMIN(av_audio_fifo_size(fifo),
- output_codec_context->frame_size);
- int data_written;
-
- /** Initialize temporary storage for one output frame. */
- if (init_output_frame(&output_frame, output_codec_context, frame_size))
- return AVERROR_EXIT;
+ /** Temporary storage of the output samples of the frame written to the file. */
+ AVFrame *output_frame;
+ /**
+ * Use the maximum number of possible samples per frame.
+ * If there is less than the maximum possible frame size in the FIFO
+ * buffer use this number. Otherwise, use the maximum possible frame size
+ */const int frame_size = FFMIN (av_audio_fifo_size (fifo),
+ output_codec_context->frame_size);
+ int data_written;
+
+ /** Initialize temporary storage for one output frame. */
+ if (init_output_frame (&output_frame, output_codec_context, frame_size))
+ return AVERROR_EXIT;
- /**
- * Read as many samples from the FIFO buffer as required to fill the frame.
- * The samples are stored in the frame temporarily.
- */
- if (av_audio_fifo_read(fifo, (void **)output_frame->data, frame_size) < frame_size) {
+ /**
+ * Read as many samples from the FIFO buffer as required to fill the frame.
+ * The samples are stored in the frame temporarily.
+ */
+ if (av_audio_fifo_read (fifo, (void **) output_frame->data, frame_size) <
+ frame_size)
+ {
#if DEBUG
- fprintf(stderr, "Could not read data from FIFO\n");
+ fprintf (stderr, "Could not read data from FIFO\n");
#endif
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
- av_frame_free (&output_frame);
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
+ av_frame_free (&output_frame);
#else
- avcodec_free_frame(&output_frame);
+ avcodec_free_frame (&output_frame);
#endif
- return AVERROR_EXIT;
- }
+ return AVERROR_EXIT;
+ }
- /** Encode one frame worth of audio samples. */
- if (encode_audio_frame(output_frame, output_format_context,
- output_codec_context, &data_written)) {
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
- av_frame_free (&output_frame);
+ /** Encode one frame worth of audio samples. */
+ if (encode_audio_frame (output_frame, output_format_context,
+ output_codec_context, &data_written))
+ {
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
+ av_frame_free (&output_frame);
#else
- avcodec_free_frame(&output_frame);
+ avcodec_free_frame (&output_frame);
#endif
- return AVERROR_EXIT;
- }
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
- av_frame_free (&output_frame);
+ return AVERROR_EXIT;
+ }
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
+ av_frame_free (&output_frame);
#else
- avcodec_free_frame(&output_frame);
+ avcodec_free_frame (&output_frame);
#endif
- return 0;
+ return 0;
}
+
+
/** Write the trailer of the output file container. */
-static int write_output_file_trailer(AVFormatContext *output_format_context)
+static int
+write_output_file_trailer (AVFormatContext *output_format_context)
{
- int error;
- if ((error = av_write_trailer(output_format_context)) < 0) {
+ int error;
+ if ((error = av_write_trailer (output_format_context)) < 0)
+ {
#if DEBUG
- fprintf(stderr, "Could not write output file trailer (error '%s')\n",
- get_error_text(error));
+ fprintf (stderr, "Could not write output file trailer (error '%s')\n",
+ get_error_text (error));
#endif
- return error;
- }
- return 0;
+ return error;
+ }
+ return 0;
}
+
#define ENUM_CODEC_ID enum AVCodecID
@@ -868,7 +929,7 @@ extract_audio (struct EXTRACTOR_ExtractContext *ec)
AVCodec *codec;
AVDictionary *options;
AVFrame *frame;
- AVCodecContext* output_codec_context = NULL;
+ AVCodecContext*output_codec_context = NULL;
AVAudioResampleContext *resample_context = NULL;
AVAudioFifo *fifo = NULL;
@@ -879,95 +940,95 @@ extract_audio (struct EXTRACTOR_ExtractContext *ec)
unsigned char *iob;
- totalSize =0;
+ totalSize = 0;
if (NULL == (iob = av_malloc (16 * 1024)))
return;
if (NULL == (io_ctx = avio_alloc_context (iob,
16 * 1024,
- 0, ec,
- &read_cb,
- NULL /* no writing */,
- &seek_cb)))
- {
- av_free (iob);
- return;
- }
+ 0, ec,
+ &read_cb,
+ NULL /* no writing */,
+ &seek_cb)))
+ {
+ av_free (iob);
+ return;
+ }
if (NULL == (format_ctx = avformat_alloc_context ()))
- {
- av_free (io_ctx);
- return;
- }
+ {
+ av_free (io_ctx);
+ return;
+ }
format_ctx->pb = io_ctx;
options = NULL;
if (0 != avformat_open_input (&format_ctx, "<no file>", NULL, &options))
- {
- av_free (io_ctx);
- return;
- }
+ {
+ av_free (io_ctx);
+ return;
+ }
av_dict_free (&options);
if (0 > avformat_find_stream_info (format_ctx, NULL))
- {
+ {
#if DEBUG
- fprintf (stderr,
- "Failed to read stream info\n");
+ fprintf (stderr,
+ "Failed to read stream info\n");
#endif
- avformat_close_input (&format_ctx);
- av_free (io_ctx);
- return;
- }
+ avformat_close_input (&format_ctx);
+ av_free (io_ctx);
+ return;
+ }
codec = NULL;
codec_ctx = NULL;
audio_stream_index = -1;
- for (i=0; i<format_ctx->nb_streams; i++)
+ for (i = 0; i<format_ctx->nb_streams; i++)
+ {
+ codec_ctx = format_ctx->streams[i]->codec;
+ if (AVMEDIA_TYPE_AUDIO != codec_ctx->codec_type)
+ continue;
+ if (NULL == (codec = avcodec_find_decoder (codec_ctx->codec_id)))
+ continue;
+ options = NULL;
+ if (0 != (err = avcodec_open2 (codec_ctx, codec, &options)))
{
- codec_ctx = format_ctx->streams[i]->codec;
- if (AVMEDIA_TYPE_AUDIO != codec_ctx->codec_type)
- continue;
- if (NULL == (codec = avcodec_find_decoder (codec_ctx->codec_id)))
- continue;
- options = NULL;
- if (0 != (err = avcodec_open2 (codec_ctx, codec, &options)))
- {
- codec = NULL;
- continue;
- }
- av_dict_free (&options);
- audio_stream_index = i;
- break;
+ codec = NULL;
+ continue;
}
+ av_dict_free (&options);
+ audio_stream_index = i;
+ break;
+ }
if ( (-1 == audio_stream_index) ||
(0 == codec_ctx->channels) )
- {
+ {
#if DEBUG
- fprintf (stderr,
- "No audio streams or no suitable codec found\n");
+ fprintf (stderr,
+ "No audio streams or no suitable codec found\n");
#endif
- if (NULL != codec)
- avcodec_close (codec_ctx);
- avformat_close_input (&format_ctx);
- av_free (io_ctx);
- return;
- }
+ if (NULL != codec)
+ avcodec_close (codec_ctx);
+ avformat_close_input (&format_ctx);
+ av_free (io_ctx);
+ return;
+ }
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
frame = av_frame_alloc ();
#else
- frame = avcodec_alloc_frame();
+ frame = avcodec_alloc_frame ();
#endif
if (NULL == frame)
- {
+ {
#if DEBUG
- fprintf (stderr,
- "Failed to allocate frame\n");
+ fprintf (stderr,
+ "Failed to allocate frame\n");
#endif
- avcodec_close (codec_ctx);
- avformat_close_input (&format_ctx);
- av_free (io_ctx);
- return;
- }
+ avcodec_close (codec_ctx);
+ avformat_close_input (&format_ctx);
+ av_free (io_ctx);
+ return;
+ }
- if (! (buffer = malloc(HARD_LIMIT_SIZE)))
+ if (! (buffer = malloc (HARD_LIMIT_SIZE)))
goto cleanup;
@@ -982,37 +1043,37 @@ extract_audio (struct EXTRACTOR_ExtractContext *ec)
&resample_context))
goto cleanup;
/** Initialize the FIFO buffer to store audio samples to be encoded. */
- if (init_fifo(&fifo))
+ if (init_fifo (&fifo))
goto cleanup;
/** Write the header of the output file container. */
- if (write_output_file_header(output_format_context))
+ if (write_output_file_header (output_format_context))
goto cleanup;
if (format_ctx->duration == AV_NOPTS_VALUE)
- {
- duration = -1;
+ {
+ duration = -1;
#if DEBUG
- fprintf (stderr,
- "Duration unknown\n");
+ fprintf (stderr,
+ "Duration unknown\n");
#endif
- }
+ }
else
- {
+ {
#if DEBUG
- duration = format_ctx->duration;
- fprintf (stderr,
- "Duration: %lld\n",
- format_ctx->duration);
+ duration = format_ctx->duration;
+ fprintf (stderr,
+ "Duration: %lld\n",
+ format_ctx->duration);
#endif
- }
+ }
/* if duration is known, seek to first tried,
* else use 10 sec into stream */
- if(-1 != duration)
- err = av_seek_frame (format_ctx, -1, (duration/3), 0);
+ if (-1 != duration)
+ err = av_seek_frame (format_ctx, -1, (duration / 3), 0);
else
err = av_seek_frame (format_ctx, -1, 10 * AV_TIME_BASE, 0);
@@ -1026,86 +1087,82 @@ extract_audio (struct EXTRACTOR_ExtractContext *ec)
* to write; abort as soon as we have neither.
*/
while (1)
- {
- /** Use the encoder's desired frame size for processing. */
- const int output_frame_size = output_codec_context->frame_size;
- int finished = 0;
+ {
+ /** Use the encoder's desired frame size for processing. */
+ const int output_frame_size = output_codec_context->frame_size;
+ int finished = 0;
+ /**
+ * Make sure that there is one frame worth of samples in the FIFO
+ * buffer so that the encoder can do its work.
+ * Since the decoder's and the encoder's frame size may differ, we
+ * need to FIFO buffer to store as many frames worth of input samples
+ * that they make up at least one frame worth of output samples.
+ */while ((av_audio_fifo_size (fifo) < output_frame_size))
+ {
/**
- * Make sure that there is one frame worth of samples in the FIFO
- * buffer so that the encoder can do its work.
- * Since the decoder's and the encoder's frame size may differ, we
- * need to FIFO buffer to store as many frames worth of input samples
- * that they make up at least one frame worth of output samples.
+ * Decode one frame worth of audio samples, convert it to the
+ * output sample format and put it into the FIFO buffer.
*/
-
- while ((av_audio_fifo_size(fifo) < output_frame_size))
- {
- /**
- * Decode one frame worth of audio samples, convert it to the
- * output sample format and put it into the FIFO buffer.
- */
- if (read_decode_convert_and_store (fifo,
- format_ctx,
- codec_ctx,
- output_codec_context,
- resample_context,
- audio_stream_index,
- &finished))
- {
- goto cleanup;
- }
-
- /**
- * If we are at the end of the input file, we continue
- * encoding the remaining audio samples to the output file.
- */
- if (finished)
- break;
- }
-
- /* Already over our limit*/
- if (totalSize >= MAX_SIZE)
- finished = 1;
+ if (read_decode_convert_and_store (fifo,
+ format_ctx,
+ codec_ctx,
+ output_codec_context,
+ resample_context,
+ audio_stream_index,
+ &finished))
+ {
+ goto cleanup;
+ }
/**
- * If we have enough samples for the encoder, we encode them.
- * At the end of the file, we pass the remaining samples to
- * the encoder.
+ * If we are at the end of the input file, we continue
+ * encoding the remaining audio samples to the output file.
*/
+ if (finished)
+ break;
+ }
- while (av_audio_fifo_size(fifo) >= output_frame_size ||
- (finished && av_audio_fifo_size(fifo) > 0))
- {
- /**
- * Take one frame worth of audio samples from the FIFO buffer,
- * encode it and write it to the output file.
- */
- if (load_encode_and_write (fifo,
- output_format_context,
- output_codec_context))
- goto cleanup;
- }
+ /* Already over our limit*/
+ if (totalSize >= MAX_SIZE)
+ finished = 1;
+
+ /**
+ * If we have enough samples for the encoder, we encode them.
+ * At the end of the file, we pass the remaining samples to
+ * the encoder.
+ */while (av_audio_fifo_size (fifo) >= output_frame_size ||
+ (finished && av_audio_fifo_size (fifo) > 0))
+ {
/**
- * If we are at the end of the input file and have encoded
- * all remaining samples, we can exit this loop and finish.
+ * Take one frame worth of audio samples from the FIFO buffer,
+ * encode it and write it to the output file.
*/
- if (finished)
- {
- int data_written;
- /** Flush the encoder as it may have delayed frames. */
- do {
- encode_audio_frame (NULL,
- output_format_context,
- output_codec_context,
- &data_written);
- } while (data_written);
- break;
- }
+ if (load_encode_and_write (fifo,
+ output_format_context,
+ output_codec_context))
+ goto cleanup;
+ }
+ /**
+ * If we are at the end of the input file and have encoded
+ * all remaining samples, we can exit this loop and finish.
+ */
+ if (finished)
+ {
+ int data_written;
+ /** Flush the encoder as it may have delayed frames. */
+ do {
+ encode_audio_frame (NULL,
+ output_format_context,
+ output_codec_context,
+ &data_written);
+ } while (data_written);
+ break;
}
+ }
/** Write the trailer of the output file container. */
- if (write_output_file_trailer(output_format_context))
+ if (write_output_file_trailer (output_format_context))
goto cleanup;
ec->proc (ec->cls,
"previewopus",
@@ -1120,34 +1177,34 @@ extract_audio (struct EXTRACTOR_ExtractContext *ec)
FILE *f;
f = fopen ("example.opus", "wb");
- if (!f)
- {
- fprintf (stderr, "Could not open %s\n", "file");
- exit(1);
- }
+ if (! f)
+ {
+ fprintf (stderr, "Could not open %s\n", "file");
+ exit (1);
+ }
fwrite (buffer, 1, totalSize, f);
- fclose(f);
+ fclose (f);
}
#endif
- cleanup:
+cleanup:
av_free (frame);
free (buffer);
if (fifo)
- av_audio_fifo_free(fifo);
+ av_audio_fifo_free (fifo);
if (resample_context)
- {
- avresample_close(resample_context);
- avresample_free(&resample_context);
- }
+ {
+ avresample_close (resample_context);
+ avresample_free (&resample_context);
+ }
if (output_codec_context)
- avcodec_close(output_codec_context);
+ avcodec_close (output_codec_context);
if (codec_ctx)
- avcodec_close(codec_ctx);
+ avcodec_close (codec_ctx);
if (format_ctx)
- avformat_close_input(&format_ctx);
+ avformat_close_input (&format_ctx);
av_free (io_ctx);
}
@@ -1165,8 +1222,8 @@ EXTRACTOR_previewopus_extract_method (struct EXTRACTOR_ExtractContext *ec)
if (-1 == (iret = ec->read (ec->cls,
- &data,
- 16 * 1024)))
+ &data,
+ 16 * 1024)))
return;
if (0 != ec->seek (ec->cls, 0, SEEK_SET))
@@ -1185,13 +1242,13 @@ EXTRACTOR_previewopus_extract_method (struct EXTRACTOR_ExtractContext *ec)
* @param ap arguments for format
*/
static void
-previewopus_av_log_callback (void* ptr,
- int level,
- const char *format,
- va_list ap)
+previewopus_av_log_callback (void*ptr,
+ int level,
+ const char *format,
+ va_list ap)
{
#if DEBUG
- vfprintf(stderr, format, ap);
+ vfprintf (stderr, format, ap);
#endif
}
diff --git a/src/plugins/ps_extractor.c b/src/plugins/ps_extractor.c
@@ -137,81 +137,82 @@ EXTRACTOR_ps_extract_method (struct EXTRACTOR_ExtractContext *ec)
return;
if ( (strlen (line) < strlen (PS_HEADER)) ||
(0 != memcmp (PS_HEADER,
- line,
- strlen (PS_HEADER))) )
- {
- free (line);
- return;
- }
+ line,
+ strlen (PS_HEADER))) )
+ {
+ free (line);
+ return;
+ }
free (line);
if (0 != ec->proc (ec->cls,
- "ps",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "application/postscript",
- strlen ("application/postscript") + 1))
+ "ps",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "application/postscript",
+ strlen ("application/postscript") + 1))
return;
line = NULL;
next = readline (ec);
while ( (NULL != next) &&
- ('%' == next[0]) )
+ ('%' == next[0]) )
+ {
+ line = next;
+ next = readline (ec);
+ for (i = 0; NULL != tests[i].prefix; i++)
{
- line = next;
- next = readline (ec);
- for (i = 0; NULL != tests[i].prefix; i++)
- {
- match = tests[i].prefix;
- if ( (strlen (line) < strlen (match)) ||
- (0 != strncmp (line, match, strlen (match))) )
- continue;
- /* %%+ continues previous meta-data type... */
- while ( (NULL != next) &&
- (0 == strncmp (next, "%%+", strlen ("%%+"))) )
- {
- if (NULL == (acc = malloc (strlen (line) + strlen (next) - 1)))
- break;
- strcpy (acc, line);
- strcat (acc, " ");
- strcat (acc, next + 3);
- free (line);
- line = acc;
- free (next);
- next = readline (ec);
- }
- if ( (line[strlen (line) - 1] == ')') &&
- (line[strlen (match)] == '(') )
- {
- acc = &line[strlen (match) + 1];
- acc[strlen (acc) - 1] = '\0'; /* remove ")" */
- }
- else
- {
- acc = &line[strlen (match)];
- }
- while (isspace ((unsigned char) acc[0]))
- acc++;
- if ( (strlen (acc) > 0) &&
- (0 != ec->proc (ec->cls,
- "ps",
- tests[i].type,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- acc,
- strlen (acc) + 1)) )
- {
- free (line);
- if (NULL != next)
- free (next);
- return;
- }
- break;
- }
- free (line);
+ match = tests[i].prefix;
+ if ( (strlen (line) < strlen (match)) ||
+ (0 != strncmp (line, match, strlen (match))) )
+ continue;
+ /* %%+ continues previous meta-data type... */
+ while ( (NULL != next) &&
+ (0 == strncmp (next, "%%+", strlen ("%%+"))) )
+ {
+ if (NULL == (acc = malloc (strlen (line) + strlen (next) - 1)))
+ break;
+ strcpy (acc, line);
+ strcat (acc, " ");
+ strcat (acc, next + 3);
+ free (line);
+ line = acc;
+ free (next);
+ next = readline (ec);
+ }
+ if ( (line[strlen (line) - 1] == ')') &&
+ (line[strlen (match)] == '(') )
+ {
+ acc = &line[strlen (match) + 1];
+ acc[strlen (acc) - 1] = '\0'; /* remove ")" */
+ }
+ else
+ {
+ acc = &line[strlen (match)];
+ }
+ while (isspace ((unsigned char) acc[0]))
+ acc++;
+ if ( (strlen (acc) > 0) &&
+ (0 != ec->proc (ec->cls,
+ "ps",
+ tests[i].type,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ acc,
+ strlen (acc) + 1)) )
+ {
+ free (line);
+ if (NULL != next)
+ free (next);
+ return;
+ }
+ break;
}
+ free (line);
+ }
if (NULL != next)
free (next);
}
+
/* end of ps_extractor.c */
diff --git a/src/plugins/riff_extractor.c b/src/plugins/riff_extractor.c
@@ -76,15 +76,19 @@ round_double (double num)
* @param s 0-terminated UTF8 string value with the meta data
* @param t libextractor type for the meta data
*/
-#define ADD(s,t) do { if (0 != ec->proc (ec->cls, "riff", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1)) return; } while (0)
+#define ADD(s,t) do { if (0 != ec->proc (ec->cls, "riff", t, \
+ EXTRACTOR_METAFORMAT_UTF8, \
+ "text/plain", s, strlen (s) \
+ + 1)) return; \
+} while (0)
/**
- * Main entry method for the 'video/x-msvideo' extraction plugin.
+ * Main entry method for the 'video/x-msvideo' extraction plugin.
*
* @param ec extraction context provided to the plugin
*/
-void
+void
EXTRACTOR_riff_extract_method (struct EXTRACTOR_ExtractContext *ec)
{
ssize_t xsize;
@@ -98,22 +102,22 @@ EXTRACTOR_riff_extract_method (struct EXTRACTOR_ExtractContext *ec)
uint32_t height;
char codec[5];
char format[256];
-
+
/* read header */
if (72 > (xsize = ec->read (ec->cls, &data, 72)))
return;
xdata = data;
-
+
/* check magic values */
if ( (0 != memcmp (&xdata[0],
- "RIFF", 4)) ||
+ "RIFF", 4)) ||
(0 != memcmp (&xdata[8], "AVI ", 4)) ||
(0 != memcmp (&xdata[12], "LIST", 4)) ||
(0 != memcmp (&xdata[20], "hdrlavih", 8)) )
return;
-
+
blockLen = fread_le (&xdata[28]);
-
+
/* begin of AVI header at 32 */
fps = (unsigned int) round_double ((double) 1.0e6 / fread_le (&xdata[32]));
duration = (unsigned int) round_double ((double) fread_le (&xdata[48])
@@ -126,7 +130,7 @@ EXTRACTOR_riff_extract_method (struct EXTRACTOR_ExtractContext *ec)
if (pos !=
ec->seek (ec->cls, pos, SEEK_SET))
- return;
+ return;
if (32 > ec->read (ec->cls, &data, 32))
return;
xdata = data;
@@ -141,17 +145,18 @@ EXTRACTOR_riff_extract_method (struct EXTRACTOR_ExtractContext *ec)
memcpy (codec, &xdata[24], 4);
codec[4] = '\0';
snprintf (format,
- sizeof (format),
- _("codec: %s, %u fps, %u ms"),
- codec, fps, duration);
+ sizeof (format),
+ _ ("codec: %s, %u fps, %u ms"),
+ codec, fps, duration);
ADD (format, EXTRACTOR_METATYPE_FORMAT);
- snprintf (format,
- sizeof (format),
- "%ux%u",
- (unsigned int) width,
- (unsigned int) height);
+ snprintf (format,
+ sizeof (format),
+ "%ux%u",
+ (unsigned int) width,
+ (unsigned int) height);
ADD (format, EXTRACTOR_METATYPE_IMAGE_DIMENSIONS);
ADD ("video/x-msvideo", EXTRACTOR_METATYPE_MIMETYPE);
}
+
/* end of riff_extractor.c */
diff --git a/src/plugins/rpm_extractor.c b/src/plugins/rpm_extractor.c
@@ -79,7 +79,7 @@ struct PipeArgs
* @return NULL
*/
static void *
-pipe_feeder (void * args)
+pipe_feeder (void *args)
{
struct PipeArgs *p = args;
ssize_t rret;
@@ -91,34 +91,34 @@ pipe_feeder (void * args)
/* buffer is heap-allocated as this is a thread and
large stack allocations might not be the best idea */
while (0 == p->shutdown)
+ {
+ pthread_mutex_lock (&p->lock);
+ if (-1 == (rret = p->ec->read (p->ec->cls, &ptr, BUF_SIZE)))
{
- pthread_mutex_lock (&p->lock);
- if (-1 == (rret = p->ec->read (p->ec->cls, &ptr, BUF_SIZE)))
- {
- pthread_mutex_unlock (&p->lock);
- break;
- }
pthread_mutex_unlock (&p->lock);
- if (0 == rret)
- break;
- buf = ptr;
- done = 0;
- while ( (0 == p->shutdown) &&
- (done < rret) )
- {
- if (-1 == (wret = WRITE (p->pi[1],
- &buf[done],
- rret - done)))
- {
- break;
- }
- if (0 == wret)
- break;
- done += wret;
- }
- if (done != rret)
- break;
+ break;
+ }
+ pthread_mutex_unlock (&p->lock);
+ if (0 == rret)
+ break;
+ buf = ptr;
+ done = 0;
+ while ( (0 == p->shutdown) &&
+ (done < rret) )
+ {
+ if (-1 == (wret = WRITE (p->pi[1],
+ &buf[done],
+ rret - done)))
+ {
+ break;
+ }
+ if (0 == wret)
+ break;
+ done += wret;
}
+ if (done != rret)
+ break;
+ }
CLOSE (p->pi[1]);
return NULL;
}
@@ -130,7 +130,7 @@ pipe_feeder (void * args)
*/
static int
discard_log_callback (rpmlogRec rec,
- void *ctx)
+ void *ctx)
{
/* do nothing! */
return 0;
@@ -190,52 +190,52 @@ static struct Matches tests[] = {
#if 0
/* FIXME: add support for some of these */
- RPMTAG_GIF = 1012, /* x */
- RPMTAG_XPM = 1013, /* x */
- RPMTAG_SOURCE = 1018, /* s[] */
- RPMTAG_PATCH = 1019, /* s[] */
- RPMTAG_PREIN = 1023, /* s */
- RPMTAG_POSTIN = 1024, /* s */
- RPMTAG_PREUN = 1025, /* s */
- RPMTAG_POSTUN = 1026, /* s */
- RPMTAG_ICON = 1043, /* x */
- RPMTAG_SOURCERPM = 1044, /* s */
- RPMTAG_PROVIDENAME = 1047, /* s[] */
- RPMTAG_EXCLUDEARCH = 1059, /* s[] */
- RPMTAG_EXCLUDEOS = 1060, /* s[] */
- RPMTAG_EXCLUSIVEARCH = 1061, /* s[] */
- RPMTAG_EXCLUSIVEOS = 1062, /* s[] */
- RPMTAG_TRIGGERSCRIPTS = 1065, /* s[] */
- RPMTAG_TRIGGERNAME = 1066, /* s[] */
- RPMTAG_TRIGGERVERSION = 1067, /* s[] */
- RPMTAG_VERIFYSCRIPT = 1079, /* s */
- RPMTAG_PREINPROG = 1085, /* s */
- RPMTAG_POSTINPROG = 1086, /* s */
- RPMTAG_PREUNPROG = 1087, /* s */
- RPMTAG_POSTUNPROG = 1088, /* s */
- RPMTAG_BUILDARCHS = 1089, /* s[] */
- RPMTAG_OBSOLETENAME = 1090, /* s[] */
- RPMTAG_VERIFYSCRIPTPROG = 1091, /* s */
- RPMTAG_TRIGGERSCRIPTPROG = 1092, /* s[] */
- RPMTAG_COOKIE = 1094, /* s */
- RPMTAG_FILELANGS = 1097, /* s[] */
- RPMTAG_PREFIXES = 1098, /* s[] */
- RPMTAG_INSTPREFIXES = 1099, /* s[] */
- RPMTAG_PROVIDEVERSION = 1113, /* s[] */
- RPMTAG_OBSOLETEVERSION = 1115, /* s[] */
- RPMTAG_BASENAMES = 1117, /* s[] */
- RPMTAG_DIRNAMES = 1118, /* s[] */
- RPMTAG_OPTFLAGS = 1122, /* s */
- RPMTAG_PAYLOADFORMAT = 1124, /* s */
- RPMTAG_PAYLOADCOMPRESSOR = 1125, /* s */
- RPMTAG_PAYLOADFLAGS = 1126, /* s */
- RPMTAG_CLASSDICT = 1142, /* s[] */
- RPMTAG_SOURCEPKGID = 1146, /* x */
- RPMTAG_PRETRANS = 1151, /* s */
- RPMTAG_POSTTRANS = 1152, /* s */
- RPMTAG_PRETRANSPROG = 1153, /* s */
- RPMTAG_POSTTRANSPROG = 1154, /* s */
- RPMTAG_DISTTAG = 1155, /* s */
+ RPMTAG_GIF = 1012, /* x */
+ RPMTAG_XPM = 1013, /* x */
+ RPMTAG_SOURCE = 1018, /* s[] */
+ RPMTAG_PATCH = 1019, /* s[] */
+ RPMTAG_PREIN = 1023, /* s */
+ RPMTAG_POSTIN = 1024, /* s */
+ RPMTAG_PREUN = 1025, /* s */
+ RPMTAG_POSTUN = 1026, /* s */
+ RPMTAG_ICON = 1043, /* x */
+ RPMTAG_SOURCERPM = 1044, /* s */
+ RPMTAG_PROVIDENAME = 1047, /* s[] */
+ RPMTAG_EXCLUDEARCH = 1059, /* s[] */
+ RPMTAG_EXCLUDEOS = 1060, /* s[] */
+ RPMTAG_EXCLUSIVEARCH = 1061, /* s[] */
+ RPMTAG_EXCLUSIVEOS = 1062, /* s[] */
+ RPMTAG_TRIGGERSCRIPTS = 1065, /* s[] */
+ RPMTAG_TRIGGERNAME = 1066, /* s[] */
+ RPMTAG_TRIGGERVERSION = 1067, /* s[] */
+ RPMTAG_VERIFYSCRIPT = 1079, /* s */
+ RPMTAG_PREINPROG = 1085, /* s */
+ RPMTAG_POSTINPROG = 1086, /* s */
+ RPMTAG_PREUNPROG = 1087, /* s */
+ RPMTAG_POSTUNPROG = 1088, /* s */
+ RPMTAG_BUILDARCHS = 1089, /* s[] */
+ RPMTAG_OBSOLETENAME = 1090, /* s[] */
+ RPMTAG_VERIFYSCRIPTPROG = 1091, /* s */
+ RPMTAG_TRIGGERSCRIPTPROG = 1092, /* s[] */
+ RPMTAG_COOKIE = 1094, /* s */
+ RPMTAG_FILELANGS = 1097, /* s[] */
+ RPMTAG_PREFIXES = 1098, /* s[] */
+ RPMTAG_INSTPREFIXES = 1099, /* s[] */
+ RPMTAG_PROVIDEVERSION = 1113, /* s[] */
+ RPMTAG_OBSOLETEVERSION = 1115, /* s[] */
+ RPMTAG_BASENAMES = 1117, /* s[] */
+ RPMTAG_DIRNAMES = 1118, /* s[] */
+ RPMTAG_OPTFLAGS = 1122, /* s */
+ RPMTAG_PAYLOADFORMAT = 1124, /* s */
+ RPMTAG_PAYLOADCOMPRESSOR = 1125, /* s */
+ RPMTAG_PAYLOADFLAGS = 1126, /* s */
+ RPMTAG_CLASSDICT = 1142, /* s[] */
+ RPMTAG_SOURCEPKGID = 1146, /* x */
+ RPMTAG_PRETRANS = 1151, /* s */
+ RPMTAG_POSTTRANS = 1152, /* s */
+ RPMTAG_PRETRANSPROG = 1153, /* s */
+ RPMTAG_POSTTRANSPROG = 1154, /* s */
+ RPMTAG_DISTTAG = 1155, /* s */
#endif
{0, 0}
};
@@ -271,142 +271,142 @@ EXTRACTOR_rpm_extract_method (struct EXTRACTOR_ExtractContext *ec)
if (0 != pipe (parg.pi))
return;
if (0 != pthread_mutex_init (&parg.lock, NULL))
- {
- CLOSE (parg.pi[0]);
- CLOSE (parg.pi[1]);
- return;
- }
+ {
+ CLOSE (parg.pi[0]);
+ CLOSE (parg.pi[1]);
+ return;
+ }
if (0 != pthread_create (&pthr,
- NULL,
- &pipe_feeder,
- &parg))
- {
- pthread_mutex_destroy (&parg.lock);
- CLOSE (parg.pi[0]);
- CLOSE (parg.pi[1]);
- return;
- }
+ NULL,
+ &pipe_feeder,
+ &parg))
+ {
+ pthread_mutex_destroy (&parg.lock);
+ CLOSE (parg.pi[0]);
+ CLOSE (parg.pi[1]);
+ return;
+ }
rpmlogSetCallback (&discard_log_callback, NULL);
fdi = fdDup (parg.pi[0]);
- ts = rpmtsCreate();
+ ts = rpmtsCreate ();
rc = rpmReadPackageFile (ts, fdi, "GNU libextractor", &hdr);
switch (rc)
- {
- case RPMRC_OK:
- case RPMRC_NOKEY:
- case RPMRC_NOTTRUSTED:
- break;
- case RPMRC_NOTFOUND:
- case RPMRC_FAIL:
- default:
- goto END;
- }
+ {
+ case RPMRC_OK:
+ case RPMRC_NOKEY:
+ case RPMRC_NOTTRUSTED:
+ break;
+ case RPMRC_NOTFOUND:
+ case RPMRC_FAIL:
+ default:
+ goto END;
+ }
pthread_mutex_lock (&parg.lock);
if (0 != ec->proc (ec->cls,
- "rpm",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "application/x-rpm",
- strlen ("application/x-rpm") +1))
- {
- pthread_mutex_unlock (&parg.lock);
- goto END;
- }
+ "rpm",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "application/x-rpm",
+ strlen ("application/x-rpm") + 1))
+ {
+ pthread_mutex_unlock (&parg.lock);
+ goto END;
+ }
pthread_mutex_unlock (&parg.lock);
hi = headerInitIterator (hdr);
p = rpmtdNew ();
while (1 == headerNext (hi, p))
for (i = 0; 0 != tests[i].rtype; i++)
+ {
+ if (tests[i].rtype != p->tag)
+ continue;
+ switch (p->type)
{
- if (tests[i].rtype != p->tag)
- continue;
- switch (p->type)
- {
- case RPM_STRING_ARRAY_TYPE:
- case RPM_I18NSTRING_TYPE:
- case RPM_STRING_TYPE:
- while (NULL != (str = rpmtdNextString (p)))
- {
- pthread_mutex_lock (&parg.lock);
- if (0 != ec->proc (ec->cls,
- "rpm",
- tests[i].type,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- str,
- strlen (str) + 1))
-
- {
- pthread_mutex_unlock (&parg.lock);
- goto CLEANUP;
- }
- pthread_mutex_unlock (&parg.lock);
- }
- break;
- case RPM_INT32_TYPE:
- {
- if (p->tag == RPMTAG_BUILDTIME)
- {
- char tmp[80];
- uint32_t *v = rpmtdNextUint32 (p);
- time_t tp = (time_t) *v;
-
- if (NULL == ctime_r (&tp, tmp))
- break;
- if ( (strlen (tmp) > 0) &&
- (isspace ((unsigned char) tmp[strlen(tmp)-1])) )
- tmp[strlen (tmp) - 1] = '\0'; /* eat linefeed */
- pthread_mutex_lock (&parg.lock);
- if (0 != ec->proc (ec->cls,
- "rpm",
- tests[i].type,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- tmp,
- strlen (tmp) + 1))
- {
- pthread_mutex_unlock (&parg.lock);
- goto CLEANUP;
- }
- pthread_mutex_unlock (&parg.lock);
- }
- else
- {
- char tmp[14];
- uint32_t *s = rpmtdNextUint32 (p);
-
- snprintf (tmp,
- sizeof (tmp),
- "%u",
- (unsigned int) *s);
- pthread_mutex_lock (&parg.lock);
- if (0 != ec->proc (ec->cls,
- "rpm",
- tests[i].type,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- tmp,
- strlen (tmp) + 1))
- {
- pthread_mutex_unlock (&parg.lock);
- goto CLEANUP;
- }
- pthread_mutex_unlock (&parg.lock);
- }
- break;
- }
- default:
- break;
- }
+ case RPM_STRING_ARRAY_TYPE:
+ case RPM_I18NSTRING_TYPE:
+ case RPM_STRING_TYPE:
+ while (NULL != (str = rpmtdNextString (p)))
+ {
+ pthread_mutex_lock (&parg.lock);
+ if (0 != ec->proc (ec->cls,
+ "rpm",
+ tests[i].type,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ str,
+ strlen (str) + 1))
+
+ {
+ pthread_mutex_unlock (&parg.lock);
+ goto CLEANUP;
+ }
+ pthread_mutex_unlock (&parg.lock);
+ }
+ break;
+ case RPM_INT32_TYPE:
+ {
+ if (p->tag == RPMTAG_BUILDTIME)
+ {
+ char tmp[80];
+ uint32_t *v = rpmtdNextUint32 (p);
+ time_t tp = (time_t) *v;
+
+ if (NULL == ctime_r (&tp, tmp))
+ break;
+ if ( (strlen (tmp) > 0) &&
+ (isspace ((unsigned char) tmp[strlen (tmp) - 1])) )
+ tmp[strlen (tmp) - 1] = '\0'; /* eat linefeed */
+ pthread_mutex_lock (&parg.lock);
+ if (0 != ec->proc (ec->cls,
+ "rpm",
+ tests[i].type,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ tmp,
+ strlen (tmp) + 1))
+ {
+ pthread_mutex_unlock (&parg.lock);
+ goto CLEANUP;
+ }
+ pthread_mutex_unlock (&parg.lock);
+ }
+ else
+ {
+ char tmp[14];
+ uint32_t *s = rpmtdNextUint32 (p);
+
+ snprintf (tmp,
+ sizeof (tmp),
+ "%u",
+ (unsigned int) *s);
+ pthread_mutex_lock (&parg.lock);
+ if (0 != ec->proc (ec->cls,
+ "rpm",
+ tests[i].type,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ tmp,
+ strlen (tmp) + 1))
+ {
+ pthread_mutex_unlock (&parg.lock);
+ goto CLEANUP;
+ }
+ pthread_mutex_unlock (&parg.lock);
+ }
+ break;
+ }
+ default:
+ break;
}
- CLEANUP:
+ }
+CLEANUP:
rpmtdFree (p);
headerFreeIterator (hi);
- END:
+END:
headerFree (hdr);
- rpmtsFree(ts);
+ rpmtsFree (ts);
/* make sure SIGALRM does not kill us, then use it to
kill the thread */
@@ -424,4 +424,5 @@ EXTRACTOR_rpm_extract_method (struct EXTRACTOR_ExtractContext *ec)
sigaction (SIGALRM, &old, &sig);
}
+
/* end of rpm_extractor.c */
diff --git a/src/plugins/s3m_extractor.c b/src/plugins/s3m_extractor.c
@@ -61,7 +61,11 @@ LE_NETWORK_STRUCT_END
* @param t LE meta data type
* @param s meta data to add
*/
-#define ADD(s, t) do { if (0 != ec->proc (ec->cls, "s3m", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1)) return; } while (0)
+#define ADD(s, t) do { if (0 != ec->proc (ec->cls, "s3m", t, \
+ EXTRACTOR_METAFORMAT_UTF8, \
+ "text/plain", s, strlen (s) \
+ + 1)) return; \
+} while (0)
/**
@@ -82,8 +86,8 @@ EXTRACTOR_s3m_extract_method (struct EXTRACTOR_ExtractContext *ec)
if ((ssize_t) sizeof (header) >
ec->read (ec->cls,
- &data,
- sizeof (header)))
+ &data,
+ sizeof (header)))
return;
memcpy (&header, data, sizeof (header));
if ( (0x1A != header.byte_1A) ||
@@ -105,4 +109,5 @@ EXTRACTOR_s3m_extract_method (struct EXTRACTOR_ExtractContext *ec)
*/
}
+
/* end of s3m_extractor.c */
diff --git a/src/plugins/sid_extractor.c b/src/plugins/sid_extractor.c
@@ -154,7 +154,11 @@ sidword (const sidwrd data)
* @param s metadata value as UTF8
* @param t metadata type to use
*/
-#define ADD(s,t) do { if (0 != ec->proc (ec->cls, "sid", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1)) return; } while (0)
+#define ADD(s,t) do { if (0 != ec->proc (ec->cls, "sid", t, \
+ EXTRACTOR_METAFORMAT_UTF8, \
+ "text/plain", s, strlen (s) \
+ + 1)) return; \
+} while (0)
/**
@@ -178,8 +182,8 @@ EXTRACTOR_sid_extract_method (struct EXTRACTOR_ExtractContext *ec)
if ((ssize_t) sizeof (struct header) >
ec->read (ec->cls,
- &data,
- sizeof (struct header)))
+ &data,
+ sizeof (struct header)))
return;
head = data;
@@ -194,22 +198,22 @@ EXTRACTOR_sid_extract_method (struct EXTRACTOR_ExtractContext *ec)
/* Version of SID format */
version = sidword (head->sidversion);
snprintf (sidversion,
- sizeof (sidversion),
- "%d",
- version);
+ sizeof (sidversion),
+ "%d",
+ version);
ADD (sidversion, EXTRACTOR_METATYPE_FORMAT_VERSION);
/* Get song count */
snprintf (songs,
- sizeof (songs),
- "%d", sidword (head->songs));
+ sizeof (songs),
+ "%d", sidword (head->songs));
ADD (songs, EXTRACTOR_METATYPE_SONG_COUNT);
/* Get number of the first song to be played */
snprintf (startingsong,
- sizeof (startingsong),
- "%d",
- sidword (head->firstsong));
+ sizeof (startingsong),
+ "%d",
+ sidword (head->firstsong));
ADD (startingsong, EXTRACTOR_METATYPE_STARTING_SONG);
/* name, artist, copyright fields */
@@ -232,8 +236,7 @@ EXTRACTOR_sid_extract_method (struct EXTRACTOR_ExtractContext *ec)
*
* Note: Had some troubles understanding specification
* on the flags in version 2. I hope this is correct.
- */
- flags = sidword (head->flags);
+ */flags = sidword (head->flags);
/* MUS data */
if (0 != (flags & MUSPLAYER_FLAG))
ADD ("Compute!'s Sidplayer", EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE);
@@ -256,4 +259,5 @@ EXTRACTOR_sid_extract_method (struct EXTRACTOR_ExtractContext *ec)
ADD ("MOS6581", EXTRACTOR_METATYPE_TARGET_ARCHITECTURE);
}
+
/* end of sid_extractor.c */
diff --git a/src/plugins/template_extractor.c b/src/plugins/template_extractor.c
@@ -46,13 +46,13 @@ EXTRACTOR_template_extract_method (struct EXTRACTOR_ExtractContext *ec)
return 1;
/* initialize state here */
-
+
/* Call seek (plugin, POSITION, WHENCE) to seek (if you know where
* data starts):
*/
// ec->seek (ec->cls, POSITION, SEEK_SET);
- /* Call read (plugin, &data, COUNT) to read COUNT bytes
+ /* Call read (plugin, &data, COUNT) to read COUNT bytes
*/
@@ -64,4 +64,5 @@ EXTRACTOR_template_extract_method (struct EXTRACTOR_ExtractContext *ec)
return;
}
+
/* end of template_extractor.c */
diff --git a/src/plugins/test_archive.c b/src/plugins/test_archive.c
@@ -36,41 +36,40 @@
int
main (int argc, char *argv[])
{
- struct SolutionData tar_archive_sol[] =
+ struct SolutionData tar_archive_sol[] = {
{
- {
- EXTRACTOR_METATYPE_FILENAME,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "test.html",
- strlen ("test.html") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_FILENAME,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "test.jpg",
- strlen ("test.jpg") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_FORMAT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "GNU tar format",
- strlen ("GNU tar format") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_FILENAME,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "test.html",
+ strlen ("test.html") + 1,
+ 0
+ },
{
- { "testdata/archive_test.tar",
- tar_archive_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_FILENAME,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "test.jpg",
+ strlen ("test.jpg") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_FORMAT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "GNU tar format",
+ strlen ("GNU tar format") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/archive_test.tar",
+ tar_archive_sol },
+ { NULL, NULL }
+ };
return ET_main ("archive", ps);
}
+
/* end of test_archive.c */
diff --git a/src/plugins/test_deb.c b/src/plugins/test_deb.c
@@ -36,139 +36,138 @@
int
main (int argc, char *argv[])
{
- struct SolutionData deb_bzip2_sol[] =
+ struct SolutionData deb_bzip2_sol[] = {
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "application/x-debian-package",
- strlen ("application/x-debian-package") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_NAME,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "bzip2",
- strlen ("bzip2") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_VERSION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "1.0.6-4",
- strlen ("1.0.6-4") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TARGET_ARCHITECTURE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "i386",
- strlen ("i386") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_MAINTAINER,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Anibal Monsalve Salazar <anibal@debian.org>",
- strlen ("Anibal Monsalve Salazar <anibal@debian.org>") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_INSTALLED_SIZE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "113", /* FIXME: should this be 'kb'? */
- strlen ("113") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "libbz2-1.0 (= 1.0.6-4), libc6 (>= 2.4)",
- strlen ("libbz2-1.0 (= 1.0.6-4), libc6 (>= 2.4)") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_SUGGESTS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "bzip2-doc",
- strlen ("bzip2-doc") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_REPLACES,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "libbz2 (<< 0.9.5d-3)",
- strlen ("libbz2 (<< 0.9.5d-3)") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_SECTION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "utils",
- strlen ("utils") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UPLOAD_PRIORITY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "standard",
- strlen ("standard") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_DESCRIPTION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "high-quality block-sorting file compressor - utilities\n"
-" bzip2 is a freely available, patent free, high-quality data compressor.\n"
-" It typically compresses files to within 10% to 15% of the best available\n"
-" techniques, whilst being around twice as fast at compression and six\n"
-" times faster at decompression.\n"
-" .\n"
-" bzip2 compresses files using the Burrows-Wheeler block-sorting text\n"
-" compression algorithm, and Huffman coding. Compression is generally\n"
-" considerably better than that achieved by more conventional\n"
-" LZ77/LZ78-based compressors, and approaches the performance of the PPM\n"
-" family of statistical compressors.\n"
-" .\n"
-" The archive file format of bzip2 (.bz2) is incompatible with that of its\n"
-" predecessor, bzip (.bz).",
- strlen ("high-quality block-sorting file compressor - utilities\n"
-" bzip2 is a freely available, patent free, high-quality data compressor.\n"
-" It typically compresses files to within 10% to 15% of the best available\n"
-" techniques, whilst being around twice as fast at compression and six\n"
-" times faster at decompression.\n"
-" .\n"
-" bzip2 compresses files using the Burrows-Wheeler block-sorting text\n"
-" compression algorithm, and Huffman coding. Compression is generally\n"
-" considerably better than that achieved by more conventional\n"
-" LZ77/LZ78-based compressors, and approaches the performance of the PPM\n"
-" family of statistical compressors.\n"
-" .\n"
-" The archive file format of bzip2 (.bz2) is incompatible with that of its\n"
-" predecessor, bzip (.bz).") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "application/x-debian-package",
+ strlen ("application/x-debian-package") + 1,
+ 0
+ },
{
- { "testdata/deb_bzip2.deb",
- deb_bzip2_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_PACKAGE_NAME,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "bzip2",
+ strlen ("bzip2") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_VERSION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "1.0.6-4",
+ strlen ("1.0.6-4") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TARGET_ARCHITECTURE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "i386",
+ strlen ("i386") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_MAINTAINER,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Anibal Monsalve Salazar <anibal@debian.org>",
+ strlen ("Anibal Monsalve Salazar <anibal@debian.org>") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_INSTALLED_SIZE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "113", /* FIXME: should this be 'kb'? */
+ strlen ("113") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "libbz2-1.0 (= 1.0.6-4), libc6 (>= 2.4)",
+ strlen ("libbz2-1.0 (= 1.0.6-4), libc6 (>= 2.4)") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_SUGGESTS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "bzip2-doc",
+ strlen ("bzip2-doc") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_REPLACES,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "libbz2 (<< 0.9.5d-3)",
+ strlen ("libbz2 (<< 0.9.5d-3)") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_SECTION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "utils",
+ strlen ("utils") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UPLOAD_PRIORITY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "standard",
+ strlen ("standard") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_DESCRIPTION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "high-quality block-sorting file compressor - utilities\n"
+ " bzip2 is a freely available, patent free, high-quality data compressor.\n"
+ " It typically compresses files to within 10% to 15% of the best available\n"
+ " techniques, whilst being around twice as fast at compression and six\n"
+ " times faster at decompression.\n"
+ " .\n"
+ " bzip2 compresses files using the Burrows-Wheeler block-sorting text\n"
+ " compression algorithm, and Huffman coding. Compression is generally\n"
+ " considerably better than that achieved by more conventional\n"
+ " LZ77/LZ78-based compressors, and approaches the performance of the PPM\n"
+ " family of statistical compressors.\n"
+ " .\n"
+ " The archive file format of bzip2 (.bz2) is incompatible with that of its\n"
+ " predecessor, bzip (.bz).",
+ strlen ("high-quality block-sorting file compressor - utilities\n"
+ " bzip2 is a freely available, patent free, high-quality data compressor.\n"
+ " It typically compresses files to within 10% to 15% of the best available\n"
+ " techniques, whilst being around twice as fast at compression and six\n"
+ " times faster at decompression.\n"
+ " .\n"
+ " bzip2 compresses files using the Burrows-Wheeler block-sorting text\n"
+ " compression algorithm, and Huffman coding. Compression is generally\n"
+ " considerably better than that achieved by more conventional\n"
+ " LZ77/LZ78-based compressors, and approaches the performance of the PPM\n"
+ " family of statistical compressors.\n"
+ " .\n"
+ " The archive file format of bzip2 (.bz2) is incompatible with that of its\n"
+ " predecessor, bzip (.bz).") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/deb_bzip2.deb",
+ deb_bzip2_sol },
+ { NULL, NULL }
+ };
return ET_main ("deb", ps);
}
+
/* end of test_deb.c */
diff --git a/src/plugins/test_dvi.c b/src/plugins/test_dvi.c
@@ -36,89 +36,94 @@
int
main (int argc, char *argv[])
{
- struct SolutionData dvi_ora_sol[] =
+ struct SolutionData dvi_ora_sol[] = {
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "application/x-dvi",
- strlen ("application/x-dvi") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PAGE_COUNT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "10",
- strlen ("10") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- "Optimal Bitwise Register Allocation using Integer Linear Programming",
- strlen ("Optimal Bitwise Register Allocation using Integer Linear Programming") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_SUBJECT,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- "Register Allocation",
- strlen ("Register Allocation") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- " TeX output 2005.02.06:0725",
- strlen (" TeX output 2005.02.06:0725") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- "LaTeX with hyperref package",
- strlen ("LaTeX with hyperref package") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_AUTHOR_NAME,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- "Rajkishore Barik and Christian Grothoff and Rahul Gupta and Vinayaka Pandit and Raghavendra Udupa",
- strlen ("Rajkishore Barik and Christian Grothoff and Rahul Gupta and Vinayaka Pandit and Raghavendra Udupa") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PRODUCED_BY_SOFTWARE,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- "dvips + Distiller",
- strlen ("dvips + Distiller") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_KEYWORDS,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- "register allocation integer linear programming bit-wise spilling coalesing rematerialization",
- strlen ("register allocation integer linear programming bit-wise spilling coalesing rematerialization") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "application/x-dvi",
+ strlen ("application/x-dvi") + 1,
+ 0
+ },
{
- { "testdata/dvi_ora.dvi",
- dvi_ora_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_PAGE_COUNT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "10",
+ strlen ("10") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ "Optimal Bitwise Register Allocation using Integer Linear Programming",
+ strlen (
+ "Optimal Bitwise Register Allocation using Integer Linear Programming")
+ + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_SUBJECT,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ "Register Allocation",
+ strlen ("Register Allocation") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ " TeX output 2005.02.06:0725",
+ strlen (" TeX output 2005.02.06:0725") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ "LaTeX with hyperref package",
+ strlen ("LaTeX with hyperref package") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_AUTHOR_NAME,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ "Rajkishore Barik and Christian Grothoff and Rahul Gupta and Vinayaka Pandit and Raghavendra Udupa",
+ strlen (
+ "Rajkishore Barik and Christian Grothoff and Rahul Gupta and Vinayaka Pandit and Raghavendra Udupa")
+ + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PRODUCED_BY_SOFTWARE,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ "dvips + Distiller",
+ strlen ("dvips + Distiller") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_KEYWORDS,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ "register allocation integer linear programming bit-wise spilling coalesing rematerialization",
+ strlen (
+ "register allocation integer linear programming bit-wise spilling coalesing rematerialization")
+ + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/dvi_ora.dvi",
+ dvi_ora_sol },
+ { NULL, NULL }
+ };
return ET_main ("dvi", ps);
}
+
/* end of test_dvi.c */
diff --git a/src/plugins/test_exiv2.c b/src/plugins/test_exiv2.c
@@ -36,305 +36,306 @@
int
main (int argc, char *argv[])
{
- struct SolutionData exiv2_iptc_sol[] =
- {
- {
- EXTRACTOR_METATYPE_GPS_LATITUDE_REF,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "North",
- strlen ("North") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_GPS_LATITUDE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "28deg 8' 17.585\" ",
- strlen ("28deg 8' 17.585\" ") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_GPS_LONGITUDE_REF,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "West",
- strlen ("West") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_GPS_LONGITUDE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "14deg 14' 21.713\" ",
- strlen ("14deg 14' 21.713\" ") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CAMERA_MAKE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "PENTAX Corporation",
- strlen ("PENTAX Corporation") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CAMERA_MODEL,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "PENTAX Optio W30",
- strlen ("PENTAX Optio W30") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ORIENTATION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "top, left",
- strlen ("top, left") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CREATION_DATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "2008:06:29 16:06:10",
- strlen ("2008:06:29 16:06:10") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_EXPOSURE_BIAS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "0 EV",
- strlen ("0 EV") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_FLASH,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "No, compulsory",
- strlen ("No, compulsory") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_FOCAL_LENGTH,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "18.9 mm",
- strlen ("18.9 mm") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_FOCAL_LENGTH_35MM,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "114.0 mm",
- strlen ("114.0 mm") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ISO_SPEED,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "64",
- strlen ("64") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_METERING_MODE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Multi-segment",
- strlen ("Multi-segment") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_APERTURE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "F8",
- strlen ("F8") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_EXPOSURE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "1/320 s",
- strlen ("1/320 s") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_LOCATION_CITY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Los Verdes",
- strlen ("Los Verdes") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_LOCATION_CITY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Los Verdes",
- strlen ("Los Verdes") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_LOCATION_SUBLOCATION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Fuerteventura",
- strlen ("Fuerteventura") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_LOCATION_COUNTRY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Spain",
- strlen ("Spain") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_LOCATION_COUNTRY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Spain",
- strlen ("Spain") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_KEYWORDS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Fuerteventura",
- strlen ("Fuerteventura") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_KEYWORDS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Landschaftsbild",
- strlen ("Landschaftsbild") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_KEYWORDS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ProCenter Rene Egli",
- strlen ("ProCenter Rene Egli") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_KEYWORDS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Sand",
- strlen ("Sand") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_KEYWORDS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Sport",
- strlen ("Sport") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_KEYWORDS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Urlaub",
- strlen ("Urlaub") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_KEYWORDS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Was?",
- strlen ("Was?") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_KEYWORDS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Wind",
- strlen ("Wind") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_KEYWORDS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Windsurfen",
- strlen ("Windsurfen") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_KEYWORDS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Wo?",
- strlen ("Wo?") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_RATING,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "3",
- strlen ("3") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_RATING,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "50",
- strlen ("50") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_LOCATION_COUNTRY_CODE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ES",
- strlen ("ES") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Optio W30 Ver 1.00",
- strlen ("Optio W30 Ver 1.00") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_SUBJECT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Wo?, Wo?|Fuerteventura, Was?, Was?|Anlass]|Urlaub, Was?|Aufnahme]|Landschaftsbild, Was?|Natur]|Wind, Was?|Natur]|Sand, Wo?|Fuerteventura|ProCenter Rene Egli, Was?|Sport, Was?|Sport|Windsurfen",
- strlen ("Wo?, Wo?|Fuerteventura, Was?, Was?|Anlass]|Urlaub, Was?|Aufnahme]|Landschaftsbild, Was?|Natur]|Wind, Was?|Natur]|Sand, Wo?|Fuerteventura|ProCenter Rene Egli, Was?|Sport, Was?|Sport|Windsurfen") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
- {
- { "testdata/exiv2_iptc.jpg",
- exiv2_iptc_sol },
- { NULL, NULL }
- };
+ struct SolutionData exiv2_iptc_sol[] = {
+ {
+ EXTRACTOR_METATYPE_GPS_LATITUDE_REF,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "North",
+ strlen ("North") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_GPS_LATITUDE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "28deg 8' 17.585\" ",
+ strlen ("28deg 8' 17.585\" ") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_GPS_LONGITUDE_REF,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "West",
+ strlen ("West") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_GPS_LONGITUDE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "14deg 14' 21.713\" ",
+ strlen ("14deg 14' 21.713\" ") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CAMERA_MAKE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "PENTAX Corporation",
+ strlen ("PENTAX Corporation") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CAMERA_MODEL,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "PENTAX Optio W30",
+ strlen ("PENTAX Optio W30") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ORIENTATION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "top, left",
+ strlen ("top, left") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CREATION_DATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2008:06:29 16:06:10",
+ strlen ("2008:06:29 16:06:10") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_EXPOSURE_BIAS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "0 EV",
+ strlen ("0 EV") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_FLASH,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "No, compulsory",
+ strlen ("No, compulsory") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_FOCAL_LENGTH,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "18.9 mm",
+ strlen ("18.9 mm") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_FOCAL_LENGTH_35MM,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "114.0 mm",
+ strlen ("114.0 mm") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ISO_SPEED,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "64",
+ strlen ("64") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_METERING_MODE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Multi-segment",
+ strlen ("Multi-segment") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_APERTURE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "F8",
+ strlen ("F8") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_EXPOSURE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "1/320 s",
+ strlen ("1/320 s") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_LOCATION_CITY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Los Verdes",
+ strlen ("Los Verdes") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_LOCATION_CITY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Los Verdes",
+ strlen ("Los Verdes") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_LOCATION_SUBLOCATION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Fuerteventura",
+ strlen ("Fuerteventura") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_LOCATION_COUNTRY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Spain",
+ strlen ("Spain") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_LOCATION_COUNTRY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Spain",
+ strlen ("Spain") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_KEYWORDS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Fuerteventura",
+ strlen ("Fuerteventura") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_KEYWORDS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Landschaftsbild",
+ strlen ("Landschaftsbild") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_KEYWORDS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ProCenter Rene Egli",
+ strlen ("ProCenter Rene Egli") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_KEYWORDS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Sand",
+ strlen ("Sand") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_KEYWORDS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Sport",
+ strlen ("Sport") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_KEYWORDS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Urlaub",
+ strlen ("Urlaub") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_KEYWORDS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Was?",
+ strlen ("Was?") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_KEYWORDS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Wind",
+ strlen ("Wind") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_KEYWORDS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Windsurfen",
+ strlen ("Windsurfen") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_KEYWORDS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Wo?",
+ strlen ("Wo?") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_RATING,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "3",
+ strlen ("3") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_RATING,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "50",
+ strlen ("50") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_LOCATION_COUNTRY_CODE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ES",
+ strlen ("ES") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Optio W30 Ver 1.00",
+ strlen ("Optio W30 Ver 1.00") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_SUBJECT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Wo?, Wo?|Fuerteventura, Was?, Was?|Anlass]|Urlaub, Was?|Aufnahme]|Landschaftsbild, Was?|Natur]|Wind, Was?|Natur]|Sand, Wo?|Fuerteventura|ProCenter Rene Egli, Was?|Sport, Was?|Sport|Windsurfen",
+ strlen (
+ "Wo?, Wo?|Fuerteventura, Was?, Was?|Anlass]|Urlaub, Was?|Aufnahme]|Landschaftsbild, Was?|Natur]|Wind, Was?|Natur]|Sand, Wo?|Fuerteventura|ProCenter Rene Egli, Was?|Sport, Was?|Sport|Windsurfen")
+ + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/exiv2_iptc.jpg",
+ exiv2_iptc_sol },
+ { NULL, NULL }
+ };
return ET_main ("exiv2", ps);
}
+
/* end of test_exiv2.c */
diff --git a/src/plugins/test_flac.c b/src/plugins/test_flac.c
@@ -26,7 +26,6 @@
#include "test_lib.h"
-
/**
* Main function for the FLAC testcase.
*
@@ -37,39 +36,37 @@
int
main (int argc, char *argv[])
{
- struct SolutionData kraftwerk_sol[] =
- {
- {
- EXTRACTOR_METATYPE_RESOURCE_TYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "44100 Hz, 2 channels",
- strlen ("44100 Hz, 2 channels") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Test Title",
- strlen ("Test Title") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct SolutionData alien_sol[] =
+ struct SolutionData kraftwerk_sol[] = {
{
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_RESOURCE_TYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "44100 Hz, 2 channels",
+ strlen ("44100 Hz, 2 channels") + 1,
+ 0
+ },
{
- { "testdata/flac_kraftwerk.flac",
- kraftwerk_sol },
- { "testdata/mpeg_alien.mpg",
- alien_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Test Title",
+ strlen ("Test Title") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct SolutionData alien_sol[] = {
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/flac_kraftwerk.flac",
+ kraftwerk_sol },
+ { "testdata/mpeg_alien.mpg",
+ alien_sol },
+ { NULL, NULL }
+ };
return ET_main ("flac", ps);
}
+
/* end of test_flac.c */
diff --git a/src/plugins/test_gif.c b/src/plugins/test_gif.c
@@ -26,7 +26,6 @@
#include "test_lib.h"
-
/**
* Main function for the GIF testcase.
*
@@ -37,41 +36,40 @@
int
main (int argc, char *argv[])
{
- struct SolutionData gif_image_sol[] =
+ struct SolutionData gif_image_sol[] = {
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "image/gif",
+ strlen ("image/gif") + 1,
+ 0
+ },
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "image/gif",
- strlen ("image/gif") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "4x4",
- strlen ("4x4") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- "Testing keyword extraction\n",
- strlen ("Testing keyword extraction\n"),
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "4x4",
+ strlen ("4x4") + 1,
+ 0
+ },
{
- { "testdata/gif_image.gif",
- gif_image_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ "Testing keyword extraction\n",
+ strlen ("Testing keyword extraction\n"),
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/gif_image.gif",
+ gif_image_sol },
+ { NULL, NULL }
+ };
return ET_main ("gif", ps);
}
+
/* end of test_gif.c */
diff --git a/src/plugins/test_gstreamer.c b/src/plugins/test_gstreamer.c
@@ -42,67 +42,69 @@ discoverer_main (GstDiscoverer *dc, const char *filename)
GstDiscovererInfo *info;
GstDiscovererResult result;
- if (! gst_uri_is_valid (filename))
+ if (! gst_uri_is_valid (filename))
+ {
+ if (! g_path_is_absolute (filename))
{
- if (! g_path_is_absolute (filename))
- {
- gchar *cur_dir;
-
- cur_dir = g_get_current_dir ();
- path = g_build_filename (cur_dir, filename, NULL);
- g_free (cur_dir);
- }
- else
- {
- path = g_strdup (filename);
- }
-
- uri = g_filename_to_uri (path, NULL, &err);
- g_free (path);
- path = NULL;
-
- if (err)
- {
- g_warning ("Couldn't convert filename %s to URI: %s\n", filename, err->message);
- g_error_free (err);
- return GST_DISCOVERER_ERROR;
- }
+ gchar *cur_dir;
+
+ cur_dir = g_get_current_dir ();
+ path = g_build_filename (cur_dir, filename, NULL);
+ g_free (cur_dir);
}
- else
+ else
{
- uri = g_strdup (filename);
+ path = g_strdup (filename);
}
- info = gst_discoverer_discover_uri (dc, uri, &err);
- result = gst_discoverer_info_get_result (info);
- switch (result)
+
+ uri = g_filename_to_uri (path, NULL, &err);
+ g_free (path);
+ path = NULL;
+
+ if (err)
{
- case GST_DISCOVERER_OK:
- break;
- case GST_DISCOVERER_URI_INVALID:
- g_print ("URI %s is not valid\n", uri);
- break;
- case GST_DISCOVERER_ERROR:
- g_print ("An error was encountered while discovering the file %s\n", filename);
- g_print (" %s\n", err->message);
- break;
- case GST_DISCOVERER_TIMEOUT:
- g_print ("Analyzing URI %s timed out\n", uri);
- break;
- case GST_DISCOVERER_BUSY:
- g_print ("Discoverer was busy\n");
- break;
- case GST_DISCOVERER_MISSING_PLUGINS:
- g_print ("Will skip %s: missing plugins\n", filename);
- break;
- default:
- g_print ("Unexpected result %d\n", result);
- break;
- }
+ g_warning ("Couldn't convert filename %s to URI: %s\n", filename,
+ err->message);
+ g_error_free (err);
+ return GST_DISCOVERER_ERROR;
+ }
+ }
+ else
+ {
+ uri = g_strdup (filename);
+ }
+ info = gst_discoverer_discover_uri (dc, uri, &err);
+ result = gst_discoverer_info_get_result (info);
+ switch (result)
+ {
+ case GST_DISCOVERER_OK:
+ break;
+ case GST_DISCOVERER_URI_INVALID:
+ g_print ("URI %s is not valid\n", uri);
+ break;
+ case GST_DISCOVERER_ERROR:
+ g_print ("An error was encountered while discovering the file %s\n",
+ filename);
+ g_print (" %s\n", err->message);
+ break;
+ case GST_DISCOVERER_TIMEOUT:
+ g_print ("Analyzing URI %s timed out\n", uri);
+ break;
+ case GST_DISCOVERER_BUSY:
+ g_print ("Discoverer was busy\n");
+ break;
+ case GST_DISCOVERER_MISSING_PLUGINS:
+ g_print ("Will skip %s: missing plugins\n", filename);
+ break;
+ default:
+ g_print ("Unexpected result %d\n", result);
+ break;
+ }
if (err)
g_error_free (err);
gst_discoverer_info_unref (info);
g_free (uri);
-
+
return result;
}
@@ -124,11 +126,11 @@ main (int argc, char *argv[])
gst_init (&argc, &argv);
dc = gst_discoverer_new (10 * GST_SECOND, &err);
- if (NULL == dc)
- {
- g_print ("Error initializing: %s\n", err->message);
- return 0;
- }
+ if (NULL == dc)
+ {
+ g_print ("Error initializing: %s\n", err->message);
+ return 0;
+ }
if (NULL != err)
g_error_free (err);
@@ -136,171 +138,170 @@ main (int argc, char *argv[])
if (GST_DISCOVERER_MISSING_PLUGINS != pre_test)
{
int test_result;
- struct SolutionData thirty_and_thirtythree_sol[] =
- {
- {
- EXTRACTOR_METATYPE_DURATION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "0:00:05.061000000",
- strlen ("0:00:05.061000000") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TRACK_NUMBER,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "21",
- strlen ("21") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ALBUM,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Zee Album",
- strlen ("Zee Album") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CREATION_TIME,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "9999",
- strlen ("9999") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ARTIST,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "All performed by Nobody",
- strlen ("All performed by Nobody") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ARTIST,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "This Artist Contributed",
- strlen ("This Artist Contributed") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Some title",
- strlen ("Some title") + 1,
- 0
- },
- /* Suggest a fix to gst devs; should be a comment, not description */
- {
- EXTRACTOR_METATYPE_DESCRIPTION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "A witty comment",
- strlen ("A witty comment") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CONTAINER_FORMAT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ASF",
- strlen ("ASF") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_AUDIO_CODEC,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "WMA Version 8",
- strlen ("WMA Version 8") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "video/x-ms-asf",
- strlen ("video/x-ms-asf") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "audio/x-wma",
- strlen ("audio/x-wma") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "wmaversion=2",
- strlen ("wmaversion=2") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "bitrate=96024",
- strlen ("bitrate=96024") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "block_align=4459",
- strlen ("block_align=4459") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_AUDIO_LANGUAGE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "en",
- strlen ("en") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CHANNELS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "2",
- strlen ("2") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_SAMPLE_RATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "44100",
- strlen ("44100") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_AUDIO_DEPTH,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "16",
- strlen ("16") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
- {
- { "testdata/gstreamer_30_and_33.asf", thirty_and_thirtythree_sol },
- { NULL, NULL }
- };
+ struct SolutionData thirty_and_thirtythree_sol[] = {
+ {
+ EXTRACTOR_METATYPE_DURATION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "0:00:05.061000000",
+ strlen ("0:00:05.061000000") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TRACK_NUMBER,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "21",
+ strlen ("21") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ALBUM,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Zee Album",
+ strlen ("Zee Album") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CREATION_TIME,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "9999",
+ strlen ("9999") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ARTIST,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "All performed by Nobody",
+ strlen ("All performed by Nobody") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ARTIST,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "This Artist Contributed",
+ strlen ("This Artist Contributed") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Some title",
+ strlen ("Some title") + 1,
+ 0
+ },
+ /* Suggest a fix to gst devs; should be a comment, not description */
+ {
+ EXTRACTOR_METATYPE_DESCRIPTION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "A witty comment",
+ strlen ("A witty comment") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CONTAINER_FORMAT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ASF",
+ strlen ("ASF") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_AUDIO_CODEC,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "WMA Version 8",
+ strlen ("WMA Version 8") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "video/x-ms-asf",
+ strlen ("video/x-ms-asf") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "audio/x-wma",
+ strlen ("audio/x-wma") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "wmaversion=2",
+ strlen ("wmaversion=2") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "bitrate=96024",
+ strlen ("bitrate=96024") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "block_align=4459",
+ strlen ("block_align=4459") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_AUDIO_LANGUAGE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "en",
+ strlen ("en") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CHANNELS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2",
+ strlen ("2") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_SAMPLE_RATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "44100",
+ strlen ("44100") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_AUDIO_DEPTH,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "16",
+ strlen ("16") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/gstreamer_30_and_33.asf", thirty_and_thirtythree_sol },
+ { NULL, NULL }
+ };
g_print ("Running asf test on GStreamer:\n");
test_result = (0 == ET_main ("gstreamer", ps) ? 0 : 1);
- g_print ("asf GStreamer test result: %s\n", test_result == 0 ? "OK" : "FAILED");
+ g_print ("asf GStreamer test result: %s\n", test_result == 0 ? "OK" :
+ "FAILED");
result += test_result;
}
@@ -308,401 +309,399 @@ main (int argc, char *argv[])
if (pre_test != GST_DISCOVERER_MISSING_PLUGINS)
{
int test_result;
- struct SolutionData barsandtone_sol[] =
- {
- {
- EXTRACTOR_METATYPE_DURATION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "0:00:06.060000000",
- strlen ("0:00:06.060000000") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "video/x-flv",
- strlen ("video/x-flv") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "video/x-vp6-flash",
- strlen ("video/x-vp6-flash") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_VIDEO_DURATION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "0:00:06.000000000",
- strlen ("0:00:06.000000000") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_AUDIO_CODEC,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "MPEG-1 Layer 3 (MP3)",
- strlen ("MPEG-1 Layer 3 (MP3)") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_VIDEO_CODEC,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "On2 VP6/Flash",
- strlen ("On2 VP6/Flash") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_VIDEO_DIMENSIONS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "368x288",
- strlen ("368x288") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_FRAME_RATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "10/1",
- strlen ("10/1") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "1/1",
- strlen ("1/1") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "audio/mpeg",
- strlen ("audio/mpeg") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "mpegversion=1",
- strlen ("mpegversion=1") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "mpegaudioversion=1",
- strlen ("mpegaudioversion=1") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "layer=3",
- strlen ("layer=3") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "parsed=true",
- strlen ("parsed=true") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_AUDIO_DURATION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "0:00:06.000000000",
- strlen ("0:00:06.000000000") + 1,
- 0
- },
- /* Yes, again. This seems to be a bug/feature of the element that
- * gives us these streams; this doesn't happen when discovering
- * Matroska files, for example. Or maybe file itself is made that way.
- */
- {
- EXTRACTOR_METATYPE_AUDIO_CODEC,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "MPEG-1 Layer 3 (MP3)",
- strlen ("MPEG-1 Layer 3 (MP3)") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_VIDEO_CODEC,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "On2 VP6/Flash",
- strlen ("On2 VP6/Flash") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "has-crc=false",
- strlen ("has-crc=false") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "channel-mode=joint-stereo",
- strlen ("channel-mode=joint-stereo") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CHANNELS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "2",
- strlen ("2") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_SAMPLE_RATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "44100",
- strlen ("44100") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_AUDIO_BITRATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "96000",
- strlen ("96000") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
- {
- { "testdata/gstreamer_barsandtone.flv", barsandtone_sol },
- { NULL, NULL }
- };
+ struct SolutionData barsandtone_sol[] = {
+ {
+ EXTRACTOR_METATYPE_DURATION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "0:00:06.060000000",
+ strlen ("0:00:06.060000000") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "video/x-flv",
+ strlen ("video/x-flv") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "video/x-vp6-flash",
+ strlen ("video/x-vp6-flash") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_VIDEO_DURATION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "0:00:06.000000000",
+ strlen ("0:00:06.000000000") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_AUDIO_CODEC,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "MPEG-1 Layer 3 (MP3)",
+ strlen ("MPEG-1 Layer 3 (MP3)") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_VIDEO_CODEC,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "On2 VP6/Flash",
+ strlen ("On2 VP6/Flash") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_VIDEO_DIMENSIONS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "368x288",
+ strlen ("368x288") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_FRAME_RATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "10/1",
+ strlen ("10/1") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "1/1",
+ strlen ("1/1") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "audio/mpeg",
+ strlen ("audio/mpeg") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "mpegversion=1",
+ strlen ("mpegversion=1") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "mpegaudioversion=1",
+ strlen ("mpegaudioversion=1") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "layer=3",
+ strlen ("layer=3") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "parsed=true",
+ strlen ("parsed=true") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_AUDIO_DURATION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "0:00:06.000000000",
+ strlen ("0:00:06.000000000") + 1,
+ 0
+ },
+ /* Yes, again. This seems to be a bug/feature of the element that
+ * gives us these streams; this doesn't happen when discovering
+ * Matroska files, for example. Or maybe file itself is made that way.
+ */
+ {
+ EXTRACTOR_METATYPE_AUDIO_CODEC,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "MPEG-1 Layer 3 (MP3)",
+ strlen ("MPEG-1 Layer 3 (MP3)") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_VIDEO_CODEC,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "On2 VP6/Flash",
+ strlen ("On2 VP6/Flash") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "has-crc=false",
+ strlen ("has-crc=false") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "channel-mode=joint-stereo",
+ strlen ("channel-mode=joint-stereo") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CHANNELS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2",
+ strlen ("2") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_SAMPLE_RATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "44100",
+ strlen ("44100") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_AUDIO_BITRATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "96000",
+ strlen ("96000") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/gstreamer_barsandtone.flv", barsandtone_sol },
+ { NULL, NULL }
+ };
g_print ("Running flv test on GStreamer:\n");
test_result = (0 == ET_main ("gstreamer", ps) ? 0 : 1);
- g_print ("flv GStreamer test result: %s\n", test_result == 0 ? "OK" : "FAILED");
+ g_print ("flv GStreamer test result: %s\n", test_result == 0 ? "OK" :
+ "FAILED");
result += test_result;
}
pre_test = discoverer_main (dc, "testdata/gstreamer_sample_sorenson.mov");
if (pre_test != GST_DISCOVERER_MISSING_PLUGINS)
{
int test_result;
- struct SolutionData sample_sorenson_sol[] =
- {
- {
- EXTRACTOR_METATYPE_DURATION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "0:00:05.000000000",
- strlen ("0:00:05.000000000") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "video/quicktime",
- strlen ("video/quicktime") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "audio/x-qdm2",
- strlen ("audio/x-qdm2") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "samplesize=16",
- strlen ("samplesize=16") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_AUDIO_CODEC,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "QDesign Music v.2",
- strlen ("QDesign Music v.2") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CREATION_TIME,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "2001-02-19T16:45:54Z",
- strlen ("2001-02-19T16:45:54Z") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "QuickTime Sample Movie",
- strlen ("QuickTime Sample Movie") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_COPYRIGHT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "© Apple Computer, Inc. 2001",
- strlen ("© Apple Computer, Inc. 2001") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CONTAINER_FORMAT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ISO MP4/M4A",
- strlen ("ISO MP4/M4A") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_AUDIO_LANGUAGE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "en",
- strlen ("en") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CHANNELS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "2",
- strlen ("2") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_SAMPLE_RATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "22050",
- strlen ("22050") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "video/x-svq",
- strlen ("video/x-svq") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "svqversion=1",
- strlen ("svqversion=1") + 1,
- 0
- },
- /* Yep, again... */
- {
- EXTRACTOR_METATYPE_CREATION_TIME,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "2001-02-19T16:45:54Z",
- strlen ("2001-02-19T16:45:54Z") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "QuickTime Sample Movie",
- strlen ("QuickTime Sample Movie") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_COPYRIGHT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "© Apple Computer, Inc. 2001",
- strlen ("© Apple Computer, Inc. 2001") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CONTAINER_FORMAT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ISO MP4/M4A",
- strlen ("ISO MP4/M4A") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_VIDEO_CODEC,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Sorensen video v.1",
- strlen ("Sorensen video v.1") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_VIDEO_LANGUAGE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "en",
- strlen ("en") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_VIDEO_DIMENSIONS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "190x240",
- strlen ("190x240") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_FRAME_RATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "12/1",
- strlen ("12/1") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "1/1",
- strlen ("1/1") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
- {
- { "testdata/gstreamer_sample_sorenson.mov", sample_sorenson_sol },
- { NULL, NULL }
- };
+ struct SolutionData sample_sorenson_sol[] = {
+ {
+ EXTRACTOR_METATYPE_DURATION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "0:00:05.000000000",
+ strlen ("0:00:05.000000000") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "video/quicktime",
+ strlen ("video/quicktime") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "audio/x-qdm2",
+ strlen ("audio/x-qdm2") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "samplesize=16",
+ strlen ("samplesize=16") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_AUDIO_CODEC,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "QDesign Music v.2",
+ strlen ("QDesign Music v.2") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CREATION_TIME,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2001-02-19T16:45:54Z",
+ strlen ("2001-02-19T16:45:54Z") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "QuickTime Sample Movie",
+ strlen ("QuickTime Sample Movie") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_COPYRIGHT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "© Apple Computer, Inc. 2001",
+ strlen ("© Apple Computer, Inc. 2001") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CONTAINER_FORMAT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ISO MP4/M4A",
+ strlen ("ISO MP4/M4A") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_AUDIO_LANGUAGE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "en",
+ strlen ("en") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CHANNELS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2",
+ strlen ("2") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_SAMPLE_RATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "22050",
+ strlen ("22050") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "video/x-svq",
+ strlen ("video/x-svq") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "svqversion=1",
+ strlen ("svqversion=1") + 1,
+ 0
+ },
+ /* Yep, again... */
+ {
+ EXTRACTOR_METATYPE_CREATION_TIME,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2001-02-19T16:45:54Z",
+ strlen ("2001-02-19T16:45:54Z") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "QuickTime Sample Movie",
+ strlen ("QuickTime Sample Movie") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_COPYRIGHT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "© Apple Computer, Inc. 2001",
+ strlen ("© Apple Computer, Inc. 2001") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CONTAINER_FORMAT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ISO MP4/M4A",
+ strlen ("ISO MP4/M4A") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_VIDEO_CODEC,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Sorensen video v.1",
+ strlen ("Sorensen video v.1") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_VIDEO_LANGUAGE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "en",
+ strlen ("en") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_VIDEO_DIMENSIONS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "190x240",
+ strlen ("190x240") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_FRAME_RATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "12/1",
+ strlen ("12/1") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "1/1",
+ strlen ("1/1") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/gstreamer_sample_sorenson.mov", sample_sorenson_sol },
+ { NULL, NULL }
+ };
g_print ("Running mov test on GStreamer:\n");
test_result = (0 == ET_main ("gstreamer", ps) ? 0 : 1);
- g_print ("mov GStreamer test result: %s\n", test_result == 0 ? "OK" : "FAILED");
+ g_print ("mov GStreamer test result: %s\n", test_result == 0 ? "OK" :
+ "FAILED");
result += test_result;
}
@@ -711,956 +710,957 @@ main (int argc, char *argv[])
{
int result_stock;
int result_patched;
- struct SolutionData matroska_flame_stock_sol[] =
- {
- {
- EXTRACTOR_METATYPE_DURATION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "0:00:03.143000000",
- strlen ("0:00:03.143000000") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "video/x-matroska",
- strlen ("video/x-matroska") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "video/x-indeo",
- strlen ("video/x-indeo") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "indeoversion=4",
- strlen ("indeoversion=4") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "filesegmenttitle",
- strlen ("filesegmenttitle") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "TITLE",
- strlen ("TITLE") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ARTIST,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ALBUM/ARTIST",
- strlen ("ALBUM/ARTIST") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ARTIST,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ARTIST",
- strlen ("ARTIST") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_COPYRIGHT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "COPYRIGHT",
- strlen ("COPYRIGHT") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_COMPOSER,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "COMPOSER",
- strlen ("COMPOSER") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_GENRE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "GENRE",
- strlen ("GENRE") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ENCODER,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ENCODER",
- strlen ("ENCODER") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ISRC,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ISRC",
- strlen ("ISRC") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CONTAINER_FORMAT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Matroska",
- strlen ("Matroska") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_VIDEO_CODEC,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Intel Video 4",
- strlen ("Intel Video 4") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_VIDEO_LANGUAGE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "it",
- strlen ("it") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_VIDEO_DIMENSIONS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "256x240",
- strlen ("256x240") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_FRAME_RATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "35/1",
- strlen ("35/1") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "1/1",
- strlen ("1/1") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet stock_ps[] =
- {
- { "testdata/matroska_flame.mkv", matroska_flame_stock_sol },
- { NULL, NULL }
- };
+ struct SolutionData matroska_flame_stock_sol[] = {
+ {
+ EXTRACTOR_METATYPE_DURATION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "0:00:03.143000000",
+ strlen ("0:00:03.143000000") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "video/x-matroska",
+ strlen ("video/x-matroska") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "video/x-indeo",
+ strlen ("video/x-indeo") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "indeoversion=4",
+ strlen ("indeoversion=4") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "filesegmenttitle",
+ strlen ("filesegmenttitle") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "TITLE",
+ strlen ("TITLE") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ARTIST,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ALBUM/ARTIST",
+ strlen ("ALBUM/ARTIST") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ARTIST,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ARTIST",
+ strlen ("ARTIST") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_COPYRIGHT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "COPYRIGHT",
+ strlen ("COPYRIGHT") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_COMPOSER,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "COMPOSER",
+ strlen ("COMPOSER") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_GENRE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "GENRE",
+ strlen ("GENRE") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ENCODER,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ENCODER",
+ strlen ("ENCODER") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ISRC,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ISRC",
+ strlen ("ISRC") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CONTAINER_FORMAT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Matroska",
+ strlen ("Matroska") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_VIDEO_CODEC,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Intel Video 4",
+ strlen ("Intel Video 4") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_VIDEO_LANGUAGE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "it",
+ strlen ("it") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_VIDEO_DIMENSIONS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "256x240",
+ strlen ("256x240") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_FRAME_RATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "35/1",
+ strlen ("35/1") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "1/1",
+ strlen ("1/1") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet stock_ps[] = {
+ { "testdata/matroska_flame.mkv", matroska_flame_stock_sol },
+ { NULL, NULL }
+ };
- struct SolutionData matroska_flame_patched_sol[] =
- {
- {
- EXTRACTOR_METATYPE_DURATION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "0:00:03.143000000",
- strlen ("0:00:03.143000000") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "video/x-matroska",
- strlen ("video/x-matroska") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "video/x-indeo",
- strlen ("video/x-indeo") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "indeoversion=4",
- strlen ("indeoversion=4") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "filesegmenttitle",
- strlen ("filesegmenttitle") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ALBUM,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ALBUM/TITLE",
- strlen ("ALBUM/TITLE") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "TITLE",
- strlen ("TITLE") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "SUBTITLE",
- strlen ("SUBTITLE") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "VIDEO/TITLE",
- strlen ("VIDEO/TITLE") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ARTIST,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ALBUM/ARTIST",
- strlen ("ALBUM/ARTIST") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ARTIST,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ARTIST",
- strlen ("ARTIST") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_SONG_COUNT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "20",
- strlen ("20") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "PART_OFFSET=5",
- strlen ("PART_OFFSET=5") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ARTIST/INSTRUMENTS=ARTIST/INSTRUMENTS",
- strlen ("ARTIST/INSTRUMENTS=ARTIST/INSTRUMENTS") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "LEAD_PERFORMER=LEAD_PERFORMER",
- strlen ("LEAD_PERFORMER=LEAD_PERFORMER") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ARRANGER=ARRANGER",
- strlen ("ARRANGER=ARRANGER") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "LYRICIST=LYRICIST",
- strlen ("LYRICIST=LYRICIST") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_MOVIE_DIRECTOR,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "DIRECTOR",
- strlen ("DIRECTOR") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ASSISTANT_DIRECTOR=ASSISTANT_DIRECTOR",
- strlen ("ASSISTANT_DIRECTOR=ASSISTANT_DIRECTOR") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "DIRECTOR_OF_PHOTOGRAPHY=DIRECTOR_OF_PHOTOGRAPHY",
- strlen ("DIRECTOR_OF_PHOTOGRAPHY=DIRECTOR_OF_PHOTOGRAPHY") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "SOUND_ENGINEER=SOUND_ENGINEER",
- strlen ("SOUND_ENGINEER=SOUND_ENGINEER") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ART_DIRECTOR=ART_DIRECTOR",
- strlen ("ART_DIRECTOR=ART_DIRECTOR") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "PRODUCTION_DESIGNER=PRODUCTION_DESIGNER",
- strlen ("PRODUCTION_DESIGNER=PRODUCTION_DESIGNER") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "CHOREGRAPHER=CHOREGRAPHER",
- strlen ("CHOREGRAPHER=CHOREGRAPHER") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "COSTUME_DESIGNER=COSTUME_DESIGNER",
- strlen ("COSTUME_DESIGNER=COSTUME_DESIGNER") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ACTOR=ACTOR",
- strlen ("ACTOR=ACTOR") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "CHARACTER=CHARACTER",
- strlen ("CHARACTER=CHARACTER") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_WRITER,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "WRITTEN_BY",
- strlen ("WRITTEN_BY") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "SCREENPLAY_BY=SCREENPLAY_BY",
- strlen ("SCREENPLAY_BY=SCREENPLAY_BY") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "EDITED_BY=EDITED_BY",
- strlen ("EDITED_BY=EDITED_BY") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PRODUCER,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "PRODUCER",
- strlen ("PRODUCER") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "COPRODUCER=COPRODUCER",
- strlen ("COPRODUCER=COPRODUCER") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "EXECUTIVE_PRODUCER=EXECUTIVE_PRODUCER",
- strlen ("EXECUTIVE_PRODUCER=EXECUTIVE_PRODUCER") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "DISTRIBUTED_BY=DISTRIBUTED_BY",
- strlen ("DISTRIBUTED_BY=DISTRIBUTED_BY") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "MASTERED_BY=MASTERED_BY",
- strlen ("MASTERED_BY=MASTERED_BY") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "MIXED_BY=MIXED_BY",
- strlen ("MIXED_BY=MIXED_BY") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "REMIXED_BY=REMIXED_BY",
- strlen ("REMIXED_BY=REMIXED_BY") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "PRODUCTION_STUDIO=PRODUCTION_STUDIO",
- strlen ("PRODUCTION_STUDIO=PRODUCTION_STUDIO") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "THANKS_TO=THANKS_TO",
- strlen ("THANKS_TO=THANKS_TO") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PUBLISHER,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "PUBLISHER",
- strlen ("PUBLISHER") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "LABEL=LABEL",
- strlen ("LABEL=LABEL") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_MOOD,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "MOOD",
- strlen ("MOOD") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ORIGINAL_MEDIA_TYPE=ORIGINAL_MEDIA_TYPE",
- strlen ("ORIGINAL_MEDIA_TYPE=ORIGINAL_MEDIA_TYPE") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "CONTENT_TYPE=CONTENT_TYPE",
- strlen ("CONTENT_TYPE=CONTENT_TYPE") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_SUBJECT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "SUBJECT",
- strlen ("SUBJECT") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_SUMMARY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "SUMMARY",
- strlen ("SUMMARY") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "SYNOPSIS=SYNOPSIS",
- strlen ("SYNOPSIS=SYNOPSIS") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "INITIAL_KEY=INITIAL_KEY",
- strlen ("INITIAL_KEY=INITIAL_KEY") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "PERIOD=PERIOD",
- strlen ("PERIOD=PERIOD") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "LAW_RATING=LAW_RATING",
- strlen ("LAW_RATING=LAW_RATING") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "COMPOSITION_LOCATION=COMPOSITION_LOCATION",
- strlen ("COMPOSITION_LOCATION=COMPOSITION_LOCATION") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "COMPOSER_NATIONALITY=COMPOSER_NATIONALITY",
- strlen ("COMPOSER_NATIONALITY=COMPOSER_NATIONALITY") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PLAY_COUNTER,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "PLAY_COUNTER",
- strlen ("PLAY_COUNTER") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_RATING,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "RATING",
- strlen ("RATING") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ENCODER_SETTINGS=ENCODER_SETTINGS",
- strlen ("ENCODER_SETTINGS=ENCODER_SETTINGS") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_FRAME_RATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "FPS",
- strlen ("FPS") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "MEASURE=MEASURE",
- strlen ("MEASURE=MEASURE") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "TUNING=TUNING",
- strlen ("TUNING=TUNING") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ISBN=ISBN",
- strlen ("ISBN=ISBN") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "BARCODE=BARCODE",
- strlen ("BARCODE=BARCODE") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "CATALOG_NUMBER=CATALOG_NUMBER",
- strlen ("CATALOG_NUMBER=CATALOG_NUMBER") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "LABEL_CODE=LABEL_CODE",
- strlen ("LABEL_CODE=LABEL_CODE") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "LCCN=LCCN",
- strlen ("LCCN=LCCN") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "PURCHASE_ITEM=PURCHASE_ITEM",
- strlen ("PURCHASE_ITEM=PURCHASE_ITEM") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "PURCHASE_INFO=PURCHASE_INFO",
- strlen ("PURCHASE_INFO=PURCHASE_INFO") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "PURCHASE_OWNER=PURCHASE_OWNER",
- strlen ("PURCHASE_OWNER=PURCHASE_OWNER") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "PURCHASE_PRICE=PURCHASE_PRICE",
- strlen ("PURCHASE_PRICE=PURCHASE_PRICE") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "PURCHASE_CURRENCY=PURCHASE_CURRENCY",
- strlen ("PURCHASE_CURRENCY=PURCHASE_CURRENCY") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ORIGINAL_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ORIGINAL/TITLE",
- strlen ("ORIGINAL/TITLE") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ORIGINAL/ARTIST/SORT_WITH=ORIGINAL/ARTIST/SORT_WITH",
- strlen ("ORIGINAL/ARTIST/SORT_WITH=ORIGINAL/ARTIST/SORT_WITH") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ORIGINAL_ARTIST,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ORIGINAL/ARTIST",
- strlen ("ORIGINAL/ARTIST") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TRACK_NUMBER,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "10",
- strlen ("10") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_COPYRIGHT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "COPYRIGHT",
- strlen ("COPYRIGHT") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CONTACT_INFORMATION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "COPYRIGHT/EMAIL",
- strlen ("COPYRIGHT/EMAIL") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CONTACT_INFORMATION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "COPYRIGHT/ADDRESS",
- strlen ("COPYRIGHT/ADDRESS") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CREATION_TIME,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "1999-01-01",
- strlen ("1999-01-01") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "The purpose of this file is to hold as many examples of Matroska tags as possible.",
- strlen ("The purpose of this file is to hold as many examples of Matroska tags as possible.") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_COMPOSER,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "COMPOSER",
- strlen ("COMPOSER") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PERFORMER,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ACCOMPANIMENT",
- strlen ("ACCOMPANIMENT") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PERFORMER,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "CONDUCTOR",
- strlen ("CONDUCTOR") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_LYRICS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "LYRICS",
- strlen ("LYRICS") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ENCODED_BY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ENCODED_BY",
- strlen ("ENCODED_BY") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_GENRE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "GENRE",
- strlen ("GENRE") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_DESCRIPTION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "DESCRIPTION",
- strlen ("DESCRIPTION") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_KEYWORDS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "KEYWORDS",
- strlen ("KEYWORDS") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_LOCATION_NAME,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "RECORDING_LOCATION",
- strlen ("RECORDING_LOCATION") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ENCODER,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ENCODER",
- strlen ("ENCODER") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ISRC,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ISRC",
- strlen ("ISRC") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_LICENSE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "LICENSE",
- strlen ("LICENSE") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CONTAINER_FORMAT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Matroska",
- strlen ("Matroska") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_VIDEO_CODEC,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Intel Video 4",
- strlen ("Intel Video 4") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_VIDEO_LANGUAGE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "it",
- strlen ("it") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_VIDEO_DIMENSIONS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "256x240",
- strlen ("256x240") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_FRAME_RATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "35/1",
- strlen ("35/1") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "1/1",
- strlen ("1/1") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet patched_ps[] =
- {
- { "testdata/matroska_flame.mkv", matroska_flame_patched_sol },
- { NULL, NULL }
- };
+ struct SolutionData matroska_flame_patched_sol[] = {
+ {
+ EXTRACTOR_METATYPE_DURATION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "0:00:03.143000000",
+ strlen ("0:00:03.143000000") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "video/x-matroska",
+ strlen ("video/x-matroska") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "video/x-indeo",
+ strlen ("video/x-indeo") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "indeoversion=4",
+ strlen ("indeoversion=4") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "filesegmenttitle",
+ strlen ("filesegmenttitle") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ALBUM,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ALBUM/TITLE",
+ strlen ("ALBUM/TITLE") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "TITLE",
+ strlen ("TITLE") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "SUBTITLE",
+ strlen ("SUBTITLE") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "VIDEO/TITLE",
+ strlen ("VIDEO/TITLE") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ARTIST,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ALBUM/ARTIST",
+ strlen ("ALBUM/ARTIST") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ARTIST,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ARTIST",
+ strlen ("ARTIST") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_SONG_COUNT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "20",
+ strlen ("20") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "PART_OFFSET=5",
+ strlen ("PART_OFFSET=5") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ARTIST/INSTRUMENTS=ARTIST/INSTRUMENTS",
+ strlen ("ARTIST/INSTRUMENTS=ARTIST/INSTRUMENTS") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "LEAD_PERFORMER=LEAD_PERFORMER",
+ strlen ("LEAD_PERFORMER=LEAD_PERFORMER") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ARRANGER=ARRANGER",
+ strlen ("ARRANGER=ARRANGER") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "LYRICIST=LYRICIST",
+ strlen ("LYRICIST=LYRICIST") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_MOVIE_DIRECTOR,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "DIRECTOR",
+ strlen ("DIRECTOR") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ASSISTANT_DIRECTOR=ASSISTANT_DIRECTOR",
+ strlen ("ASSISTANT_DIRECTOR=ASSISTANT_DIRECTOR") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "DIRECTOR_OF_PHOTOGRAPHY=DIRECTOR_OF_PHOTOGRAPHY",
+ strlen ("DIRECTOR_OF_PHOTOGRAPHY=DIRECTOR_OF_PHOTOGRAPHY") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "SOUND_ENGINEER=SOUND_ENGINEER",
+ strlen ("SOUND_ENGINEER=SOUND_ENGINEER") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ART_DIRECTOR=ART_DIRECTOR",
+ strlen ("ART_DIRECTOR=ART_DIRECTOR") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "PRODUCTION_DESIGNER=PRODUCTION_DESIGNER",
+ strlen ("PRODUCTION_DESIGNER=PRODUCTION_DESIGNER") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "CHOREGRAPHER=CHOREGRAPHER",
+ strlen ("CHOREGRAPHER=CHOREGRAPHER") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "COSTUME_DESIGNER=COSTUME_DESIGNER",
+ strlen ("COSTUME_DESIGNER=COSTUME_DESIGNER") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ACTOR=ACTOR",
+ strlen ("ACTOR=ACTOR") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "CHARACTER=CHARACTER",
+ strlen ("CHARACTER=CHARACTER") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_WRITER,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "WRITTEN_BY",
+ strlen ("WRITTEN_BY") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "SCREENPLAY_BY=SCREENPLAY_BY",
+ strlen ("SCREENPLAY_BY=SCREENPLAY_BY") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "EDITED_BY=EDITED_BY",
+ strlen ("EDITED_BY=EDITED_BY") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PRODUCER,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "PRODUCER",
+ strlen ("PRODUCER") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "COPRODUCER=COPRODUCER",
+ strlen ("COPRODUCER=COPRODUCER") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "EXECUTIVE_PRODUCER=EXECUTIVE_PRODUCER",
+ strlen ("EXECUTIVE_PRODUCER=EXECUTIVE_PRODUCER") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "DISTRIBUTED_BY=DISTRIBUTED_BY",
+ strlen ("DISTRIBUTED_BY=DISTRIBUTED_BY") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "MASTERED_BY=MASTERED_BY",
+ strlen ("MASTERED_BY=MASTERED_BY") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "MIXED_BY=MIXED_BY",
+ strlen ("MIXED_BY=MIXED_BY") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "REMIXED_BY=REMIXED_BY",
+ strlen ("REMIXED_BY=REMIXED_BY") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "PRODUCTION_STUDIO=PRODUCTION_STUDIO",
+ strlen ("PRODUCTION_STUDIO=PRODUCTION_STUDIO") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "THANKS_TO=THANKS_TO",
+ strlen ("THANKS_TO=THANKS_TO") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PUBLISHER,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "PUBLISHER",
+ strlen ("PUBLISHER") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "LABEL=LABEL",
+ strlen ("LABEL=LABEL") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_MOOD,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "MOOD",
+ strlen ("MOOD") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ORIGINAL_MEDIA_TYPE=ORIGINAL_MEDIA_TYPE",
+ strlen ("ORIGINAL_MEDIA_TYPE=ORIGINAL_MEDIA_TYPE") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "CONTENT_TYPE=CONTENT_TYPE",
+ strlen ("CONTENT_TYPE=CONTENT_TYPE") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_SUBJECT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "SUBJECT",
+ strlen ("SUBJECT") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_SUMMARY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "SUMMARY",
+ strlen ("SUMMARY") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "SYNOPSIS=SYNOPSIS",
+ strlen ("SYNOPSIS=SYNOPSIS") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "INITIAL_KEY=INITIAL_KEY",
+ strlen ("INITIAL_KEY=INITIAL_KEY") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "PERIOD=PERIOD",
+ strlen ("PERIOD=PERIOD") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "LAW_RATING=LAW_RATING",
+ strlen ("LAW_RATING=LAW_RATING") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "COMPOSITION_LOCATION=COMPOSITION_LOCATION",
+ strlen ("COMPOSITION_LOCATION=COMPOSITION_LOCATION") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "COMPOSER_NATIONALITY=COMPOSER_NATIONALITY",
+ strlen ("COMPOSER_NATIONALITY=COMPOSER_NATIONALITY") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PLAY_COUNTER,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "PLAY_COUNTER",
+ strlen ("PLAY_COUNTER") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_RATING,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "RATING",
+ strlen ("RATING") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ENCODER_SETTINGS=ENCODER_SETTINGS",
+ strlen ("ENCODER_SETTINGS=ENCODER_SETTINGS") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_FRAME_RATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "FPS",
+ strlen ("FPS") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "MEASURE=MEASURE",
+ strlen ("MEASURE=MEASURE") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "TUNING=TUNING",
+ strlen ("TUNING=TUNING") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ISBN=ISBN",
+ strlen ("ISBN=ISBN") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "BARCODE=BARCODE",
+ strlen ("BARCODE=BARCODE") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "CATALOG_NUMBER=CATALOG_NUMBER",
+ strlen ("CATALOG_NUMBER=CATALOG_NUMBER") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "LABEL_CODE=LABEL_CODE",
+ strlen ("LABEL_CODE=LABEL_CODE") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "LCCN=LCCN",
+ strlen ("LCCN=LCCN") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "PURCHASE_ITEM=PURCHASE_ITEM",
+ strlen ("PURCHASE_ITEM=PURCHASE_ITEM") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "PURCHASE_INFO=PURCHASE_INFO",
+ strlen ("PURCHASE_INFO=PURCHASE_INFO") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "PURCHASE_OWNER=PURCHASE_OWNER",
+ strlen ("PURCHASE_OWNER=PURCHASE_OWNER") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "PURCHASE_PRICE=PURCHASE_PRICE",
+ strlen ("PURCHASE_PRICE=PURCHASE_PRICE") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "PURCHASE_CURRENCY=PURCHASE_CURRENCY",
+ strlen ("PURCHASE_CURRENCY=PURCHASE_CURRENCY") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ORIGINAL_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ORIGINAL/TITLE",
+ strlen ("ORIGINAL/TITLE") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ORIGINAL/ARTIST/SORT_WITH=ORIGINAL/ARTIST/SORT_WITH",
+ strlen ("ORIGINAL/ARTIST/SORT_WITH=ORIGINAL/ARTIST/SORT_WITH") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ORIGINAL_ARTIST,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ORIGINAL/ARTIST",
+ strlen ("ORIGINAL/ARTIST") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TRACK_NUMBER,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "10",
+ strlen ("10") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_COPYRIGHT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "COPYRIGHT",
+ strlen ("COPYRIGHT") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CONTACT_INFORMATION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "COPYRIGHT/EMAIL",
+ strlen ("COPYRIGHT/EMAIL") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CONTACT_INFORMATION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "COPYRIGHT/ADDRESS",
+ strlen ("COPYRIGHT/ADDRESS") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CREATION_TIME,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "1999-01-01",
+ strlen ("1999-01-01") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "The purpose of this file is to hold as many examples of Matroska tags as possible.",
+ strlen (
+ "The purpose of this file is to hold as many examples of Matroska tags as possible.")
+ + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_COMPOSER,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "COMPOSER",
+ strlen ("COMPOSER") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PERFORMER,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ACCOMPANIMENT",
+ strlen ("ACCOMPANIMENT") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PERFORMER,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "CONDUCTOR",
+ strlen ("CONDUCTOR") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_LYRICS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "LYRICS",
+ strlen ("LYRICS") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ENCODED_BY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ENCODED_BY",
+ strlen ("ENCODED_BY") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_GENRE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "GENRE",
+ strlen ("GENRE") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_DESCRIPTION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "DESCRIPTION",
+ strlen ("DESCRIPTION") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_KEYWORDS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "KEYWORDS",
+ strlen ("KEYWORDS") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_LOCATION_NAME,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "RECORDING_LOCATION",
+ strlen ("RECORDING_LOCATION") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ENCODER,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ENCODER",
+ strlen ("ENCODER") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ISRC,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ISRC",
+ strlen ("ISRC") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_LICENSE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "LICENSE",
+ strlen ("LICENSE") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CONTAINER_FORMAT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Matroska",
+ strlen ("Matroska") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_VIDEO_CODEC,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Intel Video 4",
+ strlen ("Intel Video 4") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_VIDEO_LANGUAGE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "it",
+ strlen ("it") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_VIDEO_DIMENSIONS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "256x240",
+ strlen ("256x240") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_FRAME_RATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "35/1",
+ strlen ("35/1") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PIXEL_ASPECT_RATIO,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "1/1",
+ strlen ("1/1") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet patched_ps[] = {
+ { "testdata/matroska_flame.mkv", matroska_flame_patched_sol },
+ { NULL, NULL }
+ };
g_print ("Running mkv test on GStreamer, assuming old version:\n");
result_stock = (0 == ET_main ("gstreamer", stock_ps));
- g_print ("Old GStreamer test result: %s\n", result_stock == 0 ? "OK" : "FAILED");
+ g_print ("Old GStreamer test result: %s\n", result_stock == 0 ? "OK" :
+ "FAILED");
g_print ("Running mkv test on GStreamer, assuming new version:\n");
result_patched = (0 == ET_main ("gstreamer", patched_ps));
- g_print ("New GStreamer test result: %s\n", result_patched == 0 ? "OK" : "FAILED");
+ g_print ("New GStreamer test result: %s\n", result_patched == 0 ? "OK" :
+ "FAILED");
if ((! result_stock) && (! result_patched))
- result++;
+ result++;
}
g_object_unref (dc);
if (0 != result)
- {
- fprintf (stderr,
- "gstreamer library did not work perfectly --- consider updating it.\n");
- /* do not fail hard, as we know many users have outdated gstreamer packages */
- result = 0;
- }
+ {
+ fprintf (stderr,
+ "gstreamer library did not work perfectly --- consider updating it.\n");
+ /* do not fail hard, as we know many users have outdated gstreamer packages */
+ result = 0;
+ }
return result;
}
+
/* end of test_gstreamer.c */
diff --git a/src/plugins/test_html.c b/src/plugins/test_html.c
@@ -36,89 +36,88 @@
int
main (int argc, char *argv[])
{
- struct SolutionData html_grothoff_sol[] =
+ struct SolutionData html_grothoff_sol[] = {
{
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Christian Grothoff",
- strlen ("Christian Grothoff") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_DESCRIPTION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Homepage of Christian Grothoff",
- strlen ("Homepage of Christian Grothoff") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_AUTHOR_NAME,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Christian Grothoff",
- strlen ("Christian Grothoff") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_KEYWORDS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Christian,Grothoff",
- strlen ("Christian,Grothoff") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Welcome to Christian Grothoff",
- strlen ("Welcome to Christian Grothoff") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_LANGUAGE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "en",
- strlen ("en") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PUBLISHER,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Christian Grothoff",
- strlen ("Christian Grothoff") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN_DATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "2000-08-20",
- strlen ("2000-08-20") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_RIGHTS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "(C) 2000 by Christian Grothoff",
- strlen ("(C) 2000 by Christian Grothoff") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Christian Grothoff",
+ strlen ("Christian Grothoff") + 1,
+ 0
+ },
{
- { "testdata/html_grothoff.html",
- html_grothoff_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_DESCRIPTION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Homepage of Christian Grothoff",
+ strlen ("Homepage of Christian Grothoff") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_AUTHOR_NAME,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Christian Grothoff",
+ strlen ("Christian Grothoff") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_KEYWORDS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Christian,Grothoff",
+ strlen ("Christian,Grothoff") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Welcome to Christian Grothoff",
+ strlen ("Welcome to Christian Grothoff") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_LANGUAGE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "en",
+ strlen ("en") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PUBLISHER,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Christian Grothoff",
+ strlen ("Christian Grothoff") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN_DATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2000-08-20",
+ strlen ("2000-08-20") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_RIGHTS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "(C) 2000 by Christian Grothoff",
+ strlen ("(C) 2000 by Christian Grothoff") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/html_grothoff.html",
+ html_grothoff_sol },
+ { NULL, NULL }
+ };
return ET_main ("html", ps);
}
+
/* end of test_html.c */
diff --git a/src/plugins/test_it.c b/src/plugins/test_it.c
@@ -36,41 +36,40 @@
int
main (int argc, char *argv[])
{
- struct SolutionData it_dawn_sol[] =
+ struct SolutionData it_dawn_sol[] = {
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "audio/x-mod",
- strlen ("audio/x-mod") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- "Dawn",
- strlen ("Dawn") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_FORMAT_VERSION,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- "1.2",
- strlen ("1.2") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "audio/x-mod",
+ strlen ("audio/x-mod") + 1,
+ 0
+ },
{
- { "testdata/it_dawn.it",
- it_dawn_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ "Dawn",
+ strlen ("Dawn") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_FORMAT_VERSION,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ "1.2",
+ strlen ("1.2") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/it_dawn.it",
+ it_dawn_sol },
+ { NULL, NULL }
+ };
return ET_main ("it", ps);
}
+
/* end of test_it.c */
diff --git a/src/plugins/test_jpeg.c b/src/plugins/test_jpeg.c
@@ -26,7 +26,6 @@
#include "test_lib.h"
-
/**
* Main function for the JPEG testcase.
*
@@ -37,41 +36,40 @@
int
main (int argc, char *argv[])
{
- struct SolutionData jpeg_image_sol[] =
+ struct SolutionData jpeg_image_sol[] = {
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "image/jpeg",
+ strlen ("image/jpeg") + 1,
+ 0
+ },
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "image/jpeg",
- strlen ("image/jpeg") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "3x3",
- strlen ("3x3") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- "(C) 2001 by Christian Grothoff, using gimp 1.2 1",
- strlen ("(C) 2001 by Christian Grothoff, using gimp 1.2 1"),
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "3x3",
+ strlen ("3x3") + 1,
+ 0
+ },
{
- { "testdata/jpeg_image.jpg",
- jpeg_image_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ "(C) 2001 by Christian Grothoff, using gimp 1.2 1",
+ strlen ("(C) 2001 by Christian Grothoff, using gimp 1.2 1"),
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/jpeg_image.jpg",
+ jpeg_image_sol },
+ { NULL, NULL }
+ };
return ET_main ("jpeg", ps);
}
+
/* end of test_jpeg.c */
diff --git a/src/plugins/test_lib.c b/src/plugins/test_lib.c
@@ -38,56 +38,56 @@
* @param data hello world or good bye
* @param data_len number of bytes in data
* @return 0 (always)
- */
+ */
static int
process_replies (void *cls,
- const char *plugin_name,
- enum EXTRACTOR_MetaType type,
- enum EXTRACTOR_MetaFormat format,
- const char *data_mime_type,
- const char *data,
- size_t data_len)
+ const char *plugin_name,
+ enum EXTRACTOR_MetaType type,
+ enum EXTRACTOR_MetaFormat format,
+ const char *data_mime_type,
+ const char *data,
+ size_t data_len)
{
struct SolutionData *sd = cls;
unsigned int i;
- for (i=0; -1 != sd[i].solved; i++)
+ for (i = 0; -1 != sd[i].solved; i++)
+ {
+ if ( (0 != sd[i].solved) ||
+ (sd[i].type != type) ||
+ (sd[i].format != format) )
+ continue;
+ if ( (EXTRACTOR_METAFORMAT_BINARY != format) &&
+ ( (sd[i].data_len != data_len) ||
+ (0 != memcmp (sd[i].data, data, data_len)) ) )
+ continue;
+ if ( (EXTRACTOR_METAFORMAT_BINARY == format) &&
+ ( (sd[i].data_len > data_len) ||
+ (0 != memcmp (sd[i].data, data, sd[i].data_len)) ) )
+ continue;
+
+ if (NULL != sd[i].data_mime_type)
{
- if ( (0 != sd[i].solved) ||
- (sd[i].type != type) ||
- (sd[i].format != format) )
- continue;
- if ( (EXTRACTOR_METAFORMAT_BINARY != format) &&
- ( (sd[i].data_len != data_len) ||
- (0 != memcmp (sd[i].data, data, data_len)) ) )
- continue;
- if ( (EXTRACTOR_METAFORMAT_BINARY == format) &&
- ( (sd[i].data_len > data_len) ||
- (0 != memcmp (sd[i].data, data, sd[i].data_len)) ) )
- continue;
-
- if (NULL != sd[i].data_mime_type)
- {
- if (NULL == data_mime_type)
- continue;
- if (0 != strcmp (sd[i].data_mime_type, data_mime_type))
- continue;
- }
- else
- {
- if (NULL != data_mime_type)
- continue;
- }
- sd[i].solved = 1;
- return 0;
+ if (NULL == data_mime_type)
+ continue;
+ if (0 != strcmp (sd[i].data_mime_type, data_mime_type))
+ continue;
}
- fprintf (stderr,
- "Got additional meta data of type %d and format %d with value `%.*s' from plugin `%s'\n",
- type,
- format,
- (int) data_len,
- data,
- plugin_name);
+ else
+ {
+ if (NULL != data_mime_type)
+ continue;
+ }
+ sd[i].solved = 1;
+ return 0;
+ }
+ fprintf (stderr,
+ "Got additional meta data of type %d and format %d with value `%.*s' from plugin `%s'\n",
+ type,
+ format,
+ (int) data_len,
+ data,
+ plugin_name);
return 0;
}
@@ -97,11 +97,11 @@ process_replies (void *cls,
*
* @param plugin_name name of the plugin to load
* @param ps array of problems the plugin should solve;
- * NULL in filename terminates the array.
+ * NULL in filename terminates the array.
* @param opt options to use for loading the plugin
* @return 0 on success, 1 on failure
*/
-static int
+static int
run (const char *plugin_name,
struct ProblemSet *ps,
enum EXTRACTOR_Options opt)
@@ -111,32 +111,33 @@ run (const char *plugin_name,
unsigned int j;
int ret;
- pl = EXTRACTOR_plugin_add_config (NULL,
- plugin_name,
- opt);
- for (i=0; NULL != ps[i].filename; i++)
+ pl = EXTRACTOR_plugin_add_config (NULL,
+ plugin_name,
+ opt);
+ for (i = 0; NULL != ps[i].filename; i++)
EXTRACTOR_extract (pl,
- ps[i].filename,
- NULL, 0,
- &process_replies,
- ps[i].solution);
+ ps[i].filename,
+ NULL, 0,
+ &process_replies,
+ ps[i].solution);
EXTRACTOR_plugin_remove_all (pl);
ret = 0;
- for (i=0; NULL != ps[i].filename; i++)
- for (j=0; -1 != ps[i].solution[j].solved; j++)
- if (0 == ps[i].solution[j].solved)
+ for (i = 0; NULL != ps[i].filename; i++)
+ for (j = 0; -1 != ps[i].solution[j].solved; j++)
+ if (0 == ps[i].solution[j].solved)
{
- ret = 1;
+ ret = 1;
fprintf (stderr,
- "Did not get expected meta data of type %d and format %d with value `%.*s' from plugin `%s'\n",
- ps[i].solution[j].type,
- ps[i].solution[j].format,
- (int) ps[i].solution[j].data_len,
- ps[i].solution[j].data,
- plugin_name);
+ "Did not get expected meta data of type %d and format %d with value `%.*s' from plugin `%s'\n",
+ ps[i].solution[j].type,
+ ps[i].solution[j].format,
+ (int) ps[i].solution[j].data_len,
+ ps[i].solution[j].data,
+ plugin_name);
}
else
- ps[i].solution[j].solved = 0; /* reset for next round */
+ ps[i].solution[j].solved = 0;
+ /* reset for next round */
return ret;
}
@@ -146,22 +147,22 @@ run (const char *plugin_name,
*
* @param plugin_name name of the plugin to load
* @param ps array of problems the plugin should solve;
- * NULL in filename terminates the array.
+ * NULL in filename terminates the array.
* @return 0 on success, 1 on failure
*/
-int
+int
ET_main (const char *plugin_name,
- struct ProblemSet *ps)
+ struct ProblemSet *ps)
{
int ret;
-
+
/* change environment to find plugins which may not yet be
not installed but should be in the current directory (or .libs)
on 'make check' */
if (0 != putenv ("LIBEXTRACTOR_PREFIX=." PATH_SEPARATOR_STR ".libs/"))
- fprintf (stderr,
- "Failed to update my environment, plugin loading may fail: %s\n",
- strerror (errno));
+ fprintf (stderr,
+ "Failed to update my environment, plugin loading may fail: %s\n",
+ strerror (errno));
ret = run (plugin_name, ps, EXTRACTOR_OPTION_DEFAULT_POLICY);
if (0 != ret)
return ret;
diff --git a/src/plugins/test_lib.h b/src/plugins/test_lib.h
@@ -67,7 +67,7 @@ struct SolutionData
/**
- * Set of problems
+ * Set of problems
*/
struct ProblemSet
{
@@ -90,11 +90,11 @@ struct ProblemSet
*
* @param plugin_name name of the plugin to load
* @param ps array of problems the plugin should solve;
- * NULL in filename terminates the array.
+ * NULL in filename terminates the array.
* @return 0 on success, 1 on failure
*/
-int
+int
ET_main (const char *plugin_name,
- struct ProblemSet *ps);
+ struct ProblemSet *ps);
#endif
diff --git a/src/plugins/test_man.c b/src/plugins/test_man.c
@@ -26,7 +26,6 @@
#include "test_lib.h"
-
/**
* Main function for the MAN testcase.
*
@@ -37,49 +36,48 @@
int
main (int argc, char *argv[])
{
- struct SolutionData man_extract_sol[] =
+ struct SolutionData man_extract_sol[] = {
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "EXTRACT",
+ strlen ("EXTRACT") + 1,
+ 0
+ },
{
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "EXTRACT",
- strlen ("EXTRACT") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_SECTION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- _("Commands"),
- strlen (_("Commands")) + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_MODIFICATION_DATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Aug 7, 2012",
- strlen ("Aug 7, 2012") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_SOURCE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- _("libextractor 0.7.0"),
- strlen (_("libextractor 0.7.0")) + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_SECTION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ _ ("Commands"),
+ strlen (_ ("Commands")) + 1,
+ 0
+ },
{
- { "testdata/man_extract.1",
- man_extract_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_MODIFICATION_DATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Aug 7, 2012",
+ strlen ("Aug 7, 2012") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_SOURCE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ _ ("libextractor 0.7.0"),
+ strlen (_ ("libextractor 0.7.0")) + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/man_extract.1",
+ man_extract_sol },
+ { NULL, NULL }
+ };
return ET_main ("man", ps);
}
+
/* end of test_man.c */
diff --git a/src/plugins/test_midi.c b/src/plugins/test_midi.c
@@ -36,57 +36,56 @@
int
main (int argc, char *argv[])
{
- struct SolutionData midi_dth_sol[] =
+ struct SolutionData midi_dth_sol[] = {
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "audio/midi",
- strlen ("audio/midi") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_COPYRIGHT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "(c) 2012 d-o-o",
- strlen ("(c) 2012 d-o-o"),
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Tage wie diese T2",
- strlen ("Tage wie diese T2"),
- 0
- },
- {
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "XFhd:::Rock:8 Beat:1:m1:-:-:-:-:DD",
- strlen ("XFhd:::Rock:8 Beat:1:m1:-:-:-:-:DD"),
- 0
- },
- {
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "XFln:L1:Tage wie diese:von Holst:von Holst:-:Toten Hosen:DD",
- strlen ("XFln:L1:Tage wie diese:von Holst:von Holst:-:Toten Hosen:DD"),
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "audio/midi",
+ strlen ("audio/midi") + 1,
+ 0
+ },
{
- { "testdata/midi_dth.mid",
- midi_dth_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_COPYRIGHT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "(c) 2012 d-o-o",
+ strlen ("(c) 2012 d-o-o"),
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Tage wie diese T2",
+ strlen ("Tage wie diese T2"),
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "XFhd:::Rock:8 Beat:1:m1:-:-:-:-:DD",
+ strlen ("XFhd:::Rock:8 Beat:1:m1:-:-:-:-:DD"),
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "XFln:L1:Tage wie diese:von Holst:von Holst:-:Toten Hosen:DD",
+ strlen ("XFln:L1:Tage wie diese:von Holst:von Holst:-:Toten Hosen:DD"),
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/midi_dth.mid",
+ midi_dth_sol },
+ { NULL, NULL }
+ };
return ET_main ("midi", ps);
}
+
/* end of test_midi.c */
diff --git a/src/plugins/test_mime.c b/src/plugins/test_mime.c
@@ -40,70 +40,64 @@ main (int argc, char *argv[])
int result = 0;
int test_result;
int test_result_around_19, test_result_around_22;
- struct SolutionData courseclear_file_around_19_sol[] =
+ struct SolutionData courseclear_file_around_19_sol[] = {
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- /* not sure which is the exact version, but old ones do
- not even define MAGIC_VERSION, so this is approximately
- right. Users where this tests fail should report
- their version number from "magic.h" so we can adjust
- if necessary. */
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ /* not sure which is the exact version, but old ones do
+ not even define MAGIC_VERSION, so this is approximately
+ right. Users where this tests fail should report
+ their version number from "magic.h" so we can adjust
+ if necessary. */
#ifdef MAGIC_VERSION
- "audio/ogg",
- strlen ("audio/ogg") + 1,
+ "audio/ogg",
+ strlen ("audio/ogg") + 1,
#else
- "application/ogg",
- strlen ("application/ogg") + 1,
+ "application/ogg",
+ strlen ("application/ogg") + 1,
#endif
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct SolutionData courseclear_file_around_22_sol[] =
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct SolutionData courseclear_file_around_22_sol[] = {
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "audio/ogg",
- strlen ("audio/ogg") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct SolutionData gif_image_sol[] =
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "audio/ogg",
+ strlen ("audio/ogg") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct SolutionData gif_image_sol[] = {
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "image/gif",
- strlen ("image/gif") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps_gif[] =
- {
- { "testdata/gif_image.gif",
- gif_image_sol },
- { NULL, NULL }
- };
- struct ProblemSet ps_ogg_around_19[] =
- {
- { "testdata/ogg_courseclear.ogg",
- courseclear_file_around_19_sol },
- { NULL, NULL }
- };
- struct ProblemSet ps_ogg_around_22[] =
- {
- { "testdata/ogg_courseclear.ogg",
- courseclear_file_around_22_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "image/gif",
+ strlen ("image/gif") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps_gif[] = {
+ { "testdata/gif_image.gif",
+ gif_image_sol },
+ { NULL, NULL }
+ };
+ struct ProblemSet ps_ogg_around_19[] = {
+ { "testdata/ogg_courseclear.ogg",
+ courseclear_file_around_19_sol },
+ { NULL, NULL }
+ };
+ struct ProblemSet ps_ogg_around_22[] = {
+ { "testdata/ogg_courseclear.ogg",
+ courseclear_file_around_22_sol },
+ { NULL, NULL }
+ };
printf ("Running gif test on libmagic:\n");
test_result = (0 == ET_main ("mime", ps_gif) ? 0 : 1);
printf ("gif libmagic test result: %s\n", test_result == 0 ? "OK" : "FAILED");
@@ -111,15 +105,18 @@ main (int argc, char *argv[])
printf ("Running ogg test on libmagic, assuming version ~5.19:\n");
test_result_around_19 = (0 == ET_main ("mime", ps_ogg_around_19) ? 0 : 1);
- printf ("ogg libmagic test result: %s\n", test_result_around_19 == 0 ? "OK" : "FAILED");
+ printf ("ogg libmagic test result: %s\n", test_result_around_19 == 0 ? "OK" :
+ "FAILED");
printf ("Running ogg test on libmagic, assuming version ~5.22:\n");
test_result_around_22 = (0 == ET_main ("mime", ps_ogg_around_22) ? 0 : 1);
- printf ("ogg libmagic test result: %s\n", test_result_around_22 == 0 ? "OK" : "FAILED");
+ printf ("ogg libmagic test result: %s\n", test_result_around_22 == 0 ? "OK" :
+ "FAILED");
if ((test_result_around_19 != 0) && (test_result_around_22 != 0))
result++;
return result;
}
+
/* end of test_mime.c */
diff --git a/src/plugins/test_mpeg.c b/src/plugins/test_mpeg.c
@@ -26,7 +26,6 @@
#include "test_lib.h"
-
/**
* Main function for the MPEG testcase.
*
@@ -37,79 +36,77 @@
int
main (int argc, char *argv[])
{
- struct SolutionData melt_sol[] =
+ struct SolutionData melt_sol[] = {
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "video/mpeg",
+ strlen ("video/mpeg") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "320x208",
+ strlen ("320x208") + 1,
+ 0
+ },
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "video/mpeg",
- strlen ("video/mpeg") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "320x208",
- strlen ("320x208") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_FORMAT_VERSION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "MPEG1",
- strlen ("MPEG1") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_DURATION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "00:00:03 (22 frames)",
- strlen ("00:00:03 (22 frames)") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct SolutionData alien_sol[] =
+ EXTRACTOR_METATYPE_FORMAT_VERSION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "MPEG1",
+ strlen ("MPEG1") + 1,
+ 0
+ },
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "video/mpeg",
- strlen ("video/mpeg") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "320x240",
- strlen ("320x240") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_FORMAT_VERSION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "MPEG1",
- strlen ("MPEG1") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_DURATION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "00:00:03 (22 frames)",
+ strlen ("00:00:03 (22 frames)") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct SolutionData alien_sol[] = {
{
- { "testdata/mpeg_melt.mpg",
- melt_sol },
- { "testdata/mpeg_alien.mpg",
- alien_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "video/mpeg",
+ strlen ("video/mpeg") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "320x240",
+ strlen ("320x240") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_FORMAT_VERSION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "MPEG1",
+ strlen ("MPEG1") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/mpeg_melt.mpg",
+ melt_sol },
+ { "testdata/mpeg_alien.mpg",
+ alien_sol },
+ { NULL, NULL }
+ };
return ET_main ("mpeg", ps);
}
+
/* end of test_mpeg.c */
diff --git a/src/plugins/test_nsf.c b/src/plugins/test_nsf.c
@@ -26,7 +26,6 @@
#include "test_lib.h"
-
/**
* Main function for the NSF testcase.
*
@@ -37,81 +36,80 @@
int
main (int argc, char *argv[])
{
- struct SolutionData nsf_arkanoid_sol[] =
+ struct SolutionData nsf_arkanoid_sol[] = {
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "audio/x-nsf",
+ strlen ("audio/x-nsf") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_FORMAT_VERSION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "1",
+ strlen ("1") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_SONG_COUNT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "26",
+ strlen ("26") + 1,
+ 0
+ },
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "audio/x-nsf",
- strlen ("audio/x-nsf") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_FORMAT_VERSION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "1",
- strlen ("1") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_SONG_COUNT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "26",
- strlen ("26") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_STARTING_SONG,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "1",
- strlen ("1") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ALBUM,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Arkanoid II - Revenge of Doh",
- strlen ("Arkanoid II - Revenge of Doh") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ARTIST,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "<?>",
- strlen ("<?>") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_COPYRIGHT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "1988 Taito",
- strlen ("1988 Taito") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "NTSC",
- strlen ("NTSC") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_STARTING_SONG,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "1",
+ strlen ("1") + 1,
+ 0
+ },
{
- { "testdata/nsf_arkanoid.nsf",
- nsf_arkanoid_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_ALBUM,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Arkanoid II - Revenge of Doh",
+ strlen ("Arkanoid II - Revenge of Doh") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ARTIST,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "<?>",
+ strlen ("<?>") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_COPYRIGHT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "1988 Taito",
+ strlen ("1988 Taito") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "NTSC",
+ strlen ("NTSC") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/nsf_arkanoid.nsf",
+ nsf_arkanoid_sol },
+ { NULL, NULL }
+ };
return ET_main ("nsf", ps);
}
+
/* end of test_nsf.c */
diff --git a/src/plugins/test_nsfe.c b/src/plugins/test_nsfe.c
@@ -26,7 +26,6 @@
#include "test_lib.h"
-
/**
* Main function for the NSFE testcase.
*
@@ -37,97 +36,96 @@
int
main (int argc, char *argv[])
{
- struct SolutionData nsfe_classics_sol[] =
+ struct SolutionData nsfe_classics_sol[] = {
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "audio/x-nsfe",
+ strlen ("audio/x-nsfe") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_SONG_COUNT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2",
+ strlen ("2") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_STARTING_SONG,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "0",
+ strlen ("0") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "PAL",
+ strlen ("PAL") + 1,
+ 0
+ },
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "audio/x-nsfe",
- strlen ("audio/x-nsfe") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_SONG_COUNT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "2",
- strlen ("2") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_STARTING_SONG,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "0",
- strlen ("0") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "PAL",
- strlen ("PAL") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ALBUM,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Adventures of Dr. Franken,The",
- strlen ("Adventures of Dr. Franken,The") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ARTIST,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Mark Cooksey",
- strlen ("Mark Cooksey") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_COPYRIGHT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "1993 Motivetime LTD.",
- strlen ("1993 Motivetime LTD.") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_RIPPER,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Gil_Galad",
- strlen ("Gil_Galad") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Bach: Prelude & Fugue In C Minor",
- strlen ("Bach: Prelude & Fugue In C Minor") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Beethoven: Moonlight Sonata",
- strlen ("Beethoven: Moonlight Sonata") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_ALBUM,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Adventures of Dr. Franken,The",
+ strlen ("Adventures of Dr. Franken,The") + 1,
+ 0
+ },
{
- { "testdata/nsfe_classics.nsfe",
- nsfe_classics_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_ARTIST,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Mark Cooksey",
+ strlen ("Mark Cooksey") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_COPYRIGHT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "1993 Motivetime LTD.",
+ strlen ("1993 Motivetime LTD.") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_RIPPER,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Gil_Galad",
+ strlen ("Gil_Galad") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Bach: Prelude & Fugue In C Minor",
+ strlen ("Bach: Prelude & Fugue In C Minor") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Beethoven: Moonlight Sonata",
+ strlen ("Beethoven: Moonlight Sonata") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/nsfe_classics.nsfe",
+ nsfe_classics_sol },
+ { NULL, NULL }
+ };
return ET_main ("nsfe", ps);
}
+
/* end of test_nsfe.c */
diff --git a/src/plugins/test_odf.c b/src/plugins/test_odf.c
@@ -36,65 +36,65 @@
int
main (int argc, char *argv[])
{
- struct SolutionData odf_cg_sol[] =
+ struct SolutionData odf_cg_sol[] = {
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "application/vnd.oasis.opendocument.text",
- strlen ("application/vnd.oasis.opendocument.text") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "OpenOffice.org/3.2$Unix OpenOffice.org_project/320m12$Build-9483",
- strlen ("OpenOffice.org/3.2$Unix OpenOffice.org_project/320m12$Build-9483") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PAGE_COUNT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "1",
- strlen ("1") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CREATION_DATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "2005-11-22T11:44:00",
- strlen ("2005-11-22T11:44:00") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN_DATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "2010-06-09T13:09:34",
- strlen ("2010-06-09T13:09:34") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Anhang 1: Profile der beteiligten Wissenschaftler",
- strlen ("Anhang 1: Profile der beteiligten Wissenschaftler") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "application/vnd.oasis.opendocument.text",
+ strlen ("application/vnd.oasis.opendocument.text") + 1,
+ 0
+ },
{
- { "testdata/odf_cg.odt",
- odf_cg_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "OpenOffice.org/3.2$Unix OpenOffice.org_project/320m12$Build-9483",
+ strlen (
+ "OpenOffice.org/3.2$Unix OpenOffice.org_project/320m12$Build-9483") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PAGE_COUNT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "1",
+ strlen ("1") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CREATION_DATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2005-11-22T11:44:00",
+ strlen ("2005-11-22T11:44:00") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN_DATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2010-06-09T13:09:34",
+ strlen ("2010-06-09T13:09:34") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Anhang 1: Profile der beteiligten Wissenschaftler",
+ strlen ("Anhang 1: Profile der beteiligten Wissenschaftler") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/odf_cg.odt",
+ odf_cg_sol },
+ { NULL, NULL }
+ };
return ET_main ("odf", ps);
}
+
/* end of test_odf.c */
diff --git a/src/plugins/test_ogg.c b/src/plugins/test_ogg.c
@@ -26,7 +26,6 @@
#include "test_lib.h"
-
/**
* Main function for the OGG testcase.
*
@@ -37,57 +36,56 @@
int
main (int argc, char *argv[])
{
- struct SolutionData courseclear_sol[] =
+ struct SolutionData courseclear_sol[] = {
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "application/ogg",
+ strlen ("application/ogg") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_VENDOR,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Xiphophorus libVorbis I 20010813",
+ strlen ("Xiphophorus libVorbis I 20010813") + 1,
+ 0
+ },
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "application/ogg",
- strlen ("application/ogg") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_VENDOR,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Xiphophorus libVorbis I 20010813",
- strlen ("Xiphophorus libVorbis I 20010813") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "xoc_SMW_06_courseclear",
- strlen ("xoc_SMW_06_courseclear") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ARTIST,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "XOC",
- strlen ("XOC") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TRACK_NUMBER,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "6",
- strlen ("6") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "xoc_SMW_06_courseclear",
+ strlen ("xoc_SMW_06_courseclear") + 1,
+ 0
+ },
{
- { "testdata/ogg_courseclear.ogg",
- courseclear_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_ARTIST,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "XOC",
+ strlen ("XOC") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TRACK_NUMBER,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "6",
+ strlen ("6") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/ogg_courseclear.ogg",
+ courseclear_sol },
+ { NULL, NULL }
+ };
return ET_main ("ogg", ps);
}
+
/* end of test_ogg.c */
diff --git a/src/plugins/test_ole2.c b/src/plugins/test_ole2.c
@@ -36,457 +36,476 @@
int
main (int argc, char *argv[])
{
- struct SolutionData ole2_msword_sol[] =
- {
- {
- EXTRACTOR_METATYPE_CREATOR,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Nils Durner",
- strlen ("Nils Durner") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN_DATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "2005-03-21T06:11:12Z",
- strlen ("2005-03-21T06:11:12Z") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_DESCRIPTION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "This is a small document to test meta data extraction by GNU libextractor.",
- strlen ("This is a small document to test meta data extraction by GNU libextractor.") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_KEYWORDS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ole ole2 eole2extractor",
- strlen ("ole ole2 eole2extractor") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_SUBJECT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "GNU libextractor",
- strlen ("GNU libextractor") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Testcase for the ole2 extractor",
- strlen ("Testcase for the ole2 extractor") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_LAST_SAVED_BY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Nils Durner",
- strlen ("Nils Durner") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CREATION_DATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "2005-03-21T06:10:19Z",
- strlen ("2005-03-21T06:10:19Z") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_EDITING_CYCLES,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "2",
- strlen ("2") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
+ struct SolutionData ole2_msword_sol[] = {
+ {
+ EXTRACTOR_METATYPE_CREATOR,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Nils Durner",
+ strlen ("Nils Durner") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN_DATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2005-03-21T06:11:12Z",
+ strlen ("2005-03-21T06:11:12Z") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_DESCRIPTION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "This is a small document to test meta data extraction by GNU libextractor.",
+ strlen (
+ "This is a small document to test meta data extraction by GNU libextractor.")
+ + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_KEYWORDS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ole ole2 eole2extractor",
+ strlen ("ole ole2 eole2extractor") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_SUBJECT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "GNU libextractor",
+ strlen ("GNU libextractor") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Testcase for the ole2 extractor",
+ strlen ("Testcase for the ole2 extractor") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_LAST_SAVED_BY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Nils Durner",
+ strlen ("Nils Durner") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CREATION_DATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2005-03-21T06:10:19Z",
+ strlen ("2005-03-21T06:10:19Z") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_EDITING_CYCLES,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2",
+ strlen ("2") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
- struct SolutionData ole2_starwriter_sol[] =
- {
- {
- EXTRACTOR_METATYPE_CREATOR,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Christian Grothoff",
- strlen ("Christian Grothoff") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN_DATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "2004-09-24T02:54:31Z",
- strlen ("2004-09-24T02:54:31Z") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_DESCRIPTION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "The comments",
- strlen ("The comments") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_KEYWORDS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "The Keywords",
- strlen ("The Keywords") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_SUBJECT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "The Subject",
- strlen ("The Subject") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "The Title",
- strlen ("The Title") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_LAST_SAVED_BY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Christian Grothoff",
- strlen ("Christian Grothoff") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CREATION_DATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "2004-09-24T02:53:15Z",
- strlen ("2004-09-24T02:53:15Z") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_EDITING_CYCLES,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "4",
- strlen ("4") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "The Title",
- strlen ("The Title") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_SUBJECT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "The Subject",
- strlen ("The Subject") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "The comments",
- strlen ("The comments") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_KEYWORDS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "The Keywords",
- strlen ("The Keywords") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
+ struct SolutionData ole2_starwriter_sol[] = {
+ {
+ EXTRACTOR_METATYPE_CREATOR,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Christian Grothoff",
+ strlen ("Christian Grothoff") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN_DATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2004-09-24T02:54:31Z",
+ strlen ("2004-09-24T02:54:31Z") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_DESCRIPTION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "The comments",
+ strlen ("The comments") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_KEYWORDS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "The Keywords",
+ strlen ("The Keywords") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_SUBJECT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "The Subject",
+ strlen ("The Subject") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "The Title",
+ strlen ("The Title") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_LAST_SAVED_BY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Christian Grothoff",
+ strlen ("Christian Grothoff") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CREATION_DATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2004-09-24T02:53:15Z",
+ strlen ("2004-09-24T02:53:15Z") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_EDITING_CYCLES,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "4",
+ strlen ("4") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "The Title",
+ strlen ("The Title") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_SUBJECT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "The Subject",
+ strlen ("The Subject") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "The comments",
+ strlen ("The comments") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_KEYWORDS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "The Keywords",
+ strlen ("The Keywords") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
#if HAVE_ICONV
- struct SolutionData ole2_blair_sol[] =
- {
- {
- EXTRACTOR_METATYPE_LANGUAGE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "U.S. English",
- strlen ("U.S. English") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CREATOR,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "default",
- strlen ("default") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN_DATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "2003-02-03T11:18:00Z",
- strlen ("2003-02-03T11:18:00Z") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Iraq- ITS INFRASTRUCTURE OF CONCEALMENT, DECEPTION AND INTIMIDATION",
- strlen ("Iraq- ITS INFRASTRUCTURE OF CONCEALMENT, DECEPTION AND INTIMIDATION") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CHARACTER_COUNT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "22090",
- strlen ("22090") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_LAST_SAVED_BY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "MKhan",
- strlen ("MKhan") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PAGE_COUNT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "1",
- strlen ("1") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_WORD_COUNT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "3875",
- strlen ("3875") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CREATION_DATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "2003-02-03T09:31:00Z",
- strlen ("2003-02-03T09:31:00Z") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_EDITING_CYCLES,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "4",
- strlen ("4") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "application/vnd.ms-files",
- strlen ("application/vnd.ms-files") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Microsoft Word 8.0",
- strlen ("Microsoft Word 8.0") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TEMPLATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Normal.dot",
- strlen ("Normal.dot") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_LINE_COUNT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "184",
- strlen ("184") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PARAGRAPH_COUNT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "44",
- strlen ("44") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_REVISION_HISTORY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Revision #0: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'",
- strlen ("Revision #0: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_REVISION_HISTORY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Revision #1: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'",
- strlen ("Revision #1: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_REVISION_HISTORY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Revision #2: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'",
- strlen ("Revision #2: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_REVISION_HISTORY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Revision #3: Author `JPratt' worked on `C:\\TEMP\\Iraq - security.doc'",
- strlen ("Revision #3: Author `JPratt' worked on `C:\\TEMP\\Iraq - security.doc'") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_REVISION_HISTORY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Revision #4: Author `JPratt' worked on `A:\\Iraq - security.doc'",
- strlen ("Revision #4: Author `JPratt' worked on `A:\\Iraq - security.doc'") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_REVISION_HISTORY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Revision #5: Author `ablackshaw' worked on `C:\\ABlackshaw\\Iraq - security.doc'",
- strlen ("Revision #5: Author `ablackshaw' worked on `C:\\ABlackshaw\\Iraq - security.doc'") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_REVISION_HISTORY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Revision #6: Author `ablackshaw' worked on `C:\\ABlackshaw\\A;Iraq - security.doc'",
- strlen ("Revision #6: Author `ablackshaw' worked on `C:\\ABlackshaw\\A;Iraq - security.doc'") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_REVISION_HISTORY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Revision #7: Author `ablackshaw' worked on `A:\\Iraq - security.doc'",
- strlen ("Revision #7: Author `ablackshaw' worked on `A:\\Iraq - security.doc'") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_REVISION_HISTORY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Revision #8: Author `MKhan' worked on `C:\\TEMP\\Iraq - security.doc'",
- strlen ("Revision #8: Author `MKhan' worked on `C:\\TEMP\\Iraq - security.doc'") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_REVISION_HISTORY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Revision #9: Author `MKhan' worked on `C:\\WINNT\\Profiles\\mkhan\\Desktop\\Iraq.doc'",
- strlen ("Revision #9: Author `MKhan' worked on `C:\\WINNT\\Profiles\\mkhan\\Desktop\\Iraq.doc'") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
+ struct SolutionData ole2_blair_sol[] = {
+ {
+ EXTRACTOR_METATYPE_LANGUAGE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "U.S. English",
+ strlen ("U.S. English") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CREATOR,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "default",
+ strlen ("default") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN_DATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2003-02-03T11:18:00Z",
+ strlen ("2003-02-03T11:18:00Z") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Iraq- ITS INFRASTRUCTURE OF CONCEALMENT, DECEPTION AND INTIMIDATION",
+ strlen (
+ "Iraq- ITS INFRASTRUCTURE OF CONCEALMENT, DECEPTION AND INTIMIDATION")
+ + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CHARACTER_COUNT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "22090",
+ strlen ("22090") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_LAST_SAVED_BY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "MKhan",
+ strlen ("MKhan") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PAGE_COUNT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "1",
+ strlen ("1") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_WORD_COUNT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "3875",
+ strlen ("3875") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CREATION_DATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2003-02-03T09:31:00Z",
+ strlen ("2003-02-03T09:31:00Z") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_EDITING_CYCLES,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "4",
+ strlen ("4") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "application/vnd.ms-files",
+ strlen ("application/vnd.ms-files") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Microsoft Word 8.0",
+ strlen ("Microsoft Word 8.0") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TEMPLATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Normal.dot",
+ strlen ("Normal.dot") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_LINE_COUNT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "184",
+ strlen ("184") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PARAGRAPH_COUNT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "44",
+ strlen ("44") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_REVISION_HISTORY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Revision #0: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'",
+ strlen (
+ "Revision #0: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'")
+ + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_REVISION_HISTORY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Revision #1: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'",
+ strlen (
+ "Revision #1: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'")
+ + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_REVISION_HISTORY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Revision #2: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'",
+ strlen (
+ "Revision #2: Author `cic22' worked on `C:\\DOCUME~1\\phamill\\LOCALS~1\\Temp\\AutoRecovery save of Iraq - security.asd'")
+ + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_REVISION_HISTORY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Revision #3: Author `JPratt' worked on `C:\\TEMP\\Iraq - security.doc'",
+ strlen (
+ "Revision #3: Author `JPratt' worked on `C:\\TEMP\\Iraq - security.doc'")
+ + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_REVISION_HISTORY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Revision #4: Author `JPratt' worked on `A:\\Iraq - security.doc'",
+ strlen (
+ "Revision #4: Author `JPratt' worked on `A:\\Iraq - security.doc'") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_REVISION_HISTORY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Revision #5: Author `ablackshaw' worked on `C:\\ABlackshaw\\Iraq - security.doc'",
+ strlen (
+ "Revision #5: Author `ablackshaw' worked on `C:\\ABlackshaw\\Iraq - security.doc'")
+ + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_REVISION_HISTORY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Revision #6: Author `ablackshaw' worked on `C:\\ABlackshaw\\A;Iraq - security.doc'",
+ strlen (
+ "Revision #6: Author `ablackshaw' worked on `C:\\ABlackshaw\\A;Iraq - security.doc'")
+ + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_REVISION_HISTORY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Revision #7: Author `ablackshaw' worked on `A:\\Iraq - security.doc'",
+ strlen (
+ "Revision #7: Author `ablackshaw' worked on `A:\\Iraq - security.doc'")
+ + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_REVISION_HISTORY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Revision #8: Author `MKhan' worked on `C:\\TEMP\\Iraq - security.doc'",
+ strlen (
+ "Revision #8: Author `MKhan' worked on `C:\\TEMP\\Iraq - security.doc'")
+ + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_REVISION_HISTORY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Revision #9: Author `MKhan' worked on `C:\\WINNT\\Profiles\\mkhan\\Desktop\\Iraq.doc'",
+ strlen (
+ "Revision #9: Author `MKhan' worked on `C:\\WINNT\\Profiles\\mkhan\\Desktop\\Iraq.doc'")
+ + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
#endif
- struct SolutionData ole2_excel_sol[] =
- {
- {
- EXTRACTOR_METATYPE_CREATOR,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "JV",
- strlen ("JV") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_LAST_SAVED_BY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "JV",
- strlen ("JV") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CREATION_DATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "2002-03-20T21:26:28Z",
- strlen ("2002-03-20T21:26:28Z") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "application/vnd.ms-files",
- strlen ("application/vnd.ms-files") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Microsoft Excel",
- strlen ("Microsoft Excel") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
-
- struct ProblemSet ps[] =
+ struct SolutionData ole2_excel_sol[] = {
{
- { "testdata/ole2_msword.doc",
- ole2_msword_sol },
- { "testdata/ole2_starwriter40.sdw",
- ole2_starwriter_sol },
+ EXTRACTOR_METATYPE_CREATOR,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "JV",
+ strlen ("JV") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_LAST_SAVED_BY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "JV",
+ strlen ("JV") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CREATION_DATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2002-03-20T21:26:28Z",
+ strlen ("2002-03-20T21:26:28Z") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "application/vnd.ms-files",
+ strlen ("application/vnd.ms-files") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Microsoft Excel",
+ strlen ("Microsoft Excel") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+
+ struct ProblemSet ps[] = {
+ { "testdata/ole2_msword.doc",
+ ole2_msword_sol },
+ { "testdata/ole2_starwriter40.sdw",
+ ole2_starwriter_sol },
#if HAVE_ICONV
- { "testdata/ole2_blair.doc",
- ole2_blair_sol },
+ { "testdata/ole2_blair.doc",
+ ole2_blair_sol },
#endif
- { "testdata/ole2_excel.xls",
- ole2_excel_sol },
- { NULL, NULL }
- };
+ { "testdata/ole2_excel.xls",
+ ole2_excel_sol },
+ { NULL, NULL }
+ };
return ET_main ("ole2", ps);
}
+
/* end of test_ole2.c */
diff --git a/src/plugins/test_png.c b/src/plugins/test_png.c
@@ -36,49 +36,48 @@
int
main (int argc, char *argv[])
{
- struct SolutionData png_image_sol[] =
+ struct SolutionData png_image_sol[] = {
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "image/png",
- strlen ("image/png") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "4x4",
- strlen ("4x4") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Testing keyword extraction\n",
- strlen ("Testing keyword extraction\n") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "dc6c58c971715e8043baef058b675eec",
- strlen ("dc6c58c971715e8043baef058b675eec") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "image/png",
+ strlen ("image/png") + 1,
+ 0
+ },
{
- { "testdata/png_image.png",
- png_image_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "4x4",
+ strlen ("4x4") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Testing keyword extraction\n",
+ strlen ("Testing keyword extraction\n") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "dc6c58c971715e8043baef058b675eec",
+ strlen ("dc6c58c971715e8043baef058b675eec") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/png_image.png",
+ png_image_sol },
+ { NULL, NULL }
+ };
return ET_main ("png", ps);
}
+
/* end of test_png.c */
diff --git a/src/plugins/test_previewopus.c b/src/plugins/test_previewopus.c
@@ -26,7 +26,6 @@
#include "test_lib.h"
-
/**
* Main function for the previewopus testcase.
*
@@ -37,18 +36,17 @@
int
main (int argc, char *argv[])
{
- struct SolutionData previewopus_audio_sol[] =
- {
- //TODO. Can't test as it depends on the encoder.
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
- {
- { "testdata/mpeg_alien.mpg",
- previewopus_audio_sol },
- { NULL, NULL }
- };
+ struct SolutionData previewopus_audio_sol[] = {
+ // TODO. Can't test as it depends on the encoder.
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/mpeg_alien.mpg",
+ previewopus_audio_sol },
+ { NULL, NULL }
+ };
return ET_main ("previewopus", ps);
}
+
/* end of test_thumbnailffmpeg.c */
diff --git a/src/plugins/test_ps.c b/src/plugins/test_ps.c
@@ -26,7 +26,6 @@
#include "test_lib.h"
-
/**
* Main function for the PS testcase.
*
@@ -37,103 +36,105 @@
int
main (int argc, char *argv[])
{
- struct SolutionData ps_bloomfilter_sol[] =
+ struct SolutionData ps_bloomfilter_sol[] = {
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "application/postscript",
+ strlen ("application/postscript") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "A Quick Introduction to Bloom Filters",
+ strlen ("A Quick Introduction to Bloom Filters") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "dvips(k) 5.92b Copyright 2002 Radical Eye Software",
+ strlen ("dvips(k) 5.92b Copyright 2002 Radical Eye Software") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PAGE_COUNT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "1",
+ strlen ("1") + 1,
+ 0
+ },
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "application/postscript",
- strlen ("application/postscript") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "A Quick Introduction to Bloom Filters",
- strlen ("A Quick Introduction to Bloom Filters") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "dvips(k) 5.92b Copyright 2002 Radical Eye Software",
- strlen ("dvips(k) 5.92b Copyright 2002 Radical Eye Software") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PAGE_COUNT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "1",
- strlen ("1") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PAGE_ORDER,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Ascend",
- strlen ("Ascend") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct SolutionData ps_wallace_sol[] =
+ EXTRACTOR_METATYPE_PAGE_ORDER,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Ascend",
+ strlen ("Ascend") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct SolutionData ps_wallace_sol[] = {
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "application/postscript",
- strlen ("application/postscript") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_SUBJECT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "PS preprint of JPEG article submitted to IEEE Trans on Consum. Elect",
- strlen ("PS preprint of JPEG article submitted to IEEE Trans on Consum. Elect") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "DECwrite V1.1 Copyright (c) 1990 DIGITAL EQUIPMENT CORPORATION. All Rights Reserved.",
- strlen ("DECwrite V1.1 Copyright (c) 1990 DIGITAL EQUIPMENT CORPORATION. All Rights Reserved.") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_AUTHOR_NAME,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Greg Wallace",
- strlen ("Greg Wallace") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_UNKNOWN_DATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Tue, 17 Dec 91 14:49:50 PST",
- strlen ("Tue, 17 Dec 91 14:49:50 PST") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "application/postscript",
+ strlen ("application/postscript") + 1,
+ 0
+ },
{
- { "testdata/ps_bloomfilter.ps",
- ps_bloomfilter_sol },
- { "testdata/ps_wallace.ps",
- ps_wallace_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_SUBJECT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "PS preprint of JPEG article submitted to IEEE Trans on Consum. Elect",
+ strlen (
+ "PS preprint of JPEG article submitted to IEEE Trans on Consum. Elect")
+ + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "DECwrite V1.1 Copyright (c) 1990 DIGITAL EQUIPMENT CORPORATION. All Rights Reserved.",
+ strlen (
+ "DECwrite V1.1 Copyright (c) 1990 DIGITAL EQUIPMENT CORPORATION. All Rights Reserved.")
+ + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_AUTHOR_NAME,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Greg Wallace",
+ strlen ("Greg Wallace") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_UNKNOWN_DATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Tue, 17 Dec 91 14:49:50 PST",
+ strlen ("Tue, 17 Dec 91 14:49:50 PST") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/ps_bloomfilter.ps",
+ ps_bloomfilter_sol },
+ { "testdata/ps_wallace.ps",
+ ps_wallace_sol },
+ { NULL, NULL }
+ };
return ET_main ("ps", ps);
}
+
/* end of test_ps.c */
diff --git a/src/plugins/test_riff.c b/src/plugins/test_riff.c
@@ -26,7 +26,6 @@
#include "test_lib.h"
-
/**
* Main function for the RIFF testcase.
*
@@ -37,41 +36,40 @@
int
main (int argc, char *argv[])
{
- struct SolutionData riff_flame_sol[] =
+ struct SolutionData riff_flame_sol[] = {
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "video/x-msvideo",
+ strlen ("video/x-msvideo") + 1,
+ 0
+ },
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "video/x-msvideo",
- strlen ("video/x-msvideo") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_FORMAT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "codec: cvid, 35 fps, 3143 ms",
- strlen ("codec: cvid, 35 fps, 3143 ms") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "256x240",
- strlen ("256x240") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_FORMAT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "codec: cvid, 35 fps, 3143 ms",
+ strlen ("codec: cvid, 35 fps, 3143 ms") + 1,
+ 0
+ },
{
- { "testdata/riff_flame.avi",
- riff_flame_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "256x240",
+ strlen ("256x240") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/riff_flame.avi",
+ riff_flame_sol },
+ { NULL, NULL }
+ };
return ET_main ("riff", ps);
}
+
/* end of test_riff.c */
diff --git a/src/plugins/test_rpm.c b/src/plugins/test_rpm.c
@@ -34,12 +34,13 @@
/**
* Expected package description text.
*/
-#define DESCRIPTION "The libtool package contains the GNU libtool, a set of shell scripts\n"\
- "which automatically configure UNIX and UNIX-like architectures to\n" \
+#define DESCRIPTION \
+ "The libtool package contains the GNU libtool, a set of shell scripts\n" \
+ "which automatically configure UNIX and UNIX-like architectures to\n" \
"generically build shared libraries. Libtool provides a consistent,\n" \
- "portable interface which simplifies the process of using shared\n" \
- "libraries.\n" \
- "\n" \
+ "portable interface which simplifies the process of using shared\n" \
+ "libraries.\n" \
+ "\n" \
"If you are developing programs which will use shared libraries, you\n" \
"should install libtool."
@@ -54,273 +55,272 @@
int
main (int argc, char *argv[])
{
- struct SolutionData rpm_test_sol[] =
- {
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "application/x-rpm",
- strlen ("application/x-rpm") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_NAME,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "libtool",
- strlen ("libtool") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_SOFTWARE_VERSION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "1.5",
- strlen ("1.5") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_VERSION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "6",
- strlen ("6") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_SUMMARY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- SUMMARY,
- strlen (SUMMARY) + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_DESCRIPTION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- DESCRIPTION,
- strlen (DESCRIPTION) + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CREATION_DATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Thu Oct 2 11:44:33 2003",
- strlen ("Thu Oct 2 11:44:33 2003") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_BUILDHOST,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "bullwinkle.devel.redhat.com",
- strlen ("bullwinkle.devel.redhat.com") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_INSTALLED_SIZE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "2623621",
- strlen ("2623621") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_DISTRIBUTION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Red Hat Linux",
- strlen ("Red Hat Linux") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_VENDOR,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Red Hat, Inc.",
- strlen ("Red Hat, Inc.") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_LICENSE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "GPL",
- strlen ("GPL") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_MAINTAINER,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>",
- strlen ("Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_SECTION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Development/Tools",
- strlen ("Development/Tools") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_URL,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "http://www.gnu.org/software/libtool/",
- strlen ("http://www.gnu.org/software/libtool/") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TARGET_OS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "linux",
- strlen ("linux") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TARGET_ARCHITECTURE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ia64",
- strlen ("ia64") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_PROVIDES,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "libtool",
- strlen ("libtool") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "/bin/sh",
- strlen ("/bin/sh") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "/bin/sh",
- strlen ("/bin/sh") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "/bin/sh",
- strlen ("/bin/sh") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "/sbin/install-info",
- strlen ("/sbin/install-info") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "autoconf",
- strlen ("autoconf") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "automake",
- strlen ("automake") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "libtool-libs",
- strlen ("libtool-libs") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "m4",
- strlen ("m4") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "mktemp",
- strlen ("mktemp") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "perl",
- strlen ("perl") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "rpmlib(CompressedFileNames)",
- strlen ("rpmlib(CompressedFileNames)") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "rpmlib(PayloadFilesHavePrefix)",
- strlen ("rpmlib(PayloadFilesHavePrefix)") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "rpmlib(VersionedDependencies)",
- strlen ("rpmlib(VersionedDependencies)") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TARGET_PLATFORM,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "ia64-redhat-linux-gnu",
- strlen ("ia64-redhat-linux-gnu") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
- {
- { "testdata/rpm_test.rpm",
- rpm_test_sol },
- { NULL, NULL }
- };
+ struct SolutionData rpm_test_sol[] = {
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "application/x-rpm",
+ strlen ("application/x-rpm") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_NAME,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "libtool",
+ strlen ("libtool") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_SOFTWARE_VERSION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "1.5",
+ strlen ("1.5") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_VERSION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "6",
+ strlen ("6") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_SUMMARY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ SUMMARY,
+ strlen (SUMMARY) + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_DESCRIPTION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ DESCRIPTION,
+ strlen (DESCRIPTION) + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CREATION_DATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Thu Oct 2 11:44:33 2003",
+ strlen ("Thu Oct 2 11:44:33 2003") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_BUILDHOST,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "bullwinkle.devel.redhat.com",
+ strlen ("bullwinkle.devel.redhat.com") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_INSTALLED_SIZE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2623621",
+ strlen ("2623621") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_DISTRIBUTION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Red Hat Linux",
+ strlen ("Red Hat Linux") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_VENDOR,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Red Hat, Inc.",
+ strlen ("Red Hat, Inc.") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_LICENSE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "GPL",
+ strlen ("GPL") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_MAINTAINER,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>",
+ strlen ("Red Hat, Inc. <http://bugzilla.redhat.com/bugzilla>") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_SECTION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Development/Tools",
+ strlen ("Development/Tools") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_URL,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "http://www.gnu.org/software/libtool/",
+ strlen ("http://www.gnu.org/software/libtool/") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TARGET_OS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "linux",
+ strlen ("linux") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TARGET_ARCHITECTURE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ia64",
+ strlen ("ia64") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_PROVIDES,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "libtool",
+ strlen ("libtool") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "/bin/sh",
+ strlen ("/bin/sh") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "/bin/sh",
+ strlen ("/bin/sh") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "/bin/sh",
+ strlen ("/bin/sh") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "/sbin/install-info",
+ strlen ("/sbin/install-info") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "autoconf",
+ strlen ("autoconf") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "automake",
+ strlen ("automake") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "libtool-libs",
+ strlen ("libtool-libs") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "m4",
+ strlen ("m4") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "mktemp",
+ strlen ("mktemp") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "perl",
+ strlen ("perl") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "rpmlib(CompressedFileNames)",
+ strlen ("rpmlib(CompressedFileNames)") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "rpmlib(PayloadFilesHavePrefix)",
+ strlen ("rpmlib(PayloadFilesHavePrefix)") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_PACKAGE_DEPENDENCY,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "rpmlib(VersionedDependencies)",
+ strlen ("rpmlib(VersionedDependencies)") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TARGET_PLATFORM,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "ia64-redhat-linux-gnu",
+ strlen ("ia64-redhat-linux-gnu") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/rpm_test.rpm",
+ rpm_test_sol },
+ { NULL, NULL }
+ };
return ET_main ("rpm", ps);
}
+
/* end of test_rpm.c */
diff --git a/src/plugins/test_s3m.c b/src/plugins/test_s3m.c
@@ -26,7 +26,6 @@
#include "test_lib.h"
-
/**
* Main function for the S3M testcase.
*
@@ -37,33 +36,32 @@
int
main (int argc, char *argv[])
{
- struct SolutionData s3m_2ndpm_sol[] =
+ struct SolutionData s3m_2ndpm_sol[] = {
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "audio/x-s3m",
- strlen ("audio/x-s3m") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "UnreaL ][ / PM ",
- strlen ("UnreaL ][ / PM ") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "audio/x-s3m",
+ strlen ("audio/x-s3m") + 1,
+ 0
+ },
{
- { "testdata/s3m_2nd_pm.s3m",
- s3m_2ndpm_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "UnreaL ][ / PM ",
+ strlen ("UnreaL ][ / PM ") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/s3m_2nd_pm.s3m",
+ s3m_2ndpm_sol },
+ { NULL, NULL }
+ };
return ET_main ("s3m", ps);
}
+
/* end of test_s3m.c */
diff --git a/src/plugins/test_sid.c b/src/plugins/test_sid.c
@@ -36,89 +36,88 @@
int
main (int argc, char *argv[])
{
- struct SolutionData sid_wizball_sol[] =
+ struct SolutionData sid_wizball_sol[] = {
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "audio/prs.sid",
- strlen ("audio/prs.sid") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_FORMAT_VERSION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "2",
- strlen ("2") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_SONG_COUNT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "9",
- strlen ("9") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_STARTING_SONG,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "4",
- strlen ("4") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ALBUM,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Wizball",
- strlen ("Wizball") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ARTIST,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Martin Galway",
- strlen ("Martin Galway") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_COPYRIGHT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "1987 Ocean",
- strlen ("1987 Ocean") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "PAL",
- strlen ("PAL") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TARGET_ARCHITECTURE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "MOS6581",
- strlen ("MOS6581") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "audio/prs.sid",
+ strlen ("audio/prs.sid") + 1,
+ 0
+ },
{
- { "testdata/sid_wizball.sid",
- sid_wizball_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_FORMAT_VERSION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2",
+ strlen ("2") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_SONG_COUNT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "9",
+ strlen ("9") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_STARTING_SONG,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "4",
+ strlen ("4") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ALBUM,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Wizball",
+ strlen ("Wizball") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ARTIST,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Martin Galway",
+ strlen ("Martin Galway") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_COPYRIGHT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "1987 Ocean",
+ strlen ("1987 Ocean") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_BROADCAST_TELEVISION_SYSTEM,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "PAL",
+ strlen ("PAL") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_TARGET_ARCHITECTURE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "MOS6581",
+ strlen ("MOS6581") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/sid_wizball.sid",
+ sid_wizball_sol },
+ { NULL, NULL }
+ };
return ET_main ("sid", ps);
}
+
/* end of test_sid.c */
diff --git a/src/plugins/test_thumbnailffmpeg.c b/src/plugins/test_thumbnailffmpeg.c
@@ -26,7 +26,6 @@
#include "test_lib.h"
-
/**
* Main function for the THUMBNAILFFMPEG testcase.
*
@@ -37,17 +36,16 @@
int
main (int argc, char *argv[])
{
- struct SolutionData thumbnailffmpeg_video_sol[] =
- {
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
- {
- { "testdata/thumbnailffmpeg_video.mov",
- thumbnailffmpeg_video_sol },
- { NULL, NULL }
- };
+ struct SolutionData thumbnailffmpeg_video_sol[] = {
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/thumbnailffmpeg_video.mov",
+ thumbnailffmpeg_video_sol },
+ { NULL, NULL }
+ };
return ET_main ("thumbnailffmpeg", ps);
}
+
/* end of test_thumbnailffmpeg.c */
diff --git a/src/plugins/test_thumbnailgtk.c b/src/plugins/test_thumbnailgtk.c
@@ -26,7 +26,6 @@
#include "test_lib.h"
-
/**
* Main function for the THUMBNAILGTKJ testcase.
*
@@ -38,33 +37,32 @@ int
main (int argc, char *argv[])
{
uint8_t thumbnail_data[] = { 137, 80, 78, 71 /* rest omitted */ };
- struct SolutionData thumbnail_torsten_sol[] =
+ struct SolutionData thumbnail_torsten_sol[] = {
{
- {
- EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "1600x1200",
- strlen ("1600x1200") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_THUMBNAIL,
- EXTRACTOR_METAFORMAT_BINARY,
- "image/png",
- (void *) thumbnail_data,
- sizeof (thumbnail_data),
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "1600x1200",
+ strlen ("1600x1200") + 1,
+ 0
+ },
{
- { "testdata/thumbnail_torsten.jpg",
- thumbnail_torsten_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_THUMBNAIL,
+ EXTRACTOR_METAFORMAT_BINARY,
+ "image/png",
+ (void *) thumbnail_data,
+ sizeof (thumbnail_data),
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/thumbnail_torsten.jpg",
+ thumbnail_torsten_sol },
+ { NULL, NULL }
+ };
return ET_main ("thumbnailgtk", ps);
}
+
/* end of test_thumbnailgtk.c */
diff --git a/src/plugins/test_tiff.c b/src/plugins/test_tiff.c
@@ -26,7 +26,6 @@
#include "test_lib.h"
-
/**
* Main function for the TIFF testcase.
*
@@ -37,85 +36,84 @@
int
main (int argc, char *argv[])
{
- struct SolutionData tiff_haute_sol[] =
+ struct SolutionData tiff_haute_sol[] = {
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "image/tiff",
+ strlen ("image/tiff") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_ARTIST,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Anders Espersen",
+ strlen ("Anders Espersen") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CREATION_DATE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "2012:05:15 10:51:47",
+ strlen ("2012:05:15 10:51:47") + 1,
+ 0
+ },
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "image/tiff",
- strlen ("image/tiff") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_ARTIST,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Anders Espersen",
- strlen ("Anders Espersen") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CREATION_DATE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "2012:05:15 10:51:47",
- strlen ("2012:05:15 10:51:47") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_COPYRIGHT,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "© Anders Espersen",
- strlen ("© Anders Espersen") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CAMERA_MAKE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Hasselblad",
- strlen ("Hasselblad") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CAMERA_MODEL,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Hasselblad H4D-31",
- strlen ("Hasselblad H4D-31") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "Adobe Photoshop CS5 Macintosh",
- strlen ("Adobe Photoshop CS5 Macintosh") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "4872x6496",
- strlen ("4872x6496") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_COPYRIGHT,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "© Anders Espersen",
+ strlen ("© Anders Espersen") + 1,
+ 0
+ },
{
- /* note that the original test image was almost
- 100 MB large; so for SVN it was cut down to
- only contain the first 64 KB, which still parse
- fine and give use the meta data */
- { "testdata/tiff_haute.tiff",
- tiff_haute_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_CAMERA_MAKE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Hasselblad",
+ strlen ("Hasselblad") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CAMERA_MODEL,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Hasselblad H4D-31",
+ strlen ("Hasselblad H4D-31") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "Adobe Photoshop CS5 Macintosh",
+ strlen ("Adobe Photoshop CS5 Macintosh") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "4872x6496",
+ strlen ("4872x6496") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ /* note that the original test image was almost
+ 100 MB large; so for SVN it was cut down to
+ only contain the first 64 KB, which still parse
+ fine and give use the meta data */
+ { "testdata/tiff_haute.tiff",
+ tiff_haute_sol },
+ { NULL, NULL }
+ };
return ET_main ("tiff", ps);
}
+
/* end of test_tiff.c */
diff --git a/src/plugins/test_wav.c b/src/plugins/test_wav.c
@@ -26,7 +26,6 @@
#include "test_lib.h"
-
/**
* Main function for the WAV testcase.
*
@@ -37,55 +36,53 @@
int
main (int argc, char *argv[])
{
- struct SolutionData wav_noise_sol[] =
+ struct SolutionData wav_noise_sol[] = {
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "audio/x-wav",
+ strlen ("audio/x-wav") + 1,
+ 0
+ },
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "audio/x-wav",
- strlen ("audio/x-wav") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_RESOURCE_TYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "1000 ms, 48000 Hz, mono",
- strlen ("1000 ms, 48000 Hz, mono") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct SolutionData wav_alert_sol[] =
+ EXTRACTOR_METATYPE_RESOURCE_TYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "1000 ms, 48000 Hz, mono",
+ strlen ("1000 ms, 48000 Hz, mono") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct SolutionData wav_alert_sol[] = {
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "audio/x-wav",
- strlen ("audio/x-wav") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_RESOURCE_TYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "525 ms, 22050 Hz, mono",
- strlen ("525 ms, 22050 Hz, mono") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "audio/x-wav",
+ strlen ("audio/x-wav") + 1,
+ 0
+ },
{
- { "testdata/wav_noise.wav",
- wav_noise_sol },
- { "testdata/wav_alert.wav",
- wav_alert_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_RESOURCE_TYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "525 ms, 22050 Hz, mono",
+ strlen ("525 ms, 22050 Hz, mono") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/wav_noise.wav",
+ wav_noise_sol },
+ { "testdata/wav_alert.wav",
+ wav_alert_sol },
+ { NULL, NULL }
+ };
return ET_main ("wav", ps);
}
+
/* end of test_wav.c */
diff --git a/src/plugins/test_xm.c b/src/plugins/test_xm.c
@@ -26,7 +26,6 @@
#include "test_lib.h"
-
/**
* Main function for the XM testcase.
*
@@ -37,49 +36,48 @@
int
main (int argc, char *argv[])
{
- struct SolutionData xm_diesel_sol[] =
+ struct SolutionData xm_diesel_sol[] = {
+ {
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "audio/x-xm",
+ strlen ("audio/x-xm") + 1,
+ 0
+ },
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "audio/x-xm",
- strlen ("audio/x-xm") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_FORMAT_VERSION,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "1.4",
- strlen ("1.4") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_TITLE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "diesel",
- strlen ("diesel") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "FastTracker v2.00",
- strlen ("FastTracker v2.00") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_FORMAT_VERSION,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "1.4",
+ strlen ("1.4") + 1,
+ 0
+ },
{
- { "testdata/xm_diesel.xm",
- xm_diesel_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_TITLE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "diesel",
+ strlen ("diesel") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_CREATED_BY_SOFTWARE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "FastTracker v2.00",
+ strlen ("FastTracker v2.00") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/xm_diesel.xm",
+ xm_diesel_sol },
+ { NULL, NULL }
+ };
return ET_main ("xm", ps);
}
+
/* end of test_xm.c */
diff --git a/src/plugins/test_zip.c b/src/plugins/test_zip.c
@@ -36,73 +36,72 @@
int
main (int argc, char *argv[])
{
- struct SolutionData zip_test_sol[] =
+ struct SolutionData zip_test_sol[] = {
{
- {
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "application/zip",
- strlen ("application/zip") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- "global zipfile comment",
- strlen ("global zipfile comment") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_FILENAME,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- "ChangeLog",
- strlen ("ChangeLog") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_FILENAME,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- "test.png",
- strlen ("test.png") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- "comment for test.png",
- strlen ("comment for test.png") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_FILENAME,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- "test.jpg",
- strlen ("test.jpg") + 1,
- 0
- },
- {
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- "comment for test.jpg",
- strlen ("comment for test.jpg") + 1,
- 0
- },
- { 0, 0, NULL, NULL, 0, -1 }
- };
- struct ProblemSet ps[] =
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "application/zip",
+ strlen ("application/zip") + 1,
+ 0
+ },
{
- { "testdata/zip_test.zip",
- zip_test_sol },
- { NULL, NULL }
- };
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ "global zipfile comment",
+ strlen ("global zipfile comment") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_FILENAME,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ "ChangeLog",
+ strlen ("ChangeLog") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_FILENAME,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ "test.png",
+ strlen ("test.png") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ "comment for test.png",
+ strlen ("comment for test.png") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_FILENAME,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ "test.jpg",
+ strlen ("test.jpg") + 1,
+ 0
+ },
+ {
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ "comment for test.jpg",
+ strlen ("comment for test.jpg") + 1,
+ 0
+ },
+ { 0, 0, NULL, NULL, 0, -1 }
+ };
+ struct ProblemSet ps[] = {
+ { "testdata/zip_test.zip",
+ zip_test_sol },
+ { NULL, NULL }
+ };
return ET_main ("zip", ps);
}
+
/* end of test_zip.c */
diff --git a/src/plugins/thumbnailffmpeg_extractor.c b/src/plugins/thumbnailffmpeg_extractor.c
@@ -97,7 +97,7 @@
/**
* Maximum size in bytes for the thumbnail.
*/
-#define MAX_THUMB_BYTES (100*1024)
+#define MAX_THUMB_BYTES (100 * 1024)
/**
* Number of bytes to feed to libav in one go.
@@ -135,8 +135,8 @@ static magic_t magic;
*/
static int
read_cb (void *opaque,
- uint8_t *buf,
- int buf_size)
+ uint8_t *buf,
+ int buf_size)
{
struct EXTRACTOR_ExtractContext *ec = opaque;
void *data;
@@ -160,8 +160,8 @@ read_cb (void *opaque,
*/
static int64_t
seek_cb (void *opaque,
- int64_t offset,
- int whence)
+ int64_t offset,
+ int whence)
{
struct EXTRACTOR_ExtractContext *ec = opaque;
@@ -187,12 +187,12 @@ seek_cb (void *opaque,
*/
static size_t
create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
- int src_stride[],
- enum AVPixelFormat src_pixfmt,
- const uint8_t * const src_data[],
- int dst_width, int dst_height,
- uint8_t **output_data,
- size_t output_max_size)
+ int src_stride[],
+ enum AVPixelFormat src_pixfmt,
+ const uint8_t *const src_data[],
+ int dst_width, int dst_height,
+ uint8_t **output_data,
+ size_t output_max_size)
{
AVCodecContext *encoder_codec_ctx;
AVDictionary *opts;
@@ -205,73 +205,73 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
int err;
AVPacket pkt;
- av_init_packet(&pkt);
+ av_init_packet (&pkt);
pkt.data = NULL;
pkt.size = 0;
int gotPacket;
#if USE_JPEG
- #if LIBAVCODEC_BUILD >= AV_VERSION_INT(54,25,0)
- if (NULL == (encoder_codec = avcodec_find_encoder ( AV_CODEC_ID_MJPEG )))
- #else
- if (NULL == (encoder_codec = avcodec_find_encoder ( CODEC_ID_MJPEG )))
- #endif
+ #if LIBAVCODEC_BUILD >= AV_VERSION_INT (54,25,0)
+ if (NULL == (encoder_codec = avcodec_find_encoder (AV_CODEC_ID_MJPEG)))
+ #else
+ if (NULL == (encoder_codec = avcodec_find_encoder (CODEC_ID_MJPEG)))
+ #endif
#else
- if (NULL == (encoder_codec = avcodec_find_encoder_by_name ("png")))
+ if (NULL == (encoder_codec = avcodec_find_encoder_by_name ("png")))
#endif
- {
+ {
#if DEBUG
- fprintf (stderr,
- "Couldn't find a encoder\n");
+ fprintf (stderr,
+ "Couldn't find a encoder\n");
#endif
- return 0;
- }
+ return 0;
+ }
/* NOTE: the scaler will be used even if the src and dst image dimensions
* match, because the scaler will also perform colour space conversion */
if (NULL ==
(scaler_ctx =
- sws_getContext (src_width, src_height, src_pixfmt,
- dst_width, dst_height,
- PIX_OUTPUT_FORMAT,
- SWS_BILINEAR, NULL, NULL, NULL)))
- {
+ sws_getContext (src_width, src_height, src_pixfmt,
+ dst_width, dst_height,
+ PIX_OUTPUT_FORMAT,
+ SWS_BILINEAR, NULL, NULL, NULL)))
+ {
#if DEBUG
- fprintf (stderr,
- "Failed to get a scaler context\n");
+ fprintf (stderr,
+ "Failed to get a scaler context\n");
#endif
- return 0;
- }
+ return 0;
+ }
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
dst_frame = av_frame_alloc ();
#else
- dst_frame = avcodec_alloc_frame();
+ dst_frame = avcodec_alloc_frame ();
#endif
if (NULL == dst_frame)
- {
+ {
#if DEBUG
- fprintf (stderr,
- "Failed to allocate the destination image frame\n");
+ fprintf (stderr,
+ "Failed to allocate the destination image frame\n");
#endif
- sws_freeContext (scaler_ctx);
- return 0;
- }
+ sws_freeContext (scaler_ctx);
+ return 0;
+ }
if (NULL == (dst_buffer =
- av_malloc (avpicture_get_size (PIX_OUTPUT_FORMAT,
- dst_width, dst_height))))
- {
+ av_malloc (avpicture_get_size (PIX_OUTPUT_FORMAT,
+ dst_width, dst_height))))
+ {
#if DEBUG
- fprintf (stderr,
- "Failed to allocate the destination image buffer\n");
+ fprintf (stderr,
+ "Failed to allocate the destination image buffer\n");
#endif
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
- av_frame_free (&dst_frame);
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
+ av_frame_free (&dst_frame);
#else
- avcodec_free_frame (&dst_frame);
+ avcodec_free_frame (&dst_frame);
#endif
- sws_freeContext (scaler_ctx);
- return 0;
- }
+ sws_freeContext (scaler_ctx);
+ return 0;
+ }
avpicture_fill ((AVPicture *) dst_frame, dst_buffer,
PIX_OUTPUT_FORMAT,
dst_width, dst_height);
@@ -284,47 +284,47 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
encoder_output_buffer_size = output_max_size;
if (NULL == (encoder_output_buffer = av_malloc (encoder_output_buffer_size)))
- {
+ {
#if DEBUG
- fprintf (stderr,
- "Failed to allocate the encoder output buffer\n");
+ fprintf (stderr,
+ "Failed to allocate the encoder output buffer\n");
#endif
- av_free (dst_buffer);
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
- av_frame_free (&dst_frame);
+ av_free (dst_buffer);
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
+ av_frame_free (&dst_frame);
#else
- avcodec_free_frame (&dst_frame);
+ avcodec_free_frame (&dst_frame);
#endif
- sws_freeContext (scaler_ctx);
- return 0;
- }
+ sws_freeContext (scaler_ctx);
+ return 0;
+ }
if (NULL == (encoder_codec_ctx = avcodec_alloc_context3 (encoder_codec)))
- {
+ {
#if DEBUG
- fprintf (stderr,
- "Failed to allocate the encoder codec context\n");
+ fprintf (stderr,
+ "Failed to allocate the encoder codec context\n");
#endif
- av_free (encoder_output_buffer);
- av_free (dst_buffer);
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
- av_frame_free (&dst_frame);
+ av_free (encoder_output_buffer);
+ av_free (dst_buffer);
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
+ av_frame_free (&dst_frame);
#else
- avcodec_free_frame (&dst_frame);
+ avcodec_free_frame (&dst_frame);
#endif
- sws_freeContext (scaler_ctx);
- return 0;
- }
+ sws_freeContext (scaler_ctx);
+ return 0;
+ }
encoder_codec_ctx->width = dst_width;
encoder_codec_ctx->height = dst_height;
#if USE_JPEG
encoder_codec_ctx->bit_rate = pCodecCtx->bit_rate;
-#if LIBAVCODEC_BUILD >= AV_VERSION_INT(54,25,0)
+#if LIBAVCODEC_BUILD >= AV_VERSION_INT (54,25,0)
encoder_codec_ctx->codec_id = AV_CODEC_ID_MJPEG;
#else
encoder_codec_ctx->codec_id = CODEC_ID_MJPEG;
#endif
-#if LIBAVCODEC_BUILD >= AV_VERSION_INT(53,35,0)
+#if LIBAVCODEC_BUILD >= AV_VERSION_INT (53,35,0)
encoder_codec_ctx->codec_type = AVMEDIA_TYPE_VIDEO;
#else
encoder_codec_ctx->codec_type = CODEC_TYPE_VIDEO;
@@ -338,51 +338,52 @@ create_thumbnail (AVCodecContext *pCodecCtx, int src_width, int src_height,
opts = NULL;
if (avcodec_open2 (encoder_codec_ctx, encoder_codec, &opts) < 0)
- {
+ {
#if DEBUG
- fprintf (stderr,
- "Failed to open the encoder\n");
-#endif
- avcodec_free_context (&encoder_codec_ctx);
- av_free (encoder_output_buffer);
- av_free (dst_buffer);
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
- av_frame_free (&dst_frame);
+ fprintf (stderr,
+ "Failed to open the encoder\n");
+#endif
+ avcodec_free_context (&encoder_codec_ctx);
+ av_free (encoder_output_buffer);
+ av_free (dst_buffer);
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
+ av_frame_free (&dst_frame);
#else
- avcodec_free_frame (&dst_frame);
+ avcodec_free_frame (&dst_frame);
#endif
- sws_freeContext (scaler_ctx);
- return 0;
- }
-
+ sws_freeContext (scaler_ctx);
+ return 0;
+ }
#ifdef USE_JPEG
#if FF_API_MPV_OPT
- encoder_codec_ctx->mb_lmin = encoder_codec_ctx->lmin = encoder_codec_ctx->qmin * FF_QP2LAMBDA;
- encoder_codec_ctx->mb_lmax = encoder_codec_ctx->lmax = encoder_codec_ctx->qmax * FF_QP2LAMBDA;
+ encoder_codec_ctx->mb_lmin = encoder_codec_ctx->lmin =
+ encoder_codec_ctx->qmin * FF_QP2LAMBDA;
+ encoder_codec_ctx->mb_lmax = encoder_codec_ctx->lmax =
+ encoder_codec_ctx->qmax * FF_QP2LAMBDA;
#else
- encoder_codec_ctx->mb_lmin = encoder_codec_ctx->qmin * FF_QP2LAMBDA;
- encoder_codec_ctx->mb_lmax = encoder_codec_ctx->qmax * FF_QP2LAMBDA;
+ encoder_codec_ctx->mb_lmin = encoder_codec_ctx->qmin * FF_QP2LAMBDA;
+ encoder_codec_ctx->mb_lmax = encoder_codec_ctx->qmax * FF_QP2LAMBDA;
#endif
- encoder_codec_ctx->flags = AV_CODEC_FLAG_QSCALE;
- encoder_codec_ctx->global_quality = encoder_codec_ctx->qmin * FF_QP2LAMBDA;
+ encoder_codec_ctx->flags = AV_CODEC_FLAG_QSCALE;
+ encoder_codec_ctx->global_quality = encoder_codec_ctx->qmin * FF_QP2LAMBDA;
- dst_frame->pts = 1;
- dst_frame->quality = encoder_codec_ctx->global_quality;
+ dst_frame->pts = 1;
+ dst_frame->quality = encoder_codec_ctx->global_quality;
#endif
-#if LIBAVCODEC_BUILD >= AV_VERSION_INT(54,25,0)
+#if LIBAVCODEC_BUILD >= AV_VERSION_INT (54,25,0)
err = avcodec_encode_video2 (encoder_codec_ctx,
- &pkt,
+ &pkt,
dst_frame, &gotPacket);
- if(err < 0)
- goto cleanup;
+ if (err < 0)
+ goto cleanup;
err = pkt.size;
- memcpy(encoder_output_buffer,pkt.data, pkt.size);
+ memcpy (encoder_output_buffer,pkt.data, pkt.size);
- av_free_packet(&pkt);
+ av_free_packet (&pkt);
#else
@@ -396,7 +397,7 @@ cleanup:
avcodec_close (encoder_codec_ctx);
avcodec_free_context (&encoder_codec_ctx);
av_free (dst_buffer);
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
av_frame_free (&dst_frame);
#else
avcodec_free_frame (&dst_frame);
@@ -408,7 +409,6 @@ cleanup:
}
-
/**
* calculate the thumbnail dimensions, taking pixel aspect into account
*
@@ -421,30 +421,30 @@ cleanup:
*/
static void
calculate_thumbnail_dimensions (int src_width,
- int src_height,
- int src_sar_num,
- int src_sar_den,
- int *dst_width,
- int *dst_height)
+ int src_height,
+ int src_sar_num,
+ int src_sar_den,
+ int *dst_width,
+ int *dst_height)
{
if ( (src_sar_num <= 0) || (src_sar_den <= 0) )
- {
- src_sar_num = 1;
- src_sar_den = 1;
- }
+ {
+ src_sar_num = 1;
+ src_sar_den = 1;
+ }
if ((src_width * src_sar_num) / src_sar_den > src_height)
- {
- *dst_width = MAX_THUMB_DIMENSION;
- *dst_height = (*dst_width * src_height) /
- ((src_width * src_sar_num) / src_sar_den);
- }
+ {
+ *dst_width = MAX_THUMB_DIMENSION;
+ *dst_height = (*dst_width * src_height)
+ / ((src_width * src_sar_num) / src_sar_den);
+ }
else
- {
- *dst_height = MAX_THUMB_DIMENSION;
- *dst_width = (*dst_height *
- ((src_width * src_sar_num) / src_sar_den)) /
- src_height;
- }
+ {
+ *dst_height = MAX_THUMB_DIMENSION;
+ *dst_width = (*dst_height
+ * ((src_width * src_sar_num) / src_sar_den))
+ / src_height;
+ }
if (*dst_width < 8)
*dst_width = 8;
if (*dst_height < 1)
@@ -456,10 +456,11 @@ calculate_thumbnail_dimensions (int src_width,
#endif
}
-#if LIBAVCODEC_BUILD >= AV_VERSION_INT(54,25,0)
- #define ENUM_CODEC_ID enum AVCodecID
+
+#if LIBAVCODEC_BUILD >= AV_VERSION_INT (54,25,0)
+ #define ENUM_CODEC_ID enum AVCodecID
#else
- #define ENUM_CODEC_ID enum CodecID
+ #define ENUM_CODEC_ID enum CodecID
#endif
/**
@@ -487,77 +488,77 @@ extract_image (ENUM_CODEC_ID image_codec_id,
unsigned char padded_data[PADDED_BUFFER_SIZE];
if (NULL == (codec = avcodec_find_decoder (image_codec_id)))
- {
+ {
#if DEBUG
- fprintf (stderr,
- "No suitable codec found\n");
+ fprintf (stderr,
+ "No suitable codec found\n");
#endif
- return;
- }
+ return;
+ }
if (NULL == (codec_ctx = avcodec_alloc_context3 (codec)))
- {
+ {
#if DEBUG
- fprintf (stderr,
- "Failed to allocate codec context\n");
+ fprintf (stderr,
+ "Failed to allocate codec context\n");
#endif
- return;
- }
+ return;
+ }
opts = NULL;
if (0 != avcodec_open2 (codec_ctx, codec, &opts))
- {
+ {
#if DEBUG
- fprintf (stderr,
- "Failed to open image codec\n");
+ fprintf (stderr,
+ "Failed to open image codec\n");
#endif
- avcodec_free_context (&codec_ctx);
- return;
- }
+ avcodec_free_context (&codec_ctx);
+ return;
+ }
av_dict_free (&opts);
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
frame = av_frame_alloc ();
#else
- frame = avcodec_alloc_frame();
+ frame = avcodec_alloc_frame ();
#endif
if (NULL == frame)
- {
+ {
#if DEBUG
- fprintf (stderr,
- "Failed to allocate frame\n");
+ fprintf (stderr,
+ "Failed to allocate frame\n");
#endif
- avcodec_close (codec_ctx);
- avcodec_free_context (&codec_ctx);
- return;
- }
+ avcodec_close (codec_ctx);
+ avcodec_free_context (&codec_ctx);
+ return;
+ }
frame_finished = 0;
while (! frame_finished)
- {
- if (0 >= (iret = ec->read (ec->cls,
- &data,
- BUFFER_SIZE)))
- break;
- memcpy (padded_data, data, iret);
- memset (&padded_data[iret], 0, PADDED_BUFFER_SIZE - iret);
- av_init_packet (&avpkt);
- avpkt.data = padded_data;
- avpkt.size = iret;
- avcodec_decode_video2 (codec_ctx, frame, &frame_finished, &avpkt);
- }
+ {
+ if (0 >= (iret = ec->read (ec->cls,
+ &data,
+ BUFFER_SIZE)))
+ break;
+ memcpy (padded_data, data, iret);
+ memset (&padded_data[iret], 0, PADDED_BUFFER_SIZE - iret);
+ av_init_packet (&avpkt);
+ avpkt.data = padded_data;
+ avpkt.size = iret;
+ avcodec_decode_video2 (codec_ctx, frame, &frame_finished, &avpkt);
+ }
if (! frame_finished)
- {
+ {
#if DEBUG
- fprintf (stderr,
- "Failed to decode a complete frame\n");
+ fprintf (stderr,
+ "Failed to decode a complete frame\n");
#endif
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
- av_frame_free (&frame);
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
+ av_frame_free (&frame);
#else
- avcodec_free_frame (&frame);
+ avcodec_free_frame (&frame);
#endif
- avcodec_close (codec_ctx);
- avcodec_free_context (&codec_ctx);
- return;
- }
+ avcodec_close (codec_ctx);
+ avcodec_free_context (&codec_ctx);
+ return;
+ }
calculate_thumbnail_dimensions (codec_ctx->width, codec_ctx->height,
codec_ctx->sample_aspect_ratio.num,
codec_ctx->sample_aspect_ratio.den,
@@ -565,40 +566,41 @@ extract_image (ENUM_CODEC_ID image_codec_id,
err = create_thumbnail (codec_ctx, codec_ctx->width, codec_ctx->height,
frame->linesize, codec_ctx->pix_fmt,
- (const uint8_t * const*) frame->data,
+ (const uint8_t *const*) frame->data,
thumb_width, thumb_height,
&encoded_thumbnail, MAX_THUMB_BYTES);
if (err > 0)
+ {
+ ec->proc (ec->cls,
+ "thumbnailffmpeg",
+ EXTRACTOR_METATYPE_THUMBNAIL,
+ EXTRACTOR_METAFORMAT_BINARY,
+ "image/png",
+ (const char*) encoded_thumbnail,
+ err);
+
+ #if OUTPUT_FILE
+ FILE *f;
+ #ifdef USE_JPEG
+ f = fopen ("thumb.jpg", "wb");
+ #else
+ f = fopen ("thumb.png", "wb");
+ #endif
+ if (! f)
{
- ec->proc (ec->cls,
- "thumbnailffmpeg",
- EXTRACTOR_METATYPE_THUMBNAIL,
- EXTRACTOR_METAFORMAT_BINARY,
- "image/png",
- (const char*) encoded_thumbnail,
- err);
-
- #if OUTPUT_FILE
- FILE *f;
- #ifdef USE_JPEG
- f = fopen("thumb.jpg", "wb");
- #else
- f = fopen("thumb.png", "wb");
- #endif
- if (!f) {
- fprintf(stderr, "Could not open %s\n", "file");
- exit(1);
- }
-
- fwrite(encoded_thumbnail, 1, err, f);
- fclose(f);
+ fprintf (stderr, "Could not open %s\n", "file");
+ exit (1);
+ }
+
+ fwrite (encoded_thumbnail, 1, err, f);
+ fclose (f);
#endif
- av_free (encoded_thumbnail);
- }
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
+ av_free (encoded_thumbnail);
+ }
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
av_frame_free (&frame);
#else
avcodec_free_frame (&frame);
@@ -637,107 +639,107 @@ extract_video (struct EXTRACTOR_ExtractContext *ec)
return;
if (NULL == (io_ctx = avio_alloc_context (iob,
16 * 1024,
- 0, ec,
- &read_cb,
- NULL /* no writing */,
- &seek_cb)))
- {
- av_free (iob);
- return;
- }
+ 0, ec,
+ &read_cb,
+ NULL /* no writing */,
+ &seek_cb)))
+ {
+ av_free (iob);
+ return;
+ }
if (NULL == (format_ctx = avformat_alloc_context ()))
- {
- av_free (io_ctx);
- return;
- }
+ {
+ av_free (io_ctx);
+ return;
+ }
format_ctx->pb = io_ctx;
options = NULL;
if (0 != avformat_open_input (&format_ctx, "<no file>", NULL, &options))
- {
- av_free (io_ctx);
- return;
- }
+ {
+ av_free (io_ctx);
+ return;
+ }
av_dict_free (&options);
if (0 > avformat_find_stream_info (format_ctx, NULL))
- {
+ {
#if DEBUG
- fprintf (stderr,
- "Failed to read stream info\n");
+ fprintf (stderr,
+ "Failed to read stream info\n");
#endif
- avformat_close_input (&format_ctx);
- av_free (io_ctx);
- return;
- }
+ avformat_close_input (&format_ctx);
+ av_free (io_ctx);
+ return;
+ }
codec = NULL;
codec_ctx = NULL;
video_stream_index = -1;
- for (i=0; i<format_ctx->nb_streams; i++)
+ for (i = 0; i<format_ctx->nb_streams; i++)
+ {
+ codec_ctx = format_ctx->streams[i]->codec;
+ if (AVMEDIA_TYPE_VIDEO != codec_ctx->codec_type)
+ continue;
+ if (NULL == (codec = avcodec_find_decoder (codec_ctx->codec_id)))
+ continue;
+ options = NULL;
+ if (0 != (err = avcodec_open2 (codec_ctx, codec, &options)))
{
- codec_ctx = format_ctx->streams[i]->codec;
- if (AVMEDIA_TYPE_VIDEO != codec_ctx->codec_type)
- continue;
- if (NULL == (codec = avcodec_find_decoder (codec_ctx->codec_id)))
- continue;
- options = NULL;
- if (0 != (err = avcodec_open2 (codec_ctx, codec, &options)))
- {
- codec = NULL;
- continue;
- }
- av_dict_free (&options);
- video_stream_index = i;
- break;
+ codec = NULL;
+ continue;
}
+ av_dict_free (&options);
+ video_stream_index = i;
+ break;
+ }
if ( (-1 == video_stream_index) ||
(0 == codec_ctx->width) ||
(0 == codec_ctx->height) )
- {
+ {
#if DEBUG
- fprintf (stderr,
- "No video streams or no suitable codec found\n");
+ fprintf (stderr,
+ "No video streams or no suitable codec found\n");
#endif
- if (NULL != codec)
- avcodec_close (codec_ctx);
- avformat_close_input (&format_ctx);
- av_free (io_ctx);
- return;
- }
+ if (NULL != codec)
+ avcodec_close (codec_ctx);
+ avformat_close_input (&format_ctx);
+ av_free (io_ctx);
+ return;
+ }
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
frame = av_frame_alloc ();
#else
- frame = avcodec_alloc_frame();
+ frame = avcodec_alloc_frame ();
#endif
if (NULL == frame)
- {
+ {
#if DEBUG
- fprintf (stderr,
- "Failed to allocate frame\n");
+ fprintf (stderr,
+ "Failed to allocate frame\n");
#endif
- avcodec_close (codec_ctx);
- avformat_close_input (&format_ctx);
- av_free (io_ctx);
- return;
- }
+ avcodec_close (codec_ctx);
+ avformat_close_input (&format_ctx);
+ av_free (io_ctx);
+ return;
+ }
if (format_ctx->duration == AV_NOPTS_VALUE)
- {
- duration = -1;
+ {
+ duration = -1;
#if DEBUG
- fprintf (stderr,
- "Duration unknown\n");
+ fprintf (stderr,
+ "Duration unknown\n");
#endif
- }
+ }
else
- {
- duration = format_ctx->duration;
- }
+ {
+ duration = format_ctx->duration;
+ }
/* if duration is known, seek to first tried,
* else use 10 sec into stream */
- if(-1 != duration)
- err = av_seek_frame (format_ctx, -1, (duration/3), 0);
+ if (-1 != duration)
+ err = av_seek_frame (format_ctx, -1, (duration / 3), 0);
else
err = av_seek_frame (format_ctx, -1, 10 * AV_TIME_BASE, 0);
@@ -746,41 +748,41 @@ extract_video (struct EXTRACTOR_ExtractContext *ec)
frame_finished = 0;
while (1)
+ {
+ err = av_read_frame (format_ctx, &packet);
+ if (err < 0)
+ break;
+ if (packet.stream_index == video_stream_index)
{
- err = av_read_frame (format_ctx, &packet);
- if (err < 0)
+ avcodec_decode_video2 (codec_ctx,
+ frame,
+ &frame_finished,
+ &packet);
+ if (frame_finished && frame->key_frame)
+ {
+ av_free_packet (&packet);
break;
- if (packet.stream_index == video_stream_index)
- {
- avcodec_decode_video2 (codec_ctx,
- frame,
- &frame_finished,
- &packet);
- if (frame_finished && frame->key_frame)
- {
- av_free_packet (&packet);
- break;
- }
- }
- av_free_packet (&packet);
+ }
}
+ av_free_packet (&packet);
+ }
if (! frame_finished)
- {
+ {
#if DEBUG
- fprintf (stderr,
- "Failed to decode a complete frame\n");
+ fprintf (stderr,
+ "Failed to decode a complete frame\n");
#endif
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
- av_frame_free (&frame);
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
+ av_frame_free (&frame);
#else
- avcodec_free_frame (&frame);
+ avcodec_free_frame (&frame);
#endif
- avcodec_close (codec_ctx);
- avformat_close_input (&format_ctx);
- av_free (io_ctx);
- return;
- }
+ avcodec_close (codec_ctx);
+ avformat_close_input (&format_ctx);
+ av_free (io_ctx);
+ return;
+ }
calculate_thumbnail_dimensions (codec_ctx->width, codec_ctx->height,
codec_ctx->sample_aspect_ratio.num,
codec_ctx->sample_aspect_ratio.den,
@@ -788,37 +790,37 @@ extract_video (struct EXTRACTOR_ExtractContext *ec)
err = create_thumbnail (codec_ctx, codec_ctx->width, codec_ctx->height,
frame->linesize, codec_ctx->pix_fmt,
- (const uint8_t* const *) frame->data,
+ (const uint8_t*const *) frame->data,
thumb_width, thumb_height,
&encoded_thumbnail, MAX_THUMB_BYTES);
if (err > 0)
- {
- ec->proc (ec->cls,
- "thumbnailffmpeg",
- EXTRACTOR_METATYPE_THUMBNAIL,
- EXTRACTOR_METAFORMAT_BINARY,
- "image/png",
- (const char*) encoded_thumbnail,
- err);
+ {
+ ec->proc (ec->cls,
+ "thumbnailffmpeg",
+ EXTRACTOR_METATYPE_THUMBNAIL,
+ EXTRACTOR_METAFORMAT_BINARY,
+ "image/png",
+ (const char*) encoded_thumbnail,
+ err);
#if OUTPUT_FILE
- FILE *f;
+ FILE *f;
#ifdef USE_JPEG
- f = fopen("thumb.jpg", "wb");
+ f = fopen ("thumb.jpg", "wb");
#else
- f = fopen("thumb.png", "wb");
+ f = fopen ("thumb.png", "wb");
#endif
- if (!f)
- {
- fprintf(stderr, "Could not open %s\n", "file");
- exit(1);
- }
+ if (! f)
+ {
+ fprintf (stderr, "Could not open %s\n", "file");
+ exit (1);
+ }
- fwrite(encoded_thumbnail, 1, err, f);
- fclose(f);
+ fwrite (encoded_thumbnail, 1, err, f);
+ fclose (f);
#endif
- av_free (encoded_thumbnail);
- }
-#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55,28,1)
+ av_free (encoded_thumbnail);
+ }
+#if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT (55,28,1)
av_frame_free (&frame);
#else
avcodec_free_frame (&frame);
@@ -849,28 +851,27 @@ struct MIMEToDecoderMapping
/**
* map MIME image types to an ffmpeg decoder
*/
-static const struct MIMEToDecoderMapping m2d_map[] =
- {
-
-#if LIBAVCODEC_BUILD >= AV_VERSION_INT(54,25,0)
- { "image/x-bmp", AV_CODEC_ID_BMP },
- { "image/gif", AV_CODEC_ID_GIF },
- { "image/jpeg", AV_CODEC_ID_MJPEG },
- { "image/png", AV_CODEC_ID_PNG },
- { "image/x-png", AV_CODEC_ID_PNG },
- { "image/x-portable-pixmap", AV_CODEC_ID_PPM },
- { NULL, AV_CODEC_ID_NONE }
+static const struct MIMEToDecoderMapping m2d_map[] = {
+
+#if LIBAVCODEC_BUILD >= AV_VERSION_INT (54,25,0)
+ { "image/x-bmp", AV_CODEC_ID_BMP },
+ { "image/gif", AV_CODEC_ID_GIF },
+ { "image/jpeg", AV_CODEC_ID_MJPEG },
+ { "image/png", AV_CODEC_ID_PNG },
+ { "image/x-png", AV_CODEC_ID_PNG },
+ { "image/x-portable-pixmap", AV_CODEC_ID_PPM },
+ { NULL, AV_CODEC_ID_NONE }
#else
- { "image/x-bmp", CODEC_ID_BMP },
- { "image/gif", CODEC_ID_GIF },
- { "image/jpeg", CODEC_ID_MJPEG },
- { "image/png", CODEC_ID_PNG },
- { "image/x-png", CODEC_ID_PNG },
- { "image/x-portable-pixmap", CODEC_ID_PPM },
- { NULL, CODEC_ID_NONE }
+ { "image/x-bmp", CODEC_ID_BMP },
+ { "image/gif", CODEC_ID_GIF },
+ { "image/jpeg", CODEC_ID_MJPEG },
+ { "image/png", CODEC_ID_PNG },
+ { "image/x-png", CODEC_ID_PNG },
+ { "image/x-portable-pixmap", CODEC_ID_PPM },
+ { NULL, CODEC_ID_NONE }
#endif
- };
+};
/**
@@ -887,8 +888,8 @@ EXTRACTOR_thumbnailffmpeg_extract_method (struct EXTRACTOR_ExtractContext *ec)
const char *mime;
if (-1 == (iret = ec->read (ec->cls,
- &data,
- 16 * 1024)))
+ &data,
+ 16 * 1024)))
return;
if (NULL == (mime = magic_buffer (magic, data, iret)))
return;
@@ -896,10 +897,10 @@ EXTRACTOR_thumbnailffmpeg_extract_method (struct EXTRACTOR_ExtractContext *ec)
return;
for (i = 0; NULL != m2d_map[i].mime_type; i++)
if (0 == strcmp (m2d_map[i].mime_type, mime))
- {
- extract_image (m2d_map[i].codec_id, ec);
- return;
- }
+ {
+ extract_image (m2d_map[i].codec_id, ec);
+ return;
+ }
extract_video (ec);
}
@@ -926,13 +927,13 @@ EXTRACTOR_thumbnail_extract_method (struct EXTRACTOR_ExtractContext *ec)
* @param ap arguments for format
*/
static void
-thumbnailffmpeg_av_log_callback (void* ptr,
- int level,
- const char *format,
- va_list ap)
+thumbnailffmpeg_av_log_callback (void*ptr,
+ int level,
+ const char *format,
+ va_list ap)
{
#if DEBUG
- vfprintf(stderr, format, ap);
+ vfprintf (stderr, format, ap);
#endif
}
@@ -947,9 +948,9 @@ thumbnailffmpeg_lib_init (void)
av_register_all ();
magic = magic_open (MAGIC_MIME_TYPE);
if (0 != magic_load (magic, NULL))
- {
- /* FIXME: how to deal with errors? */
- }
+ {
+ /* FIXME: how to deal with errors? */
+ }
}
@@ -960,10 +961,10 @@ void __attribute__ ((destructor))
thumbnailffmpeg_ltdl_fini ()
{
if (NULL != magic)
- {
- magic_close (magic);
- magic = NULL;
- }
+ {
+ magic_close (magic);
+ magic = NULL;
+ }
}
diff --git a/src/plugins/thumbnailgtk_extractor.c b/src/plugins/thumbnailgtk_extractor.c
@@ -75,14 +75,14 @@ EXTRACTOR_thumbnailgtk_extract_method (struct EXTRACTOR_ExtractContext *ec)
const char *mime;
if (-1 == (iret = ec->read (ec->cls,
- &data,
- 16 * 1024)))
+ &data,
+ 16 * 1024)))
return;
if (NULL == (mime = magic_buffer (magic, data, iret)))
return;
if (0 != strncmp (mime,
- "image/",
- strlen ("image/")))
+ "image/",
+ strlen ("image/")))
return; /* not an image */
/* read entire image into memory */
@@ -98,95 +98,95 @@ EXTRACTOR_thumbnailgtk_extract_method (struct EXTRACTOR_ExtractContext *ec)
memcpy (buf, data, iret);
off = iret;
while (off < size)
+ {
+ iret = ec->read (ec->cls, &data, size - off);
+ if (iret <= 0)
{
- iret = ec->read (ec->cls, &data, size - off);
- if (iret <= 0)
- {
- /* io error */
- free (buf);
- return;
- }
- memcpy (buf + off, data, iret);
- off += iret;
+ /* io error */
+ free (buf);
+ return;
}
+ memcpy (buf + off, data, iret);
+ off += iret;
+ }
loader = gdk_pixbuf_loader_new ();
- gdk_pixbuf_loader_write (loader,
- buf,
- size, NULL);
+ gdk_pixbuf_loader_write (loader,
+ buf,
+ size, NULL);
free (buf);
in = gdk_pixbuf_loader_get_pixbuf (loader);
gdk_pixbuf_loader_close (loader, NULL);
if (NULL == in)
- {
- g_object_unref (loader);
- return;
- }
+ {
+ g_object_unref (loader);
+ return;
+ }
g_object_ref (in);
g_object_unref (loader);
height = gdk_pixbuf_get_height (in);
width = gdk_pixbuf_get_width (in);
- snprintf (format,
- sizeof (format),
- "%ux%u",
- (unsigned int) width,
- (unsigned int) height);
+ snprintf (format,
+ sizeof (format),
+ "%ux%u",
+ (unsigned int) width,
+ (unsigned int) height);
if (0 != ec->proc (ec->cls,
- "thumbnailgtk",
- EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- format,
- strlen (format) + 1))
- {
- g_object_unref (in);
- return;
- }
+ "thumbnailgtk",
+ EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ format,
+ strlen (format) + 1))
+ {
+ g_object_unref (in);
+ return;
+ }
if ((height <= THUMBSIZE) && (width <= THUMBSIZE))
- {
- g_object_unref (in);
- return;
- }
+ {
+ g_object_unref (in);
+ return;
+ }
if (height > THUMBSIZE)
- {
- width = width * THUMBSIZE / height;
- height = THUMBSIZE;
- }
+ {
+ width = width * THUMBSIZE / height;
+ height = THUMBSIZE;
+ }
if (width > THUMBSIZE)
- {
- height = height * THUMBSIZE / width;
- width = THUMBSIZE;
- }
+ {
+ height = height * THUMBSIZE / width;
+ width = THUMBSIZE;
+ }
if ( (0 == height) || (0 == width) )
- {
- g_object_unref (in);
- return;
- }
+ {
+ g_object_unref (in);
+ return;
+ }
out = gdk_pixbuf_scale_simple (in, width, height,
- GDK_INTERP_BILINEAR);
+ GDK_INTERP_BILINEAR);
g_object_unref (in);
thumb = NULL;
length = 0;
if (NULL == out)
return;
- if (! gdk_pixbuf_save_to_buffer (out, &thumb,
- &length,
- "png", NULL,
- "compression", "9",
- NULL))
- {
- g_object_unref (out);
- return;
- }
+ if (! gdk_pixbuf_save_to_buffer (out, &thumb,
+ &length,
+ "png", NULL,
+ "compression", "9",
+ NULL))
+ {
+ g_object_unref (out);
+ return;
+ }
g_object_unref (out);
if (NULL == thumb)
return;
ec->proc (ec->cls,
- "thumbnailgtk",
- EXTRACTOR_METATYPE_THUMBNAIL,
- EXTRACTOR_METAFORMAT_BINARY,
- "image/png",
- thumb, length);
+ "thumbnailgtk",
+ EXTRACTOR_METATYPE_THUMBNAIL,
+ EXTRACTOR_METAFORMAT_BINARY,
+ "image/png",
+ thumb, length);
free (thumb);
}
@@ -207,31 +207,32 @@ EXTRACTOR_thumbnail_extract_method (struct EXTRACTOR_ExtractContext *ec)
/**
* Initialize glib and load magic file.
*/
-void __attribute__ ((constructor))
+void __attribute__ ((constructor))
thumbnailgtk_gobject_init ()
{
-#if !GLIB_CHECK_VERSION(2, 35, 0)
+#if ! GLIB_CHECK_VERSION (2, 35, 0)
g_type_init ();
#endif
magic = magic_open (MAGIC_MIME_TYPE);
if (0 != magic_load (magic, NULL))
- {
- /* FIXME: how to deal with errors? */
- }
+ {
+ /* FIXME: how to deal with errors? */
+ }
}
/**
* Destructor for the library, cleans up.
*/
-void __attribute__ ((destructor))
-thumbnailgtk_ltdl_fini ()
+void __attribute__ ((destructor))
+thumbnailgtk_ltdl_fini ()
{
if (NULL != magic)
- {
- magic_close (magic);
- magic = NULL;
- }
+ {
+ magic_close (magic);
+ magic = NULL;
+ }
}
+
/* end of thumbnailgtk_extractor.c */
diff --git a/src/plugins/tiff_extractor.c b/src/plugins/tiff_extractor.c
@@ -36,8 +36,8 @@
*/
static void
error_cb (const char *module,
- const char *fmt,
- va_list ap)
+ const char *fmt,
+ va_list ap)
{
/* do nothing */
}
@@ -53,13 +53,13 @@ error_cb (const char *module,
*/
static tsize_t
read_cb (thandle_t ctx,
- tdata_t data,
- tsize_t size)
+ tdata_t data,
+ tsize_t size)
{
struct EXTRACTOR_ExtractContext *ec = ctx;
void *ptr;
ssize_t ret;
-
+
ret = ec->read (ec->cls, &ptr, size);
if (ret > 0)
memcpy (data, ptr, ret);
@@ -77,8 +77,8 @@ read_cb (thandle_t ctx,
*/
static tsize_t
write_cb (thandle_t ctx,
- tdata_t data,
- tsize_t size)
+ tdata_t data,
+ tsize_t size)
{
return -1;
}
@@ -94,8 +94,8 @@ write_cb (thandle_t ctx,
*/
static toff_t
seek_cb (thandle_t ctx,
- toff_t offset,
- int whence)
+ toff_t offset,
+ int whence)
{
struct EXTRACTOR_ExtractContext *ec = ctx;
@@ -168,77 +168,78 @@ static struct Matches tmap[] = {
/**
- * Main entry method for the 'image/tiff' extraction plugin.
+ * Main entry method for the 'image/tiff' extraction plugin.
*
* @param ec extraction context provided to the plugin
*/
-void
+void
EXTRACTOR_tiff_extract_method (struct EXTRACTOR_ExtractContext *ec)
{
TIFF *tiff;
unsigned int i;
char *meta;
char format[128];
- uint32_t width;
+ uint32_t width;
uint32_t height;
TIFFSetErrorHandler (&error_cb);
TIFFSetWarningHandler (&error_cb);
tiff = TIFFClientOpen ("<no filename>",
- "rm", /* read-only, no mmap */
- ec,
- &read_cb,
- &write_cb,
- &seek_cb,
- &close_cb,
- &size_cb,
- NULL, NULL);
+ "rm", /* read-only, no mmap */
+ ec,
+ &read_cb,
+ &write_cb,
+ &seek_cb,
+ &close_cb,
+ &size_cb,
+ NULL, NULL);
if (NULL == tiff)
return;
for (i = 0; 0 != tmap[i].tag; i++)
if ( (1 ==
- TIFFGetField (tiff, tmap[i].tag, &meta)) &&
- (0 !=
- ec->proc (ec->cls,
- "tiff",
- tmap[i].type,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- meta,
- strlen (meta) + 1)) )
- goto CLEANUP;
- if ( (1 ==
- TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width)) &&
- (1 ==
- TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height)) )
- {
- snprintf (format,
- sizeof (format),
- "%ux%u",
- (unsigned int) width,
- (unsigned int) height);
- if (0 !=
- ec->proc (ec->cls,
- "tiff",
- EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- format,
- strlen (format) + 1))
- goto CLEANUP;
- if (0 !=
- ec->proc (ec->cls,
- "tiff",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "image/tiff",
- strlen ("image/tiff") + 1))
- goto CLEANUP;
- }
-
- CLEANUP:
+ TIFFGetField (tiff, tmap[i].tag, &meta)) &&
+ (0 !=
+ ec->proc (ec->cls,
+ "tiff",
+ tmap[i].type,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ meta,
+ strlen (meta) + 1)) )
+ goto CLEANUP;
+ if ( (1 ==
+ TIFFGetField (tiff, TIFFTAG_IMAGEWIDTH, &width)) &&
+ (1 ==
+ TIFFGetField (tiff, TIFFTAG_IMAGELENGTH, &height)) )
+ {
+ snprintf (format,
+ sizeof (format),
+ "%ux%u",
+ (unsigned int) width,
+ (unsigned int) height);
+ if (0 !=
+ ec->proc (ec->cls,
+ "tiff",
+ EXTRACTOR_METATYPE_IMAGE_DIMENSIONS,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ format,
+ strlen (format) + 1))
+ goto CLEANUP;
+ if (0 !=
+ ec->proc (ec->cls,
+ "tiff",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "image/tiff",
+ strlen ("image/tiff") + 1))
+ goto CLEANUP;
+ }
+
+CLEANUP:
TIFFClose (tiff);
}
+
/* end of tiff_extractor.c */
diff --git a/src/plugins/wav_extractor.c b/src/plugins/wav_extractor.c
@@ -49,9 +49,11 @@ little_endian_to_host32 (uint32_t in)
{
unsigned char *ptr = (unsigned char *) ∈
- return ((ptr[3] & 0xFF) << 24) | ((ptr[2] & 0xFF) << 16) |
- ((ptr[1] & 0xFF) << 8) | (ptr[0] & 0xFF);
+ return ((ptr[3] & 0xFF) << 24) | ((ptr[2] & 0xFF) << 16)
+ | ((ptr[1] & 0xFF) << 8) | (ptr[0] & 0xFF);
}
+
+
#endif
@@ -85,11 +87,12 @@ EXTRACTOR_wav_extract_method (struct EXTRACTOR_ExtractContext *ec)
ec->read (ec->cls, &data, 44))
return;
buf = data;
- if ((buf[0] != 'R' || buf[1] != 'I' ||
- buf[2] != 'F' || buf[3] != 'F' ||
- buf[8] != 'W' || buf[9] != 'A' ||
- buf[10] != 'V' || buf[11] != 'E' ||
- buf[12] != 'f' || buf[13] != 'm' || buf[14] != 't' || buf[15] != ' '))
+ if (((buf[0] != 'R') || (buf[1] != 'I') ||
+ (buf[2] != 'F') || (buf[3] != 'F') ||
+ (buf[8] != 'W') || (buf[9] != 'A') ||
+ (buf[10] != 'V') || (buf[11] != 'E') ||
+ (buf[12] != 'f') || (buf[13] != 'm') || (buf[14] != 't') || (buf[15] !=
+ ' ') ))
return; /* not a WAV file */
channels = *((uint16_t *) &buf[22]);
@@ -119,23 +122,24 @@ EXTRACTOR_wav_extract_method (struct EXTRACTOR_ExtractContext *ec)
(samples < sample_rate)
? (samples * 1000 / sample_rate)
: (samples / sample_rate) * 1000,
- sample_rate, (1 == channels) ? _("mono") : _("stereo"));
+ sample_rate, (1 == channels) ? _ ("mono") : _ ("stereo"));
if (0 != ec->proc (ec->cls,
- "wav",
- EXTRACTOR_METATYPE_RESOURCE_TYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- scratch,
- strlen (scratch) + 1))
+ "wav",
+ EXTRACTOR_METATYPE_RESOURCE_TYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ scratch,
+ strlen (scratch) + 1))
return;
if (0 != ec->proc (ec->cls,
- "wav",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "audio/x-wav",
- strlen ("audio/x-wav") +1 ))
+ "wav",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "audio/x-wav",
+ strlen ("audio/x-wav") + 1))
return;
}
+
/* end of wav_extractor.c */
diff --git a/src/plugins/xm_extractor.c b/src/plugins/xm_extractor.c
@@ -47,7 +47,11 @@ struct Header
* @param s utf-8 string meta data value
* @param t type of the meta data
*/
-#define ADD(s,t) do { if (0 != ec->proc (ec->cls, "xm", t, EXTRACTOR_METAFORMAT_UTF8, "text/plain", s, strlen (s) + 1)) return; } while (0)
+#define ADD(s,t) do { if (0 != ec->proc (ec->cls, "xm", t, \
+ EXTRACTOR_METAFORMAT_UTF8, \
+ "text/plain", s, strlen (s) \
+ + 1)) return; \
+} while (0)
/**
@@ -72,20 +76,20 @@ EXTRACTOR_xm_extract_method (struct EXTRACTOR_ExtractContext *ec)
if ((ssize_t) sizeof (struct Header) >
ec->read (ec->cls,
- &data,
- sizeof (struct Header)))
+ &data,
+ sizeof (struct Header)))
return;
head = data;
/* Check "magic" id bytes */
if (memcmp (head->magicid, "Extended Module: ", 17))
return;
- ADD("audio/x-xm", EXTRACTOR_METATYPE_MIMETYPE);
+ ADD ("audio/x-xm", EXTRACTOR_METATYPE_MIMETYPE);
/* Version of Tracker */
snprintf (xmversion,
- sizeof (xmversion),
- "%u.%u",
- head->version[1],
- head->version[0]);
+ sizeof (xmversion),
+ "%u.%u",
+ head->version[1],
+ head->version[0]);
ADD (xmversion, EXTRACTOR_METATYPE_FORMAT_VERSION);
/* Song title */
memcpy (&title, head->title, 20);
@@ -104,4 +108,5 @@ EXTRACTOR_xm_extract_method (struct EXTRACTOR_ExtractContext *ec)
return;
}
+
/* end of xm_extractor.c */
diff --git a/src/plugins/zip_extractor.c b/src/plugins/zip_extractor.c
@@ -44,86 +44,87 @@ EXTRACTOR_zip_extract_method (struct EXTRACTOR_ExtractContext *ec)
if (NULL == (uf = EXTRACTOR_common_unzip_open (ec)))
return;
if ( (EXTRACTOR_UNZIP_OK ==
- EXTRACTOR_common_unzip_go_find_local_file (uf,
- "meta.xml",
- 2)) ||
+ EXTRACTOR_common_unzip_go_find_local_file (uf,
+ "meta.xml",
+ 2)) ||
(EXTRACTOR_UNZIP_OK ==
- EXTRACTOR_common_unzip_go_find_local_file (uf,
- "META-INF/MANIFEST.MF",
- 2)) )
- {
- /* not a normal zip, might be odf, jar, etc. */
- goto CLEANUP;
- }
+ EXTRACTOR_common_unzip_go_find_local_file (uf,
+ "META-INF/MANIFEST.MF",
+ 2)) )
+ {
+ /* not a normal zip, might be odf, jar, etc. */
+ goto CLEANUP;
+ }
if (EXTRACTOR_UNZIP_OK !=
EXTRACTOR_common_unzip_go_to_first_file (uf))
- {
- /* zip malformed? */
- goto CLEANUP;
- }
+ {
+ /* zip malformed? */
+ goto CLEANUP;
+ }
if (0 !=
ec->proc (ec->cls,
- "zip",
- EXTRACTOR_METATYPE_MIMETYPE,
- EXTRACTOR_METAFORMAT_UTF8,
- "text/plain",
- "application/zip",
- strlen ("application/zip") + 1))
+ "zip",
+ EXTRACTOR_METATYPE_MIMETYPE,
+ EXTRACTOR_METAFORMAT_UTF8,
+ "text/plain",
+ "application/zip",
+ strlen ("application/zip") + 1))
goto CLEANUP;
if (EXTRACTOR_UNZIP_OK ==
EXTRACTOR_common_unzip_get_global_comment (uf,
- fcomment,
- sizeof (fcomment)))
- {
- if ( (0 != strlen (fcomment)) &&
- (0 !=
- ec->proc (ec->cls,
- "zip",
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- fcomment,
- strlen (fcomment) + 1)))
- goto CLEANUP;
- }
+ fcomment,
+ sizeof (fcomment)))
+ {
+ if ( (0 != strlen (fcomment)) &&
+ (0 !=
+ ec->proc (ec->cls,
+ "zip",
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ fcomment,
+ strlen (fcomment) + 1)))
+ goto CLEANUP;
+ }
do
+ {
+ if (EXTRACTOR_UNZIP_OK ==
+ EXTRACTOR_common_unzip_get_current_file_info (uf,
+ &fi,
+ fname,
+ sizeof (fname),
+ NULL, 0,
+ fcomment,
+ sizeof (fcomment)))
{
- if (EXTRACTOR_UNZIP_OK ==
- EXTRACTOR_common_unzip_get_current_file_info (uf,
- &fi,
- fname,
- sizeof (fname),
- NULL, 0,
- fcomment,
- sizeof (fcomment)))
- {
- if ( (0 != strlen (fname)) &&
- (0 !=
- ec->proc (ec->cls,
- "zip",
- EXTRACTOR_METATYPE_FILENAME,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- fname,
- strlen (fname) + 1)))
- goto CLEANUP;
- if ( (0 != strlen (fcomment)) &&
- (0 !=
- ec->proc (ec->cls,
- "zip",
- EXTRACTOR_METATYPE_COMMENT,
- EXTRACTOR_METAFORMAT_C_STRING,
- "text/plain",
- fcomment,
- strlen (fcomment) + 1)))
- goto CLEANUP;
- }
+ if ( (0 != strlen (fname)) &&
+ (0 !=
+ ec->proc (ec->cls,
+ "zip",
+ EXTRACTOR_METATYPE_FILENAME,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ fname,
+ strlen (fname) + 1)))
+ goto CLEANUP;
+ if ( (0 != strlen (fcomment)) &&
+ (0 !=
+ ec->proc (ec->cls,
+ "zip",
+ EXTRACTOR_METATYPE_COMMENT,
+ EXTRACTOR_METAFORMAT_C_STRING,
+ "text/plain",
+ fcomment,
+ strlen (fcomment) + 1)))
+ goto CLEANUP;
}
+ }
while (EXTRACTOR_UNZIP_OK ==
- EXTRACTOR_common_unzip_go_to_next_file (uf));
+ EXTRACTOR_common_unzip_go_to_next_file (uf));
CLEANUP:
(void) EXTRACTOR_common_unzip_close (uf);
}
+
/* end of zip_extractor.c */