#include #include #include #include #include "IR.h" /* IR.h (available w/ IR) doesn't have an #endif and twice says '#define That needs to be fixed, but it's not my duty to distrubute the modified headers. */ #ifdef STACK #include #include #endif /* Function Prototypes */ GSString255Ptr cstring2gs(char *); void FixSBI(void); /* extern (assembly) kludge */ /* IR.h doesn't have this record */ typedef struct askIrAreYouThereOut{ word recvCount; word IrID; long IRVersion; }askIrAreYouThereOut, *AskIRAreYouThereOutPtr; askIrAreYouThereOut IRHere; askInstallInputRecord InstallIn={irDontOpenNDAs+irNoDuplicates,NULL,0,0}; askInstallOutputRecord InstallOut; OpenRecGS OpenOS= {15,0,NULL,1,0,0,0,0L,0, {0,0,0,0,0,0,0,0},{0,0,0,0,0,0,0,0}, NULL,0L,0L,0L,0L}; RefNumRecGS CloseOS={1,0}; word MyID; extern void Fix_start(void); extern void Fix_end(void); int main(int argc, char *argv[]){ #ifdef STACK begin_stack_check(); #endif MyID=MMStartUp(); if (argc==1){ WriteCString("\tShell Interface for IR v 1.0\r"); WriteCString("\tKelvin Sherlock, 3/19/97\r"); WriteCString("Usage: "); WriteCString(argv[0]); WriteCString(" \r"); MMShutDown(MyID); return 0; } /* check that IR is active */ SendRequest(askIRAreYouThere,sendToName+stopAfterOne, (long)NAME_OF_IR, (long)NULL, (Ptr)&IRHere); if (_toolErr){ WriteCString(argv[0]); WriteCString(" :Error - IR is not active\r"); MMShutDown(MyID); return 0; } /* get the file/auxtype */ OpenOS.pathname = InstallIn.pathname = cstring2gs(argv[1]); OpenGS(&OpenOS); if (_toolErr){ WriteCString(argv[0]); WriteCString(" :Error - could not open file "); WriteCString(argv[1]); WriteCString("\r"); MMShutDown(MyID); return 0; } CloseOS.refNum= OpenOS.refNum; CloseGS(&CloseOS); InstallIn.filetype=OpenOS.fileType; InstallIn.auxtype=OpenOS.auxType; Fix_start(); SendRequest(askIRToInstall,sendToName+stopAfterOne, (long)NAME_OF_IR, (long)&InstallIn, (Ptr)&InstallOut); Fix_end(); if ( (_toolErr) || (InstallOut.irError) ){ /* error installing */ WriteCString(argv[0]); WriteCString(" :Error - IR could not install the file "); WriteCString(argv[1]); WriteCString("\r"); MMShutDown(MyID); return 0; } MMShutDown(MyID); #ifdef STACK printf("stack usage %d\n",end_stack_check()); #endif return 0; } /* Converts a C string to a GSOS string */ GSString255* cstring2gs(char *the_file_name){ static GSString255 string; string.length=strlen(the_file_name); BlockMove(the_file_name,(Pointer)(&string)+2,string.length); //move the string into it return &string; }