[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r7916 - in Extractor: . doc src src/common src/plugins src/
From: |
gnunet |
Subject: |
[GNUnet-SVN] r7916 - in Extractor: . doc src src/common src/plugins src/plugins/ole2 src/plugins/pdf |
Date: |
Sun, 16 Nov 2008 05:22:53 -0700 (MST) |
Author: durner
Date: 2008-11-16 05:22:53 -0700 (Sun, 16 Nov 2008)
New Revision: 7916
Added:
Extractor/src/common/Makefile.am
Extractor/src/common/convert.c
Extractor/src/common/convert.h
Extractor/src/common/convert_numeric.c
Extractor/src/common/convert_numeric.h
Extractor/src/common/pack.c
Extractor/src/common/pack.h
Removed:
Extractor/src/plugins/convert.c
Extractor/src/plugins/convert.h
Extractor/src/plugins/convert_numeric.c
Extractor/src/plugins/convert_numeric.h
Extractor/src/plugins/pack.c
Extractor/src/plugins/pack.h
Modified:
Extractor/configure.ac
Extractor/doc/extractor.texi
Extractor/src/Makefile.am
Extractor/src/plugins/Makefile-plugins.am
Extractor/src/plugins/Makefile.am
Extractor/src/plugins/applefileextractor.c
Extractor/src/plugins/elfextractor.c
Extractor/src/plugins/filenameextractor.c
Extractor/src/plugins/flvextractor.c
Extractor/src/plugins/gifextractor.c
Extractor/src/plugins/htmlextractor.c
Extractor/src/plugins/id3v23extractor.c
Extractor/src/plugins/id3v24extractor.c
Extractor/src/plugins/id3v2extractor.c
Extractor/src/plugins/mp3extractor.c
Extractor/src/plugins/ole2/ole2extractor.c
Extractor/src/plugins/pdf/pdfextractor.cc
Extractor/src/plugins/pdfextractor.c
Extractor/src/plugins/pngextractor.c
Extractor/src/plugins/tiffextractor.c
Log:
move source from libpack and libconvert to new dynamic library
libextractor_common
Modified: Extractor/configure.ac
===================================================================
--- Extractor/configure.ac 2008-11-16 09:48:46 UTC (rev 7915)
+++ Extractor/configure.ac 2008-11-16 12:22:53 UTC (rev 7916)
@@ -527,6 +527,7 @@
doc/Makefile
src/Makefile
src/include/Makefile
+src/common/Makefile
src/main/Makefile
src/plugins/Makefile
src/plugins/ole2/Makefile
Modified: Extractor/doc/extractor.texi
===================================================================
--- Extractor/doc/extractor.texi 2008-11-16 09:48:46 UTC (rev 7915)
+++ Extractor/doc/extractor.texi 2008-11-16 12:22:53 UTC (rev 7916)
@@ -648,10 +648,10 @@
@cindex UTF-8
@cindex character set
address@hidden convertToUtf8
address@hidden EXTRACTOR_common_convert_to_utf8
Various @acronym{libextractor} plugins make use of the internal
@file{convert.h} header which defines a function
address@hidden|convertToUtf8|} which can be used to easily convert text from
address@hidden|EXTRACTOR_common_convert_to_utf8|} which can be used to easily
convert text from
any character set to UTF-8. This conversion is important since the
linked list of keywords that is returned by @acronym{libextractor} is
expected to contain only UTF-8 strings. Naturally, proper conversion
@@ -659,12 +659,12 @@
character set. In that case, it is often better to not convert at
all.
-The arguments to @verb{|convertToUtf8|} are the input string (which
+The arguments to @verb{|EXTRACTOR_common_convert_to_utf8|} are the input
string (which
does @emph{not} have to be zero-terminated), the length of the input
string, and the character set (which @emph{must} be zero-terminated).
Which character sets are supported depends on the platform, a list can
generally be obtained using the @command{iconv -l} command. The
-return value from @verb{|convertToUtf8|} is a zero-terminated string
+return value from @verb{|EXTRACTOR_common_convert_to_utf8|} is a
zero-terminated string
in UTF-8 format. The responsibility to free the string is with the
caller, so storing the string in the keyword list is acceptable.
Modified: Extractor/src/Makefile.am
===================================================================
--- Extractor/src/Makefile.am 2008-11-16 09:48:46 UTC (rev 7915)
+++ Extractor/src/Makefile.am 2008-11-16 12:22:53 UTC (rev 7916)
@@ -1,3 +1,3 @@
INCLUDES = -I$(top_srcdir)/src/include
-SUBDIRS = include main plugins test .
+SUBDIRS = include main common plugins test .
Added: Extractor/src/common/Makefile.am
===================================================================
--- Extractor/src/common/Makefile.am (rev 0)
+++ Extractor/src/common/Makefile.am 2008-11-16 12:22:53 UTC (rev 7916)
@@ -0,0 +1,30 @@
+INCLUDES = -I$(top_srcdir)/src/include $(LTDLINCL)
+
+LIBS = \
+ @LTLIBINTL@ @LIBS@
+
+lib_LTLIBRARIES = \
+ libextractor_common.la
+
+if !MINGW
+ exportflag=-export-symbols-regex "EXTRACTOR_.*"
+if !SOMEBSD
+ dlflag=-ldl
+endif
+else
+ winexportflag=-export-dynamic
+endif
+
+libextractor_common_la_LDFLAGS = \
+ $(exportflag) $(winexportflag) -version-info
@LIB_VERSION_CURRENT@:@LIB_VERSION_REVISION@:@LIB_VERSION_AGE@ $(LIBICONV)
+
+libextractor_common_la_LIBADD = \
+ $(LIBLTDL) $(dlflag)
+
+libextractor_common_la_SOURCES = \
+ pack.c \
+ pack.h \
+ convert.c \
+ convert.h \
+ convert_numeric.c \
+ convert_numeric.h
Copied: Extractor/src/common/convert.c (from rev 7875,
Extractor/src/plugins/convert.c)
===================================================================
--- Extractor/src/common/convert.c (rev 0)
+++ Extractor/src/common/convert.c 2008-11-16 12:22:53 UTC (rev 7916)
@@ -0,0 +1,66 @@
+/*
+ This file is part of libextractor.
+ (C) 2004 Vidyut Samanta and Christian Grothoff
+
+ libextractor is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ libextractor 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
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with libextractor; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+ */
+
+#include "platform.h"
+#include "extractor.h"
+#include "convert.h"
+
+/**
+ * Convert the len characters long character sequence
+ * given in input that is in the given charset
+ * to UTF-8.
+ * @return the converted string (0-terminated),
+ * if conversion fails, a copy of the orignal
+ * string is returned.
+ */
+char *
+EXTRACTOR_common_convert_to_utf8 (const char *input, size_t len, const char
*charset)
+{
+ size_t tmpSize;
+ size_t finSize;
+ char *tmp;
+ char *ret;
+ char *itmp;
+ const char *i;
+ iconv_t cd;
+
+ i = input;
+ cd = iconv_open ("UTF-8", charset);
+ if (cd == (iconv_t) - 1)
+ return strdup (i);
+ tmpSize = 3 * len + 4;
+ tmp = malloc (tmpSize);
+ itmp = tmp;
+ finSize = tmpSize;
+ if (iconv (cd, (char **) &input, &len, &itmp, &finSize) == (size_t) - 1)
+ {
+ iconv_close (cd);
+ free (tmp);
+ return strdup (i);
+ }
+ ret = malloc (tmpSize - finSize + 1);
+ memcpy (ret, tmp, tmpSize - finSize);
+ ret[tmpSize - finSize] = '\0';
+ free (tmp);
+ iconv_close (cd);
+ return ret;
+}
+
+/* end of convert.c */
Property changes on: Extractor/src/common/convert.c
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: Extractor/src/common/convert.h (from rev 7875,
Extractor/src/plugins/convert.h)
===================================================================
--- Extractor/src/common/convert.h (rev 0)
+++ Extractor/src/common/convert.h 2008-11-16 12:22:53 UTC (rev 7916)
@@ -0,0 +1,46 @@
+/*
+ This file is part of libextractor.
+ (C) 2004 Vidyut Samanta and Christian Grothoff
+
+ libextractor is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published
+ by the Free Software Foundation; either version 2, or (at your
+ option) any later version.
+
+ libextractor 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
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with libextractor; see the file COPYING. If not, write to the
+ Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ Boston, MA 02111-1307, USA.
+ */
+
+#ifndef CONVERT_H
+#define CONVERT_H
+
+#include "platform.h"
+#include "extractor.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/**
+ * Convert the len characters long character sequence
+ * given in input that is in the given charset
+ * to UTF-8.
+ * @return the converted string (0-terminated)
+ */
+char * EXTRACTOR_common_convert_to_utf8(const char * input,
+ size_t len,
+ const char * charset);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
Property changes on: Extractor/src/common/convert.h
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: Extractor/src/common/convert_numeric.c (from rev 7875,
Extractor/src/plugins/convert_numeric.c)
===================================================================
--- Extractor/src/common/convert_numeric.c (rev 0)
+++ Extractor/src/common/convert_numeric.c 2008-11-16 12:22:53 UTC (rev
7916)
@@ -0,0 +1,631 @@
+/* IEEE floating point support routines, for GDB, the GNU Debugger.
+ Copyright 1991, 1994, 1999, 2000, 2003, 2005, 2006
+ Free Software Foundation, Inc.
+
+This file is part of GDB.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
USA. */
+
+/* This is needed to pick up the NAN macro on some systems. */
+/* #define _GNU_SOURCE */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <math.h>
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+/* On some platforms, <float.h> provides DBL_QNAN. */
+#ifdef STDC_HEADERS
+#include <float.h>
+#endif
+
+/*#include "ansidecl.h"*/
+/*#include "libiberty.h"*/
+#include "convert_numeric.h"
+
+#ifndef INFINITY
+#ifdef HUGE_VAL
+#define INFINITY HUGE_VAL
+#else
+#define INFINITY (1.0 / 0.0)
+#endif
+#endif
+
+#ifndef NAN
+#ifdef DBL_QNAN
+#define NAN DBL_QNAN
+#else
+#define NAN (0.0 / 0.0)
+#endif
+#endif
+
+static unsigned long get_field (const unsigned char *,
+ enum EXTRACTOR_floatformat_byteorders,
+ unsigned int,
+ unsigned int,
+ unsigned int);
+static int floatformat_always_valid (const struct EXTRACTOR_floatformat *fmt,
+ const void *from);
+
+static int
+floatformat_always_valid (const struct EXTRACTOR_floatformat *fmt
/*ATTRIBUTE_UNUSED*/,
+ const void *from /*ATTRIBUTE_UNUSED*/)
+{
+ return 1;
+}
+
+/* The odds that CHAR_BIT will be anything but 8 are low enough that I'm not
+ going to bother with trying to muck around with whether it is defined in
+ a system header, what we do if not, etc. */
+#define FLOATFORMAT_CHAR_BIT 8
+
+/* floatformats for IEEE single and double, big and little endian. */
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_single_big =
+{
+ floatformat_big, 32, 0, 1, 8, 127, 255, 9, 23,
+ floatformat_intbit_no,
+ "floatformat_ieee_single_big",
+ floatformat_always_valid
+};
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_single_little =
+{
+ floatformat_little, 32, 0, 1, 8, 127, 255, 9, 23,
+ floatformat_intbit_no,
+ "floatformat_ieee_single_little",
+ floatformat_always_valid
+};
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_big =
+{
+ floatformat_big, 64, 0, 1, 11, 1023, 2047, 12, 52,
+ floatformat_intbit_no,
+ "floatformat_ieee_double_big",
+ floatformat_always_valid
+};
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ieee_double_little =
+{
+ floatformat_little, 64, 0, 1, 11, 1023, 2047, 12, 52,
+ floatformat_intbit_no,
+ "floatformat_ieee_double_little",
+ floatformat_always_valid
+};
+
+/* floatformat for IEEE double, little endian byte order, with big endian word
+ ordering, as on the ARM. */
+
+const struct EXTRACTOR_floatformat
EXTRACTOR_floatformat_ieee_double_littlebyte_bigword =
+{
+ floatformat_littlebyte_bigword, 64, 0, 1, 11, 1023, 2047, 12, 52,
+ floatformat_intbit_no,
+ "floatformat_ieee_double_littlebyte_bigword",
+ floatformat_always_valid
+};
+
+/* floatformat for VAX. Not quite IEEE, but close enough. */
+
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_vax_f =
+{
+ floatformat_vax, 32, 0, 1, 8, 129, 0, 9, 23,
+ floatformat_intbit_no,
+ "floatformat_vax_f",
+ floatformat_always_valid
+};
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_vax_d =
+{
+ floatformat_vax, 64, 0, 1, 8, 129, 0, 9, 55,
+ floatformat_intbit_no,
+ "floatformat_vax_d",
+ floatformat_always_valid
+};
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_vax_g =
+{
+ floatformat_vax, 64, 0, 1, 11, 1025, 0, 12, 52,
+ floatformat_intbit_no,
+ "floatformat_vax_g",
+ floatformat_always_valid
+};
+
+static int floatformat_i387_ext_is_valid (const struct EXTRACTOR_floatformat
*fmt,
+ const void *from);
+
+static int
+floatformat_i387_ext_is_valid (const struct EXTRACTOR_floatformat *fmt, const
void *from)
+{
+ /* In the i387 double-extended format, if the exponent is all ones,
+ then the integer bit must be set. If the exponent is neither 0
+ nor ~0, the intbit must also be set. Only if the exponent is
+ zero can it be zero, and then it must be zero. */
+ unsigned long exponent, int_bit;
+ const unsigned char *ufrom = (const unsigned char *) from;
+
+ exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize,
+ fmt->exp_start, fmt->exp_len);
+ int_bit = get_field (ufrom, fmt->byteorder, fmt->totalsize,
+ fmt->man_start, 1);
+
+ if ((exponent == 0) != (int_bit == 0))
+ return 0;
+ else
+ return 1;
+}
+
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_i387_ext =
+{
+ floatformat_little, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,
+ floatformat_intbit_yes,
+ "floatformat_i387_ext",
+ floatformat_i387_ext_is_valid
+};
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m68881_ext =
+{
+ /* Note that the bits from 16 to 31 are unused. */
+ floatformat_big, 96, 0, 1, 15, 0x3fff, 0x7fff, 32, 64,
+ floatformat_intbit_yes,
+ "floatformat_m68881_ext",
+ floatformat_always_valid
+};
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_i960_ext =
+{
+ /* Note that the bits from 0 to 15 are unused. */
+ floatformat_little, 96, 16, 17, 15, 0x3fff, 0x7fff, 32, 64,
+ floatformat_intbit_yes,
+ "floatformat_i960_ext",
+ floatformat_always_valid
+};
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m88110_ext =
+{
+ floatformat_big, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,
+ floatformat_intbit_yes,
+ "floatformat_m88110_ext",
+ floatformat_always_valid
+};
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m88110_harris_ext =
+{
+ /* Harris uses raw format 128 bytes long, but the number is just an ieee
+ double, and the last 64 bits are wasted. */
+ floatformat_big,128, 0, 1, 11, 0x3ff, 0x7ff, 12, 52,
+ floatformat_intbit_no,
+ "floatformat_m88110_ext_harris",
+ floatformat_always_valid
+};
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_arm_ext_big =
+{
+ /* Bits 1 to 16 are unused. */
+ floatformat_big, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64,
+ floatformat_intbit_yes,
+ "floatformat_arm_ext_big",
+ floatformat_always_valid
+};
+const struct EXTRACTOR_floatformat
EXTRACTOR_floatformat_arm_ext_littlebyte_bigword =
+{
+ /* Bits 1 to 16 are unused. */
+ floatformat_littlebyte_bigword, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64,
+ floatformat_intbit_yes,
+ "floatformat_arm_ext_littlebyte_bigword",
+ floatformat_always_valid
+};
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_spill_big =
+{
+ floatformat_big, 128, 0, 1, 17, 65535, 0x1ffff, 18, 64,
+ floatformat_intbit_yes,
+ "floatformat_ia64_spill_big",
+ floatformat_always_valid
+};
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_spill_little =
+{
+ floatformat_little, 128, 0, 1, 17, 65535, 0x1ffff, 18, 64,
+ floatformat_intbit_yes,
+ "floatformat_ia64_spill_little",
+ floatformat_always_valid
+};
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_quad_big =
+{
+ floatformat_big, 128, 0, 1, 15, 16383, 0x7fff, 16, 112,
+ floatformat_intbit_no,
+ "floatformat_ia64_quad_big",
+ floatformat_always_valid
+};
+const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_quad_little =
+{
+ floatformat_little, 128, 0, 1, 15, 16383, 0x7fff, 16, 112,
+ floatformat_intbit_no,
+ "floatformat_ia64_quad_little",
+ floatformat_always_valid
+};
+
+
+#ifndef min
+#define min(a, b) ((a) < (b) ? (a) : (b))
+#endif
+
+/* Extract a field which starts at START and is LEN bits long. DATA and
+ TOTAL_LEN are the thing we are extracting it from, in byteorder ORDER. */
+static unsigned long
+get_field (const unsigned char *data, enum EXTRACTOR_floatformat_byteorders
order,
+ unsigned int total_len, unsigned int start, unsigned int len)
+{
+ unsigned long result = 0;
+ unsigned int cur_byte;
+ int lo_bit, hi_bit, cur_bitshift = 0;
+ int nextbyte = (order == floatformat_little) ? 1 : -1;
+
+ /* Start is in big-endian bit order! Fix that first. */
+ start = total_len - (start + len);
+
+ /* Start at the least significant part of the field. */
+ if (order == floatformat_little)
+ cur_byte = start / FLOATFORMAT_CHAR_BIT;
+ else
+ cur_byte = (total_len - start - 1) / FLOATFORMAT_CHAR_BIT;
+
+ lo_bit = start % FLOATFORMAT_CHAR_BIT;
+ hi_bit = min (lo_bit + len, FLOATFORMAT_CHAR_BIT);
+
+ do
+ {
+ unsigned int shifted = *(data + cur_byte) >> lo_bit;
+ unsigned int bits = hi_bit - lo_bit;
+ unsigned int mask = (1 << bits) - 1;
+ result |= (shifted & mask) << cur_bitshift;
+ len -= bits;
+ cur_bitshift += bits;
+ cur_byte += nextbyte;
+ lo_bit = 0;
+ hi_bit = min (len, FLOATFORMAT_CHAR_BIT);
+ }
+ while (len != 0);
+
+ return result;
+}
+
+/* Convert from FMT to a double.
+ FROM is the address of the extended float.
+ Store the double in *TO. */
+
+void
+EXTRACTOR_common_floatformat_to_double (const struct EXTRACTOR_floatformat
*fmt,
+ const void *from, double *to)
+{
+ const unsigned char *ufrom = (const unsigned char *) from;
+ double dto;
+ long exponent;
+ unsigned long mant;
+ unsigned int mant_bits, mant_off;
+ int mant_bits_left;
+ int special_exponent; /* It's a NaN, denorm or zero */
+
+ exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize,
+ fmt->exp_start, fmt->exp_len);
+
+ /* If the exponent indicates a NaN, we don't have information to
+ decide what to do. So we handle it like IEEE, except that we
+ don't try to preserve the type of NaN. FIXME. */
+ if ((unsigned long) exponent == fmt->exp_nan)
+ {
+ int nan;
+
+ mant_off = fmt->man_start;
+ mant_bits_left = fmt->man_len;
+ nan = 0;
+ while (mant_bits_left > 0)
+ {
+ mant_bits = min (mant_bits_left, 32);
+
+ if (get_field (ufrom, fmt->byteorder, fmt->totalsize,
+ mant_off, mant_bits) != 0)
+ {
+ /* This is a NaN. */
+ nan = 1;
+ break;
+ }
+
+ mant_off += mant_bits;
+ mant_bits_left -= mant_bits;
+ }
+
+ /* On certain systems (such as GNU/Linux), the use of the
+ INFINITY macro below may generate a warning that can not be
+ silenced due to a bug in GCC (PR preprocessor/11931). The
+ preprocessor fails to recognise the __extension__ keyword in
+ conjunction with the GNU/C99 extension for hexadecimal
+ floating point constants and will issue a warning when
+ compiling with -pedantic. */
+ if (nan)
+ dto = NAN;
+ else
+ dto = INFINITY;
+
+ if (get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->sign_start,
1))
+ dto = -dto;
+
+ *to = dto;
+
+ return;
+ }
+
+ mant_bits_left = fmt->man_len;
+ mant_off = fmt->man_start;
+ dto = 0.0;
+
+ special_exponent = exponent == 0 || (unsigned long) exponent == fmt->exp_nan;
+
+ /* Don't bias zero's, denorms or NaNs. */
+ if (!special_exponent)
+ exponent -= fmt->exp_bias;
+
+ /* Build the result algebraically. Might go infinite, underflow, etc;
+ who cares. */
+
+ /* If this format uses a hidden bit, explicitly add it in now. Otherwise,
+ increment the exponent by one to account for the integer bit. */
+
+ if (!special_exponent)
+ {
+ if (fmt->intbit == floatformat_intbit_no)
+ dto = ldexp (1.0, exponent);
+ else
+ exponent++;
+ }
+
+ while (mant_bits_left > 0)
+ {
+ mant_bits = min (mant_bits_left, 32);
+
+ mant = get_field (ufrom, fmt->byteorder, fmt->totalsize,
+ mant_off, mant_bits);
+
+ /* Handle denormalized numbers. FIXME: What should we do for
+ non-IEEE formats? */
+ if (special_exponent && exponent == 0 && mant != 0)
+ dto += ldexp ((double)mant,
+ (- fmt->exp_bias
+ - mant_bits
+ - (mant_off - fmt->man_start)
+ + 1));
+ else
+ dto += ldexp ((double)mant, exponent - mant_bits);
+ if (exponent != 0)
+ exponent -= mant_bits;
+ mant_off += mant_bits;
+ mant_bits_left -= mant_bits;
+ }
+
+ /* Negate it if negative. */
+ if (get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1))
+ dto = -dto;
+ *to = dto;
+}
+
+static void put_field (unsigned char *, enum EXTRACTOR_floatformat_byteorders,
+ unsigned int,
+ unsigned int,
+ unsigned int,
+ unsigned long);
+
+/* Set a field which starts at START and is LEN bits long. DATA and
+ TOTAL_LEN are the thing we are extracting it from, in byteorder ORDER. */
+static void
+put_field (unsigned char *data, enum EXTRACTOR_floatformat_byteorders order,
+ unsigned int total_len, unsigned int start, unsigned int len,
+ unsigned long stuff_to_put)
+{
+ unsigned int cur_byte;
+ int lo_bit, hi_bit;
+ int nextbyte = (order == floatformat_little) ? 1 : -1;
+
+ /* Start is in big-endian bit order! Fix that first. */
+ start = total_len - (start + len);
+
+ /* Start at the least significant part of the field. */
+ if (order == floatformat_little)
+ cur_byte = start / FLOATFORMAT_CHAR_BIT;
+ else
+ cur_byte = (total_len - start - 1) / FLOATFORMAT_CHAR_BIT;
+
+ lo_bit = start % FLOATFORMAT_CHAR_BIT;
+ hi_bit = min (lo_bit + len, FLOATFORMAT_CHAR_BIT);
+
+ do
+ {
+ unsigned char *byte_ptr = data + cur_byte;
+ unsigned int bits = hi_bit - lo_bit;
+ unsigned int mask = ((1 << bits) - 1) << lo_bit;
+ *byte_ptr = (*byte_ptr & ~mask) | ((stuff_to_put << lo_bit) & mask);
+ stuff_to_put >>= bits;
+ len -= bits;
+ cur_byte += nextbyte;
+ lo_bit = 0;
+ hi_bit = min (len, FLOATFORMAT_CHAR_BIT);
+ }
+ while (len != 0);
+}
+
+/* The converse: convert the double *FROM to an extended float
+ and store where TO points. Neither FROM nor TO have any alignment
+ restrictions. */
+
+void
+EXTRACTOR_common_floatformat_from_double (const struct EXTRACTOR_floatformat
*fmt,
+ const double *from, void *to)
+{
+ double dfrom;
+ int exponent;
+ double mant;
+ unsigned int mant_bits, mant_off;
+ int mant_bits_left;
+ unsigned char *uto = (unsigned char *) to;
+
+ dfrom = *from;
+ memset (uto, 0, fmt->totalsize / FLOATFORMAT_CHAR_BIT);
+
+ /* If negative, set the sign bit. */
+ if (dfrom < 0)
+ {
+ put_field (uto, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1, 1);
+ dfrom = -dfrom;
+ }
+
+ if (dfrom == 0)
+ {
+ /* 0.0. */
+ return;
+ }
+
+ if (dfrom != dfrom)
+ {
+ /* NaN. */
+ put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
+ fmt->exp_len, fmt->exp_nan);
+ /* Be sure it's not infinity, but NaN value is irrelevant. */
+ put_field (uto, fmt->byteorder, fmt->totalsize, fmt->man_start,
+ 32, 1);
+ return;
+ }
+
+ if (dfrom + dfrom == dfrom)
+ {
+ /* This can only happen for an infinite value (or zero, which we
+ already handled above). */
+ put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
+ fmt->exp_len, fmt->exp_nan);
+ return;
+ }
+
+ mant = frexp (dfrom, &exponent);
+ if (exponent + fmt->exp_bias - 1 > 0)
+ put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
+ fmt->exp_len, exponent + fmt->exp_bias - 1);
+ else
+ {
+ /* Handle a denormalized number. FIXME: What should we do for
+ non-IEEE formats? */
+ put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
+ fmt->exp_len, 0);
+ mant = ldexp (mant, exponent + fmt->exp_bias - 1);
+ }
+
+ mant_bits_left = fmt->man_len;
+ mant_off = fmt->man_start;
+ while (mant_bits_left > 0)
+ {
+ unsigned long mant_long;
+ mant_bits = mant_bits_left < 32 ? mant_bits_left : 32;
+
+ mant *= 4294967296.0;
+ mant_long = (unsigned long)mant;
+ mant -= mant_long;
+
+ /* If the integer bit is implicit, and we are not creating a
+ denormalized number, then we need to discard it. */
+ if ((unsigned int) mant_bits_left == fmt->man_len
+ && fmt->intbit == floatformat_intbit_no
+ && exponent + fmt->exp_bias - 1 > 0)
+ {
+ mant_long &= 0x7fffffff;
+ mant_bits -= 1;
+ }
+ else if (mant_bits < 32)
+ {
+ /* The bits we want are in the most significant MANT_BITS bits of
+ mant_long. Move them to the least significant. */
+ mant_long >>= 32 - mant_bits;
+ }
+
+ put_field (uto, fmt->byteorder, fmt->totalsize,
+ mant_off, mant_bits, mant_long);
+ mant_off += mant_bits;
+ mant_bits_left -= mant_bits;
+ }
+}
+
+/* Return non-zero iff the data at FROM is a valid number in format FMT. */
+
+int
+EXTRACTOR_common_floatformat_is_valid (const struct EXTRACTOR_floatformat
*fmt, const void *from)
+{
+ return fmt->is_valid (fmt, from);
+}
+
+
+#ifdef IEEE_DEBUG
+
+#include <stdio.h>
+
+/* This is to be run on a host which uses IEEE floating point. */
+
+void
+ieee_test (double n)
+{
+ double result;
+
+ floatformat_to_double (&floatformat_ieee_double_little, &n, &result);
+ if ((n != result && (! isnan (n) || ! isnan (result)))
+ || (n < 0 && result >= 0)
+ || (n >= 0 && result < 0))
+ printf ("Differ(to): %.20g -> %.20g\n", n, result);
+
+ floatformat_from_double (&floatformat_ieee_double_little, &n, &result);
+ if ((n != result && (! isnan (n) || ! isnan (result)))
+ || (n < 0 && result >= 0)
+ || (n >= 0 && result < 0))
+ printf ("Differ(from): %.20g -> %.20g\n", n, result);
+
+#if 0
+ {
+ char exten[16];
+
+ floatformat_from_double (&floatformat_m68881_ext, &n, exten);
+ floatformat_to_double (&floatformat_m68881_ext, exten, &result);
+ if (n != result)
+ printf ("Differ(to+from): %.20g -> %.20g\n", n, result);
+ }
+#endif
+
+#if IEEE_DEBUG > 1
+ /* This is to be run on a host which uses 68881 format. */
+ {
+ long double ex = *(long double *)exten;
+ if (ex != n)
+ printf ("Differ(from vs. extended): %.20g\n", n);
+ }
+#endif
+}
+
+int
+main (void)
+{
+ ieee_test (0.0);
+ ieee_test (0.5);
+ ieee_test (256.0);
+ ieee_test (0.12345);
+ ieee_test (234235.78907234);
+ ieee_test (-512.0);
+ ieee_test (-0.004321);
+ ieee_test (1.2E-70);
+ ieee_test (1.2E-316);
+ ieee_test (4.9406564584124654E-324);
+ ieee_test (- 4.9406564584124654E-324);
+ ieee_test (- 0.0);
+ ieee_test (- INFINITY);
+ ieee_test (- NAN);
+ ieee_test (INFINITY);
+ ieee_test (NAN);
+ return 0;
+}
+#endif
Property changes on: Extractor/src/common/convert_numeric.c
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: Extractor/src/common/convert_numeric.h (from rev 7875,
Extractor/src/plugins/convert_numeric.h)
===================================================================
--- Extractor/src/common/convert_numeric.h (rev 0)
+++ Extractor/src/common/convert_numeric.h 2008-11-16 12:22:53 UTC (rev
7916)
@@ -0,0 +1,140 @@
+/* IEEE floating point support declarations, for GDB, the GNU Debugger.
+ Copyright 1991, 1994, 1995, 1997, 2000, 2003, 2005
+ Free Software Foundation, Inc.
+
+This file is part of GDB.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program 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 General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
USA. */
+
+#if !defined (FLOATFORMAT_H)
+#define FLOATFORMAT_H 1
+
+/*#include "ansidecl.h"*/
+
+/* A floatformat consists of a sign bit, an exponent and a mantissa. Once the
+ bytes are concatenated according to the byteorder flag, then each of those
+ fields is contiguous. We number the bits with 0 being the most significant
+ (i.e. BITS_BIG_ENDIAN type numbering), and specify which bits each field
+ contains with the *_start and *_len fields. */
+
+/* What is the order of the bytes? */
+
+enum EXTRACTOR_floatformat_byteorders {
+ /* Standard little endian byte order.
+ EX: 1.2345678e10 => 00 00 80 c5 e0 fe 06 42 */
+ floatformat_little,
+
+ /* Standard big endian byte order.
+ EX: 1.2345678e10 => 42 06 fe e0 c5 80 00 00 */
+ floatformat_big,
+
+ /* Little endian byte order but big endian word order.
+ EX: 1.2345678e10 => e0 fe 06 42 00 00 80 c5 */
+ floatformat_littlebyte_bigword,
+
+ /* VAX byte order. Little endian byte order with 16-bit words. The
+ following example is an illustration of the byte order only; VAX
+ doesn't have a fully IEEE compliant floating-point format.
+ EX: 1.2345678e10 => 80 c5 00 00 06 42 e0 fe */
+ floatformat_vax
+};
+
+enum EXTRACTOR_floatformat_intbit { floatformat_intbit_yes,
floatformat_intbit_no };
+
+struct EXTRACTOR_floatformat
+{
+ enum EXTRACTOR_floatformat_byteorders byteorder;
+ unsigned int totalsize; /* Total size of number in bits */
+
+ /* Sign bit is always one bit long. 1 means negative, 0 means positive. */
+ unsigned int sign_start;
+
+ unsigned int exp_start;
+ unsigned int exp_len;
+ /* Bias added to a "true" exponent to form the biased exponent. It
+ is intentionally signed as, otherwize, -exp_bias can turn into a
+ very large number (e.g., given the exp_bias of 0x3fff and a 64
+ bit long, the equation (long)(1 - exp_bias) evaluates to
+ 4294950914) instead of -16382). */
+ int exp_bias;
+ /* Exponent value which indicates NaN. This is the actual value stored in
+ the float, not adjusted by the exp_bias. This usually consists of all
+ one bits. */
+ unsigned int exp_nan;
+
+ unsigned int man_start;
+ unsigned int man_len;
+
+ /* Is the integer bit explicit or implicit? */
+ enum EXTRACTOR_floatformat_intbit intbit;
+
+ /* Internal name for debugging. */
+ const char *name;
+
+ /* Validator method. */
+ int (*is_valid) (const struct EXTRACTOR_floatformat *fmt, const void *from);
+};
+
+/* floatformats for IEEE single and double, big and little endian. */
+
+extern const struct EXTRACTOR_floatformat
EXTRACTOR_floatformat_ieee_single_big;
+extern const struct EXTRACTOR_floatformat
EXTRACTOR_floatformat_ieee_single_little;
+extern const struct EXTRACTOR_floatformat
EXTRACTOR_floatformat_ieee_double_big;
+extern const struct EXTRACTOR_floatformat
EXTRACTOR_floatformat_ieee_double_little;
+
+/* floatformat for ARM IEEE double, little endian bytes and big endian words */
+
+extern const struct EXTRACTOR_floatformat
EXTRACTOR_floatformat_ieee_double_littlebyte_bigword;
+
+/* floatformats for VAX. */
+
+extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_vax_f;
+extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_vax_d;
+extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_vax_g;
+
+/* floatformats for various extendeds. */
+
+extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_i387_ext;
+extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m68881_ext;
+extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_i960_ext;
+extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_m88110_ext;
+extern const struct EXTRACTOR_floatformat
EXTRACTOR_floatformat_m88110_harris_ext;
+extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_arm_ext_big;
+extern const struct EXTRACTOR_floatformat
EXTRACTOR_floatformat_arm_ext_littlebyte_bigword;
+/* IA-64 Floating Point register spilt into memory. */
+extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_spill_big;
+extern const struct EXTRACTOR_floatformat
EXTRACTOR_floatformat_ia64_spill_little;
+extern const struct EXTRACTOR_floatformat EXTRACTOR_floatformat_ia64_quad_big;
+extern const struct EXTRACTOR_floatformat
EXTRACTOR_floatformat_ia64_quad_little;
+
+/* Convert from FMT to a double.
+ FROM is the address of the extended float.
+ Store the double in *TO. */
+
+extern void
+EXTRACTOR_common_floatformat_to_double (const struct EXTRACTOR_floatformat *,
const void *, double *);
+
+/* The converse: convert the double *FROM to FMT
+ and store where TO points. */
+
+extern void
+EXTRACTOR_common_floatformat_from_double (const struct EXTRACTOR_floatformat
*, const double *, void *);
+
+/* Return non-zero iff the data at FROM is a valid number in format FMT. */
+
+extern int
+EXTRACTOR_common_floatformat_is_valid (const struct EXTRACTOR_floatformat
*fmt, const void *from);
+
+#endif /* defined (FLOATFORMAT_H) */
Property changes on: Extractor/src/common/convert_numeric.h
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: Extractor/src/common/pack.c (from rev 7875,
Extractor/src/plugins/pack.c)
===================================================================
--- Extractor/src/common/pack.c (rev 0)
+++ Extractor/src/common/pack.c 2008-11-16 12:22:53 UTC (rev 7916)
@@ -0,0 +1,516 @@
+/*
+Catlib Copyright Notice
+
+The author of this software is Christopher Adam Telfer
+Copyright (c) 1998, 1999, 2000, 2001, 2002
+by Christopher Adam Telfer. All Rights Reserved.
+
+Permission to use, copy, modify, and distribute this software for any
+purpose without fee is hereby granted, provided that the above copyright
+notice, this paragraph, and the following two paragraphs appear in all
+copies, modifications, and distributions.
+
+IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF
+ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". THE AUTHOR HAS NO
+OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+*/
+
+#include "platform.h"
+#include "pack.h"
+
+typedef unsigned char byte;
+typedef unsigned short half;
+typedef unsigned int word;
+typedef signed char sbyte;
+typedef signed short shalf;
+typedef signed int sword;
+
+
+/*
+ "bhwAcslPBHWCSL"
+
+ Small letters: do not convert (not implemented for arrays and P)
+ Captial letters: convert from network byte order to host byte order
+
+ b - byte
+ h - half-word
+ w - word
+ a - array (32-byte unsigned long + that many bytes)
+ c - signed 8 bit value
+ s - signed 16 bit value
+ l - signed 32 bit value
+ p - (unpack only) value is a pointer to a pointer. Generate the buffer
+ to hold the data.
+
+ prefixing with a number K means that the argument will be an array of K
+ of the arguments specified by the letter
+ */
+
+int
+EXTRACTOR_common_cat_pack (void *buf, const char *fmt, ...)
+{
+ va_list ap;
+ word blen, val;
+ int npacked;
+ unsigned int nreps, i;
+ byte *bp, *bytep;
+ half *halfp;
+ word *wordp;
+ void *arr;
+ struct cat_bvec *cbvp;
+ char *cp;
+
+ va_start (ap, fmt);
+
+ npacked = 0;
+ bp = (byte *) buf;
+
+ while (*fmt)
+ {
+ nreps = 0;
+
+ if (isdigit (*fmt))
+ {
+ /* We use cp instead of fmt to keep the 'const' qualifier of fmt */
+ nreps = strtoul (fmt, &cp, 0);
+ fmt = cp;
+ }
+
+ switch (*fmt)
+ {
+ case 'B':
+ case 'b':
+ case 'C':
+ case 'c':
+ if (!nreps)
+ {
+ *bp++ = va_arg (ap, int);
+ npacked += 1;
+ }
+ else
+ {
+ bytep = va_arg (ap, byte *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *bp++ = bytep[i];
+ npacked += 1;
+ }
+ }
+ break;
+
+ case 'h':
+ case 's':
+ if (!nreps)
+ {
+ val = va_arg (ap, int);
+ *bp++ = val & 0xFF;
+ *bp++ = val >> 8;
+ npacked += 2;
+ }
+ else
+ {
+ halfp = va_arg (ap, half *);
+ for (i = 0; i < nreps; ++i)
+ {
+ val = halfp[i];
+ *bp++ = val & 0xFF;
+ *bp++ = val >> 8;
+ npacked += 2;
+ }
+ }
+ break;
+
+ case 'H':
+ case 'S':
+ if (!nreps)
+ {
+ val = va_arg (ap, int);
+ *bp++ = val >> 8;
+ *bp++ = val & 0xFF;
+ npacked += 2;
+ }
+ else
+ {
+ halfp = va_arg (ap, half *);
+ for (i = 0; i < nreps; ++i)
+ {
+ val = halfp[i];
+ *bp++ = val >> 8;
+ *bp++ = val & 0xFF;
+ npacked += 2;
+ }
+ }
+ break;
+
+ case 'l':
+ case 'w':
+ if (!nreps)
+ {
+ val = va_arg (ap, word);
+ *bp++ = val & 0xFF;
+ *bp++ = val >> 8;
+ *bp++ = val >> 16;
+ *bp++ = val >> 24;
+ npacked += 4;
+ }
+ else
+ {
+ wordp = va_arg (ap, word *);
+ for (i = 0; i < nreps; ++i)
+ {
+ val = wordp[i];
+ *bp++ = val & 0xFF;
+ *bp++ = val >> 8;
+ *bp++ = val >> 16;
+ *bp++ = val >> 24;
+ npacked += 4;
+ }
+ }
+ break;
+
+ case 'L':
+ case 'W':
+ if (!nreps)
+ {
+ val = va_arg (ap, word);
+ *bp++ = val >> 24;
+ *bp++ = val >> 16;
+ *bp++ = val >> 8;
+ *bp++ = val & 0xFF;
+ npacked += 4;
+ }
+ else
+ {
+ wordp = va_arg (ap, word *);
+ for (i = 0; i < nreps; ++i)
+ {
+ val = wordp[i];
+ *bp++ = val >> 24;
+ *bp++ = val >> 16;
+ *bp++ = val >> 8;
+ *bp++ = val & 0xFF;
+ npacked += 4;
+ }
+ }
+ break;
+
+ case 'A':
+ if (!nreps)
+ {
+ blen = va_arg (ap, word);
+ arr = va_arg (ap, void *);
+ *bp++ = blen >> 24;
+ *bp++ = blen >> 16;
+ *bp++ = blen >> 8;
+ *bp++ = blen & 0xFF;
+ memmove (bp, arr, blen);
+ bp += blen;
+ npacked += blen + 4; /* +4 for the 32 bits of length field
*/
+ }
+ else
+ {
+ cbvp = va_arg (ap, struct cat_bvec *);
+ for (i = 0; i < nreps; ++i)
+ {
+ blen = cbvp[i].len;
+ arr = cbvp[i].data;
+ *bp++ = blen >> 24;
+ *bp++ = blen >> 16;
+ *bp++ = blen >> 8;
+ *bp++ = blen & 0xFF;
+ memmove (bp, arr, blen);
+ bp += blen;
+ npacked += blen + 4; /* see above */
+ }
+ }
+ break;
+
+ default:
+ va_end (ap);
+ return -1;
+ }
+ ++fmt;
+ }
+
+ va_end (ap);
+ return npacked;
+}
+
+
+
+int
+EXTRACTOR_common_cat_unpack (const void *buf, const char *fmt, ...)
+{
+ va_list ap;
+ word maxlen, len, *wordp;
+ void *arr;
+ byte *bp, *bytep, *newbuf;
+ half *halfp;
+ sbyte *sbytep;
+ shalf *shalfp;
+ sword *swordp;
+ int npacked;
+ unsigned int nreps, i, isnonprefixed = 1; /* used for 'a' types only */
+ struct cat_bvec *cbvp;
+ char *cp;
+
+ bp = (byte *) buf;
+ npacked = 0;
+
+ va_start (ap, fmt);
+
+ while (*fmt)
+ {
+ nreps = 1;
+
+ if (isdigit (*fmt))
+ {
+ /* We use cp instead of format to keep the 'const' qualifier of fmt
*/
+ nreps = strtoul (fmt, &cp, 0);
+ fmt = cp;
+ if (*fmt == 'a')
+ isnonprefixed = 0;
+ }
+
+ switch (*fmt)
+ {
+ case 'B':
+ case 'b':
+ bytep = va_arg (ap, byte *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *bytep = *bp++;
+ ++bytep;
+ npacked += 1;
+ }
+ break;
+
+
+
+ case 'h':
+ halfp = va_arg (ap, half *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *halfp = *bp++;
+ *halfp |= *bp++ << 8;
+ ++halfp;
+ npacked += 2;
+ }
+ break;
+
+ case 'H':
+ halfp = va_arg (ap, half *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *halfp = *bp++ << 8;
+ *halfp |= *bp++;
+ ++halfp;
+ npacked += 2;
+ }
+ break;
+
+
+ case 'w':
+ wordp = va_arg (ap, word *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *wordp = *bp++;
+ *wordp |= *bp++ << 8;
+ *wordp |= *bp++ << 16;
+ *wordp |= *bp++ << 24;
+ ++wordp;
+ npacked += 4;
+ }
+ break;
+
+ case 'W':
+ wordp = va_arg (ap, word *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *wordp = *bp++ << 24;
+ *wordp |= *bp++ << 16;
+ *wordp |= *bp++ << 8;
+ *wordp |= *bp++;
+ ++wordp;
+ npacked += 4;
+ }
+ break;
+
+ case 'A':
+ if (isnonprefixed)
+ {
+ maxlen = va_arg (ap, word);
+ arr = va_arg (ap, void *);
+
+ len = *bp++ << 24;
+ len |= *bp++ << 16;
+ len |= *bp++ << 8;
+ len |= *bp++;
+
+ if (len > maxlen)
+ {
+ va_end (ap);
+ return -1;
+ }
+
+ memmove (arr, bp, len);
+ bp += len;
+
+ npacked += len;
+ }
+ else
+ {
+ cbvp = va_arg (ap, struct cat_bvec *);
+ for (i = 0; i < nreps; ++i)
+ {
+ maxlen = cbvp->len;
+ arr = cbvp->data;
+
+ len = *bp++ << 24;
+ len |= *bp++ << 16;
+ len |= *bp++ << 8;
+ len |= *bp++;
+
+ if (len > maxlen)
+ return -1;
+
+ memmove (arr, bp, len);
+ cbvp->len = len;
+ bp += len;
+
+ ++cbvp;
+ npacked += len;
+ }
+ isnonprefixed = 1;
+ }
+ break;
+
+ case 'C':
+ case 'c':
+ sbytep = va_arg (ap, sbyte *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *sbytep = *bp++;
+
+ if ((sizeof (sbyte) > 1) && (*sbytep & 0x80))
+ *sbytep |= (~0) << ((sizeof (sbyte) - 1) * 8);
+
+ ++sbytep;
+ npacked += 1;
+ }
+ break;
+
+
+ case 's':
+ shalfp = va_arg (ap, shalf *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *shalfp = *bp++;
+ *shalfp |= *bp++ << 8;
+
+ if ((sizeof (shalf) > 2) && (*shalfp & 0x8000))
+ *shalfp |= (~0) << ((sizeof (shalf) - 2) * 8);
+
+ ++shalfp;
+ npacked += 2;
+ }
+ break;
+
+ case 'S':
+ shalfp = va_arg (ap, shalf *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *shalfp = *bp++ << 8;
+ *shalfp |= *bp++;
+
+ if ((sizeof (shalf) > 2) && (*shalfp & 0x8000))
+ *shalfp |= (~0) << ((sizeof (shalf) - 2) * 8);
+
+ ++shalfp;
+ npacked += 2;
+ }
+ break;
+
+ case 'l':
+ swordp = va_arg (ap, sword *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *swordp = *bp++;
+ *swordp |= *bp++ << 8;
+ *swordp |= *bp++ << 16;
+ *swordp |= *bp++ << 24;
+
+ if ((sizeof (swordp) > 4) && (*swordp & 0x80000000))
+ *swordp |= (~0) << ((sizeof (sword) - 4) * 8);
+
+ ++swordp;
+ npacked += 4;
+ }
+ break;
+
+ case 'L':
+ swordp = va_arg (ap, sword *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *swordp = *bp++ << 24;
+ *swordp |= *bp++ << 16;
+ *swordp |= *bp++ << 8;
+ *swordp |= *bp++;
+
+ if ((sizeof (swordp) > 4) && (*swordp & 0x80000000))
+ *swordp |= (~0) << ((sizeof (sword) - 4) * 8);
+
+ ++swordp;
+ npacked += 4;
+ }
+ break;
+
+ case 'P':
+ cbvp = va_arg (ap, struct cat_bvec *);
+ for (i = 0; i < nreps; ++i)
+ {
+ len = *bp++ << 24;
+ len |= *bp++ << 16;
+ len |= *bp++ << 8;
+ len |= *bp++;
+
+ newbuf = (byte *) malloc (len);
+
+ if (!newbuf)
+ {
+ int j;
+ for (j = 0; j < i; j++)
+ free (cbvp[i].data);
+ va_end (ap);
+ return -1;
+ }
+
+ memmove (newbuf, bp, len);
+ cbvp[i].data = newbuf;
+ cbvp[i].len = len;
+
+ bp += len;
+ npacked += len;
+ }
+ break;
+
+ default:
+ va_end (ap);
+ return -1;
+ }
+
+ ++fmt;
+ }
+
+ va_end (ap);
+ return 0;
+}
Property changes on: Extractor/src/common/pack.c
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: Extractor/src/common/pack.h (from rev 7875,
Extractor/src/plugins/pack.h)
===================================================================
--- Extractor/src/common/pack.h (rev 0)
+++ Extractor/src/common/pack.h 2008-11-16 12:22:53 UTC (rev 7916)
@@ -0,0 +1,59 @@
+/*
+Catlib Copyright Notice
+
+The author of this software is Christopher Adam Telfer
+Copyright (c) 1998, 1999, 2000, 2001, 2002
+by Christopher Adam Telfer. All Rights Reserved.
+
+Permission to use, copy, modify, and distribute this software for any
+purpose without fee is hereby granted, provided that the above copyright
+notice, this paragraph, and the following two paragraphs appear in all
+copies, modifications, and distributions.
+
+IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF
+ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". THE AUTHOR HAS NO
+OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
+MODIFICATIONS.
+
+
+*/
+
+#ifndef __CAT_PACK_H
+#define __CAT_PACK_H
+
+/*
+ "bhwAcslPBHWCSL"
+
+ Small letters: do not convert (not implemented for arrays and P)
+ Captial letters: convert from network byte order to host byte order
+
+ b - byte
+ h - half-word
+ w - word
+ a - array (32-byte unsigned long + that many bytes)
+ c - signed 8 bit value
+ s - signed 16 bit value
+ l - signed 32 bit value
+ p - (unpack only) value is a pointer to a pointer. Generate the buffer
+ to hold the data.
+ */
+
+int EXTRACTOR_common_cat_pack(void * buf, const char *fmt, ... );
+
+int EXTRACTOR_common_cat_unpack(const void * buf, const char *fmt, ... );
+
+struct cat_bvec {
+ unsigned long len;
+ void * data;
+};
+
+#endif /* __CAT_PACK_H */
+
+
Property changes on: Extractor/src/common/pack.h
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: Extractor/src/plugins/Makefile-plugins.am
===================================================================
--- Extractor/src/plugins/Makefile-plugins.am 2008-11-16 09:48:46 UTC (rev
7915)
+++ Extractor/src/plugins/Makefile-plugins.am 2008-11-16 12:22:53 UTC (rev
7916)
@@ -1,4 +1,4 @@
-INCLUDES = -I$(top_srcdir)/src/include
+INCLUDES = -I$(top_srcdir)/src/include -I$(top_srcdir)/src/common
# install plugins under:
plugindir = $(libdir)/@RPLUGINDIR@
Modified: Extractor/src/plugins/Makefile.am
===================================================================
--- Extractor/src/plugins/Makefile.am 2008-11-16 09:48:46 UTC (rev 7915)
+++ Extractor/src/plugins/Makefile.am 2008-11-16 12:22:53 UTC (rev 7916)
@@ -142,11 +142,6 @@
-lFLAC $(flacoggflag) $(PLUGINFLAGS) $(retaincommand)
endif
-noinst_LTLIBRARIES = \
- libpack.la \
- libconvert.la \
- libconvert_numeric.la
-
if HAVE_ZLIB
libextractor_qt_la_LDFLAGS = \
$(PLUGINFLAGS) $(retaincommand)
@@ -172,35 +167,35 @@
libextractor_pdf_la_LDFLAGS = \
$(PLUGINFLAGS) $(retaincommand)
libextractor_pdf_la_LIBADD = \
- libconvert.la
+ $(top_builddir)/src/common/libextractor_common.la
libextractor_mp3_la_SOURCES = \
mp3extractor.c
libextractor_mp3_la_LDFLAGS = \
$(PLUGINFLAGS) $(retaincommand)
libextractor_mp3_la_LIBADD = \
- libconvert.la
+ $(top_builddir)/src/common/libextractor_common.la
libextractor_id3v2_la_SOURCES = \
id3v2extractor.c
libextractor_id3v2_la_LDFLAGS = \
$(PLUGINFLAGS) $(retaincommand)
libextractor_id3v2_la_LIBADD = \
- libconvert.la
+ $(top_builddir)/src/common/libextractor_common.la
libextractor_id3v23_la_SOURCES = \
id3v23extractor.c
libextractor_id3v23_la_LDFLAGS = \
$(PLUGINFLAGS) $(retaincommand)
libextractor_id3v23_la_LIBADD = \
- libconvert.la
+ $(top_builddir)/src/common/libextractor_common.la
libextractor_id3v24_la_SOURCES = \
id3v24extractor.c
libextractor_id3v24_la_LDFLAGS = \
$(PLUGINFLAGS) $(retaincommand)
libextractor_id3v24_la_LIBADD = \
- libconvert.la
+ $(top_builddir)/src/common/libextractor_common.la
libextractor_it_la_SOURCES = \
itextractor.c
@@ -238,43 +233,29 @@
libextractor_gif_la_LDFLAGS = \
$(PLUGINFLAGS) $(retaincommand)
libextractor_gif_la_LIBADD = \
- libpack.la
+ $(top_builddir)/src/common/libextractor_common.la
libextractor_tiff_la_SOURCES = \
tiffextractor.c
libextractor_tiff_la_LDFLAGS = \
$(PLUGINFLAGS) $(retaincommand)
libextractor_tiff_la_LIBADD = \
- libpack.la
+ $(top_builddir)/src/common/libextractor_common.la
libextractor_applefile_la_SOURCES = \
applefileextractor.c
libextractor_applefile_la_LDFLAGS = \
$(PLUGINFLAGS) $(retaincommand)
libextractor_applefile_la_LIBADD = \
- libpack.la
+ $(top_builddir)/src/common/libextractor_common.la
libextractor_elf_la_SOURCES = \
elfextractor.c
libextractor_elf_la_LDFLAGS = \
$(PLUGINFLAGS) $(retaincommand)
libextractor_elf_la_LIBADD = \
- libpack.la
+ $(top_builddir)/src/common/libextractor_common.la
-libpack_la_SOURCES = \
- pack.c \
- pack.h
-
-libconvert_la_SOURCES = \
- convert.c \
- convert.h
-libconvert_la_LDFLAGS = \
- $(LIBICONV)
-
-libconvert_numeric_la_SOURCES = \
- convert_numeric.c \
- convert_numeric.h
-
libextractor_zip_la_SOURCES = \
zipextractor.c
libextractor_zip_la_LDFLAGS = \
@@ -292,14 +273,14 @@
$(PLUGINFLAGS) $(retaincommand)
libextractor_html_la_LIBADD = \
$(top_builddir)/src/main/libextractor.la \
- libconvert.la
+ $(top_builddir)/src/common/libextractor_common.la
libextractor_flv_la_SOURCES = \
flvextractor.c
libextractor_flv_la_LDFLAGS = \
$(PLUGINFLAGS) $(retaincommand)
libextractor_flv_la_LIBADD = \
- libconvert_numeric.la
+ $(top_builddir)/src/common/libextractor_common.la
libextractor_real_la_SOURCES = \
realextractor.c
@@ -353,7 +334,7 @@
$(top_builddir)/src/main/libextractor.la \
$(PLUGINFLAGS) $(retaincommand)
libextractor_png_la_LIBADD = \
- libconvert.la -lz
+ $(top_builddir)/src/common/libextractor_common.la -lz
endif
libextractor_filename_la_SOURCES = \
@@ -362,7 +343,7 @@
$(PLUGINFLAGS) $(retaincommand)
libextractor_filename_la_LIBADD = \
$(top_builddir)/src/main/libextractor.la \
- libconvert.la
+ $(top_builddir)/src/common/libextractor_common.la
libextractor_sid_la_SOURCES = \
sidextractor.c
Modified: Extractor/src/plugins/applefileextractor.c
===================================================================
--- Extractor/src/plugins/applefileextractor.c 2008-11-16 09:48:46 UTC (rev
7915)
+++ Extractor/src/plugins/applefileextractor.c 2008-11-16 12:22:53 UTC (rev
7916)
@@ -99,7 +99,7 @@
if ((*offset + APPLEFILE_HEADER_SIZE) > size)
return -1;
- cat_unpack(data + *offset,
+ EXTRACTOR_common_cat_unpack(data + *offset,
APPLEFILE_HEADER_SPEC,
APPLEFILE_HEADER_FIELDS(hdr));
*offset += APPLEFILE_HEADER_SIZE;
@@ -114,8 +114,8 @@
if ((*offset + APPLEFILE_ENTRY_DESCRIPTOR_SIZE) > size)
return -1;
- cat_unpack(data + *offset,
- APPLEFILE_ENTRY_DESCRIPTOR_SPEC,
+ EXTRACTOR_common_cat_unpack(data + *offset,
+ APPLEFILE_ENTRY_DESCRIPTOR_SPEC,
APPLEFILE_ENTRY_DESCRIPTOR_FIELDS(dsc));
*offset += APPLEFILE_ENTRY_DESCRIPTOR_SIZE;
return 0;
@@ -137,7 +137,7 @@
if (readApplefileHeader(data, &offset, size, &header) == -1)
return prev;
- if ((memcmp(header.magic, APPLESINGLE_SIGNATURE, 4) != 0) &&
+ if ((memcmp(header.magic, APPLESINGLE_SIGNATURE, 4) != 0) &&
(memcmp(header.magic, APPLEDOUBLE_SIGNATURE, 4) != 0))
return prev;
@@ -175,7 +175,7 @@
else
snprintf (s, 13, "%.2f %s", (double) dsc.length, _("Bytes"));
- result = addKeyword(EXTRACTOR_FILE_SIZE, s, result);
+ result = addKeyword(EXTRACTOR_FILE_SIZE, s, result);
}
break;
case AED_ID_REAL_NAME:
Deleted: Extractor/src/plugins/convert.c
===================================================================
--- Extractor/src/plugins/convert.c 2008-11-16 09:48:46 UTC (rev 7915)
+++ Extractor/src/plugins/convert.c 2008-11-16 12:22:53 UTC (rev 7916)
@@ -1,66 +0,0 @@
-/*
- This file is part of libextractor.
- (C) 2004 Vidyut Samanta and Christian Grothoff
-
- libextractor is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
- option) any later version.
-
- libextractor 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
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with libextractor; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
- */
-
-#include "platform.h"
-#include "extractor.h"
-#include "convert.h"
-
-/**
- * Convert the len characters long character sequence
- * given in input that is in the given charset
- * to UTF-8.
- * @return the converted string (0-terminated),
- * if conversion fails, a copy of the orignal
- * string is returned.
- */
-char *
-convertToUtf8 (const char *input, size_t len, const char *charset)
-{
- size_t tmpSize;
- size_t finSize;
- char *tmp;
- char *ret;
- char *itmp;
- const char *i;
- iconv_t cd;
-
- i = input;
- cd = iconv_open ("UTF-8", charset);
- if (cd == (iconv_t) - 1)
- return strdup (i);
- tmpSize = 3 * len + 4;
- tmp = malloc (tmpSize);
- itmp = tmp;
- finSize = tmpSize;
- if (iconv (cd, (char **) &input, &len, &itmp, &finSize) == (size_t) - 1)
- {
- iconv_close (cd);
- free (tmp);
- return strdup (i);
- }
- ret = malloc (tmpSize - finSize + 1);
- memcpy (ret, tmp, tmpSize - finSize);
- ret[tmpSize - finSize] = '\0';
- free (tmp);
- iconv_close (cd);
- return ret;
-}
-
-/* end of convert.c */
Deleted: Extractor/src/plugins/convert.h
===================================================================
--- Extractor/src/plugins/convert.h 2008-11-16 09:48:46 UTC (rev 7915)
+++ Extractor/src/plugins/convert.h 2008-11-16 12:22:53 UTC (rev 7916)
@@ -1,46 +0,0 @@
-/*
- This file is part of libextractor.
- (C) 2004 Vidyut Samanta and Christian Grothoff
-
- libextractor is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published
- by the Free Software Foundation; either version 2, or (at your
- option) any later version.
-
- libextractor 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
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with libextractor; see the file COPYING. If not, write to the
- Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- Boston, MA 02111-1307, USA.
- */
-
-#ifndef CONVERT_H
-#define CONVERT_H
-
-#include "platform.h"
-#include "extractor.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/**
- * Convert the len characters long character sequence
- * given in input that is in the given charset
- * to UTF-8.
- * @return the converted string (0-terminated)
- */
-char * convertToUtf8(const char * input,
- size_t len,
- const char * charset);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
Deleted: Extractor/src/plugins/convert_numeric.c
===================================================================
--- Extractor/src/plugins/convert_numeric.c 2008-11-16 09:48:46 UTC (rev
7915)
+++ Extractor/src/plugins/convert_numeric.c 2008-11-16 12:22:53 UTC (rev
7916)
@@ -1,631 +0,0 @@
-/* IEEE floating point support routines, for GDB, the GNU Debugger.
- Copyright 1991, 1994, 1999, 2000, 2003, 2005, 2006
- Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program 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 General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
USA. */
-
-/* This is needed to pick up the NAN macro on some systems. */
-/* #define _GNU_SOURCE */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <math.h>
-
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-/* On some platforms, <float.h> provides DBL_QNAN. */
-#ifdef STDC_HEADERS
-#include <float.h>
-#endif
-
-/*#include "ansidecl.h"*/
-/*#include "libiberty.h"*/
-#include "convert_numeric.h"
-
-#ifndef INFINITY
-#ifdef HUGE_VAL
-#define INFINITY HUGE_VAL
-#else
-#define INFINITY (1.0 / 0.0)
-#endif
-#endif
-
-#ifndef NAN
-#ifdef DBL_QNAN
-#define NAN DBL_QNAN
-#else
-#define NAN (0.0 / 0.0)
-#endif
-#endif
-
-static unsigned long get_field (const unsigned char *,
- enum floatformat_byteorders,
- unsigned int,
- unsigned int,
- unsigned int);
-static int floatformat_always_valid (const struct floatformat *fmt,
- const void *from);
-
-static int
-floatformat_always_valid (const struct floatformat *fmt /*ATTRIBUTE_UNUSED*/,
- const void *from /*ATTRIBUTE_UNUSED*/)
-{
- return 1;
-}
-
-/* The odds that CHAR_BIT will be anything but 8 are low enough that I'm not
- going to bother with trying to muck around with whether it is defined in
- a system header, what we do if not, etc. */
-#define FLOATFORMAT_CHAR_BIT 8
-
-/* floatformats for IEEE single and double, big and little endian. */
-const struct floatformat floatformat_ieee_single_big =
-{
- floatformat_big, 32, 0, 1, 8, 127, 255, 9, 23,
- floatformat_intbit_no,
- "floatformat_ieee_single_big",
- floatformat_always_valid
-};
-const struct floatformat floatformat_ieee_single_little =
-{
- floatformat_little, 32, 0, 1, 8, 127, 255, 9, 23,
- floatformat_intbit_no,
- "floatformat_ieee_single_little",
- floatformat_always_valid
-};
-const struct floatformat floatformat_ieee_double_big =
-{
- floatformat_big, 64, 0, 1, 11, 1023, 2047, 12, 52,
- floatformat_intbit_no,
- "floatformat_ieee_double_big",
- floatformat_always_valid
-};
-const struct floatformat floatformat_ieee_double_little =
-{
- floatformat_little, 64, 0, 1, 11, 1023, 2047, 12, 52,
- floatformat_intbit_no,
- "floatformat_ieee_double_little",
- floatformat_always_valid
-};
-
-/* floatformat for IEEE double, little endian byte order, with big endian word
- ordering, as on the ARM. */
-
-const struct floatformat floatformat_ieee_double_littlebyte_bigword =
-{
- floatformat_littlebyte_bigword, 64, 0, 1, 11, 1023, 2047, 12, 52,
- floatformat_intbit_no,
- "floatformat_ieee_double_littlebyte_bigword",
- floatformat_always_valid
-};
-
-/* floatformat for VAX. Not quite IEEE, but close enough. */
-
-const struct floatformat floatformat_vax_f =
-{
- floatformat_vax, 32, 0, 1, 8, 129, 0, 9, 23,
- floatformat_intbit_no,
- "floatformat_vax_f",
- floatformat_always_valid
-};
-const struct floatformat floatformat_vax_d =
-{
- floatformat_vax, 64, 0, 1, 8, 129, 0, 9, 55,
- floatformat_intbit_no,
- "floatformat_vax_d",
- floatformat_always_valid
-};
-const struct floatformat floatformat_vax_g =
-{
- floatformat_vax, 64, 0, 1, 11, 1025, 0, 12, 52,
- floatformat_intbit_no,
- "floatformat_vax_g",
- floatformat_always_valid
-};
-
-static int floatformat_i387_ext_is_valid (const struct floatformat *fmt,
- const void *from);
-
-static int
-floatformat_i387_ext_is_valid (const struct floatformat *fmt, const void *from)
-{
- /* In the i387 double-extended format, if the exponent is all ones,
- then the integer bit must be set. If the exponent is neither 0
- nor ~0, the intbit must also be set. Only if the exponent is
- zero can it be zero, and then it must be zero. */
- unsigned long exponent, int_bit;
- const unsigned char *ufrom = (const unsigned char *) from;
-
- exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize,
- fmt->exp_start, fmt->exp_len);
- int_bit = get_field (ufrom, fmt->byteorder, fmt->totalsize,
- fmt->man_start, 1);
-
- if ((exponent == 0) != (int_bit == 0))
- return 0;
- else
- return 1;
-}
-
-const struct floatformat floatformat_i387_ext =
-{
- floatformat_little, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,
- floatformat_intbit_yes,
- "floatformat_i387_ext",
- floatformat_i387_ext_is_valid
-};
-const struct floatformat floatformat_m68881_ext =
-{
- /* Note that the bits from 16 to 31 are unused. */
- floatformat_big, 96, 0, 1, 15, 0x3fff, 0x7fff, 32, 64,
- floatformat_intbit_yes,
- "floatformat_m68881_ext",
- floatformat_always_valid
-};
-const struct floatformat floatformat_i960_ext =
-{
- /* Note that the bits from 0 to 15 are unused. */
- floatformat_little, 96, 16, 17, 15, 0x3fff, 0x7fff, 32, 64,
- floatformat_intbit_yes,
- "floatformat_i960_ext",
- floatformat_always_valid
-};
-const struct floatformat floatformat_m88110_ext =
-{
- floatformat_big, 80, 0, 1, 15, 0x3fff, 0x7fff, 16, 64,
- floatformat_intbit_yes,
- "floatformat_m88110_ext",
- floatformat_always_valid
-};
-const struct floatformat floatformat_m88110_harris_ext =
-{
- /* Harris uses raw format 128 bytes long, but the number is just an ieee
- double, and the last 64 bits are wasted. */
- floatformat_big,128, 0, 1, 11, 0x3ff, 0x7ff, 12, 52,
- floatformat_intbit_no,
- "floatformat_m88110_ext_harris",
- floatformat_always_valid
-};
-const struct floatformat floatformat_arm_ext_big =
-{
- /* Bits 1 to 16 are unused. */
- floatformat_big, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64,
- floatformat_intbit_yes,
- "floatformat_arm_ext_big",
- floatformat_always_valid
-};
-const struct floatformat floatformat_arm_ext_littlebyte_bigword =
-{
- /* Bits 1 to 16 are unused. */
- floatformat_littlebyte_bigword, 96, 0, 17, 15, 0x3fff, 0x7fff, 32, 64,
- floatformat_intbit_yes,
- "floatformat_arm_ext_littlebyte_bigword",
- floatformat_always_valid
-};
-const struct floatformat floatformat_ia64_spill_big =
-{
- floatformat_big, 128, 0, 1, 17, 65535, 0x1ffff, 18, 64,
- floatformat_intbit_yes,
- "floatformat_ia64_spill_big",
- floatformat_always_valid
-};
-const struct floatformat floatformat_ia64_spill_little =
-{
- floatformat_little, 128, 0, 1, 17, 65535, 0x1ffff, 18, 64,
- floatformat_intbit_yes,
- "floatformat_ia64_spill_little",
- floatformat_always_valid
-};
-const struct floatformat floatformat_ia64_quad_big =
-{
- floatformat_big, 128, 0, 1, 15, 16383, 0x7fff, 16, 112,
- floatformat_intbit_no,
- "floatformat_ia64_quad_big",
- floatformat_always_valid
-};
-const struct floatformat floatformat_ia64_quad_little =
-{
- floatformat_little, 128, 0, 1, 15, 16383, 0x7fff, 16, 112,
- floatformat_intbit_no,
- "floatformat_ia64_quad_little",
- floatformat_always_valid
-};
-
-
-#ifndef min
-#define min(a, b) ((a) < (b) ? (a) : (b))
-#endif
-
-/* Extract a field which starts at START and is LEN bits long. DATA and
- TOTAL_LEN are the thing we are extracting it from, in byteorder ORDER. */
-static unsigned long
-get_field (const unsigned char *data, enum floatformat_byteorders order,
- unsigned int total_len, unsigned int start, unsigned int len)
-{
- unsigned long result = 0;
- unsigned int cur_byte;
- int lo_bit, hi_bit, cur_bitshift = 0;
- int nextbyte = (order == floatformat_little) ? 1 : -1;
-
- /* Start is in big-endian bit order! Fix that first. */
- start = total_len - (start + len);
-
- /* Start at the least significant part of the field. */
- if (order == floatformat_little)
- cur_byte = start / FLOATFORMAT_CHAR_BIT;
- else
- cur_byte = (total_len - start - 1) / FLOATFORMAT_CHAR_BIT;
-
- lo_bit = start % FLOATFORMAT_CHAR_BIT;
- hi_bit = min (lo_bit + len, FLOATFORMAT_CHAR_BIT);
-
- do
- {
- unsigned int shifted = *(data + cur_byte) >> lo_bit;
- unsigned int bits = hi_bit - lo_bit;
- unsigned int mask = (1 << bits) - 1;
- result |= (shifted & mask) << cur_bitshift;
- len -= bits;
- cur_bitshift += bits;
- cur_byte += nextbyte;
- lo_bit = 0;
- hi_bit = min (len, FLOATFORMAT_CHAR_BIT);
- }
- while (len != 0);
-
- return result;
-}
-
-/* Convert from FMT to a double.
- FROM is the address of the extended float.
- Store the double in *TO. */
-
-void
-floatformat_to_double (const struct floatformat *fmt,
- const void *from, double *to)
-{
- const unsigned char *ufrom = (const unsigned char *) from;
- double dto;
- long exponent;
- unsigned long mant;
- unsigned int mant_bits, mant_off;
- int mant_bits_left;
- int special_exponent; /* It's a NaN, denorm or zero */
-
- exponent = get_field (ufrom, fmt->byteorder, fmt->totalsize,
- fmt->exp_start, fmt->exp_len);
-
- /* If the exponent indicates a NaN, we don't have information to
- decide what to do. So we handle it like IEEE, except that we
- don't try to preserve the type of NaN. FIXME. */
- if ((unsigned long) exponent == fmt->exp_nan)
- {
- int nan;
-
- mant_off = fmt->man_start;
- mant_bits_left = fmt->man_len;
- nan = 0;
- while (mant_bits_left > 0)
- {
- mant_bits = min (mant_bits_left, 32);
-
- if (get_field (ufrom, fmt->byteorder, fmt->totalsize,
- mant_off, mant_bits) != 0)
- {
- /* This is a NaN. */
- nan = 1;
- break;
- }
-
- mant_off += mant_bits;
- mant_bits_left -= mant_bits;
- }
-
- /* On certain systems (such as GNU/Linux), the use of the
- INFINITY macro below may generate a warning that can not be
- silenced due to a bug in GCC (PR preprocessor/11931). The
- preprocessor fails to recognise the __extension__ keyword in
- conjunction with the GNU/C99 extension for hexadecimal
- floating point constants and will issue a warning when
- compiling with -pedantic. */
- if (nan)
- dto = NAN;
- else
- dto = INFINITY;
-
- if (get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->sign_start,
1))
- dto = -dto;
-
- *to = dto;
-
- return;
- }
-
- mant_bits_left = fmt->man_len;
- mant_off = fmt->man_start;
- dto = 0.0;
-
- special_exponent = exponent == 0 || (unsigned long) exponent == fmt->exp_nan;
-
- /* Don't bias zero's, denorms or NaNs. */
- if (!special_exponent)
- exponent -= fmt->exp_bias;
-
- /* Build the result algebraically. Might go infinite, underflow, etc;
- who cares. */
-
- /* If this format uses a hidden bit, explicitly add it in now. Otherwise,
- increment the exponent by one to account for the integer bit. */
-
- if (!special_exponent)
- {
- if (fmt->intbit == floatformat_intbit_no)
- dto = ldexp (1.0, exponent);
- else
- exponent++;
- }
-
- while (mant_bits_left > 0)
- {
- mant_bits = min (mant_bits_left, 32);
-
- mant = get_field (ufrom, fmt->byteorder, fmt->totalsize,
- mant_off, mant_bits);
-
- /* Handle denormalized numbers. FIXME: What should we do for
- non-IEEE formats? */
- if (special_exponent && exponent == 0 && mant != 0)
- dto += ldexp ((double)mant,
- (- fmt->exp_bias
- - mant_bits
- - (mant_off - fmt->man_start)
- + 1));
- else
- dto += ldexp ((double)mant, exponent - mant_bits);
- if (exponent != 0)
- exponent -= mant_bits;
- mant_off += mant_bits;
- mant_bits_left -= mant_bits;
- }
-
- /* Negate it if negative. */
- if (get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1))
- dto = -dto;
- *to = dto;
-}
-
-static void put_field (unsigned char *, enum floatformat_byteorders,
- unsigned int,
- unsigned int,
- unsigned int,
- unsigned long);
-
-/* Set a field which starts at START and is LEN bits long. DATA and
- TOTAL_LEN are the thing we are extracting it from, in byteorder ORDER. */
-static void
-put_field (unsigned char *data, enum floatformat_byteorders order,
- unsigned int total_len, unsigned int start, unsigned int len,
- unsigned long stuff_to_put)
-{
- unsigned int cur_byte;
- int lo_bit, hi_bit;
- int nextbyte = (order == floatformat_little) ? 1 : -1;
-
- /* Start is in big-endian bit order! Fix that first. */
- start = total_len - (start + len);
-
- /* Start at the least significant part of the field. */
- if (order == floatformat_little)
- cur_byte = start / FLOATFORMAT_CHAR_BIT;
- else
- cur_byte = (total_len - start - 1) / FLOATFORMAT_CHAR_BIT;
-
- lo_bit = start % FLOATFORMAT_CHAR_BIT;
- hi_bit = min (lo_bit + len, FLOATFORMAT_CHAR_BIT);
-
- do
- {
- unsigned char *byte_ptr = data + cur_byte;
- unsigned int bits = hi_bit - lo_bit;
- unsigned int mask = ((1 << bits) - 1) << lo_bit;
- *byte_ptr = (*byte_ptr & ~mask) | ((stuff_to_put << lo_bit) & mask);
- stuff_to_put >>= bits;
- len -= bits;
- cur_byte += nextbyte;
- lo_bit = 0;
- hi_bit = min (len, FLOATFORMAT_CHAR_BIT);
- }
- while (len != 0);
-}
-
-/* The converse: convert the double *FROM to an extended float
- and store where TO points. Neither FROM nor TO have any alignment
- restrictions. */
-
-void
-floatformat_from_double (const struct floatformat *fmt,
- const double *from, void *to)
-{
- double dfrom;
- int exponent;
- double mant;
- unsigned int mant_bits, mant_off;
- int mant_bits_left;
- unsigned char *uto = (unsigned char *) to;
-
- dfrom = *from;
- memset (uto, 0, fmt->totalsize / FLOATFORMAT_CHAR_BIT);
-
- /* If negative, set the sign bit. */
- if (dfrom < 0)
- {
- put_field (uto, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1, 1);
- dfrom = -dfrom;
- }
-
- if (dfrom == 0)
- {
- /* 0.0. */
- return;
- }
-
- if (dfrom != dfrom)
- {
- /* NaN. */
- put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
- fmt->exp_len, fmt->exp_nan);
- /* Be sure it's not infinity, but NaN value is irrelevant. */
- put_field (uto, fmt->byteorder, fmt->totalsize, fmt->man_start,
- 32, 1);
- return;
- }
-
- if (dfrom + dfrom == dfrom)
- {
- /* This can only happen for an infinite value (or zero, which we
- already handled above). */
- put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
- fmt->exp_len, fmt->exp_nan);
- return;
- }
-
- mant = frexp (dfrom, &exponent);
- if (exponent + fmt->exp_bias - 1 > 0)
- put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
- fmt->exp_len, exponent + fmt->exp_bias - 1);
- else
- {
- /* Handle a denormalized number. FIXME: What should we do for
- non-IEEE formats? */
- put_field (uto, fmt->byteorder, fmt->totalsize, fmt->exp_start,
- fmt->exp_len, 0);
- mant = ldexp (mant, exponent + fmt->exp_bias - 1);
- }
-
- mant_bits_left = fmt->man_len;
- mant_off = fmt->man_start;
- while (mant_bits_left > 0)
- {
- unsigned long mant_long;
- mant_bits = mant_bits_left < 32 ? mant_bits_left : 32;
-
- mant *= 4294967296.0;
- mant_long = (unsigned long)mant;
- mant -= mant_long;
-
- /* If the integer bit is implicit, and we are not creating a
- denormalized number, then we need to discard it. */
- if ((unsigned int) mant_bits_left == fmt->man_len
- && fmt->intbit == floatformat_intbit_no
- && exponent + fmt->exp_bias - 1 > 0)
- {
- mant_long &= 0x7fffffff;
- mant_bits -= 1;
- }
- else if (mant_bits < 32)
- {
- /* The bits we want are in the most significant MANT_BITS bits of
- mant_long. Move them to the least significant. */
- mant_long >>= 32 - mant_bits;
- }
-
- put_field (uto, fmt->byteorder, fmt->totalsize,
- mant_off, mant_bits, mant_long);
- mant_off += mant_bits;
- mant_bits_left -= mant_bits;
- }
-}
-
-/* Return non-zero iff the data at FROM is a valid number in format FMT. */
-
-int
-floatformat_is_valid (const struct floatformat *fmt, const void *from)
-{
- return fmt->is_valid (fmt, from);
-}
-
-
-#ifdef IEEE_DEBUG
-
-#include <stdio.h>
-
-/* This is to be run on a host which uses IEEE floating point. */
-
-void
-ieee_test (double n)
-{
- double result;
-
- floatformat_to_double (&floatformat_ieee_double_little, &n, &result);
- if ((n != result && (! isnan (n) || ! isnan (result)))
- || (n < 0 && result >= 0)
- || (n >= 0 && result < 0))
- printf ("Differ(to): %.20g -> %.20g\n", n, result);
-
- floatformat_from_double (&floatformat_ieee_double_little, &n, &result);
- if ((n != result && (! isnan (n) || ! isnan (result)))
- || (n < 0 && result >= 0)
- || (n >= 0 && result < 0))
- printf ("Differ(from): %.20g -> %.20g\n", n, result);
-
-#if 0
- {
- char exten[16];
-
- floatformat_from_double (&floatformat_m68881_ext, &n, exten);
- floatformat_to_double (&floatformat_m68881_ext, exten, &result);
- if (n != result)
- printf ("Differ(to+from): %.20g -> %.20g\n", n, result);
- }
-#endif
-
-#if IEEE_DEBUG > 1
- /* This is to be run on a host which uses 68881 format. */
- {
- long double ex = *(long double *)exten;
- if (ex != n)
- printf ("Differ(from vs. extended): %.20g\n", n);
- }
-#endif
-}
-
-int
-main (void)
-{
- ieee_test (0.0);
- ieee_test (0.5);
- ieee_test (256.0);
- ieee_test (0.12345);
- ieee_test (234235.78907234);
- ieee_test (-512.0);
- ieee_test (-0.004321);
- ieee_test (1.2E-70);
- ieee_test (1.2E-316);
- ieee_test (4.9406564584124654E-324);
- ieee_test (- 4.9406564584124654E-324);
- ieee_test (- 0.0);
- ieee_test (- INFINITY);
- ieee_test (- NAN);
- ieee_test (INFINITY);
- ieee_test (NAN);
- return 0;
-}
-#endif
Deleted: Extractor/src/plugins/convert_numeric.h
===================================================================
--- Extractor/src/plugins/convert_numeric.h 2008-11-16 09:48:46 UTC (rev
7915)
+++ Extractor/src/plugins/convert_numeric.h 2008-11-16 12:22:53 UTC (rev
7916)
@@ -1,140 +0,0 @@
-/* IEEE floating point support declarations, for GDB, the GNU Debugger.
- Copyright 1991, 1994, 1995, 1997, 2000, 2003, 2005
- Free Software Foundation, Inc.
-
-This file is part of GDB.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program 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 General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301,
USA. */
-
-#if !defined (FLOATFORMAT_H)
-#define FLOATFORMAT_H 1
-
-/*#include "ansidecl.h"*/
-
-/* A floatformat consists of a sign bit, an exponent and a mantissa. Once the
- bytes are concatenated according to the byteorder flag, then each of those
- fields is contiguous. We number the bits with 0 being the most significant
- (i.e. BITS_BIG_ENDIAN type numbering), and specify which bits each field
- contains with the *_start and *_len fields. */
-
-/* What is the order of the bytes? */
-
-enum floatformat_byteorders {
- /* Standard little endian byte order.
- EX: 1.2345678e10 => 00 00 80 c5 e0 fe 06 42 */
- floatformat_little,
-
- /* Standard big endian byte order.
- EX: 1.2345678e10 => 42 06 fe e0 c5 80 00 00 */
- floatformat_big,
-
- /* Little endian byte order but big endian word order.
- EX: 1.2345678e10 => e0 fe 06 42 00 00 80 c5 */
- floatformat_littlebyte_bigword,
-
- /* VAX byte order. Little endian byte order with 16-bit words. The
- following example is an illustration of the byte order only; VAX
- doesn't have a fully IEEE compliant floating-point format.
- EX: 1.2345678e10 => 80 c5 00 00 06 42 e0 fe */
- floatformat_vax
-};
-
-enum floatformat_intbit { floatformat_intbit_yes, floatformat_intbit_no };
-
-struct floatformat
-{
- enum floatformat_byteorders byteorder;
- unsigned int totalsize; /* Total size of number in bits */
-
- /* Sign bit is always one bit long. 1 means negative, 0 means positive. */
- unsigned int sign_start;
-
- unsigned int exp_start;
- unsigned int exp_len;
- /* Bias added to a "true" exponent to form the biased exponent. It
- is intentionally signed as, otherwize, -exp_bias can turn into a
- very large number (e.g., given the exp_bias of 0x3fff and a 64
- bit long, the equation (long)(1 - exp_bias) evaluates to
- 4294950914) instead of -16382). */
- int exp_bias;
- /* Exponent value which indicates NaN. This is the actual value stored in
- the float, not adjusted by the exp_bias. This usually consists of all
- one bits. */
- unsigned int exp_nan;
-
- unsigned int man_start;
- unsigned int man_len;
-
- /* Is the integer bit explicit or implicit? */
- enum floatformat_intbit intbit;
-
- /* Internal name for debugging. */
- const char *name;
-
- /* Validator method. */
- int (*is_valid) (const struct floatformat *fmt, const void *from);
-};
-
-/* floatformats for IEEE single and double, big and little endian. */
-
-extern const struct floatformat floatformat_ieee_single_big;
-extern const struct floatformat floatformat_ieee_single_little;
-extern const struct floatformat floatformat_ieee_double_big;
-extern const struct floatformat floatformat_ieee_double_little;
-
-/* floatformat for ARM IEEE double, little endian bytes and big endian words */
-
-extern const struct floatformat floatformat_ieee_double_littlebyte_bigword;
-
-/* floatformats for VAX. */
-
-extern const struct floatformat floatformat_vax_f;
-extern const struct floatformat floatformat_vax_d;
-extern const struct floatformat floatformat_vax_g;
-
-/* floatformats for various extendeds. */
-
-extern const struct floatformat floatformat_i387_ext;
-extern const struct floatformat floatformat_m68881_ext;
-extern const struct floatformat floatformat_i960_ext;
-extern const struct floatformat floatformat_m88110_ext;
-extern const struct floatformat floatformat_m88110_harris_ext;
-extern const struct floatformat floatformat_arm_ext_big;
-extern const struct floatformat floatformat_arm_ext_littlebyte_bigword;
-/* IA-64 Floating Point register spilt into memory. */
-extern const struct floatformat floatformat_ia64_spill_big;
-extern const struct floatformat floatformat_ia64_spill_little;
-extern const struct floatformat floatformat_ia64_quad_big;
-extern const struct floatformat floatformat_ia64_quad_little;
-
-/* Convert from FMT to a double.
- FROM is the address of the extended float.
- Store the double in *TO. */
-
-extern void
-floatformat_to_double (const struct floatformat *, const void *, double *);
-
-/* The converse: convert the double *FROM to FMT
- and store where TO points. */
-
-extern void
-floatformat_from_double (const struct floatformat *, const double *, void *);
-
-/* Return non-zero iff the data at FROM is a valid number in format FMT. */
-
-extern int
-floatformat_is_valid (const struct floatformat *fmt, const void *from);
-
-#endif /* defined (FLOATFORMAT_H) */
Modified: Extractor/src/plugins/elfextractor.c
===================================================================
--- Extractor/src/plugins/elfextractor.c 2008-11-16 09:48:46 UTC (rev
7915)
+++ Extractor/src/plugins/elfextractor.c 2008-11-16 12:22:53 UTC (rev
7916)
@@ -294,7 +294,7 @@
if (ehdr->e_shnum <= idx)
return -1;
- cat_unpack (&data[ehdr->e_shoff + ehdr->e_shentsize * idx],
+ EXTRACTOR_common_cat_unpack (&data[ehdr->e_shoff + ehdr->e_shentsize * idx],
ELF_SECTION_SPECS[getByteorder (data[EI_CLASS])],
ELF_SECTION_FIELDS (ret));
return 0;
@@ -312,7 +312,7 @@
{
if ((off + osize > size) || ((idx + 1) * ELF_DYN_SIZE > osize))
return -1;
- cat_unpack (&data[off + idx * ELF_DYN_SIZE],
+ EXTRACTOR_common_cat_unpack (&data[off + idx * ELF_DYN_SIZE],
ELF_DYN_SPECS[getByteorder (data[EI_CLASS])],
ELF_DYN_FIELDS (ret));
return 0;
@@ -330,7 +330,7 @@
if (ehdr->e_phnum <= idx)
return -1;
- cat_unpack (&data[ehdr->e_phoff + ehdr->e_phensize * idx],
+ EXTRACTOR_common_cat_unpack (&data[ehdr->e_phoff + ehdr->e_phensize * idx],
ELF_PHDR_SPECS[getByteorder (data[EI_CLASS])],
ELF_PHDR_FIELDS (ret));
return 0;
@@ -353,7 +353,7 @@
{
case ELFDATA2LSB:
case ELFDATA2MSB:
- cat_unpack (&data[EI_NIDENT],
+ EXTRACTOR_common_cat_unpack (&data[EI_NIDENT],
ELF_HEADER_SPECS[getByteorder (data[EI_CLASS])],
ELF_HEADER_FIELDS (ehdr));
break;
Modified: Extractor/src/plugins/filenameextractor.c
===================================================================
--- Extractor/src/plugins/filenameextractor.c 2008-11-16 09:48:46 UTC (rev
7915)
+++ Extractor/src/plugins/filenameextractor.c 2008-11-16 12:22:53 UTC (rev
7916)
@@ -44,7 +44,7 @@
}
keyword = malloc (sizeof (EXTRACTOR_KeywordList));
keyword->next = prev;
- keyword->keyword = convertToUtf8 (filenameRoot,
+ keyword->keyword = EXTRACTOR_common_convert_to_utf8 (filenameRoot,
strlen (filenameRoot),
nl_langinfo (CODESET));
keyword->keywordType = EXTRACTOR_FILENAME;
Modified: Extractor/src/plugins/flvextractor.c
===================================================================
--- Extractor/src/plugins/flvextractor.c 2008-11-16 09:48:46 UTC (rev
7915)
+++ Extractor/src/plugins/flvextractor.c 2008-11-16 12:22:53 UTC (rev
7916)
@@ -117,8 +117,8 @@
const unsigned char *ptr = *data;
double val;
- floatformat_to_double(&floatformat_ieee_double_big,
- (const void *)ptr,
+
EXTRACTOR_common_floatformat_to_double(&EXTRACTOR_common_floatformat_ieee_double_big,
+ (const void *)ptr,
&val);
ptr += 8;
*data = ptr;
@@ -152,7 +152,7 @@
{
const unsigned char *ptr = *data;
int val;
-
+
if (*len < 1)
return -1;
@@ -192,7 +192,7 @@
const unsigned char *ptr = *data;
char *ret;
int slen;
-
+
if (*len < 2)
return -1;
@@ -214,9 +214,9 @@
return 0;
}
-static int parse_amf(const unsigned char **data,
+static int parse_amf(const unsigned char **data,
size_t *len,
- AMFParserHandler *handler)
+ AMFParserHandler *handler)
{
const unsigned char *ptr = *data;
unsigned char astype;
@@ -231,8 +231,8 @@
double val;
ret = readASNumber(&ptr, len, &val);
if (ret == 0)
- (*(handler->as_end_callback))(astype,
- &val,
+ (*(handler->as_end_callback))(astype,
+ &val,
handler->userdata);
break;
}
@@ -241,8 +241,8 @@
int val;
ret = readASBoolean(&ptr, len, &val);
if (ret == 0)
- (*(handler->as_end_callback))(astype,
- &val,
+ (*(handler->as_end_callback))(astype,
+ &val,
handler->userdata);
break;
}
@@ -251,8 +251,8 @@
char *val;
ret = readASString(&ptr, len, &val);
if (ret == 0) {
- (*(handler->as_end_callback))(astype,
- val,
+ (*(handler->as_end_callback))(astype,
+ val,
handler->userdata);
free(val);
}
@@ -267,8 +267,8 @@
tmp[0] = &millis;
tmp[1] = &tz;
if (ret == 0)
- (*(handler->as_end_callback))(astype,
- &tmp,
+ (*(handler->as_end_callback))(astype,
+ &tmp,
handler->userdata);
break;
}
@@ -293,11 +293,11 @@
if (ret == -1)
break;
}
- (*(handler->as_end_callback))(ASTYPE_ARRAY,
- NULL,
+ (*(handler->as_end_callback))(ASTYPE_ARRAY,
+ NULL,
handler->userdata);
break;
- }
+ }
case ASTYPE_OBJECT:
{
char *key;
@@ -306,7 +306,7 @@
ret = readASString(&ptr, len, &key);
if (ret == -1)
break;
- (*(handler->as_key_callback))(key,
+ (*(handler->as_key_callback))(key,
handler->userdata);
free(key);
type = *ptr;
@@ -317,17 +317,17 @@
ret = readASString(&ptr, len, &key);
if (ret == -1)
break;
- (*(handler->as_key_callback))(key,
+ (*(handler->as_key_callback))(key,
handler->userdata);
free(key);
- type = *ptr;
+ type = *ptr;
}
if (ret == 0)
- (*(handler->as_end_callback))(ASTYPE_OBJECT,
- NULL,
+ (*(handler->as_end_callback))(ASTYPE_OBJECT,
+ NULL,
handler->userdata);
break;
- }
+ }
case ASTYPE_MIXEDARRAY:
{
char *key;
@@ -343,7 +343,7 @@
ret = readASString(&ptr, len, &key);
if (ret == -1)
break;
- (*(handler->as_key_callback))(key,
+ (*(handler->as_key_callback))(key,
handler->userdata);
free(key);
type = *ptr;
@@ -354,21 +354,21 @@
ret = readASString(&ptr, len, &key);
if (ret == -1)
break;
- (*(handler->as_key_callback))(key,
+ (*(handler->as_key_callback))(key,
handler->userdata);
free(key);
- type = *ptr;
+ type = *ptr;
}
if (ret == 0)
- (*(handler->as_end_callback))(astype,
- NULL,
+ (*(handler->as_end_callback))(astype,
+ NULL,
handler->userdata);
break;
- }
+ }
default:
ret = -1;
- (*(handler->as_end_callback))(astype,
- NULL,
+ (*(handler->as_end_callback))(astype,
+ NULL,
handler->userdata);
#if DEBUG
printf("parse_amf: Unknown type %02x", astype);
@@ -647,11 +647,11 @@
{
FLVMetaParserState *state = (FLVMetaParserState *)userdata;
- if (state->onMetaData && state->parsingDepth == 0 &&
+ if (state->onMetaData && state->parsingDepth == 0 &&
type != ASTYPE_MIXEDARRAY)
state->onMetaData = 0;
- if (type == ASTYPE_ARRAY || type == ASTYPE_MIXEDARRAY ||
+ if (type == ASTYPE_ARRAY || type == ASTYPE_MIXEDARRAY ||
type == ASTYPE_OBJECT)
state->parsingDepth++;
}
@@ -665,13 +665,13 @@
return;
i = 0;
- while ((key_to_extractor_map[i].key != NULL) &&
+ while ((key_to_extractor_map[i].key != NULL) &&
(strcasecmp(key, key_to_extractor_map[i].key) != 0))
i++;
state->currentKeyType = key_to_extractor_map[i].type;
i = 0;
- while ((key_to_attribute_map[i].key != NULL) &&
+ while ((key_to_attribute_map[i].key != NULL) &&
(strcasecmp(key, key_to_attribute_map[i].key) != 0))
i++;
state->currentAttribute = key_to_attribute_map[i].attribute;
@@ -681,7 +681,7 @@
{
FLVMetaParserState *state = (FLVMetaParserState *)userdata;
char *s;
-
+
if ((state->parsingDepth == 0) && (type == ASTYPE_STRING)) {
s = (char *)value;
if (!strcmp(s, "onMetaData"))
@@ -692,8 +692,8 @@
* right after a "onMetaData" STRING */
/* stream info related metadata */
- if (state->onMetaData && (state->parsingDepth == 1) &&
- (state->currentAttribute != FLV_NONE) &&
+ if (state->onMetaData && (state->parsingDepth == 1) &&
+ (state->currentAttribute != FLV_NONE) &&
(type == ASTYPE_NUMBER))
{
double n = *((double *)value);
@@ -711,10 +711,10 @@
break;
case FLV_FRAMERATE:
state->streamInfo->videoFrameRate = n;
- break;
+ break;
case FLV_VDATARATE:
state->streamInfo->videoDataRate = n;
- break;
+ break;
case FLV_ADATARATE:
state->streamInfo->audioDataRate = n;
break;
@@ -729,8 +729,8 @@
}
}
- if (state->onMetaData && (state->parsingDepth == 1) &&
- (state->currentAttribute == FLV_STEREO) &&
+ if (state->onMetaData && (state->parsingDepth == 1) &&
+ (state->currentAttribute == FLV_STEREO) &&
(type == ASTYPE_BOOLEAN))
{
int n = *((int *)value);
@@ -739,7 +739,7 @@
}
/* metadata that maps straight to extractor keys */
- if (state->onMetaData && (state->parsingDepth == 1) &&
+ if (state->onMetaData && (state->parsingDepth == 1) &&
(state->currentKeyType != EXTRACTOR_UNKNOWN))
{
s = NULL;
@@ -779,22 +779,22 @@
}
if (s != NULL)
- state->keywords = addKeyword (state->currentKeyType,
+ state->keywords = addKeyword (state->currentKeyType,
s,
state->keywords);
}
state->currentKeyType = EXTRACTOR_UNKNOWN;
state->currentAttribute = FLV_NONE;
- if (type == ASTYPE_ARRAY || type == ASTYPE_MIXEDARRAY ||
+ if (type == ASTYPE_ARRAY || type == ASTYPE_MIXEDARRAY ||
type == ASTYPE_OBJECT)
state->parsingDepth--;
}
static struct EXTRACTOR_Keywords *
-handleMetaBody(const unsigned char *data, size_t len,
+handleMetaBody(const unsigned char *data, size_t len,
FLVStreamInfo *stinfo,
- struct EXTRACTOR_Keywords *prev)
+ struct EXTRACTOR_Keywords *prev)
{
AMFParserHandler handler;
FLVMetaParserState pstate;
@@ -843,9 +843,9 @@
};
static struct EXTRACTOR_Keywords *
-handleAudioBody(const unsigned char *data, size_t len,
+handleAudioBody(const unsigned char *data, size_t len,
FLVStreamInfo *stinfo,
- struct EXTRACTOR_Keywords *prev)
+ struct EXTRACTOR_Keywords *prev)
{
stinfo->audioChannels = *data & 0x01;
stinfo->audioSampleBits = (*data & 0x02) >> 1;
@@ -878,9 +878,9 @@
};
static struct EXTRACTOR_Keywords *
-handleVideoBody(const unsigned char *data, size_t len,
+handleVideoBody(const unsigned char *data, size_t len,
FLVStreamInfo *stinfo,
- struct EXTRACTOR_Keywords *prev)
+ struct EXTRACTOR_Keywords *prev)
{
int codecId, frameType;
@@ -938,7 +938,7 @@
if (separated_coeff || !filter_header) {
data += 2;
}
- /* XXX encoded/displayed dimensions might vary, but which are the
+ /* XXX encoded/displayed dimensions might vary, but which are the
* right ones? */
stinfo->videoWidth = (data[3]*16) - (dim_adj>>4);
stinfo->videoHeight = (data[2]*16) - (dim_adj&0x0F);
@@ -968,7 +968,7 @@
if ((ptr + header.bodyLength) > end)
return -1;
- switch (header.type)
+ switch (header.type)
{
case FLV_TAG_TYPE_AUDIO:
head = handleAudioBody(ptr, header.bodyLength, stinfo, head);
@@ -984,7 +984,7 @@
}
ptr += header.bodyLength;
-
+
*list = head;
*data = ptr;
return 0;
@@ -1038,7 +1038,7 @@
n += snprintf(s+n, len-n, "%.4f kbps", stinfo->videoDataRate);
}
- if (n == 0)
+ if (n == 0)
return NULL;
return strdup(s);
}
@@ -1058,7 +1058,7 @@
if (n > 0)
n += snprintf(s+n, len-n, ", ");
if (n < len)
- n += snprintf(s+n, len-n, "%s",
+ n += snprintf(s+n, len-n, "%s",
FLVAudioSampleSizes[stinfo->audioSampleBits]);
}
@@ -1066,7 +1066,7 @@
if (n > 0)
n += snprintf(s+n, len-n, ", ");
if (n < len)
- n += snprintf(s+n, len-n, "%s",
+ n += snprintf(s+n, len-n, "%s",
FLVAudioChannels[stinfo->audioChannels]);
}
@@ -1085,7 +1085,7 @@
n += snprintf(s+n, len-n, "%.4f kbps", stinfo->audioDataRate);
}
- if (n == 0)
+ if (n == 0)
return NULL;
return strdup(s);
}
Modified: Extractor/src/plugins/gifextractor.c
===================================================================
--- Extractor/src/plugins/gifextractor.c 2008-11-16 09:48:46 UTC (rev
7915)
+++ Extractor/src/plugins/gifextractor.c 2008-11-16 12:22:53 UTC (rev
7916)
@@ -201,7 +201,7 @@
if (size < GIF_HEADER_SIZE)
return prev;
- cat_unpack (data, GIF_HEADER_SPEC, GIF_HEADER_FIELDS (&header));
+ EXTRACTOR_common_cat_unpack (data, GIF_HEADER_SPEC, GIF_HEADER_FIELDS
(&header));
if (0 != strncmp (&header.gif[0], "GIF", 3))
return prev;
if (0 != strncmp (&header.version[0], "89a", 3))
@@ -222,7 +222,7 @@
{
case ',': /* image descriptor block */
PRINT ("skipping local color map %d\n", pos);
- cat_unpack (&data[pos],
+ EXTRACTOR_common_cat_unpack (&data[pos],
GIF_DESCRIPTOR_SPEC, GIF_DESCRIPTOR_FIELDS (&gd));
pos = skipLocalColorMap (data, pos, size, &gd);
break;
Modified: Extractor/src/plugins/htmlextractor.c
===================================================================
--- Extractor/src/plugins/htmlextractor.c 2008-11-16 09:48:46 UTC (rev
7915)
+++ Extractor/src/plugins/htmlextractor.c 2008-11-16 12:22:53 UTC (rev
7916)
@@ -421,7 +421,7 @@
if (tmp != NULL)
{
prev = addKeyword (tagmap[i].type,
- convertToUtf8 (tmp,
+ EXTRACTOR_common_convert_to_utf8 (tmp,
strlen (tmp), charset), prev);
free (tmp);
}
@@ -434,7 +434,7 @@
t = tags;
if (tagMatch ("title", t->tagStart, t->tagEnd))
prev = addKeyword (EXTRACTOR_TITLE,
- convertToUtf8 (t->dataStart,
+ EXTRACTOR_common_convert_to_utf8 (t->dataStart,
t->dataEnd - t->dataStart,
charset), prev);
tags = t->next;
Modified: Extractor/src/plugins/id3v23extractor.c
===================================================================
--- Extractor/src/plugins/id3v23extractor.c 2008-11-16 09:48:46 UTC (rev
7915)
+++ Extractor/src/plugins/id3v23extractor.c 2008-11-16 12:22:53 UTC (rev
7916)
@@ -184,17 +184,17 @@
switch (data[pos + 10])
{
case 0x00:
- word = convertToUtf8 ((const char *) &data[pos + 11],
+ word = EXTRACTOR_common_convert_to_utf8 ((const char *)
&data[pos + 11],
csize, "ISO-8859-1");
break;
case 0x01:
- word = convertToUtf8 ((const char *) &data[pos + 11],
+ word = EXTRACTOR_common_convert_to_utf8 ((const char *)
&data[pos + 11],
csize, "UCS-2");
break;
default:
/* bad encoding byte,
try to convert from iso-8859-1 */
- word = convertToUtf8 ((const char *) &data[pos + 11],
+ word = EXTRACTOR_common_convert_to_utf8 ((const char *)
&data[pos + 11],
csize, "ISO-8859-1");
break;
}
Modified: Extractor/src/plugins/id3v24extractor.c
===================================================================
--- Extractor/src/plugins/id3v24extractor.c 2008-11-16 09:48:46 UTC (rev
7915)
+++ Extractor/src/plugins/id3v24extractor.c 2008-11-16 12:22:53 UTC (rev
7916)
@@ -184,15 +184,15 @@
switch (data[pos + 10])
{
case 0x00:
- word = convertToUtf8 ((const char *) &data[pos + 11],
+ word = EXTRACTOR_common_convert_to_utf8 ((const char *)
&data[pos + 11],
csize, "ISO-8859-1");
break;
case 0x01:
- word = convertToUtf8 ((const char *) &data[pos + 11],
+ word = EXTRACTOR_common_convert_to_utf8 ((const char *)
&data[pos + 11],
csize, "UTF-16");
break;
case 0x02:
- word = convertToUtf8 ((const char *) &data[pos + 11],
+ word = EXTRACTOR_common_convert_to_utf8 ((const char *)
&data[pos + 11],
csize, "UTF-16BE");
break;
case 0x03:
@@ -203,7 +203,7 @@
default:
/* bad encoding byte,
try to convert from iso-8859-1 */
- word = convertToUtf8 ((const char *) &data[pos + 11],
+ word = EXTRACTOR_common_convert_to_utf8 ((const char *)
&data[pos + 11],
csize, "ISO-8859-1");
break;
}
Modified: Extractor/src/plugins/id3v2extractor.c
===================================================================
--- Extractor/src/plugins/id3v2extractor.c 2008-11-16 09:48:46 UTC (rev
7915)
+++ Extractor/src/plugins/id3v2extractor.c 2008-11-16 12:22:53 UTC (rev
7916)
@@ -131,17 +131,17 @@
switch (data[pos + 6])
{
case 0x00:
- word = convertToUtf8 ((const char *) &data[pos + 7],
+ word = EXTRACTOR_common_convert_to_utf8 ((const char *)
&data[pos + 7],
csize, "ISO-8859-1");
break;
case 0x01:
- word = convertToUtf8 ((const char *) &data[pos + 7],
+ word = EXTRACTOR_common_convert_to_utf8 ((const char *)
&data[pos + 7],
csize, "UCS-2");
break;
default:
/* bad encoding byte,
try to convert from iso-8859-1 */
- word = convertToUtf8 ((const char *) &data[pos + 7],
+ word = EXTRACTOR_common_convert_to_utf8 ((const char *)
&data[pos + 7],
csize, "ISO-8859-1");
break;
}
Modified: Extractor/src/plugins/mp3extractor.c
===================================================================
--- Extractor/src/plugins/mp3extractor.c 2008-11-16 09:48:46 UTC (rev
7915)
+++ Extractor/src/plugins/mp3extractor.c 2008-11-16 12:22:53 UTC (rev
7916)
@@ -290,19 +290,19 @@
return INVALID_ID3;
pos += 3;
- id3->title = convertToUtf8 (pos, 30, "ISO-8859-1");
+ id3->title = EXTRACTOR_common_convert_to_utf8 (pos, 30, "ISO-8859-1");
trim (id3->title);
pos += 30;
- id3->artist = convertToUtf8 (pos, 30, "ISO-8859-1");
+ id3->artist = EXTRACTOR_common_convert_to_utf8 (pos, 30, "ISO-8859-1");
trim (id3->artist);
pos += 30;
- id3->album = convertToUtf8 (pos, 30, "ISO-8859-1");
+ id3->album = EXTRACTOR_common_convert_to_utf8 (pos, 30, "ISO-8859-1");
trim (id3->album);
pos += 30;
- id3->year = convertToUtf8 (pos, 4, "ISO-8859-1");
+ id3->year = EXTRACTOR_common_convert_to_utf8 (pos, 4, "ISO-8859-1");
trim (id3->year);
pos += 4;
- id3->comment = convertToUtf8 (pos, 30, "ISO-8859-1");
+ id3->comment = EXTRACTOR_common_convert_to_utf8 (pos, 30, "ISO-8859-1");
trim (id3->comment);
if ( (pos[28] == '\0') &&
(pos[29] != '\0') )
@@ -419,14 +419,14 @@
idx_num = (mpeg_ver - 1) * 3 + layer - 1;
else
idx_num = 2 + layer;
- bitrate = 1000 * bitrate_table[(header >> MPA_BITRATE_SHIFT) &
+ bitrate = 1000 * bitrate_table[(header >> MPA_BITRATE_SHIFT) &
MPA_BITRATE_MASK][idx_num];
if (bitrate < 0)
{
frames--;
break;
} /*error in header */
- sample_rate = freq_table[(header >> MPA_FREQ_SHIFT) &
+ sample_rate = freq_table[(header >> MPA_FREQ_SHIFT) &
MPA_FREQ_MASK][mpeg_ver - 1];
if (sample_rate < 0)
{
@@ -468,17 +468,17 @@
prev = addkword (prev, mpeg_versions[mpeg_ver-1], EXTRACTOR_RESOURCE_TYPE);
format = malloc (512);
- snprintf (format, 512, "%s %s audio, %d kbps (%s), %d Hz, %s, %s, %s",
+ snprintf (format, 512, "%s %s audio, %d kbps (%s), %d Hz, %s, %s, %s",
mpeg_versions[mpeg_ver-1],
layer_names[layer-1],
- avg_bps,
- vbr_flag ? _("VBR") : _("CBR"),
- sample_rate,
+ avg_bps,
+ vbr_flag ? _("VBR") : _("CBR"),
+ sample_rate,
channel_modes[ch],
- copyright_flag ? _("copyright") : _("no copyright"),
+ copyright_flag ? _("copyright") : _("no copyright"),
original_flag ? _("original") : _("copy") );
prev = addkword (prev, format, EXTRACTOR_FORMAT);
- snprintf (format, 512, "%dm%02d",
+ snprintf (format, 512, "%dm%02d",
length / 60, length % 60);
prev = addkword (prev, format, EXTRACTOR_DURATION);
free (format);
@@ -522,7 +522,7 @@
strlen (info.album) + 6);
sprintf (word, "%s: %s (%s)", info.artist, info.title, info.album);
klist = addkword (klist, word, EXTRACTOR_DESCRIPTION);
-
+
free (word);
free (info.title);
free (info.year);
Modified: Extractor/src/plugins/ole2/ole2extractor.c
===================================================================
--- Extractor/src/plugins/ole2/ole2extractor.c 2008-11-16 09:48:46 UTC (rev
7915)
+++ Extractor/src/plugins/ole2/ole2extractor.c 2008-11-16 12:22:53 UTC (rev
7916)
@@ -27,7 +27,7 @@
#include "platform.h"
#include "extractor.h"
-#include "../convert.h"
+#include "convert.h"
#include <glib-object.h>
#include <string.h>
@@ -394,14 +394,14 @@
// there are n strings, so n/2 revisions (author & file)
nRev = (lbuffer[2] + (lbuffer[3] << 8)) / 2;
where = 6;
- for (i=0; i < nRev; i++) {
+ for (i=0; i < nRev; i++) {
if (where >= lcbSttbSavedBy)
break;
length = lbuffer[where++];
if ( (where + 2 * length + 2 >= lcbSttbSavedBy) ||
(where + 2 * length + 2 <= where) )
break;
- author = convertToUtf8((const char*) &lbuffer[where],
+ author = EXTRACTOR_common_convert_to_utf8((const char*) &lbuffer[where],
length * 2,
"UTF-16BE");
where += length * 2 + 1;
@@ -411,9 +411,9 @@
free(author);
break;
}
- filename = convertToUtf8((const char*) &lbuffer[where],
+ filename = EXTRACTOR_common_convert_to_utf8((const char*) &lbuffer[where],
length * 2,
- "UTF-16BE");
+ "UTF-16BE");
where += length * 2 + 1;
rbuf = malloc(strlen(author) + strlen(filename) + 512);
snprintf(rbuf, 512 + strlen(author) + strlen(filename),
Deleted: Extractor/src/plugins/pack.c
===================================================================
--- Extractor/src/plugins/pack.c 2008-11-16 09:48:46 UTC (rev 7915)
+++ Extractor/src/plugins/pack.c 2008-11-16 12:22:53 UTC (rev 7916)
@@ -1,516 +0,0 @@
-/*
-Catlib Copyright Notice
-
-The author of this software is Christopher Adam Telfer
-Copyright (c) 1998, 1999, 2000, 2001, 2002
-by Christopher Adam Telfer. All Rights Reserved.
-
-Permission to use, copy, modify, and distribute this software for any
-purpose without fee is hereby granted, provided that the above copyright
-notice, this paragraph, and the following two paragraphs appear in all
-copies, modifications, and distributions.
-
-IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
-SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
-ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
-THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF
-ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". THE AUTHOR HAS NO
-OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
-MODIFICATIONS.
-
-*/
-
-#include "platform.h"
-#include "pack.h"
-
-typedef unsigned char byte;
-typedef unsigned short half;
-typedef unsigned int word;
-typedef signed char sbyte;
-typedef signed short shalf;
-typedef signed int sword;
-
-
-/*
- "bhwAcslPBHWCSL"
-
- Small letters: do not convert (not implemented for arrays and P)
- Captial letters: convert from network byte order to host byte order
-
- b - byte
- h - half-word
- w - word
- a - array (32-byte unsigned long + that many bytes)
- c - signed 8 bit value
- s - signed 16 bit value
- l - signed 32 bit value
- p - (unpack only) value is a pointer to a pointer. Generate the buffer
- to hold the data.
-
- prefixing with a number K means that the argument will be an array of K
- of the arguments specified by the letter
- */
-
-int
-cat_pack (void *buf, const char *fmt, ...)
-{
- va_list ap;
- word blen, val;
- int npacked;
- unsigned int nreps, i;
- byte *bp, *bytep;
- half *halfp;
- word *wordp;
- void *arr;
- struct cat_bvec *cbvp;
- char *cp;
-
- va_start (ap, fmt);
-
- npacked = 0;
- bp = (byte *) buf;
-
- while (*fmt)
- {
- nreps = 0;
-
- if (isdigit (*fmt))
- {
- /* We use cp instead of fmt to keep the 'const' qualifier of fmt */
- nreps = strtoul (fmt, &cp, 0);
- fmt = cp;
- }
-
- switch (*fmt)
- {
- case 'B':
- case 'b':
- case 'C':
- case 'c':
- if (!nreps)
- {
- *bp++ = va_arg (ap, int);
- npacked += 1;
- }
- else
- {
- bytep = va_arg (ap, byte *);
- for (i = 0; i < nreps; ++i)
- {
- *bp++ = bytep[i];
- npacked += 1;
- }
- }
- break;
-
- case 'h':
- case 's':
- if (!nreps)
- {
- val = va_arg (ap, int);
- *bp++ = val & 0xFF;
- *bp++ = val >> 8;
- npacked += 2;
- }
- else
- {
- halfp = va_arg (ap, half *);
- for (i = 0; i < nreps; ++i)
- {
- val = halfp[i];
- *bp++ = val & 0xFF;
- *bp++ = val >> 8;
- npacked += 2;
- }
- }
- break;
-
- case 'H':
- case 'S':
- if (!nreps)
- {
- val = va_arg (ap, int);
- *bp++ = val >> 8;
- *bp++ = val & 0xFF;
- npacked += 2;
- }
- else
- {
- halfp = va_arg (ap, half *);
- for (i = 0; i < nreps; ++i)
- {
- val = halfp[i];
- *bp++ = val >> 8;
- *bp++ = val & 0xFF;
- npacked += 2;
- }
- }
- break;
-
- case 'l':
- case 'w':
- if (!nreps)
- {
- val = va_arg (ap, word);
- *bp++ = val & 0xFF;
- *bp++ = val >> 8;
- *bp++ = val >> 16;
- *bp++ = val >> 24;
- npacked += 4;
- }
- else
- {
- wordp = va_arg (ap, word *);
- for (i = 0; i < nreps; ++i)
- {
- val = wordp[i];
- *bp++ = val & 0xFF;
- *bp++ = val >> 8;
- *bp++ = val >> 16;
- *bp++ = val >> 24;
- npacked += 4;
- }
- }
- break;
-
- case 'L':
- case 'W':
- if (!nreps)
- {
- val = va_arg (ap, word);
- *bp++ = val >> 24;
- *bp++ = val >> 16;
- *bp++ = val >> 8;
- *bp++ = val & 0xFF;
- npacked += 4;
- }
- else
- {
- wordp = va_arg (ap, word *);
- for (i = 0; i < nreps; ++i)
- {
- val = wordp[i];
- *bp++ = val >> 24;
- *bp++ = val >> 16;
- *bp++ = val >> 8;
- *bp++ = val & 0xFF;
- npacked += 4;
- }
- }
- break;
-
- case 'A':
- if (!nreps)
- {
- blen = va_arg (ap, word);
- arr = va_arg (ap, void *);
- *bp++ = blen >> 24;
- *bp++ = blen >> 16;
- *bp++ = blen >> 8;
- *bp++ = blen & 0xFF;
- memmove (bp, arr, blen);
- bp += blen;
- npacked += blen + 4; /* +4 for the 32 bits of length field
*/
- }
- else
- {
- cbvp = va_arg (ap, struct cat_bvec *);
- for (i = 0; i < nreps; ++i)
- {
- blen = cbvp[i].len;
- arr = cbvp[i].data;
- *bp++ = blen >> 24;
- *bp++ = blen >> 16;
- *bp++ = blen >> 8;
- *bp++ = blen & 0xFF;
- memmove (bp, arr, blen);
- bp += blen;
- npacked += blen + 4; /* see above */
- }
- }
- break;
-
- default:
- va_end (ap);
- return -1;
- }
- ++fmt;
- }
-
- va_end (ap);
- return npacked;
-}
-
-
-
-int
-cat_unpack (const void *buf, const char *fmt, ...)
-{
- va_list ap;
- word maxlen, len, *wordp;
- void *arr;
- byte *bp, *bytep, *newbuf;
- half *halfp;
- sbyte *sbytep;
- shalf *shalfp;
- sword *swordp;
- int npacked;
- unsigned int nreps, i, isnonprefixed = 1; /* used for 'a' types only */
- struct cat_bvec *cbvp;
- char *cp;
-
- bp = (byte *) buf;
- npacked = 0;
-
- va_start (ap, fmt);
-
- while (*fmt)
- {
- nreps = 1;
-
- if (isdigit (*fmt))
- {
- /* We use cp instead of format to keep the 'const' qualifier of fmt
*/
- nreps = strtoul (fmt, &cp, 0);
- fmt = cp;
- if (*fmt == 'a')
- isnonprefixed = 0;
- }
-
- switch (*fmt)
- {
- case 'B':
- case 'b':
- bytep = va_arg (ap, byte *);
- for (i = 0; i < nreps; ++i)
- {
- *bytep = *bp++;
- ++bytep;
- npacked += 1;
- }
- break;
-
-
-
- case 'h':
- halfp = va_arg (ap, half *);
- for (i = 0; i < nreps; ++i)
- {
- *halfp = *bp++;
- *halfp |= *bp++ << 8;
- ++halfp;
- npacked += 2;
- }
- break;
-
- case 'H':
- halfp = va_arg (ap, half *);
- for (i = 0; i < nreps; ++i)
- {
- *halfp = *bp++ << 8;
- *halfp |= *bp++;
- ++halfp;
- npacked += 2;
- }
- break;
-
-
- case 'w':
- wordp = va_arg (ap, word *);
- for (i = 0; i < nreps; ++i)
- {
- *wordp = *bp++;
- *wordp |= *bp++ << 8;
- *wordp |= *bp++ << 16;
- *wordp |= *bp++ << 24;
- ++wordp;
- npacked += 4;
- }
- break;
-
- case 'W':
- wordp = va_arg (ap, word *);
- for (i = 0; i < nreps; ++i)
- {
- *wordp = *bp++ << 24;
- *wordp |= *bp++ << 16;
- *wordp |= *bp++ << 8;
- *wordp |= *bp++;
- ++wordp;
- npacked += 4;
- }
- break;
-
- case 'A':
- if (isnonprefixed)
- {
- maxlen = va_arg (ap, word);
- arr = va_arg (ap, void *);
-
- len = *bp++ << 24;
- len |= *bp++ << 16;
- len |= *bp++ << 8;
- len |= *bp++;
-
- if (len > maxlen)
- {
- va_end (ap);
- return -1;
- }
-
- memmove (arr, bp, len);
- bp += len;
-
- npacked += len;
- }
- else
- {
- cbvp = va_arg (ap, struct cat_bvec *);
- for (i = 0; i < nreps; ++i)
- {
- maxlen = cbvp->len;
- arr = cbvp->data;
-
- len = *bp++ << 24;
- len |= *bp++ << 16;
- len |= *bp++ << 8;
- len |= *bp++;
-
- if (len > maxlen)
- return -1;
-
- memmove (arr, bp, len);
- cbvp->len = len;
- bp += len;
-
- ++cbvp;
- npacked += len;
- }
- isnonprefixed = 1;
- }
- break;
-
- case 'C':
- case 'c':
- sbytep = va_arg (ap, sbyte *);
- for (i = 0; i < nreps; ++i)
- {
- *sbytep = *bp++;
-
- if ((sizeof (sbyte) > 1) && (*sbytep & 0x80))
- *sbytep |= (~0) << ((sizeof (sbyte) - 1) * 8);
-
- ++sbytep;
- npacked += 1;
- }
- break;
-
-
- case 's':
- shalfp = va_arg (ap, shalf *);
- for (i = 0; i < nreps; ++i)
- {
- *shalfp = *bp++;
- *shalfp |= *bp++ << 8;
-
- if ((sizeof (shalf) > 2) && (*shalfp & 0x8000))
- *shalfp |= (~0) << ((sizeof (shalf) - 2) * 8);
-
- ++shalfp;
- npacked += 2;
- }
- break;
-
- case 'S':
- shalfp = va_arg (ap, shalf *);
- for (i = 0; i < nreps; ++i)
- {
- *shalfp = *bp++ << 8;
- *shalfp |= *bp++;
-
- if ((sizeof (shalf) > 2) && (*shalfp & 0x8000))
- *shalfp |= (~0) << ((sizeof (shalf) - 2) * 8);
-
- ++shalfp;
- npacked += 2;
- }
- break;
-
- case 'l':
- swordp = va_arg (ap, sword *);
- for (i = 0; i < nreps; ++i)
- {
- *swordp = *bp++;
- *swordp |= *bp++ << 8;
- *swordp |= *bp++ << 16;
- *swordp |= *bp++ << 24;
-
- if ((sizeof (swordp) > 4) && (*swordp & 0x80000000))
- *swordp |= (~0) << ((sizeof (sword) - 4) * 8);
-
- ++swordp;
- npacked += 4;
- }
- break;
-
- case 'L':
- swordp = va_arg (ap, sword *);
- for (i = 0; i < nreps; ++i)
- {
- *swordp = *bp++ << 24;
- *swordp |= *bp++ << 16;
- *swordp |= *bp++ << 8;
- *swordp |= *bp++;
-
- if ((sizeof (swordp) > 4) && (*swordp & 0x80000000))
- *swordp |= (~0) << ((sizeof (sword) - 4) * 8);
-
- ++swordp;
- npacked += 4;
- }
- break;
-
- case 'P':
- cbvp = va_arg (ap, struct cat_bvec *);
- for (i = 0; i < nreps; ++i)
- {
- len = *bp++ << 24;
- len |= *bp++ << 16;
- len |= *bp++ << 8;
- len |= *bp++;
-
- newbuf = (byte *) malloc (len);
-
- if (!newbuf)
- {
- int j;
- for (j = 0; j < i; j++)
- free (cbvp[i].data);
- va_end (ap);
- return -1;
- }
-
- memmove (newbuf, bp, len);
- cbvp[i].data = newbuf;
- cbvp[i].len = len;
-
- bp += len;
- npacked += len;
- }
- break;
-
- default:
- va_end (ap);
- return -1;
- }
-
- ++fmt;
- }
-
- va_end (ap);
- return 0;
-}
Deleted: Extractor/src/plugins/pack.h
===================================================================
--- Extractor/src/plugins/pack.h 2008-11-16 09:48:46 UTC (rev 7915)
+++ Extractor/src/plugins/pack.h 2008-11-16 12:22:53 UTC (rev 7916)
@@ -1,59 +0,0 @@
-/*
-Catlib Copyright Notice
-
-The author of this software is Christopher Adam Telfer
-Copyright (c) 1998, 1999, 2000, 2001, 2002
-by Christopher Adam Telfer. All Rights Reserved.
-
-Permission to use, copy, modify, and distribute this software for any
-purpose without fee is hereby granted, provided that the above copyright
-notice, this paragraph, and the following two paragraphs appear in all
-copies, modifications, and distributions.
-
-IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
-SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
-ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
-THE AUTHOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-THE AUTHOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT
-LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE. THE SOFTWARE AND ACCOMPANYING DOCUMENTATION, IF
-ANY, PROVIDED HEREUNDER IS PROVIDED "AS IS". THE AUTHOR HAS NO
-OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
-MODIFICATIONS.
-
-
-*/
-
-#ifndef __CAT_PACK_H
-#define __CAT_PACK_H
-
-/*
- "bhwAcslPBHWCSL"
-
- Small letters: do not convert (not implemented for arrays and P)
- Captial letters: convert from network byte order to host byte order
-
- b - byte
- h - half-word
- w - word
- a - array (32-byte unsigned long + that many bytes)
- c - signed 8 bit value
- s - signed 16 bit value
- l - signed 32 bit value
- p - (unpack only) value is a pointer to a pointer. Generate the buffer
- to hold the data.
- */
-
-int cat_pack(void * buf, const char *fmt, ... );
-
-int cat_unpack(const void * buf, const char *fmt, ... );
-
-struct cat_bvec {
- unsigned long len;
- void * data;
-};
-
-#endif /* __CAT_PACK_H */
-
-
Modified: Extractor/src/plugins/pdf/pdfextractor.cc
===================================================================
--- Extractor/src/plugins/pdf/pdfextractor.cc 2008-11-16 09:48:46 UTC (rev
7915)
+++ Extractor/src/plugins/pdf/pdfextractor.cc 2008-11-16 12:22:53 UTC (rev
7916)
@@ -24,7 +24,7 @@
#include "platform.h"
#include "extractor.h"
-#include "../convert.h"
+#include "convert.h"
#include <math.h>
#include "parseargs.h"
@@ -74,7 +74,7 @@
(((unsigned char)s[1]) & 0xff) == 0xff) {
char * result;
- result = convertToUtf8((const char*) &s[2], s1->getLength() - 2,
"UTF-16BE");
+ result = EXTRACTOR_common_convert_to_utf8((const char*) &s[2],
s1->getLength() - 2, "UTF-16BE");
next = addKeyword(type,
result,
next);
@@ -108,7 +108,7 @@
if (0 < len) {
next = addKeyword(type,
- convertToUtf8(s, len,
+ EXTRACTOR_common_convert_to_utf8(s, len,
"ISO-8859-1"),
next);
}
@@ -135,7 +135,7 @@
/* isUnicode */
char * result;
- result = convertToUtf8((const char*)&s[2], s1->getLength() - 2,
"UTF-16BE");
+ result = EXTRACTOR_common_convert_to_utf8((const char*)&s[2],
s1->getLength() - 2, "UTF-16BE");
next = addKeyword(type,
result,
next);
Modified: Extractor/src/plugins/pdfextractor.c
===================================================================
--- Extractor/src/plugins/pdfextractor.c 2008-11-16 09:48:46 UTC (rev
7915)
+++ Extractor/src/plugins/pdfextractor.c 2008-11-16 12:22:53 UTC (rev
7916)
@@ -206,11 +206,11 @@
/* TODO: extend glibc with
character set that corresponds to
Adobe's extended ISOLATIN1 encoding! */
- return convertToUtf8 ((const char *) in, size, "CSISOLATIN1");
+ return EXTRACTOR_common_convert_to_utf8 ((const char *) in, size,
"CSISOLATIN1");
}
else
{
- return convertToUtf8 ((const char *) &in[2], size - 2, "UTF-16BE");
+ return EXTRACTOR_common_convert_to_utf8 ((const char *) &in[2], size -
2, "UTF-16BE");
}
}
Modified: Extractor/src/plugins/pngextractor.c
===================================================================
--- Extractor/src/plugins/pngextractor.c 2008-11-16 09:48:46 UTC (rev
7915)
+++ Extractor/src/plugins/pngextractor.c 2008-11-16 12:22:53 UTC (rev
7916)
@@ -115,7 +115,7 @@
off = stnlen (data, length) + 1;
if (off >= length)
return prev; /* failed to find '\0' */
- keyword = convertToUtf8 (&data[off], length - off, "ISO-8859-1");
+ keyword = EXTRACTOR_common_convert_to_utf8 (&data[off], length - off,
"ISO-8859-1");
i = 0;
while (tagmap[i].name != NULL)
{
@@ -275,7 +275,7 @@
if (ret != Z_BUF_ERROR)
return prev; /* unknown error, abort */
}
- keyword = convertToUtf8 (buf, bufLen, "ISO-8859-1");
+ keyword = EXTRACTOR_common_convert_to_utf8 (buf, bufLen, "ISO-8859-1");
free (buf);
i = 0;
while (tagmap[i].name != NULL)
Modified: Extractor/src/plugins/tiffextractor.c
===================================================================
--- Extractor/src/plugins/tiffextractor.c 2008-11-16 09:48:46 UTC (rev
7915)
+++ Extractor/src/plugins/tiffextractor.c 2008-11-16 12:22:53 UTC (rev
7916)
@@ -129,7 +129,7 @@
#if __BYTE_ORDER == __BIG_ENDIAN
byteOrder = 1 - byteOrder;
#endif
- cat_unpack (data, TIFF_HEADER_SPECS[byteOrder], TIFF_HEADER_FIELDS (&hdr));
+ EXTRACTOR_common_cat_unpack (data, TIFF_HEADER_SPECS[byteOrder],
TIFF_HEADER_FIELDS (&hdr));
if (hdr.fourty_two != 42)
return prev; /* can not be tiff */
if (hdr.ifd_offset + 6 > size)
@@ -159,7 +159,7 @@
DIRECTORY_ENTRY entry;
off = current_ifd + 2 + DIRECTORY_ENTRY_SIZE * i;
- cat_unpack (&data[off],
+ EXTRACTOR_common_cat_unpack (&data[off],
DIRECTORY_ENTRY_SPECS[byteOrder],
DIRECTORY_ENTRY_FIELDS (&entry));
switch (entry.tag)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r7916 - in Extractor: . doc src src/common src/plugins src/plugins/ole2 src/plugins/pdf,
gnunet <=