summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorR. Bernstein <rocky@gnu.org>2012-03-03 20:11:14 -0500
committerR. Bernstein <rocky@gnu.org>2012-03-03 20:11:14 -0500
commit2022037807e458ea88890eb279ba62fc18ff578d (patch)
tree522074c0b83d9a82ef94734ac24c17697da4664a
parentd0018220cc3cd2fe4114b72d54b519b868209df4 (diff)
More patches from pbatard to reduce warnings, etc.
-rw-r--r--example/isofile.c2
-rw-r--r--example/isofile2.c2
-rw-r--r--example/isofuzzy.c2
-rw-r--r--lib/driver/Makefile.am2
-rw-r--r--lib/driver/filemode.h146
-rw-r--r--lib/driver/image/bincue.c2
-rw-r--r--lib/driver/image/cdrdao.c2
-rw-r--r--lib/driver/image/nrg.c14
-rw-r--r--lib/driver/logging.c5
-rw-r--r--lib/driver/sector.c1
-rw-r--r--src/iso-read.c6
-rw-r--r--test/testisocd.c19
-rw-r--r--test/testisocd2.c.in1
13 files changed, 127 insertions, 77 deletions
diff --git a/example/isofile.c b/example/isofile.c
index 559aac12..bcfe06a5 100644
--- a/example/isofile.c
+++ b/example/isofile.c
@@ -31,7 +31,7 @@
/* portable.h has to come first else _FILE_OFFSET_BITS are redefined in
say opensolaris. */
-#include "filemode.h"
+#include "portable.h"
#include <cdio/cdio.h>
#include <cdio/iso9660.h>
diff --git a/example/isofile2.c b/example/isofile2.c
index 09ff4bed..474f0c1f 100644
--- a/example/isofile2.c
+++ b/example/isofile2.c
@@ -37,7 +37,7 @@
/* portable.h has to come first else _FILE_OFFSET_BITS are redefined in
say opensolaris. */
-#include "filemode.h"
+#include "portable.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
diff --git a/example/isofuzzy.c b/example/isofuzzy.c
index 9ca23baa..138e1fcf 100644
--- a/example/isofuzzy.c
+++ b/example/isofuzzy.c
@@ -28,7 +28,7 @@
/* portable.h has to come first else _FILE_OFFSET_BITS are redefined in
say opensolaris. */
-#include "filemode.h"
+#include "portable.h"
#ifdef HAVE_STDIO_H
#include <stdio.h>
diff --git a/lib/driver/Makefile.am b/lib/driver/Makefile.am
index d19bfcb7..8541bffc 100644
--- a/lib/driver/Makefile.am
+++ b/lib/driver/Makefile.am
@@ -49,7 +49,7 @@ EXTRA_DIST = image/Makefile \
FreeBSD/Makefile MSWindows/Makefile \
libcdio.sym
-noinst_HEADERS = cdio_assert.h cdio_private.h filemode.h
+noinst_HEADERS = cdio_assert.h cdio_private.h filemode.h portable.h
libcdio_sources = \
_cdio_generic.c \
diff --git a/lib/driver/filemode.h b/lib/driver/filemode.h
index 48034281..7ca25ba7 100644
--- a/lib/driver/filemode.h
+++ b/lib/driver/filemode.h
@@ -1,5 +1,8 @@
/*
- Copyright (C) 2006, 2008, 2011 Rocky Bernstein <rocky@gnu.org>
+ filemode.h -- file modes common definitions
+
+ Copyright (C) 2005, 2008, 2011 Rocky Bernstein <rocky@gnu.org>
+ Copyright (C) 1985, 1990, 1993, 1998-2000 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -15,62 +18,117 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-/*
- This file contains definitions to fill in for differences or
- deficiencies to OS or compiler irregularities. If this file is
- included other routines can be more portable.
-*/
-
-#ifndef __CDIO_PORTABLE_H__
-#define __CDIO_PORTABLE_H__
+#ifndef __FILEMODE_H__
+#define __FILEMODE_H__
-#if defined(HAVE_CONFIG_H) && !defined(__CDIO_CONFIG_H__)
-# include "config.h"
-# define __CDIO_CONFIG_H__ 1
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
#endif
-#if !defined(HAVE_FTRUNCATE)
-# if defined ( WIN32 )
-# define ftruncate chsize
+#ifndef S_IRUSR
+# ifdef S_IREAD
+# define S_IRUSR S_IREAD
+# else
+# define S_IRUSR 00400
# endif
-#endif /*HAVE_FTRUNCATE*/
+#endif
-#if !defined(HAVE_SNPRINTF)
-# if defined ( MSVC )
-# define snprintf _snprintf
+#ifndef S_IWUSR
+# ifdef S_IWRITE
+# define S_IWUSR S_IWRITE
+# else
+# define S_IWUSR 00200
# endif
-#endif /*HAVE_SNPRINTF*/
+#endif
-#if !defined(HAVE_VSNPRINTF)
-# if defined ( MSVC )
-# define snprintf _vsnprintf
+#ifndef S_IXUSR
+# ifdef S_IEXEC
+# define S_IXUSR S_IEXEC
+# else
+# define S_IXUSR 00100
# endif
-#endif /*HAVE_SNPRINTF*/
+#endif
-#if !defined(HAVE_DRAND48) && defined(HAVE_RAND)
-# define drand48() (rand() / (double)RAND_MAX)
+#ifndef S_IRGRP
+# define S_IRGRP (S_IRUSR >> 3)
+#endif
+#ifndef S_IWGRP
+# define S_IWGRP (S_IWUSR >> 3)
+#endif
+#ifndef S_IXGRP
+# define S_IXGRP (S_IXUSR >> 3)
+#endif
+#ifndef S_IROTH
+# define S_IROTH (S_IRUSR >> 6)
+#endif
+#ifndef S_IWOTH
+# define S_IWOTH (S_IWUSR >> 6)
+#endif
+#ifndef S_IXOTH
+# define S_IXOTH (S_IXUSR >> 6)
#endif
-#ifdef MSVC
-# include <io.h>
+#ifdef STAT_MACROS_BROKEN
+# undef S_ISBLK
+# undef S_ISCHR
+# undef S_ISDIR
+# undef S_ISFIFO
+# undef S_ISLNK
+# undef S_ISMPB
+# undef S_ISMPC
+# undef S_ISNWK
+# undef S_ISREG
+# undef S_ISSOCK
+#endif /* STAT_MACROS_BROKEN. */
-# ifndef S_ISBLK
-# define _S_IFBLK 0060000 /* Block Special */
-# define S_ISBLK(x) (x & _S_IFBLK)
-# endif
+#if !defined S_IFBLK && defined _WIN32
+# define S_IFBLK 0x3000
+#endif
+#if !defined S_IFIFO && defined _WIN32
+# define S_IFIFO 0x1000
+#endif
-# ifndef S_ISCHR
-# define _S_IFCHR 0020000 /* character special */
-# define S_ISCHR(x) (x & _S_IFCHR)
+#if !defined S_ISBLK && defined S_IFBLK
+# define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
+#endif
+#if !defined S_ISCHR && defined S_IFCHR
+# define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
+#endif
+#if !defined S_ISDIR && defined S_IFDIR
+# define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
+#endif
+#if !defined S_ISREG && defined S_IFREG
+# define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
+#endif
+#if !defined S_ISFIFO && defined S_IFIFO
+# define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
+#endif
+#if !defined HAVE_S_ISLNK
+# if !defined S_ISLNK && defined S_IFLNK
+# define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
+# else
+# define S_ISLNK(m) ((void)m, 0)
# endif
-#endif /*MSVC*/
-
-#ifdef HAVE_MEMSET
-# define BZERO(ptr, size) memset(ptr, 0, size)
-#elif HAVE_BZERO
-# define BZERO(ptr, size) bzero(ptr, size)
-#else
-#error You need either memset or bzero
+#endif
+#if !defined HAVE_S_ISSOCK
+# if !defined S_ISSOCK && defined S_IFSOCK
+# define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
+# else
+# define S_ISSOCK(m) ((void)m, 0)
+# endif
+#endif
+#if !defined S_ISMPB && defined S_IFMPB /* V7 */
+# define S_ISMPB(m) (((m) & S_IFMT) == S_IFMPB)
+# define S_ISMPC(m) (((m) & S_IFMT) == S_IFMPC)
+#endif
+#if !defined S_ISNWK && defined S_IFNWK /* HP/UX */
+# define S_ISNWK(m) (((m) & S_IFMT) == S_IFNWK)
+#endif
+#if !defined S_ISDOOR && defined S_IFDOOR /* Solaris 2.5 and up */
+# define S_ISDOOR(m) (((m) & S_IFMT) == S_IFDOOR)
+#endif
+#if !defined S_ISCTG && defined S_IFCTG /* MassComp */
+# define S_ISCTG(m) (((m) & S_IFMT) == S_IFCTG)
#endif
-#endif /* __CDIO_PORTABLE_H__ */
+#endif /* __FILEMODE_H__ */
diff --git a/lib/driver/image/bincue.c b/lib/driver/image/bincue.c
index 82a26b18..b11b0c45 100644
--- a/lib/driver/image/bincue.c
+++ b/lib/driver/image/bincue.c
@@ -59,7 +59,7 @@
#include <ctype.h>
-#include "filemode.h"
+#include "portable.h"
/* reader */
#define DEFAULT_CDIO_DEVICE "videocd.bin"
diff --git a/lib/driver/image/cdrdao.c b/lib/driver/image/cdrdao.c
index ae0ea7dd..b075392f 100644
--- a/lib/driver/image/cdrdao.c
+++ b/lib/driver/image/cdrdao.c
@@ -62,7 +62,7 @@
#include <ctype.h>
-#include "filemode.h"
+#include "portable.h"
/* reader */
diff --git a/lib/driver/image/nrg.c b/lib/driver/image/nrg.c
index f9ca93fb..9ba83d48 100644
--- a/lib/driver/image/nrg.c
+++ b/lib/driver/image/nrg.c
@@ -178,8 +178,8 @@ static bool
parse_nrg (_img_private_t *p_env, const char *psz_nrg_name,
const cdio_log_level_t log_level)
{
- long unsigned int footer_start;
- long unsigned int size;
+ off_t footer_start;
+ off_t size;
char *footer_buf = NULL;
if (!p_env) return false;
size = cdio_stream_stat (p_env->gen.data_source);
@@ -209,11 +209,11 @@ parse_nrg (_img_private_t *p_env, const char *psz_nrg_name,
cdio_assert ((size - footer_start) <= 4096);
- footer_buf = calloc(1, size - footer_start);
+ footer_buf = calloc(1, (size_t)(size - footer_start));
cdio_stream_seek (p_env->gen.data_source, footer_start, SEEK_SET);
cdio_stream_read (p_env->gen.data_source, footer_buf,
- size - footer_start, 1);
+ (size_t)(size - footer_start), 1);
}
{
int pos = 0;
@@ -844,9 +844,9 @@ _lseek_nrg (void *p_user_data, off_t offset, int whence)
track_info_t *this_track=&(p_env->tocent[i]);
p_env->pos.index = i;
if ( (this_track->sec_count*this_track->datasize) >= offset) {
- int blocks = offset / this_track->datasize;
- int rem = offset % this_track->datasize;
- int block_offset = blocks * this_track->blocksize;
+ int blocks = (int) (offset / this_track->datasize);
+ int rem = (int) (offset % this_track->datasize);
+ off_t block_offset = blocks * this_track->blocksize;
real_offset += block_offset + rem;
p_env->pos.buff_offset = rem;
p_env->pos.lba += blocks;
diff --git a/lib/driver/logging.c b/lib/driver/logging.c
index accb589f..f33daddc 100644
--- a/lib/driver/logging.c
+++ b/lib/driver/logging.c
@@ -1,5 +1,6 @@
/*
- Copyright (C) 2003, 2004, 2008, 2011 Rocky Bernstein <rocky@gnu.org>
+ Copyright (C) 2003, 2004, 2008, 2011, 2012
+ Rocky Bernstein <rocky@gnu.org>
Copyright (C) 2000 Herbert Valerio Riedel <hvr@gnu.org>
This program is free software: you can redistribute it and/or modify
@@ -27,7 +28,7 @@
#include <cdio/logging.h>
#include "cdio_assert.h"
-#include "filemode.h"
+#include "portable.h"
static const char _rcsid[] = "$Id: logging.c,v 1.2 2008/04/22 15:29:12 karl Exp $";
diff --git a/lib/driver/sector.c b/lib/driver/sector.c
index 199f6dc1..00a4db10 100644
--- a/lib/driver/sector.c
+++ b/lib/driver/sector.c
@@ -26,6 +26,7 @@
#include <cdio/util.h>
#include <cdio/logging.h>
#include "cdio_assert.h"
+#include "portable.h"
#include <stdio.h>
#ifdef HAVE_STRING_H
diff --git a/src/iso-read.c b/src/iso-read.c
index cb59b166..820fee32 100644
--- a/src/iso-read.c
+++ b/src/iso-read.c
@@ -1,7 +1,5 @@
/*
- $Id: iso-read.c,v 1.16 2008/06/19 15:44:19 flameeyes Exp $
-
- Copyright (C) 2004, 2005, 2006, 2008 Rocky Bernstein <rocky@gnu.org>
+ Copyright (C) 2004, 2005, 2006, 2008, 2012 Rocky Bernstein <rocky@gnu.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,7 +18,7 @@
/* Program to read ISO-9660 images. */
#include "util.h"
-#include "filemode.h"
+#include "portable.h"
#ifdef HAVE_CONFIG_H
# include "config.h"
diff --git a/test/testisocd.c b/test/testisocd.c
index e4c09264..498fd949 100644
--- a/test/testisocd.c
+++ b/test/testisocd.c
@@ -17,17 +17,7 @@
*/
/* Tests reading ISO 9660 info from a CD. */
-
-#ifdef HAVE_CONFIG_H
-# include "config.h"
-# define __CDIO_CONFIG_H__ 1
-#endif
-
-#include "filemode.h"
-
-#include <cdio/cdio.h>
-#include <cdio/iso9660.h>
-#include <cdio/cd_types.h>
+#include "portable.h"
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
@@ -47,9 +37,10 @@
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
+
+#include <cdio/cdio.h>
+#include <cdio/iso9660.h>
+#include <cdio/cd_types.h>
#define SKIP_TEST_RC 77
diff --git a/test/testisocd2.c.in b/test/testisocd2.c.in
index 0664c01b..e614c964 100644
--- a/test/testisocd2.c.in
+++ b/test/testisocd2.c.in
@@ -17,6 +17,7 @@
*/
/* Tests reading ISO 9660 info from an ISO 9660 image. */
+#include "portable.h"
#ifdef HAVE_CONFIG_H
# include "config.h"