int
_VIsSpace(char in)
{
- if ((in == TAB) || (in == WSP))
+ if ((in == TAB) || (in == WSP))
return 1;
else
return 0;
int
_VRLSpace(char *in)
{
- int i, j;
- short int done;
+ int i, j;
+ short int done;
- i = 0;
- done = 0;
+ i = 0;
+ done = 0;
- while (!done && in[i]) {
+ while (!done && in[i]) {
if (_VIsSpace(in[i]))
i++;
else
done = 1;
- }
+ }
- j = 0;
- while (in[i]) {
+ j = 0;
+ while (in[i])
in[j++] = in[i++];
- }
-
- in[j] = '\0';
+ in[j] = '\0';
- return 0;
+ return 0;
}
int
_VRTSpace(char *in)
{
- int i;
- short int done;
+ int i;
+ short int done;
- i = strlen(in) - 1;
- done = 0;
+ i = strlen(in) - 1;
+ done = 0;
- while (!done && !(i < 0)) {
+ while (!done && !(i < 0)) {
if (_VIsSpace(in[i]))
in[i--] = '\0';
else
done = 1;
- }
+ }
- return(0);
+ return(0);
}
if (buf) {
for (i = 0, index = 0; i < len; i++) {
c = in[i];
- if (c == ';') {
+ if (c == ';')
buf[index++] = '\\';
- }
+
buf[index++] = c;
}
free(buf);
}
- return(0);
+ return(0);
}
int
_VManySpace2Space(char *in)
{
- int i, j;
- int spaced = 0;
+ int i, j;
+ int spaced = 0;
- j = 0;
- for (i = 0; in[i]; i++) {
+ j = 0;
+ for (i = 0; in[i]; i++) {
if (_VIsSpace(in[i])) {
if (!spaced) {
in[j] = WSP;
in[j] = in[i];
j++;
}
- }
+ }
- in[j] = '\0';
+ in[j] = '\0';
- return j;
+ return j;
}
int
__VFindBase64(char in)
{
- int i;
+ int i;
- for (i = 0; i < 65; i++) {
+ for (i = 0; i < 65; i++) {
if (Base64Table[i] == in)
return i;
- }
- return -1;
+ }
+ return -1;
}
/* 12.03.2004 Process garbage character at the end of vcard/vcal */
if (_VIsSpace(string[i]) && (i < len-5)) {
- if (string[i-1] == LF || string[i-1] == CR) {
+ if (i >= 1 && (string[i-1] == LF || string[i-1] == CR)) {
if (j < 2)
j = 0;
else
string[i-1] = 0;
}
- if (string[i-2] == LF || string[i-2] == CR) {
+ if (i >= 2 && (string[i-2] == LF || string[i-2] == CR)) {
if (j < 1)
j = 0;
else
}
- for (low = 0, high = VCARD_TYPE_NUM - 1; high >= low; diff < 0 ? (low = i+1) : (high = i-1)) {
+ for (low = 0, high = VCARD_TYPE_NUM - 1; high >= low; diff < 0 ? (low = i+1) : (high = i-1)) {
i = (low + high) / 2;
diff = strcmp(pszCardTypeList[i], strTypeName);
- if (diff == 0) /* success: found it */
+ if (diff == 0) /* success: found it */
return true;
- }
+ }
- return false;
- //res = __VCardGetName(strTypeName, (char**)pszCardTypeList, VCARD_TYPE_NUM);
+ return false;
+ /* res = __VCardGetName(strTypeName, (char**)pszCardTypeList, VCARD_TYPE_NUM); */
}
else if (vType == VMESSAGE)
diff = strcmp(pszMsgTypeList[i], strTypeName);
- if (diff == 0) /* success: found it */
+ if (diff == 0) /* success: found it */
return true;
else if (!strncmp(strTypeName, "X-", 2))
return true;
/* if (count <= 50) return TRUE; */
- return false;
+ return false;
/* res = __VCardGetName(strTypeName, (char**)pszCardTypeList, VCARD_TYPE_NUM); */
}
len = strlen(string);
- if (!(newString = (char*) calloc(1, len+1))) {
+ if (!(newString = (char*) calloc(1, len+1)))
return NULL;
- }
-
for (i = 0, j = 0; i < len; i++, j++) {
if (string[i+1] == CR && string[i+2] == LF) {
if (__VIsNewType(string) == false) {
- j -= 2;
+ if (j >= 2)
+ j -= 2;
+ else
+ j = 0;
i += 2;
}
} else if (string[i+1] == CR || string[i+1] == LF) {
if (__VIsNewType(string) == false) {
- j -= 1;
+ if (j >= 1)
+ j -= 1;
+ else
+ j = 0;
i += 1;
}
}
} else if (string[i] == ' ') {
- if (string[i-2] == CR && string[i-1] == LF) {
- if (__VIsNewType(string) == false)
- j -= 3;
- else
+ if (i >= 2 && string[i-2] == CR && string[i-1] == LF) {
+ if (__VIsNewType(string) == false) {
+ if (j >= 3)
+ j -= 3;
+ else
+ j = 0;
+ } else {
j -= 1;
- } else if (string[i-1] == CR || string[i-1] == LF) {
- j -= 2;
+ }
+ } else if (i >= 1 && (string[i-1] == CR || string[i-1] == LF)) {
+ if (j >= 2)
+ j -= 2;
+ else
+ j = 0;
}
} else if ((string[i] == CR || string[i] == LF) && __VIsNewType(string) == false) {
if (string[i+1] == LF) {
- j -= 1;
+ if (j >= 1)
+ j -= 1;
+ else
+ j = 0;
i += 1;
}
}
i += 2;
}
} else if (string[i] == WSP || string[i] == TAB) {
- if (string[i-2] == CR && string[i-1] == LF) {
+ if (i >= 2 && string[i-2] == CR && string[i-1] == LF) {
string[i] = 0;
string[i-1] = 0;
string[i-2] = 0;
j -= 3;
else
j = 0;
- } else if (string[i-1] == CR || string[i-1] == LF) {
+ } else if (i >= 1 && (string[i-1] == CR || string[i-1] == LF)) {
string[i] = 0;
string[i-1] = 0;