5 #include "event_client.h"
22 MSG_HDRS_BRIEFFILTER = 8
26 * Possible return codes from CtdlOutputMsg()
37 * Values of "headers_only" when calling message output routines
39 #define HEADERS_ALL 0 /* Headers and body */
40 #define HEADERS_ONLY 1 /* Headers only */
41 #define HEADERS_NONE 2 /* Body only */
42 #define HEADERS_FAST 3 /* Headers only with no MIME info */
46 int is_ma; /* Set to 1 if we are using this stuff */
47 int freeze; /* Freeze the replacement chain because we're
48 * digging through a subsection */
49 int did_print; /* One alternative has been displayed */
50 char chosen_part[128]; /* Which part of a m/a did we choose? */
51 int chosen_pref; /* Chosen part preference level (lower is better) */
52 int use_fo_hooks; /* Use fixed output hooks */
53 int dont_decode; /* should we call the decoder or not? */
57 struct repl { /* Info for replication checking */
58 char exclusive_id[SIZ];
65 * This is a list of "harvested" email addresses that we might want to
66 * stick into someone's address book. But we defer this operaiton so
67 * it can be done asynchronously.
69 struct addresses_to_be_filed {
70 struct addresses_to_be_filed *next;
72 char *collected_addresses;
75 extern struct addresses_to_be_filed *atbf;
77 int GetFieldFromMnemonic(eMsgField *f, const char* c);
80 void memfmout (char *mptr, const char *nl);
81 void output_mime_parts(char *);
82 long send_message (struct CtdlMessage *);
83 void loadtroom (void);
84 long CtdlSubmitMsg(struct CtdlMessage *, recptypes *, const char *, int);
86 long quickie_message(const char *from, const char *fromaddr, const char *to, char *room, const char *text, int format_type, const char *subject);
88 void flood_protect_quickie_message(const char *from,
97 const long *CritStrLen,
102 void GetMetaData(struct MetaData *, long);
103 void PutMetaData(struct MetaData *);
104 void AdjRefCount(long, int);
105 void TDAP_AdjRefCount(long, int);
106 int TDAP_ProcessAdjRefCountQueue(void);
107 void simple_listing(long, void *);
108 int CtdlMsgCmp(struct CtdlMessage *msg, struct CtdlMessage *template);
109 typedef void (*ForEachMsgCallback)(long MsgNumber, void *UserData);
110 int CtdlForEachMessage(int mode,
114 struct CtdlMessage *compare,
115 ForEachMsgCallback CallBack,
117 int CtdlDeleteMessages(const char *, long *, int, char *);
118 void CtdlWriteObject(char *req_room, /* Room to stuff it in */
119 char *content_type, /* MIME type of this object */
120 char *raw_message, /* Data to be written */
121 off_t raw_length, /* Size of raw_message */
122 struct ctdluser *is_mailbox, /* Mailbox room? */
123 int is_binary, /* Is encoding necessary? */
124 int is_unique, /* Del others of this type? */
125 unsigned int flags /* Internal save flags */
127 struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body, int run_msg_hooks);
128 struct CtdlMessage * CM_Duplicate
129 (struct CtdlMessage *OrgMsg);
130 int CM_IsEmpty (struct CtdlMessage *Msg, eMsgField which);
131 void CM_SetField (struct CtdlMessage *Msg, eMsgField which, const char *buf, long length);
132 void CM_SetFieldLONG (struct CtdlMessage *Msg, eMsgField which, long lvalue);
133 void CM_CopyField (struct CtdlMessage *Msg, eMsgField WhichToPutTo, eMsgField WhichtToCopy);
134 void CM_CutFieldAt (struct CtdlMessage *Msg, eMsgField WhichToCut, long maxlen);
135 void CM_FlushField (struct CtdlMessage *Msg, eMsgField which);
136 void CM_Flush (struct CtdlMessage *Msg);
137 void CM_SetAsField (struct CtdlMessage *Msg, eMsgField which, char **buf, long length);
138 void CM_SetAsFieldSB (struct CtdlMessage *Msg, eMsgField which, StrBuf **buf);
139 void CM_GetAsField (struct CtdlMessage *Msg, eMsgField which, char **ret, long *retlen);
140 void CM_PrependToField (struct CtdlMessage *Msg, eMsgField which, const char *buf, long length);
142 void CM_Free (struct CtdlMessage *msg);
143 void CM_FreeContents (struct CtdlMessage *msg);
144 int CM_IsValidMsg (struct CtdlMessage *msg);
146 #define CM_KEY(Message, Which) Message->cm_fields[Which], Message->cm_lengths[Which]
147 #define CM_RANGE(Message, Which) Message->cm_fields[Which], \
148 Message->cm_fields[Which] + Message->cm_lengths[Which]
150 void CtdlSerializeMessage(struct ser_ret *, struct CtdlMessage *);
151 struct CtdlMessage *CtdlDeserializeMessage(long msgnum, int with_body, const char *Buffer, long Length);
152 void ReplicationChecks(struct CtdlMessage *);
153 int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newmsgs,
154 int do_repl_check, struct CtdlMessage *supplied_msg, int suppress_refcount_adj);
155 int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int do_repl_check, struct CtdlMessage *msg);
156 long CtdlSaveThisMessage(struct CtdlMessage *msg, long msgid, int Reply);
157 char *CtdlReadMessageBody(char *terminator, long tlen, size_t maxlen, StrBuf *exist, int crlf, int *sock);
158 StrBuf *CtdlReadMessageBodyBuf(char *terminator, /* token signalling EOT */
160 size_t maxlen, /* maximum message length */
161 StrBuf *exist, /* if non-null, append to it;
162 exist is ALWAYS freed */
163 int crlf, /* CRLF newlines instead of LF */
164 int *sock /* socket handle or 0 for this session's client socket */
167 int CtdlOutputMsg(long msg_num, /* message number (local) to fetch */
168 int mode, /* how would you like that message? */
169 int headers_only, /* eschew the message body? */
170 int do_proto, /* do Citadel protocol responses? */
171 int crlf, /* 0=LF, 1=CRLF */
172 char *section, /* output a message/rfc822 section */
173 int flags, /* should the bessage be exported clean? */
174 char **Author, /* if you want to know the author of the message... */
175 char **Address, /* if you want to know the sender address of the message... */
176 char **MessageID /* if you want to know the Message-ID of the message... */
179 /* Flags which may be passed to CtdlOutputMsg() and CtdlOutputPreLoadedMsg() */
180 #define QP_EADDR (1<<0) /* quoted-printable encode email addresses */
182 #define ESC_DOT (1<<2) /* output a line containing only "." as ".." instead */
183 #define SUPPRESS_ENV_TO (1<<3) /* suppress Envelope-to: header (warning: destructive!) */
185 int CtdlOutputPreLoadedMsg(struct CtdlMessage *,
186 int mode, /* how would you like that message? */
187 int headers_only, /* eschew the message body? */
188 int do_proto, /* do Citadel protocol responses? */
189 int crlf, /* 0=LF, 1=CRLF */
190 int flags /* should the bessage be exported clean? */
194 /* values for which_set */
199 void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
200 int target_setting, int which_set,
201 struct ctdluser *which_user, struct ctdlroom *which_room);
202 void CtdlGetSeen(char *buf, int which_set);
205 struct CtdlMessage *CtdlMakeMessage(
206 struct ctdluser *author, /* author's user structure */
207 char *recipient, /* NULL if it's not mail */
208 char *recp_cc, /* NULL if it's not mail */
209 char *room, /* room where it's going */
210 int type, /* see MES_ types in header file */
211 int format_type, /* variformat, plain text, MIME... */
212 char *fake_name, /* who we're masquerading as */
213 char *my_email, /* which of my email addresses to use (empty is ok) */
214 char *subject, /* Subject (optional) */
215 char *supplied_euid, /* ...or NULL if this is irrelevant */
216 char *preformatted_text, /* ...or NULL to read text from client */
217 char *references /* Thread references */
220 struct CtdlMessage *CtdlMakeMessageLen(
221 struct ctdluser *author, /* author's user structure */
222 char *recipient, /* NULL if it's not mail */
224 char *recp_cc, /* NULL if it's not mail */
226 char *room, /* room where it's going */
228 int type, /* see MES_ types in header file */
229 int format_type, /* variformat, plain text, MIME... */
230 char *fake_name, /* who we're masquerading as */
232 char *my_email, /* which of my email addresses to use (empty is ok) */
234 char *subject, /* Subject (optional) */
236 char *supplied_euid, /* ...or NULL if this is irrelevant */
238 char *preformatted_text, /* ...or NULL to read text from client */
240 char *references, /* Thread references */
244 * loading messages async via an FD:
245 * add IO->ReadMsg = NewAsyncMsg(...)
246 * and then call CtdlReadMessageBodyAsync() from your linreader handler.
249 ReadAsyncMsg *NewAsyncMsg(const char *terminator, /* token signalling EOT */
251 size_t expectlen, /* if we expect a message, how long should it be? */
252 size_t maxlen, /* maximum message length */
253 StrBuf *exist, /* if non-null, append to it;
254 exist is ALWAYS freed */
255 long eLen, /* length of exist */
256 int crlf /* CRLF newlines instead of LF */
259 eReadState CtdlReadMessageBodyAsync(AsyncIO *IO);
260 void DeleteAsyncMsg(ReadAsyncMsg **Msg);
262 extern int MessageDebugEnabled;
264 #define MSGDBGLOG(LEVEL) if ((LEVEL != LOG_DEBUG) || (MessageDebugEnabled != 0))
265 #define CCCID CCC->cs_pid
266 #define MSG_syslog(LEVEL, FORMAT, ...) \
267 MSGDBGLOG(LEVEL) syslog(LEVEL, \
268 "CC[%d]MSG " FORMAT, \
271 #define MSGM_syslog(LEVEL, FORMAT) \
272 MSGDBGLOG(LEVEL) syslog(LEVEL, \
273 "CC[%d]MSG " FORMAT, \
278 #endif /* MSGBASE_H */