Now the escaping of a single dot on a line of its own is done in CtdlOutputPreloadedMsg()
[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,0,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 };
70
71 #define RECPTYPES_MAGIC 0xfeeb
72
73 /*
74  * This is a list of "harvested" email addresses that we might want to
75  * stick into someone's address book.  But we defer this operaiton so
76  * it can be done asynchronously.
77  */
78 struct addresses_to_be_filed {
79         struct addresses_to_be_filed *next;
80         char *roomname;
81         char *collected_addresses;
82 };
83
84 extern struct addresses_to_be_filed *atbf;
85
86 int alias (char *name);
87 void cmd_msgs (char *cmdbuf);
88 void cmd_isme (char *cmdbuf);
89 void help_subst (char *strbuf, char *source, char *dest);
90 void do_help_subst (char *buffer);
91 void memfmout (char *mptr, char subst, char *nl);
92 void output_mime_parts(char *);
93 void cmd_msg0 (char *cmdbuf);
94 void cmd_msg2 (char *cmdbuf);
95 void cmd_msg3 (char *cmdbuf);
96 void cmd_msg4 (char *cmdbuf);
97 void cmd_msgp (char *cmdbuf);
98 void cmd_opna (char *cmdbuf);
99 void cmd_dlat (char *cmdbuf);
100 long send_message (struct CtdlMessage *);
101 void loadtroom (void);
102 long CtdlSubmitMsg(struct CtdlMessage *, struct recptypes *, char *, int);
103 void quickie_message (char *, char *, char *, char *, char *, int, char *);
104 void cmd_ent0 (char *entargs);
105 void cmd_dele (char *delstr);
106 void cmd_move (char *args);
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 int CtdlForEachMessage(int mode,
115                         long ref,
116                         char *searchstring,
117                         char *content_type,
118                         struct CtdlMessage *compare,
119                         void (*CallBack) (long, void *),
120                         void *userdata);
121 int CtdlDeleteMessages(char *, long *, int, char *);
122 void CtdlWriteObject(char *, char *, char *, struct ctdluser *,
123                         int, int, unsigned int);
124 struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body);
125 void CtdlFreeMessage(struct CtdlMessage *msg);
126 void serialize_message(struct ser_ret *, struct CtdlMessage *);
127 void dump_message(struct CtdlMessage *msg, long Siz);
128 int is_valid_message(struct CtdlMessage *);
129 void ReplicationChecks(struct CtdlMessage *);
130 int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newmsgs,
131                                 int do_repl_check, struct CtdlMessage *supplied_msg);
132 int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int do_repl_check, struct CtdlMessage *msg);
133 char *CtdlReadMessageBody(char *terminator, size_t maxlen, char *exist, int crlf, int sock);
134 char *CtdlGetSysConfig(char *sysconfname);
135 void CtdlPutSysConfig(char *sysconfname, char *sysconfdata);
136 int CtdlOutputMsg(long msg_num,         /* message number (local) to fetch */
137                   int mode,             /* how would you like that message? */
138                   int headers_only,     /* eschew the message body? */
139                   int do_proto,         /* do Citadel protocol responses? */
140                   int crlf,             /* 0=LF, 1=CRLF */
141                   char *section,                /* output a message/rfc822 section */
142                   int flags             /* should the bessage be exported clean? */
143 );
144
145 #define QP_EADDR (1<<0)
146 #define CRLF (1<<1)
147 #define ESC_DOT (1<<2)
148
149 int CtdlOutputPreLoadedMsg(struct CtdlMessage *,
150                            int mode,            /* how would you like that message? */
151                            int headers_only,    /* eschew the message body? */
152                            int do_proto,                /* do Citadel protocol responses? */
153                            int crlf,            /* 0=LF, 1=CRLF */
154                            int flags            /* should the bessage be exported clean? */
155 );
156 int CtdlCopyMsgsToRoom(long *msgnum, int num_msgs, char *dest);
157 int CtdlDoIHavePermissionToDeleteMessagesFromThisRoom(void);
158
159 enum {
160         POST_LOGGED_IN,
161         POST_EXTERNAL,
162         CHECK_EXISTANCE,
163         POST_LMTP
164 };
165 int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf, 
166                                           size_t n, 
167                                           const char* RemoteIdentifier,
168                                           int PostPublic);
169
170
171 /* values for which_set */
172 enum {
173         ctdlsetseen_seen,
174         ctdlsetseen_answered
175 };
176 void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
177                  int target_setting, int which_set,
178                 struct ctdluser *which_user, struct ctdlroom *which_room);
179 void CtdlGetSeen(char *buf, int which_set);
180
181 struct recptypes *validate_recipients(char *recipients,
182                                       const char *RemoteIdentifier, 
183                                       int Flags);
184
185 void free_recipients(struct recptypes *);
186
187 struct CtdlMessage *CtdlMakeMessage(
188         struct ctdluser *author,        /* author's user structure */
189         char *recipient,                /* NULL if it's not mail */
190         char *recp_cc,                  /* NULL if it's not mail */
191         char *room,                     /* room where it's going */
192         int type,                       /* see MES_ types in header file */
193         int format_type,                /* variformat, plain text, MIME... */
194         char *fake_name,                /* who we're masquerading as */
195         char *my_email,                 /* which of my email addresses to use (empty is ok) */
196         char *subject,                  /* Subject (optional) */
197         char *supplied_euid,            /* ...or NULL if this is irrelevant */
198         char *preformatted_text,        /* ...or NULL to read text from client */
199         char *references                /* Thread references */
200 );
201 int CtdlCheckInternetMailPermission(struct ctdluser *who);
202 int CtdlIsMe(char *addr, int addr_buf_len);
203
204 #endif /* MSGBASE_H */