summaryrefslogtreecommitdiffabout
path: root/kmicromail/libetpan/mh/mailmh.c
Side-by-side diff
Diffstat (limited to 'kmicromail/libetpan/mh/mailmh.c') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libetpan/mh/mailmh.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/kmicromail/libetpan/mh/mailmh.c b/kmicromail/libetpan/mh/mailmh.c
index d6ff950..119f217 100644
--- a/kmicromail/libetpan/mh/mailmh.c
+++ b/kmicromail/libetpan/mh/mailmh.c
@@ -720,14 +720,15 @@ int mailmh_folder_get_message_size(struct mailmh_folder * folder,
* result = buf.st_size;
return MAILMH_NO_ERROR;
}
-int mailmh_folder_add_message(struct mailmh_folder * folder,
- const char * message, size_t size)
+int mailmh_folder_add_message_uid(struct mailmh_folder * folder,
+ const char * message, size_t size,
+ uint32_t * pindex)
{
char * tmpname;
int fd;
size_t namesize;
size_t left;
ssize_t res;
@@ -806,12 +807,15 @@ int mailmh_folder_add_message(struct mailmh_folder * folder,
#endif
key.data = &index;
key.len = sizeof(index);
data.data = msg_info;
data.len = 0;
+ if (pindex != NULL)
+ * pindex = index;
+
r = chash_set(folder->fl_msgs_hash, &key, &data, NULL);
if (r < 0) {
carray_delete_fast(folder->fl_msgs_tab, msg_info->msg_array_index);
mailmh_msg_info_free(msg_info);
error = MAILMH_ERROR_MEMORY;
goto err;
@@ -822,14 +826,20 @@ int mailmh_folder_add_message(struct mailmh_folder * folder,
free:
free(tmpname);
err:
return error;
}
-int mailmh_folder_add_message_file(struct mailmh_folder * folder,
- int fd)
+int mailmh_folder_add_message(struct mailmh_folder * folder,
+ const char * message, size_t size)
+{
+ return mailmh_folder_add_message_uid(folder, message, size, NULL);
+}
+
+int mailmh_folder_add_message_file_uid(struct mailmh_folder * folder,
+ int fd, uint32_t * pindex)
{
char * message;
struct stat buf;
int r;
#if 0
@@ -842,19 +852,25 @@ int mailmh_folder_add_message_file(struct mailmh_folder * folder,
return MAILMH_ERROR_FILE;
message = mmap(NULL, buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
if (message == MAP_FAILED)
return MAILMH_ERROR_FILE;
- r = mailmh_folder_add_message(folder, message, buf.st_size);
-
+ r = mailmh_folder_add_message_uid(folder, message, buf.st_size, pindex);
+
munmap(message, buf.st_size);
return r;
}
+int mailmh_folder_add_message_file(struct mailmh_folder * folder,
+ int fd)
+{
+ return mailmh_folder_add_message_file_uid(folder, fd, NULL);
+}
+
int mailmh_folder_remove_message(struct mailmh_folder * folder,
uint32_t index)
{
char * filename;
struct mailmh_msg_info * msg_info;
int res;