Back to index

courier  0.68.2
Functions | Variables
newmsg.c File Reference
#include "config.h"
#include "sqwebmail.h"
#include "newmsg.h"
#include "cgi/cgi.h"
#include "sqconfig.h"
#include "auth.h"
#include "maildir.h"
#include "token.h"
#include "pref.h"
#include "folder.h"
#include "filter.h"
#include "gpg.h"
#include "addressbook.h"
#include "maildir/maildirmisc.h"
#include "maildir/maildirquota.h"
#include "maildir/maildirgetquota.h"
#include "rfc822/rfc822.h"
#include "rfc822/rfc2047.h"
#include "rfc2045/rfc2045.h"
#include "gpglib/gpglib.h"
#include "courierauth.h"
#include <string.h>
#include <stdio.h>
#include <signal.h>
#include <stdlib.h>
#include <fcntl.h>
#include <ctype.h>
#include <sys/types.h>
#include <errno.h>
#include "htmllibdir.h"
#include "unicode/unicode.h"

Go to the source code of this file.

Functions

int spell_start (const char *)
void print_safe_len (const char *, size_t, void(*)(const char *, size_t))
void call_print_safe_to_stdout (const char *, size_t)
void print_attrencodedlen (const char *, size_t, int, FILE *)
void output_attrencoded_nltobr (const char *)
void output_attrencoded_oknl (const char *)
void output_attrencoded (const char *)
void output_scriptptrget ()
void output_form (const char *)
void output_urlencoded (const char *)
char * newmsg_newdraft (const char *, const char *, const char *, const char *)
char * newmsg_createdraft (const char *)
char * newmsg_createsentmsg (const char *, int *)
int ishttps ()
static void newmsg_header (const char *label, const char *field, const char *encoded, const char *val)
static void printc (char c, void *dummy)
static void printsep (const char *c, void *dummy)
static void newmsg_header_rfc822 (const char *label, const char *field, const char *encoded, const char *val, int is_readonly)
static const char * ispreviewmsg ()
void newmsg_hiddenheader (const char *label, const char *value)
static size_t show_textarea_start_of_line (struct show_textarea_info *, const char *, size_t)
static size_t show_textarea_quoted_text (struct show_textarea_info *, const char *, size_t)
static size_t show_textarea_notseen_sp (struct show_textarea_info *, const char *, size_t)
static size_t show_textarea_seen_sp (struct show_textarea_info *, const char *, size_t)
static size_t show_textarea_seen_spnl (struct show_textarea_info *, const char *, size_t)
static size_t show_textarea_check_sig (struct show_textarea_info *, const char *, size_t)
static size_t show_textarea_ignore_sig (struct show_textarea_info *, const char *, size_t)
void show_textarea_init (struct show_textarea_info *info, int stop_at_sig)
void show_textarea (struct show_textarea_info *info, const char *ptr, size_t cnt)
char * newmsg_alladdrs (FILE *fp)
static int show_textarea_trampoline (const char *ptr, size_t cnt, void *arg)
void newmsg_showfp (FILE *fp, int *attachcnt)
void newmsg_preview (const char *p)
void newmsg_init (const char *folder, const char *pos)
static const char * geterrbuf (int fd)
static int waitfor (pid_t pid)
void sendmsg_done ()
static int dosendmsg (const char *origdraft)
void newmsg_do (const char *folder)

Variables

const char * sqwebmail_content_charset
const char * sqwebmail_mailboxid
const char * sqwebmail_folder

Function Documentation

void call_print_safe_to_stdout ( const char *  ,
size_t   
)

Definition at line 155 of file folder.c.

Here is the call graph for this function:

static int dosendmsg ( const char *  origdraft) [static]

Definition at line 912 of file newmsg.c.

