+void import_one_bio_file(char *username, long usernum, char *path)
+{
+ syslog(LOG_DEBUG, "Import legacy bio for %s, usernum=%ld, filename=%s", username, usernum, path);
+
+ FILE *fp = fopen(path, "r");
+ if (!fp) return;
+
+ fseek(fp, 0, SEEK_END);
+ long data_length = ftell(fp);
+
+ if (data_length >= 1) {
+ rewind(fp);
+ char *unencoded_data = malloc(data_length);
+ if (unencoded_data) {
+ fread(unencoded_data, data_length, 1, fp);
+ char *encoded_data = malloc((data_length * 2) + 100);
+ if (encoded_data) {
+ sprintf(encoded_data, "Content-type: text/plain; charset=UTF-8\nContent-transfer-encoding: base64\n\n");
+ CtdlEncodeBase64(&encoded_data[strlen(encoded_data)], unencoded_data, data_length, 1);
+
+ char userconfigroomname[ROOMNAMELEN];
+ struct ctdluser usbuf;
+
+ if (CtdlGetUser(&usbuf, username) == 0) { // no need to lock it , we are still initializing
+ long old_msgnum = usbuf.msgnum_bio;
+ CtdlMailboxName(userconfigroomname, sizeof userconfigroomname, &usbuf, USERCONFIGROOM);
+ long new_msgnum = quickie_message("Citadel", NULL, NULL, userconfigroomname, encoded_data, FMT_RFC822, "Profile imported from bio");
+ syslog(LOG_DEBUG, "Message %ld is now the profile for %s", new_msgnum, username);
+ usbuf.msgnum_bio = new_msgnum;
+ CtdlPutUser(&usbuf);
+ unlink(path); // delete the old file , it's in the database now
+ if (old_msgnum > 0) {
+ syslog(LOG_DEBUG, "Deleting old message %ld from %s", old_msgnum, userconfigroomname);
+ CtdlDeleteMessages(userconfigroomname, &old_msgnum, 1, "");
+ }
+ }
+ free(encoded_data);
+ }
+ free(unencoded_data);
+ }
+ }
+ fclose(fp);
+}
+
+
+/*
+ * Look for old-format "bio" files and import them into the message base
+ */
+void import_old_bio_files(void)