void fastPoll( void ) { RANDOM_STATE randomState; BYTE buffer[ RANDOM_BUFSIZE + 8 ]; WinHandle winHandle; Coord xCoord, yCoord; Boolean flag; uint64_t ticks; nsecs_t nsTime; initRandomData( randomState, buffer, RANDOM_BUFSIZE ); /* Get the event-available and low-level event-available flag, current pen status, and handle of the window with the input focus */ flag = EvtEventAvail(); addRandomValue( randomState, flag ); flag = EvtSysEventAvail( TRUE ); addRandomValue( randomState, flag ); EvtGetPen( &xCoord, &yCoord, &flag ); addRandomValue( randomState, xCoord ); addRandomValue( randomState, yCoord ); winHandle = EvtGetFocusWindow(); addRandomValue( randomState, winHandle ); /* Get the number of ticks of the (software) millisecond clock used by the scheduler, and the length of time in nanoseconds since the last reset */ ticks = TimGetTicks(); addRandomData( randomState, &ticks, sizeof( uint64_t ) ); nsTime = SysGetRunTime(); addRandomData( randomState, &nsTime, sizeof( nsecs_t ) ); /* Get the value of the real-time and runtime clocks in nanoseconds. One of these may just be a wrapper for SysGetRunTime(), in addition it's likely that they're hardware-specific, being CPU-level cycle counters of some kind */ nsTime = system_real_time(); addRandomData( randomState, &nsTime, sizeof( nsecs_t ) ); nsTime = system_time(); addRandomData( randomState, &nsTime, sizeof( nsecs_t ) ); /* Flush any remaining data through */ endRandomData( randomState, 5 ); }
/*------------------------------------------------------CIRexxApp::FindLaunch-+ | | +----------------------------------------------------------------------------*/ Err CIRexxApp::FindLaunch(FindParamsPtr pFindParams) { //<<<JAL TODO: This is currently dependent on the Rexx category. // I'm not sure if we'll ever need to change/add-to this, // but if we do, then this code will have to be changed // along with the GoTo command. Err err; LocalID dbID; UInt16 cardNo = 0; DmOpenRef dbP; DmSearchStateType searchState; UInt16 recordNum; MemHandle hRecord; UInt32 pos; UInt16 matchLength; Boolean match, full; RectangleType r; UInt32 type; UInt32 creator; // Open our database (should we search MemoPad and pedit, too?) // and do our Find. We define the semantics of Find, so // instead of searching the whole records for the search string, // let's just search for scripts with the search string as their "name." if (FindDrawHeader(pFindParams, "Rexx Scripts")) { goto m_return; } if ((err = DmGetNextDatabaseByTypeCreator( true, &searchState, 'data', CREATORID, true, &cardNo, &dbID)) != errNone) { pFindParams->more = false; return errNone; } if ((err = DmDatabaseInfo(0, dbID, 0, 0, 0, 0, 0, 0, 0, 0, 0, &type, &creator)) != errNone || (type != 'data' && creator != CREATORID)) { pFindParams->more = false; return errNone; } if ((dbP = DmOpenDatabase(cardNo, dbID, pFindParams->dbAccesMode)) == 0 || DmGetAppInfoID(dbP) == 0) { /* if categories not initialized then CategoryGetName throws fatal error */ pFindParams->more = false; return errNone; } UInt16 category; char categoryName[dmCategoryLength]; for (category = 0; category < dmRecNumCategories; ++category) { CategoryGetName(dbP, category, categoryName); if (!StrCaselessCompare(categoryName, "REXX")) { break; } } if (category == dmRecNumCategories) { goto m_return; } // set it to dmAllCategories? UInt32 romVersion; FtrGet(sysFtrCreator, sysFtrNumROMVersion, &romVersion); full = false; recordNum = pFindParams->recordNum; while (true) { // Because applications can take a long time to finish a Find when // the result may already be on the screen, or for other reasons, // users like to be able to stop the Find. So, stop it if any event // is pending, i.e., if the user does something with the device. // Because actually checking if an event is pending slows the // search itself, just check it every so many records. if ((recordNum & 0x000f) == 0 && EvtSysEventAvail(true)) { pFindParams->more = true; break; } if (!(hRecord = DmQueryNextInCategory(dbP, &recordNum, category))) { pFindParams->more = false; break; } Char * p = (char *)MemHandleLock(hRecord); UInt32 isInternational; err = FtrGet(sysFtrCreator, sysFtrNumIntlMgr, &isInternational); if (err == errNone && isInternational) { match = TxtFindString(p, pFindParams->strToFind, &pos, &matchLength); } else { match = TxtGlueFindString(p, pFindParams->strToFind, &pos, &matchLength); } if (match) { // Add the match to the find paramter block. // If there is no room to display the match // then the following function will return true. full = FindSaveMatch(pFindParams, recordNum, (UInt16)pos, 0, 0, cardNo, dbID); if (!full) { // Get the bounds of the region where we will draw the results, and // display the title of the description neatly in that area. FindGetLineBounds(pFindParams, &r); Int16 x = r.topLeft.x + 1; Int16 y = r.topLeft.y; Int16 w = r.extent.x - 2; Char * cr = StrChr(p, linefeedChr); UInt16 titleLen = (cr == 0)? StrLen(p) : cr - p; Int16 fntWidthToOffset; if (romVersion >= sysMakeROMVersion(3, 1, 0, sysROMStageRelease, 0)) { fntWidthToOffset = FntWidthToOffset(p, titleLen, w, 0, 0); } else { fntWidthToOffset = FntGlueWidthToOffset(p, titleLen, w, 0, 0); } if (fntWidthToOffset == titleLen) { WinDrawChars(p, titleLen, x, y); } else { Int16 titleWidth; titleLen = FntWidthToOffset(p, titleLen, w - FntCharWidth(chrEllipsis), 0, &titleWidth); WinDrawChars(p, titleLen, x, y); WinDrawChar (chrEllipsis, x + titleWidth, y); } ++pFindParams->lineNumber; } } MemHandleUnlock(hRecord); if (full) { break; } ++recordNum; } m_return: DmCloseDatabase(dbP); return errNone; }