summaryrefslogtreecommitdiffabout
path: root/kmicromail/libetpan/mh/mailmh.h
Unidiff
Diffstat (limited to 'kmicromail/libetpan/mh/mailmh.h') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/libetpan/mh/mailmh.h143
1 files changed, 143 insertions, 0 deletions
diff --git a/kmicromail/libetpan/mh/mailmh.h b/kmicromail/libetpan/mh/mailmh.h
new file mode 100644
index 0000000..40432cb
--- a/dev/null
+++ b/kmicromail/libetpan/mh/mailmh.h
@@ -0,0 +1,143 @@
1/*
2 * libEtPan! -- a mail stuff library
3 *
4 * Copyright (C) 2001, 2002 - DINH Viet Hoa
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the libEtPan! project nor the names of its
16 * contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 */
31
32/*
33 * $Id$
34 */
35
36#ifndef MAILMH_H
37
38#define MAILMH_H
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44#include <sys/types.h>
45#include <inttypes.h>
46#include <libetpan/carray.h>
47#include <libetpan/cinthash.h>
48#include <libetpan/chash.h>
49
50enum {
51 MAILMH_NO_ERROR = 0,
52 MAILMH_ERROR_FOLDER,
53 MAILMH_ERROR_MEMORY,
54 MAILMH_ERROR_FILE,
55 MAILMH_ERROR_COULD_NOT_ALLOC_MSG,
56 MAILMH_ERROR_RENAME,
57 MAILMH_ERROR_MSG_NOT_FOUND,
58};
59
60struct mailmh {
61 struct mailmh_folder * mh_main;
62};
63
64struct mailmh_msg_info {
65 unsigned int msg_array_index;
66 uint32_t msg_index;
67 size_t msg_size;
68 time_t msg_mtime;
69};
70
71struct mailmh_folder {
72 char * fl_filename;
73 unsigned int fl_array_index;
74
75 char * fl_name;
76 time_t fl_mtime;
77 struct mailmh_folder * fl_parent;
78 uint32_t fl_max_index;
79
80 carray * fl_msgs_tab;
81#if 0
82 cinthash_t * fl_msgs_hash;
83#endif
84 chash * fl_msgs_hash;
85
86 carray * fl_subfolders_tab;
87 chash * fl_subfolders_hash;
88};
89
90struct mailmh * mailmh_new(const char * foldername);
91void mailmh_free(struct mailmh * f);
92
93struct mailmh_msg_info *
94mailmh_msg_info_new(uint32_t index, size_t size, time_t mtime);
95void mailmh_msg_info_free(struct mailmh_msg_info * msg_info);
96
97struct mailmh_folder * mailmh_folder_new(struct mailmh_folder * parent,
98 const char * name);
99void mailmh_folder_free(struct mailmh_folder * folder);
100
101int mailmh_folder_add_subfolder(struct mailmh_folder * parent,
102 const char * name);
103
104struct mailmh_folder * mailmh_folder_find(struct mailmh_folder * root,
105 const char * filename);
106
107int mailmh_folder_remove_subfolder(struct mailmh_folder * folder);
108
109int mailmh_folder_rename_subfolder(struct mailmh_folder * src_folder,
110 struct mailmh_folder * dst_folder,
111 const char * new_name);
112
113int mailmh_folder_get_message_filename(struct mailmh_folder * folder,
114 uint32_t index, char ** result);
115
116int mailmh_folder_get_message_fd(struct mailmh_folder * folder,
117 uint32_t index, int flags, int * result);
118
119int mailmh_folder_get_message_size(struct mailmh_folder * folder,
120 uint32_t index, size_t * result);
121
122int mailmh_folder_add_message(struct mailmh_folder * folder,
123 const char * message, size_t size);
124
125int mailmh_folder_add_message_file(struct mailmh_folder * folder,
126 int fd);
127
128int mailmh_folder_remove_message(struct mailmh_folder * folder,
129 uint32_t index);
130
131int mailmh_folder_move_message(struct mailmh_folder * dest_folder,
132 struct mailmh_folder * src_folder,
133 uint32_t index);
134
135int mailmh_folder_update(struct mailmh_folder * folder);
136
137unsigned int mailmh_folder_get_message_number(struct mailmh_folder * folder);
138
139#ifdef __cplusplus
140}
141#endif
142
143#endif