// function: 去除一组字符串中的空格
// author: sunny town
void trimSpace(char *inbuf, char *outbuf)
{
char *temp = NULL;
temp = inbuf;
while (*temp)
{
while (*temp == ' ')
{
temp++;
}
*outbuf++ = *temp++;
}
*outbuf = '\0';
return 0;
}
// function: 奇偶位输出字符串
// author: sunny town
int getStr(char *source, char *buf1, char *buf2)
{
char *temp = source;
int i = 0;
while (*temp++)
{
if (i%2 == 0)
*buf1++ = *temp;
else{
*buf2++ = *temp;
}
i++;
}
*buf1 = '\0';
*buf2 = '\0';
return 0;
}
// function: 键值对
// author: sunny town
int getKeyByValue(char *keyvalue, char *keybuf, char *valuebuf, int *valuebuflen)
{
char *temp = keyvalue;
int length = 0;
if (temp == NULL)
return -1;
while (*temp)
{
if (*temp == '=')
break;
*keybuf = *temp;
keybuf++;
temp++;
}
while (*temp)
{
++temp;
*valuebuf++ = *temp;
length++;
}
*keybuf = '\0';
*valuebuf = '\0';
*valuebuflen = length;
return 0;
}