⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 palmdesktopdatabase.c

📁 CD_高级PALM编程
💻 C
字号:
/********************************************************************* FILE:				PalmDesktopDatabase.c** DESCRIPTION:		Provides the interfaces necessary to access *                   databases created by the PalmDatabaseBuilder.*** VERSION:		1.0**********************************************************************/#include <PalmOS.h>#include "PalmDesktopDatabase.h"const int pddbCategoryAppInfoLength = sizeof( AppInfoType );typedef struct _pddbRecord{	UInt32 type;	// data follows!} PddbRecordType, *PddbRecordTypePtr;typedef struct _pddbAppInfo{	UInt16	flags;	UInt16	reserved;	// data follows!} PddbAppInfoType, *PddbAppInfoPtr;static UInt16 PrvPddbAppInfoRecordFlags( DmOpenRef );/*********************************************************************** * FUNCTION:    	PddbAppInfoRecord * * DESCRIPTION: 	This routine replaces the MemHandleLock used when  *                  accessing the appInfo block for reading.  This routine *                  provides a pointer to the appInfo data and the flags. * * RETURNED:    	A pointer to the record or NULL. Caller must free this. ***********************************************************************/MemPtr PddbAppInfoRecord(	DmOpenRef dbRef,		// (in) database owning this record.	UInt16 *flagsP			// (in) pointer of location to place type of record){	LocalID appInfoID;	MemPtr appInfoDataP;	MemPtr dataP;	MemPtr baseP;	PddbAppInfoPtr appInfoP;	MemPtr resultP = NULL;		appInfoID = DmGetAppInfoID( dbRef );	baseP = appInfoDataP = MemLocalIDToLockedPtr(appInfoID, 0);	if ( appInfoDataP )	{		// Skip over category.		appInfoDataP = (PddbAppInfoPtr)( ( ( char *)appInfoDataP + pddbCategoryAppInfoLength ) );		appInfoP = (PddbAppInfoPtr)appInfoDataP;		dataP = (MemPtr)( ( ( char*)appInfoP + sizeof( PddbAppInfoPtr ) ) );		if ( flagsP )		{			*flagsP = appInfoP->flags;		}		if ( MemPtrSize( appInfoP ) > sizeof( PddbAppInfoType ) )		{			// Create a block for the caller.			resultP = MemPtrNew( MemPtrSize( appInfoP ) - sizeof( PddbAppInfoType ) );			MemMove( resultP, dataP, 				(long)(MemPtrSize( appInfoP ) - sizeof( PddbAppInfoType ) ) );		}		MemPtrUnlock( baseP );	}	return resultP;	}/*********************************************************************** * FUNCTION:    	PrvPddbAppInfoRecordFlags * * DESCRIPTION: 	This routine returns the PDDB flags from the app info * * RETURNED:    	flags. ***********************************************************************/static UInt16 PrvPddbAppInfoRecordFlags(	DmOpenRef dbRef		// (in) database owning this record.){	LocalID appInfoID;	MemPtr appInfoDataP;	MemPtr dataP;	MemPtr baseP;	PddbAppInfoPtr appInfoP;	UInt16 flags = 0;					int debug = 	pddbCategoryAppInfoLength;			appInfoID = DmGetAppInfoID(dbRef);	baseP = appInfoDataP = MemLocalIDToLockedPtr(appInfoID, 0);	if ( appInfoDataP )	{		// Skip over category.		appInfoDataP = (PddbAppInfoPtr)( ( ( char *)appInfoDataP + pddbCategoryAppInfoLength ) );		appInfoP = (PddbAppInfoPtr)appInfoDataP;		dataP = (MemPtr)( ( ( char*)appInfoP + sizeof( PddbAppInfoPtr ) ) );		flags = appInfoP->flags;		MemPtrUnlock( baseP );	}	return flags;}/*********************************************************************** * FUNCTION:    	PddbRecordLock * * DESCRIPTION: 	This routine replaces the MemHandleLock used when  *                  accessing records for reading.  This routine *                  provides a pointer to the data and the type if known. * * RETURNED:    	A pointer to the record or NULL ***********************************************************************/MemPtr PddbRecordLock(	DmOpenRef dbRef,		// (in) database owning this record.	MemHandle recordH,		// (in) handle to database record to lock.	UInt32 *typeP			// (in) pointer of location to place type of record){	MemPtr dataP;	PddbRecordTypePtr record;		if (typeP) 	{		*typeP = 0L;	}		dataP = MemHandleLock( recordH );		// Obtain the record type if available.	if ( dataP )	{		if ( PrvPddbAppInfoRecordFlags( dbRef ) & pddbDatabaseRecordsHaveType )		{			record = (PddbRecordTypePtr)(dataP);			dataP = (MemPtr)( ( (char *)dataP + sizeof( PddbRecordType ) ) );			if (typeP) 			{				*typeP = record->type;			}		}	}	return dataP;	}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -