/****************************************************************************
*
* 两个文件名字的比较的实现
*
****************************************************************************/
#include <stdio.h>
#include <string.h>
#include "compare.h"
#define CODELEN 9
#define BYTE char
#define WORD short
#define INT int
#define UNBYTE unsigned char
#define UNWORD unsigned short
/****************************************************************************
*
* 计算文件名的长度
*
****************************************************************************/
INT name_length(BYTE *name)
{
INT len = 0;
while (*(name+len)!='\0')
{
len++;
}
return len;
}
INT uncode_name_length(WORD *name)
{
INT len = 0;
while (*(name+len)!='\0')
{
len++;
}
return len;
}
/****************************************************************************
*
* 给文件名分类,分类原则如下:
* 以首字母为标准:
* 如果首字母是非数字,且非字母的字符,就返回0;
* 如果首字母为数字,就返回1;
* 如果文件名为字母,就返回2;
* 如果首字母为汉字,就返回3
*
****************************************************************************/
INT name_class(BYTE *name)
{
if (*name<0)
return 3;
else if ((*name>='a'&&*name<='z')||(*name>='A'&&*name<='Z'))
return 2;
else if(*name>='0'&&*name<='9')
return 1;
else
return 0;
}
/****************************************************************************
*
* 汉字转化为拼音的函数
*
****************************************************************************/
BYTE * name_hzintopy(BYTE *name,BYTE pinyin[CODELEN])
{
UNBYTE hig;
UNBYTE low;
UNWORD nCode;
hig = *name;
low = *(name+1);
nCode = (hig-0xa0)*100+low-0xa0;
switch(nCode)
{
case 6325:
case 6436:
case 7571:
case 7925:
memcpy(pinyin,"A",CODELEN);
// strValue="A";
break;
case 6263:
case 6440:
case 7040:
case 7208:
case 7451:
case 7733:
case 7945:
case 8616:
memcpy(pinyin,"AI",CODELEN);
//strValue="AI";
break;
case 5847:
case 5991:
case 6278:
case 6577:
case 6654:
case 7281:
case 7907:
case 8038:
case 8786:
memcpy(pinyin,"AN",CODELEN);
//strValue="AN";
break;
// strValue="ANG";
// break;
case 5974:
case 6254:
case 6427:
case 6514:
case 6658:
case 6959:
case 7033:
case 7081:
case 7365:
case 8190:
case 8292:
case 8643:
case 8701:
case 8773:
memcpy(pinyin,"AO",CODELEN);
//strValue="AO";
break;
case 6056:
case 6135:
case 6517:
case 7857:
case 8446:
case 8649:
case 8741:
memcpy(pinyin,"BA",CODELEN);
//strValue="BA";
break;
case 6267:
case 6334:
case 7494:
memcpy(pinyin,"BAI",CODELEN);
//strValue="BAI";
break;
case 5870:
case 5964:
case 7851:
case 8103:
case 8113:
case 8418:
memcpy(pinyin,"BAN",CODELEN);
//strValue="BAN";
break;
case 6182:
case 6826:
memcpy(pinyin,"BANG",CODELEN);
//strValue="BANG";
break;
case 6165:
case 7063:
case 7650:
case 8017:
case 8157:
case 8532:
case 8621:
memcpy(pinyin,"BAO",CODELEN);
//strValue="BAO";
break;
case 5635:
case 5873:
case 5893:
case 5993:
case 6141:
case 6703:
case 7753:
case 8039:
case 8156:
case 8645:
case 8725:
memcpy(pinyin,"BEI",CODELEN);
//strValue="BEI";
break;
case 5946:
case 5948:
case 7458:
case 7928:
memcpy(pinyin,"BEN",CODELEN);
//strValue="BEN";
break;
case 6452:
case 7420:
memcpy(pinyin,"BENG",CODELEN);
//strValue="BENG";
break;
case 5616:
case 5734:
case 6074:
case 6109:
case 6221:
case 6333:
case 6357:
case 6589:
case 6656:
case 6725:
case 6868:
case 6908:
case 6986:
case 6994:
case 7030:
case 7052:
case 7221:
case 7815:
case 7873:
case 7985:
case 8152:
case 8357:
case 8375:
case 8387:
case 8416:
case 8437:
case 8547:
case 8734:
memcpy(pinyin,"BI",CODELEN);
//strValue="BI";
break;
case 5650:
case 5945:
case 6048:
case 6677:
case 6774:
case 7134:
case 7614:
case 7652:
case 7730:
case 7760:
case 8125:
case 8159:
case 8289:
case 8354:
case 8693:
memcpy(pinyin,"BIAN",CODELEN);
//strValue="BIAN";
break;
case 7027:
case 7084:
case 7609:
case 7613:
case 7958:
case 7980:
case 8106:
case 8149:
case 8707:
case 8752:
memcpy(pinyin,"BIAO",CODELEN);
//strValue="BIAO";
break;
case 8531:
memcpy(pinyin,"BIE",CODELEN);
//strValue="BIE";
break;
case 5747:
case 6557:
case 7145:
case 7167:
case 7336:
case 7375:
case 7587:
case 7957:
case 8738:
case 8762:
memcpy(pinyin,"BIN",CODELEN);
//strValue="BIN";
break;
case 5787:
case 5891:
case 6280:
memcpy(pinyin,"BING",CODELEN);
//strValue="BING";
break;
case 5781:
case 6403:
case 6636:
case 7362:
case 7502:
case 7771:
case 7864:
case 8030:
case 8404:
case 8543:
case 8559:
memcpy(pinyin,"BO",CODELEN);
//strValue="BO";
break;
case 6318:
case 6945:
case 7419:
case 7446:
case 7848:
case 7863:
case 8519:
memcpy(pinyin,"BU",CODELEN);
//strValue="BU";
break;
case 6474:
case 7769:
memcpy(pinyin,"CA",CODELEN);
//strValue="CA";
break;
// strValue="CAI";
// break;
case 6978:
case 7078:
case 7218:
case 8451:
case 8785:
memcpy(pinyin,"CAN",CODELEN);
//strValue="CAN";
break;
case 5687:
memcpy(pinyin,"CANG",CODELEN);
//strValue="CANG";
break;
case 6448:
case 6878:
case 8309:
case 8429:
memcpy(pinyin,"CAO",CODELEN);
//strValue="CAO";
break;
case 6692:
memcpy(pinyin,"CE",CODELEN);
//strValue="CE";
break;
case 6515:
case 6825:
memcpy(pinyin,"CEN",CODELEN);
//strValue="CEN";
break;
case 6465:
memcpy(pinyin,"CENG",CODELEN);
//strValue="CENG";
break;
case 6639:
case 6766:
case 7017:
case 7230:
case 7311:
case 7322:
case 7363:
case 7942:
case 7979:
case 8135:
memcpy(pinyin,"CHA",CODELEN);
//strValue="CHA";
break;
case 5713:
case 7846:
case 8091:
case 8218:
memcpy(pinyin,"CHAI",CODELEN);
//strValue="CHAI";
break;
case 5770:
case 5838:
case 6159:
case 6667:
case 6893:
case 6904:
case 6981:
case 7031:
case 7086:
case 7472:
case 7688:
case 7966:
case 8324:
case 8580:
memcpy(pinyin,"CHAN",CODELEN);
//strValue="CHAN";
break;
case 5686:
case 5943:
case 6041:
case 6137:
case 6660:
case 6568:
case 6749:
case 7029:
case 7047:
case 7438:
case 7509:
case 8680:
memcpy(pinyin,"CHANG",CODELEN);
//strValue="CHANG";
break;
case 6687:
case 7443:
case 8173:
memcpy(pinyin,"CHAO",CODELEN);
//strValue="CHAO";
break;
case 5969:
case 7726:
memcpy(pinyin,"CHE",CODELEN);
//strValue="CHE";
break;
case 5840:
case 5863:
case 6251:
case 6433:
case 6923:
case 7201:
case 7320:
case 7755:
case 8619:
memcpy(pinyin,"CHEN",CODELEN);
//strValue="CHEN";
break;
case 5609:
case 5984:
case 7239:
case 7263:
case 7583:
case 7810:
case 7881:
case 7905:
case 8146:
case 8241:
case 8508:
memcpy(pinyin,"CHENG",CODELEN);
//strValue="CHENG";
break;
case 5749:
case 6015:
case 6061:
case 6319:
case 6374:
case 6420:
case 6445:
case 6633:
case 7042:
case 7523:
case 7787:
case 8023:
case 8101:
case 8161:
case 8231:
case 8304:
case 8355:
case 8388:
case 8489:
case 8556:
case 8746:
memcpy(pinyin,"CHI",CODELEN);
//strValue="CHI";
break;
case 6091:
case 6671:
case 6731:
case 8409:
case 8430:
memcpy(pinyin,"CHONG",CODELEN);
//strValue="CHONG";
break;
case 5717:
case 6492:
case 6716:
case 8112:
case 8637:
memcpy(pinyin,"CHOU",CODELEN);
//strValue="CHOU";
break;
case 5601:
case 5927:
case 6680:
case 6732:
case 7109:
case 7238:
case 7290:
case 7
- 1
- 2
- 3
前往页