/***********************************************************************
 *
 * FUNCTION:    MainFormInit
 *
 * DESCRIPTION: This routine initializes the MainForm form.
 *
 * PARAMETERS:  frm - pointer to the MainForm form.
 *
 * RETURNED:    nothing
 *
 * REVISION HISTORY:
 *
 *
 ***********************************************************************/
static void MainFormInit(FormPtr frmP)
{
	FieldPtr			fld;
	char *ptr;
   	MemHandle			mh = MemHandleNew (10);
	fld = GetObjectPtr (MainSymbolField);
	ptr = MemHandleLock (mh);
	strcpy(ptr,"IBM");
	FldSetTextHandle (fld, mh);
    MemHandleUnlock(mh);
}
示例#2
0
static UInt16 ConvertBookmarksForRecord
         (
         UInt16        recordId,
         UInt8*        bookmarkPtr,
         OldBookmarkData* dataPtr,
         UInt16        entries,
         Boolean*      done
         )
{
     UInt16    i;
     Header*   record = NULL;
     MemHandle handle = NULL;
     Boolean   success = true;

     for ( i = 0 ; i < entries ; i++ ) {
          if ( dataPtr->recordId == recordId ) {
              AnnotationEntry e;

              if ( handle == NULL ) {
                  handle = ReturnRecordHandle( recordId );

                  if ( handle == NULL )
                      return false;

                  record = MemHandleLock( handle );
              }
              MemSet( &e, sizeof( AnnotationEntry ), 0 );

              e.flags = ANNOTATION_BOOKMARK | ANNOTATION_HIDDEN;

              e.triggerStart = dataPtr->characterPosition;
              e.triggerStop  = dataPtr->characterPosition;

              e.id.uid              = dataPtr->recordId;

              e.id.paragraphNum     = GetParagraphNumber( record, e.triggerStart );
              e.id.indexInParagraph = NEW_ANNOTATION;

              success = AddAnnotation( &e, bookmarkPtr ) && success;

              done[ i ] = true;
          }

          bookmarkPtr    += StrLen( bookmarkPtr ) + 1;
          dataPtr++;
     }

     if ( handle != NULL ) {
         MemHandleUnlock( handle );
         FreeRecordHandle( &handle );
     }

     return success;
}
示例#3
0
// Open preferences database and find a record that contains preferences.
// Return errNone if opened succesfully, otherwise an error:
//   psErrNoPrefDatabase - pref database couldn't be found
// devnote: it scans through all records even though we only store preferences
// in one record because I want to be able to use preferences database used
// in earlier versions of Noah Pro/Thes.
Err PrefsStoreReader::ErrOpenPrefsDatabase()
{
    if (_db)
    {
        Assert(_recHandle);
        Assert(_recData);
        return errNone;
    }

    // we already tried to open the database but couldn't, so don't try again
    if (_fDbNotFound)
        return psErrNoPrefDatabase;

    LocalID dbId;
    Err err = ErrFindDatabaseByNameTypeCreator(_dbName, _dbType, _dbCreator, &dbId);
    if (dmErrCantFind==err)
    {
        err = psErrNoPrefDatabase;
        goto ExitAndMarkNotFound;
    }
    if (err)
        goto ExitAndMarkNotFound;
    Assert(0!=dbId);

    _db = DmOpenDatabase(0, dbId, dmModeReadWrite);
    if (!_db)
    {
        err = DmGetLastErr();
        Assert(err);
        goto ExitAndMarkNotFound;
    }

    UInt16 recsCount = DmNumRecords(_db);
    for (UInt16 recNo = 0; recNo < recsCount; recNo++)
    {
        _recHandle = DmQueryRecord(_db, recNo);
        _recData = (unsigned char*)MemHandleLock(_recHandle);
        if ( (MemHandleSize(_recHandle)>=4) && FValidPrefsStoreRecord(_recData) )
        {
            // we found the record with prefernces so remember _recData and _recHandle
            // those must be freed in destructor
            return errNone;
        }
        MemHandleUnlock(_recHandle);
        _recHandle = NULL;
    }

    DmCloseDatabase(_db);
    _db = 0;
    err = psErrNoPrefDatabase;
ExitAndMarkNotFound:
    _fDbNotFound = true;
    return err;
}
示例#4
0
文件: clist.c 项目: timn/unimatrix
/*****************************************************************************
* Function: DrawCourses
*
* Description: local function to fill the course list
*****************************************************************************/
static void
DrawCourses(ListType *lst)
{
  MemHandle mWebsite, mEmail, old;
  Char *buffer;
  FieldType *fldWebsite, *fldEmail;
  
  gNumCourses=CountCourses();
  gCourseList = (Char **) MemPtrNew(gNumCourses * sizeof(Char *));
  gCourseInd = (UInt16 *) MemPtrNew(gNumCourses * sizeof(UInt16));

  CourseListGen(gCourseList, NULL, gCourseInd, gNumCourses, 0, CLIST_SEARCH_INDEX);
  LstSetListChoices(lst, gCourseList, gNumCourses);
  LstSetSelection(lst, -1);

  
  fldWebsite = GetObjectPtr(FIELD_cl_website);
  fldEmail = GetObjectPtr(FIELD_cl_email);
  
  mWebsite = MemHandleNew(4);
  buffer = MemHandleLock(mWebsite);
  MemSet(buffer, 4, 0);
  StrCopy(buffer, "-?-");
  MemHandleUnlock(mWebsite);

  old = FldGetTextHandle(fldWebsite);
  FldSetTextHandle(fldWebsite, mWebsite);
  if (old != NULL)  MemHandleFree(old); 

  mEmail = MemHandleNew(4);
  buffer = MemHandleLock(mEmail);
  MemSet(buffer, 4, 0);
  StrCopy(buffer, "-?-");
  MemHandleUnlock(mEmail);

  old = FldGetTextHandle(fldEmail);
  FldSetTextHandle(fldEmail, mEmail);
  if (old != NULL)  MemHandleFree(old); 

  
}
示例#5
0
/* Return info for last openned document */
DocumentInfo* GetLastDocInfo( void )
{
    DocumentInfo* docInfo;

    docInfo = NULL;

    if ( plkrDocList == NULL ) {
        plkrDocList = DmOpenDatabaseByTypeCreator( PlkrDocListType, ViewerAppID,
                        dmModeReadWrite );
    }
    if ( plkrDocList != NULL ) {
        DocumentData*   recordPtr;
        MemHandle       handle;

        ErrTry {
            /* assign doc info values for document */
            handle = FindDocData( Prefs()->docName, ALL_ELEMENTS, NULL );
            if ( handle != NULL ) {
                recordPtr = MemHandleLock( handle );

                StrNCopy( lastDocInfo.name, recordPtr->name, dmDBNameLength );
                lastDocInfo.cardNo      = recordPtr->cardNo;
                lastDocInfo.created     = recordPtr->created;
                lastDocInfo.attributes  = recordPtr->attributes;
                lastDocInfo.size        = recordPtr->size;
                lastDocInfo.categories  = recordPtr->categories;
                lastDocInfo.location    = recordPtr->location;
                lastDocInfo.timestamp   = recordPtr->timestamp;
                if ( lastDocInfo.location != RAM ) {
                    UInt16 fileLength;

                    ReleaseLastDocInfo();

                    fileLength              = StrLen( recordPtr->data ) + 1;
                    lastDocInfo.filename    = SafeMemPtrNew( fileLength );
                    StrNCopy( lastDocInfo.filename, recordPtr->data,
                        fileLength );
                    lastDocInfo.volumeRef   = FindVolRefNum( recordPtr->data +
                                                             fileLength );
                }
                MemHandleUnlock( handle );
                CloseRecord( handle, false );

                CloseDocList();

                docInfo = &lastDocInfo;
            }
        }
        ErrCatch( UNUSED_PARAM( err ) ) {
        } ErrEndCatch

        CloseDocList();
    }
示例#6
0
文件: helper.c 项目: teras/FEdit
void SetFieldFromInt ( UInt16 fieldID, int data ) {
	
	/* Temporary place in heap in order to store the string data */
	MemHandle txtH;
	
	txtH = MemHandleNew ( 10 );
	if ( !txtH) return;

	StrPrintF ( MemHandleLock(txtH), "%i", data);
	SetFieldFromHandle ( fieldID, txtH);
	MemHandleUnlock (txtH);

}
示例#7
0
 /*Returns the File record associated to an vfs fileRef */
Int32 GetFileProperties (FileRef fileRef, file_rec_t* axxFileRec)
{
    Int16 i;
    file_rec_t* axxFileList;

    i = GetFilePos((Int16)fileRef) ;
    if (i == -1)
        return expErrNotOpen;    
    axxFileList = MemHandleLock(axxFileListHandle);
    MemMove (axxFileRec, &axxFileList[i],sizeof(file_rec_t));    
    MemHandleUnlock(axxFileListHandle);
    return errNone;
}
示例#8
0
/********************************************************************
 * Function: addRecord
 * Description:  function responsible for writing a packed System record
 * to the database. 
 * ******************************************************************/ 
void writeRecord (MemPtr record, MemHandle recordDBrec) {
	UInt16 length = 0, offset = 0;
	Char *ch;
	
	/* get length of the system buffer */
	length = MemPtrSize (record);
	
	/* re-size and write. */
	if (MemHandleResize (recordDBrec, length) == 0) {
		ch = MemHandleLock (recordDBrec);
		DmWrite (ch, offset, record, length);
		MemHandleUnlock (recordDBrec);
	}
}
示例#9
0
文件: lowlevel.c 项目: docwhat/cwimp
/* SetFieldTextFromStr -- Fills a field with a string
 * Args:    
 *     Word     fieldID  -- ID of field to fill, see cwimp.rpc file
 *     CharPtr  strP     -- String to fill ID with
 * Returns:
 *     FieldPtr          -- Ptr to the field set.
 */
FieldPtr SetFieldTextFromStr(Word fieldID, CharPtr strP)
{
  VoidHand txtH;
  
  txtH = MemHandleNew(StrLen(strP) + 1);
  if(!txtH) return NULL;
  
  StrCopy(MemHandleLock(txtH), strP);
  
  // ToDo: SetFieldTextFromHandle should happen *before* unlock
  MemHandleUnlock(txtH);
  
  return SetFieldTextFromHandle(fieldID, txtH);
}
示例#10
0
void Graphics::drawBitmap(uint_t bitmapId, const Point& topLeft)
{
    MemHandle handle=DmGet1Resource(bitmapRsc, bitmapId);
    if (handle) 
    {
        BitmapType* bmp=static_cast<BitmapType*>(MemHandleLock(handle));
        if (bmp) 
        {
            WinDrawBitmap(bmp, topLeft.x, topLeft.y);
            MemHandleUnlock(handle);
        }
        DmReleaseResource(handle);
    }
}
示例#11
0
void String_Done()
{
	MemHandle *i;
	context* p = Context();

	StringFree();

	for (i=ARRAYBEGIN(p->StrModule,MemHandle);i!=ARRAYEND(p->StrModule,MemHandle);++i)
	{
		MemHandleUnlock(*i);
		DmReleaseResource(*i);
	}
	ArrayClear(&p->StrModule);
}
示例#12
0
文件: scdir.c 项目: 12019/scez-ng
int AppendField( FieldPtr fld, CharPtr str, UInt len )
{
	Err err=0;
	CharPtr  s;
	VoidHand h;
	UInt prevlen;

	h=(VoidHand)FldGetTextHandle(fld);

	if(h==NULL) {
		h=MemHandleNew(len+1);
		if(h==NULL) return(-1);
		s=MemHandleLock(h);
		StrNCopy(s, str, len);
		s[len]=0;
		MemHandleUnlock(h);
	} else {
		prevlen=FldGetTextLength(fld);

		FldSetTextHandle(fld, NULL);

		if( MemHandleSize(h)<=(prevlen+len)) {
			err=MemHandleResize( h, prevlen+len+1 );
		}
		if( err!=0 ) return(-1);

		s=MemHandleLock(h);
		StrNCopy(s+prevlen, str, len);
		s[len+prevlen]=0;
		MemHandleUnlock(h);
	}

	FldSetTextHandle(fld, (Handle)h);
	/* FldDrawField(fld); */

	return( 0 );
}
示例#13
0
文件: gadget.c 项目: timn/unimatrix
/*****************************************************************************
* Function: GadgetDrawWeekdays
*
* Description: Draws the weekdays, extra function since called in
*              GadgetDrawTimeline
*****************************************************************************/
void
GadgetDrawWeekdays(void)
{
  UInt8 i;
  MemHandle mh;
  Char *text;
  RGBColorType color, prevColor;
  DateTimeType now;
  Int16 dow;
  RectangleType bounds, rect;
  UInt16 gadgetIndex;

  // Get info about Gadget
  gadgetIndex = FrmGetObjectIndex(gForm, gGadgetID);
  FrmGetObjectBounds(gForm, gadgetIndex, &bounds);

  // Initialize time constants
  TimSecondsToDateTime(TimGetSeconds(), &now);
  dow = DayOfWeek(now.month, now.day, now.year);
  
  RctSetRectangle(&rect, bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT, bounds.topLeft.y,
                         130, FntLineHeight()+2);

  // Erase background
  WinEraseRectangle(&rect, 0);

  for (i=0; i < gGadgetDaysNum; ++i) {
    Int16 leftoff;
    mh = DmGetResource(strRsc, GADGET_STRINGS_WDAYSTART+i);
    text = MemHandleLock(mh);
    leftoff = (gGadgetDaysWidth+2 - FntLineWidth(text, MemPtrSize(text))) / 2;
    if (TNisColored() && (dow == i+1)) {
      color.r = 0xFF;  color.g = 0x00;  color.b = 0x00;
      TNSetTextColorRGB(&color, &prevColor);
    }
    WinDrawChars(text, StrLen(text), bounds.topLeft.x+GADGET_BASELEFT+GADGET_LEFT+i*gGadgetDaysWidth+i+leftoff+2, bounds.topLeft.y);
    if (dow == i+1) {
      if (TNisColored()) {
        TNSetTextColorRGB(&prevColor, NULL);
      } else {
        // Draw some kind of underline to determine current day
        Int16 lineWidth=FntLineWidth(text, StrLen(text));
        WinDrawLine(rect.topLeft.x+i*gGadgetDaysWidth+i+leftoff+1, rect.topLeft.y+FntLineHeight(),
                    rect.topLeft.x+i*gGadgetDaysWidth+i+leftoff+1+lineWidth, rect.topLeft.y+FntLineHeight());
      }
    }
    MemHandleUnlock(mh);
  }
}
示例#14
0
文件: clist.c 项目: timn/unimatrix
Boolean
CourseGetIndex(DmOpenRef cats, UInt16 category, UInt16 courseID, UInt16 *index)
{
  MemHandle m;

  *index = 0;
  
  while ((m = DmQueryNextInCategory(cats, index, category)) != NULL) {
    Char *s=(Char *)MemHandleLock(m);
    if (s[0] == TYPE_COURSE) {
      CourseDBRecord c;
      UnpackCourse(&c, s);
      if (c.id == courseID) {
        // Found it!
        MemHandleUnlock(m);
        return true;
      }
    }
    MemHandleUnlock(m);
    *index += 1;
  }

  return false;
}
示例#15
0
/**************************************************************************
 * Function: getSystemFromIndex
 * Description: based upon a system database index, this will locate the
 * system for that index, unpack and decrypt it and initialize s
 * ************************************************************************/ 
void getSystemFromIndex (DmOpenRef SystemDB, md_hash * SysPass, UInt16 index, MemHandle tmp, System * s) {
	MemHandle rec = DmQueryRecord (SystemDB, index);
	if (rec) {
		MemPtr scratch, buff = MemHandleLock (rec);
		
			/*	resize the buffer */
		if (MemHandleResize (tmp, MemPtrSize (buff)) == 0) {
			scratch = MemHandleLock (tmp);
			
			/*	unpack and decrypt the account */
			UnpackSystem (s, buff, scratch, SysPass, MemHandleSize (rec), true); 
		}
		MemHandleUnlock (rec);
	}
}
示例#16
0
文件: exams.c 项目: timn/unimatrix
static void
ExamBeam(void)
{
  MemHandle mex;
  ExamDBRecord *ex;
  UInt16 index=0;

  DmFindRecordByID(DatabaseGetRefN(DB_MAIN), gExamsLastSelRowUID, &index);
  mex = DmQueryRecord(DatabaseGetRefN(DB_MAIN), index);
  ex = (ExamDBRecord *)MemHandleLock(mex);

  MemHandleUnlock(mex);

  BeamCourseByCID(ex->course);
}
示例#17
0
文件: clist.c 项目: timn/unimatrix
/*****************************************************************************
* Function:  CountCourses
*
* Description: Counts the courses saved in the given current category.
* Assumptions: This functions assumes, that the Records are SORTED with the
*              courses first and then the times.
*****************************************************************************/
UInt16
CountCourses(void)
{
  MemHandle m;
  UInt16 index=0,count=0;

  while ((m = DmQueryNextInCategory(DatabaseGetRefN(DB_MAIN), &index, DatabaseGetCat()))) {
    Char *s = MemHandleLock(m);
    if (s[0] == TYPE_COURSE) count += 1;
    MemHandleUnlock(m);
    index += 1;
  }

  return count;
}
示例#18
0
/*
** Initiates transfer mode.
*/
void StartXferMode(void) {
  FormType* frm = FrmGetActiveForm();
  FieldType* fld =  GetObjectPointer(frm, XferField);
  const UInt32 len = MemHandleSize(d.record_name);
  MemHandle textH = MemHandleNew(len);

  ASSERT(textH);

  FlushToBuffer();
  FrmSetMenu(frm, XferMenu);
  d.is_xfer_mode = true;
  ToggleButtonBar(frm, false);
  ResetDrawingAreaRectangle(p.formID == DiddleTForm, true);
  FrmUpdateForm(p.formID, 0);
  InitXferList();
  ToggleXferBar(frm, true);
  FrmSetFocus(frm, FrmGetObjectIndex(frm, XferField));

  /* Init field with record title */
  MemMove(MemHandleLock(textH), MemHandleLock(d.record_name), len);
  MemHandleUnlock(textH);
  MemHandleUnlock(d.record_name);
  FldSetTextHandle(fld, textH);
}
示例#19
0
/**
 * FUNCTION: smUnlock
 *
 * Free pointer mapped to memH memory block.
 *
 * PRE-Condition:   memH is a valid handle; memory block is locked
 *
 * POST-Condition:  memory block is unlocked
 *
 * IN:      memH
 *          Handle to memory block
 *
 * RETURN:  SML_ERR_OK, if O.K.
 *          SML_ERR_WRONG_PARAM, if memH is unknown
 *          SML_ERR_WRONG_USAGE, if memH was already unlocked
 *          SML_ERR_UNSPECIFIC, if unlock failed
 *
 * @see  smLock
 */
Ret_t smUnlock (MemHandle_t memH) {

  if ( memH != smMemH ) {
    return SML_ERR_WRONG_PARAM;
  }
  if ( ! smLocked ) {
    return SML_ERR_WRONG_USAGE;
  }

  if ( MemHandleUnlock((VoidHand)smPalmH) != 0 ) {
    return SML_ERR_UNSPECIFIC;
  }
  smLocked = 0;

  return SML_ERR_OK;
}
示例#20
0
// Function loads a resource with specified name
resource_p resourceLoad(const char* name)
{
    resource_p resource = NULL;
    MemHandle handle = NULL;

    ASSERT(NULL != name, "resourceLoad");

    resource = resourceFind(name);
    if (NULL == resource) {
        handle = resourceOpen(name);
        if (NULL == handle) {
            THROW("resourceLoad",
                  appErrResourceNotFound);
        }

        TRY
        {
            resource = (resource_p)objectCreate(
                sizeof(*resource),
                (destructor_f)resourceDestroy);

            resource->handle = handle;
            resource->memory
                = (const void*)MemHandleLock(
                    handle);
            resource->size
                = MemHandleSize(handle);

            if (NULL != resourcesList) {
                resource->prev = NULL;
                resource->next = resourcesList;
                resourcesList->prev = resource;
            }

            resourcesList = resource;

            resource = resourceRetain(resource);
        }
        CATCH
        {
            MemHandleUnlock(handle);
            RETHROW();
        }
        END;

        resource = resourceAutorelease(resource);
    }
示例#21
0
/**************************************************************************
 * Function: getAccountFromIndex
 * Description: based upon an account index, this will locate the
 * account for that index, unpack and decrypt it and initialize acc
 * ************************************************************************/ 
void getAccountFromIndex (DmOpenRef AccountDB, md_hash * SysPass, UInt16 index, MemHandle tmp, Account * acc) {
	/*	query the record from the database */
	MemHandle rec = DmQueryRecord (AccountDB, index);
	
	if (rec){
		MemPtr scratch, buff = MemHandleLock (rec);
		
		/*	resize buffer */
		if (MemHandleResize (tmp, MemPtrSize (buff)) == 0) {
			scratch = MemHandleLock (tmp);
			
			/*	unpack the account */
			UnpackAccount (acc, buff, scratch, SysPass, MemHandleSize (rec), true, true);
		}
		MemHandleUnlock (rec);
	}
}
示例#22
0
// Write the header
void WriteHeader(void) {
  MemHandle headerMH = NULL;
  MemPtr headerMP = NULL;

  headerMH = DmGetRecord(JMPalmPrefs, 0);

  if (headerMH != NULL)
    headerMP = MemHandleLock(headerMH);

  // write new data
  if (headerMH != NULL) {
    //hd.record_count = record_count;
    DmWrite(headerMP, 0, &hd, sizeof(hd));
    MemHandleUnlock(headerMH);
    DmReleaseRecord(JMPalmPrefs, 0, true);
  }
}
示例#23
0
/* Restore data for current record from history */
static void RestoreData( void )
{
    MetaRecord* meta;
    MemHandle   handle;
    UInt16      recordId;

    recordId    = history.records[ history.currentRecord ].recordId;
    handle      = GetMetaHandle( recordId, false );
    meta        = MemHandleLock( handle );

    DmWrite( meta, OFFSETOF( MetaRecord, verticalOffset ),
        &history.records[ history.currentRecord ],
        sizeof( HistoryData ) - sizeof( Int16 ) );

    MemHandleUnlock( handle );
    CloseRecord( handle, true );
}
示例#24
0
static Int16 LoadIcon(Int16 start)
{
	FormPtr     frmP = FrmGetActiveForm();
	Int8	    i;
    Int16       num;
    Int16       iconButtonID = IconSelectIcon1Button;
    BitmapPtr   pbmp;
    MemHandle   h;
    Int16       x, y;
    RectangleType r;

    num = DmNumResources(IconDB);
    if (start > num) start = 0;
    
	for (i = 0; i < 9*8; i++) {
        UInt16 idx = FrmGetObjectIndex(frmP, iconButtonID + i);

        FrmGetObjectPosition(frmP, idx, &x, &y);
        FrmGetObjectBounds(frmP, idx, &r);

        r.topLeft.x = x;
        r.topLeft.y = y;

        WinEraseRectangle(&r, 0);

        if (i+start <num) {
            h = (MemPtr)GetIconByIndex(IconDB, i + start);
            pbmp = (h) ? MemHandleLock(h) : NULL;

            if (pbmp) {
                WinDrawBitmap(pbmp, x, y);
                                
                MemHandleUnlock(h);
                DmReleaseResource(h);
                ShowObject(frmP, iconButtonID + i);
            }
            else {
                HideObject(frmP, iconButtonID + i);
            }
        }
        else {
            HideObject(frmP, iconButtonID + i);
        }
	}
    return num;
}
示例#25
0
文件: ai.c 项目: geoffmacd/Allied-Ace
void removeAI(UInt8 aiNum)
{
	PlayerStruct playerTemp[game.numPlayersOnScreen - 1];	 	
	UInt16 i;
	Err err;
	
	if(game.numPlayersOnScreen < 1)
	{
		ErrDisplay("In removeAI(), there are no players to remove");
	}		
	
	//move all player data to temp var:
	for(i = 0; i < aiNum; i++)
	{
		//move each player until one to delete appears
		playerTemp[i] = player[i];
	}
	for(i = aiNum + 1; i < game.numPlayersOnScreen; i++)
	{
		//move each player until end
		playerTemp[i - 1] = player[i];		
	}	
	
	//players are in place and top player is useless, can now resize
	game.numPlayersOnScreen--;	
	//resize to the number of players
	err = MemHandleResize(playerH, sizeof(PlayerStruct) * (game.numPlayersOnScreen));
	if(err == memErrChunkLocked)
	{
		//unlock
		MemHandleUnlock(playerH);
		if(err = MemHandleResize(playerH, sizeof(PlayerStruct) * game.numPlayersOnScreen))
		{	
			ErrFatalDisplay("In removeAI, couldn't resize player stack");
		}
		player = (PlayerStruct *)MemHandleLock(playerH);		 
	}		
	else if(err != errNone)
	{
		//some other error
		ErrFatalDisplay("In removeAI, couldn't resize player stack");	
	} 
	//copy orginal back to stack
	MemMove(player, (PlayerStruct *)&playerTemp, sizeof(PlayerStruct) * game.numPlayersOnScreen);	
}
示例#26
0
/* Send a goto event for internal bookmark */
void SendBookmarkGoToEvent
     (
     BookmarkListEntry* listEntry,
     Boolean            returnToForm
     )
{
    AnnotationEntry e;
    UInt16         offset;
    Header*        header;
    MemHandle      handle;
    EventType      match;

    if ( ! GetAnnotationHeaderByRecordNum( &e,
              listEntry->recordNum ) )
        return;

    handle = ReturnRecordHandle( e.id.uid );

    if ( handle == NULL )
        return;

    header = MemHandleLock( handle );

    offset = e.triggerStart +
                 GetParagraphOffset( header,
                     GET_PARAGRAPH( header, e.id.paragraphNum ) );

    MemHandleUnlock( handle );
    FreeRecordHandle( &handle );

    if ( returnToForm )
        FrmReturnToForm( GetMainFormId() );

    MemSet( &match, sizeof( EventType ), 0 );

    match.eType                         = frmGotoEvent;
    match.data.frmGoto.formID           = GetMainFormId();
    match.data.frmGoto.recordNum        =
                e.id.uid;
    match.data.frmGoto.matchPos         =
                offset;
    match.data.frmGoto.matchCustom      = GOTO_BOOKMARK;

    EvtAddEventToQueue( &match );
}
示例#27
0
// Read the header data
UInt16 ReadHeader(void) {
  UInt16 err;
  MemHandle headerMH = NULL;
  MemPtr    headerMP = NULL;
  headerdata* foo;

  err = false;

  headerMH = DmGetRecord(JMPalmPrefs, 0);
  
  if (headerMH != NULL)
    headerMP = MemHandleLock(headerMH);

  foo = (headerdata*)headerMP;

  // copy the object
  if (foo != NULL) {
    memcpy(&hd, foo, sizeof(headerdata));

    // Header version incompatible?
    if (hd.version <= INCOMPATIBILITY_LEVEL) { 
      FrmCustomAlert(ErrorMessageForm, "Installation error: You must"\
		     " delete old JMPalm versions before installing"\
		     " this version. Please delete and reinstall.",
		     0, 0);
      err = true;
    }
    else if (hd.version < CURRENT_SETTINGS_VERSION) {
      FrmCustomAlert(ErrorMessageForm, "New (incompatible) version of "\
		     "JMPalm installed, "\
		     "your settings are lost!", 0, 0);
      drawSplash();
      ResetHeader();
    }
  }

  if (headerMH != NULL) {
    MemHandleUnlock(headerMH);
    DmReleaseRecord(JMPalmPrefs, 0, true);
  }

  return err;
}
示例#28
0
/*
** Initializes the transfer group structures.
*/
static void InitXferList(void) {
  SysDBListItemType* pluglistP = NULL;
  Char str[48];
  FormType* frm = FrmGetActiveForm();
  Int16 i = 0;
  Int16 width = 0;
  Int16 n = 0;

  /* Return if we've already initialized the plugin list */
  if (d.xfer.pluglistH) 
    return;

  /* Return if there are no plugins */
  if (!SysCreateDataBaseList('BooG', 0, &d.xfer.num_plugs,
			     &d.xfer.pluglistH, true)) {
    /* No databases found */
    d.xfer.pluglistH = NULL;
    d.xfer.num_plugs = 0;
    return;
  }

  /* This will unset the p.xfer_current_plug if it has been deleted */
  GetCurrentXferAppListIndex();
  /* Update the plug button */
  DrawPlugButton((DynamicButtonType*)FrmGetGadgetData(frm, FrmGetObjectIndex(frm, XferDetailsButton)));
  /* Update XferDone button */
  DrawXferDoneButton((DynamicButtonType*)FrmGetGadgetData(frm, FrmGetObjectIndex(frm, XferDoneButton)));

  /* Find the menu width and set it */
  pluglistP = MemHandleLock(d.xfer.pluglistH);
  for (; i < d.xfer.num_plugs; i++) {
    GetPlugString(i, boogerID_plugname, str);
    n = FntCharsWidth(str, StrLen(str));

    if ((pluglistP[i].version) & (IBVERSION_ORIG|IBVERSION_PICTURE))
      width = Max(width, n);
  }

  d.xfer.plug_menu_width = width + 25;

  /* Clean up */
  MemHandleUnlock(d.xfer.pluglistH);
}
示例#29
0
文件: IRexxApp.cpp 项目: Jaxo/yaxx
/*-------------------------------------CIRexxApp::copyScriptFromIndexDatabase-+
|                                                                             |
+----------------------------------------------------------------------------*/
void CIRexxApp::copyScriptFromIndexDatabase(Int16 index)
{
   Int16 count;
   UInt32 dbptr;
   ScriptRecord sr;
   CDBStream dbs(m_scriptIndexDB->QueryRecord(index));   
   dbs >> sr.m_title;
   dbs >> sr.m_dbi;
   dbs >> dbptr;
   sr.m_db = (CDatabase *)dbptr;
   dbs >> count;
   sr.m_indexes.EnsureSize(count);
   sr.m_segments.EnsureSize(count);
   for (int i = 0; i < count; ++i) {
      Int16 value1, value2;
      dbs >> value1 >> value2;
      sr.m_indexes.Insert(i, value1);
      sr.m_segments.Insert(i, value2);
   }

   emptyScript();
   bool isSegmented = count > 1;
   for (Int16 i = 0; i < count; ++i) {
      MemHandle hMem = sr.m_db->QueryRecord(sr.m_indexes[i]);
      char * script = (char *)MemHandleLock(hMem);
      UInt32 size = MemHandleSize(hMem);
      if (isSegmented) {
         char * realScript = strstr(
            script, "!DO NOT TOUCH THIS LINE OR ABOVE!"
         );
         if (realScript) {
            realScript += 34;
            size -= (realScript - script);
            script = realScript;
         }
      }
      if (script[size - 1] == '\0') { --size; }
      appendScript(script, size);
      MemHandleUnlock(hMem);
   }
   return;
}
示例#30
0
文件: helper.c 项目: teras/FEdit
void setFieldFromStr ( UInt16 fieldID, Char * strP ) 
{
	/* Temporary place in heap in order to store the string data */
	MemHandle txtH;

	/* Create new heap space */
	txtH = MemHandleNew ( StrLen (strP) + 1 ) ;
	if ( !txtH )
		return;

	/* Copy string to the heap, in order to be useful */
	StrCopy (MemHandleLock(txtH), strP);	/* Lock the current memory position, in order to accomply the specified task of setting text */
	
	/* Set text of field to the selected  heap data */
	SetFieldFromHandle (fieldID, txtH);
	
	/* Free lock for this (text) item */
	MemHandleUnlock(txtH);
	return;
}