X-Git-Url: https://code.citadel.org/?p=citadel.git;a=blobdiff_plain;f=citadel%2Fmodules%2Fvcard%2Fserv_vcard.c;h=a6f6f9d514f22a78364a4d6feeb9ff6cfa8b6363;hp=2f126f40852b3cae4e2e44225c715c6f1ab26064;hb=6eb43187a82c686ce1855d15b7ba8485d1c461bb;hpb=13d92269d1288d35ef54fdf6dfdf839359c6ee7d diff --git a/citadel/modules/vcard/serv_vcard.c b/citadel/modules/vcard/serv_vcard.c index 2f126f408..a6f6f9d51 100644 --- a/citadel/modules/vcard/serv_vcard.c +++ b/citadel/modules/vcard/serv_vcard.c @@ -794,22 +794,13 @@ struct vCard *vcard_get_user(struct ctdluser *u) { * Write our config to disk */ void vcard_write_user(struct ctdluser *u, struct vCard *v) { - char temp[PATH_MAX]; - FILE *fp; char *ser; - CtdlMakeTempFileName(temp, sizeof temp); ser = vcard_serialize(v); - - fp = fopen(temp, "w"); - if (fp == NULL) return; if (ser == NULL) { - fprintf(fp, "begin:vcard\r\nend:vcard\r\n"); - } else { - fwrite(ser, strlen(ser), 1, fp); - free(ser); + ser = strdup("begin:vcard\r\nend:vcard\r\n"); } - fclose(fp); + if (!ser) return; /* This handy API function does all the work for us. * NOTE: normally we would want to set that last argument to 1, to @@ -817,15 +808,16 @@ void vcard_write_user(struct ctdluser *u, struct vCard *v) { * have to, because the vcard_upload_beforesave() hook above * is going to notice what we're trying to do, and delete the old vCard. */ - CtdlWriteObject(USERCONFIGROOM, /* which room */ - VCARD_MIME_TYPE,/* MIME type */ - temp, /* temp file */ - u, /* which user */ - 0, /* not binary */ - 0, /* don't delete others of this type */ - 0); /* no flags */ - - unlink(temp); + CtdlWriteObject(USERCONFIGROOM, /* which room */ + VCARD_MIME_TYPE, /* MIME type */ + ser, /* data */ + strlen(ser)+1, /* length */ + u, /* which user */ + 0, /* not binary */ + 0, /* don't delete others of this type */ + 0); /* no flags */ + + free(ser); }