Remove MacOS (Classic) code and all references (1/3)

The MACINTOSH define refers to MacOS Classic (not OS X) which we do not
plan to support. Rather than carry the cruft forever, let's delete it.

NOTE: legacy/ is unused but we're keeping it around, so MACINTOSH uses
there are left alone.

Process used for this commit:
```
git rm -r mac
find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" \) \
  -exec unifdef -UMACINTOSH -o {} {} \;
git restore legacy
git add .
```

Test Plan:
On Mac, build both Debug and Release
```
cmake --build --preset mac --config Debug
cmake --build --preset mac --config Release
```
This commit is contained in:
Chris Sarbora
2024-04-26 15:22:03 -07:00
parent 9ec7714ebc
commit e6ba1906c9
299 changed files with 172 additions and 3869 deletions

View File

@@ -100,10 +100,6 @@
bool mod_FindRealFileNameCaseInsenstive(const char *directory, const char *filename, char *new_filename);
#endif
#ifdef MACINTOSH
#include <Files.h>
#include <CodeFragments.h>
#endif
#include "module.h"
#include "pstypes.h"
#include "pserror.h"
@@ -160,58 +156,6 @@ void dd_MakePath(char *newPath, const char *absolutePathHeader, const char *subD
}
va_end(args);
}
#elif defined(MACINTOSH)
// DAJ why duplicate the functions that ddio provides???
// Split a pathname into its component parts
void dd_SplitPath(const char *srcPath, char *path, char *filename, char *ext) {
#ifdef FIXED
char drivename[_MAX_DRIVE], dirname[_MAX_DIR];
_splitpath(srcPath, drivename, dirname, filename, ext);
if (path)
sprintf(path, "%s%s", drivename, dirname);
#endif
}
// Constructs a path in the local file system's syntax
// newPath: stores the constructed path
// absolutePathHeader: absolute path on which the sub directories will be appended
// (specified in local file system syntax)
// takes a variable number of subdirectories which will be concatenated on to the path
// the last argument in the list of sub dirs *MUST* be NULL to terminate the list
void dd_MakePath(char *newPath, const char *absolutePathHeader, const char *subDir, ...) {
#ifdef FIXED
const char delimiter = '\\';
va_list args;
char *currentDir = NULL;
int pathLength = 0;
assert(newPath);
assert(absolutePathHeader);
assert(subDir);
if (newPath != absolutePathHeader) {
strcpy(newPath, absolutePathHeader);
}
// Add the first sub directory
pathLength = strlen(newPath);
if (newPath[pathLength - 1] != delimiter) {
newPath[pathLength] = delimiter; // add the delimiter
newPath[pathLength + 1] = 0; // terminate the string
}
strcat(newPath, subDir);
// Add the additional subdirectories
va_start(args, subDir);
while ((currentDir = va_arg(args, char *)) != NULL) {
pathLength = strlen(newPath);
if (newPath[pathLength - 1] != delimiter) {
newPath[pathLength] = delimiter; // add the delimiter
newPath[pathLength + 1] = 0; // terminate the string
}
strcat(newPath, currentDir);
}
va_end(args);
#endif
}
#elif defined(__LINUX__)
// Split a pathname into its component parts
void dd_SplitPath(const char *srcPath, char *path, char *filename, char *ext) {
@@ -331,16 +275,10 @@ int ModLastError = MODERR_NOERROR;
// system specific extension is concatted and returned.
void mod_GetRealModuleName(const char *modfilename, char *realmodfilename) {
char pathname[_MAX_PATH], filename[_MAX_FNAME], extension[_MAX_EXT];
#ifdef MACINTOSH
ddio_SplitPath(modfilename, pathname, filename, extension);
#else
dd_SplitPath(modfilename, pathname, filename, extension);
#endif
if (*extension == '\0')
#if defined(WIN32)
strcat(filename, ".dll");
#elif defined(MACINTOSH)
strcat(filename, ".msl");
#elif defined(__LINUX__)
#if defined(MACOSX)
strcat(filename, ".dylib");
@@ -354,11 +292,6 @@ void mod_GetRealModuleName(const char *modfilename, char *realmodfilename) {
strcat(filename, ".dll");
else
strcat(filename, extension);
#elif defined(MACINTOSH)
if (!stricmp(extension, ".dll") || !stricmp(extension, "so") || !stricmp(extension, "dylib"))
strcat(filename, ".msl");
else
strcat(filename, extension);
#elif defined(__LINUX__) && !defined(MACOSX)
if (!stricmp(extension, ".dll") || !stricmp(extension, "msl") || !stricmp(extension, "dylib"))
strcat(filename, ".so");
@@ -373,11 +306,7 @@ void mod_GetRealModuleName(const char *modfilename, char *realmodfilename) {
#endif
}
if (*pathname != '\0')
#ifdef MACINTOSH
ddio_MakePath(realmodfilename, pathname, filename, NULL);
#else
dd_MakePath(realmodfilename, pathname, filename, NULL);
#endif
else
strcpy(realmodfilename, filename);
}
@@ -448,31 +377,6 @@ bool mod_LoadModule(module *handle, char *imodfilename, int flags) {
}
}
}
#elif defined(MACINTOSH)
OSErr err = noErr;
FSSpec SLSpec;
Str255 errName;
Str63 toolName;
Ptr myMainAddr;
CFragConnectionID connID;
Str255 symName;
strcpy((char *)symName, modfilename);
c2pstr((char *)symName);
err = FSMakeFSSpec(0, 0L, symName, &SLSpec);
if (err) {
mprintf((2, "could not make FSSpec in loadModule\n"));
// Int3();
}
err = GetDiskFragment(&SLSpec, 0, 0, NULL, 5, &connID, (Ptr *)NULL, NULL);
// err = GetDiskFragment(&SLSpec, 0, kCFragGoesToEOF, toolName, kPrivateCFragCopy, &connID, (Ptr*)&myMainAddr,
// errName);
if (err) {
mprintf((2, "could not get disk fragmet %s\n", modfilename));
// Int3();;
}
handle->handle = connID;
mprintf((0, "opening fragment ID 0x%X\n", handle->handle));
#endif
// Success
return true;
@@ -494,17 +398,6 @@ bool mod_FreeModule(module *handle) {
ret = (FreeLibrary(handle->handle) != 0);
#elif defined(__LINUX__)
dlclose(handle->handle); // dlclose() returns an int, but no docs say what values!!!
#elif defined(MACINTOSH)
/* //BROKE! but not needed, OS closes connection on quit
OSErr err = noErr;
if(handle->handle)
mprintf((0, "closeing fragment 0x%X\n", handle->handle));
err = CloseConnection((CFragConnectionID*)handle->handle);
if(err != noErr) {
mprintf((2, "could not close fragment 0x%X\n", handle->handle));
// return false;
}
*/
#endif
handle->handle = NULL;
return ret;
@@ -571,34 +464,6 @@ MODPROCADDRESS mod_GetSymbol(module *handle, char *symstr, unsigned char parmbyt
ModLastError = MODERR_OTHER;
return NULL;
}
#elif defined(MACINTOSH)
OSErr err = noErr;
CFragSymbolClass symClass;
CFragConnectionID connID;
Str255 symName;
mprintf((0, "finding %s in fragment 0x%X\n", symstr, handle->handle));
connID = (CFragConnectionID)handle->handle;
// DAJ for testing only
long numSym;
Ptr symAddr;
err = CountSymbols(connID, &numSym);
for (int i = 0; i < numSym; i++) {
err = GetIndSymbol(connID, i, symName, &symAddr, &symClass);
}
strcpy((char *)symName, symstr);
c2pstr((char *)symName);
err = FindSymbol(connID, symName, (Ptr *)&sym, &symClass);
if (err) {
mprintf((2, "could not find %s in fragment %d\n", symstr, handle->handle));
return NULL;
}
if (!sym) {
ModLastError = MODERR_OTHER;
return NULL;
}
#endif
return sym;
}