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

📄 phydb.h

📁 一个操作系统源代码 用于嵌入式设备 在Vc++环境下仿真 成功移植到多款处理器上
💻 H
字号:
/*************************************************************************
*
* Copyright  2000 National ASIC Center, All right Reserved
*
* FILE NAME:			phylayer.h
* PROGRAMMER:			xuanhui
* Date of Creation:		2002/8/13
* 
* DESCRIPTION: 			The essential declarations for database physical layer 
*						including MACRO define and global funtion declaration.
*
**************************************************************************/

#ifndef PHY_DATA_BASE_H
#define PHY_DATA_BASE_H

#include <sys\wintype.h>
//#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys\lmalloc.h>

//#include <asixwin.h>
//#include <asixapp.h>

#define	DEBUGING	0				//debug

#if DEBUGING
typedef unsigned long       DWORD;	/* 32 */
typedef unsigned char       BYTE;	/* 8 */
typedef unsigned short      WORD;	/* 16 */
typedef	int					STATUS;		
typedef char 				CHAR;
typedef short 				SHORT;
#define		Lmalloc(nb)		malloc(nb)
#define		Lfree(blk)		free(blk)
#endif

typedef struct					//used information of record block
{
	DWORD	usedBlockHead;		//the head address of valid record block (relative byte offset in the file)
	DWORD	usedBlockTail;
	DWORD	freeBlockHead;		//the head address of free record block (relative byte offset in the file)
	DWORD	usedBlockNum;		//the number of valid record block
	DWORD	freeBlockNum;		//the number of free record block
}RECORDBLOCKINFO;

typedef struct					//database phusical layer information
{
	RECORDBLOCKINFO	info;		//used information of record block
	FILE			*fp;		//file information of database
}DBPHYLAYERINFO;

typedef struct
{
	WORD	size;		// 记录大小
	WORD	symbol;		// 记录标识
	DWORD	next;		// 下一条记录(文件内字节偏移)
	DWORD	prev;		// 上一条记录(文件内字节偏移)
	BYTE	*data;		// 记录数据	
}DBRECORDHEAD;

#define HEAD_ADDRESS_BYTE_NUM	4			//(sizeof(DWORD))
#define ADDRESS_BYTE_NUM		4			//(sizeof(DWORD))			
#define SIZE_BYTE_NUM			2			//(sizeof(WORD))
#define FLAG_BYTE_NUM			2			//(sizeof(WORD))
#define NEXT_BYTE_NUM			4			//(sizeof(DWORD))
#define PREV_BYTE_NUM			4			//(sizeof(DWORD))

#define RECORD_BLOCK_SIZE	36											//size of record block
#define BLOCK_DATA_SIZE		( RECORD_BLOCK_SIZE - ADDRESS_BYTE_NUM )	//size of data block
#define USED_BLOCK_FLAG		0x5542	//flag of invalid record block
#define FREE_BLOCK_FLAG		0x4642	//flag of valid record block

#define DB_OK				0				//success
#define DB_ERROR			1				//failure
#define DB_FREE_RECORD		2				//free record
#define DB_NO_MEM			3				//failure of application for memory
#define DB_FILE_ERROR		4				//database file error

//global funtion declaration
//extern DWORD GlobalReadRecord( DBPHYLAYERINFO *info, DWORD id, DWORD *data );
extern DWORD GlobalReadRecord( DBPHYLAYERINFO *info, DWORD id, BYTE **data );
extern DWORD GlobalModifyRecord( DBPHYLAYERINFO *info, DWORD id, BYTE *data );
extern DWORD GlobalInsertRecord( DBPHYLAYERINFO *info, DWORD id, BYTE *data );
extern DWORD GlobalDelRecord( DBPHYLAYERINFO *info, DWORD id );

#endif

⌨️ 快捷键说明

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