From c521b4eefd7b68580b84f3f1ae257aabc08973bb Mon Sep 17 00:00:00 2001 From: rocky Date: Mon, 24 Oct 2005 03:11:33 +0000 Subject: [PATCH] MinGW tolerance. Patches based on those by Eric Lunchpail --- src/cd-paranoia/cd-paranoia.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/cd-paranoia/cd-paranoia.c b/src/cd-paranoia/cd-paranoia.c index 7d094f19..642da2f5 100644 --- a/src/cd-paranoia/cd-paranoia.c +++ b/src/cd-paranoia/cd-paranoia.c @@ -96,6 +96,15 @@ # include #endif +#if !defined(HAVE_GETTIMEOFDAY) +/* MinGW uses sys/time.h and sys/timeb.h to roll its own gettimeofday() */ +# if defined(HAVE_SYS_TIME_H) && defined(HAVE_SYS_TIMEB_H) +# include +# include +static void gettimeofday(struct timeval* tv, void* timezone); +# endif +#endif /* !defined(HAVE_GETTIMEOFDAY) */ + #include #include #include @@ -600,6 +609,17 @@ static char *info_file = NULL; free(p); \ p=NULL; +#if !defined(HAVE_GETTIMEOFDAY) && defined(HAVE_SYS_TIME_H) && defined(HAVE_SYS_TIMEB_H) +static void +gettimeofday(struct timeval* tv, void* timezone) +{ + struct timeb timebuffer; + ftime( &timebuffer ); + tv->tv_sec=timebuffer.time; + tv->tv_usec=1000*timebuffer.millitm; +} +#endif + /* This is run automatically before leaving the program. Free allocated resources. */ @@ -1070,8 +1090,12 @@ main(int argc,char *argv[]) paranoia_seek(p,cursor=i_first_lsn,SEEK_SET); /* this is probably a good idea in general */ +#if defined(HAVE_GETUID) && defined(HAVE_SETEUID) seteuid(getuid()); +#endif +#if defined(HAVE_GETGID) && defined(HAVE_SETEGID) setegid(getgid()); +#endif /* we'll need to be able to read one sector past user data if we have a sample offset in order to pick up the last bytes. We