Back to index

courier  0.68.2
Classes | Functions
msg2html.h File Reference
#include "config.h"
#include "rfc822/rfc822.h"
#include "rfc2045/rfc2045.h"
#include <stdio.h>
#include <string.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  msg2html_smiley_list
struct  msg2html_info

Functions

struct msg2html_infomsg2html_alloc (const char *charset)
void msg2html_add_smiley (struct msg2html_info *i, const char *txt, const char *imgurl)
void msg2html_free (struct msg2html_info *)
void msg2html (FILE *fp, struct rfc2045 *rfc, struct msg2html_info *info)
void msg2html_download (FILE *fp, const char *mimeid, int dodownload, const char *system_charset)
void msg2html_showmimeid (struct rfc2045id *idptr, const char *p)
struct msg2html_textplain_infomsg2html_textplain_start (const char *message_charset, const char *output_character_set, int isflowed, int isdelsp, int isdraft, char *(*get_textlink)(const char *url, void *arg), void *get_textlink_arg, const char *smiley_index, struct msg2html_smiley_list *smileys, int wikifmt, void(*output_func)(const char *p, size_t n, void *arg), void *arg)
void msg2html_textplain (struct msg2html_textplain_info *info, const char *ptr, size_t cnt)
int msg2html_textplain_end (struct msg2html_textplain_info *info)

Class Documentation

struct msg2html_smiley_list

Definition at line 11 of file msg2html.h.

Collaboration diagram for msg2html_smiley_list:
Class Members
char * code
struct msg2html_smiley_list * next
char * url

Function Documentation

void msg2html ( FILE *  fp,
struct rfc2045 rfc,
struct msg2html_info info 
)

Definition at line 661 of file msg2html.c.

