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

📄 fatchchk.c

📁 The combined demo is dedicated for S1C33L05, so DMT33L05 should be used to load and run the demo. F
💻 C
字号:
/************************************************************************
 *																		*
 *	Copyright (C) SEIKO EPSON CORP. 2000								*
 *																		*
 *	File name : fatchchk.c												*
 *	  This is FAT file path name charactor check program.				*
 *																		*
 *	Revision history													*
 *	    2000.04.26	T.Mineshima	Start.									*
 *	    2000.05.26	T.Mineshima	Comment clean up.						*
 *	    2001.05.23	H.Ogura		FAT33 library is made.					*
 *		2003.06.05	A.Saito		Modify Comment							*
 *																		*
 ************************************************************************/
/************************************************************************/
/*			The tab size of this file is 4. 							*/
/************************************************************************/

#ifndef _DOS
#include <stdio.h>
#include <string.h>
#include "fat.h"
#else
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <dos.h>
#include "cfdos.h"
#include "fatdos.h"
#endif


/*******************************************************************************
 * fatIs2ByteCode1
 *   Type :	int
 *   Ret val :	1 = OK, 0 = NG
 *   Argument :	unsigned char bChr	Check character
 *   Function :	Check 2bytes code first byte data.
 *******************************************************************************/
int fatIs2ByteCode1(unsigned char bChr)
{
	if ((bChr >= 0x81) && (bChr <= 0x9f)) return 1;
	if ((bChr >= 0xe0) && (bChr <= 0xfc)) return 1;
	return 0;
}


/*******************************************************************************
 * fatIs2ByteCode2
 *   Type :	int
 *   Ret val :	1 = OK, 0 = NG
 *   Argument :	unsigned char bChr	Check character
 *   Function :	Check 2bytes coe second byte data.
 *******************************************************************************/
int fatIs2ByteCode2(unsigned char bChr)
{
	if ((bChr >= 0x40) && (bChr <= 0x7e)) return 1;
	if ((bChr >= 0x80) && (bChr <= 0xfc)) return 1;
	return 0;
}


/*******************************************************************************
 * fatSearchByte
 *   Type :	unsigned char *
 *   Ret val :	Search byte pointer (if 0, search value is none)
 *   Argument :	unsigned char *p		Byte pointer
 *		unsigned char bData	Search byte value
 *		unsigned short wLen	Length
 *   Function :	Serch byte data from memory block.
 *******************************************************************************/
static unsigned char *fatSearchByte(unsigned char *p, unsigned char bData, unsigned short wLen)
{
	while (wLen) {
		if (*p == bData) return p;
		p++;
		wLen--;
	}
	return 0;
}


/*******************************************************************************
 * fatIsFnChr
 *   Type :	int
 *   Ret val :	1 = OK, 0 = NG
 *   Argument :	unsigned char bChr	Check character
 *   Function :	Check character of filename.
 *******************************************************************************/
int fatIsFnChr(unsigned char bChr)
{
	static const unsigned char	bFnOK[] = "$&#%`\'()-@^_{}~!";

	if ((bChr >= '0') && (bChr <= '9')) return 1;
	if ((bChr >= 'A') && (bChr <= 'Z')) return 1;
	if ((bChr >= 'a') && (bChr <= 'z')) return 1;

	if ((bChr >= 0xa0) && (bChr <= 0xdf)) return 1;	/* Other single byte code check */

	if (fatSearchByte((unsigned char *)bFnOK, bChr, sizeof(bFnOK) - 1)) return 1;
		/* Symbol code check */

	return 0;
}

⌨️ 快捷键说明

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