From 136893562488e6c767f786f9d94e5122adf78a28 Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Mon, 12 Dec 2005 06:39:39 +0000 Subject: fixes for MinGW svn path=/trunk/externals/pdogg/; revision=4194 --- oggamp~/oggamp~.c | 19 +++++++++---------- oggcast~/oggcast~.c | 21 ++++++++++----------- oggread~/oggread~.c | 16 ++++++++-------- oggwrite~/oggwrite~.c | 47 +++++++++++++++++++++++------------------------ 4 files changed, 50 insertions(+), 53 deletions(-) diff --git a/oggamp~/oggamp~.c b/oggamp~/oggamp~.c index 59a9835..d1ac186 100644 --- a/oggamp~/oggamp~.c +++ b/oggamp~/oggamp~.c @@ -42,7 +42,11 @@ #include #include #include -#ifdef UNIX +#ifdef WIN32 +#include /* for 'write' in pute-function only */ +#include +#include +#else #include #include #include @@ -51,22 +55,17 @@ #include #include #define SOCKET_ERROR -1 -#else -#include /* for 'write' in pute-function only */ -#include -#include #endif -#ifdef NT +#ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif -#ifdef UNIX -#define sys_closesocket close -#endif -#ifdef NT +#ifdef WIN32 #define sys_closesocket closesocket +#else +#define sys_closesocket close #endif diff --git a/oggcast~/oggcast~.c b/oggcast~/oggcast~.c index ae25aed..15253e4 100644 --- a/oggcast~/oggcast~.c +++ b/oggcast~/oggcast~.c @@ -38,7 +38,11 @@ #include #include #include -#ifdef UNIX +#ifdef WIN32 +#include /* for 'write' in pute-function only */ +#include +#include +#else #include #include #include @@ -47,24 +51,19 @@ #include #include #define SOCKET_ERROR -1 -#else -#include /* for 'write' in pute-function only */ -#include -#include #endif -#ifdef NT +#ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif -#ifdef UNIX -#define sys_closesocket close -#define pdogg_strdup(s) strdup(s) -#endif -#ifdef NT +#ifdef WIN32 #define sys_closesocket closesocket #define pdogg_strdup(s) _strdup(s) +#else +#define sys_closesocket close +#define pdogg_strdup(s) strdup(s) #endif /************************* oggcast~ object ******************************/ diff --git a/oggread~/oggread~.c b/oggread~/oggread~.c index 115cac4..7c8bf37 100644 --- a/oggread~/oggread~.c +++ b/oggread~/oggread~.c @@ -35,7 +35,10 @@ #include #include #include -#ifdef UNIX +#ifdef WIN32 +#include +#include +#else #include #include #include @@ -44,12 +47,9 @@ #include #include #define SOCKET_ERROR -1 -#else -#include -#include #endif -#ifdef NT +#ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif @@ -290,10 +290,10 @@ static void oggread_open(t_oggread *x, t_symbol *filename) post("oggread~: previous file closed"); } /* open file for reading */ -#ifdef UNIX - if((x->x_file = fopen(filename->s_name, "r")) < 0) -#else +#ifdef WIN32 if((x->x_file = fopen(filename->s_name, "rb")) < 0) +#else + if((x->x_file = fopen(filename->s_name, "r")) < 0) #endif { post("oggread~: could not open file \"%s\"", filename->s_name); diff --git a/oggwrite~/oggwrite~.c b/oggwrite~/oggwrite~.c index 4ac6221..ad025c0 100644 --- a/oggwrite~/oggwrite~.c +++ b/oggwrite~/oggwrite~.c @@ -27,7 +27,7 @@ -#ifdef NT +#ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif @@ -44,18 +44,18 @@ #endif #include #include -#ifdef UNIX +#ifdef WIN32 +#include +#include +#include +#include +#else #include #include #include #include #include #define SOCKET_ERROR -1 -#else -#include -#include -#include -#include #endif #include "m_pd.h" /* standard pd stuff */ @@ -126,11 +126,10 @@ typedef struct _oggwrite static void sys_closesocket(int fd) { -#ifdef UNIX - close(fd); -#endif -#ifdef NT +#ifdef WIN32 closesocket(fd); +#else + close(fd); #endif } /* prototypes */ @@ -147,7 +146,7 @@ static int oggwrite_write(t_oggwrite *x) { int result=ogg_stream_pageout(&(x->x_os),&(x->x_og)); if(result==0)break; -#ifndef UNIX +#ifdef WIN32 err = _write(x->x_fd, x->x_og.header, x->x_og.header_len); #else err = write(x->x_fd, x->x_og.header, x->x_og.header_len); @@ -158,7 +157,7 @@ static int oggwrite_write(t_oggwrite *x) x->x_eos = 1; /* indicate (artificial) end of stream */ return err; } -#ifndef UNIX +#ifdef WIN32 err = _write(x->x_fd, x->x_og.body, x->x_og.body_len); #else err = write(x->x_fd, x->x_og.body, x->x_og.body_len); @@ -221,7 +220,7 @@ static void oggwrite_encode(t_oggwrite *x) { if(x->x_fd > 0) { -#ifndef UNIX +#ifdef WIN32 if(_close(x->x_fd) < 0) #else if(close(x->x_fd) < 0) @@ -375,7 +374,7 @@ static void oggwrite_vorbis_init(t_oggwrite *x) { int result=ogg_stream_flush(&(x->x_os),&(x->x_og)); if(result==0)break; -#ifndef UNIX +#ifdef WIN32 err = _write(x->x_fd, x->x_og.header, x->x_og.header_len); #else err = write(x->x_fd, x->x_og.header, x->x_og.header_len); @@ -387,7 +386,7 @@ static void oggwrite_vorbis_init(t_oggwrite *x) x->x_vorbis = -1; /* stop encoding instantly */ if(x->x_fd > 0) { -#ifndef UNIX +#ifdef WIN32 if(_close(x->x_fd) < 0) #else if(close(x->x_fd) < 0) @@ -399,7 +398,7 @@ static void oggwrite_vorbis_init(t_oggwrite *x) } return; } -#ifndef UNIX +#ifdef WIN32 err = _write(x->x_fd, x->x_og.body, x->x_og.body_len); #else err = write(x->x_fd, x->x_og.body, x->x_og.body_len); @@ -411,7 +410,7 @@ static void oggwrite_vorbis_init(t_oggwrite *x) x->x_vorbis = -1; /* stop encoding instantly */ if(x->x_fd > 0) { -#ifndef UNIX +#ifdef WIN32 if(_close(x->x_fd) < 0) #else if(close(x->x_fd) < 0) @@ -451,7 +450,7 @@ static void oggwrite_open(t_oggwrite *x, t_symbol *sfile) /* closing previous file descriptor */ if(x->x_fd > 0) { -#ifndef UNIX +#ifdef WIN32 if(_close(x->x_fd) < 0) #else if(close(x->x_fd) < 0) @@ -467,7 +466,7 @@ static void oggwrite_open(t_oggwrite *x, t_symbol *sfile) x->x_recflag = 0; } -#ifndef UNIX +#ifdef WIN32 if((x->x_fd = _open( sfile->s_name, x->x_file_open_mode, _S_IREAD|_S_IWRITE)) < 0) #else if((x->x_fd = open( sfile->s_name, x->x_file_open_mode, S_IRWXU|S_IRWXG|S_IRWXO )) < 0) @@ -492,7 +491,7 @@ static void oggwrite_open(t_oggwrite *x, t_symbol *sfile) /* setting file write mode to append */ static void oggwrite_append(t_oggwrite *x) { -#ifndef UNIX +#ifdef WIN32 x->x_file_open_mode = _O_CREAT|_O_WRONLY|_O_APPEND|_O_BINARY; #else x->x_file_open_mode = O_CREAT|O_WRONLY|O_APPEND|O_NONBLOCK; @@ -503,7 +502,7 @@ static void oggwrite_append(t_oggwrite *x) /* setting file write mode to truncate */ static void oggwrite_truncate(t_oggwrite *x) { -#ifndef UNIX +#ifdef WIN32 x->x_file_open_mode = _O_CREAT|_O_WRONLY|_O_TRUNC|_O_BINARY; #else x->x_file_open_mode = O_CREAT|O_WRONLY|O_TRUNC|O_NONBLOCK; @@ -682,7 +681,7 @@ static void oggwrite_free(t_oggwrite *x) } if(x->x_fd >= 0) { /* close file */ -#ifndef UNIX +#ifdef WIN32 _close(x->x_fd); #else close(x->x_fd); @@ -699,7 +698,7 @@ static void *oggwrite_new(void) outlet_new(&x->x_obj, gensym("float")); x->x_outpages = outlet_new(&x->x_obj, gensym("float")); x->x_fd = -1; -#ifndef UNIX +#ifdef WIN32 x->x_file_open_mode = _O_CREAT|_O_WRONLY|_O_APPEND|_O_BINARY; #else x->x_file_open_mode = O_CREAT|O_WRONLY|O_APPEND|O_NONBLOCK; -- cgit v1.2.1