diff options
author | Ash Wolf <ninji@wuffs.org> | 2022-10-13 17:56:43 +0100 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2022-10-13 17:56:43 +0100 |
commit | b8df05413a4e8b299de07b915cddce73a3bb16e3 (patch) | |
tree | 74260aa4137676a7dc40fab0d07526d39a1de688 /UMain.c | |
parent | 59a724bd4cc7a543686c633572510e6763b34d39 (diff) | |
download | MWCC-b8df05413a4e8b299de07b915cddce73a3bb16e3.tar.gz MWCC-b8df05413a4e8b299de07b915cddce73a3bb16e3.zip |
finish CLMain.c
Diffstat (limited to '')
-rw-r--r-- | UMain.c | 102 |
1 files changed, 0 insertions, 102 deletions
diff --git a/UMain.c b/UMain.c deleted file mode 100644 index 752f640..0000000 --- a/UMain.c +++ /dev/null @@ -1,102 +0,0 @@ -#include "includes/mwcc_decomp.h" - -// TODO split main off into CLStaticMain.c -int main(int argc, const char **argv) { - CWDataType cpu; - CWDataType os; - CWDataType lang; - CWDataType type; - CWDataType style; - int ret; - - if (CmdLine_Initialize(argc, argv, CMDLINE_BUILD_DATE, CMDLINE_BUILD_TIME)) - exit(1); - - if (!RegisterStaticParserResources() || !RegisterStaticTargetResources()) { - fprintf(stderr, "\nFATAL ERROR: Could not initialize resource strings\n"); - exit(1); - } - - if (!RegisterStaticParserPlugins() || !RegisterStaticTargetPlugins()) { - fprintf(stderr, "\nFATAL ERROR: Could not initialize built-in plugins\n"); - exit(1); - } - - if (!RegisterStaticParserToolInfo()) { - fprintf(stderr, "\nFATAL ERROR: Could not initialize options\n"); - exit(1); - } - - GetStaticTarget(&cpu, &os); - SetBuildTarget(cpu, os); - GetStaticPluginType(&lang, &type); - SetPluginType(lang, type); - GetStaticParserPluginType(&style); - SetParserType(style); - - ret = CmdLine_Driver(); - if (ret) { - if (ret == 2) - fprintf(stderr, "\nUser break, cancelled...\n"); - else - fprintf(stderr, "\nErrors caused tool to abort.\n"); - } - CmdLine_Terminate(ret); - return ret; -} - -int RegisterResource(const char *name, short rsrcid, Handle list) { - Handle h; - - if (data == 0) { - h = GetResource('STR#', rsrcid); - if (h == 0) { - CLFatalError("Resource ('STR#',%d) '%s' not found in executable\n", rsrcid, name); - return 0; - } - ReleaseResource(h); - return 1; - } else { - return Res_AddResource(name, rsrcid, list); - } -} - -int RegisterStaticPlugin(const BasePluginCallbacks *callbacks) { - return Plugins_Add(Plugin_New(callbacks, 0, 0)); -} - -int RegisterStaticCompilerLinkerPlugin(const BasePluginCallbacks *callbacks, const CompilerLinkerPluginCallbacks *cl_callbacks) { - return Plugins_Add(Plugin_New(callbacks, cl_callbacks, 0)); -} - -int RegisterStaticParserPlugin(const BasePluginCallbacks *callbacks, const ParserPluginCallbacks *pr_callbacks) { - return Plugins_Add(Plugin_New(callbacks, 0, pr_callbacks)); -} - -void SetBuildTarget(CWDataType cpu, CWDataType os) { - clState.cpu = cpu; - clState.os = os; -} - -void SetParserType(CWDataType plang) { - clState.parserstyle = plang; -} - -void SetPluginType(CWDataType lang, CWDataType type) { - clState.language = lang; - clState.plugintype = type; -} - -int CmdLine_Initialize(int argc, const char **argv, const char *builddate, const char *buildtime) { - strncpy(cmdline_build_date, builddate, sizeof(cmdline_build_date)); - strncpy(cmdline_build_time, buildtime, sizeof(cmdline_build_time)); - return Main_Initialize(argc, argv); -} - -int CmdLine_Driver() { - return Main_Driver(); -} - -int CmdLine_Terminate(int exitcode) { - return Main_Terminate(exitcode); -} |