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

📄 btype.h

📁 linux keyboard driver engine. the author is lifeng
💻 H
字号:
/*
* This source code is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
*       
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*
* File Name: btype.h							
*
* Reference:
*
* Author: Li Feng                                                   
*
* Description:
*
* 	
* 
* History:
* 02/23/2005  Li Feng    Created
*  
*
*CodeReview Log:
* 
*/
#ifndef __BASE_TYPE_H__
#define __BASE_TYPE_H__
#ifdef __cplusplus
extern "C" {
#endif

typedef signed char         INT8;
typedef signed short        INT16;
typedef signed int          INT32;
typedef unsigned char       UINT8;
typedef unsigned short      UINT16;
typedef unsigned int        UINT32;

#if defined(WIN32)
	#include <windows.h>
	typedef signed __int64    INT64;
	typedef unsigned __int64  UINT64;
	#define	 strcasecmp		_stricmp

//#elif defined(_LINUX)
//	#include <unistd.h>
//	#ifndef Sleep
//	#define Sleep(x)	poll(NULL,0,x)
//	#endif
//#else  
//	#include "ghs_null.h"
#endif

#ifndef WIN32
	typedef unsigned long long UINT64;
	typedef long long INT64;
	typedef struct tagRECT
	{
		INT32    left;
		INT32    top;
		INT32    right;
		INT32    bottom;
	}RECT;

	typedef struct tagPOINT
	{
		INT32  x;
		INT32  y;
	}POINT;
#endif
	
#ifdef WIN32
#define PACKED
#elif	_GREEN_HILLS
#define PACKED
#else
#define PACKED __attribute__((packed))
#endif


#if defined(_BIG_ENDIAN)
	#define SWAP16(val)	 val
	#define SWAP64(val)  val
	#define SWAP32(val)  val
#elif defined(_ARM_LINUX)
	#define SWAP32(val) (UINT32)((((UINT32)(val)) & 0x000000FF)<<24|(((UINT32)(val)) & 0x0000FF00)<<8 |	(((UINT32)(val)) & 0x00FF0000)>>8 |	(((UINT32)(val)) & 0xFF000000)>>24)	
		
	#define SWAP64(val) (UINT64)((((UINT64)(val)) & 0x00000000000000FF)<<56|(((UINT64)(val)) & 0x000000000000FF00)<<40|	(((UINT64)(val)) & 0x0000000000FF0000)<<24|	(((UINT64)(val)) & 0x00000000FF000000)<<8 |	(((UINT64)(val)) & 0x000000FF00000000)>>8 |	(((UINT64)(val)) & 0x0000FF0000000000)>>24|	(((UINT64)(val)) & 0x00FF000000000000)>>40|	(((UINT64)(val)) & 0xFF00000000000000)>>56)		
	#define SWAP16(val)	(UINT16)((((UINT16)(val))& 0x00FF)<<8 | (((UINT16)(val)) & 0xFF00)>>8)
#else
	#define SWAP32(val) (UINT32)((((UINT32)(val)) & 0x000000FF)<<24|	\
		(((UINT32)(val)) & 0x0000FF00)<<8 |	\
		(((UINT32)(val)) & 0x00FF0000)>>8 |	\
		(((UINT32)(val)) & 0xFF000000)>>24)	

	#define SWAP64(val) (UINT64)((((UINT64)(val)) & 0x00000000000000FF)<<56|	\
		(((UINT64)(val)) & 0x000000000000FF00)<<40|	\
		(((UINT64)(val)) & 0x0000000000FF0000)<<24|	\
		(((UINT64)(val)) & 0x00000000FF000000)<<8 |	\
		(((UINT64)(val)) & 0x000000FF00000000)>>8 |	\
		(((UINT64)(val)) & 0x0000FF0000000000)>>24|	\
		(((UINT64)(val)) & 0x00FF000000000000)>>40|	\
		(((UINT64)(val)) & 0xFF00000000000000)>>56)		
	#define SWAP16(val)	(UINT16)((((UINT16)(val))& 0x00FF)<<8 | (((UINT16)(val)) & 0xFF00)>>8)
#endif
	
#define BIN2BCD(n)		((((n)%100/10)<<4)|((n)%100%10))
#define BCD2BIN(n)		((0xf & (n))+(10*((n) >> 4)))

typedef struct{char minute,second,frame;}MSF;
#define MSF2LBA(msf)		(msf.minute * 4500 + msf.second * 75 + msf.frame)
#define LBA2MSF(msf,lba)	(msf.minute=(lba)/4500, msf.second=(lba)%4500/75, msf.frame=(lba)%75)

#ifndef BOOL
	#define BOOL	int
	#define FALSE	0
	#define TRUE    1
#endif	

#ifndef TRACE
#ifdef _DEBUG
#define TRACE printf
#define PrintError(errcode) printf("\n(File=%s,Line=%n) Error:%n",__FILE__,__LINE__,errcode);
#else
#define TRACE
#endif
#endif

#ifndef ASSERT
#define ASSERT		assert
#endif

#ifndef MAX_PATH
#define MAX_PATH 260
#endif

#ifndef HANDLE
#define HANDLE void*
#endif

#ifndef INVALID_HANDLE_VALUE
#define INVALID_HANDLE_VALUE (-1)
#endif

#ifndef INFINITE
#define INFINITE 0xFFFFFFFF  // Infinite timeout
#endif

#ifndef NULL
#ifdef __cplusplus
#define NULL    0
#else
#define NULL    ((void *)0)
#endif
#endif

#ifndef max
#define max(a,b)            (((a) > (b)) ? (a) : (b))
#endif

#ifndef min
#define min(a,b)            (((a) < (b)) ? (a) : (b))
#endif

#ifndef offsetof
#define offsetof(s,m)		(UINT32)&(((s *)0)->m)
#endif

typedef struct tagBITMAPINFOHEADER
{
	UINT16		ID;
	UINT32		biSize;
	UINT32		biReserve;
	UINT32		biDataOffset;
	UINT32		biHeaderSize;
	UINT32		biWidth;
	UINT32		biHeight;
	UINT16		biPlanes;
	UINT16		biBitCount;
	UINT32		biCompression;
	UINT32		biSizeImage;
	UINT32		biXPelsPerMeter;
	UINT32		biYPelsPerMeter;
	UINT32		biColor;
	UINT32		biClrImportant;
}BitmapIfoHeader;

enum
{
	MAX_FRAME =262144,
	MAX_GOP   =675840,
	MAX_PACKET=2324
};

#ifndef RGB
#define RGB(r,g,b)   ((UINT32)(((UINT8)(r)|((UINT16)((UINT8)(g))<<8))|(((UINT32)(UINT8)(b))<<16)))
#endif

#ifndef CLOCK
	#define CLOCK	UINT64
	#define CLOCKS	(CLOCK)27000000
#endif


#ifndef WAVE_FORMAT_LPCM
#define WAVE_FORMAT_LPCM  0xA0	
#endif


#ifdef __cplusplus
}
#endif
#endif//__BASE_TYPE_H__

⌨️ 快捷键说明

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