Search
lxdream.org :: lxdream :: r1152:6464d890cc9e
lxdream 0.9.1
released Jun 29
Download Now
changeset1152:6464d890cc9e
parent1151:e1848ca9b5b1
child1153:00e507e4025c
authornkeynes
dateThu Dec 23 17:50:10 2010 +1000 (8 years ago)
Clone iso_memory_stream_new() as iso_mem_stream_new(), since current
versions of libisofs have made it unlinkable on linux
src/Makefile.am
src/Makefile.in
src/drivers/cdrom/isofs.h
src/drivers/cdrom/isomem.c
src/loader.c
1.1 --- a/src/Makefile.am Wed Dec 08 18:33:23 2010 +1000
1.2 +++ b/src/Makefile.am Thu Dec 23 17:50:10 2010 +1000
1.3 @@ -73,7 +73,7 @@
1.4 drivers/cdrom/edc_ecc.c drivers/cdrom/ecc.h drivers/cdrom/drive.c \
1.5 drivers/cdrom/edc_crctable.h drivers/cdrom/edc_encoder.h \
1.6 drivers/cdrom/edc_l2sq.h drivers/cdrom/edc_scramble.h drivers/cdrom/cd_mmc.c \
1.7 - drivers/cdrom/isofs.h drivers/cdrom/isofs.c \
1.8 + drivers/cdrom/isofs.h drivers/cdrom/isofs.c drivers/cdrom/isomem.c \
1.9 sh4/sh4.def sh4/sh4core.in sh4/sh4x86.in sh4/sh4dasm.in sh4/sh4stat.in \
1.10 hotkeys.c hotkeys.h
1.11 lxdream_CPPFLAGS = @LXDREAMCPPFLAGS@
2.1 --- a/src/Makefile.in Wed Dec 08 18:33:23 2010 +1000
2.2 +++ b/src/Makefile.in Thu Dec 23 17:50:10 2010 +1000
2.3 @@ -175,11 +175,12 @@
2.4 drivers/cdrom/drive.c drivers/cdrom/edc_crctable.h \
2.5 drivers/cdrom/edc_encoder.h drivers/cdrom/edc_l2sq.h \
2.6 drivers/cdrom/edc_scramble.h drivers/cdrom/cd_mmc.c \
2.7 - drivers/cdrom/isofs.h drivers/cdrom/isofs.c sh4/sh4.def \
2.8 - sh4/sh4core.in sh4/sh4x86.in sh4/sh4dasm.in sh4/sh4stat.in \
2.9 - hotkeys.c hotkeys.h plugin.c plugin.h sh4/sh4x86.c \
2.10 - xlat/x86/x86op.h xlat/x86/ia32abi.h xlat/x86/amd64abi.h \
2.11 - sh4/sh4trans.c sh4/sh4trans.h sh4/mmux86.c x86dasm/x86dasm.c \
2.12 + drivers/cdrom/isofs.h drivers/cdrom/isofs.c \
2.13 + drivers/cdrom/isomem.c sh4/sh4.def sh4/sh4core.in \
2.14 + sh4/sh4x86.in sh4/sh4dasm.in sh4/sh4stat.in hotkeys.c \
2.15 + hotkeys.h plugin.c plugin.h sh4/sh4x86.c xlat/x86/x86op.h \
2.16 + xlat/x86/ia32abi.h xlat/x86/amd64abi.h sh4/sh4trans.c \
2.17 + sh4/sh4trans.h sh4/mmux86.c x86dasm/x86dasm.c \
2.18 x86dasm/x86dasm.h x86dasm/i386-dis.c x86dasm/dis-init.c \
2.19 x86dasm/dis-buf.c x86dasm/ansidecl.h x86dasm/bfd.h \
2.20 x86dasm/dis-asm.h x86dasm/symcat.h x86dasm/sysdep.h \
2.21 @@ -280,13 +281,14 @@
2.22 lxdream-cd_nrg.$(OBJEXT) lxdream-cd_cdi.$(OBJEXT) \
2.23 lxdream-cd_gdi.$(OBJEXT) lxdream-edc_ecc.$(OBJEXT) \
2.24 lxdream-drive.$(OBJEXT) lxdream-cd_mmc.$(OBJEXT) \
2.25 - lxdream-isofs.$(OBJEXT) lxdream-hotkeys.$(OBJEXT) \
2.26 - $(am__objects_1) $(am__objects_2) $(am__objects_3) \
2.27 - $(am__objects_4) $(am__objects_5) $(am__objects_6) \
2.28 - $(am__objects_7) $(am__objects_8) $(am__objects_9) \
2.29 - $(am__objects_10) $(am__objects_11) $(am__objects_12) \
2.30 - $(am__objects_13) $(am__objects_14) $(am__objects_15) \
2.31 - $(am__objects_16) $(am__objects_17) $(am__objects_18)
2.32 + lxdream-isofs.$(OBJEXT) lxdream-isomem.$(OBJEXT) \
2.33 + lxdream-hotkeys.$(OBJEXT) $(am__objects_1) $(am__objects_2) \
2.34 + $(am__objects_3) $(am__objects_4) $(am__objects_5) \
2.35 + $(am__objects_6) $(am__objects_7) $(am__objects_8) \
2.36 + $(am__objects_9) $(am__objects_10) $(am__objects_11) \
2.37 + $(am__objects_12) $(am__objects_13) $(am__objects_14) \
2.38 + $(am__objects_15) $(am__objects_16) $(am__objects_17) \
2.39 + $(am__objects_18)
2.40 lxdream_OBJECTS = $(am_lxdream_OBJECTS)
2.41 lxdream_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
2.42 $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
2.43 @@ -595,15 +597,15 @@
2.44 drivers/cdrom/drive.c drivers/cdrom/edc_crctable.h \
2.45 drivers/cdrom/edc_encoder.h drivers/cdrom/edc_l2sq.h \
2.46 drivers/cdrom/edc_scramble.h drivers/cdrom/cd_mmc.c \
2.47 - drivers/cdrom/isofs.h drivers/cdrom/isofs.c sh4/sh4.def \
2.48 - sh4/sh4core.in sh4/sh4x86.in sh4/sh4dasm.in sh4/sh4stat.in \
2.49 - hotkeys.c hotkeys.h $(am__append_1) $(am__append_2) \
2.50 - $(am__append_4) $(am__append_5) $(am__append_6) \
2.51 - $(am__append_7) $(am__append_8) $(am__append_9) \
2.52 - $(am__append_10) $(am__append_17) $(am__append_19) \
2.53 - $(am__append_21) $(am__append_23) $(am__append_25) \
2.54 - $(am__append_27) $(am__append_28) $(am__append_29) \
2.55 - $(am__append_30)
2.56 + drivers/cdrom/isofs.h drivers/cdrom/isofs.c \
2.57 + drivers/cdrom/isomem.c sh4/sh4.def sh4/sh4core.in \
2.58 + sh4/sh4x86.in sh4/sh4dasm.in sh4/sh4stat.in hotkeys.c \
2.59 + hotkeys.h $(am__append_1) $(am__append_2) $(am__append_4) \
2.60 + $(am__append_5) $(am__append_6) $(am__append_7) \
2.61 + $(am__append_8) $(am__append_9) $(am__append_10) \
2.62 + $(am__append_17) $(am__append_19) $(am__append_21) \
2.63 + $(am__append_23) $(am__append_25) $(am__append_27) \
2.64 + $(am__append_28) $(am__append_29) $(am__append_30)
2.65 lxdream_CPPFLAGS = @LXDREAMCPPFLAGS@
2.66 @BUILD_SH4X86_TRUE@test_testsh4x86_LDADD = @LXDREAM_LIBS@ @GLIB_LIBS@ @GTK_LIBS@ @LIBPNG_LIBS@
2.67 @BUILD_SH4X86_TRUE@test_testsh4x86_CPPFLAGS = @LXDREAMCPPFLAGS@
2.68 @@ -838,6 +840,7 @@
2.69 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-io_osx.Po@am__quote@
2.70 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-ioutil.Po@am__quote@
2.71 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-isofs.Po@am__quote@
2.72 +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-isomem.Po@am__quote@
2.73 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-joy_linux.Po@am__quote@
2.74 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-kbd.Po@am__quote@
2.75 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lxdream-lightgun.Po@am__quote@
2.76 @@ -2085,6 +2088,20 @@
2.77 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.78 @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lxdream-isofs.obj `if test -f 'drivers/cdrom/isofs.c'; then $(CYGPATH_W) 'drivers/cdrom/isofs.c'; else $(CYGPATH_W) '$(srcdir)/drivers/cdrom/isofs.c'; fi`
2.79
2.80 +lxdream-isomem.o: drivers/cdrom/isomem.c
2.81 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lxdream-isomem.o -MD -MP -MF "$(DEPDIR)/lxdream-isomem.Tpo" -c -o lxdream-isomem.o `test -f 'drivers/cdrom/isomem.c' || echo '$(srcdir)/'`drivers/cdrom/isomem.c; \
2.82 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lxdream-isomem.Tpo" "$(DEPDIR)/lxdream-isomem.Po"; else rm -f "$(DEPDIR)/lxdream-isomem.Tpo"; exit 1; fi
2.83 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/cdrom/isomem.c' object='lxdream-isomem.o' libtool=no @AMDEPBACKSLASH@
2.84 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.85 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lxdream-isomem.o `test -f 'drivers/cdrom/isomem.c' || echo '$(srcdir)/'`drivers/cdrom/isomem.c
2.86 +
2.87 +lxdream-isomem.obj: drivers/cdrom/isomem.c
2.88 +@am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lxdream-isomem.obj -MD -MP -MF "$(DEPDIR)/lxdream-isomem.Tpo" -c -o lxdream-isomem.obj `if test -f 'drivers/cdrom/isomem.c'; then $(CYGPATH_W) 'drivers/cdrom/isomem.c'; else $(CYGPATH_W) '$(srcdir)/drivers/cdrom/isomem.c'; fi`; \
2.89 +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lxdream-isomem.Tpo" "$(DEPDIR)/lxdream-isomem.Po"; else rm -f "$(DEPDIR)/lxdream-isomem.Tpo"; exit 1; fi
2.90 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='drivers/cdrom/isomem.c' object='lxdream-isomem.obj' libtool=no @AMDEPBACKSLASH@
2.91 +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
2.92 +@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o lxdream-isomem.obj `if test -f 'drivers/cdrom/isomem.c'; then $(CYGPATH_W) 'drivers/cdrom/isomem.c'; else $(CYGPATH_W) '$(srcdir)/drivers/cdrom/isomem.c'; fi`
2.93 +
2.94 lxdream-hotkeys.o: hotkeys.c
2.95 @am__fastdepCC_TRUE@ if $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(lxdream_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT lxdream-hotkeys.o -MD -MP -MF "$(DEPDIR)/lxdream-hotkeys.Tpo" -c -o lxdream-hotkeys.o `test -f 'hotkeys.c' || echo '$(srcdir)/'`hotkeys.c; \
2.96 @am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/lxdream-hotkeys.Tpo" "$(DEPDIR)/lxdream-hotkeys.Po"; else rm -f "$(DEPDIR)/lxdream-hotkeys.Tpo"; exit 1; fi
3.1 --- a/src/drivers/cdrom/isofs.h Wed Dec 08 18:33:23 2010 +1000
3.2 +++ b/src/drivers/cdrom/isofs.h Thu Dec 23 17:50:10 2010 +1000
3.3 @@ -57,6 +57,6 @@
3.4
3.5
3.6 /** Prototypes for "Internal" Libisofs functions */
3.7 -int iso_memory_stream_new(unsigned char *buf, size_t size, IsoStream **stream);
3.8 +int iso_mem_stream_new(unsigned char *buf, size_t size, IsoStream **stream);
3.9
3.10 #endif /* !cdrom_isofs_H */
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/src/drivers/cdrom/isomem.c Thu Dec 23 17:50:10 2010 +1000
4.3 @@ -0,0 +1,178 @@
4.4 +/*
4.5 + * Copyright (c) 2007 Vreixo Formoso
4.6 + * Copyright (c) 2009 Thomas Schmitt
4.7 + *
4.8 + * This file is part of the libisofs project; you can redistribute it and/or
4.9 + * modify it under the terms of the GNU General Public License version 2
4.10 + * or later as published by the Free Software Foundation.
4.11 + * See COPYING file for details.
4.12 + *
4.13 + * Memory stream extracted for use in lxdream by Nathan Keynes 2010.
4.14 + */
4.15 +
4.16 +#include <libisofs.h>
4.17 +
4.18 +#include <stdlib.h>
4.19 +#include <string.h>
4.20 +#include <limits.h>
4.21 +#include <stdio.h>
4.22 +
4.23 +#ifndef MIN
4.24 +#define MIN(a,b) ((a)<=(b) ? (a) : (b))
4.25 +#endif
4.26 +
4.27 +#define ISO_MEM_FS_ID 4
4.28 +
4.29 +ino_t mem_serial_id = (ino_t)1;
4.30 +
4.31 +typedef struct
4.32 +{
4.33 + uint8_t *buf;
4.34 + ssize_t offset; /* -1 if stream closed */
4.35 + ino_t ino_id;
4.36 + size_t size;
4.37 +} MemStreamData;
4.38 +
4.39 +static
4.40 +int mem_open(IsoStream *stream)
4.41 +{
4.42 + MemStreamData *data;
4.43 + if (stream == NULL) {
4.44 + return ISO_NULL_POINTER;
4.45 + }
4.46 + data = (MemStreamData*)stream->data;
4.47 + if (data->offset != -1) {
4.48 + return ISO_FILE_ALREADY_OPENED;
4.49 + }
4.50 + data->offset = 0;
4.51 + return ISO_SUCCESS;
4.52 +}
4.53 +
4.54 +static
4.55 +int mem_close(IsoStream *stream)
4.56 +{
4.57 + MemStreamData *data;
4.58 + if (stream == NULL) {
4.59 + return ISO_NULL_POINTER;
4.60 + }
4.61 + data = (MemStreamData*)stream->data;
4.62 + if (data->offset == -1) {
4.63 + return ISO_FILE_NOT_OPENED;
4.64 + }
4.65 + data->offset = -1;
4.66 + return ISO_SUCCESS;
4.67 +}
4.68 +
4.69 +static
4.70 +off_t mem_get_size(IsoStream *stream)
4.71 +{
4.72 + MemStreamData *data;
4.73 + data = (MemStreamData*)stream->data;
4.74 +
4.75 + return (off_t)data->size;
4.76 +}
4.77 +
4.78 +static
4.79 +int mem_read(IsoStream *stream, void *buf, size_t count)
4.80 +{
4.81 + size_t len;
4.82 + MemStreamData *data;
4.83 + if (stream == NULL || buf == NULL) {
4.84 + return ISO_NULL_POINTER;
4.85 + }
4.86 + if (count == 0) {
4.87 + return ISO_WRONG_ARG_VALUE;
4.88 + }
4.89 + data = stream->data;
4.90 +
4.91 + if (data->offset == -1) {
4.92 + return ISO_FILE_NOT_OPENED;
4.93 + }
4.94 +
4.95 + if (data->offset >= data->size) {
4.96 + return 0; /* EOF */
4.97 + }
4.98 +
4.99 + len = MIN(count, data->size - data->offset);
4.100 + memcpy(buf, data->buf + data->offset, len);
4.101 + data->offset += len;
4.102 + return len;
4.103 +}
4.104 +
4.105 +static
4.106 +int mem_is_repeatable(IsoStream *stream)
4.107 +{
4.108 + return 1;
4.109 +}
4.110 +
4.111 +static
4.112 +void mem_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id,
4.113 + ino_t *ino_id)
4.114 +{
4.115 + MemStreamData *data;
4.116 + data = (MemStreamData*)stream->data;
4.117 + *fs_id = ISO_MEM_FS_ID;
4.118 + *dev_id = 0;
4.119 + *ino_id = data->ino_id;
4.120 +}
4.121 +
4.122 +static
4.123 +void mem_free(IsoStream *stream)
4.124 +{
4.125 + MemStreamData *data;
4.126 + data = (MemStreamData*)stream->data;
4.127 + free(data->buf);
4.128 + free(data);
4.129 +}
4.130 +
4.131 +IsoStreamIface mem_stream_class = {
4.132 + 0,
4.133 + "mem ",
4.134 + mem_open,
4.135 + mem_close,
4.136 + mem_get_size,
4.137 + mem_read,
4.138 + mem_is_repeatable,
4.139 + mem_get_id,
4.140 + mem_free
4.141 +};
4.142 +
4.143 +/**
4.144 + * Create a stream for reading from a arbitrary memory buffer.
4.145 + * When the Stream refcount reach 0, the buffer is free(3).
4.146 + *
4.147 + * @return
4.148 + * 1 sucess, < 0 error
4.149 + */
4.150 +int iso_mem_stream_new(unsigned char *buf, size_t size, IsoStream **stream)
4.151 +{
4.152 + IsoStream *str;
4.153 + MemStreamData *data;
4.154 +
4.155 + if (buf == NULL || stream == NULL) {
4.156 + return ISO_NULL_POINTER;
4.157 + }
4.158 +
4.159 + str = malloc(sizeof(IsoStream));
4.160 + if (str == NULL) {
4.161 + return ISO_OUT_OF_MEM;
4.162 + }
4.163 + data = malloc(sizeof(MemStreamData));
4.164 + if (data == NULL) {
4.165 + free(str);
4.166 + return ISO_OUT_OF_MEM;
4.167 + }
4.168 +
4.169 + /* fill data */
4.170 + data->buf = buf;
4.171 + data->size = size;
4.172 + data->offset = -1;
4.173 + data->ino_id = mem_serial_id++;
4.174 +
4.175 + str->refcount = 1;
4.176 + str->data = data;
4.177 + str->class = &mem_stream_class;
4.178 +
4.179 + *stream = str;
4.180 + return ISO_SUCCESS;
4.181 +}
5.1 --- a/src/loader.c Wed Dec 08 18:33:23 2010 +1000
5.2 +++ b/src/loader.c Thu Dec 23 17:50:10 2010 +1000
5.3 @@ -368,7 +368,7 @@
5.4 }
5.5
5.6 IsoStream *stream;
5.7 - if( iso_memory_stream_new(data, bin_size, &stream) != 1 ) {
5.8 + if( iso_mem_stream_new(data, bin_size, &stream) != 1 ) {
5.9 g_free(data);
5.10 iso_image_unref(iso);
5.11 SET_ERROR( err, LX_ERR_NOMEM, "Unable to create CD image: out of memory" );
.