Commit e4420fee authored by laser13's avatar laser13

Single oggz_off_t public type for large file support

git-svn-id: http://svn.annodex.net/liboggz/trunk@2608 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent ff264723
......@@ -256,7 +256,8 @@ AC_SUBST(OGGZ_OFF_MAX)
AC_CHECK_TYPES(ssize_t)
AC_CHECK_SIZEOF(ssize_t,4)
AC_DEFINE_UNQUOTED([oggz_off_t], ${TYPEOF_OGGZ_OFF_T}, [Configured type of oggz_off_t])
dnl was defined to set oggz_off_t type (removed by laser13)
dnl AC_DEFINE_UNQUOTED([oggz_off_t], ${TYPEOF_OGGZ_OFF_T}, [Configured type of oggz_off_t])
dnl
......@@ -367,6 +368,7 @@ doc/Makefile
doc/Doxyfile
include/Makefile
include/oggz/Makefile
include/oggz/oggz_off_t.h
src/Makefile
src/liboggz/Version_script
src/liboggz/Makefile
......
......@@ -3,5 +3,6 @@
# Include files to install
oggzincludedir = $(includedir)/oggz
oggzinclude_HEADERS = oggz.h oggz_comments.h oggz_constants.h oggz_read.h \
oggz_seek.h oggz_write.h oggz_io.h oggz_table.h oggz_deprecated.h
oggz_seek.h oggz_write.h oggz_io.h oggz_table.h oggz_deprecated.h \
oggz_off_t.h
......@@ -551,6 +551,13 @@ int oggz_get_eos (OGGZ * oggz, long serialno);
*/
long oggz_serialno_new (OGGZ * oggz);
/* define appropriate type for oggz_off_t */
#ifdef _WIN32
#include <oggz/oggz_off_t_win32.h>
#else
#include <oggz/oggz_off_t.h>
#endif
#include <oggz/oggz_comments.h>
#include <oggz/oggz_read.h>
#include <oggz/oggz_seek.h>
......
/*
Copyright (C) 2007 Commonwealth Scientific and Industrial Research
Organisation (CSIRO) Australia
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of CSIRO Australia nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __OGGZ_OFF_T_H__
#define __OGGZ_OFF_T_H__
/** \file
* Support for Large File Sizes on systems supporting 64-bit off_t types.
*
* This file is included by all files using loff_t for file
* position e.g.: \link config.h <config.h> \endlink,
* except on non-GNU Win32 systems \link ogg_off_t_w32.h \endlink is included
* instead.
*
* This file should never be included directly by user code.
*/
/**
* This typedef was determined on the system on which the documentation
* was generated.
*
* To query this on your system, do eg.
*
<pre>
echo "#include <config.h>" | gcc -E - | grep oggz_off_t
</pre>
*
*/
#ifdef _WIN32
/* MSVC/Borland & Cygwin */
typedef off_t oggz_off_t;
#else
/* Linux/BSD/etc. */
# include <sys/types.h>
typedef loff_t oggz_off_t;
#endif
/* Note: This is an ugly fix for proper display in printf but will work for now */
#if SIZEOF_OGGZ_OFF_T == 8
#define PRI_OGGZ_OFF_T = "q"
#else
#define PRI_OGGZ_OFF_T = "l"
#endif
#endif /* __OGGZ_OFF_T__ */
/*
Copyright (C) 2007 Commonwealth Scientific and Industrial Research
Organisation (CSIRO) Australia
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of CSIRO Australia nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __OGGZ_OFF_T_H__
#define __OGGZ_OFF_T_H__
/** \file
* Support for Large File Sizes on systems supporting 64-bit off_t types.
*
* This file is included by all files using @TYPEOF_OGGZ_OFF_T@ for file
* position e.g.: \link config.h <config.h> \endlink,
* except on non-GNU Win32 systems \link ogg_off_t_w32.h \endlink is included
* instead.
*
* This file should never be included directly by user code.
*/
/**
* This typedef was determined on the system on which the documentation
* was generated.
*
* To query this on your system, do eg.
*
<pre>
echo "#include <config.h>" | gcc -E - | grep oggz_off_t
</pre>
*
*/
#ifdef _WIN32
/* MSVC/Borland & Cygwin */
typedef off_t oggz_off_t;
#else
/* Linux/BSD/etc. */
# include <sys/types.h>
typedef @TYPEOF_OGGZ_OFF_T@ oggz_off_t;
#endif
/* Note: This is an ugly fix for proper display in printf but will work for now */
#if SIZEOF_OGGZ_OFF_T == 8
#define PRI_OGGZ_OFF_T = "q"
#else
#define PRI_OGGZ_OFF_T = "l"
#endif
#endif /* __OGGZ_OFF_T__ */
/*
Copyright (C) 2007 Commonwealth Scientific and Industrial Research
Organisation (CSIRO) Australia
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
- Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
- Neither the name of CSIRO Australia nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE ORGANISATION OR
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __OGGZ_OFF_T_H__
#define __OGGZ_OFF_T_H__
/** \file
* Support for Large File Sizes on systems supporting 64-bit off_t types.
*
* This file is included by all files using @TYPEOF_OGGZ_OFF_T@ for file
* position e.g.: \link config.h <config.h> \endlink,
* except on non-GNU Win32 systems \link ogg_off_t_w32.h \endlink is included
* instead.
*
* This file should never be included directly by user code.
*/
/**
* This typedef was determined on the system on which the documentation
* was generated.
*
* To query this on your system, do eg.
*
<pre>
echo "#include <config.h>" | gcc -E - | grep oggz_off_t
</pre>
*
*/
#ifdef _WIN32
/* MSVC/Borland & Cygwin */
typedef off_t oggz_off_t;
#else
/* Linux/BSD/etc. */
#include <sys/types.h>
typedef @TYPEOF_OGGZ_OFF_T@ oggz_off_t;
/* Note: This is an ugly fix for proper display in printf but will work for now */
#if SIZEOF_OGGZ_OFF_T == 8
#define PRI_OGGZ_OFF_T = "q"
#else
#define PRI_OGGZ_OFF_T = "l"
#endif
#endif
#endif /* __OGGZ_OFF_T__ */
......@@ -129,7 +129,7 @@ oggz_tell_granulepos (OGGZ * oggz);
* ahead, this may differ from the current offset of the associated file
* descriptor.
*/
off_t oggz_tell (OGGZ * oggz);
oggz_off_t oggz_tell (OGGZ * oggz);
/**
* Seek to a specific byte offset
......@@ -138,7 +138,7 @@ off_t oggz_tell (OGGZ * oggz);
* \param whence As defined in <stdio.h>: SEEK_SET, SEEK_CUR or SEEK_END
* \returns the new file offset, or -1 on failure.
*/
off_t oggz_seek (OGGZ * oggz, loff_t offset, int whence);
oggz_off_t oggz_seek (OGGZ * oggz, oggz_off_t offset, int whence);
#ifdef _UNIMPLEMENTED
long oggz_seek_packets (OGGZ * oggz, long serialno, long packets, int whence);
......@@ -443,7 +443,7 @@ long oggz_seek_byorder (OGGZ * oggz, void * target);
* \param offset The offset of the start of data
* \returns 0 on success, -1 on failure.
*/
int oggz_set_data_start (OGGZ * oggz, off_t offset);
int oggz_set_data_start (OGGZ * oggz, oggz_off_t offset);
/** \}
*/
......
......@@ -20,7 +20,7 @@ liboggz_la_SOURCES = \
oggz_stream.c oggz_stream.h \
oggz_table.c \
oggz_vector.c oggz_vector.h \
metric_internal.c
metric_internal.c
liboggz_la_LDFLAGS = -version-info @SHARED_VERSION_INFO@ @SHLIB_VERSION_ARG@
liboggz_la_LIBADD = @OGG_LIBS@
......@@ -216,7 +216,7 @@ oggz_close (OGGZ * oggz)
return 0;
}
off_t
oggz_off_t
oggz_tell (OGGZ * oggz)
{
if (oggz == NULL) return OGGZ_ERR_BAD_OGGZ;
......
......@@ -41,6 +41,11 @@
/*#define DEBUG*/
#ifdef WIN32
#define strcasecmp _stricmp
#endif
static char *
oggz_strdup (const char * s)
{
......
......@@ -39,9 +39,17 @@
#include <ogg/ogg.h>
#include <oggz/oggz_constants.h>
/* define appropriate type for oggz_off_t */
#ifdef _WIN32
#include <oggz/oggz_off_t_win32.h>
#else
#include <oggz/oggz_off_t.h>
#endif
#include "oggz_macros.h"
#include "oggz_vector.h"
typedef struct _OGGZ OGGZ;
typedef struct _OggzComment OggzComment;
typedef struct _OggzIO OggzIO;
......@@ -135,7 +143,7 @@ struct _OggzReader {
ogg_int64_t current_granulepos;
#if 0
off_t offset_page_end; /* offset of end of current page */
oggz_off_t offset_page_end; /* offset of end of current page */
#endif
};
......@@ -215,8 +223,8 @@ struct _OGGZ {
ogg_packet current_packet;
ogg_page current_page;
off_t offset; /* offset of current page start */
off_t offset_data_begin; /* offset of unit 0 page start */
oggz_off_t offset; /* offset of current page start */
oggz_off_t offset_data_begin; /* offset of unit 0 page start */
long run_blocksize; /* blocksize to use for oggz_run() */
int cb_next;
......
......@@ -145,7 +145,7 @@ oggz_reset_seek (OGGZ * oggz, oggz_off_t offset, ogg_int64_t unit, int whence)
oggz->offset = offset_at;
#ifdef DEBUG
printf ("reset to %ld\n", offset_at);
printf ("reset to %" PRI_OGGZ_OFF_T "d\n", offset_at);
#endif
if (unit != -1) reader->current_unit = unit;
......@@ -313,10 +313,10 @@ oggz_get_prev_start_page (OGGZ * oggz, ogg_page * og,
#ifdef DEBUG
printf ("get_prev_start_page: [A] offset_at: @%ld\toffset_start: @%ld\n",
printf ("get_prev_start_page: [A] offset_at: @%" PRI_OGGZ_OFF_T "d\toffset_start: @%" PRI_OGGZ_OFF_T "d\n",
offset_at, offset_start);
printf ("get_prev_start_page: seeked to %ld\n", offset_start);
printf ("get_prev_start_page: seeked to %" PRI_OGGZ_OFF_T "d\n", offset_start);
#endif
page_offset = 0;
......@@ -339,7 +339,7 @@ oggz_get_prev_start_page (OGGZ * oggz, ogg_page * og,
granule_at = ogg_page_granulepos (og);
#ifdef DEBUG_VERBOSE
printf ("get_prev_start_page: GOT page (%lld) @%ld\tat @%ld\n",
printf ("get_prev_start_page: GOT page (%lld) @%" PRI_OGGZ_OFF_T "d\tat @%" PRI_OGGZ_OFF_T "d\n",
granule_at, page_offset, offset_at);
#endif
......@@ -355,8 +355,8 @@ oggz_get_prev_start_page (OGGZ * oggz, ogg_page * og,
} while (page_offset >= 0 && page_offset < offset_at);
#ifdef DEBUG
printf ("get_prev_start_page: [B] offset_at: @%ld\toffset_start: @%ld\n"
"found_offset: @%ld\tpage_offset: @%ld\n",
printf ("get_prev_start_page: [B] offset_at: @%" PRI_OGGZ_OFF_T "d\toffset_start: @%" PRI_OGGZ_OFF_T "d\n"
"found_offset: @%" PRI_OGGZ_OFF_T "d\tpage_offset: @%" PRI_OGGZ_OFF_T "d\n",
offset_at, offset_start, found_offset, page_offset);
#endif
/* reset the file offset */
......@@ -368,8 +368,8 @@ oggz_get_prev_start_page (OGGZ * oggz, ogg_page * og,
offset_at = oggz_reset (oggz, found_offset, unit_at, SEEK_SET);
#ifdef DEBUG
printf ("get_prev_start_page: [C] offset_at: @%ld\t"
"found_offset: @%ld\tunit_at: %lld\n",
printf ("get_prev_start_page: [C] offset_at: @%" PRI_OGGZ_OFF "d\t"
"found_offset: @%" PRO_OGGZ_OFF "d\tunit_at: %lld\n",
offset_at, found_offset, unit_at);
#endif
......@@ -392,7 +392,7 @@ oggz_scan_for_page (OGGZ * oggz, ogg_page * og, ogg_int64_t unit_target,
long serialno;
#ifdef DEBUG
printf (" SCANNING from %ld...", offset_begin);
printf (" SCANNING from %" PRI_OGGZ_OFF_T "d...", offset_begin);
#endif
for ( ; ; ) {
......@@ -400,7 +400,7 @@ oggz_scan_for_page (OGGZ * oggz, ogg_page * og, ogg_int64_t unit_target,
if (offset_at == -1) return -1;
#ifdef DEBUG
printf (" scan @%ld\n", offset_at);
printf (" scan @%" PRI_OGGZ_OFF_T "d\n", offset_at);
#endif
offset_next = oggz_get_next_start_page (oggz, og);
......@@ -540,7 +540,7 @@ oggz_seek_guess (ogg_int64_t unit_at, ogg_int64_t unit_target,
}
#ifdef DEBUG
printf ("oggz_seek_guess: guessed %ld\n", offset_guess);
printf ("oggz_seek_guess: guessed %" PRI_OGGZ_OFF_T "d\n", offset_guess);
#endif
return offset_guess;
......@@ -567,7 +567,7 @@ oggz_offset_end (OGGZ * oggz)
if (oggz_stat_regular (statbuf.st_mode)) {
offset_end = statbuf.st_size;
#ifdef DEBUG
printf ("oggz_offset_end: stat size %ld\n", offset_end);
printf ("oggz_offset_end: stat size %" PRI_OGGZ_OFF_T "d\n", offset_end);
#endif
} else {
/*oggz_set_error (oggz, OGGZ_ERR_NOSEEK);*/
......@@ -659,7 +659,7 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target)
hit_eof = 0;
#ifdef DEBUG
printf ("oggz_seek_set: [A] want u%lld: (u%lld - u%lld) [@%ld - @%ld]\n",
printf ("oggz_seek_set: [A] want u%lld: (u%lld - u%lld) [@%" PRI_OGGZ_OFF_T "d - @%" PRI_OGGZ_OFF_T "d]\n",
unit_target, unit_begin, unit_end, offset_begin, offset_end);
#endif
......@@ -682,7 +682,7 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target)
offset_next = oggz_get_next_start_page (oggz, og);
#ifdef DEBUG
printf ("oggz_seek_set: offset_next %ld\n", offset_next);
printf ("oggz_seek_set: offset_next %" PRI_OGGZ_OFF_T "d\n", offset_next);
#endif
if (/*unit_end == -1 &&*/ offset_next == -2) { /* reached eof, backtrack */
......@@ -691,7 +691,7 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target)
&serialno);
unit_end = oggz_get_unit (oggz, serialno, granule_at);
#ifdef DEBUG
printf ("oggz_seek_set: [C] offset_next @%ld, g%lld, (s%ld)\n",
printf ("oggz_seek_set: [C] offset_next @%" PRI_OGGZ_OFF_T "d, g%lld, (s%ld)\n",
offset_next, granule_at, serialno);
printf ("oggz_seek_set: [c] u%lld\n",
oggz_get_unit (oggz, serialno, granule_at));
......@@ -726,7 +726,7 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target)
if (unit_at == unit_last_iter) break;
#ifdef DEBUG
printf ("oggz_seek_set: [D] want u%lld, got page u%lld @%ld g%lld\n",
printf ("oggz_seek_set: [D] want u%lld, got page u%lld @%" PRI_OGGZ_OFF_T "d g%lld\n",
unit_target, unit_at, offset_at, granule_at);
#endif
......@@ -798,7 +798,7 @@ oggz_seek_end (OGGZ * oggz, ogg_int64_t unit_offset)
}
#ifdef DEBUG
printf ("*** oggz_seek_end: found packet (%lld) at @%ld [%lld]\n",
printf ("*** oggz_seek_end: found packet (%lld) at @%" PRI_OGGZ_OFF_T "d [%lld]\n",
unit_end, offset_end, granulepos);
#endif
......
......@@ -131,6 +131,3 @@
/* Define to `unsigned' if <sys/types.h> does not define. */
#undef size_t
/* Defined type of oggz_off_t */
#define oggz_off_t off_t
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment