Back to index

citadel  8.12
msgbase.h
Go to the documentation of this file.
00001 
00002 #ifndef MSGBASE_H
00003 #define MSGBASE_H
00004 
00005 #include "event_client.h"
00006 enum {
00007        MSGS_ALL,
00008        MSGS_OLD,
00009        MSGS_NEW,
00010        MSGS_FIRST,
00011        MSGS_LAST,
00012        MSGS_GT,
00013        MSGS_EQ,
00014        MSGS_SEARCH,
00015        MSGS_LT
00016 };
00017 
00018 enum {
00019        MSG_HDRS_BRIEF = 0,
00020        MSG_HDRS_ALL = 1,
00021        MSG_HDRS_EUID = 4
00022 };
00023 
00024 /*
00025  * Possible return codes from CtdlOutputMsg()
00026  */
00027 enum {
00028        om_ok,
00029        om_not_logged_in,
00030        om_no_such_msg,
00031        om_mime_error,
00032        om_access_denied
00033 };
00034 
00035 /*
00036  * Values of "headers_only" when calling message output routines
00037  */
00038 #define HEADERS_ALL  0      /* Headers and body */
00039 #define       HEADERS_ONLY  1      /* Headers only */
00040 #define       HEADERS_NONE  2      /* Body only */
00041 #define HEADERS_FAST 3      /* Headers only with no MIME info */
00042 
00043 
00044 struct ma_info {
00045        int is_ma;           /* Set to 1 if we are using this stuff */
00046        int freeze;          /* Freeze the replacement chain because we're
00047                              * digging through a subsection */
00048        int did_print;              /* One alternative has been displayed */
00049        char chosen_part[128];      /* Which part of a m/a did we choose? */
00050        int chosen_pref;     /* Chosen part preference level (lower is better) */
00051        int use_fo_hooks;    /* Use fixed output hooks */
00052        int dont_decode;        /* should we call the decoder or not? */
00053 };
00054 
00055 
00056 struct repl {               /* Info for replication checking */
00057        char exclusive_id[SIZ];
00058        time_t highest;
00059 };
00060 
00061 
00062 /* Data structure returned by validate_recipients() */
00063 struct recptypes {
00064        int recptypes_magic;
00065         int num_local;
00066         int num_internet;
00067         int num_ignet;
00068        int num_room;
00069         int num_error;
00070        char *errormsg;
00071        char *recp_local;
00072        char *recp_internet;
00073        char *recp_ignet;
00074        char *recp_room;
00075        char *recp_orgroom;
00076        char *display_recp;
00077        char *bounce_to;
00078        char *envelope_from;
00079        char *sending_room;
00080 };
00081 
00082 #define RECPTYPES_MAGIC 0xfeeb
00083 
00084 /*
00085  * This is a list of "harvested" email addresses that we might want to
00086  * stick into someone's address book.  But we defer this operaiton so
00087  * it can be done asynchronously.
00088  */
00089 struct addresses_to_be_filed {
00090        struct addresses_to_be_filed *next;
00091        char *roomname;
00092        char *collected_addresses;
00093 };
00094 
00095 extern struct addresses_to_be_filed *atbf;
00096 
00097 int alias (char *name);
00098 void cmd_msgs (char *cmdbuf);
00099 void cmd_isme (char *cmdbuf);
00100 void help_subst (char *strbuf, char *source, char *dest);
00101 void do_help_subst (char *buffer);
00102 void memfmout (char *mptr, const char *nl);
00103 void output_mime_parts(char *);
00104 void cmd_msg0 (char *cmdbuf);
00105 void cmd_msg2 (char *cmdbuf);
00106 void cmd_msg3 (char *cmdbuf);
00107 void cmd_msg4 (char *cmdbuf);
00108 void cmd_msgp (char *cmdbuf);
00109 void cmd_opna (char *cmdbuf);
00110 void cmd_dlat (char *cmdbuf);
00111 long send_message (struct CtdlMessage *);
00112 void loadtroom (void);
00113 long CtdlSubmitMsg(struct CtdlMessage *, struct recptypes *, const char *, int);
00114 void quickie_message (const char *, const char *, char *, char *, const char *, int, const char *);
00115 void cmd_ent0 (char *entargs);
00116 void cmd_dele (char *delstr);
00117 void cmd_move (char *args);
00118 void GetMetaData(struct MetaData *, long);
00119 void PutMetaData(struct MetaData *);
00120 void AdjRefCount(long, int);
00121 void TDAP_AdjRefCount(long, int);
00122 int TDAP_ProcessAdjRefCountQueue(void);
00123 void simple_listing(long, void *);
00124 int CtdlMsgCmp(struct CtdlMessage *msg, struct CtdlMessage *template);
00125 typedef void (*ForEachMsgCallback)(long MsgNumber, void *UserData);
00126 int CtdlForEachMessage(int mode,
00127                      long ref,
00128                      char *searchstring,
00129                      char *content_type,
00130                      struct CtdlMessage *compare,
00131                         ForEachMsgCallback CallBack,
00132                      void *userdata);
00133 int CtdlDeleteMessages(char *, long *, int, char *);
00134 void CtdlWriteObject(char *req_room,                    /* Room to stuff it in */
00135                      char *content_type,         /* MIME type of this object */
00136                      char *raw_message,          /* Data to be written */
00137                      off_t raw_length,           /* Size of raw_message */
00138                      struct ctdluser *is_mailbox,       /* Mailbox room? */
00139                      int is_binary,                     /* Is encoding necessary? */
00140                      int is_unique,                     /* Del others of this type? */
00141                      unsigned int flags          /* Internal save flags */
00142 );
00143 struct CtdlMessage *CtdlFetchMessage(long msgnum, int with_body);
00144 void CtdlFreeMessage(struct CtdlMessage *msg);
00145 void CtdlFreeMessageContents(struct CtdlMessage *msg);
00146 void serialize_message(struct ser_ret *, struct CtdlMessage *);
00147 int is_valid_message(struct CtdlMessage *);
00148 void ReplicationChecks(struct CtdlMessage *);
00149 int CtdlSaveMsgPointersInRoom(char *roomname, long newmsgidlist[], int num_newmsgs,
00150                      int do_repl_check, struct CtdlMessage *supplied_msg, int suppress_refcount_adj);
00151 int CtdlSaveMsgPointerInRoom(char *roomname, long msgid, int do_repl_check, struct CtdlMessage *msg);
00152 char *CtdlReadMessageBody(char *terminator, long tlen, size_t maxlen, char *exist, int crlf, int *sock);
00153 StrBuf *CtdlReadMessageBodyBuf(char *terminator, /* token signalling EOT */
00154                             long tlen,
00155                             size_t maxlen,              /* maximum message length */
00156                             char *exist,         /* if non-null, append to it;
00157                                                     exist is ALWAYS freed  */
00158                             int crlf,            /* CRLF newlines instead of LF */
00159                             int *sock            /* socket handle or 0 for this session's client socket */
00160        );
00161 
00162 int CtdlOutputMsg(long msg_num,           /* message number (local) to fetch */
00163                 int mode,          /* how would you like that message? */
00164                 int headers_only,  /* eschew the message body? */
00165                 int do_proto,             /* do Citadel protocol responses? */
00166                 int crlf,          /* 0=LF, 1=CRLF */
00167                 char *section,            /* output a message/rfc822 section */
00168                 int flags          /* should the bessage be exported clean? */
00169 );
00170 
00171 /* Flags which may be passed to CtdlOutputMsg() and CtdlOutputPreLoadedMsg() */
00172 #define QP_EADDR     (1<<0)        /* quoted-printable encode email addresses */
00173 #define CRLF         (1<<1)
00174 #define ESC_DOT             (1<<2)        /* output a line containing only "." as ".." instead */
00175 #define SUPPRESS_ENV_TO     (1<<3)        /* suppress Envelope-to: header (warning: destructive!) */
00176 
00177 int CtdlOutputPreLoadedMsg(struct CtdlMessage *,
00178                         int mode,         /* how would you like that message? */
00179                         int headers_only, /* eschew the message body? */
00180                         int do_proto,     /* do Citadel protocol responses? */
00181                         int crlf,         /* 0=LF, 1=CRLF */
00182                         int flags         /* should the bessage be exported clean? */
00183 );
00184 int CtdlDoIHavePermissionToDeleteMessagesFromThisRoom(void);
00185 int CtdlDoIHavePermissionToReadMessagesInThisRoom(void);
00186 
00187 enum {
00188        POST_LOGGED_IN,
00189        POST_EXTERNAL,
00190        CHECK_EXISTANCE,
00191        POST_LMTP
00192 };
00193 
00194 int CtdlDoIHavePermissionToPostInThisRoom(char *errmsgbuf, 
00195        size_t n, 
00196        const char* RemoteIdentifier,
00197        int PostPublic,
00198        int is_reply
00199 );
00200 
00201 
00202 /* values for which_set */
00203 enum {
00204        ctdlsetseen_seen,
00205        ctdlsetseen_answered
00206 };
00207 void CtdlSetSeen(long *target_msgnums, int num_target_msgnums,
00208                int target_setting, int which_set,
00209               struct ctdluser *which_user, struct ctdlroom *which_room);
00210 void CtdlGetSeen(char *buf, int which_set);
00211 
00212 struct recptypes *validate_recipients(const char *recipients,
00213                                   const char *RemoteIdentifier, 
00214                                   int Flags);
00215 
00216 void free_recipients(struct recptypes *);
00217 
00218 struct CtdlMessage *CtdlMakeMessage(
00219         struct ctdluser *author,        /* author's user structure */
00220         char *recipient,                /* NULL if it's not mail */
00221         char *recp_cc,                      /* NULL if it's not mail */
00222         char *room,                     /* room where it's going */
00223         int type,                       /* see MES_ types in header file */
00224         int format_type,                /* variformat, plain text, MIME... */
00225         char *fake_name,                /* who we're masquerading as */
00226        char *my_email,                    /* which of my email addresses to use (empty is ok) */
00227         char *subject,                  /* Subject (optional) */
00228        char *supplied_euid,        /* ...or NULL if this is irrelevant */
00229         char *preformatted_text,        /* ...or NULL to read text from client */
00230        char *references            /* Thread references */
00231 );
00232 int CtdlCheckInternetMailPermission(struct ctdluser *who);
00233 int CtdlIsMe(char *addr, int addr_buf_len);
00234 
00235 /*
00236  * Use of aide_message is deprecated.
00237  * It has been replaced with CtdlAideMessage.
00238  * All parameters remain the same.
00239 */
00240 void aide_message(char *text, char *subject) __attribute__ ((deprecated));
00241 
00242 
00243 /* 
00244  * loading messages async via an FD: 
00245  * add IO->ReadMsg = NewAsyncMsg(...)
00246  * and then call CtdlReadMessageBodyAsync() from your linreader handler.
00247  */
00248 
00249 ReadAsyncMsg *NewAsyncMsg(const char *terminator,       /* token signalling EOT */
00250                        long tlen,
00251                        size_t expectlen,             /* if we expect a message, how long should it be? */
00252                        size_t maxlen,            /* maximum message length */
00253                        char *exist,                     /* if non-null, append to it;
00254                                                     exist is ALWAYS freed  */
00255                        long eLen,                /* length of exist */
00256                        int crlf                  /* CRLF newlines instead of LF */
00257        );
00258 
00259 eReadState CtdlReadMessageBodyAsync(AsyncIO *IO);
00260 void DeleteAsyncMsg(ReadAsyncMsg **Msg);
00261 
00262 extern int MessageDebugEnabled;
00263 
00264 #define MSGDBGLOG(LEVEL) if ((LEVEL != LOG_DEBUG) || (MessageDebugEnabled != 0))
00265 #define CCCID CCC->cs_pid
00266 #define MSG_syslog(LEVEL, FORMAT, ...)                  \
00267        MSGDBGLOG(LEVEL) syslog(LEVEL,                   \
00268                             "CC[%d]" FORMAT,     \
00269                             CCCID, __VA_ARGS__)
00270 
00271 #define MSGM_syslog(LEVEL, FORMAT)               \
00272        MSGDBGLOG(LEVEL) syslog(LEVEL,                   \
00273                             "CC[%d]" FORMAT,     \
00274                             CCCID)
00275 
00276 
00277 
00278 #endif /* MSGBASE_H */