/***************************************************************************
* Function Name:validatefoldername
* Description:the Ength of folder name should is less than 255.
* Illegal characters is \<> () []&:,/|? * ~ \31
* Return:0 for success, otherwise 1.
****************************************************************************/
#define Max_folder_name_len 255
Int Validatefoldername (char *pname)
{
int ret = 0;
Unsigned int u32length = 0, u32index = 0;
unsigned char u8specialchar[] = {' \ \ ', ' < ', ' > ', ' (', ') ', ' [', '] ', ' & ', ': ', ', ', '/', ' | ', '? ', ' * '};
unsigned char u8ctrlcharbegin = 0x0, u8ctrlcharend = 0x31;
if (pName = = NULL)
{
ret = 1;
}
Else
{
u32length = Strlen (PName);
if (u32length >= max_folder_name_len)
ret= 1;
}
for (U32index = 0; (U32index < U32length) && (ret== 0);
U32index + +)
{
if (U8ctrlcharbegin <= Pname[u32index] <= u8ctrlcharend)
{
Ret= 1;
}
else if (STRCHR (U8specialchar,pname[u32index])! = NULL)
{
Ret= 1;
}
}
return ret;
}
C language to determine whether the folder name is legitimate