remove_token(strbuf, i, ';');
}
}
- if (strlen(strbuf) > 0) {
- if (strbuf[strlen(strbuf)-1] == ';') {
- strbuf[strlen(strbuf)-1] = 0;
+ if (!IsEmptyStr(strbuf)) {
+ int len;
+ len = strlen(strbuf);
+ if (strbuf[len-1] == ';') {
+ strbuf[len-1] = 0;
}
}
}
char *mycopy, *ptr;
char *namebuf, *valuebuf;
int i;
+ int len;
int colonpos, nlpos;
if (vtext == NULL) return vcard_new();
* To make it easier to parse, we convert CRLF to LF, and unfold any
* multi-line fields into single lines.
*/
- for (i=0; i<strlen(mycopy); ++i) {
+ len = strlen(mycopy);
+ for (i=0; i<len; ++i) {
if (!strncmp(&mycopy[i], "\r\n", 2)) {
- strcpy(&mycopy[i], &mycopy[i+1]);
+ memmove(&mycopy[i], &mycopy[i+1], len - i);
+ len --;
}
if ( (mycopy[i]=='\n') && (isspace(mycopy[i+1])) ) {
- strcpy(&mycopy[i], &mycopy[i+1]);
+ memmove(&mycopy[i], &mycopy[i+1], len - i);
+ len --;
}
}
if (v == NULL) return v;
ptr = mycopy;
- while (strlen(ptr)>0) {
+ while (*ptr != '\0') {
colonpos = (-1);
nlpos = (-1);
colonpos = pattern2(ptr, ":");
}
- while ( (*ptr != '\n') && (strlen(ptr)>0) ) {
+ while ( (*ptr != '\n') && (*ptr != '\0') ) {
++ptr;
}
if (*ptr == '\n') ++ptr;
int is_partial, int instance, int get_propname) {
int i;
int found_instance = 0;
+ int len;
+ len = strlen(propname);
if (v->numprops) for (i=0; i<(v->numprops); ++i) {
if ( (!strcasecmp(v->prop[i].name, propname))
|| (propname[0] == 0)
|| ( (!strncasecmp(v->prop[i].name,
- propname, strlen(propname)))
- && (v->prop[i].name[strlen(propname)] == ';')
+ propname, len))
+ && (v->prop[i].name[len] == ';')
&& (is_partial) ) ) {
if (instance == found_instance++) {
if (get_propname) {
/**
- * \brief Serialize a struct vcard into a standard text/x-vcard MIME type.
+ * \brief Serialize a struct vcard into its standard format.
* \param v vCard to serialize
* \return the serialized vCard
*/