5 #include "event_client.h"
25 * Possible return codes from CtdlOutputMsg()
36 * Values of "headers_only" when calling message output routines
38 #define HEADERS_ALL 0 /* Headers and body */
39 #define HEADERS_ONLY 1 /* Headers only */
40 #define HEADERS_NONE 2 /* Body only */
41 #define HEADERS_FAST 3 /* Headers only with no MIME info */
45 int is_ma; /* Set to 1 if we are using this stuff */
46 int freeze; /* Freeze the replacement chain because we're
47 * digging through a subsection */
48 int did_print; /* One alternative has been displayed */
49 char chosen_part[128]; /* Which part of a m/a did we choose? */
50 int chosen_pref; /* Chosen part preference level (lower is better) */
51 int use_fo_hooks; /* Use fixed output hooks */
52 int dont_decode; /* should we call the decoder or not? */
56 struct repl { /* Info for replication checking */
57 char exclusive_id[SIZ];
62 /* Data structure returned by validate_recipients() */
82 #define RECPTYPES_MAGIC 0xfeeb
85 * This is a list of "harvested" email addresses that we might want to
86 * stick into someone's address book. But we defer this operaiton so
87 * it can be done asynchronously.
89 struct addresses_to_be_filed {
90 struct addresses_to_be_filed *next;
92 char *collected_addresses;
95 extern struct addresses_to_be_filed *atbf;
97 void cmd_msgs (char *cmdbuf);
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 *, const char *, int);
112 void quickie_message(const char *from,
113 const char *fromaddr,
118 const char *subject);
120 void flood_protect_quickie_message(const char *from,
121 const char *fromaddr,
128 const char **CritStr,
134 void cmd_ent0 (char *entargs);
135 void cmd_dele (char *delstr);
136 void cmd_move (char *args);
137 void GetMetaData(struct MetaData *, long);
138 void PutMetaData(struct MetaData *);
139 void AdjRefCount(long, int);
140 void TDAP_AdjRefCount(long, int);
141 int TDAP_ProcessAdjRefCountQueue(void);
142 void simple_listing(long, void *);
143 int CtdlMsgCmp(struct CtdlMessage *msg, struct CtdlMessage *template);
144 typedef void (*ForEachMsgCallback)(long MsgNumber, void *UserData);
145 int CtdlForEachMessage(int mode,
149 struct CtdlMessage *compare,
150 ForEachMsgCallback CallBack,
152 int CtdlDeleteMessages(char *, long *, int, char *);
153 void CtdlWriteObject(char *req_room, /* Room to stuff it in */
154 char *content_type, /* MIME type of this object */
155 char *raw_message, /* Data to be written */
156 off_t raw_length, /* Size of raw_message */
157 struct ctdluser *is_mailbox, /* Mailbox room? */
158 int is_binary, /* Is encoding necessary? */
159 int is_unique, /* Del others of this type? */
160 unsigned int flags /* Internal save flags */
162 struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body);
163 struct CtdlMessage * CM_Duplicate
164 (struct CtdlMessage *OrgMsg);
165 int CM_IsEmpty (struct CtdlMessage *Msg, eMsgField which);
166 void CM_SetField (struct CtdlMessage *Msg, eMsgField which, const char *buf, long length);
167 void CM_SetFieldLONG (struct CtdlMessage *Msg, eMsgField which, long lvalue);
168 void CM_CopyField (struct CtdlMessage *Msg, eMsgField WhichToPutTo, eMsgField WhichtToCopy);
169 void CM_CutFieldAt (struct CtdlMessage *Msg, eMsgField WhichToCut, long maxlen);
170 void CM_FlushField (struct CtdlMessage *Msg, eMsgField which);
171 void CM_SetAsField (struct CtdlMessage *Msg, eMsgField which, char **buf, long length);
172 void CM_SetAsFieldSB (struct CtdlMessage *Msg, eMsgField which, StrBuf **buf);
173 void CM_GetAsField (struct CtdlMessage *Msg, eMsgField which, char **ret, long *retlen);
174 void CM_PrependToField (struct CtdlMessage *Msg, eMsgField which, const char *buf, long length);
176 void CM_Free (struct CtdlMessage *msg);
177 void CM_FreeContents (struct CtdlMessage *msg);
178 int CM_IsValidMsg (struct CtdlMessage *msg);
180 void serialize_message(struct ser_ret *, struct CtdlMessage *);
181 void ReplicationChecks(struct CtdlMessage *);
182 int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newmsgs,
183 int do_repl_check, struct CtdlMessage *supplied_msg, int suppress_refcount_adj);
184 int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int do_repl_check, struct CtdlMessage *msg);
185 char *CtdlReadMessageBody(char *terminator, long tlen, size_t maxlen, StrBuf *exist, int crlf, int *sock);
186 StrBuf *CtdlReadMessageBodyBuf(char *terminator, /* token signalling EOT */
188 size_t maxlen, /* maximum message length */
189 StrBuf *exist, /* if non-null, append to it;
190 exist is ALWAYS freed */
191 int crlf, /* CRLF newlines instead of LF */
192 int *sock /* socket handle or 0 for this session's client socket */
195 int CtdlOutputMsg(long msg_num, /* message number (local) to fetch */
196 int mode, /* how would you like that message? */
197 int headers_only, /* eschew the message body? */
198 int do_proto, /* do Citadel protocol responses? */
199 int crlf, /* 0=LF, 1=CRLF */
200 char *section, /* output a message/rfc822 section */
201 int flags, /* should the bessage be exported clean? */
202 char **Author, /* if you want to know the author of the message... */
203 char **Address /* if you want to know the sender address of the message... */
206 /* Flags which may be passed to CtdlOutputMsg() and CtdlOutputPreLoadedMsg() */
207 #define QP_EADDR (1<<0) /* quoted-printable encode email addresses */
209 #define ESC_DOT (1<<2) /* output a line containing only "." as ".." instead */
210 #define SUPPRESS_ENV_TO (1<<3) /* suppress Envelope-to: header (warning: destructive!) */
212 int CtdlOutputPreLoadedMsg(struct CtdlMessage *,
213 int mode, /* how would you like that message? */
214 int headers_only, /* eschew the message body? */
215 int do_proto, /* do Citadel protocol responses? */
216 int crlf, /* 0=LF, 1=CRLF */
217 int flags /* should the bessage be exported clean? */
221 /* values for which_set */
226 void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
227 int target_setting, int which_set,
228 struct ctdluser *which_user, struct ctdlroom *which_room);
229 void CtdlGetSeen(char *buf, int which_set);
231 struct recptypes *validate_recipients(const char *recipients,
232 const char *RemoteIdentifier,
235 void free_recipients(struct recptypes *);
237 struct CtdlMessage *CtdlMakeMessage(
238 struct ctdluser *author, /* author's user structure */
239 char *recipient, /* NULL if it's not mail */
240 char *recp_cc, /* NULL if it's not mail */
241 char *room, /* room where it's going */
242 int type, /* see MES_ types in header file */
243 int format_type, /* variformat, plain text, MIME... */
244 char *fake_name, /* who we're masquerading as */
245 char *my_email, /* which of my email addresses to use (empty is ok) */
246 char *subject, /* Subject (optional) */
247 char *supplied_euid, /* ...or NULL if this is irrelevant */
248 char *preformatted_text, /* ...or NULL to read text from client */
249 char *references /* Thread references */
251 int CtdlIsMe(char *addr, int addr_buf_len);
254 * loading messages async via an FD:
255 * add IO->ReadMsg = NewAsyncMsg(...)
256 * and then call CtdlReadMessageBodyAsync() from your linreader handler.
259 ReadAsyncMsg *NewAsyncMsg(const char *terminator, /* token signalling EOT */
261 size_t expectlen, /* if we expect a message, how long should it be? */
262 size_t maxlen, /* maximum message length */
263 StrBuf *exist, /* if non-null, append to it;
264 exist is ALWAYS freed */
265 long eLen, /* length of exist */
266 int crlf /* CRLF newlines instead of LF */
269 eReadState CtdlReadMessageBodyAsync(AsyncIO *IO);
270 void DeleteAsyncMsg(ReadAsyncMsg **Msg);
272 extern int MessageDebugEnabled;
274 #define MSGDBGLOG(LEVEL) if ((LEVEL != LOG_DEBUG) || (MessageDebugEnabled != 0))
275 #define CCCID CCC->cs_pid
276 #define MSG_syslog(LEVEL, FORMAT, ...) \
277 MSGDBGLOG(LEVEL) syslog(LEVEL, \
278 "CC[%d]MSG" FORMAT, \
281 #define MSGM_syslog(LEVEL, FORMAT) \
282 MSGDBGLOG(LEVEL) syslog(LEVEL, \
283 "CC[%d]MSG" FORMAT, \
288 #endif /* MSGBASE_H */