summaryrefslogtreecommitdiffabout
path: root/libetpan/include/libetpan/mailmh.h
Unidiff
Diffstat (limited to 'libetpan/include/libetpan/mailmh.h') (more/less context) (ignore whitespace changes)
-rw-r--r--libetpan/include/libetpan/mailmh.h152
1 files changed, 152 insertions, 0 deletions
diff --git a/libetpan/include/libetpan/mailmh.h b/libetpan/include/libetpan/mailmh.h
new file mode 100644
index 0000000..dc1861b
--- a/dev/null
+++ b/libetpan/include/libetpan/mailmh.h
@@ -0,0 +1,152 @@
1/*
2 * libEtPan! -- a mail stuff library
3 *
4 * Copyright (C) 2001, 2005 - 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 AUTHORS 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 AUTHORS 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#if 0
48#include <libetpan/cinthash.h>
49#endif
50#include <libetpan/chash.h>
51
52enum {
53 MAILMH_NO_ERROR = 0,
54 MAILMH_ERROR_FOLDER,
55 MAILMH_ERROR_MEMORY,
56 MAILMH_ERROR_FILE,
57 MAILMH_ERROR_COULD_NOT_ALLOC_MSG,
58 MAILMH_ERROR_RENAME,
59 MAILMH_ERROR_MSG_NOT_FOUND,
60};
61
62struct mailmh {
63 struct mailmh_folder * mh_main;
64};
65
66struct mailmh_msg_info {
67 unsigned int msg_array_index;
68 uint32_t msg_index;
69 size_t msg_size;
70 time_t msg_mtime;
71};
72
73struct mailmh_folder {
74 char * fl_filename;
75 unsigned int fl_array_index;
76
77 char * fl_name;
78 time_t fl_mtime;
79 struct mailmh_folder * fl_parent;
80 uint32_t fl_max_index;
81
82 carray * fl_msgs_tab;
83#if 0
84 cinthash_t * fl_msgs_hash;
85#endif
86 chash * fl_msgs_hash;
87
88 carray * fl_subfolders_tab;
89 chash * fl_subfolders_hash;
90};
91
92struct mailmh * mailmh_new(const char * foldername);
93void mailmh_free(struct mailmh * f);
94
95struct mailmh_msg_info *
96mailmh_msg_info_new(uint32_t index, size_t size, time_t mtime);
97void mailmh_msg_info_free(struct mailmh_msg_info * msg_info);
98
99struct mailmh_folder * mailmh_folder_new(struct mailmh_folder * parent,
100 const char * name);
101void mailmh_folder_free(struct mailmh_folder * folder);
102
103int mailmh_folder_add_subfolder(struct mailmh_folder * parent,
104 const char * name);
105
106struct mailmh_folder * mailmh_folder_find(struct mailmh_folder * root,
107 const char * filename);
108
109int mailmh_folder_remove_subfolder(struct mailmh_folder * folder);
110
111int mailmh_folder_rename_subfolder(struct mailmh_folder * src_folder,
112 struct mailmh_folder * dst_folder,
113 const char * new_name);
114
115int mailmh_folder_get_message_filename(struct mailmh_folder * folder,
116 uint32_t index, char ** result);
117
118int mailmh_folder_get_message_fd(struct mailmh_folder * folder,
119 uint32_t index, int flags, int * result);
120
121int mailmh_folder_get_message_size(struct mailmh_folder * folder,
122 uint32_t index, size_t * result);
123
124int mailmh_folder_add_message_uid(struct mailmh_folder * folder,
125 const char * message, size_t size,
126 uint32_t * pindex);
127
128int mailmh_folder_add_message(struct mailmh_folder * folder,
129 const char * message, size_t size);
130
131int mailmh_folder_add_message_file_uid(struct mailmh_folder * folder,
132 int fd, uint32_t * pindex);
133
134int mailmh_folder_add_message_file(struct mailmh_folder * folder,
135 int fd);
136
137int mailmh_folder_remove_message(struct mailmh_folder * folder,
138 uint32_t index);
139
140int mailmh_folder_move_message(struct mailmh_folder * dest_folder,
141 struct mailmh_folder * src_folder,
142 uint32_t index);
143
144int mailmh_folder_update(struct mailmh_folder * folder);
145
146unsigned int mailmh_folder_get_message_number(struct mailmh_folder * folder);
147
148#ifdef __cplusplus
149}
150#endif
151
152#endif