summaryrefslogtreecommitdiff
path: root/command_line/CmdLine/Src/MacEmul
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--command_line/CmdLine/Src/MacEmul/ErrMgr.c2
-rw-r--r--command_line/CmdLine/Src/MacEmul/Files.c2
-rw-r--r--command_line/CmdLine/Src/MacEmul/LowMem.c2
-rw-r--r--command_line/CmdLine/Src/MacEmul/Memory.c2
-rw-r--r--command_line/CmdLine/Src/MacEmul/ResourceStrings.c6
-rw-r--r--command_line/CmdLine/Src/MacEmul/Resources.c39
-rw-r--r--command_line/CmdLine/Src/MacEmul/TextUtils.c2
7 files changed, 29 insertions, 26 deletions
diff --git a/command_line/CmdLine/Src/MacEmul/ErrMgr.c b/command_line/CmdLine/Src/MacEmul/ErrMgr.c
index 5fc621d..5ea1fe6 100644
--- a/command_line/CmdLine/Src/MacEmul/ErrMgr.c
+++ b/command_line/CmdLine/Src/MacEmul/ErrMgr.c
@@ -1,4 +1,4 @@
-#include "mwcc_decomp.h"
+#include "cmdline.h"
static const char *getsyserr(SInt16 msgNbr) {
switch (msgNbr) {
diff --git a/command_line/CmdLine/Src/MacEmul/Files.c b/command_line/CmdLine/Src/MacEmul/Files.c
index 9a9cb60..a613b4a 100644
--- a/command_line/CmdLine/Src/MacEmul/Files.c
+++ b/command_line/CmdLine/Src/MacEmul/Files.c
@@ -1,4 +1,4 @@
-#include "mwcc_decomp.h"
+#include "cmdline.h"
typedef struct MacFileInfo {
UInt32 ioFlCrDat;
diff --git a/command_line/CmdLine/Src/MacEmul/LowMem.c b/command_line/CmdLine/Src/MacEmul/LowMem.c
index 7fab079..cd31194 100644
--- a/command_line/CmdLine/Src/MacEmul/LowMem.c
+++ b/command_line/CmdLine/Src/MacEmul/LowMem.c
@@ -1,4 +1,4 @@
-#include "mwcc_decomp.h"
+#include "cmdline.h"
static OSErr memErr;
diff --git a/command_line/CmdLine/Src/MacEmul/Memory.c b/command_line/CmdLine/Src/MacEmul/Memory.c
index 0aa5d24..e201343 100644
--- a/command_line/CmdLine/Src/MacEmul/Memory.c
+++ b/command_line/CmdLine/Src/MacEmul/Memory.c
@@ -1,4 +1,4 @@
-#include "mwcc_decomp.h"
+#include "cmdline.h"
static OSErr memError;
diff --git a/command_line/CmdLine/Src/MacEmul/ResourceStrings.c b/command_line/CmdLine/Src/MacEmul/ResourceStrings.c
index 9f8f333..4b6bc22 100644
--- a/command_line/CmdLine/Src/MacEmul/ResourceStrings.c
+++ b/command_line/CmdLine/Src/MacEmul/ResourceStrings.c
@@ -1,9 +1,9 @@
-#include "mwcc_decomp.h"
+#include "cmdline.h"
typedef struct {
const char *name;
SInt16 rsrcid;
- Handle strings;
+ const char **strings;
} Res;
static Res rlist[16];
@@ -12,7 +12,7 @@ void Res_Initialize() {
memset(rlist, 0, sizeof(rlist));
}
-int Res_AddResource(const char *name, SInt16 rsrcid, Handle strings) {
+int Res_AddResource(const char *name, SInt16 rsrcid, const char **strings) {
int scan;
for (scan = 0; scan < 16 && rlist[scan].rsrcid; scan++) {
diff --git a/command_line/CmdLine/Src/MacEmul/Resources.c b/command_line/CmdLine/Src/MacEmul/Resources.c
index 796ed43..ef2aab0 100644
--- a/command_line/CmdLine/Src/MacEmul/Resources.c
+++ b/command_line/CmdLine/Src/MacEmul/Resources.c
@@ -1,4 +1,4 @@
-#include "mwcc_decomp.h"
+#include "cmdline.h"
// Fork Attributes
enum {
@@ -284,6 +284,7 @@ memcpy(buf, ((unsigned char *) file_data) + __offs, (count)); \
} while(0)
static void ReadResourceFork(SInt16 ref, SInt8 permission, void *file_data, SInt32 file_size) {
+ // this function has various awkwardly swapped registers
MemRsrcMap *rm;
Ty70 thdr;
Ty70 *dhdr;
@@ -316,27 +317,29 @@ static void ReadResourceFork(SInt16 ref, SInt8 permission, void *file_data, SInt
cnt = sizeof(Ty70);
RF_READ(&thdr, 0, cnt, mapFail);
+ dhdr = &thdr;
ref_offs = cnt;
cnt = ((thdr.map_offs < thdr.data_offs) ? thdr.map_offs : thdr.data_offs) - sizeof(Ty70);
if (cnt > sizeof(MemRsrcSysData))
cnt = sizeof(MemRsrcSysData);
RF_READ(&tsys, ref_offs, cnt, mapFail);
+ dsys = &tsys;
- msize = thdr.map_len;
+ msize = dhdr->map_len;
buffer = malloc(msize);
if (!buffer)
goto memFail;
- ref_offs = thdr.map_offs;
+ ref_offs = dhdr->map_offs;
RF_READ(buffer, ref_offs, msize, mapFail);
if (
- (thdr.map_offs > file_size)
- || ((thdr.map_offs + thdr.map_len) > file_size)
- || (thdr.data_offs > file_size)
- || ((thdr.data_offs + thdr.data_len) > file_size)
- || ((thdr.map_offs < thdr.data_offs) ? ((thdr.map_offs + thdr.map_len) != thdr.data_offs) : ((thdr.data_offs + thdr.data_len) != thdr.map_offs))
+ (dhdr->map_offs > file_size)
+ || ((dhdr->map_offs + dhdr->map_len) > file_size)
+ || (dhdr->data_offs > file_size)
+ || ((dhdr->data_offs + dhdr->data_len) > file_size)
+ || ((dhdr->map_offs < dhdr->data_offs) ? ((dhdr->map_offs + dhdr->map_len) > dhdr->data_offs) : ((dhdr->data_offs + dhdr->data_len) > dhdr->map_offs))
)
goto mapFail;
@@ -344,13 +347,13 @@ static void ReadResourceFork(SInt16 ref, SInt8 permission, void *file_data, SInt
if (!rm)
goto memFail;
- rm->sys_data = tsys;
+ rm->sys_data = *dsys;
dmap = (Ty73 *) buffer;
- if ((dmap->typelist_offs + thdr.map_offs) > file_size)
+ if ((dmap->typelist_offs + dhdr->map_offs) > file_size)
goto freeAndMapFail;
dtyp = (Ty75 *) (((unsigned char *) buffer) + dmap->typelist_offs + 2);
- if ((dmap->namelist_offs + thdr.map_offs) > file_size)
+ if ((dmap->namelist_offs + dhdr->map_offs) > file_size)
goto freeAndMapFail;
dnam = (Ty80 *) (((unsigned char *) buffer) + dmap->namelist_offs);
if (dmap->types_idx != 0xFFFF) {
@@ -359,21 +362,21 @@ static void ReadResourceFork(SInt16 ref, SInt8 permission, void *file_data, SInt
if (!mtyp)
goto freeAndReturn;
- if ((thdr.map_offs + dmap->typelist_offs + dtyp[cnt].ref_list_offs) > file_size)
+ if ((dmap->typelist_offs + dtyp[cnt].ref_list_offs + dhdr->map_offs) > file_size)
goto freeAndMapFail;
drle = (Ty77 *) (((unsigned char *) dtyp) + dtyp[cnt].ref_list_offs - 2);
if (dtyp[cnt].rsrc_idx != 0xFFFF) {
for (rcnt = 0; rcnt <= dtyp[cnt].rsrc_idx; rcnt++) {
ref_offs = (drle[rcnt].data_offs[0] << 16) | (drle[rcnt].data_offs[1] << 8) | drle[rcnt].data_offs[2];
- offs = thdr.data_offs + ref_offs;
+ offs = ref_offs + dhdr->data_offs;
if (offs > file_size)
goto freeAndMapFail;
esize = 4;
RF_READ(&tent, offs, esize, freeAndMapFail);
offs += esize;
- if ((thdr.data_offs + ref_offs + tent.len) > file_size)
+ if ((tent.len + ref_offs + dhdr->data_offs) > file_size)
goto freeAndMapFail;
hand = NewHandle(tent.len);
@@ -385,7 +388,7 @@ static void ReadResourceFork(SInt16 ref, SInt8 permission, void *file_data, SInt
HUnlock(hand);
if (drle[rcnt].name_offs != 0xFFFF) {
- nameptr = (StringPtr) (dnam + drle[rcnt].name_offs);
+ nameptr = (StringPtr) dnam + drle[rcnt].name_offs;
name = malloc(nameptr[0] + 1);
memcpy(name, nameptr, nameptr[0] + 1);
} else {
@@ -1250,14 +1253,14 @@ void HCreateResFile(SInt16 vRefNum, SInt32 dirID, ConstStringPtr fileName) {
}
}
-OSErr FSpOpenResFile(const FSSpec *fss, SInt8 permission) {
+OSErr FSpOpenResFile(const FSSpec *spec, SInt8 permission) {
SInt16 ref;
SInt32 size;
if (permission != fsRdPerm)
- FSpCreate(fss, 'CWIE', 'TEXT', -1);
+ FSpCreate(spec, 'CWIE', 'TEXT', -1);
- resError = FSpOpenRF(fss, (permission == fsWrPerm) ? fsRdWrPerm : permission, &ref);
+ resError = FSpOpenRF(spec, (permission == fsWrPerm) ? fsRdWrPerm : permission, &ref);
if (!resError) {
GetEOF(ref, &size);
if (size == 0 && permission != fsRdPerm)
diff --git a/command_line/CmdLine/Src/MacEmul/TextUtils.c b/command_line/CmdLine/Src/MacEmul/TextUtils.c
index a23ac7e..7971074 100644
--- a/command_line/CmdLine/Src/MacEmul/TextUtils.c
+++ b/command_line/CmdLine/Src/MacEmul/TextUtils.c
@@ -1,4 +1,4 @@
-#include "mwcc_decomp.h"
+#include "cmdline.h"
StringPtr c2pstr(char *s) {
unsigned int l;