Commit 97c0e56a authored by zen's avatar zen

Fixed windows binary vs text bug in fopen. Removed warnings by explicit casting.


git-svn-id: http://svn.annodex.net/liboggz/trunk@353 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent 0024182b
......@@ -37,7 +37,11 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifndef WIN32
#include <unistd.h>
#endif
#include <fcntl.h>
#include <errno.h>
#include <string.h>
......@@ -106,9 +110,9 @@ oggz_open (char * filename, int flags)
if (oggz_flags_disabled (flags)) return NULL;
if (flags & OGGZ_WRITE) {
file = fopen (filename, "w");
file = fopen (filename, "wb");
} else {
file = fopen (filename, "r");
file = fopen (filename, "rb");
}
if (file == NULL) return NULL;
......@@ -328,7 +332,13 @@ oggz_serialno_new (OGGZ * oggz)
long serialno;
do {
#ifndef WIN32
serialno = random();
#else
serialno = rand();
#endif
} while (oggz_get_stream (oggz, serialno) != NULL);
return serialno;
......
......@@ -39,7 +39,7 @@
#include "config.h"
#if OGGZ_CONFIG_READ
#include <stdlib.h>
#include <string.h>
#include <oggz/oggz.h>
......@@ -144,6 +144,7 @@ auto_theora (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data)
if (strncmp ((char *)&header[1], "theora", 6)) return 0;
if (!op->b_o_s) return 0;
tdata = oggz_malloc (sizeof (oggz_theora_metric_t));
tdata->fps_numerator = INT32_BE_AT(&header[22]);
......
......@@ -33,7 +33,13 @@
#ifndef __OGGZ_BYTEORDER_H__
#define __OGGZ_BYTEORDER_H__
static __inline__ unsigned short
#ifdef WIN32
#define __INLINE__ __inline
#else
#define __INLINE__ __inline__
#endif
static __INLINE__ unsigned short
_le_16 (unsigned short s)
{
unsigned short ret=s;
......@@ -44,7 +50,7 @@ _le_16 (unsigned short s)
return ret;
}
static __inline__ ogg_uint32_t
static __INLINE__ ogg_uint32_t
_le_32 (ogg_uint32_t i)
{
ogg_uint32_t ret=i;
......@@ -57,7 +63,7 @@ _le_32 (ogg_uint32_t i)
return ret;
}
static __inline__ ogg_uint32_t
static __INLINE__ ogg_uint32_t
_be_32 (ogg_uint32_t i)
{
ogg_uint32_t ret=i;
......@@ -70,7 +76,7 @@ _be_32 (ogg_uint32_t i)
return ret;
}
static __inline__ ogg_int64_t
static __INLINE__ ogg_int64_t
_le_64 (ogg_int64_t l)
{
ogg_int64_t ret=l;
......
......@@ -36,7 +36,11 @@
* Conrad Parker <conrad@annodex.net>
*/
#ifndef WIN32
#include "config.h"
#else
#include <config.h>
#endif
#if OGGZ_CONFIG_READ
......@@ -45,7 +49,11 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifndef WIN32
#include <unistd.h>
#endif
#include <fcntl.h>
#include <errno.h>
#include <string.h>
......@@ -234,7 +242,7 @@ oggz_read_sync (OGGZ * oggz)
}
}
os = &stream->ogg_stream;
result = ogg_stream_packetout(os, op);
if(result == -1) {
......@@ -335,7 +343,8 @@ oggz_read (OGGZ * oggz, long n)
while (bytes_read > 0 && remaining > 0) {
bytes = MIN (remaining, 4096);
buffer = ogg_sync_buffer (&reader->ogg_sync, bytes);
if ((bytes_read = fread (buffer, 1, bytes, oggz->file)) == 0) {
if ((bytes_read = (long)fread (buffer, 1, bytes, oggz->file)) == 0) {
if (ferror (oggz->file)) {
return OGGZ_ERR_SYSTEM;
}
......@@ -506,7 +515,7 @@ oggz_get_next_page (OGGZ * oggz, ogg_page * og)
page_offset = 0;
buffer = ogg_sync_buffer (&reader->ogg_sync, CHUNKSIZE);
if ((bytes = fread (buffer, 1, CHUNKSIZE, oggz->file)) == 0) {
if ((bytes = (long)fread (buffer, 1, CHUNKSIZE, oggz->file)) == 0) {
if (ferror (oggz->file)) {
/*oggz_set_error (oggz, OGGZ_ERR_SYSTEM);*/
return -1;
......@@ -780,15 +789,24 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target)
return -1;
}
#ifndef WIN32
if (S_ISREG(statbuf.st_mode) || S_ISLNK(statbuf.st_mode)) {
offset_end = statbuf.st_size;
} else {
/*oggz_set_error (oggz, OGGZ_ERR_NOSEEK);*/
return -1;
}
#else
if (statbuf.st_mode & S_IFREG) {
offset_end = statbuf.st_size;
} else {
/*oggz_set_error (oggz, OGGZ_ERR_NOSEEK);*/
return -1;
}
#endif
if (unit_target == reader->current_unit) {
return reader->current_unit;
return (long)reader->current_unit;
}
if (unit_target == 0) {
......@@ -935,7 +953,7 @@ oggz_seek_set (OGGZ * oggz, ogg_int64_t unit_target)
offset_at = oggz_reset (oggz, offset_at, unit_at, SEEK_SET);
if (offset_at == -1) return -1;
return reader->current_unit;
return (long)reader->current_unit;
notfound:
#ifdef DEBUG
......
......@@ -39,7 +39,9 @@
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifndef WIN32
#include <unistd.h>
#endif
#include <fcntl.h>
#include <errno.h>
#include <string.h>
......@@ -451,7 +453,7 @@ oggz_page_writeout (OGGZ * oggz, long n)
#ifdef OGGZ_WRITE_DIRECT
nwritten = write (fd, og->header + writer->page_offset, h);
#else
nwritten = fwrite (og->header + writer->page_offset, 1, h, oggz->file);
nwritten = (long)fwrite (og->header + writer->page_offset, 1, h, oggz->file);
#endif
if (nwritten < h) {
printf ("oggz_page_writeout: %ld < %ld\n", nwritten, h);
......@@ -468,7 +470,7 @@ oggz_page_writeout (OGGZ * oggz, long n)
nwritten = write (fd,
og->body + (writer->page_offset - og->header_len), b);
#else
nwritten = fwrite (og->body + (writer->page_offset - og->header_len),
nwritten = (long)fwrite (og->body + (writer->page_offset - og->header_len),
1, b, oggz->file);
#endif
if (nwritten < b) {
......
......@@ -30,13 +30,15 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include <config.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#ifndef WIN32
#include <inttypes.h>
#endif
#include <getopt.h>
#include <errno.h>
......@@ -163,6 +165,9 @@ bin_dump (unsigned char * buf, long n)
static int
read_packet (OGGZ * oggz, ogg_packet * op, long serialno, void * user_data)
{
#ifdef WIN32
#define PRId64 "I64d"
#endif
fprintf (outfile, "%08lx: serialno %010ld, "
"granulepos %" PRId64 ", packetno %" PRId64,
hide_offset ? -1 : oggz_tell (oggz),
......@@ -231,7 +236,7 @@ revert_file (char * infilename)
if (strcmp (infilename, "-") == 0) {
infile = stdin;
} else {
infile = fopen (infilename, "r");
infile = fopen (infilename, "rb");
}
oggz = oggz_new (OGGZ_WRITE|OGGZ_NONSTRICT);
......@@ -308,7 +313,7 @@ revert_file (char * infilename)
progname);
exit (1);
} else {
max_bytes = new_size;
max_bytes = (long)new_size;
packet = new_packet;
op.packet = packet;
}
......@@ -424,7 +429,7 @@ main (int argc, char ** argv)
if (outfilename == NULL) {
outfile = stdout;
} else {
outfile = fopen (outfilename, "w");
outfile = fopen (outfilename, "wb");
if (outfile == NULL) {
fprintf (stderr, "%s: unable to open output file %s\n",
progname, outfilename);
......@@ -468,7 +473,7 @@ main (int argc, char ** argv)
oggz_set_read_callback (oggz, serialno, my_read_packet, NULL);
}
}
while ((n = oggz_read (oggz, 1024)) > 0);
oggz_close (oggz);
......
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="C_libOGGZ"
ProjectGUID="{A8D30F09-A16C-49E2-ACBA-A4876D8E0925}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".;..\..\libogg\include;..\..\liboggz\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;C_LIBOGGZ_EXPORTS;DEBUG"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"
CompileAs="1"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
RegisterOutput="FALSE"
AdditionalOptions="/DEF:liboggz.def"
AdditionalDependencies="ogg.lib"
OutputFile="$(OutDir)/C_libOGGZ.dll"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\libogg\win32\Dynamic_Release"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/C_libOGGZ.pdb"
SubSystem="2"
ImportLibrary="$(OutDir)/C_libOGGZ.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="3"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="TRUE"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories=".;..\..\libogg\include;..\..\liboggz\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;C_LIBOGGZ_EXPORTS"
ExceptionHandling="FALSE"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"
CompileAs="1"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="ogg.lib"
OutputFile="$(OutDir)/libOGGZ.dll"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\libogg\win32\Dynamic_Release"
ModuleDefinitionFile="liboggz.def"
GenerateDebugInformation="TRUE"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
OptimizeForWindows98="1"
ImportLibrary="$(OutDir)/libOGGZ.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\liboggz.def">
</File>
<File
RelativePath="..\src\liboggz\oggz.c">
</File>
<File
RelativePath="..\src\liboggz\oggz_auto.c">
</File>
<File
RelativePath="..\src\liboggz\oggz_read.c">
</File>
<File
RelativePath="..\src\liboggz\oggz_table.c">
</File>
<File
RelativePath="..\src\liboggz\oggz_vector.c">
</File>
<File
RelativePath="..\src\liboggz\oggz_write.c">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\config.h">
</File>
<File
RelativePath="..\src\liboggz\oggz_auto.h">
</File>
<File
RelativePath="..\src\liboggz\oggz_byteorder.h">
</File>
<File
RelativePath="..\src\liboggz\oggz_macros.h">
</File>
<File
RelativePath="..\src\liboggz\oggz_private.h">
</File>
<File
RelativePath="..\src\liboggz\oggz_vector.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
<File
RelativePath=".\ReadMe.txt">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="OGGZDump"
ProjectGUID="{65EEF875-D215-4248-B216-8B9701AA7A31}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="Debug"
IntermediateDirectory="Debug"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".;..\include;..\..\libogg\include"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;DEBUG"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"
CompileAs="1"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/OGGZDump.exe"
LinkIncremental="2"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="$(OutDir)/OGGZDump.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="Release"
IntermediateDirectory="Release"
ConfigurationType="1"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="3"
GlobalOptimizations="TRUE"
InlineFunctionExpansion="2"
EnableIntrinsicFunctions="TRUE"
FavorSizeOrSpeed="1"
OptimizeForProcessor="2"
AdditionalIncludeDirectories=".;..\include;..\..\libogg\include"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
ExceptionHandling="FALSE"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"
CompileAs="1"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="$(OutDir)/OGGZDump.exe"
LinkIncremental="1"
GenerateDebugInformation="TRUE"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
<ProjectReference
ReferencedProjectIdentifier="{A8D30F09-A16C-49E2-ACBA-A4876D8E0925}"
Name="C_libOGGZ"/>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
<File
RelativePath=".\attgetopt.c">
</File>
<File
RelativePath="..\src\tools\oggzdump.c">
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
<File
RelativePath=".\config.h">
</File>
<File
RelativePath=".\getopt.h">
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
</Filter>
<File
RelativePath=".\ReadMe.txt">
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
/**
* @file attgetopt.c
* @ingroup wbxml2xml_tool
* @ingroup xml2wbxml_tool
*
* AT&T's public domain implementation of getopt.
*
* From the mod.sources newsgroup, volume 3, issue 58, with modifications
* to bring it up to 21st century C.
*
* Taken from Kannel Project (http://www.kannel.org/)
*/
#include <stdio.h>
#include <string.h>
#define ERR(s, c) if (opterr) (void) fprintf(stderr, "%s: %s\n", argv[0], s)
int opterr = 1;
int optind = 1;
int optopt;
char *optarg;
int getopt(int argc, char **argv, char *opts)
{
static int sp = 1;
register int c;
register char *cp;
if(sp == 1) {
if(optind >= argc ||
argv[optind][0] != '-' || argv[optind][1] == '\0')
return(EOF);
else if(strcmp(argv[optind], "--") == 0) {
optind++;
return(EOF);
}
}
optopt = c = argv[optind][sp];
if(c == ':' || (cp=strchr(opts, c)) == NULL) {
ERR(": illegal option -- ", c);
if(argv[optind][++sp] == '\0') {
optind++;
sp = 1;
}
return('?');
}
if(*++cp == ':') {
if(argv[optind][sp+1] != '\0')
optarg = &argv[optind++][sp+1];
else if(++optind >= argc) {
ERR(": option requires an argument -- ", c);
sp = 1;
return('?');
} else
optarg = argv[optind++];
sp = 1;
} else {
if(argv[optind][++sp] == '\0') {
sp = 1;
optind++;
}
optarg = NULL;
}
return(c);
}
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if you have the 'getopt_long' function */
#undef HAVE_GETOPT_LONG
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
/* Define to 1 if you have the `memmove' function. */
#undef HAVE_MEMMOVE
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if your system has a GNU libc compatible `realloc' function,
and to 0 otherwise. */
#undef HAVE_REALLOC
/* Define to 1 if you have the <stdint.h> header file. */
#undef HAVE_STDINT_H
/* Define to 1 if you have the <stdlib.h> header file. */
#undef HAVE_STDLIB_H
/* Define to 1 if you have the <strings.h> header file. */
#undef HAVE_STRINGS_H
/* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
/* Define to 1 if you have the <sys/types.h> header file. */
#undef HAVE_SYS_TYPES_H
/* Define to 1 if you have the <unistd.h> header file. */
#undef HAVE_UNISTD_H
/* Define to build experimental code */
#undef OGGZ_CONFIG_EXPERIMENTAL
/* Do not build reading support */
#ifdef WIN32
#define OGGZ_CONFIG_READ 1
#else
#undef OGGZ_CONFIG_READ
#endif
/* Do not build writing support */
#ifdef WIN32
#define OGGZ_CONFIG_WRITE 1
#else
#undef OGGZ_CONFIG_WRITE
#endif
/* Name of package */
#undef PACKAGE
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */