void NDAClose(void) { int i; if (gCalcActive) { CloseWindow(gCalcWinPtr); gCalcWinPtr = NULL; gCalcActive = FALSE; } if (gBuffer != NULL) { free(gBuffer); gBuffer = NULL; } if (gOpList != NULL) { free(gOpList); gOpList = NULL; } for (i = 0; i < AB_CALC_STACK_DEPTH; i++) { if (gStackList[i].memPtr != NULL) { free(gStackList[i].memPtr); gStackList[i].memPtr = NULL; } } CloseResourceFile(gResourceId); ResourceShutDown(); }
/* * Read the version (and, optionally, comment) resources from the * indicated file */ static void ReadResources(char *path_str) { #define noPreload 0x8000 Word new_file_id; Word old_file_id; Word old_depth; GSString255Ptr path_ptr; Handle rVer_handle, rCom_handle; int error; /* Let user know what file we're working on */ (void)printf("%s: ",path_str); /* Convert C string into GSString */ path_ptr = malloc_c(strlen(path_str)+2); path_ptr->length = strlen(path_str); strcpy(path_ptr->text, path_str); /* Open the resource fork of the file */ new_file_id = OpenResourceFile(noPreload+readEnable, NULL, (Pointer)path_ptr); if ((error = toolerror()) != noError) { if (error == 0x0046) (void)printf("File not found\n"); else if (error == 0x0063) (void)printf("No resource fork\n"); else (void)printf("Error $%04X opening resource fork\n", error); rval = 1; } else { /* Set up to search only this resource file, remembering */ /* previous setting so it can be restored when closing file */ old_file_id = GetCurResourceFile(); SetCurResourceFile(new_file_id); old_depth = SetResourceFileDepth(1); /* Read the version resource */ rVer_handle = LoadResource(0x8029,1); if ((error = toolerror()) != noError) { if (error == 0x1E06) (void)printf("No version resource\n"); else (void)printf( "Error $%04X getting version resource\n", error); rval = 1; } else { PrintVersionResource(*rVer_handle); } /* Read the comment resource, if requested */ if ( cflag ) { rCom_handle = LoadResource(0x802A,1); if ((error = toolerror()) == noError) { PrintCommentResource(*rCom_handle); } } /* Close the resource file and restore original search values */ CloseResourceFile(new_file_id); SetCurResourceFile(old_file_id); SetResourceFileDepth(old_depth); } /* Free the memory allocated for the path name */ free(path_ptr); }