summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/cdutils.cpp157
-rw-r--r--lib/dvdabstract.cpp161
-rw-r--r--lib/isobuilder.cpp278
-rw-r--r--lib/luacd.cpp94
4 files changed, 454 insertions, 236 deletions
diff --git a/lib/cdutils.cpp b/lib/cdutils.cpp
index ea4ff4c..f39114c 100644
--- a/lib/cdutils.cpp
+++ b/lib/cdutils.cpp
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: cdutils.cpp,v 1.33 2004-11-27 21:47:56 pixel Exp $ */
+/* $Id: cdutils.cpp,v 1.34 2005-11-02 21:34:02 pixel Exp $ */
#include <stdio.h>
#include <string.h>
@@ -26,6 +26,14 @@
#include "cdutils.h"
#include "Output.h"
+#ifdef WORDS_BIGENDIAN
+#define IS_LITTLE_ENDIAN 0
+#define IS_BIG_ENDIAN 1
+#else
+#define IS_LITTLE_ENDIAN 1
+#define IS_BIG_ENDIAN 0
+#endif
+
const long sec_sizes[7] = {0, 2048, 2336, 2048, 2324, 2352, 2352};
const long sec_offsts[7] = {0, 16, 16, 24, 24, 0, 0};
const String sec_modes[7] = {"MODE 0 (empty)", "MODE 1", "MODE 2", "MODE 2 FORM 1", "MODE 2 FORM 2", "Raw", "Autodetect"};
@@ -38,24 +46,24 @@ cdutils::~cdutils() {
free(rootDir);
}
-unsigned char cdutils::from_BCD(unsigned char x) {
+Uint8 cdutils::from_BCD(Uint8 x) {
return ((x & 0xf) + ((x & 0xf0) >> 4) * 10);
}
-unsigned char cdutils::to_BCD(unsigned char x) {
+Uint8 cdutils::to_BCD(Uint8 x) {
return ((x / 10) << 4) | (x % 10);
}
-bool cdutils::is_valid_BCD(unsigned char x) {
+bool cdutils::is_valid_BCD(Uint8 x) {
return (((x & 15) < 10) && ((x >> 4) < 10));
}
-unsigned long cdutils::from_MSF(unsigned char m, unsigned char s, unsigned char f, unsigned long start) {
+Uint32 cdutils::from_MSF(Uint8 m, Uint8 s, Uint8 f, Uint32 start) {
return (from_BCD(m) * 60 + from_BCD(s)) * 75 + from_BCD(f) - start;
}
-unsigned long cdutils::from_MSF(unsigned long msf, unsigned long start) {
- unsigned char
+Uint32 cdutils::from_MSF(Uint32 msf, Uint32 start) {
+ Uint8
f = msf & 0xff,
s = (msf >> 8) & 0xff,
m = (msf >> 16) & 0xff;
@@ -63,7 +71,7 @@ unsigned long cdutils::from_MSF(unsigned long msf, unsigned long start) {
return from_MSF(m, s, f, start);
}
-void cdutils::to_MSF(int sect, unsigned char & m, unsigned char & s, unsigned char & f, unsigned long start) {
+void cdutils::to_MSF(int sect, Uint8 & m, Uint8 & s, Uint8 & f, Uint32 start) {
sect += start;
f = to_BCD(sect % 75);
sect /= 75;
@@ -71,8 +79,8 @@ void cdutils::to_MSF(int sect, unsigned char & m, unsigned char & s, unsigned ch
m = to_BCD(sect / 60);
}
-unsigned long cdutils::to_MSF(int sect, unsigned long start) {
- unsigned char m, s, f;
+Uint32 cdutils::to_MSF(int sect, Uint32 start) {
+ Uint8 m, s, f;
to_MSF(sect, m, s, f, start);
return f | (s << 8) | (m << 16);
}
@@ -165,6 +173,38 @@ Uint32 cdutils::swap_dword(Uint32 i) {
return (i >> 24) | ((i >> 8) & 0x0000ff00) | ((i << 8) & 0x00ff0000) | (i << 24);
}
+Uint16 cdutils::from_LE16(Uint16 i) {
+#ifdef WORDS_BIGENDIAN
+ return swap_word(i);
+#else
+ return i;
+#endif
+}
+
+Uint32 cdutils::from_LE32(Uint32 i) {
+#ifdef WORDS_BIGENDIAN
+ return swap_dword(i);
+#else
+ return i;
+#endif
+}
+
+Uint16 cdutils::from_BE16(Uint16 i) {
+#ifdef WORDS_BIGENDIAN
+ return i;
+#else
+ return swap_word(i);
+#endif
+}
+
+Uint32 cdutils::from_BE32(Uint32 i) {
+#ifdef WORDS_BIGENDIAN
+ return i;
+#else
+ return swap_dword(i);
+#endif
+}
+
int cdutils::guess_type(int number) {
Byte header[24];
@@ -177,7 +217,7 @@ int cdutils::guess_type(int number) {
if (header[15] == 1) {
return MODE_1;
} else if (header[15] == 2) {
- if (*((unsigned long *) &(header[16])) == *((unsigned long *) &(header[20]))) {
+ if (*((Uint32 *) &(header[16])) == *((Uint32 *) &(header[20]))) {
if ((header[16] == 0) && (header[17] == 0) && (header[19] == 0)) {
if (header[18] & 0x20) {
return MODE_2_FORM_2;
@@ -224,7 +264,7 @@ long cdutils::read_sector(Byte * buffer, int type, int number) {
return sec_sizes[type];
}
-void cdutils::read_datas(Byte * buffer, long size, int type, int number) {
+void cdutils::read_data(Byte * buffer, long size, int type, int number) {
Byte sector[2352];
int i, n, reste;
@@ -312,9 +352,9 @@ void cdutils::write_sector(Byte * buffer, int type, int number) throw (GeneralEx
}
}
-void cdutils::write_datas(Byte * buffer, long size, int type, int number) {
+void cdutils::write_data(Byte * buffer, long size, int type, int number) {
long nbsectors, i;
- unsigned char sector[2352];
+ Uint8 sector[2352];
if (type == GUESS) {
type = guess_type(number);
@@ -339,7 +379,7 @@ void cdutils::write_datas(Byte * buffer, long size, int type, int number) {
void cdutils::write_file(Handle * file, long size, int type, int number) {
long nbsectors, i;
- unsigned char buffer[2352];
+ Uint8 buffer[2352];
if (type == GUESS) {
type = guess_type(number);
@@ -394,10 +434,15 @@ void cdutils::show_head_entry(void) {
int cdutils::show_entry(struct DirEntry * dir) {
char pbuf[200], pad;
int s;
+ Uint32 Sector, Size;
+
if ((!dir) || (!dir->R)) {
return 1;
}
+ Sector = from_LE32(dir->Sector);
+ Size = from_LE32(dir->Size);
+
strncpy(pbuf, dir->id, dir->N);
pbuf[dir->N] = 0;
if ((dir->N == 1) && (pbuf[0] == 0)) {
@@ -433,7 +478,7 @@ int cdutils::show_entry(struct DirEntry * dir) {
dir->Year += 100;
printm(M_BARE, "%6i %9i %2i/%02i/%04i %2i:%02i:%02i%+03.1f %c%c%c%c%c%c%c%c %s\n",
- dir->Sector, dir->Size, dir->Day, dir->Month, dir->Year + 1900, dir->Hour, dir->Minute, dir->Second, ((float) dir->Offset) / 4,
+ Sector, Size, dir->Day, dir->Month, dir->Year + 1900, dir->Hour, dir->Minute, dir->Second, ((float) dir->Offset) / 4,
dir->Flags & 1 ? 'H' : '-', dir->Flags & 2 ? 'D' : '-', dir->Flags & 4 ? 'A' : '-', dir->Flags & 8 ? 'R' : '-',
dir->Flags & 16 ? 'P' : '-', dir->Flags & 32 ? '1' : '-', dir->Flags & 64 ? '1' : '-', dir->Flags & 128 ? 'C' : '-', pbuf);
return dir->R;
@@ -442,16 +487,20 @@ int cdutils::show_entry(struct DirEntry * dir) {
int cdutils::show_dir(struct DirEntry * dir) {
unsigned int ptr;
Byte * buffer;
+ Uint32 Size, Sector;
if (!(dir->Flags & 2)) {
return 0;
}
- buffer = (Byte *) malloc(dir->Size);
- read_datas(buffer, dir->Size, GUESS, dir->Sector);
+ Size = from_LE32(dir->Size);
+ Sector = from_LE32(dir->Sector);
+
+ buffer = (Byte *) malloc(Size);
+ read_data(buffer, Size, GUESS, Sector);
ptr = 0;
- while(ptr < dir->Size) {
+ while(ptr < Size) {
ptr += show_entry((struct DirEntry *) &(buffer[ptr]));
}
@@ -461,15 +510,19 @@ int cdutils::show_dir(struct DirEntry * dir) {
struct cdutils::DirEntry cdutils::find_dir_entry(struct DirEntry * dir, String name) {
unsigned int ptr, size;
- unsigned char * buffer;
+ Uint8 * buffer;
struct DirEntry r = {0, 0, 0, 0, 0};
+ Uint32 Sector;
if (!(dir->Flags & 2)) {
return r;
}
- buffer = (unsigned char *) malloc(size = dir->Size);
- read_datas(buffer, dir->Size, GUESS, dir->Sector);
+ Sector = from_LE32(dir->Sector);
+ size = from_LE32(dir->Size);
+
+ buffer = (Uint8 *) malloc(size);
+ read_data(buffer, size, GUESS, Sector);
ptr = 0;
while(ptr < size) {
@@ -493,13 +546,17 @@ struct cdutils::DirEntry * cdutils::find_dir_entry(Byte ** bufout, struct cdutil
Byte * buffer;
struct DirEntry * rdir = 0;
*bufout = 0;
+ Uint32 Sector;
if (!(dir->Flags & 2)) {
return 0;
}
- buffer = (Byte *) malloc(size = dir->Size);
- read_datas(buffer, dir->Size, GUESS, dir->Sector);
+ size = from_LE32(dir->Size);
+ Sector = from_LE32(dir->Sector);
+
+ buffer = (Byte *) malloc(size);
+ read_data(buffer, size, GUESS, Sector);
ptr = 0;
while(ptr < size) {
@@ -527,7 +584,7 @@ struct cdutils::DirEntry * cdutils::find_dir_entry(Byte ** bufout, struct cdutil
int cdutils::show_iso_infos() {
char buffer[2048];
char pbuff[130];
- short int s, nogood = 0;
+ int16 s, nogood = 0;
read_sector((Byte *) buffer, GUESS, 16);
@@ -537,7 +594,7 @@ int cdutils::show_iso_infos() {
memcpy(pbuff, buffer + 1, 5);
pbuff[5] = 0;
printm(M_BARE, " 1 - 5-`CD001' : %s\n", pbuff);
- printm(M_BARE, " 6 - 2- 1 : %i\n", s = *((short int *) &(buffer[6])));
+ printm(M_BARE, " 6 - 2- 1 : %i\n", s = from_LE16(*((Uint16 *) &(buffer[6]))));
printm(M_BARE, "(*this was the signature*)\n");
if (buffer[0] != 1) nogood = 1;
if (strcmp(pbuff, "CD001")) nogood = 1;
@@ -554,15 +611,15 @@ int cdutils::show_iso_infos() {
memcpy(pbuff, buffer + 40, 32);
pbuff[32] = 0;
printm(M_BARE, " 40 - 32- VOLID : %s\n", pbuff);
- printm(M_BARE, " 80 - 8- SNum : %li\n", *((long int *) &(buffer[80])));
- printm(M_BARE, " 120 - 4- VOLSiz : %i\n", *((short int *) &(buffer[120])));
- printm(M_BARE, " 124 - 4- VOLNum : %i\n", *((short int *) &(buffer[124])));
- printm(M_BARE, " 128 - 4- SSize : %i\n", *((short int *) &(buffer[128])));
- printm(M_BARE, " 132 - 8- PSize : %li\n", *((long int *) &(buffer[132])));
- printm(M_BARE, " 140 - 4- 1SLPath: %i\n", *((long int *) &(buffer[140])));
- printm(M_BARE, " 144 - 4- 2SLPath: %i\n", *((long int *) &(buffer[144])));
- printm(M_BARE, " 148 - 4- 1SBPath: %i\n", swap_word(*((long int *) &(buffer[150]))));
- printm(M_BARE, " 152 - 4- 2SBPath: %i\n", swap_word(*((long int *) &(buffer[154]))));
+ printm(M_BARE, " 80 - 8- SNum : %li\n", from_LE32(*((Uint32 *) &(buffer[80]))));
+ printm(M_BARE, " 120 - 4- VOLSiz : %i\n", from_LE16(*((Uint16 *) &(buffer[120]))));
+ printm(M_BARE, " 124 - 4- VOLNum : %i\n", from_LE16(*((Uint16 *) &(buffer[124]))));
+ printm(M_BARE, " 128 - 4- SSize : %i\n", from_LE16(*((Uint16 *) &(buffer[128]))));
+ printm(M_BARE, " 132 - 8- PSize : %li\n", from_LE32(*((Uint32 *) &(buffer[132]))));
+ printm(M_BARE, " 140 - 4- 1SLPath: %li\n", from_LE32(*((Uint32 *) &(buffer[140]))));
+ printm(M_BARE, " 144 - 4- 2SLPath: %li\n", from_LE32(*((Uint32 *) &(buffer[144]))));
+ printm(M_BARE, " 148 - 4- 1SBPath: %li\n", from_BE32(*((Uint32 *) &(buffer[148]))));
+ printm(M_BARE, " 152 - 4- 2SBPath: %li\n", from_BE32(*((Uint32 *) &(buffer[152]))));
memcpy(pbuff, buffer + 190, 128);
pbuff[128] = 0;
printm(M_BARE, " 190 - 128- VStId : %s\n", pbuff);
@@ -599,7 +656,7 @@ int cdutils::show_iso_infos() {
int cdutils::get_iso_infos() {
Byte buffer[2048];
char pbuff[130];
- short int s, nogood = 0;
+ int16 s, nogood = 0;
int rootsec;
read_sector(buffer, GUESS, 16);
@@ -607,7 +664,7 @@ int cdutils::get_iso_infos() {
memcpy(pbuff, buffer + 1, 5);
pbuff[5] = 0;
- s = *((short int *) &(buffer[6]));
+ s = from_LE16(*((Uint16 *) &(buffer[6])));
if (buffer[0] != 1) nogood = 1;
if (strcmp(pbuff, "CD001")) nogood = 1;
if (s != 1) nogood = 1;
@@ -617,11 +674,11 @@ int cdutils::get_iso_infos() {
return 0;
}
- pt1 = *((short int *) &(buffer[140]));
- pt2 = *((short int *) &(buffer[144]));
- snum = *((int *) &(buffer[80]));
- ptl = *((long int *) &(buffer[132]));
- rootsec = ((struct DirEntry *) (&buffer[156]))->Sector;
+ pt1 = from_LE16(*((Uint16 *) &(buffer[140])));
+ pt2 = from_LE16(*((Uint16 *) &(buffer[144])));
+ snum = from_LE32(*((Uint32 *) &(buffer[80])));
+ ptl = from_LE32(*((Uint32 *) &(buffer[132])));
+ rootsec = from_LE32(((struct DirEntry *) (&buffer[156]))->Sector);
read_sector(buffer, GUESS, rootsec);
rootDir = (struct DirEntry *) malloc(buffer[0]);
memcpy(rootDir, buffer, buffer[0]);
@@ -641,7 +698,7 @@ int cdutils::get_pt_infos() {
}
buffer = (Byte *) malloc(ptl);
- read_datas(buffer, ptl, GUESS, !pt1 ? pt2 : pt1);
+ read_data(buffer, ptl, GUESS, !pt1 ? pt2 : pt1);
if (buffer[0] == 1)
if (buffer[1] == 0)
@@ -649,7 +706,7 @@ int cdutils::get_pt_infos() {
if (buffer[7] == 0)
if (buffer[8] == 0)
if (buffer[9] == 0)
- root = *((unsigned long int *) &(buffer[2]));
+ root = from_LE32(*((Uint32 *) &(buffer[2])));
free(buffer);
return root ? 1 : 0;
@@ -670,13 +727,13 @@ int cdutils::show_pt_infos() {
}
buffer = (Byte *) malloc(ptl + 2);
- read_datas(buffer, ptl, GUESS, !pt1 ? pt2 : pt1);
+ read_data(buffer, ptl, GUESS, !pt1 ? pt2 : pt1);
printm(M_BARE, "node^paren@sector : name\n");
for (ptr = 0, i = 1; buffer[ptr]; ptr += ptr & 1, i++) {
strncpy(pbuf, (char *) &(buffer[8 + ptr]), buffer[ptr]);
pbuf[buffer[ptr]] = 0;
- printm(M_BARE, "%3i ^ %3i @ %6i: %s\n", i, *((unsigned short *) &(buffer[6 + ptr])), *((unsigned long *) &(buffer[2 + ptr])), pbuf);
+ printm(M_BARE, "%3i ^ %3i @ %6i: %s\n", i, from_LE16(*((Uint16 *) &(buffer[6 + ptr]))), from_LE32(*((Uint32 *) &(buffer[2 + ptr]))), pbuf);
ptr += 8 + buffer[ptr];
}
@@ -862,7 +919,7 @@ cdfile::cdfile(cdutils * _cd, const cdutils::DirEntry * d, int _mode) : Handle(-
}
cdfile::cdfile(cdutils * _cd, int _sector, ssize_t _size, int _mode) : Handle(-1), cd(_cd), sector(_sector), mode(_mode), size(_size), name("raw reading") {
- Byte datas[2352];
+ Byte data[2352];
bool eof;
if (mode == GUESS) {
@@ -872,8 +929,8 @@ cdfile::cdfile(cdutils * _cd, int _sector, ssize_t _size, int _mode) : Handle(-1
size = 0;
if ((mode == MODE2_FORM1) || (mode == MODE2_FORM2)) {
do {
- cd->read_sector(datas, MODE_RAW, sector + size++);
- eof = datas[18] & 0x80;
+ cd->read_sector(data, MODE_RAW, sector + size++);
+ eof = data[18] & 0x80;
} while (!eof);
size *= sec_sizes[mode];
}
@@ -908,7 +965,7 @@ ssize_t cdfile::read(void *buf, size_t count) throw (GeneralException) {
buf = (Byte *) buf + nstartbytes;
if (count) {
- cd->read_datas((Byte *) buf, count, mode, startsec + 1);
+ cd->read_data((Byte *) buf, count, mode, startsec + 1);
}
itell += count + nstartbytes;
diff --git a/lib/dvdabstract.cpp b/lib/dvdabstract.cpp
new file mode 100644
index 0000000..582ad90
--- /dev/null
+++ b/lib/dvdabstract.cpp
@@ -0,0 +1,161 @@
+/*
+ * PSX-Tools Bundle Pack
+ * Copyright (C) 2002-2003 Nicolas "Pixel" Noble
+ *
+ * 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
+ */
+
+/* $Id: dvdabstract.cpp,v 1.1 2005-11-02 21:34:02 pixel Exp $ */
+
+#include "dvdabstract.h"
+
+dvdabstract::dvdabstract(Handle * h, int _m) : Handle(-1), r(h), v(h->tell()), m(_m) {
+}
+
+off_t dvdabstract::seek(off_t offset, int wheel) throw (GeneralException) {
+ switch (wheel) {
+ case SEEK_SET:
+ v = offset;
+ break;
+ case SEEK_CUR:
+ v += offset;
+ break;
+ case SEEK_END:
+ throw IOGeneral("Can't seek from the end of the dvdabstract...");
+ }
+}
+
+off_t dvdabstract::tell() const {
+ return v;
+}
+
+ssize_t dvdabstract::read(void * _buf, size_t count) throw (GeneralException) {
+ char i_buf[2352], * buf = (char *) _buf;
+ int sector, start, reminder, i_count;
+
+ if (!count) return 0;
+
+ sector = v / 2352;
+ start = v % 2352;
+
+ read_sector(i_buf, sector);
+
+ if ((start + count) < 2352) {
+ memcpy(buf, i_buf + start, count);
+ return count;
+ }
+
+ reminder = 2352 - start;
+ memcpy(buf, i_buf + start, reminder);
+ sector++;
+ i_count = count - reminder;
+ buf += reminder;
+
+ while (i_count >= 2352) {
+ read_sector(buf, sector);
+ i_count -= 2352;
+ sector++;
+ buf += 2352;
+ }
+
+ reminder = i_count;
+
+ if (reminder >= 0) {
+ read_sector(i_buf, sector);
+ memcpy(buf, i_buf, reminder);
+ }
+
+ return count;
+}
+
+ssize_t dvdabstract::write(const void * _buf, size_t count) throw (GeneralException) {
+ char i_buf[2352], * buf = (char *) _buf;
+ int sector, start, reminder, i_count;
+
+ if (!count) return 0;
+
+ sector = v / 2352;
+ start = v % 2352;
+
+ memcpy(i_buf + start, buf, 2352 - start);
+ if (start >= 16) {
+ i_buf[15] = m;
+ if (m == MODE2_FORM1) {
+ i_buf[18] = i_buf[22] = 1;
+ }
+ }
+ write_sector(i_buf, sector);
+
+ if ((start + count) < 2352) {
+ return count;
+ }
+
+ reminder = 2352 - start;
+ sector++;
+ i_count = count - reminder;
+ buf += reminder;
+
+ while (i_count >= 2352) {
+ write_sector(buf, sector);
+ i_count -= 2352;
+ sector++;
+ buf += 2352;
+ }
+
+ reminder = i_count;
+ memcpy(i_buf, buf, reminder);
+ if (reminder >= 0) {
+ memcpy(buf, i_buf, reminder);
+ if (reminder <= 22) {
+ if (reminder <= 15) {
+ i_buf[15] = m;
+ if (m == MODE2_FORM1) {
+ i_buf[18] = i_buf[22] = 1;
+ }
+ } else if (i_buf[15] == MODE2_FORM1) {
+ i_buf[18] = i_buf[22] = 1;
+ }
+ }
+ write_sector(i_buf, sector);
+ }
+
+ return count;
+}
+
+void dvdabstract::read_sector(char * buf, int sector) {
+ r->seek(sector * 2048);
+ r->read(buf + 16, 2048);
+ buf[0] = buf[11] = 0;
+ buf[1] = buf[2] = buf[3] = buf[4] = buf[5] = buf[6] = buf[7] = buf[8] = buf[9] = buf[10] = -1;
+ buf[12] = buf[13] = buf[14] = 0;
+ buf[15] = 1;
+}
+
+void dvdabstract::write_sector(const char * buf, int sector) throw (GeneralException) {
+ r->seek(sector * 2048);
+ switch(buf[15]) {
+ case 0:
+ case 1:
+ r->write(buf + 16, 2048);
+ break;
+ case 2:
+ if ((buf[18] == 1) && (buf[22] == 1)) {
+ r->write(buf + 24, 2048);
+ break;
+ }
+ default:
+ throw GeneralException("dvdabstract::write_sector: unknown sector mode.");
+ }
+}
diff --git a/lib/isobuilder.cpp b/lib/isobuilder.cpp
index 5d72abb..327b55c 100644
--- a/lib/isobuilder.cpp
+++ b/lib/isobuilder.cpp
@@ -17,68 +17,68 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: isobuilder.cpp,v 1.17 2005-01-30 14:46:24 pixel Exp $ */
+/* $Id: isobuilder.cpp,v 1.18 2005-11-02 21:34:02 pixel Exp $ */
#include "isobuilder.h"
-void isobuilder::Date::dump(Byte * datas) {
+void isobuilder::Date::dump(Byte * data) {
char pbuf[256];
sprintf(pbuf, "%04i", year);
- memcpy(datas + 0, pbuf, 4);
+ memcpy(data + 0, pbuf, 4);
sprintf(pbuf, "%02i", month);
- memcpy(datas + 4, pbuf, 2);
+ memcpy(data + 4, pbuf, 2);
sprintf(pbuf, "%02i", day);
- memcpy(datas + 6, pbuf, 2);
+ memcpy(data + 6, pbuf, 2);
sprintf(pbuf, "%02i", hour);
- memcpy(datas + 8, pbuf, 2);
+ memcpy(data + 8, pbuf, 2);
sprintf(pbuf, "%02i", minute);
- memcpy(datas + 10, pbuf, 2);
+ memcpy(data + 10, pbuf, 2);
sprintf(pbuf, "%02i", second);
- memcpy(datas + 12, pbuf, 2);
+ memcpy(data + 12, pbuf, 2);
sprintf(pbuf, "%02i", hundredths);
- memcpy(datas + 14, pbuf, 2);
+ memcpy(data + 14, pbuf, 2);
- *((char *) (datas + 16)) = offset;
+ *((char *) (data + 16)) = offset;
}
isobuilder::Date::Date(int) {
year = month = day = hour = minute = second = hundredths = offset = 0;
}
-isobuilder::Date::Date(Byte * datas) {
+isobuilder::Date::Date(Byte * data) {
char pbuf[256];
- char * cdatas = (char *) datas;
+ char * cdata = (char *) data;
- memcpy(pbuf, cdatas + 0, 4);
+ memcpy(pbuf, cdata + 0, 4);
pbuf[4] = 0;
sscanf(pbuf, "%d", &year);
- memcpy(pbuf, cdatas + 4, 2);
+ memcpy(pbuf, cdata + 4, 2);
pbuf[2] = 0;
sscanf(pbuf, "%d", &month);
- memcpy(pbuf, cdatas + 6, 2);
+ memcpy(pbuf, cdata + 6, 2);
pbuf[2] = 0;
sscanf(pbuf, "%d", &day);
- memcpy(pbuf, cdatas + 8, 2);
+ memcpy(pbuf, cdata + 8, 2);
pbuf[2] = 0;
sscanf(pbuf, "%d", &hour);
- memcpy(pbuf, cdatas + 10, 2);
+ memcpy(pbuf, cdata + 10, 2);
pbuf[2] = 0;
sscanf(pbuf, "%d", &minute);
- memcpy(pbuf, cdatas + 12, 2);
+ memcpy(pbuf, cdata + 12, 2);
pbuf[2] = 0;
sscanf(pbuf, "%d", &second);
- memcpy(pbuf, cdatas + 14, 2);
+ memcpy(pbuf, cdata + 14, 2);
pbuf[2] = 0;
sscanf(pbuf, "%d", &hundredths);
- offset = *(cdatas + 16);
+ offset = *(cdata + 16);
}
isobuilder::DirTree::DirTree(isobuilder::DirTree * _father, bool _dir) : mode(-1), father(_father), dir(_dir) {
@@ -164,19 +164,19 @@ void isobuilder::DirTree::dumpdirs(isobuilder * builder) throw (GeneralException
dir += R;
}
- builder->putdatas(odir, size, mode, sector);
+ builder->putdata(odir, size, mode, sector);
free(odir);
}
-int isobuilder::DirTree::buildpath(Byte * datas, int size, bool bigendian) throw (GeneralException) {
+int isobuilder::DirTree::buildpath(Byte * data, int size, bool bigendian) throw (GeneralException) {
int N, r, tr;
Uint16 pn;
char pbuf[256], pad;
if (!dir) {
if (brother) {
- return brother->buildpath(datas, size, bigendian);
+ return brother->buildpath(data, size, bigendian);
} else {
return 0;
}
@@ -199,28 +199,28 @@ int isobuilder::DirTree::buildpath(Byte * datas, int size, bool bigendian) throw
if (size < 0)
throw GeneralException("Path table too small.");
- datas[0] = N;
- datas[1] = 0;
- *((Uint32 *) (datas + 2)) = bigendian ? cdutils::swap_dword(sector) : sector;
- *((Uint16 *) (datas + 6)) = bigendian ? cdutils::swap_word(pn) : pn;
- memcpy(datas + 8, pbuf, N);
+ data[0] = N;
+ data[1] = 0;
+ *((Uint32 *) (data + 2)) = bigendian ? cdutils::to_BE32(sector) : cdutils::to_LE32(sector);
+ *((Uint16 *) (data + 6)) = bigendian ? cdutils::to_BE16(pn) : cdutils::to_LE16(pn);
+ memcpy(data + 8, pbuf, N);
if (pad)
- datas[8 + N] = 0;
+ data[8 + N] = 0;
- datas += r;
+ data += r;
if (brother) {
- tr = brother->buildpath(datas, size, bigendian);
+ tr = brother->buildpath(data, size, bigendian);
r += tr;
size -= tr;
- datas += tr;
+ data += tr;
}
if (child) {
- tr = child->buildpath(datas, size, bigendian);
+ tr = child->buildpath(data, size, bigendian);
r += tr;
size -= tr;
- datas += tr;
+ data += tr;
}
return r;
@@ -285,10 +285,10 @@ int isobuilder::DirTree::buildentry(Byte * buffer, int spaceleft, bool put_xa) {
d->N = N;
memcpy(d->id, pbuf, N + pad + (put_xa ? 14 : 0));
- d->Sector = sector;
- d->BESector = cdutils::swap_dword(sector);
- d->Size = size;
- d->BESize = cdutils::swap_dword(size);
+ d->Sector = cdutils::to_LE32(sector);
+ d->BESector = cdutils::to_BE32(sector);
+ d->Size = cdutils::to_LE32(size);
+ d->BESize = cdutils::to_BE32(size);
if (creation.year >= 1000) {
d->Year = creation.year - 1900;
} else {
@@ -459,7 +459,7 @@ int isobuilder::getdispsect() {
}
int isobuilder::putfile(Handle * file, int mode, int n) {
- Byte datas[2352];
+ Byte data[2352];
ssize_t filesize;
int fsect;
@@ -477,8 +477,8 @@ int isobuilder::putfile(Handle * file, int mode, int n) {
filesize = file->GetSize();
while (filesize > 0) {
- memset(datas, 0, 2352);
- filesize -= file->read(datas, sec_sizes[mode]);
+ memset(data, 0, 2352);
+ filesize -= file->read(data, sec_sizes[mode]);
if ((mode == MODE2_FORM1) || (mode == MODE2_FORM2)) {
if (filesize) {
clearEOF();
@@ -486,14 +486,14 @@ int isobuilder::putfile(Handle * file, int mode, int n) {
setEOF();
}
}
- createsector(datas, mode);
+ createsector(data, mode);
}
return fsect;
}
-int isobuilder::putdatas(Byte * _datas, size_t size, int smode, int n) {
- Byte datas[2352];
+int isobuilder::putdata(Byte * _data, size_t size, int smode, int n) {
+ Byte data[2352];
size_t eating;
int dsect;
if (n >= 0) {
@@ -508,11 +508,11 @@ int isobuilder::putdatas(Byte * _datas, size_t size, int smode, int n) {
smode = dmode;
while (size > 0) {
- memset(datas, 0, 2352);
+ memset(data, 0, 2352);
eating = MIN(size, (size_t) sec_sizes[smode]);
- memcpy(datas, _datas, eating);
+ memcpy(data, _data, eating);
size -= eating;
- _datas += eating;
+ _data += eating;
if ((smode == MODE2_FORM1) || (smode == MODE2_FORM2)) {
if (size) {
clearEOF();
@@ -520,13 +520,13 @@ int isobuilder::putdatas(Byte * _datas, size_t size, int smode, int n) {
setEOF();
}
}
- createsector(datas, smode);
+ createsector(data, smode);
}
return dsect;
}
-int isobuilder::createsector(Byte * datas, int smode, int n, int FN, int CN, int SM, int CI) {
+int isobuilder::createsector(Byte * data, int smode, int n, int FN, int CN, int SM, int CI) {
Byte dsector[2352];
int rsector;
if (n >= 0)
@@ -539,7 +539,7 @@ int isobuilder::createsector(Byte * datas, int smode, int n, int FN, int CN, int
w->seek(2352 * sector, SEEK_SET);
- memcpy(dsector + sec_offsts[smode], datas, sec_sizes[smode]);
+ memcpy(dsector + sec_offsts[smode], data, sec_sizes[smode]);
if ((smode == MODE2_FORM1) || (smode == MODE2_FORM2)) {
// Mode 2 Form 2 would be odd, but well....
@@ -636,7 +636,7 @@ isobuilder::DirTree * isobuilder::createdir(DirTree * p, const String & _name, i
r->name = _name;
r->size = size * 2048;
if (!r->size)
- r->size = d->Size;
+ r->size = cdutils::from_LE32(d->Size);
r->sector = lastdispsect;
if (mode >= 0)
r->mode = mode;
@@ -678,18 +678,18 @@ isobuilder::DirTree * isobuilder::createfile(DirTree * p, Handle * file, const S
}
void isobuilder::copydir(isobuilder::DirTree * r, cdutils * cd, cdutils::DirEntry * d, int mode) {
- Byte datas[2048];
+ Byte data[2048];
cdutils::DirEntry * p;
- int nsectors = d->Size / 2048, ssize, c = 0;
+ int nsectors = cdutils::from_LE32(d->Size) / 2048, ssize, c = 0;
int fsize, osize;
if (mode < 0)
mode = dmode;
while (nsectors) {
- cd->read_sector(datas, mode, d->Sector + c++);
+ cd->read_sector(data, mode, cdutils::from_LE32(d->Sector) + c++);
nsectors--;
- p = (cdutils::DirEntry *) datas;
+ p = (cdutils::DirEntry *) data;
ssize = 2048;
while ((ssize) && (p->R)) {
ssize -= p->R;
@@ -698,11 +698,11 @@ void isobuilder::copydir(isobuilder::DirTree * r, cdutils * cd, cdutils::DirEntr
pbuf[p->N] = 0;
if (p->Flags & 2) {
if (!((p->N == 1) && ((p->id[0] == 0) || (p->id[0] == 1))))
- copydir(createdir(r, "", p->Size / 2048, p, mode), cd, p, mode);
+ copydir(createdir(r, "", cdutils::from_LE32(p->Size) / 2048, p, mode), cd, p, mode);
} else {
printm(M_INFO, "Dupping %s\n", pbuf);
int fmode;
- osize = fsize = p->Size;
+ osize = fsize = cdutils::from_LE32(p->Size);
if (mode == MODE1) {
fmode = mode;
} else {
@@ -718,15 +718,15 @@ void isobuilder::copydir(isobuilder::DirTree * r, cdutils * cd, cdutils::DirEntr
if ((s != p->R) && ((s + 14) == p->R)) {
if (!(p->id[p->N + pad + 4] & 8)) {
fmode = MODE2;
- fsize = (p->Size / 2048) * 2336;
+ fsize = (cdutils::from_LE32(p->Size) / 2048) * 2336;
}
}
}
- p->Size = fsize;
+ p->Size = cdutils::to_BE32(fsize);
cdfile * tmp = new cdfile(cd, p, fmode);
createfile(r, tmp, "", p, fmode)->size = osize;
delete tmp;
- p->Size = osize;
+ p->Size = cdutils::to_BE32(osize);
}
p = (cdutils::DirEntry *) (((Byte *) p) + p->R);
}
@@ -734,15 +734,15 @@ void isobuilder::copydir(isobuilder::DirTree * r, cdutils * cd, cdutils::DirEntr
}
isobuilder::PVD isobuilder::createpvd(Handle * f) {
- Byte datas[2048];
- f->read(datas, 2048);
- return createpvd(datas);
+ Byte data[2048];
+ f->read(data, 2048);
+ return createpvd(data);
}
isobuilder::PVD isobuilder::createpvd(cdutils * cd) {
- Byte datas[2048];
- cd->read_sector(datas, GUESS, 16);
- return createpvd(datas);
+ Byte data[2048];
+ cd->read_sector(data, GUESS, 16);
+ return createpvd(data);
}
isobuilder::PVD isobuilder::createpvd(Byte * buffer) {
@@ -797,9 +797,9 @@ isobuilder::PVD isobuilder::createpvd(Byte * buffer) {
}
void isobuilder::close(Handle * cue, int mode, int nsects) throw (GeneralException) {
- Byte datas[2048];
- Byte * pdatas;
- char * cdatas = (char *) datas;
+ Byte data[2048];
+ Byte * pdata;
+ char * cdata = (char *) data;
int psize;
if (!root) {
@@ -809,82 +809,82 @@ void isobuilder::close(Handle * cue, int mode, int nsects) throw (GeneralExcepti
if (nsects < 0)
nsects = nsectors;
- memset(datas, 0, 2048);
-
- pdatas = (Byte *) malloc(ptsize * 2048);
- psize = root->buildpath(pdatas, ptsize * 2048);
- putdatas(pdatas, ptsize * 2048, mode, ptsect);
- putdatas(pdatas, ptsize * 2048, mode, ptsect + ptsize);
- root->buildpath(pdatas, ptsize * 2048, true);
- putdatas(pdatas, ptsize * 2048, mode, ptsect + ptsize * 2);
- putdatas(pdatas, ptsize * 2048, mode, ptsect + ptsize * 3);
- free(pdatas);
-
- datas[0] = 1;
- datas[1] = 67;
- datas[2] = 68;
- datas[3] = 48;
- datas[4] = 48;
- datas[5] = 49;
- datas[6] = 1;
- datas[7] = 0;
-
- sprintf(cdatas + 8, "%-32s", pvd.sysid.to_charp());
- sprintf(cdatas + 40, "%-32s", pvd.volid.to_charp());
- *((Uint32 *) (datas + 80)) = nsects;
- *((Uint32 *) (datas + 84)) = cdutils::swap_dword(nsects);
-
- datas[120] = 1;
- datas[121] = 0;
- datas[122] = 0;
- datas[123] = 1;
- datas[124] = 1;
- datas[125] = 0;
- datas[126] = 0;
- datas[127] = 1;
- datas[128] = 0;
- datas[129] = 8;
- datas[130] = 8;
- datas[131] = 0;
- *((Uint32 *) (datas + 132)) = psize;
- *((Uint32 *) (datas + 136)) = cdutils::swap_dword(psize);
- *((Uint32 *) (datas + 140)) = ptsect;
- *((Uint32 *) (datas + 144)) = ptsect + ptsize;
- *((Uint32 *) (datas + 148)) = cdutils::swap_dword(ptsect + ptsize * 2);
- *((Uint32 *) (datas + 152)) = cdutils::swap_dword(ptsect + ptsize * 3);
-
- root->buildentry(datas + 156, 34, false);
-
- sprintf(cdatas + 190, "%-128s", pvd.volsetid.to_charp());
- sprintf(cdatas + 318, "%-128s", pvd.pubid.to_charp());
- sprintf(cdatas + 446, "%-128s", pvd.prepid.to_charp());
- sprintf(cdatas + 574, "%-128s", pvd.appid.to_charp());
- sprintf(cdatas + 702, "%-37s", pvd.copyright.to_charp());
- sprintf(cdatas + 739, "%-37s", pvd.abstract.to_charp());
- sprintf(cdatas + 776, "%-37s", pvd.biblio.to_charp());
-
- pvd.volcreat.dump(datas + 813);
- pvd.modif.dump(datas + 830);
- pvd.volexp.dump(datas + 847);
- pvd.voleff.dump(datas + 864);
-
- memcpy(datas + 883, pvd.appdata, 512);
+ memset(data, 0, 2048);
+
+ pdata = (Byte *) malloc(ptsize * 2048);
+ psize = root->buildpath(pdata, ptsize * 2048);
+ putdata(pdata, ptsize * 2048, mode, ptsect);
+ putdata(pdata, ptsize * 2048, mode, ptsect + ptsize);
+ root->buildpath(pdata, ptsize * 2048, true);
+ putdata(pdata, ptsize * 2048, mode, ptsect + ptsize * 2);
+ putdata(pdata, ptsize * 2048, mode, ptsect + ptsize * 3);
+ free(pdata);
+
+ data[0] = 1;
+ data[1] = 67;
+ data[2] = 68;
+ data[3] = 48;
+ data[4] = 48;
+ data[5] = 49;
+ data[6] = 1;
+ data[7] = 0;
+
+ sprintf(cdata + 8, "%-32s", pvd.sysid.to_charp());
+ sprintf(cdata + 40, "%-32s", pvd.volid.to_charp());
+ *((Uint32 *) (data + 80)) = cdutils::to_LE32(nsects);
+ *((Uint32 *) (data + 84)) = cdutils::to_BE32(nsects);
+
+ data[120] = 1;
+ data[121] = 0;
+ data[122] = 0;
+ data[123] = 1;
+ data[124] = 1;
+ data[125] = 0;
+ data[126] = 0;
+ data[127] = 1;
+ data[128] = 0;
+ data[129] = 8;
+ data[130] = 8;
+ data[131] = 0;
+ *((Uint32 *) (data + 132)) = cdutils::to_LE32(psize);
+ *((Uint32 *) (data + 136)) = cdutils::to_BE32(psize);
+ *((Uint32 *) (data + 140)) = cdutils::to_LE32(ptsect);
+ *((Uint32 *) (data + 144)) = cdutils::to_LE32(ptsect + ptsize);
+ *((Uint32 *) (data + 148)) = cdutils::to_BE32(ptsect + ptsize * 2);
+ *((Uint32 *) (data + 152)) = cdutils::to_BE32(ptsect + ptsize * 3);
+
+ root->buildentry(data + 156, 34, false);
+
+ sprintf(cdata + 190, "%-128s", pvd.volsetid.to_charp());
+ sprintf(cdata + 318, "%-128s", pvd.pubid.to_charp());
+ sprintf(cdata + 446, "%-128s", pvd.prepid.to_charp());
+ sprintf(cdata + 574, "%-128s", pvd.appid.to_charp());
+ sprintf(cdata + 702, "%-37s", pvd.copyright.to_charp());
+ sprintf(cdata + 739, "%-37s", pvd.abstract.to_charp());
+ sprintf(cdata + 776, "%-37s", pvd.biblio.to_charp());
+
+ pvd.volcreat.dump(data + 813);
+ pvd.modif.dump(data + 830);
+ pvd.volexp.dump(data + 847);
+ pvd.voleff.dump(data + 864);
+
+ memcpy(data + 883, pvd.appdata, 512);
clearEOF();
sub_EOR = 1;
- createsector(datas, mode, 16);
+ createsector(data, mode, 16);
- memset(datas, 0, 2048);
- datas[0] =255;
- datas[1] = 67;
- datas[2] = 68;
- datas[3] = 48;
- datas[4] = 48;
- datas[5] = 49;
- datas[6] = 1;
+ memset(data, 0, 2048);
+ data[0] =255;
+ data[1] = 67;
+ data[2] = 68;
+ data[3] = 48;
+ data[4] = 48;
+ data[5] = 49;
+ data[6] = 1;
setEOF();
- createsector(datas, mode);
+ createsector(data, mode);
root->dumpdirs(this);
diff --git a/lib/luacd.cpp b/lib/luacd.cpp
index 9e1e698..82c72cd 100644
--- a/lib/luacd.cpp
+++ b/lib/luacd.cpp
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: luacd.cpp,v 1.18 2005-02-12 22:56:17 pixel Exp $ */
+/* $Id: luacd.cpp,v 1.19 2005-11-02 21:34:02 pixel Exp $ */
#include "luacd.h"
@@ -37,10 +37,10 @@ enum cdutils_methods_t {
CDUTILS_GUESSTYPE,
CDUTILS_SECTORSEEK,
CDUTILS_READSECTOR,
- CDUTILS_READDATAS,
+ CDUTILS_READdata,
CDUTILS_READFILE,
CDUTILS_WRITESECTOR,
- CDUTILS_WRITEDATAS,
+ CDUTILS_WRITEdata,
CDUTILS_WRITEFILE,
CDUTILS_GETISOINFOS,
CDUTILS_GETPTINFOS,
@@ -69,10 +69,10 @@ struct lua_functypes_t cdutils_methods[] = {
{ CDUTILS_GUESSTYPE, "guessmode", 0, 1, {LUA_NUMBER} },
{ CDUTILS_SECTORSEEK, "sectorseek", 1, 1, {LUA_NUMBER} },
{ CDUTILS_READSECTOR, "readsector", 0, 2, {LUA_NUMBER, LUA_NUMBER} },
- { CDUTILS_READDATAS, "readdatas", 1, 3, {LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
+ { CDUTILS_READdata, "readdata", 1, 3, {LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
{ CDUTILS_READFILE, "readfile", 2, 4, {LUA_OBJECT, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
{ CDUTILS_WRITESECTOR, "writesector", 1, 3, {LUA_TABLE, LUA_NUMBER, LUA_NUMBER} },
- { CDUTILS_WRITEDATAS, "writedatas", 2, 4, {LUA_TABLE, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
+ { CDUTILS_WRITEdata, "writedata", 2, 4, {LUA_TABLE, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
{ CDUTILS_WRITEFILE, "writefile", 1, 4, {LUA_OBJECT, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
{ CDUTILS_GETISOINFOS, "getisoinfos", 0, 0, 0 },
{ CDUTILS_GETPTINFOS, "getptinfos", 0, 0, 0 },
@@ -104,10 +104,10 @@ class sLua_cdutils : public Base {
DECLARE_METHOD(cdutils, CDUTILS_GUESSTYPE);
DECLARE_METHOD(cdutils, CDUTILS_SECTORSEEK);
DECLARE_METHOD(cdutils, CDUTILS_READSECTOR);
- DECLARE_METHOD(cdutils, CDUTILS_READDATAS);
+ DECLARE_METHOD(cdutils, CDUTILS_READdata);
DECLARE_METHOD(cdutils, CDUTILS_READFILE);
DECLARE_METHOD(cdutils, CDUTILS_WRITESECTOR);
- DECLARE_METHOD(cdutils, CDUTILS_WRITEDATAS);
+ DECLARE_METHOD(cdutils, CDUTILS_WRITEdata);
DECLARE_METHOD(cdutils, CDUTILS_WRITEFILE);
DECLARE_METHOD(cdutils, CDUTILS_GETISOINFOS);
DECLARE_METHOD(cdutils, CDUTILS_GETPTINFOS);
@@ -140,10 +140,10 @@ void Luacdutils::pushmembers(Lua * L) {
PUSH_METHOD(cdutils, CDUTILS_GUESSTYPE);
PUSH_METHOD(cdutils, CDUTILS_SECTORSEEK);
PUSH_METHOD(cdutils, CDUTILS_READSECTOR);
- PUSH_METHOD(cdutils, CDUTILS_READDATAS);
+ PUSH_METHOD(cdutils, CDUTILS_READdata);
PUSH_METHOD(cdutils, CDUTILS_READFILE);
PUSH_METHOD(cdutils, CDUTILS_WRITESECTOR);
- PUSH_METHOD(cdutils, CDUTILS_WRITEDATAS);
+ PUSH_METHOD(cdutils, CDUTILS_WRITEdata);
PUSH_METHOD(cdutils, CDUTILS_WRITEFILE);
PUSH_METHOD(cdutils, CDUTILS_GETISOINFOS);
PUSH_METHOD(cdutils, CDUTILS_GETPTINFOS);
@@ -230,7 +230,7 @@ void Luacdutils::pushstatics(Lua * L) throw (GeneralException) {
int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) {
int r = 0, sect = -1, mode = GUESS, size = -1, i;
Handle * h;
- Byte sdatas[2352], * datas;
+ Byte sdata[2352], * data;
String path;
cdutils::DirEntry * dir, * bdir, * adir, pdir;
bool invalid = false, eof = false;
@@ -258,31 +258,31 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) {
sect = L->tonumber(2);
if (n == 2)
mode = L->tonumber(3);
- size = cd->read_sector(sdatas, mode, sect);
+ size = cd->read_sector(sdata, mode, sect);
L->newtable();
for (i = 0; i < size; i++) {
L->push((lua_Number) i);
- L->push((lua_Number) sdatas[i]);
+ L->push((lua_Number) sdata[i]);
L->settable();
}
r = 1;
break;
- case CDUTILS_READDATAS:
+ case CDUTILS_READdata:
size = L->tonumber(2);
if (n >= 2)
sect = L->tonumber(3);
if (n == 3)
mode = L->tonumber(3);
- datas = (Byte *) malloc(size);
- cd->read_datas(datas, size, mode, sect);
+ data = (Byte *) malloc(size);
+ cd->read_data(data, size, mode, sect);
L->newtable();
for (i = 0; i < size; i++) {
L->push((lua_Number) i);
- L->push((lua_Number) datas[i]);
+ L->push((lua_Number) data[i]);
L->settable();
}
r = 1;
- free(datas);
+ free(data);
break;
case CDUTILS_READFILE:
h = (Handle *) LuaObject::getme(L, 2);
@@ -301,27 +301,27 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) {
for (i = 0; i < 2352; i++) {
L->push((lua_Number) i);
L->gettable(2);
- sdatas[i] = L->tonumber();
+ sdata[i] = L->tonumber();
L->pop();
}
- cd->write_sector(datas, mode, sect);
+ cd->write_sector(data, mode, sect);
break;
- case CDUTILS_WRITEDATAS:
+ case CDUTILS_WRITEdata:
size = L->tonumber(3);
if (n >= 3)
sect = L->tonumber(4);
if (n == 4)
mode = L->tonumber(5);
- datas = (Byte *) malloc(size);
+ data = (Byte *) malloc(size);
for (i = 0; i < size; i++) {
L->push((lua_Number) i);
L->gettable(2);
- sdatas[i] = L->tonumber();
+ sdata[i] = L->tonumber();
L->pop();
}
- cd->write_datas(datas, size, mode, sect);
- free(datas);
+ cd->write_data(data, size, mode, sect);
+ free(data);
break;
case CDUTILS_WRITEFILE:
h = (Handle *) LuaObject::getme(L, 2);
@@ -343,7 +343,7 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) {
break;
case CDUTILS_FINDPATH:
path = L->tostring(2);
- bdir = cd->find_path(&datas, path);
+ bdir = cd->find_path(&data, path);
if ((bdir) && bdir->R) {
dir = (cdutils::DirEntry *) malloc(bdir->R);
memcpy(dir, bdir, bdir->R);
@@ -357,11 +357,11 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) {
L->push();
}
r = 1;
- free(datas);
+ free(data);
break;
case CDUTILS_FINDPARENT:
path = L->tostring(2);
- bdir = cd->find_parent(&datas, path);
+ bdir = cd->find_parent(&data, path);
if ((bdir) && bdir->R) {
dir = (cdutils::DirEntry *) malloc(bdir->R);
memcpy(dir, bdir, bdir->R);
@@ -375,12 +375,12 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) {
L->push();
}
r = 1;
- free(datas);
+ free(data);
break;
case CDUTILS_FINDDIRENTRY:
adir = (cdutils::DirEntry *) LuaObject::getme(L, 2);
path = L->tostring(3);
- bdir = cd->find_dir_entry(&datas, adir, path);
+ bdir = cd->find_dir_entry(&data, adir, path);
if ((bdir) && bdir->R) {
dir = (cdutils::DirEntry *) malloc(bdir->R);
memcpy(dir, bdir, bdir->R);
@@ -394,7 +394,7 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) {
L->push();
}
r = 1;
- free(datas);
+ free(data);
break;
case CDUTILS_NEWCDFILE:
if (L->istable(2)) {
@@ -432,7 +432,7 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) {
case CDUTILS_UPDATESECTOR:
path = L->tostring(2);
pdir = cd->find_parent(path);
- dir = cd->find_path(&datas, path);
+ dir = cd->find_path(&data, path);
switch (caller) {
case CDUTILS_UPDATESIZE:
dir->Size = tolittle((Uint32) L->tonumber(3));
@@ -443,8 +443,8 @@ int sLua_cdutils::cdutils_proceed(Lua * L, int n, cdutils * cd, int caller) {
dir->BESector = tobig((Uint32) L->tonumber(3));
break;
}
- cd->write_datas(datas, pdir.Size, GUESS, pdir.Sector);
- free(datas);
+ cd->write_data(data, pdir.Size, GUESS, pdir.Sector);
+ free(data);
break;
case CDUTILS_CREATESECTOR:
mode = L->tonumber(2);
@@ -1343,7 +1343,7 @@ enum isobuilder_methods_t {
ISOBUILDER_FOREWORD_ARRAY,
ISOBUILDER_GETDISPSECT,
ISOBUILDER_PUTFILE,
- ISOBUILDER_PUTDATAS,
+ ISOBUILDER_PUTdata,
ISOBUILDER_CREATESECTOR,
ISOBUILDER_SETEOF,
ISOBUILDER_CLEAREOF,
@@ -1367,7 +1367,7 @@ struct lua_functypes_t isobuilder_methods[] = {
{ ISOBUILDER_FOREWORD_ARRAY, "foreword_array", 1, 2, {LUA_TABLE, LUA_NUMBER} },
{ ISOBUILDER_GETDISPSECT, "getdispsect", 0, 0, 0},
{ ISOBUILDER_PUTFILE, "putfile", 1, 3, {LUA_OBJECT, LUA_NUMBER, LUA_NUMBER} },
- { ISOBUILDER_PUTDATAS, "putdatas", 2, 4, {LUA_TABLE, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
+ { ISOBUILDER_PUTdata, "putdata", 2, 4, {LUA_TABLE, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
{ ISOBUILDER_CREATESECTOR, "createsector", 1, 7, {LUA_TABLE | LUA_OBJECT, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER, LUA_NUMBER} },
{ ISOBUILDER_SETEOF, "setEOF", 0, 0, 0 },
{ ISOBUILDER_CLEAREOF, "clearEOF", 0, 0, 0 },
@@ -1394,7 +1394,7 @@ class sLua_isobuilder : public Base {
DECLARE_METHOD(isobuilder, ISOBUILDER_FOREWORD_ARRAY);
DECLARE_METHOD(isobuilder, ISOBUILDER_GETDISPSECT);
DECLARE_METHOD(isobuilder, ISOBUILDER_PUTFILE);
- DECLARE_METHOD(isobuilder, ISOBUILDER_PUTDATAS);
+ DECLARE_METHOD(isobuilder, ISOBUILDER_PUTdata);
DECLARE_METHOD(isobuilder, ISOBUILDER_CREATESECTOR);
DECLARE_METHOD(isobuilder, ISOBUILDER_SETEOF);
DECLARE_METHOD(isobuilder, ISOBUILDER_CLEAREOF);
@@ -1422,7 +1422,7 @@ void Luaisobuilder::pushmembers(Lua * L) {
PUSH_METHOD(isobuilder, ISOBUILDER_FOREWORD_ARRAY);
PUSH_METHOD(isobuilder, ISOBUILDER_GETDISPSECT);
PUSH_METHOD(isobuilder, ISOBUILDER_PUTFILE);
- PUSH_METHOD(isobuilder, ISOBUILDER_PUTDATAS);
+ PUSH_METHOD(isobuilder, ISOBUILDER_PUTdata);
PUSH_METHOD(isobuilder, ISOBUILDER_CREATESECTOR);
PUSH_METHOD(isobuilder, ISOBUILDER_SETEOF);
PUSH_METHOD(isobuilder, ISOBUILDER_CLEAREOF);
@@ -1449,7 +1449,7 @@ int sLua_isobuilder::isobuilder_proceed(Lua * L, int n, isobuilder * iso, int ca
int mode = -1, sector = -1, rootsize = 1, ptsize = 1, nvd = 1, rootsect = -1, nsects = -1;
int FN = -1, CN = -1, SM = -1, CI = -1;
size_t size;
- Byte datas[2352 * 16], * p;
+ Byte data[2352 * 16], * p;
PVD * pvd;
DirTree * dirt, * rdir;
direntry * dire = 0;
@@ -1475,10 +1475,10 @@ int sLua_isobuilder::isobuilder_proceed(Lua * L, int n, isobuilder * iso, int ca
for (i = 0; i < 16 * 2352; i++) {
L->push((lua_Number) i);
L->gettable(2);
- datas[i] = L->tonumber();
+ data[i] = L->tonumber();
L->pop();
}
- iso->foreword(datas, mode);
+ iso->foreword(data, mode);
break;
case ISOBUILDER_GETDISPSECT:
L->push((lua_Number) iso->getdispsect());
@@ -1493,7 +1493,7 @@ int sLua_isobuilder::isobuilder_proceed(Lua * L, int n, isobuilder * iso, int ca
L->push((lua_Number) iso->putfile(h, mode, sector));
r = 1;
break;
- case ISOBUILDER_PUTDATAS:
+ case ISOBUILDER_PUTdata:
size = L->tonumber(3);
if (n >= 3)
mode = L->tonumber(4);
@@ -1506,7 +1506,7 @@ int sLua_isobuilder::isobuilder_proceed(Lua * L, int n, isobuilder * iso, int ca
p[i] = L->tonumber();
L->pop();
}
- L->push((lua_Number) iso->putdatas(p, size, mode, sector));
+ L->push((lua_Number) iso->putdata(p, size, mode, sector));
r = 1;
free(p);
break;
@@ -1530,10 +1530,10 @@ int sLua_isobuilder::isobuilder_proceed(Lua * L, int n, isobuilder * iso, int ca
for (i = 0; i < 2352; i++) {
L->push((lua_Number) i);
L->gettable(2);
- datas[i] = L->tonumber();
+ data[i] = L->tonumber();
L->pop();
}
- L->push((lua_Number) iso->createsector(datas, mode, sector, FN, CN, SM, CI));
+ L->push((lua_Number) iso->createsector(data, mode, sector, FN, CN, SM, CI));
}
r = 1;
break;
@@ -1620,7 +1620,7 @@ int sLua_isobuilder::isobuilder_proceed_statics(Lua * L, int n, int caller) {
Handle * h;
int mode = MODE2_FORM1;
cdutils * cd;
- Byte datas[2048];
+ Byte data[2048];
PVD * pvd;
switch (caller) {
@@ -1658,11 +1658,11 @@ int sLua_isobuilder::isobuilder_proceed_statics(Lua * L, int n, int caller) {
for (i = 0; i < 2048; i++) {
L->push((lua_Number) i);
L->gettable(1);
- datas[i] = L->tonumber();
+ data[i] = L->tonumber();
L->pop();
}
pvd = (PVD *) malloc(sizeof(PVD));
- *pvd = isobuilder::createpvd(datas);
+ *pvd = isobuilder::createpvd(data);
{
LuaPVD t(pvd);
t.pushdestruct(L);