{
       if (!info->mimegpgfilename)
              info->mimegpgfilename="";

       showmsgrfc822_body(fp, rfc, NULL, 0, info);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void msg2html_add_smiley ( struct msg2html_info i,
const char *  txt,
const char *  imgurl 
)

Definition at line 121 of file msg2html.c.

{
       char buf[2];
       struct msg2html_smiley_list *l;

       buf[0]=*txt;
       buf[1]=0;

       if (strlen(i->smiley_index) < sizeof(i->smiley_index)-1)
              strcat(i->smiley_index, buf);


       if ((l=malloc(sizeof(struct msg2html_smiley_list))) != NULL)
       {
              if ((l->code=strdup(txt)) != NULL)
              {
                     if ((l->url=strdup(imgurl)) != NULL)
                     {
                            l->next=i->smileys;
                            i->smileys=l;
                            return;
                     }
                     free(l->code);
              }
              free(l);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct msg2html_info* msg2html_alloc ( const char *  charset) [read]

Definition at line 109 of file msg2html.c.

{
       struct msg2html_info *p=malloc(sizeof(struct msg2html_info));

       if (!p)
              return NULL;
       memset(p, 0, sizeof(*p));

       p->output_character_set=charset;
       return p;
}

Here is the caller graph for this function:

void msg2html_download ( FILE *  fp,
const char *  mimeid,
int  dodownload,
const char *  system_charset 
)

Definition at line 3035 of file msg2html.c.

{
       struct rfc2045 *rfc, *part;
       char   buf[BUFSIZ];
       int    n,cnt;
       const char    *content_type, *dummy, *charset;
       off_t  start_pos, end_pos, start_body;
       char   *content_name;
       off_t  ldummy;

       rfc=rfc2045_alloc();

       while ((n=fread(buf, 1, sizeof(buf), fp)) > 0)
              rfc2045_parse(rfc, buf, n);
       rfc2045_parse_partial(rfc);

       part=*mimeid ? rfc2045_find(rfc, mimeid):rfc;
       if (!part)
       {
              rfc2045_free(rfc);
              return;
       }

       rfc2045_mimeinfo(part, &content_type, &dummy, &charset);

       if (rfc2231_udecodeType(part, "name", system_charset,
                            &content_name) < 0)
              content_name=NULL;

       if (dodownload)
       {
              char *disposition_filename;
              const char *p;

              if (rfc2231_udecodeDisposition(part, "filename",
                                          (strncmp(content_type, "text/",
                                                 5) == 0 ?
                                          charset:system_charset),
                                          &disposition_filename) < 0)
              {
                     if (content_name)
                            free(content_name);
                     disposition_filename=NULL;
              }


              p=disposition_filename;

              if (!p || !*p) p=content_name;
              if (!p || !*p) p="message.dat";
              disposition_attachment(stdout, p, 1);
              content_type="application/octet-stream";
              if (disposition_filename)
                     free(disposition_filename);
       } else {
              if (content_name && *content_name)
                     disposition_attachment(stdout, content_name, 0);
       }

       printf(
              content_name && *content_name ?
              "Content-Type: %s; charset=%s; name=\"%s\"\n\n":
              "Content-Type: %s; charset=%s\n\n",
              content_type,
              charset,
              content_name ? content_name:"");
       if (content_name)
              free(content_name);

       rfc2045_mimepos(part, &start_pos, &end_pos, &start_body,
              &ldummy, &ldummy);

       if (*mimeid == 0)    /* Download entire message */
       {
              if (fseek(fp, start_pos, SEEK_SET) < 0)
              {
                     rfc2045_free(rfc);
                     return;
              }

              while (start_pos < end_pos)
              {
                     cnt=sizeof(buf);
                     if (cnt > end_pos-start_pos)
                            cnt=end_pos-start_pos;
                     cnt=fread(buf, 1, cnt, fp);
                     if (cnt <= 0) break;
                     start_pos += cnt;
                     download_func(buf, cnt, NULL);
              }
       }
       else
       {
              if (fseek(fp, start_body, SEEK_SET) < 0)
              {
                     rfc2045_free(rfc);
                     return;
              }

              rfc2045_cdecode_start(part, &download_func, 0);

              while (start_body < end_pos)
              {
                     cnt=sizeof(buf);
                     if (cnt > end_pos-start_body)
                            cnt=end_pos-start_body;
                     cnt=fread(buf, 1, cnt, fp);
                     if (cnt <= 0) break;
                     start_body += cnt;
                     rfc2045_cdecode(part, buf, cnt);
              }
              rfc2045_cdecode_end(part);
       }
       rfc2045_free(rfc);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void msg2html_free ( struct msg2html_info )

Definition at line 150 of file msg2html.c.

{
       struct msg2html_smiley_list *sl;

       while ((sl=p->smileys) != NULL)
       {
              p->smileys=sl->next;
              free(sl->code);
              free(sl->url);
              free(sl);
       }
       free(p);
}

Here is the caller graph for this function:

void msg2html_showmimeid ( struct rfc2045id idptr,
const char *  p 
)

Definition at line 3159 of file msg2html.c.

{
       if (!p)
              p="&amp;mimeid=";

       while (idptr)
       {
              printf("%s%d", p, idptr->idnum);
              idptr=idptr->next;
              p=".";
       }
}

Here is the caller graph for this function:

void msg2html_textplain ( struct msg2html_textplain_info info,
const char *  ptr,
size_t  cnt 
)

Definition at line 2846 of file msg2html.c.

{
       if (info->parser)
              rfc3676parser(info->parser, ptr, cnt);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2863 of file msg2html.c.

{
       int errptr;

       if (tinfo->parser)
       {
              rfc3676parser_deinit(tinfo->parser, &errptr);

              if (errptr)
                     tinfo->conv_err=1;
       }

       text_set_quote_level(tinfo, 0);
       text_set_list_level(tinfo, "", 0);
       text_close_paragraph(tinfo);

       if (!tinfo->wikifmt)
       {
              text_emit_passthru(tinfo, tinfo->flowed ? "</div><br />\n":
                               "</pre><br />\n");
       }

       filter_end(&tinfo->info);

       if (tinfo->info.conversion_error)
              tinfo->conv_err=1;

       errptr=tinfo->conv_err;

       free(tinfo);
       return errptr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct msg2html_textplain_info* msg2html_textplain_start ( const char *  message_charset,
const char *  output_character_set,
int  isflowed,
int  isdelsp,
int  isdraft,
char *(*)(const char *url, void *arg)  get_textlink,
void *  get_textlink_arg,
const char *  smiley_index,
struct msg2html_smiley_list smileys,
int  wikifmt,
void(*)(const char *p, size_t n, void *arg)  output_func,
void *  arg 
) [read]

Definition at line 2781 of file msg2html.c.

{
       struct msg2html_textplain_info *tinfo=
              malloc(sizeof(struct msg2html_textplain_info));
                           
       memset(tinfo, 0, sizeof(*tinfo));

       tinfo->flowed=isflowed;
       tinfo->get_textlink=get_textlink;
       tinfo->get_textlink_arg=get_textlink_arg;
       tinfo->smiley_index=smiley_index;
       tinfo->smileys=smileys;
       tinfo->wikifmt=wikifmt;

       tinfo->text_url_handler=text_contents_notalpha;
       filter_start(&tinfo->info,
                   output_character_set,
                   output_func, arg);

       tinfo->conv_err=0;
       {
              struct rfc3676_parser_info pinfo;

              memset(&pinfo, 0, sizeof(pinfo));

              pinfo.charset=message_charset;
              pinfo.isflowed=isflowed;
              pinfo.isdelsp=isdelsp;
              pinfo.line_begin=text_line_begin;
              pinfo.line_contents=text_line_contents;
              pinfo.line_flowed_notify=text_line_flowed_notify;
              pinfo.line_end=text_line_end;
              pinfo.arg=tinfo;

              tinfo->parser=rfc3676parser_init(&pinfo);
       }

       if (tinfo->parser == NULL)
              tinfo->conv_err=1;

       if (!wikifmt)
       {
              text_emit_passthru(tinfo,
                               isflowed ?
                               "<div class=\"message-text-plain\">":
                               "<pre class=\"message-text-plain\">");
       }

       return tinfo;
}

Here is the call graph for this function:

Here is the caller graph for this function: