summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-03-03 12:55:36 +0100
committerChristian Grothoff <christian@grothoff.org>2020-03-03 12:55:36 +0100
commitf22abb4d1339fe55f5c10545de4b80fe3ac6aebe (patch)
treead9ebbbeb6584d64310088b9769704f048f9daa4
parent0f3f4f01cce39f83f029caa4c285035c409c0ced (diff)
uncrustifying indentation
-rwxr-xr-xbootstrap36
-rw-r--r--contrib/uncrustify.cfg95
-rwxr-xr-xcontrib/uncrustify.sh14
-rwxr-xr-xcontrib/uncrustify_precommit35
-rw-r--r--src/common/convert.c43
-rw-r--r--src/common/convert.h8
-rw-r--r--src/common/le_architecture.h8
-rw-r--r--src/common/unzip.c671
-rw-r--r--src/common/unzip.h137
-rw-r--r--src/include/extractor.h686
-rw-r--r--src/include/gettext.h6
-rw-r--r--src/include/platform.h11
-rw-r--r--src/include/plibc.h1138
-rw-r--r--src/intlemu/intlemu.c251
-rw-r--r--src/intlemu/libintlemu.h6
-rw-r--r--src/main/extract.c1015
-rw-r--r--src/main/extractor.c532
-rw-r--r--src/main/extractor_common.c49
-rw-r--r--src/main/extractor_common.h10
-rw-r--r--src/main/extractor_datasource.c1083
-rw-r--r--src/main/extractor_datasource.h28
-rw-r--r--src/main/extractor_ipc.c157
-rw-r--r--src/main/extractor_ipc.h57
-rw-r--r--src/main/extractor_ipc_gnu.c389
-rw-r--r--src/main/extractor_ipc_w32.c223
-rw-r--r--src/main/extractor_logging.c11
-rw-r--r--src/main/extractor_logging.h14
-rw-r--r--src/main/extractor_metatypes.c278
-rw-r--r--src/main/extractor_plugin_main.c524
-rw-r--r--src/main/extractor_plugin_main.h4
-rw-r--r--src/main/extractor_plugins.c313
-rw-r--r--src/main/extractor_plugins.h2
-rw-r--r--src/main/extractor_plugpath.c445
-rw-r--r--src/main/extractor_plugpath.h4
-rw-r--r--src/main/extractor_print.c75
-rw-r--r--src/main/getopt.c1139
-rw-r--r--src/main/getopt.h31
-rw-r--r--src/main/getopt1.c175
-rw-r--r--src/main/iconv.c27
-rw-r--r--src/main/test2_extractor.c122
-rw-r--r--src/main/test_bzip2.c120
-rw-r--r--src/main/test_extractor.c146
-rw-r--r--src/main/test_file.c120
-rw-r--r--src/main/test_gzip.c124
-rw-r--r--src/main/test_ipc.c134
-rw-r--r--src/main/test_plugin_load_multi.c27
-rw-r--r--src/main/test_plugin_loading.c33
-rw-r--r--src/main/test_trivial.c22
-rw-r--r--src/plugins/archive_extractor.c68
-rw-r--r--src/plugins/deb_extractor.c284
-rw-r--r--src/plugins/dvi_extractor.c205
-rw-r--r--src/plugins/flac_extractor.c349
-rw-r--r--src/plugins/gif_extractor.c98
-rw-r--r--src/plugins/gstreamer_extractor.c611
-rw-r--r--src/plugins/html_extractor.c652
-rw-r--r--src/plugins/it_extractor.c49
-rw-r--r--src/plugins/jpeg_extractor.c104
-rw-r--r--src/plugins/man_extractor.c216
-rw-r--r--src/plugins/midi_extractor.c216
-rw-r--r--src/plugins/mime_extractor.c83
-rw-r--r--src/plugins/mp4_extractor.c69
-rw-r--r--src/plugins/mpeg_extractor.c253
-rw-r--r--src/plugins/nsf_extractor.c44
-rw-r--r--src/plugins/nsfe_extractor.c1
-rw-r--r--src/plugins/odf_extractor.c349
-rw-r--r--src/plugins/ogg_extractor.c33
-rw-r--r--src/plugins/old/applefile_extractor.c267
-rw-r--r--src/plugins/old/asf_extractor.c440
-rw-r--r--src/plugins/old/convert_numeric.c423
-rw-r--r--src/plugins/old/convert_numeric.h42
-rw-r--r--src/plugins/old/ebml_extractor.c509
-rw-r--r--src/plugins/old/elf_extractor.c585
-rw-r--r--src/plugins/old/flv_extractor.c878
-rw-r--r--src/plugins/old/mkv_extractor.c144
-rw-r--r--src/plugins/old/mp3_extractor.c110
-rw-r--r--src/plugins/old/pack.c538
-rw-r--r--src/plugins/old/pack.h14
-rw-r--r--src/plugins/old/qt_extractor.c272
-rw-r--r--src/plugins/old/real_extractor.c421
-rw-r--r--src/plugins/ole2_extractor.c814
-rw-r--r--src/plugins/pdf_extractor.c181
-rw-r--r--src/plugins/png_extractor.c225
-rw-r--r--src/plugins/previewopus_extractor.c1235
-rw-r--r--src/plugins/ps_extractor.c129
-rw-r--r--src/plugins/riff_extractor.c39
-rw-r--r--src/plugins/rpm_extractor.c383
-rw-r--r--src/plugins/s3m_extractor.c11
-rw-r--r--src/plugins/sid_extractor.c30
-rw-r--r--src/plugins/template_extractor.c5
-rw-r--r--src/plugins/test_archive.c63
-rw-r--r--src/plugins/test_deb.c259
-rw-r--r--src/plugins/test_dvi.c165
-rw-r--r--src/plugins/test_exiv2.c597
-rw-r--r--src/plugins/test_flac.c59
-rw-r--r--src/plugins/test_gif.c64
-rw-r--r--src/plugins/test_gstreamer.c3088
-rw-r--r--src/plugins/test_html.c159
-rw-r--r--src/plugins/test_it.c63
-rw-r--r--src/plugins/test_jpeg.c64
-rw-r--r--src/plugins/test_lib.c141
-rw-r--r--src/plugins/test_lib.h8
-rw-r--r--src/plugins/test_man.c80
-rw-r--r--src/plugins/test_midi.c95
-rw-r--r--src/plugins/test_mime.c117
-rw-r--r--src/plugins/test_mpeg.c137
-rw-r--r--src/plugins/test_nsf.c144
-rw-r--r--src/plugins/test_nsfe.c176
-rw-r--r--src/plugins/test_odf.c112
-rw-r--r--src/plugins/test_ogg.c96
-rw-r--r--src/plugins/test_ole2.c907
-rw-r--r--src/plugins/test_png.c79
-rw-r--r--src/plugins/test_previewopus.c22
-rw-r--r--src/plugins/test_ps.c189
-rw-r--r--src/plugins/test_riff.c64
-rw-r--r--src/plugins/test_rpm.c542
-rw-r--r--src/plugins/test_s3m.c48
-rw-r--r--src/plugins/test_sid.c159
-rw-r--r--src/plugins/test_thumbnailffmpeg.c20
-rw-r--r--src/plugins/test_thumbnailgtk.c48
-rw-r--r--src/plugins/test_tiff.c152
-rw-r--r--src/plugins/test_wav.c89
-rw-r--r--src/plugins/test_xm.c80
-rw-r--r--src/plugins/test_zip.c127
-rw-r--r--src/plugins/thumbnailffmpeg_extractor.c705
-rw-r--r--src/plugins/thumbnailgtk_extractor.c155
-rw-r--r--src/plugins/tiff_extractor.c123
-rw-r--r--src/plugins/wav_extractor.c44
-rw-r--r--src/plugins/xm_extractor.c21
-rw-r--r--src/plugins/zip_extractor.c131
129 files changed, 16203 insertions, 15146 deletions
diff --git a/bootstrap b/bootstrap
index 60e0203..7e15079 100755
--- 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
new file mode 100644
index 0000000..8c9df2c
--- /dev/null
+++ 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
new file mode 100755
index 0000000..e8e05d3
--- /dev/null
+++ 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
new file mode 100755
index 0000000..fd29998
--- /dev/null
+++ 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
index 2be2108..a8a6b9d 100644
--- 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
index 9e1bf52..0600cbb 100644
--- 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
index b863ddb..fb5044b 100644
--- 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
index 46683f0..a469a5b 100644
--- 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
index 55e7bb6..9812ad8 100644
--- 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
index 3e86868..3e6c098 100644
--- 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
index 774965b..98e6784 100644
--- 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
index 060ab5b..9f72f57 100644
--- 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
index c8b6453..9199072 100644
--- 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
index a8461b7..eaa9252 100644
--- 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
index 6118a66..27a295e 100644
--- 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
index 2492fa9..144f2c3 100644
--- 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
index 3755da9..cb64b95 100644
--- 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
index 866609e..59524b3 100644
--- 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
index 14b1c7f..5887c05 100644
--- 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
index 888e524..0b18d7c 100644
--- 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
index f25cc4b..dc548a6 100644
--- 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
index 47d9d4d..b343bd6 100644
--- 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
index 0109b66..8e7fe09 100644
--- 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
index 7bb8914..5400636 100644
--- 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
index c4fbf1b..b53bc3c 100644
--- 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
index b1518ae..17192fe 100644
--- 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
index 5db9ae1..535a9a7 100644
--- 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
index 41d1061..277a39f 100644
--- 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
index 7b01140..fd4912f 100644
--- 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
index 1b33c8c..a683768 100644
--- 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
index 0fa10d6..1ab777b 100644
--- 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
index 958ad94..8b0f5e6 100644
--- 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
index 461f25e..4374bc5 100644
--- 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
index 848be52..3a3b217 100644
--- 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
index 3530430..a89b522 100644
--- 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
index b64fdf5..890aa9b 100644
--- 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
index d50c90e..89fd8eb 100644
--- 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
index 6409986..d089fd4 100644
--- 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
index 3f95d44..7daa017 100644
--- 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
index 4d55dc3..a2c1d53 100644
--- 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
index 37c9aed..598e913 100644
--- 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
index 8c15fca..dd1376f 100644
--- 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
index 52803c9..a2d6a5e 100644
--- 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
index 87a61cb..071c74c 100644
--- 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
index 5e118fd..4da3ef5 100644
--- 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
index b7958f2..6b30390 100644
--- 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
index ddcfb92..537b703 100644
--- 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
index fac9a91..b0860b4 100644
--- 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
index 7a80ac5..6d413de 100644
--- 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
index 2eb0028..16c6285 100644
--- 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
index e3aa450..4e52150 100644
--- 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
index 7f04df3..2d36c56 100644
--- 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
index 8ee5807..405eebe 100644
--- 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
index 31568a7..87f0153 100644
--- 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
index 8cd4aba..5ebf97b 100644
--- 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
index 3d8803f..336392f 100644
--- 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
index d6c1f6f..24812bd 100644
--- 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
index b92fc9e..86ba68d 100644
--- 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
index 4ceff6a..66ea71d 100644
--- 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",