AmendHub

Download:

nulleric

/

Fix-a-Fork

/

amendments

/

5

Put all checks at bottom of file for now, move later.


eric made amendment 5 about 1 year ago
--- main.c Wed Nov 8 20:30:04 2023 +++ main.c Wed Nov 8 20:49:47 2023 @@ -70,28 +70,7 @@ void OpenFileDialog() } } while(tr.good); } -Boolean magicCheck(char *magic, short offset, OSType type, OSType creator) -{ - short i; - for(i = 0; i < sizeof(magic) - 1; i++) - if(gBuf[offset+i] != magic[i]) - return false; - gType = type; - gCreator = creator; - return true; -} -Boolean isBinHex4() -{ - //char magic[] = ; - return magicCheck("BinHex 4.0", 34, 'TEXT', 'BnHq'); -} - -Boolean isSit5() -{ - return magicCheck("SIT!", 0, 'SIT!', 'SIT!'); -} - OSErr openFile(unsigned char *fName, short fRefNum, short vRefNum) { short err; @@ -107,7 +86,7 @@ OSErr openFile(unsigned char *fName, short fRefNum, sh // Check for magic in first 1024 bytes if(isBinHex4()) found = true; - else if(isSit5()) + else if(isSit15()) found = true; if(found) @@ -145,4 +124,26 @@ void main() if(!gHandledByDnD) OpenFileDialog(); return; +} +// TODO: Move to own file. + +Boolean isBinHex4() +{ + return magicCheck("BinHex 4.0", 34, 'TEXT', 'BnHq'); +} + +Boolean isSit15() +{ + return magicCheck("SIT!", 0, 'SIT!', 'SIT!'); +} + +Boolean magicCheck(char *magic, short offset, OSType type, OSType creator) +{ + short i; + for(i = 0; i < sizeof(magic) - 1; i++) + if(gBuf[offset+i] != magic[i]) + return false; + gType = type; + gCreator = creator; + return true; } --- main.h Wed Nov 8 20:07:14 2023 +++ main.h Wed Nov 8 20:50:57 2023 @@ -16,3 +16,8 @@ Boolean gHandledByDnD = false; OSErr openFile(unsigned char *fName, short fRefNum, short vRefNum); pascal OSErr DoOpenDoc(AppleEvent *event, AppleEvent *reply, long handlerRefcon); + +// checks +Boolean magicCheck(char *magic, short offset, OSType type, OSType creator); +Boolean isBinHex4(); +Boolean isSit15();