avoid decoding mime-parts unless we realy need to.
[citadel.git] / citadel / msgbase.h
1
2 #ifndef MSGBASE_H
3 #define MSGBASE_H
4
5
6 enum {
7         MSGS_ALL,
8         MSGS_OLD,
9         MSGS_NEW,
10         MSGS_FIRST,
11         MSGS_LAST,
12         MSGS_GT,
13         MSGS_EQ,
14         MSGS_SEARCH,
15         MSGS_LT
16 };
17
18 enum {
19         MSG_HDRS_BRIEF = 0,
20         MSG_HDRS_ALL = 1,
21         MSG_HDRS_EUID = 4
22 };
23
24 /*
25  * Possible return codes from CtdlOutputMsg()
26  */
27 enum {
28         om_ok,
29         om_not_logged_in,
30         om_no_such_msg,
31         om_mime_error
32 };
33
34 /*
35  * Values of "headers_only" when calling message output routines
36  */
37 #define HEADERS_ALL     0       /* Headers and body */
38 #define HEADERS_ONLY    1       /* Headers only */
39 #define HEADERS_NONE    2       /* Body only */
40 #define HEADERS_FAST    3       /* Headers only with no MIME info */
41
42
43 struct ma_info {
44         int is_ma;              /* Set to 1 if we are using this stuff */
45         int freeze;             /* Freeze the replacement chain because we're
46                                  * digging through a subsection */
47         int did_print;          /* One alternative has been displayed */
48         char chosen_part[128];  /* Which part of a m/a did we choose? */
49         int chosen_pref;        /* Chosen part preference level (lower is better) */
50         int use_fo_hooks;       /* Use fixed output hooks */
51         int dont_decode;        /* should we call the decoder or not? */
52 };
53
54
55 struct repl {                   /* Info for replication checking */
56         char exclusive_id[SIZ];
57         time_t highest;
58 };
59
60
61 /* Data structure returned by validate_recipients() */
62 struct recptypes {
63         int recptypes_magic;
64         int num_local;
65         int num_internet;
66         int num_ignet;
67         int num_room;
68         int num_error;
69         char *errormsg;
70         char *recp_local;
71         char *recp_internet;
72         char *recp_ignet;
73         char *recp_room;
74         char *display_recp;
75         char *bounce_to;
76         char *envelope_from;
77 };
78
79 #define RECPTYPES_MAGIC 0xfeeb
80
81 /*
82  * This is a list of "harvested" email addresses that we might want to
83  * stick into someone's address book.  But we defer this operaiton so
84  * it can be done asynchronously.
85  */
86 struct addresses_to_be_filed {
87         struct addresses_to_be_filed *next;
88         char *roomname;
89         char *collected_addresses;
90 };
91
92 extern struct addresses_to_be_filed *atbf;
93
94 int alias (char *name);
95 void cmd_msgs (char *cmdbuf);
96 void cmd_isme (char *cmdbuf);
97 void help_subst (char *strbuf, char *source, char *dest);
98 void do_help_subst (char *buffer);
99 void memfmout (char *mptr, const char *nl);
100 void output_mime_parts(char *);
101 void cmd_msg0 (char *cmdbuf);
102 void cmd_msg2 (char *cmdbuf);
103 void cmd_msg3 (char *cmdbuf);
104 void cmd_msg4 (char *cmdbuf);
105 void cmd_msgp (char *cmdbuf);
106 void cmd_opna (char *cmdbuf);
107 void cmd_dlat (char *cmdbuf);
108 long send_message (struct CtdlMessage *);
109 void loadtroom (void);
110 long CtdlSubmitMsg(struct CtdlMessage *, struct recptypes *, char *, int);
111 void quickie_message (const char *, const char *, char *, char *, const char *, int, const char *);
112 void cmd_ent0 (char *entargs);
113 void cmd_dele (char *delstr);
114 void cmd_move (char *args);
115 void GetMetaData(struct MetaData *, long);
116 void PutMetaData(struct MetaData *);
117 void AdjRefCount(long, int);
118 void TDAP_AdjRefCount(long, int);
119 int TDAP_ProcessAdjRefCountQueue(void);
120 void simple_listing(long, void *);
121 int CtdlMsgCmp(struct CtdlMessage *msg, struct CtdlMessage *template);
122 typedef void (*ForEachMsgCallback)(long MsgNumber, void *UserData);
123 int CtdlForEachMessage(int mode,
124                         long ref,
125                         char *searchstring,
126                         char *content_type,
127                         struct CtdlMessage *compare,
128                         ForEachMsgCallback CallBack,
129                         void *userdata);
130 int CtdlDeleteMessages(char *, long *, int, char *);
131 void CtdlWriteObject(char *req_room,                    /* Room to stuff it in */
132                         char *content_type,             /* MIME type of this object */
133                         char *raw_message,              /* Data to be written */
134                         off_t raw_length,               /* Size of raw_message */
135                         struct ctdluser *is_mailbox,    /* Mailbox room? */
136                         int is_binary,                  /* Is encoding necessary? */
137                         int is_unique,                  /* Del others of this type? */
138                         unsigned int flags              /* Internal save flags */
139 );
140 struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body);
141 void CtdlFreeMessage(struct CtdlMessage *msg);
142 void serialize_message(struct ser_ret *, struct CtdlMessage *);
143 void dump_message(struct CtdlMessage *msg, long Siz);
144 int is_valid_message(struct CtdlMessage *);
145 void ReplicationChecks(struct CtdlMessage *);
146 int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newmsgs,
147                         int do_repl_check, struct CtdlMessage *supplied_msg, int suppress_refcount_adj);
148 int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int do_repl_check, struct CtdlMessage *msg);
149 char *CtdlReadMessageBody(char *terminator, long tlen, size_t maxlen, char *exist, int crlf, int *sock);
150 StrBuf *CtdlReadMessageBodyBuf(char *terminator,        /* token signalling EOT */
151                                long tlen,
152                                size_t maxlen,           /* maximum message length */
153                                char *exist,             /* if non-null, append to it;
154                                                            exist is ALWAYS freed  */
155                                int crlf,                /* CRLF newlines instead of LF */
156                                int *sock                /* socket handle or 0 for this session's client socket */
157         );
158
159 int CtdlOutputMsg(long msg_num,         /* message number (local) to fetch */
160                   int mode,             /* how would you like that message? */
161                   int headers_only,     /* eschew the message body? */
162                   int do_proto,         /* do Citadel protocol responses? */
163                   int crlf,             /* 0=LF, 1=CRLF */
164                   char *section,                /* output a message/rfc822 section */
165                   int flags             /* should the bessage be exported clean? */
166 );
167
168 /* Flags which may be passed to CtdlOutputMsg() and CtdlOutputPreLoadedMsg() */
169 #define QP_EADDR        (1<<0)          /* quoted-printable encode email addresses */
170 #define CRLF            (1<<1)
171 #define ESC_DOT         (1<<2)          /* output a line containing only "." as ".." instead */
172 #define SUPPRESS_ENV_TO (1<<3)          /* suppress Envelope-to: header (warning: destructive!) */
173
174 int CtdlOutputPreLoadedMsg(struct CtdlMessage *,
175                            int mode,            /* how would you like that message? */
176                            int headers_only,    /* eschew the message body? */
177                            int do_proto,        /* do Citadel protocol responses? */
178                            int crlf,            /* 0=LF, 1=CRLF */
179                            int flags            /* should the bessage be exported clean? */
180 );
181 int CtdlDoIHavePermissionToDeleteMessagesFromThisRoom(void);
182 int CtdlDoIHavePermissionToReadMessagesInThisRoom(void);
183
184 enum {
185         POST_LOGGED_IN,
186         POST_EXTERNAL,
187         CHECK_EXISTANCE,
188         POST_LMTP
189 };
190
191 int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf, 
192         size_t n, 
193         const char* RemoteIdentifier,
194         int PostPublic,
195         int is_reply
196 );
197
198
199 /* values for which_set */
200 enum {
201         ctdlsetseen_seen,
202         ctdlsetseen_answered
203 };
204 void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
205                  int target_setting, int which_set,
206                 struct ctdluser *which_user, struct ctdlroom *which_room);
207 void CtdlGetSeen(char *buf, int which_set);
208
209 struct recptypes *validate_recipients(const char *recipients,
210                                       const char *RemoteIdentifier, 
211                                       int Flags);
212
213 void free_recipients(struct recptypes *);
214
215 struct CtdlMessage *CtdlMakeMessage(
216         struct ctdluser *author,        /* author's user structure */
217         char *recipient,                /* NULL if it's not mail */
218         char *recp_cc,                  /* NULL if it's not mail */
219         char *room,                     /* room where it's going */
220         int type,                       /* see MES_ types in header file */
221         int format_type,                /* variformat, plain text, MIME... */
222         char *fake_name,                /* who we're masquerading as */
223         char *my_email,                 /* which of my email addresses to use (empty is ok) */
224         char *subject,                  /* Subject (optional) */
225         char *supplied_euid,            /* ...or NULL if this is irrelevant */
226         char *preformatted_text,        /* ...or NULL to read text from client */
227         char *references                /* Thread references */
228 );
229 int CtdlCheckInternetMailPermission(struct ctdluser *who);
230 int CtdlIsMe(char *addr, int addr_buf_len);
231
232 /*
233  * Use of aide_message is deprecated.
234  * It has been replaced with CtdlAideMessage.
235  * All parameters remain the same.
236 */
237 void aide_message(char *text, char *subject) __attribute__ ((deprecated));
238
239
240
241 #endif /* MSGBASE_H */