add cmakelists for CLion, tons and tons of reorganisation using new info from the Pro8 compiler

This commit is contained in:
Ash Wolf 2022-10-11 03:18:42 +01:00
parent 7d4bee5f8f
commit 26b57fbea1
51 changed files with 5288 additions and 1994 deletions

View File

@ -1,4 +1,4 @@
#include "mwcc_decomp.h" #include "includes/mwcc_decomp.h"
char compat; char compat;
char *MAINOPTCHAR; char *MAINOPTCHAR;

65
CMakeLists.txt Normal file
View File

@ -0,0 +1,65 @@
cmake_minimum_required(VERSION 3.23)
project(mwcc)
set(CMAKE_CXX_STANDARD 14)
include_directories(.)
include_directories(includes)
include_directories(sdk_hdrs)
add_executable(mwcc
command_line/CmdLine/Src/Callbacks/CLCompilerLinkerDropin_V10.cpp
command_line/CmdLine/Src/Callbacks/CLDropinCallbacks_V10.cpp
command_line/CmdLine/Src/Callbacks/CLParserCallbacks_v1.cpp
command_line/CmdLine/Src/Clients/ClientGlue.c
command_line/CmdLine/Src/Clients/CLStaticMain.c
command_line/CmdLine/Src/Envir/CLErrors.c
command_line/CmdLine/Src/Envir/CLIO.c
command_line/CmdLine/Src/MacEmul/ErrMgr.c
command_line/CmdLine/Src/MacEmul/Files.c
command_line/CmdLine/Src/MacEmul/LowMem.c
command_line/CmdLine/Src/MacEmul/Memory.c
command_line/CmdLine/Src/MacEmul/Resources.c
command_line/CmdLine/Src/MacEmul/ResourceStrings.c
command_line/CmdLine/Src/MacEmul/TextUtils.c
command_line/CmdLine/Src/OSLib/FileHandles.c
command_line/CmdLine/Src/OSLib/Generic.c
command_line/CmdLine/Src/OSLib/MacFileTypes.c
command_line/CmdLine/Src/OSLib/MacSpecs.c
command_line/CmdLine/Src/OSLib/MemUtils.c
command_line/CmdLine/Src/OSLib/Posix.c
command_line/CmdLine/Src/OSLib/StringExtras.c
command_line/CmdLine/Src/OSLib/StringUtils.c
command_line/CmdLine/Src/Plugins/CLPlugins.c
command_line/CmdLine/Src/Project/CLAccessPaths.c
command_line/CmdLine/Src/Project/CLFiles.c
command_line/CmdLine/Src/Project/CLOverlays.c
command_line/CmdLine/Src/Project/CLProj.c
command_line/CmdLine/Src/Project/CLSegs.c
command_line/CmdLine/Src/CLBrowser.c
command_line/CmdLine/Src/CLDependencies.c
command_line/CmdLine/Src/CLFileOps.c
command_line/CmdLine/Src/CLIncludeFileCache.c
command_line/CmdLine/Src/CLLicenses.c
command_line/CmdLine/Src/CLLoadAndCache.c
command_line/CmdLine/Src/CLMain.c
command_line/CmdLine/Src/CLPluginAPI.c
command_line/CmdLine/Src/CLPrefs.c
command_line/CmdLine/Src/CLTarg.c
command_line/CmdLine/Src/CLToolExec.c
command_line/CmdLine/Src/CLWriteObjectFile.c
includes/mwcc_decomp.h
sdk_hdrs/CatTypes.h
sdk_hdrs/CompilerMapping.h
sdk_hdrs/CWDropInPanel.h
sdk_hdrs/CWPluginErrors.h
sdk_hdrs/CWPlugins.h
sdk_hdrs/CWRuntimeFeatures.h
sdk_hdrs/CWUnixPluginPrefix.h
sdk_hdrs/CWWinPluginPrefix.h
sdk_hdrs/DropInCompilerLinker.h
sdk_hdrs/DropInPanel.h
sdk_hdrs/DropInPanelWin32.h
sdk_hdrs/DropInVCS.h
sdk_hdrs/MWBrowse.h
sdk_hdrs/MWLangDefs.h)

View File

@ -1,4 +1,4 @@
#include "mwcc_decomp.h" #include "includes/mwcc_decomp.h"
#pragma once #pragma once
extern void CompilerGetPString(short index, unsigned char *str); extern void CompilerGetPString(short index, unsigned char *str);

4
Help.c
View File

