size_t sqImageFileRead(void *ptr, size_t sz, size_t count, sqImageFile f) { int remaining, actuallyRead=0; unsigned char *dstPtr; remaining = sz * count; dstPtr = (unsigned char *)ptr; PRINTF(("\\t start loading image\n")); while (remaining >= CHUNK_SIZE) { actuallyRead = fread(dstPtr, (size_t)1, (size_t)CHUNK_SIZE, f); /* if we didnt read enough, return an error case */ if ( actuallyRead != CHUNK_SIZE) { return 0; } dstPtr += CHUNK_SIZE; remaining -= CHUNK_SIZE; dummyWimpPoll(); } actuallyRead = fread(dstPtr, (size_t)1, (size_t)remaining, f); /* if we didnt read enough, return an error case */ if ( actuallyRead != remaining) { return 0; } /* return the number of bytes read */ PRINTF(("\\t finish loading image\n")); return count; }
int main(int argc, char *argv[]) { FILE *f; extern void initGlobalStructure(void); extern void setMetaKeyOptions(int swap); parseArguments( argv, argc, args); if (versionMe) versionMessage(vmPath); if (helpMe) helpMessage(vmPath, "!Help"); atexit(exit_function); // setup a clean exit function InitRiscOS(); initGlobalStructure(); dummyWimpPoll(); /* read the image file and allocate memory for Squeak heap - the image name has been set to the path parsed by c.sqArgument - if no filename was passed in, the default is to expect an image file (Squeak/image) inside the application directory */ f = fopen(imageName, "rb"); PRINTF(("\\t Starting Squeak with image file: %s\n", imageName)); if (f == NULL) { /* give a RPC error message if image file is not found */ extern char VMVersion[]; privateErr.errnum = (bits)0; sprintf(privateErr.errmess, "Could not open the Squeak image file '%s' (Squeak version: %s)", imageName, VMVersion); printf("Squeak version: %s was unable to find and open the image file supposedly at %s\n", VMVersion, imageName); printf("If you simply tried to run the !Squeak application, it will have attempted to run a default image within the application directory which is not usually present\n"); platReportError((os_error *)&privateErr); helpMessage(vmPath, "!ImName"); ioExit(); } setMetaKeyOptions(swapMeta); readImageFromFileHeapSize(f, objectHeadroom); fclose(f); /* run Squeak */ PRINTF(("\\t start running image\n")); interpret(); }
int main(int argc, char *argv[]) { FILE *f; extern void initGlobalStructure(void); extern void setMetaKeyOptions(int swap); parseArguments( argv, argc, args); if (versionMe) versionMessage(vmPath); if (helpMe) helpMessage(vmPath, "!Help"); atexit(exit_function); // setup a clean exit function InitRiscOS(); initGlobalStructure(); dummyWimpPoll(); /* read the image file and allocate memory for Squeak heap */ f = fopen(imageName, "rb"); PRINTF(("\\t Starting Squeak with image file: %s\n", imageName)); if (f == NULL) { /* give a RPC error message if image file is not found */ extern char VMVersion[]; privateErr.errnum = (bits)0; sprintf(privateErr.errmess, "Could not open the Squeak image file '%s' (Squeak version: %s)", imageName, VMVersion); printf("%s\n", privateErr.errmess); platReportError((os_error *)&privateErr); helpMessage(vmPath, "!ImName"); ioExit(); } setMetaKeyOptions(swapMeta); readImageFromFileHeapSize(f, objectHeadroom); fclose(f); /* run Squeak */ PRINTF(("\\t start running image\n")); interpret(); }