From fb3ea1342d723d0847e28e799992a1a3cfef08b2 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Wed, 5 May 2021 21:58:48 -0400 Subject: [PATCH] add -r flag to generate rez file/proper resource fork at run time --- md2teach/io.c | 14 +++++++++----- md2teach/main.c | 6 +++++- md2teach/main.h | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/md2teach/io.c b/md2teach/io.c index a2310d4..307736a 100644 --- a/md2teach/io.c +++ b/md2teach/io.c @@ -26,7 +26,6 @@ // This enables a workaround for creating the resources by writing a .rez file rather than // writing it directly. At the moment, Golden Gate does not support writing resources // but this will let me test it without that capability. -#define RESOURCE_WORKAROUND #define TEACH_FILE_TYPE 0x50 #define TEACH_AUX_TYPE 0x5445 @@ -159,7 +158,6 @@ MD_SIZE outputPos(void) static int writeResources(void) { int result = 0; -#ifndef RESOURCE_WORKAROUND int shutdownResources = 0; Word writeResId; Word oldResId; @@ -216,7 +214,14 @@ error: if (shutdownResources) ResourceShutDown(); -#else + + return result; +} + + +static int writeRez(void) +{ + int result = 0; FILE * rezFile; uint8_t * ptr; uint32_t size; @@ -279,7 +284,6 @@ error: "\n"); fclose(rezFile); -#endif return result; } @@ -295,7 +299,7 @@ int closeOutputFile(void) closeRec.refNum = writeRec.refNum; CloseGS(&closeRec); - return writeResources(); + return generateRez ? writeRez() : writeResources(); } diff --git a/md2teach/main.c b/md2teach/main.c index 157067a..706cb49 100644 --- a/md2teach/main.c +++ b/md2teach/main.c @@ -36,13 +36,14 @@ char * commandName; int debugEnabled = 0; int debugIndentLevel = 0; +int generateRez = 0; // Implementation static void printUsage(void) { - fprintf(stderr, "USAGE: %s [ -d ] inputfile outputfile\n", commandName); + fprintf(stderr, "USAGE: %s [ -d -r ] inputfile outputfile\n", commandName); } @@ -64,6 +65,9 @@ static int parseArgs(int argc, char * argv[]) case 'd': debugEnabled = 1; break; + case 'r': + generateRez = 1; + break; default: printUsage(); diff --git a/md2teach/main.h b/md2teach/main.h index bc10dfd..5322eed 100644 --- a/md2teach/main.h +++ b/md2teach/main.h @@ -13,6 +13,6 @@ extern char * commandName; extern int debugEnabled; extern int debugIndentLevel; - +extern int generateRez; #endif /* main_h */