Back to index

courier  0.68.2
msg2html.h
Go to the documentation of this file.
00001 #ifndef msg2html_h
00002 #define msg2html_h
00003 
00004 #include "config.h"
00005 #include "rfc822/rfc822.h"
00006 #include "rfc2045/rfc2045.h"
00007 
00008 #include <stdio.h>
00009 #include <string.h>
00010 
00011 struct msg2html_smiley_list {
00012        struct msg2html_smiley_list *next;
00013        char *code;
00014        char *url;
00015 };
00016 
00017 
00018 struct msg2html_info {
00019        const char *output_character_set;
00020        /* Required - generate output in this character set */
00021 
00022        void *arg; /* Passthrough parameter to callback functions */
00023 
00024        const char *mimegpgfilename;
00025        /*
00026        ** If not NULL, msg2html() receives GPG-decoded message read from
00027        ** mimegpgfilename.  The contents of mimegpgfilename are blindly
00028        ** appended to href links to multipart/related content.
00029        */
00030 
00031        const char *gpgdir;
00032        /*
00033        ** If not NULL -- points to the .gpg configuration directory.
00034        */
00035 
00036        int fullheaders; /* Flag: show all headers */
00037 
00038        int noflowedtext; /* Flag: do not show flowed text */
00039 
00040        int showhtml; /* Flag: show HTML content */
00041 
00042        int is_gpg_enabled;
00043        /* True: check for decrypted content, and format it accordingly */
00044 
00045        int is_preview_mode;
00046        /* True: sqwebmail is showing a draft message in preview mode */
00047 
00048        char *(*get_url_to_mime_part)(const char *mimeid,
00049                                   void *arg);
00050        /*
00051        ** Return a malloced buffer with a URL that would point to the
00052        ** message's indicated MIME part.
00053        */
00054 
00055        void (*charset_warning)(const char *, void *);
00056        /* If not NULL - content in this character set could not be converted */
00057 
00058        void (*html_content_follows)();
00059        /* If not NULL - HTML content follows */
00060 
00061        const char *wash_http_prefix;
00062        /* Prepended to http: URLs, which get encoded */
00063 
00064        const char *wash_mailto_prefix;
00065        /* Prepended to mailto: URLs */
00066 
00067        void (*message_rfc822_action)(struct rfc2045id *idptr);
00068        /*
00069        ** idpart references a message/rfc822 attachment.  Emit HTML
00070        ** for the usual actions (reply, forward, etc...)
00071        */
00072 
00073        void (*inline_image_action)(struct rfc2045id *idptr,
00074                                 const char *content_type,
00075                                 void *arg);
00076        /* Inline image attachment */
00077 
00078        void (*application_pgp_keys_action)(struct rfc2045id *id);
00079        /* Attached PGP keys */
00080 
00081        void (*unknown_attachment_action)(struct rfc2045id *idptr,
00082                                      const char *content_type,
00083                                      const char *content_name,
00084                                      off_t size,
00085                                      void *arg);
00086 
00087        void (*gpg_message_action)();
00088        /*
00089        ** This message contains MIME/PGP content.  Post the appropriate
00090        ** notice.
00091        */
00092 
00093        /* Mark the beginning and end of an E-mail address in mail headers: */
00094        void (*email_address_start)(const char *name, const char *addr);
00095        void (*email_address_end)();
00096 
00097        /*
00098        ** Format a mail header. (*format_header) should invoke
00099        ** (*cb_func) with a pointer to whatever should be displayed, which
00100        ** may be just hdrname (which is the default behavior.
00101        */
00102 
00103        void (*email_header)(const char *hdrname,
00104                           void (*cb_func)(const char *));
00105 
00106        /*
00107        ** Return strftime() format string for dates. 'def' is the
00108        ** proposed default.  The default implementation simply returns
00109        ** the default string.
00110        */
00111 
00112        const char *(*email_header_date_fmt)(const char *def);
00113 
00114        /*
00115        ** Return HTML code for rendering a URL, if the URL scheme is
00116        ** recognized.  The HTML code is returned in an malloc-ed buffer:
00117        */
00118        char *(*get_textlink)(const char *url, void *arg);
00119 
00120        struct msg2html_smiley_list *smileys;
00121        char smiley_index[50];
00122 };
00123 
00124 struct msg2html_info *msg2html_alloc(const char *charset);
00125 void msg2html_add_smiley(struct msg2html_info *i,
00126                       const char *txt, const char *imgurl);
00127 
00128 void msg2html_free(struct msg2html_info *);
00129 
00130 void msg2html(FILE *fp, struct rfc2045 *rfc, struct msg2html_info *info);
00131 
00132 void msg2html_download(FILE *fp, const char *mimeid, int dodownload,
00133                      const char *system_charset);
00134 
00135 void msg2html_showmimeid(struct rfc2045id *idptr, const char *p);
00136 
00137 /*
00138 ** INTERNAL
00139 */
00140 
00141 struct msg2html_textplain_info;
00142 
00143 struct msg2html_textplain_info *
00144 msg2html_textplain_start(const char *message_charset,
00145                       const char *output_character_set,
00146                       int isflowed,
00147                       int isdelsp,
00148                       int isdraft,
00149                       char *(*get_textlink)(const char *url, void *arg),
00150                       void *get_textlink_arg,
00151 
00152                       const char *smiley_index,
00153                       struct msg2html_smiley_list *smileys,
00154                       int wikifmt,
00155 
00156                       void (*output_func)(const char *p,
00157                                         size_t n, void *arg),
00158                       void *arg);
00159 
00160 void msg2html_textplain(struct msg2html_textplain_info *info,
00161                      const char *ptr,
00162                      size_t cnt);
00163 
00164 int msg2html_textplain_end(struct msg2html_textplain_info *info);
00165 
00166 #endif
00167