@ -1,4 +1,4 @@
#include "mwcc_decomp.h" #include "includes/mwcc_decomp.h"
typedef struct _Side { typedef struct _Side {
short offset; short offset;
short width; short width;
@ -415,7 +415,7 @@ void Help_Options(struct OptionList *lst, int subprint, const char *keyword) {
opts = lst->list; opts = lst->list;
toolflags = 0; toolflags = 0;
if (Option_ThisTool() == (unsigned int) OTF_TOOL_COMPILER) { if (Option_ThisTool() == OTF_TOOL_COMPILER) {
toolflags |= LISTFLAGS_COMPILER; toolflags |= LISTFLAGS_COMPILER;
} else { } else {
toolflags |= LISTFLAGS_LINKER; toolflags |= LISTFLAGS_LINKER;

View File

@ -1,4 +1,4 @@
#include "mwcc_decomp.h" #include "includes/mwcc_decomp.h"
#define OPTION_ASSERT(cond) do { if (!(cond)) { printf("%s:%u: failed assertion\n", __FILE__, __LINE__); abort(); } } while(0) #define OPTION_ASSERT(cond) do { if (!(cond)) { printf("%s:%u: failed assertion\n", __FILE__, __LINE__); abort(); } } while(0)

View File

@ -1,4 +1,4 @@
#include "mwcc_decomp.h" #include "includes/mwcc_decomp.h"
#define OPTION_ASSERT(cond) do { if (!(cond)) { printf("%s:%u: failed assertion\n", __FILE__, __LINE__); abort(); } } while(0) #define OPTION_ASSERT(cond) do { if (!(cond)) { printf("%s:%u: failed assertion\n", __FILE__, __LINE__); abort(); } } while(0)

View File

@ -1,6 +1,6 @@
#include "UCWInterface.h" #include "UCWInterface.h"
static short CLT_dummymain() { static short CLT_dummymain(void *context) {
return 0; return 0;
} }
@ -18,9 +18,9 @@ static short CLT_GetDropInFlags(const DropInFlags **flags, long *flagsSize) {
return 0; return 0;
} }
static short CLT_GetDropInName(const char **dropInName) { static short CLT_GetDropInName(const char **dropinName) {
static const char *sDropInName = "Command-Line Driver"; static const char *sDropInName = "Command-Line Driver";
*dropInName = sDropInName; *dropinName = sDropInName;
return 0; return 0;
} }
@ -73,7 +73,7 @@ static short CLT_GetVersionInfo(const VersionInfo **versioninfo) {
return 0; return 0;
} }
static short CLT_GetFileTypeMappings(const OSFileTypeMappingList **mappingList) { static short CLT_GetFileTypeMappings(const OSFileTypeMappingList **mappinglist) {
static const OSFileTypeMapping ftmes[2] = { static const OSFileTypeMapping ftmes[2] = {
{CWFOURCHAR('B','r','w','s'), "DubL", 4, 0, 0}, {CWFOURCHAR('B','r','w','s'), "DubL", 4, 0, 0},
{CWFOURCHAR('M','M','P','r'), "looc", 4, 0, 0} {CWFOURCHAR('M','M','P','r'), "looc", 4, 0, 0}
@ -82,7 +82,7 @@ static short CLT_GetFileTypeMappings(const OSFileTypeMappingList **mappingList)
2, 2,
ftmes ftmes
}; };
*mappingList = &ftml; *mappinglist = &ftml;
return 0; return 0;
} }
@ -102,14 +102,15 @@ static int RegisterStaticCmdLinePlugin() {
return RegisterStaticPlugin(&clcb); return RegisterStaticPlugin(&clcb);
} }
const char *STR12000[100]; // TODO do me later // TODO do me later - this comes from CmdLine/Project/Resources/CLErrors.r
const char *STR12000[100];
static int RegisterCmdLineResources() { static int RegisterCmdLineResources() {
return RegisterResource("Command-line strings", 12000, &STR12000); return RegisterResource("Command-line strings", 12000, &STR12000);
} }
static int special_debug(unsigned char flag, char *) { static int special_debug(unsigned char pre, char *) {
if (flag) { if (pre) {
SetupDebuggingTraps(); SetupDebuggingTraps();
return 1; return 1;
} else { } else {
@ -117,8 +118,8 @@ static int special_debug(unsigned char flag, char *) {
} }
} }
static int special_plugin_debug(unsigned char flag, char *) { static int special_plugin_debug(unsigned char pre, char *) {
if (flag) { if (pre) {
clState.pluginDebug = 1; clState.pluginDebug = 1;
return 1; return 1;
} else { } else {
@ -126,8 +127,8 @@ static int special_plugin_debug(unsigned char flag, char *) {
} }
} }
static int special_stdout_base(unsigned char flag, char *) { static int special_stdout_base(unsigned char pre, char *) {
if (flag) { if (pre) {
return 1; return 1;
} else { } else {
return clState.stdoutBase != 0; return clState.stdoutBase != 0;
@ -135,9 +136,9 @@ static int special_stdout_base(unsigned char flag, char *) {
} }
struct SpecialOption { struct SpecialOption {
const char *name; const char *optname;
char **location; char **argp;
int (*callback)(unsigned char a, char *b); int (*func)(unsigned char a, char *b);
}; };
static struct SpecialOption special_options[3] = { static struct SpecialOption special_options[3] = {
{"", 0, special_debug}, {"", 0, special_debug},
@ -146,16 +147,16 @@ static struct SpecialOption special_options[3] = {
}; };
void Main_PreParse(int *pArgc, char ***pArgv) { void Main_PreParse(int *pArgc, char ***pArgv) {
int i; struct SpecialOption *so;
struct SpecialOption *opt; int idx;
if (*pArgc > 1) { if (*pArgc > 1) {
restart: restart:
for (i = 0, opt = &special_options[0]; i < 3; i++, opt++) { for (idx = 0, so = &special_options[0]; idx < 3; idx++, so++) {
if (!strcmp(opt->name, (*pArgv)[1])) { if (!strcmp(so->optname, (*pArgv)[1])) {
if (opt->location) { if (so->argp) {
*opt->location = (*pArgv)[2]; *so->argp = (*pArgv)[2];
opt->callback(1, *opt->location); so->func(1, *so->argp);
(*pArgv)[1] = (*pArgv)[0]; (*pArgv)[1] = (*pArgv)[0];
(*pArgc)--; (*pArgc)--;
(*pArgv)++; (*pArgv)++;
@ -164,7 +165,7 @@ void Main_PreParse(int *pArgc, char ***pArgv) {
(*pArgc)--; (*pArgc)--;
(*pArgv)++; (*pArgv)++;
} else { } else {
opt->callback(1, 0); so->func(1, 0);
(*pArgv)[1] = (*pArgv)[0]; (*pArgv)[1] = (*pArgv)[0];
(*pArgc)--; (*pArgc)--;
(*pArgv)++; (*pArgv)++;
@ -173,21 +174,21 @@ void Main_PreParse(int *pArgc, char ***pArgv) {
} }
} }
if ((*pArgc) > 1 && i < 3) if ((*pArgc) > 1 && idx < 3)
goto restart; goto restart;
} }
} }
void Main_PassSpecialArgs(void *unk1, void *unk2) { void Main_PassSpecialArgs(void *unk1, void *unk2) {
int i; struct SpecialOption *so;
struct SpecialOption *opt; int idx;
for (i = 0; i < 3; i++) { for (idx = 0; idx < 3; idx++) {
opt = &special_options[i]; so = &special_options[idx];
if (opt->callback(0, 0)) { if (so->func(0, 0)) {
AppendArgumentList(unk1, unk2, opt->name); AppendArgumentList(unk1, unk2, so->optname);
if (opt->location) if (so->argp)
AppendArgumentList(unk1, unk2, (*opt->location) ? *opt->location : ""); AppendArgumentList(unk1, unk2, (*so->argp) ? *so->argp : "");
} }
} }
} }
@ -201,11 +202,11 @@ PCmdLineLinker optsLinker;
int Main_Initialize(int argc, const char **argv) { int Main_Initialize(int argc, const char **argv) {
static char secret[8]; static char secret[8];
char buf[256]; char exename[256];
OS_InitProgram(&argc, &argv); OS_InitProgram(&argc, &argv);
memset(&clState, 0, sizeof(CLState)); memset(&clState, 0, sizeof(CLState));
special_options[0].name = secret; special_options[0].optname = secret;
secret[7] = 0; secret[7] = 0;
secret[4] = 'b'; secret[4] = 'b';
secret[1] = '-'; secret[1] = '-';
@ -224,7 +225,7 @@ int Main_Initialize(int argc, const char **argv) {
return 0; return 0;
} }
int Main_Terminate(int code) { int Main_Terminate(int exitcode) {
if (MainInitialized) { if (MainInitialized) {
Plugins_Term(); Plugins_Term();
License_Terminate(); License_Terminate();
@ -232,11 +233,14 @@ int Main_Terminate(int code) {
IO_Terminate(); IO_Terminate();
MainInitialized = 0; MainInitialized = 0;
} }
return code; return exitcode;
} }
static int Main_ParseCommandLine() { static int Main_ParseCommandLine() {
// TODO: clState, Plugins, gTarg, ... // TODO: clState, Plugins, gTarg, ...
long vislang;
int x, y;
CWCommandLineArgs myargs;
} }
static int Main_SetupParamBlock() { static int Main_SetupParamBlock() {
@ -246,39 +250,41 @@ static int Main_SetupParamBlock() {
static int Main_ResolveProject() { static int Main_ResolveProject() {
// TODO: Various project things // TODO: Various project things
int err;
long startTime, endTime;
} }
static int UpdatePCmdLineFromVersion(const PCmdLine *oldVer, PCmdLine *newVer) { static int UpdatePCmdLineFromVersion(const PCmdLine *given, PCmdLine *target) {
static unsigned char warned; static unsigned char warned;
short ver = oldVer->version; short version = given->version;
*newVer = *oldVer; *target = *given;
// TODO: clState // TODO: clState
return 0; return 0;
} }
static int UpdatePCmdLineEnvirFromVersion(const PCmdLineEnvir *oldVer, PCmdLineEnvir *newVer) { static int UpdatePCmdLineEnvirFromVersion(const PCmdLineEnvir *given, PCmdLineEnvir *target) {
static unsigned char warned; static unsigned char warned;
short ver = oldVer->version; short version = given->version;
*newVer = *oldVer; *target = *given;
// TODO: clState // TODO: clState
return 0; return 0;
} }
static int UpdatePCmdLineCompilerFromVersion(const PCmdLineCompiler *oldVer, PCmdLineCompiler *newVer) { static int UpdatePCmdLineCompilerFromVersion(const PCmdLineCompiler *given, PCmdLineCompiler *target) {
static unsigned char warned; static unsigned char warned;
short ver = oldVer->version; short version = given->version;
*newVer = *oldVer; *target = *given;
// TODO: clState // TODO: clState
return 0; return 0;
} }
static int UpdatePCmdLineLinkerFromVersion(const PCmdLineLinker *oldVer, PCmdLineLinker *newVer) { static int UpdatePCmdLineLinkerFromVersion(const PCmdLineLinker *given, PCmdLineLinker *target) {
static unsigned char warned; static unsigned char warned;
short ver = oldVer->version; short version = given->version;
*newVer = *oldVer; *target = *given;
// TODO: clState // TODO: clState
return 0; return 0;
@ -286,12 +292,12 @@ static int UpdatePCmdLineLinkerFromVersion(const PCmdLineLinker *oldVer, PCmdLin
static int UpdatePrefPanels(const char *name) { static int UpdatePrefPanels(const char *name) {
PrefPanel *panel; PrefPanel *panel;
Handle handle; Handle h;
if (!name || !ustrcmp(name, "CmdLine Panel")) { if (!name || !ustrcmp(name, "CmdLine Panel")) {
if ((panel = Prefs_FindPanel("CmdLine Panel")) && (handle = PrefPanel_GetHandle(panel))) { if ((panel = Prefs_FindPanel("CmdLine Panel")) && (h = PrefPanel_GetHandle(panel))) {
if (name) { if (name) {
if (!UpdatePCmdLineFromVersion((PCmdLine *) *handle, &optsCmdLine)) if (!UpdatePCmdLineFromVersion((PCmdLine *) *h, &optsCmdLine))
return 0; return 0;
} }
} else { } else {
@ -301,9 +307,9 @@ static int UpdatePrefPanels(const char *name) {
} }
if (!name || !ustrcmp(name, "CmdLine Environment")) { if (!name || !ustrcmp(name, "CmdLine Environment")) {
if ((panel = Prefs_FindPanel("CmdLine Environment")) && (handle = PrefPanel_GetHandle(panel))) { if ((panel = Prefs_FindPanel("CmdLine Environment")) && (h = PrefPanel_GetHandle(panel))) {
if (name) { if (name) {
if (!UpdatePCmdLineEnvirFromVersion((PCmdLineEnvir *) *handle, &optsEnvir)) if (!UpdatePCmdLineEnvirFromVersion((PCmdLineEnvir *) *h, &optsEnvir))
return 0; return 0;
} }
} else { } else {
@ -313,9 +319,9 @@ static int UpdatePrefPanels(const char *name) {
} }
if (!name || !ustrcmp(name, "CmdLine Compiler Panel")) { if (!name || !ustrcmp(name, "CmdLine Compiler Panel")) {
if ((panel = Prefs_FindPanel("CmdLine Compiler Panel")) && (handle = PrefPanel_GetHandle(panel))) { if ((panel = Prefs_FindPanel("CmdLine Compiler Panel")) && (h = PrefPanel_GetHandle(panel))) {
if (name) { if (name) {
if (!UpdatePCmdLineCompilerFromVersion((PCmdLineCompiler *) *handle, &optsCompiler)) if (!UpdatePCmdLineCompilerFromVersion((PCmdLineCompiler *) *h, &optsCompiler))
return 0; return 0;
} }
} else { } else {
@ -325,9 +331,9 @@ static int UpdatePrefPanels(const char *name) {
} }
if (!name || !ustrcmp(name, "CmdLine Linker Panel")) { if (!name || !ustrcmp(name, "CmdLine Linker Panel")) {
if ((panel = Prefs_FindPanel("CmdLine Linker Panel")) && (handle = PrefPanel_GetHandle(panel))) { if ((panel = Prefs_FindPanel("CmdLine Linker Panel")) && (h = PrefPanel_GetHandle(panel))) {
if (name) { if (name) {
if (!UpdatePCmdLineLinkerFromVersion((PCmdLineLinker *) *handle, &optsLinker)) if (!UpdatePCmdLineLinkerFromVersion((PCmdLineLinker *) *h, &optsLinker))
return 0; return 0;
} }
} else { } else {
@ -340,19 +346,19 @@ static int UpdatePrefPanels(const char *name) {
} }
static int SetupCmdLinePrefPanels() { static int SetupCmdLinePrefPanels() {
int result; int ret;
PrefPanelsChangedCallback = UpdatePrefPanels; PrefPanelsChangedCallback = UpdatePrefPanels;
result = Prefs_AddPanel( ret = Prefs_AddPanel(
PrefPanel_New("CmdLine Environment", &optsEnvir, sizeof(PCmdLineEnvir)) PrefPanel_New("CmdLine Environment", &optsEnvir, sizeof(PCmdLineEnvir))
); );
result |= ( ret |= (
Prefs_AddPanel(PrefPanel_New("CmdLine Panel", 0, sizeof(PCmdLine))) Prefs_AddPanel(PrefPanel_New("CmdLine Panel", 0, sizeof(PCmdLine)))
&& Prefs_AddPanel(PrefPanel_New("CmdLine Compiler Panel", 0, sizeof(PCmdLineCompiler))) && Prefs_AddPanel(PrefPanel_New("CmdLine Compiler Panel", 0, sizeof(PCmdLineCompiler)))
&& Prefs_AddPanel(PrefPanel_New("CmdLine Linker Panel", 0, sizeof(PCmdLineLinker))) && Prefs_AddPanel(PrefPanel_New("CmdLine Linker Panel", 0, sizeof(PCmdLineLinker)))
); );
return result; return ret;
} }
static int Main_SetupContext() { static int Main_SetupContext() {

84
UMain.c
View File

@ -1,21 +1,13 @@
#include "UCWInterface.h" #include "includes/mwcc_decomp.h"
// 1C40 to 2008
// TODO move me
// TODO move me
// unsure where this is, may be here, maybe not?
extern char cmdline_build_date[32];
extern char cmdline_build_time[32];
// TODO split main off into CLStaticMain.c
int main(int argc, const char **argv) { int main(int argc, const char **argv) {
unsigned long cpu; CWDataType cpu;
unsigned long os; CWDataType os;
unsigned long language; CWDataType lang;
unsigned long plugintype; CWDataType type;
unsigned long style; CWDataType style;
int result; int ret;
if (CmdLine_Initialize(argc, argv, CMDLINE_BUILD_DATE, CMDLINE_BUILD_TIME)) if (CmdLine_Initialize(argc, argv, CMDLINE_BUILD_DATE, CMDLINE_BUILD_TIME))
exit(1); exit(1);
@ -37,48 +29,48 @@ int main(int argc, const char **argv) {
GetStaticTarget(&cpu, &os); GetStaticTarget(&cpu, &os);
SetBuildTarget(cpu, os); SetBuildTarget(cpu, os);
GetStaticPluginType(&language, &plugintype); GetStaticPluginType(&lang, &type);
SetPluginType(language, plugintype); SetPluginType(lang, type);
GetStaticParserPluginType(&style); GetStaticParserPluginType(&style);
SetParserType(style); SetParserType(style);
result = CmdLine_Driver(); ret = CmdLine_Driver();
if (result) { if (ret) {
if (result == 2) if (ret == 2)
fprintf(stderr, "\nUser break, cancelled...\n"); fprintf(stderr, "\nUser break, cancelled...\n");
else else
fprintf(stderr, "\nErrors caused tool to abort.\n"); fprintf(stderr, "\nErrors caused tool to abort.\n");
} }
CmdLine_Terminate(result); CmdLine_Terminate(ret);
return result; return ret;
} }
int RegisterResource(const char *name, short index, void *data) { int RegisterResource(const char *name, short rsrcid, Handle list) {
Handle r; Handle h;
if (data == 0) { if (data == 0) {
r = GetResource('STR#', index); h = GetResource('STR#', rsrcid);
if (r == 0) { if (h == 0) {
CLFatalError("Resource ('STR#',%d) '%s' not found in executable\n", index, name); CLFatalError("Resource ('STR#',%d) '%s' not found in executable\n", rsrcid, name);
return 0; return 0;
} }
ReleaseResource(r); ReleaseResource(h);
return 1; return 1;
} else { } else {
return Res_AddResource(name, index, data); return Res_AddResource(name, rsrcid, list);
} }
} }
int RegisterStaticPlugin(const BasePluginCallbacks *cb) { int RegisterStaticPlugin(const BasePluginCallbacks *callbacks) {
return Plugins_Add(Plugin_New(cb, 0, 0)); return Plugins_Add(Plugin_New(callbacks, 0, 0));
} }
int RegisterStaticCompilerLinkerPlugin(const BasePluginCallbacks *cb, void *b) { int RegisterStaticCompilerLinkerPlugin(const BasePluginCallbacks *callbacks, const CompilerLinkerPluginCallbacks *cl_callbacks) {
return Plugins_Add(Plugin_New(cb, b, 0)); return Plugins_Add(Plugin_New(callbacks, cl_callbacks, 0));
} }
int RegisterStaticParserPlugin(const BasePluginCallbacks *cb, void *b) { int RegisterStaticParserPlugin(const BasePluginCallbacks *callbacks, const ParserPluginCallbacks *pr_callbacks) {
return Plugins_Add(Plugin_New(cb, 0, b)); return Plugins_Add(Plugin_New(callbacks, 0, pr_callbacks));
} }
void SetBuildTarget(CWDataType cpu, CWDataType os) { void SetBuildTarget(CWDataType cpu, CWDataType os) {
@ -86,18 +78,18 @@ void SetBuildTarget(CWDataType cpu, CWDataType os) {
clState.os = os; clState.os = os;
} }
void SetParserType(CWDataType style) { void SetParserType(CWDataType plang) {
clState.style = style; clState.parserstyle = plang;
} }
void SetPluginType(CWDataType language, CWDataType plugintype) { void SetPluginType(CWDataType lang, CWDataType type) {
clState.language = language; clState.language = lang;
clState.plugintype = plugintype; clState.plugintype = type;
} }
int CmdLine_Initialize(int argc, const char **argv, const char *buildDate, const char *buildTime) { int CmdLine_Initialize(int argc, const char **argv, const char *builddate, const char *buildtime) {
strncpy(cmdline_build_date, buildDate, sizeof(cmdline_build_date)); strncpy(cmdline_build_date, builddate, sizeof(cmdline_build_date));
strncpy(cmdline_build_time, buildTime, sizeof(cmdline_build_time)); strncpy(cmdline_build_time, buildtime, sizeof(cmdline_build_time));
return Main_Initialize(argc, argv); return Main_Initialize(argc, argv);
} }
@ -105,6 +97,6 @@ int CmdLine_Driver() {
return Main_Driver(); return Main_Driver();
} }
int CmdLine_Terminate(int code) { int CmdLine_Terminate(int exitcode) {
return Main_Terminate(code); return Main_Terminate(exitcode);
} }

View File

View File

View File

View File

@ -0,0 +1,390 @@
#include "mwcc_decomp.h"
static short CLT_dummymain(void *context) {
return 0;
}
static short CLT_GetDropInFlags(const DropInFlags **flags, long *flagsSize) {
static const DropInFlags sFlags = {
kCurrentDropInFlagsVersion,
CWFOURCHAR('c','l','d','r'),
7,
0,
0,
12
};
*flags = &sFlags;
*flagsSize = sizeof(sFlags);
return 0;
}
static short CLT_GetDropInName(const char **dropinName) {
static const char *sDropInName = "Command-Line Driver";
*dropinName = sDropInName;
return 0;
}
static short CLT_GetDisplayName(const char **displayName) {
static const char *sDisplayName = "Command-Line Driver";
*displayName = sDisplayName;
return 0;
}
static short CLT_GetPanelList(const CWPanelList **panelList) {
static const char *sPanelNames[4];
static CWPanelList sPanelList = {
kCurrentCWPanelListVersion,
4,
sPanelNames
};
sPanelNames[0] = "CmdLine Panel";
if (clState.plugintype == CWDROPINCOMPILERTYPE) {
sPanelNames[1] = "CmdLine Compiler Panel";
sPanelNames[2] = "CmdLine Linker Panel";
sPanelList.count = 3;
} else {
sPanelNames[1] = "CmdLine Linker Panel";
sPanelList.count = 2;
}
*panelList = &sPanelList;
return 0;
}
static short CLT_GetTargetList(const CWTargetList **targetList) {
static CWDataType sCPU = CWFOURCHAR('*','*','*','*');
static CWDataType sOS = CWFOURCHAR('*','*','*','*');
static CWTargetList sTargetList = {
kCurrentCWTargetListVersion,
1,
&sCPU,
1,
&sOS
};
*targetList = &sTargetList;
return 0;
}
static short CLT_GetVersionInfo(const VersionInfo **versioninfo) {
static const VersionInfo vi = {
3, 0, 0, 0
};
*versioninfo = &vi;
return 0;
}
static short CLT_GetFileTypeMappings(const OSFileTypeMappingList **mappinglist) {
static const OSFileTypeMapping ftmes[2] = {
{CWFOURCHAR('B','r','w','s'), "DubL", 4, 0, 0},
{CWFOURCHAR('M','M','P','r'), "looc", 4, 0, 0}
};
static const OSFileTypeMappingList ftml = {
2,
ftmes
};
*mappinglist = &ftml;
return 0;
}
static BasePluginCallbacks clcb = {
CLT_dummymain,
CLT_GetDropInFlags,
CLT_GetDisplayName,
CLT_GetDropInName,
CLT_GetPanelList,
0,
0,
CLT_GetVersionInfo,
CLT_GetFileTypeMappings
};
static int RegisterStaticCmdLinePlugin() {
return RegisterStaticPlugin(&clcb);
}
// TODO do me later - this comes from CmdLine/Project/Resources/CLErrors.r
const char *STR12000[100];
static int RegisterCmdLineResources() {
return RegisterResource("Command-line strings", 12000, &STR12000);
}
static int special_debug(unsigned char pre, char *) {
if (pre) {
SetupDebuggingTraps();
return 1;
} else {
return 0;
}
}
static int special_plugin_debug(unsigned char pre, char *) {
if (pre) {
clState.pluginDebug = 1;
return 1;
} else {
return clState.pluginDebug;
}
}
static int special_stdout_base(unsigned char pre, char *) {
if (pre) {
return 1;
} else {
return clState.stdoutBase != 0;
}
}
struct SpecialOption {
const char *optname;
char **argp;
int (*func)(unsigned char a, char *b);
};
static struct SpecialOption special_options[3] = {
{"", 0, special_debug},
{"--plugin-debug", 0, special_plugin_debug},
{"--stdout", /*TODO clState*/ 0, special_stdout_base}
};
void Main_PreParse(int *pArgc, char ***pArgv) {
struct SpecialOption *so;
int idx;
if (*pArgc > 1) {
restart:
for (idx = 0, so = &special_options[0]; idx < 3; idx++, so++) {
if (!strcmp(so->optname, (*pArgv)[1])) {
if (so->argp) {
*so->argp = (*pArgv)[2];
so->func(1, *so->argp);
(*pArgv)[1] = (*pArgv)[0];
(*pArgc)--;
(*pArgv)++;
(*pArgv)[1] = (*pArgv)[0];
(*pArgc)--;
(*pArgv)++;
} else {
so->func(1, 0);
(*pArgv)[1] = (*pArgv)[0];
(*pArgc)--;
(*pArgv)++;
}
break;
}
}
if ((*pArgc) > 1 && idx < 3)
goto restart;
}
}
void Main_PassSpecialArgs(void *unk1, void *unk2) {
struct SpecialOption *so;
int idx;
for (idx = 0; idx < 3; idx++) {
so = &special_options[idx];
if (so->func(0, 0)) {
AppendArgumentList(unk1, unk2, so->optname);
if (so->argp)
AppendArgumentList(unk1, unk2, (*so->argp) ? *so->argp : "");
}
}
}
static int MainInitialized;
void *gProj;
PCmdLine optsCmdLine;
PCmdLineEnvir optsEnvir;
PCmdLineCompiler optsCompiler;
PCmdLineLinker optsLinker;
int Main_Initialize(int argc, const char **argv) {
static char secret[8];
char exename[256];
OS_InitProgram(&argc, &argv);
memset(&clState, 0, sizeof(CLState));
special_options[0].optname = secret;
secret[7] = 0;
secret[4] = 'b';
secret[1] = '-';
secret[5] = 'u';
secret[2] = 'd';
secret[0] = '-';
secret[3] = 'e';
secret[6] = 'g';
Main_PreParse(&argc, &argv);
clState.argc = argc;
clState.argv = argv;
// TODO more shite
MainInitialized = 1;
return 0;
}
int Main_Terminate(int exitcode) {
if (MainInitialized) {
Plugins_Term();
License_Terminate();
Proj_Terminate(gProj);
IO_Terminate();
MainInitialized = 0;
}
return exitcode;
}
static int Main_ParseCommandLine() {
// TODO: clState, Plugins, gTarg, ...
long vislang;
int x, y;
CWCommandLineArgs myargs;
}
static int Main_SetupParamBlock() {
// TODO: OS, PrefPanes, clState, ...
PrefPanelsChangedCallback(0);
}
static int Main_ResolveProject() {
// TODO: Various project things
int err;
long startTime, endTime;
}
static int UpdatePCmdLineFromVersion(const PCmdLine *given, PCmdLine *target) {
static unsigned char warned;
short version = given->version;
*target = *given;
// TODO: clState
return 0;
}
static int UpdatePCmdLineEnvirFromVersion(const PCmdLineEnvir *given, PCmdLineEnvir *target) {
static unsigned char warned;
short version = given->version;
*target = *given;
// TODO: clState
return 0;
}
static int UpdatePCmdLineCompilerFromVersion(const PCmdLineCompiler *given, PCmdLineCompiler *target) {
static unsigned char warned;
short version = given->version;
*target = *given;
// TODO: clState
return 0;
}
static int UpdatePCmdLineLinkerFromVersion(const PCmdLineLinker *given, PCmdLineLinker *target) {
static unsigned char warned;
short version = given->version;
*target = *given;
// TODO: clState
return 0;
}
static int UpdatePrefPanels(const char *name) {
PrefPanel *panel;
Handle h;
if (!name || !ustrcmp(name, "CmdLine Panel")) {
if ((panel = Prefs_FindPanel("CmdLine Panel")) && (h = PrefPanel_GetHandle(panel))) {
if (name) {
if (!UpdatePCmdLineFromVersion((PCmdLine *) *h, &optsCmdLine))
return 0;
}
} else {
CLReportError(91, "CmdLine Panel");
return 0;
}
}
if (!name || !ustrcmp(name, "CmdLine Environment")) {
if ((panel = Prefs_FindPanel("CmdLine Environment")) && (h = PrefPanel_GetHandle(panel))) {
if (name) {
if (!UpdatePCmdLineEnvirFromVersion((PCmdLineEnvir *) *h, &optsEnvir))
return 0;
}
} else {
CLReportError(91, "CmdLine Environment");
return 0;
}
}
if (!name || !ustrcmp(name, "CmdLine Compiler Panel")) {
if ((panel = Prefs_FindPanel("CmdLine Compiler Panel")) && (h = PrefPanel_GetHandle(panel))) {
if (name) {
if (!UpdatePCmdLineCompilerFromVersion((PCmdLineCompiler *) *h, &optsCompiler))
return 0;
}
} else {
CLReportError(91, "CmdLine Compiler Panel");
return 0;
}
}
if (!name || !ustrcmp(name, "CmdLine Linker Panel")) {
if ((panel = Prefs_FindPanel("CmdLine Linker Panel")) && (h = PrefPanel_GetHandle(panel))) {
if (name) {
if (!UpdatePCmdLineLinkerFromVersion((PCmdLineLinker *) *h, &optsLinker))
return 0;
}
} else {
CLReportError(91, "CmdLine Linker Panel");
return 0;
}
}
return 1;
}
static int SetupCmdLinePrefPanels() {
int ret;
PrefPanelsChangedCallback = UpdatePrefPanels;
ret = Prefs_AddPanel(
PrefPanel_New("CmdLine Environment", &optsEnvir, sizeof(PCmdLineEnvir))
);
ret |= (
Prefs_AddPanel(PrefPanel_New("CmdLine Panel", 0, sizeof(PCmdLine)))
&& Prefs_AddPanel(PrefPanel_New("CmdLine Compiler Panel", 0, sizeof(PCmdLineCompiler)))
&& Prefs_AddPanel(PrefPanel_New("CmdLine Linker Panel", 0, sizeof(PCmdLineLinker)))
);
return ret;
}
static int Main_SetupContext() {
// TODO Target, Plugins, clState
return 1;
}
jmp_buf exit_program;
int Main_Driver() {
volatile int result;
result = setjmp(exit_program);
if (!result) {
if (!SetupCmdLinePrefPanels())
CLFatalError("Could not initialize preferences");
Main_SetupContext();
if (!(result = Main_ParseCommandLine())) {
if (!(result = Main_SetupParamBlock()))
result = Main_ResolveProject();
}
} else {
result = 1;
}
return result;
}

View File

View File

View File

View File

View File

@ -0,0 +1,27 @@
/**
P 1F458 | _UCBCachePrecompiledHeader
P 1F4F8 | _UCBLoadObjectData
P 1F5BC | _UCBStoreObjectData
P 1F860 | _UCBFreeObjectData
P 1F90C | _UCBDisplayLines
P 1F980 | _UCBBeginSubCompile
P 1F9F0 | _UCBEndSubCompile
P 1FA60 | _UCBGetPrecompiledHeaderSpec
P 1FD38 | _UCBGetResourceFile
P 1FDA8 | _UCBPutResourceFile
1FE18 | _UnitNameToSBMName__FP6OSSpecP4File
P 1FEA0 | _UCBLookUpUnit
P 20544 | _UCBSBMfiles
P 20594 | _UCBStoreUnit
P 20848 | _UCBReleaseUnit
P 208C8 | _UCBUnitNameToFileName
P 20978 | _UCBOSAlert
P 20A50 | _UCBOSErrorMessage
P 20B38 | _UCBGetModifiedFiles
P 20BBC | _UCBGetSuggestedObjectFileSpec
P 20C78 | _UCBGetStoredObjectFileSpec
P 20D4C | _UCBGetFrameworkCount
P 20DB0 | _UCBGetFrameworkInfo
P 20E48 | ___ct__23CWCompilerLinkerContextFv
P 20FEC | ___dt__23CWCompilerLinkerContextFv
*/

View File

@ -0,0 +1,48 @@
/*
1B9C8 | _ANSI_To_Mac_GMT_Time__FlPUl
1BA88 | _Mac_To_ANSI_Time__FUlPl
P 1BCA4 | _UCBGetFileInfo
1BEA8 | _FindAndLoad_VirtualFile__FP22CWPluginPrivateContextPCcP10CWFileInfoP6OSSpecPUc
1BF98 | _FindAndLoad_AccessPathFile__FP22CWPluginPrivateContextPCcP10CWFileInfoP6OSSpecPUc
1C108 | _FindAndLoad_MissingFile__FP22CWPluginPrivateContextPCcP10CWFileInfoP6OSSpecPUc
P 1C278 | _UCBFindAndLoadFile
P 1C50C | _UCBGetFileText
P 1C6BC | _UCBReleaseFileText
P 1C754 | _UCBGetSegmentInfo
P 1C814 | _UCBGetOverlay1GroupInfo
P 1C8F0 | _UCBGetOverlay1FileInfo
P 1C9A0 | _UCBGetOverlay1Info
P 1CA74 | _UCBReportMessage
P 1CCDC | _UCBAlert
P 1CEB4 | _UCBShowStatus
P 1D00C | _UCBUserBreak
P 1D078 | _UCBGetNamedPreferences
P 1D13C | _UCBStorePluginData
P 1D1AC | _UCBGetPluginData
P 1D21C | _UCBSetModDate
P 1D35C | _UCBAddProjectEntry
P 1DB20 | _UCBCreateNewTextDocument
P 1DE74 | _UCBAllocateMemory
P 1DF00 | _UCBFreeMemory
P 1DF74 | _UCBAllocMemHandle
P 1E00C | _UCBFreeMemHandle
P 1E08C | _UCBGetMemHandleSize
P 1E11C | _UCBResizeMemHandle
P 1E1C0 | _UCBLockMemHandle
P 1E238 | _UCBUnlockMemHandle
P 1E29C | _UCBGetTargetName
P 1E320 | _UCBPreDialog
P 1E370 | _UCBPostDialog
P 1E3C0 | _UCBPreFileAction
P 1E430 | _UCBPostFileAction
P 1E4A0 | _UCBCacheAccessPathList
P 1E7A8 | _UCBSecretAttachHandle
P 1E814 | _UCBSecretDetachHandle
P 1E8A0 | _UCBSecretPeekHandle
P 1E92C | _UCBCheckoutLicense
P 1E998 | _UCBCheckinLicense
P 1E9E8 | _UCBResolveRelativePath
P 1EA28 | _UCBMacOSErrToCWResult
P 1EA88 | ___ct__22CWPluginPrivateContextFll
P 1EB10 | ___dt__22CWPluginPrivateContextFv
*/

View File

@ -0,0 +1,13 @@
/*
P 9C50 | _UCBParserAddAccessPath
P 9DE4 | _UCBParserSwapAccessPaths
P 9E90 | _UCBParserSetNamedPreferences
P 9F50 | _UCBParserSetFileOutputName
P A03C | _UCBParserSetOutputFileDirectory
P A110 | _UCBParserAddOverlay1Group
P A1EC | _UCBParserAddOverlay1
P A2D0 | _UCBParserAddSegment
P A364 | _UCBParserSetSegment
P A400 | ___ct__15CWParserContextFv
P A480 | ___dt__15CWParserContextFv
*/

View File

@ -0,0 +1,45 @@
#include "mwcc_decomp.h"
int main(int argc, const char **argv) {
OSType cpu;
OSType os;
OSType lang;
OSType type;
OSType style;
int ret;
if (CmdLine_Initialize(argc, argv, CMDLINE_BUILD_DATE, CMDLINE_BUILD_TIME))
exit(1);
if (!RegisterStaticParserResources() || !RegisterStaticTargetResources()) {
fprintf(stderr, "\nFATAL ERROR: Could not initialize resource strings\n");
exit(1);
}
if (!RegisterStaticParserPlugins() || !RegisterStaticTargetPlugins()) {
fprintf(stderr, "\nFATAL ERROR: Could not initialize built-in plugins\n");
exit(1);
}
if (!RegisterStaticParserToolInfo()) {
fprintf(stderr, "\nFATAL ERROR: Could not initialize options\n");
exit(1);
}
GetStaticTarget(&cpu, &os);
SetBuildTarget(cpu, os);
GetStaticPluginType(&lang, &type);
SetPluginType(lang, type);
GetStaticParserPluginType(&style);
SetParserType(style);
ret = CmdLine_Driver();
if (ret) {
if (ret == 2)
fprintf(stderr, "\nUser break, cancelled...\n");
else
fprintf(stderr, "\nErrors caused tool to abort.\n");
}
CmdLine_Terminate(ret);
return ret;
}

View File

@ -0,0 +1,57 @@
#include "mwcc_decomp.h"
int RegisterResource(const char *name, SInt16 rsrcid, Handle list) {
Handle h;
if (list == 0) {
h = GetResource('STR#', rsrcid);
if (h == 0) {
CLFatalError("Resource ('STR#',%d) '%s' not found in executable\n", rsrcid, name);
return 0;
}
ReleaseResource(h);
return 1;
} else {
return Res_AddResource(name, rsrcid, list);
}
}
int RegisterStaticPlugin(const BasePluginCallbacks *callbacks) {
return Plugins_Add(Plugin_New(callbacks, 0, 0));
}
int RegisterStaticCompilerLinkerPlugin(const BasePluginCallbacks *callbacks, const CompilerLinkerPluginCallbacks *cl_callbacks) {
return Plugins_Add(Plugin_New(callbacks, cl_callbacks, 0));
}
int RegisterStaticParserPlugin(const BasePluginCallbacks *callbacks, const ParserPluginCallbacks *pr_callbacks) {
return Plugins_Add(Plugin_New(callbacks, 0, pr_callbacks));
}
void SetBuildTarget(OSType cpu, OSType os) {
clState.cpu = cpu;
clState.os = os;
}
void SetParserType(OSType plang) {
clState.parserstyle = plang;
}
void SetPluginType(OSType lang, OSType type) {
clState.language = lang;
clState.plugintype = type;
}
int CmdLine_Initialize(int argc, const char **argv, const char *builddate, const char *buildtime) {
strncpy(cmdline_build_date, builddate, sizeof(cmdline_build_date));
strncpy(cmdline_build_time, buildtime, sizeof(cmdline_build_time));
return Main_Initialize(argc, argv);
}
int CmdLine_Driver() {
return Main_Driver();
}
int CmdLine_Terminate(int exitcode) {
return Main_Terminate(exitcode);
}

View File

@ -0,0 +1,37 @@
#include "mwcc_decomp.h"
static void CLGetErrorString(SInt16 errid, char *buffer) {
}
static void CLMessageReporter(int flags, SInt16 errid, va_list va) {
}
void CLReportError(SInt16 errid, ...) {
}
void CLReportWarning(SInt16 errid, ...) {
}
void CLReport(SInt16 errid, ...) {
}
void CLReportOSError(SInt16 errid, int err, ...) {
}
void CLReportCError(SInt16 errid, int err_no, ...) {
}
void CLInternalError(const char *file, int line, const char *format, ...) {
}
void CLFatalError(const char *format, ...) {
}

View File

@ -0,0 +1,170 @@
#include "mwcc_decomp.h"
static void catchinterrupt() {
}
static void SetupConsoleInfo() {
}
static void Crash() {
}
void SetupDebuggingTraps() {
}
Boolean IO_Initialize() {
}
Boolean IO_Terminate() {
}
Boolean IO_HelpInitialize() {
}
Boolean IO_HelpTerminate() {
}
static Boolean SendHandleToFile(FILE *file, OSHandle *text) {
}
void FixHandleForIDE(OSHandle *text) {
}
Boolean ShowHandle(OSHandle *text, Boolean decorate) {
}
Boolean WriteHandleToFile(OSSpec *spec, OSHandle *text, CWDataType creator, CWDataType type) {
}
Boolean WriteBinaryHandleToFile(OSSpec *spec, CWDataType maccreator, CWDataType mactype, OSHandle *text) {
}
Boolean AppendHandleToFile(OSSpec *spec, OSHandle *text, CWDataType maccreator, CWDataType mactype) {
}
void InitWorking() {
}
void ShowWorking() {
}
void TermWorking() {
}
static void ProgressFunction(const char *functionname) {
}
Boolean CheckForUserBreak() {
}
typedef struct {
char *buffer;
int pos;
int maxlen;
SInt16 col;
Boolean origina;
char *newline;
} UnkCLIOStruct;
static void StartLine(UnkCLIOStruct *f) {
}
static void WrapText(UnkCLIOStruct *f) {
}
static char *IO_VFormatText(char *buffer, SInt32 size, char *newline, const char *format, va_list ap) {
}
char *IO_FormatText(char *buffer, SInt32 size, char *newline, const char *format, ...) {
}
void CLPrintDispatch(SInt16 msgtype, const char *message, FILE *out, char *ptr, char *nptr) {
}
static void GetFileInfo(MessageRef *ref) {
}
static char *Arrows(MessageRef *ref) {
}
static Boolean IsLikelyAnImporter(Plugin *plugin) {
}
static char *GuessTool(Plugin *plugin) {
}
static char *GuessDoing(Plugin *plugin) {
}
static void styledMessage_MPW(Plugin *plugin, MessageRef *ref, SInt16 msgType, const char *format, va_list va) {
}
static void styledMessage_Default(Plugin *plugin, MessageRef *ref, SInt16 msgType, const char *format, va_list va) {
}
static void styledMessage_Terse(Plugin *plugin, MessageRef *ref, SInt16 msgType, const char *format, va_list va) {
}
static void styledMessage_IDE(Plugin *plugin, MessageRef *ref, SInt16 msgType, const char *format, va_list va) {
}
static void styledMessage_Parseable(Plugin *plugin, MessageRef *ref, SInt16 msgType, const char *format, va_list va) {
}
void CLPrintType(SInt16 msgtype, ...) {
}
void CLPrint(SInt16 msgtype, ...) {
}
void CLPrintWarning(SInt16 msgtype, ...) {
}
void CLPrintErr(SInt16 msgtype, ...) {
}
static void FixupMessageRef(MessageRef *ref) {
}
SInt16 CLStyledMessageDispatch(Plugin *plugin, MessageRef *ref, SInt32 errorNumber, SInt16 msgType) {
}

View File

@ -0,0 +1,54 @@
#include "mwcc_decomp.h"
static const char *getsyserr(SInt16 msgNbr) {
switch (msgNbr) {
case 0: return "No error";
case -27: return "I/O call aborted by KillIO";
case -34: return "Disk full";
case -35: return "No such volume";
case -36: return "Input/output error";
case -37: return "Some component of filename is too long";
case -39: return "End-of-file error";
case -40: return "Tried to position before EOF";
case -42: return "Too many files open";
case -43: return "File or directory not found";
case -48: return "Filename already exists on rename or create";
case -50: return "Error in user parameter list";
case -51: return "Bad reference number";
case -52: return "Get file position error";
case -54: return "Invalid file access or invalid permissions";
case -61: return "Write permissions error";
case -108: return "Null or invalid address detected";
case -109: return "invalid handle detected";
case -113: return "Directory not found";
case -120: return "User cancelled";
case -192: return "Resource not found";
case -1302: return "Not a file";
case -1309: return "Seek position exceeds boundaries for filesystem";
case -1310: return "File size too big for filesystem";
case -188: return "Resource already in memory";
case -189: return "Writing past end of file";
case -190: return "Offset of Count out of bounds";
case -193: return "Resource file not found";
case -194: return "Could not add resource";
case -195: return "Could not add reference";
case -196: return "Could not remove resource";
case -197: return "Could not remove reference";
case -198: return "Resource attribute inconsistent with operation";
case -199: return "Resource map corrupted or inconsistent with operation";
case -32767: return "Feature not supported";
default: return 0;
}
}
char *GetSysErrText(SInt16 msgNbr, char *errMsg) {
const char *txt;
txt = getsyserr(msgNbr);
if (!txt)
sprintf(errMsg, "Operating system error %ld", msgNbr & 0x7FFF);
else
strcpy(errMsg, txt);
return errMsg;
}

View File

@ -0,0 +1,149 @@
#include "mwcc_decomp.h"
typedef struct MacFileInfo {
UInt32 ioFlCrDat;
UInt32 ioFlMdDat;
SInt32 ioFlLgLen;
SInt32 ioFlPyLen;
SInt32 ioFlRLgLen;
SInt32 ioFlRPyLen;
SInt32 ioFlStBlk;
SInt32 ioFlRStBlk;
SInt32 ioFlAttrib;
} MacFileInfo;
static int OS_GetFileParamInfo(const OSSpec *spec, MacFileInfo *mfi, FInfo *fi) {
}
static int OS_SetFileParamInfo(const OSSpec *spec, MacFileInfo *mfi, FInfo *fi) {
}
OSErr HCreate(SInt16 volume, SInt32 dirid, ConstStr255Param fileName, OSType creator, OSType type) {
}
OSErr HOpen(SInt16 vRefNum, SInt32 dirID, ConstStr255Param fileName, SInt8 permission, SInt16 *refNum) {
}
OSErr HOpenDF(SInt16 vRefNum, SInt32 dirID, ConstStr255Param fileName, SInt8 permission, SInt16 *refNum) {
}
OSErr HDelete(SInt16 vRefNum, SInt32 dirID, ConstStr255Param fileName) {
}
OSErr HRename(SInt16 vRefNum, SInt32 dirID, ConstStr255Param oldName, ConstStr255Param newName) {
}
OSErr HGetFInfo(SInt16 vRefNum, SInt32 dirID, ConstStr255Param fileName, FInfo *fndrInfo) {
}
OSErr HSetFInfo(SInt16 vRefNum, SInt32 dirID, ConstStr255Param fileName, const FInfo *fndrInfo) {
}
OSErr FSpCreate(const FSSpec *fss, OSType creator, OSType fileType, ScriptCode scriptTag) {
}
OSErr FSpDirCreate(const FSSpec *fss, ScriptCode scriptTag, SInt32 *createdDirID) {
}
OSErr FSpOpenDF(const FSSpec *fss, SInt8 permission, SInt16 *refNum) {
}
OSErr FSpDelete(const FSSpec *fss) {
}
OSErr FSpRename(const FSSpec *oldfss, ConstStr255Param newName) {
}
OSErr FSpGetFInfo(const FSSpec *fss, FInfo *fndrInfo) {
}
OSErr FSpSetFInfo(const FSSpec *fss, const FInfo *fndrInfo) {
}
OSErr HGetVol(StringPtr volName, SInt16 *vRefNum, SInt32 *dirID) {
}
OSErr HSetVol(ConstStr63Param volName, SInt16 vRefNum, SInt32 dirID) {
}
OSErr FlushVol(ConstStr63Param volName, SInt16 vRefNum) {
}
OSErr FSRead(SInt16 fRefNum, SInt32 *Size, void *Buffer) {
}
OSErr FSWrite(SInt16 fRefNum, SInt32 *Size, const void *Buffer) {
}
OSErr FSClose(SInt16 fRefNum) {
}
OSErr GetEOF(SInt16 fRefNum, SInt32 *curEOF) {
}
OSErr SetEOF(SInt16 fRefNum, SInt32 newEOF) {
}
OSErr GetFPos(SInt16 fRefNum, SInt32 *pos) {
}
OSErr SetFPos(SInt16 fRefNum, SInt16 posMode, SInt32 posOffset) {
}
OSErr GetVInfo(SInt16 vRefNum, StringPtr name, SInt16 *vRef, SInt32 *hDir) {
}
OSErr PBWriteSync(ParmBlkPtr paramBlock) {
}
OSErr PBHGetFInfoSync(HParmBlkPtr paramBlock) {
}
OSErr PBHSetFInfoSync(HParmBlkPtr paramBlock) {
}
OSErr PBGetCatInfoSync(CInfoPBPtr paramBlock) {
}
OSErr ResolveAliasFile(FSSpec *fss, Boolean resolveChains, Boolean *isFolder, Boolean *wasAliased) {
}
OSErr FSMakeFSSpec(SInt16 vRefNum, SInt32 dirID, ConstStr255Param pathName, FSSpec *fss) {
}
OSErr Allocate(SInt16 refNum, SInt32 *byteCount) {
}

View File

@ -0,0 +1,20 @@
#include "mwcc_decomp.h"
static OSErr memErr;
UInt32 LMGetTicks() {
return (OS_GetMilliseconds() * 60) / 1000;
}
UInt32 LMGetTime() {
return OS_GetMilliseconds() / 1000;
}
OSErr LMGetMemErr() {
return memErr;
}
void LMSetMemErr(OSErr value) {
memErr = value;
}

View File

@ -0,0 +1,266 @@
#include "mwcc_decomp.h"
static OSErr memError;
typedef struct HandleStructure {
char *addr;
OSHandle hand;
} HandleStructure;
#define HS(h) ((HandleStructure *) (h))
OSHandle *OS_PeekMacHandle(Handle h) {
return &HS(h)->hand;
}
static void FixHandlePtr(Handle h, void *ptr) {
HS(h)->hand.addr = ptr;
}
Handle OS_CreateMacHandle(OSHandle *h) {
HandleStructure *hs = malloc(sizeof(HandleStructure));
if (!hs) {
memError = -108;
return 0;
};
hs->hand = *h;
OS_InvalidateHandle(h);
hs->addr = OS_LockHandle(&hs->hand);
OS_UnlockHandle(&hs->hand);
return (Handle) hs;
}
Handle OS_CreateMacHandleDup(OSHandle *h) {
HandleStructure *hs = malloc(sizeof(HandleStructure));
if (!hs) {
memError = -108;
return 0;
};
hs->hand = *h;
hs->addr = OS_LockHandle(&hs->hand);
OS_UnlockHandle(&hs->hand);
return (Handle) hs;
}
void OS_DestroyMacHandle(Handle h, OSHandle *ret) {
*ret = HS(h)->hand;
free(h);
}
OSErr MemError() {
return memError;
}
Handle NewHandle(SInt32 dataSize) {
int err;
OSHandle oh;
err = OS_NewHandle(dataSize, &oh);
if (err) {
memError = OS_MacError(err);
return 0;
}
return OS_CreateMacHandle(&oh);
}
Handle NewHandleClear(UInt32 dataSize) {
Handle hdl = NewHandle(dataSize);
if (hdl) {
HLock(hdl);
if (*hdl)
memset(*hdl, 0, dataSize);
HUnlock(hdl);
}
return hdl;
}
Handle TempNewHandle(UInt32 dataSize, OSErr *resultCode) {
*resultCode = 0;
Handle hdl = NewHandle(dataSize);
if (!hdl)
*resultCode = memError;
return hdl;
}
void DisposeHandle(Handle h) {
if (h) {
memError = OS_MacError(OS_FreeHandle(&HS(h)->hand));
FixHandlePtr(h, 0);
} else {
memError = -109;
}
}
void HLock(Handle h) {
void *buffer;
if (h) {
buffer = OS_LockHandle(&HS(h)->hand);
FixHandlePtr(h, buffer);
memError = 0;
} else {
memError = -109;
}
}
void HLockHi(Handle h) {
HLock(h);
}
void HUnlock(Handle h) {
if (h) {
memError = 0;
OS_UnlockHandle(&HS(h)->hand);
} else {
memError = -109;
}
}
void HPurge(Handle theHandle) {
memError = 0;
}
void HNoPurge(Handle theHandle) {
memError = 0;
}
SInt8 HGetState(Handle theHandle) {
memError = 0;
return 0;
}
void HSetState(Handle theHandle, SInt8 flags) {
memError = 0;
}
SInt32 GetHandleSize(Handle h) {
UInt32 sz;
if (h) {
memError = OS_MacError(OS_GetHandleSize(&HS(h)->hand, &sz));
} else {
sz = 0;
memError = -109;
}
return sz;
}
void SetHandleSize(Handle h, SInt32 newSize) {
memError = OS_MacError(OS_ResizeHandle(&HS(h)->hand, newSize));
FixHandlePtr(h, OS_LockHandle(&HS(h)->hand));
OS_UnlockHandle(&HS(h)->hand);
}
OSErr PtrAndHand(const void *srcPtr, Handle destHandle, SInt32 size) {
OSErr err;
err = OS_MacError(OS_AppendHandle(&HS(destHandle)->hand, srcPtr, size));
FixHandlePtr(h, OS_LockHandle(&HS(destHandle)->hand));
OS_UnlockHandle(&HS(h)->hand);
return err;
}
OSErr PtrToHand(const void *srcPtr, Handle *destHandle, SInt32 size) {
*destHandle = NewHandle(size);
if (!*destHandle)
return MemError();
HLock(*destHandle);
memcpy(**destHandle, srcPtr, size);
HUnlock(*destHandle);
return MemError();
}
OSErr HandToHand(Handle *destHandle) {
Handle srcHandle = *destHandle;
SInt32 size;
size = GetHandleSize(srcHandle);
*destHandle = NewHandle(size);
if (!*destHandle)
return MemError();
HLock(*destHandle);
HLock(srcHandle);
memcpy(**destHandle, *srcHandle, size);
HUnlock(srcHandle);
HUnlock(*destHandle);
return MemError();
}
OSErr HandAndHand(Handle src, Handle dst) {
OSErr err;
SInt32 size;
HLock(src);
size = GetHandleSize(src);
err = PtrAndHand(*src, dst, size);
HUnlock(src);
return err;
}
void MoveHHi(Handle theHandle) {
memError = theHandle ? 0 : -109;
}
void BlockMove(const void *srcPtr, void *destPtr, UInt32 byteCount) {
memmove(destPtr, srcPtr, byteCount);
}
void BlockMoveData(const void *srcPtr, void *destPtr, UInt32 byteCount) {
memmove(destPtr, srcPtr, byteCount);
}
Ptr NewPtr(SInt32 dataSize) {
Ptr p;
if (!dataSize)
dataSize = 1;
p = malloc(dataSize);
memError = p ? 0 : -108;
return p;
}
void DisposePtr(Ptr p) {
memError = 0;
if (p)
free(p);
}
Ptr NewPtrClear(SInt32 dataSize) {
Ptr p;
memError = -108;
if (!dataSize)
dataSize = 1;
p = malloc(dataSize);
if (p) {
memError = 0;
memset(p, 0, dataSize);
}
return p;
}
void DebugStr(ConstStringPtr str) {
fprintf(stderr, "*.*s", str[0], str[1], &str[1]);
}
struct Zone *HandleZone() {
return 0;
}
struct Zone *ApplicationZone() {
return 0;
}

View File

@ -0,0 +1,68 @@
#include "mwcc_decomp.h"
typedef struct {
const char *name;
SInt16 rsrcid;
const char **strings;
} Res;
static Res rlist[16];
void Res_Initialize() {
memset(rlist, 0, sizeof(rlist));
}
int Res_AddResource(const char *name, SInt16 rsrcid, const char **strings) {
int scan;
for (scan = 0; scan < 16 && rlist[scan].rsrcid; scan++) {
if (rsrcid == rlist[scan].rsrcid) {
fprintf(stderr, "Resource %d is already added!\n", rsrcid);
return 0;
}
}
if (scan >= 16)
return 0;
rlist[scan].name = name;
rlist[scan].rsrcid = rsrcid;
rlist[scan].strings = strings;
return 1;
}
enum { MaxRes = 16 };
const char *Res_GetResource(SInt16 rsrcid, SInt16 index) {
// Does not match, absolutely hopeless
int scan, find;
static char err[256];
scan = 0;
do {
if (rsrcid == rlist[scan].rsrcid) {
find = 0;
if ((SInt16) (index - 1) < 0) {
snprintf(err, sizeof(err), "[Illegal string index #%d in list '%s' (%d)]", (SInt16) (index - 1), rlist[scan].name, rsrcid);
return err;
}
while (find <= (index - 1)) {
if (!rlist[scan].strings[find]) {
snprintf(err, sizeof(err), "[String #%d not found in resource '%s' (%d)]", (SInt16) (index - 1), rlist[scan].name, rsrcid);
return err;
}
if (find == (index - 1)) {
return rlist[scan].strings[find];
} else {
find++;
}
}
}
} while (scan++ < MaxRes);
return 0;
}
void Res_Cleanup() {
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,132 @@
#include "mwcc_decomp.h"
StringPtr c2pstr(char *s) {
unsigned int l;
l = strlen(s);
if (l > 255)
l = 255;
memmove(s + 1, s, l);
s[0] = l;
return (StringPtr) s;
}
char *p2cstr(StringPtr s) {
unsigned int l;
l = s[0];
memmove(s, s + 1, l);
s[l] = 0;
return (char *) s;
}
SInt16 CharacterByteType(Ptr textBuf, SInt16 textOffset, ScriptCode script) {
return 0;
}
SInt16 CharByte() {
return 0;
}
void GetDateTime(UInt32 *secs) {
time_t time;
OS_GetTime(&time);
OS_TimeToMac(time, secs);
}
Boolean EqualString(ConstStr255Param strA, ConstStr255Param strB, Boolean caseSens, Boolean diacSens) {
int i, length;
Boolean equal;
equal = 0;
length = strA[0];
if (strA && strB && length == strB[0]) {
if (caseSens) {
equal = !memcmp(strA + 1, strB + 1, length);
} else {
equal = 1;
i = 0;
while (equal && i < length) {
equal = toupper(strA[i]) == toupper(strB[i]);
++i;
}
}
}
return equal;
}
void GetIndString(Str255 theString, SInt16 strListID, SInt16 index) {
SInt16 last;
SInt16 idc;
SInt32 len;
Handle strs;
const char *ret;
StringPtr ptr;
StringPtr dptr;
Str255 tmp;
ret = Res_GetResource(strListID, index);
if (ret) {
strcpy((char *) tmp, ret);
c2pstr((char *) tmp);
} else {
sprintf((char *) tmp, "[Resource string id=%d index=%d not found]", strListID, index);
c2pstr((char *) tmp);
strs = GetResource('STR#', strListID);
if (strs) {
last = (((unsigned char) (*strs)[0]) << 8) + ((unsigned char) (*strs)[1]);
if (index > 0 && index <= last) {
len = GetHandleSize(strs);
HLock(strs);
ptr = (StringPtr) (*strs + 2);
idc = index;
dptr = (StringPtr) (*strs + len);
while (ptr < dptr && --idc) {
ptr += *ptr + 1;
}
if (ptr < dptr)
_pstrcpy(tmp, ptr);
HUnlock(strs);
}
}
}
ptr = &tmp[1];
dptr = &theString[1];
while (ptr <= &tmp[tmp[0]]) {
if (*ptr == 0xD4) {
*dptr = '`';
} else if (*ptr == 0xD5) {
*dptr = '\'';
} else if (*ptr == 0xD2 || *ptr == 0xD3) {
*dptr = '"';
} else if (*ptr == 0xC9 && (dptr - theString) < 253) {
dptr[0] = '.';
dptr[1] = '.';
dptr[2] = '.';
dptr += 2;
} else {
*dptr = *ptr;
}
++ptr;
++dptr;
}
theString[0] = (dptr - theString) - 1;
}
char *getindstring(char *theString, SInt16 strListID, SInt16 index) {
GetIndString((StringPtr) theString, strListID, index);
return p2cstr((StringPtr) theString);
}
void NumToString(SInt32 theNum, Str255 theString) {
sprintf((char *) theString, "%d", theNum);
c2pstr((char *) theString);
}
void StringToNum(ConstStr255Param theString, SInt32 *theNum) {
p2cstr((StringPtr) theString);
sscanf((char *) theString, "%d", theNum);
c2pstr((char *) theString);
}

View File

View File

2404
includes/mwcc_decomp.h Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,3 @@
#export MWCIncludes=/Applications/Metrowerks\ CodeWarrior\ 7.0/Metrowerks\ CodeWarrior/MacOS\ Support/Universal/Interfaces/CIncludes:/Applications/Metrowerks\ CodeWarrior\ 7.0/Metrowerks\ CodeWarrior/MSL/MSL_C/MSL_Common/Include #export MWCIncludes=/Applications/Metrowerks\ CodeWarrior\ 7.0/Metrowerks\ CodeWarrior/MacOS\ Support/Universal/Interfaces/CIncludes:/Applications/Metrowerks\ CodeWarrior\ 7.0/Metrowerks\ CodeWarrior/MSL/MSL_C/MSL_Common/Include
#export MWCIncludes=/usr/include export MWCIncludes=/usr/include
export MWCIncludes=/Applications/Metrowerks\ CodeWarrior\ 7.0/Metrowerks\ CodeWarrior/MacOS\ X\ Support/MacHeaders\ Mach-O #export MWCIncludes=/Applications/Metrowerks\ CodeWarrior\ 7.0/Metrowerks\ CodeWarrior/MacOS\ X\ Support/MacHeaders\ Mach-O