/* Create an app info chunk if missing, return result from the database call */ static void InitPlkrAppInfo ( DmOpenRef docRef /* reference to document */ ) /* THROWS */ { UInt16 cardNo; MemHandle handle; LocalID dbID; LocalID appInfoID; PlkrAppInfoType* appInfoP; Err err; err = DmOpenDatabaseInfo( docRef, &dbID, NULL, NULL, &cardNo, NULL ); THROW_IF( err != errNone, err ); err = DmDatabaseInfo( cardNo, dbID, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &appInfoID, NULL, NULL, NULL ); THROW_IF( err != errNone, err ); if ( appInfoID == 0 ) { handle = DmNewHandle( docRef, sizeof *appInfoP ); THROW_IF( handle == NULL, dmErrMemError ); appInfoID = MemHandleToLocalID( handle ); DmSetDatabaseInfo( cardNo, dbID, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &appInfoID, NULL, NULL, NULL ); } appInfoP = MemLocalIDToLockedPtr( appInfoID, cardNo ); DmSet( appInfoP, 0, sizeof *appInfoP, 0 ); CategoryInitialize( ( AppInfoPtr ) appInfoP, strCatDefault ); MemPtrUnlock( appInfoP ); }
static void SelectUsingFingerAddr() { FormPtr form = FrmGetActiveForm(); if (FormIsNot(form, FormReply)) return; UInt16 mode = g_ComposeMode; char* pszTo = FldGetTextPtr((FieldPtr) GetObjectPtr(form, FieldTo)); char* pszCompose = FldGetTextPtr((FieldPtr) GetObjectPtr(form, FieldCompose)); char* pszReference = FldGetTextPtr((FieldPtr) GetObjectPtr(form, FieldReference)); UInt16 lenTo = 0; if (pszTo) lenTo = StrLen(pszTo); UInt16 lenCompose = 0; if (pszCompose) lenCompose = StrLen(pszCompose); UInt16 lenReference = 0; if (pszReference) lenReference = StrLen(pszReference); UInt16 size = sizeof(UInt16) + lenTo + 1 + lenCompose + 1 + lenReference + 1; char* ftrBuf = NULL; Err err = FtrPtrNew(appFileCreator, (UInt16) FEATURE_FINGER_ADDR, size, (void**) &ftrBuf); if (err) return; DmSet(ftrBuf, 0, size, 0); UInt16 offset = 0; DmWrite(ftrBuf, offset, &mode, sizeof(UInt16)); offset += sizeof(UInt16); if (lenTo) { DmWrite(ftrBuf, offset, pszTo, lenTo); } offset += lenTo + 1; if (lenCompose) { DmWrite(ftrBuf, offset, pszCompose, lenCompose); } offset += lenCompose + 1; if (lenReference) { DmWrite(ftrBuf, offset, pszReference, lenReference); } FasRequestSearch(appFileCreator); }
/* Create new item in app database */ static UInt16 DoTheBoogie(KleenexPtr kleenexP, DmOpenRef dbR, UInt16 *index) { MemHandle hnd; MemPtr recordP; UInt16 strLen; *index = dmMaxRecordIndex; if (!(hnd = DmNewRecord(dbR, index, 3360))) return (1); recordP = MemHandleLock(hnd); DmWrite(recordP, 0, kleenexP->data, 3200); DmSet(recordP, 3200, 160, 0); if ((strLen = StrLen(kleenexP->text)) > 31) strLen = 31; DmWrite(recordP, 3200, kleenexP->text, strLen); MemHandleUnlock(hnd); DmReleaseRecord(dbR, *index, true); return (errNone); }