* add outfunction to MSGS that just outputs ID|EUID
[citadel.git] / citadel / msgbase.h
1 /* $Id$ */
2
3 #ifndef MSGBASE_H
4 #define MSGBASE_H
5
6
7 enum {
8         MSGS_ALL,
9         MSGS_OLD,
10         MSGS_NEW,
11         MSGS_FIRST,
12         MSGS_LAST,
13         MSGS_GT,
14         MSGS_EQ,
15         MSGS_SEARCH
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 };
52
53
54 struct repl {                   /* Info for replication checking */
55         char exclusive_id[SIZ];
56         time_t highest;
57 };
58
59
60 /* Data structure returned by validate_recipients() */
61 struct recptypes {
62         int recptypes_magic;
63         int num_local;
64         int num_internet;
65         int num_ignet;
66         int num_room;
67         int num_error;
68         char *errormsg;
69         char *recp_local;
70         char *recp_internet;
71         char *recp_ignet;
72         char *recp_room;
73         char *display_recp;
74         char *bounce_to;
75         char *envelope_from;
76 };
77
78 #define RECPTYPES_MAGIC 0xfeeb
79
80 /*
81  * This is a list of "harvested" email addresses that we might want to
82  * stick into someone's address book.  But we defer this operaiton so
83  * it can be done asynchronously.
84  */
85 struct addresses_to_be_filed {
86         struct addresses_to_be_filed *next;
87         char *roomname;
88         char *collected_addresses;
89 };
90
91 extern struct addresses_to_be_filed *atbf;
92
93 int alias (char *name);
94 void cmd_msgs (char *cmdbuf);
95 void cmd_isme (char *cmdbuf);
96 void help_subst (char *strbuf, char *source, char *dest);
97 void do_help_subst (char *buffer);
98 void memfmout (char *mptr, char subst, char *nl);
99 void output_mime_parts(char *);
100 void cmd_msg0 (char *cmdbuf);
101 void cmd_msg2 (char *cmdbuf);
102 void cmd_msg3 (char *cmdbuf);
103 void cmd_msg4 (char *cmdbuf);
104 void cmd_msgp (char *cmdbuf);
105 void cmd_opna (char *cmdbuf);
106 void cmd_dlat (char *cmdbuf);
107 long send_message (struct CtdlMessage *);
108 void loadtroom (void);
109 long CtdlSubmitMsg(struct CtdlMessage *, struct recptypes *, char *, int);
110 void quickie_message (const char *, const char *, char *, char *, const char *, int, const char *);
111 void cmd_ent0 (char *entargs);
112 void cmd_dele (char *delstr);
113 void cmd_move (char *args);
114 void GetMetaData(struct MetaData *, long);
115 void PutMetaData(struct MetaData *);
116 void AdjRefCount(long, int);
117 void TDAP_AdjRefCount(long, int);
118 int TDAP_ProcessAdjRefCountQueue(void);
119 void simple_listing(long, void *);
120 int CtdlMsgCmp(struct CtdlMessage *msg, struct CtdlMessage *template);
121 typedef void (*ForEachMsgCallback)(long MsgNumber, void *UserData);
122 int CtdlForEachMessage(int mode,
123                         long ref,
124                         char *searchstring,
125                         char *content_type,
126                         struct CtdlMessage *compare,
127                         ForEachMsgCallback CallBack,
128                         void *userdata);
129 int CtdlDeleteMessages(char *, long *, int, char *);
130 void CtdlWriteObject(char *req_room,                    /* Room to stuff it in */
131                         char *content_type,             /* MIME type of this object */
132                         char *raw_message,              /* Data to be written */
133                         off_t raw_length,               /* Size of raw_message */
134                         struct ctdluser *is_mailbox,    /* Mailbox room? */
135                         int is_binary,                  /* Is encoding necessary? */
136                         int is_unique,                  /* Del others of this type? */
137                         unsigned int flags              /* Internal save flags */
138 );
139 struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body);
140 void CtdlFreeMessage(struct CtdlMessage *msg);
141 void serialize_message(struct ser_ret *, struct CtdlMessage *);
142 void dump_message(struct CtdlMessage *msg, long Siz);
143 int is_valid_message(struct CtdlMessage *);
144 void ReplicationChecks(struct CtdlMessage *);
145 int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newmsgs,
146                                 int do_repl_check, struct CtdlMessage *supplied_msg);
147 int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int do_repl_check, struct CtdlMessage *msg);
148 char *CtdlReadMessageBody(char *terminator, size_t maxlen, char *exist, int crlf, int sock);
149 char *CtdlGetSysConfig(char *sysconfname);
150 void CtdlPutSysConfig(char *sysconfname, char *sysconfdata);
151 int CtdlOutputMsg(long msg_num,         /* message number (local) to fetch */
152                   int mode,             /* how would you like that message? */
153                   int headers_only,     /* eschew the message body? */
154                   int do_proto,         /* do Citadel protocol responses? */
155                   int crlf,             /* 0=LF, 1=CRLF */
156                   char *section,                /* output a message/rfc822 section */
157                   int flags             /* should the bessage be exported clean? */
158 );
159
160 /* Flags which may be passed to CtdlOutputMsg() and CtdlOutputPreLoadedMsg() */
161 #define QP_EADDR        (1<<0)          /* quoted-printable encode email addresses */
162 #define CRLF            (1<<1)
163 #define ESC_DOT         (1<<2)          /* output a line containing only "." as ".." instead */
164 #define SUPPRESS_ENV_TO (1<<3)          /* suppress Envelope-to: header (warning: destructive!) */
165
166 int CtdlOutputPreLoadedMsg(struct CtdlMessage *,
167                            int mode,            /* how would you like that message? */
168                            int headers_only,    /* eschew the message body? */
169                            int do_proto,        /* do Citadel protocol responses? */
170                            int crlf,            /* 0=LF, 1=CRLF */
171                            int flags            /* should the bessage be exported clean? */
172 );
173 int CtdlDoIHavePermissionToDeleteMessagesFromThisRoom(void);
174 int CtdlDoIHavePermissionToReadMessagesInThisRoom(void);
175
176 enum {
177         POST_LOGGED_IN,
178         POST_EXTERNAL,
179         CHECK_EXISTANCE,
180         POST_LMTP
181 };
182 int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf, 
183                                           size_t n, 
184                                           const char* RemoteIdentifier,
185                                           int PostPublic);
186
187
188 /* values for which_set */
189 enum {
190         ctdlsetseen_seen,
191         ctdlsetseen_answered
192 };
193 void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
194                  int target_setting, int which_set,
195                 struct ctdluser *which_user, struct ctdlroom *which_room);
196 void CtdlGetSeen(char *buf, int which_set);
197
198 struct recptypes *validate_recipients(char *recipients,
199                                       const char *RemoteIdentifier, 
200                                       int Flags);
201
202 void free_recipients(struct recptypes *);
203
204 struct CtdlMessage *CtdlMakeMessage(
205         struct ctdluser *author,        /* author's user structure */
206         char *recipient,                /* NULL if it's not mail */
207         char *recp_cc,                  /* NULL if it's not mail */
208         char *room,                     /* room where it's going */
209         int type,                       /* see MES_ types in header file */
210         int format_type,                /* variformat, plain text, MIME... */
211         char *fake_name,                /* who we're masquerading as */
212         char *my_email,                 /* which of my email addresses to use (empty is ok) */
213         char *subject,                  /* Subject (optional) */
214         char *supplied_euid,            /* ...or NULL if this is irrelevant */
215         char *preformatted_text,        /* ...or NULL to read text from client */
216         char *references                /* Thread references */
217 );
218 int CtdlCheckInternetMailPermission(struct ctdluser *who);
219 int CtdlIsMe(char *addr, int addr_buf_len);
220
221 /*
222  * Use of aide_message is deprecated.
223  * It has been replaced with CtdlAideMessage.
224  * All parameters remain the same.
225 */
226 void aide_message(char *text, char *subject) __attribute__ ((deprecated));
227
228
229
230 #endif /* MSGBASE_H */