{
pid_t  pid;
const  char *returnaddr;
int    pipefd1[2];
char   *filename;
const char *line;
char   *draftmessage;
int    isgpgerr;
unsigned long filesize;
struct stat stat_buf;
int dsn;

       if (tokencheck()) /* Duplicate submission - message was already sent */
       {
              sendmsg_done();
              return (1);
       }

       if (strcmp(cgi("form"), "doattach") == 0)
       {
              /* When called from the attachment window, we do NOT create
              ** a new draft message */

              draftmessage=strdup(origdraft);
       }
       else
              draftmessage=newmsg_createdraft(origdraft);
       if (!draftmessage)
              enomem();

       filename=newmsg_createsentmsg(draftmessage, &isgpgerr);

       if (!filename)
       {
              char *draftbase=maildir_basename(draftmessage);

              if (isgpgerr)
              {
                     cgi_put("draftmessage", draftbase);
                     output_form("gpgerr.html");
              }
              else
              {
                     http_redirect_argss("&form=newmsg&pos=%s"
                                       "&draft=%s&error=quota",
                                       cgi("pos"), draftbase);
              }
              free(draftmessage);
              free(draftbase);
              return (1);
       }

       if (pipe(pipefd1) != 0)
       {
              cgi_put("foldermsg", "ERROR: pipe() failed.");
              maildir_msgpurgefile(INBOX "." SENT, filename);
              free(filename);
              free(draftmessage);
              return (0);
       }

       dsn= *cgi("dsn") != 0;

       pid=fork();
       if (pid < 0)
       {
              cgi_put("foldermsg", "ERROR: fork() failed.");
              close(pipefd1[0]);
              close(pipefd1[1]);
              maildir_msgpurgefile(INBOX "." SENT, filename);
              free(filename);
              free(draftmessage);
              return (0);
       }

       if (pid == 0)
       {
       static const char noexec[]="ERROR: Unable to execute sendit.sh.\n";
       static const char nofile[]="ERROR: Temp file not available - probably exceeded quota.\n";
       char   *tmpfile=maildir_find(INBOX "." SENT, filename);
       int    fd;

              if (!tmpfile)
              {
                     if (fwrite((char*)nofile, 1, sizeof(nofile)-1, stderr))
                            ; /* ignore */
                     _exit(1);
              }

              close(0);

              fd=maildir_safeopen(tmpfile, O_RDONLY, 0);
              dup2(pipefd1[1], 1);
              dup2(pipefd1[1], 2);
              close(pipefd1[0]);
              close(pipefd1[1]);

              if (dsn)
                     putenv("DSN=-Nsuccess,delay,failure");
              else
                     putenv("DSN=");

              if (fd == 0)
              {
                     returnaddr=login_returnaddr();
                     execl(SENDITSH, "sendit.sh", returnaddr,
                            sqwebmail_mailboxid, NULL);
              }
                     
              if (fwrite(noexec, 1, sizeof(noexec)-1, stderr))
                     ; /* ignore */
              _exit(1);
       }
       close(pipefd1[1]);

       line=geterrbuf(pipefd1[0]);
       close(pipefd1[0]);

       if (waitfor(pid))
       {
              if (!*line)
                     line="Unable to send message.\n";
       }
       else
              line="";

       if (*line == 0)      /* Succesfully sent message */
       {
              if (*draftmessage)
              {
              char   *base=maildir_basename(draftmessage);
              char   *draftfile=maildir_find(INBOX "." DRAFTS, base);

                     free(base);

                     /* Remove draft file */

                     if (draftfile)
                     {
                     char   *replytofolder=0, *replytomsg=0;
                     char   *header, *value;
                     FILE   *fp;
                     int    x;

                            fp=0;
                            x=maildir_safeopen(draftfile, O_RDONLY, 0);
                            if ( maildir_parsequota(draftfile, &filesize))
                            {
                                   if (x < 0 || fstat(x, &stat_buf))
                                          stat_buf.st_size=0;
                                   filesize=stat_buf.st_size;
                            }

                            if (x >= 0)
                                   if ((fp=fdopen(x, "r")) == 0)
                                          close(x);

                            /* First, look for a message that we should
                            ** mark as replied */

                            while (fp && (header=maildir_readheader(fp,
                                          &value, 0)) != 0)
                            {
                                   if (strcmp(header,"x-reply-to-folder")
                                          == 0 && !replytofolder)
                                   {
                                          replytofolder=strdup(value);
                                          if (!replytofolder)
                                                 enomem();
                                   }
                                   if (strcmp(header,"x-reply-to-msg")
                                          == 0 && !replytomsg)
                                   {
                                          replytomsg=strdup(value);
                                          if (!replytomsg)
                                                 enomem();
                                   }
                                   if (replytofolder && replytomsg)
                                          break;
                            }
                            if (fp)       fclose(fp);

                            if (replytofolder && replytomsg)
                                   maildir_markreplied(replytofolder,
                                                 replytomsg);
                            if (replytofolder)   free(replytofolder);
                            if (replytomsg)      free(replytomsg);
                            
                            maildir_quota_deleted(".",
                                                -(long)filesize, -1);

                            unlink(draftfile);
                            free(draftfile);
                     }
              }

              tokensave();

              if (*cgi("fcc") == 0)
              {
                     unsigned long filesize=0;
                     char   *tmpfile=maildir_find(INBOX "." SENT, filename);

                     if (tmpfile)
                     {
                            maildir_parsequota(tmpfile, &filesize);
                            unlink(tmpfile);
                            maildir_quota_deleted(".", -(long)filesize,-1);
                            free(tmpfile);
                     }
              }

              free(filename);
              free(draftmessage);
              sendmsg_done();
              return (1);
       }

       if (stat(filename, &stat_buf) == 0)
              maildir_quota_deleted(".", -(long)stat_buf.st_size, -1);
       maildir_msgpurgefile(INBOX "." SENT, filename);
       free(filename);

       {
       char *draftbase=maildir_basename(draftmessage);

              http_redirect_argsss("&form=newmsg&pos=%s&draft=%s&foldermsg=%s",
                     cgi("pos"), draftbase, line);
              free(draftmessage);
              free(draftbase);
       }
       return (1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static const char* geterrbuf ( int  fd) [static]

Definition at line 873 of file newmsg.c.

{
static char errbuf[512];
char   *errbufptr=errbuf;
size_t errbufleft=sizeof(errbuf)-1;

       while (errbufleft)
       {
       int    l=read(fd, errbufptr, errbufleft);

              if (l <= 0)   break;
              errbufptr += l;
              errbufleft -= l;
       }
       *errbufptr=0;
       return (errbuf);
}

Here is the caller graph for this function:

int ishttps ( )

Definition at line 494 of file sqwebmail.c.

{
       const char *p=getenv("HTTPS");

       return (p && strcasecmp(p, "on") == 0);
}
static const char* ispreviewmsg ( ) [static]

Definition at line 160 of file newmsg.c.

{
const char *p=cgi("previewmsg");

       if (*p == 0)
              p=cgi("addressbook_to");

       if (*p == 0)
              p=cgi("addressbook_cc");

       if (*p == 0)
              p=cgi("addressbook_bcc");

       return (p);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* newmsg_alladdrs ( FILE *  fp)

Definition at line 361 of file newmsg.c.

{
       char   *headers=NULL;
       struct rfc822t *t;
       struct rfc822a *a;
       char *p, *q;
       int l, i;

       if (fp)
       {
              char *header, *value;

              rewind(fp);

              /* First, combine all the headers into one header. */

              while ((header=maildir_readheader(fp, &value, 1)) != 0)
              {
                     char *newh;

                     if (strcmp(header, "from") &&
                         strcmp(header, "to") &&
                         strcmp(header, "cc") &&
                         strcmp(header, "bcc"))
                            continue;

                     if (headers)
                     {
                            newh=realloc(headers, strlen(headers)
                                        +strlen(value)+2);
                            if (!newh)
                                   continue;
                            strcat(newh, ",");
                            headers=newh;
                     }
                     else
                     {
                            newh=malloc(strlen(value)+1);
                            if (!newh)
                                   continue;
                            *newh=0;
                            headers=newh;
                     }
                     strcat(headers, value);
              }

       }

       /* Now, parse the header, and extract the addresses */

       t=rfc822t_alloc_new(headers ? headers:"", NULL, NULL);
       a= t ? rfc822a_alloc(t):NULL;

       l=1;
       for (i=0; i < (a ? a->naddrs:0); i++)
       {
              p=rfc822_getaddr(a, i);
              if (p)
              {
                     ++l;
                     l +=strlen(p);
                     free(p);
              }
       }
       p=malloc(l);
       if (p)
              *p=0;

       for (i=0; i < (a ? a->naddrs:0); i++)
       {
              q=rfc822_getaddr(a, i);
              if (q)
              {
                     if (p)
                     {
                            strcat(strcat(p, q), "\n");
                     }
                     free(q);
              }
       }

       rfc822a_free(a);
       rfc822t_free(t);
       free(headers);
       return (p);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* newmsg_createdraft ( const char *  )

Definition at line 58 of file newmsg_create.c.

{
       if (curdraft && *curdraft)
       {
       char   *base=maildir_basename(curdraft);
       char   *filename=maildir_find(INBOX "." DRAFTS, base);

              if (filename)
              {
              char   *p=newmsg_createdraft_do(filename, cgi("message"), 0);

                     free(filename);
                     free(base);
                     return (p);
              }
              free(base);
       }
       return (newmsg_createdraft_do(0, cgi("message"), 0));
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* newmsg_createsentmsg ( const char *  ,
int *   
)

Definition at line 1098 of file newmsg_create.c.

{
char   *filename=maildir_find(INBOX "." DRAFTS, draftname);
FILE   *fp;
char   *sentname;
char   *header, *value;
struct rfc2045 *rfcp;
int    x;

       *isgpgerr=0;
 
       if (!filename)       return (0);

       fp=0;

       x=maildir_safeopen(filename, O_RDONLY, 0);
       if (x >= 0)
              if ((fp=fdopen(x, "r")) == 0)
                     close(x);

       if (fp == 0)
       {
              free(filename);
              enomem();
       }

       rfcp=rfc2045_fromfp(fp);
       if (!rfcp || fseek(fp, 0L, SEEK_SET) < 0)
       {
              fclose(fp);
              close(newdraftfd);
              enomem();
       }

       newdraftfd=maildir_createmsg(INBOX "." SENT, 0, &sentname);
       if (newdraftfd < 0)
       {
              rfc2045_free(rfcp);
              free(filename);
              fclose(fp);
              enomem();
       }
       /* First, copy all headers except X- headers */

       while ((header=maildir_readheader(fp, &value, 1)) != 0)
       {
              if (strncmp(header, "x-", 2) == 0) continue;
              header_uc(header);
              if (rfc822hdr_namecmp(header, "To") == 0)
              {
                     lookup_addressbook("To: ", value);
                     continue;
              }

              if (rfc822hdr_namecmp(header, "Cc") == 0)
              {
                     lookup_addressbook("Cc: ", value);
                     continue;
              }

              if (rfc822hdr_namecmp(header, "Bcc") == 0)
              {
                     lookup_addressbook("Bcc: ", value);
                     continue;
              }

              maildir_writemsgstr(newdraftfd, header);
              maildir_writemsgstr(newdraftfd, ": ");
              maildir_writemsgstr(newdraftfd, value);
              maildir_writemsgstr(newdraftfd, "\n");
       }
       if (auth_getoptionenvint("wbusexsender"))
       {
              maildir_writemsgstr(newdraftfd, "X-Sender: ");
              maildir_writemsgstr(newdraftfd, login_returnaddr());
              maildir_writemsgstr(newdraftfd, "\n");
       }

       maildir_writemsgstr(newdraftfd, "\n");

       {
              off_t start_pos, end_pos, start_body;
              char buf[BUFSIZ];
              int n;
              off_t   dummy;
              
              rfc2045_mimepos(rfcp, &start_pos, &end_pos, &start_body,
                            &dummy, &dummy);

              if (fseek(fp, start_body, SEEK_SET) == -1)
              {
                     fclose(fp);
                     close(newdraftfd);
                     enomem();
              }

              while (start_body < end_pos)
              {
                     int     cnt=sizeof(buf);

                     if (cnt > end_pos - start_pos)
                            cnt=end_pos - start_pos;

                     if ((n=fread(buf, 1, cnt, fp)) <= 0)
                     {
                            fclose(fp);      
                            close(newdraftfd);
                            enomem();
                     }

                     maildir_writemsg(newdraftfd, buf, n);
                     start_body += n;
              }
       }


       if ( maildir_writemsg_flush(newdraftfd))
       {
              free(sentname);
              return (0);
       }

#if 0
       if (writebuf8bit)
       {
              if (lseek(newdraftfd, transferencodingpos, SEEK_SET) < 0 ||
                     write(newdraftfd, "8", 1) != 1)
              {
                     free(sentname);
                     return (0);
              }
       }
#endif

       if ( maildir_writemsg_flush(newdraftfd))
       {
              maildir_closemsg(newdraftfd, INBOX "." SENT, sentname, 0, 0);
              free(sentname);
              return (0);
       }

       if (libmail_gpg_has_gpg(GPGDIR) == 0)
       {
              char dosign= *cgi("sign");
              char doencrypt= *cgi("encrypt");
              const char *signkey= cgi("signkey");
              char *encryptkeys=cgi_multiple("encryptkey", " ");

              if (!encryptkeys)
                     enomem();

              if (gpgbadarg(encryptkeys) || !*encryptkeys)
              {
                     free(encryptkeys);
                     encryptkeys=0;
              }

              if (gpgbadarg(signkey) || !*signkey)
              {
                     signkey=0;
              }

              if (!encryptkeys)
                     doencrypt=0;

              if (!signkey)
                     dosign=0;

              if (lseek(newdraftfd, 0L, SEEK_SET) < 0)
              {
                     maildir_closemsg(newdraftfd, INBOX "." SENT,
                                    sentname, 0, 0);
                     free(sentname);
                     return (0);
              }

              if (!dosign)
                     signkey=0;
              if (!doencrypt)
                     encryptkeys=0;

              if (dosign || doencrypt)
              {
                     /*
                     ** What we do is create another draft, then substitute
                     ** it for newdraftfd/sentname.  Sneaky.
                     */

                     char *newnewsentname;
                     int newnewdraftfd=maildir_createmsg(INBOX "." SENT, 0,
                                                     &newnewsentname);

                     if (newnewdraftfd < 0)
                     {
                            maildir_closemsg(newdraftfd, INBOX "." SENT,
                                           sentname, 0, 0);
                            free(sentname);
                            free(encryptkeys);
                            return (0);
                     }

                     if (gpgdomsg(newdraftfd, newnewdraftfd,
                                 signkey, encryptkeys))
                     {
                            maildir_closemsg(newnewdraftfd, INBOX "." SENT,
                                           newnewsentname, 0, 0);
                            free(newnewsentname);
                            maildir_closemsg(newdraftfd, INBOX "." SENT,
                                           sentname, 0, 0);
                            free(sentname);
                            free(encryptkeys);
                            *isgpgerr=1;
                            return (0);
                     }

                     maildir_closemsg(newdraftfd, INBOX "." SENT, sentname, 0, 0);
                     free(sentname);
                     sentname=newnewsentname;
                     newdraftfd=newnewdraftfd;

              }
              free(encryptkeys);
       }

       if ( maildir_closemsg(newdraftfd, INBOX "." SENT, sentname, 1, 0))
       {
              free(sentname);
              return (0);
       }
       return (sentname);
}

Here is the caller graph for this function:

void newmsg_do ( const char *  folder)

Definition at line 1147 of file newmsg.c.

{
const  char *draftmessage=cgi("draftmessage");

       if (*draftmessage)   /* It's ok if it's blank */
       {
              CHECKFILENAME(draftmessage);
       }

       if (*cgi("savedraft"))
       {
       char   *newdraft=newmsg_createdraft(draftmessage);

              if (!newdraft)       enomem();
              free(newdraft);
              sendmsg_done();
              return;
       }

       if (*cgi("sendmsg") && dosendmsg(draftmessage))
              return;

       if (*cgi("doattachments"))
       {
       char   *newdraft=newmsg_createdraft(draftmessage);
       char   *base;

              if (!newdraft)       enomem();
              if (*cgi("error"))
              {
                     cgi_put("previewmsg", "1");
                     output_form("newmsg.html");
                     return;
              }

              base=maildir_basename(newdraft);
              http_redirect_argss("&form=attachments&pos=%s&draft=%s",
                     cgi("pos"), base);
              free(base);
              free(newdraft);
              return;
       }
#ifdef ISPELL
       if (*cgi("startspellchk"))
       {
       char   *newdraft=newmsg_createdraft(draftmessage);
       char   *base;

              if (!newdraft)       enomem();
              base=maildir_basename(newdraft);
              free(newdraft);
              if (spell_start(base) == 0)
              {
                     cgi_put("draftmessage", base);
                     output_form("spellchk.html");
              }
              else
              {
                     http_redirect_argss("&form=newmsg&pos=%s&draft=%s&previewmsg=SPELLCHK",
                            cgi("pos"), base);
              }
              free(base);
              return;
       }
#endif
       if (*ispreviewmsg())
       {
              output_form("newmsg.html");
              return;
       }
       http_redirect_argsss("&form=newmsg&pos=%s&draftmessage=%s&error=%s",
              cgi("pos"), draftmessage,
              cgi("error"));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void newmsg_header ( const char *  label,
const char *  field,
const char *  encoded,
const char *  val 
) [static]

Definition at line 67 of file newmsg.c.

{
int           hdrmaxlen=512;
const char    *p=getarg("HDRMAXLEN");

       if (p && (atoi(p) > hdrmaxlen))
              hdrmaxlen=atoi(p);

       printf("<tr><th align=\"right\"><p class=\"new-message-header\">"
              "<span class=\"new-message-header-%s\">%s</span></p></th>"
              "<td width=\"6\">&nbsp;</td>",
              field, label);

       printf("<td><input type=\"text\" name=\"%s\" size=\"50\" maxlength=\"%d\""
              " class=\"new-message-header-text\" value=\"",
              field, hdrmaxlen);
       if (encoded)
       {
              char   *s;

              s=rfc822_display_hdrvalue_tobuf("subject",
                                          encoded,
                                          sqwebmail_content_charset,
                                          NULL,
                                          NULL);

              if (!s)
                     s=strdup(encoded);

              if (!s)       enomem();
              output_attrencoded(s);
              free(s);
       }
       else if (val)
              output_attrencoded(val);
       printf("\" /></td></tr>\n");
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void newmsg_header_rfc822 ( const char *  label,
const char *  field,
const char *  encoded,
const char *  val,
int  is_readonly 
) [static]

Definition at line 120 of file newmsg.c.

{
int           hdrmaxlen=512;
const char    *p=getarg("HDRMAXLEN");

       if (p && (atoi(p) > hdrmaxlen))
              hdrmaxlen=atoi(p);

       printf("<tr><th align=\"right\"><p class=\"new-message-header\">"
              "<span class=\"new-message-header-%s\">%s</span></p></th>"
              "<td width=\"6\">&nbsp;</td>",
              field, label);

       printf("<td><input type=\"text\" name=\"%s\" size=\"50\" maxlength=\"%d\""
              " class=\"new-message-header-text\" value=\"",
              field, hdrmaxlen);
       if (encoded)
       {
              struct rfc822t *t=rfc822t_alloc_new(encoded, NULL, NULL);
              struct rfc822a *a=t ? rfc822a_alloc(t):NULL;

              if (a)
              {
                     rfc2047_print_unicodeaddr(a, sqwebmail_content_charset,
                                            printc,
                                            printsep, NULL);
                     rfc822a_free(a);
              }

              if (t)
                     rfc822t_free(t);
       }
       else if (val)
              output_attrencoded(val);
       printf("\"%s /></td></tr>\n",
              is_readonly ? " readonly=\"readonly\"":"");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void newmsg_hiddenheader ( const char *  label,
const char *  value 
)

Definition at line 176 of file newmsg.c.

{
       printf("<input type=\"hidden\" name=\"%s\" value=\"", label);
       output_attrencoded(value);
       printf("\" />");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void newmsg_init ( const char *  folder,
const char *  pos 
)

Definition at line 524 of file newmsg.c.

{
       const char    *tolab=getarg("TOLAB");
       const char    *cclab=getarg("CCLAB");
       const char    *bcclab=getarg("BCCLAB");
       const char    *subjectlab=getarg("SUBJECTLAB");
       const char    *messagelab=getarg("MESSAGELAB");
       const char    *sendlab=getarg("SENDLAB");
       const char    *previewlab=getarg("PREVIEWLAB");
       const char    *forwardsep=getarg("FORWARDLAB");
       const char    *savedraft=getarg("SAVEDRAFT");
       const char    *attachmentslab=getarg("ATTACHMENTS");
       const char      *uploadlab=getarg("UPLOAD");
       const char    *replysalutation=getarg("SALUTATION");
       const char    *checkspellingdone=getarg("SPELLCHECKDONE");
       const char    *checkspelling=getarg("CHECKSPELLING");
       const char    *quotaerr=getarg("QUOTAERR");
       const char    *fromlab=getarg("FROMLAB");
       const char    *replytolab=getarg("REPLYTOLAB");
       const char    *addressbooklab=getarg("ADDRESSBOOK");
       const char    *select1=getarg("SELECT1");
       const char    *select2=getarg("SELECT2");
       const char    *text1=getarg("TEXT1");
       const char    *text2=getarg("TEXT2");
       char   *draftmessage;
       char   *draftmessagefilename;
       const  char *p;
       FILE   *fp;
       int    attachcnt=0;
       char   *cursubj, *curto, *curcc, *curbcc, *curfrom, *curreplyto;
       int wbnochangingfrom;

       /* Picking up an existing draft? */

       p=cgi("draft");
       if (*p)
       {
              CHECKFILENAME(p);
       }

       if (*p)
       {
              draftmessage=strdup(p);
              if (!draftmessage)   enomem();
              p="";
       }
       else
       {
              draftmessage=newmsg_newdraft(folder, pos,
                     forwardsep, replysalutation);

              if (!draftmessage)
              {
                     if (*ispreviewmsg())
                     {
                            p=cgi("draftmessage");
                            if (*p)
                            {
                                   CHECKFILENAME(p);
                            }
                            draftmessage=newmsg_createdraft(p);
                     }
              }
       }

       draftmessagefilename= draftmessage ?
                             maildir_find(INBOX "." DRAFTS, draftmessage):0;

       if (*(p=cgi("previewmsg")))
       {
#ifdef ISPELL
              if (strcmp(p, "SPELLCHK") == 0)
                     printf("%s<br /><br />\n", checkspellingdone);
#endif
              printf("<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\" class=\"box-small-outer\"><tr><td>\n");
              printf("<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" class=\"preview\"><tr><td>\n");

              if (draftmessagefilename)
              {
                     const char *p=strrchr(draftmessagefilename, '/');

                     if (p)
                            ++p;
                     else
                            p=draftmessagefilename;

                     newmsg_preview(p);
              }
              printf("</td></tr></table>\n");
              printf("</td></tr></table>\n");

              printf("<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"6\"><tr><td><hr width=\"80%%\" /></td></tr></table>\n");
       }

       printf("<input type=\"hidden\" name=\"form\" value=\"donewmsg\" />\n");
       newmsg_hiddenheader("pos", pos);
       newmsg_hiddenheader("focusto",
                         *cgi("newmsg") ? "headers":"text");

       /* Generate unique message token, to detect duplicate SUBMITs */

       tokennew();

       /* Display any error message */

       if (*cgi("foldermsg"))
       {
              printf("<p><span class=\"error\" style=\"color: #ff0000\">");
              output_attrencoded_nltobr(cgi("foldermsg"));
              printf("</span></p>");
       }

       if (strcmp(cgi("error"), "quota") == 0)
              printf("%s", quotaerr);

       /* Read message from the draft file */

       cursubj=0;
       curto=0;
       curfrom=0;
       curreplyto=0;
       curcc=0;
       curbcc=0;
       fp=0;

       if (draftmessagefilename)
       {
       int    x=maildir_safeopen(draftmessagefilename, O_RDONLY, 0);

              if (x >= 0)
                     if ((fp=fdopen(x, "r")) == 0)
                            close(x);
       }

       if (fp != 0)
       {
       char *header, *value;

              while ((header=maildir_readheader(fp, &value, 0)) != 0)
              {
              char   **rfchp=0;

                     if (strcmp(header, "subject") == 0)
                     {
                            if (!cursubj && !(cursubj=strdup(value)))
                                   enomem();
                            continue;
                     }

                     while (*value && isspace(*value))
                            ++value;

                     if (strcmp(header, "from") == 0)
                            rfchp= &curfrom;
                     if (strcmp(header, "reply-to") == 0)
                            rfchp= &curreplyto;
                     if (strcmp(header, "to") == 0)
                            rfchp= &curto;
                     if (strcmp(header, "cc") == 0)
                            rfchp= &curcc;
                     if (strcmp(header, "bcc") == 0)
                            rfchp= &curbcc;
                     if (rfchp)
                     {
                     char   *newh=malloc ( (*rfchp ? strlen(*rfchp)+2:1)
                                   +strlen(value));

                            if (!newh)    enomem();
                            strcpy(newh, value);
                            if (*rfchp)
                                   strcat(strcat(newh, ","), *rfchp);
                            if (*rfchp)   free( *rfchp );
                            *rfchp=newh;
                     }
              }
       }

       printf("<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\" class=\"box-small-outer\"><tr><td>\n");
       printf("<table width=\"100%%\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\" class=\"new-message-box\"><tr><td>\n");

       printf("<table border=\"0\" width=\"100%%\">\n");
       wbnochangingfrom=auth_getoptionenvint("wbnochangingfrom");
       if (wbnochangingfrom < 2)
              newmsg_header_rfc822(fromlab, "headerfrom", curfrom,
                     *cgi("from") ? cgi("from"):
                     pref_from && *pref_from ? pref_from:
                     login_fromhdr(), wbnochangingfrom ? 1:0);

       printf("<tr valign=\"middle\"><th align=\"right\">"
              "<p class=\"new-message-header\">"
              "<span class=\"new-message-header-addressbook\">"
              "%s</span></p></th><td width=\"6\">&nbsp;</td>",
              addressbooklab);

       printf("<td valign=\"middle\">");
       printf("<table border=\"0\" cellpadding=\"0\" cellspacing=\"4\">");
       printf("<tr valign=\"middle\"><td>%s\n", select1);
       ab_listselect();
       printf("%s</td><td width=\"100%%\">", select2);
       printf("<input type=\"submit\" name=\"addressbook_to\" value=\"%s\" />",
                     tolab);
       printf("<input type=\"submit\" name=\"addressbook_cc\" value=\"%s\" />",
                     cclab);
       printf("<input type=\"submit\" name=\"addressbook_bcc\" value=\"%s\" />",
                     bcclab);
       printf("</td></tr></table>");

       printf("</td></tr>\n");

#if 0
                     {
                            FILE *fp;
                            fp=fopen("/tmp/pid", "w");
                            fprintf(fp, "%d", getpid());
                            fclose(fp);
                            sleep(10);
                     }
#endif

       newmsg_header_rfc822(tolab, "headerto", curto, cgi("to"), 0);
       newmsg_header_rfc822(cclab, "headercc", curcc, cgi("cc"), 0);
       newmsg_header_rfc822(bcclab, "headerbcc", curbcc, cgi("bcc"), 0);
       newmsg_header_rfc822(replytolab, "headerreply-to",
                          curreplyto, cgi("replyto"), 0);
       newmsg_header(subjectlab, "headersubject",
                    cursubj, cgi("subject"));

       if (curto)    free(curto);
       if (curfrom)  free(curfrom);
       if (curreplyto)      free(curreplyto);
       if (curcc)    free(curcc);
       if (curbcc)   free(curbcc);
       if (cursubj)  free(cursubj);

       printf("<tr><td colspan=\"3\"><hr width=\"100%%\" /></td></tr>");
       printf("<tr>"

              "<th valign=\"top\" align=\"right\">"
              "<p class=\"new-message-header\">"
              "<span class=\"new-message-header-message\">"
              "%s</span></p></th><td width=\"6\">&nbsp;</td>"
              "<td><select name=\"textformat\">"
              "<option value=\"plain\" %s>%s</option>"
              "<option value=\"wiki\" %s>%s</option></select>"

              "<small>(<a href='%s/wikifmt.html' target='_blank'>%s</a>)</small>"
              "</td></tr>"
              "<tr><th valign=\"top\" align=\"right\">"
              "<p class=\"new-message-header\">"
              "<span class=\"new-message-header-message\">"
              "%s</span></p></th><td width=\"6\">&nbsp;</td>",

              getarg("FMTNAME"),
              pref_wikifmt ? "":"selected='selected'", getarg("FMTTEXTPLAIN"),
              pref_wikifmt ? "selected='selected'":"", getarg("FMTTEXTWIKI"),

              get_imageurl(), getarg("FMTHELP"),
              messagelab);

       printf("<td>%s\n", text1);

       if (fp)
       {
              newmsg_showfp(fp, &attachcnt);
       }
       else
       {
              printf("%s", cgi("body"));
       }
       printf("%s\n", text2);

       if (draftmessage && *draftmessage)
       {
              printf("<input type=\"hidden\" name=\"draftmessage\" value=\"");
              output_attrencoded(draftmessage);

              printf("\" />");
       }
       if (draftmessage)    free(draftmessage);
       printf("</td></tr>\n");

       printf("<tr><th valign=\"top\" align=\"right\">"
              "<p class=\"new-message-header\">"
              "<span class=\"new-message-header-message\">"
              "%s</span></p></th><td>&nbsp;</td>"
              "<td>%d&nbsp;&nbsp;<input type=\"submit\" name=\"doattachments\" value=\"%s\" /></td></tr>",
              attachmentslab, attachcnt, uploadlab);

       printf("<tr><td colspan=\"2\" align=\"right\"><input type=\"checkbox\" "
              "name=\"fcc\" id=\"fcc\"%s /></td><td><label for=\"fcc\">%s</label></td></tr>\n",
              pref_noarchive ? "":" checked=\"checked\"",
              getarg("PRESERVELAB"));

       if (auth_getoptionenvint("wbnodsn") == 0)
              printf("<tr><td colspan=\"2\" align=\"right\"><input type=\"checkbox\" "
                     "name=\"dsn\" id=\"dsn\" /></td><td><label for=\"dsn\">%s</label></td></tr>\n",
                     getarg("DSN"));

       if (libmail_gpg_has_gpg(GPGDIR) == 0)
       {
              char *all_addr;

              printf("<tr><td colspan=\"2\" align=\"right\"><input type=\"checkbox\" "
                     "name=\"sign\" id=\"sign\" /></td><td><label for=\"sign\">%s</label><select name=\"signkey\">",
                     getarg("SIGNLAB"));
              gpgselectkey();
              printf("</select></td></tr>\n");

              all_addr=newmsg_alladdrs(fp);

              printf("<tr valign=\"middle\"><td colspan=\"2\" align=\"right\">"
                     "<input type=\"checkbox\" name=\"encrypt\" id=\"encrypt\" /></td>"
                     "<td><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr valign=\"middle\"><td><label for=\"encrypt\">%s</label></td><td><select size=\"4\" multiple=\"multiple\" name=\"encryptkey\">",
                     getarg("ENCRYPTLAB"));
              gpgencryptkeys(all_addr);
              printf("</select></td></tr>\n");
              printf("</table></td></tr>\n");

              if (ishttps())
                     printf("<tr><td colspan=\"2\" align=\"left\">&nbsp;</td><td>%s<input type=\"password\" name=\"passphrase\" /></td></tr>\n",
                            getarg("PASSPHRASE"));

              if (all_addr)
                     free(all_addr);
       }

       if (fp)
              fclose(fp);
       if (draftmessagefilename)
              free(draftmessagefilename);

       printf("<tr><td colspan=\"2\">&nbsp;</td><td>");
       printf("<input type=\"submit\" name=\"previewmsg\" value=\"%s\" />",
              previewlab);
       printf("<input type=\"submit\" name=\"sendmsg\" value=\"%s\" />",
              sendlab);
       printf("<input type=\"submit\" name=\"savedraft\" value=\"%s\" />",
              savedraft);
#ifdef ISPELL
       printf("<input type=\"submit\" name=\"startspellchk\" value=\"%s\" />",
              checkspelling);
#endif
       printf("</td></tr>\n");
       printf("</table>\n");

       printf("</td></tr></table>\n");
       printf("</td></tr></table>\n");
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* newmsg_newdraft ( const char *  ,
const char *  ,
const char *  ,
const char *   
)

Definition at line 47 of file newmsg_newdraft.c.

{
char   *filename=0;
char   *replymode;
size_t pos_n;
FILE   *fp;

const  char *mimeidptr;
char   *draftfilename;
struct rfc2045 *rfc2045p, *rfc2045partp;
int    x;

       if (*cgi(replymode="reply") ||
              *cgi(replymode="replyall") ||
              *cgi(replymode="replylist") ||
              *cgi(replymode="forward") ||
              *cgi(replymode="forwardatt"))
       {
              pos_n=atol(pos);

              filename=get_msgfilename(folder, &pos_n);
       }

       if (!filename)       return (0);

       fp=0;
       x=maildir_semisafeopen(filename, O_RDONLY, 0);

       if (x >= 0)
              if ((fp=fdopen(x, "r")) == 0)
                     close(x);

       if (fp == 0)
       {
              free(filename);
              return (0);
       }

       rfc2045p=rfc2045_fromfp(fp);

       if (!rfc2045p)
       {
              fclose(fp);
              enomem();
       }

       mimeidptr=cgi("mimeid");

       rfc2045partp=0;

       if (*mimeidptr)
       {
              rfc2045partp=rfc2045_find(rfc2045p, mimeidptr);
              if (rfc2045partp)
              {
              const char      *content_type, *dummy;

                     rfc2045_mimeinfo(rfc2045partp, &content_type,
                            &dummy, &dummy);

                     if (!content_type || strcmp(content_type, "message/rfc822"))
                            rfc2045partp=0;
                     else
                            rfc2045partp=rfc2045partp->firstpart;
              }
       }

       if (!rfc2045partp)
              rfc2045partp=rfc2045p;


       draftfd=maildir_createmsg(INBOX "." DRAFTS, 0, &draftfilename);
       if (draftfd < 0)
       {
              fclose(fp);
              rfc2045_free(rfc2045p);
              enomem();
       }

       maildir_writemsgstr(draftfd, "From: ");
       {
       const char *f=pref_from;

              if (!f || !*f)       f=login_fromhdr();
              if (!f)       f="";

              f=rfc2047_encode_header_tobuf("to", f,
                                         sqwebmail_content_charset);

              maildir_writemsgstr(draftfd, f);
              maildir_writemsgstr(draftfd, "\n");
       }

       {
              char *ml=getmailinglists();
              struct rfc2045_mkreplyinfo ri;
              struct rfc2045src *src;
              int rc;

              src=rfc2045src_init_fd(fileno(fp));
              if (src == NULL)
                     enomem();

              memset(&ri, 0, sizeof(ri));
              ri.src=src;
              ri.rfc2045partp=rfc2045partp;
              ri.replymode=replymode;
              ri.replysalut=replysalut;
              ri.forwardsep=forwardsep;
              ri.myaddr_func=ismyaddr;
              ri.write_func=writefunc;
              ri.mailinglists=ml;
              ri.charset=sqwebmail_content_charset;

              if (strcmp(replymode, "forward") == 0
                  || strcmp(replymode, "forwardatt") == 0)
              {
                     rc=rfc2045_makereply(&ri);
              }
              else
              {
              char *basename=maildir_basename(filename);

                     maildir_writemsgstr(draftfd, "X-Reply-To-Folder: ");
                     maildir_writemsgstr(draftfd, folder);
                     maildir_writemsgstr(draftfd, "\nX-Reply-To-Msg: ");

                     maildir_writemsgstr(draftfd, basename);
                     free(basename);
                     maildir_writemsgstr(draftfd, "\n");

                     rc=rfc2045_makereply(&ri);
              }
              free(ml);
              rfc2045src_deinit(src);

              if (rc)
              {
                     fclose(fp);
                     close(draftfd);
                     rfc2045_free(rfc2045p);
                     enomem();
              }
       }

       fclose(fp);
       if (maildir_closemsg(draftfd, INBOX "." DRAFTS, draftfilename, 1, 0))
       {
              free(draftfilename);
              draftfilename=0;
              cgi_put("error", "quota");
       }
       free(filename);
       rfc2045_free(rfc2045p);
       return(draftfilename);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void newmsg_preview ( const char *  p)

Definition at line 506 of file newmsg.c.

{
       size_t pos;

       maildir_remcache(INBOX "." DRAFTS);
       if (maildir_name2pos(INBOX "." DRAFTS, p, &pos) == 0)
       {
              const char *save_folder=sqwebmail_folder;
              cgi_put("showdraft", "1");
              sqwebmail_folder=INBOX "." DRAFTS;
              folder_showmsg(INBOX "." DRAFTS, pos);
              sqwebmail_folder=save_folder;
                            /* show_preview(draftmessagefilename); */
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void newmsg_showfp ( FILE *  fp,
int *  attachcnt 
)

Definition at line 454 of file newmsg.c.

{
       struct rfc2045 *p=rfc2045_fromfp(fp), *q;

       if (!p)       enomem();

       /* Here's a nice opportunity to count all attachments */

       *attachcnt=0;

       for (q=p->firstpart; q; q=q->next)
              if (!q->isdummy)     ++*attachcnt;
       if (*attachcnt)      --*attachcnt;
       /* Not counting the 1st MIME part */

       {
              const char *content_type;
              const char *content_transfer_encoding;
              const char *charset;

              rfc2045_mimeinfo(p, &content_type,
                             &content_transfer_encoding, &charset);

              if (content_type &&
                  strcmp(content_type, "multipart/alternative") == 0)
                     *attachcnt=0;
       }

       q=rfc2045_searchcontenttype(p, "text/plain");

       if (q)
       {
              struct rfc2045src *src=rfc2045src_init_fd(fileno(fp));

              if (src)
              {
                     struct show_textarea_info info;

                     show_textarea_init(&info, 1);

                     rfc2045_decodetextmimesection(src, q,
                                                sqwebmail_content_charset,
                                                NULL,
                                                &show_textarea_trampoline,
                                                &info);
                     rfc2045src_deinit(src);
                     show_textarea(&info, "\n", 1);
              }
       }
       rfc2045_free(p);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void output_attrencoded ( const char *  )

Definition at line 259 of file sqwebmail.c.

{
       output_attrencoded_fp(p, stdout);
}
void output_attrencoded_nltobr ( const char *  )

Definition at line 274 of file sqwebmail.c.

{
       print_attrencodedlen(p, strlen(p), 2, stdout);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void output_attrencoded_oknl ( const char *  )

Definition at line 269 of file sqwebmail.c.

void output_form ( const char *  )

Definition at line 796 of file sqwebmail.c.

{
       FILE   *f;

#ifdef GZIP
       int    dogzip;
       int    pipefd[2];
       pid_t  pid= -1;
#endif

       noimages= auth_getoptionenvint("wbnoimages");

       f=do_open_form(formname, 1);

       sqwebmail_formname=formname;

       if (!f)       error("Can't open form template.");

       /*
       ** Except for the dummy frame window (and the tiny empty frame),
       ** and the window containing the print preview of the message,
       ** expire everything.
       */

       if (strcmp(formname, "index.html") && strcmp(formname, "empty.html") &&
              strcmp(formname, "print.html"))
              cginocache();

#ifdef GZIP

       dogzip=0;
       if (strcmp(formname, "readmsg.html") == 0 ||
           strcmp(formname, "folder.html") == 0 ||
           strcmp(formname, "folders.html") == 0 ||
           strcmp(formname, "gpg.html") == 0)
       {
       const char *p=getenv("HTTP_ACCEPT_ENCODING");

              if (p)
              {
              char   *q=strdup(p), *r;

                     if (!q)       enomem();
                     for (r=q; *r; r++)
                            *r= tolower((int)(unsigned char)*r);
                     for (r=q; (r=strtok(r, ", ")) != 0; r=0)
                            if (strcmp(r, "gzip") == 0)
                            {
                                   dogzip=1;
                                   if (pipe(pipefd))
                                          enomem();
                            }
                     free(q);
              }
       }
#endif

       /* Do not send a Vary header for attachment downloads */

       if (*cgi("download") == 0)
              printf("Vary: Accept-Language\n");

#ifdef GZIP
       if (dogzip)
              printf("Content-Encoding: gzip\n");
#endif

       printf("Content-Type: text/html");

       if (sqwebmail_content_charset)
              printf("; charset=%s", sqwebmail_content_charset);

       printf("\n\n");

#ifdef GZIP
       if (dogzip)
       {
              fflush(stdout);
              while ((pid=fork()) == -1)
                     sleep(5);
              if (pid == 0)
              {
                     dup2(pipefd[0], 0);
                     close(pipefd[0]);
                     close(pipefd[1]);
                     execl(GZIP, "gzip", "-c", (char *)0);
                     fprintf(stderr, 
                            "ERR: Cannot execute " GZIP ": %s\n",
                            strerror(errno));
                     exit(1);
              }

              gzip_save_fd=dup(1);
              dup2(pipefd[1], 1);
              close(pipefd[1]);
              close(pipefd[0]);
       }
#endif
       fix_xml_header(f);
       do_output_form_loop(f);
       do_close_form();

#ifdef GZIP
       if (pid > 0)
       {
       int    waitstat;
       pid_t  p2;

              /* Restore original stdout */

              fflush(stdout);
              dup2(gzip_save_fd, 1);
              close(gzip_save_fd);
              gzip_save_fd= -1;
              while ((p2=wait(&waitstat)) >= 0 && p2 != pid)
                     ;
       }
#endif
}

Here is the caller graph for this function:

Definition at line 384 of file sqwebmail.c.

{
char   *p=scriptptrget();

       printf("%s", p);
       free(p);
       return;
}
void output_urlencoded ( const char *  )

Definition at line 279 of file sqwebmail.c.

{
char   *q=cgiurlencode(p);

       printf("%s", q);
       free(q);
}
void print_attrencodedlen ( const char *  ,
size_t  ,
int  ,
FILE *   
)

Definition at line 215 of file sqwebmail.c.

{
       for (; len; p++, --len)
       {
              switch (*p)   {
              case '<':
                     fprintf(fp, "&lt;");
                     continue;
              case '>':
                     fprintf(fp, "&gt;");
                     continue;
              case '&':
                     fprintf(fp, "&amp;");
                     continue;
              case '"':
                     fprintf(fp, "&quot;");
                     continue;
              case '\n':
                     if (oknl)
                     {
                            if (oknl == 2)
                            {
                                   fprintf(fp, "<br />");
                                   continue;
                            }
                            putc('\n', fp);
                            continue;
                     }
              default:
                     if (!ISCTRL(*p))
                     {
                            putc(*p, fp);
                            continue;
                     }
              }
              fprintf(fp, "&#%d;", (int)(unsigned char)*p);
       }
}
void print_safe_len ( const char *  ,
size_t  ,
void(*)(const char *, size_t)   
)

Definition at line 112 of file folder.c.

{
char   buf[10];
const  char *q=p;

       while (n)
       {
              --n;
              if (*p == '<')       strcpy(buf, "&lt;");
              else if (*p == '>') strcpy(buf, "&gt;");
              else if (*p == '&') strcpy(buf, "&amp;");
              else if (*p == ' ') strcpy(buf, "&nbsp;");
              else if (*p == '\n') strcpy(buf, "<br />");
              else if (ISCTRL(*p))
                     sprintf(buf, "&#%d;", (int)(unsigned char)*p);
              else
              {
                     p++;
                     continue;
              }

              (*func)(q, p-q);
              (*func)(buf, strlen(buf));
              p++;
              q=p;
       }
       (*func)(q, p-q);
}

Here is the caller graph for this function:

static void printc ( char  c,
void *  dummy 
) [static]

Definition at line 106 of file newmsg.c.

{
       char b[2];

       b[0]=c;
       b[1]=0;
       output_attrencoded(b);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void printsep ( const char *  c,
void *  dummy 
) [static]

Definition at line 115 of file newmsg.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void sendmsg_done ( )

Definition at line 902 of file newmsg.c.

{
       if ( *cgi("pos"))
              http_redirect_argss("&form=readmsg&pos=%s", cgi("pos"), "");
       else if (*cgi("sendmsg"))
              http_redirect_argss("&form=folders&foldermsg=sent", "", "");
       else
              http_redirect_argss("&form=folders", "", "");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void show_textarea ( struct show_textarea_info info,
const char *  ptr,
size_t  cnt 
)

Definition at line 213 of file newmsg.c.

{
       while (cnt)
       {
              size_t n= (*info->handler)(info, ptr, cnt);

              cnt -= n;
              ptr += n;
       }
}

Here is the caller graph for this function:

static size_t show_textarea_check_sig ( struct show_textarea_info info,
const char *  ptr,
size_t  cnt 
) [static]

Definition at line 323 of file newmsg.c.

{
       static const char sig[]={'-', '-', ' ', '\n'};
       size_t i;

       for (i=0; i<cnt; ++i)
       {
              if (i + info->sig_index >= sizeof(sig))
              {
                     info->handler=show_textarea_ignore_sig;
                     return cnt;
              }

              if (ptr[i] != sig[i+info->sig_index])
              {
                     info->handler=show_textarea_notseen_sp;

                     show_textarea(info, sig, info->sig_index);
                     show_textarea(info, ptr, cnt);
                     return cnt;
              }
       }

       info->sig_index += cnt;
       return cnt;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static size_t show_textarea_ignore_sig ( struct show_textarea_info info,
const char *  ptr,
size_t  cnt 
) [static]

Definition at line 351 of file newmsg.c.

{
       return cnt;
}

Here is the caller graph for this function:

void show_textarea_init ( struct show_textarea_info info,
int  stop_at_sig 
)

Definition at line 206 of file newmsg.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static size_t show_textarea_notseen_sp ( struct show_textarea_info info,
const char *  ptr,
size_t  cnt 
) [static]

Definition at line 268 of file newmsg.c.

{
       size_t i;

       for (i=0; i<cnt; i++)
       {
              if (ptr[i] == '\n')
              {
                     ++i;
                     info->handler=show_textarea_start_of_line;
                     break;
              }

              if (ptr[i] == ' ')
              {
                     if (i)
                            print_attrencodedlen(ptr, i, 1, stdout);
                     info->handler=show_textarea_seen_sp;
                     return i+1;
              }
       }

       if (i)
              print_attrencodedlen(ptr, i, 1, stdout);
       return i;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static size_t show_textarea_quoted_text ( struct show_textarea_info info,
const char *  ptr,
size_t  cnt 
) [static]

Definition at line 248 of file newmsg.c.

{
       size_t i;

       for (i=0; i<cnt; i++)
       {
              if (ptr[i] == '\n')
              {
                     ++i;
                     info->handler=show_textarea_start_of_line;
                     break;
              }
       }

       if (i)
              print_attrencodedlen(ptr, i, 1, stdout);
       return i;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static size_t show_textarea_seen_sp ( struct show_textarea_info info,
const char *  ptr,
size_t  cnt 
) [static]

Definition at line 296 of file newmsg.c.

{
       if (*ptr != '\n')
       {
              info->handler=show_textarea_notseen_sp;
              print_attrencodedlen(" ", 1, 1, stdout);
              return show_textarea_notseen_sp(info, ptr, cnt);
       }

       info->handler=show_textarea_seen_spnl;
       return 1;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static size_t show_textarea_seen_spnl ( struct show_textarea_info info,
const char *  ptr,
size_t  cnt 
) [static]

Definition at line 310 of file newmsg.c.

{
       if (*ptr == '>' || *ptr == '\n') /* Fix this */
       {
              print_attrencodedlen("\n", 1, 1, stdout);
              return show_textarea_start_of_line(info, ptr, cnt);
       }

       info->handler=show_textarea_notseen_sp;
       return show_textarea_notseen_sp(info, ptr, cnt);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static size_t show_textarea_start_of_line ( struct show_textarea_info info,
const char *  ptr,
size_t  cnt 
) [static]

Definition at line 225 of file newmsg.c.

{
       if (*ptr == '>')
       {
              info->handler=show_textarea_quoted_text;
              return show_textarea_quoted_text(info, ptr, cnt);
       }

       info->handler=show_textarea_notseen_sp;

       if (*ptr == ' ')
              return 1; /* Consume space-stuffed space */

       if (info->stop_at_sig)
       {
              info->handler=show_textarea_check_sig;
              info->sig_index=0;
              return show_textarea_check_sig(info, ptr, cnt);
       }
       return show_textarea_notseen_sp(info, ptr, cnt);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int show_textarea_trampoline ( const char *  ptr,
size_t  cnt,
void *  arg 
) [static]

Definition at line 448 of file newmsg.c.

{
       show_textarea( (struct show_textarea_info *)arg, ptr, cnt);
       return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int spell_start ( const char *  )

Definition at line 33 of file sqispell.c.

{
char   *filename=maildir_find(INBOX "." DRAFTS, c);

       if (!c)       return (-1);

       if (search_spell(filename, 0, 0) == 0)
              return (-1);

       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int waitfor ( pid_t  pid) [static]

Definition at line 891 of file newmsg.c.

{
pid_t  childpid;
int    wait_stat;

       while ((childpid=wait(&wait_stat)) != pid)
              if (childpid == -1)  return (-1);

       return (wait_stat);
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 39 of file gpg.c.

const char* sqwebmail_folder

Definition at line 106 of file sqwebmail.c.

const char* sqwebmail_mailboxid

Definition at line 105 of file sqwebmail.c.