libcdio-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libcdio-devel] [PATCH] harmonize example headers


From: Pete Batard
Subject: [Libcdio-devel] [PATCH] harmonize example headers
Date: Fri, 27 Jan 2012 18:00:37 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:9.0) Gecko/20111222 Thunderbird/9.0.1

I guess if I'm going to remove cdio_config.h, yet the examples use HAVE_####, one of the first thing to do is ensure that all the examples properly check for config.h, as not all of them currently do.

While doing that, I made sure that the header declaration was harmonized, so that:

1. the detection of config.h or portable.h (that includes detection of config.h) always comes first, with no space between it and the top level comments or top #define's. I guess if we wanted to harmonize all the way, we'd decide on whether we want to use the config.h detection block or portable.h always, and stick with it, but I haven't touched that

2. after a one line space, come the standard POSIX headers, with their guards if available. There were quite a few duplicated <sys/types.h> as well as missing #ifdef HAVE_STDIO_H which I fixed

3. after a one line space come the libcdio specific headers, and then one line to the start of code

The attached patch highlights how the files were affected.

Now, some of this harmonization required moving some libcdio headers down, which, I don't suspect should cause problems (and didn't seem to on the platforms I tested), but it may warrant further scrutiny.

Regards,

/Pete
From 2dac19b67199d91e4ed5b7a3902bb3b0e32e5d88 Mon Sep 17 00:00:00 2001
From: Pete Batard <address@hidden>
Date: Fri, 27 Jan 2012 17:43:30 +0000
Subject: [PATCH] Harmonize example headers

1. Include config.h or portable.h
2. Include standard headers, with guards and remove sys/types.h dupes
3. Include cdio specific headers
---
 example/C++/OO/cdtext.cpp   |    7 +++----
 example/C++/OO/device.cpp   |    8 ++++++--
 example/C++/OO/drives.cpp   |   11 ++++++++---
 example/C++/OO/eject.cpp    |    7 ++++++-
 example/C++/OO/iso4.cpp     |   11 ++++++++---
 example/C++/OO/isofile.cpp  |    9 +++++----
 example/C++/OO/isofile2.cpp |    8 +++-----
 example/C++/OO/isolist.cpp  |   11 ++++++++---
 example/C++/OO/mmc1.cpp     |   10 +++++++++-
 example/C++/OO/mmc2.cpp     |    7 ++++++-
 example/C++/OO/tracks.cpp   |   11 ++++++++++-
 example/C++/device.cpp      |    7 ++++++-
 example/C++/eject.cpp       |    8 +++++++-
 example/C++/isofile.cpp     |   10 +++++-----
 example/C++/isofile2.cpp    |   11 ++++++-----
 example/C++/isolist.cpp     |    9 ++++++---
 example/C++/mmc1.cpp        |   17 ++++++++++++++++-
 example/C++/mmc2.cpp        |   14 +++++++++++++-
 example/C++/paranoia.cpp    |   15 ++++++++++-----
 example/C++/paranoia2.cpp   |   12 +++++++++---
 example/audio.c             |   17 ++++++++---------
 example/cdchange.c          |   27 ++++++++++-----------------
 example/cdio-eject.c        |   11 ++++++++++-
 example/cdtext.c            |    7 +++++--
 example/device.c            |    8 +++++++-
 example/discid.c            |    7 ++++++-
 example/drives.c            |    8 +++++++-
 example/eject.c             |    8 +++++++-
 example/extract.c           |   26 ++++++++++++++++++--------
 example/isofile.c           |    1 -
 example/isofile2.c          |    6 +++---
 example/isofuzzy.c          |   10 +++++-----
 example/isolist.c           |   13 +++++++------
 example/isolsn.c            |   13 +++++++------
 example/mmc1.c              |    8 ++++++--
 example/mmc2.c              |    8 ++++++--
 example/mmc2a.c             |    7 +++++--
 example/mmc3.c              |   14 +++++++++++---
 example/paranoia.c          |   16 +++++++---------
 example/paranoia2.c         |   12 +++++++++---
 example/sample3.c           |   12 ++++++++++++
 example/sample4.c           |   12 ++++++++++++
 example/tracks.c            |    9 +++++++++
 example/udf1.c              |   13 +++++++++----
 example/udf2.c              |   13 +++++++++----
 example/udffile.c           |   14 +++++++-------
 46 files changed, 352 insertions(+), 151 deletions(-)

diff --git a/example/C++/OO/cdtext.cpp b/example/C++/OO/cdtext.cpp
index 394404b..0a69234 100644
--- a/example/C++/OO/cdtext.cpp
+++ b/example/C++/OO/cdtext.cpp
@@ -21,20 +21,19 @@
    libcdio.  An optional drive name can be supplied as an argument.
    See also corresponding C program of a similar name.
  */
