When opening the Berkeley DB environment, step
[citadel.git] / citadel / vcard.c
index 52890a461d7f52affea2e64a0fe6a29f8a08e664..75a2c9f7c6c975f98f8c74fd0d920febdbec0675 100644 (file)
 #include <errno.h>
 #include <limits.h>
 #include <string.h>
-
+#include <libcitadel.h>
 #include "citadel.h"
 #include "server.h"
 #include "support.h"
 #include "vcard.h"
-#include "tools.h"
+
+
+
 
 
 /** 
@@ -74,7 +76,7 @@ void remove_charset_attribute(char *strbuf)
                        remove_token(strbuf, i, ';');
                }
        }
-       if (strlen(strbuf) > 0) {
+       if (!IsEmptyStr(strbuf)) {
                if (strbuf[strlen(strbuf)-1] == ';') {
                        strbuf[strlen(strbuf)-1] = 0;
                }
@@ -121,7 +123,7 @@ struct vCard *vcard_load(char *vtext) {
         * 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) {
+       for (i=0; !IsEmptyStr(&mycopy[i]); ++i) {
                if (!strncmp(&mycopy[i], "\r\n", 2)) {
                        strcpy(&mycopy[i], &mycopy[i+1]);
                }
@@ -134,7 +136,7 @@ struct vCard *vcard_load(char *vtext) {
        if (v == NULL) return v;
 
        ptr = mycopy;
-       while (strlen(ptr)>0) {
+       while (!IsEmptyStr(ptr)) {
                colonpos = (-1);
                nlpos = (-1);
                colonpos = pattern2(ptr, ":");
@@ -173,7 +175,7 @@ struct vCard *vcard_load(char *vtext) {
 
                }
 
-               while ( (*ptr != '\n') && (strlen(ptr)>0) ) {
+               while ( (*ptr != '\n') && (!IsEmptyStr(ptr)) ) {
                        ++ptr;
                }
                if (*ptr == '\n') ++ptr;
@@ -286,7 +288,7 @@ void vcard_set_prop(struct vCard *v, char *name, char *value, int append) {
 
 
 /**
- * \brief Serialize a struct vcard into a standard text/x-vcard MIME type.
+ * \brief Serialize a 'struct vcard' into an actual vcard.
  * \param v vCard to serialize
  * \return the serialized vCard
  */
@@ -312,9 +314,9 @@ char *vcard_serialize(struct vCard *v)
 
        safestrncpy(ser, "begin:vcard\r\n", len);
        if (v->numprops) for (i=0; i<(v->numprops); ++i) {
-               if (strcasecmp(v->prop[i].name, "end")) {
+               if ( (strcasecmp(v->prop[i].name, "end")) && (v->prop[i].value != NULL) ) {
                        is_utf8 = 0;
-                       for (j=0; i<strlen(v->prop[i].value); ++i) {
+                       for (j=0; !IsEmptyStr(&v->prop[i].value[j]); ++j) {
                                if ( (v->prop[i].value[j] < 32) || (v->prop[i].value[j] > 126) ) {
                                        is_utf8 = 1;
                                }
@@ -396,3 +398,4 @@ void vcard_fn_to_n(char *vname, char *n, size_t vname_size) {
 
 
 
+