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];
64 * This is a list of "harvested" email addresses that we might want to
65 * stick into someone's address book. But we defer this operaiton so
66 * it can be done asynchronously.
68 struct addresses_to_be_filed {
69 struct addresses_to_be_filed *next;
71 char *collected_addresses;
74 extern struct addresses_to_be_filed *atbf;
76 int GetFieldFromMnemonic(eMsgField *f, const char* c);
79 void memfmout (char *mptr, const char *nl);
80 void output_mime_parts(char *);
81 long send_message (struct CtdlMessage *);
82 void loadtroom (void);
83 long CtdlSubmitMsg(struct CtdlMessage *, recptypes *, const char *, int);
85 void quickie_message(const char *from,
93 void flood_protect_quickie_message(const char *from,
101 const char **CritStr,
102 const long *CritStrLen,
107 void GetMetaData(struct MetaData *, long);
108 void PutMetaData(struct MetaData *);
109 void AdjRefCount(long, int);
110 void TDAP_AdjRefCount(long, int);
111 int TDAP_ProcessAdjRefCountQueue(void);
112 void simple_listing(long, void *);
113 int CtdlMsgCmp(struct CtdlMessage *msg, struct CtdlMessage *template);
114 typedef void (*ForEachMsgCallback)(long MsgNumber, void *UserData);
115 int CtdlForEachMessage(int mode,
119 struct CtdlMessage *compare,
120 ForEachMsgCallback CallBack,
122 int CtdlDeleteMessages(const char *, long *, int, char *);
123 void CtdlWriteObject(char *req_room, /* Room to stuff it in */
124 char *content_type, /* MIME type of this object */
125 char *raw_message, /* Data to be written */
126 off_t raw_length, /* Size of raw_message */
127 struct ctdluser *is_mailbox, /* Mailbox room? */
128 int is_binary, /* Is encoding necessary? */
129 int is_unique, /* Del others of this type? */
130 unsigned int flags /* Internal save flags */
132 struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body, int run_msg_hooks);
133 struct CtdlMessage * CM_Duplicate
134 (struct CtdlMessage *OrgMsg);
135 int CM_IsEmpty (struct CtdlMessage *Msg, eMsgField which);
136 void CM_SetField (struct CtdlMessage *Msg, eMsgField which, const char *buf, long length);
137 void CM_SetFieldLONG (struct CtdlMessage *Msg, eMsgField which, long lvalue);
138 void CM_CopyField (struct CtdlMessage *Msg, eMsgField WhichToPutTo, eMsgField WhichtToCopy);
139 void CM_CutFieldAt (struct CtdlMessage *Msg, eMsgField WhichToCut, long maxlen);
140 void CM_FlushField (struct CtdlMessage *Msg, eMsgField which);
141 void CM_Flush (struct CtdlMessage *Msg);
142 void CM_SetAsField (struct CtdlMessage *Msg, eMsgField which, char **buf, long length);
143 void CM_SetAsFieldSB (struct CtdlMessage *Msg, eMsgField which, StrBuf **buf);
144 void CM_GetAsField (struct CtdlMessage *Msg, eMsgField which, char **ret, long *retlen);
145 void CM_PrependToField (struct CtdlMessage *Msg, eMsgField which, const char *buf, long length);
147 void CM_Free (struct CtdlMessage *msg);
148 void CM_FreeContents (struct CtdlMessage *msg);
149 int CM_IsValidMsg (struct CtdlMessage *msg);
151 #define CM_KEY(Message, Which) Message->cm_fields[Which], Message->cm_lengths[Which]
152 #define CM_RANGE(Message, Which) Message->cm_fields[Which], \
153 Message->cm_fields[Which] + Message->cm_lengths[Which]
155 void CtdlSerializeMessage(struct ser_ret *, struct CtdlMessage *);
156 struct CtdlMessage *CtdlDeserializeMessage(long msgnum, int with_body, const char *Buffer, long Length);
157 void ReplicationChecks(struct CtdlMessage *);
158 int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newmsgs,
159 int do_repl_check, struct CtdlMessage *supplied_msg, int suppress_refcount_adj);
160 int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int do_repl_check, struct CtdlMessage *msg);
161 long CtdlSaveThisMessage(struct CtdlMessage *msg, long msgid, int Reply);
162 char *CtdlReadMessageBody(char *terminator, long tlen, size_t maxlen, StrBuf *exist, int crlf, int *sock);
163 StrBuf *CtdlReadMessageBodyBuf(char *terminator, /* token signalling EOT */
165 size_t maxlen, /* maximum message length */
166 StrBuf *exist, /* if non-null, append to it;
167 exist is ALWAYS freed */
168 int crlf, /* CRLF newlines instead of LF */
169 int *sock /* socket handle or 0 for this session's client socket */
172 int CtdlOutputMsg(long msg_num, /* message number (local) to fetch */
173 int mode, /* how would you like that message? */
174 int headers_only, /* eschew the message body? */
175 int do_proto, /* do Citadel protocol responses? */
176 int crlf, /* 0=LF, 1=CRLF */
177 char *section, /* output a message/rfc822 section */
178 int flags, /* should the bessage be exported clean? */
179 char **Author, /* if you want to know the author of the message... */
180 char **Address, /* if you want to know the sender address of the message... */
181 char **MessageID /* if you want to know the Message-ID of the message... */
184 /* Flags which may be passed to CtdlOutputMsg() and CtdlOutputPreLoadedMsg() */
185 #define QP_EADDR (1<<0) /* quoted-printable encode email addresses */
187 #define ESC_DOT (1<<2) /* output a line containing only "." as ".." instead */
188 #define SUPPRESS_ENV_TO (1<<3) /* suppress Envelope-to: header (warning: destructive!) */
190 int CtdlOutputPreLoadedMsg(struct CtdlMessage *,
191 int mode, /* how would you like that message? */
192 int headers_only, /* eschew the message body? */
193 int do_proto, /* do Citadel protocol responses? */
194 int crlf, /* 0=LF, 1=CRLF */
195 int flags /* should the bessage be exported clean? */
199 /* values for which_set */
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);
210 struct CtdlMessage *CtdlMakeMessage(
211 struct ctdluser *author, /* author's user structure */
212 char *recipient, /* NULL if it's not mail */
213 char *recp_cc, /* NULL if it's not mail */
214 char *room, /* room where it's going */
215 int type, /* see MES_ types in header file */
216 int format_type, /* variformat, plain text, MIME... */
217 char *fake_name, /* who we're masquerading as */
218 char *my_email, /* which of my email addresses to use (empty is ok) */
219 char *subject, /* Subject (optional) */
220 char *supplied_euid, /* ...or NULL if this is irrelevant */
221 char *preformatted_text, /* ...or NULL to read text from client */
222 char *references /* Thread references */
225 struct CtdlMessage *CtdlMakeMessageLen(
226 struct ctdluser *author, /* author's user structure */
227 char *recipient, /* NULL if it's not mail */
229 char *recp_cc, /* NULL if it's not mail */
231 char *room, /* room where it's going */
233 int type, /* see MES_ types in header file */
234 int format_type, /* variformat, plain text, MIME... */
235 char *fake_name, /* who we're masquerading as */
237 char *my_email, /* which of my email addresses to use (empty is ok) */
239 char *subject, /* Subject (optional) */
241 char *supplied_euid, /* ...or NULL if this is irrelevant */
243 char *preformatted_text, /* ...or NULL to read text from client */
245 char *references, /* Thread references */
249 * loading messages async via an FD:
250 * add IO->ReadMsg = NewAsyncMsg(...)
251 * and then call CtdlReadMessageBodyAsync() from your linreader handler.
254 ReadAsyncMsg *NewAsyncMsg(const char *terminator, /* token signalling EOT */
256 size_t expectlen, /* if we expect a message, how long should it be? */
257 size_t maxlen, /* maximum message length */
258 StrBuf *exist, /* if non-null, append to it;
259 exist is ALWAYS freed */
260 long eLen, /* length of exist */
261 int crlf /* CRLF newlines instead of LF */
264 eReadState CtdlReadMessageBodyAsync(AsyncIO *IO);
265 void DeleteAsyncMsg(ReadAsyncMsg **Msg);
267 extern int MessageDebugEnabled;
269 #define MSGDBGLOG(LEVEL) if ((LEVEL != LOG_DEBUG) || (MessageDebugEnabled != 0))
270 #define CCCID CCC->cs_pid
271 #define MSG_syslog(LEVEL, FORMAT, ...) \
272 MSGDBGLOG(LEVEL) syslog(LEVEL, \
273 "CC[%d]MSG " FORMAT, \
276 #define MSGM_syslog(LEVEL, FORMAT) \
277 MSGDBGLOG(LEVEL) syslog(LEVEL, \
278 "CC[%d]MSG " FORMAT, \
283 #endif /* MSGBASE_H */