-
-#include <cdio++/cdio.hpp>
 #ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
 #endif
 
 #ifdef HAVE_STDIO_H
 #include <stdio.h>
 #endif
-
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
 
+#include <cdio++/cdio.hpp>
 
 /* Set up a CD-DA image to test on which is in the libcdio distribution. */
 #define CDDA_IMAGE_PATH  "../../../test/"
diff --git a/example/C++/OO/device.cpp b/example/C++/OO/device.cpp
index fcb4b99..0521054 100644
--- a/example/C++/OO/device.cpp
+++ b/example/C++/OO/device.cpp
@@ -20,8 +20,10 @@
 /* Simple program to show drivers installed and what the default
    CD-ROM drive is. See also corresponding C program of a similar
    name. */
-
-#include <cdio++/cdio.hpp>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
 
 #ifdef HAVE_STDIO_H
 #include <stdio.h>
@@ -33,6 +35,8 @@
 #include <sys/types.h>
 #endif
 
+#include <cdio++/cdio.hpp>
+
 #define _(x) x
 
 /* Prints out drive capabilities */
diff --git a/example/C++/OO/drives.cpp b/example/C++/OO/drives.cpp
index ac318cb..789d576 100644
--- a/example/C++/OO/drives.cpp
+++ b/example/C++/OO/drives.cpp
@@ -17,9 +17,10 @@
 
 /* Simple program to show drivers installed and what the default 
    CD-ROM drive is and what CD drives are available. */
-#include <cdio++/cdio.hpp>
-#include <cdio/cd_types.h>
-#include <cdio/logging.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
 
 #ifdef HAVE_STDIO_H
 #include <stdio.h>
@@ -31,6 +32,10 @@
 #include <sys/types.h>
 #endif
 
