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