From 775b6861666af36d317fb577cf489e2c6377f878 Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Fri, 14 Oct 2022 23:15:32 +0100 Subject: add tons of stuff --- includes/ParserErrors.r | 81 ++++++ includes/common.h | 17 +- includes/mwcc_decomp.h | 693 ++++++--------------------------------------- includes/option_system.h | 413 +++++++++++++++++++++++++++ includes/plugin.h | 201 +++++++++++++ includes/plugin_internal.h | 84 ++++++ 6 files changed, 884 insertions(+), 605 deletions(-) create mode 100644 includes/ParserErrors.r create mode 100644 includes/option_system.h create mode 100644 includes/plugin.h create mode 100644 includes/plugin_internal.h (limited to 'includes') diff --git a/includes/ParserErrors.r b/includes/ParserErrors.r new file mode 100644 index 0000000..8e6b14d --- /dev/null +++ b/includes/ParserErrors.r @@ -0,0 +1,81 @@ +static const char *STR12010[79] = { + "Option missing", + "Command-line argument '%.15s...%.15s' is much too long, maximum accepted length is %d characters", + "Parameter for '%s' missing", + "Numeric constant '%s' overflowed 32-bit range", + "Invalid %sconstant '%s'", + "Numeric constant %lu is out of the legal range %lu - %lu", + "Numeric constant %lu is out of the legal range %lu - %lu; clipping to %lu", + "Four-char type '%s' is too long, expected maximum four characters", + "String constant '%.16s...%.16s' too long, expected maximum %ld characters", + "Identifier '%s' cannot start with a digit", + "Identifier '%s' cannot contain the character '%c'", + "Expected 'on' or 'off', but got '%s'", + "Filename or directory '...%32s' is too long, expected maximum %ld characters", + "Directory '...%32s' combined with filename '...%32s' is too long, maximum path is %ld characters", + "File '%s' does not exist", + "'%s' is a directory or volume, filename expected", + "'%s' does not refer to a directory", + "File path '%s' not accepted\n(%s)", + "Unknown option '%s'", + "Unknown option '%s'; expected one of '%s'", + "Option is obsolete", + "Option is obsolete; %s", + "Option '%s' substituted with %s", + "Option deprecated; accepted this time", + "Option deprecated, accepted this time; use '%s' instead", + "Option ignored", + "Option ignored;\n%s", + "%s", + "Option has no effect on this target", + "Option should not be specified multiple times", + "Option overrides the effect of '%s'; only one of '%s' should be specified", + "Option overrides the effect of '%s'; only one of '%s' should be specified;\n%s", + "No default handler set up for '%s', ignoring", + "Argument(s) expected", + "Token '%s' not expected", + "Unexpected additional argument '%s'", + "Encountered extraneous arguments", + "No help available for option '%s'", + "Empty (zero-length) argument not accepted", + "Variable name missing", + "Only one output filename allowed; '%s' not accepted", + "Output filenames found without source; '%s' not accepted", + "Multiple outputs expected, output is ambiguous; '%s' not accepted", + "Specified file '%s' not found", + "Specified directory '%s' not found", + "'%s' is a filename, not a directory; not accepted", + "'%s' is a directory, not a filename; not accepted", + "Library search found shared library '%s' instead of export library '%s.LIB'", + "No library file found matching 'lib%s{%s}' or '%s'", + "Redudant use of '%c%s%s'; linker always searches library paths;\ntypically one finds, e.g., libXXX.a with '%c%sXXX'", + "Empty filename in library list ignored", + "Environment variable '%s' not found", + "In environment variable '%s':", + "Option name expected for 'opt'", + "Token '%s' ignored", + "Token '%s[...%s]' was truncated to %d characters", + "Expected %s, but got %s", + "No output expected from this process, ignoring output name '%s'", + "Only one output directory allowed, '%s' not accepted", + "Storing browse info for '%s' in '%s'", + "All linker output will be created in the same directory; ignoring path for '%s'", + "Option overrides previously specified optimizations", + "Could not initialize command line parser", + "Output filename '%s' is invalid", + "Truncated output filename '%s' to %d characters", + "Output directory '%s' cannot be found", + "Cannot add access path '%s'", + "Cannot set preferences for '%s'", + "Some of the files specified could not be found; build aborted", + "Nothing to do: no source or object files specified", + "Contents of %s:", + "Overlays not supported on this target", + "Segments not supported on this target", + "Cannot open %s file '%s'", + "", + "The file \"%s\" may be ignored unless it has one of the following\nextensions: \"%s\"", + "Not using non-text file '%s' as optional argument", + "Cannot redirect stream to '%s' (%s)", + 0 +}; diff --git a/includes/common.h b/includes/common.h index 6a0b12c..760be22 100644 --- a/includes/common.h +++ b/includes/common.h @@ -32,6 +32,18 @@ // ---------- // MacTypes.h +#ifdef __MWERKS__ +typedef unsigned char UInt8; +typedef signed char SInt8; +typedef unsigned short UInt16; +typedef signed short SInt16; +typedef unsigned long UInt32; +typedef signed long SInt32; +typedef unsigned long long UInt64; +typedef signed long long SInt64; + +typedef long Size; +#else typedef uint8_t UInt8; typedef int8_t SInt8; typedef uint16_t UInt16; @@ -41,9 +53,11 @@ typedef int32_t SInt32; typedef uint64_t UInt64; typedef int64_t SInt64; +typedef int32_t Size; +#endif + typedef char *Ptr; typedef Ptr *Handle; -typedef int32_t Size; typedef SInt16 OSErr; typedef SInt32 OSStatus; @@ -73,6 +87,7 @@ enum { nilHandleErr = -109, // pointer was nil memLockedErr = -117, dirNFErr = -120, + userCanceledErr = -128, inputOutOfBounds = -190, resNotFound = -192, // resource not found resFNotFound = -193, // resource file not found diff --git a/includes/mwcc_decomp.h b/includes/mwcc_decomp.h index 52f25c6..c5fa000 100644 --- a/includes/mwcc_decomp.h +++ b/includes/mwcc_decomp.h @@ -2,294 +2,14 @@ #include "common.h" #include "oslib.h" #include "macemul.h" +#include "plugin.h" + +#define OPTION_ASSERT(cond) do { if (!!(cond) == 0) { printf("%s:%u: failed assertion\n", __FILE__, __LINE__); abort(); } } while(0) #ifdef __cplusplus extern "C" { #endif -/********************************/ -/* Option Fuckery */ -#ifdef __MWERKS__ -#pragma options align=packed -#endif -typedef struct PARAM_T { - char which; - char flags; - char *myname; - struct PARAM_T *next; -} PARAM_T; -typedef struct MASK_T { - char which; - char flags; - char *myname; - PARAM_T *next; - char size; - UInt32 ormask; - UInt32 andmask; - void *num; -} MASK_T; -typedef struct STRING_T { - char which; - char flags; - char *myname; - PARAM_T *next; - SInt16 maxlen; - Boolean pstring; - char *str; -} STRING_T; -typedef struct SET_T { - char which; - char flags; - char *myname; - PARAM_T *next; - char size; - UInt32 value; - char *num; -} SET_T; -typedef struct SETSTRING_T { - char which; - char flags; - char *myname; - PARAM_T *next; - char *value; - char pstring; - void *var; -} SETSTRING_T; -typedef struct GENERIC_T { - char which; - char flags; - char *myname; - PARAM_T *next; - int (*parse)(const char *opt, void *var, const char *pstr, int flags); - void *var; - char *help; -} GENERIC_T; -typedef struct SETTING_T { - char which; - char flags; - char *myname; - PARAM_T *next; - int (*parse)(const char *a, const char *b); // TODO name these args - char *valuename; -} SETTING_T; -typedef struct TOGGLE_T { - char which; - char flags; - char *myname; - PARAM_T *next; - char size; - UInt32 mask; - void *num; -} TOGGLE_T; -typedef struct NUM_T { - char which; - char flags; - char *myname; - PARAM_T *next; - char size; - char fit; - UInt32 lo; - UInt32 hi; - void *num; -} NUM_T; -typedef struct FILEPATH_T { - char which; - char flags; - char *myname; - PARAM_T *next; - char fflags; - char *defaultstr; - void *filename; - int maxlen; -} FILEPATH_T; -typedef struct IFARG_T { - char which; - char flags; - char *myname; - PARAM_T *next; - PARAM_T *parg; - char *helpa; - PARAM_T *pnone; - char *helpn; -} IFARG_T; -typedef struct ONOFF_T { - char which; - char flags; - char *myname; - PARAM_T *next; - unsigned char *var; -} ONOFF_T; -typedef struct OFFON_T { - char which; - char flags; - char *myname; - PARAM_T *next; - unsigned char *var; -} OFFON_T; -typedef struct FTYPE_T { - char which; - char flags; - char *myname; - PARAM_T *next; - OSType *fc; - Boolean iscreator; -} FTYPE_T; -typedef struct OptionList { - char *help; - int flags; - struct Option **list; -} OptionList; -typedef struct Option { - char *names; - int avail; - PARAM_T *param; - OptionList *sub; - OptionList *conflicts; - char *help; -} Option; -enum { - HELPFLAGS_1 = 1, - HELPFLAGS_IGNORED = 2, - HELPFLAGS_OBSOLETE = 4, - HELPFLAGS_DEPRECATED = 8, - HELPFLAGS_SECRET = 0x10, - HELPFLAGS_MEANINGLESS = 0x20, - HELPFLAGS_COMPATIBLE = 0x40, - HELPFLAGS_NORMAL = 0x80, // andmask = 0xE? - HELPFLAGS_SPACES = 0x100, - HELPFLAGS_TOOL = 0x200, - HELPFLAGS_TOOL_THIS = 0x400, - HELPFLAGS_TOOL_OTHER = 0x800, - HELPFLAGS_TOOL_BOTH = 0xC00, - HELPFLAGS_1000 = 0x1000, - HELPFLAGS_2000 = 0x2000, - HELPFLAGS_USAGE = 0x4000, - HELPFLAGS_8000 = 0x8000 -}; -enum { - OTF_GLOBAL = 1, - OTF2 = 2, - OTF_CASED = 4, - OTF_OBSOLETE = 8, - OTF_SUBSTITUTED = 0x10, - OTF_DEPRECATED = 0x20, - OTF_TOOL_LINKER = 0x40, - OTF_TOOL_DISASSEMBLER = 0x80, - OTF_TOOL_COMPILER = 0x100, - OTF_TOOL_MASK = OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER | OTF_TOOL_COMPILER, - OTF200 = 0x200, - OTF400 = 0x400, - OTF700 = 0x700, - OTF_IGNORED = 0x800, - OTFC00 = 0xC00, - OTF_SECRET = 0x1000, - OTF2000 = 0x2000, - OTF_COMPATIBILITY = 0x4000, - OTF8000 = 0x8000, - OTF10000 = 0x10000, - OTF20000 = 0x20000, - OTF40000 = 0x40000, - OTF_WARNING = 0x80000, - OTF_SLFLAGS_8 = 0x100000, - OTF_SLFLAGS_10 = 0x200000, - OTF_SLFLAGS_20 = 0x400000, - OTF_SLFLAGS_MASK = OTF_SLFLAGS_8 | OTF_SLFLAGS_10 | OTF_SLFLAGS_20, - OTF_MEANINGLESS = 0x800000, - OTF_ALL_HIDDEN_BY_DEFAULT = OTF_OBSOLETE | OTF_DEPRECATED | OTF_IGNORED | OTF_SECRET | OTF_MEANINGLESS, - OTF1000000 = 0x1000000, - OTF2000000 = 0x2000000, - OTF4000000 = 0x4000000, - OTF8000000 = 0x8000000, - OTF10000000 = 0x10000000, - OTF20000000 = 0x20000000, - OTF40000000 = 0x40000000, - OTF80000000 = 0x80000000 -}; - -enum { - PARAMWHICH_None = 0, - PARAMWHICH_FTypeCreator = 1, - PARAMWHICH_FilePath = 2, - PARAMWHICH_Number = 3, - PARAMWHICH_String = 4, - PARAMWHICH_Id = 5, - PARAMWHICH_Sym = 6, - PARAMWHICH_OnOff = 7, - PARAMWHICH_OffOn = 8, - PARAMWHICH_Mask = 9, - PARAMWHICH_Toggle = 0xA, - PARAMWHICH_Set = 0xB, - PARAMWHICH_SetString = 0xC, - PARAMWHICH_Generic = 0xD, - PARAMWHICH_IfArg = 0xE, - PARAMWHICH_Setting = 0xF, - PARAMWHICH_MAX = 0x10 -}; -enum { - PARAMFLAGS_1 = 1, - PARAMFLAGS_2 = 2, - PARAMFLAGS_3 = 3, - PARAMFLAGS_4 = 4, - PARAMFLAGS_8 = 8, - PARAMFLAGS_10 = 0x10, - PARAMFLAGS_12 = 0x12 -}; -enum { - PARAMPARSEFLAGS_0 = 0, - PARAMPARSEFLAGS_1 = 1, - PARAMPARSEFLAGS_2 = 2, - PARAMPARSEFLAGS_4 = 4, - PARAMPARSEFLAGS_8 = 8, - PARAMPARSEFLAGS_10 = 0x10, - PARAMPARSEFLAGS_20 = 0x20, - PARAMPARSEFLAGS_40 = 0x40, - PARAMPARSEFLAGS_80 = 0x80, - PARAMPARSEFLAGS_100 = 0x100 -}; -enum { - SLFLAGS_1 = 1, - SLFLAGS_2 = 2, - SLFLAGS_4 = 4, // displays =... - SLFLAGS_8 = 8, // displays [no] -- produces e.g. [no]err[or] | [no]iserr[or], [no]implicit[conv] - SLFLAGS_10 = 0x10, // displays [-] - SLFLAGS_20 = 0x20, // displays [no-] - SLFLAGS_40 = 0x40 -}; -enum { - LISTFLAGS_NONE = 0, - LISTFLAGS_2 = 2, - LISTFLAGS_4 = 4, - LISTFLAGS_COMPILER = 0x100, - LISTFLAGS_LINKER = 0x200, - LISTFLAGS_DISASSEMBLER = 0x400, - LISTFLAGS_TOOL_MASK = LISTFLAGS_COMPILER | LISTFLAGS_LINKER | LISTFLAGS_DISASSEMBLER -}; -#ifdef __MWERKS__ -#pragma options align=reset -#endif - -#define CWFOURCHAR(a, b, c, d) \ - (((OSType) ((a) & 0xff) << 24) \ - | ((OSType) ((b) & 0xff) << 16) \ - | ((OSType) ((c) & 0xff) << 8) \ - | ((OSType) ((d) & 0xff))) - -struct IDEAccessPath { - FSSpec pathSpec; - Boolean recursive; - SInt32 subdirectoryCount; - FSSpec *subdirectories; -}; - -struct IDEAccessPathList { - SInt32 userPathCount; - struct IDEAccessPath *userPaths; - SInt32 systemPathCount; - struct IDEAccessPath *systemPaths; - unsigned char alwaysSearchUserPaths; - unsigned char convertPaths; -}; - #ifdef __MWERKS__ #pragma options align=mac68k #endif @@ -314,179 +34,10 @@ typedef struct CWObjectFlags { OSType depFileType; } CWObjectFlags; -typedef struct CWIDEInfo { - UInt16 majorVersion; - UInt16 minorVersion; - UInt16 bugFixVersion; - UInt16 buildVersion; - UInt16 dropinAPIVersion; -} CWIDEInfo; - -typedef struct DropInFlags { - SInt16 rsrcversion; - OSType dropintype; - UInt16 earliestCompatibleAPIVersion; - UInt32 dropinflags; - OSType edit_language; - UInt16 newestAPIVersion; -} DropInFlags; - -typedef struct CWPanelList { - SInt16 version; - SInt16 count; - const char **names; -} CWPanelList; - -typedef struct CWFamily { - OSType type; - const char *name; -} CWFamily; - -typedef struct CWFamilyList { - SInt16 version; - SInt16 count; - CWFamily *families; -} CWFamilyList; - -typedef struct CWTargetList { - SInt16 version; - SInt16 cpuCount; - OSType *cpus; - SInt16 osCount; - OSType *oss; -} CWTargetList; - -typedef struct CWExtensionMapping { - OSType type; - char extension[32]; - UInt32 flags; -} CWExtensionMapping; - -typedef struct CWExtMapList { - SInt16 version; - SInt16 nMappings; - CWExtensionMapping *mappings; -} CWExtMapList; - -typedef struct CWHelpInfo { - SInt16 version; - const char *helpFileName; -} CWHelpInfo; - -#define kCurrentDropInFlagsVersion 2 -#define kCurrentCWPanelListVersion 1 -#define kCurrentCWFamilyListVersion 1 -#define kCurrentCWFamilyResourceVersion 1 -#define kCurrentCWHelpInfoVersion 1 -#define kCurrentCWPluginInfoVersion 1 -#define kCurrentCWTargetListVersion 1 -#define kCurrentCWTargetListResourceVersion 1 - -enum { - CWDROPINCOMPILERTYPE = CWFOURCHAR('C', 'o', 'm', 'p'), - CWDROPINLINKERTYPE = CWFOURCHAR('L', 'i', 'n', 'k') -}; - #ifdef __MWERKS__ #pragma options align=reset #endif -struct CW_BasePluginCallbacks { - void (*cbGetFileInfo)(); - void (*cbFindAndLoadFile)(); - void (*cbGetFileText)(); - void (*cbReleaseFileText)(); - void (*cbGetSegmentInfo)(); - void (*cbGetOverlay1GroupInfo)(); - void (*cbGetOverlay1Info)(); - void (*cbGetOverlay1FileInfo)(); - void (*cbReportMessage)(); - void (*cbAlert)(); - void (*cbShowStatus)(); - void (*cbUserBreak)(); - void (*cbGetNamedPreferences)(); - void (*cbStorePluginData)(); - void (*cbGetPluginData)(); - void (*cbSetModDate)(); - void (*cbAddProjectEntry)(); - void (*cbCreateNewTextDocument)(); - void (*cbAllocateMemory)(); - void (*cbFreeMemory)(); - void (*cbAllocMemHandle)(); - void (*cbFreeMemHandle)(); - void (*cbGetMemHandleSize)(); - void (*cbResizeMemHandle)(); - void (*cbLockMemHandle)(); - void (*cbUnlockMemHandle)(); - void *cbInternal[8]; - void (*cbGetTargetName)(); - void (*cbCacheAccessPathList)(); - void (*cbPreDialog)(); - void (*cbPostDialog)(); - void (*cbPreFileAction)(); - void (*cbPostFileAction)(); - void (*cbCheckoutLicense)(); - void (*cbCheckinLicense)(); - void (*cbResolveRelativePath)(); -}; -struct CWCompilerLinkerCallbacks { - void (*cbCachePrecompiledHeader)(); - void (*cbLoadObjectData)(); - void (*cbStoreObjectData)(); - void (*cbFreeObjectData)(); - void (*cbDisplayLines)(); - void (*cbBeginSubCompile)(); - void (*cbEndSubCompile)(); - void (*cbGetPrecompiledHeaderSpec)(); - void (*cbPutResourceFile)(); - void (*cbGetResourceFile)(); - void (*cbLookUpUnit)(); - void (*cbSBMfiles)(); - void (*cbStoreUnit)(); - void (*cbReleaseUnit)(); - void (*cbUnitNameToFileName)(); - void (*cbOSErrorMessage)(); - void (*cbOSAlert)(); - void (*cbGetModifiedFiles)(); - void (*cbGetSuggestedObjectFileSpec)(); - void (*cbGetStoredObjectFileSpec)(); - void (*cbGetRuntimeSettings)(); - void (*cbGetFrameworkCount)(); - void (*cbGetFrameworkInfo)(); - void (*cbGetFrameworkSharedLibrary)(); -}; -struct CWParserCallbacks { - void (*cbParserAddAccessPath)(); - void (*cbParserSwapAccessPaths)(); - void (*cbParserSetNamedPreferences)(); - void (*cbParserSetFileOutputName)(); - void (*cbParserSetOutputFileDirectory)(); - void (*cbParserAddOverlay1Group)(); - void (*cbParserAddOverlay1)(); - void (*cbParserAddSegment)(); - void (*cbParserSetSegment)(); -}; - -struct CWPluginPrivateContext { - SInt32 request; - SInt32 apiVersion; - void *shellContext; - void *pluginStorage; - FSSpec projectFile; - FSSpec outputFileDirectory; - OSType shellSignature; - OSType pluginType; - SInt32 numFiles; - SInt32 numOverlayGroups; - OSErr callbackOSError; - OSErr pluginOSError; - CWIDEInfo *shellInfo; - struct IDEAccessPathList *accessPathList; - SInt32 dontEatEvents; - FSSpec *targetDataDirectorySpec; - SInt32 reserved[17]; - struct CW_BasePluginCallbacks *callbacks; -}; // Pref panels #ifdef __MWERKS__ @@ -498,6 +49,17 @@ enum { 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; @@ -667,12 +229,6 @@ typedef struct { Str255 symfilename; } PCLTExtras; -typedef struct CWCommandLineArgs { - int argc; - char **argv; - char **envp; -} CWCommandLineArgs; - typedef struct VersionInfo { UInt16 major; UInt16 minor; @@ -680,7 +236,7 @@ typedef struct VersionInfo { UInt16 build; } VersionInfo; -typedef struct CLPluginInfo { +/*typedef struct CLPluginInfo { OSType plugintype; OSType language; SInt32 dropinflags; @@ -694,7 +250,7 @@ typedef struct ToolVersionInfo { char *tool; char *copyright; char *version; -} ToolVersionInfo; +} ToolVersionInfo;*/ #ifdef __MWERKS__ #pragma options align=reset #endif @@ -707,11 +263,11 @@ struct ParseOptsType { UInt16 ioCols; UInt16 ioRows; CWCommandLineArgs *args; - ToolVersionInfo *toolVersion; + const ToolVersionInfo *toolVersion; int numPlugins; - CLPluginInfo *plugins; + const CLPluginInfo *plugins; int numPanels; - char **panelNames; + const char **panelNames; OSType cpu; OSType os; char lastoutputname[256]; @@ -763,7 +319,7 @@ typedef struct { } CLState; // assumed name typedef struct BasePluginCallbacks { - SInt16 (*main)(void *context); + SInt16 (*main)(CWPluginContext context); SInt16 (*GetDropInFlags)(const DropInFlags **flags, SInt32 *flagsSize); SInt16 (*GetDisplayName)(const char **displayName); SInt16 (*GetDropInName)(const char **dropInName); @@ -804,12 +360,12 @@ typedef struct { char *toolInfo; char *copyright; int numOptionLists; - OptionList **optionLists; + struct OptionList **optionLists; int numPrefDataPanels; PrefDataPanel *prefDataPanels; - int (*PreParse)(); // sig? - int (*MidParse)(); // sig? - int (*PostParse)(); // sig? + int (*PreParse)(); + int (*MidParse)(); + int (*PostParse)(); } ParserTool; // assumed name // I think this is internally defined in its .c file @@ -985,7 +541,7 @@ typedef struct CLTargetInfo { OSSpec runfile; OSSpec linkAgainstFile; } CLTargetInfo; -typedef struct CWTargetInfo { +/*typedef struct CWTargetInfo { SInt16 outputType; FSSpec outfile; FSSpec symfile; @@ -1000,7 +556,7 @@ typedef struct CWTargetInfo { OSType debuggerCreator; OSType runHelperCreator; FSSpec linkAgainstFile; -} CWTargetInfo; +} CWTargetInfo;*/ typedef struct Target { struct BuildInfo { UInt32 linesCompiled; @@ -1186,8 +742,10 @@ 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 */ @@ -1300,8 +858,8 @@ extern void Paths_CopyRecurseFSS(FSSpec *fss, Paths *paths, UInt16 count); //static Boolean CheckForFileInFrameworkDir(char *out, const char *framework_path, OSPathSpec *osps, const char *fname); //static Boolean CheckForFileInFramework(char *out, int i, const char *fname); extern Boolean MakeFrameworkPath(char *out, const char *filename, OSPathSpec **globalpath); -extern Boolean Frameworks_AddPath(const OSPathSpec *oss); -extern Boolean Frameworks_AddFramework(const char *frameworkName, const char *version, Boolean flag); +extern void 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); @@ -1315,6 +873,7 @@ 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); @@ -1329,9 +888,11 @@ 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); @@ -1350,6 +911,7 @@ 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 */ @@ -1488,12 +1050,12 @@ extern int DisplayWarningOptions(); /********************************/ /* StaticParserGlue.c */ -extern int RegisterStaticParserResources(); extern int RegisterStaticParserPlugins(); +extern int RegisterStaticParserResources(); /********************************/ /* ParserFace.c */ -extern Handle Parser_FindPrefPanel(char *name); +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); @@ -1502,20 +1064,23 @@ extern SInt16 CWParser_GetPanelList(const CWPanelList **panelList); extern SInt16 CWParser_GetTargetList(const CWTargetList **targetList); extern SInt16 CWParser_GetVersionInfo(const VersionInfo **versioninfo); extern SInt16 Parser_SupportsPlugin(struct CLPluginInfo *pluginfo, OSType cpu, OSType os, Boolean *isSupported); -extern SInt16 Parser_SupportsPanels(int numPanels, char **panelNames, Boolean *isSupported); +extern SInt16 Parser_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, char **match); -//static Boolean MatchesExtension(const char *list, const char *filename); +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 *envvar, SInt16 id); // TODO funcptr sig - same as CLPReportWarning_V, CLPReportError_V +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); @@ -1524,8 +1089,8 @@ extern int AddFileList(const char *list, char sep1, char sep2, int source, char 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 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); @@ -1534,21 +1099,42 @@ 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, ...); +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, void *unk); -// lots of the Opt_ funcs have weird sigs, need to double check them +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; @@ -1564,43 +1150,6 @@ extern int Opt_PragmaOnOff(const char *, void *flag, const char *arg); extern int Opt_PragmaOffOn(const char *, void *flag, const char *arg); extern int SetupPragmas(const Pragma *pragmas); -/********************************/ -/* Arguments.c */ -typedef struct { - SInt16 val; - char *text; -} ArgToken; -enum { - ATK_0, - ATK_1, - ATK_2, - ATK_3, - ATK_4, - ATK_5 -}; -typedef struct { - int argc; - int nargv; - char **argv; -} anon0_50; - -extern void Arg_Init(int theargc, char **theargv); -extern void Arg_Terminate(); -extern void Arg_Reset(); -extern void Arg_Stop(ArgToken *where); -extern ArgToken *Arg_PeekToken(); -extern ArgToken *Arg_UsedToken(); -extern int Arg_IsEmpty(); -extern ArgToken *Arg_GetToken(); -extern ArgToken *Arg_UndoToken(); -extern const char *Arg_GetTokenName(ArgToken *tok); -extern const char *Arg_GetTokenText(ArgToken *tok, char *buffer, int maxlen, unsigned char warn); -extern void Arg_InitToolArgs(anon0_50 *ta); -extern void Arg_AddToToolArgs(anon0_50 *ta, SInt16 tokval, char *toktxt); -extern void Arg_FinishToolArgs(anon0_50 *ta); -extern void Arg_ToolArgsForPlugin(anon0_50 *ta, struct CWCommandLineArgs *args); -extern void Arg_FreeToolArgs(anon0_50 *ta); - /********************************/ /* ToolHelpers-cc.c */ extern int Opt_DummyLinkerRoutine(const char *opt); @@ -1618,12 +1167,12 @@ extern int GetFileCount(); extern void SetFileOutputName(SInt32 position, SInt16 which, char *outfilename); extern int AddFileToProject(OSSpec *oss, SInt16 which, char *outfilename, Boolean exists, SInt32 position); extern Boolean GetFileInfo(SInt32 position, OSSpec *spec, char *plugin); -extern int AddAccessPath(const OSPathSpec *oss, SInt16 type, SInt32 position, Boolean recursive); +extern int 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(const OSPathSpec *dir); -extern void AddOverlayGroup(const char *name, OvlAddr *addr, SInt32 *groupnum, SInt32 *overlaynum); +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); @@ -1631,72 +1180,13 @@ 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(); -/********************************/ -/* Option.c */ -typedef struct { - void *first; - void *second; -} Opt50; -typedef struct { - Option *opt; - char *curopt; -} Opt52; -typedef struct { - union { - Opt50 v; - OptionList *lst; - Opt52 o; - char *param; - } e; - SInt16 flags; -} Opt48; -//static void Option_PushList(OptionList *lst); -//static void Option_PushOpt(Option *opt, const char *optname); -//static void Option_PopOpt(const char *optname); -//static void Option_PopList(); -extern void Args_InitStack(); -extern int Args_StackSize(); -extern void Args_Push(SInt16 flags, void *first, void *second); -extern Opt48 *Args_Pop(SInt16 flags); -extern void Args_SpellStack(char *buffer, SInt16 flags); -extern void Args_AddToToolArgs(anon0_50 *ta); -extern void Options_Init(); -extern OptionList *Options_GetOptions(); -extern void Options_SortOptions(); -//static void Options_AddOption(Option *opt); -extern int Options_AddList(OptionList *optlst); -extern int Options_AddLists(OptionList **optlst); -//static void Options_Reset(OptionList *optlst); -//static void Option_SpellList(char *buffer, OptionList *conflicts, int flags); -extern int Option_ForTool(Option *opt, int which); -extern int Option_ThisTool(); -extern int Option_ForThisTool(Option *opt); -extern int Option_AlsoPassedToTool(Option *opt, int which); -extern int Option_AlsoPassedFromThisTool(Option *opt); -//static Boolean Option_ContinuesThisLevel(int level, ArgToken *tok); -//static Boolean Option_IsEndingThisLevel(int level, ArgToken *tok); -//static Boolean Option_IsEndingLevel(int level, ArgToken *tok); -extern int Option_Parse(Option *opt, int oflags); -//static int Option_MatchString(char *list, char *str, int flags, int *result); -//static Option *Option_Lookup(OptionList *search, void *unk, int *flags); -//static int Options_DoParse(OptionList *search, int flags); -extern int Options_Parse(OptionList *options, int flags); -extern int Option_ParseDefaultOption(OptionList *options); -extern void Option_ParamError(SInt16 id, va_list ap); -extern void Option_ParamWarning(SInt16 id, va_list ap); -extern void Option_OptionError(SInt16 id, va_list ap); -extern void Option_OptionWarning(SInt16 id, va_list ap); -extern void Option_Error(SInt16 id, ...); -extern void Option_Warning(SInt16 id, ...); -extern int Options_Help(const char *keyword); -extern int Option_Help(const char *opt); -extern int Options_DisplayHelp(); - /********************************/ /* ParserErrors.c */ extern void CLPReportError_V(const char *format, va_list ap); @@ -1705,7 +1195,7 @@ extern void CLPReport_V(const char *format, va_list ap); extern void CLPStatus_V(const char *format, va_list ap); extern void CLPAlert_V(const char *format, va_list ap); extern void CLPOSAlert_V(const char *format, SInt32 err, va_list ap); -extern void CLPGetErrorString(SInt16 errid, char *buffer); +extern char *CLPGetErrorString(SInt16 errid, char *buffer); extern void CLPReportError(SInt16 errid, ...); extern void CLPReportWarning(SInt16 errid, ...); extern void CLPReport(SInt16 errid, ...); @@ -1721,32 +1211,22 @@ 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); -/********************************/ -/* Parameter.c */ -extern void Param_DescHelp(PARAM_T *param, const char **desc, const char **help, const char **defaul); -extern int Param_Compare(PARAM_T *param); -extern int Params_Parse(PARAM_T *param, int flags); -extern void Param_Error(SInt16 id, ...); -extern void Param_Warning(SInt16 id, ...); - -/********************************/ -/* Help.c */ -extern int Help_Option(struct OptionList *lst, struct Option *opt, int subprint, const char *keyword); -extern void Help_Options(struct OptionList *lst, int subprint, const char *keyword); -extern void Help_Usage(); -extern void Help_Null(); -extern void Help_Init(); -extern void Help_Line(char ch); -extern void Help_Term(); - /********************************/ /* */ @@ -1798,10 +1278,11 @@ extern void COS_FileGetFSSpecInfo(const FSSpec *spec, SInt16 *vRefNum, SInt32 *d 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 ParserTool *pTool; extern PCmdLine optsCmdLine; extern PCmdLineEnvir optsEnvir; extern PCmdLineCompiler optsCompiler; @@ -1826,6 +1307,10 @@ 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 new file mode 100644 index 0000000..521213b --- /dev/null +++ b/includes/option_system.h @@ -0,0 +1,413 @@ +#pragma once +#include "common.h" + +#ifdef __cplusplus +extern "C" { +#endif +#ifdef __MWERKS__ +#pragma options align=packed +#endif +enum { + OptParseError = 0, + OptParseSuccess = 1 +}; + +typedef struct PARAM_T { + char which; + char flags; + char *myname; + struct PARAM_T *next; +} PARAM_T; +typedef struct MASK_T { + char which; + char flags; + char *myname; + PARAM_T *next; + char size; + UInt32 ormask; + UInt32 andmask; + void *num; +} MASK_T; +typedef struct STRING_T { + char which; + char flags; + char *myname; + PARAM_T *next; + SInt16 maxlen; + Boolean pstring; + char *str; +} STRING_T; +typedef struct SET_T { + char which; + char flags; + char *myname; + PARAM_T *next; + char size; + UInt32 value; + char *num; +} SET_T; +typedef struct SETSTRING_T { + char which; + char flags; + char *myname; + PARAM_T *next; + char *value; + char pstring; + void *var; +} SETSTRING_T; +typedef struct GENERIC_T { + char which; + char flags; + char *myname; + PARAM_T *next; + + int (*parse)(const char *opt, void *var, const char *pstr, int flags); + + void *var; + char *help; +} GENERIC_T; +typedef struct SETTING_T { + char which; + char flags; + char *myname; + PARAM_T *next; + + int (*parse)(const char *a, const char *b); // TODO name these args + char *valuename; +} SETTING_T; +typedef struct TOGGLE_T { + char which; + char flags; + char *myname; + PARAM_T *next; + char size; + UInt32 mask; + void *num; +} TOGGLE_T; +typedef struct NUM_T { + char which; + char flags; + char *myname; + PARAM_T *next; + char size; + char fit; + UInt32 lo; + UInt32 hi; + void *num; +} NUM_T; +typedef struct FILEPATH_T { + char which; + char flags; + char *myname; + PARAM_T *next; + char fflags; + char *defaultstr; + void *filename; + int maxlen; +} FILEPATH_T; +typedef struct IFARG_T { + char which; + char flags; + char *myname; + PARAM_T *next; + PARAM_T *parg; + char *helpa; + PARAM_T *pnone; + char *helpn; +} IFARG_T; +typedef struct ONOFF_T { + char which; + char flags; + char *myname; + PARAM_T *next; + unsigned char *var; +} ONOFF_T; +typedef struct OFFON_T { + char which; + char flags; + char *myname; + PARAM_T *next; + unsigned char *var; +} OFFON_T; +typedef struct FTYPE_T { + char which; + char flags; + char *myname; + PARAM_T *next; + OSType *fc; + Boolean iscreator; +} FTYPE_T; +typedef struct OptionList { + char *help; + int flags; + struct Option **list; +} OptionList; +typedef struct Option { + char *names; + int avail; + PARAM_T *param; + OptionList *sub; + OptionList *conflicts; + char *help; +} Option; +enum { + HELPFLAGS_1 = 1, + HELPFLAGS_IGNORED = 2, + HELPFLAGS_OBSOLETE = 4, + HELPFLAGS_DEPRECATED = 8, + HELPFLAGS_SECRET = 0x10, + HELPFLAGS_MEANINGLESS = 0x20, + HELPFLAGS_COMPATIBLE = 0x40, + HELPFLAGS_NORMAL = 0x80, // andmask = 0xE? + HELPFLAGS_SPACES = 0x100, + HELPFLAGS_TOOL = 0x200, + HELPFLAGS_TOOL_THIS = 0x400, + HELPFLAGS_TOOL_OTHER = 0x800, + HELPFLAGS_TOOL_BOTH = 0xC00, + HELPFLAGS_1000 = 0x1000, + HELPFLAGS_2000 = 0x2000, + HELPFLAGS_USAGE = 0x4000, + HELPFLAGS_8000 = 0x8000 +}; +enum { + OTF_GLOBAL = 1, + OTF2 = 2, + OTF_CASED = 4, + OTF_OBSOLETE = 8, + OTF_SUBSTITUTED = 0x10, + OTF_DEPRECATED = 0x20, + OTF_TOOL_LINKER = 0x40, + OTF_TOOL_DISASSEMBLER = 0x80, + OTF_TOOL_COMPILER = 0x100, + OTF_TOOL_MASK = OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER | OTF_TOOL_COMPILER, + OTF200 = 0x200, + OTF400 = 0x400, + OTF700 = 0x700, + OTF_IGNORED = 0x800, + OTFC00 = 0xC00, + OTF_SECRET = 0x1000, + OTF2000 = 0x2000, + OTF_COMPATIBILITY = 0x4000, + OTF8000 = 0x8000, + OTF10000 = 0x10000, + OTF20000 = 0x20000, + OTF40000 = 0x40000, + OTF_WARNING = 0x80000, + OTF_SLFLAGS_8 = 0x100000, + OTF_SLFLAGS_10 = 0x200000, + OTF_SLFLAGS_20 = 0x400000, + OTF_SLFLAGS_MASK = OTF_SLFLAGS_8 | OTF_SLFLAGS_10 | OTF_SLFLAGS_20, + OTF_MEANINGLESS = 0x800000, + OTF_ALL_HIDDEN_BY_DEFAULT = OTF_OBSOLETE | OTF_DEPRECATED | OTF_IGNORED | OTF_SECRET | OTF_MEANINGLESS, + OTF1000000 = 0x1000000, + OTF2000000 = 0x2000000, + OTF4000000 = 0x4000000, + OTF8000000 = 0x8000000, + OTF10000000 = 0x10000000, + OTF20000000 = 0x20000000, + OTF40000000 = 0x40000000, + OTF80000000 = 0x80000000 +}; + +enum { + PARAMWHICH_None = 0, + PARAMWHICH_FTypeCreator = 1, + PARAMWHICH_FilePath = 2, + PARAMWHICH_Number = 3, + PARAMWHICH_String = 4, + PARAMWHICH_Id = 5, + PARAMWHICH_Sym = 6, + PARAMWHICH_OnOff = 7, + PARAMWHICH_OffOn = 8, + PARAMWHICH_Mask = 9, + PARAMWHICH_Toggle = 0xA, + PARAMWHICH_Set = 0xB, + PARAMWHICH_SetString = 0xC, + PARAMWHICH_Generic = 0xD, + PARAMWHICH_IfArg = 0xE, + PARAMWHICH_Setting = 0xF, + PARAMWHICH_MAX = 0x10 +}; +enum { + PARAMFLAGS_1 = 1, + PARAMFLAGS_2 = 2, + PARAMFLAGS_3 = 3, + PARAMFLAGS_4 = 4, + PARAMFLAGS_8 = 8, + PARAMFLAGS_10 = 0x10, + PARAMFLAGS_12 = 0x12 +}; +enum { + PARAMPARSEFLAGS_0 = 0, + PARAMPARSEFLAGS_1 = 1, + PARAMPARSEFLAGS_2 = 2, + PARAMPARSEFLAGS_4 = 4, + PARAMPARSEFLAGS_8 = 8, + PARAMPARSEFLAGS_10 = 0x10, + PARAMPARSEFLAGS_20 = 0x20, + PARAMPARSEFLAGS_40 = 0x40, + PARAMPARSEFLAGS_80 = 0x80, + PARAMPARSEFLAGS_100 = 0x100 +}; +enum { + SLFLAGS_1 = 1, + SLFLAGS_2 = 2, + SLFLAGS_4 = 4, // displays =... + SLFLAGS_8 = 8, // displays [no] -- produces e.g. [no]err[or] | [no]iserr[or], [no]implicit[conv] + SLFLAGS_10 = 0x10, // displays [-] + SLFLAGS_20 = 0x20, // displays [no-] + SLFLAGS_40 = 0x40 +}; +enum { + LISTFLAGS_NONE = 0, + LISTFLAGS_2 = 2, + LISTFLAGS_4 = 4, + LISTFLAGS_COMPILER = 0x100, + LISTFLAGS_LINKER = 0x200, + LISTFLAGS_DISASSEMBLER = 0x400, + LISTFLAGS_TOOL_MASK = LISTFLAGS_COMPILER | LISTFLAGS_LINKER | LISTFLAGS_DISASSEMBLER +}; + +enum { + OFLAGS_1 = 1, + OFLAGS_2 = 2, + OFLAGS_4 = 4, + OFLAGS_8 = 8, + OFLAGS_10 = 0x10, + OFLAGS_20 = 0x20, + OFLAGS_40 = 0x40, + OFLAGS_80 = 0x80 +}; +enum { + PFLAGS_1 = 1, + PFLAGS_2 = 2, + PFLAGS_4 = 4, + PFLAGS_8 = 8, + PFLAGS_10 = 0x10, + PFLAGS_20 = 0x20, + PFLAGS_40 = 0x40, + PFLAGS_80 = 0x80 +}; +#ifdef __MWERKS__ +#pragma options align=reset +#endif + +/********************************/ +/* Arguments.c */ +typedef struct { + SInt16 val; + char *text; +} ArgToken; +enum { + ATK_0, + ATK_1, + ATK_2, + ATK_3, + ATK_4, + ATK_5 +}; +typedef struct { + int argc; + int nargv; + char **argv; +} anon0_50; + +extern void Arg_Init(int theargc, char **theargv); +extern void Arg_Terminate(); +extern void Arg_Reset(); +extern void Arg_Stop(ArgToken *where); +extern ArgToken *Arg_PeekToken(); +extern ArgToken *Arg_UsedToken(); +extern int Arg_IsEmpty(); +extern ArgToken *Arg_GetToken(); +extern ArgToken *Arg_UndoToken(); +extern const char *Arg_GetTokenName(ArgToken *tok); +extern const char *Arg_GetTokenText(ArgToken *tok, char *buffer, int maxlen, unsigned char warn); +extern void Arg_InitToolArgs(anon0_50 *ta); +extern void Arg_AddToToolArgs(anon0_50 *ta, SInt16 tokval, char *toktxt); +extern void Arg_FinishToolArgs(anon0_50 *ta); +extern void Arg_ToolArgsForPlugin(anon0_50 *ta, struct CWCommandLineArgs *args); +extern void Arg_FreeToolArgs(anon0_50 *ta); + +/********************************/ +/* Option.c */ +typedef struct { + void *first; + void *second; +} Opt50; +typedef struct { + Option *opt; + char *curopt; +} Opt52; +typedef struct { + union { + Opt50 v; + OptionList *lst; + Opt52 o; + char *param; + } e; + SInt16 flags; +} Opt48; +//static void Option_PushList(OptionList *lst); +//static void Option_PushOpt(Option *opt, const char *optname); +//static void Option_PopOpt(const char *optname); +//static void Option_PopList(); +extern void Args_InitStack(); +extern int Args_StackSize(); +extern void Args_Push(SInt16 flags, void *first, void *second); +extern Opt48 *Args_Pop(SInt16 flags); +extern void Args_SpellStack(char *buffer, SInt16 flags); +extern void Args_AddToToolArgs(anon0_50 *ta); +extern void Options_Init(); +extern OptionList *Options_GetOptions(); +extern void Options_SortOptions(); +//static void Options_AddOption(Option *opt); +extern int Options_AddList(OptionList *optlst); +extern int Options_AddLists(OptionList **optlst); +//static void Options_Reset(OptionList *optlst); +//static void Option_SpellList(char *buffer, OptionList *conflicts, int flags); +extern int Option_ForTool(Option *opt, int which); +extern int Option_ThisTool(); +extern int Option_ForThisTool(Option *opt); +extern int Option_AlsoPassedToTool(Option *opt, int which); +extern int Option_AlsoPassedFromThisTool(Option *opt); +//static Boolean Option_ContinuesThisLevel(int level, ArgToken *tok); +//static Boolean Option_IsEndingThisLevel(int level, ArgToken *tok); +//static Boolean Option_IsEndingLevel(int level, ArgToken *tok); +extern int Option_Parse(Option *opt, int oflags); +//static int Option_MatchString(char *list, char *str, int flags, int *result); +//static Option *Option_Lookup(OptionList *search, void *unk, int *flags); +//static int Options_DoParse(OptionList *search, int flags); +extern int Options_Parse(OptionList *options, int flags); +extern int Option_ParseDefaultOption(OptionList *options); +extern void Option_ParamError(SInt16 id, va_list ap); +extern void Option_ParamWarning(SInt16 id, va_list ap); +extern void Option_OptionError(SInt16 id, va_list ap); +extern void Option_OptionWarning(SInt16 id, va_list ap); +extern void Option_Error(SInt16 id, ...); +extern void Option_Warning(SInt16 id, ...); +extern int Options_Help(const char *keyword); +extern int Option_Help(const char *opt); +extern int Options_DisplayHelp(); + +/********************************/ +/* Parameter.c */ +extern void Param_DescHelp(PARAM_T *param, const char **desc, const char **help, const char **defaul); +extern int Param_Compare(PARAM_T *param); +extern int Params_Parse(PARAM_T *param, int flags); +extern void Param_Error(SInt16 id, ...); +extern void Param_Warning(SInt16 id, ...); + +/********************************/ +/* Help.c */ +extern int Help_Option(struct OptionList *lst, struct Option *opt, int subprint, const char *keyword); +extern void Help_Options(struct OptionList *lst, int subprint, const char *keyword); +extern void Help_Usage(); +extern void Help_Null(); +extern void Help_Init(); +extern void Help_Line(char ch); +extern void Help_Term(); + +#ifdef __cplusplus +} +#endif diff --git a/includes/plugin.h b/includes/plugin.h new file mode 100644 index 0000000..76b17cc --- /dev/null +++ b/includes/plugin.h @@ -0,0 +1,201 @@ +#pragma once +#include "CWPlugins.h" +#include "CWPluginErrors.h" +#include "DropInCompilerLinker.h" + +#ifdef __MWERKS__ +#pragma options align=mac68k +#endif + +#if CWPLUGIN_API == CWPLUGIN_API_MACOS +#define CWFileSpecNotEmpty(specPtr) ((specPtr)->name[0] != 0) +#elif CWPLUGIN_API == CWPLUGIN_API_WIN32 +#define CWFileSpecNotEmpty(specPtr) ((specPtr)->path[0] != 0) +#elif CWPLUGIN_API == CWPLUGIN_API_UNIX +#define CWFileSpecNotEmpty(specPtr) ((specPtr)->path[0] != 0) +#endif + +enum { + CWDROPINPARSERTYPE = CWFOURCHAR('P','a','r','s') +}; + +typedef struct IDEAccessPath { + FSSpec pathSpec; + Boolean recursive; + SInt32 subdirectoryCount; + FSSpec *subdirectories; +} IDEAccessPath; + +typedef struct IDEAccessPathList { + SInt32 userPathCount; + IDEAccessPath *userPaths; + SInt32 systemPathCount; + IDEAccessPath *systemPaths; + Boolean alwaysSearchUserPaths; + Boolean convertPaths; +} IDEAccessPathList; + +enum { + cwAccessPathTypeFlag2 = 2 +}; +typedef struct CWNewAccessPathInfo { + CWFileSpec pathSpec; + SInt32 position; + Boolean recursive; + CWAccessPathType type; +} CWNewAccessPathInfo; + +typedef struct CWTargetInfoV7 { + CWFileSpec outfile; + CWFileSpec symfile; + short linkType; + Boolean canRun; + Boolean canDebug; + Boolean useRunHelperApp; + char reserved1; + CWDataType debuggerCreator; + CWDataType runHelperCreator; + SInt32 reserved2[2]; +} CWTargetInfoV7; + +typedef struct CWEnvVarInfo { + char *name; + char *value; +} CWEnvVarInfo; + +typedef struct CWCommandLineArgs { + int argc; + char **argv; + char **envp; +} CWCommandLineArgs; + +typedef struct ToolVersionInfo { + char *company; + char *product; + char *tool; + char *copyright; + char *version; +} ToolVersionInfo; + +typedef struct CLPluginInfo { + OSType plugintype; + OSType language; + SInt32 dropinflags; + char *version; + Boolean storeCommandLine; +} CLPluginInfo; + +struct CW_BasePluginCallbacks { + CWResult (*cbGetFileInfo)(CWPluginContext, SInt32, Boolean, CWProjectFileInfo *); + CWResult (*cbFindAndLoadFile)(CWPluginContext, const char *, CWFileInfo *); + CWResult (*cbGetFileText)(CWPluginContext, const CWFileSpec *, const char **, SInt32 *, short *); + CWResult (*cbReleaseFileText)(CWPluginContext, const char *); + CWResult (*cbGetSegmentInfo)(CWPluginContext, SInt32, CWProjectSegmentInfo *); + CWResult (*cbGetOverlay1GroupInfo)(CWPluginContext, SInt32, CWOverlay1GroupInfo *); + CWResult (*cbGetOverlay1Info)(CWPluginContext, SInt32, SInt32, CWOverlay1Info *); + CWResult (*cbGetOverlay1FileInfo)(CWPluginContext, SInt32, SInt32, SInt32, CWOverlay1FileInfo *); + CWResult (*cbReportMessage)(CWPluginContext, const CWMessageRef *, const char *, const char *, short, SInt32); + CWResult (*cbAlert)(CWPluginContext, const char *, const char *, const char *, const char *); + CWResult (*cbShowStatus)(CWPluginContext, const char *, const char *); + CWResult (*cbUserBreak)(CWPluginContext); + CWResult (*cbGetNamedPreferences)(CWPluginContext, const char *, CWMemHandle *); + CWResult (*cbStorePluginData)(CWPluginContext, SInt32, CWDataType, CWMemHandle); + CWResult (*cbGetPluginData)(CWPluginContext, SInt32, CWDataType, CWMemHandle *); + CWResult (*cbSetModDate)(CWPluginContext, const CWFileSpec *, CWFileTime *, Boolean); + CWResult (*cbAddProjectEntry)(CWPluginContext, const CWFileSpec *, Boolean, const CWNewProjectEntryInfo *, SInt32 *); + CWResult (*cbCreateNewTextDocument)(CWPluginContext, const CWNewTextDocumentInfo *); + CWResult (*cbAllocateMemory)(CWPluginContext, SInt32, Boolean, void **); + CWResult (*cbFreeMemory)(CWPluginContext, void *, Boolean); + CWResult (*cbAllocMemHandle)(CWPluginContext, SInt32, Boolean, CWMemHandle *); + CWResult (*cbFreeMemHandle)(CWPluginContext, CWMemHandle); + CWResult (*cbGetMemHandleSize)(CWPluginContext, CWMemHandle, SInt32 *); + CWResult (*cbResizeMemHandle)(CWPluginContext, CWMemHandle, SInt32); + CWResult (*cbLockMemHandle)(CWPluginContext, CWMemHandle, Boolean, void **); + CWResult (*cbUnlockMemHandle)(CWPluginContext, CWMemHandle); + void *cbInternal[8]; + CWResult (*cbGetTargetName)(CWPluginContext, char *, short); + CWResult (*cbCacheAccessPathList)(CWPluginContext); + CWResult (*cbPreDialog)(CWPluginContext); + CWResult (*cbPostDialog)(CWPluginContext); + CWResult (*cbPreFileAction)(CWPluginContext, const CWFileSpec *); + CWResult (*cbPostFileAction)(CWPluginContext, const CWFileSpec *); + CWResult (*cbCheckoutLicense)(CWPluginContext, const char *, const char *, SInt32, void *, SInt32 *); + CWResult (*cbCheckinLicense)(CWPluginContext, SInt32); + CWResult (*cbResolveRelativePath)(CWPluginContext, const CWRelativePath *, CWFileSpec *, Boolean); +}; + +struct CWCompilerLinkerCallbacks { + CWResult (*cbCachePrecompiledHeader)(CWPluginContext, const CWFileSpec *, CWMemHandle); + CWResult (*cbLoadObjectData)(CWPluginContext, SInt32, CWMemHandle *); + CWResult (*cbStoreObjectData)(CWPluginContext, SInt32, CWObjectData *); + CWResult (*cbFreeObjectData)(CWPluginContext, SInt32, CWMemHandle); + CWResult (*cbDisplayLines)(CWPluginContext, SInt32); + CWResult (*cbBeginSubCompile)(CWPluginContext, SInt32, CWPluginContext *); + CWResult (*cbEndSubCompile)(CWPluginContext); + CWResult (*cbGetPrecompiledHeaderSpec)(CWPluginContext, CWFileSpec *, const char *); + CWResult (*cbGetResourceFile)(CWPluginContext, CWFileSpec *); + CWResult (*cbPutResourceFile)(CWPluginContext, const char *, const char *, CWFileSpec *); + CWResult (*cbLookUpUnit)(CWPluginContext, const char *, Boolean, const void **, SInt32 *); + CWResult (*cbSBMfiles)(CWPluginContext, short); + CWResult (*cbStoreUnit)(CWPluginContext, const char *, CWMemHandle, CWDependencyTag); + CWResult (*cbReleaseUnit)(CWPluginContext, void *); + CWResult (*cbUnitNameToFileName)(CWPluginContext, const char *, char *); + CWResult (*cbOSErrorMessage)(CWPluginContext, const char *, OSErr); + CWResult (*cbOSAlert)(CWPluginContext, const char *, OSErr); + CWResult (*cbGetModifiedFiles)(CWPluginContext, SInt32 *, const SInt32 **); + CWResult (*cbGetSuggestedObjectFileSpec)(CWPluginContext, SInt32, CWFileSpec *); + CWResult (*cbGetStoredObjectFileSpec)(CWPluginContext, SInt32, CWFileSpec *); + CWResult (*cbGetRuntimeSettings)(CWPluginContext); + CWResult (*cbGetFrameworkCount)(CWPluginContext, SInt32 *); + CWResult (*cbGetFrameworkInfo)(CWPluginContext, SInt32, CWFrameworkInfo *); + CWResult (*cbGetFrameworkSharedLibrary)(CWPluginContext); +}; + +struct CWParserCallbacks { + CWResult (*cbParserAddAccessPath)(CWPluginContext, const CWNewAccessPathInfo *); + CWResult (*cbParserSwapAccessPaths)(CWPluginContext); + CWResult (*cbParserSetNamedPreferences)(CWPluginContext, const char *, CWMemHandle); + CWResult (*cbParserSetFileOutputName)(CWPluginContext, SInt32, short, const char *); + CWResult (*cbParserSetOutputFileDirectory)(CWPluginContext, const CWFileSpec *); + CWResult (*cbParserAddOverlay1Group)(CWPluginContext, const char *, const CWAddr64 *, SInt32 *); + CWResult (*cbParserAddOverlay1)(CWPluginContext, const char *, SInt32, SInt32 *); + CWResult (*cbParserAddSegment)(CWPluginContext, const char *, short, SInt32 *); + CWResult (*cbParserSetSegment)(CWPluginContext, SInt32, const char *, short); +}; + +#ifdef __MWERKS__ +#pragma options align=reset +#endif + +#ifdef __cplusplus +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 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); +CW_CALLBACK CWSecretGetNamedPreferences(CWPluginContext context, const char *prefsname, Handle *prefsdata); + +CW_CALLBACK CWParserGetBuildDate(CWPluginContext context, const char **buildDate, const char **buildTime); +CW_CALLBACK CWParserGetCommandLine(CWPluginContext context, CWCommandLineArgs **args); +CW_CALLBACK CWParserGetTargetInfo(CWPluginContext context, CWDataType *cpu, CWDataType *os); +CW_CALLBACK CWParserGetToolInfo(CWPluginContext context, const ToolVersionInfo **toolVersionInfo); +CW_CALLBACK CWParserGetPlugins(CWPluginContext context, int *numPlugins, const CLPluginInfo **pluginInfo); +CW_CALLBACK CWParserGetPanels(CWPluginContext context, int *numPanels, const char ***panelNames); +CW_CALLBACK CWParserStoreCommandLineForPanel(CWPluginContext context, int index, const CWCommandLineArgs *args); +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 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); +CW_CALLBACK CWParserAddOverlay1(CWPluginContext context, const char *name, SInt32 groupNumber, SInt32 *newOverlayNumber); +CW_CALLBACK CWParserAddSegment(CWPluginContext context, const char *name, short attrs, SInt32 *newSegmentNumber); +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); +#ifdef __cplusplus +} +#endif diff --git a/includes/plugin_internal.h b/includes/plugin_internal.h new file mode 100644 index 0000000..be84406 --- /dev/null +++ b/includes/plugin_internal.h @@ -0,0 +1,84 @@ +#pragma once +#include "plugin.h" + +#ifdef __MWERKS__ +#pragma options align=mac68k +#endif +struct CWPluginPrivateContext { + CWPluginPrivateContext(); + ~CWPluginPrivateContext(); + + SInt32 request; + SInt32 apiVersion; + void *shellContext; + void *pluginStorage; + CWFileSpec projectFile; + CWFileSpec outputFileDirectory; + SInt32 shellSignature; + SInt32 pluginType; + SInt32 numFiles; + SInt32 numOverlayGroups; + OSErr callbackOSError; + OSErr pluginOSError; + CWIDEInfo *shellInfo; + IDEAccessPathList *accessPathList; + SInt32 dontEatEvents; + CWFileSpec *targetDataDirectorySpec; + SInt32 reserved[17]; + CW_BasePluginCallbacks *callbacks; +}; + +struct CWCompilerLinkerContext : CWPluginPrivateContext { + CWCompilerLinkerContext(); + ~CWCompilerLinkerContext(); + + SInt32 whichfile; + CWFileSpec sourcefile; + const char *sourcetext; + SInt32 sourcetextsize; + Boolean precompile; + Boolean autoprecompile; + Boolean preprocess; + Boolean cachingPCH; + Boolean debuginfo; + SInt16 fileID; + CWBrowseOptions browseoptions; + Boolean recordbrowseinfo; + void *reserved; + SInt32 sequenceID; + CWCompilerLinkerContext *parentPB; + void *targetStorage; + SInt32 reservedcompiler[7]; + CWMemHandle texthandle; + CWTargetInfoV7 targetinfo_V7; + CWTargetInfo *targetinfo; + const char *commandLineArgs; + CWFileSpec *workingDirectorySpec; + SInt32 numEnvironmentVariables; + CWEnvVarInfo *environmentVariables; + SInt32 workingDirectoryError; + SInt32 reservedlinker[2]; + CWCompilerLinkerCallbacks *callbacks; +}; + +struct CWParserContext : CWPluginPrivateContext { + CWParserContext(); + ~CWParserContext(); + + CWCommandLineArgs *args; + CWDataType cpu; + CWDataType os; + const char *build_date; + const char *build_time; + const ToolVersionInfo *build_tool; + int numPlugins; + CLPluginInfo *plugins; + int numPanels; + const char **panelNames; + CWCommandLineArgs *plugin_args; + CWCommandLineArgs *panel_args; + CWParserCallbacks *callbacks; +}; +#ifdef __MWERKS__ +#pragma options align=reset +#endif -- cgit v1.2.3