MSGS command can now do full text search on the room
[citadel.git] / citadel / msgbase.h
1 /* $Id$ */
2
3 #define aide_message(text)      quickie_message("Citadel",NULL,AIDEROOM,text,0,NULL)
4
5 enum {
6         MSGS_ALL,
7         MSGS_OLD,
8         MSGS_NEW,
9         MSGS_FIRST,
10         MSGS_LAST,
11         MSGS_GT,
12         MSGS_EQ,
13         MSGS_SEARCH
14 };
15
16 /*
17  * Possible return codes from CtdlOutputMsg()
18  */
19 enum {
20         om_ok,
21         om_not_logged_in,
22         om_no_such_msg,
23         om_mime_error
24 };
25
26 /*
27  * Values of "headers_only" when calling message output routines
28  */
29 #define HEADERS_ALL     0       /* Headers and body */
30 #define HEADERS_ONLY    1       /* Headers only */
31 #define HEADERS_NONE    2       /* Body only */
32 #define HEADERS_FAST    3       /* Headers only with no MIME info */
33
34
35 struct ma_info {
36         int is_ma;              /* Set to 1 if we are using this stuff */
37         int freeze;             /* Freeze the replacement chain because we're
38                                  * digging through a subsection */
39         int did_print;          /* One alternative has been displayed */
40         char chosen_part[128];  /* Which part of a m/a did we choose? */
41         int use_fo_hooks;       /* Use fixed output hooks */
42 };
43
44
45 struct repl {                   /* Info for replication checking */
46         char exclusive_id[SIZ];
47         time_t highest;
48 };
49
50
51 /* Data structure returned by validate_recipients() */
52 struct recptypes {
53         int num_local;
54         int num_internet;
55         int num_ignet;
56         int num_room;
57         int num_error;
58         char errormsg[SIZ];
59         char recp_local[SIZ];
60         char recp_internet[SIZ];
61         char recp_ignet[SIZ];
62         char recp_room[SIZ];
63         char display_recp[SIZ];
64 };
65
66 /*
67  * This is a list of "harvested" email addresses that we might want to
68  * stick into someone's address book.  But we defer this operaiton so
69  * it can be done asynchronously.
70  */
71 struct addresses_to_be_filed {
72         struct addresses_to_be_filed *next;
73         char *roomname;
74         char *collected_addresses;
75 };
76
77 extern struct addresses_to_be_filed *atbf;
78
79 int alias (char *name);
80 void get_mm (void);
81 void cmd_msgs (char *cmdbuf);
82 void cmd_isme (char *cmdbuf);
83 void help_subst (char *strbuf, char *source, char *dest);
84 void do_help_subst (char *buffer);
85 void memfmout (char *mptr, char subst, char *nl);
86 void output_mime_parts(char *);
87 void cmd_msg0 (char *cmdbuf);
88 void cmd_msg2 (char *cmdbuf);
89 void cmd_msg3 (char *cmdbuf);
90 void cmd_msg4 (char *cmdbuf);
91 void cmd_msgp (char *cmdbuf);
92 void cmd_opna (char *cmdbuf);
93 long send_message (struct CtdlMessage *);
94 void loadtroom (void);
95 long CtdlSubmitMsg(struct CtdlMessage *, struct recptypes *, char *);
96 void quickie_message (char *, char *, char *, char *, int, char *);
97 void cmd_ent0 (char *entargs);
98 void cmd_dele (char *delstr);
99 void cmd_move (char *args);
100 void GetMetaData(struct MetaData *, long);
101 void PutMetaData(struct MetaData *);
102 void AdjRefCount(long, int);
103 void simple_listing(long, void *);
104 int CtdlMsgCmp(struct CtdlMessage *msg, struct CtdlMessage *template);
105 int CtdlForEachMessage(int mode,
106                         long ref,
107                         char *searchstring,
108                         char *content_type,
109                         struct CtdlMessage *compare,
110                         void (*CallBack) (long, void *),
111                         void *userdata);
112 int CtdlDeleteMessages(char *, long *, int, char *, int);
113 void CtdlWriteObject(char *, char *, char *, struct ctdluser *,
114                         int, int, unsigned int);
115 struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body);
116 void CtdlFreeMessage(struct CtdlMessage *msg);
117 void serialize_message(struct ser_ret *, struct CtdlMessage *);
118 int is_valid_message(struct CtdlMessage *);
119 void ReplicationChecks(struct CtdlMessage *);
120 int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newmsgs,
121                                 int do_repl_check, struct CtdlMessage *supplied_msg);
122 int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int do_repl_check, struct CtdlMessage *msg);
123 char *CtdlReadMessageBody(char *terminator, size_t maxlen, char *exist, int crlf);
124 char *CtdlGetSysConfig(char *sysconfname);
125 void CtdlPutSysConfig(char *sysconfname, char *sysconfdata);
126 int CtdlOutputMsg(long msg_num,         /* message number (local) to fetch */
127                 int mode,               /* how would you like that message? */
128                 int headers_only,       /* eschew the message body? */
129                 int do_proto,           /* do Citadel protocol responses? */
130                 int crlf,               /* 0=LF, 1=CRLF */
131                 char *section           /* output a message/rfc822 section */
132 );
133 int CtdlOutputPreLoadedMsg(struct CtdlMessage *,
134                 int mode,               /* how would you like that message? */
135                 int headers_only,       /* eschew the message body? */
136                 int do_proto,           /* do Citadel protocol responses? */
137                 int crlf                /* 0=LF, 1=CRLF */
138 );
139 int CtdlCopyMsgsToRoom(long *msgnum, int num_msgs, char *dest);
140 int CtdlDoIHavePermissionToDeleteMessagesFromThisRoom(void);
141 int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf, size_t n);
142
143
144 /* values for which_set */
145 enum {
146         ctdlsetseen_seen,
147         ctdlsetseen_answered
148 };
149 void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
150                  int target_setting, int which_set,
151                 struct ctdluser *which_user, struct ctdlroom *which_room);
152 void CtdlGetSeen(char *buf, int which_set);
153
154 struct recptypes *validate_recipients(char *recipients);
155 struct CtdlMessage *CtdlMakeMessage(
156         struct ctdluser *author,        /* author's user structure */
157         char *recipient,                /* NULL if it's not mail */
158         char *recp_cc,                  /* NULL if it's not mail */
159         char *room,                     /* room where it's going */
160         int type,                       /* see MES_ types in header file */
161         int format_type,                /* variformat, plain text, MIME... */
162         char *fake_name,                /* who we're masquerading as */
163         char *subject,                  /* Subject (optional) */
164         char *supplied_euid,            /* ...or NULL if this is irrelevant */
165         char *preformatted_text         /* ...or NULL to read text from client */
166 );
167 int CtdlCheckInternetMailPermission(struct ctdluser *who);
168 int CtdlIsMe(char *addr, int addr_buf_len);