Fix up ability to use in C++ programs.
Add some C++ example programs to make sure those compile.
This commit is contained in:
12
configure.ac
12
configure.ac
@@ -19,7 +19,7 @@ define(RELEASE_NUM, 72)
|
||||
define(CDIO_VERSION_STR, 0.$1cvs)
|
||||
|
||||
AC_PREREQ(2.52)
|
||||
AC_REVISION([$Id: configure.ac,v 1.115 2004/11/21 22:32:03 rocky Exp $])dnl
|
||||
AC_REVISION([$Id: configure.ac,v 1.116 2004/11/22 01:03:52 rocky Exp $])dnl
|
||||
AC_INIT(libcdio, CDIO_VERSION_STR(RELEASE_NUM))
|
||||
AC_CONFIG_SRCDIR(src/cd-info.c)
|
||||
AM_INIT_AUTOMAKE
|
||||
@@ -52,10 +52,17 @@ AC_ARG_WITH(cd_info,
|
||||
[ --without-cd-info build program cd-info (enabled by default)],
|
||||
enable_cd_info="${withval}", enable_cd_info=yes)
|
||||
|
||||
AC_ARG_ENABLE(vcd_info,
|
||||
[ --disable-cpp don't make C++ example programs],
|
||||
enable_cpp=no,
|
||||
enable_cpp=yes)
|
||||
|
||||
dnl We use C
|
||||
AC_PROG_CC
|
||||
dnl We also use C++ in example programs
|
||||
AC_PROG_CXX
|
||||
|
||||
dnl Checks for programs.
|
||||
AC_PROG_CC
|
||||
AC_AIX
|
||||
|
||||
cd_drivers='cdrdao, BIN/CUE, NRG'
|
||||
@@ -224,6 +231,7 @@ AM_CONDITIONAL(BUILD_CDINFO, test "x$enable_cd_info" = "xyes")
|
||||
AM_CONDITIONAL(BUILD_CDINFO_LINUX, test "x$enable_cd_info_linux" = "xyes")
|
||||
AM_CONDITIONAL(BUILD_CDIOTEST, test "x$enable_cdiotest" = "xyes")
|
||||
AM_CONDITIONAL(BUILD_VERSIONED_LIBS, test "x$enable_versioned_libs" = "xyes")
|
||||
AM_CONDITIONAL(DISABLE_CPP, test "x$disable_cpp" = "xyes")
|
||||
|
||||
dnl Checks for header files.
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# $Id: Makefile.am,v 1.11 2004/10/26 08:32:29 rocky Exp $
|
||||
# $Id: Makefile.am,v 1.12 2004/11/22 01:03:53 rocky Exp $
|
||||
#
|
||||
# Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
#
|
||||
@@ -20,8 +20,13 @@
|
||||
# Things to regression testing
|
||||
####################################################
|
||||
#
|
||||
if DISABLE_CPP
|
||||
noinst_PROGRAMS = cdtext drives iso1 iso2 iso3 scsi-mmc1 scsi-mmc2 \
|
||||
tracks sample2 sample3 sample4
|
||||
else
|
||||
noinst_PROGRAMS = cdtext drives iso1 iso2 iso3 scsi-mmc1 scsi-mmc2 \
|
||||
tracks sample2 sample3 sample4 iso1cpp iso2cpp iso3cpp
|
||||
endif
|
||||
|
||||
INCLUDES = -I$(top_srcdir) $(LIBCDIO_CFLAGS)
|
||||
|
||||
@@ -33,6 +38,15 @@ iso1_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LIBICONV)
|
||||
iso2_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LIBICONV)
|
||||
iso3_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LIBICONV)
|
||||
|
||||
if !DISABLE_CPP
|
||||
iso1cpp_SOURCES = iso1cpp.cpp
|
||||
iso1cpp_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LIBICONV)
|
||||
iso2cpp_SOURCES = iso2cpp.cpp
|
||||
iso2cpp_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LIBICONV)
|
||||
iso3cpp_SOURCES = iso3cpp.cpp
|
||||
iso3cpp_LDADD = $(LIBISO9660_LIBS) $(LIBCDIO_LIBS) $(LIBICONV)
|
||||
endif
|
||||
|
||||
scsi_mmc1_LDADD = $(LIBCDIO_LIBS)
|
||||
scsi_mmc2_LDADD = $(LIBCDIO_LIBS)
|
||||
|
||||
@@ -41,3 +55,6 @@ sample3_LDADD = $(LIBCDIO_LIBS)
|
||||
sample4_LDADD = $(LIBCDIO_LIBS)
|
||||
|
||||
tracks_LDADD = $(LIBCDIO_LIBS)
|
||||
|
||||
# iso programs create file "copying"
|
||||
MOSTLYCLEANFILES = copying
|
||||
|
||||
87
example/iso1cpp.cpp
Normal file
87
example/iso1cpp.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
$Id: iso1cpp.cpp,v 1.1 2004/11/22 01:03:53 rocky Exp $
|
||||
|
||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* Simple program to show using libiso9660 to list files in a directory of
|
||||
an ISO-9660 image.
|
||||
|
||||
This program can be compiled with either a C or C++ compiler. In
|
||||
the distributuion we perfer C++ just to make sure we haven't broken
|
||||
things on the C++ side.
|
||||
*/
|
||||
|
||||
/* This is the ISO 9660 image. */
|
||||
#define ISO9660_IMAGE_PATH "../"
|
||||
#define ISO9660_IMAGE ISO9660_IMAGE_PATH "test/copying.iso"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
#include <sys/types.h>
|
||||
#include <cdio/cdio.h>
|
||||
#include <cdio/iso9660.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
|
||||
int
|
||||
main(int argc, const char *argv[])
|
||||
{
|
||||
CdioList *entlist;
|
||||
CdioListNode *entnode;
|
||||
|
||||
iso9660_t *p_iso = iso9660_open (ISO9660_IMAGE);
|
||||
|
||||
if (NULL == p_iso) {
|
||||
fprintf(stderr, "Sorry, couldn't open ISO 9660 image %s\n", ISO9660_IMAGE);
|
||||
return 1;
|
||||
}
|
||||
|
||||
entlist = iso9660_ifs_readdir (p_iso, "/");
|
||||
|
||||
/* Iterate over the list of nodes that iso9660_ifs_readdir gives */
|
||||
|
||||
_CDIO_LIST_FOREACH (entnode, entlist)
|
||||
{
|
||||
char filename[4096];
|
||||
iso9660_stat_t *p_statbuf =
|
||||
(iso9660_stat_t *) _cdio_list_node_data (entnode);
|
||||
iso9660_name_translate(p_statbuf->filename, filename);
|
||||
printf ("/%s\n", filename);
|
||||
}
|
||||
|
||||
_cdio_list_free (entlist, true);
|
||||
|
||||
iso9660_close(p_iso);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: iso2.c,v 1.3 2004/10/31 13:58:44 rocky Exp $
|
||||
$Id: iso2.c,v 1.4 2004/11/22 01:03:53 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -134,5 +134,7 @@ main(int argc, const char *argv[])
|
||||
if (ftruncate (fileno (p_outfd), p_statbuf->size))
|
||||
perror ("ftruncate()");
|
||||
|
||||
printf("Extraction of file 'copying' from %s successful.\n", ISO9660_IMAGE);
|
||||
|
||||
my_exit(0);
|
||||
}
|
||||
|
||||
144
example/iso2cpp.cpp
Normal file
144
example/iso2cpp.cpp
Normal file
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
$Id: iso2cpp.cpp,v 1.1 2004/11/22 01:03:53 rocky Exp $
|
||||
|
||||
Copyright (C) 2003, 2004 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
/* Simple program to show using libiso9660 to extract a file from a
|
||||
cue/bin CD-IMAGE.
|
||||
|
||||
This program can be compiled with either a C or C++ compiler. In
|
||||
the distributuion we perfer C++ just to make sure we haven't broken
|
||||
things on the C++ side.
|
||||
*/
|
||||
|
||||
/* This is the CD-image with an ISO-9660 filesystem */
|
||||
#define ISO9660_IMAGE_PATH "../"
|
||||
#define ISO9660_IMAGE ISO9660_IMAGE_PATH "test/isofs-m1.cue"
|
||||
|
||||
#define ISO9660_FILENAME "/COPYING.;1"
|
||||
#define LOCAL_FILENAME "copying"
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#include <cdio/cdio.h>
|
||||
#include <cdio/iso9660.h>
|
||||
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDLIB_H
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HAVE_STDIO_H
|
||||
#include <stdio.h>
|
||||
#endif
|
||||
#ifdef HAVE_ERRNO_H
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#ifdef HAVE_STRING_H
|
||||
#include <string.h>
|
||||
#endif
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef HAVE_SYS_TYPES_H
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
#define my_exit(rc) \
|
||||
fclose (p_outfd); \
|
||||
free(p_statbuf); \
|
||||
cdio_destroy(p_cdio); \
|
||||
return rc; \
|
||||
|
||||
|
||||
int
|
||||
main(int argc, const char *argv[])
|
||||
{
|
||||
iso9660_stat_t *p_statbuf;
|
||||
FILE *p_outfd;
|
||||
int i;
|
||||
|
||||
CdIo *p_cdio = cdio_open (ISO9660_IMAGE, DRIVER_BINCUE);
|
||||
|
||||
if (NULL == p_cdio) {
|
||||
fprintf(stderr, "Sorry, couldn't open BIN/CUE image %s\n", ISO9660_IMAGE);
|
||||
return 1;
|
||||
}
|
||||
|
||||
p_statbuf = iso9660_fs_stat (p_cdio, ISO9660_FILENAME);
|
||||
|
||||
if (NULL == p_statbuf)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Could not get ISO-9660 file information for file %s\n",
|
||||
ISO9660_FILENAME);
|
||||
cdio_destroy(p_cdio);
|
||||
return 2;
|
||||
}
|
||||
|
||||
if (!(p_outfd = fopen ("copying", "wb")))
|
||||
{
|
||||
perror ("fopen()");
|
||||
cdio_destroy(p_cdio);
|
||||
free(p_statbuf);
|
||||
return 3;
|
||||
}
|
||||
|
||||
/* Copy the blocks from the ISO-9660 filesystem to the local filesystem. */
|
||||
for (i = 0; i < p_statbuf->size; i += ISO_BLOCKSIZE)
|
||||
{
|
||||
char buf[ISO_BLOCKSIZE];
|
||||
|
||||
memset (buf, 0, ISO_BLOCKSIZE);
|
||||
|
||||
if ( 0 != cdio_read_mode1_sector (p_cdio, buf,
|
||||
p_statbuf->lsn + (i / ISO_BLOCKSIZE),
|
||||
false) )
|
||||
{
|
||||
fprintf(stderr, "Error reading ISO 9660 file at lsn %lu\n",
|
||||
(long unsigned int) p_statbuf->lsn + (i / ISO_BLOCKSIZE));
|
||||
my_exit(4);
|
||||
}
|
||||
|
||||
|
||||
fwrite (buf, ISO_BLOCKSIZE, 1, p_outfd);
|
||||
|
||||
if (ferror (p_outfd))
|
||||
{
|
||||
perror ("fwrite()");
|
||||
my_exit(5);
|
||||
}
|
||||
}
|
||||
|
||||
fflush (p_outfd);
|
||||
|
||||
/* Make sure the file size has the exact same byte size. Without the
|
||||
truncate below, the file will a multiple of ISO_BLOCKSIZE.
|
||||
*/
|
||||
if (ftruncate (fileno (p_outfd), p_statbuf->size))
|
||||
perror ("ftruncate()");
|
||||
|
||||
printf("Extraction of file 'copying' from %s successful.\n", ISO9660_IMAGE);
|
||||
|
||||
my_exit(0);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: iso3.c,v 1.2 2004/10/31 13:58:44 rocky Exp $
|
||||
$Id: iso3.c,v 1.3 2004/11/22 01:03:53 rocky Exp $
|
||||
|
||||
Copyright (C) 2004 Rocky Bernstein <rocky@panix.com>
|
||||
|
||||
@@ -129,5 +129,7 @@ main(int argc, const char *argv[])
|
||||
if (ftruncate (fileno (p_outfd), p_statbuf->size))
|
||||
perror ("ftruncate()");
|
||||
|
||||
printf("Extraction of file 'copying' from %s successful.\n", ISO9660_IMAGE);
|
||||
|
||||
my_exit(0);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
$Id: ds.h,v 1.1 2004/10/09 03:20:28 rocky Exp $
|
||||
$Id: ds.h,v 1.2 2004/11/22 01:03:53 rocky Exp $
|
||||
|
||||
Copyright (C) 2000, 2004 Herbert Valerio Riedel <hvr@gnu.org>
|
||||
|
||||
@@ -34,6 +34,10 @@ typedef int (*_cdio_list_cmp_func) (void *data1, void *data2);
|
||||
|
||||
typedef int (*_cdio_list_iterfunc) (void *data, void *user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* methods */
|
||||
CdioList *_cdio_list_new (void);
|
||||
|
||||
@@ -64,6 +68,10 @@ void _cdio_list_node_free (CdioListNode *node, int free_data);
|
||||
|
||||
void *_cdio_list_node_data (CdioListNode *node);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __CDIO_DS_H__ */
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user