Added to the repository
Showing
1 changed file
with
99 additions
and
0 deletions
mailbox/include/amd.h
0 → 100644
1 | /* GNU Mailutils -- a suite of utilities for electronic mail | ||
2 | Copyright (C) 1999, 2000, 2001, 2002, 2003, | ||
3 | 2004 Free Software Foundation, Inc. | ||
4 | |||
5 | This library is free software; you can redistribute it and/or | ||
6 | modify it under the terms of the GNU Lesser General Public | ||
7 | License as published by the Free Software Foundation; either | ||
8 | version 2 of the License, or (at your option) any later version. | ||
9 | |||
10 | This library is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
13 | Lesser General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU Lesser General Public | ||
16 | License along with this library; if not, write to the Free Software | ||
17 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ | ||
18 | |||
19 | #define MAX_OPEN_STREAMS 16 | ||
20 | |||
21 | /* Notifications ADD_MESG. */ | ||
22 | #define DISPATCH_ADD_MSG(mbox,mhd) \ | ||
23 | do \ | ||
24 | { \ | ||
25 | int bailing = 0; \ | ||
26 | monitor_unlock (mbox->monitor); \ | ||
27 | if (mbox->observable) \ | ||
28 | bailing = observable_notify (mbox->observable, MU_EVT_MESSAGE_ADD); \ | ||
29 | if (bailing != 0) \ | ||
30 | { \ | ||
31 | if (pcount) \ | ||
32 | *pcount = (mhd)->msg_count; \ | ||
33 | locker_unlock (mbox->locker); \ | ||
34 | return EINTR; \ | ||
35 | } \ | ||
36 | monitor_wrlock (mbox->monitor); \ | ||
37 | } while (0); | ||
38 | |||
39 | struct _amd_data; | ||
40 | struct _amd_message | ||
41 | { | ||
42 | struct _amd_message *next; | ||
43 | struct _amd_message *prev; | ||
44 | |||
45 | stream_t stream; /* Associated file stream */ | ||
46 | off_t body_start; /* Offset of body start in the message file */ | ||
47 | off_t body_end; /* Offset of body end (size of file, effectively)*/ | ||
48 | |||
49 | int attr_flags; /* Attribute flags */ | ||
50 | int deleted; /* Was the message originally deleted */ | ||
51 | |||
52 | time_t mtime; /* Time of last modification */ | ||
53 | size_t header_lines; /* Number of lines in the header part */ | ||
54 | size_t body_lines; /* Number of lines in the body */ | ||
55 | |||
56 | message_t message; /* Corresponding message_t */ | ||
57 | struct _amd_data *amd; /* Back pointer. */ | ||
58 | }; | ||
59 | |||
60 | struct _amd_data | ||
61 | { | ||
62 | size_t msg_size; /* Size of struct _amd_message */ | ||
63 | int (*msg_init_delivery) (struct _amd_data *, struct _amd_message *); | ||
64 | int (*msg_finish_delivery) (struct _amd_data *, struct _amd_message *); | ||
65 | void (*msg_free) (struct _amd_message *); | ||
66 | char *(*msg_file_name) (struct _amd_message *, int deleted); | ||
67 | int (*scan0) (mailbox_t mailbox, size_t msgno, size_t *pcount, | ||
68 | int do_notify); | ||
69 | int (*msg_cmp) (struct _amd_message *, struct _amd_message *); | ||
70 | int (*message_uid) (message_t msg, size_t *puid); | ||
71 | size_t (*next_uid) (struct _amd_data *mhd); | ||
72 | |||
73 | /* List of messages: */ | ||
74 | size_t msg_count; /* number of messages in the list */ | ||
75 | struct _amd_message *msg_head; /* First */ | ||
76 | struct _amd_message *msg_tail; /* Last */ | ||
77 | |||
78 | unsigned long uidvalidity; | ||
79 | |||
80 | char *name; /* Directory name */ | ||
81 | |||
82 | /* Pool of open message streams */ | ||
83 | struct _amd_message *msg_pool[MAX_OPEN_STREAMS]; | ||
84 | int pool_first; /* Index to the first used entry in msg_pool */ | ||
85 | int pool_last; /* Index to the first free entry in msg_pool */ | ||
86 | |||
87 | time_t mtime; /* Time of last modification */ | ||
88 | |||
89 | mailbox_t mailbox; /* Back pointer. */ | ||
90 | }; | ||
91 | |||
92 | |||
93 | int amd_init_mailbox __P((mailbox_t mailbox, size_t mhd_size, | ||
94 | struct _amd_data **pmhd)); | ||
95 | void _amd_message_insert __P((struct _amd_data *mhd, | ||
96 | struct _amd_message *msg)); | ||
97 | int amd_message_stream_open __P((struct _amd_message *mhm)); | ||
98 | void amd_message_stream_close __P((struct _amd_message *mhm)); | ||
99 | void amd_cleanup (void *arg); |
-
Please register or sign in to post a comment