int main(int argc, char *argv[]) { int ch; char *fn; /* Report stack usage at end if compile option is set */ __REPORT_STACK(); /* Parse the command-line options */ while ((ch = getopt(argc, argv, "bc")) != -1) switch (ch) { case 'c': cflag = 1; break; case 'b': bflag = 1; break; case '?': default: usage(); } argc -= optind; argv = argv + optind; if (!*argv) usage(); else { /* Start up the resource manager */ ResourceStartUp(userid()); /* Parse the command-line filenames */ while (*argv) { fn = *argv++; ReadResources(fn); if (*argv && !bflag) (void)printf("\n"); } /* Shut down the resource manager */ /* (which closes open resource files) */ ResourceShutDown(); } exit(rval); }
GrafPortPtr NDAOpen(void) { Pointer pathToSelf; unsigned int oldResourceApp; LevelRecGS levelDCB; unsigned int oldLevel; SysPrefsRecGS prefsDCB; unsigned int oldPrefs; int numOps; int i; Handle opListCtl; if (gCalcActive) return NULL; oldResourceApp = GetCurResourceApp(); ResourceStartUp(gUserId); pathToSelf = LGetPathname2(gUserId, 1); levelDCB.pCount = 2; GetLevelGS(&levelDCB); oldLevel = levelDCB.level; levelDCB.level = 0; SetLevelGS(&levelDCB); prefsDCB.pCount = 1; GetSysPrefsGS(&prefsDCB); oldPrefs = prefsDCB.preferences; prefsDCB.preferences = (prefsDCB.preferences & 0x1fff) | 0x8000; SetSysPrefsGS(&prefsDCB); gResourceId = OpenResourceFile(readEnable, NULL, pathToSelf); gCalcWinPtr = NewWindow2("\p abCalc ", 0, DrawContents, NULL, refIsResource, abCalcWinNum, rWindParam1); SetSysWindow(gCalcWinPtr); ShowWindow(gCalcWinPtr); SelectWindow(gCalcWinPtr); SetPort(gCalcWinPtr); if (gOpList == NULL) { numOps = abCalcOpNumOps(); gOpList = malloc(sizeof(*gOpList) * numOps); for (i = 0; i < numOps; i++) { gOpList[i].memPtr = abCalcOpNth(i)->name; gOpList[i].memFlag = 0; } } opListCtl = (Handle)GetCtlHandleFromID(gCalcWinPtr, abCalcOpList); NewList2(NULL, 1, (Ref)gOpList, 0, numOps, opListCtl); UpdateStack(); gCalcActive = TRUE; prefsDCB.preferences = oldPrefs; SetSysPrefsGS(&prefsDCB); levelDCB.level = oldLevel; SetLevelGS(&levelDCB); SetCurResourceApp(oldResourceApp); return gCalcWinPtr; }