[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r5368 - in Extractor: . doc doc/lj libltdl src/plugins src/
From: |
gnunet |
Subject: |
[GNUnet-SVN] r5368 - in Extractor: . doc doc/lj libltdl src/plugins src/plugins/hash src/plugins/language src/plugins/printable src/plugins/rpm src/plugins/thumbnail src/test |
Date: |
Sun, 29 Jul 2007 02:35:50 -0600 (MDT) |
Author: grothoff
Date: 2007-07-29 02:35:49 -0600 (Sun, 29 Jul 2007)
New Revision: 5368
Modified:
Extractor/ChangeLog
Extractor/doc/demux_asf.c
Extractor/doc/demux_nsf.c
Extractor/doc/demux_qt.c
Extractor/doc/demux_wc3movie.c
Extractor/doc/flacfile.c
Extractor/doc/lj/addkeyword.c
Extractor/doc/lj/minimal.c
Extractor/doc/lj/plugin.c
Extractor/doc/lj/signature.c
Extractor/libltdl/ltdl.c
Extractor/src/plugins/asfextractor.c
Extractor/src/plugins/convert.c
Extractor/src/plugins/debextractor.c
Extractor/src/plugins/dviextractor.c
Extractor/src/plugins/elfextractor.c
Extractor/src/plugins/filenameextractor.c
Extractor/src/plugins/gifextractor.c
Extractor/src/plugins/hash/md5extractor.c
Extractor/src/plugins/hash/rmd160extractor.c
Extractor/src/plugins/hash/sha1extractor.c
Extractor/src/plugins/htmlextractor.c
Extractor/src/plugins/id3v23extractor.c
Extractor/src/plugins/id3v24extractor.c
Extractor/src/plugins/id3v2extractor.c
Extractor/src/plugins/jpegextractor.c
Extractor/src/plugins/language/language-compiler.c
Extractor/src/plugins/language/languageextractor.c
Extractor/src/plugins/lowerextractor.c
Extractor/src/plugins/manextractor.c
Extractor/src/plugins/mimeextractor.c
Extractor/src/plugins/mp3extractor.c
Extractor/src/plugins/mpegextractor.c
Extractor/src/plugins/nsfeextractor.c
Extractor/src/plugins/nsfextractor.c
Extractor/src/plugins/oggextractor.c
Extractor/src/plugins/pack.c
Extractor/src/plugins/pdfextractor.c
Extractor/src/plugins/pngextractor.c
Extractor/src/plugins/printable/dictionary-builder.c
Extractor/src/plugins/psextractor.c
Extractor/src/plugins/qtextractor.c
Extractor/src/plugins/realextractor.c
Extractor/src/plugins/riffextractor.c
Extractor/src/plugins/rpm/rpmextractor.c
Extractor/src/plugins/sidextractor.c
Extractor/src/plugins/splitextractor.c
Extractor/src/plugins/tarextractor.c
Extractor/src/plugins/templateextractor.c
Extractor/src/plugins/thumbnail/thumbnailextractor.c
Extractor/src/plugins/tiffextractor.c
Extractor/src/plugins/translitextractor.c
Extractor/src/plugins/wavextractor.c
Extractor/src/plugins/zipextractor.c
Extractor/src/test/keywordlisttest.c
Extractor/src/test/multiload.c
Extractor/src/test/plugintest.c
Extractor/src/test/trivialtest.c
Log:
splitfix
Modified: Extractor/ChangeLog
===================================================================
--- Extractor/ChangeLog 2007-07-29 08:04:12 UTC (rev 5367)
+++ Extractor/ChangeLog 2007-07-29 08:35:49 UTC (rev 5368)
@@ -1,3 +1,6 @@
+Sun Jul 29 02:30:40 MDT 2007
+ Added escape (\n) handling to split extractor.
+
Wed Jul 4 17:36:53 MDT 2007
Fixed problem with newer versions of libgsf.
Fixed problem with automake 1.10 not setting MKDIR_P.
Modified: Extractor/doc/demux_asf.c
===================================================================
--- Extractor/doc/demux_asf.c 2007-07-29 08:04:12 UTC (rev 5367)
+++ Extractor/doc/demux_asf.c 2007-07-29 08:35:49 UTC (rev 5368)
@@ -61,173 +61,188 @@
#define PTS_AUDIO 0
#define PTS_VIDEO 1
-typedef struct {
- int num;
- int seq;
+typedef struct
+{
+ int num;
+ int seq;
- int frag_offset;
- int64_t timestamp;
- int ts_per_kbyte;
- int defrag;
+ int frag_offset;
+ int64_t timestamp;
+ int ts_per_kbyte;
+ int defrag;
- uint32_t buf_type;
- int stream_id;
- fifo_buffer_t *fifo;
+ uint32_t buf_type;
+ int stream_id;
+ fifo_buffer_t *fifo;
- uint8_t *buffer;
+ uint8_t *buffer;
} asf_stream_t;
-typedef struct demux_asf_s {
- demux_plugin_t demux_plugin;
+typedef struct demux_asf_s
+{
+ demux_plugin_t demux_plugin;
- xine_stream_t *stream;
+ xine_stream_t *stream;
- fifo_buffer_t *audio_fifo;
- fifo_buffer_t *video_fifo;
+ fifo_buffer_t *audio_fifo;
+ fifo_buffer_t *video_fifo;
- input_plugin_t *input;
+ input_plugin_t *input;
- int keyframe_found;
+ int keyframe_found;
- int seqno;
- uint32_t packet_size;
- uint8_t packet_flags;
- uint32_t data_size;
+ int seqno;
+ uint32_t packet_size;
+ uint8_t packet_flags;
+ uint32_t data_size;
- asf_stream_t streams[MAX_NUM_STREAMS];
- uint32_t bitrates[MAX_NUM_STREAMS];
- int num_streams;
- int num_audio_streams;
- int num_video_streams;
- int audio_stream;
- int video_stream;
- int audio_stream_id;
- int video_stream_id;
- int control_stream_id;
+ asf_stream_t streams[MAX_NUM_STREAMS];
+ uint32_t bitrates[MAX_NUM_STREAMS];
+ int num_streams;
+ int num_audio_streams;
+ int num_video_streams;
+ int audio_stream;
+ int video_stream;
+ int audio_stream_id;
+ int video_stream_id;
+ int control_stream_id;
- uint16_t wavex[1024];
- int wavex_size;
+ uint16_t wavex[1024];
+ int wavex_size;
- uint16_t bih[1024];
- int bih_size;
+ uint16_t bih[1024];
+ int bih_size;
- char title[512];
- char author[512];
- char copyright[512];
- char comment[512];
+ char title[512];
+ char author[512];
+ char copyright[512];
+ char comment[512];
- uint32_t length, rate;
+ uint32_t length, rate;
/* packet filling */
- int packet_size_left;
+ int packet_size_left;
/* frame rate calculations, discontinuity detection */
- int64_t last_pts[2];
- int32_t frame_duration;
- int send_newpts;
- int64_t last_frame_pts;
+ int64_t last_pts[2];
+ int32_t frame_duration;
+ int send_newpts;
+ int64_t last_frame_pts;
/* only for reading */
- uint32_t packet_padsize;
- int nb_frames;
- uint8_t frame_flag;
- uint8_t segtype;
- int frame;
+ uint32_t packet_padsize;
+ int nb_frames;
+ uint8_t frame_flag;
+ uint8_t segtype;
+ int frame;
- int status;
+ int status;
/* byte reordering from audio streams */
- int reorder_h;
- int reorder_w;
- int reorder_b;
+ int reorder_h;
+ int reorder_w;
+ int reorder_b;
- off_t header_size;
- int buf_flag_seek;
+ off_t header_size;
+ int buf_flag_seek;
/* first packet position */
- int64_t first_packet_pos;
+ int64_t first_packet_pos;
- int reference_mode;
-} demux_asf_t ;
+ int reference_mode;
+} demux_asf_t;
-typedef struct {
+typedef struct
+{
- demux_class_t demux_class;
+ demux_class_t demux_class;
/* class-wide, global variables here */
- xine_t *xine;
- config_values_t *config;
+ xine_t *xine;
+ config_values_t *config;
} demux_asf_class_t;
-static uint8_t get_byte (demux_asf_t *this) {
+static uint8_t
+get_byte (demux_asf_t * this)
+{
uint8_t buf;
- int i;
+ int i;
i = this->input->read (this->input, &buf, 1);
/* printf ("%02x ", buf); */
- if (i != 1) {
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_asf: end of data\n");
- this->status = DEMUX_FINISHED;
- }
+ if (i != 1)
+ {
+ if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
+ printf ("demux_asf: end of data\n");
+ this->status = DEMUX_FINISHED;
+ }
return buf;
}
-static uint16_t get_le16 (demux_asf_t *this) {
+static uint16_t
+get_le16 (demux_asf_t * this)
+{
uint8_t buf[2];
- int i;
+ int i;
i = this->input->read (this->input, buf, 2);
/* printf (" [%02x %02x] ", buf[0], buf[1]); */
- if (i != 2) {
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_asf: end of data\n");
- this->status = DEMUX_FINISHED;
- }
+ if (i != 2)
+ {
+ if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
+ printf ("demux_asf: end of data\n");
+ this->status = DEMUX_FINISHED;
+ }
return buf[0] | (buf[1] << 8);
}
-static uint32_t get_le32 (demux_asf_t *this) {
+static uint32_t
+get_le32 (demux_asf_t * this)
+{
uint8_t buf[4];
- int i;
+ int i;
i = this->input->read (this->input, buf, 4);
/* printf ("%02x %02x %02x %02x ", buf[0], buf[1], buf[2], buf[3]); */
- if (i != 4) {
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_asf: end of data\n");
- this->status = DEMUX_FINISHED;
- }
+ if (i != 4)
+ {
+ if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
+ printf ("demux_asf: end of data\n");
+ this->status = DEMUX_FINISHED;
+ }
return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24);
}
-static uint64_t get_le64 (demux_asf_t *this) {
+static uint64_t
+get_le64 (demux_asf_t * this)
+{
uint8_t buf[8];
- int i;
+ int i;
i = this->input->read (this->input, buf, 8);
- if (i != 8) {
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_asf: end of data\n");
- this->status = DEMUX_FINISHED;
- }
+ if (i != 8)
+ {
+ if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
+ printf ("demux_asf: end of data\n");
+ this->status = DEMUX_FINISHED;
+ }
return (uint64_t) buf[0]
| ((uint64_t) buf[1] << 8)
@@ -235,58 +250,67 @@
| ((uint64_t) buf[3] << 24)
| ((uint64_t) buf[4] << 32)
| ((uint64_t) buf[5] << 40)
- | ((uint64_t) buf[6] << 48)
- | ((uint64_t) buf[7] << 54) ;
+ | ((uint64_t) buf[6] << 48) | ((uint64_t) buf[7] << 54);
}
-static int get_guid (demux_asf_t *this) {
+static int
+get_guid (demux_asf_t * this)
+{
int i;
GUID g;
- g.v1 = get_le32(this);
- g.v2 = get_le16(this);
- g.v3 = get_le16(this);
- for(i = 0; i < 8; i++) {
- g.v4[i] = get_byte(this);
- }
+ g.v1 = get_le32 (this);
+ g.v2 = get_le16 (this);
+ g.v3 = get_le16 (this);
+ for (i = 0; i < 8; i++)
+ {
+ g.v4[i] = get_byte (this);
+ }
- for (i = 1; i < GUID_END; i++) {
- if (!memcmp(&g, &guids[i].guid, sizeof(GUID))) {
+ for (i = 1; i < GUID_END; i++)
+ {
+ if (!memcmp (&g, &guids[i].guid, sizeof (GUID)))
+ {
#ifdef LOG
- printf ("demux_asf: GUID: %s\n", guids[i].name);
+ printf ("demux_asf: GUID: %s\n", guids[i].name);
#endif
- return i;
+ return i;
+ }
}
- }
if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
printf ("demux_asf: unknown GUID: 0x%x, 0x%x, 0x%x, "
- "{ 0x%hx, 0x%hx, 0x%hx, 0x%hx, 0x%hx, 0x%hx, 0x%hx, 0x%hx }\n",
- g.v1, g.v2, g.v3,
- g.v4[0], g.v4[1], g.v4[2], g.v4[3], g.v4[4], g.v4[5], g.v4[6],
g.v4[7]);
+ "{ 0x%hx, 0x%hx, 0x%hx, 0x%hx, 0x%hx, 0x%hx, 0x%hx, 0x%hx }\n",
+ g.v1, g.v2, g.v3,
+ g.v4[0], g.v4[1], g.v4[2], g.v4[3], g.v4[4], g.v4[5], g.v4[6],
+ g.v4[7]);
return GUID_ERROR;
}
-static void get_str16_nolen(demux_asf_t *this, int len,
- char *buf, int buf_size) {
+static void
+get_str16_nolen (demux_asf_t * this, int len, char *buf, int buf_size)
+{
int c;
char *q;
q = buf;
- while (len > 0) {
- c = get_le16(this);
- if ((q - buf) < buf_size - 1)
- *q++ = c;
- len-=2;
- }
+ while (len > 0)
+ {
+ c = get_le16 (this);
+ if ((q - buf) < buf_size - 1)
+ *q++ = c;
+ len -= 2;
+ }
*q = '\0';
}
-static void asf_send_audio_header (demux_asf_t *this, int stream) {
+static void
+asf_send_audio_header (demux_asf_t * this, int stream)
+{
buf_element_t *buf;
- xine_waveformatex *wavex = (xine_waveformatex *) this->wavex ;
+ xine_waveformatex *wavex = (xine_waveformatex *) this->wavex;
if (!this->audio_fifo)
return;
@@ -294,7 +318,8 @@
buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
memcpy (buf->content, this->wavex, this->wavex_size);
- this->stream->stream_info[XINE_STREAM_INFO_AUDIO_FOURCC] = wavex->wFormatTag;
+ this->stream->stream_info[XINE_STREAM_INFO_AUDIO_FOURCC] =
+ wavex->wFormatTag;
#ifdef LOG
printf ("demux_asf: wavex header is %d bytes long\n", this->wavex_size);
@@ -302,7 +327,7 @@
buf->size = this->wavex_size;
buf->type = this->streams[stream].buf_type;
- buf->decoder_flags = BUF_FLAG_HEADER;
+ buf->decoder_flags = BUF_FLAG_HEADER;
buf->decoder_info[1] = wavex->nSamplesPerSec;
buf->decoder_info[2] = wavex->wBitsPerSample;
buf->decoder_info[3] = wavex->nChannels;
@@ -310,406 +335,490 @@
this->audio_fifo->put (this->audio_fifo, buf);
}
-static unsigned long str2ulong(unsigned char *str) {
- return ( str[0] | (str[1]<<8) | (str[2]<<16) | (str[3]<<24) );
+static unsigned long
+str2ulong (unsigned char *str)
+{
+ return (str[0] | (str[1] << 8) | (str[2] << 16) | (str[3] << 24));
}
-static void asf_send_video_header (demux_asf_t *this, int stream) {
+static void
+asf_send_video_header (demux_asf_t * this, int stream)
+{
- buf_element_t *buf;
- xine_bmiheader *bih = (xine_bmiheader *) this->bih;
+ buf_element_t *buf;
+ xine_bmiheader *bih = (xine_bmiheader *) this->bih;
- this->stream->stream_info[XINE_STREAM_INFO_VIDEO_FOURCC] =
bih->biCompression;
+ this->stream->stream_info[XINE_STREAM_INFO_VIDEO_FOURCC] =
+ bih->biCompression;
buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
- buf->decoder_flags = BUF_FLAG_HEADER;
- buf->decoder_info[1] = 3000; /* FIXME ? */
+ buf->decoder_flags = BUF_FLAG_HEADER;
+ buf->decoder_info[1] = 3000; /* FIXME ? */
memcpy (buf->content, &this->bih, this->bih_size);
buf->size = this->bih_size;
- buf->type = this->streams[stream].buf_type ;
+ buf->type = this->streams[stream].buf_type;
this->video_fifo->put (this->video_fifo, buf);
}
-static int asf_read_header (demux_asf_t *this) {
+static int
+asf_read_header (demux_asf_t * this)
+{
- int guid;
- uint64_t gsize;
+ int guid;
+ uint64_t gsize;
- guid = get_guid(this);
- if (guid != GUID_ASF_HEADER) {
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_asf: file doesn't start with an asf header\n");
- return 0;
- }
- get_le64(this);
- get_le32(this);
- get_byte(this);
- get_byte(this);
+ guid = get_guid (this);
+ if (guid != GUID_ASF_HEADER)
+ {
+ if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
+ printf ("demux_asf: file doesn't start with an asf header\n");
+ return 0;
+ }
+ get_le64 (this);
+ get_le32 (this);
+ get_byte (this);
+ get_byte (this);
- while (this->status != DEMUX_FINISHED) {
- guid = get_guid(this);
- gsize = get_le64(this);
+ while (this->status != DEMUX_FINISHED)
+ {
+ guid = get_guid (this);
+ gsize = get_le64 (this);
- if (gsize < 24)
- goto fail;
+ if (gsize < 24)
+ goto fail;
- switch (guid) {
- case GUID_ASF_FILE_PROPERTIES:
+ switch (guid)
{
- uint64_t start_time, end_time;
+ case GUID_ASF_FILE_PROPERTIES:
+ {
+ uint64_t start_time, end_time;
- guid = get_guid(this);
- get_le64(this); /* file size */
- get_le64(this); /* file time */
- get_le64(this); /* nb_packets */
+ guid = get_guid (this);
+ get_le64 (this); /* file size */
+ get_le64 (this); /* file time */
+ get_le64 (this); /* nb_packets */
- end_time = get_le64 (this);
+ end_time = get_le64 (this);
- this->length = get_le64(this) / 10000;
- if (this->length)
- this->rate = this->input->get_length (this->input) / (this->length
/ 1000);
- else
- this->rate = 0;
+ this->length = get_le64 (this) / 10000;
+ if (this->length)
+ this->rate =
+ this->input->get_length (this->input) / (this->length / 1000);
+ else
+ this->rate = 0;
- this->stream->stream_info[XINE_STREAM_INFO_BITRATE] = this->rate*8;
+ this->stream->stream_info[XINE_STREAM_INFO_BITRATE] =
+ this->rate * 8;
- start_time = get_le32(this); /* start timestamp in 1/1000 s*/
+ start_time = get_le32 (this); /* start timestamp in 1/1000 s
*/
- get_le32(this); /* unknown */
- get_le32(this); /* min size */
- this->packet_size = get_le32(this); /* max size */
- get_le32(this); /* max bitrate */
- get_le32(this);
- }
- break;
+ get_le32 (this); /* unknown */
+ get_le32 (this); /* min size */
+ this->packet_size = get_le32 (this); /* max size */
+ get_le32 (this); /* max bitrate */
+ get_le32 (this);
+ }
+ break;
- case (GUID_ASF_STREAM_PROPERTIES):
- {
- int type;
- uint32_t total_size, stream_data_size;
- uint16_t stream_id;
- uint64_t pos1, pos2;
- xine_bmiheader *bih = (xine_bmiheader *) this->bih;
- xine_waveformatex *wavex = (xine_waveformatex *) this->wavex ;
+ case (GUID_ASF_STREAM_PROPERTIES):
+ {
+ int type;
+ uint32_t total_size, stream_data_size;
+ uint16_t stream_id;
+ uint64_t pos1, pos2;
+ xine_bmiheader *bih = (xine_bmiheader *) this->bih;
+ xine_waveformatex *wavex = (xine_waveformatex *) this->wavex;
- pos1 = this->input->get_current_pos (this->input);
+ pos1 = this->input->get_current_pos (this->input);
- guid = get_guid(this);
- switch (guid) {
- case GUID_ASF_AUDIO_MEDIA:
- type = CODEC_TYPE_AUDIO;
- break;
+ guid = get_guid (this);
+ switch (guid)
+ {
+ case GUID_ASF_AUDIO_MEDIA:
+ type = CODEC_TYPE_AUDIO;
+ break;
- case GUID_ASF_VIDEO_MEDIA:
- type = CODEC_TYPE_VIDEO;
- break;
+ case GUID_ASF_VIDEO_MEDIA:
+ type = CODEC_TYPE_VIDEO;
+ break;
- case GUID_ASF_COMMAND_MEDIA:
- type = CODEC_TYPE_CONTROL;
- break;
+ case GUID_ASF_COMMAND_MEDIA:
+ type = CODEC_TYPE_CONTROL;
+ break;
- default:
- goto fail;
- }
+ default:
+ goto fail;
+ }
- guid = get_guid(this);
- get_le64(this);
- total_size = get_le32(this);
- stream_data_size = get_le32(this);
- stream_id = get_le16(this); /* stream id */
- get_le32(this);
+ guid = get_guid (this);
+ get_le64 (this);
+ total_size = get_le32 (this);
+ stream_data_size = get_le32 (this);
+ stream_id = get_le16 (this); /* stream id */
+ get_le32 (this);
- if (type == CODEC_TYPE_AUDIO) {
- uint8_t buffer[6];
+ if (type == CODEC_TYPE_AUDIO)
+ {
+ uint8_t buffer[6];
- this->input->read (this->input, (uint8_t *) this->wavex,
total_size);
- xine_waveformatex_le2me( (xine_waveformatex *) this->wavex );
+ this->input->read (this->input, (uint8_t *) this->wavex,
+ total_size);
+ xine_waveformatex_le2me ((xine_waveformatex *) this->wavex);
- /*
- printf ("total size: %d bytes\n", total_size);
- */
+ /*
+ printf ("total size: %d bytes\n", total_size);
+ */
- /*
- this->input->read (this->input, (uint8_t *) &this->wavex[9],
this->wavex[8]);
- */
- if (guid == GUID_ASF_AUDIO_SPREAD) {
- this->input->read (this->input, buffer, 6);
- this->reorder_h = buffer[0];
- this->reorder_w = (buffer[2]<<8)|buffer[1];
- this->reorder_b = (buffer[4]<<8)|buffer[3];
- this->reorder_w /= this->reorder_b;
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_asf: audio conceal interleave detected (%d x %d
x %d)\n",
- this->reorder_w, this->reorder_h, this->reorder_b );
- } else {
- this->reorder_b=this->reorder_h=this->reorder_w=1;
- }
+ /*
+ this->input->read (this->input, (uint8_t *)
&this->wavex[9], this->wavex[8]);
+ */
+ if (guid == GUID_ASF_AUDIO_SPREAD)
+ {
+ this->input->read (this->input, buffer, 6);
+ this->reorder_h = buffer[0];
+ this->reorder_w = (buffer[2] << 8) | buffer[1];
+ this->reorder_b = (buffer[4] << 8) | buffer[3];
+ this->reorder_w /= this->reorder_b;
+ if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
+ printf
+ ("demux_asf: audio conceal interleave detected (%d x
%d x %d)\n",
+ this->reorder_w, this->reorder_h, this->reorder_b);
+ }
+ else
+ {
+ this->reorder_b = this->reorder_h = this->reorder_w = 1;
+ }
- this->wavex_size = total_size; /* 18 + this->wavex[8]; */
+ this->wavex_size = total_size; /* 18 + this->wavex[8]; */
- this->streams[this->num_streams].buf_type =
- formattag_to_buf_audio ( wavex->wFormatTag );
- if ( !this->streams[this->num_streams].buf_type ) {
- printf ("demux_asf: unknown audio type 0x%x\n",
wavex->wFormatTag);
- this->streams[this->num_streams].buf_type = BUF_AUDIO_UNKNOWN;
- }
+ this->streams[this->num_streams].buf_type =
+ formattag_to_buf_audio (wavex->wFormatTag);
+ if (!this->streams[this->num_streams].buf_type)
+ {
+ printf ("demux_asf: unknown audio type 0x%x\n",
+ wavex->wFormatTag);
+ this->streams[this->num_streams].buf_type =
+ BUF_AUDIO_UNKNOWN;
+ }
- this->streams[this->num_streams].fifo = this->audio_fifo;
- this->streams[this->num_streams].stream_id = stream_id;
- this->streams[this->num_streams].frag_offset = 0;
- this->streams[this->num_streams].seq = 0;
- if (this->reorder_h > 1 && this->reorder_w > 1 ) {
- if( !this->streams[this->num_streams].buffer )
- this->streams[this->num_streams].buffer = malloc(
DEFRAG_BUFSIZE );
- this->streams[this->num_streams].defrag = 1;
- } else
- this->streams[this->num_streams].defrag = 0;
+ this->streams[this->num_streams].fifo = this->audio_fifo;
+ this->streams[this->num_streams].stream_id = stream_id;
+ this->streams[this->num_streams].frag_offset = 0;
+ this->streams[this->num_streams].seq = 0;
+ if (this->reorder_h > 1 && this->reorder_w > 1)
+ {
+ if (!this->streams[this->num_streams].buffer)
+ this->streams[this->num_streams].buffer =
+ malloc (DEFRAG_BUFSIZE);
+ this->streams[this->num_streams].defrag = 1;
+ }
+ else
+ this->streams[this->num_streams].defrag = 0;
#ifdef LOG
- printf ("demux_asf: found an audio stream id=%d \n", stream_id);
+ printf ("demux_asf: found an audio stream id=%d \n",
+ stream_id);
#endif
- this->num_audio_streams++;
- }
- else if (type == CODEC_TYPE_VIDEO) {
+ this->num_audio_streams++;
+ }
+ else if (type == CODEC_TYPE_VIDEO)
+ {
- uint16_t i;
+ uint16_t i;
- get_le32(this); /* width */
- get_le32(this); /* height */
- get_byte(this);
+ get_le32 (this); /* width */
+ get_le32 (this); /* height */
+ get_byte (this);
- i = get_le16(this); /* size */
- if( i > 0 && i < sizeof(this->bih) ) {
- this->bih_size = i;
- this->input->read (this->input, (uint8_t *) this->bih,
this->bih_size);
- xine_bmiheader_le2me( (xine_bmiheader *) this->bih );
+ i = get_le16 (this); /* size */
+ if (i > 0 && i < sizeof (this->bih))
+ {
+ this->bih_size = i;
+ this->input->read (this->input, (uint8_t *) this->bih,
+ this->bih_size);
+ xine_bmiheader_le2me ((xine_bmiheader *) this->bih);
- this->streams[this->num_streams].buf_type =
- fourcc_to_buf_video(bih->biCompression);
- if( !this->streams[this->num_streams].buf_type ) {
- printf ("demux_asf: unknown video format %.4s\n",
- (char*)&bih->biCompression);
+ this->streams[this->num_streams].buf_type =
+ fourcc_to_buf_video (bih->biCompression);
+ if (!this->streams[this->num_streams].buf_type)
+ {
+ printf ("demux_asf: unknown video format %.4s\n",
+ (char *) &bih->biCompression);
- this->streams[this->num_streams].buf_type = BUF_VIDEO_UNKNOWN;
- }
+ this->streams[this->num_streams].buf_type =
+ BUF_VIDEO_UNKNOWN;
+ }
- this->streams[this->num_streams].fifo = this->video_fifo;
- this->streams[this->num_streams].stream_id = stream_id;
- this->streams[this->num_streams].frag_offset = 0;
- this->streams[this->num_streams].defrag = 0;
+ this->streams[this->num_streams].fifo = this->video_fifo;
+ this->streams[this->num_streams].stream_id = stream_id;
+ this->streams[this->num_streams].frag_offset = 0;
+ this->streams[this->num_streams].defrag = 0;
- } else
- printf ("demux_asf: invalid bih_size received (%d), v_stream
ignored.\n", i );
+ }
+ else
+ printf
+ ("demux_asf: invalid bih_size received (%d), v_stream
ignored.\n",
+ i);
#ifdef LOG
- printf ("demux_asf: found a video stream id=%d, buf_type=%08x \n",
- stream_id, this->streams[this->num_streams].buf_type);
+ printf
+ ("demux_asf: found a video stream id=%d, buf_type=%08x \n",
+ stream_id, this->streams[this->num_streams].buf_type);
#endif
- this->num_video_streams++;
- }
- else if (type == CODEC_TYPE_CONTROL) {
- this->streams[this->num_streams].stream_id = stream_id;
- this->control_stream_id = stream_id;
+ this->num_video_streams++;
+ }
+ else if (type == CODEC_TYPE_CONTROL)
+ {
+ this->streams[this->num_streams].stream_id = stream_id;
+ this->control_stream_id = stream_id;
- /* This code does'nt work
- while (get_byte(this) != 0) {while (get_byte(this) != 0) {}}
- while (get_byte(this) != 0) {while (get_byte(this) != 0) {}}
- */
+ /* This code does'nt work
+ while (get_byte(this) != 0) {while (get_byte(this) != 0) {}}
+ while (get_byte(this) != 0) {while (get_byte(this) != 0) {}}
+ */
#ifdef LOG
- printf ("demux_asf: found a control stream id=%d \n", stream_id);
+ printf ("demux_asf: found a control stream id=%d \n",
+ stream_id);
#endif
+ }
+
+ this->num_streams++;
+ pos2 = this->input->get_current_pos (this->input);
+ this->input->seek (this->input, gsize - (pos2 - pos1 + 24),
+ SEEK_CUR);
}
+ break;
- this->num_streams++;
- pos2 = this->input->get_current_pos (this->input);
- this->input->seek (this->input, gsize - (pos2 - pos1 + 24),
SEEK_CUR);
- }
- break;
-
- case GUID_ASF_DATA:
+ case GUID_ASF_DATA:
#ifdef LOG
printf ("demux_asf: found data\n");
#endif
- goto headers_ok;
- break;
- case GUID_ASF_CONTENT_DESCRIPTION:
- {
- uint16_t len1, len2, len3, len4, len5;
+ goto headers_ok;
+ break;
+ case GUID_ASF_CONTENT_DESCRIPTION:
+ {
+ uint16_t len1, len2, len3, len4, len5;
- len1 = get_le16(this);
- len2 = get_le16(this);
- len3 = get_le16(this);
- len4 = get_le16(this);
- len5 = get_le16(this);
- get_str16_nolen(this, len1, this->title, sizeof(this->title));
- get_str16_nolen(this, len2, this->author, sizeof(this->author));
- get_str16_nolen(this, len3, this->copyright,
sizeof(this->copyright));
- get_str16_nolen(this, len4, this->comment, sizeof(this->comment));
- this->input->seek (this->input, len5, SEEK_CUR);
- /*
- } else if (url_feof(this)) {
- goto fail;
- */
- }
- break;
+ len1 = get_le16 (this);
+ len2 = get_le16 (this);
+ len3 = get_le16 (this);
+ len4 = get_le16 (this);
+ len5 = get_le16 (this);
+ get_str16_nolen (this, len1, this->title, sizeof (this->title));
+ get_str16_nolen (this, len2, this->author, sizeof (this->author));
+ get_str16_nolen (this, len3, this->copyright,
+ sizeof (this->copyright));
+ get_str16_nolen (this, len4, this->comment,
+ sizeof (this->comment));
+ this->input->seek (this->input, len5, SEEK_CUR);
+ /*
+ } else if (url_feof(this)) {
+ goto fail;
+ */
+ }
+ break;
- case GUID_ASF_STREAM_BITRATE_PROPERTIES:
- {
- uint16_t streams, stream_id;
- uint16_t i;
+ case GUID_ASF_STREAM_BITRATE_PROPERTIES:
+ {
+ uint16_t streams, stream_id;
+ uint16_t i;
#ifdef LOG
- printf("demux_asf: GUID stream group\n");
+ printf ("demux_asf: GUID stream group\n");
#endif
- streams = get_le16(this);
- for(i = 0; i < streams; i++) {
- stream_id = get_le16(this);
- this->bitrates[stream_id] = get_le32(this);
+ streams = get_le16 (this);
+ for (i = 0; i < streams; i++)
+ {
+ stream_id = get_le16 (this);
+ this->bitrates[stream_id] = get_le32 (this);
+ }
}
+ break;
+
+ default:
+ this->input->seek (this->input, gsize - 24, SEEK_CUR);
}
- break;
-
- default:
- this->input->seek (this->input, gsize - 24, SEEK_CUR);
}
- }
- headers_ok:
- this->input->seek (this->input, sizeof(GUID) + 10, SEEK_CUR);
+headers_ok:
+ this->input->seek (this->input, sizeof (GUID) + 10, SEEK_CUR);
this->packet_size_left = 0;
this->first_packet_pos = this->input->get_current_pos (this->input);
return 1;
- fail:
+fail:
return 0;
}
-static void asf_reorder(demux_asf_t *this, uint8_t *src, int len){
- uint8_t *dst = malloc(len);
+static void
+asf_reorder (demux_asf_t * this, uint8_t * src, int len)
+{
+ uint8_t *dst = malloc (len);
uint8_t *s2 = src;
int i = 0, x, y;
- while(len-i >= this->reorder_h * this->reorder_w*this->reorder_b){
- for(x = 0; x < this->reorder_w; x++)
- for(y = 0; y < this->reorder_h; y++){
- memcpy(dst + i, s2 + (y * this->reorder_w+x) * this->reorder_b,
- this->reorder_b);
+ while (len - i >= this->reorder_h * this->reorder_w * this->reorder_b)
+ {
+ for (x = 0; x < this->reorder_w; x++)
+ for (y = 0; y < this->reorder_h; y++)
+ {
+ memcpy (dst + i, s2 + (y * this->reorder_w + x) * this->reorder_b,
+ this->reorder_b);
i += this->reorder_b;
}
- s2 += this->reorder_h * this->reorder_w * this->reorder_b;
- }
+ s2 += this->reorder_h * this->reorder_w * this->reorder_b;
+ }
- xine_fast_memcpy(src,dst,i);
- free(dst);
+ xine_fast_memcpy (src, dst, i);
+ free (dst);
}
-static uint32_t asf_get_packet(demux_asf_t *this) {
+static uint32_t
+asf_get_packet (demux_asf_t * this)
+{
- int64_t timestamp;
- int duration;
- uint8_t ecd_flags;
- uint8_t buf[16];
- uint32_t p_hdr_size;
- int invalid_packet;
+ int64_t timestamp;
+ int duration;
+ uint8_t ecd_flags;
+ uint8_t buf[16];
+ uint32_t p_hdr_size;
+ int invalid_packet;
- do {
- ecd_flags = get_byte(this); p_hdr_size = 1;
- invalid_packet = 0;
+ do
+ {
+ ecd_flags = get_byte (this);
+ p_hdr_size = 1;
+ invalid_packet = 0;
- /* skip ecd */
- if (ecd_flags & 0x80)
- p_hdr_size += this->input->read (this->input, buf, ecd_flags & 0x0F);
+ /* skip ecd */
+ if (ecd_flags & 0x80)
+ p_hdr_size += this->input->read (this->input, buf, ecd_flags & 0x0F);
- /* skip invalid packet */
- if (ecd_flags & 0x70) {
+ /* skip invalid packet */
+ if (ecd_flags & 0x70)
+ {
#ifdef LOG
- printf("demux_asf: skip invalid packet: %d\n", ecd_flags);
+ printf ("demux_asf: skip invalid packet: %d\n", ecd_flags);
#endif
- this->input->seek (this->input, this->packet_size - p_hdr_size,
SEEK_CUR);
- invalid_packet = 1;
- }
+ this->input->seek (this->input, this->packet_size - p_hdr_size,
+ SEEK_CUR);
+ invalid_packet = 1;
+ }
- if( this->status != DEMUX_OK )
- return 0;
+ if (this->status != DEMUX_OK)
+ return 0;
- } while (invalid_packet);
+ }
+ while (invalid_packet);
- if( this->status != DEMUX_OK )
+ if (this->status != DEMUX_OK)
return 0;
- this->packet_flags = get_byte(this); p_hdr_size += 1;
- this->segtype = get_byte(this); p_hdr_size += 1;
+ this->packet_flags = get_byte (this);
+ p_hdr_size += 1;
+ this->segtype = get_byte (this);
+ p_hdr_size += 1;
/* packet size */
- switch((this->packet_flags >> 5) & 3) {
+ switch ((this->packet_flags >> 5) & 3)
+ {
case 1:
- this->data_size = get_byte(this); p_hdr_size += 1; break;
+ this->data_size = get_byte (this);
+ p_hdr_size += 1;
+ break;
case 2:
- this->data_size = get_le16(this); p_hdr_size += 2; break;
+ this->data_size = get_le16 (this);
+ p_hdr_size += 2;
+ break;
case 3:
- this->data_size = get_le32(this); p_hdr_size += 4; break;
+ this->data_size = get_le32 (this);
+ p_hdr_size += 4;
+ break;
default:
this->data_size = 0;
- }
+ }
/* sequence */
- switch ((this->packet_flags >> 1) & 3) {
+ switch ((this->packet_flags >> 1) & 3)
+ {
case 1:
- get_byte(this); p_hdr_size += 1; break;
+ get_byte (this);
+ p_hdr_size += 1;
+ break;
case 2:
- get_le16(this); p_hdr_size += 2; break;
+ get_le16 (this);
+ p_hdr_size += 2;
+ break;
case 3:
- get_le32(this); p_hdr_size += 4; break;
- }
+ get_le32 (this);
+ p_hdr_size += 4;
+ break;
+ }
/* padding size */
- switch ((this->packet_flags >> 3) & 3){
+ switch ((this->packet_flags >> 3) & 3)
+ {
case 1:
- this->packet_padsize = get_byte(this); p_hdr_size += 1; break;
+ this->packet_padsize = get_byte (this);
+ p_hdr_size += 1;
+ break;
case 2:
- this->packet_padsize = get_le16(this); p_hdr_size += 2; break;
+ this->packet_padsize = get_le16 (this);
+ p_hdr_size += 2;
+ break;
case 3:
- this->packet_padsize = get_le32(this); p_hdr_size += 4; break;
+ this->packet_padsize = get_le32 (this);
+ p_hdr_size += 4;
+ break;
default:
this->packet_padsize = 0;
- }
+ }
- timestamp = get_le32(this); p_hdr_size += 4;
- duration = get_le16(this); p_hdr_size += 2;
+ timestamp = get_le32 (this);
+ p_hdr_size += 4;
+ duration = get_le16 (this);
+ p_hdr_size += 2;
- if ((this->packet_flags >> 5) & 3) {
- /* absolute data size */
+ if ((this->packet_flags >> 5) & 3)
+ {
+ /* absolute data size */
#ifdef LOG
- printf ("demux_asf: absolute data size\n");
+ printf ("demux_asf: absolute data size\n");
#endif
- this->packet_padsize = this->packet_size - this->data_size; /* not used */
- } else {
- /* relative data size */
+ this->packet_padsize = this->packet_size - this->data_size; /* not
used */
+ }
+ else
+ {
+ /* relative data size */
#ifdef LOG
- printf ("demux_asf: relative data size\n");
+ printf ("demux_asf: relative data size\n");
#endif
- this->data_size = this->packet_size - this->packet_padsize;
- }
+ this->data_size = this->packet_size - this->packet_padsize;
+ }
/* this->packet_size_left = this->packet_size - p_hdr_size; */
this->packet_size_left = this->data_size - p_hdr_size;
#ifdef LOG
- printf ("demux_asf: new packet, size = %d, size_left = %d, flags = 0x%02x,
padsize = %d, this->packet_size = %d\n",
- this->data_size, this->packet_size_left, this->packet_flags,
this->packet_padsize, this->packet_size);
+ printf
+ ("demux_asf: new packet, size = %d, size_left = %d, flags = 0x%02x,
padsize = %d, this->packet_size = %d\n",
+ this->data_size, this->packet_size_left, this->packet_flags,
+ this->packet_padsize, this->packet_size);
#endif
return 1;
}
-static void hexdump (unsigned char *data, int len, xine_t *xine) {
+static void
+hexdump (unsigned char *data, int len, xine_t * xine)
+{
int i;
for (i = 0; i < len; i++)
- printf("%02x ", data[i]);
- printf("\n");
+ printf ("%02x ", data[i]);
+ printf ("\n");
}
@@ -717,28 +826,37 @@
i guess llabs may not be available everywhere */
#define abs(x) ( ((x)<0) ? -(x) : (x) )
-static void check_newpts (demux_asf_t *this, int64_t pts, int video, int
frame_end) {
+static void
+check_newpts (demux_asf_t * this, int64_t pts, int video, int frame_end)
+{
int64_t diff;
diff = pts - this->last_pts[video];
- if (pts && (this->send_newpts || (this->last_pts[video] &&
abs(diff)>WRAP_THRESHOLD)) ) {
+ if (pts
+ && (this->send_newpts
+ || (this->last_pts[video] && abs (diff) > WRAP_THRESHOLD)))
+ {
#ifdef LOG
- printf ("demux_asf: sending newpts %lld (video = %d diff = %lld)\n", pts,
video, diff);
+ printf ("demux_asf: sending newpts %lld (video = %d diff = %lld)\n",
+ pts, video, diff);
#endif
- if (this->buf_flag_seek) {
- xine_demux_control_newpts(this->stream, pts, BUF_FLAG_SEEK);
- this->buf_flag_seek = 0;
- } else {
- xine_demux_control_newpts(this->stream, pts, 0);
+ if (this->buf_flag_seek)
+ {
+ xine_demux_control_newpts (this->stream, pts, BUF_FLAG_SEEK);
+ this->buf_flag_seek = 0;
+ }
+ else
+ {
+ xine_demux_control_newpts (this->stream, pts, 0);
+ }
+
+ this->send_newpts = 0;
+ this->last_pts[1 - video] = 0;
}
- this->send_newpts = 0;
- this->last_pts[1-video] = 0;
- }
-
if (pts)
this->last_pts[video] = pts;
@@ -746,524 +864,654 @@
* frame rate estimation
*/
- if (pts && video && frame_end) {
+ if (pts && video && frame_end)
+ {
- if (this->last_frame_pts) {
+ if (this->last_frame_pts)
+ {
- diff = pts - this->last_frame_pts;
+ diff = pts - this->last_frame_pts;
- if ( (diff>0) && (diff < WRAP_THRESHOLD) ) {
+ if ((diff > 0) && (diff < WRAP_THRESHOLD))
+ {
#ifdef LOG
- printf ("demux_asf: last_frame_pts = %8lld, diff=%8lld\n",
- this->last_frame_pts, diff);
+ printf ("demux_asf: last_frame_pts = %8lld, diff=%8lld\n",
+ this->last_frame_pts, diff);
#endif
- this->frame_duration = (15*this->frame_duration + diff) / 16;
+ this->frame_duration = (15 * this->frame_duration + diff) / 16;
#ifdef LOG
- printf ("demux_asf: frame_duration is %d\n", this->frame_duration);
+ printf ("demux_asf: frame_duration is %d\n",
+ this->frame_duration);
#endif
- }
+ }
+ }
+
+ this->last_frame_pts = pts;
}
-
- this->last_frame_pts = pts;
- }
}
-static void asf_send_buffer_nodefrag (demux_asf_t *this, asf_stream_t *stream,
- int frag_offset, int seq,
- int64_t timestamp,
- int frag_len, int payload_size) {
+static void
+asf_send_buffer_nodefrag (demux_asf_t * this, asf_stream_t * stream,
+ int frag_offset, int seq,
+ int64_t timestamp, int frag_len, int payload_size)
+{
buf_element_t *buf;
- int bufsize;
- int package_done;
+ int bufsize;
+ int package_done;
- if (stream->frag_offset == 0) {
- /* new packet */
- stream->seq = seq;
- } else {
- if (seq == stream->seq &&
- frag_offset == stream->frag_offset) {
- /* continuing packet */
- } else {
- /* cannot continue current packet: free it */
- stream->frag_offset = 0;
- if (frag_offset != 0) {
- /* cannot create new packet */
- this->input->seek (this->input, frag_len, SEEK_CUR);
- return ;
- } else {
- /* create new packet */
- stream->seq = seq;
- }
+ if (stream->frag_offset == 0)
+ {
+ /* new packet */
+ stream->seq = seq;
}
- }
+ else
+ {
+ if (seq == stream->seq && frag_offset == stream->frag_offset)
+ {
+ /* continuing packet */
+ }
+ else
+ {
+ /* cannot continue current packet: free it */
+ stream->frag_offset = 0;
+ if (frag_offset != 0)
+ {
+ /* cannot create new packet */
+ this->input->seek (this->input, frag_len, SEEK_CUR);
+ return;
+ }
+ else
+ {
+ /* create new packet */
+ stream->seq = seq;
+ }
+ }
+ }
- while( frag_len ) {
- if ( frag_len < stream->fifo->buffer_pool_buf_size )
- bufsize = frag_len;
- else
- bufsize = stream->fifo->buffer_pool_buf_size;
+ while (frag_len)
+ {
+ if (frag_len < stream->fifo->buffer_pool_buf_size)
+ bufsize = frag_len;
+ else
+ bufsize = stream->fifo->buffer_pool_buf_size;
- buf = stream->fifo->buffer_pool_alloc (stream->fifo);
- this->input->read (this->input, buf->content, bufsize);
+ buf = stream->fifo->buffer_pool_alloc (stream->fifo);
+ this->input->read (this->input, buf->content, bufsize);
- buf->extra_info->input_pos = this->input->get_current_pos (this->input);
- if (this->rate)
- buf->extra_info->input_time = (int)((int64_t)buf->extra_info->input_pos
- * 1000 / this->rate);
- else
- buf->extra_info->input_time = 0;
+ buf->extra_info->input_pos = this->input->get_current_pos (this->input);
+ if (this->rate)
+ buf->extra_info->input_time =
+ (int) ((int64_t) buf->extra_info->input_pos * 1000 / this->rate);
+ else
+ buf->extra_info->input_time = 0;
#ifdef LOG
- printf ("demux_asf: input pos is %lld, input time is %d\n",
- buf->extra_info->input_pos,
- buf->extra_info->input_time);
+ printf ("demux_asf: input pos is %lld, input time is %d\n",
+ buf->extra_info->input_pos, buf->extra_info->input_time);
#endif
- buf->pts = timestamp * 90;
+ buf->pts = timestamp * 90;
- buf->type = stream->buf_type;
- buf->size = bufsize;
- timestamp = 0;
+ buf->type = stream->buf_type;
+ buf->size = bufsize;
+ timestamp = 0;
- stream->frag_offset += bufsize;
- frag_len -= bufsize;
+ stream->frag_offset += bufsize;
+ frag_len -= bufsize;
- package_done = (stream->frag_offset == payload_size);
+ package_done = (stream->frag_offset == payload_size);
- if ((buf->type & BUF_MAJOR_MASK) == BUF_VIDEO_BASE)
- check_newpts (this, buf->pts, PTS_VIDEO, package_done);
- else
- check_newpts (this, buf->pts, PTS_AUDIO, package_done);
+ if ((buf->type & BUF_MAJOR_MASK) == BUF_VIDEO_BASE)
+ check_newpts (this, buf->pts, PTS_VIDEO, package_done);
+ else
+ check_newpts (this, buf->pts, PTS_AUDIO, package_done);
- /* test if whole packet read */
- if (package_done) {
+ /* test if whole packet read */
+ if (package_done)
+ {
- if ( (buf->type & BUF_MAJOR_MASK) == BUF_VIDEO_BASE) {
+ if ((buf->type & BUF_MAJOR_MASK) == BUF_VIDEO_BASE)
+ {
- buf->decoder_flags = BUF_FLAG_FRAME_END | BUF_FLAG_FRAMERATE;
- buf->decoder_info[0] = this->frame_duration;
+ buf->decoder_flags = BUF_FLAG_FRAME_END | BUF_FLAG_FRAMERATE;
+ buf->decoder_info[0] = this->frame_duration;
- } else {
+ }
+ else
+ {
- buf->decoder_flags = BUF_FLAG_FRAME_END;
- }
+ buf->decoder_flags = BUF_FLAG_FRAME_END;
+ }
- stream->frag_offset = 0;
+ stream->frag_offset = 0;
- }
+ }
- if( !this->keyframe_found )
- buf->decoder_flags |= BUF_FLAG_PREVIEW;
+ if (!this->keyframe_found)
+ buf->decoder_flags |= BUF_FLAG_PREVIEW;
#ifdef LOG
- printf ("demux_asf: buffer type %08x %8d bytes, %8lld pts\n",
- buf->type, buf->size, buf->pts);
+ printf ("demux_asf: buffer type %08x %8d bytes, %8lld pts\n",
+ buf->type, buf->size, buf->pts);
#endif
- stream->fifo->put (stream->fifo, buf);
- }
+ stream->fifo->put (stream->fifo, buf);
+ }
}
-static void asf_send_buffer_defrag (demux_asf_t *this, asf_stream_t *stream,
- int frag_offset, int seq,
- int64_t timestamp,
- int frag_len, int payload_size) {
+static void
+asf_send_buffer_defrag (demux_asf_t * this, asf_stream_t * stream,
+ int frag_offset, int seq,
+ int64_t timestamp, int frag_len, int payload_size)
+{
buf_element_t *buf;
/*
- printf("asf_send_buffer seq=%d frag_offset=%d frag_len=%d\n",
- seq, frag_offset, frag_len );
- */
+ printf("asf_send_buffer seq=%d frag_offset=%d frag_len=%d\n",
+ seq, frag_offset, frag_len );
+ */
- if (stream->frag_offset == 0) {
- /* new packet */
- stream->seq = seq;
- } else {
- if (seq == stream->seq &&
- frag_offset == stream->frag_offset) {
- /* continuing packet */
- } else {
- /* cannot continue current packet: free it */
- if( stream->frag_offset )
- {
- int bufsize;
- uint8_t *p;
+ if (stream->frag_offset == 0)
+ {
+ /* new packet */
+ stream->seq = seq;
+ }
+ else
+ {
+ if (seq == stream->seq && frag_offset == stream->frag_offset)
+ {
+ /* continuing packet */
+ }
+ else
+ {
+ /* cannot continue current packet: free it */
+ if (stream->frag_offset)
+ {
+ int bufsize;
+ uint8_t *p;
- if (stream->fifo == this->audio_fifo &&
- this->reorder_h > 1 && this->reorder_w > 1 ) {
- asf_reorder(this,stream->buffer,stream->frag_offset);
- }
+ if (stream->fifo == this->audio_fifo &&
+ this->reorder_h > 1 && this->reorder_w > 1)
+ {
+ asf_reorder (this, stream->buffer, stream->frag_offset);
+ }
- p = stream->buffer;
- while( stream->frag_offset ) {
- if ( stream->frag_offset < stream->fifo->buffer_pool_buf_size )
- bufsize = stream->frag_offset;
- else
- bufsize = stream->fifo->buffer_pool_buf_size;
+ p = stream->buffer;
+ while (stream->frag_offset)
+ {
+ if (stream->frag_offset <
+ stream->fifo->buffer_pool_buf_size)
+ bufsize = stream->frag_offset;
+ else
+ bufsize = stream->fifo->buffer_pool_buf_size;
- buf = stream->fifo->buffer_pool_alloc (stream->fifo);
- xine_fast_memcpy (buf->content, p, bufsize);
+ buf = stream->fifo->buffer_pool_alloc (stream->fifo);
+ xine_fast_memcpy (buf->content, p, bufsize);
- buf->extra_info->input_pos = this->input->get_current_pos
(this->input);
- if (this->rate)
- buf->extra_info->input_time =
(int)((int64_t)buf->extra_info->input_pos
- * 1000 / this->rate);
- else
- buf->extra_info->input_time = 0;
+ buf->extra_info->input_pos =
+ this->input->get_current_pos (this->input);
+ if (this->rate)
+ buf->extra_info->input_time =
+ (int) ((int64_t) buf->extra_info->input_pos * 1000 /
+ this->rate);
+ else
+ buf->extra_info->input_time = 0;
- buf->pts = stream->timestamp * 90 + stream->ts_per_kbyte *
- (p-stream->buffer) / 1024;
+ buf->pts = stream->timestamp * 90 + stream->ts_per_kbyte *
+ (p - stream->buffer) / 1024;
- buf->type = stream->buf_type;
- buf->size = bufsize;
+ buf->type = stream->buf_type;
+ buf->size = bufsize;
#ifdef LOG
- printf ("demux_asf: buffer type %08x %8d bytes, %8lld pts\n",
- buf->type, buf->size, buf->pts);
+ printf
+ ("demux_asf: buffer type %08x %8d bytes, %8lld pts\n",
+ buf->type, buf->size, buf->pts);
#endif
- stream->frag_offset -= bufsize;
- p+=bufsize;
+ stream->frag_offset -= bufsize;
+ p += bufsize;
- if ((buf->type & BUF_MAJOR_MASK) == BUF_VIDEO_BASE)
- check_newpts (this, buf->pts, PTS_VIDEO, !stream->frag_offset);
- else
- check_newpts (this, buf->pts, PTS_AUDIO, !stream->frag_offset);
+ if ((buf->type & BUF_MAJOR_MASK) == BUF_VIDEO_BASE)
+ check_newpts (this, buf->pts, PTS_VIDEO,
+ !stream->frag_offset);
+ else
+ check_newpts (this, buf->pts, PTS_AUDIO,
+ !stream->frag_offset);
- /* test if whole packet read */
- if ( !stream->frag_offset )
- buf->decoder_flags |= BUF_FLAG_FRAME_END;
+ /* test if whole packet read */
+ if (!stream->frag_offset)
+ buf->decoder_flags |= BUF_FLAG_FRAME_END;
- if( !this->keyframe_found )
- buf->decoder_flags |= BUF_FLAG_PREVIEW;
+ if (!this->keyframe_found)
+ buf->decoder_flags |= BUF_FLAG_PREVIEW;
- stream->fifo->put (stream->fifo, buf);
- }
- }
+ stream->fifo->put (stream->fifo, buf);
+ }
+ }
- stream->frag_offset = 0;
- if (frag_offset != 0) {
- /* cannot create new packet */
- this->input->seek (this->input, frag_len, SEEK_CUR);
- return ;
- } else {
- /* create new packet */
- stream->seq = seq;
- }
+ stream->frag_offset = 0;
+ if (frag_offset != 0)
+ {
+ /* cannot create new packet */
+ this->input->seek (this->input, frag_len, SEEK_CUR);
+ return;
+ }
+ else
+ {
+ /* create new packet */
+ stream->seq = seq;
+ }
+ }
}
- }
- if( frag_offset ) {
- if( timestamp )
- stream->ts_per_kbyte = (timestamp - stream->timestamp) * 1024 * 90 /
frag_offset;
- } else {
- stream->ts_per_kbyte = 0;
- stream->timestamp = timestamp;
- }
+ if (frag_offset)
+ {
+ if (timestamp)
+ stream->ts_per_kbyte =
+ (timestamp - stream->timestamp) * 1024 * 90 / frag_offset;
+ }
+ else
+ {
+ stream->ts_per_kbyte = 0;
+ stream->timestamp = timestamp;
+ }
- if( stream->frag_offset + frag_len > DEFRAG_BUFSIZE ) {
- printf ("demux_asf: buffer overflow on defrag!\n");
- }
- else {
- this->input->read (this->input, &stream->buffer[stream->frag_offset],
frag_len);
- stream->frag_offset += frag_len;
- }
+ if (stream->frag_offset + frag_len > DEFRAG_BUFSIZE)
+ {
+ printf ("demux_asf: buffer overflow on defrag!\n");
+ }
+ else
+ {
+ this->input->read (this->input, &stream->buffer[stream->frag_offset],
+ frag_len);
+ stream->frag_offset += frag_len;
+ }
}
-static void asf_read_packet(demux_asf_t *this) {
+static void
+asf_read_packet (demux_asf_t * this)
+{
- uint8_t raw_id, stream_id;
- uint32_t seq, frag_offset, payload_size, frag_len, rlen;
- int i;
- int64_t timestamp;
- asf_stream_t *stream;
- uint32_t s_hdr_size = 0;
- uint64_t current_pos;
- uint32_t mod;
- uint32_t psl;
+ uint8_t raw_id, stream_id;
+ uint32_t seq, frag_offset, payload_size, frag_len, rlen;
+ int i;
+ int64_t timestamp;
+ asf_stream_t *stream;
+ uint32_t s_hdr_size = 0;
+ uint64_t current_pos;
+ uint32_t mod;
+ uint32_t psl;
- if ((++this->frame == (this->nb_frames & 0x3f)) ) {
- psl = this->packet_size_left;
- current_pos = this->input->get_current_pos (this->input);
- mod = (current_pos - this->first_packet_pos) % this->packet_size;
- this->packet_size_left = mod ? this->packet_size - mod : 0;
+ if ((++this->frame == (this->nb_frames & 0x3f)))
+ {
+ psl = this->packet_size_left;
+ current_pos = this->input->get_current_pos (this->input);
+ mod = (current_pos - this->first_packet_pos) % this->packet_size;
+ this->packet_size_left = mod ? this->packet_size - mod : 0;
#ifdef LOG
- printf ("demux_asf: reading new packet, packet size left psl=%d, pad=%d,
%d\n", psl, this->packet_padsize, this->packet_size_left);
+ printf
+ ("demux_asf: reading new packet, packet size left psl=%d, pad=%d,
%d\n",
+ psl, this->packet_padsize, this->packet_size_left);
#endif
- if (this->packet_size_left)
- this->input->seek (this->input, this->packet_size_left, SEEK_CUR);
+ if (this->packet_size_left)
+ this->input->seek (this->input, this->packet_size_left, SEEK_CUR);
- if (!asf_get_packet(this)) {
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_asf: get_packet failed\n");
- this->status = DEMUX_FINISHED;
- return ;
- }
+ if (!asf_get_packet (this))
+ {
+ if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
+ printf ("demux_asf: get_packet failed\n");
+ this->status = DEMUX_FINISHED;
+ return;
+ }
- if (this->packet_padsize > this->packet_size) {
- /* skip packet */
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_asf: invalid padsize: %d\n", this->packet_padsize);
- this->frame = this->nb_frames - 1;
- return;
- }
+ if (this->packet_padsize > this->packet_size)
+ {
+ /* skip packet */
+ if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
+ printf ("demux_asf: invalid padsize: %d\n", this->packet_padsize);
+ this->frame = this->nb_frames - 1;
+ return;
+ }
- /* Multiple frames */
- this->frame = 0;
- if (this->packet_flags & 0x01) {
- this->frame_flag = get_byte(this); s_hdr_size += 1;
- this->nb_frames = this->frame_flag & 0x3F;
+ /* Multiple frames */
+ this->frame = 0;
+ if (this->packet_flags & 0x01)
+ {
+ this->frame_flag = get_byte (this);
+ s_hdr_size += 1;
+ this->nb_frames = this->frame_flag & 0x3F;
#ifdef LOG
- printf ("demux_asf: multiple frames %d\n", this->nb_frames);
+ printf ("demux_asf: multiple frames %d\n", this->nb_frames);
#endif
- } else {
- this->frame_flag = 0;
- this->nb_frames = 1;
+ }
+ else
+ {
+ this->frame_flag = 0;
+ this->nb_frames = 1;
+ }
}
- }
/* read segment header, find stream */
- raw_id = get_byte(this); s_hdr_size += 1;
- stream_id = raw_id & 0x7f;
+ raw_id = get_byte (this);
+ s_hdr_size += 1;
+ stream_id = raw_id & 0x7f;
- stream = NULL;
+ stream = NULL;
#ifdef LOG
- printf ("demux_asf: got raw_id =%d keyframe_found=%d\n", raw_id,
this->keyframe_found);
+ printf ("demux_asf: got raw_id =%d keyframe_found=%d\n", raw_id,
+ this->keyframe_found);
#endif
- if ( (raw_id & 0x80) || this->keyframe_found ||
(this->num_video_streams==0)) {
- for (i = 0; i < this->num_streams; i++){
- if (this->streams[i].stream_id == stream_id &&
- (stream_id == this->audio_stream_id || stream_id ==
this->video_stream_id)) {
- stream = &this->streams[i];
- }
- }
+ if ((raw_id & 0x80) || this->keyframe_found
+ || (this->num_video_streams == 0))
+ {
+ for (i = 0; i < this->num_streams; i++)
+ {
+ if (this->streams[i].stream_id == stream_id &&
+ (stream_id == this->audio_stream_id
+ || stream_id == this->video_stream_id))
+ {
+ stream = &this->streams[i];
+ }
+ }
#ifdef LOG
- /* display control stream content */
- if (stream_id == this->control_stream_id) {
- printf("demux_asf: Control Stream : begin\n");
- for (i = 0; i < (this->packet_size_left - s_hdr_size); i++){
- printf("%c", get_byte(this));
- }
- printf("\ndemux_asf: Control Stream : end\n");
- return;
+ /* display control stream content */
+ if (stream_id == this->control_stream_id)
+ {
+ printf ("demux_asf: Control Stream : begin\n");
+ for (i = 0; i < (this->packet_size_left - s_hdr_size); i++)
+ {
+ printf ("%c", get_byte (this));
+ }
+ printf ("\ndemux_asf: Control Stream : end\n");
+ return;
+ }
+#endif
}
-#endif
- }
- switch ((this->segtype >> 4) & 3){
- case 1:
- seq = get_byte(this); s_hdr_size += 1; break;
- case 2:
- seq = get_le16(this); s_hdr_size += 2; break;
- case 3:
- seq = get_le32(this); s_hdr_size += 4; break;
- default:
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_asf: seq=0\n");
- seq = 0;
- }
+ switch ((this->segtype >> 4) & 3)
+ {
+ case 1:
+ seq = get_byte (this);
+ s_hdr_size += 1;
+ break;
+ case 2:
+ seq = get_le16 (this);
+ s_hdr_size += 2;
+ break;
+ case 3:
+ seq = get_le32 (this);
+ s_hdr_size += 4;
+ break;
+ default:
+ if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
+ printf ("demux_asf: seq=0\n");
+ seq = 0;
+ }
- switch ((this->segtype >> 2) & 3) {
+ switch ((this->segtype >> 2) & 3)
+ {
case 1:
- frag_offset = get_byte(this); s_hdr_size += 1; break;
+ frag_offset = get_byte (this);
+ s_hdr_size += 1;
+ break;
case 2:
- frag_offset = get_le16(this); s_hdr_size += 2; break;
+ frag_offset = get_le16 (this);
+ s_hdr_size += 2;
+ break;
case 3:
- frag_offset = get_le32(this); s_hdr_size += 4; break;
+ frag_offset = get_le32 (this);
+ s_hdr_size += 4;
+ break;
default:
if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_asf: frag_offset=0\n");
+ printf ("demux_asf: frag_offset=0\n");
frag_offset = 0;
- }
+ }
/* only set keyframe_found if we have it's beginning */
- if( (raw_id & 0x80) && stream && !frag_offset )
+ if ((raw_id & 0x80) && stream && !frag_offset)
this->keyframe_found = 1;
- switch (this->segtype & 3) {
+ switch (this->segtype & 3)
+ {
case 1:
- rlen = get_byte(this); s_hdr_size += 1; break;
+ rlen = get_byte (this);
+ s_hdr_size += 1;
+ break;
case 2:
- rlen = get_le16(this); s_hdr_size += 2; break;
+ rlen = get_le16 (this);
+ s_hdr_size += 2;
+ break;
case 3:
- rlen = get_le32(this); s_hdr_size += 4; break;
+ rlen = get_le32 (this);
+ s_hdr_size += 4;
+ break;
default:
rlen = 0;
- }
+ }
- if (rlen > this->packet_size_left) {
- /* skip packet */
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_asf: invalid rlen %d\n", rlen);
- this->frame = this->nb_frames - 1;
- return;
- }
+ if (rlen > this->packet_size_left)
+ {
+ /* skip packet */
+ if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
+ printf ("demux_asf: invalid rlen %d\n", rlen);
+ this->frame = this->nb_frames - 1;
+ return;
+ }
#ifdef LOG
- printf ("demux_asf: segment header, stream id %02x, frag_offset %d, flags
: %02x\n",
- stream_id, frag_offset, rlen);
+ printf
+ ("demux_asf: segment header, stream id %02x, frag_offset %d, flags :
%02x\n",
+ stream_id, frag_offset, rlen);
#endif
- if (rlen == 1) {
- int data_length, data_sent=0;
+ if (rlen == 1)
+ {
+ int data_length, data_sent = 0;
- /* multiple part segment */
- timestamp = frag_offset;
- get_byte (this); s_hdr_size += 1;
+ /* multiple part segment */
+ timestamp = frag_offset;
+ get_byte (this);
+ s_hdr_size += 1;
- if (this->packet_flags & 0x01) {
- /* multiple frames */
- switch ((this->frame_flag >> 6) & 3) {
- case 1:
- data_length = get_byte(this); s_hdr_size += 1; break;
- case 2:
- data_length = get_le16(this); s_hdr_size += 2; break;
- case 3:
- data_length = get_le32(this); s_hdr_size += 4; break;
- default:
+ if (this->packet_flags & 0x01)
+ {
+ /* multiple frames */
+ switch ((this->frame_flag >> 6) & 3)
+ {
+ case 1:
+ data_length = get_byte (this);
+ s_hdr_size += 1;
+ break;
+ case 2:
+ data_length = get_le16 (this);
+ s_hdr_size += 2;
+ break;
+ case 3:
+ data_length = get_le32 (this);
+ s_hdr_size += 4;
+ break;
+ default:
#ifdef LOG
- printf ("demux_asf: invalid frame_flag %d\n", this->frame_flag);
+ printf ("demux_asf: invalid frame_flag %d\n", this->frame_flag);
#endif
- data_length = get_le16(this); s_hdr_size += 2;
- }
+ data_length = get_le16 (this);
+ s_hdr_size += 2;
+ }
#ifdef LOG
- printf ("demux_asf: reading grouping part segment, size = %d\n",
data_length);
+ printf ("demux_asf: reading grouping part segment, size = %d\n",
+ data_length);
#endif
- } else {
- data_length = this->packet_size_left - s_hdr_size;
+ }
+ else
+ {
+ data_length = this->packet_size_left - s_hdr_size;
#ifdef LOG
- printf ("demux_asf: reading grouping single segment, size = %d\n",
data_length);
+ printf ("demux_asf: reading grouping single segment, size = %d\n",
+ data_length);
#endif
- }
+ }
- if (data_length > this->packet_size_left) {
- /* skip packet */
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_asf: invalid data_length\n");
- this->frame = this->nb_frames - 1;
- return;
- }
+ if (data_length > this->packet_size_left)
+ {
+ /* skip packet */
+ if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
+ printf ("demux_asf: invalid data_length\n");
+ this->frame = this->nb_frames - 1;
+ return;
+ }
- this->packet_size_left -= s_hdr_size;
+ this->packet_size_left -= s_hdr_size;
- while (data_sent < data_length) {
- int object_length = get_byte(this);
+ while (data_sent < data_length)
+ {
+ int object_length = get_byte (this);
#ifdef LOG
- printf ("demux_asf: sending grouped object, len = %d\n", object_length);
+ printf ("demux_asf: sending grouped object, len = %d\n",
+ object_length);
#endif
- if (stream && stream->fifo) {
+ if (stream && stream->fifo)
+ {
#ifdef LOG
- printf ("demux_asf: sending buffer of type %08x\n", stream->buf_type);
+ printf ("demux_asf: sending buffer of type %08x\n",
+ stream->buf_type);
#endif
- if (stream->defrag)
- asf_send_buffer_defrag (this, stream, 0, seq, timestamp,
- object_length, object_length);
- else
- asf_send_buffer_nodefrag (this, stream, 0, seq, timestamp,
- object_length, object_length);
- } else {
+ if (stream->defrag)
+ asf_send_buffer_defrag (this, stream, 0, seq, timestamp,
+ object_length, object_length);
+ else
+ asf_send_buffer_nodefrag (this, stream, 0, seq, timestamp,
+ object_length, object_length);
+ }
+ else
+ {
#ifdef LOG
- printf ("demux_asf: unhandled stream type, id %d\n", stream_id);
+ printf ("demux_asf: unhandled stream type, id %d\n", stream_id);
#endif
- this->input->seek (this->input, object_length, SEEK_CUR);
- }
- seq++;
- data_sent += object_length + 1;
- this->packet_size_left -= object_length + 1;
- timestamp = 0;
+ this->input->seek (this->input, object_length, SEEK_CUR);
+ }
+ seq++;
+ data_sent += object_length + 1;
+ this->packet_size_left -= object_length + 1;
+ timestamp = 0;
+ }
+
}
+ else
+ {
- } else {
+ /* single part segment */
+ if (rlen >= 8)
+ {
+ payload_size = get_le32 (this);
+ s_hdr_size += 4;
+ timestamp = get_le32 (this);
+ s_hdr_size += 4;
+ this->input->seek (this->input, rlen - 8, SEEK_CUR);
+ s_hdr_size += rlen - 8;
+ }
+ else
+ {
+ if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
+ printf ("demux_asf: strange rlen %d\n", rlen);
+ timestamp = 0;
+ payload_size = 0;
+ this->input->seek (this->input, rlen, SEEK_CUR);
+ s_hdr_size += rlen;
+ }
- /* single part segment */
- if (rlen >= 8) {
- payload_size = get_le32(this); s_hdr_size += 4;
- timestamp = get_le32(this); s_hdr_size += 4;
- this->input->seek (this->input, rlen - 8, SEEK_CUR);
- s_hdr_size += rlen - 8;
- } else {
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_asf: strange rlen %d\n", rlen);
- timestamp = 0;
- payload_size = 0;
- this->input->seek (this->input, rlen, SEEK_CUR);
- s_hdr_size += rlen;
- }
-
- if (this->packet_flags & 0x01) {
- switch ((this->frame_flag >> 6) & 3) {
- case 1:
- frag_len = get_byte(this); s_hdr_size += 1; break;
- case 2:
- frag_len = get_le16(this); s_hdr_size += 2; break;
- case 3:
- frag_len = get_le32(this); s_hdr_size += 4; break;
- default:
+ if (this->packet_flags & 0x01)
+ {
+ switch ((this->frame_flag >> 6) & 3)
+ {
+ case 1:
+ frag_len = get_byte (this);
+ s_hdr_size += 1;
+ break;
+ case 2:
+ frag_len = get_le16 (this);
+ s_hdr_size += 2;
+ break;
+ case 3:
+ frag_len = get_le32 (this);
+ s_hdr_size += 4;
+ break;
+ default:
#ifdef LOG
- printf ("demux_asf: invalid frame_flag %d\n", this->frame_flag);
+ printf ("demux_asf: invalid frame_flag %d\n", this->frame_flag);
#endif
- frag_len = get_le16(this); s_hdr_size += 2;
- }
+ frag_len = get_le16 (this);
+ s_hdr_size += 2;
+ }
#ifdef LOG
- printf ("demux_asf: reading part segment, size = %d\n", frag_len);
+ printf ("demux_asf: reading part segment, size = %d\n", frag_len);
#endif
- } else {
- frag_len = this->packet_size_left - s_hdr_size;
+ }
+ else
+ {
+ frag_len = this->packet_size_left - s_hdr_size;
#ifdef LOG
- printf ("demux_asf: reading single segment, size = %d\n", frag_len);
+ printf ("demux_asf: reading single segment, size = %d\n", frag_len);
#endif
- }
+ }
- if (frag_len > this->packet_size_left) {
- /* skip packet */
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_asf: invalid frag_len %d\n", frag_len);
- this->frame = this->nb_frames - 1;
- return;
- }
+ if (frag_len > this->packet_size_left)
+ {
+ /* skip packet */
+ if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
+ printf ("demux_asf: invalid frag_len %d\n", frag_len);
+ this->frame = this->nb_frames - 1;
+ return;
+ }
- if (!payload_size) {
- payload_size = frag_len;
- }
+ if (!payload_size)
+ {
+ payload_size = frag_len;
+ }
- this->packet_size_left -= s_hdr_size;
+ this->packet_size_left -= s_hdr_size;
- if (stream && stream->fifo) {
+ if (stream && stream->fifo)
+ {
#ifdef LOG
- printf ("demux_asf: sending buffer of type %08x\n", stream->buf_type);
+ printf ("demux_asf: sending buffer of type %08x\n",
+ stream->buf_type);
#endif
- if (stream->defrag)
- asf_send_buffer_defrag (this, stream, frag_offset, seq, timestamp,
- frag_len, payload_size);
+ if (stream->defrag)
+ asf_send_buffer_defrag (this, stream, frag_offset, seq, timestamp,
+ frag_len, payload_size);
+ else
+ asf_send_buffer_nodefrag (this, stream, frag_offset, seq,
+ timestamp, frag_len, payload_size);
+ }
else
- asf_send_buffer_nodefrag (this, stream, frag_offset, seq, timestamp,
- frag_len, payload_size);
- } else {
+ {
#ifdef LOG
- printf ("demux_asf: unhandled stream type, id %d\n", stream_id);
+ printf ("demux_asf: unhandled stream type, id %d\n", stream_id);
#endif
- this->input->seek (this->input, frag_len, SEEK_CUR);
+ this->input->seek (this->input, frag_len, SEEK_CUR);
+ }
+ this->packet_size_left -= frag_len;
}
- this->packet_size_left -= frag_len;
- }
}
/*
@@ -1272,58 +1520,67 @@
* [Reference]
* Ref1=http://www.blabla.com/blabla
*/
-static int demux_asf_parse_http_references( demux_asf_t *this) {
- char *buf = NULL;
- char *ptr;
- int buf_size = 0;
- int buf_used = 0;
- int len;
- char *href = NULL;
+static int
+demux_asf_parse_http_references (demux_asf_t * this)
+{
+ char *buf = NULL;
+ char *ptr;
+ int buf_size = 0;
+ int buf_used = 0;
+ int len;
+ char *href = NULL;
xine_mrl_reference_data_t *data;
- xine_event_t uevent;
+ xine_event_t uevent;
/* read file to memory.
* warning: dumb code, but hopefuly ok since reference file is small */
- do {
- buf_size += 1024;
- buf = realloc(buf, buf_size+1);
+ do
+ {
+ buf_size += 1024;
+ buf = realloc (buf, buf_size + 1);
- len = this->input->read(this->input, &buf[buf_used], buf_size-buf_used);
+ len =
+ this->input->read (this->input, &buf[buf_used], buf_size - buf_used);
- if( len > 0 )
- buf_used += len;
+ if (len > 0)
+ buf_used += len;
- /* 50k of reference file? no way. something must be wrong */
- if( buf_used > 50*1024 )
- break;
- } while( len > 0 );
+ /* 50k of reference file? no way. something must be wrong */
+ if (buf_used > 50 * 1024)
+ break;
+ }
+ while (len > 0);
- if(buf_used)
+ if (buf_used)
buf[buf_used] = '\0';
ptr = buf;
- if (!strncmp(ptr, "[Reference]", 11)) {
- ptr += 11;
- if (*ptr == '\r') ptr ++;
- if (*ptr == '\n') ptr ++;
- href = strchr(ptr, '=') + 1;
- *strchr(ptr, '\r') = '\0';
+ if (!strncmp (ptr, "[Reference]", 11))
+ {
+ ptr += 11;
+ if (*ptr == '\r')
+ ptr++;
+ if (*ptr == '\n')
+ ptr++;
+ href = strchr (ptr, '=') + 1;
+ *strchr (ptr, '\r') = '\0';
- /* replace http by mmsh */
- if (!strncmp(href, "http", 4)) {
- memcpy(href, "mmsh", 4);
+ /* replace http by mmsh */
+ if (!strncmp (href, "http", 4))
+ {
+ memcpy (href, "mmsh", 4);
+ }
+ if (this->stream->xine->verbosity >= XINE_VERBOSITY_LOG)
+ printf ("demux_asf: http ref: %s\n", href);
+ uevent.type = XINE_EVENT_MRL_REFERENCE;
+ uevent.stream = this->stream;
+ uevent.data_length = strlen (href) + sizeof (xine_mrl_reference_data_t);
+ data = malloc (uevent.data_length);
+ uevent.data = data;
+ strcpy (data->mrl, href);
+ data->alternative = 0;
+ xine_event_send (this->stream, &uevent);
}
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_LOG)
- printf("demux_asf: http ref: %s\n", href);
- uevent.type = XINE_EVENT_MRL_REFERENCE;
- uevent.stream = this->stream;
- uevent.data_length = strlen(href) + sizeof(xine_mrl_reference_data_t);
- data = malloc(uevent.data_length);
- uevent.data = data;
- strcpy(data->mrl, href);
- data->alternative = 0;
- xine_event_send(this->stream, &uevent);
- }
free (buf);
@@ -1335,59 +1592,67 @@
* parse a stupid ASF reference in an asx file
* format : "ASF http://www.blabla.com/blabla"
*/
-static int demux_asf_parse_asf_references( demux_asf_t *this) {
- char *buf = NULL;
- char *ptr;
- int buf_size = 0;
- int buf_used = 0;
- int len;
+static int
+demux_asf_parse_asf_references (demux_asf_t * this)
+{
+ char *buf = NULL;
+ char *ptr;
+ int buf_size = 0;
+ int buf_used = 0;
+ int len;
xine_mrl_reference_data_t *data;
- xine_event_t uevent;
- int i;
+ xine_event_t uevent;
+ int i;
/* read file to memory.
* warning: dumb code, but hopefuly ok since reference file is small */
- do {
- buf_size += 1024;
- buf = realloc(buf, buf_size+1);
+ do
+ {
+ buf_size += 1024;
+ buf = realloc (buf, buf_size + 1);
- len = this->input->read(this->input, &buf[buf_used], buf_size-buf_used);
+ len =
+ this->input->read (this->input, &buf[buf_used], buf_size - buf_used);
- if( len > 0 )
- buf_used += len;
+ if (len > 0)
+ buf_used += len;
- /* 50k of reference file? no way. something must be wrong */
- if( buf_used > 50*1024 )
- break;
- } while( len > 0 );
+ /* 50k of reference file? no way. something must be wrong */
+ if (buf_used > 50 * 1024)
+ break;
+ }
+ while (len > 0);
- if(buf_used)
+ if (buf_used)
buf[buf_used] = '\0';
ptr = buf;
- if (!strncmp(ptr, "ASF ", 4)) {
- ptr += 4;
+ if (!strncmp (ptr, "ASF ", 4))
+ {
+ ptr += 4;
- /* find the end of the string */
- for (i = 4; i < buf_used; i++) {
- if ((buf[i] == ' ') || (buf[i] == '\r') || (buf[i] == '\n')) {
- buf[i] = '\0';
- break;
- }
+ /* find the end of the string */
+ for (i = 4; i < buf_used; i++)
+ {
+ if ((buf[i] == ' ') || (buf[i] == '\r') || (buf[i] == '\n'))
+ {
+ buf[i] = '\0';
+ break;
+ }
+ }
+
+ if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
+ printf ("demux_asf: asf ref: %s\n", ptr);
+ uevent.type = XINE_EVENT_MRL_REFERENCE;
+ uevent.stream = this->stream;
+ uevent.data_length = strlen (ptr) + sizeof (xine_mrl_reference_data_t);
+ data = malloc (uevent.data_length);
+ uevent.data = data;
+ strcpy (data->mrl, ptr);
+ data->alternative = 0;
+ xine_event_send (this->stream, &uevent);
}
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf("demux_asf: asf ref: %s\n", ptr);
- uevent.type = XINE_EVENT_MRL_REFERENCE;
- uevent.stream = this->stream;
- uevent.data_length = strlen(ptr) + sizeof(xine_mrl_reference_data_t);
- data = malloc(uevent.data_length);
- uevent.data = data;
- strcpy(data->mrl, ptr);
- data->alternative = 0;
- xine_event_send(this->stream, &uevent);
- }
-
free (buf);
this->status = DEMUX_FINISHED;
@@ -1397,109 +1662,129 @@
/*
* parse .asx playlist files
*/
-static int demux_asf_parse_asx_references( demux_asf_t *this) {
+static int
+demux_asf_parse_asx_references (demux_asf_t * this)
+{
- char *buf = NULL;
- int buf_size = 0;
- int buf_used = 0;
- int len;
+ char *buf = NULL;
+ int buf_size = 0;
+ int buf_used = 0;
+ int len;
xine_mrl_reference_data_t *data;
- xine_event_t uevent;
- xml_node_t *xml_tree, *asx_entry, *asx_ref;
+ xine_event_t uevent;
+ xml_node_t *xml_tree, *asx_entry, *asx_ref;
xml_property_t *asx_prop;
- int result;
+ int result;
/* read file to memory.
* warning: dumb code, but hopefuly ok since reference file is small */
- do {
- buf_size += 1024;
- buf = realloc(buf, buf_size+1);
+ do
+ {
+ buf_size += 1024;
+ buf = realloc (buf, buf_size + 1);
- len = this->input->read(this->input, &buf[buf_used], buf_size-buf_used);
+ len =
+ this->input->read (this->input, &buf[buf_used], buf_size - buf_used);
- if( len > 0 )
- buf_used += len;
+ if (len > 0)
+ buf_used += len;
- /* 50k of reference file? no way. something must be wrong */
- if( buf_used > 50*1024 )
- break;
- } while( len > 0 );
+ /* 50k of reference file? no way. something must be wrong */
+ if (buf_used > 50 * 1024)
+ break;
+ }
+ while (len > 0);
- if(buf_used)
+ if (buf_used)
buf[buf_used] = '\0';
- xml_parser_init(buf, buf_used, XML_PARSER_CASE_INSENSITIVE);
- if((result = xml_parser_build_tree(&xml_tree)) != XML_PARSER_OK)
+ xml_parser_init (buf, buf_used, XML_PARSER_CASE_INSENSITIVE);
+ if ((result = xml_parser_build_tree (&xml_tree)) != XML_PARSER_OK)
goto __failure;
- if(!strcasecmp(xml_tree->name, "ASX")) {
+ if (!strcasecmp (xml_tree->name, "ASX"))
+ {
- asx_prop = xml_tree->props;
+ asx_prop = xml_tree->props;
- while((asx_prop) && (strcasecmp(asx_prop->name, "VERSION")))
- asx_prop = asx_prop->next;
+ while ((asx_prop) && (strcasecmp (asx_prop->name, "VERSION")))
+ asx_prop = asx_prop->next;
- if(asx_prop) {
- int version_major, version_minor = 0;
+ if (asx_prop)
+ {
+ int version_major, version_minor = 0;
- if((((sscanf(asx_prop->value, "%d.%d", &version_major, &version_minor))
== 2) ||
- ((sscanf(asx_prop->value, "%d", &version_major)) == 1)) &&
- ((version_major == 3) && (version_minor == 0))) {
+ if ((((sscanf
+ (asx_prop->value, "%d.%d", &version_major,
+ &version_minor)) == 2)
+ || ((sscanf (asx_prop->value, "%d", &version_major)) == 1))
+ && ((version_major == 3) && (version_minor == 0)))
+ {
- asx_entry = xml_tree->child;
- while(asx_entry) {
- if((!strcasecmp(asx_entry->name, "ENTRY")) ||
- (!strcasecmp(asx_entry->name, "ENTRYREF"))) {
- char *href = NULL;
+ asx_entry = xml_tree->child;
+ while (asx_entry)
+ {
+ if ((!strcasecmp (asx_entry->name, "ENTRY")) ||
+ (!strcasecmp (asx_entry->name, "ENTRYREF")))
+ {
+ char *href = NULL;
- asx_ref = asx_entry->child;
- while(asx_ref) {
+ asx_ref = asx_entry->child;
+ while (asx_ref)
+ {
- if(!strcasecmp(asx_ref->name, "REF")) {
+ if (!strcasecmp (asx_ref->name, "REF"))
+ {
- for(asx_prop = asx_ref->props; asx_prop; asx_prop =
asx_prop->next) {
+ for (asx_prop = asx_ref->props; asx_prop;
+ asx_prop = asx_prop->next)
+ {
- if(!strcasecmp(asx_prop->name, "HREF")) {
+ if (!strcasecmp (asx_prop->name, "HREF"))
+ {
- if(!href)
- href = asx_prop->value;
- }
- if(href)
- break;
+ if (!href)
+ href = asx_prop->value;
+ }
+ if (href)
+ break;
+ }
+ }
+ asx_ref = asx_ref->next;
+ }
+
+ if (href && strlen (href))
+ {
+ uevent.type = XINE_EVENT_MRL_REFERENCE;
+ uevent.stream = this->stream;
+ uevent.data_length =
+ strlen (href) +
+ sizeof (xine_mrl_reference_data_t);
+ data = malloc (uevent.data_length);
+ uevent.data = data;
+ strcpy (data->mrl, href);
+ data->alternative = 0;
+ xine_event_send (this->stream, &uevent);
+ }
+ href = NULL;
+ }
+ asx_entry = asx_entry->next;
}
- }
- asx_ref = asx_ref->next;
}
+ else
+ printf ("demux_asf: Wrong ASX version: %s\n", asx_prop->value);
- if(href && strlen(href)) {
- uevent.type = XINE_EVENT_MRL_REFERENCE;
- uevent.stream = this->stream;
- uevent.data_length =
strlen(href)+sizeof(xine_mrl_reference_data_t);
- data = malloc(uevent.data_length);
- uevent.data = data;
- strcpy(data->mrl, href);
- data->alternative = 0;
- xine_event_send(this->stream, &uevent);
- }
- href = NULL;
- }
- asx_entry = asx_entry->next;
}
- }
else
- printf("demux_asf: Wrong ASX version: %s\n", asx_prop->value);
-
+ printf ("demux_asf: Unable to find VERSION tag from ASX.\n");
}
- else
- printf("demux_asf: Unable to find VERSION tag from ASX.\n");
- }
else
- printf("demux_asf: Unsupported XML type: `%s'.\n", xml_tree->name);
+ printf ("demux_asf: Unsupported XML type: `%s'.\n", xml_tree->name);
- xml_parser_free_tree(xml_tree);
+ xml_parser_free_tree (xml_tree);
__failure:
- free(buf);
+ free (buf);
this->status = DEMUX_FINISHED;
return this->status;
@@ -1510,66 +1795,77 @@
* xine specific functions start here
*/
-static int demux_asf_send_chunk (demux_plugin_t *this_gen) {
+static int
+demux_asf_send_chunk (demux_plugin_t * this_gen)
+{
demux_asf_t *this = (demux_asf_t *) this_gen;
- switch (this->reference_mode) {
+ switch (this->reference_mode)
+ {
case 1:
- return demux_asf_parse_asx_references(this);
+ return demux_asf_parse_asx_references (this);
break;
case 2:
- return demux_asf_parse_http_references(this);
+ return demux_asf_parse_http_references (this);
break;
case 3:
- return demux_asf_parse_asf_references(this);
+ return demux_asf_parse_asf_references (this);
break;
default:
asf_read_packet (this);
return this->status;
- }
+ }
}
-static void demux_asf_dispose (demux_plugin_t *this_gen) {
+static void
+demux_asf_dispose (demux_plugin_t * this_gen)
+{
demux_asf_t *this = (demux_asf_t *) this_gen;
int i;
- for (i=0; i<this->num_streams; i++) {
- if( this->streams[i].buffer ) {
- free( this->streams[i].buffer );
- this->streams[i].buffer = NULL;
+ for (i = 0; i < this->num_streams; i++)
+ {
+ if (this->streams[i].buffer)
+ {
+ free (this->streams[i].buffer);
+ this->streams[i].buffer = NULL;
+ }
}
- }
free (this);
}
-static int demux_asf_get_status (demux_plugin_t *this_gen) {
+static int
+demux_asf_get_status (demux_plugin_t * this_gen)
+{
demux_asf_t *this = (demux_asf_t *) this_gen;
return this->status;
}
-static void demux_asf_send_headers (demux_plugin_t *this_gen) {
+static void
+demux_asf_send_headers (demux_plugin_t * this_gen)
+{
demux_asf_t *this = (demux_asf_t *) this_gen;
- int i;
- int stream_id;
- uint32_t buf_type, max_vrate, max_arate;
- uint32_t bitrate = 0;
+ int i;
+ int stream_id;
+ uint32_t buf_type, max_vrate, max_arate;
+ uint32_t bitrate = 0;
- this->video_fifo = this->stream->video_fifo;
- this->audio_fifo = this->stream->audio_fifo;
+ this->video_fifo = this->stream->video_fifo;
+ this->audio_fifo = this->stream->audio_fifo;
- this->last_pts[0] = 0;
- this->last_pts[1] = 0;
+ this->last_pts[0] = 0;
+ this->last_pts[1] = 0;
this->last_frame_pts = 0;
- this->status = DEMUX_OK;
+ this->status = DEMUX_OK;
/* will get overridden later */
this->stream->stream_info[XINE_STREAM_INFO_HAS_VIDEO] = 0;
@@ -1579,340 +1875,382 @@
* initialize asf engine
*/
- this->num_streams = 0;
- this->num_audio_streams = 0;
- this->num_video_streams = 0;
- this->audio_stream = 0;
- this->video_stream = 0;
- this->audio_stream_id = 0;
- this->video_stream_id = 0;
- this->control_stream_id = 0;
- this->packet_size = 0;
- this->seqno = 0;
- this->frame_duration = 3000;
+ this->num_streams = 0;
+ this->num_audio_streams = 0;
+ this->num_video_streams = 0;
+ this->audio_stream = 0;
+ this->video_stream = 0;
+ this->audio_stream_id = 0;
+ this->video_stream_id = 0;
+ this->control_stream_id = 0;
+ this->packet_size = 0;
+ this->seqno = 0;
+ this->frame_duration = 3000;
if (this->input->get_capabilities (this->input) & INPUT_CAP_SEEKABLE)
this->input->seek (this->input, 0, SEEK_SET);
- if (this->reference_mode) {
- xine_demux_control_start(this->stream);
- return;
- }
+ if (this->reference_mode)
+ {
+ xine_demux_control_start (this->stream);
+ return;
+ }
- if (!asf_read_header (this)) {
+ if (!asf_read_header (this))
+ {
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf ("demux_asf: asf_read_header failed.\n");
+ if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
+ printf ("demux_asf: asf_read_header failed.\n");
- this->status = DEMUX_FINISHED;
- return;
- } else {
+ this->status = DEMUX_FINISHED;
+ return;
+ }
+ else
+ {
- /*
- * send start buffer
- */
- xine_demux_control_start(this->stream);
+ /*
+ * send start buffer
+ */
+ xine_demux_control_start (this->stream);
- this->header_size = this->input->get_current_pos (this->input);
+ this->header_size = this->input->get_current_pos (this->input);
- this->stream->meta_info[XINE_META_INFO_TITLE] =
- strdup (this->title);
- this->stream->meta_info[XINE_META_INFO_ARTIST] =
- strdup (this->author);
- this->stream->meta_info[XINE_META_INFO_COMMENT] =
- strdup (this->comment);
+ this->stream->meta_info[XINE_META_INFO_TITLE] = strdup (this->title);
+ this->stream->meta_info[XINE_META_INFO_ARTIST] = strdup (this->author);
+ this->stream->meta_info[XINE_META_INFO_COMMENT] =
+ strdup (this->comment);
- /* Choose the best audio and the best video stream.
- * Use the bitrate to do the choice.
- */
- max_vrate = 0;
- max_arate = 0;
- for (i = 0; i < this->num_streams; i++) {
- buf_type = (this->streams[i].buf_type & BUF_MAJOR_MASK);
- stream_id = this->streams[i].stream_id;
- bitrate = this->bitrates[stream_id];
+ /* Choose the best audio and the best video stream.
+ * Use the bitrate to do the choice.
+ */
+ max_vrate = 0;
+ max_arate = 0;
+ for (i = 0; i < this->num_streams; i++)
+ {
+ buf_type = (this->streams[i].buf_type & BUF_MAJOR_MASK);
+ stream_id = this->streams[i].stream_id;
+ bitrate = this->bitrates[stream_id];
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_LOG)
- printf("demux_asf: stream: %d, bitrate %d bps\n", stream_id, bitrate);
- if ((buf_type == BUF_VIDEO_BASE) &&
- (bitrate > max_vrate || this->video_stream_id == 0)) {
+ if (this->stream->xine->verbosity >= XINE_VERBOSITY_LOG)
+ printf ("demux_asf: stream: %d, bitrate %d bps\n", stream_id,
+ bitrate);
+ if ((buf_type == BUF_VIDEO_BASE)
+ && (bitrate > max_vrate || this->video_stream_id == 0))
+ {
- this->stream->stream_info[XINE_STREAM_INFO_HAS_VIDEO] = 1;
- this->stream->stream_info[XINE_STREAM_INFO_VIDEO_BITRATE] = bitrate;
+ this->stream->stream_info[XINE_STREAM_INFO_HAS_VIDEO] = 1;
+ this->stream->stream_info[XINE_STREAM_INFO_VIDEO_BITRATE] =
+ bitrate;
- max_vrate = bitrate;
- this->video_stream = i;
- this->video_stream_id = stream_id;
- } else if ((buf_type == BUF_AUDIO_BASE) &&
- (bitrate > max_arate || this->audio_stream_id == 0)) {
+ max_vrate = bitrate;
+ this->video_stream = i;
+ this->video_stream_id = stream_id;
+ }
+ else if ((buf_type == BUF_AUDIO_BASE) &&
+ (bitrate > max_arate || this->audio_stream_id == 0))
+ {
- this->stream->stream_info[XINE_STREAM_INFO_HAS_AUDIO] = 1;
- this->stream->stream_info[XINE_STREAM_INFO_AUDIO_BITRATE] = bitrate;
+ this->stream->stream_info[XINE_STREAM_INFO_HAS_AUDIO] = 1;
+ this->stream->stream_info[XINE_STREAM_INFO_AUDIO_BITRATE] =
+ bitrate;
- max_arate = bitrate;
- this->audio_stream = i;
- this->audio_stream_id = stream_id;
- }
- }
+ max_arate = bitrate;
+ this->audio_stream = i;
+ this->audio_stream_id = stream_id;
+ }
+ }
- this->stream->stream_info[XINE_STREAM_INFO_BITRATE] = bitrate;
+ this->stream->stream_info[XINE_STREAM_INFO_BITRATE] = bitrate;
- if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf("demux_asf: video stream_id: %d, audio stream_id: %d\n",
- this->video_stream_id, this->audio_stream_id);
+ if (this->stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
+ printf ("demux_asf: video stream_id: %d, audio stream_id: %d\n",
+ this->video_stream_id, this->audio_stream_id);
- asf_send_audio_header(this, this->audio_stream);
- asf_send_video_header(this, this->video_stream);
+ asf_send_audio_header (this, this->audio_stream);
+ asf_send_video_header (this, this->video_stream);
#ifdef LOG
- printf ("demux_asf: send header done\n");
+ printf ("demux_asf: send header done\n");
#endif
- }
+ }
this->frame = 0;
this->nb_frames = 1;
}
-static int demux_asf_seek (demux_plugin_t *this_gen,
- off_t start_pos, int start_time) {
+static int
+demux_asf_seek (demux_plugin_t * this_gen, off_t start_pos, int start_time)
+{
demux_asf_t *this = (demux_asf_t *) this_gen;
int i;
this->status = DEMUX_OK;
- xine_demux_flush_engine(this->stream);
+ xine_demux_flush_engine (this->stream);
/*
* seek to start position
*/
- this->send_newpts = 1;
- this->frame = 0;
- this->nb_frames = 1;
- this->packet_size_left = 0;
- this->keyframe_found = (this->num_video_streams==0);
+ this->send_newpts = 1;
+ this->frame = 0;
+ this->nb_frames = 1;
+ this->packet_size_left = 0;
+ this->keyframe_found = (this->num_video_streams == 0);
- for(i = 0; i < this->num_streams; i++) {
- this->streams[i].frag_offset = 0;
- this->streams[i].seq = 0;
- this->streams[i].timestamp = 0;
- }
+ for (i = 0; i < this->num_streams; i++)
+ {
+ this->streams[i].frag_offset = 0;
+ this->streams[i].seq = 0;
+ this->streams[i].timestamp = 0;
+ }
- if (this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) {
+ if (this->input->get_capabilities (this->input) & INPUT_CAP_SEEKABLE)
+ {
- if ( (!start_pos) && (start_time))
- start_pos = start_time * this->rate;
+ if ((!start_pos) && (start_time))
+ start_pos = start_time * this->rate;
- if (start_pos < this->header_size)
- start_pos = this->header_size;
+ if (start_pos < this->header_size)
+ start_pos = this->header_size;
- this->input->seek (this->input, start_pos, SEEK_SET);
+ this->input->seek (this->input, start_pos, SEEK_SET);
- }
+ }
/*
* now start demuxing
*/
- if( !this->stream->demux_thread_running ) {
- this->buf_flag_seek = 0;
- } else {
- this->buf_flag_seek = 1;
- xine_demux_flush_engine(this->stream);
- }
+ if (!this->stream->demux_thread_running)
+ {
+ this->buf_flag_seek = 0;
+ }
+ else
+ {
+ this->buf_flag_seek = 1;
+ xine_demux_flush_engine (this->stream);
+ }
return this->status;
}
-static int demux_asf_get_stream_length (demux_plugin_t *this_gen) {
+static int
+demux_asf_get_stream_length (demux_plugin_t * this_gen)
+{
demux_asf_t *this = (demux_asf_t *) this_gen;
return this->length;
}
-static uint32_t demux_asf_get_capabilities(demux_plugin_t *this_gen) {
+static uint32_t
+demux_asf_get_capabilities (demux_plugin_t * this_gen)
+{
return DEMUX_CAP_NOCAP;
}
-static int demux_asf_get_optional_data(demux_plugin_t *this_gen,
- void *data, int data_type) {
+static int
+demux_asf_get_optional_data (demux_plugin_t * this_gen,
+ void *data, int data_type)
+{
return DEMUX_OPTIONAL_UNSUPPORTED;
}
-static demux_plugin_t *open_plugin (demux_class_t *class_gen,
- xine_stream_t *stream,
- input_plugin_t *input) {
+static demux_plugin_t *
+open_plugin (demux_class_t * class_gen,
+ xine_stream_t * stream, input_plugin_t * input)
+{
demux_asf_t *this;
- uint8_t buf[MAX_PREVIEW_SIZE+1];
- int len;
+ uint8_t buf[MAX_PREVIEW_SIZE + 1];
+ int len;
- switch (stream->content_detection_method) {
- case METHOD_BY_CONTENT:
+ switch (stream->content_detection_method)
+ {
+ case METHOD_BY_CONTENT:
- /*
- * try to get a preview of the data
- */
- len = input->get_optional_data (input, buf, INPUT_OPTIONAL_DATA_PREVIEW);
- if (len == INPUT_OPTIONAL_UNSUPPORTED) {
+ /*
+ * try to get a preview of the data
+ */
+ len =
+ input->get_optional_data (input, buf, INPUT_OPTIONAL_DATA_PREVIEW);
+ if (len == INPUT_OPTIONAL_UNSUPPORTED)
+ {
- if (input->get_capabilities (input) & INPUT_CAP_SEEKABLE) {
+ if (input->get_capabilities (input) & INPUT_CAP_SEEKABLE)
+ {
- input->seek (input, 0, SEEK_SET);
- if ( (len=input->read (input, buf, 1024)) <= 0)
- return NULL;
+ input->seek (input, 0, SEEK_SET);
+ if ((len = input->read (input, buf, 1024)) <= 0)
+ return NULL;
#ifdef LOG
- printf ("demux_asf: PREVIEW data unavailable, but seek+read worked.\n");
+ printf
+ ("demux_asf: PREVIEW data unavailable, but seek+read
worked.\n");
#endif
- } else
- return NULL;
- }
+ }
+ else
+ return NULL;
+ }
- if (memcmp(buf, &guids[GUID_ASF_HEADER].guid, sizeof(GUID))) {
- buf[len] = '\0';
- if( !strstr(buf,"asx") &&
- !strstr(buf,"ASX") &&
- strncmp(buf,"[Reference]", 11) &&
- strncmp(buf,"ASF ", 4) &&
- ((buf[0] != 0x30)
- || (buf[1] != 0x26)
- || (buf[2] != 0xb2)
- || (buf[3] != 0x75)))
- return NULL;
- }
+ if (memcmp (buf, &guids[GUID_ASF_HEADER].guid, sizeof (GUID)))
+ {
+ buf[len] = '\0';
+ if (!strstr (buf, "asx") &&
+ !strstr (buf, "ASX") &&
+ strncmp (buf, "[Reference]", 11) &&
+ strncmp (buf, "ASF ", 4) &&
+ ((buf[0] != 0x30)
+ || (buf[1] != 0x26) || (buf[2] != 0xb2) || (buf[3] != 0x75)))
+ return NULL;
+ }
#ifdef LOG
- printf ("demux_asf: file starts with an asf header\n");
+ printf ("demux_asf: file starts with an asf header\n");
#endif
- break;
+ break;
- case METHOD_BY_EXTENSION: {
- char *ending, *mrl;
+ case METHOD_BY_EXTENSION:
+ {
+ char *ending, *mrl;
- mrl = input->get_mrl (input);
+ mrl = input->get_mrl (input);
- /*
- * check extension
- */
+ /*
+ * check extension
+ */
- ending = strrchr (mrl, '.');
+ ending = strrchr (mrl, '.');
- if (!ending)
- return NULL;
+ if (!ending)
+ return NULL;
- if (strncasecmp(ending, ".asf", 4) &&
- strncasecmp(ending, ".wmv", 4) &&
- strncasecmp(ending, ".wma", 4) ) {
- return NULL;
- }
+ if (strncasecmp (ending, ".asf", 4) &&
+ strncasecmp (ending, ".wmv", 4) &&
+ strncasecmp (ending, ".wma", 4))
+ {
+ return NULL;
+ }
#ifdef LOG
- printf ("demux_asf: extension accepted.\n");
+ printf ("demux_asf: extension accepted.\n");
#endif
- }
- break;
+ }
+ break;
- case METHOD_EXPLICIT:
- break;
+ case METHOD_EXPLICIT:
+ break;
- default:
- printf ("demux_asf: warning, unkown method %d\n",
- stream->content_detection_method);
- return NULL;
- }
+ default:
+ printf ("demux_asf: warning, unkown method %d\n",
+ stream->content_detection_method);
+ return NULL;
+ }
- this = xine_xmalloc (sizeof (demux_asf_t));
+ this = xine_xmalloc (sizeof (demux_asf_t));
this->stream = stream;
- this->input = input;
+ this->input = input;
/*
* check for reference stream
*/
this->reference_mode = 0;
len = input->get_optional_data (input, buf, INPUT_OPTIONAL_DATA_PREVIEW);
- if ( (len == INPUT_OPTIONAL_UNSUPPORTED) &&
- (input->get_capabilities (input) & INPUT_CAP_SEEKABLE) ) {
- input->seek (input, 0, SEEK_SET);
- len=input->read (input, buf, 1024);
- }
- if(len > 0) {
- buf[len] = '\0';
- if( strstr(buf,"asx") || strstr(buf,"ASX") )
- this->reference_mode = 1;
- if( strstr(buf,"[Reference]") )
- this->reference_mode = 2;
- if( strstr(buf,"ASF ") )
- this->reference_mode = 3;
- }
+ if ((len == INPUT_OPTIONAL_UNSUPPORTED) &&
+ (input->get_capabilities (input) & INPUT_CAP_SEEKABLE))
+ {
+ input->seek (input, 0, SEEK_SET);
+ len = input->read (input, buf, 1024);
+ }
+ if (len > 0)
+ {
+ buf[len] = '\0';
+ if (strstr (buf, "asx") || strstr (buf, "ASX"))
+ this->reference_mode = 1;
+ if (strstr (buf, "[Reference]"))
+ this->reference_mode = 2;
+ if (strstr (buf, "ASF "))
+ this->reference_mode = 3;
+ }
- this->demux_plugin.send_headers = demux_asf_send_headers;
- this->demux_plugin.send_chunk = demux_asf_send_chunk;
- this->demux_plugin.seek = demux_asf_seek;
- this->demux_plugin.dispose = demux_asf_dispose;
- this->demux_plugin.get_status = demux_asf_get_status;
+ this->demux_plugin.send_headers = demux_asf_send_headers;
+ this->demux_plugin.send_chunk = demux_asf_send_chunk;
+ this->demux_plugin.seek = demux_asf_seek;
+ this->demux_plugin.dispose = demux_asf_dispose;
+ this->demux_plugin.get_status = demux_asf_get_status;
this->demux_plugin.get_stream_length = demux_asf_get_stream_length;
- this->demux_plugin.get_video_frame = NULL;
- this->demux_plugin.got_video_frame_cb= NULL;
- this->demux_plugin.get_capabilities = demux_asf_get_capabilities;
+ this->demux_plugin.get_video_frame = NULL;
+ this->demux_plugin.got_video_frame_cb = NULL;
+ this->demux_plugin.get_capabilities = demux_asf_get_capabilities;
this->demux_plugin.get_optional_data = demux_asf_get_optional_data;
- this->demux_plugin.demux_class = class_gen;
+ this->demux_plugin.demux_class = class_gen;
this->status = DEMUX_FINISHED;
return &this->demux_plugin;
}
-static char *get_description (demux_class_t *this_gen) {
+static char *
+get_description (demux_class_t * this_gen)
+{
return "ASF demux plugin";
}
-static char *get_identifier (demux_class_t *this_gen) {
+static char *
+get_identifier (demux_class_t * this_gen)
+{
return "ASF";
}
-static char *get_extensions (demux_class_t *this_gen) {
+static char *
+get_extensions (demux_class_t * this_gen)
+{
/* asx, wvx, wax are metafile or playlist */
return "asf wmv wma asx wvx wax";
}
-static char *get_mimetypes (demux_class_t *this_gen) {
+static char *
+get_mimetypes (demux_class_t * this_gen)
+{
return "video/x-ms-asf: asf: ASF stream;"
- "video/x-ms-wmv: wmv: Windows Media Video;"
- "video/x-ms-wma: wma: Windows Media Audio;"
- "application/vnd.ms-asf: asf: ASF stream;"
- "application/x-mplayer2: asf,asx,asp: mplayer2;"
- "video/x-ms-asf-plugin: asf,asx,asp: mms animation;"
- "video/x-ms-wvx: wvx: wmv metafile;"
- "video/x-ms-wax: wva: wma metafile;";
+ "video/x-ms-wmv: wmv: Windows Media Video;"
+ "video/x-ms-wma: wma: Windows Media Audio;"
+ "application/vnd.ms-asf: asf: ASF stream;"
+ "application/x-mplayer2: asf,asx,asp: mplayer2;"
+ "video/x-ms-asf-plugin: asf,asx,asp: mms animation;"
+ "video/x-ms-wvx: wvx: wmv metafile;" "video/x-ms-wax: wva: wma metafile;";
}
-static void class_dispose (demux_class_t *this_gen) {
+static void
+class_dispose (demux_class_t * this_gen)
+{
demux_asf_class_t *this = (demux_asf_class_t *) this_gen;
free (this);
}
-static void *init_class (xine_t *xine, void *data) {
+static void *
+init_class (xine_t * xine, void *data)
+{
- demux_asf_class_t *this;
+ demux_asf_class_t *this;
- this = xine_xmalloc (sizeof (demux_asf_class_t));
+ this = xine_xmalloc (sizeof (demux_asf_class_t));
this->config = xine->config;
- this->xine = xine;
+ this->xine = xine;
- this->demux_class.open_plugin = open_plugin;
+ this->demux_class.open_plugin = open_plugin;
this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.get_identifier = get_identifier;
+ this->demux_class.get_mimetypes = get_mimetypes;
+ this->demux_class.get_extensions = get_extensions;
+ this->demux_class.dispose = class_dispose;
return this;
}
@@ -1924,6 +2262,7 @@
plugin_info_t xine_plugin_info[] = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 20, "asf", XINE_VERSION_CODE, NULL, init_class },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
+ {PLUGIN_DEMUX, 20, "asf", XINE_VERSION_CODE, NULL, init_class}
+ ,
+ {PLUGIN_NONE, 0, "", 0, NULL, NULL}
};
Modified: Extractor/doc/demux_nsf.c
===================================================================
--- Extractor/doc/demux_nsf.c 2007-07-29 08:04:12 UTC (rev 5367)
+++ Extractor/doc/demux_nsf.c 2007-07-29 08:35:49 UTC (rev 5368)
@@ -54,82 +54,86 @@
#define NSF_REFRESH_RATE 60
#define NSF_PTS_INC (90000 / NSF_REFRESH_RATE)
-typedef struct {
+typedef struct
+{
- demux_plugin_t demux_plugin;
+ demux_plugin_t demux_plugin;
- xine_stream_t *stream;
+ xine_stream_t *stream;
- config_values_t *config;
+ config_values_t *config;
- fifo_buffer_t *video_fifo;
- fifo_buffer_t *audio_fifo;
+ fifo_buffer_t *video_fifo;
+ fifo_buffer_t *audio_fifo;
- input_plugin_t *input;
+ input_plugin_t *input;
- pthread_t thread;
- int thread_running;
- pthread_mutex_t mutex;
- int send_end_buffers;
+ pthread_t thread;
+ int thread_running;
+ pthread_mutex_t mutex;
+ int send_end_buffers;
- int status;
+ int status;
- char *title;
- char *artist;
- char *copyright;
- int total_songs;
- int current_song;
- int new_song; /* indicates song change */
- off_t filesize;
+ char *title;
+ char *artist;
+ char *copyright;
+ int total_songs;
+ int current_song;
+ int new_song; /* indicates song change */
+ off_t filesize;
- int64_t current_pts;
- int file_sent;
+ int64_t current_pts;
+ int file_sent;
- char last_mrl[1024];
+ char last_mrl[1024];
} demux_nsf_t;
-typedef struct {
+typedef struct
+{
- demux_class_t demux_class;
+ demux_class_t demux_class;
/* class-wide, global variables here */
- xine_t *xine;
- config_values_t *config;
+ xine_t *xine;
+ config_values_t *config;
} demux_nsf_class_t;
/* returns 1 if the NSF file was opened successfully, 0 otherwise */
-static int open_nsf_file(demux_nsf_t *this) {
+static int
+open_nsf_file (demux_nsf_t * this)
+{
unsigned char header[NSF_HEADER_SIZE];
- this->input->seek(this->input, 0, SEEK_SET);
- if (this->input->read(this->input, header, NSF_HEADER_SIZE) !=
- NSF_HEADER_SIZE)
+ this->input->seek (this->input, 0, SEEK_SET);
+ if (this->input->read (this->input, header, NSF_HEADER_SIZE) !=
+ NSF_HEADER_SIZE)
return 0;
/* check for the signature */
if ((header[0] != 'N') ||
(header[1] != 'E') ||
- (header[2] != 'S') ||
- (header[3] != 'M') ||
- (header[4] != 0x1A))
+ (header[2] != 'S') || (header[3] != 'M') || (header[4] != 0x1A))
return 0;
this->total_songs = header[6];
this->current_song = header[7];
- this->title = strdup(&header[0x0E]);
- this->artist = strdup(&header[0x2E]);
- this->copyright = strdup(&header[0x4E]);
+ this->title = strdup (&header[0x0E]);
+ this->artist = strdup (&header[0x2E]);
+ this->copyright = strdup (&header[0x4E]);
- this->filesize = this->input->get_length(this->input);
+ this->filesize = this->input->get_length (this->input);
return 1;
}
-static int demux_nsf_send_chunk(demux_plugin_t *this_gen) {
+static int
+demux_nsf_send_chunk (demux_plugin_t * this_gen)
+{
demux_nsf_t *this = (demux_nsf_t *) this_gen;
buf_element_t *buf;
@@ -138,68 +142,78 @@
/* send chunks of the file to the decoder until file is completely
* loaded; then send control buffers */
- if (!this->file_sent) {
- buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
- buf->type = BUF_AUDIO_NSF;
- bytes_read = this->input->read(this->input, buf->content, buf->max_size);
+ if (!this->file_sent)
+ {
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
+ buf->type = BUF_AUDIO_NSF;
+ bytes_read =
+ this->input->read (this->input, buf->content, buf->max_size);
- if (bytes_read == 0) {
- /* the file has been completely loaded, free the buffer and start
- * sending control buffers */
- buf->free_buffer(buf);
- this->file_sent = 1;
+ if (bytes_read == 0)
+ {
+ /* the file has been completely loaded, free the buffer and start
+ * sending control buffers */
+ buf->free_buffer (buf);
+ this->file_sent = 1;
- } else {
-
- /* keep loading the file */
- if (bytes_read < buf->max_size)
- buf->size = bytes_read;
+ }
else
- buf->size = buf->max_size;
+ {
- buf->extra_info->input_pos = 0;
- buf->extra_info->input_length = 0;
- buf->extra_info->input_time = 0;
- buf->pts = 0;
+ /* keep loading the file */
+ if (bytes_read < buf->max_size)
+ buf->size = bytes_read;
+ else
+ buf->size = buf->max_size;
- this->audio_fifo->put (this->audio_fifo, buf);
+ buf->extra_info->input_pos = 0;
+ buf->extra_info->input_length = 0;
+ buf->extra_info->input_time = 0;
+ buf->pts = 0;
+
+ this->audio_fifo->put (this->audio_fifo, buf);
+ }
}
- }
/* this is not an 'else' because control might fall through from above */
- if (this->file_sent) {
- /* send a control buffer */
- buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
+ if (this->file_sent)
+ {
+ /* send a control buffer */
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
- if (this->new_song) {
+ if (this->new_song)
+ {
- buf->decoder_info[1] = this->current_song;
- this->new_song = 0;
- sprintf(title, "%s, song %d/%d",
- this->title, this->current_song, this->total_songs);
- if (this->stream->meta_info[XINE_META_INFO_TITLE])
- free (this->stream->meta_info[XINE_META_INFO_TITLE]);
- this->stream->meta_info[XINE_META_INFO_TITLE] = strdup(title);
- xine_demux_control_newpts(this->stream, this->current_pts, 0);
+ buf->decoder_info[1] = this->current_song;
+ this->new_song = 0;
+ sprintf (title, "%s, song %d/%d",
+ this->title, this->current_song, this->total_songs);
+ if (this->stream->meta_info[XINE_META_INFO_TITLE])
+ free (this->stream->meta_info[XINE_META_INFO_TITLE]);
+ this->stream->meta_info[XINE_META_INFO_TITLE] = strdup (title);
+ xine_demux_control_newpts (this->stream, this->current_pts, 0);
- } else
- buf->decoder_info[1] = 0;
+ }
+ else
+ buf->decoder_info[1] = 0;
- buf->type = BUF_AUDIO_NSF;
- buf->extra_info->input_pos = this->current_song - 1;
- buf->extra_info->input_length = this->total_songs;
- buf->extra_info->input_time = this->current_pts / 90;
- buf->pts = this->current_pts;
- buf->size = 0;
- this->audio_fifo->put (this->audio_fifo, buf);
+ buf->type = BUF_AUDIO_NSF;
+ buf->extra_info->input_pos = this->current_song - 1;
+ buf->extra_info->input_length = this->total_songs;
+ buf->extra_info->input_time = this->current_pts / 90;
+ buf->pts = this->current_pts;
+ buf->size = 0;
+ this->audio_fifo->put (this->audio_fifo, buf);
- this->current_pts += NSF_PTS_INC;
- }
+ this->current_pts += NSF_PTS_INC;
+ }
return this->status;
}
-static void demux_nsf_send_headers(demux_plugin_t *this_gen) {
+static void
+demux_nsf_send_headers (demux_plugin_t * this_gen)
+{
demux_nsf_t *this = (demux_nsf_t *) this_gen;
buf_element_t *buf;
@@ -213,218 +227,251 @@
/* load stream information */
this->stream->stream_info[XINE_STREAM_INFO_HAS_VIDEO] = 0;
this->stream->stream_info[XINE_STREAM_INFO_HAS_AUDIO] = 1;
- this->stream->stream_info[XINE_STREAM_INFO_AUDIO_CHANNELS] =
- NSF_CHANNELS;
+ this->stream->stream_info[XINE_STREAM_INFO_AUDIO_CHANNELS] = NSF_CHANNELS;
this->stream->stream_info[XINE_STREAM_INFO_AUDIO_SAMPLERATE] =
NSF_SAMPLERATE;
- this->stream->stream_info[XINE_STREAM_INFO_AUDIO_BITS] =
- NSF_BITS;
+ this->stream->stream_info[XINE_STREAM_INFO_AUDIO_BITS] = NSF_BITS;
- this->stream->meta_info[XINE_META_INFO_TITLE] = strdup(this->title);
- this->stream->meta_info[XINE_META_INFO_ARTIST] = strdup(this->artist);
- sprintf(copyright, "(C) %s", this->copyright);
- this->stream->meta_info[XINE_META_INFO_COMMENT] = strdup(copyright);
+ this->stream->meta_info[XINE_META_INFO_TITLE] = strdup (this->title);
+ this->stream->meta_info[XINE_META_INFO_ARTIST] = strdup (this->artist);
+ sprintf (copyright, "(C) %s", this->copyright);
+ this->stream->meta_info[XINE_META_INFO_COMMENT] = strdup (copyright);
/* send start buffers */
- xine_demux_control_start(this->stream);
+ xine_demux_control_start (this->stream);
/* send init info to the audio decoder */
- if (this->audio_fifo) {
- buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
- buf->type = BUF_AUDIO_NSF;
- buf->decoder_flags = BUF_FLAG_HEADER;
- buf->decoder_info[0] = 5;
- buf->decoder_info[1] = NSF_SAMPLERATE;
- buf->decoder_info[2] = NSF_BITS;
- buf->decoder_info[3] = NSF_CHANNELS;
+ if (this->audio_fifo)
+ {
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
+ buf->type = BUF_AUDIO_NSF;
+ buf->decoder_flags = BUF_FLAG_HEADER;
+ buf->decoder_info[0] = 5;
+ buf->decoder_info[1] = NSF_SAMPLERATE;
+ buf->decoder_info[2] = NSF_BITS;
+ buf->decoder_info[3] = NSF_CHANNELS;
- /* send the NSF filesize in the body, big endian format */
- buf->content[0] = (this->filesize >> 24) & 0xFF;
- buf->content[1] = (this->filesize >> 16) & 0xFF;
- buf->content[2] = (this->filesize >> 8) & 0xFF;
- buf->content[3] = (this->filesize >> 0) & 0xFF;
- /* send the requested song */
- buf->content[4] = this->current_song + 5;
+ /* send the NSF filesize in the body, big endian format */
+ buf->content[0] = (this->filesize >> 24) & 0xFF;
+ buf->content[1] = (this->filesize >> 16) & 0xFF;
+ buf->content[2] = (this->filesize >> 8) & 0xFF;
+ buf->content[3] = (this->filesize >> 0) & 0xFF;
+ /* send the requested song */
+ buf->content[4] = this->current_song + 5;
- this->audio_fifo->put (this->audio_fifo, buf);
- }
+ this->audio_fifo->put (this->audio_fifo, buf);
+ }
}
-static int demux_nsf_seek (demux_plugin_t *this_gen,
- off_t start_pos, int start_time) {
+static int
+demux_nsf_seek (demux_plugin_t * this_gen, off_t start_pos, int start_time)
+{
demux_nsf_t *this = (demux_nsf_t *) this_gen;
/* if thread is not running, initialize demuxer */
- if( !this->stream->demux_thread_running ) {
+ if (!this->stream->demux_thread_running)
+ {
- /* send new pts */
- xine_demux_control_newpts(this->stream, 0, 0);
+ /* send new pts */
+ xine_demux_control_newpts (this->stream, 0, 0);
- this->status = DEMUX_OK;
+ this->status = DEMUX_OK;
- /* reposition stream at the start for loading */
- this->input->seek(this->input, 0, SEEK_SET);
+ /* reposition stream at the start for loading */
+ this->input->seek (this->input, 0, SEEK_SET);
- this->file_sent = 0;
- this->current_pts = 0;
- this->new_song = 1;
- } else {
- this->current_song = start_pos + 1;
- this->new_song = 1;
- this->current_pts = 0;
- xine_demux_flush_engine(this->stream);
- }
+ this->file_sent = 0;
+ this->current_pts = 0;
+ this->new_song = 1;
+ }
+ else
+ {
+ this->current_song = start_pos + 1;
+ this->new_song = 1;
+ this->current_pts = 0;
+ xine_demux_flush_engine (this->stream);
+ }
return this->status;
}
-static void demux_nsf_dispose (demux_plugin_t *this_gen) {
+static void
+demux_nsf_dispose (demux_plugin_t * this_gen)
+{
demux_nsf_t *this = (demux_nsf_t *) this_gen;
- free(this->title);
- free(this->artist);
- free(this->copyright);
- free(this);
+ free (this->title);
+ free (this->artist);
+ free (this->copyright);
+ free (this);
}
-static int demux_nsf_get_status (demux_plugin_t *this_gen) {
+static int
+demux_nsf_get_status (demux_plugin_t * this_gen)
+{
demux_nsf_t *this = (demux_nsf_t *) this_gen;
return this->status;
}
/* return the approximate length in miliseconds */
-static int demux_nsf_get_stream_length (demux_plugin_t *this_gen) {
+static int
+demux_nsf_get_stream_length (demux_plugin_t * this_gen)
+{
return 0;
}
-static uint32_t demux_nsf_get_capabilities(demux_plugin_t *this_gen) {
+static uint32_t
+demux_nsf_get_capabilities (demux_plugin_t * this_gen)
+{
return DEMUX_CAP_NOCAP;
}
-static int demux_nsf_get_optional_data(demux_plugin_t *this_gen,
- void *data, int data_type) {
+static int
+demux_nsf_get_optional_data (demux_plugin_t * this_gen,
+ void *data, int data_type)
+{
return DEMUX_OPTIONAL_UNSUPPORTED;
}
-static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t
*stream,
- input_plugin_t *input_gen) {
+static demux_plugin_t *
+open_plugin (demux_class_t * class_gen, xine_stream_t * stream,
+ input_plugin_t * input_gen)
+{
input_plugin_t *input = (input_plugin_t *) input_gen;
- demux_nsf_t *this;
+ demux_nsf_t *this;
- if (! (input->get_capabilities(input) & INPUT_CAP_SEEKABLE)) {
- if (stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
- printf(_("demux_nsf.c: input not seekable, can not handle!\n"));
- return NULL;
- }
+ if (!(input->get_capabilities (input) & INPUT_CAP_SEEKABLE))
+ {
+ if (stream->xine->verbosity >= XINE_VERBOSITY_DEBUG)
+ printf (_("demux_nsf.c: input not seekable, can not handle!\n"));
+ return NULL;
+ }
- this = xine_xmalloc (sizeof (demux_nsf_t));
+ this = xine_xmalloc (sizeof (demux_nsf_t));
this->stream = stream;
- this->input = input;
+ this->input = input;
- this->demux_plugin.send_headers = demux_nsf_send_headers;
- this->demux_plugin.send_chunk = demux_nsf_send_chunk;
- this->demux_plugin.seek = demux_nsf_seek;
- this->demux_plugin.dispose = demux_nsf_dispose;
- this->demux_plugin.get_status = demux_nsf_get_status;
+ this->demux_plugin.send_headers = demux_nsf_send_headers;
+ this->demux_plugin.send_chunk = demux_nsf_send_chunk;
+ this->demux_plugin.seek = demux_nsf_seek;
+ this->demux_plugin.dispose = demux_nsf_dispose;
+ this->demux_plugin.get_status = demux_nsf_get_status;
this->demux_plugin.get_stream_length = demux_nsf_get_stream_length;
- this->demux_plugin.get_video_frame = NULL;
- this->demux_plugin.got_video_frame_cb= NULL;
- this->demux_plugin.get_capabilities = demux_nsf_get_capabilities;
+ this->demux_plugin.get_video_frame = NULL;
+ this->demux_plugin.got_video_frame_cb = NULL;
+ this->demux_plugin.get_capabilities = demux_nsf_get_capabilities;
this->demux_plugin.get_optional_data = demux_nsf_get_optional_data;
- this->demux_plugin.demux_class = class_gen;
+ this->demux_plugin.demux_class = class_gen;
this->status = DEMUX_FINISHED;
- switch (stream->content_detection_method) {
+ switch (stream->content_detection_method)
+ {
- case METHOD_BY_CONTENT:
- case METHOD_EXPLICIT:
+ case METHOD_BY_CONTENT:
+ case METHOD_EXPLICIT:
- if (!open_nsf_file(this)) {
- free (this);
- return NULL;
- }
+ if (!open_nsf_file (this))
+ {
+ free (this);
+ return NULL;
+ }
- break;
+ break;
- case METHOD_BY_EXTENSION: {
- char *ending, *mrl;
+ case METHOD_BY_EXTENSION:
+ {
+ char *ending, *mrl;
- mrl = input->get_mrl (input);
+ mrl = input->get_mrl (input);
- ending = strrchr(mrl, '.');
+ ending = strrchr (mrl, '.');
- if (!ending) {
- free (this);
- return NULL;
- }
+ if (!ending)
+ {
+ free (this);
+ return NULL;
+ }
- if (strncasecmp (ending, ".nsf", 4)) {
- free (this);
- return NULL;
- }
+ if (strncasecmp (ending, ".nsf", 4))
+ {
+ free (this);
+ return NULL;
+ }
- if (!open_nsf_file(this)) {
+ if (!open_nsf_file (this))
+ {
+ free (this);
+ return NULL;
+ }
+
+ }
+
+ break;
+
+ default:
free (this);
return NULL;
}
- }
-
- break;
-
- default:
- free (this);
- return NULL;
- }
-
strncpy (this->last_mrl, input->get_mrl (input), 1024);
return &this->demux_plugin;
}
-static char *get_description (demux_class_t *this_gen) {
+static char *
+get_description (demux_class_t * this_gen)
+{
return "NES Music file demux plugin";
}
-static char *get_identifier (demux_class_t *this_gen) {
+static char *
+get_identifier (demux_class_t * this_gen)
+{
return "NSF";
}
-static char *get_extensions (demux_class_t *this_gen) {
+static char *
+get_extensions (demux_class_t * this_gen)
+{
return "nsf";
}
-static char *get_mimetypes (demux_class_t *this_gen) {
+static char *
+get_mimetypes (demux_class_t * this_gen)
+{
return NULL;
}
-static void class_dispose (demux_class_t *this_gen) {
+static void
+class_dispose (demux_class_t * this_gen)
+{
demux_nsf_class_t *this = (demux_nsf_class_t *) this_gen;
free (this);
}
-void *demux_nsf_init_plugin (xine_t *xine, void *data) {
+void *
+demux_nsf_init_plugin (xine_t * xine, void *data)
+{
- demux_nsf_class_t *this;
+ demux_nsf_class_t *this;
- this = xine_xmalloc (sizeof (demux_nsf_class_t));
+ this = xine_xmalloc (sizeof (demux_nsf_class_t));
this->config = xine->config;
- this->xine = xine;
+ this->xine = xine;
- this->demux_class.open_plugin = open_plugin;
+ this->demux_class.open_plugin = open_plugin;
this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.get_identifier = get_identifier;
+ this->demux_class.get_mimetypes = get_mimetypes;
+ this->demux_class.get_extensions = get_extensions;
+ this->demux_class.dispose = class_dispose;
return this;
}
-
Modified: Extractor/doc/demux_qt.c
===================================================================
--- Extractor/doc/demux_qt.c 2007-07-29 08:04:12 UTC (rev 5367)
+++ Extractor/doc/demux_qt.c 2007-07-29 08:35:49 UTC (rev 5368)
@@ -122,11 +122,13 @@
#define MAX_PTS_DIFF 100000
/* network bandwidth, cribbed from src/input/input_mms.c */
-const int64_t bandwidths[]={14400,19200,28800,33600,34430,57600,
- 115200,262200,393216,524300,1544000,10485800};
+const int64_t bandwidths[] = { 14400, 19200, 28800, 33600, 34430, 57600,
+ 115200, 262200, 393216, 524300, 1544000, 10485800
+};
/* these are things that can go wrong */
-typedef enum {
+typedef enum
+{
QT_OK,
QT_FILE_READ_ERROR,
QT_NO_MEMORY,
@@ -138,49 +140,57 @@
} qt_error;
/* there are other types but these are the ones we usually care about */
-typedef enum {
+typedef enum
+{
MEDIA_AUDIO,
MEDIA_VIDEO,
MEDIA_OTHER
-
} media_type;
-typedef struct {
+typedef struct
+{
int64_t offset;
unsigned int size;
int64_t pts;
int keyframe;
} qt_frame;
-typedef struct {
+typedef struct
+{
unsigned int track_duration;
unsigned int media_time;
} edit_list_table_t;
-typedef struct {
+typedef struct
+{
unsigned int first_chunk;
unsigned int samples_per_chunk;
} sample_to_chunk_table_t;
-typedef struct {
+typedef struct
+{
unsigned int count;
unsigned int duration;
} time_to_sample_table_t;
-typedef struct {
+typedef struct
+{
unsigned char *url;
int64_t data_rate;
int qtim_version;
} reference_t;
-typedef struct {
+typedef struct
+{
/* trak description */
media_type type;
- union {
+ union
+ {
- struct {
+ struct
+ {
unsigned int codec_fourcc;
unsigned int codec_buftype;
unsigned int width;
@@ -188,10 +198,11 @@
int palette_count;
palette_entry_t palette[PALETTE_COUNT];
int depth;
- int edit_list_compensation; /* special trick for edit lists */
+ int edit_list_compensation; /* special trick for edit lists */
} video;
- struct {
+ struct
+ {
unsigned int codec_fourcc;
unsigned int codec_buftype;
unsigned int sample_rate;
@@ -227,8 +238,8 @@
int decoder_config_len;
/* verbatim copy of the stsd atom */
- int stsd_size;
- void *stsd;
+ int stsd_size;
+ void *stsd;
/****************************************/
/* temporary tables for loading a chunk */
@@ -260,75 +271,78 @@
} qt_trak;
-typedef struct {
- int compressed_header; /* 1 if there was a compressed moov; just FYI */
+typedef struct
+{
+ int compressed_header; /* 1 if there was a compressed moov; just FYI
*/
- unsigned int creation_time; /* in ms since Jan-01-1904 */
+ unsigned int creation_time; /* in ms since Jan-01-1904 */
unsigned int modification_time;
- unsigned int timescale; /* base clock frequency is Hz */
+ unsigned int timescale; /* base clock frequency is Hz */
unsigned int duration;
int64_t moov_first_offset;
- int trak_count;
- qt_trak *traks;
+ int trak_count;
+ qt_trak *traks;
/* the trak numbers that won their respective frame count competitions */
- int video_trak;
- int audio_trak;
- int seek_flag; /* this is set to indicate that a seek has just occurred */
+ int video_trak;
+ int audio_trak;
+ int seek_flag; /* this is set to indicate that a seek has
just occurred */
- char *copyright;
- char *description;
- char *comment;
+ char *copyright;
+ char *description;
+ char *comment;
/* a QT movie may contain a number of references pointing to URLs */
- reference_t *references;
- int reference_count;
- int chosen_reference;
+ reference_t *references;
+ int reference_count;
+ int chosen_reference;
/* need to know base MRL to construct URLs from relative paths */
- char *base_mrl;
+ char *base_mrl;
qt_error last_error;
} qt_info;
-typedef struct {
+typedef struct
+{
- demux_plugin_t demux_plugin;
+ demux_plugin_t demux_plugin;
- xine_stream_t *stream;
+ xine_stream_t *stream;
- config_values_t *config;
+ config_values_t *config;
- fifo_buffer_t *video_fifo;
- fifo_buffer_t *audio_fifo;
+ fifo_buffer_t *video_fifo;
+ fifo_buffer_t *audio_fifo;
- input_plugin_t *input;
+ input_plugin_t *input;
- int status;
+ int status;
- qt_info *qt;
- xine_bmiheader bih;
- unsigned int current_frame;
- unsigned int last_frame;
+ qt_info *qt;
+ xine_bmiheader bih;
+ unsigned int current_frame;
+ unsigned int last_frame;
- off_t data_start;
- off_t data_size;
+ off_t data_start;
+ off_t data_size;
- int64_t bandwidth;
+ int64_t bandwidth;
- char last_mrl[1024];
+ char last_mrl[1024];
} demux_qt_t;
-typedef struct {
+typedef struct
+{
- demux_class_t demux_class;
+ demux_class_t demux_class;
/* class-wide, global variables here */
- xine_t *xine;
- config_values_t *config;
+ xine_t *xine;
+ config_values_t *config;
} demux_qt_class_t;
/**********************************************************************
@@ -365,79 +379,102 @@
#if DEBUG_ATOM_LOAD
#define debug_atom_load printf
#else
-static inline void debug_atom_load(const char *format, ...) { }
+static inline void
+debug_atom_load (const char *format, ...)
+{
+}
#endif
#if DEBUG_EDIT_LIST
#define debug_edit_list printf
#else
-static inline void debug_edit_list(const char *format, ...) { }
+static inline void
+debug_edit_list (const char *format, ...)
+{
+}
#endif
#if DEBUG_FRAME_TABLE
#define debug_frame_table printf
#else
-static inline void debug_frame_table(const char *format, ...) { }
+static inline void
+debug_frame_table (const char *format, ...)
+{
+}
#endif
#if DEBUG_VIDEO_DEMUX
#define debug_video_demux printf
#else
-static inline void debug_video_demux(const char *format, ...) { }
+static inline void
+debug_video_demux (const char *format, ...)
+{
+}
#endif
#if DEBUG_AUDIO_DEMUX
#define debug_audio_demux printf
#else
-static inline void debug_audio_demux(const char *format, ...) { }
+static inline void
+debug_audio_demux (const char *format, ...)
+{
+}
#endif
-static void hexdump (char *buf, int length) {
+static void
+hexdump (char *buf, int length)
+{
int i;
printf ("demux_qt: ascii contents>");
- for (i = 0; i < length; i++) {
- unsigned char c = buf[i];
+ for (i = 0; i < length; i++)
+ {
+ unsigned char c = buf[i];
- if ((c >= 32) && (c < 128))
- printf ("%c", c);
- else
- printf (".");
- }
+ if ((c >= 32) && (c < 128))
+ printf ("%c", c);
+ else
+ printf (".");
+ }
printf ("\n");
- printf ("demux_qt: complete hexdump of package follows:\ndemux_qt 0x0000:
");
- for (i = 0; i < length; i++) {
- unsigned char c = buf[i];
+ printf
+ ("demux_qt: complete hexdump of package follows:\ndemux_qt 0x0000: ");
+ for (i = 0; i < length; i++)
+ {
+ unsigned char c = buf[i];
- printf ("%02x", c);
+ printf ("%02x", c);
- if ((i % 16) == 15)
- printf ("\ndemux_qt 0x%04x: ", i);
+ if ((i % 16) == 15)
+ printf ("\ndemux_qt 0x%04x: ", i);
- if ((i % 2) == 1)
- printf (" ");
+ if ((i % 2) == 1)
+ printf (" ");
- }
+ }
printf ("\n");
}
-static inline void dump_moov_atom(unsigned char *moov_atom, int
moov_atom_size) {
+static inline void
+dump_moov_atom (unsigned char *moov_atom, int moov_atom_size)
+{
#if DEBUG_DUMP_MOOV
FILE *f;
- f = fopen(RAW_MOOV_FILENAME, "w");
- if (!f) {
- perror(RAW_MOOV_FILENAME);
- return;
- }
+ f = fopen (RAW_MOOV_FILENAME, "w");
+ if (!f)
+ {
+ perror (RAW_MOOV_FILENAME);
+ return;
+ }
- if (fwrite(moov_atom, moov_atom_size, 1, f) != 1)
+ if (fwrite (moov_atom, moov_atom_size, 1, f) != 1)
printf (" qt debug: could not write moov atom to disk\n");
- fclose(f);
+ fclose (f);
#endif
}
@@ -455,8 +492,10 @@
* Note: Do not count on the input stream being positioned anywhere in
* particular when this function is finished.
*/
-static void find_moov_atom(input_plugin_t *input, off_t *moov_offset,
- int64_t *moov_size) {
+static void
+find_moov_atom (input_plugin_t * input, off_t * moov_offset,
+ int64_t * moov_size)
+{
off_t atom_size;
qt_atom atom;
@@ -466,84 +505,93 @@
*moov_offset = *moov_size = -1;
/* take it from the top */
- if (input->seek(input, 0, SEEK_SET) != 0)
+ if (input->seek (input, 0, SEEK_SET) != 0)
return;
/* traverse through the input */
- while (*moov_offset == -1) {
- if (input->read(input, atom_preamble, ATOM_PREAMBLE_SIZE) !=
- ATOM_PREAMBLE_SIZE)
- break;
+ while (*moov_offset == -1)
+ {
+ if (input->read (input, atom_preamble, ATOM_PREAMBLE_SIZE) !=
+ ATOM_PREAMBLE_SIZE)
+ break;
- atom_size = BE_32(&atom_preamble[0]);
- atom = BE_32(&atom_preamble[4]);
+ atom_size = BE_32 (&atom_preamble[0]);
+ atom = BE_32 (&atom_preamble[4]);
- /* if the moov atom is found, log the position and break from the loop */
- if (atom == MOOV_ATOM) {
- *moov_offset = input->get_current_pos(input) - ATOM_PREAMBLE_SIZE;
- *moov_size = atom_size;
- break;
- }
+ /* if the moov atom is found, log the position and break from the loop */
+ if (atom == MOOV_ATOM)
+ {
+ *moov_offset = input->get_current_pos (input) - ATOM_PREAMBLE_SIZE;
+ *moov_size = atom_size;
+ break;
+ }
- /* special case alert: 'free' atoms are known to contain 'cmov' atoms.
- * If this is a free atom, check for cmov immediately following.
- * QT Player can handle it, so xine should too. */
- if (atom == FREE_ATOM) {
+ /* special case alert: 'free' atoms are known to contain 'cmov' atoms.
+ * If this is a free atom, check for cmov immediately following.
+ * QT Player can handle it, so xine should too. */
+ if (atom == FREE_ATOM)
+ {
- /* get the next atom preamble */
- if (input->read(input, atom_preamble, ATOM_PREAMBLE_SIZE) !=
- ATOM_PREAMBLE_SIZE)
- break;
+ /* get the next atom preamble */
+ if (input->read (input, atom_preamble, ATOM_PREAMBLE_SIZE) !=
+ ATOM_PREAMBLE_SIZE)
+ break;
- /* if there is a cmov, qualify this free atom as the moov atom */
- if (BE_32(&atom_preamble[4]) == CMOV_ATOM) {
- /* pos = current pos minus 2 atom preambles */
- *moov_offset = input->get_current_pos(input) - ATOM_PREAMBLE_SIZE * 2;
- *moov_size = atom_size;
+ /* if there is a cmov, qualify this free atom as the moov atom */
+ if (BE_32 (&atom_preamble[4]) == CMOV_ATOM)
+ {
+ /* pos = current pos minus 2 atom preambles */
+ *moov_offset =
+ input->get_current_pos (input) - ATOM_PREAMBLE_SIZE * 2;
+ *moov_size = atom_size;
+ break;
+ }
+ else
+ {
+ /* otherwise, rewind the stream */
+ input->seek (input, -ATOM_PREAMBLE_SIZE, SEEK_CUR);
+ }
+ }
+
+ /* if this atom is not the moov atom, make sure that it is at least one
+ * of the other top-level QT atom */
+ if ((atom != FREE_ATOM) &&
+ (atom != JUNK_ATOM) &&
+ (atom != MDAT_ATOM) &&
+ (atom != PNOT_ATOM) &&
+ (atom != SKIP_ATOM) &&
+ (atom != WIDE_ATOM) && (atom != PICT_ATOM) && (atom != FTYP_ATOM))
break;
- } else {
- /* otherwise, rewind the stream */
- input->seek(input, -ATOM_PREAMBLE_SIZE, SEEK_CUR);
- }
- }
- /* if this atom is not the moov atom, make sure that it is at least one
- * of the other top-level QT atom */
- if ((atom != FREE_ATOM) &&
- (atom != JUNK_ATOM) &&
- (atom != MDAT_ATOM) &&
- (atom != PNOT_ATOM) &&
- (atom != SKIP_ATOM) &&
- (atom != WIDE_ATOM) &&
- (atom != PICT_ATOM) &&
- (atom != FTYP_ATOM))
- break;
+ /* 64-bit length special case */
+ if (atom_size == 1)
+ {
+ if (input->read (input, atom_preamble, ATOM_PREAMBLE_SIZE) !=
+ ATOM_PREAMBLE_SIZE)
+ break;
- /* 64-bit length special case */
- if (atom_size == 1) {
- if (input->read(input, atom_preamble, ATOM_PREAMBLE_SIZE) !=
- ATOM_PREAMBLE_SIZE)
- break;
+ atom_size = BE_32 (&atom_preamble[0]);
+ atom_size <<= 32;
+ atom_size |= BE_32 (&atom_preamble[4]);
+ atom_size -= ATOM_PREAMBLE_SIZE * 2;
+ }
+ else
+ atom_size -= ATOM_PREAMBLE_SIZE;
- atom_size = BE_32(&atom_preamble[0]);
- atom_size <<= 32;
- atom_size |= BE_32(&atom_preamble[4]);
- atom_size -= ATOM_PREAMBLE_SIZE * 2;
- } else
- atom_size -= ATOM_PREAMBLE_SIZE;
+ input->seek (input, atom_size, SEEK_CUR);
+ }
- input->seek(input, atom_size, SEEK_CUR);
- }
-
/* reset to the start of the stream on the way out */
- input->seek(input, 0, SEEK_SET);
+ input->seek (input, 0, SEEK_SET);
}
/* create a qt_info structure or return NULL if no memory */
-qt_info *create_qt_info(void) {
+qt_info *
+create_qt_info (void)
+{
qt_info *info;
- info = (qt_info *)malloc(sizeof(qt_info));
+ info = (qt_info *) malloc (sizeof (qt_info));
if (!info)
return NULL;
@@ -577,43 +625,51 @@
}
/* release a qt_info structure and associated data */
-void free_qt_info(qt_info *info) {
+void
+free_qt_info (qt_info * info)
+{
int i;
- if(info) {
- if(info->traks) {
- for (i = 0; i < info->trak_count; i++) {
- free(info->traks[i].frames);
- free(info->traks[i].edit_list_table);
- free(info->traks[i].chunk_offset_table);
- /* this pointer might have been set to -1 as a special case */
- if (info->traks[i].sample_size_table != (void *)-1)
- free(info->traks[i].sample_size_table);
- free(info->traks[i].sync_sample_table);
- free(info->traks[i].sample_to_chunk_table);
- free(info->traks[i].time_to_sample_table);
- free(info->traks[i].decoder_config);
- free(info->traks[i].stsd);
- }
- free(info->traks);
+ if (info)
+ {
+ if (info->traks)
+ {
+ for (i = 0; i < info->trak_count; i++)
+ {
+ free (info->traks[i].frames);
+ free (info->traks[i].edit_list_table);
+ free (info->traks[i].chunk_offset_table);
+ /* this pointer might have been set to -1 as a special case */
+ if (info->traks[i].sample_size_table != (void *) -1)
+ free (info->traks[i].sample_size_table);
+ free (info->traks[i].sync_sample_table);
+ free (info->traks[i].sample_to_chunk_table);
+ free (info->traks[i].time_to_sample_table);
+ free (info->traks[i].decoder_config);
+ free (info->traks[i].stsd);
+ }
+ free (info->traks);
+ }
+ if (info->references)
+ {
+ for (i = 0; i < info->reference_count; i++)
+ free (info->references[i].url);
+ free (info->references);
+ }
+ free (info->base_mrl);
+ free (info->copyright);
+ free (info->description);
+ free (info->comment);
+ free (info);
+ info = NULL;
}
- if(info->references) {
- for (i = 0; i < info->reference_count; i++)
- free(info->references[i].url);
- free(info->references);
- }
- free(info->base_mrl);
- free(info->copyright);
- free(info->description);
- free(info->comment);
- free(info);
- info = NULL;
- }
}
/* returns 1 if the file is determined to be a QT file, 0 otherwise */
-static int is_qt_file(input_plugin_t *qt_file) {
+static int
+is_qt_file (input_plugin_t * qt_file)
+{
off_t moov_atom_offset = -1;
int64_t moov_atom_size = -1;
@@ -624,55 +680,68 @@
/* if the input is non-seekable, be much more stringent about qualifying
* a QT file: In this case, the moov must be the first atom in the file */
- if ((qt_file->get_capabilities(qt_file) & INPUT_CAP_SEEKABLE) == 0) {
- len = qt_file->get_optional_data(qt_file, preview,
INPUT_OPTIONAL_DATA_PREVIEW);
- if (BE_32(&preview[4]) == MOOV_ATOM)
- return 1;
- else
- return 0;
- }
+ if ((qt_file->get_capabilities (qt_file) & INPUT_CAP_SEEKABLE) == 0)
+ {
+ len =
+ qt_file->get_optional_data (qt_file, preview,
+ INPUT_OPTIONAL_DATA_PREVIEW);
+ if (BE_32 (&preview[4]) == MOOV_ATOM)
+ return 1;
+ else
+ return 0;
+ }
- find_moov_atom(qt_file, &moov_atom_offset, &moov_atom_size);
- if (moov_atom_offset == -1) {
- return 0;
- } else {
- /* check that the next atom in the chunk contains alphanumeric
- * characters in the atom type field; if not, disqualify the file
- * as a QT file */
- qt_file->seek(qt_file, moov_atom_offset + ATOM_PREAMBLE_SIZE, SEEK_SET);
- if (qt_file->read(qt_file, atom_preamble, ATOM_PREAMBLE_SIZE) !=
- ATOM_PREAMBLE_SIZE)
+ find_moov_atom (qt_file, &moov_atom_offset, &moov_atom_size);
+ if (moov_atom_offset == -1)
+ {
return 0;
+ }
+ else
+ {
+ /* check that the next atom in the chunk contains alphanumeric
+ * characters in the atom type field; if not, disqualify the file
+ * as a QT file */
+ qt_file->seek (qt_file, moov_atom_offset + ATOM_PREAMBLE_SIZE,
+ SEEK_SET);
+ if (qt_file->read (qt_file, atom_preamble, ATOM_PREAMBLE_SIZE) !=
+ ATOM_PREAMBLE_SIZE)
+ return 0;
- for (i = 4; i < 8; i++)
- if (!isalnum(atom_preamble[i]))
- return 0;
- return 1;
- }
+ for (i = 4; i < 8; i++)
+ if (!isalnum (atom_preamble[i]))
+ return 0;
+ return 1;
+ }
}
/* fetch interesting information from the movie header atom */
-static void parse_mvhd_atom(qt_info *info, unsigned char *mvhd_atom) {
+static void
+parse_mvhd_atom (qt_info * info, unsigned char *mvhd_atom)
+{
- info->creation_time = BE_32(&mvhd_atom[0x0C]);
- info->modification_time = BE_32(&mvhd_atom[0x10]);
- info->timescale = BE_32(&mvhd_atom[0x14]);
- info->duration = BE_32(&mvhd_atom[0x18]);
+ info->creation_time = BE_32 (&mvhd_atom[0x0C]);
+ info->modification_time = BE_32 (&mvhd_atom[0x10]);
+ info->timescale = BE_32 (&mvhd_atom[0x14]);
+ info->duration = BE_32 (&mvhd_atom[0x18]);
}
/* helper function from mplayer's parse_mp4.c */
-static int mp4_read_descr_len(unsigned char *s, uint32_t *length) {
+static int
+mp4_read_descr_len (unsigned char *s, uint32_t * length)
+{
uint8_t b;
uint8_t numBytes = 0;
*length = 0;
- do {
- b = *s++;
- numBytes++;
- *length = (*length << 7) | (b & 0x7F);
- } while ((b & 0x80) && numBytes < 4);
+ do
+ {
+ b = *s++;
+ numBytes++;
+ *length = (*length << 7) | (b & 0x7F);
+ }
+ while ((b & 0x80) && numBytes < 4);
return numBytes;
}
@@ -681,11 +750,12 @@
* This function traverses through a trak atom searching for the sample
* table atoms, which it loads into an internal trak structure.
*/
-static qt_error parse_trak_atom (qt_trak *trak,
- unsigned char *trak_atom) {
+static qt_error
+parse_trak_atom (qt_trak * trak, unsigned char *trak_atom)
+{
int i, j;
- unsigned int trak_atom_size = BE_32(&trak_atom[0]);
+ unsigned int trak_atom_size = BE_32 (&trak_atom[0]);
qt_atom current_atom;
unsigned int current_atom_size;
qt_error last_error = QT_OK;
@@ -724,600 +794,676 @@
trak->decoder_config_len = 0;
trak->stsd = NULL;
trak->stsd_size = 0;
- memset(&trak->properties, 0, sizeof(trak->properties));
+ memset (&trak->properties, 0, sizeof (trak->properties));
/* default type */
trak->type = MEDIA_OTHER;
/* search for media type atoms */
- for (i = ATOM_PREAMBLE_SIZE; i < trak_atom_size - 4; i++) {
- current_atom = BE_32(&trak_atom[i]);
+ for (i = ATOM_PREAMBLE_SIZE; i < trak_atom_size - 4; i++)
+ {
+ current_atom = BE_32 (&trak_atom[i]);
- if (current_atom == VMHD_ATOM) {
- trak->type = MEDIA_VIDEO;
- break;
- } else if (current_atom == SMHD_ATOM) {
- trak->type = MEDIA_AUDIO;
- break;
+ if (current_atom == VMHD_ATOM)
+ {
+ trak->type = MEDIA_VIDEO;
+ break;
+ }
+ else if (current_atom == SMHD_ATOM)
+ {
+ trak->type = MEDIA_AUDIO;
+ break;
+ }
}
- }
- debug_atom_load(" qt: parsing %s trak atom\n",
- (trak->type == MEDIA_VIDEO) ? "video" :
- (trak->type == MEDIA_AUDIO) ? "audio" : "other");
+ debug_atom_load (" qt: parsing %s trak atom\n",
+ (trak->type == MEDIA_VIDEO) ? "video" :
+ (trak->type == MEDIA_AUDIO) ? "audio" : "other");
/* search for the useful atoms */
- for (i = ATOM_PREAMBLE_SIZE; i < trak_atom_size - 4; i++) {
- current_atom_size = BE_32(&trak_atom[i - 4]);
- current_atom = BE_32(&trak_atom[i]);
+ for (i = ATOM_PREAMBLE_SIZE; i < trak_atom_size - 4; i++)
+ {
+ current_atom_size = BE_32 (&trak_atom[i - 4]);
+ current_atom = BE_32 (&trak_atom[i]);
- if (current_atom == TKHD_ATOM) {
- trak->flags = BE_16(&trak_atom[i + 6]);
+ if (current_atom == TKHD_ATOM)
+ {
+ trak->flags = BE_16 (&trak_atom[i + 6]);
- if (trak->type == MEDIA_VIDEO) {
- /* fetch display parameters */
- if( !trak->properties.video.width ||
- !trak->properties.video.height ) {
+ if (trak->type == MEDIA_VIDEO)
+ {
+ /* fetch display parameters */
+ if (!trak->properties.video.width ||
+ !trak->properties.video.height)
+ {
- trak->properties.video.width =
- BE_16(&trak_atom[i + 0x50]);
- trak->properties.video.height =
- BE_16(&trak_atom[i + 0x54]);
+ trak->properties.video.width = BE_16 (&trak_atom[i + 0x50]);
+ trak->properties.video.height =
+ BE_16 (&trak_atom[i + 0x54]);
+ }
+ }
}
- }
- } else if (current_atom == ELST_ATOM) {
+ else if (current_atom == ELST_ATOM)
+ {
- /* there should only be one edit list table */
- if (trak->edit_list_table) {
- last_error = QT_HEADER_TROUBLE;
- goto free_trak;
- }
+ /* there should only be one edit list table */
+ if (trak->edit_list_table)
+ {
+ last_error = QT_HEADER_TROUBLE;
+ goto free_trak;
+ }
- trak->edit_list_count = BE_32(&trak_atom[i + 8]);
+ trak->edit_list_count = BE_32 (&trak_atom[i + 8]);
- debug_atom_load(" qt elst atom (edit list atom): %d entries\n",
- trak->edit_list_count);
+ debug_atom_load (" qt elst atom (edit list atom): %d entries\n",
+ trak->edit_list_count);
- trak->edit_list_table = (edit_list_table_t *)malloc(
- trak->edit_list_count * sizeof(edit_list_table_t));
- if (!trak->edit_list_table) {
- last_error = QT_NO_MEMORY;
- goto free_trak;
- }
+ trak->edit_list_table =
+ (edit_list_table_t *) malloc (trak->edit_list_count *
+ sizeof (edit_list_table_t));
+ if (!trak->edit_list_table)
+ {
+ last_error = QT_NO_MEMORY;
+ goto free_trak;
+ }
- /* load the edit list table */
- for (j = 0; j < trak->edit_list_count; j++) {
- trak->edit_list_table[j].track_duration =
- BE_32(&trak_atom[i + 12 + j * 12 + 0]);
- trak->edit_list_table[j].media_time =
- BE_32(&trak_atom[i + 12 + j * 12 + 4]);
- debug_atom_load(" %d: track duration = %d, media time = %d\n",
- j,
- trak->edit_list_table[j].track_duration,
- trak->edit_list_table[j].media_time);
- }
+ /* load the edit list table */
+ for (j = 0; j < trak->edit_list_count; j++)
+ {
+ trak->edit_list_table[j].track_duration =
+ BE_32 (&trak_atom[i + 12 + j * 12 + 0]);
+ trak->edit_list_table[j].media_time =
+ BE_32 (&trak_atom[i + 12 + j * 12 + 4]);
+ debug_atom_load
+ (" %d: track duration = %d, media time = %d\n", j,
+ trak->edit_list_table[j].track_duration,
+ trak->edit_list_table[j].media_time);
+ }
- } else if (current_atom == MDHD_ATOM)
- trak->timescale = BE_32(&trak_atom[i + 0x10]);
- else if (current_atom == STSD_ATOM) {
+ }
+ else if (current_atom == MDHD_ATOM)
+ trak->timescale = BE_32 (&trak_atom[i + 0x10]);
+ else if (current_atom == STSD_ATOM)
+ {
- int hack_adjust;
+ int hack_adjust;
- debug_atom_load ("demux_qt: stsd atom\n");
+ debug_atom_load ("demux_qt: stsd atom\n");
#if DEBUG_ATOM_LOAD
- hexdump (&trak_atom[i], current_atom_size);
+ hexdump (&trak_atom[i], current_atom_size);
#endif
- /* copy whole stsd atom so it can later be sent to the decoder */
+ /* copy whole stsd atom so it can later be sent to the decoder */
- trak->stsd_size = current_atom_size;
- trak->stsd = realloc (trak->stsd, current_atom_size);
- memset (trak->stsd, 0, trak->stsd_size);
+ trak->stsd_size = current_atom_size;
+ trak->stsd = realloc (trak->stsd, current_atom_size);
+ memset (trak->stsd, 0, trak->stsd_size);
- /* awful, awful hack to support a certain type of stsd atom that
- * contains more than 1 video description atom */
- if (BE_32(&trak_atom[i + 8]) == 1) {
- /* normal case */
- memcpy (trak->stsd, &trak_atom[i], current_atom_size);
- hack_adjust = 0;
- } else {
- /* pathological case; take this route until a more definite
- * solution is found: jump over the first atom video
- * description atom */
+ /* awful, awful hack to support a certain type of stsd atom that
+ * contains more than 1 video description atom */
+ if (BE_32 (&trak_atom[i + 8]) == 1)
+ {
+ /* normal case */
+ memcpy (trak->stsd, &trak_atom[i], current_atom_size);
+ hack_adjust = 0;
+ }
+ else
+ {
+ /* pathological case; take this route until a more definite
+ * solution is found: jump over the first atom video
+ * description atom */
- /* copy the first 12 bytes since those remain the same */
- memcpy (trak->stsd, &trak_atom[i], 12);
+ /* copy the first 12 bytes since those remain the same */
+ memcpy (trak->stsd, &trak_atom[i], 12);
- /* skip to the second atom and copy it */
- hack_adjust = BE_32(&trak_atom[i + 0x0C]);
- memcpy(trak->stsd + 12, &trak_atom[i + 0x0C + hack_adjust],
- BE_32(&trak_atom[i + 0x0C + hack_adjust]));
+ /* skip to the second atom and copy it */
+ hack_adjust = BE_32 (&trak_atom[i + 0x0C]);
+ memcpy (trak->stsd + 12, &trak_atom[i + 0x0C + hack_adjust],
+ BE_32 (&trak_atom[i + 0x0C + hack_adjust]));
- /* use this variable to reference into the second atom, and
- * fix at the end of the stsd parser */
- i += hack_adjust;
- }
+ /* use this variable to reference into the second atom, and
+ * fix at the end of the stsd parser */
+ i += hack_adjust;
+ }
- if (trak->type == MEDIA_VIDEO) {
+ if (trak->type == MEDIA_VIDEO)
+ {
- /* initialize to sane values */
- trak->properties.video.width = 0;
- trak->properties.video.height = 0;
- trak->properties.video.depth = 0;
+ /* initialize to sane values */
+ trak->properties.video.width = 0;
+ trak->properties.video.height = 0;
+ trak->properties.video.depth = 0;
- /* assume no palette at first */
- trak->properties.video.palette_count = 0;
+ /* assume no palette at first */
+ trak->properties.video.palette_count = 0;
- /* fetch video parameters */
- if( BE_16(&trak_atom[i + 0x2C]) &&
- BE_16(&trak_atom[i + 0x2E]) ) {
- trak->properties.video.width =
- BE_16(&trak_atom[i + 0x2C]);
- trak->properties.video.height =
- BE_16(&trak_atom[i + 0x2E]);
- }
- trak->properties.video.codec_fourcc =
- ME_32(&trak_atom[i + 0x10]);
+ /* fetch video parameters */
+ if (BE_16 (&trak_atom[i + 0x2C]) &&
+ BE_16 (&trak_atom[i + 0x2E]))
+ {
+ trak->properties.video.width = BE_16 (&trak_atom[i + 0x2C]);
+ trak->properties.video.height =
+ BE_16 (&trak_atom[i + 0x2E]);
+ }
+ trak->properties.video.codec_fourcc =
+ ME_32 (&trak_atom[i + 0x10]);
- /* figure out the palette situation */
- color_depth = trak_atom[i + 0x5F];
- trak->properties.video.depth = color_depth;
- color_greyscale = color_depth & 0x20;
- color_depth &= 0x1F;
+ /* figure out the palette situation */
+ color_depth = trak_atom[i + 0x5F];
+ trak->properties.video.depth = color_depth;
+ color_greyscale = color_depth & 0x20;
+ color_depth &= 0x1F;
- /* if the depth is 2, 4, or 8 bpp, file is palettized */
- if ((color_depth == 2) || (color_depth == 4) || (color_depth == 8)) {
+ /* if the depth is 2, 4, or 8 bpp, file is palettized */
+ if ((color_depth == 2) || (color_depth == 4)
+ || (color_depth == 8))
+ {
- color_flag = BE_16(&trak_atom[i + 0x60]);
+ color_flag = BE_16 (&trak_atom[i + 0x60]);
- if (color_greyscale) {
+ if (color_greyscale)
+ {
- trak->properties.video.palette_count =
- 1 << color_depth;
+ trak->properties.video.palette_count = 1 << color_depth;
- /* compute the greyscale palette */
- color_index = 255;
- color_dec = 256 /
- (trak->properties.video.palette_count - 1);
- for (j = 0;
- j < trak->properties.video.palette_count;
- j++) {
+ /* compute the greyscale palette */
+ color_index = 255;
+ color_dec = 256 /
+ (trak->properties.video.palette_count - 1);
+ for (j = 0;
+ j < trak->properties.video.palette_count; j++)
+ {
- trak->properties.video.palette[j].r = color_index;
- trak->properties.video.palette[j].g = color_index;
- trak->properties.video.palette[j].b = color_index;
- color_index -= color_dec;
- if (color_index < 0)
- color_index = 0;
- }
+ trak->properties.video.palette[j].r = color_index;
+ trak->properties.video.palette[j].g = color_index;
+ trak->properties.video.palette[j].b = color_index;
+ color_index -= color_dec;
+ if (color_index < 0)
+ color_index = 0;
+ }
- } else if (color_flag & 0x08) {
+ }
+ else if (color_flag & 0x08)
+ {
- /* if flag bit 3 is set, load the default palette */
- trak->properties.video.palette_count =
- 1 << color_depth;
+ /* if flag bit 3 is set, load the default palette */
+ trak->properties.video.palette_count = 1 << color_depth;
- if (color_depth == 2)
- color_table = qt_default_palette_4;
- else if (color_depth == 4)
- color_table = qt_default_palette_16;
- else
- color_table = qt_default_palette_256;
+ if (color_depth == 2)
+ color_table = qt_default_palette_4;
+ else if (color_depth == 4)
+ color_table = qt_default_palette_16;
+ else
+ color_table = qt_default_palette_256;
- for (j = 0;
- j < trak->properties.video.palette_count;
- j++) {
+ for (j = 0;
+ j < trak->properties.video.palette_count; j++)
+ {
- trak->properties.video.palette[j].r =
- color_table[j * 4 + 0];
- trak->properties.video.palette[j].g =
- color_table[j * 4 + 1];
- trak->properties.video.palette[j].b =
- color_table[j * 4 + 2];
+ trak->properties.video.palette[j].r =
+ color_table[j * 4 + 0];
+ trak->properties.video.palette[j].g =
+ color_table[j * 4 + 1];
+ trak->properties.video.palette[j].b =
+ color_table[j * 4 + 2];
- }
+ }
- } else {
+ }
+ else
+ {
- /* load the palette from the file */
- color_start = BE_32(&trak_atom[i + 0x62]);
- color_count = BE_16(&trak_atom[i + 0x66]);
- color_end = BE_16(&trak_atom[i + 0x68]);
- trak->properties.video.palette_count =
- color_end + 1;
+ /* load the palette from the file */
+ color_start = BE_32 (&trak_atom[i + 0x62]);
+ color_count = BE_16 (&trak_atom[i + 0x66]);
+ color_end = BE_16 (&trak_atom[i + 0x68]);
+ trak->properties.video.palette_count = color_end + 1;
- for (j = color_start; j <= color_end; j++) {
+ for (j = color_start; j <= color_end; j++)
+ {
- color_index = BE_16(&trak_atom[i + 0x6A + j * 8]);
- if (color_count & 0x8000)
- color_index = j;
- if (color_index <
- trak->properties.video.palette_count) {
- trak->properties.video.palette[color_index].r =
- trak_atom[i + 0x6A + j * 8 + 2];
- trak->properties.video.palette[color_index].g =
- trak_atom[i + 0x6A + j * 8 + 4];
- trak->properties.video.palette[color_index].b =
- trak_atom[i + 0x6A + j * 8 + 6];
- }
+ color_index = BE_16 (&trak_atom[i + 0x6A + j * 8]);
+ if (color_count & 0x8000)
+ color_index = j;
+ if (color_index <
+ trak->properties.video.palette_count)
+ {
+ trak->properties.video.palette[color_index].r =
+ trak_atom[i + 0x6A + j * 8 + 2];
+ trak->properties.video.palette[color_index].g =
+ trak_atom[i + 0x6A + j * 8 + 4];
+ trak->properties.video.palette[color_index].b =
+ trak_atom[i + 0x6A + j * 8 + 6];
+ }
+ }
+ }
+ }
+ else
+ trak->properties.video.palette_count = 0;
+
+ debug_atom_load (" video description\n");
+ debug_atom_load
+ (" %dx%d, video fourcc = '%c%c%c%c' (%02X%02X%02X%02X)\n",
+ trak->properties.video.width, trak->properties.video.height,
+ trak_atom[i + 0x10], trak_atom[i + 0x11],
+ trak_atom[i + 0x12], trak_atom[i + 0x13],
+ trak_atom[i + 0x10], trak_atom[i + 0x11],
+ trak_atom[i + 0x12], trak_atom[i + 0x13]);
+ debug_atom_load (" %d RGB colors\n",
+ trak->properties.video.palette_count);
+ for (j = 0; j < trak->properties.video.palette_count; j++)
+ debug_atom_load (" %d: %3d %3d %3d\n",
+ j,
+ trak->properties.video.palette[j].r,
+ trak->properties.video.palette[j].g,
+ trak->properties.video.palette[j].b);
+
}
- }
- } else
- trak->properties.video.palette_count = 0;
+ else if (trak->type == MEDIA_AUDIO)
+ {
- debug_atom_load(" video description\n");
- debug_atom_load(" %dx%d, video fourcc = '%c%c%c%c'
(%02X%02X%02X%02X)\n",
- trak->properties.video.width,
- trak->properties.video.height,
- trak_atom[i + 0x10],
- trak_atom[i + 0x11],
- trak_atom[i + 0x12],
- trak_atom[i + 0x13],
- trak_atom[i + 0x10],
- trak_atom[i + 0x11],
- trak_atom[i + 0x12],
- trak_atom[i + 0x13]);
- debug_atom_load(" %d RGB colors\n",
- trak->properties.video.palette_count);
- for (j = 0; j < trak->properties.video.palette_count;
- j++)
- debug_atom_load(" %d: %3d %3d %3d\n",
- j,
- trak->properties.video.palette[j].r,
- trak->properties.video.palette[j].g,
- trak->properties.video.palette[j].b);
+ /* fetch audio parameters */
+ trak->properties.audio.codec_fourcc =
+ ME_32 (&trak_atom[i + 0x10]);
+ trak->properties.audio.sample_rate =
+ BE_16 (&trak_atom[i + 0x2C]);
+ trak->properties.audio.channels = trak_atom[i + 0x25];
+ trak->properties.audio.bits = trak_atom[i + 0x27];
- } else if (trak->type == MEDIA_AUDIO) {
+ /* assume uncompressed audio parameters */
+ trak->properties.audio.bytes_per_sample =
+ trak->properties.audio.bits / 8;
+ trak->properties.audio.samples_per_frame =
+ trak->properties.audio.channels;
+ trak->properties.audio.bytes_per_frame =
+ trak->properties.audio.bytes_per_sample *
+ trak->properties.audio.samples_per_frame;
+ trak->properties.audio.samples_per_packet =
+ trak->properties.audio.samples_per_frame;
+ trak->properties.audio.bytes_per_packet =
+ trak->properties.audio.bytes_per_sample;
- /* fetch audio parameters */
- trak->properties.audio.codec_fourcc =
- ME_32(&trak_atom[i + 0x10]);
- trak->properties.audio.sample_rate =
- BE_16(&trak_atom[i + 0x2C]);
- trak->properties.audio.channels = trak_atom[i + 0x25];
- trak->properties.audio.bits = trak_atom[i + 0x27];
+ /* special case time: some ima4-encoded files don't have the
+ * extra header; compensate */
+ if (BE_32 (&trak_atom[i + 0x10]) == IMA4_FOURCC)
+ {
+ trak->properties.audio.samples_per_packet = 64;
+ trak->properties.audio.bytes_per_packet = 34;
+ trak->properties.audio.bytes_per_frame = 34 *
+ trak->properties.audio.channels;
+ trak->properties.audio.bytes_per_sample = 2;
+ trak->properties.audio.samples_per_frame = 64 *
+ trak->properties.audio.channels;
+ }
- /* assume uncompressed audio parameters */
- trak->properties.audio.bytes_per_sample =
- trak->properties.audio.bits / 8;
- trak->properties.audio.samples_per_frame =
- trak->properties.audio.channels;
- trak->properties.audio.bytes_per_frame =
- trak->properties.audio.bytes_per_sample *
- trak->properties.audio.samples_per_frame;
- trak->properties.audio.samples_per_packet =
- trak->properties.audio.samples_per_frame;
- trak->properties.audio.bytes_per_packet =
- trak->properties.audio.bytes_per_sample;
+ /* it's time to dig a little deeper to determine the real audio
+ * properties; if a the stsd compressor atom has 0x24 bytes, it
+ * appears to be a handler for uncompressed data; if there are an
+ * extra 0x10 bytes, there are some more useful decoding params
*/
+ if (BE_32 (&trak_atom[i + 0x0C]) > 0x24)
+ {
- /* special case time: some ima4-encoded files don't have the
- * extra header; compensate */
- if (BE_32(&trak_atom[i + 0x10]) == IMA4_FOURCC) {
- trak->properties.audio.samples_per_packet = 64;
- trak->properties.audio.bytes_per_packet = 34;
- trak->properties.audio.bytes_per_frame = 34 *
- trak->properties.audio.channels;
- trak->properties.audio.bytes_per_sample = 2;
- trak->properties.audio.samples_per_frame = 64 *
- trak->properties.audio.channels;
- }
+ if (BE_32 (&trak_atom[i + 0x30]))
+ trak->properties.audio.samples_per_packet =
+ BE_32 (&trak_atom[i + 0x30]);
+ if (BE_32 (&trak_atom[i + 0x34]))
+ trak->properties.audio.bytes_per_packet =
+ BE_32 (&trak_atom[i + 0x34]);
+ if (BE_32 (&trak_atom[i + 0x38]))
+ trak->properties.audio.bytes_per_frame =
+ BE_32 (&trak_atom[i + 0x38]);
+ if (BE_32 (&trak_atom[i + 0x3C]))
+ trak->properties.audio.bytes_per_sample =
+ BE_32 (&trak_atom[i + 0x3C]);
+ trak->properties.audio.samples_per_frame =
+ (trak->properties.audio.bytes_per_frame /
+ trak->properties.audio.bytes_per_packet) *
+ trak->properties.audio.samples_per_packet;
- /* it's time to dig a little deeper to determine the real audio
- * properties; if a the stsd compressor atom has 0x24 bytes, it
- * appears to be a handler for uncompressed data; if there are an
- * extra 0x10 bytes, there are some more useful decoding params */
- if (BE_32(&trak_atom[i + 0x0C]) > 0x24) {
+ }
- if (BE_32(&trak_atom[i + 0x30]))
- trak->properties.audio.samples_per_packet =
- BE_32(&trak_atom[i + 0x30]);
- if (BE_32(&trak_atom[i + 0x34]))
- trak->properties.audio.bytes_per_packet =
- BE_32(&trak_atom[i + 0x34]);
- if (BE_32(&trak_atom[i + 0x38]))
- trak->properties.audio.bytes_per_frame =
- BE_32(&trak_atom[i + 0x38]);
- if (BE_32(&trak_atom[i + 0x3C]))
- trak->properties.audio.bytes_per_sample =
- BE_32(&trak_atom[i + 0x3C]);
- trak->properties.audio.samples_per_frame =
- (trak->properties.audio.bytes_per_frame /
- trak->properties.audio.bytes_per_packet) *
- trak->properties.audio.samples_per_packet;
+ /* see if the trak deserves a promotion to VBR */
+ if (BE_16 (&trak_atom[i + 0x28]) == 0xFFFE)
+ trak->properties.audio.vbr = 1;
+ else
+ trak->properties.audio.vbr = 0;
- }
+ /* if this is MP4 audio, mark the trak as VBR */
+ if (BE_32 (&trak_atom[i + 0x10]) == MP4A_FOURCC)
+ trak->properties.audio.vbr = 1;
- /* see if the trak deserves a promotion to VBR */
- if (BE_16(&trak_atom[i + 0x28]) == 0xFFFE)
- trak->properties.audio.vbr = 1;
- else
- trak->properties.audio.vbr = 0;
+ /* check for a MS-style WAVE format header */
+ if ((current_atom_size >= 0x48) &&
+ (BE_32 (&trak_atom[i + 0x44]) == WAVE_ATOM))
+ {
+ trak->properties.audio.wave_present = 1;
+ memcpy (&trak->properties.audio.wave,
+ &trak_atom[i + 0x5C],
+ sizeof (trak->properties.audio.wave));
+ xine_waveformatex_le2me (&trak->properties.audio.wave);
+ }
+ else
+ {
+ trak->properties.audio.wave_present = 0;
+ }
- /* if this is MP4 audio, mark the trak as VBR */
- if (BE_32(&trak_atom[i + 0x10]) == MP4A_FOURCC)
- trak->properties.audio.vbr = 1;
+ debug_atom_load (" audio description\n");
+ debug_atom_load
+ (" %d Hz, %d bits, %d channels, %saudio fourcc =
'%c%c%c%c' (%02X%02X%02X%02X)\n",
+ trak->properties.audio.sample_rate,
+ trak->properties.audio.bits, trak->properties.audio.channels,
+ (trak->properties.audio.vbr) ? "vbr, " : "",
+ trak_atom[i + 0x10], trak_atom[i + 0x11],
+ trak_atom[i + 0x12], trak_atom[i + 0x13],
+ trak_atom[i + 0x10], trak_atom[i + 0x11],
+ trak_atom[i + 0x12], trak_atom[i + 0x13]);
+ if (BE_32 (&trak_atom[i + 0x0C]) > 0x24)
+ {
+ debug_atom_load
+ (" %d samples/packet, %d bytes/packet, %d
bytes/frame\n",
+ trak->properties.audio.samples_per_packet,
+ trak->properties.audio.bytes_per_packet,
+ trak->properties.audio.bytes_per_frame);
+ debug_atom_load
+ (" %d bytes/sample (%d samples/frame)\n",
+ trak->properties.audio.bytes_per_sample,
+ trak->properties.audio.samples_per_frame);
+ }
+ }
- /* check for a MS-style WAVE format header */
- if ((current_atom_size >= 0x48) &&
- (BE_32(&trak_atom[i + 0x44]) == WAVE_ATOM)) {
- trak->properties.audio.wave_present = 1;
- memcpy(&trak->properties.audio.wave,
- &trak_atom[i + 0x5C],
- sizeof(trak->properties.audio.wave));
- xine_waveformatex_le2me(&trak->properties.audio.wave);
- } else {
- trak->properties.audio.wave_present = 0;
- }
+ i -= hack_adjust;
- debug_atom_load(" audio description\n");
- debug_atom_load(" %d Hz, %d bits, %d channels, %saudio fourcc =
'%c%c%c%c' (%02X%02X%02X%02X)\n",
- trak->properties.audio.sample_rate,
- trak->properties.audio.bits,
- trak->properties.audio.channels,
- (trak->properties.audio.vbr) ? "vbr, " : "",
- trak_atom[i + 0x10],
- trak_atom[i + 0x11],
- trak_atom[i + 0x12],
- trak_atom[i + 0x13],
- trak_atom[i + 0x10],
- trak_atom[i + 0x11],
- trak_atom[i + 0x12],
- trak_atom[i + 0x13]);
- if (BE_32(&trak_atom[i + 0x0C]) > 0x24) {
- debug_atom_load(" %d samples/packet, %d bytes/packet, %d
bytes/frame\n",
- trak->properties.audio.samples_per_packet,
- trak->properties.audio.bytes_per_packet,
- trak->properties.audio.bytes_per_frame);
- debug_atom_load(" %d bytes/sample (%d samples/frame)\n",
- trak->properties.audio.bytes_per_sample,
- trak->properties.audio.samples_per_frame);
}
- }
+ else if (current_atom == ESDS_ATOM)
+ {
- i -= hack_adjust;
+ uint32_t len;
- } else if (current_atom == ESDS_ATOM) {
+ debug_atom_load (" qt/mpeg-4 esds atom\n");
- uint32_t len;
+ if ((trak->type == MEDIA_VIDEO) || (trak->type == MEDIA_AUDIO))
+ {
- debug_atom_load(" qt/mpeg-4 esds atom\n");
+ j = i + 8;
+ if (trak_atom[j++] == 0x03)
+ {
+ j += mp4_read_descr_len (&trak_atom[j], &len);
+ j++;
+ }
+ j += 2;
+ if (trak_atom[j++] == 0x04)
+ {
+ j += mp4_read_descr_len (&trak_atom[j], &len);
+ j += 13;
+ if (trak_atom[j++] == 0x05)
+ {
+ j += mp4_read_descr_len (&trak_atom[j], &len);
+ debug_atom_load
+ (" decoder config is %d (0x%X) bytes long\n",
+ len, len);
+ trak->decoder_config =
+ realloc (trak->decoder_config, len);
+ trak->decoder_config_len = len;
+ memcpy (trak->decoder_config, &trak_atom[j], len);
+ }
+ }
+ }
- if ((trak->type == MEDIA_VIDEO) ||
- (trak->type == MEDIA_AUDIO)) {
-
- j = i + 8;
- if( trak_atom[j++] == 0x03 ) {
- j += mp4_read_descr_len( &trak_atom[j], &len );
- j++;
}
- j += 2;
- if( trak_atom[j++] == 0x04 ) {
- j += mp4_read_descr_len( &trak_atom[j], &len );
- j += 13;
- if( trak_atom[j++] == 0x05 ) {
- j += mp4_read_descr_len( &trak_atom[j], &len );
- debug_atom_load(" decoder config is %d (0x%X) bytes long\n",
- len, len);
- trak->decoder_config = realloc(trak->decoder_config, len);
- trak->decoder_config_len = len;
- memcpy(trak->decoder_config,&trak_atom[j],len);
- }
- }
- }
+ else if (current_atom == STSZ_ATOM)
+ {
- } else if (current_atom == STSZ_ATOM) {
+ /* there should only be one of these atoms */
+ if (trak->sample_size_table)
+ {
+ last_error = QT_HEADER_TROUBLE;
+ goto free_trak;
+ }
- /* there should only be one of these atoms */
- if (trak->sample_size_table) {
- last_error = QT_HEADER_TROUBLE;
- goto free_trak;
- }
+ trak->sample_size = BE_32 (&trak_atom[i + 8]);
+ trak->sample_size_count = BE_32 (&trak_atom[i + 12]);
- trak->sample_size = BE_32(&trak_atom[i + 8]);
- trak->sample_size_count = BE_32(&trak_atom[i + 12]);
+ debug_atom_load
+ (" qt stsz atom (sample size atom): sample size = %d, %d
entries\n",
+ trak->sample_size, trak->sample_size_count);
- debug_atom_load(" qt stsz atom (sample size atom): sample size = %d,
%d entries\n",
- trak->sample_size, trak->sample_size_count);
+ /* allocate space and load table only if sample size is 0 */
+ if (trak->sample_size == 0)
+ {
+ trak->sample_size_table =
+ (unsigned int *) malloc (trak->sample_size_count *
+ sizeof (unsigned int));
+ if (!trak->sample_size_table)
+ {
+ last_error = QT_NO_MEMORY;
+ goto free_trak;
+ }
+ /* load the sample size table */
+ for (j = 0; j < trak->sample_size_count; j++)
+ {
+ trak->sample_size_table[j] =
+ BE_32 (&trak_atom[i + 16 + j * 4]);
+ debug_atom_load (" sample size %d: %d\n",
+ j, trak->sample_size_table[j]);
+ }
+ }
+ else
+ /* set the pointer to non-NULL to indicate that the atom type has
+ * already been seen for this trak atom */
+ trak->sample_size_table = (void *) -1;
- /* allocate space and load table only if sample size is 0 */
- if (trak->sample_size == 0) {
- trak->sample_size_table = (unsigned int *)malloc(
- trak->sample_size_count * sizeof(unsigned int));
- if (!trak->sample_size_table) {
- last_error = QT_NO_MEMORY;
- goto free_trak;
}
- /* load the sample size table */
- for (j = 0; j < trak->sample_size_count; j++) {
- trak->sample_size_table[j] =
- BE_32(&trak_atom[i + 16 + j * 4]);
- debug_atom_load(" sample size %d: %d\n",
- j, trak->sample_size_table[j]);
- }
- } else
- /* set the pointer to non-NULL to indicate that the atom type has
- * already been seen for this trak atom */
- trak->sample_size_table = (void *)-1;
+ else if (current_atom == STSS_ATOM)
+ {
- } else if (current_atom == STSS_ATOM) {
+ /* there should only be one of these atoms */
+ if (trak->sync_sample_table)
+ {
+ last_error = QT_HEADER_TROUBLE;
+ goto free_trak;
+ }
- /* there should only be one of these atoms */
- if (trak->sync_sample_table) {
- last_error = QT_HEADER_TROUBLE;
- goto free_trak;
- }
+ trak->sync_sample_count = BE_32 (&trak_atom[i + 8]);
- trak->sync_sample_count = BE_32(&trak_atom[i + 8]);
+ debug_atom_load
+ (" qt stss atom (sample sync atom): %d sync samples\n",
+ trak->sync_sample_count);
- debug_atom_load(" qt stss atom (sample sync atom): %d sync samples\n",
- trak->sync_sample_count);
+ trak->sync_sample_table =
+ (unsigned int *) malloc (trak->sync_sample_count *
+ sizeof (unsigned int));
+ if (!trak->sync_sample_table)
+ {
+ last_error = QT_NO_MEMORY;
+ goto free_trak;
+ }
- trak->sync_sample_table = (unsigned int *)malloc(
- trak->sync_sample_count * sizeof(unsigned int));
- if (!trak->sync_sample_table) {
- last_error = QT_NO_MEMORY;
- goto free_trak;
- }
+ /* load the sync sample table */
+ for (j = 0; j < trak->sync_sample_count; j++)
+ {
+ trak->sync_sample_table[j] = BE_32 (&trak_atom[i + 12 + j * 4]);
+ debug_atom_load
+ (" sync sample %d: sample %d (%d) is a keyframe\n", j,
+ trak->sync_sample_table[j], trak->sync_sample_table[j] - 1);
+ }
- /* load the sync sample table */
- for (j = 0; j < trak->sync_sample_count; j++) {
- trak->sync_sample_table[j] =
- BE_32(&trak_atom[i + 12 + j * 4]);
- debug_atom_load(" sync sample %d: sample %d (%d) is a keyframe\n",
- j, trak->sync_sample_table[j],
- trak->sync_sample_table[j] - 1);
- }
+ }
+ else if (current_atom == STCO_ATOM)
+ {
- } else if (current_atom == STCO_ATOM) {
+ /* there should only be one of either stco or co64 */
+ if (trak->chunk_offset_table)
+ {
+ last_error = QT_HEADER_TROUBLE;
+ goto free_trak;
+ }
- /* there should only be one of either stco or co64 */
- if (trak->chunk_offset_table) {
- last_error = QT_HEADER_TROUBLE;
- goto free_trak;
- }
+ trak->chunk_offset_count = BE_32 (&trak_atom[i + 8]);
- trak->chunk_offset_count = BE_32(&trak_atom[i + 8]);
+ debug_atom_load
+ (" qt stco atom (32-bit chunk offset atom): %d chunk offsets\n",
+ trak->chunk_offset_count);
- debug_atom_load(" qt stco atom (32-bit chunk offset atom): %d chunk
offsets\n",
- trak->chunk_offset_count);
+ trak->chunk_offset_table =
+ (int64_t *) malloc (trak->chunk_offset_count * sizeof (int64_t));
+ if (!trak->chunk_offset_table)
+ {
+ last_error = QT_NO_MEMORY;
+ goto free_trak;
+ }
- trak->chunk_offset_table = (int64_t *)malloc(
- trak->chunk_offset_count * sizeof(int64_t));
- if (!trak->chunk_offset_table) {
- last_error = QT_NO_MEMORY;
- goto free_trak;
- }
+ /* load the chunk offset table */
+ for (j = 0; j < trak->chunk_offset_count; j++)
+ {
+ trak->chunk_offset_table[j] =
+ BE_32 (&trak_atom[i + 12 + j * 4]);
+ debug_atom_load (" chunk %d @ 0x%llX\n",
+ j, trak->chunk_offset_table[j]);
+ }
- /* load the chunk offset table */
- for (j = 0; j < trak->chunk_offset_count; j++) {
- trak->chunk_offset_table[j] =
- BE_32(&trak_atom[i + 12 + j * 4]);
- debug_atom_load(" chunk %d @ 0x%llX\n",
- j, trak->chunk_offset_table[j]);
- }
+ }
+ else if (current_atom == CO64_ATOM)
+ {
- } else if (current_atom == CO64_ATOM) {
+ /* there should only be one of either stco or co64 */
+ if (trak->chunk_offset_table)
+ {
+ last_error = QT_HEADER_TROUBLE;
+ goto free_trak;
+ }
- /* there should only be one of either stco or co64 */
- if (trak->chunk_offset_table) {
- last_error = QT_HEADER_TROUBLE;
- goto free_trak;
- }
+ trak->chunk_offset_count = BE_32 (&trak_atom[i + 8]);
- trak->chunk_offset_count = BE_32(&trak_atom[i + 8]);
+ debug_atom_load
+ (" qt co64 atom (64-bit chunk offset atom): %d chunk offsets\n",
+ trak->chunk_offset_count);
- debug_atom_load(" qt co64 atom (64-bit chunk offset atom): %d chunk
offsets\n",
- trak->chunk_offset_count);
+ trak->chunk_offset_table =
+ (int64_t *) malloc (trak->chunk_offset_count * sizeof (int64_t));
+ if (!trak->chunk_offset_table)
+ {
+ last_error = QT_NO_MEMORY;
+ goto free_trak;
+ }
- trak->chunk_offset_table = (int64_t *)malloc(
- trak->chunk_offset_count * sizeof(int64_t));
- if (!trak->chunk_offset_table) {
- last_error = QT_NO_MEMORY;
- goto free_trak;
- }
+ /* load the 64-bit chunk offset table */
+ for (j = 0; j < trak->chunk_offset_count; j++)
+ {
+ trak->chunk_offset_table[j] =
+ BE_32 (&trak_atom[i + 12 + j * 8 + 0]);
+ trak->chunk_offset_table[j] <<= 32;
+ trak->chunk_offset_table[j] |=
+ BE_32 (&trak_atom[i + 12 + j * 8 + 4]);
+ debug_atom_load (" chunk %d @ 0x%llX\n",
+ j, trak->chunk_offset_table[j]);
+ }
- /* load the 64-bit chunk offset table */
- for (j = 0; j < trak->chunk_offset_count; j++) {
- trak->chunk_offset_table[j] =
- BE_32(&trak_atom[i + 12 + j * 8 + 0]);
- trak->chunk_offset_table[j] <<= 32;
- trak->chunk_offset_table[j] |=
- BE_32(&trak_atom[i + 12 + j * 8 + 4]);
- debug_atom_load(" chunk %d @ 0x%llX\n",
- j, trak->chunk_offset_table[j]);
- }
+ }
+ else if (current_atom == STSC_ATOM)
+ {
- } else if (current_atom == STSC_ATOM) {
+ /* there should only be one of these atoms */
+ if (trak->sample_to_chunk_table)
+ {
+ last_error = QT_HEADER_TROUBLE;
+ goto free_trak;
+ }
- /* there should only be one of these atoms */
- if (trak->sample_to_chunk_table) {
- last_error = QT_HEADER_TROUBLE;
- goto free_trak;
- }
+ trak->sample_to_chunk_count = BE_32 (&trak_atom[i + 8]);
- trak->sample_to_chunk_count = BE_32(&trak_atom[i + 8]);
+ debug_atom_load
+ (" qt stsc atom (sample-to-chunk atom): %d entries\n",
+ trak->sample_to_chunk_count);
- debug_atom_load(" qt stsc atom (sample-to-chunk atom): %d entries\n",
- trak->sample_to_chunk_count);
+ trak->sample_to_chunk_table =
+ (sample_to_chunk_table_t *) malloc (trak->sample_to_chunk_count *
+ sizeof
+ (sample_to_chunk_table_t));
+ if (!trak->sample_to_chunk_table)
+ {
+ last_error = QT_NO_MEMORY;
+ goto free_trak;
+ }
- trak->sample_to_chunk_table = (sample_to_chunk_table_t *)malloc(
- trak->sample_to_chunk_count * sizeof(sample_to_chunk_table_t));
- if (!trak->sample_to_chunk_table) {
- last_error = QT_NO_MEMORY;
- goto free_trak;
- }
+ /* load the sample to chunk table */
+ for (j = 0; j < trak->sample_to_chunk_count; j++)
+ {
+ trak->sample_to_chunk_table[j].first_chunk =
+ BE_32 (&trak_atom[i + 12 + j * 12 + 0]);
+ trak->sample_to_chunk_table[j].samples_per_chunk =
+ BE_32 (&trak_atom[i + 12 + j * 12 + 4]);
+ debug_atom_load
+ (" %d: %d samples/chunk starting at chunk %d (%d)\n", j,
+ trak->sample_to_chunk_table[j].samples_per_chunk,
+ trak->sample_to_chunk_table[j].first_chunk,
+ trak->sample_to_chunk_table[j].first_chunk - 1);
+ }
- /* load the sample to chunk table */
- for (j = 0; j < trak->sample_to_chunk_count; j++) {
- trak->sample_to_chunk_table[j].first_chunk =
- BE_32(&trak_atom[i + 12 + j * 12 + 0]);
- trak->sample_to_chunk_table[j].samples_per_chunk =
- BE_32(&trak_atom[i + 12 + j * 12 + 4]);
- debug_atom_load(" %d: %d samples/chunk starting at chunk %d
(%d)\n",
- j, trak->sample_to_chunk_table[j].samples_per_chunk,
- trak->sample_to_chunk_table[j].first_chunk,
- trak->sample_to_chunk_table[j].first_chunk - 1);
- }
+ }
+ else if (current_atom == STTS_ATOM)
+ {
- } else if (current_atom == STTS_ATOM) {
+ /* there should only be one of these atoms */
+ if (trak->time_to_sample_table)
+ {
+ last_error = QT_HEADER_TROUBLE;
+ goto free_trak;
+ }
- /* there should only be one of these atoms */
- if (trak->time_to_sample_table) {
- last_error = QT_HEADER_TROUBLE;
- goto free_trak;
- }
+ trak->time_to_sample_count = BE_32 (&trak_atom[i + 8]);
- trak->time_to_sample_count = BE_32(&trak_atom[i + 8]);
+ debug_atom_load
+ (" qt stts atom (time-to-sample atom): %d entries\n",
+ trak->time_to_sample_count);
- debug_atom_load(" qt stts atom (time-to-sample atom): %d entries\n",
- trak->time_to_sample_count);
+ trak->time_to_sample_table = (time_to_sample_table_t *) malloc
((trak->time_to_sample_count + 1) * sizeof (time_to_sample_table_t));
+ if (!trak->time_to_sample_table)
+ {
+ last_error = QT_NO_MEMORY;
+ goto free_trak;
+ }
- trak->time_to_sample_table = (time_to_sample_table_t *)malloc(
- (trak->time_to_sample_count+1) * sizeof(time_to_sample_table_t));
- if (!trak->time_to_sample_table) {
- last_error = QT_NO_MEMORY;
- goto free_trak;
- }
-
- /* load the time to sample table */
- for (j = 0; j < trak->time_to_sample_count; j++) {
- trak->time_to_sample_table[j].count =
- BE_32(&trak_atom[i + 12 + j * 8 + 0]);
- trak->time_to_sample_table[j].duration =
- BE_32(&trak_atom[i + 12 + j * 8 + 4]);
- debug_atom_load(" %d: count = %d, duration = %d\n",
- j, trak->time_to_sample_table[j].count,
- trak->time_to_sample_table[j].duration);
- }
- trak->time_to_sample_table[j].count = 0; /* terminate with zero */
+ /* load the time to sample table */
+ for (j = 0; j < trak->time_to_sample_count; j++)
+ {
+ trak->time_to_sample_table[j].count =
+ BE_32 (&trak_atom[i + 12 + j * 8 + 0]);
+ trak->time_to_sample_table[j].duration =
+ BE_32 (&trak_atom[i + 12 + j * 8 + 4]);
+ debug_atom_load (" %d: count = %d, duration = %d\n",
+ j, trak->time_to_sample_table[j].count,
+ trak->time_to_sample_table[j].duration);
+ }
+ trak->time_to_sample_table[j].count = 0; /* terminate with zero
*/
+ }
}
- }
return QT_OK;
/* jump here to make sure everything is free'd and avoid leaking memory */
free_trak:
- free(trak->edit_list_table);
- free(trak->chunk_offset_table);
+ free (trak->edit_list_table);
+ free (trak->chunk_offset_table);
/* this pointer might have been set to -1 as a special case */
- if (trak->sample_size_table != (void *)-1)
- free(trak->sample_size_table);
- free(trak->sync_sample_table);
- free(trak->sample_to_chunk_table);
- free(trak->time_to_sample_table);
- free(trak->decoder_config);
- free(trak->stsd);
+ if (trak->sample_size_table != (void *) -1)
+ free (trak->sample_size_table);
+ free (trak->sync_sample_table);
+ free (trak->sample_to_chunk_table);
+ free (trak->time_to_sample_table);
+ free (trak->decoder_config);
+ free (trak->stsd);
return last_error;
}
/* Traverse through a reference atom and extract the URL and data rate. */
-static qt_error parse_reference_atom (reference_t *ref,
- unsigned char *ref_atom,
- char *base_mrl) {
+static qt_error
+parse_reference_atom (reference_t * ref,
+ unsigned char *ref_atom, char *base_mrl)
+{
int i, j;
- unsigned int ref_atom_size = BE_32(&ref_atom[0]);
+ unsigned int ref_atom_size = BE_32 (&ref_atom[0]);
qt_atom current_atom;
unsigned int current_atom_size;
@@ -1327,58 +1473,74 @@
ref->qtim_version = 0;
/* traverse through the atom looking for the key atoms */
- for (i = ATOM_PREAMBLE_SIZE; i < ref_atom_size - 4; i++) {
+ for (i = ATOM_PREAMBLE_SIZE; i < ref_atom_size - 4; i++)
+ {
- current_atom_size = BE_32(&ref_atom[i - 4]);
- current_atom = BE_32(&ref_atom[i]);
+ current_atom_size = BE_32 (&ref_atom[i - 4]);
+ current_atom = BE_32 (&ref_atom[i]);
- if (current_atom == RDRF_ATOM) {
+ if (current_atom == RDRF_ATOM)
+ {
- /* if the URL starts with "http://", copy it */
- if (strncmp(&ref_atom[i + 12], "http://", 7) == 0) {
+ /* if the URL starts with "http://", copy it */
+ if (strncmp (&ref_atom[i + 12], "http://", 7) == 0)
+ {
- /* URL is spec'd to terminate with a NULL; don't trust it */
- ref->url = xine_xmalloc(BE_32(&ref_atom[i + 12]) + 1);
- strncpy(ref->url, &ref_atom[i + 16], BE_32(&ref_atom[i + 12]));
- ref->url[BE_32(&ref_atom[i + 12]) - 1] = '\0';
+ /* URL is spec'd to terminate with a NULL; don't trust it */
+ ref->url = xine_xmalloc (BE_32 (&ref_atom[i + 12]) + 1);
+ strncpy (ref->url, &ref_atom[i + 16],
+ BE_32 (&ref_atom[i + 12]));
+ ref->url[BE_32 (&ref_atom[i + 12]) - 1] = '\0';
- } else {
+ }
+ else
+ {
- int string_size = strlen(base_mrl) + BE_32(&ref_atom[i + 12]) + 1;
+ int string_size =
+ strlen (base_mrl) + BE_32 (&ref_atom[i + 12]) + 1;
- /* otherwise, append relative URL to base MRL */
- ref->url = xine_xmalloc(string_size);
- strcpy(ref->url, base_mrl);
- strncat(ref->url, &ref_atom[i + 16], BE_32(&ref_atom[i + 12]));
- ref->url[string_size - 1] = '\0';
- }
+ /* otherwise, append relative URL to base MRL */
+ ref->url = xine_xmalloc (string_size);
+ strcpy (ref->url, base_mrl);
+ strncat (ref->url, &ref_atom[i + 16],
+ BE_32 (&ref_atom[i + 12]));
+ ref->url[string_size - 1] = '\0';
+ }
- debug_atom_load(" qt rdrf URL reference:\n %s\n", ref->url);
+ debug_atom_load (" qt rdrf URL reference:\n %s\n",
+ ref->url);
- } else if (current_atom == RMDR_ATOM) {
+ }
+ else if (current_atom == RMDR_ATOM)
+ {
- /* load the data rate */
- ref->data_rate = BE_32(&ref_atom[i + 8]);
- ref->data_rate *= 10;
+ /* load the data rate */
+ ref->data_rate = BE_32 (&ref_atom[i + 8]);
+ ref->data_rate *= 10;
- debug_atom_load(" qt rmdr data rate = %lld\n", ref->data_rate);
+ debug_atom_load (" qt rmdr data rate = %lld\n", ref->data_rate);
- } else if (current_atom == RMVC_ATOM) {
+ }
+ else if (current_atom == RMVC_ATOM)
+ {
- debug_atom_load(" qt rmvc atom\n");
+ debug_atom_load (" qt rmvc atom\n");
- /* search the rmvc atom for 'qtim'; 2 bytes will follow the qtim
- * chars so only search to 6 bytes to the end */
- for (j = 4; j < current_atom_size - 6; j++) {
+ /* search the rmvc atom for 'qtim'; 2 bytes will follow the qtim
+ * chars so only search to 6 bytes to the end */
+ for (j = 4; j < current_atom_size - 6; j++)
+ {
- if (BE_32(&ref_atom[i + j]) == QTIM_ATOM) {
+ if (BE_32 (&ref_atom[i + j]) == QTIM_ATOM)
+ {
- ref->qtim_version = BE_16(&ref_atom[i + j + 4]);
- debug_atom_load(" qtim version = %04X\n", ref->qtim_version);
+ ref->qtim_version = BE_16 (&ref_atom[i + j + 4]);
+ debug_atom_load (" qtim version = %04X\n",
+ ref->qtim_version);
+ }
+ }
}
- }
}
- }
return QT_OK;
}
@@ -1386,51 +1548,61 @@
/* This is a little support function used to process the edit list when
* building a frame table. */
#define MAX_DURATION 0x7FFFFFFFFFFFFFFF
-static void get_next_edit_list_entry(qt_trak *trak,
- int *edit_list_index,
- unsigned int *edit_list_media_time,
- int64_t *edit_list_duration,
- unsigned int global_timescale) {
+static void
+get_next_edit_list_entry (qt_trak * trak,
+ int *edit_list_index,
+ unsigned int *edit_list_media_time,
+ int64_t * edit_list_duration,
+ unsigned int global_timescale)
+{
/* if there is no edit list, set to max duration and get out */
- if (!trak->edit_list_table) {
+ if (!trak->edit_list_table)
+ {
- *edit_list_media_time = 0;
- *edit_list_duration = MAX_DURATION;
- debug_edit_list(" qt: no edit list table, initial = %d, %lld\n",
*edit_list_media_time, *edit_list_duration);
- return;
+ *edit_list_media_time = 0;
+ *edit_list_duration = MAX_DURATION;
+ debug_edit_list (" qt: no edit list table, initial = %d, %lld\n",
+ *edit_list_media_time, *edit_list_duration);
+ return;
- } else while (*edit_list_index < trak->edit_list_count) {
+ }
+ else
+ while (*edit_list_index < trak->edit_list_count)
+ {
- /* otherwise, find an edit list entries whose media time != -1 */
- if (trak->edit_list_table[*edit_list_index].media_time != -1) {
+ /* otherwise, find an edit list entries whose media time != -1 */
+ if (trak->edit_list_table[*edit_list_index].media_time != -1)
+ {
- *edit_list_media_time =
- trak->edit_list_table[*edit_list_index].media_time;
- *edit_list_duration =
- trak->edit_list_table[*edit_list_index].track_duration;
+ *edit_list_media_time =
+ trak->edit_list_table[*edit_list_index].media_time;
+ *edit_list_duration =
+ trak->edit_list_table[*edit_list_index].track_duration;
- /* duration is in global timescale units; convert to trak timescale */
- *edit_list_duration *= trak->timescale;
- *edit_list_duration /= global_timescale;
+ /* duration is in global timescale units; convert to trak
timescale */
+ *edit_list_duration *= trak->timescale;
+ *edit_list_duration /= global_timescale;
- *edit_list_index = *edit_list_index + 1;
- break;
- }
+ *edit_list_index = *edit_list_index + 1;
+ break;
+ }
- *edit_list_index = *edit_list_index + 1;
- }
+ *edit_list_index = *edit_list_index + 1;
+ }
/* on the way out, check if this is the last edit list entry; if so,
* don't let the duration expire (so set it to an absurdly large value)
*/
if (*edit_list_index == trak->edit_list_count)
*edit_list_duration = MAX_DURATION;
- debug_edit_list(" qt: edit list table exists, initial = %d, %lld\n",
*edit_list_media_time, *edit_list_duration);
+ debug_edit_list (" qt: edit list table exists, initial = %d, %lld\n",
+ *edit_list_media_time, *edit_list_duration);
}
-static qt_error build_frame_table(qt_trak *trak,
- unsigned int global_timescale) {
+static qt_error
+build_frame_table (qt_trak * trak, unsigned int global_timescale)
+{
int i, j;
unsigned int frame_counter;
@@ -1449,191 +1621,210 @@
/* AUDIO and OTHER frame types follow the same rules; VIDEO and vbr audio
* frame types follow a different set */
- if ((trak->type == MEDIA_VIDEO) ||
- (trak->properties.audio.vbr)) {
+ if ((trak->type == MEDIA_VIDEO) || (trak->properties.audio.vbr))
+ {
- /* in this case, the total number of frames is equal to the number of
- * entries in the sample size table */
- trak->frame_count = trak->sample_size_count;
- trak->frames = (qt_frame *)malloc(
- trak->frame_count * sizeof(qt_frame));
- if (!trak->frames)
- return QT_NO_MEMORY;
- trak->current_frame = 0;
+ /* in this case, the total number of frames is equal to the number of
+ * entries in the sample size table */
+ trak->frame_count = trak->sample_size_count;
+ trak->frames =
+ (qt_frame *) malloc (trak->frame_count * sizeof (qt_frame));
+ if (!trak->frames)
+ return QT_NO_MEMORY;
+ trak->current_frame = 0;
- /* initialize more accounting variables */
- frame_counter = 0;
- current_pts = 0;
- pts_index = 0;
- pts_index_countdown =
- trak->time_to_sample_table[pts_index].count;
+ /* initialize more accounting variables */
+ frame_counter = 0;
+ current_pts = 0;
+ pts_index = 0;
+ pts_index_countdown = trak->time_to_sample_table[pts_index].count;
- /* iterate through each start chunk in the stsc table */
- for (i = 0; i < trak->sample_to_chunk_count; i++) {
- /* iterate from the first chunk of the current table entry to
- * the first chunk of the next table entry */
- chunk_start = trak->sample_to_chunk_table[i].first_chunk;
- if (i < trak->sample_to_chunk_count - 1)
- chunk_end =
- trak->sample_to_chunk_table[i + 1].first_chunk;
- else
- /* if the first chunk is in the last table entry, iterate to the
- final chunk number (the number of offsets in stco table) */
- chunk_end = trak->chunk_offset_count + 1;
+ /* iterate through each start chunk in the stsc table */
+ for (i = 0; i < trak->sample_to_chunk_count; i++)
+ {
+ /* iterate from the first chunk of the current table entry to
+ * the first chunk of the next table entry */
+ chunk_start = trak->sample_to_chunk_table[i].first_chunk;
+ if (i < trak->sample_to_chunk_count - 1)
+ chunk_end = trak->sample_to_chunk_table[i + 1].first_chunk;
+ else
+ /* if the first chunk is in the last table entry, iterate to the
+ final chunk number (the number of offsets in stco table) */
+ chunk_end = trak->chunk_offset_count + 1;
- /* iterate through each sample in a chunk */
- for (j = chunk_start - 1; j < chunk_end - 1; j++) {
+ /* iterate through each sample in a chunk */
+ for (j = chunk_start - 1; j < chunk_end - 1; j++)
+ {
- samples_per_chunk =
- trak->sample_to_chunk_table[i].samples_per_chunk;
- current_offset = trak->chunk_offset_table[j];
- while (samples_per_chunk > 0) {
+ samples_per_chunk =
+ trak->sample_to_chunk_table[i].samples_per_chunk;
+ current_offset = trak->chunk_offset_table[j];
+ while (samples_per_chunk > 0)
+ {
- /* figure out the offset and size */
- trak->frames[frame_counter].offset = current_offset;
- if (trak->sample_size) {
- trak->frames[frame_counter].size =
- trak->sample_size;
- current_offset += trak->sample_size;
- } else {
- trak->frames[frame_counter].size =
- trak->sample_size_table[frame_counter];
- current_offset +=
- trak->sample_size_table[frame_counter];
- }
+ /* figure out the offset and size */
+ trak->frames[frame_counter].offset = current_offset;
+ if (trak->sample_size)
+ {
+ trak->frames[frame_counter].size = trak->sample_size;
+ current_offset += trak->sample_size;
+ }
+ else
+ {
+ trak->frames[frame_counter].size =
+ trak->sample_size_table[frame_counter];
+ current_offset +=
+ trak->sample_size_table[frame_counter];
+ }
- /* if there is no stss (sample sync) table, make all of the frames
- * keyframes; otherwise, clear the keyframe bits for now */
- if (trak->sync_sample_table)
- trak->frames[frame_counter].keyframe = 0;
- else
- trak->frames[frame_counter].keyframe = 1;
+ /* if there is no stss (sample sync) table, make all of the
frames
+ * keyframes; otherwise, clear the keyframe bits for now */
+ if (trak->sync_sample_table)
+ trak->frames[frame_counter].keyframe = 0;
+ else
+ trak->frames[frame_counter].keyframe = 1;
- /* figure out the pts situation */
- trak->frames[frame_counter].pts = current_pts;
- current_pts +=
- trak->time_to_sample_table[pts_index].duration;
- pts_index_countdown--;
- /* time to refresh countdown? */
- if (!pts_index_countdown) {
- pts_index++;
- pts_index_countdown =
- trak->time_to_sample_table[pts_index].count;
- }
+ /* figure out the pts situation */
+ trak->frames[frame_counter].pts = current_pts;
+ current_pts +=
+ trak->time_to_sample_table[pts_index].duration;
+ pts_index_countdown--;
+ /* time to refresh countdown? */
+ if (!pts_index_countdown)
+ {
+ pts_index++;
+ pts_index_countdown =
+ trak->time_to_sample_table[pts_index].count;
+ }
- samples_per_chunk--;
- frame_counter++;
+ samples_per_chunk--;
+ frame_counter++;
+ }
+ }
}
- }
- }
- /* fill in the keyframe information */
- if (trak->sync_sample_table) {
- for (i = 0; i < trak->sync_sample_count; i++)
- trak->frames[trak->sync_sample_table[i] - 1].keyframe = 1;
- }
+ /* fill in the keyframe information */
+ if (trak->sync_sample_table)
+ {
+ for (i = 0; i < trak->sync_sample_count; i++)
+ trak->frames[trak->sync_sample_table[i] - 1].keyframe = 1;
+ }
- /* initialize edit list considerations */
- edit_list_index = 0;
- get_next_edit_list_entry(trak, &edit_list_index,
- &edit_list_media_time, &edit_list_duration, global_timescale);
+ /* initialize edit list considerations */
+ edit_list_index = 0;
+ get_next_edit_list_entry (trak, &edit_list_index,
+ &edit_list_media_time, &edit_list_duration,
+ global_timescale);
- /* fix up pts information w.r.t. the edit list table */
- edit_list_pts_counter = 0;
- for (i = 0; i < trak->frame_count; i++) {
+ /* fix up pts information w.r.t. the edit list table */
+ edit_list_pts_counter = 0;
+ for (i = 0; i < trak->frame_count; i++)
+ {
- debug_edit_list(" %d: (before) pts = %lld...", i,
trak->frames[i].pts);
+ debug_edit_list (" %d: (before) pts = %lld...", i,
+ trak->frames[i].pts);
- if (trak->frames[i].pts < edit_list_media_time)
- trak->frames[i].pts = edit_list_pts_counter;
- else {
- if (i < trak->frame_count - 1)
- frame_duration =
- (trak->frames[i + 1].pts - trak->frames[i].pts);
+ if (trak->frames[i].pts < edit_list_media_time)
+ trak->frames[i].pts = edit_list_pts_counter;
+ else
+ {
+ if (i < trak->frame_count - 1)
+ frame_duration =
+ (trak->frames[i + 1].pts - trak->frames[i].pts);
- debug_edit_list("duration = %lld...", frame_duration);
- trak->frames[i].pts = edit_list_pts_counter;
- edit_list_pts_counter += frame_duration;
- edit_list_duration -= frame_duration;
- }
+ debug_edit_list ("duration = %lld...", frame_duration);
+ trak->frames[i].pts = edit_list_pts_counter;
+ edit_list_pts_counter += frame_duration;
+ edit_list_duration -= frame_duration;
+ }
- debug_edit_list("(fixup) pts = %lld...", trak->frames[i].pts);
+ debug_edit_list ("(fixup) pts = %lld...", trak->frames[i].pts);
- /* reload media time and duration */
- if (edit_list_duration <= 0) {
- get_next_edit_list_entry(trak, &edit_list_index,
- &edit_list_media_time, &edit_list_duration, global_timescale);
- }
+ /* reload media time and duration */
+ if (edit_list_duration <= 0)
+ {
+ get_next_edit_list_entry (trak, &edit_list_index,
+ &edit_list_media_time,
+ &edit_list_duration,
+ global_timescale);
+ }
- debug_edit_list("(after) pts = %lld...\n", trak->frames[i].pts);
- }
+ debug_edit_list ("(after) pts = %lld...\n", trak->frames[i].pts);
+ }
- /* compute final pts values */
- for (i = 0; i < trak->frame_count; i++) {
- trak->frames[i].pts *= 90000;
- trak->frames[i].pts /= trak->timescale;
- debug_edit_list(" final pts for sample %d = %lld\n", i,
trak->frames[i].pts);
+ /* compute final pts values */
+ for (i = 0; i < trak->frame_count; i++)
+ {
+ trak->frames[i].pts *= 90000;
+ trak->frames[i].pts /= trak->timescale;
+ debug_edit_list (" final pts for sample %d = %lld\n", i,
+ trak->frames[i].pts);
+ }
+
}
+ else
+ {
- } else {
+ /* in this case, the total number of frames is equal to the number of
+ * chunks */
+ trak->frame_count = trak->chunk_offset_count;
+ trak->frames =
+ (qt_frame *) malloc (trak->frame_count * sizeof (qt_frame));
+ if (!trak->frames)
+ return QT_NO_MEMORY;
- /* in this case, the total number of frames is equal to the number of
- * chunks */
- trak->frame_count = trak->chunk_offset_count;
- trak->frames = (qt_frame *)malloc(
- trak->frame_count * sizeof(qt_frame));
- if (!trak->frames)
- return QT_NO_MEMORY;
+ if (trak->type == MEDIA_AUDIO)
+ {
+ /* iterate through each start chunk in the stsc table */
+ for (i = 0; i < trak->sample_to_chunk_count; i++)
+ {
+ /* iterate from the first chunk of the current table entry to
+ * the first chunk of the next table entry */
+ chunk_start = trak->sample_to_chunk_table[i].first_chunk;
+ if (i < trak->sample_to_chunk_count - 1)
+ chunk_end = trak->sample_to_chunk_table[i + 1].first_chunk;
+ else
+ /* if the first chunk is in the last table entry, iterate to
the
+ final chunk number (the number of offsets in stco table) */
+ chunk_end = trak->chunk_offset_count + 1;
- if (trak->type == MEDIA_AUDIO) {
- /* iterate through each start chunk in the stsc table */
- for (i = 0; i < trak->sample_to_chunk_count; i++) {
- /* iterate from the first chunk of the current table entry to
- * the first chunk of the next table entry */
- chunk_start = trak->sample_to_chunk_table[i].first_chunk;
- if (i < trak->sample_to_chunk_count - 1)
- chunk_end =
- trak->sample_to_chunk_table[i + 1].first_chunk;
- else
- /* if the first chunk is in the last table entry, iterate to the
- final chunk number (the number of offsets in stco table) */
- chunk_end = trak->chunk_offset_count + 1;
+ /* iterate through each sample in a chunk and fill in size and
+ * pts information */
+ for (j = chunk_start - 1; j < chunk_end - 1; j++)
+ {
- /* iterate through each sample in a chunk and fill in size and
- * pts information */
- for (j = chunk_start - 1; j < chunk_end - 1; j++) {
+ /* figure out the pts for this chunk */
+ trak->frames[j].pts = audio_frame_counter;
+ trak->frames[j].pts *= 90000;
+ trak->frames[j].pts /= trak->timescale;
- /* figure out the pts for this chunk */
- trak->frames[j].pts = audio_frame_counter;
- trak->frames[j].pts *= 90000;
- trak->frames[j].pts /= trak->timescale;
+ /* fetch the alleged chunk size according to the QT header */
+ trak->frames[j].size =
+ trak->sample_to_chunk_table[i].samples_per_chunk;
- /* fetch the alleged chunk size according to the QT header */
- trak->frames[j].size =
- trak->sample_to_chunk_table[i].samples_per_chunk;
+ /* the chunk size is actually the audio frame count */
+ audio_frame_counter += trak->frames[j].size;
- /* the chunk size is actually the audio frame count */
- audio_frame_counter += trak->frames[j].size;
+ /* compute the actual chunk size */
+ trak->frames[j].size =
+ (trak->frames[j].size *
+ trak->properties.audio.channels) /
+ trak->properties.audio.samples_per_frame *
+ trak->properties.audio.bytes_per_frame;
+ }
+ }
+ }
- /* compute the actual chunk size */
- trak->frames[j].size =
- (trak->frames[j].size *
- trak->properties.audio.channels) /
- trak->properties.audio.samples_per_frame *
- trak->properties.audio.bytes_per_frame;
+ /* fill in the rest of the information for the audio samples */
+ for (i = 0; i < trak->frame_count; i++)
+ {
+ trak->frames[i].offset = trak->chunk_offset_table[i];
+ trak->frames[i].keyframe = 0;
+ if (trak->type != MEDIA_AUDIO)
+ trak->frames[i].pts = 0;
}
- }
}
- /* fill in the rest of the information for the audio samples */
- for (i = 0; i < trak->frame_count; i++) {
- trak->frames[i].offset = trak->chunk_offset_table[i];
- trak->frames[i].keyframe = 0;
- if (trak->type != MEDIA_AUDIO)
- trak->frames[i].pts = 0;
- }
- }
-
return QT_OK;
}
@@ -1643,140 +1834,168 @@
* finishes successfully, qt_info will have a list of qt_frame objects,
* ordered by offset.
*/
-static void parse_moov_atom(qt_info *info, unsigned char *moov_atom,
- int64_t bandwidth) {
+static void
+parse_moov_atom (qt_info * info, unsigned char *moov_atom, int64_t bandwidth)
+{
int i, j;
- unsigned int moov_atom_size = BE_32(&moov_atom[0]);
+ unsigned int moov_atom_size = BE_32 (&moov_atom[0]);
qt_atom current_atom;
int string_size;
unsigned int max_video_frames = 0;
unsigned int max_audio_frames = 0;
/* make sure this is actually a moov atom */
- if (BE_32(&moov_atom[4]) != MOOV_ATOM) {
- info->last_error = QT_NO_MOOV_ATOM;
- return;
- }
+ if (BE_32 (&moov_atom[4]) != MOOV_ATOM)
+ {
+ info->last_error = QT_NO_MOOV_ATOM;
+ return;
+ }
/* prowl through the moov atom looking for very specific targets */
- for (i = ATOM_PREAMBLE_SIZE; i < moov_atom_size - 4; i++) {
- current_atom = BE_32(&moov_atom[i]);
+ for (i = ATOM_PREAMBLE_SIZE; i < moov_atom_size - 4; i++)
+ {
+ current_atom = BE_32 (&moov_atom[i]);
- if (current_atom == MVHD_ATOM) {
- parse_mvhd_atom(info, &moov_atom[i - 4]);
- if (info->last_error != QT_OK)
- return;
- i += BE_32(&moov_atom[i - 4]) - 4;
- } else if (current_atom == TRAK_ATOM) {
+ if (current_atom == MVHD_ATOM)
+ {
+ parse_mvhd_atom (info, &moov_atom[i - 4]);
+ if (info->last_error != QT_OK)
+ return;
+ i += BE_32 (&moov_atom[i - 4]) - 4;
+ }
+ else if (current_atom == TRAK_ATOM)
+ {
- /* create a new trak structure */
- info->trak_count++;
- info->traks = (qt_trak *)realloc(info->traks,
- info->trak_count * sizeof(qt_trak));
+ /* create a new trak structure */
+ info->trak_count++;
+ info->traks = (qt_trak *) realloc (info->traks,
+ info->trak_count *
+ sizeof (qt_trak));
- parse_trak_atom (&info->traks[info->trak_count - 1], &moov_atom[i - 4]);
- if (info->last_error != QT_OK) {
- info->trak_count--;
- return;
- }
- i += BE_32(&moov_atom[i - 4]) - 4;
+ parse_trak_atom (&info->traks[info->trak_count - 1],
+ &moov_atom[i - 4]);
+ if (info->last_error != QT_OK)
+ {
+ info->trak_count--;
+ return;
+ }
+ i += BE_32 (&moov_atom[i - 4]) - 4;
- } else if (current_atom == CPY_ATOM) {
+ }
+ else if (current_atom == CPY_ATOM)
+ {
- string_size = BE_16(&moov_atom[i + 4]) + 1;
- info->copyright = realloc (info->copyright, string_size);
- strncpy(info->copyright, &moov_atom[i + 8], string_size - 1);
- info->copyright[string_size - 1] = 0;
+ string_size = BE_16 (&moov_atom[i + 4]) + 1;
+ info->copyright = realloc (info->copyright, string_size);
+ strncpy (info->copyright, &moov_atom[i + 8], string_size - 1);
+ info->copyright[string_size - 1] = 0;
- } else if (current_atom == DES_ATOM) {
+ }
+ else if (current_atom == DES_ATOM)
+ {
- string_size = BE_16(&moov_atom[i + 4]) + 1;
- info->description = realloc (info->description, string_size);
- strncpy(info->description, &moov_atom[i + 8], string_size - 1);
- info->description[string_size - 1] = 0;
+ string_size = BE_16 (&moov_atom[i + 4]) + 1;
+ info->description = realloc (info->description, string_size);
+ strncpy (info->description, &moov_atom[i + 8], string_size - 1);
+ info->description[string_size - 1] = 0;
- } else if (current_atom == CMT_ATOM) {
+ }
+ else if (current_atom == CMT_ATOM)
+ {
- string_size = BE_16(&moov_atom[i + 4]) + 1;
- info->comment = realloc (info->comment, string_size);
- strncpy(info->comment, &moov_atom[i + 8], string_size - 1);
- info->comment[string_size - 1] = 0;
+ string_size = BE_16 (&moov_atom[i + 4]) + 1;
+ info->comment = realloc (info->comment, string_size);
+ strncpy (info->comment, &moov_atom[i + 8], string_size - 1);
+ info->comment[string_size - 1] = 0;
- } else if (current_atom == RMDA_ATOM) {
+ }
+ else if (current_atom == RMDA_ATOM)
+ {
- /* create a new reference structure */
- info->reference_count++;
- info->references = (reference_t *)realloc(info->references,
- info->reference_count * sizeof(reference_t));
+ /* create a new reference structure */
+ info->reference_count++;
+ info->references = (reference_t *) realloc (info->references,
+ info->reference_count *
+ sizeof (reference_t));
- parse_reference_atom(&info->references[info->reference_count - 1],
- &moov_atom[i - 4], info->base_mrl);
+ parse_reference_atom (&info->references[info->reference_count - 1],
+ &moov_atom[i - 4], info->base_mrl);
+ }
}
- }
- debug_atom_load(" qt: finished parsing moov atom\n");
+ debug_atom_load (" qt: finished parsing moov atom\n");
/* build frame tables corresponding to each trak */
- debug_frame_table(" qt: preparing to build %d frame tables\n",
- info->trak_count);
- for (i = 0; i < info->trak_count; i++) {
+ debug_frame_table (" qt: preparing to build %d frame tables\n",
+ info->trak_count);
+ for (i = 0; i < info->trak_count; i++)
+ {
- debug_frame_table(" qt: building frame table #%d (%s)\n", i,
- (info->traks[i].type == MEDIA_VIDEO) ? "video" : "audio");
- build_frame_table(&info->traks[i], info->timescale);
+ debug_frame_table (" qt: building frame table #%d (%s)\n", i,
+ (info->traks[i].type ==
+ MEDIA_VIDEO) ? "video" : "audio");
+ build_frame_table (&info->traks[i], info->timescale);
- /* dump the frame table in debug mode */
- for (j = 0; j < info->traks[i].frame_count; j++)
- debug_frame_table(" %d: %8X bytes @ %llX, %lld pts%s\n",
- j,
- info->traks[i].frames[j].size,
- info->traks[i].frames[j].offset,
- info->traks[i].frames[j].pts,
- (info->traks[i].frames[j].keyframe) ? " (keyframe)" : "");
+ /* dump the frame table in debug mode */
+ for (j = 0; j < info->traks[i].frame_count; j++)
+ debug_frame_table (" %d: %8X bytes @ %llX, %lld pts%s\n",
+ j,
+ info->traks[i].frames[j].size,
+ info->traks[i].frames[j].offset,
+ info->traks[i].frames[j].pts,
+ (info->traks[i].frames[j].
+ keyframe) ? " (keyframe)" : "");
- /* decide which audio trak and which video trak has the most frames */
- if ((info->traks[i].type == MEDIA_VIDEO) &&
- (info->traks[i].frame_count > max_video_frames)) {
+ /* decide which audio trak and which video trak has the most frames */
+ if ((info->traks[i].type == MEDIA_VIDEO) &&
+ (info->traks[i].frame_count > max_video_frames))
+ {
- info->video_trak = i;
- max_video_frames = info->traks[i].frame_count;
+ info->video_trak = i;
+ max_video_frames = info->traks[i].frame_count;
- } else if ((info->traks[i].type == MEDIA_AUDIO) &&
- (info->traks[i].frame_count > max_audio_frames)) {
+ }
+ else if ((info->traks[i].type == MEDIA_AUDIO) &&
+ (info->traks[i].frame_count > max_audio_frames))
+ {
- info->audio_trak = i;
- max_audio_frames = info->traks[i].frame_count;
+ info->audio_trak = i;
+ max_audio_frames = info->traks[i].frame_count;
+ }
}
- }
/* check for references */
- if (info->reference_count > 0) {
+ if (info->reference_count > 0)
+ {
- /* init chosen reference to the first entry */
- info->chosen_reference = 0;
+ /* init chosen reference to the first entry */
+ info->chosen_reference = 0;
- /* iterate through 1..n-1 reference entries and decide on the right one */
- for (i = 1; i < info->reference_count; i++) {
+ /* iterate through 1..n-1 reference entries and decide on the right one
*/
+ for (i = 1; i < info->reference_count; i++)
+ {
- if (info->references[i].qtim_version >
- info->references[info->chosen_reference].qtim_version)
- info->chosen_reference = i;
- else if ((info->references[i].data_rate <= bandwidth) &&
- (info->references[i].data_rate >
- info->references[info->chosen_reference].data_rate))
- info->chosen_reference = i;
+ if (info->references[i].qtim_version >
+ info->references[info->chosen_reference].qtim_version)
+ info->chosen_reference = i;
+ else if ((info->references[i].data_rate <= bandwidth) &&
+ (info->references[i].data_rate >
+ info->references[info->chosen_reference].data_rate))
+ info->chosen_reference = i;
+ }
+
+ debug_atom_load
+ (" qt: chosen reference is ref #%d, qtim version %04X, %lld bps\n
URL: %s\n",
+ info->chosen_reference,
+ info->references[info->chosen_reference].qtim_version,
+ info->references[info->chosen_reference].data_rate,
+ info->references[info->chosen_reference].url);
}
-
- debug_atom_load(" qt: chosen reference is ref #%d, qtim version %04X,
%lld bps\n URL: %s\n",
- info->chosen_reference,
- info->references[info->chosen_reference].qtim_version,
- info->references[info->chosen_reference].data_rate,
- info->references[info->chosen_reference].url);
- }
}
-static qt_error open_qt_file(qt_info *info, input_plugin_t *input,
- int64_t bandwidth) {
+static qt_error
+open_qt_file (qt_info * info, input_plugin_t * input, int64_t bandwidth)
+{
unsigned char *moov_atom = NULL;
off_t moov_atom_offset = -1;
@@ -1789,122 +2008,135 @@
unsigned char *unzip_buffer;
/* extract the base MRL if this is a http MRL */
- if (strncmp(input->get_mrl(input), "http://", 7) == 0) {
+ if (strncmp (input->get_mrl (input), "http://", 7) == 0)
+ {
- char *slash;
+ char *slash;
- /* this will copy a few bytes too many, but no big deal */
- info->base_mrl = strdup(input->get_mrl(input));
- /* terminate the string after the last slash character */
- slash = strrchr(info->base_mrl, '/');
- if (slash)
- *(slash + 1) = '\0';
- }
+ /* this will copy a few bytes too many, but no big deal */
+ info->base_mrl = strdup (input->get_mrl (input));
+ /* terminate the string after the last slash character */
+ slash = strrchr (info->base_mrl, '/');
+ if (slash)
+ *(slash + 1) = '\0';
+ }
- if ((input->get_capabilities(input) & INPUT_CAP_SEEKABLE))
- find_moov_atom(input, &moov_atom_offset, &moov_atom_size);
- else {
- input->get_optional_data(input, preview, INPUT_OPTIONAL_DATA_PREVIEW);
- if (BE_32(&preview[4]) != MOOV_ATOM) {
+ if ((input->get_capabilities (input) & INPUT_CAP_SEEKABLE))
+ find_moov_atom (input, &moov_atom_offset, &moov_atom_size);
+ else
+ {
+ input->get_optional_data (input, preview, INPUT_OPTIONAL_DATA_PREVIEW);
+ if (BE_32 (&preview[4]) != MOOV_ATOM)
+ {
+ info->last_error = QT_NO_MOOV_ATOM;
+ return info->last_error;
+ }
+ moov_atom_offset = 0;
+ moov_atom_size = BE_32 (&preview[0]);
+ }
+
+ if (moov_atom_offset == -1)
+ {
info->last_error = QT_NO_MOOV_ATOM;
return info->last_error;
}
- moov_atom_offset = 0;
- moov_atom_size = BE_32(&preview[0]);
- }
-
- if (moov_atom_offset == -1) {
- info->last_error = QT_NO_MOOV_ATOM;
- return info->last_error;
- }
info->moov_first_offset = moov_atom_offset;
- moov_atom = (unsigned char *)malloc(moov_atom_size);
- if (moov_atom == NULL) {
- info->last_error = QT_NO_MEMORY;
- return info->last_error;
- }
+ moov_atom = (unsigned char *) malloc (moov_atom_size);
+ if (moov_atom == NULL)
+ {
+ info->last_error = QT_NO_MEMORY;
+ return info->last_error;
+ }
/* seek to the start of moov atom */
- if (input->seek(input, info->moov_first_offset, SEEK_SET) !=
- info->moov_first_offset) {
- free(moov_atom);
- info->last_error = QT_FILE_READ_ERROR;
- return info->last_error;
- }
- if (input->read(input, moov_atom, moov_atom_size) !=
- moov_atom_size) {
- free(moov_atom);
- info->last_error = QT_FILE_READ_ERROR;
- return info->last_error;
- }
+ if (input->seek (input, info->moov_first_offset, SEEK_SET) !=
+ info->moov_first_offset)
+ {
+ free (moov_atom);
+ info->last_error = QT_FILE_READ_ERROR;
+ return info->last_error;
+ }
+ if (input->read (input, moov_atom, moov_atom_size) != moov_atom_size)
+ {
+ free (moov_atom);
+ info->last_error = QT_FILE_READ_ERROR;
+ return info->last_error;
+ }
/* check if moov is compressed */
- if (BE_32(&moov_atom[12]) == CMOV_ATOM) {
+ if (BE_32 (&moov_atom[12]) == CMOV_ATOM)
+ {
- info->compressed_header = 1;
+ info->compressed_header = 1;
- z_state.next_in = &moov_atom[0x28];
- z_state.avail_in = moov_atom_size - 0x28;
- z_state.avail_out = BE_32(&moov_atom[0x24]);
- unzip_buffer = (unsigned char *)malloc(BE_32(&moov_atom[0x24]));
- if (!unzip_buffer) {
- free(moov_atom);
- info->last_error = QT_NO_MEMORY;
- return info->last_error;
- }
+ z_state.next_in = &moov_atom[0x28];
+ z_state.avail_in = moov_atom_size - 0x28;
+ z_state.avail_out = BE_32 (&moov_atom[0x24]);
+ unzip_buffer = (unsigned char *) malloc (BE_32 (&moov_atom[0x24]));
+ if (!unzip_buffer)
+ {
+ free (moov_atom);
+ info->last_error = QT_NO_MEMORY;
+ return info->last_error;
+ }
- z_state.next_out = unzip_buffer;
- z_state.zalloc = (alloc_func)0;
- z_state.zfree = (free_func)0;
- z_state.opaque = (voidpf)0;
+ z_state.next_out = unzip_buffer;
+ z_state.zalloc = (alloc_func) 0;
+ z_state.zfree = (free_func) 0;
+ z_state.opaque = (voidpf) 0;
- z_ret_code = inflateInit (&z_state);
- if (Z_OK != z_ret_code) {
- free(unzip_buffer);
- free(moov_atom);
- info->last_error = QT_ZLIB_ERROR;
- return info->last_error;
- }
+ z_ret_code = inflateInit (&z_state);
+ if (Z_OK != z_ret_code)
+ {
+ free (unzip_buffer);
+ free (moov_atom);
+ info->last_error = QT_ZLIB_ERROR;
+ return info->last_error;
+ }
- z_ret_code = inflate(&z_state, Z_NO_FLUSH);
- if ((z_ret_code != Z_OK) && (z_ret_code != Z_STREAM_END)) {
- free(unzip_buffer);
- free(moov_atom);
- info->last_error = QT_ZLIB_ERROR;
- return info->last_error;
+ z_ret_code = inflate (&z_state, Z_NO_FLUSH);
+ if ((z_ret_code != Z_OK) && (z_ret_code != Z_STREAM_END))
+ {
+ free (unzip_buffer);
+ free (moov_atom);
+ info->last_error = QT_ZLIB_ERROR;
+ return info->last_error;
+ }
+
+ z_ret_code = inflateEnd (&z_state);
+ if (Z_OK != z_ret_code)
+ {
+ free (unzip_buffer);
+ free (moov_atom);
+ info->last_error = QT_ZLIB_ERROR;
+ return info->last_error;
+ }
+
+ /* replace the compressed moov atom with the decompressed atom */
+ free (moov_atom);
+ moov_atom = unzip_buffer;
+ moov_atom_size = BE_32 (&moov_atom[0]);
}
- z_ret_code = inflateEnd(&z_state);
- if (Z_OK != z_ret_code) {
- free(unzip_buffer);
- free(moov_atom);
- info->last_error = QT_ZLIB_ERROR;
+ if (!moov_atom)
+ {
+ info->last_error = QT_NO_MOOV_ATOM;
return info->last_error;
}
- /* replace the compressed moov atom with the decompressed atom */
- free (moov_atom);
- moov_atom = unzip_buffer;
- moov_atom_size = BE_32(&moov_atom[0]);
- }
-
- if (!moov_atom) {
- info->last_error = QT_NO_MOOV_ATOM;
- return info->last_error;
- }
-
/* write moov atom to disk if debugging option is turned on */
- dump_moov_atom(moov_atom, moov_atom_size);
+ dump_moov_atom (moov_atom, moov_atom_size);
/* take apart the moov atom */
- parse_moov_atom(info, moov_atom, bandwidth);
- if (info->last_error != QT_OK) {
- free(moov_atom);
- return info->last_error;
- }
+ parse_moov_atom (info, moov_atom, bandwidth);
+ if (info->last_error != QT_OK)
+ {
+ free (moov_atom);
+ return info->last_error;
+ }
- free(moov_atom);
+ free (moov_atom);
return QT_OK;
}
@@ -1913,7 +2145,9 @@
* xine demuxer functions
**********************************************************************/
-static int demux_qt_send_chunk(demux_plugin_t *this_gen) {
+static int
+demux_qt_send_chunk (demux_plugin_t * this_gen)
+{
demux_qt_t *this = (demux_qt_t *) this_gen;
buf_element_t *buf = NULL;
@@ -1923,270 +2157,321 @@
int first_buf;
qt_trak *video_trak = NULL;
qt_trak *audio_trak = NULL;
- int dispatch_audio; /* boolean for deciding which trak to dispatch */
+ int dispatch_audio; /* boolean for deciding which trak to dispatch
*/
int64_t pts_diff;
xine_event_t uevent;
xine_mrl_reference_data_t *data;
/* check if it's time to send a reference up to the UI */
- if (this->qt->chosen_reference != -1) {
+ if (this->qt->chosen_reference != -1)
+ {
- uevent.type = XINE_EVENT_MRL_REFERENCE;
- uevent.stream = this->stream;
- uevent.data_length =
- strlen(this->qt->references[this->qt->chosen_reference].url) +
- sizeof(xine_mrl_reference_data_t);
- data = malloc(uevent.data_length);
- uevent.data = data;
- strcpy(data->mrl, this->qt->references[this->qt->chosen_reference].url);
- data->alternative = 0;
- xine_event_send(this->stream, &uevent);
+ uevent.type = XINE_EVENT_MRL_REFERENCE;
+ uevent.stream = this->stream;
+ uevent.data_length =
+ strlen (this->qt->references[this->qt->chosen_reference].url) +
+ sizeof (xine_mrl_reference_data_t);
+ data = malloc (uevent.data_length);
+ uevent.data = data;
+ strcpy (data->mrl,
+ this->qt->references[this->qt->chosen_reference].url);
+ data->alternative = 0;
+ xine_event_send (this->stream, &uevent);
- this->status = DEMUX_FINISHED;
- return this->status;
- }
+ this->status = DEMUX_FINISHED;
+ return this->status;
+ }
- if (this->qt->video_trak != -1) {
- video_trak = &this->qt->traks[this->qt->video_trak];
- }
- if (this->qt->audio_trak != -1) {
- audio_trak = &this->qt->traks[this->qt->audio_trak];
- }
+ if (this->qt->video_trak != -1)
+ {
+ video_trak = &this->qt->traks[this->qt->video_trak];
+ }
+ if (this->qt->audio_trak != -1)
+ {
+ audio_trak = &this->qt->traks[this->qt->audio_trak];
+ }
- if (!audio_trak && !video_trak) {
- /* something is really wrong if this case is reached */
- this->status = DEMUX_FINISHED;
- return this->status;
- }
+ if (!audio_trak && !video_trak)
+ {
+ /* something is really wrong if this case is reached */
+ this->status = DEMUX_FINISHED;
+ return this->status;
+ }
/* check if it is time to seek */
- if (this->qt->seek_flag) {
- this->qt->seek_flag = 0;
+ if (this->qt->seek_flag)
+ {
+ this->qt->seek_flag = 0;
- /* if audio is present, send pts of current audio frame, otherwise
- * send current video frame pts */
- if (audio_trak)
- xine_demux_control_newpts(this->stream,
- audio_trak->frames[audio_trak->current_frame].pts,
- BUF_FLAG_SEEK);
- else
- xine_demux_control_newpts(this->stream,
- video_trak->frames[video_trak->current_frame].pts,
- BUF_FLAG_SEEK);
- }
+ /* if audio is present, send pts of current audio frame, otherwise
+ * send current video frame pts */
+ if (audio_trak)
+ xine_demux_control_newpts (this->stream,
+ audio_trak->frames[audio_trak->
+ current_frame].pts,
+ BUF_FLAG_SEEK);
+ else
+ xine_demux_control_newpts (this->stream,
+ video_trak->frames[video_trak->
+ current_frame].pts,
+ BUF_FLAG_SEEK);
+ }
/* Decide the trak from which to dispatch a frame. Policy: Dispatch
* the frames in offset order as much as possible. If the pts difference
* between the current frames from the audio and video traks is too
* wide, make an exception. This exception deals with non-interleaved
* Quicktime files. */
- if (!audio_trak) {
+ if (!audio_trak)
+ {
- /* only video is present */
- dispatch_audio = 0;
- if (video_trak->current_frame >= video_trak->frame_count) {
- this->status = DEMUX_FINISHED;
- return this->status;
+ /* only video is present */
+ dispatch_audio = 0;
+ if (video_trak->current_frame >= video_trak->frame_count)
+ {
+ this->status = DEMUX_FINISHED;
+ return this->status;
+ }
+
}
+ else if (!video_trak)
+ {
- } else if (!video_trak) {
+ /* only audio is present */
+ dispatch_audio = 1;
+ if (audio_trak->current_frame >= audio_trak->frame_count)
+ {
+ this->status = DEMUX_FINISHED;
+ return this->status;
+ }
- /* only audio is present */
- dispatch_audio = 1;
- if (audio_trak->current_frame >= audio_trak->frame_count) {
- this->status = DEMUX_FINISHED;
- return this->status;
}
+ else
+ {
- } else {
+ /* both audio and video are present; start making some tough choices */
- /* both audio and video are present; start making some tough choices */
+ /* check the frame count limits */
+ if ((audio_trak->current_frame >= audio_trak->frame_count) &&
+ (video_trak->current_frame >= video_trak->frame_count))
+ {
- /* check the frame count limits */
- if ((audio_trak->current_frame >= audio_trak->frame_count) &&
- (video_trak->current_frame >= video_trak->frame_count)) {
+ this->status = DEMUX_FINISHED;
+ return this->status;
- this->status = DEMUX_FINISHED;
- return this->status;
+ }
+ else if (video_trak->current_frame >= video_trak->frame_count)
+ {
- } else if (video_trak->current_frame >= video_trak->frame_count) {
+ dispatch_audio = 1;
- dispatch_audio = 1;
+ }
+ else if (audio_trak->current_frame >= audio_trak->frame_count)
+ {
- } else if (audio_trak->current_frame >= audio_trak->frame_count) {
+ dispatch_audio = 0;
- dispatch_audio = 0;
+ }
+ else
+ {
- } else {
+ /* at this point, it is certain that both traks still have frames
+ * yet to be dispatched */
+ pts_diff = audio_trak->frames[audio_trak->current_frame].pts;
+ pts_diff -= video_trak->frames[video_trak->current_frame].pts;
- /* at this point, it is certain that both traks still have frames
- * yet to be dispatched */
- pts_diff = audio_trak->frames[audio_trak->current_frame].pts;
- pts_diff -= video_trak->frames[video_trak->current_frame].pts;
-
- if (pts_diff > MAX_PTS_DIFF) {
- /* if diff is +max_diff, audio is too far ahead of video */
- dispatch_audio = 0;
- } else if (pts_diff < -MAX_PTS_DIFF) {
- /* if diff is -max_diff, video is too far ahead of audio */
- dispatch_audio = 1;
- } else if (audio_trak->frames[audio_trak->current_frame].offset <
- video_trak->frames[video_trak->current_frame].offset) {
- /* pts diff is not too wide, decide based on earlier offset */
- dispatch_audio = 1;
- } else {
- dispatch_audio = 0;
- }
+ if (pts_diff > MAX_PTS_DIFF)
+ {
+ /* if diff is +max_diff, audio is too far ahead of video */
+ dispatch_audio = 0;
+ }
+ else if (pts_diff < -MAX_PTS_DIFF)
+ {
+ /* if diff is -max_diff, video is too far ahead of audio */
+ dispatch_audio = 1;
+ }
+ else if (audio_trak->frames[audio_trak->current_frame].offset <
+ video_trak->frames[video_trak->current_frame].offset)
+ {
+ /* pts diff is not too wide, decide based on earlier offset */
+ dispatch_audio = 1;
+ }
+ else
+ {
+ dispatch_audio = 0;
+ }
+ }
}
- }
- if (!dispatch_audio) {
- i = video_trak->current_frame++;
- remaining_sample_bytes = video_trak->frames[i].size;
- this->input->seek(this->input, video_trak->frames[i].offset,
- SEEK_SET);
+ if (!dispatch_audio)
+ {
+ i = video_trak->current_frame++;
+ remaining_sample_bytes = video_trak->frames[i].size;
+ this->input->seek (this->input, video_trak->frames[i].offset, SEEK_SET);
- if (i + 1 < video_trak->frame_count) {
- /* frame duration is the pts diff between this video frame and
- * the next video frame */
- frame_duration = video_trak->frames[i + 1].pts;
- frame_duration -= video_trak->frames[i].pts;
- } else {
- /* give the last frame some fixed duration */
- frame_duration = 12000;
- }
+ if (i + 1 < video_trak->frame_count)
+ {
+ /* frame duration is the pts diff between this video frame and
+ * the next video frame */
+ frame_duration = video_trak->frames[i + 1].pts;
+ frame_duration -= video_trak->frames[i].pts;
+ }
+ else
+ {
+ /* give the last frame some fixed duration */
+ frame_duration = 12000;
+ }
- /* Due to the edit lists, some successive frames have the same pts
- * which would ordinarily cause frame_duration to be 0 which can
- * cause DIV-by-0 errors in the engine. Perform this little trick
- * to compensate. */
- if (!frame_duration) {
- frame_duration = 1;
- video_trak->properties.video.edit_list_compensation++;
- } else {
- frame_duration -= video_trak->properties.video.edit_list_compensation;
- video_trak->properties.video.edit_list_compensation = 0;
- }
+ /* Due to the edit lists, some successive frames have the same pts
+ * which would ordinarily cause frame_duration to be 0 which can
+ * cause DIV-by-0 errors in the engine. Perform this little trick
+ * to compensate. */
+ if (!frame_duration)
+ {
+ frame_duration = 1;
+ video_trak->properties.video.edit_list_compensation++;
+ }
+ else
+ {
+ frame_duration -=
+ video_trak->properties.video.edit_list_compensation;
+ video_trak->properties.video.edit_list_compensation = 0;
+ }
- this->stream->stream_info[XINE_STREAM_INFO_FRAME_DURATION] =
- frame_duration;
+ this->stream->stream_info[XINE_STREAM_INFO_FRAME_DURATION] =
+ frame_duration;
- debug_video_demux(" qt: sending off video frame %d from offset 0x%llX, %d
bytes, %lld pts\n",
- i,
- video_trak->frames[i].offset,
- video_trak->frames[i].size,
- video_trak->frames[i].pts);
+ debug_video_demux
+ (" qt: sending off video frame %d from offset 0x%llX, %d bytes, %lld
pts\n",
+ i, video_trak->frames[i].offset, video_trak->frames[i].size,
+ video_trak->frames[i].pts);
- while (remaining_sample_bytes) {
- buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
- buf->type = video_trak->properties.video.codec_buftype;
- buf->extra_info->input_pos = video_trak->frames[i].offset -
this->data_start;
- buf->extra_info->input_length = this->data_size;
- buf->extra_info->input_time = video_trak->frames[i].pts / 90;
- buf->pts = video_trak->frames[i].pts;
+ while (remaining_sample_bytes)
+ {
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
+ buf->type = video_trak->properties.video.codec_buftype;
+ buf->extra_info->input_pos =
+ video_trak->frames[i].offset - this->data_start;
+ buf->extra_info->input_length = this->data_size;
+ buf->extra_info->input_time = video_trak->frames[i].pts / 90;
+ buf->pts = video_trak->frames[i].pts;
- buf->decoder_flags |= BUF_FLAG_FRAMERATE;
- buf->decoder_info[0] = frame_duration;
+ buf->decoder_flags |= BUF_FLAG_FRAMERATE;
+ buf->decoder_info[0] = frame_duration;
- if (remaining_sample_bytes > buf->max_size)
- buf->size = buf->max_size;
- else
- buf->size = remaining_sample_bytes;
- remaining_sample_bytes -= buf->size;
+ if (remaining_sample_bytes > buf->max_size)
+ buf->size = buf->max_size;
+ else
+ buf->size = remaining_sample_bytes;
+ remaining_sample_bytes -= buf->size;
- if (this->input->read(this->input, buf->content, buf->size) !=
- buf->size) {
- buf->free_buffer(buf);
- this->status = DEMUX_FINISHED;
- break;
- }
+ if (this->input->read (this->input, buf->content, buf->size) !=
+ buf->size)
+ {
+ buf->free_buffer (buf);
+ this->status = DEMUX_FINISHED;
+ break;
+ }
- if (video_trak->frames[i].keyframe)
- buf->decoder_flags |= BUF_FLAG_KEYFRAME;
- if (!remaining_sample_bytes)
- buf->decoder_flags |= BUF_FLAG_FRAME_END;
+ if (video_trak->frames[i].keyframe)
+ buf->decoder_flags |= BUF_FLAG_KEYFRAME;
+ if (!remaining_sample_bytes)
+ buf->decoder_flags |= BUF_FLAG_FRAME_END;
- this->video_fifo->put(this->video_fifo, buf);
+ this->video_fifo->put (this->video_fifo, buf);
+ }
+
}
+ else
+ {
+ /* load an audio sample and packetize it */
+ i = audio_trak->current_frame++;
- } else {
- /* load an audio sample and packetize it */
- i = audio_trak->current_frame++;
+ /* only go through with this procedure if audio_fifo exists */
+ if (!this->audio_fifo)
+ return this->status;
- /* only go through with this procedure if audio_fifo exists */
- if (!this->audio_fifo)
- return this->status;
+ remaining_sample_bytes = audio_trak->frames[i].size;
+ this->input->seek (this->input, audio_trak->frames[i].offset, SEEK_SET);
- remaining_sample_bytes = audio_trak->frames[i].size;
- this->input->seek(this->input, audio_trak->frames[i].offset,
- SEEK_SET);
+ debug_audio_demux
+ (" qt: sending off audio frame %d from offset 0x%llX, %d bytes, %lld
pts\n",
+ i, audio_trak->frames[i].offset, audio_trak->frames[i].size,
+ audio_trak->frames[i].pts);
- debug_audio_demux(" qt: sending off audio frame %d from offset 0x%llX, %d
bytes, %lld pts\n",
- i,
- audio_trak->frames[i].offset,
- audio_trak->frames[i].size,
- audio_trak->frames[i].pts);
+ first_buf = 1;
+ while (remaining_sample_bytes)
+ {
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
+ buf->type = audio_trak->properties.audio.codec_buftype;
+ buf->extra_info->input_pos =
+ audio_trak->frames[i].offset - this->data_start;
+ buf->extra_info->input_length = this->data_size;
+ /* The audio chunk is often broken up into multiple 8K buffers when
+ * it is sent to the audio decoder. Only attach the proper timestamp
+ * to the first buffer. This is for the linear PCM decoder which
+ * turns around and sends out audio buffers as soon as they are
+ * received. If 2 or more consecutive audio buffers are dispatched to
+ * the audio out unit, the engine will compensate with pops. */
+ if ((buf->type == BUF_AUDIO_LPCM_BE) ||
+ (buf->type == BUF_AUDIO_LPCM_LE))
+ {
+ if (first_buf)
+ {
+ buf->extra_info->input_time =
+ audio_trak->frames[i].pts / 90;
+ buf->pts = audio_trak->frames[i].pts;
+ first_buf = 0;
+ }
+ else
+ {
+ buf->extra_info->input_time = 0;
+ buf->pts = 0;
+ }
+ }
+ else
+ {
+ buf->extra_info->input_time = audio_trak->frames[i].pts / 90;
+ buf->pts = audio_trak->frames[i].pts;
+ }
- first_buf = 1;
- while (remaining_sample_bytes) {
- buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
- buf->type = audio_trak->properties.audio.codec_buftype;
- buf->extra_info->input_pos = audio_trak->frames[i].offset -
this->data_start;
- buf->extra_info->input_length = this->data_size;
- /* The audio chunk is often broken up into multiple 8K buffers when
- * it is sent to the audio decoder. Only attach the proper timestamp
- * to the first buffer. This is for the linear PCM decoder which
- * turns around and sends out audio buffers as soon as they are
- * received. If 2 or more consecutive audio buffers are dispatched to
- * the audio out unit, the engine will compensate with pops. */
- if ((buf->type == BUF_AUDIO_LPCM_BE) ||
- (buf->type == BUF_AUDIO_LPCM_LE)) {
- if (first_buf) {
- buf->extra_info->input_time = audio_trak->frames[i].pts / 90;
- buf->pts = audio_trak->frames[i].pts;
- first_buf = 0;
- } else {
- buf->extra_info->input_time = 0;
- buf->pts = 0;
- }
- } else {
- buf->extra_info->input_time = audio_trak->frames[i].pts / 90;
- buf->pts = audio_trak->frames[i].pts;
- }
+ if (remaining_sample_bytes > buf->max_size)
+ buf->size = buf->max_size;
+ else
+ buf->size = remaining_sample_bytes;
+ remaining_sample_bytes -= buf->size;
- if (remaining_sample_bytes > buf->max_size)
- buf->size = buf->max_size;
- else
- buf->size = remaining_sample_bytes;
- remaining_sample_bytes -= buf->size;
+ if (this->input->read (this->input, buf->content, buf->size) !=
+ buf->size)
+ {
+ buf->free_buffer (buf);
+ this->status = DEMUX_FINISHED;
+ break;
+ }
- if (this->input->read(this->input, buf->content, buf->size) !=
- buf->size) {
- buf->free_buffer(buf);
- this->status = DEMUX_FINISHED;
- break;
- }
+ /* Special case alert: If this is signed, 8-bit data, transform
+ * the data to unsigned. */
+ if ((audio_trak->properties.audio.bits == 8) &&
+ ((audio_trak->properties.audio.codec_fourcc == TWOS_FOURCC) ||
+ (audio_trak->properties.audio.codec_fourcc == SOWT_FOURCC)))
+ for (j = 0; j < buf->size; j++)
+ buf->content[j] += 0x80;
- /* Special case alert: If this is signed, 8-bit data, transform
- * the data to unsigned. */
- if ((audio_trak->properties.audio.bits == 8) &&
- ((audio_trak->properties.audio.codec_fourcc == TWOS_FOURCC) ||
- (audio_trak->properties.audio.codec_fourcc == SOWT_FOURCC)))
- for (j = 0; j < buf->size; j++)
- buf->content[j] += 0x80;
+ if (!remaining_sample_bytes)
+ {
+ buf->decoder_flags |= BUF_FLAG_FRAME_END;
+ }
- if (!remaining_sample_bytes) {
- buf->decoder_flags |= BUF_FLAG_FRAME_END;
- }
-
- this->audio_fifo->put(this->audio_fifo, buf);
+ this->audio_fifo->put (this->audio_fifo, buf);
+ }
}
- }
return this->status;
}
-static void demux_qt_send_headers(demux_plugin_t *this_gen) {
+static void
+demux_qt_send_headers (demux_plugin_t * this_gen)
+{
demux_qt_t *this = (demux_qt_t *) this_gen;
buf_element_t *buf;
@@ -2195,9 +2480,9 @@
/* for deciding data start and data size */
int64_t first_video_offset = -1;
- int64_t last_video_offset = -1;
+ int64_t last_video_offset = -1;
int64_t first_audio_offset = -1;
- int64_t last_audio_offset = -1;
+ int64_t last_audio_offset = -1;
this->video_fifo = this->stream->video_fifo;
this->audio_fifo = this->stream->audio_fifo;
@@ -2205,18 +2490,22 @@
this->status = DEMUX_OK;
/* figure out where the data begins and ends */
- if (this->qt->video_trak != -1) {
- video_trak = &this->qt->traks[this->qt->video_trak];
- first_video_offset = video_trak->frames[0].offset;
- last_video_offset = video_trak->frames[video_trak->frame_count - 1].size +
- video_trak->frames[video_trak->frame_count - 1].offset;
- }
- if (this->qt->audio_trak != -1) {
- audio_trak = &this->qt->traks[this->qt->audio_trak];
- first_audio_offset = audio_trak->frames[0].offset;
- last_audio_offset = audio_trak->frames[audio_trak->frame_count - 1].size +
- audio_trak->frames[audio_trak->frame_count - 1].offset;
- }
+ if (this->qt->video_trak != -1)
+ {
+ video_trak = &this->qt->traks[this->qt->video_trak];
+ first_video_offset = video_trak->frames[0].offset;
+ last_video_offset =
+ video_trak->frames[video_trak->frame_count - 1].size +
+ video_trak->frames[video_trak->frame_count - 1].offset;
+ }
+ if (this->qt->audio_trak != -1)
+ {
+ audio_trak = &this->qt->traks[this->qt->audio_trak];
+ first_audio_offset = audio_trak->frames[0].offset;
+ last_audio_offset =
+ audio_trak->frames[audio_trak->frame_count - 1].size +
+ audio_trak->frames[audio_trak->frame_count - 1].offset;
+ }
if (first_video_offset < first_audio_offset)
this->data_start = first_video_offset;
@@ -2229,177 +2518,188 @@
this->data_size = last_audio_offset - this->data_size;
/* sort out the A/V information */
- if (this->qt->video_trak != -1) {
+ if (this->qt->video_trak != -1)
+ {
- this->bih.biSize = sizeof(this->bih);
- this->bih.biWidth = video_trak->properties.video.width;
- this->bih.biHeight = video_trak->properties.video.height;
- this->bih.biBitCount = video_trak->properties.video.depth;
+ this->bih.biSize = sizeof (this->bih);
+ this->bih.biWidth = video_trak->properties.video.width;
+ this->bih.biHeight = video_trak->properties.video.height;
+ this->bih.biBitCount = video_trak->properties.video.depth;
- this->bih.biCompression = video_trak->properties.video.codec_fourcc;
- video_trak->properties.video.codec_buftype =
- fourcc_to_buf_video(this->bih.biCompression);
+ this->bih.biCompression = video_trak->properties.video.codec_fourcc;
+ video_trak->properties.video.codec_buftype =
+ fourcc_to_buf_video (this->bih.biCompression);
- /* hack: workaround a fourcc clash! 'mpg4' is used by MS and Sorenson
- * mpeg4 codecs (they are not compatible).
- */
- if( video_trak->properties.video.codec_buftype == BUF_VIDEO_MSMPEG4_V1 )
- video_trak->properties.video.codec_buftype = BUF_VIDEO_MPEG4;
+ /* hack: workaround a fourcc clash! 'mpg4' is used by MS and Sorenson
+ * mpeg4 codecs (they are not compatible).
+ */
+ if (video_trak->properties.video.codec_buftype == BUF_VIDEO_MSMPEG4_V1)
+ video_trak->properties.video.codec_buftype = BUF_VIDEO_MPEG4;
- if( !video_trak->properties.video.codec_buftype &&
- video_trak->properties.video.codec_fourcc )
- video_trak->properties.video.codec_buftype = BUF_VIDEO_UNKNOWN;
+ if (!video_trak->properties.video.codec_buftype &&
+ video_trak->properties.video.codec_fourcc)
+ video_trak->properties.video.codec_buftype = BUF_VIDEO_UNKNOWN;
- this->stream->stream_info[XINE_STREAM_INFO_HAS_VIDEO] = 1;
- this->stream->stream_info[XINE_STREAM_INFO_VIDEO_WIDTH] =
- this->bih.biWidth;
- this->stream->stream_info[XINE_STREAM_INFO_VIDEO_HEIGHT] =
- this->bih.biHeight;
- this->stream->stream_info[XINE_STREAM_INFO_VIDEO_FOURCC] =
- video_trak->properties.video.codec_fourcc;
+ this->stream->stream_info[XINE_STREAM_INFO_HAS_VIDEO] = 1;
+ this->stream->stream_info[XINE_STREAM_INFO_VIDEO_WIDTH] =
+ this->bih.biWidth;
+ this->stream->stream_info[XINE_STREAM_INFO_VIDEO_HEIGHT] =
+ this->bih.biHeight;
+ this->stream->stream_info[XINE_STREAM_INFO_VIDEO_FOURCC] =
+ video_trak->properties.video.codec_fourcc;
- } else {
+ }
+ else
+ {
- memset(&this->bih, 0, sizeof(this->bih));
- this->bih.biSize = sizeof(this->bih);
- this->stream->stream_info[XINE_STREAM_INFO_HAS_VIDEO] = 0;
- this->stream->stream_info[XINE_STREAM_INFO_VIDEO_WIDTH] = 0;
- this->stream->stream_info[XINE_STREAM_INFO_VIDEO_HEIGHT] = 0;
- this->stream->stream_info[XINE_STREAM_INFO_VIDEO_FOURCC] = 0;
+ memset (&this->bih, 0, sizeof (this->bih));
+ this->bih.biSize = sizeof (this->bih);
+ this->stream->stream_info[XINE_STREAM_INFO_HAS_VIDEO] = 0;
+ this->stream->stream_info[XINE_STREAM_INFO_VIDEO_WIDTH] = 0;
+ this->stream->stream_info[XINE_STREAM_INFO_VIDEO_HEIGHT] = 0;
+ this->stream->stream_info[XINE_STREAM_INFO_VIDEO_FOURCC] = 0;
- }
+ }
- if (this->qt->audio_trak != -1) {
+ if (this->qt->audio_trak != -1)
+ {
- audio_trak->properties.audio.codec_buftype =
- formattag_to_buf_audio(audio_trak->properties.audio.codec_fourcc);
+ audio_trak->properties.audio.codec_buftype =
+ formattag_to_buf_audio (audio_trak->properties.audio.codec_fourcc);
- if( !audio_trak->properties.audio.codec_buftype &&
- audio_trak->properties.audio.codec_fourcc )
- audio_trak->properties.audio.codec_buftype = BUF_AUDIO_UNKNOWN;
+ if (!audio_trak->properties.audio.codec_buftype &&
+ audio_trak->properties.audio.codec_fourcc)
+ audio_trak->properties.audio.codec_buftype = BUF_AUDIO_UNKNOWN;
- this->stream->stream_info[XINE_STREAM_INFO_HAS_AUDIO] = 1;
- this->stream->stream_info[XINE_STREAM_INFO_AUDIO_CHANNELS] =
- audio_trak->properties.audio.channels;
- this->stream->stream_info[XINE_STREAM_INFO_AUDIO_SAMPLERATE] =
- audio_trak->properties.audio.sample_rate;
- this->stream->stream_info[XINE_STREAM_INFO_AUDIO_BITS] =
- audio_trak->properties.audio.bits;
- this->stream->stream_info[XINE_STREAM_INFO_AUDIO_FOURCC] =
- audio_trak->properties.audio.codec_fourcc;
+ this->stream->stream_info[XINE_STREAM_INFO_HAS_AUDIO] = 1;
+ this->stream->stream_info[XINE_STREAM_INFO_AUDIO_CHANNELS] =
+ audio_trak->properties.audio.channels;
+ this->stream->stream_info[XINE_STREAM_INFO_AUDIO_SAMPLERATE] =
+ audio_trak->properties.audio.sample_rate;
+ this->stream->stream_info[XINE_STREAM_INFO_AUDIO_BITS] =
+ audio_trak->properties.audio.bits;
+ this->stream->stream_info[XINE_STREAM_INFO_AUDIO_FOURCC] =
+ audio_trak->properties.audio.codec_fourcc;
- } else {
+ }
+ else
+ {
- this->stream->stream_info[XINE_STREAM_INFO_HAS_AUDIO] = 0;
- this->stream->stream_info[XINE_STREAM_INFO_AUDIO_CHANNELS] = 0;
- this->stream->stream_info[XINE_STREAM_INFO_AUDIO_SAMPLERATE] = 0;
- this->stream->stream_info[XINE_STREAM_INFO_AUDIO_BITS] = 0;
- this->stream->stream_info[XINE_STREAM_INFO_AUDIO_FOURCC] = 0;
+ this->stream->stream_info[XINE_STREAM_INFO_HAS_AUDIO] = 0;
+ this->stream->stream_info[XINE_STREAM_INFO_AUDIO_CHANNELS] = 0;
+ this->stream->stream_info[XINE_STREAM_INFO_AUDIO_SAMPLERATE] = 0;
+ this->stream->stream_info[XINE_STREAM_INFO_AUDIO_BITS] = 0;
+ this->stream->stream_info[XINE_STREAM_INFO_AUDIO_FOURCC] = 0;
- }
+ }
/* copy over the meta information like artist and title */
if (this->qt->copyright)
this->stream->meta_info[XINE_META_INFO_ARTIST] =
- strdup(this->qt->copyright);
+ strdup (this->qt->copyright);
if (this->qt->description)
this->stream->meta_info[XINE_META_INFO_TITLE] =
- strdup(this->qt->description);
+ strdup (this->qt->description);
if (this->qt->comment)
this->stream->meta_info[XINE_META_INFO_COMMENT] =
- strdup(this->qt->comment);
+ strdup (this->qt->comment);
/* send start buffers */
- xine_demux_control_start(this->stream);
+ xine_demux_control_start (this->stream);
/* send init info to decoders */
- if (video_trak &&
- (video_trak->properties.video.codec_buftype)) {
- buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
- buf->decoder_flags = BUF_FLAG_HEADER;
- buf->decoder_info[0] = 0;
- /* initial video step; not necessary since each QT frame has its own
- * duration, but set it non-zero as a matter of custom */
- buf->decoder_info[1] = 3000;
- memcpy(buf->content, &this->bih, sizeof(this->bih));
- buf->size = sizeof(this->bih);
- buf->type = video_trak->properties.video.codec_buftype;
- this->video_fifo->put (this->video_fifo, buf);
-
- /* send header info to decoder. some mpeg4 streams need this */
- if( video_trak->decoder_config ) {
+ if (video_trak && (video_trak->properties.video.codec_buftype))
+ {
buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
+ buf->decoder_flags = BUF_FLAG_HEADER;
+ buf->decoder_info[0] = 0;
+ /* initial video step; not necessary since each QT frame has its own
+ * duration, but set it non-zero as a matter of custom */
+ buf->decoder_info[1] = 3000;
+ memcpy (buf->content, &this->bih, sizeof (this->bih));
+ buf->size = sizeof (this->bih);
buf->type = video_trak->properties.video.codec_buftype;
- buf->size = video_trak->decoder_config_len;
- buf->content = video_trak->decoder_config;
this->video_fifo->put (this->video_fifo, buf);
- }
- /* send off the palette, if there is one */
- if (video_trak->properties.video.palette_count) {
+ /* send header info to decoder. some mpeg4 streams need this */
+ if (video_trak->decoder_config)
+ {
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
+ buf->type = video_trak->properties.video.codec_buftype;
+ buf->size = video_trak->decoder_config_len;
+ buf->content = video_trak->decoder_config;
+ this->video_fifo->put (this->video_fifo, buf);
+ }
+
+ /* send off the palette, if there is one */
+ if (video_trak->properties.video.palette_count)
+ {
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
+ buf->decoder_flags = BUF_FLAG_SPECIAL;
+ buf->decoder_info[1] = BUF_SPECIAL_PALETTE;
+ buf->decoder_info[2] = video_trak->properties.video.palette_count;
+ buf->decoder_info_ptr[2] = &video_trak->properties.video.palette;
+ buf->size = 0;
+ buf->type = video_trak->properties.video.codec_buftype;
+ this->video_fifo->put (this->video_fifo, buf);
+ }
+
+ /* send stsd to the decoder */
buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
buf->decoder_flags = BUF_FLAG_SPECIAL;
- buf->decoder_info[1] = BUF_SPECIAL_PALETTE;
- buf->decoder_info[2] = video_trak->properties.video.palette_count;
- buf->decoder_info_ptr[2] = &video_trak->properties.video.palette;
+ buf->decoder_info[1] = BUF_SPECIAL_STSD_ATOM;
+ buf->decoder_info[2] = video_trak->stsd_size;
+ buf->decoder_info_ptr[2] = video_trak->stsd;
buf->size = 0;
buf->type = video_trak->properties.video.codec_buftype;
this->video_fifo->put (this->video_fifo, buf);
}
- /* send stsd to the decoder */
- buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
- buf->decoder_flags = BUF_FLAG_SPECIAL;
- buf->decoder_info[1] = BUF_SPECIAL_STSD_ATOM;
- buf->decoder_info[2] = video_trak->stsd_size;
- buf->decoder_info_ptr[2] = video_trak->stsd;
- buf->size = 0;
- buf->type = video_trak->properties.video.codec_buftype;
- this->video_fifo->put (this->video_fifo, buf);
- }
-
if ((this->qt->audio_trak != -1) &&
- (audio_trak->properties.audio.codec_buftype) &&
- this->audio_fifo) {
+ (audio_trak->properties.audio.codec_buftype) && this->audio_fifo)
+ {
- buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
- buf->type = audio_trak->properties.audio.codec_buftype;
- buf->decoder_flags = BUF_FLAG_HEADER;
- buf->decoder_info[0] = 0;
- buf->decoder_info[1] = audio_trak->properties.audio.sample_rate;
- buf->decoder_info[2] = audio_trak->properties.audio.bits;
- buf->decoder_info[3] = audio_trak->properties.audio.channels;
- buf->content = (void *)&audio_trak->properties.audio.wave;
- buf->size = sizeof(audio_trak->properties.audio.wave);
- this->audio_fifo->put (this->audio_fifo, buf);
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
+ buf->type = audio_trak->properties.audio.codec_buftype;
+ buf->decoder_flags = BUF_FLAG_HEADER;
+ buf->decoder_info[0] = 0;
+ buf->decoder_info[1] = audio_trak->properties.audio.sample_rate;
+ buf->decoder_info[2] = audio_trak->properties.audio.bits;
+ buf->decoder_info[3] = audio_trak->properties.audio.channels;
+ buf->content = (void *) &audio_trak->properties.audio.wave;
+ buf->size = sizeof (audio_trak->properties.audio.wave);
+ this->audio_fifo->put (this->audio_fifo, buf);
- if( audio_trak->decoder_config ) {
+ if (audio_trak->decoder_config)
+ {
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
+ buf->type = audio_trak->properties.audio.codec_buftype;
+ buf->size = 0;
+ buf->decoder_flags = BUF_FLAG_SPECIAL;
+ buf->decoder_info[1] = BUF_SPECIAL_DECODER_CONFIG;
+ buf->decoder_info[2] = audio_trak->decoder_config_len;
+ buf->decoder_info_ptr[2] = audio_trak->decoder_config;
+ this->audio_fifo->put (this->audio_fifo, buf);
+ }
+
+ /* send stsd to the decoder */
buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
+ buf->decoder_flags = BUF_FLAG_SPECIAL;
+ buf->decoder_info[1] = BUF_SPECIAL_STSD_ATOM;
+ buf->decoder_info[2] = audio_trak->stsd_size;
+ buf->decoder_info_ptr[2] = audio_trak->stsd;
+ buf->size = 0;
buf->type = audio_trak->properties.audio.codec_buftype;
- buf->size = 0;
- buf->decoder_flags = BUF_FLAG_SPECIAL;
- buf->decoder_info[1] = BUF_SPECIAL_DECODER_CONFIG;
- buf->decoder_info[2] = audio_trak->decoder_config_len;
- buf->decoder_info_ptr[2] = audio_trak->decoder_config;
this->audio_fifo->put (this->audio_fifo, buf);
+
}
-
- /* send stsd to the decoder */
- buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
- buf->decoder_flags = BUF_FLAG_SPECIAL;
- buf->decoder_info[1] = BUF_SPECIAL_STSD_ATOM;
- buf->decoder_info[2] = audio_trak->stsd_size;
- buf->decoder_info_ptr[2] = audio_trak->stsd;
- buf->size = 0;
- buf->type = audio_trak->properties.audio.codec_buftype;
- this->audio_fifo->put (this->audio_fifo, buf);
-
- }
}
/* support function that performs a binary seek on a trak; returns the
* demux status */
-static int binary_seek(qt_trak *trak, off_t start_pos, int start_time) {
+static int
+binary_seek (qt_trak * trak, off_t start_pos, int start_time)
+{
int best_index;
int left, middle, right;
@@ -2407,59 +2707,76 @@
/* perform a binary search on the trak, testing the offset
* boundaries first; offset request has precedent over time request */
- if (start_pos) {
- if (start_pos <= trak->frames[0].offset)
- best_index = 0;
- else if (start_pos >= trak->frames[trak->frame_count - 1].offset)
- return DEMUX_FINISHED;
- else {
- left = 0;
- right = trak->frame_count - 1;
- found = 0;
+ if (start_pos)
+ {
+ if (start_pos <= trak->frames[0].offset)
+ best_index = 0;
+ else if (start_pos >= trak->frames[trak->frame_count - 1].offset)
+ return DEMUX_FINISHED;
+ else
+ {
+ left = 0;
+ right = trak->frame_count - 1;
+ found = 0;
- while (!found) {
- middle = (left + right + 1) / 2;
- if ((start_pos >= trak->frames[middle].offset) &&
- (start_pos < trak->frames[middle + 1].offset)) {
- found = 1;
- } else if (start_pos < trak->frames[middle].offset) {
- right = middle - 1;
- } else {
- left = middle;
+ while (!found)
+ {
+ middle = (left + right + 1) / 2;
+ if ((start_pos >= trak->frames[middle].offset) &&
+ (start_pos < trak->frames[middle + 1].offset))
+ {
+ found = 1;
+ }
+ else if (start_pos < trak->frames[middle].offset)
+ {
+ right = middle - 1;
+ }
+ else
+ {
+ left = middle;
+ }
+ }
+
+ best_index = middle;
}
- }
-
- best_index = middle;
}
- } else {
- int64_t pts = 90000 * start_time;
+ else
+ {
+ int64_t pts = 90000 * start_time;
- if (pts <= trak->frames[0].pts)
- best_index = 0;
- else if (pts >= trak->frames[trak->frame_count - 1].pts)
- return DEMUX_FINISHED;
- else {
- left = 0;
- right = trak->frame_count - 1;
- do {
- middle = (left + right + 1) / 2;
- if (pts < trak->frames[middle].pts) {
- right = (middle - 1);
- } else {
- left = middle;
- }
- } while (left < right);
+ if (pts <= trak->frames[0].pts)
+ best_index = 0;
+ else if (pts >= trak->frames[trak->frame_count - 1].pts)
+ return DEMUX_FINISHED;
+ else
+ {
+ left = 0;
+ right = trak->frame_count - 1;
+ do
+ {
+ middle = (left + right + 1) / 2;
+ if (pts < trak->frames[middle].pts)
+ {
+ right = (middle - 1);
+ }
+ else
+ {
+ left = middle;
+ }
+ }
+ while (left < right);
- best_index = left;
+ best_index = left;
+ }
}
- }
trak->current_frame = best_index;
return DEMUX_OK;
}
-static int demux_qt_seek (demux_plugin_t *this_gen,
- off_t start_pos, int start_time) {
+static int
+demux_qt_seek (demux_plugin_t * this_gen, off_t start_pos, int start_time)
+{
demux_qt_t *this = (demux_qt_t *) this_gen;
qt_trak *video_trak = NULL;
@@ -2469,50 +2786,59 @@
/* short-circuit any attempts to seek in a non-seekable stream, including
* seeking in the forward direction; this may change later */
- if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0) {
- this->qt->seek_flag = 1;
- this->status = DEMUX_OK;
- return this->status;
- }
+ if ((this->input->get_capabilities (this->input) & INPUT_CAP_SEEKABLE) == 0)
+ {
+ this->qt->seek_flag = 1;
+ this->status = DEMUX_OK;
+ return this->status;
+ }
/* if there is a video trak, position it as close as possible to the
* requested position */
- if (this->qt->video_trak != -1) {
- video_trak = &this->qt->traks[this->qt->video_trak];
- this->status = binary_seek(video_trak, start_pos, start_time);
- if (this->status != DEMUX_OK)
- return this->status;
- }
+ if (this->qt->video_trak != -1)
+ {
+ video_trak = &this->qt->traks[this->qt->video_trak];
+ this->status = binary_seek (video_trak, start_pos, start_time);
+ if (this->status != DEMUX_OK)
+ return this->status;
+ }
- if (this->qt->audio_trak != -1) {
- audio_trak = &this->qt->traks[this->qt->audio_trak];
- this->status = binary_seek(audio_trak, start_pos, start_time);
- if (this->status != DEMUX_OK)
- return this->status;
- }
+ if (this->qt->audio_trak != -1)
+ {
+ audio_trak = &this->qt->traks[this->qt->audio_trak];
+ this->status = binary_seek (audio_trak, start_pos, start_time);
+ if (this->status != DEMUX_OK)
+ return this->status;
+ }
/* search back in the video trak for the nearest keyframe */
if (video_trak)
- while (video_trak->current_frame) {
- if (video_trak->frames[video_trak->current_frame].keyframe) {
- break;
+ while (video_trak->current_frame)
+ {
+ if (video_trak->frames[video_trak->current_frame].keyframe)
+ {
+ break;
+ }
+ video_trak->current_frame--;
}
- video_trak->current_frame--;
- }
/* not done yet; now that the nearest keyframe has been found, seek
* back to the first audio frame that has a pts less than or equal to
* that of the keyframe; do not go through with this process there is
* no video trak */
- if (audio_trak && video_trak) {
- keyframe_pts = video_trak->frames[video_trak->current_frame].pts;
- while (audio_trak->current_frame) {
- if (audio_trak->frames[audio_trak->current_frame].pts < keyframe_pts) {
- break;
- }
- audio_trak->current_frame--;
+ if (audio_trak && video_trak)
+ {
+ keyframe_pts = video_trak->frames[video_trak->current_frame].pts;
+ while (audio_trak->current_frame)
+ {
+ if (audio_trak->frames[audio_trak->current_frame].pts <
+ keyframe_pts)
+ {
+ break;
+ }
+ audio_trak->current_frame--;
+ }
}
- }
this->qt->seek_flag = 1;
this->status = DEMUX_OK;
@@ -2521,186 +2847,222 @@
* do only flush if already running (seeking).
* otherwise decoder_config is flushed too.
*/
- if(this->stream->demux_thread_running)
- xine_demux_flush_engine(this->stream);
+ if (this->stream->demux_thread_running)
+ xine_demux_flush_engine (this->stream);
return this->status;
}
-static void demux_qt_dispose (demux_plugin_t *this_gen) {
+static void
+demux_qt_dispose (demux_plugin_t * this_gen)
+{
demux_qt_t *this = (demux_qt_t *) this_gen;
- free_qt_info(this->qt);
- free(this);
+ free_qt_info (this->qt);
+ free (this);
}
-static int demux_qt_get_status (demux_plugin_t *this_gen) {
+static int
+demux_qt_get_status (demux_plugin_t * this_gen)
+{
demux_qt_t *this = (demux_qt_t *) this_gen;
return this->status;
}
-static int demux_qt_get_stream_length (demux_plugin_t *this_gen) {
+static int
+demux_qt_get_stream_length (demux_plugin_t * this_gen)
+{
demux_qt_t *this = (demux_qt_t *) this_gen;
- return (int)((int64_t) 1000 * this->qt->duration / this->qt->timescale);
+ return (int) ((int64_t) 1000 * this->qt->duration / this->qt->timescale);
}
-static uint32_t demux_qt_get_capabilities(demux_plugin_t *this_gen) {
+static uint32_t
+demux_qt_get_capabilities (demux_plugin_t * this_gen)
+{
return DEMUX_CAP_NOCAP;
}
-static int demux_qt_get_optional_data(demux_plugin_t *this_gen,
- void *data, int data_type) {
+static int
+demux_qt_get_optional_data (demux_plugin_t * this_gen,
+ void *data, int data_type)
+{
return DEMUX_OPTIONAL_UNSUPPORTED;
}
-static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t
*stream,
- input_plugin_t *input_gen) {
+static demux_plugin_t *
+open_plugin (demux_class_t * class_gen, xine_stream_t * stream,
+ input_plugin_t * input_gen)
+{
input_plugin_t *input = (input_plugin_t *) input_gen;
- demux_qt_t *this;
+ demux_qt_t *this;
xine_cfg_entry_t entry;
- if ((input->get_capabilities(input) & INPUT_CAP_BLOCK)) {
- return NULL;
- }
+ if ((input->get_capabilities (input) & INPUT_CAP_BLOCK))
+ {
+ return NULL;
+ }
- this = xine_xmalloc (sizeof (demux_qt_t));
+ this = xine_xmalloc (sizeof (demux_qt_t));
this->stream = stream;
- this->input = input;
+ this->input = input;
/* fetch bandwidth config */
- this->bandwidth = 0x7FFFFFFFFFFFFFFF; /* assume infinite bandwidth */
+ this->bandwidth = 0x7FFFFFFFFFFFFFFF; /* assume infinite bandwidth */
if (xine_config_lookup_entry (stream->xine, "input.mms_network_bandwidth",
- &entry)) {
- if ((entry.num_value >= 0) && (entry.num_value <= 11))
- this->bandwidth = bandwidths[entry.num_value];
- }
+ &entry))
+ {
+ if ((entry.num_value >= 0) && (entry.num_value <= 11))
+ this->bandwidth = bandwidths[entry.num_value];
+ }
- this->demux_plugin.send_headers = demux_qt_send_headers;
- this->demux_plugin.send_chunk = demux_qt_send_chunk;
- this->demux_plugin.seek = demux_qt_seek;
- this->demux_plugin.dispose = demux_qt_dispose;
- this->demux_plugin.get_status = demux_qt_get_status;
+ this->demux_plugin.send_headers = demux_qt_send_headers;
+ this->demux_plugin.send_chunk = demux_qt_send_chunk;
+ this->demux_plugin.seek = demux_qt_seek;
+ this->demux_plugin.dispose = demux_qt_dispose;
+ this->demux_plugin.get_status = demux_qt_get_status;
this->demux_plugin.get_stream_length = demux_qt_get_stream_length;
- this->demux_plugin.get_video_frame = NULL;
- this->demux_plugin.got_video_frame_cb= NULL;
- this->demux_plugin.get_capabilities = demux_qt_get_capabilities;
+ this->demux_plugin.get_video_frame = NULL;
+ this->demux_plugin.got_video_frame_cb = NULL;
+ this->demux_plugin.get_capabilities = demux_qt_get_capabilities;
this->demux_plugin.get_optional_data = demux_qt_get_optional_data;
- this->demux_plugin.demux_class = class_gen;
+ this->demux_plugin.demux_class = class_gen;
this->status = DEMUX_FINISHED;
- switch (stream->content_detection_method) {
+ switch (stream->content_detection_method)
+ {
- case METHOD_BY_CONTENT:
+ case METHOD_BY_CONTENT:
- if (!is_qt_file(this->input)) {
- free (this);
- return NULL;
- }
- if ((this->qt = create_qt_info()) == NULL) {
- free (this);
- return NULL;
- }
- if (open_qt_file(this->qt, this->input, this->bandwidth) != QT_OK) {
- free_qt_info (this->qt);
- free (this);
- return NULL;
- }
+ if (!is_qt_file (this->input))
+ {
+ free (this);
+ return NULL;
+ }
+ if ((this->qt = create_qt_info ()) == NULL)
+ {
+ free (this);
+ return NULL;
+ }
+ if (open_qt_file (this->qt, this->input, this->bandwidth) != QT_OK)
+ {
+ free_qt_info (this->qt);
+ free (this);
+ return NULL;
+ }
- break;
+ break;
- case METHOD_BY_EXTENSION: {
- char *ending, *mrl;
+ case METHOD_BY_EXTENSION:
+ {
+ char *ending, *mrl;
- mrl = input->get_mrl (input);
+ mrl = input->get_mrl (input);
- ending = strrchr(mrl, '.');
+ ending = strrchr (mrl, '.');
- if (!ending) {
- free (this);
- return NULL;
- }
+ if (!ending)
+ {
+ free (this);
+ return NULL;
+ }
- if (strncasecmp (ending, ".mov", 4) &&
- strncasecmp (ending, ".qt", 3) &&
- strncasecmp (ending, ".mp4", 4)) {
- free (this);
- return NULL;
- }
- }
+ if (strncasecmp (ending, ".mov", 4) &&
+ strncasecmp (ending, ".qt", 3) && strncasecmp (ending, ".mp4", 4))
+ {
+ free (this);
+ return NULL;
+ }
+ }
- /* we want to fall through here */
- case METHOD_EXPLICIT: {
+ /* we want to fall through here */
+ case METHOD_EXPLICIT:
+ {
- if (!is_qt_file(this->input)) {
+ if (!is_qt_file (this->input))
+ {
+ free (this);
+ return NULL;
+ }
+ if ((this->qt = create_qt_info ()) == NULL)
+ {
+ free (this);
+ return NULL;
+ }
+ if (open_qt_file (this->qt, this->input, this->bandwidth) != QT_OK)
+ {
+ free_qt_info (this->qt);
+ free (this);
+ return NULL;
+ }
+ }
+ break;
+
+ default:
free (this);
return NULL;
}
- if ((this->qt = create_qt_info()) == NULL) {
- free (this);
- return NULL;
- }
- if (open_qt_file(this->qt, this->input, this->bandwidth) != QT_OK) {
- free_qt_info (this->qt);
- free (this);
- return NULL;
- }
- }
- break;
- default:
- free (this);
- return NULL;
- }
-
strncpy (this->last_mrl, input->get_mrl (input), 1024);
return &this->demux_plugin;
}
-static char *get_description (demux_class_t *this_gen) {
+static char *
+get_description (demux_class_t * this_gen)
+{
return "Apple Quicktime (MOV) and MPEG-4 demux plugin";
}
-static char *get_identifier (demux_class_t *this_gen) {
+static char *
+get_identifier (demux_class_t * this_gen)
+{
return "MOV/MPEG-4";
}
-static char *get_extensions (demux_class_t *this_gen) {
+static char *
+get_extensions (demux_class_t * this_gen)
+{
return "mov qt mp4";
}
-static char *get_mimetypes (demux_class_t *this_gen) {
+static char *
+get_mimetypes (demux_class_t * this_gen)
+{
return "video/quicktime: mov,qt: Quicktime animation;"
- "video/x-quicktime: mov,qt: Quicktime animation;"
- "application/x-quicktimeplayer: qtl: Quicktime list";
+ "video/x-quicktime: mov,qt: Quicktime animation;"
+ "application/x-quicktimeplayer: qtl: Quicktime list";
}
-static void class_dispose (demux_class_t *this_gen) {
+static void
+class_dispose (demux_class_t * this_gen)
+{
demux_qt_class_t *this = (demux_qt_class_t *) this_gen;
free (this);
}
-static void *init_plugin (xine_t *xine, void *data) {
+static void *
+init_plugin (xine_t * xine, void *data)
+{
- demux_qt_class_t *this;
+ demux_qt_class_t *this;
- this = xine_xmalloc (sizeof (demux_qt_class_t));
+ this = xine_xmalloc (sizeof (demux_qt_class_t));
this->config = xine->config;
- this->xine = xine;
+ this->xine = xine;
- this->demux_class.open_plugin = open_plugin;
+ this->demux_class.open_plugin = open_plugin;
this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.get_identifier = get_identifier;
+ this->demux_class.get_mimetypes = get_mimetypes;
+ this->demux_class.get_extensions = get_extensions;
+ this->demux_class.dispose = class_dispose;
return this;
}
@@ -2711,6 +3073,7 @@
plugin_info_t xine_plugin_info[] = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 20, "quicktime", XINE_VERSION_CODE, NULL, init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
+ {PLUGIN_DEMUX, 20, "quicktime", XINE_VERSION_CODE, NULL, init_plugin}
+ ,
+ {PLUGIN_NONE, 0, "", 0, NULL, NULL}
};
Modified: Extractor/doc/demux_wc3movie.c
===================================================================
--- Extractor/doc/demux_wc3movie.c 2007-07-29 08:04:12 UTC (rev 5367)
+++ Extractor/doc/demux_wc3movie.c 2007-07-29 08:35:49 UTC (rev 5368)
@@ -70,89 +70,109 @@
#define WC3_HEADER_SIZE 16
#define PREAMBLE_SIZE 8
-typedef struct {
+typedef struct
+{
- demux_plugin_t demux_plugin;
+ demux_plugin_t demux_plugin;
- xine_stream_t *stream;
+ xine_stream_t *stream;
- config_values_t *config;
+ config_values_t *config;
- fifo_buffer_t *video_fifo;
- fifo_buffer_t *audio_fifo;
+ fifo_buffer_t *video_fifo;
+ fifo_buffer_t *audio_fifo;
- input_plugin_t *input;
+ input_plugin_t *input;
- int status;
+ int status;
- unsigned int fps;
- unsigned int frame_pts_inc;
- unsigned int video_width;
- unsigned int video_height;
+ unsigned int fps;
+ unsigned int frame_pts_inc;
+ unsigned int video_width;
+ unsigned int video_height;
- xine_waveformatex wave;
+ xine_waveformatex wave;
- palette_entry_t *palettes;
- unsigned int number_of_shots;
- unsigned int current_shot;
- off_t *shot_offsets;
- int seek_flag; /* this is set when a seek occurs */
+ palette_entry_t *palettes;
+ unsigned int number_of_shots;
+ unsigned int current_shot;
+ off_t *shot_offsets;
+ int seek_flag; /* this is set when a seek occurs */
- off_t data_start;
- off_t data_size;
+ off_t data_start;
+ off_t data_size;
- int64_t video_pts;
+ int64_t video_pts;
- char last_mrl[1024];
+ char last_mrl[1024];
} demux_mve_t;
-typedef struct {
+typedef struct
+{
- demux_class_t demux_class;
+ demux_class_t demux_class;
/* class-wide, global variables here */
- xine_t *xine;
- config_values_t *config;
+ xine_t *xine;
+ config_values_t *config;
} demux_mve_class_t;
/* bizarre palette lookup table */
const unsigned char wc3_pal_lookup[] = {
-0x00, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0E, 0x10, 0x12, 0x13, 0x15, 0x16,
-0x18, 0x19, 0x1A,
-0x1C, 0x1D, 0x1F, 0x20, 0x21, 0x23, 0x24, 0x25, 0x27, 0x28, 0x29, 0x2A, 0x2C,
-0x2D, 0x2E, 0x2F,
-0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D, 0x3F,
-0x40, 0x41, 0x42,
-0x43, 0x44, 0x45, 0x46, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F, 0x50,
-0x51, 0x52, 0x53,
-0x54, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60, 0x61,
-0x62, 0x63, 0x64,
-0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70, 0x71,
-0x72, 0x73, 0x74,
-0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7D, 0x7E, 0x7F, 0x80,
-0x81, 0x82, 0x83,
-0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8D, 0x8E, 0x8F,
-0x90, 0x91, 0x92,
-0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x99, 0x9A, 0x9B, 0x9C, 0x9D, 0x9E,
-0x9F, 0xA0, 0xA1,
-0xA2, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAA, 0xAB, 0xAC,
-0xAD, 0xAE, 0xAF,
-0xB0, 0xB1, 0xB2, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xB9, 0xBA,
-0xBB, 0xBC, 0xBD,
-0xBE, 0xBF, 0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC5, 0xC6, 0xC7, 0xC8,
-0xC9, 0xCA, 0xCB,
-0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5, 0xD5,
-0xD6, 0xD7, 0xD8,
-0xD9, 0xDA, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xDF, 0xE0, 0xE1, 0xE2, 0xE3,
-0xE4, 0xE4, 0xE5,
-0xE6, 0xE7, 0xE8, 0xE9, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xED, 0xEE, 0xEF, 0xF0,
-0xF1, 0xF1, 0xF2,
-0xF3, 0xF4, 0xF5, 0xF6, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFA, 0xFB, 0xFC, 0xFD,
-0xFD, 0xFD, 0xFD
+ 0x00, 0x03, 0x05, 0x07, 0x09, 0x0B, 0x0D, 0x0E, 0x10, 0x12, 0x13, 0x15,
+ 0x16,
+ 0x18, 0x19, 0x1A,
+ 0x1C, 0x1D, 0x1F, 0x20, 0x21, 0x23, 0x24, 0x25, 0x27, 0x28, 0x29, 0x2A,
+ 0x2C,
+ 0x2D, 0x2E, 0x2F,
+ 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x38, 0x39, 0x3A, 0x3B, 0x3C, 0x3D,
+ 0x3F,
+ 0x40, 0x41, 0x42,
+ 0x43, 0x44, 0x45, 0x46, 0x48, 0x49, 0x4A, 0x4B, 0x4C, 0x4D, 0x4E, 0x4F,
+ 0x50,
+ 0x51, 0x52, 0x53,
+ 0x54, 0x56, 0x57, 0x58, 0x59, 0x5A, 0x5B, 0x5C, 0x5D, 0x5E, 0x5F, 0x60,
+ 0x61,
+ 0x62, 0x63, 0x64,
+ 0x65, 0x66, 0x67, 0x68, 0x69, 0x6A, 0x6B, 0x6C, 0x6D, 0x6E, 0x6F, 0x70,
+ 0x71,
+ 0x72, 0x73, 0x74,
+ 0x75, 0x76, 0x77, 0x78, 0x79, 0x7A, 0x7B, 0x7C, 0x7D, 0x7D, 0x7E, 0x7F,
+ 0x80,
+ 0x81, 0x82, 0x83,
+ 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8A, 0x8B, 0x8C, 0x8D, 0x8D, 0x8E,
+ 0x8F,
+ 0x90, 0x91, 0x92,
+ 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x99, 0x9A, 0x9B, 0x9C, 0x9D,
+ 0x9E,
+ 0x9F, 0xA0, 0xA1,
+ 0xA2, 0xA2, 0xA3, 0xA4, 0xA5, 0xA6, 0xA7, 0xA8, 0xA9, 0xAA, 0xAA, 0xAB,
+ 0xAC,
+ 0xAD, 0xAE, 0xAF,
+ 0xB0, 0xB1, 0xB2, 0xB2, 0xB3, 0xB4, 0xB5, 0xB6, 0xB7, 0xB8, 0xB9, 0xB9,
+ 0xBA,
+ 0xBB, 0xBC, 0xBD,
+ 0xBE, 0xBF, 0xBF, 0xC0, 0xC1, 0xC2, 0xC3, 0xC4, 0xC5, 0xC5, 0xC6, 0xC7,
+ 0xC8,
+ 0xC9, 0xCA, 0xCB,
+ 0xCB, 0xCC, 0xCD, 0xCE, 0xCF, 0xD0, 0xD0, 0xD1, 0xD2, 0xD3, 0xD4, 0xD5,
+ 0xD5,
+ 0xD6, 0xD7, 0xD8,
+ 0xD9, 0xDA, 0xDA, 0xDB, 0xDC, 0xDD, 0xDE, 0xDF, 0xDF, 0xE0, 0xE1, 0xE2,
+ 0xE3,
+ 0xE4, 0xE4, 0xE5,
+ 0xE6, 0xE7, 0xE8, 0xE9, 0xE9, 0xEA, 0xEB, 0xEC, 0xED, 0xED, 0xEE, 0xEF,
+ 0xF0,
+ 0xF1, 0xF1, 0xF2,
+ 0xF3, 0xF4, 0xF5, 0xF6, 0xF6, 0xF7, 0xF8, 0xF9, 0xFA, 0xFA, 0xFB, 0xFC,
+ 0xFD,
+ 0xFD, 0xFD, 0xFD
};
-static int demux_mve_send_chunk(demux_plugin_t *this_gen) {
+static int
+demux_mve_send_chunk (demux_plugin_t * this_gen)
+{
demux_mve_t *this = (demux_mve_t *) this_gen;
buf_element_t *buf = NULL;
@@ -165,157 +185,186 @@
unsigned int palette_number;
/* compensate for the initial data in the file */
- current_file_pos = this->input->get_current_pos(this->input) -
+ current_file_pos = this->input->get_current_pos (this->input) -
this->data_start;
- if (this->input->read(this->input, preamble, PREAMBLE_SIZE) !=
- PREAMBLE_SIZE)
+ if (this->input->read (this->input, preamble, PREAMBLE_SIZE) !=
+ PREAMBLE_SIZE)
this->status = DEMUX_FINISHED;
- else {
- chunk_tag = BE_32(&preamble[0]);
- /* round up to the nearest even size */
- chunk_size = (BE_32(&preamble[4]) + 1) & (~1);
+ else
+ {
+ chunk_tag = BE_32 (&preamble[0]);
+ /* round up to the nearest even size */
+ chunk_size = (BE_32 (&preamble[4]) + 1) & (~1);
- if (chunk_tag == BRCH_TAG) {
+ if (chunk_tag == BRCH_TAG)
+ {
- /* empty chunk; do nothing */
+ /* empty chunk; do nothing */
- } else if (chunk_tag == SHOT_TAG) {
+ }
+ else if (chunk_tag == SHOT_TAG)
+ {
- if (this->seek_flag) {
+ if (this->seek_flag)
+ {
- /* reset pts */
- this->video_pts = 0;
- xine_demux_control_newpts(this->stream, 0, BUF_FLAG_SEEK);
- this->seek_flag = 0;
+ /* reset pts */
+ this->video_pts = 0;
+ xine_demux_control_newpts (this->stream, 0, BUF_FLAG_SEEK);
+ this->seek_flag = 0;
- } else {
+ }
+ else
+ {
- /* record the offset of the SHOT chunk */
- this->shot_offsets[this->current_shot] =
- this->input->get_current_pos(this->input) - PREAMBLE_SIZE;
- }
+ /* record the offset of the SHOT chunk */
+ this->shot_offsets[this->current_shot] =
+ this->input->get_current_pos (this->input) - PREAMBLE_SIZE;
+ }
- this->current_shot++;
+ this->current_shot++;
- /* this is the start of a new shot; send a new palette */
- if (this->input->read(this->input, preamble, 4) != 4) {
- this->status = DEMUX_FINISHED;
- return this->status;
- }
- palette_number = LE_32(&preamble[0]);
+ /* this is the start of a new shot; send a new palette */
+ if (this->input->read (this->input, preamble, 4) != 4)
+ {
+ this->status = DEMUX_FINISHED;
+ return this->status;
+ }
+ palette_number = LE_32 (&preamble[0]);
- if (palette_number >= this->number_of_shots) {
- xine_log(this->stream->xine, XINE_LOG_MSG,
- _("demux_wc3movie: SHOT chunk referenced invalid palette (%d >=
%d)\n"),
- palette_number, this->number_of_shots);
- this->status = DEMUX_FINISHED;
- return this->status;
- }
+ if (palette_number >= this->number_of_shots)
+ {
+ xine_log (this->stream->xine, XINE_LOG_MSG,
+ _
+ ("demux_wc3movie: SHOT chunk referenced invalid
palette (%d >= %d)\n"),
+ palette_number, this->number_of_shots);
+ this->status = DEMUX_FINISHED;
+ return this->status;
+ }
- buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
- buf->decoder_flags = BUF_FLAG_SPECIAL;
- buf->decoder_info[1] = BUF_SPECIAL_PALETTE;
- buf->decoder_info[2] = PALETTE_SIZE;
- buf->decoder_info_ptr[2] = &this->palettes[PALETTE_SIZE *
palette_number];
- buf->size = 0;
- buf->type = BUF_VIDEO_WC3;
- this->video_fifo->put (this->video_fifo, buf);
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
+ buf->decoder_flags = BUF_FLAG_SPECIAL;
+ buf->decoder_info[1] = BUF_SPECIAL_PALETTE;
+ buf->decoder_info[2] = PALETTE_SIZE;
+ buf->decoder_info_ptr[2] =
+ &this->palettes[PALETTE_SIZE * palette_number];
+ buf->size = 0;
+ buf->type = BUF_VIDEO_WC3;
+ this->video_fifo->put (this->video_fifo, buf);
- } else if (chunk_tag == AUDI_TAG) {
+ }
+ else if (chunk_tag == AUDI_TAG)
+ {
- if( this->audio_fifo ) {
+ if (this->audio_fifo)
+ {
- audio_pts = this->video_pts - WC3_PTS_INC;
+ audio_pts = this->video_pts - WC3_PTS_INC;
- while (chunk_size) {
- buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
- buf->type = BUF_AUDIO_LPCM_LE;
- buf->extra_info->input_pos = current_file_pos;
- buf->extra_info->input_length = this->data_size;
- buf->extra_info->input_time = audio_pts / 90;
- buf->pts = audio_pts;
+ while (chunk_size)
+ {
+ buf =
+ this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
+ buf->type = BUF_AUDIO_LPCM_LE;
+ buf->extra_info->input_pos = current_file_pos;
+ buf->extra_info->input_length = this->data_size;
+ buf->extra_info->input_time = audio_pts / 90;
+ buf->pts = audio_pts;
- if (chunk_size > buf->max_size)
- buf->size = buf->max_size;
- else
- buf->size = chunk_size;
- chunk_size -= buf->size;
+ if (chunk_size > buf->max_size)
+ buf->size = buf->max_size;
+ else
+ buf->size = chunk_size;
+ chunk_size -= buf->size;
- if (this->input->read(this->input, buf->content, buf->size) !=
- buf->size) {
- buf->free_buffer(buf);
- this->status = DEMUX_FINISHED;
- break;
- }
+ if (this->input->
+ read (this->input, buf->content,
+ buf->size) != buf->size)
+ {
+ buf->free_buffer (buf);
+ this->status = DEMUX_FINISHED;
+ break;
+ }
- if (!chunk_size)
- buf->decoder_flags |= BUF_FLAG_FRAME_END;
+ if (!chunk_size)
+ buf->decoder_flags |= BUF_FLAG_FRAME_END;
- this->audio_fifo->put (this->audio_fifo, buf);
+ this->audio_fifo->put (this->audio_fifo, buf);
+ }
+ }
+ else
+ {
+ this->input->seek (this->input, chunk_size, SEEK_CUR);
+ }
}
- }else{
- this->input->seek(this->input, chunk_size, SEEK_CUR);
- }
- } else if (chunk_tag == VGA_TAG) {
+ else if (chunk_tag == VGA_TAG)
+ {
- while (chunk_size) {
- buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
- buf->type = BUF_VIDEO_WC3;
- buf->extra_info->input_pos = current_file_pos;
- buf->extra_info->input_length = this->data_size;
- buf->extra_info->input_time = this->video_pts / 90;
- buf->pts = this->video_pts;
+ while (chunk_size)
+ {
+ buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
+ buf->type = BUF_VIDEO_WC3;
+ buf->extra_info->input_pos = current_file_pos;
+ buf->extra_info->input_length = this->data_size;
+ buf->extra_info->input_time = this->video_pts / 90;
+ buf->pts = this->video_pts;
- if (chunk_size > buf->max_size)
- buf->size = buf->max_size;
- else
- buf->size = chunk_size;
- chunk_size -= buf->size;
+ if (chunk_size > buf->max_size)
+ buf->size = buf->max_size;
+ else
+ buf->size = chunk_size;
+ chunk_size -= buf->size;
- if (this->input->read(this->input, buf->content, buf->size) !=
- buf->size) {
- buf->free_buffer(buf);
- this->status = DEMUX_FINISHED;
- break;
- }
+ if (this->input->read (this->input, buf->content, buf->size) !=
+ buf->size)
+ {
+ buf->free_buffer (buf);
+ this->status = DEMUX_FINISHED;
+ break;
+ }
- if (!chunk_size)
- buf->decoder_flags |= BUF_FLAG_FRAME_END;
+ if (!chunk_size)
+ buf->decoder_flags |= BUF_FLAG_FRAME_END;
- this->video_fifo->put (this->video_fifo, buf);
- }
- this->video_pts += WC3_PTS_INC;
+ this->video_fifo->put (this->video_fifo, buf);
+ }
+ this->video_pts += WC3_PTS_INC;
- } else if (chunk_tag == TEXT_TAG) {
+ }
+ else if (chunk_tag == TEXT_TAG)
+ {
- text_pts = this->video_pts - WC3_PTS_INC;
+ text_pts = this->video_pts - WC3_PTS_INC;
- /* unhandled thus far */
- this->input->seek(this->input, chunk_size, SEEK_CUR);
+ /* unhandled thus far */
+ this->input->seek (this->input, chunk_size, SEEK_CUR);
- } else {
+ }
+ else
+ {
- /* report an unknown chunk and skip it */
- printf (_("demux_wc3movie: encountered unknown chunk: %c%c%c%c\n"),
- (chunk_tag >> 24) & 0xFF,
- (chunk_tag >> 16) & 0xFF,
- (chunk_tag >> 8) & 0xFF,
- (chunk_tag >> 0) & 0xFF);
- this->input->seek(this->input, chunk_size, SEEK_CUR);
+ /* report an unknown chunk and skip it */
+ printf (_("demux_wc3movie: encountered unknown chunk: %c%c%c%c\n"),
+ (chunk_tag >> 24) & 0xFF,
+ (chunk_tag >> 16) & 0xFF,
+ (chunk_tag >> 8) & 0xFF, (chunk_tag >> 0) & 0xFF);
+ this->input->seek (this->input, chunk_size, SEEK_CUR);
+ }
}
- }
return this->status;
}
-static void demux_mve_send_headers(demux_plugin_t *this_gen) {
+static void
+demux_mve_send_headers (demux_plugin_t * this_gen)
+{
demux_mve_t *this = (demux_mve_t *) this_gen;
buf_element_t *buf;
- this->video_fifo = this->stream->video_fifo;
- this->audio_fifo = this->stream->audio_fifo;
+ this->video_fifo = this->stream->video_fifo;
+ this->audio_fifo = this->stream->audio_fifo;
this->status = DEMUX_OK;
@@ -325,7 +374,8 @@
* audio, but I'm too lazy to check if that is the case */
this->stream->stream_info[XINE_STREAM_INFO_HAS_AUDIO] = 1;
this->stream->stream_info[XINE_STREAM_INFO_VIDEO_WIDTH] = this->video_width;
- this->stream->stream_info[XINE_STREAM_INFO_VIDEO_HEIGHT] =
this->video_height;
+ this->stream->stream_info[XINE_STREAM_INFO_VIDEO_HEIGHT] =
+ this->video_height;
this->stream->stream_info[XINE_STREAM_INFO_AUDIO_CHANNELS] =
this->wave.nChannels;
this->stream->stream_info[XINE_STREAM_INFO_AUDIO_SAMPLERATE] =
@@ -334,13 +384,13 @@
this->wave.wBitsPerSample;
/* send start buffers */
- xine_demux_control_start(this->stream);
+ xine_demux_control_start (this->stream);
/* send init info to decoders */
buf = this->video_fifo->buffer_pool_alloc (this->video_fifo);
buf->decoder_flags = BUF_FLAG_HEADER;
buf->decoder_info[0] = 0;
- buf->decoder_info[1] = WC3_PTS_INC; /* initial video_step */
+ buf->decoder_info[1] = WC3_PTS_INC; /* initial video_step */
/* really be a rebel: No structure at all, just put the video width
* and height straight into the buffer, BE_16 format */
buf->content[0] = (this->video_width >> 8) & 0xFF;
@@ -351,29 +401,34 @@
buf->type = BUF_VIDEO_WC3;
this->video_fifo->put (this->video_fifo, buf);
- if (this->audio_fifo) {
- this->wave.wFormatTag = 1;
- this->wave.nChannels = 1;
- this->wave.nSamplesPerSec = 22050;
- this->wave.wBitsPerSample = 16;
- this->wave.nBlockAlign = (this->wave.wBitsPerSample / 8) *
this->wave.nChannels;
- this->wave.nAvgBytesPerSec = this->wave.nBlockAlign *
this->wave.nSamplesPerSec;
+ if (this->audio_fifo)
+ {
+ this->wave.wFormatTag = 1;
+ this->wave.nChannels = 1;
+ this->wave.nSamplesPerSec = 22050;
+ this->wave.wBitsPerSample = 16;
+ this->wave.nBlockAlign =
+ (this->wave.wBitsPerSample / 8) * this->wave.nChannels;
+ this->wave.nAvgBytesPerSec =
+ this->wave.nBlockAlign * this->wave.nSamplesPerSec;
- buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
- buf->type = BUF_AUDIO_LPCM_LE;
- buf->decoder_flags = BUF_FLAG_HEADER;
- buf->decoder_info[0] = 0;
- buf->decoder_info[1] = this->wave.nSamplesPerSec;
- buf->decoder_info[2] = this->wave.wBitsPerSample;
- buf->decoder_info[3] = this->wave.nChannels;
- buf->content = (void *)&this->wave;
- buf->size = sizeof(this->wave);
- this->audio_fifo->put (this->audio_fifo, buf);
- }
+ buf = this->audio_fifo->buffer_pool_alloc (this->audio_fifo);
+ buf->type = BUF_AUDIO_LPCM_LE;
+ buf->decoder_flags = BUF_FLAG_HEADER;
+ buf->decoder_info[0] = 0;
+ buf->decoder_info[1] = this->wave.nSamplesPerSec;
+ buf->decoder_info[2] = this->wave.wBitsPerSample;
+ buf->decoder_info[3] = this->wave.nChannels;
+ buf->content = (void *) &this->wave;
+ buf->size = sizeof (this->wave);
+ this->audio_fifo->put (this->audio_fifo, buf);
+ }
}
/* returns 1 if the MVE file was opened successfully, 0 otherwise */
-static int open_mve_file(demux_mve_t *this) {
+static int
+open_mve_file (demux_mve_t * this)
+{
unsigned char preamble[PREAMBLE_SIZE];
unsigned int chunk_tag;
@@ -390,166 +445,183 @@
this->video_width = WC3_USUAL_WIDTH;
this->video_height = WC3_USUAL_HEIGHT;
- if (this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) {
- this->input->seek(this->input, 0, SEEK_SET);
- if (this->input->read(this->input, header, WC3_HEADER_SIZE) !=
- WC3_HEADER_SIZE)
- return 0;
- } else {
- this->input->get_optional_data(this->input, preview,
- INPUT_OPTIONAL_DATA_PREVIEW);
+ if (this->input->get_capabilities (this->input) & INPUT_CAP_SEEKABLE)
+ {
+ this->input->seek (this->input, 0, SEEK_SET);
+ if (this->input->read (this->input, header, WC3_HEADER_SIZE) !=
+ WC3_HEADER_SIZE)
+ return 0;
+ }
+ else
+ {
+ this->input->get_optional_data (this->input, preview,
+ INPUT_OPTIONAL_DATA_PREVIEW);
- /* copy over the header bytes for processing */
- memcpy(header, preview, WC3_HEADER_SIZE);
- }
+ /* copy over the header bytes for processing */
+ memcpy (header, preview, WC3_HEADER_SIZE);
+ }
- if ((BE_32(&header[0]) != FORM_TAG) ||
- (BE_32(&header[8]) != MOVE_TAG) ||
- (BE_32(&header[12]) != PC_TAG))
+ if ((BE_32 (&header[0]) != FORM_TAG) ||
+ (BE_32 (&header[8]) != MOVE_TAG) || (BE_32 (&header[12]) != PC_TAG))
return 0;
/* file is qualified; if the input was not seekable, skip over the header
* bytes in the stream */
- if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0) {
- this->input->seek(this->input, WC3_HEADER_SIZE, SEEK_SET);
- }
+ if ((this->input->get_capabilities (this->input) & INPUT_CAP_SEEKABLE) == 0)
+ {
+ this->input->seek (this->input, WC3_HEADER_SIZE, SEEK_SET);
+ }
/* load the number of palettes, the only interesting piece of information
* in the _PC_ chunk; take it for granted that it will always appear at
* position 0x1C */
- this->input->seek(this->input, 0x1C, SEEK_SET);
- if (this->input->read(this->input, preamble, 4) != 4)
+ this->input->seek (this->input, 0x1C, SEEK_SET);
+ if (this->input->read (this->input, preamble, 4) != 4)
return 0;
- this->number_of_shots = LE_32(&preamble[0]);
+ this->number_of_shots = LE_32 (&preamble[0]);
/* allocate space for the shot offset index and set offsets to 0 */
- this->shot_offsets = xine_xmalloc(this->number_of_shots * sizeof(off_t));
+ this->shot_offsets = xine_xmalloc (this->number_of_shots * sizeof (off_t));
this->current_shot = 0;
for (i = 0; i < this->number_of_shots; i++)
this->shot_offsets[i] = 0;
/* skip the SOND chunk */
- this->input->seek(this->input, 12, SEEK_CUR);
+ this->input->seek (this->input, 12, SEEK_CUR);
/* load the palette chunks */
- this->palettes = xine_xmalloc(this->number_of_shots * PALETTE_SIZE *
- sizeof(palette_entry_t));
- for (i = 0; i < this->number_of_shots; i++) {
- /* make sure there was a valid palette chunk preamble */
- if (this->input->read(this->input, preamble, PREAMBLE_SIZE) !=
- PREAMBLE_SIZE) {
- free (this->palettes);
- free (this->shot_offsets);
- return 0;
- }
+ this->palettes = xine_xmalloc (this->number_of_shots * PALETTE_SIZE *
+ sizeof (palette_entry_t));
+ for (i = 0; i < this->number_of_shots; i++)
+ {
+ /* make sure there was a valid palette chunk preamble */
+ if (this->input->read (this->input, preamble, PREAMBLE_SIZE) !=
+ PREAMBLE_SIZE)
+ {
+ free (this->palettes);
+ free (this->shot_offsets);
+ return 0;
+ }
- if ((BE_32(&preamble[0]) != PALT_TAG) ||
- (BE_32(&preamble[4]) != PALETTE_CHUNK_SIZE)) {
- xine_log(this->stream->xine, XINE_LOG_MSG,
- _("demux_wc3movie: There was a problem while loading palette
chunks\n"));
- free (this->palettes);
- free (this->shot_offsets);
- return 0;
- }
+ if ((BE_32 (&preamble[0]) != PALT_TAG) ||
+ (BE_32 (&preamble[4]) != PALETTE_CHUNK_SIZE))
+ {
+ xine_log (this->stream->xine, XINE_LOG_MSG,
+ _
+ ("demux_wc3movie: There was a problem while loading
palette chunks\n"));
+ free (this->palettes);
+ free (this->shot_offsets);
+ return 0;
+ }
- /* load the palette chunk */
- if (this->input->read(this->input, disk_palette, PALETTE_CHUNK_SIZE) !=
- PALETTE_CHUNK_SIZE) {
- free (this->palettes);
- free (this->shot_offsets);
- return 0;
- }
+ /* load the palette chunk */
+ if (this->input->read (this->input, disk_palette, PALETTE_CHUNK_SIZE) !=
+ PALETTE_CHUNK_SIZE)
+ {
+ free (this->palettes);
+ free (this->shot_offsets);
+ return 0;
+ }
- /* convert and store the palette */
- for (j = 0; j < PALETTE_SIZE; j++) {
- r = disk_palette[j * 3 + 0];
- g = disk_palette[j * 3 + 1];
- b = disk_palette[j * 3 + 2];
- /* rotate each component left by 2 */
- temp = r << 2; r = (temp & 0xff) | (temp >> 8);
- r = wc3_pal_lookup[r];
- temp = g << 2; g = (temp & 0xff) | (temp >> 8);
- g = wc3_pal_lookup[g];
- temp = b << 2; b = (temp & 0xff) | (temp >> 8);
- b = wc3_pal_lookup[b];
- this->palettes[i * 256 + j].r = r;
- this->palettes[i * 256 + j].g = g;
- this->palettes[i * 256 + j].b = b;
+ /* convert and store the palette */
+ for (j = 0; j < PALETTE_SIZE; j++)
+ {
+ r = disk_palette[j * 3 + 0];
+ g = disk_palette[j * 3 + 1];
+ b = disk_palette[j * 3 + 2];
+ /* rotate each component left by 2 */
+ temp = r << 2;
+ r = (temp & 0xff) | (temp >> 8);
+ r = wc3_pal_lookup[r];
+ temp = g << 2;
+ g = (temp & 0xff) | (temp >> 8);
+ g = wc3_pal_lookup[g];
+ temp = b << 2;
+ b = (temp & 0xff) | (temp >> 8);
+ b = wc3_pal_lookup[b];
+ this->palettes[i * 256 + j].r = r;
+ this->palettes[i * 256 + j].g = g;
+ this->palettes[i * 256 + j].b = b;
+ }
}
- }
/* after the palette chunks comes any number of chunks such as INDX,
* BNAM, SIZE and perhaps others; traverse chunks until first BRCH
* chunk is found */
chunk_tag = 0;
title = NULL;
- while (chunk_tag != BRCH_TAG) {
+ while (chunk_tag != BRCH_TAG)
+ {
- if (this->input->read(this->input, preamble, PREAMBLE_SIZE) !=
- PREAMBLE_SIZE) {
- free (title);
- free (this->palettes);
- free (this->shot_offsets);
- return 0;
- }
-
- chunk_tag = BE_32(&preamble[0]);
- /* round up to the nearest even size */
- chunk_size = (BE_32(&preamble[4]) + 1) & (~1);
-
- switch (chunk_tag) {
-
- case BRCH_TAG:
- /* time to start demuxing */
- break;
-
- case BNAM_TAG:
- /* load the name into the stream attributes */
- title = realloc (title, chunk_size);
- if (this->input->read(this->input, title, chunk_size) != chunk_size) {
+ if (this->input->read (this->input, preamble, PREAMBLE_SIZE) !=
+ PREAMBLE_SIZE)
+ {
free (title);
free (this->palettes);
free (this->shot_offsets);
return 0;
}
- break;
- case SIZE_TAG:
- /* override the default width and height */
- /* reuse the preamble bytes */
- if (this->input->read(this->input, preamble, PREAMBLE_SIZE) !=
- PREAMBLE_SIZE) {
- free (title);
- free (this->palettes);
- free (this->shot_offsets);
- return 0;
+ chunk_tag = BE_32 (&preamble[0]);
+ /* round up to the nearest even size */
+ chunk_size = (BE_32 (&preamble[4]) + 1) & (~1);
+
+ switch (chunk_tag)
+ {
+
+ case BRCH_TAG:
+ /* time to start demuxing */
+ break;
+
+ case BNAM_TAG:
+ /* load the name into the stream attributes */
+ title = realloc (title, chunk_size);
+ if (this->input->read (this->input, title, chunk_size) !=
+ chunk_size)
+ {
+ free (title);
+ free (this->palettes);
+ free (this->shot_offsets);
+ return 0;
+ }
+ break;
+
+ case SIZE_TAG:
+ /* override the default width and height */
+ /* reuse the preamble bytes */
+ if (this->input->read (this->input, preamble, PREAMBLE_SIZE) !=
+ PREAMBLE_SIZE)
+ {
+ free (title);
+ free (this->palettes);
+ free (this->shot_offsets);
+ return 0;
+ }
+ this->video_width = BE_32 (&preamble[0]);
+ this->video_height = BE_32 (&preamble[4]);
+ break;
+
+ case INDX_TAG:
+ /* index is not useful for this demuxer */
+ this->input->seek (this->input, chunk_size, SEEK_CUR);
+ break;
+
+ default:
+ /* report an unknown chunk and skip it */
+ printf (_("demux_wc3movie: encountered unknown chunk: %c%c%c%c\n"),
+ (chunk_tag >> 24) & 0xFF,
+ (chunk_tag >> 16) & 0xFF,
+ (chunk_tag >> 8) & 0xFF, (chunk_tag >> 0) & 0xFF);
+ this->input->seek (this->input, chunk_size, SEEK_CUR);
+ break;
}
- this->video_width = BE_32(&preamble[0]);
- this->video_height = BE_32(&preamble[4]);
- break;
- case INDX_TAG:
- /* index is not useful for this demuxer */
- this->input->seek(this->input, chunk_size, SEEK_CUR);
- break;
-
- default:
- /* report an unknown chunk and skip it */
- printf (_("demux_wc3movie: encountered unknown chunk: %c%c%c%c\n"),
- (chunk_tag >> 24) & 0xFF,
- (chunk_tag >> 16) & 0xFF,
- (chunk_tag >> 8) & 0xFF,
- (chunk_tag >> 0) & 0xFF);
- this->input->seek(this->input, chunk_size, SEEK_CUR);
- break;
}
- }
-
/* note the data start offset */
- this->data_start = this->input->get_current_pos(this->input);
+ this->data_start = this->input->get_current_pos (this->input);
- this->data_size = this->input->get_length(this->input) - this->data_start;
+ this->data_size = this->input->get_length (this->input) - this->data_start;
this->video_pts = 0;
@@ -558,8 +630,9 @@
return 1;
}
-static int demux_mve_seek (demux_plugin_t *this_gen,
- off_t start_pos, int start_time) {
+static int
+demux_mve_seek (demux_plugin_t * this_gen, off_t start_pos, int start_time)
+{
/*
* MVE files are comprised of a series of SHOTs. A SHOT begins when the
@@ -581,82 +654,97 @@
int new_shot = -1;
this->status = DEMUX_OK;
- xine_demux_flush_engine(this->stream);
+ xine_demux_flush_engine (this->stream);
this->seek_flag = 1;
/* if input is non-seekable, do not proceed with the rest of this
* seek function */
- if ((this->input->get_capabilities(this->input) & INPUT_CAP_SEEKABLE) == 0)
+ if ((this->input->get_capabilities (this->input) & INPUT_CAP_SEEKABLE) == 0)
return this->status;
/* make sure the first shot has been recorded */
- if (this->shot_offsets[0] == 0) {
+ if (this->shot_offsets[0] == 0)
+ {
- while (1) {
+ while (1)
+ {
- if (this->input->read(this->input, preamble, PREAMBLE_SIZE) !=
- PREAMBLE_SIZE) {
- this->status = DEMUX_FINISHED;
- return this->status;
- }
+ if (this->input->read (this->input, preamble, PREAMBLE_SIZE) !=
+ PREAMBLE_SIZE)
+ {
+ this->status = DEMUX_FINISHED;
+ return this->status;
+ }
- chunk_tag = BE_32(&preamble[0]);
- /* round up to the nearest even size */
- chunk_size = (BE_32(&preamble[4]) + 1) & (~1);
+ chunk_tag = BE_32 (&preamble[0]);
+ /* round up to the nearest even size */
+ chunk_size = (BE_32 (&preamble[4]) + 1) & (~1);
- if (chunk_tag == SHOT_TAG) {
- this->shot_offsets[0] =
- this->input->get_current_pos(this->input) - PREAMBLE_SIZE;
- /* skip the four SHOT data bytes (palette index) */
- this->input->seek(this->input, 4, SEEK_CUR);
- break; /* get out of the infinite while loop */
- } else {
- this->input->seek(this->input, chunk_size, SEEK_CUR);
- }
+ if (chunk_tag == SHOT_TAG)
+ {
+ this->shot_offsets[0] =
+ this->input->get_current_pos (this->input) - PREAMBLE_SIZE;
+ /* skip the four SHOT data bytes (palette index) */
+ this->input->seek (this->input, 4, SEEK_CUR);
+ break; /* get out of the infinite while loop */
+ }
+ else
+ {
+ this->input->seek (this->input, chunk_size, SEEK_CUR);
+ }
+ }
}
- }
/* compensate for data at start of file */
start_pos += this->data_start;
- for (i = 0; i < this->number_of_shots - 1; i++) {
+ for (i = 0; i < this->number_of_shots - 1; i++)
+ {
- /* if the next shot offset has not been recorded, traverse through the
- * file until it is found */
- if (this->shot_offsets[i + 1] == 0) {
+ /* if the next shot offset has not been recorded, traverse through the
+ * file until it is found */
+ if (this->shot_offsets[i + 1] == 0)
+ {
- while (1) {
+ while (1)
+ {
- if (this->input->read(this->input, preamble, PREAMBLE_SIZE) !=
- PREAMBLE_SIZE) {
- this->status = DEMUX_FINISHED;
- return this->status;
- }
+ if (this->input->read (this->input, preamble, PREAMBLE_SIZE) !=
+ PREAMBLE_SIZE)
+ {
+ this->status = DEMUX_FINISHED;
+ return this->status;
+ }
- chunk_tag = BE_32(&preamble[0]);
- /* round up to the nearest even size */
- chunk_size = (BE_32(&preamble[4]) + 1) & (~1);
+ chunk_tag = BE_32 (&preamble[0]);
+ /* round up to the nearest even size */
+ chunk_size = (BE_32 (&preamble[4]) + 1) & (~1);
- if (chunk_tag == SHOT_TAG) {
- this->shot_offsets[i + 1] =
- this->input->get_current_pos(this->input) - PREAMBLE_SIZE;
- /* skip the four SHOT data bytes (palette index) */
- this->input->seek(this->input, 4, SEEK_CUR);
- break; /* get out of the infinite while loop */
- } else {
- this->input->seek(this->input, chunk_size, SEEK_CUR);
+ if (chunk_tag == SHOT_TAG)
+ {
+ this->shot_offsets[i + 1] =
+ this->input->get_current_pos (this->input) -
+ PREAMBLE_SIZE;
+ /* skip the four SHOT data bytes (palette index) */
+ this->input->seek (this->input, 4, SEEK_CUR);
+ break; /* get out of the infinite while loop */
+ }
+ else
+ {
+ this->input->seek (this->input, chunk_size, SEEK_CUR);
+ }
+ }
}
- }
- }
- /* check if the seek-to offset falls in between this shot offset and
- * the next one */
- if ((start_pos >= this->shot_offsets[i]) &&
- (start_pos < this->shot_offsets[i + 1])) {
+ /* check if the seek-to offset falls in between this shot offset and
+ * the next one */
+ if ((start_pos >= this->shot_offsets[i]) &&
+ (start_pos < this->shot_offsets[i + 1]))
+ {
- new_shot = i;
- break;
+ new_shot = i;
+ break;
+ }
}
- }
/* if no new shot was found in the loop, the new shot must be the last
* shot */
@@ -665,148 +753,178 @@
this->current_shot = new_shot;
/* reposition the stream at new shot */
- this->input->seek(this->input, this->shot_offsets[new_shot], SEEK_SET);
+ this->input->seek (this->input, this->shot_offsets[new_shot], SEEK_SET);
return this->status;
}
-static void demux_mve_dispose (demux_plugin_t *this_gen) {
+static void
+demux_mve_dispose (demux_plugin_t * this_gen)
+{
demux_mve_t *this = (demux_mve_t *) this_gen;
- free(this->palettes);
- free(this->shot_offsets);
- free(this);
+ free (this->palettes);
+ free (this->shot_offsets);
+ free (this);
}
-static int demux_mve_get_status (demux_plugin_t *this_gen) {
+static int
+demux_mve_get_status (demux_plugin_t * this_gen)
+{
demux_mve_t *this = (demux_mve_t *) this_gen;
return this->status;
}
-static int demux_mve_get_stream_length (demux_plugin_t *this_gen) {
+static int
+demux_mve_get_stream_length (demux_plugin_t * this_gen)
+{
return 0;
}
-static uint32_t demux_mve_get_capabilities(demux_plugin_t *this_gen) {
+static uint32_t
+demux_mve_get_capabilities (demux_plugin_t * this_gen)
+{
return DEMUX_CAP_NOCAP;
}
-static int demux_mve_get_optional_data(demux_plugin_t *this_gen,
- void *data, int data_type) {
+static int
+demux_mve_get_optional_data (demux_plugin_t * this_gen,
+ void *data, int data_type)
+{
return DEMUX_OPTIONAL_UNSUPPORTED;
}
-static demux_plugin_t *open_plugin (demux_class_t *class_gen, xine_stream_t
*stream,
- input_plugin_t *input_gen) {
+static demux_plugin_t *
+open_plugin (demux_class_t * class_gen, xine_stream_t * stream,
+ input_plugin_t * input_gen)
+{
input_plugin_t *input = (input_plugin_t *) input_gen;
- demux_mve_t *this;
+ demux_mve_t *this;
- this = xine_xmalloc (sizeof (demux_mve_t));
+ this = xine_xmalloc (sizeof (demux_mve_t));
this->stream = stream;
- this->input = input;
+ this->input = input;
- this->demux_plugin.send_headers = demux_mve_send_headers;
- this->demux_plugin.send_chunk = demux_mve_send_chunk;
- this->demux_plugin.seek = demux_mve_seek;
- this->demux_plugin.dispose = demux_mve_dispose;
- this->demux_plugin.get_status = demux_mve_get_status;
+ this->demux_plugin.send_headers = demux_mve_send_headers;
+ this->demux_plugin.send_chunk = demux_mve_send_chunk;
+ this->demux_plugin.seek = demux_mve_seek;
+ this->demux_plugin.dispose = demux_mve_dispose;
+ this->demux_plugin.get_status = demux_mve_get_status;
this->demux_plugin.get_stream_length = demux_mve_get_stream_length;
- this->demux_plugin.get_video_frame = NULL;
- this->demux_plugin.got_video_frame_cb= NULL;
- this->demux_plugin.get_capabilities = demux_mve_get_capabilities;
+ this->demux_plugin.get_video_frame = NULL;
+ this->demux_plugin.got_video_frame_cb = NULL;
+ this->demux_plugin.get_capabilities = demux_mve_get_capabilities;
this->demux_plugin.get_optional_data = demux_mve_get_optional_data;
- this->demux_plugin.demux_class = class_gen;
+ this->demux_plugin.demux_class = class_gen;
this->status = DEMUX_FINISHED;
- switch (stream->content_detection_method) {
+ switch (stream->content_detection_method)
+ {
- case METHOD_BY_CONTENT:
- case METHOD_EXPLICIT:
+ case METHOD_BY_CONTENT:
+ case METHOD_EXPLICIT:
- if (!open_mve_file(this)) {
- free (this);
- return NULL;
- }
+ if (!open_mve_file (this))
+ {
+ free (this);
+ return NULL;
+ }
- break;
+ break;
- case METHOD_BY_EXTENSION: {
- char *ending, *mrl;
+ case METHOD_BY_EXTENSION:
+ {
+ char *ending, *mrl;
- mrl = input->get_mrl (input);
+ mrl = input->get_mrl (input);
- ending = strrchr(mrl, '.');
+ ending = strrchr (mrl, '.');
- if (!ending) {
- free (this);
- return NULL;
- }
+ if (!ending)
+ {
+ free (this);
+ return NULL;
+ }
- if (strncasecmp (ending, ".mve", 4)) {
- free (this);
- return NULL;
- }
+ if (strncasecmp (ending, ".mve", 4))
+ {
+ free (this);
+ return NULL;
+ }
- if (!open_mve_file(this)) {
+ if (!open_mve_file (this))
+ {
+ free (this);
+ return NULL;
+ }
+
+ }
+
+ break;
+
+ default:
free (this);
return NULL;
}
- }
-
- break;
-
- default:
- free (this);
- return NULL;
- }
-
strncpy (this->last_mrl, input->get_mrl (input), 1024);
return &this->demux_plugin;
}
-static char *get_description (demux_class_t *this_gen) {
+static char *
+get_description (demux_class_t * this_gen)
+{
return "Wing Commander III Movie (MVE) demux plugin";
}
-static char *get_identifier (demux_class_t *this_gen) {
+static char *
+get_identifier (demux_class_t * this_gen)
+{
return "WC3 Movie";
}
-static char *get_extensions (demux_class_t *this_gen) {
+static char *
+get_extensions (demux_class_t * this_gen)
+{
return "mve";
}
-static char *get_mimetypes (demux_class_t *this_gen) {
+static char *
+get_mimetypes (demux_class_t * this_gen)
+{
return NULL;
}
-static void class_dispose (demux_class_t *this_gen) {
+static void
+class_dispose (demux_class_t * this_gen)
+{
demux_mve_class_t *this = (demux_mve_class_t *) this_gen;
free (this);
}
-void *demux_wc3movie_init_plugin (xine_t *xine, void *data) {
+void *
+demux_wc3movie_init_plugin (xine_t * xine, void *data)
+{
- demux_mve_class_t *this;
+ demux_mve_class_t *this;
- this = xine_xmalloc (sizeof (demux_mve_class_t));
+ this = xine_xmalloc (sizeof (demux_mve_class_t));
this->config = xine->config;
- this->xine = xine;
+ this->xine = xine;
- this->demux_class.open_plugin = open_plugin;
+ this->demux_class.open_plugin = open_plugin;
this->demux_class.get_description = get_description;
- this->demux_class.get_identifier = get_identifier;
- this->demux_class.get_mimetypes = get_mimetypes;
- this->demux_class.get_extensions = get_extensions;
- this->demux_class.dispose = class_dispose;
+ this->demux_class.get_identifier = get_identifier;
+ this->demux_class.get_mimetypes = get_mimetypes;
+ this->demux_class.get_extensions = get_extensions;
+ this->demux_class.dispose = class_dispose;
return this;
}
@@ -818,7 +936,9 @@
#if 0
plugin_info_t xine_plugin_info[] = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_DEMUX, 20, "wc3movie", XINE_VERSION_CODE, NULL,
demux_wc3movie_init_plugin },
- { PLUGIN_NONE, 0, "", 0, NULL, NULL }
+ {PLUGIN_DEMUX, 20, "wc3movie", XINE_VERSION_CODE, NULL,
+ demux_wc3movie_init_plugin}
+ ,
+ {PLUGIN_NONE, 0, "", 0, NULL, NULL}
};
#endif
Modified: Extractor/doc/flacfile.c
===================================================================
--- Extractor/doc/flacfile.c 2007-07-29 08:04:12 UTC (rev 5367)
+++ Extractor/doc/flacfile.c 2007-07-29 08:35:49 UTC (rev 5368)
@@ -26,332 +26,423 @@
#include <stdio.h>
#include <string.h>
-const char *get_mime_type(const char *filename) {
- magic_t magic_flags;
- const char *mime_type;
+const char *
+get_mime_type (const char *filename)
+{
+ magic_t magic_flags;
+ const char *mime_type;
- magic_flags = magic_open(MAGIC_MIME);
- if (magic_flags == NULL) {
- perror("flacfile: magic_open");
- exit(1);
- }
+ magic_flags = magic_open (MAGIC_MIME);
+ if (magic_flags == NULL)
+ {
+ perror ("flacfile: magic_open");
+ exit (1);
+ }
- if (magic_load(magic_flags,NULL) != 0) {
- perror("flacfile: magic_load");
- exit(1);
- }
+ if (magic_load (magic_flags, NULL) != 0)
+ {
+ perror ("flacfile: magic_load");
+ exit (1);
+ }
- mime_type = magic_file(magic_flags,filename);
- if (mime_type == NULL) {
- fprintf(stderr,"flacfile: Unable to determine MIME type
automatically; please specify one.\n");
- }
+ mime_type = magic_file (magic_flags, filename);
+ if (mime_type == NULL)
+ {
+ fprintf (stderr,
+ "flacfile: Unable to determine MIME type automatically; please
specify one.\n");
+ }
- return mime_type;
+ return mime_type;
}
-FLAC__StreamMetadata *new_block(const char *filename, const char *description,
const char *mime) {
- // block size is mime length + description length + file length + 2
- size_t desc_len = strlen(description);
- size_t mime_len = strlen(mime);
- struct stat s;
- int f = open(filename,O_RDONLY);
- static FLAC__StreamMetadata meta;
- char *block;
- int pos = 0;
+FLAC__StreamMetadata *
+new_block (const char *filename, const char *description, const char *mime)
+{
+ // block size is mime length + description length + file length + 2
+ size_t desc_len = strlen (description);
+ size_t mime_len = strlen (mime);
+ struct stat s;
+ int f = open (filename, O_RDONLY);
+ static FLAC__StreamMetadata meta;
+ char *block;
+ int pos = 0;
- if (desc_len > 255 || mime_len > 255) {
- fprintf(stderr,"flacfile: Description and MIME type must both
be shorter than 256 characters.\n");
- exit(1);
- }
+ if (desc_len > 255 || mime_len > 255)
+ {
+ fprintf (stderr,
+ "flacfile: Description and MIME type must both be shorter than
256 characters.\n");
+ exit (1);
+ }
- if (f == -1) {
- perror("flacfile: open(FLAC file)");
- exit(1);
- }
+ if (f == -1)
+ {
+ perror ("flacfile: open(FLAC file)");
+ exit (1);
+ }
- if (fstat(f,&s) != 0) {
- perror("flacfile: fstat(FLAC file)");
- exit(1);
- }
+ if (fstat (f, &s) != 0)
+ {
+ perror ("flacfile: fstat(FLAC file)");
+ exit (1);
+ }
- block = malloc(desc_len + mime_len + s.st_size + 2);
- if (block == NULL) {
- perror("flacfile: malloc");
- exit(1);
- }
+ block = malloc (desc_len + mime_len + s.st_size + 2);
+ if (block == NULL)
+ {
+ perror ("flacfile: malloc");
+ exit (1);
+ }
- block[pos++] = (char) desc_len;
- strcpy(&block[pos],description);
- pos += desc_len;
+ block[pos++] = (char) desc_len;
+ strcpy (&block[pos], description);
+ pos += desc_len;
- block[pos++] = (char) mime_len;
- strcpy(&block[pos],mime);
- pos += mime_len;
+ block[pos++] = (char) mime_len;
+ strcpy (&block[pos], mime);
+ pos += mime_len;
- if (read(f,&block[pos],s.st_size) != s.st_size) {
- perror("flacfile: read(FLAC file)");
- exit(1);
- }
+ if (read (f, &block[pos], s.st_size) != s.st_size)
+ {
+ perror ("flacfile: read(FLAC file)");
+ exit (1);
+ }
- meta.is_last = false;
- meta.length = desc_len + mime_len + s.st_size + 6;
- meta.type = FLAC__METADATA_TYPE_APPLICATION;
- memcpy(meta.data.application.id,"ATCH",4);
- meta.data.application.data = block;
+ meta.is_last = false;
+ meta.length = desc_len + mime_len + s.st_size + 6;
+ meta.type = FLAC__METADATA_TYPE_APPLICATION;
+ memcpy (meta.data.application.id, "ATCH", 4);
+ meta.data.application.data = block;
- return &meta;
+ return &meta;
}
-int add(FLAC__Metadata_SimpleIterator *iter, char *description, char *attach,
const char *mime_type) {
- if (mime_type == NULL)
- mime_type = get_mime_type(attach);
+int
+add (FLAC__Metadata_SimpleIterator * iter, char *description, char *attach,
+ const char *mime_type)
+{
+ if (mime_type == NULL)
+ mime_type = get_mime_type (attach);
- if
(FLAC__metadata_simple_iterator_insert_block_after(iter,new_block(attach,description,mime_type),true)
!= true) {
- perror("flacfile:
FLAC__metadata_simple_iterator_insert_block_after");
- exit(1);
- }
+ if (FLAC__metadata_simple_iterator_insert_block_after
+ (iter, new_block (attach, description, mime_type), true) != true)
+ {
+ perror ("flacfile: FLAC__metadata_simple_iterator_insert_block_after");
+ exit (1);
+ }
- return 0;
+ return 0;
}
-int list(FLAC__Metadata_SimpleIterator *iter) {
- while (1) {
- int pos;
- FLAC__StreamMetadata *meta;
- if (FLAC__metadata_simple_iterator_get_block_type(iter) !=
FLAC__METADATA_TYPE_APPLICATION) {
- if (FLAC__metadata_simple_iterator_next(iter) == false)
- return 0;
- continue;
- }
+int
+list (FLAC__Metadata_SimpleIterator * iter)
+{
+ while (1)
+ {
+ int pos;
+ FLAC__StreamMetadata *meta;
+ if (FLAC__metadata_simple_iterator_get_block_type (iter) !=
+ FLAC__METADATA_TYPE_APPLICATION)
+ {
+ if (FLAC__metadata_simple_iterator_next (iter) == false)
+ return 0;
+ continue;
+ }
- meta = FLAC__metadata_simple_iterator_get_block(iter);
- if (memcmp(meta->data.application.id,"ATCH",4) != 0) {
- if (FLAC__metadata_simple_iterator_next(iter) == false)
- return 0;
- FLAC__metadata_object_delete(meta);
- continue;
- }
+ meta = FLAC__metadata_simple_iterator_get_block (iter);
+ if (memcmp (meta->data.application.id, "ATCH", 4) != 0)
+ {
+ if (FLAC__metadata_simple_iterator_next (iter) == false)
+ return 0;
+ FLAC__metadata_object_delete (meta);
+ continue;
+ }
- /* this is one of our blocks */
- write(1,"Description: '",14);
- if (meta->length < 1 || meta->length <
meta->data.application.data[0] + 1) {
- write(1,"(invalid block)\n",16);
- if (FLAC__metadata_simple_iterator_next(iter) == false)
- return 0;
- FLAC__metadata_object_delete(meta);
- continue;
- }
-
write(1,&meta->data.application.data[1],meta->data.application.data[0]);
- write(1,"', ",3);
- pos = meta->data.application.data[0] + 1;
+ /* this is one of our blocks */
+ write (1, "Description: '", 14);
+ if (meta->length < 1
+ || meta->length < meta->data.application.data[0] + 1)
+ {
+ write (1, "(invalid block)\n", 16);
+ if (FLAC__metadata_simple_iterator_next (iter) == false)
+ return 0;
+ FLAC__metadata_object_delete (meta);
+ continue;
+ }
+ write (1, &meta->data.application.data[1],
+ meta->data.application.data[0]);
+ write (1, "', ", 3);
+ pos = meta->data.application.data[0] + 1;
- write(1,"MIME: '",7);
- if (meta->length < pos + 1 || meta->length <
meta->data.application.data[pos] + pos + 1) {
- write(1,"(invalid block)\n",16);
- if (FLAC__metadata_simple_iterator_next(iter) == false)
- return 0;
- FLAC__metadata_object_delete(meta);
- continue;
- }
-
write(1,&meta->data.application.data[pos+1],meta->data.application.data[pos]);
- write(1,"', ",3);
- pos += meta->data.application.data[pos] + 1;
-
- printf("Length: %d\n",meta->length - pos - 4);
+ write (1, "MIME: '", 7);
+ if (meta->length < pos + 1
+ || meta->length < meta->data.application.data[pos] + pos + 1)
+ {
+ write (1, "(invalid block)\n", 16);
+ if (FLAC__metadata_simple_iterator_next (iter) == false)
+ return 0;
+ FLAC__metadata_object_delete (meta);
+ continue;
+ }
+ write (1, &meta->data.application.data[pos + 1],
+ meta->data.application.data[pos]);
+ write (1, "', ", 3);
+ pos += meta->data.application.data[pos] + 1;
- FLAC__metadata_object_delete(meta);
+ printf ("Length: %d\n", meta->length - pos - 4);
- if (FLAC__metadata_simple_iterator_next(iter) == false)
- return 0;
- }
+ FLAC__metadata_object_delete (meta);
+
+ if (FLAC__metadata_simple_iterator_next (iter) == false)
+ return 0;
+ }
}
-int extract(FLAC__Metadata_SimpleIterator *iter, char *description, char
*filename, char *mime) {
- while (1) {
- int pos;
- int o;
- FLAC__StreamMetadata *meta;
+int
+extract (FLAC__Metadata_SimpleIterator * iter, char *description,
+ char *filename, char *mime)
+{
+ while (1)
+ {
+ int pos;
+ int o;
+ FLAC__StreamMetadata *meta;
- if (FLAC__metadata_simple_iterator_get_block_type(iter) !=
FLAC__METADATA_TYPE_APPLICATION) {
- if (FLAC__metadata_simple_iterator_next(iter) == false)
- return 1;
- continue;
- }
+ if (FLAC__metadata_simple_iterator_get_block_type (iter) !=
+ FLAC__METADATA_TYPE_APPLICATION)
+ {
+ if (FLAC__metadata_simple_iterator_next (iter) == false)
+ return 1;
+ continue;
+ }
- meta = FLAC__metadata_simple_iterator_get_block(iter);
- if (memcmp(meta->data.application.id,"ATCH",4) != 0) {
- if (FLAC__metadata_simple_iterator_next(iter) == false)
- return 1;
- FLAC__metadata_object_delete(meta);
- continue;
- }
+ meta = FLAC__metadata_simple_iterator_get_block (iter);
+ if (memcmp (meta->data.application.id, "ATCH", 4) != 0)
+ {
+ if (FLAC__metadata_simple_iterator_next (iter) == false)
+ return 1;
+ FLAC__metadata_object_delete (meta);
+ continue;
+ }
- /* this is one of our blocks */
- if (meta->length < 1 || meta->length <
meta->data.application.data[0] + 1) {
- if (FLAC__metadata_simple_iterator_next(iter) == false)
- return 1;
- FLAC__metadata_object_delete(meta);
- continue;
- }
- if (meta->data.application.data[0] != strlen(description) ||
memcmp(&meta->data.application.data[1],description,meta->data.application.data[0])
!= 0) {
- if (FLAC__metadata_simple_iterator_next(iter) == false)
- return 1;
- FLAC__metadata_object_delete(meta);
- continue;
- }
- pos = meta->data.application.data[0] + 1;
+ /* this is one of our blocks */
+ if (meta->length < 1
+ || meta->length < meta->data.application.data[0] + 1)
+ {
+ if (FLAC__metadata_simple_iterator_next (iter) == false)
+ return 1;
+ FLAC__metadata_object_delete (meta);
+ continue;
+ }
+ if (meta->data.application.data[0] != strlen (description)
+ || memcmp (&meta->data.application.data[1], description,
+ meta->data.application.data[0]) != 0)
+ {
+ if (FLAC__metadata_simple_iterator_next (iter) == false)
+ return 1;
+ FLAC__metadata_object_delete (meta);
+ continue;
+ }
+ pos = meta->data.application.data[0] + 1;
- if (meta->length < pos + 1 || meta->length <
meta->data.application.data[pos] + pos + 1) {
- if (FLAC__metadata_simple_iterator_next(iter) == false)
- return 1;
- FLAC__metadata_object_delete(meta);
- continue;
- }
+ if (meta->length < pos + 1
+ || meta->length < meta->data.application.data[pos] + pos + 1)
+ {
+ if (FLAC__metadata_simple_iterator_next (iter) == false)
+ return 1;
+ FLAC__metadata_object_delete (meta);
+ continue;
+ }
- if (mime != NULL &&
- (meta->data.application.data[pos] !=
strlen(mime) ||
memcmp(&meta->data.application.data[pos+1],mime,meta->data.application.data[pos])
!= 0)) {
- if (FLAC__metadata_simple_iterator_next(iter) == false)
- return 1;
- FLAC__metadata_object_delete(meta);
- continue;
- }
- pos += meta->data.application.data[pos] + 1;
+ if (mime != NULL &&
+ (meta->data.application.data[pos] != strlen (mime)
+ || memcmp (&meta->data.application.data[pos + 1], mime,
+ meta->data.application.data[pos]) != 0))
+ {
+ if (FLAC__metadata_simple_iterator_next (iter) == false)
+ return 1;
+ FLAC__metadata_object_delete (meta);
+ continue;
+ }
+ pos += meta->data.application.data[pos] + 1;
- o = open(filename,O_WRONLY|O_CREAT,0644);
- if (o == -1) {
- perror("flacfile: open");
- exit(1);
- }
+ o = open (filename, O_WRONLY | O_CREAT, 0644);
+ if (o == -1)
+ {
+ perror ("flacfile: open");
+ exit (1);
+ }
- if (write(o,&meta->data.application.data[pos],meta->length -
pos - 4));
-
- FLAC__metadata_object_delete(meta);
+ if (write
+ (o, &meta->data.application.data[pos], meta->length - pos - 4));
- return 0;
- }
+ FLAC__metadata_object_delete (meta);
+
+ return 0;
+ }
}
-int my_remove(FLAC__Metadata_SimpleIterator *iter, char *description, char
*mime) {
- while (1) {
- int pos;
- FLAC__StreamMetadata *meta;
+int
+my_remove (FLAC__Metadata_SimpleIterator * iter, char *description,
+ char *mime)
+{
+ while (1)
+ {
+ int pos;
+ FLAC__StreamMetadata *meta;
- if (FLAC__metadata_simple_iterator_get_block_type(iter) !=
FLAC__METADATA_TYPE_APPLICATION) {
- if (FLAC__metadata_simple_iterator_next(iter) == false)
- return 1;
- continue;
- }
+ if (FLAC__metadata_simple_iterator_get_block_type (iter) !=
+ FLAC__METADATA_TYPE_APPLICATION)
+ {
+ if (FLAC__metadata_simple_iterator_next (iter) == false)
+ return 1;
+ continue;
+ }
- meta = FLAC__metadata_simple_iterator_get_block(iter);
- if (memcmp(meta->data.application.id,"ATCH",4) != 0) {
- if (FLAC__metadata_simple_iterator_next(iter) == false)
- return 1;
- FLAC__metadata_object_delete(meta);
- continue;
- }
+ meta = FLAC__metadata_simple_iterator_get_block (iter);
+ if (memcmp (meta->data.application.id, "ATCH", 4) != 0)
+ {
+ if (FLAC__metadata_simple_iterator_next (iter) == false)
+ return 1;
+ FLAC__metadata_object_delete (meta);
+ continue;
+ }
- /* this is one of our blocks */
- if (meta->length < 1 || meta->length <
meta->data.application.data[0] + 1) {
- if (FLAC__metadata_simple_iterator_next(iter) == false)
- return 1;
- FLAC__metadata_object_delete(meta);
- continue;
- }
- if (meta->data.application.data[0] != strlen(description) ||
memcmp(&meta->data.application.data[1],description,meta->data.application.data[0])
!= 0) {
- if (FLAC__metadata_simple_iterator_next(iter) == false)
- return 1;
- FLAC__metadata_object_delete(meta);
- continue;
- }
- pos = meta->data.application.data[0] + 1;
+ /* this is one of our blocks */
+ if (meta->length < 1
+ || meta->length < meta->data.application.data[0] + 1)
+ {
+ if (FLAC__metadata_simple_iterator_next (iter) == false)
+ return 1;
+ FLAC__metadata_object_delete (meta);
+ continue;
+ }
+ if (meta->data.application.data[0] != strlen (description)
+ || memcmp (&meta->data.application.data[1], description,
+ meta->data.application.data[0]) != 0)
+ {
+ if (FLAC__metadata_simple_iterator_next (iter) == false)
+ return 1;
+ FLAC__metadata_object_delete (meta);
+ continue;
+ }
+ pos = meta->data.application.data[0] + 1;
- if (meta->length < pos + 1 || meta->length <
meta->data.application.data[pos] + pos + 1) {
- if (FLAC__metadata_simple_iterator_next(iter) == false)
- return 1;
- FLAC__metadata_object_delete(meta);
- continue;
- }
+ if (meta->length < pos + 1
+ || meta->length < meta->data.application.data[pos] + pos + 1)
+ {
+ if (FLAC__metadata_simple_iterator_next (iter) == false)
+ return 1;
+ FLAC__metadata_object_delete (meta);
+ continue;
+ }
- if (mime != NULL &&
- (meta->data.application.data[pos] !=
strlen(mime) ||
memcmp(&meta->data.application.data[pos+1],mime,meta->data.application.data[pos])
!= 0)) {
- if (FLAC__metadata_simple_iterator_next(iter) == false)
- return 1;
- FLAC__metadata_object_delete(meta);
- continue;
- }
- pos += meta->data.application.data[pos] + 1;
+ if (mime != NULL &&
+ (meta->data.application.data[pos] != strlen (mime)
+ || memcmp (&meta->data.application.data[pos + 1], mime,
+ meta->data.application.data[pos]) != 0))
+ {
+ if (FLAC__metadata_simple_iterator_next (iter) == false)
+ return 1;
+ FLAC__metadata_object_delete (meta);
+ continue;
+ }
+ pos += meta->data.application.data[pos] + 1;
- if (FLAC__metadata_simple_iterator_delete_block(iter,false) !=
true) {
- perror("flacfile:
FLAC__metadata_simple_iterator_delete_block");
- exit(1);
- }
+ if (FLAC__metadata_simple_iterator_delete_block (iter, false) != true)
+ {
+ perror ("flacfile: FLAC__metadata_simple_iterator_delete_block");
+ exit (1);
+ }
- FLAC__metadata_object_delete(meta);
+ FLAC__metadata_object_delete (meta);
- return 0;
- }
+ return 0;
+ }
}
-void usage() {
- fprintf(stderr,"flacfile v" VERSION "\n\n");
- fprintf(stderr,"Usage: flacfile add <FLAC filename> <description>
<filename to attach> [<MIME type>]\n");
- fprintf(stderr," flacfile list <FLAC filename>\n");
- fprintf(stderr," flacfile extract <FLAC filename> <description>
<filename to save as> [<MIME type>]\n");
- fprintf(stderr," flacfile remove <FLAC filename> <description>
[<MIME type>]\n");
- exit(1);
+void
+usage ()
+{
+ fprintf (stderr, "flacfile v" VERSION "\n\n");
+ fprintf (stderr,
+ "Usage: flacfile add <FLAC filename> <description> <filename to
attach> [<MIME type>]\n");
+ fprintf (stderr, " flacfile list <FLAC filename>\n");
+ fprintf (stderr,
+ " flacfile extract <FLAC filename> <description> <filename to
save as> [<MIME type>]\n");
+ fprintf (stderr,
+ " flacfile remove <FLAC filename> <description> [<MIME
type>]\n");
+ exit (1);
}
-int main(int argc, char *argv[]) {
- FLAC__Metadata_SimpleIterator *iter;
+int
+main (int argc, char *argv[])
+{
+ FLAC__Metadata_SimpleIterator *iter;
- if (argc < 3 || argc > 6)
- usage();
+ if (argc < 3 || argc > 6)
+ usage ();
- iter = FLAC__metadata_simple_iterator_new();
- if (iter == NULL) {
- perror("flacfile: FLAC__metadata_simple_iterator_new");
- exit(1);
- }
+ iter = FLAC__metadata_simple_iterator_new ();
+ if (iter == NULL)
+ {
+ perror ("flacfile: FLAC__metadata_simple_iterator_new");
+ exit (1);
+ }
- if (FLAC__metadata_simple_iterator_init(iter,argv[2],false,false) !=
true) {
- perror("flacfile: FLAC__metadata_simple_iterator_init");
- exit(1);
- }
+ if (FLAC__metadata_simple_iterator_init (iter, argv[2], false, false) !=
+ true)
+ {
+ perror ("flacfile: FLAC__metadata_simple_iterator_init");
+ exit (1);
+ }
- if (strcmp(argv[1],"add") == 0) {
- if (argc < 5)
- usage();
- if (strcmp(argv[2],argv[4]) == 0) {
- fprintf(stderr,"flacfile: You didn't really want to
attach a file to itself.\n");
- exit(1);
- }
- return add(iter,argv[3],argv[4],argc == 6 ? argv[5] : NULL);
- } else if (strcmp(argv[1],"list") == 0) {
- if (argc > 3)
- usage();
- return list(iter);
- } else if (strcmp(argv[1],"extract") == 0) {
- int r;
- if (argc < 5)
- usage();
- if (strcmp(argv[2],argv[4]) == 0) {
- fprintf(stderr,"flacfile: You didn't really want to
extract a file onto itself.\n");
- exit(1);
- }
- r = extract(iter,argv[3],argv[4],argc == 6 ? argv[5] : NULL);
- if (r != 0)
- fprintf(stderr,"flacfile: requested block not found\n");
- return r;
- } else if (strcmp(argv[1],"remove") == 0) {
- int r;
- if (argc < 4)
- usage();
- r = my_remove(iter,argv[3],argc == 5 ? argv[4] : NULL);
- if (r != 0)
- fprintf(stderr,"flacfile: requested block not found\n");
- return r;
- } else {
- usage();
- return 1;
- }
+ if (strcmp (argv[1], "add") == 0)
+ {
+ if (argc < 5)
+ usage ();
+ if (strcmp (argv[2], argv[4]) == 0)
+ {
+ fprintf (stderr,
+ "flacfile: You didn't really want to attach a file to
itself.\n");
+ exit (1);
+ }
+ return add (iter, argv[3], argv[4], argc == 6 ? argv[5] : NULL);
+ }
+ else if (strcmp (argv[1], "list") == 0)
+ {
+ if (argc > 3)
+ usage ();
+ return list (iter);
+ }
+ else if (strcmp (argv[1], "extract") == 0)
+ {
+ int r;
+ if (argc < 5)
+ usage ();
+ if (strcmp (argv[2], argv[4]) == 0)
+ {
+ fprintf (stderr,
+ "flacfile: You didn't really want to extract a file onto
itself.\n");
+ exit (1);
+ }
+ r = extract (iter, argv[3], argv[4], argc == 6 ? argv[5] : NULL);
+ if (r != 0)
+ fprintf (stderr, "flacfile: requested block not found\n");
+ return r;
+ }
+ else if (strcmp (argv[1], "remove") == 0)
+ {
+ int r;
+ if (argc < 4)
+ usage ();
+ r = my_remove (iter, argv[3], argc == 5 ? argv[4] : NULL);
+ if (r != 0)
+ fprintf (stderr, "flacfile: requested block not found\n");
+ return r;
+ }
+ else
+ {
+ usage ();
+ return 1;
+ }
}
Modified: Extractor/doc/lj/addkeyword.c
===================================================================
--- Extractor/doc/lj/addkeyword.c 2007-07-29 08:04:12 UTC (rev 5367)
+++ Extractor/doc/lj/addkeyword.c 2007-07-29 08:35:49 UTC (rev 5368)
@@ -1,14 +1,13 @@
static void addKeyword
- (struct EXTRACTOR_Keywords ** list,
- char * keyword,
- EXTRACTOR_KeywordType type)
+ (struct EXTRACTOR_Keywords **list,
+ char *keyword, EXTRACTOR_KeywordType type)
{
- EXTRACTOR_KeywordList * next;
- next = malloc(sizeof(EXTRACTOR_KeywordList));
+ EXTRACTOR_KeywordList *next;
+ next = malloc (sizeof (EXTRACTOR_KeywordList));
next->next = *list;
next->keyword = keyword;
next->keywordType = type;
*list = next;
}
-Caption: The plugins return the meta-data using a simple linked-list.
+Caption:The plugins return the meta - data using a simple linked - list.
Modified: Extractor/doc/lj/minimal.c
===================================================================
--- Extractor/doc/lj/minimal.c 2007-07-29 08:04:12 UTC (rev 5367)
+++ Extractor/doc/lj/minimal.c 2007-07-29 08:35:49 UTC (rev 5368)
@@ -1,12 +1,14 @@
#include <extractor.h>
-int main(int argc, char * argv[]) {
- EXTRACTOR_ExtractorList * plugins;
- EXTRACTOR_KeywordList * md_list;
- plugins = EXTRACTOR_loadDefaultLibraries();
- md_list = EXTRACTOR_getKeywords(plugins, argv[1]);
- EXTRACTOR_printKeywords(stdout, md_list);
- EXTRACTOR_freeKeywords(md_list);
- EXTRACTOR_removeAll(plugins); /* unload plugins */
+int
+main (int argc, char *argv[])
+{
+ EXTRACTOR_ExtractorList *plugins;
+ EXTRACTOR_KeywordList *md_list;
+ plugins = EXTRACTOR_loadDefaultLibraries ();
+ md_list = EXTRACTOR_getKeywords (plugins, argv[1]);
+ EXTRACTOR_printKeywords (stdout, md_list);
+ EXTRACTOR_freeKeywords (md_list);
+ EXTRACTOR_removeAll (plugins); /* unload plugins */
}
-Caption: minimal.c shows the most important libextractor functions in concert.
+Caption:minimal.c shows the most important libextractor functions in concert.
Modified: Extractor/doc/lj/plugin.c
===================================================================
--- Extractor/doc/lj/plugin.c 2007-07-29 08:04:12 UTC (rev 5367)
+++ Extractor/doc/lj/plugin.c 2007-07-29 08:35:49 UTC (rev 5368)
@@ -1,9 +1,8 @@
-if ( (data[0] != 0xFF) || (data[1] != 0xD8) )
- return prev; /* not a JPEG */
-addKeyword(&prev,
- strdup("image/jpeg"),
- EXTRACTOR_MIMETYPE);
+if ((data[0] != 0xFF) || (data[1] != 0xD8))
+ return prev; /* not a JPEG */
+addKeyword (&prev, strdup ("image/jpeg"), EXTRACTOR_MIMETYPE);
/* ... more parsing code here ... */
return prev;
-Caption: jpegextractor.c adds the Mime-Type to the list after parsing the file
header.
+Caption:jpegextractor.c adds the Mime -
+ Type to the list after parsing the file header.
Modified: Extractor/doc/lj/signature.c
===================================================================
--- Extractor/doc/lj/signature.c 2007-07-29 08:04:12 UTC (rev 5367)
+++ Extractor/doc/lj/signature.c 2007-07-29 08:35:49 UTC (rev 5368)
@@ -1,8 +1,4 @@
-struct EXTRACTOR_Keywords *
-libextractor_XXX_extract
- (char * filename,
- char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev);
+struct EXTRACTOR_Keywords *libextractor_XXX_extract
+ (char *filename, char *data, size_t size, struct EXTRACTOR_Keywords *prev);
-Caption: Signature of the function that each libextractor plugin must export.
+Caption:Signature of the function that each libextractor plugin must export.
Modified: Extractor/libltdl/ltdl.c
===================================================================
--- Extractor/libltdl/ltdl.c 2007-07-29 08:04:12 UTC (rev 5367)
+++ Extractor/libltdl/ltdl.c 2007-07-29 08:35:49 UTC (rev 5368)
@@ -131,10 +131,10 @@
#if WITH_DMALLOC
# include <dmalloc.h>
#endif
+
-
/* --- WINDOWS SUPPORT --- */
@@ -162,7 +162,7 @@
struct dirent
{
char d_name[2048];
- int d_namlen;
+ int d_namlen;
};
typedef struct _DIR
@@ -174,8 +174,8 @@
} DIR;
#endif /* LT_USE_WINDOWS_DIRENT_EMULATION */
+
-
/* --- MANIFEST CONSTANTS --- */
@@ -199,30 +199,32 @@
/* This accounts for the _LTX_ separator */
#undef LT_SYMBOL_OVERHEAD
#define LT_SYMBOL_OVERHEAD 5
+
-
/* --- MEMORY HANDLING --- */
/* These are the functions used internally. In addition to making
use of the associated function pointers above, they also perform
error handling. */
-static char *lt_estrdup LT_PARAMS((const char *str));
-static lt_ptr lt_emalloc LT_PARAMS((size_t size));
-static lt_ptr lt_erealloc LT_PARAMS((lt_ptr addr, size_t size));
+static char *lt_estrdup LT_PARAMS ((const char *str));
+static lt_ptr lt_emalloc LT_PARAMS ((size_t size));
+static lt_ptr lt_erealloc LT_PARAMS ((lt_ptr addr, size_t size));
/* static lt_ptr rpl_realloc LT_PARAMS((lt_ptr ptr, size_t size)); */
#define rpl_realloc realloc
/* These are the pointers that can be changed by the caller: */
-LT_GLOBAL_DATA lt_ptr (*lt_dlmalloc) LT_PARAMS((size_t size))
- = (lt_ptr (*) LT_PARAMS((size_t))) malloc;
-LT_GLOBAL_DATA lt_ptr (*lt_dlrealloc) LT_PARAMS((lt_ptr ptr, size_t size))
- = (lt_ptr (*) LT_PARAMS((lt_ptr, size_t))) rpl_realloc;
-LT_GLOBAL_DATA void (*lt_dlfree) LT_PARAMS((lt_ptr ptr))
- = (void (*) LT_PARAMS((lt_ptr))) free;
+LT_GLOBAL_DATA
+lt_ptr (*lt_dlmalloc)
+LT_PARAMS ((size_t size)) = (lt_ptr (*)LT_PARAMS ((size_t))) malloc;
+ LT_GLOBAL_DATA lt_ptr (*lt_dlrealloc)
+ LT_PARAMS ((lt_ptr ptr, size_t size)) =
+ (lt_ptr (*)LT_PARAMS ((lt_ptr, size_t))) rpl_realloc;
+ LT_GLOBAL_DATA void (*lt_dlfree) LT_PARAMS ((lt_ptr ptr)) =
+ (void (*)LT_PARAMS ((lt_ptr))) free;
/* The following macros reduce the amount of typing needed to cast
assigned memory. */
@@ -251,29 +253,28 @@
#define LT_DLMEM_REASSIGN(p, q) LT_STMT_START { \
if ((p) != (q)) { if (p) lt_dlfree (p); (p) = (q); (q) = 0; } \
} LT_STMT_END
+
-
/* --- REPLACEMENT FUNCTIONS --- */
#undef strdup
#define strdup rpl_strdup
-static char *strdup LT_PARAMS((const char *str));
+ static char *strdup LT_PARAMS ((const char *str));
-static char *
-strdup(str)
+ static char *strdup (str)
const char *str;
{
char *tmp = 0;
if (str)
{
- tmp = LT_DLMALLOC (char, 1+ strlen (str));
+ tmp = LT_DLMALLOC (char, 1 + strlen (str));
if (tmp)
- {
- strcpy(tmp, str);
- }
+ {
+ strcpy (tmp, str);
+ }
}
return tmp;
@@ -285,7 +286,7 @@
#undef strcmp
#define strcmp rpl_strcmp
-static int strcmp LT_PARAMS((const char *str1, const char *str2));
+static int strcmp LT_PARAMS ((const char *str1, const char *str2));
static int
strcmp (str1, str2)
@@ -299,13 +300,13 @@
if (str2 == 0)
return 1;
- for (;*str1 && *str2; ++str1, ++str2)
+ for (; *str1 && *str2; ++str1, ++str2)
{
if (*str1 != *str2)
- break;
+ break;
}
- return (int)(*str1 - *str2);
+ return (int) (*str1 - *str2);
}
#endif
@@ -317,19 +318,19 @@
# else
# define strchr rpl_strchr
-static const char *strchr LT_PARAMS((const char *str, int ch));
+static const char *strchr LT_PARAMS ((const char *str, int ch));
-static const char*
-strchr(str, ch)
+static const char *
+strchr (str, ch)
const char *str;
int ch;
{
const char *p;
- for (p = str; *p != (char)ch && *p != LT_EOS_CHAR; ++p)
- /*NOWORK*/;
+ for (p = str; *p != (char) ch && *p != LT_EOS_CHAR; ++p)
+ /*NOWORK*/;
- return (*p == (char)ch) ? p : 0;
+ return (*p == (char) ch) ? p : 0;
}
# endif
@@ -343,10 +344,10 @@
# else
# define strrchr rpl_strrchr
-static const char *strrchr LT_PARAMS((const char *str, int ch));
+static const char *strrchr LT_PARAMS ((const char *str, int ch));
-static const char*
-strrchr(str, ch)
+static const char *
+strrchr (str, ch)
const char *str;
int ch;
{
@@ -355,9 +356,9 @@
for (p = str; *p != LT_EOS_CHAR; ++p)
{
if (*p == (char) ch)
- {
- q = p;
- }
+ {
+ q = p;
+ }
}
return q;
@@ -377,7 +378,7 @@
# else
# define memcpy rpl_memcpy
-static lt_ptr memcpy LT_PARAMS((lt_ptr dest, const lt_ptr src, size_t size));
+static lt_ptr memcpy LT_PARAMS ((lt_ptr dest, const lt_ptr src, size_t size));
static lt_ptr
memcpy (dest, src, size)
@@ -385,9 +386,9 @@
const lt_ptr src;
size_t size;
{
- const char * s = src;
- char * d = dest;
- size_t i = 0;
+ const char *s = src;
+ char *d = dest;
+ size_t i = 0;
for (i = 0; i < size; ++i)
{
@@ -398,12 +399,13 @@
}
# endif /* !HAVE_BCOPY */
-#endif /* !HAVE_MEMCPY */
+#endif /* !HAVE_MEMCPY */
#if ! HAVE_MEMMOVE
# define memmove rpl_memmove
-static lt_ptr memmove LT_PARAMS((lt_ptr dest, const lt_ptr src, size_t size));
+static lt_ptr memmove
+LT_PARAMS ((lt_ptr dest, const lt_ptr src, size_t size));
static lt_ptr
memmove (dest, src, size)
@@ -411,21 +413,21 @@
const lt_ptr src;
size_t size;
{
- const char * s = src;
- char * d = dest;
- size_t i;
+ const char *s = src;
+ char *d = dest;
+ size_t i;
if (d < s)
for (i = 0; i < size; ++i)
{
- d[i] = s[i];
+ d[i] = s[i];
}
else if (d > s && size > 0)
- for (i = size -1; ; --i)
+ for (i = size - 1;; --i)
{
- d[i] = s[i];
- if (i == 0)
- break;
+ d[i] = s[i];
+ if (i == 0)
+ break;
}
return dest;
@@ -435,74 +437,76 @@
#ifdef LT_USE_WINDOWS_DIRENT_EMULATION
-static void closedir LT_PARAMS((DIR *entry));
+static void closedir LT_PARAMS ((DIR * entry));
static void
-closedir(entry)
- DIR *entry;
+closedir (entry)
+ DIR *entry;
{
- assert(entry != (DIR *) NULL);
- FindClose(entry->hSearch);
- lt_dlfree((lt_ptr)entry);
+ assert (entry != (DIR *) NULL);
+ FindClose (entry->hSearch);
+ lt_dlfree ((lt_ptr) entry);
}
-static DIR * opendir LT_PARAMS((const char *path));
+static DIR *opendir LT_PARAMS ((const char *path));
-static DIR*
+static DIR *
opendir (path)
- const char *path;
+ const char *path;
{
char file_specification[LT_FILENAME_MAX];
DIR *entry;
- assert(path != (char *) NULL);
+ assert (path != (char *) NULL);
/* allow space for: path + '\\' '\\' '*' '.' '*' + '\0' */
- (void) strncpy (file_specification, path, LT_FILENAME_MAX-6);
- file_specification[LT_FILENAME_MAX-6] = LT_EOS_CHAR;
- (void) strcat(file_specification,"\\");
- entry = LT_DLMALLOC (DIR,sizeof(DIR));
+ (void) strncpy (file_specification, path, LT_FILENAME_MAX - 6);
+ file_specification[LT_FILENAME_MAX - 6] = LT_EOS_CHAR;
+ (void) strcat (file_specification, "\\");
+ entry = LT_DLMALLOC (DIR, sizeof (DIR));
if (entry != (DIR *) 0)
{
entry->firsttime = TRUE;
- entry->hSearch = FindFirstFile(file_specification,&entry->Win32FindData);
+ entry->hSearch =
+ FindFirstFile (file_specification, &entry->Win32FindData);
}
if (entry->hSearch == INVALID_HANDLE_VALUE)
{
- (void) strcat(file_specification,"\\*.*");
- entry->hSearch = FindFirstFile(file_specification,&entry->Win32FindData);
+ (void) strcat (file_specification, "\\*.*");
+ entry->hSearch =
+ FindFirstFile (file_specification, &entry->Win32FindData);
if (entry->hSearch == INVALID_HANDLE_VALUE)
{
LT_DLFREE (entry);
return (DIR *) 0;
}
}
- return(entry);
+ return (entry);
}
-static struct dirent *readdir LT_PARAMS((DIR *entry));
+static struct dirent *readdir LT_PARAMS ((DIR * entry));
-static struct dirent *readdir(entry)
- DIR *entry;
+static struct dirent *
+readdir (entry)
+ DIR *entry;
{
- int
- status;
+ int status;
if (entry == (DIR *) 0)
- return((struct dirent *) 0);
+ return ((struct dirent *) 0);
if (!entry->firsttime)
{
- status = FindNextFile(entry->hSearch,&entry->Win32FindData);
+ status = FindNextFile (entry->hSearch, &entry->Win32FindData);
if (status == 0)
- return((struct dirent *) 0);
+ return ((struct dirent *) 0);
}
entry->firsttime = FALSE;
- (void) strncpy(entry->file_info.d_name,entry->Win32FindData.cFileName,
- LT_FILENAME_MAX-1);
+ (void) strncpy (entry->file_info.d_name, entry->Win32FindData.cFileName,
+ LT_FILENAME_MAX - 1);
entry->file_info.d_name[LT_FILENAME_MAX - 1] = LT_EOS_CHAR;
- entry->file_info.d_namlen = strlen(entry->file_info.d_name);
- return(&entry->file_info);
+ entry->file_info.d_namlen = strlen (entry->file_info.d_name);
+ return (&entry->file_info);
}
#endif /* LT_USE_WINDOWS_DIRENT_EMULATION */
@@ -533,9 +537,9 @@
{
/* For zero or less bytes, free the original memory */
if (ptr != 0)
- {
- lt_dlfree (ptr);
- }
+ {
+ lt_dlfree (ptr);
+ }
return (lt_ptr) 0;
}
@@ -550,13 +554,13 @@
lt_ptr mem = lt_dlmalloc (size);
if (mem)
- {
- memcpy (mem, ptr, size);
- lt_dlfree (ptr);
- }
+ {
+ memcpy (mem, ptr, size);
+ lt_dlfree (ptr);
+ }
/* Note that the contents of PTR are not damaged if there is
- insufficient memory to realloc. */
+ insufficient memory to realloc. */
return mem;
}
}
@@ -566,8 +570,8 @@
#if ! HAVE_ARGZ_APPEND
# define argz_append rpl_argz_append
-static error_t argz_append LT_PARAMS((char **pargz, size_t *pargz_len,
- const char *buf, size_t buf_len));
+static error_t argz_append LT_PARAMS ((char **pargz, size_t * pargz_len,
+ const char *buf, size_t buf_len));
static error_t
argz_append (pargz, pargz_len, buf, buf_len)
@@ -577,7 +581,7 @@
size_t buf_len;
{
size_t argz_len;
- char *argz;
+ char *argz;
assert (pargz);
assert (pargz_len);
@@ -608,8 +612,8 @@
#if ! HAVE_ARGZ_CREATE_SEP
# define argz_create_sep rpl_argz_create_sep
-static error_t argz_create_sep LT_PARAMS((const char *str, int delim,
- char **pargz, size_t *pargz_len));
+static error_t argz_create_sep LT_PARAMS ((const char *str, int delim,
+ char **pargz, size_t * pargz_len));
static error_t
argz_create_sep (str, delim, pargz, pargz_len)
@@ -627,7 +631,7 @@
/* Make a copy of STR, but replacing each occurrence of
DELIM with '\0'. */
- argz_len = 1+ LT_STRLEN (str);
+ argz_len = 1 + LT_STRLEN (str);
if (argz_len)
{
const char *p;
@@ -635,22 +639,22 @@
argz = LT_DLMALLOC (char, argz_len);
if (!argz)
- return ENOMEM;
+ return ENOMEM;
for (p = str, q = argz; *p != LT_EOS_CHAR; ++p)
- {
- if (*p == delim)
- {
- /* Ignore leading delimiters, and fold consecutive
- delimiters in STR into a single '\0' in ARGZ. */
- if ((q > argz) && (q[-1] != LT_EOS_CHAR))
- *q++ = LT_EOS_CHAR;
- else
- --argz_len;
- }
- else
- *q++ = *p;
- }
+ {
+ if (*p == delim)
+ {
+ /* Ignore leading delimiters, and fold consecutive
+ delimiters in STR into a single '\0' in ARGZ. */
+ if ((q > argz) && (q[-1] != LT_EOS_CHAR))
+ *q++ = LT_EOS_CHAR;
+ else
+ --argz_len;
+ }
+ else
+ *q++ = *p;
+ }
/* Copy terminating LT_EOS_CHAR. */
*q = *p;
}
@@ -671,8 +675,8 @@
#if ! HAVE_ARGZ_INSERT
# define argz_insert rpl_argz_insert
-static error_t argz_insert LT_PARAMS((char **pargz, size_t *pargz_len,
- char *before, const char *entry));
+static error_t argz_insert LT_PARAMS ((char **pargz, size_t * pargz_len,
+ char *before, const char *entry));
static error_t
argz_insert (pargz, pargz_len, before, entry)
@@ -688,7 +692,7 @@
/* No BEFORE address indicates ENTRY should be inserted after the
current last element. */
if (!before)
- return argz_append (pargz, pargz_len, entry, 1+ LT_STRLEN (entry));
+ return argz_append (pargz, pargz_len, entry, 1 + LT_STRLEN (entry));
/* This probably indicates a programmer error, but to preserve
semantics, scan back to the start of an entry if BEFORE points
@@ -697,10 +701,10 @@
--before;
{
- size_t entry_len = 1+ LT_STRLEN (entry);
- size_t argz_len = *pargz_len + entry_len;
- size_t offset = before - *pargz;
- char *argz = LT_DLREALLOC (char, *pargz, argz_len);
+ size_t entry_len = 1 + LT_STRLEN (entry);
+ size_t argz_len = *pargz_len + entry_len;
+ size_t offset = before - *pargz;
+ char *argz = LT_DLREALLOC (char, *pargz, argz_len);
if (!argz)
return ENOMEM;
@@ -713,7 +717,7 @@
space at the end -- making room to copy ENTRY into the
resulting gap. */
memmove (before + entry_len, before, *pargz_len - offset);
- memcpy (before, entry, entry_len);
+ memcpy (before, entry, entry_len);
/* Assign new values. */
*pargz = argz;
@@ -728,8 +732,8 @@
#if ! HAVE_ARGZ_NEXT
# define argz_next rpl_argz_next
-static char *argz_next LT_PARAMS((char *argz, size_t argz_len,
- const char *entry));
+static char *argz_next LT_PARAMS ((char *argz, size_t argz_len,
+ const char *entry));
static char *
argz_next (argz, argz_len, entry)
@@ -742,28 +746,28 @@
if (entry)
{
/* Either ARGZ/ARGZ_LEN is empty, or ENTRY points into an address
- within the ARGZ vector. */
+ within the ARGZ vector. */
assert ((!argz && !argz_len)
- || ((argz <= entry) && (entry < (argz + argz_len))));
+ || ((argz <= entry) && (entry < (argz + argz_len))));
/* Move to the char immediately after the terminating
- '\0' of ENTRY. */
- entry = 1+ strchr (entry, LT_EOS_CHAR);
+ '\0' of ENTRY. */
+ entry = 1 + strchr (entry, LT_EOS_CHAR);
/* Return either the new ENTRY, or else NULL if ARGZ is
- exhausted. */
+ exhausted. */
return (entry >= argz + argz_len) ? 0 : (char *) entry;
}
else
{
/* This should probably be flagged as a programmer error,
- since starting an argz_next loop with the iterator set
- to ARGZ is safer. To preserve semantics, handle the NULL
- case by returning the start of ARGZ (if any). */
+ since starting an argz_next loop with the iterator set
+ to ARGZ is safer. To preserve semantics, handle the NULL
+ case by returning the start of ARGZ (if any). */
if (argz_len > 0)
- return argz;
+ return argz;
else
- return 0;
+ return 0;
}
}
#endif /* !HAVE_ARGZ_NEXT */
@@ -773,8 +777,7 @@
#if ! HAVE_ARGZ_STRINGIFY
# define argz_stringify rpl_argz_stringify
-static void argz_stringify LT_PARAMS((char *argz, size_t argz_len,
- int sep));
+static void argz_stringify LT_PARAMS ((char *argz, size_t argz_len, int sep));
static void
argz_stringify (argz, argz_len, sep)
@@ -786,68 +789,69 @@
if (sep)
{
- --argz_len; /* don't stringify the terminating EOS */
+ --argz_len; /* don't stringify the terminating EOS */
while (--argz_len > 0)
- {
- if (argz[argz_len] == LT_EOS_CHAR)
- argz[argz_len] = sep;
- }
+ {
+ if (argz[argz_len] == LT_EOS_CHAR)
+ argz[argz_len] = sep;
+ }
}
}
#endif /* !HAVE_ARGZ_STRINGIFY */
+
-
/* --- TYPE DEFINITIONS -- */
/* This type is used for the array of caller data sets in each handler. */
-typedef struct {
- lt_dlcaller_id key;
- lt_ptr data;
+typedef struct
+{
+ lt_dlcaller_id key;
+ lt_ptr data;
} lt_caller_data;
+
-
/* --- OPAQUE STRUCTURES DECLARED IN LTDL.H --- */
/* Extract the diagnostic strings from the error table macro in the same
order as the enumerated indices in ltdl.h. */
-static const char *lt_dlerror_strings[] =
- {
+static const char *lt_dlerror_strings[] = {
#define LT_ERROR(name, diagnostic) (diagnostic),
- lt_dlerror_table
+ lt_dlerror_table
#undef LT_ERROR
+ 0
+};
- 0
- };
-
/* This structure is used for the list of registered loaders. */
-struct lt_dlloader {
- struct lt_dlloader *next;
- const char *loader_name; /* identifying name for each loader */
- const char *sym_prefix; /* prefix for symbols */
- lt_module_open *module_open;
- lt_module_close *module_close;
- lt_find_sym *find_sym;
- lt_dlloader_exit *dlloader_exit;
- lt_user_data dlloader_data;
+struct lt_dlloader
+{
+ struct lt_dlloader *next;
+ const char *loader_name; /* identifying name for each loader */
+ const char *sym_prefix; /* prefix for symbols */
+ lt_module_open *module_open;
+ lt_module_close *module_close;
+ lt_find_sym *find_sym;
+ lt_dlloader_exit *dlloader_exit;
+ lt_user_data dlloader_data;
};
-struct lt_dlhandle_struct {
- struct lt_dlhandle_struct *next;
- lt_dlloader *loader; /* dlopening interface */
- lt_dlinfo info;
- int depcount; /* number of dependencies */
- lt_dlhandle *deplibs; /* dependencies */
- lt_module module; /* system module handle */
- lt_ptr system; /* system specific data */
- lt_caller_data *caller_data; /* per caller associated data */
- int flags; /* various boolean stats */
+struct lt_dlhandle_struct
+{
+ struct lt_dlhandle_struct *next;
+ lt_dlloader *loader; /* dlopening interface */
+ lt_dlinfo info;
+ int depcount; /* number of dependencies */
+ lt_dlhandle *deplibs; /* dependencies */
+ lt_module module; /* system module handle */
+ lt_ptr system; /* system specific data */
+ lt_caller_data *caller_data; /* per caller associated data */
+ int flags; /* various boolean stats */
};
/* Various boolean flags can be stored in the flags field of an
@@ -863,18 +867,18 @@
#define LT_DLSTRERROR(name) lt_dlerror_strings[LT_CONC(LT_ERROR_,name)]
-static const char objdir[] = LTDL_OBJDIR;
-static const char archive_ext[] = LTDL_ARCHIVE_EXT;
+static const char objdir[] = LTDL_OBJDIR;
+static const char archive_ext[] = LTDL_ARCHIVE_EXT;
#ifdef LTDL_SHLIB_EXT
-static const char shlib_ext[] = LTDL_SHLIB_EXT;
+static const char shlib_ext[] = LTDL_SHLIB_EXT;
#endif
#ifdef LTDL_SYSSEARCHPATH
-static const char sys_search_path[] = LTDL_SYSSEARCHPATH;
+static const char sys_search_path[] = LTDL_SYSSEARCHPATH;
#endif
+
-
/* --- MUTEX LOCKING --- */
@@ -900,11 +904,11 @@
/* The mutex functions stored here are global, and are necessarily the
same for all threads that wish to share access to libltdl. */
-static lt_dlmutex_lock *lt_dlmutex_lock_func = 0;
-static lt_dlmutex_unlock *lt_dlmutex_unlock_func = 0;
-static lt_dlmutex_seterror *lt_dlmutex_seterror_func = 0;
-static lt_dlmutex_geterror *lt_dlmutex_geterror_func = 0;
-static const char *lt_dllast_error = 0;
+static lt_dlmutex_lock *lt_dlmutex_lock_func = 0;
+static lt_dlmutex_unlock *lt_dlmutex_unlock_func = 0;
+static lt_dlmutex_seterror *lt_dlmutex_seterror_func = 0;
+static lt_dlmutex_geterror *lt_dlmutex_geterror_func = 0;
+static const char *lt_dllast_error = 0;
/* Either set or reset the mutex functions. Either all the arguments must
@@ -919,7 +923,7 @@
lt_dlmutex_geterror *geterror;
{
lt_dlmutex_unlock *old_unlock = unlock;
- int errors = 0;
+ int errors = 0;
/* Lock using the old lock() callback, if any. */
LT_DLMUTEX_LOCK ();
@@ -927,8 +931,8 @@
if ((lock && unlock && seterror && geterror)
|| !(lock || unlock || seterror || geterror))
{
- lt_dlmutex_lock_func = lock;
- lt_dlmutex_unlock_func = unlock;
+ lt_dlmutex_lock_func = lock;
+ lt_dlmutex_unlock_func = unlock;
lt_dlmutex_geterror_func = geterror;
}
else
@@ -946,23 +950,23 @@
this function. */
return errors;
}
+
-
/* --- ERROR HANDLING --- */
-static const char **user_error_strings = 0;
-static int errorcount = LT_ERROR_MAX;
+static const char **user_error_strings = 0;
+static int errorcount = LT_ERROR_MAX;
int
lt_dladderror (diagnostic)
const char *diagnostic;
{
- int errindex = 0;
- int result = -1;
- const char **temp = (const char **) 0;
+ int errindex = 0;
+ int result = -1;
+ const char **temp = (const char **) 0;
assert (diagnostic);
@@ -972,9 +976,9 @@
temp = LT_EREALLOC (const char *, user_error_strings, 1 + errindex);
if (temp)
{
- user_error_strings = temp;
- user_error_strings[errindex] = diagnostic;
- result = errorcount++;
+ user_error_strings = temp;
+ user_error_strings[errindex] = diagnostic;
+ result = errorcount++;
}
LT_DLMUTEX_UNLOCK ();
@@ -986,7 +990,7 @@
lt_dlseterror (errindex)
int errindex;
{
- int errors = 0;
+ int errors = 0;
LT_DLMUTEX_LOCK ();
@@ -1042,10 +1046,10 @@
LT_DLMUTEX_SETERROR (LT_DLSTRERROR (NO_MEMORY));
return copy;
}
+
-
/* --- DLOPEN() INTERFACE LOADER --- */
@@ -1096,7 +1100,7 @@
lt_user_data loader_data;
const char *filename;
{
- lt_module module = dlopen (filename, LT_LAZY_OR_NOW);
+ lt_module module = dlopen (filename, LT_LAZY_OR_NOW);
if (!module)
{
@@ -1138,20 +1142,20 @@
return address;
}
-static struct lt_user_dlloader sys_dl =
- {
+static struct lt_user_dlloader sys_dl = {
# ifdef NEED_USCORE
- "_",
+ "_",
# else
- 0,
+ 0,
# endif
- sys_dl_open, sys_dl_close, sys_dl_sym, 0, 0 };
+ sys_dl_open, sys_dl_close, sys_dl_sym, 0, 0
+};
#endif /* HAVE_LIBDL */
+
-
/* --- SHL_LOAD() INTERFACE LOADER --- */
#if HAVE_SHL_LOAD
@@ -1229,9 +1233,9 @@
module = shl_load (filename, LT_BIND_FLAGS, 0L);
if (!module)
- {
- LT_DLMUTEX_SETERROR (LT_DLSTRERROR (CANNOT_OPEN));
- }
+ {
+ LT_DLMUTEX_SETERROR (LT_DLSTRERROR (CANNOT_OPEN));
+ }
}
return module;
@@ -1263,15 +1267,16 @@
/* sys_shl_open should never return a NULL module handle */
if (module == (lt_module) 0)
- {
- LT_DLMUTEX_SETERROR (LT_DLSTRERROR (INVALID_HANDLE));
- }
- else if (!shl_findsym((shl_t*) &module, symbol, TYPE_UNDEFINED, &address))
{
+ LT_DLMUTEX_SETERROR (LT_DLSTRERROR (INVALID_HANDLE));
+ }
+ else
+ if (!shl_findsym ((shl_t *) & module, symbol, TYPE_UNDEFINED, &address))
+ {
if (!address)
- {
- LT_DLMUTEX_SETERROR (LT_DLSTRERROR (SYMBOL_NOT_FOUND));
- }
+ {
+ LT_DLMUTEX_SETERROR (LT_DLSTRERROR (SYMBOL_NOT_FOUND));
+ }
}
return address;
@@ -1282,10 +1287,10 @@
};
#endif /* HAVE_SHL_LOAD */
+
-
/* --- LOADLIBRARY() INTERFACE LOADER --- */
#ifdef __WINDOWS__
@@ -1302,12 +1307,12 @@
lt_user_data loader_data;
const char *filename;
{
- lt_dlhandle cur;
- lt_module module = 0;
- const char *errormsg = 0;
- char *searchname = 0;
- char *ext;
- char self_name_buf[MAX_PATH];
+ lt_dlhandle cur;
+ lt_module module = 0;
+ const char *errormsg = 0;
+ char *searchname = 0;
+ char *ext;
+ char self_name_buf[MAX_PATH];
if (!filename)
{
@@ -1329,10 +1334,10 @@
else
{
/* Append a `.' to stop Windows from adding an
- implicit `.dll' extension. */
- searchname = LT_EMALLOC (char, 2+ LT_STRLEN (filename));
+ implicit `.dll' extension. */
+ searchname = LT_EMALLOC (char, 2 + LT_STRLEN (filename));
if (searchname)
- sprintf (searchname, "%s.", filename);
+ sprintf (searchname, "%s.", filename);
}
if (!searchname)
return 0;
@@ -1341,8 +1346,8 @@
/* Silence dialog from LoadLibrary on some failures.
No way to get the error mode, but to set it,
so set it twice to preserve any previous flags. */
- UINT errormode = SetErrorMode(SEM_FAILCRITICALERRORS);
- SetErrorMode(errormode | SEM_FAILCRITICALERRORS);
+ UINT errormode = SetErrorMode (SEM_FAILCRITICALERRORS);
+ SetErrorMode (errormode | SEM_FAILCRITICALERRORS);
#if defined(__CYGWIN__)
{
@@ -1355,7 +1360,7 @@
#endif
/* Restore the error mode. */
- SetErrorMode(errormode);
+ SetErrorMode (errormode);
}
LT_DLFREE (searchname);
@@ -1373,18 +1378,18 @@
while (cur)
{
if (!cur->module)
- {
- cur = 0;
- break;
- }
+ {
+ cur = 0;
+ break;
+ }
if (cur->module == module)
- {
- break;
- }
+ {
+ break;
+ }
cur = cur->next;
- }
+ }
LT_DLMUTEX_UNLOCK ();
if (cur || !module)
@@ -1401,9 +1406,9 @@
lt_user_data loader_data;
lt_module module;
{
- int errors = 0;
+ int errors = 0;
- if (FreeLibrary(module) == 0)
+ if (FreeLibrary (module) == 0)
{
LT_DLMUTEX_SETERROR (LT_DLSTRERROR (CANNOT_CLOSE));
++errors;
@@ -1418,7 +1423,7 @@
lt_module module;
const char *symbol;
{
- lt_ptr address = GetProcAddress (module, symbol);
+ lt_ptr address = GetProcAddress (module, symbol);
if (!address)
{
@@ -1433,10 +1438,10 @@
};
#endif /* __WINDOWS__ */
+
-
/* --- LOAD_ADD_ON() INTERFACE LOADER --- */
@@ -1462,7 +1467,7 @@
image_info info;
int32 cookie = 0;
if (get_next_image_info (0, &cookie, &info) == B_OK)
- image = load_add_on (info.name);
+ image = load_add_on (info.name);
}
if (image <= 0)
@@ -1513,10 +1518,10 @@
};
#endif /* __BEOS__ */
+
-
/* --- DLD_LINK() INTERFACE LOADER --- */
@@ -1552,7 +1557,7 @@
{
int errors = 0;
- if (dld_unlink_by_file ((char*)(module), 1) != 0)
+ if (dld_unlink_by_file ((char *) (module), 1) != 0)
{
LT_DLMUTEX_SETERROR (LT_DLSTRERROR (CANNOT_CLOSE));
++errors;
@@ -1605,10 +1610,11 @@
# define ENUM_DYLD_BOOL
# undef FALSE
# undef TRUE
- enum DYLD_BOOL {
- FALSE,
- TRUE
- };
+enum DYLD_BOOL
+{
+ FALSE,
+ TRUE
+};
#endif
#ifndef LC_REQ_DYLD
# define LC_REQ_DYLD 0x80000000
@@ -1616,10 +1622,18 @@
#ifndef LC_LOAD_WEAK_DYLIB
# define LC_LOAD_WEAK_DYLIB (0x18 | LC_REQ_DYLD)
#endif
-static const struct mach_header * (*ltdl_NSAddImage)(const char *image_name,
unsigned long options) = 0;
-static NSSymbol (*ltdl_NSLookupSymbolInImage)(const struct mach_header
*image,const char *symbolName, unsigned long options) = 0;
-static enum DYLD_BOOL (*ltdl_NSIsSymbolNameDefinedInImage)(const struct
mach_header *image, const char *symbolName) = 0;
-static enum DYLD_BOOL (*ltdl_NSMakePrivateModulePublic)(NSModule module) = 0;
+static const struct mach_header *(*ltdl_NSAddImage) (const char *image_name,
+ unsigned long options) =
+ 0;
+static NSSymbol (*ltdl_NSLookupSymbolInImage) (const struct mach_header *
+ image, const char *symbolName,
+ unsigned long options) = 0;
+static enum DYLD_BOOL (*ltdl_NSIsSymbolNameDefinedInImage) (const struct
+ mach_header *
+ image,
+ const char
+ *symbolName) = 0;
+static enum DYLD_BOOL (*ltdl_NSMakePrivateModulePublic) (NSModule module) = 0;
#ifndef NSADDIMAGE_OPTION_NONE
#define NSADDIMAGE_OPTION_NONE 0x0
@@ -1651,144 +1665,170 @@
static const char *
-lt_int_dyld_error(othererror)
- char* othererror;
+lt_int_dyld_error (othererror)
+ char *othererror;
{
/* return the dyld error string, or the passed in error string if none */
- NSLinkEditErrors ler;
- int lerno;
- const char *errstr;
- const char *file;
- NSLinkEditError(&ler,&lerno,&file,&errstr);
- if (!errstr || !strlen(errstr)) errstr = othererror;
- return errstr;
+ NSLinkEditErrors ler;
+ int lerno;
+ const char *errstr;
+ const char *file;
+ NSLinkEditError (&ler, &lerno, &file, &errstr);
+ if (!errstr || !strlen (errstr))
+ errstr = othererror;
+ return errstr;
}
static const struct mach_header *
-lt_int_dyld_get_mach_header_from_nsmodule(module)
- NSModule module;
+lt_int_dyld_get_mach_header_from_nsmodule (module)
+ NSModule module;
{
/* There should probably be an apple dyld api for this */
- int i=_dyld_image_count();
- int j;
- const char *modname=NSNameOfModule(module);
- const struct mach_header *mh=NULL;
- if (!modname) return NULL;
- for (j = 0; j < i; j++)
- {
- if (!strcmp(_dyld_get_image_name(j),modname))
- {
- mh=_dyld_get_image_header(j);
- break;
- }
- }
- return mh;
+ int i = _dyld_image_count ();
+ int j;
+ const char *modname = NSNameOfModule (module);
+ const struct mach_header *mh = NULL;
+ if (!modname)
+ return NULL;
+ for (j = 0; j < i; j++)
+ {
+ if (!strcmp (_dyld_get_image_name (j), modname))
+ {
+ mh = _dyld_get_image_header (j);
+ break;
+ }
+ }
+ return mh;
}
-static const char* lt_int_dyld_lib_install_name(mh)
- const struct mach_header *mh;
+static const char *
+lt_int_dyld_lib_install_name (mh)
+ const struct mach_header *mh;
{
/* NSAddImage is also used to get the loaded image, but it only works if the
lib
is installed, for uninstalled libs we need to check the install_names
against
each other. Note that this is still broken if DYLD_IMAGE_SUFFIX is set and a
different lib was loaded as a result
*/
- int j;
- struct load_command *lc;
- unsigned long offset = sizeof(struct mach_header);
- const char* retStr=NULL;
- for (j = 0; j < mh->ncmds; j++)
- {
- lc = (struct load_command*)(((unsigned long)mh) + offset);
- if (LC_ID_DYLIB == lc->cmd)
- {
- retStr=(char*)(((struct
dylib_command*)lc)->dylib.name.offset +
-
(unsigned long)lc);
- }
- offset += lc->cmdsize;
- }
- return retStr;
+ int j;
+ struct load_command *lc;
+ unsigned long offset = sizeof (struct mach_header);
+ const char *retStr = NULL;
+ for (j = 0; j < mh->ncmds; j++)
+ {
+ lc = (struct load_command *) (((unsigned long) mh) + offset);
+ if (LC_ID_DYLIB == lc->cmd)
+ {
+ retStr =
+ (char *) (((struct dylib_command *) lc)->dylib.name.offset +
+ (unsigned long) lc);
+ }
+ offset += lc->cmdsize;
+ }
+ return retStr;
}
static const struct mach_header *
-lt_int_dyld_match_loaded_lib_by_install_name(const char *name)
+lt_int_dyld_match_loaded_lib_by_install_name (const char *name)
{
- int i=_dyld_image_count();
- int j;
- const struct mach_header *mh=NULL;
- const char *id=NULL;
- for (j = 0; j < i; j++)
- {
- id=lt_int_dyld_lib_install_name(_dyld_get_image_header(j));
- if ((id) && (!strcmp(id,name)))
- {
- mh=_dyld_get_image_header(j);
- break;
- }
- }
- return mh;
+ int i = _dyld_image_count ();
+ int j;
+ const struct mach_header *mh = NULL;
+ const char *id = NULL;
+ for (j = 0; j < i; j++)
+ {
+ id = lt_int_dyld_lib_install_name (_dyld_get_image_header (j));
+ if ((id) && (!strcmp (id, name)))
+ {
+ mh = _dyld_get_image_header (j);
+ break;
+ }
+ }
+ return mh;
}
static NSSymbol
-lt_int_dyld_NSlookupSymbolInLinkedLibs(symbol,mh)
- const char *symbol;
- const struct mach_header *mh;
+lt_int_dyld_NSlookupSymbolInLinkedLibs (symbol, mh)
+ const char *symbol;
+ const struct mach_header *mh;
{
- /* Safe to assume our mh is good */
- int j;
- struct load_command *lc;
- unsigned long offset = sizeof(struct mach_header);
- NSSymbol retSym = 0;
- const struct mach_header *mh1;
- if ((ltdl_NSLookupSymbolInImage) && NSIsSymbolNameDefined(symbol) )
- {
- for (j = 0; j < mh->ncmds; j++)
- {
- lc = (struct load_command*)(((unsigned long)mh) +
offset);
- if ((LC_LOAD_DYLIB == lc->cmd) || (LC_LOAD_WEAK_DYLIB
== lc->cmd))
- {
-
mh1=lt_int_dyld_match_loaded_lib_by_install_name((char*)(((struct
dylib_command*)lc)->dylib.name.offset +
-
(unsigned long)lc));
- if (!mh1)
- {
- /* Maybe NSAddImage can find it */
- mh1=ltdl_NSAddImage((char*)(((struct
dylib_command*)lc)->dylib.name.offset +
-
(unsigned long)lc),
-
NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED +
-
NSADDIMAGE_OPTION_WITH_SEARCHING +
-
NSADDIMAGE_OPTION_RETURN_ON_ERROR );
- }
- if (mh1)
- {
- retSym = ltdl_NSLookupSymbolInImage(mh1,
-
symbol,
-
NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW
-
| NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR
-
);
- if (retSym) break;
- }
- }
- offset += lc->cmdsize;
- }
- }
- return retSym;
+ /* Safe to assume our mh is good */
+ int j;
+ struct load_command *lc;
+ unsigned long offset = sizeof (struct mach_header);
+ NSSymbol retSym = 0;
+ const struct mach_header *mh1;
+ if ((ltdl_NSLookupSymbolInImage) && NSIsSymbolNameDefined (symbol))
+ {
+ for (j = 0; j < mh->ncmds; j++)
+ {
+ lc = (struct load_command *) (((unsigned long) mh) + offset);
+ if ((LC_LOAD_DYLIB == lc->cmd) || (LC_LOAD_WEAK_DYLIB == lc->cmd))
+ {
+ mh1 =
+ lt_int_dyld_match_loaded_lib_by_install_name ((char
+ *) (((struct
+
dylib_command
+ *) lc)->
+ dylib.name.
+ offset +
+ (unsigned
+ long)
+ lc));
+ if (!mh1)
+ {
+ /* Maybe NSAddImage can find it */
+ mh1 =
+ ltdl_NSAddImage ((char *) (((struct dylib_command *) lc)->
+ dylib.name.offset +
+ (unsigned long) lc),
+ NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED +
+ NSADDIMAGE_OPTION_WITH_SEARCHING +
+ NSADDIMAGE_OPTION_RETURN_ON_ERROR);
+ }
+ if (mh1)
+ {
+ retSym = ltdl_NSLookupSymbolInImage (mh1,
+ symbol,
+
NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW
+ |
+
NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
+ if (retSym)
+ break;
+ }
+ }
+ offset += lc->cmdsize;
+ }
+ }
+ return retSym;
}
static int
-sys_dyld_init()
+sys_dyld_init ()
{
- int retCode = 0;
- int err = 0;
- if (!_dyld_present()) {
- retCode=1;
- }
- else {
- err = _dyld_func_lookup("__dyld_NSAddImage",(unsigned
long*)<dl_NSAddImage);
- err = _dyld_func_lookup("__dyld_NSLookupSymbolInImage",(unsigned
long*)<dl_NSLookupSymbolInImage);
- err = _dyld_func_lookup("__dyld_NSIsSymbolNameDefinedInImage",(unsigned
long*)<dl_NSIsSymbolNameDefinedInImage);
- err = _dyld_func_lookup("__dyld_NSMakePrivateModulePublic",(unsigned
long*)<dl_NSMakePrivateModulePublic);
+ int retCode = 0;
+ int err = 0;
+ if (!_dyld_present ())
+ {
+ retCode = 1;
}
- return retCode;
+ else
+ {
+ err =
+ _dyld_func_lookup ("__dyld_NSAddImage",
+ (unsigned long *) <dl_NSAddImage);
+ err =
+ _dyld_func_lookup ("__dyld_NSLookupSymbolInImage",
+ (unsigned long *) <dl_NSLookupSymbolInImage);
+ err =
+ _dyld_func_lookup ("__dyld_NSIsSymbolNameDefinedInImage",
+ (unsigned long *)
+ <dl_NSIsSymbolNameDefinedInImage);
+ err =
+ _dyld_func_lookup ("__dyld_NSMakePrivateModulePublic",
+ (unsigned long *) <dl_NSMakePrivateModulePublic);
+ }
+ return retCode;
}
static lt_module
@@ -1796,35 +1836,38 @@
lt_user_data loader_data;
const char *filename;
{
- lt_module module = 0;
- NSObjectFileImage ofi = 0;
- NSObjectFileImageReturnCode ofirc;
+ lt_module module = 0;
+ NSObjectFileImage ofi = 0;
+ NSObjectFileImageReturnCode ofirc;
- if (!filename)
- return (lt_module)-1;
- ofirc = NSCreateObjectFileImageFromFile(filename, &ofi);
- switch (ofirc)
- {
- case NSObjectFileImageSuccess:
- module = NSLinkModule(ofi, filename,
-
NSLINKMODULE_OPTION_RETURN_ON_ERROR
- | NSLINKMODULE_OPTION_PRIVATE
- | NSLINKMODULE_OPTION_BINDNOW);
- NSDestroyObjectFileImage(ofi);
- if (module)
- ltdl_NSMakePrivateModulePublic(module);
- break;
- case NSObjectFileImageInappropriateFile:
- if (ltdl_NSIsSymbolNameDefinedInImage &&
ltdl_NSLookupSymbolInImage)
- {
- module = (lt_module)ltdl_NSAddImage(filename,
NSADDIMAGE_OPTION_RETURN_ON_ERROR);
- break;
- }
- default:
- LT_DLMUTEX_SETERROR
(lt_int_dyld_error(LT_DLSTRERROR(CANNOT_OPEN)));
- return 0;
- }
- if (!module) LT_DLMUTEX_SETERROR
(lt_int_dyld_error(LT_DLSTRERROR(CANNOT_OPEN)));
+ if (!filename)
+ return (lt_module) - 1;
+ ofirc = NSCreateObjectFileImageFromFile (filename, &ofi);
+ switch (ofirc)
+ {
+ case NSObjectFileImageSuccess:
+ module = NSLinkModule (ofi, filename,
+ NSLINKMODULE_OPTION_RETURN_ON_ERROR
+ | NSLINKMODULE_OPTION_PRIVATE
+ | NSLINKMODULE_OPTION_BINDNOW);
+ NSDestroyObjectFileImage (ofi);
+ if (module)
+ ltdl_NSMakePrivateModulePublic (module);
+ break;
+ case NSObjectFileImageInappropriateFile:
+ if (ltdl_NSIsSymbolNameDefinedInImage && ltdl_NSLookupSymbolInImage)
+ {
+ module =
+ (lt_module) ltdl_NSAddImage (filename,
+ NSADDIMAGE_OPTION_RETURN_ON_ERROR);
+ break;
+ }
+ default:
+ LT_DLMUTEX_SETERROR (lt_int_dyld_error (LT_DLSTRERROR (CANNOT_OPEN)));
+ return 0;
+ }
+ if (!module)
+ LT_DLMUTEX_SETERROR (lt_int_dyld_error (LT_DLSTRERROR (CANNOT_OPEN)));
return module;
}
@@ -1833,43 +1876,45 @@
lt_user_data loader_data;
lt_module module;
{
- int retCode = 0;
- int flags = 0;
- if (module == (lt_module)-1) return 0;
+ int retCode = 0;
+ int flags = 0;
+ if (module == (lt_module) - 1)
+ return 0;
#ifdef __BIG_ENDIAN__
- if (((struct mach_header *)module)->magic == MH_MAGIC)
+ if (((struct mach_header *) module)->magic == MH_MAGIC)
#else
- if (((struct mach_header *)module)->magic == MH_CIGAM)
+ if (((struct mach_header *) module)->magic == MH_CIGAM)
#endif
- {
- LT_DLMUTEX_SETERROR("Can not close a dylib");
- retCode = 1;
- }
- else
- {
+ {
+ LT_DLMUTEX_SETERROR ("Can not close a dylib");
+ retCode = 1;
+ }
+ else
+ {
#if 1
/* Currently, if a module contains c++ static destructors and it is unloaded,
we
get a segfault in atexit(), due to compiler and dynamic loader differences
of
opinion, this works around that.
*/
- if ((const struct section *)NULL !=
-
getsectbynamefromheader(lt_int_dyld_get_mach_header_from_nsmodule(module),
- "__DATA","__mod_term_func"))
- {
- flags += NSUNLINKMODULE_OPTION_KEEP_MEMORY_MAPPED;
- }
+ if ((const struct section *) NULL !=
+ getsectbynamefromheader (lt_int_dyld_get_mach_header_from_nsmodule
+ (module), "__DATA", "__mod_term_func"))
+ {
+ flags += NSUNLINKMODULE_OPTION_KEEP_MEMORY_MAPPED;
+ }
#endif
#ifdef __ppc__
- flags += NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES;
+ flags += NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES;
#endif
- if (!NSUnLinkModule(module,flags))
- {
- retCode=1;
- LT_DLMUTEX_SETERROR
(lt_int_dyld_error(LT_DLSTRERROR(CANNOT_CLOSE)));
- }
- }
+ if (!NSUnLinkModule (module, flags))
+ {
+ retCode = 1;
+ LT_DLMUTEX_SETERROR (lt_int_dyld_error
+ (LT_DLSTRERROR (CANNOT_CLOSE)));
+ }
+ }
- return retCode;
+ return retCode;
}
static lt_ptr
@@ -1878,52 +1923,57 @@
lt_module module;
const char *symbol;
{
- lt_ptr address = 0;
- NSSymbol *nssym = 0;
- void *unused;
- const struct mach_header *mh=NULL;
- char saveError[256] = "Symbol not found";
- if (module == (lt_module)-1)
- {
- _dyld_lookup_and_bind(symbol,(unsigned long*)&address,&unused);
- return address;
- }
+ lt_ptr address = 0;
+ NSSymbol *nssym = 0;
+ void *unused;
+ const struct mach_header *mh = NULL;
+ char saveError[256] = "Symbol not found";
+ if (module == (lt_module) - 1)
+ {
+ _dyld_lookup_and_bind (symbol, (unsigned long *) &address, &unused);
+ return address;
+ }
#ifdef __BIG_ENDIAN__
- if (((struct mach_header *)module)->magic == MH_MAGIC)
+ if (((struct mach_header *) module)->magic == MH_MAGIC)
#else
- if (((struct mach_header *)module)->magic == MH_CIGAM)
+ if (((struct mach_header *) module)->magic == MH_CIGAM)
#endif
- {
- if (ltdl_NSIsSymbolNameDefinedInImage && ltdl_NSLookupSymbolInImage)
- {
- mh=module;
- if (ltdl_NSIsSymbolNameDefinedInImage((struct
mach_header*)module,symbol))
- {
- nssym = ltdl_NSLookupSymbolInImage((struct
mach_header*)module,
-
symbol,
-
NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW
-
| NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR
-
);
- }
- }
+ {
+ if (ltdl_NSIsSymbolNameDefinedInImage && ltdl_NSLookupSymbolInImage)
+ {
+ mh = module;
+ if (ltdl_NSIsSymbolNameDefinedInImage
+ ((struct mach_header *) module, symbol))
+ {
+ nssym =
+ ltdl_NSLookupSymbolInImage ((struct mach_header *) module,
+ symbol,
+
NSLOOKUPSYMBOLINIMAGE_OPTION_BIND_NOW
+ |
+
NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR);
+ }
+ }
- }
- else {
- nssym = NSLookupSymbolInModule(module, symbol);
- }
- if (!nssym)
- {
- strncpy(saveError,
lt_int_dyld_error(LT_DLSTRERROR(SYMBOL_NOT_FOUND)), 255);
- saveError[255] = 0;
- if (!mh) mh=lt_int_dyld_get_mach_header_from_nsmodule(module);
- nssym = lt_int_dyld_NSlookupSymbolInLinkedLibs(symbol,mh);
- }
- if (!nssym)
- {
- LT_DLMUTEX_SETERROR (saveError);
- return NULL;
- }
- return NSAddressOfSymbol(nssym);
+ }
+ else
+ {
+ nssym = NSLookupSymbolInModule (module, symbol);
+ }
+ if (!nssym)
+ {
+ strncpy (saveError,
+ lt_int_dyld_error (LT_DLSTRERROR (SYMBOL_NOT_FOUND)), 255);
+ saveError[255] = 0;
+ if (!mh)
+ mh = lt_int_dyld_get_mach_header_from_nsmodule (module);
+ nssym = lt_int_dyld_NSlookupSymbolInLinkedLibs (symbol, mh);
+ }
+ if (!nssym)
+ {
+ LT_DLMUTEX_SETERROR (saveError);
+ return NULL;
+ }
+ return NSAddressOfSymbol (nssym);
}
static struct lt_user_dlloader sys_dyld =
@@ -1931,8 +1981,8 @@
#endif /* HAVE_DYLD */
+
-
/* --- DLPREOPEN() INTERFACE LOADER --- */
@@ -1940,12 +1990,12 @@
typedef struct lt_dlsymlists_t
{
- struct lt_dlsymlists_t *next;
- const lt_dlsymlist *syms;
+ struct lt_dlsymlists_t *next;
+ const lt_dlsymlist *syms;
} lt_dlsymlists_t;
-static const lt_dlsymlist *default_preloaded_symbols = 0;
-static lt_dlsymlists_t *preloaded_symbols = 0;
+static const lt_dlsymlist *default_preloaded_symbols = 0;
+static lt_dlsymlists_t *preloaded_symbols = 0;
static int
presym_init (loader_data)
@@ -1976,7 +2026,7 @@
lists = preloaded_symbols;
while (lists)
{
- lt_dlsymlists_t *tmp = lists;
+ lt_dlsymlists_t *tmp = lists;
lists = lists->next;
LT_DLFREE (tmp);
@@ -2002,7 +2052,7 @@
{
lt_dlsymlists_t *tmp;
lt_dlsymlists_t *lists;
- int errors = 0;
+ int errors = 0;
LT_DLMUTEX_LOCK ();
@@ -2010,16 +2060,16 @@
while (lists)
{
if (lists->syms == preloaded)
- {
- goto done;
- }
+ {
+ goto done;
+ }
lists = lists->next;
}
tmp = LT_EMALLOC (lt_dlsymlists_t, 1);
if (tmp)
{
- memset (tmp, 0, sizeof(lt_dlsymlists_t));
+ memset (tmp, 0, sizeof (lt_dlsymlists_t));
tmp->syms = preloaded;
tmp->next = preloaded_symbols;
preloaded_symbols = tmp;
@@ -2029,7 +2079,7 @@
++errors;
}
- done:
+done:
LT_DLMUTEX_UNLOCK ();
return errors;
}
@@ -2040,7 +2090,7 @@
const char *filename;
{
lt_dlsymlists_t *lists;
- lt_module module = (lt_module) 0;
+ lt_module module = (lt_module) 0;
LT_DLMUTEX_LOCK ();
lists = preloaded_symbols;
@@ -2065,21 +2115,21 @@
const lt_dlsymlist *syms = lists->syms;
while (syms->name)
- {
- if (!syms->address && strcmp(syms->name, filename) == 0)
- {
- module = (lt_module) syms;
- goto done;
- }
- ++syms;
- }
+ {
+ if (!syms->address && strcmp (syms->name, filename) == 0)
+ {
+ module = (lt_module) syms;
+ goto done;
+ }
+ ++syms;
+ }
lists = lists->next;
}
LT_DLMUTEX_SETERROR (LT_DLSTRERROR (FILE_NOT_FOUND));
- done:
+done:
LT_DLMUTEX_UNLOCK ();
return module;
}
@@ -2100,18 +2150,18 @@
lt_module module;
const char *symbol;
{
- lt_dlsymlist *syms = (lt_dlsymlist*) module;
+ lt_dlsymlist *syms = (lt_dlsymlist *) module;
++syms;
while (syms->address)
{
- if (strcmp(syms->name, symbol) == 0)
- {
- return syms->address;
- }
+ if (strcmp (syms->name, symbol) == 0)
+ {
+ return syms->address;
+ }
- ++syms;
- }
+ ++syms;
+ }
LT_DLMUTEX_SETERROR (LT_DLSTRERROR (SYMBOL_NOT_FOUND));
@@ -2121,88 +2171,80 @@
static struct lt_user_dlloader presym = {
0, presym_open, presym_close, presym_sym, presym_exit, 0
};
+
-
/* --- DYNAMIC MODULE LOADING --- */
/* The type of a function used at each iteration of foreach_dirinpath(). */
-typedef int foreach_callback_func LT_PARAMS((char *filename, lt_ptr data1,
- lt_ptr data2));
+typedef int foreach_callback_func LT_PARAMS ((char *filename, lt_ptr data1,
+ lt_ptr data2));
-static int foreach_dirinpath LT_PARAMS((const char *search_path,
- const char *base_name,
- foreach_callback_func *func,
- lt_ptr data1, lt_ptr data2));
+static int foreach_dirinpath LT_PARAMS ((const char *search_path,
+ const char *base_name,
+ foreach_callback_func * func,
+ lt_ptr data1, lt_ptr data2));
-static int find_file_callback LT_PARAMS((char *filename, lt_ptr data,
- lt_ptr ignored));
-static int find_handle_callback LT_PARAMS((char *filename, lt_ptr data,
- lt_ptr ignored));
-static int foreachfile_callback LT_PARAMS((char *filename, lt_ptr data1,
- lt_ptr data2));
+static int find_file_callback LT_PARAMS ((char *filename, lt_ptr data,
+ lt_ptr ignored));
+static int find_handle_callback LT_PARAMS ((char *filename, lt_ptr data,
+ lt_ptr ignored));
+static int foreachfile_callback LT_PARAMS ((char *filename, lt_ptr data1,
+ lt_ptr data2));
-static int canonicalize_path LT_PARAMS((const char *path,
- char **pcanonical));
-static int argzize_path LT_PARAMS((const char *path,
- char **pargz,
- size_t *pargz_len));
-static FILE *find_file LT_PARAMS((const char *search_path,
- const char *base_name,
- char **pdir));
-static lt_dlhandle *find_handle LT_PARAMS((const char *search_path,
- const char *base_name,
- lt_dlhandle *handle));
-static int find_module LT_PARAMS((lt_dlhandle *handle,
- const char *dir,
- const char *libdir,
- const char *dlname,
- const char *old_name,
- int installed));
-static int free_vars LT_PARAMS((char *dlname, char *oldname,
- char *libdir, char *deplibs));
-static int load_deplibs LT_PARAMS((lt_dlhandle handle,
- char *deplibs));
-static int trim LT_PARAMS((char **dest,
- const char *str));
-static int try_dlopen LT_PARAMS((lt_dlhandle *handle,
- const char *filename));
-static int tryall_dlopen LT_PARAMS((lt_dlhandle *handle,
- const char *filename));
-static int unload_deplibs LT_PARAMS((lt_dlhandle handle));
-static int lt_argz_insert LT_PARAMS((char **pargz,
- size_t *pargz_len,
- char *before,
- const char *entry));
-static int lt_argz_insertinorder LT_PARAMS((char **pargz,
- size_t *pargz_len,
- const char *entry));
-static int lt_argz_insertdir LT_PARAMS((char **pargz,
- size_t *pargz_len,
- const char *dirnam,
- struct dirent *dp));
-static int lt_dlpath_insertdir LT_PARAMS((char **ppath,
- char *before,
- const char *dir));
-static int list_files_by_dir LT_PARAMS((const char *dirnam,
- char **pargz,
- size_t *pargz_len));
-static int file_not_found LT_PARAMS((void));
+static int canonicalize_path LT_PARAMS ((const char *path,
+ char **pcanonical));
+static int argzize_path LT_PARAMS ((const char *path,
+ char **pargz, size_t * pargz_len));
+static FILE *find_file LT_PARAMS ((const char *search_path,
+ const char *base_name, char **pdir));
+static lt_dlhandle *find_handle LT_PARAMS ((const char *search_path,
+ const char *base_name,
+ lt_dlhandle * handle));
+static int find_module LT_PARAMS ((lt_dlhandle * handle,
+ const char *dir,
+ const char *libdir,
+ const char *dlname,
+ const char *old_name, int installed));
+static int free_vars LT_PARAMS ((char *dlname, char *oldname,
+ char *libdir, char *deplibs));
+static int load_deplibs LT_PARAMS ((lt_dlhandle handle, char *deplibs));
+static int trim LT_PARAMS ((char **dest, const char *str));
+static int try_dlopen LT_PARAMS ((lt_dlhandle * handle,
+ const char *filename));
+static int tryall_dlopen LT_PARAMS ((lt_dlhandle * handle,
+ const char *filename));
+static int unload_deplibs LT_PARAMS ((lt_dlhandle handle));
+static int lt_argz_insert LT_PARAMS ((char **pargz,
+ size_t * pargz_len,
+ char *before, const char *entry));
+static int lt_argz_insertinorder LT_PARAMS ((char **pargz,
+ size_t * pargz_len,
+ const char *entry));
+static int lt_argz_insertdir LT_PARAMS ((char **pargz,
+ size_t * pargz_len,
+ const char *dirnam,
+ struct dirent * dp));
+static int lt_dlpath_insertdir LT_PARAMS ((char **ppath,
+ char *before, const char *dir));
+static int list_files_by_dir LT_PARAMS ((const char *dirnam,
+ char **pargz, size_t * pargz_len));
+static int file_not_found LT_PARAMS ((void));
-static char *user_search_path= 0;
-static lt_dlloader *loaders = 0;
-static lt_dlhandle handles = 0;
-static int initialized = 0;
+static char *user_search_path = 0;
+static lt_dlloader *loaders = 0;
+static lt_dlhandle handles = 0;
+static int initialized = 0;
/* Initialize libltdl. */
int
lt_dlinit ()
{
- int errors = 0;
+ int errors = 0;
LT_DLMUTEX_LOCK ();
@@ -2210,7 +2252,7 @@
if (++initialized == 1)
{
handles = 0;
- user_search_path = 0; /* empty search path */
+ user_search_path = 0; /* empty search path */
#if HAVE_LIBDL
errors += lt_dlloader_add (lt_dlloader_next (0), &sys_dl, "dlopen");
@@ -2228,21 +2270,21 @@
errors += lt_dlloader_add (lt_dlloader_next (0), &sys_dld, "dld");
#endif
#if HAVE_DYLD
- errors += lt_dlloader_add (lt_dlloader_next (0), &sys_dyld, "dyld");
- errors += sys_dyld_init();
+ errors += lt_dlloader_add (lt_dlloader_next (0), &sys_dyld, "dyld");
+ errors += sys_dyld_init ();
#endif
errors += lt_dlloader_add (lt_dlloader_next (0), &presym, "dlpreload");
if (presym_init (presym.dlloader_data))
- {
- LT_DLMUTEX_SETERROR (LT_DLSTRERROR (INIT_LOADER));
- ++errors;
- }
+ {
+ LT_DLMUTEX_SETERROR (LT_DLSTRERROR (INIT_LOADER));
+ ++errors;
+ }
else if (errors != 0)
- {
- LT_DLMUTEX_SETERROR (LT_DLSTRERROR (DLOPEN_NOT_SUPPORTED));
- ++errors;
- }
+ {
+ LT_DLMUTEX_SETERROR (LT_DLSTRERROR (DLOPEN_NOT_SUPPORTED));
+ ++errors;
+ }
}
LT_DLMUTEX_UNLOCK ();
@@ -2262,13 +2304,13 @@
}
else
{
- presym_free_symlists();
+ presym_free_symlists ();
LT_DLMUTEX_LOCK ();
if (default_preloaded_symbols)
- {
- errors = lt_dlpreload (default_preloaded_symbols);
- }
+ {
+ errors = lt_dlpreload (default_preloaded_symbols);
+ }
LT_DLMUTEX_UNLOCK ();
}
@@ -2290,7 +2332,7 @@
{
/* shut down libltdl */
lt_dlloader *loader;
- int errors = 0;
+ int errors = 0;
LT_DLMUTEX_LOCK ();
loader = loaders;
@@ -2305,54 +2347,54 @@
/* shut down only at last call. */
if (--initialized == 0)
{
- int level;
+ int level;
while (handles && LT_DLIS_RESIDENT (handles))
- {
- handles = handles->next;
- }
+ {
+ handles = handles->next;
+ }
/* close all modules */
for (level = 1; handles; ++level)
- {
- lt_dlhandle cur = handles;
- int saw_nonresident = 0;
+ {
+ lt_dlhandle cur = handles;
+ int saw_nonresident = 0;
- while (cur)
- {
- lt_dlhandle tmp = cur;
- cur = cur->next;
- if (!LT_DLIS_RESIDENT (tmp))
- saw_nonresident = 1;
- if (!LT_DLIS_RESIDENT (tmp) && tmp->info.ref_count <= level)
- {
- if (lt_dlclose (tmp))
- {
- ++errors;
- }
- }
- }
- /* done if only resident modules are left */
- if (!saw_nonresident)
- break;
- }
+ while (cur)
+ {
+ lt_dlhandle tmp = cur;
+ cur = cur->next;
+ if (!LT_DLIS_RESIDENT (tmp))
+ saw_nonresident = 1;
+ if (!LT_DLIS_RESIDENT (tmp) && tmp->info.ref_count <= level)
+ {
+ if (lt_dlclose (tmp))
+ {
+ ++errors;
+ }
+ }
+ }
+ /* done if only resident modules are left */
+ if (!saw_nonresident)
+ break;
+ }
/* close all loaders */
while (loader)
- {
- lt_dlloader *next = loader->next;
- lt_user_data data = loader->dlloader_data;
- if (loader->dlloader_exit && loader->dlloader_exit (data))
- {
- ++errors;
- }
+ {
+ lt_dlloader *next = loader->next;
+ lt_user_data data = loader->dlloader_data;
+ if (loader->dlloader_exit && loader->dlloader_exit (data))
+ {
+ ++errors;
+ }
- LT_DLMEM_REASSIGN (loader, next);
- }
+ LT_DLMEM_REASSIGN (loader, next);
+ }
loaders = 0;
}
- done:
+done:
LT_DLMUTEX_UNLOCK ();
return errors;
}
@@ -2362,15 +2404,15 @@
lt_dlhandle *handle;
const char *filename;
{
- lt_dlhandle cur;
- lt_dlloader *loader;
- const char *saved_error;
- int errors = 0;
+ lt_dlhandle cur;
+ lt_dlloader *loader;
+ const char *saved_error;
+ int errors = 0;
LT_DLMUTEX_GETERROR (saved_error);
LT_DLMUTEX_LOCK ();
- cur = handles;
+ cur = handles;
loader = loaders;
/* check whether the module was already opened */
@@ -2378,15 +2420,15 @@
{
/* try to dlopen the program itself? */
if (!cur->info.filename && !filename)
- {
- break;
- }
+ {
+ break;
+ }
if (cur->info.filename && filename
- && strcmp (cur->info.filename, filename) == 0)
- {
- break;
- }
+ && strcmp (cur->info.filename, filename) == 0)
+ {
+ break;
+ }
cur = cur->next;
}
@@ -2402,23 +2444,23 @@
if (filename)
{
/* Comment out the check of file permissions using access.
- This call seems to always return -1 with error EACCES.
- */
+ This call seems to always return -1 with error EACCES.
+ */
/* We need to catch missing file errors early so that
- file_not_found() can detect what happened.
- if (access (filename, R_OK) != 0)
- {
- LT_DLMUTEX_SETERROR (LT_DLSTRERROR (FILE_NOT_FOUND));
- ++errors;
- goto done;
- } */
+ file_not_found() can detect what happened.
+ if (access (filename, R_OK) != 0)
+ {
+ LT_DLMUTEX_SETERROR (LT_DLSTRERROR (FILE_NOT_FOUND));
+ ++errors;
+ goto done;
+ } */
cur->info.filename = lt_estrdup (filename);
if (!cur->info.filename)
- {
- ++errors;
- goto done;
- }
+ {
+ ++errors;
+ goto done;
+ }
}
else
{
@@ -2432,9 +2474,9 @@
cur->module = loader->module_open (data, filename);
if (cur->module != 0)
- {
- break;
- }
+ {
+ break;
+ }
loader = loader->next;
}
@@ -2445,10 +2487,10 @@
goto done;
}
- cur->loader = loader;
+ cur->loader = loader;
LT_DLMUTEX_SETERROR (saved_error);
- done:
+done:
LT_DLMUTEX_UNLOCK ();
return errors;
@@ -2461,10 +2503,10 @@
const char *dirname;
const char *dlname;
{
- int error = 0;
- char *filename = 0;
- size_t filename_len = 0;
- size_t dirname_len = LT_STRLEN (dirname);
+ int error = 0;
+ char *filename = 0;
+ size_t filename_len = 0;
+ size_t dirname_len = LT_STRLEN (dirname);
assert (handle);
assert (dirname);
@@ -2476,13 +2518,13 @@
#endif
if (dirname_len > 0)
- if (dirname[dirname_len -1] == '/')
+ if (dirname[dirname_len - 1] == '/')
--dirname_len;
filename_len = dirname_len + 1 + LT_STRLEN (dlname);
/* Allocate memory, and combine DIRNAME and MODULENAME into it.
The PREFIX (if any) is handled below. */
- filename = LT_EMALLOC (char, dirname_len + 1 + filename_len + 1);
+ filename = LT_EMALLOC (char, dirname_len + 1 + filename_len + 1);
if (!filename)
return 1;
@@ -2494,7 +2536,7 @@
if (prefix)
{
error += tryall_dlopen_module (handle,
- (const char *) 0, prefix, filename);
+ (const char *) 0, prefix, filename);
}
else if (tryall_dlopen (handle, filename) != 0)
{
@@ -2527,24 +2569,25 @@
{
/* try to open the installed module */
if (installed && libdir)
- {
- if (tryall_dlopen_module (handle,
- (const char *) 0, libdir, dlname) == 0)
- return 0;
- }
+ {
+ if (tryall_dlopen_module (handle,
+ (const char *) 0, libdir, dlname) == 0)
+ return 0;
+ }
/* try to open the not-installed module */
if (!installed)
- {
- if (tryall_dlopen_module (handle, dir, objdir, dlname) == 0)
- return 0;
- }
+ {
+ if (tryall_dlopen_module (handle, dir, objdir, dlname) == 0)
+ return 0;
+ }
/* maybe it was moved to another directory */
{
- if (dir && (tryall_dlopen_module (handle,
- (const char *) 0, dir, dlname) == 0))
- return 0;
+ if (dir && (tryall_dlopen_module (handle,
+ (const char *) 0, dir,
+ dlname) == 0))
+ return 0;
}
}
@@ -2562,7 +2605,7 @@
assert (path && *path);
assert (pcanonical);
- canonical = LT_EMALLOC (char, 1+ LT_STRLEN (path));
+ canonical = LT_EMALLOC (char, 1 + LT_STRLEN (path));
if (!canonical)
return 1;
@@ -2571,38 +2614,38 @@
size_t src;
for (src = 0; path[src] != LT_EOS_CHAR; ++src)
{
- /* Path separators are not copied to the beginning or end of
- the destination, or if another separator would follow
- immediately. */
- if (path[src] == LT_PATHSEP_CHAR)
- {
- if ((dest == 0)
- || (path[1+ src] == LT_PATHSEP_CHAR)
- || (path[1+ src] == LT_EOS_CHAR))
- continue;
- }
+ /* Path separators are not copied to the beginning or end of
+ the destination, or if another separator would follow
+ immediately. */
+ if (path[src] == LT_PATHSEP_CHAR)
+ {
+ if ((dest == 0)
+ || (path[1 + src] == LT_PATHSEP_CHAR)
+ || (path[1 + src] == LT_EOS_CHAR))
+ continue;
+ }
- /* Anything other than a directory separator is copied verbatim. */
- if ((path[src] != '/')
+ /* Anything other than a directory separator is copied verbatim. */
+ if ((path[src] != '/')
#ifdef LT_DIRSEP_CHAR
- && (path[src] != LT_DIRSEP_CHAR)
+ && (path[src] != LT_DIRSEP_CHAR)
#endif
- )
- {
- canonical[dest++] = path[src];
- }
- /* Directory separators are converted and copied only if they are
- not at the end of a path -- i.e. before a path separator or
- NULL terminator. */
- else if ((path[1+ src] != LT_PATHSEP_CHAR)
- && (path[1+ src] != LT_EOS_CHAR)
+ )
+ {
+ canonical[dest++] = path[src];
+ }
+ /* Directory separators are converted and copied only if they are
+ not at the end of a path -- i.e. before a path separator or
+ NULL terminator. */
+ else if ((path[1 + src] != LT_PATHSEP_CHAR)
+ && (path[1 + src] != LT_EOS_CHAR)
#ifdef LT_DIRSEP_CHAR
- && (path[1+ src] != LT_DIRSEP_CHAR)
+ && (path[1 + src] != LT_DIRSEP_CHAR)
#endif
- && (path[1+ src] != '/'))
- {
- canonical[dest++] = '/';
- }
+ && (path[1 + src] != '/'))
+ {
+ canonical[dest++] = '/';
+ }
}
/* Add an end-of-string marker at the end. */
@@ -2630,14 +2673,14 @@
if ((error = argz_create_sep (path, LT_PATHSEP_CHAR, pargz, pargz_len)))
{
switch (error)
- {
- case ENOMEM:
- LT_DLMUTEX_SETERROR (LT_DLSTRERROR (NO_MEMORY));
- break;
- default:
- LT_DLMUTEX_SETERROR (LT_DLSTRERROR (UNKNOWN));
- break;
- }
+ {
+ case ENOMEM:
+ LT_DLMUTEX_SETERROR (LT_DLSTRERROR (NO_MEMORY));
+ break;
+ default:
+ LT_DLMUTEX_SETERROR (LT_DLSTRERROR (UNKNOWN));
+ break;
+ }
return 1;
}
@@ -2657,13 +2700,13 @@
lt_ptr data1;
lt_ptr data2;
{
- int result = 0;
- int filenamesize = 0;
- size_t lenbase = LT_STRLEN (base_name);
- size_t argz_len = 0;
- char *argz = 0;
- char *filename = 0;
- char *canonical = 0;
+ int result = 0;
+ int filenamesize = 0;
+ size_t lenbase = LT_STRLEN (base_name);
+ size_t argz_len = 0;
+ char *argz = 0;
+ char *filename = 0;
+ char *canonical = 0;
LT_DLMUTEX_LOCK ();
@@ -2683,35 +2726,35 @@
char *dir_name = 0;
while ((dir_name = argz_next (argz, argz_len, dir_name)))
{
- size_t lendir = LT_STRLEN (dir_name);
+ size_t lendir = LT_STRLEN (dir_name);
- if (lendir +1 +lenbase >= filenamesize)
- {
- LT_DLFREE (filename);
- filenamesize = lendir +1 +lenbase +1; /* "/d" + '/' + "f" + '\0' */
- filename = LT_EMALLOC (char, filenamesize);
- if (!filename)
- goto cleanup;
- }
+ if (lendir + 1 + lenbase >= filenamesize)
+ {
+ LT_DLFREE (filename);
+ filenamesize = lendir + 1 + lenbase + 1; /* "/d" + '/' + "f" +
'\0' */
+ filename = LT_EMALLOC (char, filenamesize);
+ if (!filename)
+ goto cleanup;
+ }
- assert (filenamesize > lendir);
- strcpy (filename, dir_name);
+ assert (filenamesize > lendir);
+ strcpy (filename, dir_name);
- if (base_name && *base_name)
- {
- if (filename[lendir -1] != '/')
- filename[lendir++] = '/';
- strcpy (filename +lendir, base_name);
- }
+ if (base_name && *base_name)
+ {
+ if (filename[lendir - 1] != '/')
+ filename[lendir++] = '/';
+ strcpy (filename + lendir, base_name);
+ }
- if ((result = (*func) (filename, data1, data2)))
- {
- break;
- }
+ if ((result = (*func) (filename, data1, data2)))
+ {
+ break;
+ }
}
}
- cleanup:
+cleanup:
LT_DLFREE (argz);
LT_DLFREE (canonical);
LT_DLFREE (filename);
@@ -2730,9 +2773,9 @@
lt_ptr data1;
lt_ptr data2;
{
- char **pdir = (char **) data1;
- FILE **pfile = (FILE **) data2;
- int is_done = 0;
+ char **pdir = (char **) data1;
+ FILE **pfile = (FILE **) data2;
+ int is_done = 0;
assert (filename && *filename);
assert (pdir);
@@ -2743,10 +2786,10 @@
char *dirend = strrchr (filename, '/');
if (dirend > filename)
- *dirend = LT_EOS_CHAR;
+ *dirend = LT_EOS_CHAR;
LT_DLFREE (*pdir);
- *pdir = lt_estrdup (filename);
+ *pdir = lt_estrdup (filename);
is_done = (*pdir == 0) ? -1 : 1;
}
@@ -2772,8 +2815,8 @@
lt_ptr data;
lt_ptr ignored;
{
- lt_dlhandle *handle = (lt_dlhandle *) data;
- int notfound = access (filename, R_OK);
+ lt_dlhandle *handle = (lt_dlhandle *) data;
+ int notfound = access (filename, R_OK);
/* Bail out if file cannot be read... */
if (notfound)
@@ -2799,7 +2842,7 @@
return 0;
if (!foreach_dirinpath (search_path, base_name, find_handle_callback,
- handle, 0))
+ handle, 0))
return 0;
return handle;
@@ -2811,12 +2854,12 @@
char *deplibs;
{
#if LTDL_DLOPEN_DEPLIBS
- char *p, *save_search_path = 0;
- int depcount = 0;
- int i;
- char **names = 0;
+ char *p, *save_search_path = 0;
+ int depcount = 0;
+ int i;
+ char **names = 0;
#endif
- int errors = 0;
+ int errors = 0;
handle->depcount = 0;
@@ -2832,7 +2875,7 @@
{
save_search_path = lt_estrdup (user_search_path);
if (!save_search_path)
- goto cleanup;
+ goto cleanup;
}
/* extract search paths and count deplibs */
@@ -2840,34 +2883,34 @@
while (*p)
{
if (!isspace ((int) *p))
- {
- char *end = p+1;
- while (*end && !isspace((int) *end))
- {
- ++end;
- }
+ {
+ char *end = p + 1;
+ while (*end && !isspace ((int) *end))
+ {
+ ++end;
+ }
- if (strncmp(p, "-L", 2) == 0 || strncmp(p, "-R", 2) == 0)
- {
- char save = *end;
- *end = 0; /* set a temporary string terminator */
- if (lt_dladdsearchdir(p+2))
- {
- goto cleanup;
- }
- *end = save;
- }
- else
- {
- ++depcount;
- }
+ if (strncmp (p, "-L", 2) == 0 || strncmp (p, "-R", 2) == 0)
+ {
+ char save = *end;
+ *end = 0; /* set a temporary string terminator */
+ if (lt_dladdsearchdir (p + 2))
+ {
+ goto cleanup;
+ }
+ *end = save;
+ }
+ else
+ {
+ ++depcount;
+ }
- p = end;
- }
+ p = end;
+ }
else
- {
- ++p;
- }
+ {
+ ++p;
+ }
}
if (!depcount)
@@ -2876,7 +2919,7 @@
goto cleanup;
}
- names = LT_EMALLOC (char *, depcount * sizeof (char*));
+ names = LT_EMALLOC (char *, depcount * sizeof (char *));
if (!names)
goto cleanup;
@@ -2886,40 +2929,40 @@
while (*p)
{
if (isspace ((int) *p))
- {
- ++p;
- }
+ {
+ ++p;
+ }
else
- {
- char *end = p+1;
- while (*end && !isspace ((int) *end))
- {
- ++end;
- }
+ {
+ char *end = p + 1;
+ while (*end && !isspace ((int) *end))
+ {
+ ++end;
+ }
- if (strncmp(p, "-L", 2) != 0 && strncmp(p, "-R", 2) != 0)
- {
- char *name;
- char save = *end;
- *end = 0; /* set a temporary string terminator */
- if (strncmp(p, "-l", 2) == 0)
- {
- size_t name_len = 3+ /* "lib" */ LT_STRLEN (p + 2);
- name = LT_EMALLOC (char, 1+ name_len);
- if (name)
- sprintf (name, "lib%s", p+2);
- }
- else
- name = lt_estrdup(p);
+ if (strncmp (p, "-L", 2) != 0 && strncmp (p, "-R", 2) != 0)
+ {
+ char *name;
+ char save = *end;
+ *end = 0; /* set a temporary string terminator */
+ if (strncmp (p, "-l", 2) == 0)
+ {
+ size_t name_len = 3 + /* "lib" */ LT_STRLEN (p + 2);
+ name = LT_EMALLOC (char, 1 + name_len);
+ if (name)
+ sprintf (name, "lib%s", p + 2);
+ }
+ else
+ name = lt_estrdup (p);
- if (!name)
- goto cleanup_names;
+ if (!name)
+ goto cleanup_names;
- names[depcount++] = name;
- *end = save;
- }
- p = end;
- }
+ names[depcount++] = name;
+ *end = save;
+ }
+ p = end;
+ }
}
/* load the deplibs (in reverse order)
@@ -2929,38 +2972,39 @@
later on if the loaded module cannot resolve all of its symbols. */
if (depcount)
{
- int j = 0;
+ int j = 0;
- handle->deplibs = (lt_dlhandle*) LT_EMALLOC (lt_dlhandle *, depcount);
+ handle->deplibs = (lt_dlhandle *) LT_EMALLOC (lt_dlhandle *, depcount);
if (!handle->deplibs)
- goto cleanup;
+ goto cleanup;
for (i = 0; i < depcount; ++i)
- {
- handle->deplibs[j] = lt_dlopenext(names[depcount-1-i]);
- if (handle->deplibs[j])
- {
- ++j;
- }
- }
+ {
+ handle->deplibs[j] = lt_dlopenext (names[depcount - 1 - i]);
+ if (handle->deplibs[j])
+ {
+ ++j;
+ }
+ }
- handle->depcount = j; /* Number of successfully loaded deplibs */
- errors = 0;
+ handle->depcount = j; /* Number of successfully loaded deplibs */
+ errors = 0;
}
- cleanup_names:
+cleanup_names:
for (i = 0; i < depcount; ++i)
{
LT_DLFREE (names[i]);
}
- cleanup:
+cleanup:
LT_DLFREE (names);
/* restore the old search path */
- if (user_search_path) {
- LT_DLFREE (user_search_path);
- user_search_path = save_search_path;
- }
+ if (user_search_path)
+ {
+ LT_DLFREE (user_search_path);
+ user_search_path = save_search_path;
+ }
LT_DLMUTEX_UNLOCK ();
#endif
@@ -2978,12 +3022,12 @@
if (handle->depcount)
{
for (i = 0; i < handle->depcount; ++i)
- {
- if (!LT_DLIS_RESIDENT (handle->deplibs[i]))
- {
- errors += lt_dlclose (handle->deplibs[i]);
- }
- }
+ {
+ if (!LT_DLIS_RESIDENT (handle->deplibs[i]))
+ {
+ errors += lt_dlclose (handle->deplibs[i]);
+ }
+ }
}
return errors;
@@ -2996,8 +3040,8 @@
{
/* remove the leading and trailing "'" from str
and store the result in dest */
- const char *end = strrchr (str, '\'');
- size_t len = LT_STRLEN (str);
+ const char *end = strrchr (str, '\'');
+ size_t len = LT_STRLEN (str);
char *tmp;
LT_DLFREE (*dest);
@@ -3009,10 +3053,10 @@
{
tmp = LT_EMALLOC (char, end - str);
if (!tmp)
- return 1;
+ return 1;
- strncpy(tmp, &str[1], (end - str) - 1);
- tmp[len-3] = LT_EOS_CHAR;
+ strncpy (tmp, &str[1], (end - str) - 1);
+ tmp[len - 3] = LT_EOS_CHAR;
*dest = tmp;
}
else
@@ -3043,14 +3087,14 @@
lt_dlhandle *phandle;
const char *filename;
{
- const char * ext = 0;
- const char * saved_error = 0;
- char * canonical = 0;
- char * base_name = 0;
- char * dir = 0;
- char * name = 0;
- int errors = 0;
- lt_dlhandle newhandle;
+ const char *ext = 0;
+ const char *saved_error = 0;
+ char *canonical = 0;
+ char *base_name = 0;
+ char *dir = 0;
+ char *name = 0;
+ int errors = 0;
+ lt_dlhandle newhandle;
assert (phandle);
assert (*phandle == 0);
@@ -3062,19 +3106,19 @@
{
*phandle = (lt_dlhandle) LT_EMALLOC (struct lt_dlhandle_struct, 1);
if (*phandle == 0)
- return 1;
+ return 1;
- memset (*phandle, 0, sizeof(struct lt_dlhandle_struct));
- newhandle = *phandle;
+ memset (*phandle, 0, sizeof (struct lt_dlhandle_struct));
+ newhandle = *phandle;
/* lt_dlclose()ing yourself is very bad! Disallow it. */
LT_DLSET_FLAG (*phandle, LT_DLRESIDENT_FLAG);
if (tryall_dlopen (&newhandle, 0) != 0)
- {
- LT_DLFREE (*phandle);
- return 1;
- }
+ {
+ LT_DLFREE (*phandle);
+ return 1;
+ }
goto register_handle;
}
@@ -3094,14 +3138,14 @@
base_name = strrchr (canonical, '/');
if (base_name)
{
- size_t dirlen = (1+ base_name) - canonical;
+ size_t dirlen = (1 + base_name) - canonical;
- dir = LT_EMALLOC (char, 1+ dirlen);
+ dir = LT_EMALLOC (char, 1 + dirlen);
if (!dir)
- {
- ++errors;
- goto cleanup;
- }
+ {
+ ++errors;
+ goto cleanup;
+ }
strncpy (dir, canonical, dirlen);
dir[dirlen] = LT_EOS_CHAR;
@@ -3118,41 +3162,41 @@
if (ext && strcmp (ext, archive_ext) == 0)
{
/* this seems to be a libtool module */
- FILE * file = 0;
- char * dlname = 0;
- char * old_name = 0;
- char * libdir = 0;
- char * deplibs = 0;
- char * line = 0;
- size_t line_len;
+ FILE *file = 0;
+ char *dlname = 0;
+ char *old_name = 0;
+ char *libdir = 0;
+ char *deplibs = 0;
+ char *line = 0;
+ size_t line_len;
/* if we can't find the installed flag, it is probably an
- installed libtool archive, produced with an old version
- of libtool */
- int installed = 1;
+ installed libtool archive, produced with an old version
+ of libtool */
+ int installed = 1;
/* extract the module name from the file name */
name = LT_EMALLOC (char, ext - base_name + 1);
if (!name)
- {
- ++errors;
- goto cleanup;
- }
+ {
+ ++errors;
+ goto cleanup;
+ }
/* canonicalize the module name */
{
size_t i;
for (i = 0; i < ext - base_name; ++i)
- {
- if (isalnum ((int)(base_name[i])))
- {
- name[i] = base_name[i];
- }
- else
- {
- name[i] = '_';
- }
- }
+ {
+ if (isalnum ((int) (base_name[i])))
+ {
+ name[i] = base_name[i];
+ }
+ else
+ {
+ name[i] = '_';
+ }
+ }
name[ext - base_name] = LT_EOS_CHAR;
}
@@ -3161,146 +3205,145 @@
prescribed paths. Otherwise (or in any case if the module was not
yet found) try opening just the module name as passed. */
if (!dir)
- {
- const char *search_path;
+ {
+ const char *search_path;
- LT_DLMUTEX_LOCK ();
- search_path = user_search_path;
- if (search_path)
- file = find_file (user_search_path, base_name, &dir);
- LT_DLMUTEX_UNLOCK ();
+ LT_DLMUTEX_LOCK ();
+ search_path = user_search_path;
+ if (search_path)
+ file = find_file (user_search_path, base_name, &dir);
+ LT_DLMUTEX_UNLOCK ();
- if (!file)
- {
- search_path = getenv (LTDL_SEARCHPATH_VAR);
- if (search_path)
- file = find_file (search_path, base_name, &dir);
- }
+ if (!file)
+ {
+ search_path = getenv (LTDL_SEARCHPATH_VAR);
+ if (search_path)
+ file = find_file (search_path, base_name, &dir);
+ }
#ifdef LTDL_SHLIBPATH_VAR
- if (!file)
- {
- search_path = getenv (LTDL_SHLIBPATH_VAR);
- if (search_path)
- file = find_file (search_path, base_name, &dir);
- }
+ if (!file)
+ {
+ search_path = getenv (LTDL_SHLIBPATH_VAR);
+ if (search_path)
+ file = find_file (search_path, base_name, &dir);
+ }
#endif
#ifdef LTDL_SYSSEARCHPATH
- if (!file && sys_search_path)
- {
- file = find_file (sys_search_path, base_name, &dir);
- }
+ if (!file && sys_search_path)
+ {
+ file = find_file (sys_search_path, base_name, &dir);
+ }
#endif
- }
+ }
if (!file)
- {
- file = fopen (filename, LT_READTEXT_MODE);
- }
+ {
+ file = fopen (filename, LT_READTEXT_MODE);
+ }
/* If we didn't find the file by now, it really isn't there. Set
- the status flag, and bail out. */
+ the status flag, and bail out. */
if (!file)
- {
- LT_DLMUTEX_SETERROR (LT_DLSTRERROR (FILE_NOT_FOUND));
- ++errors;
- goto cleanup;
- }
+ {
+ LT_DLMUTEX_SETERROR (LT_DLSTRERROR (FILE_NOT_FOUND));
+ ++errors;
+ goto cleanup;
+ }
line_len = LT_FILENAME_MAX;
line = LT_EMALLOC (char, line_len);
if (!line)
- {
- fclose (file);
- ++errors;
- goto cleanup;
- }
+ {
+ fclose (file);
+ ++errors;
+ goto cleanup;
+ }
/* read the .la file */
while (!feof (file))
- {
- if (!fgets (line, (int) line_len, file))
- {
- break;
- }
+ {
+ if (!fgets (line, (int) line_len, file))
+ {
+ break;
+ }
- /* Handle the case where we occasionally need to read a line
- that is longer than the initial buffer size. */
- while ((line[LT_STRLEN(line) -1] != '\n') && (!feof (file)))
- {
- line = LT_DLREALLOC (char, line, line_len *2);
- if (!fgets (&line[line_len -1], (int) line_len +1, file))
- {
- break;
- }
- line_len *= 2;
- }
+ /* Handle the case where we occasionally need to read a line
+ that is longer than the initial buffer size. */
+ while ((line[LT_STRLEN (line) - 1] != '\n') && (!feof (file)))
+ {
+ line = LT_DLREALLOC (char, line, line_len * 2);
+ if (!fgets (&line[line_len - 1], (int) line_len + 1, file))
+ {
+ break;
+ }
+ line_len *= 2;
+ }
- if (line[0] == '\n' || line[0] == '#')
- {
- continue;
- }
+ if (line[0] == '\n' || line[0] == '#')
+ {
+ continue;
+ }
#undef STR_DLNAME
#define STR_DLNAME "dlname="
- if (strncmp (line, STR_DLNAME, sizeof (STR_DLNAME) - 1) == 0)
- {
- errors += trim (&dlname, &line[sizeof (STR_DLNAME) - 1]);
- }
+ if (strncmp (line, STR_DLNAME, sizeof (STR_DLNAME) - 1) == 0)
+ {
+ errors += trim (&dlname, &line[sizeof (STR_DLNAME) - 1]);
+ }
#undef STR_OLD_LIBRARY
#define STR_OLD_LIBRARY "old_library="
- else if (strncmp (line, STR_OLD_LIBRARY,
- sizeof (STR_OLD_LIBRARY) - 1) == 0)
- {
- errors += trim (&old_name, &line[sizeof (STR_OLD_LIBRARY) - 1]);
- }
+ else if (strncmp (line, STR_OLD_LIBRARY,
+ sizeof (STR_OLD_LIBRARY) - 1) == 0)
+ {
+ errors += trim (&old_name, &line[sizeof (STR_OLD_LIBRARY) - 1]);
+ }
#undef STR_LIBDIR
#define STR_LIBDIR "libdir="
- else if (strncmp (line, STR_LIBDIR, sizeof (STR_LIBDIR) - 1) == 0)
- {
- errors += trim (&libdir, &line[sizeof(STR_LIBDIR) - 1]);
- }
+ else if (strncmp (line, STR_LIBDIR, sizeof (STR_LIBDIR) - 1) == 0)
+ {
+ errors += trim (&libdir, &line[sizeof (STR_LIBDIR) - 1]);
+ }
#undef STR_DL_DEPLIBS
#define STR_DL_DEPLIBS "dependency_libs="
- else if (strncmp (line, STR_DL_DEPLIBS,
- sizeof (STR_DL_DEPLIBS) - 1) == 0)
- {
- errors += trim (&deplibs, &line[sizeof (STR_DL_DEPLIBS) - 1]);
- }
- else if (strcmp (line, "installed=yes\n") == 0)
- {
- installed = 1;
- }
- else if (strcmp (line, "installed=no\n") == 0)
- {
- installed = 0;
- }
+ else if (strncmp (line, STR_DL_DEPLIBS,
+ sizeof (STR_DL_DEPLIBS) - 1) == 0)
+ {
+ errors += trim (&deplibs, &line[sizeof (STR_DL_DEPLIBS) - 1]);
+ }
+ else if (strcmp (line, "installed=yes\n") == 0)
+ {
+ installed = 1;
+ }
+ else if (strcmp (line, "installed=no\n") == 0)
+ {
+ installed = 0;
+ }
#undef STR_LIBRARY_NAMES
#define STR_LIBRARY_NAMES "library_names="
- else if (! dlname && strncmp (line, STR_LIBRARY_NAMES,
- sizeof (STR_LIBRARY_NAMES) - 1) == 0)
- {
- char *last_libname;
- errors += trim (&dlname, &line[sizeof (STR_LIBRARY_NAMES) - 1]);
- if (!errors
- && dlname
- && (last_libname = strrchr (dlname, ' ')) != 0)
- {
- last_libname = lt_estrdup (last_libname + 1);
- if (!last_libname)
- {
- ++errors;
- goto cleanup;
- }
- LT_DLMEM_REASSIGN (dlname, last_libname);
- }
- }
+ else if (!dlname && strncmp (line, STR_LIBRARY_NAMES,
+ sizeof (STR_LIBRARY_NAMES) - 1) == 0)
+ {
+ char *last_libname;
+ errors += trim (&dlname, &line[sizeof (STR_LIBRARY_NAMES) - 1]);
+ if (!errors
+ && dlname && (last_libname = strrchr (dlname, ' ')) != 0)
+ {
+ last_libname = lt_estrdup (last_libname + 1);
+ if (!last_libname)
+ {
+ ++errors;
+ goto cleanup;
+ }
+ LT_DLMEM_REASSIGN (dlname, last_libname);
+ }
+ }
- if (errors)
- break;
- }
+ if (errors)
+ break;
+ }
fclose (file);
LT_DLFREE (line);
@@ -3308,105 +3351,106 @@
/* allocate the handle */
*phandle = (lt_dlhandle) LT_EMALLOC (struct lt_dlhandle_struct, 1);
if (*phandle == 0)
- ++errors;
+ ++errors;
if (errors)
- {
- free_vars (dlname, old_name, libdir, deplibs);
- LT_DLFREE (*phandle);
- goto cleanup;
- }
+ {
+ free_vars (dlname, old_name, libdir, deplibs);
+ LT_DLFREE (*phandle);
+ goto cleanup;
+ }
assert (*phandle);
- memset (*phandle, 0, sizeof(struct lt_dlhandle_struct));
+ memset (*phandle, 0, sizeof (struct lt_dlhandle_struct));
if (load_deplibs (*phandle, deplibs) == 0)
- {
- newhandle = *phandle;
- /* find_module may replace newhandle */
- if (find_module (&newhandle, dir, libdir, dlname, old_name,
installed))
- {
- unload_deplibs (*phandle);
- ++errors;
- }
- }
+ {
+ newhandle = *phandle;
+ /* find_module may replace newhandle */
+ if (find_module
+ (&newhandle, dir, libdir, dlname, old_name, installed))
+ {
+ unload_deplibs (*phandle);
+ ++errors;
+ }
+ }
else
- {
- ++errors;
- }
+ {
+ ++errors;
+ }
free_vars (dlname, old_name, libdir, deplibs);
if (errors)
- {
- LT_DLFREE (*phandle);
- goto cleanup;
- }
+ {
+ LT_DLFREE (*phandle);
+ goto cleanup;
+ }
if (*phandle != newhandle)
- {
- unload_deplibs (*phandle);
- }
+ {
+ unload_deplibs (*phandle);
+ }
}
else
{
/* not a libtool module */
*phandle = (lt_dlhandle) LT_EMALLOC (struct lt_dlhandle_struct, 1);
if (*phandle == 0)
- {
- ++errors;
- goto cleanup;
- }
+ {
+ ++errors;
+ goto cleanup;
+ }
memset (*phandle, 0, sizeof (struct lt_dlhandle_struct));
newhandle = *phandle;
/* If the module has no directory name component, try to find it
- first in user_search_path and then other prescribed paths.
- Otherwise (or in any case if the module was not yet found) try
- opening just the module name as passed. */
+ first in user_search_path and then other prescribed paths.
+ Otherwise (or in any case if the module was not yet found) try
+ opening just the module name as passed. */
if ((dir || (!find_handle (user_search_path, base_name, &newhandle)
- && !find_handle (getenv (LTDL_SEARCHPATH_VAR), base_name,
- &newhandle)
+ && !find_handle (getenv (LTDL_SEARCHPATH_VAR), base_name,
+ &newhandle)
#ifdef LTDL_SHLIBPATH_VAR
- && !find_handle (getenv (LTDL_SHLIBPATH_VAR), base_name,
- &newhandle)
+ && !find_handle (getenv (LTDL_SHLIBPATH_VAR), base_name,
+ &newhandle)
#endif
#ifdef LTDL_SYSSEARCHPATH
- && !find_handle (sys_search_path, base_name, &newhandle)
+ && !find_handle (sys_search_path, base_name, &newhandle)
#endif
- )))
- {
+ )))
+ {
if (tryall_dlopen (&newhandle, filename) != 0)
{
newhandle = NULL;
}
- }
+ }
if (!newhandle)
- {
- LT_DLFREE (*phandle);
- ++errors;
- goto cleanup;
- }
+ {
+ LT_DLFREE (*phandle);
+ ++errors;
+ goto cleanup;
+ }
}
- register_handle:
+register_handle:
LT_DLMEM_REASSIGN (*phandle, newhandle);
if ((*phandle)->info.ref_count == 0)
{
- (*phandle)->info.ref_count = 1;
+ (*phandle)->info.ref_count = 1;
LT_DLMEM_REASSIGN ((*phandle)->info.name, name);
LT_DLMUTEX_LOCK ();
- (*phandle)->next = handles;
- handles = *phandle;
+ (*phandle)->next = handles;
+ handles = *phandle;
LT_DLMUTEX_UNLOCK ();
}
LT_DLMUTEX_SETERROR (saved_error);
- cleanup:
+cleanup:
LT_DLFREE (dir);
LT_DLFREE (name);
LT_DLFREE (canonical);
@@ -3450,11 +3494,11 @@
lt_dlopenext (filename)
const char *filename;
{
- lt_dlhandle handle = 0;
- char * tmp = 0;
- char * ext = 0;
- size_t len;
- int errors = 0;
+ lt_dlhandle handle = 0;
+ char *tmp = 0;
+ char *ext = 0;
+ size_t len;
+ int errors = 0;
if (!filename)
{
@@ -3470,7 +3514,7 @@
to try appending additional extensions. */
if (ext && ((strcmp (ext, archive_ext) == 0)
#ifdef LTDL_SHLIB_EXT
- || (strcmp (ext, shlib_ext) == 0)
+ || (strcmp (ext, shlib_ext) == 0)
#endif
))
{
@@ -3504,7 +3548,7 @@
LT_DLFREE (tmp);
tmp = LT_EMALLOC (char, len + LT_STRLEN (shlib_ext) + 1);
if (!tmp)
- return 0;
+ return 0;
strcpy (tmp, filename);
}
@@ -3513,7 +3557,7 @@
tmp[len] = LT_EOS_CHAR;
}
- strcat(tmp, shlib_ext);
+ strcat (tmp, shlib_ext);
errors = try_dlopen (&handle, tmp);
/* As before, if the file was found but loading failed, return now
@@ -3552,14 +3596,14 @@
if (error)
{
switch (error)
- {
- case ENOMEM:
- LT_DLMUTEX_SETERROR (LT_DLSTRERROR (NO_MEMORY));
- break;
- default:
- LT_DLMUTEX_SETERROR (LT_DLSTRERROR (UNKNOWN));
- break;
- }
+ {
+ case ENOMEM:
+ LT_DLMUTEX_SETERROR (LT_DLSTRERROR (NO_MEMORY));
+ break;
+ default:
+ LT_DLMUTEX_SETERROR (LT_DLSTRERROR (UNKNOWN));
+ break;
+ }
return 1;
}
@@ -3581,10 +3625,12 @@
if (*pargz)
while ((before = argz_next (*pargz, *pargz_len, before)))
{
- int cmp = strcmp (entry, before);
+ int cmp = strcmp (entry, before);
- if (cmp < 0) break;
- if (cmp == 0) return 0; /* No duplicates! */
+ if (cmp < 0)
+ break;
+ if (cmp == 0)
+ return 0; /* No duplicates! */
}
return lt_argz_insert (pargz, pargz_len, before, entry);
@@ -3597,26 +3643,26 @@
const char *dirnam;
struct dirent *dp;
{
- char *buf = 0;
- size_t buf_len = 0;
- char *end = 0;
+ char *buf = 0;
+ size_t buf_len = 0;
+ char *end = 0;
size_t end_offset = 0;
- size_t dir_len = 0;
- int errors = 0;
+ size_t dir_len = 0;
+ int errors = 0;
assert (pargz);
assert (pargz_len);
assert (dp);
dir_len = LT_STRLEN (dirnam);
- end = dp->d_name + LT_D_NAMLEN(dp);
+ end = dp->d_name + LT_D_NAMLEN (dp);
/* Ignore version numbers. */
{
char *p;
- for (p = end; p -1 > dp->d_name; --p)
+ for (p = end; p - 1 > dp->d_name; --p)
if (strchr (".0123456789", p[-1]) == 0)
- break;
+ break;
if (*p == '.')
end = p;
@@ -3625,25 +3671,25 @@
/* Ignore filename extension. */
{
char *p;
- for (p = end -1; p > dp->d_name; --p)
+ for (p = end - 1; p > dp->d_name; --p)
if (*p == '.')
- {
- end = p;
- break;
- }
+ {
+ end = p;
+ break;
+ }
}
/* Prepend the directory name. */
- end_offset = end - dp->d_name;
- buf_len = dir_len + 1+ end_offset;
- buf = LT_EMALLOC (char, 1+ buf_len);
+ end_offset = end - dp->d_name;
+ buf_len = dir_len + 1 + end_offset;
+ buf = LT_EMALLOC (char, 1 + buf_len);
if (!buf)
return ++errors;
assert (buf);
- strcpy (buf, dirnam);
- strcat (buf, "/");
+ strcpy (buf, dirnam);
+ strcat (buf, "/");
strncat (buf, dp->d_name, end_offset);
buf[buf_len] = LT_EOS_CHAR;
@@ -3662,26 +3708,26 @@
char **pargz;
size_t *pargz_len;
{
- DIR *dirp = 0;
- int errors = 0;
+ DIR *dirp = 0;
+ int errors = 0;
assert (dirnam && *dirnam);
assert (pargz);
assert (pargz_len);
- assert (dirnam[LT_STRLEN(dirnam) -1] != '/');
+ assert (dirnam[LT_STRLEN (dirnam) - 1] != '/');
dirp = opendir (dirnam);
if (dirp)
{
- struct dirent *dp = 0;
+ struct dirent *dp = 0;
while ((dp = readdir (dirp)))
- if (dp->d_name[0] != '.')
- if (lt_argz_insertdir (pargz, pargz_len, dirnam, dp))
- {
- ++errors;
- break;
- }
+ if (dp->d_name[0] != '.')
+ if (lt_argz_insertdir (pargz, pargz_len, dirnam, dp))
+ {
+ ++errors;
+ break;
+ }
closedir (dirp);
}
@@ -3700,12 +3746,12 @@
lt_ptr data1;
lt_ptr data2;
{
- int (*func) LT_PARAMS((const char *filename, lt_ptr data))
- = (int (*) LT_PARAMS((const char *filename, lt_ptr data))) data1;
+ int (*func) LT_PARAMS ((const char *filename, lt_ptr data))
+ = (int (*)LT_PARAMS ((const char *filename, lt_ptr data))) data1;
- int is_done = 0;
- char *argz = 0;
- size_t argz_len = 0;
+ int is_done = 0;
+ char *argz = 0;
+ size_t argz_len = 0;
if (list_files_by_dir (dirname, &argz, &argz_len) != 0)
goto cleanup;
@@ -3716,10 +3762,10 @@
char *filename = 0;
while ((filename = argz_next (argz, argz_len, filename)))
if ((is_done = (*func) (filename, data2)))
- break;
+ break;
}
- cleanup:
+cleanup:
LT_DLFREE (argz);
return is_done;
@@ -3743,34 +3789,34 @@
if (search_path)
{
/* If a specific path was passed, search only the directories
- listed in it. */
+ listed in it. */
is_done = foreach_dirinpath (search_path, 0,
- foreachfile_callback, func, data);
+ foreachfile_callback, func, data);
}
else
{
/* Otherwise search the default paths. */
is_done = foreach_dirinpath (user_search_path, 0,
- foreachfile_callback, func, data);
+ foreachfile_callback, func, data);
if (!is_done)
- {
- is_done = foreach_dirinpath (getenv("LTDL_LIBRARY_PATH"), 0,
- foreachfile_callback, func, data);
- }
+ {
+ is_done = foreach_dirinpath (getenv ("LTDL_LIBRARY_PATH"), 0,
+ foreachfile_callback, func, data);
+ }
#ifdef LTDL_SHLIBPATH_VAR
if (!is_done)
- {
- is_done = foreach_dirinpath (getenv(LTDL_SHLIBPATH_VAR), 0,
- foreachfile_callback, func, data);
- }
+ {
+ is_done = foreach_dirinpath (getenv (LTDL_SHLIBPATH_VAR), 0,
+ foreachfile_callback, func, data);
+ }
#endif
#ifdef LTDL_SYSSEARCHPATH
if (!is_done)
- {
- is_done = foreach_dirinpath (getenv(LTDL_SYSSEARCHPATH), 0,
- foreachfile_callback, func, data);
- }
+ {
+ is_done = foreach_dirinpath (getenv (LTDL_SYSSEARCHPATH), 0,
+ foreachfile_callback, func, data);
+ }
#endif
}
@@ -3812,16 +3858,16 @@
lt_user_data data = handle->loader->dlloader_data;
if (handle != handles)
- {
- last->next = handle->next;
- }
+ {
+ last->next = handle->next;
+ }
else
- {
- handles = handle->next;
- }
+ {
+ handles = handle->next;
+ }
errors += handle->loader->module_close (data, handle->module);
- errors += unload_deplibs(handle);
+ errors += unload_deplibs (handle);
/* It is up to the callers to free the data itself. */
LT_DLFREE (handle->caller_data);
@@ -3839,7 +3885,7 @@
++errors;
}
- done:
+done:
LT_DLMUTEX_UNLOCK ();
return errors;
@@ -3851,8 +3897,8 @@
const char *symbol;
{
size_t lensym;
- char lsym[LT_SYMBOL_LENGTH];
- char *sym;
+ char lsym[LT_SYMBOL_LENGTH];
+ char *sym;
lt_ptr address;
lt_user_data data;
@@ -3869,7 +3915,7 @@
}
lensym = LT_STRLEN (symbol) + LT_STRLEN (handle->loader->sym_prefix)
- + LT_STRLEN (handle->info.name);
+ + LT_STRLEN (handle->info.name);
if (lensym + LT_SYMBOL_OVERHEAD < LT_SYMBOL_LENGTH)
{
@@ -3879,10 +3925,10 @@
{
sym = LT_EMALLOC (char, lensym + LT_SYMBOL_OVERHEAD + 1);
if (!sym)
- {
- LT_DLMUTEX_SETERROR (LT_DLSTRERROR (BUFFER_OVERFLOW));
- return 0;
- }
+ {
+ LT_DLMUTEX_SETERROR (LT_DLSTRERROR (BUFFER_OVERFLOW));
+ return 0;
+ }
}
data = handle->loader->dlloader_data;
@@ -3894,40 +3940,40 @@
/* this is a libtool module */
if (handle->loader->sym_prefix)
- {
- strcpy(sym, handle->loader->sym_prefix);
- strcat(sym, handle->info.name);
- }
+ {
+ strcpy (sym, handle->loader->sym_prefix);
+ strcat (sym, handle->info.name);
+ }
else
- {
- strcpy(sym, handle->info.name);
- }
+ {
+ strcpy (sym, handle->info.name);
+ }
- strcat(sym, "_LTX_");
- strcat(sym, symbol);
+ strcat (sym, "_LTX_");
+ strcat (sym, symbol);
/* try "modulename_LTX_symbol" */
address = handle->loader->find_sym (data, handle->module, sym);
if (address)
- {
- if (sym != lsym)
- {
- LT_DLFREE (sym);
- }
- return address;
- }
+ {
+ if (sym != lsym)
+ {
+ LT_DLFREE (sym);
+ }
+ return address;
+ }
LT_DLMUTEX_SETERROR (saved_error);
}
/* otherwise try "symbol" */
if (handle->loader->sym_prefix)
{
- strcpy(sym, handle->loader->sym_prefix);
- strcat(sym, symbol);
+ strcpy (sym, handle->loader->sym_prefix);
+ strcat (sym, symbol);
}
else
{
- strcpy(sym, symbol);
+ strcpy (sym, symbol);
}
address = handle->loader->find_sym (data, handle->module, sym);
@@ -3956,10 +4002,10 @@
char *before;
const char *dir;
{
- int errors = 0;
- char *canonical = 0;
- char *argz = 0;
- size_t argz_len = 0;
+ int errors = 0;
+ char *canonical = 0;
+ char *argz = 0;
+ size_t argz_len = 0;
assert (ppath);
assert (dir && *dir);
@@ -3975,12 +4021,12 @@
/* If *PPATH is empty, set it to DIR. */
if (*ppath == 0)
{
- assert (!before); /* BEFORE cannot be set without PPATH.
*/
- assert (dir); /* Without DIR, don't call this function! */
+ assert (!before); /* BEFORE cannot be set without PPATH. */
+ assert (dir); /* Without DIR, don't call this function! */
*ppath = lt_estrdup (dir);
if (*ppath == 0)
- ++errors;
+ ++errors;
return errors;
}
@@ -4013,9 +4059,9 @@
}
argz_stringify (argz, argz_len, LT_PATHSEP_CHAR);
- LT_DLMEM_REASSIGN (*ppath, argz);
+ LT_DLMEM_REASSIGN (*ppath, argz);
- cleanup:
+cleanup:
LT_DLFREE (canonical);
LT_DLFREE (argz);
@@ -4032,7 +4078,7 @@
{
LT_DLMUTEX_LOCK ();
if (lt_dlpath_insertdir (&user_search_path, 0, search_dir) != 0)
- ++errors;
+ ++errors;
LT_DLMUTEX_UNLOCK ();
}
@@ -4050,12 +4096,12 @@
{
LT_DLMUTEX_LOCK ();
if ((before < user_search_path)
- || (before >= user_search_path + LT_STRLEN (user_search_path)))
- {
- LT_DLMUTEX_UNLOCK ();
- LT_DLMUTEX_SETERROR (LT_DLSTRERROR (INVALID_POSITION));
- return 1;
- }
+ || (before >= user_search_path + LT_STRLEN (user_search_path)))
+ {
+ LT_DLMUTEX_UNLOCK ();
+ LT_DLMUTEX_SETERROR (LT_DLSTRERROR (INVALID_POSITION));
+ return 1;
+ }
LT_DLMUTEX_UNLOCK ();
}
@@ -4063,10 +4109,10 @@
{
LT_DLMUTEX_LOCK ();
if (lt_dlpath_insertdir (&user_search_path,
- (char *) before, search_dir) != 0)
- {
- ++errors;
- }
+ (char *) before, search_dir) != 0)
+ {
+ ++errors;
+ }
LT_DLMUTEX_UNLOCK ();
}
@@ -4077,7 +4123,7 @@
lt_dlsetsearchpath (search_path)
const char *search_path;
{
- int errors = 0;
+ int errors = 0;
LT_DLMUTEX_LOCK ();
LT_DLFREE (user_search_path);
@@ -4128,7 +4174,7 @@
}
int
-lt_dlisresident (handle)
+lt_dlisresident (handle)
lt_dlhandle handle;
{
if (!handle)
@@ -4139,10 +4185,10 @@
return LT_DLIS_RESIDENT (handle);
}
+
-
/* --- MODULE INFORMATION --- */
const lt_dlinfo *
@@ -4167,7 +4213,7 @@
int
lt_dlforeach (func, data)
- int (*func) LT_PARAMS((lt_dlhandle handle, lt_ptr data));
+ int (*func) LT_PARAMS ((lt_dlhandle handle, lt_ptr data));
lt_ptr data;
{
int errors = 0;
@@ -4182,10 +4228,10 @@
cur = cur->next;
if ((*func) (tmp, data))
- {
- ++errors;
- break;
- }
+ {
+ ++errors;
+ break;
+ }
}
LT_DLMUTEX_UNLOCK ();
@@ -4227,10 +4273,10 @@
for (i = 0; i < n_elements; ++i)
{
if (handle->caller_data[i].key == key)
- {
- stale = handle->caller_data[i].data;
- break;
- }
+ {
+ stale = handle->caller_data[i].data;
+ break;
+ }
}
/* Ensure that there is enough room in this handle's caller_data
@@ -4238,31 +4284,31 @@
if (i == n_elements)
{
lt_caller_data *temp
- = LT_DLREALLOC (lt_caller_data, handle->caller_data, 2+ n_elements);
+ = LT_DLREALLOC (lt_caller_data, handle->caller_data, 2 + n_elements);
if (!temp)
- {
- stale = 0;
- goto done;
- }
+ {
+ stale = 0;
+ goto done;
+ }
handle->caller_data = temp;
/* We only need this if we needed to allocate a new caller_data. */
- handle->caller_data[i].key = key;
- handle->caller_data[1+ i].key = 0;
+ handle->caller_data[i].key = key;
+ handle->caller_data[1 + i].key = 0;
}
handle->caller_data[i].data = data;
- done:
+done:
LT_DLMUTEX_UNLOCK ();
return stale;
}
lt_ptr
-lt_dlcaller_get_data (key, handle)
+lt_dlcaller_get_data (key, handle)
lt_dlcaller_id key;
lt_dlhandle handle;
{
@@ -4277,11 +4323,11 @@
int i;
for (i = 0; handle->caller_data[i].key; ++i)
{
- if (handle->caller_data[i].key == key)
- {
- result = handle->caller_data[i].data;
- break;
- }
+ if (handle->caller_data[i].key == key)
+ {
+ result = handle->caller_data[i].data;
+ break;
+ }
}
}
@@ -4289,9 +4335,9 @@
return result;
}
+
-
/* --- USER MODULE LOADER API --- */
@@ -4304,10 +4350,9 @@
int errors = 0;
lt_dlloader *node = 0, *ptr = 0;
- if ((dlloader == 0) /* diagnose null parameters */
+ if ((dlloader == 0) /* diagnose null parameters */
|| (dlloader->module_open == 0)
- || (dlloader->module_close == 0)
- || (dlloader->find_sym == 0))
+ || (dlloader->module_close == 0) || (dlloader->find_sym == 0))
{
LT_DLMUTEX_SETERROR (LT_DLSTRERROR (INVALID_LOADER));
return 1;
@@ -4318,14 +4363,14 @@
if (!node)
return 1;
- node->next = 0;
- node->loader_name = loader_name;
- node->sym_prefix = dlloader->sym_prefix;
- node->dlloader_exit = dlloader->dlloader_exit;
- node->module_open = dlloader->module_open;
- node->module_close = dlloader->module_close;
- node->find_sym = dlloader->find_sym;
- node->dlloader_data = dlloader->dlloader_data;
+ node->next = 0;
+ node->loader_name = loader_name;
+ node->sym_prefix = dlloader->sym_prefix;
+ node->dlloader_exit = dlloader->dlloader_exit;
+ node->module_open = dlloader->module_open;
+ node->module_close = dlloader->module_close;
+ node->find_sym = dlloader->find_sym;
+ node->dlloader_data = dlloader->dlloader_data;
LT_DLMUTEX_LOCK ();
if (!loaders)
@@ -4336,11 +4381,11 @@
else if (!place)
{
/* If PLACE is not set, add NODE to the end of the
- LOADERS list. */
+ LOADERS list. */
for (ptr = loaders; ptr->next; ptr = ptr->next)
- {
- /*NOWORK*/;
- }
+ {
+ /*NOWORK*/;
+ }
ptr->next = node;
}
@@ -4354,21 +4399,21 @@
{
/* Find the node immediately preceding PLACE. */
for (ptr = loaders; ptr->next != place; ptr = ptr->next)
- {
- /*NOWORK*/;
- }
+ {
+ /*NOWORK*/;
+ }
if (ptr->next != place)
- {
- LT_DLMUTEX_SETERROR (LT_DLSTRERROR (INVALID_LOADER));
- ++errors;
- }
+ {
+ LT_DLMUTEX_SETERROR (LT_DLSTRERROR (INVALID_LOADER));
+ ++errors;
+ }
else
- {
- /* Insert NODE between PTR and PLACE. */
- node->next = place;
- ptr->next = node;
- }
+ {
+ /* Insert NODE between PTR and PLACE. */
+ node->next = place;
+ ptr->next = node;
+ }
}
LT_DLMUTEX_UNLOCK ();
@@ -4393,14 +4438,14 @@
LT_DLMUTEX_LOCK ();
/* Fail if there are any open modules which use this loader. */
- for (handle = handles; handle; handle = handle->next)
+ for (handle = handles; handle; handle = handle->next)
{
if (handle->loader == place)
- {
- LT_DLMUTEX_SETERROR (LT_DLSTRERROR (REMOVE_LOADER));
- ++errors;
- goto done;
- }
+ {
+ LT_DLMUTEX_SETERROR (LT_DLSTRERROR (REMOVE_LOADER));
+ ++errors;
+ goto done;
+ }
}
if (place == loaders)
@@ -4413,12 +4458,12 @@
/* Find the loader before the one being removed. */
lt_dlloader *prev;
for (prev = loaders; prev->next; prev = prev->next)
- {
- if (!strcmp (prev->next->loader_name, loader_name))
- {
- break;
- }
- }
+ {
+ if (!strcmp (prev->next->loader_name, loader_name))
+ {
+ break;
+ }
+ }
place = prev->next;
prev->next = prev->next->next;
@@ -4431,7 +4476,7 @@
LT_DLFREE (place);
- done:
+done:
LT_DLMUTEX_UNLOCK ();
return errors;
@@ -4500,9 +4545,9 @@
for (place = loaders; place; place = place->next)
{
if (strcmp (place->loader_name, loader_name) == 0)
- {
- break;
- }
+ {
+ break;
+ }
}
LT_DLMUTEX_UNLOCK ();
Modified: Extractor/src/plugins/asfextractor.c
===================================================================
--- Extractor/src/plugins/asfextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/asfextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -132,235 +132,318 @@
typedef unsigned long long ext_uint64_t;
-typedef unsigned int ext_uint32_t ;
-typedef unsigned short ext_uint16_t ;
+typedef unsigned int ext_uint32_t;
+typedef unsigned short ext_uint16_t;
typedef unsigned char ext_uint8_t;
-typedef struct {
+typedef struct
+{
ext_uint32_t v1;
ext_uint16_t v2;
ext_uint16_t v3;
- ext_uint8_t v4[8];
+ ext_uint8_t v4[8];
} LE_GUID;
static const struct
{
- const char* name;
- const LE_GUID guid;
+ const char *name;
+ const LE_GUID guid;
} guids[] =
{
- { "error",
- { 0x0,} },
-
-
+ {
+ "error",
+ {
+ 0x0,}},
/* base ASF objects */
- { "header",
- { 0x75b22630, 0x668e, 0x11cf, { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce,
0x6c }} },
-
- { "data",
- { 0x75b22636, 0x668e, 0x11cf, { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce,
0x6c }} },
-
- { "simple index",
- { 0x33000890, 0xe5b1, 0x11cf, { 0x89, 0xf4, 0x00, 0xa0, 0xc9, 0x03, 0x49,
0xcb }} },
-
-
+ {
+ "header",
+ {
+ 0x75b22630, 0x668e, 0x11cf,
+ {
+ 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}}},
+ {
+ "data",
+ {
+ 0x75b22636, 0x668e, 0x11cf,
+ {
+ 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}}},
+ {
+ "simple index",
+ {
+ 0x33000890, 0xe5b1, 0x11cf,
+ {
+ 0x89, 0xf4, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xcb}}},
/* header ASF objects */
- { "file properties",
- { 0x8cabdca1, 0xa947, 0x11cf, { 0x8e, 0xe4, 0x00, 0xc0, 0x0c, 0x20, 0x53,
0x65 }} },
-
- { "stream header",
- { 0xb7dc0791, 0xa9b7, 0x11cf, { 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53,
0x65 }} },
-
- { "stream bitrate properties", /* (http://get.to/sdp) */
- { 0x7bf875ce, 0x468d, 0x11d1, { 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2,
0xb2 }} },
-
- { "content description",
- { 0x75b22633, 0x668e, 0x11cf, { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce,
0x6c }} },
-
- { "extended content encryption",
- { 0x298ae614, 0x2622, 0x4c17, { 0xb9, 0x35, 0xda, 0xe0, 0x7e, 0xe9, 0x28,
0x9c }} },
-
- { "script command",
- { 0x1efb1a30, 0x0b62, 0x11d0, { 0xa3, 0x9b, 0x00, 0xa0, 0xc9, 0x03, 0x48,
0xf6 }} },
-
- { "marker",
- { 0xf487cd01, 0xa951, 0x11cf, { 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53,
0x65 }} },
-
- { "header extension",
- { 0x5fbf03b5, 0xa92e, 0x11cf, { 0x8e, 0xe3, 0x00, 0xc0, 0x0c, 0x20, 0x53,
0x65 }} },
-
- { "bitrate mutual exclusion",
- { 0xd6e229dc, 0x35da, 0x11d1, { 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49,
0xbe }} },
-
- { "codec list",
- { 0x86d15240, 0x311d, 0x11d0, { 0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48,
0xf6 }} },
-
- { "extended content description",
- { 0xd2d0a440, 0xe307, 0x11d2, { 0x97, 0xf0, 0x00, 0xa0, 0xc9, 0x5e, 0xa8,
0x50 }} },
-
- { "error correction",
- { 0x75b22635, 0x668e, 0x11cf, { 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce,
0x6c }} },
-
- { "padding",
- { 0x1806d474, 0xcadf, 0x4509, { 0xa4, 0xba, 0x9a, 0xab, 0xcb, 0x96, 0xaa,
0xe8 }} },
-
-
+ {
+ "file properties",
+ {
+ 0x8cabdca1, 0xa947, 0x11cf,
+ {
+ 0x8e, 0xe4, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65}}},
+ {
+ "stream header",
+ {
+ 0xb7dc0791, 0xa9b7, 0x11cf,
+ {
+ 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65}}},
+ {
+ "stream bitrate properties", /* (http://get.to/sdp) */
+ {
+ 0x7bf875ce, 0x468d, 0x11d1,
+ {
+ 0x8d, 0x82, 0x00, 0x60, 0x97, 0xc9, 0xa2, 0xb2}}},
+ {
+ "content description",
+ {
+ 0x75b22633, 0x668e, 0x11cf,
+ {
+ 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}}},
+ {
+ "extended content encryption",
+ {
+ 0x298ae614, 0x2622, 0x4c17,
+ {
+ 0xb9, 0x35, 0xda, 0xe0, 0x7e, 0xe9, 0x28, 0x9c}}},
+ {
+ "script command",
+ {
+ 0x1efb1a30, 0x0b62, 0x11d0,
+ {
+ 0xa3, 0x9b, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6}}},
+ {
+ "marker",
+ {
+ 0xf487cd01, 0xa951, 0x11cf,
+ {
+ 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65}}},
+ {
+ "header extension",
+ {
+ 0x5fbf03b5, 0xa92e, 0x11cf,
+ {
+ 0x8e, 0xe3, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65}}},
+ {
+ "bitrate mutual exclusion",
+ {
+ 0xd6e229dc, 0x35da, 0x11d1,
+ {
+ 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe}}},
+ {
+ "codec list",
+ {
+ 0x86d15240, 0x311d, 0x11d0,
+ {
+ 0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6}}},
+ {
+ "extended content description",
+ {
+ 0xd2d0a440, 0xe307, 0x11d2,
+ {
+ 0x97, 0xf0, 0x00, 0xa0, 0xc9, 0x5e, 0xa8, 0x50}}},
+ {
+ "error correction",
+ {
+ 0x75b22635, 0x668e, 0x11cf,
+ {
+ 0xa6, 0xd9, 0x00, 0xaa, 0x00, 0x62, 0xce, 0x6c}}},
+ {
+ "padding",
+ {
+ 0x1806d474, 0xcadf, 0x4509,
+ {
+ 0xa4, 0xba, 0x9a, 0xab, 0xcb, 0x96, 0xaa, 0xe8}}},
/* stream properties object stream type */
- { "audio media",
- { 0xf8699e40, 0x5b4d, 0x11cf, { 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44,
0x2b }} },
-
- { "video media",
- { 0xbc19efc0, 0x5b4d, 0x11cf, { 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44,
0x2b }} },
-
- { "command media",
- { 0x59dacfc0, 0x59e6, 0x11d0, { 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48,
0xf6 }} },
-
-
+ {
+ "audio media",
+ {
+ 0xf8699e40, 0x5b4d, 0x11cf,
+ {
+ 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b}}},
+ {
+ "video media",
+ {
+ 0xbc19efc0, 0x5b4d, 0x11cf,
+ {
+ 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b}}},
+ {
+ "command media",
+ {
+ 0x59dacfc0, 0x59e6, 0x11d0,
+ {
+ 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6}}},
/* stream properties object error correction */
- { "no error correction",
- { 0x20fb5700, 0x5b55, 0x11cf, { 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44,
0x2b }} },
-
- { "audio spread",
- { 0xbfc3cd50, 0x618f, 0x11cf, { 0x8b, 0xb2, 0x00, 0xaa, 0x00, 0xb4, 0xe2,
0x20 }} },
-
-
+ {
+ "no error correction",
+ {
+ 0x20fb5700, 0x5b55, 0x11cf,
+ {
+ 0xa8, 0xfd, 0x00, 0x80, 0x5f, 0x5c, 0x44, 0x2b}}},
+ {
+ "audio spread",
+ {
+ 0xbfc3cd50, 0x618f, 0x11cf,
+ {
+ 0x8b, 0xb2, 0x00, 0xaa, 0x00, 0xb4, 0xe2, 0x20}}},
/* mutual exclusion object exlusion type */
- { "mutex bitrate",
- { 0xd6e22a01, 0x35da, 0x11d1, { 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49,
0xbe }} },
-
- { "mutex unknown",
- { 0xd6e22a02, 0x35da, 0x11d1, { 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49,
0xbe }} },
-
-
+ {
+ "mutex bitrate",
+ {
+ 0xd6e22a01, 0x35da, 0x11d1,
+ {
+ 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe}}},
+ {
+ "mutex unknown",
+ {
+ 0xd6e22a02, 0x35da, 0x11d1,
+ {
+ 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe}}},
/* header extension */
- { "reserved_1",
- { 0xabd3d211, 0xa9ba, 0x11cf, { 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53,
0x65 }} },
-
-
+ {
+ "reserved_1",
+ {
+ 0xabd3d211, 0xa9ba, 0x11cf,
+ {
+ 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53, 0x65}}},
/* script command */
- { "reserved script command",
- { 0x4B1ACBE3, 0x100B, 0x11D0, { 0xA3, 0x9B, 0x00, 0xA0, 0xC9, 0x03, 0x48,
0xF6 }} },
-
+ {
+ "reserved script command",
+ {
+ 0x4B1ACBE3, 0x100B, 0x11D0,
+ {
+ 0xA3, 0x9B, 0x00, 0xA0, 0xC9, 0x03, 0x48, 0xF6}}},
/* marker object */
- { "reserved marker",
- { 0x4CFEDB20, 0x75F6, 0x11CF, { 0x9C, 0x0F, 0x00, 0xA0, 0xC9, 0x03, 0x49,
0xCB }} },
-
+ {
+ "reserved marker",
+ {
+ 0x4CFEDB20, 0x75F6, 0x11CF,
+ {
+ 0x9C, 0x0F, 0x00, 0xA0, 0xC9, 0x03, 0x49, 0xCB}}},
/* various */
/* Already defined (reserved_1)
- { "head2",
- { 0xabd3d211, 0xa9ba, 0x11cf, { 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20, 0x53,
0x65 }} },
- */
- { "audio conceal none",
- { 0x49f1a440, 0x4ece, 0x11d0, { 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48,
0xf6 }} },
+ { "head2",
+ { 0xabd3d211, 0xa9ba, 0x11cf, { 0x8e, 0xe6, 0x00, 0xc0, 0x0c, 0x20,
0x53, 0x65 }} },
+ */
+ {
+ "audio conceal none",
+ {
+ 0x49f1a440, 0x4ece, 0x11d0,
+ {
+ 0xa3, 0xac, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6}}},
+ {
+ "codec comment1 header",
+ {
+ 0x86d15241, 0x311d, 0x11d0,
+ {
+ 0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48, 0xf6}}},
+ {
+ "asf 2.0 header",
+ {
+ 0xd6e229d1, 0x35da, 0x11d1,
+ {
+0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49, 0xbe}}},};
- { "codec comment1 header",
- { 0x86d15241, 0x311d, 0x11d0, { 0xa3, 0xa4, 0x00, 0xa0, 0xc9, 0x03, 0x48,
0xf6 }} },
+typedef struct
+{
+ int num;
+ int seq;
- { "asf 2.0 header",
- { 0xd6e229d1, 0x35da, 0x11d1, { 0x90, 0x34, 0x00, 0xa0, 0xc9, 0x03, 0x49,
0xbe }} },
+ int frag_offset;
+ int64_t timestamp;
+ int ts_per_kbyte;
+ int defrag;
-};
+ ext_uint32_t buf_type;
+ int stream_id;
-typedef struct {
- int num;
- int seq;
-
- int frag_offset;
- int64_t timestamp;
- int ts_per_kbyte;
- int defrag;
-
- ext_uint32_t buf_type;
- int stream_id;
-
- ext_uint8_t *buffer;
+ ext_uint8_t *buffer;
} asf_stream_t;
-typedef struct demux_asf_s {
+typedef struct demux_asf_s
+{
/* pointer to the stream data */
- char * input;
+ char *input;
/* current position in stream */
size_t inputPos;
size_t inputLen;
- int keyframe_found;
+ int keyframe_found;
- int seqno;
- ext_uint32_t packet_size;
- ext_uint8_t packet_flags;
- ext_uint32_t data_size;
+ int seqno;
+ ext_uint32_t packet_size;
+ ext_uint8_t packet_flags;
+ ext_uint32_t data_size;
- ext_uint32_t bitrates[MAX_NUM_STREAMS];
- int num_streams;
- int num_audio_streams;
- int num_video_streams;
- int audio_stream;
- int video_stream;
- int audio_stream_id;
- int video_stream_id;
- int control_stream_id;
+ ext_uint32_t bitrates[MAX_NUM_STREAMS];
+ int num_streams;
+ int num_audio_streams;
+ int num_video_streams;
+ int audio_stream;
+ int video_stream;
+ int audio_stream_id;
+ int video_stream_id;
+ int control_stream_id;
- ext_uint16_t wavex[1024];
- int wavex_size;
+ ext_uint16_t wavex[1024];
+ int wavex_size;
- char title[512];
- char author[512];
- char copyright[512];
- char comment[512];
+ char title[512];
+ char author[512];
+ char copyright[512];
+ char comment[512];
- ext_uint32_t length, rate;
+ ext_uint32_t length, rate;
/* packet filling */
- int packet_size_left;
+ int packet_size_left;
/* frame rate calculations, discontinuity detection */
- int64_t last_pts[2];
- int32_t frame_duration;
- int send_newpts;
- int64_t last_frame_pts;
+ int64_t last_pts[2];
+ int32_t frame_duration;
+ int send_newpts;
+ int64_t last_frame_pts;
/* only for reading */
- ext_uint32_t packet_padsize;
- int nb_frames;
- ext_uint8_t frame_flag;
- ext_uint8_t segtype;
- int frame;
+ ext_uint32_t packet_padsize;
+ int nb_frames;
+ ext_uint8_t frame_flag;
+ ext_uint8_t segtype;
+ int frame;
- int status;
+ int status;
/* byte reordering from audio streams */
- int reorder_h;
- int reorder_w;
- int reorder_b;
+ int reorder_h;
+ int reorder_w;
+ int reorder_b;
- off_t header_size;
- int buf_flag_seek;
+ off_t header_size;
+ int buf_flag_seek;
/* first packet position */
- int64_t first_packet_pos;
+ int64_t first_packet_pos;
- int reference_mode;
-} demux_asf_t ;
+ int reference_mode;
+} demux_asf_t;
-static int readBuf(demux_asf_t * this,
- void * buf,
- int len) {
+static int
+readBuf (demux_asf_t * this, void *buf, int len)
+{
int min;
min = len;
if (this->inputLen - this->inputPos < min)
min = this->inputLen - this->inputPos;
- memcpy(buf,
- &this->input[this->inputPos],
- min);
+ memcpy (buf, &this->input[this->inputPos], min);
this->inputPos += min;
return min;
}
-static ext_uint8_t get_byte (demux_asf_t *this) {
+static ext_uint8_t
+get_byte (demux_asf_t * this)
+{
ext_uint8_t buf;
- int i;
+ int i;
i = readBuf (this, &buf, 1);
if (i != 1)
@@ -368,9 +451,11 @@
return buf;
}
-static ext_uint16_t get_le16 (demux_asf_t *this) {
+static ext_uint16_t
+get_le16 (demux_asf_t * this)
+{
ext_uint8_t buf[2];
- int i;
+ int i;
i = readBuf (this, buf, 2);
if (i != 2)
@@ -378,9 +463,11 @@
return buf[0] | (buf[1] << 8);
}
-static ext_uint32_t get_le32 (demux_asf_t *this) {
+static ext_uint32_t
+get_le32 (demux_asf_t * this)
+{
ext_uint8_t buf[4];
- int i;
+ int i;
i = readBuf (this, buf, 4);
if (i != 4)
@@ -388,9 +475,11 @@
return buf[0] | (buf[1] << 8) | (buf[2] << 16) | (buf[3] << 24);
}
-static ext_uint64_t get_le64 (demux_asf_t *this) {
+static ext_uint64_t
+get_le64 (demux_asf_t * this)
+{
ext_uint8_t buf[8];
- int i;
+ int i;
i = readBuf (this, buf, 8);
if (i != 8)
@@ -401,226 +490,243 @@
| ((ext_uint64_t) buf[3] << 24)
| ((ext_uint64_t) buf[4] << 32)
| ((ext_uint64_t) buf[5] << 40)
- | ((ext_uint64_t) buf[6] << 48)
- | ((ext_uint64_t) buf[7] << 54) ;
+ | ((ext_uint64_t) buf[6] << 48) | ((ext_uint64_t) buf[7] << 54);
}
-static int get_guid (demux_asf_t *this) {
+static int
+get_guid (demux_asf_t * this)
+{
int i;
LE_GUID g;
- g.v1 = get_le32(this);
- g.v2 = get_le16(this);
- g.v3 = get_le16(this);
- for(i = 0; i < 8; i++)
- g.v4[i] = get_byte(this);
+ g.v1 = get_le32 (this);
+ g.v2 = get_le16 (this);
+ g.v3 = get_le16 (this);
+ for (i = 0; i < 8; i++)
+ g.v4[i] = get_byte (this);
if (this->status == DEMUX_FINISHED)
return GUID_ERROR;
for (i = 1; i < GUID_END; i++)
- if (!memcmp(&g, &guids[i].guid, sizeof(LE_GUID)))
+ if (!memcmp (&g, &guids[i].guid, sizeof (LE_GUID)))
return i;
return GUID_ERROR;
}
-static void get_str16_nolen(demux_asf_t *this,
- int len,
- char *buf,
- int buf_size) {
+static void
+get_str16_nolen (demux_asf_t * this, int len, char *buf, int buf_size)
+{
int c;
char *q;
q = buf;
- while (len > 0) {
- c = get_le16(this);
- if ((q - buf) < buf_size - 1)
- *q++ = c;
- len-=2;
- }
+ while (len > 0)
+ {
+ c = get_le16 (this);
+ if ((q - buf) < buf_size - 1)
+ *q++ = c;
+ len -= 2;
+ }
*q = '\0';
}
-static int asf_read_header(demux_asf_t *this) {
- int guid;
- ext_uint64_t gsize;
+static int
+asf_read_header (demux_asf_t * this)
+{
+ int guid;
+ ext_uint64_t gsize;
- guid = get_guid(this);
+ guid = get_guid (this);
if (guid != GUID_ASF_HEADER)
return 0;
- get_le64(this);
- get_le32(this);
- get_byte(this);
- get_byte(this);
+ get_le64 (this);
+ get_le32 (this);
+ get_byte (this);
+ get_byte (this);
- while (this->status != DEMUX_FINISHED) {
- guid = get_guid(this);
- gsize = get_le64(this);
+ while (this->status != DEMUX_FINISHED)
+ {
+ guid = get_guid (this);
+ gsize = get_le64 (this);
- if (gsize < 24)
- goto fail;
+ if (gsize < 24)
+ goto fail;
- switch (guid) {
- case GUID_ASF_FILE_PROPERTIES:
+ switch (guid)
{
- ext_uint64_t start_time, end_time;
+ case GUID_ASF_FILE_PROPERTIES:
+ {
+ ext_uint64_t start_time, end_time;
- guid = get_guid(this);
- get_le64(this); /* file size */
- get_le64(this); /* file time */
- get_le64(this); /* nb_packets */
+ guid = get_guid (this);
+ get_le64 (this); /* file size */
+ get_le64 (this); /* file time */
+ get_le64 (this); /* nb_packets */
- end_time = get_le64 (this);
+ end_time = get_le64 (this);
- this->length = get_le64(this) / 10000;
- if (this->length)
- this->rate = this->inputLen / (this->length / 1000);
- else
- this->rate = 0;
+ this->length = get_le64 (this) / 10000;
+ if (this->length)
+ this->rate = this->inputLen / (this->length / 1000);
+ else
+ this->rate = 0;
- start_time = get_le32(this); /* start timestamp in 1/1000 s*/
+ start_time = get_le32 (this); /* start timestamp in 1/1000 s
*/
- get_le32(this); /* unknown */
- get_le32(this); /* min size */
- this->packet_size = get_le32(this); /* max size */
- get_le32(this); /* max bitrate */
- get_le32(this);
- }
- break;
+ get_le32 (this); /* unknown */
+ get_le32 (this); /* min size */
+ this->packet_size = get_le32 (this); /* max size */
+ get_le32 (this); /* max bitrate */
+ get_le32 (this);
+ }
+ break;
- case (GUID_ASF_STREAM_PROPERTIES):
- {
- int type;
- ext_uint32_t total_size, stream_data_size;
- ext_uint16_t stream_id;
- ext_uint64_t pos1, pos2;
- pos1 = this->inputPos;
+ case (GUID_ASF_STREAM_PROPERTIES):
+ {
+ int type;
+ ext_uint32_t total_size, stream_data_size;
+ ext_uint16_t stream_id;
+ ext_uint64_t pos1, pos2;
+ pos1 = this->inputPos;
- guid = get_guid(this);
- switch (guid) {
- case GUID_ASF_AUDIO_MEDIA:
- type = CODEC_TYPE_AUDIO;
- break;
+ guid = get_guid (this);
+ switch (guid)
+ {
+ case GUID_ASF_AUDIO_MEDIA:
+ type = CODEC_TYPE_AUDIO;
+ break;
- case GUID_ASF_VIDEO_MEDIA:
- type = CODEC_TYPE_VIDEO;
- break;
+ case GUID_ASF_VIDEO_MEDIA:
+ type = CODEC_TYPE_VIDEO;
+ break;
- case GUID_ASF_COMMAND_MEDIA:
- type = CODEC_TYPE_CONTROL;
- break;
+ case GUID_ASF_COMMAND_MEDIA:
+ type = CODEC_TYPE_CONTROL;
+ break;
- default:
+ default:
+ goto fail;
+ }
+
+ guid = get_guid (this);
+ get_le64 (this);
+ total_size = get_le32 (this);
+ if (total_size > sizeof (this->wavex))
goto fail;
- }
+ stream_data_size = get_le32 (this);
+ stream_id = get_le16 (this); /* stream id */
+ get_le32 (this);
- guid = get_guid(this);
- get_le64(this);
- total_size = get_le32(this);
- if (total_size > sizeof(this->wavex))
- goto fail;
- stream_data_size = get_le32(this);
- stream_id = get_le16(this); /* stream id */
- get_le32(this);
+ if (type == CODEC_TYPE_AUDIO)
+ {
+ ext_uint8_t buffer[6];
- if (type == CODEC_TYPE_AUDIO) {
- ext_uint8_t buffer[6];
+ readBuf (this, (ext_uint8_t *) this->wavex, total_size);
+ if (guid == GUID_ASF_AUDIO_SPREAD)
+ {
+ readBuf (this, buffer, 6);
+ this->reorder_h = buffer[0];
+ this->reorder_w = (buffer[2] << 8) | buffer[1];
+ this->reorder_b = (buffer[4] << 8) | buffer[3];
+ this->reorder_w /= this->reorder_b;
+ }
+ else
+ {
+ this->reorder_b = this->reorder_h = this->reorder_w = 1;
+ }
- readBuf (this, (ext_uint8_t *) this->wavex, total_size);
- if (guid == GUID_ASF_AUDIO_SPREAD) {
- readBuf (this, buffer, 6);
- this->reorder_h = buffer[0];
- this->reorder_w = (buffer[2]<<8)|buffer[1];
- this->reorder_b = (buffer[4]<<8)|buffer[3];
- this->reorder_w /= this->reorder_b;
- } else {
- this->reorder_b=this->reorder_h=this->reorder_w=1;
- }
+ this->wavex_size = total_size; /* 18 + this->wavex[8]; */
+ this->num_audio_streams++;
+ }
+ else if (type == CODEC_TYPE_VIDEO)
+ {
- this->wavex_size = total_size; /* 18 + this->wavex[8]; */
- this->num_audio_streams++;
- }
- else if (type == CODEC_TYPE_VIDEO) {
+ ext_uint16_t i;
- ext_uint16_t i;
+ get_le32 (this); /* width */
+ get_le32 (this); /* height */
+ get_byte (this);
- get_le32(this); /* width */
- get_le32(this); /* height */
- get_byte(this);
+ i = get_le16 (this); /* size */
+ this->inputPos += i;
+ this->num_video_streams++;
+ }
+ else if (type == CODEC_TYPE_CONTROL)
+ {
+ this->control_stream_id = stream_id;
+ }
- i = get_le16(this); /* size */
- this->inputPos += i;
- this->num_video_streams++;
+ this->num_streams++;
+ pos2 = this->inputPos;
+ this->inputPos += gsize - (pos2 - pos1 + 24);
}
- else if (type == CODEC_TYPE_CONTROL) {
- this->control_stream_id = stream_id;
- }
+ break;
- this->num_streams++;
- pos2 = this->inputPos;
- this->inputPos += gsize - (pos2 - pos1 + 24);
- }
- break;
+ case GUID_ASF_DATA:
+ goto headers_ok;
+ break;
+ case GUID_ASF_CONTENT_DESCRIPTION:
+ {
+ ext_uint16_t len1, len2, len3, len4, len5;
- case GUID_ASF_DATA:
- goto headers_ok;
- break;
- case GUID_ASF_CONTENT_DESCRIPTION: {
- ext_uint16_t len1, len2, len3, len4, len5;
+ len1 = get_le16 (this);
+ len2 = get_le16 (this);
+ len3 = get_le16 (this);
+ len4 = get_le16 (this);
+ len5 = get_le16 (this);
+ get_str16_nolen (this, len1, this->title, sizeof (this->title));
+ get_str16_nolen (this, len2, this->author, sizeof (this->author));
+ get_str16_nolen (this, len3, this->copyright,
+ sizeof (this->copyright));
+ get_str16_nolen (this, len4, this->comment,
+ sizeof (this->comment));
+ this->inputPos += len5;
+ }
+ break;
- len1 = get_le16(this);
- len2 = get_le16(this);
- len3 = get_le16(this);
- len4 = get_le16(this);
- len5 = get_le16(this);
- get_str16_nolen(this, len1, this->title, sizeof(this->title));
- get_str16_nolen(this, len2, this->author, sizeof(this->author));
- get_str16_nolen(this, len3, this->copyright,
sizeof(this->copyright));
- get_str16_nolen(this, len4, this->comment, sizeof(this->comment));
- this->inputPos += len5;
- }
- break;
+ case GUID_ASF_STREAM_BITRATE_PROPERTIES:
+ {
+ ext_uint16_t streams, stream_id;
+ ext_uint16_t i;
- case GUID_ASF_STREAM_BITRATE_PROPERTIES:
- {
- ext_uint16_t streams, stream_id;
- ext_uint16_t i;
+ streams = get_le16 (this);
+ for (i = 0; i < streams; i++)
+ {
+ stream_id = get_le16 (this);
+ this->bitrates[stream_id] = get_le32 (this);
+ }
+ }
+ break;
- streams = get_le16(this);
- for (i = 0; i < streams; i++) {
- stream_id = get_le16(this);
- this->bitrates[stream_id] = get_le32(this);
- }
+ default:
+ this->inputPos += gsize - 24;
}
- break;
-
- default:
- this->inputPos += gsize - 24;
}
- }
- headers_ok:
- this->inputPos += sizeof(LE_GUID) + 10;
+headers_ok:
+ this->inputPos += sizeof (LE_GUID) + 10;
this->packet_size_left = 0;
this->first_packet_pos = this->inputPos;
return 1;
- fail:
+fail:
return 0;
}
-static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordType type,
- char * keyword,
- struct EXTRACTOR_Keywords * next)
{
- EXTRACTOR_KeywordList * result;
+static struct EXTRACTOR_Keywords *
+addKeyword (EXTRACTOR_KeywordType type,
+ char *keyword, struct EXTRACTOR_Keywords *next)
+{
+ EXTRACTOR_KeywordList *result;
if (keyword == NULL)
return next;
- result = malloc(sizeof(EXTRACTOR_KeywordList));
+ result = malloc (sizeof (EXTRACTOR_KeywordList));
result->next = next;
- result->keyword = strdup(keyword);
+ result->keyword = strdup (keyword);
result->keywordType = type;
return result;
}
@@ -635,51 +741,55 @@
video/x-ms-asf-plugin: asf,asx,asp: mms animation;
video/x-ms-wvx: wvx: wmv metafile;
video/x-ms-wax: wva: wma metafile; */
-struct EXTRACTOR_Keywords * libextractor_asf_extract(char * filename,
- char * data,
- size_t size,
- struct EXTRACTOR_Keywords
* prev) {
- demux_asf_t * this;
+struct EXTRACTOR_Keywords *
+libextractor_asf_extract (char *filename,
+ char *data,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
+ demux_asf_t *this;
- this = malloc(sizeof(demux_asf_t));
- memset(this, 0, sizeof(demux_asf_t));
+ this = malloc (sizeof (demux_asf_t));
+ memset (this, 0, sizeof (demux_asf_t));
this->input = data;
this->inputPos = 0;
this->inputLen = size;
this->status = DEMUX_START;
- if (0 == asf_read_header(this)) {
- free(this);
- return prev;
- }
+ if (0 == asf_read_header (this))
+ {
+ free (this);
+ return prev;
+ }
- if (strlen(this->title) > 0)
- prev = addKeyword(EXTRACTOR_TITLE, this->title, prev);
- if (strlen(this->author) > 0)
- prev = addKeyword(EXTRACTOR_AUTHOR, this->author, prev);
- if (strlen(this->comment) > 0)
- prev = addKeyword(EXTRACTOR_COMMENT, this->comment, prev);
- if (strlen(this->copyright) > 0)
- prev = addKeyword(EXTRACTOR_COPYRIGHT, this->copyright, prev);
- prev = addKeyword(EXTRACTOR_MIMETYPE, "video/x-ms-asf", prev);
+ if (strlen (this->title) > 0)
+ prev = addKeyword (EXTRACTOR_TITLE, this->title, prev);
+ if (strlen (this->author) > 0)
+ prev = addKeyword (EXTRACTOR_AUTHOR, this->author, prev);
+ if (strlen (this->comment) > 0)
+ prev = addKeyword (EXTRACTOR_COMMENT, this->comment, prev);
+ if (strlen (this->copyright) > 0)
+ prev = addKeyword (EXTRACTOR_COPYRIGHT, this->copyright, prev);
+ prev = addKeyword (EXTRACTOR_MIMETYPE, "video/x-ms-asf", prev);
/* build a description from author and title */
- if (strlen(this->author) * strlen(this->title) > 0) {
- EXTRACTOR_KeywordList * keyword = malloc(sizeof(EXTRACTOR_KeywordList));
- char * word;
- int len = 3 + strlen(this->author) + strlen(this->title);
+ if (strlen (this->author) * strlen (this->title) > 0)
+ {
+ EXTRACTOR_KeywordList *keyword =
+ malloc (sizeof (EXTRACTOR_KeywordList));
+ char *word;
+ int len = 3 + strlen (this->author) + strlen (this->title);
- word = malloc(len);
- word[0] = '\0';
- strcat(word, this->author);
- strcat(word,": ");
- strcat(word, this->title);
- keyword->next = prev;
- keyword->keyword = word;
- keyword->keywordType = EXTRACTOR_DESCRIPTION;
- prev = keyword;
- }
- free(this);
+ word = malloc (len);
+ word[0] = '\0';
+ strcat (word, this->author);
+ strcat (word, ": ");
+ strcat (word, this->title);
+ keyword->next = prev;
+ keyword->keyword = word;
+ keyword->keywordType = EXTRACTOR_DESCRIPTION;
+ prev = keyword;
+ }
+ free (this);
return prev;
}
Modified: Extractor/src/plugins/convert.c
===================================================================
--- Extractor/src/plugins/convert.c 2007-07-29 08:04:12 UTC (rev 5367)
+++ Extractor/src/plugins/convert.c 2007-07-29 08:35:49 UTC (rev 5368)
@@ -30,41 +30,36 @@
* if conversion fails, a copy of the orignal
* string is returned.
*/
-char * convertToUtf8(const char * input,
- size_t len,
- const char * charset) {
+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;
+ 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);
+ cd = iconv_open ("UTF-8", charset);
+ if (cd == (iconv_t) - 1)
+ return strdup (i);
tmpSize = 3 * len + 4;
- tmp = malloc(tmpSize);
+ 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);
+ 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);
+ free (tmp);
+ iconv_close (cd);
return ret;
}
Modified: Extractor/src/plugins/debextractor.c
===================================================================
--- Extractor/src/plugins/debextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/debextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -34,133 +34,139 @@
* http://www.opengroup.org/onlinepubs/009695399/utilities/ar.html
*/
-static EXTRACTOR_KeywordList * addKeyword(EXTRACTOR_KeywordType type,
- char * keyword,
- EXTRACTOR_KeywordList * next) {
- EXTRACTOR_KeywordList * result;
+static EXTRACTOR_KeywordList *
+addKeyword (EXTRACTOR_KeywordType type,
+ char *keyword, EXTRACTOR_KeywordList * next)
+{
+ EXTRACTOR_KeywordList *result;
if (keyword == NULL)
return next;
- result = malloc(sizeof(EXTRACTOR_KeywordList));
+ result = malloc (sizeof (EXTRACTOR_KeywordList));
result->next = next;
result->keyword = keyword;
result->keywordType = type;
return result;
}
-static char * stndup(const char * str,
- size_t n) {
- char * tmp;
- tmp = malloc(n+1);
+static char *
+stndup (const char *str, size_t n)
+{
+ char *tmp;
+ tmp = malloc (n + 1);
tmp[n] = '\0';
- memcpy(tmp, str, n);
+ memcpy (tmp, str, n);
return tmp;
}
-typedef struct {
- char * text;
+typedef struct
+{
+ char *text;
EXTRACTOR_KeywordType type;
} Matches;
/* see also: "man 5 deb-control" */
static Matches tmap[] = {
- { "Package: ", EXTRACTOR_SOFTWARE },
- { "Version: ", EXTRACTOR_VERSIONNUMBER },
- { "Section: ", EXTRACTOR_GENRE },
- { "Priority: ", EXTRACTOR_PRIORITY },
- { "Architecture: ", EXTRACTOR_CREATED_FOR },
- { "Depends: ", EXTRACTOR_DEPENDENCY },
- { "Recommends: ", EXTRACTOR_RELATION },
- { "Suggests: ", EXTRACTOR_RELATION },
- { "Installed-Size: ", EXTRACTOR_SIZE },
- { "Maintainer: ", EXTRACTOR_PACKAGER },
- { "Description: ", EXTRACTOR_DESCRIPTION },
- { "Source: ", EXTRACTOR_SOURCE },
- { "Pre-Depends: ", EXTRACTOR_DEPENDENCY },
- { "Conflicts: ", EXTRACTOR_CONFLICTS },
- { "Replaces: ", EXTRACTOR_REPLACES },
- { "Provides: ", EXTRACTOR_PROVIDES },
- { NULL, 0 },
- { "Essential: ", EXTRACTOR_UNKNOWN }
+ {"Package: ", EXTRACTOR_SOFTWARE},
+ {"Version: ", EXTRACTOR_VERSIONNUMBER},
+ {"Section: ", EXTRACTOR_GENRE},
+ {"Priority: ", EXTRACTOR_PRIORITY},
+ {"Architecture: ", EXTRACTOR_CREATED_FOR},
+ {"Depends: ", EXTRACTOR_DEPENDENCY},
+ {"Recommends: ", EXTRACTOR_RELATION},
+ {"Suggests: ", EXTRACTOR_RELATION},
+ {"Installed-Size: ", EXTRACTOR_SIZE},
+ {"Maintainer: ", EXTRACTOR_PACKAGER},
+ {"Description: ", EXTRACTOR_DESCRIPTION},
+ {"Source: ", EXTRACTOR_SOURCE},
+ {"Pre-Depends: ", EXTRACTOR_DEPENDENCY},
+ {"Conflicts: ", EXTRACTOR_CONFLICTS},
+ {"Replaces: ", EXTRACTOR_REPLACES},
+ {"Provides: ", EXTRACTOR_PROVIDES},
+ {NULL, 0},
+ {"Essential: ", EXTRACTOR_UNKNOWN}
};
/**
* Process the control file.
*/
-static struct EXTRACTOR_Keywords * processControl(const char * data,
- const size_t size,
- struct EXTRACTOR_Keywords *
prev) {
+static struct EXTRACTOR_Keywords *
+processControl (const char *data,
+ const size_t size, struct EXTRACTOR_Keywords *prev)
+{
size_t pos;
- char * key;
+ char *key;
pos = 0;
- while (pos < size) {
- size_t colon;
- size_t eol;
- int i;
+ while (pos < size)
+ {
+ size_t colon;
+ size_t eol;
+ int i;
- colon = pos;
- while (data[colon] != ':') {
- if ( (colon > size) || (data[colon] == '\n') )
- return prev;
+ colon = pos;
+ while (data[colon] != ':')
+ {
+ if ((colon > size) || (data[colon] == '\n'))
+ return prev;
+ colon++;
+ }
colon++;
- }
- colon++;
- while ( (colon < size) &&
- (isspace(data[colon]) ) )
- colon++;
- eol = colon;
- while ( (eol < size) &&
- ( (data[eol] != '\n') ||
- ( (eol+1 < size) &&
- (data[eol+1] == ' ') ) ) )
- eol++;
- if ( (eol == colon) || (eol > size) )
- return prev;
- key = stndup(&data[pos], colon-pos);
- i = 0;
- while (tmap[i].text != NULL) {
- if (0 == strcmp(key, tmap[i].text)) {
- char * val;
+ while ((colon < size) && (isspace (data[colon])))
+ colon++;
+ eol = colon;
+ while ((eol < size) &&
+ ((data[eol] != '\n') ||
+ ((eol + 1 < size) && (data[eol + 1] == ' '))))
+ eol++;
+ if ((eol == colon) || (eol > size))
+ return prev;
+ key = stndup (&data[pos], colon - pos);
+ i = 0;
+ while (tmap[i].text != NULL)
+ {
+ if (0 == strcmp (key, tmap[i].text))
+ {
+ char *val;
- val = stndup(&data[colon], eol-colon);
- prev = addKeyword(tmap[i].type,
- val,
- prev);
- break;
- }
- i++;
+ val = stndup (&data[colon], eol - colon);
+ prev = addKeyword (tmap[i].type, val, prev);
+ break;
+ }
+ i++;
+ }
+ free (key);
+ pos = eol + 1;
}
- free(key);
- pos = eol+1;
- }
return prev;
}
-typedef struct {
+typedef struct
+{
char name[100];
char mode[8];
char userId[8];
char groupId[8];
char filesize[12];
- char lastModTime [12];
+ char lastModTime[12];
char chksum[8];
char link;
char linkName[100];
} TarHeader;
-typedef struct {
+typedef struct
+{
TarHeader tar;
char magic[6];
char version[2];
char uname[32];
char gname[32];
char devmajor[8];
- char devminor [8];
+ char devminor[8];
char prefix[155];
} USTarHeader;
@@ -168,120 +174,121 @@
* Process the control.tar file.
*/
static struct EXTRACTOR_Keywords *
-processControlTar(const char * data,
- const size_t size,
- struct EXTRACTOR_Keywords * prev) {
- TarHeader * tar;
- USTarHeader * ustar;
+processControlTar (const char *data,
+ const size_t size, struct EXTRACTOR_Keywords *prev)
+{
+ TarHeader *tar;
+ USTarHeader *ustar;
size_t pos;
pos = 0;
- while (pos + sizeof(TarHeader) < size) {
- unsigned long long fsize;
- char buf[13];
+ while (pos + sizeof (TarHeader) < size)
+ {
+ unsigned long long fsize;
+ char buf[13];
- tar = (TarHeader*) &data[pos];
- if (pos + sizeof(USTarHeader) < size) {
- ustar = (USTarHeader*) &data[pos];
- if (0 == strncmp("ustar",
- &ustar->magic[0],
- strlen("ustar")))
- pos += 512; /* sizeof(USTarHeader); */
+ tar = (TarHeader *) & data[pos];
+ if (pos + sizeof (USTarHeader) < size)
+ {
+ ustar = (USTarHeader *) & data[pos];
+ if (0 == strncmp ("ustar", &ustar->magic[0], strlen ("ustar")))
+ pos += 512; /* sizeof(USTarHeader); */
+ else
+ pos += 257; /* sizeof(TarHeader); minus gcc alignment... */
+ }
else
- pos += 257; /* sizeof(TarHeader); minus gcc alignment... */
- } else {
- pos += 257; /* sizeof(TarHeader); minus gcc alignment... */
- }
+ {
+ pos += 257; /* sizeof(TarHeader); minus gcc alignment... */
+ }
- memcpy(buf, &tar->filesize[0], 12);
- buf[12] = '\0';
- if (1 != sscanf(buf, "%12llo", &fsize)) /* octal! Yuck yuck! */
- return prev;
- if ( (pos + fsize > size) ||
- (fsize > size) ||
- (pos + fsize < pos) )
- return prev;
+ memcpy (buf, &tar->filesize[0], 12);
+ buf[12] = '\0';
+ if (1 != sscanf (buf, "%12llo", &fsize)) /* octal! Yuck yuck! */
+ return prev;
+ if ((pos + fsize > size) || (fsize > size) || (pos + fsize < pos))
+ return prev;
- if (0 == strncmp(&tar->name[0],
- "./control",
- strlen("./control"))) {
- return processControl(&data[pos],
- fsize,
- prev);
+ if (0 == strncmp (&tar->name[0], "./control", strlen ("./control")))
+ {
+ return processControl (&data[pos], fsize, prev);
+ }
+ if ((fsize & 511) != 0)
+ fsize = (fsize | 511) + 1; /* round up! */
+ if (pos + fsize < pos)
+ return prev;
+ pos += fsize;
}
- if ( (fsize & 511) != 0)
- fsize = (fsize | 511)+1; /* round up! */
- if (pos + fsize < pos)
- return prev;
- pos += fsize;
- }
return prev;
}
#define MAX_CONTROL_SIZE (1024 * 1024)
-static voidpf Emalloc(voidpf opaque, uInt items, uInt size) {
- return malloc(size * items);
+static voidpf
+Emalloc (voidpf opaque, uInt items, uInt size)
+{
+ return malloc (size * items);
}
-static void Efree(voidpf opaque, voidpf ptr) {
- free(ptr);
+static void
+Efree (voidpf opaque, voidpf ptr)
+{
+ free (ptr);
}
/**
* Process the control.tar.gz file.
*/
static struct EXTRACTOR_Keywords *
-processControlTGZ(const unsigned char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev) {
+processControlTGZ (const unsigned char *data,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
size_t bufSize;
- char * buf;
+ char *buf;
z_stream strm;
- bufSize = data[size-4] + 256 * data[size-3] + 65536 * data[size-2] +
256*65536 * data[size-1];
+ bufSize =
+ data[size - 4] + 256 * data[size - 3] + 65536 * data[size - 2] +
+ 256 * 65536 * data[size - 1];
if (bufSize > MAX_CONTROL_SIZE)
return prev;
- memset(&strm,
- 0,
- sizeof(z_stream));
+ memset (&strm, 0, sizeof (z_stream));
- strm.next_in = (Bytef*) data;
+ strm.next_in = (Bytef *) data;
strm.avail_in = size;
strm.total_in = 0;
strm.zalloc = &Emalloc;
strm.zfree = &Efree;
strm.opaque = NULL;
- if (Z_OK == inflateInit2(&strm,
- 15 + 32)) {
- buf = malloc(bufSize);
- if (buf == NULL) {
- inflateEnd(&strm);
- return prev;
+ if (Z_OK == inflateInit2 (&strm, 15 + 32))
+ {
+ buf = malloc (bufSize);
+ if (buf == NULL)
+ {
+ inflateEnd (&strm);
+ return prev;
+ }
+ strm.next_out = (Bytef *) buf;
+ strm.avail_out = bufSize;
+ inflate (&strm, Z_FINISH);
+ if (strm.total_out > 0)
+ {
+ prev = processControlTar (buf, strm.total_out, prev);
+ inflateEnd (&strm);
+ free (buf);
+ return prev;
+ }
+ free (buf);
+ inflateEnd (&strm);
}
- strm.next_out = (Bytef*) buf;
- strm.avail_out = bufSize;
- inflate(&strm,
- Z_FINISH);
- if (strm.total_out > 0) {
- prev = processControlTar(buf,
- strm.total_out,
- prev);
- inflateEnd(&strm);
- free(buf);
- return prev;
- }
- free(buf);
- inflateEnd(&strm);
- }
return prev;
}
-typedef struct {
+typedef struct
+{
char name[16];
- char lastModTime [12];
+ char lastModTime[12];
char userId[6];
char groupId[6];
char modeInOctal[8];
@@ -290,60 +297,52 @@
} ObjectHeader;
struct EXTRACTOR_Keywords *
-libextractor_deb_extract(const char * filename,
- const char * data,
- const size_t size,
- struct EXTRACTOR_Keywords * prev) {
+libextractor_deb_extract (const char *filename,
+ const char *data,
+ const size_t size, struct EXTRACTOR_Keywords *prev)
+{
size_t pos;
int done = 0;
if (size < 128)
return prev;
- if (0 != strncmp("!<arch>\n",
- data,
- strlen("!<arch>\n")))
+ if (0 != strncmp ("!<arch>\n", data, strlen ("!<arch>\n")))
return prev;
- pos = strlen("!<arch>\n");
- while (pos + sizeof(ObjectHeader) < size) {
- ObjectHeader * hdr;
- unsigned long long fsize;
- char buf[11];
+ pos = strlen ("!<arch>\n");
+ while (pos + sizeof (ObjectHeader) < size)
+ {
+ ObjectHeader *hdr;
+ unsigned long long fsize;
+ char buf[11];
- hdr = (ObjectHeader*) &data[pos];
- if (0 != strncmp(&hdr->trailer[0],
- "`\n",
- 2))
- return prev;
+ hdr = (ObjectHeader *) & data[pos];
+ if (0 != strncmp (&hdr->trailer[0], "`\n", 2))
+ return prev;
- memcpy(buf, &hdr->filesize[0], 10);
- buf[10] = '\0';
- if (1 != sscanf(buf, "%10llu", &fsize))
- return prev;
- pos += sizeof(ObjectHeader);
- if ( (pos + fsize > size) ||
- (fsize > size) ||
- (pos + fsize < pos) )
- return prev;
- if (0 == strncmp(&hdr->name[0],
- "control.tar.gz",
- strlen("control.tar.gz"))) {
- prev = processControlTGZ((const unsigned char*) &data[pos],
- fsize,
- prev);
- done++;
+ memcpy (buf, &hdr->filesize[0], 10);
+ buf[10] = '\0';
+ if (1 != sscanf (buf, "%10llu", &fsize))
+ return prev;
+ pos += sizeof (ObjectHeader);
+ if ((pos + fsize > size) || (fsize > size) || (pos + fsize < pos))
+ return prev;
+ if (0 == strncmp (&hdr->name[0],
+ "control.tar.gz", strlen ("control.tar.gz")))
+ {
+ prev = processControlTGZ ((const unsigned char *) &data[pos],
+ fsize, prev);
+ done++;
+ }
+ if (0 == strncmp (&hdr->name[0],
+ "debian-binary", strlen ("debian-binary")))
+ {
+ prev = addKeyword (EXTRACTOR_MIMETYPE,
+ strdup ("application/x-debian-package"), prev);
+ done++;
+ }
+ pos += fsize;
+ if (done == 2)
+ break; /* no need to process the rest of the archive
*/
}
- if (0 == strncmp(&hdr->name[0],
- "debian-binary",
- strlen("debian-binary"))) {
- prev = addKeyword(EXTRACTOR_MIMETYPE,
- strdup("application/x-debian-package"),
- prev);
- done++;
- }
- pos += fsize;
- if (done == 2)
- break; /* no need to process the rest of the archive */
- }
return prev;
}
-
Modified: Extractor/src/plugins/dviextractor.c
===================================================================
--- Extractor/src/plugins/dviextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/dviextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -21,120 +21,123 @@
#include "platform.h"
#include "extractor.h"
-static EXTRACTOR_KeywordList * addKeyword(EXTRACTOR_KeywordType type,
- char * keyword,
- EXTRACTOR_KeywordList * next) {
- EXTRACTOR_KeywordList * result;
+static EXTRACTOR_KeywordList *
+addKeyword (EXTRACTOR_KeywordType type,
+ char *keyword, EXTRACTOR_KeywordList * next)
+{
+ EXTRACTOR_KeywordList *result;
if (keyword == NULL)
return next;
- result = malloc(sizeof(EXTRACTOR_KeywordList));
+ result = malloc (sizeof (EXTRACTOR_KeywordList));
result->next = next;
result->keyword = keyword;
result->keywordType = type;
return result;
}
-typedef struct {
- char * text;
+typedef struct
+{
+ char *text;
EXTRACTOR_KeywordType type;
} Matches;
static Matches tmap[] = {
- { "/Title (", EXTRACTOR_TITLE },
- { "/Subject (", EXTRACTOR_SUBJECT },
- { "/Author (", EXTRACTOR_AUTHOR },
- { "/Keywords (", EXTRACTOR_KEYWORDS },
- { "/Creator (", EXTRACTOR_CREATOR },
- { "/Producer (", EXTRACTOR_PRODUCER },
- { NULL, 0 },
+ {"/Title (", EXTRACTOR_TITLE},
+ {"/Subject (", EXTRACTOR_SUBJECT},
+ {"/Author (", EXTRACTOR_AUTHOR},
+ {"/Keywords (", EXTRACTOR_KEYWORDS},
+ {"/Creator (", EXTRACTOR_CREATOR},
+ {"/Producer (", EXTRACTOR_PRODUCER},
+ {NULL, 0},
};
-static struct EXTRACTOR_Keywords * parseZZZ(const char * data,
- size_t pos,
- size_t len,
- struct EXTRACTOR_Keywords * prev) {
+static struct EXTRACTOR_Keywords *
+parseZZZ (const char *data,
+ size_t pos, size_t len, struct EXTRACTOR_Keywords *prev)
+{
size_t slen;
size_t end;
int i;
- char * value;
+ char *value;
end = pos + len;
- slen = strlen("ps:SDict begin [");
+ slen = strlen ("ps:SDict begin [");
if (len <= slen)
return prev;
- if (0 != strncmp("ps:SDict begin [ ",
- &data[pos],
- slen))
+ if (0 != strncmp ("ps:SDict begin [ ", &data[pos], slen))
return prev;
pos += slen;
- while (pos < end) {
- i = 0;
- while (tmap[i].text != NULL) {
- slen = strlen(tmap[i].text);
- if (pos + slen < end) {
- if (0 == strncmp(&data[pos],
- tmap[i].text,
- slen)) {
- pos += slen;
- slen = pos;
- while ( (slen < end) && (data[slen] != ')') )
- slen++;
- slen = slen - pos;
- value = malloc(slen+1);
- value[slen] = '\0';
- memcpy(value,
- &data[pos],
- slen);
- prev = addKeyword(tmap[i].type,
- value,
- prev);
- pos += slen + 1;
- }
- }
- i++;
+ while (pos < end)
+ {
+ i = 0;
+ while (tmap[i].text != NULL)
+ {
+ slen = strlen (tmap[i].text);
+ if (pos + slen < end)
+ {
+ if (0 == strncmp (&data[pos], tmap[i].text, slen))
+ {
+ pos += slen;
+ slen = pos;
+ while ((slen < end) && (data[slen] != ')'))
+ slen++;
+ slen = slen - pos;
+ value = malloc (slen + 1);
+ value[slen] = '\0';
+ memcpy (value, &data[pos], slen);
+ prev = addKeyword (tmap[i].type, value, prev);
+ pos += slen + 1;
+ }
+ }
+ i++;
+ }
+ pos++;
}
- pos++;
- }
return prev;
}
-static unsigned int getIntAt(const void * data) {
+static unsigned int
+getIntAt (const void *data)
+{
char p[4];
- memcpy(p, data, 4); /* ensure alignment! */
- return *(unsigned int*)&p[0];
+ memcpy (p, data, 4); /* ensure alignment! */
+ return *(unsigned int *) &p[0];
}
-static unsigned int getShortAt(const void * data) {
+static unsigned int
+getShortAt (const void *data)
+{
char p[2];
- memcpy(p, data, 2); /* ensure alignment! */
- return *(unsigned short*)&p[0];
+ memcpy (p, data, 2); /* ensure alignment! */
+ return *(unsigned short *) &p[0];
}
-struct EXTRACTOR_Keywords * libextractor_dvi_extract(const char * filename,
- const unsigned char * data,
- size_t size,
- struct EXTRACTOR_Keywords
* prev) {
+struct EXTRACTOR_Keywords *
+libextractor_dvi_extract (const char *filename,
+ const unsigned char *data,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
unsigned int klen;
- char * comment;
+ char *comment;
unsigned int pos;
unsigned int opos;
unsigned int len;
unsigned int pageCount;
- char * pages;
+ char *pages;
if (size < 40)
return prev;
- if ( (data[0] != 247) || (data[1] != 2) )
- return prev; /* cannot be dvi or unsupported version */
+ if ((data[0] != 247) || (data[1] != 2))
+ return prev; /* cannot be dvi or unsupported version */
klen = data[14];
- pos = size-1;
- while ( (data[pos] == 223) && (pos > 0) )
+ pos = size - 1;
+ while ((data[pos] == 223) && (pos > 0))
pos--;
- if ( (data[pos] != 2) || (pos < 40) )
+ if ((data[pos] != 2) || (pos < 40))
return prev;
pos--;
pos -= 4;
@@ -142,98 +145,77 @@
if (data[pos] != 249)
return prev;
opos = pos;
- pos = ntohl(getIntAt(&data[opos+1]));
- if (pos+25 > size)
+ pos = ntohl (getIntAt (&data[opos + 1]));
+ if (pos + 25 > size)
return prev;
/* assert pos at 'post' command */
if (data[pos] != 248)
return prev;
pageCount = 0;
opos = pos;
- pos = ntohl(getIntAt(&data[opos+1]));
- while (1) {
- if (pos == (unsigned int)-1)
- break;
- if (pos+45 > size)
- return prev;
- if (data[pos] != 139) /* expect 'bop' */
- return prev;
- pageCount++;
- opos = pos;
- pos = ntohl(getIntAt(&data[opos+41]));
- if (pos == (unsigned int)-1)
- break;
- if (pos >= opos)
- return prev; /* invalid! */
- }
+ pos = ntohl (getIntAt (&data[opos + 1]));
+ while (1)
+ {
+ if (pos == (unsigned int) -1)
+ break;
+ if (pos + 45 > size)
+ return prev;
+ if (data[pos] != 139) /* expect 'bop' */
+ return prev;
+ pageCount++;
+ opos = pos;
+ pos = ntohl (getIntAt (&data[opos + 41]));
+ if (pos == (unsigned int) -1)
+ break;
+ if (pos >= opos)
+ return prev; /* invalid! */
+ }
/* ok, now we believe it's a dvi... */
- pages = malloc(16);
- snprintf(pages,
- 16,
- "%u",
- pageCount);
- comment = malloc(klen+1);
+ pages = malloc (16);
+ snprintf (pages, 16, "%u", pageCount);
+ comment = malloc (klen + 1);
comment[klen] = '\0';
- memcpy(comment,
- &data[15],
- klen);
- prev = addKeyword(EXTRACTOR_MIMETYPE,
- strdup("application/x-dvi"),
- prev);
- prev = addKeyword(EXTRACTOR_COMMENT,
- comment,
- prev);
- prev = addKeyword(EXTRACTOR_PAGE_COUNT,
- pages,
- prev);
+ memcpy (comment, &data[15], klen);
+ prev = addKeyword (EXTRACTOR_MIMETYPE, strdup ("application/x-dvi"), prev);
+ prev = addKeyword (EXTRACTOR_COMMENT, comment, prev);
+ prev = addKeyword (EXTRACTOR_PAGE_COUNT, pages, prev);
/* try to find PDF/ps special */
pos = opos;
- while (pos < size - 100) {
- switch (data[pos]) {
- case 139: /* begin page 'bop', we typically have to skip that one to
- find the zzz's */
- pos += 45; /* skip bop */
- break;
- case 239: /* zzz1 */
- len = data[pos+1];
- if (pos + 2 + len < size)
- prev = parseZZZ((const char*) data,
- pos+2,
- len,
- prev);
- pos += len+2;
- break;
- case 240: /* zzz2 */
- len = ntohs(getShortAt(&data[pos+1]));
- if (pos + 3 + len < size)
- prev = parseZZZ((const char*) data,
- pos+3,
- len,
- prev);
- pos += len+3;
- break;
- case 241: /* zzz3, who uses that? */
- len = (ntohs(getShortAt(&data[pos+1]))) + 65536 * data[pos+3];
- if (pos + 4 + len < size)
- prev = parseZZZ((const char*) data,
- pos+4,
- len,
- prev);
- pos += len+4;
- break;
- case 242: /* zzz4, hurray! */
- len = ntohl(getIntAt(&data[pos+1]));
- if (pos + 1 + len < size)
- prev = parseZZZ((const char*) data,
- pos+5,
- len,
- prev);
- pos += len+5;
- break;
- default: /* unsupported opcode, abort scan */
- return prev;
+ while (pos < size - 100)
+ {
+ switch (data[pos])
+ {
+ case 139: /* begin page 'bop', we typically have to skip
that one to
+ find the zzz's */
+ pos += 45; /* skip bop */
+ break;
+ case 239: /* zzz1 */
+ len = data[pos + 1];
+ if (pos + 2 + len < size)
+ prev = parseZZZ ((const char *) data, pos + 2, len, prev);
+ pos += len + 2;
+ break;
+ case 240: /* zzz2 */
+ len = ntohs (getShortAt (&data[pos + 1]));
+ if (pos + 3 + len < size)
+ prev = parseZZZ ((const char *) data, pos + 3, len, prev);
+ pos += len + 3;
+ break;
+ case 241: /* zzz3, who uses that? */
+ len = (ntohs (getShortAt (&data[pos + 1]))) + 65536 * data[pos + 3];
+ if (pos + 4 + len < size)
+ prev = parseZZZ ((const char *) data, pos + 4, len, prev);
+ pos += len + 4;
+ break;
+ case 242: /* zzz4, hurray! */
+ len = ntohl (getIntAt (&data[pos + 1]));
+ if (pos + 1 + len < size)
+ prev = parseZZZ ((const char *) data, pos + 5, len, prev);
+ pos += len + 5;
+ break;
+ default: /* unsupported opcode, abort scan */
+ return prev;
+ }
}
- }
return prev;
}
-
Modified: Extractor/src/plugins/elfextractor.c
===================================================================
--- Extractor/src/plugins/elfextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/elfextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -22,13 +22,14 @@
#include "extractor.h"
#include "pack.h"
-static void addKeyword(struct EXTRACTOR_Keywords ** list,
- const char * keyword,
- EXTRACTOR_KeywordType type) {
- EXTRACTOR_KeywordList * next;
- next = malloc(sizeof(EXTRACTOR_KeywordList));
+static void
+addKeyword (struct EXTRACTOR_Keywords **list,
+ const char *keyword, EXTRACTOR_KeywordType type)
+{
+ EXTRACTOR_KeywordList *next;
+ next = malloc (sizeof (EXTRACTOR_KeywordList));
next->next = *list;
- next->keyword = strdup(keyword);
+ next->keyword = strdup (keyword);
next->keywordType = type;
*list = next;
}
@@ -48,20 +49,21 @@
#define EI_PAD 7
#define EI_NIDENT 16
-typedef struct {
+typedef struct
+{
Elf32_Half e_type;
Elf32_Half e_machine;
Elf32_Word e_version;
Elf32_Addr e_entry;
Elf32_Off e_phoff;
- Elf32_Off e_shoff; /* offset of the section header table */
+ Elf32_Off e_shoff; /* offset of the section header table */
Elf32_Word e_flags;
Elf32_Half e_ehsize;
Elf32_Half e_phensize;
Elf32_Half e_phnum;
- Elf32_Half e_shentsize; /* size of each entry in SH table */
- Elf32_Half e_shnum; /* how many entries in section header table */
- Elf32_Half e_shstrndx; /* section header's sh_name member is index into this
string table! */
+ Elf32_Half e_shentsize; /* size of each entry in SH table */
+ Elf32_Half e_shnum; /* how many entries in section header table */
+ Elf32_Half e_shstrndx; /* section header's sh_name member is index
into this string table! */
} Elf32_Ehdr;
/* elf-header minus e_ident */
@@ -80,22 +82,23 @@
&(p)->e_phnum, \
&(p)->e_shentsize, \
&(p)->e_shnum, \
- &(p)->e_shstrndx
-static char * ELF_HEADER_SPECS[] = {
+ &(p)->e_shstrndx
+static char *ELF_HEADER_SPECS[] = {
"hhwwwwwhhhhhh",
"HHWWWWWHHHHHH",
};
-typedef struct {
+typedef struct
+{
Elf32_Word sh_name;
Elf32_Word sh_type;
Elf32_Word sh_flags;
- Elf32_Addr sh_addr; /* where loaded */
- Elf32_Off sh_offset; /* where in image (! sh_type==SHT_NOBITS) */
- Elf32_Word sh_size; /* section size in bytes */
- Elf32_Word sh_link; /* for symbol table: section header index of the
associated string table! */
- Elf32_Word sh_info; /* "one greater than the symbol table index of the last
local symbol _STB_LOCAL_" */
+ Elf32_Addr sh_addr; /* where loaded */
+ Elf32_Off sh_offset; /* where in image (! sh_type==SHT_NOBITS) */
+ Elf32_Word sh_size; /* section size in bytes */
+ Elf32_Word sh_link; /* for symbol table: section header index of
the associated string table! */
+ Elf32_Word sh_info; /* "one greater than the symbol table index of
the last local symbol _STB_LOCAL_" */
Elf32_Word sh_addralign;
Elf32_Word sh_entsize;
} Elf32_Shdr;
@@ -111,12 +114,13 @@
&(p)->sh_info, \
&(p)->sh_addralign, \
&(p)->sh_entsize
-static char * ELF_SECTION_SPECS[] = {
+static char *ELF_SECTION_SPECS[] = {
"wwwwwwwwww",
"WWWWWWWWWW",
};
-typedef struct {
+typedef struct
+{
Elf32_Word p_type;
Elf32_Off p_offset;
Elf32_Addr p_vaddr;
@@ -136,14 +140,16 @@
&(p)->p_memsz, \
&(p)->p_flags, \
&(p)->p_align
-static char * ELF_PHDR_SPECS[] = {
+static char *ELF_PHDR_SPECS[] = {
"wwwwwwww",
"WWWWWWWW",
};
-typedef struct {
+typedef struct
+{
Elf32_Sword d_tag;
- union {
+ union
+ {
Elf32_Word d_val;
Elf32_Addr d_ptr;
} d_un;
@@ -152,7 +158,7 @@
#define ELF_DYN_FIELDS(p) \
&(p)->d_tag, \
&(p)->d_un
-static char * ELF_DYN_SPECS[] = {
+static char *ELF_DYN_SPECS[] = {
"ww",
"WW",
};
@@ -255,37 +261,42 @@
* @param ei_data ELFDATA2LSB or ELFDATA2MSB
* @return 1 if we need to convert, 0 if not
*/
-static int getByteorder(char ei_data) {
- if (ei_data == ELFDATA2LSB) {
+static int
+getByteorder (char ei_data)
+{
+ if (ei_data == ELFDATA2LSB)
+ {
#if __BYTE_ORDER == __BIG_ENDIAN
- return 1;
+ return 1;
#else
- return 0;
+ return 0;
#endif
- } else {
+ }
+ else
+ {
#if __BYTE_ORDER == __BIG_ENDIAN
- return 0;
+ return 0;
#else
- return 1;
+ return 1;
#endif
- }
+ }
}
/**
*
* @return 0 on success, -1 on error
*/
-static int getSectionHdr(char * data,
- size_t size,
- Elf32_Ehdr * ehdr,
- Elf32_Half idx,
- Elf32_Shdr * ret) {
+static int
+getSectionHdr (char *data,
+ size_t size,
+ Elf32_Ehdr * ehdr, Elf32_Half idx, Elf32_Shdr * ret)
+{
if (ehdr->e_shnum <= idx)
return -1;
- cat_unpack(&data[ehdr->e_shoff + ehdr->e_shentsize * idx],
- ELF_SECTION_SPECS[getByteorder(data[EI_CLASS])],
- ELF_SECTION_FIELDS(ret));
+ cat_unpack (&data[ehdr->e_shoff + ehdr->e_shentsize * idx],
+ ELF_SECTION_SPECS[getByteorder (data[EI_CLASS])],
+ ELF_SECTION_FIELDS (ret));
return 0;
}
@@ -293,19 +304,17 @@
*
* @return 0 on success, -1 on error
*/
-static int getDynTag(char * data,
- size_t size,
- Elf32_Ehdr * ehdr,
- Elf32_Off off,
- Elf32_Word osize,
- unsigned int idx,
- Elf32_Dyn * ret) {
- if ( (off+osize > size) ||
- ((idx+1) * ELF_DYN_SIZE > osize) )
+static int
+getDynTag (char *data,
+ size_t size,
+ Elf32_Ehdr * ehdr,
+ Elf32_Off off, Elf32_Word osize, unsigned int idx, Elf32_Dyn * ret)
+{
+ if ((off + osize > size) || ((idx + 1) * ELF_DYN_SIZE > osize))
return -1;
- cat_unpack(&data[off + idx*ELF_DYN_SIZE],
- ELF_DYN_SPECS[getByteorder(data[EI_CLASS])],
- ELF_DYN_FIELDS(ret));
+ cat_unpack (&data[off + idx * ELF_DYN_SIZE],
+ ELF_DYN_SPECS[getByteorder (data[EI_CLASS])],
+ ELF_DYN_FIELDS (ret));
return 0;
}
@@ -313,17 +322,17 @@
*
* @return 0 on success, -1 on error
*/
-static int getProgramHdr(char * data,
- size_t size,
- Elf32_Ehdr * ehdr,
- Elf32_Half idx,
- Elf32_Phdr * ret) {
+static int
+getProgramHdr (char *data,
+ size_t size,
+ Elf32_Ehdr * ehdr, Elf32_Half idx, Elf32_Phdr * ret)
+{
if (ehdr->e_phnum <= idx)
return -1;
- cat_unpack(&data[ehdr->e_phoff + ehdr->e_phensize * idx],
- ELF_PHDR_SPECS[getByteorder(data[EI_CLASS])],
- ELF_PHDR_FIELDS(ret));
+ cat_unpack (&data[ehdr->e_phoff + ehdr->e_phensize * idx],
+ ELF_PHDR_SPECS[getByteorder (data[EI_CLASS])],
+ ELF_PHDR_FIELDS (ret));
return 0;
}
@@ -331,31 +340,30 @@
* Parse ELF header.
* @return 0 on success, -1 on error
*/
-static int getELFHdr(char * data,
- size_t size,
- Elf32_Ehdr * ehdr) {
+static int
+getELFHdr (char *data, size_t size, Elf32_Ehdr * ehdr)
+{
/* catlib */
- if (size < sizeof(Elf32_Ehdr) + EI_NIDENT)
+ if (size < sizeof (Elf32_Ehdr) + EI_NIDENT)
return -1;
- if (0 != strncmp(data,
- elfMagic,
- sizeof(elfMagic)))
- return -1; /* not an elf */
+ if (0 != strncmp (data, elfMagic, sizeof (elfMagic)))
+ return -1; /* not an elf */
- switch (data[EI_CLASS]) {
- case ELFDATA2LSB:
- case ELFDATA2MSB:
- cat_unpack(&data[EI_NIDENT],
- ELF_HEADER_SPECS[getByteorder(data[EI_CLASS])],
- ELF_HEADER_FIELDS(ehdr));
- break;
- default:
- return -1;
- }
+ switch (data[EI_CLASS])
+ {
+ case ELFDATA2LSB:
+ case ELFDATA2MSB:
+ cat_unpack (&data[EI_NIDENT],
+ ELF_HEADER_SPECS[getByteorder (data[EI_CLASS])],
+ ELF_HEADER_FIELDS (ehdr));
+ break;
+ default:
+ return -1;
+ }
if (ehdr->e_shoff + ehdr->e_shentsize * ehdr->e_shnum > size)
- return -1; /* invalid offsets... */
+ return -1; /* invalid offsets... */
if (ehdr->e_shentsize < ELF_SECTION_SIZE)
- return -1; /* huh? */
+ return -1; /* huh? */
if (ehdr->e_phoff + ehdr->e_phensize * ehdr->e_phnum > size)
return -1;
@@ -365,206 +373,170 @@
/**
* @return the string (offset into data, do NOT free), NULL on error
*/
-static const char * readStringTable(char * data,
- size_t size,
- Elf32_Ehdr * ehdr,
- Elf32_Half strTableOffset,
- Elf32_Word sh_name) {
+static const char *
+readStringTable (char *data,
+ size_t size,
+ Elf32_Ehdr * ehdr,
+ Elf32_Half strTableOffset, Elf32_Word sh_name)
+{
Elf32_Shdr shrd;
- if (-1 == getSectionHdr(data,
- size,
- ehdr,
- strTableOffset,
- &shrd))
+ if (-1 == getSectionHdr (data, size, ehdr, strTableOffset, &shrd))
return NULL;
- if ( (shrd.sh_type != SHT_STRTAB) ||
- (shrd.sh_offset + shrd.sh_size > size) ||
- (shrd.sh_size <= sh_name) ||
- (data[shrd.sh_offset+shrd.sh_size-1] != '\0') )
+ if ((shrd.sh_type != SHT_STRTAB) ||
+ (shrd.sh_offset + shrd.sh_size > size) ||
+ (shrd.sh_size <= sh_name) ||
+ (data[shrd.sh_offset + shrd.sh_size - 1] != '\0'))
return NULL;
- return &data[shrd.sh_offset+sh_name];
+ return &data[shrd.sh_offset + sh_name];
}
/* application/x-executable, ELF */
-struct EXTRACTOR_Keywords * libextractor_elf_extract(char * filename,
- char * data,
- size_t size,
- struct EXTRACTOR_Keywords
* prev) {
+struct EXTRACTOR_Keywords *
+libextractor_elf_extract (char *filename,
+ char *data,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
Elf32_Ehdr ehdr;
Elf32_Half idx;
- if (0 != getELFHdr(data,
- size,
- &ehdr))
+ if (0 != getELFHdr (data, size, &ehdr))
return prev;
- addKeyword(&prev,
- "application/x-executable",
- EXTRACTOR_MIMETYPE);
- switch (ehdr.e_type) {
- case ET_REL:
- addKeyword(&prev,
- "Relocatable file",
- EXTRACTOR_RESOURCE_TYPE);
- break;
- case ET_EXEC:
- addKeyword(&prev,
- "Executable file",
- EXTRACTOR_RESOURCE_TYPE);
- break;
- case ET_DYN:
- addKeyword(&prev,
- "Shared object file",
- EXTRACTOR_RESOURCE_TYPE);
- break;
- case ET_CORE:
- addKeyword(&prev,
- "Core file",
- EXTRACTOR_RESOURCE_TYPE);
- break;
- default:
- break; /* unknown */
- }
- switch (ehdr.e_machine) {
- case EM_M32:
- addKeyword(&prev,
- "M32",
- EXTRACTOR_CREATED_FOR);
- break;
- case EM_386:
- addKeyword(&prev,
- "i386",
- EXTRACTOR_CREATED_FOR);
- break;
- case EM_68K:
- addKeyword(&prev,
- "68K",
- EXTRACTOR_CREATED_FOR);
- break;
- case EM_88K:
- addKeyword(&prev,
- "88K",
- EXTRACTOR_CREATED_FOR);
- break;
- case EM_SPARC:
- addKeyword(&prev,
- "Sparc",
- EXTRACTOR_CREATED_FOR);
- break;
- case EM_860:
- addKeyword(&prev,
- "960",
- EXTRACTOR_CREATED_FOR);
- break;
- case EM_MIPS:
- addKeyword(&prev,
- "MIPS",
- EXTRACTOR_CREATED_FOR);
- break;
- default:
- break; /* oops */
- }
+ addKeyword (&prev, "application/x-executable", EXTRACTOR_MIMETYPE);
+ switch (ehdr.e_type)
+ {
+ case ET_REL:
+ addKeyword (&prev, "Relocatable file", EXTRACTOR_RESOURCE_TYPE);
+ break;
+ case ET_EXEC:
+ addKeyword (&prev, "Executable file", EXTRACTOR_RESOURCE_TYPE);
+ break;
+ case ET_DYN:
+ addKeyword (&prev, "Shared object file", EXTRACTOR_RESOURCE_TYPE);
+ break;
+ case ET_CORE:
+ addKeyword (&prev, "Core file", EXTRACTOR_RESOURCE_TYPE);
+ break;
+ default:
+ break; /* unknown */
+ }
+ switch (ehdr.e_machine)
+ {
+ case EM_M32:
+ addKeyword (&prev, "M32", EXTRACTOR_CREATED_FOR);
+ break;
+ case EM_386:
+ addKeyword (&prev, "i386", EXTRACTOR_CREATED_FOR);
+ break;
+ case EM_68K:
+ addKeyword (&prev, "68K", EXTRACTOR_CREATED_FOR);
+ break;
+ case EM_88K:
+ addKeyword (&prev, "88K", EXTRACTOR_CREATED_FOR);
+ break;
+ case EM_SPARC:
+ addKeyword (&prev, "Sparc", EXTRACTOR_CREATED_FOR);
+ break;
+ case EM_860:
+ addKeyword (&prev, "960", EXTRACTOR_CREATED_FOR);
+ break;
+ case EM_MIPS:
+ addKeyword (&prev, "MIPS", EXTRACTOR_CREATED_FOR);
+ break;
+ default:
+ break; /* oops */
+ }
- for (idx=0;idx<ehdr.e_phnum;idx++) {
- Elf32_Phdr phdr;
+ for (idx = 0; idx < ehdr.e_phnum; idx++)
+ {
+ Elf32_Phdr phdr;
- if (0 != getProgramHdr(data,
- size,
- &ehdr,
- idx,
- &phdr))
- return prev;
- if (phdr.p_type == PT_DYNAMIC) {
- unsigned int dc = phdr.p_filesz / ELF_DYN_SIZE;
- unsigned int id;
- Elf32_Addr stringPtr;
- Elf32_Half stringIdx;
- Elf32_Half six;
+ if (0 != getProgramHdr (data, size, &ehdr, idx, &phdr))
+ return prev;
+ if (phdr.p_type == PT_DYNAMIC)
+ {
+ unsigned int dc = phdr.p_filesz / ELF_DYN_SIZE;
+ unsigned int id;
+ Elf32_Addr stringPtr;
+ Elf32_Half stringIdx;
+ Elf32_Half six;
- stringPtr = 0;
+ stringPtr = 0;
- for (id=0;id<dc;id++) {
- Elf32_Dyn dyn;
- if (0 != getDynTag(data,
- size,
- &ehdr,
- phdr.p_offset,
- phdr.p_filesz,
- id,
- &dyn))
- return prev;
- if (DT_STRTAB == dyn.d_tag) {
- stringPtr = dyn.d_un.d_ptr;
- break;
- }
- }
- if (stringPtr == 0)
- return prev;
- for (six=0;six<ehdr.e_shnum;six++) {
- Elf32_Shdr sec;
- if (-1 == getSectionHdr(data,
- size,
- &ehdr,
- six,
- &sec))
- return prev;
- if ( (sec.sh_addr == stringPtr) &&
- (sec.sh_type == SHT_STRTAB) ) {
- stringIdx = six;
- break;
- }
- }
+ for (id = 0; id < dc; id++)
+ {
+ Elf32_Dyn dyn;
+ if (0 != getDynTag (data,
+ size,
+ &ehdr,
+ phdr.p_offset, phdr.p_filesz, id, &dyn))
+ return prev;
+ if (DT_STRTAB == dyn.d_tag)
+ {
+ stringPtr = dyn.d_un.d_ptr;
+ break;
+ }
+ }
+ if (stringPtr == 0)
+ return prev;
+ for (six = 0; six < ehdr.e_shnum; six++)
+ {
+ Elf32_Shdr sec;
+ if (-1 == getSectionHdr (data, size, &ehdr, six, &sec))
+ return prev;
+ if ((sec.sh_addr == stringPtr) && (sec.sh_type == SHT_STRTAB))
+ {
+ stringIdx = six;
+ break;
+ }
+ }
- for (id=0;id<dc;id++) {
- Elf32_Dyn dyn;
- if (0 != getDynTag(data,
- size,
- &ehdr,
- phdr.p_offset,
- phdr.p_filesz,
- id,
- &dyn))
- return prev;
- switch(dyn.d_tag) {
- case DT_RPATH: {
- const char * rpath;
+ for (id = 0; id < dc; id++)
+ {
+ Elf32_Dyn dyn;
+ if (0 != getDynTag (data,
+ size,
+ &ehdr,
+ phdr.p_offset, phdr.p_filesz, id, &dyn))
+ return prev;
+ switch (dyn.d_tag)
+ {
+ case DT_RPATH:
+ {
+ const char *rpath;
- rpath = readStringTable(data,
- size,
- &ehdr,
- stringIdx,
- dyn.d_un.d_val);
- /* "source" of the dependencies: path
- to dynamic libraries */
- if (rpath != NULL) {
- addKeyword(&prev,
- rpath,
- EXTRACTOR_SOURCE);
- }
- break;
- }
- case DT_NEEDED: {
- const char * needed;
+ rpath = readStringTable (data,
+ size,
+ &ehdr,
+ stringIdx, dyn.d_un.d_val);
+ /* "source" of the dependencies: path
+ to dynamic libraries */
+ if (rpath != NULL)
+ {
+ addKeyword (&prev, rpath, EXTRACTOR_SOURCE);
+ }
+ break;
+ }
+ case DT_NEEDED:
+ {
+ const char *needed;
- needed = readStringTable(data,
- size,
- &ehdr,
- stringIdx,
- dyn.d_un.d_val);
- if (needed != NULL) {
- addKeyword(&prev,
- needed,
- EXTRACTOR_DEPENDENCY);
- }
- break;
- }
- }
- }
+ needed = readStringTable (data,
+ size,
+ &ehdr,
+ stringIdx, dyn.d_un.d_val);
+ if (needed != NULL)
+ {
+ addKeyword (&prev, needed, EXTRACTOR_DEPENDENCY);
+ }
+ break;
+ }
+ }
+ }
+ }
}
- }
return prev;
}
-
Modified: Extractor/src/plugins/filenameextractor.c
===================================================================
--- Extractor/src/plugins/filenameextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/filenameextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -25,48 +25,52 @@
/* "extract" the 'filename' as a keyword */
struct EXTRACTOR_Keywords *
-libextractor_filename_extract(const char * filename,
- char * date,
- size_t size,
- struct EXTRACTOR_Keywords * prev) {
- EXTRACTOR_KeywordList * keyword;
- const char * filenameRoot = filename;
+libextractor_filename_extract (const char *filename,
+ char *date,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
+ EXTRACTOR_KeywordList *keyword;
+ const char *filenameRoot = filename;
int res;
/* get filename */
- if (filename != NULL) {
- for (res=strlen(filename)-1;res>=0;res--)
- if (filename[res] == DIR_SEPARATOR) {
- filenameRoot = &filename[res+1];
- break;
- }
- keyword = malloc(sizeof(EXTRACTOR_KeywordList));
- keyword->next = prev;
- keyword->keyword = convertToUtf8(filenameRoot,
- strlen(filenameRoot),
- nl_langinfo(CODESET));
- keyword->keywordType = EXTRACTOR_FILENAME;
- prev = keyword;
- }
-
+ if (filename != NULL)
+ {
+ for (res = strlen (filename) - 1; res >= 0; res--)
+ if (filename[res] == DIR_SEPARATOR)
+ {
+ filenameRoot = &filename[res + 1];
+ break;
+ }
+ keyword = malloc (sizeof (EXTRACTOR_KeywordList));
+ keyword->next = prev;
+ keyword->keyword = convertToUtf8 (filenameRoot,
+ strlen (filenameRoot),
+ nl_langinfo (CODESET));
+ keyword->keywordType = EXTRACTOR_FILENAME;
+ prev = keyword;
+ }
+
/* get file size */
- if (size > 0) {
- keyword = malloc(sizeof(EXTRACTOR_KeywordList));
- keyword->next = prev;
- keyword->keyword = malloc(14);
- keyword->keywordType = EXTRACTOR_FILE_SIZE;
-
- if (size >= 1000000000)
- snprintf(keyword->keyword, 13, "%.2f %s", size / 1000000000.0, _("GB"));
- else if (size >= 1000000)
- snprintf(keyword->keyword, 13, "%.2f %s", size / 1000000.0, _("MB"));
- else if (size >= 1000)
- snprintf(keyword->keyword, 13, "%.2f %s", size / 1000.0, _("KB"));
- else
- snprintf(keyword->keyword, 13, "%.2f %s", (double) size, _("Bytes"));
-
- prev = keyword;
- }
-
+ if (size > 0)
+ {
+ keyword = malloc (sizeof (EXTRACTOR_KeywordList));
+ keyword->next = prev;
+ keyword->keyword = malloc (14);
+ keyword->keywordType = EXTRACTOR_FILE_SIZE;
+
+ if (size >= 1000000000)
+ snprintf (keyword->keyword, 13, "%.2f %s", size / 1000000000.0,
+ _("GB"));
+ else if (size >= 1000000)
+ snprintf (keyword->keyword, 13, "%.2f %s", size / 1000000.0, _("MB"));
+ else if (size >= 1000)
+ snprintf (keyword->keyword, 13, "%.2f %s", size / 1000.0, _("KB"));
+ else
+ snprintf (keyword->keyword, 13, "%.2f %s", (double) size, _("Bytes"));
+
+ prev = keyword;
+ }
+
return prev;
}
Modified: Extractor/src/plugins/gifextractor.c
===================================================================
--- Extractor/src/plugins/gifextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/gifextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -29,7 +29,8 @@
#define PRINT(a,b)
#endif
-typedef struct {
+typedef struct
+{
char gif[3];
char version[3];
unsigned short screen_width;
@@ -54,7 +55,8 @@
&(p)->background_color_index, \
&(p)->pixel_aspect_ratio
-typedef struct {
+typedef struct
+{
unsigned char image_separator;
unsigned short image_left;
unsigned short image_top;
@@ -77,19 +79,21 @@
&(p)->image_height, \
&(p)->flags
-typedef struct {
+typedef struct
+{
unsigned char extension_introducer;
unsigned char graphic_control_label;
} GIF_EXTENSION;
-static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordType type,
- char * keyword,
- struct EXTRACTOR_Keywords * next)
{
- EXTRACTOR_KeywordList * result;
+static struct EXTRACTOR_Keywords *
+addKeyword (EXTRACTOR_KeywordType type,
+ char *keyword, struct EXTRACTOR_Keywords *next)
+{
+ EXTRACTOR_KeywordList *result;
if (keyword == NULL)
return next;
- result = malloc(sizeof(EXTRACTOR_KeywordList));
+ result = malloc (sizeof (EXTRACTOR_KeywordList));
result->next = next;
result->keyword = keyword;
result->keywordType = type;
@@ -100,36 +104,38 @@
* Skip a data block.
* @return the position after the block
**/
-static size_t skipDataBlock(const unsigned char * data,
- size_t pos,
- const size_t size) {
- while ( (pos < size) &&
- (data[pos] != 0) )
- pos += data[pos]+1;
- return pos+1;
+static size_t
+skipDataBlock (const unsigned char *data, size_t pos, const size_t size)
+{
+ while ((pos < size) && (data[pos] != 0))
+ pos += data[pos] + 1;
+ return pos + 1;
}
/**
* skip an extention block
* @return the position after the block
**/
-static size_t skipExtensionBlock(const unsigned char * data,
- size_t pos,
- const size_t size,
- const GIF_EXTENSION * ext) {
- return skipDataBlock(data, pos+sizeof(GIF_EXTENSION), size);
+static size_t
+skipExtensionBlock (const unsigned char *data,
+ size_t pos, const size_t size, const GIF_EXTENSION * ext)
+{
+ return skipDataBlock (data, pos + sizeof (GIF_EXTENSION), size);
}
/**
* @return the offset after the global color map
**/
-static size_t skipGlobalColorMap(const unsigned char * data,
- const size_t size,
- const GIF_HEADER * header) {
+static size_t
+skipGlobalColorMap (const unsigned char *data,
+ const size_t size, const GIF_HEADER * header)
+{
size_t gct_size;
- if ( (header->flags & HEADER_FLAGS__GLOBAL_COLOR_TABLE_FLAG) > 0)
- gct_size = 3*(1 << ((header->flags &
HEADER_FLAGS__SIZE_OF_GLOBAL_COLOR_TABLE)+1));
+ if ((header->flags & HEADER_FLAGS__GLOBAL_COLOR_TABLE_FLAG) > 0)
+ gct_size =
+ 3 *
+ (1 << ((header->flags & HEADER_FLAGS__SIZE_OF_GLOBAL_COLOR_TABLE) + 1));
else
gct_size = 0;
return GIF_HEADER_SIZE + gct_size;
@@ -138,121 +144,106 @@
/**
* @return the offset after the local color map
**/
-static size_t skipLocalColorMap(const unsigned char * data,
- size_t pos,
- const size_t size,
- GIF_DESCRIPTOR * descriptor) {
+static size_t
+skipLocalColorMap (const unsigned char *data,
+ size_t pos, const size_t size, GIF_DESCRIPTOR * descriptor)
+{
size_t lct_size;
- if (pos+GIF_DESCRIPTOR_SIZE > size)
+ if (pos + GIF_DESCRIPTOR_SIZE > size)
return size;
- if ( (descriptor->flags & DESCRIPTOR_FLAGS__LOCAL_COLOR_TABLE_FLAG) > 0)
- lct_size = 3*(1 << ((descriptor->flags & DESCRIPTOR_FLAGS__PIXEL_SIZE)+1));
+ if ((descriptor->flags & DESCRIPTOR_FLAGS__LOCAL_COLOR_TABLE_FLAG) > 0)
+ lct_size =
+ 3 * (1 << ((descriptor->flags & DESCRIPTOR_FLAGS__PIXEL_SIZE) + 1));
else
lct_size = 0;
return pos + GIF_DESCRIPTOR_SIZE + lct_size;
}
-static struct EXTRACTOR_Keywords * parseComment(const unsigned char * data,
- size_t pos,
- const size_t size,
- struct EXTRACTOR_Keywords *
prev) {
+static struct EXTRACTOR_Keywords *
+parseComment (const unsigned char *data,
+ size_t pos, const size_t size, struct EXTRACTOR_Keywords *prev)
+{
size_t length = 0;
size_t curr = pos;
- char * keyword;
+ char *keyword;
- while ( (data[curr] != 0) &&
- (curr < size) ) {
- length += data[curr];
- curr += data[curr] + 1;
- }
- keyword = malloc(length+1);
+ while ((data[curr] != 0) && (curr < size))
+ {
+ length += data[curr];
+ curr += data[curr] + 1;
+ }
+ keyword = malloc (length + 1);
curr = pos;
length = 0;
- while ( (data[curr] != 0) &&
- (curr < size) ) {
- length += data[curr];
- if (length >= size)
- break;
- memcpy(&keyword[length-data[curr]],
- &data[curr]+1,
- data[curr]);
- keyword[length] = 0;
- curr += data[curr] + 1;
- }
- return addKeyword(EXTRACTOR_COMMENT,
- keyword,
- prev);
+ while ((data[curr] != 0) && (curr < size))
+ {
+ length += data[curr];
+ if (length >= size)
+ break;
+ memcpy (&keyword[length - data[curr]], &data[curr] + 1, data[curr]);
+ keyword[length] = 0;
+ curr += data[curr] + 1;
+ }
+ return addKeyword (EXTRACTOR_COMMENT, keyword, prev);
}
-
-struct EXTRACTOR_Keywords * libextractor_gif_extract(const char * filename,
- const unsigned char *
data,
- const size_t size,
- struct EXTRACTOR_Keywords
* prev) {
+
+struct EXTRACTOR_Keywords *
+libextractor_gif_extract (const char *filename,
+ const unsigned char *data,
+ const size_t size, struct EXTRACTOR_Keywords *prev)
+{
size_t pos;
- struct EXTRACTOR_Keywords * result;
+ struct EXTRACTOR_Keywords *result;
GIF_HEADER header;
- char * tmp;
+ char *tmp;
if (size < GIF_HEADER_SIZE)
return prev;
- cat_unpack(data,
- GIF_HEADER_SPEC,
- GIF_HEADER_FIELDS(&header));
- if (0 != strncmp(&header.gif[0],"GIF",3))
+ 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))
- return prev; /* only 89a has support for comments */
+ if (0 != strncmp (&header.version[0], "89a", 3))
+ return prev; /* only 89a has support for comments */
result = prev;
- result = addKeyword(EXTRACTOR_MIMETYPE,
- strdup("image/gif"),
- result);
- tmp = malloc(128);
- snprintf(tmp,
- 128,
- "%ux%u",
- header.screen_width,
- header.screen_height);
- result = addKeyword(EXTRACTOR_SIZE,
- strdup(tmp),
- result);
- free(tmp);
- pos = skipGlobalColorMap(data, size, &header);
- PRINT("global color map ends at %d\n",pos);
- while (pos < size) {
- GIF_DESCRIPTOR gd;
+ result = addKeyword (EXTRACTOR_MIMETYPE, strdup ("image/gif"), result);
+ tmp = malloc (128);
+ snprintf (tmp, 128, "%ux%u", header.screen_width, header.screen_height);
+ result = addKeyword (EXTRACTOR_SIZE, strdup (tmp), result);
+ free (tmp);
+ pos = skipGlobalColorMap (data, size, &header);
+ PRINT ("global color map ends at %d\n", pos);
+ while (pos < size)
+ {
+ GIF_DESCRIPTOR gd;
- switch (data[pos]) {
- case ',': /* image descriptor block */
- PRINT("skipping local color map %d\n", pos);
- cat_unpack(&data[pos],
- GIF_DESCRIPTOR_SPEC,
- GIF_DESCRIPTOR_FIELDS(&gd));
- pos = skipLocalColorMap(data, pos, size,
- &gd);
- break;
- case '!': /* extension block */
- PRINT("skipping extension block %d\n",pos);
- if (data[pos+1] == (unsigned char)0xFE) {
- result = parseComment(data,
- pos+2,
- size,
- result);
- }
- pos = skipExtensionBlock(data, pos, size,
- (GIF_EXTENSION *) &data[pos]);
- break;
- case ';':
- PRINT("hit terminator at %d!\n",pos);
- return result; /* terminator! */
- default: /* raster data block */
- PRINT("skipping data block at %d\n",pos);
- pos = skipDataBlock(data, pos+1, size);
- break;
+ switch (data[pos])
+ {
+ case ',': /* image descriptor block */
+ PRINT ("skipping local color map %d\n", pos);
+ cat_unpack (&data[pos],
+ GIF_DESCRIPTOR_SPEC, GIF_DESCRIPTOR_FIELDS (&gd));
+ pos = skipLocalColorMap (data, pos, size, &gd);
+ break;
+ case '!': /* extension block */
+ PRINT ("skipping extension block %d\n", pos);
+ if (data[pos + 1] == (unsigned char) 0xFE)
+ {
+ result = parseComment (data, pos + 2, size, result);
+ }
+ pos = skipExtensionBlock (data, pos, size,
+ (GIF_EXTENSION *) & data[pos]);
+ break;
+ case ';':
+ PRINT ("hit terminator at %d!\n", pos);
+ return result; /* terminator! */
+ default: /* raster data block */
+ PRINT ("skipping data block at %d\n", pos);
+ pos = skipDataBlock (data, pos + 1, size);
+ break;
+ }
}
- }
- PRINT("returning at %d\n",pos);
+ PRINT ("returning at %d\n", pos);
return result;
}
-
Modified: Extractor/src/plugins/hash/md5extractor.c
===================================================================
--- Extractor/src/plugins/hash/md5extractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/hash/md5extractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -34,17 +34,17 @@
# define UINT_MAX_32_BITS 4294967295U
# if UINT_MAX == UINT_MAX_32_BITS
- typedef unsigned int md5_uint32;
+typedef unsigned int md5_uint32;
# else
# if USHRT_MAX == UINT_MAX_32_BITS
- typedef unsigned short md5_uint32;
+typedef unsigned short md5_uint32;
# else
# if ULONG_MAX == UINT_MAX_32_BITS
- typedef unsigned long md5_uint32;
+typedef unsigned long md5_uint32;
# else
/* The following line is intended to evoke an error.
Using #error is not portable enough. */
- "Cannot determine unsigned 32-bit data type."
+"Cannot determine unsigned 32-bit data type."
# endif
# endif
# endif
@@ -87,7 +87,7 @@
/* This array contains the bytes used to pad the buffer to the next
64-byte boundary. (RFC 1321, 3.1: Step 1) */
-static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
+static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
@@ -134,11 +134,11 @@
md5_uint32 D_save = D;
/* First round: using the given function, the context and a constant
- the next context is computed. Because the algorithms processing
- unit is a 32-bit word and it is determined to work on words in
- little endian byte order we perhaps have to change the byte order
- before the computation. To reduce the work for the next steps
- we store the swapped words in the array CORRECT_WORDS. */
+ the next context is computed. Because the algorithms processing
+ unit is a 32-bit word and it is determined to work on words in
+ little endian byte order we perhaps have to change the byte order
+ before the computation. To reduce the work for the next steps
+ we store the swapped words in the array CORRECT_WORDS. */
#define OP(a, b, c, d, s, T) \
do \
@@ -151,33 +151,33 @@
while (0)
/* Before we start, one word to the strange constants.
- They are defined in RFC 1321 as
+ They are defined in RFC 1321 as
- T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64, or
- perl -e 'foreach(1..64){printf "0x%08x\n", int (4294967296 * abs (sin
$_))}'
+ T[i] = (int) (4294967296.0 * fabs (sin (i))), i=1..64, or
+ perl -e 'foreach(1..64){printf "0x%08x\n", int (4294967296 * abs (sin
$_))}'
*/
/* Round 1. */
- OP (A, B, C, D, 7, 0xd76aa478);
+ OP (A, B, C, D, 7, 0xd76aa478);
OP (D, A, B, C, 12, 0xe8c7b756);
OP (C, D, A, B, 17, 0x242070db);
OP (B, C, D, A, 22, 0xc1bdceee);
- OP (A, B, C, D, 7, 0xf57c0faf);
+ OP (A, B, C, D, 7, 0xf57c0faf);
OP (D, A, B, C, 12, 0x4787c62a);
OP (C, D, A, B, 17, 0xa8304613);
OP (B, C, D, A, 22, 0xfd469501);
- OP (A, B, C, D, 7, 0x698098d8);
+ OP (A, B, C, D, 7, 0x698098d8);
OP (D, A, B, C, 12, 0x8b44f7af);
OP (C, D, A, B, 17, 0xffff5bb1);
OP (B, C, D, A, 22, 0x895cd7be);
- OP (A, B, C, D, 7, 0x6b901122);
+ OP (A, B, C, D, 7, 0x6b901122);
OP (D, A, B, C, 12, 0xfd987193);
OP (C, D, A, B, 17, 0xa679438e);
OP (B, C, D, A, 22, 0x49b40821);
/* For the second to fourth round we have the possibly swapped words
- in CORRECT_WORDS. Redefine the macro to take an additional first
- argument specifying the function to use. */
+ in CORRECT_WORDS. Redefine the macro to take an additional first
+ argument specifying the function to use. */
#undef OP
#define OP(f, a, b, c, d, k, s, T) \
do \
@@ -189,58 +189,58 @@
while (0)
/* Round 2. */
- OP (FG, A, B, C, D, 1, 5, 0xf61e2562);
- OP (FG, D, A, B, C, 6, 9, 0xc040b340);
+ OP (FG, A, B, C, D, 1, 5, 0xf61e2562);
+ OP (FG, D, A, B, C, 6, 9, 0xc040b340);
OP (FG, C, D, A, B, 11, 14, 0x265e5a51);
- OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa);
- OP (FG, A, B, C, D, 5, 5, 0xd62f105d);
- OP (FG, D, A, B, C, 10, 9, 0x02441453);
+ OP (FG, B, C, D, A, 0, 20, 0xe9b6c7aa);
+ OP (FG, A, B, C, D, 5, 5, 0xd62f105d);
+ OP (FG, D, A, B, C, 10, 9, 0x02441453);
OP (FG, C, D, A, B, 15, 14, 0xd8a1e681);
- OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8);
- OP (FG, A, B, C, D, 9, 5, 0x21e1cde6);
- OP (FG, D, A, B, C, 14, 9, 0xc33707d6);
- OP (FG, C, D, A, B, 3, 14, 0xf4d50d87);
- OP (FG, B, C, D, A, 8, 20, 0x455a14ed);
- OP (FG, A, B, C, D, 13, 5, 0xa9e3e905);
- OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8);
- OP (FG, C, D, A, B, 7, 14, 0x676f02d9);
+ OP (FG, B, C, D, A, 4, 20, 0xe7d3fbc8);
+ OP (FG, A, B, C, D, 9, 5, 0x21e1cde6);
+ OP (FG, D, A, B, C, 14, 9, 0xc33707d6);
+ OP (FG, C, D, A, B, 3, 14, 0xf4d50d87);
+ OP (FG, B, C, D, A, 8, 20, 0x455a14ed);
+ OP (FG, A, B, C, D, 13, 5, 0xa9e3e905);
+ OP (FG, D, A, B, C, 2, 9, 0xfcefa3f8);
+ OP (FG, C, D, A, B, 7, 14, 0x676f02d9);
OP (FG, B, C, D, A, 12, 20, 0x8d2a4c8a);
/* Round 3. */
- OP (FH, A, B, C, D, 5, 4, 0xfffa3942);
- OP (FH, D, A, B, C, 8, 11, 0x8771f681);
+ OP (FH, A, B, C, D, 5, 4, 0xfffa3942);
+ OP (FH, D, A, B, C, 8, 11, 0x8771f681);
OP (FH, C, D, A, B, 11, 16, 0x6d9d6122);
OP (FH, B, C, D, A, 14, 23, 0xfde5380c);
- OP (FH, A, B, C, D, 1, 4, 0xa4beea44);
- OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9);
- OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60);
+ OP (FH, A, B, C, D, 1, 4, 0xa4beea44);
+ OP (FH, D, A, B, C, 4, 11, 0x4bdecfa9);
+ OP (FH, C, D, A, B, 7, 16, 0xf6bb4b60);
OP (FH, B, C, D, A, 10, 23, 0xbebfbc70);
- OP (FH, A, B, C, D, 13, 4, 0x289b7ec6);
- OP (FH, D, A, B, C, 0, 11, 0xeaa127fa);
- OP (FH, C, D, A, B, 3, 16, 0xd4ef3085);
- OP (FH, B, C, D, A, 6, 23, 0x04881d05);
- OP (FH, A, B, C, D, 9, 4, 0xd9d4d039);
+ OP (FH, A, B, C, D, 13, 4, 0x289b7ec6);
+ OP (FH, D, A, B, C, 0, 11, 0xeaa127fa);
+ OP (FH, C, D, A, B, 3, 16, 0xd4ef3085);
+ OP (FH, B, C, D, A, 6, 23, 0x04881d05);
+ OP (FH, A, B, C, D, 9, 4, 0xd9d4d039);
OP (FH, D, A, B, C, 12, 11, 0xe6db99e5);
OP (FH, C, D, A, B, 15, 16, 0x1fa27cf8);
- OP (FH, B, C, D, A, 2, 23, 0xc4ac5665);
+ OP (FH, B, C, D, A, 2, 23, 0xc4ac5665);
/* Round 4. */
- OP (FI, A, B, C, D, 0, 6, 0xf4292244);
- OP (FI, D, A, B, C, 7, 10, 0x432aff97);
+ OP (FI, A, B, C, D, 0, 6, 0xf4292244);
+ OP (FI, D, A, B, C, 7, 10, 0x432aff97);
OP (FI, C, D, A, B, 14, 15, 0xab9423a7);
- OP (FI, B, C, D, A, 5, 21, 0xfc93a039);
- OP (FI, A, B, C, D, 12, 6, 0x655b59c3);
- OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92);
+ OP (FI, B, C, D, A, 5, 21, 0xfc93a039);
+ OP (FI, A, B, C, D, 12, 6, 0x655b59c3);
+ OP (FI, D, A, B, C, 3, 10, 0x8f0ccc92);
OP (FI, C, D, A, B, 10, 15, 0xffeff47d);
- OP (FI, B, C, D, A, 1, 21, 0x85845dd1);
- OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f);
+ OP (FI, B, C, D, A, 1, 21, 0x85845dd1);
+ OP (FI, A, B, C, D, 8, 6, 0x6fa87e4f);
OP (FI, D, A, B, C, 15, 10, 0xfe2ce6e0);
- OP (FI, C, D, A, B, 6, 15, 0xa3014314);
+ OP (FI, C, D, A, B, 6, 15, 0xa3014314);
OP (FI, B, C, D, A, 13, 21, 0x4e0811a1);
- OP (FI, A, B, C, D, 4, 6, 0xf7537e82);
+ OP (FI, A, B, C, D, 4, 6, 0xf7537e82);
OP (FI, D, A, B, C, 11, 10, 0xbd3af235);
- OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb);
- OP (FI, B, C, D, A, 9, 21, 0xeb86d391);
+ OP (FI, C, D, A, B, 2, 15, 0x2ad7d2bb);
+ OP (FI, B, C, D, A, 9, 21, 0xeb86d391);
/* Add the starting values of the context. */
A += A_save;
@@ -271,14 +271,14 @@
ctx->buflen += add;
if (ctx->buflen > 64)
- {
- md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
+ {
+ md5_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
- ctx->buflen &= 63;
- /* The regions in the following copy operation cannot overlap. */
- memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63],
- ctx->buflen);
- }
+ ctx->buflen &= 63;
+ /* The regions in the following copy operation cannot overlap. */
+ memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63],
+ ctx->buflen);
+ }
buffer = (const char *) buffer + add;
len -= add;
@@ -296,19 +296,19 @@
# define UNALIGNED_P(p) (((md5_uintptr) p) % sizeof (md5_uint32) != 0)
# endif
if (UNALIGNED_P (buffer))
- while (len > 64)
- {
- md5_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
- buffer = (const char *) buffer + 64;
- len -= 64;
- }
+ while (len > 64)
+ {
+ md5_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
+ buffer = (const char *) buffer + 64;
+ len -= 64;
+ }
else
#endif
- {
- md5_process_block (buffer, len & ~63, ctx);
- buffer = (const char *) buffer + (len & ~63);
- len &= 63;
- }
+ {
+ md5_process_block (buffer, len & ~63, ctx);
+ buffer = (const char *) buffer + (len & ~63);
+ len &= 63;
+ }
}
/* Move remaining bytes in internal buffer. */
@@ -319,11 +319,11 @@
memcpy (&ctx->buffer[left_over], buffer, len);
left_over += len;
if (left_over >= 64)
- {
- md5_process_block (ctx->buffer, 64, ctx);
- left_over -= 64;
- memcpy (ctx->buffer, &ctx->buffer[64], left_over);
- }
+ {
+ md5_process_block (ctx->buffer, 64, ctx);
+ left_over -= 64;
+ memcpy (ctx->buffer, &ctx->buffer[64], left_over);
+ }
ctx->buflen = left_over;
}
}
@@ -380,9 +380,9 @@
memcpy (&ctx->buffer[bytes], fillbuf, pad);
/* Put the 64-bit file length in *bits* at the end of the buffer. */
- *(md5_uint32 *) &ctx->buffer[bytes + pad] = SWAP (ctx->total[0] << 3);
- *(md5_uint32 *) &ctx->buffer[bytes + pad + 4] = SWAP ((ctx->total[1] << 3) |
- (ctx->total[0] >> 29));
+ *(md5_uint32 *) & ctx->buffer[bytes + pad] = SWAP (ctx->total[0] << 3);
+ *(md5_uint32 *) & ctx->buffer[bytes + pad + 4] =
+ SWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
/* Process last bytes. */
md5_process_block (ctx->buffer, bytes + pad + 8, ctx);
@@ -413,16 +413,16 @@
static struct EXTRACTOR_Keywords *
-addKeyword(EXTRACTOR_KeywordList *oldhead,
- const char *phrase,
- EXTRACTOR_KeywordType type) {
+addKeyword (EXTRACTOR_KeywordList * oldhead,
+ const char *phrase, EXTRACTOR_KeywordType type)
+{
- EXTRACTOR_KeywordList * keyword;
- keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList));
- keyword->next = oldhead;
- keyword->keyword = strdup(phrase);
- keyword->keywordType = type;
- return keyword;
+ EXTRACTOR_KeywordList *keyword;
+ keyword = (EXTRACTOR_KeywordList *) malloc (sizeof (EXTRACTOR_KeywordList));
+ keyword->next = oldhead;
+ keyword->keyword = strdup (phrase);
+ keyword->keywordType = type;
+ return keyword;
}
@@ -433,27 +433,23 @@
#define MAX_DIGEST_BIN_BYTES DIGEST_BIN_BYTES
struct EXTRACTOR_Keywords *
-libextractor_hash_md5_extract(const char * filename,
- const char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev) {
+libextractor_hash_md5_extract (const char *filename,
+ const char *data,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
unsigned char bin_buffer[MAX_DIGEST_BIN_BYTES];
char hash[8 * MAX_DIGEST_BIN_BYTES];
char buf[16];
int i;
- md5_buffer(data, size, bin_buffer);
+ md5_buffer (data, size, bin_buffer);
hash[0] = '\0';
- for (i=0;i<DIGEST_HEX_BYTES / 2; i++) {
- snprintf(buf,
- 16,
- "%02x",
- bin_buffer[i]);
- strcat(hash, buf);
- }
- prev = addKeyword(prev,
- hash,
- EXTRACTOR_HASH_MD5);
+ for (i = 0; i < DIGEST_HEX_BYTES / 2; i++)
+ {
+ snprintf (buf, 16, "%02x", bin_buffer[i]);
+ strcat (hash, buf);
+ }
+ prev = addKeyword (prev, hash, EXTRACTOR_HASH_MD5);
return prev;
}
Modified: Extractor/src/plugins/hash/rmd160extractor.c
===================================================================
--- Extractor/src/plugins/hash/rmd160extractor.c 2007-07-29 08:04:12 UTC
(rev 5367)
+++ Extractor/src/plugins/hash/rmd160extractor.c 2007-07-29 08:35:49 UTC
(rev 5368)
@@ -39,26 +39,27 @@
typedef unsigned char rmd160uint32;
#else
typedef unsigned short rmd160uint32;
-#endif /*UCHAR_MAX*/
+#endif /*UCHAR_MAX */
#else
typedef unsigned int rmd160uint32;
-#endif /*USHRT_MAX*/
+#endif /*USHRT_MAX */
#else
typedef unsigned long rmd160uint32;
-#endif /*UINT_MAX*/
+#endif /*UINT_MAX */
#else
typedef unsigned long rmd160uint32;
#endif
-struct rmd160_object {
- rmd160uint32 data [16] ;
- rmd160uint32 state [5] ;
- rmd160uint32 len [2] ;
- rmd160uint32 * wptr ;
- rmd160uint32 * wend ;
- unsigned int bpos ;
+struct rmd160_object
+{
+ rmd160uint32 data[16];
+ rmd160uint32 state[5];
+ rmd160uint32 len[2];
+ rmd160uint32 *wptr;
+ rmd160uint32 *wend;
+ unsigned int bpos;
};
-typedef struct rmd160_object * RMD160 ;
+typedef struct rmd160_object *RMD160;
#define RMD160_OK 0
#define RMD160_ERR_INVALID_ARG 1
@@ -76,20 +77,16 @@
#define FUNCTION_NAME "rmd160_calc"
static int
-_rmd160_calc (
- rmd160uint32 * state
-,
- rmd160uint32 * data
-)
+_rmd160_calc (rmd160uint32 * state, rmd160uint32 * data)
{
- rmd160uint32 x0,x1,x2,x3,x4;
- rmd160uint32 y0,y1,y2,y3,y4;
+ rmd160uint32 x0, x1, x2, x3, x4;
+ rmd160uint32 y0, y1, y2, y3, y4;
- x0 = y0 = state[0];
- x1 = y1 = state[1];
- x2 = y2 = state[2];
- x3 = y3 = state[3];
- x4 = y4 = state[4];
+ x0 = y0 = state[0];
+ x1 = y1 = state[1];
+ x2 = y2 = state[2];
+ x3 = y3 = state[3];
+ x4 = y4 = state[4];
#define RL(x,n) (((x) << (n)) | ((x) >> (32-(n))))
@@ -142,184 +139,184 @@
(a) = RL((a),(s)) + (e); \
(c) = RL((c),10);}
- T1( x0 , x1 , x2 , x3 , x4 , data[ 0] , 11 );
- T1( x4 , x0 , x1 , x2 , x3 , data[ 1] , 14 );
- T1( x3 , x4 , x0 , x1 , x2 , data[ 2] , 15 );
- T1( x2 , x3 , x4 , x0 , x1 , data[ 3] , 12 );
- T1( x1 , x2 , x3 , x4 , x0 , data[ 4] , 5 );
- T1( x0 , x1 , x2 , x3 , x4 , data[ 5] , 8 );
- T1( x4 , x0 , x1 , x2 , x3 , data[ 6] , 7 );
- T1( x3 , x4 , x0 , x1 , x2 , data[ 7] , 9 );
- T1( x2 , x3 , x4 , x0 , x1 , data[ 8] , 11 );
- T1( x1 , x2 , x3 , x4 , x0 , data[ 9] , 13 );
- T1( x0 , x1 , x2 , x3 , x4 , data[10] , 14 );
- T1( x4 , x0 , x1 , x2 , x3 , data[11] , 15 );
- T1( x3 , x4 , x0 , x1 , x2 , data[12] , 6 );
- T1( x2 , x3 , x4 , x0 , x1 , data[13] , 7 );
- T1( x1 , x2 , x3 , x4 , x0 , data[14] , 9 );
- T1( x0 , x1 , x2 , x3 , x4 , data[15] , 8 );
+ T1 (x0, x1, x2, x3, x4, data[0], 11);
+ T1 (x4, x0, x1, x2, x3, data[1], 14);
+ T1 (x3, x4, x0, x1, x2, data[2], 15);
+ T1 (x2, x3, x4, x0, x1, data[3], 12);
+ T1 (x1, x2, x3, x4, x0, data[4], 5);
+ T1 (x0, x1, x2, x3, x4, data[5], 8);
+ T1 (x4, x0, x1, x2, x3, data[6], 7);
+ T1 (x3, x4, x0, x1, x2, data[7], 9);
+ T1 (x2, x3, x4, x0, x1, data[8], 11);
+ T1 (x1, x2, x3, x4, x0, data[9], 13);
+ T1 (x0, x1, x2, x3, x4, data[10], 14);
+ T1 (x4, x0, x1, x2, x3, data[11], 15);
+ T1 (x3, x4, x0, x1, x2, data[12], 6);
+ T1 (x2, x3, x4, x0, x1, data[13], 7);
+ T1 (x1, x2, x3, x4, x0, data[14], 9);
+ T1 (x0, x1, x2, x3, x4, data[15], 8);
- T2( x4 , x0 , x1 , x2 , x3 , data[ 7] , 7 );
- T2( x3 , x4 , x0 , x1 , x2 , data[ 4] , 6 );
- T2( x2 , x3 , x4 , x0 , x1 , data[13] , 8 );
- T2( x1 , x2 , x3 , x4 , x0 , data[ 1] , 13 );
- T2( x0 , x1 , x2 , x3 , x4 , data[10] , 11 );
- T2( x4 , x0 , x1 , x2 , x3 , data[ 6] , 9 );
- T2( x3 , x4 , x0 , x1 , x2 , data[15] , 7 );
- T2( x2 , x3 , x4 , x0 , x1 , data[ 3] , 15 );
- T2( x1 , x2 , x3 , x4 , x0 , data[12] , 7 );
- T2( x0 , x1 , x2 , x3 , x4 , data[ 0] , 12 );
- T2( x4 , x0 , x1 , x2 , x3 , data[ 9] , 15 );
- T2( x3 , x4 , x0 , x1 , x2 , data[ 5] , 9 );
- T2( x2 , x3 , x4 , x0 , x1 , data[ 2] , 11 );
- T2( x1 , x2 , x3 , x4 , x0 , data[14] , 7 );
- T2( x0 , x1 , x2 , x3 , x4 , data[11] , 13 );
- T2( x4 , x0 , x1 , x2 , x3 , data[ 8] , 12 );
+ T2 (x4, x0, x1, x2, x3, data[7], 7);
+ T2 (x3, x4, x0, x1, x2, data[4], 6);
+ T2 (x2, x3, x4, x0, x1, data[13], 8);
+ T2 (x1, x2, x3, x4, x0, data[1], 13);
+ T2 (x0, x1, x2, x3, x4, data[10], 11);
+ T2 (x4, x0, x1, x2, x3, data[6], 9);
+ T2 (x3, x4, x0, x1, x2, data[15], 7);
+ T2 (x2, x3, x4, x0, x1, data[3], 15);
+ T2 (x1, x2, x3, x4, x0, data[12], 7);
+ T2 (x0, x1, x2, x3, x4, data[0], 12);
+ T2 (x4, x0, x1, x2, x3, data[9], 15);
+ T2 (x3, x4, x0, x1, x2, data[5], 9);
+ T2 (x2, x3, x4, x0, x1, data[2], 11);
+ T2 (x1, x2, x3, x4, x0, data[14], 7);
+ T2 (x0, x1, x2, x3, x4, data[11], 13);
+ T2 (x4, x0, x1, x2, x3, data[8], 12);
- T3( x3 , x4 , x0 , x1 , x2 , data[ 3] , 11 );
- T3( x2 , x3 , x4 , x0 , x1 , data[10] , 13 );
- T3( x1 , x2 , x3 , x4 , x0 , data[14] , 6 );
- T3( x0 , x1 , x2 , x3 , x4 , data[ 4] , 7 );
- T3( x4 , x0 , x1 , x2 , x3 , data[ 9] , 14 );
- T3( x3 , x4 , x0 , x1 , x2 , data[15] , 9 );
- T3( x2 , x3 , x4 , x0 , x1 , data[ 8] , 13 );
- T3( x1 , x2 , x3 , x4 , x0 , data[ 1] , 15 );
- T3( x0 , x1 , x2 , x3 , x4 , data[ 2] , 14 );
- T3( x4 , x0 , x1 , x2 , x3 , data[ 7] , 8 );
- T3( x3 , x4 , x0 , x1 , x2 , data[ 0] , 13 );
- T3( x2 , x3 , x4 , x0 , x1 , data[ 6] , 6 );
- T3( x1 , x2 , x3 , x4 , x0 , data[13] , 5 );
- T3( x0 , x1 , x2 , x3 , x4 , data[11] , 12 );
- T3( x4 , x0 , x1 , x2 , x3 , data[ 5] , 7 );
- T3( x3 , x4 , x0 , x1 , x2 , data[12] , 5 );
+ T3 (x3, x4, x0, x1, x2, data[3], 11);
+ T3 (x2, x3, x4, x0, x1, data[10], 13);
+ T3 (x1, x2, x3, x4, x0, data[14], 6);
+ T3 (x0, x1, x2, x3, x4, data[4], 7);
+ T3 (x4, x0, x1, x2, x3, data[9], 14);
+ T3 (x3, x4, x0, x1, x2, data[15], 9);
+ T3 (x2, x3, x4, x0, x1, data[8], 13);
+ T3 (x1, x2, x3, x4, x0, data[1], 15);
+ T3 (x0, x1, x2, x3, x4, data[2], 14);
+ T3 (x4, x0, x1, x2, x3, data[7], 8);
+ T3 (x3, x4, x0, x1, x2, data[0], 13);
+ T3 (x2, x3, x4, x0, x1, data[6], 6);
+ T3 (x1, x2, x3, x4, x0, data[13], 5);
+ T3 (x0, x1, x2, x3, x4, data[11], 12);
+ T3 (x4, x0, x1, x2, x3, data[5], 7);
+ T3 (x3, x4, x0, x1, x2, data[12], 5);
- T4( x2 , x3 , x4 , x0 , x1 , data[ 1] , 11 );
- T4( x1 , x2 , x3 , x4 , x0 , data[ 9] , 12 );
- T4( x0 , x1 , x2 , x3 , x4 , data[11] , 14 );
- T4( x4 , x0 , x1 , x2 , x3 , data[10] , 15 );
- T4( x3 , x4 , x0 , x1 , x2 , data[ 0] , 14 );
- T4( x2 , x3 , x4 , x0 , x1 , data[ 8] , 15 );
- T4( x1 , x2 , x3 , x4 , x0 , data[12] , 9 );
- T4( x0 , x1 , x2 , x3 , x4 , data[ 4] , 8 );
- T4( x4 , x0 , x1 , x2 , x3 , data[13] , 9 );
- T4( x3 , x4 , x0 , x1 , x2 , data[ 3] , 14 );
- T4( x2 , x3 , x4 , x0 , x1 , data[ 7] , 5 );
- T4( x1 , x2 , x3 , x4 , x0 , data[15] , 6 );
- T4( x0 , x1 , x2 , x3 , x4 , data[14] , 8 );
- T4( x4 , x0 , x1 , x2 , x3 , data[ 5] , 6 );
- T4( x3 , x4 , x0 , x1 , x2 , data[ 6] , 5 );
- T4( x2 , x3 , x4 , x0 , x1 , data[ 2] , 12 );
+ T4 (x2, x3, x4, x0, x1, data[1], 11);
+ T4 (x1, x2, x3, x4, x0, data[9], 12);
+ T4 (x0, x1, x2, x3, x4, data[11], 14);
+ T4 (x4, x0, x1, x2, x3, data[10], 15);
+ T4 (x3, x4, x0, x1, x2, data[0], 14);
+ T4 (x2, x3, x4, x0, x1, data[8], 15);
+ T4 (x1, x2, x3, x4, x0, data[12], 9);
+ T4 (x0, x1, x2, x3, x4, data[4], 8);
+ T4 (x4, x0, x1, x2, x3, data[13], 9);
+ T4 (x3, x4, x0, x1, x2, data[3], 14);
+ T4 (x2, x3, x4, x0, x1, data[7], 5);
+ T4 (x1, x2, x3, x4, x0, data[15], 6);
+ T4 (x0, x1, x2, x3, x4, data[14], 8);
+ T4 (x4, x0, x1, x2, x3, data[5], 6);
+ T4 (x3, x4, x0, x1, x2, data[6], 5);
+ T4 (x2, x3, x4, x0, x1, data[2], 12);
- T5( x1 , x2 , x3 , x4 , x0 , data[ 4] , 9 );
- T5( x0 , x1 , x2 , x3 , x4 , data[ 0] , 15 );
- T5( x4 , x0 , x1 , x2 , x3 , data[ 5] , 5 );
- T5( x3 , x4 , x0 , x1 , x2 , data[ 9] , 11 );
- T5( x2 , x3 , x4 , x0 , x1 , data[ 7] , 6 );
- T5( x1 , x2 , x3 , x4 , x0 , data[12] , 8 );
- T5( x0 , x1 , x2 , x3 , x4 , data[ 2] , 13 );
- T5( x4 , x0 , x1 , x2 , x3 , data[10] , 12 );
- T5( x3 , x4 , x0 , x1 , x2 , data[14] , 5 );
- T5( x2 , x3 , x4 , x0 , x1 , data[ 1] , 12 );
- T5( x1 , x2 , x3 , x4 , x0 , data[ 3] , 13 );
- T5( x0 , x1 , x2 , x3 , x4 , data[ 8] , 14 );
- T5( x4 , x0 , x1 , x2 , x3 , data[11] , 11 );
- T5( x3 , x4 , x0 , x1 , x2 , data[ 6] , 8 );
- T5( x2 , x3 , x4 , x0 , x1 , data[15] , 5 );
- T5( x1 , x2 , x3 , x4 , x0 , data[13] , 6 );
+ T5 (x1, x2, x3, x4, x0, data[4], 9);
+ T5 (x0, x1, x2, x3, x4, data[0], 15);
+ T5 (x4, x0, x1, x2, x3, data[5], 5);
+ T5 (x3, x4, x0, x1, x2, data[9], 11);
+ T5 (x2, x3, x4, x0, x1, data[7], 6);
+ T5 (x1, x2, x3, x4, x0, data[12], 8);
+ T5 (x0, x1, x2, x3, x4, data[2], 13);
+ T5 (x4, x0, x1, x2, x3, data[10], 12);
+ T5 (x3, x4, x0, x1, x2, data[14], 5);
+ T5 (x2, x3, x4, x0, x1, data[1], 12);
+ T5 (x1, x2, x3, x4, x0, data[3], 13);
+ T5 (x0, x1, x2, x3, x4, data[8], 14);
+ T5 (x4, x0, x1, x2, x3, data[11], 11);
+ T5 (x3, x4, x0, x1, x2, data[6], 8);
+ T5 (x2, x3, x4, x0, x1, data[15], 5);
+ T5 (x1, x2, x3, x4, x0, data[13], 6);
- S5( y0 , y1 , y2 , y3 , y4 , data[ 5] , 8 );
- S5( y4 , y0 , y1 , y2 , y3 , data[14] , 9 );
- S5( y3 , y4 , y0 , y1 , y2 , data[ 7] , 9 );
- S5( y2 , y3 , y4 , y0 , y1 , data[ 0] , 11 );
- S5( y1 , y2 , y3 , y4 , y0 , data[ 9] , 13 );
- S5( y0 , y1 , y2 , y3 , y4 , data[ 2] , 15 );
- S5( y4 , y0 , y1 , y2 , y3 , data[11] , 15 );
- S5( y3 , y4 , y0 , y1 , y2 , data[ 4] , 5 );
- S5( y2 , y3 , y4 , y0 , y1 , data[13] , 7 );
- S5( y1 , y2 , y3 , y4 , y0 , data[ 6] , 7 );
- S5( y0 , y1 , y2 , y3 , y4 , data[15] , 8 );
- S5( y4 , y0 , y1 , y2 , y3 , data[ 8] , 11 );
- S5( y3 , y4 , y0 , y1 , y2 , data[ 1] , 14 );
- S5( y2 , y3 , y4 , y0 , y1 , data[10] , 14 );
- S5( y1 , y2 , y3 , y4 , y0 , data[ 3] , 12 );
- S5( y0 , y1 , y2 , y3 , y4 , data[12] , 6 );
+ S5 (y0, y1, y2, y3, y4, data[5], 8);
+ S5 (y4, y0, y1, y2, y3, data[14], 9);
+ S5 (y3, y4, y0, y1, y2, data[7], 9);
+ S5 (y2, y3, y4, y0, y1, data[0], 11);
+ S5 (y1, y2, y3, y4, y0, data[9], 13);
+ S5 (y0, y1, y2, y3, y4, data[2], 15);
+ S5 (y4, y0, y1, y2, y3, data[11], 15);
+ S5 (y3, y4, y0, y1, y2, data[4], 5);
+ S5 (y2, y3, y4, y0, y1, data[13], 7);
+ S5 (y1, y2, y3, y4, y0, data[6], 7);
+ S5 (y0, y1, y2, y3, y4, data[15], 8);
+ S5 (y4, y0, y1, y2, y3, data[8], 11);
+ S5 (y3, y4, y0, y1, y2, data[1], 14);
+ S5 (y2, y3, y4, y0, y1, data[10], 14);
+ S5 (y1, y2, y3, y4, y0, data[3], 12);
+ S5 (y0, y1, y2, y3, y4, data[12], 6);
- S4( y4 , y0 , y1 , y2 , y3 , data[ 6] , 9 );
- S4( y3 , y4 , y0 , y1 , y2 , data[11] , 13 );
- S4( y2 , y3 , y4 , y0 , y1 , data[ 3] , 15 );
- S4( y1 , y2 , y3 , y4 , y0 , data[ 7] , 7 );
- S4( y0 , y1 , y2 , y3 , y4 , data[ 0] , 12 );
- S4( y4 , y0 , y1 , y2 , y3 , data[13] , 8 );
- S4( y3 , y4 , y0 , y1 , y2 , data[ 5] , 9 );
- S4( y2 , y3 , y4 , y0 , y1 , data[10] , 11 );
- S4( y1 , y2 , y3 , y4 , y0 , data[14] , 7 );
- S4( y0 , y1 , y2 , y3 , y4 , data[15] , 7 );
- S4( y4 , y0 , y1 , y2 , y3 , data[ 8] , 12 );
- S4( y3 , y4 , y0 , y1 , y2 , data[12] , 7 );
- S4( y2 , y3 , y4 , y0 , y1 , data[ 4] , 6 );
- S4( y1 , y2 , y3 , y4 , y0 , data[ 9] , 15 );
- S4( y0 , y1 , y2 , y3 , y4 , data[ 1] , 13 );
- S4( y4 , y0 , y1 , y2 , y3 , data[ 2] , 11 );
+ S4 (y4, y0, y1, y2, y3, data[6], 9);
+ S4 (y3, y4, y0, y1, y2, data[11], 13);
+ S4 (y2, y3, y4, y0, y1, data[3], 15);
+ S4 (y1, y2, y3, y4, y0, data[7], 7);
+ S4 (y0, y1, y2, y3, y4, data[0], 12);
+ S4 (y4, y0, y1, y2, y3, data[13], 8);
+ S4 (y3, y4, y0, y1, y2, data[5], 9);
+ S4 (y2, y3, y4, y0, y1, data[10], 11);
+ S4 (y1, y2, y3, y4, y0, data[14], 7);
+ S4 (y0, y1, y2, y3, y4, data[15], 7);
+ S4 (y4, y0, y1, y2, y3, data[8], 12);
+ S4 (y3, y4, y0, y1, y2, data[12], 7);
+ S4 (y2, y3, y4, y0, y1, data[4], 6);
+ S4 (y1, y2, y3, y4, y0, data[9], 15);
+ S4 (y0, y1, y2, y3, y4, data[1], 13);
+ S4 (y4, y0, y1, y2, y3, data[2], 11);
- S3( y3 , y4 , y0 , y1 , y2 , data[15] , 9 );
- S3( y2 , y3 , y4 , y0 , y1 , data[ 5] , 7 );
- S3( y1 , y2 , y3 , y4 , y0 , data[ 1] , 15 );
- S3( y0 , y1 , y2 , y3 , y4 , data[ 3] , 11 );
- S3( y4 , y0 , y1 , y2 , y3 , data[ 7] , 8 );
- S3( y3 , y4 , y0 , y1 , y2 , data[14] , 6 );
- S3( y2 , y3 , y4 , y0 , y1 , data[ 6] , 6 );
- S3( y1 , y2 , y3 , y4 , y0 , data[ 9] , 14 );
- S3( y0 , y1 , y2 , y3 , y4 , data[11] , 12 );
- S3( y4 , y0 , y1 , y2 , y3 , data[ 8] , 13 );
- S3( y3 , y4 , y0 , y1 , y2 , data[12] , 5 );
- S3( y2 , y3 , y4 , y0 , y1 , data[ 2] , 14 );
- S3( y1 , y2 , y3 , y4 , y0 , data[10] , 13 );
- S3( y0 , y1 , y2 , y3 , y4 , data[ 0] , 13 );
- S3( y4 , y0 , y1 , y2 , y3 , data[ 4] , 7 );
- S3( y3 , y4 , y0 , y1 , y2 , data[13] , 5 );
+ S3 (y3, y4, y0, y1, y2, data[15], 9);
+ S3 (y2, y3, y4, y0, y1, data[5], 7);
+ S3 (y1, y2, y3, y4, y0, data[1], 15);
+ S3 (y0, y1, y2, y3, y4, data[3], 11);
+ S3 (y4, y0, y1, y2, y3, data[7], 8);
+ S3 (y3, y4, y0, y1, y2, data[14], 6);
+ S3 (y2, y3, y4, y0, y1, data[6], 6);
+ S3 (y1, y2, y3, y4, y0, data[9], 14);
+ S3 (y0, y1, y2, y3, y4, data[11], 12);
+ S3 (y4, y0, y1, y2, y3, data[8], 13);
+ S3 (y3, y4, y0, y1, y2, data[12], 5);
+ S3 (y2, y3, y4, y0, y1, data[2], 14);
+ S3 (y1, y2, y3, y4, y0, data[10], 13);
+ S3 (y0, y1, y2, y3, y4, data[0], 13);
+ S3 (y4, y0, y1, y2, y3, data[4], 7);
+ S3 (y3, y4, y0, y1, y2, data[13], 5);
- S2( y2 , y3 , y4 , y0 , y1 , data[ 8] , 15 );
- S2( y1 , y2 , y3 , y4 , y0 , data[ 6] , 5 );
- S2( y0 , y1 , y2 , y3 , y4 , data[ 4] , 8 );
- S2( y4 , y0 , y1 , y2 , y3 , data[ 1] , 11 );
- S2( y3 , y4 , y0 , y1 , y2 , data[ 3] , 14 );
- S2( y2 , y3 , y4 , y0 , y1 , data[11] , 14 );
- S2( y1 , y2 , y3 , y4 , y0 , data[15] , 6 );
- S2( y0 , y1 , y2 , y3 , y4 , data[ 0] , 14 );
- S2( y4 , y0 , y1 , y2 , y3 , data[ 5] , 6 );
- S2( y3 , y4 , y0 , y1 , y2 , data[12] , 9 );
- S2( y2 , y3 , y4 , y0 , y1 , data[ 2] , 12 );
- S2( y1 , y2 , y3 , y4 , y0 , data[13] , 9 );
- S2( y0 , y1 , y2 , y3 , y4 , data[ 9] , 12 );
- S2( y4 , y0 , y1 , y2 , y3 , data[ 7] , 5 );
- S2( y3 , y4 , y0 , y1 , y2 , data[10] , 15 );
- S2( y2 , y3 , y4 , y0 , y1 , data[14] , 8 );
+ S2 (y2, y3, y4, y0, y1, data[8], 15);
+ S2 (y1, y2, y3, y4, y0, data[6], 5);
+ S2 (y0, y1, y2, y3, y4, data[4], 8);
+ S2 (y4, y0, y1, y2, y3, data[1], 11);
+ S2 (y3, y4, y0, y1, y2, data[3], 14);
+ S2 (y2, y3, y4, y0, y1, data[11], 14);
+ S2 (y1, y2, y3, y4, y0, data[15], 6);
+ S2 (y0, y1, y2, y3, y4, data[0], 14);
+ S2 (y4, y0, y1, y2, y3, data[5], 6);
+ S2 (y3, y4, y0, y1, y2, data[12], 9);
+ S2 (y2, y3, y4, y0, y1, data[2], 12);
+ S2 (y1, y2, y3, y4, y0, data[13], 9);
+ S2 (y0, y1, y2, y3, y4, data[9], 12);
+ S2 (y4, y0, y1, y2, y3, data[7], 5);
+ S2 (y3, y4, y0, y1, y2, data[10], 15);
+ S2 (y2, y3, y4, y0, y1, data[14], 8);
- S1( y1 , y2 , y3 , y4 , y0 , data[12] , 8 );
- S1( y0 , y1 , y2 , y3 , y4 , data[15] , 5 );
- S1( y4 , y0 , y1 , y2 , y3 , data[10] , 12 );
- S1( y3 , y4 , y0 , y1 , y2 , data[ 4] , 9 );
- S1( y2 , y3 , y4 , y0 , y1 , data[ 1] , 12 );
- S1( y1 , y2 , y3 , y4 , y0 , data[ 5] , 5 );
- S1( y0 , y1 , y2 , y3 , y4 , data[ 8] , 14 );
- S1( y4 , y0 , y1 , y2 , y3 , data[ 7] , 6 );
- S1( y3 , y4 , y0 , y1 , y2 , data[ 6] , 8 );
- S1( y2 , y3 , y4 , y0 , y1 , data[ 2] , 13 );
- S1( y1 , y2 , y3 , y4 , y0 , data[13] , 6 );
- S1( y0 , y1 , y2 , y3 , y4 , data[14] , 5 );
- S1( y4 , y0 , y1 , y2 , y3 , data[ 0] , 15 );
- S1( y3 , y4 , y0 , y1 , y2 , data[ 3] , 13 );
- S1( y2 , y3 , y4 , y0 , y1 , data[ 9] , 11 );
- S1( y1 , y2 , y3 , y4 , y0 , data[11] , 11 );
+ S1 (y1, y2, y3, y4, y0, data[12], 8);
+ S1 (y0, y1, y2, y3, y4, data[15], 5);
+ S1 (y4, y0, y1, y2, y3, data[10], 12);
+ S1 (y3, y4, y0, y1, y2, data[4], 9);
+ S1 (y2, y3, y4, y0, y1, data[1], 12);
+ S1 (y1, y2, y3, y4, y0, data[5], 5);
+ S1 (y0, y1, y2, y3, y4, data[8], 14);
+ S1 (y4, y0, y1, y2, y3, data[7], 6);
+ S1 (y3, y4, y0, y1, y2, data[6], 8);
+ S1 (y2, y3, y4, y0, y1, data[2], 13);
+ S1 (y1, y2, y3, y4, y0, data[13], 6);
+ S1 (y0, y1, y2, y3, y4, data[14], 5);
+ S1 (y4, y0, y1, y2, y3, data[0], 15);
+ S1 (y3, y4, y0, y1, y2, data[3], 13);
+ S1 (y2, y3, y4, y0, y1, data[9], 11);
+ S1 (y1, y2, y3, y4, y0, data[11], 11);
- y3 += x2 + state[1];
- state[1] = state[2] + x3 + y4;
- state[2] = state[3] + x4 + y0;
- state[3] = state[4] + x0 + y1;
- state[4] = state[0] + x1 + y2;
- state[0] = y3;
+ y3 += x2 + state[1];
+ state[1] = state[2] + x3 + y4;
+ state[2] = state[3] + x4 + y0;
+ state[3] = state[4] + x0 + y1;
+ state[4] = state[0] + x1 + y2;
+ state[0] = y3;
- return RMD160_OK;
+ return RMD160_OK;
}
#undef FUNCTION_NAME
@@ -327,104 +324,114 @@
#define FUNCTION_NAME "rmd160_append"
static int
-rmd160_append (
- RMD160 arg_obj
-,
- size_t arg_len
-,
- const unsigned char * arg_data
-)
+rmd160_append (RMD160 arg_obj, size_t arg_len, const unsigned char *arg_data)
{
- size_t alen ;
+ size_t alen;
- rmd160uint32 * wend ;
- rmd160uint32 * wptr ;
+ rmd160uint32 *wend;
+ rmd160uint32 *wptr;
- unsigned int bpos ;
+ unsigned int bpos;
- if ( ! arg_obj ) return RMD160_ERR_INVALID_ARG;
+ if (!arg_obj)
+ return RMD160_ERR_INVALID_ARG;
- if ( arg_len == 0 ) return RMD160_OK;
- if ( ! arg_data ) return RMD160_ERR_INVALID_ARG;
+ if (arg_len == 0)
+ return RMD160_OK;
+ if (!arg_data)
+ return RMD160_ERR_INVALID_ARG;
- alen = arg_len;
- wend = arg_obj->wend;
- wptr = arg_obj->wptr;
- bpos = arg_obj->bpos;
+ alen = arg_len;
+ wend = arg_obj->wend;
+ wptr = arg_obj->wptr;
+ bpos = arg_obj->bpos;
- if ( bpos ) {
- register rmd160uint32 w;
- w = * wptr;
- if ( bpos == 1 ) {
- w |= ( (rmd160uint32) ( 0xff & * ( arg_data ++ ) ) ) << 8;
- -- alen;
- ++ bpos;
- }
- if ( bpos == 2 && alen ) {
- w |= ( (rmd160uint32) ( 0xff & * ( arg_data ++ ) ) ) << 16;
- -- alen;
- ++ bpos;
- }
- if ( bpos == 3 && alen ) {
- w |= ( (rmd160uint32) ( 0xff & * ( arg_data ++ ) ) ) << 24;
- -- alen;
- ++ bpos;
- }
- * wptr = w;
- if ( ! alen ) {
- arg_obj->wptr = wptr;
- arg_obj->bpos = bpos;
- if ( ( arg_obj->len[0] = arg_len + arg_obj->len[0] ) < arg_len ) {
- arg_obj->len[1] ++;
- }
- return RMD160_OK;
- }
- bpos = 0;
- ++ wptr;
+ if (bpos)
+ {
+ register rmd160uint32 w;
+ w = *wptr;
+ if (bpos == 1)
+ {
+ w |= ((rmd160uint32) (0xff & *(arg_data++))) << 8;
+ --alen;
+ ++bpos;
+ }
+ if (bpos == 2 && alen)
+ {
+ w |= ((rmd160uint32) (0xff & *(arg_data++))) << 16;
+ --alen;
+ ++bpos;
+ }
+ if (bpos == 3 && alen)
+ {
+ w |= ((rmd160uint32) (0xff & *(arg_data++))) << 24;
+ --alen;
+ ++bpos;
+ }
+ *wptr = w;
+ if (!alen)
+ {
+ arg_obj->wptr = wptr;
+ arg_obj->bpos = bpos;
+ if ((arg_obj->len[0] = arg_len + arg_obj->len[0]) < arg_len)
+ {
+ arg_obj->len[1]++;
+ }
+ return RMD160_OK;
+ }
+ bpos = 0;
+ ++wptr;
}
- for (;;) {
- while ( alen >= 4 && wptr < wend ) {
+ for (;;)
+ {
+ while (alen >= 4 && wptr < wend)
+ {
#if defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && __BYTE_ORDER ==
__LITTLE_ENDIAN
- * wptr = * (const rmd160uint32 *) arg_data;
+ *wptr = *(const rmd160uint32 *) arg_data;
#else
- * wptr =
- ( (rmd160uint32) ( 0xff & arg_data[ 0 ] ) ) |
- ( (rmd160uint32) ( 0xff & arg_data[ 1 ] ) ) << 8 |
- ( (rmd160uint32) ( 0xff & arg_data[ 2 ] ) ) << 16 |
- ( (rmd160uint32) ( 0xff & arg_data[ 3 ] ) ) << 24;
+ *wptr =
+ ((rmd160uint32) (0xff & arg_data[0])) |
+ ((rmd160uint32) (0xff & arg_data[1])) << 8 |
+ ((rmd160uint32) (0xff & arg_data[2])) << 16 |
+ ((rmd160uint32) (0xff & arg_data[3])) << 24;
#endif
- ++ wptr;
- arg_data += 4;
- alen -= 4;
- }
- if ( wptr < wend ) break;
- _rmd160_calc( arg_obj->state , arg_obj->data );
- wptr = arg_obj->data;
+ ++wptr;
+ arg_data += 4;
+ alen -= 4;
+ }
+ if (wptr < wend)
+ break;
+ _rmd160_calc (arg_obj->state, arg_obj->data);
+ wptr = arg_obj->data;
}
- if ( alen ) {
- rmd160uint32 w;
- w = ( (rmd160uint32) ( 0xff & * ( arg_data ++ ) ) );
- if ( alen >= 2 ) {
- w |= ( (rmd160uint32) ( 0xff & * ( arg_data ++ ) ) ) << 8;
- if ( alen >= 3 ) {
- w |= ( (rmd160uint32) ( 0xff & * ( arg_data ++ ) ) ) << 16;
- }
- }
- bpos = alen;
- * wptr = w;
+ if (alen)
+ {
+ rmd160uint32 w;
+ w = ((rmd160uint32) (0xff & *(arg_data++)));
+ if (alen >= 2)
+ {
+ w |= ((rmd160uint32) (0xff & *(arg_data++))) << 8;
+ if (alen >= 3)
+ {
+ w |= ((rmd160uint32) (0xff & *(arg_data++))) << 16;
+ }
+ }
+ bpos = alen;
+ *wptr = w;
}
- arg_obj->wptr = wptr;
- arg_obj->bpos = bpos;
- if ( ( arg_obj->len[0] = arg_len + arg_obj->len[0] ) < arg_len ) {
- arg_obj->len[1] ++;
+ arg_obj->wptr = wptr;
+ arg_obj->bpos = bpos;
+ if ((arg_obj->len[0] = arg_len + arg_obj->len[0]) < arg_len)
+ {
+ arg_obj->len[1]++;
}
- return RMD160_OK;
+ return RMD160_OK;
}
@@ -433,15 +440,14 @@
#define FUNCTION_NAME "rmd160_destroy"
static int
-rmd160_destroy (
- RMD160 ptr
-)
+rmd160_destroy (RMD160 ptr)
{
- if ( ! ptr ) {
- return RMD160_ERR_INVALID_ARG;
+ if (!ptr)
+ {
+ return RMD160_ERR_INVALID_ARG;
}
- free( ptr );
- return RMD160_OK;
+ free (ptr);
+ return RMD160_OK;
}
#undef FUNCTION_NAME
@@ -449,56 +455,60 @@
#define FUNCTION_NAME "rmd160_copy"
static RMD160
-rmd160_copy (
- RMD160 target_p
-,
- RMD160 source_p
-)
+rmd160_copy (RMD160 target_p, RMD160 source_p)
{
- if ( ! target_p ) {
- if ( ! ( target_p = (struct rmd160_object*)malloc( sizeof (struct
rmd160_object) ) ) ) {
- return NULL;
+ if (!target_p)
+ {
+ if (!
+ (target_p =
+ (struct rmd160_object *) malloc (sizeof (struct rmd160_object))))
+ {
+ return NULL;
}
}
- if ( source_p ) {
- target_p->state[ 0 ] = source_p->state[ 0 ];
- target_p->state[ 1 ] = source_p->state[ 1 ];
- target_p->state[ 2 ] = source_p->state[ 2 ];
- target_p->state[ 3 ] = source_p->state[ 3 ];
- target_p->state[ 4 ] = source_p->state[ 4 ];
- {
- int i;
- for ( i = 0 ; i < 16 ; ++ i ) {
- target_p->data[ i ] = source_p->data[ i ];
- }
- }
- target_p->len[ 0 ] = source_p->len[ 0 ];
- target_p->len[ 1 ] = source_p->len[ 1 ];
- target_p->bpos = source_p->bpos;
- target_p->wptr = source_p->wptr - source_p->data + target_p->data;
- target_p->wend = 16 + target_p->data;
+ if (source_p)
+ {
+ target_p->state[0] = source_p->state[0];
+ target_p->state[1] = source_p->state[1];
+ target_p->state[2] = source_p->state[2];
+ target_p->state[3] = source_p->state[3];
+ target_p->state[4] = source_p->state[4];
+ {
+ int i;
+ for (i = 0; i < 16; ++i)
+ {
+ target_p->data[i] = source_p->data[i];
+ }
+ }
+ target_p->len[0] = source_p->len[0];
+ target_p->len[1] = source_p->len[1];
+ target_p->bpos = source_p->bpos;
+ target_p->wptr = source_p->wptr - source_p->data + target_p->data;
+ target_p->wend = 16 + target_p->data;
}
- else {
- target_p->state[ 0 ] = RMD160_INIT0;
- target_p->state[ 1 ] = RMD160_INIT1;
- target_p->state[ 2 ] = RMD160_INIT2;
- target_p->state[ 3 ] = RMD160_INIT3;
- target_p->state[ 4 ] = RMD160_INIT4;
- {
- int i;
- for ( i = 0 ; i < 16 ; ++ i ) {
- target_p->data[ i ] = 0U;
- }
- }
- target_p->len[ 0 ] = 0U;
- target_p->len[ 1 ] = 0U;
- target_p->bpos = 0;
- target_p->wptr = target_p->data;
- target_p->wend = 16 + target_p->data;
- }
+ else
+ {
+ target_p->state[0] = RMD160_INIT0;
+ target_p->state[1] = RMD160_INIT1;
+ target_p->state[2] = RMD160_INIT2;
+ target_p->state[3] = RMD160_INIT3;
+ target_p->state[4] = RMD160_INIT4;
+ {
+ int i;
+ for (i = 0; i < 16; ++i)
+ {
+ target_p->data[i] = 0U;
+ }
+ }
+ target_p->len[0] = 0U;
+ target_p->len[1] = 0U;
+ target_p->bpos = 0;
+ target_p->wptr = target_p->data;
+ target_p->wend = 16 + target_p->data;
+ }
- return target_p;
+ return target_p;
}
#undef FUNCTION_NAME
@@ -508,45 +518,48 @@
#define FUNCTION_NAME "rmd160_sum_words"
static rmd160uint32 *
-rmd160_sum_words (
- RMD160 arg_handle
-,
- rmd160uint32 * arg_result_p
-)
+rmd160_sum_words (RMD160 arg_handle, rmd160uint32 * arg_result_p)
{
- struct rmd160_object work ;
+ struct rmd160_object work;
- if ( ! arg_handle ) return NULL;
+ if (!arg_handle)
+ return NULL;
- if ( ! arg_result_p && ! ( arg_result_p = (rmd160uint32*)malloc( 5 *
sizeof (rmd160uint32) ) ) ) {
- return NULL;
+ if (!arg_result_p
+ && !(arg_result_p =
+ (rmd160uint32 *) malloc (5 * sizeof (rmd160uint32))))
+ {
+ return NULL;
}
- rmd160_copy( & work , arg_handle );
+ rmd160_copy (&work, arg_handle);
+ {
+ rmd160uint32 *p;
+ p = work.wptr;
+ if (work.bpos)
+ ++p;
+ while (p < work.wend)
+ *(p++) = 0U;
+ }
+ *(work.wptr) |= ((rmd160uint32) 0x80) << (work.bpos << 3);
+
+ if ((work.wend - work.wptr) <= 2)
{
- rmd160uint32 * p;
- p = work.wptr;
- if ( work.bpos ) ++ p;
- while ( p < work.wend ) * ( p ++ ) = 0U;
- }
- * ( work.wptr ) |= ( (rmd160uint32) 0x80 ) << ( work.bpos << 3 );
+ _rmd160_calc (work.state, work.data);
- if ( ( work.wend - work.wptr ) <= 2 ) {
- _rmd160_calc( work.state , work.data );
-
- memset( work.data , 0U , 14 * sizeof (rmd160uint32) );
+ memset (work.data, 0U, 14 * sizeof (rmd160uint32));
}
- work.data[14] = work.len[0] << 3;
- work.data[15] = ( work.len[1] << 3 ) | ( work.len[0] >> 29 );
+ work.data[14] = work.len[0] << 3;
+ work.data[15] = (work.len[1] << 3) | (work.len[0] >> 29);
- _rmd160_calc( work.state , work.data );
+ _rmd160_calc (work.state, work.data);
- memcpy( arg_result_p , work.state , 5 * sizeof (rmd160uint32) );
+ memcpy (arg_result_p, work.state, 5 * sizeof (rmd160uint32));
- return arg_result_p;
+ return arg_result_p;
}
@@ -557,58 +570,60 @@
#define FUNCTION_NAME "rmd160_sum_bytes"
static unsigned char *
-rmd160_sum_bytes (
- RMD160 arg_handle
-,
- unsigned char * arg_result_p
-)
+rmd160_sum_bytes (RMD160 arg_handle, unsigned char *arg_result_p)
{
- rmd160uint32 temp [5] ;
+ rmd160uint32 temp[5];
- rmd160uint32 * ptemp ;
+ rmd160uint32 *ptemp;
- unsigned char * result_p ;
+ unsigned char *result_p;
- if ( ! ( result_p = arg_result_p ) ) {
- if ( ! ( result_p = (unsigned char*)malloc( 20 ) ) ) return NULL;
- }
-
- if ( ! rmd160_sum_words( arg_handle , temp ) ) {
- if ( ! arg_result_p ) free( result_p );
+ if (!(result_p = arg_result_p))
+ {
+ if (!(result_p = (unsigned char *) malloc (20)))
return NULL;
}
- ptemp = temp;
+ if (!rmd160_sum_words (arg_handle, temp))
{
- int i;
- for ( i = 0 ; i < 5 ; ++ i ) {
- register rmd160uint32 w;
- * ( arg_result_p ++ ) = 0xff & ( w = * ptemp );
- * ( arg_result_p ++ ) = 0xff & ( w >> 8 );
- * ( arg_result_p ++ ) = 0xff & ( w >> 16 );
- * ( arg_result_p ++ ) = 0xff & ( w >> 24 );
- ++ ptemp;
- }
+ if (!arg_result_p)
+ free (result_p);
+ return NULL;
}
- return arg_result_p;
+ ptemp = temp;
+ {
+ int i;
+ for (i = 0; i < 5; ++i)
+ {
+ register rmd160uint32 w;
+ *(arg_result_p++) = 0xff & (w = *ptemp);
+ *(arg_result_p++) = 0xff & (w >> 8);
+ *(arg_result_p++) = 0xff & (w >> 16);
+ *(arg_result_p++) = 0xff & (w >> 24);
+ ++ptemp;
+ }
+ }
+ return arg_result_p;
+
}
#undef FUNCTION_NAME
-static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead,
- const char *phrase,
- EXTRACTOR_KeywordType type) {
+static struct EXTRACTOR_Keywords *
+addKeyword (EXTRACTOR_KeywordList * oldhead,
+ const char *phrase, EXTRACTOR_KeywordType type)
+{
- EXTRACTOR_KeywordList * keyword;
- keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList));
- keyword->next = oldhead;
- keyword->keyword = strdup(phrase);
- keyword->keywordType = type;
- return keyword;
+ EXTRACTOR_KeywordList *keyword;
+ keyword = (EXTRACTOR_KeywordList *) malloc (sizeof (EXTRACTOR_KeywordList));
+ keyword->next = oldhead;
+ keyword->keyword = strdup (phrase);
+ keyword->keywordType = type;
+ return keyword;
}
#define DIGEST_BITS 160
@@ -620,30 +635,27 @@
struct EXTRACTOR_Keywords *
-libextractor_hash_rmd160_extract(const char * filename,
- const unsigned char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev) {
+libextractor_hash_rmd160_extract (const char *filename,
+ const unsigned char *data,
+ size_t size,
+ struct EXTRACTOR_Keywords *prev)
+{
unsigned char bin_buffer[MAX_DIGEST_BIN_BYTES];
char hash[8 * MAX_DIGEST_BIN_BYTES];
char buf[16];
RMD160 ptr;
int i;
- ptr = rmd160_new();
- rmd160_append(ptr, size, data);
- rmd160_sum_bytes(ptr, bin_buffer);
- rmd160_destroy(ptr);
+ ptr = rmd160_new ();
+ rmd160_append (ptr, size, data);
+ rmd160_sum_bytes (ptr, bin_buffer);
+ rmd160_destroy (ptr);
hash[0] = '\0';
- for (i=0;i<DIGEST_HEX_BYTES / 2; i++) {
- snprintf(buf,
- 16,
- "%02x",
- bin_buffer[i]);
- strcat(hash, buf);
- }
- prev = addKeyword(prev,
- hash,
- EXTRACTOR_HASH_RMD160);
+ for (i = 0; i < DIGEST_HEX_BYTES / 2; i++)
+ {
+ snprintf (buf, 16, "%02x", bin_buffer[i]);
+ strcat (hash, buf);
+ }
+ prev = addKeyword (prev, hash, EXTRACTOR_HASH_RMD160);
return prev;
}
Modified: Extractor/src/plugins/hash/sha1extractor.c
===================================================================
--- Extractor/src/plugins/hash/sha1extractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/hash/sha1extractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -53,17 +53,17 @@
# define UINT_MAX_32_BITS 4294967295U
# if UINT_MAX == UINT_MAX_32_BITS
- typedef unsigned int md5_uint32;
+typedef unsigned int md5_uint32;
# else
# if USHRT_MAX == UINT_MAX_32_BITS
- typedef unsigned short md5_uint32;
+typedef unsigned short md5_uint32;
# else
# if ULONG_MAX == UINT_MAX_32_BITS
- typedef unsigned long md5_uint32;
+typedef unsigned long md5_uint32;
# else
/* The following line is intended to evoke an error.
Using #error is not portable enough. */
- "Cannot determine unsigned 32-bit data type."
+"Cannot determine unsigned 32-bit data type."
# endif
# endif
# endif
@@ -125,10 +125,9 @@
/* FIXME-someday (soon?): use #error instead of this kludge. */
"invalid BLOCKSIZE"
#endif
-
/* This array contains the bytes used to pad the buffer to the next
64-byte boundary. (RFC 1321, 3.1: Step 1) */
-static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
+static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ... */ };
@@ -173,91 +172,91 @@
int t;
/* FIXME: see sha1.c for a better implementation. */
for (t = 0; t < 16; t++)
- {
- x[t] = NOTSWAP (*words);
- words++;
- }
+ {
+ x[t] = NOTSWAP (*words);
+ words++;
+ }
- R( a, b, c, d, e, F1, K1, x[ 0] );
- R( e, a, b, c, d, F1, K1, x[ 1] );
- R( d, e, a, b, c, F1, K1, x[ 2] );
- R( c, d, e, a, b, F1, K1, x[ 3] );
- R( b, c, d, e, a, F1, K1, x[ 4] );
- R( a, b, c, d, e, F1, K1, x[ 5] );
- R( e, a, b, c, d, F1, K1, x[ 6] );
- R( d, e, a, b, c, F1, K1, x[ 7] );
- R( c, d, e, a, b, F1, K1, x[ 8] );
- R( b, c, d, e, a, F1, K1, x[ 9] );
- R( a, b, c, d, e, F1, K1, x[10] );
- R( e, a, b, c, d, F1, K1, x[11] );
- R( d, e, a, b, c, F1, K1, x[12] );
- R( c, d, e, a, b, F1, K1, x[13] );
- R( b, c, d, e, a, F1, K1, x[14] );
- R( a, b, c, d, e, F1, K1, x[15] );
- R( e, a, b, c, d, F1, K1, M(16) );
- R( d, e, a, b, c, F1, K1, M(17) );
- R( c, d, e, a, b, F1, K1, M(18) );
- R( b, c, d, e, a, F1, K1, M(19) );
- R( a, b, c, d, e, F2, K2, M(20) );
- R( e, a, b, c, d, F2, K2, M(21) );
- R( d, e, a, b, c, F2, K2, M(22) );
- R( c, d, e, a, b, F2, K2, M(23) );
- R( b, c, d, e, a, F2, K2, M(24) );
- R( a, b, c, d, e, F2, K2, M(25) );
- R( e, a, b, c, d, F2, K2, M(26) );
- R( d, e, a, b, c, F2, K2, M(27) );
- R( c, d, e, a, b, F2, K2, M(28) );
- R( b, c, d, e, a, F2, K2, M(29) );
- R( a, b, c, d, e, F2, K2, M(30) );
- R( e, a, b, c, d, F2, K2, M(31) );
- R( d, e, a, b, c, F2, K2, M(32) );
- R( c, d, e, a, b, F2, K2, M(33) );
- R( b, c, d, e, a, F2, K2, M(34) );
- R( a, b, c, d, e, F2, K2, M(35) );
- R( e, a, b, c, d, F2, K2, M(36) );
- R( d, e, a, b, c, F2, K2, M(37) );
- R( c, d, e, a, b, F2, K2, M(38) );
- R( b, c, d, e, a, F2, K2, M(39) );
- R( a, b, c, d, e, F3, K3, M(40) );
- R( e, a, b, c, d, F3, K3, M(41) );
- R( d, e, a, b, c, F3, K3, M(42) );
- R( c, d, e, a, b, F3, K3, M(43) );
- R( b, c, d, e, a, F3, K3, M(44) );
- R( a, b, c, d, e, F3, K3, M(45) );
- R( e, a, b, c, d, F3, K3, M(46) );
- R( d, e, a, b, c, F3, K3, M(47) );
- R( c, d, e, a, b, F3, K3, M(48) );
- R( b, c, d, e, a, F3, K3, M(49) );
- R( a, b, c, d, e, F3, K3, M(50) );
- R( e, a, b, c, d, F3, K3, M(51) );
- R( d, e, a, b, c, F3, K3, M(52) );
- R( c, d, e, a, b, F3, K3, M(53) );
- R( b, c, d, e, a, F3, K3, M(54) );
- R( a, b, c, d, e, F3, K3, M(55) );
- R( e, a, b, c, d, F3, K3, M(56) );
- R( d, e, a, b, c, F3, K3, M(57) );
- R( c, d, e, a, b, F3, K3, M(58) );
- R( b, c, d, e, a, F3, K3, M(59) );
- R( a, b, c, d, e, F4, K4, M(60) );
- R( e, a, b, c, d, F4, K4, M(61) );
- R( d, e, a, b, c, F4, K4, M(62) );
- R( c, d, e, a, b, F4, K4, M(63) );
- R( b, c, d, e, a, F4, K4, M(64) );
- R( a, b, c, d, e, F4, K4, M(65) );
- R( e, a, b, c, d, F4, K4, M(66) );
- R( d, e, a, b, c, F4, K4, M(67) );
- R( c, d, e, a, b, F4, K4, M(68) );
- R( b, c, d, e, a, F4, K4, M(69) );
- R( a, b, c, d, e, F4, K4, M(70) );
- R( e, a, b, c, d, F4, K4, M(71) );
- R( d, e, a, b, c, F4, K4, M(72) );
- R( c, d, e, a, b, F4, K4, M(73) );
- R( b, c, d, e, a, F4, K4, M(74) );
- R( a, b, c, d, e, F4, K4, M(75) );
- R( e, a, b, c, d, F4, K4, M(76) );
- R( d, e, a, b, c, F4, K4, M(77) );
- R( c, d, e, a, b, F4, K4, M(78) );
- R( b, c, d, e, a, F4, K4, M(79) );
+ R (a, b, c, d, e, F1, K1, x[0]);
+ R (e, a, b, c, d, F1, K1, x[1]);
+ R (d, e, a, b, c, F1, K1, x[2]);
+ R (c, d, e, a, b, F1, K1, x[3]);
+ R (b, c, d, e, a, F1, K1, x[4]);
+ R (a, b, c, d, e, F1, K1, x[5]);
+ R (e, a, b, c, d, F1, K1, x[6]);
+ R (d, e, a, b, c, F1, K1, x[7]);
+ R (c, d, e, a, b, F1, K1, x[8]);
+ R (b, c, d, e, a, F1, K1, x[9]);
+ R (a, b, c, d, e, F1, K1, x[10]);
+ R (e, a, b, c, d, F1, K1, x[11]);
+ R (d, e, a, b, c, F1, K1, x[12]);
+ R (c, d, e, a, b, F1, K1, x[13]);
+ R (b, c, d, e, a, F1, K1, x[14]);
+ R (a, b, c, d, e, F1, K1, x[15]);
+ R (e, a, b, c, d, F1, K1, M (16));
+ R (d, e, a, b, c, F1, K1, M (17));
+ R (c, d, e, a, b, F1, K1, M (18));
+ R (b, c, d, e, a, F1, K1, M (19));
+ R (a, b, c, d, e, F2, K2, M (20));
+ R (e, a, b, c, d, F2, K2, M (21));
+ R (d, e, a, b, c, F2, K2, M (22));
+ R (c, d, e, a, b, F2, K2, M (23));
+ R (b, c, d, e, a, F2, K2, M (24));
+ R (a, b, c, d, e, F2, K2, M (25));
+ R (e, a, b, c, d, F2, K2, M (26));
+ R (d, e, a, b, c, F2, K2, M (27));
+ R (c, d, e, a, b, F2, K2, M (28));
+ R (b, c, d, e, a, F2, K2, M (29));
+ R (a, b, c, d, e, F2, K2, M (30));
+ R (e, a, b, c, d, F2, K2, M (31));
+ R (d, e, a, b, c, F2, K2, M (32));
+ R (c, d, e, a, b, F2, K2, M (33));
+ R (b, c, d, e, a, F2, K2, M (34));
+ R (a, b, c, d, e, F2, K2, M (35));
+ R (e, a, b, c, d, F2, K2, M (36));
+ R (d, e, a, b, c, F2, K2, M (37));
+ R (c, d, e, a, b, F2, K2, M (38));
+ R (b, c, d, e, a, F2, K2, M (39));
+ R (a, b, c, d, e, F3, K3, M (40));
+ R (e, a, b, c, d, F3, K3, M (41));
+ R (d, e, a, b, c, F3, K3, M (42));
+ R (c, d, e, a, b, F3, K3, M (43));
+ R (b, c, d, e, a, F3, K3, M (44));
+ R (a, b, c, d, e, F3, K3, M (45));
+ R (e, a, b, c, d, F3, K3, M (46));
+ R (d, e, a, b, c, F3, K3, M (47));
+ R (c, d, e, a, b, F3, K3, M (48));
+ R (b, c, d, e, a, F3, K3, M (49));
+ R (a, b, c, d, e, F3, K3, M (50));
+ R (e, a, b, c, d, F3, K3, M (51));
+ R (d, e, a, b, c, F3, K3, M (52));
+ R (c, d, e, a, b, F3, K3, M (53));
+ R (b, c, d, e, a, F3, K3, M (54));
+ R (a, b, c, d, e, F3, K3, M (55));
+ R (e, a, b, c, d, F3, K3, M (56));
+ R (d, e, a, b, c, F3, K3, M (57));
+ R (c, d, e, a, b, F3, K3, M (58));
+ R (b, c, d, e, a, F3, K3, M (59));
+ R (a, b, c, d, e, F4, K4, M (60));
+ R (e, a, b, c, d, F4, K4, M (61));
+ R (d, e, a, b, c, F4, K4, M (62));
+ R (c, d, e, a, b, F4, K4, M (63));
+ R (b, c, d, e, a, F4, K4, M (64));
+ R (a, b, c, d, e, F4, K4, M (65));
+ R (e, a, b, c, d, F4, K4, M (66));
+ R (d, e, a, b, c, F4, K4, M (67));
+ R (c, d, e, a, b, F4, K4, M (68));
+ R (b, c, d, e, a, F4, K4, M (69));
+ R (a, b, c, d, e, F4, K4, M (70));
+ R (e, a, b, c, d, F4, K4, M (71));
+ R (d, e, a, b, c, F4, K4, M (72));
+ R (c, d, e, a, b, F4, K4, M (73));
+ R (b, c, d, e, a, F4, K4, M (74));
+ R (a, b, c, d, e, F4, K4, M (75));
+ R (e, a, b, c, d, F4, K4, M (76));
+ R (d, e, a, b, c, F4, K4, M (77));
+ R (c, d, e, a, b, F4, K4, M (78));
+ R (b, c, d, e, a, F4, K4, M (79));
a = ctx->A += a;
b = ctx->B += b;
@@ -283,14 +282,14 @@
ctx->buflen += add;
if (ctx->buflen > 64)
- {
- sha_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
+ {
+ sha_process_block (ctx->buffer, ctx->buflen & ~63, ctx);
- ctx->buflen &= 63;
- /* The regions in the following copy operation cannot overlap. */
- memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63],
- ctx->buflen);
- }
+ ctx->buflen &= 63;
+ /* The regions in the following copy operation cannot overlap. */
+ memcpy (ctx->buffer, &ctx->buffer[(left_over + add) & ~63],
+ ctx->buflen);
+ }
buffer = (const char *) buffer + add;
len -= add;
@@ -308,19 +307,19 @@
# define UNALIGNED_P(p) (((md5_uintptr) p) % sizeof (md5_uint32) != 0)
# endif
if (UNALIGNED_P (buffer))
- while (len > 64)
- {
- sha_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
- buffer = (const char *) buffer + 64;
- len -= 64;
- }
+ while (len > 64)
+ {
+ sha_process_block (memcpy (ctx->buffer, buffer, 64), 64, ctx);
+ buffer = (const char *) buffer + 64;
+ len -= 64;
+ }
else
#endif
- {
- sha_process_block (buffer, len & ~63, ctx);
- buffer = (const char *) buffer + (len & ~63);
- len &= 63;
- }
+ {
+ sha_process_block (buffer, len & ~63, ctx);
+ buffer = (const char *) buffer + (len & ~63);
+ len &= 63;
+ }
}
/* Move remaining bytes in internal buffer. */
@@ -331,11 +330,11 @@
memcpy (&ctx->buffer[left_over], buffer, len);
left_over += len;
if (left_over >= 64)
- {
- sha_process_block (ctx->buffer, 64, ctx);
- left_over -= 64;
- memcpy (ctx->buffer, &ctx->buffer[64], left_over);
- }
+ {
+ sha_process_block (ctx->buffer, 64, ctx);
+ left_over -= 64;
+ memcpy (ctx->buffer, &ctx->buffer[64], left_over);
+ }
ctx->buflen = left_over;
}
}
@@ -397,9 +396,10 @@
memcpy (&ctx->buffer[bytes], fillbuf, pad);
/* Put the 64-bit file length in *bits* at the end of the buffer. */
- *(md5_uint32 *) &ctx->buffer[bytes + pad + 4] = NOTSWAP (ctx->total[0] << 3);
- *(md5_uint32 *) &ctx->buffer[bytes + pad] = NOTSWAP ((ctx->total[1] << 3) |
- (ctx->total[0] >> 29));
+ *(md5_uint32 *) & ctx->buffer[bytes + pad + 4] =
+ NOTSWAP (ctx->total[0] << 3);
+ *(md5_uint32 *) & ctx->buffer[bytes + pad] =
+ NOTSWAP ((ctx->total[1] << 3) | (ctx->total[0] >> 29));
/* Process last bytes. */
sha_process_block (ctx->buffer, bytes + pad + 8, ctx);
@@ -433,16 +433,17 @@
-static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead,
- const char *phrase,
- EXTRACTOR_KeywordType type) {
+static struct EXTRACTOR_Keywords *
+addKeyword (EXTRACTOR_KeywordList * oldhead,
+ const char *phrase, EXTRACTOR_KeywordType type)
+{
- EXTRACTOR_KeywordList * keyword;
- keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList));
- keyword->next = oldhead;
- keyword->keyword = strdup(phrase);
- keyword->keywordType = type;
- return keyword;
+ EXTRACTOR_KeywordList *keyword;
+ keyword = (EXTRACTOR_KeywordList *) malloc (sizeof (EXTRACTOR_KeywordList));
+ keyword->next = oldhead;
+ keyword->keyword = strdup (phrase);
+ keyword->keywordType = type;
+ return keyword;
}
#define DIGEST_BITS 160
@@ -451,27 +452,24 @@
#define MAX_DIGEST_BIN_BYTES DIGEST_BIN_BYTES
-struct EXTRACTOR_Keywords * libextractor_hash_sha1_extract(const char *
filename,
- char * data,
- size_t size,
- struct
EXTRACTOR_Keywords * prev) {
+struct EXTRACTOR_Keywords *
+libextractor_hash_sha1_extract (const char *filename,
+ char *data,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
unsigned char bin_buffer[MAX_DIGEST_BIN_BYTES];
char hash[8 * MAX_DIGEST_BIN_BYTES];
char buf[16];
int i;
- sha_buffer(data, size, bin_buffer);
+ sha_buffer (data, size, bin_buffer);
hash[0] = '\0';
- for (i=0;i<DIGEST_HEX_BYTES / 2; i++) {
- snprintf(buf,
- 16,
- "%02x",
- bin_buffer[i]);
- strcat(hash, buf);
- }
- prev = addKeyword(prev,
- hash,
- EXTRACTOR_HASH_SHA1);
+ for (i = 0; i < DIGEST_HEX_BYTES / 2; i++)
+ {
+ snprintf (buf, 16, "%02x", bin_buffer[i]);
+ strcat (hash, buf);
+ }
+ prev = addKeyword (prev, hash, EXTRACTOR_HASH_SHA1);
return prev;
}
Modified: Extractor/src/plugins/htmlextractor.c
===================================================================
--- Extractor/src/plugins/htmlextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/htmlextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -24,37 +24,62 @@
#include <string.h>
#include "convert.h"
-static struct {
- char * name;
+static struct
+{
+ char *name;
EXTRACTOR_KeywordType type;
-} tagmap[] = {
- { "author" , EXTRACTOR_AUTHOR},
- { "title" , EXTRACTOR_TITLE},
- { "description" , EXTRACTOR_DESCRIPTION},
- { "language", EXTRACTOR_LANGUAGE},
- { "rights", EXTRACTOR_COPYRIGHT},
- { "publisher", EXTRACTOR_PUBLISHER},
- { "formatter", EXTRACTOR_SOFTWARE},
- { "copyright", EXTRACTOR_COPYRIGHT},
- { "abstract", EXTRACTOR_SUMMARY},
- { "subject", EXTRACTOR_SUBJECT},
- { "abstract", EXTRACTOR_SUMMARY},
- { "date", EXTRACTOR_DATE},
- { "keywords", EXTRACTOR_KEYWORDS},
- { "dc.author" , EXTRACTOR_AUTHOR},
- { "dc.title" , EXTRACTOR_TITLE},
- { "dc.description" , EXTRACTOR_DESCRIPTION},
- { "dc.subject", EXTRACTOR_SUBJECT},
- { "dc.creator", EXTRACTOR_CREATOR},
- { "dc.publisher", EXTRACTOR_PUBLISHER},
- { "dc.date", EXTRACTOR_DATE},
- { "dc.format", EXTRACTOR_FORMAT},
- { "dc.identifier", EXTRACTOR_RESOURCE_IDENTIFIER},
- { "dc.rights", EXTRACTOR_COPYRIGHT},
- {NULL, EXTRACTOR_UNKNOWN},
-};
+} tagmap[] =
+{
+ {
+ "author", EXTRACTOR_AUTHOR},
+ {
+ "title", EXTRACTOR_TITLE},
+ {
+ "description", EXTRACTOR_DESCRIPTION},
+ {
+ "language", EXTRACTOR_LANGUAGE},
+ {
+ "rights", EXTRACTOR_COPYRIGHT},
+ {
+ "publisher", EXTRACTOR_PUBLISHER},
+ {
+ "formatter", EXTRACTOR_SOFTWARE},
+ {
+ "copyright", EXTRACTOR_COPYRIGHT},
+ {
+ "abstract", EXTRACTOR_SUMMARY},
+ {
+ "subject", EXTRACTOR_SUBJECT},
+ {
+ "abstract", EXTRACTOR_SUMMARY},
+ {
+ "date", EXTRACTOR_DATE},
+ {
+ "keywords", EXTRACTOR_KEYWORDS},
+ {
+ "dc.author", EXTRACTOR_AUTHOR},
+ {
+ "dc.title", EXTRACTOR_TITLE},
+ {
+ "dc.description", EXTRACTOR_DESCRIPTION},
+ {
+ "dc.subject", EXTRACTOR_SUBJECT},
+ {
+ "dc.creator", EXTRACTOR_CREATOR},
+ {
+ "dc.publisher", EXTRACTOR_PUBLISHER},
+ {
+ "dc.date", EXTRACTOR_DATE},
+ {
+ "dc.format", EXTRACTOR_FORMAT},
+ {
+ "dc.identifier", EXTRACTOR_RESOURCE_IDENTIFIER},
+ {
+ "dc.rights", EXTRACTOR_COPYRIGHT},
+ {
+NULL, EXTRACTOR_UNKNOWN},};
-static char * relevantTags[] = {
+static char *relevantTags[] = {
"title",
"meta",
NULL,
@@ -63,7 +88,7 @@
/* which mime-types should not be subjected to
the HTML extractor (no use trying & parsing
is expensive!) */
-static char * blacklist[] = {
+static char *blacklist[] = {
"image/jpeg",
"image/gif",
"image/png",
@@ -98,24 +123,25 @@
NULL,
};
-typedef struct TI {
- struct TI * next;
- const char * tagStart;
- const char * tagEnd;
- const char * dataStart;
- const char * dataEnd;
+typedef struct TI
+{
+ struct TI *next;
+ const char *tagStart;
+ const char *tagEnd;
+ const char *dataStart;
+ const char *dataEnd;
} TagInfo;
/**
* Add a keyword.
*/
static struct EXTRACTOR_Keywords *
-addKeyword(EXTRACTOR_KeywordType type,
- char * keyword,
- struct EXTRACTOR_Keywords * next) {
- EXTRACTOR_KeywordList * result;
+addKeyword (EXTRACTOR_KeywordType type,
+ char *keyword, struct EXTRACTOR_Keywords *next)
+{
+ EXTRACTOR_KeywordList *result;
- result = malloc(sizeof(EXTRACTOR_KeywordList));
+ result = malloc (sizeof (EXTRACTOR_KeywordList));
result->next = next;
result->keyword = keyword;
result->keywordType = type;
@@ -124,106 +150,107 @@
/* ******************** parser helper functions ************** */
-static int tagMatch(const char * tag,
- const char * s,
- const char * e) {
- return ( ( (e - s) == strlen(tag)) &&
- (0 == strncasecmp(tag, s, e-s)) );
+static int
+tagMatch (const char *tag, const char *s, const char *e)
+{
+ return (((e - s) == strlen (tag)) && (0 == strncasecmp (tag, s, e - s)));
}
-static int lookFor(char c,
- size_t * pos,
- const char * data,
- size_t size) {
+static int
+lookFor (char c, size_t * pos, const char *data, size_t size)
+{
size_t p = *pos;
- while ( (p < size) &&
- (data[p] != c) ) {
- if (data[p] == '\0') return 0;
- p++;
- }
+ while ((p < size) && (data[p] != c))
+ {
+ if (data[p] == '\0')
+ return 0;
+ p++;
+ }
*pos = p;
return p < size;
}
-static int skipWhitespace(size_t * pos,
- const char * data,
- size_t size) {
+static int
+skipWhitespace (size_t * pos, const char *data, size_t size)
+{
size_t p = *pos;
- while ( (p < size) &&
- (isspace(data[p])) ) {
- if (data[p] == '\0') return 0;
- p++;
- }
+ while ((p < size) && (isspace (data[p])))
+ {
+ if (data[p] == '\0')
+ return 0;
+ p++;
+ }
*pos = p;
return p < size;
}
-static int skipLetters(size_t * pos,
- const char * data,
- size_t size) {
+static int
+skipLetters (size_t * pos, const char *data, size_t size)
+{
size_t p = *pos;
- while ( (p < size) &&
- (isalpha(data[p])) ) {
- if (data[p] == '\0') return 0;
- p++;
- }
+ while ((p < size) && (isalpha (data[p])))
+ {
+ if (data[p] == '\0')
+ return 0;
+ p++;
+ }
*pos = p;
return p < size;
}
-static int lookForMultiple(const char * c,
- size_t * pos,
- const char * data,
- size_t size) {
+static int
+lookForMultiple (const char *c, size_t * pos, const char *data, size_t size)
+{
size_t p = *pos;
- while ( (p < size) &&
- (strchr(c, data[p]) == NULL) ) {
- if (data[p] == '\0') return 0;
- p++;
- }
+ while ((p < size) && (strchr (c, data[p]) == NULL))
+ {
+ if (data[p] == '\0')
+ return 0;
+ p++;
+ }
*pos = p;
return p < size;
}
-static void findEntry(const char * key,
- const char * start,
- const char * end,
- const char ** mstart,
- const char ** mend) {
+static void
+findEntry (const char *key,
+ const char *start,
+ const char *end, const char **mstart, const char **mend)
+{
size_t len;
*mstart = NULL;
*mend = NULL;
- len = strlen(key);
- while (start < end - len - 1) {
- start++;
- if (start[len] != '=')
- continue;
- if (0 == strncmp(start,
- key,
- len)) {
- start += len+1;
- *mstart = start;
- if ( (*start == '\"') ||
- (*start == '\'') ) {
- start++;
- while ( (start < end) &&
- (*start != **mstart) )
- start++;
- (*mstart)++; /* skip quote */
- } else {
- while ( (start < end) &&
- (! isspace(*start)) )
- start++;
- }
- *mend = start;
- return;
+ len = strlen (key);
+ while (start < end - len - 1)
+ {
+ start++;
+ if (start[len] != '=')
+ continue;
+ if (0 == strncmp (start, key, len))
+ {
+ start += len + 1;
+ *mstart = start;
+ if ((*start == '\"') || (*start == '\''))
+ {
+ start++;
+ while ((start < end) && (*start != **mstart))
+ start++;
+ (*mstart)++; /* skip quote */
+ }
+ else
+ {
+ while ((start < end) && (!isspace (*start)))
+ start++;
+ }
+ *mend = start;
+ return;
+ }
}
- }
}
/**
@@ -235,79 +262,69 @@
*
* @return NULL if nothing is found
*/
-static char * findInTags(TagInfo * t,
- const char * tagname,
- const char * keyname,
- const char * keyvalue,
- const char * searchname) {
- const char * pstart;
- const char * pend;
+static char *
+findInTags (TagInfo * t,
+ const char *tagname,
+ const char *keyname, const char *keyvalue, const char *searchname)
+{
+ const char *pstart;
+ const char *pend;
- while (t != NULL) {
- if (tagMatch(tagname,
- t->tagStart,
- t->tagEnd)) {
- findEntry(keyname,
- t->tagEnd,
- t->dataStart,
- &pstart,
- &pend);
- if ( ( pstart != NULL) &&
- (tagMatch(keyvalue,
- pstart,
- pend)) ) {
- findEntry(searchname,
- t->tagEnd,
- t->dataStart,
- &pstart,
- &pend);
- if (pstart != NULL) {
- char * ret = malloc(pend - pstart + 1);
- memcpy(ret,
- pstart,
- pend - pstart);
- ret[pend-pstart] = '\0';
- return ret;
- }
- }
+ while (t != NULL)
+ {
+ if (tagMatch (tagname, t->tagStart, t->tagEnd))
+ {
+ findEntry (keyname, t->tagEnd, t->dataStart, &pstart, &pend);
+ if ((pstart != NULL) && (tagMatch (keyvalue, pstart, pend)))
+ {
+ findEntry (searchname, t->tagEnd, t->dataStart, &pstart, &pend);
+ if (pstart != NULL)
+ {
+ char *ret = malloc (pend - pstart + 1);
+ memcpy (ret, pstart, pend - pstart);
+ ret[pend - pstart] = '\0';
+ return ret;
+ }
+ }
+ }
+ t = t->next;
}
- t = t->next;
- }
return NULL;
}
/* mimetype = text/html */
struct EXTRACTOR_Keywords *
-libextractor_html_extract(const char * filename,
- const char * data,
- const size_t size,
- struct EXTRACTOR_Keywords * prev) {
+libextractor_html_extract (const char *filename,
+ const char *data,
+ const size_t size, struct EXTRACTOR_Keywords *prev)
+{
size_t xsize;
- const char * mime;
- TagInfo * tags;
- TagInfo * t;
+ const char *mime;
+ TagInfo *tags;
+ TagInfo *t;
TagInfo tag;
size_t pos;
size_t tpos;
int i;
- char * charset;
- char * tmp;
+ char *charset;
+ char *tmp;
if (size == 0)
return prev;
- mime = EXTRACTOR_extractLast(EXTRACTOR_MIMETYPE,
- prev);
- if (mime != NULL) {
- int j;
- j = 0;
- while (blacklist[j] != NULL) {
- if (0 == strcmp(blacklist[j], mime))
- return prev;
- j++;
+ mime = EXTRACTOR_extractLast (EXTRACTOR_MIMETYPE, prev);
+ if (mime != NULL)
+ {
+ int j;
+ j = 0;
+ while (blacklist[j] != NULL)
+ {
+ if (0 == strcmp (blacklist[j], mime))
+ return prev;
+ j++;
+ }
}
- }
/* only scan first 32k */
if (size > 1024 * 32)
@@ -317,50 +334,59 @@
tags = NULL;
tag.next = NULL;
pos = 0;
- while (pos < xsize) {
- if (! lookFor('<', &pos, data, size)) break;
- tag.tagStart = &data[++pos];
- if (! skipLetters(&pos, data, size)) break;
- tag.tagEnd = &data[pos];
- if (! skipWhitespace(&pos, data, size)) break;
- STEP3:
- if (! lookForMultiple(">\"\'", &pos, data, size)) break;
- if (data[pos] != '>') {
- /* find end-quote, ignore escaped quotes (\') */
- do {
- tpos = pos;
- pos++;
- if (! lookFor(data[tpos], &pos, data, size))
- break;
- } while (data[pos-1] == '\\');
+ while (pos < xsize)
+ {
+ if (!lookFor ('<', &pos, data, size))
+ break;
+ tag.tagStart = &data[++pos];
+ if (!skipLetters (&pos, data, size))
+ break;
+ tag.tagEnd = &data[pos];
+ if (!skipWhitespace (&pos, data, size))
+ break;
+ STEP3:
+ if (!lookForMultiple (">\"\'", &pos, data, size))
+ break;
+ if (data[pos] != '>')
+ {
+ /* find end-quote, ignore escaped quotes (\') */
+ do
+ {
+ tpos = pos;
+ pos++;
+ if (!lookFor (data[tpos], &pos, data, size))
+ break;
+ }
+ while (data[pos - 1] == '\\');
+ pos++;
+ goto STEP3;
+ }
pos++;
- goto STEP3;
+ if (!skipWhitespace (&pos, data, size))
+ break;
+ tag.dataStart = &data[pos];
+ if (!lookFor ('<', &pos, data, size))
+ break;
+ tag.dataEnd = &data[pos];
+ i = 0;
+ while (relevantTags[i] != NULL)
+ {
+ if ((strlen (relevantTags[i]) == tag.tagEnd - tag.tagStart) &&
+ (0 == strncasecmp (relevantTags[i],
+ tag.tagStart, tag.tagEnd - tag.tagStart)))
+ {
+ t = malloc (sizeof (TagInfo));
+ *t = tag;
+ t->next = tags;
+ tags = t;
+ break;
+ }
+ i++;
+ }
+ /* abort early if we hit the body tag */
+ if (tagMatch ("body", tag.tagStart, tag.tagEnd))
+ break;
}
- pos++;
- if (! skipWhitespace(&pos, data, size)) break;
- tag.dataStart = &data[pos];
- if (! lookFor('<', &pos, data, size)) break;
- tag.dataEnd = &data[pos];
- i = 0;
- while (relevantTags[i] != NULL) {
- if ( (strlen(relevantTags[i]) == tag.tagEnd - tag.tagStart) &&
- (0 == strncasecmp(relevantTags[i],
- tag.tagStart,
- tag.tagEnd - tag.tagStart)) ) {
- t = malloc(sizeof(TagInfo));
- *t = tag;
- t->next = tags;
- tags = t;
- break;
- }
- i++;
- }
- /* abort early if we hit the body tag */
- if (tagMatch("body",
- tag.tagStart,
- tag.tagEnd))
- break;
- }
/* fast exit */
if (tags == NULL)
@@ -369,64 +395,52 @@
charset = NULL;
/* first, try to determine mime type and/or character set */
- tmp = findInTags(tags,
- "meta",
- "http-equiv", "content-type",
- "content");
- if (tmp != NULL) {
- /* ideally, tmp == "test/html; charset=ISO-XXXX-Y" or something like that;
- if text/html is present, we take that as the mime-type; if charset=
- is present, we try to use that for character set conversion. */
- if (0 == strncmp(tmp,
- "text/html",
- strlen("text/html")))
- prev = addKeyword(EXTRACTOR_MIMETYPE,
- strdup("text/html"),
- prev);
+ tmp = findInTags (tags, "meta", "http-equiv", "content-type", "content");
+ if (tmp != NULL)
+ {
+ /* ideally, tmp == "test/html; charset=ISO-XXXX-Y" or something like
that;
+ if text/html is present, we take that as the mime-type; if charset=
+ is present, we try to use that for character set conversion. */
+ if (0 == strncmp (tmp, "text/html", strlen ("text/html")))
+ prev = addKeyword (EXTRACTOR_MIMETYPE, strdup ("text/html"), prev);
- charset = strstr(tmp, "charset=");
+ charset = strstr (tmp, "charset=");
- if (charset != NULL)
- charset = strdup(&charset[strlen("charset=")]);
- free(tmp);
- }
+ if (charset != NULL)
+ charset = strdup (&charset[strlen ("charset=")]);
+ free (tmp);
+ }
if (charset == NULL)
- charset = strdup("ISO-8859-1"); /* try a sensible default */
+ charset = strdup ("ISO-8859-1"); /* try a sensible default */
i = 0;
- while (tagmap[i].name != NULL) {
- tmp = findInTags(tags,
- "meta",
- "name", tagmap[i].name,
- "content");
- if (tmp != NULL) {
- prev = addKeyword(tagmap[i].type,
- convertToUtf8(tmp,
- strlen(tmp),
- charset),
- prev);
- free(tmp);
+ while (tagmap[i].name != NULL)
+ {
+ tmp = findInTags (tags, "meta", "name", tagmap[i].name, "content");
+ if (tmp != NULL)
+ {
+ prev = addKeyword (tagmap[i].type,
+ convertToUtf8 (tmp,
+ strlen (tmp), charset), prev);
+ free (tmp);
+ }
+ i++;
}
- i++;
- }
- while (tags != NULL) {
- t = tags;
- if (tagMatch("title",
- t->tagStart,
- t->tagEnd))
- prev = addKeyword(EXTRACTOR_TITLE,
- convertToUtf8(t->dataStart,
- t->dataEnd - t->dataStart,
- charset),
- prev);
- tags = t->next;
- free(t);
- }
- free(charset);
+ while (tags != NULL)
+ {
+ t = tags;
+ if (tagMatch ("title", t->tagStart, t->tagEnd))
+ prev = addKeyword (EXTRACTOR_TITLE,
+ convertToUtf8 (t->dataStart,
+ t->dataEnd - t->dataStart,
+ charset), prev);
+ tags = t->next;
+ free (t);
+ }
+ free (charset);
return prev;
}
-
Modified: Extractor/src/plugins/id3v23extractor.c
===================================================================
--- Extractor/src/plugins/id3v23extractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/id3v23extractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -31,77 +31,80 @@
#include <stdlib.h>
#include <fcntl.h>
#ifndef MINGW
- #include <sys/mman.h>
+#include <sys/mman.h>
#endif
#include "convert.h"
-static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead,
- char *phrase,
- EXTRACTOR_KeywordType type) {
- EXTRACTOR_KeywordList * keyword;
+static struct EXTRACTOR_Keywords *
+addKeyword (EXTRACTOR_KeywordList * oldhead,
+ char *phrase, EXTRACTOR_KeywordType type)
+{
+ EXTRACTOR_KeywordList *keyword;
- keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList));
+ keyword = (EXTRACTOR_KeywordList *) malloc (sizeof (EXTRACTOR_KeywordList));
keyword->next = oldhead;
keyword->keyword = phrase;
keyword->keywordType = type;
return keyword;
}
-typedef struct {
- char * text;
+typedef struct
+{
+ char *text;
EXTRACTOR_KeywordType type;
} Matches;
static Matches tmap[] = {
- { "COMM", EXTRACTOR_COMMENT },
- { "IPLS", EXTRACTOR_CONTRIBUTOR },
- { "LINK", EXTRACTOR_LINK },
- { "MCDI", EXTRACTOR_MUSIC_CD_IDENTIFIER },
- { "PCNT", EXTRACTOR_PLAY_COUNTER },
- { "POPM", EXTRACTOR_POPULARITY_METER },
- { "TCOP", EXTRACTOR_COPYRIGHT },
- { "TDAT", EXTRACTOR_DATE },
- { "TCON", EXTRACTOR_CONTENT_TYPE },
- { "TIT1", EXTRACTOR_GENRE },
- { "TENC", EXTRACTOR_ENCODED_BY },
- { "TEXT", EXTRACTOR_LYRICS },
- { "TOLY", EXTRACTOR_CONTRIBUTOR },
- { "TOPE", EXTRACTOR_CONTRIBUTOR },
- { "TOWN", EXTRACTOR_OWNER },
- { "TPE1", EXTRACTOR_ARTIST },
- { "TPE2", EXTRACTOR_ARTIST },
- { "TPE3", EXTRACTOR_CONDUCTOR },
- { "TPE4", EXTRACTOR_INTERPRET },
- { "TMED", EXTRACTOR_MEDIA_TYPE },
- { "TCOM", EXTRACTOR_CREATOR },
- { "TIME", EXTRACTOR_TIME },
- { "TOFN", EXTRACTOR_FILENAME },
- { "TOPE", EXTRACTOR_ARTIST },
- { "TPUB", EXTRACTOR_PUBLISHER },
- { "TRSN", EXTRACTOR_SOURCE },
- { "TRSO", EXTRACTOR_CREATED_FOR },
- { "TSRC", EXTRACTOR_RESOURCE_IDENTIFIER },
- { "TOAL", EXTRACTOR_ALBUM },
- { "TALB", EXTRACTOR_ALBUM },
- { "TLAN", EXTRACTOR_LANGUAGE },
- { "TYER", EXTRACTOR_YEAR },
- { "TLEN", EXTRACTOR_DURATION },
- { "TIT2", EXTRACTOR_TITLE },
- { "TIT3", EXTRACTOR_DESCRIPTION },
- { "WCOM", EXTRACTOR_RELEASE },
- { "WCOP", EXTRACTOR_DISCLAIMER },
- { "", EXTRACTOR_KEYWORDS },
- { NULL, 0},
+ {"COMM", EXTRACTOR_COMMENT},
+ {"IPLS", EXTRACTOR_CONTRIBUTOR},
+ {"LINK", EXTRACTOR_LINK},
+ {"MCDI", EXTRACTOR_MUSIC_CD_IDENTIFIER},
+ {"PCNT", EXTRACTOR_PLAY_COUNTER},
+ {"POPM", EXTRACTOR_POPULARITY_METER},
+ {"TCOP", EXTRACTOR_COPYRIGHT},
+ {"TDAT", EXTRACTOR_DATE},
+ {"TCON", EXTRACTOR_CONTENT_TYPE},
+ {"TIT1", EXTRACTOR_GENRE},
+ {"TENC", EXTRACTOR_ENCODED_BY},
+ {"TEXT", EXTRACTOR_LYRICS},
+ {"TOLY", EXTRACTOR_CONTRIBUTOR},
+ {"TOPE", EXTRACTOR_CONTRIBUTOR},
+ {"TOWN", EXTRACTOR_OWNER},
+ {"TPE1", EXTRACTOR_ARTIST},
+ {"TPE2", EXTRACTOR_ARTIST},
+ {"TPE3", EXTRACTOR_CONDUCTOR},
+ {"TPE4", EXTRACTOR_INTERPRET},
+ {"TMED", EXTRACTOR_MEDIA_TYPE},
+ {"TCOM", EXTRACTOR_CREATOR},
+ {"TIME", EXTRACTOR_TIME},
+ {"TOFN", EXTRACTOR_FILENAME},
+ {"TOPE", EXTRACTOR_ARTIST},
+ {"TPUB", EXTRACTOR_PUBLISHER},
+ {"TRSN", EXTRACTOR_SOURCE},
+ {"TRSO", EXTRACTOR_CREATED_FOR},
+ {"TSRC", EXTRACTOR_RESOURCE_IDENTIFIER},
+ {"TOAL", EXTRACTOR_ALBUM},
+ {"TALB", EXTRACTOR_ALBUM},
+ {"TLAN", EXTRACTOR_LANGUAGE},
+ {"TYER", EXTRACTOR_YEAR},
+ {"TLEN", EXTRACTOR_DURATION},
+ {"TIT2", EXTRACTOR_TITLE},
+ {"TIT3", EXTRACTOR_DESCRIPTION},
+ {"WCOM", EXTRACTOR_RELEASE},
+ {"WCOP", EXTRACTOR_DISCLAIMER},
+ {"", EXTRACTOR_KEYWORDS},
+ {NULL, 0},
};
/* mimetype = audio/mpeg */
struct EXTRACTOR_Keywords *
-libextractor_id3v23_extract(const char * filename,
- const unsigned char * data,
- const size_t size,
- struct EXTRACTOR_Keywords * prev) {
+libextractor_id3v23_extract (const char *filename,
+ const unsigned char *data,
+ const size_t size,
+ struct EXTRACTOR_Keywords *prev)
+{
int unsync;
int extendedHdr;
int experimental;
@@ -110,110 +113,105 @@
unsigned int ehdrSize;
unsigned int padding;
- if ( (size < 16) ||
- (data[0] != 0x49) ||
- (data[1] != 0x44) ||
- (data[2] != 0x33) ||
- (data[3] != 0x03) ||
- (data[4] != 0x00) )
+ if ((size < 16) ||
+ (data[0] != 0x49) ||
+ (data[1] != 0x44) ||
+ (data[2] != 0x33) || (data[3] != 0x03) || (data[4] != 0x00))
return prev;
unsync = (data[5] & 0x80) > 0;
extendedHdr = (data[5] & 0x40) > 0;
experimental = (data[5] & 0x20) > 0;
- tsize = ( ( (data[6] & 0x7F) << 21 ) |
- ( (data[7] & 0x7F) << 14 ) |
- ( (data[8] & 0x7F) << 7 ) |
- ( (data[9] & 0x7F) << 0 ) );
- if ( (tsize + 10 > size) || (experimental) )
+ tsize = (((data[6] & 0x7F) << 21) |
+ ((data[7] & 0x7F) << 14) |
+ ((data[8] & 0x7F) << 7) | ((data[9] & 0x7F) << 0));
+ if ((tsize + 10 > size) || (experimental))
return prev;
pos = 10;
padding = 0;
- if (extendedHdr) {
- ehdrSize = ( ( (data[10]) << 24 ) |
- ( (data[11]) << 16 ) |
- ( (data[12]) << 8 ) |
- ( (data[12]) << 0 ) );
+ if (extendedHdr)
+ {
+ ehdrSize = (((data[10]) << 24) |
+ ((data[11]) << 16) | ((data[12]) << 8) | ((data[12]) << 0));
- padding = ( ( (data[15]) << 24 ) |
- ( (data[16]) << 16 ) |
- ( (data[17]) << 8 ) |
- ( (data[18]) << 0 ) );
- pos += 4 + ehdrSize;
- if (padding < tsize)
- tsize -= padding;
- else
- return prev;
- }
+ padding = (((data[15]) << 24) |
+ ((data[16]) << 16) | ((data[17]) << 8) | ((data[18]) << 0));
+ pos += 4 + ehdrSize;
+ if (padding < tsize)
+ tsize -= padding;
+ else
+ return prev;
+ }
- while (pos < tsize) {
- size_t csize;
- int i;
- unsigned short flags;
+ while (pos < tsize)
+ {
+ size_t csize;
+ int i;
+ unsigned short flags;
- if (pos + 10 > tsize)
- return prev;
- csize = (data[pos+4] << 24) + (data[pos+5] << 16) + (data[pos+6] << 8) +
data[pos+7];
- if ( (pos + 10 + csize > tsize) ||
- (csize > tsize) ||
- (csize == 0) )
- break;
- flags = (data[pos+8]<<8) + data[pos+9];
- if ( ( (flags & 0x80) > 0) /* compressed, not yet supported */ ||
- ( (flags & 0x40) > 0) /* encrypted, not supported */ ) {
+ if (pos + 10 > tsize)
+ return prev;
+ csize =
+ (data[pos + 4] << 24) + (data[pos + 5] << 16) + (data[pos + 6] << 8) +
+ data[pos + 7];
+ if ((pos + 10 + csize > tsize) || (csize > tsize) || (csize == 0))
+ break;
+ flags = (data[pos + 8] << 8) + data[pos + 9];
+ if (((flags & 0x80) > 0) /* compressed, not yet supported */ ||
+ ((flags & 0x40) > 0) /* encrypted, not supported */ )
+ {
+ pos += 10 + csize;
+ continue;
+ }
+ i = 0;
+ while (tmap[i].text != NULL)
+ {
+ if (0 == strncmp (tmap[i].text, (const char *) &data[pos], 4))
+ {
+ char *word;
+ if ((flags & 0x20) > 0)
+ {
+ /* "group" identifier, skip a byte */
+ pos++;
+ csize--;
+ }
+ csize--;
+ /* this byte describes the encoding
+ try to convert strings to UTF-8
+ if it fails, then forget it */
+ switch (data[pos + 10])
+ {
+ case 0x00:
+ word = convertToUtf8 ((const char *) &data[pos + 11],
+ csize, "ISO-8859-1");
+ break;
+ case 0x01:
+ word = convertToUtf8 ((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],
+ csize, "ISO-8859-1");
+ break;
+ }
+ pos++;
+ if ((word != NULL) && (strlen (word) > 0))
+ {
+ prev = addKeyword (prev, word, tmap[i].type);
+ }
+ else
+ {
+ if (word != NULL)
+ free (word);
+ }
+ break;
+ }
+ i++;
+ }
pos += 10 + csize;
- continue;
}
- i = 0;
- while (tmap[i].text != NULL) {
- if (0 == strncmp(tmap[i].text,
- (const char*) &data[pos],
- 4)) {
- char * word;
- if ( (flags & 0x20) > 0) {
- /* "group" identifier, skip a byte */
- pos++;
- csize--;
- }
- csize--;
- /* this byte describes the encoding
- try to convert strings to UTF-8
- if it fails, then forget it */
- switch (data[pos+10]) {
- case 0x00 :
- word = convertToUtf8((const char*) &data[pos+11],
- csize,
- "ISO-8859-1");
- break;
- case 0x01 :
- word = convertToUtf8((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],
- csize,
- "ISO-8859-1");
- break;
- }
- pos++;
- if ( (word != NULL) &&
- (strlen(word) > 0) ) {
- prev = addKeyword(prev,
- word,
- tmap[i].type);
- } else {
- if (word != NULL)
- free(word);
- }
- break;
- }
- i++;
- }
- pos += 10 + csize;
- }
return prev;
}
Modified: Extractor/src/plugins/id3v24extractor.c
===================================================================
--- Extractor/src/plugins/id3v24extractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/id3v24extractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -31,80 +31,82 @@
#include <stdlib.h>
#include <fcntl.h>
#ifndef MINGW
- #include <sys/mman.h>
+#include <sys/mman.h>
#endif
#include "convert.h"
static struct EXTRACTOR_Keywords *
-addKeyword(EXTRACTOR_KeywordList *oldhead,
- char *phrase,
- EXTRACTOR_KeywordType type) {
- EXTRACTOR_KeywordList * keyword;
+addKeyword (EXTRACTOR_KeywordList * oldhead,
+ char *phrase, EXTRACTOR_KeywordType type)
+{
+ EXTRACTOR_KeywordList *keyword;
- keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList));
+ keyword = (EXTRACTOR_KeywordList *) malloc (sizeof (EXTRACTOR_KeywordList));
keyword->next = oldhead;
keyword->keyword = phrase;
keyword->keywordType = type;
return keyword;
}
-typedef struct {
- char * text;
+typedef struct
+{
+ char *text;
EXTRACTOR_KeywordType type;
} Matches;
static Matches tmap[] = {
- { "COMM", EXTRACTOR_COMMENT },
- { "IPLS", EXTRACTOR_CONTRIBUTOR },
- { "TIPL", EXTRACTOR_CONTRIBUTOR },
- { "TMOO", EXTRACTOR_MOOD },
- { "TMCL", EXTRACTOR_MUSICIAN_CREDITS_LIST },
- { "LINK", EXTRACTOR_LINK },
- { "MCDI", EXTRACTOR_MUSIC_CD_IDENTIFIER },
- { "PCNT", EXTRACTOR_PLAY_COUNTER },
- { "POPM", EXTRACTOR_POPULARITY_METER },
- { "TCOP", EXTRACTOR_COPYRIGHT },
- { "TDRC", EXTRACTOR_DATE },
- { "TCON", EXTRACTOR_GENRE },
- { "TIT1", EXTRACTOR_GENRE },
- { "TENC", EXTRACTOR_ENCODED_BY },
- { "TEXT", EXTRACTOR_LYRICS },
- { "TOLY", EXTRACTOR_CONTRIBUTOR },
- { "TOPE", EXTRACTOR_CONTRIBUTOR },
- { "TOWN", EXTRACTOR_OWNER },
- { "TPE1", EXTRACTOR_ARTIST },
- { "TPE2", EXTRACTOR_ARTIST },
- { "TPE3", EXTRACTOR_CONDUCTOR },
- { "TPE4", EXTRACTOR_INTERPRET },
- { "TIME", EXTRACTOR_TIME },
- { "TMED", EXTRACTOR_MEDIA_TYPE },
- { "TCOM", EXTRACTOR_CREATOR },
- { "TOFN", EXTRACTOR_FILENAME },
- { "TOPE", EXTRACTOR_ARTIST },
- { "TPUB", EXTRACTOR_PUBLISHER },
- { "TRSN", EXTRACTOR_SOURCE },
- { "TRSO", EXTRACTOR_CREATED_FOR },
- { "TSRC", EXTRACTOR_RESOURCE_IDENTIFIER },
- { "TYER", EXTRACTOR_YEAR },
- { "TOAL", EXTRACTOR_ALBUM },
- { "TALB", EXTRACTOR_ALBUM },
- { "TLAN", EXTRACTOR_LANGUAGE },
- { "TIT2", EXTRACTOR_TITLE },
- { "TIT3", EXTRACTOR_DESCRIPTION },
- { "WCOM", EXTRACTOR_RELEASE },
- { "WCOP", EXTRACTOR_DISCLAIMER },
- { "", EXTRACTOR_KEYWORDS },
- { NULL, 0},
+ {"COMM", EXTRACTOR_COMMENT},
+ {"IPLS", EXTRACTOR_CONTRIBUTOR},
+ {"TIPL", EXTRACTOR_CONTRIBUTOR},
+ {"TMOO", EXTRACTOR_MOOD},
+ {"TMCL", EXTRACTOR_MUSICIAN_CREDITS_LIST},
+ {"LINK", EXTRACTOR_LINK},
+ {"MCDI", EXTRACTOR_MUSIC_CD_IDENTIFIER},
+ {"PCNT", EXTRACTOR_PLAY_COUNTER},
+ {"POPM", EXTRACTOR_POPULARITY_METER},
+ {"TCOP", EXTRACTOR_COPYRIGHT},
+ {"TDRC", EXTRACTOR_DATE},
+ {"TCON", EXTRACTOR_GENRE},
+ {"TIT1", EXTRACTOR_GENRE},
+ {"TENC", EXTRACTOR_ENCODED_BY},
+ {"TEXT", EXTRACTOR_LYRICS},
+ {"TOLY", EXTRACTOR_CONTRIBUTOR},
+ {"TOPE", EXTRACTOR_CONTRIBUTOR},
+ {"TOWN", EXTRACTOR_OWNER},
+ {"TPE1", EXTRACTOR_ARTIST},
+ {"TPE2", EXTRACTOR_ARTIST},
+ {"TPE3", EXTRACTOR_CONDUCTOR},
+ {"TPE4", EXTRACTOR_INTERPRET},
+ {"TIME", EXTRACTOR_TIME},
+ {"TMED", EXTRACTOR_MEDIA_TYPE},
+ {"TCOM", EXTRACTOR_CREATOR},
+ {"TOFN", EXTRACTOR_FILENAME},
+ {"TOPE", EXTRACTOR_ARTIST},
+ {"TPUB", EXTRACTOR_PUBLISHER},
+ {"TRSN", EXTRACTOR_SOURCE},
+ {"TRSO", EXTRACTOR_CREATED_FOR},
+ {"TSRC", EXTRACTOR_RESOURCE_IDENTIFIER},
+ {"TYER", EXTRACTOR_YEAR},
+ {"TOAL", EXTRACTOR_ALBUM},
+ {"TALB", EXTRACTOR_ALBUM},
+ {"TLAN", EXTRACTOR_LANGUAGE},
+ {"TIT2", EXTRACTOR_TITLE},
+ {"TIT3", EXTRACTOR_DESCRIPTION},
+ {"WCOM", EXTRACTOR_RELEASE},
+ {"WCOP", EXTRACTOR_DISCLAIMER},
+ {"", EXTRACTOR_KEYWORDS},
+ {NULL, 0},
};
/* mimetype = audio/mpeg */
struct EXTRACTOR_Keywords *
-libextractor_id3v24_extract(const char * filename,
- const unsigned char * data,
- const size_t size,
- struct EXTRACTOR_Keywords * prev) {
+libextractor_id3v24_extract (const char *filename,
+ const unsigned char *data,
+ const size_t size,
+ struct EXTRACTOR_Keywords *prev)
+{
int unsync;
int extendedHdr;
int experimental;
@@ -114,119 +116,111 @@
unsigned int ehdrSize;
unsigned int padding;
- if ( (size < 16) ||
- (data[0] != 0x49) ||
- (data[1] != 0x44) ||
- (data[2] != 0x33) ||
- (data[3] != 0x04) ||
- (data[4] != 0x00) )
+ if ((size < 16) ||
+ (data[0] != 0x49) ||
+ (data[1] != 0x44) ||
+ (data[2] != 0x33) || (data[3] != 0x04) || (data[4] != 0x00))
return prev;
unsync = (data[5] & 0x80) > 0;
extendedHdr = (data[5] & 0x40) > 0;
experimental = (data[5] & 0x20) > 0;
footer = (data[5] & 0x10) > 0;
- tsize = ( ( (data[6] & 0x7F) << 21 ) |
- ( (data[7] & 0x7F) << 14 ) |
- ( (data[8] & 0x7F) << 7 ) |
- ( (data[9] & 0x7F) << 0 ) );
- if ( (tsize + 10 > size) || (experimental) )
+ tsize = (((data[6] & 0x7F) << 21) |
+ ((data[7] & 0x7F) << 14) |
+ ((data[8] & 0x7F) << 7) | ((data[9] & 0x7F) << 0));
+ if ((tsize + 10 > size) || (experimental))
return prev;
pos = 10;
padding = 0;
- if (extendedHdr) {
- ehdrSize = ( ( (data[10] & 0x7F) << 21 ) |
- ( (data[11] & 0x7F) << 14 ) |
- ( (data[12] & 0x7F) << 7 ) |
- ( (data[13] & 0x7F) << 0 ) );
- pos += ehdrSize;
- }
+ if (extendedHdr)
+ {
+ ehdrSize = (((data[10] & 0x7F) << 21) |
+ ((data[11] & 0x7F) << 14) |
+ ((data[12] & 0x7F) << 7) | ((data[13] & 0x7F) << 0));
+ pos += ehdrSize;
+ }
- while (pos < tsize) {
- size_t csize;
- int i;
- unsigned short flags;
+ while (pos < tsize)
+ {
+ size_t csize;
+ int i;
+ unsigned short flags;
- if (pos + 10 > tsize)
- return prev;
+ if (pos + 10 > tsize)
+ return prev;
- csize = ( ( (data[pos+4] & 0x7F) << 21 ) |
- ( (data[pos+5] & 0x7F) << 14 ) |
- ( (data[pos+6] & 0x7F) << 7 ) |
- ( (data[pos+7] & 0x7F) << 0 ) );
+ csize = (((data[pos + 4] & 0x7F) << 21) |
+ ((data[pos + 5] & 0x7F) << 14) |
+ ((data[pos + 6] & 0x7F) << 7) | ((data[pos + 7] & 0x7F) << 0));
- if ( (pos + 10 + csize > tsize) ||
- (csize > tsize) ||
- (csize == 0) )
- break;
- flags = (data[pos+8]<<8) + data[pos+9];
- if ( ( (flags & 0x80) > 0) /* compressed, not yet supported */ ||
- ( (flags & 0x40) > 0) /* encrypted, not supported */ ) {
+ if ((pos + 10 + csize > tsize) || (csize > tsize) || (csize == 0))
+ break;
+ flags = (data[pos + 8] << 8) + data[pos + 9];
+ if (((flags & 0x80) > 0) /* compressed, not yet supported */ ||
+ ((flags & 0x40) > 0) /* encrypted, not supported */ )
+ {
+ pos += 10 + csize;
+ continue;
+ }
+ i = 0;
+ while (tmap[i].text != NULL)
+ {
+ if (0 == strncmp (tmap[i].text, (const char *) &data[pos], 4))
+ {
+ char *word;
+ if ((flags & 0x20) > 0)
+ {
+ /* "group" identifier, skip a byte */
+ pos++;
+ csize--;
+ }
+
+ /* this byte describes the encoding
+ try to convert strings to UTF-8
+ if it fails, then forget it */
+ switch (data[pos + 10])
+ {
+ case 0x00:
+ word = convertToUtf8 ((const char *) &data[pos + 11],
+ csize, "ISO-8859-1");
+ break;
+ case 0x01:
+ word = convertToUtf8 ((const char *) &data[pos + 11],
+ csize, "UTF-16");
+ break;
+ case 0x02:
+ word = convertToUtf8 ((const char *) &data[pos + 11],
+ csize, "UTF-16BE");
+ break;
+ case 0x03:
+ word = malloc (csize + 1);
+ memcpy (word, &data[pos + 11], csize);
+ word[csize] = '\0';
+ break;
+ default:
+ /* bad encoding byte,
+ try to convert from iso-8859-1 */
+ word = convertToUtf8 ((const char *) &data[pos + 11],
+ csize, "ISO-8859-1");
+ break;
+ }
+ pos++;
+ csize--;
+ if ((word != NULL) && (strlen (word) > 0))
+ {
+ prev = addKeyword (prev, word, tmap[i].type);
+ }
+ else
+ {
+ free (word);
+ }
+ break;
+ }
+ i++;
+ }
pos += 10 + csize;
- continue;
}
- i = 0;
- while (tmap[i].text != NULL) {
- if (0 == strncmp(tmap[i].text,
- (const char*) &data[pos],
- 4)) {
- char * word;
- if ( (flags & 0x20) > 0) {
- /* "group" identifier, skip a byte */
- pos++;
- csize--;
- }
-
- /* this byte describes the encoding
- try to convert strings to UTF-8
- if it fails, then forget it */
- switch (data[pos+10]) {
- case 0x00 :
- word = convertToUtf8((const char*) &data[pos+11],
- csize,
- "ISO-8859-1");
- break;
- case 0x01 :
- word = convertToUtf8((const char*) &data[pos+11],
- csize,
- "UTF-16");
- break;
- case 0x02 :
- word = convertToUtf8((const char*) &data[pos+11],
- csize,
- "UTF-16BE");
- break;
- case 0x03 :
- word = malloc(csize+1);
- memcpy(word,
- &data[pos+11],
- csize);
- word[csize] = '\0';
- break;
- default:
- /* bad encoding byte,
- try to convert from iso-8859-1 */
- word = convertToUtf8((const char*) &data[pos+11],
- csize,
- "ISO-8859-1");
- break;
- }
- pos++;
- csize--;
- if ( (word != NULL) &&
- (strlen(word) > 0) ) {
- prev = addKeyword(prev,
- word,
- tmap[i].type);
- } else {
- free(word);
- }
- break;
- }
- i++;
- }
- pos += 10 + csize;
- }
return prev;
}
Modified: Extractor/src/plugins/id3v2extractor.c
===================================================================
--- Extractor/src/plugins/id3v2extractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/id3v2extractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -22,148 +22,144 @@
#include "platform.h"
#include "extractor.h"
#ifndef MINGW
- #include <sys/mman.h>
+#include <sys/mman.h>
#endif
#include "convert.h"
#define DEBUG_EXTRACT_ID3v2 0
-static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordList *oldhead,
- char *phrase,
- EXTRACTOR_KeywordType type) {
- EXTRACTOR_KeywordList * keyword;
+static struct EXTRACTOR_Keywords *
+addKeyword (EXTRACTOR_KeywordList * oldhead,
+ char *phrase, EXTRACTOR_KeywordType type)
+{
+ EXTRACTOR_KeywordList *keyword;
- keyword = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList));
+ keyword = (EXTRACTOR_KeywordList *) malloc (sizeof (EXTRACTOR_KeywordList));
keyword->next = oldhead;
keyword->keyword = phrase;
keyword->keywordType = type;
return keyword;
}
-typedef struct {
- char * text;
+typedef struct
+{
+ char *text;
EXTRACTOR_KeywordType type;
} Matches;
static Matches tmap[] = {
- { "TAL", EXTRACTOR_TITLE },
- { "TT1", EXTRACTOR_GROUP },
- { "TT2", EXTRACTOR_TITLE },
- { "TT3", EXTRACTOR_TITLE },
- { "TXT", EXTRACTOR_DESCRIPTION },
- { "TPB", EXTRACTOR_PUBLISHER },
- { "WAF", EXTRACTOR_LOCATION },
- { "WAR", EXTRACTOR_LOCATION },
- { "WAS", EXTRACTOR_LOCATION },
- { "WCP", EXTRACTOR_COPYRIGHT },
- { "WAF", EXTRACTOR_LOCATION },
- { "WCM", EXTRACTOR_DISCLAIMER },
- { "TSS", EXTRACTOR_FORMAT },
- { "TYE", EXTRACTOR_DATE },
- { "TLA", EXTRACTOR_LANGUAGE },
- { "TP1", EXTRACTOR_ARTIST },
- { "TP2", EXTRACTOR_ARTIST },
- { "TP3", EXTRACTOR_CONDUCTOR },
- { "TP4", EXTRACTOR_INTERPRET },
- { "IPL", EXTRACTOR_CONTRIBUTOR },
- { "TOF", EXTRACTOR_FILENAME },
- { "TEN", EXTRACTOR_PRODUCER },
- { "TCO", EXTRACTOR_SUBJECT },
- { "TCR", EXTRACTOR_COPYRIGHT },
- { "SLT", EXTRACTOR_LYRICS },
- { "TOA", EXTRACTOR_ARTIST },
- { "TRC", EXTRACTOR_RESOURCE_IDENTIFIER },
- { "TCM", EXTRACTOR_CREATOR },
- { "TOT", EXTRACTOR_ALBUM },
- { "TOL", EXTRACTOR_AUTHOR },
- { "COM", EXTRACTOR_COMMENT },
- { "", EXTRACTOR_KEYWORDS },
- { NULL, 0},
+ {"TAL", EXTRACTOR_TITLE},
+ {"TT1", EXTRACTOR_GROUP},
+ {"TT2", EXTRACTOR_TITLE},
+ {"TT3", EXTRACTOR_TITLE},
+ {"TXT", EXTRACTOR_DESCRIPTION},
+ {"TPB", EXTRACTOR_PUBLISHER},
+ {"WAF", EXTRACTOR_LOCATION},
+ {"WAR", EXTRACTOR_LOCATION},
+ {"WAS", EXTRACTOR_LOCATION},
+ {"WCP", EXTRACTOR_COPYRIGHT},
+ {"WAF", EXTRACTOR_LOCATION},
+ {"WCM", EXTRACTOR_DISCLAIMER},
+ {"TSS", EXTRACTOR_FORMAT},
+ {"TYE", EXTRACTOR_DATE},
+ {"TLA", EXTRACTOR_LANGUAGE},
+ {"TP1", EXTRACTOR_ARTIST},
+ {"TP2", EXTRACTOR_ARTIST},
+ {"TP3", EXTRACTOR_CONDUCTOR},
+ {"TP4", EXTRACTOR_INTERPRET},
+ {"IPL", EXTRACTOR_CONTRIBUTOR},
+ {"TOF", EXTRACTOR_FILENAME},
+ {"TEN", EXTRACTOR_PRODUCER},
+ {"TCO", EXTRACTOR_SUBJECT},
+ {"TCR", EXTRACTOR_COPYRIGHT},
+ {"SLT", EXTRACTOR_LYRICS},
+ {"TOA", EXTRACTOR_ARTIST},
+ {"TRC", EXTRACTOR_RESOURCE_IDENTIFIER},
+ {"TCM", EXTRACTOR_CREATOR},
+ {"TOT", EXTRACTOR_ALBUM},
+ {"TOL", EXTRACTOR_AUTHOR},
+ {"COM", EXTRACTOR_COMMENT},
+ {"", EXTRACTOR_KEYWORDS},
+ {NULL, 0},
};
/* mimetype = audio/mpeg */
struct EXTRACTOR_Keywords *
-libextractor_id3v2_extract(const char * filename,
- const unsigned char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev) {
+libextractor_id3v2_extract (const char *filename,
+ const unsigned char *data,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
int unsync;
unsigned int tsize;
unsigned int pos;
- if ( (size < 16) ||
- (data[0] != 0x49) ||
- (data[1] != 0x44) ||
- (data[2] != 0x33) ||
- (data[3] != 0x02) ||
- (data[4] != 0x00) )
+ if ((size < 16) ||
+ (data[0] != 0x49) ||
+ (data[1] != 0x44) ||
+ (data[2] != 0x33) || (data[3] != 0x02) || (data[4] != 0x00))
return prev;
unsync = (data[5] & 0x80) > 0;
- tsize = ( ( (data[6] & 0x7F) << 21 ) |
- ( (data[7] & 0x7F) << 14 ) |
- ( (data[8] & 0x7F) << 07 ) |
- ( (data[9] & 0x7F) << 00 ) );
+ tsize = (((data[6] & 0x7F) << 21) |
+ ((data[7] & 0x7F) << 14) |
+ ((data[8] & 0x7F) << 07) | ((data[9] & 0x7F) << 00));
if (tsize + 10 > size)
return prev;
pos = 10;
- while (pos < tsize) {
- size_t csize;
- int i;
+ while (pos < tsize)
+ {
+ size_t csize;
+ int i;
- if (pos + 6 > tsize)
- return prev;
- csize = (data[pos+3] << 16) + (data[pos+4] << 8) + data[pos+5];
- if ( (pos + 6 + csize > tsize) ||
- (csize > tsize) ||
- (csize == 0) )
- break;
- i = 0;
- while (tmap[i].text != NULL) {
- if (0 == strncmp(tmap[i].text,
- (const char*) &data[pos],
- 3)) {
- char * word;
- /* this byte describes the encoding
- try to convert strings to UTF-8
- if it fails, then forget it */
- switch (data[pos+6]) {
- case 0x00:
- word = convertToUtf8((const char*) &data[pos+7],
- csize,
- "ISO-8859-1");
- break;
- case 0x01:
- word = convertToUtf8((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],
- csize,
- "ISO-8859-1");
- break;
- }
- pos++;
- csize--;
- if ( (word != NULL) &&
- (strlen(word) > 0) ) {
- prev = addKeyword(prev,
- word,
- tmap[i].type);
- } else {
- free(word);
- }
- break;
- }
- i++;
+ if (pos + 6 > tsize)
+ return prev;
+ csize = (data[pos + 3] << 16) + (data[pos + 4] << 8) + data[pos + 5];
+ if ((pos + 6 + csize > tsize) || (csize > tsize) || (csize == 0))
+ break;
+ i = 0;
+ while (tmap[i].text != NULL)
+ {
+ if (0 == strncmp (tmap[i].text, (const char *) &data[pos], 3))
+ {
+ char *word;
+ /* this byte describes the encoding
+ try to convert strings to UTF-8
+ if it fails, then forget it */
+ switch (data[pos + 6])
+ {
+ case 0x00:
+ word = convertToUtf8 ((const char *) &data[pos + 7],
+ csize, "ISO-8859-1");
+ break;
+ case 0x01:
+ word = convertToUtf8 ((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],
+ csize, "ISO-8859-1");
+ break;
+ }
+ pos++;
+ csize--;
+ if ((word != NULL) && (strlen (word) > 0))
+ {
+ prev = addKeyword (prev, word, tmap[i].type);
+ }
+ else
+ {
+ free (word);
+ }
+ break;
+ }
+ i++;
+ }
+ pos += 6 + csize;
}
- pos += 6 + csize;
- }
return prev;
}
Modified: Extractor/src/plugins/jpegextractor.c
===================================================================
--- Extractor/src/plugins/jpegextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/jpegextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -22,21 +22,22 @@
#include "extractor.h"
-#define M_SOI 0xD8 /* Start Of Image (beginning of datastream) */
-#define M_EOI 0xD9 /* End Of Image (end of datastream) */
-#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */
-#define M_APP12 0xEC
-#define M_COM 0xFE /* COMment */
+#define M_SOI 0xD8 /* Start Of Image (beginning of datastream) */
+#define M_EOI 0xD9 /* End Of Image (end of datastream) */
+#define M_SOS 0xDA /* Start Of Scan (begins compressed data) */
+#define M_APP12 0xEC
+#define M_COM 0xFE /* COMment */
#define M_APP0 0xE0
-static EXTRACTOR_KeywordList * addKeyword(EXTRACTOR_KeywordType type,
- char * keyword,
- EXTRACTOR_KeywordList * next) {
- EXTRACTOR_KeywordList * result;
+static EXTRACTOR_KeywordList *
+addKeyword (EXTRACTOR_KeywordType type,
+ char *keyword, EXTRACTOR_KeywordList * next)
+{
+ EXTRACTOR_KeywordList *result;
if (keyword == NULL)
return next;
- result = malloc(sizeof(EXTRACTOR_KeywordList));
+ result = malloc (sizeof (EXTRACTOR_KeywordList));
result->next = next;
result->keyword = keyword;
result->keywordType = type;
@@ -66,177 +67,177 @@
* All 2-byte quantities in JPEG markers are MSB first
* @return -1 on error
*/
-static int readLength(unsigned char ** data,
- unsigned char * end) {
+static int
+readLength (unsigned char **data, unsigned char *end)
+{
int c1;
int c2;
- c1 = NEXTC(data, end);
+ c1 = NEXTC (data, end);
if (c1 == -1)
return -1;
- c2 = NEXTC(data, end);
+ c2 = NEXTC (data, end);
if (c2 == -1)
return -1;
- return ((((unsigned int) c1) << 8) + ((unsigned int) c2))-2;
+ return ((((unsigned int) c1) << 8) + ((unsigned int) c2)) - 2;
}
/**
* @return the next marker or -1 on error.
*/
-static int next_marker(unsigned char ** data,
- unsigned char * end) {
+static int
+next_marker (unsigned char **data, unsigned char *end)
+{
int c;
- c = NEXTC(data, end);
- while ( (c != 0xFF) && (c != -1) )
- c = NEXTC(data, end);
- do {
- c = NEXTC(data, end);
- } while ( (c == 0xFF) && (c != -1) );
+ c = NEXTC (data, end);
+ while ((c != 0xFF) && (c != -1))
+ c = NEXTC (data, end);
+ do
+ {
+ c = NEXTC (data, end);
+ }
+ while ((c == 0xFF) && (c != -1));
return c;
}
-static void skip_variable(unsigned char ** data,
- unsigned char * end) {
+static void
+skip_variable (unsigned char **data, unsigned char *end)
+{
int length;
- length = readLength(data, end);
- if (length < 0) {
- (*data) = end; /* skip to the end */
- return;
- }
+ length = readLength (data, end);
+ if (length < 0)
+ {
+ (*data) = end; /* skip to the end */
+ return;
+ }
/* Skip over length bytes */
(*data) += length;
}
-static char * process_COM(unsigned char ** data,
- unsigned char * end) {
+static char *
+process_COM (unsigned char **data, unsigned char *end)
+{
unsigned int length;
int ch;
int pos;
- char * comment;
+ char *comment;
- length = readLength(data, end);
+ length = readLength (data, end);
if (length <= 0)
return NULL;
- comment = malloc(length+1);
+ comment = malloc (length + 1);
pos = 0;
- while (length > 0) {
- ch = NEXTC(data, end);
- if ( (ch == '\r') ||
- (ch == '\n') )
- comment[pos++] = '\n';
- else if (isprint(ch))
- comment[pos++] = ch;
- length--;
- }
+ while (length > 0)
+ {
+ ch = NEXTC (data, end);
+ if ((ch == '\r') || (ch == '\n'))
+ comment[pos++] = '\n';
+ else if (isprint (ch))
+ comment[pos++] = ch;
+ length--;
+ }
comment[pos] = '\0';
return comment;
}
-struct EXTRACTOR_Keywords * libextractor_jpeg_extract(const char * filename,
- unsigned char * data,
- size_t size,
- struct
EXTRACTOR_Keywords * prev) {
+struct EXTRACTOR_Keywords *
+libextractor_jpeg_extract (const char *filename,
+ unsigned char *data,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
int c1;
int c2;
int marker;
- unsigned char * end;
- struct EXTRACTOR_Keywords * result;
+ unsigned char *end;
+ struct EXTRACTOR_Keywords *result;
if (size < 0x12)
return prev;
result = prev;
end = &data[size];
- c1 = NEXTC(&data, end);
- c2 = NEXTC(&data, end);
- if ( (c1 != 0xFF) || (c2 != M_SOI) )
- return result; /* not a JPEG */
- result = addKeyword(EXTRACTOR_MIMETYPE,
- strdup("image/jpeg"),
- result);
- while(1) {
- marker = next_marker(&data, end);
- switch (marker) {
- case -1: /* end of file */
- case M_SOS:
- case M_EOI:
- goto RETURN; /* this used to be "return result", but this
- makes certain compilers unhappy...*/
- case M_APP0: {
- int len = readLength(&data, end);
- if (len < 0x8)
- goto RETURN;
- if (0 == strncmp((char*)data,
- "JFIF",
- 4)) {
- char * val;
+ c1 = NEXTC (&data, end);
+ c2 = NEXTC (&data, end);
+ if ((c1 != 0xFF) || (c2 != M_SOI))
+ return result; /* not a JPEG */
+ result = addKeyword (EXTRACTOR_MIMETYPE, strdup ("image/jpeg"), result);
+ while (1)
+ {
+ marker = next_marker (&data, end);
+ switch (marker)
+ {
+ case -1: /* end of file */
+ case M_SOS:
+ case M_EOI:
+ goto RETURN; /* this used to be "return result", but this
+ makes certain compilers unhappy... */
+ case M_APP0:
+ {
+ int len = readLength (&data, end);
+ if (len < 0x8)
+ goto RETURN;
+ if (0 == strncmp ((char *) data, "JFIF", 4))
+ {
+ char *val;
- switch (data[0x4]) {
- case 1: /* dots per inch */
- val = malloc(128);
- snprintf(val, 128,
- _("%ux%u dots per inch"),
- (data[0x8] << 8) + data[0x9],
- (data[0xA] << 8) + data[0xB]);
- result = addKeyword(EXTRACTOR_RESOLUTION,
- val,
- result);
- break;
- case 2: /* dots per cm */
- val = malloc(128);
- snprintf(val, 128,
- _("%ux%u dots per cm"),
- (data[0x8] << 8) + data[0x9],
- (data[0xA] << 8) + data[0xB]);
- result = addKeyword(EXTRACTOR_RESOLUTION,
- val,
- result);
- break;
- case 0: /* no unit given */
- val = malloc(128);
- snprintf(val, 128,
- _("%ux%u dots per inch?"),
- (data[0x8] << 8) + data[0x9],
- (data[0xA] << 8) + data[0xB]);
- result = addKeyword(EXTRACTOR_RESOLUTION,
- val,
- result);
- break;
- default: /* unknown unit */
- break;
- }
- }
- data = &data[len];
- break;
+ switch (data[0x4])
+ {
+ case 1: /* dots per inch */
+ val = malloc (128);
+ snprintf (val, 128,
+ _("%ux%u dots per inch"),
+ (data[0x8] << 8) + data[0x9],
+ (data[0xA] << 8) + data[0xB]);
+ result = addKeyword (EXTRACTOR_RESOLUTION, val, result);
+ break;
+ case 2: /* dots per cm */
+ val = malloc (128);
+ snprintf (val, 128,
+ _("%ux%u dots per cm"),
+ (data[0x8] << 8) + data[0x9],
+ (data[0xA] << 8) + data[0xB]);
+ result = addKeyword (EXTRACTOR_RESOLUTION, val, result);
+ break;
+ case 0: /* no unit given */
+ val = malloc (128);
+ snprintf (val, 128,
+ _("%ux%u dots per inch?"),
+ (data[0x8] << 8) + data[0x9],
+ (data[0xA] << 8) + data[0xB]);
+ result = addKeyword (EXTRACTOR_RESOLUTION, val, result);
+ break;
+ default: /* unknown unit */
+ break;
+ }
+ }
+ data = &data[len];
+ break;
+ }
+ case 0xC0:
+ {
+ char *val;
+ int len = readLength (&data, end);
+ if (len < 0x9)
+ goto RETURN;
+ val = malloc (128);
+ snprintf (val, 128,
+ "%ux%u",
+ (data[0x3] << 8) + data[0x4],
+ (data[0x1] << 8) + data[0x2]);
+ result = addKeyword (EXTRACTOR_SIZE, val, result);
+ data = &data[len];
+ break;
+ }
+ case M_COM:
+ case M_APP12:
+ result = addKeyword (EXTRACTOR_COMMENT,
+ process_COM (&data, end), result);
+ break;
+ default:
+ skip_variable (&data, end);
+ break;
+ }
}
- case 0xC0: {
- char * val;
- int len = readLength(&data, end);
- if (len < 0x9)
- goto RETURN;
- val = malloc(128);
- snprintf(val, 128,
- "%ux%u",
- (data[0x3] << 8) + data[0x4],
- (data[0x1] << 8) + data[0x2]);
- result = addKeyword(EXTRACTOR_SIZE,
- val,
- result);
- data = &data[len];
- break;
- }
- case M_COM:
- case M_APP12:
- result = addKeyword(EXTRACTOR_COMMENT,
- process_COM(&data, end),
- result);
- break;
- default:
- skip_variable(&data, end);
- break;
- }
- }
- RETURN:
+RETURN:
return result;
}
-
Modified: Extractor/src/plugins/language/language-compiler.c
===================================================================
--- Extractor/src/plugins/language/language-compiler.c 2007-07-29 08:04:12 UTC
(rev 5367)
+++ Extractor/src/plugins/language/language-compiler.c 2007-07-29 08:35:49 UTC
(rev 5368)
@@ -21,67 +21,63 @@
#include "platform.h"
-int main(int argc,
- char ** argv) {
+int
+main (int argc, char **argv)
+{
int i;
int cnt;
- char * fn;
- char ** words;
- char line[2048]; /* buffer overflow, here we go */
+ char *fn;
+ char **words;
+ char line[2048]; /* buffer overflow, here we go */
FILE *dictin;
- char * bn;
+ char *bn;
#define ALLOCSIZE 1024*1024
- if (argc<2) {
- fprintf(stderr,
- _("Please provide a list of klp files as arguments.\n"));
- exit(-1);
- }
+ if (argc < 2)
+ {
+ fprintf (stderr,
+ _("Please provide a list of klp files as arguments.\n"));
+ exit (-1);
+ }
- fn = malloc(strlen(argv[1]) + 6);
- strcpy(fn, argv[1]);
- strcat(fn, ".txt");
- dictin=fopen(fn,"r");
- free(fn);
- if (dictin==NULL) {
- fprintf(stderr,
- _("Error opening file `%s': %s\n"),
- argv[1],strerror(errno));
- exit(-1);
- }
+ fn = malloc (strlen (argv[1]) + 6);
+ strcpy (fn, argv[1]);
+ strcat (fn, ".txt");
+ dictin = fopen (fn, "r");
+ free (fn);
+ if (dictin == NULL)
+ {
+ fprintf (stderr,
+ _("Error opening file `%s': %s\n"), argv[1], strerror (errno));
+ exit (-1);
+ }
- words = malloc(sizeof(char*) * ALLOCSIZE); /* don't we LOVE constant size
buffers? */
- if (words == NULL) {
- fprintf(stderr,
- _("Error allocating: %s\n."),
- strerror(errno));
- exit(-1);
- }
+ words = malloc (sizeof (char *) * ALLOCSIZE); /* don't we LOVE constant size
buffers? */
+ if (words == NULL)
+ {
+ fprintf (stderr, _("Error allocating: %s\n."), strerror (errno));
+ exit (-1);
+ }
cnt = 0;
- memset(&line[0], 0, 2048);
- while (1 == fscanf(dictin, "%s", (char*)&line)) {
- words[cnt] = strdup(line);
- cnt++;
- memset(&line[0], 0, 2048);
- if (cnt > ALLOCSIZE) {
- fprintf(stderr,
- _("Increase ALLOCSIZE (in %s).\n"),
- __FILE__);
- exit(-1);
+ memset (&line[0], 0, 2048);
+ while (1 == fscanf (dictin, "%s", (char *) &line))
+ {
+ words[cnt] = strdup (line);
+ cnt++;
+ memset (&line[0], 0, 2048);
+ if (cnt > ALLOCSIZE)
+ {
+ fprintf (stderr, _("Increase ALLOCSIZE (in %s).\n"), __FILE__);
+ exit (-1);
+ }
+
}
- }
-
- fprintf(stdout,
- "#include \"somefile.h\"\n");
- fprintf(stdout,
- "static int bits[] = { ");
- for (i=0;i<bf.bitArraySize/sizeof(int);i++)
- fprintf(stdout,
- "%dL,",
- (((int*)bf.bitArray)[i]));
- fprintf(stdout,
- "};\n");
+ fprintf (stdout, "#include \"somefile.h\"\n");
+ fprintf (stdout, "static int bits[] = { ");
+ for (i = 0; i < bf.bitArraySize / sizeof (int); i++)
+ fprintf (stdout, "%dL,", (((int *) bf.bitArray)[i]));
+ fprintf (stdout, "};\n");
return 0;
}
Modified: Extractor/src/plugins/language/languageextractor.c
===================================================================
--- Extractor/src/plugins/language/languageextractor.c 2007-07-29 08:04:12 UTC
(rev 5367)
+++ Extractor/src/plugins/language/languageextractor.c 2007-07-29 08:35:49 UTC
(rev 5368)
@@ -48,172 +48,185 @@
#include "platform.h"
#include "extractor.h"
-int NGramsList::compareItems( QCollection::Item item1, QCollection::Item item2
)
+int
+NGramsList::compareItems (QCollection::Item item1, QCollection::Item item2)
{
- NGram* n1 = (NGram*)item1;
- NGram* n2 = (NGram*)item2;
+ NGram *n1 = (NGram *) item1;
+ NGram *n2 = (NGram *) item2;
- return n2->occurrences - n1->occurrences;
+ return n2->occurrences - n1->occurrences;
}
-int LanguageList::compareItems( QCollection::Item item1, QCollection::Item
item2 )
+int
+LanguageList::compareItems (QCollection::Item item1, QCollection::Item item2)
{
- Language* n1 = (Language*)item1;
- Language* n2 = (Language*)item2;
+ Language *n1 = (Language *) item1;
+ Language *n2 = (Language *) item2;
- return n2->distance - n1->distance;
+ return n2->distance - n1->distance;
}
-static void extractNGrams(const char * str,
- QStringList& ngrams) {
- QString paddedString( str );
+static void
+extractNGrams (const char *str, QStringList & ngrams)
+{
+ QString paddedString (str);
- paddedString = paddedString.replace( QRegExp( " " ), "_" );
+ paddedString = paddedString.replace (QRegExp (" "), "_");
paddedString = '_' + paddedString + '_';
- for( int i = 0; i < paddedString.length() - size + 1; i++ )
- ngrams.append( paddedString.mid( i, size ) );
+ for (int i = 0; i < paddedString.length () - size + 1; i++)
+ ngrams.append (paddedString.mid (i, size));
}
-static NGramsList createFingerprintFromQString(const char * buf )
+static NGramsList
+createFingerprintFromQString (const char *buf)
{
- QStringList ngrams;
- NGramsList wngrams;
+ QStringList ngrams;
+ NGramsList wngrams;
- wngrams.setAutoDelete( true );
+ wngrams.setAutoDelete (true);
- QString buffer( buf );
- buffer.truncate( MAXDOCSIZE ); // only use the first MAXDOCSIZE characters
of the buffer
+ QString buffer (buf);
+ buffer.truncate (MAXDOCSIZE); // only use the first MAXDOCSIZE characters of
the buffer
- // extract the ngrams
- for ( int size = 1; size <= MAXNGRAMSIZE; ++size )
- extractNGrams( buffer, ngrams, size );
+ // extract the ngrams
+ for (int size = 1; size <= MAXNGRAMSIZE; ++size)
+ extractNGrams (buffer, ngrams, size);
- // sort the ngrams
- ngrams.sort();
+ // sort the ngrams
+ ngrams.sort ();
- // count the occurrences of every ngram
- // and build the NGramList wngrams
- long occurrences;
- QStringList::Iterator ngram = ngrams.begin();
- while ( ngram != ngrams.end() )
+ // count the occurrences of every ngram
+ // and build the NGramList wngrams
+ long occurrences;
+ QStringList::Iterator ngram = ngrams.begin ();
+ while (ngram != ngrams.end ())
{
- QString currentNGram = *ngram;
+ QString currentNGram = *ngram;
- ngram++;
+ ngram++;
- occurrences = 1;
- while ( *ngram == currentNGram )
+ occurrences = 1;
+ while (*ngram == currentNGram)
{
- occurrences++;
- ngram++;
+ occurrences++;
+ ngram++;
}
- wngrams.inSort( new NGram( currentNGram, occurrences ) );
+ wngrams.inSort (new NGram (currentNGram, occurrences));
}
- // the profile has to contain a maximum of MAXNGRAMS
- while ( wngrams.count() > MAXNGRAMS )
- wngrams.removeLast();
+ // the profile has to contain a maximum of MAXNGRAMS
+ while (wngrams.count () > MAXNGRAMS)
+ wngrams.removeLast ();
- return wngrams;
+ return wngrams;
}
-static const char * identifyLanguage(const QString& buffer,
- LanguageProfileMap lp )
+static const char *
+identifyLanguage (const QString & buffer, LanguageProfileMap lp)
{
- long distance;
- long minscore = MAXSCORE;
- long threshold = minscore;
- LanguageList language_list;
- language_list.setAutoDelete( true );
- LanguageList candidates;
- candidates.setAutoDelete( true );
+ long distance;
+ long minscore = MAXSCORE;
+ long threshold = minscore;
+ LanguageList language_list;
+ language_list.setAutoDelete (true);
+ LanguageList candidates;
+ candidates.setAutoDelete (true);
- // create the fingerprint of the buffer
- NGramsList file_ngrams = createFingerprintFromQString( buffer );
- if ( buffer.length() < MINDOCSIZE )
- return QString( "unknown" );
+ // create the fingerprint of the buffer
+ NGramsList file_ngrams = createFingerprintFromQString (buffer);
+ if (buffer.length () < MINDOCSIZE)
+ return QString ("unknown");
- // cycle through the list of managed languages
- // and build an ordered list of languages sorted by distance
- QMap<QString,LanguageProfile>::Iterator end( lp.end() );
- for ( QMap<QString,LanguageProfile>::Iterator it = lp.begin(); it != end;
++it )
+ // cycle through the list of managed languages
+ // and build an ordered list of languages sorted by distance
+ QMap < QString, LanguageProfile >::Iterator end (lp.end ());
+ for (QMap < QString, LanguageProfile >::Iterator it = lp.begin ();
+ it != end; ++it)
{
- QString lname = it.key();
- LanguageProfile language_ngrams = (LanguageProfile)it.data();
+ QString lname = it.key ();
+ LanguageProfile language_ngrams = (LanguageProfile) it.data ();
- // calculate the distance between the file profile and the language
profile
- distance = calculateDistance( file_ngrams, language_ngrams );
+ // calculate the distance between the file profile and the language
profile
+ distance = calculateDistance (file_ngrams, language_ngrams);
- // calculate the threshold
- if ( distance < minscore )
+ // calculate the threshold
+ if (distance < minscore)
{
- minscore = distance;
- threshold = (long)( (double)distance * THRESHOLDVALUE );
+ minscore = distance;
+ threshold = (long) ((double) distance * THRESHOLDVALUE);
}
- language_list.inSort( new Language( lname, distance ) );
+ language_list.inSort (new Language (lname, distance));
}
- // now that the list of languages is sorted by distance
- // extract at most MAXCANDIDATES candidates
- int cnt = 0;
- Language* currentLanguage;
- QPtrList<Language>::Iterator language = language_list.begin();
- while ( language != language_list.end() )
+ // now that the list of languages is sorted by distance
+ // extract at most MAXCANDIDATES candidates
+ int cnt = 0;
+ Language *currentLanguage;
+ QPtrList < Language >::Iterator language = language_list.begin ();
+ while (language != language_list.end ())
{
- currentLanguage = *language;
+ currentLanguage = *language;
- if ( currentLanguage->distance <= threshold )
+ if (currentLanguage->distance <= threshold)
{
- cnt++;
- if ( cnt == MAXCANDIDATES + 1 )
- break;
+ cnt++;
+ if (cnt == MAXCANDIDATES + 1)
+ break;
- candidates.inSort( new Language( currentLanguage->language,
currentLanguage->distance ) );
+ candidates.
+ inSort (new
+ Language (currentLanguage->language,
+ currentLanguage->distance));
}
- language++;
+ language++;
}
- // If more than MAXCANDIDATES matches are found within the threshold,
- // the classifier reports unknown, because the input is obviously confusing
- if ( cnt == MAXCANDIDATES + 1 ) {
- return QString( "unknown" );
- } else {
- Language* first = candidates.getFirst();
- if ( first != 0L )
- return QString( first->language );
- else
- return QString( "unknown" );
+ // If more than MAXCANDIDATES matches are found within the threshold,
+ // the classifier reports unknown, because the input is obviously confusing
+ if (cnt == MAXCANDIDATES + 1)
+ {
+ return QString ("unknown");
}
+ else
+ {
+ Language *first = candidates.getFirst ();
+ if (first != 0L)
+ return QString (first->language);
+ else
+ return QString ("unknown");
+ }
}
-static unsigned long long calculateDistance(NGramsList & file_ngrams,
- LanguageProfile & langNG) {
+static unsigned long long
+calculateDistance (NGramsList & file_ngrams, LanguageProfile & langNG)
+{
unsigned long long fileNGPos = 0L;
unsigned long long langNGPos = 0L;
unsigned long long distance = 0L;
- NGramsList::Iterator file_ngram = file_ngrams.begin();
- while ( file_ngram != file_ngrams.end() )
+ NGramsList::Iterator file_ngram = file_ngrams.begin ();
+ while (file_ngram != file_ngrams.end ())
{
- NGram* currentFileNGram = *file_ngram;
+ NGram *currentFileNGram = *file_ngram;
- QMap<QString, unsigned long long>::iterator ng = langNG.find(
currentFileNGram->ngram );
+ QMap < QString, unsigned long long >::iterator ng =
+ langNG.find (currentFileNGram->ngram);
- if ( ng == langNG.end() )
+ if (ng == langNG.end ())
{
- // not found
- distance = distance + MAXOUTOFPLACE;
+ // not found
+ distance = distance + MAXOUTOFPLACE;
}
else
{
- //found
- langNGPos = ng.data();
- distance = distance + labs( langNGPos - fileNGPos );
+ //found
+ langNGPos = ng.data ();
+ distance = distance + labs (langNGPos - fileNGPos);
}
fileNGPos++;
@@ -226,9 +239,9 @@
struct EXTRACTOR_Keywords *
-libextractor_language_extract(const char * filename,
- const char * buf,
- size_t size,
- struct EXTRACTOR_Keywords * prev) {
+libextractor_language_extract (const char *filename,
+ const char *buf,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
return prev;
}
Modified: Extractor/src/plugins/lowerextractor.c
===================================================================
--- Extractor/src/plugins/lowerextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/lowerextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -21,24 +21,25 @@
#include "platform.h"
#include "extractor.h"
-static void addKeyword(struct EXTRACTOR_Keywords ** list,
- const char * keyword,
- EXTRACTOR_KeywordType type) {
- EXTRACTOR_KeywordList * next;
- next = malloc(sizeof(EXTRACTOR_KeywordList));
+static void
+addKeyword (struct EXTRACTOR_Keywords **list,
+ const char *keyword, EXTRACTOR_KeywordType type)
+{
+ EXTRACTOR_KeywordList *next;
+ next = malloc (sizeof (EXTRACTOR_KeywordList));
next->next = *list;
- next->keyword = strdup(keyword);
+ next->keyword = strdup (keyword);
next->keywordType = type;
*list = next;
}
/* convert other keywords to lower case */
struct EXTRACTOR_Keywords *
-libextractor_lower_extract(char * filename,
- char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev) {
- struct EXTRACTOR_Keywords * pos;
+libextractor_lower_extract (char *filename,
+ char *data,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
+ struct EXTRACTOR_Keywords *pos;
char *lower;
unsigned int mem, needed, i;
@@ -47,32 +48,32 @@
mem = 0;
while (pos != NULL)
- {
- if (pos->keywordType == EXTRACTOR_FILE_SIZE) {
- pos = pos->next;
- continue;
- }
-
- needed = strlen(pos->keyword) + 1;
- if (needed > mem)
{
- lower = (lower == NULL) ? realloc(lower, needed) : malloc(needed);
- mem = needed;
- }
+ if (pos->keywordType == EXTRACTOR_FILE_SIZE)
+ {
+ pos = pos->next;
+ continue;
+ }
- for(i = 0; i < needed; i++)
- {
- lower[i] = tolower(pos->keyword[i]);
- }
+ needed = strlen (pos->keyword) + 1;
+ if (needed > mem)
+ {
+ lower = (lower == NULL) ? realloc (lower, needed) : malloc (needed);
+ mem = needed;
+ }
- if(strcmp(pos->keyword, lower))
- {
- addKeyword(&prev, lower, EXTRACTOR_LOWERCASE);
+ for (i = 0; i < needed; i++)
+ {
+ lower[i] = tolower (pos->keyword[i]);
+ }
+
+ if (strcmp (pos->keyword, lower))
+ {
+ addKeyword (&prev, lower, EXTRACTOR_LOWERCASE);
+ }
+ pos = pos->next;
}
- pos = pos->next;
- }
- free(lower);
+ free (lower);
return prev;
}
-
Modified: Extractor/src/plugins/manextractor.c
===================================================================
--- Extractor/src/plugins/manextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/manextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -22,60 +22,64 @@
#include "extractor.h"
#include <ctype.h>
-static char * stndup(const char * str,
- size_t n) {
- char * tmp;
- tmp = malloc(n+1);
+static char *
+stndup (const char *str, size_t n)
+{
+ char *tmp;
+ tmp = malloc (n + 1);
tmp[n] = '\0';
- memcpy(tmp, str, n);
+ memcpy (tmp, str, n);
return tmp;
}
-static EXTRACTOR_KeywordList * addKeyword(EXTRACTOR_KeywordType type,
- char * keyword,
- EXTRACTOR_KeywordList * next) {
- EXTRACTOR_KeywordList * result;
+static EXTRACTOR_KeywordList *
+addKeyword (EXTRACTOR_KeywordType type,
+ char *keyword, EXTRACTOR_KeywordList * next)
+{
+ EXTRACTOR_KeywordList *result;
if (keyword == NULL)
return next;
- if (strlen(keyword) == 0) {
- free(keyword);
- return next;
- }
- if ( (keyword[0] == '\"') && (keyword[strlen(keyword)-1] == '\"') ) {
- char * tmp;
+ if (strlen (keyword) == 0)
+ {
+ free (keyword);
+ return next;
+ }
+ if ((keyword[0] == '\"') && (keyword[strlen (keyword) - 1] == '\"'))
+ {
+ char *tmp;
- keyword[strlen(keyword)-1] = '\0';
- tmp = strdup(&keyword[1]);
- free(keyword);
- keyword = tmp;
- }
- if (strlen(keyword) == 0) {
- free(keyword);
- return next;
- }
- result = malloc(sizeof(EXTRACTOR_KeywordList));
+ keyword[strlen (keyword) - 1] = '\0';
+ tmp = strdup (&keyword[1]);
+ free (keyword);
+ keyword = tmp;
+ }
+ if (strlen (keyword) == 0)
+ {
+ free (keyword);
+ return next;
+ }
+ result = malloc (sizeof (EXTRACTOR_KeywordList));
result->next = next;
result->keyword = keyword;
result->keywordType = type;
return result;
}
-static void NEXT(size_t * end,
- const char * buf,
- const size_t size) {
+static void
+NEXT (size_t * end, const char *buf, const size_t size)
+{
int quot;
quot = 0;
- while ( (*end < size) &&
- ( ((quot & 1) != 0) ||
- ( (buf[*end] != ' ') ) ) ) {
- if (buf[*end] == '\"')
- quot++;
- (*end)++;
- }
+ while ((*end < size) && (((quot & 1) != 0) || ((buf[*end] != ' '))))
+ {
+ if (buf[*end] == '\"')
+ quot++;
+ (*end)++;
+ }
if ((quot & 1) == 1)
- (*end) = size+1;
+ (*end) = size + 1;
}
/**
@@ -87,135 +91,133 @@
struct EXTRACTOR_Keywords *
-libextractor_man_extract(const char * filename,
- const char * buf,
- size_t size,
- struct EXTRACTOR_Keywords * prev) {
+libextractor_man_extract (const char *filename,
+ const char *buf,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
int pos;
size_t xsize;
- const size_t xlen = strlen(".TH ");
+ const size_t xlen = strlen (".TH ");
if (size > MAX_READ)
size = MAX_READ;
pos = 0;
if (size < xlen)
return prev;
- while ( (pos < size - xlen) &&
- ( (0 != strncmp(".TH ",
- &buf[pos],
- xlen)) ||
- ( (pos != 0) &&
- (buf[pos-1] != '\n') ) ) ) {
- if ( !isgraph(buf[pos]) && !isspace(buf[pos]) )
- return prev;
- pos++;
- }
+ while ((pos < size - xlen) &&
+ ((0 != strncmp (".TH ",
+ &buf[pos],
+ xlen)) || ((pos != 0) && (buf[pos - 1] != '\n'))))
+ {
+ if (!isgraph (buf[pos]) && !isspace (buf[pos]))
+ return prev;
+ pos++;
+ }
xsize = pos;
- while ( (xsize < size) &&
- (buf[xsize] != '\n') )
+ while ((xsize < size) && (buf[xsize] != '\n'))
xsize++;
size = xsize;
- if (0 == strncmp(".TH ",
- &buf[pos],
- xlen)) {
- size_t end;
+ if (0 == strncmp (".TH ", &buf[pos], xlen))
+ {
+ size_t end;
- pos += xlen;
- end = pos;
- NEXT(&end, buf, size);
- if (end > size)
- return prev;
- if (end - pos > 0) {
- prev = addKeyword(EXTRACTOR_TITLE,
- stndup(&buf[pos],
- end - pos),
- prev);
- pos = end + 1;
+ pos += xlen;
+ end = pos;
+ NEXT (&end, buf, size);
+ if (end > size)
+ return prev;
+ if (end - pos > 0)
+ {
+ prev = addKeyword (EXTRACTOR_TITLE,
+ stndup (&buf[pos], end - pos), prev);
+ pos = end + 1;
+ }
+ if (pos >= size)
+ return prev;
+ end = pos;
+ NEXT (&end, buf, size);
+ if (end > size)
+ return prev;
+ if (buf[pos] == '\"')
+ pos++;
+ if ((end - pos >= 1) && (end - pos <= 4))
+ {
+ switch (buf[pos])
+ {
+ case '1':
+ prev = addKeyword (EXTRACTOR_CATEGORY,
+ strdup (_("Commands")), prev);
+ break;
+ case '2':
+ prev = addKeyword (EXTRACTOR_CATEGORY,
+ strdup (_("System calls")), prev);
+ break;
+ case '3':
+ prev = addKeyword (EXTRACTOR_CATEGORY,
+ strdup (_("Library calls")), prev);
+ break;
+ case '4':
+ prev = addKeyword (EXTRACTOR_CATEGORY,
+ strdup (_("Special files")), prev);
+ break;
+ case '5':
+ prev = addKeyword (EXTRACTOR_CATEGORY,
+ strdup (_("File formats and conventions")),
+ prev);
+ break;
+ case '6':
+ prev = addKeyword (EXTRACTOR_CATEGORY,
+ strdup (_("Games")), prev);
+ break;
+ case '7':
+ prev = addKeyword (EXTRACTOR_CATEGORY,
+ strdup (_("Conventions and miscellaneous")),
+ prev);
+ break;
+ case '8':
+ prev = addKeyword (EXTRACTOR_CATEGORY,
+ strdup (_("System management commands")),
+ prev);
+ break;
+ case '9':
+ prev = addKeyword (EXTRACTOR_CATEGORY,
+ strdup (_("Kernel routines")), prev);
+ break;
+ }
+ pos = end + 1;
+ }
+ end = pos;
+ NEXT (&end, buf, size);
+ if (end > size)
+ return prev;
+ if (end - pos > 0)
+ {
+ prev = addKeyword (EXTRACTOR_DATE,
+ stndup (&buf[pos], end - pos), prev);
+ pos = end + 1;
+ }
+ end = pos;
+ NEXT (&end, buf, size);
+ if (end > size)
+ return prev;
+ if (end - pos > 0)
+ {
+ prev = addKeyword (EXTRACTOR_SOURCE,
+ stndup (&buf[pos], end - pos), prev);
+ pos = end + 1;
+ }
+ end = pos;
+ NEXT (&end, buf, size);
+ if (end > size)
+ return prev;
+ if (end - pos > 0)
+ {
+ prev = addKeyword (EXTRACTOR_BOOKTITLE,
+ stndup (&buf[pos], end - pos), prev);
+ pos = end + 1;
+ }
}
- if (pos >= size) return prev;
- end = pos;
- NEXT(&end, buf, size); if (end > size) return prev;
- if (buf[pos] == '\"')
- pos++;
- if ( (end-pos >= 1) && (end - pos <= 4) ) {
- switch (buf[pos]) {
- case '1':
- prev = addKeyword(EXTRACTOR_CATEGORY,
- strdup(_("Commands")),
- prev);
- break;
- case '2':
- prev = addKeyword(EXTRACTOR_CATEGORY,
- strdup(_("System calls")),
- prev);
- break;
- case '3':
- prev = addKeyword(EXTRACTOR_CATEGORY,
- strdup(_("Library calls")),
- prev);
- break;
- case '4':
- prev = addKeyword(EXTRACTOR_CATEGORY,
- strdup(_("Special files")),
- prev);
- break;
- case '5':
- prev = addKeyword(EXTRACTOR_CATEGORY,
- strdup(_("File formats and conventions")),
- prev);
- break;
- case '6':
- prev = addKeyword(EXTRACTOR_CATEGORY,
- strdup(_("Games")),
- prev);
- break;
- case '7':
- prev = addKeyword(EXTRACTOR_CATEGORY,
- strdup(_("Conventions and miscellaneous")),
- prev);
- break;
- case '8':
- prev = addKeyword(EXTRACTOR_CATEGORY,
- strdup(_("System management commands")),
- prev);
- break;
- case '9':
- prev = addKeyword(EXTRACTOR_CATEGORY,
- strdup(_("Kernel routines")),
- prev);
- break;
- }
- pos = end + 1;
- }
- end = pos;
- NEXT(&end, buf, size); if (end > size) return prev;
- if (end - pos > 0) {
- prev = addKeyword(EXTRACTOR_DATE,
- stndup(&buf[pos],
- end - pos),
- prev);
- pos = end + 1;
- }
- end = pos;
- NEXT(&end, buf, size); if (end > size) return prev;
- if (end - pos > 0) {
- prev = addKeyword(EXTRACTOR_SOURCE,
- stndup(&buf[pos],
- end - pos),
- prev);
- pos = end + 1;
- }
- end = pos;
- NEXT(&end, buf, size); if (end > size) return prev;
- if (end - pos > 0) {
- prev = addKeyword(EXTRACTOR_BOOKTITLE,
- stndup(&buf[pos],
- end - pos),
- prev);
- pos = end + 1;
- }
- }
return prev;
}
Modified: Extractor/src/plugins/mimeextractor.c
===================================================================
--- Extractor/src/plugins/mimeextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/mimeextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -22,14 +22,15 @@
#include "extractor.h"
-static EXTRACTOR_KeywordList * addKeyword(EXTRACTOR_KeywordType type,
- char * keyword,
- EXTRACTOR_KeywordList * next) {
- EXTRACTOR_KeywordList * result;
+static EXTRACTOR_KeywordList *
+addKeyword (EXTRACTOR_KeywordType type,
+ char *keyword, EXTRACTOR_KeywordList * next)
+{
+ EXTRACTOR_KeywordList *result;
if (keyword == NULL)
return next;
- result = malloc(sizeof(EXTRACTOR_KeywordList));
+ result = malloc (sizeof (EXTRACTOR_KeywordList));
result->next = next;
result->keyword = keyword;
result->keywordType = type;
@@ -43,9 +44,7 @@
* @param arg closure...
* @return 0 if the file does not match, 1 if it does
**/
-typedef int (*Detector)(const char * data,
- size_t len,
- void * arg);
+typedef int (*Detector) (const char *data, size_t len, void *arg);
/**
* Detect a file-type.
@@ -53,9 +52,9 @@
* @param len the length of the file
* @return always 1
**/
-static int defaultDetector(const char * data,
- size_t len,
- void * arg) {
+static int
+defaultDetector (const char *data, size_t len, void *arg)
+{
return 1;
}
@@ -65,16 +64,17 @@
* @param len the length of the file
* @return always 0
**/
-static int disableDetector(const char * data,
- size_t len,
- void * arg) {
+static int
+disableDetector (const char *data, size_t len, void *arg)
+{
return 0;
}
-typedef struct ExtraPattern {
+typedef struct ExtraPattern
+{
int pos;
int len;
- char * pattern;
+ char *pattern;
} ExtraPattern;
/**
@@ -82,26 +82,26 @@
**/
static ExtraPattern xpatterns[] = {
#define AVI_XPATTERN 0
- { 8, 4, "AVI "},
- { 0, 0, NULL },
+ {8, 4, "AVI "},
+ {0, 0, NULL},
#define WAVE_XPATTERN 2
- { 8, 4, "WAVE"},
- { 0, 0, NULL },
+ {8, 4, "WAVE"},
+ {0, 0, NULL},
#define ACE_XPATTERN 4
- { 4, 10, "\x00\x00\x90**ACE**"},
- { 0, 0, NULL },
+ {4, 10, "\x00\x00\x90**ACE**"},
+ {0, 0, NULL},
#define TAR_XPATTERN 6
- { 257, 6, "ustar\x00"},
- { 0, 0, NULL },
+ {257, 6, "ustar\x00"},
+ {0, 0, NULL},
#define GTAR_XPATTERN 8
- { 257, 8, "ustar\040\040\0"},
- { 0, 0, NULL },
+ {257, 8, "ustar\040\040\0"},
+ {0, 0, NULL},
#define RMID_XPATTERN 10
- { 8, 4, "RMID"},
- { 0, 0, NULL },
+ {8, 4, "RMID"},
+ {0, 0, NULL},
#define ACON_XPATTERN 12
- { 8, 4, "ACON"},
- { 0, 0, NULL},
+ {8, 4, "ACON"},
+ {0, 0, NULL},
};
/**
@@ -110,63 +110,67 @@
* entries in the main table, so this "AND" (all match) semantics are
* the only reasonable answer.
**/
-static int xPatternMatcher(const char * data,
- size_t len,
- void * cls) {
- ExtraPattern * arg = cls;
+static int
+xPatternMatcher (const char *data, size_t len, void *cls)
+{
+ ExtraPattern *arg = cls;
- while (arg->pattern != NULL) {
- if (arg->pos + arg->len > len)
- return 0;
- if (0 != memcmp(&data[arg->pos],
- arg->pattern,
- arg->len))
- return 0;
- arg++;
- }
+ while (arg->pattern != NULL)
+ {
+ if (arg->pos + arg->len > len)
+ return 0;
+ if (0 != memcmp (&data[arg->pos], arg->pattern, arg->len))
+ return 0;
+ arg++;
+ }
return 1;
}
/**
* Detect SVG
*/
-static int svgMatcher(const char *data,
- size_t len,
- void * cls) {
- enum {XMLSTART, XMLCLOSE, SVGSTART} state;
+static int
+svgMatcher (const char *data, size_t len, void *cls)
+{
+ enum
+ { XMLSTART, XMLCLOSE, SVGSTART } state;
size_t i;
i = 0;
state = XMLSTART;
- while (i < len) {
- if (! isprint(data[i]))
- return 0;
- switch (state) {
- case XMLSTART:
- if (i + 6 >= len)
- return 0;
- else if (memcmp(data + i, "<?xml", 5) == 0 && isspace(*(data + i + 5)))
- state = XMLCLOSE;
- break;
- case XMLCLOSE:
- if (i + 2 >= len)
- return 0;
- else if (memcmp(data + i, "?>", 2) == 0)
- state = SVGSTART;
- break;
- case SVGSTART:
- if (i + 5 >= len)
- return 0;
- else if (memcmp(data + i, "<svg", 4) == 0 && isspace(*(data + i + 4)))
- return 1;
- break;
- default:
- /* do nothing */
- break;
+ while (i < len)
+ {
+ if (!isprint (data[i]))
+ return 0;
+ switch (state)
+ {
+ case XMLSTART:
+ if (i + 6 >= len)
+ return 0;
+ else if (memcmp (data + i, "<?xml", 5) == 0
+ && isspace (*(data + i + 5)))
+ state = XMLCLOSE;
+ break;
+ case XMLCLOSE:
+ if (i + 2 >= len)
+ return 0;
+ else if (memcmp (data + i, "?>", 2) == 0)
+ state = SVGSTART;
+ break;
+ case SVGSTART:
+ if (i + 5 >= len)
+ return 0;
+ else if (memcmp (data + i, "<svg", 4) == 0
+ && isspace (*(data + i + 4)))
+ return 1;
+ break;
+ default:
+ /* do nothing */
+ break;
+ }
+ i++;
}
- i++;
- }
return 0;
}
@@ -186,135 +190,134 @@
* Select an entry in xpatterns for matching
**/
#define XPATTERN(a) &xPatternMatcher, &xpatterns[(a)]
-
-typedef struct Pattern {
- char * pattern;
+
+typedef struct Pattern
+{
+ char *pattern;
int size;
- char * mimetype;
+ char *mimetype;
Detector detector;
- void * arg;
+ void *arg;
} Pattern;
static Pattern patterns[] = {
- { "\xFF\xD8", 2, "image/jpeg", DEFAULT},
- { "\211PNG\r\n\032\n", 8, "image/png", DEFAULT},
- { "/* XPM */", 9, "image/x-xpm", DEFAULT},
- { "GIF8", 4, "image/gif", DEFAULT},
- { "P1", 2, "image/x-portable-bitmap", DEFAULT},
- { "P2", 2, "image/x-portable-graymap", DEFAULT},
- { "P3", 2, "image/x-portable-pixmap", DEFAULT},
- { "P4", 2, "image/x-portable-bitmap", DEFAULT},
- { "P5", 2, "image/x-portable-graymap", DEFAULT},
- { "P6", 2, "image/x-portable-pixmap", DEFAULT},
- { "P7", 2, "image/x-portable-anymap", DEFAULT},
- { "BM", 2, "image/x-bmp", DEFAULT},
- { "\x89PNG", 4, "image/x-png", DEFAULT},
- { "id=ImageMagick", 14, "application/x-imagemagick-image", DEFAULT},
- { "hsi1", 4, "image/x-jpeg-proprietary", DEFAULT},
- { "\x2E\x52\x4d\x46", 4, "video/real", DEFAULT},
- { "\x2e\x72\x61\xfd", 4, "audio/real", DEFAULT},
- { "\177ELF", 4, "application/elf", DEFAULT},
+ {"\xFF\xD8", 2, "image/jpeg", DEFAULT},
+ {"\211PNG\r\n\032\n", 8, "image/png", DEFAULT},
+ {"/* XPM */", 9, "image/x-xpm", DEFAULT},
+ {"GIF8", 4, "image/gif", DEFAULT},
+ {"P1", 2, "image/x-portable-bitmap", DEFAULT},
+ {"P2", 2, "image/x-portable-graymap", DEFAULT},
+ {"P3", 2, "image/x-portable-pixmap", DEFAULT},
+ {"P4", 2, "image/x-portable-bitmap", DEFAULT},
+ {"P5", 2, "image/x-portable-graymap", DEFAULT},
+ {"P6", 2, "image/x-portable-pixmap", DEFAULT},
+ {"P7", 2, "image/x-portable-anymap", DEFAULT},
+ {"BM", 2, "image/x-bmp", DEFAULT},
+ {"\x89PNG", 4, "image/x-png", DEFAULT},
+ {"id=ImageMagick", 14, "application/x-imagemagick-image", DEFAULT},
+ {"hsi1", 4, "image/x-jpeg-proprietary", DEFAULT},
+ {"\x2E\x52\x4d\x46", 4, "video/real", DEFAULT},
+ {"\x2e\x72\x61\xfd", 4, "audio/real", DEFAULT},
+ {"\177ELF", 4, "application/elf", DEFAULT},
/* FIXME: correct MIME-type for an ELF!? */
- { "\xca\xfe\xba\xbe", 4, "application/java", DEFAULT},
+ {"\xca\xfe\xba\xbe", 4, "application/java", DEFAULT},
/* FIXME: correct MIME for a class-file? */
- { "gimp xcf", 8, "image/xcf", DEFAULT},
- { "IIN1", 4, "image/tiff", DEFAULT},
- { "MM\x00\x2a", 4, "image/tiff", DEFAULT}, /* big-endian */
- { "II\x2a\x00", 4, "image/tiff", DEFAULT}, /* little-endian */
- { "%PDF", 4, "application/pdf", DEFAULT},
- { "%!PS-Adobe-", 11, "application/postscript", DEFAULT},
- { "\004%!PS-Adobe-", 12, "application/postscript", DEFAULT },
- { "RIFF", 4, "video/x-msvideo", XPATTERN(AVI_XPATTERN)},
- { "RIFF", 4, "audio/x-wav", XPATTERN(WAVE_XPATTERN)},
- { "RIFX", 4, "video/x-msvideo", XPATTERN(AVI_XPATTERN)},
- { "RIFX", 4, "audio/x-wav", XPATTERN(WAVE_XPATTERN)},
- { "RIFF", 4, "audio/midi", XPATTERN(RMID_XPATTERN)},
- { "RIFX", 4, "audio/midi", XPATTERN(RMID_XPATTERN)},
- { "RIFF", 4, "image/x-animated-cursor", XPATTERN(ACON_XPATTERN)},
- { "RIFX", 4, "image/x-animated-cursor", XPATTERN(ACON_XPATTERN)},
- { "\211GND\r\n\032\n", 8, "application/gnunet-directory", DEFAULT},
- { "{\\rtf", 5, "application/rtf", DEFAULT},
- { "\xf7\x02", 2, "application/x-dvi", DEFAULT},
- { "\x1F\x8B\x08\x00", 4, "application/x-gzip", DEFAULT},
- { "BZh91AY&SY", 10, "application/bz2", DEFAULT},
- { "\xED\xAB\xEE\xDB", 4, "application/x-rpm", DEFAULT}, /* binary */
- { "!<arch>\ndebian", 14, "application/x-dpkg", DEFAULT}, /* .deb */
- { "PK\x03\x04", 4, "application/x-zip", DEFAULT},
- { "\xea\x60", 2, "application/x-arj", DEFAULT},
- { "\037\235", 2, "application/x-compress", DEFAULT},
- { "Rar!", 4, "application/x-rar", DEFAULT},
- { "", 0, "application/x-ace", XPATTERN(ACE_XPATTERN)},
- { "", 0, "application/x-tar", XPATTERN(TAR_XPATTERN)},
- { "", 0, "application/x-gtar", XPATTERN(GTAR_XPATTERN)},
- { "-lh0-", 5, "application/x-lha", DEFAULT},
- { "-lh1-", 5, "application/x-lha", DEFAULT},
- { "-lh2-", 5, "application/x-lha", DEFAULT},
- { "-lh3-", 5, "application/x-lha", DEFAULT},
- { "-lh4-", 5, "application/x-lha", DEFAULT},
- { "-lh5-", 5, "application/x-lha", DEFAULT},
- { "-lh6-", 5, "application/x-lha", DEFAULT},
- { "-lh7-", 5, "application/x-lha", DEFAULT},
- { "-lhd-", 5, "application/x-lha", DEFAULT},
- { "-lh\40-", 5, "application/x-lha", DEFAULT},
- { "-lz4-", 5, "application/x-lha", DEFAULT},
- { "-lz5-", 5, "application/x-lha", DEFAULT},
- { "-lzs-", 5, "application/x-lha", DEFAULT},
- { "\xFD\x76", 2, "application/x-lzh", DEFAULT},
- { "\x00\x00\x01\xb3", 4, "video/mpeg", DEFAULT},
- { "\x00\x00\x01\xba", 4, "video/mpeg", DEFAULT},
- { "moov", 4, "video/quicktime", DEFAULT},
- { "mdat", 4, "video/quicktime", DEFAULT},
- { "\x8aMNG", 4, "video/x-mng", DEFAULT},
- { "\x30\x26\xb2\x75\x8e\x66", 6, "video/asf", DEFAULT}, /* same as .wmv ? */
- { "FWS", 3, "application/x-shockwave-flash", DEFAULT},
- { "MThd", 4, "audio/midi", DEFAULT},
- { "ID3", 3, "audio/mpeg", DEFAULT},
- { "\xFF\xFA", 2, "audio/mpeg", DEFAULT},
- { "\xFF\xFB", 2, "audio/mpeg", DEFAULT},
- { "\xFF\xFC", 2, "audio/mpeg", DEFAULT},
- { "\xFF\xFD", 2, "audio/mpeg", DEFAULT},
- { "\xFF\xFE", 2, "audio/mpeg", DEFAULT},
- { "\xFF\xFF", 2, "audio/mpeg", DEFAULT},
- { "OggS", 4, "application/ogg", DEFAULT},
- { "#!/bin/sh", 9, "application/x-shellscript", DEFAULT},
- { "#!/bin/bash", 11, "application/x-shellscript", DEFAULT},
- { "#!/bin/csh", 10, "application/x-shellscript", DEFAULT},
- { "#!/bin/tcsh", 11, "application/x-shellscript", DEFAULT},
- { "#!/bin/perl", 11, "application/x-perl", DEFAULT},
- { "<?xml", 5, "image/svg+xml", svgMatcher, NULL},
+ {"gimp xcf", 8, "image/xcf", DEFAULT},
+ {"IIN1", 4, "image/tiff", DEFAULT},
+ {"MM\x00\x2a", 4, "image/tiff", DEFAULT}, /* big-endian */
+ {"II\x2a\x00", 4, "image/tiff", DEFAULT}, /* little-endian */
+ {"%PDF", 4, "application/pdf", DEFAULT},
+ {"%!PS-Adobe-", 11, "application/postscript", DEFAULT},
+ {"\004%!PS-Adobe-", 12, "application/postscript", DEFAULT},
+ {"RIFF", 4, "video/x-msvideo", XPATTERN (AVI_XPATTERN)},
+ {"RIFF", 4, "audio/x-wav", XPATTERN (WAVE_XPATTERN)},
+ {"RIFX", 4, "video/x-msvideo", XPATTERN (AVI_XPATTERN)},
+ {"RIFX", 4, "audio/x-wav", XPATTERN (WAVE_XPATTERN)},
+ {"RIFF", 4, "audio/midi", XPATTERN (RMID_XPATTERN)},
+ {"RIFX", 4, "audio/midi", XPATTERN (RMID_XPATTERN)},
+ {"RIFF", 4, "image/x-animated-cursor", XPATTERN (ACON_XPATTERN)},
+ {"RIFX", 4, "image/x-animated-cursor", XPATTERN (ACON_XPATTERN)},
+ {"\211GND\r\n\032\n", 8, "application/gnunet-directory", DEFAULT},
+ {"{\\rtf", 5, "application/rtf", DEFAULT},
+ {"\xf7\x02", 2, "application/x-dvi", DEFAULT},
+ {"\x1F\x8B\x08\x00", 4, "application/x-gzip", DEFAULT},
+ {"BZh91AY&SY", 10, "application/bz2", DEFAULT},
+ {"\xED\xAB\xEE\xDB", 4, "application/x-rpm", DEFAULT}, /* binary */
+ {"!<arch>\ndebian", 14, "application/x-dpkg", DEFAULT}, /* .deb */
+ {"PK\x03\x04", 4, "application/x-zip", DEFAULT},
+ {"\xea\x60", 2, "application/x-arj", DEFAULT},
+ {"\037\235", 2, "application/x-compress", DEFAULT},
+ {"Rar!", 4, "application/x-rar", DEFAULT},
+ {"", 0, "application/x-ace", XPATTERN (ACE_XPATTERN)},
+ {"", 0, "application/x-tar", XPATTERN (TAR_XPATTERN)},
+ {"", 0, "application/x-gtar", XPATTERN (GTAR_XPATTERN)},
+ {"-lh0-", 5, "application/x-lha", DEFAULT},
+ {"-lh1-", 5, "application/x-lha", DEFAULT},
+ {"-lh2-", 5, "application/x-lha", DEFAULT},
+ {"-lh3-", 5, "application/x-lha", DEFAULT},
+ {"-lh4-", 5, "application/x-lha", DEFAULT},
+ {"-lh5-", 5, "application/x-lha", DEFAULT},
+ {"-lh6-", 5, "application/x-lha", DEFAULT},
+ {"-lh7-", 5, "application/x-lha", DEFAULT},
+ {"-lhd-", 5, "application/x-lha", DEFAULT},
+ {"-lh\40-", 5, "application/x-lha", DEFAULT},
+ {"-lz4-", 5, "application/x-lha", DEFAULT},
+ {"-lz5-", 5, "application/x-lha", DEFAULT},
+ {"-lzs-", 5, "application/x-lha", DEFAULT},
+ {"\xFD\x76", 2, "application/x-lzh", DEFAULT},
+ {"\x00\x00\x01\xb3", 4, "video/mpeg", DEFAULT},
+ {"\x00\x00\x01\xba", 4, "video/mpeg", DEFAULT},
+ {"moov", 4, "video/quicktime", DEFAULT},
+ {"mdat", 4, "video/quicktime", DEFAULT},
+ {"\x8aMNG", 4, "video/x-mng", DEFAULT},
+ {"\x30\x26\xb2\x75\x8e\x66", 6, "video/asf", DEFAULT}, /* same as
.wmv ? */
+ {"FWS", 3, "application/x-shockwave-flash", DEFAULT},
+ {"MThd", 4, "audio/midi", DEFAULT},
+ {"ID3", 3, "audio/mpeg", DEFAULT},
+ {"\xFF\xFA", 2, "audio/mpeg", DEFAULT},
+ {"\xFF\xFB", 2, "audio/mpeg", DEFAULT},
+ {"\xFF\xFC", 2, "audio/mpeg", DEFAULT},
+ {"\xFF\xFD", 2, "audio/mpeg", DEFAULT},
+ {"\xFF\xFE", 2, "audio/mpeg", DEFAULT},
+ {"\xFF\xFF", 2, "audio/mpeg", DEFAULT},
+ {"OggS", 4, "application/ogg", DEFAULT},
+ {"#!/bin/sh", 9, "application/x-shellscript", DEFAULT},
+ {"#!/bin/bash", 11, "application/x-shellscript", DEFAULT},
+ {"#!/bin/csh", 10, "application/x-shellscript", DEFAULT},
+ {"#!/bin/tcsh", 11, "application/x-shellscript", DEFAULT},
+ {"#!/bin/perl", 11, "application/x-perl", DEFAULT},
+ {"<?xml", 5, "image/svg+xml", svgMatcher, NULL},
{NULL, 0, NULL, DISABLED},
};
struct EXTRACTOR_Keywords *
-libextractor_mime_extract(const char * filename,
- const char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev) {
+libextractor_mime_extract (const char *filename,
+ const char *data,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
int i;
- const char * mime;
+ const char *mime;
- mime = EXTRACTOR_extractLast(EXTRACTOR_MIMETYPE,
- prev);
+ mime = EXTRACTOR_extractLast (EXTRACTOR_MIMETYPE, prev);
if (mime != NULL)
- return prev; /* if the mime-type has already
- been determined, there is no need
- to probe again (and potentially be wrong...) */
- i=0;
- while (patterns[i].pattern != NULL) {
- if (size < patterns[i].size) {
+ return prev; /* if the mime-type has already
+ been determined, there is no need
+ to probe again (and potentially be
wrong...) */
+ i = 0;
+ while (patterns[i].pattern != NULL)
+ {
+ if (size < patterns[i].size)
+ {
+ i++;
+ continue;
+ }
+ if (0 == memcmp (patterns[i].pattern, data, patterns[i].size))
+ {
+ if (patterns[i].detector (data, size, patterns[i].arg))
+ return addKeyword (EXTRACTOR_MIMETYPE,
+ strdup (patterns[i].mimetype), prev);
+ }
i++;
- continue;
}
- if (0 == memcmp(patterns[i].pattern,
- data,
- patterns[i].size)) {
- if (patterns[i].detector(data, size, patterns[i].arg))
- return addKeyword(EXTRACTOR_MIMETYPE,
- strdup(patterns[i].mimetype),
- prev);
- }
- i++;
- }
return prev;
}
-
Modified: Extractor/src/plugins/mp3extractor.c
===================================================================
--- Extractor/src/plugins/mp3extractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/mp3extractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -36,164 +36,165 @@
#include <unistd.h>
#include <stdlib.h>
-typedef struct {
- char * title;
- char * artist;
- char * album;
- char * year;
- char * comment;
- const char * genre;
+typedef struct
+{
+ char *title;
+ char *artist;
+ char *album;
+ char *year;
+ char *comment;
+ const char *genre;
} id3tag;
static const char *const genre_names[] = {
- gettext_noop("Blues"),
- gettext_noop("Classic Rock"),
- gettext_noop("Country"),
- gettext_noop("Dance"),
- gettext_noop("Disco"),
- gettext_noop("Funk"),
- gettext_noop("Grunge"),
- gettext_noop("Hip-Hop"),
- gettext_noop("Jazz"),
- gettext_noop("Metal"),
- gettext_noop("New Age"),
- gettext_noop("Oldies"),
- gettext_noop("Other"),
- gettext_noop("Pop"),
- gettext_noop("R&B"),
- gettext_noop("Rap"),
- gettext_noop("Reggae"),
- gettext_noop("Rock"),
- gettext_noop("Techno"),
- gettext_noop("Industrial"),
- gettext_noop("Alternative"),
- gettext_noop("Ska"),
- gettext_noop("Death Metal"),
- gettext_noop("Pranks"),
- gettext_noop("Soundtrack"),
- gettext_noop("Euro-Techno"),
- gettext_noop("Ambient"),
- gettext_noop("Trip-Hop"),
- gettext_noop("Vocal"),
- gettext_noop("Jazz+Funk"),
- gettext_noop("Fusion"),
- gettext_noop("Trance"),
- gettext_noop("Classical"),
- gettext_noop("Instrumental"),
- gettext_noop("Acid"),
- gettext_noop("House"),
- gettext_noop("Game"),
- gettext_noop("Sound Clip"),
- gettext_noop("Gospel"),
- gettext_noop("Noise"),
- gettext_noop("Alt. Rock"),
- gettext_noop("Bass"),
- gettext_noop("Soul"),
- gettext_noop("Punk"),
- gettext_noop("Space"),
- gettext_noop("Meditative"),
- gettext_noop("Instrumental Pop"),
- gettext_noop("Instrumental Rock"),
- gettext_noop("Ethnic"),
- gettext_noop("Gothic"),
- gettext_noop("Darkwave"),
- gettext_noop("Techno-Industrial"),
- gettext_noop("Electronic"),
- gettext_noop("Pop-Folk"),
- gettext_noop("Eurodance"),
- gettext_noop("Dream"),
- gettext_noop("Southern Rock"),
- gettext_noop("Comedy"),
- gettext_noop("Cult"),
- gettext_noop("Gangsta Rap"),
- gettext_noop("Top 40"),
- gettext_noop("Christian Rap"),
- gettext_noop("Pop/Funk"),
- gettext_noop("Jungle"),
- gettext_noop("Native American"),
- gettext_noop("Cabaret"),
- gettext_noop("New Wave"),
- gettext_noop("Psychedelic"),
- gettext_noop("Rave"),
- gettext_noop("Showtunes"),
- gettext_noop("Trailer"),
- gettext_noop("Lo-Fi"),
- gettext_noop("Tribal"),
- gettext_noop("Acid Punk"),
- gettext_noop("Acid Jazz"),
- gettext_noop("Polka"),
- gettext_noop("Retro"),
- gettext_noop("Musical"),
- gettext_noop("Rock & Roll"),
- gettext_noop("Hard Rock"),
- gettext_noop("Folk"),
- gettext_noop("Folk/Rock"),
- gettext_noop("National Folk"),
- gettext_noop("Swing"),
- gettext_noop("Fast-Fusion"),
- gettext_noop("Bebob"),
- gettext_noop("Latin"),
- gettext_noop("Revival"),
- gettext_noop("Celtic"),
- gettext_noop("Bluegrass"),
- gettext_noop("Avantgarde"),
- gettext_noop("Gothic Rock"),
- gettext_noop("Progressive Rock"),
- gettext_noop("Psychedelic Rock"),
- gettext_noop("Symphonic Rock"),
- gettext_noop("Slow Rock"),
- gettext_noop("Big Band"),
- gettext_noop("Chorus"),
- gettext_noop("Easy Listening"),
- gettext_noop("Acoustic"),
- gettext_noop("Humour"),
- gettext_noop("Speech"),
- gettext_noop("Chanson"),
- gettext_noop("Opera"),
- gettext_noop("Chamber Music"),
- gettext_noop("Sonata"),
- gettext_noop("Symphony"),
- gettext_noop("Booty Bass"),
- gettext_noop("Primus"),
- gettext_noop("Porn Groove"),
- gettext_noop("Satire"),
- gettext_noop("Slow Jam"),
- gettext_noop("Club"),
- gettext_noop("Tango"),
- gettext_noop("Samba"),
- gettext_noop("Folklore"),
- gettext_noop("Ballad"),
- gettext_noop("Power Ballad"),
- gettext_noop("Rhythmic Soul"),
- gettext_noop("Freestyle"),
- gettext_noop("Duet"),
- gettext_noop("Punk Rock"),
- gettext_noop("Drum Solo"),
- gettext_noop("A Cappella"),
- gettext_noop("Euro-House"),
- gettext_noop("Dance Hall"),
- gettext_noop("Goa"),
- gettext_noop("Drum & Bass"),
- gettext_noop("Club-House"),
- gettext_noop("Hardcore"),
- gettext_noop("Terror"),
- gettext_noop("Indie"),
- gettext_noop("BritPop"),
- gettext_noop("Negerpunk"),
- gettext_noop("Polsk Punk"),
- gettext_noop("Beat"),
- gettext_noop("Christian Gangsta Rap"),
- gettext_noop("Heavy Metal"),
- gettext_noop("Black Metal"),
- gettext_noop("Crossover"),
- gettext_noop("Contemporary Christian"),
- gettext_noop("Christian Rock"),
- gettext_noop("Merengue"),
- gettext_noop("Salsa"),
- gettext_noop("Thrash Metal"),
- gettext_noop("Anime"),
- gettext_noop("JPop"),
- gettext_noop("Synthpop"),
+ gettext_noop ("Blues"),
+ gettext_noop ("Classic Rock"),
+ gettext_noop ("Country"),
+ gettext_noop ("Dance"),
+ gettext_noop ("Disco"),
+ gettext_noop ("Funk"),
+ gettext_noop ("Grunge"),
+ gettext_noop ("Hip-Hop"),
+ gettext_noop ("Jazz"),
+ gettext_noop ("Metal"),
+ gettext_noop ("New Age"),
+ gettext_noop ("Oldies"),
+ gettext_noop ("Other"),
+ gettext_noop ("Pop"),
+ gettext_noop ("R&B"),
+ gettext_noop ("Rap"),
+ gettext_noop ("Reggae"),
+ gettext_noop ("Rock"),
+ gettext_noop ("Techno"),
+ gettext_noop ("Industrial"),
+ gettext_noop ("Alternative"),
+ gettext_noop ("Ska"),
+ gettext_noop ("Death Metal"),
+ gettext_noop ("Pranks"),
+ gettext_noop ("Soundtrack"),
+ gettext_noop ("Euro-Techno"),
+ gettext_noop ("Ambient"),
+ gettext_noop ("Trip-Hop"),
+ gettext_noop ("Vocal"),
+ gettext_noop ("Jazz+Funk"),
+ gettext_noop ("Fusion"),
+ gettext_noop ("Trance"),
+ gettext_noop ("Classical"),
+ gettext_noop ("Instrumental"),
+ gettext_noop ("Acid"),
+ gettext_noop ("House"),
+ gettext_noop ("Game"),
+ gettext_noop ("Sound Clip"),
+ gettext_noop ("Gospel"),
+ gettext_noop ("Noise"),
+ gettext_noop ("Alt. Rock"),
+ gettext_noop ("Bass"),
+ gettext_noop ("Soul"),
+ gettext_noop ("Punk"),
+ gettext_noop ("Space"),
+ gettext_noop ("Meditative"),
+ gettext_noop ("Instrumental Pop"),
+ gettext_noop ("Instrumental Rock"),
+ gettext_noop ("Ethnic"),
+ gettext_noop ("Gothic"),
+ gettext_noop ("Darkwave"),
+ gettext_noop ("Techno-Industrial"),
+ gettext_noop ("Electronic"),
+ gettext_noop ("Pop-Folk"),
+ gettext_noop ("Eurodance"),
+ gettext_noop ("Dream"),
+ gettext_noop ("Southern Rock"),
+ gettext_noop ("Comedy"),
+ gettext_noop ("Cult"),
+ gettext_noop ("Gangsta Rap"),
+ gettext_noop ("Top 40"),
+ gettext_noop ("Christian Rap"),
+ gettext_noop ("Pop/Funk"),
+ gettext_noop ("Jungle"),
+ gettext_noop ("Native American"),
+ gettext_noop ("Cabaret"),
+ gettext_noop ("New Wave"),
+ gettext_noop ("Psychedelic"),
+ gettext_noop ("Rave"),
+ gettext_noop ("Showtunes"),
+ gettext_noop ("Trailer"),
+ gettext_noop ("Lo-Fi"),
+ gettext_noop ("Tribal"),
+ gettext_noop ("Acid Punk"),
+ gettext_noop ("Acid Jazz"),
+ gettext_noop ("Polka"),
+ gettext_noop ("Retro"),
+ gettext_noop ("Musical"),
+ gettext_noop ("Rock & Roll"),
+ gettext_noop ("Hard Rock"),
+ gettext_noop ("Folk"),
+ gettext_noop ("Folk/Rock"),
+ gettext_noop ("National Folk"),
+ gettext_noop ("Swing"),
+ gettext_noop ("Fast-Fusion"),
+ gettext_noop ("Bebob"),
+ gettext_noop ("Latin"),
+ gettext_noop ("Revival"),
+ gettext_noop ("Celtic"),
+ gettext_noop ("Bluegrass"),
+ gettext_noop ("Avantgarde"),
+ gettext_noop ("Gothic Rock"),
+ gettext_noop ("Progressive Rock"),
+ gettext_noop ("Psychedelic Rock"),
+ gettext_noop ("Symphonic Rock"),
+ gettext_noop ("Slow Rock"),
+ gettext_noop ("Big Band"),
+ gettext_noop ("Chorus"),
+ gettext_noop ("Easy Listening"),
+ gettext_noop ("Acoustic"),
+ gettext_noop ("Humour"),
+ gettext_noop ("Speech"),
+ gettext_noop ("Chanson"),
+ gettext_noop ("Opera"),
+ gettext_noop ("Chamber Music"),
+ gettext_noop ("Sonata"),
+ gettext_noop ("Symphony"),
+ gettext_noop ("Booty Bass"),
+ gettext_noop ("Primus"),
+ gettext_noop ("Porn Groove"),
+ gettext_noop ("Satire"),
+ gettext_noop ("Slow Jam"),
+ gettext_noop ("Club"),
+ gettext_noop ("Tango"),
+ gettext_noop ("Samba"),
+ gettext_noop ("Folklore"),
+ gettext_noop ("Ballad"),
+ gettext_noop ("Power Ballad"),
+ gettext_noop ("Rhythmic Soul"),
+ gettext_noop ("Freestyle"),
+ gettext_noop ("Duet"),
+ gettext_noop ("Punk Rock"),
+ gettext_noop ("Drum Solo"),
+ gettext_noop ("A Cappella"),
+ gettext_noop ("Euro-House"),
+ gettext_noop ("Dance Hall"),
+ gettext_noop ("Goa"),
+ gettext_noop ("Drum & Bass"),
+ gettext_noop ("Club-House"),
+ gettext_noop ("Hardcore"),
+ gettext_noop ("Terror"),
+ gettext_noop ("Indie"),
+ gettext_noop ("BritPop"),
+ gettext_noop ("Negerpunk"),
+ gettext_noop ("Polsk Punk"),
+ gettext_noop ("Beat"),
+ gettext_noop ("Christian Gangsta Rap"),
+ gettext_noop ("Heavy Metal"),
+ gettext_noop ("Black Metal"),
+ gettext_noop ("Crossover"),
+ gettext_noop ("Contemporary Christian"),
+ gettext_noop ("Christian Rock"),
+ gettext_noop ("Merengue"),
+ gettext_noop ("Salsa"),
+ gettext_noop ("Thrash Metal"),
+ gettext_noop ("Anime"),
+ gettext_noop ("JPop"),
+ gettext_noop ("Synthpop"),
};
#define GENRE_NAME_COUNT \
@@ -201,28 +202,30 @@
#define MAX_MP3_SCAN_DEEP 16768
-const int max_frames_scan=1024;
-enum{ MPEG_ERR=0,MPEG_V1=1,MPEG_V2=2,MPEG_V25=3};
+const int max_frames_scan = 1024;
+enum
+{ MPEG_ERR = 0, MPEG_V1 = 1, MPEG_V2 = 2, MPEG_V25 = 3 };
-enum{ LAYER_ERR=0,LAYER_1=1,LAYER_2=2,LAYER_3=3};
+enum
+{ LAYER_ERR = 0, LAYER_1 = 1, LAYER_2 = 2, LAYER_3 = 3 };
-const unsigned int sync_mask=0xE0FF;
-const unsigned int mpeg_ver_mask=0x1800;
-const unsigned int mpeg_layer_mask=0x600;
-const unsigned int bitrate_mask=0xF00000;
-const unsigned int freq_mask=0xC0000;
-const unsigned int ch_mask=0xC0000000;
-const unsigned int pad_mask=0x20000;
+const unsigned int sync_mask = 0xE0FF;
+const unsigned int mpeg_ver_mask = 0x1800;
+const unsigned int mpeg_layer_mask = 0x600;
+const unsigned int bitrate_mask = 0xF00000;
+const unsigned int freq_mask = 0xC0000;
+const unsigned int ch_mask = 0xC0000000;
+const unsigned int pad_mask = 0x20000;
-unsigned int bitrate_table[16][6]={
- {0,0,0,0,0,0},
+unsigned int bitrate_table[16][6] = {
+ {0, 0, 0, 0, 0, 0},
{32, 32, 32, 32, 32, 8},
{64, 48, 40, 64, 48, 16},
{96, 56, 48, 96, 56, 24},
- {128, 64 , 56 , 128, 64 , 32},
- {160, 80 , 64 , 160, 80 , 64},
- {192, 96 , 80 , 192, 96 , 80},
- {224, 112, 96 , 224, 112, 56},
+ {128, 64, 56, 128, 64, 32},
+ {160, 80, 64, 160, 80, 64},
+ {192, 96, 80, 192, 96, 80},
+ {224, 112, 96, 224, 112, 56},
{256, 128, 112, 256, 128, 64},
{288, 160, 128, 288, 160, 128},
{320, 192, 160, 320, 192, 160},
@@ -230,12 +233,12 @@
{384, 256, 224, 384, 256, 128},
{416, 320, 256, 416, 320, 256},
{448, 384, 320, 448, 384, 320},
- {-1,-1,-1,-1,-1,-1}
+ {-1, -1, -1, -1, -1, -1}
};
-int freq_table[4][3]={
- {44100,22050,11025},
- {48000,24000,12000},
- {32000,16000,8000}
+int freq_table[4][3] = {
+ {44100, 22050, 11025},
+ {48000, 24000, 12000},
+ {32000, 16000, 8000}
};
@@ -243,258 +246,238 @@
#define SYSERR 1
#define INVALID_ID3 2
-static void trim(char * k) {
- while ( (strlen(k) > 0) &&
- (isspace(k[strlen(k)-1])) )
- k[strlen(k)-1] = '\0';
+static void
+trim (char *k)
+{
+ while ((strlen (k) > 0) && (isspace (k[strlen (k) - 1])))
+ k[strlen (k) - 1] = '\0';
}
-static int get_id3(const char * data,
- size_t size,
- id3tag * id3) {
- const char * pos;
+static int
+get_id3 (const char *data, size_t size, id3tag * id3)
+{
+ const char *pos;
if (size < 128)
return INVALID_ID3;
pos = &data[size - 128];
- if (0 != strncmp("TAG",
- pos,
- 3))
+ if (0 != strncmp ("TAG", pos, 3))
return INVALID_ID3;
pos += 3;
- id3->title = convertToUtf8(pos,
- 30,
- "ISO-8859-1");
- trim(id3->title);
+ id3->title = convertToUtf8 (pos, 30, "ISO-8859-1");
+ trim (id3->title);
pos += 30;
- id3->artist = convertToUtf8(pos,
- 30,
- "ISO-8859-1");
- trim(id3->artist);
+ id3->artist = convertToUtf8 (pos, 30, "ISO-8859-1");
+ trim (id3->artist);
pos += 30;
- id3->album = convertToUtf8(pos,
- 30,
- "ISO-8859-1");
- trim(id3->album);
+ id3->album = convertToUtf8 (pos, 30, "ISO-8859-1");
+ trim (id3->album);
pos += 30;
- id3->year = convertToUtf8(pos,
- 4,
- "ISO-8859-1");
- trim(id3->year);
+ id3->year = convertToUtf8 (pos, 4, "ISO-8859-1");
+ trim (id3->year);
pos += 4;
- id3->comment = convertToUtf8(pos,
- 30,
- "ISO-8859-1");
- trim(id3->comment);
+ id3->comment = convertToUtf8 (pos, 30, "ISO-8859-1");
+ trim (id3->comment);
pos += 30;
id3->genre = "";
if (pos[0] < GENRE_NAME_COUNT)
- id3->genre = dgettext(PACKAGE,
- genre_names[(unsigned) pos[0]]);
+ id3->genre = dgettext (PACKAGE, genre_names[(unsigned) pos[0]]);
return OK;
}
static struct EXTRACTOR_Keywords *
-addkword(EXTRACTOR_KeywordList *oldhead,
- const char * phrase,
- EXTRACTOR_KeywordType type) {
- EXTRACTOR_KeywordList * keyword;
+addkword (EXTRACTOR_KeywordList * oldhead,
+ const char *phrase, EXTRACTOR_KeywordType type)
+{
+ EXTRACTOR_KeywordList *keyword;
- keyword = malloc(sizeof(EXTRACTOR_KeywordList));
- keyword->next = oldhead;
- keyword->keyword = strdup(phrase);
- keyword->keywordType = type;
- return keyword;
+ keyword = malloc (sizeof (EXTRACTOR_KeywordList));
+ keyword->next = oldhead;
+ keyword->keyword = strdup (phrase);
+ keyword->keywordType = type;
+ return keyword;
}
static struct EXTRACTOR_Keywords *
-mp3parse(const char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev) {
+mp3parse (const char *data, size_t size, struct EXTRACTOR_Keywords *prev)
+{
unsigned int header;
- int counter=0;
- char mpeg_ver=0;
- char layer_ver=0;
- int idx_num=0;
- int bitrate=0; /*used for each frame*/
- int avg_bps=0; /*average bitrate*/
- int vbr_flag=0;
- int length=0;
- int sample_rate=0;
- int ch=0;
+ int counter = 0;
+ char mpeg_ver = 0;
+ char layer_ver = 0;
+ int idx_num = 0;
+ int bitrate = 0; /*used for each frame */
+ int avg_bps = 0; /*average bitrate */
+ int vbr_flag = 0;
+ int length = 0;
+ int sample_rate = 0;
+ int ch = 0;
int frame_size;
- int frames=0;
+ int frames = 0;
size_t pos = 0;
- char * format;
+ char *format;
- do {
- /* seek for frame start */
- if (pos + sizeof(header) > size) {
+ do
+ {
+ /* seek for frame start */
+ if (pos + sizeof (header) > size)
+ {
+ return prev;
+ } /*unable to find header */
+ memcpy (&header, &data[pos], sizeof (header));
+ if ((header & sync_mask) == sync_mask)
+ break; /*found header sync */
+ pos++;
+ counter++; /*next try */
+ }
+ while (counter < MAX_MP3_SCAN_DEEP);
+ if (counter >= MAX_MP3_SCAN_DEEP)
+ {
return prev;
- }/*unable to find header*/
- memcpy(&header,
- &data[pos],
- sizeof(header));
- if ((header&sync_mask)==sync_mask)
- break;/*found header sync*/
- pos++;
- counter++; /*next try*/
- } while(counter<MAX_MP3_SCAN_DEEP);
- if (counter>=MAX_MP3_SCAN_DEEP) {
- return prev;
- };/*give up to find mp3 header*/
+ }; /*give up to find mp3 header */
- prev = addkword(prev,
- "audio/mpeg",
- EXTRACTOR_MIMETYPE);
+ prev = addkword (prev, "audio/mpeg", EXTRACTOR_MIMETYPE);
- do { /*ok, now we found a mp3 frame header*/
- frames++;
- switch (header & mpeg_ver_mask){
- case 0x1000:
- mpeg_ver = MPEG_ERR; /*error*/
- break;
- case 0x800:
- prev = addkword(prev,
- "MPEG V2",
- EXTRACTOR_RESOURCE_TYPE);
- mpeg_ver = MPEG_V2;
- break;
- case 0x1800:
- prev = addkword(prev,
- "MPEG V1",
- EXTRACTOR_RESOURCE_TYPE);
- mpeg_ver = MPEG_V1;
- break;
- case 0:
- prev = addkword(prev,
- "MPEG V25",
- EXTRACTOR_RESOURCE_TYPE);
- mpeg_ver = MPEG_V25;
- break;
+ do
+ { /*ok, now we found a mp3 frame header */
+ frames++;
+ switch (header & mpeg_ver_mask)
+ {
+ case 0x1000:
+ mpeg_ver = MPEG_ERR; /*error */
+ break;
+ case 0x800:
+ prev = addkword (prev, "MPEG V2", EXTRACTOR_RESOURCE_TYPE);
+ mpeg_ver = MPEG_V2;
+ break;
+ case 0x1800:
+ prev = addkword (prev, "MPEG V1", EXTRACTOR_RESOURCE_TYPE);
+ mpeg_ver = MPEG_V1;
+ break;
+ case 0:
+ prev = addkword (prev, "MPEG V25", EXTRACTOR_RESOURCE_TYPE);
+ mpeg_ver = MPEG_V25;
+ break;
+ }
+ switch (header & mpeg_layer_mask)
+ {
+ case 0x400:
+ layer_ver = LAYER_2;
+ break;
+ case 0x200:
+ layer_ver = LAYER_3;
+ break;
+ case 0x600:
+ layer_ver = LAYER_1;
+ break;
+ case 0:
+ layer_ver = LAYER_ERR; /*error */
+ }
+ if (!layer_ver || !mpeg_ver)
+ return prev; /*unknown mpeg type */
+ if (mpeg_ver < 3)
+ idx_num = (mpeg_ver - 1) * 3 + layer_ver - 1;
+ else
+ idx_num = 2 + layer_ver;
+ bitrate = 1000 * bitrate_table[(header & bitrate_mask) >> 20][idx_num];
+ if (bitrate < 0)
+ {
+ frames--;
+ break;
+ } /*error in header */
+ sample_rate = freq_table[(header & freq_mask) >> 18][mpeg_ver - 1];
+ if (sample_rate < 0)
+ {
+ frames--;
+ break;
+ } /*error in header */
+ if ((header & ch_mask) == ch_mask)
+ ch = 1;
+ else
+ ch = 2; /*stereo non stereo select */
+ frame_size =
+ 144 * bitrate / (sample_rate ? sample_rate : 1) +
+ ((header & pad_mask) >> 17);
+ avg_bps += bitrate / 1000;
+
+ pos += frame_size - 4;
+ if (frames > max_frames_scan)
+ break; /*optimization */
+ if (avg_bps / frames != bitrate / 1000)
+ vbr_flag = 1;
+ if (pos + sizeof (header) > size)
+ break; /* EOF */
+ memcpy (&header, &data[pos], sizeof (header));
}
- switch(header&mpeg_layer_mask){
- case 0x400:
- layer_ver=LAYER_2;
- break;
- case 0x200:
- layer_ver=LAYER_3;
- break;
- case 0x600:
- layer_ver=LAYER_1;
- break;
- case 0:
- layer_ver=LAYER_ERR;/*error*/
- }
- if (!layer_ver||!mpeg_ver)
- return prev; /*unknown mpeg type*/
- if (mpeg_ver<3)
- idx_num=(mpeg_ver-1)*3+layer_ver-1;
- else
- idx_num=2+layer_ver;
- bitrate = 1000*bitrate_table[(header&bitrate_mask)>>20][idx_num];
- if (bitrate<0) {
- frames--;
- break;
- } /*error in header*/
- sample_rate = freq_table[(header&freq_mask)>>18][mpeg_ver-1];
- if (sample_rate<0) {
- frames--;
- break;
- } /*error in header*/
- if ((header&ch_mask)==ch_mask)
- ch=1;
- else
- ch=2; /*stereo non stereo select*/
- frame_size =
144*bitrate/(sample_rate?sample_rate:1)+((header&pad_mask)>>17);
- avg_bps += bitrate/1000;
+ while ((header & sync_mask) == sync_mask);
- pos += frame_size-4;
- if (frames > max_frames_scan)
- break; /*optimization*/
- if (avg_bps/frames!=bitrate/1000)
- vbr_flag=1;
- if (pos + sizeof(header) > size)
- break; /* EOF */
- memcpy(&header,
- &data[pos],
- sizeof(header));
- } while ((header&sync_mask)==sync_mask);
-
if (!frames)
- return prev; /*no valid frames*/
- avg_bps = avg_bps/frames;
- if (max_frames_scan){ /*if not all frames scaned*/
- length=size/(avg_bps?avg_bps:bitrate?bitrate:0xFFFFFFFF)/125;
- } else{
- length=1152*frames/(sample_rate?sample_rate:0xFFFFFFFF);
- }
+ return prev; /*no valid frames */
+ avg_bps = avg_bps / frames;
+ if (max_frames_scan)
+ { /*if not all frames scaned */
+ length =
+ size / (avg_bps ? avg_bps : bitrate ? bitrate : 0xFFFFFFFF) / 125;
+ }
+ else
+ {
+ length = 1152 * frames / (sample_rate ? sample_rate : 0xFFFFFFFF);
+ }
- format = malloc(512);
- snprintf(format,
- 512,
- "%d kbps, %d hz, %dm%02d %s %s",
- avg_bps,
- sample_rate,
- length/60, length % 60, /* minutes / seconds */
- ch == 2 ? _("stereo") : _("mono"),
- vbr_flag ? _("(variable bps)"):"");
- prev = addkword(prev,
- format,
- EXTRACTOR_FORMAT);
- free(format);
+ format = malloc (512);
+ snprintf (format, 512, "%d kbps, %d hz, %dm%02d %s %s", avg_bps,
sample_rate, length / 60, length % 60, /* minutes / seconds */
+ ch == 2 ? _("stereo") : _("mono"),
+ vbr_flag ? _("(variable bps)") : "");
+ prev = addkword (prev, format, EXTRACTOR_FORMAT);
+ free (format);
return prev;
}
/* mimetype = audio/mpeg */
struct EXTRACTOR_Keywords *
-libextractor_mp3_extract(const char * filename,
- const char * data,
- size_t size,
- struct EXTRACTOR_Keywords * klist) {
+libextractor_mp3_extract (const char *filename,
+ const char *data,
+ size_t size, struct EXTRACTOR_Keywords *klist)
+{
id3tag info;
- char * word;
+ char *word;
- if (0 != get_id3(data, size, &info))
+ if (0 != get_id3 (data, size, &info))
return klist;
- if (strlen(info.title) > 0)
- klist = addkword(klist, info.title, EXTRACTOR_TITLE);
- if (strlen(info.artist) > 0)
- klist = addkword(klist, info.artist, EXTRACTOR_ARTIST);
- if (strlen(info.album) > 0)
- klist = addkword(klist, info.album, EXTRACTOR_ALBUM);
- if (strlen(info.year) > 0)
- klist = addkword(klist, info.year, EXTRACTOR_YEAR);
- if (strlen(info.genre) > 0)
- klist = addkword(klist, info.genre, EXTRACTOR_GENRE);
- if (strlen(info.comment) > 0)
- klist = addkword(klist, info.comment, EXTRACTOR_COMMENT);
+ if (strlen (info.title) > 0)
+ klist = addkword (klist, info.title, EXTRACTOR_TITLE);
+ if (strlen (info.artist) > 0)
+ klist = addkword (klist, info.artist, EXTRACTOR_ARTIST);
+ if (strlen (info.album) > 0)
+ klist = addkword (klist, info.album, EXTRACTOR_ALBUM);
+ if (strlen (info.year) > 0)
+ klist = addkword (klist, info.year, EXTRACTOR_YEAR);
+ if (strlen (info.genre) > 0)
+ klist = addkword (klist, info.genre, EXTRACTOR_GENRE);
+ if (strlen (info.comment) > 0)
+ klist = addkword (klist, info.comment, EXTRACTOR_COMMENT);
/* A keyword that has all of the information together) */
- word = (char*) malloc(strlen(info.artist) + strlen(info.title) +
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);
- free(info.album);
- free(info.artist);
- free(info.comment);
+ word =
+ (char *) malloc (strlen (info.artist) + strlen (info.title) +
+ 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);
+ free (info.album);
+ free (info.artist);
+ free (info.comment);
- return mp3parse(data,
- size,
- klist);
+ return mp3parse (data, size, klist);
}
/* end of mp3extractor.c */
Modified: Extractor/src/plugins/mpegextractor.c
===================================================================
--- Extractor/src/plugins/mpegextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/mpegextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -23,96 +23,96 @@
#include "extractor.h"
#include <mpeg2dec/mpeg2.h>
-static void addKeyword(struct EXTRACTOR_Keywords ** list,
- char * keyword,
- EXTRACTOR_KeywordType type) {
- EXTRACTOR_KeywordList * next;
- next = malloc(sizeof(EXTRACTOR_KeywordList));
+static void
+addKeyword (struct EXTRACTOR_Keywords **list,
+ char *keyword, EXTRACTOR_KeywordType type)
+{
+ EXTRACTOR_KeywordList *next;
+ next = malloc (sizeof (EXTRACTOR_KeywordList));
next->next = *list;
- next->keyword = strdup(keyword);
+ next->keyword = strdup (keyword);
next->keywordType = type;
*list = next;
}
/* video/mpeg */
struct EXTRACTOR_Keywords *
-libextractor_mpeg_extract(const char * filename,
- const unsigned char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev) {
- mpeg2dec_t * handle;
- uint8_t * start;
- uint8_t * end;
- const mpeg2_info_t * info;
+libextractor_mpeg_extract (const char *filename,
+ const unsigned char *data,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
+ mpeg2dec_t *handle;
+ uint8_t *start;
+ uint8_t *end;
+ const mpeg2_info_t *info;
mpeg2_state_t state;
char format[256];
- if ( ( size < 4) ||
- ( ! ( (data[0]==0x00) &&
- (data[1]==0x00) &&
- (data[2]==0x01) &&
- ( (data[3]==0xB3) || (data[3]==0xBA) ) ) ) )
+ if ((size < 4) ||
+ (!((data[0] == 0x00) &&
+ (data[1] == 0x00) &&
+ (data[2] == 0x01) && ((data[3] == 0xB3) || (data[3] == 0xBA)))))
return prev;
- handle = mpeg2_init();
+ handle = mpeg2_init ();
if (handle == NULL)
return prev;
start = (uint8_t *) data;
- end = (uint8_t *) &data[size];
- mpeg2_buffer(handle, start, end);
- state = mpeg2_parse(handle);
- if (state != STATE_SEQUENCE) {
- mpeg2_close(handle);
- return prev;
- }
- info = mpeg2_info(handle);
- if (info == NULL) {
- mpeg2_close(handle);
- return prev;
- }
- addKeyword(&prev,
- "video/mpeg",
- EXTRACTOR_MIMETYPE);
- if (info->sequence != NULL) {
- snprintf(format, 256, "%ux%u",
- info->sequence->width,
- info->sequence->height);
- addKeyword(&prev, format, EXTRACTOR_SIZE);
- switch (info->sequence->flags & SEQ_VIDEO_FORMAT_UNSPECIFIED) {
- case SEQ_VIDEO_FORMAT_PAL:
- addKeyword(&prev, "PAL", EXTRACTOR_FORMAT);
- break;
- case SEQ_VIDEO_FORMAT_NTSC:
- addKeyword(&prev, "NTSC", EXTRACTOR_FORMAT);
- break;
- case SEQ_VIDEO_FORMAT_SECAM:
- addKeyword(&prev, "SECAM", EXTRACTOR_FORMAT);
- break;
- case SEQ_VIDEO_FORMAT_MAC:
- addKeyword(&prev, "MAC", EXTRACTOR_FORMAT);
- break;
- default:
- break;
+ end = (uint8_t *) & data[size];
+ mpeg2_buffer (handle, start, end);
+ state = mpeg2_parse (handle);
+ if (state != STATE_SEQUENCE)
+ {
+ mpeg2_close (handle);
+ return prev;
}
- if ((info->sequence->flags & SEQ_FLAG_MPEG2) > 0)
- addKeyword(&prev, "MPEG2", EXTRACTOR_RESOURCE_TYPE);
- else
- addKeyword(&prev, "MPEG1", EXTRACTOR_RESOURCE_TYPE);
- }
- if (info->gop != NULL) {
- /* this usually does not work yet, since gop's are not
- often at the beginning of the stream (and we
- don't iterate over the stream hoping to find one).
- Hence we usually don't get the size. Not sure how
- to *efficiently* get the gop (without scanning
- through the entire file) */
- snprintf(format, 256, "%u:%u:%u (%u frames)",
- info->gop->hours,
- info->gop->minutes,
- info->gop->seconds,
- info->gop->pictures);
- addKeyword(&prev, format, EXTRACTOR_DURATION);
- }
- mpeg2_close(handle);
+ info = mpeg2_info (handle);
+ if (info == NULL)
+ {
+ mpeg2_close (handle);
+ return prev;
+ }
+ addKeyword (&prev, "video/mpeg", EXTRACTOR_MIMETYPE);
+ if (info->sequence != NULL)
+ {
+ snprintf (format, 256, "%ux%u",
+ info->sequence->width, info->sequence->height);
+ addKeyword (&prev, format, EXTRACTOR_SIZE);
+ switch (info->sequence->flags & SEQ_VIDEO_FORMAT_UNSPECIFIED)
+ {
+ case SEQ_VIDEO_FORMAT_PAL:
+ addKeyword (&prev, "PAL", EXTRACTOR_FORMAT);
+ break;
+ case SEQ_VIDEO_FORMAT_NTSC:
+ addKeyword (&prev, "NTSC", EXTRACTOR_FORMAT);
+ break;
+ case SEQ_VIDEO_FORMAT_SECAM:
+ addKeyword (&prev, "SECAM", EXTRACTOR_FORMAT);
+ break;
+ case SEQ_VIDEO_FORMAT_MAC:
+ addKeyword (&prev, "MAC", EXTRACTOR_FORMAT);
+ break;
+ default:
+ break;
+ }
+ if ((info->sequence->flags & SEQ_FLAG_MPEG2) > 0)
+ addKeyword (&prev, "MPEG2", EXTRACTOR_RESOURCE_TYPE);
+ else
+ addKeyword (&prev, "MPEG1", EXTRACTOR_RESOURCE_TYPE);
+ }
+ if (info->gop != NULL)
+ {
+ /* this usually does not work yet, since gop's are not
+ often at the beginning of the stream (and we
+ don't iterate over the stream hoping to find one).
+ Hence we usually don't get the size. Not sure how
+ to *efficiently* get the gop (without scanning
+ through the entire file) */
+ snprintf (format, 256, "%u:%u:%u (%u frames)",
+ info->gop->hours,
+ info->gop->minutes, info->gop->seconds, info->gop->pictures);
+ addKeyword (&prev, format, EXTRACTOR_DURATION);
+ }
+ mpeg2_close (handle);
return prev;
}
Modified: Extractor/src/plugins/nsfeextractor.c
===================================================================
--- Extractor/src/plugins/nsfeextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/nsfeextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -43,231 +43,218 @@
struct header
{
- char magicid[ 4 ];
+ char magicid[4];
};
struct infochunk
{
- UINT16 loadaddr;
- UINT16 initaddr;
- UINT16 playaddr;
- char tvflags;
- char chipflags;
- char songs;
- char firstsong;
+ UINT16 loadaddr;
+ UINT16 initaddr;
+ UINT16 playaddr;
+ char tvflags;
+ char chipflags;
+ char songs;
+ char firstsong;
};
-static int nsfeuint(const char * data )
+static int
+nsfeuint (const char *data)
{
- int i, value = 0;
+ int i, value = 0;
- for( i = 3; i > 0 ; i-- )
- {
- value += ( unsigned char ) data[ i ];
- value *= 0x100;
- }
+ for (i = 3; i > 0; i--)
+ {
+ value += (unsigned char) data[i];
+ value *= 0x100;
+ }
- value += ( unsigned char ) data[ 0 ];
+ value += (unsigned char) data[0];
- return( value );
+ return (value);
}
-static char * nsfestring(const char * data, int size )
+static char *
+nsfestring (const char *data, int size)
{
- char *s;
- int length;
+ char *s;
+ int length;
- if( size < strlen( data ) )
- {
- length = size;
- }
- else
- {
- length = strlen( data );
- }
+ if (size < strlen (data))
+ {
+ length = size;
+ }
+ else
+ {
+ length = strlen (data);
+ }
- s = malloc( length + 1 );
+ s = malloc (length + 1);
- strncpy( s, data, length );
+ strncpy (s, data, length);
- s[ strlen( data ) ] = '\0';
+ s[strlen (data)] = '\0';
- return( s );
+ return (s);
}
-static struct EXTRACTOR_Keywords * addkword
-(
- EXTRACTOR_KeywordList *oldhead,
- const char * phrase,
- EXTRACTOR_KeywordType type
-)
+static struct EXTRACTOR_Keywords *addkword
+ (EXTRACTOR_KeywordList * oldhead,
+ const char *phrase, EXTRACTOR_KeywordType type)
{
- EXTRACTOR_KeywordList * keyword;
+ EXTRACTOR_KeywordList *keyword;
- keyword = malloc( sizeof( EXTRACTOR_KeywordList ) );
- keyword->next = oldhead;
- keyword->keyword = strdup( phrase );
- keyword->keywordType = type;
- return( keyword );
+ keyword = malloc (sizeof (EXTRACTOR_KeywordList));
+ keyword->next = oldhead;
+ keyword->keyword = strdup (phrase);
+ keyword->keywordType = type;
+ return (keyword);
}
-static struct EXTRACTOR_Keywords * libextractor_nsfe_info_extract
-(
- const char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev
-)
+static struct EXTRACTOR_Keywords *libextractor_nsfe_info_extract
+ (const char *data, size_t size, struct EXTRACTOR_Keywords *prev)
{
- const struct infochunk *ichunk;
- char songs[ 32 ];
+ const struct infochunk *ichunk;
+ char songs[32];
- ichunk = (const struct infochunk * ) data;
+ ichunk = (const struct infochunk *) data;
- if( size < 8 )
- {
- return( prev );
- }
+ if (size < 8)
+ {
+ return (prev);
+ }
- /* PAL or NTSC */
+ /* PAL or NTSC */
- if( ichunk->tvflags & DUAL_FLAG )
- {
- prev = addkword( prev, "PAL/NTSC", EXTRACTOR_TELEVISION_SYSTEM
);
- }
- else
- {
- if( ichunk->tvflags & PAL_FLAG )
- {
- prev = addkword( prev, "PAL",
EXTRACTOR_TELEVISION_SYSTEM );
- }
- else
- {
- prev = addkword( prev, "NTSC",
EXTRACTOR_TELEVISION_SYSTEM );
- }
- }
+ if (ichunk->tvflags & DUAL_FLAG)
+ {
+ prev = addkword (prev, "PAL/NTSC", EXTRACTOR_TELEVISION_SYSTEM);
+ }
+ else
+ {
+ if (ichunk->tvflags & PAL_FLAG)
+ {
+ prev = addkword (prev, "PAL", EXTRACTOR_TELEVISION_SYSTEM);
+ }
+ else
+ {
+ prev = addkword (prev, "NTSC", EXTRACTOR_TELEVISION_SYSTEM);
+ }
+ }
- /* Detect Extra Sound Chips needed to play the files */
+ /* Detect Extra Sound Chips needed to play the files */
- if( ichunk->chipflags & VRCVI_FLAG )
- {
- prev = addkword( prev, "VRCVI", EXTRACTOR_HARDWARE_DEPENDENCY );
- }
- if( ichunk->chipflags & VRCVII_FLAG )
- {
- prev = addkword( prev, "VRCVII", EXTRACTOR_HARDWARE_DEPENDENCY
);
- }
- if( ichunk->chipflags & FDS_FLAG )
- {
- prev = addkword( prev, "FDS Sound",
EXTRACTOR_HARDWARE_DEPENDENCY );
- }
- if( ichunk->chipflags & MMC5_FLAG )
- {
- prev = addkword( prev, "MMC5 audio",
EXTRACTOR_HARDWARE_DEPENDENCY );
- }
- if( ichunk->chipflags & NAMCO_FLAG )
- {
- prev = addkword( prev, "Namco 106",
EXTRACTOR_HARDWARE_DEPENDENCY );
- }
- if( ichunk->chipflags & SUNSOFT_FLAG )
- {
- prev = addkword( prev, "Sunsoft FME-07",
EXTRACTOR_HARDWARE_DEPENDENCY );
- }
+ if (ichunk->chipflags & VRCVI_FLAG)
+ {
+ prev = addkword (prev, "VRCVI", EXTRACTOR_HARDWARE_DEPENDENCY);
+ }
+ if (ichunk->chipflags & VRCVII_FLAG)
+ {
+ prev = addkword (prev, "VRCVII", EXTRACTOR_HARDWARE_DEPENDENCY);
+ }
+ if (ichunk->chipflags & FDS_FLAG)
+ {
+ prev = addkword (prev, "FDS Sound", EXTRACTOR_HARDWARE_DEPENDENCY);
+ }
+ if (ichunk->chipflags & MMC5_FLAG)
+ {
+ prev = addkword (prev, "MMC5 audio", EXTRACTOR_HARDWARE_DEPENDENCY);
+ }
+ if (ichunk->chipflags & NAMCO_FLAG)
+ {
+ prev = addkword (prev, "Namco 106", EXTRACTOR_HARDWARE_DEPENDENCY);
+ }
+ if (ichunk->chipflags & SUNSOFT_FLAG)
+ {
+ prev = addkword (prev, "Sunsoft FME-07", EXTRACTOR_HARDWARE_DEPENDENCY);
+ }
- if( size < 9 )
- {
- prev = addkword( prev, "1", EXTRACTOR_SONG_COUNT );
- return( prev );
- }
+ if (size < 9)
+ {
+ prev = addkword (prev, "1", EXTRACTOR_SONG_COUNT);
+ return (prev);
+ }
- sprintf( songs, "%d", ichunk->songs );
- prev = addkword( prev, songs, EXTRACTOR_SONG_COUNT );
+ sprintf (songs, "%d", ichunk->songs);
+ prev = addkword (prev, songs, EXTRACTOR_SONG_COUNT);
- return( prev );
+ return (prev);
}
-static struct EXTRACTOR_Keywords * libextractor_nsfe_tlbl_extract
-(
- const char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev
-)
+static struct EXTRACTOR_Keywords *libextractor_nsfe_tlbl_extract
+ (const char *data, size_t size, struct EXTRACTOR_Keywords *prev)
{
- char * title;
- int left, length;
+ char *title;
+ int left, length;
- for( left = size; left > 0; left -= length )
- {
- title = nsfestring( &data[ size - left ], left );
- prev = addkword( prev, title, EXTRACTOR_TITLE );
- length = strlen( title ) + 1;
+ for (left = size; left > 0; left -= length)
+ {
+ title = nsfestring (&data[size - left], left);
+ prev = addkword (prev, title, EXTRACTOR_TITLE);
+ length = strlen (title) + 1;
- free(title);
- }
+ free (title);
+ }
- return( prev );
+ return (prev);
}
-static struct EXTRACTOR_Keywords * libextractor_nsfe_auth_extract
-(
- const char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev
-)
+static struct EXTRACTOR_Keywords *libextractor_nsfe_auth_extract
+ (const char *data, size_t size, struct EXTRACTOR_Keywords *prev)
{
- char * album;
- char * artist;
- char * copyright;
- char * ripper;
- int left = size;
+ char *album;
+ char *artist;
+ char *copyright;
+ char *ripper;
+ int left = size;
- if( left < 1 )
- {
- return( prev );
- }
+ if (left < 1)
+ {
+ return (prev);
+ }
- album = nsfestring( &data[ size - left ], left );
- prev = addkword( prev, album, EXTRACTOR_ALBUM );
-
- left -= ( strlen( album ) + 1 );
- free(album);
+ album = nsfestring (&data[size - left], left);
+ prev = addkword (prev, album, EXTRACTOR_ALBUM);
- if( left < 1 )
- {
- return( prev );
- }
+ left -= (strlen (album) + 1);
+ free (album);
- artist = nsfestring( &data[ size - left ], left );
- prev = addkword( prev, artist, EXTRACTOR_ARTIST );
+ if (left < 1)
+ {
+ return (prev);
+ }
- left -= ( strlen( artist ) + 1 );
- free(artist);
+ artist = nsfestring (&data[size - left], left);
+ prev = addkword (prev, artist, EXTRACTOR_ARTIST);
- if( left < 1 )
- {
- return( prev );
- }
+ left -= (strlen (artist) + 1);
+ free (artist);
- copyright = nsfestring( &data[ size - left ], left );
- prev = addkword( prev, copyright, EXTRACTOR_COPYRIGHT );
+ if (left < 1)
+ {
+ return (prev);
+ }
- left -= ( strlen( copyright ) + 1 );
- free(copyright);
+ copyright = nsfestring (&data[size - left], left);
+ prev = addkword (prev, copyright, EXTRACTOR_COPYRIGHT);
- if( left < 1 )
- {
- return( prev );
- }
+ left -= (strlen (copyright) + 1);
+ free (copyright);
- ripper = nsfestring( &data[ size - left ], left );
- prev = addkword( prev, ripper, EXTRACTOR_RIPPER );
- free(ripper);
+ if (left < 1)
+ {
+ return (prev);
+ }
- return( prev );
+ ripper = nsfestring (&data[size - left], left);
+ prev = addkword (prev, ripper, EXTRACTOR_RIPPER);
+ free (ripper);
+
+ return (prev);
}
@@ -278,89 +265,70 @@
* originally written.
*
*/
-struct EXTRACTOR_Keywords * libextractor_nsfe_extract
-(
- const char * filename,
- const char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev
-)
+struct EXTRACTOR_Keywords *libextractor_nsfe_extract
+ (const char *filename,
+ const char *data, size_t size, struct EXTRACTOR_Keywords *prev)
{
- const struct header *head;
- int i;
- char chunkid[ 5 ] = " ";
+ const struct header *head;
+ int i;
+ char chunkid[5] = " ";
- /* Check header size */
+ /* Check header size */
- if( size < HEADER_SIZE )
- {
- return( prev );
- }
+ if (size < HEADER_SIZE)
+ {
+ return (prev);
+ }
- head = (const struct header * ) data;
+ head = (const struct header *) data;
- /* Check "magic" id bytes */
+ /* Check "magic" id bytes */
- if( memcmp( head->magicid, "NSFE", 4 ) )
- {
- return( prev );
- }
+ if (memcmp (head->magicid, "NSFE", 4))
+ {
+ return (prev);
+ }
- /* Mime-type */
+ /* Mime-type */
- prev = addkword( prev, "audio/x-nsfe", EXTRACTOR_MIMETYPE );
+ prev = addkword (prev, "audio/x-nsfe", EXTRACTOR_MIMETYPE);
- i = 4; /* Jump over magic id */
+ i = 4; /* Jump over magic id */
- while( i + 7 < size && strncmp( chunkid, "NEND", 4 ) ) /* CHECK */
- {
+ while (i + 7 < size && strncmp (chunkid, "NEND", 4)) /* CHECK */
+ {
- unsigned int chunksize = nsfeuint( &data[ i ] );
+ unsigned int chunksize = nsfeuint (&data[i]);
- i += 4; /* Jump over chunk size */
+ i += 4; /* Jump over chunk size */
- memcpy( &chunkid, data + i, 4 );
- chunkid[ 4 ] = '\0';
+ memcpy (&chunkid, data + i, 4);
+ chunkid[4] = '\0';
- i += 4; /* Jump over chunk id */
+ i += 4; /* Jump over chunk id */
- if( ! strncmp( chunkid, "INFO", 4 ) )
- {
- prev = libextractor_nsfe_info_extract
- (
- data + i,
- chunksize,
- prev
- );
- }
+ if (!strncmp (chunkid, "INFO", 4))
+ {
+ prev = libextractor_nsfe_info_extract (data + i, chunksize, prev);
+ }
- if( ! strncmp( chunkid, "auth", 4 ) )
- {
- prev = libextractor_nsfe_auth_extract
- (
- data + i,
- chunksize,
- prev
- );
- }
+ if (!strncmp (chunkid, "auth", 4))
+ {
+ prev = libextractor_nsfe_auth_extract (data + i, chunksize, prev);
+ }
- if( ! strncmp( chunkid, "tlbl", 4 ) )
- {
- prev = libextractor_nsfe_tlbl_extract
- (
- data + i,
- chunksize,
- prev
- );
- }
+ if (!strncmp (chunkid, "tlbl", 4))
+ {
+ prev = libextractor_nsfe_tlbl_extract (data + i, chunksize, prev);
+ }
- /* Ignored chunks: DATA, NEND, plst, time, fade, BANK */
+ /* Ignored chunks: DATA, NEND, plst, time, fade, BANK */
- i += chunksize;
-
- }
+ i += chunksize;
- return( prev );
+ }
+ return (prev);
+
}
Modified: Extractor/src/plugins/nsfextractor.c
===================================================================
--- Extractor/src/plugins/nsfextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/nsfextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -44,38 +44,35 @@
struct header
{
- char magicid[ 5 ];
- char nsfversion;
- char songs;
- char firstsong;
- UINT16 loadaddr;
- UINT16 initaddr;
- UINT16 playaddr;
- char title[ 32 ];
- char artist[ 32 ];
- char copyright[ 32 ];
- UINT16 ntscspeed;
- char bankswitch[ 8 ];
- UINT16 palspeed;
- char tvflags;
- char chipflags;
+ char magicid[5];
+ char nsfversion;
+ char songs;
+ char firstsong;
+ UINT16 loadaddr;
+ UINT16 initaddr;
+ UINT16 playaddr;
+ char title[32];
+ char artist[32];
+ char copyright[32];
+ UINT16 ntscspeed;
+ char bankswitch[8];
+ UINT16 palspeed;
+ char tvflags;
+ char chipflags;
};
-static struct EXTRACTOR_Keywords * addkword
-(
- EXTRACTOR_KeywordList *oldhead,
- const char * phrase,
- EXTRACTOR_KeywordType type
-)
+static struct EXTRACTOR_Keywords *addkword
+ (EXTRACTOR_KeywordList * oldhead,
+ const char *phrase, EXTRACTOR_KeywordType type)
{
- EXTRACTOR_KeywordList * keyword;
+ EXTRACTOR_KeywordList *keyword;
- keyword = malloc( sizeof( EXTRACTOR_KeywordList ) );
- keyword->next = oldhead;
- keyword->keyword = strdup( phrase );
- keyword->keywordType = type;
- return( keyword );
+ keyword = malloc (sizeof (EXTRACTOR_KeywordList));
+ keyword->next = oldhead;
+ keyword->keyword = strdup (phrase);
+ keyword->keywordType = type;
+ return (keyword);
}
@@ -86,123 +83,119 @@
* written.
*
*/
-struct EXTRACTOR_Keywords * libextractor_nsf_extract
-(
- const char * filename,
- char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev
-)
+struct EXTRACTOR_Keywords *libextractor_nsf_extract
+ (const char *filename,
+ char *data, size_t size, struct EXTRACTOR_Keywords *prev)
{
- char album[ 33 ];
- char artist[ 33 ];
- char copyright[ 33 ];
- char songs[ 32 ];
- char startingsong[ 32 ];
- char nsfversion[ 32 ];
- struct header *head;
+ char album[33];
+ char artist[33];
+ char copyright[33];
+ char songs[32];
+ char startingsong[32];
+ char nsfversion[32];
+ struct header *head;
- /* Check header size */
+ /* Check header size */
- if( size < HEADER_SIZE )
- {
- return( prev );
- }
+ if (size < HEADER_SIZE)
+ {
+ return (prev);
+ }
- head = ( struct header * ) data;
+ head = (struct header *) data;
- /* Check "magic" id bytes */
+ /* Check "magic" id bytes */
- if( memcmp( head->magicid, "NESM\x1a", 5 ) )
- {
- return( prev );
- }
+ if (memcmp (head->magicid, "NESM\x1a", 5))
+ {
+ return (prev);
+ }
- /* Mime-type */
+ /* Mime-type */
- prev = addkword( prev, "audio/x-nsf", EXTRACTOR_MIMETYPE );
+ prev = addkword (prev, "audio/x-nsf", EXTRACTOR_MIMETYPE);
- /* Version of NSF format */
+ /* Version of NSF format */
- sprintf( nsfversion, "%d", head->nsfversion );
- prev = addkword( prev, nsfversion, EXTRACTOR_FORMAT_VERSION );
+ sprintf (nsfversion, "%d", head->nsfversion);
+ prev = addkword (prev, nsfversion, EXTRACTOR_FORMAT_VERSION);
- /* Get song count */
+ /* Get song count */
- sprintf( songs, "%d", head->songs );
- prev = addkword( prev, songs, EXTRACTOR_SONG_COUNT );
+ sprintf (songs, "%d", head->songs);
+ prev = addkword (prev, songs, EXTRACTOR_SONG_COUNT);
- /* Get number of the first song to be played */
+ /* Get number of the first song to be played */
- sprintf( startingsong, "%d", head->firstsong );
- prev = addkword( prev, startingsong, EXTRACTOR_STARTING_SONG );
+ sprintf (startingsong, "%d", head->firstsong);
+ prev = addkword (prev, startingsong, EXTRACTOR_STARTING_SONG);
- /* name, artist, copyright fields */
+ /* name, artist, copyright fields */
- memcpy( &album, head->title, 32 );
- memcpy( &artist, head->artist, 32 );
- memcpy( ©right, head->copyright, 32 );
+ memcpy (&album, head->title, 32);
+ memcpy (&artist, head->artist, 32);
+ memcpy (©right, head->copyright, 32);
- album[ 32 ] = '\0';
- artist[ 32 ] = '\0';
- copyright[ 32 ] = '\0';
+ album[32] = '\0';
+ artist[32] = '\0';
+ copyright[32] = '\0';
- prev = addkword( prev, album, EXTRACTOR_ALBUM );
- prev = addkword( prev, artist, EXTRACTOR_ARTIST );
- prev = addkword( prev, copyright, EXTRACTOR_COPYRIGHT );
+ prev = addkword (prev, album, EXTRACTOR_ALBUM);
+ prev = addkword (prev, artist, EXTRACTOR_ARTIST);
+ prev = addkword (prev, copyright, EXTRACTOR_COPYRIGHT);
- /* PAL or NTSC */
+ /* PAL or NTSC */
- if( head->tvflags & DUAL_FLAG )
- {
- prev = addkword( prev, "PAL/NTSC", EXTRACTOR_TELEVISION_SYSTEM
);
- }
- else
- {
- if( head->tvflags & PAL_FLAG )
- {
- prev = addkword( prev, "PAL",
EXTRACTOR_TELEVISION_SYSTEM );
- }
- else
- {
- prev = addkword( prev, "NTSC",
EXTRACTOR_TELEVISION_SYSTEM );
- }
- }
+ if (head->tvflags & DUAL_FLAG)
+ {
+ prev = addkword (prev, "PAL/NTSC", EXTRACTOR_TELEVISION_SYSTEM);
+ }
+ else
+ {
+ if (head->tvflags & PAL_FLAG)
+ {
+ prev = addkword (prev, "PAL", EXTRACTOR_TELEVISION_SYSTEM);
+ }
+ else
+ {
+ prev = addkword (prev, "NTSC", EXTRACTOR_TELEVISION_SYSTEM);
+ }
+ }
- /* Detect Extra Sound Chips needed to play the files */
+ /* Detect Extra Sound Chips needed to play the files */
- if( head->chipflags & VRCVI_FLAG )
- {
- prev = addkword( prev, "VRCVI", EXTRACTOR_HARDWARE_DEPENDENCY );
- }
- if( head->chipflags & VRCVII_FLAG )
- {
- prev = addkword( prev, "VRCVII", EXTRACTOR_HARDWARE_DEPENDENCY
);
- }
- if( head->chipflags & FDS_FLAG )
- {
- prev = addkword( prev, "FDS Sound",
EXTRACTOR_HARDWARE_DEPENDENCY );
- }
- if( head->chipflags & MMC5_FLAG )
- {
- prev = addkword( prev, "MMC5 audio",
EXTRACTOR_HARDWARE_DEPENDENCY );
- }
- if( head->chipflags & NAMCO_FLAG )
- {
- prev = addkword( prev, "Namco 106",
EXTRACTOR_HARDWARE_DEPENDENCY );
- }
- if( head->chipflags & SUNSOFT_FLAG )
- {
- prev = addkword( prev, "Sunsoft FME-07",
EXTRACTOR_HARDWARE_DEPENDENCY );
- }
+ if (head->chipflags & VRCVI_FLAG)
+ {
+ prev = addkword (prev, "VRCVI", EXTRACTOR_HARDWARE_DEPENDENCY);
+ }
+ if (head->chipflags & VRCVII_FLAG)
+ {
+ prev = addkword (prev, "VRCVII", EXTRACTOR_HARDWARE_DEPENDENCY);
+ }
+ if (head->chipflags & FDS_FLAG)
+ {
+ prev = addkword (prev, "FDS Sound", EXTRACTOR_HARDWARE_DEPENDENCY);
+ }
+ if (head->chipflags & MMC5_FLAG)
+ {
+ prev = addkword (prev, "MMC5 audio", EXTRACTOR_HARDWARE_DEPENDENCY);
+ }
+ if (head->chipflags & NAMCO_FLAG)
+ {
+ prev = addkword (prev, "Namco 106", EXTRACTOR_HARDWARE_DEPENDENCY);
+ }
+ if (head->chipflags & SUNSOFT_FLAG)
+ {
+ prev = addkword (prev, "Sunsoft FME-07", EXTRACTOR_HARDWARE_DEPENDENCY);
+ }
- return( prev );
+ return (prev);
}
Modified: Extractor/src/plugins/oggextractor.c
===================================================================
--- Extractor/src/plugins/oggextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/oggextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -30,127 +30,154 @@
#error You must install the libvorbis header files!
#endif
-static char* get_comment(vorbis_comment *vc, char *label) {
+static char *
+get_comment (vorbis_comment * vc, char *label)
+{
char *tag;
- if (vc && (tag = vorbis_comment_query(vc, label, 0)) != NULL)
+ if (vc && (tag = vorbis_comment_query (vc, label, 0)) != NULL)
return tag;
else
return NULL;
}
-static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordType type,
- char * keyword,
- struct EXTRACTOR_Keywords * next)
{
- EXTRACTOR_KeywordList * result;
+static struct EXTRACTOR_Keywords *
+addKeyword (EXTRACTOR_KeywordType type,
+ char *keyword, struct EXTRACTOR_Keywords *next)
+{
+ EXTRACTOR_KeywordList *result;
if (keyword == NULL)
return next;
- result = malloc(sizeof(EXTRACTOR_KeywordList));
+ result = malloc (sizeof (EXTRACTOR_KeywordList));
result->next = next;
- result->keyword = strdup(keyword);
+ result->keyword = strdup (keyword);
result->keywordType = type;
return result;
}
-static size_t readError(void * ptr,
- size_t size,
- size_t nmemb,
- void * datasource) {
+static size_t
+readError (void *ptr, size_t size, size_t nmemb, void *datasource)
+{
return -1;
}
-static int seekError(void * datasource,
- int64_t offset,
- int whence) {
+static int
+seekError (void *datasource, int64_t offset, int whence)
+{
return -1;
}
-static int closeOk(void * datasource) {
+static int
+closeOk (void *datasource)
+{
return 0;
}
-static long tellError(void * datasource) {
+static long
+tellError (void *datasource)
+{
return -1;
}
/* mimetype = application/ogg */
-struct EXTRACTOR_Keywords * libextractor_ogg_extract(const char * filename,
- char * data,
- size_t size,
- struct EXTRACTOR_Keywords
* prev) {
+struct EXTRACTOR_Keywords *
+libextractor_ogg_extract (const char *filename,
+ char *data,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
OggVorbis_File vf;
- vorbis_comment * comments;
+ vorbis_comment *comments;
ov_callbacks callbacks;
- if (size < 2*sizeof(int)) {
- return prev;
- }
- if (OGG_HEADER != ntohl(*(int*)data)) {
- return prev;
- }
+ if (size < 2 * sizeof (int))
+ {
+ return prev;
+ }
+ if (OGG_HEADER != ntohl (*(int *) data))
+ {
+ return prev;
+ }
callbacks.read_func = &readError;
callbacks.seek_func = &seekError;
callbacks.close_func = &closeOk;
callbacks.tell_func = &tellError;
- if (0 != ov_open_callbacks(NULL, &vf, data, size, callbacks)) {
- ov_clear(&vf);
- return prev;
- }
- comments = ov_comment(&vf, -1);
+ if (0 != ov_open_callbacks (NULL, &vf, data, size, callbacks))
+ {
+ ov_clear (&vf);
+ return prev;
+ }
+ comments = ov_comment (&vf, -1);
- if (NULL == comments) {
- ov_clear(&vf);
- return prev;
- }
- if ( (comments->vendor != NULL) && (strlen(comments->vendor) > 0) )
- prev = addKeyword(EXTRACTOR_PUBLISHER, comments->vendor, prev);
+ if (NULL == comments)
+ {
+ ov_clear (&vf);
+ return prev;
+ }
+ if ((comments->vendor != NULL) && (strlen (comments->vendor) > 0))
+ prev = addKeyword (EXTRACTOR_PUBLISHER, comments->vendor, prev);
- prev = addKeyword(EXTRACTOR_TITLE, get_comment(comments, "title"), prev);
- prev = addKeyword(EXTRACTOR_ARTIST, get_comment(comments, "artist"), prev);
- prev = addKeyword(EXTRACTOR_INTERPRET, get_comment(comments, "performer"),
prev);
- prev = addKeyword(EXTRACTOR_ALBUM, get_comment(comments, "album"), prev);
- prev = addKeyword(EXTRACTOR_CONTACT, get_comment(comments, "contact"), prev);
- prev = addKeyword(EXTRACTOR_GENRE, get_comment(comments, "genre"), prev);
- prev = addKeyword(EXTRACTOR_DATE, get_comment(comments, "date"), prev);
- prev = addKeyword(EXTRACTOR_COMMENT, get_comment(comments, ""), prev);
- prev = addKeyword(EXTRACTOR_LOCATION,get_comment(comments, "location"),
prev);
- prev = addKeyword(EXTRACTOR_DESCRIPTION, get_comment(comments,
"description"), prev);
- prev = addKeyword(EXTRACTOR_VERSIONNUMBER, get_comment(comments, "version"),
prev);
- prev = addKeyword(EXTRACTOR_RESOURCE_IDENTIFIER, get_comment(comments,
"isrc"), prev);
- prev = addKeyword(EXTRACTOR_ORGANIZATION, get_comment(comments,
"organization"), prev);
- prev = addKeyword(EXTRACTOR_COPYRIGHT, get_comment(comments, "copyright"),
prev);
+ prev = addKeyword (EXTRACTOR_TITLE, get_comment (comments, "title"), prev);
+ prev =
+ addKeyword (EXTRACTOR_ARTIST, get_comment (comments, "artist"), prev);
+ prev =
+ addKeyword (EXTRACTOR_INTERPRET, get_comment (comments, "performer"),
+ prev);
+ prev = addKeyword (EXTRACTOR_ALBUM, get_comment (comments, "album"), prev);
+ prev =
+ addKeyword (EXTRACTOR_CONTACT, get_comment (comments, "contact"), prev);
+ prev = addKeyword (EXTRACTOR_GENRE, get_comment (comments, "genre"), prev);
+ prev = addKeyword (EXTRACTOR_DATE, get_comment (comments, "date"), prev);
+ prev = addKeyword (EXTRACTOR_COMMENT, get_comment (comments, ""), prev);
+ prev =
+ addKeyword (EXTRACTOR_LOCATION, get_comment (comments, "location"), prev);
+ prev =
+ addKeyword (EXTRACTOR_DESCRIPTION, get_comment (comments, "description"),
+ prev);
+ prev =
+ addKeyword (EXTRACTOR_VERSIONNUMBER, get_comment (comments, "version"),
+ prev);
+ prev =
+ addKeyword (EXTRACTOR_RESOURCE_IDENTIFIER, get_comment (comments, "isrc"),
+ prev);
+ prev =
+ addKeyword (EXTRACTOR_ORGANIZATION,
+ get_comment (comments, "organization"), prev);
+ prev =
+ addKeyword (EXTRACTOR_COPYRIGHT, get_comment (comments, "copyright"),
+ prev);
/* we have determined for sure that this is an
ogg-vorbis stream, we should add this as a keyword, too */
- prev = addKeyword(EXTRACTOR_MIMETYPE,
- "application/ogg",
- prev);
+ prev = addKeyword (EXTRACTOR_MIMETYPE, "application/ogg", prev);
/* build a description from artist, title and album */
{
- EXTRACTOR_KeywordList * keyword = malloc(sizeof(EXTRACTOR_KeywordList));
- char * word;
- int len = 1+2+2+1;
- if (get_comment(comments, "artist") != NULL)
- len += strlen(get_comment(comments, "artist"));
- if (get_comment(comments, "title") != NULL)
- len += strlen(get_comment(comments, "title"));
- if (get_comment(comments, "album") != NULL)
- len += strlen(get_comment(comments, "album"));
+ EXTRACTOR_KeywordList *keyword = malloc (sizeof (EXTRACTOR_KeywordList));
+ char *word;
+ int len = 1 + 2 + 2 + 1;
+ if (get_comment (comments, "artist") != NULL)
+ len += strlen (get_comment (comments, "artist"));
+ if (get_comment (comments, "title") != NULL)
+ len += strlen (get_comment (comments, "title"));
+ if (get_comment (comments, "album") != NULL)
+ len += strlen (get_comment (comments, "album"));
- word = malloc(len);
+ word = malloc (len);
word[0] = 0;
- if (get_comment(comments, "artist") != NULL) {
- strcat(word, get_comment(comments, "artist"));
- }
- if (get_comment(comments, "title") != NULL) {
- strcat(word,": ");
- strcat(word, get_comment(comments, "title"));
- }
- if (get_comment(comments, "album") != NULL) {
- strcat(word," (");
- strcat(word, get_comment(comments, "album"));
- strcat(word, ")");
- }
+ if (get_comment (comments, "artist") != NULL)
+ {
+ strcat (word, get_comment (comments, "artist"));
+ }
+ if (get_comment (comments, "title") != NULL)
+ {
+ strcat (word, ": ");
+ strcat (word, get_comment (comments, "title"));
+ }
+ if (get_comment (comments, "album") != NULL)
+ {
+ strcat (word, " (");
+ strcat (word, get_comment (comments, "album"));
+ strcat (word, ")");
+ }
keyword->next = prev;
keyword->keyword = word;
keyword->keywordType = EXTRACTOR_DESCRIPTION;
@@ -158,6 +185,6 @@
}
- ov_clear(&vf);
+ ov_clear (&vf);
return prev;
}
Modified: Extractor/src/plugins/pack.c
===================================================================
--- Extractor/src/plugins/pack.c 2007-07-29 08:04:12 UTC (rev 5367)
+++ Extractor/src/plugins/pack.c 2007-07-29 08:35:49 UTC (rev 5368)
@@ -27,12 +27,12 @@
#include "platform.h"
#include "pack.h"
-typedef unsigned char byte;
-typedef unsigned short half;
-typedef unsigned long word;
-typedef signed char sbyte;
-typedef signed short shalf;
-typedef signed long sword;
+typedef unsigned char byte;
+typedef unsigned short half;
+typedef unsigned long word;
+typedef signed char sbyte;
+typedef signed short shalf;
+typedef signed long sword;
/*
@@ -55,9 +55,9 @@
of the arguments specified by the letter
*/
-int cat_pack(void * buf,
- const char *fmt,
- ...) {
+int
+cat_pack (void *buf, const char *fmt, ...)
+{
va_list ap;
word blen, val;
int npacked;
@@ -65,405 +65,448 @@
byte *bp, *bytep;
half *halfp;
word *wordp;
- void * arr;
+ void *arr;
struct cat_bvec *cbvp;
char *cp;
- va_start(ap, fmt);
+ va_start (ap, fmt);
npacked = 0;
- bp = (byte *)buf;
+ bp = (byte *) buf;
- while( *fmt ) {
- nreps = 0;
+ 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;
- }
+ 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;
+ 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 & 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 '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 & 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 '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;
+ 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;
+ default:
+ va_end (ap);
+ return -1;
+ }
+ ++fmt;
}
- ++fmt;
- }
- va_end(ap);
+ va_end (ap);
return npacked;
}
-int cat_unpack(const void * buf,
- const char *fmt,
- ...) {
+int
+cat_unpack (const void *buf, const char *fmt, ...)
+{
va_list ap;
word maxlen, len, *wordp;
- void * arr;
+ 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 */
+ unsigned int nreps, i, isnonprefixed = 1; /* used for 'a' types only */
struct cat_bvec *cbvp;
char *cp;
- bp = (byte *)buf;
+ bp = (byte *) buf;
npacked = 0;
- va_start(ap, fmt);
+ va_start (ap, fmt);
- while ( *fmt ) {
- nreps = 1;
+ 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;
- }
+ 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;
+ 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++;
+ *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 '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++;
+ *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 '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 )
- 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 'A':
+ if (isnonprefixed)
+ {
+ maxlen = va_arg (ap, word);
+ arr = va_arg (ap, void *);
- 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;
+ len = *bp++ << 24;
+ len |= *bp++ << 16;
+ len |= *bp++ << 8;
+ len |= *bp++;
+ if (len > maxlen)
+ return -1;
- 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;
+ memmove (arr, bp, len);
+ bp += len;
- 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;
+ npacked += len;
+ }
+ else
+ {
+ cbvp = va_arg (ap, struct cat_bvec *);
+ for (i = 0; i < nreps; ++i)
+ {
+ maxlen = cbvp->len;
+ arr = cbvp->data;
- 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;
+ len = *bp++ << 24;
+ len |= *bp++ << 16;
+ len |= *bp++ << 8;
+ len |= *bp++;
- 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;
+ if (len > maxlen)
+ return -1;
- 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);
- return -1;
- }
-
- memmove(newbuf, bp, len);
- cbvp[i].data = newbuf;
- cbvp[i].len = len;
-
- bp += len;
- npacked += len;
- }
- break;
+ memmove (arr, bp, len);
+ cbvp->len = len;
+ bp += len;
- default:
- va_end(ap);
- return -1;
- }
+ ++cbvp;
+ npacked += len;
+ }
+ isnonprefixed = 1;
+ }
+ break;
- ++fmt;
- }
+ case 'C':
+ case 'c':
+ sbytep = va_arg (ap, sbyte *);
+ for (i = 0; i < nreps; ++i)
+ {
+ *sbytep = *bp++;
- va_end(ap);
- return 0;
-}
+ 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);
+ 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;
+}
Modified: Extractor/src/plugins/pdfextractor.c
===================================================================
--- Extractor/src/plugins/pdfextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/pdfextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -38,24 +38,25 @@
#include <time.h>
#include "convert.h"
-static char * stndup(const char * str,
- size_t n) {
- char * tmp;
- tmp = malloc(n+1);
+static char *
+stndup (const char *str, size_t n)
+{
+ char *tmp;
+ tmp = malloc (n + 1);
tmp[n] = '\0';
- memcpy(tmp, str, n);
+ memcpy (tmp, str, n);
return tmp;
}
static struct EXTRACTOR_Keywords *
-addKeyword(EXTRACTOR_KeywordType type,
- char * keyword,
- struct EXTRACTOR_Keywords * next) {
- EXTRACTOR_KeywordList * result;
+addKeyword (EXTRACTOR_KeywordType type,
+ char *keyword, struct EXTRACTOR_Keywords *next)
+{
+ EXTRACTOR_KeywordList *result;
if (keyword == NULL)
return next;
- result = malloc(sizeof(EXTRACTOR_KeywordList));
+ result = malloc (sizeof (EXTRACTOR_KeywordList));
result->next = next;
result->keyword = keyword;
result->keywordType = type;
@@ -65,167 +66,192 @@
static unsigned char *
-dateDecode(const char * pdfString) {
+dateDecode (const char *pdfString)
+{
if (pdfString == NULL)
return NULL;
- if (strlen(pdfString) < 4)
+ if (strlen (pdfString) < 4)
return NULL;
- return (unsigned char*) stndup(&pdfString[3], strlen(pdfString) - 4);
+ return (unsigned char *) stndup (&pdfString[3], strlen (pdfString) - 4);
}
static unsigned char *
-stringDecode(const char * pdfString,
- size_t * size) {
+stringDecode (const char *pdfString, size_t * size)
+{
size_t slen;
size_t r;
size_t w;
- unsigned char * ret;
+ unsigned char *ret;
char hex[3];
int i;
int val;
- slen = strlen(pdfString);
+ slen = strlen (pdfString);
if (slen < 2)
return NULL;
- switch (pdfString[0]) {
- case '(':
- if (pdfString[slen-1] != ')')
- return NULL;
- ret = malloc(slen);
- w = 0;
- for (r=1;r<slen-1;r++) {
- if (pdfString[r] == '/') {
- r++;
- switch (pdfString[r]) {
- case '/':
- ret[w++] = '/';
- break;
- case 'n':
- ret[w++] = '\n';
- break;
- case 'r':
- ret[w++] = '\r';
- break;
- case 't':
- ret[w++] = '\t';
- break;
- case 'b':
- ret[w++] = '\b';
- break;
- case 'f':
- ret[w++] = '\f';
- break;
- case '(':
- ret[w++] = '(';
- break;
- case ')':
- ret[w++] = ')';
- break;
- case '0':
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9': {
- char buf[4];
- unsigned int u;
- memset(buf, 0, 4);
- buf[0] = pdfString[r++];
- if ( (pdfString[r] >= '0') &&
- (pdfString[r] <= '9') )
- buf[1] = pdfString[r++];
- if ( (pdfString[r] >= '0') &&
- (pdfString[r] <= '9') )
- buf[2] = pdfString[r++];
- if (1 == sscanf(buf, "%o", &u)) {
- ret[w++] = (char) u;
- } else {
- free(ret);
- return NULL; /* invalid! */
- }
- break;
- }
- default: /* invalid */
- free(ret);
- return NULL;
- }
- } else {
- ret[w++] = pdfString[r];
- }
+ switch (pdfString[0])
+ {
+ case '(':
+ if (pdfString[slen - 1] != ')')
+ return NULL;
+ ret = malloc (slen);
+ w = 0;
+ for (r = 1; r < slen - 1; r++)
+ {
+ if (pdfString[r] == '/')
+ {
+ r++;
+ switch (pdfString[r])
+ {
+ case '/':
+ ret[w++] = '/';
+ break;
+ case 'n':
+ ret[w++] = '\n';
+ break;
+ case 'r':
+ ret[w++] = '\r';
+ break;
+ case 't':
+ ret[w++] = '\t';
+ break;
+ case 'b':
+ ret[w++] = '\b';
+ break;
+ case 'f':
+ ret[w++] = '\f';
+ break;
+ case '(':
+ ret[w++] = '(';
+ break;
+ case ')':
+ ret[w++] = ')';
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ {
+ char buf[4];
+ unsigned int u;
+ memset (buf, 0, 4);
+ buf[0] = pdfString[r++];
+ if ((pdfString[r] >= '0') && (pdfString[r] <= '9'))
+ buf[1] = pdfString[r++];
+ if ((pdfString[r] >= '0') && (pdfString[r] <= '9'))
+ buf[2] = pdfString[r++];
+ if (1 == sscanf (buf, "%o", &u))
+ {
+ ret[w++] = (char) u;
+ }
+ else
+ {
+ free (ret);
+ return NULL; /* invalid! */
+ }
+ break;
+ }
+ default: /* invalid */
+ free (ret);
+ return NULL;
+ }
+ }
+ else
+ {
+ ret[w++] = pdfString[r];
+ }
+ }
+ ret[w] = '/';
+ *size = w;
+ return ret;
+ case '<':
+ if (pdfString[slen - 1] != '>')
+ return NULL;
+ hex[2] = '\0';
+ ret = malloc (1 + ((slen - 1) / 2));
+ for (i = 0; i < slen - 2; i += 2)
+ {
+ hex[0] = pdfString[i + 1];
+ hex[1] = '0';
+ if (i + 1 < slen)
+ hex[1] = pdfString[i + 2];
+ if ((1 != sscanf (hex, "%x", &val)) &&
+ (1 != sscanf (hex, "%X", &val)))
+ {
+ free (ret);
+ return NULL;
+ }
+ ret[i / 2] = val;
+ }
+ ret[(slen - 1) / 2] = '\0';
+ *size = (slen - 1) / 2;
+ return ret;
}
- ret[w] = '/';
- *size = w;
- return ret;
- case '<':
- if (pdfString[slen-1] != '>')
- return NULL;
- hex[2] = '\0';
- ret = malloc(1 + ((slen - 1) / 2));
- for (i=0;i<slen-2;i+=2) {
- hex[0] = pdfString[i+1];
- hex[1] = '0';
- if (i + 1 < slen)
- hex[1] = pdfString[i+2];
- if ( (1 != sscanf(hex, "%x", &val)) &&
- (1 != sscanf(hex, "%X", &val)) ) {
- free(ret);
- return NULL;
- }
- ret[i/2] = val;
- }
- ret[(slen-1)/2] = '\0';
- *size = (slen-1) / 2;
- return ret;
- }
return NULL;
}
static char *
-charsetDecode(const unsigned char * in,
- size_t size) {
+charsetDecode (const unsigned char *in, size_t size)
+{
if (in == NULL)
return NULL;
- if ( (size < 2) ||
- (in[0] != 0xfe) ||
- (in[1] != 0xff) ) {
- /* TODO: extend glibc with
- character set that corresponds to
- Adobe's extended ISOLATIN1 encoding! */
- return convertToUtf8((const char*) in,
- size,
- "CSISOLATIN1");
- } else {
- return convertToUtf8((const char*) &in[2],
- size - 2,
- "UTF-16BE");
- }
+ if ((size < 2) || (in[0] != 0xfe) || (in[1] != 0xff))
+ {
+ /* TODO: extend glibc with
+ character set that corresponds to
+ Adobe's extended ISOLATIN1 encoding! */
+ return convertToUtf8 ((const char *) in, size, "CSISOLATIN1");
+ }
+ else
+ {
+ return convertToUtf8 ((const char *) &in[2], size - 2, "UTF-16BE");
+ }
}
-static struct {
- char * name;
+static struct
+{
+ char *name;
EXTRACTOR_KeywordType type;
-} tagmap[] = {
- { "/CreationDate", EXTRACTOR_CREATION_DATE},
- { "/Author" , EXTRACTOR_AUTHOR},
- { "/Description" , EXTRACTOR_DESCRIPTION},
- { "/Title" , EXTRACTOR_TITLE},
- { "/Comment", EXTRACTOR_COMMENT},
- { "/Copyright", EXTRACTOR_COPYRIGHT},
- { "/Subject", EXTRACTOR_SUBJECT},
- { "/PTEX.Fullbanner", EXTRACTOR_SOFTWARE},
- { "/Creator", EXTRACTOR_CREATOR},
- { "/ModDate", EXTRACTOR_MODIFICATION_DATE},
- { "/Producer", EXTRACTOR_PRODUCER},
- { "/Software", EXTRACTOR_SOFTWARE},
- { "/Keywords", EXTRACTOR_KEYWORDS},
- { "/Warning", EXTRACTOR_WARNING},
- { "/Signature", EXTRACTOR_RESOURCE_IDENTIFIER},
- { NULL, EXTRACTOR_UNKNOWN},
-};
+} tagmap[] =
+{
+ {
+ "/CreationDate", EXTRACTOR_CREATION_DATE},
+ {
+ "/Author", EXTRACTOR_AUTHOR},
+ {
+ "/Description", EXTRACTOR_DESCRIPTION},
+ {
+ "/Title", EXTRACTOR_TITLE},
+ {
+ "/Comment", EXTRACTOR_COMMENT},
+ {
+ "/Copyright", EXTRACTOR_COPYRIGHT},
+ {
+ "/Subject", EXTRACTOR_SUBJECT},
+ {
+ "/PTEX.Fullbanner", EXTRACTOR_SOFTWARE},
+ {
+ "/Creator", EXTRACTOR_CREATOR},
+ {
+ "/ModDate", EXTRACTOR_MODIFICATION_DATE},
+ {
+ "/Producer", EXTRACTOR_PRODUCER},
+ {
+ "/Software", EXTRACTOR_SOFTWARE},
+ {
+ "/Keywords", EXTRACTOR_KEYWORDS},
+ {
+ "/Warning", EXTRACTOR_WARNING},
+ {
+ "/Signature", EXTRACTOR_RESOURCE_IDENTIFIER},
+ {
+NULL, EXTRACTOR_UNKNOWN},};
#define PDF_HEADER "%PDF"
#define PDF_EOF "%%EOF"
@@ -242,10 +268,10 @@
#define SKIP(k,p,b,s) while ( (p<s) && (NULL != strchr(k, b[p])) ) p++;
struct EXTRACTOR_Keywords *
-libextractor_pdf_extract(const char * filename,
- const char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev) {
+libextractor_pdf_extract (const char *filename,
+ const char *data,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
size_t pos;
size_t spos;
size_t steps;
@@ -257,221 +283,209 @@
unsigned long long xrefpos;
int haveValidXref;
unsigned long long info_offset;
- char buf[MAX_STEPS+1];
+ char buf[MAX_STEPS + 1];
int i;
- char * meta;
- unsigned char * dmeta;
+ char *meta;
+ unsigned char *dmeta;
char pcnt[20];
float version;
- while ( (size > 0) && (IS_NL(data[size-1])) )
+ while ((size > 0) && (IS_NL (data[size - 1])))
size--;
- if (size < strlen(PDF_HEADER) + strlen(PDF_EOF) + strlen(PDF_SXR) + 3)
+ if (size < strlen (PDF_HEADER) + strlen (PDF_EOF) + strlen (PDF_SXR) + 3)
return prev;
- if (0 != memcmp(data, PDF_HEADER, strlen(PDF_HEADER)))
+ if (0 != memcmp (data, PDF_HEADER, strlen (PDF_HEADER)))
return prev;
- if (0 != memcmp(&data[size - strlen(PDF_EOF)], PDF_EOF, strlen(PDF_EOF)))
+ if (0 != memcmp (&data[size - strlen (PDF_EOF)], PDF_EOF, strlen (PDF_EOF)))
return prev;
/* PDF format is pretty much sure by now */
- memcpy(buf,
- data,
- 8);
+ memcpy (buf, data, 8);
buf[8] = '\0';
- if (1 != sscanf(buf, "%%PDF-%f", &version)) {
- return prev;
- }
- sprintf(pcnt, "PDF %.1f", version);
- prev = addKeyword(EXTRACTOR_FORMAT,
- strdup(pcnt),
- prev);
+ if (1 != sscanf (buf, "%%PDF-%f", &version))
+ {
+ return prev;
+ }
+ sprintf (pcnt, "PDF %.1f", version);
+ prev = addKeyword (EXTRACTOR_FORMAT, strdup (pcnt), prev);
- pos = size - strlen(PDF_EOF) - strlen(PDF_SXR);
+ pos = size - strlen (PDF_EOF) - strlen (PDF_SXR);
steps = 0;
- while ( (steps++ < MAX_STEPS) &&
- (pos > 0) &&
- (0 != memcmp(&data[pos], PDF_SXR, strlen(PDF_SXR))) )
+ while ((steps++ < MAX_STEPS) &&
+ (pos > 0) && (0 != memcmp (&data[pos], PDF_SXR, strlen (PDF_SXR))))
pos--;
- if (0 != memcmp(&data[pos], PDF_SXR, strlen(PDF_SXR))) {
- /* cross reference streams not yet supported! */
- return prev;
- }
- memcpy(buf, &data[pos + strlen(PDF_SXR)], steps);
+ if (0 != memcmp (&data[pos], PDF_SXR, strlen (PDF_SXR)))
+ {
+ /* cross reference streams not yet supported! */
+ return prev;
+ }
+ memcpy (buf, &data[pos + strlen (PDF_SXR)], steps);
buf[steps] = '\0';
- if (1 != sscanf(buf, "%llu", &startxref))
+ if (1 != sscanf (buf, "%llu", &startxref))
return prev;
- if (startxref >= size - strlen(PDF_XREF))
+ if (startxref >= size - strlen (PDF_XREF))
return prev;
- if (0 != memcmp(&data[startxref], PDF_XREF, strlen(PDF_XREF)))
+ if (0 != memcmp (&data[startxref], PDF_XREF, strlen (PDF_XREF)))
return prev;
haveValidXref = 0;
- xrefpos = startxref + strlen(PDF_XREF);
- while (1) {
- pos = xrefpos;
- while ( (pos < size) && (IS_NL(data[pos])) )
- pos++;
- memcpy(buf, &data[pos], MIN(MAX_STEPS, size - pos));
- buf[MIN(MAX_STEPS,size-pos)] = '\0';
- if (2 != sscanf(buf, "%u %u", &xstart, &xcount))
- break;
- while ( (pos < size) && (! IS_NL(data[pos])) )
- pos++;
- if ( (pos < size) && IS_NL(data[pos]))
- pos++;
- xrefpos = 20 * xcount + pos;
- if ( (xrefpos >= size) || (xrefpos < pos) )
- return prev; /* invalid xref size */
- haveValidXref = 1;
- }
- if (! haveValidXref)
+ xrefpos = startxref + strlen (PDF_XREF);
+ while (1)
+ {
+ pos = xrefpos;
+ while ((pos < size) && (IS_NL (data[pos])))
+ pos++;
+ memcpy (buf, &data[pos], MIN (MAX_STEPS, size - pos));
+ buf[MIN (MAX_STEPS, size - pos)] = '\0';
+ if (2 != sscanf (buf, "%u %u", &xstart, &xcount))
+ break;
+ while ((pos < size) && (!IS_NL (data[pos])))
+ pos++;
+ if ((pos < size) && IS_NL (data[pos]))
+ pos++;
+ xrefpos = 20 * xcount + pos;
+ if ((xrefpos >= size) || (xrefpos < pos))
+ return prev; /* invalid xref size */
+ haveValidXref = 1;
+ }
+ if (!haveValidXref)
return prev;
- if (size - pos < strlen(PDF_TRAILER))
+ if (size - pos < strlen (PDF_TRAILER))
return prev;
- if (0 != memcmp(&data[pos],
- PDF_TRAILER,
- strlen(PDF_TRAILER)))
+ if (0 != memcmp (&data[pos], PDF_TRAILER, strlen (PDF_TRAILER)))
return prev;
- pos += strlen(PDF_TRAILER);
+ pos += strlen (PDF_TRAILER);
- SKIP("<< \n\r", pos, data, size);
- while ( (pos < size) &&
- (pos + strlen(PDF_INFO) < size) &&
- (0 != memcmp(&data[pos],
- PDF_INFO,
- strlen(PDF_INFO))) ) {
- while ( (pos < size) &&
- (! IS_NL(data[pos]) ) ) {
- if ( (data[pos] == '>') &&
- (pos + 1 < size) &&
- (data[pos+1] == '>') )
- return prev; /* no info */
- pos++;
+ SKIP ("<< \n\r", pos, data, size);
+ while ((pos < size) &&
+ (pos + strlen (PDF_INFO) < size) &&
+ (0 != memcmp (&data[pos], PDF_INFO, strlen (PDF_INFO))))
+ {
+ while ((pos < size) && (!IS_NL (data[pos])))
+ {
+ if ((data[pos] == '>') &&
+ (pos + 1 < size) && (data[pos + 1] == '>'))
+ return prev; /* no info */
+ pos++;
+ }
+ while ((pos < size) && (IS_NL (data[pos]) || isspace (data[pos])))
+ pos++;
}
- while ( (pos < size) &&
- (IS_NL(data[pos]) || isspace(data[pos]) ) )
- pos++; }
- if ( ! ( (pos < size) &&
- (pos + strlen(PDF_INFO) < size) &&
- (0 == memcmp(&data[pos],
- PDF_INFO,
- strlen(PDF_INFO))) ) )
+ if (!((pos < size) &&
+ (pos + strlen (PDF_INFO) < size) &&
+ (0 == memcmp (&data[pos], PDF_INFO, strlen (PDF_INFO)))))
return prev;
- pos += strlen(PDF_INFO);
- memcpy(buf,
- &data[pos],
- MIN(MAX_STEPS, size - pos));
- buf[MIN(MAX_STEPS,size-pos)] = '\0';
- for (i=0;i<MIN(MAX_STEPS,size-pos);i++)
- if (isspace(buf[i])) {
- buf[i] = '\0';
- break;
- }
- if (1 != sscanf(buf, "%u", &xinfo))
+ pos += strlen (PDF_INFO);
+ memcpy (buf, &data[pos], MIN (MAX_STEPS, size - pos));
+ buf[MIN (MAX_STEPS, size - pos)] = '\0';
+ for (i = 0; i < MIN (MAX_STEPS, size - pos); i++)
+ if (isspace (buf[i]))
+ {
+ buf[i] = '\0';
+ break;
+ }
+ if (1 != sscanf (buf, "%u", &xinfo))
return prev;
haveValidXref = 0;
/* now go find xinfo in xref table */
- xrefpos = startxref + strlen(PDF_XREF);
- while (1) {
- pos = xrefpos;
- while ( (pos < size) && (IS_NL(data[pos])) )
- pos++;
- memcpy(buf, &data[pos], MIN(MAX_STEPS, size - pos));
- buf[MIN(MAX_STEPS,size-pos)] = '\0';
- if (2 != sscanf(buf, "%u %u", &xstart, &xcount))
- break;
- while ( (pos < size) && (! IS_NL(data[pos])) )
- pos++;
- if ( (pos < size) && IS_NL(data[pos]))
- pos++;
- if ( (xinfo > xstart) &&
- (xinfo < xstart + xcount) ) {
- haveValidXref = 1;
- pos += 20 * xinfo - xstart;
- memcpy(buf, &data[pos], 20);
- buf[20] = '\0';
- sscanf(buf, "%10llu %*5u %*c", &info_offset);
- break;
+ xrefpos = startxref + strlen (PDF_XREF);
+ while (1)
+ {
+ pos = xrefpos;
+ while ((pos < size) && (IS_NL (data[pos])))
+ pos++;
+ memcpy (buf, &data[pos], MIN (MAX_STEPS, size - pos));
+ buf[MIN (MAX_STEPS, size - pos)] = '\0';
+ if (2 != sscanf (buf, "%u %u", &xstart, &xcount))
+ break;
+ while ((pos < size) && (!IS_NL (data[pos])))
+ pos++;
+ if ((pos < size) && IS_NL (data[pos]))
+ pos++;
+ if ((xinfo > xstart) && (xinfo < xstart + xcount))
+ {
+ haveValidXref = 1;
+ pos += 20 * xinfo - xstart;
+ memcpy (buf, &data[pos], 20);
+ buf[20] = '\0';
+ sscanf (buf, "%10llu %*5u %*c", &info_offset);
+ break;
+ }
+ xrefpos = 20 * xcount + pos;
+ if ((xrefpos >= size) || (xrefpos < pos))
+ return prev; /* invalid xref size */
}
- xrefpos = 20 * xcount + pos;
- if ( (xrefpos >= size) || (xrefpos < pos) )
- return prev; /* invalid xref size */
- }
- if (! haveValidXref)
+ if (!haveValidXref)
return prev;
pos = info_offset;
- while ( (pos < size - 4) &&
- (! ( (data[pos] == '<') &&
- (data[pos+1] == '<') ) ) )
+ while ((pos < size - 4) &&
+ (!((data[pos] == '<') && (data[pos + 1] == '<'))))
pos++;
pos++;
if (pos >= size - 4)
return prev;
- if ( (data[pos] == ' ') ||
- (data[pos] == 10) ||
- (data[pos] == 13) )
+ if ((data[pos] == ' ') || (data[pos] == 10) || (data[pos] == 13))
pos++;
- while ( (pos < size - 2) &&
- ( ! ( (data[pos] == '>') &&
- (data[pos+1] == '>') ) ) ) {
- i = 0;
- while (tagmap[i].name != NULL) {
- if ( (pos + strlen(tagmap[i].name) > pos) &&
- (pos + strlen(tagmap[i].name) + 1 < size) &&
- (0 == memcmp(&data[pos],
- tagmap[i].name,
- strlen(tagmap[i].name))) ) {
- pos += strlen(tagmap[i].name);
- if (isspace(data[pos]))
- pos++;
- spos = pos;
- while ( (pos < size + 2) &&
- (! IS_NL(data[pos])) &&
- (data[pos] != '/') &&
- (! ( (data[pos] == '>') &&
- (data[pos+1] == '>') ) ) )
- pos++;
- meta = stndup(&data[spos],
- pos - spos);
- if (i == 0) {
- dmeta = dateDecode(meta);
- if (dmeta != NULL)
- mlen = strlen((const char*)dmeta);
- else
- mlen = 0;
- } else {
- dmeta = stringDecode(meta,
- &mlen);
- }
- if (meta != NULL)
- free(meta);
- if (dmeta != NULL) {
- meta = charsetDecode(dmeta, mlen);
- if (dmeta != NULL)
- free(dmeta);
- if (meta != NULL) {
- prev = addKeyword(tagmap[i].type,
- meta,
- prev);
- }
- }
- break;
- }
- i++;
+ while ((pos < size - 2) &&
+ (!((data[pos] == '>') && (data[pos + 1] == '>'))))
+ {
+ i = 0;
+ while (tagmap[i].name != NULL)
+ {
+ if ((pos + strlen (tagmap[i].name) > pos) &&
+ (pos + strlen (tagmap[i].name) + 1 < size) &&
+ (0 == memcmp (&data[pos],
+ tagmap[i].name, strlen (tagmap[i].name))))
+ {
+ pos += strlen (tagmap[i].name);
+ if (isspace (data[pos]))
+ pos++;
+ spos = pos;
+ while ((pos < size + 2) &&
+ (!IS_NL (data[pos])) &&
+ (data[pos] != '/') &&
+ (!((data[pos] == '>') && (data[pos + 1] == '>'))))
+ pos++;
+ meta = stndup (&data[spos], pos - spos);
+ if (i == 0)
+ {
+ dmeta = dateDecode (meta);
+ if (dmeta != NULL)
+ mlen = strlen ((const char *) dmeta);
+ else
+ mlen = 0;
+ }
+ else
+ {
+ dmeta = stringDecode (meta, &mlen);
+ }
+ if (meta != NULL)
+ free (meta);
+ if (dmeta != NULL)
+ {
+ meta = charsetDecode (dmeta, mlen);
+ if (dmeta != NULL)
+ free (dmeta);
+ if (meta != NULL)
+ {
+ prev = addKeyword (tagmap[i].type, meta, prev);
+ }
+ }
+ break;
+ }
+ i++;
+ }
+ if (tagmap[i].name == NULL)
+ {
+ while ((pos < size) && (!IS_NL (data[pos])))
+ pos++;
+ }
+ while ((pos < size) && (IS_NL (data[pos])))
+ pos++;
}
- if (tagmap[i].name == NULL) {
- while ( (pos < size) &&
- (! IS_NL(data[pos])) )
- pos++;
- }
- while ( (pos < size) &&
- (IS_NL(data[pos])) )
- pos++;
- }
return prev;
}
-
Modified: Extractor/src/plugins/pngextractor.c
===================================================================
--- Extractor/src/plugins/pngextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/pngextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -23,12 +23,13 @@
#include <zlib.h>
#include "convert.h"
-static char * stndup(const char * str,
- size_t n) {
- char * tmp;
- tmp = malloc(n+1);
+static char *
+stndup (const char *str, size_t n)
+{
+ char *tmp;
+ tmp = malloc (n + 1);
tmp[n] = '\0';
- memcpy(tmp, str, n);
+ memcpy (tmp, str, n);
return tmp;
}
@@ -36,250 +37,261 @@
* strnlen is GNU specific, let's redo it here to be
* POSIX compliant.
*/
-static size_t stnlen(const char * str,
- size_t maxlen) {
+static size_t
+stnlen (const char *str, size_t maxlen)
+{
size_t ret;
ret = 0;
- while ( (ret < maxlen) &&
- (str[ret] != '\0') )
+ while ((ret < maxlen) && (str[ret] != '\0'))
ret++;
return ret;
}
-static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordType type,
- char * keyword,
- struct EXTRACTOR_Keywords * next)
{
- EXTRACTOR_KeywordList * result;
+static struct EXTRACTOR_Keywords *
+addKeyword (EXTRACTOR_KeywordType type,
+ char *keyword, struct EXTRACTOR_Keywords *next)
+{
+ EXTRACTOR_KeywordList *result;
if (keyword == NULL)
return next;
- result = malloc(sizeof(EXTRACTOR_KeywordList));
+ result = malloc (sizeof (EXTRACTOR_KeywordList));
result->next = next;
result->keyword = keyword;
result->keywordType = type;
return result;
}
-static int getIntAt(const void * pos) {
+static int
+getIntAt (const void *pos)
+{
char p[4];
- memcpy(p, pos, 4); /* ensure alignment! */
- return *(int*)&p[0];
+ memcpy (p, pos, 4); /* ensure alignment! */
+ return *(int *) &p[0];
}
-static struct {
- char * name;
+static struct
+{
+ char *name;
EXTRACTOR_KeywordType type;
-} tagmap[] = {
- { "Author" , EXTRACTOR_AUTHOR},
- { "Description" , EXTRACTOR_DESCRIPTION},
- { "Comment", EXTRACTOR_COMMENT},
- { "Copyright", EXTRACTOR_COPYRIGHT},
- { "Source", EXTRACTOR_SOURCE},
- { "Creation Time", EXTRACTOR_CREATION_DATE},
- { "Title", EXTRACTOR_TITLE},
- { "Software", EXTRACTOR_SOFTWARE},
- { "Disclaimer", EXTRACTOR_DISCLAIMER},
- { "Warning", EXTRACTOR_WARNING},
- { "Signature", EXTRACTOR_RESOURCE_IDENTIFIER},
- { NULL, EXTRACTOR_UNKNOWN},
-};
+} tagmap[] =
+{
+ {
+ "Author", EXTRACTOR_AUTHOR},
+ {
+ "Description", EXTRACTOR_DESCRIPTION},
+ {
+ "Comment", EXTRACTOR_COMMENT},
+ {
+ "Copyright", EXTRACTOR_COPYRIGHT},
+ {
+ "Source", EXTRACTOR_SOURCE},
+ {
+ "Creation Time", EXTRACTOR_CREATION_DATE},
+ {
+ "Title", EXTRACTOR_TITLE},
+ {
+ "Software", EXTRACTOR_SOFTWARE},
+ {
+ "Disclaimer", EXTRACTOR_DISCLAIMER},
+ {
+ "Warning", EXTRACTOR_WARNING},
+ {
+ "Signature", EXTRACTOR_RESOURCE_IDENTIFIER},
+ {
+NULL, EXTRACTOR_UNKNOWN},};
-static struct EXTRACTOR_Keywords * processtEXt(const char * data,
- unsigned int length,
- struct EXTRACTOR_Keywords *
prev) {
- char * keyword;
+static struct EXTRACTOR_Keywords *
+processtEXt (const char *data,
+ unsigned int length, struct EXTRACTOR_Keywords *prev)
+{
+ char *keyword;
unsigned int off;
int i;
data += 4;
- off = stnlen(data, length) + 1;
+ off = stnlen (data, length) + 1;
if (off >= length)
- return prev; /* failed to find '\0' */
- keyword = convertToUtf8(&data[off],
- length-off,
- "ISO-8859-1");
+ return prev; /* failed to find '\0' */
+ keyword = convertToUtf8 (&data[off], length - off, "ISO-8859-1");
i = 0;
- while (tagmap[i].name != NULL) {
- if (0 == strcmp(tagmap[i].name, data))
- return addKeyword(tagmap[i].type,
- keyword,
- prev);
+ while (tagmap[i].name != NULL)
+ {
+ if (0 == strcmp (tagmap[i].name, data))
+ return addKeyword (tagmap[i].type, keyword, prev);
- i++;
- }
- return addKeyword(EXTRACTOR_UNKNOWN,
- keyword,
- prev);
+ i++;
+ }
+ return addKeyword (EXTRACTOR_UNKNOWN, keyword, prev);
}
-static struct EXTRACTOR_Keywords * processiTXt(const char * data,
- unsigned int length,
- struct EXTRACTOR_Keywords *
prev) {
+static struct EXTRACTOR_Keywords *
+processiTXt (const char *data,
+ unsigned int length, struct EXTRACTOR_Keywords *prev)
+{
unsigned int pos;
- char * keyword;
- const char * language;
- const char * translated;
+ char *keyword;
+ const char *language;
+ const char *translated;
int i;
int compressed;
- char * buf;
+ char *buf;
uLongf bufLen;
int ret;
- pos = stnlen(data, length)+1;
- if (pos+3 >= length)
+ pos = stnlen (data, length) + 1;
+ if (pos + 3 >= length)
return prev;
compressed = data[pos++];
if (compressed && (data[pos++] != 0))
- return prev; /* bad compression method */
+ return prev; /* bad compression method */
language = &data[pos];
- if (stnlen(language, length-pos) > 0)
- prev = addKeyword(EXTRACTOR_LANGUAGE,
- stndup(language, length-pos),
- prev);
- pos += stnlen(language, length-pos)+1;
- if (pos+1 >= length)
+ if (stnlen (language, length - pos) > 0)
+ prev = addKeyword (EXTRACTOR_LANGUAGE,
+ stndup (language, length - pos), prev);
+ pos += stnlen (language, length - pos) + 1;
+ if (pos + 1 >= length)
return prev;
- translated = &data[pos]; /* already in utf-8! */
- if (stnlen(translated, length-pos) > 0)
- prev = addKeyword(EXTRACTOR_TRANSLATED,
- stndup(translated, length-pos),
- prev);
- pos += stnlen(translated, length-pos)+1;
+ translated = &data[pos]; /* already in utf-8! */
+ if (stnlen (translated, length - pos) > 0)
+ prev = addKeyword (EXTRACTOR_TRANSLATED,
+ stndup (translated, length - pos), prev);
+ pos += stnlen (translated, length - pos) + 1;
if (pos >= length)
return prev;
- if (compressed) {
- bufLen = 1024 + 2 * (length - pos);
- while (1) {
- if (bufLen * 2 < bufLen)
- return prev;
- bufLen *= 2;
- if (bufLen > 50 * (length - pos)) {
- /* printf("zlib problem"); */
- return prev;
- }
- buf = malloc(bufLen);
- if (buf == NULL) {
- /* printf("out of memory"); */
- return prev; /* out of memory */
- }
- ret = uncompress((Bytef*) buf,
- &bufLen,
- (const Bytef*) &data[pos],
- length - pos);
- if (ret == Z_OK) {
- /* printf("zlib ok"); */
- break;
- }
- free(buf);
- if (ret != Z_BUF_ERROR)
- return prev; /* unknown error, abort */
+ if (compressed)
+ {
+ bufLen = 1024 + 2 * (length - pos);
+ while (1)
+ {
+ if (bufLen * 2 < bufLen)
+ return prev;
+ bufLen *= 2;
+ if (bufLen > 50 * (length - pos))
+ {
+ /* printf("zlib problem"); */
+ return prev;
+ }
+ buf = malloc (bufLen);
+ if (buf == NULL)
+ {
+ /* printf("out of memory"); */
+ return prev; /* out of memory */
+ }
+ ret = uncompress ((Bytef *) buf,
+ &bufLen,
+ (const Bytef *) &data[pos], length - pos);
+ if (ret == Z_OK)
+ {
+ /* printf("zlib ok"); */
+ break;
+ }
+ free (buf);
+ if (ret != Z_BUF_ERROR)
+ return prev; /* unknown error, abort */
+ }
+ keyword = stndup (buf, bufLen);
+ free (buf);
}
- keyword = stndup(buf, bufLen);
- free(buf);
- } else {
- keyword = stndup(&data[pos], length - pos);
- }
+ else
+ {
+ keyword = stndup (&data[pos], length - pos);
+ }
i = 0;
- while (tagmap[i].name != NULL) {
- if (0 == strcmp(tagmap[i].name,
- data))
- return addKeyword(tagmap[i].type,
- keyword, /* already in utf-8 */
- prev);
- i++;
- }
- return addKeyword(EXTRACTOR_UNKNOWN,
- keyword,
- prev);
+ while (tagmap[i].name != NULL)
+ {
+ if (0 == strcmp (tagmap[i].name, data))
+ return addKeyword (tagmap[i].type, keyword, /* already in utf-8 */
+ prev);
+ i++;
+ }
+ return addKeyword (EXTRACTOR_UNKNOWN, keyword, prev);
}
-static struct EXTRACTOR_Keywords * processIHDR(const char * data,
- unsigned int length,
- struct EXTRACTOR_Keywords *
prev) {
- char * tmp;
+static struct EXTRACTOR_Keywords *
+processIHDR (const char *data,
+ unsigned int length, struct EXTRACTOR_Keywords *prev)
+{
+ char *tmp;
if (length < 12)
return prev;
- tmp = malloc(128);
- snprintf(tmp,
- 128,
- "%ux%u",
- htonl(getIntAt(&data[4])),
- htonl(getIntAt(&data[8])));
- return addKeyword(EXTRACTOR_SIZE,
- tmp,
- prev);
+ tmp = malloc (128);
+ snprintf (tmp,
+ 128,
+ "%ux%u",
+ htonl (getIntAt (&data[4])), htonl (getIntAt (&data[8])));
+ return addKeyword (EXTRACTOR_SIZE, tmp, prev);
}
-static struct EXTRACTOR_Keywords * processzTXt(const char * data,
- unsigned int length,
- struct EXTRACTOR_Keywords *
prev) {
- char * keyword;
+static struct EXTRACTOR_Keywords *
+processzTXt (const char *data,
+ unsigned int length, struct EXTRACTOR_Keywords *prev)
+{
+ char *keyword;
unsigned int off;
int i;
- char * buf;
+ char *buf;
uLongf bufLen;
int ret;
data += 4;
- off = stnlen(data, length) + 1;
+ off = stnlen (data, length) + 1;
if (off >= length)
- return prev; /* failed to find '\0' */
+ return prev; /* failed to find '\0' */
if (data[off] != 0)
- return prev; /* compression method must be 0 */
+ return prev; /* compression method must be 0 */
off++;
bufLen = 1024 + 2 * (length - off);
- while (1) {
- if (bufLen * 2 < bufLen)
- return prev;
- bufLen *= 2;
- if (bufLen > 50 * (length - off)) {
- /* printf("zlib problem"); */
- return prev;
+ while (1)
+ {
+ if (bufLen * 2 < bufLen)
+ return prev;
+ bufLen *= 2;
+ if (bufLen > 50 * (length - off))
+ {
+ /* printf("zlib problem"); */
+ return prev;
+ }
+ buf = malloc (bufLen);
+ if (buf == NULL)
+ {
+ /* printf("out of memory"); */
+ return prev; /* out of memory */
+ }
+ ret = uncompress ((Bytef *) buf,
+ &bufLen, (const Bytef *) &data[off], length - off);
+ if (ret == Z_OK)
+ {
+ /* printf("zlib ok"); */
+ break;
+ }
+ free (buf);
+ if (ret != Z_BUF_ERROR)
+ return prev; /* unknown error, abort */
}
- buf = malloc(bufLen);
- if (buf == NULL) {
- /* printf("out of memory"); */
- return prev; /* out of memory */
- }
- ret = uncompress((Bytef*) buf,
- &bufLen,
- (const Bytef*) &data[off],
- length - off);
- if (ret == Z_OK) {
- /* printf("zlib ok"); */
- break;
- }
- free(buf);
- if (ret != Z_BUF_ERROR)
- return prev; /* unknown error, abort */
- }
- keyword = convertToUtf8(buf,
- bufLen,
- "ISO-8859-1");
- free(buf);
+ keyword = convertToUtf8 (buf, bufLen, "ISO-8859-1");
+ free (buf);
i = 0;
- while (tagmap[i].name != NULL) {
- if (0 == strcmp(tagmap[i].name, data))
- return addKeyword(tagmap[i].type,
- keyword,
- prev);
+ while (tagmap[i].name != NULL)
+ {
+ if (0 == strcmp (tagmap[i].name, data))
+ return addKeyword (tagmap[i].type, keyword, prev);
- i++;
- }
- return addKeyword(EXTRACTOR_UNKNOWN,
- keyword,
- prev);
+ i++;
+ }
+ return addKeyword (EXTRACTOR_UNKNOWN, keyword, prev);
}
-static struct EXTRACTOR_Keywords * processtIME(const char * data,
- unsigned int length,
- struct EXTRACTOR_Keywords *
prev) {
+static struct EXTRACTOR_Keywords *
+processtIME (const char *data,
+ unsigned int length, struct EXTRACTOR_Keywords *prev)
+{
unsigned short y;
unsigned int year;
unsigned int mo;
@@ -291,72 +303,60 @@
if (length != 7)
return prev;
- memcpy(&y,
- &data[4],
- sizeof(unsigned short));
- year = ntohs(y);
- mo = (unsigned char) data[6];
- day = (unsigned char) data[7];
- h = (unsigned char) data[8];
- m = (unsigned char) data[9];
- s = (unsigned char) data[10];
- sprintf(val,
- "%04u-%02u-%02u %02d:%02d:%02d",
- year,
- mo,
- day,
- h,
- m,
- s);
- return addKeyword(EXTRACTOR_MODIFICATION_DATE,
- strdup(val),
- prev);
+ memcpy (&y, &data[4], sizeof (unsigned short));
+ year = ntohs (y);
+ mo = (unsigned char) data[6];
+ day = (unsigned char) data[7];
+ h = (unsigned char) data[8];
+ m = (unsigned char) data[9];
+ s = (unsigned char) data[10];
+ sprintf (val, "%04u-%02u-%02u %02d:%02d:%02d", year, mo, day, h, m, s);
+ return addKeyword (EXTRACTOR_MODIFICATION_DATE, strdup (val), prev);
}
#define PNG_HEADER "\211PNG\r\n\032\n"
-struct EXTRACTOR_Keywords * libextractor_png_extract(const char * filename,
- const char * data,
- size_t size,
- struct EXTRACTOR_Keywords
* prev) {
- const char * pos;
- const char * end;
- struct EXTRACTOR_Keywords * result;
+struct EXTRACTOR_Keywords *
+libextractor_png_extract (const char *filename,
+ const char *data,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
+ const char *pos;
+ const char *end;
+ struct EXTRACTOR_Keywords *result;
unsigned int length;
- if (size < strlen(PNG_HEADER))
+ if (size < strlen (PNG_HEADER))
return prev;
- if (0 != strncmp(data, PNG_HEADER, strlen(PNG_HEADER)))
+ if (0 != strncmp (data, PNG_HEADER, strlen (PNG_HEADER)))
return prev;
result = prev;
end = &data[size];
- pos = &data[strlen(PNG_HEADER)];
- result = addKeyword(EXTRACTOR_MIMETYPE,
- strdup("image/png"),
- result);
- while(1) {
- if (pos+12 >= end)
- break;
- length = htonl(getIntAt(pos)); pos+=4;
- /* printf("Length: %u, pos %u\n", length, pos - data); */
- if ( (pos+4+length+4 > end) ||
- (pos+4+length+4 < pos + 8) )
- break;
+ pos = &data[strlen (PNG_HEADER)];
+ result = addKeyword (EXTRACTOR_MIMETYPE, strdup ("image/png"), result);
+ while (1)
+ {
+ if (pos + 12 >= end)
+ break;
+ length = htonl (getIntAt (pos));
+ pos += 4;
+ /* printf("Length: %u, pos %u\n", length, pos - data); */
+ if ((pos + 4 + length + 4 > end) || (pos + 4 + length + 4 < pos + 8))
+ break;
- if (0 == strncmp(pos, "IHDR", 4))
- result = processIHDR(pos, length, result);
- if (0 == strncmp(pos, "iTXt", 4))
- result = processiTXt(pos, length, result);
- if (0 == strncmp(pos, "tEXt", 4))
- result = processtEXt(pos, length, result);
- if (0 == strncmp(pos, "zTXt", 4))
- result = processzTXt(pos, length, result);
- if (0 == strncmp(pos, "tIME", 4))
- result = processtIME(pos, length, result);
- pos += 4+length+4; /* Chunk type, data, crc */
- }
+ if (0 == strncmp (pos, "IHDR", 4))
+ result = processIHDR (pos, length, result);
+ if (0 == strncmp (pos, "iTXt", 4))
+ result = processiTXt (pos, length, result);
+ if (0 == strncmp (pos, "tEXt", 4))
+ result = processtEXt (pos, length, result);
+ if (0 == strncmp (pos, "zTXt", 4))
+ result = processzTXt (pos, length, result);
+ if (0 == strncmp (pos, "tIME", 4))
+ result = processtIME (pos, length, result);
+ pos += 4 + length + 4; /* Chunk type, data, crc */
+ }
return result;
}
-
Modified: Extractor/src/plugins/printable/dictionary-builder.c
===================================================================
--- Extractor/src/plugins/printable/dictionary-builder.c 2007-07-29
08:04:12 UTC (rev 5367)
+++ Extractor/src/plugins/printable/dictionary-builder.c 2007-07-29
08:35:49 UTC (rev 5368)
@@ -32,8 +32,9 @@
* @param bitArray memory area to set the bit in
* @param bitIdx which bit to set
*/
-static void setBit(unsigned char * bitArray,
- unsigned int bitIdx) {
+static void
+setBit (unsigned char *bitArray, unsigned int bitIdx)
+{
unsigned int arraySlot;
unsigned int targetBit;
@@ -49,11 +50,10 @@
* @param bit the bit to increment
* @param arg not used
*/
-static void setBitCallback(Bloomfilter * bf,
- unsigned int bit,
- void * arg) {
- setBit(bf->bitArray,
- bit);
+static void
+setBitCallback (Bloomfilter * bf, unsigned int bit, void *arg)
+{
+ setBit (bf->bitArray, bit);
}
/**
@@ -62,150 +62,130 @@
* @param bf the filter
* @param e the element
*/
-static void addToBloomfilter(Bloomfilter * bf,
- const HashCode160 * e) {
+static void
+addToBloomfilter (Bloomfilter * bf, const HashCode160 * e)
+{
if (NULL == bf)
return;
- iterateBits(bf,
- &setBitCallback,
- NULL,
- e);
+ iterateBits (bf, &setBitCallback, NULL, e);
}
#define ADDR_PER_ELEMENT 46
-int main(int argc,
- char ** argv) {
+int
+main (int argc, char **argv)
+{
Bloomfilter bf;
HashCode160 hc;
int i;
int j;
int cnt;
- char * fn;
- char ** words;
- char line[2048]; /* buffer overflow, here we go */
+ char *fn;
+ char **words;
+ char line[2048]; /* buffer overflow, here we go */
FILE *dictin;
- char * bn;
- char * charset = NULL;
+ char *bn;
+ char *charset = NULL;
#define ALLOCSIZE 1024*1024
- if (argc<3) {
- fprintf(stderr,
- _("Please provide the name of the language you are building\n"
- "a dictionary for. For example:\n"));
- fprintf(stderr, "$ ./dictionary-builder ./en en > en.c\n");
- exit(-1);
- }
+ if (argc < 3)
+ {
+ fprintf (stderr,
+ _("Please provide the name of the language you are building\n"
+ "a dictionary for. For example:\n"));
+ fprintf (stderr, "$ ./dictionary-builder ./en en > en.c\n");
+ exit (-1);
+ }
- fn = malloc(strlen(argv[1]) + 6);
- strcpy(fn, argv[1]);
- strcat(fn, ".txt");
- dictin=fopen(fn,"r");
- free(fn);
- if (dictin==NULL) {
- fprintf(stderr,
- _("Error opening file `%s': %s\n"),
- argv[1],strerror(errno));
- exit(-1);
- }
+ fn = malloc (strlen (argv[1]) + 6);
+ strcpy (fn, argv[1]);
+ strcat (fn, ".txt");
+ dictin = fopen (fn, "r");
+ free (fn);
+ if (dictin == NULL)
+ {
+ fprintf (stderr,
+ _("Error opening file `%s': %s\n"), argv[1], strerror (errno));
+ exit (-1);
+ }
- words = malloc(sizeof(char*) * ALLOCSIZE); /* don't we LOVE constant size
buffers? */
- if (words == NULL) {
- fprintf(stderr,
- _("Error allocating: %s\n."),
- strerror(errno));
- exit(-1);
- }
+ words = malloc (sizeof (char *) * ALLOCSIZE); /* don't we LOVE constant size
buffers? */
+ if (words == NULL)
+ {
+ fprintf (stderr, _("Error allocating: %s\n."), strerror (errno));
+ exit (-1);
+ }
cnt = 0;
- memset(&line[0], 0, 2048);
- fscanf(dictin, "%s", (char*)&line);
- charset = strdup(line); /* not used (yet) */
- while (1 == fscanf(dictin, "%s", (char*)&line)) {
- words[cnt] = strdup(line);
- cnt++;
- memset(&line[0], 0, 2048);
- if (cnt >= ALLOCSIZE) {
- fprintf(stderr,
- _("Increase ALLOCSIZE (in %s).\n"),
- __FILE__);
- exit(-1);
+ memset (&line[0], 0, 2048);
+ fscanf (dictin, "%s", (char *) &line);
+ charset = strdup (line); /* not used (yet) */
+ while (1 == fscanf (dictin, "%s", (char *) &line))
+ {
+ words[cnt] = strdup (line);
+ cnt++;
+ memset (&line[0], 0, 2048);
+ if (cnt >= ALLOCSIZE)
+ {
+ fprintf (stderr, _("Increase ALLOCSIZE (in %s).\n"), __FILE__);
+ exit (-1);
+ }
}
- }
bf.addressesPerElement = ADDR_PER_ELEMENT;
- bf.bitArraySize = (1 + (cnt / SUBTABLES)) * sizeof(int) * SUBTABLES;
- bf.bitArray = malloc(bf.bitArraySize);
- memset(bf.bitArray, 0, bf.bitArraySize);
+ bf.bitArraySize = (1 + (cnt / SUBTABLES)) * sizeof (int) * SUBTABLES;
+ bf.bitArray = malloc (bf.bitArraySize);
+ memset (bf.bitArray, 0, bf.bitArraySize);
- for (i=0;i<cnt;i++) {
- hash(words[i],
- strlen(words[i]),
- &hc);
- addToBloomfilter(&bf, &hc);
- }
+ for (i = 0; i < cnt; i++)
+ {
+ hash (words[i], strlen (words[i]), &hc);
+ addToBloomfilter (&bf, &hc);
+ }
- fprintf(stdout,
- "#include \"bloomfilter-def.h\"\n");
+ fprintf (stdout, "#include \"bloomfilter-def.h\"\n");
/* use int[] instead of char[] since it cuts the memory use of
gcc down to a quarter; don't use long long since various
gcc versions then output tons of warnings about "decimal constant
is so large that it is unsigned" (even for unsigned long long[]
that warning is generated and dramatically increases compile times). */
- for (j=0;j<SUBTABLES;j++) {
- char fn[64];
- FILE * btfile;
+ for (j = 0; j < SUBTABLES; j++)
+ {
+ char fn[64];
+ FILE *btfile;
- snprintf(fn, 64, "%s_%d.c", argv[1], j);
- btfile = fopen(fn, "w+");
- if (btfile == NULL) {
- fprintf(stderr,
- _("Error opening file `%s': %s\n"),
- fn, strerror(errno));
- exit(-1);
+ snprintf (fn, 64, "%s_%d.c", argv[1], j);
+ btfile = fopen (fn, "w+");
+ if (btfile == NULL)
+ {
+ fprintf (stderr,
+ _("Error opening file `%s': %s\n"), fn, strerror (errno));
+ exit (-1);
+ }
+ fprintf (btfile, "int %s_bits_%d[] = { ", argv[2], j);
+ for (i = j * (bf.bitArraySize / sizeof (int) / SUBTABLES);
+ i < (j + 1) * (bf.bitArraySize / sizeof (int) / SUBTABLES); i++)
+ fprintf (btfile, "%dL,", (((int *) bf.bitArray)[i]));
+ fprintf (btfile, "};\n");
+ fclose (btfile);
+ fprintf (stdout, "extern int %s_bits_%d[];\n", argv[2], j);
}
- fprintf(btfile,
- "int %s_bits_%d[] = { ", argv[2], j);
- for (i= j * (bf.bitArraySize/sizeof(int)/SUBTABLES);
- i<(j+1) * (bf.bitArraySize/sizeof(int)/SUBTABLES);
- i++)
- fprintf(btfile,
- "%dL,",
- (((int*)bf.bitArray)[i]));
- fprintf(btfile,
- "};\n");
- fclose(btfile);
- fprintf(stdout,
- "extern int %s_bits_%d[];\n", argv[2], j);
- }
- fprintf(stdout,
- "static int * bits[] = { ");
- for (i=0;i<SUBTABLES;i++)
- fprintf(stdout,
- "%s_bits_%d,",
- argv[2],
- i);
- fprintf(stdout,
- "};\n");
- bn = &argv[1][strlen(argv[1])];
- while ( (bn != argv[1]) &&
- (bn[0] != '/') )
+ fprintf (stdout, "static int * bits[] = { ");
+ for (i = 0; i < SUBTABLES; i++)
+ fprintf (stdout, "%s_bits_%d,", argv[2], i);
+ fprintf (stdout, "};\n");
+ bn = &argv[1][strlen (argv[1])];
+ while ((bn != argv[1]) && (bn[0] != '/'))
bn--;
if (bn[0] == '/')
bn++;
- fprintf(stdout,
- "Bloomfilter libextractor_printable_%s_filter = {\n"
- " %u,\n"
- " NULL,\n" /* bitarray */
- " (unsigned char **)bits,\n" /* sbitArray */
- " %u };\n",
- bn,
- ADDR_PER_ELEMENT,
- bf.bitArraySize);
- free(charset);
+ fprintf (stdout, "Bloomfilter libextractor_printable_%s_filter = {\n" "
%u,\n" " NULL,\n" /* bitarray */
+ " (unsigned char **)bits,\n" /* sbitArray */
+ " %u };\n", bn, ADDR_PER_ELEMENT, bf.bitArraySize);
+ free (charset);
return 0;
}
Modified: Extractor/src/plugins/psextractor.c
===================================================================
--- Extractor/src/plugins/psextractor.c 2007-07-29 08:04:12 UTC (rev 5367)
+++ Extractor/src/plugins/psextractor.c 2007-07-29 08:35:49 UTC (rev 5368)
@@ -21,101 +21,101 @@
#include "platform.h"
#include "extractor.h"
-static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordType type,
- char * keyword,
- struct EXTRACTOR_Keywords * next)
{
- EXTRACTOR_KeywordList * result;
+static struct EXTRACTOR_Keywords *
+addKeyword (EXTRACTOR_KeywordType type,
+ char *keyword, struct EXTRACTOR_Keywords *next)
+{
+ EXTRACTOR_KeywordList *result;
if (keyword == NULL)
return next;
- result = malloc(sizeof(EXTRACTOR_KeywordList));
+ result = malloc (sizeof (EXTRACTOR_KeywordList));
result->next = next;
- result->keyword = strdup(keyword);
+ result->keyword = strdup (keyword);
result->keywordType = type;
return result;
}
-static char * readline(char * data,
- size_t size,
- size_t pos) {
+static char *
+readline (char *data, size_t size, size_t pos)
+{
size_t end;
- char * res;
+ char *res;
- while ( ( pos < size) &&
- ( (data[pos] == (char)0x0d) ||
- (data[pos] == (char)0x0a) ) )
+ while ((pos < size) &&
+ ((data[pos] == (char) 0x0d) || (data[pos] == (char) 0x0a)))
pos++;
-
+
if (pos >= size)
- return NULL; /* end of file */
+ return NULL; /* end of file */
end = pos;
- while ( (end < size) &&
- (data[end] != (char)0x0d) &&
- (data[end] != (char)0x0a) )
+ while ((end < size) &&
+ (data[end] != (char) 0x0d) && (data[end] != (char) 0x0a))
end++;
- res = malloc(end-pos+1);
- memcpy(res,
- &data[pos],
- end-pos);
- res[end-pos] = '\0';
-
+ res = malloc (end - pos + 1);
+ memcpy (res, &data[pos], end - pos);
+ res[end - pos] = '\0';
+
return res;
}
-static struct EXTRACTOR_Keywords * testmeta(char * line,
- const char * match,
- EXTRACTOR_KeywordType type,
- struct EXTRACTOR_Keywords * prev) {
- if ( (strncmp(line, match, strlen(match)) == 0) &&
- (strlen(line) > strlen(match) ) ) {
- char * key;
+static struct EXTRACTOR_Keywords *
+testmeta (char *line,
+ const char *match,
+ EXTRACTOR_KeywordType type, struct EXTRACTOR_Keywords *prev)
+{
+ if ((strncmp (line, match, strlen (match)) == 0) &&
+ (strlen (line) > strlen (match)))
+ {
+ char *key;
- if ( (line[strlen(line)-1] == ')') &&
- (line[strlen(match)] == '(') ) {
- key = &line[strlen(match)+1];
- key[strlen(key)-1] = '\0'; /* remove ")" */
- } else {
- key = &line[strlen(match)];
+ if ((line[strlen (line) - 1] == ')') && (line[strlen (match)] == '('))
+ {
+ key = &line[strlen (match) + 1];
+ key[strlen (key) - 1] = '\0'; /* remove ")" */
+ }
+ else
+ {
+ key = &line[strlen (match)];
+ }
+ prev = addKeyword (type, key, prev);
}
- prev = addKeyword(type,
- key,
- prev);
- }
return prev;
}
-typedef struct {
- char * prefix;
+typedef struct
+{
+ char *prefix;
EXTRACTOR_KeywordType type;
} Matches;
static Matches tests[] = {
- { "%%Title: ", EXTRACTOR_TITLE },
- { "%%Version: ", EXTRACTOR_VERSIONNUMBER },
- { "%%Creator: ", EXTRACTOR_CREATOR },
- { "%%CreationDate: ", EXTRACTOR_CREATION_DATE },
- { "%%Pages: ", EXTRACTOR_PAGE_COUNT },
- { "%%Orientation: ", EXTRACTOR_UNKNOWN },
- { "%%DocumentPaperSizes: ", EXTRACTOR_UNKNOWN },
- { "%%DocumentFonts: ", EXTRACTOR_UNKNOWN },
- { "%%PageOrder: ", EXTRACTOR_UNKNOWN },
- { "%%For: ", EXTRACTOR_UNKNOWN },
- { "%%Magnification: ", EXTRACTOR_UNKNOWN },
+ {"%%Title: ", EXTRACTOR_TITLE},
+ {"%%Version: ", EXTRACTOR_VERSIONNUMBER},
+ {"%%Creator: ", EXTRACTOR_CREATOR},
+ {"%%CreationDate: ", EXTRACTOR_CREATION_DATE},
+ {"%%Pages: ", EXTRACTOR_PAGE_COUNT},
+ {"%%Orientation: ", EXTRACTOR_UNKNOWN},
+ {"%%DocumentPaperSizes: ", EXTRACTOR_UNKNOWN},
+ {"%%DocumentFonts: ", EXTRACTOR_UNKNOWN},
+ {"%%PageOrder: ", EXTRACTOR_UNKNOWN},
+ {"%%For: ", EXTRACTOR_UNKNOWN},
+ {"%%Magnification: ", EXTRACTOR_UNKNOWN},
/* Also widely used but not supported since they
probably make no sense:
- "%%BoundingBox: ",
- "%%DocumentNeededResources: ",
- "%%DocumentSuppliedResources: ",
- "%%DocumentProcSets: ",
- "%%DocumentData: ", */
+ "%%BoundingBox: ",
+ "%%DocumentNeededResources: ",
+ "%%DocumentSuppliedResources: ",
+ "%%DocumentProcSets: ",
+ "%%DocumentData: ", */
- { NULL, 0 },
+ {NULL, 0},
};
/* which mime-types should not be subjected to
the PostScript extractor (no use trying) */
-static char * blacklist[] = {
+static char *blacklist[] = {
"image/jpeg",
"image/gif",
"image/png",
@@ -142,89 +142,85 @@
};
/* mimetype = application/postscript */
-struct EXTRACTOR_Keywords * libextractor_ps_extract(const char * filename,
- char * data,
- size_t size,
- struct EXTRACTOR_Keywords
* prev) {
+struct EXTRACTOR_Keywords *
+libextractor_ps_extract (const char *filename,
+ char *data,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
size_t pos;
- char * psheader = "%!PS-Adobe";
- char * line;
+ char *psheader = "%!PS-Adobe";
+ char *line;
int i;
int lastLine;
- const char * mime;
+ const char *mime;
/* if the mime-type of the file is blacklisted, don't
run the printable extactor! */
- mime = EXTRACTOR_extractLast(EXTRACTOR_MIMETYPE,
- prev);
- if (mime != NULL) {
- int j;
- j = 0;
- while (blacklist[j] != NULL) {
- if (0 == strcmp(blacklist[j], mime))
- return prev;
- j++;
+ mime = EXTRACTOR_extractLast (EXTRACTOR_MIMETYPE, prev);
+ if (mime != NULL)
+ {
+ int j;
+ j = 0;
+ while (blacklist[j] != NULL)
+ {
+ if (0 == strcmp (blacklist[j], mime))
+ return prev;
+ j++;
+ }
}
- }
pos = 0;
- while ( (pos < size) &&
- (pos < strlen(psheader)) &&
- (data[pos] == psheader[pos]) )
+ while ((pos < size) &&
+ (pos < strlen (psheader)) && (data[pos] == psheader[pos]))
pos++;
- if (pos != strlen(psheader)) {
- return prev; /* no ps */
- }
+ if (pos != strlen (psheader))
+ {
+ return prev; /* no ps */
+ }
- prev = addKeyword(EXTRACTOR_MIMETYPE,
- "application/postscript",
- prev);
+ prev = addKeyword (EXTRACTOR_MIMETYPE, "application/postscript", prev);
/* skip rest of first line */
- while ( (pos<size) && (data[pos] != '\n') )
+ while ((pos < size) && (data[pos] != '\n'))
pos++;
lastLine = -1;
- line = strdup(psheader);
+ line = strdup (psheader);
/* while Windows-PostScript does not seem to (always?) put
"%%EndComments", this should allow us to not read through most of
the file for all the sane applications... For Windows-generated
PS files, we will bail out at the end of the file. */
- while (0 != strncmp("%%EndComments",
- line,
- strlen("%%EndComments"))) {
- free(line);
- line = readline(data, size, pos);
- if (line == NULL)
- break;
- i=0;
- while (tests[i].prefix != NULL) {
- prev = testmeta(line,
- tests[i].prefix,
- tests[i].type,
- prev);
- i++;
- }
+ while (0 != strncmp ("%%EndComments", line, strlen ("%%EndComments")))
+ {
+ free (line);
+ line = readline (data, size, pos);
+ if (line == NULL)
+ break;
+ i = 0;
+ while (tests[i].prefix != NULL)
+ {
+ prev = testmeta (line, tests[i].prefix, tests[i].type, prev);
+ i++;
+ }
- /* %%+ continues previous meta-data type... */
- if ( (lastLine != -1) &&
- (0 == strncmp(line, "%%+ ", strlen("%%+ "))) ) {
- prev = testmeta(line,
- "%%+ ",
- tests[lastLine].type,
- prev);
- } else {
- /* update "previous" type */
- if (tests[i].prefix == NULL)
- lastLine = -1;
+ /* %%+ continues previous meta-data type... */
+ if ((lastLine != -1) && (0 == strncmp (line, "%%+ ", strlen ("%%+ "))))
+ {
+ prev = testmeta (line, "%%+ ", tests[lastLine].type, prev);
+ }
else
- lastLine = i;
+ {
+ /* update "previous" type */
+ if (tests[i].prefix == NULL)
+ lastLine = -1;
+ else
+ lastLine = i;
+ }
+ pos += strlen (line) + 1; /* skip newline, too; guarantee progress! */
}
- pos += strlen(line)+1; /* skip newline, too; guarantee progress! */
- }
- free(line);
+ free (line);
return prev;
}
Modified: Extractor/src/plugins/qtextractor.c
===================================================================
--- Extractor/src/plugins/qtextractor.c 2007-07-29 08:04:12 UTC (rev 5367)
+++ Extractor/src/plugins/qtextractor.c 2007-07-29 08:35:49 UTC (rev 5368)
@@ -25,36 +25,40 @@
#define DEBUG 0
-typedef struct {
+typedef struct
+{
unsigned int size;
unsigned int type;
} Atom;
-typedef struct {
+typedef struct
+{
unsigned int one;
unsigned int type;
unsigned long long size;
} LongAtom;
-static unsigned long long ntohll(unsigned long long n) {
+static unsigned long long
+ntohll (unsigned long long n)
+{
#if __BYTE_ORDER == __BIG_ENDIAN
return n;
#else
- return (((unsigned long long)ntohl(n)) << 32) + ntohl(n >> 32);
+ return (((unsigned long long) ntohl (n)) << 32) + ntohl (n >> 32);
#endif
}
static void
-addKeyword(EXTRACTOR_KeywordType type,
- const char * keyword,
- struct EXTRACTOR_Keywords ** list) {
- EXTRACTOR_KeywordList * result;
+addKeyword (EXTRACTOR_KeywordType type,
+ const char *keyword, struct EXTRACTOR_Keywords **list)
+{
+ EXTRACTOR_KeywordList *result;
if (keyword == NULL)
return;
- result = malloc(sizeof(EXTRACTOR_KeywordList));
+ result = malloc (sizeof (EXTRACTOR_KeywordList));
result->next = *list;
- result->keyword = strdup(keyword);
+ result->keyword = strdup (keyword);
result->keywordType = type;
*list = result;
}
@@ -64,70 +68,73 @@
* Check if at position pos there is a valid atom.
* @return 0 if the atom is invalid, 1 if it is valid
*/
-static int checkAtomValid(const char * buffer,
- size_t size,
- size_t pos) {
+static int
+checkAtomValid (const char *buffer, size_t size, size_t pos)
+{
unsigned long long atomSize;
- const Atom * atom;
- const LongAtom * latom;
- if ( (pos >= size) ||
- (pos + sizeof(Atom) > size) ||
- (pos + sizeof(Atom) < pos) )
+ const Atom *atom;
+ const LongAtom *latom;
+ if ((pos >= size) ||
+ (pos + sizeof (Atom) > size) || (pos + sizeof (Atom) < pos))
return 0;
- atom = (const Atom*) &buffer[pos];
- if (ntohl(atom->size) == 1) {
- if ( (pos + sizeof(LongAtom) > size) ||
- (pos + sizeof(LongAtom) < pos) )
- return 0;
- latom = (const LongAtom*) &buffer[pos];
- atomSize = ntohll(latom->size);
- if ( (atomSize < sizeof(LongAtom)) ||
- (atomSize + pos > size) ||
- (atomSize + pos < atomSize) )
- return 0;
- } else {
- atomSize = ntohl(atom->size);
- if ( (atomSize < sizeof(Atom)) ||
- (atomSize + pos > size) ||
- (atomSize + pos < atomSize) )
- return 0;
- }
+ atom = (const Atom *) &buffer[pos];
+ if (ntohl (atom->size) == 1)
+ {
+ if ((pos + sizeof (LongAtom) > size) || (pos + sizeof (LongAtom) < pos))
+ return 0;
+ latom = (const LongAtom *) &buffer[pos];
+ atomSize = ntohll (latom->size);
+ if ((atomSize < sizeof (LongAtom)) ||
+ (atomSize + pos > size) || (atomSize + pos < atomSize))
+ return 0;
+ }
+ else
+ {
+ atomSize = ntohl (atom->size);
+ if ((atomSize < sizeof (Atom)) ||
+ (atomSize + pos > size) || (atomSize + pos < atomSize))
+ return 0;
+ }
return 1;
}
/**
* Assumes that checkAtomValid has already been called.
*/
-static unsigned long long getAtomSize(const char * buf) {
- const Atom * atom;
- const LongAtom * latom;
- atom = (const Atom*) buf;
- if (ntohl(atom->size) == 1) {
- latom = (const LongAtom*) buf;
- return ntohll(latom->size);
- }
- return ntohl(atom->size);
+static unsigned long long
+getAtomSize (const char *buf)
+{
+ const Atom *atom;
+ const LongAtom *latom;
+ atom = (const Atom *) buf;
+ if (ntohl (atom->size) == 1)
+ {
+ latom = (const LongAtom *) buf;
+ return ntohll (latom->size);
+ }
+ return ntohl (atom->size);
}
/**
* Assumes that checkAtomValid has already been called.
*/
-static unsigned int getAtomHeaderSize(const char * buf) {
- const Atom * atom;
+static unsigned int
+getAtomHeaderSize (const char *buf)
+{
+ const Atom *atom;
- atom = (const Atom*) buf;
- if (ntohl(atom->size) == 1)
- return sizeof(const LongAtom);
- return sizeof(Atom);
+ atom = (const Atom *) buf;
+ if (ntohl (atom->size) == 1)
+ return sizeof (const LongAtom);
+ return sizeof (Atom);
}
/**
* Assumes that checkAtomValid has already been called.
*/
-typedef int (*AtomHandler)(const char * input,
- size_t size,
- size_t pos,
- struct EXTRACTOR_Keywords ** list);
+typedef int (*AtomHandler) (const char *input,
+ size_t size,
+ size_t pos, struct EXTRACTOR_Keywords ** list);
/**
* Call the handler for the atom at the given position.
@@ -135,31 +142,29 @@
*
* @return 0 on error, 1 for success, -1 for unknown atom type
*/
-static int handleAtom(const char * input,
- size_t size,
- size_t pos,
- struct EXTRACTOR_Keywords ** list);
+static int handleAtom (const char *input,
+ size_t size,
+ size_t pos, struct EXTRACTOR_Keywords **list);
/**
* Process all atoms.
* @return 0 on error, 1 for success, -1 for unknown atom type
*/
-static int processAllAtoms(const char * input,
- size_t size,
- struct EXTRACTOR_Keywords ** list) {
+static int
+processAllAtoms (const char *input,
+ size_t size, struct EXTRACTOR_Keywords **list)
+{
size_t pos;
- if (size < sizeof(Atom))
+ if (size < sizeof (Atom))
return 1;
pos = 0;
- while (pos < size - sizeof(Atom)) {
- if (0 == handleAtom(input,
- size,
- pos,
- list))
- return 0;
- pos += getAtomSize(&input[pos]);
- }
+ while (pos < size - sizeof (Atom))
+ {
+ if (0 == handleAtom (input, size, pos, list))
+ return 0;
+ pos += getAtomSize (&input[pos]);
+ }
return 1;
}
@@ -167,17 +172,17 @@
* Handle the moov atom.
* @return 0 on error, 1 for success, -1 for unknown atom type
*/
-static int moovHandler(const char * input,
- size_t size,
- size_t pos,
- struct EXTRACTOR_Keywords ** list) {
- unsigned int hdr = getAtomHeaderSize(&input[pos]);
- return processAllAtoms(&input[pos+hdr],
- getAtomSize(&input[pos]) - hdr,
- list);
+static int
+moovHandler (const char *input,
+ size_t size, size_t pos, struct EXTRACTOR_Keywords **list)
+{
+ unsigned int hdr = getAtomHeaderSize (&input[pos]);
+ return processAllAtoms (&input[pos + hdr],
+ getAtomSize (&input[pos]) - hdr, list);
}
-typedef struct {
+typedef struct
+{
Atom header;
/* major brand */
char type[4];
@@ -187,52 +192,51 @@
char compatibility[4];
} FileType;
-typedef struct {
- const char * ext;
- const char * mime;
+typedef struct
+{
+ const char *ext;
+ const char *mime;
} C2M;
static C2M ftMap[] = {
- { "qt ", "video/quicktime" },
- { "isom", "video/mp4" }, /* ISO Base Media files */
- { "mp41", "video/mp4" }, /* MPEG-4 (ISO/IEC 14491-1) version 1 */
- { "mp42", "video/mp4" }, /* MPEG-4 (ISO/IEC 14491-1) version 2 */
- { "3gp1", "video/3gpp"},
- { "3gp2", "video/3gpp"},
- { "3gp3", "video/3gpp"},
- { "3gp4", "video/3gpp"},
- { "3gp5", "video/3gpp"},
- { "3g2a", "video/3gpp2"},
- { "mmp4", "video/mp4"}, /* Mobile MPEG-4 */
- { "M4A ", "video/mp4"},
- { "M4P ", "video/mp4"},
- { "mjp2", "video/mj2"}, /* Motion JPEG 2000 */
- { NULL, NULL },
+ {"qt ", "video/quicktime"},
+ {"isom", "video/mp4"}, /* ISO Base Media files */
+ {"mp41", "video/mp4"}, /* MPEG-4 (ISO/IEC 14491-1) version 1 */
+ {"mp42", "video/mp4"}, /* MPEG-4 (ISO/IEC 14491-1) version 2 */
+ {"3gp1", "video/3gpp"},
+ {"3gp2", "video/3gpp"},
+ {"3gp3", "video/3gpp"},
+ {"3gp4", "video/3gpp"},
+ {"3gp5", "video/3gpp"},
+ {"3g2a", "video/3gpp2"},
+ {"mmp4", "video/mp4"}, /* Mobile MPEG-4 */
+ {"M4A ", "video/mp4"},
+ {"M4P ", "video/mp4"},
+ {"mjp2", "video/mj2"}, /* Motion JPEG 2000 */
+ {NULL, NULL},
};
-static int ftypHandler(const char * input,
- size_t size,
- size_t pos,
- struct EXTRACTOR_Keywords ** list) {
- const FileType * ft;
+static int
+ftypHandler (const char *input,
+ size_t size, size_t pos, struct EXTRACTOR_Keywords **list)
+{
+ const FileType *ft;
int i;
- if (getAtomSize(&input[pos]) != sizeof(FileType))
+ if (getAtomSize (&input[pos]) != sizeof (FileType))
return 0;
- ft = (const FileType* ) &input[pos];
+ ft = (const FileType *) &input[pos];
i = 0;
- while ( (ftMap[i].ext != NULL) &&
- (0 != memcmp(ft->type, ftMap[i].ext, 4)) )
+ while ((ftMap[i].ext != NULL) && (0 != memcmp (ft->type, ftMap[i].ext, 4)))
i++;
if (ftMap[i].ext != NULL)
- addKeyword(EXTRACTOR_MIMETYPE,
- ftMap[i].mime,
- list);
+ addKeyword (EXTRACTOR_MIMETYPE, ftMap[i].mime, list);
return 1;
}
-typedef struct {
+typedef struct
+{
Atom hdr;
unsigned char version;
unsigned char flags[3];
@@ -261,23 +265,22 @@
unsigned int nextTrackId;
} MovieHeaderAtom;
-static int mvhdHandler(const char * input,
- size_t size,
- size_t pos,
- struct EXTRACTOR_Keywords ** list) {
- const MovieHeaderAtom * m;
+static int
+mvhdHandler (const char *input,
+ size_t size, size_t pos, struct EXTRACTOR_Keywords **list)
+{
+ const MovieHeaderAtom *m;
char duration[16];
- if (getAtomSize(&input[pos]) != sizeof(MovieHeaderAtom))
+ if (getAtomSize (&input[pos]) != sizeof (MovieHeaderAtom))
return 0;
- m = (const MovieHeaderAtom* ) &input[pos];
- snprintf(duration, 16, "%us", ntohl(m->duration) / ntohl(m->timeScale));
- addKeyword(EXTRACTOR_DURATION,
- duration,
- list);
+ m = (const MovieHeaderAtom *) &input[pos];
+ snprintf (duration, 16, "%us", ntohl (m->duration) / ntohl (m->timeScale));
+ addKeyword (EXTRACTOR_DURATION, duration, list);
return 1;
}
-typedef struct {
+typedef struct
+{
Atom cmovAtom;
Atom dcomAtom;
char compressor[4];
@@ -285,73 +288,77 @@
unsigned int decompressedSize;
} CompressedMovieHeaderAtom;
-static int cmovHandler(const char * input,
- size_t size,
- size_t pos,
- struct EXTRACTOR_Keywords ** list) {
- const CompressedMovieHeaderAtom * c;
+static int
+cmovHandler (const char *input,
+ size_t size, size_t pos, struct EXTRACTOR_Keywords **list)
+{
+ const CompressedMovieHeaderAtom *c;
unsigned int s;
- char * buf;
+ char *buf;
int ret;
z_stream z_state;
int z_ret_code;
- if (getAtomSize(&input[pos]) < sizeof(CompressedMovieHeaderAtom))
+ if (getAtomSize (&input[pos]) < sizeof (CompressedMovieHeaderAtom))
return 0;
- c = (const CompressedMovieHeaderAtom * ) &input[pos];
- if ( (ntohl(c->dcomAtom.size) != 12) ||
- (0 != memcmp(&c->dcomAtom.type, "dcom", 4)) ||
- (0 != memcmp(c->compressor, "zlib", 4)) ||
- (0 != memcmp(&c->cmvdAtom.type, "cmvd", 4)) ||
- (ntohl(c->cmvdAtom.size) != getAtomSize(&input[pos]) - sizeof(Atom) * 2
- 4)) {
- return 0; /* dcom must be 12 bytes */
- }
- s = ntohl(c->decompressedSize);
+ c = (const CompressedMovieHeaderAtom *) &input[pos];
+ if ((ntohl (c->dcomAtom.size) != 12) ||
+ (0 != memcmp (&c->dcomAtom.type, "dcom", 4)) ||
+ (0 != memcmp (c->compressor, "zlib", 4)) ||
+ (0 != memcmp (&c->cmvdAtom.type, "cmvd", 4)) ||
+ (ntohl (c->cmvdAtom.size) !=
+ getAtomSize (&input[pos]) - sizeof (Atom) * 2 - 4))
+ {
+ return 0; /* dcom must be 12 bytes */
+ }
+ s = ntohl (c->decompressedSize);
if (s > 16 * 1024 * 1024)
- return 1; /* ignore, too big! */
- buf = malloc(s);
+ return 1; /* ignore, too big! */
+ buf = malloc (s);
if (buf == NULL)
- return 1; /* out of memory, handle gracefully */
+ return 1; /* out of memory, handle gracefully */
- z_state.next_in = (unsigned char*) &c[1];
- z_state.avail_in = ntohl(c->cmvdAtom.size);
+ z_state.next_in = (unsigned char *) &c[1];
+ z_state.avail_in = ntohl (c->cmvdAtom.size);
z_state.avail_out = s;
- z_state.next_out = (unsigned char*) buf;
- z_state.zalloc = (alloc_func)0;
- z_state.zfree = (free_func)0;
- z_state.opaque = (voidpf)0;
+ z_state.next_out = (unsigned char *) buf;
+ z_state.zalloc = (alloc_func) 0;
+ z_state.zfree = (free_func) 0;
+ z_state.opaque = (voidpf) 0;
z_ret_code = inflateInit (&z_state);
- if (Z_OK != z_ret_code) {
- free(buf);
- return 0; /* crc error? */
- }
- z_ret_code = inflate(&z_state, Z_NO_FLUSH);
- if ((z_ret_code != Z_OK) && (z_ret_code != Z_STREAM_END)) {
- free(buf);
- return 0; /* decode error? */
- }
- z_ret_code = inflateEnd(&z_state);
- if (Z_OK != z_ret_code) {
- free(buf);
- return 0; /* decode error? */
- }
- ret = handleAtom(buf,
- s,
- 0,
- list);
- free(buf);
+ if (Z_OK != z_ret_code)
+ {
+ free (buf);
+ return 0; /* crc error? */
+ }
+ z_ret_code = inflate (&z_state, Z_NO_FLUSH);
+ if ((z_ret_code != Z_OK) && (z_ret_code != Z_STREAM_END))
+ {
+ free (buf);
+ return 0; /* decode error? */
+ }
+ z_ret_code = inflateEnd (&z_state);
+ if (Z_OK != z_ret_code)
+ {
+ free (buf);
+ return 0; /* decode error? */
+ }
+ ret = handleAtom (buf, s, 0, list);
+ free (buf);
return ret;
}
-typedef struct {
+typedef struct
+{
short integer;
short fraction;
} Fixed;
-typedef struct {
+typedef struct
+{
Atom hdr;
- unsigned int flags; /* 1 byte of version, 3 bytes of flags */
+ unsigned int flags; /* 1 byte of version, 3 bytes of flags */
/* in seconds since midnight, January 1, 1904 */
unsigned int creationTime;
/* in seconds since midnight, January 1, 1904 */
@@ -372,59 +379,57 @@
Fixed track_height;
} TrackAtom;
-static int tkhdHandler(const char * input,
- size_t size,
- size_t pos,
- struct EXTRACTOR_Keywords ** list) {
- const TrackAtom * m;
+static int
+tkhdHandler (const char *input,
+ size_t size, size_t pos, struct EXTRACTOR_Keywords **list)
+{
+ const TrackAtom *m;
char dimensions[40];
- if (getAtomSize(&input[pos]) < sizeof(TrackAtom))
+ if (getAtomSize (&input[pos]) < sizeof (TrackAtom))
return 0;
- m = (const TrackAtom* ) &input[pos];
- if (ntohs(m->track_width.integer) != 0) {
- /* if actually a/the video track */
- snprintf(dimensions,
- 40,
- "%dx%d",
- ntohs(m->track_width.integer),
- ntohs(m->track_height.integer));
- addKeyword(EXTRACTOR_FORMAT,
- dimensions,
- list);
- }
+ m = (const TrackAtom *) &input[pos];
+ if (ntohs (m->track_width.integer) != 0)
+ {
+ /* if actually a/the video track */
+ snprintf (dimensions,
+ 40,
+ "%dx%d",
+ ntohs (m->track_width.integer),
+ ntohs (m->track_height.integer));
+ addKeyword (EXTRACTOR_FORMAT, dimensions, list);
+ }
return 1;
}
-static int trakHandler(const char * input,
- size_t size,
- size_t pos,
- struct EXTRACTOR_Keywords ** list) {
- unsigned int hdr = getAtomHeaderSize(&input[pos]);
- return processAllAtoms(&input[pos+hdr],
- getAtomSize(&input[pos]) - hdr,
- list);
+static int
+trakHandler (const char *input,
+ size_t size, size_t pos, struct EXTRACTOR_Keywords **list)
+{
+ unsigned int hdr = getAtomHeaderSize (&input[pos]);
+ return processAllAtoms (&input[pos + hdr],
+ getAtomSize (&input[pos]) - hdr, list);
}
-static int metaHandler(const char * input,
- size_t size,
- size_t pos,
- struct EXTRACTOR_Keywords ** list) {
- unsigned int hdr = getAtomHeaderSize(&input[pos]);
- if (getAtomSize(&input[pos]) < hdr + 4)
+static int
+metaHandler (const char *input,
+ size_t size, size_t pos, struct EXTRACTOR_Keywords **list)
+{
+ unsigned int hdr = getAtomHeaderSize (&input[pos]);
+ if (getAtomSize (&input[pos]) < hdr + 4)
return 0;
- return processAllAtoms(&input[pos+hdr+4],
- getAtomSize(&input[pos]) - hdr - 4,
- list);
+ return processAllAtoms (&input[pos + hdr + 4],
+ getAtomSize (&input[pos]) - hdr - 4, list);
}
-typedef struct {
+typedef struct
+{
Atom header;
unsigned short length;
unsigned short language;
} InternationalText;
-static const char * languages[] = {
+static const char *languages[] = {
"English",
"French",
"German",
@@ -536,199 +541,191 @@
};
-static int processTextTag(const char * input,
- size_t size,
- size_t pos,
- EXTRACTOR_KeywordType type,
- struct EXTRACTOR_Keywords ** list) {
+static int
+processTextTag (const char *input,
+ size_t size,
+ size_t pos,
+ EXTRACTOR_KeywordType type, struct EXTRACTOR_Keywords **list)
+{
unsigned long long as;
unsigned short len;
unsigned short lang;
- const InternationalText * txt;
- char * meta;
+ const InternationalText *txt;
+ char *meta;
int i;
/* contains "international text":
- 16-bit size + 16 bit language code */
- as = getAtomSize(&input[pos]);
- if (as < sizeof(InternationalText))
- return 0; /* invalid */
- txt = (const InternationalText*) &input[pos];
- len = ntohs(txt->length);
- if (len + sizeof(InternationalText) > as)
- return 0; /* invalid */
- lang = ntohs(txt->language);
- if (lang >= sizeof(languages) / sizeof(char*))
- return 0; /* invalid */
- addKeyword(EXTRACTOR_LANGUAGE,
- languages[lang],
- list);
+ 16-bit size + 16 bit language code */
+ as = getAtomSize (&input[pos]);
+ if (as < sizeof (InternationalText))
+ return 0; /* invalid */
+ txt = (const InternationalText *) &input[pos];
+ len = ntohs (txt->length);
+ if (len + sizeof (InternationalText) > as)
+ return 0; /* invalid */
+ lang = ntohs (txt->language);
+ if (lang >= sizeof (languages) / sizeof (char *))
+ return 0; /* invalid */
+ addKeyword (EXTRACTOR_LANGUAGE, languages[lang], list);
/* TODO: what is the character set encoding here?
For now, let's assume it is Utf-8 (cannot find
anything in the public documentation) */
- meta = malloc(len + 1);
- memcpy(meta, &txt[1], len);
+ meta = malloc (len + 1);
+ memcpy (meta, &txt[1], len);
meta[len] = '\0';
- for (i=0;i<len;i++)
+ for (i = 0; i < len; i++)
if (meta[i] == '\r')
meta[i] = '\n';
- addKeyword(type,
- meta,
- list);
- free(meta);
+ addKeyword (type, meta, list);
+ free (meta);
return 1;
}
-typedef struct CHE {
- const char * pfx;
+typedef struct CHE
+{
+ const char *pfx;
EXTRACTOR_KeywordType type;
} CHE;
static CHE cHm[] = {
- { "aut", EXTRACTOR_AUTHOR, },
- { "cpy", EXTRACTOR_COPYRIGHT, },
- { "day", EXTRACTOR_CREATION_DATE, },
- { "cmt", EXTRACTOR_COMMENT, },
- { "hst", EXTRACTOR_BUILDHOST, },
- { "inf", EXTRACTOR_INFORMATION, },
- { "nam", EXTRACTOR_FULL_NAME, },
- { "mak", EXTRACTOR_CAMERA_MAKE, },
- { "mod", EXTRACTOR_CAMERA_MODEL, },
- { "des", EXTRACTOR_DESCRIPTION, },
- { "dis", EXTRACTOR_DISCLAIMER, },
- { "dir", EXTRACTOR_MOVIE_DIRECTOR, },
- { "src", EXTRACTOR_CONTRIBUTOR, },
- { "prf", EXTRACTOR_ARTIST, }, /* performer */
- { "req", EXTRACTOR_CREATED_FOR, }, /* hardware requirements */
- { "fmt", EXTRACTOR_FORMAT, },
- { "prd", EXTRACTOR_PRODUCER, },
- { "PRD", EXTRACTOR_PRODUCTVERSION, }, /* just product */
- { "swr", EXTRACTOR_SOFTWARE, },
- { "wrt", EXTRACTOR_AUTHOR, }, /* writer */
- { "wrn", EXTRACTOR_WARNING, },
- { "ed1", EXTRACTOR_REVISION_HISTORY, },
- { "ed2", EXTRACTOR_REVISION_HISTORY, },
- { "ed3", EXTRACTOR_REVISION_HISTORY, },
- { "ed4", EXTRACTOR_REVISION_HISTORY, },
- { "ed5", EXTRACTOR_REVISION_HISTORY, },
- { "ed6", EXTRACTOR_REVISION_HISTORY, },
- { "ed7", EXTRACTOR_REVISION_HISTORY, },
- { "ed8", EXTRACTOR_REVISION_HISTORY, },
- { "ed9", EXTRACTOR_REVISION_HISTORY, },
- { "chp", EXTRACTOR_CHAPTER, },
- { NULL, EXTRACTOR_UNKNOWN },
+ {"aut", EXTRACTOR_AUTHOR,},
+ {"cpy", EXTRACTOR_COPYRIGHT,},
+ {"day", EXTRACTOR_CREATION_DATE,},
+ {"cmt", EXTRACTOR_COMMENT,},
+ {"hst", EXTRACTOR_BUILDHOST,},
+ {"inf", EXTRACTOR_INFORMATION,},
+ {"nam", EXTRACTOR_FULL_NAME,},
+ {"mak", EXTRACTOR_CAMERA_MAKE,},
+ {"mod", EXTRACTOR_CAMERA_MODEL,},
+ {"des", EXTRACTOR_DESCRIPTION,},
+ {"dis", EXTRACTOR_DISCLAIMER,},
+ {"dir", EXTRACTOR_MOVIE_DIRECTOR,},
+ {"src", EXTRACTOR_CONTRIBUTOR,},
+ {"prf", EXTRACTOR_ARTIST,}, /* performer */
+ {"req", EXTRACTOR_CREATED_FOR,}, /* hardware requirements */
+ {"fmt", EXTRACTOR_FORMAT,},
+ {"prd", EXTRACTOR_PRODUCER,},
+ {"PRD", EXTRACTOR_PRODUCTVERSION,}, /* just product */
+ {"swr", EXTRACTOR_SOFTWARE,},
+ {"wrt", EXTRACTOR_AUTHOR,}, /* writer */
+ {"wrn", EXTRACTOR_WARNING,},
+ {"ed1", EXTRACTOR_REVISION_HISTORY,},
+ {"ed2", EXTRACTOR_REVISION_HISTORY,},
+ {"ed3", EXTRACTOR_REVISION_HISTORY,},
+ {"ed4", EXTRACTOR_REVISION_HISTORY,},
+ {"ed5", EXTRACTOR_REVISION_HISTORY,},
+ {"ed6", EXTRACTOR_REVISION_HISTORY,},
+ {"ed7", EXTRACTOR_REVISION_HISTORY,},
+ {"ed8", EXTRACTOR_REVISION_HISTORY,},
+ {"ed9", EXTRACTOR_REVISION_HISTORY,},
+ {"chp", EXTRACTOR_CHAPTER,},
+ {NULL, EXTRACTOR_UNKNOWN},
};
-static int c_Handler(const char * input,
- size_t size,
- size_t pos,
- struct EXTRACTOR_Keywords ** list) {
+static int
+c_Handler (const char *input,
+ size_t size, size_t pos, struct EXTRACTOR_Keywords **list)
+{
int i;
i = 0;
- while ( (cHm[i].pfx != NULL) &&
- (0 != memcmp(&input[5], cHm[i].pfx, 3)) )
+ while ((cHm[i].pfx != NULL) && (0 != memcmp (&input[5], cHm[i].pfx, 3)))
i++;
if (cHm[i].pfx != NULL)
- return processTextTag(input,
- size,
- pos,
- cHm[i].type,
- list);
- return -1; /* not found */
+ return processTextTag (input, size, pos, cHm[i].type, list);
+ return -1; /* not found */
}
-static int udtaHandler(const char * input,
- size_t size,
- size_t pos,
- struct EXTRACTOR_Keywords ** list) {
- unsigned int hdr = getAtomHeaderSize(&input[pos]);
- return processAllAtoms(&input[pos+hdr],
- getAtomSize(&input[pos]) - hdr,
- list);
+static int
+udtaHandler (const char *input,
+ size_t size, size_t pos, struct EXTRACTOR_Keywords **list)
+{
+ unsigned int hdr = getAtomHeaderSize (&input[pos]);
+ return processAllAtoms (&input[pos + hdr],
+ getAtomSize (&input[pos]) - hdr, list);
}
-typedef struct {
- char * name;
+typedef struct
+{
+ char *name;
AtomHandler handler;
} HandlerEntry;
static HandlerEntry handlers[] = {
- { "moov", &moovHandler },
- { "cmov", &cmovHandler },
- { "mvhd", &mvhdHandler },
- { "trak", &trakHandler },
- { "tkhd", &tkhdHandler },
- { "meta", &metaHandler },
- { "udta", &udtaHandler },
- { "ftyp", &ftypHandler },
- { "\xa9""swr", &c_Handler },
- { "\xa9""cpy", &c_Handler },
- { "\xa9""day", &c_Handler },
- { "\xa9""dir", &c_Handler },
- { "\xa9""ed1", &c_Handler },
- { "\xa9""ed2", &c_Handler },
- { "\xa9""ed3", &c_Handler },
- { "\xa9""ed4", &c_Handler },
- { "\xa9""ed5", &c_Handler },
- { "\xa9""ed6", &c_Handler },
- { "\xa9""ed7", &c_Handler },
- { "\xa9""ed8", &c_Handler },
- { "\xa9""ed9", &c_Handler },
- { "\xa9""fmt", &c_Handler },
- { "\xa9""inf", &c_Handler },
- { "\xa9""prd", &c_Handler },
- { "\xa9""prf", &c_Handler },
- { "\xa9""req", &c_Handler },
- { "\xa9""src", &c_Handler },
- { "\xa9""wrt", &c_Handler },
- { "\xa9""aut", &c_Handler },
- { "\xa9""hst", &c_Handler },
- { "\xa9""wrt", &c_Handler },
- { "\xa9""cmt", &c_Handler },
- { "\xa9""mak", &c_Handler },
- { "\xa9""mod", &c_Handler },
- { "\xa9""nam", &c_Handler },
- { "\xa9""des", &c_Handler },
- { "\xa9""PRD", &c_Handler },
- { "\xa9""wrn", &c_Handler },
- { "\xa9""chp", &c_Handler },
+ {"moov", &moovHandler},
+ {"cmov", &cmovHandler},
+ {"mvhd", &mvhdHandler},
+ {"trak", &trakHandler},
+ {"tkhd", &tkhdHandler},
+ {"meta", &metaHandler},
+ {"udta", &udtaHandler},
+ {"ftyp", &ftypHandler},
+ {"\xa9" "swr", &c_Handler},
+ {"\xa9" "cpy", &c_Handler},
+ {"\xa9" "day", &c_Handler},
+ {"\xa9" "dir", &c_Handler},
+ {"\xa9" "ed1", &c_Handler},
+ {"\xa9" "ed2", &c_Handler},
+ {"\xa9" "ed3", &c_Handler},
+ {"\xa9" "ed4", &c_Handler},
+ {"\xa9" "ed5", &c_Handler},
+ {"\xa9" "ed6", &c_Handler},
+ {"\xa9" "ed7", &c_Handler},
+ {"\xa9" "ed8", &c_Handler},
+ {"\xa9" "ed9", &c_Handler},
+ {"\xa9" "fmt", &c_Handler},
+ {"\xa9" "inf", &c_Handler},
+ {"\xa9" "prd", &c_Handler},
+ {"\xa9" "prf", &c_Handler},
+ {"\xa9" "req", &c_Handler},
+ {"\xa9" "src", &c_Handler},
+ {"\xa9" "wrt", &c_Handler},
+ {"\xa9" "aut", &c_Handler},
+ {"\xa9" "hst", &c_Handler},
+ {"\xa9" "wrt", &c_Handler},
+ {"\xa9" "cmt", &c_Handler},
+ {"\xa9" "mak", &c_Handler},
+ {"\xa9" "mod", &c_Handler},
+ {"\xa9" "nam", &c_Handler},
+ {"\xa9" "des", &c_Handler},
+ {"\xa9" "PRD", &c_Handler},
+ {"\xa9" "wrn", &c_Handler},
+ {"\xa9" "chp", &c_Handler},
/* { "name", &nameHandler }, */
- { NULL, NULL },
+ {NULL, NULL},
};
/**
* Call the handler for the atom at the given position.
* @return 0 on error, 1 for success, -1 for unknown atom type
*/
-static int handleAtom(const char * input,
- size_t size,
- size_t pos,
- struct EXTRACTOR_Keywords ** list) {
+static int
+handleAtom (const char *input,
+ size_t size, size_t pos, struct EXTRACTOR_Keywords **list)
+{
int i;
- if (0 == checkAtomValid(input, size, pos)) {
- return 0;
- }
+ if (0 == checkAtomValid (input, size, pos))
+ {
+ return 0;
+ }
i = 0;
- while ( (handlers[i].name != NULL) &&
- (0 != memcmp(&input[pos + 4], handlers[i].name, 4)) )
+ while ((handlers[i].name != NULL) &&
+ (0 != memcmp (&input[pos + 4], handlers[i].name, 4)))
i++;
- if (handlers[i].name == NULL) {
+ if (handlers[i].name == NULL)
+ {
#if DEBUG
- char b[5];
- memcpy(b, &input[pos+4], 4);
- b[4] = '\0';
- printf("No handler for `%s'\n",
- b);
+ char b[5];
+ memcpy (b, &input[pos + 4], 4);
+ b[4] = '\0';
+ printf ("No handler for `%s'\n", b);
#endif
- return -1;
- }
- i = handlers[i].handler(input, size, pos, list);
+ return -1;
+ }
+ i = handlers[i].handler (input, size, pos, list);
#if DEBUG
- printf("Running handler for `%4s' at %u completed with result %d\n",
- &input[pos + 4],
- pos,
- i);
+ printf ("Running handler for `%4s' at %u completed with result %d\n",
+ &input[pos + 4], pos, i);
#endif
return i;
}
@@ -739,13 +736,11 @@
application/x-quicktimeplayer: qtl: Quicktime list;
*/
struct EXTRACTOR_Keywords *
-libextractor_qt_extract(const char * filename,
- const char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev) {
- processAllAtoms(data,
- size,
- &prev);
+libextractor_qt_extract (const char *filename,
+ const char *data,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
+ processAllAtoms (data, size, &prev);
return prev;
}
Modified: Extractor/src/plugins/realextractor.c
===================================================================
--- Extractor/src/plugins/realextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/realextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -25,44 +25,46 @@
#define UINT16 unsigned short
#define UINT8 unsigned char
-typedef struct{
- UINT32 object_id;
- UINT32 size;
- UINT16 object_version; /* must be 0 */
- UINT16 stream_number;
- UINT32 max_bit_rate;
- UINT32 avg_bit_rate;
- UINT32 max_packet_size;
- UINT32 avg_packet_size;
- UINT32 start_time;
- UINT32 preroll;
- UINT32 duration;
- UINT8 stream_name_size;
- UINT8 data[0]; /* variable length section */
+typedef struct
+{
+ UINT32 object_id;
+ UINT32 size;
+ UINT16 object_version; /* must be 0 */
+ UINT16 stream_number;
+ UINT32 max_bit_rate;
+ UINT32 avg_bit_rate;
+ UINT32 max_packet_size;
+ UINT32 avg_packet_size;
+ UINT32 start_time;
+ UINT32 preroll;
+ UINT32 duration;
+ UINT8 stream_name_size;
+ UINT8 data[0]; /* variable length section */
/*
- UINT8[stream_name_size] stream_name;
- UINT8 mime_type_size;
- UINT8[mime_type_size] mime_type;
- UINT32 type_specific_len;
- UINT8[type_specific_len] type_specific_data;
- */
+ UINT8[stream_name_size] stream_name;
+ UINT8 mime_type_size;
+ UINT8[mime_type_size] mime_type;
+ UINT32 type_specific_len;
+ UINT8[type_specific_len] type_specific_data;
+ */
} Media_Properties;
-typedef struct {
- UINT32 object_id;
- UINT32 size;
- UINT16 object_version; /* must be 0 */
- UINT16 title_len;
- UINT8 data[0]; /* variable length section */
+typedef struct
+{
+ UINT32 object_id;
+ UINT32 size;
+ UINT16 object_version; /* must be 0 */
+ UINT16 title_len;
+ UINT8 data[0]; /* variable length section */
/*
- UINT8[title_len] title;
- UINT16 author_len;
- UINT8[author_len] author;
- UINT16 copyright_len;
- UINT8[copyright_len] copyright;
- UINT16 comment_len;
- UINT8[comment_len] comment;
- */
+ UINT8[title_len] title;
+ UINT16 author_len;
+ UINT8[author_len] author;
+ UINT16 copyright_len;
+ UINT8[copyright_len] copyright;
+ UINT16 comment_len;
+ UINT8[comment_len] comment;
+ */
} Content_Description;
/* author, copyright and comment are supposed to be ASCII */
@@ -73,14 +75,14 @@
#define RAFF4_HEADER 0x2E7261FD
static struct EXTRACTOR_Keywords *
-addKeyword(EXTRACTOR_KeywordType type,
- char * keyword,
- struct EXTRACTOR_Keywords * next) {
- EXTRACTOR_KeywordList * result;
+addKeyword (EXTRACTOR_KeywordType type,
+ char *keyword, struct EXTRACTOR_Keywords *next)
+{
+ EXTRACTOR_KeywordList *result;
if (keyword == NULL)
return next;
- result = malloc(sizeof(EXTRACTOR_KeywordList));
+ result = malloc (sizeof (EXTRACTOR_KeywordList));
result->next = next;
result->keyword = keyword;
result->keywordType = type;
@@ -88,128 +90,120 @@
}
static struct EXTRACTOR_Keywords *
-processMediaProperties(const Media_Properties * prop,
- struct EXTRACTOR_Keywords * prev) {
+processMediaProperties (const Media_Properties * prop,
+ struct EXTRACTOR_Keywords *prev)
+{
UINT8 mime_type_size;
UINT32 prop_size;
- char * data;
+ char *data;
- prop_size = ntohl(prop->size);
- if (prop_size <= sizeof(Media_Properties))
+ prop_size = ntohl (prop->size);
+ if (prop_size <= sizeof (Media_Properties))
return prev;
if (0 != prop->object_version)
return prev;
- if (prop_size <= prop->stream_name_size + sizeof(UINT8)
- + sizeof(Media_Properties))
+ if (prop_size <= prop->stream_name_size + sizeof (UINT8)
+ + sizeof (Media_Properties))
return prev;
mime_type_size = prop->data[prop->stream_name_size];
- if (prop_size <= prop->stream_name_size + sizeof(UINT8) +
- + mime_type_size + sizeof(Media_Properties))
+ if (prop_size <= prop->stream_name_size + sizeof (UINT8) +
+ +mime_type_size + sizeof (Media_Properties))
return prev;
- data = malloc(mime_type_size+1);
- memcpy(data,&prop->data[prop->stream_name_size+1],mime_type_size);
- data[mime_type_size]='\0';
+ data = malloc (mime_type_size + 1);
+ memcpy (data, &prop->data[prop->stream_name_size + 1], mime_type_size);
+ data[mime_type_size] = '\0';
- return addKeyword(EXTRACTOR_MIMETYPE,
- data,
- prev);
+ return addKeyword (EXTRACTOR_MIMETYPE, data, prev);
}
static struct EXTRACTOR_Keywords *
-processContentDescription(const Content_Description * prop,
- struct EXTRACTOR_Keywords * prev) {
+processContentDescription (const Content_Description * prop,
+ struct EXTRACTOR_Keywords *prev)
+{
UINT16 author_len;
UINT16 copyright_len;
UINT16 comment_len;
UINT16 title_len;
- char * title;
- char * author;
- char * copyright;
- char * comment;
+ char *title;
+ char *author;
+ char *copyright;
+ char *comment;
UINT32 prop_size;
- prop_size = ntohl(prop->size);
- if (prop_size <= sizeof(Content_Description))
+ prop_size = ntohl (prop->size);
+ if (prop_size <= sizeof (Content_Description))
return prev;
if (0 != prop->object_version)
return prev;
- title_len = ntohs(prop->title_len);
- if (prop_size <= title_len + sizeof(UINT16)
- + sizeof(Content_Description))
+ title_len = ntohs (prop->title_len);
+ if (prop_size <= title_len + sizeof (UINT16) + sizeof (Content_Description))
return prev;
- author_len = ntohs( *(UINT16*)&prop->data[title_len]);
+ author_len = ntohs (*(UINT16 *) & prop->data[title_len]);
- if (prop_size <= title_len + sizeof(UINT16)
- + author_len + sizeof(Content_Description))
+ if (prop_size <= title_len + sizeof (UINT16)
+ + author_len + sizeof (Content_Description))
return prev;
- copyright_len =ntohs( *(UINT16*)&prop->data[title_len+
- author_len+
- sizeof(UINT16)]);
+ copyright_len = ntohs (*(UINT16 *) & prop->data[title_len +
+ author_len +
+ sizeof (UINT16)]);
- if (prop_size <= title_len + 2*sizeof(UINT16)
- + author_len + copyright_len + sizeof(Content_Description))
+ if (prop_size <= title_len + 2 * sizeof (UINT16)
+ + author_len + copyright_len + sizeof (Content_Description))
return prev;
- comment_len = ntohs( *(UINT16*)&prop->data[title_len+
- author_len+
- copyright_len+
- 2*sizeof(UINT16)]);
+ comment_len = ntohs (*(UINT16 *) & prop->data[title_len +
+ author_len +
+ copyright_len +
+ 2 * sizeof (UINT16)]);
- if (prop_size < title_len + 3*sizeof(UINT16)
+ if (prop_size < title_len + 3 * sizeof (UINT16)
+ author_len + copyright_len + comment_len
- + sizeof(Content_Description))
+ + sizeof (Content_Description))
return prev;
- title = malloc(title_len+1);
- memcpy(title,&prop->data[0],title_len);
- title[title_len]='\0';
+ title = malloc (title_len + 1);
+ memcpy (title, &prop->data[0], title_len);
+ title[title_len] = '\0';
- prev = addKeyword(EXTRACTOR_TITLE,
- title,
- prev);
+ prev = addKeyword (EXTRACTOR_TITLE, title, prev);
- author = malloc(author_len+1);
- memcpy(author,&prop->data[title_len+sizeof(UINT16)],author_len);
- author[author_len]='\0';
+ author = malloc (author_len + 1);
+ memcpy (author, &prop->data[title_len + sizeof (UINT16)], author_len);
+ author[author_len] = '\0';
- prev = addKeyword(EXTRACTOR_AUTHOR,
- author,
- prev);
+ prev = addKeyword (EXTRACTOR_AUTHOR, author, prev);
- copyright=malloc(copyright_len+1);
- memcpy(copyright,
- &prop->data[title_len + sizeof(UINT16)*2 + author_len],
- copyright_len);
- copyright[copyright_len]='\0';
+ copyright = malloc (copyright_len + 1);
+ memcpy (copyright,
+ &prop->data[title_len + sizeof (UINT16) * 2 + author_len],
+ copyright_len);
+ copyright[copyright_len] = '\0';
- prev = addKeyword(EXTRACTOR_COPYRIGHT,
- copyright,
- prev);
+ prev = addKeyword (EXTRACTOR_COPYRIGHT, copyright, prev);
- comment=malloc(comment_len+1);
- memcpy(comment,
- &prop->data[title_len + sizeof(UINT16)*3 + author_len + copyright_len],
- comment_len);
- comment[comment_len]='\0';
+ comment = malloc (comment_len + 1);
+ memcpy (comment,
+ &prop->data[title_len + sizeof (UINT16) * 3 + author_len +
+ copyright_len], comment_len);
+ comment[comment_len] = '\0';
- prev = addKeyword(EXTRACTOR_COMMENT,
- comment,
- prev);
+ prev = addKeyword (EXTRACTOR_COMMENT, comment, prev);
return prev;
}
-typedef struct RAFF4_header {
+typedef struct RAFF4_header
+{
unsigned short version;
unsigned short revision;
unsigned short header_length;
@@ -230,125 +224,126 @@
unsigned char copy_byte;
unsigned char stream_type;
/*
- unsigned char tlen;
- unsigned char title[tlen];
- unsigned char alen;
- unsigned char author[alen];
- unsigned char clen;
- unsigned char copyright[clen];
- unsigned char aplen;
- unsigned char app[aplen]; */
+ unsigned char tlen;
+ unsigned char title[tlen];
+ unsigned char alen;
+ unsigned char author[alen];
+ unsigned char clen;
+ unsigned char copyright[clen];
+ unsigned char aplen;
+ unsigned char app[aplen]; */
} RAFF4_header;
#define RAFF4_HDR_SIZE 53
-static char * stndup(const char * str,
- size_t n) {
- char * tmp;
- tmp = malloc(n+1);
+static char *
+stndup (const char *str, size_t n)
+{
+ char *tmp;
+ tmp = malloc (n + 1);
tmp[n] = '\0';
- memcpy(tmp, str, n);
+ memcpy (tmp, str, n);
return tmp;
}
/* audio/vnd.rn-realaudio */
-struct EXTRACTOR_Keywords * libextractor_real_extract(unsigned char * filename,
- const unsigned char *
data,
- size_t size,
- struct
EXTRACTOR_Keywords * prev) {
- const unsigned char * pos;
- const unsigned char * end;
- struct EXTRACTOR_Keywords * result;
+struct EXTRACTOR_Keywords *
+libextractor_real_extract (unsigned char *filename,
+ const unsigned char *data,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
+ const unsigned char *pos;
+ const unsigned char *end;
+ struct EXTRACTOR_Keywords *result;
unsigned int length;
- const RAFF4_header * hdr;
+ const RAFF4_header *hdr;
unsigned char tlen;
unsigned char alen;
unsigned char clen;
unsigned char aplen;
- if (size <= 2*sizeof(int))
+ if (size <= 2 * sizeof (int))
return prev;
- if (RAFF4_HEADER == ntohl(*(int*)data)) {
- /* HELIX */
- if (size <= RAFF4_HDR_SIZE + 16 + 4)
+ if (RAFF4_HEADER == ntohl (*(int *) data))
+ {
+ /* HELIX */
+ if (size <= RAFF4_HDR_SIZE + 16 + 4)
+ return prev;
+ prev = addKeyword (EXTRACTOR_MIMETYPE,
+ strdup ("audio/vnd.rn-realaudio"), prev);
+ hdr = (const RAFF4_header *) &data[16];
+ if (ntohs (hdr->header_length) + 16 > size)
+ return prev;
+ tlen = data[16 + RAFF4_HDR_SIZE];
+ if (tlen + RAFF4_HDR_SIZE + 20 > size)
+ return prev;
+ alen = data[17 + tlen + RAFF4_HDR_SIZE];
+ if (tlen + alen + RAFF4_HDR_SIZE + 20 > size)
+ return prev;
+ clen = data[18 + tlen + alen + RAFF4_HDR_SIZE];
+ if (tlen + alen + clen + RAFF4_HDR_SIZE + 20 > size)
+ return prev;
+ aplen = data[19 + tlen + clen + alen + RAFF4_HDR_SIZE];
+ if (tlen + alen + clen + aplen + RAFF4_HDR_SIZE + 20 > size)
+ return prev;
+
+ if (tlen > 0)
+ prev = addKeyword (EXTRACTOR_TITLE,
+ stndup ((const char *) &data[17 + RAFF4_HDR_SIZE],
+ tlen), prev);
+ if (alen > 0)
+ prev = addKeyword (EXTRACTOR_AUTHOR,
+ stndup ((const char *)
+ &data[18 + RAFF4_HDR_SIZE + tlen], alen),
+ prev);
+ if (clen > 0)
+ prev = addKeyword (EXTRACTOR_COPYRIGHT,
+ stndup ((const char *)
+ &data[19 + RAFF4_HDR_SIZE + tlen + alen],
+ clen), prev);
+ if (aplen > 0)
+ prev = addKeyword (EXTRACTOR_SOFTWARE,
+ stndup ((const char *)
+ &data[20 + RAFF4_HDR_SIZE + tlen + alen +
+ clen], aplen), prev);
return prev;
- prev = addKeyword(EXTRACTOR_MIMETYPE,
- strdup("audio/vnd.rn-realaudio"),
- prev);
- hdr = (const RAFF4_header*) &data[16];
- if (ntohs(hdr->header_length) + 16 > size)
- return prev;
- tlen = data[16 + RAFF4_HDR_SIZE];
- if (tlen + RAFF4_HDR_SIZE + 20 > size)
- return prev;
- alen = data[17 + tlen + RAFF4_HDR_SIZE];
- if (tlen + alen + RAFF4_HDR_SIZE + 20 > size)
- return prev;
- clen = data[18 + tlen + alen + RAFF4_HDR_SIZE];
- if (tlen + alen + clen + RAFF4_HDR_SIZE + 20 > size)
- return prev;
- aplen = data[19 + tlen + clen + alen + RAFF4_HDR_SIZE];
- if (tlen + alen + clen + aplen + RAFF4_HDR_SIZE + 20 > size)
- return prev;
- if (tlen > 0)
- prev = addKeyword(EXTRACTOR_TITLE,
- stndup((const char*) &data[17 + RAFF4_HDR_SIZE],
- tlen),
- prev);
- if (alen > 0)
- prev = addKeyword(EXTRACTOR_AUTHOR,
- stndup((const char*) &data[18 + RAFF4_HDR_SIZE + tlen],
- alen),
- prev);
- if (clen > 0)
- prev = addKeyword(EXTRACTOR_COPYRIGHT,
- stndup((const char*) &data[19 + RAFF4_HDR_SIZE + tlen +
alen],
- clen),
- prev);
- if (aplen > 0)
- prev = addKeyword(EXTRACTOR_SOFTWARE,
- stndup((const char*) &data[20 + RAFF4_HDR_SIZE + tlen +
alen + clen],
- aplen),
- prev);
- return prev;
-
- }
- if (REAL_HEADER == ntohl(*(int*)data)) {
- /* old real */
- result = prev;
- end = &data[size];
- pos = &data[0];
- while(1) {
- if ( (pos+8 >= end) ||
- (pos+8 < pos) )
- break;
- length = ntohl(*(((unsigned int*) pos)+1));
- if (length <= 0)
- break;
- if ( (pos + length >= end) ||
- (pos + length < pos) )
- break;
- switch (ntohl(*((unsigned int*) pos))) {
- case MDPR_HEADER:
- result = processMediaProperties((Media_Properties *)pos,
- result);
- pos += length;
- break;
- case CONT_HEADER:
- result = processContentDescription((Content_Description *)pos,
- result);
- pos += length;
- break;
- case REAL_HEADER: /* treat like default */
- default:
- pos += length;
- break;
- }
}
- return result;
- }
+ if (REAL_HEADER == ntohl (*(int *) data))
+ {
+ /* old real */
+ result = prev;
+ end = &data[size];
+ pos = &data[0];
+ while (1)
+ {
+ if ((pos + 8 >= end) || (pos + 8 < pos))
+ break;
+ length = ntohl (*(((unsigned int *) pos) + 1));
+ if (length <= 0)
+ break;
+ if ((pos + length >= end) || (pos + length < pos))
+ break;
+ switch (ntohl (*((unsigned int *) pos)))
+ {
+ case MDPR_HEADER:
+ result = processMediaProperties ((Media_Properties *) pos,
+ result);
+ pos += length;
+ break;
+ case CONT_HEADER:
+ result = processContentDescription ((Content_Description *) pos,
+ result);
+ pos += length;
+ break;
+ case REAL_HEADER: /* treat like default */
+ default:
+ pos += length;
+ break;
+ }
+ }
+ return result;
+ }
return prev;
}
-
Modified: Extractor/src/plugins/riffextractor.c
===================================================================
--- Extractor/src/plugins/riffextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/riffextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -30,11 +30,12 @@
#include "extractor.h"
#include <math.h>
-static void addKeyword(struct EXTRACTOR_Keywords ** list,
- char * keyword,
- EXTRACTOR_KeywordType type) {
- EXTRACTOR_KeywordList * next;
- next = malloc(sizeof(EXTRACTOR_KeywordList));
+static void
+addKeyword (struct EXTRACTOR_Keywords **list,
+ char *keyword, EXTRACTOR_KeywordType type)
+{
+ EXTRACTOR_KeywordList *next;
+ next = malloc (sizeof (EXTRACTOR_KeywordList));
next->next = *list;
next->keyword = keyword;
next->keywordType = type;
@@ -43,27 +44,24 @@
#ifdef FIXME
-static struct EXTRACTOR_Keywords * riffparse_INFO(char * buffer,
- size_t size,
- struct EXTRACTOR_Keywords *
prev) {
+static struct EXTRACTOR_Keywords *
+riffparse_INFO (char *buffer, size_t size, struct EXTRACTOR_Keywords *prev)
+{
size_t c = 0;
- char * word;
+ char *word;
if (size < 64)
return prev;
c = 8;
- while ( (c < size) && isprint(buffer[c]) )
+ while ((c < size) && isprint (buffer[c]))
c++;
- if (c > 8) {
- word = malloc(c+1-8);
- memcpy(word,
- &buffer[8],
- c - 8);
- word[c-8] = '\0';
- addKeyword(&prev,
- word,
- EXTRACTOR_UNKNOWN); /* eh, what exactly is it */
- }
+ if (c > 8)
+ {
+ word = malloc (c + 1 - 8);
+ memcpy (word, &buffer[8], c - 8);
+ word[c - 8] = '\0';
+ addKeyword (&prev, word, EXTRACTOR_UNKNOWN); /* eh, what exactly is
it */
+ }
return prev;
}
#endif
@@ -73,12 +71,14 @@
* Read the specified number of bytes as a little-endian (least
* significant byte first) integer.
*/
-static unsigned int fread_le(char * data) {
+static unsigned int
+fread_le (char *data)
+{
int x;
unsigned int result = 0;
- for(x=0;x<4; x++)
- result |= ((unsigned char)data[x]) << (x*8);
+ for (x = 0; x < 4; x++)
+ result |= ((unsigned char) data[x]) << (x * 8);
return result;
}
@@ -86,15 +86,18 @@
* C99's round(), nearbyint(), rint(), etc. seems to be spotty, whereas
* floor() is available in math.h on all C compilers.
*/
-static double round_double(double num) {
- return floor(num + 0.5);
+static double
+round_double (double num)
+{
+ return floor (num + 0.5);
}
/* video/x-msvideo */
-struct EXTRACTOR_Keywords * libextractor_riff_extract(char * filename,
- char * xdata,
- size_t xsize,
- struct EXTRACTOR_Keywords
* prev) {
+struct EXTRACTOR_Keywords *
+libextractor_riff_extract (char *filename,
+ char *xdata,
+ size_t xsize, struct EXTRACTOR_Keywords *prev)
+{
unsigned int blockLen;
unsigned int fps;
unsigned int duration;
@@ -102,87 +105,54 @@
unsigned int width;
unsigned int height;
char codec[5];
- char * format;
+ char *format;
if (xsize < 32)
return prev;
- if ( (memcmp(&xdata[0],
- "RIFF", 4) !=0) ||
- (memcmp(&xdata[8],
- "AVI ",
- 4) !=0) )
+ if ((memcmp (&xdata[0],
+ "RIFF", 4) != 0) || (memcmp (&xdata[8], "AVI ", 4) != 0))
return prev;
- if (memcmp(&xdata[12],
- "LIST",
- 4) != 0)
+ if (memcmp (&xdata[12], "LIST", 4) != 0)
return prev;
- if (memcmp(&xdata[20],
- "hdrlavih",
- 8) != 0)
+ if (memcmp (&xdata[20], "hdrlavih", 8) != 0)
return prev;
- blockLen = fread_le(&xdata[28]);
+ blockLen = fread_le (&xdata[28]);
/* begin of AVI header at 32 */
- fps = (unsigned int) round_double((double) 1.0e6 / fread_le(&xdata[32]));
- duration = (unsigned int) round_double((double) fread_le(&xdata[48])
- * 1000 / fps);
- width = fread_le(&xdata[64]);
- height = fread_le(&xdata[68]);
+ fps = (unsigned int) round_double ((double) 1.0e6 / fread_le (&xdata[32]));
+ duration = (unsigned int) round_double ((double) fread_le (&xdata[48])
+ * 1000 / fps);
+ width = fread_le (&xdata[64]);
+ height = fread_le (&xdata[68]);
/* pos: begin of video stream header */
pos = blockLen + 32;
- if ( (pos < blockLen) ||
- (pos + 32 > xsize) ||
- (pos > xsize) )
+ if ((pos < blockLen) || (pos + 32 > xsize) || (pos > xsize))
return prev;
- if (memcmp(&xdata[pos],
- "LIST",
- 4) != 0)
+ if (memcmp (&xdata[pos], "LIST", 4) != 0)
return prev;
- blockLen = fread_le(&xdata[pos+4]);
- if (memcmp(&xdata[pos+8],
- "strlstrh",
- 8) != 0)
+ blockLen = fread_le (&xdata[pos + 4]);
+ if (memcmp (&xdata[pos + 8], "strlstrh", 8) != 0)
return prev;
- if (memcmp(&xdata[pos+20],
- "vids",
- 4) != 0)
+ if (memcmp (&xdata[pos + 20], "vids", 4) != 0)
return prev;
/* pos + 24: video stream header */
- memcpy(codec,
- &xdata[pos+24],
- 4);
+ memcpy (codec, &xdata[pos + 24], 4);
codec[4] = '\0';
- format = malloc(256);
- snprintf(format,
- 256,
- _("codec: %s, %u fps, %u ms"),
- codec,
- fps,
- duration);
- addKeyword(&prev,
- format,
- EXTRACTOR_FORMAT);
- format = malloc(256);
- snprintf(format,
- 256,
- "%ux%u",
- width,
- height);
- addKeyword(&prev,
- format,
- EXTRACTOR_SIZE);
- addKeyword(&prev,
- strdup("video/x-msvideo"),
- EXTRACTOR_MIMETYPE);
+ format = malloc (256);
+ snprintf (format, 256, _("codec: %s, %u fps, %u ms"), codec, fps, duration);
+ addKeyword (&prev, format, EXTRACTOR_FORMAT);
+ format = malloc (256);
+ snprintf (format, 256, "%ux%u", width, height);
+ addKeyword (&prev, format, EXTRACTOR_SIZE);
+ addKeyword (&prev, strdup ("video/x-msvideo"), EXTRACTOR_MIMETYPE);
return prev;
}
-
Modified: Extractor/src/plugins/rpm/rpmextractor.c
===================================================================
--- Extractor/src/plugins/rpm/rpmextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/rpm/rpmextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -26,33 +26,34 @@
* the function so that it will now work. below is the
* original FIXME notice. -- Filip Pizlo 2003 */
/* FIXME: replace use of stpcpy to increase portability */
-static char *my_stpcpy(char *dest, const char *src) {
- strcpy(dest,src);
- return dest+strlen(src);
+static char *
+my_stpcpy (char *dest, const char *src)
+{
+ strcpy (dest, src);
+ return dest + strlen (src);
}
/* **************** buffer-based IO ************** */
-typedef struct {
- char * data;
+typedef struct
+{
+ char *data;
size_t pos;
size_t len;
} fdStruct;
-typedef fdStruct * FD_t;
+typedef fdStruct *FD_t;
-static int timedRead(FD_t f,
- void * dst,
- size_t n) {
+static int
+timedRead (FD_t f, void *dst, size_t n)
+{
size_t min;
if (f->len - f->pos >= n)
min = n;
else
min = f->len - f->pos;
- memcpy(dst,
- &f->data[f->pos],
- min);
+ memcpy (dst, &f->data[f->pos], min);
f->pos += min;
return min;
}
@@ -79,181 +80,182 @@
* Tags identify data in package headers.
* @note tags should not have value 0!
*/
-typedef enum rpmTag_e {
+typedef enum rpmTag_e
+{
- RPMTAG_HEADERIMAGE = HEADER_IMAGE, /*!< Current image. */
- RPMTAG_HEADERSIGNATURES = HEADER_SIGNATURES, /*!< Signatures. */
- RPMTAG_HEADERIMMUTABLE = HEADER_IMMUTABLE, /*!< Original image. */
+ RPMTAG_HEADERIMAGE = HEADER_IMAGE, /*!< Current image. */
+ RPMTAG_HEADERSIGNATURES = HEADER_SIGNATURES, /*!< Signatures. */
+ RPMTAG_HEADERIMMUTABLE = HEADER_IMMUTABLE, /*!< Original image. */
/address@hidden@*/
- RPMTAG_HEADERREGIONS = HEADER_REGIONS, /*!< Regions. */
+ RPMTAG_HEADERREGIONS = HEADER_REGIONS, /*!< Regions. */
- RPMTAG_HEADERI18NTABLE = HEADER_I18NTABLE, /*!< I18N string locales. */
+ RPMTAG_HEADERI18NTABLE = HEADER_I18NTABLE, /*!< I18N string locales. */
/address@hidden@*/
/* Retrofit (and uniqify) signature tags for use by tagName() and rpmQuery. */
/* the md5 sum was broken *twice* on big endian machines */
/* XXX 2nd underscore prevents tagTable generation */
- RPMTAG_SIG_BASE = HEADER_SIGBASE,
- RPMTAG_SIGSIZE = RPMTAG_SIG_BASE+1,
- RPMTAG_SIGLEMD5_1 = RPMTAG_SIG_BASE+2, /*!< internal -
obsolate */
- RPMTAG_SIGPGP = RPMTAG_SIG_BASE+3,
- RPMTAG_SIGLEMD5_2 = RPMTAG_SIG_BASE+4, /*!< internal -
obsolate */
- RPMTAG_SIGMD5 = RPMTAG_SIG_BASE+5,
- RPMTAG_SIGGPG = RPMTAG_SIG_BASE+6,
- RPMTAG_SIGPGP5 = RPMTAG_SIG_BASE+7, /*!< internal -
obsolate */
+ RPMTAG_SIG_BASE = HEADER_SIGBASE,
+ RPMTAG_SIGSIZE = RPMTAG_SIG_BASE + 1,
+ RPMTAG_SIGLEMD5_1 = RPMTAG_SIG_BASE + 2, /*!< internal - obsolate */
+ RPMTAG_SIGPGP = RPMTAG_SIG_BASE + 3,
+ RPMTAG_SIGLEMD5_2 = RPMTAG_SIG_BASE + 4, /*!< internal - obsolate */
+ RPMTAG_SIGMD5 = RPMTAG_SIG_BASE + 5,
+ RPMTAG_SIGGPG = RPMTAG_SIG_BASE + 6,
+ RPMTAG_SIGPGP5 = RPMTAG_SIG_BASE + 7, /*!< internal - obsolate */
- RPMTAG_BADSHA1_1 = RPMTAG_SIG_BASE+8, /*!< internal -
obsolate */
- RPMTAG_BADSHA1_2 = RPMTAG_SIG_BASE+9, /*!< internal -
obsolate */
+ RPMTAG_BADSHA1_1 = RPMTAG_SIG_BASE + 8, /*!< internal - obsolate */
+ RPMTAG_BADSHA1_2 = RPMTAG_SIG_BASE + 9, /*!< internal - obsolate */
- RPMTAG_PUBKEYS = RPMTAG_SIG_BASE+10,
- RPMTAG_DSAHEADER = RPMTAG_SIG_BASE+11,
- RPMTAG_RSAHEADER = RPMTAG_SIG_BASE+12,
- RPMTAG_SHA1HEADER = RPMTAG_SIG_BASE+13,
+ RPMTAG_PUBKEYS = RPMTAG_SIG_BASE + 10,
+ RPMTAG_DSAHEADER = RPMTAG_SIG_BASE + 11,
+ RPMTAG_RSAHEADER = RPMTAG_SIG_BASE + 12,
+ RPMTAG_SHA1HEADER = RPMTAG_SIG_BASE + 13,
- RPMTAG_NAME = 1000,
- RPMTAG_VERSION = 1001,
- RPMTAG_RELEASE = 1002,
- RPMTAG_EPOCH = 1003,
-#define RPMTAG_SERIAL RPMTAG_EPOCH /* backward comaptibility */
- RPMTAG_SUMMARY = 1004,
- RPMTAG_DESCRIPTION = 1005,
- RPMTAG_BUILDTIME = 1006,
- RPMTAG_BUILDHOST = 1007,
- RPMTAG_INSTALLTIME = 1008,
- RPMTAG_SIZE = 1009,
- RPMTAG_DISTRIBUTION = 1010,
- RPMTAG_VENDOR = 1011,
- RPMTAG_GIF = 1012,
- RPMTAG_XPM = 1013,
- RPMTAG_LICENSE = 1014,
-#define RPMTAG_COPYRIGHT RPMTAG_LICENSE /* backward comaptibility */
- RPMTAG_PACKAGER = 1015,
- RPMTAG_GROUP = 1016,
+ RPMTAG_NAME = 1000,
+ RPMTAG_VERSION = 1001,
+ RPMTAG_RELEASE = 1002,
+ RPMTAG_EPOCH = 1003,
+#define RPMTAG_SERIAL RPMTAG_EPOCH /* backward comaptibility */
+ RPMTAG_SUMMARY = 1004,
+ RPMTAG_DESCRIPTION = 1005,
+ RPMTAG_BUILDTIME = 1006,
+ RPMTAG_BUILDHOST = 1007,
+ RPMTAG_INSTALLTIME = 1008,
+ RPMTAG_SIZE = 1009,
+ RPMTAG_DISTRIBUTION = 1010,
+ RPMTAG_VENDOR = 1011,
+ RPMTAG_GIF = 1012,
+ RPMTAG_XPM = 1013,
+ RPMTAG_LICENSE = 1014,
+#define RPMTAG_COPYRIGHT RPMTAG_LICENSE /* backward comaptibility */
+ RPMTAG_PACKAGER = 1015,
+ RPMTAG_GROUP = 1016,
/address@hidden@*/
- RPMTAG_CHANGELOG = 1017, /*!< internal */
+ RPMTAG_CHANGELOG = 1017, /*!< internal */
/address@hidden@*/
- RPMTAG_SOURCE = 1018,
- RPMTAG_PATCH = 1019,
- RPMTAG_URL = 1020,
- RPMTAG_OS = 1021,
- RPMTAG_ARCH = 1022,
- RPMTAG_PREIN = 1023,
- RPMTAG_POSTIN = 1024,
- RPMTAG_PREUN = 1025,
- RPMTAG_POSTUN = 1026,
- RPMTAG_OLDFILENAMES = 1027, /* obsolete */
- RPMTAG_FILESIZES = 1028,
- RPMTAG_FILESTATES = 1029,
- RPMTAG_FILEMODES = 1030,
- RPMTAG_FILEUIDS = 1031, /*!< internal */
- RPMTAG_FILEGIDS = 1032, /*!< internal */
- RPMTAG_FILERDEVS = 1033,
- RPMTAG_FILEMTIMES = 1034,
- RPMTAG_FILEMD5S = 1035,
- RPMTAG_FILELINKTOS = 1036,
- RPMTAG_FILEFLAGS = 1037,
+ RPMTAG_SOURCE = 1018,
+ RPMTAG_PATCH = 1019,
+ RPMTAG_URL = 1020,
+ RPMTAG_OS = 1021,
+ RPMTAG_ARCH = 1022,
+ RPMTAG_PREIN = 1023,
+ RPMTAG_POSTIN = 1024,
+ RPMTAG_PREUN = 1025,
+ RPMTAG_POSTUN = 1026,
+ RPMTAG_OLDFILENAMES = 1027, /* obsolete */
+ RPMTAG_FILESIZES = 1028,
+ RPMTAG_FILESTATES = 1029,
+ RPMTAG_FILEMODES = 1030,
+ RPMTAG_FILEUIDS = 1031, /*!< internal */
+ RPMTAG_FILEGIDS = 1032, /*!< internal */
+ RPMTAG_FILERDEVS = 1033,
+ RPMTAG_FILEMTIMES = 1034,
+ RPMTAG_FILEMD5S = 1035,
+ RPMTAG_FILELINKTOS = 1036,
+ RPMTAG_FILEFLAGS = 1037,
/address@hidden@*/
- RPMTAG_ROOT = 1038, /*!< internal - obsolete */
+ RPMTAG_ROOT = 1038, /*!< internal - obsolete */
/address@hidden@*/
- RPMTAG_FILEUSERNAME = 1039,
- RPMTAG_FILEGROUPNAME = 1040,
+ RPMTAG_FILEUSERNAME = 1039,
+ RPMTAG_FILEGROUPNAME = 1040,
/address@hidden@*/
- RPMTAG_EXCLUDE = 1041, /*!< internal - obsolete */
- RPMTAG_EXCLUSIVE = 1042, /*!< internal - obsolete */
+ RPMTAG_EXCLUDE = 1041, /*!< internal - obsolete */
+ RPMTAG_EXCLUSIVE = 1042, /*!< internal - obsolete */
/address@hidden@*/
- RPMTAG_ICON = 1043,
- RPMTAG_SOURCERPM = 1044,
- RPMTAG_FILEVERIFYFLAGS = 1045,
- RPMTAG_ARCHIVESIZE = 1046,
- RPMTAG_PROVIDENAME = 1047,
-#define RPMTAG_PROVIDES RPMTAG_PROVIDENAME /* backward
comaptibility */
- RPMTAG_REQUIREFLAGS = 1048,
- RPMTAG_REQUIRENAME = 1049,
- RPMTAG_REQUIREVERSION = 1050,
- RPMTAG_NOSOURCE = 1051, /*!< internal */
- RPMTAG_NOPATCH = 1052, /*!< internal */
- RPMTAG_CONFLICTFLAGS = 1053,
- RPMTAG_CONFLICTNAME = 1054,
- RPMTAG_CONFLICTVERSION = 1055,
- RPMTAG_DEFAULTPREFIX = 1056, /*!< internal - deprecated */
- RPMTAG_BUILDROOT = 1057, /*!< internal */
- RPMTAG_INSTALLPREFIX = 1058, /*!< internal - deprecated */
- RPMTAG_EXCLUDEARCH = 1059,
- RPMTAG_EXCLUDEOS = 1060,
- RPMTAG_EXCLUSIVEARCH = 1061,
- RPMTAG_EXCLUSIVEOS = 1062,
- RPMTAG_AUTOREQPROV = 1063, /*!< internal */
- RPMTAG_RPMVERSION = 1064,
- RPMTAG_TRIGGERSCRIPTS = 1065,
- RPMTAG_TRIGGERNAME = 1066,
- RPMTAG_TRIGGERVERSION = 1067,
- RPMTAG_TRIGGERFLAGS = 1068,
- RPMTAG_TRIGGERINDEX = 1069,
- RPMTAG_VERIFYSCRIPT = 1079,
- RPMTAG_CHANGELOGTIME = 1080,
- RPMTAG_CHANGELOGNAME = 1081,
- RPMTAG_CHANGELOGTEXT = 1082,
+ RPMTAG_ICON = 1043,
+ RPMTAG_SOURCERPM = 1044,
+ RPMTAG_FILEVERIFYFLAGS = 1045,
+ RPMTAG_ARCHIVESIZE = 1046,
+ RPMTAG_PROVIDENAME = 1047,
+#define RPMTAG_PROVIDES RPMTAG_PROVIDENAME /* backward
comaptibility */
+ RPMTAG_REQUIREFLAGS = 1048,
+ RPMTAG_REQUIRENAME = 1049,
+ RPMTAG_REQUIREVERSION = 1050,
+ RPMTAG_NOSOURCE = 1051, /*!< internal */
+ RPMTAG_NOPATCH = 1052, /*!< internal */
+ RPMTAG_CONFLICTFLAGS = 1053,
+ RPMTAG_CONFLICTNAME = 1054,
+ RPMTAG_CONFLICTVERSION = 1055,
+ RPMTAG_DEFAULTPREFIX = 1056, /*!< internal - deprecated */
+ RPMTAG_BUILDROOT = 1057, /*!< internal */
+ RPMTAG_INSTALLPREFIX = 1058, /*!< internal - deprecated */
+ RPMTAG_EXCLUDEARCH = 1059,
+ RPMTAG_EXCLUDEOS = 1060,
+ RPMTAG_EXCLUSIVEARCH = 1061,
+ RPMTAG_EXCLUSIVEOS = 1062,
+ RPMTAG_AUTOREQPROV = 1063, /*!< internal */
+ RPMTAG_RPMVERSION = 1064,
+ RPMTAG_TRIGGERSCRIPTS = 1065,
+ RPMTAG_TRIGGERNAME = 1066,
+ RPMTAG_TRIGGERVERSION = 1067,
+ RPMTAG_TRIGGERFLAGS = 1068,
+ RPMTAG_TRIGGERINDEX = 1069,
+ RPMTAG_VERIFYSCRIPT = 1079,
+ RPMTAG_CHANGELOGTIME = 1080,
+ RPMTAG_CHANGELOGNAME = 1081,
+ RPMTAG_CHANGELOGTEXT = 1082,
/address@hidden@*/
- RPMTAG_BROKENMD5 = 1083, /*!< internal */
+ RPMTAG_BROKENMD5 = 1083, /*!< internal */
/address@hidden@*/
- RPMTAG_PREREQ = 1084, /*!< internal */
- RPMTAG_PREINPROG = 1085,
- RPMTAG_POSTINPROG = 1086,
- RPMTAG_PREUNPROG = 1087,
- RPMTAG_POSTUNPROG = 1088,
- RPMTAG_BUILDARCHS = 1089,
- RPMTAG_OBSOLETENAME = 1090,
-#define RPMTAG_OBSOLETES RPMTAG_OBSOLETENAME /* backward
comaptibility */
- RPMTAG_VERIFYSCRIPTPROG = 1091,
- RPMTAG_TRIGGERSCRIPTPROG = 1092,
- RPMTAG_DOCDIR = 1093, /*!< internal */
- RPMTAG_COOKIE = 1094,
- RPMTAG_FILEDEVICES = 1095,
- RPMTAG_FILEINODES = 1096,
- RPMTAG_FILELANGS = 1097,
- RPMTAG_PREFIXES = 1098,
- RPMTAG_INSTPREFIXES = 1099,
- RPMTAG_TRIGGERIN = 1100, /*!< internal */
- RPMTAG_TRIGGERUN = 1101, /*!< internal */
- RPMTAG_TRIGGERPOSTUN = 1102, /*!< internal */
- RPMTAG_AUTOREQ = 1103, /*!< internal */
- RPMTAG_AUTOPROV = 1104, /*!< internal */
+ RPMTAG_PREREQ = 1084, /*!< internal */
+ RPMTAG_PREINPROG = 1085,
+ RPMTAG_POSTINPROG = 1086,
+ RPMTAG_PREUNPROG = 1087,
+ RPMTAG_POSTUNPROG = 1088,
+ RPMTAG_BUILDARCHS = 1089,
+ RPMTAG_OBSOLETENAME = 1090,
+#define RPMTAG_OBSOLETES RPMTAG_OBSOLETENAME /* backward
comaptibility */
+ RPMTAG_VERIFYSCRIPTPROG = 1091,
+ RPMTAG_TRIGGERSCRIPTPROG = 1092,
+ RPMTAG_DOCDIR = 1093, /*!< internal */
+ RPMTAG_COOKIE = 1094,
+ RPMTAG_FILEDEVICES = 1095,
+ RPMTAG_FILEINODES = 1096,
+ RPMTAG_FILELANGS = 1097,
+ RPMTAG_PREFIXES = 1098,
+ RPMTAG_INSTPREFIXES = 1099,
+ RPMTAG_TRIGGERIN = 1100, /*!< internal */
+ RPMTAG_TRIGGERUN = 1101, /*!< internal */
+ RPMTAG_TRIGGERPOSTUN = 1102, /*!< internal */
+ RPMTAG_AUTOREQ = 1103, /*!< internal */
+ RPMTAG_AUTOPROV = 1104, /*!< internal */
/address@hidden@*/
- RPMTAG_CAPABILITY = 1105, /*!< internal - obsolete */
+ RPMTAG_CAPABILITY = 1105, /*!< internal - obsolete */
/address@hidden@*/
- RPMTAG_SOURCEPACKAGE = 1106, /*!< internal */
+ RPMTAG_SOURCEPACKAGE = 1106, /*!< internal */
/address@hidden@*/
- RPMTAG_OLDORIGFILENAMES = 1107, /*!< internal - obsolete */
+ RPMTAG_OLDORIGFILENAMES = 1107, /*!< internal - obsolete */
/address@hidden@*/
- RPMTAG_BUILDPREREQ = 1108, /*!< internal */
- RPMTAG_BUILDREQUIRES = 1109, /*!< internal */
- RPMTAG_BUILDCONFLICTS = 1110, /*!< internal */
+ RPMTAG_BUILDPREREQ = 1108, /*!< internal */
+ RPMTAG_BUILDREQUIRES = 1109, /*!< internal */
+ RPMTAG_BUILDCONFLICTS = 1110, /*!< internal */
/address@hidden@*/
- RPMTAG_BUILDMACROS = 1111, /*!< internal */
+ RPMTAG_BUILDMACROS = 1111, /*!< internal */
/address@hidden@*/
- RPMTAG_PROVIDEFLAGS = 1112,
- RPMTAG_PROVIDEVERSION = 1113,
- RPMTAG_OBSOLETEFLAGS = 1114,
- RPMTAG_OBSOLETEVERSION = 1115,
- RPMTAG_DIRINDEXES = 1116,
- RPMTAG_BASENAMES = 1117,
- RPMTAG_DIRNAMES = 1118,
- RPMTAG_ORIGDIRINDEXES = 1119, /*!< internal */
- RPMTAG_ORIGBASENAMES = 1120, /*!< internal */
- RPMTAG_ORIGDIRNAMES = 1121, /*!< internal */
- RPMTAG_OPTFLAGS = 1122,
- RPMTAG_DISTURL = 1123,
- RPMTAG_PAYLOADFORMAT = 1124,
- RPMTAG_PAYLOADCOMPRESSOR = 1125,
- RPMTAG_PAYLOADFLAGS = 1126,
- RPMTAG_MULTILIBS = 1127,
- RPMTAG_INSTALLTID = 1128,
- RPMTAG_REMOVETID = 1129,
- RPMTAG_SHA1RHN = 1130, /*!< internal */
- RPMTAG_RHNPLATFORM = 1131,
- RPMTAG_PLATFORM = 1132,
+ RPMTAG_PROVIDEFLAGS = 1112,
+ RPMTAG_PROVIDEVERSION = 1113,
+ RPMTAG_OBSOLETEFLAGS = 1114,
+ RPMTAG_OBSOLETEVERSION = 1115,
+ RPMTAG_DIRINDEXES = 1116,
+ RPMTAG_BASENAMES = 1117,
+ RPMTAG_DIRNAMES = 1118,
+ RPMTAG_ORIGDIRINDEXES = 1119, /*!< internal */
+ RPMTAG_ORIGBASENAMES = 1120, /*!< internal */
+ RPMTAG_ORIGDIRNAMES = 1121, /*!< internal */
+ RPMTAG_OPTFLAGS = 1122,
+ RPMTAG_DISTURL = 1123,
+ RPMTAG_PAYLOADFORMAT = 1124,
+ RPMTAG_PAYLOADCOMPRESSOR = 1125,
+ RPMTAG_PAYLOADFLAGS = 1126,
+ RPMTAG_MULTILIBS = 1127,
+ RPMTAG_INSTALLTID = 1128,
+ RPMTAG_REMOVETID = 1129,
+ RPMTAG_SHA1RHN = 1130, /*!< internal */
+ RPMTAG_RHNPLATFORM = 1131,
+ RPMTAG_PLATFORM = 1132,
/address@hidden@*/
- RPMTAG_FIRSTFREE_TAG /*!< internal */
+ RPMTAG_FIRSTFREE_TAG /*!< internal */
/address@hidden@*/
} rpmTag;
@@ -262,100 +264,105 @@
/** \ingroup signature
* Tags found in signature header from package.
*/
-enum rpmtagSignature {
- RPMSIGTAG_SIZE = 1000, /*!< Header+Payload size in bytes. */
+enum rpmtagSignature
+{
+ RPMSIGTAG_SIZE = 1000, /*!< Header+Payload size in bytes. */
/* the md5 sum was broken *twice* on big endian machines */
- RPMSIGTAG_LEMD5_1 = 1001, /*!< Broken MD5, take 1 */
- RPMSIGTAG_PGP = 1002, /*!< PGP 2.6.3 signature. */
- RPMSIGTAG_LEMD5_2 = 1003, /*!< Broken MD5, take 2 */
- RPMSIGTAG_MD5 = 1004, /*!< MD5 signature. */
- RPMSIGTAG_GPG = 1005, /*!< GnuPG signature. */
- RPMSIGTAG_PGP5 = 1006, /*!< PGP5 signature @deprecated legacy. */
- RPMSIGTAG_PAYLOADSIZE = 1007,
- /*!< uncompressed payload size in bytes. */
- RPMSIGTAG_BADSHA1_1 = RPMTAG_BADSHA1_1, /*!< Broken SHA1, take 1. */
- RPMSIGTAG_BADSHA1_2 = RPMTAG_BADSHA1_2, /*!< Broken SHA1, take 2. */
- RPMSIGTAG_SHA1 = RPMTAG_SHA1HEADER, /*!< sha1 header digest. */
- RPMSIGTAG_DSA = RPMTAG_DSAHEADER, /*!< DSA header signature. */
- RPMSIGTAG_RSA = RPMTAG_RSAHEADER /*!< RSA header signature. */
+ RPMSIGTAG_LEMD5_1 = 1001, /*!< Broken MD5, take 1 */
+ RPMSIGTAG_PGP = 1002, /*!< PGP 2.6.3 signature. */
+ RPMSIGTAG_LEMD5_2 = 1003, /*!< Broken MD5, take 2 */
+ RPMSIGTAG_MD5 = 1004, /*!< MD5 signature. */
+ RPMSIGTAG_GPG = 1005, /*!< GnuPG signature. */
+ RPMSIGTAG_PGP5 = 1006, /*!< PGP5 signature @deprecated legacy. */
+ RPMSIGTAG_PAYLOADSIZE = 1007,
+ /*!< uncompressed payload size in bytes. */
+ RPMSIGTAG_BADSHA1_1 = RPMTAG_BADSHA1_1, /*!< Broken SHA1, take 1. */
+ RPMSIGTAG_BADSHA1_2 = RPMTAG_BADSHA1_2, /*!< Broken SHA1, take 2. */
+ RPMSIGTAG_SHA1 = RPMTAG_SHA1HEADER, /*!< sha1 header digest. */
+ RPMSIGTAG_DSA = RPMTAG_DSAHEADER, /*!< DSA header signature. */
+ RPMSIGTAG_RSA = RPMTAG_RSAHEADER /*!< RSA header signature. */
};
/**
* Dependency Attributes.
*/
-typedef enum rpmsenseFlags_e {
- RPMSENSE_ANY = 0,
+typedef enum rpmsenseFlags_e
+{
+ RPMSENSE_ANY = 0,
/address@hidden@*/
- RPMSENSE_SERIAL = (1 << 0), /*!< @todo Legacy. */
+ RPMSENSE_SERIAL = (1 << 0), /*!< @todo Legacy. */
/address@hidden@*/
- RPMSENSE_LESS = (1 << 1),
- RPMSENSE_GREATER = (1 << 2),
- RPMSENSE_EQUAL = (1 << 3),
- RPMSENSE_PROVIDES = (1 << 4), /* only used internally by builds */
- RPMSENSE_CONFLICTS = (1 << 5), /* only used internally by builds */
- RPMSENSE_PREREQ = (1 << 6), /*!< @todo Legacy. */
- RPMSENSE_OBSOLETES = (1 << 7), /* only used internally by builds */
- RPMSENSE_INTERP = (1 << 8), /*!< Interpreter used by scriptlet. */
- RPMSENSE_SCRIPT_PRE = ((1 << 9)|RPMSENSE_PREREQ), /*!< %pre
dependency. */
- RPMSENSE_SCRIPT_POST = ((1 << 10)|RPMSENSE_PREREQ), /*!< %post dependency.
*/
- RPMSENSE_SCRIPT_PREUN = ((1 << 11)|RPMSENSE_PREREQ), /*!< %preun
dependency. */
- RPMSENSE_SCRIPT_POSTUN = ((1 << 12)|RPMSENSE_PREREQ), /*!< %postun
dependency. */
- RPMSENSE_SCRIPT_VERIFY = (1 << 13), /*!< %verify dependency. */
- RPMSENSE_FIND_REQUIRES = (1 << 14), /*!< find-requires generated
dependency. */
- RPMSENSE_FIND_PROVIDES = (1 << 15), /*!< find-provides generated
dependency. */
+ RPMSENSE_LESS = (1 << 1),
+ RPMSENSE_GREATER = (1 << 2),
+ RPMSENSE_EQUAL = (1 << 3),
+ RPMSENSE_PROVIDES = (1 << 4), /* only used internally by builds */
+ RPMSENSE_CONFLICTS = (1 << 5), /* only used internally by builds */
+ RPMSENSE_PREREQ = (1 << 6), /*!< @todo Legacy. */
+ RPMSENSE_OBSOLETES = (1 << 7), /* only used internally by builds */
+ RPMSENSE_INTERP = (1 << 8), /*!< Interpreter used by scriptlet. */
+ RPMSENSE_SCRIPT_PRE = ((1 << 9) | RPMSENSE_PREREQ), /*!< %pre dependency.
*/
+ RPMSENSE_SCRIPT_POST = ((1 << 10) | RPMSENSE_PREREQ), /*!< %post dependency.
*/
+ RPMSENSE_SCRIPT_PREUN = ((1 << 11) | RPMSENSE_PREREQ), /*!< %preun
dependency. */
+ RPMSENSE_SCRIPT_POSTUN = ((1 << 12) | RPMSENSE_PREREQ), /*!< %postun
dependency. */
+ RPMSENSE_SCRIPT_VERIFY = (1 << 13), /*!< %verify dependency. */
+ RPMSENSE_FIND_REQUIRES = (1 << 14), /*!< find-requires generated
dependency. */
+ RPMSENSE_FIND_PROVIDES = (1 << 15), /*!< find-provides generated
dependency. */
- RPMSENSE_TRIGGERIN = (1 << 16), /*!< %triggerin dependency. */
- RPMSENSE_TRIGGERUN = (1 << 17), /*!< %triggerun dependency. */
- RPMSENSE_TRIGGERPOSTUN = (1 << 18), /*!< %triggerpostun dependency.
*/
- RPMSENSE_MULTILIB = (1 << 19),
- RPMSENSE_SCRIPT_PREP = (1 << 20), /*!< %prep build dependency. */
- RPMSENSE_SCRIPT_BUILD = (1 << 21), /*!< %build build dependency. */
- RPMSENSE_SCRIPT_INSTALL = (1 << 22),/*!< %install build dependency. */
- RPMSENSE_SCRIPT_CLEAN = (1 << 23), /*!< %clean build dependency. */
- RPMSENSE_RPMLIB = ((1 << 24) | RPMSENSE_PREREQ), /*!< rpmlib(feature)
dependency. */
+ RPMSENSE_TRIGGERIN = (1 << 16), /*!< %triggerin dependency. */
+ RPMSENSE_TRIGGERUN = (1 << 17), /*!< %triggerun dependency. */
+ RPMSENSE_TRIGGERPOSTUN = (1 << 18), /*!< %triggerpostun dependency. */
+ RPMSENSE_MULTILIB = (1 << 19),
+ RPMSENSE_SCRIPT_PREP = (1 << 20), /*!< %prep build dependency. */
+ RPMSENSE_SCRIPT_BUILD = (1 << 21), /*!< %build build dependency. */
+ RPMSENSE_SCRIPT_INSTALL = (1 << 22), /*!< %install build dependency. */
+ RPMSENSE_SCRIPT_CLEAN = (1 << 23), /*!< %clean build dependency. */
+ RPMSENSE_RPMLIB = ((1 << 24) | RPMSENSE_PREREQ), /*!< rpmlib(feature)
dependency. */
/address@hidden@*/
- RPMSENSE_TRIGGERPREIN = (1 << 25), /*!< @todo Implement %triggerprein. */
+ RPMSENSE_TRIGGERPREIN = (1 << 25), /*!< @todo Implement %triggerprein. */
/address@hidden@*/
/address@hidden@*/
- RPMSENSE_KEYRING = (1 << 26)
+ RPMSENSE_KEYRING = (1 << 26)
/address@hidden@*/
} rpmsenseFlags;
/** \ingroup header
* Include calculation for 8 bytes of (magic, 0)?
*/
-enum hMagic {
- HEADER_MAGIC_NO = 0,
- HEADER_MAGIC_YES = 1
+enum hMagic
+{
+ HEADER_MAGIC_NO = 0,
+ HEADER_MAGIC_YES = 1
};
/**
* Package read return codes.
*/
-typedef enum rpmRC_e {
- RPMRC_OK = 0,
- RPMRC_BADMAGIC = 1,
- RPMRC_FAIL = 2,
- RPMRC_BADSIZE = 3,
- RPMRC_SHORTREAD = 4
+typedef enum rpmRC_e
+{
+ RPMRC_OK = 0,
+ RPMRC_BADMAGIC = 1,
+ RPMRC_FAIL = 2,
+ RPMRC_BADSIZE = 3,
+ RPMRC_SHORTREAD = 4
} rpmRC;
/** \ingroup header
* The basic types of data in tags from headers.
*/
-typedef enum rpmTagType_e {
+typedef enum rpmTagType_e
+{
#define RPM_MIN_TYPE 0
- RPM_NULL_TYPE = 0,
- RPM_CHAR_TYPE = 1,
- RPM_INT8_TYPE = 2,
- RPM_INT16_TYPE = 3,
- RPM_INT32_TYPE = 4,
+ RPM_NULL_TYPE = 0,
+ RPM_CHAR_TYPE = 1,
+ RPM_INT8_TYPE = 2,
+ RPM_INT16_TYPE = 3,
+ RPM_INT32_TYPE = 4,
/* RPM_INT64_TYPE = 5, ---- These aren't supported (yet) */
- RPM_STRING_TYPE = 6,
- RPM_BIN_TYPE = 7,
- RPM_STRING_ARRAY_TYPE = 8,
- RPM_I18NSTRING_TYPE = 9
+ RPM_STRING_TYPE = 6,
+ RPM_BIN_TYPE = 7,
+ RPM_STRING_ARRAY_TYPE = 8,
+ RPM_I18NSTRING_TYPE = 9
#define RPM_MAX_TYPE 9
} rpmTagType;
@@ -376,13 +383,13 @@
#define RPMLEAD_MAGIC2 0xee
#define RPMLEAD_MAGIC3 0xdb
-#define RPMLEAD_SIZE 96 /*!< Don't rely on sizeof(struct) */
+#define RPMLEAD_SIZE 96 /*!< Don't rely on sizeof(struct) */
/** \ingroup header
* Maximum no. of bytes permitted in a header.
*/
/address@hidden@*/
-static size_t headerMaxbytes = (32*1024*1024);
+static size_t headerMaxbytes = (32 * 1024 * 1024);
/** \ingroup lead
* The lead data structure.
@@ -390,56 +397,60 @@
* @deprecated The lead (except for signature_type) is legacy.
* @todo Don't use any information from lead.
*/
-struct rpmlead {
- unsigned char magic[4];
- unsigned char major, minor;
- short type;
- short archnum;
- char name[66];
- short osnum;
- short signature_type; /*!< Signature header type (RPMSIG_HEADERSIG) */
-/address@hidden@*/ char reserved[16]; /*!< Pad to 96 bytes -- 8 byte aligned
*/
-} ;
+struct rpmlead
+{
+ unsigned char magic[4];
+ unsigned char major, minor;
+ short type;
+ short archnum;
+ char name[66];
+ short osnum;
+ short signature_type; /*!< Signature header type (RPMSIG_HEADERSIG)
*/
+ /address@hidden@*/ char reserved[16];
+ /*!< Pad to 96 bytes -- 8 byte aligned
*/
+};
/** \ingroup header
* Alignment needs (and sizeof scalars types) for internal rpm data types.
*/
-/address@hidden@*/ /address@hidden@*/
-static int typeSizes[] = {
- 0, /*!< RPM_NULL_TYPE */
- 1, /*!< RPM_CHAR_TYPE */
- 1, /*!< RPM_INT8_TYPE */
- 2, /*!< RPM_INT16_TYPE */
- 4, /*!< RPM_INT32_TYPE */
- -1, /*!< RPM_INT64_TYPE */
- -1, /*!< RPM_STRING_TYPE */
- 1, /*!< RPM_BIN_TYPE */
- -1, /*!< RPM_STRING_ARRAY_TYPE */
- -1 /*!< RPM_I18NSTRING_TYPE */
+ /address@hidden@*//address@hidden@ */
+static int typeSizes[] = {
+ 0, /*!< RPM_NULL_TYPE */
+ 1, /*!< RPM_CHAR_TYPE */
+ 1, /*!< RPM_INT8_TYPE */
+ 2, /*!< RPM_INT16_TYPE */
+ 4, /*!< RPM_INT32_TYPE */
+ -1, /*!< RPM_INT64_TYPE */
+ -1, /*!< RPM_STRING_TYPE */
+ 1, /*!< RPM_BIN_TYPE */
+ -1, /*!< RPM_STRING_ARRAY_TYPE */
+ -1 /*!< RPM_I18NSTRING_TYPE */
};
/** \ingroup header
*/
-enum headerSprintfExtenstionType {
- HEADER_EXT_LAST = 0, /*!< End of extension chain. */
- HEADER_EXT_FORMAT, /*!< headerTagFormatFunction() extension */
- HEADER_EXT_MORE, /*!< Chain to next table. */
- HEADER_EXT_TAG /*!< headerTagTagFunction() extension */
+enum headerSprintfExtenstionType
+{
+ HEADER_EXT_LAST = 0, /*!< End of extension chain. */
+ HEADER_EXT_FORMAT, /*!< headerTagFormatFunction() extension */
+ HEADER_EXT_MORE, /*!< Chain to next table. */
+ HEADER_EXT_TAG /*!< headerTagTagFunction() extension */
};
/** \ingroup signature
* Signature types stored in rpm lead.
*/
-typedef enum sigType_e {
- RPMSIGTYPE_NONE = 0, /*!< unused, legacy. */
- RPMSIGTYPE_PGP262_1024 = 1, /*!< unused, legacy. */
+typedef enum sigType_e
+{
+ RPMSIGTYPE_NONE = 0, /*!< unused, legacy. */
+ RPMSIGTYPE_PGP262_1024 = 1, /*!< unused, legacy. */
/address@hidden@*/
- RPMSIGTYPE_BAD = 2, /*!< Unknown signature type. */
+ RPMSIGTYPE_BAD = 2, /*!< Unknown signature type. */
/address@hidden@*/
- RPMSIGTYPE_MD5 = 3, /*!< unused, legacy. */
- RPMSIGTYPE_MD5_PGP = 4, /*!< unused, legacy. */
- RPMSIGTYPE_HEADERSIG= 5, /*!< Header style signature */
- RPMSIGTYPE_DISABLE = 6 /*!< Disable verification (debugging only) */
+ RPMSIGTYPE_MD5 = 3, /*!< unused, legacy. */
+ RPMSIGTYPE_MD5_PGP = 4, /*!< unused, legacy. */
+ RPMSIGTYPE_HEADERSIG = 5, /*!< Header style signature */
+ RPMSIGTYPE_DISABLE = 6 /*!< Disable verification (debugging only) */
} sigType;
/** \ingroup header
@@ -454,32 +465,36 @@
* @param element
* @return formatted string
*/
-typedef /address@hidden/ char * (*headerTagFormatFunction)(int_32 type,
- const void * data, char * formatPrefix,
- int padding, int element);
+typedef /*only@ */ char *(*headerTagFormatFunction) (int_32 type,
+ const void *data,
+ char *formatPrefix,
+ int padding,
+ int element);
/** \ingroup header
* Associate tag names with numeric values.
*/
-typedef /address@hidden@*/ struct headerTagTableEntry_s * headerTagTableEntry;
-struct headerTagTableEntry_s {
-/address@hidden@*/ /address@hidden@*/ const char * name; /*!< Tag name.
*/
- int val; /*!< Tag numeric value. */
+typedef /address@hidden@ */ struct headerTagTableEntry_s *headerTagTableEntry;
+struct headerTagTableEntry_s
+{
+
/address@hidden@*//address@hidden@ */ const char *name;
+ /*!< Tag name. */
+ int val; /*!< Tag numeric value. */
};
/** \ingroup header
*/
-typedef /address@hidden@*/ struct headerIteratorS * HeaderIterator;
+typedef /address@hidden@ */ struct headerIteratorS *HeaderIterator;
/** \ingroup header
*/
-typedef /address@hidden@*/ /address@hidden@*/ struct headerToken * Header;
+typedef /address@hidden@ *//address@hidden@ */ struct headerToken *Header;
-typedef int_32 * hTYP_t;
-typedef const void * hPTR_t;
-typedef int_32 * hCNT_t;
+typedef int_32 *hTYP_t;
+typedef const void *hPTR_t;
+typedef int_32 *hCNT_t;
/** \ingroup header
* HEADER_EXT_FORMAT format function prototype.
@@ -493,35 +508,37 @@
* @return 0 on success
*/
typedef int (*headerTagTagFunction) (Header h,
- /address@hidden@*/ /address@hidden@*/ hTYP_t type,
- /address@hidden@*/ /address@hidden@*/ hPTR_t * data,
- /address@hidden@*/ /address@hidden@*/ hCNT_t count,
- /address@hidden@*/ /address@hidden@*/ int * freeData);
+ /address@hidden@ *//address@hidden@ */
hTYP_t type,
+ /address@hidden@ *//address@hidden@ */
hPTR_t * data,
+ /address@hidden@ *//address@hidden@ */
hCNT_t count,
+ /address@hidden@ *//address@hidden@ */
int *freeData);
/** \ingroup header
* Define header tag output formats.
*/
-typedef /address@hidden@*/ struct headerSprintfExtension_s *
headerSprintfExtension;
-struct headerSprintfExtension_s {
- enum headerSprintfExtenstionType type; /*!< Type of extension. */
-/address@hidden@*/ /address@hidden@*/
- const char * name; /*!< Name of extension. */
- union {
-/address@hidden@*/ /address@hidden@*/
- void * generic; /*!< Private extension. */
- headerTagFormatFunction formatFunction; /*!< HEADER_EXT_TAG extension.
*/
- headerTagTagFunction tagFunction; /*!< HEADER_EXT_FORMAT
extension. */
- struct headerSprintfExtension_s * more; /*!< Chained table extension. */
- } u;
+typedef /address@hidden@ */ struct headerSprintfExtension_s
+ *headerSprintfExtension;
+struct headerSprintfExtension_s
+{
+ enum headerSprintfExtenstionType type; /*!< Type of extension. */
+ /address@hidden@*//address@hidden@ */
+ const char *name; /*!< Name of extension. */
+ union
+ {
+ /address@hidden@*//address@hidden@ */
+ void *generic; /*!< Private extension. */
+ headerTagFormatFunction formatFunction; /*!< HEADER_EXT_TAG extension.
*/
+ headerTagTagFunction tagFunction; /*!< HEADER_EXT_FORMAT extension. */
+ struct headerSprintfExtension_s *more; /*!< Chained table extension.
*/
+ } u;
};
/** \ingroup header
* Create new (empty) header instance.
* @return header
*/
-typedef
-Header (*HDRnew) (void)
- /address@hidden/;
+typedef Header (*HDRnew) (void)
+ /*@ */ ;
/** \ingroup header
* Dereference a header instance.
@@ -529,44 +546,40 @@
* @return NULL always
*/
typedef
-/address@hidden@*/ Header (*HDRfree) (/address@hidden@*/ /address@hidden@*/
Header h)
- /address@hidden h @*/;
+/address@hidden@*/ Header (*HDRfree) ( /address@hidden@ *//address@hidden@ */
Header h)
+ /address@hidden h @ */ ;
/** \ingroup header
* Reference a header instance.
* @param h header
* @return referenced header instance
*/
-typedef
-Header (*HDRlink) (Header h)
- /address@hidden h @*/;
+typedef Header (*HDRlink) (Header h)
+ /address@hidden h @ */ ;
/** \ingroup header
* Dereference a header instance.
* @param h header
* @return NULL always
*/
-typedef
-Header (*HDRunlink) (/address@hidden@*/ /address@hidden@*/ Header h)
- /address@hidden h @*/;
+typedef Header (*HDRunlink) ( /address@hidden@ *//address@hidden@ */ Header h)
+ /address@hidden h @ */ ;
/** \ingroup header
* Sort tags in header.
* @todo Eliminate from API.
* @param h header
*/
-typedef
-void (*HDRsort) (Header h)
- /address@hidden h @*/;
+typedef void (*HDRsort) (Header h)
+ /address@hidden h @ */ ;
/** \ingroup header
* Restore tags in header to original ordering.
* @todo Eliminate from API.
* @param h header
*/
-typedef
-void (*HDRunsort) (Header h)
- /address@hidden h @*/;
+typedef void (*HDRunsort) (Header h)
+ /address@hidden h @ */ ;
/** \ingroup header
* Return size of on-disk header representation in bytes.
@@ -574,9 +587,8 @@
* @param magicp include size of 8 bytes for (magic, 0)?
* @return size of on-disk header
*/
-typedef
-unsigned int (*HDRsizeof) (/address@hidden@*/ Header h, enum hMagic magicp)
- /address@hidden h @*/;
+typedef unsigned int (*HDRsizeof) ( /address@hidden@ */ Header h, enum hMagic
magicp)
+ /address@hidden h @ */ ;
/** \ingroup header
* Convert header to on-disk representation.
@@ -584,8 +596,8 @@
* @return on-disk header blob (i.e. with offsets)
*/
typedef
-/address@hidden@*/ /address@hidden@*/ void * (*HDRunload) (Header h)
- /address@hidden h @*/;
+ /address@hidden@*//address@hidden@ */ void *(*HDRunload) (Header h)
+ /address@hidden h @ */ ;
/** \ingroup header
* Convert header to on-disk representation, and then reload.
@@ -595,17 +607,16 @@
* @return on-disk header (with offsets)
*/
typedef
-/address@hidden@*/ Header (*HDRreload) (/address@hidden@*/ Header h, int tag)
- /address@hidden h @*/;
+/address@hidden@*/ Header (*HDRreload) ( /address@hidden@ */ Header h, int tag)
+ /address@hidden h @ */ ;
/** \ingroup header
* Duplicate a header.
* @param h header
* @return new header instance
*/
-typedef
-Header (*HDRcopy) (Header h)
- /address@hidden h @*/;
+typedef Header (*HDRcopy) (Header h)
+ /address@hidden h @ */ ;
/** \ingroup header
* Convert header to in-memory representation.
@@ -613,8 +624,8 @@
* @return header
*/
typedef
-/address@hidden@*/ Header (*HDRload) (/address@hidden@*/ void * uh)
- /address@hidden uh @*/;
+/address@hidden@*/ Header (*HDRload) ( /address@hidden@ */ void *uh)
+ /address@hidden uh @ */ ;
/** \ingroup header
* Make a copy and convert header to in-memory representation.
@@ -622,8 +633,8 @@
* @return header
*/
typedef
-/address@hidden@*/ Header (*HDRcopyload) (const void * uh)
- /address@hidden/;
+/address@hidden@*/ Header (*HDRcopyload) (const void *uh)
+ /*@ */ ;
/** \ingroup header
* Read (and load) header from file handle.
@@ -633,7 +644,7 @@
*/
typedef
/address@hidden@*/ Header (*HDRhdrread) (FD_t fd, enum hMagic magicp)
- /address@hidden fd @*/;
+ /address@hidden fd @ */ ;
/** \ingroup header
* Write (with unload) header to file handle.
@@ -642,10 +653,9 @@
* @param magicp prefix write with 8 bytes of (magic, 0)?
* @return 0 on success, 1 on error
*/
-typedef
-int (*HDRhdrwrite) (FD_t fd, /address@hidden@*/ Header h, enum hMagic magicp)
- /address@hidden fileSystem @*/
- /address@hidden fd, h, fileSystem @*/;
+typedef int (*HDRhdrwrite) (FD_t fd, /address@hidden@ */ Header h, enum hMagic
magicp)
+ /address@hidden fileSystem @ */
+ /address@hidden fd, h, fileSystem @ */ ;
/** \ingroup header
* Check if tag is in header.
@@ -653,9 +663,8 @@
* @param tag tag
* @return 1 on success, 0 on failure
*/
-typedef
-int (*HDRisentry) (/address@hidden@*/Header h, int_32 tag)
- /address@hidden/;
+typedef int (*HDRisentry) ( /address@hidden@ */ Header h, int_32 tag)
+ /*@ */ ;
/** \ingroup header
* Free data allocated when retrieved from header.
@@ -665,9 +674,10 @@
* @return NULL always
*/
typedef
-/address@hidden@*/ void * (*HDRfreetag) (Header h,
- /address@hidden@*/ /address@hidden@*/ const void * data,
rpmTagType type)
- /address@hidden data @*/;
+/address@hidden@*/ void *(*HDRfreetag) (Header h,
+ /address@hidden@ *//address@hidden@ */ const
void *data,
+ rpmTagType type)
+ /address@hidden data @ */ ;
/** \ingroup header
* Retrieve tag value.
@@ -682,12 +692,11 @@
* @retval c address of number of values (or NULL)
* @return 1 on success, 0 on failure
*/
-typedef
-int (*HDRget) (Header h, int_32 tag,
- /address@hidden@*/ /address@hidden@*/ hTYP_t type,
- /address@hidden@*/ /address@hidden@*/ void ** p,
- /address@hidden@*/ /address@hidden@*/ hCNT_t c)
- /address@hidden *type, *p, *c @*/;
+typedef int (*HDRget) (Header h, int_32 tag,
+ /address@hidden@ *//address@hidden@ */ hTYP_t type,
+ /address@hidden@ *//address@hidden@ */ void **p,
+ /address@hidden@ *//address@hidden@ */ hCNT_t c)
+ /address@hidden *type, *p, *c @ */ ;
/** \ingroup header
* Retrieve tag value using header internal array.
@@ -701,12 +710,11 @@
* @retval c address of number of values (or NULL)
* @return 1 on success, 0 on failure
*/
-typedef
-int (*HDRgetmin) (Header h, int_32 tag,
- /address@hidden@*/ /address@hidden@*/ hTYP_t type,
- /address@hidden@*/ /address@hidden@*/ hPTR_t * p,
- /address@hidden@*/ /address@hidden@*/ hCNT_t c)
- /address@hidden *type, *p, *c @*/;
+typedef int (*HDRgetmin) (Header h, int_32 tag,
+ /address@hidden@ *//address@hidden@ */ hTYP_t type,
+ /address@hidden@ *//address@hidden@ */ hPTR_t * p,
+ /address@hidden@ *//address@hidden@ */ hCNT_t c)
+ /address@hidden *type, *p, *c @ */ ;
/** \ingroup header
* Add tag to header.
@@ -723,8 +731,8 @@
* @return 1 on success, 0 on failure
*/
typedef
-int (*HDRadd) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
- /address@hidden h @*/;
+ int (*HDRadd) (Header h, int_32 tag, int_32 type, const void *p, int_32 c)
+ /address@hidden h @ */ ;
/** \ingroup header
* Append element to tag array in header.
@@ -741,8 +749,9 @@
* @return 1 on success, 0 on failure
*/
typedef
-int (*HDRappend) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
- /address@hidden h @*/;
+ int (*HDRappend) (Header h, int_32 tag, int_32 type, const void *p,
+ int_32 c)
+ /address@hidden h @ */ ;
/** \ingroup header
* Add or append element to tag array in header.
@@ -755,8 +764,9 @@
* @return 1 on success, 0 on failure
*/
typedef
-int (*HDRaddorappend) (Header h, int_32 tag, int_32 type, const void * p,
int_32 c)
- /address@hidden h @*/;
+ int (*HDRaddorappend) (Header h, int_32 tag, int_32 type, const void *p,
+ int_32 c)
+ /address@hidden h @ */ ;
/** \ingroup header
* Add locale specific tag to header.
@@ -779,9 +789,9 @@
* @return 1 on success, 0 on failure
*/
typedef
-int (*HDRaddi18n) (Header h, int_32 tag, const char * string,
- const char * lang)
- /address@hidden h @*/;
+ int (*HDRaddi18n) (Header h, int_32 tag, const char *string,
+ const char *lang)
+ /address@hidden h @ */ ;
/** \ingroup header
* Modify tag in header.
@@ -794,8 +804,9 @@
* @return 1 on success, 0 on failure
*/
typedef
-int (*HDRmodify) (Header h, int_32 tag, int_32 type, const void * p, int_32 c)
- /address@hidden h @*/;
+ int (*HDRmodify) (Header h, int_32 tag, int_32 type, const void *p,
+ int_32 c)
+ /address@hidden h @ */ ;
/** \ingroup header
* Delete tag in header.
@@ -806,15 +817,14 @@
* @param tag tag
* @return 0 on success, 1 on failure (INCONSISTENT)
*/
-typedef
-int (*HDRremove) (Header h, int_32 tag)
- /address@hidden h @*/;
+typedef int (*HDRremove) (Header h, int_32 tag)
+ /address@hidden h @ */ ;
-/address@hidden@*/ /* LCL: no clue */
+ /address@hidden@*//* LCL: no clue */
/** \ingroup header
*/
-typedef const char * errmsg_t;
-typedef int_32 * hTAG_t;
+typedef const char *errmsg_t;
+typedef int_32 *hTAG_t;
/** \ingroup header
* Return formatted output string from header tags.
@@ -828,11 +838,12 @@
* @return formatted output string (malloc'ed)
*/
typedef
-/address@hidden@*/ char * (*HDRhdrsprintf) (Header h, const char * fmt,
- const struct headerTagTableEntry_s * tags,
- const struct headerSprintfExtension_s * extensions,
- /address@hidden@*/ /address@hidden@*/ errmsg_t * errmsg)
- /address@hidden *errmsg @*/;
+/address@hidden@*/ char *(*HDRhdrsprintf) (Header h, const char *fmt,
+ const struct headerTagTableEntry_s * tags,
+ const struct headerSprintfExtension_s *
+ extensions,
+ /address@hidden@ *//address@hidden@ */
errmsg_t * errmsg)
+ /address@hidden *errmsg @ */ ;
/** \ingroup header
* Duplicate tag values from one header into another.
@@ -841,26 +852,24 @@
* @param tagstocopy array of tags that are copied
*/
typedef
-void (*HDRcopytags) (Header headerFrom, Header headerTo, hTAG_t tagstocopy)
- /address@hidden headerFrom, headerTo @*/;
+ void (*HDRcopytags) (Header headerFrom, Header headerTo, hTAG_t tagstocopy)
+ /address@hidden headerFrom, headerTo @ */ ;
/** \ingroup header
* Destroy header tag iterator.
* @param hi header tag iterator
* @return NULL always
*/
-typedef
-HeaderIterator (*HDRfreeiter) (/address@hidden@*/ HeaderIterator hi)
- /address@hidden hi @*/;
+typedef HeaderIterator (*HDRfreeiter) ( /address@hidden@ */ HeaderIterator hi)
+ /address@hidden hi @ */ ;
/** \ingroup header
* Create header tag iterator.
* @param h header
* @return header tag iterator
*/
-typedef
-HeaderIterator (*HDRinititer) (Header h)
- /address@hidden h */;
+typedef HeaderIterator (*HDRinititer) (Header h)
+ /address@hidden h */ ;
/** \ingroup header
* Return next tag from header.
@@ -871,99 +880,109 @@
* @retval c address of number of values
* @return 1 on success, 0 on failure
*/
-typedef
-int (*HDRnextiter) (HeaderIterator hi,
- /address@hidden@*/ /address@hidden@*/ hTAG_t tag,
- /address@hidden@*/ /address@hidden@*/ hTYP_t type,
- /address@hidden@*/ /address@hidden@*/ hPTR_t * p,
- /address@hidden@*/ /address@hidden@*/ hCNT_t c)
- /address@hidden hi, *tag, *type, *p, *c @*/;
+typedef int (*HDRnextiter) (HeaderIterator hi,
+ /address@hidden@ *//address@hidden@ */ hTAG_t tag,
+ /address@hidden@ *//address@hidden@ */ hTYP_t type,
+ /address@hidden@ *//address@hidden@ */ hPTR_t * p,
+ /address@hidden@ *//address@hidden@ */ hCNT_t c)
+ /address@hidden hi, *tag, *type, *p, *c @ */ ;
/** \ingroup header
* Header method vectors.
*/
-typedef /address@hidden@*/ struct HV_s * HV_t;
-struct HV_s {
- HDRnew hdrnew;
- HDRfree hdrfree;
- HDRlink hdrlink;
- HDRsort hdrsort;
- HDRunsort hdrunsort;
- HDRsizeof hdrsizeof;
- HDRunload hdrunload;
- HDRreload hdrreload;
- HDRcopy hdrcopy;
- HDRload hdrload;
- HDRcopyload hdrcopyload;
- HDRhdrread hdrread;
- HDRhdrwrite hdrwrite;
- HDRisentry hdrisentry;
- HDRfreetag hdrfreetag;
- HDRget hdrget;
- HDRgetmin hdrgetmin;
- HDRadd hdradd;
- HDRappend hdrappend;
- HDRaddorappend hdraddorappend;
- HDRaddi18n hdraddi18n;
- HDRmodify hdrmodify;
- HDRremove hdrremove;
- HDRhdrsprintf hdrsprintf;
- HDRcopytags hdrcopytags;
- HDRfreeiter hdrfreeiter;
- HDRinititer hdrinititer;
- HDRnextiter hdrnextiter;
- HDRunlink hdrunlink;
+typedef /address@hidden@ */ struct HV_s *HV_t;
+struct HV_s
+{
+ HDRnew hdrnew;
+ HDRfree hdrfree;
+ HDRlink hdrlink;
+ HDRsort hdrsort;
+ HDRunsort hdrunsort;
+ HDRsizeof hdrsizeof;
+ HDRunload hdrunload;
+ HDRreload hdrreload;
+ HDRcopy hdrcopy;
+ HDRload hdrload;
+ HDRcopyload hdrcopyload;
+ HDRhdrread hdrread;
+ HDRhdrwrite hdrwrite;
+ HDRisentry hdrisentry;
+ HDRfreetag hdrfreetag;
+ HDRget hdrget;
+ HDRgetmin hdrgetmin;
+ HDRadd hdradd;
+ HDRappend hdrappend;
+ HDRaddorappend hdraddorappend;
+ HDRaddi18n hdraddi18n;
+ HDRmodify hdrmodify;
+ HDRremove hdrremove;
+ HDRhdrsprintf hdrsprintf;
+ HDRcopytags hdrcopytags;
+ HDRfreeiter hdrfreeiter;
+ HDRinititer hdrinititer;
+ HDRnextiter hdrnextiter;
+ HDRunlink hdrunlink;
/address@hidden@*/
- void * hdrvecs;
+ void *hdrvecs;
/address@hidden@*/
- void * hdrdata;
- int hdrversion;
+ void *hdrdata;
+ int hdrversion;
};
/** \ingroup header
* Description of tag data.
*/
-typedef /address@hidden@*/ struct entryInfo * entryInfo;
-struct entryInfo {
- int_32 tag; /*!< Tag identifier. */
- int_32 type; /*!< Tag data type. */
- int_32 offset; /*!< Offset into data segment (ondisk only). */
- int_32 count; /*!< Number of tag elements. */
+typedef /address@hidden@ */ struct entryInfo *entryInfo;
+struct entryInfo
+{
+ int_32 tag; /*!< Tag identifier. */
+ int_32 type; /*!< Tag data type. */
+ int_32 offset; /*!< Offset into data segment (ondisk only). */
+ int_32 count; /*!< Number of tag elements. */
};
/** \ingroup header
* A single tag from a Header.
*/
-typedef /address@hidden@*/ struct indexEntry * indexEntry;
-struct indexEntry {
- struct entryInfo info; /*!< Description of tag data. */
-/address@hidden@*/ void * data; /*!< Location of tag data. */
- int length; /*!< No. bytes of data. */
- int rdlen; /*!< No. bytes of data in region. */
+typedef /address@hidden@ */ struct indexEntry *indexEntry;
+struct indexEntry
+{
+ struct entryInfo info; /*!< Description of tag data. */
+ /address@hidden@*/ void *data;
+ /*!< Location of tag data. */
+ int length; /*!< No. bytes of data. */
+ int rdlen; /*!< No. bytes of data in region. */
};
/** \ingroup header
* The Header data structure.
*/
-struct headerToken {
-/address@hidden@*/ struct HV_s hv; /*!< Header public methods. */
- void * blob; /*!< Header region blob. */
-/address@hidden@*/ indexEntry index; /*!< Array of tags. */
- int indexUsed; /*!< Current size of tag array. */
- int indexAlloced; /*!< Allocated size of tag array. */
- int flags;
-#define HEADERFLAG_SORTED (1 << 0) /*!< Are header entries
sorted? */
-#define HEADERFLAG_ALLOCATED (1 << 1) /*!< Is 1st header region
allocated? */
-#define HEADERFLAG_LEGACY (1 << 2) /*!< Header came from legacy
source? */
-/address@hidden@*/ int nrefs; /*!< Reference count. */
+struct headerToken
+{
+ /address@hidden@*/ struct HV_s hv;
+ /*!< Header public methods. */
+ void *blob; /*!< Header region blob. */
+ /address@hidden@*/ indexEntry index;
+ /*!< Array of tags. */
+ int indexUsed; /*!< Current size of tag array. */
+ int indexAlloced; /*!< Allocated size of tag array. */
+ int flags;
+#define HEADERFLAG_SORTED (1 << 0) /*!< Are header entries
sorted? */
+#define HEADERFLAG_ALLOCATED (1 << 1) /*!< Is 1st header
region allocated? */
+#define HEADERFLAG_LEGACY (1 << 2) /*!< Header came from
legacy source? */
+ /address@hidden@*/ int nrefs;
+ /*!< Reference count. */
};
/**
* Header tag iterator data structure.
*/
-struct headerIteratorS {
-/address@hidden@*/ Header h; /*!< Header being iterated. */
-/address@hidden@*/ int next_index; /*!< Next tag index. */
+struct headerIteratorS
+{
+ /address@hidden@*/ Header h;
+ /*!< Header being iterated. */
+ /address@hidden@*/ int next_index;
+ /*!< Next tag index. */
};
/address@hidden/
@@ -976,9 +995,9 @@
* @param type type of data (or -1 to force free)
* @return NULL always
*/
-typedef /address@hidden@*/
- void * (*HFD_t) (/address@hidden@*/ /address@hidden@*/ const void * data,
rpmTagType type)
- /address@hidden data @*/;
+typedef /address@hidden@ */
+void *(*HFD_t) ( /address@hidden@ *//address@hidden@ */ const void *data,
rpmTagType type)
+ /address@hidden data @ */ ;
/**
* Prototype for headerAddEntry() vector.
@@ -995,8 +1014,8 @@
* @return 1 on success, 0 on failure
*/
typedef int (*HAE_t) (Header h, rpmTag tag, rpmTagType type,
- const void * p, int_32 c)
- /address@hidden h @*/;
+ const void *p, int_32 c)
+ /address@hidden h @ */ ;
/**
* Prototype for headerGetEntry() vector.
@@ -1012,10 +1031,10 @@
* @return 1 on success, 0 on failure
*/
typedef int (*HGE_t) (Header h, rpmTag tag,
- /address@hidden@*/ /address@hidden@*/ rpmTagType * type,
- /address@hidden@*/ /address@hidden@*/ void ** p,
- /address@hidden@*/ /address@hidden@*/ int_32 * c)
- /address@hidden *type, *p, *c @*/;
+ /address@hidden@ *//address@hidden@ */ rpmTagType * type,
+ /address@hidden@ *//address@hidden@ */ void **p,
+ /address@hidden@ *//address@hidden@ */ int_32 * c)
+ /address@hidden *type, *p, *c @ */ ;
/**
* Prototype for headerRemoveEntry() vector.
@@ -1028,7 +1047,7 @@
* @return 0 on success, 1 on failure (INCONSISTENT)
*/
typedef int (*HRE_t) (Header h, int_32 tag)
- /address@hidden h @*/;
+ /address@hidden h @ */ ;
#define ENTRY_IS_REGION(_e) \
(((_e)->info.tag >= HEADER_IMAGE) && ((_e)->info.tag < HEADER_REGIONS))
@@ -1041,34 +1060,37 @@
* @param p memory to free
* @return NULL always
*/
-/address@hidden@*/ static /address@hidden@*/ void *
-_free(/address@hidden@*/ /address@hidden@*/ /address@hidden@*/ const void * p)
/address@hidden *p @*/
+/address@hidden@*/ static /address@hidden@ */ void *
+_free ( /address@hidden@ *//address@hidden@ *//address@hidden@ */ const void
*p) /address@hidden *p @ */
{
- if (p != NULL) free((void *)p);
- return NULL;
+ if (p != NULL)
+ free ((void *) p);
+ return NULL;
}
/**
*/
-static int indexCmp(const void * avp, const void * bvp) /address@hidden/
+static int
+indexCmp (const void *avp, const void *bvp) /*@ */
{
- /address@hidden@*/
- indexEntry ap = (indexEntry) avp, bp = (indexEntry) bvp;
- /address@hidden@*/
- return (ap->info.tag - bp->info.tag);
+ /address@hidden@ */
+ indexEntry ap = (indexEntry) avp, bp = (indexEntry) bvp;
+ /address@hidden@ */
+ return (ap->info.tag - bp->info.tag);
}
/** \ingroup header
* Sort tags in header.
* @param h header
*/
-static
-void headerSort(Header h)
- /address@hidden h @*/
+static void
+headerSort (Header h)
+ /address@hidden h @ */
{
- if (!(h->flags & HEADERFLAG_SORTED)) {
- qsort(h->index, h->indexUsed, sizeof(*h->index), indexCmp);
- h->flags |= HEADERFLAG_SORTED;
+ if (!(h->flags & HEADERFLAG_SORTED))
+ {
+ qsort (h->index, h->indexUsed, sizeof (*h->index), indexCmp);
+ h->flags |= HEADERFLAG_SORTED;
}
}
@@ -1079,13 +1101,14 @@
* @return string
*/
/address@hidden@*/ static inline
-/address@hidden@*/ char * stripTrailingChar(/address@hidden@*/ char * s, char
c)
- /address@hidden *s */
+/address@hidden@*/ char *
+stripTrailingChar ( /address@hidden@ */ char *s, char c)
+ /address@hidden *s */
{
- char * t;
- for (t = s + strlen(s) - 1; *t == c && t >= s; t--)
- *t = '\0';
- return s;
+ char *t;
+ for (t = s + strlen (s) - 1; *t == c && t >= s; t--)
+ *t = '\0';
+ return s;
}
/** \ingroup header
@@ -1097,20 +1120,22 @@
* @param type type of data (or -1 to force free)
* @return NULL always
*/
-/address@hidden@*/ static /address@hidden@*/
-void * headerFreeData( /address@hidden@*/ /address@hidden@*/ const void *
data, rpmTagType type)
- /address@hidden data @*/
+ /address@hidden@*/ static
+ /address@hidden@ */
+void *
+headerFreeData ( /address@hidden@ *//address@hidden@ */ const void *data,
rpmTagType type)
+ /address@hidden data @ */
{
- if (data) {
- /address@hidden@*/
- if (type == -1 ||
- type == RPM_STRING_ARRAY_TYPE ||
- type == RPM_I18NSTRING_TYPE ||
- type == RPM_BIN_TYPE)
- free((void *)data);
- /address@hidden@*/
+ if (data)
+ {
+ /address@hidden@ */
+ if (type == -1 ||
+ type == RPM_STRING_ARRAY_TYPE ||
+ type == RPM_I18NSTRING_TYPE || type == RPM_BIN_TYPE)
+ free ((void *) data);
+ /address@hidden@ */
}
- return NULL;
+ return NULL;
}
@@ -1124,93 +1149,108 @@
* @return no. bytes in data
*/
/address@hidden@*/
-static int dataLength(int_32 type, hPTR_t p, int_32 count, int onDisk)
- /address@hidden/
+static int
+dataLength (int_32 type, hPTR_t p, int_32 count, int onDisk)
+ /*@ */
{
- int length = 0;
+ int length = 0;
- switch (type) {
+ switch (type)
+ {
case RPM_STRING_TYPE:
- if (count == 1) { /* Special case -- p is just the string */
- length = strlen(p) + 1;
- break;
- }
- /* This should not be allowed */
- /address@hidden@*/
- /address@hidden@*/
- exit(EXIT_FAILURE);
- /address@hidden@*/ break;
+ if (count == 1)
+ { /* Special case -- p is just the string */
+ length = strlen (p) + 1;
+ break;
+ }
+ /* This should not be allowed */
+ /address@hidden@ */
+ /address@hidden@ */
+ exit (EXIT_FAILURE);
+ /address@hidden@ */ break;
case RPM_STRING_ARRAY_TYPE:
case RPM_I18NSTRING_TYPE:
- { int i;
+ {
+ int i;
- /* This is like RPM_STRING_TYPE, except it's *always* an array */
- /* Compute sum of length of all strings, including null terminators */
- i = count;
+ /* This is like RPM_STRING_TYPE, except it's *always* an array */
+ /* Compute sum of length of all strings, including null terminators */
+ i = count;
- if (onDisk) {
- const char * chptr = p;
- int thisLen;
+ if (onDisk)
+ {
+ const char *chptr = p;
+ int thisLen;
- while (i--) {
- thisLen = strlen(chptr) + 1;
- length += thisLen;
- chptr += thisLen;
- }
- } else {
- const char ** src = (const char **)p;
- while (i--) {
- /* add one for null termination */
- length += strlen(*src++) + 1;
- }
- }
- } break;
+ while (i--)
+ {
+ thisLen = strlen (chptr) + 1;
+ length += thisLen;
+ chptr += thisLen;
+ }
+ }
+ else
+ {
+ const char **src = (const char **) p;
+ while (i--)
+ {
+ /* add one for null termination */
+ length += strlen (*src++) + 1;
+ }
+ }
+ }
+ break;
default:
- if (typeSizes[type] != -1) {
- length = typeSizes[type] * count;
- break;
- }
- /address@hidden@*/
- /address@hidden@*/
- exit(EXIT_FAILURE);
- /address@hidden@*/ break;
+ if (typeSizes[type] != -1)
+ {
+ length = typeSizes[type] * count;
+ break;
+ }
+ /address@hidden@ */
+ /address@hidden@ */
+ exit (EXIT_FAILURE);
+ /address@hidden@ */ break;
}
- return length;
+ return length;
}
/**
*/
-static void copyData(int_32 type, /address@hidden@*/ void * dstPtr, const void
* srcPtr,
- int_32 c, int dataLengtha)
- /address@hidden *dstPtr @*/
+static void
+copyData (int_32 type, /address@hidden@ */ void *dstPtr, const void *srcPtr,
+ int_32 c, int dataLengtha)
+ /address@hidden *dstPtr @ */
{
- const char ** src;
- char * dst;
- int i;
+ const char **src;
+ char *dst;
+ int i;
- switch (type) {
+ switch (type)
+ {
case RPM_STRING_ARRAY_TYPE:
case RPM_I18NSTRING_TYPE:
- /* Otherwise, p is char** */
- i = c;
- src = (const char **) srcPtr;
- dst = dstPtr;
- while (i--) {
- if (*src) {
- int len = strlen(*src) + 1;
- memcpy(dst, *src, len);
- dst += len;
- }
- src++;
- }
- break;
+ /* Otherwise, p is char** */
+ i = c;
+ src = (const char **) srcPtr;
+ dst = dstPtr;
+ while (i--)
+ {
+ if (*src)
+ {
+ int len = strlen (*src) + 1;
+ memcpy (dst, *src, len);
+ dst += len;
+ }
+ src++;
+ }
+ break;
default:
- memmove(dstPtr, srcPtr, dataLengtha);
- break;
+ memmove (dstPtr, srcPtr, dataLengtha);
+ break;
}
}
@@ -1222,18 +1262,19 @@
* @retval lengthPtr no. bytes in returned data
* @return (malloc'ed) copy of entry data
*/
-static void * grabData(int_32 type, hPTR_t p, int_32 c,
- /address@hidden@*/ int * lengthPtr)
- /address@hidden *lengthPtr @*/
+static void *
+grabData (int_32 type, hPTR_t p, int_32 c,
+ /address@hidden@ */ int *lengthPtr)
+ /address@hidden *lengthPtr @ */
{
- int length = dataLength(type, p, c, 0);
- void * data = malloc(length);
+ int length = dataLength (type, p, c, 0);
+ void *data = malloc (length);
- copyData(type, data, p, c, length);
+ copyData (type, data, p, c, length);
- if (lengthPtr)
- *lengthPtr = length;
- return data;
+ if (lengthPtr)
+ *lengthPtr = length;
+ return data;
}
@@ -1253,35 +1294,36 @@
* @param c number of values
* @return 1 on success, 0 on failure
*/
-static
-int headerAddEntry(Header h, int_32 tag, int_32 type, const void * p, int_32 c)
- /address@hidden h @*/
+static int
+headerAddEntry (Header h, int_32 tag, int_32 type, const void *p, int_32 c)
+ /address@hidden h @ */
{
- indexEntry entry;
+ indexEntry entry;
- /* Count must always be >= 1 for headerAddEntry. */
- if (c <= 0)
- return 0;
+ /* Count must always be >= 1 for headerAddEntry. */
+ if (c <= 0)
+ return 0;
- /* Allocate more index space if necessary */
- if (h->indexUsed == h->indexAlloced) {
- h->indexAlloced += INDEX_MALLOC_SIZE;
- h->index = realloc(h->index, h->indexAlloced * sizeof(*h->index));
+ /* Allocate more index space if necessary */
+ if (h->indexUsed == h->indexAlloced)
+ {
+ h->indexAlloced += INDEX_MALLOC_SIZE;
+ h->index = realloc (h->index, h->indexAlloced * sizeof (*h->index));
}
- /* Fill in the index */
- entry = h->index + h->indexUsed;
- entry->info.tag = tag;
- entry->info.type = type;
- entry->info.count = c;
- entry->info.offset = 0;
- entry->data = grabData(type, p, c, &entry->length);
+ /* Fill in the index */
+ entry = h->index + h->indexUsed;
+ entry->info.tag = tag;
+ entry->info.type = type;
+ entry->info.count = c;
+ entry->info.offset = 0;
+ entry->data = grabData (type, p, c, &entry->length);
- if (h->indexUsed > 0 && tag < h->index[h->indexUsed-1].info.tag)
- h->flags &= ~HEADERFLAG_SORTED;
- h->indexUsed++;
+ if (h->indexUsed > 0 && tag < h->index[h->indexUsed - 1].info.tag)
+ h->flags &= ~HEADERFLAG_SORTED;
+ h->indexUsed++;
- return 1;
+ return 1;
}
/** \ingroup header
@@ -1289,9 +1331,9 @@
* @param h header
* @return NULL always
*/
-static /address@hidden@*/
-Header headerFree(/address@hidden@*/ /address@hidden@*/ Header h);
- /address@hidden h @*/
+static /address@hidden@ */
+Header headerFree ( /address@hidden@ *//address@hidden@ */ Header h);
+ /address@hidden h @ */
/** \ingroup header
@@ -1299,13 +1341,14 @@
* @param hi header tag iterator
* @return NULL always
*/
-static /address@hidden@*/
-HeaderIterator headerFreeIterator(/address@hidden@*/ HeaderIterator hi)
- /address@hidden hi @*/
+static /address@hidden@ */
+ HeaderIterator
+headerFreeIterator ( /address@hidden@ */ HeaderIterator hi)
+ /address@hidden hi @ */
{
- hi->h = headerFree(hi->h);
- hi = _free(hi);
- return hi;
+ hi->h = headerFree (hi->h);
+ hi = _free (hi);
+ return hi;
}
/**
@@ -1315,48 +1358,53 @@
* @param type entry type
* @return header entry
*/
-static /address@hidden@*/
-indexEntry findEntry(/address@hidden@*/ Header h, int_32 tag, int_32 type)
- /address@hidden h @*/
+static /address@hidden@ */
+ indexEntry
+findEntry ( /address@hidden@ */ Header h, int_32 tag, int_32 type)
+ /address@hidden h @ */
{
- indexEntry entry, entry2, last;
- struct indexEntry key;
+ indexEntry entry, entry2, last;
+ struct indexEntry key;
- if (h == NULL) return NULL;
- if (!(h->flags & HEADERFLAG_SORTED)) headerSort(h);
+ if (h == NULL)
+ return NULL;
+ if (!(h->flags & HEADERFLAG_SORTED))
+ headerSort (h);
- key.info.tag = tag;
+ key.info.tag = tag;
- entry2 = entry =
- bsearch(&key, h->index, h->indexUsed, sizeof(*h->index), indexCmp);
- if (entry == NULL)
- return NULL;
+ entry2 = entry =
+ bsearch (&key, h->index, h->indexUsed, sizeof (*h->index), indexCmp);
+ if (entry == NULL)
+ return NULL;
- if (type == RPM_NULL_TYPE)
- return entry;
+ if (type == RPM_NULL_TYPE)
+ return entry;
- /* look backwards */
- while (entry->info.tag == tag && entry->info.type != type &&
- entry > h->index) entry--;
+ /* look backwards */
+ while (entry->info.tag == tag && entry->info.type != type &&
+ entry > h->index)
+ entry--;
- if (entry->info.tag == tag && entry->info.type == type)
- return entry;
+ if (entry->info.tag == tag && entry->info.type == type)
+ return entry;
- last = h->index + h->indexUsed;
- /address@hidden@*/ /* FIX: entry2 = entry. Code looks bogus as well. */
- while (entry2->info.tag == tag && entry2->info.type != type &&
- entry2 < last) entry2++;
- /address@hidden@*/
+ last = h->index + h->indexUsed;
+ /address@hidden@ *//* FIX: entry2 = entry. Code looks bogus as well. */
+ while (entry2->info.tag == tag && entry2->info.type != type &&
+ entry2 < last)
+ entry2++;
+ /address@hidden@ */
- if (entry->info.tag == tag && entry->info.type == type)
- return entry;
+ if (entry->info.tag == tag && entry->info.type == type)
+ return entry;
- return NULL;
+ return NULL;
}
-static int regionSwab(/address@hidden@*/ indexEntry entry, int il, int dl,
- entryInfo pe, char * dataStart, int regionid);
- /address@hidden *entry, *dataStart @*/
+static int regionSwab ( /address@hidden@ */ indexEntry entry, int il, int dl,
+ entryInfo pe, char *dataStart, int regionid);
+ /address@hidden *entry, *dataStart @ */
/** \ingroup header
* Retrieve data from header entry.
@@ -1368,109 +1416,126 @@
* @param minMem string pointers refer to header memory?
* @return 1 on success, otherwise error.
*/
-static int copyEntry(const indexEntry entry,
- /address@hidden@*/ /address@hidden@*/ hTYP_t type,
- /address@hidden@*/ /address@hidden@*/ hPTR_t * p,
- /address@hidden@*/ /address@hidden@*/ hCNT_t c,
- int minMem)
- /address@hidden *type, *p, *c @*/
+static int
+copyEntry (const indexEntry entry,
+ /address@hidden@ *//address@hidden@ */ hTYP_t type,
+ /address@hidden@ *//address@hidden@ */ hPTR_t * p,
+ /address@hidden@ *//address@hidden@ */ hCNT_t c,
+ int minMem)
+ /address@hidden *type, *p, *c @ */
{
- int_32 count = entry->info.count;
- int rc = 1; /* XXX 1 on success. */
+ int_32 count = entry->info.count;
+ int rc = 1; /* XXX 1 on success. */
- if (p)
- switch (entry->info.type) {
- case RPM_BIN_TYPE:
- /*
- * XXX This only works for
- * XXX "sealed" HEADER_IMMUTABLE/HEADER_SIGNATURES/HEADER_IMAGE.
- * XXX This will *not* work for unsealed legacy HEADER_IMAGE (i.e.
- * XXX a legacy header freshly read, but not yet unloaded to the rpmdb).
- */
- if (ENTRY_IS_REGION(entry)) {
- int_32 * ei = ((int_32 *)entry->data) - 2;
- /address@hidden@*/
- entryInfo pe = (entryInfo) (ei + 2);
- /address@hidden@*/
- char * dataStart = (char *) (pe + ntohl(ei[0]));
- int_32 rdl = -entry->info.offset; /* negative offset */
- int_32 ril = rdl/sizeof(*pe);
+ if (p)
+ switch (entry->info.type)
+ {
+ case RPM_BIN_TYPE:
+ /*
+ * XXX This only works for
+ * XXX "sealed" HEADER_IMMUTABLE/HEADER_SIGNATURES/HEADER_IMAGE.
+ * XXX This will *not* work for unsealed legacy HEADER_IMAGE (i.e.
+ * XXX a legacy header freshly read, but not yet unloaded to the
rpmdb).
+ */
+ if (ENTRY_IS_REGION (entry))
+ {
+ int_32 *ei = ((int_32 *) entry->data) - 2;
+ /address@hidden@ */
+ entryInfo pe = (entryInfo) (ei + 2);
+ /address@hidden@ */
+ char *dataStart = (char *) (pe + ntohl (ei[0]));
+ int_32 rdl = -entry->info.offset; /* negative offset */
+ int_32 ril = rdl / sizeof (*pe);
- /address@hidden@*/
- rdl = entry->rdlen;
- count = 2 * sizeof(*ei) + (ril * sizeof(*pe)) + rdl;
- if (entry->info.tag == HEADER_IMAGE) {
- ril -= 1;
- pe += 1;
- } else {
- count += REGION_TAG_COUNT;
- rdl += REGION_TAG_COUNT;
- }
+ /address@hidden@ */
+ rdl = entry->rdlen;
+ count = 2 * sizeof (*ei) + (ril * sizeof (*pe)) + rdl;
+ if (entry->info.tag == HEADER_IMAGE)
+ {
+ ril -= 1;
+ pe += 1;
+ }
+ else
+ {
+ count += REGION_TAG_COUNT;
+ rdl += REGION_TAG_COUNT;
+ }
- *p = malloc(count);
- ei = (int_32 *) *p;
- ei[0] = htonl(ril);
- ei[1] = htonl(rdl);
+ *p = malloc (count);
+ ei = (int_32 *) * p;
+ ei[0] = htonl (ril);
+ ei[1] = htonl (rdl);
- /address@hidden@*/
- pe = (entryInfo) memcpy(ei + 2, pe, (ril * sizeof(*pe)));
- /address@hidden@*/
+ /address@hidden@ */
+ pe = (entryInfo) memcpy (ei + 2, pe, (ril * sizeof (*pe)));
+ /address@hidden@ */
- dataStart = (char *) memcpy(pe + ril, dataStart, rdl);
- /address@hidden@*/
+ dataStart = (char *) memcpy (pe + ril, dataStart, rdl);
+ /address@hidden@ */
- rc = regionSwab(NULL, ril, 0, pe, dataStart, 0);
- /* XXX 1 on success. */
- rc = (rc < 0) ? 0 : 1;
- } else {
- count = entry->length;
- *p = (!minMem
- ? memcpy(malloc(count), entry->data, count)
- : entry->data);
- }
- break;
- case RPM_STRING_TYPE:
- if (count == 1) {
- *p = entry->data;
- break;
- }
- /address@hidden@*/
- case RPM_STRING_ARRAY_TYPE:
- case RPM_I18NSTRING_TYPE:
- { const char ** ptrEntry;
- /address@hidden@*/
- int tableSize = count * sizeof(char *);
- /address@hidden@*/
- char * t;
- int i;
+ rc = regionSwab (NULL, ril, 0, pe, dataStart, 0);
+ /* XXX 1 on success. */
+ rc = (rc < 0) ? 0 : 1;
+ }
+ else
+ {
+ count = entry->length;
+ *p = (!minMem
+ ? memcpy (malloc (count), entry->data, count)
+ : entry->data);
+ }
+ break;
+ case RPM_STRING_TYPE:
+ if (count == 1)
+ {
+ *p = entry->data;
+ break;
+ }
+ /address@hidden@ */
+ case RPM_STRING_ARRAY_TYPE:
+ case RPM_I18NSTRING_TYPE:
+ {
+ const char **ptrEntry;
+ /address@hidden@ */
+ int tableSize = count * sizeof (char *);
+ /address@hidden@ */
+ char *t;
+ int i;
- /address@hidden@*/
- if (minMem) {
- *p = malloc(tableSize);
- ptrEntry = (const char **) *p;
- t = entry->data;
- } else {
- t = malloc(tableSize + entry->length);
- *p = (void *)t;
- ptrEntry = (const char **) *p;
- t += tableSize;
- memcpy(t, entry->data, entry->length);
- }
- /address@hidden@*/
- for (i = 0; i < count; i++) {
- *ptrEntry++ = t;
- t = strchr(t, 0);
- t++;
- }
- } break;
+ /address@hidden@ */
+ if (minMem)
+ {
+ *p = malloc (tableSize);
+ ptrEntry = (const char **) *p;
+ t = entry->data;
+ }
+ else
+ {
+ t = malloc (tableSize + entry->length);
+ *p = (void *) t;
+ ptrEntry = (const char **) *p;
+ t += tableSize;
+ memcpy (t, entry->data, entry->length);
+ }
+ /address@hidden@ */
+ for (i = 0; i < count; i++)
+ {
+ *ptrEntry++ = t;
+ t = strchr (t, 0);
+ t++;
+ }
+ }
+ break;
- default:
- *p = entry->data;
- break;
- }
- if (type) *type = entry->info.type;
- if (c) *c = count;
- return rc;
+ default:
+ *p = entry->data;
+ break;
+ }
+ if (type)
+ *type = entry->info.type;
+ if (c)
+ *c = count;
+ return rc;
}
#define ENTRY_IN_REGION(_e) ((_e)->info.offset < 0)
@@ -1489,41 +1554,43 @@
* @param c number of values
* @return 1 on success, 0 on failure
*/
-static
-int headerAppendEntry(Header h, int_32 tag, int_32 type,
- const void * p, int_32 c)
- /address@hidden h @*/
+static int
+headerAppendEntry (Header h, int_32 tag, int_32 type, const void *p, int_32 c)
+ /address@hidden h @ */
{
- indexEntry entry;
- int length;
+ indexEntry entry;
+ int length;
- /* First find the tag */
- entry = findEntry(h, tag, type);
- if (!entry)
- return 0;
+ /* First find the tag */
+ entry = findEntry (h, tag, type);
+ if (!entry)
+ return 0;
- if (type == RPM_STRING_TYPE || type == RPM_I18NSTRING_TYPE) {
- /* we can't do this */
- return 0;
+ if (type == RPM_STRING_TYPE || type == RPM_I18NSTRING_TYPE)
+ {
+ /* we can't do this */
+ return 0;
}
- length = dataLength(type, p, c, 0);
+ length = dataLength (type, p, c, 0);
- if (ENTRY_IN_REGION(entry)) {
- char * t = malloc(entry->length + length);
- memcpy(t, entry->data, entry->length);
- entry->data = t;
- entry->info.offset = 0;
- } else
- entry->data = realloc(entry->data, entry->length + length);
+ if (ENTRY_IN_REGION (entry))
+ {
+ char *t = malloc (entry->length + length);
+ memcpy (t, entry->data, entry->length);
+ entry->data = t;
+ entry->info.offset = 0;
+ }
+ else
+ entry->data = realloc (entry->data, entry->length + length);
- copyData(type, ((char *) entry->data) + entry->length, p, c, length);
+ copyData (type, ((char *) entry->data) + entry->length, p, c, length);
- entry->length += length;
+ entry->length += length;
- entry->info.count += c;
+ entry->info.count += c;
- return 1;
+ return 1;
}
/** \ingroup header
@@ -1536,14 +1603,14 @@
* @param c number of values
* @return 1 on success, 0 on failure
*/
-static
-int headerAddOrAppendEntry(Header h, int_32 tag, int_32 type,
- const void * p, int_32 c)
- /address@hidden h @*/
+static int
+headerAddOrAppendEntry (Header h, int_32 tag, int_32 type,
+ const void *p, int_32 c)
+ /address@hidden h @ */
{
- return (findEntry(h, tag, type)
- ? headerAppendEntry(h, tag, type, p, c)
- : headerAddEntry(h, tag, type, p, c));
+ return (findEntry (h, tag, type)
+ ? headerAppendEntry (h, tag, type, p, c)
+ : headerAddEntry (h, tag, type, p, c));
}
/**
@@ -1564,70 +1631,78 @@
* @param le end of locale to match
* @return 1 on match, 0 on no match
*/
-static int headerMatchLocale(const char *td, const char *l, const char *le)
- /address@hidden/
+static int
+headerMatchLocale (const char *td, const char *l, const char *le)
+ /*@ */
{
- const char *fe;
+ const char *fe;
#if 0
- { const char *s, *ll, *CC, *EE, *dd;
+ {
+ const char *s, *ll, *CC, *EE, *dd;
char *lbuf, *t.
+ /* Copy the buffer and parse out components on the fly. */
+ lbuf = alloca (le - l + 1);
+ for (s = l, ll = t = lbuf; *s; s++, t++)
+ {
+ switch (*s)
+ {
+ case '_':
+ *t = '\0';
+ CC = t + 1;
+ break;
+ case '.':
+ *t = '\0';
+ EE = t + 1;
+ break;
+ case '@':
+ *t = '\0';
+ dd = t + 1;
+ break;
+ default:
+ *t = *s;
+ break;
+ }
+ }
- /* Copy the buffer and parse out components on the fly. */
- lbuf = alloca(le - l + 1);
- for (s = l, ll = t = lbuf; *s; s++, t++) {
- switch (*s) {
- case '_':
- *t = '\0';
- CC = t + 1;
- break;
- case '.':
- *t = '\0';
- EE = t + 1;
- break;
- case '@':
- *t = '\0';
- dd = t + 1;
- break;
- default:
- *t = *s;
- break;
- }
- }
+ if (ll) /* ISO language should be lower case */
+ for (t = ll; *t; t++)
+ *t = tolower (*t);
+ if (CC) /* ISO country code should be upper case */
+ for (t = CC; *t; t++)
+ *t = toupper (*t);
- if (ll) /* ISO language should be lower case */
- for (t = ll; *t; t++) *t = tolower(*t);
- if (CC) /* ISO country code should be upper case */
- for (t = CC; *t; t++) *t = toupper(*t);
-
/* There are a total of 16 cases to attempt to match. */
}
#endif
- /* First try a complete match. */
- if (strlen(td) == (le-l) && !strncmp(td, l, (le - l)))
- return 1;
+ /* First try a complete match. */
+ if (strlen (td) == (le - l) && !strncmp (td, l, (le - l)))
+ return 1;
- /* Next, try stripping optional dialect and matching. */
- for (fe = l; fe < le && *fe != '@'; fe++)
- {};
- if (fe < le && !strncmp(td, l, (fe - l)))
- return 1;
+ /* Next, try stripping optional dialect and matching. */
+ for (fe = l; fe < le && *fe != '@'; fe++)
+ {
+ };
+ if (fe < le && !strncmp (td, l, (fe - l)))
+ return 1;
- /* Next, try stripping optional codeset and matching. */
- for (fe = l; fe < le && *fe != '.'; fe++)
- {};
- if (fe < le && !strncmp(td, l, (fe - l)))
- return 1;
+ /* Next, try stripping optional codeset and matching. */
+ for (fe = l; fe < le && *fe != '.'; fe++)
+ {
+ };
+ if (fe < le && !strncmp (td, l, (fe - l)))
+ return 1;
- /* Finally, try stripping optional country code and matching. */
- for (fe = l; fe < le && *fe != '_'; fe++)
- {};
- if (fe < le && !strncmp(td, l, (fe - l)))
- return 1;
+ /* Finally, try stripping optional country code and matching. */
+ for (fe = l; fe < le && *fe != '_'; fe++)
+ {
+ };
+ if (fe < le && !strncmp (td, l, (fe - l)))
+ return 1;
- return 0;
+ return 0;
}
/**
@@ -1636,49 +1711,53 @@
* @param entry i18n string data
* @return matching i18n string (or 1st string if no match)
*/
-/address@hidden@*/ /address@hidden@*/ static char *
-headerFindI18NString(Header h, indexEntry entry)
- /address@hidden/
+ /address@hidden@*//address@hidden@ */ static char *
+headerFindI18NString (Header h, indexEntry entry)
+ /*@ */
{
- const char *lang, *l, *le;
- indexEntry table;
+ const char *lang, *l, *le;
+ indexEntry table;
- /* XXX Drepper sez' this is the order. */
- if ((lang = getenv("LANGUAGE")) == NULL &&
- (lang = getenv("LC_ALL")) == NULL &&
- (lang = getenv("LC_MESSAGES")) == NULL &&
- (lang = getenv("LANG")) == NULL)
- return entry->data;
+ /* XXX Drepper sez' this is the order. */
+ if ((lang = getenv ("LANGUAGE")) == NULL &&
+ (lang = getenv ("LC_ALL")) == NULL &&
+ (lang = getenv ("LC_MESSAGES")) == NULL &&
+ (lang = getenv ("LANG")) == NULL)
+ return entry->data;
- /address@hidden@*/
- if ((table = findEntry(h, HEADER_I18NTABLE, RPM_STRING_ARRAY_TYPE)) ==
NULL)
- return entry->data;
- /address@hidden@*/
+ /address@hidden@ */
+ if ((table =
+ findEntry (h, HEADER_I18NTABLE, RPM_STRING_ARRAY_TYPE)) == NULL)
+ return entry->data;
+ /address@hidden@ */
- for (l = lang; *l != '\0'; l = le) {
- const char *td;
- char *ed;
- int langNum;
+ for (l = lang; *l != '\0'; l = le)
+ {
+ const char *td;
+ char *ed;
+ int langNum;
- while (*l && *l == ':') /* skip leading colons */
- l++;
- if (*l == '\0')
- break;
- for (le = l; *le && *le != ':'; le++) /* find end of this locale */
- {};
+ while (*l && *l == ':') /* skip leading colons */
+ l++;
+ if (*l == '\0')
+ break;
+ for (le = l; *le && *le != ':'; le++) /* find end of this locale */
+ {
+ };
- /* For each entry in the header ... */
- for (langNum = 0, td = table->data, ed = entry->data;
- langNum < entry->info.count;
- langNum++, td += strlen(td) + 1, ed += strlen(ed) + 1) {
+ /* For each entry in the header ... */
+ for (langNum = 0, td = table->data, ed = entry->data;
+ langNum < entry->info.count;
+ langNum++, td += strlen (td) + 1, ed += strlen (ed) + 1)
+ {
- if (headerMatchLocale(td, l, le))
- return ed;
+ if (headerMatchLocale (td, l, le))
+ return ed;
- }
+ }
}
- return entry->data;
+ return entry->data;
}
/**
@@ -1691,43 +1770,52 @@
* @param minMem string pointers reference header memory?
* @return 1 on success, 0 on not found
*/
-static int intGetEntry(Header h, int_32 tag,
- /address@hidden@*/ /address@hidden@*/ hTAG_t type,
- /address@hidden@*/ /address@hidden@*/ hPTR_t * p,
- /address@hidden@*/ /address@hidden@*/ hCNT_t c,
- int minMem)
- /address@hidden *type, *p, *c @*/
+static int
+intGetEntry (Header h, int_32 tag,
+ /address@hidden@ *//address@hidden@ */ hTAG_t type,
+ /address@hidden@ *//address@hidden@ */ hPTR_t * p,
+ /address@hidden@ *//address@hidden@ */ hCNT_t c,
+ int minMem)
+ /address@hidden *type, *p, *c @ */
{
- indexEntry entry;
- int rc;
+ indexEntry entry;
+ int rc;
- /* First find the tag */
- /address@hidden@*/ /*@ FIX: h modified by sort. */
- entry = findEntry(h, tag, RPM_NULL_TYPE);
- /address@hidden@*/
- if (entry == NULL) {
- if (type) type = 0;
- if (p) *p = NULL;
- if (c) *c = 0;
- return 0;
+ /* First find the tag */
+ /address@hidden@ *//*@ FIX: h modified by sort. */
+ entry = findEntry (h, tag, RPM_NULL_TYPE);
+ /address@hidden@ */
+ if (entry == NULL)
+ {
+ if (type)
+ type = 0;
+ if (p)
+ *p = NULL;
+ if (c)
+ *c = 0;
+ return 0;
}
- switch (entry->info.type) {
+ switch (entry->info.type)
+ {
case RPM_I18NSTRING_TYPE:
- rc = 1;
- if (type) *type = RPM_STRING_TYPE;
- if (c) *c = 1;
- /address@hidden@*/
- if (p) *p = headerFindI18NString(h, entry);
- /address@hidden@*/
- break;
+ rc = 1;
+ if (type)
+ *type = RPM_STRING_TYPE;
+ if (c)
+ *c = 1;
+ /address@hidden@ */
+ if (p)
+ *p = headerFindI18NString (h, entry);
+ /address@hidden@ */
+ break;
default:
- rc = copyEntry(entry, type, p, c, minMem);
- break;
+ rc = copyEntry (entry, type, p, c, minMem);
+ break;
}
- /* XXX 1 on success */
- return ((rc == 1) ? 1 : 0);
+ /* XXX 1 on success */
+ return ((rc == 1) ? 1 : 0);
}
/** \ingroup header
@@ -1743,21 +1831,21 @@
* @retval c address of number of values (or NULL)
* @return 1 on success, 0 on failure
*/
-static
-int headerGetEntry(Header h, int_32 tag,
- /address@hidden@*/ /address@hidden@*/ hTYP_t type,
- /address@hidden@*/ /address@hidden@*/ void ** p,
- /address@hidden@*/ /address@hidden@*/ hCNT_t c)
- /address@hidden *type, *p, *c @*/
+static int
+headerGetEntry (Header h, int_32 tag,
+ /address@hidden@ *//address@hidden@ */ hTYP_t type,
+ /address@hidden@ *//address@hidden@ */ void **p,
+ /address@hidden@ *//address@hidden@ */ hCNT_t c)
+ /address@hidden *type, *p, *c @ */
{
- return intGetEntry(h, tag, type, (hPTR_t *)p, c, 0);
+ return intGetEntry (h, tag, type, (hPTR_t *) p, c, 0);
}
/** \ingroup header
*/
-/address@hidden@*/ /address@hidden@*/
+ /address@hidden@*//address@hidden@ */
static unsigned char header_magic[8] = {
- 0x8e, 0xad, 0xe8, 0x01, 0x00, 0x00, 0x00, 0x00
+ 0x8e, 0xad, 0xe8, 0x01, 0x00, 0x00, 0x00, 0x00
};
/** \ingroup header
@@ -1766,65 +1854,70 @@
* @param magicp include size of 8 bytes for (magic, 0)?
* @return size of on-disk header
*/
-static
-unsigned int headerSizeof(/address@hidden@*/ Header h, enum hMagic magicp)
- /address@hidden h @*/
+static unsigned int
+headerSizeof ( /address@hidden@ */ Header h, enum hMagic magicp)
+ /address@hidden h @ */
{
- indexEntry entry;
- unsigned int size = 0;
- int i;
+ indexEntry entry;
+ unsigned int size = 0;
+ int i;
- if (h == NULL)
- return size;
+ if (h == NULL)
+ return size;
- headerSort(h);
+ headerSort (h);
- switch (magicp) {
+ switch (magicp)
+ {
case HEADER_MAGIC_YES:
- size += sizeof(header_magic);
- break;
+ size += sizeof (header_magic);
+ break;
case HEADER_MAGIC_NO:
- break;
+ break;
}
- /address@hidden@*/
- size += 2 * sizeof(int_32); /* count of index entries */
- /address@hidden@*/
+ /address@hidden@ */
+ size += 2 * sizeof (int_32); /* count of index entries */
+ /address@hidden@ */
- for (i = 0, entry = h->index; i < h->indexUsed; i++, entry++) {
- unsigned diff;
- int_32 type;
+ for (i = 0, entry = h->index; i < h->indexUsed; i++, entry++)
+ {
+ unsigned diff;
+ int_32 type;
- /* Regions go in as is ... */
- if (ENTRY_IS_REGION(entry)) {
- size += entry->length;
- /* XXX Legacy regions do not include the region tag and data. */
- /address@hidden@*/
- if (i == 0 && (h->flags & HEADERFLAG_LEGACY))
- size += sizeof(struct entryInfo) + entry->info.count;
- /address@hidden@*/
- continue;
+ /* Regions go in as is ... */
+ if (ENTRY_IS_REGION (entry))
+ {
+ size += entry->length;
+ /* XXX Legacy regions do not include the region tag and data. */
+ /address@hidden@ */
+ if (i == 0 && (h->flags & HEADERFLAG_LEGACY))
+ size += sizeof (struct entryInfo) + entry->info.count;
+ /address@hidden@ */
+ continue;
}
- /* ... and region elements are skipped. */
- if (entry->info.offset < 0)
- continue;
+ /* ... and region elements are skipped. */
+ if (entry->info.offset < 0)
+ continue;
- /* Alignment */
- type = entry->info.type;
- if (typeSizes[type] > 1) {
- diff = typeSizes[type] - (size % typeSizes[type]);
- if (diff != typeSizes[type]) {
- size += diff;
- }
- }
+ /* Alignment */
+ type = entry->info.type;
+ if (typeSizes[type] > 1)
+ {
+ diff = typeSizes[type] - (size % typeSizes[type]);
+ if (diff != typeSizes[type])
+ {
+ size += diff;
+ }
+ }
- /address@hidden@*/
- size += sizeof(struct entryInfo) + entry->length;
- /address@hidden@*/
+ /address@hidden@ */
+ size += sizeof (struct entryInfo) + entry->length;
+ /address@hidden@ */
}
- return size;
+ return size;
}
/** \ingroup header
@@ -1832,14 +1925,15 @@
* @param h header
* @return referenced header instance
*/
-static
-Header headerLink(Header h)
- /address@hidden h @*/
+static Header
+headerLink (Header h)
+ /address@hidden h @ */
{
- if (h != NULL) h->nrefs++;
- /address@hidden -nullret @*/
- return h;
- /address@hidden =nullret @*/
+ if (h != NULL)
+ h->nrefs++;
+ /address@hidden -nullret @ */
+ return h;
+ /address@hidden =nullret @ */
}
/** \ingroup header
@@ -1847,17 +1941,17 @@
* @param h header
* @return header tag iterator
*/
-static
-HeaderIterator headerInitIterator(Header h)
- /address@hidden h */
+static HeaderIterator
+headerInitIterator (Header h)
+ /address@hidden h */
{
- HeaderIterator hi = malloc(sizeof(*hi));
+ HeaderIterator hi = malloc (sizeof (*hi));
- headerSort(h);
+ headerSort (h);
- hi->h = headerLink(h);
- hi->next_index = 0;
- return hi;
+ hi->h = headerLink (h);
+ hi->next_index = 0;
+ return hi;
}
/** \ingroup header
@@ -1866,13 +1960,13 @@
* @param tag tag
* @return 1 on success, 0 on failure
*/
-static
-int headerIsEntry(/address@hidden@*/Header h, int_32 tag)
- /address@hidden/
+static int
+headerIsEntry ( /address@hidden@ */ Header h, int_32 tag)
+ /*@ */
{
- /address@hidden@*/ /*@ FIX: h modified by sort. */
- return (findEntry(h, tag, RPM_NULL_TYPE) ? 1 : 0);
- /address@hidden@*/
+ /address@hidden@ *//*@ FIX: h modified by sort. */
+ return (findEntry (h, tag, RPM_NULL_TYPE) ? 1 : 0);
+ /address@hidden@ */
}
/** \ingroup header
@@ -1884,39 +1978,40 @@
* @retval c address of number of values
* @return 1 on success, 0 on failure
*/
-static
-int headerNextIterator(HeaderIterator hi,
- /address@hidden@*/ /address@hidden@*/ hTAG_t tag,
- /address@hidden@*/ /address@hidden@*/ hTYP_t type,
- /address@hidden@*/ /address@hidden@*/ hPTR_t * p,
- /address@hidden@*/ /address@hidden@*/ hCNT_t c,
- int do_copy)
- /address@hidden hi, *tag, *type, *p, *c @*/
+static int
+headerNextIterator (HeaderIterator hi,
+ /address@hidden@ *//address@hidden@ */ hTAG_t tag,
+ /address@hidden@ *//address@hidden@ */ hTYP_t type,
+ /address@hidden@ *//address@hidden@ */ hPTR_t * p,
+ /address@hidden@ *//address@hidden@ */ hCNT_t c,
+ int do_copy)
+ /address@hidden hi, *tag, *type, *p, *c @ */
{
- Header h = hi->h;
- int slot = hi->next_index;
- indexEntry entry = NULL;
- int rc;
+ Header h = hi->h;
+ int slot = hi->next_index;
+ indexEntry entry = NULL;
+ int rc;
- for (slot = hi->next_index; slot < h->indexUsed; slot++) {
- entry = h->index + slot;
- if (!ENTRY_IS_REGION(entry))
- break;
+ for (slot = hi->next_index; slot < h->indexUsed; slot++)
+ {
+ entry = h->index + slot;
+ if (!ENTRY_IS_REGION (entry))
+ break;
}
- hi->next_index = slot;
- if (entry == NULL || slot >= h->indexUsed)
- return 0;
- /address@hidden@*/ /* LCL: no clue */
- hi->next_index++;
- /address@hidden@*/
+ hi->next_index = slot;
+ if (entry == NULL || slot >= h->indexUsed)
+ return 0;
+ /address@hidden@ *//* LCL: no clue */
+ hi->next_index++;
+ /address@hidden@ */
- if (tag)
- *tag = entry->info.tag;
+ if (tag)
+ *tag = entry->info.tag;
- rc = copyEntry(entry, type, p, c, do_copy);
+ rc = copyEntry (entry, type, p, c, do_copy);
- /* XXX 1 on success */
- return ((rc == 1) ? 1 : 0);
+ /* XXX 1 on success */
+ return ((rc == 1) ? 1 : 0);
}
/** \ingroup header
@@ -1924,12 +2019,14 @@
* @param h header
* @return NULL always
*/
-static /address@hidden@*/
-Header headerUnlink(/address@hidden@*/ /address@hidden@*/ Header h)
- /address@hidden h @*/
+static /address@hidden@ */
+ Header
+headerUnlink ( /address@hidden@ *//address@hidden@ */ Header h)
+ /address@hidden h @ */
{
- if (h != NULL) h->nrefs--;
- return NULL;
+ if (h != NULL)
+ h->nrefs--;
+ return NULL;
}
/** \ingroup header
@@ -1937,37 +2034,46 @@
* @param h header
* @return NULL always
*/
-static /address@hidden@*/
-Header headerFree(/address@hidden@*/ /address@hidden@*/ Header h)
- /address@hidden h @*/
+static /address@hidden@ */
+ Header
+headerFree ( /address@hidden@ *//address@hidden@ */ Header h)
+ /address@hidden h @ */
{
- (void) headerUnlink(h);
+ (void) headerUnlink (h);
- /address@hidden@*/
- if (h == NULL || h->nrefs > 0)
- return NULL; /* XXX return previous header? */
+ /address@hidden@ */
+ if (h == NULL || h->nrefs > 0)
+ return NULL; /* XXX return previous header? */
- if (h->index) {
- indexEntry entry = h->index;
- int i;
- for (i = 0; i < h->indexUsed; i++, entry++) {
- if ((h->flags & HEADERFLAG_ALLOCATED) && ENTRY_IS_REGION(entry)) {
- if (entry->length > 0) {
- int_32 * ei = entry->data;
- if ((ei - 2) == h->blob) h->blob = _free(h->blob);
- entry->data = NULL;
- }
- } else if (!ENTRY_IN_REGION(entry)) {
- entry->data = _free(entry->data);
- }
- entry->data = NULL;
- }
- h->index = _free(h->index);
+ if (h->index)
+ {
+ indexEntry entry = h->index;
+ int i;
+ for (i = 0; i < h->indexUsed; i++, entry++)
+ {
+ if ((h->flags & HEADERFLAG_ALLOCATED) && ENTRY_IS_REGION (entry))
+ {
+ if (entry->length > 0)
+ {
+ int_32 *ei = entry->data;
+ if ((ei - 2) == h->blob)
+ h->blob = _free (h->blob);
+ entry->data = NULL;
+ }
+ }
+ else if (!ENTRY_IN_REGION (entry))
+ {
+ entry->data = _free (entry->data);
+ }
+ entry->data = NULL;
+ }
+ h->index = _free (h->index);
}
- /address@hidden@*/ h = _free(h); /address@hidden@*/
- return h;
- /address@hidden@*/
+ /address@hidden@ */ h = _free (h);
+ /address@hidden@ */
+ return h;
+ /address@hidden@ */
}
/**
@@ -2009,283 +2115,308 @@
* @param regionid region offset
* @return no. bytes of data in region, -1 on error
*/
-static int regionSwab(/address@hidden@*/ indexEntry entry, int il, int dl,
- entryInfo pe, char * dataStart, int regionid)
- /address@hidden *entry, *dataStart @*/
+static int
+regionSwab ( /address@hidden@ */ indexEntry entry, int il, int dl,
+ entryInfo pe, char *dataStart, int regionid)
+ /address@hidden *entry, *dataStart @ */
{
- char * tprev = NULL;
- char * t = NULL;
- int tdel, tl = dl;
- struct indexEntry ieprev;
+ char *tprev = NULL;
+ char *t = NULL;
+ int tdel, tl = dl;
+ struct indexEntry ieprev;
- memset(&ieprev, 0, sizeof(ieprev));
- for (; il > 0; il--, pe++) {
- struct indexEntry ie;
- int_32 type;
+ memset (&ieprev, 0, sizeof (ieprev));
+ for (; il > 0; il--, pe++)
+ {
+ struct indexEntry ie;
+ int_32 type;
- ie.info.tag = ntohl(pe->tag);
- ie.info.type = ntohl(pe->type);
- if (ie.info.type < RPM_MIN_TYPE || ie.info.type > RPM_MAX_TYPE)
- return -1;
- ie.info.count = ntohl(pe->count);
- ie.info.offset = ntohl(pe->offset);
- ie.data = t = dataStart + ie.info.offset;
- ie.length = dataLength(ie.info.type, ie.data, ie.info.count, 1);
- ie.rdlen = 0;
+ ie.info.tag = ntohl (pe->tag);
+ ie.info.type = ntohl (pe->type);
+ if (ie.info.type < RPM_MIN_TYPE || ie.info.type > RPM_MAX_TYPE)
+ return -1;
+ ie.info.count = ntohl (pe->count);
+ ie.info.offset = ntohl (pe->offset);
+ ie.data = t = dataStart + ie.info.offset;
+ ie.length = dataLength (ie.info.type, ie.data, ie.info.count, 1);
+ ie.rdlen = 0;
- if (entry) {
- ie.info.offset = regionid;
- *entry = ie; /* structure assignment */
- entry++;
- }
+ if (entry)
+ {
+ ie.info.offset = regionid;
+ *entry = ie; /* structure assignment */
+ entry++;
+ }
- /* Alignment */
- type = ie.info.type;
- if (typeSizes[type] > 1) {
- unsigned diff;
- diff = typeSizes[type] - (dl % typeSizes[type]);
- if (diff != typeSizes[type]) {
- dl += diff;
- if (ieprev.info.type == RPM_I18NSTRING_TYPE)
- ieprev.length += diff;
- }
- }
- tdel = (tprev ? (t - tprev) : 0);
- if (ieprev.info.type == RPM_I18NSTRING_TYPE)
- tdel = ieprev.length;
+ /* Alignment */
+ type = ie.info.type;
+ if (typeSizes[type] > 1)
+ {
+ unsigned diff;
+ diff = typeSizes[type] - (dl % typeSizes[type]);
+ if (diff != typeSizes[type])
+ {
+ dl += diff;
+ if (ieprev.info.type == RPM_I18NSTRING_TYPE)
+ ieprev.length += diff;
+ }
+ }
+ tdel = (tprev ? (t - tprev) : 0);
+ if (ieprev.info.type == RPM_I18NSTRING_TYPE)
+ tdel = ieprev.length;
- if (ie.info.tag >= HEADER_I18NTABLE) {
- tprev = t;
- } else {
- tprev = dataStart;
- /* XXX HEADER_IMAGE tags don't include region sub-tag. */
- /address@hidden@*/
- if (ie.info.tag == HEADER_IMAGE)
- tprev -= REGION_TAG_COUNT;
- /address@hidden@*/
- }
+ if (ie.info.tag >= HEADER_I18NTABLE)
+ {
+ tprev = t;
+ }
+ else
+ {
+ tprev = dataStart;
+ /* XXX HEADER_IMAGE tags don't include region sub-tag. */
+ /address@hidden@ */
+ if (ie.info.tag == HEADER_IMAGE)
+ tprev -= REGION_TAG_COUNT;
+ /address@hidden@ */
+ }
- /* Perform endian conversions */
- switch (ntohl(pe->type)) {
- case RPM_INT32_TYPE:
- { int_32 * it = (int_32 *)t;
- for (; ie.info.count > 0; ie.info.count--, it += 1)
- *it = htonl(*it);
- t = (char *) it;
- } /address@hidden@*/ break;
- case RPM_INT16_TYPE:
- { unsigned short * it = (unsigned short *) t;
- for (; ie.info.count > 0; ie.info.count--, it += 1)
- *it = htons(*it);
- t = (char *) it;
- } /address@hidden@*/ break;
- default:
- t += ie.length;
- /address@hidden@*/ break;
- }
+ /* Perform endian conversions */
+ switch (ntohl (pe->type))
+ {
+ case RPM_INT32_TYPE:
+ {
+ int_32 *it = (int_32 *) t;
+ for (; ie.info.count > 0; ie.info.count--, it += 1)
+ *it = htonl (*it);
+ t = (char *) it;
+ } /address@hidden@ */ break;
+ case RPM_INT16_TYPE:
+ {
+ unsigned short *it = (unsigned short *) t;
+ for (; ie.info.count > 0; ie.info.count--, it += 1)
+ *it = htons (*it);
+ t = (char *) it;
+ } /address@hidden@ */ break;
+ default:
+ t += ie.length;
+ /address@hidden@ */ break;
+ }
- dl += ie.length;
- tl += tdel;
- ieprev = ie; /* structure assignment */
+ dl += ie.length;
+ tl += tdel;
+ ieprev = ie; /* structure assignment */
}
- tdel = (tprev ? (t - tprev) : 0);
- tl += tdel;
+ tdel = (tprev ? (t - tprev) : 0);
+ tl += tdel;
- /* XXX
- * There are two hacks here:
- * 1) tl is 16b (i.e. REGION_TAG_COUNT) short while doing headerReload().
- * 2) the 8/98 rpm bug with inserting i18n tags needs to use tl, not dl.
- */
- /address@hidden@*/
- if (tl+REGION_TAG_COUNT == dl)
- tl += REGION_TAG_COUNT;
- /address@hidden@*/
+ /* XXX
+ * There are two hacks here:
+ * 1) tl is 16b (i.e. REGION_TAG_COUNT) short while doing headerReload().
+ * 2) the 8/98 rpm bug with inserting i18n tags needs to use tl, not dl.
+ */
+ /address@hidden@ */
+ if (tl + REGION_TAG_COUNT == dl)
+ tl += REGION_TAG_COUNT;
+ /address@hidden@ */
- return dl;
+ return dl;
}
-static
-int headerRemoveEntry(Header h, int_32 tag);
+static int headerRemoveEntry (Header h, int_32 tag);
/** \ingroup header
* Convert header to in-memory representation.
* @param uh on-disk header blob (i.e. with offsets)
* @return header
*/
-static /address@hidden@*/
-Header headerLoad(/address@hidden@*/ void * uh)
- /address@hidden uh @*/
+static /address@hidden@ */
+ Header
+headerLoad ( /address@hidden@ */ void *uh)
+ /address@hidden uh @ */
{
- int_32 * ei = (int_32 *) uh;
- int_32 il = ntohl(ei[0]); /* index length */
- int_32 dl = ntohl(ei[1]); /* data length */
- /address@hidden@*/
- size_t pvlen = sizeof(il) + sizeof(dl) +
- (il * sizeof(struct entryInfo)) + dl;
- /address@hidden@*/
- void * pv = uh;
- Header h = NULL;
- entryInfo pe;
- char * dataStart;
- indexEntry entry;
- int rdlen;
+ int_32 *ei = (int_32 *) uh;
+ int_32 il = ntohl (ei[0]); /* index length */
+ int_32 dl = ntohl (ei[1]); /* data length */
+ /address@hidden@ */
+ size_t pvlen = sizeof (il) + sizeof (dl) +
+ (il * sizeof (struct entryInfo)) + dl;
+ /address@hidden@ */
+ void *pv = uh;
+ Header h = NULL;
+ entryInfo pe;
+ char *dataStart;
+ indexEntry entry;
+ int rdlen;
- /* Sanity checks on header intro. */
- if (hdrchkTags(il) || hdrchkData(dl))
- goto errxit;
+ /* Sanity checks on header intro. */
+ if (hdrchkTags (il) || hdrchkData (dl))
+ goto errxit;
- ei = (int_32 *) pv;
- /address@hidden@*/
- pe = (entryInfo) &ei[2];
- /address@hidden@*/
- dataStart = (char *) (pe + il);
+ ei = (int_32 *) pv;
+ /address@hidden@ */
+ pe = (entryInfo) & ei[2];
+ /address@hidden@ */
+ dataStart = (char *) (pe + il);
- h = calloc(1, sizeof(*h));
- memset(h, 0, sizeof(*h));
- /address@hidden@*/
- /address@hidden@*/
- /address@hidden address@hidden/
- h->blob = uh;
- /address@hidden address@hidden/
- h->indexAlloced = il + 1;
- h->indexUsed = il;
- h->index = calloc(h->indexAlloced, sizeof(*h->index));
- h->flags = HEADERFLAG_SORTED;
- h->nrefs = 0;
- h = headerLink(h);
+ h = calloc (1, sizeof (*h));
+ memset (h, 0, sizeof (*h));
+ /address@hidden@ */
+ /address@hidden@ */
+ /address@hidden -kepttrans@ */
+ h->blob = uh;
+ /address@hidden =kepttrans@ */
+ h->indexAlloced = il + 1;
+ h->indexUsed = il;
+ h->index = calloc (h->indexAlloced, sizeof (*h->index));
+ h->flags = HEADERFLAG_SORTED;
+ h->nrefs = 0;
+ h = headerLink (h);
- /*
- * XXX XFree86-libs, ash, and pdksh from Red Hat 5.2 have bogus
- * %verifyscript tag that needs to be diddled.
- */
- if (ntohl(pe->tag) == 15 &&
- ntohl(pe->type) == RPM_STRING_TYPE &&
- ntohl(pe->count) == 1)
+ /*
+ * XXX XFree86-libs, ash, and pdksh from Red Hat 5.2 have bogus
+ * %verifyscript tag that needs to be diddled.
+ */
+ if (ntohl (pe->tag) == 15 &&
+ ntohl (pe->type) == RPM_STRING_TYPE && ntohl (pe->count) == 1)
{
- pe->tag = htonl(1079);
+ pe->tag = htonl (1079);
}
- entry = h->index;
- if (!(htonl(pe->tag) < HEADER_I18NTABLE)) {
- h->flags |= HEADERFLAG_LEGACY;
- entry->info.type = REGION_TAG_TYPE;
- entry->info.tag = HEADER_IMAGE;
- /address@hidden@*/
- entry->info.count = REGION_TAG_COUNT;
- /address@hidden@*/
- entry->info.offset = ((char *)pe - dataStart); /* negative offset */
+ entry = h->index;
+ if (!(htonl (pe->tag) < HEADER_I18NTABLE))
+ {
+ h->flags |= HEADERFLAG_LEGACY;
+ entry->info.type = REGION_TAG_TYPE;
+ entry->info.tag = HEADER_IMAGE;
+ /address@hidden@ */
+ entry->info.count = REGION_TAG_COUNT;
+ /address@hidden@ */
+ entry->info.offset = ((char *) pe - dataStart); /* negative offset */
- /address@hidden@*/
- entry->data = pe;
- /address@hidden@*/
- entry->length = pvlen - sizeof(il) - sizeof(dl);
- rdlen = regionSwab(entry+1, il, 0, pe, dataStart, entry->info.offset);
-#if 0 /* XXX don't check, the 8/98 i18n bug fails here. */
- if (rdlen != dl)
- goto errxit;
+ /address@hidden@ */
+ entry->data = pe;
+ /address@hidden@ */
+ entry->length = pvlen - sizeof (il) - sizeof (dl);
+ rdlen =
+ regionSwab (entry + 1, il, 0, pe, dataStart, entry->info.offset);
+#if 0 /* XXX don't check, the 8/98 i18n bug fails
here. */
+ if (rdlen != dl)
+ goto errxit;
#endif
- entry->rdlen = rdlen;
- entry++;
- h->indexUsed++;
- } else {
- int nb = ntohl(pe->count);
- int_32 rdl;
- int_32 ril;
+ entry->rdlen = rdlen;
+ entry++;
+ h->indexUsed++;
+ }
+ else
+ {
+ int nb = ntohl (pe->count);
+ int_32 rdl;
+ int_32 ril;
- h->flags &= ~HEADERFLAG_LEGACY;
+ h->flags &= ~HEADERFLAG_LEGACY;
- entry->info.type = htonl(pe->type);
- if (entry->info.type < RPM_MIN_TYPE || entry->info.type > RPM_MAX_TYPE)
- goto errxit;
- entry->info.count = htonl(pe->count);
+ entry->info.type = htonl (pe->type);
+ if (entry->info.type < RPM_MIN_TYPE || entry->info.type > RPM_MAX_TYPE)
+ goto errxit;
+ entry->info.count = htonl (pe->count);
- if (hdrchkTags(entry->info.count))
- goto errxit;
+ if (hdrchkTags (entry->info.count))
+ goto errxit;
- { int off = ntohl(pe->offset);
+ {
+ int off = ntohl (pe->offset);
- if (hdrchkData(off))
- goto errxit;
- if (off) {
- int_32 * stei = memcpy(alloca(nb), dataStart + off, nb);
- rdl = -ntohl(stei[2]); /* negative offset */
- ril = rdl/sizeof(*pe);
- if (hdrchkTags(ril) || hdrchkData(rdl))
- goto errxit;
- entry->info.tag = htonl(pe->tag);
- } else {
- ril = il;
- /address@hidden@*/
- rdl = (ril * sizeof(struct entryInfo));
- /address@hidden@*/
- entry->info.tag = HEADER_IMAGE;
- }
- }
- entry->info.offset = -rdl; /* negative offset */
+ if (hdrchkData (off))
+ goto errxit;
+ if (off)
+ {
+ int_32 *stei = memcpy (alloca (nb), dataStart + off, nb);
+ rdl = -ntohl (stei[2]); /* negative offset */
+ ril = rdl / sizeof (*pe);
+ if (hdrchkTags (ril) || hdrchkData (rdl))
+ goto errxit;
+ entry->info.tag = htonl (pe->tag);
+ }
+ else
+ {
+ ril = il;
+ /address@hidden@ */
+ rdl = (ril * sizeof (struct entryInfo));
+ /address@hidden@ */
+ entry->info.tag = HEADER_IMAGE;
+ }
+ }
+ entry->info.offset = -rdl; /* negative offset */
- /address@hidden@*/
- entry->data = pe;
- /address@hidden@*/
- entry->length = pvlen - sizeof(il) - sizeof(dl);
- rdlen = regionSwab(entry+1, ril-1, 0, pe+1, dataStart,
entry->info.offset);
- if (rdlen < 0)
- goto errxit;
- entry->rdlen = rdlen;
+ /address@hidden@ */
+ entry->data = pe;
+ /address@hidden@ */
+ entry->length = pvlen - sizeof (il) - sizeof (dl);
+ rdlen =
+ regionSwab (entry + 1, ril - 1, 0, pe + 1, dataStart,
+ entry->info.offset);
+ if (rdlen < 0)
+ goto errxit;
+ entry->rdlen = rdlen;
- if (ril < h->indexUsed) {
- indexEntry newEntry = entry + ril;
- int ne = (h->indexUsed - ril);
- int rid = entry->info.offset+1;
- int rc;
+ if (ril < h->indexUsed)
+ {
+ indexEntry newEntry = entry + ril;
+ int ne = (h->indexUsed - ril);
+ int rid = entry->info.offset + 1;
+ int rc;
- /* Load dribble entries from region. */
- rc = regionSwab(newEntry, ne, 0, pe+ril, dataStart, rid);
- if (rc < 0)
- goto errxit;
- rdlen += rc;
+ /* Load dribble entries from region. */
+ rc = regionSwab (newEntry, ne, 0, pe + ril, dataStart, rid);
+ if (rc < 0)
+ goto errxit;
+ rdlen += rc;
- { indexEntry firstEntry = newEntry;
- int save = h->indexUsed;
- int j;
+ {
+ indexEntry firstEntry = newEntry;
+ int save = h->indexUsed;
+ int j;
- /* Dribble entries replace duplicate region entries. */
- h->indexUsed -= ne;
- for (j = 0; j < ne; j++, newEntry++) {
- (void) headerRemoveEntry(h, newEntry->info.tag);
- if (newEntry->info.tag == HEADER_BASENAMES)
- (void) headerRemoveEntry(h, HEADER_OLDFILENAMES);
- }
+ /* Dribble entries replace duplicate region entries. */
+ h->indexUsed -= ne;
+ for (j = 0; j < ne; j++, newEntry++)
+ {
+ (void) headerRemoveEntry (h, newEntry->info.tag);
+ if (newEntry->info.tag == HEADER_BASENAMES)
+ (void) headerRemoveEntry (h, HEADER_OLDFILENAMES);
+ }
- /* If any duplicate entries were replaced, move new entries down. */
- if (h->indexUsed < (save - ne)) {
- memmove(h->index + h->indexUsed, firstEntry,
- (ne * sizeof(*entry)));
- }
- h->indexUsed += ne;
- }
- }
+ /* If any duplicate entries were replaced, move new entries down.
*/
+ if (h->indexUsed < (save - ne))
+ {
+ memmove (h->index + h->indexUsed, firstEntry,
+ (ne * sizeof (*entry)));
+ }
+ h->indexUsed += ne;
+ }
+ }
}
- h->flags &= ~HEADERFLAG_SORTED;
- headerSort(h);
+ h->flags &= ~HEADERFLAG_SORTED;
+ headerSort (h);
- /address@hidden -observertrans @*/
- return h;
- /address@hidden =observertrans @*/
+ /address@hidden -observertrans @ */
+ return h;
+ /address@hidden =observertrans @ */
errxit:
- /address@hidden@*/
- if (h) {
- h->index = _free(h->index);
- /address@hidden@*/
- h = _free(h);
- /address@hidden@*/
+ /address@hidden@ */
+ if (h)
+ {
+ h->index = _free (h->index);
+ /address@hidden@ */
+ h = _free (h);
+ /address@hidden@ */
}
- /address@hidden@*/
- /address@hidden address@hidden/
- return h;
- /address@hidden address@hidden/
+ /address@hidden@ */
+ /address@hidden -globstate@ */
+ return h;
+ /address@hidden =globstate@ */
}
/** \ingroup header
@@ -2294,71 +2425,78 @@
* @param magicp read (and verify) 8 bytes of (magic, 0)?
* @return header (or NULL on error)
*/
-static /address@hidden@*/
-Header headerRead(FD_t fd, enum hMagic magicp)
- /address@hidden fd @*/
+static /address@hidden@ */
+ Header
+headerRead (FD_t fd, enum hMagic magicp)
+ /address@hidden fd @ */
{
- int_32 block[4];
- int_32 * ei = NULL;
- int_32 il;
- int_32 dl;
- int_32 magic;
- Header h = NULL;
- size_t len;
- int i;
+ int_32 block[4];
+ int_32 *ei = NULL;
+ int_32 il;
+ int_32 dl;
+ int_32 magic;
+ Header h = NULL;
+ size_t len;
+ int i;
- memset(block, 0, sizeof(block));
- i = 2;
- if (magicp == HEADER_MAGIC_YES)
- i += 2;
+ memset (block, 0, sizeof (block));
+ i = 2;
+ if (magicp == HEADER_MAGIC_YES)
+ i += 2;
- /address@hidden@*/ /* FIX: cast? */
- if (timedRead(fd, (char *)block, i*sizeof(*block)) != (i * sizeof(*block)))
- goto exit;
- /address@hidden@*/
+ /address@hidden@ *//* FIX: cast? */
+ if (timedRead (fd, (char *) block, i * sizeof (*block)) !=
+ (i * sizeof (*block)))
+ goto exit;
+ /address@hidden@ */
- i = 0;
+ i = 0;
- if (magicp == HEADER_MAGIC_YES) {
- magic = block[i++];
- if (memcmp(&magic, header_magic, sizeof(magic)))
- goto exit;
- i++;
+ if (magicp == HEADER_MAGIC_YES)
+ {
+ magic = block[i++];
+ if (memcmp (&magic, header_magic, sizeof (magic)))
+ goto exit;
+ i++;
}
- il = ntohl(block[i]); i++;
- dl = ntohl(block[i]); i++;
+ il = ntohl (block[i]);
+ i++;
+ dl = ntohl (block[i]);
+ i++;
- /address@hidden@*/
- len = sizeof(il) + sizeof(dl) + (il * sizeof(struct entryInfo)) + dl;
- /address@hidden@*/
+ /address@hidden@ */
+ len = sizeof (il) + sizeof (dl) + (il * sizeof (struct entryInfo)) + dl;
+ /address@hidden@ */
- /* Sanity checks on header intro. */
- if (hdrchkTags(il) || hdrchkData(dl) || len > headerMaxbytes)
- goto exit;
+ /* Sanity checks on header intro. */
+ if (hdrchkTags (il) || hdrchkData (dl) || len > headerMaxbytes)
+ goto exit;
- ei = malloc(len);
- ei[0] = htonl(il);
- ei[1] = htonl(dl);
- len -= sizeof(il) + sizeof(dl);
+ ei = malloc (len);
+ ei[0] = htonl (il);
+ ei[1] = htonl (dl);
+ len -= sizeof (il) + sizeof (dl);
- /address@hidden@*/ /* FIX: cast? */
- if (timedRead(fd, (char *)&ei[2], len) != len)
- goto exit;
- /address@hidden@*/
+ /address@hidden@ *//* FIX: cast? */
+ if (timedRead (fd, (char *) &ei[2], len) != len)
+ goto exit;
+ /address@hidden@ */
- h = headerLoad(ei);
+ h = headerLoad (ei);
exit:
- if (h) {
- if (h->flags & HEADERFLAG_ALLOCATED)
- ei = _free(ei);
- h->flags |= HEADERFLAG_ALLOCATED;
- } else if (ei)
- ei = _free(ei);
- /address@hidden@*/ /* FIX: timedRead macro obscures annotation */
- return h;
- /address@hidden@*/
+ if (h)
+ {
+ if (h->flags & HEADERFLAG_ALLOCATED)
+ ei = _free (ei);
+ h->flags |= HEADERFLAG_ALLOCATED;
+ }
+ else if (ei)
+ ei = _free (ei);
+ /address@hidden@ *//* FIX: timedRead macro obscures annotation */
+ return h;
+ /address@hidden@ */
}
/**
@@ -2370,132 +2508,137 @@
* @param datalen length of header+payload
* @return rpmRC return code
*/
-static rpmRC checkSize(FD_t fd, int siglen, int pad, int datalen)
- /address@hidden fileSystem @*/
- /address@hidden fileSystem @*/
+static rpmRC
+checkSize (FD_t fd, int siglen, int pad, int datalen)
+ /address@hidden fileSystem @ */
+ /address@hidden fileSystem @ */
{
- rpmRC rc;
+ rpmRC rc;
- rc = (((sizeof(struct rpmlead) + siglen + pad + datalen) - fd->len)
- ? RPMRC_BADSIZE : RPMRC_OK);
+ rc = (((sizeof (struct rpmlead) + siglen + pad + datalen) - fd->len)
+ ? RPMRC_BADSIZE : RPMRC_OK);
- return rc;
+ return rc;
}
/** \ingroup header
* Create new (empty) header instance.
* @return header
*/
-static
-Header headerNew(void)
- /address@hidden/
+static Header
+headerNew (void)
+ /*@ */
{
- Header h = calloc(1, sizeof(*h));
+ Header h = calloc (1, sizeof (*h));
- memset(h, 0, sizeof(*h));
- /address@hidden@*/
- /address@hidden@*/
- h->blob = NULL;
- h->indexAlloced = INDEX_MALLOC_SIZE;
- h->indexUsed = 0;
- h->flags = HEADERFLAG_SORTED;
+ memset (h, 0, sizeof (*h));
+ /address@hidden@ */
+ /address@hidden@ */
+ h->blob = NULL;
+ h->indexAlloced = INDEX_MALLOC_SIZE;
+ h->indexUsed = 0;
+ h->flags = HEADERFLAG_SORTED;
- h->index = (h->indexAlloced
- ? calloc(h->indexAlloced, sizeof(*h->index))
- : NULL);
+ h->index = (h->indexAlloced
+ ? calloc (h->indexAlloced, sizeof (*h->index)) : NULL);
- /address@hidden -observertrans @*/
- h->nrefs = 0;
- return headerLink(h);
- /address@hidden =observertrans @*/
+ /address@hidden -observertrans @ */
+ h->nrefs = 0;
+ return headerLink (h);
+ /address@hidden =observertrans @ */
}
typedef unsigned char byte;
-static rpmRC rpmReadSignature(FD_t fd, Header * headerp, sigType sig_type)
+static rpmRC
+rpmReadSignature (FD_t fd, Header * headerp, sigType sig_type)
{
- byte buf[2048];
- int sigSize, pad;
- int_32 type, count;
- int_32 *archSize;
- Header h = NULL;
- rpmRC rc = RPMRC_FAIL; /* assume failure */
+ byte buf[2048];
+ int sigSize, pad;
+ int_32 type, count;
+ int_32 *archSize;
+ Header h = NULL;
+ rpmRC rc = RPMRC_FAIL; /* assume failure */
- if (headerp)
- *headerp = NULL;
+ if (headerp)
+ *headerp = NULL;
- buf[0] = 0;
- switch (sig_type) {
+ buf[0] = 0;
+ switch (sig_type)
+ {
case RPMSIGTYPE_NONE:
- rc = RPMRC_OK;
- break;
+ rc = RPMRC_OK;
+ break;
case RPMSIGTYPE_PGP262_1024:
- /* These are always 256 bytes */
- if (timedRead(fd, buf, 256) != 256)
- break;
- h = headerNew();
- (void) headerAddEntry(h, RPMSIGTAG_PGP, RPM_BIN_TYPE, buf, 152);
- rc = RPMRC_OK;
- break;
+ /* These are always 256 bytes */
+ if (timedRead (fd, buf, 256) != 256)
+ break;
+ h = headerNew ();
+ (void) headerAddEntry (h, RPMSIGTAG_PGP, RPM_BIN_TYPE, buf, 152);
+ rc = RPMRC_OK;
+ break;
case RPMSIGTYPE_MD5:
case RPMSIGTYPE_MD5_PGP:
- break;
+ break;
case RPMSIGTYPE_HEADERSIG:
case RPMSIGTYPE_DISABLE:
- /* This is a new style signature */
- h = headerRead(fd, HEADER_MAGIC_YES);
- if (h == NULL)
- break;
+ /* This is a new style signature */
+ h = headerRead (fd, HEADER_MAGIC_YES);
+ if (h == NULL)
+ break;
- rc = RPMRC_OK;
- sigSize = headerSizeof(h, HEADER_MAGIC_YES);
+ rc = RPMRC_OK;
+ sigSize = headerSizeof (h, HEADER_MAGIC_YES);
- /* XXX Legacy headers have a HEADER_IMAGE tag added. */
- if (headerIsEntry(h, RPMTAG_HEADERIMAGE))
- sigSize -= (16 + 16);
+ /* XXX Legacy headers have a HEADER_IMAGE tag added. */
+ if (headerIsEntry (h, RPMTAG_HEADERIMAGE))
+ sigSize -= (16 + 16);
- pad = (8 - (sigSize % 8)) % 8; /* 8-byte pad */
- if (sig_type == RPMSIGTYPE_HEADERSIG) {
- if (! headerGetEntry(h, RPMSIGTAG_SIZE, &type,
- (void **)&archSize, &count))
- break;
- rc = checkSize(fd, sigSize, pad, *archSize);
- }
- if (pad && timedRead(fd, buf, pad) != pad)
- rc = RPMRC_SHORTREAD;
- break;
+ pad = (8 - (sigSize % 8)) % 8; /* 8-byte pad */
+ if (sig_type == RPMSIGTYPE_HEADERSIG)
+ {
+ if (!headerGetEntry (h, RPMSIGTAG_SIZE, &type,
+ (void **) &archSize, &count))
+ break;
+ rc = checkSize (fd, sigSize, pad, *archSize);
+ }
+ if (pad && timedRead (fd, buf, pad) != pad)
+ rc = RPMRC_SHORTREAD;
+ break;
default:
- break;
+ break;
}
- if (rc == 0 && headerp)
- /address@hidden@*/
- *headerp = h;
- /address@hidden@*/
- else if (h)
- h = headerFree(h);
+ if (rc == 0 && headerp)
+ /address@hidden@ */
+ *headerp = h;
+ /address@hidden@ */
+ else if (h)
+ h = headerFree (h);
- return rc;
+ return rc;
}
-static int readLead(FD_t fd, struct rpmlead *lead)
+static int
+readLead (FD_t fd, struct rpmlead *lead)
{
- memset(lead, 0, sizeof(*lead));
- /address@hidden@*/ /* FIX: remove timed read */
- if (timedRead(fd, (char *)lead, sizeof(*lead)) != sizeof(*lead)) {
- return 1;
+ memset (lead, 0, sizeof (*lead));
+ /address@hidden@ *//* FIX: remove timed read */
+ if (timedRead (fd, (char *) lead, sizeof (*lead)) != sizeof (*lead))
+ {
+ return 1;
}
- /address@hidden@*/
+ /address@hidden@ */
- lead->type = ntohs(lead->type);
- lead->archnum = ntohs(lead->archnum);
- lead->osnum = ntohs(lead->osnum);
+ lead->type = ntohs (lead->type);
+ lead->archnum = ntohs (lead->archnum);
+ lead->osnum = ntohs (lead->osnum);
- if (lead->major >= 2)
- lead->signature_type = ntohs(lead->signature_type);
+ if (lead->major >= 2)
+ lead->signature_type = ntohs (lead->signature_type);
- return 0;
+ return 0;
}
/** \ingroup header
@@ -2510,14 +2653,14 @@
* @retval c address of number of values (or NULL)
* @return 1 on success, 0 on failure
*/
-static
-int headerGetEntryMinMemory(Header h, int_32 tag,
- /address@hidden@*/ /address@hidden@*/ hTYP_t type,
- /address@hidden@*/ /address@hidden@*/ hPTR_t * p,
- /address@hidden@*/ /address@hidden@*/ hCNT_t c)
- /address@hidden *type, *p, *c @*/
+static int
+headerGetEntryMinMemory (Header h, int_32 tag,
+ /address@hidden@ *//address@hidden@ */ hTYP_t type,
+ /address@hidden@ *//address@hidden@ */ hPTR_t * p,
+ /address@hidden@ *//address@hidden@ */ hCNT_t c)
+ /address@hidden *type, *p, *c @ */
{
- return intGetEntry(h, tag, type, p, c, 1);
+ return intGetEntry (h, tag, type, p, c, 1);
}
/** \ingroup header
@@ -2529,246 +2672,270 @@
* @param tag tag
* @return 0 on success, 1 on failure (INCONSISTENT)
*/
-static
-int headerRemoveEntry(Header h, int_32 tag)
- /address@hidden h @*/
+static int
+headerRemoveEntry (Header h, int_32 tag)
+ /address@hidden h @ */
{
- indexEntry last = h->index + h->indexUsed;
- indexEntry entry, first;
- int ne;
+ indexEntry last = h->index + h->indexUsed;
+ indexEntry entry, first;
+ int ne;
- entry = findEntry(h, tag, RPM_NULL_TYPE);
- if (!entry) return 1;
+ entry = findEntry (h, tag, RPM_NULL_TYPE);
+ if (!entry)
+ return 1;
- /* Make sure entry points to the first occurence of this tag. */
- while (entry > h->index && (entry - 1)->info.tag == tag)
- entry--;
+ /* Make sure entry points to the first occurence of this tag. */
+ while (entry > h->index && (entry - 1)->info.tag == tag)
+ entry--;
- /* Free data for tags being removed. */
- for (first = entry; first < last; first++) {
- void * data;
- if (first->info.tag != tag)
- break;
- data = first->data;
- first->data = NULL;
- first->length = 0;
- if (ENTRY_IN_REGION(first))
- continue;
- data = _free(data);
+ /* Free data for tags being removed. */
+ for (first = entry; first < last; first++)
+ {
+ void *data;
+ if (first->info.tag != tag)
+ break;
+ data = first->data;
+ first->data = NULL;
+ first->length = 0;
+ if (ENTRY_IN_REGION (first))
+ continue;
+ data = _free (data);
}
- ne = (first - entry);
- if (ne > 0) {
- h->indexUsed -= ne;
- ne = last - first;
- if (ne > 0)
- memmove(entry, first, (ne * sizeof(*entry)));
+ ne = (first - entry);
+ if (ne > 0)
+ {
+ h->indexUsed -= ne;
+ ne = last - first;
+ if (ne > 0)
+ memmove (entry, first, (ne * sizeof (*entry)));
}
- return 0;
+ return 0;
}
-static int dncmp(const void * a, const void * b)
+static int
+dncmp (const void *a, const void *b)
{
- const char *const * first = a;
- const char *const * second = b;
- return strcmp(*first, *second);
+ const char *const *first = a;
+ const char *const *second = b;
+ return strcmp (*first, *second);
}
-static void compressFilelist(Header h)
+static void
+compressFilelist (Header h)
{
- HGE_t hge = (HGE_t)headerGetEntryMinMemory;
- HAE_t hae = (HAE_t)headerAddEntry;
- HRE_t hre = (HRE_t)headerRemoveEntry;
- HFD_t hfd = headerFreeData;
- char ** fileNames;
- const char ** dirNames;
- const char ** baseNames;
- int_32 * dirIndexes;
- rpmTagType fnt;
- int count;
- int i;
- int dirIndex = -1;
+ HGE_t hge = (HGE_t) headerGetEntryMinMemory;
+ HAE_t hae = (HAE_t) headerAddEntry;
+ HRE_t hre = (HRE_t) headerRemoveEntry;
+ HFD_t hfd = headerFreeData;
+ char **fileNames;
+ const char **dirNames;
+ const char **baseNames;
+ int_32 *dirIndexes;
+ rpmTagType fnt;
+ int count;
+ int i;
+ int dirIndex = -1;
- /*
- * This assumes the file list is already sorted, and begins with a
- * single '/'. That assumption isn't critical, but it makes things go
- * a bit faster.
- */
+ /*
+ * This assumes the file list is already sorted, and begins with a
+ * single '/'. That assumption isn't critical, but it makes things go
+ * a bit faster.
+ */
- if (headerIsEntry(h, RPMTAG_DIRNAMES)) {
- (void) hre(h, RPMTAG_OLDFILENAMES);
- return; /* Already converted. */
+ if (headerIsEntry (h, RPMTAG_DIRNAMES))
+ {
+ (void) hre (h, RPMTAG_OLDFILENAMES);
+ return; /* Already converted. */
}
- if (!hge(h, RPMTAG_OLDFILENAMES, &fnt, (void **) &fileNames, &count))
- return; /* no file list */
- if (fileNames == NULL || count <= 0)
- return;
+ if (!hge (h, RPMTAG_OLDFILENAMES, &fnt, (void **) &fileNames, &count))
+ return; /* no file list */
+ if (fileNames == NULL || count <= 0)
+ return;
- dirNames = alloca(sizeof(*dirNames) * count); /* worst case */
- baseNames = alloca(sizeof(*dirNames) * count);
- dirIndexes = alloca(sizeof(*dirIndexes) * count);
+ dirNames = alloca (sizeof (*dirNames) * count); /* worst case */
+ baseNames = alloca (sizeof (*dirNames) * count);
+ dirIndexes = alloca (sizeof (*dirIndexes) * count);
- if (fileNames[0][0] != '/') {
- /* HACK. Source RPM, so just do things differently */
- dirIndex = 0;
- dirNames[dirIndex] = "";
- for (i = 0; i < count; i++) {
- dirIndexes[i] = dirIndex;
- baseNames[i] = fileNames[i];
- }
- goto exit;
+ if (fileNames[0][0] != '/')
+ {
+ /* HACK. Source RPM, so just do things differently */
+ dirIndex = 0;
+ dirNames[dirIndex] = "";
+ for (i = 0; i < count; i++)
+ {
+ dirIndexes[i] = dirIndex;
+ baseNames[i] = fileNames[i];
+ }
+ goto exit;
}
- for (i = 0; i < count; i++) {
- const char ** needle;
- char savechar;
- char * baseName;
- int len;
+ for (i = 0; i < count; i++)
+ {
+ const char **needle;
+ char savechar;
+ char *baseName;
+ int len;
- if (fileNames[i] == NULL) /* XXX can't happen */
- continue;
- baseName = strrchr(fileNames[i], '/') + 1;
- len = baseName - fileNames[i];
- needle = dirNames;
- savechar = *baseName;
- *baseName = '\0';
- if (dirIndex < 0 ||
- (needle = bsearch(&fileNames[i], dirNames, dirIndex + 1,
sizeof(dirNames[0]), dncmp)) == NULL) {
- char *s = alloca(len + 1);
- memcpy(s, fileNames[i], len + 1);
- s[len] = '\0';
- dirIndexes[i] = ++dirIndex;
- dirNames[dirIndex] = s;
- } else
- dirIndexes[i] = needle - dirNames;
+ if (fileNames[i] == NULL) /* XXX can't happen */
+ continue;
+ baseName = strrchr (fileNames[i], '/') + 1;
+ len = baseName - fileNames[i];
+ needle = dirNames;
+ savechar = *baseName;
+ *baseName = '\0';
+ if (dirIndex < 0 ||
+ (needle =
+ bsearch (&fileNames[i], dirNames, dirIndex + 1,
+ sizeof (dirNames[0]), dncmp)) == NULL)
+ {
+ char *s = alloca (len + 1);
+ memcpy (s, fileNames[i], len + 1);
+ s[len] = '\0';
+ dirIndexes[i] = ++dirIndex;
+ dirNames[dirIndex] = s;
+ }
+ else
+ dirIndexes[i] = needle - dirNames;
- *baseName = savechar;
- baseNames[i] = baseName;
+ *baseName = savechar;
+ baseNames[i] = baseName;
}
exit:
- if (count > 0) {
- (void) hae(h, RPMTAG_DIRINDEXES, RPM_INT32_TYPE, dirIndexes, count);
- (void) hae(h, RPMTAG_BASENAMES, RPM_STRING_ARRAY_TYPE,
- baseNames, count);
- (void) hae(h, RPMTAG_DIRNAMES, RPM_STRING_ARRAY_TYPE,
- dirNames, dirIndex + 1);
+ if (count > 0)
+ {
+ (void) hae (h, RPMTAG_DIRINDEXES, RPM_INT32_TYPE, dirIndexes, count);
+ (void) hae (h, RPMTAG_BASENAMES, RPM_STRING_ARRAY_TYPE,
+ baseNames, count);
+ (void) hae (h, RPMTAG_DIRNAMES, RPM_STRING_ARRAY_TYPE,
+ dirNames, dirIndex + 1);
}
- fileNames = hfd(fileNames, fnt);
+ fileNames = hfd (fileNames, fnt);
- (void) hre(h, RPMTAG_OLDFILENAMES);
+ (void) hre (h, RPMTAG_OLDFILENAMES);
}
-static int headerNVR(Header h, const char **np, const char **vp, const char
**rp)
+static int
+headerNVR (Header h, const char **np, const char **vp, const char **rp)
{
- int type;
- int count;
+ int type;
+ int count;
- if (np) {
- if (!(headerGetEntry(h, RPMTAG_NAME, &type, (void **) np, &count)
- && type == RPM_STRING_TYPE && count == 1))
- *np = NULL;
+ if (np)
+ {
+ if (!(headerGetEntry (h, RPMTAG_NAME, &type, (void **) np, &count)
+ && type == RPM_STRING_TYPE && count == 1))
+ *np = NULL;
}
- if (vp) {
- if (!(headerGetEntry(h, RPMTAG_VERSION, &type, (void **) vp, &count)
- && type == RPM_STRING_TYPE && count == 1))
- *vp = NULL;
+ if (vp)
+ {
+ if (!(headerGetEntry (h, RPMTAG_VERSION, &type, (void **) vp, &count)
+ && type == RPM_STRING_TYPE && count == 1))
+ *vp = NULL;
}
- if (rp) {
- if (!(headerGetEntry(h, RPMTAG_RELEASE, &type, (void **) rp, &count)
- && type == RPM_STRING_TYPE && count == 1))
- *rp = NULL;
+ if (rp)
+ {
+ if (!(headerGetEntry (h, RPMTAG_RELEASE, &type, (void **) rp, &count)
+ && type == RPM_STRING_TYPE && count == 1))
+ *rp = NULL;
}
- return 0;
+ return 0;
}
/*
* Up to rpm 3.0.4, packages implicitly provided their own
name-version-release.
* Retrofit an explicit "Provides: name = epoch:version-release.
*/
-static void providePackageNVR(Header h)
+static void
+providePackageNVR (Header h)
{
- HGE_t hge = (HGE_t)headerGetEntryMinMemory;
- HFD_t hfd = headerFreeData;
- const char *name, *version, *release;
- int_32 * epoch;
- const char *pEVR;
- char *p;
- int_32 pFlags = RPMSENSE_EQUAL;
- const char ** provides = NULL;
- const char ** providesEVR = NULL;
- rpmTagType pnt, pvt = RPM_NULL_TYPE;
- int_32 * provideFlags = NULL;
- int providesCount;
- int i;
- int bingo = 1;
+ HGE_t hge = (HGE_t) headerGetEntryMinMemory;
+ HFD_t hfd = headerFreeData;
+ const char *name, *version, *release;
+ int_32 *epoch;
+ const char *pEVR;
+ char *p;
+ int_32 pFlags = RPMSENSE_EQUAL;
+ const char **provides = NULL;
+ const char **providesEVR = NULL;
+ rpmTagType pnt, pvt = RPM_NULL_TYPE;
+ int_32 *provideFlags = NULL;
+ int providesCount;
+ int i;
+ int bingo = 1;
- /* Generate provides for this package name-version-release. */
- (void) headerNVR(h, &name, &version, &release);
- if (!(name && version && release))
- return;
- pEVR = p = alloca(21 + strlen(version) + 1 + strlen(release) + 1);
- *p = '\0';
- if (hge(h, RPMTAG_EPOCH, NULL, (void **) &epoch, NULL)) {
- sprintf(p, "%d:", *epoch);
- while (*p != '\0')
- p++;
+ /* Generate provides for this package name-version-release. */
+ (void) headerNVR (h, &name, &version, &release);
+ if (!(name && version && release))
+ return;
+ pEVR = p = alloca (21 + strlen (version) + 1 + strlen (release) + 1);
+ *p = '\0';
+ if (hge (h, RPMTAG_EPOCH, NULL, (void **) &epoch, NULL))
+ {
+ sprintf (p, "%d:", *epoch);
+ while (*p != '\0')
+ p++;
}
- (void) my_stpcpy( my_stpcpy( my_stpcpy(p, version) , "-") , release);
+ (void) my_stpcpy (my_stpcpy (my_stpcpy (p, version), "-"), release);
- /*
- * Rpm prior to 3.0.3 does not have versioned provides.
- * If no provides at all are available, we can just add.
- */
- if (!hge(h, RPMTAG_PROVIDENAME, &pnt, (void **) &provides, &providesCount))
- goto exit;
+ /*
+ * Rpm prior to 3.0.3 does not have versioned provides.
+ * If no provides at all are available, we can just add.
+ */
+ if (!hge (h, RPMTAG_PROVIDENAME, &pnt, (void **) &provides, &providesCount))
+ goto exit;
- /*
- * Otherwise, fill in entries on legacy packages.
- */
- if (!hge(h, RPMTAG_PROVIDEVERSION, &pvt, (void **) &providesEVR, NULL)) {
- for (i = 0; i < providesCount; i++) {
- char * vdummy = "";
- int_32 fdummy = RPMSENSE_ANY;
- (void) headerAddOrAppendEntry(h, RPMTAG_PROVIDEVERSION,
RPM_STRING_ARRAY_TYPE,
- &vdummy, 1);
- (void) headerAddOrAppendEntry(h, RPMTAG_PROVIDEFLAGS,
RPM_INT32_TYPE,
- &fdummy, 1);
- }
- goto exit;
+ /*
+ * Otherwise, fill in entries on legacy packages.
+ */
+ if (!hge (h, RPMTAG_PROVIDEVERSION, &pvt, (void **) &providesEVR, NULL))
+ {
+ for (i = 0; i < providesCount; i++)
+ {
+ char *vdummy = "";
+ int_32 fdummy = RPMSENSE_ANY;
+ (void) headerAddOrAppendEntry (h, RPMTAG_PROVIDEVERSION,
+ RPM_STRING_ARRAY_TYPE, &vdummy, 1);
+ (void) headerAddOrAppendEntry (h, RPMTAG_PROVIDEFLAGS,
+ RPM_INT32_TYPE, &fdummy, 1);
+ }
+ goto exit;
}
- (void) hge(h, RPMTAG_PROVIDEFLAGS, NULL, (void **) &provideFlags, NULL);
+ (void) hge (h, RPMTAG_PROVIDEFLAGS, NULL, (void **) &provideFlags, NULL);
- if (provides && providesEVR && provideFlags)
- for (i = 0; i < providesCount; i++) {
+ if (provides && providesEVR && provideFlags)
+ for (i = 0; i < providesCount; i++)
+ {
if (!(provides[i] && providesEVR[i]))
- continue;
- if (!(provideFlags[i] == RPMSENSE_EQUAL &&
- !strcmp(name, provides[i]) && !strcmp(pEVR, providesEVR[i])))
- continue;
- bingo = 0;
- break;
- }
+ continue;
+ if (!(provideFlags[i] == RPMSENSE_EQUAL &&
+ !strcmp (name, provides[i]) && !strcmp (pEVR, providesEVR[i])))
+ continue;
+ bingo = 0;
+ break;
+ }
exit:
- provides = hfd(provides, pnt);
- providesEVR = hfd(providesEVR, pvt);
+ provides = hfd (provides, pnt);
+ providesEVR = hfd (providesEVR, pvt);
- if (bingo) {
- (void) headerAddOrAppendEntry(h, RPMTAG_PROVIDENAME,
RPM_STRING_ARRAY_TYPE,
- &name, 1);
- (void) headerAddOrAppendEntry(h, RPMTAG_PROVIDEFLAGS, RPM_INT32_TYPE,
- &pFlags, 1);
- (void) headerAddOrAppendEntry(h, RPMTAG_PROVIDEVERSION,
RPM_STRING_ARRAY_TYPE,
- &pEVR, 1);
+ if (bingo)
+ {
+ (void) headerAddOrAppendEntry (h, RPMTAG_PROVIDENAME,
+ RPM_STRING_ARRAY_TYPE, &name, 1);
+ (void) headerAddOrAppendEntry (h, RPMTAG_PROVIDEFLAGS, RPM_INT32_TYPE,
+ &pFlags, 1);
+ (void) headerAddOrAppendEntry (h, RPMTAG_PROVIDEVERSION,
+ RPM_STRING_ARRAY_TYPE, &pEVR, 1);
}
}
-static Header rpmFreeSignature(Header h);
+static Header rpmFreeSignature (Header h);
/**
* Retrieve package components from file handle.
@@ -2778,207 +2945,225 @@
* @param hdrPtr address of header (or NULL)
* @return rpmRC return code
*/
-static rpmRC readPackageHeaders(FD_t fd,
- /address@hidden@*/ /address@hidden@*/ struct rpmlead * leadPtr,
- /address@hidden@*/ /address@hidden@*/ Header * sigs,
- /address@hidden@*/ /address@hidden@*/ Header * hdrPtr)
- /address@hidden fd, *leadPtr, *sigs, *hdrPtr @*/
+static rpmRC
+readPackageHeaders (FD_t fd,
+ /address@hidden@ *//address@hidden@ */ struct rpmlead
*leadPtr,
+ /address@hidden@ *//address@hidden@ */ Header * sigs,
+ /address@hidden@ *//address@hidden@ */ Header * hdrPtr)
+ /address@hidden fd, *leadPtr, *sigs, *hdrPtr @ */
{
- Header hdrBlock;
- struct rpmlead leadBlock;
- Header * hdr = NULL;
- struct rpmlead * lead;
- char * defaultPrefix;
- rpmRC rc;
+ Header hdrBlock;
+ struct rpmlead leadBlock;
+ Header *hdr = NULL;
+ struct rpmlead *lead;
+ char *defaultPrefix;
+ rpmRC rc;
- hdr = hdrPtr ? hdrPtr : &hdrBlock;
- lead = leadPtr ? leadPtr : &leadBlock;
+ hdr = hdrPtr ? hdrPtr : &hdrBlock;
+ lead = leadPtr ? leadPtr : &leadBlock;
- if (readLead(fd, lead))
- return RPMRC_FAIL;
+ if (readLead (fd, lead))
+ return RPMRC_FAIL;
- if (lead->magic[0] != RPMLEAD_MAGIC0 || lead->magic[1] != RPMLEAD_MAGIC1 ||
- lead->magic[2] != RPMLEAD_MAGIC2 || lead->magic[3] != RPMLEAD_MAGIC3) {
- return RPMRC_BADMAGIC;
+ if (lead->magic[0] != RPMLEAD_MAGIC0 || lead->magic[1] != RPMLEAD_MAGIC1 ||
+ lead->magic[2] != RPMLEAD_MAGIC2 || lead->magic[3] != RPMLEAD_MAGIC3)
+ {
+ return RPMRC_BADMAGIC;
}
- switch (lead->major) {
+ switch (lead->major)
+ {
case 1:
- return RPMRC_FAIL;
- /address@hidden@*/ break;
+ return RPMRC_FAIL;
+ /address@hidden@ */ break;
case 2:
case 3:
case 4:
- rc = rpmReadSignature(fd, sigs, lead->signature_type);
- if (rc == RPMRC_FAIL)
- return rc;
- *hdr = headerRead(fd, (lead->major >= 3)
- ? HEADER_MAGIC_YES : HEADER_MAGIC_NO);
- if (*hdr == NULL) {
- if (sigs != NULL)
- *sigs = rpmFreeSignature(*sigs);
- return RPMRC_FAIL;
- }
+ rc = rpmReadSignature (fd, sigs, lead->signature_type);
+ if (rc == RPMRC_FAIL)
+ return rc;
+ *hdr = headerRead (fd, (lead->major >= 3)
+ ? HEADER_MAGIC_YES : HEADER_MAGIC_NO);
+ if (*hdr == NULL)
+ {
+ if (sigs != NULL)
+ *sigs = rpmFreeSignature (*sigs);
+ return RPMRC_FAIL;
+ }
- /*
- * We don't use these entries (and rpm >= 2 never has) and they are
- * pretty misleading. Let's just get rid of them so they don't confuse
- * anyone.
- */
- if (headerIsEntry(*hdr, RPMTAG_FILEUSERNAME))
- (void) headerRemoveEntry(*hdr, RPMTAG_FILEUIDS);
- if (headerIsEntry(*hdr, RPMTAG_FILEGROUPNAME))
- (void) headerRemoveEntry(*hdr, RPMTAG_FILEGIDS);
+ /*
+ * We don't use these entries (and rpm >= 2 never has) and they are
+ * pretty misleading. Let's just get rid of them so they don't confuse
+ * anyone.
+ */
+ if (headerIsEntry (*hdr, RPMTAG_FILEUSERNAME))
+ (void) headerRemoveEntry (*hdr, RPMTAG_FILEUIDS);
+ if (headerIsEntry (*hdr, RPMTAG_FILEGROUPNAME))
+ (void) headerRemoveEntry (*hdr, RPMTAG_FILEGIDS);
- /*
- * We switched the way we do relocateable packages. We fix some of
- * it up here, though the install code still has to be a bit
- * careful. This fixup makes queries give the new values though,
- * which is quite handy.
- */
- if (headerGetEntry(*hdr, RPMTAG_DEFAULTPREFIX, NULL,
- (void **) &defaultPrefix, NULL))
- {
- defaultPrefix =
- stripTrailingChar(alloca_strdup(defaultPrefix), '/');
- (void) headerAddEntry(*hdr, RPMTAG_PREFIXES, RPM_STRING_ARRAY_TYPE,
- &defaultPrefix, 1);
- }
+ /*
+ * We switched the way we do relocateable packages. We fix some of
+ * it up here, though the install code still has to be a bit
+ * careful. This fixup makes queries give the new values though,
+ * which is quite handy.
+ */
+ if (headerGetEntry (*hdr, RPMTAG_DEFAULTPREFIX, NULL,
+ (void **) &defaultPrefix, NULL))
+ {
+ defaultPrefix =
+ stripTrailingChar (alloca_strdup (defaultPrefix), '/');
+ (void) headerAddEntry (*hdr, RPMTAG_PREFIXES, RPM_STRING_ARRAY_TYPE,
+ &defaultPrefix, 1);
+ }
- /*
- * The file list was moved to a more compressed format which not
- * only saves memory (nice), but gives fingerprinting a nice, fat
- * speed boost (very nice). Go ahead and convert old headers to
- * the new style (this is a noop for new headers).
- */
- if (lead->major < 4)
- compressFilelist(*hdr);
+ /*
+ * The file list was moved to a more compressed format which not
+ * only saves memory (nice), but gives fingerprinting a nice, fat
+ * speed boost (very nice). Go ahead and convert old headers to
+ * the new style (this is a noop for new headers).
+ */
+ if (lead->major < 4)
+ compressFilelist (*hdr);
- /* XXX binary rpms always have RPMTAG_SOURCERPM, source rpms do not */
- if (lead->type == RPMLEAD_SOURCE) {
- int_32 one = 1;
- if (!headerIsEntry(*hdr, RPMTAG_SOURCEPACKAGE))
- (void)headerAddEntry(*hdr, RPMTAG_SOURCEPACKAGE, RPM_INT32_TYPE,
- &one, 1);
- } else if (lead->major < 4) {
- /* Retrofit "Provide: name = EVR" for binary packages. */
- providePackageNVR(*hdr);
- }
- break;
+ /* XXX binary rpms always have RPMTAG_SOURCERPM, source rpms do not */
+ if (lead->type == RPMLEAD_SOURCE)
+ {
+ int_32 one = 1;
+ if (!headerIsEntry (*hdr, RPMTAG_SOURCEPACKAGE))
+ (void) headerAddEntry (*hdr, RPMTAG_SOURCEPACKAGE, RPM_INT32_TYPE,
+ &one, 1);
+ }
+ else if (lead->major < 4)
+ {
+ /* Retrofit "Provide: name = EVR" for binary packages. */
+ providePackageNVR (*hdr);
+ }
+ break;
default:
- return RPMRC_FAIL;
- /address@hidden@*/ break;
+ return RPMRC_FAIL;
+ /address@hidden@ */ break;
}
- if (hdrPtr == NULL)
- *hdr = headerFree(*hdr);
+ if (hdrPtr == NULL)
+ *hdr = headerFree (*hdr);
- return RPMRC_OK;
+ return RPMRC_OK;
}
-static void headerMergeLegacySigs(Header h, const Header sig)
+static void
+headerMergeLegacySigs (Header h, const Header sig)
{
- HFD_t hfd = (HFD_t) headerFreeData;
- HAE_t hae = (HAE_t) headerAddEntry;
- HeaderIterator hi;
- int_32 tag, type, count;
- const void * ptr;
+ HFD_t hfd = (HFD_t) headerFreeData;
+ HAE_t hae = (HAE_t) headerAddEntry;
+ HeaderIterator hi;
+ int_32 tag, type, count;
+ const void *ptr;
- /address@hidden@*/ /* FIX: undocumented modification of sig */
- for (hi = headerInitIterator(sig);
- /address@hidden@*/
- headerNextIterator(hi, &tag, &type, &ptr, &count, 0);
- ptr = hfd(ptr, type))
+ /address@hidden@ *//* FIX: undocumented modification of sig */
+ for (hi = headerInitIterator (sig);
+ /address@hidden@ */
+ headerNextIterator (hi, &tag, &type, &ptr, &count, 0);
+ ptr = hfd (ptr, type))
{
- switch (tag) {
- case RPMSIGTAG_SIZE:
- tag = RPMTAG_SIGSIZE;
- /address@hidden@*/ break;
- case RPMSIGTAG_LEMD5_1:
- tag = RPMTAG_SIGLEMD5_1;
- /address@hidden@*/ break;
- case RPMSIGTAG_PGP:
- tag = RPMTAG_SIGPGP;
- /address@hidden@*/ break;
- case RPMSIGTAG_LEMD5_2:
- tag = RPMTAG_SIGLEMD5_2;
- /address@hidden@*/ break;
- case RPMSIGTAG_MD5:
- tag = RPMTAG_SIGMD5;
- /address@hidden@*/ break;
- case RPMSIGTAG_GPG:
- tag = RPMTAG_SIGGPG;
- /address@hidden@*/ break;
- case RPMSIGTAG_PGP5:
- tag = RPMTAG_SIGPGP5;
- /address@hidden@*/ break;
- case RPMSIGTAG_PAYLOADSIZE:
- tag = RPMTAG_ARCHIVESIZE;
- /address@hidden@*/ break;
- case RPMSIGTAG_SHA1:
- case RPMSIGTAG_DSA:
- case RPMSIGTAG_RSA:
- default:
- if (!(tag >= HEADER_SIGBASE && tag < HEADER_TAGBASE))
- continue;
- /address@hidden@*/ break;
- }
- if (ptr == NULL) continue; /* XXX can't happen */
- if (!headerIsEntry(h, tag))
- hae(h, tag, type, ptr, count);
+ switch (tag)
+ {
+ case RPMSIGTAG_SIZE:
+ tag = RPMTAG_SIGSIZE;
+ /address@hidden@ */ break;
+ case RPMSIGTAG_LEMD5_1:
+ tag = RPMTAG_SIGLEMD5_1;
+ /address@hidden@ */ break;
+ case RPMSIGTAG_PGP:
+ tag = RPMTAG_SIGPGP;
+ /address@hidden@ */ break;
+ case RPMSIGTAG_LEMD5_2:
+ tag = RPMTAG_SIGLEMD5_2;
+ /address@hidden@ */ break;
+ case RPMSIGTAG_MD5:
+ tag = RPMTAG_SIGMD5;
+ /address@hidden@ */ break;
+ case RPMSIGTAG_GPG:
+ tag = RPMTAG_SIGGPG;
+ /address@hidden@ */ break;
+ case RPMSIGTAG_PGP5:
+ tag = RPMTAG_SIGPGP5;
+ /address@hidden@ */ break;
+ case RPMSIGTAG_PAYLOADSIZE:
+ tag = RPMTAG_ARCHIVESIZE;
+ /address@hidden@ */ break;
+ case RPMSIGTAG_SHA1:
+ case RPMSIGTAG_DSA:
+ case RPMSIGTAG_RSA:
+ default:
+ if (!(tag >= HEADER_SIGBASE && tag < HEADER_TAGBASE))
+ continue;
+ /address@hidden@ */ break;
+ }
+ if (ptr == NULL)
+ continue; /* XXX can't happen */
+ if (!headerIsEntry (h, tag))
+ hae (h, tag, type, ptr, count);
}
- hi = headerFreeIterator(hi);
+ hi = headerFreeIterator (hi);
}
-static Header rpmFreeSignature(Header h)
+static Header
+rpmFreeSignature (Header h)
{
- return headerFree(h);
+ return headerFree (h);
}
-static rpmRC rpmReadPackageHeader(FD_t fd, Header * hdrp, int * isSource, int
* major,
- int * minor)
+static rpmRC
+rpmReadPackageHeader (FD_t fd, Header * hdrp, int *isSource, int *major,
+ int *minor)
{
- struct rpmlead lead;
- Header sig = NULL;
- rpmRC rc = readPackageHeaders(fd, &lead, &sig, hdrp);
+ struct rpmlead lead;
+ Header sig = NULL;
+ rpmRC rc = readPackageHeaders (fd, &lead, &sig, hdrp);
- if (rc != RPMRC_OK)
- goto exit;
+ if (rc != RPMRC_OK)
+ goto exit;
- if (hdrp && *hdrp && sig) {
- headerMergeLegacySigs(*hdrp, sig);
- sig = rpmFreeSignature(sig);
+ if (hdrp && *hdrp && sig)
+ {
+ headerMergeLegacySigs (*hdrp, sig);
+ sig = rpmFreeSignature (sig);
}
- if (isSource) *isSource = lead.type == RPMLEAD_SOURCE;
- /address@hidden@*/
- if (major) *major = lead.major;
- if (minor) *minor = lead.minor;
- /address@hidden@*/
+ if (isSource)
+ *isSource = lead.type == RPMLEAD_SOURCE;
+ /address@hidden@ */
+ if (major)
+ *major = lead.major;
+ if (minor)
+ *minor = lead.minor;
+ /address@hidden@ */
exit:
- return rc;
+ return rc;
}
/* ******************** real libextractor stuff ************************ */
-static struct EXTRACTOR_Keywords * addKeyword(EXTRACTOR_KeywordType type,
- char * keyword,
- struct EXTRACTOR_Keywords * next)
{
- EXTRACTOR_KeywordList * result;
+static struct EXTRACTOR_Keywords *
+addKeyword (EXTRACTOR_KeywordType type,
+ char *keyword, struct EXTRACTOR_Keywords *next)
+{
+ EXTRACTOR_KeywordList *result;
if (keyword == NULL)
return next;
- result = malloc(sizeof(EXTRACTOR_KeywordList));
+ result = malloc (sizeof (EXTRACTOR_KeywordList));
result->next = next;
- result->keyword = strdup(keyword);
+ result->keyword = strdup (keyword);
result->keywordType = type;
return result;
}
-typedef struct {
+typedef struct
+{
int_32 rtype;
EXTRACTOR_KeywordType type;
} Matches;
@@ -2986,30 +3171,31 @@
/* SEE:
http://rikers.org/rpmbook/node119.html#SECTION031425200000000000000 */
static Matches tests[] = {
- { RPMTAG_NAME, EXTRACTOR_TITLE },
- { RPMTAG_VERSION, EXTRACTOR_VERSIONNUMBER },
- { RPMTAG_RELEASE, EXTRACTOR_RELEASE },
- { RPMTAG_GROUP, EXTRACTOR_GROUP },
- { RPMTAG_SIZE, EXTRACTOR_SIZE },
- { RPMTAG_URL, EXTRACTOR_RESOURCE_IDENTIFIER },
- { RPMTAG_SUMMARY, EXTRACTOR_SUMMARY },
- { RPMTAG_PACKAGER, EXTRACTOR_PACKAGER },
- { RPMTAG_BUILDTIME, EXTRACTOR_CREATION_DATE },
- { RPMTAG_COPYRIGHT, EXTRACTOR_COPYRIGHT },
- { RPMTAG_LICENSE, EXTRACTOR_LICENSE },
- { RPMTAG_DISTRIBUTION, EXTRACTOR_DISTRIBUTION },
- { RPMTAG_BUILDHOST, EXTRACTOR_BUILDHOST },
- { RPMTAG_VENDOR, EXTRACTOR_VENDOR },
- { RPMTAG_OS, EXTRACTOR_OS },
- { RPMTAG_DESCRIPTION, EXTRACTOR_DESCRIPTION },
- { 0, 0},
+ {RPMTAG_NAME, EXTRACTOR_TITLE},
+ {RPMTAG_VERSION, EXTRACTOR_VERSIONNUMBER},
+ {RPMTAG_RELEASE, EXTRACTOR_RELEASE},
+ {RPMTAG_GROUP, EXTRACTOR_GROUP},
+ {RPMTAG_SIZE, EXTRACTOR_SIZE},
+ {RPMTAG_URL, EXTRACTOR_RESOURCE_IDENTIFIER},
+ {RPMTAG_SUMMARY, EXTRACTOR_SUMMARY},
+ {RPMTAG_PACKAGER, EXTRACTOR_PACKAGER},
+ {RPMTAG_BUILDTIME, EXTRACTOR_CREATION_DATE},
+ {RPMTAG_COPYRIGHT, EXTRACTOR_COPYRIGHT},
+ {RPMTAG_LICENSE, EXTRACTOR_LICENSE},
+ {RPMTAG_DISTRIBUTION, EXTRACTOR_DISTRIBUTION},
+ {RPMTAG_BUILDHOST, EXTRACTOR_BUILDHOST},
+ {RPMTAG_VENDOR, EXTRACTOR_VENDOR},
+ {RPMTAG_OS, EXTRACTOR_OS},
+ {RPMTAG_DESCRIPTION, EXTRACTOR_DESCRIPTION},
+ {0, 0},
};
/* mimetype = application/rpm */
-struct EXTRACTOR_Keywords * libextractor_rpm_extract(char * filename,
- char * data,
- size_t size,
- struct EXTRACTOR_Keywords
* prev) {
+struct EXTRACTOR_Keywords *
+libextractor_rpm_extract (char *filename,
+ char *data,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
fdStruct handle;
Header hdr;
HeaderIterator hi;
@@ -3026,137 +3212,124 @@
handle.data = data;
handle.pos = 0;
handle.len = size;
- if (0 != rpmReadPackageHeader(&handle,
- &hdr,
- &isSource,
- &major,
- &minor)) {
- return prev;
- }
- prev = addKeyword(EXTRACTOR_MIMETYPE,
- "application/x-redhat-package-manager",
- prev);
+ if (0 != rpmReadPackageHeader (&handle, &hdr, &isSource, &major, &minor))
+ {
+ return prev;
+ }
+ prev = addKeyword (EXTRACTOR_MIMETYPE,
+ "application/x-redhat-package-manager", prev);
/* FIXME: add platform! */
if (isSource)
- sprintf(verb,
- _("Source RPM %d.%d"),
- major,
- minor);
+ sprintf (verb, _("Source RPM %d.%d"), major, minor);
else
- sprintf(verb,
- _("Binary RPM %d.%d"),
- major,
- minor);
- prev = addKeyword(EXTRACTOR_UNKNOWN,
- verb,
- prev);
- hi = headerInitIterator(hdr);
- while (1 == headerNextIterator(hi,
- &tag,
- &type,
- &p,
- &c,
- 0)) {
- i=0;
- while (tests[i].rtype != 0) {
- if (tests[i].rtype == tag) {
- switch (type) {
- case RPM_STRING_ARRAY_TYPE: {
- char * tmp;
- const char * p2;
- int c2;
- int size;
+ sprintf (verb, _("Binary RPM %d.%d"), major, minor);
+ prev = addKeyword (EXTRACTOR_UNKNOWN, verb, prev);
+ hi = headerInitIterator (hdr);
+ while (1 == headerNextIterator (hi, &tag, &type, &p, &c, 0))
+ {
+ i = 0;
+ while (tests[i].rtype != 0)
+ {
+ if (tests[i].rtype == tag)
+ {
+ switch (type)
+ {
+ case RPM_STRING_ARRAY_TYPE:
+ {
+ char *tmp;
+ const char *p2;
+ int c2;
+ int size;
- c2 = c;
- p2 = p;
- size = 0;
- while (c2--) {
- size += strlen(p2);
- p2 = strchr(p2, 0);
- p2++;
- }
-
- tmp = malloc(size+1);
- tmp[0] = '\0';
- while (c--) {
- strcat(tmp, p);
- p = strchr(p, 0);
- p++;
- }
- prev = addKeyword(tests[i].type,
- tmp,
- prev);
- free(tmp);
- break;
- }
- case RPM_I18NSTRING_TYPE: {
- char * tmp;
- const char * p2;
- int c2;
- int size;
+ c2 = c;
+ p2 = p;
+ size = 0;
+ while (c2--)
+ {
+ size += strlen (p2);
+ p2 = strchr (p2, 0);
+ p2++;
+ }
- c2 = c;
- p2 = p;
- p2+=sizeof(char*)*c;
- size = 0;
- while (c2--) {
- size += strlen(p2);
- p2 = strchr(p2, 0);
- p2++;
- }
-
- tmp = malloc(size+1);
- tmp[0] = '\0';
- p2 = p;
- p2+=sizeof(char*)*c;
- while (c--) {
- strcat(tmp, p2);
- p2 = strchr(p2, 0);
- p2++;
- }
- prev = addKeyword(tests[i].type,
- tmp,
- prev);
- free(tmp);
- break;
- }
- case RPM_STRING_TYPE:
- prev = addKeyword(tests[i].type,
- (char*)p,
- prev);
- break;
- case RPM_INT32_TYPE: {
- if (tag == RPMTAG_BUILDTIME) {
- char tmp[30];
+ tmp = malloc (size + 1);
+ tmp[0] = '\0';
+ while (c--)
+ {
+ strcat (tmp, p);
+ p = strchr (p, 0);
+ p++;
+ }
+ prev = addKeyword (tests[i].type, tmp, prev);
+ free (tmp);
+ break;
+ }
+ case RPM_I18NSTRING_TYPE:
+ {
+ char *tmp;
+ const char *p2;
+ int c2;
+ int size;
- ctime_r((time_t*)p, tmp);
- tmp[strlen(tmp)-1] = '\0'; /* eat linefeed */
- prev = addKeyword(tests[i].type,
- tmp,
- prev);
- } else {
- char tmp[14];
-
- sprintf(tmp, "%d", *(int*)p);
- prev = addKeyword(tests[i].type,
- tmp,
- prev);
- }
- break;
- }
- }
- }
- i++;
+ c2 = c;
+ p2 = p;
+ p2 += sizeof (char *) * c;
+ size = 0;
+ while (c2--)
+ {
+ size += strlen (p2);
+ p2 = strchr (p2, 0);
+ p2++;
+ }
+
+ tmp = malloc (size + 1);
+ tmp[0] = '\0';
+ p2 = p;
+ p2 += sizeof (char *) * c;
+ while (c--)
+ {
+ strcat (tmp, p2);
+ p2 = strchr (p2, 0);
+ p2++;
+ }
+ prev = addKeyword (tests[i].type, tmp, prev);
+ free (tmp);
+ break;
+ }
+ case RPM_STRING_TYPE:
+ prev = addKeyword (tests[i].type, (char *) p, prev);
+ break;
+ case RPM_INT32_TYPE:
+ {
+ if (tag == RPMTAG_BUILDTIME)
+ {
+ char tmp[30];
+
+ ctime_r ((time_t *) p, tmp);
+ tmp[strlen (tmp) - 1] = '\0'; /* eat linefeed */
+ prev = addKeyword (tests[i].type, tmp, prev);
+ }
+ else
+ {
+ char tmp[14];
+
+ sprintf (tmp, "%d", *(int *) p);
+ prev = addKeyword (tests[i].type, tmp, prev);
+ }
+ break;
+ }
+ }
+ }
+ i++;
+ }
+ if (((type == RPM_BIN_TYPE) ||
+ (type == RPM_I18NSTRING_TYPE) ||
+ (type == RPM_STRING_ARRAY_TYPE)) && (p != NULL))
+ {
+ free ((void *) p);
+ }
}
- if ( ( (type == RPM_BIN_TYPE) ||
- (type == RPM_I18NSTRING_TYPE) ||
- (type == RPM_STRING_ARRAY_TYPE) ) &&
- (p != NULL) ) {
- free((void*)p);
- }
- }
- headerFreeIterator(hi);
- headerFree(hdr);
+ headerFreeIterator (hi);
+ headerFree (hdr);
return prev;
}
Modified: Extractor/src/plugins/sidextractor.c
===================================================================
--- Extractor/src/plugins/sidextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/sidextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -36,53 +36,49 @@
#define MOS6581_FLAG 0x10
#define MOS8580_FLAG 0x20
-typedef char sidwrd[ 2 ];
-typedef char sidlongwrd[ 4 ];
+typedef char sidwrd[2];
+typedef char sidlongwrd[4];
struct header
{
- char magicid[ 4 ];
- sidwrd sidversion;
- sidwrd dataoffset;
- sidwrd loadaddr;
- sidwrd initaddr;
- sidwrd playaddr;
- sidwrd songs;
- sidwrd firstsong;
- sidlongwrd speed;
- char title[ 32 ];
- char artist[ 32 ];
- char copyright[ 32 ];
- sidwrd flags; /* version 2 specific fields start */
- char startpage;
- char pagelength;
- sidwrd reserved;
+ char magicid[4];
+ sidwrd sidversion;
+ sidwrd dataoffset;
+ sidwrd loadaddr;
+ sidwrd initaddr;
+ sidwrd playaddr;
+ sidwrd songs;
+ sidwrd firstsong;
+ sidlongwrd speed;
+ char title[32];
+ char artist[32];
+ char copyright[32];
+ sidwrd flags; /* version 2 specific fields start */
+ char startpage;
+ char pagelength;
+ sidwrd reserved;
};
-int sidword( sidwrd data )
+int
+sidword (sidwrd data)
{
- int value =
- ( unsigned char ) data[ 0 ] * 0x100 +
- ( unsigned char ) data[ 1 ];
+ int value = (unsigned char) data[0] * 0x100 + (unsigned char) data[1];
- return( value );
+ return (value);
}
-static struct EXTRACTOR_Keywords * addkword
-(
- EXTRACTOR_KeywordList *oldhead,
- const char * phrase,
- EXTRACTOR_KeywordType type
-)
+static struct EXTRACTOR_Keywords *addkword
+ (EXTRACTOR_KeywordList * oldhead,
+ const char *phrase, EXTRACTOR_KeywordType type)
{
- EXTRACTOR_KeywordList * keyword;
+ EXTRACTOR_KeywordList *keyword;
- keyword = malloc( sizeof( EXTRACTOR_KeywordList ) );
- keyword->next = oldhead;
- keyword->keyword = strdup( phrase );
- keyword->keywordType = type;
- return( keyword );
+ keyword = malloc (sizeof (EXTRACTOR_KeywordList));
+ keyword->next = oldhead;
+ keyword->keyword = strdup (phrase);
+ keyword->keywordType = type;
+ return (keyword);
}
@@ -91,155 +87,148 @@
* This plugin is based on the nsf extractor
*
*/
-struct EXTRACTOR_Keywords * libextractor_sid_extract
-(
- const char * filename,
- char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev
-)
+struct EXTRACTOR_Keywords *libextractor_sid_extract
+ (const char *filename,
+ char *data, size_t size, struct EXTRACTOR_Keywords *prev)
{
- unsigned int flags;
- int version;
- char album[ 33 ];
- char artist[ 33 ];
- char copyright[ 33 ];
- char songs[ 32 ];
- char startingsong[ 32 ];
- char sidversion[ 32 ];
- struct header *head;
+ unsigned int flags;
+ int version;
+ char album[33];
+ char artist[33];
+ char copyright[33];
+ char songs[32];
+ char startingsong[32];
+ char sidversion[32];
+ struct header *head;
- /* Check header size */
+ /* Check header size */
- if( size < SID1_HEADER_SIZE )
- {
- return( prev );
- }
+ if (size < SID1_HEADER_SIZE)
+ {
+ return (prev);
+ }
- head = ( struct header * ) data;
+ head = (struct header *) data;
- /* Check "magic" id bytes */
+ /* Check "magic" id bytes */
- if
- (
- memcmp( head->magicid, "PSID", 4 ) &&
- memcmp( head->magicid, "RSID", 4 )
- )
- {
- return( prev );
- }
+ if (memcmp (head->magicid, "PSID", 4) && memcmp (head->magicid, "RSID", 4))
+ {
+ return (prev);
+ }
- /* Mime-type */
+ /* Mime-type */
- prev = addkword( prev, "audio/prs.sid", EXTRACTOR_MIMETYPE );
+ prev = addkword (prev, "audio/prs.sid", EXTRACTOR_MIMETYPE);
- /* Version of SID format */
+ /* Version of SID format */
- version = sidword( head->sidversion );
- sprintf( sidversion, "%d", version );
- prev = addkword( prev, sidversion, EXTRACTOR_FORMAT_VERSION );
+ version = sidword (head->sidversion);
+ sprintf (sidversion, "%d", version);
+ prev = addkword (prev, sidversion, EXTRACTOR_FORMAT_VERSION);
- /* Get song count */
+ /* Get song count */
- sprintf( songs, "%d", sidword( head->songs ) );
- prev = addkword( prev, songs, EXTRACTOR_SONG_COUNT );
+ sprintf (songs, "%d", sidword (head->songs));
+ prev = addkword (prev, songs, EXTRACTOR_SONG_COUNT);
- /* Get number of the first song to be played */
+ /* Get number of the first song to be played */
- sprintf( startingsong, "%d", sidword( head->firstsong ) );
- prev = addkword( prev, startingsong, EXTRACTOR_STARTING_SONG );
+ sprintf (startingsong, "%d", sidword (head->firstsong));
+ prev = addkword (prev, startingsong, EXTRACTOR_STARTING_SONG);
- /* name, artist, copyright fields */
+ /* name, artist, copyright fields */
- memcpy( &album, head->title, 32 );
- memcpy( &artist, head->artist, 32 );
- memcpy( ©right, head->copyright, 32 );
+ memcpy (&album, head->title, 32);
+ memcpy (&artist, head->artist, 32);
+ memcpy (©right, head->copyright, 32);
- album[ 32 ] = '\0';
- artist[ 32 ] = '\0';
- copyright[ 32 ] = '\0';
+ album[32] = '\0';
+ artist[32] = '\0';
+ copyright[32] = '\0';
- prev = addkword( prev, album, EXTRACTOR_ALBUM );
- prev = addkword( prev, artist, EXTRACTOR_ARTIST );
- prev = addkword( prev, copyright, EXTRACTOR_COPYRIGHT );
+ prev = addkword (prev, album, EXTRACTOR_ALBUM);
+ prev = addkword (prev, artist, EXTRACTOR_ARTIST);
+ prev = addkword (prev, copyright, EXTRACTOR_COPYRIGHT);
- if( version < 2 || size < SID2_HEADER_SIZE )
- {
- return( prev );
- }
+ if (version < 2 || size < SID2_HEADER_SIZE)
+ {
+ return (prev);
+ }
- /* Version 2 specific options follow
- *
- * Note: Had some troubles understanding specification
- * on the flags in version 2. I hope this is correct.
- *
- */
+ /* Version 2 specific options follow
+ *
+ * Note: Had some troubles understanding specification
+ * on the flags in version 2. I hope this is correct.
+ *
+ */
- flags = sidword( head->flags );
+ flags = sidword (head->flags);
- /* MUS data */
+ /* MUS data */
- if( flags & MUSPLAYER_FLAG )
- {
- prev = addkword( prev, "Compute!'s Sidplayer",
EXTRACTOR_DEPENDENCY );
- }
+ if (flags & MUSPLAYER_FLAG)
+ {
+ prev = addkword (prev, "Compute!'s Sidplayer", EXTRACTOR_DEPENDENCY);
+ }
- /* PlaySID data */
+ /* PlaySID data */
- if( flags & PLAYSID_FLAG )
- {
- prev = addkword( prev, "PlaySID", EXTRACTOR_DEPENDENCY );
- }
+ if (flags & PLAYSID_FLAG)
+ {
+ prev = addkword (prev, "PlaySID", EXTRACTOR_DEPENDENCY);
+ }
- /* PAL or NTSC */
+ /* PAL or NTSC */
- if( flags & PAL_FLAG )
- {
- if( flags & NTSC_FLAG )
- {
- prev = addkword( prev, "PAL/NTSC",
EXTRACTOR_TELEVISION_SYSTEM );
- }
- else
- {
- prev = addkword( prev, "PAL",
EXTRACTOR_TELEVISION_SYSTEM );
- }
- }
- else
- {
- if( flags & NTSC_FLAG )
- {
- prev = addkword( prev, "NTSC",
EXTRACTOR_TELEVISION_SYSTEM );
- }
- }
+ if (flags & PAL_FLAG)
+ {
+ if (flags & NTSC_FLAG)
+ {
+ prev = addkword (prev, "PAL/NTSC", EXTRACTOR_TELEVISION_SYSTEM);
+ }
+ else
+ {
+ prev = addkword (prev, "PAL", EXTRACTOR_TELEVISION_SYSTEM);
+ }
+ }
+ else
+ {
+ if (flags & NTSC_FLAG)
+ {
+ prev = addkword (prev, "NTSC", EXTRACTOR_TELEVISION_SYSTEM);
+ }
+ }
- /* Detect SID Chips suitable for play the files */
+ /* Detect SID Chips suitable for play the files */
- if( flags & MOS6581_FLAG )
- {
- if( flags & MOS8580_FLAG )
- {
- prev = addkword( prev, "MOS6581/MOS8580",
EXTRACTOR_HARDWARE_DEPENDENCY );
- }
- else
- {
- prev = addkword( prev, "MOS6581",
EXTRACTOR_HARDWARE_DEPENDENCY );
- }
- }
- else
- {
- if( flags & MOS8580_FLAG )
- {
- prev = addkword( prev, "MOS8580",
EXTRACTOR_HARDWARE_DEPENDENCY );
- }
- }
+ if (flags & MOS6581_FLAG)
+ {
+ if (flags & MOS8580_FLAG)
+ {
+ prev =
+ addkword (prev, "MOS6581/MOS8580", EXTRACTOR_HARDWARE_DEPENDENCY);
+ }
+ else
+ {
+ prev = addkword (prev, "MOS6581", EXTRACTOR_HARDWARE_DEPENDENCY);
+ }
+ }
+ else
+ {
+ if (flags & MOS8580_FLAG)
+ {
+ prev = addkword (prev, "MOS8580", EXTRACTOR_HARDWARE_DEPENDENCY);
+ }
+ }
- return( prev );
+ return (prev);
}
Modified: Extractor/src/plugins/splitextractor.c
===================================================================
--- Extractor/src/plugins/splitextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/splitextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -24,7 +24,7 @@
/**
* Default split characters.
*/
-static const char * TOKENIZERS = "._ ,address@hidden(){}";
+static const char *TOKENIZERS = "._ ,address@hidden(){}";
/**
* Do not use keywords shorter than this minimum
@@ -32,79 +32,125 @@
*/
static int MINIMUM_KEYWORD_LENGTH = 4;
-static void addKeyword(struct EXTRACTOR_Keywords ** list,
- const char * keyword) {
- EXTRACTOR_KeywordList * next;
- next = malloc(sizeof(EXTRACTOR_KeywordList));
+static void
+addKeyword (struct EXTRACTOR_Keywords **list, const char *keyword)
+{
+ EXTRACTOR_KeywordList *next;
+ next = malloc (sizeof (EXTRACTOR_KeywordList));
next->next = *list;
- next->keyword = strdup(keyword);
+ next->keyword = strdup (keyword);
next->keywordType = EXTRACTOR_SPLIT;
*list = next;
}
-static int token(char letter,
- const char * options) {
+static int
+token (char letter, const char *options)
+{
size_t i;
i = 0;
- while (options[i] != '\0') {
- if (letter == options[i])
- return 1;
- i++;
- }
+ while (options[i] != '\0')
+ {
+ if (letter == options[i])
+ return 1;
+ i++;
+ }
return 0;
}
-static void splitKeywords(const char * keyword,
- struct EXTRACTOR_Keywords ** list,
- const char * options) {
- char * dp;
+static void
+splitKeywords (const char *keyword,
+ struct EXTRACTOR_Keywords **list, const char *options)
+{
+ char *dp;
size_t pos;
size_t last;
size_t len;
- dp = strdup(keyword);
- len = strlen(dp);
+ dp = strdup (keyword);
+ len = strlen (dp);
pos = 0;
last = 0;
- while (pos < len) {
- while ( (0 == token(dp[pos], options)) &&
- (pos < len) )
- pos++;
- dp[pos++] = '\0';
- if ( (pos - last > MINIMUM_KEYWORD_LENGTH) &&
- (0 != strcmp(keyword,
- &dp[last])) )
- addKeyword(list,
- &dp[last]);
- while ( (pos < len) &&
- (1 == token(dp[pos], options)) )
- pos++;
- last = pos;
- }
- free(dp);
+ while (pos < len)
+ {
+ while ((0 == token (dp[pos], options)) && (pos < len))
+ pos++;
+ dp[pos++] = '\0';
+ if ((pos - last > MINIMUM_KEYWORD_LENGTH) &&
+ (0 != strcmp (keyword, &dp[last])))
+ addKeyword (list, &dp[last]);
+ while ((pos < len) && (1 == token (dp[pos], options)))
+ pos++;
+ last = pos;
+ }
+ free (dp);
}
/* split other keywords into multiple keywords */
struct EXTRACTOR_Keywords *
-libextractor_split_extract(const char * filename,
- const char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev,
- const char * options) {
- struct EXTRACTOR_Keywords * pos;
+libextractor_split_extract (const char *filename,
+ const char *data,
+ size_t size,
+ struct EXTRACTOR_Keywords *prev,
+ const char *options)
+{
+ struct EXTRACTOR_Keywords *kpos;
+ char *opt;
+ char *pos;
if (options == NULL)
- options = TOKENIZERS;
- pos = prev;
- while (pos != NULL) {
- if (pos->keywordType != EXTRACTOR_FILE_SIZE)
- splitKeywords(pos->keyword,
- &prev,
- options);
-
- pos = pos->next;
- }
+ {
+ opt = strdup (TOKENIZERS);
+ }
+ else
+ {
+ opt = strdup (options);
+ pos = opt;
+ while (pos[0] != '\0')
+ {
+ if (pos[0] == '\\')
+ {
+ switch (pos[1])
+ {
+ case 'n':
+ pos[0] = '\n';
+ memmove (&pos[1], &pos[2], strlen (&pos[2]));
+ continue;
+ case 'r':
+ pos[0] = '\r';
+ memmove (&pos[1], &pos[2], strlen (&pos[2]));
+ continue;
+ case 'b':
+ pos[0] = '\b';
+ memmove (&pos[1], &pos[2], strlen (&pos[2]));
+ continue;
+ case 't':
+ pos[0] = '\t';
+ memmove (&pos[1], &pos[2], strlen (&pos[2]));
+ continue;
+ case '\\':
+ memmove (&pos[1], &pos[2], strlen (&pos[2]));
+ continue;
+ case '\0': /* invalid escape, ignore */
+ pos[0] = '\0';
+ break;
+ default: /* invalid escape, skip */
+ memmove (&pos[0], &pos[2], strlen (&pos[2]));
+ continue;
+ }
+ }
+ pos++;
+ }
+ }
+ kpos = prev;
+ while (kpos != NULL)
+ {
+ if (kpos->keywordType != EXTRACTOR_FILE_SIZE)
+ splitKeywords (kpos->keyword, &prev, options);
+
+ kpos = kpos->next;
+ }
+ free (opt);
return prev;
}
Modified: Extractor/src/plugins/tarextractor.c
===================================================================
--- Extractor/src/plugins/tarextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/tarextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -35,52 +35,68 @@
* (J. Schilling's remarks on TAR formats compatibility issues.)
*/
-static EXTRACTOR_KeywordList * addKeyword(EXTRACTOR_KeywordType type,
- char * keyword,
- EXTRACTOR_KeywordList * next) {
- EXTRACTOR_KeywordList * result = next;
+static EXTRACTOR_KeywordList *
+addKeyword (EXTRACTOR_KeywordType type,
+ char *keyword, EXTRACTOR_KeywordList * next)
+{
+ EXTRACTOR_KeywordList *result = next;
- if (NULL != keyword) {
- if (0 == *keyword) {
- free(keyword);
- } else {
- result = malloc(sizeof(EXTRACTOR_KeywordList));
- if(NULL == result) {
- free(keyword);
- } else {
- result->next = next;
- result->keyword = keyword;
- result->keywordType = type;
- }
+ if (NULL != keyword)
+ {
+ if (0 == *keyword)
+ {
+ free (keyword);
+ }
+ else
+ {
+ result = malloc (sizeof (EXTRACTOR_KeywordList));
+ if (NULL == result)
+ {
+ free (keyword);
+ }
+ else
+ {
+ result->next = next;
+ result->keyword = keyword;
+ result->keywordType = type;
+ }
+ }
}
- }
return result;
}
-static EXTRACTOR_KeywordList * appendKeyword(EXTRACTOR_KeywordType type,
- char * keyword,
- EXTRACTOR_KeywordList * last) {
- EXTRACTOR_KeywordList * result = last;
+static EXTRACTOR_KeywordList *
+appendKeyword (EXTRACTOR_KeywordType type,
+ char *keyword, EXTRACTOR_KeywordList * last)
+{
+ EXTRACTOR_KeywordList *result = last;
- if (NULL != keyword) {
- if (0 == *keyword) {
- free(keyword);
- } else {
- if ( (NULL != last) && (NULL != last->next) )
- abort();
- result = malloc(sizeof(EXTRACTOR_KeywordList));
- if(NULL == result) {
- free(keyword);
- } else {
- result->next = NULL;
- result->keywordType = type;
- result->keyword = keyword;
- if (NULL != last)
- last->next = result;
- }
+ if (NULL != keyword)
+ {
+ if (0 == *keyword)
+ {
+ free (keyword);
+ }
+ else
+ {
+ if ((NULL != last) && (NULL != last->next))
+ abort ();
+ result = malloc (sizeof (EXTRACTOR_KeywordList));
+ if (NULL == result)
+ {
+ free (keyword);
+ }
+ else
+ {
+ result->next = NULL;
+ result->keywordType = type;
+ result->keyword = keyword;
+ if (NULL != last)
+ last->next = result;
+ }
+ }
}
- }
return result;
}
@@ -106,13 +122,14 @@
/*
* TAR header structure, modelled after POSIX.1-1988
*/
-typedef struct {
+typedef struct
+{
char fileName[100];
char mode[8];
char userId[8];
char groupId[8];
char fileSize[12];
- char lastModTime [12];
+ char lastModTime[12];
char chksum[8];
char link;
char linkName[100];
@@ -136,7 +153,7 @@
#define TAR_TIME_FENCE ((long long) (-(1LL << 62)))
static size_t
-tar_roundup(size_t size)
+tar_roundup (size_t size)
{
size_t diff = (size % TAR_HEADER_SIZE);
@@ -144,54 +161,55 @@
}
static int
-tar_isnonzero(const char *data,
- unsigned int length)
+tar_isnonzero (const char *data, unsigned int length)
{
unsigned int total = 0;
- while(total < length) {
- if(0 != data[total])
- return 1;
- total++;
- }
+ while (total < length)
+ {
+ if (0 != data[total])
+ return 1;
+ total++;
+ }
return 0;
}
static unsigned int
-tar_octalvalue(const char *data,
- size_t size,
- unsigned long long *valueptr)
+tar_octalvalue (const char *data, size_t size, unsigned long long *valueptr)
{
- unsigned int result = 0;
+ unsigned int result = 0;
- if(NULL != data && 0 < size) {
- const char *p = data;
- int found = 0;
- unsigned long long value = 0;
+ if (NULL != data && 0 < size)
+ {
+ const char *p = data;
+ int found = 0;
+ unsigned long long value = 0;
- while( (p < data + size) && (' ' == *p) )
- p += 1;
+ while ((p < data + size) && (' ' == *p))
+ p += 1;
- while( (p < data + size) && ('0' <= *p) && (*p < '8') ) {
- found = 1;
- value *= 8;
- value += (*p - '0');
- p += 1;
- }
+ while ((p < data + size) && ('0' <= *p) && (*p < '8'))
+ {
+ found = 1;
+ value *= 8;
+ value += (*p - '0');
+ p += 1;
+ }
- if(0 != found) {
- while( (p < data + size) && ((0 == *p) || (' ' == *p)) )
- p += 1;
+ if (0 != found)
+ {
+ while ((p < data + size) && ((0 == *p) || (' ' == *p)))
+ p += 1;
- result = (p - data);
- }
+ result = (p - data);
+ }
- if( (0 < result) && (NULL != valueptr) )
- *valueptr = value;
- }
+ if ((0 < result) && (NULL != valueptr))
+ *valueptr = value;
+ }
- return result;
+ return result;
}
#ifndef EOVERFLOW
@@ -199,9 +217,7 @@
#endif
static int
-tar_time(long long timeval,
- char *rtime,
- unsigned int rsize)
+tar_time (long long timeval, char *rtime, unsigned int rsize)
{
int retval = 0;
@@ -210,98 +226,109 @@
* to make subsequent modulo operations safer.
*/
long long my_timeval = timeval
- + ((long long) ((1970 * 365) + 478)
- * (long long) 86400);
+ + ((long long) ((1970 * 365) + 478) * (long long) 86400);
unsigned int seconds = (unsigned int) (my_timeval % 60);
unsigned int minutes = (unsigned int) ((my_timeval / 60) % 60);
- unsigned int hours = (unsigned int) ((my_timeval / 3600) % 24);
+ unsigned int hours = (unsigned int) ((my_timeval / 3600) % 24);
- unsigned int year = 0;
- unsigned int month = 1;
+ unsigned int year = 0;
+ unsigned int month = 1;
- unsigned int days = (unsigned int) (my_timeval / (24 * 3600));
+ unsigned int days = (unsigned int) (my_timeval / (24 * 3600));
- unsigned int days_in_month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30,
31};
+ unsigned int days_in_month[] =
+ { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
unsigned int diff = 0;
- if ((long long)0 > my_timeval)
+ if ((long long) 0 > my_timeval)
return EDOM;
/*
* 400-year periods
*/
- year += ( 400 * (days / ((365 * 400) + 97)) );
+ year += (400 * (days / ((365 * 400) + 97)));
days %= ((365 * 400) + 97);
/*
* 100-year periods
*/
- diff = (days / ((365 * 100) + 24));
- if(4 <= diff) {
- year += 399;
- days = 364;
- }
- else {
- year += (100 * diff);
- days %= ((365 * 100) + 24);
- }
+ diff = (days / ((365 * 100) + 24));
+ if (4 <= diff)
+ {
+ year += 399;
+ days = 364;
+ }
+ else
+ {
+ year += (100 * diff);
+ days %= ((365 * 100) + 24);
+ }
/*
* remaining leap years
*/
- year += (4 * (days / ((365 * 4) + 1)) );
+ year += (4 * (days / ((365 * 4) + 1)));
days %= ((365 * 4) + 1);
- while(1) {
- if( (0 == (year % 400)) || ((0 == (year % 4)) && (0 != (year % 100))) ) {
- if(366 > days) {
- break;
- } else {
- days -= 366;
- year++;
- }
+ while (1)
+ {
+ if ((0 == (year % 400)) || ((0 == (year % 4)) && (0 != (year % 100))))
+ {
+ if (366 > days)
+ {
+ break;
+ }
+ else
+ {
+ days -= 366;
+ year++;
+ }
+ }
+ else
+ {
+ if (365 > days)
+ {
+ break;
+ }
+ else
+ {
+ days -= 365;
+ year++;
+ }
+ }
}
- else {
- if(365 > days) {
- break;
- } else {
- days -= 365;
- year++;
- }
- }
- }
- if( (0 == (year % 400)) || ((0 == (year % 4)) && (0 != (year % 100))) )
+ if ((0 == (year % 400)) || ((0 == (year % 4)) && (0 != (year % 100))))
days_in_month[1] = 29;
for (month = 0; (month < 12) && (days >= days_in_month[month]); month += 1)
days -= days_in_month[month];
- retval = snprintf(rtime, rsize, "%04u-%02u-%02uT%02u:%02u:%02uZ",
- year, month + 1, days + 1, hours, minutes, seconds);
+ retval = snprintf (rtime, rsize, "%04u-%02u-%02uT%02u:%02u:%02uZ",
+ year, month + 1, days + 1, hours, minutes, seconds);
return (retval < rsize) ? 0 : EOVERFLOW;
}
struct EXTRACTOR_Keywords *
-libextractor_tar_extract(const char * filename,
- const char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev) {
+libextractor_tar_extract (const char *filename,
+ const char *data,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
char *fname = NULL;
size_t pos = 0;
int contents_are_empty = 1;
long long maxftime = TAR_TIME_FENCE;
unsigned int format_archive = 0;
- struct EXTRACTOR_Keywords * last;
+ struct EXTRACTOR_Keywords *last;
if (512 != TAR_HEADER_SIZE)
- return prev; /* compiler should remove this when optimising */
+ return prev; /* compiler should remove this when optimising
*/
if (0 != (size % TAR_HEADER_SIZE))
- return prev; /* cannot be tar! */
+ return prev; /* cannot be tar! */
if (size < TAR_HEADER_SIZE)
- return prev; /* too short, or somehow truncated */
+ return prev; /* too short, or somehow truncated */
last = prev;
if (last != NULL)
@@ -309,510 +336,595 @@
last = last->next;
pos = 0;
- while ((pos + TAR_HEADER_SIZE) <= size) {
- const TarHeader * tar = NULL;
- unsigned format_member = 0;
- unsigned long long fmode;
- unsigned long long fsize;
- long long ftime;
- char typeFlag = -1;
- const char * nul_pos;
- unsigned int tar_prefix_length = 0;
- unsigned int tar_name_length = 0;
- unsigned int checksum_offset;
- int checksum_computed_500s = 0;
- int checksum_computed_512s = 0;
- unsigned int checksum_computed_500u = 0;
- unsigned int checksum_computed_512u = 0;
- unsigned long long checksum_stored = 0;
+ while ((pos + TAR_HEADER_SIZE) <= size)
+ {
+ const TarHeader *tar = NULL;
+ unsigned format_member = 0;
+ unsigned long long fmode;
+ unsigned long long fsize;
+ long long ftime;
+ char typeFlag = -1;
+ const char *nul_pos;
+ unsigned int tar_prefix_length = 0;
+ unsigned int tar_name_length = 0;
+ unsigned int checksum_offset;
+ int checksum_computed_500s = 0;
+ int checksum_computed_512s = 0;
+ unsigned int checksum_computed_500u = 0;
+ unsigned int checksum_computed_512u = 0;
+ unsigned long long checksum_stored = 0;
- /*
- * Compute TAR header checksum and compare with stored value.
- * Allow for non-conformant checksums computed with signed values,
- * such as those produced by early Solaris tar.
- * Allow for non-conformant checksums computed on first 500 octets,
- * such as those produced by SunOS 4.x tar according to J. Schilling.
- * This will also detect EOF marks, since a zero-filled block
- * cannot possibly hold octal values.
- */
- for (checksum_offset = 0; checksum_offset < 148; checksum_offset += 1) {
- checksum_computed_500u += (unsigned char) data[pos + checksum_offset];
- checksum_computed_500s += (signed char) data[pos + checksum_offset];
- }
- if (8 > tar_octalvalue(data + pos + checksum_offset, 8, &checksum_stored))
- break;
- for (; checksum_offset < 156; checksum_offset += 1) {
- checksum_computed_500u += (unsigned char) ' ';
- checksum_computed_500s += (signed char) ' ';
- }
- for (; checksum_offset < 500; checksum_offset += 1) {
- checksum_computed_500u += (unsigned char) data[pos + checksum_offset];
- checksum_computed_500s += (signed char) data[pos + checksum_offset];
- }
+ /*
+ * Compute TAR header checksum and compare with stored value.
+ * Allow for non-conformant checksums computed with signed values,
+ * such as those produced by early Solaris tar.
+ * Allow for non-conformant checksums computed on first 500 octets,
+ * such as those produced by SunOS 4.x tar according to J. Schilling.
+ * This will also detect EOF marks, since a zero-filled block
+ * cannot possibly hold octal values.
+ */
+ for (checksum_offset = 0; checksum_offset < 148; checksum_offset += 1)
+ {
+ checksum_computed_500u +=
+ (unsigned char) data[pos + checksum_offset];
+ checksum_computed_500s += (signed char) data[pos + checksum_offset];
+ }
+ if (8 >
+ tar_octalvalue (data + pos + checksum_offset, 8, &checksum_stored))
+ break;
+ for (; checksum_offset < 156; checksum_offset += 1)
+ {
+ checksum_computed_500u += (unsigned char) ' ';
+ checksum_computed_500s += (signed char) ' ';
+ }
+ for (; checksum_offset < 500; checksum_offset += 1)
+ {
+ checksum_computed_500u +=
+ (unsigned char) data[pos + checksum_offset];
+ checksum_computed_500s += (signed char) data[pos + checksum_offset];
+ }
- checksum_computed_512u = checksum_computed_500u;
- checksum_computed_512s = checksum_computed_500s;
- for (; checksum_offset < TAR_HEADER_SIZE; checksum_offset += 1) {
- checksum_computed_512u += (unsigned char) data[pos + checksum_offset];
- checksum_computed_512s += (signed char) data[pos + checksum_offset];
- }
+ checksum_computed_512u = checksum_computed_500u;
+ checksum_computed_512s = checksum_computed_500s;
+ for (; checksum_offset < TAR_HEADER_SIZE; checksum_offset += 1)
+ {
+ checksum_computed_512u +=
+ (unsigned char) data[pos + checksum_offset];
+ checksum_computed_512s += (signed char) data[pos + checksum_offset];
+ }
- /*
- * Suggestion: use signed checksum matches to refine
- * TAR format detection.
- */
- if ( (checksum_stored != (unsigned long long) checksum_computed_512u)
- && (checksum_stored != (unsigned long long) checksum_computed_512s)
- && (checksum_stored != (unsigned long long) checksum_computed_500s)
- && (checksum_stored != (unsigned long long) checksum_computed_500u) )
- break;
+ /*
+ * Suggestion: use signed checksum matches to refine
+ * TAR format detection.
+ */
+ if ((checksum_stored != (unsigned long long) checksum_computed_512u)
+ && (checksum_stored != (unsigned long long) checksum_computed_512s)
+ && (checksum_stored != (unsigned long long) checksum_computed_500s)
+ && (checksum_stored != (unsigned long long) checksum_computed_500u))
+ break;
- tar = (const TarHeader*) &data[pos];
- typeFlag = tar->link;
- pos += TAR_HEADER_SIZE;
+ tar = (const TarHeader *) &data[pos];
+ typeFlag = tar->link;
+ pos += TAR_HEADER_SIZE;
- /*
- * Checking all octal fields helps reduce
- * the possibility of false positives ;
- * only the file size, time and mode are used for now.
- *
- * This will fail over GNU and Schilling TAR huge size fields
- * using non-octal encodings used for very large file lengths (> 8 GB).
- */
- if( (12 > tar_octalvalue(tar->fileSize, 12,
- &fsize))
- || (12 > tar_octalvalue(tar->lastModTime, 12,
- (unsigned long long *) &ftime))
- || (8 > tar_octalvalue(tar->mode, 8,
- (unsigned long long *) &fmode))
- || (8 > tar_octalvalue(tar->userId, 8, NULL))
- || (8 > tar_octalvalue(tar->groupId, 8, NULL)) )
- break;
+ /*
+ * Checking all octal fields helps reduce
+ * the possibility of false positives ;
+ * only the file size, time and mode are used for now.
+ *
+ * This will fail over GNU and Schilling TAR huge size fields
+ * using non-octal encodings used for very large file lengths (> 8 GB).
+ */
+ if ((12 > tar_octalvalue (tar->fileSize, 12,
+ &fsize))
+ || (12 > tar_octalvalue (tar->lastModTime, 12,
+ (unsigned long long *) &ftime))
+ || (8 > tar_octalvalue (tar->mode, 8,
+ (unsigned long long *) &fmode))
+ || (8 > tar_octalvalue (tar->userId, 8, NULL))
+ || (8 > tar_octalvalue (tar->groupId, 8, NULL)))
+ break;
- /*
- * Find out which TAR variant is here.
- */
- if(0 == memcmp(tar->ustarMagic, "ustar ", 7)) {
+ /*
+ * Find out which TAR variant is here.
+ */
+ if (0 == memcmp (tar->ustarMagic, "ustar ", 7))
+ {
- if(' ' == tar->mode[6])
- format_member = TAR_GNU1991_FORMAT;
- else if( ('K' == typeFlag) || ('L' == typeFlag) ) {
- format_member = TAR_GNU1997_FORMAT;
- ftime = TAR_TIME_FENCE;
- } else
- format_member = ( ((unsigned) fmode) != (((unsigned) fmode) & 03777) )
- ? TAR_GNU1997_FORMAT : TAR_GNU2004_FORMAT;
+ if (' ' == tar->mode[6])
+ format_member = TAR_GNU1991_FORMAT;
+ else if (('K' == typeFlag) || ('L' == typeFlag))
+ {
+ format_member = TAR_GNU1997_FORMAT;
+ ftime = TAR_TIME_FENCE;
+ }
+ else
+ format_member =
+ (((unsigned) fmode) !=
+ (((unsigned) fmode) & 03777)) ? TAR_GNU1997_FORMAT :
+ TAR_GNU2004_FORMAT;
- } else if (0 == memcmp(tar->ustarMagic, "ustar", 6)) {
+ }
+ else if (0 == memcmp (tar->ustarMagic, "ustar", 6))
+ {
- /*
- * It is important to perform test for SCHILLING1994 before GNU1997
- * because certain extension type flags ('L' and 'S' for instance)
- * are used by both.
- */
- if( (0 == tar->prefix[130])
- && (12 <= tar_octalvalue(tar->prefix + 131, 12, NULL))
- && (12 <= tar_octalvalue(tar->prefix + 143, 12, NULL))
- && (0 == tar_isnonzero(tar->filler, 8))
- && (0 == memcmp(tar->filler + 8, "tar", 4)) ) {
+ /*
+ * It is important to perform test for SCHILLING1994 before GNU1997
+ * because certain extension type flags ('L' and 'S' for instance)
+ * are used by both.
+ */
+ if ((0 == tar->prefix[130])
+ && (12 <= tar_octalvalue (tar->prefix + 131, 12, NULL))
+ && (12 <= tar_octalvalue (tar->prefix + 143, 12, NULL))
+ && (0 == tar_isnonzero (tar->filler, 8))
+ && (0 == memcmp (tar->filler + 8, "tar", 4)))
+ {
- format_member = TAR_SCHILLING1994_FORMAT;
+ format_member = TAR_SCHILLING1994_FORMAT;
- } else if ( ('D' == typeFlag) || ('K' == typeFlag)
- || ('L' == typeFlag) || ('M' == typeFlag)
- || ('N' == typeFlag) || ('S' == typeFlag)
- || ('V' == typeFlag) ) {
+ }
+ else if (('D' == typeFlag) || ('K' == typeFlag)
+ || ('L' == typeFlag) || ('M' == typeFlag)
+ || ('N' == typeFlag) || ('S' == typeFlag)
+ || ('V' == typeFlag))
+ {
- format_member = TAR_GNU1997_FORMAT;
+ format_member = TAR_GNU1997_FORMAT;
- } else if ( ('g' == typeFlag)
- || ('x' == typeFlag) || ('X' == typeFlag) ) {
+ }
+ else if (('g' == typeFlag)
+ || ('x' == typeFlag) || ('X' == typeFlag))
+ {
- format_member = TAR_POSIX2001_FORMAT;
- ftime = TAR_TIME_FENCE;
+ format_member = TAR_POSIX2001_FORMAT;
+ ftime = TAR_TIME_FENCE;
- } else {
+ }
+ else
+ {
- format_member = TAR_POSIX1988_FORMAT;
+ format_member = TAR_POSIX1988_FORMAT;
- }
- } else if ( (0 == memcmp(tar->filler + 8, "tar", 4))
- && (0 == tar_isnonzero(tar->filler, 8)) ) {
+ }
+ }
+ else if ((0 == memcmp (tar->filler + 8, "tar", 4))
+ && (0 == tar_isnonzero (tar->filler, 8)))
+ {
- format_member = TAR_SCHILLING1985_FORMAT;
+ format_member = TAR_SCHILLING1985_FORMAT;
- } else if ( ('0' <= typeFlag) && (typeFlag <= '2') ) {
+ }
+ else if (('0' <= typeFlag) && (typeFlag <= '2'))
+ {
- format_member = TAR_V7ORIGINAL_FORMAT;
+ format_member = TAR_V7ORIGINAL_FORMAT;
- } else {
+ }
+ else
+ {
- format_member = TAR_V7EXTENDED_FORMAT;
+ format_member = TAR_V7EXTENDED_FORMAT;
- }
+ }
- /*
- * Locate the file names.
- */
- if ( (0 != (format_member & TAR_POSIX2001_FORMAT))
- && (('x' == typeFlag) || ('X' == typeFlag)) ) {
+ /*
+ * Locate the file names.
+ */
+ if ((0 != (format_member & TAR_POSIX2001_FORMAT))
+ && (('x' == typeFlag) || ('X' == typeFlag)))
+ {
- if(size <= pos)
- break;
+ if (size <= pos)
+ break;
- else if ( (8 <= fsize) && fsize <= (unsigned long long) (size - pos)) {
- const char *keyptr = data + pos;
- const char *valptr = NULL;
- const char *nameptr = NULL;
- unsigned int keylength = 0;
- unsigned int namelength = 0;
+ else if ((8 <= fsize) && fsize <= (unsigned long long) (size - pos))
+ {
+ const char *keyptr = data + pos;
+ const char *valptr = NULL;
+ const char *nameptr = NULL;
+ unsigned int keylength = 0;
+ unsigned int namelength = 0;
- while (keyptr < data + pos + (size_t) fsize) {
- if( ('0' > *keyptr) || ('9' < *keyptr) ) {
- keyptr += 1;
- continue;
- }
+ while (keyptr < data + pos + (size_t) fsize)
+ {
+ if (('0' > *keyptr) || ('9' < *keyptr))
+ {
+ keyptr += 1;
+ continue;
+ }
- keylength = (unsigned int) strtoul(keyptr, (char **) &valptr, 10);
- if( (0 < keylength) && (NULL != valptr) && (keyptr != valptr) ) {
- unsigned int difflength = 0;
+ keylength =
+ (unsigned int) strtoul (keyptr, (char **) &valptr, 10);
+ if ((0 < keylength) && (NULL != valptr)
+ && (keyptr != valptr))
+ {
+ unsigned int difflength = 0;
- while( (valptr < data + pos + (size_t) fsize)
- && (' ' == *valptr) )
- valptr += 1;
+ while ((valptr < data + pos + (size_t) fsize)
+ && (' ' == *valptr))
+ valptr += 1;
- difflength = (valptr - keyptr);
+ difflength = (valptr - keyptr);
- if (0 == memcmp(valptr, "path=", 5)) {
- nameptr = valptr + 5;
- namelength = keylength - (nameptr - keyptr);
- } else {
+ if (0 == memcmp (valptr, "path=", 5))
+ {
+ nameptr = valptr + 5;
+ namelength = keylength - (nameptr - keyptr);
+ }
+ else
+ {
- if( (keylength > (valptr - keyptr) + 4 + 2)
- && (0 == memcmp(valptr, "GNU.", 4)) )
- format_archive |= TAR_GNU2004_FORMAT;
+ if ((keylength > (valptr - keyptr) + 4 + 2)
+ && (0 == memcmp (valptr, "GNU.", 4)))
+ format_archive |= TAR_GNU2004_FORMAT;
- else if( (keylength > (valptr - keyptr) + 7 + 2)
- && (0 == memcmp(valptr, "SCHILY.", 7)) )
- format_archive |= TAR_SCHILLING2001_FORMAT;
+ else if ((keylength > (valptr - keyptr) + 7 + 2)
+ && (0 == memcmp (valptr, "SCHILY.", 7)))
+ format_archive |= TAR_SCHILLING2001_FORMAT;
- else if( (keylength > (valptr - keyptr) + 4 + 2)
- && (0 == memcmp(valptr, "SUN.", 4)) )
- format_archive |= TAR_SOLARIS2001_FORMAT;
- }
+ else if ((keylength > (valptr - keyptr) + 4 + 2)
+ && (0 == memcmp (valptr, "SUN.", 4)))
+ format_archive |= TAR_SOLARIS2001_FORMAT;
+ }
- keyptr += keylength;
- } else {
- nameptr = NULL;
- break;
- }
- }
+ keyptr += keylength;
+ }
+ else
+ {
+ nameptr = NULL;
+ break;
+ }
+ }
- if ( (NULL != nameptr) && (0 != *nameptr)
- && ((size - (nameptr - data)) >= namelength) && (1 < namelength) ) {
- if (NULL != fname)
- free(fname);
- /*
- * There is an 1-offset because POSIX.1-2001
- * field separator is counted in field length.
- */
- fname = malloc(namelength);
- if (NULL != fname) {
- memcpy(fname, nameptr, namelength-1);
- fname[namelength-1] = '\0';
+ if ((NULL != nameptr) && (0 != *nameptr)
+ && ((size - (nameptr - data)) >= namelength)
+ && (1 < namelength))
+ {
+ if (NULL != fname)
+ free (fname);
+ /*
+ * There is an 1-offset because POSIX.1-2001
+ * field separator is counted in field length.
+ */
+ fname = malloc (namelength);
+ if (NULL != fname)
+ {
+ memcpy (fname, nameptr, namelength - 1);
+ fname[namelength - 1] = '\0';
- pos += tar_roundup((size_t) fsize);
- format_archive |= format_member;
- continue;
- }
+ pos += tar_roundup ((size_t) fsize);
+ format_archive |= format_member;
+ continue;
+ }
+ }
+ }
}
- }
- }
- else if ( (0 != (format_member
- & (TAR_SCHILLING1994_FORMAT
- |TAR_GNU1997_FORMAT|TAR_GNU2004_FORMAT)))
- && ('L' == typeFlag) ) {
+ else if ((0 != (format_member
+ & (TAR_SCHILLING1994_FORMAT
+ | TAR_GNU1997_FORMAT | TAR_GNU2004_FORMAT)))
+ && ('L' == typeFlag))
+ {
- if(size <= pos)
- break;
+ if (size <= pos)
+ break;
- else if ( (0 < fsize) && fsize <= (unsigned long long) (size - pos)) {
+ else if ((0 < fsize) && fsize <= (unsigned long long) (size - pos))
+ {
- size_t length = (size_t) fsize;
+ size_t length = (size_t) fsize;
- nul_pos = memchr(data + pos, 0, length);
- if (NULL != nul_pos)
- length = (nul_pos - (data + pos));
+ nul_pos = memchr (data + pos, 0, length);
+ if (NULL != nul_pos)
+ length = (nul_pos - (data + pos));
- if (0 < length) {
- if (NULL != fname)
- free(fname);
- fname = malloc(1 + length);
- if (NULL != fname) {
- memcpy(fname, data + pos, length);
- fname[length] = '\0';
- }
+ if (0 < length)
+ {
+ if (NULL != fname)
+ free (fname);
+ fname = malloc (1 + length);
+ if (NULL != fname)
+ {
+ memcpy (fname, data + pos, length);
+ fname[length] = '\0';
+ }
- pos += tar_roundup((size_t) fsize);
- format_archive |= format_member;
- continue;
+ pos += tar_roundup ((size_t) fsize);
+ format_archive |= format_member;
+ continue;
+ }
+ }
}
- }
- } else {
+ else
+ {
- nul_pos = memchr(tar->fileName, 0, sizeof tar->fileName);
- tar_name_length = (0 == nul_pos)
- ? sizeof(tar->fileName) : (nul_pos - tar->fileName);
+ nul_pos = memchr (tar->fileName, 0, sizeof tar->fileName);
+ tar_name_length = (0 == nul_pos)
+ ? sizeof (tar->fileName) : (nul_pos - tar->fileName);
- if ( (0 != (format_member & (TAR_GNU1997_FORMAT|TAR_GNU2004_FORMAT)))
- && ('S' == typeFlag) ) {
+ if ((0 !=
+ (format_member & (TAR_GNU1997_FORMAT | TAR_GNU2004_FORMAT)))
+ && ('S' == typeFlag))
+ {
- if( (0 == tar->prefix[40])
- && (0 != tar->prefix[137])
- && (12 <= tar_octalvalue(tar->prefix + 41, 12, NULL))
- && (12 <= tar_octalvalue(tar->prefix + 53, 12, NULL)) ) {
- /*
- * fsize needs adjustment when there are more than 4 sparse blocks
- */
- size_t diffpos = 0;
- fsize += TAR_HEADER_SIZE;
+ if ((0 == tar->prefix[40])
+ && (0 != tar->prefix[137])
+ && (12 <= tar_octalvalue (tar->prefix + 41, 12, NULL))
+ && (12 <= tar_octalvalue (tar->prefix + 53, 12, NULL)))
+ {
+ /*
+ * fsize needs adjustment when there are more than 4 sparse
blocks
+ */
+ size_t diffpos = 0;
+ fsize += TAR_HEADER_SIZE;
- while ( (pos + diffpos + TAR_HEADER_SIZE < size)
- && (0 != *(data + pos + diffpos + 504)) ) {
- diffpos += TAR_HEADER_SIZE;
- fsize += TAR_HEADER_SIZE;
- }
- }
+ while ((pos + diffpos + TAR_HEADER_SIZE < size)
+ && (0 != *(data + pos + diffpos + 504)))
+ {
+ diffpos += TAR_HEADER_SIZE;
+ fsize += TAR_HEADER_SIZE;
+ }
+ }
- typeFlag = '0';
+ typeFlag = '0';
- } else if(0 != (format_member & TAR_SCHILLING1994_FORMAT) ) {
+ }
+ else if (0 != (format_member & TAR_SCHILLING1994_FORMAT))
+ {
- nul_pos = memchr(tar->prefix, 0, 130);
- tar_prefix_length = (0 == nul_pos)
- ? 130
- : (nul_pos - tar->prefix);
+ nul_pos = memchr (tar->prefix, 0, 130);
+ tar_prefix_length = (0 == nul_pos)
+ ? 130 : (nul_pos - tar->prefix);
- if ('S' == typeFlag)
- typeFlag = '0';
+ if ('S' == typeFlag)
+ typeFlag = '0';
- } else if(0 != (format_member & TAR_SCHILLING1985_FORMAT) ) {
+ }
+ else if (0 != (format_member & TAR_SCHILLING1985_FORMAT))
+ {
- nul_pos = memchr(tar->prefix, 0, 155);
- tar_prefix_length = (0 == nul_pos)
- ? 155
- : (nul_pos - tar->prefix);
+ nul_pos = memchr (tar->prefix, 0, 155);
+ tar_prefix_length = (0 == nul_pos)
+ ? 155 : (nul_pos - tar->prefix);
- if ('S' == typeFlag)
- typeFlag = '0';
+ if ('S' == typeFlag)
+ typeFlag = '0';
- } else if (0 != (format_member & TAR_POSIX1988_FORMAT) ) {
+ }
+ else if (0 != (format_member & TAR_POSIX1988_FORMAT))
+ {
- nul_pos = memchr(tar->prefix, 0, sizeof tar->prefix);
- tar_prefix_length = (0 == nul_pos)
- ? sizeof tar->prefix
- : nul_pos - tar->prefix;
+ nul_pos = memchr (tar->prefix, 0, sizeof tar->prefix);
+ tar_prefix_length = (0 == nul_pos)
+ ? sizeof tar->prefix : nul_pos - tar->prefix;
- }
- }
+ }
+ }
- /*
- * Update position so that next loop iteration will find
- * either a TAR header or TAR EOF mark or just EOF.
- *
- * Consider archive member size to be zero
- * with no data following the header in the following cases :
- * '1' : hard link, '2' : soft link,
- * '3' : character device, '4' : block device,
- * '5' : directory, '6' : named pipe.
- */
- if('1' != typeFlag && '2' != typeFlag
- && '3' != typeFlag && '4' != typeFlag
- && '5' != typeFlag && '6' != typeFlag) {
- if ( (fsize > (unsigned long long) size)
- || (fsize + (unsigned long long) pos > (unsigned long long) size) )
+ /*
+ * Update position so that next loop iteration will find
+ * either a TAR header or TAR EOF mark or just EOF.
+ *
+ * Consider archive member size to be zero
+ * with no data following the header in the following cases :
+ * '1' : hard link, '2' : soft link,
+ * '3' : character device, '4' : block device,
+ * '5' : directory, '6' : named pipe.
+ */
+ if ('1' != typeFlag && '2' != typeFlag
+ && '3' != typeFlag && '4' != typeFlag
+ && '5' != typeFlag && '6' != typeFlag)
+ {
+ if ((fsize > (unsigned long long) size)
+ || (fsize + (unsigned long long) pos >
+ (unsigned long long) size))
+ break;
+
+ pos += tar_roundup ((size_t) fsize);
+ }
+ if (pos - 1 > size)
break;
- pos += tar_roundup((size_t) fsize);
- }
- if(pos - 1 > size)
- break;
+ format_archive |= format_member;
- format_archive |= format_member;
+ /*
+ * Store the file name in libextractor list.
+ *
+ * For the time being, only file types listed in POSIX.1-1988 ('0'..'7')
+ * are retained, leaving out labels, access control lists, etc.
+ */
+ if ((0 == typeFlag) || (('0' <= typeFlag) && (typeFlag <= '7')))
+ {
+ if (NULL == fname)
+ {
+ if (0 < tar_prefix_length + tar_name_length)
+ {
+ fname = malloc (2 + tar_prefix_length + tar_name_length);
- /*
- * Store the file name in libextractor list.
- *
- * For the time being, only file types listed in POSIX.1-1988 ('0'..'7')
- * are retained, leaving out labels, access control lists, etc.
- */
- if ( (0 == typeFlag) || (('0' <= typeFlag) && (typeFlag <= '7')) ) {
- if (NULL == fname) {
- if (0 < tar_prefix_length + tar_name_length) {
- fname = malloc(2 + tar_prefix_length + tar_name_length);
+ if (NULL != fname)
+ {
+ if (0 < tar_prefix_length)
+ {
+ memcpy (fname, tar->prefix, tar_prefix_length);
- if (NULL != fname) {
- if (0 < tar_prefix_length) {
- memcpy(fname, tar->prefix, tar_prefix_length);
+ if (('/' != tar->prefix[tar_prefix_length - 1])
+ && (0 < tar_name_length)
+ && ('/' != tar->fileName[0]))
+ {
+ fname[tar_prefix_length] = '/';
+ tar_prefix_length += 1;
+ }
+ }
- if ( ('/' != tar->prefix[tar_prefix_length - 1])
- && (0 < tar_name_length)
- && ('/' != tar->fileName[0]) ) {
- fname[tar_prefix_length] = '/';
- tar_prefix_length += 1;
- }
+ if (0 < tar_name_length)
+ memcpy (fname + tar_prefix_length, tar->fileName,
+ tar_name_length);
+
+ fname[tar_prefix_length + tar_name_length] = '\0';
+ }
+ }
}
- if (0 < tar_name_length)
- memcpy(fname + tar_prefix_length, tar->fileName,
tar_name_length);
+ if ((NULL != fname) && (0 != *fname))
+ {
+#if 0
+ fprintf (stdout,
+ "(%u) flag = %c, size = %u, tname = (%s), fname =
(%s)\n",
+ __LINE__, typeFlag, (unsigned int) fsize,
+ (NULL == tar->fileName) ? "" : tar->fileName,
+ (NULL == fname) ? "" : fname);
+#endif
- fname[tar_prefix_length + tar_name_length]= '\0';
- }
+ last = appendKeyword (EXTRACTOR_FILENAME, fname, last);
+ fname = NULL;
+ if (prev == NULL)
+ prev = last;
+ if (ftime > maxftime)
+ maxftime = ftime;
+ contents_are_empty = 0;
+ }
}
- }
- if ( (NULL != fname) && (0 != *fname) ) {
-#if 0
- fprintf(stdout,
- "(%u) flag = %c, size = %u, tname = (%s), fname = (%s)\n",
- __LINE__, typeFlag, (unsigned int) fsize,
- (NULL == tar->fileName) ? "" : tar->fileName,
- (NULL == fname) ? "" : fname);
-#endif
-
- last = appendKeyword(EXTRACTOR_FILENAME, fname, last);
- fname = NULL;
- if (prev == NULL)
- prev = last;
- if (ftime > maxftime)
- maxftime = ftime;
- contents_are_empty = 0;
- }
+ if (NULL != fname)
+ {
+ free (fname);
+ fname = NULL;
+ }
}
- if(NULL != fname) {
- free(fname);
+ if (NULL != fname)
+ {
+ free (fname);
fname = NULL;
}
- }
- if(NULL != fname) {
- free(fname);
- fname = NULL;
- }
-
/*
* Report mimetype; report also format(s) and most recent date
* when at least one archive member was found.
*/
- if (0 != format_archive) {
- if (0 == contents_are_empty) {
+ if (0 != format_archive)
+ {
+ if (0 == contents_are_empty)
+ {
- const char *formats[5] = {NULL, NULL, NULL, NULL, NULL};
- unsigned int formats_count = 0;
- unsigned int formats_u = 0;
- unsigned int format_length = 0;
- char *format = NULL;
+ const char *formats[5] = { NULL, NULL, NULL, NULL, NULL };
+ unsigned int formats_count = 0;
+ unsigned int formats_u = 0;
+ unsigned int format_length = 0;
+ char *format = NULL;
- if(TAR_TIME_FENCE < maxftime) {
- char iso8601_time[24];
+ if (TAR_TIME_FENCE < maxftime)
+ {
+ char iso8601_time[24];
- if(0 == tar_time(maxftime, iso8601_time, sizeof iso8601_time))
- prev = addKeyword(EXTRACTOR_DATE, strdup(iso8601_time), prev);
- }
+ if (0 == tar_time (maxftime, iso8601_time, sizeof iso8601_time))
+ prev =
+ addKeyword (EXTRACTOR_DATE, strdup (iso8601_time), prev);
+ }
- /*
- * We only keep the most recent POSIX format.
- */
- if (0 != (format_archive & TAR_POSIX2001_FORMAT))
- formats[formats_count++] = "POSIX 2001";
+ /*
+ * We only keep the most recent POSIX format.
+ */
+ if (0 != (format_archive & TAR_POSIX2001_FORMAT))
+ formats[formats_count++] = "POSIX 2001";
- else if (0 != (format_archive & TAR_POSIX1988_FORMAT))
- formats[formats_count++] = "POSIX 1988";
+ else if (0 != (format_archive & TAR_POSIX1988_FORMAT))
+ formats[formats_count++] = "POSIX 1988";
- /*
- * We only keep the most recent GNU format.
- */
- if (0 != (format_archive & TAR_GNU2004_FORMAT))
- formats[formats_count++] = "GNU 2004";
+ /*
+ * We only keep the most recent GNU format.
+ */
+ if (0 != (format_archive & TAR_GNU2004_FORMAT))
+ formats[formats_count++] = "GNU 2004";
- else if (0 != (format_archive & TAR_GNU1997_FORMAT))
- formats[formats_count++] = "GNU 1997";
+ else if (0 != (format_archive & TAR_GNU1997_FORMAT))
+ formats[formats_count++] = "GNU 1997";
- else if (0 != (format_archive & TAR_GNU1991_FORMAT))
- formats[formats_count++] = "GNU 1991";
+ else if (0 != (format_archive & TAR_GNU1991_FORMAT))
+ formats[formats_count++] = "GNU 1991";
- /*
- * We only keep the most recent Schilling format.
- */
- if (0 != (format_archive & TAR_SCHILLING2001_FORMAT))
- formats[formats_count++] = "Schilling 2001";
+ /*
+ * We only keep the most recent Schilling format.
+ */
+ if (0 != (format_archive & TAR_SCHILLING2001_FORMAT))
+ formats[formats_count++] = "Schilling 2001";
- else if (0 != (format_archive & TAR_SCHILLING1994_FORMAT))
- formats[formats_count++] = "Schilling 1994";
+ else if (0 != (format_archive & TAR_SCHILLING1994_FORMAT))
+ formats[formats_count++] = "Schilling 1994";
- else if (0 != (format_archive & TAR_SCHILLING1985_FORMAT))
- formats[formats_count++] = "Schilling 1985";
+ else if (0 != (format_archive & TAR_SCHILLING1985_FORMAT))
+ formats[formats_count++] = "Schilling 1985";
- /*
- * We only keep the most recent Solaris format.
- */
- if (0 != (format_archive & TAR_SOLARIS2001_FORMAT))
- formats[formats_count++] = "Solaris 2001";
+ /*
+ * We only keep the most recent Solaris format.
+ */
+ if (0 != (format_archive & TAR_SOLARIS2001_FORMAT))
+ formats[formats_count++] = "Solaris 2001";
- /*
- * We only keep the (supposedly) most recent UNIX V7 format.
- */
- if (0 != (format_archive & TAR_V7EXTENDED_FORMAT))
- formats[formats_count++] = "UNIX extended V7";
+ /*
+ * We only keep the (supposedly) most recent UNIX V7 format.
+ */
+ if (0 != (format_archive & TAR_V7EXTENDED_FORMAT))
+ formats[formats_count++] = "UNIX extended V7";
- else if (0 != (format_archive & TAR_V7ORIGINAL_FORMAT))
- formats[formats_count++] = "UNIX original V7";
+ else if (0 != (format_archive & TAR_V7ORIGINAL_FORMAT))
+ formats[formats_count++] = "UNIX original V7";
- /*
- * Build the format string
- */
- for(formats_u = 0; formats_u < formats_count; formats_u += 1) {
- if( (NULL != formats[formats_u]) && (0 != *formats[formats_u]) ) {
+ /*
+ * Build the format string
+ */
+ for (formats_u = 0; formats_u < formats_count; formats_u += 1)
+ {
+ if ((NULL != formats[formats_u]) && (0 != *formats[formats_u]))
+ {
+ if (0 < format_length)
+ format_length += 3;
+ format_length += strlen (formats[formats_u]);
+ }
+ }
+
if (0 < format_length)
- format_length += 3;
- format_length += strlen(formats[formats_u]);
- }
- }
+ {
+ format = malloc (format_length + 5);
- if(0 < format_length)
- {
- format = malloc(format_length + 5);
+ if (NULL != format)
+ {
- if (NULL != format) {
+ format_length = 0;
- format_length = 0;
+ for (formats_u = 0; formats_u < formats_count;
+ formats_u += 1)
+ {
+ if ((NULL != formats[formats_u])
+ && (0 != *formats[formats_u]))
+ {
+ if (0 < format_length)
+ {
+ strcpy (format + format_length, " + ");
+ format_length += 3;
+ }
+ strcpy (format + format_length, formats[formats_u]);
+ format_length += strlen (formats[formats_u]);
+ }
+ }
- for(formats_u = 0; formats_u < formats_count; formats_u += 1) {
- if( (NULL != formats[formats_u]) && (0 != *formats[formats_u]) ) {
- if (0 < format_length) {
- strcpy(format + format_length, " + ");
- format_length += 3;
- }
- strcpy(format + format_length, formats[formats_u]);
- format_length += strlen(formats[formats_u]);
+ if (0 < format_length)
+ {
+ strcpy (format + format_length, " TAR");
+ prev = addKeyword (EXTRACTOR_FORMAT, format, prev);
+ }
+ else
+ {
+ free (format);
+ }
+ }
}
- }
+ }
- if (0 < format_length) {
- strcpy(format + format_length, " TAR");
- prev = addKeyword(EXTRACTOR_FORMAT, format, prev);
- } else {
- free(format);
- }
- }
- }
+ prev =
+ addKeyword (EXTRACTOR_MIMETYPE, strdup ("application/x-tar"), prev);
}
- prev = addKeyword(EXTRACTOR_MIMETYPE, strdup("application/x-tar"), prev);
- }
-
return prev;
}
Modified: Extractor/src/plugins/templateextractor.c
===================================================================
--- Extractor/src/plugins/templateextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/templateextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -21,25 +21,26 @@
#include "platform.h"
#include "extractor.h"
-static EXTRACTOR_KeywordList * addKeyword(EXTRACTOR_KeywordType type,
- char * keyword,
- EXTRACTOR_KeywordList * next) {
- EXTRACTOR_KeywordList * result;
+static EXTRACTOR_KeywordList *
+addKeyword (EXTRACTOR_KeywordType type,
+ char *keyword, EXTRACTOR_KeywordList * next)
+{
+ EXTRACTOR_KeywordList *result;
if (keyword == NULL)
return next;
- result = malloc(sizeof(EXTRACTOR_KeywordList));
+ result = malloc (sizeof (EXTRACTOR_KeywordList));
result->next = next;
result->keyword = keyword;
result->keywordType = type;
return result;
}
-struct EXTRACTOR_Keywords * libextractor_TEMPLATE_extract(const char *
filename,
- char * data,
- size_t size,
- struct
EXTRACTOR_Keywords * prev) {
+struct EXTRACTOR_Keywords *
+libextractor_TEMPLATE_extract (const char *filename,
+ char *data,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
return prev;
}
-
Modified: Extractor/src/plugins/thumbnail/thumbnailextractor.c
===================================================================
--- Extractor/src/plugins/thumbnail/thumbnailextractor.c 2007-07-29
08:04:12 UTC (rev 5367)
+++ Extractor/src/plugins/thumbnail/thumbnailextractor.c 2007-07-29
08:35:49 UTC (rev 5368)
@@ -35,19 +35,21 @@
/* using libgobject, needs init! */
-void __attribute__ ((constructor)) ole_gobject_init(void) {
- g_type_init();
+void __attribute__ ((constructor)) ole_gobject_init (void)
+{
+ g_type_init ();
}
-static EXTRACTOR_KeywordList * addKeyword(EXTRACTOR_KeywordType type,
- char * keyword,
- EXTRACTOR_KeywordList * next) {
- EXTRACTOR_KeywordList * result;
+static EXTRACTOR_KeywordList *
+addKeyword (EXTRACTOR_KeywordType type,
+ char *keyword, EXTRACTOR_KeywordList * next)
+{
+ EXTRACTOR_KeywordList *result;
if (keyword == NULL)
return next;
- result = malloc(sizeof(EXTRACTOR_KeywordList));
+ result = malloc (sizeof (EXTRACTOR_KeywordList));
result->next = next;
result->keyword = keyword;
result->keywordType = type;
@@ -60,7 +62,7 @@
crashes and/or prints errors for bad
formats, so we need to be rather
conservative here) */
-static char * whitelist[] = {
+static char *whitelist[] = {
"image/jpeg",
"image/gif",
"image/miff",
@@ -76,120 +78,100 @@
};
struct EXTRACTOR_Keywords *
-libextractor_thumbnailgtk_extract(const char * filename,
- const unsigned char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev) {
- GdkPixbufLoader * loader;
- GdkPixbuf * in;
- GdkPixbuf * out;
+libextractor_thumbnailgtk_extract (const char *filename,
+ const unsigned char *data,
+ size_t size,
+ struct EXTRACTOR_Keywords *prev)
+{
+ GdkPixbufLoader *loader;
+ GdkPixbuf *in;
+ GdkPixbuf *out;
size_t length;
- char * thumb;
+ char *thumb;
unsigned long width;
unsigned long height;
- char * binary;
- const char * mime;
+ char *binary;
+ const char *mime;
int j;
- char * format;
+ char *format;
/* if the mime-type of the file is not whitelisted
do not run the thumbnail extactor! */
- mime = EXTRACTOR_extractLast(EXTRACTOR_MIMETYPE,
- prev);
+ mime = EXTRACTOR_extractLast (EXTRACTOR_MIMETYPE, prev);
if (mime == NULL)
return prev;
j = 0;
- while (whitelist[j] != NULL) {
- if (0 == strcmp(whitelist[j], mime))
- break;
- j++;
- }
+ while (whitelist[j] != NULL)
+ {
+ if (0 == strcmp (whitelist[j], mime))
+ break;
+ j++;
+ }
if (whitelist[j] == NULL)
return prev;
- loader = gdk_pixbuf_loader_new();
- gdk_pixbuf_loader_write(loader,
- data,
- size,
- NULL);
- in = gdk_pixbuf_loader_get_pixbuf(loader);
- gdk_pixbuf_loader_close(loader,
- NULL);
- if (in == NULL) {
- g_object_unref(loader);
- return prev;
- }
- g_object_ref(in);
- g_object_unref(loader);
- height = gdk_pixbuf_get_height(in);
- width = gdk_pixbuf_get_width(in);
- format = malloc(64);
- snprintf(format,
- 64,
- "%ux%u",
- (unsigned int) width,
- (unsigned int) height);
- prev
- = addKeyword(EXTRACTOR_SIZE,
- format,
- prev);
+ loader = gdk_pixbuf_loader_new ();
+ gdk_pixbuf_loader_write (loader, data, size, NULL);
+ in = gdk_pixbuf_loader_get_pixbuf (loader);
+ gdk_pixbuf_loader_close (loader, NULL);
+ if (in == NULL)
+ {
+ g_object_unref (loader);
+ return prev;
+ }
+ g_object_ref (in);
+ g_object_unref (loader);
+ height = gdk_pixbuf_get_height (in);
+ width = gdk_pixbuf_get_width (in);
+ format = malloc (64);
+ snprintf (format, 64, "%ux%u", (unsigned int) width, (unsigned int) height);
+ prev = addKeyword (EXTRACTOR_SIZE, format, prev);
if (height == 0)
height = 1;
if (width == 0)
width = 1;
- if ( (height <= THUMBSIZE) &&
- (width <= THUMBSIZE) ) {
- g_object_unref(in);
- return prev;
- }
- if (height > THUMBSIZE) {
- width = width * THUMBSIZE / height;
- height = THUMBSIZE;
- }
- if (width > THUMBSIZE) {
- height = height * THUMBSIZE / width;
- width = THUMBSIZE;
- }
- out = gdk_pixbuf_scale_simple(in,
- width,
- height,
- GDK_INTERP_BILINEAR);
- g_object_unref(in);
+ if ((height <= THUMBSIZE) && (width <= THUMBSIZE))
+ {
+ g_object_unref (in);
+ return prev;
+ }
+ if (height > THUMBSIZE)
+ {
+ width = width * THUMBSIZE / height;
+ height = THUMBSIZE;
+ }
+ if (width > THUMBSIZE)
+ {
+ height = height * THUMBSIZE / width;
+ width = THUMBSIZE;
+ }
+ out = gdk_pixbuf_scale_simple (in, width, height, GDK_INTERP_BILINEAR);
+ g_object_unref (in);
thumb = NULL;
- if (! gdk_pixbuf_save_to_buffer(out,
- &thumb,
- &length,
- "png",
- NULL,
- NULL)) {
- g_object_unref(out);
- return prev;
- }
- g_object_unref(out);
+ if (!gdk_pixbuf_save_to_buffer (out, &thumb, &length, "png", NULL, NULL))
+ {
+ g_object_unref (out);
+ return prev;
+ }
+ g_object_unref (out);
if (thumb == NULL)
return prev;
- binary
- = EXTRACTOR_binaryEncode((const unsigned char*) thumb,
- length);
- free(thumb);
+ binary = EXTRACTOR_binaryEncode ((const unsigned char *) thumb, length);
+ free (thumb);
if (binary == NULL)
return prev;
- return addKeyword(EXTRACTOR_THUMBNAIL_DATA,
- binary,
- prev);
+ return addKeyword (EXTRACTOR_THUMBNAIL_DATA, binary, prev);
}
-struct EXTRACTOR_Keywords *
-libextractor_thumbnail_extract(const char * filename,
- const unsigned char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev,
- const char * options) {
- return libextractor_thumbnailgtk_extract(filename,
- data,
- size,
- prev);
+struct EXTRACTOR_Keywords *
+libextractor_thumbnail_extract (const char *filename,
+ const unsigned char *data,
+ size_t size,
+ struct EXTRACTOR_Keywords *prev,
+ const char *options)
+{
+ return libextractor_thumbnailgtk_extract (filename, data, size, prev);
}
/* end of thumbnailextractor.c */
Modified: Extractor/src/plugins/tiffextractor.c
===================================================================
--- Extractor/src/plugins/tiffextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/tiffextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -24,18 +24,20 @@
#define DEBUG 0
-static void addKeyword(struct EXTRACTOR_Keywords ** list,
- char * keyword,
- EXTRACTOR_KeywordType type) {
- EXTRACTOR_KeywordList * next;
- next = malloc(sizeof(EXTRACTOR_KeywordList));
+static void
+addKeyword (struct EXTRACTOR_Keywords **list,
+ char *keyword, EXTRACTOR_KeywordType type)
+{
+ EXTRACTOR_KeywordList *next;
+ next = malloc (sizeof (EXTRACTOR_KeywordList));
next->next = *list;
next->keyword = keyword;
next->keywordType = type;
*list = next;
}
-typedef struct {
+typedef struct
+{
unsigned short byteorder;
unsigned short fourty_two;
unsigned int ifd_offset;
@@ -45,12 +47,13 @@
&(p)->byteorder, \
&(p)->fourty_two, \
&(p)->ifd_offset
-static char * TIFF_HEADER_SPECS[] = {
+static char *TIFF_HEADER_SPECS[] = {
"hhw",
"HHW",
};
-typedef struct {
+typedef struct
+{
unsigned short tag;
unsigned short type;
unsigned int count;
@@ -62,7 +65,7 @@
&(p)->type, \
&(p)->count, \
&(p)->value_or_offset
-static char * DIRECTORY_ENTRY_SPECS[] = {
+static char *DIRECTORY_ENTRY_SPECS[] = {
"hhww",
"HHWW"
};
@@ -85,178 +88,154 @@
#define TYPE_LONG 4
#define TYPE_RATIONAL 5
-static void addASCII(struct EXTRACTOR_Keywords ** prev,
- char * data,
- size_t size,
- DIRECTORY_ENTRY * entry,
- EXTRACTOR_KeywordType type) {
+static void
+addASCII (struct EXTRACTOR_Keywords **prev,
+ char *data,
+ size_t size, DIRECTORY_ENTRY * entry, EXTRACTOR_KeywordType type)
+{
if (entry->count > size)
- return; /* invalid! */
+ return; /* invalid! */
if (entry->type != TYPE_ASCII)
- return; /* huh? */
- if (entry->count+entry->value_or_offset > size)
+ return; /* huh? */
+ if (entry->count + entry->value_or_offset > size)
return;
- if (data[entry->value_or_offset+entry->count-1] != 0)
+ if (data[entry->value_or_offset + entry->count - 1] != 0)
return;
- addKeyword(prev,
- strdup(&data[entry->value_or_offset]),
- EXTRACTOR_SOFTWARE);
+ addKeyword (prev,
+ strdup (&data[entry->value_or_offset]), EXTRACTOR_SOFTWARE);
}
-struct EXTRACTOR_Keywords * libextractor_tiff_extract(char * filename,
- char * data,
- size_t size,
- struct EXTRACTOR_Keywords
* prev) {
+struct EXTRACTOR_Keywords *
+libextractor_tiff_extract (char *filename,
+ char *data,
+ size_t size, struct EXTRACTOR_Keywords *prev)
+{
TIFF_HEADER hdr;
- int byteOrder; /* 0: do not convert;
- 1: do convert */
+ int byteOrder; /* 0: do not convert;
+ 1: do convert */
int current_ifd;
long long length = -1;
long long width = -1;
if (size < TIFF_HEADER_SIZE)
- return prev; /* can not be tiff */
- if ( (data[0] == 0x49) &&
- (data[1] == 0x49) )
+ return prev; /* can not be tiff */
+ if ((data[0] == 0x49) && (data[1] == 0x49))
byteOrder = 0;
- else if ( (data[0] == 0x4D) &&
- (data[1] == 0x4D) )
+ else if ((data[0] == 0x4D) && (data[1] == 0x4D))
byteOrder = 1;
else
- return prev; /* can not be tiff */
+ return prev; /* can not be tiff */
#if __BYTE_ORDER == __BIG_ENDIAN
- byteOrder = 1-byteOrder;
+ byteOrder = 1 - byteOrder;
#endif
- cat_unpack(data,
- TIFF_HEADER_SPECS[byteOrder],
- TIFF_HEADER_FIELDS(&hdr));
+ cat_unpack (data, TIFF_HEADER_SPECS[byteOrder], TIFF_HEADER_FIELDS (&hdr));
if (hdr.fourty_two != 42)
- return prev; /* can not be tiff */
+ return prev; /* can not be tiff */
if (hdr.ifd_offset + 6 > size)
- return prev; /* malformed tiff */
- addKeyword(&prev,
- strdup("image/tiff"),
- EXTRACTOR_MIMETYPE);
+ return prev; /* malformed tiff */
+ addKeyword (&prev, strdup ("image/tiff"), EXTRACTOR_MIMETYPE);
current_ifd = hdr.ifd_offset;
- while (current_ifd != 0) {
- unsigned short len;
- unsigned int off;
- int i;
- if (current_ifd + 6 > size)
- return prev;
- if (byteOrder == 0)
- len = data[current_ifd+1] << 8 | data[current_ifd];
- else
- len = data[current_ifd] << 8 | data[current_ifd+1];
- if (len * DIRECTORY_ENTRY_SIZE + 2 + 4 > size) {
+ while (current_ifd != 0)
+ {
+ unsigned short len;
+ unsigned int off;
+ int i;
+ if (current_ifd + 6 > size)
+ return prev;
+ if (byteOrder == 0)
+ len = data[current_ifd + 1] << 8 | data[current_ifd];
+ else
+ len = data[current_ifd] << 8 | data[current_ifd + 1];
+ if (len * DIRECTORY_ENTRY_SIZE + 2 + 4 > size)
+ {
#if DEBUG
- printf("WARNING: malformed tiff\n");
+ printf ("WARNING: malformed tiff\n");
#endif
- return prev;
- }
- for (i=0;i<len;i++) {
- DIRECTORY_ENTRY entry;
- off = current_ifd + 2 + DIRECTORY_ENTRY_SIZE*i;
+ return prev;
+ }
+ for (i = 0; i < len; i++)
+ {
+ DIRECTORY_ENTRY entry;
+ off = current_ifd + 2 + DIRECTORY_ENTRY_SIZE * i;
- cat_unpack(&data[off],
- DIRECTORY_ENTRY_SPECS[byteOrder],
- DIRECTORY_ENTRY_FIELDS(&entry));
- switch (entry.tag) {
- case TAG_LENGTH:
- if ( (entry.type == TYPE_SHORT) &&
- (byteOrder == 1) ) {
- length = entry.value_or_offset >> 16;
- } else {
- length = entry.value_or_offset;
- }
- if (width != -1) {
- char * tmp;
- tmp = malloc(128);
- sprintf(tmp, "%ux%u",
- (unsigned int) width,
- (unsigned int) length);
- addKeyword(&prev,
- strdup(tmp),
- EXTRACTOR_SIZE);
- free(tmp);
- }
- break;
- case TAG_WIDTH:
- if ( (entry.type == TYPE_SHORT) &&
- (byteOrder == 1) )
- width = entry.value_or_offset >> 16;
- else
- width = entry.value_or_offset;
- if (length != -1) {
- char * tmp;
- tmp = malloc(128);
- sprintf(tmp, "%ux%u",
- (unsigned int) width,
- (unsigned int) length);
- addKeyword(&prev,
- strdup(tmp),
- EXTRACTOR_SIZE);
- free(tmp);
- }
- break;
- case TAG_SOFTWARE:
- addASCII(&prev,
- data, size,
- &entry,
- EXTRACTOR_SOFTWARE);
- break;
- case TAG_ARTIST:
- addASCII(&prev,
- data, size,
- &entry,
- EXTRACTOR_ARTIST);
- break;
- case TAG_DOCUMENT_NAME:
- addASCII(&prev,
- data, size,
- &entry,
- EXTRACTOR_TITLE);
- break;
- case TAG_COPYRIGHT:
- addASCII(&prev,
- data, size,
- &entry,
- EXTRACTOR_COPYRIGHT);
- break;
- case TAG_DESCRIPTION:
- addASCII(&prev,
- data, size,
- &entry,
- EXTRACTOR_DESCRIPTION);
- break;
- case TAG_HOST:
- addASCII(&prev,
- data, size,
- &entry,
- EXTRACTOR_BUILDHOST);
- break;
- case TAG_SCANNER:
- addASCII(&prev,
- data, size,
- &entry,
- EXTRACTOR_SOURCE);
- break;
- case TAG_DAYTIME:
- addASCII(&prev,
- data, size,
- &entry,
- EXTRACTOR_CREATION_DATE);
- break;
- }
- }
+ cat_unpack (&data[off],
+ DIRECTORY_ENTRY_SPECS[byteOrder],
+ DIRECTORY_ENTRY_FIELDS (&entry));
+ switch (entry.tag)
+ {
+ case TAG_LENGTH:
+ if ((entry.type == TYPE_SHORT) && (byteOrder == 1))
+ {
+ length = entry.value_or_offset >> 16;
+ }
+ else
+ {
+ length = entry.value_or_offset;
+ }
+ if (width != -1)
+ {
+ char *tmp;
+ tmp = malloc (128);
+ sprintf (tmp, "%ux%u",
+ (unsigned int) width, (unsigned int) length);
+ addKeyword (&prev, strdup (tmp), EXTRACTOR_SIZE);
+ free (tmp);
+ }
+ break;
+ case TAG_WIDTH:
+ if ((entry.type == TYPE_SHORT) && (byteOrder == 1))
+ width = entry.value_or_offset >> 16;
+ else
+ width = entry.value_or_offset;
+ if (length != -1)
+ {
+ char *tmp;
+ tmp = malloc (128);
+ sprintf (tmp, "%ux%u",
+ (unsigned int) width, (unsigned int) length);
+ addKeyword (&prev, strdup (tmp), EXTRACTOR_SIZE);
+ free (tmp);
+ }
+ break;
+ case TAG_SOFTWARE:
+ addASCII (&prev, data, size, &entry, EXTRACTOR_SOFTWARE);
+ break;
+ case TAG_ARTIST:
+ addASCII (&prev, data, size, &entry, EXTRACTOR_ARTIST);
+ break;
+ case TAG_DOCUMENT_NAME:
+ addASCII (&prev, data, size, &entry, EXTRACTOR_TITLE);
+ break;
+ case TAG_COPYRIGHT:
+ addASCII (&prev, data, size, &entry, EXTRACTOR_COPYRIGHT);
+ break;
+ case TAG_DESCRIPTION:
+ addASCII (&prev, data, size, &entry, EXTRACTOR_DESCRIPTION);
+ break;
+ case TAG_HOST:
+ addASCII (&prev, data, size, &entry, EXTRACTOR_BUILDHOST);
+ break;
+ case TAG_SCANNER:
+ addASCII (&prev, data, size, &entry, EXTRACTOR_SOURCE);
+ break;
+ case TAG_DAYTIME:
+ addASCII (&prev, data, size, &entry, EXTRACTOR_CREATION_DATE);
+ break;
+ }
+ }
- off = current_ifd + 2 + DIRECTORY_ENTRY_SIZE * len;
- if (byteOrder == 0)
- current_ifd = data[off+3]<<24|data[off+2]<<16|data[off+1]<<8|data[off];
- else
- current_ifd = data[off]<<24|data[off+1]<<16|data[off+2]<<8|data[off+3];
- }
+ off = current_ifd + 2 + DIRECTORY_ENTRY_SIZE * len;
+ if (byteOrder == 0)
+ current_ifd =
+ data[off + 3] << 24 | data[off + 2] << 16 | data[off +
+ 1] << 8 |
+ data[off];
+ else
+ current_ifd =
+ data[off] << 24 | data[off + 1] << 16 | data[off +
+ 2] << 8 | data[off +
+ 3];
+ }
return prev;
}
-
Modified: Extractor/src/plugins/translitextractor.c
===================================================================
--- Extractor/src/plugins/translitextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/translitextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -16,17 +16,17 @@
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.
- */
-
+ */
+
/**
* @brief Transliterate keywords that contain international characters
* @author Nils Durner
- */
-
+ */
+
#include "platform.h"
#include "extractor.h"
#include "convert.h"
-
+
/* Language independent chars were taken from glibc's locale/C-translit.h.in
*
* This extractor uses two tables: one contains the Unicode
@@ -69,598 +69,1011 @@
*
* The unicode values for the other characters were taken from
* http://bigfield.ddo.jp/unicode/unicode0.html
- */
-
-unsigned int chars[][2] = {
- {0x00C4, 444}, {0x00D6, 445}, {0x00DC, 446}, {0x00DF, 13}, /* �, �, �, � */
- {0x00E4, 14}, {0x00F6, 19}, {0x00FC, 447}, {0x00C5, 448}, /* �, �, �, � */
- {0x00E5, 449}, {0x00C6, 444}, {0x00E6, 14}, {0x00D8, 445}, /* �, �, �, � */
- {0x00F8, 19}, {0x00C0, 419}, {0x00C8, 77}, {0x00D9, 426}, /* �, �, �, � */
- {0x00E0, 431}, {0x00E8, 76}, {0x00F9, 5}, {0x00C9, 77}, /* �, �, �, � */
- {0x00E9, 76}, {0x00C2, 419}, {0x00CA, 77}, {0x00CE, 63}, /* �, �, �, � */
- {0x00D4, 423}, {0x00DB, 426}, {0x00E2, 431}, {0x00EA, 76}, /* �, �, �, � */
- {0x00EE, 80}, {0x00F4, 41}, {0x00FB, 5}, {0x00CB, 77}, /* �, �, �, � */
- {0x00CF, 63}, {0x00EB, 76}, {0x00EF, 80}, {0x00C7, 57}, /* �, �, �, � */
- {0x00E7, 118}, {0x0152, 445}, {0x0053, 19}, {0x0080, 66}, /* �, �, �, � */
+ */
+
+unsigned int chars[][2] = {
+ {0x00C4, 444}, {0x00D6, 445}, {0x00DC, 446}, {0x00DF, 13},
+ /* �, �, �, � */
+{0x00E4, 14}, {0x00F6, 19}, {0x00FC, 447}, {0x00C5, 448}, /* �, �, �, � */
+{0x00E5, 449}, {0x00C6, 444}, {0x00E6, 14}, {0x00D8, 445}, /* �, �, �, � */
+{0x00F8, 19}, {0x00C0, 419}, {0x00C8, 77}, {0x00D9, 426}, /* �, �, �, � */
+{0x00E0, 431}, {0x00E8, 76}, {0x00F9, 5}, {0x00C9, 77}, /* �, �, �, � */
+{0x00E9, 76}, {0x00C2, 419}, {0x00CA, 77}, {0x00CE, 63}, /* �, �, �, � */
+{0x00D4, 423}, {0x00DB, 426}, {0x00E2, 431}, {0x00EA, 76}, /* �, �, �, � */
+{0x00EE, 80}, {0x00F4, 41}, {0x00FB, 5}, {0x00CB, 77}, /* �, �, �, � */
+{0x00CF, 63}, {0x00EB, 76}, {0x00EF, 80}, {0x00C7, 57}, /* �, �, �, � */
+{0x00E7, 118}, {0x0152, 445}, {0x0053, 19}, {0x0080, 66}, /* �, �, �, � */
- /* Language independent */
- {0xFB00, 391}, {0xFB01, 392}, {0xFB02, 393}, {0xFB03, 394},
- {0xFB04, 395}, {0xFB06, 396}, {0xFB29, 40}, {0xFEFF, 36},
- {0xFE4D, 33}, {0xFE4E, 33}, {0xFE4F, 33}, {0xFE5A, 401},
- {0xFE5B, 402}, {0xFE5C, 403}, {0xFE5F, 404}, {0xFE50, 6},
- {0xFE52, 42}, {0xFE54, 397}, {0xFE55, 34}, {0xFE56, 398},
- {0xFE57, 399}, {0xFE59, 400}, {0xFE6A, 407}, {0xFE6B, 408},
- {0xFE60, 405}, {0xFE61, 128}, {0xFE62, 40}, {0xFE63, 3},
- {0xFE64, 47}, {0xFE65, 48}, {0xFE66, 262}, {0xFE68, 127},
- {0xFE69, 406}, {0xFF0A, 128}, {0xFF0B, 40}, {0xFF0C, 6},
- {0xFF0D, 3}, {0xFF0E, 42}, {0xFF0F, 126}, {0xFF01, 399},
- {0xFF02, 38}, {0xFF03, 404}, {0xFF04, 406}, {0xFF05, 407},
- {0xFF06, 405}, {0xFF07, 30}, {0xFF08, 400}, {0xFF09, 401},
- {0xFF1A, 34}, {0xFF1B, 397}, {0xFF1C, 47}, {0xFF1D, 262},
- {0xFF1E, 48}, {0xFF1F, 398}, {0xFF10, 409}, {0xFF11, 410},
- {0xFF12, 411}, {0xFF13, 412}, {0xFF14, 413}, {0xFF15, 414},
- {0xFF16, 415}, {0xFF17, 416}, {0xFF18, 417}, {0xFF19, 418},
- {0xFF2A, 421}, {0xFF2B, 422}, {0xFF2C, 64}, {0xFF2D, 79},
- {0xFF2E, 66}, {0xFF2F, 423}, {0xFF20, 408}, {0xFF21, 419},
- {0xFF22, 75}, {0xFF23, 57}, {0xFF24, 81}, {0xFF25, 77},
- {0xFF26, 78}, {0xFF27, 420}, {0xFF28, 61}, {0xFF29, 63},
- {0xFF3A, 73}, {0xFF3B, 429}, {0xFF3C, 127}, {0xFF3D, 430},
- {0xFF3E, 31}, {0xFF3F, 33}, {0xFF30, 68}, {0xFF31, 69},
- {0xFF32, 70}, {0xFF33, 424}, {0xFF34, 425}, {0xFF35, 426},
- {0xFF36, 100}, {0xFF37, 427}, {0xFF38, 105}, {0xFF39, 428},
- {0xFF4A, 83}, {0xFF4B, 434}, {0xFF4C, 65}, {0xFF4D, 119},
- {0xFF4E, 435}, {0xFF4F, 41}, {0xFF40, 32}, {0xFF41, 431},
- {0xFF42, 432}, {0xFF43, 118}, {0xFF44, 82}, {0xFF45, 76},
- {0xFF46, 433}, {0xFF47, 60}, {0xFF48, 62}, {0xFF49, 80},
- {0xFF5A, 442}, {0xFF5B, 402}, {0xFF5C, 129}, {0xFF5D, 403},
- {0xFF5E, 35}, {0xFF50, 436}, {0xFF51, 437}, {0xFF52, 438},
- {0xFF53, 20}, {0xFF54, 439}, {0xFF55, 5}, {0xFF56, 111},
- {0xFF57, 440}, {0xFF58, 12}, {0xFF59, 441}, {0x00AB, 2},
- {0x00AD, 3}, {0x00AE, 4}, {0x00A0, 0}, {0x00A9, 1},
- {0x00BB, 7}, {0x00BC, 8}, {0x00BD, 9}, {0x00BE, 10},
- {0x00B5, 5}, {0x00B8, 6}, {0x00C6, 11}, {0x00DF, 13},
- {0x00D7, 12}, {0x00E6, 14}, {0x0001D4AA, 423}, {0x0001D4AB, 68},
- {0x0001D4AC, 69}, {0x0001D4AE, 424}, {0x0001D4AF, 425}, {0x0001D4A2, 420},
- {0x0001D4A5, 421}, {0x0001D4A6, 422}, {0x0001D4A9, 66}, {0x0001D4BB, 433},
- {0x0001D4BD, 62}, {0x0001D4BE, 80}, {0x0001D4BF, 83}, {0x0001D4B0, 426},
- {0x0001D4B1, 100}, {0x0001D4B2, 427}, {0x0001D4B3, 105}, {0x0001D4B4, 428},
- {0x0001D4B5, 73}, {0x0001D4B6, 431}, {0x0001D4B7, 432}, {0x0001D4B8, 118},
- {0x0001D4B9, 82}, {0x0001D4CA, 5}, {0x0001D4CB, 111}, {0x0001D4CC, 440},
- {0x0001D4CD, 12}, {0x0001D4CE, 441}, {0x0001D4CF, 442}, {0x0001D4C0, 434},
- {0x0001D4C2, 119}, {0x0001D4C3, 435}, {0x0001D4C5, 436}, {0x0001D4C6, 437},
- {0x0001D4C7, 438}, {0x0001D4C8, 20}, {0x0001D4C9, 439}, {0x0001D4DA, 422},
- {0x0001D4DB, 64}, {0x0001D4DC, 79}, {0x0001D4DD, 66}, {0x0001D4DE, 423},
- {0x0001D4DF, 68}, {0x0001D4D0, 419}, {0x0001D4D1, 75}, {0x0001D4D2, 57},
- {0x0001D4D3, 81}, {0x0001D4D4, 77}, {0x0001D4D5, 78}, {0x0001D4D6, 420},
- {0x0001D4D7, 61}, {0x0001D4D8, 63}, {0x0001D4D9, 421}, {0x0001D4EA, 431},
- {0x0001D4EB, 432}, {0x0001D4EC, 118}, {0x0001D4ED, 82}, {0x0001D4EE, 76},
- {0x0001D4EF, 433}, {0x0001D4E0, 69}, {0x0001D4E1, 70}, {0x0001D4E2, 424},
- {0x0001D4E3, 425}, {0x0001D4E4, 426}, {0x0001D4E5, 100}, {0x0001D4E6, 427},
- {0x0001D4E7, 105}, {0x0001D4E8, 428}, {0x0001D4E9, 73}, {0x0001D4FA, 437},
- {0x0001D4FB, 438}, {0x0001D4FC, 20}, {0x0001D4FD, 439}, {0x0001D4FE, 5},
- {0x0001D4FF, 111}, {0x0001D4F0, 60}, {0x0001D4F1, 62}, {0x0001D4F2, 80},
- {0x0001D4F3, 83}, {0x0001D4F4, 434}, {0x0001D4F5, 65}, {0x0001D4F6, 119},
- {0x0001D4F7, 435}, {0x0001D4F8, 41}, {0x0001D4F9, 436}, {0x0001D40A, 422},
- {0x0001D40B, 64}, {0x0001D40C, 79}, {0x0001D40D, 66}, {0x0001D40E, 423},
- {0x0001D40F, 68}, {0x0001D400, 419}, {0x0001D401, 75}, {0x0001D402, 57},
- {0x0001D403, 81}, {0x0001D404, 77}, {0x0001D405, 78}, {0x0001D406, 420},
- {0x0001D407, 61}, {0x0001D408, 63}, {0x0001D409, 421}, {0x0001D41A, 431},
- {0x0001D41B, 432}, {0x0001D41C, 118}, {0x0001D41D, 82}, {0x0001D41E, 76},
- {0x0001D41F, 433}, {0x0001D410, 69}, {0x0001D411, 70}, {0x0001D412, 424},
- {0x0001D413, 425}, {0x0001D414, 426}, {0x0001D415, 100}, {0x0001D416, 427},
- {0x0001D417, 105}, {0x0001D418, 428}, {0x0001D419, 73}, {0x0001D42A, 437},
- {0x0001D42B, 438}, {0x0001D42C, 20}, {0x0001D42D, 439}, {0x0001D42E, 5},
- {0x0001D42F, 111}, {0x0001D420, 60}, {0x0001D421, 62}, {0x0001D422, 80},
- {0x0001D423, 83}, {0x0001D424, 434}, {0x0001D425, 65}, {0x0001D426, 119},
- {0x0001D427, 435}, {0x0001D428, 41}, {0x0001D429, 436}, {0x0001D43A, 420},
- {0x0001D43B, 61}, {0x0001D43C, 63}, {0x0001D43D, 421}, {0x0001D43E, 422},
- {0x0001D43F, 64}, {0x0001D430, 440}, {0x0001D431, 12}, {0x0001D432, 441},
- {0x0001D433, 442}, {0x0001D434, 419}, {0x0001D435, 75}, {0x0001D436, 57},
- {0x0001D437, 81}, {0x0001D438, 77}, {0x0001D439, 78}, {0x0001D44A, 427},
- {0x0001D44B, 105}, {0x0001D44C, 428}, {0x0001D44D, 73}, {0x0001D44E, 431},
- {0x0001D44F, 432}, {0x0001D440, 79}, {0x0001D441, 66}, {0x0001D442, 423},
- {0x0001D443, 68}, {0x0001D444, 69}, {0x0001D445, 70}, {0x0001D446, 424},
- {0x0001D447, 425}, {0x0001D448, 426}, {0x0001D449, 100}, {0x0001D45A, 119},
- {0x0001D45B, 435}, {0x0001D45C, 41}, {0x0001D45D, 436}, {0x0001D45E, 437},
- {0x0001D45F, 438}, {0x0001D450, 118}, {0x0001D451, 82}, {0x0001D452, 76},
- {0x0001D453, 433}, {0x0001D454, 60}, {0x0001D456, 80}, {0x0001D457, 83},
- {0x0001D458, 434}, {0x0001D459, 65}, {0x0001D46A, 57}, {0x0001D46B, 81},
- {0x0001D46C, 77}, {0x0001D46D, 78}, {0x0001D46E, 420}, {0x0001D46F, 61},
- {0x0001D460, 20}, {0x0001D461, 439}, {0x0001D462, 5}, {0x0001D463, 111},
- {0x0001D464, 440}, {0x0001D465, 12}, {0x0001D466, 441}, {0x0001D467, 442},
- {0x0001D468, 419}, {0x0001D469, 75}, {0x0001D47A, 424}, {0x0001D47B, 425},
- {0x0001D47C, 426}, {0x0001D47D, 100}, {0x0001D47E, 427}, {0x0001D47F, 105},
- {0x0001D470, 63}, {0x0001D471, 421}, {0x0001D472, 422}, {0x0001D473, 64},
- {0x0001D474, 79}, {0x0001D475, 66}, {0x0001D476, 423}, {0x0001D477, 68},
- {0x0001D478, 69}, {0x0001D479, 70}, {0x0001D48A, 80}, {0x0001D48B, 83},
- {0x0001D48C, 434}, {0x0001D48D, 65}, {0x0001D48E, 119}, {0x0001D48F, 435},
- {0x0001D480, 428}, {0x0001D481, 73}, {0x0001D482, 431}, {0x0001D483, 432},
- {0x0001D484, 118}, {0x0001D485, 82}, {0x0001D486, 76}, {0x0001D487, 433},
- {0x0001D488, 60}, {0x0001D489, 62}, {0x0001D49A, 441}, {0x0001D49B, 442},
- {0x0001D49C, 419}, {0x0001D49E, 57}, {0x0001D49F, 81}, {0x0001D490, 41},
- {0x0001D491, 436}, {0x0001D492, 437}, {0x0001D493, 438}, {0x0001D494, 20},
- {0x0001D495, 439}, {0x0001D496, 5}, {0x0001D497, 111}, {0x0001D498, 440},
- {0x0001D499, 12}, {0x0001D5AA, 422}, {0x0001D5AB, 64}, {0x0001D5AC, 79},
- {0x0001D5AD, 66}, {0x0001D5AE, 423}, {0x0001D5AF, 68}, {0x0001D5A0, 419},
- {0x0001D5A1, 75}, {0x0001D5A2, 57}, {0x0001D5A3, 81}, {0x0001D5A4, 77},
- {0x0001D5A5, 78}, {0x0001D5A6, 420}, {0x0001D5A7, 61}, {0x0001D5A8, 63},
- {0x0001D5A9, 421}, {0x0001D5BA, 431}, {0x0001D5BB, 432}, {0x0001D5BC, 118},
- {0x0001D5BD, 82}, {0x0001D5BE, 76}, {0x0001D5BF, 433}, {0x0001D5B0, 69},
- {0x0001D5B1, 70}, {0x0001D5B2, 424}, {0x0001D5B3, 425}, {0x0001D5B4, 426},
- {0x0001D5B5, 100}, {0x0001D5B6, 427}, {0x0001D5B7, 105}, {0x0001D5B8, 428},
- {0x0001D5B9, 73}, {0x0001D5CA, 437}, {0x0001D5CB, 438}, {0x0001D5CC, 20},
- {0x0001D5CD, 439}, {0x0001D5CE, 5}, {0x0001D5CF, 111}, {0x0001D5C0, 60},
- {0x0001D5C1, 62}, {0x0001D5C2, 80}, {0x0001D5C3, 83}, {0x0001D5C4, 434},
- {0x0001D5C5, 65}, {0x0001D5C6, 119}, {0x0001D5C7, 435}, {0x0001D5C8, 41},
- {0x0001D5C9, 436}, {0x0001D5DA, 420}, {0x0001D5DB, 61}, {0x0001D5DC, 63},
- {0x0001D5DD, 421}, {0x0001D5DE, 422}, {0x0001D5DF, 64}, {0x0001D5D0, 440},
- {0x0001D5D1, 12}, {0x0001D5D2, 441}, {0x0001D5D3, 442}, {0x0001D5D4, 419},
- {0x0001D5D5, 75}, {0x0001D5D6, 57}, {0x0001D5D7, 81}, {0x0001D5D8, 77},
- {0x0001D5D9, 78}, {0x0001D5EA, 427}, {0x0001D5EB, 105}, {0x0001D5EC, 428},
- {0x0001D5ED, 73}, {0x0001D5EE, 431}, {0x0001D5EF, 432}, {0x0001D5E0, 79},
- {0x0001D5E1, 66}, {0x0001D5E2, 423}, {0x0001D5E3, 68}, {0x0001D5E4, 69},
- {0x0001D5E5, 70}, {0x0001D5E6, 424}, {0x0001D5E7, 425}, {0x0001D5E8, 426},
- {0x0001D5E9, 100}, {0x0001D5FA, 119}, {0x0001D5FB, 435}, {0x0001D5FC, 41},
- {0x0001D5FD, 436}, {0x0001D5FE, 437}, {0x0001D5FF, 438}, {0x0001D5F0, 118},
- {0x0001D5F1, 82}, {0x0001D5F2, 76}, {0x0001D5F3, 433}, {0x0001D5F4, 60},
- {0x0001D5F5, 62}, {0x0001D5F6, 80}, {0x0001D5F7, 83}, {0x0001D5F8, 434},
- {0x0001D5F9, 65}, {0x0001D50A, 420}, {0x0001D50D, 421}, {0x0001D50E, 422},
- {0x0001D50F, 64}, {0x0001D500, 440}, {0x0001D501, 12}, {0x0001D502, 441},
- {0x0001D503, 442}, {0x0001D504, 419}, {0x0001D505, 75}, {0x0001D507, 81},
- {0x0001D508, 77}, {0x0001D509, 78}, {0x0001D51A, 427}, {0x0001D51B, 105},
- {0x0001D51C, 428}, {0x0001D51E, 431}, {0x0001D51F, 432}, {0x0001D510, 79},
- {0x0001D511, 66}, {0x0001D512, 423}, {0x0001D513, 68}, {0x0001D514, 69},
- {0x0001D516, 424}, {0x0001D517, 425}, {0x0001D518, 426}, {0x0001D519, 100},
- {0x0001D52A, 119}, {0x0001D52B, 435}, {0x0001D52C, 41}, {0x0001D52D, 436},
- {0x0001D52E, 437}, {0x0001D52F, 438}, {0x0001D520, 118}, {0x0001D521, 82},
- {0x0001D522, 76}, {0x0001D523, 433}, {0x0001D524, 60}, {0x0001D525, 62},
- {0x0001D526, 80}, {0x0001D527, 83}, {0x0001D528, 434}, {0x0001D529, 65},
- {0x0001D53B, 81}, {0x0001D53C, 77}, {0x0001D53D, 78}, {0x0001D53E, 420},
- {0x0001D530, 20}, {0x0001D531, 439}, {0x0001D532, 5}, {0x0001D533, 111},
- {0x0001D534, 440}, {0x0001D535, 12}, {0x0001D536, 441}, {0x0001D537, 442},
- {0x0001D538, 419}, {0x0001D539, 75}, {0x0001D54A, 424}, {0x0001D54B, 425},
- {0x0001D54C, 426}, {0x0001D54D, 100}, {0x0001D54E, 427}, {0x0001D54F, 105},
- {0x0001D540, 63}, {0x0001D541, 421}, {0x0001D542, 422}, {0x0001D543, 64},
- {0x0001D544, 79}, {0x0001D546, 423}, {0x0001D55A, 80}, {0x0001D55B, 83},
- {0x0001D55C, 434}, {0x0001D55D, 65}, {0x0001D55E, 119}, {0x0001D55F, 435},
- {0x0001D550, 428}, {0x0001D552, 431}, {0x0001D553, 432}, {0x0001D554, 118},
- {0x0001D555, 82}, {0x0001D556, 76}, {0x0001D557, 433}, {0x0001D558, 60},
- {0x0001D559, 62}, {0x0001D56A, 441}, {0x0001D56B, 442}, {0x0001D56C, 419},
- {0x0001D56D, 75}, {0x0001D56E, 57}, {0x0001D56F, 81}, {0x0001D560, 41},
- {0x0001D561, 436}, {0x0001D562, 437}, {0x0001D563, 438}, {0x0001D564, 20},
- {0x0001D565, 439}, {0x0001D566, 5}, {0x0001D567, 111}, {0x0001D568, 440},
- {0x0001D569, 12}, {0x0001D57A, 423}, {0x0001D57B, 68}, {0x0001D57C, 69},
- {0x0001D57D, 70}, {0x0001D57E, 424}, {0x0001D57F, 425}, {0x0001D570, 77},
- {0x0001D571, 78}, {0x0001D572, 420}, {0x0001D573, 61}, {0x0001D574, 63},
- {0x0001D575, 421}, {0x0001D576, 422}, {0x0001D577, 64}, {0x0001D578, 79},
- {0x0001D579, 66}, {0x0001D58A, 76}, {0x0001D58B, 433}, {0x0001D58C, 60},
- {0x0001D58D, 62}, {0x0001D58E, 80}, {0x0001D58F, 83}, {0x0001D580, 426},
- {0x0001D581, 100}, {0x0001D582, 427}, {0x0001D583, 105}, {0x0001D584, 428},
- {0x0001D585, 73}, {0x0001D586, 431}, {0x0001D587, 432}, {0x0001D588, 118},
- {0x0001D589, 82}, {0x0001D59A, 5}, {0x0001D59B, 111}, {0x0001D59C, 440},
- {0x0001D59D, 12}, {0x0001D59E, 441}, {0x0001D59F, 442}, {0x0001D590, 434},
- {0x0001D591, 65}, {0x0001D592, 119}, {0x0001D593, 435}, {0x0001D594, 41},
- {0x0001D595, 436}, {0x0001D596, 437}, {0x0001D597, 438}, {0x0001D598, 20},
- {0x0001D599, 439}, {0x0001D6A0, 440}, {0x0001D6A1, 12}, {0x0001D6A2, 441},
- {0x0001D6A3, 442}, {0x0001D60A, 57}, {0x0001D60B, 81}, {0x0001D60C, 77},
- {0x0001D60D, 78}, {0x0001D60E, 420}, {0x0001D60F, 61}, {0x0001D600, 20},
- {0x0001D601, 439}, {0x0001D602, 5}, {0x0001D603, 111}, {0x0001D604, 440},
- {0x0001D605, 12}, {0x0001D606, 441}, {0x0001D607, 442}, {0x0001D608, 419},
- {0x0001D609, 75}, {0x0001D61A, 424}, {0x0001D61B, 425}, {0x0001D61C, 426},
- {0x0001D61D, 100}, {0x0001D61E, 427}, {0x0001D61F, 105}, {0x0001D610, 63},
- {0x0001D611, 421}, {0x0001D612, 422}, {0x0001D613, 64}, {0x0001D614, 79},
- {0x0001D615, 66}, {0x0001D616, 423}, {0x0001D617, 68}, {0x0001D618, 69},
- {0x0001D619, 70}, {0x0001D62A, 80}, {0x0001D62B, 83}, {0x0001D62C, 434},
- {0x0001D62D, 65}, {0x0001D62E, 119}, {0x0001D62F, 435}, {0x0001D620, 428},
- {0x0001D621, 73}, {0x0001D622, 431}, {0x0001D623, 432}, {0x0001D624, 118},
- {0x0001D625, 82}, {0x0001D626, 76}, {0x0001D627, 433}, {0x0001D628, 60},
- {0x0001D629, 62}, {0x0001D63A, 441}, {0x0001D63B, 442}, {0x0001D63C, 419},
- {0x0001D63D, 75}, {0x0001D63E, 57}, {0x0001D63F, 81}, {0x0001D630, 41},
- {0x0001D631, 436}, {0x0001D632, 437}, {0x0001D633, 438}, {0x0001D634, 20},
- {0x0001D635, 439}, {0x0001D636, 5}, {0x0001D637, 111}, {0x0001D638, 440},
- {0x0001D639, 12}, {0x0001D64A, 423}, {0x0001D64B, 68}, {0x0001D64C, 69},
- {0x0001D64D, 70}, {0x0001D64E, 424}, {0x0001D64F, 425}, {0x0001D640, 77},
- {0x0001D641, 78}, {0x0001D642, 420}, {0x0001D643, 61}, {0x0001D644, 63},
- {0x0001D645, 421}, {0x0001D646, 422}, {0x0001D647, 64}, {0x0001D648, 79},
- {0x0001D649, 66}, {0x0001D65A, 76}, {0x0001D65B, 433}, {0x0001D65C, 60},
- {0x0001D65D, 62}, {0x0001D65E, 80}, {0x0001D65F, 83}, {0x0001D650, 426},
- {0x0001D651, 100}, {0x0001D652, 427}, {0x0001D653, 105}, {0x0001D654, 428},
- {0x0001D655, 73}, {0x0001D656, 431}, {0x0001D657, 432}, {0x0001D658, 118},
- {0x0001D659, 82}, {0x0001D66A, 5}, {0x0001D66B, 111}, {0x0001D66C, 440},
- {0x0001D66D, 12}, {0x0001D66E, 441}, {0x0001D66F, 442}, {0x0001D660, 434},
- {0x0001D661, 65}, {0x0001D662, 119}, {0x0001D663, 435}, {0x0001D664, 41},
- {0x0001D665, 436}, {0x0001D666, 437}, {0x0001D667, 438}, {0x0001D668, 20},
- {0x0001D669, 439}, {0x0001D67A, 422}, {0x0001D67B, 64}, {0x0001D67C, 79},
- {0x0001D67D, 66}, {0x0001D67E, 423}, {0x0001D67F, 68}, {0x0001D670, 419},
- {0x0001D671, 75}, {0x0001D672, 57}, {0x0001D673, 81}, {0x0001D674, 77},
- {0x0001D675, 78}, {0x0001D676, 420}, {0x0001D677, 61}, {0x0001D678, 63},
- {0x0001D679, 421}, {0x0001D68A, 431}, {0x0001D68B, 432}, {0x0001D68C, 118},
- {0x0001D68D, 82}, {0x0001D68E, 76}, {0x0001D68F, 433}, {0x0001D680, 69},
- {0x0001D681, 70}, {0x0001D682, 424}, {0x0001D683, 425}, {0x0001D684, 426},
- {0x0001D685, 100}, {0x0001D686, 427}, {0x0001D687, 105}, {0x0001D688, 428},
- {0x0001D689, 73}, {0x0001D69A, 437}, {0x0001D69B, 438}, {0x0001D69C, 20},
- {0x0001D69D, 439}, {0x0001D69E, 5}, {0x0001D69F, 111}, {0x0001D690, 60},
- {0x0001D691, 62}, {0x0001D692, 80}, {0x0001D693, 83}, {0x0001D694, 434},
- {0x0001D695, 65}, {0x0001D696, 119}, {0x0001D697, 435}, {0x0001D698, 41},
- {0x0001D699, 436}, {0x0001D7CE, 409}, {0x0001D7CF, 410}, {0x0001D7DA, 411},
- {0x0001D7DB, 412}, {0x0001D7DC, 413}, {0x0001D7DD, 414}, {0x0001D7DE, 415},
- {0x0001D7DF, 416}, {0x0001D7D0, 411}, {0x0001D7D1, 412}, {0x0001D7D2, 413},
- {0x0001D7D3, 414}, {0x0001D7D4, 415}, {0x0001D7D5, 416}, {0x0001D7D6, 417},
- {0x0001D7D7, 418}, {0x0001D7D8, 409}, {0x0001D7D9, 410}, {0x0001D7EA, 417},
- {0x0001D7EB, 418}, {0x0001D7EC, 409}, {0x0001D7ED, 410}, {0x0001D7EE, 411},
- {0x0001D7EF, 412}, {0x0001D7E0, 417}, {0x0001D7E1, 418}, {0x0001D7E2, 409},
- {0x0001D7E3, 410}, {0x0001D7E4, 411}, {0x0001D7E5, 412}, {0x0001D7E6, 413},
- {0x0001D7E7, 414}, {0x0001D7E8, 415}, {0x0001D7E9, 416}, {0x0001D7FA, 413},
- {0x0001D7FB, 414}, {0x0001D7FC, 415}, {0x0001D7FD, 416}, {0x0001D7FE, 417},
- {0x0001D7FF, 418}, {0x0001D7F0, 413}, {0x0001D7F1, 414}, {0x0001D7F2, 415},
- {0x0001D7F3, 416}, {0x0001D7F4, 417}, {0x0001D7F5, 418}, {0x0001D7F6, 409},
- {0x0001D7F7, 410}, {0x0001D7F8, 411}, {0x0001D7F9, 412}, {0x01CA, 24},
- {0x01CB, 25}, {0x01CC, 26}, {0x01C7, 21}, {0x01C8, 22},
- {0x01C9, 23}, {0x01F1, 27}, {0x01F2, 28}, {0x01F3, 29},
- {0x0132, 15}, {0x0133, 16}, {0x0149, 17}, {0x0152, 18},
- {0x0152, 18}, {0x0153, 19}, {0x0153, 19}, {0x017F, 20},
- {0x02BC, 30}, {0x02CB, 32}, {0x02CD, 33}, {0x02C6, 31},
- {0x02C8, 30}, {0x02DC, 35}, {0x02D0, 34}, {0x2A74, 259},
- {0x2A75, 260}, {0x2A76, 261}, {0x20AC, 54}, {0x20A8, 53},
- {0x200A, 0}, {0x200B, 36}, {0x2002, 0}, {0x2003, 0},
- {0x2004, 0}, {0x2005, 0}, {0x2006, 0}, {0x2008, 0},
- {0x2009, 0}, {0x201A, 6}, {0x201B, 30}, {0x201C, 38},
- {0x201D, 38}, {0x201E, 39}, {0x201F, 38}, {0x2010, 3},
- {0x2011, 3}, {0x2012, 3}, {0x2013, 3}, {0x2014, 37},
- {0x2015, 3}, {0x2018, 30}, {0x2019, 30}, {0x202F, 0},
- {0x2020, 40}, {0x2022, 41}, {0x2024, 42}, {0x2025, 43},
- {0x2026, 44}, {0x203A, 48}, {0x203C, 49}, {0x2035, 32},
- {0x2036, 45}, {0x2037, 46}, {0x2039, 47}, {0x2047, 50},
- {0x2048, 51}, {0x2049, 52}, {0x205F, 0}, {0x2060, 36},
- {0x2061, 36}, {0x2062, 36}, {0x2063, 36}, {0x21D0, 123},
- {0x21D2, 124}, {0x21D4, 125}, {0x210A, 60}, {0x210B, 61},
- {0x210C, 61}, {0x210D, 61}, {0x210E, 62}, {0x2100, 55},
- {0x2101, 56}, {0x2102, 57}, {0x2105, 58}, {0x2106, 59},
- {0x211A, 69}, {0x211B, 70}, {0x211C, 70}, {0x211D, 70},
- {0x2110, 63}, {0x2111, 63}, {0x2112, 64}, {0x2113, 65},
- {0x2115, 66}, {0x2116, 67}, {0x2119, 68}, {0x212C, 75},
- {0x212D, 57}, {0x212E, 76}, {0x212F, 76}, {0x2121, 71},
- {0x2122, 72}, {0x2124, 73}, {0x2126, 74}, {0x2128, 73},
- {0x2130, 77}, {0x2131, 78}, {0x2133, 79}, {0x2134, 41},
- {0x2139, 80}, {0x2145, 81}, {0x2146, 82}, {0x2147, 76},
- {0x2148, 80}, {0x2149, 83}, {0x215A, 91}, {0x215B, 92},
- {0x215C, 93}, {0x215D, 94}, {0x215E, 95}, {0x215F, 96},
- {0x2153, 84}, {0x2154, 85}, {0x2155, 86}, {0x2156, 87},
- {0x2157, 88}, {0x2158, 89}, {0x2159, 90}, {0x216A, 106},
- {0x216B, 107}, {0x216C, 64}, {0x216D, 57}, {0x216E, 81},
- {0x216F, 79}, {0x2160, 63}, {0x2161, 97}, {0x2162, 98},
- {0x2163, 99}, {0x2164, 100}, {0x2165, 101}, {0x2166, 102},
- {0x2167, 103}, {0x2168, 104}, {0x2169, 105}, {0x217A, 116},
- {0x217B, 117}, {0x217C, 65}, {0x217D, 118}, {0x217E, 82},
- {0x217F, 119}, {0x2170, 80}, {0x2171, 108}, {0x2172, 109},
- {0x2173, 110}, {0x2174, 111}, {0x2175, 112}, {0x2176, 113},
- {0x2177, 114}, {0x2178, 115}, {0x2179, 12}, {0x2190, 120},
- {0x2192, 121}, {0x2194, 122}, {0x22D8, 131}, {0x22D9, 132},
- {0x2212, 3}, {0x2215, 126}, {0x2216, 127}, {0x2217, 128},
- {0x2223, 129}, {0x223C, 35}, {0x2236, 34}, {0x226A, 2},
- {0x226B, 7}, {0x2264, 123}, {0x2265, 130}, {0x24AA, 222},
- {0x24AB, 223}, {0x24AC, 224}, {0x24AD, 225}, {0x24AE, 226},
- {0x24AF, 227}, {0x24A0, 212}, {0x24A1, 213}, {0x24A2, 214},
- {0x24A3, 215}, {0x24A4, 216}, {0x24A5, 217}, {0x24A6, 218},
- {0x24A7, 219}, {0x24A8, 220}, {0x24A9, 221}, {0x24BA, 237},
- {0x24BB, 238}, {0x24BC, 239}, {0x24BD, 240}, {0x24BE, 241},
- {0x24BF, 242}, {0x24B0, 228}, {0x24B1, 229}, {0x24B2, 230},
- {0x24B3, 231}, {0x24B4, 232}, {0x24B5, 233}, {0x24B6, 234},
- {0x24B7, 235}, {0x24B8, 1}, {0x24B9, 236}, {0x24CA, 252},
- {0x24CB, 253}, {0x24CC, 254}, {0x24CD, 255}, {0x24CE, 256},
- {0x24CF, 257}, {0x24C0, 243}, {0x24C1, 244}, {0x24C2, 245},
- {0x24C3, 246}, {0x24C4, 247}, {0x24C5, 248}, {0x24C6, 249},
- {0x24C7, 4}, {0x24C8, 250}, {0x24C9, 251}, {0x24DA, 218},
- {0x24DB, 219}, {0x24DC, 220}, {0x24DD, 221}, {0x24DE, 222},
- {0x24DF, 223}, {0x24D0, 208}, {0x24D1, 209}, {0x24D2, 210},
- {0x24D3, 211}, {0x24D4, 212}, {0x24D5, 213}, {0x24D6, 214},
- {0x24D7, 215}, {0x24D8, 216}, {0x24D9, 217}, {0x24EA, 258},
- {0x24E0, 224}, {0x24E1, 225}, {0x24E2, 226}, {0x24E3, 227},
- {0x24E4, 228}, {0x24E5, 229}, {0x24E6, 230}, {0x24E7, 231},
- {0x24E8, 232}, {0x24E9, 233}, {0x240A, 143}, {0x240B, 144},
- {0x240C, 145}, {0x240D, 146}, {0x240E, 147}, {0x240F, 148},
- {0x2400, 133}, {0x2401, 134}, {0x2402, 135}, {0x2403, 136},
- {0x2404, 137}, {0x2405, 138}, {0x2406, 139}, {0x2407, 140},
- {0x2408, 141}, {0x2409, 142}, {0x241A, 159}, {0x241B, 160},
- {0x241C, 161}, {0x241D, 162}, {0x241E, 163}, {0x241F, 164},
- {0x2410, 149}, {0x2411, 150}, {0x2412, 151}, {0x2413, 152},
- {0x2414, 153}, {0x2415, 154}, {0x2416, 155}, {0x2417, 156},
- {0x2418, 157}, {0x2419, 158}, {0x2420, 165}, {0x2421, 166},
- {0x2423, 33}, {0x2424, 167}, {0x246A, 178}, {0x246B, 179},
- {0x246C, 180}, {0x246D, 181}, {0x246E, 182}, {0x246F, 183},
- {0x2460, 168}, {0x2461, 169}, {0x2462, 170}, {0x2463, 171},
- {0x2464, 172}, {0x2465, 173}, {0x2466, 174}, {0x2467, 175},
- {0x2468, 176}, {0x2469, 177}, {0x247A, 174}, {0x247B, 175},
- {0x247C, 176}, {0x247D, 177}, {0x247E, 178}, {0x247F, 179},
- {0x2470, 184}, {0x2471, 185}, {0x2472, 186}, {0x2473, 187},
- {0x2474, 168}, {0x2475, 169}, {0x2476, 170}, {0x2477, 171},
- {0x2478, 172}, {0x2479, 173}, {0x248A, 190}, {0x248B, 191},
- {0x248C, 192}, {0x248D, 193}, {0x248E, 194}, {0x248F, 195},
- {0x2480, 180}, {0x2481, 181}, {0x2482, 182}, {0x2483, 183},
- {0x2484, 184}, {0x2485, 185}, {0x2486, 186}, {0x2487, 187},
- {0x2488, 188}, {0x2489, 189}, {0x249A, 206}, {0x249B, 207},
- {0x249C, 208}, {0x249D, 209}, {0x249E, 210}, {0x249F, 211},
- {0x2490, 196}, {0x2491, 197}, {0x2492, 198}, {0x2493, 199},
- {0x2494, 200}, {0x2495, 201}, {0x2496, 202}, {0x2497, 203},
- {0x2498, 204}, {0x2499, 205}, {0x25E6, 41}, {0x250C, 40},
- {0x2500, 3}, {0x2502, 129}, {0x251C, 40}, {0x2510, 40},
- {0x2514, 40}, {0x2518, 40}, {0x252C, 40}, {0x2524, 40},
- {0x253C, 40}, {0x2534, 40}, {0x30A0, 262}, {0x3000, 0},
- {0x32BA, 287}, {0x32BB, 288}, {0x32BC, 289}, {0x32BD, 290},
- {0x32BE, 291}, {0x32BF, 292}, {0x32B1, 278}, {0x32B2, 279},
- {0x32B3, 280}, {0x32B4, 281}, {0x32B5, 282}, {0x32B6, 283},
- {0x32B7, 284}, {0x32B8, 285}, {0x32B9, 286}, {0x325A, 272},
- {0x325B, 273}, {0x325C, 274}, {0x325D, 275}, {0x325E, 276},
- {0x325F, 277}, {0x3251, 263}, {0x3252, 264}, {0x3253, 265},
- {0x3254, 266}, {0x3255, 267}, {0x3256, 268}, {0x3257, 269},
- {0x3258, 270}, {0x3259, 271}, {0x33AA, 341}, {0x33AB, 342},
- {0x33AC, 343}, {0x33AD, 344}, {0x33AE, 345}, {0x33AF, 346},
- {0x33A0, 331}, {0x33A1, 332}, {0x33A2, 333}, {0x33A3, 334},
- {0x33A4, 335}, {0x33A5, 336}, {0x33A6, 337}, {0x33A7, 338},
- {0x33A8, 339}, {0x33A9, 340}, {0x33BA, 357}, {0x33BB, 358},
- {0x33BC, 359}, {0x33BD, 360}, {0x33BE, 361}, {0x33BF, 362},
- {0x33B0, 347}, {0x33B1, 348}, {0x33B2, 349}, {0x33B3, 350},
- {0x33B4, 351}, {0x33B5, 352}, {0x33B6, 353}, {0x33B7, 354},
- {0x33B8, 355}, {0x33B9, 356}, {0x33CA, 371}, {0x33CB, 372},
- {0x33CC, 373}, {0x33CD, 374}, {0x33CE, 375}, {0x33CF, 376},
- {0x33C2, 363}, {0x33C3, 364}, {0x33C4, 365}, {0x33C5, 366},
- {0x33C6, 367}, {0x33C7, 368}, {0x33C8, 369}, {0x33C9, 370},
- {0x33DA, 387}, {0x33DB, 388}, {0x33DC, 389}, {0x33DD, 390},
- {0x33D0, 377}, {0x33D1, 378}, {0x33D2, 379}, {0x33D3, 380},
- {0x33D4, 381}, {0x33D5, 382}, {0x33D6, 383}, {0x33D7, 384},
- {0x33D8, 385}, {0x33D9, 386}, {0x3371, 293}, {0x3372, 294},
- {0x3373, 295}, {0x3374, 296}, {0x3375, 297}, {0x3376, 298},
- {0x338A, 309}, {0x338B, 310}, {0x338C, 311}, {0x338D, 312},
- {0x338E, 313}, {0x338F, 314}, {0x3380, 299}, {0x3381, 300},
- {0x3382, 301}, {0x3383, 302}, {0x3384, 303}, {0x3385, 304},
- {0x3386, 305}, {0x3387, 306}, {0x3388, 307}, {0x3389, 308},
- {0x339A, 325}, {0x339B, 326}, {0x339C, 327}, {0x339D, 328},
- {0x339E, 329}, {0x339F, 330}, {0x3390, 315}, {0x3391, 316},
- {0x3392, 317}, {0x3393, 318}, {0x3394, 319}, {0x3395, 320},
- {0x3396, 321}, {0x3397, 322}, {0x3398, 323}, {0x3399, 324},
- {0, 0}};
-
-char *translit[] = {
- " ", "(C)", "<<", "-",
- "(R)", "u", ",", ">>",
- " 1/4 ", " 1/2 ", " 3/4 ", "AE",
- "x", "ss", "ae", "IJ",
- "ij", "'n", "OE", "oe",
- "s", "LJ", "Lj", "lj",
- "NJ", "Nj", "nj", "DZ",
- "Dz", "dz", "'", "^",
- "`", "_", ":", "~",
- "", "--", "\"", ",,",
- "+", "o", ".", "..",
- "...", "``", "```", "<",
- ">", "!!", "??", "?!",
- "!?", "Rs", "EUR", "a/c",
- "a/s", "C", "c/o", "c/u",
- "g", "H", "h", "I",
- "L", "l", "N", "No",
- "P", "Q", "R", "TEL",
- "(TM)", "Z", "Ohm", "B",
- "e", "E", "F", "M",
- "i", "D", "d", "j",
- " 1/3 ", " 2/3 ", " 1/5 ", " 2/5 ",
- " 3/5 ", " 4/5 ", " 1/6 ", " 5/6 ",
- " 1/8 ", " 3/8 ", " 5/8 ", " 7/8 ",
- " 1/", "II", "III", "IV",
- "V", "VI", "VII", "VIII",
- "IX", "X", "XI", "XII",
- "ii", "iii", "iv", "v",
- "vi", "vii", "viii", "ix",
- "xi", "xii", "c", "m",
- "<-", "->", "<->", "<=",
- "=>", "<=>", "/", "\\",
- "*", "|", ">=", "<<<",
- ">>>", "NUL", "SOH", "STX",
- "ETX", "EOT", "ENQ", "ACK",
- "BEL", "BS", "HT", "LF",
- "VT", "FF", "CR", "SO",
- "SI", "DLE", "DC1", "DC2",
- "DC3", "DC4", "NAK", "SYN",
- "ETB", "CAN", "EM", "SUB",
- "ESC", "FS", "GS", "RS",
- "US", "SP", "DEL", "NL",
- "(1)", "(2)", "(3)", "(4)",
- "(5)", "(6)", "(7)", "(8)",
- "(9)", "(10)", "(11)", "(12)",
- "(13)", "(14)", "(15)", "(16)",
- "(17)", "(18)", "(19)", "(20)",
- "1.", "2.", "3.", "4.",
- "5.", "6.", "7.", "8.",
- "9.", "10.", "11.", "12.",
- "13.", "14.", "15.", "16.",
- "17.", "18.", "19.", "20.",
- "(a)", "(b)", "(c)", "(d)",
- "(e)", "(f)", "(g)", "(h)",
- "(i)", "(j)", "(k)", "(l)",
- "(m)", "(n)", "(o)", "(p)",
- "(q)", "(r)", "(s)", "(t)",
- "(u)", "(v)", "(w)", "(x)",
- "(y)", "(z)", "(A)", "(B)",
- "(D)", "(E)", "(F)", "(G)",
- "(H)", "(I)", "(J)", "(K)",
- "(L)", "(M)", "(N)", "(O)",
- "(P)", "(Q)", "(S)", "(T)",
- "(U)", "(V)", "(W)", "(X)",
- "(Y)", "(Z)", "(0)", "::=",
- "==", "===", "=", "(21)",
- "(22)", "(23)", "(24)", "(25)",
- "(26)", "(27)", "(28)", "(29)",
- "(30)", "(31)", "(32)", "(33)",
- "(34)", "(35)", "(36)", "(37)",
- "(38)", "(39)", "(40)", "(41)",
- "(42)", "(43)", "(44)", "(45)",
- "(46)", "(47)", "(48)", "(49)",
- "(50)", "hPa", "da", "AU",
- "bar", "oV", "pc", "pA",
- "nA", "uA", "mA", "kA",
- "KB", "MB", "GB", "cal",
- "kcal", "pF", "nF", "uF",
- "ug", "mg", "kg", "Hz",
- "kHz", "MHz", "GHz", "THz",
- "ul", "ml", "dl", "kl",
- "fm", "nm", "um", "mm",
- "cm", "km", "mm^2", "cm^2",
- "m^2", "km^2", "mm^3", "cm^3",
- "m^3", "km^3", "m/s", "m/s^2",
- "Pa", "kPa", "MPa", "GPa",
- "rad", "rad/s", "rad/s^2", "ps",
- "ns", "us", "ms", "pV",
- "nV", "uV", "mV", "kV",
- "MV", "pW", "nW", "uW",
- "mW", "kW", "MW", "a.m.",
- "Bq", "cc", "cd", "C/kg",
- "Co.", "dB", "Gy", "ha",
- "HP", "in", "KK", "KM",
- "kt", "lm", "ln", "log",
- "lx", "mb", "mil", "mol",
- "PH", "p.m.", "PPM", "PR",
- "sr", "Sv", "Wb", "ff",
- "fi", "fl", "ffi", "ffl",
- "st", ";", "?", "!",
- "(", ")", "{", "}",
- "#", "&", "$", "%",
- "@", "0", "1", "2",
- "3", "4", "5", "6",
- "7", "8", "9", "A",
- "G", "J", "K", "O",
- "S", "T", "U", "W",
- "Y", "[", "]", "a",
- "b", "f", "k", "n",
- "p", "q", "r", "t",
- "w", "y", "z", "z",
- /* German */ "Ae", "Oe", "Ue", "ue",
- /* Scandinavian */ "Aa", "aa"
-};
+ /* Language independent */
+{0xFB00, 391}, {0xFB01, 392}, {0xFB02, 393}, {0xFB03, 394},
+ {0xFB04, 395}, {0xFB06, 396}, {0xFB29, 40}, {0xFEFF, 36},
+ {0xFE4D, 33}, {0xFE4E, 33}, {0xFE4F, 33}, {0xFE5A, 401},
+ {0xFE5B, 402}, {0xFE5C, 403}, {0xFE5F, 404}, {0xFE50, 6},
+ {0xFE52, 42}, {0xFE54, 397}, {0xFE55, 34}, {0xFE56, 398},
+ {0xFE57, 399}, {0xFE59, 400}, {0xFE6A, 407}, {0xFE6B, 408},
+ {0xFE60, 405}, {0xFE61, 128}, {0xFE62, 40}, {0xFE63, 3},
+ {0xFE64, 47}, {0xFE65, 48}, {0xFE66, 262}, {0xFE68, 127},
+ {0xFE69, 406}, {0xFF0A, 128}, {0xFF0B, 40}, {0xFF0C, 6},
+ {0xFF0D, 3}, {0xFF0E, 42}, {0xFF0F, 126}, {0xFF01, 399},
+ {0xFF02, 38}, {0xFF03, 404}, {0xFF04, 406}, {0xFF05, 407},
+ {0xFF06, 405}, {0xFF07, 30}, {0xFF08, 400}, {0xFF09, 401},
+ {0xFF1A, 34}, {0xFF1B, 397}, {0xFF1C, 47}, {0xFF1D, 262},
+ {0xFF1E, 48}, {0xFF1F, 398}, {0xFF10, 409}, {0xFF11, 410},
+ {0xFF12, 411}, {0xFF13, 412}, {0xFF14, 413}, {0xFF15, 414},
+ {0xFF16, 415}, {0xFF17, 416}, {0xFF18, 417}, {0xFF19, 418},
+ {0xFF2A, 421}, {0xFF2B, 422}, {0xFF2C, 64}, {0xFF2D, 79},
+ {0xFF2E, 66}, {0xFF2F, 423}, {0xFF20, 408}, {0xFF21, 419},
+ {0xFF22, 75}, {0xFF23, 57}, {0xFF24, 81}, {0xFF25, 77},
+ {0xFF26, 78}, {0xFF27, 420}, {0xFF28, 61}, {0xFF29, 63},
+ {0xFF3A, 73}, {0xFF3B, 429}, {0xFF3C, 127}, {0xFF3D, 430},
+ {0xFF3E, 31}, {0xFF3F, 33}, {0xFF30, 68}, {0xFF31, 69},
+ {0xFF32, 70}, {0xFF33, 424}, {0xFF34, 425}, {0xFF35, 426},
+ {0xFF36, 100}, {0xFF37, 427}, {0xFF38, 105}, {0xFF39, 428},
+ {0xFF4A, 83}, {0xFF4B, 434}, {0xFF4C, 65}, {0xFF4D, 119},
+ {0xFF4E, 435}, {0xFF4F, 41}, {0xFF40, 32}, {0xFF41, 431},
+ {0xFF42, 432}, {0xFF43, 118}, {0xFF44, 82}, {0xFF45, 76},
+ {0xFF46, 433}, {0xFF47, 60}, {0xFF48, 62}, {0xFF49, 80},
+ {0xFF5A, 442}, {0xFF5B, 402}, {0xFF5C, 129}, {0xFF5D, 403},
+ {0xFF5E, 35}, {0xFF50, 436}, {0xFF51, 437}, {0xFF52, 438},
+ {0xFF53, 20}, {0xFF54, 439}, {0xFF55, 5}, {0xFF56, 111},
+ {0xFF57, 440}, {0xFF58, 12}, {0xFF59, 441}, {0x00AB, 2},
+ {0x00AD, 3}, {0x00AE, 4}, {0x00A0, 0}, {0x00A9, 1},
+ {0x00BB, 7}, {0x00BC, 8}, {0x00BD, 9}, {0x00BE, 10},
+ {0x00B5, 5}, {0x00B8, 6}, {0x00C6, 11}, {0x00DF, 13},
+ {0x00D7, 12}, {0x00E6, 14}, {0x0001D4AA, 423}, {0x0001D4AB, 68},
+ {0x0001D4AC, 69}, {0x0001D4AE, 424}, {0x0001D4AF, 425}, {0x0001D4A2, 420},
+ {0x0001D4A5, 421}, {0x0001D4A6, 422}, {0x0001D4A9, 66}, {0x0001D4BB, 433},
+ {0x0001D4BD, 62}, {0x0001D4BE, 80}, {0x0001D4BF, 83}, {0x0001D4B0, 426},
+ {0x0001D4B1, 100}, {0x0001D4B2, 427}, {0x0001D4B3, 105}, {0x0001D4B4, 428},
+
+{0x0001D4B5, 73}, {0x0001D4B6, 431}, {0x0001D4B7, 432}, {0x0001D4B8, 118},
+
+{0x0001D4B9, 82}, {0x0001D4CA, 5}, {0x0001D4CB, 111}, {0x0001D4CC, 440},
+
+{0x0001D4CD, 12}, {0x0001D4CE, 441}, {0x0001D4CF, 442}, {0x0001D4C0, 434},
+
+{0x0001D4C2, 119}, {0x0001D4C3, 435}, {0x0001D4C5, 436}, {0x0001D4C6, 437},
+
+{0x0001D4C7, 438}, {0x0001D4C8, 20}, {0x0001D4C9, 439}, {0x0001D4DA, 422},
+
+{0x0001D4DB, 64}, {0x0001D4DC, 79}, {0x0001D4DD, 66}, {0x0001D4DE, 423},
+
+{0x0001D4DF, 68}, {0x0001D4D0, 419}, {0x0001D4D1, 75}, {0x0001D4D2, 57},
+
+{0x0001D4D3, 81}, {0x0001D4D4, 77}, {0x0001D4D5, 78}, {0x0001D4D6, 420},
+
+{0x0001D4D7, 61}, {0x0001D4D8, 63}, {0x0001D4D9, 421}, {0x0001D4EA, 431},
+
+{0x0001D4EB, 432}, {0x0001D4EC, 118}, {0x0001D4ED, 82}, {0x0001D4EE, 76},
+
+{0x0001D4EF, 433}, {0x0001D4E0, 69}, {0x0001D4E1, 70}, {0x0001D4E2, 424},
+
+{0x0001D4E3, 425}, {0x0001D4E4, 426}, {0x0001D4E5, 100}, {0x0001D4E6, 427},
+
+{0x0001D4E7, 105}, {0x0001D4E8, 428}, {0x0001D4E9, 73}, {0x0001D4FA, 437},
+
+{0x0001D4FB, 438}, {0x0001D4FC, 20}, {0x0001D4FD, 439}, {0x0001D4FE, 5},
+
+{0x0001D4FF, 111}, {0x0001D4F0, 60}, {0x0001D4F1, 62}, {0x0001D4F2, 80},
+
+{0x0001D4F3, 83}, {0x0001D4F4, 434}, {0x0001D4F5, 65}, {0x0001D4F6, 119},
+
+{0x0001D4F7, 435}, {0x0001D4F8, 41}, {0x0001D4F9, 436}, {0x0001D40A, 422},
+
+{0x0001D40B, 64}, {0x0001D40C, 79}, {0x0001D40D, 66}, {0x0001D40E, 423},
+
+{0x0001D40F, 68}, {0x0001D400, 419}, {0x0001D401, 75}, {0x0001D402, 57},
+
+{0x0001D403, 81}, {0x0001D404, 77}, {0x0001D405, 78}, {0x0001D406, 420},
+
+{0x0001D407, 61}, {0x0001D408, 63}, {0x0001D409, 421}, {0x0001D41A, 431},
+
+{0x0001D41B, 432}, {0x0001D41C, 118}, {0x0001D41D, 82}, {0x0001D41E, 76},
+
+{0x0001D41F, 433}, {0x0001D410, 69}, {0x0001D411, 70}, {0x0001D412, 424},
+
+{0x0001D413, 425}, {0x0001D414, 426}, {0x0001D415, 100}, {0x0001D416, 427},
+
+{0x0001D417, 105}, {0x0001D418, 428}, {0x0001D419, 73}, {0x0001D42A, 437},
+
+{0x0001D42B, 438}, {0x0001D42C, 20}, {0x0001D42D, 439}, {0x0001D42E, 5},
+
+{0x0001D42F, 111}, {0x0001D420, 60}, {0x0001D421, 62}, {0x0001D422, 80},
+
+{0x0001D423, 83}, {0x0001D424, 434}, {0x0001D425, 65}, {0x0001D426, 119},
+
+{0x0001D427, 435}, {0x0001D428, 41}, {0x0001D429, 436}, {0x0001D43A, 420},
+
+{0x0001D43B, 61}, {0x0001D43C, 63}, {0x0001D43D, 421}, {0x0001D43E, 422},
+
+{0x0001D43F, 64}, {0x0001D430, 440}, {0x0001D431, 12}, {0x0001D432, 441},
+
+{0x0001D433, 442}, {0x0001D434, 419}, {0x0001D435, 75}, {0x0001D436, 57},
+
+{0x0001D437, 81}, {0x0001D438, 77}, {0x0001D439, 78}, {0x0001D44A, 427},
+
+{0x0001D44B, 105}, {0x0001D44C, 428}, {0x0001D44D, 73}, {0x0001D44E, 431},
+
+{0x0001D44F, 432}, {0x0001D440, 79}, {0x0001D441, 66}, {0x0001D442, 423},
+
+{0x0001D443, 68}, {0x0001D444, 69}, {0x0001D445, 70}, {0x0001D446, 424},
+
+{0x0001D447, 425}, {0x0001D448, 426}, {0x0001D449, 100}, {0x0001D45A, 119},
+
+{0x0001D45B, 435}, {0x0001D45C, 41}, {0x0001D45D, 436}, {0x0001D45E, 437},
+
+{0x0001D45F, 438}, {0x0001D450, 118}, {0x0001D451, 82}, {0x0001D452, 76},
+
+{0x0001D453, 433}, {0x0001D454, 60}, {0x0001D456, 80}, {0x0001D457, 83},
+
+{0x0001D458, 434}, {0x0001D459, 65}, {0x0001D46A, 57}, {0x0001D46B, 81},
+
+{0x0001D46C, 77}, {0x0001D46D, 78}, {0x0001D46E, 420}, {0x0001D46F, 61},
+
+{0x0001D460, 20}, {0x0001D461, 439}, {0x0001D462, 5}, {0x0001D463, 111},
+
+{0x0001D464, 440}, {0x0001D465, 12}, {0x0001D466, 441}, {0x0001D467, 442},
+
+{0x0001D468, 419}, {0x0001D469, 75}, {0x0001D47A, 424}, {0x0001D47B, 425},
+
+{0x0001D47C, 426}, {0x0001D47D, 100}, {0x0001D47E, 427}, {0x0001D47F, 105},
+
+{0x0001D470, 63}, {0x0001D471, 421}, {0x0001D472, 422}, {0x0001D473, 64},
+
+{0x0001D474, 79}, {0x0001D475, 66}, {0x0001D476, 423}, {0x0001D477, 68},
+
+{0x0001D478, 69}, {0x0001D479, 70}, {0x0001D48A, 80}, {0x0001D48B, 83},
+
+{0x0001D48C, 434}, {0x0001D48D, 65}, {0x0001D48E, 119}, {0x0001D48F, 435},
+
+{0x0001D480, 428}, {0x0001D481, 73}, {0x0001D482, 431}, {0x0001D483, 432},
+
+{0x0001D484, 118}, {0x0001D485, 82}, {0x0001D486, 76}, {0x0001D487, 433},
+
+{0x0001D488, 60}, {0x0001D489, 62}, {0x0001D49A, 441}, {0x0001D49B, 442},
+
+{0x0001D49C, 419}, {0x0001D49E, 57}, {0x0001D49F, 81}, {0x0001D490, 41},
+
+{0x0001D491, 436}, {0x0001D492, 437}, {0x0001D493, 438}, {0x0001D494, 20},
+
+{0x0001D495, 439}, {0x0001D496, 5}, {0x0001D497, 111}, {0x0001D498, 440},
+
+{0x0001D499, 12}, {0x0001D5AA, 422}, {0x0001D5AB, 64}, {0x0001D5AC, 79},
+
+{0x0001D5AD, 66}, {0x0001D5AE, 423}, {0x0001D5AF, 68}, {0x0001D5A0, 419},
+
+{0x0001D5A1, 75}, {0x0001D5A2, 57}, {0x0001D5A3, 81}, {0x0001D5A4, 77},
+
+{0x0001D5A5, 78}, {0x0001D5A6, 420}, {0x0001D5A7, 61}, {0x0001D5A8, 63},
+
+{0x0001D5A9, 421}, {0x0001D5BA, 431}, {0x0001D5BB, 432}, {0x0001D5BC, 118},
+
+{0x0001D5BD, 82}, {0x0001D5BE, 76}, {0x0001D5BF, 433}, {0x0001D5B0, 69},
+
+{0x0001D5B1, 70}, {0x0001D5B2, 424}, {0x0001D5B3, 425}, {0x0001D5B4, 426},
+
+{0x0001D5B5, 100}, {0x0001D5B6, 427}, {0x0001D5B7, 105}, {0x0001D5B8, 428},
+
+{0x0001D5B9, 73}, {0x0001D5CA, 437}, {0x0001D5CB, 438}, {0x0001D5CC, 20},
+
+{0x0001D5CD, 439}, {0x0001D5CE, 5}, {0x0001D5CF, 111}, {0x0001D5C0, 60},
+
+{0x0001D5C1, 62}, {0x0001D5C2, 80}, {0x0001D5C3, 83}, {0x0001D5C4, 434},
+
+{0x0001D5C5, 65}, {0x0001D5C6, 119}, {0x0001D5C7, 435}, {0x0001D5C8, 41},
+
+{0x0001D5C9, 436}, {0x0001D5DA, 420}, {0x0001D5DB, 61}, {0x0001D5DC, 63},
+
+{0x0001D5DD, 421}, {0x0001D5DE, 422}, {0x0001D5DF, 64}, {0x0001D5D0, 440},
+
+{0x0001D5D1, 12}, {0x0001D5D2, 441}, {0x0001D5D3, 442}, {0x0001D5D4, 419},
+
+{0x0001D5D5, 75}, {0x0001D5D6, 57}, {0x0001D5D7, 81}, {0x0001D5D8, 77},
+
+{0x0001D5D9, 78}, {0x0001D5EA, 427}, {0x0001D5EB, 105}, {0x0001D5EC, 428},
+
+{0x0001D5ED, 73}, {0x0001D5EE, 431}, {0x0001D5EF, 432}, {0x0001D5E0, 79},
+
+{0x0001D5E1, 66}, {0x0001D5E2, 423}, {0x0001D5E3, 68}, {0x0001D5E4, 69},
+
+{0x0001D5E5, 70}, {0x0001D5E6, 424}, {0x0001D5E7, 425}, {0x0001D5E8, 426},
+
+{0x0001D5E9, 100}, {0x0001D5FA, 119}, {0x0001D5FB, 435}, {0x0001D5FC, 41},
+
+{0x0001D5FD, 436}, {0x0001D5FE, 437}, {0x0001D5FF, 438}, {0x0001D5F0, 118},
+
+{0x0001D5F1, 82}, {0x0001D5F2, 76}, {0x0001D5F3, 433}, {0x0001D5F4, 60},
+
+{0x0001D5F5, 62}, {0x0001D5F6, 80}, {0x0001D5F7, 83}, {0x0001D5F8, 434},
+
+{0x0001D5F9, 65}, {0x0001D50A, 420}, {0x0001D50D, 421}, {0x0001D50E, 422},
+
+{0x0001D50F, 64}, {0x0001D500, 440}, {0x0001D501, 12}, {0x0001D502, 441},
+
+{0x0001D503, 442}, {0x0001D504, 419}, {0x0001D505, 75}, {0x0001D507, 81},
+
+{0x0001D508, 77}, {0x0001D509, 78}, {0x0001D51A, 427}, {0x0001D51B, 105},
+
+{0x0001D51C, 428}, {0x0001D51E, 431}, {0x0001D51F, 432}, {0x0001D510, 79},
+
+{0x0001D511, 66}, {0x0001D512, 423}, {0x0001D513, 68}, {0x0001D514, 69},
+
+{0x0001D516, 424}, {0x0001D517, 425}, {0x0001D518, 426}, {0x0001D519, 100},
+
+{0x0001D52A, 119}, {0x0001D52B, 435}, {0x0001D52C, 41}, {0x0001D52D, 436},
+
+{0x0001D52E, 437}, {0x0001D52F, 438}, {0x0001D520, 118}, {0x0001D521, 82},
+
+{0x0001D522, 76}, {0x0001D523, 433}, {0x0001D524, 60}, {0x0001D525, 62},
+
+{0x0001D526, 80}, {0x0001D527, 83}, {0x0001D528, 434}, {0x0001D529, 65},
+
+{0x0001D53B, 81}, {0x0001D53C, 77}, {0x0001D53D, 78}, {0x0001D53E, 420},
+
+{0x0001D530, 20}, {0x0001D531, 439}, {0x0001D532, 5}, {0x0001D533, 111},
+
+{0x0001D534, 440}, {0x0001D535, 12}, {0x0001D536, 441}, {0x0001D537, 442},
+
+{0x0001D538, 419}, {0x0001D539, 75}, {0x0001D54A, 424}, {0x0001D54B, 425},
+
+{0x0001D54C, 426}, {0x0001D54D, 100}, {0x0001D54E, 427}, {0x0001D54F, 105},
+
+{0x0001D540, 63}, {0x0001D541, 421}, {0x0001D542, 422}, {0x0001D543, 64},
+
+{0x0001D544, 79}, {0x0001D546, 423}, {0x0001D55A, 80}, {0x0001D55B, 83},
+
+{0x0001D55C, 434}, {0x0001D55D, 65}, {0x0001D55E, 119}, {0x0001D55F, 435},
+
+{0x0001D550, 428}, {0x0001D552, 431}, {0x0001D553, 432}, {0x0001D554, 118},
+
+{0x0001D555, 82}, {0x0001D556, 76}, {0x0001D557, 433}, {0x0001D558, 60},
+
+{0x0001D559, 62}, {0x0001D56A, 441}, {0x0001D56B, 442}, {0x0001D56C, 419},
+
+{0x0001D56D, 75}, {0x0001D56E, 57}, {0x0001D56F, 81}, {0x0001D560, 41},
+
+{0x0001D561, 436}, {0x0001D562, 437}, {0x0001D563, 438}, {0x0001D564, 20},
+
+{0x0001D565, 439}, {0x0001D566, 5}, {0x0001D567, 111}, {0x0001D568, 440},
+
+{0x0001D569, 12}, {0x0001D57A, 423}, {0x0001D57B, 68}, {0x0001D57C, 69},
+
+{0x0001D57D, 70}, {0x0001D57E, 424}, {0x0001D57F, 425}, {0x0001D570, 77},
+
+{0x0001D571, 78}, {0x0001D572, 420}, {0x0001D573, 61}, {0x0001D574, 63},
+
+{0x0001D575, 421}, {0x0001D576, 422}, {0x0001D577, 64}, {0x0001D578, 79},
+
+{0x0001D579, 66}, {0x0001D58A, 76}, {0x0001D58B, 433}, {0x0001D58C, 60},
+
+{0x0001D58D, 62}, {0x0001D58E, 80}, {0x0001D58F, 83}, {0x0001D580, 426},
+
+{0x0001D581, 100}, {0x0001D582, 427}, {0x0001D583, 105}, {0x0001D584, 428},
+
+{0x0001D585, 73}, {0x0001D586, 431}, {0x0001D587, 432}, {0x0001D588, 118},
+
+{0x0001D589, 82}, {0x0001D59A, 5}, {0x0001D59B, 111}, {0x0001D59C, 440},
+
+{0x0001D59D, 12}, {0x0001D59E, 441}, {0x0001D59F, 442}, {0x0001D590, 434},
+
+{0x0001D591, 65}, {0x0001D592, 119}, {0x0001D593, 435}, {0x0001D594, 41},
+
+{0x0001D595, 436}, {0x0001D596, 437}, {0x0001D597, 438}, {0x0001D598, 20},
+
+{0x0001D599, 439}, {0x0001D6A0, 440}, {0x0001D6A1, 12}, {0x0001D6A2, 441},
+
+{0x0001D6A3, 442}, {0x0001D60A, 57}, {0x0001D60B, 81}, {0x0001D60C, 77},
+
+{0x0001D60D, 78}, {0x0001D60E, 420}, {0x0001D60F, 61}, {0x0001D600, 20},
+
+{0x0001D601, 439}, {0x0001D602, 5}, {0x0001D603, 111}, {0x0001D604, 440},
+
+{0x0001D605, 12}, {0x0001D606, 441}, {0x0001D607, 442}, {0x0001D608, 419},
+
+{0x0001D609, 75}, {0x0001D61A, 424}, {0x0001D61B, 425}, {0x0001D61C, 426},
+
+{0x0001D61D, 100}, {0x0001D61E, 427}, {0x0001D61F, 105}, {0x0001D610, 63},
+
+{0x0001D611, 421}, {0x0001D612, 422}, {0x0001D613, 64}, {0x0001D614, 79},
+
+{0x0001D615, 66}, {0x0001D616, 423}, {0x0001D617, 68}, {0x0001D618, 69},
+
+{0x0001D619, 70}, {0x0001D62A, 80}, {0x0001D62B, 83}, {0x0001D62C, 434},
+
+{0x0001D62D, 65}, {0x0001D62E, 119}, {0x0001D62F, 435}, {0x0001D620, 428},
+
+{0x0001D621, 73}, {0x0001D622, 431}, {0x0001D623, 432}, {0x0001D624, 118},
+
+{0x0001D625, 82}, {0x0001D626, 76}, {0x0001D627, 433}, {0x0001D628, 60},
+
+{0x0001D629, 62}, {0x0001D63A, 441}, {0x0001D63B, 442}, {0x0001D63C, 419},
+
+{0x0001D63D, 75}, {0x0001D63E, 57}, {0x0001D63F, 81}, {0x0001D630, 41},
+
+{0x0001D631, 436}, {0x0001D632, 437}, {0x0001D633, 438}, {0x0001D634, 20},
+
+{0x0001D635, 439}, {0x0001D636, 5}, {0x0001D637, 111}, {0x0001D638, 440},
+
+{0x0001D639, 12}, {0x0001D64A, 423}, {0x0001D64B, 68}, {0x0001D64C, 69},
+
+{0x0001D64D, 70}, {0x0001D64E, 424}, {0x0001D64F, 425}, {0x0001D640, 77},
+
+{0x0001D641, 78}, {0x0001D642, 420}, {0x0001D643, 61}, {0x0001D644, 63},
+
+{0x0001D645, 421}, {0x0001D646, 422}, {0x0001D647, 64}, {0x0001D648, 79},
+
+{0x0001D649, 66}, {0x0001D65A, 76}, {0x0001D65B, 433}, {0x0001D65C, 60},
+
+{0x0001D65D, 62}, {0x0001D65E, 80}, {0x0001D65F, 83}, {0x0001D650, 426},
+
+{0x0001D651, 100}, {0x0001D652, 427}, {0x0001D653, 105}, {0x0001D654, 428},
+
+{0x0001D655, 73}, {0x0001D656, 431}, {0x0001D657, 432}, {0x0001D658, 118},
+
+{0x0001D659, 82}, {0x0001D66A, 5}, {0x0001D66B, 111}, {0x0001D66C, 440},
+
+{0x0001D66D, 12}, {0x0001D66E, 441}, {0x0001D66F, 442}, {0x0001D660, 434},
+
+{0x0001D661, 65}, {0x0001D662, 119}, {0x0001D663, 435}, {0x0001D664, 41},
+
+{0x0001D665, 436}, {0x0001D666, 437}, {0x0001D667, 438}, {0x0001D668, 20},
+
+{0x0001D669, 439}, {0x0001D67A, 422}, {0x0001D67B, 64}, {0x0001D67C, 79},
+
+{0x0001D67D, 66}, {0x0001D67E, 423}, {0x0001D67F, 68}, {0x0001D670, 419},
+
+{0x0001D671, 75}, {0x0001D672, 57}, {0x0001D673, 81}, {0x0001D674, 77},
+
+{0x0001D675, 78}, {0x0001D676, 420}, {0x0001D677, 61}, {0x0001D678, 63},
+
+{0x0001D679, 421}, {0x0001D68A, 431}, {0x0001D68B, 432}, {0x0001D68C, 118},
+
+{0x0001D68D, 82}, {0x0001D68E, 76}, {0x0001D68F, 433}, {0x0001D680, 69},
+
+{0x0001D681, 70}, {0x0001D682, 424}, {0x0001D683, 425}, {0x0001D684, 426},
+
+{0x0001D685, 100}, {0x0001D686, 427}, {0x0001D687, 105}, {0x0001D688, 428},
+
+{0x0001D689, 73}, {0x0001D69A, 437}, {0x0001D69B, 438}, {0x0001D69C, 20},
+
+{0x0001D69D, 439}, {0x0001D69E, 5}, {0x0001D69F, 111}, {0x0001D690, 60},
+
+{0x0001D691, 62}, {0x0001D692, 80}, {0x0001D693, 83}, {0x0001D694, 434},
+
+{0x0001D695, 65}, {0x0001D696, 119}, {0x0001D697, 435}, {0x0001D698, 41},
+
+{0x0001D699, 436}, {0x0001D7CE, 409}, {0x0001D7CF, 410}, {0x0001D7DA, 411},
+
+{0x0001D7DB, 412}, {0x0001D7DC, 413}, {0x0001D7DD, 414}, {0x0001D7DE, 415},
+
+{0x0001D7DF, 416}, {0x0001D7D0, 411}, {0x0001D7D1, 412}, {0x0001D7D2, 413},
+
+{0x0001D7D3, 414}, {0x0001D7D4, 415}, {0x0001D7D5, 416}, {0x0001D7D6, 417},
+
+{0x0001D7D7, 418}, {0x0001D7D8, 409}, {0x0001D7D9, 410}, {0x0001D7EA, 417},
+
+{0x0001D7EB, 418}, {0x0001D7EC, 409}, {0x0001D7ED, 410}, {0x0001D7EE, 411},
+
+{0x0001D7EF, 412}, {0x0001D7E0, 417}, {0x0001D7E1, 418}, {0x0001D7E2, 409},
+
+{0x0001D7E3, 410}, {0x0001D7E4, 411}, {0x0001D7E5, 412}, {0x0001D7E6, 413},
+
+{0x0001D7E7, 414}, {0x0001D7E8, 415}, {0x0001D7E9, 416}, {0x0001D7FA, 413},
+
+{0x0001D7FB, 414}, {0x0001D7FC, 415}, {0x0001D7FD, 416}, {0x0001D7FE, 417},
+
+{0x0001D7FF, 418}, {0x0001D7F0, 413}, {0x0001D7F1, 414}, {0x0001D7F2, 415},
+
+{0x0001D7F3, 416}, {0x0001D7F4, 417}, {0x0001D7F5, 418}, {0x0001D7F6, 409},
+
+{0x0001D7F7, 410}, {0x0001D7F8, 411}, {0x0001D7F9, 412}, {0x01CA, 24},
+
+{0x01CB, 25}, {0x01CC, 26}, {0x01C7, 21}, {0x01C8, 22},
+{0x01C9, 23},
+ {0x01F1, 27}, {0x01F2, 28}, {0x01F3, 29},
+{0x0132, 15}, {0x0133, 16},
+ {0x0149, 17}, {0x0152, 18},
+{0x0152, 18}, {0x0153, 19}, {0x0153, 19},
+ {0x017F, 20},
+{0x02BC, 30}, {0x02CB, 32}, {0x02CD, 33}, {0x02C6, 31},
+
+{0x02C8, 30}, {0x02DC, 35}, {0x02D0, 34}, {0x2A74, 259},
+{0x2A75, 260},
+ {0x2A76, 261}, {0x20AC, 54}, {0x20A8, 53},
+{0x200A, 0}, {0x200B, 36},
+ {0x2002, 0}, {0x2003, 0},
+{0x2004, 0}, {0x2005, 0}, {0x2006, 0}, {0x2008,
+ 0},
+
+{0x2009, 0}, {0x201A, 6}, {0x201B, 30}, {0x201C, 38},
+{0x201D, 38},
+ {0x201E, 39}, {0x201F, 38}, {0x2010, 3},
+{0x2011, 3}, {0x2012, 3}, {0x2013,
+ 3},
+ {0x2014, 37},
+{0x2015, 3}, {0x2018, 30}, {0x2019, 30}, {0x202F, 0},
+
+{0x2020, 40}, {0x2022, 41}, {0x2024, 42}, {0x2025, 43},
+{0x2026, 44},
+ {0x203A, 48}, {0x203C, 49}, {0x2035, 32},
+{0x2036, 45}, {0x2037, 46},
+ {0x2039, 47}, {0x2047, 50},
+{0x2048, 51}, {0x2049, 52}, {0x205F, 0},
+ {0x2060, 36},
+{0x2061, 36}, {0x2062, 36}, {0x2063, 36}, {0x21D0, 123},
+
+{0x21D2, 124}, {0x21D4, 125}, {0x210A, 60}, {0x210B, 61},
+{0x210C, 61},
+ {0x210D, 61}, {0x210E, 62}, {0x2100, 55},
+{0x2101, 56}, {0x2102, 57},
+ {0x2105, 58}, {0x2106, 59},
+{0x211A, 69}, {0x211B, 70}, {0x211C, 70},
+ {0x211D, 70},
+{0x2110, 63}, {0x2111, 63}, {0x2112, 64}, {0x2113, 65},
+
+{0x2115, 66}, {0x2116, 67}, {0x2119, 68}, {0x212C, 75},
+{0x212D, 57},
+ {0x212E, 76}, {0x212F, 76}, {0x2121, 71},
+{0x2122, 72}, {0x2124, 73},
+ {0x2126, 74}, {0x2128, 73},
+{0x2130, 77}, {0x2131, 78}, {0x2133, 79},
+ {0x2134, 41},
+{0x2139, 80}, {0x2145, 81}, {0x2146, 82}, {0x2147, 76},
+
+{0x2148, 80}, {0x2149, 83}, {0x215A, 91}, {0x215B, 92},
+{0x215C, 93},
+ {0x215D, 94}, {0x215E, 95}, {0x215F, 96},
+{0x2153, 84}, {0x2154, 85},
+ {0x2155, 86}, {0x2156, 87},
+{0x2157, 88}, {0x2158, 89}, {0x2159, 90},
+ {0x216A, 106},
+{0x216B, 107}, {0x216C, 64}, {0x216D, 57}, {0x216E, 81},
+
+{0x216F, 79}, {0x2160, 63}, {0x2161, 97}, {0x2162, 98},
+{0x2163, 99},
+ {0x2164, 100}, {0x2165, 101}, {0x2166, 102},
+{0x2167, 103}, {0x2168, 104},
+ {0x2169, 105}, {0x217A, 116},
+{0x217B, 117}, {0x217C, 65}, {0x217D, 118},
+ {0x217E, 82},
+{0x217F, 119}, {0x2170, 80}, {0x2171, 108}, {0x2172, 109},
+
+{0x2173, 110}, {0x2174, 111}, {0x2175, 112}, {0x2176, 113},
+{0x2177, 114},
+ {0x2178, 115}, {0x2179, 12}, {0x2190, 120},
+{0x2192, 121}, {0x2194, 122},
+ {0x22D8, 131}, {0x22D9, 132},
+{0x2212, 3}, {0x2215, 126}, {0x2216, 127},
+ {0x2217, 128},
+{0x2223, 129}, {0x223C, 35}, {0x2236, 34}, {0x226A, 2},
+
+{0x226B, 7}, {0x2264, 123}, {0x2265, 130}, {0x24AA, 222},
+{0x24AB, 223},
+ {0x24AC, 224}, {0x24AD, 225}, {0x24AE, 226},
+{0x24AF, 227}, {0x24A0, 212},
+ {0x24A1, 213}, {0x24A2, 214},
+{0x24A3, 215}, {0x24A4, 216}, {0x24A5, 217},
+ {0x24A6, 218},
+{0x24A7, 219}, {0x24A8, 220}, {0x24A9, 221}, {0x24BA, 237},
+
+{0x24BB, 238}, {0x24BC, 239}, {0x24BD, 240}, {0x24BE, 241},
+{0x24BF, 242},
+ {0x24B0, 228}, {0x24B1, 229}, {0x24B2, 230},
+{0x24B3, 231}, {0x24B4, 232},
+ {0x24B5, 233}, {0x24B6, 234},
+{0x24B7, 235}, {0x24B8, 1}, {0x24B9, 236},
+ {0x24CA, 252},
+{0x24CB, 253}, {0x24CC, 254}, {0x24CD, 255}, {0x24CE, 256},
+
+{0x24CF, 257}, {0x24C0, 243}, {0x24C1, 244}, {0x24C2, 245},
+{0x24C3, 246},
+ {0x24C4, 247}, {0x24C5, 248}, {0x24C6, 249},
+{0x24C7, 4}, {0x24C8, 250},
+ {0x24C9, 251}, {0x24DA, 218},
+{0x24DB, 219}, {0x24DC, 220}, {0x24DD, 221},
+ {0x24DE, 222},
+{0x24DF, 223}, {0x24D0, 208}, {0x24D1, 209}, {0x24D2, 210},
+
+{0x24D3, 211}, {0x24D4, 212}, {0x24D5, 213}, {0x24D6, 214},
+{0x24D7, 215},
+ {0x24D8, 216}, {0x24D9, 217}, {0x24EA, 258},
+{0x24E0, 224}, {0x24E1, 225},
+ {0x24E2, 226}, {0x24E3, 227},
+{0x24E4, 228}, {0x24E5, 229}, {0x24E6, 230},
+ {0x24E7, 231},
+{0x24E8, 232}, {0x24E9, 233}, {0x240A, 143}, {0x240B, 144},
+
+{0x240C, 145}, {0x240D, 146}, {0x240E, 147}, {0x240F, 148},
+{0x2400, 133},
+ {0x2401, 134}, {0x2402, 135}, {0x2403, 136},
+{0x2404, 137}, {0x2405, 138},
+ {0x2406, 139}, {0x2407, 140},
+{0x2408, 141}, {0x2409, 142}, {0x241A, 159},
+ {0x241B, 160},
+{0x241C, 161}, {0x241D, 162}, {0x241E, 163}, {0x241F, 164},
+
+{0x2410, 149}, {0x2411, 150}, {0x2412, 151}, {0x2413, 152},
+{0x2414, 153},
+ {0x2415, 154}, {0x2416, 155}, {0x2417, 156},
+{0x2418, 157}, {0x2419, 158},
+ {0x2420, 165}, {0x2421, 166},
+{0x2423, 33}, {0x2424, 167}, {0x246A, 178},
+ {0x246B, 179},
+{0x246C, 180}, {0x246D, 181}, {0x246E, 182}, {0x246F, 183},
+
+{0x2460, 168}, {0x2461, 169}, {0x2462, 170}, {0x2463, 171},
+{0x2464, 172},
+ {0x2465, 173}, {0x2466, 174}, {0x2467, 175},
+{0x2468, 176}, {0x2469, 177},
+ {0x247A, 174}, {0x247B, 175},
+{0x247C, 176}, {0x247D, 177}, {0x247E, 178},
+ {0x247F, 179},
+{0x2470, 184}, {0x2471, 185}, {0x2472, 186}, {0x2473, 187},
+
+{0x2474, 168}, {0x2475, 169}, {0x2476, 170}, {0x2477, 171},
+{0x2478, 172},
+ {0x2479, 173}, {0x248A, 190}, {0x248B, 191},
+{0x248C, 192}, {0x248D, 193},
+ {0x248E, 194}, {0x248F, 195},
+{0x2480, 180}, {0x2481, 181}, {0x2482, 182},
+ {0x2483, 183},
+{0x2484, 184}, {0x2485, 185}, {0x2486, 186}, {0x2487, 187},
+
+{0x2488, 188}, {0x2489, 189}, {0x249A, 206}, {0x249B, 207},
+{0x249C, 208},
+ {0x249D, 209}, {0x249E, 210}, {0x249F, 211},
+{0x2490, 196}, {0x2491, 197},
+ {0x2492, 198}, {0x2493, 199},
+{0x2494, 200}, {0x2495, 201}, {0x2496, 202},
+ {0x2497, 203},
+{0x2498, 204}, {0x2499, 205}, {0x25E6, 41}, {0x250C, 40},
+
+{0x2500, 3}, {0x2502, 129}, {0x251C, 40}, {0x2510, 40},
+{0x2514, 40},
+ {0x2518, 40}, {0x252C, 40}, {0x2524, 40},
+{0x253C, 40}, {0x2534, 40},
+ {0x30A0, 262}, {0x3000, 0},
+{0x32BA, 287}, {0x32BB, 288}, {0x32BC, 289},
+ {0x32BD, 290},
+{0x32BE, 291}, {0x32BF, 292}, {0x32B1, 278}, {0x32B2, 279},
+
+{0x32B3, 280}, {0x32B4, 281}, {0x32B5, 282}, {0x32B6, 283},
+{0x32B7, 284},
+ {0x32B8, 285}, {0x32B9, 286}, {0x325A, 272},
+{0x325B, 273}, {0x325C, 274},
+ {0x325D, 275}, {0x325E, 276},
+{0x325F, 277}, {0x3251, 263}, {0x3252, 264},
+ {0x3253, 265},
+{0x3254, 266}, {0x3255, 267}, {0x3256, 268}, {0x3257, 269},
+
+{0x3258, 270}, {0x3259, 271}, {0x33AA, 341}, {0x33AB, 342},
+{0x33AC, 343},
+ {0x33AD, 344}, {0x33AE, 345}, {0x33AF, 346},
+{0x33A0, 331}, {0x33A1, 332},
+ {0x33A2, 333}, {0x33A3, 334},
+{0x33A4, 335}, {0x33A5, 336}, {0x33A6, 337},
+ {0x33A7, 338},
+{0x33A8, 339}, {0x33A9, 340}, {0x33BA, 357}, {0x33BB, 358},
+
+{0x33BC, 359}, {0x33BD, 360}, {0x33BE, 361}, {0x33BF, 362},
+{0x33B0, 347},
+ {0x33B1, 348}, {0x33B2, 349}, {0x33B3, 350},
+{0x33B4, 351}, {0x33B5, 352},
+ {0x33B6, 353}, {0x33B7, 354},
+{0x33B8, 355}, {0x33B9, 356}, {0x33CA, 371},
+ {0x33CB, 372},
+{0x33CC, 373}, {0x33CD, 374}, {0x33CE, 375}, {0x33CF, 376},
+
+{0x33C2, 363}, {0x33C3, 364}, {0x33C4, 365}, {0x33C5, 366},
+{0x33C6, 367},
+ {0x33C7, 368}, {0x33C8, 369}, {0x33C9, 370},
+{0x33DA, 387}, {0x33DB, 388},
+ {0x33DC, 389}, {0x33DD, 390},
+{0x33D0, 377}, {0x33D1, 378}, {0x33D2, 379},
+ {0x33D3, 380},
+{0x33D4, 381}, {0x33D5, 382}, {0x33D6, 383}, {0x33D7, 384},
+
+{0x33D8, 385}, {0x33D9, 386}, {0x3371, 293}, {0x3372, 294},
+{0x3373, 295},
+ {0x3374, 296}, {0x3375, 297}, {0x3376, 298},
+{0x338A, 309}, {0x338B, 310},
+ {0x338C, 311}, {0x338D, 312},
+{0x338E, 313}, {0x338F, 314}, {0x3380, 299},
+ {0x3381, 300},
+{0x3382, 301}, {0x3383, 302}, {0x3384, 303}, {0x3385, 304},
+
+{0x3386, 305}, {0x3387, 306}, {0x3388, 307}, {0x3389, 308},
+{0x339A, 325},
+ {0x339B, 326}, {0x339C, 327}, {0x339D, 328},
+{0x339E, 329}, {0x339F, 330},
+ {0x3390, 315}, {0x3391, 316},
+{0x3392, 317}, {0x3393, 318}, {0x3394, 319},
+ {0x3395, 320},
+{0x3396, 321}, {0x3397, 322}, {0x3398, 323}, {0x3399, 324},
+
+{0, 0}
+};
+
+
+char *translit[] =
+ {
+" ", "(C)", "<<", "-",
+"(R)", "u", ",", ">>",
+" 1/4 ", " 1/2 ",
+" 3/4 ", "AE",
+"x", "ss", "ae", "IJ",
+"ij", "'n", "OE", "oe",
+"s", "LJ", "Lj", "lj",
+
+"NJ", "Nj", "nj", "DZ",
+"Dz", "dz", "'", "^",
+"`", "_", ":", "~",
+"", "--", "\"", ",,",
+
+"+", "o", ".", "..",
+"...", "``", "```", "<",
+">", "!!", "??", "?!",
+"!?", "Rs", "EUR",
+"a/c",
+"a/s", "C", "c/o", "c/u",
+"g", "H", "h", "I",
+"L", "l", "N", "No",
+"P", "Q", "R",
+"TEL",
+"(TM)", "Z", "Ohm", "B",
+"e", "E", "F", "M",
+"i", "D", "d", "j",
+" 1/3 ", " 2/3 ",
+" 1/5 ", " 2/5 ",
+" 3/5 ", " 4/5 ", " 1/6 ", " 5/6 ",
+" 1/8 ", " 3/8 ", " 5/8 ", " 7/8 ",
+
+" 1/", "II", "III", "IV",
+"V", "VI", "VII", "VIII",
+"IX", "X", "XI", "XII",
+"ii", "iii",
+"iv", "v",
+"vi", "vii", "viii", "ix",
+"xi", "xii", "c", "m",
+"<-", "->", "<->", "<=",
+
+"=>", "<=>", "/", "\\",
+"*", "|", ">=", "<<<",
+">>>", "NUL", "SOH", "STX",
+"ETX", "EOT",
+"ENQ", "ACK",
+"BEL", "BS", "HT", "LF",
+"VT", "FF", "CR", "SO",
+"SI", "DLE", "DC1", "DC2",
+
+"DC3", "DC4", "NAK", "SYN",
+"ETB", "CAN", "EM", "SUB",
+"ESC", "FS", "GS", "RS",
+"US",
+"SP", "DEL", "NL",
+"(1)", "(2)", "(3)", "(4)",
+"(5)", "(6)", "(7)", "(8)",
+"(9)", "(10)",
+"(11)", "(12)",
+"(13)", "(14)", "(15)", "(16)",
+"(17)", "(18)", "(19)", "(20)",
+"1.",
+"2.", "3.", "4.",
+"5.", "6.", "7.", "8.",
+"9.", "10.", "11.", "12.",
+"13.", "14.", "15.",
+"16.",
+"17.", "18.", "19.", "20.",
+"(a)", "(b)", "(c)", "(d)",
+"(e)", "(f)", "(g)", "(h)",
+
+"(i)", "(j)", "(k)", "(l)",
+"(m)", "(n)", "(o)", "(p)",
+"(q)", "(r)", "(s)", "(t)",
+
+"(u)", "(v)", "(w)", "(x)",
+"(y)", "(z)", "(A)", "(B)",
+"(D)", "(E)", "(F)", "(G)",
+
+"(H)", "(I)", "(J)", "(K)",
+"(L)", "(M)", "(N)", "(O)",
+"(P)", "(Q)", "(S)", "(T)",
+
+"(U)", "(V)", "(W)", "(X)",
+"(Y)", "(Z)", "(0)", "::=",
+"==", "===", "=", "(21)",
+"(22)",
+"(23)", "(24)", "(25)",
+"(26)", "(27)", "(28)", "(29)",
+"(30)", "(31)", "(32)", "(33)",
+
+"(34)", "(35)", "(36)", "(37)",
+"(38)", "(39)", "(40)", "(41)",
+"(42)", "(43)", "(44)",
+"(45)",
+"(46)", "(47)", "(48)", "(49)",
+"(50)", "hPa", "da", "AU",
+"bar", "oV", "pc",
+"pA",
+"nA", "uA", "mA", "kA",
+"KB", "MB", "GB", "cal",
+"kcal", "pF", "nF", "uF",
+"ug",
+"mg", "kg", "Hz",
+"kHz", "MHz", "GHz", "THz",
+"ul", "ml", "dl", "kl",
+"fm", "nm", "um",
+"mm",
+"cm", "km", "mm^2", "cm^2",
+"m^2", "km^2", "mm^3", "cm^3",
+"m^3", "km^3", "m/s",
+"m/s^2",
+"Pa", "kPa", "MPa", "GPa",
+"rad", "rad/s", "rad/s^2", "ps",
+"ns", "us", "ms",
+"pV",
+"nV", "uV", "mV", "kV",
+"MV", "pW", "nW", "uW",
+"mW", "kW", "MW", "a.m.",
+"Bq",
+"cc", "cd", "C/kg",
+"Co.", "dB", "Gy", "ha",
+"HP", "in", "KK", "KM",
+"kt", "lm", "ln",
+"log",
+"lx", "mb", "mil", "mol",
+"PH", "p.m.", "PPM", "PR",
+"sr", "Sv", "Wb", "ff",
+"fi",
+"fl", "ffi", "ffl",
+"st", ";", "?", "!",
+"(", ")", "{", "}",
+"#", "&", "$", "%",
+"@",
+"0", "1", "2",
+"3", "4", "5", "6",
+"7", "8", "9", "A",
+"G", "J", "K", "O",
+"S", "T", "U",
+"W",
+"Y", "[", "]", "a",
+"b", "f", "k", "n",
+"p", "q", "r", "t",
+"w", "y", "z", "z",
+ /* German */ "Ae", "Oe", "Ue", "ue",
+ /* Scandinavian */ "Aa", "aa"
+};
+
+
+static void
+addKeyword (struct EXTRACTOR_Keywords **list,
+char *keyword,
+
+EXTRACTOR_KeywordType type)
+{
+
+EXTRACTOR_KeywordList * next;
+
+next = malloc (sizeof (EXTRACTOR_KeywordList));
+
+next->next = *list;
+
+next->keyword = strdup (keyword);
+
+next->keywordType = type;
+
+*list = next;
+
+}
+
+
+struct EXTRACTOR_Keywords *
+libextractor_translit_extract (const char *filename,
+const char *data,
+
+size_t size,
+struct EXTRACTOR_Keywords *prev)
+{
+
+struct EXTRACTOR_Keywords *pos;
+
+unsigned int mem, src, dest, len;
+
+char *transl;
+
+
+pos = prev;
+
+
+mem = 256;
+
+transl = malloc (mem + 1);
+
+
+
+while (pos != NULL)
+
+ {
+
+int charlen = 0;
+
+char *srcdata = pos->keyword;
+
+
+len = strlen (pos->keyword);
+
+
+for (src = 0, dest = 0; src <= len; src += charlen)
+ {
+
+char c;
+
+int trlen;
+
+long long unicode;
+
+int idx;
+
+char *tr;
+
+
-static void addKeyword(struct EXTRACTOR_Keywords ** list,
- char * keyword,
- EXTRACTOR_KeywordType type) {
- EXTRACTOR_KeywordList * next;
- next = malloc(sizeof(EXTRACTOR_KeywordList));
- next->next = *list;
- next->keyword = strdup(keyword);
- next->keywordType = type;
- *list = next;
-}
+ /* Get length of character */
+ c = srcdata[src];
+
+if ((c & 0xC0) == 0xC0)
+
+ /* UTF-8 char */
+ if ((c & 0xE0) == 0xE0)
+
+if ((c & 0xF0) == 0xF0)
+
+charlen = 4;
+
+ else
+
+charlen = 3;
+
+ else
+
+charlen = 2;
+
+ else
+
+charlen = 1;
+
+
+if (src + charlen - 1 > len)
+ {
+
+ /* incomplete UTF-8 */
+ src = len;
+
+continue;
+
+}
+
-struct EXTRACTOR_Keywords *
-libextractor_translit_extract(const char * filename,
- const char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev) {
- struct EXTRACTOR_Keywords * pos;
- unsigned int mem, src, dest, len;
- char * transl;
+ /* Copy character to destination */
+ if (charlen > 1)
+ {
+
+unicode = 0;
+
+
+if (charlen == 2)
+ {
+
+ /* 5 bits from the first byte and 6 bits from the second.
+ 64 = 2^6 */
+ unicode =
+ ((srcdata[src] & 0x1F) * 64) | (srcdata[src + 1] & 0x3F);
+
+}
+
+ else if (charlen == 3)
+ {
+
+ /* 4 bits from the first byte and 6 bits from the second
and third
+ byte. 4096 = 2^12 */
+ unicode = ((srcdata[src] & 0xF) * 4096) |
+ ((srcdata[src + 1] & 0x3F) *
+ 64) | (srcdata[src + 2] & 0x3F);
+
+}
+
+ else if (charlen == 4)
+ {
+
+ /* 3 bits from the first byte and 6 bits from the second,
third
+ and fourth byte. 262144 = 2^18 */
+ unicode = ((srcdata[src] & 7) * 262144) |
+ ((srcdata[src] & 0xF) * 4096) |
+ ((srcdata[src + 1] & 0x3F) *
+ 64) | (srcdata[src + 2] & 0x3F);
+
+}
+
- pos = prev;
+ /* Look it up */
+ idx = 0;
+
+tr = srcdata + src;
+
+trlen = charlen;
+
+while (chars[idx][0])
+ {
+
+if (unicode == chars[idx][0])
+ {
+
+ /* Found it */
+ tr = translit[chars[idx][1]];
+
+trlen = strlen (tr);
+
+break;
+
+}
+
+idx++;
+
+}
+
+}
+
+ else
+
+trlen = 1;
+
+
+if (dest + trlen > mem)
+ {
+
+mem = dest + trlen;
+
+transl = (char *) realloc (transl, mem + 1);
+
+}
+
+
+if (charlen > 1)
+ {
+
+ /* Copy character to destination string */
+ memcpy (transl + dest, tr, trlen);
+
+}
+
+ else
+
+transl[dest] = c;
+
+
+dest += trlen;
+
+}
+
+
+transl[dest] = 0;
+
+
+if (strcmp (pos->keyword, transl) != 0)
+
+addKeyword (&prev, transl, EXTRACTOR_UNKNOWN);
+
+
+pos = pos->next;
+
+}
+
+
+free (transl);
+
+
+return prev;
+
+}
+
- mem = 256;
- transl = malloc(mem + 1);
-
-
- while (pos != NULL)
- {
- int charlen = 0;
- char *srcdata = pos->keyword;
-
- len = strlen(pos->keyword);
-
- for (src = 0, dest = 0; src <= len; src += charlen){
- char c;
- int trlen;
- long long unicode;
- int idx;
- char *tr;
-
-
- /* Get length of character */
- c = srcdata[src];
- if ((c & 0xC0) == 0xC0)
- /* UTF-8 char */
- if ((c & 0xE0) == 0xE0)
- if ((c & 0xF0) == 0xF0)
- charlen = 4;
- else
- charlen = 3;
- else
- charlen = 2;
- else
- charlen = 1;
-
- if (src + charlen - 1 > len) {
- /* incomplete UTF-8 */
- src = len;
- continue;
- }
-
- /* Copy character to destination */
- if (charlen > 1) {
- unicode = 0;
-
- if (charlen == 2) {
- /* 5 bits from the first byte and 6 bits from the second.
- 64 = 2^6*/
- unicode = ((srcdata[src] & 0x1F) * 64) | (srcdata[src + 1] & 0x3F);
- }
- else if (charlen == 3) {
- /* 4 bits from the first byte and 6 bits from the second and third
- byte. 4096 = 2^12 */
- unicode = ((srcdata[src] & 0xF) * 4096) |
- ((srcdata[src + 1] & 0x3F) * 64) | (srcdata[src + 2] & 0x3F);
- }
- else if (charlen == 4) {
- /* 3 bits from the first byte and 6 bits from the second, third
- and fourth byte. 262144 = 2^18 */
- unicode = ((srcdata[src] & 7) * 262144) |
- ((srcdata[src] & 0xF) * 4096) |
- ((srcdata[src + 1] & 0x3F) * 64) | (srcdata[src + 2] & 0x3F);
- }
-
- /* Look it up */
- idx = 0;
- tr = srcdata + src;
- trlen = charlen;
- while(chars[idx][0]) {
- if (unicode == chars[idx][0]) {
- /* Found it */
- tr = translit[chars[idx][1]];
- trlen = strlen(tr);
- break;
- }
- idx++;
- }
- }
- else
- trlen = 1;
-
- if (dest + trlen > mem) {
- mem = dest + trlen;
- transl = (char *) realloc(transl, mem + 1);
- }
-
- if (charlen > 1) {
- /* Copy character to destination string */
- memcpy(transl + dest, tr, trlen);
- }
- else
- transl[dest] = c;
-
- dest += trlen;
- }
-
- transl[dest] = 0;
-
- if(strcmp(pos->keyword, transl) != 0)
- addKeyword(&prev, transl, EXTRACTOR_UNKNOWN);
-
- pos = pos->next;
- }
-
- free(transl);
-
- return prev;
-}
Modified: Extractor/src/plugins/wavextractor.c
===================================================================
--- Extractor/src/plugins/wavextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/wavextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -30,11 +30,12 @@
#include "extractor.h"
#include "pack.h"
-static void addKeyword(struct EXTRACTOR_Keywords ** list,
- char * keyword,
- EXTRACTOR_KeywordType type) {
- EXTRACTOR_KeywordList * next;
- next = malloc(sizeof(EXTRACTOR_KeywordList));
+static void
+addKeyword (struct EXTRACTOR_Keywords **list,
+ char *keyword, EXTRACTOR_KeywordType type)
+{
+ EXTRACTOR_KeywordList *next;
+ next = malloc (sizeof (EXTRACTOR_KeywordList));
next->next = *list;
next->keyword = keyword;
next->keywordType = type;
@@ -42,16 +43,23 @@
}
#if BIG_ENDIAN_HOST
-static short toLittleEndian16(short in) {
- char *ptr = (char *)∈
+static short
+toLittleEndian16 (short in)
+{
+ char *ptr = (char *) ∈
return ((ptr[1] & 0xFF) << 8) | (ptr[0] & 0xFF);
}
-static unsigned int toLittleEndian32(unsigned int in) {
- char *ptr = (char *)∈
+static unsigned int
+toLittleEndian32 (unsigned int in)
+{
+ char *ptr = (char *) ∈
- return ((ptr[3] & 0xFF) << 24) | ((ptr[2] & 0xFF) << 16) | ((ptr[1] & 0xFF)
<< 8) | (ptr[0] & 0xFF);
+ return ((ptr[3] & 0xFF) << 24) | ((ptr[2] & 0xFF) << 16) | ((ptr[1] & 0xFF)
+ << 8) | (ptr[0]
+ &
+ 0xFF);
}
#endif
@@ -62,60 +70,54 @@
22 2 bytes <channels> // Channels: 1 = mono, 2 = stereo
24 4 bytes <sample rate> // Samples per second: e.g., 44100
*/
-struct EXTRACTOR_Keywords * libextractor_wav_extract(char * filename,
- const unsigned char * buf,
- size_t bufLen,
- struct EXTRACTOR_Keywords
* prev) {
+struct EXTRACTOR_Keywords *
+libextractor_wav_extract (char *filename,
+ const unsigned char *buf,
+ size_t bufLen, struct EXTRACTOR_Keywords *prev)
+{
unsigned short channels;
unsigned short sampleSize;
unsigned int sampleRate;
unsigned int dataLen;
unsigned int samples;
- char * scratch;
+ char *scratch;
- if ( (bufLen < 44) ||
- (buf[0] != 'R' || buf[1] != 'I' ||
- buf[2] != 'F' || buf[3] != 'F' ||
- buf[8] != 'W' || buf[9] != 'A' ||
- buf[10] != 'V' || buf[11] != 'E' ||
- buf[12] != 'f' || buf[13] != 'm' ||
- buf[14] != 't' || buf[15] != ' ') )
- return prev; /* not a WAV file */
+ if ((bufLen < 44) ||
+ (buf[0] != 'R' || buf[1] != 'I' ||
+ buf[2] != 'F' || buf[3] != 'F' ||
+ buf[8] != 'W' || buf[9] != 'A' ||
+ buf[10] != 'V' || buf[11] != 'E' ||
+ buf[12] != 'f' || buf[13] != 'm' || buf[14] != 't' || buf[15] != ' '))
+ return prev; /* not a WAV file */
- channels = *((unsigned short *)&buf[22]);
- sampleRate = *((unsigned int *)&buf[24]);
- sampleSize = *((unsigned short *)&buf[34]);
- dataLen = *((unsigned int *)&buf[40]);
+ channels = *((unsigned short *) &buf[22]);
+ sampleRate = *((unsigned int *) &buf[24]);
+ sampleSize = *((unsigned short *) &buf[34]);
+ dataLen = *((unsigned int *) &buf[40]);
#if BIG_ENDIAN_HOST
- channels = toLittleEndian16(channels);
- sampleSize = toLittleEndian16(sampleSize);
- sampleRate = toLittleEndian32(sampleRate);
- dataLen = toLittleEndian32(dataLen);
+ channels = toLittleEndian16 (channels);
+ sampleSize = toLittleEndian16 (sampleSize);
+ sampleRate = toLittleEndian32 (sampleRate);
+ dataLen = toLittleEndian32 (dataLen);
#endif
if (sampleSize != 8 && sampleSize != 16)
- return prev; /* invalid sample size found in wav file */
+ return prev; /* invalid sample size found in wav file */
if (channels == 0)
- return prev; /* invalid channels value -- avoid division by 0! */
+ return prev; /* invalid channels value -- avoid division by
0! */
samples = dataLen / (channels * (sampleSize >> 3));
- scratch = malloc(256);
- snprintf(scratch,
- 256,
- "%u ms, %d Hz, %s",
- (samples < sampleRate)
- ? (samples * 1000 / sampleRate)
- : (samples / sampleRate) * 1000,
- sampleRate,
- channels == 1 ?
- _("mono") : _("stereo"));
- addKeyword(&prev,
- scratch,
- EXTRACTOR_FORMAT);
- addKeyword(&prev,
- strdup("audio/x-wav"),
- EXTRACTOR_MIMETYPE);
+ scratch = malloc (256);
+ snprintf (scratch,
+ 256,
+ "%u ms, %d Hz, %s",
+ (samples < sampleRate)
+ ? (samples * 1000 / sampleRate)
+ : (samples / sampleRate) * 1000,
+ sampleRate, channels == 1 ? _("mono") : _("stereo"));
+ addKeyword (&prev, scratch, EXTRACTOR_FORMAT);
+ addKeyword (&prev, strdup ("audio/x-wav"), EXTRACTOR_MIMETYPE);
return prev;
}
Modified: Extractor/src/plugins/zipextractor.c
===================================================================
--- Extractor/src/plugins/zipextractor.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/plugins/zipextractor.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -36,8 +36,8 @@
No Copyright 2003 Julia Wolf
- */
-
+ */
+
/*
* This file is part of libextractor.
* (C) 2002, 2003 Vidyut Samanta and Christian Grothoff
@@ -56,344 +56,555 @@
* 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"
-
+
#define DEBUG_EXTRACT_ZIP 0
+
-
/* In a zipfile there are two kinds of comments. One is a big one for the
entire .zip, it's usually a BBS ad. The other is a small comment on each
individual file; most people don't use this.
- */
+ */
-/* TODO: zip_entry linked list is handeled kinda messily, should clean up
(maybe) */
+/* TODO: zip_entry linked list is handeled kinda messily, should clean up
(maybe) */
+
+typedef struct
+{
+
+char *filename;
+
+char *comment;
+
+void *next;
+
+} zip_entry;
+
+
+
-typedef struct {
- char *filename;
- char *comment;
- void *next;
-} zip_entry;
+/* mimetype = application/zip */
+struct EXTRACTOR_Keywords *
+libextractor_zip_extract (const char *filename,
+const unsigned char *data,
+
+size_t size,
+struct EXTRACTOR_Keywords *prev)
+{
+
+void *tmp;
+
+zip_entry * info;
+
+zip_entry * start;
+
+char *filecomment = NULL;
+
+const unsigned char *pos;
+
+unsigned int offset, stop;
+
+unsigned int name_length, extra_length, comment_length;
+
+unsigned int filecomment_length;
+
+unsigned int entry_total, entry_count;
+
+EXTRACTOR_KeywordList * keyword;
+
+const char *mimetype;
+
+
+mimetype = EXTRACTOR_extractLast (EXTRACTOR_MIMETYPE,
+prev);
+
+if (NULL != mimetype)
+ {
+
+if ((0 != strcmp (mimetype, "application/x-zip")) &&
+ (0 != strcmp (mimetype, "application/zip")))
+ {
+
+ /* we think we already know what's in here,
+ and it is not a zip */
+ return prev;
+
+}
+
+}
+
+ /* I think the smallest zipfile you can have is about 120 bytes */
+ if ((NULL == data) || (size < 100))
+
+return prev;
+
+
+if (!
+ (('P' == data[0]) && ('K' == data[1]) && (0x03 == data[2])
+ && (0x04 == data[3])))
+
+return prev;
+
+ /* The filenames for each file in a zipfile are stored in two locations.
+ * There is one at the start of each entry, just before the compressed
data,
+ * and another at the end in a 'central directory structure'.
+ *
+ * In order to catch self-extracting executables, we scan backwards from
the end
+ * of the file looking for the central directory structure. The previous
version
+ * of this went forewards through the local headers, but that only works
for plain
+ * vanilla zip's and I don't feel like writing a special case for each of
the dozen
+ * self-extracting executable stubs.
+ *
+ * This assumes that the zip file is considered to be
non-corrupt/non-truncated.
+ * If it is truncated then it's not considered to be a zip and skipped.
+ *
+ */
+
+ /* From appnote.iz and appnote.txt (more or less)
+ *
+ * (this is why you always need to put in the last floppy if you span
disks)
+ *
+ * 0- 3 end of central dir signature 4 bytes (0x06054b50) P K ^E ^F
+ * 4- 5 number of this disk 2 bytes
+ * 6- 7 number of the disk with the
+ * start of the central directory 2 bytes
+ * 8- 9 total number of entries in
+ * the central dir on this disk 2 bytes
+ * 10-11 total number of entries in
+ * the central dir 2 bytes
+ * 12-15 size of the central directory 4 bytes
+ * 16-19 offset of start of central
+ * directory with respect to
+ * the starting disk number 4 bytes
+ * 20-21 zipfile comment length 2 bytes
+ * 22-?? zipfile comment (variable size) max length 65536 bytes
+ */
+
-/* mimetype = application/zip */
-struct EXTRACTOR_Keywords *
-libextractor_zip_extract(const char * filename,
- const unsigned char * data,
- size_t size,
- struct EXTRACTOR_Keywords * prev) {
- void * tmp;
- zip_entry * info;
- zip_entry * start;
- char *filecomment = NULL;
- const unsigned char * pos;
- unsigned int offset, stop;
- unsigned int name_length, extra_length, comment_length;
- unsigned int filecomment_length;
- unsigned int entry_total, entry_count;
- EXTRACTOR_KeywordList * keyword;
- const char * mimetype;
+ /* the signature can't be more than 22 bytes from the end */
+ offset = size - 22;
+
+pos = &data[offset];
+
+
+stop = 0;
+
+if (((signed int) size - 65556) > 0)
+
+stop = size - 65556;
+
- mimetype = EXTRACTOR_extractLast(EXTRACTOR_MIMETYPE,
- prev);
- if (NULL != mimetype) {
- if ( (0 != strcmp(mimetype, "application/x-zip")) &&
- (0 != strcmp(mimetype, "application/zip")) ) {
- /* we think we already know what's in here,
- and it is not a zip */
- return prev;
- }
- }
-
- /* I think the smallest zipfile you can have is about 120 bytes */
- if ( (NULL==data) || (size < 100) )
- return prev;
-
- if ( !( ('P'==data[0]) && ('K'==data[1]) && (0x03==data[2]) &&
(0x04==data[3])) )
- return prev;
-
- /* The filenames for each file in a zipfile are stored in two locations.
- * There is one at the start of each entry, just before the compressed data,
- * and another at the end in a 'central directory structure'.
- *
- * In order to catch self-extracting executables, we scan backwards from the
end
- * of the file looking for the central directory structure. The previous
version
- * of this went forewards through the local headers, but that only works for
plain
- * vanilla zip's and I don't feel like writing a special case for each of
the dozen
- * self-extracting executable stubs.
- *
- * This assumes that the zip file is considered to be
non-corrupt/non-truncated.
- * If it is truncated then it's not considered to be a zip and skipped.
- *
- */
-
- /* From appnote.iz and appnote.txt (more or less)
- *
- * (this is why you always need to put in the last floppy if you span
disks)
- *
- * 0- 3 end of central dir signature 4 bytes (0x06054b50) P K ^E ^F
- * 4- 5 number of this disk 2 bytes
- * 6- 7 number of the disk with the
- * start of the central directory 2 bytes
- * 8- 9 total number of entries in
- * the central dir on this disk 2 bytes
- * 10-11 total number of entries in
- * the central dir 2 bytes
- * 12-15 size of the central directory 4 bytes
- * 16-19 offset of start of central
- * directory with respect to
- * the starting disk number 4 bytes
- * 20-21 zipfile comment length 2 bytes
- * 22-?? zipfile comment (variable size) max length 65536 bytes
- */
-
-
- /* the signature can't be more than 22 bytes from the end */
- offset = size-22;
- pos = &data[offset];
-
- stop = 0;
- if ( ((signed int)size-65556) > 0)
- stop = size-65556;
-
- /* not using int 0x06054b50 so that we don't have to deal with endianess
issues.
- break out if we go more than 64K backwards and havn't found it, or if we
hit the
- begining of the file. */
-
- while ( ( !( ('P'==pos[0]) && ('K'==pos[1]) && (0x05==pos[2]) &&
(0x06==pos[3])) ) &&
- (offset > stop) )
- pos = &data[offset--];
-
- if (offset==stop) {
+ /* not using int 0x06054b50 so that we don't have to deal with endianess
issues.
+ break out if we go more than 64K backwards and havn't found it, or if
we hit the
+ begining of the file. */
+
+while ((!
+ (('P' == pos[0]) && ('K' == pos[1]) && (0x05 == pos[2])
+ && (0x06 == pos[3]))) &&
+(offset > stop))
+
+pos = &data[offset--];
+
+
+if (offset == stop)
+ {
+
#if DEBUG_EXTRACT_ZIP
- fprintf(stderr,
- "Did not find end of central directory structure signature. offset:
%i\n",
- offset);
-#endif
- return prev;
- }
+ fprintf (stderr,
+
+"Did not find end of central directory structure signature. offset: %i\n",
+
+offset);
+
+#endif /*
+ */
+ return prev;
+
+}
+
- /* offset should now point to the start of the end-of-central directory
structure */
- /* and pos[0] should be pointing there too */
- /* so slurp down filecomment while here... */
-
- filecomment_length = pos[20] + (pos[21]<<8);
- if (filecomment_length + offset + 22 > size) {
- return prev; /* invalid zip file format! */
- }
- filecomment = NULL;
- if (filecomment_length > 0) {
- filecomment = malloc(filecomment_length+1);
- memcpy(filecomment,
- &pos[22],
- filecomment_length);
- filecomment[filecomment_length] = '\0';
- }
-
-
- if ( (0!=pos[4])&&(0!=pos[5]) ) {
+ /* offset should now point to the start of the end-of-central directory
structure */
+ /* and pos[0] should be pointing there too */
+ /* so slurp down filecomment while here... */
+
+filecomment_length = pos[20] + (pos[21] << 8);
+
+if (filecomment_length + offset + 22 > size)
+ {
+
+return prev; /* invalid zip file format! */
+
+}
+
+filecomment = NULL;
+
+if (filecomment_length > 0)
+ {
+
+filecomment = malloc (filecomment_length + 1);
+
+memcpy (filecomment,
+&pos[22],
+filecomment_length);
+
+filecomment[filecomment_length] = '\0';
+
+}
+
+
+
+if ((0 != pos[4]) && (0 != pos[5]))
+ {
+
#if DEBUG_EXTRACT_ZIP
- fprintf(stderr,
- "WARNING: This seems to be the last disk in a multi-volume"
- " ZIP archive, and so this might not work.\n");
-#endif
- }
- if ( (pos[8]!=pos[10])&&(pos[9]!=pos[11]) ) {
+ fprintf (stderr,
+
+"WARNING: This seems to be the last disk in a multi-volume"
+
+ " ZIP archive, and so this might not work.\n");
+
+#endif /*
+ */
+ }
+
+if ((pos[8] != pos[10]) && (pos[9] != pos[11]))
+ {
+
#if DEBUG_EXTRACT_ZIP
- fprintf(stderr,
- "WARNING: May not be able to find all the files in this"
- " ZIP archive (no multi-volume support right now).\n");
-#endif
- }
+ fprintf (stderr,
+
+"WARNING: May not be able to find all the files in this"
+ " ZIP archive (no multi-volume support right now).\n");
+
+#endif /*
+ */
+ }
+
+
+entry_total = pos[10] + (pos[11] << 8);
+
+entry_count = 0;
+
- entry_total = pos[10]+(pos[11]<<8);
- entry_count = 0;
+ /* jump to start of central directory, ASSUMING that the starting disk
that it's on is disk 0 */
+ /* starting disk would otherwise be pos[6]+pos[7]<<8 */
+
+offset = pos[16] + (pos[17] << 8) + (pos[18] << 16) + (pos[19] << 24); /*
offset of cent-dir from start of disk 0 */
+
+ /* stop = pos[12] + (pos[13]<<8) + (pos[14]<<16) + (pos[15]<<24); *//*
length of central dir */
+ if (offset + 46 > size)
+ {
+
+ /* not a zip */
+ if (filecomment != NULL)
+
+free (filecomment);
+
+return prev;
+
+}
+
+pos = &data[offset]; /* jump */
+
- /* jump to start of central directory, ASSUMING that the starting disk that
it's on is disk 0 */
- /* starting disk would otherwise be pos[6]+pos[7]<<8 */
-
- offset = pos[16] + (pos[17]<<8) + (pos[18]<<16) + (pos[19]<<24); /* offset
of cent-dir from start of disk 0 */
- /* stop = pos[12] + (pos[13]<<8) + (pos[14]<<16) + (pos[15]<<24); */ /*
length of central dir */
- if (offset + 46 > size) {
- /* not a zip */
- if (filecomment != NULL)
- free(filecomment);
- return prev;
- }
- pos = &data[offset]; /* jump */
-
- /* we should now be at the begining of the central directory structure */
-
- /* from appnote.txt and appnote.iz (mostly)
- *
- * 0- 3 central file header signature 4 bytes (0x02014b50)
- * 4- 5 version made by 2 bytes
- * 6- 7 version needed to extract 2 bytes
- * 8- 9 general purpose bit flag 2 bytes
- * 10-11 compression method 2 bytes
- * 12-13 last mod file time 2 bytes
- * 14-15 last mod file date 2 bytes
- * 16-19 crc-32 4 bytes
- * 20-23 compressed size 4 bytes
- * 24-27 uncompressed size 4 bytes
- * 28-29 filename length 2 bytes
- * 30-31 extra field length 2 bytes
- * 32-33 file comment length 2 bytes
- * 34-35 disk number start 2 bytes
- * 36-37 internal file attributes 2 bytes
- * 38-41 external file attributes 4 bytes
- * 42-45 relative offset of local header 4 bytes
- *
- * 46-?? filename (variable size)
- * ?- ? extra field (variable size)
- * ?- ? file comment (variable size)
- */
-
- if ( !(('P'==pos[0])&&('K'==pos[1])&&(0x01==pos[2])&&(0x02==pos[3])) ) {
+ /* we should now be at the begining of the central directory structure */
+
+ /* from appnote.txt and appnote.iz (mostly)
+ *
+ * 0- 3 central file header signature 4 bytes (0x02014b50)
+ * 4- 5 version made by 2 bytes
+ * 6- 7 version needed to extract 2 bytes
+ * 8- 9 general purpose bit flag 2 bytes
+ * 10-11 compression method 2 bytes
+ * 12-13 last mod file time 2 bytes
+ * 14-15 last mod file date 2 bytes
+ * 16-19 crc-32 4 bytes
+ * 20-23 compressed size 4 bytes
+ * 24-27 uncompressed size 4 bytes
+ * 28-29 filename length 2 bytes
+ * 30-31 extra field length 2 bytes
+ * 32-33 file comment length 2 bytes
+ * 34-35 disk number start 2 bytes
+ * 36-37 internal file attributes 2 bytes
+ * 38-41 external file attributes 4 bytes
+ * 42-45 relative offset of local header 4 bytes
+ *
+ * 46-?? filename (variable size)
+ * ?- ? extra field (variable size)
+ * ?- ? file comment (variable size)
+ */
+
+if (!
+ (('P' == pos[0]) && ('K' == pos[1]) && (0x01 == pos[2])
+ && (0x02 == pos[3])))
+ {
+
#if DEBUG_EXTRACT_ZIP
- fprintf(stderr,
- "Did not find central directory structure signature. offset: %i\n",
- offset);
-#endif
- if (filecomment != NULL)
- free(filecomment);
- return prev;
- }
+ fprintf (stderr,
+
+"Did not find central directory structure signature. offset: %i\n",
+
+offset);
+
+#endif /*
+ */
+ if (filecomment != NULL)
+
+free (filecomment);
+
+return prev;
+
+}
+
+
+start = NULL;
+
+info = NULL;
+
+ do
+ { /* while ( (0x01==pos[2])&&(0x02==pos[3]) ) */
+
+entry_count++; /* check to make sure we found everything at the end
*/
+
+
+name_length = pos[28] + (pos[29] << 8);
+
+extra_length = pos[30] + (pos[31] << 8);
+
+comment_length = pos[32] + (pos[33] << 8);
+
+
+if (name_length + extra_length + comment_length + offset + 46 > size)
+ {
+
+ /* ok, invalid, abort! */
+ break;
+
+}
+
- start = NULL;
- info = NULL;
- do { /* while ( (0x01==pos[2])&&(0x02==pos[3]) ) */
- entry_count++; /* check to make sure we found everything at the end */
-
- name_length = pos[28] + (pos[29]<<8);
- extra_length = pos[30] + (pos[31]<<8);
- comment_length = pos[32] + (pos[33]<<8);
-
- if (name_length + extra_length + comment_length + offset + 46 > size) {
- /* ok, invalid, abort! */
- break;
- }
-
#if DEBUG_EXTRACT_ZIP
- fprintf(stderr,
- "Found filename length %i Comment length: %i\n",
- name_length,
- comment_length);
-#endif
+ fprintf (stderr,
+"Found filename length %i Comment length: %i\n",
+
+name_length,
+comment_length);
+
+#endif /*
+ */
+
+ /* yay, finally get filenames */
+ if (start == NULL)
+ {
+
+start = malloc (sizeof (zip_entry));
+
+start->next = NULL;
+
+info = start;
+
+}
+ else
+ {
+
+info->next = malloc (sizeof (zip_entry));
+
+info = info->next;
+
+info->next = NULL;
+
+}
+
+info->filename = malloc (name_length + 1);
+
+info->comment = malloc (comment_length + 1);
+
- /* yay, finally get filenames */
- if (start == NULL) {
- start = malloc(sizeof(zip_entry));
- start->next = NULL;
- info = start;
- } else {
- info->next = malloc(sizeof(zip_entry));
- info = info->next;
- info->next = NULL;
- }
- info->filename = malloc(name_length + 1);
- info->comment = malloc(comment_length + 1);
+ /* (strings in zip files are not null terminated) */
+ memcpy (info->filename,
+&pos[46],
+name_length);
+
+info->filename[name_length] = '\0';
+
+memcpy (info->comment,
+&pos[46 + name_length + extra_length],
+
+comment_length);
+
+info->comment[comment_length] = '\0';
+
- /* (strings in zip files are not null terminated) */
- memcpy(info->filename,
- &pos[46],
- name_length);
- info->filename[name_length] = '\0';
- memcpy(info->comment,
- &pos[46+name_length+extra_length],
- comment_length);
- info->comment[comment_length] = '\0';
-
#if DEBUG_EXTRACT_ZIP
- fprintf(stderr,
- "Found file %s, Comment: %s\n",
- info->filename,
- info->comment);
-#endif
+ fprintf (stderr,
+"Found file %s, Comment: %s\n",
+info->filename,
+
+info->comment);
+
+#endif /*
+ */
+
+offset += 46 + name_length + extra_length + comment_length;
+
+pos = &data[offset];
+
- offset += 46 + name_length + extra_length + comment_length;
- pos = &data[offset];
-
- /* check for next header entry (0x02014b50) or (0x06054b50) if at end */
- if ( ('P'!=pos[0])&&('K'!=pos[1]) ) {
+ /* check for next header entry (0x02014b50) or (0x06054b50) if at end
*/
+ if (('P' != pos[0]) && ('K' != pos[1]))
+ {
+
#if DEBUG_EXTRACT_ZIP
- fprintf(stderr,
- "Did not find next header in central directory.\n");
-#endif
- info = start;
- while (info != NULL) {
- start = info->next;
- free(info->filename);
- free(info->comment);
- free(info);
- info = start;
- }
- if (filecomment != NULL)
- free(filecomment);
- return prev;
- }
+ fprintf (stderr,
+
+"Did not find next header in central directory.\n");
+
+#endif /*
+ */
+ info = start;
+
+while (info != NULL)
+ {
+
+start = info->next;
+
+free (info->filename);
+
+free (info->comment);
+
+free (info);
+
+info = start;
+
+}
+
+if (filecomment != NULL)
+
+free (filecomment);
+
+return prev;
+
+}
+
+
+}
+ while ((0x01 == pos[2]) && (0x02 == pos[3]));
+
- } while ( (0x01==pos[2])&&(0x02==pos[3]) );
+ /* end list */
+
- /* end list */
-
-
- /* TODO: should this return an error? indicates corrupt zipfile (or
- disk missing in middle of multi-disk)? */
- if (entry_count != entry_total) {
+ /* TODO: should this return an error? indicates corrupt zipfile (or
+ disk missing in middle of multi-disk)? */
+ if (entry_count != entry_total)
+ {
+
#if DEBUG_EXTRACT_ZIP
- fprintf(stderr,
- "WARNING: Did not find all of the zipfile entries that we should
have.\n");
-#endif
- }
+ fprintf (stderr,
+
+"WARNING: Did not find all of the zipfile entries that we should have.\n");
+
+#endif /*
+ */
+ }
+
- /* I'm only putting this in the else clause so that keyword has a local
scope */
- keyword
- = malloc(sizeof(EXTRACTOR_KeywordList));
- keyword->next = prev;
- keyword->keyword = strdup("application/zip");
- keyword->keywordType = EXTRACTOR_MIMETYPE;
- prev = keyword;
+ /* I'm only putting this in the else clause so that keyword has a local
scope */
+ keyword
+ = malloc (sizeof (EXTRACTOR_KeywordList));
+
+keyword->next = prev;
+
+keyword->keyword = strdup ("application/zip");
+
+keyword->keywordType = EXTRACTOR_MIMETYPE;
+
+prev = keyword;
+
+
+if (filecomment != NULL)
+ {
+
+EXTRACTOR_KeywordList * kw
+ = malloc (sizeof (EXTRACTOR_KeywordList));
+
+kw->next = prev;
+
+kw->keyword = strdup (filecomment);
+
+kw->keywordType = EXTRACTOR_COMMENT;
+
+prev = kw;
+
+free (filecomment);
+
+}
+
- if (filecomment != NULL) {
- EXTRACTOR_KeywordList * kw
- = malloc(sizeof(EXTRACTOR_KeywordList));
- kw->next = prev;
- kw->keyword = strdup(filecomment);
- kw->keywordType = EXTRACTOR_COMMENT;
- prev = kw;
- free(filecomment);
- }
+ /* if we've gotten to here then there is at least one zip entry (see
get_zipinfo call above) */
+ /* note: this free()'s the info list as it goes */
+ info = start;
+
+while (NULL != info)
+ {
+
+if (info->filename != NULL)
+ {
+
+if (strlen (info->filename))
+ {
+
+EXTRACTOR_KeywordList * keyword =
+ malloc (sizeof (EXTRACTOR_KeywordList));
+
+keyword->next = prev;
+
+keyword->keyword = strdup (info->filename);
+
+keyword->keywordType = EXTRACTOR_FILENAME;
+
+prev = keyword;
+
+}
+
+free (info->filename);
+
+}
+
+if (strlen (info->comment))
+ {
+
+EXTRACTOR_KeywordList * keyword =
+ malloc (sizeof (EXTRACTOR_KeywordList));
+
+keyword->next = prev;
+
+keyword->keyword = strdup (info->comment);
+
+keyword->keywordType = EXTRACTOR_COMMENT;
+
+prev = keyword;
+
+}
+
+if (info->comment != NULL)
+
+free (info->comment);
+
+tmp = info;
+
+info = info->next;
+
+free (tmp);
+
+}
+
+return prev;
+
+}
+
- /* if we've gotten to here then there is at least one zip entry (see
get_zipinfo call above) */
- /* note: this free()'s the info list as it goes */
- info = start;
- while (NULL != info) {
- if (info->filename != NULL) {
- if (strlen(info->filename)){
- EXTRACTOR_KeywordList * keyword = malloc(sizeof(EXTRACTOR_KeywordList));
- keyword->next = prev;
- keyword->keyword = strdup(info->filename);
- keyword->keywordType = EXTRACTOR_FILENAME;
- prev = keyword;
- }
- free(info->filename);
- }
- if (strlen(info->comment)){
- EXTRACTOR_KeywordList * keyword = malloc(sizeof(EXTRACTOR_KeywordList));
- keyword->next = prev;
- keyword->keyword = strdup(info->comment);
- keyword->keywordType = EXTRACTOR_COMMENT;
- prev = keyword;
- }
- if (info->comment != NULL)
- free(info->comment);
- tmp = info;
- info = info->next;
- free(tmp);
- }
- return prev;
-}
Modified: Extractor/src/test/keywordlisttest.c
===================================================================
--- Extractor/src/test/keywordlisttest.c 2007-07-29 08:04:12 UTC (rev
5367)
+++ Extractor/src/test/keywordlisttest.c 2007-07-29 08:35:49 UTC (rev
5368)
@@ -7,81 +7,88 @@
#include "platform.h"
#include "extractor.h"
-int main(int argc, char * argv[]){
+int
+main (int argc, char *argv[])
+{
EXTRACTOR_KeywordType i;
- char * keywords[] = {
- "test", /* 0 */
- "me", /* 1 */
- "too", /* 2 */
- "many", /* 3 */
- "stupid", /* 0 */
- "silly", /* 1 */
- "keywords", /* 2 */
- "with", /* 3 */
- "too", /* 0 */
- "many", /* 1 */
- "repetitions", /* 2 */
- "many", /* 3 */
- "", /* 0 */
+ char *keywords[] = {
+ "test", /* 0 */
+ "me", /* 1 */
+ "too", /* 2 */
+ "many", /* 3 */
+ "stupid", /* 0 */
+ "silly", /* 1 */
+ "keywords", /* 2 */
+ "with", /* 3 */
+ "too", /* 0 */
+ "many", /* 1 */
+ "repetitions", /* 2 */
+ "many", /* 3 */
+ "", /* 0 */
NULL,
};
- EXTRACTOR_KeywordList * head;
- EXTRACTOR_KeywordList * pos;
+ EXTRACTOR_KeywordList *head;
+ EXTRACTOR_KeywordList *pos;
head = NULL;
i = 0;
- while (keywords[i] != NULL) {
- pos = (EXTRACTOR_KeywordList*) malloc(sizeof(EXTRACTOR_KeywordList));
- pos->next = head;
- pos->keywordType = i % 4;
- pos->keyword = strdup(keywords[i]);
- i++;
- head = pos;
- }
- if (0 != strcmp("test",
-
EXTRACTOR_extractLastByString(EXTRACTOR_getKeywordTypeAsString(0),
- head))) {
- printf("Wrong keyword returned by extractLastByString\n");
- return -1;
- }
- if (0 != strcmp("me",
- EXTRACTOR_extractLast(1,
- head))) {
- printf("Wrong keyword returned by extractLast\n");
- return -1;
- }
- if (13 != EXTRACTOR_countKeywords(head)) {
- printf("Wrong number of keywords returned by countKeywords!\n");
- return -1;
- }
- head = EXTRACTOR_removeEmptyKeywords(head);
- if (12 != EXTRACTOR_countKeywords(head)) {
- printf("removeEmptyKeyword did not work!\n");
- return -1;
- }
- head = EXTRACTOR_removeDuplicateKeywords(head,
- 0);
+ while (keywords[i] != NULL)
+ {
+ pos = (EXTRACTOR_KeywordList *) malloc (sizeof (EXTRACTOR_KeywordList));
+ pos->next = head;
+ pos->keywordType = i % 4;
+ pos->keyword = strdup (keywords[i]);
+ i++;
+ head = pos;
+ }
+ if (0 != strcmp ("test",
+ EXTRACTOR_extractLastByString
+ (EXTRACTOR_getKeywordTypeAsString (0), head)))
+ {
+ printf ("Wrong keyword returned by extractLastByString\n");
+ return -1;
+ }
+ if (0 != strcmp ("me", EXTRACTOR_extractLast (1, head)))
+ {
+ printf ("Wrong keyword returned by extractLast\n");
+ return -1;
+ }
+ if (13 != EXTRACTOR_countKeywords (head))
+ {
+ printf ("Wrong number of keywords returned by countKeywords!\n");
+ return -1;
+ }
+ head = EXTRACTOR_removeEmptyKeywords (head);
+ if (12 != EXTRACTOR_countKeywords (head))
+ {
+ printf ("removeEmptyKeyword did not work!\n");
+ return -1;
+ }
+ head = EXTRACTOR_removeDuplicateKeywords (head, 0);
/* removes many - 3 */
- if (11 != EXTRACTOR_countKeywords(head)) {
- printf("removeDuplicateKeywords(0) did not work!\n");
- return -1;
- }
+ if (11 != EXTRACTOR_countKeywords (head))
+ {
+ printf ("removeDuplicateKeywords(0) did not work!\n");
+ return -1;
+ }
- head = EXTRACTOR_removeDuplicateKeywords(head,
- EXTRACTOR_DUPLICATES_REMOVE_UNKNOWN);
+ head = EXTRACTOR_removeDuplicateKeywords (head,
+
EXTRACTOR_DUPLICATES_REMOVE_UNKNOWN);
/* removes 0-too! */
- if (10 != EXTRACTOR_countKeywords(head)) {
- printf("removeDuplicateKeywords(2) did not work!\n");
- return -1;
- }
+ if (10 != EXTRACTOR_countKeywords (head))
+ {
+ printf ("removeDuplicateKeywords(2) did not work!\n");
+ return -1;
+ }
- head = EXTRACTOR_removeDuplicateKeywords(head,
- EXTRACTOR_DUPLICATES_TYPELESS);
+ head = EXTRACTOR_removeDuplicateKeywords (head,
+ EXTRACTOR_DUPLICATES_TYPELESS);
/* removes many */
- if (9 != EXTRACTOR_countKeywords(head)) {
- printf("removeDuplicateKeywords(1) did not work!\n");
- return -1;
- }
- EXTRACTOR_freeKeywords(head);
+ if (9 != EXTRACTOR_countKeywords (head))
+ {
+ printf ("removeDuplicateKeywords(1) did not work!\n");
+ return -1;
+ }
+ EXTRACTOR_freeKeywords (head);
return 0;
}
Modified: Extractor/src/test/multiload.c
===================================================================
--- Extractor/src/test/multiload.c 2007-07-29 08:04:12 UTC (rev 5367)
+++ Extractor/src/test/multiload.c 2007-07-29 08:35:49 UTC (rev 5368)
@@ -8,25 +8,30 @@
#include "platform.h"
#include "extractor.h"
-static int testLoadPlugins() {
- EXTRACTOR_ExtractorList * el1;
- EXTRACTOR_ExtractorList * el2;
+static int
+testLoadPlugins ()
+{
+ EXTRACTOR_ExtractorList *el1;
+ EXTRACTOR_ExtractorList *el2;
- el1 = EXTRACTOR_loadDefaultLibraries();
- el2 = EXTRACTOR_loadDefaultLibraries();
- if ( (el1 == NULL) || (el2 == NULL) ) {
- printf("Failed to load default plugins!\n");
- return 1;
- }
- EXTRACTOR_removeAll(el1);
- EXTRACTOR_removeAll(el2);
+ el1 = EXTRACTOR_loadDefaultLibraries ();
+ el2 = EXTRACTOR_loadDefaultLibraries ();
+ if ((el1 == NULL) || (el2 == NULL))
+ {
+ printf ("Failed to load default plugins!\n");
+ return 1;
+ }
+ EXTRACTOR_removeAll (el1);
+ EXTRACTOR_removeAll (el2);
return 0;
}
-int main(int argc, char * argv[]){
+int
+main (int argc, char *argv[])
+{
int ret = 0;
- ret += testLoadPlugins();
- ret += testLoadPlugins();
+ ret += testLoadPlugins ();
+ ret += testLoadPlugins ();
return ret;
}
Modified: Extractor/src/test/plugintest.c
===================================================================
--- Extractor/src/test/plugintest.c 2007-07-29 08:04:12 UTC (rev 5367)
+++ Extractor/src/test/plugintest.c 2007-07-29 08:35:49 UTC (rev 5368)
@@ -5,82 +5,74 @@
#include "platform.h"
#include "extractor.h"
-int main(int argc, char * argv[]){
+int
+main (int argc, char *argv[])
+{
int i;
- EXTRACTOR_ExtractorList * arg;
- EXTRACTOR_KeywordList * list;
- EXTRACTOR_KeywordList * list1;
+ EXTRACTOR_ExtractorList *arg;
+ EXTRACTOR_KeywordList *list;
+ EXTRACTOR_KeywordList *list1;
/* do some loading and unloading */
- for (i=0;i<10;i++) {
- arg = EXTRACTOR_loadDefaultLibraries();
- EXTRACTOR_removeAll(arg);
- }
+ for (i = 0; i < 10; i++)
+ {
+ arg = EXTRACTOR_loadDefaultLibraries ();
+ EXTRACTOR_removeAll (arg);
+ }
/* do some load/unload tests */
- arg = EXTRACTOR_addLibrary(NULL,
- "libextractor_split");
- arg = EXTRACTOR_addLibrary(arg,
- "libextractor_mime");
- arg = EXTRACTOR_addLibrary(arg,
- "libextractor_filename");
- arg = EXTRACTOR_removeLibrary(arg,
- "libextractor_mime");
- arg = EXTRACTOR_removeLibrary(arg,
- "libextractor_split");
- arg = EXTRACTOR_removeLibrary(arg,
- "libextractor_filename");
- if (arg != NULL) {
- printf("add-remove test failed!\n");
- return -1;
- }
+ arg = EXTRACTOR_addLibrary (NULL, "libextractor_split");
+ arg = EXTRACTOR_addLibrary (arg, "libextractor_mime");
+ arg = EXTRACTOR_addLibrary (arg, "libextractor_filename");
+ arg = EXTRACTOR_removeLibrary (arg, "libextractor_mime");
+ arg = EXTRACTOR_removeLibrary (arg, "libextractor_split");
+ arg = EXTRACTOR_removeLibrary (arg, "libextractor_filename");
+ if (arg != NULL)
+ {
+ printf ("add-remove test failed!\n");
+ return -1;
+ }
- arg = EXTRACTOR_addLibrary(NULL,
- "libextractor_split");
- arg = EXTRACTOR_addLibrary(arg,
- "libextractor_mime");
- arg = EXTRACTOR_addLibrary(arg,
- "libextractor_filename");
- arg = EXTRACTOR_removeLibrary(arg,
- "libextractor_mime");
- arg = EXTRACTOR_removeLibrary(arg,
- "libextractor_filename");
- arg = EXTRACTOR_removeLibrary(arg,
- "libextractor_split");
- if (arg != NULL) {
- printf("add-remove test failed!\n");
- return -1;
- }
+ arg = EXTRACTOR_addLibrary (NULL, "libextractor_split");
+ arg = EXTRACTOR_addLibrary (arg, "libextractor_mime");
+ arg = EXTRACTOR_addLibrary (arg, "libextractor_filename");
+ arg = EXTRACTOR_removeLibrary (arg, "libextractor_mime");
+ arg = EXTRACTOR_removeLibrary (arg, "libextractor_filename");
+ arg = EXTRACTOR_removeLibrary (arg, "libextractor_split");
+ if (arg != NULL)
+ {
+ printf ("add-remove test failed!\n");
+ return -1;
+ }
- arg = EXTRACTOR_loadConfigLibraries(NULL,
- "libextractor_filename");
- arg = EXTRACTOR_loadConfigLibraries(arg,
- "-libextractor_split");
- list = EXTRACTOR_getKeywords(arg,
- "/etc/resolv.conf");
- if (4 != EXTRACTOR_countKeywords(list)) {
- printf("Invalid number of keywords (4 != %d)\n",
- EXTRACTOR_countKeywords(list));
- return -1;
- }
+ arg = EXTRACTOR_loadConfigLibraries (NULL, "libextractor_filename");
+ arg = EXTRACTOR_loadConfigLibraries (arg, "-libextractor_split");
+ list = EXTRACTOR_getKeywords (arg, "/etc/resolv.conf");
+ if (4 != EXTRACTOR_countKeywords (list))
+ {
+ printf ("Invalid number of keywords (4 != %d)\n",
+ EXTRACTOR_countKeywords (list));
+ return -1;
+ }
i = 0;
list1 = list;
- while (list1 != NULL) {
- if ( (strcmp(list1->keyword, "resolv") == 0) ||
- (strcmp(list1->keyword, "conf") == 0) ||
- (strcmp(list1->keyword, "resolv.conf") == 0) )
- i++;
- list1 = list1->next;
- }
- if (i != 3) {
- printf("Wrong keyword extracted.\n");
- EXTRACTOR_printKeywords(stderr,
- list);
- return -1;
- }
+ while (list1 != NULL)
+ {
+ if ((strcmp (list1->keyword, "resolv") == 0) ||
+ (strcmp (list1->keyword, "conf") == 0) ||
+ (strcmp (list1->keyword, "resolv.conf") == 0))
+ i++;
+ list1 = list1->next;
+ }
+ if (i != 3)
+ {
+ printf ("Wrong keyword extracted.\n");
+ EXTRACTOR_printKeywords (stderr, list);
+ return -1;
+ }
- EXTRACTOR_removeAll(arg);
- EXTRACTOR_freeKeywords(list);
+ EXTRACTOR_removeAll (arg);
+ EXTRACTOR_freeKeywords (list);
return 0;
}
Modified: Extractor/src/test/trivialtest.c
===================================================================
--- Extractor/src/test/trivialtest.c 2007-07-29 08:04:12 UTC (rev 5367)
+++ Extractor/src/test/trivialtest.c 2007-07-29 08:35:49 UTC (rev 5368)
@@ -6,22 +6,27 @@
#include "platform.h"
#include "extractor.h"
-static int testLoadPlugins() {
- EXTRACTOR_ExtractorList * el;
+static int
+testLoadPlugins ()
+{
+ EXTRACTOR_ExtractorList *el;
- el = EXTRACTOR_loadDefaultLibraries();
- if (el == NULL) {
- printf("Failed to load default plugins!\n");
- return 1;
- }
- EXTRACTOR_removeAll(el);
+ el = EXTRACTOR_loadDefaultLibraries ();
+ if (el == NULL)
+ {
+ printf ("Failed to load default plugins!\n");
+ return 1;
+ }
+ EXTRACTOR_removeAll (el);
return 0;
}
-int main(int argc, char * argv[]){
+int
+main (int argc, char *argv[])
+{
int ret = 0;
- ret += testLoadPlugins();
- ret += testLoadPlugins();
+ ret += testLoadPlugins ();
+ ret += testLoadPlugins ();
return ret;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r5368 - in Extractor: . doc doc/lj libltdl src/plugins src/plugins/hash src/plugins/language src/plugins/printable src/plugins/rpm src/plugins/thumbnail src/test,
gnunet <=