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