libcdio-devel
[Top][All Lists]
Advanced

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

[Libcdio-devel] [PATCH 3/5] Harmonize source headers: C++ examples


From: Pete Batard
Subject: [Libcdio-devel] [PATCH 3/5] Harmonize source headers: C++ examples
Date: Fri, 10 Feb 2012 19:35:07 +0000
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:10.0) Gecko/20120129 Thunderbird/10.0

This is the first of 3 fairly independent but cumbersome patches that attempt to harmonize the header section of the libcdio sources.

It does so by removing duplicate or add missing one, and ensuring that the cdio specific files always come at the end, except for config. It also removed the need to config.h or types.h in case a file that already sets them up (eg. portable.h) is leardy included.

Regards,

/Pete
>From 0ab191abbd9f99dbd183abaa13f1b097e27509d2 Mon Sep 17 00:00:00 2001
From: Pete Batard <address@hidden>
Date: Fri, 10 Feb 2012 18:27:03 +0000
Subject: [PATCH 3/5] Harmonize source headers: C++ examples

---
 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 +++++++++---
 20 files changed, 150 insertions(+), 53 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[])
 {
-- 
1.7.8.msysgit.0


reply via email to

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