Err sbuReceiveResponse( SyncBmrResponse_t **respP ) { UInt cardNo; LocalID dbID; DWord result; Err error; SyncBmrData_t *dataP; sbuFindSyncBmr( &cardNo, &dbID ); // find SyncBmr // Allocate memory for SyncBmr comm block dataP = (SyncBmrData_t *)MEM_ALLOC( sizeof( SyncBmrData_t ) ); ErrFatalDisplayIf( !dataP, "memory allocation" ); MemPtrSetOwner( dataP, 0 ); // set owner of storage to system dataP->waitForResponse = true; // indicate a response is expected dataP->requestP = NULL; // indicate no document to send dataP->responseP = NULL; // indicate no document received yet // Cause SyncBmr to be programmatically launched error = SysAppLaunch( cardNo, dbID, sysAppLaunchFlagNewGlobals, sysAppLaunchSyncBmrReceive, (void *)dataP, &result ); *respP = (SyncBmrResponse_t *)dataP->responseP; // return received document MEM_FREE( dataP ); // free SyncBmr comm block return 0; } // sbuSendResponse()
/* Finds and opens database, * calls plugin specific code to create new item, * then fills in GoTo parameters. */ static UInt16 PickBooger(KleenexPtr kleenexP) { DmOpenRef dbR; UInt32 creatorID; UInt16 cardNo; LocalID dbID; Boolean closedb = false; UInt16 err, index; Char name[dmDBNameLength]; /* Check for the correct version */ if (!((kleenexP->version) & IBVERSION_PICTURE)) return (boogerErrorVersionMismatch); /* Open the database */ cardNo = 0; if (!(dbID = DmFindDatabase(cardNo, "DiddleIDB"))) return 1; if ((dbR = DmOpenDatabase(cardNo, dbID, dmModeReadWrite))) { closedb = true; } else if (DmGetLastErr() == dmErrAlreadyOpenForWrites) { dbR = NULL; while ((dbR = DmNextOpenDatabase(dbR))) { DmOpenDatabaseInfo(dbR, &dbID, NULL, NULL, &cardNo, NULL); DmDatabaseInfo(cardNo, dbID, name, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &creatorID); if (!StrCompare(name, "DiddleIDB") && (creatorID == DB_CREATOR)) break; } if (!dbR) return 1; } /* Call plugin specific routine to create item in database */ err = DoTheBoogie(kleenexP, dbR, &index); /* Close the database */ if (closedb) DmCloseDatabase(dbR); /* Did it work? */ if (err) return (1); /* Load the GoTo parameters */ if (!(kleenexP->booger.cmdPBP = MemPtrNew(sizeof(GoToParamsType)))) return (1); MemSet(kleenexP->booger.cmdPBP, sizeof(GoToParamsType), 0); ((GoToParamsType *)(kleenexP->booger.cmdPBP))->dbCardNo = cardNo; ((GoToParamsType *)(kleenexP->booger.cmdPBP))->dbID = dbID; ((GoToParamsType *)(kleenexP->booger.cmdPBP))->recordNum = index; MemPtrSetOwner(kleenexP->booger.cmdPBP, 0); return (errNone); }
/* Finds and opens database, * calls plugin specific code to create new item, * then fills in GoTo parameters. */ static UInt16 PickBooger(KleenexPtr kleenexP) { DmOpenRef dbR; DmSearchStateType searchstate; UInt32 creatorID, dbtype; UInt16 cardNo; LocalID dbID; Boolean closedb = false; UInt16 err, index; /* Check for the correct version */ if (!((kleenexP->version) & IBVERSION_ORIG)) return (boogerErrorVersionMismatch); /* Open the database */ if (DmGetNextDatabaseByTypeCreator(true, &searchstate, DB_TYPE, DB_CREATOR, true, &cardNo, &dbID)) return (1); if ((dbR = DmOpenDatabase(cardNo, dbID, dmModeReadWrite))) { closedb = true; } else if (DmGetLastErr() == dmErrAlreadyOpenForWrites) { dbR = NULL; while ((dbR = DmNextOpenDatabase(dbR))) { DmOpenDatabaseInfo(dbR, &dbID, NULL, NULL, &cardNo, NULL); DmDatabaseInfo(cardNo, dbID, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &dbtype, &creatorID); if ((dbtype == DB_TYPE) && (creatorID == DB_CREATOR)) break; } if (!dbR) return (1); } /* Call plugin specific routine to create item in database */ err = DoTheBoogie(kleenexP, dbR, &index); /* Close the database */ if (closedb) DmCloseDatabase(dbR); /* Did it work? */ if (err) return (1); /* Load the GoTo parameters */ if (!(kleenexP->booger.cmdPBP = MemPtrNew(sizeof(GoToParamsType)))) return (1); MemSet(kleenexP->booger.cmdPBP, sizeof(GoToParamsType), 0); ((GoToParamsType *)(kleenexP->booger.cmdPBP))->dbCardNo = cardNo; ((GoToParamsType *)(kleenexP->booger.cmdPBP))->dbID = dbID; ((GoToParamsType *)(kleenexP->booger.cmdPBP))->recordNum = index; MemPtrSetOwner(kleenexP->booger.cmdPBP, 0); return (errNone); }
Int16 GotoAddress(Int16 index) { GoToParamsPtr theGotoPointer; DmSearchStateType searchInfo; UInt16 cardNo; LocalID dbID; UInt32 addrID = AddrGotoCreatorId[(int)gPrefsR.addrapp]; theGotoPointer = MemPtrNew(sizeof(GoToParamsType)); if (!theGotoPointer) return -1; /* Set the owner of the pointer to be the system. This is required because all memory allocated by our application is freed when the application quits. Our application will quit the next time through our event handler. */ if ((MemPtrSetOwner(theGotoPointer, 0) == 0) && (DmGetNextDatabaseByTypeCreator(true, &searchInfo, 0, addrID, true, &cardNo, &dbID) == 0)) { // copy all the goto information into the // GotoParamsPtr structure theGotoPointer->searchStrLen = 0; theGotoPointer->dbCardNo = cardNo; theGotoPointer->dbID = dbID; theGotoPointer->recordNum = index; theGotoPointer->matchPos = 0; theGotoPointer->matchFieldNum = 0; theGotoPointer->matchCustom = 0; if ((DmGetNextDatabaseByTypeCreator (true, &searchInfo, sysFileTApplication, addrID, true, &cardNo, &dbID) == 0)) { SysUIAppSwitch(cardNo, dbID, sysAppLaunchCmdGoTo, (MemPtr) theGotoPointer); /* * return from address? (fatal?) SysAppLaunch(cardNo, dbID, sysAppLaunchFlagNewThread, sysAppLaunchCmdGoTo, (MemPtr) theGotoPointer, &ret); */ return 0; } } MemPtrFree(theGotoPointer); return -1; }
Err FlickrAppendImageData(FlickrSocketContext& context, const void* data, UInt32 length) { context.imageData = PrvRealloc(context.imageData, context.imageSize + length); if (NULL == context.imageData) { DMSG("FlickrAppendImageData(): PrvRealloc() failed"); DENDL; return exgMemError; } MemPtrSetOwner(context.imageData, 0); char* p = (char*)context.imageData; p += context.imageSize; MemMove(p, data, length); context.imageSize += length; return errNone; }
static ZDicFontGlobalsType * PrvMakeGlobals(UInt16 refNum) { ZDicFontGlobalsType * gP = NULL; MemHandle gH; SysLibTblEntryType * libEntryP; /* Get library globals */ libEntryP = SysLibTblEntry(refNum); ErrFatalDisplayIf(libEntryP == NULL, "invalid ZDicFont refNum"); /* Error check to make sure the globals don't already exist */ ErrFatalDisplayIf(libEntryP->globalsP, "ZDicFont globals already exist"); /* Allocate and initialize our library globals. */ gH = MemHandleNew(sizeof(ZDicFontGlobalsType)); if ( !gH ) return( NULL ); /* Save the handle of our library globals in the system library table */ /* entry so we can later retrieve it using SysLibTblEntry(). */ libEntryP->globalsP = (void*)gH; /* Lock our globals (should not fail) */ gP = PrvLockGlobals(refNum); ErrFatalDisplayIf(gP == NULL, "failed to lock ZDicFont globals"); /* Set the owner of our globals memory chunk to "system" (zero), so it won't get * freed automatically by Memory Manager when the first application to call * ZDicFontOpen exits. This is important if the library is going to stay open * between apps. */ MemPtrSetOwner(gP, 0); /* Initialize our library globals */ MemSet(gP, sizeof(ZDicFontGlobalsType), 0); /* for convenience and debugging, save ref in globals structure */ gP->thisLibRefNum = refNum; /* initial open count */ gP->openCount = 0; /* return a pointer to our *locked* globals */ return( gP ); }
Err IntlSetRoutineAddress(IntlSelector iSelector, void* iProcPtr) { #if (EMULATION_LEVEL == EMULATION_NONE) void** tablePtr; Int16 i; if (iSelector > intlMaxSelector) { return(intlErrInvalidSelector); } ErrNonFatalDisplayIf(iProcPtr == NULL, "Null proc ptr parameter"); tablePtr = (void**)GIntlDispatchTableP; if (tablePtr == NULL) { tablePtr = (void**)MemPtrNew((intlMaxSelector + 1) * sizeof(Int32*)); if (tablePtr == NULL) { return(memErrNotEnoughSpace); } // Make sure it doesn't get tossed when the current app quits. MemPtrSetOwner(tablePtr, 0); // Initialize the table with all of the default routine addresses. for (i = 0; i <= intlMaxSelector; i++) { tablePtr[i] = IntlGetRoutineAddress(i); } // Set up the low-memory global with our new, valid table. GIntlDispatchTableP = tablePtr; } tablePtr[iSelector] = iProcPtr; return(errNone); #else // EMULATION_LEVEL != EMULATION_NONE ErrFatalDisplay("Can't call IntlSetRoutineAddress in Simulator"); return(errNone); #endif } // IntlSetRoutineAddress
/* * FUNCTION: PrvMakeGlobals * * DESCRIPTION: Create our library globals. * * PARAMETERS: * * refNum * Library reference number returned by SysLibLoad() or SysLibFind(). * * CALLED BY: internal * * RETURNS: * * pointer to our *locked* library globals * NULL if our globals could not be created. */ FlickrGlobals* PrvMakeGlobals(UInt16 refNum) { SysLibTblEntryType* libEntry = SysLibTblEntry(refNum); ErrFatalDisplayIf(libEntry == NULL, "invalid InfoMan Flickr Uploader refNum"); /* Error check to make sure the globals don't already exist */ ErrFatalDisplayIf(libEntry->globalsP != NULL, "InfoMan Flickr Uploader globals already exist"); /* Allocate and initialize our library globals. */ MemHandle handle = MemHandleNew(sizeof(FlickrGlobals)); if (NULL == handle) return NULL; FlickrGlobals* globals = (FlickrGlobals*)MemHandleLock(handle); if (NULL == globals) { MemHandleFree(handle); return NULL; } Err err = globals->Init(refNum); if (errNone != err) { MemPtrUnlock(globals); MemHandleFree(handle); return NULL; } /* Set the owner of our globals memory chunk to "system" (zero), so it won't get * freed automatically by Memory Manager when the first application to call * FlickrOpen exits. This is important if the library is going to stay open * between apps. */ MemPtrSetOwner(globals, 0); libEntry->globalsP = (MemPtr)handle; return globals; }
/*********************************************************************** * * FUNCTION: FntDefineFont * * DESCRIPTION: Define a font. Only an app font may be defined. The * application is responsible for freeing or releasing the font when * the application quits. * * PARAMETERS: fontID - id of the font to define. Should be a app defined * font only. * fontP - Pointer to font to use. * * RETURNED: memErrNotEnoughSpace - if it isn't able to allocate * space for the new font in the font table. * 0 - if no error * * REVISION HISTORY: * Name Date Description * ---- ---- ----------- * roger 9/26/97 Initial Revision * SCL 12/10/97 Rewrote to support new (separate) app font table * roger 11/ 9/98 Fixed MemMove reading past end of source. * gavin 11/18/98 set UINumAppFonts to count, not index * SCL 11/25/98 Fixed MemMove to copy exact size of old table * vivek 06/07/00 Added support for hierarchical application fonts * ***********************************************************************/ Err FntDefineFont (FontID fontID, FontPtr fontP) { UInt32 reqSize; FontTablePtr tableP; FontTablePtr newTableP; Err err; Int16 appFontIndex; Int16 fontIndex; Int16 numAppFonts; Boolean isSubFont; ErrNonFatalDisplayIf (!FntIsAppDefined(fontID), "App defined fonts only"); // KEY POINT: "...Index" is a zero-based array index, whereas // "...Num...Fonts" is a one-based number of fonts. // Thus, appFontIndex is the array index into which fontP will be installed. // The font table must be large enough to support this new font index. isSubFont = (fontP->fontType & fntAppSubFontMask) ? true : false; if (isSubFont) { numAppFonts = MemPtrSize(GAppSubFontListPtr) / sizeof(FontPtr); tableP = GAppSubFontListPtr; } else { tableP = UIAppFontTablePtr; numAppFonts = UINumAppFonts; } appFontIndex = (FontID) (fontID - fntAppFontCustomBase); // See if there's room in the app font table for this font if (appFontIndex >= numAppFonts) { // if not, try to resize the table (new size is appFontIndex+1 entries) reqSize = (appFontIndex+1) * sizeof(FontPtr); err = MemPtrResize(tableP, reqSize); // If we couldn't resize it, try and reallocate it if (err) { newTableP = MemPtrNew(reqSize); if (!newTableP) return memErrNotEnoughSpace; // Copy old table (numFonts entries) into new table MemMove(newTableP, tableP, numAppFonts * sizeof(FontPtr)); MemPtrSetOwner(newTableP, 0); // Change global to point to new table, and free the old one if (isSubFont) GAppSubFontListPtr = newTableP; else UIAppFontTablePtr = newTableP; MemPtrFree(tableP); tableP = newTableP; } // Zero out (only) the newly added slots in the table for (fontIndex = numAppFonts; fontIndex <= appFontIndex; fontIndex++) { tableP[fontIndex] = NULL; } // Save the new table size if (!isSubFont) UINumAppFonts = appFontIndex+1; } tableP[appFontIndex] = fontP; return 0; }
Boolean StartScummVM() { Char **argvP; UInt8 lightspeed, argc = 0; UInt32 stackSize; Boolean toLauncher, direct, isARM; UInt8 engine; Char num[6]; UInt16 index = GamGetSelected(); argvP = ArgsInit(); direct = false; // start command line (exec name) ArgsAdd(&argvP[argc], "-", NULL, &argc); // no game selected if (index == dmMaxRecordIndex) { ListPtr listP; UInt16 whichButton; // init form FormPtr frmP = FrmInitForm(EngineForm); listP = (ListType *)FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, EngineListList)); itemsText = (Char **)MemPtrNew(ENGINE_COUNT * sizeof(Char *)); for (int i = 0; i < ENGINE_COUNT; i++) itemsText[i] = (Char *)engines[i].nameP; LstSetListChoices (listP, itemsText, ENGINE_COUNT); LstSetSelection(listP, 0); whichButton = FrmDoDialog(frmP); engine = LstGetSelection(listP); FrmDeleteForm(frmP); MemPtrFree(itemsText); itemsText = NULL; if (whichButton == EngineCancelButton) { if (bDirectMode) { // and force exit if nothing selected EventType event; event.eType = keyDownEvent; event.data.keyDown.chr = vchrLaunch; event.data.keyDown.modifiers = commandKeyMask; EvtAddUniqueEventToQueue(&event, 0, true); } // free args ArgsFree(argvP); return false; } // default values if (bDirectMode) gPrefs->card.volRefNum = parseCards(); // always use the first removable card available (?) gVars->filter = true; gVars->palmVolume = 50; gVars->fmQuality = FM_QUALITY_INI; direct = true; // somthing selected } else { Char pathP[256]; MemHandle recordH; GameInfoType *gameInfoP; recordH = DmQueryRecord(gameDB,index); gameInfoP = (GameInfoType *)MemHandleLock(recordH); engine = gameInfoP->engine; // build path StrCopy(pathP,"/Palm/Programs/ScummVM/Games/"); if (gameInfoP->pathP[0] == '/') StrCopy(pathP, gameInfoP->pathP); else if (!(gameInfoP->pathP[0] == '.' && StrLen(gameInfoP->pathP) == 1)) StrCat(pathP, gameInfoP->pathP); // path ArgsAdd(&argvP[argc], "-p", pathP, &argc); // language if (gameInfoP->language > 0) { const Char *lang = "zh\0cz\0gb\0en\0fr\0de\0hb\0it\0jp\0kr\0pl\0pt\0ru\0es\0se\0"; ArgsAdd(&argvP[argc], "-q", (lang + (gameInfoP->language - 1) * 3), &argc); } // fullscreen ? if (gameInfoP->fullscreen) ArgsAdd(&argvP[argc], "-f", NULL, &argc); // aspect-ratio ? ArgsAdd(&argvP[argc], (gameInfoP->aspectRatio ? "--aspect-ratio" : "--no-aspect-ratio"), NULL, &argc); // gfx mode gVars->filter = gameInfoP->filter; switch (gameInfoP->renderMode) { case 1: ArgsAdd(&argvP[argc], "--render-mode=", "amiga", &argc); break; case 2: ArgsAdd(&argvP[argc], "--render-mode=", "cga", &argc); break; case 3: ArgsAdd(&argvP[argc], "--render-mode=", "ega", &argc); break; case 4: ArgsAdd(&argvP[argc], "--render-mode=", "hercAmber", &argc); break; case 5: ArgsAdd(&argvP[argc], "--render-mode=", "hercGreen", &argc); break; } switch (gameInfoP->gfxMode) { case 1: ArgsAdd(&argvP[argc], "-g", "wide", &argc); break; default: ArgsAdd(&argvP[argc], "-g", "1x", &argc); break; } // load state if (gameInfoP->autoLoad) { StrIToA(num, gameInfoP->loadSlot); ArgsAdd(&argvP[argc], "-x", num, &argc); } // boot script parameter if (gameInfoP->bootParam) { StrIToA(num, gameInfoP->bootValue); ArgsAdd(&argvP[argc], "-b", num, &argc); } // not a PC version if (gameInfoP->setPlatform) { static const char *platform[] = { "3do", "acorn", "amiga", "atari", "c64", "pc", "fmtowns", "linux", "mac", "nes", "segacd", "windows" }; ArgsAdd(&argvP[argc], "--platform=", platform[gameInfoP->platform], &argc); } // subtitles if (gameInfoP->subtitles) ArgsAdd(&argvP[argc], "-n", NULL, &argc); // multi midi ? if (gameInfoP->musicInfo.sound.multiMidi) ArgsAdd(&argvP[argc], "--multi-midi", NULL, &argc); if (engine == ENGINE_SCUMM) { // music tempo StrIToA(num, gameInfoP->musicInfo.sound.tempo); ArgsAdd(&argvP[argc], "--tempo=", num, &argc); } // talk speed if (gameInfoP->talkSpeed) { StrIToA(num, gameInfoP->talkValue); ArgsAdd(&argvP[argc], "--talkspeed=", num, &argc); } // music driver if (gameInfoP->musicInfo.sound.music) { static char *drv[] = { "auto", "null", "adlib", "towns", "pcjr", "native", "pcspk" }; if (StrCompare(drv[gameInfoP->musicInfo.sound.drvMusic], "native") == 0) { if (OPTIONS_TST(kOptDeviceZodiac)) ArgsAdd(&argvP[argc], "-e", "zodiac", &argc); // Tapwave Zodiac else if (OPTIONS_TST(kOptSonyPa1LibAPI)) ArgsAdd(&argvP[argc], "-e", "ypa1", &argc); // Pa1Lib devices else ArgsAdd(&argvP[argc], "-e", "auto", &argc); // no driver, switch to auto } else { ArgsAdd(&argvP[argc], "-e", drv[gameInfoP->musicInfo.sound.drvMusic], &argc); } // output rate UInt32 rates[] = {4000, 8000, 11025, 22050, 44100}; StrIToA(num, rates[gameInfoP->musicInfo.sound.rate]); ArgsAdd(&argvP[argc], "--output-rate=", num, &argc); // FM quality gVars->fmQuality = gameInfoP->fmQuality; } else { ArgsAdd(&argvP[argc], "-e", "null", &argc); } // volume control StrIToA(num, gameInfoP->musicInfo.volume.sfx); ArgsAdd(&argvP[argc], "-s", num, &argc); StrIToA(num, gameInfoP->musicInfo.volume.music); ArgsAdd(&argvP[argc], "-m", num, &argc); StrIToA(num, gameInfoP->musicInfo.volume.speech); ArgsAdd(&argvP[argc], "-r", num, &argc); // game name ArgsAdd(&argvP[argc], gameInfoP->gameP, NULL, &argc); // others globals data gVars->CD.enable = gameInfoP->musicInfo.sound.CD; gVars->CD.driver = gameInfoP->musicInfo.sound.drvCD; gVars->CD.format = gameInfoP->musicInfo.sound.frtCD; gVars->CD.volume = gameInfoP->musicInfo.volume.audiocd; gVars->CD.defaultTrackLength = gameInfoP->musicInfo.sound.defaultTrackLength; gVars->CD.firstTrack = gameInfoP->musicInfo.sound.firstTrack; gVars->palmVolume = gameInfoP->musicInfo.sound.music ? gameInfoP->musicInfo.volume.palm : 0; MemHandleUnlock(recordH); } // end no game / game selected // common command line options // debug level if (gPrefs->debug) { StrIToA(num, gPrefs->debugLevel); ArgsAdd(&argvP[argc], "-d", num, &argc); } if (engine == ENGINE_QUEEN || engine == ENGINE_SKY) { // alternative intro ? if (gPrefs->altIntro) ArgsAdd(&argvP[argc], "--alt-intro", NULL, &argc); } if (engine == ENGINE_SCUMM) { // demo mode ? if (gPrefs->demoMode) ArgsAdd(&argvP[argc], "--demo-mode", NULL, &argc); } // copy protection ? if (gPrefs->copyProtection) ArgsAdd(&argvP[argc], "--copy-protection", NULL, &argc); // exceed max args ? if (argc > MAX_ARG) FrmCustomAlert(FrmErrorAlert, "Too many parameters.",0,0); // set some common options stackSize = (gPrefs->setStack ? STACK_LARGER : STACK_DEFAULT); lightspeed= (gPrefs->lightspeed.enable ? gPrefs->lightspeed.mode : 255); toLauncher= (gPrefs->exitLauncher); // gVars values // (gVars->HRrefNum defined in checkHRmode on Clié) gVars->VFS.volRefNum = gPrefs->card.volRefNum; gVars->vibrator = gPrefs->vibrator; gVars->stdPalette = gPrefs->stdPalette; gVars->VFS.cacheSize = (gPrefs->card.useCache ? gPrefs->card.cacheSize : 0); gVars->indicator.showLED= gPrefs->card.showLED; gVars->stylusClick = gPrefs->stylusClick; gVars->autoSave = (gPrefs->autoSave ? gPrefs->autoSavePeriod : -1); gVars->advancedMode = gPrefs->advancedMode; gVars->arrowKeys = gPrefs->arrowKeys; // user params HWR_RSTALL(); if (gPrefs->goLCD) HWR_SET(INIT_GOLCD); else OPTIONS_RST(kOptGoLcdAPI); if (!gPrefs->autoOff) HWR_SET(INIT_AUTOOFF); if (gVars->vibrator) HWR_SET(INIT_VIBRATOR); /* ???? if ( musicDriver == 1 || musicDriver == 3 || musicDriver == 4 || musicDriver == sysInvalidRefNum) { HWR_SET(INIT_PA1LIB); } */ if (ModImport(gVars->VFS.volRefNum, engine, &isARM) != errNone) { if (bDirectMode) { // and force exit if nothing selected EventType event; event.eType = keyDownEvent; event.data.keyDown.chr = vchrLaunch; event.data.keyDown.modifiers = commandKeyMask; EvtAddUniqueEventToQueue(&event, 0, true); } ArgsFree(argvP); return false; } // reset mode if screen rotation occured (DIA only) if (!direct && OPTIONS_TST(kOptCollapsible)) { UInt8 mode = PalmScreenSize(0,0, &(gVars->screenFullWidth), &(gVars->screenFullHeight)); OPTIONS_RST(kOptModeLandscape); OPTIONS_SET((mode == PALM_LANDSCAPE) ? kOptModeLandscape : kOptNone); } // free and save globals pref memory GamCloseDatabase(false); FrmCloseAllForms(); SavePrefs(); { UInt16 cardNo; UInt32 dbID; LaunchParamType *cmdPBP = (LaunchParamType *)MemPtrNew(sizeof(LaunchParamType)); MemPtrSetOwner(cmdPBP, 0); MemPtrSetOwner(gVars, 0); ArgsSetOwner(argvP, 0); cardNo = 0; dbID = DmFindDatabase(0, "ScummVM-Engine"); if (isARM) FtrSet(appFileCreator, ftrStack , (stackSize * 4)); else ModSetStack(stackSize, cardNo, dbID); cmdPBP->args.argc = argc; cmdPBP->args.argv = argvP; cmdPBP->gVars = gVars; cmdPBP->lightspeed = lightspeed; cmdPBP->exitLauncher = toLauncher; SysUIAppSwitch(cardNo, dbID, sysAppLaunchCmdNormalLaunch, cmdPBP); bLaunched = true; } return false; }
// ExgLibPut Err FlickrPut(UInt16 libRefnum, ExgSocketType* exgSocket) { DMSG("FlickrPut() enter"); DENDL; FlickrDbOpen dbOpen; assert(exgSocket->libraryRef == libRefnum); FlickrSocketContext* context = NULL; const char* extension = NULL; const char* mimeType = NULL; const char* name = NULL; Err err = FlickrDetectExtensionAndType(exgSocket, extension, mimeType, name); if (errNone != err) { FlickrAlert(unsupportedFormatAlert); goto Finish; } DMSG("FlickrPut() using extension: "); DMSG(extension); DMSG(" and type: "); DMSG(mimeType); DENDL; if (NULL != exgSocket->socketRef) { DMSG("FlickrPut(): socketRef is not NULL!");DENDL; context = (FlickrSocketContext*)exgSocket->socketRef; if (FlickrSocketContext::magicValue != context->magic) { DMSG("FlickrPut(): socketRef probably is not context, magic value mismatch"); DENDL; exgSocket->socketRef = NULL; } else { err = FlickrUploadImage(*context, exgSocket); if (errNone != err) goto Finish; err = context->Reset(); if (errNone != err) goto Finish; } } if (NULL == exgSocket->socketRef) { context = new FlickrSocketContext(libRefnum); if (NULL == context) { DMSG("FlickrPut(): not enough memory to create FlickrSocketContext");DENDL; FlickrAlert(notEnoughMemoryAlert); err = exgMemError; goto Finish; } err = context->Init(); if (errNone != err) { // TODO: inspect error and display appropriate alert goto Finish; } exgSocket->socketRef = (UInt32)context; MemPtrSetOwner(context, 0); } bool hasCredentials; err = FlickrVerifyUserCredentials(hasCredentials, context->prefs); if (errNone != err) goto Finish; if (!hasCredentials) { DMSG("FlickrVerifyUserCredentials() returned false"); DENDL; err = FlickrGetUserCredentials(context->prefs); if (errNone != err) goto Finish; } DMSG("FlickrPut() user credentials obtained succesfully; email: "); DMSG(context->prefs.email); DMSG("; password: "******"PrgUpdateDialog() called"); DENDL; PrvUpdateProgress(*context, err); err = PrvProcessEvents(*context, 0); } if (errNone != err) { delete context; exgSocket->socketRef = NULL; } DMSG("FlickrPut() exit; error: ");DNUM(err);DENDL return err; }