From d1f153d34b023d81768f6087f67dbfff714bafc9 Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Wed, 19 Oct 2022 21:16:13 +0100 Subject: let's commit all this before my VM blows up and nukes my work --- Arguments.c | 604 --------- CMakeLists.txt | 26 +- CompilerTools.c | 30 +- Help.c | 560 -------- Option.c | 1136 ---------------- Parameter.c | 1146 ----------------- .../C++_Parser/Src/Library/WarningHelpers.c | 84 ++ command_line/CmdLine/Src/CLBrowser.c | 217 ++++ command_line/CmdLine/Src/CLDependencies.c | 407 ++++++ command_line/CmdLine/Src/CLFileOps.c | 803 ++++++++++++ command_line/CmdLine/Src/CLIncludeFileCache.c | 159 +++ command_line/CmdLine/Src/CLLicenses.c | 23 + command_line/CmdLine/Src/CLLoadAndCache.c | 85 ++ command_line/CmdLine/Src/CLMain.c | 34 +- command_line/CmdLine/Src/CLPluginAPI.c | 0 command_line/CmdLine/Src/CLPluginRequests.cpp | 348 +++++ command_line/CmdLine/Src/CLPrefs.c | 123 ++ command_line/CmdLine/Src/CLTarg.c | 55 + command_line/CmdLine/Src/CLToolExec.c | 243 ++++ command_line/CmdLine/Src/CLWriteObjectFile.c | 44 + .../Src/Callbacks/CLCompilerLinkerDropin_V10.cpp | 663 +++++++++- .../Src/Callbacks/CLDropinCallbacks_V10.cpp | 1353 +++++++++++++++++++- .../CmdLine/Src/Callbacks/CLParserCallbacks_v1.cpp | 233 +++- command_line/CmdLine/Src/Clients/CLStaticMain.c | 19 +- command_line/CmdLine/Src/Clients/ClientGlue.c | 4 +- command_line/CmdLine/Src/Envir/CLErrors.c | 91 +- command_line/CmdLine/Src/Envir/CLIO.c | 852 +++++++++++- command_line/CmdLine/Src/MacEmul/ErrMgr.c | 2 +- command_line/CmdLine/Src/MacEmul/Files.c | 2 +- command_line/CmdLine/Src/MacEmul/LowMem.c | 2 +- command_line/CmdLine/Src/MacEmul/Memory.c | 2 +- command_line/CmdLine/Src/MacEmul/ResourceStrings.c | 6 +- command_line/CmdLine/Src/MacEmul/Resources.c | 39 +- command_line/CmdLine/Src/MacEmul/TextUtils.c | 2 +- command_line/CmdLine/Src/OSLib/MacFileTypes.c | 6 +- command_line/CmdLine/Src/OSLib/Posix.c | 6 +- command_line/CmdLine/Src/Plugins/CLPlugins.c | 981 ++++++++++++++ command_line/CmdLine/Src/Project/CLAccessPaths.c | 525 ++++++++ command_line/CmdLine/Src/Project/CLFiles.c | 165 +++ command_line/CmdLine/Src/Project/CLOverlays.c | 296 +++++ command_line/CmdLine/Src/Project/CLProj.c | 16 + command_line/CmdLine/Src/Project/CLSegs.c | 123 ++ command_line/CmdLine/Src/uFileTypeMappings.c | 31 + .../BackEnd/PowerPC/Disassembler/InstPPC.c | 0 .../BackEnd/PowerPC/MachLinker/dumpmacho.c | 0 .../BackEnd/PowerPC/MachLinker/ld/4byte_literals.c | 0 .../BackEnd/PowerPC/MachLinker/ld/8byte_literals.c | 0 .../PowerPC/MachLinker/ld/coalesced_sections.c | 0 .../PowerPC/MachLinker/ld/cstring_literals.c | 0 .../BackEnd/PowerPC/MachLinker/ld/dylibs.c | 0 .../BackEnd/PowerPC/MachLinker/ld/fvmlibs.c | 0 .../BackEnd/PowerPC/MachLinker/ld/generic_reloc.c | 0 .../BackEnd/PowerPC/MachLinker/ld/hppa_reloc.c | 0 .../BackEnd/PowerPC/MachLinker/ld/i860_reloc.c | 0 .../PowerPC/MachLinker/ld/indirect_sections.c | 0 .../BackEnd/PowerPC/MachLinker/ld/layout.c | 0 .../BackEnd/PowerPC/MachLinker/ld/ld.c | 0 .../PowerPC/MachLinker/ld/literal_pointers.c | 0 .../BackEnd/PowerPC/MachLinker/ld/m68k_reloc.c | 0 .../BackEnd/PowerPC/MachLinker/ld/mod_sections.c | 0 .../BackEnd/PowerPC/MachLinker/ld/objects.c | 0 .../BackEnd/PowerPC/MachLinker/ld/pass1.c | 0 .../BackEnd/PowerPC/MachLinker/ld/pass2.c | 0 .../BackEnd/PowerPC/MachLinker/ld/ppc_reloc.c | 0 .../BackEnd/PowerPC/MachLinker/ld/sections.c | 0 .../BackEnd/PowerPC/MachLinker/ld/sparc_reloc.c | 0 .../BackEnd/PowerPC/MachLinker/ld/specs.c | 0 .../BackEnd/PowerPC/MachLinker/ld/symbols.c | 0 .../BackEnd/PowerPC/MachLinker/libstuff/arch.c | 0 .../PowerPC/MachLinker/libstuff/best_arch.c | 0 .../BackEnd/PowerPC/MachLinker/libstuff/bytesex.c | 0 .../MachLinker/libstuff/get_arch_from_host.c | 0 .../PowerPC/MachLinker/libstuff/get_toc_byte_sex.c | 0 .../PowerPC/MachLinker/libstuff/guess_short_name.c | 0 .../BackEnd/PowerPC/MachLinker/libstuff/hppa.c | 0 .../BackEnd/PowerPC/MachLinker/libstuff/ofile.c | 0 .../BackEnd/PowerPC/MachLinker/libstuff/reloc.c | 0 .../PowerPC/MachLinker/libstuff/seg_addr_table.c | 0 .../MachLinker/libstuff/set_arch_flag_name.c | 0 .../PowerPC/MachLinker/libstuff/swap_headers.c | 0 .../PowerPC/MachLinker/libstuff/version_number.c | 0 .../BackEnd/PowerPC/MachLinker/misc/libtool.c | 0 .../BackEnd/PowerPC/MachLinker/mwerks_allocate.c | 0 .../BackEnd/PowerPC/MachLinker/mwerks_execute.c | 0 .../Tools_PPC/Lib/mac-ppc-cc/OptsBackEnd.opt | 786 ++++++++++++ .../Tools_PPC/Lib/mac-ppc-cc/OptsCmdLine.opt | 809 ++++++++++++ .../Lib/mac-ppc-cc/OptsCmdLineCompiler.opt | 1028 +++++++++++++++ .../Tools_PPC/Lib/mac-ppc-cc/OptsCmdLineLinker.opt | 199 +++ .../Tools_PPC/Lib/mac-ppc-cc/OptsDebugging.opt | 80 ++ .../Tools_PPC/Lib/mac-ppc-cc/OptsDumper.opt | 368 ++++++ .../Tools_PPC/Lib/mac-ppc-cc/OptsFrontEndC.opt | 1208 +++++++++++++++++ .../Tools_PPC/Lib/mac-ppc-cc/OptsLinker.opt | 321 +++++ .../Tools_PPC/Lib/mac-ppc-cc/OptsOptimizer.opt | 765 +++++++++++ .../Tools_PPC/Lib/mac-ppc-cc/OptsProject.opt | 320 +++++ .../Tools_PPC/Lib/mac-ppc-cc/OptsWarningC.opt | 583 +++++++++ .../Tools_PPC/Lib/mac-ppc-ld/OptsCmdLine.opt | 0 .../Tools_PPC/Lib/mac-ppc-ld/OptsCmdLineLinker.opt | 0 .../Tools_PPC/Lib/mac-ppc-ld/OptsDebugging.opt | 0 .../Tools_PPC/Lib/mac-ppc-ld/OptsDumper.opt | 0 .../Tools_PPC/Lib/mac-ppc-ld/OptsLinker.opt | 0 .../Tools_PPC/Lib/mac-ppc-ld/OptsProject.opt | 0 .../Tools_PPC/Lib/mac-ppc-ld/OptsWarning.opt | 0 .../Src/Options/Glue/ParserGlue-mach-ppc-cc.c | 137 ++ .../Src/Options/Glue/ParserGlue-mach-ppc-common.h | 147 +++ .../Src/Options/Glue/ParserGlue-mach-ppc-ld.c | 0 .../Src/Options/Glue/TargetWarningHelpers-ppc-cc.c | 84 ++ .../Src/Options/Glue/TargetWarningHelpers-ppc-ld.c | 0 .../MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.c | 582 +++++++++ .../MacOS_PPC/Tools_PPC/Src/Plugin/ld-mach-ppc.c | 0 .../Tools_PPC/Src/Plugin/libimp-mach-ppc.c | 146 +++ .../Tools_PPC/Src/Static/cc-mach-ppc-mw.c | 31 + .../Tools_PPC/Src/Static/ld-mach-ppc-mw.c | 0 .../Resources/MachOLinkErrors.r | 1 + includes/cmdline.h | 749 +++++++++++ includes/common.h | 10 +- includes/cos.h | 41 + includes/cw_common.h | 43 + includes/macemul.h | 4 +- includes/mwcc_decomp.h | 1225 +----------------- includes/option_system.h | 73 +- includes/oslib.h | 18 +- includes/parser.h | 370 ++++++ includes/plugin.h | 123 +- includes/plugin_internal.h | 9 +- includes/pref_structs.h | 253 ++++ notes | 109 +- opt_decomp.py | 394 ++++++ opt_recomp.py | 381 ++++++ optdump.py | 386 ++++++ osx_build.sh | 89 ++ sdk_hdrs/CompilerMapping.h | 2 +- setup.sh | 9 +- unsorted/Arguments.c | 591 +++++++++ unsorted/Help.c | 561 ++++++++ unsorted/IO.c | 6 +- unsorted/OptimizerHelpers.c | 166 +++ unsorted/Option.c | 1134 ++++++++++++++++ unsorted/Parameter.c | 1146 +++++++++++++++++ unsorted/ParserErrors.c | 2 +- unsorted/ParserFace.c | 28 +- unsorted/ParserHelpers-cc.c | 22 +- unsorted/ParserHelpers.c | 65 +- unsorted/Projects.c | 3 +- unsorted/StaticParserGlue.c | 3 +- unsorted/TargetOptimizer-ppc-mach.c | 69 + unsorted/Targets.c | 6 +- unsorted/ToolHelpers-cc.c | 5 +- unsorted/ToolHelpers.c | 32 +- unsorted/Utils.c | 174 +++ unsorted/uCOS.c | 292 +++++ unsorted/uContextParser.cpp | 2 +- unsorted/uLibImporter.c | 103 ++ 152 files changed, 22760 insertions(+), 5079 deletions(-) delete mode 100644 Arguments.c delete mode 100644 Help.c delete mode 100644 Option.c delete mode 100644 Parameter.c create mode 100644 command_line/C++_Parser/Src/Library/WarningHelpers.c delete mode 100644 command_line/CmdLine/Src/CLPluginAPI.c create mode 100644 command_line/CmdLine/Src/CLPluginRequests.cpp create mode 100644 command_line/CmdLine/Src/uFileTypeMappings.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/Disassembler/InstPPC.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/dumpmacho.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/4byte_literals.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/8byte_literals.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/coalesced_sections.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/cstring_literals.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/dylibs.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/fvmlibs.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/generic_reloc.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/hppa_reloc.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/i860_reloc.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/indirect_sections.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/layout.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/ld.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/literal_pointers.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/m68k_reloc.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/mod_sections.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/objects.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/pass1.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/pass2.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/ppc_reloc.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/sections.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/sparc_reloc.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/specs.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/symbols.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/arch.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/best_arch.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/bytesex.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/get_arch_from_host.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/get_toc_byte_sex.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/guess_short_name.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/hppa.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/ofile.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/reloc.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/seg_addr_table.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/set_arch_flag_name.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/swap_headers.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/version_number.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/misc/libtool.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/mwerks_allocate.c create mode 100644 compiler_and_linker/BackEnd/PowerPC/MachLinker/mwerks_execute.c create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsBackEnd.opt create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsCmdLine.opt create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsCmdLineCompiler.opt create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsCmdLineLinker.opt create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsDebugging.opt create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsDumper.opt create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsFrontEndC.opt create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsLinker.opt create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsOptimizer.opt create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsProject.opt create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsWarningC.opt create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-ld/OptsCmdLine.opt create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-ld/OptsCmdLineLinker.opt create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-ld/OptsDebugging.opt create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-ld/OptsDumper.opt create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-ld/OptsLinker.opt create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-ld/OptsProject.opt create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-ld/OptsWarning.opt create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-cc.c create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-common.h create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-ld.c create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-cc.c create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-ld.c create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.c create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/ld-mach-ppc.c create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/libimp-mach-ppc.c create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Static/cc-mach-ppc-mw.c create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Static/ld-mach-ppc-mw.c create mode 100644 compiler_and_linker/Plugin_Tools/MacOS_PPC/Linker_MacOS_MachPPC/Resources/MachOLinkErrors.r create mode 100644 includes/cmdline.h create mode 100644 includes/cos.h create mode 100644 includes/cw_common.h create mode 100644 includes/parser.h create mode 100644 includes/pref_structs.h create mode 100644 opt_decomp.py create mode 100644 opt_recomp.py create mode 100644 optdump.py create mode 100755 osx_build.sh create mode 100644 unsorted/Arguments.c create mode 100644 unsorted/Help.c create mode 100644 unsorted/OptimizerHelpers.c create mode 100644 unsorted/Option.c create mode 100644 unsorted/Parameter.c create mode 100644 unsorted/TargetOptimizer-ppc-mach.c create mode 100644 unsorted/Utils.c create mode 100644 unsorted/uCOS.c create mode 100644 unsorted/uLibImporter.c diff --git a/Arguments.c b/Arguments.c deleted file mode 100644 index 324965a..0000000 --- a/Arguments.c +++ /dev/null @@ -1,604 +0,0 @@ -#include "includes/mwcc_decomp.h" - -char compat; -char *MAINOPTCHAR; -char *FIRSTARGCHAR; -char *SEPOPTSTR; -char SEPOPTCHAR; -char SEP1; -char SEP2; -char SEP3; -char RESPFILECHAR; -char *RESPFILESTR; -static ArgToken *argtoks; -static int numargtoks; -static int maxargtoks; -unsigned char parserDebug; -static unsigned char in_response_file; -static int margc; -static int margind; -static char **margv; -static OSFileHandle respfilehandle; -static char *respfile; -static char *respfilestart; -static unsigned long respfilesize; -static int scantok; -anon0_50 linkargs; -anon0_50 prelinkargs; -anon0_50 postlinkargs; - -// TODO move me -/*extern int OS_MakeFileSpec(const char *name, struct OSSpec *spec); -extern int OS_NewFileHandle(struct OSSpec *spec, int a, int b, OSFileHandle *fh); -extern int OS_AppendHandle(struct OSHandle *h, const void *, long); -extern int OS_LockFileHandle(OSFileHandle *fh, char **h, unsigned long *size); -extern void OS_FreeFileHandle(OSFileHandle *fh); -extern void CLPOSAlert(short code, short code2, ...); -extern void CLPReportError(short code, ...); -extern void CLPReportWarning(short code, ...); -extern void CLPFatalError(const char *format, ...); -extern int ustrncmp(const char *a, const char *b, int len);*/ -// TODO move me - -static void Arg_AddToken(short val, char *text); -static void Arg_Setup(int argc, char **argv); -static void Arg_SkipRespFileWS(); -static unsigned char Arg_OpenRespFile(const char *name); -static void Arg_CloseRespFile(); -static char *Arg_GetRespFileToken(); -static char *Arg_GetNext(unsigned char allow_resp); -static unsigned char Arg_GotMore(); -static void Arg_Parse(); -static void Arg_GrowArgs(anon0_50 *ta); -static void Arg_GrowArg(anon0_50 *ta, char *txt); - -static void Arg_AddToken(short val, char *text) { - ArgToken *cur; - ArgToken *prev; - ArgToken *pprev; - ArgToken *ppprev; - ArgToken *pppprev; - - if (numargtoks > 0) - prev = &argtoks[numargtoks - 1]; - else - prev = 0; - - if (prev && prev->val == ATK_2 && prev->text[0] == 0) { - pppprev = ppprev = pprev = 0; - if (numargtoks > 3) - pppprev = &argtoks[numargtoks - 4]; - if (numargtoks > 2) - ppprev = &argtoks[numargtoks - 3]; - if (numargtoks > 1) - pprev = &argtoks[numargtoks - 2]; - - if (pprev) { - if ((int) val == ATK_1 && (pprev->val == ATK_5 || pprev->val == ATK_4) && (ppprev->val != ATK_2 || pppprev->val != ATK_3)) { - if (parserDebug) - printf("Coalescing args with '%s'\n", Arg_GetTokenName(pprev)); - val = pprev->val; - numargtoks -= 2; - } else if (pprev->val == ATK_1 && ((int) val == ATK_5 || (int) val == ATK_4)) { - if (parserDebug) - printf("Coalescing args, removing '%s'\n", Arg_GetTokenName(pprev)); - numargtoks -= 2; - } - } - } - - if (numargtoks >= maxargtoks) { - argtoks = (ArgToken *) xrealloc("argument list", argtoks, sizeof(ArgToken) * (maxargtoks + 16)); - maxargtoks += 16; - } - - cur = &argtoks[numargtoks]; - cur->val = val; - if (text) - cur->text = xstrdup(text); - else - cur->text = 0; - numargtoks++; -} - -static void Arg_Setup(int argc, char **argv) { - in_response_file = 0; - respfile = 0; - margc = argc; - margv = argv; - margind = 1; -} - -static void Arg_SkipRespFileWS() { -restart: - while (respfile[0] && isspace(respfile[0])) - ++respfile; - - if (respfile[0] == '\\' && respfile[1] == '#') { - ++respfile; - return; - } - - if (respfile[0] == '#') { - if ((respfile > respfilestart) ? (respfile[-1] != '\\') : 1) { - while (respfile[0] && respfile[0] != 10 && respfile[0] != 13) - ++respfile; - - while (respfile[0] == 13 || respfile[0] == 10) - ++respfile; - - goto restart; - } - } -} - -static unsigned char Arg_OpenRespFile(const char *name) { - struct OSSpec spec; - int err; - - if ( - (err = OS_MakeFileSpec(name, &spec)) - || (err = OS_NewFileHandle(&spec, 0, 0, &respfilehandle)) - || (err = OS_AppendHandle(&respfilehandle.hand, "", 1)) - || (err = OS_LockFileHandle(&respfilehandle, &respfile, &respfilesize)) - ) { - CLPOSAlert(74, (short) err, "response ", name); - return 0; - } else { - respfilestart = respfile; - Arg_SkipRespFileWS(); - in_response_file = 1; - return 1; - } -} - -static void Arg_CloseRespFile() { - in_response_file = 0; - OS_FreeFileHandle(&respfilehandle); -} - -static char *Arg_GetRespFileToken() { - char *start; - char *ptr; - int quoting; - - quoting = 0; - if (respfile[0] == 0) - return 0; - - start = ptr = respfile; - while (respfile[0]) { - if (!quoting && isspace(respfile[0])) - break; - - if (respfile[0] == '"') { - quoting = !quoting; - respfile++; - } else if (respfile[0] == '\\' && respfile[1] == '"') { - *ptr = '"'; - respfile += 2; - ptr++; - } else { - *(ptr++) = *(respfile++); - } - } - - if (respfile[0]) - Arg_SkipRespFileWS(); - *ptr = 0; - return start; -} - -static char *Arg_GetNext(unsigned char allow_resp) { - char *ret; - int rfclen; - char *rfcequ; - -restart: - if (!in_response_file) { - rfclen = 1; - ret = margv[margind++]; - if (ret[0] == '\\' && ret[1] == RESPFILECHAR) { - ret++; - } else if (allow_resp) { - if (ret[0] == RESPFILECHAR || (RESPFILESTR[0] && !ustrncmp(ret, RESPFILESTR, rfclen = strlen(RESPFILESTR))) && ret[rfclen]) { - rfcequ = strchr(ret + rfclen, '='); - if (rfcequ) - rfclen = (rfcequ + 1) - ret; - if (Arg_OpenRespFile(ret + rfclen)) - goto restart; - ret = 0; - } - } - } else { - ret = Arg_GetRespFileToken(); - if (!ret) { - Arg_CloseRespFile(); - goto restart; - } - } - - if (parserDebug) - fprintf(stderr, "Got arg = '%s'\n", ret ? ret : ""); - - return ret; -} - -static unsigned char Arg_GotMore() { - if (!in_response_file) - return margind < margc; - else if (respfile[0]) - return 1; - else - return margind < margc; -} - -static void Arg_Parse() { - unsigned char isOpt; - unsigned char isList; - char *arg; - char *argstart; - char buffer[4096]; - char *bufptr; - char ch; - - isOpt = 0; - isList = 0; - while (Arg_GotMore()) { - argstart = arg = Arg_GetNext(1); - if (!arg) - break; - - bufptr = buffer; - buffer[0] = 0; - isList = 0; - - if (arg[0] && arg[1] && strchr(MAINOPTCHAR, arg[0])) { - if (isOpt) - Arg_AddToken(ATK_1, 0); - buffer[0] = arg[1]; - buffer[1] = 0; - isOpt = 1; - isList = 0; - bufptr++; - arg += 2; - } else { - isOpt = 0; - } - - while (arg && arg[0]) { - ch = arg[0]; - if (arg[0] == '\\' && (arg[1] == SEP1 || arg[1] == SEP2 || arg[1] == SEP3)) { - ch = 0x80 | *(++arg); - } else if (compat == 1 && arg[0] == ':' && arg[1] == '\\') { - ch |= 0x80; - } - - if (ch != SEP1 && ch != SEP2 && ch != SEP3) { - if ((ch & 0x7F) == SEP1 || (ch & 0x7F) == SEP2 || (ch & 0x7F) == SEP3) - ch &= 0x7F; - *(bufptr++) = ch; - if (bufptr >= &buffer[sizeof(buffer)]) { - CLPReportError(2, argstart, argstart + strlen(argstart) - 15, sizeof(buffer)); - } - *bufptr = 0; - } else { - if (isOpt) { - Arg_AddToken(ATK_3, buffer); - Arg_AddToken(ATK_2, buffer); - } else { - Arg_AddToken(ATK_2, buffer); - } - - Arg_AddToken( - (unsigned char) ((ch == ',') ? ATK_5 : (((ch == '=') || (ch == SEP3)) ? ATK_4 : ATK_0)), - 0 - ); - - bufptr = buffer; - buffer[0] = 0; - - if (ch == SEP1 || ch == SEP2 || ch == SEP3) - isOpt = 0; - isList = 1; - } - - arg++; - } - - // 1799C8 - if (isOpt && bufptr > &buffer[0]) { - Arg_AddToken(ATK_3, buffer + (isList && strchr(MAINOPTCHAR, buffer[0]))); - Arg_AddToken(ATK_2, buffer + (isList && strchr(MAINOPTCHAR, buffer[0])) + 1); - } else { - Arg_AddToken(ATK_2, buffer); - Arg_AddToken(ATK_1, 0); - } - } - - if (isOpt || isList) - Arg_AddToken(ATK_1, 0); - Arg_AddToken(ATK_0, 0); -} - -enum { - COMPAT_0, - COMPAT_1, - COMPAT_2 -}; - -void Arg_Init(int theargc, char **theargv) { - int p; - int x; - - maxargtoks = 0; - numargtoks = 0; - parserDebug = 0; - if (theargc > 1 && !strcmp(theargv[1], "--parser-debug")) { - parserDebug = 1; - memmove(&theargv[1], &theargv[2], sizeof(char *) * (theargc - 1)); - theargc--; - } - - if ((int) compat == COMPAT_0) { - MAINOPTCHAR = "-"; - FIRSTARGCHAR = "="; - SEPOPTSTR = " "; - SEP1 = ','; - SEP2 = '='; - SEP3 = '='; - RESPFILECHAR = '@'; - RESPFILESTR = ""; - } else if ((int) compat == COMPAT_1) { - MAINOPTCHAR = "/-"; - FIRSTARGCHAR = ":"; - SEPOPTSTR = ":"; - SEP1 = ','; - SEP2 = '='; - SEP3 = ':'; - RESPFILECHAR = '@'; - RESPFILESTR = ""; - } else if ((int) compat == COMPAT_2) { - if (!MAINOPTCHAR) - MAINOPTCHAR = "-"; - if (!FIRSTARGCHAR) - FIRSTARGCHAR = "="; - if (!SEPOPTSTR) - SEPOPTSTR = " "; - if (!SEP1) - SEP1 = ','; - if (!SEP2) - SEP2 = '='; - if (!SEP3) - SEP3 = '='; - if (!RESPFILECHAR) - RESPFILECHAR = '@'; - if (!RESPFILESTR) - RESPFILESTR = ""; - } else { - CLPFatalError("Unknown parser compatibility type (%d)\n", (int) compat); - } - - if (parserDebug) { - printf("Incoming arguments: \n"); - for (p = 0; p < theargc; p++) { - printf("[%s] ", theargv[p]); - } - printf("\n"); - } - - Arg_Setup(theargc, theargv); - Arg_Parse(); - Arg_Reset(); - - if (parserDebug) { - for (x = 0; x < numargtoks; x++) { - printf("TOKEN: '%s'\n", Arg_GetTokenName(&argtoks[x])); - } - } -} - -void Arg_Terminate() { - ArgToken *cur; - - while (numargtoks > 0) { - cur = &argtoks[--numargtoks]; - if (cur->text) - free(cur->text); - } - - if (maxargtoks) - free(argtoks); - maxargtoks = 0; -} - -void Arg_Reset() { - scantok = 0; -} - -void Arg_Stop(ArgToken *where) { - ArgToken *cur; - - while (&argtoks[numargtoks] > where) { - cur = &argtoks[--numargtoks]; - if (cur->text) - free(cur->text); - cur->val = ATK_0; - cur->text = 0; - } - - argtoks[numargtoks++].val = ATK_1; - argtoks[numargtoks++].val = ATK_0; - scantok = numargtoks - 2; -} - -ArgToken *Arg_PeekToken() { - if (scantok >= numargtoks) - return 0; - else - return &argtoks[scantok]; -} - -ArgToken *Arg_UsedToken() { - if (scantok < numargtoks) - scantok++; - return Arg_PeekToken(); -} - -int Arg_IsEmpty() { - ArgToken *tok; - - tok = Arg_PeekToken(); - return (tok == 0 || tok->val == ATK_0); -} - -ArgToken *Arg_GetToken() { - ArgToken *ret; - - ret = Arg_PeekToken(); - if (ret) - scantok++; - return ret; -} - -ArgToken *Arg_UndoToken() { - if (scantok > 0) { - scantok--; - return Arg_PeekToken(); - } else { - return 0; - } -} - -const char *Arg_GetTokenName(ArgToken *tok) { - if ((int) tok->val == ATK_2) - return tok->text; - - return - ((int) tok->val == ATK_3) ? "option" : - ((int) tok->val == ATK_5) ? "comma" : - (((int) compat == COMPAT_1 && (int) tok->val == ATK_4)) ? "colon or equals" : - (((int) compat != COMPAT_1 && (int) tok->val == ATK_4)) ? "equals" : - ((int) tok->val == ATK_1) ? "end of argument" : - ((int) tok->val == ATK_0) ? "end of command line" : - ""; -} - -const char *Arg_GetTokenText(ArgToken *tok, char *buffer, int maxlen, unsigned char warn) { - const char *ptr; - char *bptr; - int curlen; - - bptr = buffer; - curlen = 0; - if (tok->val == ATK_2 || tok->val == ATK_3) - ptr = tok->text; - else - ptr = Arg_GetTokenName(tok); - - while (*ptr && curlen++ < maxlen) { - *(bptr++) = *(ptr++); - } - - if (curlen < maxlen) { - bptr[0] = 0; - } else { - bptr[-1] = 0; - if (warn) - CLPReportWarning(56, buffer, ptr + strlen(ptr) - ((maxlen <= 32) ? maxlen : 32), maxlen); - } - - return buffer; -} - -static void Arg_GrowArgs(anon0_50 *ta) { - int len; - - if (!ta->argv || (ta->argc + 1) >= ta->nargv) { - len = ta->nargv; - ta->nargv = len + 16; - ta->argv = xrealloc("argument list", ta->argv, sizeof(char *) * (ta->nargv + 1)); - while (len <= ta->nargv) { - ta->argv[len++] = 0; - } - } - - ta->argc++; -} - -static void Arg_GrowArg(anon0_50 *ta, char *txt) { - char **ptr; - int ptrlen; - - ptr = &ta->argv[ta->argc]; - - if (*ptr == 0) { - *ptr = xstrdup(txt); - } else { - ptrlen = strlen(*ptr); - *ptr = xrealloc("command line", *ptr, ptrlen + strlen(txt) + 1); - strcpy(*ptr + ptrlen, txt); - } -} - -void Arg_InitToolArgs(anon0_50 *ta) { - ta->argc = 0; - ta->nargv = 0; - ta->argv = 0; - Arg_GrowArgs(ta); -} - -void Arg_AddToToolArgs(anon0_50 *ta, short tokval, char *toktxt) { - switch (tokval) { - case ATK_0: - Arg_FinishToolArgs(ta); - break; - case ATK_1: - if (ta->argv && ta->argv[ta->argc]) - Arg_GrowArgs(ta); - break; - case ATK_2: - Arg_GrowArg(ta, toktxt); - break; - case ATK_3: - Arg_GrowArg(ta, "-"); - break; - case ATK_4: - Arg_GrowArg(ta, "="); - break; - case ATK_5: - Arg_GrowArg(ta, ","); - break; - default: -#line 787 - CLPFatalError(__FILE__, __LINE__, "Unknown token (%d)", tokval); - break; - } -} - -void Arg_FinishToolArgs(anon0_50 *ta) { - Arg_GrowArgs(ta); - ta->argv[ta->argc] = 0; -} - -void Arg_ToolArgsForPlugin(anon0_50 *ta, struct CWCommandLineArgs *args) { - args->argc = 1; - args->argv = ta->argv; - - while (args->argv[args->argc]) - args->argc++; - - args->envp = 0; -} - -void Arg_FreeToolArgs(anon0_50 *ta) { - int x; - - if (ta->argv) { - for (x = 1; x < ta->argc; x++) { - if (ta->argv[x]) - free(ta->argv[x]); - } - free(ta->argv); - } -} diff --git a/CMakeLists.txt b/CMakeLists.txt index 810b938..33718d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,6 @@ add_executable(mwcc 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 @@ -52,4 +51,27 @@ add_executable(mwcc unsorted/uContext1.cpp unsorted/uContextCL.cpp unsorted/uContextParser.cpp - unsorted/uContextSecret.cpp unsorted/StaticParserGlue.c unsorted/ParserHelpers.c unsorted/ToolHelpers.c unsorted/ParserHelpers-cc.c unsorted/ToolHelpers-cc.c unsorted/IO.c unsorted/Projects.c unsorted/Targets.c unsorted/ParserErrors.c) + unsorted/uContextSecret.cpp + unsorted/StaticParserGlue.c + unsorted/ParserHelpers.c + unsorted/ToolHelpers.c + unsorted/ParserHelpers-cc.c + unsorted/ToolHelpers-cc.c + unsorted/IO.c + unsorted/Projects.c + unsorted/Targets.c + unsorted/ParserErrors.c + unsorted/Utils.c + compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Static/cc-mach-ppc-mw.c + compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.c + compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/libimp-mach-ppc.c + command_line/C++_Parser/Src/Library/WarningHelpers.c + unsorted/uLibImporter.c + command_line/CmdLine/Src/CLPluginRequests.cpp + unsorted/uCOS.c + command_line/CmdLine/Src/uFileTypeMappings.c + compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-cc.c + unsorted/Arguments.c + unsorted/Help.c + unsorted/Option.c + unsorted/Parameter.c unsorted/TargetOptimizer-ppc-mach.c unsorted/OptimizerHelpers.c compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-cc.c) diff --git a/CompilerTools.c b/CompilerTools.c index daba8df..d2ff19d 100644 --- a/CompilerTools.c +++ b/CompilerTools.c @@ -192,10 +192,12 @@ void RemoveGListData(GList *list, long size) { char GetGListByte(GList *list) { unsigned char *p; + char r; p = (unsigned char *) (*list->data + list->size); list->size++; - return p[0]; + r = p[0]; + return r; } short GetGListWord(GList *list) { @@ -266,10 +268,9 @@ static short PHash(const unsigned char *str) { unsigned char work; const unsigned char *p; - result = str[0]; - result &= 0xFF; + result = str[0] & 0xFF; p = &str[1]; - if (str[0]) { + if (str[0] & 0xFF) { counter = result; work = 0; while (counter > 0) { @@ -287,21 +288,34 @@ static short PHash(const unsigned char *str) { short CHash(const char *str) { /* not matching :( */ + unsigned char len; short result; // orig r4 unsigned char work; // orig r5 short counter; // orig r3 + // counter,result,work -> r3=work, r4=counter, r5=result + // result,counter,work -> r3=work, r4=result, r5=counter + // work,result,counter -> r3=work, r4=result, r5=counter + // work,counter,result -> r3=work, r4=counter, r5=result + // counter,work,result -> r3=work, r4=counter, r5=result + // result,work,counter -> r3=work, r4=result, r5=counter + // i am: r4 = result, r5 = counter, r3 = work - if (result = strlen(str) & 0xFF) { - counter = result; + len = strlen(str); + result = len; + if (len) { + counter = len; work = 0; while (counter > 0) { work = (work >> 3) | (work << 5); - work = work + *(str++); + work = work + *str; + //work = *(str++) + (unsigned char) ((work >> 3) | (work << 5)); counter--; + str++; } - result = (result << 8) | work; + result = result << 8; + result = result | work; } return result & 0x7FF; diff --git a/Help.c b/Help.c deleted file mode 100644 index aaa4e9f..0000000 --- a/Help.c +++ /dev/null @@ -1,560 +0,0 @@ -#include "includes/mwcc_decomp.h" -typedef struct _Side { - short offset; - short width; - char buffer[1024]; - short bptr; - short blen; - short indent; - short vrow; - short vcol; - unsigned char atEOL; - unsigned char impInd; -} Side; - -short helpExtras; -unsigned char showedHelp; -Side left; -Side right; -Side all; -char **helptext; -static char outLine[256]; - -static void Help_Output(Side *left, Side *right); -static void Help_OutputSingle(Side *all); -static void Help_Flush(); - -static void Side_Init(Side *s, short offset, short width) { - memset(s, 0, sizeof(Side)); - s->offset = offset; - s->width = width; -} - -static void Side_Print(Side *s, const char *format, ...) { - char c; - char *text; - char buffer[1024]; - va_list args; - - va_start(args, format); - vsprintf(buffer, format, args); - va_end(args); - - text = buffer; - while (*text) { - if (s->blen < 1024) { - c = *(text++); - if (c == '~' && *text == '~') { - c = *MAINOPTCHAR; - text++; - } - - s->buffer[(s->bptr + s->blen) & 1023] = c; - s->blen++; - } else { - if (s == &left) - Help_Output(&left, &right); - else - Help_OutputSingle(&all); - } - } -} - -static void Side_NewLine(Side *s) { - Side_Print(s, "\n"); -} - -static void Side_Indent(Side *s, short how) { - if ((s->width - s->indent - how) > (parseopts.ioCols / 8)) - s->indent += how; - else if ((s->width - s->indent - 1) > (parseopts.ioCols / 10)) - s->indent++; -} - -static void Side_Outdent(Side *s, short how) { - if ((s->width - s->indent) < (parseopts.ioCols / 8)) - s->indent++; - else if (s->indent >= how) - s->indent -= how; -} - -static unsigned char isBreaker(char c) { - return (c == 10) || (c == 13) || (c == 32) || (c == 9) || (c == 8) || (c == '|'); -} - -static void Side_DumpLine(Side *s) { - short col; - short len; - short afterspace; - short eol; - short ind; - char c; - - eol = 0; - ind = 0; - col = s->offset + s->indent; - s->vcol = s->indent; - len = 0; - afterspace = s->width - s->indent; - - while (s->blen > 0 && s->vcol < s->width && !eol && !ind) { - c = s->buffer[s->bptr]; - outLine[col + len] = c; - s->vcol++; - len++; - - if (isBreaker(c)) { - afterspace = len; - eol = (c == '\n') || (c == '\r'); - eol += (c == '\r'); - ind = (c == '\b') || (c == '\t'); - ind += (c == '\b'); - } - - s->bptr = (s->bptr + 1) & 1023; - s->blen--; - } - - if (s->blen || eol || ind) { - s->blen += len - afterspace; - s->bptr = (s->bptr - (len - afterspace)) & 1023; - if (eol || ind) { - len++; - afterspace--; - } - - while (len > afterspace) { - outLine[col + --len] = ' '; - } - } - - s->vcol = 0; - s->vrow++; - s->atEOL = (eol == 1) || ind || !s->blen; - if ((s->atEOL || ind) && s->impInd) { - Side_Outdent(s, parseopts.ioCols / 40); - s->impInd = 0; - } - if (ind) { - if (ind == 1) - Side_Indent(s, parseopts.ioCols / 25); - else - Side_Outdent(s, parseopts.ioCols / 25); - } else if (!s->atEOL && s != &all && !s->impInd) { - Side_Indent(s, parseopts.ioCols / 40); - s->impInd = 1; - } -} - -static void Help_PrintLine() { - HPrintF(helptext, "%.*s\n", parseopts.ioCols - 1, outLine); -} - -static void Help_Output(Side *left, Side *right) { - while (left->blen || right->blen) { - memset(outLine, ' ', parseopts.ioCols); - outLine[left->offset + left->width + 1] = '#'; - if (left->atEOL && right->atEOL) - left->atEOL = right->atEOL = 0; - if (!left->atEOL) - Side_DumpLine(left); - if (!right->atEOL) - Side_DumpLine(right); - Help_PrintLine(); - } -} - -static void Help_OutputSingle(Side *all) { - while (all->blen) { - memset(outLine, ' ', parseopts.ioCols); - if (all->atEOL) - all->atEOL = 0; - if (!all->atEOL) - Side_DumpLine(all); - Help_PrintLine(); - } -} - -static void Help_Flush() { - Help_Output(&left, &right); -} - -static void Help_NewLine() { - Side_NewLine(&left); - Side_NewLine(&right); -} - -int Help_Option(struct OptionList *lst, struct Option *opt, int subprint, const char *keyword) { - char pfbuf[512]; - char slflags; - int listFlags; - Boolean allNoArgs; - PARAM_T *lastparam; - Boolean print; - Boolean printMe; - - if (!opt->names[0] && !(lst->flags & LISTFLAGS_4)) - return 0; - - if (keyword && keyword[0] && !strstr(opt->names, keyword) && (!opt->help || !strstr(opt->help, keyword))) - return 0; - - if ((opt->avail & OTF_SECRET) && !(parseopts.helpFlags & HELPFLAGS_SECRET)) - return 0; - - if ((opt->avail & OTF_OBSOLETE) && !(parseopts.helpFlags & HELPFLAGS_OBSOLETE)) - return 0; - - if ((opt->avail & OTF_DEPRECATED) && !(parseopts.helpFlags & HELPFLAGS_DEPRECATED)) - return 0; - - if ((opt->avail & OTF_IGNORED) && !(parseopts.helpFlags & HELPFLAGS_IGNORED)) - return 0; - - if ((opt->avail & OTF_MEANINGLESS) && !(parseopts.helpFlags & HELPFLAGS_MEANINGLESS)) - return 0; - - if (!(parseopts.helpFlags & HELPFLAGS_NORMAL) && !(opt->avail & OTF_ALL_HIDDEN_BY_DEFAULT)) - return 0; - - if (opt->help || (opt->avail & OTF8000)) { - allNoArgs = 1; - lastparam = 0; - if (parseopts.helpFlags & HELPFLAGS_SPACES) - Help_NewLine(); - if ((opt->avail & OTF_GLOBAL) && !subprint) - Side_Print(&right, "global; "); - if (compat != 1 && (opt->avail & OTF_CASED)) - Side_Print(&right, "cased; "); - - slflags = (subprint == 0) ? SLFLAGS_1 : SLFLAGS_2; - switch (opt->avail & OTF_SLFLAGS_MASK) { - case OTF_SLFLAGS_8: - slflags = slflags | SLFLAGS_8; - break; - case OTF_SLFLAGS_10: - slflags = slflags | SLFLAGS_10; - break; - case OTF_SLFLAGS_20: - slflags = slflags | SLFLAGS_20; - break; - } - if (opt->avail & OTF2) - slflags = slflags | SLFLAGS_40; - - Utils_SpellList(opt->names[0] ? opt->names : "...", pfbuf, slflags); - Side_Print(&left, pfbuf); - - if (opt->avail & OTF_OBSOLETE) - Side_Print(&right, "obsolete;\r"); - if (opt->avail & OTF_COMPATIBILITY) - Side_Print(&right, "compatibility;\r"); - if (opt->avail & OTF_IGNORED) - Side_Print(&right, "ignored;\r"); - - listFlags = ((lst->flags & LISTFLAGS_COMPILER) ? OTF_TOOL_COMPILER : 0) | ((lst->flags & LISTFLAGS_LINKER) ? OTF_TOOL_LINKER : 0) | ((lst->flags & LISTFLAGS_DISASSEMBLER) ? OTF_TOOL_DISASSEMBLER : 0); - if (!Option_ForThisTool(opt) || Option_AlsoPassedFromThisTool(opt) || listFlags != Option_ThisTool()) { - print = 0; - printMe = 1; - if ((opt->avail & OTF_TOOL_MASK) != (unsigned int) listFlags) - print = 1; - if (Option_ForThisTool(opt) && Option_AlsoPassedFromThisTool(opt)) - printMe = 0; - - if (print) { - char opttool[64] = ""; // stack 0x44 - if ((opt->avail & OTF_TOOL_MASK) == (unsigned int) OTF_TOOL_MASK) { - strcat(opttool, "all tools"); - } else { - if (Option_ForTool(opt, OTF_TOOL_COMPILER) && ((Option_ThisTool() != (unsigned int) OTF_TOOL_COMPILER) || printMe)) { - strcat(opttool, "this tool"); - } - if (Option_ForTool(opt, OTF_TOOL_LINKER) && ((Option_ThisTool() != (unsigned int) OTF_TOOL_LINKER) || printMe)) { - if (opttool[0]) - strcat(opttool, ", "); - strcat(opttool, "linker"); - } - if (Option_ForTool(opt, OTF_TOOL_DISASSEMBLER) && ((Option_ThisTool() != (unsigned int) OTF_TOOL_DISASSEMBLER) || printMe)) { - if (opttool[0]) - strcat(opttool, ", "); - strcat(opttool, "disassembler"); - } - if (!Option_ForTool(opt, OTF_TOOL_MASK)) - strcat(opttool, "another tool"); - } - - if (printMe || !Option_ForThisTool(opt)) { - Side_Print(&right, "for %s;\r", opttool); - } else if (parseopts.passingArgs) { - Side_Print(&right, "passed to %s;\r", opttool); - } - } - } - - if (opt->avail & OTF_WARNING) - Side_Print(&right, "warning:\r"); - - if (opt->avail & OTF_DEPRECATED) - Side_Print(&right, "deprecated;\rinstead use "); - else if (opt->avail & OTF_SUBSTITUTED) - Side_Print(&right, "substituted with "); - - if (opt->help) - Side_Print(&right, "%s", opt->help); - - if (opt->param && !(opt->avail & OTF_IGNORED)) { - PARAM_T *scan = opt->param; - PARAM_T *firstparam = 0; - const char *desc; - const char *help; - const char *defaul; - while (scan) { - if ((scan->flags & PARAMFLAGS_3) != PARAMFLAGS_1) { - if (!firstparam) - firstparam = scan; - - allNoArgs = 0; - Param_DescHelp(scan, &desc, &help, &defaul); - if (desc) { - if (((scan->flags & PARAMFLAGS_3) == PARAMFLAGS_2) && scan->which != PARAMWHICH_Setting && scan->which != PARAMWHICH_IfArg) { - if (SEPOPTSTR[0] == ' ') { - Side_Print(&left, (scan != firstparam) ? "[," : subprint ? "[=" : " ["); - } else { - Side_Print(&left, "[%s", (scan != firstparam) ? "," : subprint ? "=" : SEPOPTSTR); - } - } else { - Side_Print(&left, (scan != firstparam) ? "," : subprint ? "=" : ((opt->avail & OTF2) && !strchr(opt->names, '|')) ? "" : SEPOPTSTR); - } - Side_Print(&left, "%s", desc); - if (((scan->flags & PARAMFLAGS_3) == PARAMFLAGS_2) && scan->which != PARAMWHICH_Setting && scan->which != PARAMWHICH_IfArg) { - Side_Print(&left, "]"); - } - if (help) { - if ((scan->flags & PARAMFLAGS_3) != PARAMFLAGS_2) - Side_Print(&right, "; for '%s', %s", desc, help); - else - Side_Print(&right, "; if parameter specified, %s", help); - } - if (defaul && !(opt->avail & OTF2000)) { - if (firstparam == scan) - Side_Print(&right, "; default is %s", defaul); - else - Side_Print(&right, ",%s", defaul); - } - } - } - lastparam = scan; - scan = scan->next; - } - - if (allNoArgs && !(opt->avail & OTF2000)) { - PARAM_T *scan = opt->param; - Boolean isdefault = scan ? 1 : 0; - while (scan && isdefault) { - isdefault &= Param_Compare(scan); - scan = scan->next; - } - - if (isdefault) - Side_Print(&right, "; default"); - } - } - - if (opt->avail & OTF_MEANINGLESS) - Side_Print(&right, "; meaningless for this target"); - - if ((opt->avail & OTF8000) && opt->sub) { - if (!allNoArgs) { - Side_Print( - &left, - "%s", - (opt->avail & OTF10000) ? ((lastparam->flags & PARAMFLAGS_8) ? "[=" : "[,") : ((lastparam->flags & PARAMFLAGS_8) ? "," : "=") - ); - } else if (!(opt->avail & OTF2)) { - if (opt->avail & OTF10000) { - if (SEPOPTSTR[0] == ' ') - Side_Print(&left, subprint ? "[=" : " ["); - else - Side_Print(&left, "[%s", subprint ? "=" : SEPOPTSTR); - } else { - Side_Print(&left, "%c", subprint ? '=' : SEPOPTSTR[0]); - } - } else { - if (opt->avail & OTF10000) { - Side_Print(&left, subprint ? "[" : (SEPOPTSTR[0] == ' ') ? " [" : "["); - } - } - - Side_Print( - &left, - "%s%s%s", - opt->sub->help ? opt->sub->help : "keyword", - (opt->sub->flags & PARAMFLAGS_1) ? "" : "[,...]", - (opt->avail & OTF10000) ? "]" : "" - ); - - Side_Print(&left, "\t"); - Side_Print(&right, "\t"); - Help_Options(opt->sub, 1, ""); - Side_Print(&left, "\b"); - Side_Print(&right, "\b"); - } else { - Side_Print(&left, "\n"); - Side_Print(&right, "\n"); - } - } - - Help_Flush(); - return 1; -} - -void Help_Options(struct OptionList *lst, int subprint, const char *keyword) { - Option **opts; - int toolflags; - Boolean show; - - opts = lst->list; - toolflags = 0; - if (Option_ThisTool() == OTF_TOOL_COMPILER) { - toolflags |= LISTFLAGS_COMPILER; - } else { - toolflags |= LISTFLAGS_LINKER; - } - - // review me maybe? - if (!subprint && (parseopts.helpFlags & HELPFLAGS_TOOL)) { - if ((parseopts.helpFlags & HELPFLAGS_TOOL_BOTH) == HELPFLAGS_TOOL_THIS && (lst->flags & LISTFLAGS_TOOL_MASK) && !(lst->flags & toolflags)) - return; - if ((parseopts.helpFlags & HELPFLAGS_TOOL_BOTH) == HELPFLAGS_TOOL_OTHER && (((lst->flags & LISTFLAGS_TOOL_MASK) == (unsigned int) toolflags) || ((lst->flags & LISTFLAGS_TOOL_MASK) == (unsigned int) LISTFLAGS_NONE))) - return; - } - - if (lst->help && !subprint && opts[0]) { - Help_Line('-'); - Side_Print(&all, "%s", lst->help); - Help_OutputSingle(&all); - Help_Line('-'); - } - - while (*opts) { - show = 0; - if (!(parseopts.helpFlags & HELPFLAGS_TOOL)) { - if (((parseopts.helpFlags & HELPFLAGS_TOOL_BOTH) == HELPFLAGS_TOOL_BOTH) && (parseopts.passingArgs ? (Option_ForTool(*opts, OTF_TOOL_LINKER) || Option_ForTool(*opts, OTF_TOOL_DISASSEMBLER)) : 1) && Option_ForThisTool(*opts)) - show = 1; - } else if ((parseopts.helpFlags & HELPFLAGS_TOOL_BOTH) == HELPFLAGS_TOOL_BOTH) { - show = 1; - } else if ((parseopts.helpFlags & HELPFLAGS_TOOL_THIS) && Option_ForThisTool(*opts)) { - show = 1; - } else if ((parseopts.helpFlags & HELPFLAGS_TOOL_OTHER) && !Option_ForThisTool(*opts)) { - show = 1; - } else if ((parseopts.helpFlags & HELPFLAGS_TOOL_OTHER) && Option_ForTool(*opts, ~Option_ThisTool() & OTF_TOOL_MASK)) { - show = 1; - } - - if (show) - Help_Option(lst, *opts, subprint, keyword); - - ++opts; - } - - if (subprint && (parseopts.helpFlags & HELPFLAGS_SPACES)) - Help_NewLine(); - Help_Flush(); - if (!subprint) - HPrintF(helptext, "\n"); -} - -void Help_Usage() { - Side_Print( - &all, - "\tGuide to help:\b" - "\tWhen an option is specified as '~~xxx | yy[y] | zzz', then either '~~xxx', '~~yy', '~~yyy', or '~~zzz' matches the option.\b" - "\tAn option given as '~~[no]xxx' may be given as '~~xxx' or '~~noxxx'; '~~noxxx' reverses the meaning of the option.\b" - ); - Help_OutputSingle(&all); - - Side_Print( - &all, - "\tFor most options, the option and the parameters are separated by a %sspace. When the option's name is '~~xxx+', however, the parameter must directly follow the option, without the '+' (as in '~~xxx45').\b", - (compat != 1) ? "" : "colon or " - ); - Side_Print( - &all, - "\tA parameter included in brackets '[]' is optional. An ellipsis '...' indicates that the previous type of parameter may be repeated as a list.\b" - ); - Help_OutputSingle(&all); - - Side_Print( - &all, - "\t%s-- \"compatability\" indicates that the option is borrowed from another vendor's tool and may only approximate its counterpart.\r" - "-- \"global\" indicates that the option has an effect over the entire command line and is parsed before any other options. When several global options are specified, they are interpreted in order.\r" - "-- \"deprecated\" indicates that the option will be eliminated in the future and should not be used any longer. An alternative form is supplied.\r", - (compat != 1) ? "-- \"cased\" indicates that the option is case-sensitive. By default, no options are case-sensitive.\r" : ""); - Help_OutputSingle(&all); - - Side_Print( - &all, - "-- \"ignored\" means the option will be accepted but has no effect on the tool.\r" - "-- \"meaningless\" means the option is accepted but probably has no meaning for the target OS.\r" - "-- \"obsolete\" means the option was once deprecated and is now gone.\r" - "-- \"substituted\" means the option has the same effect as another. This points out a preferred form and prevents confusion when similar options appear in the help.\r" - "-- \"default\" in the help text indicates that the given value or variation of an option will be used unless otherwise overridden. \b" - ); - Help_OutputSingle(&all); - - Side_Print( - &all, - "\tThe symbols ',' %s separate options and parameters unconditionally; to include one of these symbols in a parameter or filename, escape it (e.g., as '\\,' in mwcc file.c\\,v).\b\n", - (compat != 1) ? "and '='" : ", ':', and '='" - ); - Help_OutputSingle(&all); - - if (parseopts.passingArgs && pTool->TYPE == CWDROPINCOMPILERTYPE) - Side_Print( - &all, - "\tThis tool calls the linker (unless a compiler option such as ~~c prevents it) and understands linker options -- use '~~help tool=other' to see them. Options marked \"passed to linker\" are used by the compiler and the linker; options marked \"for linker\" are used only by the linker. When using the compiler and linker separately, you must pass the common options to both.\b\n" - ); - Help_OutputSingle(&all); -} - -void Help_Null() { - Side_Print(&all, - "%s [options, filenames...]\n\nExecute '%s %shelp' for more information.", - OS_GetFileNamePtr(parseopts.args->argv[0]), - OS_GetFileNamePtr(parseopts.args->argv[0]), - MAINOPTCHAR - ); - Help_OutputSingle(&all); -} - -void Help_Init() { - short lb; - short le; - short rb; - short re; - - if (!(helptext = NewHandle(0))) { - fprintf(stderr, "\n*** Out of memory\n"); - exit(-23); - } - - lb = parseopts.ioCols / 40; - le = (parseopts.ioCols / 3) + lb; - rb = le + 3 + ((parseopts.ioCols / 60) & ~1); - re = parseopts.ioCols - 1; - Side_Init(&left, lb, le - lb); - Side_Init(&right, rb, re - rb); - Side_Init(&all, 0, re); -} - -void Help_Line(char ch) { - char line[256]; - memset(line, ch, 255); - line[255] = 0; - HPrintF(helptext, "%.*s\n", parseopts.ioCols - 1, line); -} - -void Help_Term() { - ShowTextHandle(0, helptext); - DisposeHandle(helptext); -} diff --git a/Option.c b/Option.c deleted file mode 100644 index c7e8093..0000000 --- a/Option.c +++ /dev/null @@ -1,1136 +0,0 @@ -#include "includes/mwcc_decomp.h" - -#define MAXSTACK 8 - -int oStackPtr; -Opt48 oStack[8]; -char curopt[1024]; -int maxlegalset; -int numlegalset; -int numinternalset; -static OptionList legalset; -static OptionList internalset; -int numoptionlists; -static OptionList *optionlists[32]; - -extern char curparam[1024]; // check me - -enum { - ARGFLAG_1 = 1, - ARGFLAG_2 = 2, - ARGFLAG_4 = 4, - ARGFLAG_8 = 8, - ARGFLAG_10 = 0x10, - ARGFLAG_20 = 0x20, - ARGFLAG_40 = 0x40, - ARGFLAG_80 = 0x80 -}; - -enum { - ARGSPELLFLAG_1 = 1, - ARGSPELLFLAG_2 = 2, - ARGSPELLFLAG_4 = 4, - ARGSPELLFLAG_8 = 8, - ARGSPELLFLAG_10 = 0x10, - ARGSPELLFLAG_20 = 0x20, - ARGSPELLFLAG_40 = 0x40, - ARGSPELLFLAG_80 = 0x80 -}; - -enum { - OPTSPELLFLAG_1 = 1, - OPTSPELLFLAG_2 = 2, - OPTSPELLFLAG_4 = 4, - OPTSPELLFLAG_8 = 8, - OPTSPELLFLAG_10 = 0x10, - OPTSPELLFLAG_20 = 0x20, - OPTSPELLFLAG_40 = 0x40, - OPTSPELLFLAG_80 = 0x80 -}; - -static void Option_PushList(OptionList *lst) { - Args_Push(1, lst, 0); -} - -static void Option_PushOpt(Option *opt, const char *optname) { - char *cpy; - short flags = ARGFLAG_2; - if (opt && (opt->avail & OTF2)) { - if (Utils_CompareOptionString(opt->names, optname, opt->avail & OTF_CASED, OTF2)) { - flags |= ARGFLAG_80; - } - } - cpy = xstrdup(optname); - Args_Push(flags, opt, cpy); -} - -static void Option_PopOpt(char *optname) { - Opt48 *os = Args_Pop(ARGFLAG_2); - if (optname) - strcpy(optname, os->e.o.curopt); - free(os->e.o.curopt); -} - -static void Option_PopList() { - Args_Pop(ARGFLAG_1); -} - -void Args_InitStack() { - oStackPtr = 0; -} -int Args_StackSize() { - return oStackPtr; -} - -void Args_Push(short flags, void *first, void *second) { -#line 104 - OPTION_ASSERT(oStackPtr 0) - { - short prev = - (flags & ARGFLAG_1) ? ARGFLAG_2 : - (flags & ARGFLAG_2) ? ARGFLAG_1 : - (flags & ARGFLAG_4) ? ARGFLAG_2 : -1; - OPTION_ASSERT(oStack[oStackPtr-1].flags & prev); - } - - oStack[oStackPtr].e.v.first = first; - oStack[oStackPtr].e.v.second = second; - oStack[oStackPtr].flags = flags; - oStackPtr++; -} - -Opt48 *Args_Pop(short flags) -{ - OPTION_ASSERT(oStackPtr>0); - --oStackPtr; - OPTION_ASSERT(oStack[oStackPtr].flags & flags); - return &oStack[oStackPtr]; -} - -void Args_SpellStack(char *buffer, short flags) { - char *bptr; - Opt48 *os; - int sp; - int level; - - bptr = buffer; - sp = 0; - level = 0; - os = &oStack[sp]; - - while (sp < oStackPtr) { - if (!flags || !(os->flags & ARGFLAG_20)) { - if (os->flags & ARGFLAG_4) { - Opt48 *po = os - 1; - if (!(os[-1].flags & ARGFLAG_40)) { - if ((level == 1 || level == 2) && !(po->flags & ARGFLAG_80)) - *(bptr++) = (flags & ARGSPELLFLAG_20) ? '\n' : ' '; - os[-1].flags |= ARGFLAG_40; - } else if (level == 2) { - *(bptr++) = ','; - } else if (level == 3) { - *(bptr++) = '='; - } - strcpy(bptr, os->e.param); - bptr += strlen(bptr); - } else if (os->flags & ARGFLAG_2) { - if (level == 1) { - *(bptr++) = MAINOPTCHAR[0]; - } else if (level == 2) { - Opt48 *po = os - 2; - if (!(os[-1].flags & ARGFLAG_40) && !(po->flags & ARGFLAG_80)) - *(bptr++) = (flags & ARGSPELLFLAG_20) ? '\n' : ' '; - } - - if (os[-1].flags & ARGFLAG_40) { - if (level == 2) { - if (flags & ARGSPELLFLAG_20) - *(bptr++) = ','; - else - *(bptr++) = ' '; - } - } else { - if (level == 3) { - *(bptr++) = '='; - } - } - - os[-1].flags |= ARGFLAG_40; - strcpy(bptr, os->e.o.curopt); - bptr += strlen(bptr); - } - - if (flags & ARGSPELLFLAG_20) - os->flags |= ARGFLAG_20; - } - - if (os->flags & ARGFLAG_1) - level++; - - ++sp; - ++os; - } -} - -void Args_AddToToolArgs(anon0_50 *ta) { - char buffer[4096]; - char *nptr; - - Args_SpellStack(buffer, ARGSPELLFLAG_20); - nptr = strchr(buffer, '\n'); - if (nptr) { - *(nptr++) = 0; - Arg_AddToToolArgs(ta, 2, buffer); - Arg_AddToToolArgs(ta, 1, 0); - } else { - nptr = buffer; - } - Arg_AddToToolArgs(ta, 2, nptr); -} - -void Options_Init() { - numoptionlists = 0; - maxlegalset = 0; - numlegalset = 0; - numinternalset = 0; - - if (legalset.list) - free(legalset.list); - if (internalset.list) - free(internalset.list); - - legalset.list = 0; - legalset.flags = - ((Option_ThisTool() & OTF_TOOL_COMPILER) ? LISTFLAGS_COMPILER : 0) | - ((Option_ThisTool() & OTF_TOOL_LINKER) ? LISTFLAGS_LINKER : 0) | - ((Option_ThisTool() & OTF_TOOL_DISASSEMBLER) ? LISTFLAGS_DISASSEMBLER : 0); - internalset.list = 0; - internalset.flags = - ((Option_ThisTool() & OTF_TOOL_COMPILER) ? LISTFLAGS_COMPILER : 0) | - ((Option_ThisTool() & OTF_TOOL_LINKER) ? LISTFLAGS_LINKER : 0) | - ((Option_ThisTool() & OTF_TOOL_DISASSEMBLER) ? LISTFLAGS_DISASSEMBLER : 0); - - Args_InitStack(); -} - -OptionList *Options_GetOptions() { - return &legalset; -} - -void Options_SortOptions() { - int r; - - if (numinternalset > 0) { - legalset.list = (Option **) xrealloc("options", legalset.list, sizeof(Option *) * (numinternalset + 1)); - for (r = 0; r < numinternalset; r++) { - if (internalset.list[r]->avail & (OTF2 | OTF_CASED)) - legalset.list[numlegalset++] = internalset.list[r]; - } - for (r = 0; r < numinternalset; r++) { - if (!(internalset.list[r]->avail & (OTF2 | OTF_CASED))) - legalset.list[numlegalset++] = internalset.list[r]; - } - legalset.list[numlegalset] = 0; - - if (internalset.list) - free(internalset.list); - internalset.list = 0; - numinternalset = 0; - } -} - -static void Options_AddOption(Option *opt) { - if (numinternalset >= maxlegalset) { - maxlegalset += 32; - internalset.list = (Option **) xrealloc("options", internalset.list, sizeof(Option *) * (maxlegalset + 1)); - } - - internalset.list[numinternalset++] = opt; - internalset.list[numinternalset] = 0; -} - -int Options_AddList(OptionList *optlst) { - Option **ptr; - - if (numoptionlists >= 32) - CLPFatalError("Too many option lists defined!"); - - optionlists[numoptionlists++] = optlst; - for (ptr = optlst->list; *ptr; ptr++) - Options_AddOption(*ptr); - - return 1; -} - -int Options_AddLists(OptionList **optlst) { - int ret = 1; - OptionList **ptr; - - for (ptr = optlst; *ptr; ptr++) { - ret = Options_AddList(*ptr); - if (!ret) - return ret; - } - - return ret; -} - -static void Options_Reset(OptionList *optlst) { - Option **os; - - os = optlst->list; - if (os) { - for (; *os; os++) { - (*os)->avail &= ~(OTF80000000 | OTF40000000); - } - } -} - -static void Option_SpellList(char *buffer, OptionList *conflicts, int flags) { - Option **scan; - Boolean first; - int total; - char tmp[256]; - Option **next; - int slflags; - - scan = conflicts->list; - first = 1; - total = 0; - while (*scan) { - next = scan + 1; - if (!((*scan)->avail & (((parseopts.helpFlags & HELPFLAGS_SECRET) ? 0 : OTF_SECRET) | ((parseopts.helpFlags & HELPFLAGS_DEPRECATED) ? 0 : OTF_DEPRECATED) | OTF_SUBSTITUTED)) && (*scan)->names[0]) { - if (!first) - buffer += sprintf(buffer, ", "); - if (first) - first = 0; - - if (total > 1) { - while (*next && (((*next)->avail & (((parseopts.helpFlags & HELPFLAGS_SECRET) ? 0 : OTF_SECRET) | ((parseopts.helpFlags & HELPFLAGS_DEPRECATED) ? 0 : OTF_DEPRECATED) | OTF_SUBSTITUTED)) || !(*next)->names[0])) { - ++next; - } - - if (!*next) - buffer += sprintf(buffer, "or "); - } - - slflags = (flags & OPTSPELLFLAG_2) ? SLFLAGS_2 : SLFLAGS_1; - switch ((*scan)->avail & OTF_SLFLAGS_MASK) { - case OTF_SLFLAGS_8: - slflags |= SLFLAGS_8; - break; - case OTF_SLFLAGS_20: - slflags |= SLFLAGS_20; - break; - case OTF_SLFLAGS_10: - slflags |= SLFLAGS_10; - break; - } - - Utils_SpellList((*scan)->names, tmp, slflags); - total++; - buffer += sprintf(buffer, "%s", tmp); - - if ((*scan)->avail & OTF8000) - buffer += sprintf(buffer, " ..."); - } - scan++; - } -} - -int Option_ForTool(Option *opt, int which) { - return !which || (opt->avail & which); -} - -int Option_ThisTool() { - return (pTool->TYPE == CWDROPINCOMPILERTYPE) ? OTF_TOOL_COMPILER : OTF_TOOL_LINKER; -} - -int Option_ForThisTool(Option *opt) { - return !Option_ForTool(opt, OTF_TOOL_MASK) || Option_ForTool(opt, Option_ThisTool()); -} - -int Option_AlsoPassedToTool(Option *opt, int which) { - return Option_ForThisTool(opt) && Option_ForTool(opt, which); -} - -int Option_AlsoPassedFromThisTool(Option *opt) { - return Option_ForThisTool(opt) && Option_ForTool(opt, ~Option_ThisTool() & OTF_TOOL_MASK); -} - -static Boolean Option_ContinuesThisLevel(int level, ArgToken *tok) { - ArgToken *tmp; - int ret; // not in stabs but i think this exists - - if (level == 1) { - return (tok->val == ATK_1) || (tok->val == ATK_3) || (tok->val == ATK_2); - } else if (level == 2) { - tmp = Arg_UsedToken(); - ret = (tok->val == ATK_5 && tmp->val != ATK_3) || (tok->val == ATK_2 && tmp->val != ATK_1); - Arg_UndoToken(); - return ret; - } else if (level == 3) { - return (tok->val == ATK_4) || (tok->val == ATK_2); - } else { - return 0; - } -} - -static short endingStack[5][3]; -static Boolean Option_IsEndingThisLevel(int level, ArgToken *tok) { - ArgToken *tmp; - - if (!tok) - return 1; - if (tok->val == endingStack[level][0]) - return 1; - - if (endingStack[level][1] && tok->val == endingStack[level][1]) { - tmp = Arg_UsedToken(); - if (tmp && tmp->val == endingStack[level][2]) { - Arg_UndoToken(); - return 1; - } - Arg_UndoToken(); - } - - return 0; -} - -static Boolean Option_IsEndingLevel(int level, ArgToken *tok) { - if (!tok) - return 1; - - while (level > 0) { - if (Option_IsEndingThisLevel(level - 1, tok)) - return 1; - level--; - } - - return 0; -} - -int Option_Parse(Option *opt, int oflags) { - int ret; - int pushed; - int samelevel; - int subparse; - int flags; - char errstr[1024]; - Option **cscan; - Option **scan; - int goingtosubparse; - ArgToken *tok; - - ret = 1; - pushed = 0; - samelevel = (opt->avail & OTF_GLOBAL) == (oflags & OFLAGS_1); - subparse = (oflags & OFLAGS_2) != 0; - flags = 0; - if (subparse) flags |= PFLAGS_4; - if (oflags & OFLAGS_8) flags |= PFLAGS_8; - if (oflags & OFLAGS_40) flags |= PFLAGS_1; - - if (curopt[0]) { - pushed = 1; - Option_PushOpt(opt, curopt); - } - - if (samelevel) { - if (!(flags & PFLAGS_1)) { - if ((opt->avail & OTF80000000) && (opt->avail & OTF20000)) { - Option_Warning(30); - } else if (opt->avail & OTF40000) { - cscan = opt->conflicts->list; - while (*cscan && (*cscan == opt || !((*cscan)->avail & OTF80000000))) { - ++cscan; - } - - if (*cscan && *cscan != opt) { - (*cscan)->avail &= ~OTF80000000; - Option_SpellList(errstr, opt->conflicts, oflags); - if (opt->conflicts->help) - Option_Warning(32, (*cscan)->names, errstr, opt->conflicts->help); - else - Option_Warning(31, (*cscan)->names, errstr); - } - } - } - - if (Option_ThisTool() == OTF_TOOL_COMPILER && Option_ForTool(opt, OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER)) { - flags |= PFLAGS_2; - if (!Option_ForThisTool(opt)) - flags |= PFLAGS_1; - if (!subparse) - Arg_AddToToolArgs(&linkargs, ATK_1, 0); - Args_AddToToolArgs(&linkargs); - } - - if (!(flags & PFLAGS_1)) { - if (opt->avail & OTF_OBSOLETE) { - if (opt->help) - Option_Error(22, opt->help); - else - Option_Error(21); - flags |= PFLAGS_1; - } - - if (opt->avail & OTF_IGNORED) { - if (!(opt->avail & (OTF_WARNING | OTF_MEANINGLESS))) { - if (opt->help) - Option_Warning(27, opt->help); - else - Option_Warning(26); - } - flags |= PFLAGS_1; - } else if (opt->avail & OTF_SUBSTITUTED) { - Option_Warning(23, curopt, opt->help); - } else if (opt->avail & OTF_DEPRECATED) { - if (opt->help) - Option_Warning(25, opt->help); - else - Option_Warning(24); - } - - if (opt->avail & OTF_WARNING) - Option_Warning(28, opt->help); - if (opt->avail & OTF_MEANINGLESS) - Option_Warning(29); - } - - opt->avail |= OTF80000000; - if (opt->avail & OTF40000) { - scan = opt->conflicts->list; - opt->avail |= OTF40000000; - while (*scan) { - (*scan)->avail |= OTF40000000; - scan++; - } - } - } else { - flags |= PFLAGS_1; - } - - goingtosubparse = opt->avail & OTF8000; - if (opt->param) { - ret = Params_Parse(opt->param, flags | (goingtosubparse ? PFLAGS_20 : 0)); - } else { - tok = Arg_PeekToken(); - if (tok && tok->val == ATK_4) - Arg_UsedToken(); - } - - if (ret && goingtosubparse) { - ret = ret && Options_Parse( - opt->sub, - (oflags & ~OFLAGS_4) - | OFLAGS_2 - | ((flags & PFLAGS_1) ? OFLAGS_40 : 0) - | (subparse ? OFLAGS_10 : 0) - | ((opt->avail & OTF10000) ? OFLAGS_4 : 0) - ); - } - - if (pushed) - Option_PopOpt(curopt); - - if (Option_ThisTool() == OTF_TOOL_COMPILER && !subparse) - Arg_AddToToolArgs(&linkargs, ATK_1, 0); - - return ret; -} - -static int Option_MatchString(char *list, char *str, int flags, int *result) { - int str_len; - char cpy[64]; - - if (result) - *result = 0; - - if (!list[0] && !str[0]) - return 1; - - while (*list) { - if (Utils_CompareOptionString(list, str, flags & OTF_CASED, 0)) - return 1; - - switch (flags & OTF_SLFLAGS_MASK) { - case OTF_SLFLAGS_8: - if (my_tolower(str[0]) == 'n' && my_tolower(str[1]) == 'o' && Utils_CompareOptionString(list, str + 2, flags & OTF_CASED, 0)) { - if (result) - *result |= 0x100000; - return 1; - } - break; - case OTF_SLFLAGS_20: - if (my_tolower(str[0]) == 'n' && my_tolower(str[1]) == 'o' && str[2] == '-' && Utils_CompareOptionString(list, str + 3, flags & OTF_CASED, 0)) { - if (result) - *result |= 0x400000; - return 1; - } - break; - case OTF_SLFLAGS_10: - str_len = strlen(str); - if (str[str_len - 1] == '-') { - strcpy(cpy, str); - cpy[str_len - 1] = 0; - if (Utils_CompareOptionString(list, cpy, flags & OTF_CASED, 0)) { - if (result) - *result |= 0x200000; - return 1; - } - } - break; - } - - while (*list && *list != '|') - ++list; - - if (*list) - ++list; - if (*list == '|') - ++list; - } - - return 0; -} - -static Option *Option_Lookup(OptionList *search, int unk, int *flags) { - Option **os; - Option *stickyopt; - int stickyflags; - Boolean matched; - char *names; - - os = search->list; - stickyopt = 0; - stickyflags = *flags; - - if (os) { - while (*os) { - names = (*os)->names; - if (((*os)->avail & OTF2) == OTF2) { - while (*names && *names != '|') - ++names; - if (*names) - ++names; - if (*names == '|') - ++names; - } - - matched = Option_MatchString(names, curopt, (*os)->avail & (OTF_SLFLAGS_MASK | OTF_CASED), flags) && (*names || names == (*os)->names); - if (matched) { - if (!stickyopt || (*os)->names[0] == curopt[0] || strlen(curopt) > 1) - return *os; - } - - if ((*os)->avail & OTF2) { - matched = Utils_CompareOptionString((*os)->names, curopt, (*os)->avail & OTF_CASED, 2); - if (matched) - stickyflags |= OTF2; - } else { - matched = 0; - } - - if (matched) - stickyopt = *os; - - ++os; - } - } - - *flags = stickyflags; - return stickyopt; -} - -static int Options_DoParse(OptionList *search, int flags) { - // search: r26 *n - // flags: r28 *n - int haderrors; // r30 *n - int parsedany; // r23 *n - int failed; // r24 *n - int matchflags; // stack 0x38 - int subparse; // r20 *n - ArgToken *starttok; // r0 (actually r19 i think?) - int mystery_r31; // figure out what var this actually is - ArgToken *tok; // r25 *n - ArgToken *opttok; // r27 *n - ArgToken *token_r18; // r18 MAYBE???? - Option *opt; // r16 *n - Boolean isOpt; // r0 - char *lptr; // r17 *n - char *optname; // r16 *n - - // 915 - haderrors = 0; - // 917 - failed = 0; - // 918 - matchflags = 0; - // 920 - subparse = (flags & OFLAGS_2) != 0; - // 921 - mystery_r31 = subparse && (flags & OFLAGS_10); - // 925 - opttok = 0; - // 929 - mystery_r31 = (subparse == 0) ? 1 : (mystery_r31 == 0) ? 2 : 3; - - starttok = Arg_PeekToken(); // i think this is starttok - while ((token_r18 = Arg_PeekToken())) { - parsedany = 0; - isOpt = ((mystery_r31 == 1) && (token_r18->val == ATK_3)) || ((mystery_r31 == 2) && (token_r18->val == ATK_2) && (token_r18->text[0] || search->flags & LISTFLAGS_4)) || ((mystery_r31 == 3) && (token_r18->val == ATK_4)); - // 950 17CFD4 - if ((mystery_r31 == 3) && isOpt) { - token_r18 = Arg_UsedToken(); - isOpt = token_r18 && (token_r18->val == ATK_2); - flags &= ~OFLAGS_4; - } - // 957 17D00C - if (isOpt) { - // 959 - opt = 0; - // 960 - Arg_GetTokenText(token_r18, curopt, sizeof(curopt), 0); - // 963 - if (curopt[0]) { - opt = Option_Lookup(search, 0x700000, &matchflags); - if (opt) { - opttok = token_r18; - if (!(matchflags & 2)) { - // 972 - if (token_r18->val == ATK_3) - Arg_UsedToken(); - token_r18 = Arg_UsedToken(); - } else { - lptr = opt->names; - optname = token_r18->text; - while (*lptr && *lptr != '|') - ++lptr; - token_r18 = Arg_UsedToken(); - - if (!subparse) - strcpy(token_r18->text, optname + (lptr - opt->names)); - - curopt[(lptr - opt->names)] = 0; - - if (!token_r18->text || !token_r18->text[0]) { - Option_PushOpt(0, curopt); - Option_ParamError(34, curopt); - Option_PopOpt(0); - return 0; - } - } - } - } - - // 1006 - if (!opt) { - // 1009 - if (search->flags & LISTFLAGS_4) { - char saveopt[1024]; // stack 0xBC - strcpy(saveopt, curopt); - curopt[0] = 0; - opt = Option_Lookup(search, 0, &matchflags); - strcpy(curopt, token_r18->text); - - // 1019 - if (opt) { - if (opt->names[0]) - token_r18 = Arg_UsedToken(); - if (token_r18->val == ATK_4) - Arg_UsedToken(); - haderrors = Option_Parse(opt, flags) == 0; - parsedany = 1; - if (haderrors) - failed = 1; - opt = 0; - } else { - CLPFatalError("Missing default for variable list"); - return 0; - } - // 1041 - strcpy(curopt, saveopt); - } else if (!opt) { - // 1059 - curopt[0] = 0; - // 1061 - if (mystery_r31 > 1) { - if ((flags & OFLAGS_4) && token_r18 == starttok) - return haderrors == 0; - // 1072 - if (search->flags & LISTFLAGS_2) { - if (!(flags & OFLAGS_1)) { - Option_SpellList(curparam, search, flags); - Option_Warning(20, token_r18->text, curparam); - } - Arg_UsedToken(); - parsedany = 1; - } else { - // 1090 - Option_SpellList(curparam, search, flags); - Option_Error(20, token_r18->text, curparam); - failed = 1; - haderrors++; - } - } else { - // 1099 - if ((search->flags & LISTFLAGS_2) || parseopts.ignoreUnknown) { - // 1101 - if (!(flags & OFLAGS_1)) - Option_Warning(19, token_r18->text); - Arg_UsedToken(); - Arg_GetToken(); - parsedany = 1; - } else { - // 1115 - Option_Error(19, token_r18->text); - failed = 1; - haderrors++; - } - } - } - } - - // 1126 - after_if_1006 - if (!haderrors && !failed && opt) { - flags &= ~OFLAGS_8; - if (matchflags & 0x700000) - flags |= OFLAGS_8; - haderrors = Option_Parse(opt, flags) == 0; - if (haderrors) - failed = 1; - parsedany++; - } // else: goto 1229 - } else if ((mystery_r31 == 1) && (token_r18->val == ATK_2)) { - // 1142 - opttok = 0; - curopt[0] = 0; - opt = Option_Lookup(search, 0, &matchflags); - strcpy(curopt, token_r18->text); - if (!opt) { - Option_Warning(33, curopt); - failed = 1; - } else { - if (!(flags & OFLAGS_1)) { - haderrors = Option_Parse(opt, flags) == 0; - } else { - parseopts.possibleFiles++; - haderrors = 0; - } - parsedany = 1; - if (haderrors) - failed = 1; - else - Arg_UsedToken(); - } - } else if ((mystery_r31 > 1) && Option_IsEndingLevel(mystery_r31, token_r18)) { - // 1193 - Option *opt; - char saveopt[64]; // stack 0x7C - strcpy(saveopt, curopt); - if (!(search->flags & LISTFLAGS_4)) { - curopt[0] = 0; - opt = Option_Lookup(search, 0, &matchflags); // probably wrong result reg - } else { - opt = 0; // probably wrong reg - } - // 1203 - if (!opt) { - // 1205 - if (!(flags & OFLAGS_4)) { - Option_Error(34, saveopt); - failed = 1; - haderrors++; - } else { - strcpy(curopt, saveopt); - break; - } - } else { - // 1219 - haderrors = Option_Parse(opt, flags) == 0; - parsedany = 1; - if (haderrors) - failed = 1; - } - // 1224 - strcpy(curopt, saveopt); - } - - // 1229 after_if_1126 - // This is where tok comes into play. - tok = Arg_PeekToken(); - // 1231 - if (!failed) { - if (tok && (tok->val == ATK_2) && (matchflags & 2)) { - // 1235 - ArgToken *prev; // r16 - char sticky[64]; // stack 0x3C - prev = Arg_UndoToken(); - tok = Arg_UsedToken(); - if (tok->text[0] && prev == opttok) { - if (opttok) { - strcpy(sticky, opttok->text); - sticky[strlen(tok->text)] = 0; - Option_PushOpt(0, sticky); - Param_Error(36, Arg_GetTokenName(tok)); - Option_PopOpt(0); - } else { - CLPReportError(36, Arg_GetTokenName(tok)); - } - // 1251 - haderrors++; - // goes to 1323 - } else { - // 1256 - if (!tok->text[0]) - tok = Arg_UsedToken(); - // 1257 - if (flags & OFLAGS_1) - parseopts.possibleFiles++; - // goes to 1323 - } - } else { - // 1267 - if (Option_IsEndingThisLevel(mystery_r31 - 1, tok)) - break; - if (Option_IsEndingThisLevel(mystery_r31 + 1, tok)) { - // 1276 - ArgToken *prev = tok; // r16 - tok = Arg_UsedToken(); - // 1278 - if ((mystery_r31 != 1) || (tok->val != ATK_3)) { - // 1280 - if (opttok) { - Option_PushOpt(0, opttok->text); - if (tok->val == ATK_2) - Param_Error(36, Arg_GetTokenName(tok)); - else - Param_Error(35, Arg_GetTokenName(prev)); - Option_PopOpt(opttok->text); - } else if (tok->val == ATK_2) { - // 1292 - CLPReportError(36, Arg_GetTokenName(tok)); - } else { - // 1294 - CLPReportError(35, Arg_GetTokenName(prev)); - } - haderrors++; - failed++; - } - // goto 1323 - } else if ((mystery_r31 < 2) && Option_IsEndingThisLevel(mystery_r31 + 2, tok)) { - // 1303 - if (opttok) { - Option_PushOpt(0, opttok->text); - if (tok->val == ATK_2) - Param_Error(36, Arg_GetTokenName(tok)); - else - Param_Error(35, Arg_GetTokenName(tok)); - Option_PopOpt(opttok->text); - } else if (tok->val == ATK_2) { - CLPReportError(36, Arg_GetTokenName(tok)); - } else { - CLPReportError(35, Arg_GetTokenName(tok)); - } - haderrors++; - failed++; - } - } - } // else: 1323 - - if (haderrors || failed) { - while (!Option_IsEndingLevel(mystery_r31, tok)) - tok = Arg_GetToken(); - if (!tok) - tok = Arg_UndoToken(); -#line 1335 - OPTION_ASSERT(tok); - } - - if (!parsedany || haderrors) - break; - - if (Option_IsEndingThisLevel(mystery_r31, tok)) - Arg_UsedToken(); - else if (!Option_ContinuesThisLevel(mystery_r31, tok)) - break; - } - - return haderrors == 0; -} - -int Options_Parse(OptionList *options, int flags) { - // options: r30 - // flags: r31 - int ret; // r31 - char savecuropt[64]; // stack 0x3C - - Options_Reset(options); - Option_PushList(options); - - if (!(flags & 2)) { - ret = Options_DoParse(options, flags); - if (Option_ThisTool() == OTF_TOOL_COMPILER) - Arg_AddToToolArgs(&linkargs, 1, 0); - } else { - strcpy(savecuropt, curopt); - ret = Options_DoParse(options, flags); - strcpy(curopt, savecuropt); - } - - Option_PopList(); - return ret; -} - -int Option_ParseDefaultOption(OptionList *options) { - // options: r31 - int ret; // r31 - Option *dopt; // r0 - int matchflags; // 0x3C - - Options_Reset(options); - Option_PushList(options); - - strcpy(curopt, "defaultoptions"); - dopt = Option_Lookup(options, 0, &matchflags); - if (!dopt) { - CLPFatalError("Default options not defined"); - ret = 1; - } else { - ret = Option_Parse(dopt, 0); - } - - Option_PopList(); - return ret; -} - -void Option_ParamError(short id, va_list ap) { - char buf[4096]; - - CLPGetErrorString(id, buf); - sprintf(&buf[strlen(buf)], "\nwhile parsing option '"); - Args_SpellStack(&buf[strlen(buf)], 0); - sprintf(&buf[strlen(buf)], "'"); - CLPReportError_V(buf, ap); -} - -void Option_ParamWarning(short id, va_list ap) { - char buf[1024]; - - CLPGetErrorString(id, buf); - sprintf(&buf[strlen(buf)], "\nwhile parsing option '"); - Args_SpellStack(&buf[strlen(buf)], 0); - sprintf(&buf[strlen(buf)], "'"); - CLPReportWarning_V(buf, ap); -} - -void Option_OptionError(short id, va_list ap) { - char buf[1024]; - - CLPGetErrorString(id, buf); - if (Args_StackSize() >= 2) { - sprintf(&buf[strlen(buf)], "\nwhile parsing option '"); - Args_SpellStack(&buf[strlen(buf)], 0); - sprintf(&buf[strlen(buf)], "'"); - } - CLPReportError_V(buf, ap); -} - -void Option_OptionWarning(short id, va_list ap) { - char buf[1024]; - - CLPGetErrorString(id, buf); - if (Args_StackSize() >= 2) { - sprintf(&buf[strlen(buf)], "\nwhile parsing option '"); - Args_SpellStack(&buf[strlen(buf)], 0); - sprintf(&buf[strlen(buf)], "'"); - } - CLPReportWarning_V(buf, ap); -} - -void Option_Error(short id, ...) { - va_list va; - va_start(va, id); - Option_OptionError(id, va); - va_end(va); -} - -void Option_Warning(short id, ...) { - va_list va; - va_start(va, id); - Option_OptionWarning(id, va); - va_end(va); -} - -int Options_Help(const char *keyword) { - // keyword: r31 - int scan; // r26 - OptionList *lst; // r25 - - Help_Init(); - - if (parseopts.helpFlags & HELPFLAGS_USAGE) { - ShowVersion(1); - Help_Line('='); - Help_Usage(); - } else { - ShowVersion(1); - for (scan = 0; scan < numoptionlists; scan++) { - if ((lst = optionlists[scan])) { - if (parseopts.helpFlags & HELPFLAGS_8000) { - if (keyword && keyword[0] && lst->help && strstr(lst->help, keyword)) - Help_Options(lst, 0, ""); - } else { - Help_Options(lst, 0, keyword); - } - } - } - } - - Help_Term(); - return 1; -} - -int Option_Help(const char *opt) { - // opt: r31 - Option *find; // r29 - int matchflags; // stack 0x3C - int ret; // r29 - - find = 0; - Option_PushList(Options_GetOptions()); - Option_PushOpt(0, "help"); - if (opt[0] == MAINOPTCHAR[0]) - strcpy(curopt, opt + 1); - else - strcpy(curopt, opt); - - if (!curopt[1]) - find = Option_Lookup(Options_GetOptions(), 0x700002, &matchflags); - if (!find) - find = Option_Lookup(Options_GetOptions(), 0x700000, &matchflags); - - if (find) { - Help_Init(); - if (!Help_Option(Options_GetOptions(), find, 0, "")) - CLPReportWarning(38, opt); - Help_Term(); - ret = 1; - } else { - Option_Error(19, opt); - ret = 0; - } - - Option_PopOpt(curopt); - Option_PopList(); - return ret; -} - -int Options_DisplayHelp() { - if (parseopts.helpFlags & HELPFLAGS_1) - Option_Help(parseopts.helpKey); - else - Options_Help(parseopts.helpKey); -} diff --git a/Parameter.c b/Parameter.c deleted file mode 100644 index 95bde45..0000000 --- a/Parameter.c +++ /dev/null @@ -1,1146 +0,0 @@ -#include "includes/mwcc_decomp.h" - -char curparam[4096]; -char *descparam = &curparam[0]; -char *helpparam = &curparam[1024]; -char *defaultparam = &curparam[2048]; - -#define copy_8(dst, src) \ -do { \ -((unsigned char *) (dst))[0] = ((unsigned char *) (src))[0]; \ -} while (0) - -#define copy_16(dst, src) \ -do { \ -((unsigned char *) (dst))[0] = ((unsigned char *) (src))[0]; \ -((unsigned char *) (dst))[1] = ((unsigned char *) (src))[1]; \ -} while (0) - -#define copy_32(dst, src) \ -do { \ -((unsigned char *) (dst))[0] = ((unsigned char *) (src))[0]; \ -((unsigned char *) (dst))[1] = ((unsigned char *) (src))[1]; \ -((unsigned char *) (dst))[2] = ((unsigned char *) (src))[2]; \ -((unsigned char *) (dst))[3] = ((unsigned char *) (src))[3]; \ -} while (0) - -#define inline_write_32(dst, val) do { \ -union {unsigned char bytes[4]; unsigned long lg;} _val, _arg; \ -copy_32(_arg.bytes, val); \ -_val.lg = _arg.lg; \ -copy_32(dst, _val.bytes); \ -} while (0) - -#define inline_write_16(dst, val) do { \ -union {unsigned char bytes[2]; unsigned short sh;} _val, _arg; \ -copy_16(_arg.bytes, val); \ -_val.sh = _arg.sh; \ -copy_16(dst, _val.bytes); \ -} while (0) - -#define inline_write_8(ptr, val) copy_8(ptr, val) - -#define inline_andor_32(dst, and, or) do { \ -union {unsigned char bytes[4]; unsigned long lg;} _val, _arg, _arg2; \ -copy_32(_val.bytes, dst); \ -copy_32(_arg.bytes, and); \ -copy_32(_arg2.bytes, or); \ -_val.lg = (_val.lg & ~_arg.lg) | _arg2.lg; \ -copy_32(dst, _val.bytes); \ -} while(0) - -#define inline_andor_16(dst, and, or) do { \ -union {unsigned char bytes[2]; unsigned short sh;} _val, _arg, _arg2; \ -copy_16(_val.bytes, dst); \ -copy_16(_arg.bytes, and); \ -copy_16(_arg2.bytes, or); \ -_val.sh = (_val.sh & ~_arg.sh) | _arg2.sh; \ -copy_16(dst, _val.bytes); \ -} while(0) - -#define inline_andor_8(dst, and, or) do { \ -((unsigned char *) (dst))[0] = (((unsigned char *) (dst))[0] & ~((unsigned char *) (and))[0]) | ((unsigned char *) (or))[0]; \ -} while(0) - -#define inline_xor_32(dst, arg) do { \ -union {unsigned char bytes[4]; unsigned long lg;} _val, _arg; \ -copy_32(_val.bytes, dst); \ -copy_32(_arg.bytes, arg); \ -_val.lg = _val.lg ^ _arg.lg; \ -copy_32(dst, _val.bytes); \ -} while(0) - -#define inline_xor_16(dst, arg) do { \ -union {unsigned char bytes[2]; unsigned short sh;} _val, _arg; \ -copy_16(_val.bytes, dst); \ -copy_16(_arg.bytes, arg); \ -_val.sh = _val.sh ^ _arg.sh; \ -copy_16(dst, _val.bytes); \ -} while(0) - -#define inline_xor_8(dst, arg) do { \ -((unsigned char *) (dst))[0] = (((unsigned char *) (dst))[0] ^ ((unsigned char *) (arg))[0]); \ -} while(0) - -// forward declaration -static int Param_GetArgument(PARAM_T *param, const char **cparam, int exec); -static int Param_Parse(PARAM_T *param, const char *cparam, int flags); - -static int Param_None(PARAM_T *p, const char *pstr, int flags) { - return 1; -} - -static void DescHelpParam_None(PARAM_T *p, const char **desc, const char **help, const char **defaul) { - *desc = 0; - *help = 0; - *defaul = 0; -} - -static int CompareParam_None(PARAM_T *p) { - return 0; -} - -static void DescHelpParam_Number(NUM_T *p, const char **desc, const char **help, const char **defaul) { - unsigned long value; - unsigned char value8; - unsigned short value16; - - value = 0; - *desc = 0; - if (p->myname) - *desc = p->myname; - - if (p->size == 1) { - if (!*desc) - *desc = "byte"; - if (p->num) copy_8(&value8, p->num); - value = value8; - } else if (p->size == 2) { - if (!*desc) - *desc = "short"; - if (p->num) copy_16(&value16, p->num); - value = value16; - } else if (p->size == 4) { - if (!*desc) - *desc = "long"; - if (p->num) copy_32(&value, p->num); - } - - if (p->size == 4) { - if (p->lo != p->hi) - sprintf(helpparam, "range 0x%x - 0x%x", p->lo, p->hi); - *help = helpparam; - if (value <= 0x10000) - sprintf(defaultparam, "%u", value); - else - sprintf(defaultparam, "0x%x", value); - *defaul = defaultparam; - } else { - if (p->lo != p->hi) - sprintf(helpparam, "range %u - %u", p->lo, p->hi); - *help = helpparam; - sprintf(defaultparam, "%u", value); - *defaul = defaultparam; - } - - if (!p->num) - *defaul = 0; - if (p->lo == p->hi) - *help = 0; -} - -static int CompareParam_Number(NUM_T *p) { - return 0; -} - -static int Param_Number(NUM_T *p, const char *pstr, int flags) { - unsigned long val; - unsigned long lo; - unsigned long hi; - const char *opstr; - - val = 0; - opstr = pstr; - if (!pstr[0]) { - Param_Error(5, "", pstr); - return 0; - } - - if (((*pstr == '0') && my_tolower(pstr[1]) == 'x') || (*pstr == '$')) { - // 218 - if (pstr[0] == '$') - pstr += 1; - else - pstr += 2; - - while (*pstr) { - if (!my_isxdigit(*pstr)) { - Param_Error(5, "hexadecimal ", opstr); - return 0; - } - - if (val > 0xFFFFFFF) { - Param_Error(4, opstr); - return 0; - } - - val = (val << 4) | (my_isdigit(*pstr) ? (*pstr - '0') : (my_tolower(*pstr) - 'a' + 10)); - ++pstr; - } - } else if (pstr[0] == '0') { - pstr += 1; - - while (*pstr) { - if (*pstr < '0' || *pstr >= '8') { - Param_Error(5, "octal ", opstr); - return 0; - } - - if (val > 0x1FFFFFFF) { - Param_Error(4, opstr); - return 0; - } - - val = (val << 3) | (*pstr - '0'); - ++pstr; - } - } else { - while (*pstr) { - if (!my_isdigit(*pstr)) { - Param_Error(5, "decimal ", opstr); - return 0; - } - - if (val > 0x19999999) { - Param_Error(4, opstr); - return 0; - } - - val = (val * 10) + (*pstr - '0'); - ++pstr; - } - } - - if (p->lo == p->hi) { - if (p->size == 1) { - lo = 0; - hi = 0xFF; - } else if (p->size == 2) { - lo = 0; - hi = 0xFFFF; - } else { - lo = 0; - hi = 0xFFFFFFFF; - } - } else { - lo = p->lo; - hi = p->hi; - } - - if (!p->fit && (val < lo || val > hi)) { - Param_Error(6, val, lo, hi); - return 0; - } - - if (val < lo) { - Param_Warning(7, val, lo, hi, lo); - val = lo; - } else if (val > hi) { - Param_Warning(7, val, lo, hi, hi); - val = hi; - } - - if (p->size == 1) { - unsigned char val8 = val; - inline_write_8(p->num, &val8); - } - - if (p->size == 2) { - unsigned short val16 = val; - inline_write_16(p->num, &val16); - } else if (p->size == 4) { - unsigned long val32 = val; - inline_write_32(p->num, &val32); - } - - return 1; -} - -static void DescHelpParam_FTypeCreator(FTYPE_T *p, const char **desc, const char **help, const char **defaul) { - if (p->myname) - *desc = p->myname; - else if (p->iscreator) - *desc = "creator"; - else - *desc = "type"; - - if (!p->fc) { - *defaul = 0; - } else { - unsigned long tmp; - unsigned char *ptr; - - ptr = (unsigned char *) defaultparam; - tmp = *p->fc; - ptr[0] = '\''; - ptr[1] = tmp & 0xFF; - ptr[2] = (tmp >> 8) & 0xFF; - ptr[3] = (tmp >> 16) & 0xFF; - ptr[4] = (tmp >> 24) & 0xFF; - ptr[5] = '\''; - ptr[6] = 0; - *defaul = defaultparam; - } -} - -static int CompareParam_FTypeCreator(FTYPE_T *p) { - return 0; -} - -static int Param_FTypeCreator(FTYPE_T *p, const char *pstr, int flags) { - char x[4] = " "; - int cnt; - const char *opstr; - - cnt = 0; - opstr = pstr; - while (*pstr && cnt < 4) { - x[cnt++] = *(pstr++); - } - - if (*pstr) { - Param_Error(8, opstr); - return 0; - } - - inline_write_32(p->fc, &x); - return 1; -} - -static void DescHelpParam_String(STRING_T *p, const char **desc, const char **help, const char **defaul) { - if (p->myname) - *desc = p->myname; - else - *desc = "string"; - - if (!p->str) { - *help = 0; - *defaul = 0; - } else { - sprintf(helpparam, "maximum length %d chars", p->maxlen - 1); - *help = helpparam; - - if (*p->str) { - sprintf(defaultparam, "'%s'", p->str); - *defaul = defaultparam; - } else { - *defaul = "none"; - } - } -} - -static int CompareParam_String(STRING_T *p) { - return 0; -} - -static int Param_String(STRING_T *p, const char *pstr, int flags) { - int len; - - len = strlen(pstr); - strncpy(p->str, pstr, p->maxlen - 1); - if (p->pstring) - c2pstr(p->str); - - if (len > p->maxlen) { - Param_Error(9, pstr, pstr + len - 5, p->maxlen - 1); - return 0; - } - - return 1; -} - -static void DescHelpParam_ID_or_SYM(STRING_T *p, const char **desc, const char **help, const char **defaul) { - if (p->myname) - *desc = p->myname; - else if (p->which == PARAMWHICH_Id) - *desc = "identifier"; - else - *desc = "symbol"; - - if (!p->str) { - *help = *defaul = 0; - } else { - sprintf(helpparam, "maximum length %d chars", p->maxlen - 1); - *help = helpparam; - - if (*p->str) { - sprintf(defaultparam, "'%s'", p->str); - *defaul = defaultparam; - } else { - *defaul = "none"; - } - } -} - -static int CompareParam_ID_or_SYM(STRING_T *p) { - return 0; -} - -static int Param_ID_or_SYM(STRING_T *p, const char *pstr, int flags) { - const char *ptr; - const char *x; - - if (Param_String(p, pstr, flags)) { - if (p->which == PARAMWHICH_Id) { - x = "$_"; - } else if (p->which == PARAMWHICH_Sym) { - x = "_.$@?#"; - } - - for (ptr = pstr; *ptr; ++ptr) { - if (ptr == pstr && my_isdigit(*ptr)) - Param_Warning(10, pstr); - - if (!my_isalnum(*ptr) && !strchr(x, *ptr)) - Param_Warning(11, pstr, *ptr); - } - - return 1; - } else { - return 0; - } -} - -static void DescHelpParam_OnOff(ONOFF_T *p, const char **desc, const char **help, const char **defaul) { - unsigned char def; - - if (p->myname) - *desc = p->myname; - else - *desc = "on|off"; - - *help = 0; - if (!p->var) { - *defaul = 0; - } else { - if (p->var) - *((unsigned char *) &def) = *((unsigned char *) p->var); - if (def) - *defaul = "on"; - else - *defaul = "off"; - } -} - -static int CompareParam_OnOff(ONOFF_T *p) { - return 0; -} - -static int Param_OnOff(ONOFF_T *p, const char *pstr, int flags) { - Boolean mytrue = (flags & PARAMPARSEFLAGS_8) == 0; - - if (!ustrcmp(pstr, "on")) { - *(p->var) = mytrue; - } else if (!ustrcmp(pstr, "off")) { - *(p->var) = mytrue == 0; - } else { - Param_Error(12, pstr); - return 0; - } - - return 1; -} - -static void DescHelpParam_OffOn(ONOFF_T *p, const char **desc, const char **help, const char **defaul) { - unsigned char def; - - if (p->myname) - *desc = p->myname; - else - *desc = "off|on"; - - *help = 0; - if (!p->var) { - *defaul = 0; - } else { - if (p->var) - *((unsigned char *) &def) = *((unsigned char *) p->var); - if (!def) - *defaul = "on"; - else - *defaul = "off"; - } -} - -static int CompareParam_OffOn(OFFON_T *p) { - return 0; -} - -static int Param_OffOn(OFFON_T *p, const char *pstr, int flags) { - Boolean mytrue = (flags & PARAMPARSEFLAGS_8) == 0; - - if (!ustrcmp(pstr, "off")) { - *(p->var) = mytrue; - } else if (!ustrcmp(pstr, "on")) { - *(p->var) = mytrue == 0; - } else { - Param_Error(12, pstr); - return 0; - } - - return 1; -} - -static void DescHelpParam_FilePath(FILEPATH_T *p, const char **desc, const char **help, const char **defaul) { - if (p->myname) - *desc = p->myname; - else - *desc = "filepath"; - - *help = 0; - *defaul = p->defaultstr; -} - -static int CompareParam_FilePath(FILEPATH_T *p) { - return 0; -} - -static int Param_FilePath(FILEPATH_T *p, const char *pstr, int flags) { - int err; - OSSpec spec; - char canon[256]; - int clen; - - if (!pstr[0]) { - ((unsigned char *) p->filename)[0] = 0; - return 1; - } - - err = OS_MakeFileSpec(pstr, &spec); - if (err) { - Param_Error(18, pstr, OS_GetErrText(err)); - return 0; - } - - OS_SpecToString(&spec, canon, sizeof(canon)); - if (p->fflags & 1) { - c2pstrcpy(p->filename, canon); - } else { - clen = strlen(canon); - if (clen > p->maxlen) { - Param_Error(13, canon + clen - 32, canon); - return 0; - } - strcpy(p->filename, canon); - } - - return 1; -} - -static void DescHelpParam_Mask(MASK_T *p, const char **desc, const char **help, const char **defaul) { - *help = 0; - *desc = 0; - *defaul = 0; -} - -static int CompareParam_Mask(MASK_T *p) { - if (p->size == 1) { - unsigned char or8 = p->ormask, and8 = p->andmask, val8; - if (p->num) copy_8(&val8, p->num); - return ((val8 & ~and8) | or8) == val8; - } else if (p->size == 2) { - unsigned short or16 = p->ormask, and16 = p->andmask, val16; - if (p->num) copy_16(&val16, p->num); - return ((val16 & ~and16) | or16) == val16; - } else { - unsigned long or32 = p->ormask, and32 = p->andmask, val32; - if (p->num) copy_32(&val32, p->num); - return ((val32 & ~and32) | or32) == val32; - } -} - -static int Param_Mask(MASK_T *p, const char *pstr, int flags) { - if (p->size == 1) { - unsigned char or8 = p->ormask, and8 = p->andmask, tmp8; - if (flags & PARAMPARSEFLAGS_8) { - tmp8 = and8; - and8 = and8 | or8; - or8 = tmp8; - } - inline_andor_8(p->num, &and8, &or8); - } else if (p->size == 2) { - unsigned short or16 = p->ormask, and16 = p->andmask, tmp16; - if (flags & PARAMPARSEFLAGS_8) { - tmp16 = and16; - and16 = and16 | or16; - or16 = tmp16; - } - inline_andor_16(p->num, &and16, &or16); - } else { - unsigned long or32 = p->ormask, and32 = p->andmask, tmp32; - if (flags & PARAMPARSEFLAGS_8) { - tmp32 = and32; - and32 = and32 | or32; - or32 = tmp32; - } - inline_andor_32(p->num, &and32, &or32); - } - return 1; -} - -static void DescHelpParam_Toggle(TOGGLE_T *p, const char **desc, const char **help, const char **defaul) { - *help = 0; - *desc = 0; - *defaul = 0; -} - -static int CompareParam_Toggle(TOGGLE_T *p) { - if (p->size == 1) { - unsigned char mask8, val8; - mask8 = (unsigned char) p->mask; - if (p->num) copy_8(&val8, p->num); - return (val8 ^ mask8) == val8; - } else if (p->size == 2) { - unsigned short mask16, val16; - mask16 = (unsigned short) p->mask; - if (p->num) copy_16(&val16, p->num); - return (val16 ^ mask16) == val16; - } else { - unsigned long mask32, val32; - mask32 = p->mask; - if (p->num) copy_16(&val32, p->num); // BUG ALERT - return (val32 ^ mask32) == val32; - } -} - -static int Param_Toggle(TOGGLE_T *p, const char *pstr, int flags) { - if (p->size == 1) { - unsigned char val8; - val8 = (unsigned char) p->mask; - inline_xor_8(p->num, &val8); - } else if (p->size == 2) { - unsigned short val16; - val16 = (unsigned short) p->mask; - inline_xor_16(p->num, &val16); - } else { - inline_xor_32(p->num, &p->mask); - } - return 1; -} - -static void DescHelpParam_Set(SET_T *p, const char **desc, const char **help, const char **defaul) { - *help = 0; - *desc = 0; - *defaul = 0; -} - -static int CompareParam_Set(SET_T *p) { - if (p->size == 1) { - unsigned char set8, val8; - set8 = (unsigned char) p->value; - if (p->num) copy_8(&val8, p->num); - return set8 == val8; - } else if (p->size == 2) { - unsigned short set16, val16; - set16 = (unsigned short) p->value; - if (p->num) copy_16(&val16, p->num); - return set16 == val16; - } else { - unsigned long set32, val32; - set32 = p->value; - if (p->num) copy_32(&val32, p->num); - return set32 == val32; - } -} - -static int Param_Set(SET_T *p, const char *pstr, int flags) { - if (p->size == 1) { - unsigned char val8; - val8 = (unsigned char) p->value; - if ((flags & PARAMPARSEFLAGS_8) && val8 <= 1) - val8 = (val8 == 0); - inline_write_8(p->num, &val8); - } else if (p->size == 2) { - unsigned short val16; - val16 = (unsigned short) p->value; - if ((flags & PARAMPARSEFLAGS_8) && val16 <= 1) - val16 = (val16 == 0); - inline_write_16(p->num, &val16); - } else { - unsigned long val32; - val32 = p->value; - if ((flags & PARAMPARSEFLAGS_8) && val32 <= 1) - val32 = (val32 == 0); - inline_write_32(p->num, &val32); - } - return 1; -} - -static void DescHelpParam_SetString(SETSTRING_T *p, const char **desc, const char **help, const char **defaul) { - *help = 0; - *desc = 0; - *defaul = 0; -} - -static int CompareParam_SetString(SETSTRING_T *p, int flags) { - if (p->pstring) - return pstrcmp((const unsigned char *) p->var, (const unsigned char *) p->value) == 0; - else - return strcmp(p->var, p->value) == 0; -} - -static int Param_SetString(SETSTRING_T *p, const char *pstr, int flags) { - if (p->pstring) - memcpy(p->var, p->value, p->value[0]); - else - strcpy(p->var, p->value); - return 1; -} - -static void DescHelpParam_Generic(GENERIC_T *p, const char **desc, const char **help, const char **defaul) { - if (p->myname) - *desc = p->myname; - else if ((p->flags & PARAMFLAGS_3) != 1) - *desc = "xxx"; - else - *desc = 0; - *help = p->help; - *defaul = 0; -} - -static int CompareParam_Generic(GENERIC_T *p) { - return 0; -} - -static int Param_Generic(GENERIC_T *p, const char *pstr, int flags) { - return p->parse(curopt, p->var, pstr, flags); -} - -static void DescHelpParam_Setting(SETTING_T *p, const char **desc, const char **help, const char **defaul) { - char *dptr = descparam; - - dptr += sprintf(dptr, "%s", p->myname ? p->myname : "var"); - if ((p->flags & PARAMFLAGS_3) != 1) { - sprintf(dptr, - "%s=%s%s", - (p->flags & PARAMFLAGS_2) ? "[" : "", - p->valuename ? p->valuename : "...", - (p->flags & PARAMFLAGS_2) ? "]" : "" - ); - } - *desc = descparam; - *help = 0; - *defaul = 0; -} - -static int CompareParam_Setting(SETTING_T *p) { - return 0; -} - -static int Param_Setting(SETTING_T *p, const char *pstr, int flags) { - char savevar[256]; - const char *vstr; - ArgToken *tok; - Boolean equals = 0; - - if (!pstr) { - Param_Error(40); - return 0; - } - - strncpy(savevar, pstr, sizeof(savevar)); - tok = Arg_PeekToken(); - if (tok && tok->val == ATK_4) { - Arg_UsedToken(); - equals = 1; - if (!Param_GetArgument((PARAM_T *) p, &vstr, flags)) - return 0; - } else { - vstr = 0; - } - - if (!vstr && equals) - vstr = ""; - - return p->parse(savevar, vstr); -} - -static void DescHelpParam_IfArg(IFARG_T *p, const char **desc, const char **help, const char **defaul) { - const char *d1 = 0; - const char *d2 = 0; - const char *h1 = 0; - const char *h2 = 0; - const char *df1 = 0; - const char *df2 = 0; - char desclocal[1024]; - char *dptr = desclocal; - char helplocal[1024]; - char *hptr = helplocal; - const char *ind; - - desclocal[0] = 0; - helplocal[0] = 0; - - if (p->parg) - Param_DescHelp(p->parg, &d1, &h1, &df1); - if (p->pnone) - Param_DescHelp(p->pnone, &d2, &h2, &df2); - - if (p->helpa && p->helpn) { - if (df1) - hptr += sprintf(hptr, "%s (default is %s), else %s", p->helpa, df1, p->helpn); - else - hptr += sprintf(hptr, "%s, else %s", p->helpa, p->helpn); - } else if (p->helpa) { - hptr += sprintf(hptr, "%s", p->helpa); - if (df1) - hptr += sprintf(hptr, "; default is %s", df1); - } else if (p->helpn) { - hptr += sprintf(hptr, "nothing, else %s", p->helpn); - } - - if (d1) { - if (p->myname) { - dptr += sprintf(dptr, "[%s]", p->myname ? p->myname: "param"); - } else if (h1) { - ind = strchr(d1, '\n'); - if (!ind) - ind = d1 + strlen(d1); - dptr += sprintf(dptr, "[%.*s]", ind - d1, d1); - } else { - dptr += sprintf(dptr, "[%s]", d1); - d1 = 0; - } - } - - if (h1 || h2) { - dptr += sprintf(dptr, "\n\t"); - hptr += sprintf(hptr, "\n\t"); - if (h1) { - if (d1) - dptr += sprintf(dptr, "%s", d1); - if (h1) - hptr += sprintf(hptr, "%s", h1); - if (h2) { - dptr += sprintf(dptr, "\b\t"); - hptr += sprintf(hptr, "\b\t"); - } - } - if (h2) { - if (d2) - dptr += sprintf(dptr, "%s", d2); - else - dptr += sprintf(dptr, "(if blank)"); - if (h2) - hptr += sprintf(hptr, "%s", h2); - dptr += sprintf(dptr, "\n"); - hptr += sprintf(hptr, "\n"); - } - dptr += sprintf(dptr, "\b"); - hptr += sprintf(hptr, "\b"); - } - - if (dptr != desclocal) { - strcpy(descparam, desclocal); - *desc = descparam; - } else { - *desc = 0; - } - - if (hptr != helplocal) { - strcpy(helpparam, helplocal); - *help = helpparam; - } else { - *help = 0; - } - - *defaul = 0; -} - -static int CompareParam_IfArg(IFARG_T *p) { - return 0; -} - -static int Param_IfArg(IFARG_T *p, const char *pstr, int flags) { - if (pstr) - return Param_Parse(p->parg, pstr, flags); - else if (p->pnone) - return Param_Parse(p->pnone, pstr, flags); - else - return 1; -} - -typedef int (*PARSE_FUNC)(PARAM_T *, const char *, int); -PARSE_FUNC ParamParsers[16] = { - (PARSE_FUNC) &Param_None, - (PARSE_FUNC) &Param_FTypeCreator, - (PARSE_FUNC) &Param_FilePath, - (PARSE_FUNC) &Param_Number, - (PARSE_FUNC) &Param_String, - (PARSE_FUNC) &Param_ID_or_SYM, - (PARSE_FUNC) &Param_ID_or_SYM, - (PARSE_FUNC) &Param_OnOff, - (PARSE_FUNC) &Param_OffOn, - (PARSE_FUNC) &Param_Mask, - (PARSE_FUNC) &Param_Toggle, - (PARSE_FUNC) &Param_Set, - (PARSE_FUNC) &Param_SetString, - (PARSE_FUNC) &Param_Generic, - (PARSE_FUNC) &Param_IfArg, - (PARSE_FUNC) &Param_Setting -}; - -static int Param_Parse(PARAM_T *param, const char *cparam, int flags) { - if (!param) - CLPFatalError("PARAM_T is NULL"); - - if (param->which >= PARAMWHICH_None && param->which < PARAMWHICH_MAX) { - return ParamParsers[param->which](param, cparam, flags); - } else { - CLPFatalError("Unhandled PARAM_T (%d)", param->which); - return 0; - } -} - -typedef void (*DESC_HELP_FUNC)(PARAM_T *, const char **, const char **, const char **); -DESC_HELP_FUNC DescHelpParams[16] = { - (DESC_HELP_FUNC) &DescHelpParam_None, - (DESC_HELP_FUNC) &DescHelpParam_FTypeCreator, - (DESC_HELP_FUNC) &DescHelpParam_FilePath, - (DESC_HELP_FUNC) &DescHelpParam_Number, - (DESC_HELP_FUNC) &DescHelpParam_String, - (DESC_HELP_FUNC) &DescHelpParam_ID_or_SYM, - (DESC_HELP_FUNC) &DescHelpParam_ID_or_SYM, - (DESC_HELP_FUNC) &DescHelpParam_OnOff, - (DESC_HELP_FUNC) &DescHelpParam_OffOn, - (DESC_HELP_FUNC) &DescHelpParam_Mask, - (DESC_HELP_FUNC) &DescHelpParam_Toggle, - (DESC_HELP_FUNC) &DescHelpParam_Set, - (DESC_HELP_FUNC) &DescHelpParam_SetString, - (DESC_HELP_FUNC) &DescHelpParam_Generic, - (DESC_HELP_FUNC) &DescHelpParam_IfArg, - (DESC_HELP_FUNC) &DescHelpParam_Setting -}; -void Param_DescHelp(PARAM_T *param, const char **desc, const char **help, const char **defaul) { - *desc = 0; - *help = 0; - *defaul = 0; - - if (!param) { - CLPFatalError("PARAM_T is NULL"); - return; - } - - if (param->which >= PARAMWHICH_None && param->which < PARAMWHICH_MAX) { - DescHelpParams[param->which](param, desc, help, defaul); - } else { - CLPFatalError("Unhandled PARAM_T (%d)", param->which); - } -} - -typedef int (*COMPARE_FUNC)(PARAM_T *); -COMPARE_FUNC CompareParams[16] = { - (COMPARE_FUNC) &CompareParam_None, - (COMPARE_FUNC) &CompareParam_FTypeCreator, - (COMPARE_FUNC) &CompareParam_FilePath, - (COMPARE_FUNC) &CompareParam_Number, - (COMPARE_FUNC) &CompareParam_String, - (COMPARE_FUNC) &CompareParam_ID_or_SYM, - (COMPARE_FUNC) &CompareParam_ID_or_SYM, - (COMPARE_FUNC) &CompareParam_OnOff, - (COMPARE_FUNC) &CompareParam_OffOn, - (COMPARE_FUNC) &CompareParam_Mask, - (COMPARE_FUNC) &CompareParam_Toggle, - (COMPARE_FUNC) &CompareParam_Set, - (COMPARE_FUNC) &CompareParam_SetString, - (COMPARE_FUNC) &CompareParam_Generic, - (COMPARE_FUNC) &CompareParam_IfArg, - (COMPARE_FUNC) &CompareParam_Setting -}; -int Param_Compare(PARAM_T *param) { - if (!param) - CLPFatalError("PARAM_T is NULL"); - - if (param->which >= PARAMWHICH_None && param->which < PARAMWHICH_MAX) { - return CompareParams[param->which](param); - } else { - CLPFatalError("Unhandled PARAM_T (%d)", param->which); - return 0; - } -} - -static void Param_PushParam(const char *param) { - Args_Push(4, (void *) param, 0); -} - -static void Param_PopParam() { - Args_Pop(4); -} - -static Boolean Param_IsNonTextFile(const char *fname, Boolean warn) { - OSSpec tmp; - CWDataType mactype; - Boolean isfile; - - if (!OS_MakeSpec(fname, &tmp, &isfile)) { - if (isfile) { - if (!OS_Status(&tmp)) { - if (!OS_GetMacFileType(&tmp, &mactype)) { - if (mactype != 'TEXT') { - if (warn) - Param_Warning(77, fname); - return 1; - } - } - } - } - } - - return 0; -} - -static int Param_GetArgument(PARAM_T *param, const char **cparam, int exec) { - int subparse; - short nextOpt; - short nextParam; - short lastOpt; - ArgToken *tok; - - subparse = (exec & PARAMPARSEFLAGS_4) != 0; - nextOpt = !subparse ? ATK_1 : ATK_5; - nextParam = !subparse ? ATK_5 : ATK_4; - lastOpt = !subparse ? ATK_0 : ATK_1; - - tok = Arg_PeekToken(); -#line 1467 - OPTION_ASSERT(tok); - - if ((param->flags & PARAMFLAGS_3) == 0) { - if (tok->val == nextParam || tok->val == ATK_4) - tok = Arg_UsedToken(); - if (tok->val == nextOpt || tok->val == nextParam || tok->val == lastOpt) { - Param_Error(34); - return 0; - } - if (tok->val != ATK_2) { - Param_Error(57, "parameter", Arg_GetTokenName(tok)); - return 0; - } - Arg_GetTokenText(tok, curparam, sizeof(curparam), 1); - Arg_UsedToken(); - *cparam = curparam; - - if (param->flags & PARAMFLAGS_8) { - tok = Arg_PeekToken(); - if (tok->val == ATK_4) - Arg_UsedToken(); - } - } else if (param->flags & PARAMFLAGS_1) { - *cparam = 0; - if (tok->val == ATK_4 && !subparse) { - if (!(exec & PARAMPARSEFLAGS_40)) { - Param_Error(37); - return 0; - } - Arg_UsedToken(); - } - } else if (param->flags & PARAMFLAGS_2) { - if (tok->val == nextOpt || tok->val == lastOpt) { - *cparam = 0; - } else if (tok->val == nextParam) { - tok = Arg_UsedToken(); - if (tok->val == ATK_2) { - Arg_GetTokenText(tok, curparam, sizeof(curparam), 1); - if ((param->flags & PARAMFLAGS_12) && Param_IsNonTextFile(curparam, !(exec & PARAMPARSEFLAGS_1))) { - *cparam = 0; - } else { - Arg_UsedToken(); - *cparam = curparam; - } - } else { - *cparam = 0; - } - } else if (tok->val == ATK_2 && !tok->text[0]) { - tok = Arg_UsedToken(); - if (tok->val == nextParam) - Arg_UsedToken(); - *cparam = 0; - } else if ((exec & PARAMPARSEFLAGS_4) && tok->val != ATK_4) { - *cparam = 0; - } else { - if (tok->val == ATK_4) - tok = Arg_UsedToken(); - if (tok->val == ATK_2) { - Arg_GetTokenText(tok, curparam, sizeof(curparam), 1); - if ((param->flags & PARAMFLAGS_12) && Param_IsNonTextFile(curparam, !(exec & PARAMPARSEFLAGS_1))) { - *cparam = 0; - } else { - Arg_UsedToken(); - *cparam = curparam; - } - } else { - *cparam = 0; - } - } - } else { - CLPFatalError("Unknown parameter type"); - } - - if (pTool->TYPE == CWDROPINCOMPILERTYPE && (exec & PARAMPARSEFLAGS_2) && *cparam) { - if (!(exec & PARAMPARSEFLAGS_10)) { - if (subparse) - Arg_AddToToolArgs(&linkargs, ATK_4, 0); - else - Arg_AddToToolArgs(&linkargs, ATK_5, 0); - } - Param_PushParam(*cparam); - Args_AddToToolArgs(&linkargs); - Param_PopParam(); - } - - return 1; -} - -int Params_Parse(PARAM_T *param, int flags) { - const char *cparam; - flags |= PARAMPARSEFLAGS_10; - - if (param) { - while (param) { - if (flags & PARAMPARSEFLAGS_20) - flags |= PARAMPARSEFLAGS_40; - - if (!Param_GetArgument(param, &cparam, flags)) - return 0; - - if (!(flags & PARAMPARSEFLAGS_1)) { - if (!Param_Parse(param, cparam, flags | (short) ((param->flags & PARAMFLAGS_4) ? PARAMPARSEFLAGS_20 : 0))) - return 0; - } else if (param->flags & PARAMFLAGS_4) { - if (!Param_GetArgument(param, &cparam, flags | PARAMPARSEFLAGS_4)) - return 0; - } - - if (cparam) - flags &= ~PARAMPARSEFLAGS_10; - flags &= ~PARAMPARSEFLAGS_40; - param = param->next; - } - } - - return 1; -} - -void Param_Error(short id, ...) { - va_list va; - va_start(va, id); - Option_ParamError(id, va); - va_end(va); -} - -void Param_Warning(short id, ...) { - va_list va; - va_start(va, id); - Option_ParamWarning(id, va); - va_end(va); -} diff --git a/command_line/C++_Parser/Src/Library/WarningHelpers.c b/command_line/C++_Parser/Src/Library/WarningHelpers.c new file mode 100644 index 0000000..35a6fa8 --- /dev/null +++ b/command_line/C++_Parser/Src/Library/WarningHelpers.c @@ -0,0 +1,84 @@ +#include "parser.h" + +int SetWarningFlags(const char *opt, void *str, const char *, int flags) { + // this is very similar to ToolHelper + // might also fail to match + unsigned char *ptr; + Boolean set; + Boolean no; + UInt16 flag; + + ptr = (unsigned char *) str; + no = (Boolean) ((flags & PARAMPARSEFLAGS_8) >> 3); + set = (Boolean) (no ^ 1); + + while (*ptr) { + if (*ptr == '+') { + set = !no; + } else if (*ptr == '-') { + set = no; + } else if (*ptr == '|') { + set = (Boolean) (no ^ 1); + } else { + flag = (ptr[0] << 8) | ptr[1]; + + if (set) + pCmdLine.noWarnings = 0; + + switch (flag) { + case 'Nw': + pCmdLine.noWarnings = set; + break; + case 'Aw': + TargetSetWarningFlags(flag, set); + break; + case 'Cw': + pCmdLine.noCmdLineWarnings = !set; + break; + case 'We': + pCmdLine.warningsAreErrors = set; + TargetSetWarningFlags(flag, set); + break; + default: + if (!TargetSetWarningFlags(flag, set)) + CLPFatalError("Bad warning settings in %s (%c%c)\n", str, ptr[0], ptr[1]); + } + + ++ptr; + } + + ++ptr; + } + + Parser_StorePanels(parseopts.context); + + return 1; +} + +int DisplayWarningOptions() { + Handle h; + + h = NewHandle(0); + if (!h) + exit(-23); + + HPrintF(h, "Command-line warning options:\n"); + + if (pCmdLine.noCmdLineWarnings) + HPrintF(h, "\t- no command-line warnings\n"); + else + HPrintF(h, "\t- command-line warnings\n"); + + if (pCmdLine.warningsAreErrors) + HPrintF(h, "\t- warnings are errors\n"); + else + HPrintF(h, "\t- warnings are not errors\n"); + + if (pCmdLine.noWarnings) + HPrintF(h, "\t- no warnings at all\n"); + + TargetDisplayWarningOptions(h); + ShowTextHandle(NULL, h); + DisposeHandle(h); + return 1; +} diff --git a/command_line/CmdLine/Src/CLBrowser.c b/command_line/CmdLine/Src/CLBrowser.c index e69de29..826d395 100644 --- a/command_line/CmdLine/Src/CLBrowser.c +++ b/command_line/CmdLine/Src/CLBrowser.c @@ -0,0 +1,217 @@ +#include "cmdline.h" + +typedef struct { + UInt16 fileID; + char *filepath; +} S43; + +typedef struct { + UInt16 fileID; + char unused[12]; + UInt16 filename_length; + char filepath[1]; +} S49; + +typedef struct { + char magic_word[4]; + char version; + char big_endian; + char padding[16]; + UInt16 file_data_count; + UInt32 browse_data_offset; + UInt32 browse_data_length; + UInt32 file_data_offset; + UInt32 file_data_length; +} T53; + +static void GetBrowseTableInfoAndLock(OSHandle *browsetable, S43 **scan, SInt32 *num, SInt32 *size) { + UInt32 tsize; + + OS_GetHandleSize(browsetable, &tsize); + if (scan) + *scan = OS_LockHandle(browsetable); + if (num) + *num = tsize / sizeof(S43); + if (size) + *size = tsize; +} + +int Browser_Initialize(OSHandle *browsetableptr) { + int err = OS_NewHandle(0, browsetableptr); + if (err) { + CLReportOSError(63, err, "allocate", "browse file table"); + return 0; + } else { + return 1; + } +} + +static int Destroy(OSHandle *browsetable) { + S43 *scan; + SInt32 num; + + GetBrowseTableInfoAndLock(browsetable, &scan, &num, NULL); + while (num--) { + xfree(scan->filepath); + scan++; + } + OS_UnlockHandle(browsetable); + return 1; +} + +int Browser_Terminate(OSHandle *browsetableptr) { + if (!Destroy(browsetableptr)) { + return 0; + } else { + OS_FreeHandle(browsetableptr); + return 1; + } +} + +int Browser_SearchFile(OSHandle *browsetable, const char *fullpath, SInt16 *ID) { + S43 *scan; + SInt32 cnt; + SInt32 idx; + SInt32 size; + Boolean found = 0; + +#line 114 + OPTION_ASSERT(OS_IsFullPath(fullpath)); + OPTION_ASSERT(browsetable!=NULL); + + GetBrowseTableInfoAndLock(browsetable, &scan, &cnt, &size); + for (idx = 0; idx < cnt; idx++) { + if (OS_EqualPath(fullpath, scan->filepath)) { + found = 1; + break; + } + scan++; + } + + if (found) + *ID = scan->fileID; + else + *ID = 0; + + OS_UnlockHandle(browsetable); + return found; +} + +int Browser_SearchAndAddFile(OSHandle *browsetable, const char *fullpath, SInt16 *ID) { + S43 *scan; + SInt32 cnt; + SInt32 size; + char *pathptr; + + if (!Browser_SearchFile(browsetable, fullpath, ID)) { + pathptr = xstrdup(fullpath); + GetBrowseTableInfoAndLock(browsetable, &scan, &cnt, &size); + OS_UnlockHandle(browsetable); + if (OS_ResizeHandle(browsetable, sizeof(S43) * (cnt + 1))) { + fprintf(stderr, "\n*** Out of memory\n"); + exit(-23); + } + + scan = (S43 *) (((char *) OS_LockHandle(browsetable)) + size); + scan->filepath = pathptr; + scan->fileID = cnt + 1; + OS_UnlockHandle(browsetable); + + *ID = scan->fileID; + return -1; + } else { + return 1; + } +} + +static SInt32 CalcDiskSpaceRequirements(S43 *mem, int num) { + SInt32 space = 0; + while (num--) { + space += 0x10; + space += (strlen(mem->filepath) + 7) & ~7; + mem++; + } + return space; +} + +static int ConvertMemToDisk(S43 *mem, S49 *disk, int num) { + int slen; + int blen; + + while (num--) { + disk->fileID = mem->fileID; + memset(disk->unused, 0, sizeof(disk->unused)); + slen = strlen(mem->filepath); + blen = (slen + 7) & ~7; + disk->filename_length = slen; + memset(disk->filepath, 0, blen); + strncpy(disk->filepath, mem->filepath, slen); + disk = (S49 *) (((unsigned char *) disk) + 0x10 + blen); + mem++; + } + + return 1; +} + +int Browser_PackBrowseFile(Handle browsedata, OSHandle *browsetable, OSHandle *browsefileptr) { + OSHandle h; + char *ptr; + T53 header; + S43 *scan; + SInt32 entries; + UInt32 datasize; + UInt32 tableoffs; + UInt32 tablesize; + UInt32 totalsize; + SInt32 a_long = 1; + int err; + void *bptr; + +#line 253 + OPTION_ASSERT(browsedata!=NULL); + OPTION_ASSERT(browsetable!=NULL); + + datasize = GetHandleSize(browsedata); + tableoffs = (datasize + sizeof(header) + 7) & ~7; + + GetBrowseTableInfoAndLock(browsetable, &scan, &entries, NULL); + tablesize = CalcDiskSpaceRequirements(scan, entries); + OS_UnlockHandle(browsetable); + + totalsize = tablesize + tableoffs; + + memcpy(header.magic_word, "DubL", 4); + header.version = 1; + header.big_endian = *((char *) &a_long) == 0; + memset(header.padding, 0, sizeof(header.padding)); + + header.browse_data_offset = sizeof(header); + header.browse_data_length = datasize; + header.file_data_offset = tableoffs; + header.file_data_length = tablesize; + header.file_data_count = entries; + + err = OS_NewHandle(totalsize, &h); + *browsefileptr = h; + if (err) { + fprintf(stderr, "\n*** Out of memory\n"); + exit(-23); + } + + ptr = OS_LockHandle(&h); + memcpy(ptr, &header, sizeof(header)); + + HLock(browsedata); + memcpy(&ptr[sizeof(header)], *browsedata, datasize); + // an 'add' for this is swapped around and i cannot fucking figure out why + memset(&ptr[sizeof(header) + datasize], 0, tableoffs - sizeof(header) - datasize); + HUnlock(browsedata); + + GetBrowseTableInfoAndLock(browsetable, &scan, &entries, NULL); + ConvertMemToDisk(scan, bptr = ptr + tableoffs, entries); + memset((char *) bptr + tablesize, 0, totalsize - tableoffs - tablesize); + OS_UnlockHandle(browsetable); + OS_UnlockHandle(&h); + return 1; +} + diff --git a/command_line/CmdLine/Src/CLDependencies.c b/command_line/CmdLine/Src/CLDependencies.c index e69de29..8c4c13b 100644 --- a/command_line/CmdLine/Src/CLDependencies.c +++ b/command_line/CmdLine/Src/CLDependencies.c @@ -0,0 +1,407 @@ +#include "cmdline.h" + +extern char STSbuf[256]; + +static Path *specialAccessPath; +SInt16 *CLT_filesp; +CPrepFileInfoStack *CLT_filestack; + +// forward decl +static Boolean FindFileInPaths(Paths *paths, const char *filename, Path **thepath, OSSpec *spec); +static void SetSpecialAccessPathFromIncludeStackTOS(); + +Boolean Incls_Initialize(Incls *incls, Target *targ) { + specialAccessPath = NULL; + incls->targ = targ; + incls->maxincls = 0; + incls->numincls = 0; + incls->bufpos = 0; + incls->buflen = 0; + incls->buffer = NULL; + incls->files = NULL; + incls->allPaths = xmalloc(NULL, sizeof(Paths)); + Paths_Initialize(incls->allPaths); + return 1; +} + +void Incls_Terminate(Incls *incls) { + if (incls->buffer) + xfree(incls->buffer); + if (incls->files) + xfree(incls->files); + Paths_Terminate(incls->allPaths); + xfree(incls->allPaths); +} + +static Boolean IsSysIncl(Incls *incls, SInt32 idx) { + InclFile *i = &incls->files[idx]; + return i->syspath; +} + +static void MakeInclFileSpec(Incls *incls, SInt32 idx, OSSpec *spec) { + InclFile *f = &incls->files[idx]; + OS_MakeSpecWithPath( + f->globalpath->spec, + &incls->buffer[f->filenameoffs], + 0, + spec); +} + +static Boolean QuickFindFileInIncls(Incls *incls, Boolean fullsearch, const char *filename, OSSpec *spec, SInt32 *index, InclFile **f) { + int idx; + for (idx = 0; idx < incls->numincls; idx++) { + *f = &incls->files[idx]; + if (OS_EqualPath(&incls->buffer[(*f)->filenameoffs], filename)) { + if (fullsearch || (*f)->syspath) { + MakeInclFileSpec(incls, idx, spec); + *index = idx; + return 1; + } + } + } + return 0; +} + +static Boolean SameIncl(Incls *incls, SInt32 a, SInt32 b) { + InclFile *ia; + InclFile *ib; + if (a == b) + return 1; + ia = &incls->files[a]; + ib = &incls->files[b]; + return ia->globalpath == ib->globalpath && OS_EqualPath(&incls->buffer[ia->filenameoffs], &incls->buffer[ib->filenameoffs]); +} + +static Path *FindOrAddGlobalInclPath(Paths *paths, OSPathSpec *spec) { + Path *path = Paths_FindPathSpec(paths, spec); + if (!path) { + path = Path_New(spec); + Paths_AddPath(paths, path); + } + return path; +} + +static Boolean _FindFileInPath(Path *path, const char *filename, Path **thepath, OSSpec *spec) { + if (!OS_MakeSpecWithPath(path->spec, filename, 0, spec) && OS_IsFile(spec)) { + *thepath = path; + return 1; + } + + if (path->recursive && FindFileInPaths(path->recursive, filename, thepath, spec)) + return 1; + + return 0; +} + +static Boolean FindFileInPaths(Paths *paths, const char *filename, Path **thepath, OSSpec *spec) { + UInt16 idx; + Path *path; + + for (idx = 0; idx < Paths_Count(paths); idx++) { + path = Paths_GetPath(paths, idx); +#line 175 + OPTION_ASSERT(path); + if (_FindFileInPath(path, filename, thepath, spec)) + return 1; + } + + return 0; +} + +static void AddFileToIncls(Incls *incls, char *infilename, Boolean syspath, Path *accesspath, Path *globalpath, Path *specialpath, SInt32 *index) { + InclFile *f; + int fnlen; + char *filename; + OSSpec spec; + + if (!accesspath && !globalpath) + filename = OS_GetFileNamePtr(infilename); + else + filename = infilename; + fnlen = strlen(filename) + 1; + + if (incls->numincls >= incls->maxincls) { + incls->maxincls += 16; + incls->files = xrealloc("include list", incls->files, sizeof(InclFile) * incls->maxincls); + } + + f = &incls->files[incls->numincls]; + f->filenameoffs = incls->bufpos; + f->syspath = syspath; + f->accesspath = accesspath; + if (globalpath) { + f->globalpath = globalpath; + } else if (accesspath) { + f->globalpath = FindOrAddGlobalInclPath(incls->allPaths, accesspath->spec); + } else { + OS_MakeFileSpec(infilename, &spec); + f->globalpath = FindOrAddGlobalInclPath(incls->allPaths, &spec.path); + } + f->specialpath = Deps_GetSpecialAccessPath(); + + if (incls->bufpos + fnlen > incls->buflen) { + incls->buflen += 1024; + incls->buffer = xrealloc("include list", incls->buffer, incls->buflen); + } + strcpy(&incls->buffer[incls->bufpos], filename); + incls->bufpos += fnlen; + *index = incls->numincls++; +} + +Boolean Incls_FindFileInPaths(Incls *incls, char *filename, Boolean fullsearch, OSSpec *spec, SInt32 *inclidx) { + Boolean found; + InclFile *incl; + Boolean foundglobal; + Path *globalpath; + Path *accesspath; + Path *specialpath; + Boolean userpath; + char rel_path[256]; + + found = 0; + if (optsCompiler.includeSearch == 3 && fullsearch) + SetSpecialAccessPathFromIncludeStackTOS(); + *inclidx = -1; + + foundglobal = QuickFindFileInIncls(incls, fullsearch, filename, spec, inclidx, &incl); + if (foundglobal) { + if (incl->specialpath == specialAccessPath && incl->syspath && !fullsearch) + found = 1; + else if (!incl->accesspath) + foundglobal = 0; + } + + if (!found) { + accesspath = globalpath = NULL; + userpath = fullsearch; + if (OS_IsFullPath(filename)) { + found = !OS_MakeFileSpec(filename, spec) && !OS_Status(spec); + accesspath = globalpath = specialpath = NULL; + } else { + specialpath = Deps_GetSpecialAccessPath(); + globalpath = specialpath; + if (specialpath) { + found = _FindFileInPath(specialpath, filename, &globalpath, spec); + accesspath = NULL; + } + if (!found && foundglobal && incl->syspath && !fullsearch) { + globalpath = incl->globalpath; + accesspath = incl->accesspath; + specialpath = NULL; + MakeInclFileSpec(incls, *inclidx, spec); + found = 1; + } + if (!found && fullsearch) { + userpath = 1; + globalpath = NULL; + found = FindFileInPaths(&incls->targ->userPaths, filename, &accesspath, spec); + } + if (!found) { + userpath = 0; + globalpath = NULL; + found = FindFileInPaths(&incls->targ->sysPaths, filename, &accesspath, spec); + } + if (!found) { + specialpath = Deps_GetSpecialAccessPath(); + globalpath = specialpath; + if (!found && MakeFrameworkPath(rel_path, filename, specialpath)) { + filename = rel_path; + found = FindFileInPaths(&FrameworkPaths, filename, &globalpath, spec); + } + } + } + + if (found && *inclidx < 0) + AddFileToIncls(incls, filename, !userpath, accesspath, globalpath, specialpath, inclidx); + } + + return found; +} + +Boolean Deps_Initialize(Deps *deps, Incls *incls) { + deps->numDeps = 0; + deps->maxDeps = 0; + deps->list = NULL; + deps->incls = incls; + return 1; +} + +void Deps_Terminate(Deps *deps) { + if (deps->list) + xfree(deps->list); +} + +int Deps_ChangeSpecialAccessPath(OSSpec *srcfss, Boolean initialize) { + static OSSpec *currentsrcfss; + OSPathSpec pathspec; + OSPathSpec *pathspecptr; + + if (initialize && srcfss) + currentsrcfss = srcfss; + + switch (optsCompiler.includeSearch) { + case IncludeSearch_Type2: + specialAccessPath = NULL; + return 1; + case IncludeSearch_Type0: + if (!initialize) + return 1; + OS_GetCWD(&pathspec); + pathspecptr = &pathspec; + break; + case IncludeSearch_Type1: + if (!initialize) + return 1; + case IncludeSearch_Type3: + if (srcfss) { + pathspecptr = &srcfss->path; + } else if (currentsrcfss) { + pathspecptr = ¤tsrcfss->path; + } else { + OS_GetCWD(&pathspec); + pathspecptr = &pathspec; + } + break; + default: +#line 468 + DO_INTERNAL_ERROR("Unhandled include file search type (%d)\n", optsCompiler.includeSearch); + } + + specialAccessPath = FindOrAddGlobalInclPath(gTarg->incls.allPaths, pathspecptr); + if (optsCmdLine.verbose > 2) + CLReport(105, OS_PathSpecToString(pathspecptr, STSbuf, sizeof(STSbuf))); + return 1; +} + +Path *Deps_GetSpecialAccessPath() { + return specialAccessPath; +} + +static void SetSpecialAccessPathFromIncludeStackTOS() { + // does not match, some registers are in the wrong order + OSSpec spec; + SInt16 index; + char *fnameptr; + VFile *vf; + + if (optsCompiler.includeSearch == IncludeSearch_Type3 && CLT_filesp && CLT_filestack) { + if (*CLT_filesp >= 0) { + index = *CLT_filesp; + while (index) { + if (!(*CLT_filestack)[index]) + break; + OS_FSSpec_To_OSSpec(&(*CLT_filestack)[index--]->textfile, &spec); + fnameptr = OS_GetFileNamePtr(OS_NameSpecToString(&spec.name, STSbuf, sizeof(STSbuf))); + vf = VFiles_Find(gTarg->virtualFiles, fnameptr); + if (!vf) { + if (!specialAccessPath || !OS_EqualPathSpec(&spec.path, specialAccessPath->spec)) { + Deps_ChangeSpecialAccessPath(&spec, 0); + return; + } + return; + } + } + } + Deps_ChangeSpecialAccessPath(NULL, 0); + } +} + +static Boolean FindDepFile(Deps *deps, SInt32 incl) { + int idx; + + for (idx = 0; idx < deps->numDeps; idx++) { + if (SameIncl(&gTarg->incls, deps->list[idx], incl)) + return 1; + } + + return 0; +} + +static void AddDepFile(Deps *deps, SInt32 incl, SInt16 dependencyType) { + if (deps->numDeps >= deps->maxDeps) { + deps->maxDeps += 16; + deps->list = xrealloc("dependency list", deps->list, sizeof(SInt32) * deps->maxDeps); + } + deps->list[deps->numDeps++] = incl; +} + +void Deps_AddDependency(Deps *deps, SInt32 incl, OSSpec *spec, Boolean unk, SInt16 dependencyType, Boolean *alreadyincluded) { + Boolean included; + + if (incl < 0) { + AddFileToIncls( + &gTarg->incls, + OS_SpecToString(spec, STSbuf, sizeof(STSbuf)), + 0, + NULL, NULL, NULL, + &incl); + } + + included = FindDepFile(deps, incl); + if (!included) { + if (!(optsCompiler.depsOnlyUserFiles ? IsSysIncl(deps->incls, incl) : 0)) + AddDepFile(deps, incl, dependencyType); + } + + if (alreadyincluded) + *alreadyincluded = included; +} + +static char *EscapeName(Boolean spaces, char *escbuf, char *path) { + char *ret; + + if (!spaces) + return path; + + ret = escbuf; + while (*path) { + if (*path == ' ') + *(escbuf++) = '\\'; + *(escbuf++) = *(path++); + } + *escbuf = 0; + return ret; +} + +void Deps_ListDependencies(Incls *incls, File *file, OSHandle *h) { + Boolean spaces; + int idx; + char linebuf[512]; + char outfilename[256]; + int totdeps; + char path[256]; + char escbuf[320]; + OSSpec spec; + +#define LIST_DEP(format, name, ...) \ +do { \ +sprintf(linebuf, format, spaces ? "" : "", EscapeName(spaces, escbuf, (name)), spaces ? "" : "", __VA_ARGS__); \ +if (OS_AppendHandle(h, linebuf, strlen(linebuf))) goto memFail; \ +} while (0) + + if (!OS_NewHandle(0, h)) { + totdeps = file->deps.numDeps; + OS_SpecToStringRelative(&file->outfss, NULL, outfilename, sizeof(outfilename)); + if (outfilename[0]) { + spaces = strchr(outfilename, ' ') != NULL; + LIST_DEP("%s%s%s%s ", outfilename, ":"); + spaces = strchr(file->srcfilename, ' ') != NULL; + LIST_DEP("%s%s%s %s\n", file->srcfilename, totdeps ? "\\" : ""); + } else { + spaces = strchr(file->srcfilename, ' ') != NULL; + LIST_DEP("%s%s%s%s %s\n", file->srcfilename, ":", totdeps ? "\\" : ""); + } + + for (idx = 0; idx < file->deps.numDeps; idx++) { + totdeps--; + MakeInclFileSpec(incls, file->deps.list[idx], &spec); + OS_SpecToString(&spec, path, sizeof(path)); + spaces = strchr(path, ' ') != NULL; + LIST_DEP("\t%s%s%s %s\n", path, totdeps ? "\\" : ""); + } + } else { + memFail: + fprintf(stderr, "\n*** Out of memory\n"); + exit(-23); + } +} diff --git a/command_line/CmdLine/Src/CLFileOps.c b/command_line/CmdLine/Src/CLFileOps.c index e69de29..14c9dc6 100644 --- a/command_line/CmdLine/Src/CLFileOps.c +++ b/command_line/CmdLine/Src/CLFileOps.c @@ -0,0 +1,803 @@ +#include "cmdline.h" + +extern char STSbuf[256]; + +static int OutputTextData(File *file, SInt16 stage, OSType maccreator, OSType mactype) { + int ret = 0; + SInt32 size; + + if (file->textdata) { + size = GetHandleSize(file->textdata); + if (stage != CmdLineStageMask_Dp || optsCmdLine.toDisk & CmdLineStageMask_Dp) { + if (!(file->writeToDisk & stage)) { + ret = ShowHandle(file->textdata, size, 0); + } else { + if (optsCmdLine.verbose) + CLReport(15, OS_SpecToStringRelative(&file->outfss, NULL, STSbuf, sizeof(STSbuf))); + ret = WriteHandleToFile(&file->outfss, file->textdata, size, maccreator, mactype); + file->wroteToDisk |= stage; + } + } else { + if (optsCompiler.outMakefile[0]) { + ret = AppendHandleToFile(&clState.makefileSpec, file->textdata, size, maccreator, mactype); + } else { + ret = ShowHandle(file->textdata, size, 0); + } + } + + DisposeHandle(file->textdata); + file->textdata = NULL; + } + + return ret; +} + +static int fstrcat(char *file, const char *add, SInt32 length) { + if (strlen(file) + strlen(add) >= length) { + return 0; + } else { + strcat(file, add); + return 1; + } +} + +static void extstrcat(char *file, const char *ext) { + if (!fstrcat(file, ext, 64)) + strcpy(file + 63 - strlen(ext), ext); +} + +int GetOutputFile(File *file, SInt16 stage) { + int err; + char tempoutfilename[256]; + char *targetoutfilename; + Boolean specifiedName; + const char *ext; + const CWObjectFlags *cof; + char tmpname[256]; + char *env; + char *extptr; + char *fnptr; + char text[64]; + char *inname; + OSPathSpec tmppath; + + if (optsCmdLine.toDisk & stage) + file->writeToDisk |= stage; + + if (file->outfileowner == stage) { + targetoutfilename = file->outfilename; + specifiedName = file->outfilename[0] && !(file->tempOnDisk & stage); + if (specifiedName) { + file->writeToDisk |= stage; + file->tempOnDisk &= ~stage; + } + } else { + targetoutfilename = tempoutfilename; + specifiedName = 0; + } + + if (!(stage & (optsCmdLine.toDisk | file->writeToDisk | file->tempOnDisk))) { + if ((stage == CmdLineStageMask_Cg) && (optsCmdLine.stages & CmdLineStageMask_Ds) && (optsCmdLine.state == OptsCmdLineState_2) && optsCompiler.keepObjects) + file->writeToDisk |= stage; + else + file->tempOnDisk |= stage; + } + + if (!specifiedName && (stage & (optsCmdLine.toDisk | file->writeToDisk | file->tempOnDisk))) { + cof = Plugin_CL_GetObjectFlags(file->compiler); + if (stage == CmdLineStageMask_Pp) { + ext = optsCompiler.ppFileExt[0] ? optsCompiler.ppFileExt : cof->ppFileExt; + } else if (stage == CmdLineStageMask_Ds) { + ext = optsCompiler.disFileExt[0] ? optsCompiler.disFileExt : cof->disFileExt; + } else if (stage == CmdLineStageMask_Dp) { + ext = optsCompiler.depFileExt[0] ? optsCompiler.depFileExt : cof->depFileExt; + } else if (stage == CmdLineStageMask_Cg) { + ext = optsCompiler.objFileExt[0] ? optsCompiler.objFileExt : cof->objFileExt; + if (!(file->objectflags & 0x80000000) && !specifiedName) + ext = NULL; + } else { + ext = NULL; + } + + if (ext && ext[0]) { + if (ext[0] != '.') { + snprintf(text, sizeof(text), ".%s", ext); + } else { + strncpy(text, ext, sizeof(text) - 1); + text[sizeof(text) - 1] = 0; + } + if ((file->tempOnDisk & stage) && !(optsCmdLine.stages & CmdLineStageMask_Dp)) { + env = getenv("TEMP"); + if (!env || !env[0] || OS_MakePathSpec(NULL, env, &tmppath)) + env = getenv("TMP"); + if (!env || !env[0] || OS_MakePathSpec(NULL, env, &tmppath)) + env = getenv("TMPDIR"); + if (!env || !env[0] || OS_MakePathSpec(NULL, env, &tmppath)) + env = "/tmp"; + if (!env || !env[0] || OS_MakePathSpec(NULL, env, &tmppath)) + env = "."; + snprintf(tmpname, sizeof(tmpname), "%s%c%s", env, OS_PATHSEP, OS_GetFileNamePtr(file->srcfilename)); + inname = tmpname; + } else if (!optsCompiler.relPathInOutputDir) { + inname = OS_GetFileNamePtr(file->srcfilename); + } else { + inname = file->srcfilename; + } + + fnptr = OS_GetFileNamePtr(inname); + extptr = strrchr(fnptr, '.'); + if (!extptr || ext[0] == '.') + extptr = fnptr + strlen(fnptr); + + if (extptr - fnptr + strlen(text) >= sizeof(text)) + extptr = &fnptr[sizeof(text) - 1] - strlen(text); + + snprintf(targetoutfilename, 256, "%.*s%s", extptr - inname, inname, text); + } else { + *targetoutfilename = 0; + file->writeToDisk &= ~stage; + file->tempOnDisk &= ~stage; + } + } + + if (stage & (file->writeToDisk | file->tempOnDisk)) { + err = OS_MakeSpecWithPath(&gTarg->outputDirectory, targetoutfilename, !optsCompiler.relPathInOutputDir, &file->outfss); + if (!err) { + if (OS_EqualSpec(&file->srcfss, &file->outfss)) { + if (specifiedName) { + CLReportError(102, targetoutfilename); + file->writeToDisk &= ~stage; + file->tempOnDisk &= ~stage; + return 0; + } + file->writeToDisk &= ~stage; + file->tempOnDisk &= ~stage; + } + } else { + CLReportOSError(9, err, targetoutfilename, OS_PathSpecToString(&gTarg->outputDirectory, STSbuf, sizeof(STSbuf))); + } + return err == 0; + } + + return 1; +} + +static int SyntaxCheckFile(File *file) { + return SendCompilerRequest(file->compiler, file, 0) != 0; +} + +static int PreprocessFile(File *file) { + const CWObjectFlags *cof; + + if (!(file->dropinflags & kCanpreprocess)) { + CLReportWarning(53, Plugin_GetDropInName(file->compiler), file->srcfilename); + return 1; + } + + if (!SendCompilerRequest(file->compiler, file, 1)) + return 0; + + if (!GetOutputFile(file, CmdLineStageMask_Pp)) + return 0; + + if (file->textdata) { + cof = Plugin_CL_GetObjectFlags(file->compiler); + return OutputTextData( + file, CmdLineStageMask_Pp, + optsCompiler.ppFileCreator ? optsCompiler.ppFileCreator : cof->ppFileCreator, + optsCompiler.ppFileType ? optsCompiler.ppFileType : cof->ppFileType); + } + + CLReportError(96, "preprocessing", file->srcfilename); + return 0; +} + +static int DependencyMapFile(File *file, Boolean compileifnecessary) { + OSHandle mf; + const CWObjectFlags *cof; + + cof = Plugin_CL_GetObjectFlags(file->compiler); + if (!(optsCmdLine.stages & (CmdLineStageMask_Pp | CmdLineStageMask_Cg)) && compileifnecessary) { + if (!SendCompilerRequest(file->compiler, file, CmdLineStageMask_Dp)) + return 0; + } + + if (!GetOutputFile(file, CmdLineStageMask_Cg)) + return 0; + + Deps_ListDependencies(&gTarg->incls, file, &mf); + file->textdata = OS_CreateMacHandle(&mf); + + if (!GetOutputFile(file, CmdLineStageMask_Dp)) + return 0; + + if (OutputTextData( + file, CmdLineStageMask_Dp, + optsCompiler.depFileCreator ? optsCompiler.depFileCreator : cof->depFileCreator, + optsCompiler.depFileType ? optsCompiler.depFileType : cof->depFileType)) { + return 1; + } else { + return 0; + } +} + +static int RecordBrowseInfo(File *file) { + const CWObjectFlags *cof; + + if (!file->recordbrowseinfo) + return 1; + + if (!file->browsedata) { + CLReportError(101, Plugin_GetDropInName(file->compiler), OS_SpecToStringRelative(&file->srcfss, NULL, STSbuf, sizeof(STSbuf))); + return 0; + } + + if ((optsCmdLine.toDisk & CmdLineStageMask_Cg) && optsCompiler.browserEnabled) { + cof = Plugin_CL_GetObjectFlags(file->compiler); + if (!WriteBrowseData(file, optsCompiler.brsFileCreator ? optsCompiler.brsFileCreator : cof->brsFileCreator, optsCompiler.brsFileType ? optsCompiler.brsFileType : cof->brsFileType)) + return 0; + } + + return 1; +} + +static int RecordObjectData(File *file) { + const CWObjectFlags *cof = Plugin_CL_GetObjectFlags(file->compiler); + + if (!file->objectdata) + return 1; + + if (!WriteObjectFile(file, optsCompiler.objFileCreator ? optsCompiler.objFileCreator : cof->objFileCreator, optsCompiler.objFileType ? optsCompiler.objFileType : cof->objFileType)) + return 0; + + return 1; +} + +int StoreObjectFile(File *file) { + if (file->wroteToDisk & CmdLineStageMask_Cg) + return 1; + + if (!file->objectdata && !file->browsedata) + return 1; + + if (GetOutputFile(file, CmdLineStageMask_Cg)) { + if (!((file->writeToDisk | file->tempOnDisk) & CmdLineStageMask_Cg)) + return 1; + + if (!RecordBrowseInfo(file) || !RecordObjectData(file)) + return 0; + + file->wroteToDisk |= CmdLineStageMask_Cg; + return 1; + } + + return 0; +} + +static int CompileFile(File *file) { + int ret = 1; + + if (!(file->dropinflags & kCanprecompile) && ((optsCompiler.forcePrecompile == 1) || (file->mappingflags & kPrecompile))) { + CLReportWarning(54, Plugin_GetDropInName(file->compiler), file->srcfilename); + return 1; + } + + if (optsCompiler.browserEnabled) { + SInt16 id; + int ret; + char fullpath[256]; + memset(file->browseoptions, 1, sizeof(file->browseoptions)); + OS_SpecToString(&file->srcfss, fullpath, sizeof(fullpath)); + ret = Browser_SearchAndAddFile(&clState.browseTableHandle, fullpath, &id); + if (!ret) + return 0; + file->recordbrowseinfo = ret < 0; + file->browseFileID = id; + if (optsCmdLine.verbose > 1) + CLReport(22, file->srcfilename, file->browseFileID); + } else { + memset(file->browseoptions, 0, sizeof(file->browseoptions)); + file->recordbrowseinfo = 0; + file->recordbrowseinfo = 0; + file->browseFileID = 0; + } + + if (!SendCompilerRequest(file->compiler, file, 2)) { + ret = 0; + } else { + if ((!file->hasobjectcode || !file->objectdata) && (file->dropinflags & kGeneratescode) && (file->objectUsage & 2)) { + CLReportError(96, "compiling", file->srcfilename); + ret = 0; + } else if (optsCmdLine.state == OptsCmdLineState_2 && !StoreObjectFile(file)) { + ret = 0; + } + } + + return ret; +} + +static int DisassembleWithLinker(File *file, Plugin *linker, SInt32 linkerDropinFlags) { + char filename[256]; + int ret; + + if (file->writeToDisk & CmdLineStageMask_Ds) { + OS_SpecToString(&file->outfss, filename, sizeof(filename)); + ret = ExecuteLinker(linker, linkerDropinFlags, file, (optsCmdLine.toDisk & CmdLineStageMask_Ds) ? NULL : filename, NULL); + file->wroteToDisk |= CmdLineStageMask_Ds; + return ret; + } + + return ExecuteLinker(linker, linkerDropinFlags, file, NULL, NULL); +} + +static int DisassembleFile(File *file) { + Plugin *disasm; + + if (!file->hasobjectcode && !file->hasresources) { + CLReportError(56, file->srcfilename); + return 0; + } + + if (!GetOutputFile(file, CmdLineStageMask_Ds)) + return 0; + + if (file->dropinflags & kCandisassemble) { + if (!SendDisassemblerRequest(file->compiler, file)) + return 0; + + if (file->textdata) { + const CWObjectFlags *cof = Plugin_CL_GetObjectFlags(file->compiler); + return OutputTextData( + file, CmdLineStageMask_Ds, + optsCompiler.disFileCreator ? optsCompiler.disFileCreator : cof->disFileCreator, + optsCompiler.disFileType ? optsCompiler.disFileType : cof->disFileType); + } + CLReportError(96, "disassembling", file->srcfilename); + return 0; + + } else { + if ((gTarg->linkerDropinFlags & dropInExecutableTool) && !(gTarg->linkerDropinFlags & cantDisassemble)) + return DisassembleWithLinker(file, gTarg->linker, gTarg->linkerDropinFlags); + if ((gTarg->preLinkerDropinFlags & dropInExecutableTool) && !(gTarg->preLinkerDropinFlags & cantDisassemble)) + return DisassembleWithLinker(file, gTarg->preLinker, gTarg->preLinkerDropinFlags); + + if (gTarg->linker && !(gTarg->linkerDropinFlags & cantDisassemble)) { + if (SendDisassemblerRequest(gTarg->linker, file)) { + if (file->textdata && GetHandleSize(file->textdata) > 0) { + const CWObjectFlags *cof = Plugin_CL_GetObjectFlags(file->compiler); + return OutputTextData( + file, CmdLineStageMask_Ds, + optsCompiler.disFileCreator ? optsCompiler.disFileCreator : cof->disFileCreator, + optsCompiler.disFileType ? optsCompiler.disFileType : cof->disFileType); + } + CLReportError(96, "disassembling", file->srcfilename); + } + return 0; + } + if (gTarg->preLinker && !(gTarg->preLinkerDropinFlags & cantDisassemble)) { + if (SendDisassemblerRequest(gTarg->preLinker, file)) { + if (file->textdata && GetHandleSize(file->textdata) > 0) { + const CWObjectFlags *cof = Plugin_CL_GetObjectFlags(file->compiler); + return OutputTextData( + file, CmdLineStageMask_Ds, + optsCompiler.disFileCreator ? optsCompiler.disFileCreator : cof->disFileCreator, + optsCompiler.disFileType ? optsCompiler.disFileType : cof->disFileType); + } + CLReportError(96, "disassembling", file->srcfilename); + } + return 0; + } + + if (gTarg->linker) + CLReportError(58, Plugin_GetDropInName(gTarg->linker), Plugin_GetDropInName(file->compiler), file->srcfilename); + else + CLReportError(57, Plugin_GetDropInName(file->compiler), file->srcfilename); + + return 0; + } +} + +static int CompileEntry(File *file, Boolean *compiled) { + UInt32 beginWork; + UInt32 endWork; + struct BuildInfo *tinfo = &gTarg->info; + + *compiled = 0; + + if (optsCmdLine.dryRun) { + *compiled = 1; + return 1; + } + + if (!(file->sourceUsage & 1)) { + if (file->mappingflags & kRsrcfile) + *compiled = 1; + return 1; + } + +#line 835 + OPTION_ASSERT(file->compiler); + + *compiled = 1; + beginWork = OS_GetMilliseconds(); + Browser_Initialize(&clState.browseTableHandle); + Deps_ChangeSpecialAccessPath(&file->srcfss, 1); + + if ((optsCmdLine.stages == 0) && !SyntaxCheckFile(file)) + return 0; + if ((optsCmdLine.stages & CmdLineStageMask_Pp) && !PreprocessFile(file)) + return 0; + if ((optsCmdLine.stages & (CmdLineStageMask_Cg | CmdLineStageMask_Ds)) && !CompileFile(file)) + return 0; + if ((optsCmdLine.stages & CmdLineStageMask_Dp) && !DependencyMapFile(file, 1)) + return 0; + if ((optsCmdLine.stages & CmdLineStageMask_Ds) && !DisassembleFile(file)) + return 0; + + if (optsCmdLine.verbose && (optsCmdLine.stages & CmdLineStageMask_Cg)) { + const char *cun; + const char *dun; + const char *uun; + CLReport(25, file->compiledlines); + tinfo->linesCompiled += file->compiledlines; + cun = dun = uun = "bytes"; + CLReport(26, file->codesize, cun, file->idatasize, dun, file->udatasize, uun); + } + tinfo->codeSize += file->codesize; + tinfo->iDataSize += file->idatasize; + tinfo->uDataSize += file->udatasize; + + Browser_Terminate(&clState.browseTableHandle); + endWork = OS_GetMilliseconds(); + + if (optsCmdLine.timeWorking) { + if (optsCmdLine.verbose) + CLReport(24, (endWork - beginWork) / 1000.0, "compile", "", "", ""); + else + CLReport(24, (endWork - beginWork) / 1000.0, "compile", "'", file->srcfilename, "'"); + } + + return 1; +} + +static void DumpFileAndPathInfo() { + int i; + int n; + + CLReport(84, "Framework search paths ([d] = default, [r] = recursive)"); + n = Paths_Count(&FrameworkPaths); + if (!n) { + CLReport(85, "(none)", ""); + } else { + for (i = 0; i < n; i++) { + Path *path = Paths_GetPath(&FrameworkPaths, i); +#line 961 + OPTION_ASSERT(path != NULL); + + CLReport(85, + OS_PathSpecToString(path->spec, STSbuf, sizeof(STSbuf)), + ((path->flags & 2) && path->recursive) ? " [d] [r]" : (path->flags & 2) ? " [d]" : path->recursive ? " [r]" : "" + ); + + if (path->recursive && optsCmdLine.verbose > 2) { + UInt16 j; + for (j = 0; j < Paths_Count(path->recursive); j++) { + Path *sub = Paths_GetPath(path->recursive, j); +#line 976 + OPTION_ASSERT(sub); + CLReport(85, "\t", OS_PathSpecToString(sub->spec, STSbuf, sizeof(STSbuf))); + } + } + } + } + + n = Frameworks_GetCount(); + if (Frameworks_GetCount()) { + CLReport(84, "Included frameworks"); + for (i = 0; i < n; i++) { + char version[80]; + Paths_FWInfo *info = Frameworks_GetInfo(i); +#line 993 + OPTION_ASSERT(info); + + version[0] = 0; + strcpy(version, "\t("); + if (!info->version.s[0]) { + strcat(version, "Current)"); + } else { + strncat(version, info->version.s, sizeof(version) - 4); + strcat(version, ")"); + } + CLReport(85, info->name.s, version); + } + } + + if (clState.plugintype == CWDROPINCOMPILERTYPE) + CLReport(84, "User include search paths ([d] = default, [r] = recursive)"); + else + CLReport(84, "Library search paths ([d] = default, [r] = recursive)"); + + if (!Paths_Count(&gTarg->userPaths) && clState.plugintype == CWDROPINCOMPILERTYPE) { + CLReport(85, "(none)", ""); + } else { + for (i = 0; i < Paths_Count(&gTarg->userPaths); i++) { + Path *path = Paths_GetPath(&gTarg->userPaths, i); +#line 1024 + OPTION_ASSERT(path != NULL); + + CLReport(85, + OS_PathSpecToString(path->spec, STSbuf, sizeof(STSbuf)), + ((path->flags & 2) && path->recursive) ? " [d] [r]" : (path->flags & 2) ? " [d]" : path->recursive ? " [r]" : "" + ); + + if (path->recursive && optsCmdLine.verbose > 2) { + UInt16 j; + for (j = 0; j < Paths_Count(path->recursive); j++) { + Path *sub = Paths_GetPath(path->recursive, j); +#line 1039 + OPTION_ASSERT(sub); + CLReport(85, "\t", OS_PathSpecToString(sub->spec, STSbuf, sizeof(STSbuf))); + } + } + } + } + + if (clState.plugintype == CWDROPINCOMPILERTYPE) + CLReport(84, "System include search paths ([d] = default, [r] = recursive)"); + + if (!Paths_Count(&gTarg->sysPaths)) + CLReport(85, "(none)", ""); + + for (i = 0; i < Paths_Count(&gTarg->sysPaths); i++) { + Path *path = Paths_GetPath(&gTarg->sysPaths, i); +#line 1054 + OPTION_ASSERT(path != NULL); + + CLReport(85, + OS_PathSpecToString(path->spec, STSbuf, sizeof(STSbuf)), + ((path->flags & 2) && path->recursive) ? " [d] [r]" : (path->flags & 2) ? " [d]" : path->recursive ? " [r]" : "" + ); + + if (path->recursive && optsCmdLine.verbose > 2) { + UInt16 j; + for (j = 0; j < Paths_Count(path->recursive); j++) { + Path *sub = Paths_GetPath(path->recursive, j); +#line 1069 + OPTION_ASSERT(sub); + CLReport(85, "\t", OS_PathSpecToString(sub->spec, STSbuf, sizeof(STSbuf))); + } + } + } + + if (clState.plugintype == CWDROPINCOMPILERTYPE) + CLReport(84, "Files in project (relative to CWD)"); + else + CLReport(84, "Link order for project (relative to CWD)"); + + for (i = 0; i < Files_Count(&gTarg->files); i++) { + File *file = Files_GetFile(&gTarg->files, i); + if (!VFiles_Find(gTarg->virtualFiles, file->srcfilename)) + CLReport(85, OS_SpecToStringRelative(&file->srcfss, NULL, STSbuf, sizeof(STSbuf)), ""); + else + CLReport(85, file->srcfilename, "\t(virtual file)"); + } +} + +int CompileFilesInProject() { + struct BuildInfo *tinfo; + SInt32 index; + SInt32 startTime; + SInt32 endTime; + int ignored; + int compiled; + Boolean failed; + + failed = 0; + startTime = OS_GetMilliseconds(); + InitializeIncludeCache(); + if (optsCmdLine.verbose > 1) + DumpFileAndPathInfo(); + + if (!SendTargetInfoRequest(gTarg, gTarg->linker, gTarg->linkerDropinFlags)) + return Result_Failed; + + ignored = 0; + compiled = 0; + for (index = 0; index < Files_Count(&gTarg->files); index++) { + int ret; + File *file; + Boolean wascompiled; + + file = Files_GetFile(&gTarg->files, index); + if (!file->outfileowner) + file->outfileowner = CmdLineStageMask_Cg; + ret = CompileEntry(file, &wascompiled); + if (ret) { + if (wascompiled) + compiled++; + if (!wascompiled) + ignored++; + if (CheckForUserBreak()) + return Result_Cancelled; + } + + if (!ret) { + if (optsCompiler.noFail) { + failed = 1; + clState.countWarnings = 0; + clState.countErrors = 0; + clState.withholdWarnings = 0; + clState.withholdErrors = 0; + } else { + return CheckForUserBreak() ? Result_Cancelled : Result_Failed; + } + } + } + + if (optsCmdLine.stages & CmdLineStageMask_Dp) { + for (index = 0; index < Files_Count(&gTarg->pchs); index++) { + int ret; + File *file; + + file = Files_GetFile(&gTarg->pchs, index); + ret = DependencyMapFile(file, 0); + if (!ret) { + if (optsCompiler.noFail) { + failed = 1; + clState.countWarnings = 0; + clState.countErrors = 0; + clState.withholdWarnings = 0; + clState.withholdErrors = 0; + } else { + return CheckForUserBreak() ? Result_Cancelled : Result_Failed; + } + } + } + } + + CleanupIncludeCache(); + + tinfo = &gTarg->info; + if (optsCmdLine.verbose && compiled > 1) { + const char *cun; + const char *dun; + const char *uun; + cun = dun = uun = "bytes"; + CLReport(27, tinfo->codeSize, cun, tinfo->iDataSize, dun, tinfo->uDataSize, uun); + } + + endTime = OS_GetMilliseconds(); + + if (optsCmdLine.timeWorking) + CLReport(24, (endTime - startTime) / 1000.0, "compile", "", "", "project"); + + if (ignored > 0 && compiled == 0 && (gTarg->preLinker || gTarg->linker)) + CLReportError(29); + + if (failed) + return Result_Failed; + return CheckForUserBreak() ? Result_Cancelled : Result_Success; +} + +static int PostLinkFilesInProject() { + SInt32 index; + SInt32 startTime; + SInt32 endTime; + File *file; + FSSpec fss; + + startTime = OS_GetMilliseconds(); + for (index = 0; index < Files_Count(&gTarg->files); index++) { + file = Files_GetFile(&gTarg->files, index); + OS_OSSpec_To_FSSpec(&file->srcfss, &fss); + gTarg->targetinfo->outfile = fss; + gTarg->targetinfo->runfile = fss; + gTarg->targetinfo->symfile = fss; + + if (!SendLinkerRequest(gTarg->postLinker, gTarg->postLinkerDropinFlags, gTarg->targetinfo)) { + return CheckForUserBreak() ? Result_Cancelled : Result_Failed; + } else { + if (CheckForUserBreak()) + return Result_Cancelled; + } + } + endTime = OS_GetMilliseconds(); + + if (optsCmdLine.timeWorking) + CLReport(24, (endTime - startTime) / 1000.0, "compile", "", "", "project"); + + return CheckForUserBreak() ? Result_Cancelled : Result_Success; +} + +int LinkProject() { + SInt32 startTime; + SInt32 endTime; + + startTime = OS_GetMilliseconds(); + if (!SendTargetInfoRequest(gTarg, gTarg->linker, gTarg->linkerDropinFlags)) + return Result_Failed; + if (!SetupTemporaries()) + return Result_Failed; + + if (gTarg->preLinker && optsLinker.callPreLinker && optsCmdLine.state == OptsCmdLineState_3) { + SInt32 subStart; + SInt32 subEnd; + + subStart = OS_GetMilliseconds(); + if (gTarg->preLinkerDropinFlags & dropInExecutableTool) { + if (!ExecuteLinker(gTarg->preLinker, gTarg->preLinkerDropinFlags, NULL, NULL, NULL)) + return Result_Failed; + } else if (!optsCmdLine.dryRun) { + if (!SendLinkerRequest(gTarg->preLinker, gTarg->preLinkerDropinFlags, gTarg->targetinfo)) + return CheckForUserBreak() ? Result_Cancelled : Result_Failed; + } + subEnd = OS_GetMilliseconds(); + + if (optsCmdLine.timeWorking) + CLReport(24, (subEnd - subStart) / 1000.0, "prelink project", "", "", ""); + } + + if (gTarg->linker && optsLinker.callLinker && optsCmdLine.state == OptsCmdLineState_3) { + SInt32 subStart; + SInt32 subEnd; + + subStart = OS_GetMilliseconds(); + if (gTarg->linkerDropinFlags & dropInExecutableTool) { + if (!ExecuteLinker(gTarg->linker, gTarg->linkerDropinFlags, NULL, NULL, NULL)) + return Result_Failed; + } else if (!optsCmdLine.dryRun) { + if (!SendLinkerRequest(gTarg->linker, gTarg->linkerDropinFlags, gTarg->targetinfo)) + return CheckForUserBreak() ? Result_Cancelled : Result_Failed; + } + subEnd = OS_GetMilliseconds(); + + if (optsCmdLine.timeWorking) + CLReport(24, (subEnd - subStart) / 1000.0, "link project", "", "", ""); + } + + if (gTarg->postLinker && optsLinker.callPostLinker && optsCmdLine.state == OptsCmdLineState_3) { + SInt32 subStart; + SInt32 subEnd; + FSSpec fss; + OSSpec outfile; + + subStart = OS_GetMilliseconds(); + if (gTarg->postLinkerDropinFlags & dropInExecutableTool) { + if (!ExecuteLinker(gTarg->postLinker, gTarg->postLinkerDropinFlags, NULL, NULL, NULL)) + return Result_Failed; + } else if (!optsCmdLine.dryRun) { + if (!SendTargetInfoRequest(gTarg, gTarg->linker, gTarg->linkerDropinFlags)) + return Result_Failed; + if (gTarg->targetinfo->outputType == linkOutputFile) + fss = gTarg->targetinfo->outfile; + if (gTarg->targetinfo->outputType != linkOutputNone) { + if (!SendLinkerRequest(gTarg->postLinker, gTarg->postLinkerDropinFlags, gTarg->targetinfo)) + return CheckForUserBreak() ? Result_Cancelled : Result_Failed; + if (!SendTargetInfoRequest(gTarg, gTarg->postLinker, gTarg->postLinkerDropinFlags)) + return Result_Failed; + } + } + subEnd = OS_GetMilliseconds(); + + if (optsCmdLine.timeWorking) + CLReport(24, (subEnd - subStart) / 1000.0, "postlink project", "", "", ""); + + if (!optsLinker.keepLinkerOutput && gTarg->targetinfo->outputType == linkOutputFile) { + if (optsCmdLine.verbose > 1) { + OS_FSSpec_To_OSSpec(&fss, &outfile); + CLReport(19, OS_SpecToString(&outfile, STSbuf, sizeof(STSbuf))); + } + FSpDelete(&fss); + } + } + + if (!DeleteTemporaries()) + return Result_Failed; + + endTime = OS_GetMilliseconds(); + + if (optsCmdLine.timeWorking) + CLReport(24, (endTime - startTime) / 1000.0, "finish link stage", "", "", ""); + + return Result_Success; +} diff --git a/command_line/CmdLine/Src/CLIncludeFileCache.c b/command_line/CmdLine/Src/CLIncludeFileCache.c index e69de29..d479f36 100644 --- a/command_line/CmdLine/Src/CLIncludeFileCache.c +++ b/command_line/CmdLine/Src/CLIncludeFileCache.c @@ -0,0 +1,159 @@ +#include "cmdline.h" + +typedef struct CacheEntry { + struct CacheEntry *next; + struct CacheEntry *prev; + int locked; + int precompiled; + Handle text; + OSSpec spec; + UInt32 size; + UInt32 when; +} CacheEntry; + +enum { + CACHE_SIZE = 0x800000 +}; + +static CacheEntry *cachelist; +static CacheEntry *freelist; +static UInt32 availablecache; + +static CacheEntry *makecacheentry() { + CacheEntry *c = freelist; + if (c) { + freelist = c->next; + return c; + } else { + return xmalloc("include file cache", sizeof(CacheEntry)); + } +} + +static void insertcacheentry(CacheEntry *c) { + if (cachelist) + cachelist->prev = c; + c->next = cachelist; + c->prev = NULL; + cachelist = c; +} + +static void deletecacheentry(CacheEntry *c) { + if (c->next) + c->next->prev = c->prev; + if (c->prev) + c->prev->next = c->next; + else + cachelist = c->next; +} + +void InitializeIncludeCache() { + freelist = NULL; + cachelist = NULL; + availablecache = CACHE_SIZE; +} + +void CleanupIncludeCache() { + CacheEntry *c; + CacheEntry *c1; + + for (c = cachelist; c; c = c1) { + c1 = c->next; + if (c->text) + DisposeHandle(c->text); + xfree(c); + } + + for (c = freelist; c; c = c1) { + c1 = c->next; + xfree(c); + } + + InitializeIncludeCache(); +} + +void CacheIncludeFile(OSSpec *spec, Handle text, Boolean precompiled) { + UInt32 size; + CacheEntry *c; + CacheEntry *lru; + + size = GetHandleSize(text); + if (precompiled) { + lru = NULL; + for (c = cachelist; c; c = c->next) { + if (c->precompiled) { + lru = c; + break; + } + } + if (lru) { + DisposeHandle(lru->text); + lru->text = NULL; + deletecacheentry(lru); + lru->next = freelist; + freelist = lru; + } + } else { + if ((SInt32) size > (SInt32) CACHE_SIZE) { + return; + } else { + while (size > availablecache) { + lru = NULL; + for (c = cachelist; c; c = c->next) { + if (!c->locked && !c->precompiled && (lru == NULL || c->when < lru->when)) + lru = c; + } + + if (lru) { + DisposeHandle(lru->text); + lru->text = NULL; + availablecache += lru->size; + deletecacheentry(lru); + lru->next = freelist; + freelist = lru; + } else { + return; + } + } + } + } + + c = makecacheentry(); + c->locked = 1; + c->precompiled = precompiled; + c->spec = *spec; + c->text = text; + c->size = size; + c->when = OS_GetMilliseconds(); + insertcacheentry(c); + + if (!precompiled) + availablecache -= size; +} + +Handle CachedIncludeFile(OSSpec *spec, Boolean *precompiled) { + CacheEntry *c; + + for (c = cachelist; c; c = c->next) { + if (OS_EqualSpec(&c->spec, spec)) { + c->when = OS_GetMilliseconds(); + *precompiled = c->precompiled; + c->locked++; + return c->text; + } + } + + return NULL; +} + +void FreeIncludeFile(Handle text) { + CacheEntry *c; + + for (c = cachelist; c; c = c->next) { + if (c->text == text) { + c->locked--; + return; + } + } + + DisposeHandle(text); +} diff --git a/command_line/CmdLine/Src/CLLicenses.c b/command_line/CmdLine/Src/CLLicenses.c index e69de29..f264e6c 100644 --- a/command_line/CmdLine/Src/CLLicenses.c +++ b/command_line/CmdLine/Src/CLLicenses.c @@ -0,0 +1,23 @@ +#include "cmdline.h" + +void License_Initialize() { +} + +void License_Terminate() { +} + +SInt32 License_Checkout() { + return 0xD0AD0A; +} + +void License_Refresh() { + +} + +void License_Checkin() { + +} + +void License_AutoCheckin() { + +} diff --git a/command_line/CmdLine/Src/CLLoadAndCache.c b/command_line/CmdLine/Src/CLLoadAndCache.c index e69de29..efc3f63 100644 --- a/command_line/CmdLine/Src/CLLoadAndCache.c +++ b/command_line/CmdLine/Src/CLLoadAndCache.c @@ -0,0 +1,85 @@ +#include "cmdline.h" + +short FixTextHandle(Handle txt) { + char *tptr; + UInt32 tlen; + char *scan; + + HLock(txt); + tptr = *txt; + tlen = GetHandleSize(txt); + + scan = tptr; + while (scan < (tptr + tlen)) { + if (scan[0] == '\r') { + if (scan[1] == '\n') + scan += 2; + else + scan += 1; + } else if (scan[0] == '\n') { + scan[0] = '\r'; + scan++; + } else { + scan++; + } + } + + HUnlock(txt); + return 0; +} + +int LoadAndCacheFile(OSSpec *spec, Handle *texthandle, Boolean *precomp) { + Handle h; + int err; + OSType mactype; + int refnum; + UInt32 ltxtlen; + + if ((*texthandle = CachedIncludeFile(spec, precomp))) + return 0; + + *precomp = !OS_GetMacFileType(spec, &mactype) && mactype != CWFOURCHAR('T','E','X','T'); + *texthandle = NULL; + + err = OS_Open(spec, OSReadOnly, &refnum); + if (err) + return err; + err = OS_GetSize(refnum, <xtlen); + if (err) + return err; + + h = NewHandle(ltxtlen + 1); + if (!h) { + fprintf(stderr, "\n*** Out of memory\n"); + exit(-23); + } + + HLock(h); + err = OS_Read(refnum, *h, <xtlen); + if (err) { + DisposeHandle(h); + OS_Close(refnum); + return err; + } + + OS_Close(refnum); + (*h)[ltxtlen] = 0; + HUnlock(h); + + if (!*precomp) + FixTextHandle(h); + + CacheIncludeFile(spec, h, *precomp); + *texthandle = h; + return 0; +} + +void CopyFileText(Handle src, char **text, SInt32 *textsize) { + *textsize = GetHandleSize(src); + *text = xmalloc(NULL, *textsize); + + HLock(src); + memcpy(*text, *src, *textsize); + *textsize -= 1; + HUnlock(src); +} diff --git a/command_line/CmdLine/Src/CLMain.c b/command_line/CmdLine/Src/CLMain.c index f8247c4..6e041ad 100644 --- a/command_line/CmdLine/Src/CLMain.c +++ b/command_line/CmdLine/Src/CLMain.c @@ -1,10 +1,10 @@ -#include "mwcc_decomp.h" +#include "cmdline.h" jmp_buf exit_program; int numPlugins; CLPluginInfo *pluginInfo; int numPanels; -char **panelNames; +const char **panelNames; CWCommandLineArgs *panel_args; CWCommandLineArgs *plugin_args; Project mainProj; @@ -18,14 +18,14 @@ char cmdline_build_date[32]; char cmdline_build_time[32]; Project *gProj = &mainProj; -static SInt16 CLT_dummymain(void *context) { +static CWPLUGIN_ENTRY(CLT_dummymain)(CWPluginContext) { return 0; } -static SInt16 CLT_GetDropInFlags(const DropInFlags **flags, SInt32 *flagsSize) { +static CWPLUGIN_ENTRY(CLT_GetDropInFlags)(const DropInFlags **flags, SInt32 *flagsSize) { static const DropInFlags sFlags = { kCurrentDropInFlagsVersion, - CWFOURCHAR('c','l','d','r'), + CWDROPINDRIVERTYPE, 7, 0, 0, @@ -36,19 +36,19 @@ static SInt16 CLT_GetDropInFlags(const DropInFlags **flags, SInt32 *flagsSize) { return 0; } -static SInt16 CLT_GetDropInName(const char **dropinName) { +static CWPLUGIN_ENTRY(CLT_GetDropInName)(const char **dropinName) { static const char *sDropInName = "Command-Line Driver"; *dropinName = sDropInName; return 0; } -static SInt16 CLT_GetDisplayName(const char **displayName) { +static CWPLUGIN_ENTRY(CLT_GetDisplayName)(const char **displayName) { static const char *sDisplayName = "Command-Line Driver"; *displayName = sDisplayName; return 0; } -static SInt16 CLT_GetPanelList(const CWPanelList **panelList) { +static CWPLUGIN_ENTRY(CLT_GetPanelList)(const CWPanelList **panelList) { static const char *sPanelNames[4]; static CWPanelList sPanelList = { kCurrentCWPanelListVersion, @@ -70,7 +70,7 @@ static SInt16 CLT_GetPanelList(const CWPanelList **panelList) { return 0; } -static SInt16 CLT_GetTargetList(const CWTargetList **targetList) { +static CWPLUGIN_ENTRY(CLT_GetTargetList)(const CWTargetList **targetList) { static FourCharCode sCPU = targetCPUAny; static FourCharCode sOS = targetOSAny; static CWTargetList sTargetList = { @@ -84,7 +84,7 @@ static SInt16 CLT_GetTargetList(const CWTargetList **targetList) { return 0; } -static SInt16 CLT_GetVersionInfo(const VersionInfo **versioninfo) { +static CWPLUGIN_ENTRY(CLT_GetVersionInfo)(const VersionInfo **versioninfo) { static const VersionInfo vi = { 3, 0, 0, 0 }; @@ -92,7 +92,7 @@ static SInt16 CLT_GetVersionInfo(const VersionInfo **versioninfo) { return 0; } -static SInt16 CLT_GetFileTypeMappings(const OSFileTypeMappingList **mappinglist) { +static CWPLUGIN_ENTRY(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} @@ -278,12 +278,6 @@ int Main_Terminate(int exitcode) { return exitcode; } -enum { - ResultCode_0 = 0, - ResultCode_1 = 1, - ResultCode_2 = 2 -}; - static int Main_ParseCommandLine() { Plugin *parser; CWCommandLineArgs myargs; @@ -308,7 +302,7 @@ static int Main_ParseCommandLine() { myargs.envp = 0; if (!SendParserRequest(parser, gTarg, &myargs, gTarg->cpu, gTarg->os, numPlugins, pluginInfo, numPanels, panelNames, plugin_args, panel_args, cmdline_build_date, cmdline_build_time, Plugin_GetToolVersionInfo())) { - return CheckForUserBreak() ? ResultCode_2 : ResultCode_1; + return CheckForUserBreak() ? Result_Cancelled : Result_Failed; } if (clState.pluginDebug) { @@ -340,7 +334,7 @@ static int Main_ParseCommandLine() { } } - return ResultCode_0; + return Result_Success; } static int Main_SetupParamBlock() { @@ -622,7 +616,7 @@ static int Main_SetupContext() { CLFatalError("The linker plugin was not found!"); } - gTarg->linkmodel = 0; + gTarg->linkmodel = LinkModel0; Framework_GetEnvInfo(); return 1; diff --git a/command_line/CmdLine/Src/CLPluginAPI.c b/command_line/CmdLine/Src/CLPluginAPI.c deleted file mode 100644 index e69de29..0000000 diff --git a/command_line/CmdLine/Src/CLPluginRequests.cpp b/command_line/CmdLine/Src/CLPluginRequests.cpp new file mode 100644 index 0000000..9de50ba --- /dev/null +++ b/command_line/CmdLine/Src/CLPluginRequests.cpp @@ -0,0 +1,348 @@ +#include "cmdline.h" +#include "plugin_internal.h" + +extern "C" { +static CWResult CallPlugin(Plugin *plugin) { + return Plugin_Call(plugin, plugin->context); +} +} + +static void SetupPluginContext(Plugin *plugin, CWResult request) { + OSSpec spec; + shellContextType *sc; + OSPathSpec cwd; + + sc = static_cast(plugin->context->shellContext); + sc->plugin = plugin; + sc->systemAccessPathsChanged = 1; + sc->userAccessPathsChanged = 1; + plugin->context->request = request; + plugin->context->apiVersion = 12; + plugin->context->pluginStorage = NULL; + + OS_MakeFileSpec("Project.mcp", &spec); + OS_OSSpec_To_FSSpec(&spec, &plugin->context->projectFile); + if (gTarg) { + OS_MakeSpecWithPath(&gTarg->outputDirectory, NULL, 0, &spec); + OS_OSSpec_To_FSSpec(&spec, &plugin->context->outputFileDirectory); + } else { + OS_GetCWD(&cwd); + OS_MakeSpecWithPath(&cwd, NULL, 0, &spec); + OS_OSSpec_To_FSSpec(&spec, &plugin->context->outputFileDirectory); + } + + plugin->context->shellSignature = CWFOURCHAR('C','W','I','E'); + plugin->context->pluginType = Plugin_GetDropInFlags(plugin)->dropintype; + + if (gTarg) + plugin->context->numFiles = Files_Count(&gTarg->files); + else + plugin->context->numFiles = 0; + + if (gTarg) + plugin->context->numOverlayGroups = Overlays_CountGroups(&gTarg->linkage.overlays); + else + plugin->context->numOverlayGroups = 0; + + plugin->context->pluginOSError = noErr; + plugin->context->callbackOSError = noErr; + plugin->context->accessPathList = NULL; +} + +static void DestroyPluginContext(CWPluginContext context) { +} + +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, + const ToolVersionInfo *build_tool +) { + int result; + CWParserContext *pc; + + SetupPluginContext(plugin, 1); + + pc = static_cast(plugin->context); + pc->build_date = build_date; + pc->build_time = build_time; + pc->build_tool = build_tool; + pc->args = args; + pc->cpu = cpu; + pc->os = os; + pc->numPlugins = numPlugins; + pc->plugins = pluginInfo; + pc->numPanels = numPanels; + pc->panelNames = panelNames; + pc->plugin_args = plugin_args; + pc->panel_args = panel_args; + + if (CallPlugin(plugin) != cwNoErr) + return 0; + if (!SendTargetInfoRequest(target, target->linker, target->linkerDropinFlags)) + return 0; + + target->linkmodel = + (target->targetinfo->linkType == exelinkageSegmented) ? LinkModel1 : + (target->targetinfo->linkType == exelinkageOverlay1) ? LinkModel2 : + LinkModel0; + + if (!Plugin_VerifyPanels(plugin)) + return 0; + + SetupPluginContext(plugin, 2); + pc->args = args; + pc->cpu = cpu; + pc->os = os; + pc->numPlugins = numPlugins; + pc->plugins = pluginInfo; + pc->numPanels = numPanels; + pc->panelNames = panelNames; + pc->plugin_args = plugin_args; + pc->panel_args = panel_args; + + result = CallPlugin(plugin); + return (result == cwNoErr); +} + +Boolean SendCompilerRequest(Plugin *plugin, File *file, SInt16 stage) { + CWResult result; + CWCompilerLinkerContext *cc; + Boolean precompiling; + SInt16 type; + OSType mactype; + const char *pn; + int v; + + if (stage & CmdLineStageMask_Cg) { + if (optsCompiler.forcePrecompile == 1) + precompiling = 1; + else if (optsCompiler.forcePrecompile == 2) + precompiling = 0; + else + precompiling = !!(file->mappingflags & kPrecompile); + } else { + precompiling = 0; + } + + if (optsCmdLine.verbose) { + pn = Plugin_GetDropInName(plugin); + v = optsCmdLine.verbose > 1; + if (stage & CmdLineStageMask_Pp) { + CLReport(CLStr34 + v, file->srcfilename, pn); + } else if (stage & CmdLineStageMask_Cg) { + if (precompiling) + CLReport(CLStr32 + v, file->srcfilename, pn); + else + CLReport(CLStr30 + v, file->srcfilename, pn); + } else if (stage & CmdLineStageMask_Dp) { + CLReport(CLStr36 + v, file->srcfilename, pn); + } else if (stage & CmdLineStageMask_Ds) { + CLReport(CLStr46 + v, file->srcfilename, pn); + } else if (!stage) { + CLReport(CLStr48 + v, file->srcfilename, pn); + } + } + + if (!Plugin_VerifyPanels(plugin)) + return 0; + + SetupPluginContext(plugin, reqCompile); + cc = static_cast(plugin->context); + *cc->targetinfo = *gTarg->targetinfo; + + OS_OSSpec_To_FSSpec(&file->srcfss, &cc->sourcefile); + if (!OS_GetMacFileType(&file->srcfss, &mactype) && mactype == CWFOURCHAR('T','E','X','T')) { + if (UCBGetFileText(cc, &cc->sourcefile, &cc->sourcetext, &cc->sourcetextsize, &type) != cwNoErr) + return 0; + } else { + cc->sourcetext = NULL; + cc->sourcetextsize = 0; + } + + cc->whichfile = file->filenum; + cc->debuginfo = optsCmdLine.debugInfo; + cc->recordbrowseinfo = file->recordbrowseinfo; + cc->fileID = file->browseFileID; + memcpy(&cc->browseoptions, file->browseoptions, sizeof(cc->browseoptions)); + + if (stage & (CmdLineStageMask_Pp | CmdLineStageMask_Dp)) { + if (stage & CmdLineStageMask_Pp) + cc->preprocess = 1; + else + cc->preprocess = 2; + } else { + cc->preprocess = 0; + } + + if ((stage & CmdLineStageMask_Cg) && precompiling) { + cc->precompile = 1; + cc->autoprecompile = 1; + } else { + cc->precompile = 0; + cc->autoprecompile = 0; + } + + if (!(stage & (CmdLineStageMask_Pp | CmdLineStageMask_Cg | CmdLineStageMask_Dp))) { + cc->preprocess = 2; + cc->precompile = 2; + } + + result = CallPlugin(plugin); + + if (cc->sourcetext) { + UCBReleaseFileText(cc, cc->sourcetext); + cc->sourcetext = NULL; + cc->sourcetextsize = 0; + } + + return (result == cwNoErr); +} + +Boolean SendTargetInfoRequest(Target *targ, Plugin *linker, SInt32 dropinflags) { + CWResult result; + CWCompilerLinkerContext *cc; + OSSpec spec; + FSSpec fss; + + if (linker && !(dropinflags & dropInExecutableTool)) { + if (optsCmdLine.verbose > 1) + CLReport(CLStr50, Plugin_GetDropInName(linker)); +#line 298 + OPTION_ASSERT(Plugin_GetPluginType(linker) == CWDROPINLINKERTYPE); + + if (!Plugin_VerifyPanels(linker)) + return 0; + + SetupPluginContext(linker, reqTargetInfo); + cc = static_cast(linker->context); + *cc->targetinfo = *targ->targetinfo; + result = CallPlugin(linker); + *targ->targetinfo = *cc->targetinfo; + } else { + OS_MakeFileSpec("(unknown file)", &spec); + OS_OSSpec_To_FSSpec(&spec, &fss); + targ->targetinfo->outputType = linkOutputFile; + targ->targetinfo->outfile = fss; + targ->targetinfo->symfile = fss; + targ->targetinfo->runfile = fss; + targ->targetinfo->linkType = exelinkageFlat; + targ->targetinfo->canRun = 0; + targ->targetinfo->canDebug = 0; + targ->targetinfo->targetCPU = targ->cpu; + targ->targetinfo->targetOS = targ->os; + targ->targetinfo->outfileCreator = CWFOURCHAR('C','W','I','E'); + targ->targetinfo->outfileType = CWFOURCHAR('A','P','P','L'); + targ->targetinfo->debuggerCreator = CWFOURCHAR('M','W','D','B'); + targ->targetinfo->runHelperCreator = CWFOURCHAR('?','?','?','?'); + result = cwNoErr; + } + + return (result == cwNoErr); +} + +Boolean SendLinkerRequest(Plugin *plugin, SInt32 dropinflags, CWTargetInfo *targetInfo) { + CWResult result; + CWCompilerLinkerContext *cc; + const char *nm; + int v; + + if (optsCmdLine.verbose) { + nm = Plugin_GetDropInName(plugin); + v = optsCmdLine.verbose > 1; + if (dropinflags & isPostLinker) + CLReport(CLStr44 + v, nm); + else if (dropinflags & isPreLinker) + CLReport(CLStr42 + v, nm); + else + CLReport(CLStr40 + v, nm); + } + + if (!Plugin_VerifyPanels(plugin)) + return 0; + + SetupPluginContext(plugin, reqLink); + cc = static_cast(plugin->context); + *cc->targetinfo = *targetInfo; + result = CallPlugin(plugin); + *targetInfo = *cc->targetinfo; + + return (result == cwNoErr); +} + +Boolean SendDisassemblerRequest(Plugin *linker, File *file) { + CWResult result; + Plugin *plugin; + + if (linker == NULL) + plugin = file->compiler; + else + plugin = linker; + + if (optsCmdLine.verbose) + CLReport((optsCmdLine.verbose > 1) + CLStr46, file->srcfilename, Plugin_GetDropInName(linker)); + + if (!Plugin_VerifyPanels(plugin)) + return 0; + + if (!linker) { + SetupPluginContext(plugin, reqCompDisassemble); + static_cast(plugin->context)->whichfile = file->filenum; + result = CallPlugin(plugin); + } else { + SetupPluginContext(plugin, reqDisassemble); + static_cast(plugin->context)->whichfile = file->filenum; + result = CallPlugin(plugin); + } + + return (result == cwNoErr); +} + +Boolean SendInitOrTermRequest(Plugin *plugin, Boolean reqIsInitialize) { + CWResult result; + OSType ty; + + result = cwErrRequestFailed; + + if (plugin) { + if (clState.pluginDebug) + CLReport(reqIsInitialize ? CLStr51 : CLStr52, Plugin_GetDropInName(plugin)); + + if (reqIsInitialize) { + ty = Plugin_GetDropInFlags(plugin)->dropintype; + if (ty == CWDROPINDRIVERTYPE) { + plugin->context = new CWPluginPrivateContext(ty); + } else if (ty == CWDROPINPARSERTYPE) { + plugin->context = new CWParserContext(); + } else if (ty == CWDROPINCOMPILERTYPE || ty == CWDROPINLINKERTYPE) { + plugin->context = new CWCompilerLinkerContext(); + } else { + plugin->context = NULL; + } + + plugin->context->shellContext = new shellContextType; + } + + if (plugin->context) { + SetupPluginContext(plugin, reqIsInitialize ? reqInitialize : reqTerminate); + result = CallPlugin(plugin); + } else { + result = cwNoErr; + } + + if (!reqIsInitialize) + License_AutoCheckin(); + } + + return (result == cwNoErr); +} diff --git a/command_line/CmdLine/Src/CLPrefs.c b/command_line/CmdLine/Src/CLPrefs.c index e69de29..7aaa28a 100644 --- a/command_line/CmdLine/Src/CLPrefs.c +++ b/command_line/CmdLine/Src/CLPrefs.c @@ -0,0 +1,123 @@ +#include "cmdline.h" + +struct PrefPanel { + char *name; + Handle data; + Handle workHandle; + PrefPanel *next; +}; + +static PrefPanel *panellist; + +PrefPanel *PrefPanel_New(const char *name, void *initdata, SInt32 initdatasize) { + PrefPanel *pnl; + pnl = xmalloc(NULL, sizeof(PrefPanel)); + if (!pnl) + return pnl; + + pnl->name = xstrdup(name); + pnl->data = NewHandle(initdatasize); + if (!pnl->data) { + fprintf(stderr, "\n*** Out of memory\n"); + exit(-23); + } + + pnl->workHandle = NULL; + + HLock(pnl->data); + if (initdata) + memcpy(*pnl->data, initdata, initdatasize); + else + memset(*pnl->data, 0, initdatasize); + HUnlock(pnl->data); + + pnl->next = NULL; + return pnl; +} + +Handle PrefPanel_GetHandle(PrefPanel *panel) { + UInt32 len = GetHandleSize(panel->data); + if (!panel->workHandle || !*panel->workHandle) + panel->workHandle = NewHandle(len); + else + SetHandleSize(panel->workHandle, len); + +#line 60 + OPTION_ASSERT(MemError()==noErr); + + HLock(panel->data); + HLock(panel->workHandle); + memcpy(*panel->workHandle, *panel->data, len); + HUnlock(panel->workHandle); + HUnlock(panel->data); + return panel->workHandle; +} + +int PrefPanel_PutHandle(PrefPanel *panel, Handle data) { + UInt32 len = GetHandleSize(data); + if (data != panel->workHandle) { + if (!panel->workHandle) + panel->workHandle = NewHandle(len); + else + SetHandleSize(panel->workHandle, len); + if (MemError() != noErr) + return 0; + + HLock(panel->workHandle); + HLock(data); + memcpy(*panel->workHandle, *data, len); + HUnlock(data); + HUnlock(panel->workHandle); + } + + HLock(panel->data); + HLock(panel->workHandle); + memcpy(*panel->data, *panel->workHandle, len); + HUnlock(panel->workHandle); + HUnlock(panel->data); + return 1; +} + +void Prefs_Initialize() { + panellist = NULL; +} + +void Prefs_Terminate() { + PrefPanel *scan; + PrefPanel *next; + + for (scan = panellist; scan; scan = next) { + xfree(scan->name); + DisposeHandle(scan->data); + next = scan->next; + xfree(scan); + } +} + +Boolean Prefs_AddPanel(PrefPanel *panel) { + PrefPanel **scan; + + for (scan = &panellist; *scan; scan = &(*scan)->next) { + if (!strcmp((*scan)->name, panel->name)) { + CLReportError(90, panel->name); + return 0; + } + } + + if (clState.pluginDebug) + CLPrint("Defining/adding pref panel '%s'\n", panel->name); + + *scan = panel; + return 1; +} + +PrefPanel *Prefs_FindPanel(const char *name) { + PrefPanel *scan; + + for (scan = panellist; scan; scan = scan->next) { + if (!ustrcmp(scan->name, name)) + break; + } + + return scan; +} diff --git a/command_line/CmdLine/Src/CLTarg.c b/command_line/CmdLine/Src/CLTarg.c index e69de29..a3f4389 100644 --- a/command_line/CmdLine/Src/CLTarg.c +++ b/command_line/CmdLine/Src/CLTarg.c @@ -0,0 +1,55 @@ +#include "cmdline.h" + +Target *Target_New(const char *name, OSType cpu, OSType os, OSType lang) { + Target *targ; + + targ = xcalloc("target", sizeof(Target)); + + strncpy(targ->targetName, name, sizeof(targ->targetName)); + targ->targetinfo = xcalloc("target info", sizeof(CWTargetInfo)); + targ->cpu = cpu; + targ->os = os; + targ->lang = lang; + + OS_GetCWD(&targ->outputDirectory); + +#line 25 + OPTION_ASSERT(Segments_Initialize(&targ->linkage.segs)); +#line 28 + OPTION_ASSERT(Overlays_Initialize(&targ->linkage.overlays)); +#line 35 + OPTION_ASSERT(Files_Initialize(&targ->files) && Files_Initialize(&targ->pchs) && VFiles_Initialize(&targ->virtualFiles) && + Paths_Initialize(&targ->sysPaths) && Paths_Initialize(&targ->userPaths) && Incls_Initialize(&targ->incls, targ)); + + return targ; +} + +void Target_Free(Target *targ) { + Segments_Terminate(&targ->linkage.segs); + Overlays_Terminate(&targ->linkage.overlays); + Paths_Terminate(&targ->sysPaths); + Paths_Terminate(&targ->userPaths); + Files_Terminate(&targ->files); + Files_Terminate(&targ->pchs); + VFiles_Terminate(&targ->virtualFiles); + Incls_Terminate(&targ->incls); + xfree(targ); +} + +void Targets_Term(Target *list) { + Target *scan; + Target *next; + + for (scan = list; scan; scan = next) { + next = scan->next; + Target_Free(scan); + } +} + +void Target_Add(Target **list, Target *targ) { + Target **scan; + + for (scan = list; *scan; scan = &(*scan)->next) {} + + *scan = targ; +} diff --git a/command_line/CmdLine/Src/CLToolExec.c b/command_line/CmdLine/Src/CLToolExec.c index e69de29..80e3a7c 100644 --- a/command_line/CmdLine/Src/CLToolExec.c +++ b/command_line/CmdLine/Src/CLToolExec.c @@ -0,0 +1,243 @@ +#include "cmdline.h" + +extern char STSbuf[256]; +extern PCmdLine pCmdLine; + +void AppendArgumentList(int *argc, char ***argv, const char *str) { + *argv = xrealloc("command-line arguments", *argv, sizeof(char *) * (*argc + 2)); + (*argv)[(*argc)++] = xstrdup(str); +} + +static int CopyArgumentList(int argc, char **argv, int *Argc, char ***Argv) { + int x; + int y; + + y = Argc ? *Argc : 0; + *Argv = xrealloc("command-line arguments", *Argv, sizeof(char *) * (y + argc + 1)); + + if (argv) { + for (x = 0; x < argc; x++) { + (*Argv)[y++] = xstrdup(argv[x]); + } + } + (*Argv)[y] = NULL; + if (Argc) + *Argc = y; + + return 1; +} + +static int FreeArgumentList(char **argv) { + char **scan; + for (scan = argv; *scan; scan++) + xfree(*scan); + xfree(argv); + return 1; +} + +static int SetupLinkerCommandLine(SInt32 dropinflags, File *file, CWCommandLineArgs *args) { + CWCommandLineArgs *baseargs; + int x; + SInt32 idx; + OSSpec spec; + + for (x = 0; x < numPlugins; x++) { + if (pluginInfo[x].plugintype == CWDROPINLINKERTYPE && ((dropinflags & (isPostLinker | isPreLinker)) == (pluginInfo[x].dropinflags & (isPostLinker | isPreLinker)))) + break; + } + +#line 89 + OPTION_ASSERT(x < numPlugins); + + args->argc = 1; + args->argv = xmalloc("command-line arguments", 2 * sizeof(char *)); + Main_PassSpecialArgs(&args->argc, &args->argv); + + baseargs = &plugin_args[x]; + CopyArgumentList(baseargs->argc - 1, baseargs->argv + 1, &args->argc, &args->argv); + + x = 0; + if (baseargs->envp) { + while (baseargs->envp[x]) + x++; + } + args->envp = NULL; + CopyArgumentList(x, baseargs->envp, NULL, &args->envp); + + if (!file && !(dropinflags & isPostLinker)) { + for (idx = 0; idx < Files_Count(&gTarg->files); idx++) { + file = Files_GetFile(&gTarg->files, idx); + if (file->sourceUsage & CmdLineStageMask_Cg) { + AppendArgumentList(&args->argc, &args->argv, file->srcfilename); + } + if (file->objectUsage & CmdLineStageMask_Cg) { + if (GetOutputFile(file, CmdLineStageMask_Cg) != 0 && StoreObjectFile(file)) + AppendArgumentList(&args->argc, &args->argv, OS_SpecToString(&file->outfss, STSbuf, sizeof(STSbuf))); + else + return 0; + } + } + } else if (file) { + args->argv = xrealloc("command-line arguments", args->argv, sizeof(char *) * (args->argc + 1)); + if (file->sourceUsage & CmdLineStageMask_Cg) { + AppendArgumentList(&args->argc, &args->argv, file->srcfilename); + } + if (file->objectUsage & CmdLineStageMask_Cg) { + if (GetOutputFile(file, CmdLineStageMask_Cg) != 0 && StoreObjectFile(file)) { + AppendArgumentList(&args->argc, &args->argv, OS_SpecToString(&file->outfss, STSbuf, sizeof(STSbuf))); + } + } + if ((pCmdLine.toDisk & CmdLineStageMask_Ds) && (file->objectUsage & CmdLineStageMask_Pp) && file->outfilename[0] && GetOutputFile(file, CmdLineStageMask_Ds)) { + AppendArgumentList(&args->argc, &args->argv, "-o"); + AppendArgumentList(&args->argc, &args->argv, OS_SpecToString(&file->outfss, STSbuf, sizeof(STSbuf))); + } + } else if (dropinflags & isPostLinker) { + OS_FSSpec_To_OSSpec(&gTarg->targetinfo->outfile, &spec); + AppendArgumentList(&args->argc, &args->argv, OS_SpecToString(&spec, STSbuf, sizeof(STSbuf))); + } + + args->argv[args->argc] = NULL; + return 1; +} + +int SetupTemporaries() { + SInt32 idx; + File *file; + + for (idx = 0; idx < Files_Count(&gTarg->files); idx++) { + file = Files_GetFile(&gTarg->files, idx); + if ((file->objectUsage & CmdLineStageMask_Cg) && !(optsCmdLine.toDisk & CmdLineStageMask_Cg) && !(file->writeToDisk & CmdLineStageMask_Cg)) { + if (!optsCompiler.keepObjects) + file->tempOnDisk |= CmdLineStageMask_Cg; + else + file->writeToDisk |= CmdLineStageMask_Cg; + } + } + + return 1; +} + +int DeleteTemporaries() { + SInt32 idx; + File *file; + + for (idx = 0; idx < Files_Count(&gTarg->files); idx++) { + file = Files_GetFile(&gTarg->files, idx); + if ((file->objectUsage & CmdLineStageMask_Cg) && (file->tempOnDisk & CmdLineStageMask_Cg) && (file->wroteToDisk & CmdLineStageMask_Cg)) { + GetOutputFile(file, CmdLineStageMask_Cg); + if (optsCmdLine.verbose > 1) + CLReport(19, OS_SpecToString(&file->outfss, STSbuf, sizeof(STSbuf))); + OS_Delete(&file->outfss); + file->tempOnDisk &= ~CmdLineStageMask_Cg; + file->wroteToDisk &= ~CmdLineStageMask_Cg; + } + } + + return 1; +} + +int ExecuteLinker(Plugin *plugin, SInt32 dropinflags, File *file, char *stdoutfile, char *stderrfile) { + char cname[64]; + const char *linkername; + OSSpec linkerspec; + CWCommandLineArgs args; + int exitcode; + int execerr; + const char *linkertype; + int ret; + char *ptr; + char *ptr2; + int x; + + // TODO rename this flag to isExecutableTool +#line 269 + OPTION_ASSERT(dropinflags & dropInExecutableTool); + + args.argc = 0; + args.argv = args.envp = NULL; + + if (dropinflags & isPreLinker) + linkertype = "pre-linker"; + else if (dropinflags & isPostLinker) + linkertype = "post-linker"; + else + linkertype = "linker"; + + linkername = Plugin_GetDropInName(plugin); + if (!(dropinflags & (isPreLinker | isPostLinker)) && optsCompiler.linkerName[0]) + linkername = optsCompiler.linkerName; + + if (OS_FindProgram(linkername, &linkerspec)) { + strcpy(cname, clState.programName); + + for (ptr = cname; *ptr; ptr++) + *ptr = tolower(*ptr); + + if ((ptr = strstr(cname, "cc")) || (ptr = strstr(cname, "pas")) || (ptr = strstr(cname, "asm"))) { + if (ptr[0] != 'c') { + memmove(ptr + 2, ptr + 3, strlen(ptr) - 3); + ptr[strlen(ptr) - 1] = 0; + } + ptr[0] = 'l'; + ptr[1] = 'd'; + } else { + if ((ptr = strstr(cname, "mwc"))) { + // this ptr2 seems redundant, but it's needed to generate the same code + ptr2 = ptr + 2; + memmove(ptr2 + 3, ptr2, strlen(ptr2)); + memcpy(ptr + 2, "Link", 4); + } + } + + if (!OS_FindProgram(cname, &linkerspec)) { + ptr = cname; + if (optsCompiler.linkerName[0]) { + CLReportWarning(66, linkertype, optsCompiler.linkerName); + CLReport(65, ptr, clState.programName); + } else if (optsCmdLine.verbose) { + CLReport(65, ptr, clState.programName); + } + } else { + CLReportError(66, linkertype, linkername); + return 0; + } + } + + ret = 1; + SetupLinkerCommandLine(dropinflags, file, &args); + args.argv[0] = xstrdup(OS_SpecToString(&linkerspec, STSbuf, sizeof(STSbuf))); + args.argv[args.argc] = 0; + + if (optsCmdLine.verbose || optsCmdLine.dryRun) { + CLPrint("\nCommand line:\n"); + for (x = 0; x < args.argc && args.argv[x]; x++) { + if (strchr(args.argv[x], ' ')) + CLPrint("\"%s\" ", args.argv[x]); + else + CLPrint("%s ", args.argv[x]); + } + CLPrint("\n\n"); + } + + fflush(stdout); + fflush(stderr); + + if (optsCmdLine.verbose) + CLReport(67, linkertype, OS_SpecToString(&linkerspec, STSbuf, sizeof(STSbuf))); + + if (!optsCmdLine.dryRun) { + execerr = OS_Execute(&linkerspec, args.argv, args.envp, stdoutfile, stderrfile, &exitcode); + if (execerr) { + CLReportError(68, linkertype, args.argv[0], OS_GetErrText(execerr)); + ret = 0; + } else if (exitcode) { + CLReportError(69 /*nice*/, linkertype, args.argv[0], exitcode); + ret = 0; + } + } + + FreeArgumentList(args.argv); + FreeArgumentList(args.envp); + + return ret; +} diff --git a/command_line/CmdLine/Src/CLWriteObjectFile.c b/command_line/CmdLine/Src/CLWriteObjectFile.c index e69de29..6e92114 100644 --- a/command_line/CmdLine/Src/CLWriteObjectFile.c +++ b/command_line/CmdLine/Src/CLWriteObjectFile.c @@ -0,0 +1,44 @@ +#include "cmdline.h" + +extern char STSbuf[256]; + +int WriteObjectFile(File *file, OSType maccreator, OSType mactype) { + FSSpec srcfss; + FSSpec outfss; + +#line 22 + OPTION_ASSERT(file->objectdata && file->compiler); + + OS_OSSpec_To_FSSpec(&file->outfss, &outfss); + OS_OSSpec_To_FSSpec(&file->srcfss, &srcfss); + + if (optsCmdLine.verbose) { + CLReport(16, + (file->tempOnDisk & CmdLineStageMask_Cg) ? "temporary " : "", + OS_SpecToStringRelative(&file->outfss, NULL, STSbuf, sizeof(STSbuf))); + } + + if (!Plugin_CL_WriteObjectFile(file->compiler, &srcfss, &outfss, maccreator, mactype, file->objectdata)) + return 0; + else + return 1; +} + +int WriteBrowseData(File *file, OSType maccreator, OSType mactype) { + OSHandle browsehandle; + OSSpec outfss; + const CWObjectFlags *cof; + + cof = Plugin_CL_GetObjectFlags(file->compiler); + outfss = file->outfss; + + OS_NameSpecSetExtension(&outfss.name, optsCompiler.brsFileExt[0] ? optsCompiler.brsFileExt : cof->brsFileExt); + if (optsCmdLine.verbose) { + CLReport(17, OS_SpecToStringRelative(&outfss, NULL, STSbuf, sizeof(STSbuf))); + } + + if (!Browser_PackBrowseFile(file->browsedata, &clState.browseTableHandle, &browsehandle)) + return 0; + + return WriteBinaryHandleToFile(&outfss, maccreator, mactype, &browsehandle) != 0; +} diff --git a/command_line/CmdLine/Src/Callbacks/CLCompilerLinkerDropin_V10.cpp b/command_line/CmdLine/Src/Callbacks/CLCompilerLinkerDropin_V10.cpp index 5861e94..070bc07 100644 --- a/command_line/CmdLine/Src/Callbacks/CLCompilerLinkerDropin_V10.cpp +++ b/command_line/CmdLine/Src/Callbacks/CLCompilerLinkerDropin_V10.cpp @@ -1,27 +1,636 @@ -/** - 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 -*/ +#include "cmdline.h" +#include "plugin_internal.h" + +extern char STSbuf[256]; + +CWResult UCBCachePrecompiledHeader(CWPluginContext context, const CWFileSpec *filespec, CWMemHandle pchhandle) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBCachePrecompiledHeader"); + + OSSpec spec; + Handle handle; + OS_FSSpec_To_OSSpec(filespec, &spec); + UCBSecretDetachHandle(context, pchhandle, &handle); + CacheIncludeFile(&spec, handle, 1); + return cwNoErr; +} + +CWResult UCBLoadObjectData(CWPluginContext context, SInt32 whichfile, CWMemHandle *objectdata) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBLoadObjectData"); + + File *file = Files_GetFile(&gTarg->files, whichfile); + if (!file) + return cwErrUnknownFile; + + if (file->objectdata) { + UCBSecretAttachHandle(context, file->objectdata, objectdata); + return cwNoErr; + } else { + return cwErrRequestFailed; + } +} + +CWResult UCBStoreObjectData(CWPluginContext context, SInt32 whichfile, CWObjectData *object) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBStoreObjectData"); + + if (CheckForUserBreak()) + return cwErrUserCanceled; + + File *filedata = Files_GetFile(&gTarg->files, whichfile); + if (!filedata) + return cwErrUnknownFile; + + if (!object->objectfile) { + Handle objecthand; + Handle browsehand; + UCBSecretDetachHandle(context, object->objectdata, &objecthand); + UCBSecretDetachHandle(context, object->browsedata, &browsehand); + filedata->objectdata = objecthand; + filedata->browsedata = browsehand; + UCBSecretAttachHandle(context, objecthand, &object->objectdata); + UCBSecretAttachHandle(context, browsehand, &object->browsedata); + } else { + if (filedata->outfileowner && filedata->outfileowner != CmdLineStageMask_Cg) { +#line 240 + DO_INTERNAL_ERROR("Cannot store object file spec for '%s'\n", filedata->srcfilename); + } + OS_FSSpec_To_OSSpec(object->objectfile, &filedata->outfss); + filedata->wroteToDisk |= CmdLineStageMask_Cg; + } + + filedata->codesize = object->codesize; + filedata->udatasize = object->udatasize; + filedata->idatasize = object->idatasize; + filedata->compiledlines = object->compiledlines; + if (filedata->dropinflags & kGeneratesrsrcs) + filedata->hasresources = 1; + else + filedata->hasobjectcode = 1; + filedata->recompileDependents = object->dependencyCount && object->interfaceChanged; + OS_GetTime(&filedata->outmoddate); + if (object->reserved1) + filedata->filetype = object->reserved1; + + if (object->reserved2) { + char *newname = reinterpret_cast(object->reserved2); + CWFileInfo fi; + if (OS_MakeSpec(newname, &filedata->srcfss, NULL) || OS_Status(&filedata->srcfss)) { + fi.fullsearch = 1; + fi.dependencyType = cwNoDependency; + fi.isdependentoffile = -1; + fi.suppressload = 1; + if (UCBFindAndLoadFile(context, newname, &fi) == cwNoErr) { + OS_FSSpec_To_OSSpec(&fi.filespec, &filedata->srcfss); + } else { + char *fnptr = OS_GetFileNamePtr(newname); + if (fnptr != newname) { + fi.fullsearch = 1; + fi.dependencyType = cwNoDependency; + fi.isdependentoffile = -1; + fi.suppressload = 1; + if (UCBFindAndLoadFile(context, fnptr, &fi) == cwNoErr) { + OS_FSSpec_To_OSSpec(&fi.filespec, &filedata->srcfss); + } + } + } + } + } + + return cwNoErr; +} + +CWResult UCBFreeObjectData(CWPluginContext context, SInt32 whichfile, CWMemHandle objectdata) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBFreeObjectData"); + + File *file = Files_GetFile(&gTarg->files, whichfile); + if (!file) + return cwErrUnknownFile; + + if (file->objectdata) { + DisposeHandle(file->objectdata); + file->objectdata = NULL; + return cwNoErr; + } else { + return cwErrInvalidParameter; + } +} + +CWResult UCBDisplayLines(CWPluginContext context, SInt32 nlines) { + ShowWorking(12); + + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBDisplayLines"); + + if (CheckForUserBreak()) + return cwErrUserCanceled; + else + return cwNoErr; +} + +CWResult UCBBeginSubCompile(CWPluginContext context, SInt32 whichfile, CWPluginContext *subContext) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBBeginSubCompile"); + +#line 372 + DO_INTERNAL_ERROR("UCBBeginSubCompile not implemented"); + return cwErrRequestFailed; +} + +CWResult UCBEndSubCompile(CWPluginContext subContext) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBEndSubCompile"); + +#line 384 + DO_INTERNAL_ERROR("UCBEndSubCompile not implemented"); + return cwErrRequestFailed; +} + +CWResult UCBGetPrecompiledHeaderSpec(CWPluginContext context, CWFileSpec *pchspec, const char *intarget) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBGetPrecompiledHeaderSpec"); + + CWCompilerLinkerContext *c; + int err; + OSSpec outfss; + File *file; + const CWObjectFlags *cof; + char target[256]; + + if (context->pluginType == CWDROPINCOMPILERTYPE || context->pluginType == CWDROPINLINKERTYPE) + c = static_cast(context); + else + return cwErrInvalidCallback; + + file = Files_GetFile(&gTarg->files, c->whichfile); +#line 420 + OPTION_ASSERT(file != NULL); + + cof = Plugin_CL_GetObjectFlags(file->compiler); + if (!file->outfilename[0]) { + if (intarget) { + if (optsCompiler.canonicalIncludes) + strcpy(target, intarget); + else if (OS_CanonPath(intarget, target) != noErr) + return cwErrInvalidParameter; + + err = OS_MakeSpecWithPath(&file->srcfss.path, target, 0, &outfss); + if (err) { + CLReportOSError(CLStr97, err, target); + return cwErrRequestFailed; + } + + if (!file->outfileowner || file->outfileowner == CmdLineStageMask_Cg) { + file->outfileowner = CmdLineStageMask_Cg; + OS_SpecToStringRelative(&outfss, NULL, file->outfilename, sizeof(file->outfilename)); + } + + if (optsCmdLine.verbose) + CLReport(CLStr16, "precompiled ", OS_SpecToStringRelative(&outfss, NULL, STSbuf, sizeof(STSbuf))); + } else { + OS_MakeSpecWithPath(&gTarg->outputDirectory, file->srcfilename, optsCompiler.relPathInOutputDir == 0, &outfss); + OS_NameSpecSetExtension(&outfss.name, optsCompiler.pchFileExt[0] ? optsCompiler.pchFileExt : cof->pchFileExt); + + if (!file->outfileowner || file->outfileowner == CmdLineStageMask_Cg) { + file->outfileowner = CmdLineStageMask_Cg; + OS_NameSpecToString(&outfss.name, file->outfilename, sizeof(file->outfilename)); + } + + CLReport(CLStr59, OS_SpecToStringRelative(&outfss, NULL, STSbuf, sizeof(STSbuf))); + } + + OS_OSSpec_To_FSSpec(&outfss, pchspec); + } else { + err = OS_MakeSpecWithPath(&gTarg->outputDirectory, file->outfilename, 0, &outfss); + if (err) { + CLReportOSError(CLStr97, err, file->outfilename); + return cwErrRequestFailed; + } + + OS_OSSpec_To_FSSpec(&outfss, pchspec); + + if (intarget) + CLReport(CLStr60, OS_SpecToStringRelative(&outfss, NULL, STSbuf, sizeof(STSbuf)), intarget); + } + + return cwNoErr; +} + +CWResult UCBGetResourceFile(CWPluginContext context, CWFileSpec *filespec) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBGetResourceFile"); + +#line 514 + DO_INTERNAL_ERROR("UCBGetResourceFile not implemented"); + return cwErrRequestFailed; +} + +CWResult UCBPutResourceFile(CWPluginContext context, const char *prompt, const char *name, CWFileSpec *filespec) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBPutResourceFile"); + +#line 529 + DO_INTERNAL_ERROR("UCBPutResourceFile not implemented"); + return cwErrRequestFailed; +} + +static int UnitNameToSBMName(OSSpec *spec, File *srcfile) { + const CWObjectFlags *cof; + int err; + + cof = Plugin_CL_GetObjectFlags(srcfile->compiler); + err = OS_NameSpecChangeExtension( + &spec->name, + cof->pchFileExt ? cof->pchFileExt : ".sbm", + cof->pchFileExt ? (cof->pchFileExt[0] == '.') : 0 + ); + return err; +} + +CWResult UCBLookUpUnit(CWPluginContext context, const char *name, Boolean isdependency, const void **unitdata, SInt32 *unitdatalength) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBLookUpUnit"); + + CWFileInfo includeinfo; + OSSpec unitspec; + OSSpec sbmspec; + time_t unittime; + UInt32 unitmactime; + char sbmpath[256]; + int err; + CWCompilerLinkerContext *c; + File *srcfile; + File *sbmfile; + + if (context->pluginType == CWDROPINCOMPILERTYPE || context->pluginType == CWDROPINLINKERTYPE) + c = static_cast(context); + else + return cwErrInvalidCallback; + + srcfile = Files_GetFile(&gTarg->files, c->whichfile); +#line 591 + OPTION_ASSERT(srcfile != NULL); + + *unitdata = NULL; + *unitdatalength = 0; + + if (optsCompiler.sbmState == OptsCompilerSbmState_1 || optsCompiler.sbmState == OptsCompilerSbmState_3) { + if (clState.pluginDebug) + CLPrint("UCBLookUpUnit: sbmState == sbmRebuild or sbmClean; failing\n"); + return cwErrSBMNotFound; + } + + includeinfo.fullsearch = 1; + includeinfo.dependencyType = isdependency ? cwNormalDependency : cwNoDependency; + includeinfo.isdependentoffile = -1; + includeinfo.suppressload = 1; + if (UCBFindAndLoadFile(context, name, &includeinfo) != cwNoErr) { + if (clState.pluginDebug) + CLPrint("UCBLookUpUnit: could not find source '%s'; failing\n", name); + return cwErrFileNotFound; + } + + OS_FSSpec_To_OSSpec(&includeinfo.filespec, &unitspec); + sbmspec = unitspec; + err = UnitNameToSBMName(&sbmspec, srcfile); + if (err) { + if (clState.pluginDebug) + CLPrint("UCBLookUpUnit: could not make precompiled unit spec for '%s' (%s)\n", name, OS_GetErrText(err)); + return cwErrRequestFailed; + } + + if (optsCompiler.sbmPath[0]) { + sbmspec.path = clState.sbmPathSpec; + OS_SpecToString(&sbmspec, sbmpath, sizeof(sbmpath)); + if (clState.pluginDebug) + CLPrint("UCBLookUpUnit: Only looking at '%s'\n", sbmpath); + } else { + OS_NameSpecToString(&sbmspec.name, sbmpath, sizeof(sbmpath)); + if (clState.pluginDebug) + CLPrint("UCBLookUpUnit: searching paths for '%s'\n", sbmpath); + } + + includeinfo.fullsearch = 1; + includeinfo.dependencyType = isdependency ? cwNormalDependency : cwNoDependency; + includeinfo.isdependentoffile = -1; + includeinfo.suppressload = 0; + if (UCBFindAndLoadFile(context, sbmpath, &includeinfo) != cwNoErr || !includeinfo.filedata) { + if (clState.pluginDebug) + CLPrint("UCBLookUpUnit: could not find or load precompiled unit file '%s'; failing\n", sbmpath); + return cwErrFileNotFound; + } + + OS_FSSpec_To_OSSpec(&includeinfo.filespec, &sbmspec); + if (includeinfo.filedatatype != cwFileTypePrecompiledHeader) { + CLPrint("UCBLookUpUnit: file '%s' does not appear to be precompiled\n", OS_SpecToString(&sbmspec, STSbuf, sizeof(STSbuf))); + UCBReleaseFileText(context, includeinfo.filedata); + return cwErrRequestFailed; + } + + OS_GetFileTime(&unitspec, NULL, &unittime); + OS_TimeToMac(unittime, &unitmactime); + if (unitmactime != *reinterpret_cast(includeinfo.filedata)) { + if (clState.pluginDebug) + CLPrint( + "UCBLookUpUnit: file '%s' does not have internal timestamp that matches source unit's timestamp (0x%8x != 0x%8x)\n", + OS_SpecToString(&sbmspec, STSbuf, sizeof(STSbuf)), + unitmactime, + *reinterpret_cast(includeinfo.filedata)); + UCBReleaseFileText(context, includeinfo.filedata); + return cwErrRequestFailed; + } + + sbmfile = Files_FindFile(&gTarg->pchs, &sbmspec); + if (!sbmfile) { + sbmfile = File_New(); + sbmfile->srcfss = unitspec; + OS_SpecToString(&sbmfile->srcfss, sbmfile->srcfilename, sizeof(sbmfile->srcfilename)); + sbmfile->outfss = sbmspec; + OS_SpecToString(&sbmfile->outfss, sbmfile->outfilename, sizeof(sbmfile->outfilename)); + sbmfile->compiler = srcfile->compiler; + sbmfile->outfileowner = CmdLineStageMask_Cg; + sbmfile->writeToDisk = srcfile->writeToDisk; + sbmfile->dropinflags = srcfile->dropinflags; + sbmfile->objectflags = srcfile->objectflags; + sbmfile->mappingflags = srcfile->mappingflags; + Deps_Initialize(&sbmfile->deps, &gTarg->incls); + if (!Files_AddFile(&gTarg->pchs, sbmfile)) + return cwErrRequestFailed; + } + + if (clState.pluginDebug) + CLPrint("UCBLookUpUnit: success for '%s'\n", name); + + if (optsCmdLine.verbose) + CLReport(CLStr62, "unit symbol table", OS_SpecToStringRelative(&sbmspec, NULL, STSbuf, sizeof(STSbuf))); + + *unitdata = includeinfo.filedata; + *unitdatalength = includeinfo.filedatalength; + return cwNoErr; +} + +CWResult UCBSBMfiles(CWPluginContext context, short libref) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBSBMfiles"); + return cwNoErr; +} + +CWResult UCBStoreUnit(CWPluginContext context, const char *inunitname, CWMemHandle unitdata, CWDependencyTag dependencytag) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBStoreUnit"); + + char unitname[256]; + OSSpec sbmspec; + int err; + Handle h; + OSHandle unithand; + OSFileHandle fhand; + CWCompilerLinkerContext *c; + File *srcfile; + + if (optsCompiler.canonicalIncludes) { + strcpy(unitname, inunitname); + } else if (OS_CanonPath(inunitname, unitname)) { + return cwErrInvalidParameter; + } + + if (optsCompiler.sbmState == OptsCompilerSbmState_0 || optsCompiler.sbmState == OptsCompilerSbmState_1) { + if (context->pluginType == CWDROPINCOMPILERTYPE || context->pluginType == CWDROPINLINKERTYPE) + c = static_cast(context); + else + return cwErrInvalidCallback; + + srcfile = Files_GetFile(&gTarg->files, c->whichfile); +#line 791 + OPTION_ASSERT(srcfile != NULL); + + if (optsCompiler.sbmPath[0]) { + err = OS_MakeSpecWithPath(&clState.sbmPathSpec, unitname, 1, &sbmspec); + if (err) { + if (clState.pluginDebug) + CLPrint("UCBStoreUnit: '%s' is a bad unit name (%s)\n", unitname, OS_GetErrText(err)); + return cwErrInvalidParameter; + } + } else { + err = OS_MakeFileSpec(unitname, &sbmspec); + if (err) { + if (clState.pluginDebug) + CLPrint("UCBStoreUnit: '%s' is a bad filename (%s)\n", unitname, OS_GetErrText(err)); + return cwErrInvalidParameter; + } + } + + err = UnitNameToSBMName(&sbmspec, srcfile); + if (err) { + if (clState.pluginDebug) + CLPrint("UCBStoreUnit: could not make precompiled unit form of '%s' (%s)\n", unitname, OS_GetErrText(err)); + return cwErrInvalidParameter; + } + + if (optsCmdLine.verbose) + CLReport(CLStr61, "unit symbol table", OS_SpecToStringRelative(&sbmspec, NULL, STSbuf, sizeof(STSbuf))); + + UCBSecretDetachHandle(context, unitdata, &h); + OS_DestroyMacHandle(h, &unithand); + err = OS_NewFileHandle(&sbmspec, &unithand, 1, &fhand); + if (err || (err = OS_FreeFileHandle(&fhand))) { + CLReportOSError(CLStr18, err, "precompiled unit", OS_SpecToStringRelative(&sbmspec, NULL, STSbuf, sizeof(STSbuf))); + return cwErrRequestFailed; + } + } + + return cwNoErr; +} + +CWResult UCBReleaseUnit(CWPluginContext context, void *unitdata) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBReleaseUnit"); + + if (!unitdata) + return cwErrRequestFailed; + return UCBReleaseFileText(context, static_cast(unitdata)); +} + +CWResult UCBUnitNameToFileName(CWPluginContext context, const char *unitname, char *filename) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBUnitNameToFileName"); + + strcpy(filename, unitname); + if (!OS_EqualPath(filename + strlen(filename) - 2, ".p")) + strcat(filename, ".p"); + return cwNoErr; +} + +CWResult UCBOSAlert(CWPluginContext context, const char *message, OSErr errorcode) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBOSAlert"); + if (CheckForUserBreak()) + return cwErrUserCanceled; + + char errormessage[256]; + GetSysErrText(errorcode, errormessage); + CLStyledMessageDispatch( + static_cast(context->shellContext)->plugin, + NULL, + errorcode, + CLStyledMessageDispatch_Type4, + "%\n(%)\n", + message ? message : "", + errormessage + ); + return cwNoErr; +} + +CWResult UCBOSErrorMessage(CWPluginContext context, const char *message, OSErr errorcode) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBOSErrorMessage"); + if (!errorcode) + return cwNoErr; + if (CheckForUserBreak()) + return cwErrUserCanceled; + + char errormessage[256]; + GetSysErrText(errorcode, errormessage); + CLStyledMessageDispatch( + static_cast(context->shellContext)->plugin, + NULL, + errorcode, + CLStyledMessageDispatch_Type4, + "%\n%\n", + message ? message : "", + errormessage + ); + return cwNoErr; +} + +CWResult UCBGetModifiedFiles(CWPluginContext context, SInt32 *modifiedFileCount, const SInt32 **modifiedFiles) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBGetModifiedFiles"); + + *modifiedFileCount = 0; +#line 949 + DO_INTERNAL_ERROR("CWGetModifiedFiles not implemented!\n"); + return cwNoErr; +} + +CWResult UCBGetSuggestedObjectFileSpec(CWPluginContext context, SInt32 whichfile, CWFileSpec *fileSpec) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBGetSuggestedObjectFileSpec"); + + File *file; + if (!(file = Files_GetFile(&gTarg->files, whichfile))) + return cwErrUnknownFile; + + if (!GetOutputFile(file, CmdLineStageMask_Cg)) + return cwErrRequestFailed; + + OS_OSSpec_To_FSSpec(&file->outfss, fileSpec); + return cwNoErr; +} + +CWResult UCBGetStoredObjectFileSpec(CWPluginContext context, SInt32 whichfile, CWFileSpec *fileSpec) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBGetStoredObjectFileSpec"); + + File *file; + if (!(file = Files_GetFile(&gTarg->files, whichfile))) + return cwErrUnknownFile; + if (file->outfileowner != CmdLineStageMask_Cg) { +#line 993 + DO_INTERNAL_ERROR("Lost stored object file spec for '%s'\n", file->srcfilename); + return cwErrRequestFailed; + } else { + OS_OSSpec_To_FSSpec(&file->outfss, fileSpec); + return cwNoErr; + } +} + +CWResult UCBGetFrameworkCount(CWPluginContext context, SInt32 *frameworkCount) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBGetFrameworkCount"); + + *frameworkCount = Frameworks_GetCount(); + return cwNoErr; +} + +CWResult UCBGetFrameworkInfo(CWPluginContext context, SInt32 whichFramework, CWFrameworkInfo *frameworkInfo) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBGetFrameworkCount"); + + Paths_FWInfo *info; + if ((info = Frameworks_GetInfo(whichFramework))) { + OS_OSSpec_To_FSSpec(&info->fileSpec, &frameworkInfo->fileSpec); + strncpy(frameworkInfo->version, info->version.s, sizeof(frameworkInfo->version)); + return cwNoErr; + } + + return cwErrFileNotFound; +} + +CWCompilerLinkerCallbacks sCompilerLinkerCallbacks = { + UCBCachePrecompiledHeader, + UCBLoadObjectData, + UCBStoreObjectData, + UCBFreeObjectData, + UCBDisplayLines, + UCBBeginSubCompile, + UCBEndSubCompile, + UCBGetPrecompiledHeaderSpec, + UCBGetResourceFile, + UCBPutResourceFile, + UCBLookUpUnit, + UCBSBMfiles, + UCBStoreUnit, + UCBReleaseUnit, + UCBUnitNameToFileName, + UCBOSErrorMessage, + UCBOSAlert, + UCBGetModifiedFiles, + UCBGetSuggestedObjectFileSpec, + UCBGetStoredObjectFileSpec, + NULL, + UCBGetFrameworkCount, + UCBGetFrameworkInfo +}; + +CWCompilerLinkerContext::CWCompilerLinkerContext() + : + CWPluginPrivateContext(clState.plugintype, sizeof(CWCompilerLinkerContext)) { + targetinfo = static_cast(xmalloc("context", sizeof(CWTargetInfo))); + memset(targetinfo, 0, sizeof(CWTargetInfo)); + + if (gTarg) { + targetinfo->targetCPU = gTarg->cpu; + targetinfo->targetOS = gTarg->os; + } else { + targetinfo->targetOS = targetOSAny; + targetinfo->targetCPU = targetCPUAny; + } + + whichfile = 0; + memset(&sourcefile, 0, sizeof(sourcefile)); + sourcetext = NULL; + sourcetextsize = 0; + + preprocess = 0; + autoprecompile = 0; + precompile = 0; + cachingPCH = 0; + debuginfo = 0; + fileID = 0; + memset(&browseoptions, 0, sizeof(browseoptions)); + reserved = NULL; + sequenceID = 0; + parentPB = NULL; + targetStorage = NULL; + texthandle = NULL; + memset(&targetinfo_V7, 0, sizeof(targetinfo_V7)); + + callbacks = &sCompilerLinkerCallbacks; +} + +CWCompilerLinkerContext::~CWCompilerLinkerContext() { + xfree(targetinfo); +} diff --git a/command_line/CmdLine/Src/Callbacks/CLDropinCallbacks_V10.cpp b/command_line/CmdLine/Src/Callbacks/CLDropinCallbacks_V10.cpp index cf6f1f7..ed02965 100644 --- a/command_line/CmdLine/Src/Callbacks/CLDropinCallbacks_V10.cpp +++ b/command_line/CmdLine/Src/Callbacks/CLDropinCallbacks_V10.cpp @@ -1,48 +1,1305 @@ -/* - 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 - */ +#include "cmdline.h" +#include "plugin_internal.h" + +extern char STSbuf[256]; + +static void ANSI_To_Mac_GMT_Time(time_t sectm, UInt32 *secs) { + struct tm *tmrec; + int years; + int ydays; + + tmrec = localtime(§m); + years = tmrec->tm_year - 4; + + ydays = + (years * 365) + + ((years + 3) / 4) - + ((years + 4) / 100) + + ((years - 296) / 400); + + *secs = + ((ydays + tmrec->tm_yday) * 86400) + + (tmrec->tm_hour * 3600) + + (tmrec->tm_min * 60) + + (tmrec->tm_sec); +} + +static void Mac_To_ANSI_Time(UInt32 secs, time_t *sectm) { + static int monthdays[12] = { + 31, 28, 31, 30, + 31, 30, 31, 31, + 30, 31, 30, 31 + }; + struct tm tmrec; + int month; + + memset(&tmrec, 0, sizeof(tmrec)); + tmrec.tm_sec = secs % 60; // line 1523 + tmrec.tm_min = (secs / 60) % 60; // line 1524 + tmrec.tm_hour = (secs / 3600) % 24; // line 1525 + tmrec.tm_yday = (secs / 86400) % 365; + tmrec.tm_year = (secs / 31536000) + 4; // line 1533 + tmrec.tm_yday -= + ((((secs / 31536000) + 3) / 4) + - + (((secs / 31536000) + 4) / 100) + + + ((SInt32)((secs / 31536000) - 296) / 400)) + ; + + if ((tmrec.tm_year % 4) && ((tmrec.tm_year % 100) || !(tmrec.tm_year % 400))) { + monthdays[1] = 28; + } else { + monthdays[1] = 29; + } + + for (month = 0; tmrec.tm_yday >= monthdays[month]; month++) { + tmrec.tm_yday -= monthdays[month]; + } + tmrec.tm_mon = month; + tmrec.tm_mday = tmrec.tm_yday + 1; + + *sectm = mktime(&tmrec); + if (month >= 4 && month < 10) + *sectm += 3600; +} + +CWResult UCBGetFileInfo(CWPluginContext context, SInt32 whichfile, Boolean checkFileLocation, CWProjectFileInfo *fileinfo) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBGetFileInfo"); + + File *file; + SInt16 id; + int ret; + char fullpath[256]; + time_t tmptime; + + file = Files_GetFile(&gTarg->files, whichfile); + if (!file) + return cwErrUnknownFile; + + memset(fileinfo, 0, sizeof(CWProjectFileInfo)); + OS_OSSpec_To_FSSpec(&file->srcfss, &fileinfo->filespec); + OS_TimeToMac(file->srcmoddate, &fileinfo->moddate); + Mac_To_ANSI_Time(fileinfo->moddate, &tmptime); + ANSI_To_Mac_GMT_Time(tmptime, &fileinfo->moddate); + + fileinfo->segment = file->segnum; + fileinfo->hasobjectcode = file->hasobjectcode; + fileinfo->hasresources = file->hasresources; + fileinfo->isresourcefile = file->isresourcefile; + fileinfo->weakimport = file->weakimport; + fileinfo->initbefore = file->initbefore; + fileinfo->mergeintooutput = file->mergeintooutput; + fileinfo->reserved = 0; + fileinfo->gendebug = file->gendebug; + OS_TimeToMac(file->outmoddate, &fileinfo->objmoddate); + + if (file->compiler) { + strncpy(fileinfo->dropinname, Plugin_GetDropInName(file->compiler), 31); + fileinfo->dropinname[31] = 0; + } else { + fileinfo->dropinname[0] = 0; + } + + fileinfo->fileID = file->browseFileID; + fileinfo->recordbrowseinfo = file->recordbrowseinfo; + fileinfo->filetype = file->filetype; + fileinfo->filecreator = file->filecreator; + + if (optsCompiler.browserEnabled) { + ret = Browser_SearchFile(&clState.browseTableHandle, OS_SpecToString(&file->srcfss, fullpath, sizeof(fullpath)), &id); + if (ret) { + fileinfo->recordbrowseinfo = 1; + fileinfo->fileID = id; + } else { + fileinfo->recordbrowseinfo = 0; + fileinfo->fileID = id; + } + } else { + fileinfo->recordbrowseinfo = 0; + fileinfo->fileID = 0; + } + fileinfo->unitdatadependencytag = 0; + fileinfo->hasunitdata = 0; + return cwNoErr; +} + +static Boolean FindAndLoad_VirtualFile(CWPluginContext context, const char *filename, CWFileInfo *fileinfo, OSSpec *spec, Boolean *loaded) { + VFile *vf; + char *fnameptr; + + fnameptr = OS_GetFileNamePtr(const_cast(filename)); + vf = VFiles_Find(gTarg->virtualFiles, fnameptr); + if (vf) { + if (!fileinfo->suppressload) { + CopyFileText(vf->data, const_cast(&fileinfo->filedata), &fileinfo->filedatalength); + *loaded = 1; + } + fileinfo->filedatatype = cwFileTypeText; + fileinfo->fileID = 0; + fileinfo->alreadyincluded = 0; + fileinfo->recordbrowseinfo = 0; + fileinfo->filespec.parID = 0; + fileinfo->filespec.vRefNum = 0; + c2pstrcpy(fileinfo->filespec.name, fnameptr); + OS_MakeFileSpec(fnameptr, spec); + if (optsCompiler.printHeaderNames) + CLPrint("%s\n", fnameptr); + return 1; + } + + return 0; +} + +static Boolean FindAndLoad_AccessPathFile(CWPluginContext context, const char *filename, CWFileInfo *fileinfo, OSSpec *spec, Boolean *loaded) { + SInt32 incl; + shellContextType *sc; + File *depfile; + SInt16 id; + int ret; + char fullpath[256]; + + if (Incls_FindFileInPaths(&gTarg->incls, const_cast(filename), fileinfo->fullsearch || optsCompiler.noSysPath, spec, &incl)) { + if (context->pluginType == CWDROPINCOMPILERTYPE) { + depfile = Files_GetFile( + &gTarg->files, + (fileinfo->isdependentoffile < 0) ? static_cast(context)->whichfile : fileinfo->isdependentoffile); + if (depfile) + Deps_AddDependency(&depfile->deps, incl, NULL, 0, fileinfo->dependencyType, &fileinfo->alreadyincluded); + + if (optsCompiler.browserEnabled) { + ret = Browser_SearchAndAddFile(&clState.browseTableHandle, OS_SpecToString(spec, fullpath, sizeof(fullpath)), &id); + if (ret == 0) { + return 2; + } else if (ret < 0) { + fileinfo->recordbrowseinfo = 1; + fileinfo->fileID = id; + } else { + fileinfo->recordbrowseinfo = 0; + fileinfo->fileID = id; + } + } else { + fileinfo->recordbrowseinfo = 0; + fileinfo->fileID = 0; + } + } + + OS_OSSpec_To_FSSpec(spec, &fileinfo->filespec); + return 1; + } + + return 0; +} + +static Boolean FindAndLoad_MissingFile(CWPluginContext context, const char *filename, CWFileInfo *fileinfo, OSSpec *spec, Boolean *loaded) { + File *file; + CWCompilerLinkerContext *c; + + if (optsCompiler.ignoreMissingFiles) { + if (context->pluginType == CWDROPINCOMPILERTYPE || context->pluginType == CWDROPINLINKERTYPE) + c = static_cast(context); + else + return 0; + + file = Files_GetFile(&gTarg->files, c->whichfile); +#line 486 + OPTION_ASSERT(file != NULL); + + OS_MakeSpecWithPath(&file->srcfss.path, filename, 1, spec); + Deps_AddDependency(&file->deps, -1, spec, !fileinfo->fullsearch && !optsCompiler.noSysPath, fileinfo->dependencyType, &fileinfo->alreadyincluded); + + fileinfo->fileID = 0; + fileinfo->recordbrowseinfo = 0; + if (!fileinfo->suppressload) { + fileinfo->filedata = xstrdup(""); + fileinfo->filedatalength = 0; + fileinfo->filedatatype = cwFileTypeText; + *loaded = 1; + } else { + fileinfo->filedata = NULL; + fileinfo->filedatalength = 0; + fileinfo->filedatatype = cwFileTypeUnknown; + } + + OS_OSSpec_To_FSSpec(spec, &fileinfo->filespec); + return 1; + } + + return 0; +} + +CWResult UCBFindAndLoadFile(CWPluginContext context, const char *infilename, CWFileInfo *fileinfo) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBFindAndLoadFile"); + + OSSpec spec; + Boolean loaded; + char filename[256]; + char browseinfo[64]; + + ShowWorking(8); + if (CheckForUserBreak()) + return cwErrUserCanceled; + + if (optsCompiler.canonicalIncludes) + strcpy(filename, infilename); + else if (OS_CanonPath(infilename, filename)) + return cwErrInvalidParameter; + + loaded = 0; + if (!FindAndLoad_VirtualFile(context, filename, fileinfo, &spec, &loaded) && !FindAndLoad_AccessPathFile(context, filename, fileinfo, &spec, &loaded) && !FindAndLoad_MissingFile(context, filename, fileinfo, &spec, &loaded)) { + return cwErrFileNotFound; + } + + if (optsCompiler.printHeaderNames) + CLPrint("%s\n", OS_SpecToStringRelative(&spec, NULL, STSbuf, sizeof(STSbuf))); + + if (context->pluginType == CWDROPINCOMPILERTYPE) { + if (optsCmdLine.verbose > 2) { + sprintf(browseinfo, " (browse fileID %d)", fileinfo->fileID); + CLReport( + CLStr21, + fileinfo->alreadyincluded ? "Included" : "Including", + OS_SpecToString(&spec, STSbuf, sizeof(STSbuf)), + fileinfo->recordbrowseinfo ? browseinfo : ""); + } else if (optsCmdLine.verbose > 1 && !fileinfo->alreadyincluded) { + CLReport( + CLStr21, + "Including", + OS_SpecToString(&spec, STSbuf, sizeof(STSbuf)), + ""); + } + } else { + fileinfo->fileID = 0; + fileinfo->recordbrowseinfo = 0; + fileinfo->alreadyincluded = 0; + } + + if (!loaded) { + if (!fileinfo->suppressload) { + return UCBGetFileText(context, &fileinfo->filespec, &fileinfo->filedata, &fileinfo->filedatalength, &fileinfo->filedatatype); + } else { + fileinfo->filedata = NULL; + fileinfo->filedatalength = 0; + fileinfo->filedatatype = cwFileTypeUnknown; + return cwNoErr; + } + } else { + return cwNoErr; + } +} + +CWResult UCBGetFileText(CWPluginContext context, const CWFileSpec *filespec, const char **text, SInt32 *textLength, short *filedatatype) { + int err; + Handle texthandle = NULL; + Boolean precomp; + OSSpec spec; + VFile *vf; + char filename[64]; + + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBGetFileText"); + + OS_FSSpec_To_OSSpec(filespec, &spec); + err = LoadAndCacheFile(&spec, &texthandle, &precomp); + if (err) { + p2cstrcpy(filename, filespec->name); + if (filespec->vRefNum || filespec->parID || !(vf = VFiles_Find(gTarg->virtualFiles, filename))) { + CLReportOSError(CLStr93, err, OS_SpecToString(&spec, STSbuf, sizeof(STSbuf))); + return cwErrFileNotFound; + } + CopyFileText(vf->data, const_cast(text), textLength); + *filedatatype = cwFileTypeText; + int err = OS_MakeFileSpec(filename, &spec); + } else { + if (texthandle) { + if (!precomp) { + CopyFileText(texthandle, const_cast(text), textLength); + FreeIncludeFile(texthandle); + } else { + HLock(texthandle); + *text = *texthandle; + *textLength = GetHandleSize(texthandle); + } + } + + if (texthandle) { + if (!precomp) + *filedatatype = cwFileTypeText; + else + *filedatatype = cwFileTypePrecompiledHeader; + } else { + *filedatatype = cwFileTypeUnknown; + } + } + + return cwNoErr; +} + +CWResult UCBReleaseFileText(CWPluginContext context, const char *text) { + short callbackResult = 0; + CWCompilerLinkerContext *cc = static_cast(context); + + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBReleaseFileText"); + + if (text) { + if (text != cc->sourcetext) + xfree((void *) text); + } else { + callbackResult = cwErrInvalidParameter; + } + + return callbackResult; +} + +CWResult UCBGetSegmentInfo(CWPluginContext context, SInt32 whichsegment, CWProjectSegmentInfo *segmentinfo) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBGetSegmentInfo"); + + if (gTarg->linkmodel != LinkModel1) + return cwErrInvalidCallback; + + Segment *seg = Segments_GetSegment(&gTarg->linkage.segs, whichsegment); + if (!seg) + return cwErrUnknownSegment; + + strcpy(segmentinfo->name, seg->name); + segmentinfo->attributes = seg->attrs; + return cwNoErr; +} + +CWResult UCBGetOverlay1GroupInfo(CWPluginContext context, SInt32 whichgroup, CWOverlay1GroupInfo *groupinfo) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBGetOverlay1GroupInfo"); + + OvlGroup *grp = Overlays_GetOvlGroup(&gTarg->linkage.overlays, whichgroup); + if (gTarg->linkmodel != LinkModel2) + return cwErrInvalidCallback; + + if (grp) { + strcpy(groupinfo->name, grp->name); + groupinfo->address.lo = grp->addr.lo; + groupinfo->address.hi = grp->addr.hi; + groupinfo->numoverlays = OvlGroup_CountOverlays(grp); + return cwNoErr; + } else { + return cwErrInvalidParameter; + } +} + +CWResult UCBGetOverlay1FileInfo(CWPluginContext context, SInt32 whichgroup, SInt32 whichoverlay, SInt32 whichoverlayfile, CWOverlay1FileInfo *fileinfo) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBGetOverlay1FileInfo"); + + if (gTarg->linkmodel != LinkModel2) + return cwErrInvalidCallback; + + SInt32 filenum = Overlays_GetFileInOverlay(&gTarg->linkage.overlays, whichgroup, whichoverlay, whichoverlayfile); + if (filenum >= 0) { + fileinfo->whichfile = filenum; + return cwNoErr; + } else { + return cwErrInvalidParameter; + } +} + +CWResult UCBGetOverlay1Info(CWPluginContext context, SInt32 whichgroup, SInt32 whichoverlay, CWOverlay1Info *overlayinfo) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBGetOverlay1Info"); + + if (gTarg->linkmodel != LinkModel2) + return cwErrInvalidCallback; + + Overlay *oly = Overlays_GetOverlayInGroup(&gTarg->linkage.overlays, whichgroup, whichoverlay); + if (oly) { + strcpy(overlayinfo->name, oly->name); + overlayinfo->numfiles = Overlay_CountFiles(oly); + return cwNoErr; + } else { + return cwErrInvalidParameter; + } +} + +CWResult UCBReportMessage(CWPluginContext context, const CWMessageRef *msgRef, const char *line1, const char *line2, short errorlevel, SInt32 errorNumber) { + if (optsCmdLine.verbose > 4) + CLPrint("Callback: %s\n", "UCBReportMessage"); + + short msgType; + int eeol; + const char *eeptr; + char *tptr; + MessageRef ref; + CWCompilerLinkerContext *clx; + + static const char *fmts[2][2][2] = { + "%\n", "%", + "%\n", "%", + "%\n%\n", "%%\n", + "%\n%", "%%" + }; + + if (line1 == NULL) { + line1 = ""; + eeol = 0; + } else { + eeptr = line1 + strlen(line1) - 1; + eeol = *eeptr == '\r' || *eeptr == '\n'; + } + + if (CheckForUserBreak()) + return cwErrUserCanceled; + + if (errorlevel == messagetypeError) + msgType = CLStyledMessageDispatch_Type3; + else if (errorlevel == messagetypeWarning) + msgType = CLStyledMessageDispatch_Type2; + else + msgType = CLStyledMessageDispatch_Type1; + + clx = static_cast(context); + + if (!msgRef) { + if (line2 && line2[0]) { + eeptr = line2 + strlen(line2) - 1; + int eeol2 = *eeptr == '\r' || *eeptr == '\n'; + CLStyledMessageDispatch( + static_cast(clx->shellContext)->plugin, + NULL, + errorNumber, + msgType, + fmts[1][eeol2][eeol], + line1, + line2 + ); + } else { + CLStyledMessageDispatch( + static_cast(clx->shellContext)->plugin, + NULL, + errorNumber, + msgType, + fmts[0][0][eeol], + line1 + ); + } + } else { + OS_FSSpec_To_OSSpec(&clx->sourcefile, &ref.sourcefile); + OS_FSSpec_To_OSSpec(&msgRef->sourcefile, &ref.errorfile); + ref.sourceline = const_cast(line2); + ref.linenumber = msgRef->linenumber; + + ref.tokenoffset = msgRef->tokenoffset; + ref.tokenlength = msgRef->tokenlength; + ref.selectionoffset = msgRef->selectionoffset; + ref.selectionlength = msgRef->selectionlength; + + if (ref.tokenoffset < 0) + ref.tokenoffset = 0; + if (ref.tokenlength < 0) + ref.tokenlength = 0; + if (ref.selectionoffset < 0) + ref.selectionoffset = 0; + if (ref.selectionlength < 0) + ref.selectionlength = 0; + + CLStyledMessageDispatch( + static_cast(clx->shellContext)->plugin, + &ref, + errorNumber, + msgType, + fmts[0][0][eeol], + line1 + ); + } + + return cwNoErr; +} + +CWResult UCBAlert(CWPluginContext context, const char *msg1, const char *msg2, const char *msg3, const char *msg4) { + if (optsCmdLine.verbose > 4) + CLPrint("Callback: %s\n", "UCBAlert"); + + if (CheckForUserBreak()) + return cwErrUserCanceled; + + if (msg4) { + CLStyledMessageDispatch( + static_cast(context->shellContext)->plugin, + NULL, + 0, + CLStyledMessageDispatch_Type4, + "%\n%\n%\n%\n", + msg1 ? msg1 : "", + msg2 ? msg2 : "", + msg3 ? msg3 : "", + msg4 + ); + } else if (msg3) { + CLStyledMessageDispatch( + static_cast(context->shellContext)->plugin, + NULL, + 0, + CLStyledMessageDispatch_Type4, + "%\n%\n%\n", + msg1 ? msg1 : "", + msg2 ? msg2 : "", + msg3 + ); + } else if (msg2) { + CLStyledMessageDispatch( + static_cast(context->shellContext)->plugin, + NULL, + 0, + CLStyledMessageDispatch_Type4, + "%\n%\n", + msg1 ? msg1 : "", + msg2 + ); + } else { + CLStyledMessageDispatch( + static_cast(context->shellContext)->plugin, + NULL, + 0, + CLStyledMessageDispatch_Type4, + "%\n", + msg1 ? msg1 : "" + ); + } + + return cwNoErr; +} + +CWResult UCBShowStatus(CWPluginContext context, const char *line1, const char *line2) { + if (optsCmdLine.verbose > 4) + CLPrint("Callback: %s\n", "UCBShowStatus"); + + if (CheckForUserBreak()) + return cwErrUserCanceled; + + if (optsCmdLine.verbose > 1) { + if ((!line1 || !*line1) && (!line2 || !*line2)) + return cwNoErr; + + if (line2 && *line2) { + CLStyledMessageDispatch( + static_cast(context->shellContext)->plugin, + NULL, + 0, + CLStyledMessageDispatch_Type5, + "%\n%\n", + line1 ? line1 : "", + line2 ? line2 : "" + ); + } else { + CLStyledMessageDispatch( + static_cast(context->shellContext)->plugin, + NULL, + 0, + CLStyledMessageDispatch_Type5, + "%\n", + line1 ? line1 : "" + ); + } + } + + return cwNoErr; +} + +CWResult UCBUserBreak(CWPluginContext context) { + if (optsCmdLine.verbose > 4) + CLPrint("Callback: %s\n", "UCBUserBreak"); + + ShowWorking(8); + if (CheckForUserBreak()) + return cwErrUserCanceled; + else + return cwNoErr; +} + +CWResult UCBGetNamedPreferences(CWPluginContext context, const char *prefsname, CWMemHandle *prefsdata) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBGetNamedPreferences"); + + PrefPanel *pnl = Prefs_FindPanel(prefsname); + if (pnl) { + if (optsCmdLine.verbose > 2) + CLReport(83, prefsname); + UCBSecretAttachHandle(context, PrefPanel_GetHandle(pnl), prefsdata); + return cwNoErr; + } else { + CLReportError(91, prefsname); + *prefsdata = NULL; + return cwErrRequestFailed; + } +} + +CWResult UCBStorePluginData(CWPluginContext context, SInt32 whichfile, CWDataType type, CWMemHandle prefsdata) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBStorePluginData"); + +#line 1267 + DO_INTERNAL_ERROR("UCBStorePluginData not implemented"); + return cwErrRequestFailed; +} + +CWResult UCBGetPluginData(CWPluginContext context, SInt32 whichfile, CWDataType type, CWMemHandle *prefsdata) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBGetPluginData"); + +#line 1286 + DO_INTERNAL_ERROR("UCBGetPluginData not implemented"); + return cwErrRequestFailed; +} + +CWResult UCBSetModDate(CWPluginContext context, const CWFileSpec *filespec, CWFileTime *moddate, Boolean isGenerated) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBSetModDate"); + + OSSpec spec; + time_t mdtm; + int err; + SInt32 idx; + File *file; + + OS_FSSpec_To_OSSpec(filespec, &spec); + if (!moddate || !*moddate) + OS_GetTime(&mdtm); + else + OS_MacToTime(*moddate, &mdtm); + + for (idx = 0; idx < Files_Count(&gTarg->files); idx++) { + file = Files_GetFile(&gTarg->files, idx); + if (OS_EqualSpec(&file->srcfss, &spec)) + file->srcmoddate = mdtm; + else if (OS_EqualSpec(&file->outfss, &spec)) + file->outmoddate = mdtm; + } + + err = OS_SetFileTime(&spec, NULL, &mdtm); + if (err == 0) + return cwNoErr; + else + return cwErrRequestFailed; +} + +CWResult UCBAddProjectEntry(CWPluginContext context, const CWFileSpec *fileSpec, Boolean isGenerated, const CWNewProjectEntryInfo *entry, SInt32 *whichfile) { + // two registers are awkwardly swapped here... + File *file; + OSSpec fss; + UInt32 filetype; + Plugin *plugin; + char *extptr; + char ext[16]; + UInt32 flags; + char filename[256]; + const DropInFlags *df; + OvlGroup *ovg; + Overlay *oly; + SInt32 idx; + + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBAddProjectEntry"); + + OS_FSSpec_To_OSSpec(fileSpec, &fss); + if (OS_IsDir(&fss)) + return cwErrInvalidParameter; + + OS_NameSpecToString(&fss.name, filename, sizeof(filename)); + if (gTarg->linker && !(gTarg->linkerDropinFlags & (linkAllowDupFileNames | dropInExecutableTool))) { + if (Files_FindFile(&gTarg->files, &fss)) { + if (optsCmdLine.verbose > 1) + CLReportWarning(CLStr106, filename); + return cwNoErr; + } + } + + extptr = filename + strlen(filename) - 1; + while (extptr > filename && *extptr != '.') + --extptr; + if (extptr <= filename) + extptr = "."; + strncpy(ext, extptr, sizeof(ext) - 1); + ext[sizeof(ext) - 1] = 0; + + OS_SpecToStringRelative(&fss, NULL, filename, sizeof(filename)); + if (optsCmdLine.verbose > 2) + CLReport(CLStr77, " to project", filename); + + if (OS_GetMacFileType(&fss, &filetype)) + filetype = CWFOURCHAR('T','E','X','T'); + + plugin = Plugins_GetPluginForFile(NULL, CWDROPINANYTYPE, targetCPUAny, targetOSAny, filetype, ext, Lang_Any); + if (plugin && gTarg->linker && !Plugin_CL_MatchesTarget(plugin, gTarg->cpu, gTarg->os, 0)) + CLReportError(CLStr76, filename); + + if (!plugin) + plugin = Plugins_CL_MatchTarget(NULL, gTarg->cpu, gTarg->os, clState.plugintype, clState.language); + + if (plugin) { + if (!Plugin_CL_GetCompilerMapping(plugin, filetype, ext, &flags)) { + flags = 0; + if (!isGenerated && !optsCompiler.compileIgnored && optsCompiler.forcePrecompile != 1) { + CLReportWarning( + CLStr73, + "file", filename, + (clState.plugintype == CWDROPINCOMPILERTYPE) ? "treating as source text" : "passing unknown file to linker" + ); + } + if (isGenerated) + flags = kIgnored; + } else if (!isGenerated && (flags & kIgnored) && !optsCompiler.compileIgnored) { + if ((!optsCmdLine.stages || (optsCmdLine.stages & (CmdLineStageMask_Cg | CmdLineStageMask_Ds))) && (optsCompiler.forcePrecompile != 1)) + CLReportWarning(CLStr28, filename); + else + flags &= ~kIgnored; + } + + if (optsCompiler.compileIgnored && !isGenerated) + flags &= ~kIgnored; + + if (clState.pluginDebug) { + CLPrint("Using plugin '%s' for '%s'\n", Plugin_GetDropInName(plugin), filename); + CLPrint( + "[flags: %s, %s, %s, %s]\n", + (flags & kPrecompile) ? "precompile" : "don't precompile", + (flags & kLaunchable) ? "launchable" : "not launchable", + (flags & kRsrcfile) ? "resource file" : "not resource file", + (flags & kIgnored) ? "ignored" : "used" + ); + } + } else { + CLReportError(CLStr74, filename); + flags = kIgnored; + } + + file = File_New(); + if (!file) + return cwErrOutOfMemory; + + Deps_Initialize(&file->deps, &gTarg->incls); + + file->segnum = (entry->segment == -1) ? (Segments_Count(&gTarg->linkage.segs) - 1) : entry->segment; + + strcpy(file->srcfilename, filename); + file->srcfss = fss; + + OS_GetFileTime(&file->srcfss, NULL, &file->srcmoddate); + OS_GetTime(&file->outmoddate); + + file->outfilename[0] = 0; + memset(&file->outfss, 0, sizeof(file->outfss)); + + file->outfileowner = 0; + file->tempOnDisk = 0; + file->wroteToDisk = 0; + file->writeToDisk = 0; + + if (plugin && Plugin_GetPluginType(plugin) != CWDROPINCOMPILERTYPE) + file->compiler = NULL; + else + file->compiler = plugin; + + file->filetype = filetype; + file->mappingflags = flags; + + if (file->compiler) { + df = Plugin_GetDropInFlags(file->compiler); + file->dropinflags = df->dropinflags; + } else { + file->dropinflags = 0; + } + + file->weakimport = entry->weakimport; + file->initbefore = entry->initbefore; + file->mergeintooutput = entry->mergeintooutput; + file->isresourcefile = (flags & kRsrcfile) != 0; + + if (file->compiler) + file->objectflags = Plugin_CL_GetObjectFlags(file->compiler)->flags; + else + file->objectflags = 0; + + file->sourceUsage = 0; + if (!(file->mappingflags & kIgnored)) { + if (file->compiler) { + file->sourceUsage |= CmdLineStageMask_Pp; + if (!(file->objectflags & 0x80000000)) + file->sourceUsage |= CmdLineStageMask_Cg; + } else if (plugin) { + file->sourceUsage |= CmdLineStageMask_Cg; + } + } + + if (file->isresourcefile) + file->sourceUsage |= CmdLineStageMask_Cg; + + file->objectUsage = file->sourceUsage & CmdLineStageMask_Pp; + if ((file->sourceUsage & CmdLineStageMask_Pp) && !(file->mappingflags & kPrecompile) && (optsCompiler.forcePrecompile != 1) && (file->objectflags & 0x80000000)) + file->objectUsage |= CmdLineStageMask_Cg; + + *whichfile = 0; + if ((entry->position != -1) ? (Files_AddFile(&gTarg->files, file) == 0) : (Files_InsertFile(&gTarg->files, file, entry->position) == 0)) + return cwErrRequestFailed; + *whichfile = file->filenum; + context->numFiles++; + + if (gTarg->linkmodel == LinkModel2) { + ovg = Overlays_GetOvlGroup( + &gTarg->linkage.overlays, + (entry->overlayGroup == -1) ? (Overlays_CountGroups(&gTarg->linkage.overlays) - 1) : entry->overlayGroup); + if (ovg) { + oly = OvlGroup_GetOverlay( + ovg, + (entry->overlay == -1) ? (OvlGroup_CountOverlays(ovg) - 1) : entry->overlay); + if (oly) { + if (!Overlay_AddFile(oly, file->filenum, &idx)) + return cwErrRequestFailed; + } else { + return cwErrRequestFailed; + } + } else { + return cwErrRequestFailed; + } + } + + return cwNoErr; +} + +CWResult UCBCreateNewTextDocument(CWPluginContext context, const CWNewTextDocumentInfo *docinfo) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBCreateNewTextDocument"); + + if (context->pluginType == CWDROPINCOMPILERTYPE || context->pluginType == CWDROPINLINKERTYPE) { + if (!docinfo->documentname) { + CWCompilerLinkerContext *clcontext = static_cast(context); + File *file = Files_GetFile(&gTarg->files, clcontext->whichfile); + if (!file) + return cwErrUnknownFile; + + if (file->textdata) { + if (!ShowHandle(file->textdata, GetHandleSize(file->textdata), 1)) + return cwErrRequestFailed; + DisposeHandle(file->textdata); + } + + UCBSecretDetachHandle(context, docinfo->text, &file->textdata); + OS_GetTime(&file->outmoddate); + return cwNoErr; + } else { + Handle texth; + UCBSecretDetachHandle(context, docinfo->text, &texth); + UInt32 size = GetHandleSize(texth); + if (strcmp(docinfo->documentname, ">stdout") || clState.stdout_base) { + FILE *stdfile; + if (!strcmp(docinfo->documentname, ">stdout")) { + stdfile = clState.stdout_written ? fopen(clState.stdout_base, "at") : fopen(clState.stdout_base, "wt"); + clState.stdout_written = 1; + } else { + stdfile = fopen(docinfo->documentname, "wt"); + } + + if (stdfile) { + HLock(texth); + fwrite(*texth, size, 1, stdfile); + fclose(stdfile); + HUnlock(texth); + return cwNoErr; + } + } + + if (!ShowHandle(texth, size, 0)) + return cwErrRequestFailed; + else + return cwNoErr; + } + } else if (context->pluginType == CWDROPINPARSERTYPE) { + Str255 filename; + VFile *vf; + Handle texth; + FSSpec fss; + CWNewProjectEntryInfo entry; + SInt32 pos; + + UCBSecretDetachHandle(context, docinfo->text, &texth); + + if (docinfo->markDirty) { + if (!docinfo->documentname) + return cwErrInvalidParameter; + + vf = VFile_New(docinfo->documentname, texth); + if (!vf) + return cwErrOutOfMemory; + if (!VFiles_Add(&gTarg->virtualFiles, vf)) + return cwErrRequestFailed; + + entry.overlay = -1; + entry.overlayGroup = -1; + entry.segment = -1; + entry.position = -1; + entry.groupPath = NULL; + entry.initbefore = 0; + entry.weakimport = 0; + entry.mergeintooutput = 0; + c2pstrcpy(filename, docinfo->documentname); + FSMakeFSSpec(0, 0, filename, &fss); + return UCBAddProjectEntry(context, &fss, 1, &entry, &pos); + } else { + if (ShowHandle(texth, GetHandleSize(texth), docinfo->documentname != NULL)) + return cwNoErr; + else + return cwErrRequestFailed; + } + } else { +#line 1755 + DO_INTERNAL_ERROR("Cannot deal with unexpected document"); + return cwErrInvalidCallback; + } +} + +CWResult UCBAllocateMemory(CWPluginContext context, SInt32 size, Boolean isPermanent, void **ptr) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBAllocateMemory"); + + *ptr = xmalloc(NULL, size); + return (*ptr == NULL) ? cwErrRequestFailed : cwNoErr; +} + +CWResult UCBFreeMemory(CWPluginContext context, void *ptr, Boolean isPermanent) { + if (optsCmdLine.verbose > 4) + CLPrint("Callback: %s\n", "UCBFreeMemory"); + + if (ptr) { + xfree(ptr); + return cwNoErr; + } else { + return cwErrRequestFailed; + } +} + +CWResult UCBAllocMemHandle(CWPluginContext context, SInt32 size, Boolean useTempMemory, CWMemHandle *memhandle) { + if (optsCmdLine.verbose > 4) + CLPrint("Callback: %s\n", "UCBAllocMemHandle"); + + Handle handle = NewHandle(size); + if (!handle) + return cwErrOutOfMemory; + + UCBSecretAttachHandle(context, handle, memhandle); + return cwNoErr; +} + +CWResult UCBFreeMemHandle(CWPluginContext context, CWMemHandle memhandle) { + if (optsCmdLine.verbose > 4) + CLPrint("Callback: %s\n", "UCBFreeMemHandle"); + + Handle handle; + UCBSecretDetachHandle(context, memhandle, &handle); + DisposeHandle(handle); + return cwNoErr; +} + +CWResult UCBGetMemHandleSize(CWPluginContext context, CWMemHandle memhandle, SInt32 *size) { + if (optsCmdLine.verbose > 4) + CLPrint("Callback: %s\n", "UCBGetMemHandleSize"); + + Handle handle; + UCBSecretDetachHandle(context, memhandle, &handle); + *size = GetHandleSize(handle); + return cwNoErr; +} + +CWResult UCBResizeMemHandle(CWPluginContext context, CWMemHandle memhandle, SInt32 newSize) { + if (optsCmdLine.verbose > 4) + CLPrint("Callback: %s\n", "UCBResizeMemHandle"); + + Handle handle; + UCBSecretDetachHandle(context, memhandle, &handle); + SetHandleSize(handle, newSize); + return (MemError() == noErr) ? cwNoErr : cwErrOutOfMemory; +} + +CWResult UCBLockMemHandle(CWPluginContext context, CWMemHandle handle, Boolean moveHi, void **ptr) { + if (optsCmdLine.verbose > 4) + CLPrint("Callback: %s\n", "UCBLockMemHandle"); + + HLock(reinterpret_cast(handle)); + *ptr = *reinterpret_cast(handle); + return cwNoErr; +} + +CWResult UCBUnlockMemHandle(CWPluginContext context, CWMemHandle handle) { + if (optsCmdLine.verbose > 4) + CLPrint("Callback: %s\n", "UCBUnlockMemHandle"); + + HUnlock(reinterpret_cast(handle)); + return cwNoErr; +} + +CWResult UCBGetTargetName(CWPluginContext context, char *name, short maxLength) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBGetTargetName"); + + strncpy(name, "command-line target", maxLength); + return cwNoErr; +} + +CWResult UCBPreDialog(CWPluginContext context) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBPreDialog"); + + return cwNoErr; +} + +CWResult UCBPostDialog(CWPluginContext context) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBPostDialog"); + + return cwNoErr; +} + +CWResult UCBPreFileAction(CWPluginContext context, const CWFileSpec *theFile) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBPreFileAction"); + +#line 1963 + DO_INTERNAL_ERROR("UCBPreFileAction not implemented"); + return cwErrRequestFailed; +} + +CWResult UCBPostFileAction(CWPluginContext context, const CWFileSpec *theFile) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBPostFileAction"); + +#line 1977 + DO_INTERNAL_ERROR("UCBPostFileAction not implemented"); + return cwErrRequestFailed; +} + +CWResult UCBCacheAccessPathList(CWPluginContext context) { + IDEAccessPathList *apl; + shellContextType *sc; + int x; + + sc = static_cast(context->shellContext); + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBCacheAccessPathList"); + + apl = context->accessPathList; + if (!apl) + apl = context->accessPathList = static_cast(calloc(sizeof(IDEAccessPathList), 1)); + + if (sc->userAccessPathsChanged || !apl->userPaths) { + OSSpec spec; + Path *path; + IDEAccessPath *ap; + + apl->userPathCount = Paths_Count(&gTarg->userPaths); + apl->userPaths = static_cast(xrealloc("access paths", apl->userPaths, sizeof(IDEAccessPath) * apl->userPathCount)); + + for (x = 0; x < apl->userPathCount; x++) { + ap = &apl->userPaths[x]; + path = Paths_GetPath(&gTarg->userPaths, x); +#line 2010 + OPTION_ASSERT(path); + + OS_MakeSpecWithPath(path->spec, NULL, 0, &spec); + OS_OSSpec_To_FSSpec(&spec, &ap->pathSpec); + ap->recursive = path->recursive != 0; + if (path->recursive) { + ap->subdirectoryCount = Paths_CountRecurse(path->recursive); + if (ap->subdirectories) + xfree(ap->subdirectories); + ap->subdirectories = static_cast(xmalloc(NULL, sizeof(FSSpec) * ap->subdirectoryCount)); + Paths_CopyRecurseFSS(ap->subdirectories, path->recursive, ap->subdirectoryCount); + } else { + ap->subdirectoryCount = 0; + ap->subdirectories = NULL; + } + } + + sc->userAccessPathsChanged = 0; + } + + if (sc->systemAccessPathsChanged || !apl->systemPaths) { + OSSpec spec; + Path *path; + IDEAccessPath *ap; + + apl->systemPathCount = Paths_Count(&gTarg->sysPaths); + apl->systemPaths = static_cast(xrealloc("access paths", apl->systemPaths, sizeof(IDEAccessPath) * apl->systemPathCount)); + + for (x = 0; x < apl->systemPathCount; x++) { + ap = &apl->systemPaths[x]; + path = Paths_GetPath(&gTarg->sysPaths, x); +#line 2044 + OPTION_ASSERT(path); + + OS_MakeSpecWithPath(path->spec, NULL, 0, &spec); + OS_OSSpec_To_FSSpec(&spec, &ap->pathSpec); + ap->recursive = path->recursive != 0; + if (path->recursive) { + ap->subdirectoryCount = Paths_CountRecurse(path->recursive); + if (ap->subdirectories) + xfree(ap->subdirectories); + ap->subdirectories = static_cast(xmalloc(NULL, sizeof(FSSpec) * ap->subdirectoryCount)); + Paths_CopyRecurseFSS(ap->subdirectories, path->recursive, ap->subdirectoryCount); + } else { + ap->subdirectoryCount = 0; + ap->subdirectories = NULL; + } + } + + sc->systemAccessPathsChanged = 0; + } + + return cwNoErr; +} + +CWResult UCBSecretAttachHandle(CWPluginContext context, Handle handle, CWMemHandle *memHandle) { + if (optsCmdLine.verbose > 4) + CLPrint("Callback: %s\n", "UCBSecretAttachHandle"); + + *memHandle = reinterpret_cast(handle); + return cwNoErr; +} + +CWResult UCBSecretDetachHandle(CWPluginContext context, CWMemHandle memHandle, Handle *handle) { + if (optsCmdLine.verbose > 4) + CLPrint("Callback: %s\n", "UCBSecretDetachHandle"); + + if (!memHandle || !handle) { + *handle = NULL; + return cwErrInvalidParameter; + } else { + *handle = reinterpret_cast(memHandle); + return cwNoErr; + } +} + +CWResult UCBSecretPeekHandle(CWPluginContext context, CWMemHandle memHandle, Handle *handle) { + if (optsCmdLine.verbose > 4) + CLPrint("Callback: %s\n", "UCBSecretPeekHandle"); + + if (!memHandle || !handle) { + *handle = NULL; + return cwErrInvalidParameter; + } else { + *handle = reinterpret_cast(memHandle); + return cwNoErr; + } +} + +CWResult UCBCheckoutLicense(CWPluginContext context, const char *a, const char *b, SInt32 c, void *d, SInt32 *cookiePtr) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBCheckoutLicense"); + + if (cookiePtr) + *cookiePtr = 0xD0A; + + return cwErrInvalidCallback; +} + +CWResult UCBCheckinLicense(CWPluginContext context, SInt32 cookie) { + if (optsCmdLine.verbose > 3) + CLPrint("Callback: %s\n", "UCBCheckinLicense"); + + return cwErrInvalidCallback; +} + +CWResult UCBResolveRelativePath(CWPluginContext context, const CWRelativePath *relativePath, CWFileSpec *fileSpec, Boolean create) { +#line 2255 + DO_INTERNAL_ERROR("UCBResolveRelativePath not implemented"); + return cwErrRequestFailed; +} + +CWResult UCBMacOSErrToCWResult(CWPluginContext context, OSErr err) { + if (optsCmdLine.verbose > 4) + CLPrint("Callback: %s\n", "UCBMacOSErrToCWResult"); + + return OSErrtoCWResult(err); +} + +CW_BasePluginCallbacks sBasePluginCallbacks = { + UCBGetFileInfo, + UCBFindAndLoadFile, + UCBGetFileText, + UCBReleaseFileText, + UCBGetSegmentInfo, + UCBGetOverlay1GroupInfo, + UCBGetOverlay1Info, + UCBGetOverlay1FileInfo, + UCBReportMessage, + UCBAlert, + UCBShowStatus, + UCBUserBreak, + UCBGetNamedPreferences, + UCBStorePluginData, + UCBGetPluginData, + UCBSetModDate, + UCBAddProjectEntry, + UCBCreateNewTextDocument, + UCBAllocateMemory, + UCBFreeMemory, + UCBAllocMemHandle, + UCBFreeMemHandle, + UCBGetMemHandleSize, + UCBResizeMemHandle, + UCBLockMemHandle, + UCBUnlockMemHandle, + reinterpret_cast(UCBSecretAttachHandle), + reinterpret_cast(UCBSecretDetachHandle), + reinterpret_cast(UCBSecretPeekHandle), + NULL, + NULL, + NULL, + NULL, + NULL, + UCBGetTargetName, + UCBCacheAccessPathList, + UCBPreDialog, + UCBPostDialog, + UCBPreFileAction, + UCBPostFileAction, + UCBCheckoutLicense, + UCBCheckinLicense, + UCBResolveRelativePath +}; + +static CWIDEInfo sIDEInfo = { + 3, 3, 0, 0, 10 +}; + +CWPluginPrivateContext::CWPluginPrivateContext(SInt32 thePluginType, SInt32 totalSize) { + if (totalSize <= 0) + totalSize = sizeof(CWPluginPrivateContext); + memset(this, 0, totalSize); + + shellSignature = CWFOURCHAR('C','W','I','E'); + pluginType = thePluginType; + shellInfo = &sIDEInfo; + callbacks = &sBasePluginCallbacks; +} + +CWPluginPrivateContext::~CWPluginPrivateContext() { + int x; + + if (accessPathList) { + if (accessPathList->userPathCount) { + for (x = 0; x < accessPathList->userPathCount; x++) { + if (accessPathList->userPaths[x].subdirectories) + xfree(accessPathList->userPaths[x].subdirectories); + } + } + if (accessPathList->systemPathCount) { + for (x = 0; x < accessPathList->systemPathCount; x++) { + if (accessPathList->systemPaths[x].subdirectories) + xfree(accessPathList->systemPaths[x].subdirectories); + } + } + xfree(accessPathList->userPaths); + xfree(accessPathList->systemPaths); + xfree(accessPathList); + accessPathList = NULL; + } +} diff --git a/command_line/CmdLine/Src/Callbacks/CLParserCallbacks_v1.cpp b/command_line/CmdLine/Src/Callbacks/CLParserCallbacks_v1.cpp index 5dbd4d8..19b7dab 100644 --- a/command_line/CmdLine/Src/Callbacks/CLParserCallbacks_v1.cpp +++ b/command_line/CmdLine/Src/Callbacks/CLParserCallbacks_v1.cpp @@ -1,13 +1,220 @@ -/* - 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 +#include "cmdline.h" +#include "plugin_internal.h" + +extern char STSbuf[256]; + +CWResult UCBParserAddAccessPath(CWPluginContext context, const CWNewAccessPathInfo *api) { + OSSpec oss; + Paths *paths; + Path *path; + int err; + + if ((err = OS_FSSpec_To_OSSpec(&api->pathSpec, &oss))) { + context->callbackOSError = OS_MacError(err); + return cwErrInvalidParameter; + } + + if (optsCmdLine.verbose > 2) + CLReport(CLStr77, " search path", OS_PathSpecToString(&oss.path, STSbuf, sizeof(STSbuf))); + + if ((api->type & cwAccessPathTypeFlag1) == 0) + paths = &gTarg->sysPaths; + else + paths = &gTarg->userPaths; + path = Path_New(&oss.path); + + path->flags = api->type & cwAccessPathTypeFlag2; + if ((api->position >= 0) ? (Paths_InsertPath(paths, api->position, path) == 0) : (Paths_AddPath(paths, path) == 0)) + return cwErrRequestFailed; + + if (api->recursive) { + Paths_GatherRecurse(path); + if (CheckForUserBreak()) + return cwErrUserCanceled; + } + + if (!(api->type & cwAccessPathTypeFlag1)) + static_cast(context->shellContext)->systemAccessPathsChanged = 1; + else + static_cast(context->shellContext)->userAccessPathsChanged = 1; + + return cwNoErr; +} + +CWResult UCBParserSwapAccessPaths(CWPluginContext context) { + Path *tmp; + UInt16 idx; + + for (idx = 0; idx < Paths_Count(&gTarg->sysPaths); idx++) { + tmp = Paths_GetPath(&gTarg->sysPaths, idx); + if (!(tmp->flags & cwAccessPathTypeFlag2)) { + Paths_AddPath(&gTarg->userPaths, tmp); + Paths_RemovePath(&gTarg->sysPaths, idx); + idx--; + } + } + + return cwNoErr; +} + +int (*PrefPanelsChangedCallback)(const char *); + +CWResult UCBParserSetNamedPreferences(CWPluginContext context, const char *panelName, Handle paneldata) { + PrefPanel *panel; + + panel = Prefs_FindPanel(panelName); + if (!panel) { + panel = PrefPanel_New(panelName, *paneldata, GetHandleSize(paneldata)); + if (!panel || !Prefs_AddPanel(panel)) + return cwErrRequestFailed; + } else { + if (!PrefPanel_PutHandle(panel, paneldata)) + return cwErrRequestFailed; + } + + if (PrefPanelsChangedCallback) + PrefPanelsChangedCallback(panelName); + + return cwNoErr; +} + +CWResult UCBParserSetFileOutputName(CWPluginContext context, SInt32 position, short which, const char *outfilename) { + if (position < 0) + return cwErrInvalidParameter; + + File *file = Files_GetFile(&gTarg->files, position); + if (!file) + return cwErrUnknownFile; + + if (file->outfileowner) + CLReportError(CLStr103, file->srcfilename, file->outfilename); + + strcpy(file->outfilename, outfilename); + if (which == 1) + file->outfileowner = CmdLineStageMask_Cg; + else if (which == 2) + file->outfileowner = CmdLineStageMask_Pp; + else if (which == 3) + file->outfileowner = CmdLineStageMask_Ds; + else + return cwErrInvalidParameter; + + return cwNoErr; +} + +CWResult UCBParserSetOutputFileDirectory(CWPluginContext context, const CWFileSpec *idefss) { + OSSpec fss; + int err; + + if ((err = OS_FSSpec_To_OSSpec(idefss, &fss))) { + context->callbackOSError = OS_MacError(err); + return cwErrInvalidParameter; + } + + gTarg->outputDirectory = fss.path; + context->outputFileDirectory = *idefss; + + return cwNoErr; +} + +CWResult UCBParserAddOverlay1Group(CWPluginContext context, const char *name, const CWAddr64 *addr, SInt32 *newGroupNumber) { + if (gTarg->linkmodel != LinkModel2) + return cwErrInvalidCallback; + + OvlGroup *grp; + OvlAddr oaddr; + oaddr.hi = addr->hi; + oaddr.lo = addr->lo; + + grp = OvlGroup_New(name, oaddr); + if (!grp) + return cwErrRequestFailed; + if (!Overlays_AddOvlGroup(&gTarg->linkage.overlays, grp, newGroupNumber)) + return cwErrRequestFailed; + + ++context->numOverlayGroups; + if (optsCmdLine.verbose > 2) + CLReport(CLStr79, name, oaddr.hi, oaddr.lo); + + return cwNoErr; +} + +CWResult UCBParserAddOverlay1(CWPluginContext context, const char *name, SInt32 groupNumber, SInt32 *newOverlayNumber) { + if (gTarg->linkmodel != LinkModel2) + return cwErrInvalidCallback; + + OvlGroup *grp; + Overlay *ovl; + + grp = Overlays_GetOvlGroup(&gTarg->linkage.overlays, groupNumber); + if (!grp) + return cwErrRequestFailed; + ovl = Overlay_New(name); + if (!ovl) + return cwErrOutOfMemory; + if (!OvlGroup_AddOverlay(grp, ovl, newOverlayNumber)) + return cwErrOutOfMemory; + + if (optsCmdLine.verbose > 2) + CLReport(CLStr78, name, grp->name); + + return cwNoErr; +} + +CWResult UCBParserAddSegment(CWPluginContext context, const char *name, short attrs, SInt32 *newSegmentNumber) { + if (gTarg->linkmodel != LinkModel1) + return cwErrInvalidCallback; + + Segment *seg; + UInt16 index; + + seg = Segment_New(name, attrs); + if (!Segments_AddSegment(&gTarg->linkage.segs, seg, &index)) + return cwErrRequestFailed; + + *newSegmentNumber = index; + return cwNoErr; +} + +CWResult UCBParserSetSegment(CWPluginContext context, SInt32 segmentNumber, const char *name, short attrs) { + if (gTarg->linkmodel != LinkModel1) + return cwErrInvalidCallback; + + Segment *seg = Segments_GetSegment(&gTarg->linkage.segs, segmentNumber); + if (!seg) + return cwErrUnknownSegment; + + strncpy(seg->name, name, sizeof(seg->name)); + seg->name[sizeof(seg->name) - 1] = 0; + seg->attrs = attrs; + + return cwNoErr; +} + +static CWParserCallbacks parser_cb = { + UCBParserAddAccessPath, + UCBParserSwapAccessPaths, + UCBParserSetNamedPreferences, + UCBParserSetFileOutputName, + UCBParserSetOutputFileDirectory, + UCBParserAddOverlay1Group, + UCBParserAddOverlay1, + UCBParserAddSegment, + UCBParserSetSegment +}; + +CWParserContext::CWParserContext() : CWPluginPrivateContext(CWDROPINPARSERTYPE, -1) { + args = NULL; + os = 0; + cpu = 0; + numPlugins = 0; + plugins = NULL; + numPanels = 0; + panelNames = NULL; + panel_args = NULL; + plugin_args = NULL; + callbacks = &parser_cb; +} + +CWParserContext::~CWParserContext() { +} diff --git a/command_line/CmdLine/Src/Clients/CLStaticMain.c b/command_line/CmdLine/Src/Clients/CLStaticMain.c index cecab30..871dcef 100644 --- a/command_line/CmdLine/Src/Clients/CLStaticMain.c +++ b/command_line/CmdLine/Src/Clients/CLStaticMain.c @@ -1,6 +1,21 @@ -#include "mwcc_decomp.h" +#include "cmdline.h" -int main(int argc, const char **argv) { +extern const char *CMDLINE_BUILD_TIME; +extern const char *CMDLINE_BUILD_DATE; + +// Glue functions +extern int RegisterStaticParserPlugins(); +extern int RegisterStaticParserResources(); + +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(); + +extern int RegisterStaticParserToolInfo(); + +int main(int argc, char **argv) { OSType cpu; OSType os; OSType lang; diff --git a/command_line/CmdLine/Src/Clients/ClientGlue.c b/command_line/CmdLine/Src/Clients/ClientGlue.c index a1b40b1..6bc0508 100644 --- a/command_line/CmdLine/Src/Clients/ClientGlue.c +++ b/command_line/CmdLine/Src/Clients/ClientGlue.c @@ -1,4 +1,4 @@ -#include "mwcc_decomp.h" +#include "cmdline.h" int RegisterResource(const char *name, SInt16 rsrcid, const char **list) { Handle h; @@ -42,7 +42,7 @@ void SetPluginType(OSType lang, OSType type) { clState.plugintype = type; } -int CmdLine_Initialize(int argc, const char **argv, const char *builddate, const char *buildtime) { +int CmdLine_Initialize(int argc, 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); diff --git a/command_line/CmdLine/Src/Envir/CLErrors.c b/command_line/CmdLine/Src/Envir/CLErrors.c index 76ff06f..591e30d 100644 --- a/command_line/CmdLine/Src/Envir/CLErrors.c +++ b/command_line/CmdLine/Src/Envir/CLErrors.c @@ -1,37 +1,114 @@ -#include "mwcc_decomp.h" - -static void CLGetErrorString(SInt16 errid, char *buffer) { +#include "cmdline.h" +static char *CLGetErrorString(SInt16 errid, char *buffer) { + getindstring(buffer, 12000, errid); + strcat(buffer, "\n"); + return buffer; } static void CLMessageReporter(int flags, SInt16 errid, va_list va) { - + static char stmsg[256]; + static char stbuf[256]; + char *ptr; + + CLGetErrorString(errid, stmsg); + ptr = mvprintf(stbuf, sizeof(stbuf), stmsg, va); + + CLStyledMessageDispatch( + NULL, + NULL, + 0, + (flags == messagetypeError) ? CLStyledMessageDispatch_Type3 : (flags == messagetypeWarning) ? CLStyledMessageDispatch_Type2 : CLStyledMessageDispatch_Type5, + "%", + ptr); + + if (ptr != stbuf) + free(ptr); } void CLReportError(SInt16 errid, ...) { - + va_list va; + va_start(va, errid); + CLMessageReporter(messagetypeError, errid, va); + va_end(va); } void CLReportWarning(SInt16 errid, ...) { - + va_list va; + va_start(va, errid); + CLMessageReporter(messagetypeWarning, errid, va); + va_end(va); } void CLReport(SInt16 errid, ...) { - + va_list va; + va_start(va, errid); + CLMessageReporter(messagetypeInfo, errid, va); + va_end(va); } void CLReportOSError(SInt16 errid, int err, ...) { + char *txt; + const char *oserr; + char mybuf[256]; + char myerr[256]; + va_list va; + + va_start(va, err); + txt = mvprintf(mybuf, sizeof(mybuf), CLGetErrorString(errid, myerr), va); + va_end(va); + oserr = OS_GetErrText(err); + CLReportError(99, txt, oserr, err); + + if (txt != mybuf) + free(txt); } void CLReportCError(SInt16 errid, int err_no, ...) { + char *txt; + const char *serr; + char mybuf[256]; + char myerr[256]; + va_list va; + + va_start(va, err_no); + txt = mvprintf(mybuf, sizeof(mybuf), CLGetErrorString(errid, myerr), va); + va_end(va); + + serr = strerror(err_no); + CLReportError(100, txt, serr, err_no); + if (txt != mybuf) + free(txt); } void CLInternalError(const char *file, int line, const char *format, ...) { + char mybuf[256]; + char *txt; + va_list va; + va_start(va, format); + txt = mvprintf(mybuf, sizeof(mybuf), format, va); + va_end(va); + CLPrintErr("INTERNAL ERROR [%s:%d]:\n%s\n", file, line, txt); + + if (txt != mybuf) + free(txt); } void CLFatalError(const char *format, ...) { + char mybuf[256]; + char *txt; + va_list va; + + va_start(va, format); + txt = mvprintf(mybuf, sizeof(mybuf), format, va); + va_end(va); + CLPrintErr("FATAL ERROR:\n%s\n", txt); + + if (txt != mybuf) + free(txt); + exit(-123); } diff --git a/command_line/CmdLine/Src/Envir/CLIO.c b/command_line/CmdLine/Src/Envir/CLIO.c index e832de5..70ba9ae 100644 --- a/command_line/CmdLine/Src/Envir/CLIO.c +++ b/command_line/CmdLine/Src/Envir/CLIO.c @@ -1,79 +1,251 @@ -#include "mwcc_decomp.h" +#include "cmdline.h" +#include +#include +#include +#include + +extern char STSbuf[256]; + +static int ioLineNum; +static Boolean printedAnything; +static char arrowBuf[256]; +static Boolean newErr; +static Boolean newSrc; +static Boolean srcIsErr; +static OSSpec errSpec; +static OSSpec srcSpec; +static Boolean validErr; +static Boolean validSrc; +static SInt32 lastPrintingPlugin; +static Boolean ioInHelp; +static Boolean ioPiping; static void catchinterrupt() { - + clState.userBreak = 1; } static void SetupConsoleInfo() { - + struct winsize ws; + struct stat st; + + signal(SIGINT, catchinterrupt); + ioPiping = 0; + + fstat(stdout->_file, &st); + if (st.st_mode & 0x1000) + ioPiping = 1; + fstat(stderr->_file, &st); + if (st.st_mode & 0x1000) + ioPiping = 1; + + if (ioPiping) { + ws.ws_row = 0; + ws.ws_col = 80; + } else if (ioctl(stdout->_file, TIOCGWINSZ, &ws) < 0) { + ioPiping = 1; + ws.ws_row = 0; + ws.ws_col = 80; + } + + optsEnvir.rows = ws.ws_row; + optsEnvir.cols = ws.ws_col; + if (optsEnvir.cols > 256) + optsEnvir.cols = 256; } static void Crash() { - + *((unsigned char *) NULL) = 0; } void SetupDebuggingTraps() { - + signal(SIGABRT, Crash); } Boolean IO_Initialize() { + ioPiping = 0; + ioInHelp = 0; + ioLineNum = 0; + SetupConsoleInfo(); + if (ioPiping) { + setvbuf(stdout, NULL, 0, 1024); + setvbuf(stderr, NULL, 0, 1024); + } else { + setvbuf(stdout, NULL, 1, 1024); + setvbuf(stderr, NULL, 1, 1024); + } + + InitWorking(); + return 1; } Boolean IO_Terminate() { - + if (ioInHelp) + IO_HelpTerminate(); + TermWorking(); + return 1; } Boolean IO_HelpInitialize() { - + ioInHelp = 1; + return 1; } Boolean IO_HelpTerminate() { + ioInHelp = 0; + return 1; +} + +static Boolean SendHandleToFile(FILE *file, Handle text, SInt32 size) { + Boolean ret; + char *ptr; + char *lineEnd; + char *end; -} + if (file != stdout && file != stderr) + setvbuf(file, NULL, 0, 1024); -static Boolean SendHandleToFile(FILE *file, OSHandle *text) { + HLock(text); + ptr = *text; + if (size && ptr[size - 1] == 0) + size--; + if (size <= 0) { + ret = 1; + } else { + end = ptr + size; + while (ptr < end) { + lineEnd = ptr; + while (lineEnd < end && *lineEnd != '\n' && *lineEnd != '\r') + lineEnd++; + + if (lineEnd - ptr) { + if (fwrite(ptr, lineEnd - ptr, 1, file) != 1) { + CLReportCError(10, errno); + ret = 0; + goto fail; + } + } + + if (CheckForUserBreak()) { + ret = 1; + goto fail; + } + + // I have a hunch that this "\n" might be a define + if (fwrite("\n", strlen("\n"), 1, file) != 1) { + CLReportCError(10, errno); + ret = 0; + goto fail; + } + + if (lineEnd < end && *(lineEnd++) == '\r' && *lineEnd == '\n') + ++lineEnd; + ptr = lineEnd; + } + ret = 1; + } + +fail: + HUnlock(text); + fflush(file); + + if (file != stdout && file != stderr) + setvbuf(file, NULL, 2, 1024); + + return ret; } -void FixHandleForIDE(OSHandle *text) { +void FixHandleForIDE(Handle text, UInt32 size) { + char *ptr; + HLock(text); + for (ptr = *text; ptr < (*text + size); ptr++) { + if (*ptr == '\r') + *ptr = '\n'; + } + HUnlock(text); } -Boolean ShowHandle(OSHandle *text, Boolean decorate) { +Boolean ShowHandle(Handle text, UInt32 size, Boolean decorate) { + static const char *border = "===============\n"; + + if (decorate) + fprintf(stdout, border); + if (!SendHandleToFile(stdout, text, size)) + return 0; + if (decorate) + fprintf(stdout, border); + fflush(stdout); + return 1; } -Boolean WriteHandleToFile(OSSpec *spec, OSHandle *text, CWDataType creator, CWDataType type) { +Boolean WriteHandleToFile(OSSpec *spec, Handle text, UInt32 size, OSType creator, OSType type) { + FILE *file; + char path[256]; + OS_SpecToString(spec, path, sizeof(path)); + file = fopen(path, "w+b"); + if (!file) { + CLReportCError(8, errno, path); + return 0; + } + + SendHandleToFile(file, text, size); + fclose(file); + + OS_SetMacFileCreatorAndType(spec, creator, type); + return 1; } Boolean WriteBinaryHandleToFile(OSSpec *spec, CWDataType maccreator, CWDataType mactype, OSHandle *text) { + int err; + OSFileHandle file; + if ((err = OS_NewFileHandle(spec, text, 1, &file)) || (err = OS_FreeFileHandle(&file)) || (err = OS_SetMacFileCreatorAndType(spec, maccreator, mactype))) { + CLReportOSError(8, err, OS_SpecToString(spec, STSbuf, sizeof(STSbuf))); + return 0; + } + + return 1; } -Boolean AppendHandleToFile(OSSpec *spec, OSHandle *text, CWDataType maccreator, CWDataType mactype) { +Boolean AppendHandleToFile(OSSpec *spec, Handle text, UInt32 size, CWDataType maccreator, CWDataType mactype) { + FILE *file; + char path[256]; -} + OS_SpecToString(spec, path, sizeof(path)); + file = fopen(path, "a+b"); + if (!file) { + CLReportCError(8, errno, path); + return 0; + } -void InitWorking() { + SendHandleToFile(file, text, size); + fclose(file); + OS_SetMacFileCreatorAndType(spec, maccreator, mactype); + return 1; } -void ShowWorking() { +void InitWorking() { +} +void ShowWorking(int x) { } void TermWorking() { - } static void ProgressFunction(const char *functionname) { - + if (optsCmdLine.verbose) + CLReport(7, functionname); } Boolean CheckForUserBreak() { - + ShowWorking(4); + return clState.userBreak; } typedef struct { @@ -81,90 +253,650 @@ typedef struct { int pos; int maxlen; SInt16 col; - Boolean origina; + Boolean original; char *newline; } UnkCLIOStruct; +// unknown names for these inlines +inline void appendText(UnkCLIOStruct *f, const char *str) { + int len = strlen(str); + + if (f->pos + len >= f->maxlen) { + f->maxlen = f->maxlen * 2 + len; + if (f->original) { + char *oldbuf; + oldbuf = f->buffer; + f->buffer = xmalloc("message buffer", f->maxlen); + memcpy(f->buffer, oldbuf, f->pos); + } else { + f->buffer = xrealloc("message buffer", f->original ? NULL : f->buffer, f->maxlen); + } + f->original = 0; + } + + memcpy(f->buffer + f->pos, str, len); + f->pos += len; + f->col += len; +} +inline void appendChar(UnkCLIOStruct *f, char c) { + if (f->pos >= f->maxlen) { + f->maxlen *= 2; + if (f->original) { + char *oldbuf = f->buffer; + f->buffer = xmalloc("message buffer", f->maxlen); + memcpy(f->buffer, oldbuf, f->pos); + } else { + f->buffer = xrealloc("message buffer", f->buffer, f->maxlen); + } + f->original = 0; + } + + f->buffer[f->pos++] = c; + f->col++; +} + static void StartLine(UnkCLIOStruct *f) { + f->col = 0; + if (!optsEnvir.underIDE && f->newline) + appendText(f, f->newline); +} +inline void newLine(UnkCLIOStruct *f) { + if (f->newline) + appendChar(f, '\n'); + else + appendChar(f, ' '); + StartLine(f); } static void WrapText(UnkCLIOStruct *f) { - + int wrapped; + char wrapbuf[256]; + char c; + + wrapped = 0; + if (optsCmdLine.noWrapOutput) + return; + if (!f->newline) + return; + if (strlen(f->newline) > optsEnvir.cols / 2) + return; + + while (wrapped < (optsEnvir.cols - 1) && f->col > strlen(f->newline)) { + c = f->buffer[f->pos - 1]; + if (c == ' ') break; + if (c == '/') break; + if (c == '-') break; + wrapbuf[wrapped] = c; + f->pos = f->pos - 1; + f->col = f->col - 1; + wrapped++; + } + + if (f->col <= strlen(f->newline)) { + while (f->col < (optsEnvir.cols - 1) && wrapped > 0) { + appendChar(f, wrapbuf[--wrapped]); + } + } + + newLine(f); + while (wrapped > 0 && f->maxlen > 0) { + appendChar(f, wrapbuf[--wrapped]); + } } static char *IO_VFormatText(char *buffer, SInt32 size, char *newline, const char *format, va_list ap) { - + UnkCLIOStruct f; + char *arg; + + f.buffer = buffer; + f.pos = 0; + f.maxlen = size; + f.col = 0; + f.original = 1; + f.newline = newline; + StartLine(&f); + + while (*format && f.maxlen > 0) { + if (*format == '%') { + arg = va_arg(ap, char *); + while (*arg && f.maxlen > 0) { + if (*arg == '\r' || *arg == '\n') { + newLine(&f); + arg++; + } else if (*arg == '\t') { + if (f.maxlen > 0) { + do { + appendChar(&f, ' '); + } while (f.col & 7); + } + arg++; + } else { + appendChar(&f, *(arg++)); + if (!optsCmdLine.noWrapOutput && f.newline && f.col >= optsEnvir.cols - 1) + WrapText(&f); + } + } + format++; + } else if (*format == '\r' || *format == '\n') { + format++; + newLine(&f); + } else { + appendChar(&f, *(format++)); + if (!optsCmdLine.noWrapOutput && f.col >= optsEnvir.cols - 1) + WrapText(&f); + } + } + + if (f.newline) { + if (f.col == strlen(f.newline)) { + f.pos -= f.col; + f.col = 0; + } + } + + appendChar(&f, 0); + + return f.buffer; } 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) { - + va_list ap; + char *ret; + + va_start(ap, format); + ret = IO_VFormatText(buffer, size, newline, format, ap); + va_end(ap); + + return ret; +} + +// TODO unify me with the one in the header +enum { + Msg_Note = 1, + Msg_Warning = 2, + Msg_Error = 3, + Msg_Alert = 4, + Msg_Status = 5 +}; +void CLPrintDispatch(int unk, SInt16 msgtype, const char *message) { + FILE *out; + const char *ptr; + const char *nptr; + + if (optsCmdLine.stderr2stdout == 1 || msgtype == Msg_Note || msgtype == Msg_Status) { + out = stdout; + } else if (msgtype == Msg_Warning || msgtype == Msg_Error || msgtype == Msg_Alert) { + out = stderr; + } else { +#line 847 + OPTION_ASSERT(0); + } + + if (!printedAnything && !ioPiping) { + printedAnything = 1; + ioLineNum = 0; + } + + ptr = message; + while (*ptr) { + nptr = ptr; + while (*nptr && *nptr != '\n' && *nptr != '\r') + ++nptr; + + if (nptr - ptr) { + if (fwrite(ptr, nptr - ptr, 1, out) != 1) + clState.userBreak = 1; + } + + if (*nptr) { + ioLineNum++; + fwrite("\n", strlen("\n"), 1, out); + if (*nptr == '\r') + nptr++; + if (*nptr == '\n') + nptr++; + if (nptr[0] && !nptr[1] && (nptr[0] == '\n' || nptr[0] == '\r')) + nptr++; + } + + ptr = nptr; + } + + if (out == stdout && optsCmdLine.verbose > 1) + fflush(out); } static void GetFileInfo(MessageRef *ref) { - + if (ref) { + srcIsErr = OS_EqualSpec(&ref->sourcefile, &ref->errorfile); + if (!validSrc || !OS_EqualSpec(&ref->sourcefile, &srcSpec)) { + newSrc = 1; + srcSpec = ref->sourcefile; + validSrc = 1; + } else { + newSrc = 0; + } + if (!validErr || !OS_EqualSpec(&ref->errorfile, &errSpec)) { + newErr = 1; + errSpec = ref->errorfile; + validErr = 1; + } else { + newErr = 0; + } + } } static char *Arrows(MessageRef *ref) { - + int start; + int len; + + arrowBuf[0] = 0; + start = ref->tokenoffset; + start %= optsEnvir.cols; + if (start >= 0 && start < sizeof(arrowBuf)) { + len = ref->tokenlength; + if (len + start > sizeof(arrowBuf)) + len = sizeof(arrowBuf) - start; + if (len == 0) + len = 1; + memset(arrowBuf, ' ', start); + memset(arrowBuf + start, '^', len); + arrowBuf[start + len] = 0; + } + + return arrowBuf; } static Boolean IsLikelyAnImporter(Plugin *plugin) { + if (Plugin_CL_GetObjectFlags(plugin)->flags & 0x80000000) + return 0; + return plugin != Plugins_CL_MatchTarget(NULL, gTarg->cpu, gTarg->os, clState.plugintype, clState.language); } static char *GuessTool(Plugin *plugin) { - + if (plugin) { + DropInFlags *df = Plugin_GetDropInFlags(plugin); + switch (df->dropintype) { + case CWDROPINDRIVERTYPE: return "Driver"; + case CWDROPINPARSERTYPE: return "Usage"; + case CWDROPINCOMPILERTYPE: + if (df->edit_language == Lang_C_CPP || df->edit_language == Lang_Pascal) + return "Compiler"; + else if (df->edit_language == CWFOURCHAR('A','s','m',' ')) + return "Assembler"; + else if (IsLikelyAnImporter(plugin)) + return "Importer"; + else + return "Compiler"; + case CWDROPINLINKERTYPE: + return "Linker"; + } + } + return "Driver"; } 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, ...) { - + if (plugin) { + DropInFlags *df = Plugin_GetDropInFlags(plugin); + switch (df->dropintype) { + case CWDROPINPARSERTYPE: return "parsing"; + case CWDROPINCOMPILERTYPE: return "compiling"; + case CWDROPINLINKERTYPE: return "linking"; + } + } + return "processing"; +} + +static const char *msgnames[6] = { + "", + "Note", + "Warning", + "Error", + "Alert", + "Status" +}; + +static const char *msgnames_gcc[6] = { + "", + " note", + " warning", + "", + " alert", + " status" +}; + +static void styledMessage_MPW(Plugin *plugin, MessageRef *ref, SInt32 errorNumber, SInt16 msgType, const char *format, va_list va) { + char msgBuf[256]; + char *msgPtr; + + msgPtr = IO_VFormatText(msgBuf, sizeof(msgBuf), "# ", format, va); + if (msgType != Msg_Status) + CLPrintType(msgType, "### %s %s %s:\n", clState.programName, GuessTool(plugin), msgnames[msgType]); + + if (ref) { + CLPrintType(msgType, "#\t%s\n", ref->sourceline); + CLPrintType(msgType, "#\t%s\n", Arrows(ref)); + } + + CLPrintDispatch(0, msgType, msgPtr); + + if (ref) { + CLPrintType(msgType, "#----------------------------------------------------------\n"); + CLPrintType(msgType, " File \"%s\"; Line %d\n", OS_SpecToString(&ref->errorfile, STSbuf, sizeof(STSbuf)), ref->linenumber); + GetFileInfo(ref); + if (!srcIsErr) + CLPrintType(msgType, "#\twhile %s \"%s\"\n", GuessDoing(plugin), OS_SpecToString(&ref->sourcefile, STSbuf, sizeof(STSbuf))); + CLPrintType(msgType, "#----------------------------------------------------------\n"); + } + + if (msgPtr != msgBuf) + free(msgPtr); +} + +static void styledMessage_Default(Plugin *plugin, MessageRef *ref, SInt32 errorNumber, SInt16 msgType, const char *format, va_list va) { + char lineBuf[320]; + char msgBuf[256]; + char *msgPtr; + char *ptr; + + msgPtr = IO_VFormatText(msgBuf, sizeof(msgBuf), "# ", format, va); + if (ref) { + CLPrintType(msgType, "### %s %s:\n", clState.programName, GuessTool(plugin)); + } else if (msgType != Msg_Status) { + CLPrintType(msgType, "### %s %s %s:\n", clState.programName, GuessTool(plugin), msgnames[msgType]); + } + + if (ref) { + GetFileInfo(ref); + if (newErr || (newSrc && srcIsErr)) { + if (srcIsErr) { + sprintf(lineBuf, "#%8s: %s\n", "File", OS_SpecToStringRelative(&errSpec, NULL, STSbuf, sizeof(STSbuf))); + } else { + sprintf(lineBuf, "#%8s: %s\n", "In", OS_SpecToStringRelative(&errSpec, NULL, STSbuf, sizeof(STSbuf))); + } + CLPrintDispatch(0, msgType, lineBuf); + } + if (newSrc && !srcIsErr) { + sprintf(lineBuf, "# %7s: %s\n", "From", OS_SpecToStringRelative(&srcSpec, NULL, STSbuf, sizeof(STSbuf))); + CLPrintDispatch(0, msgType, lineBuf); + } + if (newErr || newSrc) { + ptr = &lineBuf[2]; + while (*ptr && *ptr != '\n') + *(ptr++) = '-'; + *ptr = 0; + if (ptr - lineBuf >= optsEnvir.cols - 1) + lineBuf[optsEnvir.cols - 1] = 0; + strcat(lineBuf, "\n"); + CLPrintDispatch(0, msgType, lineBuf); + } + CLPrintType(msgType, "#%8d: %s\n", ref->linenumber, ref->sourceline); + CLPrintType(msgType, "#%8s: %s\n", msgnames[msgType], Arrows(ref)); + } + + CLPrintDispatch(0, msgType, msgPtr); + if (msgPtr != msgBuf) + free(msgPtr); +} + +static void styledMessage_Terse(Plugin *plugin, MessageRef *ref, SInt32 errorNumber, SInt16 msgType, const char *format, va_list va) { + char *msg; + char *ptr; + char msgBuf[256]; + char *msgPtr; + char header[256]; + char *headPtr; + char errBuf[256]; + char *errPtr; + + if (ref) { + if (msgnames_gcc[msgType][0]) { + headPtr = mprintf( + header, sizeof(header), + "%s:%d:%s: ", + OS_SpecToStringRelative(&ref->errorfile, NULL, STSbuf, sizeof(STSbuf)), + ref->linenumber, + msgnames_gcc[msgType] + ); + } else { + headPtr = mprintf( + header, sizeof(header), + "%s:%d: ", + OS_SpecToStringRelative(&ref->errorfile, NULL, STSbuf, sizeof(STSbuf)), + ref->linenumber + ); + } + } else if (msgType != Msg_Status) { + headPtr = mprintf(header, sizeof(header), "%s: ", clState.programName); + } else { + header[0] = 0; + headPtr = header; + } + + msgPtr = IO_VFormatText(msgBuf, sizeof(msgBuf), headPtr, format, va); + if ((strstr(msgPtr, "#warning") || strstr(msgPtr, "#error")) && ref->sourceline[0]) { + errPtr = IO_FormatText(errBuf, sizeof(errBuf), headPtr, "%", ref->sourceline); + } else { + errPtr = 0; + } + + if (headPtr != header) + free(headPtr); + + msg = msgPtr; + while (*msg) { + ptr = msg; + while (*ptr && *ptr != '\n') + ptr++; + + CLPrintType(msgType, "%.*s\n", ptr - msg, msg); + if (errPtr) { + CLPrintType(msgType, "%s\n", errPtr); + if (errPtr != errBuf) + free(errPtr); + errPtr = NULL; + } + + if (*ptr) + msg = ptr + 1; + else + msg = ptr; + } + + if (msgPtr != msgBuf) + free(msgPtr); +} + +static void styledMessage_IDE(Plugin *plugin, MessageRef *ref, SInt32 errorNumber, SInt16 msgType, const char *format, va_list va) { + char msgBuf[256]; + char *msgPtr; + SInt16 oldCols; + + oldCols = optsEnvir.cols; + msgPtr = IO_VFormatText(msgBuf, sizeof(msgBuf), " ", format, va); + optsEnvir.cols = oldCols; + + CLPrintType(msgType, "%8s : %s\n", msgnames[msgType], msgPtr + 11); + if (msgPtr != msgBuf) + free(msgPtr); + + if (ref) { + msgPtr = IO_FormatText(msgBuf, sizeof(msgBuf), "\t", "%", ref->sourceline); + CLPrintType(msgType, "%s line %d%s\n", OS_SpecToStringRelative(&ref->errorfile, NULL, STSbuf, sizeof(STSbuf)), ref->linenumber, msgPtr); + if (msgPtr != msgBuf) + free(msgPtr); + } +} + +static void styledMessage_Parseable(Plugin *plugin, MessageRef *ref, SInt32 errorNumber, SInt16 msgType, const char *format, va_list va) { + char msgBuf[256]; + char *msgPtr; + + CLPrintType(msgType, "%s|%s|%s\n", clState.programName, GuessTool(plugin), msgnames[msgType]); + if (ref) { + CLPrintType( + msgType, + "(%s|%d|%d|%d|%d|%d)\n", + OS_SpecToString(&ref->errorfile, STSbuf, sizeof(STSbuf)), + ref->linenumber, + ref->tokenoffset, + ref->tokenlength, + ref->selectionoffset, + ref->selectionlength + ); + CLPrintType(msgType, "=%s\n", ref->sourceline); + } + + msgPtr = IO_VFormatText(msgBuf, sizeof(msgBuf), ">", format, va); + CLPrintType(msgType, "%s\n", msgPtr); + if (msgPtr != msgBuf) + free(msgPtr); +} + +void CLPrintType(SInt16 msgtype, const char *format, ...) { + char printbuffer[256]; + char *ptr; + va_list va; + + va_start(va, format); + ptr = mvprintf(printbuffer, sizeof(printbuffer), format, va); + va_end(va); + CLPrintDispatch(0, msgtype, ptr); + if (ptr != printbuffer) + free(ptr); } void CLPrint(const char *format, ...) { + char printbuffer[256]; + char *ptr; + va_list va; + va_start(va, format); + ptr = mvprintf(printbuffer, sizeof(printbuffer), format, va); + va_end(va); + CLPrintDispatch(0, Msg_Note, ptr); + if (ptr != printbuffer) + free(ptr); } void CLPrintWarning(const char *format, ...) { + char printbuffer[256]; + char *ptr; + va_list va; + va_start(va, format); + ptr = mvprintf(printbuffer, sizeof(printbuffer), format, va); + va_end(va); + CLPrintDispatch(0, Msg_Warning, ptr); + if (ptr != printbuffer) + free(ptr); } void CLPrintErr(const char *format, ...) { + char printbuffer[256]; + char *ptr; + va_list va; + va_start(va, format); + ptr = mvprintf(printbuffer, sizeof(printbuffer), format, va); + va_end(va); + CLPrintDispatch(0, Msg_Error, ptr); + if (ptr != printbuffer) + free(ptr); } static void FixupMessageRef(MessageRef *ref) { - -} - -SInt16 CLStyledMessageDispatch(Plugin *plugin, MessageRef *ref, SInt32 errorNumber, SInt16 msgType) { - + char *bol; + char *eol; + int len; + int scan; + + if (ref->sourceline && *ref->sourceline) { + bol = ref->sourceline + ref->tokenoffset; + eol = ref->sourceline + ref->tokenoffset + ref->tokenlength - 1; + if (eol < bol) + eol = bol; + while (bol > ref->sourceline && bol[-1] != '\r') + bol--; + while (*eol && *eol != '\r' && *eol != '\n') + eol++; + + len = eol - bol; + ref->sourceline = xmalloc("text buffer", len + 1); + strncpy(ref->sourceline, bol, len); + ref->sourceline[len] = 0; + + for (scan = 0; scan < len; scan++) { + if (ref->sourceline[scan] < ' ' || ref->sourceline[scan] >= 127) + ref->sourceline[scan] = ' '; + } + } else { + ref->sourceline = 0; + } +} + +SInt16 CLStyledMessageDispatch(Plugin *plugin, MessageRef *ref, SInt32 errorNumber, SInt16 msgType, const char *format, ...) { + va_list va; + MessageRef myref; + UInt32 ptype; + + if (msgType == Msg_Warning) { + ptype = plugin ? Plugin_GetPluginType(plugin) : CWDROPINDRIVERTYPE; + if (optsCmdLine.noWarnings) + return 0; + if ((ptype == CWDROPINDRIVERTYPE || ptype == CWDROPINPARSERTYPE) && optsCmdLine.noCmdLineWarnings) + return 0; + if (optsCmdLine.warningsAreErrors) + msgType = Msg_Error; + } + + if (msgType == Msg_Error && clState.withholdErrors) + return 0; + if (msgType == Msg_Warning && clState.withholdWarnings) + return 0; + + if (ref) { + myref = *ref; + FixupMessageRef(&myref); + } + + va_start(va, format); + if (optsCmdLine.msgStyle == 2) { + styledMessage_MPW(plugin, ref ? &myref : 0, errorNumber, msgType, format, va); + } else if (optsCmdLine.msgStyle == 1) { + styledMessage_Terse(plugin, ref ? &myref : 0, errorNumber, msgType, format, va); + } else if (optsCmdLine.msgStyle == 3) { + styledMessage_IDE(plugin, ref ? &myref : 0, errorNumber, msgType, format, va); + } else if (optsCmdLine.msgStyle == 4) { + styledMessage_Parseable(plugin, ref ? &myref : 0, errorNumber, msgType, format, va); + } else { + styledMessage_Default(plugin, ref ? &myref : 0, errorNumber, msgType, format, va); + } + va_end(va); + + if (ref && myref.sourceline) + xfree(myref.sourceline); + + if (msgType == Msg_Error && optsCmdLine.maxErrors) { + if (++clState.countErrors >= optsCmdLine.maxErrors) { + clState.withholdErrors = 1; + if (!optsCompiler.noFail) { + CLReport(70); + clState.userBreak = 1; + } else { + CLReport(71); + } + } + } + + if (msgType == Msg_Warning && optsCmdLine.maxWarnings) { + if (++clState.countWarnings >= optsCmdLine.maxWarnings) { + clState.withholdWarnings = 1; + CLReport(72); + } + } + + return msgType; } diff --git a/command_line/CmdLine/Src/MacEmul/ErrMgr.c b/command_line/CmdLine/Src/MacEmul/ErrMgr.c index 5fc621d..5ea1fe6 100644 --- a/command_line/CmdLine/Src/MacEmul/ErrMgr.c +++ b/command_line/CmdLine/Src/MacEmul/ErrMgr.c @@ -1,4 +1,4 @@ -#include "mwcc_decomp.h" +#include "cmdline.h" static const char *getsyserr(SInt16 msgNbr) { switch (msgNbr) { diff --git a/command_line/CmdLine/Src/MacEmul/Files.c b/command_line/CmdLine/Src/MacEmul/Files.c index 9a9cb60..a613b4a 100644 --- a/command_line/CmdLine/Src/MacEmul/Files.c +++ b/command_line/CmdLine/Src/MacEmul/Files.c @@ -1,4 +1,4 @@ -#include "mwcc_decomp.h" +#include "cmdline.h" typedef struct MacFileInfo { UInt32 ioFlCrDat; diff --git a/command_line/CmdLine/Src/MacEmul/LowMem.c b/command_line/CmdLine/Src/MacEmul/LowMem.c index 7fab079..cd31194 100644 --- a/command_line/CmdLine/Src/MacEmul/LowMem.c +++ b/command_line/CmdLine/Src/MacEmul/LowMem.c @@ -1,4 +1,4 @@ -#include "mwcc_decomp.h" +#include "cmdline.h" static OSErr memErr; diff --git a/command_line/CmdLine/Src/MacEmul/Memory.c b/command_line/CmdLine/Src/MacEmul/Memory.c index 0aa5d24..e201343 100644 --- a/command_line/CmdLine/Src/MacEmul/Memory.c +++ b/command_line/CmdLine/Src/MacEmul/Memory.c @@ -1,4 +1,4 @@ -#include "mwcc_decomp.h" +#include "cmdline.h" static OSErr memError; diff --git a/command_line/CmdLine/Src/MacEmul/ResourceStrings.c b/command_line/CmdLine/Src/MacEmul/ResourceStrings.c index 9f8f333..4b6bc22 100644 --- a/command_line/CmdLine/Src/MacEmul/ResourceStrings.c +++ b/command_line/CmdLine/Src/MacEmul/ResourceStrings.c @@ -1,9 +1,9 @@ -#include "mwcc_decomp.h" +#include "cmdline.h" typedef struct { const char *name; SInt16 rsrcid; - Handle strings; + const char **strings; } Res; static Res rlist[16]; @@ -12,7 +12,7 @@ void Res_Initialize() { memset(rlist, 0, sizeof(rlist)); } -int Res_AddResource(const char *name, SInt16 rsrcid, Handle strings) { +int Res_AddResource(const char *name, SInt16 rsrcid, const char **strings) { int scan; for (scan = 0; scan < 16 && rlist[scan].rsrcid; scan++) { diff --git a/command_line/CmdLine/Src/MacEmul/Resources.c b/command_line/CmdLine/Src/MacEmul/Resources.c index 796ed43..ef2aab0 100644 --- a/command_line/CmdLine/Src/MacEmul/Resources.c +++ b/command_line/CmdLine/Src/MacEmul/Resources.c @@ -1,4 +1,4 @@ -#include "mwcc_decomp.h" +#include "cmdline.h" // Fork Attributes enum { @@ -284,6 +284,7 @@ memcpy(buf, ((unsigned char *) file_data) + __offs, (count)); \ } while(0) static void ReadResourceFork(SInt16 ref, SInt8 permission, void *file_data, SInt32 file_size) { + // this function has various awkwardly swapped registers MemRsrcMap *rm; Ty70 thdr; Ty70 *dhdr; @@ -316,27 +317,29 @@ static void ReadResourceFork(SInt16 ref, SInt8 permission, void *file_data, SInt cnt = sizeof(Ty70); RF_READ(&thdr, 0, cnt, mapFail); + dhdr = &thdr; ref_offs = cnt; cnt = ((thdr.map_offs < thdr.data_offs) ? thdr.map_offs : thdr.data_offs) - sizeof(Ty70); if (cnt > sizeof(MemRsrcSysData)) cnt = sizeof(MemRsrcSysData); RF_READ(&tsys, ref_offs, cnt, mapFail); + dsys = &tsys; - msize = thdr.map_len; + msize = dhdr->map_len; buffer = malloc(msize); if (!buffer) goto memFail; - ref_offs = thdr.map_offs; + ref_offs = dhdr->map_offs; RF_READ(buffer, ref_offs, msize, mapFail); if ( - (thdr.map_offs > file_size) - || ((thdr.map_offs + thdr.map_len) > file_size) - || (thdr.data_offs > file_size) - || ((thdr.data_offs + thdr.data_len) > file_size) - || ((thdr.map_offs < thdr.data_offs) ? ((thdr.map_offs + thdr.map_len) != thdr.data_offs) : ((thdr.data_offs + thdr.data_len) != thdr.map_offs)) + (dhdr->map_offs > file_size) + || ((dhdr->map_offs + dhdr->map_len) > file_size) + || (dhdr->data_offs > file_size) + || ((dhdr->data_offs + dhdr->data_len) > file_size) + || ((dhdr->map_offs < dhdr->data_offs) ? ((dhdr->map_offs + dhdr->map_len) > dhdr->data_offs) : ((dhdr->data_offs + dhdr->data_len) > dhdr->map_offs)) ) goto mapFail; @@ -344,13 +347,13 @@ static void ReadResourceFork(SInt16 ref, SInt8 permission, void *file_data, SInt if (!rm) goto memFail; - rm->sys_data = tsys; + rm->sys_data = *dsys; dmap = (Ty73 *) buffer; - if ((dmap->typelist_offs + thdr.map_offs) > file_size) + if ((dmap->typelist_offs + dhdr->map_offs) > file_size) goto freeAndMapFail; dtyp = (Ty75 *) (((unsigned char *) buffer) + dmap->typelist_offs + 2); - if ((dmap->namelist_offs + thdr.map_offs) > file_size) + if ((dmap->namelist_offs + dhdr->map_offs) > file_size) goto freeAndMapFail; dnam = (Ty80 *) (((unsigned char *) buffer) + dmap->namelist_offs); if (dmap->types_idx != 0xFFFF) { @@ -359,21 +362,21 @@ static void ReadResourceFork(SInt16 ref, SInt8 permission, void *file_data, SInt if (!mtyp) goto freeAndReturn; - if ((thdr.map_offs + dmap->typelist_offs + dtyp[cnt].ref_list_offs) > file_size) + if ((dmap->typelist_offs + dtyp[cnt].ref_list_offs + dhdr->map_offs) > file_size) goto freeAndMapFail; drle = (Ty77 *) (((unsigned char *) dtyp) + dtyp[cnt].ref_list_offs - 2); if (dtyp[cnt].rsrc_idx != 0xFFFF) { for (rcnt = 0; rcnt <= dtyp[cnt].rsrc_idx; rcnt++) { ref_offs = (drle[rcnt].data_offs[0] << 16) | (drle[rcnt].data_offs[1] << 8) | drle[rcnt].data_offs[2]; - offs = thdr.data_offs + ref_offs; + offs = ref_offs + dhdr->data_offs; if (offs > file_size) goto freeAndMapFail; esize = 4; RF_READ(&tent, offs, esize, freeAndMapFail); offs += esize; - if ((thdr.data_offs + ref_offs + tent.len) > file_size) + if ((tent.len + ref_offs + dhdr->data_offs) > file_size) goto freeAndMapFail; hand = NewHandle(tent.len); @@ -385,7 +388,7 @@ static void ReadResourceFork(SInt16 ref, SInt8 permission, void *file_data, SInt HUnlock(hand); if (drle[rcnt].name_offs != 0xFFFF) { - nameptr = (StringPtr) (dnam + drle[rcnt].name_offs); + nameptr = (StringPtr) dnam + drle[rcnt].name_offs; name = malloc(nameptr[0] + 1); memcpy(name, nameptr, nameptr[0] + 1); } else { @@ -1250,14 +1253,14 @@ void HCreateResFile(SInt16 vRefNum, SInt32 dirID, ConstStringPtr fileName) { } } -OSErr FSpOpenResFile(const FSSpec *fss, SInt8 permission) { +OSErr FSpOpenResFile(const FSSpec *spec, SInt8 permission) { SInt16 ref; SInt32 size; if (permission != fsRdPerm) - FSpCreate(fss, 'CWIE', 'TEXT', -1); + FSpCreate(spec, 'CWIE', 'TEXT', -1); - resError = FSpOpenRF(fss, (permission == fsWrPerm) ? fsRdWrPerm : permission, &ref); + resError = FSpOpenRF(spec, (permission == fsWrPerm) ? fsRdWrPerm : permission, &ref); if (!resError) { GetEOF(ref, &size); if (size == 0 && permission != fsRdPerm) diff --git a/command_line/CmdLine/Src/MacEmul/TextUtils.c b/command_line/CmdLine/Src/MacEmul/TextUtils.c index a23ac7e..7971074 100644 --- a/command_line/CmdLine/Src/MacEmul/TextUtils.c +++ b/command_line/CmdLine/Src/MacEmul/TextUtils.c @@ -1,4 +1,4 @@ -#include "mwcc_decomp.h" +#include "cmdline.h" StringPtr c2pstr(char *s) { unsigned int l; diff --git a/command_line/CmdLine/Src/OSLib/MacFileTypes.c b/command_line/CmdLine/Src/OSLib/MacFileTypes.c index 05a2ae9..5ebb4d6 100644 --- a/command_line/CmdLine/Src/OSLib/MacFileTypes.c +++ b/command_line/CmdLine/Src/OSLib/MacFileTypes.c @@ -4,7 +4,7 @@ static OSFileTypeMappings *defaultList; static OSFileTypeMappings **fmList = &defaultList; int (*__OS_ExtendedGetMacFileTypeHook)(const OSSpec *, OSType *); -void OS_AddFileTypeMappingList(OSFileTypeMappings **list, OSFileTypeMappingList *entry) { +void OS_AddFileTypeMappingList(OSFileTypeMappings **list, const OSFileTypeMappingList *entry) { OSFileTypeMappings **scan; if (!list) @@ -27,7 +27,7 @@ void OS_UseFileTypeMappings(OSFileTypeMappings *list) { void OS_MacType_To_OSType(OSType mactype, uOSTypePair *type) { OSFileTypeMappings *list; - OSFileTypeMappingList *scan; + const OSFileTypeMappingList *scan; int idx; for (list = *fmList; list; list = list->next) { @@ -51,7 +51,7 @@ int OS_SetMacFileType(const OSSpec *spec, OSType mactype) { Boolean OS_GetMacFileTypeMagic(const char *buffer, int count, OSType *mactype) { OSFileTypeMappings *list; - OSFileTypeMappingList *scan; + const OSFileTypeMappingList *scan; int idx; *mactype = 0; diff --git a/command_line/CmdLine/Src/OSLib/Posix.c b/command_line/CmdLine/Src/OSLib/Posix.c index e3f8a03..d416b9b 100644 --- a/command_line/CmdLine/Src/OSLib/Posix.c +++ b/command_line/CmdLine/Src/OSLib/Posix.c @@ -408,14 +408,14 @@ int OS_EqualPath(const char *a, const char *b) { return !strcmp(a, b); } -int OS_CanonPath(char *src, char *dst) { +int OS_CanonPath(const char *src, char *dst) { int idx; if (strlen(src) > 255) return ENAMETOOLONG; if (!dst) - dst = src; + dst = (char *) src; for (idx = 0; src[idx]; idx++) { if (src[idx] == '\\') @@ -956,6 +956,6 @@ int OS_LoadMacResourceFork(const OSSpec *spec, void **file_data, SInt32 *file_le return ENOENT; } -int OS_IsMultiByte(const char *str, int offset) { +Boolean OS_IsMultiByte(const char *str, int offset) { return 0; } diff --git a/command_line/CmdLine/Src/Plugins/CLPlugins.c b/command_line/CmdLine/Src/Plugins/CLPlugins.c index e69de29..5f31f45 100644 --- a/command_line/CmdLine/Src/Plugins/CLPlugins.c +++ b/command_line/CmdLine/Src/Plugins/CLPlugins.c @@ -0,0 +1,981 @@ +#include "cmdline.h" + +static Plugin *pluginlist; +static ToolVersionInfo toolVersionInfo; +static VersionInfo toolVersion; +static Boolean useToolVersion; + +static void GetToolVersionInfo() { + useToolVersion = 0; +} + +const ToolVersionInfo *Plugin_GetToolVersionInfo() { + return useToolVersion ? &toolVersionInfo : 0; +} + +static const char *Plugin_GetDisplayName(Plugin *pl) { + const char *name; +#line 251 + OPTION_ASSERT(pl); + + if (pl->cb->GetDisplayName && pl->cb->GetDisplayName(&name) == 0) + return name; + else + return "(no name found)"; +} + +const char *Plugin_GetDropInName(Plugin *pl) { + const char *name; +#line 263 + OPTION_ASSERT(pl); + + if (pl->cb->GetDropInName && pl->cb->GetDropInName(&name) == 0) + return name; + else + return "(no name found)"; +} + +const VersionInfo *Plugin_GetVersionInfo(Plugin *pl) { + static const VersionInfo fakeversion = {0, 0, 0, 0}; + const VersionInfo *vi; +#line 276 + OPTION_ASSERT(pl); + + if (pl->cb->GetVersionInfo && pl->cb->GetVersionInfo(&vi) == 0) + return vi; + else + return &fakeversion; +} + +char *Plugin_GetVersionInfoASCII(Plugin *pl) { + const VersionInfo *vi; + char *buffer; + char vernum[16]; + char *bptr; + + if (!pl && useToolVersion) { + vi = &toolVersion; + } else if (!pl) { + return NULL; + } else { + vi = Plugin_GetVersionInfo(pl); + } + + buffer = xmalloc("version info", 64); + if (vi->major | vi->minor | vi->patch | vi->build != 0) { + bptr = vernum; + bptr += sprintf(bptr, "%u", vi->major); + bptr += sprintf(bptr, ".%u", vi->minor); + if (vi->patch) + bptr += sprintf(bptr, ".%u", vi->patch); + if (vi->build) + bptr += sprintf(bptr, " build %u", vi->build); + sprintf(buffer, "Version %s", vernum); + return buffer; + } else { + return NULL; + } +} + +DropInFlags *Plugin_GetDropInFlags(Plugin *pl) { + static DropInFlags retdf; + const DropInFlags *df; + SInt32 dfsize; + +#line 329 + OPTION_ASSERT(pl); + + if (pl->cb->GetDropInFlags && pl->cb->GetDropInFlags(&df, &dfsize) == 0) { + memset(&retdf, 0, sizeof(retdf)); + memcpy(&retdf, df, dfsize); + return &retdf; + } else { + return NULL; + } +} + +OSType Plugin_GetPluginType(Plugin *pl) { + DropInFlags *df; + +#line 345 + OPTION_ASSERT(pl); + + df = Plugin_GetDropInFlags(pl); + if (df) + return df->dropintype; + else + return CWFOURCHAR('N','O','N','E'); +} + +const CWTargetList *Plugin_CL_GetTargetList(Plugin *pl) { + static const CWTargetList faketl = { + kCurrentCWTargetListVersion, + 0, NULL, + 0, NULL + }; + const CWTargetList *tl; + +#line 358 + OPTION_ASSERT(pl); + OPTION_ASSERT(pl->cl_cb != NULL); + + if (pl->cl_cb->GetTargetList && pl->cl_cb->GetTargetList(&tl) == 0) + return tl; + else + return &faketl; +} + +const CWPanelList *Plugin_GetPanelList(Plugin *pl) { + static CWPanelList fakepnl = { + kCurrentCWPanelListVersion, 0, NULL + }; + const CWPanelList *pnl; + +#line 381 + OPTION_ASSERT(pl); + + if (pl->cb->GetPanelList && pl->cb->GetPanelList(&pnl) == 0) + return pnl; + else + return &fakepnl; +} + +const CWExtMapList *Plugin_CL_GetExtMapList(Plugin *pl) { + static CWExtMapList fakeel = { + kCurrentCWExtMapListVersion, + 0, NULL + }; + const CWExtMapList *el; + +#line 401 + OPTION_ASSERT(pl); + OPTION_ASSERT(pl->cl_cb != NULL); + + if (pl->cl_cb->GetDefaultMappingList && pl->cl_cb->GetDefaultMappingList(&el) == 0) + return el; + else + return &fakeel; +} + +const OSFileTypeMappingList *Plugin_GetFileTypeMappingList(Plugin *pl) { + const OSFileTypeMappingList *ftml; + +#line 422 + OPTION_ASSERT(pl); + + if (pl->cb->GetFileTypeMappings && pl->cb->GetFileTypeMappings(&ftml) == 0) + return ftml; + else + return NULL; +} + +const CWObjectFlags *Plugin_CL_GetObjectFlags(Plugin *pl) { + static CWObjectFlags fake = { + 2, 0, + "", "", "", "", "", "", + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 + }; + const CWObjectFlags *cof; + +#line 434 + OPTION_ASSERT(pl); + OPTION_ASSERT(pl->cl_cb != NULL); + + if (pl->cl_cb->GetObjectFlags && pl->cl_cb->GetObjectFlags(&cof) == 0) + return cof; + else if (Plugin_GetDropInFlags(pl)->dropintype == CWDROPINCOMPILERTYPE) + return NULL; + else + return &fake; +} + +Boolean Plugin_MatchesName(Plugin *pl, const char *name) { + const char *pname = Plugin_GetDropInName(pl); + return !strcmp(pname, name); +} + +Boolean Plugin_CL_MatchesTarget(Plugin *pl, OSType cpu, OSType os, Boolean exact) { + const CWTargetList *tl; + int idx; + int ix; + + tl = Plugin_CL_GetTargetList(pl); + + for (idx = 0; idx < tl->cpuCount; idx++) { + if (cpu == targetCPUAny || cpu == tl->cpus[idx] || (tl->cpus[idx] == targetCPUAny && !exact)) { + for (ix = 0; ix < tl->osCount; ix++) { + if (os == targetOSAny || os == tl->oss[ix] || (tl->oss[ix] == targetOSAny && !exact)) + return 1; + } + } + } + + return 0; +} + +Boolean Plugins_CL_HaveMatchingTargets(Plugin *p1, Plugin *p2, Boolean exact) { + // does not match, annoyingly + const CWTargetList *t1; + const CWTargetList *t2; + int ic1; + int ic2; + int io1; + int io2; + + t1 = Plugin_CL_GetTargetList(p1); + t2 = Plugin_CL_GetTargetList(p2); + + for (ic1 = 0; ic1 < t1->cpuCount; ic1++) { + for (ic2 = 0; ic2 < t2->cpuCount; ic2++) { + if ((t2->cpus[ic2] == targetCPUAny && !exact) || (t1->cpus[ic1] == t2->cpus[ic2]) || (t1->cpus[ic1] == targetCPUAny && !exact)) { + for (io1 = 0; io1 < t1->osCount; io1++) { + for (io2 = 0; io2 < t2->osCount; io2++) { + if ((t2->oss[io2] == targetOSAny && !exact) || (t1->oss[io1] == t2->oss[io2]) || (t1->oss[io1] == targetOSAny && !exact)) { + return 1; + } + } + } + } + } + } + + return 0; +} + +static Boolean CL_MatchesExtMapping(CWExtensionMapping *map, OSType type, const char *ext, Boolean exact) { + if (exact && type && map->type && type == map->type) + return 1; + + if ( + (((!map->extension[0] && !exact) || (!ext[0] && !exact)) && map->type == type) + || + (((!map->type && !exact) || (!type && !exact)) && !ustrcmp(map->extension, ext)) + || + (!ustrcmp(map->extension, ext) && map->type == type) + ) { + return 1; + } + + return 0; +} + +Boolean Plugin_CL_MatchesFileType(Plugin *pl, OSType type, const char *extension, Boolean exact) { + const CWExtMapList *el; + int idx; + + el = Plugin_CL_GetExtMapList(pl); + + for (idx = 0; idx < el->nMappings; idx++) { + if (CL_MatchesExtMapping(&el->mappings[idx], type, extension, exact)) + return 1; + } + + return 0; +} + +Boolean Plugin_MatchesType(Plugin *pl, OSType type, OSType lang, Boolean exact) { + const DropInFlags *df; + + df = Plugin_GetDropInFlags(pl); + if (df->dropintype == type || type == CWDROPINANYTYPE) { + if (df->edit_language == lang || lang == Lang_Any || (df->edit_language == Lang_Any && !exact)) + return 1; + } + + return 0; +} + +Boolean Plugin_Pr_MatchesPlugin(Plugin *pl, CLPluginInfo *pluginfo, OSType cpu, OSType os) { + Boolean isSupported; + +#line 566 + OPTION_ASSERT(pl->pr_cb != NULL); + + if (pl->pr_cb->SupportsPlugin && pl->pr_cb->SupportsPlugin(pluginfo, cpu, os, &isSupported) == 0) + return isSupported; + else + return 0; +} + +Boolean Plugin_Pr_MatchesPanels(Plugin *pl, int numPanels, const char **panelNames) { + Boolean isSupported; + +#line 578 + OPTION_ASSERT(pl->pr_cb != NULL); + + if (pl->pr_cb->SupportsPanels && pl->pr_cb->SupportsPanels(numPanels, panelNames, &isSupported) == 0) + return isSupported; + else + return 0; +} + +Boolean Plugin_CL_WriteObjectFile(Plugin *pl, FSSpec *srcfss, FSSpec *outfss, OSType creator, OSType type, Handle data) { + OSSpec outoss; + +#line 590 + OPTION_ASSERT(pl->cl_cb != NULL); + OPTION_ASSERT(data != NULL && srcfss != NULL && outfss != NULL); + + if (pl->cl_cb->WriteObjectFile) { + return pl->cl_cb->WriteObjectFile(srcfss, outfss, creator, type, data) == 0; + } + + OS_FSSpec_To_OSSpec(outfss, &outoss); + return WriteBinaryHandleToFile(&outoss, creator, type, OS_PeekMacHandle(data)); +} + +Boolean Plugin_CL_GetCompilerMapping(Plugin *pl, OSType type, const char *ext, UInt32 *flags) { + const CWExtMapList *el; + int idx; + int pick; + + el = Plugin_CL_GetExtMapList(pl); + pick = -1; + for (idx = 0; idx < el->nMappings; idx++) { + if (CL_MatchesExtMapping(&el->mappings[idx], type, ext, 0)) { + pick = idx; + if (CL_MatchesExtMapping(&el->mappings[idx], type, ext, 1)) + break; + } + } + + if (pick < 0) { + *flags = 0; + return 0; + } else { + *flags = el->mappings[pick].flags; + return 1; + } +} + +static Boolean SupportedPlugin(Plugin *pl, const char **reason) { + static const SInt32 DropInFlagsSize[3] = {0, 0x10, 0x12}; + const DropInFlags *df; + const CWObjectFlags *cof; + SInt32 dfsize; + + *reason = ""; + if (pl->cb->GetDropInFlags == NULL) { + *reason = "GetDropInFlags callback not found"; + return 0; + } + if (pl->cb->GetDropInFlags(&df, &dfsize)) { + *reason = "GetDropInFlags callback failed"; + return 0; + } + if (df->dropintype != CWDROPINCOMPILERTYPE && df->dropintype != CWDROPINLINKERTYPE && df->dropintype != CWDROPINPARSERTYPE && df->dropintype != CWDROPINDRIVERTYPE) { + *reason = "The plugin type is not supported by this driver"; + return 0; + } + if (df->earliestCompatibleAPIVersion > 11) { + *reason = "The plugin's earliest compatible API version is too new for this driver"; + return 0; + } + if (df->earliestCompatibleAPIVersion > 1 && df->newestAPIVersion < 11 && clState.pluginDebug) { + CLPrintErr("%s's newest compatible API version is probably too old for this driver\n", Plugin_GetDropInName(pl)); + } + if (dfsize != DropInFlagsSize[df->rsrcversion]) { + *reason = "The plugin's DropInFlags has an unexpected size"; + return 0; + } + if (!(df->dropinflags & dropInExecutableTool) && !pl->cb->main) { + *reason = "The plugin has no entry point"; + return 0; + } + if ((df->dropinflags & dropInExecutableTool) && pl->cb->main) { + *reason = "The executable tool stub has an entry point"; + return 0; + } + + if (pl->cl_cb) { + if (pl->cl_cb->GetObjectFlags == NULL && df->dropintype == CWDROPINCOMPILERTYPE) { + *reason = "GetObjectFlags callback not found in compiler plugin"; + return 0; + } + + cof = Plugin_CL_GetObjectFlags(pl); + if (cof->version < 2 || cof->flags & 0x7FFFFFFF) { + *reason = "The object flags data is out-of-date or invalid"; + return 0; + } + } + + return 1; +} + +static Boolean VerifyPanels(Plugin *pl) { + const CWPanelList *pls; + Boolean failed; + int idx; + + failed = 0; + + if (pl->cb->GetPanelList && pl->cb->GetPanelList(&pls) == 0) { + for (idx = 0; idx < pls->count; idx++) { + if (Prefs_FindPanel(pls->names[idx]) == NULL) { + CLReportError(91, pls->names[idx]); + failed = 1; + } + } + } + + return !failed; +} + +Plugin *Plugin_New(const BasePluginCallbacks *cb, const CompilerLinkerPluginCallbacks *cl_cb, const ParserPluginCallbacks *pr_cb) { + Plugin *p; + + p = xmalloc(NULL, sizeof(Plugin)); + if (!p) + return NULL; + if (!cb) + return NULL; + + p->cb = xmalloc(NULL, sizeof(BasePluginCallbacks)); + if (!p->cb) + return NULL; + *p->cb = *cb; + + if (cl_cb) { + p->cl_cb = xmalloc(NULL, sizeof(CompilerLinkerPluginCallbacks)); + if (!p->cl_cb) + return NULL; + *p->cl_cb = *cl_cb; + } else { + p->cl_cb = NULL; + } + + if (pr_cb) { + p->pr_cb = xmalloc(NULL, sizeof(ParserPluginCallbacks)); + if (!p->pr_cb) + return NULL; + *p->pr_cb = *pr_cb; + } else { + p->pr_cb = NULL; + } + + p->context = NULL; + p->next = NULL; + return p; +} + +void Plugin_Free(Plugin *pl) { + if (pl) { + if (pl->cb) + xfree(pl->cb); + if (pl->cl_cb) + xfree(pl->cl_cb); + if (pl->pr_cb) + xfree(pl->pr_cb); + xfree(pl); + } +} + +Boolean Plugin_VerifyPanels(Plugin *pl) { + if (!VerifyPanels(pl)) { + CLReportError(92, Plugin_GetDropInName(pl)); + return 0; + } else { + return 1; + } +} + +void Plugins_Init() { + pluginlist = NULL; + GetToolVersionInfo(); +} + +void Plugins_Term() { + Plugin *scan; + Plugin *next; + + scan = pluginlist; + while (scan) { + next = scan->next; + SendInitOrTermRequest(scan, 0); + Plugin_Free(scan); + scan = next; + } + + if (toolVersionInfo.company) + xfree(toolVersionInfo.company); + if (toolVersionInfo.product) + xfree(toolVersionInfo.product); + if (toolVersionInfo.tool) + xfree(toolVersionInfo.tool); + if (toolVersionInfo.copyright) + xfree(toolVersionInfo.copyright); + if (toolVersionInfo.version) + xfree(toolVersionInfo.version); +} + +int Plugins_Add(Plugin *pl) { + Plugin **scan; + const char *dropinname; + const DropInFlags *df; + const CWTargetList *tl; + const CWExtMapList *el; + const CWPanelList *pnl; + const char *failreason; + CWDataType vislang; + SInt16 step; + + dropinname = Plugin_GetDropInName(pl); + pl->cached_ascii_version = Plugin_GetVersionInfoASCII(pl); + + if (!SupportedPlugin(pl, &failreason)) { + CLReportError(88, dropinname, pl->cached_ascii_version, failreason); + return 0; + } + + scan = &pluginlist; + while (*scan) { + if (Plugin_MatchesName(*scan, dropinname)) { + CLReportError(89, dropinname); + return 0; + } + scan = &(*scan)->next; + } + + *scan = pl; + + df = Plugin_GetDropInFlags(pl); + if (!(df->dropinflags & dropInExecutableTool) && !SendInitOrTermRequest(pl, 1)) { + CLReportError(3, dropinname); + return 0; + } + + if (df->dropintype == CWDROPINCOMPILERTYPE && df->dropinflags & 0x17C000) + CLReportError(4, "compiler", dropinname); + if (df->dropintype == CWDROPINLINKERTYPE && df->dropinflags & 0x5FE4000) + CLReportError(4, "linker", dropinname); + + if (clState.pluginDebug) { + vislang = df->edit_language ? df->edit_language : CWFOURCHAR('-','-','-','-'); + CLPrint("Added plugin '%s', version '%s'\n", dropinname, pl->cached_ascii_version); + CLPrint("Type: '%c%c%c%c'; Lang: '%c%c%c%c'; API range: %d-%d\n", + (df->dropintype & 0xFF000000) >> 24, + (df->dropintype & 0x00FF0000) >> 16, + (df->dropintype & 0x0000FF00) >> 8, + (df->dropintype & 0x000000FF), + (vislang & 0xFF000000) >> 24, + (vislang & 0x00FF0000) >> 16, + (vislang & 0x0000FF00) >> 8, + (vislang & 0x000000FF), + df->earliestCompatibleAPIVersion, + df->newestAPIVersion + ); + + if (pl->cl_cb) { + tl = Plugin_CL_GetTargetList(pl); + CLPrint("Target CPUs: "); + for (step = 0; step < tl->cpuCount; step++) { + CLPrint("'%c%c%c%c', ", + (tl->cpus[step] & 0xFF000000) >> 24, + (tl->cpus[step] & 0x00FF0000) >> 16, + (tl->cpus[step] & 0x0000FF00) >> 8, + (tl->cpus[step] & 0x000000FF) + ); + } + CLPrint("\nTarget OSes: "); + for (step = 0; step < tl->osCount; step++) { + CLPrint("'%c%c%c%c', ", + (tl->oss[step] & 0xFF000000) >> 24, + (tl->oss[step] & 0x00FF0000) >> 16, + (tl->oss[step] & 0x0000FF00) >> 8, + (tl->oss[step] & 0x000000FF) + ); + } + CLPrint("\n"); + + el = Plugin_CL_GetExtMapList(pl); + CLPrint("File mappings:\n"); + for (step = 0; step < el->nMappings; step++) { + if (el->mappings[step].type) { + CLPrint("\tFile type: '%c%c%c%c' Extension: '%s'\n", + (el->mappings[step].type & 0xFF000000) >> 24, + (el->mappings[step].type & 0x00FF0000) >> 16, + (el->mappings[step].type & 0x0000FF00) >> 8, + (el->mappings[step].type & 0x000000FF), + el->mappings[step].extension + ); + } else { + CLPrint("\tFile type: Extension: '%s'\n", + el->mappings[step].extension + ); + } + } + } + + pnl = Plugin_GetPanelList(pl); + CLPrint("Pref panels needed:\n"); + for (step = 0; step < pnl->count; step++) { + CLPrint("\t'%s'\n", pnl->names[step]); + } + + CLPrint("Dropin flags:\n"); + if (df->dropinflags & dropInExecutableTool) CLPrint("\texecutable tool,\n"); + if (df->dropintype == CWDROPINCOMPILERTYPE) { + if (df->dropinflags & kGeneratescode) CLPrint("\tgenerates code,\n"); + if (df->dropinflags & kGeneratesrsrcs) CLPrint("\tgenerates resources, \n"); + if (df->dropinflags & kCanpreprocess) CLPrint("\tcan preprocess, \n"); + if (df->dropinflags & kCanprecompile) CLPrint("\tcan precompile, \n"); + if (df->dropinflags & kIspascal) CLPrint("\tis Pascal, \n"); + if (df->dropinflags & kCanimport) CLPrint("\tcan import, \n"); + if (df->dropinflags & kCandisassemble) CLPrint("\tcan disassemble, \n"); + if (df->dropinflags & kCompAllowDupFileNames) CLPrint("\tallow duplicate filenames, \n"); + if (df->dropinflags & kCompMultiTargAware) CLPrint("\tallow multiple targets, \n"); + if (df->dropinflags & kCompUsesTargetStorage) CLPrint("\tuses target storage, \n"); + if (df->dropinflags & kCompEmitsOwnBrSymbols) CLPrint("\temits own browser symbols, \n"); + if (df->dropinflags & kCompAlwaysReload) CLPrint("\tshould be always reloaded, \n"); + if (df->dropinflags & kCompRequiresProjectBuildStartedMsg) CLPrint("\trequires project build started msg, \n"); + if (df->dropinflags & kCompRequiresTargetBuildStartedMsg) CLPrint("\trequires target build started msg, \n"); + if (df->dropinflags & kCompRequiresSubProjectBuildStartedMsg) CLPrint("\trequires subproject build started msg, \n"); + if (df->dropinflags & kCompRequiresFileListBuildStartedMsg) CLPrint("\trequires file list build started msg, \n"); + } + + if (df->dropintype == CWDROPINLINKERTYPE) { + if (df->dropinflags & cantDisassemble) CLPrint("\tcan't disassemble, \n"); + if (df->dropinflags & isPostLinker) CLPrint("\tis a post-linker, \n"); + if (df->dropinflags & linkAllowDupFileNames) CLPrint("\tallow duplicate filenames, \n"); + if (df->dropinflags & linkMultiTargAware) CLPrint("\tallow multiple targets, \n"); + if (df->dropinflags & isPreLinker) CLPrint("\tis a pre-linker, \n"); + if (df->dropinflags & linkerUsesTargetStorage) CLPrint("\tuses target storage, \n"); + if (df->dropinflags & linkerUnmangles) CLPrint("\tsupports unmangling, \n"); + if (df->dropinflags & magicCapLinker) CLPrint("\tis Magic Cap linker, \n"); + if (df->dropinflags & linkAlwaysReload) CLPrint("\tshould be always reloaded, \n"); + if (df->dropinflags & linkRequiresProjectBuildStartedMsg) CLPrint("\trequires project build started msg, \n"); + if (df->dropinflags & linkRequiresTargetBuildStartedMsg) CLPrint("\trequires target build started msg, \n"); + if (df->dropinflags & linkRequiresSubProjectBuildStartedMsg) CLPrint("\trequires subproject build started msg, \n"); + if (df->dropinflags & linkRequiresFileListBuildStartedMsg) CLPrint("\trequires file list build started msg, \n"); + if (df->dropinflags & linkRequiresTargetLinkStartedMsg) CLPrint("\trequires target link started msg, \n"); + if (df->dropinflags & linkerWantsPreRunRequest) CLPrint("\twants pre-run request, \n"); + } + + CLPrint("\n"); + } + + return 1; +} + +Plugin *Plugins_MatchName(Plugin *list, const char *name) { + Plugin *scan; + + scan = list ? list : pluginlist; + while (scan) { + if (Plugin_MatchesName(scan, name)) + break; + scan = scan->next; + } + + return scan; +} + +Plugin *Plugins_CL_MatchTarget(Plugin *list, OSType cpu, OSType os, OSType type, OSType lang) { + Plugin *scan; + Plugin *pick; + + scan = list ? list : pluginlist; + pick = NULL; + while (scan) { + if (scan->cl_cb) { + if (Plugin_CL_MatchesTarget(scan, cpu, os, 0) && Plugin_MatchesType(scan, type, lang, 0)) { + pick = scan; + if (Plugin_CL_MatchesTarget(scan, cpu, os, 1) && Plugin_MatchesType(scan, type, lang, 1)) + break; + } + } + scan = scan->next; + } + + return pick; +} + +Plugin *Plugins_CL_MatchFileType(Plugin *list, OSType type, const char *ext, Boolean exact) { + Plugin *scan; + + scan = list ? list : pluginlist; + while (scan) { + if (Plugin_CL_MatchesFileType(scan, type, ext, exact)) + break; + scan = scan->next; + } + + return scan; +} + +Plugin *Plugins_GetPluginForFile(Plugin *list, OSType plugintype, OSType cpu, OSType os, OSType type, const char *ext, OSType lang) { + Plugin *scan; + Plugin *pick; + + scan = list ? list : pluginlist; + pick = NULL; + while (scan) { + if (Plugin_MatchesType(scan, plugintype, lang, 1) && scan->cl_cb) { + if (Plugin_CL_MatchesTarget(scan, cpu, os, 0) && Plugin_CL_MatchesFileType(scan, type, ext, 0)) { + pick = scan; + if (Plugin_CL_MatchesTarget(scan, cpu, os, 1) && Plugin_CL_MatchesFileType(scan, type, ext, 1)) + break; + } + } + scan = scan->next; + } + + return pick; +} + +Plugin *Plugins_GetLinker(Plugin *list, OSType cpu, OSType os) { + Plugin *scan; + Plugin *pick; + + scan = list ? list : pluginlist; + pick = NULL; + while (scan) { + if (Plugin_MatchesType(scan, CWDROPINLINKERTYPE, Lang_Any, 1)) { + if (!(Plugin_GetDropInFlags(scan)->dropinflags & (isPreLinker | isPostLinker))) { + if (Plugin_CL_MatchesTarget(scan, cpu, os, 0)) { + pick = scan; + if (Plugin_CL_MatchesTarget(scan, cpu, os, 1)) + break; + } + } + } + scan = scan->next; + } + + return pick; +} + +Plugin *Plugins_GetPreLinker(Plugin *list, OSType cpu, OSType os) { + Plugin *scan; + Plugin *pick; + + scan = list ? list : pluginlist; + pick = NULL; + while (scan) { + if (Plugin_MatchesType(scan, CWDROPINLINKERTYPE, Lang_Any, 1)) { + if (Plugin_GetDropInFlags(scan)->dropinflags & isPreLinker) { + if (Plugin_CL_MatchesTarget(scan, cpu, os, 0)) { + pick = scan; + if (Plugin_CL_MatchesTarget(scan, cpu, os, 1)) + break; + } + } + } + scan = scan->next; + } + + return pick; +} + +Plugin *Plugins_GetPostLinker(Plugin *list, OSType cpu, OSType os) { + Plugin *scan; + Plugin *pick; + + scan = list ? list : pluginlist; + pick = NULL; + while (scan) { + if (Plugin_MatchesType(scan, CWDROPINLINKERTYPE, Lang_Any, 1)) { + if (Plugin_GetDropInFlags(scan)->dropinflags & isPostLinker) { + if (Plugin_CL_MatchesTarget(scan, cpu, os, 0)) { + pick = scan; + if (Plugin_CL_MatchesTarget(scan, cpu, os, 1)) + break; + } + } + } + scan = scan->next; + } + + return pick; +} + +Plugin *Plugins_GetParserForPlugin(Plugin *list, OSType style, int numPlugins, CLPluginInfo *plugins, OSType cpu, OSType os, int numPanels, const char **panelNames) { + Plugin *scan; + Plugin *pick; + Boolean allpanels; + Boolean hasplugintype; + Boolean *supports; + + scan = list ? list : pluginlist; + pick = NULL; + supports = alloca(numPanels); + + while (scan) { + if (Plugin_MatchesType(scan, CWDROPINPARSERTYPE, style, 1)) { + int idx; + int pnl; + hasplugintype = 0; + for (idx = 0; idx < numPlugins; idx++) { + if (plugins[idx].plugintype != CWDROPINPARSERTYPE && plugins[idx].plugintype != CWDROPINDRIVERTYPE && !plugins[idx].storeCommandLine) { + if (Plugin_Pr_MatchesPlugin(scan, &plugins[idx], cpu, os)) + hasplugintype = 1; + } + } + + if (hasplugintype) { + pick = scan; + allpanels = 1; + for (pnl = 0; pnl < numPanels; pnl++) { + allpanels &= (supports[pnl] = Plugin_Pr_MatchesPanels(scan, 1, &panelNames[pnl])); + } + + if (allpanels) + break; + } + } + scan = scan->next; + } + + if (pick && !allpanels) { + int idx; + CLReport(5); + + for (idx = 0; idx < numPanels; idx++) { + if (!supports[idx]) + CLReport(6, panelNames[idx]); + } + } + + return pick; +} + +Plugin *Plugins_GetCompilerForLinker(Plugin *list, Plugin *linker, OSType type, const char *ext, OSType edit) { + Plugin *scan; + Plugin *pick; + + scan = list ? list : pluginlist; + pick = NULL; + + while (scan) { + if (Plugin_MatchesType(scan, CWDROPINCOMPILERTYPE, edit, 1)) { + if (Plugin_CL_MatchesFileType(scan, type, ext, 0) && Plugins_CL_HaveMatchingTargets(scan, linker, 0)) { + pick = scan; + if (Plugin_CL_MatchesFileType(scan, type, ext, 1) && Plugins_CL_HaveMatchingTargets(scan, linker, 1)) + break; + } + } + scan = scan->next; + } + + return pick; +} + +int Plugins_GetPluginList(Plugin *list, int *numPlugins, CLPluginInfo **pluginInfo) { + Plugin *scan; + int idx; + const DropInFlags *df; + const VersionInfo *vi; + + scan = list ? list : pluginlist; + idx = 0; + while (scan) { + scan = scan->next; + idx++; + } + + *numPlugins = idx; + *pluginInfo = xmalloc(NULL, sizeof(CLPluginInfo) * idx); + if (!*pluginInfo) + return 0; + + scan = list ? list : pluginlist; + idx = 0; + while (scan) { + df = Plugin_GetDropInFlags(scan); + vi = Plugin_GetVersionInfo(scan); +#line 1270 + OPTION_ASSERT(df != NULL); + OPTION_ASSERT(vi != NULL); + (*pluginInfo)[idx].plugintype = df->dropintype; + (*pluginInfo)[idx].language = df->edit_language; + (*pluginInfo)[idx].dropinflags = df->dropinflags; + (*pluginInfo)[idx].version = scan->cached_ascii_version; + (*pluginInfo)[idx].storeCommandLine = df->dropinflags & 1; + scan = scan->next; + idx++; + } + + return 1; +} + +int Plugins_GetPrefPanelUnion(Plugin *list, int *numPanels, const char ***panelNames) { + Plugin *scan; + int tempNum; + int idx; + const char **tempPanels; + + scan = list ? list : pluginlist; + + tempNum = 0; + while (scan) { + const CWPanelList *pl; + pl = Plugin_GetPanelList(scan); + tempNum += pl->count; + scan = scan->next; + } + + tempPanels = xmalloc("plugin preference union", sizeof(const char *) * tempNum); + + idx = 0; + scan = list ? list : pluginlist; + while (scan) { + const CWPanelList *pl; + int step; + + pl = Plugin_GetPanelList(scan); + for (step = 0; step < pl->count; step++) { + int cmp; + for (cmp = 0; cmp < idx; cmp++) { + if (!ustrcmp(tempPanels[cmp], pl->names[step])) + break; + } + + if (cmp >= idx) + tempPanels[idx++] = pl->names[step]; + } + + scan = scan->next; + } + + *panelNames = xmalloc(NULL, idx * sizeof(const char *)); + if (!*panelNames) + return 0; + + *panelNames = xrealloc("plugin preference union", tempPanels, idx * sizeof(const char *)); + *numPanels = idx; + return 1; +} + +int Plugin_AddFileTypeMappings(Plugin *pl, OSFileTypeMappings **mlist) { + const OSFileTypeMappingList *ftml; + + ftml = Plugin_GetFileTypeMappingList(pl); + if (!ftml) { + return 1; + } else { + AddFileTypeMappingList(NULL, ftml); + return 1; + } +} + +int Plugins_AddFileTypeMappingsForTarget(Plugin *list, OSFileTypeMappings **mlist, OSType cpu, OSType os) { + if (!list) + list = pluginlist; + + while (list) { + if (!list->cl_cb || Plugin_CL_MatchesTarget(list, cpu, os, 0)) + Plugin_AddFileTypeMappings(list, mlist); + list = list->next; + } + + return 1; +} + +SInt16 Plugin_Call(Plugin *pl, void *context) { + if (pl->cb->main) + return pl->cb->main(context); + else + return cwErrRequestFailed; +} + diff --git a/command_line/CmdLine/Src/Project/CLAccessPaths.c b/command_line/CmdLine/Src/Project/CLAccessPaths.c index e69de29..1ffcd1d 100644 --- a/command_line/CmdLine/Src/Project/CLAccessPaths.c +++ b/command_line/CmdLine/Src/Project/CLAccessPaths.c @@ -0,0 +1,525 @@ +#include "cmdline.h" + +// TODO check where this should be! +Paths FrameworkPaths; +Frameworks FrameworkInfo; + +Path *Path_Init(const OSPathSpec *dir, Path *path) { + path->spec = xmalloc(NULL, sizeof(OSPathSpec)); + *path->spec = *dir; + path->recursive = NULL; + path->dirlist = NULL; + path->flags = 0; + return path; +} + +Path *Path_New(const OSPathSpec *dir) { + Path *path; + path = xmalloc(NULL, sizeof(Path)); + return Path_Init(dir, path); +} + +void Path_Free(Path *path) { + if (path) { + if (path->spec) + xfree(path->spec); + if (path->recursive) { + Paths_Terminate(path->recursive); + xfree(path->recursive); + } + xfree(path); + } +} + +Boolean Paths_Initialize(Paths *paths) { +#line 52 + OPTION_ASSERT(paths != NULL); + + memset(paths, 0, sizeof(Paths)); + paths->pathsArray = NULL; + return 1; +} + +Boolean Paths_Terminate(Paths *paths) { + UInt16 index; + +#line 63 + OPTION_ASSERT(paths != NULL); + + if (paths->pathsArray) { + for (index = 0; index < paths->pathsCount; index++) + Path_Free(paths->pathsArray[index]); + xfree(paths->pathsArray); + } + + paths->pathsArray = NULL; + return 1; +} + +static Boolean Paths_GrowPaths(Paths *paths, UInt16 *index) { + Path **newArray; + +#line 84 + OPTION_ASSERT(paths != NULL); + + if (paths->pathsCount >= paths->arraySize) { + paths->arraySize += 20; + newArray = xrealloc("access paths", paths->pathsArray, sizeof(Path *) * paths->arraySize); + paths->pathsArray = newArray; + } + + *index = paths->pathsCount++; + return 1; +} + +Boolean Paths_AddPath(Paths *paths, Path *path) { + UInt16 ni; + + if (Paths_GrowPaths(paths, &ni)) { + paths->pathsArray[ni] = path; + return 1; + } else { + return 0; + } +} + +Boolean Paths_InsertPath(Paths *paths, UInt16 index, Path *path) { + UInt16 ni; + + if (Paths_GrowPaths(paths, &ni)) { + if (index > ni) { + index = (ni != 0) ? (ni - 1) : 0; + } + memmove(&paths->pathsArray[index + 1], &paths->pathsArray[index], sizeof(Path *) * (paths->pathsCount - index)); + paths->pathsArray[index] = path; + return 1; + } else { + return 0; + } +} + +Boolean Paths_RemovePath(Paths *paths, UInt16 index) { + if (index >= paths->pathsCount) + return 0; + + memmove(&paths->pathsArray[index], &paths->pathsArray[index + 1], sizeof(Path *) * (paths->pathsCount - index - 1)); + paths->pathsCount--; + return 1; +} + +Boolean Paths_DeletePath(Paths *paths, UInt16 index) { + if (index >= paths->pathsCount) + return 0; + + Path_Free(paths->pathsArray[index]); + return Paths_RemovePath(paths, index); +} + +Path *Paths_GetPath(Paths *paths, UInt16 pathnum) { +#line 151 + OPTION_ASSERT(paths != NULL); + + if (pathnum < paths->pathsCount) + return paths->pathsArray[pathnum]; + else + return NULL; +} + +UInt16 Paths_Count(const Paths *paths) { +#line 161 + OPTION_ASSERT(paths != NULL); + + return paths->pathsCount; +} + +Boolean Paths_FindPath(const Paths *paths, const Path *path) { + UInt16 idx; + +#line 169 + OPTION_ASSERT(paths != NULL); + + for (idx = 0; idx < paths->pathsCount; idx++) { + if (paths->pathsArray[idx] == path) + return 1; + } + + return 0; +} + +Path *Paths_FindPathSpec(const Paths *paths, const OSPathSpec *dir) { + UInt16 idx; + Path *path; + +#line 182 + OPTION_ASSERT(paths != NULL); + + for (idx = 0; idx < paths->pathsCount; idx++) { + path = paths->pathsArray[idx]; + if (OS_EqualPathSpec(path->spec, dir)) + return path; + } + + return NULL; +} + +static Boolean GatherRecurse(Paths *list, Path *path) { + int err; + OSOpenedDir rf; + OSSpec ent; + int count; + char filename[64]; + Boolean isfile; + char *nptr; + char *eptr; + UInt16 added; + Path *nw; + + count = 0; + if (CheckForUserBreak()) + return 1; + + err = OS_OpenDir(path->spec, &rf); + while (!err) { + err = OS_ReadDir(&rf, &ent, filename, &isfile); + if (!err) { + if (!isfile) { + nw = Path_New(&ent.path); + nptr = OS_GetFileNamePtr(filename); + eptr = nptr + strlen(nptr) - 1; + if (eptr[0] == OS_PATHSEP) + eptr--; + if (eptr > nptr && *nptr == '(' && *eptr == ')') + continue; + + if (!Paths_AddPath(list, nw)) + break; + added = Paths_Count(list) - 1; + if (!GatherRecurse(list, nw)) + Paths_DeletePath(list, added); + } else { + if (!(++count % 50) && CheckForUserBreak()) + return 0; + } + } + } + OS_CloseDir(&rf); + return count > 0; +} + +Boolean Paths_GatherRecurse(Path *path) { + path->recursive = xcalloc(NULL, sizeof(Paths)); + GatherRecurse(path->recursive, path); + return Paths_Count(path->recursive) != 0; +} + +int Paths_CountRecurse(Paths *paths) { + UInt16 idx; + int mine; + Path *path; + + mine = Paths_Count(paths); + for (idx = 0; idx < mine; idx++) { + path = Paths_GetPath(paths, idx); +#line 336 + OPTION_ASSERT(path); + + if (path->recursive) + mine += Paths_CountRecurse(path->recursive); + } + + return mine; +} + +static void CopyRecurseFSS(FSSpec **list, Paths *paths, UInt16 *count) { + UInt16 idx; + OSSpec spec; + Path *path; + + for (idx = 0; idx < Paths_Count(paths); idx++) { + path = Paths_GetPath(paths, idx); +#line 353 + OPTION_ASSERT(path && *count > 0); + OS_MakeSpecWithPath(path->spec, NULL, 0, &spec); +#line 355 + OPTION_ASSERT(OS_OSSpec_To_FSSpec(&spec, *list)); + (*list)++; + (*count)--; + if (path->recursive) + CopyRecurseFSS(list, path->recursive, count); + } +} + +void Paths_CopyRecurseFSS(FSSpec *list, Paths *paths, UInt16 count) { + CopyRecurseFSS(&list, paths, &count); +#line 367 + OPTION_ASSERT(count == 0); +} + +static Boolean Frameworks_Initialize(Frameworks *fws) { +#line 405 + OPTION_ASSERT(fws != NULL); + + memset(fws, 0, sizeof(Frameworks)); + fws->fwsArray = NULL; + return 1; +} + +static Boolean Frameworks_Grow(Frameworks *fws, UInt16 *index) { + Paths_FWInfo **newArray; + +#line 418 + OPTION_ASSERT(fws != NULL); + + if (fws->fwsCount >= fws->arraySize) { + fws->arraySize += 20; + newArray = xrealloc("access frameworks", fws->fwsArray, sizeof(Paths_FWInfo *) * fws->arraySize); + fws->fwsArray = newArray; + } + + *index = fws->fwsCount++; + return 1; +} + +static Boolean Frameworks_Add(Frameworks *fws, Paths_FWInfo *info) { + UInt16 ni; + + if (Frameworks_Grow(fws, &ni)) { + fws->fwsArray[ni] = info; + return 1; + } else { + return 0; + } +} + +static Paths_FWInfo *Framework_Init(OSSpec *dir, const char *name, const char *version, Paths_FWInfo *info, Path *p, Boolean hidden) { + info->fileSpec = *dir; + if (version && version[0]) + strncpy(info->version.s, version, sizeof(info->version.s)); + else + info->version.s[0] = 0; + strncpy(info->name.s, name, sizeof(info->name.s)); + info->path = p; + info->hidden = hidden; + return info; +} + +static Paths_FWInfo *Framework_New(OSSpec *dir, const char *name, const char *version, Path *p, Boolean hidden) { + Paths_FWInfo *info; + info = xmalloc(NULL, sizeof(Paths_FWInfo)); + return Framework_Init(dir, name, version, info, p, hidden); +} + +static Boolean CheckForFileInFrameworkDir(char *out, const char *framework_path, OSPathSpec *osps, const char *fname) { + int err; + OSSpec oss; + + sprintf(out, "%s/%s", framework_path, fname); + err = OS_MakeSpecWithPath(osps, out, 0, &oss); + if (err == 0 && OS_IsFile(&oss)) + return 1; + + sprintf(out, "%s/Headers/%s", framework_path, fname); + err = OS_MakeSpecWithPath(osps, out, 0, &oss); + if (err == 0 && OS_IsFile(&oss)) + return 1; + + sprintf(out, "%s/Resources/%s", framework_path, fname); + err = OS_MakeSpecWithPath(osps, out, 0, &oss); + if (err == 0 && OS_IsFile(&oss)) + return 1; + + sprintf(out, "%s/Resources/%s", framework_path, fname); + err = OS_MakeSpecWithPath(osps, out, 0, &oss); + if (err == 0 && OS_IsFile(&oss)) + return 1; + + return 0; +} + +static Boolean CheckForFileInFramework(char *out, int i, const char *fname) { + Paths_FWInfo *info; + char framework_path[256]; + + info = Frameworks_GetInfo(i); + if (strlen(info->version.s)) + sprintf(framework_path, "%s.framework/Versions/%s", info->name.s, info->version.s); + else + sprintf(framework_path, "%s.framework", info->name.s); + + if (CheckForFileInFrameworkDir(out, framework_path, info->path->spec, fname)) + return 1; + else + return 0; +} + +Boolean MakeFrameworkPath(char *out, const char *filename, Path *globalpath) { + Paths_FWInfo *info; + int err; + char *end; + char *fname; + char framework_name[256]; + char framework_path[256]; + const char *s; + char *d; + int i; + int n; + + n = Frameworks_GetCount(); + end = strchr(filename, OS_PATHSEP); + if (!end) { + for (i = 0; i < n; i++) { + info = Frameworks_GetInfo(i); + if (!info->hidden && CheckForFileInFramework(out, i, filename)) + return 1; + } + return 0; + } + + fname = end + 1; + s = filename; + d = framework_name; + while (s < end) + *(d++) = *(s++); + *d = 0; + + for (i = 0; i < n; i++) { + if (!strcmp(Frameworks_GetInfo(i)->name.s, framework_name)) { + return CheckForFileInFramework(out, i, fname) != 0; + } + } + + if (globalpath) { + OSSpec oss; + sprintf(framework_path, "../Frameworks/%s.framework", framework_name); + err = OS_MakeSpecWithPath(globalpath->spec, framework_path, 0, &oss); + if (!err && OS_IsDir(&oss)) { + if (CheckForFileInFrameworkDir(out, framework_path, globalpath->spec, fname)) + return 1; + } + } + + n = Paths_Count(&FrameworkPaths); + sprintf(framework_path, "%s.framework", framework_name); + for (i = 0; i < n; i++) { + OSSpec oss; + Path *p; + p = Paths_GetPath(&FrameworkPaths, i); + err = OS_MakeSpecWithPath(p->spec, framework_path, 0, &oss); + if (!err && OS_IsDir(&oss)) { + if (CheckForFileInFrameworkDir(out, framework_path, p->spec, fname)) { + Frameworks_AddFramework(framework_name, NULL, 1); + return 1; + } + } + } + + return 0; +} + +void Frameworks_AddPath(const OSPathSpec *oss) { + Paths_AddPath(&FrameworkPaths, Path_New(oss)); +} + +int Frameworks_AddFramework(const char *name, const char *version, Boolean hidden) { + char fullname[256]; + int i; + Path *p; + int n_paths; + OSSpec oss; + int err; + + sprintf(fullname, "%s.framework", name); + n_paths = Paths_Count(&FrameworkPaths); + for (i = 0; i < n_paths; i++) { + p = Paths_GetPath(&FrameworkPaths, i); + err = OS_MakeSpecWithPath(p->spec, fullname, 0, &oss); + if (!err && OS_IsDir(&oss)) { + if (Frameworks_Add(&FrameworkInfo, Framework_New(&oss, name, version, p, hidden))) { + if (version && strlen(version)) { + sprintf(fullname, "Versions/%s/Frameworks", version); + err = OS_MakeSpecWithPath(&oss.path, fullname, 0, &oss); + } else { + err = OS_MakeSpecWithPath(&oss.path, "Frameworks", 0, &oss); + } + if (!err && OS_IsDir(&oss)) + Frameworks_AddPath(&oss.path); + return 1; + } + } + } + + return 0; +} + +void Framework_GetEnvInfo() { + char path[256]; + char *env; + char *ptr; + OSSpec spec; + char name[64]; + char version[16]; + int err; + Boolean is_file; + +#line 672 + OPTION_ASSERT(Paths_Initialize(&FrameworkPaths) == 1); + OPTION_ASSERT(Frameworks_Initialize(&FrameworkInfo) == 1); + + env = getenv("MWFrameworkPaths"); + if (env) { + while (*env) { + ptr = path; + while (*env && *env != ':' && (ptr + 1) < &path[sizeof(path)]) + *(ptr++) = *(env++); + *ptr = 0; + while (*env && *env == ':') + env++; + + if (path[0]) { + if (strlen(path) >= sizeof(path)) { + CLReportError(64, sizeof(path), path); + } else { + err = OS_MakeSpec(path, &spec, &is_file); + if (!is_file && !err) { + Frameworks_AddPath(&spec.path); + } else { + CLReportError(23, path); + } + } + } + } + } + + env = getenv("MWFrameworkVersions"); + if (env) { + while (*env) { + ptr = name; + while (*env && *env != ':' && (ptr + 1) < &name[sizeof(name)]) + *(ptr++) = *(env++); + *ptr = 0; + while (*env && *env == ':') + env++; + + ptr = version; + while (*env && *env != ',' && (ptr + 1) < &version[sizeof(version)]) + *(ptr++) = *(env++); + *ptr = 0; + while (*env && *env == ',') + env++; + + if (name[0]) + Frameworks_AddFramework(name, version, 0); + } + } +} + +int Frameworks_GetCount() { + return FrameworkInfo.fwsCount; +} + +Paths_FWInfo *Frameworks_GetInfo(int which) { +#line 762 + OPTION_ASSERT(FrameworkInfo.fwsArray); + OPTION_ASSERT(FrameworkInfo.fwsCount > which); + return FrameworkInfo.fwsArray[which]; +} diff --git a/command_line/CmdLine/Src/Project/CLFiles.c b/command_line/CmdLine/Src/Project/CLFiles.c index e69de29..a13deaf 100644 --- a/command_line/CmdLine/Src/Project/CLFiles.c +++ b/command_line/CmdLine/Src/Project/CLFiles.c @@ -0,0 +1,165 @@ +#include "cmdline.h" + +File *File_New() { + File *file; + file = xmalloc(NULL, sizeof(File)); + if (!file) { + return NULL; + } else { + memset(file, 0, sizeof(File)); + return file; + } +} + +void File_Free(File *file) { + if (file) { + if (file->textdata) { + DisposeHandle(file->textdata); + file->textdata = NULL; + } + if (file->objectdata) { + DisposeHandle(file->objectdata); + file->objectdata = NULL; + } + if (file->browsedata) { + DisposeHandle(file->browsedata); + file->browsedata = NULL; + } + xfree(file); + } +} + +Boolean Files_Initialize(Files *this) { +#line 47 + OPTION_ASSERT(this != NULL); + return 1; +} + +Boolean Files_Terminate(Files *this) { + File *file; + File *next; + +#line 56 + OPTION_ASSERT(this != NULL); + + for (file = this->fileList; file; file = next) { + next = file->next; + File_Free(file); + } + + return 1; +} + +Boolean Files_AddFile(Files *this, File *file) { + return Files_InsertFile(this, file, this->fileCount); +} + +Boolean Files_InsertFile(Files *this, File *file, SInt32 position) { + File **scan; + +#line 80 + OPTION_ASSERT(this != NULL); + OPTION_ASSERT(file != NULL); + + if (position < 0) + position = 0; + else if (position > this->fileCount) + position = this->fileCount; + + scan = &this->fileList; + while (position > 0) { + scan = &(*scan)->next; + position--; + } + + file->filenum = this->fileCount++; + file->next = *scan; + *scan = file; + return 1; +} + +File *Files_GetFile(Files *this, SInt32 filenum) { + File *file; + +#line 104 + OPTION_ASSERT(this != NULL); + OPTION_ASSERT(filenum >= 0); + + file = this->fileList; + while (file && file->filenum != filenum) + file = file->next; + return file; +} + +File *Files_FindFile(Files *this, OSSpec *spec) { + File *file; + + file = this->fileList; + while (file && !OS_EqualSpec(&file->srcfss, spec)) + file = file->next; + return file; +} + +int Files_Count(Files *this) { +#line 127 + OPTION_ASSERT(this != NULL); + + return this->fileCount; +} + +Boolean VFiles_Initialize(VFile **list) { + *list = NULL; + return 1; +} + +void VFiles_Terminate(VFile **list) { + VFile *next; + + while (*list) { + next = (*list)->next; + DisposeHandle((*list)->data); + xfree(*list); + list = &next; + } + + *list = NULL; +} + +VFile *VFile_New(const char *name, Handle data) { + VFile *vf; + + vf = xmalloc(NULL, sizeof(VFile)); + if (!vf) + return NULL; + + strncpy(vf->displayName, name, sizeof(vf->displayName)); + vf->displayName[sizeof(vf->displayName) - 1] = 0; + + vf->data = NewHandle(0); + if (!vf->data || HandAndHand(data, vf->data)) { + xfree(vf); + return NULL; + } + + FixTextHandle(vf->data); + vf->next = NULL; + return vf; +} + +Boolean VFiles_Add(VFile **list, VFile *entry) { + VFile **scan = list; + while (*scan) + scan = &(*scan)->next; + *scan = entry; + return 1; +} + +VFile *VFiles_Find(VFile *list, const char *name) { + VFile *scan = list; + while (scan) { + if (!strcmp(scan->displayName, name)) + break; + scan = scan->next; + } + return scan; +} diff --git a/command_line/CmdLine/Src/Project/CLOverlays.c b/command_line/CmdLine/Src/Project/CLOverlays.c index e69de29..3437366 100644 --- a/command_line/CmdLine/Src/Project/CLOverlays.c +++ b/command_line/CmdLine/Src/Project/CLOverlays.c @@ -0,0 +1,296 @@ +#include "cmdline.h" + +Boolean Overlays_Initialize(Overlays *this) { + OvlGroup *grp; + Overlay *ovl; + OvlAddr addr; + SInt32 idx; + +#line 24 + OPTION_ASSERT(this); + + this->groups = NULL; + this->lastgrp = NULL; + this->grpcnt = 0; + addr.hi = 0; + addr.lo = 0; + + grp = OvlGroup_New("main_application", addr); + if (!grp) + return 0; + + ovl = Overlay_New("MAIN"); + if (!ovl) + return 0; + + OvlGroup_AddOverlay(grp, ovl, &idx); +#line 42 + OPTION_ASSERT(idx==0); + + Overlays_AddOvlGroup(this, grp, &idx); +#line 45 + OPTION_ASSERT(idx==0); + + return 1; +} + +Boolean Overlays_Terminate(Overlays *this) { + OvlGroup *grp; + OvlGroup *nxtgrp; + +#line 54 + OPTION_ASSERT(this); + + for (grp = this->groups; grp; grp = nxtgrp) { + nxtgrp = grp->next; + OvlGroup_Delete(grp); + xfree(grp); + } + + this->groups = NULL; + return 1; +} + +Boolean Overlays_AddOvlGroup(Overlays *this, OvlGroup *grp, SInt32 *grpnum) { +#line 70 + OPTION_ASSERT(this); + OPTION_ASSERT(grp); + + if (this->groups == NULL) + this->groups = grp; + else + this->lastgrp->next = grp; + this->lastgrp = grp; + + if (grpnum) + *grpnum = this->grpcnt; + this->grpcnt++; + + return 1; +} + +OvlGroup *Overlays_GetOvlGroup(Overlays *this, SInt32 grpnum) { + OvlGroup *grp; + SInt32 cnt = 0; + +#line 93 + OPTION_ASSERT(this); + + grp = this->groups; + while (grp && cnt < grpnum) { + grp = grp->next; + cnt++; + } + + if (cnt == grpnum) + return grp; + else + return NULL; +} + +SInt32 Overlays_CountGroups(Overlays *this) { + OvlGroup *scan; + int num = 0; + +#line 112 + OPTION_ASSERT(this); + + scan = this->groups; + while (scan) { + scan = scan->next; + num++; + } + + return num; +} + +Boolean Overlays_AddFileToOverlay(Overlays *this, SInt32 grpnum, SInt32 ovlnum, SInt32 filenum) { + Overlay *oly; + +#line 130 + OPTION_ASSERT(this); + + oly = Overlays_GetOverlayInGroup(this, grpnum, ovlnum); + if (oly) + return Overlay_AddFile(oly, filenum, NULL); + else + return 0; +} + +Overlay *Overlays_GetOverlayInGroup(Overlays *this, SInt32 grpnum, SInt32 ovlnum) { + OvlGroup *grp; + +#line 144 + OPTION_ASSERT(this); + + grp = Overlays_GetOvlGroup(this, grpnum); + if (grp) + return OvlGroup_GetOverlay(grp, ovlnum); + else + return NULL; +} + +SInt32 Overlays_GetFileInOverlay(Overlays *this, SInt32 grpnum, SInt32 ovlnum, SInt32 filnum) { + Overlay *oly; + +#line 160 + OPTION_ASSERT(this); + + oly = Overlays_GetOverlayInGroup(this, grpnum, ovlnum); + if (oly) + return Overlay_GetFile(oly, filnum); + else + return -1; +} + +OvlGroup *OvlGroup_New(const char *name, OvlAddr addr) { + OvlGroup *grp; + +#line 175 + OPTION_ASSERT(name); + + grp = xmalloc(NULL, sizeof(OvlGroup)); + if (grp) { + strncpy(grp->name, name, sizeof(grp->name)); + grp->name[sizeof(grp->name) - 1] = 0; + grp->addr = addr; + grp->lastoly = NULL; + grp->olys = NULL; + grp->olycnt = 0; + grp->next = NULL; + } else { +#line 188 + DO_INTERNAL_ERROR("Could not allocate %s", "overlay group"); + } + return grp; +} + +void OvlGroup_Delete(OvlGroup *grp) { + Overlay *scan; + Overlay *next; + +#line 197 + OPTION_ASSERT(grp); + + for (scan = grp->olys; scan; scan = next) { + next = scan->next; + Overlay_Delete(scan); + xfree(scan); + } + + grp->olys = NULL; +} + +Boolean OvlGroup_AddOverlay(OvlGroup *this, Overlay *oly, SInt32 *olynum) { +#line 211 + OPTION_ASSERT(this); + OPTION_ASSERT(oly); + + if (!this->lastoly) + this->olys = oly; + else + this->lastoly->next = oly; + this->lastoly = oly; + + if (olynum) + *olynum = this->olycnt; + this->olycnt++; + + return 1; +} + +Overlay *OvlGroup_GetOverlay(OvlGroup *this, SInt32 olynum) { + Overlay *oly; + SInt32 cnt = 0; + +#line 234 + OPTION_ASSERT(this); + + oly = this->olys; + while (oly && cnt < olynum) { + oly = oly->next; + cnt++; + } + + if (cnt == olynum) + return oly; + else + return NULL; +} + +SInt32 OvlGroup_CountOverlays(OvlGroup *this) { + Overlay *scan; + int num = 0; + +#line 254 + OPTION_ASSERT(this); + + scan = this->olys; + while (scan) { + scan = scan->next; + num++; + } + + return num; +} + +Overlay *Overlay_New(const char *name) { + Overlay *oly; + + oly = xmalloc(NULL, sizeof(Overlay)); + if (oly) { + strncpy(oly->name, name, sizeof(oly->name)); + oly->name[sizeof(oly->name) - 1] = 0; + oly->list = NULL; + oly->max = 0; + oly->cnt = 0; + oly->next = NULL; + } else { +#line 281 + DO_INTERNAL_ERROR("Could not allocate %s", "overlay"); + } + return oly; +} + +void Overlay_Delete(Overlay *oly) { +#line 288 + OPTION_ASSERT(oly); + + if (oly->list) + xfree(oly->list); + oly->list = NULL; +} + +Boolean Overlay_AddFile(Overlay *oly, SInt32 filenum, SInt32 *filnum) { +#line 296 + OPTION_ASSERT(oly); + + if (oly->cnt >= oly->max) { + oly->max += 16; + oly->list = xrealloc("overlay file list", oly->list, sizeof(SInt32) * oly->max); + } + oly->list[oly->cnt] = filenum; + + if (filnum) + *filnum = oly->cnt; + oly->cnt++; + + return 1; +} + +SInt32 Overlay_GetFile(Overlay *oly, SInt32 filnum) { +#line 314 + OPTION_ASSERT(oly); + + if (filnum < oly->cnt) + return oly->list[filnum]; + else + return -1; +} + +SInt32 Overlay_CountFiles(Overlay *oly) { +#line 323 + OPTION_ASSERT(oly); + + return oly->cnt; +} diff --git a/command_line/CmdLine/Src/Project/CLProj.c b/command_line/CmdLine/Src/Project/CLProj.c index e69de29..83b2ce1 100644 --- a/command_line/CmdLine/Src/Project/CLProj.c +++ b/command_line/CmdLine/Src/Project/CLProj.c @@ -0,0 +1,16 @@ +#include "cmdline.h" + +Boolean Proj_Initialize(Project *this) { + this->targets = NULL; + OS_GetCWD(&this->projectDirectory.path); + OS_MakeNameSpec("", &this->projectDirectory.name); + return 1; +} + +Boolean Proj_Terminate(Project *this) { +#line 25 + OPTION_ASSERT(this != NULL); + + Targets_Term(this->targets); + return 1; +} diff --git a/command_line/CmdLine/Src/Project/CLSegs.c b/command_line/CmdLine/Src/Project/CLSegs.c index e69de29..a0e006c 100644 --- a/command_line/CmdLine/Src/Project/CLSegs.c +++ b/command_line/CmdLine/Src/Project/CLSegs.c @@ -0,0 +1,123 @@ +#include "cmdline.h" + +Segment *Segment_New(const char *name, UInt16 attrs) { + Segment *seg = xmalloc(NULL, sizeof(Segment)); + strncpy(seg->name, name, sizeof(seg->name)); + seg->name[sizeof(seg->name) - 1] = 0; + seg->attrs = attrs; + return seg; +} + +void Segment_Free(Segment *seg) { + if (seg) + xfree(seg); +} + +Boolean Segments_Initialize(Segments *segs) { + Segment *jump; + Segment *main; + UInt16 idx; + +#line 36 + OPTION_ASSERT(segs != NULL); + + memset(segs, 0, sizeof(Segments)); + segs->segsArray = NULL; + + jump = Segment_New("Jump Table", 0x28); + Segments_AddSegment(segs, jump, &idx); +#line 44 + OPTION_ASSERT(idx==0); + + main = Segment_New("Main", 0xFFFF); + Segments_AddSegment(segs, main, &idx); +#line 49 + OPTION_ASSERT(idx==1); + + return 1; +} + +Boolean Segments_Terminate(Segments *segs) { + UInt16 index; + +#line 57 + OPTION_ASSERT(segs != NULL); + + if (segs->segsArray) { + for (index = 0; index < segs->segsCount; index++) + Segment_Free(segs->segsArray[index]); + xfree(segs->segsArray); + } + segs->segsArray = NULL; + + return 1; +} + +static Boolean Segments_GrowSegments(Segments *segs, UInt16 *index) { + Segment **newArray; + +#line 78 + OPTION_ASSERT(segs != NULL); + + if (segs->segsCount >= segs->arraySize) { + segs->arraySize += 20; + newArray = xrealloc("segments", segs->segsArray, sizeof(Segment *) * segs->arraySize); + segs->segsArray = newArray; + } + + *index = segs->segsCount++; + return 1; +} + +Boolean Segments_AddSegment(Segments *segs, Segment *seg, UInt16 *index) { + UInt16 ni; + + if (Segments_GrowSegments(segs, &ni)) { + segs->segsArray[ni] = seg; + *index = ni; + return 1; + } else { + return 0; + } +} + +Boolean Segments_InsertSegment(Segments *segs, UInt16 index, Segment *seg) { + UInt16 ni; + + if (Segments_GrowSegments(segs, &ni)) { + if (index > ni) + index = ni - 1; + memmove(&segs->segsArray[index + 1], &segs->segsArray[index], sizeof(Segment *) * (segs->segsCount - index)); + segs->segsArray[index] = seg; + return 1; + } else { + return 0; + } +} + +Boolean Segments_DeleteSegment(Segments *segs, UInt16 index) { + if (index >= segs->segsCount) + return 0; + + Segment_Free(segs->segsArray[index]); + memmove(&segs->segsArray[index], &segs->segsArray[index + 1], sizeof(Segment *) * (segs->segsCount - index)); + segs->segsCount--; + return 1; +} + +Segment *Segments_GetSegment(Segments *segs, UInt16 segnum) { +#line 137 + OPTION_ASSERT(segs != NULL); + + if (segnum < segs->segsCount) + return segs->segsArray[segnum]; + else + return NULL; +} + +UInt16 Segments_Count(const Segments *segs) { +#line 147 + OPTION_ASSERT(segs != NULL); + + return segs->segsCount; +} diff --git a/command_line/CmdLine/Src/uFileTypeMappings.c b/command_line/CmdLine/Src/uFileTypeMappings.c new file mode 100644 index 0000000..56aaea5 --- /dev/null +++ b/command_line/CmdLine/Src/uFileTypeMappings.c @@ -0,0 +1,31 @@ +#include "cmdline.h" + +// I don't actually have a name for this file, annoyingly enough + +void AddFileTypeMappingList(OSFileTypeMappings **list, const OSFileTypeMappingList *entry) { + OS_AddFileTypeMappingList(list, entry); +} + +void UseFileTypeMappings(OSFileTypeMappings *list) { + OS_UseFileTypeMappings(list); +} + +OSErr SetMacFileType(const FSSpec *spec, OSType mactype) { + OSSpec ospec; + OSErr err; + + err = OS_FSSpec_To_OSSpec(spec, &ospec); + if (err) + return err; + return OS_SetMacFileType(&ospec, mactype); +} + +OSErr GetMacFileType(const FSSpec *spec, OSType *mactype) { + OSSpec ospec; + OSErr err; + + err = OS_FSSpec_To_OSSpec(spec, &ospec); + if (err) + return err; + return OS_GetMacFileType(&ospec, mactype); +} diff --git a/compiler_and_linker/BackEnd/PowerPC/Disassembler/InstPPC.c b/compiler_and_linker/BackEnd/PowerPC/Disassembler/InstPPC.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/dumpmacho.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/dumpmacho.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/4byte_literals.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/4byte_literals.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/8byte_literals.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/8byte_literals.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/coalesced_sections.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/coalesced_sections.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/cstring_literals.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/cstring_literals.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/dylibs.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/dylibs.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/fvmlibs.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/fvmlibs.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/generic_reloc.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/generic_reloc.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/hppa_reloc.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/hppa_reloc.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/i860_reloc.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/i860_reloc.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/indirect_sections.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/indirect_sections.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/layout.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/layout.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/ld.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/ld.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/literal_pointers.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/literal_pointers.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/m68k_reloc.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/m68k_reloc.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/mod_sections.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/mod_sections.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/objects.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/objects.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/pass1.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/pass1.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/pass2.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/pass2.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/ppc_reloc.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/ppc_reloc.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/sections.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/sections.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/sparc_reloc.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/sparc_reloc.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/specs.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/specs.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/symbols.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/ld/symbols.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/arch.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/arch.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/best_arch.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/best_arch.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/bytesex.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/bytesex.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/get_arch_from_host.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/get_arch_from_host.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/get_toc_byte_sex.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/get_toc_byte_sex.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/guess_short_name.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/guess_short_name.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/hppa.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/hppa.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/ofile.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/ofile.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/reloc.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/reloc.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/seg_addr_table.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/seg_addr_table.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/set_arch_flag_name.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/set_arch_flag_name.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/swap_headers.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/swap_headers.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/version_number.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/libstuff/version_number.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/misc/libtool.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/misc/libtool.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/mwerks_allocate.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/mwerks_allocate.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/BackEnd/PowerPC/MachLinker/mwerks_execute.c b/compiler_and_linker/BackEnd/PowerPC/MachLinker/mwerks_execute.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsBackEnd.opt b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsBackEnd.opt new file mode 100644 index 0000000..1f06ca4 --- /dev/null +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsBackEnd.opt @@ -0,0 +1,786 @@ +/* forward declare */ extern OptionList alignPPC_conflicts; +/* forward declare */ extern OptionList tbtables_conflicts; + +/* BackEnd */ +SET_T optlstBackEnd882 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x2, + /* num = */ (char *) &pBackEnd.structalignment +}; +Option alignPPC_883 = { + /* names = */ "power|powerpc", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstBackEnd882, + /* sub = */ 0, + /* conflicts = */ &alignPPC_conflicts, + /* help = */ "PowerPC alignment" +}; +SET_T optlstBackEnd879 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pBackEnd.structalignment +}; +Option alignPPC_880 = { + /* names = */ "mac68k", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstBackEnd879, + /* sub = */ 0, + /* conflicts = */ &alignPPC_conflicts, + /* help = */ "Macintosh 680x0 alignment" +}; +SET_T optlstBackEnd876 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pBackEnd.structalignment +}; +Option alignPPC_877 = { + /* names = */ "mac68k4byte", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstBackEnd876, + /* sub = */ 0, + /* conflicts = */ &alignPPC_conflicts, + /* help = */ "Mac 680x0 4-byte alignment" +}; +GENERIC_T optlstBackEnd873 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_AddStringToDefines, + /* arg = */ (void *) "#pragma align_array_members on\n", + /* help = */ 0 +}; +Option optlstBackEnd_874 = { + /* names = */ "array|arraymembers", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstBackEnd873, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "align members of arrays" +}; +Option *optlstBackEnd_884_list[] = { + &alignPPC_883, + &alignPPC_880, + &alignPPC_877, + &optlstBackEnd_874, + 0 +}; +OptionList optlstBackEnd_884 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_COMPILER, + /* list = */ optlstBackEnd_884_list +}; +Option optlstBackEnd_885 = { + /* names = */ "align", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_SUB_OPTIONS, + /* param = */ 0, + /* sub = */ &optlstBackEnd_884, + /* conflicts = */ 0, + /* help = */ "specify structure/array alignment options" +}; +ONOFF_T optlstBackEnd887 = { + /* which = */ PARAMWHICH_OnOff, + /* flags = */ 0x00, + /* myname = */ 0, + /* next = */ 0, + /* var = */ &pBackEnd.common +}; +Option optlstBackEnd_888 = { + /* names = */ "common", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstBackEnd887, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "common variables" +}; +SET_T optlstBackEnd891 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pBackEnd.dynamic +}; +Option optlstBackEnd_892 = { + /* names = */ "dynamic", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstBackEnd891, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "dynamic addressing mode" +}; +ONOFF_T optlstBackEnd894 = { + /* which = */ PARAMWHICH_OnOff, + /* flags = */ 0x00, + /* myname = */ 0, + /* next = */ 0, + /* var = */ &pBackEnd.fpcontract +}; +Option optlstBackEnd_895 = { + /* names = */ "fp_contract", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstBackEnd894, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "generate fused multiply-add instructions" +}; +ONOFF_T optlstBackEnd897 = { + /* which = */ PARAMWHICH_OnOff, + /* flags = */ 0x00, + /* myname = */ 0, + /* next = */ 0, + /* var = */ &pBackEnd.implicit_templates +}; +Option optlstBackEnd_898 = { + /* names = */ "imp_templates", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstBackEnd897, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "implicit templates" +}; +ONOFF_T optlstBackEnd900 = { + /* which = */ PARAMWHICH_OnOff, + /* flags = */ 0x00, + /* myname = */ 0, + /* next = */ 0, + /* var = */ &pBackEnd.pic +}; +Option optlstBackEnd_901 = { + /* names = */ "pic", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstBackEnd900, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "generate position independent code" +}; +/* forward declare */ extern OptionList optlstBackEnd_932_conflicts; +SET_T optlstBackEnd930 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pBackEnd.processor +}; +Option optlstBackEnd_932_931 = { + /* names = */ "generic||ppc|power|powerc", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstBackEnd930, + /* sub = */ 0, + /* conflicts = */ &optlstBackEnd_932_conflicts, + /* help = */ "generic PowerPC" +}; +SET_T optlstBackEnd927 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pBackEnd.processor +}; +Option optlstBackEnd_932_928 = { + /* names = */ "601", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstBackEnd927, + /* sub = */ 0, + /* conflicts = */ &optlstBackEnd_932_conflicts, + /* help = */ "PPC 601" +}; +SET_T optlstBackEnd924 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x2, + /* num = */ (char *) &pBackEnd.processor +}; +Option optlstBackEnd_932_925 = { + /* names = */ "603", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstBackEnd924, + /* sub = */ 0, + /* conflicts = */ &optlstBackEnd_932_conflicts, + /* help = */ "PPC 603" +}; +SET_T optlstBackEnd921 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x3, + /* num = */ (char *) &pBackEnd.processor +}; +Option optlstBackEnd_932_922 = { + /* names = */ "603e", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstBackEnd921, + /* sub = */ 0, + /* conflicts = */ &optlstBackEnd_932_conflicts, + /* help = */ "PPC 603e" +}; +SET_T optlstBackEnd918 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x4, + /* num = */ (char *) &pBackEnd.processor +}; +Option optlstBackEnd_932_919 = { + /* names = */ "604", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstBackEnd918, + /* sub = */ 0, + /* conflicts = */ &optlstBackEnd_932_conflicts, + /* help = */ "PPC 604" +}; +SET_T optlstBackEnd915 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x5, + /* num = */ (char *) &pBackEnd.processor +}; +Option optlstBackEnd_932_916 = { + /* names = */ "604e", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstBackEnd915, + /* sub = */ 0, + /* conflicts = */ &optlstBackEnd_932_conflicts, + /* help = */ "PPC 604e" +}; +SET_T optlstBackEnd912 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x6, + /* num = */ (char *) &pBackEnd.processor +}; +Option optlstBackEnd_932_913 = { + /* names = */ "750", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstBackEnd912, + /* sub = */ 0, + /* conflicts = */ &optlstBackEnd_932_conflicts, + /* help = */ "PPC 750" +}; +SET_T optlstBackEnd909 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x7, + /* num = */ (char *) &pBackEnd.processor +}; +Option optlstBackEnd_932_910 = { + /* names = */ "7400", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstBackEnd909, + /* sub = */ 0, + /* conflicts = */ &optlstBackEnd_932_conflicts, + /* help = */ "PPC 7400 (AltiVec)" +}; +SET_T optlstBackEnd906 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x8, + /* num = */ (char *) &pBackEnd.processor +}; +Option optlstBackEnd_932_907 = { + /* names = */ "7450", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstBackEnd906, + /* sub = */ 0, + /* conflicts = */ &optlstBackEnd_932_conflicts, + /* help = */ "PPC 7450 (AltiVec)" +}; +SET_T optlstBackEnd903 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x7, + /* num = */ (char *) &pBackEnd.processor +}; +Option optlstBackEnd_932_904 = { + /* names = */ "altivec", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstBackEnd903, + /* sub = */ 0, + /* conflicts = */ &optlstBackEnd_932_conflicts, + /* help = */ "Altivec" +}; +Option *optlstBackEnd_932_list[] = { + &optlstBackEnd_932_931, + &optlstBackEnd_932_928, + &optlstBackEnd_932_925, + &optlstBackEnd_932_922, + &optlstBackEnd_932_919, + &optlstBackEnd_932_916, + &optlstBackEnd_932_913, + &optlstBackEnd_932_910, + &optlstBackEnd_932_907, + &optlstBackEnd_932_904, + 0 +}; +OptionList optlstBackEnd_932 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_COMPILER, + /* list = */ optlstBackEnd_932_list +}; +OptionList optlstBackEnd_932_conflicts = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_COMPILER, + /* list = */ optlstBackEnd_932_list +}; +Option optlstBackEnd_933 = { + /* names = */ "proc|processor||scheduling|target", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_SUB_OPTIONS, + /* param = */ 0, + /* sub = */ &optlstBackEnd_932, + /* conflicts = */ 0, + /* help = */ "specify target processor; currently used only for scheduling" +}; +ONOFF_T optlstBackEnd935 = { + /* which = */ PARAMWHICH_OnOff, + /* flags = */ 0x00, + /* myname = */ 0, + /* next = */ 0, + /* var = */ &pBackEnd.profiler +}; +Option optlstBackEnd_936 = { + /* names = */ "profile", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstBackEnd935, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "enable calls to profiler" +}; +SET_T optlstBackEnd939 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pBackEnd.readonlystrings +}; +Option optlstBackEnd_940 = { + /* names = */ "rostr|readonlystrings", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstBackEnd939, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "make string constants read-only" +}; +/* forward declare */ extern OptionList optlstBackEnd_950_conflicts; +SET_T optlstBackEnd948 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pBackEnd.tracebacktables +}; +Option optlstBackEnd_950_949 = { + /* names = */ "none", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstBackEnd948, + /* sub = */ 0, + /* conflicts = */ &optlstBackEnd_950_conflicts, + /* help = */ "don't generate traceback tables" +}; +SET_T optlstBackEnd945 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pBackEnd.tracebacktables +}; +Option optlstBackEnd_950_946 = { + /* names = */ "inline", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstBackEnd945, + /* sub = */ 0, + /* conflicts = */ &optlstBackEnd_950_conflicts, + /* help = */ "generate inline traceback tables" +}; +SET_T optlstBackEnd942 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x2, + /* num = */ (char *) &pBackEnd.tracebacktables +}; +Option optlstBackEnd_950_943 = { + /* names = */ "outofline", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstBackEnd942, + /* sub = */ 0, + /* conflicts = */ &optlstBackEnd_950_conflicts, + /* help = */ "generate out-of-line traceback tables" +}; +Option *optlstBackEnd_950_list[] = { + &optlstBackEnd_950_949, + &optlstBackEnd_950_946, + &optlstBackEnd_950_943, + 0 +}; +OptionList optlstBackEnd_950 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_COMPILER, + /* list = */ optlstBackEnd_950_list +}; +OptionList optlstBackEnd_950_conflicts = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_COMPILER, + /* list = */ optlstBackEnd_950_list +}; +Option tbtables_951 = { + /* names = */ "tbtable", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_SUB_OPTIONS | OTF_HAS_CONFLICTS, + /* param = */ 0, + /* sub = */ &optlstBackEnd_950, + /* conflicts = */ &tbtables_conflicts, + /* help = */ "specify traceback tables generation" +}; +Option optlstBackEnd_964 = { + /* names = */ "on", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ 0, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "turn on support for vector types / codegen" +}; +SET_T optlstBackEnd962 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pBackEnd.altivec +}; +Option optlstBackEnd_963 = { + /* names = */ "off", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstBackEnd962, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "turn off vectorization" +}; +SET_T optlstBackEnd958 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pBackEnd.vrsave +}; +Option optlstBackEnd_959 = { + /* names = */ "vrsave", + /* avail = */ OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstBackEnd958, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "use VRSAVE prologue/epilogue code" +}; +SET_T optlstBackEnd954 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pBackEnd.autovectorize +}; +Option optlstBackEnd_955 = { + /* names = */ "auto", + /* avail = */ OTF_SECRET | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstBackEnd954, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "auto-vectorize" +}; +Option *optlstBackEnd_965_list[] = { + &optlstBackEnd_964, + &optlstBackEnd_963, + &optlstBackEnd_959, + &optlstBackEnd_955, + 0 +}; +OptionList optlstBackEnd_965 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_COMPILER, + /* list = */ optlstBackEnd_965_list +}; +SET_T optlstBackEnd968 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pBackEnd.altivec +}; +Option optlstBackEnd_969 = { + /* names = */ "vector", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_SUB_OPTIONS, + /* param = */ (PARAM_T *) &optlstBackEnd968, + /* sub = */ &optlstBackEnd_965, + /* conflicts = */ 0, + /* help = */ "specify Altivec options" +}; +SET_T optlstBackEnd972 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pBackEnd.dynamic +}; +Option optlstBackEnd_973 = { + /* names = */ "static", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstBackEnd972, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "static addressing mode" +}; +SET_T optlstBackEnd976 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pBackEnd.altivec +}; +Option optlstBackEnd_977 = { + /* names = */ "faltivec", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstBackEnd976, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "turn on support for vector types / codegen" +}; +SET_T optlstBackEnd980 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pBackEnd.altivec +}; +Option optlstBackEnd_981 = { + /* names = */ "fno-altivec", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstBackEnd980, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "turn off support for vector types / codegen" +}; +SET_T optlstBackEnd984 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pBackEnd.common +}; +Option optlstBackEnd_985 = { + /* names = */ "fcommon", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstBackEnd984, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "allow common variable definitions" +}; +SET_T optlstBackEnd988 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pBackEnd.common +}; +Option optlstBackEnd_989 = { + /* names = */ "fno-common", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstBackEnd988, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "dont allow common variable definitions" +}; +SET_T optlstBackEnd992 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pBackEnd.pic +}; +Option optlstBackEnd_993 = { + /* names = */ "fpic", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstBackEnd992, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "generate position independent code" +}; +SET_T optlstBackEnd996 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pBackEnd.pic +}; +Option optlstBackEnd_997 = { + /* names = */ "fno-pic", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstBackEnd996, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "dont generate position independent code" +}; +SET_T optlstBackEnd1000 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pBackEnd.readonlystrings +}; +Option optlstBackEnd_1001 = { + /* names = */ "fwritable-strings", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstBackEnd1000, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "string constants are writable" +}; +SET_T optlstBackEnd1004 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pBackEnd.implicit_templates +}; +Option optlstBackEnd_1005 = { + /* names = */ "fimplicit-templates", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstBackEnd1004, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "implicit templates" +}; +SET_T optlstBackEnd1008 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pBackEnd.implicit_templates +}; +Option optlstBackEnd_1009 = { + /* names = */ "fno-implicit-templates", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstBackEnd1008, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "no implicit templates" +}; +Option *optlstBackEnd_1010_list[] = { + &optlstBackEnd_885, + &optlstBackEnd_888, + &optlstBackEnd_892, + &optlstBackEnd_895, + &optlstBackEnd_898, + &optlstBackEnd_901, + &optlstBackEnd_933, + &optlstBackEnd_936, + &optlstBackEnd_940, + &tbtables_951, + &optlstBackEnd_969, + &optlstBackEnd_973, + &optlstBackEnd_977, + &optlstBackEnd_981, + &optlstBackEnd_985, + &optlstBackEnd_989, + &optlstBackEnd_993, + &optlstBackEnd_997, + &optlstBackEnd_1001, + &optlstBackEnd_1005, + &optlstBackEnd_1009, + 0 +}; +OptionList optlstBackEnd = { + /* help = */ "Mach-O PowerPC CodeGen Options\n", + /* flags = */ LISTFLAGS_COMPILER, + /* list = */ optlstBackEnd_1010_list +}; +Option *alignPPC_000_list[] = { + &alignPPC_883, + &alignPPC_880, + &alignPPC_877, + 0 +}; +OptionList alignPPC_conflicts = { + /* help = */ 0, + /* flags = */ 0, + /* list = */ alignPPC_000_list +}; +Option *tbtables_001_list[] = { + &tbtables_951, + 0 +}; +OptionList tbtables_conflicts = { + /* help = */ 0, + /* flags = */ 0, + /* list = */ tbtables_001_list +}; diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsCmdLine.opt b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsCmdLine.opt new file mode 100644 index 0000000..dfdd158 --- /dev/null +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsCmdLine.opt @@ -0,0 +1,809 @@ +/* forward declare */ extern OptionList helpAllNormal_conflicts; +/* forward declare */ extern OptionList helpkey_conflicts; +/* forward declare */ extern OptionList helpTool_conflicts; + +/* CmdLine */ +MASK_T optlstCmdLine070 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 4, + /* ormask = */ 0x4000, + /* andmask = */ 0x0, + /* num = */ &parseopts.helpFlags +}; +Option optlstCmdLine_071 = { + /* names = */ "usage", + /* avail = */ OTF_GLOBAL | OTF_HIDE_DEFAULT | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLine070, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "show usage information" +}; +MASK_T optlstCmdLine066 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 4, + /* ormask = */ 0x100, + /* andmask = */ 0x0, + /* num = */ &parseopts.helpFlags +}; +Option optlstCmdLine_067 = { + /* names = */ "spaces", + /* avail = */ OTF_GLOBAL | OTF_HIDE_DEFAULT | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLine066, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "insert blank lines between options in printout" +}; +MASK_T optlstCmdLine062 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 4, + /* ormask = */ 0x6A, + /* andmask = */ 0x0, + /* num = */ &parseopts.helpFlags +}; +Option helpAllNormal_063 = { + /* names = */ "all", + /* avail = */ OTF_GLOBAL | OTF_HIDE_DEFAULT | OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstCmdLine062, + /* sub = */ 0, + /* conflicts = */ &helpAllNormal_conflicts, + /* help = */ "show all standard options" +}; +MASK_T optlstCmdLine058 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 4, + /* ormask = */ 0x80, + /* andmask = */ 0xE, + /* num = */ &parseopts.helpFlags +}; +Option helpAllNormal_059 = { + /* names = */ "normal", + /* avail = */ OTF_GLOBAL | OTF_HIDE_DEFAULT | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstCmdLine058, + /* sub = */ 0, + /* conflicts = */ &helpAllNormal_conflicts, + /* help = */ "show only standard options" +}; +MASK_T optlstCmdLine055 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 4, + /* ormask = */ 0x4, + /* andmask = */ 0x0, + /* num = */ &parseopts.helpFlags +}; +Option optlstCmdLine_056 = { + /* names = */ "obsolete", + /* avail = */ OTF_GLOBAL | OTF_HIDE_DEFAULT | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLine055, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "show obsolete options" +}; +MASK_T optlstCmdLine051 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 4, + /* ormask = */ 0x2, + /* andmask = */ 0x0, + /* num = */ &parseopts.helpFlags +}; +Option optlstCmdLine_052 = { + /* names = */ "ignored", + /* avail = */ OTF_GLOBAL | OTF_HIDE_DEFAULT | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLine051, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "show ignored options" +}; +MASK_T optlstCmdLine047 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 4, + /* ormask = */ 0x8, + /* andmask = */ 0x0, + /* num = */ &parseopts.helpFlags +}; +Option optlstCmdLine_048 = { + /* names = */ "deprecated", + /* avail = */ OTF_GLOBAL | OTF_HIDE_DEFAULT | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLine047, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "show deprecated options" +}; +MASK_T optlstCmdLine043 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 4, + /* ormask = */ 0x20, + /* andmask = */ 0x0, + /* num = */ &parseopts.helpFlags +}; +Option optlstCmdLine_044 = { + /* names = */ "meaningless", + /* avail = */ OTF_GLOBAL | OTF_HIDE_DEFAULT | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLine043, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "show options meaningless for this target" +}; +MASK_T optlstCmdLine039 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 4, + /* ormask = */ 0x40, + /* andmask = */ 0x0, + /* num = */ &parseopts.helpFlags +}; +Option optlstCmdLine_040 = { + /* names = */ "compatible", + /* avail = */ OTF_GLOBAL | OTF_HIDE_DEFAULT | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLine039, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "show compatibility options" +}; +MASK_T optlstCmdLine035 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 4, + /* ormask = */ 0x10, + /* andmask = */ 0x0, + /* num = */ &parseopts.helpFlags +}; +Option optlstCmdLine_036 = { + /* names = */ "secret", + /* avail = */ OTF_GLOBAL | OTF_SECRET | OTF_HIDE_DEFAULT | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLine035, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ 0 +}; +MASK_T optlstCmdLine029 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 4, + /* ormask = */ 0x1, + /* andmask = */ 0x0, + /* num = */ &parseopts.helpFlags +}; +STRING_T optlstCmdLine031 = { + /* which = */ PARAMWHICH_String, + /* flags = */ 0x00, + /* myname = */ "name", + /* next = */ (PARAM_T *) &optlstCmdLine029, + /* maxlen = */ 64, + /* pstring = */ 0, + /* str = */ parseopts.helpKey +}; +Option helpkey_032 = { + /* names = */ "opt|option", + /* avail = */ OTF_GLOBAL | OTF_HIDE_DEFAULT | OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstCmdLine031, + /* sub = */ 0, + /* conflicts = */ &helpkey_conflicts, + /* help = */ "show help for a given option" +}; +STRING_T optlstCmdLine025 = { + /* which = */ PARAMWHICH_String, + /* flags = */ 0x00, + /* myname = */ "keyword", + /* next = */ 0, + /* maxlen = */ 64, + /* pstring = */ 0, + /* str = */ parseopts.helpKey +}; +Option helpkey_026 = { + /* names = */ "search", + /* avail = */ OTF_GLOBAL | OTF_HIDE_DEFAULT | OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstCmdLine025, + /* sub = */ 0, + /* conflicts = */ &helpkey_conflicts, + /* help = */ "show help for an option whose name or help contains 'keyword' (case-sensitive)" +}; +MASK_T optlstCmdLine020 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 4, + /* ormask = */ 0x8000, + /* andmask = */ 0x0, + /* num = */ &parseopts.helpFlags +}; +STRING_T optlstCmdLine022 = { + /* which = */ PARAMWHICH_String, + /* flags = */ 0x00, + /* myname = */ "keyword", + /* next = */ (PARAM_T *) &optlstCmdLine020, + /* maxlen = */ 64, + /* pstring = */ 0, + /* str = */ parseopts.helpKey +}; +Option helpkey_023 = { + /* names = */ "group", + /* avail = */ OTF_GLOBAL | OTF_HIDE_DEFAULT | OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstCmdLine022, + /* sub = */ 0, + /* conflicts = */ &helpkey_conflicts, + /* help = */ "show help for groups whose names contain 'keyword' (case-sensitive)" +}; +MASK_T optlstCmdLine011 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 4, + /* ormask = */ 0xC00, + /* andmask = */ 0x0, + /* num = */ &parseopts.helpFlags +}; +Option helpTool_012 = { + /* names = */ "all", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstCmdLine011, + /* sub = */ 0, + /* conflicts = */ &helpTool_conflicts, + /* help = */ "show all options available in this tool" +}; +MASK_T optlstCmdLine007 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 4, + /* ormask = */ 0x400, + /* andmask = */ 0x800, + /* num = */ &parseopts.helpFlags +}; +Option helpTool_008 = { + /* names = */ "this", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstCmdLine007, + /* sub = */ 0, + /* conflicts = */ &helpTool_conflicts, + /* help = */ "show options executed by this tool" +}; +MASK_T optlstCmdLine004 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 4, + /* ormask = */ 0x800, + /* andmask = */ 0x400, + /* num = */ &parseopts.helpFlags +}; +Option helpTool_005 = { + /* names = */ "other|skipped", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstCmdLine004, + /* sub = */ 0, + /* conflicts = */ &helpTool_conflicts, + /* help = */ "show options passed to another tool" +}; +MASK_T optlstCmdLine001 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 4, + /* ormask = */ 0xC00, + /* andmask = */ 0x200, + /* num = */ &parseopts.helpFlags +}; +Option helpTool_002 = { + /* names = */ "both", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstCmdLine001, + /* sub = */ 0, + /* conflicts = */ &helpTool_conflicts, + /* help = */ "show options used in all tools" +}; +Option *optlstCmdLine_013_list[] = { + &helpTool_012, + &helpTool_008, + &helpTool_005, + &helpTool_002, + 0 +}; +OptionList optlstCmdLine_013 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_COMPILER, + /* list = */ optlstCmdLine_013_list +}; +MASK_T optlstCmdLine016 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 4, + /* ormask = */ 0x200, + /* andmask = */ 0x0, + /* num = */ &parseopts.helpFlags +}; +Option optlstCmdLine_017 = { + /* names = */ "tool", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER | OTF_HAS_SUB_OPTIONS, + /* param = */ (PARAM_T *) &optlstCmdLine016, + /* sub = */ &optlstCmdLine_013, + /* conflicts = */ 0, + /* help = */ "categorize groups of options by tool" +}; +Option *optlstCmdLine_072_list[] = { + &optlstCmdLine_071, + &optlstCmdLine_067, + &helpAllNormal_063, + &helpAllNormal_059, + &optlstCmdLine_056, + &optlstCmdLine_052, + &optlstCmdLine_048, + &optlstCmdLine_044, + &optlstCmdLine_040, + &optlstCmdLine_036, + &helpkey_032, + &helpkey_026, + &helpkey_023, + &optlstCmdLine_017, + 0 +}; +OptionList optlstCmdLine_072 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_COMPILER, + /* list = */ optlstCmdLine_072_list +}; +MASK_T optlstCmdLine075 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 4, + /* ormask = */ 0x680, + /* andmask = */ 0x0, + /* num = */ &parseopts.helpFlags +}; +SET_T optlstCmdLine078 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLine075, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &parseopts.hadAnyOutput +}; +SET_T optlstCmdLine081 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLine078, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &parseopts.showHelp +}; +Option optlstCmdLine_082 = { + /* names = */ "help||-help", + /* avail = */ OTF_GLOBAL | OTF_HIDE_DEFAULT | OTF_ONLY_ONCE | OTF_TOOL_COMPILER | OTF_HAS_SUB_OPTIONS | OTF_SUB_OPTIONS_OPTIONAL, + /* param = */ (PARAM_T *) &optlstCmdLine081, + /* sub = */ &optlstCmdLine_072, + /* conflicts = */ 0, + /* help = */ "display help" +}; +SET_T optlstCmdLine085 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &parseopts.hadAnyOutput +}; +GENERIC_T optlstCmdLine087 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLine085, + /* parse = */ &Opt_PrintVersion, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +Option optlstCmdLine_088 = { + /* names = */ "version", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLine087, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "show version, configuration, and build date" +}; +SET_T optlstCmdLine091 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pCmdLine.timeWorking +}; +Option optlstCmdLine_092 = { + /* names = */ "timing", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstCmdLine091, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "collect timing statistics" +}; +GENERIC_T optlstCmdLine094 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_PrintVersion, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +SET_T optlstCmdLine096 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLine094, + /* size = */ 2, + /* value = */ 0x1, + /* num = */ (char *) &pCmdLine.verbose +}; +Option optlstCmdLine_progress = { + /* names = */ "progress", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstCmdLine096, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "show progress and version" +}; +GENERIC_T optlstCmdLine099 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_PrintVersion, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +GENERIC_T optlstCmdLine101 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLine099, + /* parse = */ &Opt_IncreaseVerbosity, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +Option optlstCmdLine_102 = { + /* names = */ "v|verbose", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstCmdLine101, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "verbose information; cumulative; implies ~~progress" +}; +SET_T optlstCmdLine105 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &parseopts.alwaysUsePaths +}; +Option optlstCmdLine_106 = { + /* names = */ "search", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstCmdLine105, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "search access paths for source files specified on the command line; may specify object code and libraries as well; this option provides the IDE's 'access paths' functionality" +}; +SET_T optlstCmdLine109 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pCmdLine.showLines +}; +Option optlstCmdLine_110 = { + /* names = */ "lines", + /* avail = */ OTF_GLOBAL | OTF_SECRET | OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstCmdLine109, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "show line count" +}; +SET_T optlstCmdLine113 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pCmdLine.noWrapOutput +}; +Option optlstCmdLine_114 = { + /* names = */ "wraplines", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstCmdLine113, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "word wrap messages" +}; +NUM_T optlstCmdLine116 = { + /* which = */ PARAMWHICH_Number, + /* flags = */ 0x00, + /* myname = */ "max", + /* next = */ 0, + /* size = */ 2, + /* fit = */ 0, + /* lo = */ 0, + /* hi = */ 0, + /* num = */ &pCmdLine.maxErrors +}; +Option optlstCmdLine_117 = { + /* names = */ "maxerrors", + /* avail = */ OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstCmdLine116, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "specify maximum number of errors to print, zero means no maximum" +}; +NUM_T optlstCmdLine119 = { + /* which = */ PARAMWHICH_Number, + /* flags = */ 0x00, + /* myname = */ "max", + /* next = */ 0, + /* size = */ 2, + /* fit = */ 0, + /* lo = */ 0, + /* hi = */ 0, + /* num = */ &pCmdLine.maxWarnings +}; +Option optlstCmdLine_120 = { + /* names = */ "maxwarnings", + /* avail = */ OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstCmdLine119, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "specify maximum number of warnings to print, zero means no maximum" +}; +/* forward declare */ extern OptionList optlstCmdLine_136_conflicts; +SET_T optlstCmdLine134 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x2, + /* num = */ (char *) &pCmdLine.msgStyle +}; +Option optlstCmdLine_136_135 = { + /* names = */ "mpw", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstCmdLine134, + /* sub = */ 0, + /* conflicts = */ &optlstCmdLine_136_conflicts, + /* help = */ "use MPW message style" +}; +SET_T optlstCmdLine131 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x0, + /* num = */ (char *) &pCmdLine.msgStyle +}; +Option optlstCmdLine_136_132 = { + /* names = */ "std", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstCmdLine131, + /* sub = */ 0, + /* conflicts = */ &optlstCmdLine_136_conflicts, + /* help = */ "use standard message style" +}; +SET_T optlstCmdLine128 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x1, + /* num = */ (char *) &pCmdLine.msgStyle +}; +Option optlstCmdLine_136_129 = { + /* names = */ "gcc", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstCmdLine128, + /* sub = */ 0, + /* conflicts = */ &optlstCmdLine_136_conflicts, + /* help = */ "use GCC-like message style" +}; +SET_T optlstCmdLine125 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x3, + /* num = */ (char *) &pCmdLine.msgStyle +}; +Option optlstCmdLine_136_126 = { + /* names = */ "IDE", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstCmdLine125, + /* sub = */ 0, + /* conflicts = */ &optlstCmdLine_136_conflicts, + /* help = */ "use CW IDE-like message style" +}; +SET_T optlstCmdLine122 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x4, + /* num = */ (char *) &pCmdLine.msgStyle +}; +Option optlstCmdLine_136_123 = { + /* names = */ "parseable", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstCmdLine122, + /* sub = */ 0, + /* conflicts = */ &optlstCmdLine_136_conflicts, + /* help = */ "use context-free machine-parseable message style" +}; +Option *optlstCmdLine_136_list[] = { + &optlstCmdLine_136_135, + &optlstCmdLine_136_132, + &optlstCmdLine_136_129, + &optlstCmdLine_136_126, + &optlstCmdLine_136_123, + 0 +}; +OptionList optlstCmdLine_136 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_COMPILER | LISTFLAGS_LINKER | LISTFLAGS_DISASSEMBLER, + /* list = */ optlstCmdLine_136_list +}; +OptionList optlstCmdLine_136_conflicts = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_COMPILER | LISTFLAGS_LINKER | LISTFLAGS_DISASSEMBLER, + /* list = */ optlstCmdLine_136_list +}; +Option optlstCmdLine_137 = { + /* names = */ "msgstyle", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER | OTF_HAS_SUB_OPTIONS, + /* param = */ 0, + /* sub = */ &optlstCmdLine_136, + /* conflicts = */ 0, + /* help = */ "set error/warning message style" +}; +GENERIC_T optlstCmdLine139 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_SavePrefs, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +SET_T optlstCmdLine142 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLine139, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pCmdLine.stderr2stdout +}; +Option optlstCmdLine_143 = { + /* names = */ "stderr", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstCmdLine142, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "use separate stderr and stdout streams; if using ~~nostderr, stderr goes to stdout" +}; +GENERIC_T optlstCmdLine145 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_FindAndAddFile, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +Option optlstCmdLine_146 = { + /* names = */ "", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLine145, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ 0 +}; +Option *optlstCmdLine_147_list[] = { + &optlstCmdLine_082, + &optlstCmdLine_088, + &optlstCmdLine_092, + &optlstCmdLine_progress, + &optlstCmdLine_102, + &optlstCmdLine_106, + &optlstCmdLine_110, + &optlstCmdLine_114, + &optlstCmdLine_117, + &optlstCmdLine_120, + &optlstCmdLine_137, + &optlstCmdLine_143, + &optlstCmdLine_146, + 0 +}; +OptionList optlstCmdLine = { + /* help = */ "General Command-Line Options\n\tAll the options are passed to the linker unless otherwise noted.\b\tPlease see '~~help usage' for details about the meaning of this help.\b", + /* flags = */ LISTFLAGS_COMPILER | LISTFLAGS_LINKER | LISTFLAGS_DISASSEMBLER, + /* list = */ optlstCmdLine_147_list +}; +Option *helpAllNormal_000_list[] = { + &helpAllNormal_063, + &helpAllNormal_059, + 0 +}; +OptionList helpAllNormal_conflicts = { + /* help = */ 0, + /* flags = */ 0, + /* list = */ helpAllNormal_000_list +}; +Option *helpkey_001_list[] = { + &helpkey_032, + &helpkey_026, + &helpkey_023, + 0 +}; +OptionList helpkey_conflicts = { + /* help = */ 0, + /* flags = */ 0, + /* list = */ helpkey_001_list +}; +Option *helpTool_002_list[] = { + &helpTool_012, + &helpTool_008, + &helpTool_005, + &helpTool_002, + 0 +}; +OptionList helpTool_conflicts = { + /* help = */ 0, + /* flags = */ 0, + /* list = */ helpTool_002_list +}; diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsCmdLineCompiler.opt b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsCmdLineCompiler.opt new file mode 100644 index 0000000..8f5b7c0 --- /dev/null +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsCmdLineCompiler.opt @@ -0,0 +1,1028 @@ +/* forward declare */ extern OptionList precompile_conflicts; + +/* CmdLineCompiler */ +SET_T optlstCmdLineCompiler150 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pCmdLineCompiler.browserEnabled +}; +Option optlstCmdLineCompiler_151 = { + /* names = */ "browse", + /* avail = */ OTF_GLOBAL | OTF_SECRET | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler150, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "record browse information to file named .b" +}; +SET_T optlstCmdLineCompiler153 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x2, + /* num = */ (char *) &pCmdLine.state +}; +Option optlstCmdLineCompiler_154 = { + /* names = */ "c", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler153, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "compile only, do not link" +}; +GENERIC_T optlstCmdLineCompiler156 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_SetStage, + /* arg = */ (void *) "Cg", + /* help = */ 0 +}; +Option optlstCmdLineCompiler_157 = { + /* names = */ "codegen", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler156, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "generate object code" +}; +SET_T optlstCmdLineCompiler160 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pCmdLineCompiler.canonicalIncludes +}; +Option optlstCmdLineCompiler_161 = { + /* names = */ "convertpaths", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler160, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "interpret #include filepaths specified for a foreign operating system; i.e., or ; when enabled, '/' and '\\' will separate directories and cannot be used in filenames" +}; +/* forward declare */ extern OptionList optlstCmdLineCompiler_174_conflicts; +SET_T optlstCmdLineCompiler172 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x0, + /* num = */ (char *) &pCmdLineCompiler.includeSearch +}; +Option optlstCmdLineCompiler_174_173 = { + /* names = */ "proj", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler172, + /* sub = */ 0, + /* conflicts = */ &optlstCmdLineCompiler_174_conflicts, + /* help = */ "begin search in current working directory" +}; +SET_T optlstCmdLineCompiler169 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x1, + /* num = */ (char *) &pCmdLineCompiler.includeSearch +}; +Option optlstCmdLineCompiler_174_170 = { + /* names = */ "source", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler169, + /* sub = */ 0, + /* conflicts = */ &optlstCmdLineCompiler_174_conflicts, + /* help = */ "begin search in directory of source file" +}; +SET_T optlstCmdLineCompiler166 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x2, + /* num = */ (char *) &pCmdLineCompiler.includeSearch +}; +Option optlstCmdLineCompiler_174_167 = { + /* names = */ "explicit", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler166, + /* sub = */ 0, + /* conflicts = */ &optlstCmdLineCompiler_174_conflicts, + /* help = */ "no implicit directory; only search '~~I' or '~~ir' paths" +}; +SET_T optlstCmdLineCompiler163 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x3, + /* num = */ (char *) &pCmdLineCompiler.includeSearch +}; +Option optlstCmdLineCompiler_174_164 = { + /* names = */ "include", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler163, + /* sub = */ 0, + /* conflicts = */ &optlstCmdLineCompiler_174_conflicts, + /* help = */ "begin search in directory of referencing file" +}; +Option *optlstCmdLineCompiler_174_list[] = { + &optlstCmdLineCompiler_174_173, + &optlstCmdLineCompiler_174_170, + &optlstCmdLineCompiler_174_167, + &optlstCmdLineCompiler_174_164, + 0 +}; +OptionList optlstCmdLineCompiler_174 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_COMPILER, + /* list = */ optlstCmdLineCompiler_174_list +}; +OptionList optlstCmdLineCompiler_174_conflicts = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_COMPILER, + /* list = */ optlstCmdLineCompiler_174_list +}; +Option optlstCmdLineCompiler_175 = { + /* names = */ "cwd", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_SUB_OPTIONS, + /* param = */ 0, + /* sub = */ &optlstCmdLineCompiler_174, + /* conflicts = */ 0, + /* help = */ "specify #include searching semantics: before searching any access paths, the path specified by this option will be searched" +}; +SETTING_T optlstCmdLineCompiler176 = { + /* which = */ PARAMWHICH_Setting, + /* flags = */ 0x06, + /* myname = */ "name", + /* next = */ 0, + /* parse = */ &Opt_DefineSymbol, + /* valuename = */ "value" +}; +Option optlstCmdLineCompiler_177 = { + /* names = */ "D|d|define", + /* avail = */ OTF_STICKY | OTF_CASED | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler176, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "define symbol 'name' to 'value' if specified, else '1'" +}; +SET_T optlstCmdLineCompiler180 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &useDefaultIncludes +}; +Option optlstCmdLineCompiler_181 = { + /* names = */ "defaults", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER | OTF_TOOL_LINKER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler180, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "same as '~~[no]stdinc'" +}; +GENERIC_T optlstCmdLineCompiler183 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_SetStage, + /* arg = */ (void *) "Ds", + /* help = */ 0 +}; +SET_T optlstCmdLineCompiler185 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler183, + /* size = */ 2, + /* value = */ 0x2, + /* num = */ (char *) &pCmdLine.state +}; +Option optlstCmdLineCompiler_186 = { + /* names = */ "dis|disassemble", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler185, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "disassemble files to stdout" +}; +GENERIC_T optlstCmdLineCompiler188 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_SetStage, + /* arg = */ (void *) "Pp", + /* help = */ 0 +}; +SET_T optlstCmdLineCompiler190 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler188, + /* size = */ 2, + /* value = */ 0x2, + /* num = */ (char *) &pCmdLine.state +}; +Option optlstCmdLineCompiler_191 = { + /* names = */ "E", + /* avail = */ OTF_GLOBAL | OTF_CASED | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler190, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "preprocess source files" +}; +GENERIC_T optlstCmdLineCompiler193 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_AddStringToDefines, + /* arg = */ (void *) "#pragma simple_prepdump on\n", + /* help = */ 0 +}; +GENERIC_T optlstCmdLineCompiler195 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler193, + /* parse = */ &Opt_SetStage, + /* arg = */ (void *) "Pp", + /* help = */ 0 +}; +SET_T optlstCmdLineCompiler197 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler195, + /* size = */ 2, + /* value = */ 0x2, + /* num = */ (char *) &pCmdLine.state +}; +Option optlstCmdLineCompiler_198 = { + /* names = */ "EP", + /* avail = */ OTF_GLOBAL | OTF_CASED | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler197, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "preprocess and strip out #line directives" +}; +STRING_T optlstCmdLineCompiler200 = { + /* which = */ PARAMWHICH_String, + /* flags = */ 0x00, + /* myname = */ "extension", + /* next = */ 0, + /* maxlen = */ 15, + /* pstring = */ 0, + /* str = */ pCmdLineCompiler.objFileExt +}; +Option optlstCmdLineCompiler_201 = { + /* names = */ "ext", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler200, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "specify extension for generated object files; with a leading period ('.'), appends extension; without, replaces source file's extension" +}; +GENERIC_T optlstCmdLineCompiler203 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x00, + /* myname = */ "path", + /* next = */ 0, + /* parse = */ &Opt_AddFrameworkPath, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +Option optlstCmdLineCompiler_204 = { + /* names = */ "F", + /* avail = */ OTF_GLOBAL | OTF_CASED | OTF_TOOL_COMPILER | OTF_TOOL_LINKER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler203, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "append access path to current framework access paths list" +}; +GENERIC_T optlstCmdLineCompiler206 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x00, + /* myname = */ "path", + /* next = */ 0, + /* parse = */ &Opt_AddFramework, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +Option optlstCmdLineCompiler_207 = { + /* names = */ "framework", + /* avail = */ OTF_GLOBAL | OTF_CASED | OTF_TOOL_COMPILER | OTF_TOOL_LINKER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler206, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "append framework to the frameworks list" +}; +SET_T optlstCmdLineCompiler210 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pCmdLineCompiler.compileIgnored +}; +Option optlstCmdLineCompiler_211 = { + /* names = */ "force_compile", + /* avail = */ OTF_GLOBAL | OTF_SECRET | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler210, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "force compilation of unrecognized files" +}; +SET_T optlstCmdLineCompiler213 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x3, + /* num = */ (char *) &pCmdLineCompiler.includeSearch +}; +SET_T optlstCmdLineCompiler216 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler213, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &dashIMinusMovesPaths +}; +SET_T optlstCmdLineCompiler219 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler216, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &namingSysPaths +}; +Option optlstCmdLineCompiler_220 = { + /* names = */ "gccinc|gccincludes", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler219, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "adopt GCC #include semantics: add '~~I' paths to system list if '~~I-' is not specified, and search directory of referencing file first for #includes (same as '~~cwd include')" +}; +SET_T optlstCmdLineCompiler222 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x2, + /* num = */ (char *) &pCmdLineCompiler.includeSearch +}; +SET_T optlstCmdLineCompiler225 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler222, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &usedDashIMinus +}; +SET_T optlstCmdLineCompiler228 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler225, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &namingSysPaths +}; +GENERIC_T optlstCmdLineCompiler230 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler228, + /* parse = */ &Opt_MaybeMoveAccessPaths, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +Option optlstCmdLineCompiler_231 = { + /* names = */ "i-|I-", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler230, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "change target for '~~I' access paths to the system list; implies '~~cwd explicit'; while compiling, user paths then system paths are searched when using '#include \"...\"; only system paths are searched with '#include <...>'" +}; +GENERIC_T optlstCmdLineCompiler233 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x00, + /* myname = */ "path", + /* next = */ 0, + /* parse = */ &Opt_AddAccessPath, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +Option optlstCmdLineCompiler_234 = { + /* names = */ "I|i", + /* avail = */ OTF_GLOBAL | OTF_STICKY | OTF_CASED | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler233, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "append access path to current #include list(see '~~gccincludes' and '~~I-')" +}; +GENERIC_T optlstCmdLineCompiler236 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x00, + /* myname = */ "file", + /* next = */ 0, + /* parse = */ &Opt_AddPrefixFile, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +Option optlstCmdLineCompiler_237 = { + /* names = */ "include", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler236, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "prefix text file or precompiled header onto all source files" +}; +GENERIC_T optlstCmdLineCompiler239 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x00, + /* myname = */ "path", + /* next = */ 0, + /* parse = */ &Opt_AddAccessPath, + /* arg = */ (void *) "", + /* help = */ 0 +}; +Option optlstCmdLineCompiler_240 = { + /* names = */ "ir", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler239, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "append a recursive access path to current #include list" +}; +SET_T optlstCmdLineCompiler243 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pCmdLineCompiler.keepObjects +}; +Option optlstCmdLineCompiler_244 = { + /* names = */ "keepobj|keepobjects", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler243, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "keep object files generated after invoking linker; if disabled, intermediate object files are temporary and deleted after link stage; objects are always kept when compiling" +}; +STRING_T optlstCmdLineCompiler246 = { + /* which = */ PARAMWHICH_String, + /* flags = */ 0x00, + /* myname = */ 0, + /* next = */ 0, + /* maxlen = */ 64, + /* pstring = */ 0, + /* str = */ pCmdLineCompiler.linkerName +}; +Option optlstCmdLineCompiler_247 = { + /* names = */ "linkername", + /* avail = */ OTF_GLOBAL | OTF_SECRET | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler246, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "give name of alternate linker" +}; +GENERIC_T optlstCmdLineCompiler249 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_SetStage, + /* arg = */ (void *) "Dp", + /* help = */ 0 +}; +SET_T optlstCmdLineCompiler251 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler249, + /* size = */ 2, + /* value = */ 0x2, + /* num = */ (char *) &pCmdLine.state +}; +Option optlstCmdLineCompiler_252 = { + /* names = */ "M", + /* avail = */ OTF_GLOBAL | OTF_CASED | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler251, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "scan source files for dependencies and emit Makefile, do not generate object code" +}; +GENERIC_T optlstCmdLineCompiler254 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_SetStage, + /* arg = */ (void *) "Dp", + /* help = */ 0 +}; +SET_T optlstCmdLineCompiler257 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler254, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pCmdLineCompiler.depsOnlyUserFiles +}; +SET_T optlstCmdLineCompiler259 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler257, + /* size = */ 2, + /* value = */ 0x2, + /* num = */ (char *) &pCmdLine.state +}; +Option optlstCmdLineCompiler_260 = { + /* names = */ "MM", + /* avail = */ OTF_GLOBAL | OTF_CASED | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler259, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "like ~~M, but do not list system include files" +}; +GENERIC_T optlstCmdLineCompiler262 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_SetStage, + /* arg = */ (void *) "DpCg", + /* help = */ 0 +}; +MASK_T optlstCmdLineCompiler265 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler262, + /* size = */ 2, + /* ormask = */ 0xA, + /* andmask = */ 0x0, + /* num = */ &pCmdLine.toDisk +}; +SET_T optlstCmdLineCompiler267 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler265, + /* size = */ 2, + /* value = */ 0x2, + /* num = */ (char *) &pCmdLine.state +}; +Option optlstCmdLineCompiler_268 = { + /* names = */ "MD", + /* avail = */ OTF_GLOBAL | OTF_CASED | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler267, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "like ~~M, but write dependency map to a file and generate object code" +}; +GENERIC_T optlstCmdLineCompiler270 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_SetStage, + /* arg = */ (void *) "DpCg", + /* help = */ 0 +}; +SET_T optlstCmdLineCompiler273 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler270, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pCmdLineCompiler.depsOnlyUserFiles +}; +MASK_T optlstCmdLineCompiler276 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler273, + /* size = */ 2, + /* ormask = */ 0xA, + /* andmask = */ 0x0, + /* num = */ &pCmdLine.toDisk +}; +SET_T optlstCmdLineCompiler278 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler276, + /* size = */ 2, + /* value = */ 0x2, + /* num = */ (char *) &pCmdLine.state +}; +Option optlstCmdLineCompiler_279 = { + /* names = */ "MMD", + /* avail = */ OTF_GLOBAL | OTF_CASED | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler278, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "like ~~MD, but do not list system include files" +}; +GENERIC_T optlstCmdLineCompiler281 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_SetStage, + /* arg = */ (void *) "Dp", + /* help = */ 0 +}; +SET_T optlstCmdLineCompiler283 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler281, + /* size = */ 2, + /* value = */ 0x2, + /* num = */ (char *) &pCmdLine.state +}; +Option optlstCmdLineCompiler_284 = { + /* names = */ "make", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler283, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "scan source files for dependencies and emit Makefile, do not generate object code" +}; +SET_T optlstCmdLineCompiler287 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pCmdLineCompiler.noFail +}; +Option optlstCmdLineCompiler_288 = { + /* names = */ "nofail", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler287, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "continue working after errors in earlier files" +}; +SET_T optlstCmdLineCompiler290 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x2, + /* num = */ (char *) &pCmdLine.state +}; +Option optlstCmdLineCompiler_291 = { + /* names = */ "nolink", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler290, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "compile only, do not link" +}; +GENERIC_T optlstCmdLineCompiler293 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_SavePrefs, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +SET_T optlstCmdLineCompiler295 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler293, + /* size = */ 1, + /* value = */ 0x2, + /* num = */ (char *) &pCmdLineCompiler.forcePrecompile +}; +Option precompile_296 = { + /* names = */ "noprecompile", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler295, + /* sub = */ 0, + /* conflicts = */ &precompile_conflicts, + /* help = */ "do not precompile any files based on the filename extension" +}; +SET_T optlstCmdLineCompiler299 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pCmdLineCompiler.noSysPath +}; +Option optlstCmdLineCompiler_300 = { + /* names = */ "nosyspath", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler299, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "treat #include <...> like #include \"...\"; always search both user and system path lists" +}; +GENERIC_T optlstCmdLineCompiler302 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x00, + /* myname = */ "file|dir", + /* next = */ 0, + /* parse = */ &Opt_HandleOutputName, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +Option optlstCmdLineCompiler_303 = { + /* names = */ "o", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler302, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "specify output filename or directory for object file(s) or text output, or output filename for linker if called" +}; +GENERIC_T optlstCmdLineCompiler305 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_SetStage, + /* arg = */ (void *) "Pp", + /* help = */ 0 +}; +MASK_T optlstCmdLineCompiler308 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler305, + /* size = */ 2, + /* ormask = */ 0x1, + /* andmask = */ 0x0, + /* num = */ &pCmdLine.toDisk +}; +SET_T optlstCmdLineCompiler310 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler308, + /* size = */ 2, + /* value = */ 0x2, + /* num = */ (char *) &pCmdLine.state +}; +Option optlstCmdLineCompiler_311 = { + /* names = */ "P", + /* avail = */ OTF_GLOBAL | OTF_CASED | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler310, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "preprocess and send output to file; do not generate code" +}; +GENERIC_T optlstCmdLineCompiler313 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_SavePrefs, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +SET_T optlstCmdLineCompiler315 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler313, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pCmdLineCompiler.forcePrecompile +}; +GENERIC_T optlstCmdLineCompiler317 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x00, + /* myname = */ "file|dir", + /* next = */ (PARAM_T *) &optlstCmdLineCompiler315, + /* parse = */ &Opt_HandleOutputName, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +SET_T optlstCmdLineCompiler319 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler317, + /* size = */ 2, + /* value = */ 0x2, + /* num = */ (char *) &pCmdLine.state +}; +Option precompile_320 = { + /* names = */ "precompile", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler319, + /* sub = */ 0, + /* conflicts = */ &precompile_conflicts, + /* help = */ "generate precompiled header from source; write header to 'file' if specified, or put header in 'dir'; if argument is \"\", write header to source-specified location; if neither is defined, header filename is derived from source filename; note: the driver can tell whether to precompile a file based on its extension; '~~precompile file source' then is the same as '~~c ~~o file source'" +}; +GENERIC_T optlstCmdLineCompiler322 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_SetStage, + /* arg = */ (void *) "Pp", + /* help = */ 0 +}; +SET_T optlstCmdLineCompiler324 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler322, + /* size = */ 2, + /* value = */ 0x2, + /* num = */ (char *) &pCmdLine.state +}; +Option optlstCmdLineCompiler_325 = { + /* names = */ "preprocess", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler324, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "preprocess source files" +}; +GENERIC_T optlstCmdLineCompiler327 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x00, + /* myname = */ "file", + /* next = */ 0, + /* parse = */ &Opt_AddPrefixFile, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +Option optlstCmdLineCompiler_328 = { + /* names = */ "prefix", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler327, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "prefix text file or precompiled header onto all source files" +}; +GENERIC_T optlstCmdLineCompiler330 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_SetStage, + /* arg = */ (void *) "Ds", + /* help = */ 0 +}; +MASK_T optlstCmdLineCompiler333 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler330, + /* size = */ 2, + /* ormask = */ 0x4, + /* andmask = */ 0x0, + /* num = */ &pCmdLine.toDisk +}; +SET_T optlstCmdLineCompiler335 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineCompiler333, + /* size = */ 2, + /* value = */ 0x2, + /* num = */ (char *) &pCmdLine.state +}; +Option optlstCmdLineCompiler_336 = { + /* names = */ "S", + /* avail = */ OTF_GLOBAL | OTF_CASED | OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler335, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "disassemble and send output to file" +}; +SET_T optlstCmdLineCompiler339 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &useDefaultIncludes +}; +Option optlstCmdLineCompiler_340 = { + /* names = */ "stdinc", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler339, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "use standard system include paths (specified by the environment variable {MWCIncludes}); added after all system '~~I' paths" +}; +GENERIC_T optlstCmdLineCompiler342 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x00, + /* myname = */ "name", + /* next = */ 0, + /* parse = */ &Opt_UndefineSymbol, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +Option optlstCmdLineCompiler_343 = { + /* names = */ "U|u|undefine", + /* avail = */ OTF_STICKY | OTF_CASED | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstCmdLineCompiler342, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "undefine symbol 'name'" +}; +Option *optlstCmdLineCompiler_344_list[] = { + &optlstCmdLineCompiler_151, + &optlstCmdLineCompiler_154, + &optlstCmdLineCompiler_157, + &optlstCmdLineCompiler_161, + &optlstCmdLineCompiler_175, + &optlstCmdLineCompiler_177, + &optlstCmdLineCompiler_181, + &optlstCmdLineCompiler_186, + &optlstCmdLineCompiler_191, + &optlstCmdLineCompiler_198, + &optlstCmdLineCompiler_201, + &optlstCmdLineCompiler_204, + &optlstCmdLineCompiler_207, + &optlstCmdLineCompiler_211, + &optlstCmdLineCompiler_220, + &optlstCmdLineCompiler_231, + &optlstCmdLineCompiler_234, + &optlstCmdLineCompiler_237, + &optlstCmdLineCompiler_240, + &optlstCmdLineCompiler_244, + &optlstCmdLineCompiler_247, + &optlstCmdLineCompiler_252, + &optlstCmdLineCompiler_260, + &optlstCmdLineCompiler_268, + &optlstCmdLineCompiler_279, + &optlstCmdLineCompiler_284, + &optlstCmdLineCompiler_288, + &optlstCmdLineCompiler_291, + &precompile_296, + &optlstCmdLineCompiler_300, + &optlstCmdLineCompiler_303, + &optlstCmdLineCompiler_311, + &precompile_320, + &optlstCmdLineCompiler_325, + &optlstCmdLineCompiler_328, + &optlstCmdLineCompiler_336, + &optlstCmdLineCompiler_340, + &optlstCmdLineCompiler_343, + 0 +}; +OptionList optlstCmdLineCompiler = { + /* help = */ "Preprocessing, Precompiling, and Input File Control Options\n", + /* flags = */ LISTFLAGS_COMPILER, + /* list = */ optlstCmdLineCompiler_344_list +}; +Option *precompile_000_list[] = { + &precompile_296, + &precompile_320, + 0 +}; +OptionList precompile_conflicts = { + /* help = */ 0, + /* flags = */ 0, + /* list = */ precompile_000_list +}; diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsCmdLineLinker.opt b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsCmdLineLinker.opt new file mode 100644 index 0000000..6f26341 --- /dev/null +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsCmdLineLinker.opt @@ -0,0 +1,199 @@ +/* CmdLineLinker */ +GENERIC_T optlstCmdLineLinker346 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_SetStage, + /* arg = */ (void *) "Ds", + /* help = */ 0 +}; +SET_T optlstCmdLineLinker349 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineLinker346, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ 0 +}; +SET_T optlstCmdLineLinker351 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineLinker349, + /* size = */ 2, + /* value = */ 0x2, + /* num = */ (char *) &pCmdLine.state +}; +Option optlstCmdLineLinker_352 = { + /* names = */ "dis|disassemble", + /* avail = */ OTF_GLOBAL | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstCmdLineLinker351, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "disassemble object code and do not link; implies '~~nostdlib'" +}; +GENERIC_T optlstCmdLineLinker354 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x00, + /* myname = */ "path", + /* next = */ 0, + /* parse = */ &Opt_DummyLinkerRoutine, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +Option optlstCmdLineLinker_355 = { + /* names = */ "L|l", + /* avail = */ OTF_GLOBAL | OTF_STICKY | OTF_CASED | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstCmdLineLinker354, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "add library search path; default is to search current working directory and then system directories (see '~~defaults'); search paths have global scope over the command line and are searched in the order given" +}; +GENERIC_T optlstCmdLineLinker357 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x00, + /* myname = */ "path", + /* next = */ 0, + /* parse = */ &Opt_DummyLinkerRoutine, + /* arg = */ (void *) 1, + /* help = */ 0 +}; +Option optlstCmdLineLinker_358 = { + /* names = */ "lr", + /* avail = */ OTF_GLOBAL | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstCmdLineLinker357, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "like '~~l', but add recursive library search path" +}; +GENERIC_T optlstCmdLineLinker360 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x00, + /* myname = */ "file", + /* next = */ 0, + /* parse = */ &Opt_DummyLinkerRoutine, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +Option optlstCmdLineLinker_361 = { + /* names = */ "l", + /* avail = */ OTF_STICKY | OTF_CASED | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstCmdLineLinker360, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "add a library by searching access paths for file named lib. where is a typical library extension; added before system libraries (see '~~defaults')" +}; +SET_T optlstCmdLineLinker364 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ 0 +}; +Option optlstCmdLineLinker_365 = { + /* names = */ "defaults", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_LINKER, + /* param = */ (PARAM_T *) &optlstCmdLineLinker364, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "same as ~~[no]stdlib" +}; +SET_T optlstCmdLineLinker368 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pCmdLineCompiler.noFail +}; +Option optlstCmdLineLinker_369 = { + /* names = */ "nofail", + /* avail = */ OTF_TOOL_LINKER, + /* param = */ (PARAM_T *) &optlstCmdLineLinker368, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "continue importing or disassembling after errors in earlier files" +}; +SET_T optlstCmdLineLinker372 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ 0 +}; +Option optlstCmdLineLinker_373 = { + /* names = */ "stdlib", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_LINKER, + /* param = */ (PARAM_T *) &optlstCmdLineLinker372, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "use system library access paths (specified by {MWLibraries}) and add system libraries (specified by {MWLibraryFiles})" +}; +GENERIC_T optlstCmdLineLinker375 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_SetStage, + /* arg = */ (void *) "Ds", + /* help = */ 0 +}; +MASK_T optlstCmdLineLinker378 = { + /* which = */ PARAMWHICH_Mask, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineLinker375, + /* size = */ 2, + /* ormask = */ 0x4, + /* andmask = */ 0x0, + /* num = */ &pCmdLine.toDisk +}; +SET_T optlstCmdLineLinker381 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineLinker378, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ 0 +}; +SET_T optlstCmdLineLinker383 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstCmdLineLinker381, + /* size = */ 2, + /* value = */ 0x2, + /* num = */ (char *) &pCmdLine.state +}; +Option optlstCmdLineLinker_384 = { + /* names = */ "S", + /* avail = */ OTF_GLOBAL | OTF_CASED | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstCmdLineLinker383, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "disassemble and send output to file; do not link; implies '~~nostdlib'" +}; +Option *optlstCmdLineLinker_385_list[] = { + &optlstCmdLineLinker_352, + &optlstCmdLineLinker_355, + &optlstCmdLineLinker_358, + &optlstCmdLineLinker_361, + &optlstCmdLineLinker_365, + &optlstCmdLineLinker_369, + &optlstCmdLineLinker_373, + &optlstCmdLineLinker_384, + 0 +}; +OptionList optlstCmdLineLinker = { + /* help = */ "Command-Line Linker Options\n", + /* flags = */ LISTFLAGS_LINKER, + /* list = */ optlstCmdLineLinker_385_list +}; diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsDebugging.opt b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsDebugging.opt new file mode 100644 index 0000000..6b488ba --- /dev/null +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsDebugging.opt @@ -0,0 +1,80 @@ +/* Debugging */ +SET_T optlstDebugging388 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pCmdLine.debugInfo +}; +Option optlstDebugging_389 = { + /* names = */ "g", + /* avail = */ OTF_GLOBAL | OTF_CASED | OTF_TOOL_COMPILER | OTF_TOOL_LINKER, + /* param = */ (PARAM_T *) &optlstDebugging388, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "generate debugging information; same as '~~sym on'" +}; +SET_T optlstDebugging396 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pCmdLine.debugInfo +}; +Option optlstDebugging_397 = { + /* names = */ "off", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER | OTF_TOOL_LINKER, + /* param = */ (PARAM_T *) &optlstDebugging396, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "do not generate debugging information" +}; +SET_T optlstDebugging392 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pCmdLine.debugInfo +}; +Option optlstDebugging_393 = { + /* names = */ "on", + /* avail = */ OTF_GLOBAL | OTF_HIDE_DEFAULT | OTF_TOOL_COMPILER | OTF_TOOL_LINKER, + /* param = */ (PARAM_T *) &optlstDebugging392, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "turn on debugging information" +}; +Option *optlstDebugging_398_list[] = { + &optlstDebugging_397, + &optlstDebugging_393, + 0 +}; +OptionList optlstDebugging_398 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_ALLOW_UNKNOWNS | LISTFLAGS_COMPILER | LISTFLAGS_LINKER, + /* list = */ optlstDebugging_398_list +}; +Option optlstDebugging_399 = { + /* names = */ "sym", + /* avail = */ OTF_GLOBAL | OTF_HIDE_DEFAULT | OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_HAS_SUB_OPTIONS, + /* param = */ 0, + /* sub = */ &optlstDebugging_398, + /* conflicts = */ 0, + /* help = */ "specify debugging options" +}; +Option *optlstDebugging_400_list[] = { + &optlstDebugging_389, + &optlstDebugging_399, + 0 +}; +OptionList optlstDebugging = { + /* help = */ "Debugging Control Options\n", + /* flags = */ LISTFLAGS_COMPILER | LISTFLAGS_LINKER, + /* list = */ optlstDebugging_400_list +}; diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsDumper.opt b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsDumper.opt new file mode 100644 index 0000000..88c6e90 --- /dev/null +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsDumper.opt @@ -0,0 +1,368 @@ +/* Dumper */ +SET_T optlstDumper1187 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pDisassembler.shownames +}; +SET_T optlstDumper1190 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstDumper1187, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pDisassembler.showsym +}; +SET_T optlstDumper1193 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstDumper1190, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pDisassembler.showexceptions +}; +SET_T optlstDumper1196 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstDumper1193, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pDisassembler.showdata +}; +SET_T optlstDumper1199 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstDumper1196, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pDisassembler.nohex +}; +SET_T optlstDumper1202 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstDumper1199, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pDisassembler.mix +}; +SET_T optlstDumper1205 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstDumper1202, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pDisassembler.extended +}; +SET_T optlstDumper1208 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstDumper1205, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pDisassembler.showcode +}; +Option optlstDumper_1209 = { + /* names = */ "only|none", + /* avail = */ OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstDumper1208, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "as in '~~show none' or, e.g.,\r'~~show only,code,data'" +}; +SET_T optlstDumper1162 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pDisassembler.shownames +}; +SET_T optlstDumper1165 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstDumper1162, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pDisassembler.showsym +}; +SET_T optlstDumper1168 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstDumper1165, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pDisassembler.showexceptions +}; +SET_T optlstDumper1171 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstDumper1168, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pDisassembler.showdata +}; +SET_T optlstDumper1174 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstDumper1171, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pDisassembler.nohex +}; +SET_T optlstDumper1177 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstDumper1174, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pDisassembler.mix +}; +SET_T optlstDumper1180 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstDumper1177, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pDisassembler.extended +}; +SET_T optlstDumper1183 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstDumper1180, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pDisassembler.showcode +}; +Option optlstDumper_1184 = { + /* names = */ "all", + /* avail = */ OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstDumper1183, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "show everything" +}; +SET_T optlstDumper1158 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pDisassembler.showcode +}; +Option optlstDumper_1159 = { + /* names = */ "code|text", + /* avail = */ OTF_SLFLAGS_8 | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstDumper1158, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "show disassembly of code sections" +}; +SET_T optlstDumper1151 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pDisassembler.showcode +}; +SET_T optlstDumper1154 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstDumper1151, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pDisassembler.extended +}; +Option optlstDumper_1155 = { + /* names = */ "extended", + /* avail = */ OTF_SLFLAGS_8 | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstDumper1154, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "show extended mnemonics" +}; +SET_T optlstDumper1144 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pDisassembler.showcode +}; +SET_T optlstDumper1147 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstDumper1144, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pDisassembler.mix +}; +Option optlstDumper_1148 = { + /* names = */ "mix", + /* avail = */ OTF_SLFLAGS_8 | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstDumper1147, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "mix code and assembly; requires that modules were compiled with '~~sym on'" +}; +SET_T optlstDumper1137 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pDisassembler.showcode +}; +SET_T optlstDumper1140 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstDumper1137, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pDisassembler.nohex +}; +Option optlstDumper_1141 = { + /* names = */ "hex", + /* avail = */ OTF_SLFLAGS_8 | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstDumper1140, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "show addresses and opcodes" +}; +SET_T optlstDumper1133 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pDisassembler.showdata +}; +Option optlstDumper_1134 = { + /* names = */ "data", + /* avail = */ OTF_SLFLAGS_8 | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstDumper1133, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "show data modules" +}; +SET_T optlstDumper1126 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pDisassembler.showdata +}; +SET_T optlstDumper1129 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstDumper1126, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pDisassembler.showexceptions +}; +Option optlstDumper_1130 = { + /* names = */ "exceptions", + /* avail = */ OTF_SLFLAGS_8 | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstDumper1129, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "show exception tables" +}; +SET_T optlstDumper1122 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pDisassembler.showsym +}; +Option optlstDumper_1123 = { + /* names = */ "sym", + /* avail = */ OTF_SLFLAGS_8 | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstDumper1122, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "show SYM info" +}; +SET_T optlstDumper1118 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pDisassembler.shownames +}; +Option optlstDumper_1119 = { + /* names = */ "names", + /* avail = */ OTF_SLFLAGS_8 | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstDumper1118, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "show symbol and string tables" +}; +Option *optlstDumper_1210_list[] = { + &optlstDumper_1209, + &optlstDumper_1184, + &optlstDumper_1159, + &optlstDumper_1155, + &optlstDumper_1148, + &optlstDumper_1141, + &optlstDumper_1134, + &optlstDumper_1130, + &optlstDumper_1123, + &optlstDumper_1119, + 0 +}; +OptionList optlstDumper_1210 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_LINKER | LISTFLAGS_DISASSEMBLER, + /* list = */ optlstDumper_1210_list +}; +Option optlstDumper_1211 = { + /* names = */ "show", + /* avail = */ OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER | OTF_HAS_SUB_OPTIONS, + /* param = */ 0, + /* sub = */ &optlstDumper_1210, + /* conflicts = */ 0, + /* help = */ "specify disassembly options" +}; +Option *optlstDumper_1212_list[] = { + &optlstDumper_1211, + 0 +}; +OptionList optlstDumper = { + /* help = */ "Mach-O PowerPC Disassembler Options\n", + /* flags = */ LISTFLAGS_LINKER | LISTFLAGS_DISASSEMBLER, + /* list = */ optlstDumper_1212_list +}; diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsFrontEndC.opt b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsFrontEndC.opt new file mode 100644 index 0000000..7e3c179 --- /dev/null +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsFrontEndC.opt @@ -0,0 +1,1208 @@ +/* FrontEndC */ +/* forward declare */ extern OptionList optlstFrontEndC_431_conflicts; +SET_T optlstFrontEndC423 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pFrontEndC.ansistrict +}; +SET_T optlstFrontEndC426 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstFrontEndC423, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pFrontEndC.enumsalwaysint +}; +SET_T optlstFrontEndC429 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstFrontEndC426, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pFrontEndC.onlystdkeywords +}; +Option optlstFrontEndC_431_430 = { + /* names = */ "off", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstFrontEndC429, + /* sub = */ 0, + /* conflicts = */ &optlstFrontEndC_431_conflicts, + /* help = */ "same as '~~stdkeywords on', '~~enum min', and '~~strict off'" +}; +SET_T optlstFrontEndC413 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.ansistrict +}; +SET_T optlstFrontEndC416 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstFrontEndC413, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pFrontEndC.enumsalwaysint +}; +SET_T optlstFrontEndC419 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstFrontEndC416, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.onlystdkeywords +}; +Option optlstFrontEndC_431_420 = { + /* names = */ "on|relaxed", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstFrontEndC419, + /* sub = */ 0, + /* conflicts = */ &optlstFrontEndC_431_conflicts, + /* help = */ "same as '~~stdkeywords off', '~~enum min', and '~~strict on'" +}; +SET_T optlstFrontEndC403 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.ansistrict +}; +SET_T optlstFrontEndC406 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstFrontEndC403, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.enumsalwaysint +}; +SET_T optlstFrontEndC409 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstFrontEndC406, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.onlystdkeywords +}; +Option optlstFrontEndC_431_410 = { + /* names = */ "strict", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstFrontEndC409, + /* sub = */ 0, + /* conflicts = */ &optlstFrontEndC_431_conflicts, + /* help = */ "same as '~~stdkeywords off', '~~enum int', and '~~strict on'" +}; +Option *optlstFrontEndC_431_list[] = { + &optlstFrontEndC_431_430, + &optlstFrontEndC_431_420, + &optlstFrontEndC_431_410, + 0 +}; +OptionList optlstFrontEndC_431 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_COMPILER, + /* list = */ optlstFrontEndC_431_list +}; +OptionList optlstFrontEndC_431_conflicts = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_COMPILER, + /* list = */ optlstFrontEndC_431_list +}; +Option optlstFrontEndC_432 = { + /* names = */ "ansi", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_SUB_OPTIONS, + /* param = */ 0, + /* sub = */ &optlstFrontEndC_431, + /* conflicts = */ 0, + /* help = */ "specify ANSI conformance options, overriding the given settings" +}; +OFFON_T optlstFrontEndC434 = { + /* which = */ PARAMWHICH_OffOn, + /* flags = */ 0x00, + /* myname = */ 0, + /* next = */ 0, + /* var = */ &pFrontEndC.onlystdkeywords +}; +Option optlstFrontEndC_435 = { + /* names = */ "appleext", + /* avail = */ OTF_SECRET | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC434, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "allow nonstandard keywords" +}; +ONOFF_T optlstFrontEndC437 = { + /* which = */ PARAMWHICH_OnOff, + /* flags = */ 0x00, + /* myname = */ 0, + /* next = */ 0, + /* var = */ &pFrontEndC.arm +}; +Option optlstFrontEndC_438 = { + /* names = */ "ARM", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC437, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "check code for ARM (Annotated C++ Reference Manual) conformance" +}; +ONOFF_T optlstFrontEndC440 = { + /* which = */ PARAMWHICH_OnOff, + /* flags = */ 0x00, + /* myname = */ 0, + /* next = */ 0, + /* var = */ &pFrontEndC.booltruefalse +}; +Option optlstFrontEndC_441 = { + /* names = */ "bool", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC440, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "enable C++ 'bool' type, 'true' and 'false' constants" +}; +ONOFF_T optlstFrontEndC443 = { + /* which = */ PARAMWHICH_OnOff, + /* flags = */ 0x00, + /* myname = */ 0, + /* next = */ 0, + /* var = */ &pFrontEndC.enableexceptions +}; +Option optlstFrontEndC_444 = { + /* names = */ "Cpp_exceptions", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC443, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "enable or disable true C++ exceptions" +}; +/* forward declare */ extern OptionList optlstFrontEndC_454_conflicts; +SET_T optlstFrontEndC452 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pFrontEndC.unsignedchars +}; +Option optlstFrontEndC_454_453 = { + /* names = */ "signed", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstFrontEndC452, + /* sub = */ 0, + /* conflicts = */ &optlstFrontEndC_454_conflicts, + /* help = */ "chars are signed" +}; +SET_T optlstFrontEndC448 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.unsignedchars +}; +Option optlstFrontEndC_454_449 = { + /* names = */ "unsigned", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstFrontEndC448, + /* sub = */ 0, + /* conflicts = */ &optlstFrontEndC_454_conflicts, + /* help = */ "chars are unsigned" +}; +Option optlstFrontEndC_454_445 = { + /* names = */ "unsignedx", + /* avail = */ OTF_IGNORED | OTF_HIDE_DEFAULT | OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ 0, + /* sub = */ 0, + /* conflicts = */ &optlstFrontEndC_454_conflicts, + /* help = */ 0 +}; +Option *optlstFrontEndC_454_list[] = { + &optlstFrontEndC_454_453, + &optlstFrontEndC_454_449, + &optlstFrontEndC_454_445, + 0 +}; +OptionList optlstFrontEndC_454 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_COMPILER, + /* list = */ optlstFrontEndC_454_list +}; +OptionList optlstFrontEndC_454_conflicts = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_COMPILER, + /* list = */ optlstFrontEndC_454_list +}; +Option optlstFrontEndC_455 = { + /* names = */ "char", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_SUB_OPTIONS, + /* param = */ 0, + /* sub = */ &optlstFrontEndC_454, + /* conflicts = */ 0, + /* help = */ "set sign of 'char'" +}; +/* forward declare */ extern OptionList optlstFrontEndC_483_conflicts; +GENERIC_T optlstFrontEndC478 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_AddStringToDefines, + /* arg = */ (void *) "#pragma cplusplus off\n", + /* help = */ 0 +}; +SET_T optlstFrontEndC481 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstFrontEndC478, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pFrontEndC.cplusplus +}; +Option optlstFrontEndC_483_482 = { + /* names = */ "c|ansic", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstFrontEndC481, + /* sub = */ 0, + /* conflicts = */ &optlstFrontEndC_483_conflicts, + /* help = */ "treat source as C always" +}; +SET_T optlstFrontEndC475 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.cplusplus +}; +Option optlstFrontEndC_483_476 = { + /* names = */ "cplus|cplusplus|c++", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstFrontEndC475, + /* sub = */ 0, + /* conflicts = */ &optlstFrontEndC_483_conflicts, + /* help = */ "treat source as C++ always" +}; +GENERIC_T optlstFrontEndC468 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_AddStringToDefines, + /* arg = */ (void *) "#pragma ignore_oldstyle on\n", + /* help = */ 0 +}; +SET_T optlstFrontEndC471 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstFrontEndC468, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pFrontEndC.cplusplus +}; +Option optlstFrontEndC_483_472 = { + /* names = */ "krc", + /* avail = */ OTF_SUBSTITUTED | OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstFrontEndC471, + /* sub = */ 0, + /* conflicts = */ &optlstFrontEndC_483_conflicts, + /* help = */ "'dialect c' and 'proto ignoreoldstyle'\r(CodeWarrior has minimal support for K&R C)" +}; +SET_T optlstFrontEndC462 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.cplusplus +}; +SET_T optlstFrontEndC465 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstFrontEndC462, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.ecplusplus +}; +Option optlstFrontEndC_483_466 = { + /* names = */ "ecplusplus|ec++", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstFrontEndC465, + /* sub = */ 0, + /* conflicts = */ &optlstFrontEndC_483_conflicts, + /* help = */ "generate warnings for use of C++ features outside Embedded C++ subset (implies 'dialect cplus')" +}; +SET_T optlstFrontEndC458 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.objective_c +}; +Option optlstFrontEndC_483_459 = { + /* names = */ "objective-c|objc", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstFrontEndC458, + /* sub = */ 0, + /* conflicts = */ &optlstFrontEndC_483_conflicts, + /* help = */ "allow Objective C extensions" +}; +Option *optlstFrontEndC_483_list[] = { + &optlstFrontEndC_483_482, + &optlstFrontEndC_483_476, + &optlstFrontEndC_483_472, + &optlstFrontEndC_483_466, + &optlstFrontEndC_483_459, + 0 +}; +OptionList optlstFrontEndC_483 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_COMPILER, + /* list = */ optlstFrontEndC_483_list +}; +OptionList optlstFrontEndC_483_conflicts = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_COMPILER, + /* list = */ optlstFrontEndC_483_list +}; +Option optlstFrontEndC_484 = { + /* names = */ "dialect|lang", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_SUB_OPTIONS, + /* param = */ 0, + /* sub = */ &optlstFrontEndC_483, + /* conflicts = */ 0, + /* help = */ "specify source language" +}; +/* forward declare */ extern OptionList optlstFrontEndC_493_conflicts; +SET_T optlstFrontEndC491 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pFrontEndC.enumsalwaysint +}; +Option optlstFrontEndC_493_492 = { + /* names = */ "min", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstFrontEndC491, + /* sub = */ 0, + /* conflicts = */ &optlstFrontEndC_493_conflicts, + /* help = */ "use minimum sized enums" +}; +SET_T optlstFrontEndC487 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.enumsalwaysint +}; +Option optlstFrontEndC_493_488 = { + /* names = */ "int", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstFrontEndC487, + /* sub = */ 0, + /* conflicts = */ &optlstFrontEndC_493_conflicts, + /* help = */ "use int-sized enums" +}; +Option *optlstFrontEndC_493_list[] = { + &optlstFrontEndC_493_492, + &optlstFrontEndC_493_488, + 0 +}; +OptionList optlstFrontEndC_493 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_COMPILER, + /* list = */ optlstFrontEndC_493_list +}; +OptionList optlstFrontEndC_493_conflicts = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_COMPILER, + /* list = */ optlstFrontEndC_493_list +}; +Option optlstFrontEndC_494 = { + /* names = */ "enum", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_SUB_OPTIONS, + /* param = */ 0, + /* sub = */ &optlstFrontEndC_493, + /* conflicts = */ 0, + /* help = */ "specify word size for enumeration types" +}; +SET_T optlstFrontEndC537 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pFrontEndC.alwaysinline +}; +SET_T optlstFrontEndC539 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstFrontEndC537, + /* size = */ 2, + /* value = */ 0x0, + /* num = */ (char *) &pFrontEndC.inlinelevel +}; +Option optlstFrontEndC_540 = { + /* names = */ "all|on|smart", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC539, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "turn on inlining" +}; +SET_T optlstFrontEndC528 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pFrontEndC.alwaysinline +}; +SET_T optlstFrontEndC530 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstFrontEndC528, + /* size = */ 2, + /* value = */ 0xFFFFFFFF, + /* num = */ (char *) &pFrontEndC.inlinelevel +}; +SET_T optlstFrontEndC533 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstFrontEndC530, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.dontinline +}; +Option optlstFrontEndC_534 = { + /* names = */ "none|off", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC533, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "turn off inlining" +}; +SET_T optlstFrontEndC521 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.autoinline +}; +SET_T optlstFrontEndC524 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstFrontEndC521, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pFrontEndC.dontinline +}; +Option optlstFrontEndC_525 = { + /* names = */ "auto", + /* avail = */ OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC524, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "auto-inline small functions (without 'inline' explicitly specified)" +}; +SET_T optlstFrontEndC517 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pFrontEndC.autoinline +}; +Option optlstFrontEndC_518 = { + /* names = */ "noauto", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC517, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "do not auto-inline" +}; +SET_T optlstFrontEndC510 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.alwaysinline +}; +SET_T optlstFrontEndC513 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstFrontEndC510, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pFrontEndC.dontinline +}; +Option optlstFrontEndC_514 = { + /* names = */ "always", + /* avail = */ OTF_SECRET | OTF_WARNING | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC513, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "always inlining 'inline' functions is currently unstable" +}; +SET_T optlstFrontEndC503 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.defer_codegen +}; +SET_T optlstFrontEndC506 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstFrontEndC503, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pFrontEndC.dontinline +}; +Option optlstFrontEndC_507 = { + /* names = */ "deferred", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC506, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "defer inlining until end of compilation unit; this allows inlining of functions in both directions" +}; +Option optlstFrontEndC_500 = { + /* names = */ "static", + /* avail = */ OTF_OBSOLETE | OTF_HIDE_DEFAULT | OTF_TOOL_COMPILER, + /* param = */ 0, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "unreferenced inline functions are removed from object code" +}; +NUM_T optlstFrontEndC495 = { + /* which = */ PARAMWHICH_Number, + /* flags = */ 0x00, + /* myname = */ "n", + /* next = */ 0, + /* size = */ 2, + /* fit = */ 1, + /* lo = */ 0, + /* hi = */ 8, + /* num = */ &pFrontEndC.inlinelevel +}; +SET_T optlstFrontEndC498 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstFrontEndC495, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pFrontEndC.dontinline +}; +Option optlstFrontEndC_499 = { + /* names = */ "l|level|depth", + /* avail = */ OTF_CASED | OTF_HIDE_DEFAULT | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC498, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "inline functions up to 'n' levels deep; level 0 is the same as '~~inline off'" +}; +Option *optlstFrontEndC_541_list[] = { + &optlstFrontEndC_540, + &optlstFrontEndC_534, + &optlstFrontEndC_525, + &optlstFrontEndC_518, + &optlstFrontEndC_514, + &optlstFrontEndC_507, + &optlstFrontEndC_500, + &optlstFrontEndC_499, + 0 +}; +OptionList optlstFrontEndC_541 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_COMPILER, + /* list = */ optlstFrontEndC_541_list +}; +SET_T optlstFrontEndC544 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pFrontEndC.dontinline +}; +Option optlstFrontEndC_545 = { + /* names = */ "inline", + /* avail = */ OTF_HIDE_DEFAULT | OTF_TOOL_COMPILER | OTF_HAS_SUB_OPTIONS, + /* param = */ (PARAM_T *) &optlstFrontEndC544, + /* sub = */ &optlstFrontEndC_541, + /* conflicts = */ 0, + /* help = */ "specify inline options" +}; +SET_T optlstFrontEndC548 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.multibyteaware +}; +Option optlstFrontEndC_549 = { + /* names = */ "multibyte|multibyteaware", + /* avail = */ OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC548, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "enable multi-byte character encodings for source text, comments, and strings" +}; +GENERIC_T optlstFrontEndC551 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_AddStringToDefines, + /* arg = */ (void *) "#pragma once off\n", + /* help = */ 0 +}; +Option optlstFrontEndC_552 = { + /* names = */ "notonce", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC551, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "allow header files to be processed more than once; default" +}; +GENERIC_T optlstFrontEndC554 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_AddStringToDefines, + /* arg = */ (void *) "#pragma once on\n", + /* help = */ 0 +}; +Option optlstFrontEndC_555 = { + /* names = */ "once", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC554, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "prevent header files from being processed more than once" +}; +GENERIC_T optlstFrontEndC557 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_AddStringToDefines, + /* arg = */ (void *) "\n", + /* help = */ 0 +}; +GENERIC_T optlstFrontEndC559 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x00, + /* myname = */ "...", + /* next = */ (PARAM_T *) &optlstFrontEndC557, + /* parse = */ &Opt_AddStringToDefines, + /* arg = */ (void *) "#pragma ", + /* help = */ 0 +}; +Option optlstFrontEndC_560 = { + /* names = */ "pragma", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC559, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "define a pragma for the compiler such as \"#pragma ...\"" +}; +SET_T optlstFrontEndC570 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.checkprotos +}; +Option optlstFrontEndC_571 = { + /* names = */ "strict", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC570, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "require prototypes" +}; +SET_T optlstFrontEndC566 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pFrontEndC.checkprotos +}; +Option optlstFrontEndC_567 = { + /* names = */ "auto|lax", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC566, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "don't require prototypes" +}; +GENERIC_T optlstFrontEndC562 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &Opt_AddStringToDefines, + /* arg = */ (void *) "#pragma ignore_oldstyle on\n", + /* help = */ 0 +}; +Option optlstFrontEndC_563 = { + /* names = */ "ignoreoldstyle", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC562, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "allow old-style K&R declarations" +}; +Option *optlstFrontEndC_572_list[] = { + &optlstFrontEndC_571, + &optlstFrontEndC_567, + &optlstFrontEndC_563, + 0 +}; +OptionList optlstFrontEndC_572 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_COMPILER, + /* list = */ optlstFrontEndC_572_list +}; +Option optlstFrontEndC_573 = { + /* names = */ "proto", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_SUB_OPTIONS, + /* param = */ 0, + /* sub = */ &optlstFrontEndC_572, + /* conflicts = */ 0, + /* help = */ "specify prototype parsing options" +}; +SET_T optlstFrontEndC576 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.checkprotos +}; +Option optlstFrontEndC_577 = { + /* names = */ "r|requireprotos|fstrict-prototype", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC576, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "require prototypes" +}; +ONOFF_T optlstFrontEndC582 = { + /* which = */ PARAMWHICH_OnOff, + /* flags = */ 0x00, + /* myname = */ 0, + /* next = */ 0, + /* var = */ &pFrontEndC.useRTTI +}; +SET_T optlstFrontEndC580 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.useRTTI +}; +IFARG_T optlstFrontEndC584 = { + /* which = */ PARAMWHICH_IfArg, + /* flags = */ 0x02, + /* myname = */ 0, + /* next = */ 0, + /* parg = */ (PARAM_T *) &optlstFrontEndC582, + /* helpa = */ "enable or disable RTTI", + /* pnone = */ (PARAM_T *) &optlstFrontEndC580, + /* helpn = */ "enable RTTI" +}; +Option optlstFrontEndC_585 = { + /* names = */ "RTTI", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC584, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "specify run-time typing information options" +}; +SET_T optlstFrontEndC588 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.mpwpointerstyle +}; +Option optlstFrontEndC_589 = { + /* names = */ "relax_pointers", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC588, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "relax pointer type-checking rules" +}; +SET_T optlstFrontEndC592 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.direct_to_som +}; +Option optlstFrontEndC_593 = { + /* names = */ "som", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC592, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "enable Apple's Direct-to-SOM implementation" +}; +SET_T optlstFrontEndC596 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.direct_to_som +}; +SET_T optlstFrontEndC599 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstFrontEndC596, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.som_env_check +}; +Option optlstFrontEndC_600 = { + /* names = */ "som_env_check", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC599, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "enables automatic SOM environment and new allocation checking; implies ~~som" +}; +ONOFF_T optlstFrontEndC602 = { + /* which = */ PARAMWHICH_OnOff, + /* flags = */ 0x00, + /* myname = */ 0, + /* next = */ 0, + /* var = */ &pFrontEndC.onlystdkeywords +}; +Option optlstFrontEndC_603 = { + /* names = */ "stdkeywords", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC602, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "allow only standard keywords" +}; +SET_T optlstFrontEndC618 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pFrontEndC.dontreusestrings +}; +Option optlstFrontEndC_619 = { + /* names = */ "reuse", + /* avail = */ OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC618, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "reuse strings; equivalent strings are the same object" +}; +SET_T optlstFrontEndC614 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.dontreusestrings +}; +Option optlstFrontEndC_615 = { + /* names = */ "dontreuse", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC614, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "don't reuse strings; equivalent strings are distinct objects" +}; +SET_T optlstFrontEndC610 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.poolstrings +}; +Option optlstFrontEndC_611 = { + /* names = */ "pool|poolstrings", + /* avail = */ OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC610, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "pool strings into a single data object" +}; +SET_T optlstFrontEndC606 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pBackEnd.readonlystrings +}; +Option optlstFrontEndC_607 = { + /* names = */ "readonly|ro", + /* avail = */ OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC606, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "make all string constants read-only" +}; +Option *optlstFrontEndC_620_list[] = { + &optlstFrontEndC_619, + &optlstFrontEndC_615, + &optlstFrontEndC_611, + &optlstFrontEndC_607, + 0 +}; +OptionList optlstFrontEndC_620 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_COMPILER, + /* list = */ optlstFrontEndC_620_list +}; +Option optlstFrontEndC_621 = { + /* names = */ "str|strings", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_SUB_OPTIONS, + /* param = */ 0, + /* sub = */ &optlstFrontEndC_620, + /* conflicts = */ 0, + /* help = */ "specify string constant options" +}; +ONOFF_T optlstFrontEndC623 = { + /* which = */ PARAMWHICH_OnOff, + /* flags = */ 0x00, + /* myname = */ 0, + /* next = */ 0, + /* var = */ &pFrontEndC.ansistrict +}; +Option optlstFrontEndC_624 = { + /* names = */ "strict", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC623, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "specify ANSI strictness checking" +}; +ONOFF_T optlstFrontEndC626 = { + /* which = */ PARAMWHICH_OnOff, + /* flags = */ 0x00, + /* myname = */ 0, + /* next = */ 0, + /* var = */ &pFrontEndC.trigraphs +}; +Option optlstFrontEndC_627 = { + /* names = */ "trigraphs", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC626, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "enable recognition of trigraphs" +}; +ONOFF_T optlstFrontEndC629 = { + /* which = */ PARAMWHICH_OnOff, + /* flags = */ 0x00, + /* myname = */ 0, + /* next = */ 0, + /* var = */ &pFrontEndC.wchar_type +}; +Option optlstFrontEndC_630 = { + /* names = */ "wchar_t", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC629, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "enable wchar_t as a built-in C++ type" +}; +SET_T optlstFrontEndC633 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.enableexceptions +}; +Option optlstFrontEndC_634 = { + /* names = */ "fhandle-exceptions", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC633, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "enable true C++ exceptions" +}; +SET_T optlstFrontEndC637 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pFrontEndC.enableexceptions +}; +Option optlstFrontEndC_638 = { + /* names = */ "fno-handle-exceptions", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC637, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "disable true C++ exceptions" +}; +SET_T optlstFrontEndC641 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.unsignedchars +}; +Option optlstFrontEndC_642 = { + /* names = */ "funsigned-char", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC641, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "unspecified chars as unsigned" +}; +SET_T optlstFrontEndC645 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pFrontEndC.checkprotos +}; +Option optlstFrontEndC_646 = { + /* names = */ "fno-strict-prototype", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC645, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "don't require prototypes" +}; +SET_T optlstFrontEndC649 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pFrontEndC.objective_c +}; +Option optlstFrontEndC_650 = { + /* names = */ "fobjc", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstFrontEndC649, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "allow Objective C extensions" +}; +Option *optlstFrontEndC_651_list[] = { + &optlstFrontEndC_432, + &optlstFrontEndC_435, + &optlstFrontEndC_438, + &optlstFrontEndC_441, + &optlstFrontEndC_444, + &optlstFrontEndC_455, + &optlstFrontEndC_484, + &optlstFrontEndC_494, + &optlstFrontEndC_545, + &optlstFrontEndC_549, + &optlstFrontEndC_552, + &optlstFrontEndC_555, + &optlstFrontEndC_560, + &optlstFrontEndC_573, + &optlstFrontEndC_577, + &optlstFrontEndC_585, + &optlstFrontEndC_589, + &optlstFrontEndC_593, + &optlstFrontEndC_600, + &optlstFrontEndC_603, + &optlstFrontEndC_621, + &optlstFrontEndC_624, + &optlstFrontEndC_627, + &optlstFrontEndC_630, + &optlstFrontEndC_634, + &optlstFrontEndC_638, + &optlstFrontEndC_642, + &optlstFrontEndC_646, + &optlstFrontEndC_650, + 0 +}; +OptionList optlstFrontEndC = { + /* help = */ "C/C++ Support Options\n", + /* flags = */ LISTFLAGS_COMPILER, + /* list = */ optlstFrontEndC_651_list +}; diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsLinker.opt b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsLinker.opt new file mode 100644 index 0000000..1e1279a --- /dev/null +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsLinker.opt @@ -0,0 +1,321 @@ +/* Linker */ +STRING_T optlstLinker1061 = { + /* which = */ PARAMWHICH_String, + /* flags = */ 0x00, + /* myname = */ 0, + /* next = */ 0, + /* maxlen = */ 64, + /* pstring = */ 0, + /* str = */ pLinker.mainname +}; +SET_T optlstLinker1064 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstLinker1061, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ 0 +}; +Option optlstLinker_1065 = { + /* names = */ "m|main", + /* avail = */ OTF_TOOL_LINKER, + /* param = */ (PARAM_T *) &optlstLinker1064, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "set main entry point for application, executable, orshared library" +}; +FILEPATH_T optlstLinker1070 = { + /* which = */ PARAMWHICH_FilePath, + /* flags = */ 0x00, + /* myname = */ "filename", + /* next = */ 0, + /* fflags = */ 1, + /* defaultstr = */ 0, + /* filename = */ pCLTExtras.mapfilename, + /* maxlen = */ 255 +}; +SET_T optlstLinker1068 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pCLTExtras.gPrintMapToStdOutput +}; +IFARG_T optlstLinker1072 = { + /* which = */ PARAMWHICH_IfArg, + /* flags = */ 0x12, + /* myname = */ 0, + /* next = */ 0, + /* parg = */ (PARAM_T *) &optlstLinker1070, + /* helpa = */ "write map to 'filename'", + /* pnone = */ (PARAM_T *) &optlstLinker1068, + /* helpn = */ "write map to stdout" +}; +SET_T optlstLinker1075 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstLinker1072, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pLinker.linkmap +}; +Option optlstLinker_1076 = { + /* names = */ "map", + /* avail = */ OTF_TOOL_LINKER, + /* param = */ (PARAM_T *) &optlstLinker1075, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "generate link map" +}; +SET_T optlstLinker1079 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pLinker.multisymerror +}; +Option optlstLinker_1080 = { + /* names = */ "multisymerr", + /* avail = */ OTF_SLFLAGS_8 | OTF_TOOL_LINKER, + /* param = */ (PARAM_T *) &optlstLinker1079, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "generate errors for multiply defined symbols" +}; +GENERIC_T optlstLinker1082 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x00, + /* myname = */ "file", + /* next = */ 0, + /* parse = */ &Opt_DummyLinkerRoutine, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +Option optlstLinker_1083 = { + /* names = */ "o", + /* avail = */ OTF_ONLY_ONCE | OTF_TOOL_LINKER, + /* param = */ (PARAM_T *) &optlstLinker1082, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "specify output filename" +}; +ONOFF_T optlstLinker1085 = { + /* which = */ PARAMWHICH_OnOff, + /* flags = */ 0x00, + /* myname = */ 0, + /* next = */ 0, + /* var = */ &pLinker.use_objectivec_semantics +}; +Option optlstLinker_1086 = { + /* names = */ "objc", + /* avail = */ OTF_TOOL_LINKER, + /* param = */ (PARAM_T *) &optlstLinker1085, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "use objective C semantics" +}; +/* forward declare */ extern OptionList optlstLinker_1096_conflicts; +SET_T optlstLinker1094 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pLinker.readonlyrelocs +}; +Option optlstLinker_1096_1095 = { + /* names = */ "errors", + /* avail = */ OTF_TOOL_LINKER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstLinker1094, + /* sub = */ 0, + /* conflicts = */ &optlstLinker_1096_conflicts, + /* help = */ "as errors" +}; +SET_T optlstLinker1091 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pLinker.readonlyrelocs +}; +Option optlstLinker_1096_1092 = { + /* names = */ "warnings", + /* avail = */ OTF_TOOL_LINKER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstLinker1091, + /* sub = */ 0, + /* conflicts = */ &optlstLinker_1096_conflicts, + /* help = */ "as warnings" +}; +SET_T optlstLinker1088 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x2, + /* num = */ (char *) &pLinker.readonlyrelocs +}; +Option optlstLinker_1096_1089 = { + /* names = */ "supressed", + /* avail = */ OTF_TOOL_LINKER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstLinker1088, + /* sub = */ 0, + /* conflicts = */ &optlstLinker_1096_conflicts, + /* help = */ "supressed" +}; +Option *optlstLinker_1096_list[] = { + &optlstLinker_1096_1095, + &optlstLinker_1096_1092, + &optlstLinker_1096_1089, + 0 +}; +OptionList optlstLinker_1096 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_LINKER, + /* list = */ optlstLinker_1096_list +}; +OptionList optlstLinker_1096_conflicts = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_LINKER, + /* list = */ optlstLinker_1096_list +}; +Option optlstLinker_1097 = { + /* names = */ "roreloc|readonlyrelocs", + /* avail = */ OTF_TOOL_LINKER | OTF_HAS_SUB_OPTIONS, + /* param = */ 0, + /* sub = */ &optlstLinker_1096, + /* conflicts = */ 0, + /* help = */ "treat read only relocations" +}; +/* forward declare */ extern OptionList optlstLinker_1107_conflicts; +SET_T optlstLinker1105 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x0, + /* num = */ (char *) &pLinker.undefinedsymbols +}; +Option optlstLinker_1107_1106 = { + /* names = */ "errors", + /* avail = */ OTF_TOOL_LINKER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstLinker1105, + /* sub = */ 0, + /* conflicts = */ &optlstLinker_1107_conflicts, + /* help = */ "as errors" +}; +SET_T optlstLinker1102 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pLinker.undefinedsymbols +}; +Option optlstLinker_1107_1103 = { + /* names = */ "warnings", + /* avail = */ OTF_TOOL_LINKER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstLinker1102, + /* sub = */ 0, + /* conflicts = */ &optlstLinker_1107_conflicts, + /* help = */ "as warnings" +}; +SET_T optlstLinker1099 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 1, + /* value = */ 0x2, + /* num = */ (char *) &pLinker.undefinedsymbols +}; +Option optlstLinker_1107_1100 = { + /* names = */ "supressed", + /* avail = */ OTF_TOOL_LINKER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstLinker1099, + /* sub = */ 0, + /* conflicts = */ &optlstLinker_1107_conflicts, + /* help = */ "supressed" +}; +Option *optlstLinker_1107_list[] = { + &optlstLinker_1107_1106, + &optlstLinker_1107_1103, + &optlstLinker_1107_1100, + 0 +}; +OptionList optlstLinker_1107 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_LINKER, + /* list = */ optlstLinker_1107_list +}; +OptionList optlstLinker_1107_conflicts = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_LINKER, + /* list = */ optlstLinker_1107_list +}; +Option optlstLinker_1108 = { + /* names = */ "undefsym", + /* avail = */ OTF_TOOL_LINKER | OTF_HAS_SUB_OPTIONS, + /* param = */ 0, + /* sub = */ &optlstLinker_1107, + /* conflicts = */ 0, + /* help = */ "treat undefined symbols" +}; +ONOFF_T optlstLinker1110 = { + /* which = */ PARAMWHICH_OnOff, + /* flags = */ 0x00, + /* myname = */ 0, + /* next = */ 0, + /* var = */ &pLinker.whatfileloaded +}; +Option optlstLinker_1111 = { + /* names = */ "whatfile", + /* avail = */ OTF_TOOL_LINKER, + /* param = */ (PARAM_T *) &optlstLinker1110, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "report what files are loaded" +}; +ONOFF_T optlstLinker1113 = { + /* which = */ PARAMWHICH_OnOff, + /* flags = */ 0x00, + /* myname = */ 0, + /* next = */ 0, + /* var = */ &pLinker.whyfileloaded +}; +Option optlstLinker_1114 = { + /* names = */ "whyfile", + /* avail = */ OTF_TOOL_LINKER, + /* param = */ (PARAM_T *) &optlstLinker1113, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "report why files are loaded" +}; +Option *optlstLinker_1115_list[] = { + &optlstLinker_1065, + &optlstLinker_1076, + &optlstLinker_1080, + &optlstLinker_1083, + &optlstLinker_1086, + &optlstLinker_1097, + &optlstLinker_1108, + &optlstLinker_1111, + &optlstLinker_1114, + 0 +}; +OptionList optlstLinker = { + /* help = */ "Mach-O PowerPC Linker Options\n", + /* flags = */ LISTFLAGS_LINKER, + /* list = */ optlstLinker_1115_list +}; diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsOptimizer.opt b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsOptimizer.opt new file mode 100644 index 0000000..177a79e --- /dev/null +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsOptimizer.opt @@ -0,0 +1,765 @@ +/* Optimizer */ +GENERIC_T optlstOptimizer748 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "G2Pe", + /* help = */ 0 +}; +Option optlstOptimizer_749 = { + /* names = */ "O", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer748, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "same as '~~O2'" +}; +GENERIC_T optlstOptimizer769 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "G0", + /* help = */ 0 +}; +Option optlstOptimizer_770 = { + /* names = */ "0", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer769, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "same as '~~opt l0'" +}; +GENERIC_T optlstOptimizer766 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "G1", + /* help = */ 0 +}; +Option optlstOptimizer_767 = { + /* names = */ "1", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer766, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "same as '~~opt l1'" +}; +GENERIC_T optlstOptimizer763 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "G2Pe", + /* help = */ 0 +}; +Option optlstOptimizer_764 = { + /* names = */ "2", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer763, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "same as '~~opt l2, peephole'" +}; +GENERIC_T optlstOptimizer760 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "G3Pe", + /* help = */ 0 +}; +Option optlstOptimizer_761 = { + /* names = */ "3", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer760, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "same as '~~opt l3, peephole'" +}; +GENERIC_T optlstOptimizer757 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "G4ShPe", + /* help = */ 0 +}; +Option optlstOptimizer_758 = { + /* names = */ "4||5|6|7", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer757, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "same as '~~opt l4, peephole, schedule'" +}; +GENERIC_T optlstOptimizer754 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "Gp", + /* help = */ 0 +}; +Option optlstOptimizer_755 = { + /* names = */ "p", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer754, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "same as '~~opt speed'" +}; +GENERIC_T optlstOptimizer751 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "Gs", + /* help = */ 0 +}; +Option optlstOptimizer_752 = { + /* names = */ "s", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer751, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "same as '~~opt space'" +}; +Option *optlstOptimizer_771_list[] = { + &optlstOptimizer_770, + &optlstOptimizer_767, + &optlstOptimizer_764, + &optlstOptimizer_761, + &optlstOptimizer_758, + &optlstOptimizer_755, + &optlstOptimizer_752, + 0 +}; +OptionList optlstOptimizer_771 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_COMPILER, + /* list = */ optlstOptimizer_771_list +}; +Option optlstOptimizer_772 = { + /* names = */ "O", + /* avail = */ OTF_STICKY | OTF_CASED | OTF_TOOL_COMPILER | OTF_HAS_SUB_OPTIONS, + /* param = */ 0, + /* sub = */ &optlstOptimizer_771, + /* conflicts = */ 0, + /* help = */ "control optimization; you may combine options as in '~~O4,p'" +}; +GENERIC_T optlstOptimizer867 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "G0Sn-Pe", + /* help = */ 0 +}; +Option optlstOptimizer_868 = { + /* names = */ "off|none", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer867, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "suppress all optimizations" +}; +GENERIC_T optlstOptimizer864 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "G2Pe", + /* help = */ 0 +}; +Option optlstOptimizer_865 = { + /* names = */ "on", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer864, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "same as '~~opt l2, peephole'" +}; +GENERIC_T optlstOptimizer861 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "G4GpShPe", + /* help = */ 0 +}; +Option optlstOptimizer_862 = { + /* names = */ "all|full", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer861, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "same as '~~opt l4, speed, peephole, schedule'" +}; +GENERIC_T optlstOptimizer858 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "Gs", + /* help = */ 0 +}; +Option optlstOptimizer_859 = { + /* names = */ "space|size", + /* avail = */ OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer858, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "optimize for space" +}; +GENERIC_T optlstOptimizer855 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "Gp", + /* help = */ 0 +}; +Option optlstOptimizer_856 = { + /* names = */ "speed", + /* avail = */ OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer855, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "optimize for speed" +}; +GENERIC_T optlstOptimizer850 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetPragmaOptimizationsToUnspecified, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +NUM_T optlstOptimizer852 = { + /* which = */ PARAMWHICH_Number, + /* flags = */ 0x00, + /* myname = */ "num", + /* next = */ (PARAM_T *) &optlstOptimizer850, + /* size = */ 1, + /* fit = */ 0, + /* lo = */ 0, + /* hi = */ 4, + /* num = */ &pGlobalOptimizer.optimizationlevel +}; +Option optlstOptimizer_853 = { + /* names = */ "l|level", + /* avail = */ OTF_ONLY_ONCE | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer852, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "set optimization level:\rlevel 0: global register allocation only for temporary values\rlevel 1: adds dead code elimination\rlevel 2: adds common subexpression elimination and copy propagation\rlevel 3: adds loop transformations, strength reducation, and loop-invariant code motion\rlevel 4: adds repeated common subexpression elimination and loop-invariant code motion" +}; +GENERIC_T optlstOptimizer847 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "G0", + /* help = */ 0 +}; +Option optlstOptimizer_848 = { + /* names = */ "l0", + /* avail = */ OTF_SECRET | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer847, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "level 0: global register allocation only for temporary values" +}; +GENERIC_T optlstOptimizer844 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "G1", + /* help = */ 0 +}; +Option optlstOptimizer_845 = { + /* names = */ "l1", + /* avail = */ OTF_SECRET | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer844, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "level 1: adds dead code elimination" +}; +GENERIC_T optlstOptimizer841 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "G2", + /* help = */ 0 +}; +Option optlstOptimizer_842 = { + /* names = */ "l2", + /* avail = */ OTF_SECRET | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer841, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "level 2: adds common subexpression elimination and copy propagation" +}; +GENERIC_T optlstOptimizer838 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "G3", + /* help = */ 0 +}; +Option optlstOptimizer_839 = { + /* names = */ "l3", + /* avail = */ OTF_SECRET | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer838, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "level 3: adds loop transformations, strength reducation, and loop-invariant code motion" +}; +GENERIC_T optlstOptimizer835 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "G4", + /* help = */ 0 +}; +Option optlstOptimizer_836 = { + /* names = */ "l4", + /* avail = */ OTF_SECRET | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer835, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "level 4: adds repeated common subexpression elimination and loop-invariant code motion" +}; +GENERIC_T optlstOptimizer832 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "Cs", + /* help = */ 0 +}; +Option optlstOptimizer_833 = { + /* names = */ "cse|commonsubs", + /* avail = */ OTF_COMPATIBILITY | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer832, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "common subexpression elimination" +}; +GENERIC_T optlstOptimizer829 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "Dc", + /* help = */ 0 +}; +Option optlstOptimizer_830 = { + /* names = */ "deadcode", + /* avail = */ OTF_COMPATIBILITY | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer829, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "removal of dead code" +}; +GENERIC_T optlstOptimizer826 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "Ds", + /* help = */ 0 +}; +Option optlstOptimizer_827 = { + /* names = */ "deadstore", + /* avail = */ OTF_COMPATIBILITY | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer826, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "removal of dead assignments" +}; +GENERIC_T optlstOptimizer823 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "Lt", + /* help = */ 0 +}; +Option optlstOptimizer_824 = { + /* names = */ "lifetimes", + /* avail = */ OTF_COMPATIBILITY | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer823, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "computation of variable lifetimes" +}; +GENERIC_T optlstOptimizer820 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "Li", + /* help = */ 0 +}; +Option optlstOptimizer_821 = { + /* names = */ "loop|loopinvariants", + /* avail = */ OTF_COMPATIBILITY | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer820, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "removal of loop invariants" +}; +GENERIC_T optlstOptimizer817 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "Pr", + /* help = */ 0 +}; +Option optlstOptimizer_818 = { + /* names = */ "prop|propagation", + /* avail = */ OTF_COMPATIBILITY | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer817, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "propagation of constant and copy assignments" +}; +GENERIC_T optlstOptimizer814 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "Sr", + /* help = */ 0 +}; +Option optlstOptimizer_815 = { + /* names = */ "strength", + /* avail = */ OTF_COMPATIBILITY | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer814, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "strength reduction; reducing multiplication by an index variable into addition" +}; +Option optlstOptimizer_812 = { + /* names = */ "global", + /* avail = */ OTF_IGNORED | OTF_HIDE_DEFAULT | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ 0, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "global optimization is controlled through '-opt level=X'" +}; +GENERIC_T optlstOptimizer810 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "Pe", + /* help = */ 0 +}; +Option optlstOptimizer_811 = { + /* names = */ "peep|peephole", + /* avail = */ OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer810, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "peephole optimization" +}; +GENERIC_T optlstOptimizer807 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "Rc", + /* help = */ 0 +}; +Option optlstOptimizer_808 = { + /* names = */ "color", + /* avail = */ OTF_COMPATIBILITY | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer807, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "register coloring" +}; +GENERIC_T optlstOptimizer804 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "Sh", + /* help = */ 0 +}; +Option optlstOptimizer_805 = { + /* names = */ "schedule", + /* avail = */ OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer804, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "schedule instructions (see '~~proc')" +}; +GENERIC_T optlstOptimizer801 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "S1", + /* help = */ 0 +}; +Option optlstOptimizer_802 = { + /* names = */ "schedule601", + /* avail = */ OTF_SECRET | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer801, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "-opt schedule, -proc 601" +}; +GENERIC_T optlstOptimizer798 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "S3", + /* help = */ 0 +}; +Option optlstOptimizer_799 = { + /* names = */ "schedule603", + /* avail = */ OTF_SECRET | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer798, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "-opt schedule, -proc 603" +}; +GENERIC_T optlstOptimizer795 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "S#", + /* help = */ 0 +}; +Option optlstOptimizer_796 = { + /* names = */ "schedule603e", + /* avail = */ OTF_SECRET | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer795, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "-opt schedule, -proc 603e" +}; +GENERIC_T optlstOptimizer792 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "S4", + /* help = */ 0 +}; +Option optlstOptimizer_793 = { + /* names = */ "schedule604", + /* avail = */ OTF_SECRET | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer792, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "-opt schedule, -proc 604" +}; +GENERIC_T optlstOptimizer789 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "S$", + /* help = */ 0 +}; +Option optlstOptimizer_790 = { + /* names = */ "schedule604e", + /* avail = */ OTF_SECRET | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer789, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "-opt schedule, -proc 604e" +}; +GENERIC_T optlstOptimizer786 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "S7", + /* help = */ 0 +}; +Option optlstOptimizer_787 = { + /* names = */ "schedule750", + /* avail = */ OTF_SECRET | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer786, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "-opt schedule, -proc 750" +}; +GENERIC_T optlstOptimizer783 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "SA", + /* help = */ 0 +}; +Option optlstOptimizer_784 = { + /* names = */ "schedulealtivec", + /* avail = */ OTF_SECRET | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer783, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "-opt schedule, -proc altivec" +}; +GENERIC_T optlstOptimizer780 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "G1PeS1", + /* help = */ 0 +}; +Option optlstOptimizer_781 = { + /* names = */ "inter|local|unroll", + /* avail = */ OTF_SECRET | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer780, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "opt level=1, peep, schedule=601" +}; +GENERIC_T optlstOptimizer777 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetOptFlags, + /* arg = */ (void *) "G2PeS1", + /* help = */ 0 +}; +Option optlstOptimizer_778 = { + /* names = */ "rep", + /* avail = */ OTF_SECRET | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer777, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "opt level=2, peep, schedule=601" +}; +GENERIC_T optlstOptimizer774 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &DisplayOptimizationOptions, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +Option optlstOptimizer_775 = { + /* names = */ "display|dump", + /* avail = */ OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstOptimizer774, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "display list of active optimizations" +}; +Option *optlstOptimizer_869_list[] = { + &optlstOptimizer_868, + &optlstOptimizer_865, + &optlstOptimizer_862, + &optlstOptimizer_859, + &optlstOptimizer_856, + &optlstOptimizer_853, + &optlstOptimizer_848, + &optlstOptimizer_845, + &optlstOptimizer_842, + &optlstOptimizer_839, + &optlstOptimizer_836, + &optlstOptimizer_833, + &optlstOptimizer_830, + &optlstOptimizer_827, + &optlstOptimizer_824, + &optlstOptimizer_821, + &optlstOptimizer_818, + &optlstOptimizer_815, + &optlstOptimizer_812, + &optlstOptimizer_811, + &optlstOptimizer_808, + &optlstOptimizer_805, + &optlstOptimizer_802, + &optlstOptimizer_799, + &optlstOptimizer_796, + &optlstOptimizer_793, + &optlstOptimizer_790, + &optlstOptimizer_787, + &optlstOptimizer_784, + &optlstOptimizer_781, + &optlstOptimizer_778, + &optlstOptimizer_775, + 0 +}; +OptionList optlstOptimizer_869 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_ALLOW_UNKNOWNS | LISTFLAGS_COMPILER, + /* list = */ optlstOptimizer_869_list +}; +Option optlstOptimizer_870 = { + /* names = */ "opt", + /* avail = */ OTF_TOOL_COMPILER | OTF_HAS_SUB_OPTIONS, + /* param = */ 0, + /* sub = */ &optlstOptimizer_869, + /* conflicts = */ 0, + /* help = */ "specify optimization options" +}; +Option *optlstOptimizer_871_list[] = { + &optlstOptimizer_749, + &optlstOptimizer_772, + &optlstOptimizer_870, + 0 +}; +OptionList optlstOptimizer = { + /* help = */ "Optimizer Options\n\tNote that all options besides '-opt off|on|all|space|speed|level=...' (marked with 'compatibility') are for backwards compatibility or special needs only; other optimization options may be superceded by use of '~~opt level=xxx'.\b", + /* flags = */ LISTFLAGS_COMPILER, + /* list = */ optlstOptimizer_871_list +}; diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsProject.opt b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsProject.opt new file mode 100644 index 0000000..095ddb9 --- /dev/null +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsProject.opt @@ -0,0 +1,320 @@ +/* forward declare */ extern OptionList projtype_conflicts; + +/* Project */ +SET_T optlstProject1012 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x0, + /* num = */ (char *) &pProject.type +}; +Option projtype_1013 = { + /* names = */ "app|application", + /* avail = */ OTF_TOOL_LINKER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstProject1012, + /* sub = */ 0, + /* conflicts = */ &projtype_conflicts, + /* help = */ "generate an application bundle; same as '~~xm a'" +}; +SET_T optlstProject1015 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x1, + /* num = */ (char *) &pProject.type +}; +Option projtype_1016 = { + /* names = */ "exe|executable", + /* avail = */ OTF_TOOL_LINKER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstProject1015, + /* sub = */ 0, + /* conflicts = */ &projtype_conflicts, + /* help = */ "generate an excutable; same as '~~xm e'" +}; +SET_T optlstProject1018 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x4, + /* num = */ (char *) &pProject.type +}; +Option projtype_1019 = { + /* names = */ "lib|library", + /* avail = */ OTF_TOOL_LINKER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstProject1018, + /* sub = */ 0, + /* conflicts = */ &projtype_conflicts, + /* help = */ "generate a static library; same as '~~xm l'" +}; +SET_T optlstProject1021 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x3, + /* num = */ (char *) &pProject.type +}; +Option projtype_1022 = { + /* names = */ "obj|object", + /* avail = */ OTF_TOOL_LINKER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstProject1021, + /* sub = */ 0, + /* conflicts = */ &projtype_conflicts, + /* help = */ "generate an object; same as '~~xm o'" +}; +SET_T optlstProject1024 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x2, + /* num = */ (char *) &pProject.type +}; +Option projtype_1025 = { + /* names = */ "shared|sharedlibrary||shlib", + /* avail = */ OTF_TOOL_LINKER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstProject1024, + /* sub = */ 0, + /* conflicts = */ &projtype_conflicts, + /* help = */ "generate a shared library; same as '~~xm s'" +}; +/* forward declare */ extern OptionList optlstProject_1041_conflicts; +SET_T optlstProject1039 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x0, + /* num = */ (char *) &pProject.type +}; +Option optlstProject_1041_1040 = { + /* names = */ "a|application", + /* avail = */ OTF_TOOL_LINKER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstProject1039, + /* sub = */ 0, + /* conflicts = */ &optlstProject_1041_conflicts, + /* help = */ "application bundle" +}; +SET_T optlstProject1036 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x1, + /* num = */ (char *) &pProject.type +}; +Option optlstProject_1041_1037 = { + /* names = */ "e|executable", + /* avail = */ OTF_TOOL_LINKER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstProject1036, + /* sub = */ 0, + /* conflicts = */ &optlstProject_1041_conflicts, + /* help = */ "executable" +}; +SET_T optlstProject1033 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x4, + /* num = */ (char *) &pProject.type +}; +Option optlstProject_1041_1034 = { + /* names = */ "l|library", + /* avail = */ OTF_TOOL_LINKER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstProject1033, + /* sub = */ 0, + /* conflicts = */ &optlstProject_1041_conflicts, + /* help = */ "static library" +}; +SET_T optlstProject1030 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x3, + /* num = */ (char *) &pProject.type +}; +Option optlstProject_1041_1031 = { + /* names = */ "o|object", + /* avail = */ OTF_TOOL_LINKER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstProject1030, + /* sub = */ 0, + /* conflicts = */ &optlstProject_1041_conflicts, + /* help = */ "object" +}; +SET_T optlstProject1027 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 2, + /* value = */ 0x2, + /* num = */ (char *) &pProject.type +}; +Option optlstProject_1041_1028 = { + /* names = */ "s|sharedlibrary", + /* avail = */ OTF_TOOL_LINKER | OTF_HAS_CONFLICTS, + /* param = */ (PARAM_T *) &optlstProject1027, + /* sub = */ 0, + /* conflicts = */ &optlstProject_1041_conflicts, + /* help = */ "shared library" +}; +Option *optlstProject_1041_list[] = { + &optlstProject_1041_1040, + &optlstProject_1041_1037, + &optlstProject_1041_1034, + &optlstProject_1041_1031, + &optlstProject_1041_1028, + 0 +}; +OptionList optlstProject_1041 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_LINKER, + /* list = */ optlstProject_1041_list +}; +OptionList optlstProject_1041_conflicts = { + /* help = */ 0, + /* flags = */ LISTFLAGS_EXCLUSIVE | LISTFLAGS_LINKER, + /* list = */ optlstProject_1041_list +}; +Option projtype_1042 = { + /* names = */ "xm", + /* avail = */ OTF_TOOL_LINKER | OTF_HAS_SUB_OPTIONS | OTF_HAS_CONFLICTS, + /* param = */ 0, + /* sub = */ &optlstProject_1041, + /* conflicts = */ &projtype_conflicts, + /* help = */ "specify project type" +}; +FTYPE_T optlstProject1043 = { + /* which = */ PARAMWHICH_FTypeCreator, + /* flags = */ 0x00, + /* myname = */ "creator", + /* next = */ 0, + /* fc = */ &pProject.filecreator, + /* iscreator = */ 30 +}; +SET_T optlstProject1046 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstProject1043, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pCLTExtras.userSetCreator +}; +Option optlstProject_1047 = { + /* names = */ "fc", + /* avail = */ OTF_TOOL_LINKER, + /* param = */ (PARAM_T *) &optlstProject1046, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "specify output file creator; not used with static libs and MPW tools" +}; +FTYPE_T optlstProject1048 = { + /* which = */ PARAMWHICH_FTypeCreator, + /* flags = */ 0x00, + /* myname = */ "type", + /* next = */ 0, + /* fc = */ &pProject.filetype, + /* iscreator = */ 156 +}; +SET_T optlstProject1051 = { + /* which = */ PARAMWHICH_Set, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ (PARAM_T *) &optlstProject1048, + /* size = */ 1, + /* value = */ 0x1, + /* num = */ (char *) &pCLTExtras.userSetType +}; +Option optlstProject_1052 = { + /* names = */ "ft", + /* avail = */ OTF_ONLY_ONCE | OTF_TOOL_LINKER, + /* param = */ (PARAM_T *) &optlstProject1051, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "specify output file type; not used with static libs and MPW tools" +}; +NUM_T optlstProject1054 = { + /* which = */ PARAMWHICH_Number, + /* flags = */ 0x00, + /* myname = */ 0, + /* next = */ 0, + /* size = */ 4, + /* fit = */ 0, + /* lo = */ 0, + /* hi = */ 0, + /* num = */ &pProject.stackaddress +}; +Option optlstProject_1055 = { + /* names = */ "stackaddr", + /* avail = */ OTF_HIDE_DEFAULT | OTF_TOOL_LINKER, + /* param = */ (PARAM_T *) &optlstProject1054, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "specify stack address; default is 0" +}; +NUM_T optlstProject1057 = { + /* which = */ PARAMWHICH_Number, + /* flags = */ 0x00, + /* myname = */ "kB", + /* next = */ 0, + /* size = */ 4, + /* fit = */ 0, + /* lo = */ 0, + /* hi = */ 0, + /* num = */ &pProject.stacksize +}; +Option optlstProject_1058 = { + /* names = */ "stacksize", + /* avail = */ OTF_HIDE_DEFAULT | OTF_TOOL_LINKER, + /* param = */ (PARAM_T *) &optlstProject1057, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "specify stack size in kilobytes default is kDefaultStackSize (i.e., determined by loader)" +}; +Option *optlstProject_1059_list[] = { + &projtype_1013, + &projtype_1016, + &projtype_1019, + &projtype_1022, + &projtype_1025, + &projtype_1042, + &optlstProject_1047, + &optlstProject_1052, + &optlstProject_1055, + &optlstProject_1058, + 0 +}; +OptionList optlstProject = { + /* help = */ "Mach-O PowerPC Project Options\n", + /* flags = */ LISTFLAGS_LINKER, + /* list = */ optlstProject_1059_list +}; +Option *projtype_000_list[] = { + &projtype_1013, + &projtype_1016, + &projtype_1019, + &projtype_1022, + &projtype_1025, + &projtype_1042, + 0 +}; +OptionList projtype_conflicts = { + /* help = */ 0, + /* flags = */ 0, + /* list = */ projtype_000_list +}; diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsWarningC.opt b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsWarningC.opt new file mode 100644 index 0000000..ff8b345 --- /dev/null +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsWarningC.opt @@ -0,0 +1,583 @@ +/* WarningC */ +GENERIC_T optlstWarningC659 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "IpEdPuUvUaEcPdHvIcNiCw", + /* help = */ 0 +}; +Option optlstWarningC_660 = { + /* names = */ "1", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstWarningC659, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "same as ~~w on" +}; +GENERIC_T optlstWarningC656 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "IpEdPuUvUaEcPdHvIcNiCpLaScCw", + /* help = */ 0 +}; +Option optlstWarningC_657 = { + /* names = */ "2", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstWarningC656, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "same as ~~w all" +}; +GENERIC_T optlstWarningC653 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "IpEdPuUvUaEcPdHvIcNiCw-UvUa", + /* help = */ 0 +}; +Option optlstWarningC_654 = { + /* names = */ "3", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstWarningC653, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "same as ~~w on,nounused" +}; +Option *optlstWarningC_661_list[] = { + &optlstWarningC_660, + &optlstWarningC_657, + &optlstWarningC_654, + 0 +}; +OptionList optlstWarningC_661 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_COMPILER, + /* list = */ optlstWarningC_661_list +}; +Option optlstWarningC_662 = { + /* names = */ "w", + /* avail = */ OTF_GLOBAL | OTF_STICKY | OTF_CASED | OTF_TOOL_COMPILER | OTF_HAS_SUB_OPTIONS, + /* param = */ 0, + /* sub = */ &optlstWarningC_661, + /* conflicts = */ 0, + /* help = */ "compatibility warning options" +}; +GENERIC_T optlstWarningC727 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "Cw", + /* help = */ 0 +}; +Option optlstWarningC_728 = { + /* names = */ "options|cmdline", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstWarningC727, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "command-line parser warnings" +}; +GENERIC_T optlstWarningC724 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "-IpEdPuUvUaEcPdHvIcNiCpLaScWeCw|Nw", + /* help = */ 0 +}; +Option optlstWarningC_725 = { + /* names = */ "off", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstWarningC724, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "turn off all warnings" +}; +GENERIC_T optlstWarningC721 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "IpEdPuUvUaEcPdHvIcNiCw", + /* help = */ 0 +}; +Option optlstWarningC_722 = { + /* names = */ "on", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstWarningC721, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "turn on most warnings, except 'largeargs' and 'structclass'" +}; +GENERIC_T optlstWarningC718 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "IpEdPuUvUaEcPdHvIcNiCw", + /* help = */ 0 +}; +Option optlstWarningC_719 = { + /* names = */ "conformance|usage", + /* avail = */ OTF_GLOBAL | OTF_SECRET | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstWarningC718, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "same as '-w on'" +}; +GENERIC_T optlstWarningC715 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "IpEdPuUvUaEcPdHvIcNiCpLaScCw", + /* help = */ 0 +}; +Option optlstWarningC_716 = { + /* names = */ "all|full", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstWarningC715, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "turn on all warnings, require prototypes" +}; +GENERIC_T optlstWarningC712 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "We", + /* help = */ 0 +}; +Option optlstWarningC_713 = { + /* names = */ "err|error|iserr|iserror", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstWarningC712, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "warnings are errors" +}; +GENERIC_T optlstWarningC709 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "Ip", + /* help = */ 0 +}; +Option optlstWarningC_710 = { + /* names = */ "pragmas|illpragmas", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstWarningC709, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "illegal #pragmas" +}; +GENERIC_T optlstWarningC706 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "Ed", + /* help = */ 0 +}; +Option optlstWarningC_707 = { + /* names = */ "empty|emptydecl", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstWarningC706, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "empty declarations" +}; +GENERIC_T optlstWarningC703 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "Pu", + /* help = */ 0 +}; +Option optlstWarningC_704 = { + /* names = */ "possible|unwanted", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstWarningC703, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "possible unwanted effects" +}; +GENERIC_T optlstWarningC700 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "UaUv", + /* help = */ 0 +}; +Option optlstWarningC_701 = { + /* names = */ "unused", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstWarningC700, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "unused arguments and variables" +}; +GENERIC_T optlstWarningC697 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "Ua", + /* help = */ 0 +}; +Option optlstWarningC_698 = { + /* names = */ "unusedarg", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstWarningC697, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "unused arguments" +}; +GENERIC_T optlstWarningC694 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "Uv", + /* help = */ 0 +}; +Option optlstWarningC_695 = { + /* names = */ "unusedvar", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstWarningC694, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "unused variables" +}; +GENERIC_T optlstWarningC691 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "UaUv", + /* help = */ 0 +}; +Option optlstWarningC_692 = { + /* names = */ "unused", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstWarningC691, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "same as ~~w [no]unusedarg,[no]unusedvar" +}; +GENERIC_T optlstWarningC688 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "Ec", + /* help = */ 0 +}; +Option optlstWarningC_689 = { + /* names = */ "extracomma|comma", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstWarningC688, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "extra commas" +}; +GENERIC_T optlstWarningC685 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "Pd", + /* help = */ 0 +}; +Option optlstWarningC_686 = { + /* names = */ "pedantic|extended", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstWarningC685, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "pedantic error checking" +}; +GENERIC_T optlstWarningC682 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "Hv", + /* help = */ 0 +}; +Option optlstWarningC_683 = { + /* names = */ "hidevirtual|hidden|hiddenvirtual", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstWarningC682, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "hidden virtual functions" +}; +GENERIC_T optlstWarningC679 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "Ic", + /* help = */ 0 +}; +Option optlstWarningC_680 = { + /* names = */ "implicit|implicitconv", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstWarningC679, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "implicit arithmetic conversions" +}; +GENERIC_T optlstWarningC676 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "Ni", + /* help = */ 0 +}; +Option optlstWarningC_677 = { + /* names = */ "notinlined", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstWarningC676, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "'inline' functions not inlined" +}; +GENERIC_T optlstWarningC673 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "La", + /* help = */ 0 +}; +Option optlstWarningC_674 = { + /* names = */ "largeargs", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstWarningC673, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "passing large arguments to unprototyped functions" +}; +GENERIC_T optlstWarningC670 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "Sc", + /* help = */ 0 +}; +Option optlstWarningC_671 = { + /* names = */ "structclass", + /* avail = */ OTF_GLOBAL | OTF_SLFLAGS_8 | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstWarningC670, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "inconsistent use of 'class' and 'struct'" +}; +GENERIC_T optlstWarningC667 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "-IpEdPuUvUaEcPdHvIcNiCpLaScCw|Nw", + /* help = */ 0 +}; +Option optlstWarningC_668 = { + /* names = */ "", + /* avail = */ OTF_GLOBAL | OTF_WARNING | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstWarningC667, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "Option 'w' deprecated, use 'w off' instead;\r'w' not passed to linker;\rparse error will occur if a non-option follows" +}; +GENERIC_T optlstWarningC664 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &DisplayWarningOptions, + /* arg = */ (void *) 0, + /* help = */ 0 +}; +Option optlstWarningC_665 = { + /* names = */ "display|dump", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER, + /* param = */ (PARAM_T *) &optlstWarningC664, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "display list of active warnings" +}; +Option *optlstWarningC_729_list[] = { + &optlstWarningC_728, + &optlstWarningC_725, + &optlstWarningC_722, + &optlstWarningC_719, + &optlstWarningC_716, + &optlstWarningC_713, + &optlstWarningC_710, + &optlstWarningC_707, + &optlstWarningC_704, + &optlstWarningC_701, + &optlstWarningC_698, + &optlstWarningC_695, + &optlstWarningC_692, + &optlstWarningC_689, + &optlstWarningC_686, + &optlstWarningC_683, + &optlstWarningC_680, + &optlstWarningC_677, + &optlstWarningC_674, + &optlstWarningC_671, + &optlstWarningC_668, + &optlstWarningC_665, + 0 +}; +OptionList optlstWarningC_729 = { + /* help = */ 0, + /* flags = */ LISTFLAGS_ALLOW_UNKNOWNS | LISTFLAGS_COMPILER, + /* list = */ optlstWarningC_729_list +}; +Option optlstWarningC_730 = { + /* names = */ "w|warnings", + /* avail = */ OTF_GLOBAL | OTF_TOOL_COMPILER | OTF_HAS_SUB_OPTIONS, + /* param = */ 0, + /* sub = */ &optlstWarningC_729, + /* conflicts = */ 0, + /* help = */ "warning options" +}; +GENERIC_T optlstWarningC732 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "IpPuHvEd", + /* help = */ 0 +}; +Option optlstWarningC_733 = { + /* names = */ "Wmost", + /* avail = */ OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstWarningC732, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "turn on pragmas, emptydecl, possible, hidevirtual" +}; +GENERIC_T optlstWarningC735 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "IpEdPuUvUaEcPdHvIcNiCpLaSc", + /* help = */ 0 +}; +Option optlstWarningC_736 = { + /* names = */ "Wall", + /* avail = */ OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstWarningC735, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "same as -w all" +}; +GENERIC_T optlstWarningC738 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "We", + /* help = */ 0 +}; +Option optlstWarningC_739 = { + /* names = */ "Werror", + /* avail = */ OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstWarningC738, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "same as -w iserror" +}; +GENERIC_T optlstWarningC741 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "UaUv", + /* help = */ 0 +}; +Option optlstWarningC_742 = { + /* names = */ "Wunused", + /* avail = */ OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstWarningC741, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "same as -w unusedarg,unusedvar" +}; +GENERIC_T optlstWarningC744 = { + /* which = */ PARAMWHICH_Generic, + /* flags = */ 0x01, + /* myname = */ 0, + /* next = */ 0, + /* parse = */ &SetWarningFlags, + /* arg = */ (void *) "-UaUv", + /* help = */ 0 +}; +Option optlstWarningC_745 = { + /* names = */ "Wno-unused", + /* avail = */ OTF_TOOL_COMPILER | OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER, + /* param = */ (PARAM_T *) &optlstWarningC744, + /* sub = */ 0, + /* conflicts = */ 0, + /* help = */ "turns off -w unusedarg,unusedvar" +}; +Option *optlstWarningC_746_list[] = { + &optlstWarningC_662, + &optlstWarningC_730, + &optlstWarningC_733, + &optlstWarningC_736, + &optlstWarningC_739, + &optlstWarningC_742, + &optlstWarningC_745, + 0 +}; +OptionList optlstWarningC = { + /* help = */ "Warning Options\n", + /* flags = */ LISTFLAGS_COMPILER | LISTFLAGS_LINKER | LISTFLAGS_DISASSEMBLER, + /* list = */ optlstWarningC_746_list +}; diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-ld/OptsCmdLine.opt b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-ld/OptsCmdLine.opt new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-ld/OptsCmdLineLinker.opt b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-ld/OptsCmdLineLinker.opt new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-ld/OptsDebugging.opt b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-ld/OptsDebugging.opt new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-ld/OptsDumper.opt b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-ld/OptsDumper.opt new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-ld/OptsLinker.opt b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-ld/OptsLinker.opt new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-ld/OptsProject.opt b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-ld/OptsProject.opt new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-ld/OptsWarning.opt b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-ld/OptsWarning.opt new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-cc.c b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-cc.c new file mode 100644 index 0000000..7e741c3 --- /dev/null +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-cc.c @@ -0,0 +1,137 @@ +#include "cmdline.h" +#include "parser.h" + +#include "compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-common.h" + +static Boolean useDefaultIncludes = 1; +static Boolean useDefaultLibraries = 1; + +#include "compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsCmdLine.opt" +#include "compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsCmdLineCompiler.opt" +#include "compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsCmdLineLinker.opt" +#include "compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsFrontEndC.opt" +#include "compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsDebugging.opt" +#include "compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsOptimizer.opt" +#include "compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsWarningC.opt" +#include "compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsBackEnd.opt" +#include "compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsProject.opt" +#include "compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsLinker.opt" +#include "compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/OptsDumper.opt" + +char *prefs[] = { + "PPC CodeGen Mach-O", + "PPC Mach-O Linker", + "PPC Mach-O Target", + "PPC Disassembler", + "PPC Global Optimizer", + "C/C++ Compiler", + "C/C++ Warnings", + "CmdLine Panel", + "CmdLine Compiler Panel", + "CmdLine Linker Panel" +}; + +OptionList *optLists[] = { + &optlstCmdLine, + &optlstCmdLineCompiler, + &optlstFrontEndC, + &optlstBackEnd, + &optlstOptimizer, + &optlstDebugging, + &optlstWarningC, + &optlstProject, + &optlstCmdLineLinker, + &optlstLinker, + &optlstDumper +}; + +static PrefDataPanel stPrefPanels[] = { + "PPC CodeGen Mach-O", &pBackEnd, sizeof(pBackEnd), + "PPC Mach-O Linker", &pLinker, sizeof(pLinker), + "PPC Mach-O Target", &pProject, sizeof(pProject), + "PPC Disassembler", &pDisassembler, sizeof(pDisassembler), + "PPC Global Optimizer", &pGlobalOptimizer, sizeof(pGlobalOptimizer), + "C/C++ Compiler", &pFrontEndC, sizeof(pFrontEndC), + "C/C++ Warnings", &pWarningC, sizeof(pWarningC), + "CmdLine Panel", &pCmdLine, sizeof(pCmdLine), + "CmdLine Compiler Panel", &pCmdLineCompiler, sizeof(pCmdLineCompiler), + "CmdLine Linker Panel", &pCmdLineLinker, sizeof(pCmdLineLinker) +}; + +static int PreParse() { + setLinkerOutputFilename = 0; + linkerOutputFilename[0] = 0; + definesHandle = NULL; + useDefaultIncludes = 1; + schedule_ppc_default = 0; + return 1; +} + +static int MidParse() { + const char *match; + const char *env; + + if (!pCmdLine.state) + pCmdLine.state = OptsCmdLineState_2; + + if (parseopts.possibleFiles > 0 && useDefaultIncludes) { + if ((env = GetEnvVar("MWCMachPPCIncludes", 1, &match))) { + // FIXME can probably get rid of this cast later + if (!AddAccessPathList(env, ':', ',', 1, (char *) match, 1, -1, 0)) + return 0; + } + } + + return 1; +} + +static int PostParse() { + if (!SetupPragmas(irPragmas) || !SetupPragmas(warningPragmas)) + return 0; + + if (definesHandle) { + static const char *name = "(command-line defines)"; + if (pCmdLine.verbose) + ShowTextHandle(name, definesHandle); + AddVirtualFile(name, &definesHandle); + c2pstrcpy(pFrontEndC.oldprefixname, name); + } else { + pFrontEndC.oldprefixname[0] = 0; + } + + FinishCompilerTool(); + if (!ValidateToolState(1)) + return 0; + + if (linkerOutputFilename[0]) { + Arg_AddToToolArgs(&linkargs, ATK_ARG_END, NULL); + Arg_AddToToolArgs(&linkargs, ATK_ARG, "-o"); + Arg_AddToToolArgs(&linkargs, ATK_ARG_END, NULL); + Arg_AddToToolArgs(&linkargs, ATK_ARG, linkerOutputFilename); + Arg_AddToToolArgs(&linkargs, ATK_ARG_END, NULL); + } + + return 1; +} + +static ParserTool parser = { + CWDROPINCOMPILERTYPE, + Lang_C_CPP, + targetCPUPowerPC, + CWFOURCHAR('R','h','a','p'), + 10, + prefs, + "Metrowerks C/C++ Compiler for Mach-O/PPC", + "1993-2000", + 11, + optLists, + 10, + stPrefPanels, + &PreParse, + &MidParse, + &PostParse +}; + +int RegisterStaticParserToolInfo() { + return SetParserToolInfo(&parser); +} diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-common.h b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-common.h new file mode 100644 index 0000000..a56768d --- /dev/null +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-common.h @@ -0,0 +1,147 @@ +PCmdLine pCmdLine = { + 0x1002, + 3, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 2 +}; +PCmdLineCompiler pCmdLineCompiler = { + 0x1005, + 0, + 0, + 0, + "", + "", + "", + "", + "", + "", + "", + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + "", + 0, + 0, + 0, + 0, + "", + 0, + 1 +}; +PCmdLineLinker pCmdLineLinker = { + 0x1001, + 1, + 1 +}; +PFrontEndC pFrontEndC = { // compiler only? + 0xC, + 0, + 0, + 0, + 0, + 0, + 1, + 0, + "", + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1, + 0, + 0, + 0, + 1 +}; +PWarningC pWarningC = { // compiler only? + 4 +}; +PGlobalOptimizer pGlobalOptimizer = { // compiler only? + 1, + 2 +}; +PBackEnd pBackEnd = { + 1, + 2, + 0, + 0, + 1, + 0, + 1, + 1, + 1, + 0, + 0, + 1, + 0, + 0, + 1, + 1, + 0, + 1 +}; +PDisassembler pDisassembler = { + 1, + 1, + 1, + 0, + 0, + 1, + 1, + 0, + 1 +}; +PMachOLinker pLinker = { + 1, + 0, + 0, + 0, + 0, + 1, + 0, + 0, + 1, + 0, + 0, + 0, + 0, + 2 +}; +PMachOProject pProject = { + 1, + 1, + "", + CWFOURCHAR('?','?','?','?'), + CWFOURCHAR('M','E','X','E'), + 0x40 +}; +PCLTExtras pCLTExtras = { + 1 +}; diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-ld.c b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-ld.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-cc.c b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-cc.c new file mode 100644 index 0000000..31b718f --- /dev/null +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-cc.c @@ -0,0 +1,84 @@ +#include "parser.h" + +// I'm making assumptions about the name of this file +// based on TargetWarningHelpers-ppc-ld.c existing in the linker + +PExtraWarningC pExtraWarningC = {0}; +Pragma warningPragmas[] = { + &pExtraWarningC.warn_largeargs, "warn_largeargs", 0, + &pExtraWarningC.warn_padding, "warn_padding", 0, + &pExtraWarningC.warn_resultnotused, "warn_resultnotused", 0, + &pExtraWarningC.warn_ptr_int_conv, "warn_ptr_int_conv", 0, + &pExtraWarningC.warn_no_side_effect, "warn_no_side_effect", 0, + 0, 0, 0 +}; + +int TargetSetWarningFlags(short val, Boolean set) { + switch (val) { + case 'Ip': pWarningC.warn_illpragma = set; break; + case 'Ed': pWarningC.warn_emptydecl = set; break; + case 'Pu': pWarningC.warn_possunwant = set; break; + case 'Uv': pWarningC.warn_unusedvar = set; break; + case 'Ua': pWarningC.warn_unusedarg = set; break; + case 'Ec': pWarningC.warn_extracomma = set; break; + case 'Pe': pWarningC.pedantic = set; break; + case 'Hv': pWarningC.warn_hidevirtual = set; break; + case 'Ic': pWarningC.warn_implicitconv = set; break; + case 'Ni': pWarningC.warn_notinlined = set; break; + case 'Sc': pWarningC.warn_structclass = set; break; + case 'Pa': pExtraWarningC.warn_padding = set ? 1 : 2; break; + case 'Nu': pExtraWarningC.warn_resultnotused = set ? 1 : 2; break; + case 'Se': pExtraWarningC.warn_no_side_effect = set ? 1 : 2; break; + case 'PI': pExtraWarningC.warn_ptr_int_conv = set ? 1 : 2; break; + case 'La': pExtraWarningC.warn_largeargs = set ? 1 : 2; break; + case 'We': pWarningC.warningerrors = set; break; + case 'Cp': pFrontEndC.checkprotos = set; break; + default: return 0; + } + + return 1; +} + +void TargetDisplayWarningOptions(Handle txt) { + HPrintF(txt, "C language warning options:\n"); + + if (pWarningC.warn_illpragma) + HPrintF(txt, "\t- illegal pragmas\n"); + if (pWarningC.warn_emptydecl) + HPrintF(txt, "\t- empty declarations\n"); + if (pWarningC.warn_possunwant) + HPrintF(txt, "\t- possible unwanted effects\n"); + if (pWarningC.warn_unusedvar) + HPrintF(txt, "\t- unused variables\n"); + if (pWarningC.warn_unusedarg) + HPrintF(txt, "\t- unused arguments\n"); + if (pWarningC.warn_extracomma) + HPrintF(txt, "\t- extra commas\n"); + if (pWarningC.pedantic) + HPrintF(txt, "\t- pedantic\n"); + if (pWarningC.warn_hidevirtual) + HPrintF(txt, "\t- hidden virtual functions\n"); + if (pWarningC.warn_implicitconv) + HPrintF(txt, "\t- implicit conversions\n"); + if (pWarningC.warn_notinlined) + HPrintF(txt, "\t- 'inline' not performed\n"); + if (pWarningC.warn_structclass) + HPrintF(txt, "\t- struct/class conflict\n"); + if (pExtraWarningC.warn_largeargs) + HPrintF(txt, "\t- large args passed to unprototyped functions\n"); + if (pExtraWarningC.warn_padding) + HPrintF(txt, "\t- padding added between struct members\n"); + if (pExtraWarningC.warn_resultnotused) + HPrintF(txt, "\t- result of non-void function call not used\n"); + if (pExtraWarningC.warn_no_side_effect) + HPrintF(txt, "\t- use of expressions as statements without side effects\n"); + if (pExtraWarningC.warn_ptr_int_conv) + HPrintF(txt, "\t- implicit integer/pointer conversions\n"); + if (pFrontEndC.checkprotos) + HPrintF(txt, "\t- checking prototypes\n"); + + if (pWarningC.warningerrors) + HPrintF(txt, "\t- warnings are errors\n"); + else + HPrintF(txt, "\t- warnings are not errors\n"); +} diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-ld.c b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-ld.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.c b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.c new file mode 100644 index 0000000..fc6206c --- /dev/null +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.c @@ -0,0 +1,582 @@ +#include "cmdline.h" + +extern CWPLUGIN_ENTRY(MWC_main)(CWPluginContext context); + +CWPLUGIN_ENTRY (CWPlugin_GetDropInFlags)(const DropInFlags **flags, SInt32 *flagsSize) { + static const DropInFlags sFlags = { + kCurrentDropInFlagsVersion, + CWDROPINCOMPILERTYPE, + DROPINCOMPILERLINKERAPIVERSION_8, + kGeneratescode | kCanpreprocess | kCanprecompile | kCompAllowDupFileNames, + Lang_C_CPP, + DROPINCOMPILERLINKERAPIVERSION_12 + }; + + *flags = &sFlags; + *flagsSize = sizeof(sFlags); + return 0; +} + +CWPLUGIN_ENTRY (CWPlugin_GetTargetList)(const CWTargetList **targetList) { + static CWDataType sCPU[1] = {targetCPUPowerPC}; + static CWDataType sOS[1] = {CWFOURCHAR('R','h','a','p')}; + static CWTargetList sTargetList = { + kCurrentCWTargetListVersion, + 1, + sCPU, + 1, + sOS + }; + + *targetList = &sTargetList; + return 0; +} + +CWPLUGIN_ENTRY (CWPlugin_GetDropInName)(const char **dropinName) { + static const char *sDropInName = "MW C/C++ Mach-O PPC"; + *dropinName = sDropInName; + return 0; +} + +CWPLUGIN_ENTRY (CWPlugin_GetDisplayName)(const char **displayName) { + static const char *sDisplayName = "Mach-O PPC"; + *displayName = sDisplayName; + return 0; +} + +CWPLUGIN_ENTRY (CWPlugin_GetDefaultMappingList)(const CWExtMapList **defaultMappingList) { + static CWExtensionMapping sExtension[10] = { + CWFOURCHAR('T','E','X','T'), ".c", 0, + CWFOURCHAR('T','E','X','T'), ".c++", 0, + CWFOURCHAR('T','E','X','T'), ".cc", 0, + CWFOURCHAR('T','E','X','T'), ".cp", 0, + CWFOURCHAR('T','E','X','T'), ".cpp", 0, + CWFOURCHAR('T','E','X','T'), ".h", kIgnored, + CWFOURCHAR('T','E','X','T'), ".h++", kIgnored, + CWFOURCHAR('T','E','X','T'), ".hpp", kIgnored, + CWFOURCHAR('T','E','X','T'), ".pch", kPrecompile, + CWFOURCHAR('T','E','X','T'), ".pch++", kPrecompile + }; + static CWExtMapList sExtensionMapList = { + kCurrentCWExtMapListVersion, + 10, + sExtension + }; + + *defaultMappingList = &sExtensionMapList; + return 0; +} + +CWPLUGIN_ENTRY (CWPlugin_GetPanelList)(const CWPanelList **panelList) { + static const char *sPanelNames[4] = { + "C/C++ Compiler", + "C/C++ Warnings", + "PPC Global Optimizer", + "PPC CodeGen Mach-O" + }; + static CWPanelList sPanelList = { + kCurrentCWPanelListVersion, + 4, + sPanelNames + }; + + *panelList = &sPanelList; + return 0; +} + +static CWPLUGIN_ENTRY (CmdLine_GetObjectFlags)(const CWObjectFlags **objectFlags) { + static const CWObjectFlags sFlags = { + 2, + 0x80000000, + ".o", + ".b", + ".i", + ".s", + ".d", + "mch", + CWFOURCHAR('C','W','I','E'), CWFOURCHAR('M','P','L','F'), + CWFOURCHAR('C','W','I','E'), CWFOURCHAR('B','R','W','S'), + CWFOURCHAR('C','W','I','E'), CWFOURCHAR('T','E','X','T'), + CWFOURCHAR('C','W','I','E'), CWFOURCHAR('T','E','X','T'), + CWFOURCHAR('C','W','I','E'), CWFOURCHAR('T','E','X','T') + }; + + *objectFlags = &sFlags; + return 0; +} + +static CWPLUGIN_ENTRY (CWPlugin_GetVersionInfo)(const VersionInfo **versionInfo) { + static const VersionInfo vi = { + 2, 4, 5, 0 + }; + + *versionInfo = &vi; + return 0; +} + +static CWPLUGIN_ENTRY (CWPlugin_GetFileTypeMappings)(const OSFileTypeMappingList **mappings) { + static const OSFileTypeMapping ftmes[2] = { + CWFOURCHAR('M','M','C','H'), "\xBE\xEF\xFA\xCE", 4, 0, NULL, + CWFOURCHAR('M','M','C','H'), "\xCE\xFA\xEF\xBE", 4, 0, NULL + }; + static const OSFileTypeMappingList ftml = { + 2, ftmes + }; + + *mappings = &ftml; + return 0; +} + +static BasePluginCallbacks plugin_cb = { + MWC_main, + CWPlugin_GetDropInFlags, + CWPlugin_GetDisplayName, + CWPlugin_GetDropInName, + CWPlugin_GetPanelList, + NULL, + NULL, + CWPlugin_GetVersionInfo, + CWPlugin_GetFileTypeMappings +}; + +static CompilerLinkerPluginCallbacks plugin_cl_cb = { + CWPlugin_GetTargetList, + CWPlugin_GetDefaultMappingList, + NULL, + NULL, + CmdLine_GetObjectFlags, + NULL +}; + +static CWPLUGIN_ENTRY (Linker_GetDropInFlags)(const DropInFlags **flags, SInt32 *flagsSize) { + static const DropInFlags sFlags = { + kCurrentDropInFlagsVersion, + CWDROPINLINKERTYPE, + DROPINCOMPILERLINKERAPIVERSION_8, + 1, + CWFOURCHAR('*','*','*','*'), + DROPINCOMPILERLINKERAPIVERSION_12 + }; + + *flags = &sFlags; + *flagsSize = sizeof(sFlags); + return 0; +} + +static CWPLUGIN_ENTRY (Linker_GetDropInName)(const char **dropinName) { + *dropinName = "Mach-O PPC Linker"; + return 0; +} + +static CWPLUGIN_ENTRY (Linker_GetDisplayName)(const char **displayName) { + *displayName = "Linker Tool Stub"; + return 0; +} + +static CWPLUGIN_ENTRY (Linker_GetPanelList)(const CWPanelList **panelList) { + static const char *sPanelNames[3] = { + "PPC Mach-O Linker", + "PPC Mach-O Target", + "PPC Disassembler" + }; + static CWPanelList sPanelList = { + kCurrentCWPanelListVersion, + 3, + sPanelNames + }; + + *panelList = &sPanelList; + return 0; +} + +static CWPLUGIN_ENTRY (Linker_GetTargetList)(const CWTargetList **targetList) { + static CWDataType sCPU[1] = {targetCPUPowerPC}; + static CWDataType sOS[1] = {CWFOURCHAR('R','h','a','p')}; + static CWTargetList sTargetList = { + kCurrentCWTargetListVersion, + 1, + sCPU, + 1, + sOS + }; + + *targetList = &sTargetList; + return 0; +} + +static CWPLUGIN_ENTRY (Linker_GetDefaultMappingList)(const CWExtMapList **defaultMappingList) { + static CWExtensionMapping sExtension[8] = { + CWFOURCHAR('A','P','P','L'), "", kLaunchable | kRsrcfile, + CWFOURCHAR('A','p','p','l'), "", kLaunchable | kRsrcfile, + CWFOURCHAR('M','W','C','D'), "", kLaunchable | kRsrcfile, + CWFOURCHAR('R','S','R','C'), "", kLaunchable | kRsrcfile, + CWFOURCHAR('r','s','r','c'), "", kLaunchable | kRsrcfile, + CWFOURCHAR('d','o','c','u'), "", kLaunchable | kRsrcfile, + 0, ".rsrc", kLaunchable | kRsrcfile, + 0, ".doc", kLaunchable | kIgnored + }; + static CWExtMapList sExtensionMapList = { + kCurrentCWExtMapListVersion, + 8, + sExtension + }; + + *defaultMappingList = &sExtensionMapList; + return 0; +} + +static BasePluginCallbacks lk_cb = { + NULL, + Linker_GetDropInFlags, + Linker_GetDisplayName, + Linker_GetDropInName, + Linker_GetPanelList, + NULL, + NULL, + CWPlugin_GetVersionInfo, + NULL +}; + +static CompilerLinkerPluginCallbacks lk_cl_cb = { + Linker_GetTargetList, + Linker_GetDefaultMappingList, + NULL, + NULL, + NULL, + NULL +}; + +int RegisterStaticCompilerPlugin() { + return RegisterStaticCompilerLinkerPlugin(&plugin_cb, &plugin_cl_cb) && RegisterStaticCompilerLinkerPlugin(&lk_cb, &lk_cl_cb); +} + +// This is going to be in some .r file, but I'm not sure which +static const char *STR10000[] = { + "illegal character constant", + "illegal string constant", + "unexpected end of file", + "unterminated comment", + "undefined preprocessor directive", + "illegal token", + "string too long", + "identifier expected", + "macro '%u' redefined", + "illegal argument list", + "too many macro arguments", + "macro(s) too complex", + "unexpected end of line", + "end of line expected", + "'(' expected", + "')' expected", + "',' expected", + "preprocessor syntax error", + "preceding #if is missing", + "unterminated #if / macro", + "unexpected token", + "declaration syntax error", + "identifier '%u' redeclared", + "';' expected", + "illegal constant expression", + "']' expected", + "illegal use of 'void'", + "illegal function definition", + "illegal function return type", + "illegal array definition", + "'}' expected", + "illegal struct/union/enum/class definition", + "struct/union/enum/class tag '%u' redefined", + "struct/union/class member '%u' redefined", + "declarator expected", + "'{' expected", + "illegal use of incomplete struct/union/class '%t'", + "struct/union/class size exceeds 32K", + "illegal bitfield declaration", + "division by 0", + "undefined identifier '%u'", + "expression syntax error", + "not an lvalue", + "illegal operation", + "illegal operand", + "data type is incomplete", + "illegal type", + "too many initializers", + "pointer/array required", + "not a struct/union/class", + "'%u' is not a struct/union/class member", + "the file '%u' cannot be opened", + "illegal instruction for this processor", + "illegal operands for this processor", + "number is out of range", + "illegal addressing mode", + "illegal data size", + "illegal register list", + "branch out of range", + "undefined label '%u'", + "reference to label '%u' is out of range", + "call of non-function", + "function call does not match prototype", + "illegal use of register variable", + "illegal type cast", + "function already has a stackframe", + "function has no initialized stackframe", + "value is not stored in register", + "function nesting too complex", + "illegal use of keyword", + "':' expected", + "label '%u' redefined", + "case constant defined more than once", + "default label defined more than once", + "illegal initialization", + "illegal use of inline function", + "illegal type qualifier(s)", + "illegal storage class", + "function has no prototype", + "illegal assignment to constant", + "illegal use of precompiled header", + "illegal data in precompiled header", + "variable / argument '%u' is not used in function", + "illegal use of direct parameters", + "return value expected", + "variable '%u' is not initialized before being used", + "illegal #pragma", + "illegal access to protected/private member", + "ambiguous access to class/struct/union member", + "illegal use of 'this'", + "unimplemented C++ feature", + "illegal use of 'HandleObject'", + "illegal access qualifier", + "illegal 'operator' declaration", + "illegal use of abstract class ('%o')", + "illegal use of pure function", + "illegal '&' reference", + "illegal function overloading", + "illegal operator overloading", + "ambiguous access to overloaded function ", + "illegal access/using declaration", + "illegal 'friend' declaration", + "illegal 'inline' function definition", + "class has no default constructor", + "illegal operator", + "illegal default argument(s)", + "possible unwanted ';'", + "possible unwanted assignment", + "possible unwanted compare", + "illegal implicit conversion from '%t' to", + "'%t'", + "local data >32k", + "illegal jump past initializer", + "illegal ctor initializer", + "cannot construct %t's base class '%t'", + "cannot construct %t's direct member '%u'", + "#if nesting overflow", + "illegal empty declaration", + "illegal implicit enum conversion from '%t' to", + "'%t'", + "illegal use of #pragma parameter", + "virtual functions cannot be pascal functions", + "illegal implicit const/volatile pointer conversion from '%t' to", + "'%t'", + "illegal use of non-static member", + "illegal precompiled header version", + "illegal precompiled header compiler flags or target", + "'const' or '&' variable needs initializer", + "'%o' hides inherited virtual function '%o'", + "pascal function cannot be overloaded", + "derived function differs from virtual base function in return type only", + "non-const '&' reference initialized to temporary", + "illegal template declaration", + "'<' expected", + "'>' expected", + "illegal template argument(s)", + "cannot instantiate '%o'", + "template redefined", + "template parameter mismatch", + "cannot pass const/volatile data object to non-const/volatile member function", + "preceding '#pragma push' is missing", + "illegal explicit template instantiation", + "illegal X::X(X) copy constructor", + "function defined 'inline' after being called", + "illegal constructor/destructor declaration", + "'catch' expected", + "#include nesting overflow", + "cannot convert", + "'%t' to", + "'%t'", + "type mismatch", + "'%t' and", + "'%t'", + "class type expected", + "illegal explicit conversion from '%t' to", + "'%t'", + "function call '*' does not match", + "identifier '%u' redeclared", + "was declared as: '%t'", + "now declared as: '%t'", + "cannot throw class with ambiguous base class ('%u')", + "class '%t': '%o' has more than one final overrider:", + "'%o'", + "and '%o'", + "exception handling option is disabled", + "cannot delete pointer to const", + "cannot destroy const object", + "const member '%u' is not initialized", + "'&' reference member '%u' is not initialized", + "RTTI option is disabled", + "constness casted away", + "illegal const/volatile '&' reference initialization", + "inconsistent linkage: 'extern' object redeclared as 'static'", + "unknown assembler instruction mnemonic", + "local data > 224 bytes", + "'%u' could not be assigned to a register", + "illegal exception specification", + "exception specification list mismatch", + "the parameter(s) of the '%n' function must be immediate value(s)", + "SOM classes can only inherit from other SOM based classes", + "SOM classes inhertiance must be virtual", + "SOM class data members must be private", + "illegal SOM function overload '%o'", + "no static members allowed in SOM classes", + "no parameters allowed in SOM class constructors", + "illegal SOM function parameters or return type", + "SOM runtime function '%u' not defined (should be defined in somobj.hh)", + "SOM runtime function '%u' has unexpected type", + "'%u' is not a SOM class", + "illegal use of #pragma outside of SOM class definition", + "introduced method '%o' is not specified in release order list", + "SOM class access qualification only allowed to direct parent or own class", + "SOM class must have one non-inline member function", + "SOM type '%u' undefined", + "new SOM callstyle method '%o' must have explicit 'Environment *' parameter", + "functions cannot return SOM classes", + "functions cannot have SOM class arguments", + "assignment is not supported for SOM classes", + "sizeof() is not supported for SOM classes", + "SOM classes cannot be class members", + "global SOM class objects are not supported", + "SOM class arrays are not supported", + "'pointer to member' is not supported for SOM classes", + "SOM class has no release order list", + "'%u' is not an Objective-C class", + "method '%m' redeclared", + "undefined method '%m'", + "class '%u' redeclared", + "class '%u' redefined", + "Objective-C type '%u' is undefined (should be defined in objc.h)", + "Objective-C type '%u' has unexpected type", + "method '%m' not defined", + "method '%m' redefined", + "illegal use of 'self'", + "illegal use of 'super'", + "illegal message receiver", + "receiver cannot handle this message", + "ambiguous message selector", + "used: '%m'", + "also had: '%m'", + "unknown message selector", + "illegal use of Objective-C object", + "protocol '%u' redefined", + "protocol '%u' is undefined", + "protocol '%u' is already in protocol list", + "category '%u' redefined", + "category '%u' is undefined", + "illegal use of '%u'", + "template too complex or recursive", + "illegal return value in void/constructor/destructor function", + "assigning a non-int numeric value to an unprototyped function", + "implicit arithmetic conversion from '%t' to '%t'", + "preprocessor #error directive", + "ambiguous access to name found '%u' and '%u'", + "illegal namespace", + "illegal use of namespace name", + "illegal name overloading", + "instance variable list does not match @interface", + "protocol list does not match @interface", + "super class does not match @interface", + "function result is a pointer/reference to an automatic variable", + "cannot allocate initialized objects in the scratchpad", + "illegal class member access", + "data object '%o' redefined", + "illegal access to local variable from other function", + "illegal implicit member pointer conversion", + "typename redefined", + "object '%o' redefined", + "'main' not defined as external 'int main()' function", + "illegal explicit template specialization", + "name has not been declared in namespace/class", + "preprocessor #warning directive", + "illegal use of asm inline function", + "illegal use of C++ feature in EC++", + "illegal use template argument dependent type 'T::%u'", + "illegal use of alloca() in function argument", + "inline function call '%o' not inlined", + "inconsistent use of 'class' and 'struct' keywords", + "illegal partial specialization", + "illegal partial specialization argument list", + "ambiguous use of partial specialization", + "local classes shall not have member templates", + "illegal template argument dependent expression", + "implicit 'int' is no longer supported in C++", + "%i pad byte(s) inserted after data member '%u'", + "pure function '%o' is not virtual", + "illegal virtual function '%o' in 'union'", + "cannot pass 'void' or 'function' parameter", + "illegal static const member '%u' initialization", + "'typename' is missing in template argument dependent qualified type", + "more than one expression in non-class type conversion", + "template non-type argument objects shall have external linkage", + "illegal inline assembly operand: %u", + "illegal or unsupported __attribute__", + "cannot create object file '%f'", + "error writing to object file '%f'", + "printf-family format string doesn't match arguments", + "scanf-family format string doesn't match arguments", + "__alignof__() is not supported for SOM classes", + "illegal macro argument name '%u'", + "case has an empty range of values", + "'long long' switch() is not supported", + "'long long' case range is not supported", + "expression has no side effect", + "result of function call is not used", + "illegal non-type template argument", + "illegal use of abstract class ('%t')", + "illegal use of 'template' prefix", + "template parameter/argument list mismatch", + "cannot find matching deallocation function for '%t'", + "illegal operand '%t'", + "illegal operands '%t' %u '%t'", + "illegal use of default template-argument", + "illegal UUID syntax", + "__uuidof() is not supported for SOM classes", + "illegal access from '%t' to protected/private member '%o'", + "integral type is not large enough to hold pointer", + "unknown x86 assembler instruction mnemonic", + "illegal use of const/volatile function qualifier sequence", + "illegal optimization level for this limited version of CodeWarrior", + "no UUID defined for type '%t'", + "using implicit copy assigment for class with const or reference member ('%t')", + "unimplemented assembler instruction/directive", + "override of dllimport function '%u' only has application scope", + "illegal combination of operands in inline statement at line %i", + "illegal operand in inline statement at line %i", + "function call '*' is ambiguous", + NULL +}; + +static const char *STR10100[] = { + "### Error: Compilation aborted at end of file ###", + "Save precompiled header as...", + "### Error while creating precompiled headerfile (OSErr %ld) ###", + "### Error while writing precompiled headerfile (OSErr %ld) ### ", + "internal compiler error: File: '%s' Line: %ld", + "ran out of registers--turn on Global Optimization for this function", + "### Error: Out of memory ###", + "### User break detected ###", + "### Error: Cannot open main file ###", + "Analyzing symbol table...", + "Writing precompiled header file...", + NULL +}; + +int RegisterCompilerResources() { + return RegisterResource("Compiler Errors", 10000, STR10000) && RegisterResource("Compiler Strings", 10100, STR10100); +} diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/ld-mach-ppc.c b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/ld-mach-ppc.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/libimp-mach-ppc.c b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/libimp-mach-ppc.c new file mode 100644 index 0000000..b62d413 --- /dev/null +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/libimp-mach-ppc.c @@ -0,0 +1,146 @@ +#include "cmdline.h" + +// this exists elsewhere +extern CWPLUGIN_ENTRY(PPCLibImport_main)(CWPluginContext context); + +CWPLUGIN_ENTRY (PPCLibImport_GetDropInFlags)(const DropInFlags **flags, SInt32 *flagsSize) { + static const DropInFlags sFlags = { + kCurrentDropInFlagsVersion, + CWDROPINCOMPILERTYPE, + DROPINCOMPILERLINKERAPIVERSION_8, + kGeneratescode | kCanpreprocess | kCanprecompile | kCompAllowDupFileNames | kCompMultiTargAware, + Lang_MISC, + DROPINCOMPILERLINKERAPIVERSION_12 + }; + + *flags = &sFlags; + *flagsSize = sizeof(sFlags); + return 0; +} + +CWPLUGIN_ENTRY (PPCLibImport_GetTargetList)(const CWTargetList **targetList) { + static CWDataType sCPU[1] = {targetCPUPowerPC}; + static CWDataType sOS[1] = {CWFOURCHAR('R','h','a','p')}; + static CWTargetList sTargetList = { + kCurrentCWTargetListVersion, + 1, + sCPU, + 1, + sOS + }; + + *targetList = &sTargetList; + return 0; +} + +CWPLUGIN_ENTRY (PPCLibImport_GetDropInName)(const char **dropinName) { + static const char *sDropInName = "Lib Import Mach-O"; + *dropinName = sDropInName; + return 0; +} + +CWPLUGIN_ENTRY (PPCLibImport_GetDisplayName)(const char **displayName) { + static const char *sDisplayName = "Lib Import Mach-O"; + *displayName = sDisplayName; + return 0; +} + +CWPLUGIN_ENTRY (PPCLibImport_GetDefaultMappingList)(const CWExtMapList **defaultMappingList) { + static CWExtensionMapping sExtension[10] = { + CWFOURCHAR('M','P','L','F'), "", 0, + CWFOURCHAR('M','L','I','B'), "", 0 + }; + static CWExtMapList sExtensionMapList = { + kCurrentCWExtMapListVersion, + 2, + sExtension + }; + + *defaultMappingList = &sExtensionMapList; + return 0; +} + +CWPLUGIN_ENTRY (PPCLibImport_GetPanelList)(const CWPanelList **panelList) { + static CWPanelList sPanelList = { + kCurrentCWPanelListVersion, + 0, + NULL + }; + + *panelList = &sPanelList; + return 0; +} + +static CWPLUGIN_ENTRY (PPCLibImport_GetVersionInfo)(const VersionInfo **versionInfo) { + static const VersionInfo vi = { + 2, 4, 5, 0 + }; + + *versionInfo = &vi; + return 0; +} + +static CWPLUGIN_ENTRY (PPCLibImport_GetFileTypeMappings)(const OSFileTypeMappingList **mappings) { + static const OSFileTypeMapping ftmes[2] = { + CWFOURCHAR('M','P','L','F'), "!arch\n", 8, 0, NULL, + CWFOURCHAR('M','L','I','B'), "\xFE\xED\xFA\xCE", 4, 0, NULL + }; + static const OSFileTypeMappingList ftml = { + 2, ftmes + }; + + *mappings = &ftml; + return 0; +} + +static CWPLUGIN_ENTRY (PPCLibImport_GetObjectFlags)(const CWObjectFlags **objectFlags) { + static const CWObjectFlags sFlags = { + 2, + 0, + NULL, + NULL, + NULL, + ".s", + ".d", + "mch", + 0, 0, + 0, 0, + 0, 0, + CWFOURCHAR('C','W','I','E'), CWFOURCHAR('T','E','X','T'), + 0, 0 + }; + + *objectFlags = &sFlags; + return 0; +} + +static BasePluginCallbacks machlibimport_cb = { + PPCLibImport_main, + PPCLibImport_GetDropInFlags, + PPCLibImport_GetDisplayName, + PPCLibImport_GetDropInName, + PPCLibImport_GetPanelList, + NULL, + NULL, + PPCLibImport_GetVersionInfo, + PPCLibImport_GetFileTypeMappings +}; + +static CompilerLinkerPluginCallbacks machlibimport_cl_cb = { + PPCLibImport_GetTargetList, + PPCLibImport_GetDefaultMappingList, + NULL, + NULL, + PPCLibImport_GetObjectFlags, + NULL +}; + +int RegisterStaticLibImporterPlugin() { + return RegisterStaticCompilerLinkerPlugin(&machlibimport_cb, &machlibimport_cl_cb); +} + +#include "compiler_and_linker/Plugin_Tools/MacOS_PPC/Lib_Importer_Mach/Resources/Errors.r" + +int RegisterLibImporterResources() { + return RegisterResource("Mach-O Lib Importer Errors", 911, STR911); +} diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Static/cc-mach-ppc-mw.c b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Static/cc-mach-ppc-mw.c new file mode 100644 index 0000000..25a9f49 --- /dev/null +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Static/cc-mach-ppc-mw.c @@ -0,0 +1,31 @@ +#include "cmdline.h" + +// cc-mach-ppc.c +extern int RegisterStaticCompilerPlugin(); +extern int RegisterCompilerResources(); +// libimp-mach-ppc.c +extern int RegisterStaticLibImporterPlugin(); +extern int RegisterLibImporterResources(); + +void GetStaticTarget(OSType *cpu, OSType *os) { + *cpu = targetCPUPowerPC; + *os = CWFOURCHAR('R','h','a','p'); +} + +void GetStaticPluginType(OSType *language, OSType *plugintype) { + *language = Lang_C_CPP; + *plugintype = CWDROPINCOMPILERTYPE; +} + +void GetStaticParserPluginType(OSType *style) { + *style = CWFOURCHAR('S','e','e','p'); +} + +int RegisterStaticTargetPlugins() { + return RegisterStaticCompilerPlugin() && RegisterStaticLibImporterPlugin(); +} + +int RegisterStaticTargetResources() { + OS_UseMacResourceForkInfo(1); + return RegisterCompilerResources() && RegisterLibImporterResources(); +} diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Static/ld-mach-ppc-mw.c b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Static/ld-mach-ppc-mw.c new file mode 100644 index 0000000..e69de29 diff --git a/compiler_and_linker/Plugin_Tools/MacOS_PPC/Linker_MacOS_MachPPC/Resources/MachOLinkErrors.r b/compiler_and_linker/Plugin_Tools/MacOS_PPC/Linker_MacOS_MachPPC/Resources/MachOLinkErrors.r new file mode 100644 index 0000000..3a7eb93 --- /dev/null +++ b/compiler_and_linker/Plugin_Tools/MacOS_PPC/Linker_MacOS_MachPPC/Resources/MachOLinkErrors.r @@ -0,0 +1 @@ +// STR11001 \ No newline at end of file diff --git a/includes/cmdline.h b/includes/cmdline.h new file mode 100644 index 0000000..2861794 --- /dev/null +++ b/includes/cmdline.h @@ -0,0 +1,749 @@ +#pragma once + +#include "cw_common.h" +#include "pref_structs.h" + +enum { + CLStr1 = 1, + CLStr2 = 2, + CLStr3 = 3, + CLStr4 = 4, + CLStr5 = 5, + CLStr6 = 6, + CLStr7 = 7, + CLStr8 = 8, + CLStr9 = 9, + CLStr10 = 10, + CLStr11 = 11, + CLStr12 = 12, + CLStr13 = 13, + CLStr14 = 14, + CLStr15 = 15, + CLStr16 = 16, + CLStr17 = 17, + CLStr18 = 18, + CLStr19 = 19, + CLStr20 = 20, + CLStr21 = 21, + CLStr22 = 22, + CLStr23 = 23, + CLStr24 = 24, + CLStr25 = 25, + CLStr26 = 26, + CLStr27 = 27, + CLStr28 = 28, + CLStr29 = 29, + CLStr30 = 30, + CLStr31 = 31, + CLStr32 = 32, + CLStr33 = 33, + CLStr34 = 34, + CLStr35 = 35, + CLStr36 = 36, + CLStr37 = 37, + CLStr38 = 38, + CLStr39 = 39, + CLStr40 = 40, + CLStr41 = 41, + CLStr42 = 42, + CLStr43 = 43, + CLStr44 = 44, + CLStr45 = 45, + CLStr46 = 46, + CLStr47 = 47, + CLStr48 = 48, + CLStr49 = 49, + CLStr50 = 50, + CLStr51 = 51, + CLStr52 = 52, + CLStr53 = 53, + CLStr54 = 54, + CLStr55 = 55, + CLStr56 = 56, + CLStr57 = 57, + CLStr58 = 58, + CLStr59 = 59, + CLStr60 = 60, + CLStr61 = 61, + CLStr62 = 62, + CLStr63 = 63, + CLStr64 = 64, + CLStr65 = 65, + CLStr66 = 66, + CLStr67 = 67, + CLStr68 = 68, + CLStr69 = 69, + CLStr70 = 70, + CLStr71 = 71, + CLStr72 = 72, + CLStr73 = 73, + CLStr74 = 74, + CLStr75 = 75, + CLStr76 = 76, + CLStr77 = 77, + CLStr78 = 78, + CLStr79 = 79, + CLStr80 = 80, + CLStr81 = 81, + CLStr82 = 82, + CLStr83 = 83, + CLStr84 = 84, + CLStr85 = 85, + CLStr86 = 86, + CLStr87 = 87, + CLStr88 = 88, + CLStr89 = 89, + CLStr90 = 90, + CLStr91 = 91, + CLStr92 = 92, + CLStr93 = 93, + CLStr94 = 94, + CLStr95 = 95, + CLStr96 = 96, + CLStr97 = 97, + CLStr98 = 98, + CLStr99 = 99, + CLStr100 = 100, + CLStr101 = 101, + CLStr102 = 102, + CLStr103 = 103, + CLStr104 = 104, + CLStr105 = 105, + CLStr106 = 106, + CLStr107 = 107, + CLStr108 = 108, + CLStr109 = 109, + CLStr110 = 110, + CLStr111 = 111, + CLStr112 = 112 +}; + +#define DO_INTERNAL_ERROR(...) CLInternalError(__FILE__, __LINE__, __VA_ARGS__) + +#ifdef __MWERKS__ +#pragma options align=mac68k +#endif +// TODO fixme +typedef struct CPrepFileInfo { + FSSpec textfile; + void *nameNode; + SInt32 fileModDate; + char *textbuffer; + SInt32 textlength; + SInt32 linenumber; + SInt32 pos; + Boolean hasprepline; + SInt16 fileID; + Boolean recordbrowseinfo; + void *unk; +} CPrepFileInfo; +typedef CPrepFileInfo *CPrepFileInfoStack[]; +#ifdef __MWERKS__ +#pragma options align=reset +#endif + +enum { + OptsCmdLineState_0 = 0, + OptsCmdLineState_1 = 1, + OptsCmdLineState_2 = 2, + OptsCmdLineState_3 = 3 +}; +enum { + OptsCompilerSbmState_0 = 0, + OptsCompilerSbmState_1 = 1, // sbmRebuild? + OptsCompilerSbmState_2 = 2, + OptsCompilerSbmState_3 = 3 // sbmClean? +}; +enum { + CmdLineStage_Cg = 1, + CmdLineStage_Pp = 2, + CmdLineStage_Ds = 3 +}; +enum { + CmdLineStageMask_Pp = 1, + CmdLineStageMask_Cg = 2, + CmdLineStageMask_Ds = 4, + CmdLineStageMask_Dp = 8 +}; + +// Result codes used by various things in CLMain and CLFileOps +enum { + Result_Success = 0, + Result_Failed = 1, + Result_Cancelled = 2 +}; + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct MessageRef { + OSSpec sourcefile; + OSSpec errorfile; + char *sourceline; + SInt32 linenumber; + SInt32 tokenoffset; + SInt16 tokenlength; + SInt32 selectionoffset; + SInt16 selectionlength; +} MessageRef; + +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; + +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; + +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; + +typedef struct Segment { + char name[32]; + UInt16 attrs; +} Segment; + +typedef struct Segments { + Segment **segsArray; + UInt16 arraySize; + UInt16 segsCount; +} Segments; +typedef struct File { + struct File *next; + SInt32 filenum; + UInt16 segnum; + time_t srcmoddate; + time_t 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; + +enum { + LinkModel0 = 0, + LinkModel1 = 1, + LinkModel2 = 2 +}; + +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 Project { + Target *targets; + OSSpec projectDirectory; +} Project; + +enum { + CLStyledMessageDispatch_Type0 = 0, + CLStyledMessageDispatch_Type1 = 1, + CLStyledMessageDispatch_Type2 = 2, + CLStyledMessageDispatch_Type3 = 3, + CLStyledMessageDispatch_Type4 = 4, + CLStyledMessageDispatch_Type5 = 5 +}; + +enum { + IncludeSearch_Type0 = 0, + IncludeSearch_Type1 = 1, + IncludeSearch_Type2 = 2, + IncludeSearch_Type3 = 3, + IncludeSearch_Type4 = 4 +}; + +typedef struct PrefPanel PrefPanel; + +typedef struct Plugin { + BasePluginCallbacks *cb; + CompilerLinkerPluginCallbacks *cl_cb; + ParserPluginCallbacks *pr_cb; + CWPluginContext context; + char *cached_ascii_version; + struct Plugin *next; +} Plugin; + +/********************************/ +/* State */ +typedef struct { + int argc; + 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; + char *stdout_base; + Boolean stdout_written; +} CLState; // assumed name + +extern char cmdline_build_time[32]; +extern char cmdline_build_date[32]; +extern CLState clState; +extern PCmdLineLinker optsLinker; +extern PCmdLineCompiler optsCompiler; +extern PCmdLineEnvir optsEnvir; +extern PCmdLine optsCmdLine; +extern Target *gTarg; +extern Project mainProj; +extern CWCommandLineArgs *plugin_args; +extern CWCommandLineArgs *panel_args; +extern const char **panelNames; +extern int numPanels; +extern CLPluginInfo *pluginInfo; +extern int numPlugins; +extern jmp_buf exit_program; + +/********************************/ +/* Callbacks/CLParserCallbacks_V1.cpp */ +extern int (*PrefPanelsChangedCallback)(const char *); + +/********************************/ +/* Clients/ClientGlue.c */ +extern int RegisterResource(const char *name, SInt16 rsrcid, const char **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, char **argv, const char *builddate, const char *buildtime); +extern int CmdLine_Driver(); +extern int CmdLine_Terminate(int exitcode); + +/********************************/ +/* 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, ...); + +/********************************/ +/* Envir/CLIO.c */ +extern void SetupDebuggingTraps(); +extern Boolean IO_Initialize(); +extern Boolean IO_Terminate(); +extern Boolean IO_HelpInitialize(); +extern Boolean IO_HelpTerminate(); +extern void FixHandleForIDE(Handle text, UInt32 size); +extern Boolean ShowHandle(Handle text, UInt32 size, Boolean decorate); +extern Boolean WriteHandleToFile(OSSpec *spec, Handle text, UInt32 size, OSType creator, OSType type); +extern Boolean WriteBinaryHandleToFile(OSSpec *spec, OSType maccreator, OSType mactype, OSHandle *text); +extern Boolean AppendHandleToFile(OSSpec *spec, Handle text, UInt32 size, OSType maccreator, OSType mactype); +extern void InitWorking(); +extern void ShowWorking(int x); +extern void TermWorking(); +extern Boolean CheckForUserBreak(); +extern char *IO_FormatText(char *buffer, SInt32 size, char *newline, const char *format, ...); +extern void CLPrintDispatch(int unk, SInt16 msgtype, const char *message); +extern void CLPrintType(SInt16 msgtype, const char *format, ...); +extern void CLPrint(const char *format, ...); +extern void CLPrintWarning(const char *format, ...); +extern void CLPrintErr(const char *format, ...); +extern SInt16 CLStyledMessageDispatch(Plugin *plugin, MessageRef *ref, SInt32 errorNumber, SInt16 msgType, const char *format, ...); + +/********************************/ +/* Plugins/CLPlugins.c */ +extern const ToolVersionInfo *Plugin_GetToolVersionInfo(); +extern const char *Plugin_GetDropInName(Plugin *pl); +extern const VersionInfo *Plugin_GetVersionInfo(Plugin *pl); +extern 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); +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, const char **panelNames); +extern Boolean Plugin_CL_WriteObjectFile(Plugin *pl, FSSpec *srcfss, FSSpec *outfss, OSType creator, OSType type, Handle data); +extern Boolean Plugin_CL_GetCompilerMapping(Plugin *pl, OSType type, const char *ext, UInt32 *flags); +extern Plugin *Plugin_New(const BasePluginCallbacks *cb, const CompilerLinkerPluginCallbacks *cl_cb, const ParserPluginCallbacks *pr_cb); +extern void Plugin_Free(Plugin *pl); +extern Boolean 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, const char **panelNames); +extern Plugin *Plugins_GetCompilerForLinker(Plugin *list, Plugin *linker, OSType type, const char *ext, OSType edit); +extern int Plugins_GetPluginList(Plugin *list, int *numPlugins, CLPluginInfo **pluginInfo); +extern int Plugins_GetPrefPanelUnion(Plugin *list, int *numPanels, const char ***panelNames); +extern int Plugin_AddFileTypeMappings(Plugin *pl, OSFileTypeMappings **mlist); +extern int Plugins_AddFileTypeMappingsForTarget(Plugin *list, OSFileTypeMappings **mlist, OSType cpu, OSType os); +extern SInt16 Plugin_Call(Plugin *pl, void *context); + +/********************************/ +/* Project/CLAccessPaths.c */ +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); +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); +extern Boolean Paths_GatherRecurse(Path *path); +extern int Paths_CountRecurse(Paths *paths); +extern void Paths_CopyRecurseFSS(FSSpec *list, Paths *paths, UInt16 count); +extern Boolean MakeFrameworkPath(char *out, const char *filename, Path *globalpath); +extern void Frameworks_AddPath(const OSPathSpec *oss); +extern int Frameworks_AddFramework(const char *name, const char *version, Boolean hidden); +extern void Framework_GetEnvInfo(); +extern int Frameworks_GetCount(); +extern Paths_FWInfo *Frameworks_GetInfo(int which); + +// Not sure if this is the right TU for this +extern Paths FrameworkPaths; + +/********************************/ +/* Project/CLFiles.c */ +extern File *File_New(); +extern void File_Free(File *file); +extern Boolean Files_Initialize(Files *); +extern Boolean Files_Terminate(Files *); +extern Boolean Files_AddFile(Files *, File *file); +extern Boolean Files_InsertFile(Files *, File *file, SInt32 position); +extern File *Files_GetFile(Files *, SInt32 filenum); +extern File *Files_FindFile(Files *, OSSpec *spec); +extern int Files_Count(Files *); +extern Boolean VFiles_Initialize(VFile **list); +extern void VFiles_Terminate(VFile **list); +extern VFile *VFile_New(const char *name, Handle data); +extern Boolean VFiles_Add(VFile **list, VFile *entry); +extern VFile *VFiles_Find(VFile *list, const char *name); + +/********************************/ +/* Project/CLOverlays.c */ +extern Boolean Overlays_Initialize(Overlays *); +extern Boolean Overlays_Terminate(Overlays *); +extern Boolean Overlays_AddOvlGroup(Overlays *, OvlGroup *grp, SInt32 *grpnum); +extern OvlGroup *Overlays_GetOvlGroup(Overlays *, SInt32 grpnum); +extern SInt32 Overlays_CountGroups(Overlays *); +extern Boolean Overlays_AddFileToOverlay(Overlays *, SInt32 grpnum, SInt32 ovlnum, SInt32 filenum); +extern Overlay *Overlays_GetOverlayInGroup(Overlays *, SInt32 grpnum, SInt32 ovlnum); +extern SInt32 Overlays_GetFileInOverlay(Overlays *, 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 *, Overlay *oly, SInt32 *olynum); +extern Overlay *OvlGroup_GetOverlay(OvlGroup *, SInt32 olynum); +extern SInt32 OvlGroup_CountOverlays(OvlGroup *); +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 filnum); +extern SInt32 Overlay_CountFiles(Overlay *oly); + +/********************************/ +/* Project/CLProj.c */ +extern Boolean Proj_Initialize(Project *); +extern Boolean Proj_Terminate(Project *); + +/********************************/ +/* 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); +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); + +/********************************/ +/* CLBrowser.c */ +extern int Browser_Initialize(OSHandle *browsetableptr); +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); +extern int Browser_PackBrowseFile(Handle browsedata, OSHandle *browsetable, OSHandle *browsefileptr); + +/********************************/ +/* CLDependencies.c */ +extern SInt16 *CLT_filesp; +extern CPrepFileInfoStack *CLT_filestack; + +extern Boolean Incls_Initialize(Incls *incls, Target *targ); +extern void Incls_Terminate(Incls *incls); +extern Boolean Incls_FindFileInPaths(Incls *incls, 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(); +extern void Deps_AddDependency(Deps *deps, SInt32 incl, OSSpec *spec, Boolean unk, SInt16 dependencyType, Boolean *alreadyincluded); +extern void Deps_ListDependencies(Incls *incls, File *file, OSHandle *h); + +/********************************/ +/* CLFileOps.c */ +extern int GetOutputFile(File *file, SInt16 stage); +extern int StoreObjectFile(File *file); +extern int CompileFilesInProject(); +extern int LinkProject(); + +/********************************/ +/* CLIncludeFileCache.c */ +extern void InitializeIncludeCache(); +extern void CleanupIncludeCache(); +extern void CacheIncludeFile(OSSpec *spec, Handle text, Boolean precompiled); +extern Handle CachedIncludeFile(OSSpec *spec, Boolean *precompiled); +extern void FreeIncludeFile(Handle text); + +/********************************/ +/* 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(); + +/********************************/ +/* CLLoadAndCache.c */ +extern short FixTextHandle(Handle txt); +extern int LoadAndCacheFile(OSSpec *spec, Handle *texthandle, Boolean *precomp); +extern void CopyFileText(Handle src, char **text, SInt32 *textsize); + +/********************************/ +/* CLMain.c */ +extern void Main_PreParse(int *argc, char ***argv); +extern void Main_PassSpecialArgs(int *argc, char ***argv); +extern int Main_Initialize(int argc, char **argv); +extern int Main_Terminate(int code); +extern int Main_Driver(); + +/********************************/ +/* 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, + const 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); + +/********************************/ +/* 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 data); +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, 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); + +/********************************/ +/* CLToolExec.c */ +extern void AppendArgumentList(int *argc, char ***argv, const char *str); +extern int SetupTemporaries(); +extern int DeleteTemporaries(); +extern int ExecuteLinker(Plugin *plugin, SInt32 dropinflags, File *file, char *stdoutfile, char *stderrfile); + +/********************************/ +/* CLWriteObjectFile.c */ +extern int WriteObjectFile(File *file, OSType maccreator, OSType mactype); +extern int WriteBrowseData(File *file, OSType maccreator, OSType mactype); + +/********************************/ +/* Unknown name - provisionally named uFileTypeMappings.c */ +extern void AddFileTypeMappingList(OSFileTypeMappings **list, const OSFileTypeMappingList *entry); +extern void UseFileTypeMappings(OSFileTypeMappings *list); +extern OSErr SetMacFileType(const FSSpec *spec, OSType mactype); +extern OSErr GetMacFileType(const FSSpec *spec, OSType *mactype); + +#ifdef __cplusplus +} +#endif diff --git a/includes/common.h b/includes/common.h index 760be22..b1b5b61 100644 --- a/includes/common.h +++ b/includes/common.h @@ -24,6 +24,8 @@ #define va_arg(a,b) (*(b *) (void *) ((a = (char *) (((((unsigned long)(a)) + ((__alignof__ (b) == 16) ? 15 : 3)) & ~((__alignof__ (b) == 16) ? 15 : 3)) + ((sizeof (b) + 3) & ~3))) - ((sizeof (b) + 3) & ~3))) #define va_end(a) ((void)0) +#define alloca(x) __alloca(x) + #else #include // expand this to nothing @@ -34,13 +36,13 @@ // MacTypes.h #ifdef __MWERKS__ typedef unsigned char UInt8; -typedef signed char SInt8; +typedef char SInt8; typedef unsigned short UInt16; -typedef signed short SInt16; +typedef short SInt16; typedef unsigned long UInt32; -typedef signed long SInt32; +typedef long SInt32; typedef unsigned long long UInt64; -typedef signed long long SInt64; +typedef long long SInt64; typedef long Size; #else diff --git a/includes/cos.h b/includes/cos.h new file mode 100644 index 0000000..777b380 --- /dev/null +++ b/includes/cos.h @@ -0,0 +1,41 @@ +#pragma once + +#include "common.h" + +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(StringPtr buffer, SInt16 strListID, SInt16 index); +extern Boolean COS_IsMultiByte(const char *str, int offset); +extern OSErr COS_FileNew(const FSSpec *spec, SInt16 *refNum, OSType creator, OSType fileType); +extern OSErr COS_FileOpen(const FSSpec *spec, SInt16 *refNum); +extern OSErr COS_FileGetType(const FSSpec *spec, OSType *fileType); +extern OSErr COS_FileGetSize(SInt16 refNum, SInt32 *logEOF); +extern OSErr COS_FileRead(SInt16 refNum, void *buffPtr, SInt32 count); +extern OSErr COS_FileWrite(SInt16 refNum, const void *buffPtr, SInt32 count); +extern OSErr COS_FileGetPos(SInt16 refNum, SInt32 *filePos); +extern OSErr COS_FileSetPos(SInt16 refNum, SInt32 filePos); +extern OSErr COS_FileClose(SInt16 refNum); +extern void COS_FileSetFSSpec(FSSpec *spec, ConstStringPtr path); +extern OSErr COS_FileMakeFSSpec(SInt16 vRefNum, SInt32 dirID, ConstStringPtr fileName, FSSpec *spec); +extern OSErr COS_FileMakeFSSpecWithPath(const FSSpec *inputSpec, ConstStringPtr fileName, FSSpec *spec); +extern OSErr COS_FileGetFileInfo(const FSSpec *spec, OSType *creator, OSType *fileType); +extern void COS_FileGetFSSpecInfo(const FSSpec *spec, SInt16 *vRefNum, SInt32 *dirID, StringPtr fileName); +extern void COS_FileGetPathName(char *buffer, const FSSpec *spec, SInt32 *mdDat); +extern int COS_EqualFileSpec(const FSSpec *a, const FSSpec *b); diff --git a/includes/cw_common.h b/includes/cw_common.h new file mode 100644 index 0000000..bea498a --- /dev/null +++ b/includes/cw_common.h @@ -0,0 +1,43 @@ +#pragma once + +/* + * Things that seem to be shared across different CodeWarrior modules + */ + +#include "common.h" +#include "oslib.h" +#include "macemul.h" +#include "plugin.h" + +typedef struct VersionInfo { + UInt16 major; + UInt16 minor; + UInt16 patch; + UInt16 build; +} VersionInfo; + +typedef struct BasePluginCallbacks { + CWPLUGIN_ENTRY (*main)(CWPluginContext context); + CWPLUGIN_ENTRY (*GetDropInFlags)(const DropInFlags **flags, SInt32 *flagsSize); + CWPLUGIN_ENTRY (*GetDisplayName)(const char **displayName); + CWPLUGIN_ENTRY (*GetDropInName)(const char **dropInName); + CWPLUGIN_ENTRY (*GetPanelList)(const CWPanelList **panelList); + CWPLUGIN_ENTRY (*GetFamilyList)(const CWFamilyList **familyList); + CWPLUGIN_ENTRY (*GetHelpInfo)(const CWHelpInfo **helpInfo); + CWPLUGIN_ENTRY (*GetVersionInfo)(const VersionInfo **versionInfo); + CWPLUGIN_ENTRY (*GetFileTypeMappings)(const OSFileTypeMappingList **mappingList); +} BasePluginCallbacks; + +typedef struct CompilerLinkerPluginCallbacks { + CWPLUGIN_ENTRY (*GetTargetList)(const struct CWTargetList **targetList); + CWPLUGIN_ENTRY (*GetDefaultMappingList)(const CWExtMapList **mappings); + CWPLUGIN_ENTRY (*Unmangle)(); + CWPLUGIN_ENTRY (*BrSymbolEntryPoint)(); + CWPLUGIN_ENTRY (*GetObjectFlags)(const CWObjectFlags **objectFlags); + CWPLUGIN_ENTRY (*WriteObjectFile)(const FSSpec *srcfss, const FSSpec *outfss, OSType creator, OSType type, Handle data); +} CompilerLinkerPluginCallbacks; + +typedef struct ParserPluginCallbacks { + CWPLUGIN_ENTRY (*SupportsPlugin)(const CLPluginInfo *pluginfo, OSType cpu, OSType os, Boolean *isSupported); + CWPLUGIN_ENTRY (*SupportsPanels)(int numPanels, const char **panelNames, Boolean *isSupported); +} ParserPluginCallbacks; diff --git a/includes/macemul.h b/includes/macemul.h index 4d0e502..dbc4765 100644 --- a/includes/macemul.h +++ b/includes/macemul.h @@ -110,7 +110,7 @@ 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 OSErr FSpOpenResFile(const FSSpec *spec, SInt8 permission); extern SInt16 HOpenResFile(SInt16 vRefNum, SInt32 dirID, ConstStringPtr fileName, SInt8 permission); extern SInt16 CurResFile(); extern void UseResFile(SInt16 refNum); @@ -146,7 +146,7 @@ extern Boolean LMGetResLoad(); /********************************/ /* ResourceStrings */ extern void Res_Initialize(); -extern int Res_AddResource(const char *name, SInt16 rsrcid, Handle strings); +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(); diff --git a/includes/mwcc_decomp.h b/includes/mwcc_decomp.h index c5fa000..a898422 100644 --- a/includes/mwcc_decomp.h +++ b/includes/mwcc_decomp.h @@ -10,860 +10,10 @@ extern "C" { #endif -#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; - -#ifdef __MWERKS__ -#pragma options align=reset -#endif - - -// Pref panels -#ifdef __MWERKS__ -#pragma options align=mac68k -#endif -enum { - OptsCmdLineState_0 = 0, - OptsCmdLineState_1 = 1, - OptsCmdLineState_2 = 2, - OptsCmdLineState_3 = 3 -}; -enum { - CmdLineStage_Cg = 1, - CmdLineStage_Pp = 2, - CmdLineStage_Ds = 3 -}; -enum { - CmdLineStageMask_Pp = 1, - CmdLineStageMask_Cg = 2, - CmdLineStageMask_Ds = 4, - CmdLineStageMask_Dp = 8 -}; -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; - UInt16 maxErrors; - UInt16 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; - -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;*/ -#ifdef __MWERKS__ -#pragma options align=reset -#endif - -// may not actually be named this -struct ParseOptsType { - struct CWPluginPrivateContext *context; - char helpKey[64]; - SInt32 helpFlags; - UInt16 ioCols; - UInt16 ioRows; - CWCommandLineArgs *args; - const ToolVersionInfo *toolVersion; - int numPlugins; - const CLPluginInfo *plugins; - int numPanels; - const 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; - 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; - char *stdout_base; - int stdout_written; -} CLState; // assumed name - -typedef struct BasePluginCallbacks { - SInt16 (*main)(CWPluginContext 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; - struct OptionList **optionLists; - int numPrefDataPanels; - PrefDataPanel *prefDataPanels; - int (*PreParse)(); - int (*MidParse)(); - int (*PostParse)(); -} 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, const char **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 *argc, char ***argv); -extern void Main_PassSpecialArgs(int *argc, char ***argv); -extern int Main_Initialize(int argc, 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 int Plugins_GetPluginList(Plugin *list, int *numPlugins, CLPluginInfo **pluginInfo); -extern int Plugins_GetPrefPanelUnion(Plugin *list, int *numPanels, char ***panelNames); -extern int Plugin_AddFileTypeMappings(Plugin *pl, OSFileTypeMappingList *ftml); -extern int 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(const char *format, ...); -extern void CLPrintWarning(const char *format, ...); -extern void CLPrintErr(const char *format, ...); -extern SInt16 CLStyledMessageDispatch(Plugin *plugin, MessageRef *ref, SInt32 errorNumber, SInt16 msgType); - -/********************************/ -/* command_line/CmdLine/Src/CLToolExec.c */ -extern void AppendArgumentList(int *argc, 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(); -extern int DeleteTemporaries(); -extern int ExecuteLinker(Plugin *plugin, SInt32 dropinflags, File *file, char *stdoutfile, char *stderrfile); - -/********************************/ -/* command_line/CmdLine/Src/Project/CLProj.c */ -typedef struct Project { - Target *targets; - OSSpec projectDirectory; -} Project; -#ifndef __cplusplus -extern int Proj_Initialize(Project *this); -extern int Proj_Terminate(Project *this); -#endif - -/********************************/ -/* 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/CLPluginRequests.cpp */ -extern Boolean SendParserRequest( - Plugin *plugin, - Target *target, - CWCommandLineArgs *args, - OSType cpu, - OSType os, - int numPlugins, - CLPluginInfo *pluginInfo, - int numPanels, - char **panelNames, - CWCommandLineArgs *plugin_args, - CWCommandLineArgs *panel_args, - const char *build_date, - const char *build_time, - const 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 void Frameworks_AddPath(const OSPathSpec *oss); -extern int 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); - /********************************/ /* ??? */ extern int AddFileTypeMappingList(void *a, void *b); // TODO sig @@ -871,118 +21,6 @@ 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 */ -#ifndef __cplusplus -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); -#endif - -/********************************/ -/* command_line/CmdLine/Src/Project/CLOverlays.c */ -#ifndef __cplusplus -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); -#endif - -/********************************/ -/* 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/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); @@ -997,21 +35,6 @@ 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(); @@ -1045,6 +68,7 @@ extern int DisplayWarningOptions(); /********************************/ /* CCompiler.c */ +extern CWPLUGIN_ENTRY(MWC_main)(CWPluginContext context); // LOTS OF STUFF @@ -1053,242 +77,6 @@ extern int DisplayWarningOptions(); extern int RegisterStaticParserPlugins(); extern int RegisterStaticParserResources(); -/********************************/ -/* ParserFace.c */ -extern Handle Parser_FindPrefPanel(const 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, const char **panelNames, Boolean *isSupported); -extern SInt16 parser_main(struct CWPluginPrivateContext *context); - -extern const char *failedCallback; -extern jmp_buf exit_plugin; -extern struct ParseOptsType parseopts; - -/********************************/ -/* ParserHelpers.c */ -extern SInt16 lastStage; - -extern int FindFileInPath(const char *filename, OSSpec *fss); -extern char *GetEnvVar(const char *name, Boolean warn, const char **match); -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 *, va_list), const char *envvar, SInt16 id, ...); -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 */ -enum { - OutputOrdering0 = 0, - OutputOrdering1 = 1, - OutputOrdering2 = 2 -}; -extern SInt16 outputOrdering; -extern Boolean setOutputDirectory; - -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, int err, ...); -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, int flags); -extern int Opt_RedirectStream(const char *opt, void *file, const char *filename); - -/********************************/ -/* ParserHelpers-cc.c */ -extern Handle definesHandle; - -enum { - PRAGMA_FLAGS_0, - PRAGMA_FLAGS_1 -}; -enum { - PR_UNSET = 0, // this is the only one we know the name of (from asserts) - PR_ON = 1, - PR_OFF = 2, - PR_AUTO = 3, - PR_RESET = 4 -}; - -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); - -/********************************/ -/* 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(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(OSPathSpec *dir); -extern void AddOverlayGroup(const char *name, CWAddr64 *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 ParserTool *pTool; - -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(); - -/********************************/ -/* 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 char *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"... -#ifdef UNSIGNED_CHAR_FOR_MY_UTILS -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); -#else -extern int my_tolower(char c); -extern int my_isdigit(char c); -extern int my_isalpha(char c); -extern int my_isalnum(char c); -extern int my_isxdigit(char c); -#endif -extern char *Utils_SpellList(char *list, char *buffer, char opts); -extern int Utils_CompareOptionString(const char *a, const char *b, int cased, int sticky); - -/********************************/ -/* */ - -/********************************/ -/* */ - -/********************************/ -/* ?? 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); - -#include "option_system.h" - - -// TODO sort me -extern Project *gProj; -extern PCmdLine optsCmdLine; -extern PCmdLineEnvir optsEnvir; -extern PCmdLineCompiler optsCompiler; -extern PCmdLineLinker optsLinker; -extern CLState clState; - /********************************/ /* CmdLineBuildDate.c */ extern char CMDLINE_BUILD_DATE[]; @@ -1300,17 +88,6 @@ extern char CMDLINE_BUILD_TIME[]; 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; -extern anon0_50 prelinkargs; -extern anon0_50 postlinkargs; -extern PCmdLine pCmdLine; -extern PCmdLineCompiler pCmdLineCompiler; #ifdef __cplusplus } diff --git a/includes/option_system.h b/includes/option_system.h index 521213b..aa519e2 100644 --- a/includes/option_system.h +++ b/includes/option_system.h @@ -4,7 +4,7 @@ #ifdef __cplusplus extern "C" { #endif -#ifdef __MWERKS__ +#ifdef __MWERKS__ #pragma options align=packed #endif enum { @@ -171,7 +171,7 @@ enum { }; enum { OTF_GLOBAL = 1, - OTF2 = 2, + OTF_STICKY = 2, OTF_CASED = 4, OTF_OBSOLETE = 8, OTF_SUBSTITUTED = 0x10, @@ -182,16 +182,14 @@ enum { 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_HIDE_DEFAULT = 0x2000, OTF_COMPATIBILITY = 0x4000, - OTF8000 = 0x8000, - OTF10000 = 0x10000, - OTF20000 = 0x20000, - OTF40000 = 0x40000, + OTF_HAS_SUB_OPTIONS = 0x8000, + OTF_SUB_OPTIONS_OPTIONAL = 0x10000, + OTF_ONLY_ONCE = 0x20000, + OTF_HAS_CONFLICTS = 0x40000, OTF_WARNING = 0x80000, OTF_SLFLAGS_8 = 0x100000, OTF_SLFLAGS_10 = 0x200000, @@ -205,8 +203,8 @@ enum { OTF8000000 = 0x8000000, OTF10000000 = 0x10000000, OTF20000000 = 0x20000000, - OTF40000000 = 0x40000000, - OTF80000000 = 0x80000000 + OTF_INTERNAL_SEEN_CONFLICTED = 0x40000000, + OTF_INTERNAL_ALREADY_SEEN = 0x80000000 }; enum { @@ -260,7 +258,8 @@ enum { }; enum { LISTFLAGS_NONE = 0, - LISTFLAGS_2 = 2, + LISTFLAGS_EXCLUSIVE = 1, + LISTFLAGS_ALLOW_UNKNOWNS = 2, LISTFLAGS_4 = 4, LISTFLAGS_COMPILER = 0x100, LISTFLAGS_LINKER = 0x200, @@ -288,7 +287,7 @@ enum { PFLAGS_40 = 0x40, PFLAGS_80 = 0x80 }; -#ifdef __MWERKS__ +#ifdef __MWERKS__ #pragma options align=reset #endif @@ -299,12 +298,12 @@ typedef struct { char *text; } ArgToken; enum { - ATK_0, - ATK_1, - ATK_2, - ATK_3, - ATK_4, - ATK_5 + ATK_END, + ATK_ARG_END, + ATK_ARG, + ATK_OPTION, + ATK_EQUALS, + ATK_COMMA }; typedef struct { int argc; @@ -312,6 +311,20 @@ typedef struct { char **argv; } anon0_50; +extern char compat; +extern char *MAINOPTCHAR; +extern char *FIRSTARGCHAR; +extern char *SEPOPTSTR; +extern char SEPOPTCHAR; +extern char SEP1; +extern char SEP2; +extern char SEP3; +extern char RESPFILECHAR; +extern char *RESPFILESTR; +extern anon0_50 linkargs; +extern anon0_50 prelinkargs; +extern anon0_50 postlinkargs; + extern void Arg_Init(int theargc, char **theargv); extern void Arg_Terminate(); extern void Arg_Reset(); @@ -348,10 +361,9 @@ typedef struct { } 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 char curopt[1024]; + extern void Args_InitStack(); extern int Args_StackSize(); extern void Args_Push(SInt16 flags, void *first, void *second); @@ -361,23 +373,14 @@ 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); @@ -392,6 +395,8 @@ extern int Options_DisplayHelp(); /********************************/ /* Parameter.c */ +extern char curparam[4096]; + 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); @@ -400,8 +405,8 @@ 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 int Help_Option(OptionList *lst, Option *opt, int subprint, const char *keyword); +extern void Help_Options(OptionList *lst, int subprint, const char *keyword); extern void Help_Usage(); extern void Help_Null(); extern void Help_Init(); diff --git a/includes/oslib.h b/includes/oslib.h index 22e8ddc..dfa3827 100644 --- a/includes/oslib.h +++ b/includes/oslib.h @@ -7,6 +7,8 @@ * OS abstraction layer */ +#define OPTION_ASSERT(cond) do { if (!!(cond) == 0) { printf("%s:%u: failed assertion\n", __FILE__, __LINE__); abort(); } } while(0) + typedef struct uOSTypePair { int perm; } uOSTypePair; // unknown name @@ -73,13 +75,17 @@ typedef struct OSFileTypeMappingList { } OSFileTypeMappingList; typedef struct OSFileTypeMappings { - OSFileTypeMappingList *mappingList; + const OSFileTypeMappingList *mappingList; struct OSFileTypeMappings *next; } OSFileTypeMappings; #ifdef __MWERKS__ #pragma options align=reset #endif +#ifdef __cplusplus +extern "C" { +#endif + /********************************/ /* Generic */ extern int WildCardMatch(char *wild, char *name); @@ -128,7 +134,7 @@ extern int OS_IsLegalPath(const char *path); extern int OS_IsFullPath(const char *path); extern char *OS_GetDirPtr(char *path); extern int OS_EqualPath(const char *a, const char *b); -extern int OS_CanonPath(char *src, char *dst); +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); @@ -168,7 +174,7 @@ 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); +extern Boolean OS_IsMultiByte(const char *str, int offset); /********************************/ /* FileHandles */ @@ -180,7 +186,7 @@ extern void OS_GetFileHandleSpec(const OSFileHandle *hand, OSSpec *spec); /********************************/ /* MacFileTypes */ -extern void OS_AddFileTypeMappingList(OSFileTypeMappings **list, OSFileTypeMappingList *entry); +extern void OS_AddFileTypeMappingList(OSFileTypeMappings **list, const 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); @@ -226,3 +232,7 @@ 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, ...); + +#ifdef __cplusplus +} +#endif diff --git a/includes/parser.h b/includes/parser.h new file mode 100644 index 0000000..ae28fee --- /dev/null +++ b/includes/parser.h @@ -0,0 +1,370 @@ +#pragma once + +#include "cw_common.h" +#include "pref_structs.h" +#include "option_system.h" + +enum { + PRAGMA_FLAGS_0, + PRAGMA_FLAGS_1 +}; +enum { + PR_UNSET = 0, // this is the only one we know the name of (from asserts) + PR_ON = 1, + PR_OFF = 2, + PR_AUTO = 3, + PR_RESET = 4 +}; + +typedef struct { + void *value; + const char *pragma; + int flags; +} Pragma; // assumed name + +enum { + CLPStr0 = 0, + CLPStr1 = 1, + CLPStr2 = 2, + CLPStr3 = 3, + CLPStr4 = 4, + CLPStr5 = 5, + CLPStr6 = 6, + CLPStr7 = 7, + CLPStr8 = 8, + CLPStr9 = 9, + CLPStr10 = 10, + CLPStr11 = 11, + CLPStr12 = 12, + CLPStr13 = 13, + CLPStr14 = 14, + CLPStr15 = 15, + CLPStr16 = 16, + CLPStr17 = 17, + CLPStr18 = 18, + CLPStr19_UnknownOptionX = 19, + CLPStr20_UnknownOptionX_ExpectedOneOfX = 20, + CLPStr21_OptionObsolete = 21, + CLPStr22_OptionObsoleteWithHelp = 22, + CLPStr23_OptionXSubstitutedWithX = 23, + CLPStr24_OptionDeprecated = 24, + CLPStr25_OptionDeprecatedWithHelp = 25, + CLPStr26_OptionIgnored = 26, + CLPStr27_OptionIgnoredWithText = 27, + CLPStr28_WarningText = 28, + CLPStr29_OptionHasNoEffect = 29, + CLPStr30_OptionShouldNotBeSpecifiedMultipleTimes = 30, + CLPStr31_OptionOverridesEffect = 31, + CLPStr32_OptionOverridesEffectWithHelp = 32, + CLPStr33_NoDefaultHandlerSetUpForX_Ignoring = 33, + CLPStr34_ArgumentsExpected = 34, + CLPStr35_TokenXNotExpected = 35, + CLPStr36_UnexpectedAdditionalArgumentX = 36, + CLPStr37 = 37, + CLPStr38_NoHelpAvailableForOptionX = 38, + CLPStr39 = 39, + CLPStr40 = 40, + CLPStr41 = 41, + CLPStr42 = 42, + CLPStr43 = 43, + CLPStr44 = 44, + CLPStr45 = 45, + CLPStr46 = 46, + CLPStr47 = 47, + CLPStr48 = 48, + CLPStr49 = 49, + CLPStr50 = 50, + CLPStr51 = 51, + CLPStr52 = 52, + CLPStr53 = 53, + CLPStr54 = 54, + CLPStr55 = 55, + CLPStr56 = 56, + CLPStr57 = 57, + CLPStr58 = 58, + CLPStr59 = 59, + CLPStr60 = 60, + CLPStr61 = 61, + CLPStr62 = 62, + CLPStr63 = 63, + CLPStr64 = 64, + CLPStr65 = 65, + CLPStr66 = 66, + CLPStr67 = 67, + CLPStr68 = 68, + CLPStr69 = 69, + CLPStr70 = 70, + CLPStr71 = 71, + CLPStr72 = 72, + CLPStr73 = 73, + CLPStr74 = 74, + CLPStr75 = 75, + CLPStr76 = 76, + CLPStr77 = 77, + CLPStr78 = 78 +}; + +// State + +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)(); + int (*MidParse)(); + int (*PostParse)(); +} ParserTool; // assumed name + +typedef struct { + struct CWPluginPrivateContext *context; + char helpKey[64]; + SInt32 helpFlags; + UInt16 ioCols; + UInt16 ioRows; + CWCommandLineArgs *args; + const ToolVersionInfo *toolVersion; + int numPlugins; + const CLPluginInfo *plugins; + int numPanels; + const 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]; +} ParseOptsType; // assumed name + +#ifdef __cplusplus +extern "C" { +#endif + +/********************************/ +/* IO.c */ +extern void ShowTextHandle(const char *description, Handle text); +extern void ShowVersion(Boolean decorate); + +/********************************/ +/* OptimizerHelpers.c */ +extern Pragma irPragmas[]; + +extern int SetPragmaOptimizationsToUnspecified(const char *opt, void *, const char *, int); +extern int SetOptFlags(const char *opt, void *str, const char *, int flags); +extern int DisplayOptimizationOptions(); + +/********************************/ +/* 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 char *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, ...); + +/********************************/ +/* ParserFace.c */ +extern const char *failedCallback; +extern jmp_buf exit_plugin; +extern ParseOptsType parseopts; + +extern Handle Parser_FindPrefPanel(const char *name); +extern SInt32 Parser_StorePanels(struct CWPluginPrivateContext *context); +extern CWPLUGIN_ENTRY (CWParser_GetDropInFlags)(const DropInFlags **flags, SInt32 *flagsSize); +extern CWPLUGIN_ENTRY (CWParser_GetDropInName)(const char **dropinName); +extern CWPLUGIN_ENTRY (CWParser_GetDisplayName)(const char **displayName); +extern CWPLUGIN_ENTRY (CWParser_GetPanelList)(const CWPanelList **panelList); +extern CWPLUGIN_ENTRY (CWParser_GetTargetList)(const CWTargetList **targetList); +extern CWPLUGIN_ENTRY (CWParser_GetVersionInfo)(const VersionInfo **versioninfo); +extern CWPLUGIN_ENTRY (Parser_SupportsPlugin)(const struct CLPluginInfo *pluginfo, OSType cpu, OSType os, Boolean *isSupported); +extern CWPLUGIN_ENTRY (Parser_SupportsPanels)(int numPanels, const char **panelNames, Boolean *isSupported); +extern CWPLUGIN_ENTRY (parser_main)(struct CWPluginPrivateContext *context); + +/********************************/ +/* ParserGlue-mach-ppc-c.c */ +extern PCmdLine pCmdLine; +extern PCmdLineCompiler pCmdLineCompiler; +extern PCmdLineLinker pCmdLineLinker; +extern PFrontEndC pFrontEndC; +extern PWarningC pWarningC; +extern PGlobalOptimizer pGlobalOptimizer; +extern PBackEnd pBackEnd; +extern PDisassembler pDisassembler; +extern PMachOLinker pLinker; +extern PMachOProject pMachOProject; +extern PCLTExtras pCLTExtras; + +/********************************/ +/* ParserHelpers.c */ +extern SInt16 lastStage; +extern Boolean dashIMinusMovesPaths; +extern Boolean usedDashIMinus; +extern Boolean namingSysPaths; + +extern int FindFileInPath(const char *filename, OSSpec *fss); +extern char *GetEnvVar(const char *name, Boolean warn, const char **match); +extern int Opt_AddAccessPath(const char *opt, void *var, const char *arg, int flags); +extern int Opt_AddFrameworkPath(const char *opt, void *var, const char *arg, int flags); +extern int Opt_AddFramework(const char *opt, void *var, const char *arg, int flags); +extern void ListParseMessage(void (*errprint)(const char *, va_list), const char *envvar, SInt16 id, ...); +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, int flags); +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, int flags); +extern void GetFirstSourceFilenameBase(char *buffer, char *defaul); +extern int Opt_SavePrefs(const char *opt, void *var, const char *arg, int flags); +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, int flags); + +/********************************/ +/* ParserHelpers-cc.c */ +extern Handle definesHandle; + +extern int Opt_AddStringToDefines(const char *opt, void *str, const char *param, int flags); +extern int Opt_DefineSymbol(const char *var, const char *value); +extern int Opt_UndefineSymbol(const char *opt, void *, const char *arg, int flags); +extern int Opt_AddPrefixFile(const char *opt, void *handle, const char *filename, int flags); +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); + +/********************************/ +/* 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(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(OSPathSpec *dir); +extern void AddOverlayGroup(const char *name, CWAddr64 *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); + +/********************************/ +/* TargetOptimizer-ppc-mach.c */ +extern char schedule_ppc_default; + +extern int TargetSetOptFlags(short val, Boolean set); +extern void TargetDisplayOptimizationOptions(Handle txt); +extern void TargetSetPragmaOptimizationsToUnspecified(); + +/********************************/ +/* TargetWarningHelpers-ppc-cc.c */ +extern Pragma warningPragmas[]; + +extern int TargetSetWarningFlags(short val, Boolean set); +extern void TargetDisplayWarningOptions(Handle txt); + +/********************************/ +/* Targets.c */ +extern ParserTool *pTool; + +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(); + +/********************************/ +/* ToolHelpers.c */ +enum { + OutputOrdering0 = 0, + OutputOrdering1 = 1, + OutputOrdering2 = 2 +}; +extern char linkerOutputFilename[256]; +extern Boolean setLinkerOutputFilename; +extern Boolean setOutputDirectory; +extern SInt16 outputOrdering; + +extern int Opt_HandleOutputName(const char *opt, void *, const char *filename, int flags); +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, int err, ...); +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, int flags); +extern int Opt_SetStage(const char *opt, void *str, const char *arg, int flags); +extern int Opt_RedirectStream(const char *opt, void *file, const char *filename); + +/********************************/ +/* ToolHelpers-cc.c */ +extern int Opt_DummyLinkerRoutine(const char *opt, void *, const char *, int); +extern int Opt_DummyLinkerSettingRoutine(const char *var, const char *val); +extern void FinishCompilerTool(); + +/********************************/ +/* Utils.c */ +extern int my_tolower(char c); +extern int my_isdigit(char c); +extern int my_isalpha(char c); +extern int my_isalnum(char c); +extern int my_isxdigit(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); + +/********************************/ +/* WarningHelpers.c */ +extern int SetWarningFlags(const char *opt, void *str, const char *, int flags); +extern int DisplayWarningOptions(); + +#ifdef __cplusplus +extern "C" } +#endif diff --git a/includes/plugin.h b/includes/plugin.h index 76b17cc..3341c82 100644 --- a/includes/plugin.h +++ b/includes/plugin.h @@ -16,7 +16,18 @@ #endif enum { - CWDROPINPARSERTYPE = CWFOURCHAR('P','a','r','s') + CWDROPINPARSERTYPE = CWFOURCHAR('P','a','r','s'), + CWDROPINDRIVERTYPE = CWFOURCHAR('c','l','d','r'), + CWDROPINANYTYPE = CWFOURCHAR('*','*','*','*') +}; + +// Extra drop-in flags that aren't in the public plugin SDK headers +enum { + dropInExecutableTool = 1 +}; + +enum { + Lang_Any = CWFOURCHAR('*','*','*','*') }; typedef struct IDEAccessPath { @@ -36,6 +47,7 @@ typedef struct IDEAccessPathList { } IDEAccessPathList; enum { + cwAccessPathTypeFlag1 = 1, cwAccessPathTypeFlag2 = 2 }; typedef struct CWNewAccessPathInfo { @@ -77,6 +89,27 @@ typedef struct ToolVersionInfo { char *version; } ToolVersionInfo; +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 CLPluginInfo { OSType plugintype; OSType language; @@ -154,7 +187,7 @@ struct CWCompilerLinkerCallbacks { struct CWParserCallbacks { CWResult (*cbParserAddAccessPath)(CWPluginContext, const CWNewAccessPathInfo *); CWResult (*cbParserSwapAccessPaths)(CWPluginContext); - CWResult (*cbParserSetNamedPreferences)(CWPluginContext, const char *, CWMemHandle); + CWResult (*cbParserSetNamedPreferences)(CWPluginContext, const char *, Handle); CWResult (*cbParserSetFileOutputName)(CWPluginContext, SInt32, short, const char *); CWResult (*cbParserSetOutputFileDirectory)(CWPluginContext, const CWFileSpec *); CWResult (*cbParserAddOverlay1Group)(CWPluginContext, const char *, const CWAddr64 *, SInt32 *); @@ -172,6 +205,10 @@ extern "C" { #endif CW_CALLBACK CWCheckoutLicense(CWPluginContext context, const char *a, const char *b, SInt32 c, void *d, SInt32 *cookiePtr); CW_CALLBACK CWCheckinLicense(CWPluginContext context, SInt32 cookie); + +CW_CALLBACK CWOSErrorMessage(CWPluginContext context, const char *msg, OSErr errorcode); +CW_CALLBACK CWOSAlert(CWPluginContext context, const char* message, OSErr errorcode); + CW_CALLBACK CWSecretAttachHandle(CWPluginContext context, Handle handle, CWMemHandle *memHandle); CW_CALLBACK CWSecretDetachHandle(CWPluginContext context, CWMemHandle memHandle, Handle *handle); CW_CALLBACK CWSecretPeekHandle(CWPluginContext context, CWMemHandle memHandle, Handle *handle); @@ -187,7 +224,7 @@ CW_CALLBACK CWParserStoreCommandLineForPanel(CWPluginContext context, int index, CW_CALLBACK CWParserStoreCommandLineForPlugin(CWPluginContext context, int index, const CWCommandLineArgs *args); CW_CALLBACK CWParserAddAccessPath(CWPluginContext context, const CWNewAccessPathInfo *api); CW_CALLBACK CWParserSwapAccessPaths(CWPluginContext context); -CW_CALLBACK CWParserSetNamedPreferences(CWPluginContext context, const char *panelName, CWMemHandle paneldata); +CW_CALLBACK CWParserSetNamedPreferences(CWPluginContext context, const char *panelName, Handle paneldata); CW_CALLBACK CWParserSetFileOutputName(CWPluginContext context, SInt32 position, short which, const char *outfilename); CW_CALLBACK CWParserSetOutputFileDirectory(CWPluginContext context, const CWFileSpec *idefss); CW_CALLBACK CWParserAddOverlay1Group(CWPluginContext context, const char *name, const CWAddr64 *addr, SInt32 *newGroupNumber); @@ -196,6 +233,86 @@ CW_CALLBACK CWParserAddSegment(CWPluginContext context, const char *name, short CW_CALLBACK CWParserSetSegment(CWPluginContext context, SInt32 segmentNumber, const char *name, short attrs); CW_CALLBACK CWParserCreateVirtualFile(CWPluginContext context, const char *name, CWMemHandle text); CW_CALLBACK CWParserDisplayTextHandle(CWPluginContext context, const char *name, CWMemHandle text); + +// CLDropinCallbacks +extern CWResult UCBGetFileInfo(CWPluginContext context, SInt32 whichfile, Boolean checkFileLocation, CWProjectFileInfo *fileinfo); +extern CWResult UCBFindAndLoadFile(CWPluginContext context, const char *filename, CWFileInfo *fileinfo); +extern CWResult UCBGetFileText(CWPluginContext context, const CWFileSpec *filespec, const char **text, SInt32 *textLength, short *filedatatype); +extern CWResult UCBReleaseFileText(CWPluginContext context, const char *text); +extern CWResult UCBGetSegmentInfo(CWPluginContext context, SInt32 whichsegment, CWProjectSegmentInfo *segmentinfo); +extern CWResult UCBGetOverlay1GroupInfo(CWPluginContext context, SInt32 whichgroup, CWOverlay1GroupInfo *groupinfo); +extern CWResult UCBGetOverlay1FileInfo(CWPluginContext context, SInt32 whichgroup, SInt32 whichoverlay, SInt32 whichoverlayfile, CWOverlay1FileInfo *fileinfo); +extern CWResult UCBGetOverlay1Info(CWPluginContext context, SInt32 whichgroup, SInt32 whichoverlay, CWOverlay1Info *overlayinfo); +extern CWResult UCBReportMessage(CWPluginContext context, const CWMessageRef *msgRef, const char *line1, const char *line2, short errorlevel, SInt32 errorNumber); +extern CWResult UCBAlert(CWPluginContext context, const char *msg1, const char *msg2, const char *msg3, const char *msg4); +extern CWResult UCBShowStatus(CWPluginContext context, const char *line1, const char *line2); +extern CWResult UCBUserBreak(CWPluginContext context); +extern CWResult UCBGetNamedPreferences(CWPluginContext context, const char *prefsname, CWMemHandle *prefsdata); +extern CWResult UCBStorePluginData(CWPluginContext context, SInt32 whichfile, CWDataType type, CWMemHandle prefsdata); +extern CWResult UCBGetPluginData(CWPluginContext context, SInt32 whichfile, CWDataType type, CWMemHandle *prefsdata); +extern CWResult UCBSetModDate(CWPluginContext context, const CWFileSpec *filespec, CWFileTime *moddate, Boolean isGenerated); +extern CWResult UCBAddProjectEntry(CWPluginContext context, const CWFileSpec *fileSpec, Boolean isGenerated, const CWNewProjectEntryInfo *projectEntryInfo, SInt32 *whichfile); +extern CWResult UCBCreateNewTextDocument(CWPluginContext context, const CWNewTextDocumentInfo *docinfo); +extern CWResult UCBAllocateMemory(CWPluginContext context, SInt32 size, Boolean isPermanent, void **ptr); +extern CWResult UCBFreeMemory(CWPluginContext context, void *ptr, Boolean isPermanent); +extern CWResult UCBAllocMemHandle(CWPluginContext context, SInt32 size, Boolean useTempMemory, CWMemHandle *handle); +extern CWResult UCBFreeMemHandle(CWPluginContext context, CWMemHandle handle); +extern CWResult UCBGetMemHandleSize(CWPluginContext context, CWMemHandle handle, SInt32 *size); +extern CWResult UCBResizeMemHandle(CWPluginContext context, CWMemHandle handle, SInt32 newSize); +extern CWResult UCBLockMemHandle(CWPluginContext context, CWMemHandle handle, Boolean moveHi, void **ptr); +extern CWResult UCBUnlockMemHandle(CWPluginContext context, CWMemHandle handle); +extern CWResult UCBGetTargetName(CWPluginContext context, char *name, short maxLength); +extern CWResult UCBPreDialog(CWPluginContext context); +extern CWResult UCBPostDialog(CWPluginContext context); +extern CWResult UCBPreFileAction(CWPluginContext context, const CWFileSpec *theFile); +extern CWResult UCBPostFileAction(CWPluginContext context, const CWFileSpec *theFile); +extern CWResult UCBCacheAccessPathList(CWPluginContext context); +extern CWResult UCBSecretAttachHandle(CWPluginContext context, Handle handle, CWMemHandle *memHandle); +extern CWResult UCBSecretDetachHandle(CWPluginContext context, CWMemHandle memHandle, Handle *handle); +extern CWResult UCBSecretPeekHandle(CWPluginContext context, CWMemHandle memHandle, Handle *handle); +extern CWResult UCBCheckoutLicense(CWPluginContext context, const char *a, const char *b, SInt32 c, void *d, SInt32 *cookiePtr); +extern CWResult UCBCheckinLicense(CWPluginContext context, SInt32 cookie); +extern CWResult UCBResolveRelativePath(CWPluginContext context, const CWRelativePath *relativePath, CWFileSpec *fileSpec, Boolean create); +extern CWResult UCBMacOSErrToCWResult(CWPluginContext context, OSErr err); + +// CLCompilerLinkerDropin +extern CWResult UCBCachePrecompiledHeader(CWPluginContext context, const CWFileSpec *filespec, CWMemHandle pchhandle); +extern CWResult UCBLoadObjectData(CWPluginContext context, SInt32 whichfile, CWMemHandle *objectdata); +extern CWResult UCBStoreObjectData(CWPluginContext context, SInt32 whichfile, CWObjectData *object); +extern CWResult UCBFreeObjectData(CWPluginContext context, SInt32 whichfile, CWMemHandle objectdata); +extern CWResult UCBDisplayLines(CWPluginContext context, SInt32 nlines); +extern CWResult UCBBeginSubCompile(CWPluginContext context, SInt32 whichfile, CWPluginContext *subContext); +extern CWResult UCBEndSubCompile(CWPluginContext subContext); +extern CWResult UCBGetPrecompiledHeaderSpec(CWPluginContext context, CWFileSpec *pchspec, const char *target); +extern CWResult UCBGetResourceFile(CWPluginContext context, CWFileSpec *filespec); +extern CWResult UCBPutResourceFile(CWPluginContext context, const char *prompt, const char *name, CWFileSpec *filespec); +extern CWResult UCBLookUpUnit(CWPluginContext context, const char *name, Boolean isdependency, const void **unitdata, SInt32 *unitdatalength); +extern CWResult UCBSBMfiles(CWPluginContext context, short libref); +extern CWResult UCBStoreUnit(CWPluginContext context, const char *unitname, CWMemHandle unitdata, CWDependencyTag dependencytag); +extern CWResult UCBReleaseUnit(CWPluginContext context, void *unitdata); +extern CWResult UCBUnitNameToFileName(CWPluginContext context, const char *unitname, char *filename); +extern CWResult UCBOSAlert(CWPluginContext context, const char *message, OSErr errorcode); +extern CWResult UCBOSErrorMessage(CWPluginContext context, const char *msg, OSErr errorcode); +extern CWResult UCBGetModifiedFiles(CWPluginContext context, SInt32 *modifiedFileCount, const SInt32 **modifiedFiles); +extern CWResult UCBGetSuggestedObjectFileSpec(CWPluginContext context, SInt32 whichfile, CWFileSpec *fileSpec); +extern CWResult UCBGetStoredObjectFileSpec(CWPluginContext context, SInt32 whichfile, CWFileSpec *fileSpec); +extern CWResult UCBGetFrameworkCount(CWPluginContext context, SInt32 *frameworkCount); +extern CWResult UCBGetFrameworkInfo(CWPluginContext context, SInt32 whichFramework, CWFrameworkInfo *frameworkInfo); + +// CLParserCallbacks +extern CWResult UCBParserAddAccessPath(CWPluginContext context, const CWNewAccessPathInfo *api); +extern CWResult UCBParserSwapAccessPaths(CWPluginContext context); +extern CWResult UCBParserSetNamedPreferences(CWPluginContext context, const char *panelName, Handle paneldata); +extern CWResult UCBParserSetFileOutputName(CWPluginContext context, SInt32 position, short which, const char *outfilename); +extern CWResult UCBParserSetOutputFileDirectory(CWPluginContext context, const CWFileSpec *idefss); +extern CWResult UCBParserAddOverlay1Group(CWPluginContext context, const char *name, const CWAddr64 *addr, SInt32 *newGroupNumber); +extern CWResult UCBParserAddOverlay1(CWPluginContext context, const char *name, SInt32 groupNumber, SInt32 *newOverlayNumber); +extern CWResult UCBParserAddSegment(CWPluginContext context, const char *name, short attrs, SInt32 *newSegmentNumber); +extern CWResult UCBParserSetSegment(CWPluginContext context, SInt32 segmentNumber, const char *name, short attrs); + #ifdef __cplusplus } #endif + +// This one is intentionally outwith the extern "C" block as it's mangled +extern CWResult OSErrtoCWResult(OSErr err); \ No newline at end of file diff --git a/includes/plugin_internal.h b/includes/plugin_internal.h index be84406..fdf2bd0 100644 --- a/includes/plugin_internal.h +++ b/includes/plugin_internal.h @@ -5,7 +5,7 @@ #pragma options align=mac68k #endif struct CWPluginPrivateContext { - CWPluginPrivateContext(); + CWPluginPrivateContext(SInt32 thePluginType, SInt32 totalSize = 0); ~CWPluginPrivateContext(); SInt32 request; @@ -79,6 +79,13 @@ struct CWParserContext : CWPluginPrivateContext { CWCommandLineArgs *panel_args; CWParserCallbacks *callbacks; }; + +struct Plugin; +typedef struct shellContextType { + Plugin *plugin; + Boolean userAccessPathsChanged; + Boolean systemAccessPathsChanged; +} shellContextType; #ifdef __MWERKS__ #pragma options align=reset #endif diff --git a/includes/pref_structs.h b/includes/pref_structs.h new file mode 100644 index 0000000..b443bf7 --- /dev/null +++ b/includes/pref_structs.h @@ -0,0 +1,253 @@ +#pragma once +#include "common.h" + +#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; + UInt16 maxErrors; + UInt16 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 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; + +typedef struct PCmdLineEnvir { + SInt16 version; + SInt16 cols; + SInt16 rows; + Boolean underIDE; +} PCmdLineEnvir; + +typedef struct PFrontEndC { + SInt16 version; + Boolean cplusplus; + Boolean checkprotos; + Boolean arm; + Boolean trigraphs; + Boolean onlystdkeywords; + Boolean enumsalwaysint; + Boolean mpwpointerstyle; + unsigned char oldprefixname[32]; + Boolean ansistrict; + Boolean mpwcnewline; + Boolean wchar_type; + Boolean enableexceptions; + Boolean dontreusestrings; + Boolean poolstrings; + Boolean dontinline; + Boolean useRTTI; + Boolean multibyteaware; + Boolean unsignedchars; + Boolean autoinline; + Boolean booltruefalse; + Boolean direct_to_som; + Boolean som_env_check; + Boolean alwaysinline; + SInt16 inlinelevel; + Boolean ecplusplus; + Boolean objective_c; + Boolean defer_codegen; + Boolean templateparser; + Boolean c99; + Boolean bottomupinline; +} PFrontEndC; + +typedef struct PWarningC { + SInt16 version; + Boolean warn_illpragma; + Boolean warn_emptydecl; + Boolean warn_possunwant; + Boolean warn_unusedvar; + Boolean warn_unusedarg; + Boolean warn_extracomma; + Boolean pedantic; + Boolean warningerrors; + Boolean warn_hidevirtual; + Boolean warn_implicitconv; + Boolean warn_notinlined; + Boolean warn_structclass; +} PWarningC; + +typedef struct PGlobalOptimizer { + SInt16 version; + UInt8 optimizationlevel; + UInt8 optfor; + UInt8 reserved[8]; +} PGlobalOptimizer; + +// assumed name/symbols for this one +typedef struct PExtraWarningC { + Boolean warn_largeargs; + Boolean warn_padding; + Boolean warn_resultnotused; + Boolean warn_ptr_int_conv; + Boolean warn_no_side_effect; +} PExtraWarningC; + +#ifdef __MWERKS__ +#pragma options align=reset +#endif diff --git a/notes b/notes index 0a2c468..190d074 100644 --- a/notes +++ b/notes @@ -1,62 +1,65 @@ +~/bin/mwccppc -c -g -opt l=4,noschedule,speed -enum min -Iincludes -Isdk_hdrs -w all,nounused -wchar_t on -bool off -Cpp_exceptions off + * - has issues -DONE CLStaticMain.c -DONE ClientGlue.c -DONE CLMain.c -DONE* MacEmul/Resources.c -STUB Envir/CLErrors.c -DONE* MacEmul/ResourceStrings.c ----- Plugins/CLPlugins.c ----- Callbacks/CLParserCallbacks_v1.cpp -STUB CLIO.c -STUB CLToolExec.c -DONE OSLib/Posix.c -DONE OSLib/StringExtras.c -DONE OSLib/Generic.c ----- Project/CLProj.c ----- CLLicenses.c -DONE OSLib/MemUtils.c ----- CLPluginRequests.cpp -DONE MacEmul/LowMem.c ----- CLFileOps.c ----- CLPrefs.c ----- CLTarg.c ----- Project/CLAccessPaths.c -DONE OSLib/MacSpecs.c -DONE OSLib/StringUtils.c -DONE MacEmul/Memory.c -DONE MacEmul/File.c -DONE MacEmul/TextUtils.c ----- ?? AddFileTypeMappingList, SetMacFileType, ... ----- Project/CLFiles.c ----- Project/CLOverlays.c ----- Project/CLSegs.c ----- Callbacks/CLDropinCallbacks_V10.cpp -DONE OSLib/MacFileTypes.c -DONE OSLib/FileHandles.c ----- Callbacks/CLCompilerLinkerDropin_V10.cpp ----- CLDependencies.c ----- CLWriteObjectFile.c ----- CLBrowser.c ----- CLIncludeFileCache.c ----- CLLoadAndCache.c -DONE MacEmul/ErrMgr.c ----- ?? Counterpart of cc-macosx-ppc-mw.c - (Includes RegisterStaticTargetResources, GetStaticTarget, ...) ----- ?? Counterpart of ParserGlue-macosx-ppc-cc.c +[CL / command_line] +DONE command_line/CmdLine/Src/Clients/CLStaticMain.c +DONE command_line/CmdLine/Src/Clients/ClientGlue.c +DONE command_line/CmdLine/Src/CLMain.c +DONE* command_line/CmdLine/Src/MacEmul/Resources.c +DONE command_line/CmdLine/Src/Envir/CLErrors.c +DONE* command_line/CmdLine/Src/MacEmul/ResourceStrings.c +DONE* command_line/CmdLine/Src/Plugins/CLPlugins.c +DONE command_line/CmdLine/Src/Callbacks/CLParserCallbacks_v1.cpp +DONE command_line/CmdLine/Src/Envir/CLIO.c +DONE command_line/CmdLine/Src/CLToolExec.c +DONE command_line/CmdLine/Src/OSLib/Posix.c +DONE command_line/CmdLine/Src/OSLib/StringExtras.c +DONE command_line/CmdLine/Src/OSLib/Generic.c +DONE command_line/CmdLine/Src/Project/CLProj.c +DONE command_line/CmdLine/Src/CLLicenses.c +DONE command_line/CmdLine/Src/OSLib/MemUtils.c +DONE command_line/CmdLine/Src/CLPluginRequests.cpp +DONE command_line/CmdLine/Src/MacEmul/LowMem.c +DONE command_line/CmdLine/Src/CLFileOps.c +DONE command_line/CmdLine/Src/CLPrefs.c +DONE command_line/CmdLine/Src/CLTarg.c +DONE command_line/CmdLine/Src/Project/CLAccessPaths.c +DONE command_line/CmdLine/Src/OSLib/MacSpecs.c +DONE command_line/CmdLine/Src/OSLib/StringUtils.c +DONE command_line/CmdLine/Src/MacEmul/Memory.c +DONE command_line/CmdLine/Src/MacEmul/Files.c +DONE command_line/CmdLine/Src/MacEmul/TextUtils.c +DONE ?? AddFileTypeMappingList, SetMacFileType, ... +DONE command_line/CmdLine/Src/Project/CLFiles.c +DONE command_line/CmdLine/Src/Project/CLOverlays.c +DONE command_line/CmdLine/Src/Project/CLSegs.c +DONE* command_line/CmdLine/Src/Callbacks/CLDropinCallbacks_V10.cpp +DONE command_line/CmdLine/Src/OSLib/MacFileTypes.c +DONE command_line/CmdLine/Src/OSLib/FileHandles.c +DONE command_line/CmdLine/Src/Callbacks/CLCompilerLinkerDropin_V10.cpp +DONE* command_line/CmdLine/Src/CLDependencies.c +DONE command_line/CmdLine/Src/CLWriteObjectFile.c +DONE* command_line/CmdLine/Src/CLBrowser.c +DONE command_line/CmdLine/Src/CLIncludeFileCache.c +DONE command_line/CmdLine/Src/CLLoadAndCache.c +DONE command_line/CmdLine/Src/MacEmul/ErrMgr.c + +DONE compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Static/cc-mach-ppc-mw.c +---- compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-cc.c (Includes RegisterStaticParserToolInfo and all the option lists) ----- ?? Counterpart of cc-macosx-ppc.c +DONE compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.o (Includes RegisterStaticCompilerPlugin, RegisterCompilerResources) ----- ?? Counterpart of machimp-macosx-ppc.c +DONE compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/libimp-mach-ppc.c (Includes RegisterStaticLibImporterPlugin, RegisterLibImporterResources) ----- TargetOptimizer-ppc-mach.c +2CHK TargetOptimizer-ppc-mach.c ---- OptimizerHelpers.c ---- ?? TargetSetWarningFlags, TargetDisplayWarningOptions ---- WarningHelpers.c ---- CCompiler.c ---- CParser.c ----- CompilerTools.c +---- compiler_and_linker/FrontEnd/Common/CompilerTools.c ---- CodeGenOptPPC.c ---- IrOptimizer.c ---- CodeGen.c @@ -168,6 +171,8 @@ STUB PCodeInfo.c ---- SpillCode.c ---- GCCInlineAsm.c ---- BitVectors.c + +[Parser] DONE (debug) StaticParserGlue.c DONE (debug) ParserFace.c DONE* (debug) ParserHelpers.c @@ -180,13 +185,13 @@ DONE (debug) Projects.c DONE (debug) Targets.c DONE# (debug) Option.c DONE (debug) ParserErrors.c ----- (debug) Utils.c +DONE* (debug) Utils.c DONE# (debug) Parameter.c DONE# (debug) Help.c DONE uContext1.cpp DONE uContextCL.cpp DONE uContextSecret.cpp ----- ?? COS +DONE* ?? COS DONE uContextParser.cpp ----- ?? Something import-related ----- Various MSL objects \ No newline at end of file +DONE uLibImporter.c +---- Various MSL objects diff --git a/opt_decomp.py b/opt_decomp.py new file mode 100644 index 0000000..a6e612b --- /dev/null +++ b/opt_decomp.py @@ -0,0 +1,394 @@ +import json +import sys + +def decode_avail(f): + flags = [] + if (f & 0x1) != 0: flags.append('Global') + if (f & 0x2) != 0: flags.append('Sticky') + if (f & 0x4) != 0: flags.append('Cased') + if (f & 0x8) != 0: flags.append('Obsolete') + if (f & 0x10) != 0: flags.append('Substituted') + if (f & 0x20) != 0: flags.append('Deprecated') + if (f & 0x40) != 0: flags.append('Link') + if (f & 0x80) != 0: flags.append('Disasm') + if (f & 0x100) != 0: flags.append('Comp') + if (f & 0x200) != 0: flags.append('OF200') + if (f & 0x400) != 0: flags.append('OF400') + if (f & 0x800) != 0: flags.append('Ignored') + if (f & 0x1000) != 0: flags.append('Secret') + if (f & 0x2000) != 0: flags.append('HideDefault') + if (f & 0x4000) != 0: flags.append('Compat') + if (f & 0x8000) != 0: flags.append('Sub') + if (f & 0x10000) != 0: flags.append('SubsOptional') + if (f & 0x20000) != 0: flags.append('OnlyOnce') + if (f & 0x40000) != 0: flags.append('Conflicts') + if (f & 0x80000) != 0: flags.append('Warning') + if (f & 0x100000) != 0: flags.append('CanBeNegated') + if (f & 0x200000) != 0: flags.append('O_SLFlags10') + if (f & 0x400000) != 0: flags.append('O_SLFlags20') + if (f & 0x800000) != 0: flags.append('Meaningless') + if (f & 0x1000000) != 0: flags.append('OF1000000') + if (f & 0x2000000) != 0: flags.append('OF2000000') + if (f & 0x4000000) != 0: flags.append('OF4000000') + if (f & 0x8000000) != 0: flags.append('OF8000000') + if (f & 0x10000000) != 0: flags.append('OF10000000') + if (f & 0x20000000) != 0: flags.append('OF20000000') + return '|'.join(flags) +def decode_paramflags(f): + flags = [] + if (f & 0x1) != 0: flags.append('PF01') + if (f & 0x2) != 0: flags.append('PF02') + if (f & 0x4) != 0: flags.append('PF04') + if (f & 0x8) != 0: flags.append('PF08') + if (f & 0x10) != 0: flags.append('PF10') + if (f & 0x20) != 0: flags.append('PF20') + if (f & 0x40) != 0: flags.append('PF40') + if (f & 0x80) != 0: flags.append('PF80') + return '|'.join(flags) +def decode_listflags(f): + flags = [] + if (f & 0x1) != 0: flags.append('L_Exclusive') + if (f & 0x2) != 0: flags.append('L_AllowUnknowns') + if (f & 0x4) != 0: flags.append('LF4') + if (f & 0x8) != 0: flags.append('LF8') + if (f & 0x10) != 0: flags.append('LF10') + if (f & 0x20) != 0: flags.append('LF20') + if (f & 0x40) != 0: flags.append('LF40') + if (f & 0x80) != 0: flags.append('LF80') + if (f & 0x100) != 0: flags.append('L_Comp') + if (f & 0x200) != 0: flags.append('L_Link') + if (f & 0x400) != 0: flags.append('L_Disasm') + if (f & 0x800) != 0: flags.append('LF800') + if (f & 0x1000) != 0: flags.append('LF1000') + if (f & 0x2000) != 0: flags.append('LF2000') + if (f & 0x4000) != 0: flags.append('LF4000') + if (f & 0x8000) != 0: flags.append('LF8000') + if (f & 0x10000) != 0: flags.append('LF10000') + if (f & 0x20000) != 0: flags.append('LF20000') + if (f & 0x40000) != 0: flags.append('LF40000') + if (f & 0x80000) != 0: flags.append('LF80000') + if (f & 0x100000) != 0: flags.append('LF100000') + if (f & 0x200000) != 0: flags.append('LF200000') + if (f & 0x400000) != 0: flags.append('LF400000') + if (f & 0x800000) != 0: flags.append('LF800000') + if (f & 0x1000000) != 0: flags.append('LF1000000') + if (f & 0x2000000) != 0: flags.append('LF2000000') + if (f & 0x4000000) != 0: flags.append('LF4000000') + if (f & 0x8000000) != 0: flags.append('LF8000000') + if (f & 0x10000000) != 0: flags.append('LF10000000') + if (f & 0x20000000) != 0: flags.append('LF20000000') + if (f & 0x40000000) != 0: flags.append('LF40000000') + if (f & 0x80000000) != 0: flags.append('LF80000000') + return '|'.join(flags) + +navstack = [] +indent = '' +def push_indent(): + global indent + indent += ' ' +def pop_indent(): + global indent + indent = indent[:-2] + +scan_objs = {} +def register_scan_obj(name, what): + ckname = name.replace('_list', '') + if ckname[-1].isdigit(): + last_non_digit = 0 + for i,c in enumerate(ckname): + if not c.isdigit(): + last_non_digit = i + idx = int(ckname[last_non_digit+1:]) + else: + return + + stk = ' / '.join(navstack) + if idx in scan_objs: + lst = scan_objs[idx] + for o in lst: + if o[1] == name: + return + lst.append((stk, name, what)) + else: + scan_objs[idx] = [(stk, name, what)] + +def dump_param(p): + suff = '' + if 'myname' in p: + suff += ' +myname' + if 'help' in p: + suff += ' +help' + register_scan_obj(p['_name'], f"PF:{p['flags']:02X} T:{p['_type']}{suff}") + print(f"{indent}-{p['_name']:37} | {decode_paramflags(p['flags'])} ", end='') + if 'myname' in p: + print(f"<{p['myname']}> ", end='') + if p['_type'] == 'FTypeCreator': + print(f"FTypeCreator(fc={p['fc']} iscreator={p['iscreator']})") + elif p['_type'] == 'FilePath': + print(f"FilePath(flg={p['fflags']:02X} def={p['defaultstr']} fn={p['filename']} max={p['maxlen']})") + elif p['_type'] == 'Number': + print(f"Number(sz={p['size']} fit={p['fit']} lo={p['lo']:08X} hi={p['hi']:08X} num={p['num']})") + elif p['_type'] in ('String','Id','Sym'): + print(f"{p['_type']}(max={p['maxlen']} ps={p['pstring']} s={p['str']})") + elif p['_type'] == 'OnOff': + print(f"OnOff(var={p['var']})") + elif p['_type'] == 'OffOn': + print(f"OffOn(var={p['var']})") + elif p['_type'] == 'Mask': + print(f"Mask(sz={p['size']} or={p['ormask']:08X} and={p['andmask']:08X} num={p['num']})") + elif p['_type'] == 'Toggle': + print(f"Toggle(sz={p['size']} mask={p['mask']:08X} num={p['num']})") + elif p['_type'] == 'Set': + print(f"Set(sz={p['size']} v={p['value']} num={p['num']})") + elif p['_type'] == 'SetString': + print(f"SetString(v={p['value']} ps={p['pstring']} var={p['var']})") + elif p['_type'] == 'Generic': + v = p['var'] + if isinstance(v, str): + v = v.replace('\n','').replace('\r','') + print(f"Generic(p={p['parse']} var={v})") + elif p['_type'] == 'IfArg': + print('IfArg') + push_indent() + print(f'{indent}TRUE:') + push_indent() + for i,s in enumerate(p['parg']): + navstack.append(f'ifArgParam{i}') + dump_param(s) + navstack.pop(-1) + pop_indent() + print(f'{indent}FALSE:') + push_indent() + for i,s in enumerate(p['pnone']): + navstack.append(f'ifArgNoneParam{i}') + dump_param(s) + navstack.pop(-1) + pop_indent() + pop_indent() + elif p['_type'] == 'Setting': + print(f"Setting(p={p['parse']} vn={p['valuename']})") + else: + print() + +def dump_opt(o): + navstack.append(o['names']) + trunchelp = o['help'] + if trunchelp: + if len(trunchelp) > 35: + trunchelp = trunchelp[:20] + '...' + trunchelp[-5:] + trunchelp = trunchelp.replace('\r', ' ') + trunchelp = trunchelp.replace('\n', ' ') + avail = decode_avail(o['avail']) + register_scan_obj(o['_name'], 'OPTION ' + avail) + print(f"{indent}{o['_name']:40} | {avail} {o['names']:40} {trunchelp}") + if 'conflicts' in o: + conflicts = o['conflicts'] + print(f"{indent}CONFLICTS: {conflicts['_name']} / {conflicts['_list_name']} / {decode_listflags(conflicts['flags'])}") + print(f"{indent} {conflicts['list']}") + register_scan_obj(conflicts['_name'], f"CONFLICTS LIST") + register_scan_obj(conflicts['_list_name'], f"CONFLICTS LIST NAME") + push_indent() + for i,p in enumerate(o['param']): + navstack.append(f'param{i}') + dump_param(p) + navstack.pop(-1) + pop_indent() + if 'sub' in o: + sub = o['sub'] + print(f"{indent}SUB {{ {sub['_name']} / {sub['_list_name']} / {decode_listflags(sub['flags'])}") + register_scan_obj(sub['_name'], f"SUB LIST") + register_scan_obj(sub['_list_name'], f"SUB LIST NAME") + push_indent() + for s in sub['list']: + dump_opt(s) + pop_indent() + print(f"{indent}}}") + navstack.pop(-1) + +def dump_optlst(ol): + register_scan_obj(ol['_name'], 'ROOT OBJECT') + register_scan_obj(ol['_list_name'], 'ROOT OBJECT LIST') + print(f"{indent}# FLAGS: {decode_listflags(ol['flags'])} - HELP: {repr(ol['help'])}") + for option in ol['list']: + dump_opt(option) + +with open(sys.argv[1], 'r') as f: + optlsts = json.load(f) + +for optlst in optlsts: + print(f"{indent}# --- {optlst['_name']} ---") + push_indent() + dump_optlst(optlst) + pop_indent() + print() + +lastseen = 0 +deltas = {} +for i in range(1220): + if i in scan_objs: + delta = i - lastseen + for stk,name,what in scan_objs[i]: + print(f'{i:04d} {stk:60} | {name:30} | {what}') + deltas[name] = delta + lastseen = i + else: + print(f'{i:04d} -----') + +def nice_param(p): + # param names don't matter + np = {'_type': p['_type'], 'flags': p['flags']} + if 'myname' in p and p['myname']: + np['myname'] = p['myname'] + + delta = deltas[p['_name']] + if p['_name'] == '_optlstCmdLine099': + delta -= 1 # hack to account for the weird 'progress' one + if delta > 1: + np['_idskip'] = delta - 1 + + if p['_type'] == 'FTypeCreator': + np['target'] = p['fc'] + np['is_creator'] = p['iscreator'] + elif p['_type'] == 'FilePath': + np['fflags'] = p['fflags'] + np['default'] = p['defaultstr'] + np['target'] = p['filename'] + np['max_length'] = p['maxlen'] + elif p['_type'] == 'Number': + np['target'] = p['num'] + np['minimum'] = p['lo'] + np['maximum'] = p['hi'] + np['byte_size'] = p['size'] + np['fit'] = p['fit'] + elif p['_type'] in ('String','Id','Sym'): + np['max_length'] = p['maxlen'] + np['pascal'] = (p['pstring'] != 0) + np['target'] = p['str'] + elif p['_type'] == 'OnOff': + np['target'] = p['var'] + elif p['_type'] == 'OffOn': + np['target'] = p['var'] + elif p['_type'] == 'Mask': + np['target'] = p['num'] + np['byte_size'] = p['size'] + np['or_mask'] = p['ormask'] + np['and_mask'] = p['andmask'] + elif p['_type'] == 'Toggle': + np['target'] = p['num'] + np['byte_size'] = p['size'] + np['mask'] = p['mask'] + elif p['_type'] == 'Set': + np['target'] = p['num'] + np['value'] = p['value'] + np['byte_size'] = p['size'] + elif p['_type'] == 'SetString': + np['target'] = p['var'] + np['value'] = p['value'] + np['pascal'] = (p['pstring'] != 0) + elif p['_type'] == 'Generic': + np['function'] = p['parse'] + np['arg'] = p['var'] + np['help'] = p['help'] + elif p['_type'] == 'IfArg': + np['help_a'] = p['helpa'] + np['help_n'] = p['helpn'] + np['if_arg'] = [nice_param(sp) for sp in p['parg']] + np['if_no_arg'] = [nice_param(sp) for sp in p['pnone']] + elif p['_type'] == 'Setting': + np['function'] = p['parse'] + np['value_name'] = p['valuename'] + return np + +def nice_option(o, exclusive_parent=False): + no = {'names': o['names'], 'tools': [], 'params': [nice_param(p) for p in o['param']]} + if 'help' in o: + no['help'] = o['help'] + if o['_name'] == '_optlstCmdLine_progress': + no['custom_name'] = 'progress' # lol hack + if (o['avail'] & 0x1) != 0: no['global'] = True + if (o['avail'] & 0x2) != 0: no['sticky'] = True + if (o['avail'] & 0x4) != 0: no['cased'] = True + if (o['avail'] & 0x8) != 0: no['obsolete'] = True + if (o['avail'] & 0x10) != 0: no['substituted'] = True + if (o['avail'] & 0x20) != 0: no['deprecated'] = True + if (o['avail'] & 0x100) != 0: no['tools'].append('compiler') + if (o['avail'] & 0x40) != 0: no['tools'].append('linker') + if (o['avail'] & 0x80) != 0: no['tools'].append('disassembler') + if (o['avail'] & 0x200) != 0: raise ValueError('fucked') + if (o['avail'] & 0x400) != 0: raise ValueError('fucked') + if (o['avail'] & 0x800) != 0: no['ignored'] = True + if (o['avail'] & 0x1000) != 0: no['secret'] = True + if (o['avail'] & 0x2000) != 0: no['hide_default'] = True + if (o['avail'] & 0x4000) != 0: no['compatibility'] = True + if (o['avail'] & 0x20000) != 0: no['only_once'] = True + if (o['avail'] & 0x80000) != 0: no['warning'] = True + if (o['avail'] & 0x100000) != 0: no['can_be_negated'] = True + if (o['avail'] & 0x200000) != 0: no['can_be_negated_2'] = True + if (o['avail'] & 0x400000) != 0: no['can_be_negated_3'] = True + if (o['avail'] & 0x800000) != 0: no['meaningless'] = True + + if (o['avail'] & 0x8000) != 0: + subflags = o['sub']['flags'] + obj_comp = (o['avail'] & 0x100) != 0 + obj_link = (o['avail'] & 0x40) != 0 + obj_disasm = (o['avail'] & 0x80) != 0 + sublist_comp = (subflags & 0x100) != 0 + sublist_link = (subflags & 0x200) != 0 + sublist_disasm = (subflags & 0x400) != 0 + assert(obj_comp == sublist_comp) + assert(obj_link == sublist_link) + assert(obj_disasm == sublist_disasm) + + excl = False + if (o['avail'] & 0x10000) != 0: + no['sub_options_optional'] = True + if (subflags & 2) != 0: + no['sub_options_allow_unknowns'] = True + if (subflags & 1) != 0: + no['sub_options_exclusive'] = True + excl = True + + assert('help' not in o['sub']) + no['sub_options'] = [nice_option(so, excl) for so in o['sub']['list']] + else: + assert('sub' not in o) + + if exclusive_parent: + # conflicts flag should be set + assert((o['avail'] & 0x40000) == 0x40000) + assert('help' not in o['conflicts']) + else: + if (o['avail'] & 0x40000) == 0x40000: + no['conflict_group'] = o['conflicts']['_name'][1:].replace('_conflicts', '') + + return no + +if len(sys.argv) > 2: + nice_optlsts_map = {} + for optlst in optlsts: + #print('---' + optlst['_name']) + root_list = {'name': optlst['_name'].replace('_optlst', ''), 'tools': [], 'help': optlst['help'], 'options': []} + if (optlst['flags'] & 0x100) != 0: root_list['tools'].append('compiler') + if (optlst['flags'] & 0x200) != 0: root_list['tools'].append('linker') + if (optlst['flags'] & 0x400) != 0: root_list['tools'].append('disassembler') + for opt in optlst['list']: + #print('+' + opt['names']) + root_list['options'].append(nice_option(opt)) + nice_optlsts_map[root_list['name']] = root_list + + nice_optlsts = [ + nice_optlsts_map['CmdLine'], + nice_optlsts_map['CmdLineCompiler'], + nice_optlsts_map['CmdLineLinker'], + nice_optlsts_map['Debugging'], + nice_optlsts_map['FrontEndC'], + nice_optlsts_map['WarningC'], + nice_optlsts_map['Optimizer'], + nice_optlsts_map['BackEnd'], + nice_optlsts_map['Project'], + nice_optlsts_map['Linker'], + nice_optlsts_map['Dumper'] + ] + + with open(sys.argv[2], 'w') as f: + json.dump(nice_optlsts, f, indent=4) diff --git a/opt_recomp.py b/opt_recomp.py new file mode 100644 index 0000000..b7c46c4 --- /dev/null +++ b/opt_recomp.py @@ -0,0 +1,381 @@ +import json + +class OptionCompiler: + def __init__(self): + self.last_id = 0 + self.debug_indent = '' + self.root_basename = '' + self.current_basename = '' + self.current_forward_decls = [] + self.current_output = [] + self.conflict_groups = {} + + def debug_push(self): + self.debug_indent += ' ' + + def debug_pop(self): + self.debug_indent = self.debug_indent[:-2] + + def get_new_id(self): + self.last_id += 1 + return self.last_id + + def skip_id(self): + self.last_id += 1 + + def add_root(self, root): + self.assign_all_ids(root) + print('-'*80) + self.assign_all_names(root) + print('-'*80) + self.current_forward_decls = [] + self.current_output = [] + self.conflict_groups = {} + self.emit_root(root) + + filename = f"Opts{root['name']}.opt" + with open(f'compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Lib/mac-ppc-cc/{filename}', 'w') as f: + for line in self.current_forward_decls: + f.write(line) + f.write('\n') + if self.current_forward_decls: + f.write('\n') + for line in self.current_output: + f.write(line) + f.write('\n') + + # Phase 1 + def assign_all_ids(self, root): + for option in root['options']: + self.assign_id_to_option(option) + root['_list_id'] = self.get_new_id() + + def assign_id_to_option(self, option): + print(f"{self.debug_indent}option {option['names']}") + self.debug_push() + if 'sub_options' in option: + for sub_option in reversed(option['sub_options']): + self.assign_id_to_option(sub_option) + option['_sub_list_id'] = self.get_new_id() + print(f"{self.debug_indent}{option['_sub_list_id']}: option sublist") + for param in reversed(option['params']): + self.assign_id_to_param(param) + option['_id'] = self.get_new_id() + print(f"{self.debug_indent}{option['_id']}: option ({option['names']})") + self.debug_pop() + + def assign_id_to_param(self, param): + if param['_type'] == 'IfArg': + for sub_param in reversed(param['if_no_arg']): + self.assign_id_to_param(sub_param) + for sub_param in reversed(param['if_arg']): + self.assign_id_to_param(sub_param) + + if '_idskip' in param: + self.last_id += param['_idskip'] + param['_id'] = self.get_new_id() + print(f"{self.debug_indent}{param['_id']}: param {param['_type']}") + + # Phase 2 + def assign_all_names(self, root): + self.root_basename = f"optlst{root['name']}" + self.current_basename = f"optlst{root['name']}" + root['_name'] = self.current_basename + root['_list_name'] = f"{self.current_basename}_{root['_list_id']:03d}_list" + for option in root['options']: + self.assign_name_to_option(option) + + def assign_name_to_option(self, option): + if 'conflict_group' in option: + option['_name'] = f"{option['conflict_group']}_{option['_id']:03d}" + elif 'custom_name' in option: + option['_name'] = f"{self.current_basename}_{option['custom_name']}" + else: + option['_name'] = f"{self.current_basename}_{option['_id']:03d}" + print(f"{self.debug_indent}{option['_name']} = {option['names']}") + self.debug_push() + for param in option['params']: + self.assign_name_to_param(param) + if 'sub_options' in option: + save_basename = self.current_basename + option['_sub_list_name'] = f"{self.current_basename}_{option['_sub_list_id']:03d}" + if 'sub_options_exclusive' in option and option['sub_options_exclusive']: + self.current_basename = option['_sub_list_name'] + for sub_option in option['sub_options']: + self.assign_name_to_option(sub_option) + self.current_basename = save_basename + self.debug_pop() + + def assign_name_to_param(self, param): + if param['_type'] == 'IfArg': + self.debug_push() + for sub_param in param['if_no_arg']: + self.assign_name_to_param(sub_param) + for sub_param in param['if_arg']: + self.assign_name_to_param(sub_param) + self.debug_pop() + param['_name'] = f"{self.root_basename}{param['_id']:03d}" + print(f"{self.debug_indent}{param['_name']} = {param['_type']}") + + # Phase 3 + def emit_root(self, root): + self.current_output.append(f"/* {root['name']} */") + for option in root['options']: + self.emit_option(option) + + self.current_output.append(f"Option *{root['_list_name']}[] = {{") + for option in root['options']: + self.current_output.append(f"\t&{option['_name']},") + self.current_output.append('\t0') + self.current_output.append('};') + + list_flags = build_list_flags(root) + self.current_output.append(f"OptionList {root['_name']} = {{") + self.current_output.append(f"\t/* help = */ {json.dumps(root['help'])},") + self.current_output.append(f"\t/* flags = */ {list_flags},") + self.current_output.append(f"\t/* list = */ {root['_list_name']}") + self.current_output.append('};') + + for (i, (group, option_names)) in enumerate(self.conflict_groups.items()): + self.current_forward_decls.append(f'/* forward declare */ extern OptionList {group}_conflicts;') + self.current_output.append(f'Option *{group}_{i:03d}_list[] = {{') + for option_name in option_names: + self.current_output.append(f'\t&{option_name},') + self.current_output.append('\t0') + self.current_output.append('};') + self.current_output.append(f'OptionList {group}_conflicts = {{') + self.current_output.append(f'\t/* help = */ 0,') + self.current_output.append(f'\t/* flags = */ 0,') + self.current_output.append(f'\t/* list = */ {group}_{i:03d}_list') + self.current_output.append('};') + + def emit_option(self, option, is_conflicted=None): + option_flags = build_option_flags(option, is_conflicted) + + sub_name = '0' + if 'sub_options' in option: + sub_name = '&' + option['_sub_list_name'] + sub_conflicts = None + if ('sub_options_exclusive' in option) and option['sub_options_exclusive']: + sub_conflicts = f"&{option['_sub_list_name']}_conflicts" + self.current_output.append(f"/* forward declare */ extern OptionList {option['_sub_list_name']}_conflicts;") + + for sub_option in option['sub_options']: + self.emit_option(sub_option, sub_conflicts) + + self.current_output.append(f"Option *{option['_sub_list_name']}_list[] = {{") + for sub_option in option['sub_options']: + self.current_output.append(f"\t&{sub_option['_name']},") + self.current_output.append('\t0') + self.current_output.append('};') + + list_flags = build_list_flags(option) + self.current_output.append(f"OptionList {option['_sub_list_name']} = {{") + self.current_output.append(f"\t/* help = */ 0,") + self.current_output.append(f"\t/* flags = */ {list_flags},") + self.current_output.append(f"\t/* list = */ {option['_sub_list_name']}_list") + self.current_output.append('};') + + if ('sub_options_exclusive' in option) and option['sub_options_exclusive']: + self.current_output.append(f"OptionList {option['_sub_list_name']}_conflicts = {{") + self.current_output.append(f"\t/* help = */ 0,") + self.current_output.append(f"\t/* flags = */ {list_flags},") + self.current_output.append(f"\t/* list = */ {option['_sub_list_name']}_list") + self.current_output.append('};') + + if is_conflicted: + conflicts_name = is_conflicted + elif 'conflict_group' in option: + conflict_group = option['conflict_group'] + conflicts_name = f'&{conflict_group}_conflicts' + if conflict_group in self.conflict_groups: + self.conflict_groups[conflict_group].append(option['_name']) + else: + self.conflict_groups[conflict_group] = [option['_name']] + else: + conflicts_name = '0' + + last_param = self.emit_params(option['params']) + help_str = json.dumps(option['help']) if ('help' in option and option['help'] is not None) else '0' + + self.current_output.append(f"Option {option['_name']} = {{") + self.current_output.append(f"\t/* names = */ {json.dumps(option['names'])},") + self.current_output.append(f"\t/* avail = */ {option_flags},") + self.current_output.append(f"\t/* param = */ {last_param},") + self.current_output.append(f"\t/* sub = */ {sub_name},") + self.current_output.append(f"\t/* conflicts = */ {conflicts_name},") + self.current_output.append(f"\t/* help = */ {help_str}") + self.current_output.append('};') + + def emit_params(self, params): + last_param = '0' + + for param in reversed(params): + if param['_type'] == 'IfArg': + ia_last_parg = self.emit_params(param['if_arg']) + ia_last_pnone = self.emit_params(param['if_no_arg']) + + myname_str = json.dumps(param['myname']) if 'myname' in param else '0' + + self.current_output.append(f"{PARAM_TYPES[param['_type']]} {param['_name']} = {{") + self.current_output.append(f"\t/* which = */ PARAMWHICH_{param['_type']},") + self.current_output.append(f"\t/* flags = */ 0x{param['flags']:02X},") + self.current_output.append(f"\t/* myname = */ {myname_str},") + self.current_output.append(f"\t/* next = */ {last_param},") + if param['_type'] == 'FTypeCreator': + self.current_output.append(f"\t/* fc = */ &{param['target']},") + self.current_output.append(f"\t/* iscreator = */ {param['is_creator']}") + elif param['_type'] == 'FilePath': + self.current_output.append(f"\t/* fflags = */ {param['fflags']},") + df = json.dumps(param['default']) if param['default'] is not None else '0' + self.current_output.append(f"\t/* defaultstr = */ {df},") + self.current_output.append(f"\t/* filename = */ {param['target']},") + self.current_output.append(f"\t/* maxlen = */ {param['max_length']}") + elif param['_type'] == 'Number': + self.current_output.append(f"\t/* size = */ {param['byte_size']},") + self.current_output.append(f"\t/* fit = */ {param['fit']},") + self.current_output.append(f"\t/* lo = */ {param['minimum']},") + self.current_output.append(f"\t/* hi = */ {param['maximum']},") + self.current_output.append(f"\t/* num = */ &{param['target']}") + elif param['_type'] in ('String','Id','Sym'): + self.current_output.append(f"\t/* maxlen = */ {param['max_length']},") + self.current_output.append(f"\t/* pstring = */ {int(param['pascal'])},") + self.current_output.append(f"\t/* str = */ {param['target']}") + elif param['_type'] in ('OnOff','OffOn'): + self.current_output.append(f"\t/* var = */ &{param['target']}") + elif param['_type'] == 'Mask': + self.current_output.append(f"\t/* size = */ {param['byte_size']},") + self.current_output.append(f"\t/* ormask = */ 0x{param['or_mask']:X},") + self.current_output.append(f"\t/* andmask = */ 0x{param['and_mask']:X},") + self.current_output.append(f"\t/* num = */ &{param['target']}") + elif param['_type'] == 'Toggle': + self.current_output.append(f"\t/* size = */ {param['byte_size']},") + self.current_output.append(f"\t/* mask = */ 0x{param['mask']:X},") + self.current_output.append(f"\t/* num = */ &{param['target']}") + elif param['_type'] == 'Set': + self.current_output.append(f"\t/* size = */ {param['byte_size']},") + self.current_output.append(f"\t/* value = */ 0x{param['value']:X},") + if param['target']: + self.current_output.append(f"\t/* num = */ (char *) &{param['target']}") + else: + self.current_output.append(f"\t/* num = */ 0") + elif param['_type'] == 'SetString': + self.current_output.append(f"\t/* value = */ {json.dumps(param['value'])},") + self.current_output.append(f"\t/* pstring = */ {int(param['pascal'])},") + self.current_output.append(f"\t/* var = */ {param['target']}") + elif param['_type'] == 'Generic': + self.current_output.append(f"\t/* parse = */ &{param['function']},") + self.current_output.append(f"\t/* arg = */ (void *) {json.dumps(param['arg'])},") + help_str = json.dumps(param['help']) if ('help' in param and param['help'] is not None) else '0' + self.current_output.append(f"\t/* help = */ {help_str}") + elif param['_type'] == 'IfArg': + self.current_output.append(f"\t/* parg = */ {ia_last_parg},") + self.current_output.append(f"\t/* helpa = */ {json.dumps(param['help_a'])},") + self.current_output.append(f"\t/* pnone = */ {ia_last_pnone},") + self.current_output.append(f"\t/* helpn = */ {json.dumps(param['help_n'])}") + elif param['_type'] == 'Setting': + self.current_output.append(f"\t/* parse = */ &{param['function']},") + self.current_output.append(f"\t/* valuename = */ {json.dumps(param['value_name'])}") + self.current_output.append('};') + last_param = '(PARAM_T *) &' + param['_name'] + + return last_param + +PARAM_TYPES = { + 'FTypeCreator': 'FTYPE_T', + 'FilePath': 'FILEPATH_T', + 'Number': 'NUM_T', + 'String': 'STRING_T', + 'Id': 'STRING_T', + 'Sym': 'STRING_T', + 'OnOff': 'ONOFF_T', + 'OffOn': 'OFFON_T', + 'Mask': 'MASK_T', + 'Toggle': 'TOGGLE_T', + 'Set': 'SET_T', + 'SetString': 'SETSTRING_T', + 'Generic': 'GENERIC_T', + 'IfArg': 'IFARG_T', + 'Setting': 'SETTING_T' +} + +def build_list_flags(what): + bits = [] + if 'sub_options_exclusive' in what and what['sub_options_exclusive']: + bits.append('LISTFLAGS_EXCLUSIVE') + if 'sub_options_allow_unknowns' in what and what['sub_options_allow_unknowns']: + bits.append('LISTFLAGS_ALLOW_UNKNOWNS') + for tool in what['tools']: + if tool == 'compiler': + bits.append('LISTFLAGS_COMPILER') + elif tool == 'linker': + bits.append('LISTFLAGS_LINKER') + elif tool == 'disassembler': + bits.append('LISTFLAGS_DISASSEMBLER') + if bits: + return ' | '.join(bits) + else: + return '0' + +def build_option_flags(option, has_conflicts=False): + bits = [] + if 'global' in option and option['global']: + bits.append('OTF_GLOBAL') + if 'sticky' in option and option['sticky']: + bits.append('OTF_STICKY') + if 'cased' in option and option['cased']: + bits.append('OTF_CASED') + if 'obsolete' in option and option['obsolete']: + bits.append('OTF_OBSOLETE') + if 'substituted' in option and option['substituted']: + bits.append('OTF_SUBSTITUTED') + if 'deprecated' in option and option['deprecated']: + bits.append('OTF_DEPRECATED') + if 'ignored' in option and option['ignored']: + bits.append('OTF_IGNORED') + if 'secret' in option and option['secret']: + bits.append('OTF_SECRET') + if 'hide_default' in option and option['hide_default']: + bits.append('OTF_HIDE_DEFAULT') + if 'compatibility' in option and option['compatibility']: + bits.append('OTF_COMPATIBILITY') + if 'only_once' in option and option['only_once']: + bits.append('OTF_ONLY_ONCE') + if 'warning' in option and option['warning']: + bits.append('OTF_WARNING') + if 'can_be_negated' in option and option['can_be_negated']: + bits.append('OTF_SLFLAGS_8') + if 'can_be_negated_2' in option and option['can_be_negated_2']: + bits.append('OTF_SLFLAGS_10') + if 'can_be_negated_3' in option and option['can_be_negated_3']: + bits.append('OTF_SLFLAGS_20') + if 'meaningless' in option and option['meaningless']: + bits.append('OTF_MEANINGLESS') + + for tool in option['tools']: + if tool == 'compiler': + bits.append('OTF_TOOL_COMPILER') + elif tool == 'linker': + bits.append('OTF_TOOL_LINKER') + elif tool == 'disassembler': + bits.append('OTF_TOOL_DISASSEMBLER') + + if 'sub_options' in option: + bits.append('OTF_HAS_SUB_OPTIONS') + if 'sub_options_optional' in option and option['sub_options_optional']: + bits.append('OTF_SUB_OPTIONS_OPTIONAL') + + if 'conflict_group' in option or has_conflicts: + bits.append('OTF_HAS_CONFLICTS') + + if bits: + return ' | '.join(bits) + else: + return '0' + +with open('../../nice_opts.json', 'r') as f: + roots = json.load(f) + +oc = OptionCompiler() +for root in roots: + oc.add_root(root) diff --git a/optdump.py b/optdump.py new file mode 100644 index 0000000..b1bb42e --- /dev/null +++ b/optdump.py @@ -0,0 +1,386 @@ +import json + +''' +HOW TO GENERATE: + + +''' + +def play_with_addr(ea): + if ea == 0: + return None + + e = ida_name.get_name_expr(0, 0, ea, BADADDR) + e = e[13:-2] + return e + +class String: + name: str + value: str + + @staticmethod + def from_ea(ea): + if ea == 0: + return None + else: + s = String() + s.name = get_name(ea) + v = get_bytes(ea, 1024) + v = v[:v.find(b'\0')] + s.value = v.decode('ascii') + return s + + def encode(self): + if self.name.startswith('a'): + return self.value + else: + return dict(name=self.name, value=self.value) + +class Param: + name: str + flags: int + myname: String + + @staticmethod + def from_ea(ea): + print('reading param %08x' % ea) + which = get_wide_byte(ea) + next_ea = get_wide_dword(ea + 6) + p = PARAM_CLASSES[which]() + p.populate_from_ea(ea) + return p, next_ea + + def populate_from_ea(self, ea): + self.name = get_name(ea) + self.flags = get_wide_byte(ea + 1) + self.myname = String.from_ea(get_wide_dword(ea + 2)) + + def encode(self): + d = dict(_name=self.name, flags=self.flags) + if self.myname is not None: + d['myname'] = self.myname + return d + + @staticmethod + def list_from_ea(ea): + lst = [] + while ea != 0: + param, next_ea = Param.from_ea(ea) + lst.append(param) + ea = next_ea + return lst + +class FTypeCreatorParam(Param): + def populate_from_ea(self, ea): + super(FTypeCreatorParam, self).populate_from_ea(ea) + self.fc = play_with_addr(get_wide_dword(ea + 10)) + self.iscreator = get_wide_byte(ea + 14) + def encode(self): + d = super(FTypeCreatorParam, self).encode() + d['_type'] = 'FTypeCreator' + d['fc'] = self.fc + d['iscreator'] = self.iscreator + return d + +class FilePathParam(Param): + def populate_from_ea(self, ea): + super(FilePathParam, self).populate_from_ea(ea) + self.fflags = get_wide_byte(ea + 10) + self.defaultstr = String.from_ea(get_wide_dword(ea + 11)) + self.filename = play_with_addr(get_wide_dword(ea + 15)) + self.maxlen = get_wide_dword(ea + 19) + def encode(self): + d = super(FilePathParam, self).encode() + d['_type'] = 'FilePath' + d['fflags'] = self.fflags + d['defaultstr'] = self.defaultstr + d['filename'] = self.filename + d['maxlen'] = self.maxlen + return d + +class NumberParam(Param): + def populate_from_ea(self, ea): + super(NumberParam, self).populate_from_ea(ea) + self.size = get_wide_byte(ea + 10) + self.fit = get_wide_byte(ea + 11) + self.lo = get_wide_dword(ea + 12) + self.hi = get_wide_dword(ea + 16) + self.num = play_with_addr(get_wide_dword(ea + 20)) + def encode(self): + d = super(NumberParam, self).encode() + d['_type'] = 'Number' + d['size'] = self.size + d['fit'] = self.fit + d['lo'] = self.lo + d['hi'] = self.hi + d['num'] = self.num + return d + +class StringParam(Param): + def populate_from_ea(self, ea): + super(StringParam, self).populate_from_ea(ea) + self.maxlen = get_wide_word(ea + 10) + self.pstring = get_wide_byte(ea + 12) + self.str = play_with_addr(get_wide_dword(ea + 13)) + def encode(self): + d = super(StringParam, self).encode() + d['_type'] = 'String' + d['maxlen'] = self.maxlen + d['pstring'] = self.pstring + d['str'] = self.str + return d + +class IdParam(StringParam): + def populate_from_ea(self, ea): + super(IdParam, self).populate_from_ea(ea) + def encode(self): + d = super(IdParam, self).encode() + d['_type'] = 'Id' + return d + +class SymParam(StringParam): + def populate_from_ea(self, ea): + super(SymParam, self).populate_from_ea(ea) + def encode(self): + d = super(SymParam, self).encode() + d['_type'] = 'Sym' + return d + +class OnOffParam(Param): + def populate_from_ea(self, ea): + super(OnOffParam, self).populate_from_ea(ea) + self.var = play_with_addr(get_wide_dword(ea + 10)) + def encode(self): + d = super(OnOffParam, self).encode() + d['_type'] = 'OnOff' + d['var'] = self.var + return d + +class OffOnParam(Param): + def populate_from_ea(self, ea): + super(OffOnParam, self).populate_from_ea(ea) + self.var = play_with_addr(get_wide_dword(ea + 10)) + def encode(self): + d = super(OffOnParam, self).encode() + d['_type'] = 'OffOn' + d['var'] = self.var + return d + +class MaskParam(Param): + def populate_from_ea(self, ea): + super(MaskParam, self).populate_from_ea(ea) + self.size = get_wide_byte(ea + 10) + self.ormask = get_wide_dword(ea + 11) + self.andmask = get_wide_dword(ea + 15) + self.num = play_with_addr(get_wide_dword(ea + 19)) + def encode(self): + d = super(MaskParam, self).encode() + d['_type'] = 'Mask' + d['size'] = self.size + d['ormask'] = self.ormask + d['andmask'] = self.andmask + d['num'] = self.num + return d + +class ToggleParam(Param): + def populate_from_ea(self, ea): + super(ToggleParam, self).populate_from_ea(ea) + self.size = get_wide_byte(ea + 10) + self.mask = get_wide_dword(ea + 11) + self.num = play_with_addr(get_wide_dword(ea + 15)) + def encode(self): + d = super(ToggleParam, self).encode() + d['_type'] = 'Toggle' + d['size'] = self.size + d['mask'] = self.mask + d['num'] = self.num + return d + +class SetParam(Param): + def populate_from_ea(self, ea): + super(SetParam, self).populate_from_ea(ea) + self.size = get_wide_byte(ea + 10) + self.value = get_wide_dword(ea + 11) + self.num = play_with_addr(get_wide_dword(ea + 15)) + def encode(self): + d = super(SetParam, self).encode() + d['_type'] = 'Set' + d['size'] = self.size + d['value'] = self.value + d['num'] = self.num + return d + +class SetStringParam(Param): + def populate_from_ea(self, ea): + super(SetStringParam, self).populate_from_ea(ea) + self.value = get_wide_dword(ea + 10) + self.pstring = get_wide_byte(ea + 14) + self.var = play_with_addr(get_wide_dword(ea + 15)) + def encode(self): + d = super(SetStringParam, self).encode() + d['_type'] = 'SetString' + d['value'] = self.value + d['pstring'] = self.pstring + d['var'] = self.var + return d + +class GenericParam(Param): + def populate_from_ea(self, ea): + super(GenericParam, self).populate_from_ea(ea) + self.parse = play_with_addr(get_wide_dword(ea + 10)) + # self.var = play_with_addr(get_wide_dword(ea + 14)) + var = get_wide_dword(ea + 14) + if get_name(var).startswith('a'): + self.var = String.from_ea(var) + else: + self.var = var + self.help = String.from_ea(get_wide_dword(ea + 18)) + def encode(self): + d = super(GenericParam, self).encode() + d['_type'] = 'Generic' + d['parse'] = self.parse + d['var'] = self.var + d['help'] = self.help + return d + +class IfArgParam(Param): + def populate_from_ea(self, ea): + super(IfArgParam, self).populate_from_ea(ea) + self.parg = Param.list_from_ea(get_wide_dword(ea + 10)) + self.helpa = String.from_ea(get_wide_dword(ea + 14)) + self.pnone = Param.list_from_ea(get_wide_dword(ea + 18)) + self.helpn = String.from_ea(get_wide_dword(ea + 22)) + def encode(self): + d = super(IfArgParam, self).encode() + d['_type'] = 'IfArg' + d['parg'] = self.parg + d['helpa'] = self.helpa + d['pnone'] = self.pnone + d['helpn'] = self.helpn + return d + +class SettingParam(Param): + def populate_from_ea(self, ea): + super(SettingParam, self).populate_from_ea(ea) + self.parse = play_with_addr(get_wide_dword(ea + 10)) + self.valuename = String.from_ea(get_wide_dword(ea + 14)) + def encode(self): + d = super(SettingParam, self).encode() + d['_type'] = 'Setting' + d['parse'] = self.parse + d['valuename'] = self.valuename + return d + +PARAM_CLASSES = [ + Param, + FTypeCreatorParam, + FilePathParam, + NumberParam, + StringParam, + IdParam, + SymParam, + OnOffParam, + OffOnParam, + MaskParam, + ToggleParam, + SetParam, + SetStringParam, + GenericParam, + IfArgParam, + SettingParam +] + +class Option: + name: str + names: String + avail: int + sub: 'OptionList' + conflicts: 'OptionList' + help: String + + @staticmethod + def from_ea(ea): + if ea == 0: + return None + else: + o = Option() + o.name = get_name(ea) + o.names = String.from_ea(get_wide_dword(ea)) + o.avail = get_wide_dword(ea + 4) + o.param = Param.list_from_ea(get_wide_dword(ea + 8)) + o.sub = OptionList.from_ea(get_wide_dword(ea + 12)) + o.conflicts = OptionList.from_ea(get_wide_dword(ea + 16), shallow=True) + o.help = String.from_ea(get_wide_dword(ea + 20)) + return o + + @staticmethod + def read_list(list_ea, shallow=False): + lst = [] + while True: + ea = get_wide_dword(list_ea) + if ea == 0: + break + if shallow: + lst.append(get_name(ea)) + else: + lst.append(Option.from_ea(ea)) + list_ea += 4 + return lst + + def encode(self): + d = dict(_name=self.name, names=self.names, avail=self.avail, param=self.param, help=self.help) + if self.sub is not None: + d['sub'] = self.sub + if self.conflicts is not None: + d['conflicts'] = self.conflicts + return d + +class OptionList: + @staticmethod + def from_ea(ea, shallow=False): + if ea == 0: + return None + else: + ol = OptionList() + ol.name = get_name(ea) + ol.help = String.from_ea(get_wide_dword(ea)) + ol.flags = get_wide_dword(ea + 4) + list_ea = get_wide_dword(ea + 8) + if list_ea != 0: + ol.list_name = get_name(list_ea) + ol.list = Option.read_list(list_ea, shallow) + return ol + + def dump(self): + print(f'OptionList({self.name})') + + def encode(self): + d = dict(_name=self.name, flags=self.flags, _list_name=self.list_name, list=self.list) + if self.help is not None: + d['help'] = self.help + return d + +def get_optlist_eas(): + ea = get_name_ea_simple('_optLists') + lists = [] + while True: + list_ea = get_wide_dword(ea) + if list_ea == 0: + break + # list_name = get_name(list_ea) + lists.append(list_ea) + ea += 4 + return lists + +optlists = [] +for ea in get_optlist_eas(): + optlists.append(OptionList.from_ea(ea)) + +def enc(obj): + if hasattr(obj, 'encode'): + return obj.encode() + else: + raise TypeError + +with open('/Users/ash/src/mwcc/opts.json', 'w') as f: + json.dump(optlists, f, sort_keys=True, indent=4, default=enc) diff --git a/osx_build.sh b/osx_build.sh new file mode 100755 index 0000000..7847f47 --- /dev/null +++ b/osx_build.sh @@ -0,0 +1,89 @@ +set -e +export MWCIncludes=/usr/include + +#rm objs/* + +MWC_FLAGS="-c -g -opt l=4,noschedule,speed -enum min -Iincludes -Isdk_hdrs -w all,nounused -wchar_t on -bool off -Cpp_exceptions off" + +#~/bin/mwccppc $MWC_FLAGS -o objs/WarningHelpers.o command_line/C++_Parser/Src/Library/WarningHelpers.c +# +#~/bin/mwccppc $MWC_FLAGS -o objs/CLCompilerLinkerDropin_V10.o command_line/CmdLine/Src/Callbacks/CLCompilerLinkerDropin_V10.cpp +#~/bin/mwccppc $MWC_FLAGS -o objs/CLDropinCallbacks_V10.o command_line/CmdLine/Src/Callbacks/CLDropinCallbacks_V10.cpp +#~/bin/mwccppc $MWC_FLAGS -o objs/CLParserCallbacks_V1.o command_line/CmdLine/Src/Callbacks/CLParserCallbacks_V1.cpp +# +#~/bin/mwccppc $MWC_FLAGS -o objs/CLStaticMain.o command_line/CmdLine/Src/Clients/CLStaticMain.c +#~/bin/mwccppc $MWC_FLAGS -o objs/ClientGlue.o command_line/CmdLine/Src/Clients/ClientGlue.c +# +#~/bin/mwccppc $MWC_FLAGS -o objs/CLErrors.o command_line/CmdLine/Src/Envir/CLErrors.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CLIO.o command_line/CmdLine/Src/Envir/CLIO.c +# +#~/bin/mwccppc $MWC_FLAGS -o objs/ErrMgr.o command_line/CmdLine/Src/MacEmul/ErrMgr.c +#~/bin/mwccppc $MWC_FLAGS -o objs/Files.o command_line/CmdLine/Src/MacEmul/Files.c +#~/bin/mwccppc $MWC_FLAGS -o objs/LowMem.o command_line/CmdLine/Src/MacEmul/LowMem.c +#~/bin/mwccppc $MWC_FLAGS -o objs/Memory.o command_line/CmdLine/Src/MacEmul/Memory.c +#~/bin/mwccppc $MWC_FLAGS -o objs/Resources.o command_line/CmdLine/Src/MacEmul/Resources.c +#~/bin/mwccppc $MWC_FLAGS -o objs/ResourceStrings.o command_line/CmdLine/Src/MacEmul/ResourceStrings.c +#~/bin/mwccppc $MWC_FLAGS -o objs/TextUtils.o command_line/CmdLine/Src/MacEmul/TextUtils.c +# +#~/bin/mwccppc $MWC_FLAGS -o objs/FileHandles.o command_line/CmdLine/Src/OSLib/FileHandles.c +#~/bin/mwccppc $MWC_FLAGS -o objs/Generic.o command_line/CmdLine/Src/OSLib/Generic.c +#~/bin/mwccppc $MWC_FLAGS -o objs/MacFileTypes.o command_line/CmdLine/Src/OSLib/MacFileTypes.c +#~/bin/mwccppc $MWC_FLAGS -o objs/MacSpecs.o command_line/CmdLine/Src/OSLib/MacSpecs.c +#~/bin/mwccppc $MWC_FLAGS -o objs/MemUtils.o command_line/CmdLine/Src/OSLib/MemUtils.c +#~/bin/mwccppc $MWC_FLAGS -o objs/Posix.o command_line/CmdLine/Src/OSLib/Posix.c +#~/bin/mwccppc $MWC_FLAGS -o objs/StringExtras.o command_line/CmdLine/Src/OSLib/StringExtras.c +#~/bin/mwccppc $MWC_FLAGS -o objs/StringUtils.o command_line/CmdLine/Src/OSLib/StringUtils.c +# +#~/bin/mwccppc $MWC_FLAGS -o objs/CLPlugins.o command_line/CmdLine/Src/Plugins/CLPlugins.c +# +#~/bin/mwccppc $MWC_FLAGS -o objs/CLAccessPaths.o command_line/CmdLine/Src/Project/CLAccessPaths.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CLFiles.o command_line/CmdLine/Src/Project/CLFiles.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CLOverlays.o command_line/CmdLine/Src/Project/CLOverlays.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CLProj.o command_line/CmdLine/Src/Project/CLProj.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CLSegs.o command_line/CmdLine/Src/Project/CLSegs.c +# +#~/bin/mwccppc $MWC_FLAGS -o objs/CLBrowser.o command_line/CmdLine/Src/CLBrowser.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CLDependencies.o command_line/CmdLine/Src/CLDependencies.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CLFileOps.o command_line/CmdLine/Src/CLFileOps.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CLIncludeFileCache.o command_line/CmdLine/Src/CLIncludeFileCache.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CLLicenses.o command_line/CmdLine/Src/CLLicenses.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CLLoadAndCache.o command_line/CmdLine/Src/CLLoadAndCache.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CLMain.o command_line/CmdLine/Src/CLMain.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CLPluginRequests.o command_line/CmdLine/Src/CLPluginRequests.cpp +#~/bin/mwccppc $MWC_FLAGS -o objs/CLPrefs.o command_line/CmdLine/Src/CLPrefs.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CLTarg.o command_line/CmdLine/Src/CLTarg.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CLToolExec.o command_line/CmdLine/Src/CLToolExec.c +#~/bin/mwccppc $MWC_FLAGS -o objs/CLWriteObjectFile.o command_line/CmdLine/Src/CLWriteObjectFile.c +#~/bin/mwccppc $MWC_FLAGS -o objs/uFileTypeMappings.o command_line/CmdLine/Src/uFileTypeMappings.c +# +#~/bin/mwccppc $MWC_FLAGS -o objs/ParserGlue-mach-ppc-cc.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-cc.c +#~/bin/mwccppc $MWC_FLAGS -o objs/TargetWarningHelpers-ppc-cc.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-cc.c +# +#~/bin/mwccppc $MWC_FLAGS -o objs/cc-mach-ppc.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.c +#~/bin/mwccppc $MWC_FLAGS -o objs/libimp-mach-ppc.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/libimp-mach-ppc.c +# +#~/bin/mwccppc $MWC_FLAGS -o objs/cc-mach-ppc-mw.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Static/cc-mach-ppc-mw.c +# +#~/bin/mwccppc $MWC_FLAGS -o objs/Arguments.o unsorted/Arguments.c +#~/bin/mwccppc $MWC_FLAGS -o objs/Help.o unsorted/Help.c +#~/bin/mwccppc $MWC_FLAGS -o objs/IO.o unsorted/IO.c +#~/bin/mwccppc $MWC_FLAGS -o objs/OptimizerHelpers.o unsorted/OptimizerHelpers.c +#~/bin/mwccppc $MWC_FLAGS -o objs/Option.o unsorted/Option.c +#~/bin/mwccppc $MWC_FLAGS -o objs/Parameter.o unsorted/Parameter.c +#~/bin/mwccppc $MWC_FLAGS -o objs/ParserErrors.o unsorted/ParserErrors.c +#~/bin/mwccppc $MWC_FLAGS -o objs/ParserFace.o unsorted/ParserFace.c +#~/bin/mwccppc $MWC_FLAGS -o objs/ParserHelpers.o unsorted/ParserHelpers.c +#~/bin/mwccppc $MWC_FLAGS -o objs/ParserHelpers-cc.o unsorted/ParserHelpers-cc.c +#~/bin/mwccppc $MWC_FLAGS -o objs/Projects.o unsorted/Projects.c +#~/bin/mwccppc $MWC_FLAGS -o objs/StaticParserGlue.o unsorted/StaticParserGlue.c +#~/bin/mwccppc $MWC_FLAGS -o objs/Targets.o unsorted/Targets.c +#~/bin/mwccppc $MWC_FLAGS -o objs/TargetOptimizer-ppc-mach.o unsorted/TargetOptimizer-ppc-mach.c +#~/bin/mwccppc $MWC_FLAGS -o objs/ToolHelpers.o unsorted/ToolHelpers.c +#~/bin/mwccppc $MWC_FLAGS -o objs/ToolHelpers-cc.o unsorted/ToolHelpers-cc.c +#~/bin/mwccppc $MWC_FLAGS -o objs/uContext1.o unsorted/uContext1.cpp +#~/bin/mwccppc $MWC_FLAGS -o objs/uContextCL.o unsorted/uContextCL.cpp +#~/bin/mwccppc $MWC_FLAGS -o objs/uContextParser.o unsorted/uContextParser.cpp +#~/bin/mwccppc $MWC_FLAGS -o objs/uContextSecret.o unsorted/uContextSecret.cpp +#~/bin/mwccppc $MWC_FLAGS -o objs/uCOS.o unsorted/uCOS.c +#~/bin/mwccppc $MWC_FLAGS -o objs/uLibImporter.o unsorted/uLibImporter.c +#~/bin/mwccppc $MWC_FLAGS -o objs/Utils.o unsorted/Utils.c diff --git a/sdk_hdrs/CompilerMapping.h b/sdk_hdrs/CompilerMapping.h index 30ee355..c929a74 100755 --- a/sdk_hdrs/CompilerMapping.h +++ b/sdk_hdrs/CompilerMapping.h @@ -1 +1 @@ -/* * CompilerMapping.h - File Type & Extension => Compiler Mapping for Metrowerks CodeWarriorª * * Copyright © 1995 Metrowerks, Inc. All rights reserved. * */ #ifndef __COMPILERMAPPING_H__ #define __COMPILERMAPPING_H__ #ifdef __MWERKS__ # pragma once #endif #ifndef __CWPLUGINS_H__ #include "CWPlugins.h" #endif #ifdef __MWERKS__ #pragma options align=mac68k #endif #ifdef _MSC_VER #pragma pack(push,2) #endif #ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus const CWDataType Lang_C_CPP = CWFOURCHAR('c','+','+',' '); const CWDataType Lang_Pascal = CWFOURCHAR('p','a','s','c'); const CWDataType Lang_Rez = CWFOURCHAR('r','e','z',' '); const CWDataType Lang_Java = CWFOURCHAR('j','a','v','a'); const CWDataType Lang_MISC = CWFOURCHAR('\?','\?','\?','\?'); #else #define Lang_C_CPP CWFOURCHAR('c','+','+',' ') #define Lang_Pascal CWFOURCHAR('p','a','s','c') #define Lang_Rez CWFOURCHAR('r','e','z',' ') #define Lang_Java CWFOURCHAR('j','a','v','a') #define Lang_MISC CWFOURCHAR('\?','\?','\?','\?') #endif /* Compiler flags, as used in member dropinflags of struct DropInFlags returned by compilers */ enum { kGeneratescode = 1L << 31, /* this compiler generates code */ kGeneratesrsrcs = 1L << 30, /* this compiler generates resources */ kCanpreprocess = 1L << 29, /* this compiler can accept a Preprocess request */ kCanprecompile = 1L << 28, /* this compiler can accept a Precompile request */ kIspascal = 1L << 27, /* this is the pascal compiler */ kCanimport = 1L << 26, /* this compiler needs the "Import Weak" popup */ kCandisassemble = 1L << 25, /* this compiler can disassemble */ kPersistent = 1L << 24, /* keep the compiler resident except on context switches*/ kCompAllowDupFileNames = 1L << 23, /* allow multiple project files with the same name */ kCompMultiTargAware = 1L << 22, /* the compiler can be used with multiple targets */ kIsMPAware = 1L << 21, /* the compiler can be run in an MP thread */ kCompUsesTargetStorage = 1L << 20, /* the compiler keeps storage per target */ kCompEmitsOwnBrSymbols = 1L << 19, /* browser info includes compiler-specific symbols */ kCompAlwaysReload = 1L << 18, /* always reload the compiler before request */ kCompRequiresProjectBuildStartedMsg = 1L << 17, /* Compiler listens for project build started messages */ kCompRequiresTargetBuildStartedMsg = 1L << 16, /* Compiler listens for target build started messages */ kCompRequiresSubProjectBuildStartedMsg = 1L << 15, /* Compiler listens for Sub project build started messages */ kCompRequiresFileListBuildStartedMsg = 1L << 14, /* Compiler listens for filelist build started messages */ kCompReentrant = 1L << 13, /* Compiler can use re-entrant DropIn and is re-entry safe */ kCompSavesDbgPreprocess = 1 << 12, /* Compiler will save preprocessed files for debugging needs */ kCompRequiresTargetCompileStartedMsg = 1 << 11 /* Compiler listens for target compile started/ended messages */ /* remaining flags are reserved for future use and should be zero-initialized */ }; /* Compiler mapping flags, used in CompilerMapping.flags & CWExtensionMapping.flags */ typedef unsigned long CompilerMappingFlags; enum { kPrecompile = 1L << 31, /* should this file type be Precompiled? */ kLaunchable = 1L << 30, /* can this file type be double-clicked on? */ kRsrcfile = 1L << 29, /* does this file type contain resources for linking? */ kIgnored = 1L << 28 /* should files of this type be ignored during Make? */ /* remaining flags are reserved for future use and should be zero-initialized */ }; /* Format of data in 'EMap' resource, or as returned by a compiler's */ /* GetExtensionMapping entry point */ typedef struct CWExtensionMapping { CWDataType type; /* MacOS file type, e.g. 'TEXT' or 0 */ char extension[32]; /* file extension, e.g. .c/.cp/.pch or "" */ CompilerMappingFlags flags; /* see above */ char editlanguage[32]; /* edit language or "" to use default language for plugin */ } CWExtensionMapping; #define kCurrentCWExtMapListVersion 2 #define kCurrentCWExtMapListResourceVersion 2 typedef struct CWExtMapList { short version; short nMappings; CWExtensionMapping* mappings; } CWExtMapList; /* Format of data returned by GetTargetList entry point */ #define kCurrentCWTargetListVersion 1 #define kCurrentCWTargetListResourceVersion 1 typedef struct CWTypeList { short count; CWDataType items[1]; } CW_CPUList, CW_OSList; typedef struct CWTargetList { short version; short cpuCount; CWDataType* cpus; short osCount; CWDataType* oss; } CWTargetList; typedef struct CWTargetListResource { short version; CW_CPUList cpus; CW_OSList oss; } CWTargetListResource; #ifdef __cplusplus } #endif #ifdef _MSC_VER #pragma pack(pop,2) #endif #ifdef __MWERKS__ #pragma options align=reset #endif #endif /* __COMPILERMAPPING_H__ */ \ No newline at end of file +/* * CompilerMapping.h - File Type & Extension => Compiler Mapping for Metrowerks CodeWarrior� * * Copyright � 1995 Metrowerks, Inc. All rights reserved. * */ #ifndef __COMPILERMAPPING_H__ #define __COMPILERMAPPING_H__ #ifdef __MWERKS__ # pragma once #endif #ifndef __CWPLUGINS_H__ #include "CWPlugins.h" #endif #ifdef __MWERKS__ #pragma options align=mac68k #endif #ifdef _MSC_VER #pragma pack(push,2) #endif #ifdef __cplusplus extern "C" { #endif #ifdef __cplusplus const CWDataType Lang_C_CPP = CWFOURCHAR('c','+','+',' '); const CWDataType Lang_Pascal = CWFOURCHAR('p','a','s','c'); const CWDataType Lang_Rez = CWFOURCHAR('r','e','z',' '); const CWDataType Lang_Java = CWFOURCHAR('j','a','v','a'); const CWDataType Lang_MISC = CWFOURCHAR('\?','\?','\?','\?'); #else #define Lang_C_CPP CWFOURCHAR('c','+','+',' ') #define Lang_Pascal CWFOURCHAR('p','a','s','c') #define Lang_Rez CWFOURCHAR('r','e','z',' ') #define Lang_Java CWFOURCHAR('j','a','v','a') #define Lang_MISC CWFOURCHAR('\?','\?','\?','\?') #endif /* Compiler flags, as used in member dropinflags of struct DropInFlags returned by compilers */ enum { kGeneratescode = 1L << 31, /* this compiler generates code */ kGeneratesrsrcs = 1L << 30, /* this compiler generates resources */ kCanpreprocess = 1L << 29, /* this compiler can accept a Preprocess request */ kCanprecompile = 1L << 28, /* this compiler can accept a Precompile request */ kIspascal = 1L << 27, /* this is the pascal compiler */ kCanimport = 1L << 26, /* this compiler needs the "Import Weak" popup */ kCandisassemble = 1L << 25, /* this compiler can disassemble */ kPersistent = 1L << 24, /* keep the compiler resident except on context switches*/ kCompAllowDupFileNames = 1L << 23, /* allow multiple project files with the same name */ kCompMultiTargAware = 1L << 22, /* the compiler can be used with multiple targets */ kIsMPAware = 1L << 21, /* the compiler can be run in an MP thread */ kCompUsesTargetStorage = 1L << 20, /* the compiler keeps storage per target */ kCompEmitsOwnBrSymbols = 1L << 19, /* browser info includes compiler-specific symbols */ kCompAlwaysReload = 1L << 18, /* always reload the compiler before request */ kCompRequiresProjectBuildStartedMsg = 1L << 17, /* Compiler listens for project build started messages */ kCompRequiresTargetBuildStartedMsg = 1L << 16, /* Compiler listens for target build started messages */ kCompRequiresSubProjectBuildStartedMsg = 1L << 15, /* Compiler listens for Sub project build started messages */ kCompRequiresFileListBuildStartedMsg = 1L << 14, /* Compiler listens for filelist build started messages */ kCompReentrant = 1L << 13, /* Compiler can use re-entrant DropIn and is re-entry safe */ kCompSavesDbgPreprocess = 1 << 12, /* Compiler will save preprocessed files for debugging needs */ kCompRequiresTargetCompileStartedMsg = 1 << 11 /* Compiler listens for target compile started/ended messages */ /* remaining flags are reserved for future use and should be zero-initialized */ }; /* Compiler mapping flags, used in CompilerMapping.flags & CWExtensionMapping.flags */ typedef unsigned long CompilerMappingFlags; enum { kPrecompile = 1L << 31, /* should this file type be Precompiled? */ kLaunchable = 1L << 30, /* can this file type be double-clicked on? */ kRsrcfile = 1L << 29, /* does this file type contain resources for linking? */ kIgnored = 1L << 28 /* should files of this type be ignored during Make? */ /* remaining flags are reserved for future use and should be zero-initialized */ }; /* Format of data in 'EMap' resource, or as returned by a compiler's */ /* GetExtensionMapping entry point */ typedef struct CWExtensionMapping { CWDataType type; /* MacOS file type, e.g. 'TEXT' or 0 */ char extension[32]; /* file extension, e.g. .c/.cp/.pch or "" */ CompilerMappingFlags flags; /* see above */ } CWExtensionMapping; #define kCurrentCWExtMapListVersion 1 #define kCurrentCWExtMapListResourceVersion 1 typedef struct CWExtMapList { short version; short nMappings; CWExtensionMapping* mappings; } CWExtMapList; /* Format of data returned by GetTargetList entry point */ #define kCurrentCWTargetListVersion 1 #define kCurrentCWTargetListResourceVersion 1 typedef struct CWTypeList { short count; CWDataType items[1]; } CW_CPUList, CW_OSList; typedef struct CWTargetList { short version; short cpuCount; CWDataType* cpus; short osCount; CWDataType* oss; } CWTargetList; typedef struct CWTargetListResource { short version; CW_CPUList cpus; CW_OSList oss; } CWTargetListResource; #ifdef __cplusplus } #endif #ifdef _MSC_VER #pragma pack(pop,2) #endif #ifdef __MWERKS__ #pragma options align=reset #endif #endif /* __COMPILERMAPPING_H__ */ \ No newline at end of file diff --git a/setup.sh b/setup.sh index cdeab68..5c2db99 100644 --- a/setup.sh +++ b/setup.sh @@ -1,3 +1,10 @@ #export MWCIncludes=/Applications/Metrowerks\ CodeWarrior\ 7.0/Metrowerks\ CodeWarrior/MacOS\ Support/Universal/Interfaces/CIncludes:/Applications/Metrowerks\ CodeWarrior\ 7.0/Metrowerks\ CodeWarrior/MSL/MSL_C/MSL_Common/Include -export MWCIncludes=/usr/include +export MWCIncludes=/usr/include:/Applications/Metrowerks\ CodeWarrior\ 7.0/Metrowerks\ CodeWarrior/MSL/MSL_C/MSL_Common/Include:/Applications/Metrowerks\ CodeWarrior\ 7.0/Metrowerks\ CodeWarrior/MSL/MSL_C/MSL_MacOS/Include:/Applications/Metrowerks\ CodeWarrior\ 7.0/Metrowerks\ CodeWarrior/MSL/MSL_C++/MSL_Common/Include +export MWLibraries=libs:/Applications/Metrowerks\ CodeWarrior\ 7.0/Metrowerks\ CodeWarrior/MacOS\ X\ Support/Libraries/Runtime/Libs:/Applications/Metrowerks\ CodeWarrior\ 7.0/Metrowerks\ CodeWarrior/MSL/MSL_C++/MSL_MacOS/Lib/Mach-O:/usr/lib:/ +export MWLibraryFiles=MSL_Runtime_Mach-O.a:MSL_C++_Mach-O.a +export MWFrameworkPaths=/System/Library/Frameworks +export MWFrameworkVersions=System #export MWCIncludes=/Applications/Metrowerks\ CodeWarrior\ 7.0/Metrowerks\ CodeWarrior/MacOS\ X\ Support/MacHeaders\ Mach-O + +# the defaults break on Tiger haha +export MWFrameworkVersions="" diff --git a/unsorted/Arguments.c b/unsorted/Arguments.c new file mode 100644 index 0000000..c427a5a --- /dev/null +++ b/unsorted/Arguments.c @@ -0,0 +1,591 @@ +#include "parser.h" + +char compat; +char *MAINOPTCHAR; +char *FIRSTARGCHAR; +char *SEPOPTSTR; +char SEPOPTCHAR; +char SEP1; +char SEP2; +char SEP3; +char RESPFILECHAR; +char *RESPFILESTR; +static ArgToken *argtoks; +static int numargtoks; +static int maxargtoks; +unsigned char parserDebug; +static unsigned char in_response_file; +static int margc; +static int margind; +static char **margv; +static OSFileHandle respfilehandle; +static char *respfile; +static char *respfilestart; +static unsigned long respfilesize; +static int scantok; +anon0_50 linkargs; +anon0_50 prelinkargs; +anon0_50 postlinkargs; + +static void Arg_AddToken(short val, char *text); +static void Arg_Setup(int argc, char **argv); +static void Arg_SkipRespFileWS(); +static unsigned char Arg_OpenRespFile(const char *name); +static void Arg_CloseRespFile(); +static char *Arg_GetRespFileToken(); +static char *Arg_GetNext(unsigned char allow_resp); +static unsigned char Arg_GotMore(); +static void Arg_Parse(); +static void Arg_GrowArgs(anon0_50 *ta); +static void Arg_GrowArg(anon0_50 *ta, char *txt); + +static void Arg_AddToken(short val, char *text) { + ArgToken *cur; + ArgToken *prev; + ArgToken *pprev; + ArgToken *ppprev; + ArgToken *pppprev; + + if (numargtoks > 0) + prev = &argtoks[numargtoks - 1]; + else + prev = 0; + + if (prev && prev->val == ATK_ARG && prev->text[0] == 0) { + pppprev = ppprev = pprev = 0; + if (numargtoks > 3) + pppprev = &argtoks[numargtoks - 4]; + if (numargtoks > 2) + ppprev = &argtoks[numargtoks - 3]; + if (numargtoks > 1) + pprev = &argtoks[numargtoks - 2]; + + if (pprev) { + if ((int) val == ATK_ARG_END && (pprev->val == ATK_COMMA || pprev->val == ATK_EQUALS) && (ppprev->val != ATK_ARG || pppprev->val != ATK_OPTION)) { + if (parserDebug) + printf("Coalescing args with '%s'\n", Arg_GetTokenName(pprev)); + val = pprev->val; + numargtoks -= 2; + } else if (pprev->val == ATK_ARG_END && ((int) val == ATK_COMMA || (int) val == ATK_EQUALS)) { + if (parserDebug) + printf("Coalescing args, removing '%s'\n", Arg_GetTokenName(pprev)); + numargtoks -= 2; + } + } + } + + if (numargtoks >= maxargtoks) { + argtoks = (ArgToken *) xrealloc("argument list", argtoks, sizeof(ArgToken) * (maxargtoks + 16)); + maxargtoks += 16; + } + + cur = &argtoks[numargtoks]; + cur->val = val; + if (text) + cur->text = xstrdup(text); + else + cur->text = 0; + numargtoks++; +} + +static void Arg_Setup(int argc, char **argv) { + in_response_file = 0; + respfile = 0; + margc = argc; + margv = argv; + margind = 1; +} + +static void Arg_SkipRespFileWS() { +restart: + while (respfile[0] && isspace(respfile[0])) + ++respfile; + + if (respfile[0] == '\\' && respfile[1] == '#') { + ++respfile; + return; + } + + if (respfile[0] == '#') { + if ((respfile > respfilestart) ? (respfile[-1] != '\\') : 1) { + while (respfile[0] && respfile[0] != 10 && respfile[0] != 13) + ++respfile; + + while (respfile[0] == 13 || respfile[0] == 10) + ++respfile; + + goto restart; + } + } +} + +static unsigned char Arg_OpenRespFile(const char *name) { + struct OSSpec spec; + int err; + + if ( + (err = OS_MakeFileSpec(name, &spec)) + || (err = OS_NewFileHandle(&spec, 0, 0, &respfilehandle)) + || (err = OS_AppendHandle(&respfilehandle.hand, "", 1)) + || (err = OS_LockFileHandle(&respfilehandle, &respfile, &respfilesize)) + ) { + CLPOSAlert(CLPStr74, (short) err, "response ", name); + return 0; + } else { + respfilestart = respfile; + Arg_SkipRespFileWS(); + in_response_file = 1; + return 1; + } +} + +static void Arg_CloseRespFile() { + in_response_file = 0; + OS_FreeFileHandle(&respfilehandle); +} + +static char *Arg_GetRespFileToken() { + char *start; + char *ptr; + int quoting; + + quoting = 0; + if (respfile[0] == 0) + return 0; + + start = ptr = respfile; + while (respfile[0]) { + if (!quoting && isspace(respfile[0])) + break; + + if (respfile[0] == '"') { + quoting = !quoting; + respfile++; + } else if (respfile[0] == '\\' && respfile[1] == '"') { + *ptr = '"'; + respfile += 2; + ptr++; + } else { + *(ptr++) = *(respfile++); + } + } + + if (respfile[0]) + Arg_SkipRespFileWS(); + *ptr = 0; + return start; +} + +static char *Arg_GetNext(unsigned char allow_resp) { + char *ret; + int rfclen; + char *rfcequ; + +restart: + if (!in_response_file) { + rfclen = 1; + ret = margv[margind++]; + if (ret[0] == '\\' && ret[1] == RESPFILECHAR) { + ret++; + } else if (allow_resp) { + if (ret[0] == RESPFILECHAR || (RESPFILESTR[0] && !ustrncmp(ret, RESPFILESTR, rfclen = strlen(RESPFILESTR))) && ret[rfclen]) { + rfcequ = strchr(ret + rfclen, '='); + if (rfcequ) + rfclen = (rfcequ + 1) - ret; + if (Arg_OpenRespFile(ret + rfclen)) + goto restart; + ret = 0; + } + } + } else { + ret = Arg_GetRespFileToken(); + if (!ret) { + Arg_CloseRespFile(); + goto restart; + } + } + + if (parserDebug) + fprintf(stderr, "Got arg = '%s'\n", ret ? ret : ""); + + return ret; +} + +static unsigned char Arg_GotMore() { + if (!in_response_file) + return margind < margc; + else if (respfile[0]) + return 1; + else + return margind < margc; +} + +static void Arg_Parse() { + unsigned char isOpt; + unsigned char isList; + char *arg; + char *argstart; + char buffer[4096]; + char *bufptr; + char ch; + + isOpt = 0; + isList = 0; + while (Arg_GotMore()) { + argstart = arg = Arg_GetNext(1); + if (!arg) + break; + + bufptr = buffer; + buffer[0] = 0; + isList = 0; + + if (arg[0] && arg[1] && strchr(MAINOPTCHAR, arg[0])) { + if (isOpt) + Arg_AddToken(ATK_ARG_END, 0); + buffer[0] = arg[1]; + buffer[1] = 0; + isOpt = 1; + isList = 0; + bufptr++; + arg += 2; + } else { + isOpt = 0; + } + + while (arg && arg[0]) { + ch = arg[0]; + if (arg[0] == '\\' && (arg[1] == SEP1 || arg[1] == SEP2 || arg[1] == SEP3)) { + ch = 0x80 | *(++arg); + } else if (compat == 1 && arg[0] == ':' && arg[1] == '\\') { + ch |= 0x80; + } + + if (ch != SEP1 && ch != SEP2 && ch != SEP3) { + if ((ch & 0x7F) == SEP1 || (ch & 0x7F) == SEP2 || (ch & 0x7F) == SEP3) + ch &= 0x7F; + *(bufptr++) = ch; + if (bufptr >= &buffer[sizeof(buffer)]) { + CLPReportError(CLPStr2, argstart, argstart + strlen(argstart) - 15, sizeof(buffer)); + } + *bufptr = 0; + } else { + if (isOpt) { + Arg_AddToken(ATK_OPTION, buffer); + Arg_AddToken(ATK_ARG, buffer); + } else { + Arg_AddToken(ATK_ARG, buffer); + } + + Arg_AddToken( + (unsigned char) ((ch == ',') ? ATK_COMMA : (((ch == '=') || (ch == SEP3)) ? ATK_EQUALS : ATK_END)), + 0 + ); + + bufptr = buffer; + buffer[0] = 0; + + if (ch == SEP1 || ch == SEP2 || ch == SEP3) + isOpt = 0; + isList = 1; + } + + arg++; + } + + // 1799C8 + if (isOpt && bufptr > &buffer[0]) { + Arg_AddToken(ATK_OPTION, buffer + (isList && strchr(MAINOPTCHAR, buffer[0]))); + Arg_AddToken(ATK_ARG, buffer + (isList && strchr(MAINOPTCHAR, buffer[0])) + 1); + } else { + Arg_AddToken(ATK_ARG, buffer); + Arg_AddToken(ATK_ARG_END, 0); + } + } + + if (isOpt || isList) + Arg_AddToken(ATK_ARG_END, 0); + Arg_AddToken(ATK_END, 0); +} + +enum { + COMPAT_0, + COMPAT_1, + COMPAT_2 +}; + +void Arg_Init(int theargc, char **theargv) { + int p; + int x; + + maxargtoks = 0; + numargtoks = 0; + parserDebug = 0; + if (theargc > 1 && !strcmp(theargv[1], "--parser-debug")) { + parserDebug = 1; + memmove(&theargv[1], &theargv[2], sizeof(char *) * (theargc - 1)); + theargc--; + } + + if ((int) compat == COMPAT_0) { + MAINOPTCHAR = "-"; + FIRSTARGCHAR = "="; + SEPOPTSTR = " "; + SEP1 = ','; + SEP2 = '='; + SEP3 = '='; + RESPFILECHAR = '@'; + RESPFILESTR = ""; + } else if ((int) compat == COMPAT_1) { + MAINOPTCHAR = "/-"; + FIRSTARGCHAR = ":"; + SEPOPTSTR = ":"; + SEP1 = ','; + SEP2 = '='; + SEP3 = ':'; + RESPFILECHAR = '@'; + RESPFILESTR = ""; + } else if ((int) compat == COMPAT_2) { + if (!MAINOPTCHAR) + MAINOPTCHAR = "-"; + if (!FIRSTARGCHAR) + FIRSTARGCHAR = "="; + if (!SEPOPTSTR) + SEPOPTSTR = " "; + if (!SEP1) + SEP1 = ','; + if (!SEP2) + SEP2 = '='; + if (!SEP3) + SEP3 = '='; + if (!RESPFILECHAR) + RESPFILECHAR = '@'; + if (!RESPFILESTR) + RESPFILESTR = ""; + } else { + CLPFatalError("Unknown parser compatibility type (%d)\n", (int) compat); + } + + if (parserDebug) { + printf("Incoming arguments: \n"); + for (p = 0; p < theargc; p++) { + printf("[%s] ", theargv[p]); + } + printf("\n"); + } + + Arg_Setup(theargc, theargv); + Arg_Parse(); + Arg_Reset(); + + if (parserDebug) { + for (x = 0; x < numargtoks; x++) { + printf("TOKEN: '%s'\n", Arg_GetTokenName(&argtoks[x])); + } + } +} + +void Arg_Terminate() { + ArgToken *cur; + + while (numargtoks > 0) { + cur = &argtoks[--numargtoks]; + if (cur->text) + free(cur->text); + } + + if (maxargtoks) + free(argtoks); + maxargtoks = 0; +} + +void Arg_Reset() { + scantok = 0; +} + +void Arg_Stop(ArgToken *where) { + ArgToken *cur; + + while (&argtoks[numargtoks] > where) { + cur = &argtoks[--numargtoks]; + if (cur->text) + free(cur->text); + cur->val = ATK_END; + cur->text = 0; + } + + argtoks[numargtoks++].val = ATK_ARG_END; + argtoks[numargtoks++].val = ATK_END; + scantok = numargtoks - 2; +} + +ArgToken *Arg_PeekToken() { + if (scantok >= numargtoks) + return 0; + else + return &argtoks[scantok]; +} + +ArgToken *Arg_UsedToken() { + if (scantok < numargtoks) + scantok++; + return Arg_PeekToken(); +} + +int Arg_IsEmpty() { + ArgToken *tok; + + tok = Arg_PeekToken(); + return (tok == 0 || tok->val == ATK_END); +} + +ArgToken *Arg_GetToken() { + ArgToken *ret; + + ret = Arg_PeekToken(); + if (ret) + scantok++; + return ret; +} + +ArgToken *Arg_UndoToken() { + if (scantok > 0) { + scantok--; + return Arg_PeekToken(); + } else { + return 0; + } +} + +const char *Arg_GetTokenName(ArgToken *tok) { + if ((int) tok->val == ATK_ARG) + return tok->text; + + return + ((int) tok->val == ATK_OPTION) ? "option" : + ((int) tok->val == ATK_COMMA) ? "comma" : + (((int) compat == COMPAT_1 && (int) tok->val == ATK_EQUALS)) ? "colon or equals" : + (((int) compat != COMPAT_1 && (int) tok->val == ATK_EQUALS)) ? "equals" : + ((int) tok->val == ATK_ARG_END) ? "end of argument" : + ((int) tok->val == ATK_END) ? "end of command line" : + ""; +} + +const char *Arg_GetTokenText(ArgToken *tok, char *buffer, int maxlen, unsigned char warn) { + const char *ptr; + char *bptr; + int curlen; + + bptr = buffer; + curlen = 0; + if (tok->val == ATK_ARG || tok->val == ATK_OPTION) + ptr = tok->text; + else + ptr = Arg_GetTokenName(tok); + + while (*ptr && curlen++ < maxlen) { + *(bptr++) = *(ptr++); + } + + if (curlen < maxlen) { + bptr[0] = 0; + } else { + bptr[-1] = 0; + if (warn) + CLPReportWarning(CLPStr56, buffer, ptr + strlen(ptr) - ((maxlen <= 32) ? maxlen : 32), maxlen); + } + + return buffer; +} + +static void Arg_GrowArgs(anon0_50 *ta) { + int len; + + if (!ta->argv || (ta->argc + 1) >= ta->nargv) { + len = ta->nargv; + ta->nargv = len + 16; + ta->argv = xrealloc("argument list", ta->argv, sizeof(char *) * (ta->nargv + 1)); + while (len <= ta->nargv) { + ta->argv[len++] = 0; + } + } + + ta->argc++; +} + +static void Arg_GrowArg(anon0_50 *ta, char *txt) { + char **ptr; + int ptrlen; + + ptr = &ta->argv[ta->argc]; + + if (*ptr == 0) { + *ptr = xstrdup(txt); + } else { + ptrlen = strlen(*ptr); + *ptr = xrealloc("command line", *ptr, ptrlen + strlen(txt) + 1); + strcpy(*ptr + ptrlen, txt); + } +} + +void Arg_InitToolArgs(anon0_50 *ta) { + ta->argc = 0; + ta->nargv = 0; + ta->argv = 0; + Arg_GrowArgs(ta); +} + +void Arg_AddToToolArgs(anon0_50 *ta, short tokval, char *toktxt) { + switch (tokval) { + case ATK_END: + Arg_FinishToolArgs(ta); + break; + case ATK_ARG_END: + if (ta->argv && ta->argv[ta->argc]) + Arg_GrowArgs(ta); + break; + case ATK_ARG: + Arg_GrowArg(ta, toktxt); + break; + case ATK_OPTION: + Arg_GrowArg(ta, "-"); + break; + case ATK_EQUALS: + Arg_GrowArg(ta, "="); + break; + case ATK_COMMA: + Arg_GrowArg(ta, ","); + break; + default: +#line 787 + CLPFatalError(__FILE__, __LINE__, "Unknown token (%d)", tokval); + break; + } +} + +void Arg_FinishToolArgs(anon0_50 *ta) { + Arg_GrowArgs(ta); + ta->argv[ta->argc] = 0; +} + +void Arg_ToolArgsForPlugin(anon0_50 *ta, struct CWCommandLineArgs *args) { + args->argc = 1; + args->argv = ta->argv; + + while (args->argv[args->argc]) + args->argc++; + + args->envp = 0; +} + +void Arg_FreeToolArgs(anon0_50 *ta) { + int x; + + if (ta->argv) { + for (x = 1; x < ta->argc; x++) { + if (ta->argv[x]) + free(ta->argv[x]); + } + free(ta->argv); + } +} diff --git a/unsorted/Help.c b/unsorted/Help.c new file mode 100644 index 0000000..ceeb278 --- /dev/null +++ b/unsorted/Help.c @@ -0,0 +1,561 @@ +#include "parser.h" + +typedef struct _Side { + short offset; + short width; + char buffer[1024]; + short bptr; + short blen; + short indent; + short vrow; + short vcol; + Boolean atEOL; + Boolean impInd; +} Side; + +short helpExtras; +Boolean showedHelp; +Side left; +Side right; +Side all; +char **helptext; +static char outLine[256]; + +static void Help_Output(Side *left, Side *right); +static void Help_OutputSingle(Side *all); +static void Help_Flush(); + +static void Side_Init(Side *s, short offset, short width) { + memset(s, 0, sizeof(Side)); + s->offset = offset; + s->width = width; +} + +static void Side_Print(Side *s, const char *format, ...) { + char c; + char *text; + char buffer[1024]; + va_list args; + + va_start(args, format); + vsprintf(buffer, format, args); + va_end(args); + + text = buffer; + while (*text) { + if (s->blen < 1024) { + c = *(text++); + if (c == '~' && *text == '~') { + c = *MAINOPTCHAR; + text++; + } + + s->buffer[(s->bptr + s->blen) & 1023] = c; + s->blen++; + } else { + if (s == &left) + Help_Output(&left, &right); + else + Help_OutputSingle(&all); + } + } +} + +static void Side_NewLine(Side *s) { + Side_Print(s, "\n"); +} + +static void Side_Indent(Side *s, short how) { + if ((s->width - s->indent - how) > (parseopts.ioCols / 8)) + s->indent += how; + else if ((s->width - s->indent - 1) > (parseopts.ioCols / 10)) + s->indent++; +} + +static void Side_Outdent(Side *s, short how) { + if ((s->width - s->indent) < (parseopts.ioCols / 8)) + s->indent++; + else if (s->indent >= how) + s->indent -= how; +} + +static unsigned char isBreaker(char c) { + return (c == 10) || (c == 13) || (c == 32) || (c == 9) || (c == 8) || (c == '|'); +} + +static void Side_DumpLine(Side *s) { + short col; + short len; + short afterspace; + short eol; + short ind; + char c; + + eol = 0; + ind = 0; + col = s->offset + s->indent; + s->vcol = s->indent; + len = 0; + afterspace = s->width - s->indent; + + while (s->blen > 0 && s->vcol < s->width && !eol && !ind) { + c = s->buffer[s->bptr]; + outLine[col + len] = c; + s->vcol++; + len++; + + if (isBreaker(c)) { + afterspace = len; + eol = (c == '\n') || (c == '\r'); + eol += (c == '\r'); + ind = (c == '\b') || (c == '\t'); + ind += (c == '\b'); + } + + s->bptr = (s->bptr + 1) & 1023; + s->blen--; + } + + if (s->blen || eol || ind) { + s->blen += len - afterspace; + s->bptr = (s->bptr - (len - afterspace)) & 1023; + if (eol || ind) { + len++; + afterspace--; + } + + while (len > afterspace) { + outLine[col + --len] = ' '; + } + } + + s->vcol = 0; + s->vrow++; + s->atEOL = (eol == 1) || ind || !s->blen; + if ((s->atEOL || ind) && s->impInd) { + Side_Outdent(s, parseopts.ioCols / 40); + s->impInd = 0; + } + if (ind) { + if (ind == 1) + Side_Indent(s, parseopts.ioCols / 25); + else + Side_Outdent(s, parseopts.ioCols / 25); + } else if (!s->atEOL && s != &all && !s->impInd) { + Side_Indent(s, parseopts.ioCols / 40); + s->impInd = 1; + } +} + +static void Help_PrintLine() { + HPrintF(helptext, "%.*s\n", parseopts.ioCols - 1, outLine); +} + +static void Help_Output(Side *left, Side *right) { + while (left->blen || right->blen) { + memset(outLine, ' ', parseopts.ioCols); + outLine[left->offset + left->width + 1] = '#'; + if (left->atEOL && right->atEOL) + left->atEOL = right->atEOL = 0; + if (!left->atEOL) + Side_DumpLine(left); + if (!right->atEOL) + Side_DumpLine(right); + Help_PrintLine(); + } +} + +static void Help_OutputSingle(Side *all) { + while (all->blen) { + memset(outLine, ' ', parseopts.ioCols); + if (all->atEOL) + all->atEOL = 0; + if (!all->atEOL) + Side_DumpLine(all); + Help_PrintLine(); + } +} + +static void Help_Flush() { + Help_Output(&left, &right); +} + +static void Help_NewLine() { + Side_NewLine(&left); + Side_NewLine(&right); +} + +int Help_Option(struct OptionList *lst, struct Option *opt, int subprint, const char *keyword) { + char pfbuf[512]; + char slflags; + int listFlags; + Boolean allNoArgs; + PARAM_T *lastparam; + Boolean print; + Boolean printMe; + + if (!opt->names[0] && !(lst->flags & LISTFLAGS_4)) + return 0; + + if (keyword && keyword[0] && !strstr(opt->names, keyword) && (!opt->help || !strstr(opt->help, keyword))) + return 0; + + if ((opt->avail & OTF_SECRET) && !(parseopts.helpFlags & HELPFLAGS_SECRET)) + return 0; + + if ((opt->avail & OTF_OBSOLETE) && !(parseopts.helpFlags & HELPFLAGS_OBSOLETE)) + return 0; + + if ((opt->avail & OTF_DEPRECATED) && !(parseopts.helpFlags & HELPFLAGS_DEPRECATED)) + return 0; + + if ((opt->avail & OTF_IGNORED) && !(parseopts.helpFlags & HELPFLAGS_IGNORED)) + return 0; + + if ((opt->avail & OTF_MEANINGLESS) && !(parseopts.helpFlags & HELPFLAGS_MEANINGLESS)) + return 0; + + if (!(parseopts.helpFlags & HELPFLAGS_NORMAL) && !(opt->avail & OTF_ALL_HIDDEN_BY_DEFAULT)) + return 0; + + if (opt->help || (opt->avail & OTF_HAS_SUB_OPTIONS)) { + allNoArgs = 1; + lastparam = 0; + if (parseopts.helpFlags & HELPFLAGS_SPACES) + Help_NewLine(); + if ((opt->avail & OTF_GLOBAL) && !subprint) + Side_Print(&right, "global; "); + if (compat != 1 && (opt->avail & OTF_CASED)) + Side_Print(&right, "cased; "); + + slflags = (subprint == 0) ? SLFLAGS_1 : SLFLAGS_2; + switch (opt->avail & OTF_SLFLAGS_MASK) { + case OTF_SLFLAGS_8: + slflags = slflags | SLFLAGS_8; + break; + case OTF_SLFLAGS_10: + slflags = slflags | SLFLAGS_10; + break; + case OTF_SLFLAGS_20: + slflags = slflags | SLFLAGS_20; + break; + } + if (opt->avail & OTF_STICKY) + slflags = slflags | SLFLAGS_40; + + Utils_SpellList(opt->names[0] ? opt->names : "...", pfbuf, slflags); + Side_Print(&left, pfbuf); + + if (opt->avail & OTF_OBSOLETE) + Side_Print(&right, "obsolete;\r"); + if (opt->avail & OTF_COMPATIBILITY) + Side_Print(&right, "compatibility;\r"); + if (opt->avail & OTF_IGNORED) + Side_Print(&right, "ignored;\r"); + + listFlags = ((lst->flags & LISTFLAGS_COMPILER) ? OTF_TOOL_COMPILER : 0) | ((lst->flags & LISTFLAGS_LINKER) ? OTF_TOOL_LINKER : 0) | ((lst->flags & LISTFLAGS_DISASSEMBLER) ? OTF_TOOL_DISASSEMBLER : 0); + if (!Option_ForThisTool(opt) || Option_AlsoPassedFromThisTool(opt) || listFlags != Option_ThisTool()) { + print = 0; + printMe = 1; + if ((opt->avail & OTF_TOOL_MASK) != (unsigned int) listFlags) + print = 1; + if (Option_ForThisTool(opt) && Option_AlsoPassedFromThisTool(opt)) + printMe = 0; + + if (print) { + char opttool[64] = ""; // stack 0x44 + if ((opt->avail & OTF_TOOL_MASK) == (unsigned int) OTF_TOOL_MASK) { + strcat(opttool, "all tools"); + } else { + if (Option_ForTool(opt, OTF_TOOL_COMPILER) && ((Option_ThisTool() != (unsigned int) OTF_TOOL_COMPILER) || printMe)) { + strcat(opttool, "this tool"); + } + if (Option_ForTool(opt, OTF_TOOL_LINKER) && ((Option_ThisTool() != (unsigned int) OTF_TOOL_LINKER) || printMe)) { + if (opttool[0]) + strcat(opttool, ", "); + strcat(opttool, "linker"); + } + if (Option_ForTool(opt, OTF_TOOL_DISASSEMBLER) && ((Option_ThisTool() != (unsigned int) OTF_TOOL_DISASSEMBLER) || printMe)) { + if (opttool[0]) + strcat(opttool, ", "); + strcat(opttool, "disassembler"); + } + if (!Option_ForTool(opt, OTF_TOOL_MASK)) + strcat(opttool, "another tool"); + } + + if (printMe || !Option_ForThisTool(opt)) { + Side_Print(&right, "for %s;\r", opttool); + } else if (parseopts.passingArgs) { + Side_Print(&right, "passed to %s;\r", opttool); + } + } + } + + if (opt->avail & OTF_WARNING) + Side_Print(&right, "warning:\r"); + + if (opt->avail & OTF_DEPRECATED) + Side_Print(&right, "deprecated;\rinstead use "); + else if (opt->avail & OTF_SUBSTITUTED) + Side_Print(&right, "substituted with "); + + if (opt->help) + Side_Print(&right, "%s", opt->help); + + if (opt->param && !(opt->avail & OTF_IGNORED)) { + PARAM_T *scan = opt->param; + PARAM_T *firstparam = 0; + const char *desc; + const char *help; + const char *defaul; + while (scan) { + if ((scan->flags & PARAMFLAGS_3) != PARAMFLAGS_1) { + if (!firstparam) + firstparam = scan; + + allNoArgs = 0; + Param_DescHelp(scan, &desc, &help, &defaul); + if (desc) { + if (((scan->flags & PARAMFLAGS_3) == PARAMFLAGS_2) && scan->which != PARAMWHICH_Setting && scan->which != PARAMWHICH_IfArg) { + if (SEPOPTSTR[0] == ' ') { + Side_Print(&left, (scan != firstparam) ? "[," : subprint ? "[=" : " ["); + } else { + Side_Print(&left, "[%s", (scan != firstparam) ? "," : subprint ? "=" : SEPOPTSTR); + } + } else { + Side_Print(&left, (scan != firstparam) ? "," : subprint ? "=" : ((opt->avail & OTF_STICKY) && !strchr(opt->names, '|')) ? "" : SEPOPTSTR); + } + Side_Print(&left, "%s", desc); + if (((scan->flags & PARAMFLAGS_3) == PARAMFLAGS_2) && scan->which != PARAMWHICH_Setting && scan->which != PARAMWHICH_IfArg) { + Side_Print(&left, "]"); + } + if (help) { + if ((scan->flags & PARAMFLAGS_3) != PARAMFLAGS_2) + Side_Print(&right, "; for '%s', %s", desc, help); + else + Side_Print(&right, "; if parameter specified, %s", help); + } + if (defaul && !(opt->avail & OTF_HIDE_DEFAULT)) { + if (firstparam == scan) + Side_Print(&right, "; default is %s", defaul); + else + Side_Print(&right, ",%s", defaul); + } + } + } + lastparam = scan; + scan = scan->next; + } + + if (allNoArgs && !(opt->avail & OTF_HIDE_DEFAULT)) { + PARAM_T *scan = opt->param; + Boolean isdefault = scan ? 1 : 0; + while (scan && isdefault) { + isdefault &= Param_Compare(scan); + scan = scan->next; + } + + if (isdefault) + Side_Print(&right, "; default"); + } + } + + if (opt->avail & OTF_MEANINGLESS) + Side_Print(&right, "; meaningless for this target"); + + if ((opt->avail & OTF_HAS_SUB_OPTIONS) && opt->sub) { + if (!allNoArgs) { + Side_Print( + &left, + "%s", + (opt->avail & OTF_SUB_OPTIONS_OPTIONAL) ? ((lastparam->flags & PARAMFLAGS_8) ? "[=" : "[,") : ((lastparam->flags & PARAMFLAGS_8) ? "," : "=") + ); + } else if (!(opt->avail & OTF_STICKY)) { + if (opt->avail & OTF_SUB_OPTIONS_OPTIONAL) { + if (SEPOPTSTR[0] == ' ') + Side_Print(&left, subprint ? "[=" : " ["); + else + Side_Print(&left, "[%s", subprint ? "=" : SEPOPTSTR); + } else { + Side_Print(&left, "%c", subprint ? '=' : SEPOPTSTR[0]); + } + } else { + if (opt->avail & OTF_SUB_OPTIONS_OPTIONAL) { + Side_Print(&left, subprint ? "[" : (SEPOPTSTR[0] == ' ') ? " [" : "["); + } + } + + Side_Print( + &left, + "%s%s%s", + opt->sub->help ? opt->sub->help : "keyword", + (opt->sub->flags & PARAMFLAGS_1) ? "" : "[,...]", + (opt->avail & OTF_SUB_OPTIONS_OPTIONAL) ? "]" : "" + ); + + Side_Print(&left, "\t"); + Side_Print(&right, "\t"); + Help_Options(opt->sub, 1, ""); + Side_Print(&left, "\b"); + Side_Print(&right, "\b"); + } else { + Side_Print(&left, "\n"); + Side_Print(&right, "\n"); + } + } + + Help_Flush(); + return 1; +} + +void Help_Options(struct OptionList *lst, int subprint, const char *keyword) { + Option **opts; + int toolflags; + Boolean show; + + opts = lst->list; + toolflags = 0; + if (Option_ThisTool() == OTF_TOOL_COMPILER) { + toolflags |= LISTFLAGS_COMPILER; + } else { + toolflags |= LISTFLAGS_LINKER; + } + + // review me maybe? + if (!subprint && (parseopts.helpFlags & HELPFLAGS_TOOL)) { + if ((parseopts.helpFlags & HELPFLAGS_TOOL_BOTH) == HELPFLAGS_TOOL_THIS && (lst->flags & LISTFLAGS_TOOL_MASK) && !(lst->flags & toolflags)) + return; + if ((parseopts.helpFlags & HELPFLAGS_TOOL_BOTH) == HELPFLAGS_TOOL_OTHER && (((lst->flags & LISTFLAGS_TOOL_MASK) == (unsigned int) toolflags) || ((lst->flags & LISTFLAGS_TOOL_MASK) == (unsigned int) LISTFLAGS_NONE))) + return; + } + + if (lst->help && !subprint && opts[0]) { + Help_Line('-'); + Side_Print(&all, "%s", lst->help); + Help_OutputSingle(&all); + Help_Line('-'); + } + + while (*opts) { + show = 0; + if (!(parseopts.helpFlags & HELPFLAGS_TOOL)) { + if (((parseopts.helpFlags & HELPFLAGS_TOOL_BOTH) == HELPFLAGS_TOOL_BOTH) && (parseopts.passingArgs ? (Option_ForTool(*opts, OTF_TOOL_LINKER) || Option_ForTool(*opts, OTF_TOOL_DISASSEMBLER)) : 1) && Option_ForThisTool(*opts)) + show = 1; + } else if ((parseopts.helpFlags & HELPFLAGS_TOOL_BOTH) == HELPFLAGS_TOOL_BOTH) { + show = 1; + } else if ((parseopts.helpFlags & HELPFLAGS_TOOL_THIS) && Option_ForThisTool(*opts)) { + show = 1; + } else if ((parseopts.helpFlags & HELPFLAGS_TOOL_OTHER) && !Option_ForThisTool(*opts)) { + show = 1; + } else if ((parseopts.helpFlags & HELPFLAGS_TOOL_OTHER) && Option_ForTool(*opts, ~Option_ThisTool() & OTF_TOOL_MASK)) { + show = 1; + } + + if (show) + Help_Option(lst, *opts, subprint, keyword); + + ++opts; + } + + if (subprint && (parseopts.helpFlags & HELPFLAGS_SPACES)) + Help_NewLine(); + Help_Flush(); + if (!subprint) + HPrintF(helptext, "\n"); +} + +void Help_Usage() { + Side_Print( + &all, + "\tGuide to help:\b" + "\tWhen an option is specified as '~~xxx | yy[y] | zzz', then either '~~xxx', '~~yy', '~~yyy', or '~~zzz' matches the option.\b" + "\tAn option given as '~~[no]xxx' may be given as '~~xxx' or '~~noxxx'; '~~noxxx' reverses the meaning of the option.\b" + ); + Help_OutputSingle(&all); + + Side_Print( + &all, + "\tFor most options, the option and the parameters are separated by a %sspace. When the option's name is '~~xxx+', however, the parameter must directly follow the option, without the '+' (as in '~~xxx45').\b", + (compat != 1) ? "" : "colon or " + ); + Side_Print( + &all, + "\tA parameter included in brackets '[]' is optional. An ellipsis '...' indicates that the previous type of parameter may be repeated as a list.\b" + ); + Help_OutputSingle(&all); + + Side_Print( + &all, + "\t%s-- \"compatability\" indicates that the option is borrowed from another vendor's tool and may only approximate its counterpart.\r" + "-- \"global\" indicates that the option has an effect over the entire command line and is parsed before any other options. When several global options are specified, they are interpreted in order.\r" + "-- \"deprecated\" indicates that the option will be eliminated in the future and should not be used any longer. An alternative form is supplied.\r", + (compat != 1) ? "-- \"cased\" indicates that the option is case-sensitive. By default, no options are case-sensitive.\r" : ""); + Help_OutputSingle(&all); + + Side_Print( + &all, + "-- \"ignored\" means the option will be accepted but has no effect on the tool.\r" + "-- \"meaningless\" means the option is accepted but probably has no meaning for the target OS.\r" + "-- \"obsolete\" means the option was once deprecated and is now gone.\r" + "-- \"substituted\" means the option has the same effect as another. This points out a preferred form and prevents confusion when similar options appear in the help.\r" + "-- \"default\" in the help text indicates that the given value or variation of an option will be used unless otherwise overridden. \b" + ); + Help_OutputSingle(&all); + + Side_Print( + &all, + "\tThe symbols ',' %s separate options and parameters unconditionally; to include one of these symbols in a parameter or filename, escape it (e.g., as '\\,' in mwcc file.c\\,v).\b\n", + (compat != 1) ? "and '='" : ", ':', and '='" + ); + Help_OutputSingle(&all); + + if (parseopts.passingArgs && pTool->TYPE == CWDROPINCOMPILERTYPE) + Side_Print( + &all, + "\tThis tool calls the linker (unless a compiler option such as ~~c prevents it) and understands linker options -- use '~~help tool=other' to see them. Options marked \"passed to linker\" are used by the compiler and the linker; options marked \"for linker\" are used only by the linker. When using the compiler and linker separately, you must pass the common options to both.\b\n" + ); + Help_OutputSingle(&all); +} + +void Help_Null() { + Side_Print(&all, + "%s [options, filenames...]\n\nExecute '%s %shelp' for more information.", + OS_GetFileNamePtr(parseopts.args->argv[0]), + OS_GetFileNamePtr(parseopts.args->argv[0]), + MAINOPTCHAR + ); + Help_OutputSingle(&all); +} + +void Help_Init() { + short lb; + short le; + short rb; + short re; + + if (!(helptext = NewHandle(0))) { + fprintf(stderr, "\n*** Out of memory\n"); + exit(-23); + } + + lb = parseopts.ioCols / 40; + le = (parseopts.ioCols / 3) + lb; + rb = le + 3 + ((parseopts.ioCols / 60) & ~1); + re = parseopts.ioCols - 1; + Side_Init(&left, lb, le - lb); + Side_Init(&right, rb, re - rb); + Side_Init(&all, 0, re); +} + +void Help_Line(char ch) { + char line[256]; + memset(line, ch, 255); + line[255] = 0; + HPrintF(helptext, "%.*s\n", parseopts.ioCols - 1, line); +} + +void Help_Term() { + ShowTextHandle(0, helptext); + DisposeHandle(helptext); +} diff --git a/unsorted/IO.c b/unsorted/IO.c index 7ef3cb1..36d809b 100644 --- a/unsorted/IO.c +++ b/unsorted/IO.c @@ -1,4 +1,4 @@ -#include "mwcc_decomp.h" +#include "parser.h" void ShowTextHandle(const char *description, Handle text) { CWMemHandle mh; @@ -32,8 +32,8 @@ void ShowVersion(Boolean decorate) { } for (x = 0; x < parseopts.numPlugins; x++) { - if (parseopts.plugins[x].plugintype == CWFOURCHAR('c','l','d','r')) continue; - if (parseopts.plugins[x].plugintype == CWFOURCHAR('P','a','r','s')) continue; + if (parseopts.plugins[x].plugintype == CWDROPINDRIVERTYPE) continue; + if (parseopts.plugins[x].plugintype == CWDROPINPARSERTYPE) continue; if (pTool->TYPE == parseopts.plugins[x].plugintype) { if (!vplugin && pTool->LANG == parseopts.plugins[x].language) diff --git a/unsorted/OptimizerHelpers.c b/unsorted/OptimizerHelpers.c new file mode 100644 index 0000000..8b4bf36 --- /dev/null +++ b/unsorted/OptimizerHelpers.c @@ -0,0 +1,166 @@ +#include "parser.h" + +Boolean setOldOptimizerOptions; + +typedef struct { + Boolean commonsubs; + Boolean loopinvariants; + Boolean propagation; + Boolean deadstore; + Boolean strengthreduction; + Boolean deadcode; + Boolean lifetimes; +} PIROptimizer; // assumed name + +static PIROptimizer pIrOptimizer = {0}; + +Pragma irPragmas[] = { + &pIrOptimizer.commonsubs, "opt_common_subs", 0, + &pIrOptimizer.loopinvariants, "opt_loop_invariants", 0, + &pIrOptimizer.propagation, "opt_propagation", 0, + &pIrOptimizer.deadstore, "opt_dead_assignments", 0, + &pIrOptimizer.deadcode, "opt_dead_code", 0, + &pIrOptimizer.strengthreduction, "opt_strength_reduction", 0, + &pIrOptimizer.lifetimes, "opt_lifetimes", 0, + 0, 0, 0 +}; + +int SetPragmaOptimizationsToUnspecified(const char *opt, void *, const char *, int) { + if (setOldOptimizerOptions) + Option_Warning(CLPStr62); + + memset(&pIrOptimizer, 0, sizeof(pIrOptimizer)); + TargetSetPragmaOptimizationsToUnspecified(); + return 1; +} + +int SetOptFlags(const char *opt, void *str, const char *, int flags) { + // this is very similar to ToolHelper + // might also fail to match + unsigned char *ptr; + Boolean set; + Boolean no; + UInt16 flag; + + ptr = (unsigned char *) str; + no = (Boolean) ((flags & PARAMPARSEFLAGS_8) >> 3); + set = (Boolean) (no ^ 1); + + while (*ptr) { + if (*ptr == '+') { + set = !no; + } else if (*ptr == '-') { + set = no; + } else if (*ptr == '|') { + set = (Boolean) (no ^ 1); + } else { + flag = (ptr[0] << 8) | ptr[1]; + + if ((flag >= 'G0' && flag <= 'G4') || (flag == 'Gs') || (flag == 'Gp')) + SetPragmaOptimizationsToUnspecified(opt, NULL, NULL, 0); + + switch (flag) { + case 'Cs': + pIrOptimizer.commonsubs = set ? 1 : 2; + setOldOptimizerOptions = 1; + break; + case 'Li': + pIrOptimizer.loopinvariants = set ? 1 : 2; + setOldOptimizerOptions = 1; + break; + case 'Pr': + pIrOptimizer.propagation = set ? 1 : 2; + setOldOptimizerOptions = 1; + break; + case 'Ds': + pIrOptimizer.deadstore = set ? 1 : 2; + setOldOptimizerOptions = 1; + break; + case 'Sr': + pIrOptimizer.strengthreduction = set ? 1 : 2; + setOldOptimizerOptions = 1; + break; + case 'Dc': + pIrOptimizer.deadcode = set ? 1 : 2; + setOldOptimizerOptions = 1; + break; + case 'Lt': + pIrOptimizer.lifetimes = set ? 1 : 2; + setOldOptimizerOptions = 1; + break; + case 'G0': + pGlobalOptimizer.optimizationlevel = set ? 0 : 0; + break; + case 'G1': + pGlobalOptimizer.optimizationlevel = set ? 1 : 0; + break; + case 'G2': + pGlobalOptimizer.optimizationlevel = set ? 2 : 0; + break; + case 'G3': + pGlobalOptimizer.optimizationlevel = set ? 3 : 0; + break; + case 'G4': + pGlobalOptimizer.optimizationlevel = set ? 4 : 0; + break; + case 'Gs': + pGlobalOptimizer.optfor = set ? 1 : 0; + break; + case 'Gp': + pGlobalOptimizer.optfor = set ? 0 : 1; + break; + default: + if (!TargetSetOptFlags(flag, set)) + CLPFatalError("Bad optimizer settings in %s (%c%c)\n", str, ptr[0], ptr[1]); + } + + ++ptr; + } + + ++ptr; + } + + return 1; +} + +int DisplayOptimizationOptions() { + SInt32 oldsize; + Handle h; + + h = NewHandle(0); + if (!h) + exit(-23); + + HPrintF(h, "\t- global optimizer level %d\n", pGlobalOptimizer.optimizationlevel); + HPrintF(h, "\t- global optimize for %s\n", (pGlobalOptimizer.optfor == 0) ? "speed" : "size"); + + oldsize = GetHandleSize(h); + if (pIrOptimizer.commonsubs) + HPrintF(h, "\t- common subexpression elimination %s\n", (pIrOptimizer.commonsubs == 1) ? "on" : "off"); + if (pIrOptimizer.loopinvariants) + HPrintF(h, "\t- loop invariants %s\n", (pIrOptimizer.loopinvariants == 1) ? "on" : "off"); + if (pIrOptimizer.commonsubs) + HPrintF(h, "\t- constant propagation %s\n", (pIrOptimizer.propagation == 1) ? "on" : "off"); + if (pIrOptimizer.deadstore) + HPrintF(h, "\t- dead store elimination %s\n", (pIrOptimizer.deadstore == 1) ? "on" : "off"); + if (pIrOptimizer.deadcode) + HPrintF(h, "\t- dead code elimination %s\n", (pIrOptimizer.deadcode == 1) ? "on" : "off"); + if (pIrOptimizer.strengthreduction) + HPrintF(h, "\t- strength reduction %s\n", (pIrOptimizer.strengthreduction == 1) ? "on" : "off"); + if (pIrOptimizer.lifetimes) + HPrintF(h, "\t- variable lifetimes %s\n", (pIrOptimizer.lifetimes == 1) ? "on" : "off"); + + if (oldsize == GetHandleSize(h)) + HPrintF(h, "\t- no extra global optimizations\n"); + + HPrintF(h, "Backend-specific optimizer options:\n"); + + oldsize = GetHandleSize(h); + TargetDisplayOptimizationOptions(h); + if (oldsize == GetHandleSize(h)) + HPrintF(h, "\t- no extra backend-specific optimizations\n"); + + ShowTextHandle(NULL, h); + DisposeHandle(h); + return 1; +} diff --git a/unsorted/Option.c b/unsorted/Option.c new file mode 100644 index 0000000..410c807 --- /dev/null +++ b/unsorted/Option.c @@ -0,0 +1,1134 @@ +#include "parser.h" + +#define MAXSTACK 8 + +static OptionList *optionlists[32]; +int numoptionlists; +static OptionList internalset; +static OptionList legalset; +int numinternalset; +int numlegalset; +int maxlegalset; +char curopt[1024]; +Opt48 oStack[8]; +int oStackPtr; + +enum { + ARGFLAG_1 = 1, + ARGFLAG_2 = 2, + ARGFLAG_4 = 4, + ARGFLAG_8 = 8, + ARGFLAG_10 = 0x10, + ARGFLAG_20 = 0x20, + ARGFLAG_40 = 0x40, + ARGFLAG_80 = 0x80 +}; + +enum { + ARGSPELLFLAG_1 = 1, + ARGSPELLFLAG_2 = 2, + ARGSPELLFLAG_4 = 4, + ARGSPELLFLAG_8 = 8, + ARGSPELLFLAG_10 = 0x10, + ARGSPELLFLAG_20 = 0x20, + ARGSPELLFLAG_40 = 0x40, + ARGSPELLFLAG_80 = 0x80 +}; + +enum { + OPTSPELLFLAG_1 = 1, + OPTSPELLFLAG_2 = 2, + OPTSPELLFLAG_4 = 4, + OPTSPELLFLAG_8 = 8, + OPTSPELLFLAG_10 = 0x10, + OPTSPELLFLAG_20 = 0x20, + OPTSPELLFLAG_40 = 0x40, + OPTSPELLFLAG_80 = 0x80 +}; + +static void Option_PushList(OptionList *lst) { + Args_Push(1, lst, 0); +} + +static void Option_PushOpt(Option *opt, const char *optname) { + char *cpy; + short flags = ARGFLAG_2; + if (opt && (opt->avail & OTF_STICKY)) { + if (Utils_CompareOptionString(opt->names, optname, opt->avail & OTF_CASED, OTF_STICKY)) { + flags |= ARGFLAG_80; + } + } + cpy = xstrdup(optname); + Args_Push(flags, opt, cpy); +} + +static void Option_PopOpt(char *optname) { + Opt48 *os = Args_Pop(ARGFLAG_2); + if (optname) + strcpy(optname, os->e.o.curopt); + free(os->e.o.curopt); +} + +static void Option_PopList() { + Args_Pop(ARGFLAG_1); +} + +void Args_InitStack() { + oStackPtr = 0; +} +int Args_StackSize() { + return oStackPtr; +} + +void Args_Push(short flags, void *first, void *second) { +#line 104 + OPTION_ASSERT(oStackPtr 0) + { + short prev = + (flags & ARGFLAG_1) ? ARGFLAG_2 : + (flags & ARGFLAG_2) ? ARGFLAG_1 : + (flags & ARGFLAG_4) ? ARGFLAG_2 : -1; + OPTION_ASSERT(oStack[oStackPtr-1].flags & prev); + } + + oStack[oStackPtr].e.v.first = first; + oStack[oStackPtr].e.v.second = second; + oStack[oStackPtr].flags = flags; + oStackPtr++; +} + +Opt48 *Args_Pop(short flags) +{ + OPTION_ASSERT(oStackPtr>0); + --oStackPtr; + OPTION_ASSERT(oStack[oStackPtr].flags & flags); + return &oStack[oStackPtr]; +} + +void Args_SpellStack(char *buffer, short flags) { + char *bptr; + Opt48 *os; + int sp; + int level; + + bptr = buffer; + sp = 0; + level = 0; + os = &oStack[sp]; + + while (sp < oStackPtr) { + if (!flags || !(os->flags & ARGFLAG_20)) { + if (os->flags & ARGFLAG_4) { + Opt48 *po = os - 1; + if (!(os[-1].flags & ARGFLAG_40)) { + if ((level == 1 || level == 2) && !(po->flags & ARGFLAG_80)) + *(bptr++) = (flags & ARGSPELLFLAG_20) ? '\n' : ' '; + os[-1].flags |= ARGFLAG_40; + } else if (level == 2) { + *(bptr++) = ','; + } else if (level == 3) { + *(bptr++) = '='; + } + strcpy(bptr, os->e.param); + bptr += strlen(bptr); + } else if (os->flags & ARGFLAG_2) { + if (level == 1) { + *(bptr++) = MAINOPTCHAR[0]; + } else if (level == 2) { + Opt48 *po = os - 2; + if (!(os[-1].flags & ARGFLAG_40) && !(po->flags & ARGFLAG_80)) + *(bptr++) = (flags & ARGSPELLFLAG_20) ? '\n' : ' '; + } + + if (os[-1].flags & ARGFLAG_40) { + if (level == 2) { + if (flags & ARGSPELLFLAG_20) + *(bptr++) = ','; + else + *(bptr++) = ' '; + } + } else { + if (level == 3) { + *(bptr++) = '='; + } + } + + os[-1].flags |= ARGFLAG_40; + strcpy(bptr, os->e.o.curopt); + bptr += strlen(bptr); + } + + if (flags & ARGSPELLFLAG_20) + os->flags |= ARGFLAG_20; + } + + if (os->flags & ARGFLAG_1) + level++; + + ++sp; + ++os; + } +} + +void Args_AddToToolArgs(anon0_50 *ta) { + char buffer[4096]; + char *nptr; + + Args_SpellStack(buffer, ARGSPELLFLAG_20); + nptr = strchr(buffer, '\n'); + if (nptr) { + *(nptr++) = 0; + Arg_AddToToolArgs(ta, 2, buffer); + Arg_AddToToolArgs(ta, 1, 0); + } else { + nptr = buffer; + } + Arg_AddToToolArgs(ta, 2, nptr); +} + +void Options_Init() { + numoptionlists = 0; + maxlegalset = 0; + numlegalset = 0; + numinternalset = 0; + + if (legalset.list) + free(legalset.list); + if (internalset.list) + free(internalset.list); + + legalset.list = 0; + legalset.flags = + ((Option_ThisTool() & OTF_TOOL_COMPILER) ? LISTFLAGS_COMPILER : 0) | + ((Option_ThisTool() & OTF_TOOL_LINKER) ? LISTFLAGS_LINKER : 0) | + ((Option_ThisTool() & OTF_TOOL_DISASSEMBLER) ? LISTFLAGS_DISASSEMBLER : 0); + internalset.list = 0; + internalset.flags = + ((Option_ThisTool() & OTF_TOOL_COMPILER) ? LISTFLAGS_COMPILER : 0) | + ((Option_ThisTool() & OTF_TOOL_LINKER) ? LISTFLAGS_LINKER : 0) | + ((Option_ThisTool() & OTF_TOOL_DISASSEMBLER) ? LISTFLAGS_DISASSEMBLER : 0); + + Args_InitStack(); +} + +OptionList *Options_GetOptions() { + return &legalset; +} + +void Options_SortOptions() { + int r; + + if (numinternalset > 0) { + legalset.list = (Option **) xrealloc("options", legalset.list, sizeof(Option *) * (numinternalset + 1)); + for (r = 0; r < numinternalset; r++) { + if (internalset.list[r]->avail & (OTF_STICKY | OTF_CASED)) + legalset.list[numlegalset++] = internalset.list[r]; + } + for (r = 0; r < numinternalset; r++) { + if (!(internalset.list[r]->avail & (OTF_STICKY | OTF_CASED))) + legalset.list[numlegalset++] = internalset.list[r]; + } + legalset.list[numlegalset] = 0; + + if (internalset.list) + free(internalset.list); + internalset.list = 0; + numinternalset = 0; + } +} + +static void Options_AddOption(Option *opt) { + if (numinternalset >= maxlegalset) { + maxlegalset += 32; + internalset.list = (Option **) xrealloc("options", internalset.list, sizeof(Option *) * (maxlegalset + 1)); + } + + internalset.list[numinternalset++] = opt; + internalset.list[numinternalset] = 0; +} + +int Options_AddList(OptionList *optlst) { + Option **ptr; + + if (numoptionlists >= 32) + CLPFatalError("Too many option lists defined!"); + + optionlists[numoptionlists++] = optlst; + for (ptr = optlst->list; *ptr; ptr++) + Options_AddOption(*ptr); + + return 1; +} + +int Options_AddLists(OptionList **optlst) { + int ret = 1; + OptionList **ptr; + + for (ptr = optlst; *ptr; ptr++) { + ret = Options_AddList(*ptr); + if (!ret) + return ret; + } + + return ret; +} + +static void Options_Reset(OptionList *optlst) { + Option **os; + + os = optlst->list; + if (os) { + for (; *os; os++) { + (*os)->avail &= ~(OTF_INTERNAL_ALREADY_SEEN | OTF_INTERNAL_SEEN_CONFLICTED); + } + } +} + +static void Option_SpellList(char *buffer, OptionList *conflicts, int flags) { + Option **scan; + Boolean first; + int total; + char tmp[256]; + Option **next; + int slflags; + + scan = conflicts->list; + first = 1; + total = 0; + while (*scan) { + next = scan + 1; + if (!((*scan)->avail & (((parseopts.helpFlags & HELPFLAGS_SECRET) ? 0 : OTF_SECRET) | ((parseopts.helpFlags & HELPFLAGS_DEPRECATED) ? 0 : OTF_DEPRECATED) | OTF_SUBSTITUTED)) && (*scan)->names[0]) { + if (!first) + buffer += sprintf(buffer, ", "); + if (first) + first = 0; + + if (total > 1) { + while (*next && (((*next)->avail & (((parseopts.helpFlags & HELPFLAGS_SECRET) ? 0 : OTF_SECRET) | ((parseopts.helpFlags & HELPFLAGS_DEPRECATED) ? 0 : OTF_DEPRECATED) | OTF_SUBSTITUTED)) || !(*next)->names[0])) { + ++next; + } + + if (!*next) + buffer += sprintf(buffer, "or "); + } + + slflags = (flags & OPTSPELLFLAG_2) ? SLFLAGS_2 : SLFLAGS_1; + switch ((*scan)->avail & OTF_SLFLAGS_MASK) { + case OTF_SLFLAGS_8: + slflags |= SLFLAGS_8; + break; + case OTF_SLFLAGS_20: + slflags |= SLFLAGS_20; + break; + case OTF_SLFLAGS_10: + slflags |= SLFLAGS_10; + break; + } + + Utils_SpellList((*scan)->names, tmp, slflags); + total++; + buffer += sprintf(buffer, "%s", tmp); + + if ((*scan)->avail & OTF_HAS_SUB_OPTIONS) + buffer += sprintf(buffer, " ..."); + } + scan++; + } +} + +int Option_ForTool(Option *opt, int which) { + return !which || (opt->avail & which); +} + +int Option_ThisTool() { + return (pTool->TYPE == CWDROPINCOMPILERTYPE) ? OTF_TOOL_COMPILER : OTF_TOOL_LINKER; +} + +int Option_ForThisTool(Option *opt) { + return !Option_ForTool(opt, OTF_TOOL_MASK) || Option_ForTool(opt, Option_ThisTool()); +} + +int Option_AlsoPassedToTool(Option *opt, int which) { + return Option_ForThisTool(opt) && Option_ForTool(opt, which); +} + +int Option_AlsoPassedFromThisTool(Option *opt) { + return Option_ForThisTool(opt) && Option_ForTool(opt, ~Option_ThisTool() & OTF_TOOL_MASK); +} + +static Boolean Option_ContinuesThisLevel(int level, ArgToken *tok) { + ArgToken *tmp; + int ret; // not in stabs but i think this exists + + if (level == 1) { + return (tok->val == ATK_ARG_END) || (tok->val == ATK_OPTION) || (tok->val == ATK_ARG); + } else if (level == 2) { + tmp = Arg_UsedToken(); + ret = (tok->val == ATK_COMMA && tmp->val != ATK_OPTION) || (tok->val == ATK_ARG && tmp->val != ATK_ARG_END); + Arg_UndoToken(); + return ret; + } else if (level == 3) { + return (tok->val == ATK_EQUALS) || (tok->val == ATK_ARG); + } else { + return 0; + } +} + +static short endingStack[5][3]; +static Boolean Option_IsEndingThisLevel(int level, ArgToken *tok) { + ArgToken *tmp; + + if (!tok) + return 1; + if (tok->val == endingStack[level][0]) + return 1; + + if (endingStack[level][1] && tok->val == endingStack[level][1]) { + tmp = Arg_UsedToken(); + if (tmp && tmp->val == endingStack[level][2]) { + Arg_UndoToken(); + return 1; + } + Arg_UndoToken(); + } + + return 0; +} + +static Boolean Option_IsEndingLevel(int level, ArgToken *tok) { + if (!tok) + return 1; + + while (level > 0) { + if (Option_IsEndingThisLevel(level - 1, tok)) + return 1; + level--; + } + + return 0; +} + +int Option_Parse(Option *opt, int oflags) { + int ret; + int pushed; + int samelevel; + int subparse; + int flags; + char errstr[1024]; + Option **cscan; + Option **scan; + int goingtosubparse; + ArgToken *tok; + + ret = 1; + pushed = 0; + samelevel = (opt->avail & OTF_GLOBAL) == (oflags & OFLAGS_1); + subparse = (oflags & OFLAGS_2) != 0; + flags = 0; + if (subparse) flags |= PFLAGS_4; + if (oflags & OFLAGS_8) flags |= PFLAGS_8; + if (oflags & OFLAGS_40) flags |= PFLAGS_1; + + if (curopt[0]) { + pushed = 1; + Option_PushOpt(opt, curopt); + } + + if (samelevel) { + if (!(flags & PFLAGS_1)) { + if ((opt->avail & OTF_INTERNAL_ALREADY_SEEN) && (opt->avail & OTF_ONLY_ONCE)) { + Option_Warning(CLPStr30_OptionShouldNotBeSpecifiedMultipleTimes); + } else if (opt->avail & OTF_HAS_CONFLICTS) { + cscan = opt->conflicts->list; + while (*cscan && (*cscan == opt || !((*cscan)->avail & OTF_INTERNAL_ALREADY_SEEN))) { + ++cscan; + } + + if (*cscan && *cscan != opt) { + (*cscan)->avail &= ~OTF_INTERNAL_ALREADY_SEEN; + Option_SpellList(errstr, opt->conflicts, oflags); + if (opt->conflicts->help) + Option_Warning(CLPStr32_OptionOverridesEffectWithHelp, (*cscan)->names, errstr, opt->conflicts->help); + else + Option_Warning(CLPStr31_OptionOverridesEffect, (*cscan)->names, errstr); + } + } + } + + if (Option_ThisTool() == OTF_TOOL_COMPILER && Option_ForTool(opt, OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER)) { + flags |= PFLAGS_2; + if (!Option_ForThisTool(opt)) + flags |= PFLAGS_1; + if (!subparse) + Arg_AddToToolArgs(&linkargs, ATK_ARG_END, 0); + Args_AddToToolArgs(&linkargs); + } + + if (!(flags & PFLAGS_1)) { + if (opt->avail & OTF_OBSOLETE) { + if (opt->help) + Option_Error(CLPStr22_OptionObsoleteWithHelp, opt->help); + else + Option_Error(CLPStr21_OptionObsolete); + flags |= PFLAGS_1; + } + + if (opt->avail & OTF_IGNORED) { + if (!(opt->avail & (OTF_WARNING | OTF_MEANINGLESS))) { + if (opt->help) + Option_Warning(CLPStr27_OptionIgnoredWithText, opt->help); + else + Option_Warning(CLPStr26_OptionIgnored); + } + flags |= PFLAGS_1; + } else if (opt->avail & OTF_SUBSTITUTED) { + Option_Warning(CLPStr23_OptionXSubstitutedWithX, curopt, opt->help); + } else if (opt->avail & OTF_DEPRECATED) { + if (opt->help) + Option_Warning(CLPStr25_OptionDeprecatedWithHelp, opt->help); + else + Option_Warning(CLPStr24_OptionDeprecated); + } + + if (opt->avail & OTF_WARNING) + Option_Warning(CLPStr28_WarningText, opt->help); + if (opt->avail & OTF_MEANINGLESS) + Option_Warning(CLPStr29_OptionHasNoEffect); + } + + opt->avail |= OTF_INTERNAL_ALREADY_SEEN; + if (opt->avail & OTF_HAS_CONFLICTS) { + scan = opt->conflicts->list; + opt->avail |= OTF_INTERNAL_SEEN_CONFLICTED; + while (*scan) { + (*scan)->avail |= OTF_INTERNAL_SEEN_CONFLICTED; + scan++; + } + } + } else { + flags |= PFLAGS_1; + } + + goingtosubparse = opt->avail & OTF_HAS_SUB_OPTIONS; + if (opt->param) { + ret = Params_Parse(opt->param, flags | (goingtosubparse ? PFLAGS_20 : 0)); + } else { + tok = Arg_PeekToken(); + if (tok && tok->val == ATK_EQUALS) + Arg_UsedToken(); + } + + if (ret && goingtosubparse) { + ret = ret && Options_Parse( + opt->sub, + (oflags & ~OFLAGS_4) + | OFLAGS_2 + | ((flags & PFLAGS_1) ? OFLAGS_40 : 0) + | (subparse ? OFLAGS_10 : 0) + | ((opt->avail & OTF_SUB_OPTIONS_OPTIONAL) ? OFLAGS_4 : 0) + ); + } + + if (pushed) + Option_PopOpt(curopt); + + if (Option_ThisTool() == OTF_TOOL_COMPILER && !subparse) + Arg_AddToToolArgs(&linkargs, ATK_ARG_END, 0); + + return ret; +} + +static int Option_MatchString(char *list, char *str, int flags, int *result) { + int str_len; + char cpy[64]; + + if (result) + *result = 0; + + if (!list[0] && !str[0]) + return 1; + + while (*list) { + if (Utils_CompareOptionString(list, str, flags & OTF_CASED, 0)) + return 1; + + switch (flags & OTF_SLFLAGS_MASK) { + case OTF_SLFLAGS_8: + if (my_tolower(str[0]) == 'n' && my_tolower(str[1]) == 'o' && Utils_CompareOptionString(list, str + 2, flags & OTF_CASED, 0)) { + if (result) + *result |= 0x100000; + return 1; + } + break; + case OTF_SLFLAGS_20: + if (my_tolower(str[0]) == 'n' && my_tolower(str[1]) == 'o' && str[2] == '-' && Utils_CompareOptionString(list, str + 3, flags & OTF_CASED, 0)) { + if (result) + *result |= 0x400000; + return 1; + } + break; + case OTF_SLFLAGS_10: + str_len = strlen(str); + if (str[str_len - 1] == '-') { + strcpy(cpy, str); + cpy[str_len - 1] = 0; + if (Utils_CompareOptionString(list, cpy, flags & OTF_CASED, 0)) { + if (result) + *result |= 0x200000; + return 1; + } + } + break; + } + + while (*list && *list != '|') + ++list; + + if (*list) + ++list; + if (*list == '|') + ++list; + } + + return 0; +} + +static Option *Option_Lookup(OptionList *search, int unk, int *flags) { + Option **os; + Option *stickyopt; + int stickyflags; + Boolean matched; + char *names; + + os = search->list; + stickyopt = 0; + stickyflags = *flags; + + if (os) { + while (*os) { + names = (*os)->names; + if (((*os)->avail & OTF_STICKY) == OTF_STICKY) { + while (*names && *names != '|') + ++names; + if (*names) + ++names; + if (*names == '|') + ++names; + } + + matched = Option_MatchString(names, curopt, (*os)->avail & (OTF_SLFLAGS_MASK | OTF_CASED), flags) && (*names || names == (*os)->names); + if (matched) { + if (!stickyopt || (*os)->names[0] == curopt[0] || strlen(curopt) > 1) + return *os; + } + + if ((*os)->avail & OTF_STICKY) { + matched = Utils_CompareOptionString((*os)->names, curopt, (*os)->avail & OTF_CASED, 2); + if (matched) + stickyflags |= OTF_STICKY; + } else { + matched = 0; + } + + if (matched) + stickyopt = *os; + + ++os; + } + } + + *flags = stickyflags; + return stickyopt; +} + +static int Options_DoParse(OptionList *search, int flags) { + // search: r26 *n + // flags: r28 *n + int haderrors; // r30 *n + int parsedany; // r23 *n + int failed; // r24 *n + int matchflags; // stack 0x38 + int subparse; // r20 *n + ArgToken *starttok; // r0 (actually r19 i think?) + int mystery_r31; // figure out what var this actually is + ArgToken *tok; // r25 *n + ArgToken *opttok; // r27 *n + ArgToken *token_r18; // r18 MAYBE???? + Option *opt; // r16 *n + Boolean isOpt; // r0 + char *lptr; // r17 *n + char *optname; // r16 *n + + // 915 + haderrors = 0; + // 917 + failed = 0; + // 918 + matchflags = 0; + // 920 + subparse = (flags & OFLAGS_2) != 0; + // 921 + mystery_r31 = subparse && (flags & OFLAGS_10); + // 925 + opttok = 0; + // 929 + mystery_r31 = (subparse == 0) ? 1 : (mystery_r31 == 0) ? 2 : 3; + + starttok = Arg_PeekToken(); // i think this is starttok + while ((token_r18 = Arg_PeekToken())) { + parsedany = 0; + isOpt = ((mystery_r31 == 1) && (token_r18->val == ATK_OPTION)) || ((mystery_r31 == 2) && (token_r18->val == ATK_ARG) && (token_r18->text[0] || search->flags & LISTFLAGS_4)) || ((mystery_r31 == 3) && (token_r18->val == ATK_EQUALS)); + // 950 17CFD4 + if ((mystery_r31 == 3) && isOpt) { + token_r18 = Arg_UsedToken(); + isOpt = token_r18 && (token_r18->val == ATK_ARG); + flags &= ~OFLAGS_4; + } + // 957 17D00C + if (isOpt) { + // 959 + opt = 0; + // 960 + Arg_GetTokenText(token_r18, curopt, sizeof(curopt), 0); + // 963 + if (curopt[0]) { + opt = Option_Lookup(search, 0x700000, &matchflags); + if (opt) { + opttok = token_r18; + if (!(matchflags & 2)) { + // 972 + if (token_r18->val == ATK_OPTION) + Arg_UsedToken(); + token_r18 = Arg_UsedToken(); + } else { + lptr = opt->names; + optname = token_r18->text; + while (*lptr && *lptr != '|') + ++lptr; + token_r18 = Arg_UsedToken(); + + if (!subparse) + strcpy(token_r18->text, optname + (lptr - opt->names)); + + curopt[(lptr - opt->names)] = 0; + + if (!token_r18->text || !token_r18->text[0]) { + Option_PushOpt(0, curopt); + Option_ParamError(CLPStr34_ArgumentsExpected, curopt); + Option_PopOpt(0); + return 0; + } + } + } + } + + // 1006 + if (!opt) { + // 1009 + if (search->flags & LISTFLAGS_4) { + char saveopt[1024]; // stack 0xBC + strcpy(saveopt, curopt); + curopt[0] = 0; + opt = Option_Lookup(search, 0, &matchflags); + strcpy(curopt, token_r18->text); + + // 1019 + if (opt) { + if (opt->names[0]) + token_r18 = Arg_UsedToken(); + if (token_r18->val == ATK_EQUALS) + Arg_UsedToken(); + haderrors = Option_Parse(opt, flags) == 0; + parsedany = 1; + if (haderrors) + failed = 1; + opt = 0; + } else { + CLPFatalError("Missing default for variable list"); + return 0; + } + // 1041 + strcpy(curopt, saveopt); + } else if (!opt) { + // 1059 + curopt[0] = 0; + // 1061 + if (mystery_r31 > 1) { + if ((flags & OFLAGS_4) && token_r18 == starttok) + return haderrors == 0; + // 1072 + if (search->flags & LISTFLAGS_ALLOW_UNKNOWNS) { + if (!(flags & OFLAGS_1)) { + Option_SpellList(curparam, search, flags); + Option_Warning(CLPStr20_UnknownOptionX_ExpectedOneOfX, token_r18->text, curparam); + } + Arg_UsedToken(); + parsedany = 1; + } else { + // 1090 + Option_SpellList(curparam, search, flags); + Option_Error(CLPStr20_UnknownOptionX_ExpectedOneOfX, token_r18->text, curparam); + failed = 1; + haderrors++; + } + } else { + // 1099 + if ((search->flags & LISTFLAGS_ALLOW_UNKNOWNS) || parseopts.ignoreUnknown) { + // 1101 + if (!(flags & OFLAGS_1)) + Option_Warning(CLPStr19_UnknownOptionX, token_r18->text); + Arg_UsedToken(); + Arg_GetToken(); + parsedany = 1; + } else { + // 1115 + Option_Error(CLPStr19_UnknownOptionX, token_r18->text); + failed = 1; + haderrors++; + } + } + } + } + + // 1126 - after_if_1006 + if (!haderrors && !failed && opt) { + flags &= ~OFLAGS_8; + if (matchflags & 0x700000) + flags |= OFLAGS_8; + haderrors = Option_Parse(opt, flags) == 0; + if (haderrors) + failed = 1; + parsedany++; + } // else: goto 1229 + } else if ((mystery_r31 == 1) && (token_r18->val == ATK_ARG)) { + // 1142 + opttok = 0; + curopt[0] = 0; + opt = Option_Lookup(search, 0, &matchflags); + strcpy(curopt, token_r18->text); + if (!opt) { + Option_Warning(CLPStr33_NoDefaultHandlerSetUpForX_Ignoring, curopt); + failed = 1; + } else { + if (!(flags & OFLAGS_1)) { + haderrors = Option_Parse(opt, flags) == 0; + } else { + parseopts.possibleFiles++; + haderrors = 0; + } + parsedany = 1; + if (haderrors) + failed = 1; + else + Arg_UsedToken(); + } + } else if ((mystery_r31 > 1) && Option_IsEndingLevel(mystery_r31, token_r18)) { + // 1193 + Option *opt; + char saveopt[64]; // stack 0x7C + strcpy(saveopt, curopt); + if (!(search->flags & LISTFLAGS_4)) { + curopt[0] = 0; + opt = Option_Lookup(search, 0, &matchflags); // probably wrong result reg + } else { + opt = 0; // probably wrong reg + } + // 1203 + if (!opt) { + // 1205 + if (!(flags & OFLAGS_4)) { + Option_Error(CLPStr34_ArgumentsExpected, saveopt); + failed = 1; + haderrors++; + } else { + strcpy(curopt, saveopt); + break; + } + } else { + // 1219 + haderrors = Option_Parse(opt, flags) == 0; + parsedany = 1; + if (haderrors) + failed = 1; + } + // 1224 + strcpy(curopt, saveopt); + } + + // 1229 after_if_1126 + // This is where tok comes into play. + tok = Arg_PeekToken(); + // 1231 + if (!failed) { + if (tok && (tok->val == ATK_ARG) && (matchflags & 2)) { + // 1235 + ArgToken *prev; // r16 + char sticky[64]; // stack 0x3C + prev = Arg_UndoToken(); + tok = Arg_UsedToken(); + if (tok->text[0] && prev == opttok) { + if (opttok) { + strcpy(sticky, opttok->text); + sticky[strlen(tok->text)] = 0; + Option_PushOpt(0, sticky); + Param_Error(CLPStr36_UnexpectedAdditionalArgumentX, Arg_GetTokenName(tok)); + Option_PopOpt(0); + } else { + CLPReportError(CLPStr36_UnexpectedAdditionalArgumentX, Arg_GetTokenName(tok)); + } + // 1251 + haderrors++; + // goes to 1323 + } else { + // 1256 + if (!tok->text[0]) + tok = Arg_UsedToken(); + // 1257 + if (flags & OFLAGS_1) + parseopts.possibleFiles++; + // goes to 1323 + } + } else { + // 1267 + if (Option_IsEndingThisLevel(mystery_r31 - 1, tok)) + break; + if (Option_IsEndingThisLevel(mystery_r31 + 1, tok)) { + // 1276 + ArgToken *prev = tok; // r16 + tok = Arg_UsedToken(); + // 1278 + if ((mystery_r31 != 1) || (tok->val != ATK_OPTION)) { + // 1280 + if (opttok) { + Option_PushOpt(0, opttok->text); + if (tok->val == ATK_ARG) + Param_Error(CLPStr36_UnexpectedAdditionalArgumentX, Arg_GetTokenName(tok)); + else + Param_Error(CLPStr35_TokenXNotExpected, Arg_GetTokenName(prev)); + Option_PopOpt(opttok->text); + } else if (tok->val == ATK_ARG) { + // 1292 + CLPReportError(CLPStr36_UnexpectedAdditionalArgumentX, Arg_GetTokenName(tok)); + } else { + // 1294 + CLPReportError(CLPStr35_TokenXNotExpected, Arg_GetTokenName(prev)); + } + haderrors++; + failed++; + } + // goto 1323 + } else if ((mystery_r31 < 2) && Option_IsEndingThisLevel(mystery_r31 + 2, tok)) { + // 1303 + if (opttok) { + Option_PushOpt(0, opttok->text); + if (tok->val == ATK_ARG) + Param_Error(CLPStr36_UnexpectedAdditionalArgumentX, Arg_GetTokenName(tok)); + else + Param_Error(CLPStr35_TokenXNotExpected, Arg_GetTokenName(tok)); + Option_PopOpt(opttok->text); + } else if (tok->val == ATK_ARG) { + CLPReportError(CLPStr36_UnexpectedAdditionalArgumentX, Arg_GetTokenName(tok)); + } else { + CLPReportError(CLPStr35_TokenXNotExpected, Arg_GetTokenName(tok)); + } + haderrors++; + failed++; + } + } + } // else: 1323 + + if (haderrors || failed) { + while (!Option_IsEndingLevel(mystery_r31, tok)) + tok = Arg_GetToken(); + if (!tok) + tok = Arg_UndoToken(); +#line 1335 + OPTION_ASSERT(tok); + } + + if (!parsedany || haderrors) + break; + + if (Option_IsEndingThisLevel(mystery_r31, tok)) + Arg_UsedToken(); + else if (!Option_ContinuesThisLevel(mystery_r31, tok)) + break; + } + + return haderrors == 0; +} + +int Options_Parse(OptionList *options, int flags) { + // options: r30 + // flags: r31 + int ret; // r31 + char savecuropt[64]; // stack 0x3C + + Options_Reset(options); + Option_PushList(options); + + if (!(flags & 2)) { + ret = Options_DoParse(options, flags); + if (Option_ThisTool() == OTF_TOOL_COMPILER) + Arg_AddToToolArgs(&linkargs, 1, 0); + } else { + strcpy(savecuropt, curopt); + ret = Options_DoParse(options, flags); + strcpy(curopt, savecuropt); + } + + Option_PopList(); + return ret; +} + +int Option_ParseDefaultOption(OptionList *options) { + // options: r31 + int ret; // r31 + Option *dopt; // r0 + int matchflags; // 0x3C + + Options_Reset(options); + Option_PushList(options); + + strcpy(curopt, "defaultoptions"); + dopt = Option_Lookup(options, 0, &matchflags); + if (!dopt) { + CLPFatalError("Default options not defined"); + ret = 1; + } else { + ret = Option_Parse(dopt, 0); + } + + Option_PopList(); + return ret; +} + +void Option_ParamError(short id, va_list ap) { + char buf[4096]; + + CLPGetErrorString(id, buf); + sprintf(&buf[strlen(buf)], "\nwhile parsing option '"); + Args_SpellStack(&buf[strlen(buf)], 0); + sprintf(&buf[strlen(buf)], "'"); + CLPReportError_V(buf, ap); +} + +void Option_ParamWarning(short id, va_list ap) { + char buf[1024]; + + CLPGetErrorString(id, buf); + sprintf(&buf[strlen(buf)], "\nwhile parsing option '"); + Args_SpellStack(&buf[strlen(buf)], 0); + sprintf(&buf[strlen(buf)], "'"); + CLPReportWarning_V(buf, ap); +} + +void Option_OptionError(short id, va_list ap) { + char buf[1024]; + + CLPGetErrorString(id, buf); + if (Args_StackSize() >= 2) { + sprintf(&buf[strlen(buf)], "\nwhile parsing option '"); + Args_SpellStack(&buf[strlen(buf)], 0); + sprintf(&buf[strlen(buf)], "'"); + } + CLPReportError_V(buf, ap); +} + +void Option_OptionWarning(short id, va_list ap) { + char buf[1024]; + + CLPGetErrorString(id, buf); + if (Args_StackSize() >= 2) { + sprintf(&buf[strlen(buf)], "\nwhile parsing option '"); + Args_SpellStack(&buf[strlen(buf)], 0); + sprintf(&buf[strlen(buf)], "'"); + } + CLPReportWarning_V(buf, ap); +} + +void Option_Error(short id, ...) { + va_list va; + va_start(va, id); + Option_OptionError(id, va); + va_end(va); +} + +void Option_Warning(short id, ...) { + va_list va; + va_start(va, id); + Option_OptionWarning(id, va); + va_end(va); +} + +int Options_Help(const char *keyword) { + // keyword: r31 + int scan; // r26 + OptionList *lst; // r25 + + Help_Init(); + + if (parseopts.helpFlags & HELPFLAGS_USAGE) { + ShowVersion(1); + Help_Line('='); + Help_Usage(); + } else { + ShowVersion(1); + for (scan = 0; scan < numoptionlists; scan++) { + if ((lst = optionlists[scan])) { + if (parseopts.helpFlags & HELPFLAGS_8000) { + if (keyword && keyword[0] && lst->help && strstr(lst->help, keyword)) + Help_Options(lst, 0, ""); + } else { + Help_Options(lst, 0, keyword); + } + } + } + } + + Help_Term(); + return 1; +} + +int Option_Help(const char *opt) { + // opt: r31 + Option *find; // r29 + int matchflags; // stack 0x3C + int ret; // r29 + + find = 0; + Option_PushList(Options_GetOptions()); + Option_PushOpt(0, "help"); + if (opt[0] == MAINOPTCHAR[0]) + strcpy(curopt, opt + 1); + else + strcpy(curopt, opt); + + if (!curopt[1]) + find = Option_Lookup(Options_GetOptions(), 0x700002, &matchflags); + if (!find) + find = Option_Lookup(Options_GetOptions(), 0x700000, &matchflags); + + if (find) { + Help_Init(); + if (!Help_Option(Options_GetOptions(), find, 0, "")) + CLPReportWarning(CLPStr38_NoHelpAvailableForOptionX, opt); + Help_Term(); + ret = 1; + } else { + Option_Error(CLPStr19_UnknownOptionX, opt); + ret = 0; + } + + Option_PopOpt(curopt); + Option_PopList(); + return ret; +} + +int Options_DisplayHelp() { + if (parseopts.helpFlags & HELPFLAGS_1) + return Option_Help(parseopts.helpKey); + else + return Options_Help(parseopts.helpKey); +} diff --git a/unsorted/Parameter.c b/unsorted/Parameter.c new file mode 100644 index 0000000..b3c7367 --- /dev/null +++ b/unsorted/Parameter.c @@ -0,0 +1,1146 @@ +#include "parser.h" + +char curparam[4096]; +char *descparam = &curparam[0]; +char *helpparam = &curparam[1024]; +char *defaultparam = &curparam[2048]; + +#define copy_8(dst, src) \ +do { \ +((unsigned char *) (dst))[0] = ((unsigned char *) (src))[0]; \ +} while (0) + +#define copy_16(dst, src) \ +do { \ +((unsigned char *) (dst))[0] = ((unsigned char *) (src))[0]; \ +((unsigned char *) (dst))[1] = ((unsigned char *) (src))[1]; \ +} while (0) + +#define copy_32(dst, src) \ +do { \ +((unsigned char *) (dst))[0] = ((unsigned char *) (src))[0]; \ +((unsigned char *) (dst))[1] = ((unsigned char *) (src))[1]; \ +((unsigned char *) (dst))[2] = ((unsigned char *) (src))[2]; \ +((unsigned char *) (dst))[3] = ((unsigned char *) (src))[3]; \ +} while (0) + +#define inline_write_32(dst, val) do { \ +union {unsigned char bytes[4]; unsigned long lg;} _val, _arg; \ +copy_32(_arg.bytes, val); \ +_val.lg = _arg.lg; \ +copy_32(dst, _val.bytes); \ +} while (0) + +#define inline_write_16(dst, val) do { \ +union {unsigned char bytes[2]; unsigned short sh;} _val, _arg; \ +copy_16(_arg.bytes, val); \ +_val.sh = _arg.sh; \ +copy_16(dst, _val.bytes); \ +} while (0) + +#define inline_write_8(ptr, val) copy_8(ptr, val) + +#define inline_andor_32(dst, and, or) do { \ +union {unsigned char bytes[4]; unsigned long lg;} _val, _arg, _arg2; \ +copy_32(_val.bytes, dst); \ +copy_32(_arg.bytes, and); \ +copy_32(_arg2.bytes, or); \ +_val.lg = (_val.lg & ~_arg.lg) | _arg2.lg; \ +copy_32(dst, _val.bytes); \ +} while(0) + +#define inline_andor_16(dst, and, or) do { \ +union {unsigned char bytes[2]; unsigned short sh;} _val, _arg, _arg2; \ +copy_16(_val.bytes, dst); \ +copy_16(_arg.bytes, and); \ +copy_16(_arg2.bytes, or); \ +_val.sh = (_val.sh & ~_arg.sh) | _arg2.sh; \ +copy_16(dst, _val.bytes); \ +} while(0) + +#define inline_andor_8(dst, and, or) do { \ +((unsigned char *) (dst))[0] = (((unsigned char *) (dst))[0] & ~((unsigned char *) (and))[0]) | ((unsigned char *) (or))[0]; \ +} while(0) + +#define inline_xor_32(dst, arg) do { \ +union {unsigned char bytes[4]; unsigned long lg;} _val, _arg; \ +copy_32(_val.bytes, dst); \ +copy_32(_arg.bytes, arg); \ +_val.lg = _val.lg ^ _arg.lg; \ +copy_32(dst, _val.bytes); \ +} while(0) + +#define inline_xor_16(dst, arg) do { \ +union {unsigned char bytes[2]; unsigned short sh;} _val, _arg; \ +copy_16(_val.bytes, dst); \ +copy_16(_arg.bytes, arg); \ +_val.sh = _val.sh ^ _arg.sh; \ +copy_16(dst, _val.bytes); \ +} while(0) + +#define inline_xor_8(dst, arg) do { \ +((unsigned char *) (dst))[0] = (((unsigned char *) (dst))[0] ^ ((unsigned char *) (arg))[0]); \ +} while(0) + +// forward declaration +static int Param_GetArgument(PARAM_T *param, const char **cparam, int exec); +static int Param_Parse(PARAM_T *param, const char *cparam, int flags); + +static int Param_None(PARAM_T *p, const char *pstr, int flags) { + return 1; +} + +static void DescHelpParam_None(PARAM_T *p, const char **desc, const char **help, const char **defaul) { + *desc = 0; + *help = 0; + *defaul = 0; +} + +static int CompareParam_None(PARAM_T *p) { + return 0; +} + +static void DescHelpParam_Number(NUM_T *p, const char **desc, const char **help, const char **defaul) { + unsigned long value; + unsigned char value8; + unsigned short value16; + + value = 0; + *desc = 0; + if (p->myname) + *desc = p->myname; + + if (p->size == 1) { + if (!*desc) + *desc = "byte"; + if (p->num) copy_8(&value8, p->num); + value = value8; + } else if (p->size == 2) { + if (!*desc) + *desc = "short"; + if (p->num) copy_16(&value16, p->num); + value = value16; + } else if (p->size == 4) { + if (!*desc) + *desc = "long"; + if (p->num) copy_32(&value, p->num); + } + + if (p->size == 4) { + if (p->lo != p->hi) + sprintf(helpparam, "range 0x%x - 0x%x", p->lo, p->hi); + *help = helpparam; + if (value <= 0x10000) + sprintf(defaultparam, "%u", value); + else + sprintf(defaultparam, "0x%x", value); + *defaul = defaultparam; + } else { + if (p->lo != p->hi) + sprintf(helpparam, "range %u - %u", p->lo, p->hi); + *help = helpparam; + sprintf(defaultparam, "%u", value); + *defaul = defaultparam; + } + + if (!p->num) + *defaul = 0; + if (p->lo == p->hi) + *help = 0; +} + +static int CompareParam_Number(NUM_T *p) { + return 0; +} + +static int Param_Number(NUM_T *p, const char *pstr, int flags) { + unsigned long val; + unsigned long lo; + unsigned long hi; + const char *opstr; + + val = 0; + opstr = pstr; + if (!pstr[0]) { + Param_Error(5, "", pstr); + return 0; + } + + if (((*pstr == '0') && my_tolower(pstr[1]) == 'x') || (*pstr == '$')) { + // 218 + if (pstr[0] == '$') + pstr += 1; + else + pstr += 2; + + while (*pstr) { + if (!my_isxdigit(*pstr)) { + Param_Error(5, "hexadecimal ", opstr); + return 0; + } + + if (val > 0xFFFFFFF) { + Param_Error(4, opstr); + return 0; + } + + val = (val << 4) | (my_isdigit(*pstr) ? (*pstr - '0') : (my_tolower(*pstr) - 'a' + 10)); + ++pstr; + } + } else if (pstr[0] == '0') { + pstr += 1; + + while (*pstr) { + if (*pstr < '0' || *pstr >= '8') { + Param_Error(5, "octal ", opstr); + return 0; + } + + if (val > 0x1FFFFFFF) { + Param_Error(4, opstr); + return 0; + } + + val = (val << 3) | (*pstr - '0'); + ++pstr; + } + } else { + while (*pstr) { + if (!my_isdigit(*pstr)) { + Param_Error(5, "decimal ", opstr); + return 0; + } + + if (val > 0x19999999) { + Param_Error(4, opstr); + return 0; + } + + val = (val * 10) + (*pstr - '0'); + ++pstr; + } + } + + if (p->lo == p->hi) { + if (p->size == 1) { + lo = 0; + hi = 0xFF; + } else if (p->size == 2) { + lo = 0; + hi = 0xFFFF; + } else { + lo = 0; + hi = 0xFFFFFFFF; + } + } else { + lo = p->lo; + hi = p->hi; + } + + if (!p->fit && (val < lo || val > hi)) { + Param_Error(6, val, lo, hi); + return 0; + } + + if (val < lo) { + Param_Warning(7, val, lo, hi, lo); + val = lo; + } else if (val > hi) { + Param_Warning(7, val, lo, hi, hi); + val = hi; + } + + if (p->size == 1) { + unsigned char val8 = val; + inline_write_8(p->num, &val8); + } + + if (p->size == 2) { + unsigned short val16 = val; + inline_write_16(p->num, &val16); + } else if (p->size == 4) { + unsigned long val32 = val; + inline_write_32(p->num, &val32); + } + + return 1; +} + +static void DescHelpParam_FTypeCreator(FTYPE_T *p, const char **desc, const char **help, const char **defaul) { + if (p->myname) + *desc = p->myname; + else if (p->iscreator) + *desc = "creator"; + else + *desc = "type"; + + if (!p->fc) { + *defaul = 0; + } else { + unsigned long tmp; + unsigned char *ptr; + + ptr = (unsigned char *) defaultparam; + tmp = *p->fc; + ptr[0] = '\''; + ptr[1] = tmp & 0xFF; + ptr[2] = (tmp >> 8) & 0xFF; + ptr[3] = (tmp >> 16) & 0xFF; + ptr[4] = (tmp >> 24) & 0xFF; + ptr[5] = '\''; + ptr[6] = 0; + *defaul = defaultparam; + } +} + +static int CompareParam_FTypeCreator(FTYPE_T *p) { + return 0; +} + +static int Param_FTypeCreator(FTYPE_T *p, const char *pstr, int flags) { + char x[4] = " "; + int cnt; + const char *opstr; + + cnt = 0; + opstr = pstr; + while (*pstr && cnt < 4) { + x[cnt++] = *(pstr++); + } + + if (*pstr) { + Param_Error(8, opstr); + return 0; + } + + inline_write_32(p->fc, &x); + return 1; +} + +static void DescHelpParam_String(STRING_T *p, const char **desc, const char **help, const char **defaul) { + if (p->myname) + *desc = p->myname; + else + *desc = "string"; + + if (!p->str) { + *help = 0; + *defaul = 0; + } else { + sprintf(helpparam, "maximum length %d chars", p->maxlen - 1); + *help = helpparam; + + if (*p->str) { + sprintf(defaultparam, "'%s'", p->str); + *defaul = defaultparam; + } else { + *defaul = "none"; + } + } +} + +static int CompareParam_String(STRING_T *p) { + return 0; +} + +static int Param_String(STRING_T *p, const char *pstr, int flags) { + int len; + + len = strlen(pstr); + strncpy(p->str, pstr, p->maxlen - 1); + if (p->pstring) + c2pstr(p->str); + + if (len > p->maxlen) { + Param_Error(9, pstr, pstr + len - 5, p->maxlen - 1); + return 0; + } + + return 1; +} + +static void DescHelpParam_ID_or_SYM(STRING_T *p, const char **desc, const char **help, const char **defaul) { + if (p->myname) + *desc = p->myname; + else if (p->which == PARAMWHICH_Id) + *desc = "identifier"; + else + *desc = "symbol"; + + if (!p->str) { + *help = *defaul = 0; + } else { + sprintf(helpparam, "maximum length %d chars", p->maxlen - 1); + *help = helpparam; + + if (*p->str) { + sprintf(defaultparam, "'%s'", p->str); + *defaul = defaultparam; + } else { + *defaul = "none"; + } + } +} + +static int CompareParam_ID_or_SYM(STRING_T *p) { + return 0; +} + +static int Param_ID_or_SYM(STRING_T *p, const char *pstr, int flags) { + const char *ptr; + const char *x; + + if (Param_String(p, pstr, flags)) { + if (p->which == PARAMWHICH_Id) { + x = "$_"; + } else if (p->which == PARAMWHICH_Sym) { + x = "_.$@?#"; + } + + for (ptr = pstr; *ptr; ++ptr) { + if (ptr == pstr && my_isdigit(*ptr)) + Param_Warning(10, pstr); + + if (!my_isalnum(*ptr) && !strchr(x, *ptr)) + Param_Warning(11, pstr, *ptr); + } + + return 1; + } else { + return 0; + } +} + +static void DescHelpParam_OnOff(ONOFF_T *p, const char **desc, const char **help, const char **defaul) { + unsigned char def; + + if (p->myname) + *desc = p->myname; + else + *desc = "on|off"; + + *help = 0; + if (!p->var) { + *defaul = 0; + } else { + if (p->var) + *((unsigned char *) &def) = *((unsigned char *) p->var); + if (def) + *defaul = "on"; + else + *defaul = "off"; + } +} + +static int CompareParam_OnOff(ONOFF_T *p) { + return 0; +} + +static int Param_OnOff(ONOFF_T *p, const char *pstr, int flags) { + Boolean mytrue = (flags & PARAMPARSEFLAGS_8) == 0; + + if (!ustrcmp(pstr, "on")) { + *(p->var) = mytrue; + } else if (!ustrcmp(pstr, "off")) { + *(p->var) = mytrue == 0; + } else { + Param_Error(12, pstr); + return 0; + } + + return 1; +} + +static void DescHelpParam_OffOn(ONOFF_T *p, const char **desc, const char **help, const char **defaul) { + unsigned char def; + + if (p->myname) + *desc = p->myname; + else + *desc = "off|on"; + + *help = 0; + if (!p->var) { + *defaul = 0; + } else { + if (p->var) + *((unsigned char *) &def) = *((unsigned char *) p->var); + if (!def) + *defaul = "on"; + else + *defaul = "off"; + } +} + +static int CompareParam_OffOn(OFFON_T *p) { + return 0; +} + +static int Param_OffOn(OFFON_T *p, const char *pstr, int flags) { + Boolean mytrue = (flags & PARAMPARSEFLAGS_8) == 0; + + if (!ustrcmp(pstr, "off")) { + *(p->var) = mytrue; + } else if (!ustrcmp(pstr, "on")) { + *(p->var) = mytrue == 0; + } else { + Param_Error(12, pstr); + return 0; + } + + return 1; +} + +static void DescHelpParam_FilePath(FILEPATH_T *p, const char **desc, const char **help, const char **defaul) { + if (p->myname) + *desc = p->myname; + else + *desc = "filepath"; + + *help = 0; + *defaul = p->defaultstr; +} + +static int CompareParam_FilePath(FILEPATH_T *p) { + return 0; +} + +static int Param_FilePath(FILEPATH_T *p, const char *pstr, int flags) { + int err; + OSSpec spec; + char canon[256]; + int clen; + + if (!pstr[0]) { + ((unsigned char *) p->filename)[0] = 0; + return 1; + } + + err = OS_MakeFileSpec(pstr, &spec); + if (err) { + Param_Error(18, pstr, OS_GetErrText(err)); + return 0; + } + + OS_SpecToString(&spec, canon, sizeof(canon)); + if (p->fflags & 1) { + c2pstrcpy(p->filename, canon); + } else { + clen = strlen(canon); + if (clen > p->maxlen) { + Param_Error(13, canon + clen - 32, canon); + return 0; + } + strcpy(p->filename, canon); + } + + return 1; +} + +static void DescHelpParam_Mask(MASK_T *p, const char **desc, const char **help, const char **defaul) { + *help = 0; + *desc = 0; + *defaul = 0; +} + +static int CompareParam_Mask(MASK_T *p) { + if (p->size == 1) { + unsigned char or8 = p->ormask, and8 = p->andmask, val8; + if (p->num) copy_8(&val8, p->num); + return ((val8 & ~and8) | or8) == val8; + } else if (p->size == 2) { + unsigned short or16 = p->ormask, and16 = p->andmask, val16; + if (p->num) copy_16(&val16, p->num); + return ((val16 & ~and16) | or16) == val16; + } else { + unsigned long or32 = p->ormask, and32 = p->andmask, val32; + if (p->num) copy_32(&val32, p->num); + return ((val32 & ~and32) | or32) == val32; + } +} + +static int Param_Mask(MASK_T *p, const char *pstr, int flags) { + if (p->size == 1) { + unsigned char or8 = p->ormask, and8 = p->andmask, tmp8; + if (flags & PARAMPARSEFLAGS_8) { + tmp8 = and8; + and8 = and8 | or8; + or8 = tmp8; + } + inline_andor_8(p->num, &and8, &or8); + } else if (p->size == 2) { + unsigned short or16 = p->ormask, and16 = p->andmask, tmp16; + if (flags & PARAMPARSEFLAGS_8) { + tmp16 = and16; + and16 = and16 | or16; + or16 = tmp16; + } + inline_andor_16(p->num, &and16, &or16); + } else { + unsigned long or32 = p->ormask, and32 = p->andmask, tmp32; + if (flags & PARAMPARSEFLAGS_8) { + tmp32 = and32; + and32 = and32 | or32; + or32 = tmp32; + } + inline_andor_32(p->num, &and32, &or32); + } + return 1; +} + +static void DescHelpParam_Toggle(TOGGLE_T *p, const char **desc, const char **help, const char **defaul) { + *help = 0; + *desc = 0; + *defaul = 0; +} + +static int CompareParam_Toggle(TOGGLE_T *p) { + if (p->size == 1) { + unsigned char mask8, val8; + mask8 = (unsigned char) p->mask; + if (p->num) copy_8(&val8, p->num); + return (val8 ^ mask8) == val8; + } else if (p->size == 2) { + unsigned short mask16, val16; + mask16 = (unsigned short) p->mask; + if (p->num) copy_16(&val16, p->num); + return (val16 ^ mask16) == val16; + } else { + unsigned long mask32, val32; + mask32 = p->mask; + if (p->num) copy_16(&val32, p->num); // BUG ALERT + return (val32 ^ mask32) == val32; + } +} + +static int Param_Toggle(TOGGLE_T *p, const char *pstr, int flags) { + if (p->size == 1) { + unsigned char val8; + val8 = (unsigned char) p->mask; + inline_xor_8(p->num, &val8); + } else if (p->size == 2) { + unsigned short val16; + val16 = (unsigned short) p->mask; + inline_xor_16(p->num, &val16); + } else { + inline_xor_32(p->num, &p->mask); + } + return 1; +} + +static void DescHelpParam_Set(SET_T *p, const char **desc, const char **help, const char **defaul) { + *help = 0; + *desc = 0; + *defaul = 0; +} + +static int CompareParam_Set(SET_T *p) { + if (p->size == 1) { + unsigned char set8, val8; + set8 = (unsigned char) p->value; + if (p->num) copy_8(&val8, p->num); + return set8 == val8; + } else if (p->size == 2) { + unsigned short set16, val16; + set16 = (unsigned short) p->value; + if (p->num) copy_16(&val16, p->num); + return set16 == val16; + } else { + unsigned long set32, val32; + set32 = p->value; + if (p->num) copy_32(&val32, p->num); + return set32 == val32; + } +} + +static int Param_Set(SET_T *p, const char *pstr, int flags) { + if (p->size == 1) { + unsigned char val8; + val8 = (unsigned char) p->value; + if ((flags & PARAMPARSEFLAGS_8) && val8 <= 1) + val8 = (val8 == 0); + inline_write_8(p->num, &val8); + } else if (p->size == 2) { + unsigned short val16; + val16 = (unsigned short) p->value; + if ((flags & PARAMPARSEFLAGS_8) && val16 <= 1) + val16 = (val16 == 0); + inline_write_16(p->num, &val16); + } else { + unsigned long val32; + val32 = p->value; + if ((flags & PARAMPARSEFLAGS_8) && val32 <= 1) + val32 = (val32 == 0); + inline_write_32(p->num, &val32); + } + return 1; +} + +static void DescHelpParam_SetString(SETSTRING_T *p, const char **desc, const char **help, const char **defaul) { + *help = 0; + *desc = 0; + *defaul = 0; +} + +static int CompareParam_SetString(SETSTRING_T *p, int flags) { + if (p->pstring) + return pstrcmp((const unsigned char *) p->var, (const unsigned char *) p->value) == 0; + else + return strcmp(p->var, p->value) == 0; +} + +static int Param_SetString(SETSTRING_T *p, const char *pstr, int flags) { + if (p->pstring) + memcpy(p->var, p->value, p->value[0]); + else + strcpy(p->var, p->value); + return 1; +} + +static void DescHelpParam_Generic(GENERIC_T *p, const char **desc, const char **help, const char **defaul) { + if (p->myname) + *desc = p->myname; + else if ((p->flags & PARAMFLAGS_3) != 1) + *desc = "xxx"; + else + *desc = 0; + *help = p->help; + *defaul = 0; +} + +static int CompareParam_Generic(GENERIC_T *p) { + return 0; +} + +static int Param_Generic(GENERIC_T *p, const char *pstr, int flags) { + return p->parse(curopt, p->var, pstr, flags); +} + +static void DescHelpParam_Setting(SETTING_T *p, const char **desc, const char **help, const char **defaul) { + char *dptr = descparam; + + dptr += sprintf(dptr, "%s", p->myname ? p->myname : "var"); + if ((p->flags & PARAMFLAGS_3) != 1) { + sprintf(dptr, + "%s=%s%s", + (p->flags & PARAMFLAGS_2) ? "[" : "", + p->valuename ? p->valuename : "...", + (p->flags & PARAMFLAGS_2) ? "]" : "" + ); + } + *desc = descparam; + *help = 0; + *defaul = 0; +} + +static int CompareParam_Setting(SETTING_T *p) { + return 0; +} + +static int Param_Setting(SETTING_T *p, const char *pstr, int flags) { + char savevar[256]; + const char *vstr; + ArgToken *tok; + Boolean equals = 0; + + if (!pstr) { + Param_Error(40); + return 0; + } + + strncpy(savevar, pstr, sizeof(savevar)); + tok = Arg_PeekToken(); + if (tok && tok->val == ATK_EQUALS) { + Arg_UsedToken(); + equals = 1; + if (!Param_GetArgument((PARAM_T *) p, &vstr, flags)) + return 0; + } else { + vstr = 0; + } + + if (!vstr && equals) + vstr = ""; + + return p->parse(savevar, vstr); +} + +static void DescHelpParam_IfArg(IFARG_T *p, const char **desc, const char **help, const char **defaul) { + const char *d1 = 0; + const char *d2 = 0; + const char *h1 = 0; + const char *h2 = 0; + const char *df1 = 0; + const char *df2 = 0; + char desclocal[1024]; + char *dptr = desclocal; + char helplocal[1024]; + char *hptr = helplocal; + const char *ind; + + desclocal[0] = 0; + helplocal[0] = 0; + + if (p->parg) + Param_DescHelp(p->parg, &d1, &h1, &df1); + if (p->pnone) + Param_DescHelp(p->pnone, &d2, &h2, &df2); + + if (p->helpa && p->helpn) { + if (df1) + hptr += sprintf(hptr, "%s (default is %s), else %s", p->helpa, df1, p->helpn); + else + hptr += sprintf(hptr, "%s, else %s", p->helpa, p->helpn); + } else if (p->helpa) { + hptr += sprintf(hptr, "%s", p->helpa); + if (df1) + hptr += sprintf(hptr, "; default is %s", df1); + } else if (p->helpn) { + hptr += sprintf(hptr, "nothing, else %s", p->helpn); + } + + if (d1) { + if (p->myname) { + dptr += sprintf(dptr, "[%s]", p->myname ? p->myname: "param"); + } else if (h1) { + ind = strchr(d1, '\n'); + if (!ind) + ind = d1 + strlen(d1); + dptr += sprintf(dptr, "[%.*s]", ind - d1, d1); + } else { + dptr += sprintf(dptr, "[%s]", d1); + d1 = 0; + } + } + + if (h1 || h2) { + dptr += sprintf(dptr, "\n\t"); + hptr += sprintf(hptr, "\n\t"); + if (h1) { + if (d1) + dptr += sprintf(dptr, "%s", d1); + if (h1) + hptr += sprintf(hptr, "%s", h1); + if (h2) { + dptr += sprintf(dptr, "\b\t"); + hptr += sprintf(hptr, "\b\t"); + } + } + if (h2) { + if (d2) + dptr += sprintf(dptr, "%s", d2); + else + dptr += sprintf(dptr, "(if blank)"); + if (h2) + hptr += sprintf(hptr, "%s", h2); + dptr += sprintf(dptr, "\n"); + hptr += sprintf(hptr, "\n"); + } + dptr += sprintf(dptr, "\b"); + hptr += sprintf(hptr, "\b"); + } + + if (dptr != desclocal) { + strcpy(descparam, desclocal); + *desc = descparam; + } else { + *desc = 0; + } + + if (hptr != helplocal) { + strcpy(helpparam, helplocal); + *help = helpparam; + } else { + *help = 0; + } + + *defaul = 0; +} + +static int CompareParam_IfArg(IFARG_T *p) { + return 0; +} + +static int Param_IfArg(IFARG_T *p, const char *pstr, int flags) { + if (pstr) + return Param_Parse(p->parg, pstr, flags); + else if (p->pnone) + return Param_Parse(p->pnone, pstr, flags); + else + return 1; +} + +typedef int (*PARSE_FUNC)(PARAM_T *, const char *, int); +PARSE_FUNC ParamParsers[16] = { + (PARSE_FUNC) &Param_None, + (PARSE_FUNC) &Param_FTypeCreator, + (PARSE_FUNC) &Param_FilePath, + (PARSE_FUNC) &Param_Number, + (PARSE_FUNC) &Param_String, + (PARSE_FUNC) &Param_ID_or_SYM, + (PARSE_FUNC) &Param_ID_or_SYM, + (PARSE_FUNC) &Param_OnOff, + (PARSE_FUNC) &Param_OffOn, + (PARSE_FUNC) &Param_Mask, + (PARSE_FUNC) &Param_Toggle, + (PARSE_FUNC) &Param_Set, + (PARSE_FUNC) &Param_SetString, + (PARSE_FUNC) &Param_Generic, + (PARSE_FUNC) &Param_IfArg, + (PARSE_FUNC) &Param_Setting +}; + +static int Param_Parse(PARAM_T *param, const char *cparam, int flags) { + if (!param) + CLPFatalError("PARAM_T is NULL"); + + if (param->which >= PARAMWHICH_None && param->which < PARAMWHICH_MAX) { + return ParamParsers[param->which](param, cparam, flags); + } else { + CLPFatalError("Unhandled PARAM_T (%d)", param->which); + return 0; + } +} + +typedef void (*DESC_HELP_FUNC)(PARAM_T *, const char **, const char **, const char **); +DESC_HELP_FUNC DescHelpParams[16] = { + (DESC_HELP_FUNC) &DescHelpParam_None, + (DESC_HELP_FUNC) &DescHelpParam_FTypeCreator, + (DESC_HELP_FUNC) &DescHelpParam_FilePath, + (DESC_HELP_FUNC) &DescHelpParam_Number, + (DESC_HELP_FUNC) &DescHelpParam_String, + (DESC_HELP_FUNC) &DescHelpParam_ID_or_SYM, + (DESC_HELP_FUNC) &DescHelpParam_ID_or_SYM, + (DESC_HELP_FUNC) &DescHelpParam_OnOff, + (DESC_HELP_FUNC) &DescHelpParam_OffOn, + (DESC_HELP_FUNC) &DescHelpParam_Mask, + (DESC_HELP_FUNC) &DescHelpParam_Toggle, + (DESC_HELP_FUNC) &DescHelpParam_Set, + (DESC_HELP_FUNC) &DescHelpParam_SetString, + (DESC_HELP_FUNC) &DescHelpParam_Generic, + (DESC_HELP_FUNC) &DescHelpParam_IfArg, + (DESC_HELP_FUNC) &DescHelpParam_Setting +}; +void Param_DescHelp(PARAM_T *param, const char **desc, const char **help, const char **defaul) { + *desc = 0; + *help = 0; + *defaul = 0; + + if (!param) { + CLPFatalError("PARAM_T is NULL"); + return; + } + + if (param->which >= PARAMWHICH_None && param->which < PARAMWHICH_MAX) { + DescHelpParams[param->which](param, desc, help, defaul); + } else { + CLPFatalError("Unhandled PARAM_T (%d)", param->which); + } +} + +typedef int (*COMPARE_FUNC)(PARAM_T *); +COMPARE_FUNC CompareParams[16] = { + (COMPARE_FUNC) &CompareParam_None, + (COMPARE_FUNC) &CompareParam_FTypeCreator, + (COMPARE_FUNC) &CompareParam_FilePath, + (COMPARE_FUNC) &CompareParam_Number, + (COMPARE_FUNC) &CompareParam_String, + (COMPARE_FUNC) &CompareParam_ID_or_SYM, + (COMPARE_FUNC) &CompareParam_ID_or_SYM, + (COMPARE_FUNC) &CompareParam_OnOff, + (COMPARE_FUNC) &CompareParam_OffOn, + (COMPARE_FUNC) &CompareParam_Mask, + (COMPARE_FUNC) &CompareParam_Toggle, + (COMPARE_FUNC) &CompareParam_Set, + (COMPARE_FUNC) &CompareParam_SetString, + (COMPARE_FUNC) &CompareParam_Generic, + (COMPARE_FUNC) &CompareParam_IfArg, + (COMPARE_FUNC) &CompareParam_Setting +}; +int Param_Compare(PARAM_T *param) { + if (!param) + CLPFatalError("PARAM_T is NULL"); + + if (param->which >= PARAMWHICH_None && param->which < PARAMWHICH_MAX) { + return CompareParams[param->which](param); + } else { + CLPFatalError("Unhandled PARAM_T (%d)", param->which); + return 0; + } +} + +static void Param_PushParam(const char *param) { + Args_Push(4, (void *) param, 0); +} + +static void Param_PopParam() { + Args_Pop(4); +} + +static Boolean Param_IsNonTextFile(const char *fname, Boolean warn) { + OSSpec tmp; + CWDataType mactype; + Boolean isfile; + + if (!OS_MakeSpec(fname, &tmp, &isfile)) { + if (isfile) { + if (!OS_Status(&tmp)) { + if (!OS_GetMacFileType(&tmp, &mactype)) { + if (mactype != 'TEXT') { + if (warn) + Param_Warning(77, fname); + return 1; + } + } + } + } + } + + return 0; +} + +static int Param_GetArgument(PARAM_T *param, const char **cparam, int exec) { + int subparse; + short nextOpt; + short nextParam; + short lastOpt; + ArgToken *tok; + + subparse = (exec & PARAMPARSEFLAGS_4) != 0; + nextOpt = !subparse ? ATK_ARG_END : ATK_COMMA; + nextParam = !subparse ? ATK_COMMA : ATK_EQUALS; + lastOpt = !subparse ? ATK_END : ATK_ARG_END; + + tok = Arg_PeekToken(); +#line 1467 + OPTION_ASSERT(tok); + + if ((param->flags & PARAMFLAGS_3) == 0) { + if (tok->val == nextParam || tok->val == ATK_EQUALS) + tok = Arg_UsedToken(); + if (tok->val == nextOpt || tok->val == nextParam || tok->val == lastOpt) { + Param_Error(34); + return 0; + } + if (tok->val != ATK_ARG) { + Param_Error(57, "parameter", Arg_GetTokenName(tok)); + return 0; + } + Arg_GetTokenText(tok, curparam, sizeof(curparam), 1); + Arg_UsedToken(); + *cparam = curparam; + + if (param->flags & PARAMFLAGS_8) { + tok = Arg_PeekToken(); + if (tok->val == ATK_EQUALS) + Arg_UsedToken(); + } + } else if (param->flags & PARAMFLAGS_1) { + *cparam = 0; + if (tok->val == ATK_EQUALS && !subparse) { + if (!(exec & PARAMPARSEFLAGS_40)) { + Param_Error(37); + return 0; + } + Arg_UsedToken(); + } + } else if (param->flags & PARAMFLAGS_2) { + if (tok->val == nextOpt || tok->val == lastOpt) { + *cparam = 0; + } else if (tok->val == nextParam) { + tok = Arg_UsedToken(); + if (tok->val == ATK_ARG) { + Arg_GetTokenText(tok, curparam, sizeof(curparam), 1); + if ((param->flags & PARAMFLAGS_12) && Param_IsNonTextFile(curparam, !(exec & PARAMPARSEFLAGS_1))) { + *cparam = 0; + } else { + Arg_UsedToken(); + *cparam = curparam; + } + } else { + *cparam = 0; + } + } else if (tok->val == ATK_ARG && !tok->text[0]) { + tok = Arg_UsedToken(); + if (tok->val == nextParam) + Arg_UsedToken(); + *cparam = 0; + } else if ((exec & PARAMPARSEFLAGS_4) && tok->val != ATK_EQUALS) { + *cparam = 0; + } else { + if (tok->val == ATK_EQUALS) + tok = Arg_UsedToken(); + if (tok->val == ATK_ARG) { + Arg_GetTokenText(tok, curparam, sizeof(curparam), 1); + if ((param->flags & PARAMFLAGS_12) && Param_IsNonTextFile(curparam, !(exec & PARAMPARSEFLAGS_1))) { + *cparam = 0; + } else { + Arg_UsedToken(); + *cparam = curparam; + } + } else { + *cparam = 0; + } + } + } else { + CLPFatalError("Unknown parameter type"); + } + + if (pTool->TYPE == CWDROPINCOMPILERTYPE && (exec & PARAMPARSEFLAGS_2) && *cparam) { + if (!(exec & PARAMPARSEFLAGS_10)) { + if (subparse) + Arg_AddToToolArgs(&linkargs, ATK_EQUALS, 0); + else + Arg_AddToToolArgs(&linkargs, ATK_COMMA, 0); + } + Param_PushParam(*cparam); + Args_AddToToolArgs(&linkargs); + Param_PopParam(); + } + + return 1; +} + +int Params_Parse(PARAM_T *param, int flags) { + const char *cparam; + flags |= PARAMPARSEFLAGS_10; + + if (param) { + while (param) { + if (flags & PARAMPARSEFLAGS_20) + flags |= PARAMPARSEFLAGS_40; + + if (!Param_GetArgument(param, &cparam, flags)) + return 0; + + if (!(flags & PARAMPARSEFLAGS_1)) { + if (!Param_Parse(param, cparam, flags | (short) ((param->flags & PARAMFLAGS_4) ? PARAMPARSEFLAGS_20 : 0))) + return 0; + } else if (param->flags & PARAMFLAGS_4) { + if (!Param_GetArgument(param, &cparam, flags | PARAMPARSEFLAGS_4)) + return 0; + } + + if (cparam) + flags &= ~PARAMPARSEFLAGS_10; + flags &= ~PARAMPARSEFLAGS_40; + param = param->next; + } + } + + return 1; +} + +void Param_Error(short id, ...) { + va_list va; + va_start(va, id); + Option_ParamError(id, va); + va_end(va); +} + +void Param_Warning(short id, ...) { + va_list va; + va_start(va, id); + Option_ParamWarning(id, va); + va_end(va); +} diff --git a/unsorted/ParserErrors.c b/unsorted/ParserErrors.c index 172e04c..df5e67e 100644 --- a/unsorted/ParserErrors.c +++ b/unsorted/ParserErrors.c @@ -1,4 +1,4 @@ -#include "mwcc_decomp.h" +#include "parser.h" static char errorbuf[1024]; diff --git a/unsorted/ParserFace.c b/unsorted/ParserFace.c index 24f3213..a005ece 100644 --- a/unsorted/ParserFace.c +++ b/unsorted/ParserFace.c @@ -1,8 +1,8 @@ -#include "mwcc_decomp.h" +#include "parser.h" const char *failedCallback; jmp_buf exit_plugin; -struct ParseOptsType parseopts; +ParseOptsType parseopts; static CWResult SetupParamBlock(CWPluginContext context) { CWResult result; @@ -136,9 +136,9 @@ CWResult Parser_StorePanels(CWPluginContext context) { name = parseopts.panelNames[idx]; h = Parser_FindPrefPanel(name); if (h) { - result = CWParserSetNamedPreferences(parseopts.context, name, (CWMemHandle) h); + result = CWParserSetNamedPreferences(parseopts.context, name, h); if (result) { - CLPReportError(68, name); + CLPReportError(CLPStr68, name); return result; } } @@ -190,10 +190,10 @@ static CWResult StoreResults(CWPluginContext context) { return cwNoErr; } -short CWParser_GetDropInFlags(const DropInFlags **flags, SInt32 *flagsSize) { +CWPLUGIN_ENTRY (CWParser_GetDropInFlags)(const DropInFlags **flags, SInt32 *flagsSize) { static const DropInFlags sFlags = { kCurrentDropInFlagsVersion, - CWFOURCHAR('P','a','r','s'), + CWDROPINPARSERTYPE, 7, 0, 'Seep', @@ -204,19 +204,19 @@ short CWParser_GetDropInFlags(const DropInFlags **flags, SInt32 *flagsSize) { return 0; } -short CWParser_GetDropInName(const char **dropinName) { +CWPLUGIN_ENTRY (CWParser_GetDropInName)(const char **dropinName) { static const char *sDropInName = "Command-Line Parser"; *dropinName = sDropInName; return 0; } -short CWParser_GetDisplayName(const char **displayName) { +CWPLUGIN_ENTRY (CWParser_GetDisplayName)(const char **displayName) { static const char *sDisplayName = "Command-Line Parser"; *displayName = sDisplayName; return 0; } -short CWParser_GetPanelList(const CWPanelList **panelList) { +CWPLUGIN_ENTRY (CWParser_GetPanelList)(const CWPanelList **panelList) { static CWPanelList sPanelList = { kCurrentCWFamilyListVersion, 0, @@ -226,7 +226,7 @@ short CWParser_GetPanelList(const CWPanelList **panelList) { return 0; } -short CWParser_GetTargetList(const CWTargetList **targetList) { +CWPLUGIN_ENTRY (CWParser_GetTargetList)(const CWTargetList **targetList) { static CWDataType sCPU = '****'; static CWDataType sOS = '****'; static CWTargetList sTargetList = { @@ -240,7 +240,7 @@ short CWParser_GetTargetList(const CWTargetList **targetList) { return 0; } -short CWParser_GetVersionInfo(const VersionInfo **versioninfo) { +CWPLUGIN_ENTRY (CWParser_GetVersionInfo)(const VersionInfo **versioninfo) { static const VersionInfo vi = { 1, 1, 0, 0 }; @@ -248,17 +248,17 @@ short CWParser_GetVersionInfo(const VersionInfo **versioninfo) { return 0; } -short Parser_SupportsPlugin(struct CLPluginInfo *pluginfo, CWDataType cpu, CWDataType os, Boolean *isSupported) { +CWPLUGIN_ENTRY (Parser_SupportsPlugin)(const struct CLPluginInfo *pluginfo, CWDataType cpu, CWDataType os, Boolean *isSupported) { *isSupported = ParserToolMatchesPlugin(pluginfo->plugintype, pluginfo->language, cpu, os); return 0; } -short Parser_SupportsPanels(int numPanels, const char **panelNames, Boolean *isSupported) { +CWPLUGIN_ENTRY (Parser_SupportsPanels)(int numPanels, const char **panelNames, Boolean *isSupported) { *isSupported = ParserToolHandlesPanels(numPanels, panelNames); return 0; } -short parser_main(CWPluginContext context) { +CWPLUGIN_ENTRY (parser_main)(CWPluginContext context) { CWResult result; SInt32 request; diff --git a/unsorted/ParserHelpers-cc.c b/unsorted/ParserHelpers-cc.c index d56fe4d..fe081ad 100644 --- a/unsorted/ParserHelpers-cc.c +++ b/unsorted/ParserHelpers-cc.c @@ -1,8 +1,8 @@ -#include "mwcc_decomp.h" +#include "parser.h" Handle definesHandle; -int Opt_AddStringToDefines(const char *opt, void *str, const char *param) { +int Opt_AddStringToDefines(const char *opt, void *str, const char *param, int flags) { AddStringToHandle(&definesHandle, (const char *) str); if (param) AddStringToHandle(&definesHandle, param); @@ -18,7 +18,7 @@ int Opt_DefineSymbol(const char *var, const char *value) { sprintf(tmp, "{$definec %s %s}\n", var, value ? value : "1"); } else { sprintf(tmp, "Option '-D|d' is not supported with this plugin"); - CLPReportError(28, tmp); + CLPReportError(CLPStr28_WarningText, tmp); return 0; } @@ -26,7 +26,7 @@ int Opt_DefineSymbol(const char *var, const char *value) { return 1; } -int Opt_UndefineSymbol(const char *opt, void *, const char *arg) { +int Opt_UndefineSymbol(const char *opt, void *, const char *arg, int flags) { char tmp[300]; if (pTool->LANG == Lang_C_CPP || pTool->LANG == CWFOURCHAR('A','s','m',' ')) { @@ -35,7 +35,7 @@ int Opt_UndefineSymbol(const char *opt, void *, const char *arg) { sprintf(tmp, "{$undefc %s}\n", arg); } else { sprintf(tmp, "Option -%s is not supported with this plugin", opt); - CLPReportError(28, tmp); + CLPReportError(CLPStr28_WarningText, tmp); return 0; } @@ -43,7 +43,7 @@ int Opt_UndefineSymbol(const char *opt, void *, const char *arg) { return 1; } -int Opt_AddPrefixFile(const char *opt, void *handle, const char *filename) { +int Opt_AddPrefixFile(const char *opt, void *handle, const char *filename, int flags) { char tmp[300]; handle = !handle ? &definesHandle : handle; @@ -60,7 +60,7 @@ int Opt_AddPrefixFile(const char *opt, void *handle, const char *filename) { snprintf(tmp, sizeof(tmp), "{$I+}\n{$I %s}\n{$I-}\n", filename); } else { sprintf(tmp, "Option -%s is not supported with this plugin", opt); - CLPReportError(28, tmp); + CLPReportError(CLPStr28_WarningText, tmp); return 0; } @@ -86,7 +86,7 @@ int Opt_PragmaFalseTrue(const char *, void *flag, const char *, int flags) { int Opt_PragmaOnOff(const char *, void *flag, const char *arg) { if (!arg) { - CLPReportError(34); + CLPReportError(CLPStr34_ArgumentsExpected); return 0; } @@ -95,7 +95,7 @@ int Opt_PragmaOnOff(const char *, void *flag, const char *arg) { } else if (!ustrcmp(arg, "off")) { *((unsigned char *) flag) = PR_OFF; } else { - CLPReportError(12, arg); + CLPReportError(CLPStr12, arg); return 0; } @@ -104,7 +104,7 @@ int Opt_PragmaOnOff(const char *, void *flag, const char *arg) { int Opt_PragmaOffOn(const char *, void *flag, const char *arg) { if (!arg) { - CLPReportError(34); + CLPReportError(CLPStr34_ArgumentsExpected); return 0; } @@ -113,7 +113,7 @@ int Opt_PragmaOffOn(const char *, void *flag, const char *arg) { } else if (!ustrcmp(arg, "off")) { *((unsigned char *) flag) = PR_ON; } else { - CLPReportError(12, arg); + CLPReportError(CLPStr12, arg); return 0; } diff --git a/unsorted/ParserHelpers.c b/unsorted/ParserHelpers.c index c8d4c55..4cb793e 100644 --- a/unsorted/ParserHelpers.c +++ b/unsorted/ParserHelpers.c @@ -1,4 +1,5 @@ -#include "mwcc_decomp.h" +#include "parser.h" +#include "cmdline.h" #include SInt16 lastStage; @@ -44,7 +45,7 @@ char *GetEnvVar(const char *name, Boolean warn, const char **match) { } if (warn) - CLPReportWarning(52, last); + CLPReportWarning(CLPStr52, last); *match = 0; return 0; } @@ -82,7 +83,7 @@ static Boolean MatchesExtension(const char *list, const char *filename) { return !*list && !*ptr; } -int Opt_AddAccessPath(const char *opt, void *var, const char *arg) { +int Opt_AddAccessPath(const char *opt, void *var, const char *arg, int flags) { OSPathSpec spec; int err; @@ -93,16 +94,16 @@ int Opt_AddAccessPath(const char *opt, void *var, const char *arg) { return 1; if (strlen(arg) >= 256) { - CLPReportError(13, arg + strlen(arg) - 32, 256); + CLPReportError(CLPStr13, arg + strlen(arg) - 32, 256); return 0; } err = OS_MakePathSpec(0, arg, &spec); if (err == ENOENT || err == ENOENT) { - CLPReportWarning(45, arg); + CLPReportWarning(CLPStr45, arg); return 1; } else if (err != 0) { - CLPOSAlert(45, err, arg); + CLPOSAlert(CLPStr45, err, arg); return 1; } @@ -113,7 +114,7 @@ int Opt_AddAccessPath(const char *opt, void *var, const char *arg) { return 1; } -int Opt_AddFrameworkPath(const char *opt, void *var, const char *arg) { +int Opt_AddFrameworkPath(const char *opt, void *var, const char *arg, int flags) { OSPathSpec spec; int err; @@ -124,16 +125,16 @@ int Opt_AddFrameworkPath(const char *opt, void *var, const char *arg) { return 1; if (strlen(arg) >= 256) { - CLPReportError(13, arg + strlen(arg) - 32, 256); + CLPReportError(CLPStr13, arg + strlen(arg) - 32, 256); return 0; } err = OS_MakePathSpec(0, arg, &spec); if (err == ENOENT || err == ENOENT) { - CLPReportWarning(45, arg); + CLPReportWarning(CLPStr45, arg); return 1; } else if (err != 0) { - CLPOSAlert(45, err, arg); + CLPOSAlert(CLPStr45, err, arg); return 1; } else { Frameworks_AddPath(&spec); @@ -141,7 +142,7 @@ int Opt_AddFrameworkPath(const char *opt, void *var, const char *arg) { } } -int Opt_AddFramework(const char *opt, void *var, const char *arg) { +int Opt_AddFramework(const char *opt, void *var, const char *arg, int flags) { if (!Frameworks_AddFramework(arg ? arg : opt, 0, 0)) return 0; else @@ -190,7 +191,7 @@ int AddAccessPathList(const char *list, char sep1, char sep2, int source, char * ListParseMessage( CLPReportError_V, (source == 1) ? text : NULL, - 9, + CLPStr9, tmp, tmp + strlen(tmp) - 16, 256); @@ -202,7 +203,7 @@ int AddAccessPathList(const char *list, char sep1, char sep2, int source, char * ListParseMessage( CLPReportWarning_V, (source == 1) ? text : NULL, - 45, + CLPStr45, tmp); } else { AddAccessPath(&spec, type, position, recurse ^ recursive); @@ -218,7 +219,7 @@ int AddAccessPathList(const char *list, char sep1, char sep2, int source, char * return 1; } -int Opt_FindAndAddFile(const char *opt, void *var, const char *arg) { +int Opt_FindAndAddFile(const char *opt, void *var, const char *arg, int flags) { OSSpec spec; int err; Boolean isfile; @@ -235,11 +236,11 @@ int Opt_FindAndAddFile(const char *opt, void *var, const char *arg) { err = OS_Status(&spec); if (!err && !isfile) { - CLPReportError(47, arg); + CLPReportError(CLPStr47, arg); parseopts.unusedFiles++; return 0; } else if (err && err != ENOENT) { - CLPOSAlert(44, err, arg); + CLPOSAlert(CLPStr44, err, arg); parseopts.unusedFiles++; return 0; } else if (err && parseopts.alwaysUsePaths) { @@ -247,13 +248,13 @@ int Opt_FindAndAddFile(const char *opt, void *var, const char *arg) { } if (err) { - CLPReportError(44, arg); + CLPReportError(CLPStr44, arg); parseopts.unusedFiles++; return 0; } if (var && !MatchesExtension((const char *) var, arg)) - CLPReportWarning(76, arg, var); + CLPReportWarning(CLPStr76, arg, var); if (!AddFileToProject(&spec, lastStage, parseopts.lastoutputname, 1, -1)) { parseopts.unusedFiles++; @@ -277,14 +278,14 @@ int Opt_FindAndAddFileRef(const char *opt, void *var, const char *arg) { parseopts.userSpecifiedFiles++; if (var && !MatchesExtension((const char *) var, arg)) - CLPReportWarning(76, arg, var); + CLPReportWarning(CLPStr76, arg, var); err = OS_MakeSpec(arg, &spec, &isfile); if (!err) err = OS_Status(&spec); if (!err && !isfile) { - CLPReportError(47, arg); + CLPReportError(CLPStr47, arg); parseopts.unusedFiles++; return 0; } else if (err && parseopts.alwaysUsePaths) { @@ -307,7 +308,7 @@ int Opt_AddUnixLibraryFile(const char *opt, void *var, const char *name) { char tmpname[64]; if (strlen(name) >= 56) { - CLPReportError(13, name + strlen(name) - 32, 64); + CLPReportError(CLPStr13, name + strlen(name) - 32, 64); return 0; } @@ -336,7 +337,7 @@ int Opt_AddUnixLibraryFile(const char *opt, void *var, const char *name) { if (failed) { failed = !FindFileInPath(name, &spec); if (failed) - CLPReportError(49, name, var, name); + CLPReportError(CLPStr49, name, var, name); } if (!failed) { @@ -368,7 +369,7 @@ int AddFileList(const char *list, char sep1, char sep2, int source, char *text, ListParseMessage( CLPReportError_V, (source == 1) ? text : 0, - 9, + CLPStr9, tmp, tmp + strlen(tmp) - 16, 256 @@ -381,14 +382,14 @@ int AddFileList(const char *list, char sep1, char sep2, int source, char *text, ListParseMessage( CLPReportError_V, (source == 1) ? text : 0, - 16, + CLPStr16, tmp ); } else { ListParseMessage( CLPReportWarning_V, (source == 1) ? text : 0, - 44, + CLPStr44, tmp ); } @@ -416,18 +417,18 @@ void GetCFileNameInOutputDirectory(const char *input, char *name, int maxlen) { err = OS_MakeFileSpec(input, &spec); if (err) { - CLPOSAlert(64, err, input); + CLPOSAlert(CLPStr64, err, input); name[0] = 0; return; } if (!IsFileInOutputDirectory(&spec)) { - CLPReportWarning(61, OS_SpecToStringRelative(&spec, 0, STSbuf, sizeof(STSbuf))); + CLPReportWarning(CLPStr61, OS_SpecToStringRelative(&spec, 0, STSbuf, sizeof(STSbuf))); } OS_NameSpecToString(&spec.name, filename, 256); if (strlen(filename) >= maxlen) { - CLPReportWarning(65, filename, maxlen - 1); + CLPReportWarning(CLPStr65, filename, maxlen - 1); filename[maxlen - 1] = 0; } @@ -469,7 +470,7 @@ void AddStringToHandle(Handle *h, const char *str) { AddStringLenToHandle(h, str, strlen(str)); } -int Opt_PrintVersion(const char *opt, void *var, const char *arg) { +int Opt_PrintVersion(const char *opt, void *var, const char *arg, int flags) { ShowVersion(0); return 1; } @@ -500,7 +501,7 @@ void GetFirstSourceFilenameBase(char *buffer, char *defaul) { strcpy(buffer, defaul); } -int Opt_SavePrefs(const char *opt, void *var, const char *arg) { +int Opt_SavePrefs(const char *opt, void *var, const char *arg, int flags) { Parser_StorePanels(parseopts.context); return 1; } @@ -520,14 +521,14 @@ int ParseNumber(const char *arg, Boolean emit_error, SInt32 *ret, const char **e *endptr = end; if (*end && emit_error) { - CLPReportError(5, "", arg); + CLPReportError(CLPStr5, "", arg); return 0; } return 1; } -int Opt_MaybeMoveAccessPaths(const char *opt, void *var, const char *arg) { +int Opt_MaybeMoveAccessPaths(const char *opt, void *var, const char *arg, int flags) { if (dashIMinusMovesPaths && !usedDashIMinus) MoveSystemPathsIntoUserList(); return 1; diff --git a/unsorted/Projects.c b/unsorted/Projects.c index 72b06b1..fda92df 100644 --- a/unsorted/Projects.c +++ b/unsorted/Projects.c @@ -1,6 +1,5 @@ -#include "mwcc_decomp.h" +#include "parser.h" -// TODO: figure out who defines this extern char STSbuf[256]; int GetFileCount() { diff --git a/unsorted/StaticParserGlue.c b/unsorted/StaticParserGlue.c index 4673c27..c2e130d 100644 --- a/unsorted/StaticParserGlue.c +++ b/unsorted/StaticParserGlue.c @@ -1,4 +1,5 @@ -#include "mwcc_decomp.h" +#include "parser.h" +#include "cmdline.h" static BasePluginCallbacks cb = { parser_main, diff --git a/unsorted/TargetOptimizer-ppc-mach.c b/unsorted/TargetOptimizer-ppc-mach.c new file mode 100644 index 0000000..10fe33e --- /dev/null +++ b/unsorted/TargetOptimizer-ppc-mach.c @@ -0,0 +1,69 @@ +#include "parser.h" + +char schedule_ppc_default; + +int TargetSetOptFlags(short val, Boolean set) { + switch (val) { + case 'Pe': + pBackEnd.peephole = set; + break; + case 'Sn': + pBackEnd.schedule = 0; + break; + case 'Sh': + pBackEnd.schedule = set; + break; + case 'S?': + pBackEnd.processor = schedule_ppc_default; + break; + case 'SG': + pBackEnd.processor = schedule_ppc_default = 0; + break; + case 'S1': + pBackEnd.processor = schedule_ppc_default = 1; + break; + case 'S3': + pBackEnd.processor = schedule_ppc_default = 2; + break; + case 'S#': + pBackEnd.processor = schedule_ppc_default = 3; + break; + case 'S4': + pBackEnd.processor = schedule_ppc_default = 4; + break; + case 'S%': + pBackEnd.processor = schedule_ppc_default = 5; + break; + case 'S7': + pBackEnd.processor = schedule_ppc_default = 6; + break; + case 'SA': + pBackEnd.processor = schedule_ppc_default = 7; + break; + default: + return 0; + } + + return 1; +} + +void TargetDisplayOptimizationOptions(Handle txt) { + if (!pBackEnd.schedule) { + HPrintF(txt, "\t- no instruction scheduling\n"); + } else { + HPrintF(txt, "\t- schedule for %s\n", + (pBackEnd.processor == 0) ? "generic PPC" : + (pBackEnd.processor == 1) ? "601" : + (pBackEnd.processor == 2) ? "603" : + (pBackEnd.processor == 3) ? "603e" : + (pBackEnd.processor == 4) ? "604" : + (pBackEnd.processor == 5) ? "604e" : + (pBackEnd.processor == 6) ? "750" : + (pBackEnd.processor == 7) ? "Altivec" : + "???" + ); + } +} + +void TargetSetPragmaOptimizationsToUnspecified() { +} diff --git a/unsorted/Targets.c b/unsorted/Targets.c index b4307ff..accad8b 100644 --- a/unsorted/Targets.c +++ b/unsorted/Targets.c @@ -1,4 +1,4 @@ -#include "mwcc_decomp.h" +#include "parser.h" ParserTool *pTool; @@ -18,8 +18,8 @@ Boolean ParserToolMatchesPlugin(OSType type, OSType lang, OSType cpu, OSType os) } if ( - (type == CWFOURCHAR('*','*','*','*') || pTool->TYPE == CWFOURCHAR('*','*','*','*') || pTool->TYPE == type) && - (lang == CWFOURCHAR('*','*','*','*') || pTool->LANG == CWFOURCHAR('*','*','*','*') || pTool->LANG == lang) && + (type == CWDROPINANYTYPE || pTool->TYPE == CWDROPINANYTYPE || pTool->TYPE == type) && + (lang == Lang_Any || pTool->LANG == Lang_Any || pTool->LANG == lang) && (cpu == targetCPUAny || pTool->CPU == targetCPUAny || pTool->CPU == cpu) && (os == targetOSAny || pTool->OS == targetOSAny || pTool->OS == os) ) diff --git a/unsorted/ToolHelpers-cc.c b/unsorted/ToolHelpers-cc.c index dd0bc92..fee7517 100644 --- a/unsorted/ToolHelpers-cc.c +++ b/unsorted/ToolHelpers-cc.c @@ -1,6 +1,7 @@ -#include "mwcc_decomp.h" +#include "parser.h" +#include "cmdline.h" -int Opt_DummyLinkerRoutine(const char *opt) { +int Opt_DummyLinkerRoutine(const char *opt, void *, const char *, int) { CLPFatalError("Calling linker option '%s'\n", opt); return 0; } diff --git a/unsorted/ToolHelpers.c b/unsorted/ToolHelpers.c index 1942072..e872546 100644 --- a/unsorted/ToolHelpers.c +++ b/unsorted/ToolHelpers.c @@ -1,16 +1,16 @@ -#include "mwcc_decomp.h" +#include "parser.h" +#include "cmdline.h" #include -// TODO: figure out who defines this extern char STSbuf[256]; static Boolean setStage; -SInt16 outputOrdering; -Boolean setOutputDirectory; -Boolean setLinkerOutputFilename; char linkerOutputFilename[256]; +Boolean setLinkerOutputFilename; +Boolean setOutputDirectory; +SInt16 outputOrdering; -int Opt_HandleOutputName(const char *opt, void *, const char *filename) { +int Opt_HandleOutputName(const char *opt, void *, const char *filename, int flags) { OSSpec spec; int err; SInt32 result; @@ -21,7 +21,7 @@ int Opt_HandleOutputName(const char *opt, void *, const char *filename) { if ((pCmdLine.state == OptsCmdLineState_3 || (pCmdLine.state == OptsCmdLineState_0 && pTool->TYPE == CWDROPINLINKERTYPE)) && pCmdLine.toDisk != 4) { if (setLinkerOutputFilename) { - CLPReportError(41, filename); + CLPReportError(CLPStr41, filename); return 0; } setLinkerOutputFilename = 1; @@ -33,7 +33,7 @@ int Opt_HandleOutputName(const char *opt, void *, const char *filename) { Boolean isfile; err = OS_MakeSpec(filename, &spec, &isfile); if (err) { - CLPOSAlert(64, err, filename); + CLPOSAlert(CLPStr64, err, filename); return 0; } if (isfile) @@ -44,14 +44,14 @@ int Opt_HandleOutputName(const char *opt, void *, const char *filename) { } else { err = OS_MakeSpec(filename, &spec, &isfile); if (err) { - CLPOSAlert(64, err, filename); + CLPOSAlert(CLPStr64, err, filename); return 0; } if (!err && !isfile) { FSSpec ofd; if (setOutputDirectory) { - CLPReportError(59, filename); + CLPReportError(CLPStr59, filename); return 0; } setOutputDirectory = 1; @@ -67,7 +67,7 @@ int Opt_HandleOutputName(const char *opt, void *, const char *filename) { SInt32 index; CWProjectFileInfo pfi; if (parseopts.lastoutputname[0]) { - CLPReportError(41, filename); + CLPReportError(CLPStr41, filename); return 0; } strncpy(parseopts.lastoutputname, filename, 256); @@ -115,7 +115,7 @@ int ValidateToolState(Boolean mustHaveFiles) { if (!parseopts.userSpecifiedFiles) { if (!parseopts.hadAnyOutput) { if (mustHaveFiles) { - CLPReportError(70); + CLPReportError(CLPStr70); return 0; } } else { @@ -124,7 +124,7 @@ int ValidateToolState(Boolean mustHaveFiles) { return 1; } } else if (parseopts.unusedFiles > 0) { - CLPReportError(69); + CLPReportError(CLPStr69); return 0; } } @@ -195,7 +195,7 @@ int Opt_DoNotLink(const char *opt, void *var, const char *arg) { return 1; } -int Opt_IncreaseVerbosity(const char *opt, void *var, const char *arg) { +int Opt_IncreaseVerbosity(const char *opt, void *var, const char *arg, int flags) { if (pCmdLine.verbose) pCmdLine.verbose++; else @@ -275,13 +275,13 @@ int Opt_RedirectStream(const char *opt, void *file, const char *filename) { err = OS_MakeFileSpec(filename, &spec); if (err) { - CLPReportError(78, filename, OS_GetErrText(err)); + CLPReportError(CLPStr78, filename, OS_GetErrText(err)); return 0; } nw = freopen(OS_SpecToString(&spec, STSbuf, 256), "wt", (FILE *) file); if (!nw) { - CLPReportError(78, filename, strerror(errno)); + CLPReportError(CLPStr78, filename, strerror(errno)); return 0; } diff --git a/unsorted/Utils.c b/unsorted/Utils.c new file mode 100644 index 0000000..b627c4d --- /dev/null +++ b/unsorted/Utils.c @@ -0,0 +1,174 @@ +#include "parser.h" + +int my_tolower(char c) { + if (c >= 'A' && c <= 'Z') + return c | 0x20; + else + return c; +} + +int my_isdigit(char c) { + return (c >= '0' && c <= '9'); +} + +int my_isalpha(char c) { + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); +} + +int my_isalnum(char c) { + return my_isdigit(c) || my_isalpha(c); +} + +int my_isxdigit(char c) { + return my_isdigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); +} + +char *Utils_SpellList(char *list, char *buffer, char opts) { + char *sptr; + char *eptr; + char *nptr; + char *bptr; + int pflen; + int npflen; + int undo; + char *neptr; + int cnt; + + undo = 0; + bptr = buffer; + sptr = list; + pflen = 0; + while (sptr) { + if ((opts & 1) && !pflen) + *(bptr++) = *MAINOPTCHAR; + + eptr = strchr(sptr, '|'); + if (!eptr) { + eptr = sptr + strlen(sptr); + nptr = 0; + } else if (eptr[1] == '|') { + nptr = 0; + } else { + nptr = eptr + 1; + } + + if (undo == 0 && !pflen) { + if (opts & 8) { + *(bptr++) = '['; + *(bptr++) = 'n'; + *(bptr++) = 'o'; + *(bptr++) = ']'; + } + if (opts & 0x20) { + *(bptr++) = '['; + *(bptr++) = 'n'; + *(bptr++) = 'o'; + *(bptr++) = '-'; + *(bptr++) = ']'; + } + } + + npflen = 0; + if (nptr) { + while (sptr < nptr && *nptr && *nptr != '|' && sptr[npflen] == nptr[npflen]) + npflen++; + + if (npflen) { + neptr = strchr(nptr, '|'); + if (!neptr) + neptr = nptr + strlen(nptr); + if ((neptr - nptr) < (eptr - sptr) || ((sptr[1] && sptr[1] != '|') ? (sptr[1] != nptr[1]) : 0)) + npflen = 0; + if (opts & 0x40) + npflen = 0; + } + } + + if (pflen) { + sptr += pflen; + while (sptr < eptr) { + *(bptr++) = *(sptr++); + } + if (npflen > pflen) { + *(bptr++) = '['; + undo++; + } + if (npflen < pflen) { + *(bptr++) = ']'; + undo--; + } + } else if (npflen) { + for (cnt = npflen; cnt > 0; cnt--) { + *(bptr++) = *(sptr++); + } + *(bptr++) = '['; + undo++; + } + + while (sptr < eptr) { + *(bptr++) = *(sptr++); + } + + if (opts & 0x10) { + *(bptr++) = '['; + *(bptr++) = '-'; + *(bptr++) = ']'; + } + if (opts & 0x40) { + *(bptr++) = '+'; + } + + sptr = nptr; + if (nptr && bptr[-1] != '[') { + if ((opts & 1) || (bptr[-1] == ']') || ((opts & 8) && !undo)) { + *(bptr++) = ' '; + *(bptr++) = '|'; + *(bptr++) = ' '; + } else { + *(bptr++) = '|'; + } + } + + opts &= ~0x40; + pflen = npflen; + } + + for (cnt = undo; cnt; cnt--) { + *(bptr++) = ']'; + } + + if (opts & 4) + bptr += sprintf(bptr, "=..."); + + *bptr = 0; + return bptr; +} + +int Utils_CompareOptionString(const char *a, const char *b, int cased, int sticky) { + const char *ae; + const char *be; + + for (ae = a; *ae && *ae != '|'; ae++) {} + for (be = b; *be && *be != '|'; be++) {} + + if (sticky && (be - b) < (ae - a)) + return 0; + + if (cased) { + while (a < ae && b < be) { + if (*a != *b) + break; + a++; + b++; + } + } else { + while (a < ae && b < be) { + if (my_tolower(*a) != my_tolower(*b)) + break; + a++; + b++; + } + } + + return (a == ae) && (sticky || b == be); +} diff --git a/unsorted/uCOS.c b/unsorted/uCOS.c new file mode 100644 index 0000000..5564e5b --- /dev/null +++ b/unsorted/uCOS.c @@ -0,0 +1,292 @@ +#include "cw_common.h" +#include "cos.h" + +extern Boolean systemHandles; + +static StringPtr COS_pstrcpy(StringPtr dst, ConstStringPtr src) { + short cnt; + for (cnt = src[0]; cnt >= 0; cnt--) { + *(dst++) = *(src++); + } + return dst; +} + +static StringPtr COS_pstrcat(StringPtr dst, ConstStringPtr src) { + // not matching + short as; + short bs; + + bs = *(src++); + as = dst[0]; + if ((bs + as) > 255) + bs = 255 - as; + + dst[0] += bs; + dst = &dst[as]; + dst++; + + while (bs-- > 0) { + *(dst++) = *(src++); + } + return dst; +} + +static void COS_pstrcharcat(StringPtr to, char ch) { + if (to[0] < 255) { + to[0]++; + to[to[0]] = ch; + } +} + +static short COS_pstrcmp(ConstStringPtr a, ConstStringPtr b) { + short as, bs; + if ((bs = *(b++)) != (as = *(a++))) + return 1; + while (as-- > 0) { + if (*(a++) != *(b++)) + return 1; + } + return 0; +} + +Handle COS_NewHandle(SInt32 byteCount) { + return NewHandle(byteCount); +} + +Handle COS_NewOSHandle(SInt32 logicalSize) { + OSErr err; + Handle h; + + if (systemHandles) { + h = TempNewHandle(logicalSize, &err); + if (!err) + return h; + } + + return NULL; +} + +void COS_FreeHandle(Handle handle) { + DisposeHandle(handle); +} + +Boolean COS_ResizeHandle(Handle handle, SInt32 newSize) { + SetHandleSize(handle, newSize); + return LMGetMemErr() == noErr; +} + +SInt32 COS_GetHandleSize(Handle handle) { + return GetHandleSize(handle); +} + +void COS_LockHandle(Handle handle) { + HLock(handle); +} + +void COS_LockHandleHi(Handle handle) { + HLockHi(handle); +} + +void COS_UnlockHandle(Handle handle) { + HUnlock(handle); +} + +int COS_GetHandleState(Handle handle) { + return HGetState(handle); +} + +void COS_SetHandleState(Handle handle, int state) { + HSetState(handle, state); +} + +Boolean COS_IsLockedState(int state) { + return (state & 0x80) >> 7; +} + +char *COS_NewPtr(SInt32 byteCount) { + return NewPtr(byteCount); +} + +char *COS_NewPtrClear(SInt32 byteCount) { + return NewPtrClear(byteCount); +} + +void COS_FreePtr(char *ptr) { + DisposePtr(ptr); +} + +void COS_AppendPtrToHandle(char *ptr1, Handle hand2, SInt32 size) { + PtrAndHand(ptr1, hand2, size); +} + +OSErr COS_GetMemErr() { + return LMGetMemErr(); +} + +SInt32 COS_GetTicks() { + return LMGetTicks(); +} + +SInt32 COS_GetTime() { + return LMGetTime(); +} + +void COS_GetString(char *buffer, SInt16 strListID, SInt16 index) { + GetIndString((StringPtr) buffer, strListID, index); + p2cstr((StringPtr) buffer); +} + +void COS_GetPString(StringPtr buffer, SInt16 strListID, SInt16 index) { + GetIndString((StringPtr) buffer, strListID, index); +} + +Boolean COS_IsMultiByte(const char *str, int offset) { + return OS_IsMultiByte(str, offset); +} + +OSErr COS_FileNew(const FSSpec *spec, SInt16 *refNum, OSType creator, OSType fileType) { + OSErr err; + + HDelete(spec->vRefNum, spec->parID, spec->name); + err = HCreate(spec->vRefNum, spec->parID, spec->name, creator, fileType); + if (!err) + err = HOpenDF(spec->vRefNum, spec->parID, spec->name, fsRdWrPerm, refNum); + return err; +} + +OSErr COS_FileOpen(const FSSpec *spec, SInt16 *refNum) { + return HOpenDF(spec->vRefNum, spec->parID, spec->name, fsRdPerm, refNum); +} + +OSErr COS_FileGetType(const FSSpec *spec, OSType *fileType) { + OSErr err; + FInfo fi; + + err = HGetFInfo(spec->vRefNum, spec->parID, spec->name, &fi); + *fileType = fi.fdType; + return err; +} + +OSErr COS_FileGetSize(SInt16 refNum, SInt32 *logEOF) { + return GetEOF(refNum, logEOF); +} + +OSErr COS_FileRead(SInt16 refNum, void *buffPtr, SInt32 count) { + return FSRead(refNum, &count, buffPtr); +} + +OSErr COS_FileWrite(SInt16 refNum, const void *buffPtr, SInt32 count) { + return FSWrite(refNum, &count, buffPtr); +} + +OSErr COS_FileGetPos(SInt16 refNum, SInt32 *filePos) { + return GetFPos(refNum, filePos); +} + +OSErr COS_FileSetPos(SInt16 refNum, SInt32 filePos) { + return SetFPos(refNum, fsFromStart, filePos); +} + +OSErr COS_FileClose(SInt16 refNum) { + return FSClose(refNum); +} + +void COS_FileSetFSSpec(FSSpec *spec, ConstStringPtr path) { + char buf[256]; + OSSpec ospec; + + memcpy(buf, path + 1, path[0]); + buf[path[0]] = 0; + + if (OS_MakeSpec(buf, &ospec, NULL) || OS_OSSpec_To_FSSpec(&ospec, spec)) { + spec->vRefNum = 0; + spec->parID = 0; + c2pstrcpy(spec->name, buf); + } +} + +OSErr COS_FileMakeFSSpec(SInt16 vRefNum, SInt32 dirID, ConstStringPtr fileName, FSSpec *spec) { + int oerr; + OSPathSpec opspec; + char buf[256]; + OSSpec ospec; + + oerr = OS_VolDir_To_OSPathSpec(vRefNum, dirID, &opspec); + if (oerr) + return OS_MacError(oerr); + + p2cstrcpy(buf, fileName); + oerr = OS_MakeSpecWithPath(&opspec, buf, 0, &ospec); + if (oerr) { + pstrncpy(spec->name, fileName, 256); + return OS_MacError(oerr); + } else { + return OS_MacError(OS_OSSpec_To_FSSpec(&ospec, spec)); + } +} + +OSErr COS_FileMakeFSSpecWithPath(const FSSpec *inputSpec, ConstStringPtr fileName, FSSpec *spec) { + spec->vRefNum = inputSpec->vRefNum; + spec->parID = inputSpec->parID; + COS_pstrcpy(spec->name, fileName); + return noErr; +} + +OSErr COS_FileGetFileInfo(const FSSpec *spec, OSType *creator, OSType *fileType) { + OSErr err; + FInfo fi; + err = HGetFInfo(spec->vRefNum, spec->parID, spec->name, &fi); + if (fileType) + *fileType = fi.fdType; + if (creator) + *creator = fi.fdCreator; + return err; +} + +void COS_FileGetFSSpecInfo(const FSSpec *spec, SInt16 *vRefNum, SInt32 *dirID, StringPtr fileName) { + if (vRefNum) + *vRefNum = spec->vRefNum; + if (dirID) + *dirID = spec->parID; + if (fileName) + COS_pstrcpy(fileName, spec->name); +} + +static void COS_MakePath(SInt16 vRefNum, SInt32 dirID, StringPtr path) { + FSSpec fss; + OSSpec oss; + fss.vRefNum = vRefNum; + fss.parID = dirID; + COS_pstrcpy(fss.name, path); + if (!OS_FSSpec_To_OSSpec(&fss, &oss)) { + OS_SpecToString(&oss, (char *) path, 256); + c2pstr((char *) path); + } +} + +void COS_FileGetPathName(char *buffer, const FSSpec *spec, SInt32 *mdDat) { + HParamBlockRec rec; + + if (mdDat) { + rec.fileParam.ioNamePtr = (StringPtr) spec->name; + rec.fileParam.ioVRefNum = spec->vRefNum; + rec.fileParam.ioDirID = spec->parID; + rec.fileParam.ioFDirIndex = 0; + if (!PBHGetFInfoSync(&rec)) + *mdDat = rec.fileParam.ioFlMdDat; + else + *mdDat = 0; + } + + COS_pstrcpy((StringPtr) buffer, spec->name); + COS_MakePath(spec->vRefNum, spec->parID, (StringPtr) buffer); + p2cstr((StringPtr) buffer); +} + +int COS_EqualFileSpec(const FSSpec *a, const FSSpec *b) { + if (a->vRefNum != b->vRefNum) + return 0; + if (a->parID != b->parID) + return 0; + return COS_pstrcmp(a->name, b->name) == 0; +} diff --git a/unsorted/uContextParser.cpp b/unsorted/uContextParser.cpp index be1aa0a..35d6dfa 100644 --- a/unsorted/uContextParser.cpp +++ b/unsorted/uContextParser.cpp @@ -103,7 +103,7 @@ CW_CALLBACK CWParserStoreCommandLineForPlugin(CWPluginContext context, int index return cwNoErr; } -CW_CALLBACK CWParserSetNamedPreferences(CWPluginContext context, const char *panelName, CWMemHandle paneldata) { +CW_CALLBACK CWParserSetNamedPreferences(CWPluginContext context, const char *panelName, Handle paneldata) { CWParserContext *pc; if (!(pc = GetContext(context))) return cwErrInvalidCallback; diff --git a/unsorted/uLibImporter.c b/unsorted/uLibImporter.c new file mode 100644 index 0000000..3cf3475 --- /dev/null +++ b/unsorted/uLibImporter.c @@ -0,0 +1,103 @@ +#include "cw_common.h" +#include "cos.h" + +static CWPluginContext compiler_context; + +static void pstrcpy(StringPtr dst, ConstStringPtr src) { + short len = src[0]; + do { + *(dst++) = *(src++); + } while (len-- > 0); +} + +static void ReportError(int index, int osErr) { + char buf[256]; + COS_GetString(buf, 911, index); + if (osErr) + CWOSErrorMessage(compiler_context, buf, osErr); + else + CWReportMessage(compiler_context, NULL, buf, NULL, messagetypeError, 0); +} + +static CWMemHandle ImportObjectLibrary(CWFileSpec *spec, SInt32 *codesize, SInt32 *udatasize, SInt32 *idatasize) { + int err; + short ref; + CWMemHandle mh; + UInt32 *ptr; + SInt32 fsize; + + err = COS_FileOpen(spec, &ref); + if (err) { + ReportError(1, err); + return NULL; + } + + err = COS_FileGetSize(ref, &fsize); + if (err) { + COS_FileClose(ref); + ReportError(1, err); + return NULL; + } + + err = CWAllocMemHandle(compiler_context, 8, 1, &mh); + if (err) { + COS_FileClose(ref); + ReportError(1, err); + return NULL; + } + + err = CWLockMemHandle(compiler_context, mh, 0, (void **) &ptr); + if (err) { + COS_FileClose(ref); + CWFreeMemHandle(compiler_context, mh); + ReportError(1, err); + return NULL; + } + + err = COS_FileRead(ref, ptr, 8); + if (err != (short) err) { + ReportError(1, err); + return NULL; + } + + COS_FileClose(ref); + + if (ptr[0] != 0xFEEDFACE && ptr[0] != 0xCAFEBABE && ptr[0] != CWFOURCHAR('!','<','a','r') && ptr[1] != CWFOURCHAR('c','h','>','\n')) { + CWFreeMemHandle(compiler_context, mh); + ReportError(2, 0); + return NULL; + } + + CWUnlockMemHandle(compiler_context, mh); + *codesize = fsize; + *udatasize = 0; + *idatasize = 0; + return mh; +} + +CWPLUGIN_ENTRY(PPCLibImport_main)(CWPluginContext context) { + SInt32 request; + CWResult result; + CWFileSpec fss; + SInt32 fileNumber; + CWObjectData od; + + result = cwNoErr; + + CWGetPluginRequest(context, &request); + switch (request) { + case reqInitialize: + case reqTerminate: + break; + case 0: + compiler_context = context; + CWGetMainFileSpec(context, &fss); + CWGetMainFileNumber(context, &fileNumber); + memset(&od, 0, sizeof(od)); + od.objectdata = ImportObjectLibrary(&fss, &od.codesize, &od.udatasize, &od.idatasize); + result = CWDonePluginRequest(context, od.objectdata ? CWStoreObjectData(context, fileNumber, &od) : cwErrRequestFailed); + break; + } + + return result; +} -- cgit v1.2.3