summaryrefslogtreecommitdiff
path: root/ParserFace.c
diff options
context:
space:
mode:
Diffstat (limited to 'ParserFace.c')
-rw-r--r--ParserFace.c226
1 files changed, 0 insertions, 226 deletions
diff --git a/ParserFace.c b/ParserFace.c
deleted file mode 100644
index 7ce84e5..0000000
--- a/ParserFace.c
+++ /dev/null
@@ -1,226 +0,0 @@
-#include "UCWInterface.h"
-
-struct ParseOptsType parseopts;
-
-// TODO move me imports
-extern CWResult CWSecretGetNamedPreferences(CWPluginContext context, const char *name, Handle *pHandle);
-extern CWResult CWParserSetNamedPreferences(CWPluginContext context, const char *name, Handle pHandle);
-extern CWResult CWParserGetCommandLine(CWPluginContext context, CWCommandLineArgs **pArgs);
-extern CWResult CWParserGetToolInfo(CWPluginContext context, struct ToolVersionInfo **pToolVersion);
-extern CWResult CWParserGetTargetInfo(CWPluginContext context, unsigned long *pCpu, unsigned long *pOs);
-extern CWResult CWParserGetPanels(CWPluginContext context, int *pNumPanels, char ***pPanelNames);
-extern CWResult CWParserGetPlugins(CWPluginContext context, int *pNumPlugins, struct CLPluginInfo **pPlugins);
-extern void/*?*/ CWGetPluginRequest(CWPluginContext context, long *request);
-extern void/*?*/ CWDonePluginRequest(CWPluginContext context, CWResult result);
-extern void *pTool;
-extern void SetupParserToolOptions();
-extern void CLPReportError(short code, ...);
-extern unsigned char ParserToolMatchesPlugin(unsigned long plugintype, unsigned long language, unsigned long cpu, unsigned long os);
-extern unsigned char ParserToolHandlesPanels(int numPanels, char **panelNames);
-// TODO move me imports
-
-char *failedCallback;
-
-static CWResult SetupParamBlock(CWPluginContext context) {
- struct PCmdLineEnvir cle;
- Handle h;
- int x;
- CWResult result;
-
- memset(&parseopts, 0, sizeof(parseopts));
- parseopts.context = context;
-
- result = CWSecretGetNamedPreferences(context, "CmdLine Environment", &h);
- if (result)
- return result;
-
- cle = **((struct PCmdLineEnvir **) h);
- parseopts.underIDE = cle.underIDE;
- parseopts.ioRows = cle.rows;
- parseopts.ioCols = cle.cols;
-
- result = CWParserGetCommandLine(context, &parseopts.args);
- if (result)
- return result;
-
- result = CWParserGetToolInfo(context, &parseopts.toolVersion);
- if (result)
- return result;
-
- result = CWParserGetTargetInfo(context, &parseopts.cpu, &parseopts.os);
- if (result)
- return result;
-
- result = CWParserGetPanels(context, &parseopts.numPanels, &parseopts.panelNames);
- if (result)
- return result;
-
- result = CWParserGetPlugins(context, &parseopts.numPlugins, &parseopts.plugins);
- if (result)
- return result;
-
- parseopts.passingArgs = 0;
- for (x = 0; x < parseopts.numPlugins; x++) {
- if (parseopts.plugins[x].storeCommandLine)
- parseopts.passingArgs = 1;
- }
-
- return 0;
-}
-
-static CWResult SetupOptions(CWPluginContext context) {
- if (!pTool) {
- return 2;
- } else {
- SetupParserToolOptions();
- return 0;
- }
-}
-
-static CWResult Parse(CWPluginContext context) {
- CWResult result;
-
- // TODO
- return result;
-}
-
-Handle Parser_FindPrefPanel(char *name) {
- Handle h;
- int idx;
-
- // TODO pTool
-}
-
-CWResult Parser_StorePanels(CWPluginContext context) {
- int idx;
- CWResult result;
- char *name;
- Handle h;
-
- for (idx = 0; idx < parseopts.numPanels; idx++) {
- name = parseopts.panelNames[idx];
- h = Parser_FindPrefPanel(name);
- if (h) {
- result = CWParserSetNamedPreferences(parseopts.context, name, h);
- if (result) {
- CLPReportError(68, name);
- return result;
- }
- }
- }
-
- return 0;
-}
-
-static CWResult StoreResults(CWPluginContext context) {
- // TODO Arg
-}
-
-short CWParser_GetDropInFlags(const DropInFlags **flags, long *flagsSize) {
- static const DropInFlags sFlags = {
- kCurrentDropInFlagsVersion,
- CWFOURCHAR('P','a','r','s'),
- 7,
- 0,
- 'Seep',
- 12
- };
- *flags = &sFlags;
- *flagsSize = sizeof(sFlags);
- return 0;
-}
-
-short CWParser_GetDropInName(const char **dropinName) {
- static const char *sDropInName = "Command-Line Parser";
- *dropinName = sDropInName;
- return 0;
-}
-
-short CWParser_GetDisplayName(const char **displayName) {
- static const char *sDisplayName = "Command-Line Parser";
- *displayName = sDisplayName;
- return 0;
-}
-
-short CWParser_GetPanelList(const CWPanelList **panelList) {
- static const CWPanelList sPanelList = {
- kCurrentCWFamilyListVersion,
- 0,
- 0
- };
- *panelList = &sPanelList;
- return 0;
-}
-
-short CWParser_GetTargetList(const CWTargetList **targetList) {
- static const unsigned long sCPU = '****';
- static const unsigned long sOS = '****';
- static const CWTargetList sTargetList = {
- kCurrentCWTargetListVersion,
- 1,
- &sCPU,
- 1,
- &sOS
- };
- *targetList = &sTargetList;
- return 0;
-}
-
-short CWParser_GetVersionInfo(const VersionInfo **versioninfo) {
- static const VersionInfo vi = {
- 1, 1, 0, 0
- };
- *versioninfo = &vi;
- return 0;
-}
-
-short Parser_SupportsPlugin(struct CLPluginInfo *pluginfo, CWDataType cpu, CWDataType os, Boolean *isSupported) {
- *isSupported = ParserToolMatchesPlugin(pluginfo->plugintype, pluginfo->language, cpu, os);
- return 0;
-}
-
-short Parser_SupportsPanels(int numPanels, char **panelNames, Boolean *isSupported) {
- *isSupported = ParserToolHandlesPanels(numPanels, panelNames);
- return 0;
-}
-
-jmp_buf exit_plugin;
-
-short parser_main(CWPluginContext context) {
- long request;
- CWResult result;
-
- CWGetPluginRequest(context, &request);
- result = setjmp(exit_plugin);
- if (result == 0) {
- switch (request) {
- case reqInitialize:
- result = 0;
- break;
- case 0:
- break;
- case 1:
- result = SetupParamBlock(context);
- if (!result)
- result = Parser_StorePanels(context);
- break;
- case 2:
- result = SetupParamBlock(context);
- if (!result) {
- result = SetupOptions(context);
- if (!result) {
- result = Parse(context);
- if (!result)
- result = StoreResults(context);
- }
- }
- break;
- }
- } else {
- if (failedCallback && result != 1)
- fprintf(stderr, "Unexpected error in %s [%d]\n", failedCallback, result);
- }
- CWDonePluginRequest(context, result);
-
- return result;
-}