From 26b57fbea1a969ef6405365ff78391e9d3605621 Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Tue, 11 Oct 2022 03:18:42 +0100 Subject: [PATCH] add cmakelists for CLion, tons and tons of reorganisation using new info from the Pro8 compiler --- Arguments.c | 2 +- CMakeLists.txt | 65 + CompilerTools.h | 2 +- Help.c | 4 +- Option.c | 2 +- Parameter.c | 2 +- UCLTMain.c | 128 +- UMain.c | 84 +- command_line/CmdLine/Src/CLBrowser.c | 0 command_line/CmdLine/Src/CLDependencies.c | 0 command_line/CmdLine/Src/CLFileOps.c | 0 command_line/CmdLine/Src/CLIncludeFileCache.c | 0 command_line/CmdLine/Src/CLLicenses.c | 0 command_line/CmdLine/Src/CLLoadAndCache.c | 0 command_line/CmdLine/Src/CLMain.c | 390 +++ command_line/CmdLine/Src/CLPluginAPI.c | 0 command_line/CmdLine/Src/CLPrefs.c | 0 command_line/CmdLine/Src/CLTarg.c | 0 command_line/CmdLine/Src/CLToolExec.c | 0 command_line/CmdLine/Src/CLWriteObjectFile.c | 0 .../Callbacks/CLCompilerLinkerDropin_V10.cpp | 27 + .../Src/Callbacks/CLDropinCallbacks_V10.cpp | 48 + .../Src/Callbacks/CLParserCallbacks_v1.cpp | 13 + .../CmdLine/Src/Clients/CLStaticMain.c | 45 + command_line/CmdLine/Src/Clients/ClientGlue.c | 57 + command_line/CmdLine/Src/Envir/CLErrors.c | 37 + command_line/CmdLine/Src/Envir/CLIO.c | 170 ++ command_line/CmdLine/Src/MacEmul/ErrMgr.c | 54 + command_line/CmdLine/Src/MacEmul/Files.c | 149 + command_line/CmdLine/Src/MacEmul/LowMem.c | 20 + command_line/CmdLine/Src/MacEmul/Memory.c | 266 ++ .../CmdLine/Src/MacEmul/ResourceStrings.c | 68 + command_line/CmdLine/Src/MacEmul/Resources.c | 1230 +++++++++ command_line/CmdLine/Src/MacEmul/TextUtils.c | 132 + command_line/CmdLine/Src/OSLib/FileHandles.c | 0 command_line/CmdLine/Src/OSLib/Generic.c | 0 command_line/CmdLine/Src/OSLib/MacFileTypes.c | 0 command_line/CmdLine/Src/OSLib/MacSpecs.c | 0 command_line/CmdLine/Src/OSLib/MemUtils.c | 0 command_line/CmdLine/Src/OSLib/Posix.c | 0 command_line/CmdLine/Src/OSLib/StringExtras.c | 0 command_line/CmdLine/Src/OSLib/StringUtils.c | 0 command_line/CmdLine/Src/Plugins/CLPlugins.c | 0 .../CmdLine/Src/Project/CLAccessPaths.c | 0 command_line/CmdLine/Src/Project/CLFiles.c | 0 command_line/CmdLine/Src/Project/CLOverlays.c | 0 command_line/CmdLine/Src/Project/CLProj.c | 0 command_line/CmdLine/Src/Project/CLSegs.c | 0 includes/mwcc_decomp.h | 2404 +++++++++++++++++ mwcc_decomp.h | 1879 ------------- setup.sh | 4 +- 51 files changed, 5288 insertions(+), 1994 deletions(-) create mode 100644 CMakeLists.txt create mode 100644 command_line/CmdLine/Src/CLBrowser.c create mode 100644 command_line/CmdLine/Src/CLDependencies.c create mode 100644 command_line/CmdLine/Src/CLFileOps.c create mode 100644 command_line/CmdLine/Src/CLIncludeFileCache.c create mode 100644 command_line/CmdLine/Src/CLLicenses.c create mode 100644 command_line/CmdLine/Src/CLLoadAndCache.c create mode 100644 command_line/CmdLine/Src/CLMain.c create mode 100644 command_line/CmdLine/Src/CLPluginAPI.c create mode 100644 command_line/CmdLine/Src/CLPrefs.c create mode 100644 command_line/CmdLine/Src/CLTarg.c create mode 100644 command_line/CmdLine/Src/CLToolExec.c create mode 100644 command_line/CmdLine/Src/CLWriteObjectFile.c create mode 100644 command_line/CmdLine/Src/Callbacks/CLCompilerLinkerDropin_V10.cpp create mode 100644 command_line/CmdLine/Src/Callbacks/CLDropinCallbacks_V10.cpp create mode 100644 command_line/CmdLine/Src/Callbacks/CLParserCallbacks_v1.cpp create mode 100644 command_line/CmdLine/Src/Clients/CLStaticMain.c create mode 100644 command_line/CmdLine/Src/Clients/ClientGlue.c create mode 100644 command_line/CmdLine/Src/Envir/CLErrors.c create mode 100644 command_line/CmdLine/Src/Envir/CLIO.c create mode 100644 command_line/CmdLine/Src/MacEmul/ErrMgr.c create mode 100644 command_line/CmdLine/Src/MacEmul/Files.c create mode 100644 command_line/CmdLine/Src/MacEmul/LowMem.c create mode 100644 command_line/CmdLine/Src/MacEmul/Memory.c create mode 100644 command_line/CmdLine/Src/MacEmul/ResourceStrings.c create mode 100644 command_line/CmdLine/Src/MacEmul/Resources.c create mode 100644 command_line/CmdLine/Src/MacEmul/TextUtils.c create mode 100644 command_line/CmdLine/Src/OSLib/FileHandles.c create mode 100644 command_line/CmdLine/Src/OSLib/Generic.c create mode 100644 command_line/CmdLine/Src/OSLib/MacFileTypes.c create mode 100644 command_line/CmdLine/Src/OSLib/MacSpecs.c create mode 100644 command_line/CmdLine/Src/OSLib/MemUtils.c create mode 100644 command_line/CmdLine/Src/OSLib/Posix.c create mode 100644 command_line/CmdLine/Src/OSLib/StringExtras.c create mode 100644 command_line/CmdLine/Src/OSLib/StringUtils.c create mode 100644 command_line/CmdLine/Src/Plugins/CLPlugins.c create mode 100644 command_line/CmdLine/Src/Project/CLAccessPaths.c create mode 100644 command_line/CmdLine/Src/Project/CLFiles.c create mode 100644 command_line/CmdLine/Src/Project/CLOverlays.c create mode 100644 command_line/CmdLine/Src/Project/CLProj.c create mode 100644 command_line/CmdLine/Src/Project/CLSegs.c create mode 100644 includes/mwcc_decomp.h delete mode 100644 mwcc_decomp.h diff --git a/Arguments.c b/Arguments.c index 2f66ee9..324965a 100644 --- a/Arguments.c +++ b/Arguments.c @@ -1,4 +1,4 @@ -#include "mwcc_decomp.h" +#include "includes/mwcc_decomp.h" char compat; char *MAINOPTCHAR; diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..55edbe1 --- /dev/null +++ b/CMakeLists.txt @@ -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) diff --git a/CompilerTools.h b/CompilerTools.h index 5c6607e..6f8ceac 100644 --- a/CompilerTools.h +++ b/CompilerTools.h @@ -1,4 +1,4 @@ -#include "mwcc_decomp.h" +#include "includes/mwcc_decomp.h" #pragma once extern void CompilerGetPString(short index, unsigned char *str); diff --git a/Help.c b/Help.c index aab179d..aaa4e9f 100644 --- a/Help.c +++ b/Help.c @@ -1,4 +1,4 @@ -#include "mwcc_decomp.h" +#include "includes/mwcc_decomp.h" typedef struct _Side { short offset; short width; @@ -415,7 +415,7 @@ void Help_Options(struct OptionList *lst, int subprint, const char *keyword) { opts = lst->list; toolflags = 0; - if (Option_ThisTool() == (unsigned int) OTF_TOOL_COMPILER) { + if (Option_ThisTool() == OTF_TOOL_COMPILER) { toolflags |= LISTFLAGS_COMPILER; } else { toolflags |= LISTFLAGS_LINKER; diff --git a/Option.c b/Option.c index 1ff5209..6a93fc0 100644 --- a/Option.c +++ b/Option.c @@ -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) diff --git a/Parameter.c b/Parameter.c index 6566f12..9d6b08e 100644 --- a/Parameter.c +++ b/Parameter.c @@ -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) diff --git a/UCLTMain.c b/UCLTMain.c index 7da89af..22359dc 100644 --- a/UCLTMain.c +++ b/UCLTMain.c @@ -1,6 +1,6 @@ #include "UCWInterface.h" -static short CLT_dummymain() { +static short CLT_dummymain(void *context) { return 0; } @@ -18,9 +18,9 @@ static short CLT_GetDropInFlags(const DropInFlags **flags, long *flagsSize) { return 0; } -static short CLT_GetDropInName(const char **dropInName) { +static short CLT_GetDropInName(const char **dropinName) { static const char *sDropInName = "Command-Line Driver"; - *dropInName = sDropInName; + *dropinName = sDropInName; return 0; } @@ -73,7 +73,7 @@ static short CLT_GetVersionInfo(const VersionInfo **versioninfo) { return 0; } -static short CLT_GetFileTypeMappings(const OSFileTypeMappingList **mappingList) { +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} @@ -82,7 +82,7 @@ static short CLT_GetFileTypeMappings(const OSFileTypeMappingList **mappingList) 2, ftmes }; - *mappingList = &ftml; + *mappinglist = &ftml; return 0; } @@ -102,14 +102,15 @@ static int RegisterStaticCmdLinePlugin() { 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() { return RegisterResource("Command-line strings", 12000, &STR12000); } -static int special_debug(unsigned char flag, char *) { - if (flag) { +static int special_debug(unsigned char pre, char *) { + if (pre) { SetupDebuggingTraps(); return 1; } else { @@ -117,8 +118,8 @@ static int special_debug(unsigned char flag, char *) { } } -static int special_plugin_debug(unsigned char flag, char *) { - if (flag) { +static int special_plugin_debug(unsigned char pre, char *) { + if (pre) { clState.pluginDebug = 1; return 1; } else { @@ -126,8 +127,8 @@ static int special_plugin_debug(unsigned char flag, char *) { } } -static int special_stdout_base(unsigned char flag, char *) { - if (flag) { +static int special_stdout_base(unsigned char pre, char *) { + if (pre) { return 1; } else { return clState.stdoutBase != 0; @@ -135,9 +136,9 @@ static int special_stdout_base(unsigned char flag, char *) { } struct SpecialOption { - const char *name; - char **location; - int (*callback)(unsigned char a, char *b); + const char *optname; + char **argp; + int (*func)(unsigned char a, char *b); }; static struct SpecialOption special_options[3] = { {"", 0, special_debug}, @@ -146,16 +147,16 @@ static struct SpecialOption special_options[3] = { }; void Main_PreParse(int *pArgc, char ***pArgv) { - int i; - struct SpecialOption *opt; + struct SpecialOption *so; + int idx; if (*pArgc > 1) { restart: - for (i = 0, opt = &special_options[0]; i < 3; i++, opt++) { - if (!strcmp(opt->name, (*pArgv)[1])) { - if (opt->location) { - *opt->location = (*pArgv)[2]; - opt->callback(1, *opt->location); + 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)++; @@ -164,7 +165,7 @@ void Main_PreParse(int *pArgc, char ***pArgv) { (*pArgc)--; (*pArgv)++; } else { - opt->callback(1, 0); + so->func(1, 0); (*pArgv)[1] = (*pArgv)[0]; (*pArgc)--; (*pArgv)++; @@ -173,21 +174,21 @@ void Main_PreParse(int *pArgc, char ***pArgv) { } } - if ((*pArgc) > 1 && i < 3) + if ((*pArgc) > 1 && idx < 3) goto restart; } } void Main_PassSpecialArgs(void *unk1, void *unk2) { - int i; - struct SpecialOption *opt; + struct SpecialOption *so; + int idx; - for (i = 0; i < 3; i++) { - opt = &special_options[i]; - if (opt->callback(0, 0)) { - AppendArgumentList(unk1, unk2, opt->name); - if (opt->location) - AppendArgumentList(unk1, unk2, (*opt->location) ? *opt->location : ""); + 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 : ""); } } } @@ -201,11 +202,11 @@ PCmdLineLinker optsLinker; int Main_Initialize(int argc, const char **argv) { static char secret[8]; - char buf[256]; + char exename[256]; OS_InitProgram(&argc, &argv); memset(&clState, 0, sizeof(CLState)); - special_options[0].name = secret; + special_options[0].optname = secret; secret[7] = 0; secret[4] = 'b'; secret[1] = '-'; @@ -224,7 +225,7 @@ int Main_Initialize(int argc, const char **argv) { return 0; } -int Main_Terminate(int code) { +int Main_Terminate(int exitcode) { if (MainInitialized) { Plugins_Term(); License_Terminate(); @@ -232,11 +233,14 @@ int Main_Terminate(int code) { IO_Terminate(); MainInitialized = 0; } - return code; + return exitcode; } static int Main_ParseCommandLine() { // TODO: clState, Plugins, gTarg, ... + long vislang; + int x, y; + CWCommandLineArgs myargs; } static int Main_SetupParamBlock() { @@ -246,39 +250,41 @@ static int Main_SetupParamBlock() { static int Main_ResolveProject() { // 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; - short ver = oldVer->version; - *newVer = *oldVer; + short version = given->version; + *target = *given; // TODO: clState return 0; } -static int UpdatePCmdLineEnvirFromVersion(const PCmdLineEnvir *oldVer, PCmdLineEnvir *newVer) { +static int UpdatePCmdLineEnvirFromVersion(const PCmdLineEnvir *given, PCmdLineEnvir *target) { static unsigned char warned; - short ver = oldVer->version; - *newVer = *oldVer; + short version = given->version; + *target = *given; // TODO: clState return 0; } -static int UpdatePCmdLineCompilerFromVersion(const PCmdLineCompiler *oldVer, PCmdLineCompiler *newVer) { +static int UpdatePCmdLineCompilerFromVersion(const PCmdLineCompiler *given, PCmdLineCompiler *target) { static unsigned char warned; - short ver = oldVer->version; - *newVer = *oldVer; + short version = given->version; + *target = *given; // TODO: clState return 0; } -static int UpdatePCmdLineLinkerFromVersion(const PCmdLineLinker *oldVer, PCmdLineLinker *newVer) { +static int UpdatePCmdLineLinkerFromVersion(const PCmdLineLinker *given, PCmdLineLinker *target) { static unsigned char warned; - short ver = oldVer->version; - *newVer = *oldVer; + short version = given->version; + *target = *given; // TODO: clState return 0; @@ -286,12 +292,12 @@ static int UpdatePCmdLineLinkerFromVersion(const PCmdLineLinker *oldVer, PCmdLin static int UpdatePrefPanels(const char *name) { PrefPanel *panel; - Handle handle; + Handle h; 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 (!UpdatePCmdLineFromVersion((PCmdLine *) *handle, &optsCmdLine)) + if (!UpdatePCmdLineFromVersion((PCmdLine *) *h, &optsCmdLine)) return 0; } } else { @@ -301,9 +307,9 @@ static int UpdatePrefPanels(const char *name) { } 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 (!UpdatePCmdLineEnvirFromVersion((PCmdLineEnvir *) *handle, &optsEnvir)) + if (!UpdatePCmdLineEnvirFromVersion((PCmdLineEnvir *) *h, &optsEnvir)) return 0; } } else { @@ -313,9 +319,9 @@ static int UpdatePrefPanels(const char *name) { } 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 (!UpdatePCmdLineCompilerFromVersion((PCmdLineCompiler *) *handle, &optsCompiler)) + if (!UpdatePCmdLineCompilerFromVersion((PCmdLineCompiler *) *h, &optsCompiler)) return 0; } } else { @@ -325,9 +331,9 @@ static int UpdatePrefPanels(const char *name) { } 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 (!UpdatePCmdLineLinkerFromVersion((PCmdLineLinker *) *handle, &optsLinker)) + if (!UpdatePCmdLineLinkerFromVersion((PCmdLineLinker *) *h, &optsLinker)) return 0; } } else { @@ -340,19 +346,19 @@ static int UpdatePrefPanels(const char *name) { } static int SetupCmdLinePrefPanels() { - int result; + int ret; PrefPanelsChangedCallback = UpdatePrefPanels; - result = Prefs_AddPanel( + ret = Prefs_AddPanel( PrefPanel_New("CmdLine Environment", &optsEnvir, sizeof(PCmdLineEnvir)) ); - result |= ( + 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 result; + return ret; } static int Main_SetupContext() { diff --git a/UMain.c b/UMain.c index 717eee1..752f640 100644 --- a/UMain.c +++ b/UMain.c @@ -1,21 +1,13 @@ -#include "UCWInterface.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]; +#include "includes/mwcc_decomp.h" +// TODO split main off into CLStaticMain.c int main(int argc, const char **argv) { - unsigned long cpu; - unsigned long os; - unsigned long language; - unsigned long plugintype; - unsigned long style; - int result; + CWDataType cpu; + CWDataType os; + CWDataType lang; + CWDataType type; + CWDataType style; + int ret; if (CmdLine_Initialize(argc, argv, CMDLINE_BUILD_DATE, CMDLINE_BUILD_TIME)) exit(1); @@ -37,48 +29,48 @@ int main(int argc, const char **argv) { GetStaticTarget(&cpu, &os); SetBuildTarget(cpu, os); - GetStaticPluginType(&language, &plugintype); - SetPluginType(language, plugintype); + GetStaticPluginType(&lang, &type); + SetPluginType(lang, type); GetStaticParserPluginType(&style); SetParserType(style); - result = CmdLine_Driver(); - if (result) { - if (result == 2) + 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(result); - return result; + CmdLine_Terminate(ret); + return ret; } -int RegisterResource(const char *name, short index, void *data) { - Handle r; +int RegisterResource(const char *name, short rsrcid, Handle list) { + Handle h; if (data == 0) { - r = GetResource('STR#', index); - if (r == 0) { - CLFatalError("Resource ('STR#',%d) '%s' not found in executable\n", index, name); + h = GetResource('STR#', rsrcid); + if (h == 0) { + CLFatalError("Resource ('STR#',%d) '%s' not found in executable\n", rsrcid, name); return 0; } - ReleaseResource(r); + ReleaseResource(h); return 1; } else { - return Res_AddResource(name, index, data); + return Res_AddResource(name, rsrcid, list); } } -int RegisterStaticPlugin(const BasePluginCallbacks *cb) { - return Plugins_Add(Plugin_New(cb, 0, 0)); +int RegisterStaticPlugin(const BasePluginCallbacks *callbacks) { + return Plugins_Add(Plugin_New(callbacks, 0, 0)); } -int RegisterStaticCompilerLinkerPlugin(const BasePluginCallbacks *cb, void *b) { - return Plugins_Add(Plugin_New(cb, b, 0)); +int RegisterStaticCompilerLinkerPlugin(const BasePluginCallbacks *callbacks, const CompilerLinkerPluginCallbacks *cl_callbacks) { + return Plugins_Add(Plugin_New(callbacks, cl_callbacks, 0)); } -int RegisterStaticParserPlugin(const BasePluginCallbacks *cb, void *b) { - return Plugins_Add(Plugin_New(cb, 0, b)); +int RegisterStaticParserPlugin(const BasePluginCallbacks *callbacks, const ParserPluginCallbacks *pr_callbacks) { + return Plugins_Add(Plugin_New(callbacks, 0, pr_callbacks)); } void SetBuildTarget(CWDataType cpu, CWDataType os) { @@ -86,18 +78,18 @@ void SetBuildTarget(CWDataType cpu, CWDataType os) { clState.os = os; } -void SetParserType(CWDataType style) { - clState.style = style; +void SetParserType(CWDataType plang) { + clState.parserstyle = plang; } -void SetPluginType(CWDataType language, CWDataType plugintype) { - clState.language = language; - clState.plugintype = plugintype; +void SetPluginType(CWDataType lang, CWDataType 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)); +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); } @@ -105,6 +97,6 @@ int CmdLine_Driver() { return Main_Driver(); } -int CmdLine_Terminate(int code) { - return Main_Terminate(code); +int CmdLine_Terminate(int exitcode) { + return Main_Terminate(exitcode); } diff --git a/command_line/CmdLine/Src/CLBrowser.c b/command_line/CmdLine/Src/CLBrowser.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/CLDependencies.c b/command_line/CmdLine/Src/CLDependencies.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/CLFileOps.c b/command_line/CmdLine/Src/CLFileOps.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/CLIncludeFileCache.c b/command_line/CmdLine/Src/CLIncludeFileCache.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/CLLicenses.c b/command_line/CmdLine/Src/CLLicenses.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/CLLoadAndCache.c b/command_line/CmdLine/Src/CLLoadAndCache.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/CLMain.c b/command_line/CmdLine/Src/CLMain.c new file mode 100644 index 0000000..c4d782b --- /dev/null +++ b/command_line/CmdLine/Src/CLMain.c @@ -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; +} + diff --git a/command_line/CmdLine/Src/CLPluginAPI.c b/command_line/CmdLine/Src/CLPluginAPI.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/CLPrefs.c b/command_line/CmdLine/Src/CLPrefs.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/CLTarg.c b/command_line/CmdLine/Src/CLTarg.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/CLToolExec.c b/command_line/CmdLine/Src/CLToolExec.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/CLWriteObjectFile.c b/command_line/CmdLine/Src/CLWriteObjectFile.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/Callbacks/CLCompilerLinkerDropin_V10.cpp b/command_line/CmdLine/Src/Callbacks/CLCompilerLinkerDropin_V10.cpp new file mode 100644 index 0000000..5861e94 --- /dev/null +++ b/command_line/CmdLine/Src/Callbacks/CLCompilerLinkerDropin_V10.cpp @@ -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 +*/ diff --git a/command_line/CmdLine/Src/Callbacks/CLDropinCallbacks_V10.cpp b/command_line/CmdLine/Src/Callbacks/CLDropinCallbacks_V10.cpp new file mode 100644 index 0000000..cf6f1f7 --- /dev/null +++ b/command_line/CmdLine/Src/Callbacks/CLDropinCallbacks_V10.cpp @@ -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 + */ diff --git a/command_line/CmdLine/Src/Callbacks/CLParserCallbacks_v1.cpp b/command_line/CmdLine/Src/Callbacks/CLParserCallbacks_v1.cpp new file mode 100644 index 0000000..5dbd4d8 --- /dev/null +++ b/command_line/CmdLine/Src/Callbacks/CLParserCallbacks_v1.cpp @@ -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 + */ \ No newline at end of file diff --git a/command_line/CmdLine/Src/Clients/CLStaticMain.c b/command_line/CmdLine/Src/Clients/CLStaticMain.c new file mode 100644 index 0000000..cecab30 --- /dev/null +++ b/command_line/CmdLine/Src/Clients/CLStaticMain.c @@ -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; +} diff --git a/command_line/CmdLine/Src/Clients/ClientGlue.c b/command_line/CmdLine/Src/Clients/ClientGlue.c new file mode 100644 index 0000000..9573f51 --- /dev/null +++ b/command_line/CmdLine/Src/Clients/ClientGlue.c @@ -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); +} diff --git a/command_line/CmdLine/Src/Envir/CLErrors.c b/command_line/CmdLine/Src/Envir/CLErrors.c new file mode 100644 index 0000000..76ff06f --- /dev/null +++ b/command_line/CmdLine/Src/Envir/CLErrors.c @@ -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, ...) { + +} diff --git a/command_line/CmdLine/Src/Envir/CLIO.c b/command_line/CmdLine/Src/Envir/CLIO.c new file mode 100644 index 0000000..ac58506 --- /dev/null +++ b/command_line/CmdLine/Src/Envir/CLIO.c @@ -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) { + +} diff --git a/command_line/CmdLine/Src/MacEmul/ErrMgr.c b/command_line/CmdLine/Src/MacEmul/ErrMgr.c new file mode 100644 index 0000000..65bb89c --- /dev/null +++ b/command_line/CmdLine/Src/MacEmul/ErrMgr.c @@ -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; +} diff --git a/command_line/CmdLine/Src/MacEmul/Files.c b/command_line/CmdLine/Src/MacEmul/Files.c new file mode 100644 index 0000000..7216c6b --- /dev/null +++ b/command_line/CmdLine/Src/MacEmul/Files.c @@ -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) { + +} diff --git a/command_line/CmdLine/Src/MacEmul/LowMem.c b/command_line/CmdLine/Src/MacEmul/LowMem.c new file mode 100644 index 0000000..7fab079 --- /dev/null +++ b/command_line/CmdLine/Src/MacEmul/LowMem.c @@ -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; +} + diff --git a/command_line/CmdLine/Src/MacEmul/Memory.c b/command_line/CmdLine/Src/MacEmul/Memory.c new file mode 100644 index 0000000..8b956a0 --- /dev/null +++ b/command_line/CmdLine/Src/MacEmul/Memory.c @@ -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; +} diff --git a/command_line/CmdLine/Src/MacEmul/ResourceStrings.c b/command_line/CmdLine/Src/MacEmul/ResourceStrings.c new file mode 100644 index 0000000..bdf3735 --- /dev/null +++ b/command_line/CmdLine/Src/MacEmul/ResourceStrings.c @@ -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() { +} diff --git a/command_line/CmdLine/Src/MacEmul/Resources.c b/command_line/CmdLine/Src/MacEmul/Resources.c new file mode 100644 index 0000000..7c2bea8 --- /dev/null +++ b/command_line/CmdLine/Src/MacEmul/Resources.c @@ -0,0 +1,1230 @@ +#include "mwcc_decomp.h" + +// base is 0,51, ptr is 0,54 +typedef struct MemRefList { + UInt16 id; + OSType type; + StringPtr name; + unsigned char attr; + Handle hand; + struct MemRefList *next; +} MemRefList; + +// base is 0,50, ptr is 0,55 +typedef struct MemRsrcTypeList { + OSType type; + MemRefList *ref_list; + struct MemRsrcTypeList *next; +} MemRsrcTypeList; + +// base is 0,56 +typedef struct { + char sysdata[66]; + char type[4]; + char creator[4]; + char sysdata2[38]; + char appdata[128]; +} MemRsrcSysData; // assumed name + +// base is 0,49, ptr is 0,62, ptrptr is 0,63 +typedef struct MemRsrcMap { + SInt16 refnum; + UInt16 fork_attr; + MemRsrcTypeList *type_list; + MemRsrcSysData sys_data; + struct MemRsrcMap *prev; +} MemRsrcMap; + +typedef struct { + UInt32 data_offs; + UInt32 map_offs; + UInt32 data_len; + UInt32 map_len; +} Ty70; +typedef struct { + Ty70 mem_hdr; + Handle mem_next_map_handle; + SInt16 mem_refnum; + UInt16 fork_addr; + UInt16 typelist_offs; + UInt16 namelist_offs; + UInt16 types_idx; +} Ty73; +typedef struct { + OSType type; + UInt16 rsrc_idx; + UInt16 ref_list_offs; +} Ty75; +typedef struct { + UInt16 id; + UInt16 name_offs; + unsigned char attr; + unsigned char data_offs[3]; + Handle mem_rsrc_handle; +} Ty77; +typedef struct { + unsigned char len; +} Ty80; +typedef struct { + UInt32 len; +} Ty82; + +typedef struct ResRef { + OSSpec spec; + int ref; + struct ResRef *next; +} ResRef; + +static OSErr resError; +static SInt16 cur_res_file; +Boolean ResLoad; +static MemRsrcMap *maplist; +static ResRef *resForkList; +static ResRef *resForkLast; +static Boolean UseResourceForkInfo; + +// Forward declarations +static void ReadResourceFork(SInt16 ref, SInt8 permission, void *file_data, SInt32 file_size); + +Boolean OS_UsingMacResourceForkInfo() { + return UseResourceForkInfo; +} + +void OS_UseMacResourceForkInfo(Boolean which) { + UseResourceForkInfo = which; +} + +OSErr SystemInitResources(OSSpec *spec) { + void *file_data; + SInt32 file_len; + + maplist = 0; + cur_res_file = 0; + + if (!OS_LoadMacResourceFork(spec, &file_data, &file_len)) { + ReadResourceFork(-1, 1, file_data, file_len); + cur_res_file = -1; + resError = noErr; + return noErr; + } else { + FSSpec prog; + if (!OS_OSSpec_To_FSSpec(spec, &prog) && !FSpOpenResFile(&prog, 1)) { + resError = noErr; + return noErr; + } else { + resError = fnfErr; + return fnfErr; + } + } +} + +static MemRsrcMap *NewResourceMap(SInt16 ref, UInt16 attr, MemRsrcTypeList *list) { + MemRsrcMap *nw; + MemRsrcMap **scan; + + scan = &maplist; + nw = malloc(sizeof(MemRsrcMap)); + + if (!nw) { + resError = memFullErr; + return 0; + } + + nw->refnum = ref; + nw->fork_attr = attr; + nw->type_list = list; + nw->prev = *scan; + *scan = nw; + return nw; +} + +static MemRsrcTypeList *NewTypeListEntry(MemRsrcTypeList **scan, OSType type, MemRefList *list, MemRsrcTypeList *next) { + MemRsrcTypeList *nw; + + while (*scan) + scan = &(*scan)->next; + + nw = malloc(sizeof(MemRsrcTypeList)); + if (!nw) { + resError = memFullErr; + return 0; + } + + nw->type = type; + nw->ref_list = list; + nw->next = next; + *scan = nw; + return nw; +} + +static MemRefList *NewRefListEntry(MemRefList **scan, UInt16 id, OSType type, StringPtr name, unsigned char attr, Handle hand) { + char mname[256]; + MemRefList *prev; + MemRefList *nw; + + prev = 0; + if (name) + p2cstrcpy(mname, name); + else + strcpy(mname, "(none)"); + + while (*scan && (*scan)->id != id) { + prev = *scan; + scan = &(*scan)->next; + } + + nw = malloc(sizeof(MemRefList)); + if (!nw) { + resError = memFullErr; + return 0; + } + + nw->id = id; + nw->type = type; + nw->name = name; + nw->attr = attr; + nw->hand = hand; + if (prev) { + nw->next = prev->next; + prev->next = nw; + } else { + nw->next = 0; + } + *scan = nw; + return nw; +} + +static MemRsrcMap *FindResourceMap(SInt16 ref) { + MemRsrcMap *list = maplist; + + while (list) { + if (list->refnum == ref) + return list; + list = list->prev; + } + + return 0; +} + +static MemRsrcMap *FindResourceMap2(SInt16 ref, MemRsrcMap **next) { + MemRsrcMap *list = maplist; + + *next = 0; + while (list) { + if (list->refnum == ref) + return list; + *next = list; + list = list->prev; + } + + return 0; +} + +static void DeleteResources(SInt16 refNum) { + MemRsrcMap *rm, *rmnext; + MemRsrcTypeList *mtyptmp, *mtyp; + MemRefList *mrletmp, *mrle; + + rm = FindResourceMap2(refNum, &rmnext); + if (rm) { + mtyp = rm->type_list; + while (mtyp) { + mrle = mtyp->ref_list; + while (mrle) { + if (mrle->hand) + DisposeHandle(mrle->hand); + if (mrle->name) + free(mrle->name); + mrletmp = mrle; + mrle = mrle->next; + free(mrletmp); + } + mtyptmp = mtyp; + mtyp = mtyp->next; + free(mtyptmp); + } + + if (rmnext) + rmnext->prev = rm->prev; + else + maplist = rm->prev; + free(rm); + } +} + +static void ReadResourceFork(SInt16 ref, SInt8 permission, void *file_data, SInt32 file_size) { + unsigned char *nameptr; + unsigned char *name; + Handle hand; + SInt32 offs; + SInt32 esize; + Ty82 tent; + MemRsrcTypeList *mtyp; + int rcnt; + SInt32 ref_offs; + SInt32 cnt; + SInt32 msize; + void *buffer; + Ty80 *dnam; + Ty77 *drle; + Ty75 *dtyp; + Ty73 *dmap; + MemRsrcSysData *dsys; + MemRsrcSysData tsys; + Ty70 *dhdr; + Ty70 thdr; + MemRsrcMap *rm; + + // Not Right Now Folk's +} + +static void GetResourceSizes(MemRsrcMap *rm, SInt32 *data_size, SInt32 *name_size, SInt32 *reflist_size, SInt32 *typelist_size) { + MemRefList *mrle; + MemRsrcTypeList *mtyp; + + *data_size = *name_size = *reflist_size = *typelist_size = 0; + + mtyp = rm->type_list; + while (mtyp) { + mrle = mtyp->ref_list; + while (mrle) { + *name_size += !mrle->name ? 0 : (mrle->name[0] + 1); + *data_size += (!mrle->hand ? 0 : GetHandleSize(mrle->hand)) + 4; + *reflist_size += 12; + mrle = mrle->next; + } + *typelist_size += 8; + mtyp = mtyp->next; + } +} + +static SInt32 GetResourceTypesCount(MemRsrcMap *dm) { + MemRsrcTypeList *mtyp; + SInt32 tmp; + + tmp = 0; + mtyp = dm->type_list; + while (mtyp) { + mtyp = mtyp->next; + ++tmp; + } + + return tmp; +} + +static SInt32 GetResourceEntriesCount(MemRsrcTypeList *mtyp) { + MemRefList *mrle; + SInt32 tmp; + + tmp = 0; + mrle = mtyp->ref_list; + while (mrle) { + mrle = mrle->next; + ++tmp; + } + + return tmp; +} + +static void WriteResourceFork(SInt16 ref) { + // some weird shit going on with locals here + // there's probably a bunch of macros + // may be able to refer to the Windows binary for assert values + SInt32 sz; + SInt32 __len; + SInt32 __offs; + SInt32 __offs_2; + SInt32 __len_2; + SInt32 __offs_3; + SInt32 __offs_4; + Ty82 tent; + Ty82 dent; + Ty77 trle; + Ty77 drle; + SInt32 __offs_5; + MemRefList *mrle; + Ty75 ttyp; + Ty75 dtyp; + MemRsrcTypeList *mtyp; + SInt32 __offs_6; + SInt32 data_offs; + SInt32 name_offs; + SInt32 typelist_offs; + SInt32 reflist_offs; + SInt32 data_size; + SInt32 name_size; + SInt32 typelist_size; + SInt32 reflist_size; + Handle hand_ref; + Ty73 tmap; + Ty73 dmap; + MemRsrcSysData tsys; + Ty70 thdr; + Ty70 dhdr; + MemRsrcMap *rm; +} + +static void WriteEmptyResourceFork(SInt16 ref) { + SInt32 sz; + Handle hand_ref; + Ty73 dmap; + MemRsrcSysData dsys; + Ty70 dhdr; + + // i'll do this one later lol +} + +static MemRsrcTypeList *FindResourceType1(MemRsrcMap *rm, OSType theType) { + MemRsrcTypeList *mtyp; + + mtyp = rm->type_list; + while (mtyp) { + if (mtyp->type == theType) + return mtyp; + mtyp = mtyp->next; + } + + return 0; +} + +static SInt32 CountResourceType1(MemRsrcMap *rm, OSType theType) { + MemRsrcTypeList *mtyp; + + mtyp = rm->type_list; + while (mtyp) { + if (mtyp->type == theType) + return GetResourceEntriesCount(mtyp); + mtyp = mtyp->next; + } + + return 0; +} + +static SInt32 CountResourceType(OSType theType) { + MemRsrcMap *rm; + SInt32 total; + + total = 0; + rm = FindResourceMap(cur_res_file); + + while (rm) { + total += CountResourceType1(rm, theType); + rm = rm->prev; + } + + return total; +} + +static MemRefList *FindIndResource1(MemRsrcMap *rm, OSType theType, SInt16 index) { + MemRefList *mrle; + MemRsrcTypeList *mtyp; + + mtyp = rm->type_list; + while (mtyp) { + if (mtyp->type == theType) { + mrle = mtyp->ref_list; + while (mrle && --index > 0) { + mrle = mrle->next; + } + return mrle; + } + mtyp = mtyp->next; + } + + return 0; +} + +static MemRefList *FindIndResource(OSType theType, SInt16 index) { + MemRefList *mrle; + MemRsrcMap *rm = FindResourceMap(cur_res_file); + + while (rm) { + mrle = FindIndResource1(rm, theType, index); + if (mrle) + return mrle; + rm = rm->prev; + } + + return 0; +} + +static MemRefList *FindResourceTypeAndID1(MemRsrcMap *rm, OSType theType, SInt16 theID) { + MemRefList *mref; + MemRsrcTypeList *mtyp = FindResourceType1(rm, theType); + + if (mtyp) { + mref = mtyp->ref_list; + while (mref) { + if (mref->id == theID) + return mref; + mref = mref->next; + } + } + + return 0; +} + +static MemRefList *FindResourceTypeAndID(OSType theType, SInt16 theID) { + MemRefList *mref; + MemRsrcMap *rm = FindResourceMap(cur_res_file); + + while (rm) { + mref = FindResourceTypeAndID1(rm, theType, theID); + if (mref) + return mref; + rm = rm->prev; + } + + return 0; +} + +static MemRefList *FindResourceTypeAndName1(MemRsrcMap *rm, OSType theType, ConstStringPtr theName) { + MemRefList *mref; + MemRsrcTypeList *mtyp; + + mtyp = FindResourceType1(rm, theType); + if (mtyp) { + mref = mtyp->ref_list; + while (mref) { + if (mref->name && EqualString(mref->name, theName, 0, 0)) + return mref; + mref = mref->next; + } + } + + return 0; +} + +static MemRefList *FindResourceTypeAndName(OSType theType, ConstStringPtr theName) { + MemRefList *mref; + MemRsrcMap *rm = FindResourceMap(cur_res_file); + + while (rm) { + mref = FindResourceTypeAndName1(rm, theType, theName); + if (mref) + return mref; + rm = rm->prev; + } + + return 0; +} + +static MemRefList *FindResourceHandle1(MemRsrcMap *rm, Handle theResource) { + MemRefList *mrle; + MemRsrcTypeList *mtyp; + + for (mtyp = rm->type_list; mtyp; mtyp = mtyp->next) { + for (mrle = mtyp->ref_list; mrle; mrle = mrle->next) { + if (mrle->hand == theResource) + return mrle; + } + } + + return 0; +} + +static MemRefList *FindResourceHandle(Handle theResource) { + MemRefList *mrle; + MemRsrcMap *rm; + + for (rm = FindResourceMap(cur_res_file); rm; rm = rm->prev) { + mrle = FindResourceHandle1(rm, theResource); + if (mrle) + return mrle; + } + + return 0; +} + +static int RemoveResourceHandle1(MemRsrcMap *rm, Handle theResource) { + MemRefList *mrle, *pmrle; + MemRsrcTypeList *mtyp, *pmtyp; + + mtyp = rm->type_list; + pmtyp = 0; + while (mtyp) { + mrle = mtyp->ref_list; + pmrle = 0; + while (mrle) { + if (mrle->hand == theResource) { + if (pmrle) + pmrle->next = mrle->next; + else + mtyp->ref_list = mrle->next; + free(mrle); + + if (!mtyp->ref_list) { + if (pmtyp) + pmtyp->next = mtyp->next; + else + rm->type_list = mtyp->next; + free(mtyp); + } + + return 1; + } + + pmrle = mrle; + mrle = mrle->next; + } + pmtyp = mtyp; + mtyp = mtyp->next; + } + + return 0; +} + +static int RemoveResourceHandle(Handle theResource) { + MemRsrcMap *rm; + + for (rm = FindResourceMap(cur_res_file); rm; rm = rm->prev) { + if (RemoveResourceHandle1(rm, theResource)) + return 1; + } + + return 0; +} + +static SInt16 FindResourceHandleFile1(MemRsrcMap *rm, Handle theResource) { + MemRefList *mrle; + MemRsrcTypeList *mtyp; +} + +static SInt16 FindResourceHandleFile(Handle theResource) { + MemRefList *mrle; + MemRsrcMap *rm; +} + +void OS_AddMacResourceForkRef(int ref, const OSSpec *spec) { + ResRef *nw; +} + +void OS_RemoveMacResourceForkRef(int ref) { + ResRef *prev; + ResRef *lst; +} + +OSSpec *OS_GetMacResourceForkFromRef(int ref) { + ResRef *lst; +} + +Boolean OS_SearchMacResourceForkList(const OSSpec *rspec, int *ref) { + ResRef *lst; +} + +int OS_SetMacResourceForkCreatorAndType(int ref, OSType creator, OSType type) { + MemRsrcMap *rm; + UInt32 sz; + UInt32 buf[2]; + int err; + + if (!OS_GetMacResourceForkFromRef(ref)) { + sz = 8; + buf[0] = type; + buf[1] = creator; + err = OS_Seek(ref, OSSeekAbs, 0x52); + if (!err) { + err = OS_Write(ref, buf, &sz); + if (!err && sz == 8) { + err = 0; + } + } + } else { + rm = FindResourceMap(OS_RefToMac(ref)); + if (!rm) { + err = 2; + } else if (rm->fork_attr & 0x80) { + err = 13; + } else { + rm->sys_data.creator[0] = (creator & 0xFF000000) >> 24; + rm->sys_data.creator[1] = (creator & 0x00FF0000) >> 16; + rm->sys_data.creator[2] = (creator & 0x0000FF00) >> 8; + rm->sys_data.creator[3] = (creator & 0x000000FF); + rm->sys_data.type[0] = (type & 0xFF000000) >> 24; + rm->sys_data.type[1] = (type & 0x00FF0000) >> 16; + rm->sys_data.type[2] = (type & 0x0000FF00) >> 8; + rm->sys_data.type[3] = (type & 0x000000FF); + rm->fork_attr |= 0x20; + err = 0; + } + } + + return err; +} + +int OS_GetMacResourceForkCreatorAndType(int ref, OSType *creator, OSType *type) { + MemRsrcMap *rm; + UInt32 sz; + UInt32 buf[2]; + int err; + + if (!OS_GetMacResourceForkFromRef(ref)) { + sz = 8; + err = OS_Seek(ref, OSSeekAbs, 0x52); + if (!err) { + err = OS_Read(ref, buf, &sz); + if (!err && sz == 8) { + err = 0; + *type = buf[0]; + *creator = buf[1]; + } + } + } else { + rm = FindResourceMap(OS_RefToMac(ref)); + if (!rm) { + err = 2; + } else { + *creator = (rm->sys_data.creator[0] << 24) | (rm->sys_data.creator[1] << 16) | (rm->sys_data.creator[2] << 8) | rm->sys_data.creator[3]; + *type = (rm->sys_data.type[0] << 24) | (rm->sys_data.type[1] << 16) | (rm->sys_data.type[2] << 8) | rm->sys_data.type[3]; + err = 0; + } + } + + return err; +} + +void OS_CleanupMacResourceForkDir(const OSPathSpec *dir) { + OS_Rmdir(dir); +} + +OSErr OS_MacDumpResourceFork(SInt16 ref, Boolean dumpContents) { + int spaces; + char safe[16]; + SInt32 size; + SInt32 idx; + StringPtr ptr; + char name[256]; + MemRefList *rl; + MemRsrcTypeList *tl; + MemRsrcMap *rm; + + // Debug shit +} + +OSErr FSpOpenRF(const FSSpec *fss, SInt8 permission, SInt16 *refNum) { + Boolean create; + OSSpec rspec; + OSSpec spec; + FSSpec rfss; + int oserr; + OSErr err; + + create = (permission == 1) | (permission > 1); + oserr = OS_FSSpec_To_OSSpec(fss, &spec); + if (oserr) + return OS_MacError(oserr); + + oserr = OS_GetRsrcOSSpec(&spec, &rspec, create); + if (oserr) + return OS_MacError(oserr); + + oserr = OS_OSSpec_To_FSSpec(&rspec, &rfss); + if (oserr) + return OS_MacError(oserr); + + if (OS_Status(&rspec) && create) + HCreate(rfss.vRefNum, rfss.parID, rfss.name, 'CWIE', 'rsrc'); + + err = HOpen(rfss.vRefNum, rfss.parID, rfss.name, permission, refNum); + if (!err) + OS_AddMacResourceForkRef(OS_MacToRef(*refNum), &rspec); + + return err; +} + +OSErr HOpenRF(SInt16 vRefNum, SInt32 dirID, ConstStringPtr fileName, SInt8 permission, SInt16 *refNum) { + OSErr __err; + FSSpec fss; + + __err = FSMakeFSSpec(vRefNum, dirID, fileName, &fss); + if (__err != noErr && __err != fnfErr) { + return __err; + } else { + return FSpOpenRF(&fss, permission, refNum); + } +} + +OSErr InitResources() { + MemRsrcMap *map; + + map = maplist; + cur_res_file = 0; + while (map) { + cur_res_file = map->refnum; + map = map->prev; + } + + ResLoad = 1; + resError = noErr; + return 0; +} + +OSErr ResError() { + return resError; +} + +void FSpCreateResFile(const FSSpec *fss, OSType creator, OSType fileType, ScriptCode scriptTag) { + SInt16 ref; + OSSpec spec, rspec; + int oserr; + + FSpCreate(fss, creator, fileType, scriptTag); + oserr = OS_FSSpec_To_OSSpec(fss, &spec); + if (oserr) { + resError = OS_MacError(oserr); + return; + } + + oserr = OS_GetRsrcOSSpec(&spec, &rspec, 1); + if (oserr) { + resError = OS_MacError(oserr); + return; + } + + if (OS_Status(&rspec)) { + oserr = OS_Create(&rspec, &OS_TEXTTYPE); + if (oserr) { + resError = OS_MacError(oserr); + return; + } + + resError = FSpOpenRF(fss, 3, &ref); + if (!resError) { + WriteEmptyResourceFork(ref); + FSClose(ref); + } + } else { + resError = dupFNErr; + } + +} + +void HCreateResFile(SInt16 vRefNum, SInt32 dirID, ConstStringPtr fileName) { + OSErr __err; + FSSpec fss; + + __err = FSMakeFSSpec(vRefNum, dirID, fileName, &fss); + if (__err != noErr && __err != fnfErr) { + resError = __err; + } else { + FSpCreateResFile(&fss, 'CWIE', kUnknownType, -1); + } +} + +OSErr FSpOpenResFile(const FSSpec *fss, SInt8 permission) { + SInt32 size; + SInt16 ref; + + if (permission != 1) + FSpCreate(fss, 'CWIE', 'TEXT', -1); + + resError = FSpOpenRF(fss, (permission != 2) ? permission : 3, &ref); + if (!resError) { + GetEOF(ref, &size); + if (size == 0 && permission != 1) + WriteEmptyResourceFork(ref); + ReadResourceFork(ref, permission, 0, 0); + if (resError) { + FSClose(ref); + CloseResFile(ref); + ref = -1; + } + cur_res_file = ref; + } else { + ref = -1; + } + + return ref; +} + +OSErr HOpenResFile(SInt16 vRefNum, SInt32 dirID, ConstStringPtr fileName, SInt8 permission) { + OSErr __err; + FSSpec fss; + + __err = FSMakeFSSpec(vRefNum, dirID, fileName, &fss); + if (__err != noErr && __err != fnfErr) + return __err; + return FSpOpenResFile(&fss, permission); +} + +SInt16 CurResFile() { + return cur_res_file; +} + +void UseResFile(SInt16 refNum) { + MemRsrcMap *map; + + for (map = maplist; map; map = map->prev) { + if (map->refnum == refNum) { + cur_res_file = refNum; + resError = noErr; + return; + } + } + + resError = resFNotFound; +} + +SInt16 HomeResFile(Handle theResource) { + SInt16 refnum = FindResourceHandleFile(theResource); + resError = (refnum == -1) ? resNotFound : 0; + return refnum; +} + +Handle GetResource(OSType theType, SInt16 theID) { + MemRefList *mref; + + mref = FindResourceTypeAndID(theType, theID); + if (mref) { + resError = noErr; + return mref->hand; + } else { + resError = ResLoad ? resNotFound : noErr; + return 0; + } +} + +Handle Get1Resource(OSType theType, SInt16 theID) { + MemRefList *mref; + MemRsrcMap *rm; + + rm = FindResourceMap(cur_res_file); + if (!rm) { + resError = resFNotFound; + return 0; + } + + mref = FindResourceTypeAndID1(rm, theType, theID); + if (mref) { + resError = noErr; + return mref->hand; + } else { + resError = ResLoad ? resNotFound : noErr; + return 0; + } +} + +Handle GetNamedResource(OSType theType, ConstStringPtr theName) { + MemRefList *mref; + + mref = FindResourceTypeAndName(theType, theName); + if (mref) { + resError = noErr; + return mref->hand; + } else { + resError = ResLoad ? resNotFound : noErr; + return 0; + } +} + +Handle Get1NamedResource(OSType theType, ConstStringPtr theName) { + MemRefList *mref; + MemRsrcMap *rm; + + rm = FindResourceMap(cur_res_file); + if (!rm) { + resError = resFNotFound; + return 0; + } + + mref = FindResourceTypeAndName1(rm, theType, theName); + if (mref) { + resError = noErr; + return mref->hand; + } else { + resError = (ResLoad != 0) ? resNotFound : noErr; + return 0; + } +} + +void SetResLoad(Boolean load) { + ResLoad = load; +} + +void MacEmul_LoadResource(Handle theResource) { + resError = (theResource == 0) ? nilHandleErr : 0; +} + +void GetResInfo(Handle theResource, SInt16 *theID, OSType *theType, StringPtr name) { + MemRefList *mrle; + + mrle = FindResourceHandle(theResource); + if (mrle) { + resError = noErr; + *theID = mrle->id; + *theType = mrle->type; + if (mrle->name) + _pstrcpy(name, mrle->name); + else + name[0] = 0; + } else { + resError = resNotFound; + } +} + +void SetResInfo(Handle theResource, SInt16 theID, ConstStringPtr name) { + MemRefList *mrle; + + mrle = FindResourceHandle(theResource); + if (mrle) { + resError = noErr; + if (mrle->name) + free(mrle->name); + mrle->name = malloc(name[0] + 1); + mrle->attr |= 2; + if (mrle->name) + _pstrcpy(mrle->name, name); + else + resError = memFullErr; + } else { + resError = resNotFound; + } +} + +SInt16 GetResAttrs(Handle theResource) { + MemRefList *mrle; + + mrle = FindResourceHandle(theResource); + if (mrle) { + resError = noErr; + return mrle->attr; + } else { + resError = resNotFound; + return 0; + } +} + +void SetResAttrs(Handle theResource, SInt16 attrs) { + MemRefList *mrle; + + mrle = FindResourceHandle(theResource); + if (mrle) { + resError = noErr; + mrle->attr = attrs; + } else { + resError = resNotFound; + } +} + +void ChangedResource(Handle theResource) { + MemRefList *mrle; + MemRsrcMap *rm; + + rm = FindResourceMap(cur_res_file); + mrle = FindResourceHandle(theResource); + if (mrle) { + if (rm && (rm->fork_attr & 0x80)) { + resError = resAttrErr; + } else { + resError = noErr; + mrle->attr |= 2; + rm->fork_attr |= 0x20; + } + } else { + resError = resNotFound; + } +} + +void AddResource(Handle theData, OSType theType, SInt16 theID, ConstStringPtr name) { + MemRsrcMap *rm; + MemRsrcTypeList *mtyp; + MemRefList *mrle; + StringPtr namecpy; + + rm = FindResourceMap(cur_res_file); + if (rm) { + if (rm->fork_attr & 0x80) { + resError = resAttrErr; + return; + } + + resError = noErr; + mtyp = FindResourceType1(rm, theType); + if (!mtyp) { + mtyp = NewTypeListEntry(&rm->type_list, theType, 0, 0); + if (!mtyp) { + resError = memFullErr; + return; + } + rm->fork_attr |= 0x20; + } + if (!theData || FindResourceHandle(theData)) { + resError = addResFailed; + return; + } + + if (name && name[0]) { + namecpy = malloc(name[0] + 1); + _pstrcpy(namecpy, name); + } else { + namecpy = 0; + } + + mrle = NewRefListEntry(&mtyp->ref_list, theID, theType, namecpy, 2, theData); + if (!mrle) { + resError = memFullErr; + return; + } + + rm->fork_attr |= 0x20; + } else { + resError = resFNotFound; + } +} + +void UpdateResFile(SInt16 refnum) { + WriteResourceFork(refnum); +} + +void WriteResource(Handle theResource) { + resError = noErr; +} + +void SetResPurge(Boolean install) { +} + +SInt16 CountResources(OSType theType) { + return CountResourceType(theType); +} + +SInt16 Count1Resources(OSType theType) { + MemRsrcMap *rm; + + rm = FindResourceMap(cur_res_file); + if (rm) { + resError = noErr; + return CountResourceType1(rm, theType); + } else { + resError = resFNotFound; + return 0; + } +} + +Handle GetIndResource(OSType theType, SInt16 index) { + MemRefList *mrle; + + mrle = FindIndResource(theType, index); + resError = mrle ? 0 : resNotFound; + return mrle->hand; +} + +Handle Get1IndResource(OSType theType, SInt16 index) { + MemRefList *mrle; + MemRsrcMap *rm; + + rm = FindResourceMap(cur_res_file); + if (rm) { + mrle = FindIndResource1(rm, theType, index); + if (mrle) { + resError = noErr; + return mrle->hand; + } else { + resError = resNotFound; + return 0; + } + } else { + resError = resFNotFound; + return 0; + } +} + +SInt16 Count1Types() { + SInt16 count; + MemRsrcTypeList *rtl; + MemRsrcMap *rm; + + count = 0; + rm = FindResourceMap(cur_res_file); + if (rm) { + rtl = rm->type_list; + while (rtl) { + rtl = rtl->next; + ++count; + } + } else { + resError = resFNotFound; + } + + return count; +} + +void Get1IndType(OSType *theType, SInt16 index) { + SInt16 count; + MemRsrcTypeList *rtl; + MemRsrcMap *rm; + + count = 1; + rm = FindResourceMap(cur_res_file); + if (rm) { + rtl = rm->type_list; + while (rtl && count < index) { + rtl = rtl->next; + ++count; + } + if (rtl) + *theType = rtl->type; + else + resError = inputOutOfBounds; + } else { + resError = resFNotFound; + } +} + +void ReleaseResource(Handle theResource) { + resError = noErr; +} + +void DetachResource(Handle theResource) { + SInt32 ns; + MemRefList *mrle; + + mrle = FindResourceHandle(theResource); + if (mrle) { + ns = GetHandleSize(theResource); + mrle->hand = NewHandle(ns); + if (!mrle->hand) { + resError = memFullErr; + } else { + HLock(mrle->hand); + HLock(theResource); + memcpy(*mrle->hand, *theResource, ns); + HUnlock(theResource); + HUnlock(mrle->hand); + resError = noErr; + } + } else { + resError = resNotFound; + } +} + +void RemoveResource(Handle theResource) { + resError = RemoveResourceHandle(theResource) ? 0 : rmvResFailed; +} + +void CloseResFile(SInt16 refNum) { + MemRsrcMap *rm = FindResourceMap(refNum); + + if (rm && refNum != -1) { + WriteResourceFork(refNum); + DeleteResources(refNum); + FSClose(refNum); + } + + cur_res_file = maplist ? maplist->refnum : 0; +} + +SInt16 GetResFileAttrs(SInt16) { + MemRsrcMap *rm = FindResourceMap(cur_res_file); + + if (rm) { + resError = 0; + return rm->fork_attr; + } else { + resError = resFNotFound; + return 0; + } +} + +Boolean LMGetResLoad() { + return 1; +} diff --git a/command_line/CmdLine/Src/MacEmul/TextUtils.c b/command_line/CmdLine/Src/MacEmul/TextUtils.c new file mode 100644 index 0000000..a23ac7e --- /dev/null +++ b/command_line/CmdLine/Src/MacEmul/TextUtils.c @@ -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); +} diff --git a/command_line/CmdLine/Src/OSLib/FileHandles.c b/command_line/CmdLine/Src/OSLib/FileHandles.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/OSLib/Generic.c b/command_line/CmdLine/Src/OSLib/Generic.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/OSLib/MacFileTypes.c b/command_line/CmdLine/Src/OSLib/MacFileTypes.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/OSLib/MacSpecs.c b/command_line/CmdLine/Src/OSLib/MacSpecs.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/OSLib/MemUtils.c b/command_line/CmdLine/Src/OSLib/MemUtils.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/OSLib/Posix.c b/command_line/CmdLine/Src/OSLib/Posix.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/OSLib/StringExtras.c b/command_line/CmdLine/Src/OSLib/StringExtras.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/OSLib/StringUtils.c b/command_line/CmdLine/Src/OSLib/StringUtils.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/Plugins/CLPlugins.c b/command_line/CmdLine/Src/Plugins/CLPlugins.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/Project/CLAccessPaths.c b/command_line/CmdLine/Src/Project/CLAccessPaths.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/Project/CLFiles.c b/command_line/CmdLine/Src/Project/CLFiles.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/Project/CLOverlays.c b/command_line/CmdLine/Src/Project/CLOverlays.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/Project/CLProj.c b/command_line/CmdLine/Src/Project/CLProj.c new file mode 100644 index 0000000..e69de29 diff --git a/command_line/CmdLine/Src/Project/CLSegs.c b/command_line/CmdLine/Src/Project/CLSegs.c new file mode 100644 index 0000000..e69de29 diff --git a/includes/mwcc_decomp.h b/includes/mwcc_decomp.h new file mode 100644 index 0000000..3b4d2b1 --- /dev/null +++ b/includes/mwcc_decomp.h @@ -0,0 +1,2404 @@ +#pragma once + +#ifdef __MWERKS__ +#define macintosh +//#include +#define CW_PASCAL pascal +#include +#include +#include +#include +#include +#include +#undef toupper +#else +#include +#include +#include +#include +#include +#include +#include + +// expand this to nothing +#define CW_PASCAL +#endif + +// MacOS nonsense + +// ---------- +// MacTypes.h +typedef uint8_t UInt8; +typedef int8_t SInt8; +typedef uint16_t UInt16; +typedef int16_t SInt16; +typedef uint32_t UInt32; +typedef int32_t SInt32; +typedef uint64_t UInt64; +typedef int64_t SInt64; + +typedef char *Ptr; +typedef Ptr *Handle; +typedef int32_t Size; + +typedef SInt16 OSErr; +typedef SInt32 OSStatus; +typedef SInt16 ScriptCode; +typedef UInt32 FourCharCode; +typedef FourCharCode OSType; +typedef FourCharCode ResType; +typedef OSType *OSTypePtr; +typedef ResType *ResTypePtr; + +typedef uint8_t Boolean; + +enum { + noErr = 0, + fnfErr = -43, // file not found + dupFNErr = -48, // duplicate filename + memFullErr = -108, // not enough memory + nilHandleErr = -109, // pointer was nil + inputOutOfBounds = -190, + resNotFound = -192, // resource not found + resFNotFound = -193, // resource file not found + addResFailed = -194, // AddResource failed + rmvResFailed = -196, // RmveResource failed + resAttrErr = -198 // inconsistent attribute +}; +enum { kNilOptions = 0 }; +enum { kUnknownType = 0x3F3F3F3F }; + +// Pascal strings +typedef unsigned char Str255[256]; +typedef unsigned char Str63[64]; +typedef unsigned char *StringPtr; +typedef const unsigned char *ConstStringPtr; +typedef const unsigned char *ConstStr63Param; +typedef const unsigned char *ConstStr255Param; +// XXX: MacTypes.h defines StrLength() which is an inline for C++ and a macro for C +// This might be useful? + +typedef struct Point { + SInt16 v, h; +} Point; + +typedef struct Rect { + SInt16 top, left, bottom, right; +} Rect; + +// ------- +// Files.h +typedef struct FSSpec { + SInt16 vRefNum; + SInt32 parID; + Str255 name; +} FSSpec; + +typedef struct FInfo { + OSType fdType; + OSType fdCreator; + UInt16 fdFlags; + Point fdLocation; + SInt16 fdFldr; +} FInfo; + +typedef struct FXInfo { + SInt16 fdIconID; + SInt16 fdUnused[3]; + SInt8 fdScript; + SInt8 fdXFlags; + SInt16 fdComment; + SInt32 fdPutAway; +} FXInfo; + +typedef struct DInfo { + Rect frRect; + SInt16 frFlags; + Point frLocation; + SInt16 frView; +} DInfo; + +typedef struct DXInfo { + Point frScroll; + SInt32 frOpenChain; + SInt16 frUnused; + SInt16 frComment; + SInt32 frPutAway; +} DXInfo; + +typedef struct IOParam { + SInt16 ioResult; + SInt16 ioRefNum; + char *ioBuffer; + SInt32 ioReqCount; + SInt32 ioActCount; + SInt16 ioPosMode; + SInt32 ioPosOffset; +} IOParam; +typedef union ParamBlockRec { + IOParam ioParam; +} ParamBlockRec; +typedef ParamBlockRec *ParmBlkPtr; + +typedef struct HFileParam { + void *qLink; + SInt16 qType; + SInt16 ioTrap; + Ptr ioCmdAddr; + void *ioCompletion; + SInt16 ioResult; + StringPtr ioNamePtr; + SInt16 ioVRefNum; + SInt16 ioFRefNum; + SInt8 ioFVersNum; + SInt8 filler1; + SInt16 ioFDirIndex; + SInt8 ioFlAttrib; + SInt8 ioFlVersNum; + FInfo ioFlFndrInfo; + SInt32 ioDirID; + UInt16 ioFlStBlk; + SInt32 ioFlLgLen; + SInt32 ioFlPyLen; + UInt16 ioFlRStBlk; + SInt32 ioFlRLgLen; + SInt32 ioFlRPyLen; + UInt32 ioFlCrDat; + UInt32 ioFlMdDat; +} HFileParam; +typedef union HParamBlockRec { + HFileParam fileParam; +} HParamBlockRec; +typedef HParamBlockRec *HParmBlkPtr; + +typedef struct HFileInfo { + void *qLink; + SInt16 qType; + SInt16 ioTrap; + Ptr ioCmdAddr; + void *ioCompletion; + SInt16 ioResult; + StringPtr ioNamePtr; + SInt16 ioVRefNum; + SInt16 ioFRefNum; + SInt8 ioFVersNum; + SInt8 filler1; + SInt16 ioFDirIndex; + SInt8 ioFlAttrib; + SInt8 ioACUser; + FInfo ioFlFndrInfo; + SInt32 ioDirID; + UInt16 ioFlStBlk; + SInt32 ioFlLgLen; + SInt32 ioFlPyLen; + UInt16 ioFlRStBlk; + SInt32 ioFlRLgLen; + SInt32 ioFlRPyLen; + UInt32 ioFlCrDat; + UInt32 ioFlMdDat; + UInt32 ioFlBkDat; + FXInfo ioFlXFndrInfo; + SInt32 ioFlParID; + SInt32 ioFlClpSiz; +} HFileInfo; +typedef struct DirInfo { + void *qLink; + SInt16 qType; + SInt16 ioTrap; + Ptr ioCmdAddr; + void *ioCompletion; + SInt16 ioResult; + StringPtr ioNamePtr; + SInt16 ioVRefNum; + SInt16 ioFRefNum; + SInt8 ioFVersNum; + SInt8 filler1; + SInt16 ioFDirIndex; + SInt8 ioFlAttrib; + SInt8 ioACUser; + DInfo ioDrUsrWds; + SInt32 ioDrDirID; + UInt16 ioDrNmFls; + SInt16 filler3[9]; + UInt32 ioDrCrDat; + UInt32 ioDrMdDat; + UInt32 ioDrBkDat; + DXInfo ioDrFndrInfo; + SInt32 ioDrParID; +} DirInfo; +typedef union CInfoPBRec { + HFileInfo hFileInfo; + DirInfo hDirInfo; +} CInfoPBRec; +typedef CInfoPBRec *CInfoPBPtr; +//#endif + +//#include "../sdk_hdrs/CompilerMapping.h" +//#include "../sdk_hdrs/DropInCompilerLinker.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/********************************/ +/* OS Garbage */ +typedef struct OSPathSpec { + char s[256]; +} OSPathSpec; +typedef struct OSNameSpec { + char s[64]; +} OSNameSpec; +typedef struct OSSpec { + OSPathSpec path; + OSNameSpec name; +} OSSpec; + +typedef struct OSHandle { + void *addr; + UInt32 used; + UInt32 size; +} OSHandle; + +typedef struct { + OSSpec spec; + OSHandle hand; + Boolean loaded; + Boolean changed; + Boolean writeable; +} OSFileHandle; // assumed name + +/********************************/ +/* Option Fuckery */ +#ifdef __MWERKS__ +#pragma options align=packed +#endif +typedef struct PARAM_T { + char which; + char flags; + char *myname; + struct PARAM_T *next; +} PARAM_T; +typedef struct MASK_T { + char which; + char flags; + char *myname; + PARAM_T *next; + char size; + UInt32 ormask; + UInt32 andmask; + void *num; +} MASK_T; +typedef struct STRING_T { + char which; + char flags; + char *myname; + PARAM_T *next; + SInt16 maxlen; + Boolean pstring; + char *str; +} STRING_T; +typedef struct SET_T { + char which; + char flags; + char *myname; + PARAM_T *next; + char size; + UInt32 value; + char *num; +} SET_T; +typedef struct SETSTRING_T { + char which; + char flags; + char *myname; + PARAM_T *next; + char *value; + char pstring; + void *var; +} SETSTRING_T; +typedef struct GENERIC_T { + char which; + char flags; + char *myname; + PARAM_T *next; + int (*parse)(const char *opt, void *var, const char *pstr, int flags); + void *var; + char *help; +} GENERIC_T; +typedef struct SETTING_T { + char which; + char flags; + char *myname; + PARAM_T *next; + int (*parse)(const char *a, const char *b); // TODO name these args + char *valuename; +} SETTING_T; +typedef struct TOGGLE_T { + char which; + char flags; + char *myname; + PARAM_T *next; + char size; + UInt32 mask; + void *num; +} TOGGLE_T; +typedef struct NUM_T { + char which; + char flags; + char *myname; + PARAM_T *next; + char size; + char fit; + UInt32 lo; + UInt32 hi; + void *num; +} NUM_T; +typedef struct FILEPATH_T { + char which; + char flags; + char *myname; + PARAM_T *next; + char fflags; + char *defaultstr; + void *filename; + int maxlen; +} FILEPATH_T; +typedef struct IFARG_T { + char which; + char flags; + char *myname; + PARAM_T *next; + PARAM_T *parg; + char *helpa; + PARAM_T *pnone; + char *helpn; +} IFARG_T; +typedef struct ONOFF_T { + char which; + char flags; + char *myname; + PARAM_T *next; + unsigned char *var; +} ONOFF_T; +typedef struct OFFON_T { + char which; + char flags; + char *myname; + PARAM_T *next; + unsigned char *var; +} OFFON_T; +typedef struct FTYPE_T { + char which; + char flags; + char *myname; + PARAM_T *next; + OSType *fc; + Boolean iscreator; +} FTYPE_T; +typedef struct OptionList { + char *help; + int flags; + struct Option **list; +} OptionList; +typedef struct Option { + char *names; + int avail; + PARAM_T *param; + OptionList *sub; + OptionList *conflicts; + char *help; +} Option; +enum { + HELPFLAGS_1 = 1, + HELPFLAGS_IGNORED = 2, + HELPFLAGS_OBSOLETE = 4, + HELPFLAGS_DEPRECATED = 8, + HELPFLAGS_SECRET = 0x10, + HELPFLAGS_MEANINGLESS = 0x20, + HELPFLAGS_COMPATIBLE = 0x40, + HELPFLAGS_NORMAL = 0x80, // andmask = 0xE? + HELPFLAGS_SPACES = 0x100, + HELPFLAGS_TOOL = 0x200, + HELPFLAGS_TOOL_THIS = 0x400, + HELPFLAGS_TOOL_OTHER = 0x800, + HELPFLAGS_TOOL_BOTH = 0xC00, + HELPFLAGS_1000 = 0x1000, + HELPFLAGS_2000 = 0x2000, + HELPFLAGS_USAGE = 0x4000, + HELPFLAGS_8000 = 0x8000 +}; +enum { + OTF_GLOBAL = 1, + OTF2 = 2, + OTF_CASED = 4, + OTF_OBSOLETE = 8, + OTF_SUBSTITUTED = 0x10, + OTF_DEPRECATED = 0x20, + OTF_TOOL_LINKER = 0x40, + OTF_TOOL_DISASSEMBLER = 0x80, + OTF_TOOL_COMPILER = 0x100, + OTF_TOOL_MASK = OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER | OTF_TOOL_COMPILER, + OTF200 = 0x200, + OTF400 = 0x400, + OTF700 = 0x700, + OTF_IGNORED = 0x800, + OTFC00 = 0xC00, + OTF_SECRET = 0x1000, + OTF2000 = 0x2000, + OTF_COMPATIBILITY = 0x4000, + OTF8000 = 0x8000, + OTF10000 = 0x10000, + OTF20000 = 0x20000, + OTF40000 = 0x40000, + OTF_WARNING = 0x80000, + OTF_SLFLAGS_8 = 0x100000, + OTF_SLFLAGS_10 = 0x200000, + OTF_SLFLAGS_20 = 0x400000, + OTF_SLFLAGS_MASK = OTF_SLFLAGS_8 | OTF_SLFLAGS_10 | OTF_SLFLAGS_20, + OTF_MEANINGLESS = 0x800000, + OTF_ALL_HIDDEN_BY_DEFAULT = OTF_OBSOLETE | OTF_DEPRECATED | OTF_IGNORED | OTF_SECRET | OTF_MEANINGLESS, + OTF1000000 = 0x1000000, + OTF2000000 = 0x2000000, + OTF4000000 = 0x4000000, + OTF8000000 = 0x8000000, + OTF10000000 = 0x10000000, + OTF20000000 = 0x20000000, + OTF40000000 = 0x40000000, + OTF80000000 = 0x80000000 +}; + +enum { + PARAMWHICH_None = 0, + PARAMWHICH_FTypeCreator = 1, + PARAMWHICH_FilePath = 2, + PARAMWHICH_Number = 3, + PARAMWHICH_String = 4, + PARAMWHICH_Id = 5, + PARAMWHICH_Sym = 6, + PARAMWHICH_OnOff = 7, + PARAMWHICH_OffOn = 8, + PARAMWHICH_Mask = 9, + PARAMWHICH_Toggle = 0xA, + PARAMWHICH_Set = 0xB, + PARAMWHICH_SetString = 0xC, + PARAMWHICH_Generic = 0xD, + PARAMWHICH_IfArg = 0xE, + PARAMWHICH_Setting = 0xF, + PARAMWHICH_MAX = 0x10 +}; +enum { + PARAMFLAGS_1 = 1, + PARAMFLAGS_2 = 2, + PARAMFLAGS_3 = 3, + PARAMFLAGS_4 = 4, + PARAMFLAGS_8 = 8, + PARAMFLAGS_10 = 0x10, + PARAMFLAGS_12 = 0x12 +}; +enum { + PARAMPARSEFLAGS_0 = 0, + PARAMPARSEFLAGS_1 = 1, + PARAMPARSEFLAGS_2 = 2, + PARAMPARSEFLAGS_4 = 4, + PARAMPARSEFLAGS_8 = 8, + PARAMPARSEFLAGS_10 = 0x10, + PARAMPARSEFLAGS_20 = 0x20, + PARAMPARSEFLAGS_40 = 0x40, + PARAMPARSEFLAGS_80 = 0x80, + PARAMPARSEFLAGS_100 = 0x100 +}; +enum { + SLFLAGS_1 = 1, + SLFLAGS_2 = 2, + SLFLAGS_4 = 4, // displays =... + SLFLAGS_8 = 8, // displays [no] -- produces e.g. [no]err[or] | [no]iserr[or], [no]implicit[conv] + SLFLAGS_10 = 0x10, // displays [-] + SLFLAGS_20 = 0x20, // displays [no-] + SLFLAGS_40 = 0x40 +}; +enum { + LISTFLAGS_NONE = 0, + LISTFLAGS_2 = 2, + LISTFLAGS_4 = 4, + LISTFLAGS_COMPILER = 0x100, + LISTFLAGS_LINKER = 0x200, + LISTFLAGS_DISASSEMBLER = 0x400, + LISTFLAGS_TOOL_MASK = LISTFLAGS_COMPILER | LISTFLAGS_LINKER | LISTFLAGS_DISASSEMBLER +}; +#ifdef __MWERKS__ +#pragma options align=reset +#endif + + +struct IDEAccessPath { + FSSpec pathSpec; + Boolean recursive; + SInt32 subdirectoryCount; + FSSpec *subdirectories; +}; + +struct IDEAccessPathList { + SInt32 userPathCount; + struct IDEAccessPath *userPaths; + SInt32 systemPathCount; + struct IDEAccessPath *systemPaths; + unsigned char alwaysSearchUserPaths; + unsigned char convertPaths; +}; + +#ifdef __MWERKS__ +#pragma options align=mac68k +#endif +typedef struct CWObjectFlags { + SInt16 version; + SInt32 flags; + const char *objFileExt; + const char *brsFileExt; + const char *ppFileExt; + const char *disFileExt; + const char *depFileExt; + const char *pchFileExt; + OSType objFileCreator; + OSType objFileType; + OSType brsFileCreator; + OSType brsFileType; + OSType ppFileCreator; + OSType ppFileType; + OSType disFileCreator; + OSType disFileType; + OSType depFileCreator; + OSType depFileType; +} CWObjectFlags; + +typedef struct CWIDEInfo { + UInt16 majorVersion; + UInt16 minorVersion; + UInt16 bugFixVersion; + UInt16 buildVersion; + UInt16 dropinAPIVersion; +} CWIDEInfo; + +typedef struct DropInFlags { + SInt16 rsrcversion; + OSType dropintype; + UInt16 earliestCompatibleAPIVersion; + UInt32 dropinflags; + OSType edit_language; + UInt16 newestAPIVersion; +} DropInFlags; + +typedef struct CWPanelList { + SInt16 version; + SInt16 count; + const char **names; +} CWPanelList; + +typedef struct CWFamily { + OSType type; + const char *name; +} CWFamily; + +typedef struct CWFamilyList { + SInt16 version; + SInt16 count; + CWFamily *families; +} CWFamilyList; + +typedef struct CWTargetList { + SInt16 version; + SInt16 cpuCount; + OSType *cpus; + SInt16 osCount; + OSType *oss; +} CWTargetList; + +typedef struct CWExtensionMapping { + OSType type; + char extension[32]; + UInt32 flags; +} CWExtensionMapping; + +typedef struct CWExtMapList { + SInt16 version; + SInt16 nMappings; + CWExtensionMapping *mappings; +} CWExtMapList; + +typedef struct CWHelpInfo { + SInt16 version; + const char *helpFileName; +} CWHelpInfo; +#ifdef __MWERKS__ +#pragma options align=reset +#endif + +struct CW_BasePluginCallbacks { + void (*cbGetFileInfo)(); + void (*cbFindAndLoadFile)(); + void (*cbGetFileText)(); + void (*cbReleaseFileText)(); + void (*cbGetSegmentInfo)(); + void (*cbGetOverlay1GroupInfo)(); + void (*cbGetOverlay1Info)(); + void (*cbGetOverlay1FileInfo)(); + void (*cbReportMessage)(); + void (*cbAlert)(); + void (*cbShowStatus)(); + void (*cbUserBreak)(); + void (*cbGetNamedPreferences)(); + void (*cbStorePluginData)(); + void (*cbGetPluginData)(); + void (*cbSetModDate)(); + void (*cbAddProjectEntry)(); + void (*cbCreateNewTextDocument)(); + void (*cbAllocateMemory)(); + void (*cbFreeMemory)(); + void (*cbAllocMemHandle)(); + void (*cbFreeMemHandle)(); + void (*cbGetMemHandleSize)(); + void (*cbResizeMemHandle)(); + void (*cbLockMemHandle)(); + void (*cbUnlockMemHandle)(); + void *cbInternal[8]; + void (*cbGetTargetName)(); + void (*cbCacheAccessPathList)(); + void (*cbPreDialog)(); + void (*cbPostDialog)(); + void (*cbPreFileAction)(); + void (*cbPostFileAction)(); + void (*cbCheckoutLicense)(); + void (*cbCheckinLicense)(); + void (*cbResolveRelativePath)(); +}; +struct CWCompilerLinkerCallbacks { + void (*cbCachePrecompiledHeader)(); + void (*cbLoadObjectData)(); + void (*cbStoreObjectData)(); + void (*cbFreeObjectData)(); + void (*cbDisplayLines)(); + void (*cbBeginSubCompile)(); + void (*cbEndSubCompile)(); + void (*cbGetPrecompiledHeaderSpec)(); + void (*cbPutResourceFile)(); + void (*cbGetResourceFile)(); + void (*cbLookUpUnit)(); + void (*cbSBMfiles)(); + void (*cbStoreUnit)(); + void (*cbReleaseUnit)(); + void (*cbUnitNameToFileName)(); + void (*cbOSErrorMessage)(); + void (*cbOSAlert)(); + void (*cbGetModifiedFiles)(); + void (*cbGetSuggestedObjectFileSpec)(); + void (*cbGetStoredObjectFileSpec)(); + void (*cbGetRuntimeSettings)(); + void (*cbGetFrameworkCount)(); + void (*cbGetFrameworkInfo)(); + void (*cbGetFrameworkSharedLibrary)(); +}; +struct CWParserCallbacks { + void (*cbParserAddAccessPath)(); + void (*cbParserSwapAccessPaths)(); + void (*cbParserSetNamedPreferences)(); + void (*cbParserSetFileOutputName)(); + void (*cbParserSetOutputFileDirectory)(); + void (*cbParserAddOverlay1Group)(); + void (*cbParserAddOverlay1)(); + void (*cbParserAddSegment)(); + void (*cbParserSetSegment)(); +}; + +struct CWPluginPrivateContext { + SInt32 request; + SInt32 apiVersion; + void *shellContext; + void *pluginStorage; + FSSpec projectFile; + FSSpec outputFileDirectory; + OSType shellSignature; + OSType pluginType; + SInt32 numFiles; + SInt32 numOverlayGroups; + OSErr callbackOSError; + OSErr pluginOSError; + CWIDEInfo *shellInfo; + struct IDEAccessPathList *accessPathList; + SInt32 dontEatEvents; + FSSpec *targetDataDirectorySpec; + SInt32 reserved[17]; + struct CW_BasePluginCallbacks *callbacks; +}; + +// Pref panels +#ifdef __MWERKS__ +#pragma options align=mac68k +#endif +typedef struct PCmdLine { + SInt16 version; + SInt16 state; + SInt16 stages; + SInt16 toDisk; + SInt16 outNameOwner; + Boolean dryRun; + Boolean debugInfo; + SInt16 verbose; + Boolean showLines; + Boolean timeWorking; + Boolean noWarnings; + Boolean warningsAreErrors; + Boolean maxErrors; + Boolean maxWarnings; + SInt16 msgStyle; + Boolean noWrapOutput; + Boolean stderr2stdout; + Boolean noCmdLineWarnings; +} PCmdLine; +typedef struct PCmdLineCompiler { + SInt16 version; + Boolean noSysPath; + Boolean noFail; + SInt16 includeSearch; + char linkerName[64]; + char objFileExt[15]; + char brsFileExt[15]; + char ppFileExt[15]; + char disFileExt[15]; + char depFileExt[15]; + char pchFileExt[15]; + OSType objFileCreator; + OSType objFileType; + OSType brsFileCreator; + OSType brsFileType; + OSType ppFileCreator; + OSType ppFileType; + OSType disFileCreator; + OSType disFileType; + OSType depFileCreator; + OSType depFileType; + Boolean compileIgnored; + Boolean relPathInOutputDir; + Boolean browserEnabled; + Boolean depsOnlyUserFiles; + char outMakefile[256]; + SInt8 forcePrecompile; + Boolean ignoreMissingFiles; + Boolean printHeaderNames; + SInt8 sbmState; + char sbmPath[256]; + Boolean canonicalIncludes; + Boolean keepObjects; +} PCmdLineCompiler; +typedef struct PCmdLineLinker { + SInt16 version; + Boolean callPreLinker; + Boolean callPostLinker; + Boolean keepLinkerOutput; + Boolean callLinker; +} PCmdLineLinker; +typedef struct PCmdLineEnvir { + SInt16 version; + SInt16 cols; + SInt16 rows; + Boolean underIDE; +} PCmdLineEnvir; +typedef struct PBackEnd { + SInt16 version; + UInt8 structalignment; + UInt8 tracebacktables; + UInt8 processor; + UInt8 readonlystrings; + UInt8 profiler; + UInt8 fpcontract; + UInt8 schedule; + UInt8 peephole; + UInt8 processorspecific; + UInt8 altivec; + UInt8 vrsave; + UInt8 autovectorize; + UInt8 usebuiltins; + UInt8 pic; + UInt8 dynamic; + UInt8 common; + UInt8 implicit_templates; + UInt8 reserved[3]; +} PBackEnd; +typedef struct PDisassembler { + SInt16 version; + Boolean showcode; + Boolean extended; + Boolean mix; + Boolean nohex; + Boolean showdata; + Boolean showexceptions; + Boolean showsym; + Boolean shownames; +} PDisassembler; +typedef struct PMachOLinker { + SInt16 version; + UInt8 linksym; + UInt8 symfullpath; + UInt8 suppresswarn; + UInt8 linkmap; + UInt8 multisymerror; + UInt8 whatfileloaded; + UInt8 whyfileloaded; + UInt8 use_objectivec_semantics; + SInt8 undefinedsymbols; + SInt8 readonlyrelocs; + SInt8 reserved_value1; + SInt8 reserved_value2; + SInt16 exports; + SInt16 reserved_short1; + UInt32 currentversion; + UInt32 compatibleversion; + SInt32 reserved_long1; + char mainname[64]; + UInt8 prebind; + UInt8 dead_strip; + UInt8 twolevel_namespace; + UInt8 strip_debug_symbols; +} PMachOLinker; +typedef struct PMachOProject { + SInt16 version; + SInt16 type; + Str63 outfile; + OSType filecreator; + OSType filetype; + SInt32 stacksize; + SInt32 stackaddress; + SInt32 reserved1; + SInt32 reserved2; + SInt32 reserved3; + SInt32 reserved4; + SInt32 reserved5; + SInt32 reserved6; + SInt32 reserved7; + SInt32 reserved8; + SInt32 reserved9; + SInt32 reserved10; + SInt32 reserved11; + SInt32 reserved12; + SInt32 reserved13; + SInt32 reserved14; + SInt32 reserved15; + SInt32 reserved16; + SInt32 reserved17; + SInt32 reserved18; + SInt32 reserved19; + SInt32 reserved20; + UInt8 flatrsrc; + UInt8 filler1; + UInt8 filler2; + UInt8 filler3; + Str63 separateflatfile; + Str255 installpath; +} PMachOProject; +typedef struct { + SInt16 version; + Boolean userSetCreator; + Boolean userSetType; + Boolean gPrintMapToStdOutput; + Str255 mapfilename; + Str255 symfilename; +} PCLTExtras; +#ifdef __MWERKS__ +#pragma options align=reset +#endif + +typedef struct CWCommandLineArgs { + int argc; + char **argv; + char **envp; +} CWCommandLineArgs; + +typedef struct VersionInfo { + UInt16 major; + UInt16 minor; + UInt16 patch; + UInt16 build; +} VersionInfo; + +typedef struct CLPluginInfo { + OSType plugintype; + OSType language; + SInt32 dropinflags; + char *version; + Boolean storeCommandLine; +} CLPluginInfo; + +typedef struct ToolVersionInfo { + char *company; + char *product; + char *tool; + char *copyright; + char *version; +} ToolVersionInfo; + +// may not actually be named this +struct ParseOptsType { + struct CWPluginPrivateContext *context; + char helpKey[64]; + SInt32 helpFlags; + UInt16 ioCols; + UInt16 ioRows; + CWCommandLineArgs *args; + ToolVersionInfo *toolVersion; + int numPlugins; + CLPluginInfo *plugins; + int numPanels; + char **panelNames; + OSType cpu; + OSType os; + char lastoutputname[256]; + SInt32 currentSegment; + SInt32 currentOverlayGroup; + SInt32 currentOverlay; + int possibleFiles; + int userSpecifiedFiles; + int unusedFiles; + Boolean hadAnyOutput; + Boolean hadErrors; + Boolean showHelp; + Boolean underIDE; + Boolean alwaysUsePaths; + Boolean noOptions; + Boolean printedVersion; + Boolean passingArgs; + Boolean disToFile; + Boolean ppToFile; + Boolean initBefore; + Boolean weakImport; + Boolean mergeIntoOutput; + Boolean success; + Boolean ignoreUnknown; + UInt8 unused[2]; +}; + +typedef struct { + int argc; + const char **argv; + OSType cpu; + OSType os; + OSType plugintype; + OSType language; + OSType parserstyle; + OSSpec programSpec; + const char *programName; + SInt16 countWarnings; + SInt16 countErrors; + Boolean pluginDebug; + Boolean userBreak; + Boolean withholdWarnings; + Boolean withholdErrors; + OSSpec makefileSpec; + OSPathSpec sbmPathSpec; + OSHandle browseTableHandle; + const char *stdout_base; + int stdout_written; +} CLState; // assumed name + +typedef struct OSFileTypeMapping { + OSType mactype; + const char *magic; + char length; + const char *mimetype; + char executable; // not sure why this is rearranged +} OSFileTypeMapping; + +typedef struct OSFileTypeMappingList { + SInt16 numMappings; + const OSFileTypeMapping *mappings; +} OSFileTypeMappingList; + +typedef struct BasePluginCallbacks { + SInt16 (*main)(void *context); + SInt16 (*GetDropInFlags)(const DropInFlags **flags, SInt32 *flagsSize); + SInt16 (*GetDisplayName)(const char **displayName); + SInt16 (*GetDropInName)(const char **dropInName); + SInt16 (*GetPanelList)(const CWPanelList **panelList); + SInt16 (*GetFamilyList)(const CWFamilyList **familyList); + SInt16 (*GetHelpInfo)(const CWHelpInfo **helpInfo); + SInt16 (*GetVersionInfo)(const VersionInfo **versionInfo); + SInt16 (*GetFileTypeMappings)(const OSFileTypeMappingList **mappingList); +} BasePluginCallbacks; + +typedef struct CompilerLinkerPluginCallbacks { + SInt16 (*GetTargetList)(const struct CWTargetList **targetList); + SInt16 (*GetDefaultMappingList)(); + SInt16 (*Unmangle)(); + SInt16 (*BrSymbolEntryPoint)(); + SInt16 (*GetObjectFlags)(); + SInt16 (*WriteObjectFile)(); +} CompilerLinkerPluginCallbacks; + +typedef struct ParserPluginCallbacks { + SInt16 (*SupportsPlugin)(); + SInt16 (*SupportsPanels)(); +} ParserPluginCallbacks; + +typedef struct { + char *name; + void *ptr; + SInt32 size; +} PrefDataPanel; // assumed name + +typedef struct { + OSType TYPE; + OSType LANG; + OSType CPU; + OSType OS; + int numPrefPanels; + char **prefPanels; + char *toolInfo; + char *copyright; + int numOptionLists; + OptionList **optionLists; + int numPrefDataPanels; + PrefDataPanel *prefDataPanels; + int (*PreParse)(); // sig? + int (*MidParse)(); // sig? + int (*PostParse)(); // sig? +} ParserTool; // assumed name + +// I think this is internally defined in its .c file +// pro8 mwcc refers to it as =s0 +typedef struct PrefPanel { + char *name; + Handle data; + Handle workData; + struct PrefPanel *next; +} PrefPanel; + +// CLAccessPaths +typedef struct Paths { + struct Path **pathsArray; + UInt16 arraySize; + UInt16 pathsCount; +} Paths; + +typedef struct Frameworks { + struct Paths_FWInfo **fwsArray; + UInt16 arraySize; + UInt16 fwsCount; +} Frameworks; + +typedef struct Path { + OSPathSpec *spec; + Paths *recursive; + char *dirlist; + SInt16 flags; +} Path; + +typedef struct Paths_FWInfo { + OSSpec fileSpec; + OSPathSpec version; + OSPathSpec name; + Path *path; + Boolean hidden; +} Paths_FWInfo; + +// CLDependencies +typedef struct InclFile { + SInt32 filenameoffs; + Path *accesspath; + Path *globalpath; + Path *specialpath; + Boolean syspath; +} InclFile; + +typedef struct Incls { + struct Target *targ; + SInt32 numincls; + SInt32 maxincls; + InclFile *files; + SInt32 buflen; + SInt32 bufpos; + char *buffer; + Paths *allPaths; +} Incls; + +typedef struct Deps { + int numDeps; + int maxDeps; + SInt32 *list; + Incls *incls; +} Deps; + +// CLFiles +typedef struct File { + struct File *next; + SInt32 filenum; + UInt16 segnum; + SInt32 srcmoddate; + SInt32 outmoddate; + char srcfilename[256]; + char outfilename[256]; + SInt16 outfileowner; + OSSpec srcfss; + OSSpec outfss; + SInt16 writeToDisk; + SInt16 wroteToDisk; + SInt16 tempOnDisk; + struct Plugin *compiler; + SInt32 dropinflags; + SInt32 objectflags; + SInt32 mappingflags; + SInt16 sourceUsage; + SInt16 objectUsage; + Handle textdata; + Handle objectdata; + Handle browsedata; + SInt32 codesize; + SInt32 udatasize; + SInt32 idatasize; + SInt32 compiledlines; + Boolean recompileDependents; + Boolean gendebug; + Boolean hasobjectcode; + Boolean hasresources; + Boolean isresourcefile; + Boolean weakimport; + Boolean initbefore; + Boolean mergeintooutput; + Deps deps; + Boolean recordbrowseinfo; + SInt16 browseFileID; + char browseoptions[32]; + OSType filetype; + OSType filecreator; +} File; + +typedef struct Files { + File *fileList; + SInt32 fileCount; +} Files; + +typedef struct VFile { + char displayName[32]; + Handle data; + struct VFile *next; +} VFile; + +// CLOverlays +typedef struct OvlAddr { + UInt32 lo, hi; +} OvlAddr; + +typedef struct Overlay { + char name[256]; + SInt32 *list; + SInt32 cnt; + SInt32 max; + struct Overlay *next; +} Overlay; + +typedef struct OvlGroup { + char name[256]; + OvlAddr addr; + Overlay *olys; + Overlay *lastoly; + int olycnt; + struct OvlGroup *next; +} OvlGroup; + +typedef struct Overlays { + OvlGroup *groups; + OvlGroup *lastgrp; + SInt32 grpcnt; +} Overlays; + +// CLSegs +typedef struct Segment { + char name[32]; + SInt16 attrs; +} Segment; + +typedef struct Segments { + Segment **segsArray; + UInt16 arraySize; + UInt16 segsCount; +} Segments; + +// CLTarg +// Is this actually in Pro7? Not sure +typedef struct CLTargetInfo { + OSType targetCPU; + OSType targetOS; + SInt16 outputType; + SInt16 linkType; + Boolean canRun; + Boolean canDebug; + OSSpec outfile; + OSSpec symfile; + OSSpec runfile; + OSSpec linkAgainstFile; +} CLTargetInfo; +typedef struct CWTargetInfo { + SInt16 outputType; + FSSpec outfile; + FSSpec symfile; + FSSpec runfile; + SInt16 linkType; + Boolean canRun; + Boolean canDebug; + OSType targetCPU; + OSType targetOS; + OSType outfileCreator; + OSType outfileType; + OSType debuggerCreator; + OSType runHelperCreator; + FSSpec linkAgainstFile; +} CWTargetInfo; +typedef struct Target { + struct BuildInfo { + UInt32 linesCompiled; + UInt32 codeSize; + UInt32 iDataSize; + UInt32 uDataSize; + } info; + CWTargetInfo *targetinfo; + struct { + Segments segs; + Overlays overlays; + } linkage; + SInt32 linkmodel; + Files files; + Files pchs; + Incls incls; + Paths sysPaths; + Paths userPaths; + OSType lang; + OSType cpu; + OSType os; + char targetName[64]; + struct Plugin *preLinker; + struct Plugin *linker; + struct Plugin *postLinker; + UInt32 preLinkerDropinFlags; + UInt32 linkerDropinFlags; + UInt32 postLinkerDropinFlags; + OSPathSpec outputDirectory; + VFile *virtualFiles; + struct Target *next; +} Target; + +typedef struct Plugin { + BasePluginCallbacks *cb; + CompilerLinkerPluginCallbacks *cl_cb; + ParserPluginCallbacks *pr_cb; + void *context; + char *cached_ascii_version; + struct Plugin *next; +} Plugin; + +typedef struct Token { + int x0; + void *x4; +} Token; + +/********************************/ +/* command_line/CmdLine/Src/Clients/CLStaticMain.c */ +extern int main(int argc, const char **argv); + +/********************************/ +/* command_line/CmdLine/Src/Clients/ClientGlue.c */ +extern int RegisterResource(const char *name, SInt16 rsrcid, Handle list); +extern int RegisterStaticPlugin(const BasePluginCallbacks *callbacks); +extern int RegisterStaticCompilerLinkerPlugin(const BasePluginCallbacks *callbacks, const CompilerLinkerPluginCallbacks *cl_callbacks); +extern int RegisterStaticParserPlugin(const BasePluginCallbacks *cb, const ParserPluginCallbacks *pr_callbacks); +extern void SetBuildTarget(OSType cpu, OSType os); +extern void SetParserType(OSType plang); +extern void SetPluginType(OSType lang, OSType type); +extern int CmdLine_Initialize(int argc, const char **argv, const char *builddate, const char *buildtime); +extern int CmdLine_Driver(); +extern int CmdLine_Terminate(int exitcode); + +/********************************/ +/* command_line/CmdLine/Src/CLMain.c */ +extern void Main_PreParse(int *pArgc, char ***pArgv); +extern void Main_PassSpecialArgs(void *unk1, void *unk2); +extern int Main_Initialize(int argc, const char **argv); +extern int Main_Terminate(int code); +extern int Main_Driver(); + +/********************************/ +/* command_line/CmdLine/Src/Envir/CLErrors.c */ +extern void CLReportError(SInt16 errid, ...); +extern void CLReportWarning(SInt16 errid, ...); +extern void CLReport(SInt16 errid, ...); +extern void CLReportOSError(SInt16 errid, int err, ...); +extern void CLReportCError(SInt16 errid, int err_no, ...); +extern void CLInternalError(const char *file, int line, const char *format, ...); +extern void CLFatalError(const char *format, ...); + +/********************************/ +/* command_line/CmdLine/Src/Plugins/CLPlugins.c */ +//static void GetToolVersionInfo(); +extern const ToolVersionInfo *Plugin_GetToolVersionInfo(); +//static const char *Plugin_GetDisplayName(Plugin *pl); +extern const char *Plugin_GetDropInName(Plugin *pl); +extern VersionInfo *Plugin_GetVersionInfo(Plugin *pl); +extern const char *Plugin_GetVersionInfoASCII(Plugin *pl); +extern DropInFlags *Plugin_GetDropInFlags(Plugin *pl); +extern OSType Plugin_GetPluginType(Plugin *pl); +extern const CWTargetList *Plugin_CL_GetTargetList(Plugin *pl); +extern const CWPanelList *Plugin_GetPanelList(Plugin *pl); +extern const CWExtMapList *Plugin_CL_GetExtMapList(Plugin *pl); +extern const OSFileTypeMappingList *Plugin_GetFileTypeMappingList(Plugin *pl); +extern const CWObjectFlags *Plugin_CL_GetObjectFlags(Plugin *pl); +extern Boolean Plugin_MatchesName(Plugin *pl, const char *name); +extern Boolean Plugin_CL_MatchesTarget(Plugin *pl, OSType cpu, OSType os, Boolean exact); +extern Boolean Plugins_CL_HaveMatchingTargets(Plugin *p1, Plugin *p2, Boolean exact); +//static CL_MatchesExtMapping(CWExtensionMapping *map, OSType type, const char *ext, Boolean exact); +extern Boolean Plugin_CL_MatchesFileType(Plugin *pl, OSType type, const char *extension, Boolean exact); +extern Boolean Plugin_MatchesType(Plugin *pl, OSType type, OSType lang, Boolean exact); +extern Boolean Plugin_Pr_MatchesPlugin(Plugin *pl, CLPluginInfo *pluginfo, OSType cpu, OSType os); +extern Boolean Plugin_Pr_MatchesPanels(Plugin *pl, int numPanels, char **panelNames); +extern Boolean Plugin_CL_WriteObjectFile(Plugin *pl, FSSpec *src, FSSpec *out, OSType creator, OSType type, OSHandle *data); +extern Boolean Plugin_CL_GetCompilerMapping(Plugin *pl, OSType type, const char *ext, UInt32 *flags); +//static Boolean SupportedPlugin(Plugin *pl, const char **reason); +//static Boolean VerifyPanels(Plugin *pl); +extern Plugin *Plugin_New(const BasePluginCallbacks *cb, const CompilerLinkerPluginCallbacks *cl_cb, const ParserPluginCallbacks *pr_cb); +extern void Plugin_Free(Plugin *pl); +extern int Plugin_VerifyPanels(Plugin *pl); +extern void Plugins_Init(); +extern void Plugins_Term(); +extern int Plugins_Add(Plugin *pl); +extern Plugin *Plugins_MatchName(Plugin *list, const char *name); +extern Plugin *Plugins_CL_MatchTarget(Plugin *list, OSType cpu, OSType os, OSType type, OSType lang); +extern Plugin *Plugins_CL_MatchFileType(Plugin *list, OSType type, const char *ext, Boolean exact); +extern Plugin *Plugins_GetPluginForFile(Plugin *list, OSType plugintype, OSType cpu, OSType os, OSType type, const char *ext, OSType lang); +extern Plugin *Plugins_GetLinker(Plugin *list, OSType cpu, OSType os); +extern Plugin *Plugins_GetPreLinker(Plugin *list, OSType cpu, OSType os); +extern Plugin *Plugins_GetPostLinker(Plugin *list, OSType cpu, OSType os); +extern Plugin *Plugins_GetParserForPlugin(Plugin *list, OSType style, int numPlugins, CLPluginInfo *plugins, OSType cpu, OSType os, int numPanels, char **panelNames); +extern Plugin *Plugins_GetCompilerForLinker(Plugin *list, Plugin *linker, OSType type, const char *ext, OSType edit); +extern Boolean Plugins_GetPluginList(Plugin *list, int *numPlugins, CLPluginInfo **pluginInfo); +extern Boolean Plugins_GetPrefPanelUnion(Plugin *list, int *numPanels, const char ***panelNames); +extern Boolean Plugin_AddFileTypeMappings(Plugin *pl, OSFileTypeMappingList *ftml); +typedef struct OSFileTypeMappings { + OSFileTypeMappingList *mappingList; + struct OSFileTypeMappings *next; +} OSFileTypeMappings; +extern Boolean Plugins_AddFileTypeMappingsForTarget(Plugin *list, OSFileTypeMappings **mlist, OSType cpu, OSType os); +extern SInt16 Plugin_Call(Plugin *pl, void *context); + +/********************************/ +/* command_line/CmdLine/Src/Callbacks/CLParserCallbacks_v1.cpp */ +// haha this is a C++ nightmare + +/********************************/ +/* command_line/CmdLine/Src/Envir/CLIO.c */ +typedef struct MessageRef { + OSSpec sourcefile; + OSSpec errorfile; + char *sourceline; + SInt32 linenumber; + SInt32 tokenoffset; + SInt16 tokenlength; + SInt32 selectionoffset; + SInt16 selectionlength; +} MessageRef; + +extern void SetupDebuggingTraps(); +extern Boolean IO_Initialize(); +extern Boolean IO_Terminate(); +extern Boolean IO_HelpInitialize(); +extern Boolean IO_HelpTerminate(); +extern void FixHandleForIDE(OSHandle *text); +extern Boolean ShowHandle(OSHandle *text, Boolean decorate); +extern Boolean WriteHandleToFile(OSSpec *spec, OSHandle *text, OSType creator, OSType type); +extern Boolean WriteBinaryHandleToFile(OSSpec *spec, OSType maccreator, OSType mactype, OSHandle *text); +extern Boolean AppendHandleToFile(OSSpec *spec, OSHandle *text, OSType maccreator, OSType mactype); +extern void InitWorking(); +extern void ShowWorking(); +extern void TermWorking(); +extern Boolean CheckForUserBreak(); +extern char *IO_FormatText(char *buffer, SInt32 size, char *newline, const char *format, ...); +extern void CLPrintDispatch(SInt16 msgtype, const char *message, FILE *out, char *ptr, char *nptr); +extern void CLPrintType(SInt16 msgtype, ...); +extern void CLPrint(SInt16 msgtype, ...); +extern void CLPrintWarning(SInt16 msgtype, ...); +extern void CLPrintErr(SInt16 msgtype, ...); +extern SInt16 CLStyledMessageDispatch(Plugin *plugin, MessageRef *ref, SInt32 errorNumber, SInt16 msgType); + +/********************************/ +/* command_line/CmdLine/Src/CLToolExec.c */ +extern void AppendArgumentList(int *argc, const char ***argv, const char *str); +// static int CopyArgumentList(int argc, const char **argv, int *Argc, const char ***Argv); +// static int FreeArgumentList(const char **argv); +// static int SetupLinkerCommandLine(SInt32 dropinflags, File *file, CWCommandLineArgs *args); +extern int SetupTemporaries(SInt32 idx, File *file); +extern int DeleteTemporaries(SInt32 idx, File *file); +extern int ExecuteLinker(Plugin *plugin, SInt32 dropinflags, File *file, char *stdoutfile, char *stderrfile); + +/********************************/ +/* command_line/CmdLine/Src/OSLib/Posix.c */ +typedef struct uOSTypePair { + int perm; +} uOSTypePair; // unknown name +extern uOSTypePair OS_TEXTTYPE; +typedef enum { + OSReadOnly, + OSWrite, + OSReadWrite, + OSAppend +} OSOpenMode; // assumed name +typedef enum { + OSSeekRel, + OSSeekAbs, + OSSeekEnd +} OSSeekMode; // assumed name +extern const char *OS_GetErrText(int err); +extern int OS_InitProgram(int *pArgc, const char ***pArgv); +extern int OS_TermProgram(); +extern int OS_Create(const OSSpec *spec, const uOSTypePair *type); +extern int OS_Status(const OSSpec *spec); +extern int OS_GetFileType(const OSSpec *spec, uOSTypePair *type); +extern int OS_SetFileType(const OSSpec *spec, const uOSTypePair *type); +extern int OS_GetFileTime(const OSSpec *spec, time_t *crtm, time_t *chtm); +extern int OS_SetFileTime(const OSSpec *spec, const time_t *crtm, const time_t *chtm); +extern int OS_Open(const OSSpec *spec, OSOpenMode mode, int *ref); +extern int OS_Write(int ref, const void *buffer, UInt32 *length); +extern int OS_Read(int ref, void *buffer, UInt32 *length); +extern int OS_Seek(int ref, OSSeekMode how, SInt32 offset); +extern int OS_Tell(int ref, SInt32 *offset); +extern int OS_Close(int ref); +extern int OS_GetSize(int ref, UInt32 *length); +extern int OS_SetSize(int ref, UInt32 size); +extern int OS_Delete(const OSSpec *spec); +extern int OS_Rename(const OSSpec *oldspec, const OSSpec *newspec); +extern int OS_Mkdir(const OSSpec *spec); +extern int OS_Rmdir(const OSPathSpec *spec); +extern int OS_Chdir(const OSPathSpec *spec); +extern int OS_GetCWD(OSPathSpec *spec); +extern int OS_Execute(const char **argv, const char **envp, const char *stdoutfile, const char *stderrfile, int *exitcode); +extern int OS_IsLegalPath(const char *path); +extern int OS_IsFullPath(const char *path); +extern char *OS_GetDirPtr(char *path); +// static int OS_CompactPath(const char *src, char *dst); +extern int OS_EqualPath(const char *a, const char *b); +extern int OS_CanonPath(const char *src, char *dst); +extern int OS_MakeSpec(const char *path, OSSpec *spec, Boolean *isfile); +extern int OS_MakeFileSpec(const char *path, OSSpec *spec); +extern int OS_MakePathSpec(const char *vol, const char *dir, OSPathSpec *spec); +extern int OS_MakeNameSpec(const char *name, OSNameSpec *spec); +extern int OS_GetRootSpec(OSPathSpec *spec); +extern char *OS_SpecToString(const OSSpec *spec, char *path, int size); +extern char *OS_PathSpecToString(const OSPathSpec *pspec, char *path, int size); +extern char *OS_NameSpecToString(const OSNameSpec *nspec, char *name, int size); +extern int OS_SizeOfPathSpec(const OSPathSpec *spec); +extern int OS_SizeOfNameSpec(const OSNameSpec *spec); +extern int OS_EqualSpec(const OSSpec *a, const OSSpec *b); +extern int OS_EqualPathSpec(const OSPathSpec *a, const OSPathSpec *b); +extern int OS_EqualNameSpec(const OSNameSpec *a, const OSNameSpec *b); +extern int OS_IsDir(const OSSpec *spec); +extern int OS_IsFile(const OSSpec *spec); +extern int OS_IsLink(const OSSpec *spec); +extern int OS_ResolveLink(const OSSpec *link, OSSpec *target); +typedef struct { + void *dir; + OSPathSpec spec; +} OSOpenedDir; // assumed name +extern int OS_OpenDir(const OSPathSpec *spec, OSOpenedDir *ref); +extern int OS_ReadDir(OSOpenedDir *ref, OSSpec *spec, char *filename, Boolean *isfile); +extern int OS_CloseDir(OSOpenedDir *ref); +extern UInt32 OS_GetMilliseconds(); +extern void OS_GetTime(time_t *p); +extern int OS_NewHandle(UInt32 size, OSHandle *hand); +extern int OS_ResizeHandle(OSHandle *hand, UInt32 size); +extern void *OS_LockHandle(OSHandle *hand); +extern void OS_UnlockHandle(OSHandle *hand); +extern int OS_FreeHandle(OSHandle *hand); +extern int OS_GetHandleSize(OSHandle *hand, UInt32 *size); +extern void OS_InvalidateHandle(OSHandle *hand); +extern Boolean OS_ValidHandle(OSHandle *hand); +extern OSErr OS_MacError(int err); +extern void OS_TimeToMac(time_t sectm, UInt32 *secs); +extern void OS_MacToTime(UInt32 secs, time_t *sectm); +extern SInt16 OS_RefToMac(int ref); +extern int OS_MacToRef(SInt16 refnum); +extern int OS_OpenLibrary(const char *a, void **lib); +extern int OS_GetLibrarySymbol(void *a, void *b, void **sym); +extern int OS_CloseLibrary(void *a); +extern int OS_LoadMacResourceFork(const OSSpec *spec, void **file_data, SInt32 *file_len); +extern int OS_IsMultiByte(const char *str, int offset); + +/********************************/ +/* command_line/CmdLine/Src/OSLib/StringExtras.c */ +extern char *strcatn(char *d, const char *s, SInt32 max); +extern char *strcpyn(char *d, const char *s, SInt32 len, SInt32 max); +extern int ustrcmp(const char *src, const char *dst); +extern int ustrncmp(const char *src, const char *dst, UInt32 len); + +/********************************/ +/* command_line/CmdLine/Src/OSLib/Generic.c */ +extern int WildCardMatch(const char *wild, const char *name); +extern OSSpec *OS_MatchPath(const char *path); +extern char *OS_GetFileNamePtr(char *path); +extern char *OS_GetDirName(const OSPathSpec *spec, char *buf, int size); +extern int OS_MakeSpec2(const char *path, const char *filename, OSSpec *spec); +extern int OS_MakeSpecWithPath(OSPathSpec *path, const char *filename, Boolean noRelative, OSSpec *spec); +extern int OS_NameSpecChangeExtension(OSNameSpec *spec, const char *ext, Boolean append); +extern int OS_NameSpecSetExtension(OSNameSpec *spec, const char *ext); +extern char *OS_CompactPaths(char *buf, const char *p, const char *n, int size); +extern char *OS_SpecToStringRelative(const OSSpec *spec, const OSPathSpec *cwdspec, char *path, int size); +extern int OS_FindFileInPath(const char *filename, const char *plist, OSSpec *spec); +extern int OS_FindProgram(const char *filename, OSSpec *spec); +extern int OS_CopyHandle(OSHandle *hand, OSHandle *copy); +extern int OS_AppendHandle(OSHandle *hand, const void *data, UInt32 len); + +/********************************/ +/* command_line/CmdLine/Src/Project/CLProj.c */ +typedef struct Project { + Target *targets; + OSSpec projectDirectory; +} Project; +extern int Proj_Initialize(Project *this); +extern int Proj_Terminate(Project *this); + +/********************************/ +/* command_line/CmdLine/Src/CLLicenses.c */ +extern void License_Initialize(); +extern void License_Terminate(); +extern SInt32 License_Checkout(); +extern void License_Refresh(); +extern void License_Checkin(); +extern void License_AutoCheckin(); + +/********************************/ +/* command_line/CmdLine/Src/OSLib/MemUtils.c */ +extern void *xmalloc(const char *what, int size); +extern void *xcalloc(const char *what, int size); +extern void *xrealloc(const char *what, void *old, int size); +extern char *xstrdup(const char *str); +extern void xfree(void *ptr); + +/********************************/ +/* command_line/CmdLine/Src/CLPluginRequests.cpp */ +extern Boolean SendParserRequest( + Plugin *plugin, + Target *target, + CWCommandLineArgs *args, + OSType cpu, + OSType os, + int numPlugins, + CLPluginInfo *pluginInfo, + int numPanels, + const char **panelNames, + CWCommandLineArgs *plugin_args, + CWCommandLineArgs *panel_args, + const char *build_date, + const char *build_time, + ToolVersionInfo *build_tool + ); +extern Boolean SendCompilerRequest(Plugin *plugin, File *file, SInt16 stage); +extern Boolean SendTargetInfoRequest(Target *targ, Plugin *linker, SInt32 dropinflags); +extern Boolean SendLinkerRequest(Plugin *plugin, SInt32 dropinflags, CWTargetInfo *targetInfo); +extern Boolean SendDisassemblerRequest(Plugin *linker, File *file); +extern Boolean SendInitOrTermRequest(Plugin *plugin, Boolean reqIsInitialize); + +/********************************/ +/* command_line/CmdLine/Src/CLFileOps.c */ +// PRO8 ONLY ??? Boolean CanFlushObjectData(File *file); +// PRO8 ONLY ??? void FlushObjectData(File *file); +// PRO8 ONLY ??? Boolean RetrieveObjectData(File *file); +// static int OutputTextData(File *file, SInt16 stage, OSType maccreator, OSType mactype); +// static int fstrcat(const char *file, const char *add, SInt32 length); +// static void extstrcat(char *file, const char *ext); +extern int GetOutputFile(File *file, SInt16 stage); +// static int SyntaxCheckFile(File *file); +// static int PreprocessFile(File *file); +// static int DependencyMapFile(File *file, Boolean compileifnecessary); +// static int RecordBrowseInfo(File *file); +// static int RecordObjectData(File *file); +extern int StoreObjectFile(File *file); +// static int CompileFile(File *file); +// static int DisassembleWithLinker(File *file, Plugin *linker, SInt32 linkerDropinFlags); +// static int DisassembleFile(File *file, Plugin *disasm); +// static int CompileEntry(File *file, Boolean *compiled); +// static void DumpFileAndPathInfo(); +extern int CompileFilesInProject(); +// static int PostLinkFilesInProject(); +extern int LinkProject(); + +/********************************/ +/* command_line/CmdLine/Src/Project/CLPrefs.c */ +extern PrefPanel *PrefPanel_New(const char *name, void *initdata, SInt32 initdatasize); +extern Handle PrefPanel_GetHandle(PrefPanel *panel); +extern int PrefPanel_PutHandle(PrefPanel *panel, Handle handle); +extern void Prefs_Initialize(); +extern void Prefs_Terminate(); +extern Boolean Prefs_AddPanel(PrefPanel *panel); +extern PrefPanel *Prefs_FindPanel(const char *name); + +/********************************/ +/* command_line/CmdLine/Src/Project/CLTarg.c */ +extern Target *Target_New(const char *name, OSType cpu, OSType os, OSType lang); +extern void Target_Free(Target *targ); +extern void Targets_Term(Target *list); +extern void Target_Add(Target **list, Target *targ); + +/********************************/ +/* command_line/CmdLine/Src/Project/CLAccessPaths.c */ +// 0,40=Path +// 0,41=OSPathSpec +// 0,43=Paths +// 0,44=Path** +// 0,45=Path* +// 0,46=OSPathSpec* +// 0,47=Paths* +// 0,48=Path* +extern Path *Path_Init(const OSPathSpec *dir, Path *path); +extern Path *Path_New(const OSPathSpec *dir); +extern void Path_Free(Path *path); +extern Boolean Paths_Initialize(Paths *paths); +extern Boolean Paths_Terminate(Paths *paths); +//static Boolean Paths_GrowPaths(Paths *paths, UInt16 *index); +extern Boolean Paths_AddPath(Paths *paths, Path *path); +extern Boolean Paths_InsertPath(Paths *paths, UInt16 index, Path *path); +extern Boolean Paths_RemovePath(Paths *paths, UInt16 index); +extern Boolean Paths_DeletePath(Paths *paths, UInt16 index); +extern Path *Paths_GetPath(Paths *paths, UInt16 pathnum); +extern UInt16 Paths_Count(const Paths *paths); +extern Boolean Paths_FindPath(const Paths *paths, const Path *path); +extern Path *Paths_FindPathSpec(const Paths *paths, const OSPathSpec *dir); +//static Boolean GatherRecurse(Paths *paths, Path *path); +extern Boolean Paths_GatherRecurse(Paths *paths); +extern int Paths_CountRecurse(Paths *paths); +//static void CopyRecurseFSS(FSSpec **pFss, Paths *paths, UInt16 *pCount); +extern void Paths_CopyRecurseFSS(FSSpec *fss, Paths *paths, UInt16 count); +//static Boolean Frameworks_Initialize(Frameworks *fws); +//static Boolean Frameworks_Grow(Frameworks *fws, UInt16 *index); +//static Boolean Frameworks_Add(Frameworks *fws, Paths_FWInfo *info); +//static Paths_FWInfo *Framework_Init(OSSpec *dir, const char *name, const char *version, Paths_FWInfo *info, Path *p, Boolean hidden); +//static Paths_FWInfo *Framework_New(OSSpec *dir, const char *name, const char *version, Path *p, Boolean hidden); +//static Boolean CheckForFileInFrameworkDir(char *out, const char *framework_path, OSPathSpec *osps, const char *fname); +//static Boolean CheckForFileInFramework(char *out, int i, const char *fname); +extern Boolean MakeFrameworkPath(char *out, const char *filename, OSPathSpec **globalpath); +extern Boolean Frameworks_AddPath(const OSPathSpec *oss); +extern Boolean Frameworks_AddFramework(const char *frameworkName, const char *version, Boolean flag); +extern void Framework_GetEnvInfo(); +extern int Frameworks_GetCount(); +extern Paths_FWInfo *Frameworks_GetInfo(int which); + +/********************************/ +/* command_line/CmdLine/Src/OSLib/MacSpecs.c */ +// This is pretty much self-contained lol +extern int OS_OSPathSpec_To_VolDir(const OSPathSpec *spec, SInt16 *vRefNum, SInt32 *dirID); +extern int OS_OSSpec_To_FSSpec(const OSSpec *spec, FSSpec *fss); +extern int OS_VolDir_To_OSNameSpec(SInt16 vRefNum, SInt32 dirID, OSNameSpec *spec, SInt32 *parID); +extern int OS_VolDir_To_OSPathSpec(SInt16 vRefNum, SInt32 dirID, OSPathSpec *spec); +extern int OS_FSSpec_To_OSSpec(const FSSpec *fss, OSSpec *spec); +extern int OS_GetRsrcOSSpec(const OSSpec *spec, OSSpec *rspec, Boolean create); + +/********************************/ +/* command_line/CmdLine/Src/OSLib/StringUtils.c */ +extern StringPtr _pstrcpy(StringPtr dst, ConstStringPtr src); +extern void _pstrcat(StringPtr dst, ConstStringPtr src); +extern void _pstrcharcat(StringPtr to, char ch); +extern void pstrncpy(StringPtr to, ConstStringPtr from, int max); +extern void pstrncat(StringPtr to, ConstStringPtr append, int max); +extern int pstrcmp(ConstStringPtr a, ConstStringPtr b); +extern int pstrchr(ConstStringPtr str, char find); +extern void c2pstrcpy(StringPtr dst, const char *src); +extern void p2cstrcpy(char *dst, ConstStringPtr src); +extern char *mvprintf(char *mybuf, unsigned int len, const char *format, va_list va); +extern char *mprintf(char *mybuf, unsigned int len, const char *format, ...); +extern int HPrintF(Handle text, const char *format, ...); + +/********************************/ +/* ??? */ +extern int AddFileTypeMappingList(void *a, void *b); // TODO sig +extern void UseFileTypeMappings(void *a); // TODO sig +extern OSErr SetMacFileType(const FSSpec *fss, void *a); // TODO sig +extern OSErr GetMacFileType(const FSSpec *fss, void *a); // TODO sig + +/********************************/ +/* command_line/CmdLine/Src/Project/CLFiles.c */ +extern File *File_New(); +extern void File_Free(File *file); +extern Boolean Files_Initialize(Files *this); +extern Boolean Files_Terminate(Files *this); +extern Boolean Files_AddFile(Files *this, File *file); +extern Boolean Files_InsertFile(Files *this, File *file, SInt32 position); +extern File *Files_GetFile(Files *this, SInt32 filenum); +extern File *Files_FindFile(Files *this, OSSpec *spec); +extern int Files_Count(Files *this); +extern Boolean VFiles_Initialize(VFile **list); +extern void VFiles_Terminate(VFile **list); +extern VFile *VFile_New(const char *name, OSHandle *data); +extern Boolean VFiles_Add(VFile **list, VFile *entry); +extern VFile *VFiles_Find(VFile *list, const char *name); + +/********************************/ +/* command_line/CmdLine/Src/Project/CLOverlays.c */ +extern Boolean Overlays_Initialize(Overlays *this); +extern Boolean Overlays_Terminate(Overlays *this); +extern Boolean Overlays_AddOvlGroup(Overlays *this, OvlGroup *grp, SInt32 *grpnum); +extern OvlGroup *Overlays_GetOvlGroup(Overlays *this, SInt32 grpnum); +extern SInt32 Overlays_CountGroups(Overlays *this); +extern Boolean Overlays_AddFileToOverlay(Overlays *this, SInt32 grpnum, SInt32 ovlnum, SInt32 filenum); +extern Overlay *Overlays_GetOverlayInGroup(Overlays *this, SInt32 grpnum, SInt32 ovlnum); +extern SInt32 Overlays_GetFileInOverlay(Overlays *this, SInt32 grpnum, SInt32 ovlnum, SInt32 filnum); +extern OvlGroup *OvlGroup_New(const char *name, OvlAddr addr); +extern void OvlGroup_Delete(OvlGroup *grp); +extern Boolean OvlGroup_AddOverlay(OvlGroup *this, Overlay *oly, SInt32 *olynum); +extern Overlay *OvlGroup_GetOverlay(OvlGroup *this, SInt32 olynum); +extern SInt32 OvlGroup_CountOverlays(OvlGroup *this); +extern Overlay *Overlay_New(const char *name); +extern void Overlay_Delete(Overlay *oly); +extern Boolean Overlay_AddFile(Overlay *oly, SInt32 filenum, SInt32 *filnum); +extern SInt32 Overlay_GetFile(Overlay *oly, SInt32 filnul); +extern SInt32 Overlay_CountFiles(Overlay *oly); + +/********************************/ +/* command_line/CmdLine/Src/Project/CLSegs.c */ +extern Segment *Segment_New(const char *name, UInt16 attrs); +extern void Segment_Free(Segment *seg); +extern Boolean Segments_Initialize(Segments *segs); +extern Boolean Segments_Terminate(Segments *segs); +//static Boolean Segments_GrowSegments(Segments *segs, UInt16 *index); +extern Boolean Segments_AddSegment(Segments *segs, Segment *seg, UInt16 *index); +extern Boolean Segments_InsertSegment(Segments *segs, UInt16 index, Segment *seg); +extern Boolean Segments_DeleteSegment(Segments *segs, UInt16 index); +extern Segment *Segments_GetSegment(Segments *segs, UInt16 segnum); +extern UInt16 Segments_Count(const Segments *segs); + +/********************************/ +/* CLDropinCallbacks_V10.cpp */ +// TODO + +/********************************/ +/* command_line/CmdLine/Src/OSLib/MacFileTypes.c */ +extern void OS_AddFileTypeMappingList(OSFileTypeMappings **list, OSFileTypeMappingList *entry); +extern void OS_UseFileTypeMappings(OSFileTypeMappings *list); +extern void OS_MacType_To_OSType(OSType mactype, uOSTypePair *type); +extern int OS_SetMacFileType(const OSSpec *spec, OSType mactype); +extern Boolean OS_GetMacFileTypeMagic(const char *buffer, int count, OSType *mactype); +extern int OS_GetMacFileType(const OSSpec *spec, OSType *mactype); +extern int OS_SetMacFileCreatorAndType(const OSSpec *spec, OSType creator, OSType mactype); + +/********************************/ +/* command_line/CmdLine/Src/OSLib/FileHandles.c */ +//extern int OS_LoadFileHandle(OSFileHandle *hand); +//extern int OS_WriteFileHandle(OSFileHandle *hand); +extern int OS_NewFileHandle(const OSSpec *spec, OSHandle *src, Boolean writeable, OSFileHandle *hand); +extern int OS_LockFileHandle(OSFileHandle *hand, Ptr *ptr, UInt32 *size); +extern int OS_UnlockFileHandle(OSFileHandle *hand); +extern int OS_FreeFileHandle(OSFileHandle *hand); +extern void OS_GetFileHandleSpec(const OSFileHandle *hand, OSSpec *spec); + +/********************************/ +/* command_line/CmdLine/Src/Callbacks/CLCompilerLinkerDropin_V10.cpp */ +// TODO + +/********************************/ +/* command_line/CmdLine/Src/CLDependencies.c */ +extern Boolean Incls_Initialize(Incls *incls, Target *targ); +extern void Incls_Terminate(Incls *incls); +// static Boolean IsSysIncl(Incls *incls, SInt32 idx); +// static void MakeInclFileSpec(Incls *incls, SInt32 idx, OSSpec *spec); +// static Boolean QuickFindFileInIncls(Incls *incls, Boolean fullsearch, const char *filename, OSSpec *spec, SInt32 *index, InclFile **f); +// static Boolean SameIncl(Incls *incls, SInt32 a, SInt32 b); +// static Path *FindOrAddGlobalInclPath(Paths *paths, OSPathSpec *spec); +// static Boolean _FindFileInPath(Path *path, const char *filename, Path **thepath, OSSpec *spec); +// static Boolean FindFileInPaths(Paths *paths, const char *filename, Path **thepath, OSSpec *spec); +// static void AddFileToIncls(Incls *incls, const char *infilename, Boolean syspath, Path *accesspath, Path *globalpath, SInt32 *index); +extern Boolean Incls_FindFileInPaths(Incls *incls, const char *filename, Boolean fullsearch, OSSpec *spec, SInt32 *inclidx); +extern Boolean Deps_Initialize(Deps *deps, Incls *incls); +extern void Deps_Terminate(Deps *deps); +extern int Deps_ChangeSpecialAccessPath(OSSpec *srcfss, Boolean initialize); +extern Path *Deps_GetSpecialAccessPath(); +// static void SetSpecialAccessPathFromIncludeStackTOS(); +// static Boolean FindDepFile(Deps *deps, SInt32 incl); +// static void AddDepFile(Deps *deps, SInt32 incl); +extern void Deps_AddDependency(Deps *deps, SInt32 incl, OSSpec *spec, SInt16 dependencyType); +// static char *EscapeName(Boolean spaces, char *escbuf, const char *path); +extern void Deps_ListDependencies(Incls *incls, File *file, Handle h); + +/********************************/ +/* command_line/CmdLine/Src/CLWriteObjectFile.c */ +extern Boolean WriteObjectFile(File *file, OSType maccreator, OSType mactype); +extern Boolean WriteBrowseData(File *file, OSType maccreator, OSType mactype); + +/********************************/ +/* command_line/CmdLine/Src/CLBrowser.c */ +// GetBrowseTableInfoAndLock +extern int Browser_Initialize(OSHandle *browsetableptr); +//static int Destroy(OSHandle *browsetable); +extern int Browser_Terminate(OSHandle *browsetableptr); +extern int Browser_SearchFile(OSHandle *browsetable, const char *fullpath, SInt16 *ID); +extern int Browser_SearchAndAddFile(OSHandle *browsetable, const char *fullpath, SInt16 *ID); +//static SInt32 CalcDiskSpaceRequirements(...); // needs table type +//static int ConvertMemToDisk(...); // needs table type +extern int Browser_PackBrowseFile(OSHandle *browsedata, OSHandle *browsetable, OSHandle *browsefileptr); + +/********************************/ +/* command_line/CmdLine/Src/CLIncludeFileCache.c */ +// TODO + +/********************************/ +/* ?? Error */ +extern char *GetSysErrText(SInt16 code, char *buffer); + +/********************************/ +/* Might be cc-mach-ppc-mw.c? */ +extern void GetStaticTarget(OSType *cpu, OSType *os); +extern void GetStaticPluginType(OSType *language, OSType *plugintype); +extern void GetStaticParserPluginType(OSType *style); +extern int RegisterStaticTargetResources(); +extern int RegisterStaticTargetPlugins(); + +/********************************/ +/* Might be ParserGlue-mach-ppc-cc.c? */ +extern int RegisterStaticParserToolInfo(); + +/********************************/ +/* Might be cc-mach-ppc.c? */ +extern CW_PASCAL SInt16 CWPlugin_GetDropInFlags(const DropInFlags **flags, SInt32 *flagsSize); +extern CW_PASCAL SInt16 CWPlugin_GetTargetList(const CWTargetList **targetList); +extern CW_PASCAL SInt16 CWPlugin_GetDropInName(const char **dropinName); +extern CW_PASCAL SInt16 CWPlugin_GetDisplayName(const char **displayName); +extern CW_PASCAL SInt16 CWPlugin_GetDefaultMappingList(const CWExtMapList **defaultMappingList); +extern CW_PASCAL SInt16 CWPlugin_GetPanelList(const CWPanelList **panelList); +//_CmdLine_GetObjectFlags +//_CWPlugin_GetVersionInfo +//_CWPlugin_GetFileTypeMappings +//_Linker_GetDropInFlags +//_Linker_GetDropInName +//_Linker_GetDisplayName +//_Linker_GetPanelList +//_Linker_GetTargetList +//_Linker_GetDefaultMappingList +extern int RegisterStaticCompilerPlugin(); +extern int RegisterCompilerResources(); + +/********************************/ +/* libimp-mach-ppc.c */ +// some statics here +extern int RegisterStaticLibImporterPlugin(); +extern int RegisterLibImporterResources(); + +/********************************/ +/* TargetOptimizer-ppc-mach.c */ +extern int TargetSetOptFlags(SInt16 val, Boolean set); +extern void TargetDisplayOptimizationOptions(Handle txt); +extern void TargetSetPragmaOptimizationsToUnspecified(); + +/********************************/ +/* OptimizerHelpers.c */ +extern int SetPragmaOptimizationsToUnspecified(); +extern int SetOptFlags(char *opt, void *str, ...); // two unknown args +extern int DisplayOptimizationOptions(); + +/********************************/ +/* Unk name lol */ +extern int TargetSetWarningFlags(SInt16 val, Boolean set); +extern int TargetDisplayWarningOptions(Handle txt); + +/********************************/ +/* WarningHelpers.c */ +extern int SetWarningFlags(char *opt, void *str, ...); // two unknown args +extern int DisplayWarningOptions(); + +/********************************/ +/* CCompiler.c */ + +// LOTS OF STUFF + +/********************************/ +/* StaticParserGlue.c */ +extern int RegisterStaticParserResources(); +extern int RegisterStaticParserPlugins(); + +/********************************/ +/* ParserFace.c */ +extern Handle Parser_FindPrefPanel(char *name); +extern SInt32 Parser_StorePanels(struct CWPluginPrivateContext *context); +extern SInt16 CWParser_GetDropInFlags(const DropInFlags **flags, SInt32 *flagsSize); +extern SInt16 CWParser_GetDropInName(const char **dropinName); +extern SInt16 CWParser_GetDisplayName(const char **displayName); +extern SInt16 CWParser_GetPanelList(const CWPanelList **panelList); +extern SInt16 CWParser_GetTargetList(const CWTargetList **targetList); +extern SInt16 CWParser_GetVersionInfo(const VersionInfo **versioninfo); +extern SInt16 Parser_SupportsPlugin(struct CLPluginInfo *pluginfo, OSType cpu, OSType os, Boolean *isSupported); +extern SInt16 Parser_SupportsPanels(int numPanels, char **panelNames, Boolean *isSupported); +extern SInt16 parser_main(struct CWPluginPrivateContext *context); + +extern struct ParseOptsType parseopts; + +/********************************/ +/* ParserHelpers.c */ +extern int FindFileInPath(const char *filename, OSSpec *fss); +extern char *GetEnvVar(const char *name, Boolean warn, char **match); +//static Boolean MatchesExtension(const char *list, const char *filename); +extern int Opt_AddAccessPath(const char *opt, void *var, const char *arg); +extern int Opt_AddFrameworkPath(const char *opt, void *var, const char *arg); +extern int Opt_AddFramework(const char *opt, void *var, const char *arg); +extern void ListParseMessage(void *errprint, const char *envvar, SInt16 id); // TODO funcptr sig - same as CLPReportWarning_V, CLPReportError_V +extern int AddAccessPathList(const char *list, char sep1, char sep2, int source, char *text, Boolean system, SInt32 position, Boolean recursive); +extern int Opt_FindAndAddFile(const char *opt, void *var, const char *arg); +extern int Opt_FindAndAddFileRef(const char *opt, void *var, const char *arg); +extern int Opt_AddUnixLibraryFile(const char *opt, void *var, const char *arg); +extern int AddFileList(const char *list, char sep1, char sep2, int source, char *text, SInt32 position); +extern int IsFileInOutputDirectory(const OSSpec *file); +extern void GetCFileNameInOutputDirectory(const char *input, char *name, int maxlen); +extern void GetPFileNameInOutputDirectory(const char *input, unsigned char *name, int len); +extern void AddStringLenToHandle(Handle h, const char *str, int len); +extern void AddStringToHandle(Handle h, const char *str); +extern int Opt_PrintVersion(const char *opt, void *var, const char *arg); +extern void GetFirstSourceFilenameBase(char *buffer, char *defaul); +extern int Opt_SavePrefs(const char *opt, void *var, const char *arg); +extern int ParseNumber(const char *arg, Boolean emit_error, SInt32 *ret, const char **endptr); +extern int Opt_MaybeMoveAccessPaths(const char *opt, void *var, const char *arg); + +/********************************/ +/* ToolHelpers.c */ +extern int Opt_HandleOutputName(const char *opt, void *, const char *filename); +extern int ValidateToolState(Boolean mustHaveFiles); +extern void ToolReportMessage(SInt16 errid, SInt16 type, va_list va); +extern void ToolReportWarning(SInt16 id, ...); +extern void ToolReportError(SInt16 id, ...); +extern void ToolReportOSError(SInt16 id, ...); +extern void ToolReportInfo(SInt16 id, ...); +extern int Opt_DoNotLink(const char *opt, void *var, const char *arg); +extern int Opt_IncreaseVerbosity(const char *opt, void *var, const char *arg); +extern int Opt_SetStage(const char *opt, void *str, const char *arg, void *unk); +// lots of the Opt_ funcs have weird sigs, need to double check them +extern int Opt_RedirectStream(const char *opt, void *file, const char *filename); + +/********************************/ +/* ParserHelpers-cc.c */ +typedef struct { + void *value; + const char *pragma; + int flags; +} Pragma; // assumed name +extern int Opt_AddStringToDefines(const char *opt, void *str, const char *param); +extern int Opt_DefineSymbol(const char *var, const char *value); +extern int Opt_UndefineSymbol(const char *opt, void *, const char *arg); +extern int Opt_AddPrefixFile(const char *opt, void *handle, const char *filename); +extern int Opt_PragmaTrueFalse(const char *, void *flag, const char *, int flags); +extern int Opt_PragmaFalseTrue(const char *, void *flag, const char *, int flags); +extern int Opt_PragmaOnOff(const char *, void *flag, const char *arg); +extern int Opt_PragmaOffOn(const char *, void *flag, const char *arg); +extern int SetupPragmas(const Pragma *pragmas); + +/********************************/ +/* Arguments.c */ +typedef struct { + SInt16 val; + char *text; +} ArgToken; +enum { + ATK_0, + ATK_1, + ATK_2, + ATK_3, + ATK_4, + ATK_5 +}; +typedef struct { + int argc; + int nargv; + char **argv; +} anon0_50; + +extern void Arg_Init(int theargc, char **theargv); +extern void Arg_Terminate(); +extern void Arg_Reset(); +extern void Arg_Stop(ArgToken *where); +extern ArgToken *Arg_PeekToken(); +extern ArgToken *Arg_UsedToken(); +extern int Arg_IsEmpty(); +extern ArgToken *Arg_GetToken(); +extern ArgToken *Arg_UndoToken(); +extern const char *Arg_GetTokenName(ArgToken *tok); +extern const char *Arg_GetTokenText(ArgToken *tok, char *buffer, int maxlen, unsigned char warn); +extern void Arg_InitToolArgs(anon0_50 *ta); +extern void Arg_AddToToolArgs(anon0_50 *ta, SInt16 tokval, char *toktxt); +extern void Arg_FinishToolArgs(anon0_50 *ta); +extern void Arg_ToolArgsForPlugin(anon0_50 *ta, struct CWCommandLineArgs *args); +extern void Arg_FreeToolArgs(anon0_50 *ta); + +/********************************/ +/* ToolHelpers-cc.c */ +extern int Opt_DummyLinkerRoutine(const char *opt); +extern int Opt_DummyLinkerSettingRoutine(const char *var, const char *val); +extern void FinishCompilerTool(); + +/********************************/ +/* IO.c */ +extern void ShowTextHandle(const char *description, Handle text); +extern void ShowVersion(Boolean decorate); + +/********************************/ +/* Projects.c */ +extern int GetFileCount(); +extern void SetFileOutputName(SInt32 position, SInt16 which, char *outfilename); +extern int AddFileToProject(OSSpec *oss, SInt16 which, char *outfilename, Boolean exists, SInt32 position); +extern Boolean GetFileInfo(SInt32 position, OSSpec *spec, char *plugin); +extern int AddAccessPath(const OSPathSpec *oss, SInt16 type, SInt32 position, Boolean recursive); +extern int MoveSystemPathsIntoUserList(); +extern void AddVirtualFile(const char *filename, Handle *text); +extern void GetOutputFileDirectory(OSPathSpec *dir); +extern void SetOutputFileDirectory(const OSPathSpec *dir); +extern void AddOverlayGroup(const char *name, OvlAddr *addr, SInt32 *groupnum, SInt32 *overlaynum); +extern void AddOverlay(SInt32 groupnum, const char *name, SInt32 *overlaynum); +extern void AddSegment(const char *name, SInt16 attrs, SInt32 *segmentnum); +extern void ChangeSegment(SInt32 segmentnum, const char *name, SInt16 attrs); +extern int GetSegment(SInt32 segmentnum, char *name, SInt16 *attrs); + +/********************************/ +/* Targets.c */ +extern int SetParserToolInfo(ParserTool *tool); +extern Boolean ParserToolMatchesPlugin(OSType type, OSType lang, OSType cpu, OSType os); +extern Boolean ParserToolHandlesPanels(int numPanels, const char **panelNames); +extern Boolean SetupParserToolOptions(); + +/********************************/ +/* Option.c */ +typedef struct { + void *first; + void *second; +} Opt50; +typedef struct { + Option *opt; + char *curopt; +} Opt52; +typedef struct { + union { + Opt50 v; + OptionList *lst; + Opt52 o; + char *param; + } e; + SInt16 flags; +} Opt48; +//static void Option_PushList(OptionList *lst); +//static void Option_PushOpt(Option *opt, const char *optname); +//static void Option_PopOpt(const char *optname); +//static void Option_PopList(); +extern void Args_InitStack(); +extern int Args_StackSize(); +extern void Args_Push(SInt16 flags, void *first, void *second); +extern Opt48 *Args_Pop(SInt16 flags); +extern void Args_SpellStack(char *buffer, SInt16 flags); +extern void Args_AddToToolArgs(anon0_50 *ta); +extern void Options_Init(); +extern OptionList *Options_GetOptions(); +extern void Options_SortOptions(); +//static void Options_AddOption(Option *opt); +extern int Options_AddList(OptionList *optlst); +extern int Options_AddLists(OptionList **optlst); +//static void Options_Reset(OptionList *optlst); +//static void Option_SpellList(char *buffer, OptionList *conflicts, int flags); +extern int Option_ForTool(Option *opt, int which); +extern int Option_ThisTool(); +extern int Option_ForThisTool(Option *opt); +extern int Option_AlsoPassedToTool(Option *opt, int which); +extern int Option_AlsoPassedFromThisTool(Option *opt); +//static Boolean Option_ContinuesThisLevel(int level, ArgToken *tok); +//static Boolean Option_IsEndingThisLevel(int level, ArgToken *tok); +//static Boolean Option_IsEndingLevel(int level, ArgToken *tok); +extern int Option_Parse(Option *opt, int oflags); +//static int Option_MatchString(char *list, char *str, int flags, int *result); +//static Option *Option_Lookup(OptionList *search, void *unk, int *flags); +//static int Options_DoParse(OptionList *search, int flags); +extern int Options_Parse(OptionList *options, int flags); +extern int Option_ParseDefaultOption(OptionList *options); +extern void Option_ParamError(SInt16 id, va_list ap); +extern void Option_ParamWarning(SInt16 id, va_list ap); +extern void Option_OptionError(SInt16 id, va_list ap); +extern void Option_OptionWarning(SInt16 id, va_list ap); +extern void Option_Error(SInt16 id, ...); +extern void Option_Warning(SInt16 id, ...); +extern int Options_Help(const char *keyword); +extern int Option_Help(const char *opt); +extern int Options_DisplayHelp(); + +/********************************/ +/* ParserErrors.c */ +extern void CLPReportError_V(const char *format, va_list ap); +extern void CLPReportWarning_V(const char *format, va_list ap); +extern void CLPReport_V(const char *format, va_list ap); +extern void CLPStatus_V(const char *format, va_list ap); +extern void CLPAlert_V(const char *format, va_list ap); +extern void CLPOSAlert_V(const char *format, SInt32 err, va_list ap); +extern void CLPGetErrorString(SInt16 errid, char *buffer); +extern void CLPReportError(SInt16 errid, ...); +extern void CLPReportWarning(SInt16 errid, ...); +extern void CLPReport(SInt16 errid, ...); +extern void CLPAlert(SInt16 errid, ...); +extern void CLPOSAlert(SInt16 errid, SInt16 err, ...); +extern void CLPProgress(SInt16 errid, ...); +extern void CLPStatus(SInt16 errid, ...); +extern void CLPFatalError(const char *format, ...); + +extern char curopt[1024]; + +/********************************/ +/* Utils.c */ +// something is weird with these parameters +// they're supposed to be just "char"... +extern int my_tolower(unsigned char c); +extern int my_isdigit(unsigned char c); +extern int my_isalpha(unsigned char c); +extern int my_isalnum(unsigned char c); +extern int my_isxdigit(unsigned char c); +extern char *Utils_SpellList(char *list, char *buffer, char opts); +extern int Utils_CompareOptionString(const char *a, const char *b, int cased, int sticky); + +/********************************/ +/* Parameter.c */ +extern void Param_DescHelp(PARAM_T *param, const char **desc, const char **help, const char **defaul); +extern int Param_Compare(PARAM_T *param); +extern int Params_Parse(PARAM_T *param, int flags); +extern void Param_Error(SInt16 id, ...); +extern void Param_Warning(SInt16 id, ...); + +/********************************/ +/* Help.c */ +extern int Help_Option(struct OptionList *lst, struct Option *opt, int subprint, const char *keyword); +extern void Help_Options(struct OptionList *lst, int subprint, const char *keyword); +extern void Help_Usage(); +extern void Help_Null(); +extern void Help_Init(); +extern void Help_Line(char ch); +extern void Help_Term(); + +/********************************/ +/* */ + +/********************************/ +/* */ + +/********************************/ +/* ?? COS */ +// static COS_pstrcpy +// static COS_pstrcat +// static COS_pstrcharcat +// static COS_pstrcmp +extern Handle COS_NewHandle(SInt32 byteCount); +extern Handle COS_NewOSHandle(SInt32 logicalSize); +extern void COS_FreeHandle(Handle handle); +extern Boolean COS_ResizeHandle(Handle handle, SInt32 newSize); +extern SInt32 COS_GetHandleSize(Handle handle); +extern void COS_LockHandle(Handle handle); +extern void COS_LockHandleHi(Handle handle); +extern void COS_UnlockHandle(Handle handle); +extern int COS_GetHandleState(Handle handle); +extern void COS_SetHandleState(Handle handle, int state); +extern Boolean COS_IsLockedState(int state); +extern char *COS_NewPtr(SInt32 byteCount); +extern char *COS_NewPtrClear(SInt32 byteCount); +extern void COS_FreePtr(char *ptr); +extern void COS_AppendPtrToHandle(char *ptr1, Handle hand2, SInt32 size); +extern OSErr COS_GetMemErr(); +extern SInt32 COS_GetTicks(); +extern SInt32 COS_GetTime(); +extern void COS_GetString(char *buffer, SInt16 strListID, SInt16 index); +extern void COS_GetPString(unsigned char *buffer, SInt16 strListID, SInt16 index); +extern Boolean COS_IsMultiByte(char *buffer, char *str); +extern SInt16 COS_FileNew(const FSSpec *spec, SInt16 *refNum, OSType creator, OSType fileType); +extern SInt16 COS_FileOpen(const FSSpec *spec, SInt16 *refNum); +extern SInt16 COS_FileGetType(const FSSpec *spec, OSType *fileType); +extern SInt16 COS_FileGetSize(SInt16 refNum, SInt32 *logEOF); +extern SInt16 COS_FileRead(SInt16 refNum, void *buffPtr, SInt32 count); +extern SInt16 COS_FileWrite(SInt16 refNum, const void *buffPtr, SInt32 count); +extern SInt16 COS_FileGetPos(SInt16 refNum, SInt32 *filePos); +extern SInt16 COS_FileSetPos(SInt16 refNum, SInt32 filePos); +extern SInt16 COS_FileClose(SInt16 refNum); +extern void COS_FileSetFSSpec(FSSpec *spec, unsigned char *path); +extern SInt16 COS_FileMakeFSSpec(SInt16 vRefNum, SInt32 dirID, unsigned char *fileName, FSSpec *spec); +extern SInt16 COS_FileMakeFSSpecWithPath(const FSSpec *inputSpec, unsigned char *fileName, FSSpec *spec); +extern SInt16 COS_FileGetFileInfo(const FSSpec *spec, OSType *creator, OSType *fileType); +extern void COS_FileGetFSSpecInfo(const FSSpec *spec, SInt16 *vRefNum, SInt32 *dirID, unsigned char *fileName); +//static void COS_MakePath(SInt16 vRefNum, SInt32 dirID, char *path); +extern void COS_FileGetPathName(char *buffer, const FSSpec *spec, SInt32 *mdDat); +extern Boolean COS_EqualFileSpec(const FSSpec *a, const FSSpec *b); + +/********************************/ +/* MacEmul - ErrMgr */ +extern char *GetSysErrText(SInt16 msgNbr, char *errMsg); + +/********************************/ +/* MacEmul - Files */ +extern OSErr HCreate(SInt16 volume, SInt32 dirid, ConstStr255Param fileName, OSType creator, OSType type); +extern OSErr HOpen(SInt16 vRefNum, SInt32 dirID, ConstStr255Param fileName, SInt8 permission, SInt16 *refNum); +extern OSErr HOpenDF(SInt16 vRefNum, SInt32 dirID, ConstStr255Param fileName, SInt8 permission, SInt16 *refNum); +extern OSErr HDelete(SInt16 vRefNum, SInt32 dirID, ConstStr255Param fileName); +extern OSErr HRename(SInt16 vRefNum, SInt32 dirID, ConstStr255Param oldName, ConstStr255Param newName); +extern OSErr HGetFInfo(SInt16 vRefNum, SInt32 dirID, ConstStr255Param fileName, FInfo *fndrInfo); +extern OSErr HSetFInfo(SInt16 vRefNum, SInt32 dirID, ConstStr255Param fileName, const FInfo *fndrInfo); +extern OSErr FSpCreate(const FSSpec *fss, OSType creator, OSType fileType, ScriptCode scriptTag); +extern OSErr FSpDirCreate(const FSSpec *fss, ScriptCode scriptTag, SInt32 *createdDirID); +extern OSErr FSpOpenDF(const FSSpec *fss, SInt8 permission, SInt16 *refNum); +extern OSErr FSpDelete(const FSSpec *fss); +extern OSErr FSpRename(const FSSpec *oldfss, ConstStr255Param newName); +extern OSErr FSpGetFInfo(const FSSpec *fss, FInfo *fndrInfo); +extern OSErr FSpSetFInfo(const FSSpec *fss, const FInfo *fndrInfo); +extern OSErr HGetVol(StringPtr volName, SInt16 *vRefNum, SInt32 *dirID); +extern OSErr HSetVol(ConstStr63Param volName, SInt16 vRefNum, SInt32 dirID); +extern OSErr FlushVol(ConstStr63Param volName, SInt16 vRefNum); +extern OSErr FSRead(SInt16 fRefNum, SInt32 *Size, void *Buffer); +extern OSErr FSWrite(SInt16 fRefNum, SInt32 *Size, const void *Buffer); +extern OSErr FSClose(SInt16 fRefNum); +extern OSErr GetEOF(SInt16 fRefNum, SInt32 *curEOF); +extern OSErr SetEOF(SInt16 fRefNum, SInt32 newEOF); +extern OSErr GetFPos(SInt16 fRefNum, SInt32 *pos); +extern OSErr SetFPos(SInt16 fRefNum, SInt16 posMode, SInt32 posOffset); +extern OSErr GetVInfo(SInt16 vRefNum, StringPtr name, SInt16 *vRef, SInt32 *hDir); +extern OSErr PBWriteSync(ParmBlkPtr paramBlock); +extern OSErr PBHGetFInfoSync(HParmBlkPtr paramBlock); +extern OSErr PBHSetFInfoSync(HParmBlkPtr paramBlock); +extern OSErr PBGetCatInfoSync(CInfoPBPtr paramBlock); +extern OSErr ResolveAliasFile(FSSpec *fss, Boolean resolveChains, Boolean *isFolder, Boolean *wasAliased); +extern OSErr FSMakeFSSpec(SInt16 vRefNum, SInt32 dirID, ConstStr255Param pathName, FSSpec *fss); +extern OSErr Allocate(SInt16 refNum, SInt32 *byteCount); + +/********************************/ +/* MacEmul - LowMem */ +extern UInt32 LMGetTicks(); +extern UInt32 LMGetTime(); +extern OSErr LMGetMemErr(); +extern void LMSetMemErr(OSErr value); + +/********************************/ +/* MacEmul - Memory */ +extern OSHandle *OS_PeekMacHandle(Handle h); +extern Handle OS_CreateMacHandle(OSHandle *h); +extern Handle OS_CreateMacHandleDup(OSHandle *h); +extern void OS_DestroyMacHandle(Handle h, OSHandle *ret); + +extern OSErr MemError(); +extern Handle NewHandle(SInt32 dataSize); +extern Handle NewHandleClear(UInt32 dataSize); +extern Handle TempNewHandle(UInt32 dataSize, OSErr *resultCode); +extern void DisposeHandle(Handle h); +extern void HLock(Handle h); +extern void HLockHi(Handle h); +extern void HUnlock(Handle h); +extern void HPurge(Handle theHandle); +extern void HNoPurge(Handle theHandle); +extern SInt8 HGetState(Handle theHandle); +extern void HSetState(Handle theHandle, SInt8 flags); +extern SInt32 GetHandleSize(Handle h); +extern void SetHandleSize(Handle h, SInt32 newSize); +extern OSErr PtrAndHand(const void *srcPtr, Handle destHandle, SInt32 size); +extern OSErr PtrToHand(const void *srcPtr, Handle *destHandle, SInt32 size); +extern OSErr HandToHand(Handle *destHandle); +extern OSErr HandAndHand(Handle src, Handle dst); +extern void MoveHHi(Handle theHandle); +extern void BlockMove(const void *srcPtr, void *destPtr, UInt32 byteCount); +extern void BlockMoveData(const void *srcPtr, void *destPtr, UInt32 byteCount); +extern Ptr NewPtr(SInt32 dataSize); +extern void DisposePtr(Ptr p); +extern Ptr NewPtrClear(SInt32 dataSize); +extern void DebugStr(ConstStringPtr str); +extern struct Zone *HandleZone(); +extern struct Zone *ApplicationZone(); + +/********************************/ +/* MacEmul - Resources */ +extern Boolean OS_UsingMacResourceForkInfo(); +extern void OS_UseMacResourceForkInfo(Boolean which); +extern OSErr SystemInitResources(OSSpec *spec); +extern void OS_AddMacResourceForkRef(int ref, const OSSpec *spec); +extern void OS_RemoveMacResourceForkRef(int ref); +extern OSSpec *OS_GetMacResourceForkFromRef(int ref); +extern Boolean OS_SearchMacResourceForkList(const OSSpec *rspec, int *ref); +extern int OS_SetMacResourceForkCreatorAndType(int ref, OSType creator, OSType type); +extern int OS_GetMacResourceForkCreatorAndType(int ref, OSType *creator, OSType *type); +extern void OS_CleanupMacResourceForkDir(const OSPathSpec *dir); +extern OSErr OS_MacDumpResourceFork(SInt16 ref, Boolean dumpContents); +extern OSErr FSpOpenRF(const FSSpec *fss, SInt8 permission, SInt16 *refNum); +extern OSErr HOpenRF(SInt16 vRefNum, SInt32 dirID, ConstStringPtr fileName, SInt8 permission, SInt16 *refNum); +extern OSErr InitResources(); +extern OSErr ResError(); +extern void FSpCreateResFile(const FSSpec *fss, OSType creator, OSType fileType, ScriptCode scriptTag); +extern void HCreateResFile(SInt16 vRefNum, SInt32 dirID, ConstStringPtr fileName); +extern OSErr FSpOpenResFile(const FSSpec *fss, SInt8 permission); +extern SInt16 HOpenResFile(SInt16 vRefNum, SInt32 dirID, ConstStringPtr fileName, SInt8 permission); +extern SInt16 CurResFile(); +extern void UseResFile(SInt16 refNum); +extern SInt16 HomeResFile(Handle theResource); +extern Handle GetResource(OSType theType, SInt16 theID); +extern Handle Get1Resource(OSType theType, SInt16 theID); +extern Handle GetNamedResource(OSType theType, ConstStringPtr theName); +extern Handle Get1NamedResource(OSType theType, ConstStringPtr theName); +extern void SetResLoad(Boolean load); +extern void MacEmul_LoadResource(Handle theResource); +extern void GetResInfo(Handle theResource, SInt16 *theID, OSType *theType, StringPtr name); +extern void SetResInfo(Handle theResource, SInt16 theID, ConstStringPtr name); +extern SInt16 GetResAttrs(Handle theResource); +extern void SetResAttrs(Handle theResource, SInt16 attrs); +extern void ChangedResource(Handle theResource); +extern void AddResource(Handle theData, OSType theType, SInt16 theID, ConstStringPtr name); +extern void UpdateResFile(SInt16 refnum); +extern void WriteResource(Handle theResource); +extern void SetResPurge(Boolean install); +extern SInt16 CountResources(OSType theType); +extern SInt16 Count1Resources(OSType theType); +extern Handle GetIndResource(OSType theType, SInt16 index); +extern Handle Get1IndResource(OSType theType, SInt16 index); +extern SInt16 Count1Types(); +extern void Get1IndType(OSType *theType, SInt16 index); +extern void ReleaseResource(); +extern void DetachResource(Handle theResource); +extern void RemoveResource(Handle theResource); +extern void CloseResFile(SInt16 refNum); +extern SInt16 GetResFileAttrs(SInt16); +extern Boolean LMGetResLoad(); + +/********************************/ +/* MacEmul - ResourceStrings */ +extern void Res_Initialize(); +extern int Res_AddResource(const char *name, SInt16 rsrcid, const char **strings); +extern const char *Res_GetResource(SInt16 rsrcid, SInt16 index); +extern void Res_Cleanup(); + +/********************************/ +/* MacEmul - TextUtils */ +extern StringPtr c2pstr(char *s); +extern char *p2cstr(StringPtr s); +extern SInt16 CharacterByteType(Ptr textBuf, SInt16 textOffset, ScriptCode script); +extern SInt16 CharByte(); +extern void GetDateTime(UInt32 *secs); +extern Boolean EqualString(ConstStr255Param strA, ConstStr255Param strB, Boolean caseSens, Boolean diacSens); +extern void GetIndString(Str255 theString, SInt16 strListID, SInt16 index); +extern char *getindstring(char *theString, SInt16 strListID, SInt16 index); +extern void NumToString(SInt32 theNum, Str255 theString); +extern void StringToNum(ConstStr255Param theString, SInt32 *theNum); + +// TODO sort me +extern Project *gProj; +extern ParserTool *pTool; +extern PCmdLine optsCmdLine; +extern PCmdLineEnvir optsEnvir; +extern PCmdLineCompiler optsCompiler; +extern PCmdLineLinker optsLinker; +extern CLState clState; + +/********************************/ +/* CmdLineBuildDate.c */ +extern char CMDLINE_BUILD_DATE[]; +extern char CMDLINE_BUILD_TIME[]; + + +/********************************/ +/* MISC */ +extern char cmdline_build_date[32]; +extern char cmdline_build_time[32]; + +extern StringPtr pstrcpy(StringPtr dst, ConstStringPtr src); +extern int (*PrefPanelsChangedCallback)(const char *); +extern Boolean systemHandles; +extern char *MAINOPTCHAR; +extern char *SEPOPTSTR; +extern char compat; +extern anon0_50 linkargs; + +#ifdef __cplusplus +} +#endif diff --git a/mwcc_decomp.h b/mwcc_decomp.h deleted file mode 100644 index dcafa5b..0000000 --- a/mwcc_decomp.h +++ /dev/null @@ -1,1879 +0,0 @@ -#pragma once -#include -#define macintosh -#include "sdk_hdrs/CompilerMapping.h" -#include "sdk_hdrs/DropInCompilerLinker.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/********************************/ -/* OS Garbage */ -typedef struct OSPathSpec { - char s[256]; -} OSPathSpec; -typedef struct OSNameSpec { - char s[64]; -} OSNameSpec; -typedef struct OSSpec { - OSPathSpec path; - OSNameSpec name; -} OSSpec; -typedef struct OSHandle { - void *addr; - unsigned long used; - unsigned long size; -} OSHandle; -typedef struct { - OSSpec spec; - OSHandle hand; - unsigned char loaded; - unsigned char changed; - unsigned char writeable; -} OSFileHandle; // assumed name - -/********************************/ -/* Option Fuckery */ -#ifdef __MWERKS__ -#pragma options align=packed -#endif -typedef struct PARAM_T { - char which; - char flags; - char *myname; - struct PARAM_T *next; -} PARAM_T; -typedef struct MASK_T { - char which; - char flags; - char *myname; - PARAM_T *next; - char size; - unsigned long ormask; - unsigned long andmask; - void *num; -} MASK_T; -typedef struct STRING_T { - char which; - char flags; - char *myname; - PARAM_T *next; - short maxlen; - unsigned char pstring; - char *str; -} STRING_T; -typedef struct SET_T { - char which; - char flags; - char *myname; - PARAM_T *next; - char size; - unsigned long value; - char *num; -} SET_T; -typedef struct SETSTRING_T { - char which; - char flags; - char *myname; - PARAM_T *next; - char *value; - char pstring; - void *var; -} SETSTRING_T; -typedef struct GENERIC_T { - char which; - char flags; - char *myname; - PARAM_T *next; - int (*parse)(const char *opt, void *var, const char *pstr, int flags); - void *var; - char *help; -} GENERIC_T; -typedef struct SETTING_T { - char which; - char flags; - char *myname; - PARAM_T *next; - int (*parse)(const char *a, const char *b); // TODO name these args - char *valuename; -} SETTING_T; -typedef struct TOGGLE_T { - char which; - char flags; - char *myname; - PARAM_T *next; - char size; - unsigned long mask; - void *num; -} TOGGLE_T; -typedef struct NUM_T { - char which; - char flags; - char *myname; - PARAM_T *next; - char size; - char fit; - unsigned long lo; - unsigned long hi; - void *num; -} NUM_T; -typedef struct FILEPATH_T { - char which; - char flags; - char *myname; - PARAM_T *next; - char fflags; - char *defaultstr; - void *filename; - int maxlen; -} FILEPATH_T; -typedef struct IFARG_T { - char which; - char flags; - char *myname; - PARAM_T *next; - PARAM_T *parg; - char *helpa; - PARAM_T *pnone; - char *helpn; -} IFARG_T; -typedef struct ONOFF_T { - char which; - char flags; - char *myname; - PARAM_T *next; - unsigned char *var; -} ONOFF_T; -typedef struct OFFON_T { - char which; - char flags; - char *myname; - PARAM_T *next; - unsigned char *var; -} OFFON_T; -typedef struct FTYPE_T { - char which; - char flags; - char *myname; - PARAM_T *next; - unsigned long *fc; - unsigned char iscreator; -} FTYPE_T; -typedef struct OptionList { - char *help; - int flags; - struct Option **list; -} OptionList; -typedef struct Option { - char *names; - int avail; - PARAM_T *param; - OptionList *sub; - OptionList *conflicts; - char *help; -} Option; -enum { - HELPFLAGS_1 = 1, - HELPFLAGS_IGNORED = 2, - HELPFLAGS_OBSOLETE = 4, - HELPFLAGS_DEPRECATED = 8, - HELPFLAGS_SECRET = 0x10, - HELPFLAGS_MEANINGLESS = 0x20, - HELPFLAGS_COMPATIBLE = 0x40, - HELPFLAGS_NORMAL = 0x80, // andmask = 0xE? - HELPFLAGS_SPACES = 0x100, - HELPFLAGS_TOOL = 0x200, - HELPFLAGS_TOOL_THIS = 0x400, - HELPFLAGS_TOOL_OTHER = 0x800, - HELPFLAGS_TOOL_BOTH = 0xC00, - HELPFLAGS_1000 = 0x1000, - HELPFLAGS_2000 = 0x2000, - HELPFLAGS_USAGE = 0x4000, - HELPFLAGS_8000 = 0x8000, - HELPFLAGS_10000 = 0x10000, - HELPFLAGS_20000 = 0x20000, - HELPFLAGS_40000 = 0x40000, - HELPFLAGS_80000 = 0x80000, - HELPFLAGS_100000 = 0x100000, - HELPFLAGS_200000 = 0x200000, - HELPFLAGS_400000 = 0x400000, - HELPFLAGS_700000 = 0x700000, - HELPFLAGS_800000 = 0x800000, - HELPFLAGS_801828 = 0x801828, - HELPFLAGS_1000000 = 0x1000000, - HELPFLAGS_2000000 = 0x2000000, - HELPFLAGS_4000000 = 0x4000000, - HELPFLAGS_8000000 = 0x8000000, - HELPFLAGS_10000000 = 0x10000000, - HELPFLAGS_20000000 = 0x20000000, - HELPFLAGS_40000000 = 0x40000000, - HELPFLAGS_80000000 = 0x80000000 -}; -enum { - OTF_GLOBAL = 1, - OTF2 = 2, - OTF_CASED = 4, - OTF_OBSOLETE = 8, - OTF_SUBSTITUTED = 0x10, - OTF_DEPRECATED = 0x20, - OTF_TOOL_LINKER = 0x40, - OTF_TOOL_DISASSEMBLER = 0x80, - OTF_TOOL_COMPILER = 0x100, - OTF_TOOL_MASK = OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER | OTF_TOOL_COMPILER, - OTF200 = 0x200, - OTF400 = 0x400, - OTF700 = 0x700, - OTF_IGNORED = 0x800, - OTFC00 = 0xC00, - OTF_SECRET = 0x1000, - OTF2000 = 0x2000, - OTF_COMPATIBILITY = 0x4000, - OTF8000 = 0x8000, - OTF10000 = 0x10000, - OTF20000 = 0x20000, - OTF40000 = 0x40000, - OTF_WARNING = 0x80000, - OTF_SLFLAGS_8 = 0x100000, - OTF_SLFLAGS_10 = 0x200000, - OTF_SLFLAGS_20 = 0x400000, - OTF_SLFLAGS_MASK = OTF_SLFLAGS_8 | OTF_SLFLAGS_10 | OTF_SLFLAGS_20, - OTF_MEANINGLESS = 0x800000, - OTF_ALL_HIDDEN_BY_DEFAULT = OTF_OBSOLETE | OTF_DEPRECATED | OTF_IGNORED | OTF_SECRET | OTF_MEANINGLESS, - OTF1000000 = 0x1000000, - OTF2000000 = 0x2000000, - OTF4000000 = 0x4000000, - OTF8000000 = 0x8000000, - OTF10000000 = 0x10000000, - OTF20000000 = 0x20000000, - OTF40000000 = 0x40000000, - OTF80000000 = 0x80000000 -}; - -enum { - PARAMWHICH_None = 0, - PARAMWHICH_FTypeCreator = 1, - PARAMWHICH_FilePath = 2, - PARAMWHICH_Number = 3, - PARAMWHICH_String = 4, - PARAMWHICH_Id = 5, - PARAMWHICH_Sym = 6, - PARAMWHICH_OnOff = 7, - PARAMWHICH_OffOn = 8, - PARAMWHICH_Mask = 9, - PARAMWHICH_Toggle = 0xA, - PARAMWHICH_Set = 0xB, - PARAMWHICH_SetString = 0xC, - PARAMWHICH_Generic = 0xD, - PARAMWHICH_IfArg = 0xE, - PARAMWHICH_Setting = 0xF, - PARAMWHICH_MAX = 0x10 -}; -enum { - PARAMFLAGS_1 = 1, - PARAMFLAGS_2 = 2, - PARAMFLAGS_3 = 3, - PARAMFLAGS_4 = 4, - PARAMFLAGS_8 = 8, - PARAMFLAGS_10 = 0x10, - PARAMFLAGS_12 = 0x12 -}; -enum { - PARAMPARSEFLAGS_0 = 0, - PARAMPARSEFLAGS_1 = 1, - PARAMPARSEFLAGS_2 = 2, - PARAMPARSEFLAGS_4 = 4, - PARAMPARSEFLAGS_8 = 8, - PARAMPARSEFLAGS_10 = 0x10, - PARAMPARSEFLAGS_20 = 0x20, - PARAMPARSEFLAGS_40 = 0x40, - PARAMPARSEFLAGS_80 = 0x80, - PARAMPARSEFLAGS_100 = 0x100 -}; -enum { - SLFLAGS_1 = 1, - SLFLAGS_2 = 2, - SLFLAGS_4 = 4, // displays =... - SLFLAGS_8 = 8, // displays [no] -- produces e.g. [no]err[or] | [no]iserr[or], [no]implicit[conv] - SLFLAGS_10 = 0x10, // displays [-] - SLFLAGS_20 = 0x20, // displays [no-] - SLFLAGS_40 = 0x40 -}; -enum { - LISTFLAGS_NONE = 0, - LISTFLAGS_2 = 2, - LISTFLAGS_4 = 4, - LISTFLAGS_COMPILER = 0x100, - LISTFLAGS_LINKER = 0x200, - LISTFLAGS_DISASSEMBLER = 0x400, - LISTFLAGS_TOOL_MASK = LISTFLAGS_COMPILER | LISTFLAGS_LINKER | LISTFLAGS_DISASSEMBLER -}; -#ifdef __MWERKS__ -#pragma options align=reset -#endif - - -struct IDEAccessPath { - FSSpec pathSpec; - unsigned char recursive; - long subdirectoryCount; - FSSpec *subdirectories; -}; - -struct IDEAccessPathList { - long userPathCount; - struct IDEAccessPath *userPaths; - long systemPathCount; - struct IDEAccessPath *systemPaths; - unsigned char alwaysSearchUserPaths; - unsigned char convertPaths; -}; - -#ifdef __MWERKS__ -#pragma options align=mac68k -#endif -typedef struct CWObjectFlags { - short version; - long flags; - const char *objFileExt; - const char *brsFileExt; - const char *ppFileExt; - const char *disFileExt; - const char *depFileExt; - const char *pchFileExt; - CWDataType objFileCreator; - CWDataType objFileType; - CWDataType brsFileCreator; - CWDataType brsFileType; - CWDataType ppFileCreator; - CWDataType ppFileType; - CWDataType disFileCreator; - CWDataType disFileType; - CWDataType depFileCreator; - CWDataType depFileType; -} CWObjectFlags; -#ifdef __MWERKS__ -#pragma options align=reset -#endif - -struct CW_BasePluginCallbacks { - void (*cbGetFileInfo)(); - void (*cbFindAndLoadFile)(); - void (*cbGetFileText)(); - void (*cbReleaseFileText)(); - void (*cbGetSegmentInfo)(); - void (*cbGetOverlay1GroupInfo)(); - void (*cbGetOverlay1Info)(); - void (*cbGetOverlay1FileInfo)(); - void (*cbReportMessage)(); - void (*cbAlert)(); - void (*cbShowStatus)(); - void (*cbUserBreak)(); - void (*cbGetNamedPreferences)(); - void (*cbStorePluginData)(); - void (*cbGetPluginData)(); - void (*cbSetModDate)(); - void (*cbAddProjectEntry)(); - void (*cbCreateNewTextDocument)(); - void (*cbAllocateMemory)(); - void (*cbFreeMemory)(); - void (*cbAllocMemHandle)(); - void (*cbFreeMemHandle)(); - void (*cbGetMemHandleSize)(); - void (*cbResizeMemHandle)(); - void (*cbLockMemHandle)(); - void (*cbUnlockMemHandle)(); - void *cbInternal[8]; - void (*cbGetTargetName)(); - void (*cbCacheAccessPathList)(); - void (*cbPreDialog)(); - void (*cbPostDialog)(); - void (*cbPreFileAction)(); - void (*cbPostFileAction)(); - void (*cbCheckoutLicense)(); - void (*cbCheckinLicense)(); - void (*cbResolveRelativePath)(); -}; - -struct CWPluginPrivateContext { - long request; - long apiVersion; - void *shellContext; - void *pluginStorage; - FSSpec projectFile; - FSSpec outputFileDirectory; - long shellSignature; - long pluginType; - long numFiles; - long numOverlayGroups; - short callbackOSError; - short pluginOSError; - CWIDEInfo *shellInfo; - struct IDEAccessPathList *accessPathList; - long dontEatEvents; - struct FSSpec *targetDataDirectorySpec; - long reserved[17]; - struct CW_BasePluginCallbacks *callbacks; -}; - -// Pref panels -#ifdef __MWERKS__ -#pragma options align=mac68k -#endif -typedef struct PCmdLine { - short version; - short state; - short stages; - short toDisk; - short outNameOwner; - unsigned char dryRun; - unsigned char debugInfo; - short verbose; - unsigned char showLines; - unsigned char timeWorking; - unsigned char noWarnings; - unsigned char warningsAreErrors; - unsigned short maxErrors; - unsigned short maxWarnings; - short msgStyle; - unsigned char noWrapOutput; - unsigned char stderr2stdout; - unsigned char noCmdLineWarnings; -} PCmdLine; -typedef struct PCmdLineCompiler { - short version; - unsigned char noSysPath; - unsigned char noFail; - short includeSearch; - char linkerName[64]; - char objFileExt[15]; - char brsFileExt[15]; - char ppFileExt[15]; - char disFileExt[15]; - char depFileExt[15]; - char pchFileExt[15]; - CWDataType objFileCreator; - CWDataType objFileType; - CWDataType brsFileCreator; - CWDataType brsFileType; - CWDataType ppFileCreator; - CWDataType ppFileType; - CWDataType disFileCreator; - CWDataType disFileType; - CWDataType depFileCreator; - CWDataType depFileType; - unsigned char compileIgnored; - unsigned char relPathInOutputDir; - unsigned char browserEnabled; - unsigned char depsOnlyUserFiles; - char outMakefile[256]; - char forcePrecompile; - unsigned char ignoreMissingFiles; - unsigned char printHeaderNames; - char sbmState; - char sbmPath[256]; - unsigned char canonicalIncludes; - unsigned char keepObjects; -} PCmdLineCompiler; -typedef struct PCmdLineLinker { - short version; - unsigned char callPreLinker; - unsigned char callPostLinker; - unsigned char keepLinkerOutput; - unsigned char callLinker; -} PCmdLineLinker; -typedef struct PCmdLineEnvir { - short version; - short cols; - short rows; - unsigned char underIDE; -} PCmdLineEnvir; -typedef struct PBackEnd { - short version; - unsigned char structalignment; - unsigned char tracebacktables; - unsigned char processor; - unsigned char readonlystrings; - unsigned char profiler; - unsigned char fpcontract; - unsigned char schedule; - unsigned char peephole; - unsigned char processorspecific; - unsigned char altivec; - unsigned char vrsave; - unsigned char autovectorize; - unsigned char usebuiltins; - unsigned char pic; - unsigned char dynamic; - unsigned char common; - unsigned char implicit_templates; - unsigned char reserved[3]; -} PBackEnd; -typedef struct PDisassembler { - short version; - unsigned char showcode; - unsigned char extended; - unsigned char mix; - unsigned char nohex; - unsigned char showdata; - unsigned char showexceptions; - unsigned char showsym; - unsigned char shownames; -} PDisassembler; -typedef struct PMachOLinker { - short version; - unsigned char linksym; - unsigned char symfullpath; - unsigned char suppresswarn; - unsigned char linkmap; - unsigned char multisymerror; - unsigned char whatfileloaded; - unsigned char whyfileloaded; - unsigned char use_objectivec_semantics; - char undefinedsymbols; - char readonlyrelocs; - char reserved_value1; - char reserved_value2; - short exports; - short reserved_short1; - unsigned long currentversion; - unsigned long compatibleversion; - long reserved_long1; - char mainname[64]; - unsigned char prebind; - unsigned char dead_strip; - unsigned char twolevel_namespace; - unsigned char strip_debug_symbols; -} PMachOLinker; -typedef struct PMachOProject { - short version; - short type; - unsigned char outfile[64]; - long filecreator; - long filetype; - long stacksize; - long stackaddress; - unsigned long reserved1; - unsigned long reserved2; - unsigned long reserved3; - unsigned long reserved4; - unsigned long reserved5; - unsigned long reserved6; - unsigned long reserved7; - unsigned long reserved8; - unsigned long reserved9; - unsigned long reserved10; - unsigned long reserved11; - unsigned long reserved12; - unsigned long reserved13; - unsigned long reserved14; - unsigned long reserved15; - unsigned long reserved16; - unsigned long reserved17; - unsigned long reserved18; - unsigned long reserved19; - unsigned long reserved20; - unsigned char flatrsrc; - unsigned char filler1; - unsigned char filler2; - unsigned char filler3; - unsigned char separateflatfile[64]; - unsigned char installpath[256]; -} PMachOProject; -typedef struct { - short version; - unsigned char userSetCreator; - unsigned char userSetType; - unsigned char gPrintMapToStdOutput; - unsigned char mapfilename[256]; - unsigned char symfilename[256]; -} PCLTExtras; -#ifdef __MWERKS__ -#pragma options align=reset -#endif - -typedef struct CWCommandLineArgs { - int argc; - char **argv; - char **envp; -} CWCommandLineArgs; - -typedef struct VersionInfo { - unsigned short major; - unsigned short minor; - unsigned short patch; - unsigned short build; -} VersionInfo; - -typedef struct CLPluginInfo { - unsigned long plugintype; - unsigned long language; - long dropinflags; - char *version; - unsigned char storeCommandLine; -} CLPluginInfo; - -typedef struct ToolVersionInfo { - char *company; - char *product; - char *tool; - char *copyright; - char *version; -} ToolVersionInfo; - -// may not actually be named this -struct ParseOptsType { - CWPluginContext context; - char helpKey[64]; - long helpFlags; - unsigned short ioCols; - unsigned short ioRows; - CWCommandLineArgs *args; - ToolVersionInfo *toolVersion; - int numPlugins; - CLPluginInfo *plugins; - int numPanels; - char **panelNames; - unsigned long cpu; - unsigned long os; - char lastoutputname[256]; - long currentSegment; - long currentOverlayGroup; - long currentOverlay; - int possibleFiles; - int userSpecifiedFiles; - int unusedFiles; - unsigned char hadAnyOutput; - unsigned char hadErrors; - unsigned char showHelp; - unsigned char underIDE; - unsigned char alwaysUsePaths; - unsigned char noOptions; - unsigned char printedVersion; - unsigned char passingArgs; - unsigned char disToFile; - unsigned char ppToFile; - unsigned char initBefore; - unsigned char weakImport; - unsigned char mergeIntoOutput; - unsigned char success; - unsigned char ignoreUnknown; - unsigned char unused[2]; -}; - -// assumed name -typedef struct CLState { - int argc; - const char **argv; - CWDataType cpu; - CWDataType os; - CWDataType plugintype; - CWDataType language; - CWDataType style; - OSSpec programPath; - const char *programName; - short numWarnings; - short numErrors; - Boolean pluginDebug; - Boolean userBreak; - Boolean reachedWarningThreshold; - Boolean reachedErrorThreshold; - OSSpec makefileSpec; - OSPathSpec sbmPathSpec; - OSHandle browseHandle; - const char *stdoutBase; - int appendToStdoutBase; -} CLState; - -typedef struct OSFileTypeMapping { - CWDataType mactype; - const char *magic; - char length; - const char *mimetype; - char executable; // not sure why this is rearranged -} OSFileTypeMapping; - -typedef struct OSFileTypeMappingList { - short numMappings; - const OSFileTypeMapping *mappings; -} OSFileTypeMappingList; - -typedef struct BasePluginCallbacks { - short (*main)(); - short (*GetDropInFlags)(const DropInFlags **flags, long *flagsSize); - short (*GetDisplayName)(const char **displayName); - short (*GetDropInName)(const char **dropInName); - short (*GetPanelList)(const CWPanelList **panelList); - short (*GetFamilyList)(const CWFamilyList **familyList); - short (*GetHelpInfo)(const CWHelpInfo **helpInfo); - short (*GetVersionInfo)(const VersionInfo **versionInfo); - short (*GetFileTypeMappings)(const OSFileTypeMappingList **mappingList); -} BasePluginCallbacks; - -typedef struct CompilerLinkerPluginCallbacks { - short (*GetTargetList)(const struct CWTargetList **targetList); - short (*GetDefaultMappingList)(); - short (*Unmangle)(); - short (*BrSymbolEntryPoint)(); - short (*GetObjectFlags)(); - short (*WriteObjectFile)(); -} CompilerLinkerPluginCallbacks; - -typedef struct ParserPluginCallbacks { - short (*SupportsPlugin)(); - short (*SupportsPanels)(); -} ParserPluginCallbacks; - -typedef struct { - char *name; - void *ptr; - long size; -} PrefDataPanel; // assumed name - -typedef struct { - CWDataType TYPE; - CWDataType LANG; - CWDataType CPU; - CWDataType OS; - int numPrefPanels; - char **prefPanels; - char *toolInfo; - char *copyright; - int numOptionLists; - OptionList **optionLists; - int numPrefDataPanels; - PrefDataPanel *prefDataPanels; - int (*PreParse)(); // sig? - int (*MidParse)(); // sig? - int (*PostParse)(); // sig? -} ParserTool; // assumed name - -typedef struct PrefPanel { // assumed name - char *name; - Handle data; - Handle workData; - struct PrefPanel *next; -} PrefPanel; // assumed name - -// CLAccessPaths -typedef struct Paths { - struct Path **array; - unsigned short capacity; - unsigned short count; -} Paths; // assumed name -typedef struct Frameworks { - struct Framework **array; - unsigned short capacity; - unsigned short count; -} Frameworks; // assumed name -typedef struct Path { - OSPathSpec *spec; - Paths *subpaths; - int x8; - short xC; -} Path; // assumed name -typedef struct Framework { - OSSpec frameworkSpec; - OSPathSpec name; - OSPathSpec version; - Path *containingPath; - Boolean flag344; -} Framework; // assumed name - -// CLFiles -typedef struct File { - struct File *next; - int index; - // TODO fill me up -} File; -typedef struct Files { - File *files; - int count; -} Files; // assumed name -typedef struct VFile { - char name[32]; - Handle hand; - struct VFile *next; -} VFile; // assumed name - -// CLOverlays -typedef struct Overlay { - char name[256]; - int *fileIDList; - int fileCount; - int fileCapacity; - struct Overlay *next; -} Overlay; // assumed name -typedef struct OvlGroup { - char name[256]; - CWAddr64 addr; - Overlay *overlays; - Overlay *lastOverlay; - int overlayCount; - struct OvlGroup *next; -} OvlGroup; // assumed name -typedef struct Overlays { - OvlGroup *groups; - OvlGroup *lastGroup; -} Overlays; // assumed name - -// CLSegs -typedef struct Segment { - char name[32]; - short attributes; -} Segment; // assumed name -typedef struct Segments { - Segment **array; - unsigned short capacity; - unsigned short count; -} Segments; // assumed name - -// CLDependencies -typedef struct Incls { - struct Target *target; - // ... - Paths *paths; -} Incls; // assumed name -typedef struct Deps { - int x0; - int x4; - int x8; - Incls *incls; -} Deps; // assumed name - -// CLTarg -typedef struct Target { - int count0; - int count4; - int count8; - int countC; - CWTargetInfo *targetInfo; - struct { - // not sure how much stuff exactly is part of this struct - Segments segments; - Overlays overlays; - } linkage; - int x28; - Files files; - Files pchs; - Incls incls; - Paths sysPaths; - Paths userPaths; - CWDataType language; - CWDataType cpu; - CWDataType os; - char name[64]; - struct Plugin *preLinker; - struct Plugin *linker; - struct Plugin *postLinker; - unsigned long preLinkerFlags; - unsigned long linkerFlags; - unsigned long postLinkerFlags; - OSPathSpec cwd; - VFile *virtualFiles; - struct Target *next; -} Target; // assumed name - -typedef struct Plugin { - BasePluginCallbacks *cb; - CompilerLinkerPluginCallbacks *cl_cb; - ParserPluginCallbacks *pr_cb; - void *context; - char *versionInfoASCII; - struct Plugin *next; -} Plugin; - -typedef struct Token { - int x0; - void *x4; -} Token; - -/********************************/ -/* UMain.c */ -extern int main(int argc, const char **argv); -extern int RegisterResource(const char *name, short index, void *data); -extern int RegisterStaticPlugin(const BasePluginCallbacks *cb); -extern int RegisterStaticCompilerLinkerPlugin(const BasePluginCallbacks *cb, void *b); -extern int RegisterStaticParserPlugin(const BasePluginCallbacks *cb, void *b); -extern void SetBuildTarget(CWDataType cpu, CWDataType os); -extern void SetParserType(CWDataType style); -extern void SetPluginType(CWDataType language, CWDataType plugintype); -extern int CmdLine_Initialize(int argc, const char **argv, const char *buildDate, const char *buildTime); -extern int CmdLine_Driver(); -extern int CmdLine_Terminate(int code); - -/********************************/ -/* UCLTMain.c */ -extern void Main_PreParse(int *pArgc, char ***pArgv); -extern void Main_PassSpecialArgs(void *unk1, void *unk2); -extern int Main_Initialize(int argc, const char **argv); -extern int Main_Terminate(int code); -extern int Main_Driver(); - -/********************************/ -/* Resources.c */ - -/********************************/ -/* ?? CL Errors */ -//static void CLGetErrorString(short errid, char *buffer); -//static void CLMessageReporter(int kind, short errid, va_list ap); -extern void CLReportError(short errid, ...); -extern void CLReportWarning(short errid, ...); -extern void CLReport(short errid, ...); -extern void CLReportOSError(short errid, long err, ...); -extern void CLReportCError(short errid, long err, ...); -extern void CLInternalError(const char *filename, int linenum, const char *format, ...); -extern void CLFatalError(const char *format, ...); - -/********************************/ -/* ?? Res */ -extern void Res_Initialize(); -extern void Res_AddResource(const char *name, short id, const void *data); -extern const char *Res_GetResource(short listIndex, short strId); -extern void Res_Cleanup(); - -/********************************/ -/* CLPlugins.c */ -//static void GetToolVersionInfo(); -extern const ToolVersionInfo *Plugin_GetToolVersionInfo(); -//static const char *Plugin_GetDisplayName(Plugin *pl); -extern const char *Plugin_GetDropInName(Plugin *pl); -extern VersionInfo *Plugin_GetVersionInfo(Plugin *pl); -extern const char *Plugin_GetVersionInfoASCII(Plugin *pl); -extern DropInFlags *Plugin_GetDropInFlags(Plugin *pl); -extern CWDataType Plugin_GetPluginType(Plugin *pl); -extern const CWTargetList *Plugin_CL_GetTargetList(Plugin *pl); -extern const CWPanelList *Plugin_GetPanelList(Plugin *pl); -extern const CWExtMapList *Plugin_CL_GetExtMapList(Plugin *pl); -extern const OSFileTypeMappingList *Plugin_GetFileTypeMappingList(Plugin *pl); -extern const CWObjectFlags *Plugin_CL_GetObjectFlags(Plugin *pl); -extern Boolean Plugin_MatchesName(Plugin *pl, const char *name); -extern Boolean Plugin_CL_MatchesTarget(Plugin *pl, CWDataType cpu, CWDataType os, Boolean flag); -extern Boolean Plugins_CL_HaveMatchingTargets(Plugin *a, Plugin *b, Boolean flag); -//static CL_MatchesExtMapping(CWExtensionMapping *em, CWDataType type, const char *extension, Boolean flag); -extern Boolean Plugin_CL_MatchesFileType(Plugin *pl, CWDataType type, const char *extension, Boolean flag); -extern Boolean Plugin_MatchesType(Plugin *pl, CWDataType plugintype, CWDataType edit_language, Boolean flag); -extern Boolean Plugin_Pr_MatchesPlugin(Plugin *pl, void *unk1, void *unk2, void *unk3); // fixme -extern Boolean Plugin_Pr_MatchesPanels(Plugin *pl, void *unk1, void *unk2); // fixme -extern Boolean Plugin_CL_WriteObjectFile(Plugin *pl, FSSpec *srcfss, FSSpec *outfss, CWDataType creator, CWDataType filetype, Handle data); -extern Boolean Plugin_CL_GetCompilerMapping(Plugin *pl, CWDataType type, const char *extension, CompilerMappingFlags *flags); -//static Boolean SupportedPlugin(Plugin *pl, const char **errmsg); -//static Boolean VerifyPanels(Plugin *pl); -extern Plugin *Plugin_New(const BasePluginCallbacks *cb, const CompilerLinkerPluginCallbacks *cl_cb, const ParserPluginCallbacks *pr_cb); -extern void Plugin_Free(Plugin *pl); -extern int Plugin_VerifyPanels(Plugin *pl); -extern void Plugins_Init(); -extern void Plugins_Term(); -extern int Plugins_Add(Plugin *pl); -extern Plugin *Plugins_MatchName(Plugin *first, const char *name); -extern Plugin *Plugins_CL_MatchTarget(Plugin *first, CWDataType cpu, CWDataType os, CWDataType plugintype, CWDataType edit_language); -extern Plugin *Plugins_CL_MatchFileType(Plugin *first, CWDataType type, const char *extension, Boolean flag); -extern Plugin *Plugins_GetPluginForFile(Plugin *first, CWDataType plugintype, CWDataType cpu, CWDataType os, CWDataType type, const char *extension); -extern Plugin *Plugins_GetLinker(Plugin *first, CWDataType cpu, CWDataType os); -extern Plugin *Plugins_GetPreLinker(Plugin *first, CWDataType cpu, CWDataType os); -extern Plugin *Plugins_GetPostLinker(Plugin *first, CWDataType cpu, CWDataType os); -extern Plugin *Plugins_GetParserForPlugin(...); // TODO fixme args -extern Plugin *Plugins_GetCompilerForLinker(Plugin *first, Plugin *linker, CWDataType type, const char *extension, CWDataType edit_language); -extern Boolean Plugins_GetPluginList(Plugin *first, int *count, void **list); // TODO fixme define list struct -extern Boolean Plugins_GetPrefPanelUnion(Plugin *first, int *count, void **list); // TODO fixme define struct -extern Boolean Plugin_AddFileTypeMappings(Plugin *pl, void *unk); -extern Boolean Plugins_AddFileTypeMappingsForTarget(Plugin *first, void *unk, CWDataType cpu, CWDataType os); -extern short Plugin_Call(Plugin *pl, void *context); - -/********************************/ -/* ?? parser_cb */ - -/********************************/ -/* CLIO.c */ - -/********************************/ -/* CLToolExec.c */ - -/********************************/ -/* OS TU 1 */ -typedef struct uOSTypePair { // unknown name - short a; - short b; -} uOSTypePair; -extern const char *OS_GetErrText(int errnum); -extern int OS_InitProgram(int *pArgc, const char ***pArgv); -extern int OS_TermProgram(); -extern int OS_Create(const OSSpec *spec, const uOSTypePair *type); -extern int OS_Status(const OSSpec *spec); -extern int OS_GetFileType(const OSSpec *spec, uOSTypePair *type); -extern int OS_SetFileType(const OSSpec *spec, const uOSTypePair *type); -extern int OS_GetFileTime(const OSSpec *spec, time_t *ctime, time_t *mtime); -extern int OS_SetFileTime(const OSSpec *spec, const time_t *ctime, const time_t *mtime); -extern int OS_Open(const OSSpec *spec, unsigned short mode, int *pRef); -extern int OS_Write(int ref, const void *data, long *pLen); -extern int OS_Read(int ref, void *data, long *pLen); -extern int OS_Seek(int ref, unsigned short how, long offset); -extern int OS_Tell(int ref, long *pOffset); -extern int OS_Close(int ref); -extern int OS_GetSize(int ref, long *pSize); -extern int OS_SetSize(int ref, long size); -extern int OS_Delete(const OSSpec *spec); -extern int OS_Rename(const OSSpec *a, const OSSpec *b); -extern int OS_Mkdir(const OSSpec *spec); -extern int OS_Rmdir(const OSPathSpec *spec); -extern int OS_Chdir(const OSPathSpec *spec); -extern int OS_GetCWD(OSPathSpec *spec); -extern int OS_Execute(); // TODO figure out the args for this properly -extern int OS_IsLegalPath(const char *str); -extern int OS_IsFullPath(const char *str); -extern char *OS_GetDirPtr(OSPathSpec *spec); -//extern int OS_CompactPath(const char *spec, char *dest); -extern int OS_EqualPath(const char *a, const char *b); -extern int OS_CanonPath(const char *src, char *dest); -extern int OS_MakeSpec(const char *path, OSSpec *spec, Boolean *pFlag); -extern int OS_MakeFileSpec(const char *path, OSSpec *spec); -extern int OS_MakePathSpec(const char *a, const char *b, OSPathSpec *spec); -extern int OS_MakeNameSpec(const char *src, OSNameSpec *spec); -extern int OS_GetRootSpec(OSPathSpec *spec); -extern char *OS_SpecToString(const OSSpec *spec, char *output, int maxlen); -extern char *OS_PathSpecToString(const OSPathSpec *spec, char *output, int maxlen); -extern char *OS_NameSpecToString(const OSNameSpec *spec, char *output, int maxlen); -extern int OS_SizeOfPathSpec(const OSPathSpec *spec); -extern int OS_SizeOfNameSpec(const OSNameSpec *spec); -extern int OS_EqualSpec(const OSSpec *a, const OSSpec *b); -extern int OS_EqualPathSpec(const OSPathSpec *a, const OSPathSpec *b); -extern int OS_EqualNameSpec(const OSNameSpec *a, const OSNameSpec *b); -extern int OS_IsDir(const OSSpec *spec); -extern int OS_IsFile(const OSSpec *spec); -extern int OS_IsLink(const OSSpec *spec); -extern int OS_ResolveLink(const OSSpec *src, OSSpec *dest); -extern int OS_OpenDir(const OSPathSpec *spec, void *data); // TODO arg type -extern int OS_ReadDir(void *data, OSSpec *spec, OSNameSpec *nameSpec, Boolean *pFlag); -extern int OS_CloseDir(void *data); // TODO arg type -extern long OS_GetMilliseconds(); -extern time_t OS_GetTime(time_t *p); -extern int OS_NewHandle(unsigned long size, OSHandle *hand); -extern int OS_ResizeHandle(OSHandle *hand, unsigned long newSize); -extern void *OS_LockHandle(OSHandle *hand); -extern void OS_UnlockHandle(OSHandle *hand); -extern int OS_FreeHandle(OSHandle *hand); -extern int OS_GetHandleSize(OSHandle *hand, unsigned long *pSize); -extern void OS_InvalidateHandle(OSHandle *handle); -extern Boolean OS_ValidHandle(OSHandle *handle); -extern short OS_MacError(int err); -extern void OS_TimeToMac(time_t t, unsigned long *pMacTime); -extern time_t OS_MacToTime(unsigned long macTime, time_t *p); -extern short OS_RefToMac(int ref); -extern int OS_MacToRef(short macRef); -extern int OS_OpenLibrary(const char *a, int *p); -extern int OS_GetLibrarySymbol(void *a, void *b, int *p); -extern int OS_CloseLibrary(void *a); -extern int OS_LoadMacResourceFork(const OSSpec *spec, void **unkA, void **unkB); -extern int OS_IsMultiByte(const char *str, int offset); -extern char *strcatn(char *dst, const char *src, int maxlen); -extern char *strcpyn(char *dst, const char *src, int maxlen); -extern int ustrcmp(const char *a, const char *b); -extern int ustrncmp(const char *a, const char *b, int maxlen); - -/********************************/ -/* OS TU 2 */ -extern int WildCardMatch(const char *a, const char *b); -extern OSSpec *OS_MatchPath(const char *path); -extern char *OS_GetFileNamePtr(char *path); -extern char *OS_GetDirName(const OSPathSpec *spec, char *buf, int bufsize); -extern int OS_MakeSpec2(const char *a, const char *b, OSSpec *spec); -extern int OS_MakeSpecWithPath(const char *pathSpec, const char *str, Boolean flag, OSSpec *spec); -extern int OS_NameSpecChangeExtension(OSNameSpec *nameSpec, const char *newExt, Boolean flag); -extern int OS_NameSpecSetExtension(OSNameSpec *nameSpec, const char *newExt); -extern char *OS_CompactPaths(char *str, const char *a, const char *b, int lenmaybe); -extern char *OS_SpecToStringRelative(const OSSpec *spec, const OSPathSpec *pathSpec, char *outbuf, int outlen); -extern int OS_FindFileInPath(const char *filename, const char *paths, OSSpec *spec); -extern int OS_FindProgram(const char *path, OSSpec *spec); -extern int OS_CopyHandle(OSHandle *src, OSHandle *dest); -extern int OS_AppendHandle(OSHandle *hand, const void *data, long size); - -/********************************/ -/* CLProj.c */ -typedef struct Proj { - Target *target; - OSPathSpec projDir; - OSNameSpec projName; -} Proj; -extern int Proj_Initialize(Proj *proj); -extern int Proj_Terminate(Proj *this); - -/********************************/ -/* ?? License */ -extern void License_Initialize(); -extern void License_Terminate(); -extern long License_Checkout(); -extern void License_Refresh(); -extern void License_Checkin(); -extern void License_AutoCheckin(); - -/********************************/ -/* ?? 'x' funcs */ -extern void *xmalloc(const char *str, size_t amount); -extern void *xcalloc(const char *str, size_t amount); -extern void *xrealloc(const char *str, void *curPtr, size_t amount); -extern char *xstrdup(const char *str); -extern void xfree(void *ptr); - -/********************************/ -/* CLPluginRequests.cpp */ -extern Boolean SendParserRequest( - Plugin *plugin, - Target *target, - CWCommandLineArgs *args, - CWDataType cpu, - CWDataType os, - int numPlugin, - void *pluginInfo, - int numPanels, - void *panelNames, - void *pluginArgs, - void *panelArgs, - const char *cmdlineBuildDate, - const char *cmdlineBuildTime, - ToolVersionInfo *toolVersionInfo - ); -extern Boolean SendCompilerRequest(Plugin *plugin, File *file, short request); -extern Boolean SendTargetInfoRequest(Target *target, Plugin *linker, int flags); -extern Boolean SendLinkerRequest(Plugin *plugin, int flags, CWTargetInfo *targetInfo); -extern Boolean SendDisassemblerRequest(Plugin *plugin, File *file); -extern Boolean SendInitOrTermRequest(Plugin *plugin, Boolean action); - -/********************************/ -/* ?? LM funcs */ -extern unsigned long LMGetTicks(); -extern unsigned long LMGetTime(); -extern short LMGetMemErr(); -extern void LMSetMemErr(short err); - -/********************************/ -/* CLFileOps.c */ -extern int GetOutputFile(); // TODO args -extern int StoreObjectFile(); // TODO args -extern int CompileFilesInProject(); -extern int LinkProject(); - -/********************************/ -/* CLPrefs.c */ -extern PrefPanel *PrefPanel_New(const char *name, void *data, long dataSize); -extern Handle PrefPanel_GetHandle(PrefPanel *panel); -extern int PrefPanel_PutHandle(PrefPanel *panel, Handle handle); -extern void Prefs_Initialize(); -extern void Prefs_Terminate(); -extern Boolean Prefs_AddPanel(PrefPanel *panel); -extern PrefPanel *Prefs_FindPanel(const char *name); - -/********************************/ -/* CLTarg.c */ -extern Target *Target_New(const char *name, CWDataType cpu, CWDataType os, CWDataType language); -extern void Target_Free(Target *target); -extern void Targets_Term(Target *targets); -extern void Target_Add(Target **targets, Target *targetToAdd); - -/********************************/ -/* CLAccessPaths.c */ -extern Path *Path_Init(const OSPathSpec *pathSpec, Path *path); -extern Path *Path_New(const OSPathSpec *pathSpec); -extern void Path_Free(Path *path); -extern Boolean Paths_Initialize(Paths *paths); -extern Boolean Paths_Terminate(Paths *paths); -//static Boolean Paths_GrowPaths(Paths *paths, unsigned short *pIndex); -extern Boolean Paths_AddPath(Paths *paths, Path *path); -extern Boolean Paths_InsertPath(Paths *paths, unsigned short index, Path *path); -extern Boolean Paths_RemovePath(Paths *paths, unsigned short index); -extern Boolean Paths_DeletePath(Paths *paths, unsigned short index); -extern Path *Paths_GetPath(Paths *paths, unsigned short index); -extern unsigned short Paths_Count(const Paths *paths); -extern Boolean Paths_FindPath(const Paths *paths, const Path *path); -extern Path *Paths_FindPathSpec(const Paths *paths, const OSPathSpec *pathSpec); -//static Boolean GatherRecurse(Paths *paths, Path *path); -extern Boolean Paths_GatherRecurse(Paths *paths); -extern int Paths_CountRecurse(Paths *paths); -//static void CopyRecurseFSS(FSSpec **pFss, Paths *paths, unsigned short *pCount); -extern void Paths_CopyRecurseFSS(FSSpec *fss, Paths *paths, unsigned short count); -//static Boolean Frameworks_Initialize(Frameworks *frameworks); -//static Boolean Frameworks_Grow(Frameworks *frameworks, unsigned short *pIndex); -//static Boolean Frameworks_Add(Frameworks *frameworks, Framework *framework); -//static Framework *Framework_Init(OSSpec *frameworkSpec, const char *name, const char *version, Framework *framework, Path *containingPath, Boolean flag); -//static Framework *Framework_New(OSSpec *frameworkSpec, const char *name, const char *version, Path *containingPath, Boolean flag); -//static Boolean CheckForFileInFrameworkDir(char *buf, const char *dir, OSPathSpec *pathSpec, const char *filename); -//static Boolean CheckForFileInFramework(char *buf, int fwIndex, const char *filename); -extern Boolean MakeFrameworkPath(char *buf, const char *frameworkName, OSPathSpec **pOutputSpec); -extern Boolean Frameworks_AddPath(const OSPathSpec *pathSpec); -extern Boolean Frameworks_AddFramework(const char *frameworkName, const char *version, Boolean flag); -extern void Framework_GetEnvInfo(); -extern int Frameworks_GetCount(); -extern Framework *Frameworks_GetInfo(int index); - -/********************************/ -/* MacSpecs.c */ -// This is pretty much self-contained lol -extern OSErr OS_OSPathSpec_To_VolDir(const OSPathSpec *pathSpec, short *pVol, long *pDir); -extern OSErr OS_OSSpec_To_FSSpec(const OSSpec *spec, FSSpec *fss); -extern OSErr OS_VolDir_To_OSNameSpec(short vol, long dir, OSNameSpec *nameSpec, long *pDir); -extern OSErr OS_VolDir_To_OSPathSpec(short vol, long dir, OSPathSpec *pathSpec); -extern OSErr OS_FSSpec_To_OSSpec(const FSSpec *fss, OSSpec *spec); -extern OSErr OS_GetRsrcOSSpec(const OSSpec *baseSpec, OSSpec *rsrcSpec, Boolean createFlag); - -/********************************/ -/* StringUtils.c */ -extern StringPtr _pstrcpy(StringPtr dst, ConstStringPtr src); -extern StringPtr _pstrcat(StringPtr dst, ConstStringPtr src); -extern StringPtr _pstrcharcat(StringPtr dst, unsigned char c); -extern StringPtr pstrncpy(StringPtr dst, ConstStringPtr src, short maxlen); -extern StringPtr pstrncat(StringPtr dst, ConstStringPtr src, short maxlen); -extern int pstrcmp(ConstStringPtr a, ConstStringPtr b); -extern int pstrchr(ConstStringPtr str, char c); -extern void c2pstrcpy(StringPtr dst, const char *src); -extern void p2cstrcpy(char *dst, ConstStringPtr src); -extern char *mvprintf(char *str, size_t size, const char *format, va_list ap); -extern char *mprintf(char *str, size_t size, const char *format, ...); -extern int HPrintF(Handle hand, const char *format, ...); - -/********************************/ -/* ?? Handle emulation */ -typedef struct MacHandle { - char *addr; - OSHandle hand; -} MacHandle; -extern OSHandle *OS_PeekMacHandle(MacHandle *mh); -//static void FixHandlePtr(MacHandle *mh, char *ptr); -extern MacHandle *OS_CreateMacHandle(OSHandle *hand); -extern MacHandle *OS_CreateMacHandleDup(MacHandle *mh); -extern void OS_DestroyMacHandle(MacHandle *mh, OSHandle *hand); - -extern OSErr MemError(); -extern Handle NewHandle(long byteCount); -extern Handle NewHandleClear(long byteCount); -extern Handle TempNewHandle(long logicalSize, OSErr *resultCode); -extern void DisposeHandle(Handle h); -extern void HLock(Handle h); -extern void HLockHi(Handle h); -extern void HUnlock(Handle h); -extern void HPurge(Handle h); -extern void HNoPurge(Handle h); -extern SInt8 HGetState(Handle h); -extern void HSetState(Handle h, SInt8 flags); -extern long GetHandleSize(Handle h); -extern void SetHandleSize(Handle h, long size); -extern OSErr PtrAndHand(const void *ptr1, Handle hand2, long size); -extern OSErr PtrToHand(const void *srcPtr, Handle *dstHndl, long size); -extern OSErr HandToHand(Handle *theHndl); -extern OSErr HandAndHand(Handle hand1, Handle hand2); -extern void MoveHHi(Handle h); -extern void BlockMove(const void *srcPtr, void *destPtr, long byteCount); -extern void BlockMoveData(const void *srcPtr, void *destPtr, long byteCount); -extern Ptr NewPtr(long byteCount); -extern void DisposePtr(Ptr p); -extern Ptr NewPtrClear(long byteCount); -extern void DebugStr(ConstStringPtr debuggerMsg); -extern OSErr HandleZone(); -extern OSErr ApplicationZone(); - -/********************************/ -/* Files.c */ -typedef struct FileParamInfo { // i think this is internal, move it once i impl Files.c - unsigned long creationDate; - unsigned long modifiedDate; - long logicalLen; - long physicalLen; - long rLogicalLen; - long rPhysicalLen; - long x18; - long x1C; - unsigned char attrib; -} FileParamInfo; // assumed name -//static int OS_GetFileParamInfo(const OSSpec *spec, FileParamInfo *info, FInfo *finfo); -//static int OS_SetFileParamInfo(const OSSpec *spec, FileParamInfo *info, FInfo *finfo); -extern OSErr HCreate(short vRefNum, long dirID, ConstStr255Param fileName, OSType creator, OSType fileType); -extern OSErr HOpen(short vRefNum, long dirID, ConstStr255Param fileName, SInt8 permission, short *refNum); -extern OSErr HOpenDF(short vRefNum, long dirID, ConstStr255Param fileName, SInt8 permission, short *refNum); -extern OSErr HDelete(short vRefNum, long dirID, ConstStr255Param fileName); -extern OSErr HRename(short vRefNum, long dirID, ConstStr255Param oldName, ConstStr255Param newName); -extern OSErr HGetFInfo(short vRefNum, long dirID, ConstStr255Param fileName, FInfo *fndrInfo); -extern OSErr HSetFInfo(short vRefNum, long dirID, ConstStr255Param fileName, const FInfo *fndrInfo); -extern OSErr FSpCreate(const FSSpec *spec, OSType creator, OSType fileType, ScriptCode scriptTag); -extern OSErr FSpDirCreate(const FSSpec *spec, ScriptCode scriptTag, long *createdDirID); -extern OSErr FSpOpenDF(const FSSpec *spec, SInt8 permission, short *refNum); -extern OSErr FSpDelete(const FSSpec *spec); -extern OSErr FSpRename(const FSSpec *spec, ConstStr255Param newName); -extern OSErr FSpGetFInfo(const FSSpec *spec, FInfo *fndrInfo); -extern OSErr FSpSetFInfo(const FSSpec *spec, const FInfo *fndrInfo); -extern OSErr HGetVol(StringPtr volName, short *vRefNum, long *dirID); -extern OSErr HSetVol(ConstStr63Param volName, short vRefNum, long dirID); -extern OSErr FlushVol(ConstStr63Param volName, short vRefNum); -extern OSErr FSRead(short refNum, long *count, void *buffPtr); -extern OSErr FSWrite(short refNum, long *count, const void *buffPtr); -extern OSErr FSClose(short refNum); -extern OSErr GetEOF(short refNum, long *logEOF); -extern OSErr SetEOF(short refNum, long logEOF); -extern OSErr GetFPos(short refNum, long *filePos); -extern OSErr SetFPos(short refNum, short posMode, long posOff); -extern OSErr GetVInfo(short drvNum, StringPtr volName, short *vRefNum, long *freeBytes); -extern OSErr PBWriteSync(ParmBlkPtr paramBlock); -extern OSErr PBHGetFInfoSync(HParmBlkPtr paramBlock); -extern OSErr PBHSetFInfoSync(HParmBlkPtr paramBlock); -extern OSErr PBGetCatInfoSync(CInfoPBPtr paramBlock); -extern OSErr ResolveAliasFile(FSSpec *theSpec, Boolean resolveAliasChains, Boolean *targetIsFolder, Boolean *wasAliased); -extern OSErr FSMakeFSSpec(short vRefNum, long dirID, ConstStr255Param fileName, FSSpec *spec); -extern OSErr Allocate(short refNum, long *count); -extern StringPtr c2pstr(char *str); -extern char *p2cstr(StringPtr str); -extern short CharacterByteType(Ptr textBuf, short textOffset, ScriptCode script); -extern short CharByte(); -extern void GetDateTime(unsigned long *secs); -extern Boolean EqualString(ConstStr255Param str1, ConstStr255Param str2, Boolean caseSensitive, Boolean diacSensitive); -extern void GetIndString(Str255 theString, short strListID, short index); -extern char *getindstring(char *theString, short strListID, short index); -extern void NumToString(long theNum, Str255 theString); -extern void StringToNum(ConstStr255Param theString, long *theNum); - -/********************************/ -/* MacFileTypes.c */ -extern int AddFileTypeMappingList(void *a, void *b); // TODO sig -extern void UseFileTypeMappings(void *a); // TODO sig -extern OSErr SetMacFileType(const FSSpec *fss, void *a); // TODO sig -extern OSErr GetMacFileType(const FSSpec *fss, void *a); // TODO sig - -/********************************/ -/* CLFiles.c */ -extern File *File_New(); -extern void File_Free(File *file); -extern int Files_Initialize(Files *this); -extern int Files_Terminate(Files *this); -extern int Files_AddFile(Files *this, File *file); -extern int Files_InsertFile(Files *this, File *file, int index); -extern File *Files_GetFile(Files *this, int filenum); -extern File *Files_FindFile(Files *this, OSSpec *spec); -extern int Files_Count(Files *this); -extern int VFiles_Initialize(VFile **vfiles); -extern int VFiles_Terminate(VFile **vfiles); -extern VFile *VFile_New(const char *name, Handle data); -extern int VFiles_Add(VFile **vfiles, VFile *vfile); -extern VFile *VFiles_Find(VFile *vfiles, const char *name); - -/********************************/ -/* CLOverlays.c */ -extern int Overlays_Initialize(Overlays *this); -extern int Overlays_Terminate(Overlays *this); -extern int Overlays_AddOvlGroup(Overlays *this, OvlGroup *grp, int *pIndex); -extern OvlGroup *Overlays_GetOvlGroup(Overlays *this, int index); -extern int Overlays_CountGroups(Overlays *this); -extern int Overlays_AddFileToOverlay(Overlays *this, int groupIndex, int overlayIndex, int fileID); -extern Overlay *Overlays_GetOverlayInGroup(Overlays *this, int groupIndex, int overlayIndex); -extern int Overlays_GetFileInOverlay(Overlays *this, int groupIndex, int overlayIndex, int fileIndex); -extern OvlGroup *OvlGroup_New(const char *name, CWAddr64 addr); -extern void OvlGroup_Delete(OvlGroup *grp); -extern int OvlGroup_AddOverlay(OvlGroup *this, Overlay *oly, int *pIndex); -extern Overlay *OvlGroup_GetOverlay(OvlGroup *this, int index); -extern int OvlGroup_CountOverlays(OvlGroup *this); -extern Overlay *Overlay_New(const char *name); -extern void Overlay_Delete(Overlay *oly); -extern int Overlay_AddFile(Overlay *oly, int fileID, int *pIndex); -extern int Overlay_GetFile(Overlay *oly, int index); -extern int Overlay_CountFiles(Overlay *oly); - -/********************************/ -/* CLSegs.c */ -extern Segment *Segment_New(const char *name, unsigned short a); -extern void Segment_Free(Segment *segment); -extern int Segments_Initialize(Segments *segs); -extern int Segments_Terminate(Segments *segs); -//static Boolean Segments_GrowSegments(Segments *segments, unsigned short *pIndex); -extern int Segments_AddSegment(Segments *segs, Segment *segment, unsigned short *pIndex); -extern Boolean Segments_InsertSegment(Segments *segs, unsigned short index, Segment *segment); -extern Boolean Segments_DeleteSegment(Segments *segs, unsigned short index); -extern Segment *Segments_GetSegment(Segments *segs, unsigned short index); -extern unsigned short Segments_Count(const Segments *segs); - -/********************************/ -/* CLDropinCallbacks_V10.cpp */ -// TODO - -/********************************/ -/* MacFileTypes.c */ -typedef struct OSFileTypeMappingListNode { - OSFileTypeMappingList *list; - struct OSFileTypeMappingListNode *next; -} OSFileTypeMappingListNode; // assumed name -extern void OS_AddFileTypeMappingList(OSFileTypeMappingListNode **node, OSFileTypeMappingList *list); -extern void OS_UseFileTypeMappings(OSFileTypeMappingListNode *node); -extern void OS_MacType_To_OSType(OSType mactype, uOSTypePair *ostype); -extern int OS_SetMacFileType(const OSSpec *spec, OSType mactype); -extern int OS_GetMacFileTypeMagic(const void *magic, int length, OSType *mactype); -extern int OS_GetMacFileType(const OSSpec *spec, OSType *mactype); -extern int OS_SetMacFileCreatorAndType(const OSSpec *spec, OSType creator, OSType mactype); - -/********************************/ -/* ?? Handles */ -//extern int OS_LoadFileHandle(OSFileHandle *fh); -//extern int OS_WriteFileHandle(OSFileHandle *fh); -extern int OS_NewFileHandle(const OSSpec *spec, OSHandle *hand, Boolean writeable, OSFileHandle *fh); -extern int OS_LockFileHandle(OSFileHandle *fh, Ptr *h, unsigned long *pSize); -extern int OS_UnlockFileHandle(OSFileHandle *fh); -extern int OS_FreeFileHandle(OSFileHandle *fh); -extern void OS_GetFileHandleSpec(const OSFileHandle *fh, OSSpec *spec); - -/********************************/ -/* CLCompilerLinkerDropin_V10.cpp */ -// TODO - -/********************************/ -/* CLDependencies.c */ -extern int Incls_Initialize(Incls *incls, Target *targ); -extern void Incls_Terminate(Incls *incls); -// IsSysIncl -// MakeInclFileSpec -// QuickFindFileInIncls -// SameIncl -// FindOrAddGlobalInclPath -// _FindFileInPath -// FindFileInPaths -// AddFileToIncls -extern int Incls_FindFileInPaths(Incls *incls, ...); // TODO sig -extern int Deps_Initialize(Deps *deps, Incls *incls); -extern void Deps_Terminate(Deps *deps); -extern int Deps_ChangeSpecialAccessPath(OSPathSpec *pathSpec, Boolean flag); -extern Path *Deps_GetSpecialAccessPath(); -//extern void SetSpecialAccessPathFromIncludeStackTOS(); -// FindDepFile -// AddDepFile -extern int Deps_AddDependency(); // TODO sig -// EscapeName -extern int Deps_ListDependencies(); // TODO sig - -/********************************/ -/* CLWriteObjectFile.c */ -extern Boolean WriteObjectFile(File *file, OSType creator, OSType filetype); -extern Boolean WriteBrowseData(File *file); - -/********************************/ -/* CLBrowser.c */ -// GetBrowseTableInfoAndLock -extern int Browser_Initialize(OSHandle *browsetable); -//static int Destroy(OSHandle *hand); -extern int Browser_Terminate(OSHandle *browsetable); -extern int Browser_SearchFile(OSHandle *browsetable, const char *fullpath, short *pIndex); -extern int Browser_SearchAndAddFile(OSHandle *browsetable, const char *fullpath, short *pIndex); -//static long CalcDiskSpaceRequirements(...); // needs table type -//static int ConvertMemToDisk(...); // needs table type -extern int Browser_PackBrowseFile(Handle browsedata, OSHandle *browsetable, OSHandle *hand2); - -/********************************/ -/* ?? Include Cache */ -// TODO - -/********************************/ -/* ?? Error */ -extern char *GetSysErrText(short code, char *buffer); - -/********************************/ -/* Might be cc-mach-ppc-mw.c? */ -extern void GetStaticTarget(CWDataType *cpu, CWDataType *os); -extern void GetStaticPluginType(CWDataType *language, CWDataType *plugintype); -extern void GetStaticParserPluginType(CWDataType *style); -extern int RegisterStaticTargetResources(); -extern int RegisterStaticTargetPlugins(); - -/********************************/ -/* Might be ParserGlue-mach-ppc-cc.c? */ -extern int RegisterStaticParserToolInfo(); - -/********************************/ -/* Might be cc-mach-ppc.c? */ -extern pascal short CWPlugin_GetDropInFlags(const DropInFlags **flags, long *flagsSize); -extern pascal short CWPlugin_GetTargetList(const CWTargetList **targetList); -extern pascal short CWPlugin_GetDropInName(const char **dropinName); -extern pascal short CWPlugin_GetDisplayName(const char **displayName); -extern pascal short CWPlugin_GetDefaultMappingList(const CWExtMapList **defaultMappingList); -extern pascal short CWPlugin_GetPanelList(const CWPanelList **panelList); -//_CmdLine_GetObjectFlags -//_CWPlugin_GetVersionInfo -//_CWPlugin_GetFileTypeMappings -//_Linker_GetDropInFlags -//_Linker_GetDropInName -//_Linker_GetDisplayName -//_Linker_GetPanelList -//_Linker_GetTargetList -//_Linker_GetDefaultMappingList -extern int RegisterStaticCompilerPlugin(); -extern int RegisterCompilerResources(); - -/********************************/ -/* libimp-mach-ppc.c */ -// some statics here -extern int RegisterStaticLibImporterPlugin(); -extern int RegisterLibImporterResources(); - -/********************************/ -/* TargetOptimizer-ppc-mach.c */ -extern int TargetSetOptFlags(short val, Boolean set); -extern void TargetDisplayOptimizationOptions(Handle txt); -extern void TargetSetPragmaOptimizationsToUnspecified(); - -/********************************/ -/* OptimizerHelpers.c */ -extern int SetPragmaOptimizationsToUnspecified(); -extern int SetOptFlags(char *opt, void *str, ...); // two unknown args -extern int DisplayOptimizationOptions(); - -/********************************/ -/* Unk name lol */ -extern int TargetSetWarningFlags(short val, Boolean set); -extern int TargetDisplayWarningOptions(Handle txt); - -/********************************/ -/* WarningHelpers.c */ -extern int SetWarningFlags(char *opt, void *str, ...); // two unknown args -extern int DisplayWarningOptions(); - -/********************************/ -/* CCompiler.c */ - -// LOTS OF STUFF - -/********************************/ -/* StaticParserGlue.c */ -extern int RegisterStaticParserResources(); -extern int RegisterStaticParserPlugins(); - -/********************************/ -/* ParserFace.c */ -extern Handle Parser_FindPrefPanel(char *name); -extern CWResult Parser_StorePanels(CWPluginContext context); -extern short CWParser_GetDropInFlags(const DropInFlags **flags, long *flagsSize); -extern short CWParser_GetDropInName(const char **dropinName); -extern short CWParser_GetDisplayName(const char **displayName); -extern short CWParser_GetPanelList(const CWPanelList **panelList); -extern short CWParser_GetTargetList(const CWTargetList **targetList); -extern short CWParser_GetVersionInfo(const VersionInfo **versioninfo); -extern short Parser_SupportsPlugin(struct CLPluginInfo *pluginfo, CWDataType cpu, CWDataType os, Boolean *isSupported); -extern short Parser_SupportsPanels(int numPanels, char **panelNames, Boolean *isSupported); -extern short parser_main(CWPluginContext context); - -extern struct ParseOptsType parseopts; - -/********************************/ -/* ParserHelpers.c */ -extern int FindFileInPath(const char *filename, OSSpec *fss); -extern char *GetEnvVar(const char *name, Boolean warn, char **match); -//static Boolean MatchesExtension(const char *list, const char *filename); -extern int Opt_AddAccessPath(const char *opt, void *var, const char *arg); -extern int Opt_AddFrameworkPath(const char *opt, void *var, const char *arg); -extern int Opt_AddFramework(const char *opt, void *var, const char *arg); -extern void ListParseMessage(void *errprint, const char *envvar, short id); // TODO funcptr sig - same as CLPReportWarning_V, CLPReportError_V -extern int AddAccessPathList(const char *list, char sep1, char sep2, int source, char *text, Boolean system, long position, Boolean recursive); -extern int Opt_FindAndAddFile(const char *opt, void *var, const char *arg); -extern int Opt_FindAndAddFileRef(const char *opt, void *var, const char *arg); -extern int Opt_AddUnixLibraryFile(const char *opt, void *var, const char *arg); -extern int AddFileList(const char *list, char sep1, char sep2, int source, char *text, long position); -extern int IsFileInOutputDirectory(const OSSpec *file); -extern void GetCFileNameInOutputDirectory(const char *input, char *name, int maxlen); -extern void GetPFileNameInOutputDirectory(const char *input, unsigned char *name, int len); -extern void AddStringLenToHandle(Handle h, const char *str, int len); -extern void AddStringToHandle(Handle h, const char *str); -extern int Opt_PrintVersion(const char *opt, void *var, const char *arg); -extern void GetFirstSourceFilenameBase(char *buffer, char *defaul); -extern int Opt_SavePrefs(const char *opt, void *var, const char *arg); -extern int ParseNumber(const char *arg, Boolean emit_error, long *ret, const char **endptr); -extern int Opt_MaybeMoveAccessPaths(const char *opt, void *var, const char *arg); - -/********************************/ -/* ToolHelpers.c */ -extern int Opt_HandleOutputName(const char *opt, void *, const char *filename); -extern int ValidateToolState(Boolean mustHaveFiles); -extern void ToolReportMessage(short errid, short type, va_list va); -extern void ToolReportWarning(short id, ...); -extern void ToolReportError(short id, ...); -extern void ToolReportOSError(short id, ...); -extern void ToolReportInfo(short id, ...); -extern int Opt_DoNotLink(const char *opt, void *var, const char *arg); -extern int Opt_IncreaseVerbosity(const char *opt, void *var, const char *arg); -extern int Opt_SetStage(const char *opt, void *str, const char *arg, void *unk); -// lots of the Opt_ funcs have weird sigs, need to double check them -extern int Opt_RedirectStream(const char *opt, void *file, const char *filename); - -/********************************/ -/* ParserHelpers-cc.c */ -typedef struct { - void *value; - const char *pragma; - int flags; -} Pragma; // assumed name -extern int Opt_AddStringToDefines(const char *opt, void *str, const char *param); -extern int Opt_DefineSymbol(const char *var, const char *value); -extern int Opt_UndefineSymbol(const char *opt, void *, const char *arg); -extern int Opt_AddPrefixFile(const char *opt, void *handle, const char *filename); -extern int Opt_PragmaTrueFalse(const char *, void *flag, const char *, int flags); -extern int Opt_PragmaFalseTrue(const char *, void *flag, const char *, int flags); -extern int Opt_PragmaOnOff(const char *, void *flag, const char *arg); -extern int Opt_PragmaOffOn(const char *, void *flag, const char *arg); -extern int SetupPragmas(const Pragma *pragmas); - -/********************************/ -/* Arguments.c */ -typedef struct { - short val; - char *text; -} ArgToken; -enum { - ATK_0, - ATK_1, - ATK_2, - ATK_3, - ATK_4, - ATK_5 -}; -typedef struct { - int argc; - int nargv; - char **argv; -} anon0_50; - -extern void Arg_Init(int theargc, char **theargv); -extern void Arg_Terminate(); -extern void Arg_Reset(); -extern void Arg_Stop(ArgToken *where); -extern ArgToken *Arg_PeekToken(); -extern ArgToken *Arg_UsedToken(); -extern int Arg_IsEmpty(); -extern ArgToken *Arg_GetToken(); -extern ArgToken *Arg_UndoToken(); -extern const char *Arg_GetTokenName(ArgToken *tok); -extern const char *Arg_GetTokenText(ArgToken *tok, char *buffer, int maxlen, unsigned char warn); -extern void Arg_InitToolArgs(anon0_50 *ta); -extern void Arg_AddToToolArgs(anon0_50 *ta, short tokval, char *toktxt); -extern void Arg_FinishToolArgs(anon0_50 *ta); -extern void Arg_ToolArgsForPlugin(anon0_50 *ta, struct CWCommandLineArgs *args); -extern void Arg_FreeToolArgs(anon0_50 *ta); - -/********************************/ -/* ToolHelpers-cc.c */ -extern int Opt_DummyLinkerRoutine(const char *opt); -extern int Opt_DummyLinkerSettingRoutine(const char *var, const char *val); -extern void FinishCompilerTool(); - -/********************************/ -/* IO.c */ -extern void ShowTextHandle(const char *description, Handle text); -extern void ShowVersion(Boolean decorate); - -/********************************/ -/* Projects.c */ -extern int GetFileCount(); -extern void SetFileOutputName(long position, short which, char *outfilename); -extern int AddFileToProject(OSSpec *oss, short which, char *outfilename, Boolean exists, long position); -extern Boolean GetFileInfo(long position, OSSpec *spec, char *plugin); -extern int AddAccessPath(const OSPathSpec *oss, short type, long position, Boolean recursive); -extern int MoveSystemPathsIntoUserList(); -extern void AddVirtualFile(const char *filename, Handle *text); -extern void GetOutputFileDirectory(OSPathSpec *dir); -extern void SetOutputFileDirectory(const OSPathSpec *dir); -extern void AddOverlayGroup(const char *name, CWAddr64 *addr, long *groupnum, long *overlaynum); -extern void AddOverlay(long groupnum, const char *name, long *overlaynum); -extern void AddSegment(const char *name, short attrs, long *segmentnum); -extern void ChangeSegment(long segmentnum, const char *name, short attrs); -extern int GetSegment(long segmentnum, char *name, short *attrs); - -/********************************/ -/* Targets.c */ -extern int SetParserToolInfo(ParserTool *tool); -extern Boolean ParserToolMatchesPlugin(CWDataType type, CWDataType lang, CWDataType cpu, CWDataType os); -extern Boolean ParserToolHandlesPanels(int numPanels, const char **panelNames); -extern Boolean SetupParserToolOptions(); - -/********************************/ -/* Option.c */ -typedef struct { - void *first; - void *second; -} Opt50; -typedef struct { - Option *opt; - char *curopt; -} Opt52; -typedef struct { - union { - Opt50 v; - OptionList *lst; - Opt52 o; - char *param; - } e; - short flags; -} Opt48; -//static void Option_PushList(OptionList *lst); -//static void Option_PushOpt(Option *opt, const char *optname); -//static void Option_PopOpt(const char *optname); -//static void Option_PopList(); -extern void Args_InitStack(); -extern int Args_StackSize(); -extern void Args_Push(short flags, void *first, void *second); -extern Opt48 *Args_Pop(short flags); -extern void Args_SpellStack(char *buffer, short flags); -extern void Args_AddToToolArgs(anon0_50 *ta); -extern void Options_Init(); -extern OptionList *Options_GetOptions(); -extern void Options_SortOptions(); -//static void Options_AddOption(Option *opt); -extern int Options_AddList(OptionList *optlst); -extern int Options_AddLists(OptionList **optlst); -//static void Options_Reset(OptionList *optlst); -//static void Option_SpellList(char *buffer, OptionList *conflicts, int flags); -extern int Option_ForTool(Option *opt, int which); -extern int Option_ThisTool(); -extern int Option_ForThisTool(Option *opt); -extern int Option_AlsoPassedToTool(Option *opt, int which); -extern int Option_AlsoPassedFromThisTool(Option *opt); -//static Boolean Option_ContinuesThisLevel(int level, ArgToken *tok); -//static Boolean Option_IsEndingThisLevel(int level, ArgToken *tok); -//static Boolean Option_IsEndingLevel(int level, ArgToken *tok); -extern int Option_Parse(Option *opt, int oflags); -//static int Option_MatchString(char *list, char *str, int flags, int *result); -//static Option *Option_Lookup(OptionList *search, void *unk, int *flags); -//static int Options_DoParse(OptionList *search, int flags); -extern int Options_Parse(OptionList *options, int flags); -extern int Option_ParseDefaultOption(OptionList *options); -extern void Option_ParamError(short id, va_list ap); -extern void Option_ParamWarning(short id, va_list ap); -extern void Option_OptionError(short id, va_list ap); -extern void Option_OptionWarning(short id, va_list ap); -extern void Option_Error(short id, ...); -extern void Option_Warning(short id, ...); -extern int Options_Help(const char *keyword); -extern int Option_Help(const char *opt); -extern int Options_DisplayHelp(); - -/********************************/ -/* ParserErrors.c */ -extern void CLPReportError_V(const char *format, va_list ap); -extern void CLPReportWarning_V(const char *format, va_list ap); -extern void CLPReport_V(const char *format, va_list ap); -extern void CLPStatus_V(const char *format, va_list ap); -extern void CLPAlert_V(const char *format, va_list ap); -extern void CLPOSAlert_V(const char *format, long err, va_list ap); -extern void CLPGetErrorString(short errid, char *buffer); -extern void CLPReportError(short errid, ...); -extern void CLPReportWarning(short errid, ...); -extern void CLPReport(short errid, ...); -extern void CLPAlert(short errid, ...); -extern void CLPOSAlert(short errid, short err, ...); -extern void CLPProgress(short errid, ...); -extern void CLPStatus(short errid, ...); -extern void CLPFatalError(const char *format, ...); - -extern char curopt[1024]; - -/********************************/ -/* Utils.c */ -// something is weird with these parameters -// they're supposed to be just "char"... -extern int my_tolower(unsigned char c); -extern int my_isdigit(unsigned char c); -extern int my_isalpha(unsigned char c); -extern int my_isalnum(unsigned char c); -extern int my_isxdigit(unsigned char c); -extern char *Utils_SpellList(char *list, char *buffer, char opts); -extern int Utils_CompareOptionString(const char *a, const char *b, int cased, int sticky); - -/********************************/ -/* Parameter.c */ -extern void Param_DescHelp(PARAM_T *param, const char **desc, const char **help, const char **defaul); -extern int Param_Compare(PARAM_T *param); -extern int Params_Parse(PARAM_T *param, int flags); -extern void Param_Error(short id, ...); -extern void Param_Warning(short id, ...); - -/********************************/ -/* Help.c */ -extern int Help_Option(struct OptionList *lst, struct Option *opt, int subprint, const char *keyword); -extern void Help_Options(struct OptionList *lst, int subprint, const char *keyword); -extern void Help_Usage(); -extern void Help_Null(); -extern void Help_Init(); -extern void Help_Line(char ch); -extern void Help_Term(); - -/********************************/ -/* */ - -/********************************/ -/* */ - -/********************************/ -/* ?? COS */ -// static COS_pstrcpy -// static COS_pstrcat -// static COS_pstrcharcat -// static COS_pstrcmp -extern Handle COS_NewHandle(long byteCount); -extern Handle COS_NewOSHandle(long logicalSize); -extern void COS_FreeHandle(Handle handle); -extern Boolean COS_ResizeHandle(Handle handle, long newSize); -extern long COS_GetHandleSize(Handle handle); -extern void COS_LockHandle(Handle handle); -extern void COS_LockHandleHi(Handle handle); -extern void COS_UnlockHandle(Handle handle); -extern int COS_GetHandleState(Handle handle); -extern void COS_SetHandleState(Handle handle, int state); -extern Boolean COS_IsLockedState(int state); -extern char *COS_NewPtr(long byteCount); -extern char *COS_NewPtrClear(long byteCount); -extern void COS_FreePtr(char *ptr); -extern void COS_AppendPtrToHandle(char *ptr1, Handle hand2, long size); -extern short COS_GetMemErr(); -extern long COS_GetTicks(); -extern long COS_GetTime(); -extern void COS_GetString(char *buffer, short strListID, short index); -extern void COS_GetPString(unsigned char *buffer, short strListID, short index); -extern Boolean COS_IsMultiByte(char *buffer, char *str); -extern short COS_FileNew(const FSSpec *spec, short *refNum, FourCharCode creator, FourCharCode fileType); -extern short COS_FileOpen(const FSSpec *spec, short *refNum); -extern short COS_FileGetType(const FSSpec *spec, FourCharCode *fileType); -extern short COS_FileGetSize(short refNum, long *logEOF); -extern short COS_FileRead(short refNum, void *buffPtr, long count); -extern short COS_FileWrite(short refNum, const void *buffPtr, long count); -extern short COS_FileGetPos(short refNum, long *filePos); -extern short COS_FileSetPos(short refNum, long filePos); -extern short COS_FileClose(short refNum); -extern void COS_FileSetFSSpec(FSSpec *spec, unsigned char *path); -extern short COS_FileMakeFSSpec(short vRefNum, long dirID, unsigned char *fileName, FSSpec *spec); -extern short COS_FileMakeFSSpecWithPath(const FSSpec *inputSpec, unsigned char *fileName, FSSpec *spec); -extern short COS_FileGetFileInfo(const FSSpec *spec, OSType *creator, OSType *fileType); -extern void COS_FileGetFSSpecInfo(const FSSpec *spec, short *vRefNum, long *dirID, unsigned char *fileName); -//static void COS_MakePath(short vRefNum, long dirID, char *path); -extern void COS_FileGetPathName(char *buffer, const FSSpec *spec, long *mdDat); -extern Boolean COS_EqualFileSpec(const FSSpec *a, const FSSpec *b); - -/********************************/ -/* */ - -// TODO sort me -extern Proj *gProj; -extern ParserTool *pTool; -extern PCmdLine optsCmdLine; -extern PCmdLineEnvir optsEnvir; -extern PCmdLineCompiler optsCompiler; -extern PCmdLineLinker optsLinker; -extern CLState clState; - -/********************************/ -/* CmdLineBuildDate.c */ -extern char CMDLINE_BUILD_DATE[]; -extern char CMDLINE_BUILD_TIME[]; - - -/********************************/ -/* MISC */ -extern void IO_Terminate(); -extern void SetupDebuggingTraps(); -extern void AppendArgumentList(void *unk1, void *unk2, const char *arg); - -extern int (*PrefPanelsChangedCallback)(const char *); -extern Boolean systemHandles; -extern char *MAINOPTCHAR; -extern char *SEPOPTSTR; -extern char compat; -extern anon0_50 linkargs; - -#ifdef __cplusplus -} -#endif diff --git a/setup.sh b/setup.sh index 83038c4..cdeab68 100644 --- a/setup.sh +++ b/setup.sh @@ -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=/usr/include -export MWCIncludes=/Applications/Metrowerks\ CodeWarrior\ 7.0/Metrowerks\ CodeWarrior/MacOS\ X\ Support/MacHeaders\ Mach-O +export MWCIncludes=/usr/include +#export MWCIncludes=/Applications/Metrowerks\ CodeWarrior\ 7.0/Metrowerks\ CodeWarrior/MacOS\ X\ Support/MacHeaders\ Mach-O