+#include <cdio++/cdio.hpp>
+#include <cdio/cd_types.h>
+#include <cdio/logging.h>
+
 static void 
 log_handler (cdio_log_level_t level, const char message[])
 {
diff --git a/example/C++/OO/eject.cpp b/example/C++/OO/eject.cpp
index 1b6030a..974fd8b 100644
--- a/example/C++/OO/eject.cpp
+++ b/example/C++/OO/eject.cpp
@@ -24,7 +24,10 @@
 
    See also corresponding C program of a similar name. 
 */
-#include <cdio++/cdio.hpp>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
 
 #include <stdio.h>
 #ifdef HAVE_STDLIB_H
@@ -34,6 +37,8 @@
 #include <string.h>
 #endif
 
+#include <cdio++/cdio.hpp>
+
 int
 main(int argc, const char *argv[])
 {
diff --git a/example/C++/OO/iso4.cpp b/example/C++/OO/iso4.cpp
index 4f01df1..6a186a6 100644
--- a/example/C++/OO/iso4.cpp
+++ b/example/C++/OO/iso4.cpp
@@ -32,11 +32,14 @@
 #define ISO9660_IMAGE_PATH "../../../"
 #define ISO9660_IMAGE ISO9660_IMAGE_PATH "test/isofs-m1.cue"
 
-#include <sys/types.h>
-#include <cdio++/iso9660.hpp>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
 
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
-
+#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -50,6 +53,8 @@
 #include <sys/types.h>
 #endif
 
+#include <cdio++/iso9660.hpp>
+
 #define print_vd_info(title, fn)         \
   psz_str = p_pvd->fn();                 \
   if (psz_str) {                         \
diff --git a/example/C++/OO/isofile.cpp b/example/C++/OO/isofile.cpp
index 1e03412..da9e5b9 100644
--- a/example/C++/OO/isofile.cpp
+++ b/example/C++/OO/isofile.cpp
@@ -29,12 +29,11 @@
 
 #define LOCAL_FILENAME "copying"
 
-#include <sys/types.h>
-#include <cdio++/iso9660.hpp>
-
 #include "portable.h"
-#include <stdio.h>
 
+#ifdef HAVE_STDIO_H
+#include <stdio.h>
+#endif
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
@@ -51,6 +50,8 @@
 #include <sys/types.h>
 #endif
 
+#include <cdio++/iso9660.hpp>
+
 #define CEILING(x, y) ((x+(y-1))/y)
 
 #define my_exit(rc)                            \
diff --git a/example/C++/OO/isofile2.cpp b/example/C++/OO/isofile2.cpp
index 311c6ca..8a32bf6 100644
--- a/example/C++/OO/isofile2.cpp
+++ b/example/C++/OO/isofile2.cpp
@@ -35,13 +35,8 @@
 #define ISO9660_FILENAME "COPYING"
 #define LOCAL_FILENAME "copying"
 
-#include <cdio++/cdio.hpp>
-#include <cdio++/iso9660.hpp>
 #include "portable.h"
 
-#ifdef HAVE_SYS_TYPES_H
-#include <sys/types.h>
-#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -61,6 +56,9 @@
 #include <sys/types.h>
 #endif
 
+#include <cdio++/cdio.hpp>
+#include <cdio++/iso9660.hpp>
+
 #define CEILING(x, y) ((x+(y-1))/y)
 
 #define my_exit(rc)                            \
diff --git a/example/C++/OO/isolist.cpp b/example/C++/OO/isolist.cpp
index 52eb68c..e8642b9 100644
--- a/example/C++/OO/isolist.cpp
+++ b/example/C++/OO/isolist.cpp
@@ -34,11 +34,14 @@
 #define ISO9660_IMAGE_PATH "../../../"
 #define ISO9660_IMAGE ISO9660_IMAGE_PATH "test/copying.iso"
 
-#include <sys/types.h>
-#include <cdio++/iso9660.hpp>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
 
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
-
+#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -52,6 +55,8 @@
 #include <sys/types.h>
 #endif
 
+#include <cdio++/iso9660.hpp>
+
 #define print_vd_info(title, fn)         \
   if (p_iso->fn(psz_str)) {              \
     printf(title ": %s\n", psz_str);     \
diff --git a/example/C++/OO/mmc1.cpp b/example/C++/OO/mmc1.cpp
index 97bf25b..63425bb 100644
--- a/example/C++/OO/mmc1.cpp
+++ b/example/C++/OO/mmc1.cpp
@@ -20,8 +20,14 @@
    This basically the libdio mmc_get_hwinfo() routine.
    See also corresponding C and non OO C++ program.
 */
-#include <cdio++/cdio.hpp>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
+
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
+#endif
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
@@ -29,6 +35,8 @@
 #include <string.h>
 #endif
 
+#include <cdio++/cdio.hpp>
+
 /* Set how long to wait for MMC commands to complete */
 #define DEFAULT_TIMEOUT_MS 10000
 
diff --git a/example/C++/OO/mmc2.cpp b/example/C++/OO/mmc2.cpp
index 55aa1f3..62b522a 100644
--- a/example/C++/OO/mmc2.cpp
+++ b/example/C++/OO/mmc2.cpp
@@ -18,15 +18,20 @@
 /* A program to using the MMC interface to list CD and drive features
    from the MMC GET_CONFIGURATION command . */
 #ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
 #endif
+
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
+#endif
 #ifdef HAVE_SYS_TYPE_H
 #include <sys/types.h>
 #endif
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
+
 #include <cdio++/cdio.hpp>
 
 /* Set how long do wto wait for SCSI-MMC commands to complete */
diff --git a/example/C++/OO/tracks.cpp b/example/C++/OO/tracks.cpp
index 7dbb4ff..f7ef2d2 100644
--- a/example/C++/OO/tracks.cpp
+++ b/example/C++/OO/tracks.cpp
@@ -17,11 +17,20 @@
 
 /* Simple program to list track numbers and logical sector numbers of
    a Compact Disc using libcdio. */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
+
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
-#include <cdio++/cdio.hpp>
+#endif
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
+
+#include <cdio++/cdio.hpp>
+
 int
 main(int argc, const char *argv[])
 {
diff --git a/example/C++/device.cpp b/example/C++/device.cpp
index 4ab5610..ffd8ff8 100644
--- a/example/C++/device.cpp
+++ b/example/C++/device.cpp
@@ -19,8 +19,11 @@
 /* Simple program to show drivers installed and what the default
    CD-ROM drive is. See also corresponding C program of a similar
    name. */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
 
-#include <cdio/cdio.h>
 #ifdef HAVE_STDIO_H
 #include <stdio.h>
 #endif
@@ -31,6 +34,8 @@
 #include <sys/types.h>
 #endif
 
+#include <cdio/cdio.h>
+
 #define _(x) x
 
 /* Prints out drive capabilities */
diff --git a/example/C++/eject.cpp b/example/C++/eject.cpp
index f49e937..e483527 100644
--- a/example/C++/eject.cpp
+++ b/example/C++/eject.cpp
@@ -20,7 +20,11 @@
    If a single argument is given, it is used as the CD-ROM device to 
    eject/close. Otherwise a CD-ROM drive will be scanned for.
 */
-#include <cdio/cdio.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
+
 #ifdef HAVE_STDIO_H
 #include <stdio.h>
 #endif
@@ -31,6 +35,8 @@
 #include <string.h>
 #endif
 
+#include <cdio/cdio.h>
+
 int
 main(int argc, const char *argv[])
 {
diff --git a/example/C++/isofile.cpp b/example/C++/isofile.cpp
index f3be5fc..fdb8422 100644
--- a/example/C++/isofile.cpp
+++ b/example/C++/isofile.cpp
@@ -29,14 +29,11 @@
 
 #define LOCAL_FILENAME "copying"
 
-#include <sys/types.h>
-#include <cdio/cdio.h>
-#include <cdio/iso9660.h>
-
 #include "portable.h"
 
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
-
+#endif
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
@@ -53,6 +50,9 @@
 #include <sys/types.h>
 #endif
 
+#include <cdio/cdio.h>
+#include <cdio/iso9660.h>
+
 #define CEILING(x, y) ((x+(y-1))/y)
 
 #define my_exit(rc)                            \
diff --git a/example/C++/isofile2.cpp b/example/C++/isofile2.cpp
index 8670f84..838e2dd 100644
--- a/example/C++/isofile2.cpp
+++ b/example/C++/isofile2.cpp
@@ -29,13 +29,11 @@
 
 #define LOCAL_FILENAME "copying"
 
-#include <sys/types.h>
-#include <cdio/cdio.h>
-#include <cdio/iso9660.h>
-
 #include "portable.h"
-#include <stdio.h>
 
+#ifdef HAVE_STDIO_H
+#include <stdio.h>
+#endif
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
@@ -52,6 +50,9 @@
 #include <sys/types.h>
 #endif
 
+#include <cdio/cdio.h>
+#include <cdio/iso9660.h>
+
 #define CEILING(x, y) ((x+(y-1))/y)
 
 #define my_exit(rc)                            \
diff --git a/example/C++/isolist.cpp b/example/C++/isolist.cpp
index 0db0582..68a0964 100644
--- a/example/C++/isolist.cpp
+++ b/example/C++/isolist.cpp
@@ -33,12 +33,13 @@
 #define ISO9660_IMAGE ISO9660_IMAGE_PATH "test/copying.iso"
 
 #ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
 #endif
-#include <cdio/iso9660.h>
 
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
-
+#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -52,6 +53,8 @@
 #include <sys/types.h>
 #endif
 
+#include <cdio/iso9660.h>
+
 #define print_vd_info(title, fn)         \
   if (fn(p_iso, &psz_str)) {             \
     printf(title ": %s\n", psz_str);     \
diff --git a/example/C++/mmc1.cpp b/example/C++/mmc1.cpp
index 78b6804..67a6cd5 100644
--- a/example/C++/mmc1.cpp
+++ b/example/C++/mmc1.cpp
@@ -20,11 +20,26 @@
    This basically the libdio mmc_get_hwinfo() routine.
    See also corresponding C and OO C++ program.
 */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
+
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
 #include <cdio/cdio.h>
 #include <cdio/mmc.h>
-#include <string.h>
 
 /* Set how long to wait for MMC commands to complete */
 #define DEFAULT_TIMEOUT_MS 10000
diff --git a/example/C++/mmc2.cpp b/example/C++/mmc2.cpp
index a919058..ecec992 100644
--- a/example/C++/mmc2.cpp
+++ b/example/C++/mmc2.cpp
@@ -17,11 +17,23 @@
 
 /* A program to using the MMC interface to list CD and drive features
    from the MMC GET_CONFIGURATION command . */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
+
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
 #include <cdio/cdio.h>
 #include <cdio/mmc.h>
-#include <string.h>
 
 /* Set how long do wto wait for SCSI-MMC commands to complete */
 #define DEFAULT_TIMEOUT_MS 10000
diff --git a/example/C++/paranoia.cpp b/example/C++/paranoia.cpp
index a75581f..c9c452f 100644
--- a/example/C++/paranoia.cpp
+++ b/example/C++/paranoia.cpp
@@ -19,6 +19,10 @@
 
 /* Simple program to show using libcdio's version of the CD-DA paranoia. 
    library.  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
 
 #include <iostream>
 #include <cstdlib>
@@ -27,14 +31,15 @@
 using namespace std;
 
 extern "C"{
-  #include <cdio/paranoia.h>
-  #include <cdio/cd_types.h>
+  #ifdef HAVE_STDIO_H
   #include <stdio.h>
-
-#ifdef HAVE_STDLIB_H
+  #endif
+  #ifdef HAVE_STDLIB_H
   #include <stdlib.h>
-#endif
+  #endif
 
+  #include <cdio/paranoia.h>
+  #include <cdio/cd_types.h>
 }
 
 
diff --git a/example/C++/paranoia2.cpp b/example/C++/paranoia2.cpp
index f3a2d09..b2cbbd7 100644
--- a/example/C++/paranoia2.cpp
+++ b/example/C++/paranoia2.cpp
@@ -20,15 +20,21 @@
    calling paranoia's open. I imagine in many cases such as media
    players this may be what will be done since, one may want to get
    CDDB/CD-Text info beforehand.  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
 
-#include <cdio/cdda.h>
-#include <cdio/cd_types.h>
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
-
+#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
 
+#include <cdio/cdda.h>
+#include <cdio/cd_types.h>
+
 int
 main(int argc, const char *argv[])
 {
diff --git a/example/audio.c b/example/audio.c
index 57c187b..6951bd5 100644
--- a/example/audio.c
+++ b/example/audio.c
@@ -22,36 +22,35 @@
    CDDA player program using curses display see cdda-player in this
    distribution.
 */
-#include <cdio/cdio.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
 
 #ifdef HAVE_STDIO_H
 #include <stdio.h>
 #endif
-
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
-
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
-
+#ifdef HAVE_SYS_TIME_H
 #include <sys/time.h>
-
-#include <signal.h>
-
+#endif
 #ifdef HAVE_GETOPT_H
 #include <getopt.h>
 #endif
-
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
+#include <signal.h>
 
+#include <cdio/cdio.h>
 #include <cdio/mmc.h>
 #include <cdio/util.h>
 #include <cdio/cd_types.h>
diff --git a/example/cdchange.c b/example/cdchange.c
index f08cb21..ad2da74 100644
--- a/example/cdchange.c
+++ b/example/cdchange.c
@@ -16,46 +16,39 @@
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-/* config.h has to come first else _FILE_OFFSET_BITS are redefined in
-   say opensolaris. */
+/* Test media changed */
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 # define __CDIO_CONFIG_H__ 1
 #endif
 
-#include <cdio/cdio.h>
-
-/* Test media changed */
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
-
+#endif
 #ifdef HAVE_LIMITS_H
 #include <limits.h>
 #endif
-
 #ifdef HAVE_STDLIB_H
-# include <stdlib.h>
+#include <stdlib.h>
 #endif
-
 #ifdef HAVE_STRING_H
-# include <string.h>
+#include <string.h>
 #endif
-
 #ifdef HAVE_UNISTD_H
-# include <unistd.h>
+#include <unistd.h>
 #endif
-
 #ifdef HAVE_ERRNO_H
-# include <errno.h>
+#include <errno.h>
 #endif 
-
 #ifdef HAVE_WINDOWS_H
-# include <windows.h>
+#include <windows.h>
 #endif
-
 #ifndef HAVE_USLEEP
 #error usleep() unimplemented
 #endif
 
+#include <cdio/cdio.h>
+
 int
 main(int argc, const char *argv[])
 {
diff --git a/example/cdio-eject.c b/example/cdio-eject.c
index 5db25b5..e7e8bdd 100644
--- a/example/cdio-eject.c
+++ b/example/cdio-eject.c
@@ -14,10 +14,19 @@
   You should have received a copy of the GNU General Public License
   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
 
-#include <cdio/cdio.h>
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
+#endif
+#ifdef HAVE_STRING_H
 #include <string.h>
+#endif
+
+#include <cdio/cdio.h>
 
 static void usage(char * progname)
   {
diff --git a/example/cdtext.c b/example/cdtext.c
index 086b077..6374c86 100644
--- a/example/cdtext.c
+++ b/example/cdtext.c
@@ -18,8 +18,11 @@
 
 /* Simple program to list CD-Text info of a Compact Disc using
    libcdio.  See also corresponding C++ programs of similar names. */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
 
-#include <cdio/cdio.h>
 #ifdef HAVE_STDIO_H
 #include <stdio.h>
 #endif
@@ -27,9 +30,9 @@
 #include <sys/types.h>
 #endif
 
+#include <cdio/cdio.h>
 #include <cdio/cdtext.h>
 
-
 static void 
 print_cdtext_track_info(cdtext_t *cdtext, track_t i_track, const char 
*psz_msg) {
   cdtext_field_t i;
diff --git a/example/device.c b/example/device.c
index 23b7a39..0fd005e 100644
--- a/example/device.c
+++ b/example/device.c
@@ -18,7 +18,11 @@
 /* Simple program to show drivers installed and what the default
    CD-ROM drive is. See also corresponding C++ programs of similar
    names .*/
-#include <cdio/cdio.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
+
 #ifdef HAVE_STDIO_H
 #include <stdio.h>
 #endif
@@ -29,6 +33,8 @@
 #include <sys/types.h>
 #endif
 
+#include <cdio/cdio.h>
+
 #define _(x) x
 
 /* Prints out drive capabilities */
diff --git a/example/discid.c b/example/discid.c
index ebed2cc..3375ad1 100644
--- a/example/discid.c
+++ b/example/discid.c
@@ -22,8 +22,11 @@
    discs. The disc-ID can be used to query info (tracks, title,
    interpret) about compact audio discs from a CDDB-Server.
 */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
 
-#include <cdio/cdio.h>
 #ifdef HAVE_STDIO_H
 #include <stdio.h>
 #endif
@@ -31,6 +34,8 @@
 #include <sys/types.h>
 #endif
 
+#include <cdio/cdio.h>
+
 static int cddb_sum(int n)
 {
   int result = 0;
diff --git a/example/drives.c b/example/drives.c
index b06f30c..b28d279 100644
--- a/example/drives.c
+++ b/example/drives.c
@@ -17,7 +17,11 @@
 
 /* Simple program to show drivers installed and what the default 
    CD-ROM drive is and what CD drives are available. */
-#include <cdio/cdio.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
+
 #ifdef HAVE_STDIO_H
 #include <stdio.h>
 #endif
@@ -27,6 +31,8 @@
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
+
+#include <cdio/cdio.h>
 #include <cdio/cd_types.h>
 #include <cdio/logging.h>
 
diff --git a/example/eject.c b/example/eject.c
index d239ef2..b278b01 100644
--- a/example/eject.c
+++ b/example/eject.c
@@ -24,7 +24,11 @@
 
    See also corresponding C++ program of a similar name. 
 */
-#include <cdio/cdio.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
+
 #ifdef HAVE_STDIO_H
 #include <stdio.h>
 #endif
@@ -35,6 +39,8 @@
 #include <string.h>
 #endif
 
+#include <cdio/cdio.h>
+
 int
 main(int argc, const char *argv[])
 {
diff --git a/example/extract.c b/example/extract.c
index 6b5e03a..aba99ad 100644
--- a/example/extract.c
+++ b/example/extract.c
@@ -23,28 +23,38 @@
 /* To handle files > 2 GB, we may need the Large File Support settings
    defined in config.h. Comes first, as stdio.h depends on it. */
 #ifdef HAVE_CONFIG_H
-# include "config.h"
-# define __CDIO_CONFIG_H__ 1
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
 #endif
 
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
+#endif
+#ifdef HAVE_STRING_H
 #include <string.h>
-#include <malloc.h>
+#endif
+#ifdef HAVE_ERRNO_H
 #include <errno.h>
-
-#include <cdio/cdio.h>
-#include <cdio/logging.h>
-#include <cdio/iso9660.h>
-#include <cdio/udf.h>
+#endif
+#include <malloc.h>
 
 #if defined(_WIN32)
 #include <direct.h>
 #else
+#ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
+#endif
 #define _mkdir(a) mkdir(a, S_IRWXU)
 #endif
 
+#include <cdio/cdio.h>
+#include <cdio/logging.h>
+#include <cdio/iso9660.h>
+#include <cdio/udf.h>
+
 #ifndef MIN
 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
 #endif
diff --git a/example/isofile.c b/example/isofile.c
index 281408d..bcfe06a 100644
--- a/example/isofile.c
+++ b/example/isofile.c
@@ -33,7 +33,6 @@
    say opensolaris. */
 #include "portable.h"
 
-#include <sys/types.h>
 #include <cdio/cdio.h>
 #include <cdio/iso9660.h>
 
diff --git a/example/isofile2.c b/example/isofile2.c
index 753fe55..474f0c1 100644
--- a/example/isofile2.c
+++ b/example/isofile2.c
@@ -39,9 +39,6 @@
    say opensolaris. */
 #include "portable.h"
 
-#include <cdio/cdio.h>
-#include <cdio/iso9660.h>
-
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
@@ -64,6 +61,9 @@
 #include <sys/types.h>
 #endif
 
+#include <cdio/cdio.h>
+#include <cdio/iso9660.h>
+
 #define CEILING(x, y) ((x+(y-1))/y)
 
 #define my_exit(rc)                            \
diff --git a/example/isofuzzy.c b/example/isofuzzy.c
index 15e81ef..138e1fc 100644
--- a/example/isofuzzy.c
+++ b/example/isofuzzy.c
@@ -30,12 +30,9 @@
    say opensolaris. */
 #include "portable.h"
 
-#include <sys/types.h>
-#include <cdio/cdio.h>
-#include <cdio/iso9660.h>
-
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
-
+#endif
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
@@ -52,6 +49,9 @@
 #include <sys/types.h>
 #endif
 
+#include <cdio/cdio.h>
+#include <cdio/iso9660.h>
+
 int
 main(int argc, const char *argv[])
 {
diff --git a/example/isolist.c b/example/isolist.c
index 0cb86b9..9233d2e 100644
--- a/example/isolist.c
+++ b/example/isolist.c
@@ -30,15 +30,13 @@
 #define ISO9660_IMAGE ISO9660_IMAGE_PATH "copying.iso"
 
 #ifdef HAVE_CONFIG_H
-# include "config.h"
-# define __CDIO_CONFIG_H__ 1
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
 #endif
-#include <sys/types.h>
-#include <cdio/cdio.h>
-#include <cdio/iso9660.h>
 
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
-
+#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -52,6 +50,9 @@
 #include <sys/types.h>
 #endif
 
+#include <cdio/cdio.h>
+#include <cdio/iso9660.h>
+
 #define print_vd_info(title, fn)         \
   if (fn(p_iso, &psz_str)) {             \
     printf(title ": %s\n", psz_str);     \
diff --git a/example/isolsn.c b/example/isolsn.c
index cdcfa06..d3046ac 100644
--- a/example/isolsn.c
+++ b/example/isolsn.c
@@ -32,15 +32,13 @@
 #define ISO9660_IMAGE ISO9660_IMAGE_PATH "copying.iso"
 
 #ifdef HAVE_CONFIG_H
-# include "config.h"
-# define __CDIO_CONFIG_H__ 1
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
 #endif
-#include <sys/types.h>
-#include <cdio/cdio.h>
-#include <cdio/iso9660.h>
 
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
-
+#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -54,6 +52,9 @@
 #include <sys/types.h>
 #endif
 
+#include <cdio/cdio.h>
+#include <cdio/iso9660.h>
+
 #define print_vd_info(title, fn)         \
   if (fn(p_iso, &psz_str)) {             \
     printf(title ": %s\n", psz_str);     \
diff --git a/example/mmc1.c b/example/mmc1.c
index 84fb470..08bfddc 100644
--- a/example/mmc1.c
+++ b/example/mmc1.c
@@ -22,16 +22,20 @@
    See also corresponding C++ programs.
 */
 #ifdef HAVE_CONFIG_H
-# include "config.h"
-# define __CDIO_CONFIG_H__ 1
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
 #endif
+
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
+#endif
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
+
 #include <cdio/cdio.h>
 #include <cdio/mmc.h>
 #include <cdio/mmc_cmds.h>
diff --git a/example/mmc2.c b/example/mmc2.c
index 46eb1db..e98cd0f 100644
--- a/example/mmc2.c
+++ b/example/mmc2.c
@@ -18,16 +18,20 @@
 /* A program to using the MMC interface to list CD and drive features
    from the MMC GET_CONFIGURATION command . */
 #ifdef HAVE_CONFIG_H
-# include "config.h"
-# define __CDIO_CONFIG_H__ 1
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
 #endif
+
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
+#endif
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
 #ifdef HAVE_STRING_H
 #include <string.h>
 #endif
+
 #include <cdio/cdio.h>
 #include <cdio/mmc.h>
 
diff --git a/example/mmc2a.c b/example/mmc2a.c
index 1a4848d..b90a87b 100644
--- a/example/mmc2a.c
+++ b/example/mmc2a.c
@@ -22,10 +22,13 @@
    routines.
 */
 #ifdef HAVE_CONFIG_H
-# include "config.h"
-# define __CDIO_CONFIG_H__ 1
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
 #endif
+
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
+#endif
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
diff --git a/example/mmc3.c b/example/mmc3.c
index 135a99e..033593a 100644
--- a/example/mmc3.c
+++ b/example/mmc3.c
@@ -19,17 +19,25 @@
    the libdio scsi_mmc_get_hwinfo() routine.
 */
 #ifdef HAVE_CONFIG_H
-# include "config.h"
-# define __CDIO_CONFIG_H__ 1
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
 #endif
+
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
+#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
 #include <cdio/cdio.h>
 #include <cdio/mmc.h>
-#include <string.h>
 
 /* Set how long to wait for MMC commands to complete */
 #define DEFAULT_TIMEOUT_MS 10000
diff --git a/example/paranoia.c b/example/paranoia.c
index 7df6b9c..25c2c88 100644
--- a/example/paranoia.c
+++ b/example/paranoia.c
@@ -22,32 +22,30 @@
 /* config.h has to come first else _FILE_OFFSET_BITS are redefined in
    say opensolaris. */
 #ifdef HAVE_CONFIG_H
-# include "config.h"
-# define __CDIO_CONFIG_H__ 1
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
 #endif
 
-#include <cdio/paranoia.h>
-#include <cdio/cd_types.h>
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
-
+#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
-
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
 #endif
-
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
-
 #ifdef HAVE_SYS_STAT_H
 #include <sys/stat.h>
 #endif
-
 #include <fcntl.h>
 
+#include <cdio/paranoia.h>
+#include <cdio/cd_types.h>
+
 static void 
 put_num(long int num, int f, int bytes)
 {
diff --git a/example/paranoia2.c b/example/paranoia2.c
index 19a725b..949ba5d 100644
--- a/example/paranoia2.c
+++ b/example/paranoia2.c
@@ -21,15 +21,21 @@
    players this may be what will be done since, one may want to get
    CDDB/CD-Text info beforehand.
  */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
 
-#include <cdio/cdda.h>
-#include <cdio/cd_types.h>
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
-
+#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
 
+#include <cdio/cdda.h>
+#include <cdio/cd_types.h>
+
 int
 main(int argc, const char *argv[])
 {
diff --git a/example/sample3.c b/example/sample3.c
index aff0b57..e5bf96e 100644
--- a/example/sample3.c
+++ b/example/sample3.c
@@ -19,9 +19,21 @@
    A somewhat simplified program to show the use of cdio_guess_cd_type().
    Figure out the kind of CD image we've got.
 */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
+
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
+#endif
+#ifdef HAVE_STRING_H
 #include <string.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
+#endif
+
 #include <cdio/cdio.h>
 #include <cdio/cd_types.h>
 
diff --git a/example/sample4.c b/example/sample4.c
index 21826c5..4e75f5c 100644
--- a/example/sample4.c
+++ b/example/sample4.c
@@ -19,9 +19,21 @@
    A slightly improved sample3 program: we handle cdio logging and
    take an optional CD-location.
 */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
+
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
+#endif
+#ifdef HAVE_STRING_H
 #include <string.h>
+#endif
+#ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
+#endif
+
 #include <cdio/cdio.h>
 #include <cdio/cd_types.h>
 #include <cdio/logging.h>
diff --git a/example/tracks.c b/example/tracks.c
index 8422735..8a2e633 100644
--- a/example/tracks.c
+++ b/example/tracks.c
@@ -18,11 +18,20 @@
 
 /* Simple program to list track numbers and logical sector numbers of
    a Compact Disc using libcdio. */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
+
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
+#endif
 #ifdef HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
+
 #include <cdio/cdio.h>
+
 int
 main(int argc, const char *argv[])
 {
diff --git a/example/udf1.c b/example/udf1.c
index 52f7077..2da6f8f 100644
--- a/example/udf1.c
+++ b/example/udf1.c
@@ -25,12 +25,14 @@
 #define UDF_IMAGE_PATH "../"
 #define UDF_IMAGE "/src2/cd-images/udf/UDF102ISO.iso"
 
-#include <sys/types.h>
-#include <cdio/cdio.h>
-#include <cdio/udf.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
 
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
-
+#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -44,6 +46,9 @@
 #include <sys/types.h>
 #endif
 
+#include <cdio/cdio.h>
+#include <cdio/udf.h>
+
 #define udf_PATH_DELIMITERS "/\\"
 
 static void 
diff --git a/example/udf2.c b/example/udf2.c
index 2cd5ef1..1c0cd4e 100644
--- a/example/udf2.c
+++ b/example/udf2.c
@@ -27,12 +27,14 @@
 #define UDF_IMAGE "/src2/cd-images/udf/test2.iso"
 #define UDF_FILENAME "/parse/cue.L"
 
-#include <sys/types.h>
-#include <cdio/cdio.h>
-#include <cdio/udf.h>
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
+#endif
 
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
-
+#endif
 #ifdef HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -46,6 +48,9 @@
 #include <sys/types.h>
 #endif
 
+#include <cdio/cdio.h>
+#include <cdio/udf.h>
+
 #define CEILING(x, y) ((x+(y-1))/y)
 
 #define udf_PATH_DELIMITERS "/\\"
diff --git a/example/udffile.c b/example/udffile.c
index 2bb8e8a..ffbc011 100644
--- a/example/udffile.c
+++ b/example/udffile.c
@@ -26,8 +26,8 @@
 /* config.h has to come first else _FILE_OFFSET_BITS are redefined in
    say opensolaris. */
 #ifdef HAVE_CONFIG_H
-# include "config.h"
-# define __CDIO_CONFIG_H__ 1
+#include "config.h"
+#define __CDIO_CONFIG_H__ 1
 #endif
 
 /* This is the UDF image. */
@@ -36,12 +36,9 @@
 #define UDF_FILENAME "/COPYING"
 #define LOCAL_FILENAME "copying"
 
-#include <sys/types.h>
-#include <cdio/cdio.h>
-#include <cdio/udf.h>
-
+#ifdef HAVE_STDIO_H
 #include <stdio.h>
-
+#endif
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
@@ -58,6 +55,9 @@
 #include <sys/types.h>
 #endif
 
+#include <cdio/cdio.h>
+#include <cdio/udf.h>
+
 #define CEILING(x, y) ((x+(y-1))/y)
 
 #define udf_PATH_DELIMITERS "/\\"
-- 
1.7.8.msysgit.0


reply via email to

[Prev in Thread] Current Thread [Next in Thread]