在Maat_command.h中增加Maat_str_escape函数,供用户预先处理待输入的字符串规则。

This commit is contained in:
zhengchao
2017-07-08 16:42:51 +08:00
parent 59aa0419c9
commit 6a89f18d2f
6 changed files with 53 additions and 9 deletions

View File

@@ -414,6 +414,39 @@ char* str_unescape(char* s)
s[j]='\0';
return s;
}
char* Maat_str_escape(char* dst,int size,const char*src)
{
int i=0,j=0;
int len=strlen(src);
for(i=0,j=0;i<len&&j<size;i++)
{
switch(src[i])
{
case '&':
dst[j]='\\';
dst[j+1]='&';
j+=2;
break;
case ' ':
dst[j]='\\';
dst[j+1]='b';//space,0x20;
j+=2;
break;
case '\\':
dst[j]='\\';
dst[j+1]='\\';
j+=2;
break;
default:
dst[j]=src[i];
j++; //undo the followed i++
break;
}
}
dst[j]='\0';
return dst;
}
int cnt_maskbits(struct in6_addr mask)
{
unsigned int i=0;