Back to index

courier  0.68.2
Functions | Variables
pref.h File Reference
#include <stdio.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void pref_setprefs ()
void pref_isoldest1st ()
void pref_isdisplayfullmsg ()
void pref_displayautopurge ()
void pref_sortorder ()
void pref_pagesize ()
void pref_displayhtml ()
void pref_displayflowedtext ()
void pref_displaynoarchive ()
void pref_displaynoautorenamesent ()
void pref_displayweekstart ()
void pref_init ()
void pref_signature ()
void pref_setfrom (const char *p)
void pref_setldap (const char *p)
void pref_update ()
char * pref_getsig ()
char * pref_getfile (FILE *)
char * pref_getdefaultgpgkey ()
void pref_setdefaultgpgkey (const char *)

Variables

int pref_flagisoldest1st
int pref_flagfullheaders
int pref_flagsortorder
int pref_flagpagesize
int pref_autopurge
int pref_showhtml
int pref_noflowedtext
int pref_noarchive
int pref_noautorenamesent
int pref_startofweek
int pref_wikifmt
char * pref_from
char * pref_ldap

Function Documentation

Definition at line 482 of file pref.c.

{
       printf("<input type=\"text\" name=\"autopurge\" value=\"%d\" size=\"2\" maxlength=\"2\" />",
              pref_autopurge);
}

Here is the caller graph for this function:

Definition at line 445 of file pref.c.

{
       printf("<input type=\"checkbox\" name=\"%s\" id=\"%s\"%s />",
              FLOWEDTEXT_PREF, FLOWEDTEXT_PREF, pref_noflowedtext ? " checked=\"checked\"":"");
}

Here is the caller graph for this function:

void pref_displayhtml ( )

Definition at line 439 of file pref.c.

{
       printf("<input type=\"checkbox\" name=\"%s\" id=\"%s\"%s />",
              HTML_PREF, HTML_PREF, pref_showhtml ? " checked=\"checked\"":"");
}

Here is the caller graph for this function:

Definition at line 470 of file pref.c.

{
       printf("<input type=\"checkbox\" name=\"%s\" id=\"%s\"%s />",
              NOARCHIVE_PREF, NOARCHIVE_PREF, pref_noarchive ? " checked=\"checked\"":"");
}

Here is the caller graph for this function:

Definition at line 476 of file pref.c.

{
       printf("<input type=\"checkbox\" name=\"%s\" id=\"%s\"%s />",
              NOAUTORENAMESENT_PREF, NOAUTORENAMESENT_PREF, pref_noautorenamesent ? " checked=\"checked\"":"");
}

Here is the caller graph for this function:

Definition at line 451 of file pref.c.

{
       int i, j;
       static const int d[3]={6,0,1};

       printf("<select name=\"" STARTOFWEEK "\">");

       for (j=0; j<3; j++)
       {
              i=d[j];
              printf("<option value=\"%d\"%s>", i,
                     i == pref_startofweek ? " selected='selected'":"");

              output_attrencoded_oknl( pcp_wdayname_long(i));
              printf("</option>");
       }
       printf("</select>");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 668 of file pref.c.

{
       return (getgpgconfig(DEFAULTKEY));
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* pref_getfile ( FILE *  )

Definition at line 529 of file pref.c.

{
       struct stat st;
       char *utf8_buf;
       char *sig_buf;

       if (fp == NULL)
              return NULL;

       if (fstat(fileno(fp), &st) < 0)
       {
              fclose(fp);
              return NULL;
       }

       utf8_buf=malloc(st.st_size+1);

       if (!utf8_buf)
       {
              fclose(fp);
              return NULL;
       }

       if (fread(utf8_buf, 1, st.st_size, fp) != st.st_size)
       {
              fclose(fp);
              return NULL;
       }
       utf8_buf[st.st_size]=0;
       fclose(fp);

       sig_buf=libmail_u_convert_fromutf8(utf8_buf,
                                      sqwebmail_content_charset,
                                      NULL);
       free(utf8_buf);

       return sig_buf;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* pref_getsig ( )

Definition at line 524 of file pref.c.

{
       return pref_getfile(fopen(SIGNATURE, "r"));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pref_init ( )

Definition at line 98 of file pref.c.

{
const  char *p;
char   *q, *r;

       p=read_sqconfig(".", CONFIGFILE, 0);
       pref_flagisoldest1st=0;
       pref_flagfullheaders=0;
       pref_flagsortorder=0;
       pref_flagpagesize=10;
       pref_noarchive=0;

       {
              const char *autorenamesent=AUTORENAMESENT;

              const char *p=getenv("SQWEBMAIL_AUTORENAMESENT");
              if (p && *p)
                     autorenamesent = p;

              pref_noautorenamesent=strncmp(autorenamesent, "no", 2) == 0;
       }

       pref_startofweek=0;
       pref_autopurge=AUTOPURGE;
       pref_showhtml=1;
       pref_wikifmt=0;

       if(pref_from) {
              free(pref_from);
              pref_from=0;
              }

       if(pref_ldap) {
              free(pref_ldap);
              pref_ldap=0;
              }


       if (p)
       {
              q=strdup(p);
              if (!q)       enomem();

              for (r=q; (r=strtok(r, " ")) != 0; r=0)
              {
                     if (strcmp(r, OLDEST1ST) == 0)
                            pref_flagisoldest1st=1;
                     if (strcmp(r, FULLHEADERS) == 0)
                            pref_flagfullheaders=1;
                     if (strcmp(r, NOHTML) == 0)
                            pref_showhtml=0;
                     if (strcmp(r, WIKITEXT) == 0)
                            pref_wikifmt=1;

                     if (strncmp(r, SORTORDER, sizeof(SORTORDER)-1) == 0
                            && r[sizeof(SORTORDER)-1] == '=')
                            pref_flagsortorder=r[sizeof(SORTORDER)];
                     if (strncmp(r, PAGESIZE, sizeof(PAGESIZE)-1) == 0
                            && r[sizeof(PAGESIZE)-1] == '=')
                            pref_flagpagesize=atoi(r+sizeof(PAGESIZE));
                     if (strncmp(r, AUTOPURGE_V, sizeof(AUTOPURGE_V)-1) == 0
                            && r[sizeof(AUTOPURGE_V)-1] == '=')
                            pref_autopurge=atoi(r+sizeof(AUTOPURGE_V));
                     if (strncmp(r, FLOWEDTEXT, sizeof(FLOWEDTEXT)-1) == 0
                            && r[sizeof(FLOWEDTEXT)-1] == '=')
                            pref_noflowedtext=atoi(r+sizeof(FLOWEDTEXT));
                     if (strncmp(r, NOARCHIVE, sizeof(NOARCHIVE)-1) == 0
                            && r[sizeof(NOARCHIVE)-1] == '=')
                            pref_noarchive=atoi(r+sizeof(NOARCHIVE));
                     if (strncmp(r, NOAUTORENAMESENT, sizeof(NOAUTORENAMESENT)-1) == 0
                            && r[sizeof(NOAUTORENAMESENT)-1] == '=')
                            pref_noautorenamesent=atoi(r+sizeof(NOAUTORENAMESENT));
                     if (strncmp(r, FROM, sizeof(FROM)-1) == 0
                            && r[sizeof(FROM)-1] == '=')
                     {
                            if (pref_from)       free(pref_from);
                            if ((pref_from=strdup(r+sizeof(FROM))) == 0)
                                   enomem();

                            decode(pref_from);
                     }
                     if (strncmp(r, LDAP, sizeof(LDAP)-1) == 0
                            && r[sizeof(LDAP)-1] == '=')
                     {
                            if (pref_ldap)       free(pref_ldap);
                            if ((pref_ldap=strdup(r+sizeof(LDAP))) == 0)
                                   enomem();

                            decode(pref_ldap);
                     }
                     if (strncmp(r, STARTOFWEEK, sizeof(STARTOFWEEK)-1) == 0
                            && r[sizeof(STARTOFWEEK)-1] == '=')
                     {
                            int n=atoi(r+sizeof(STARTOFWEEK));

                            if (n >= 0 && n < 7)
                                   pref_startofweek=n;
                     }

              }
              free(q);
       }
       switch (pref_flagpagesize)  {
       case 20:
       case 50:
       case 100:
       case 250:
              break;
       default:
              pref_flagpagesize=10;
              break;
       }

       if (pref_autopurge < 0)     pref_autopurge=0;
       if (pref_autopurge > MAXPURGE)     pref_autopurge=MAXPURGE;

       switch (pref_flagsortorder) {
       case 'F':
       case 'S':
              break;
       default:
              pref_flagsortorder='D';
              break;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 433 of file pref.c.

{
       printf("<input type=\"checkbox\" name=\"%s\" id=\"%s\"%s />",
              FULLHEADERS_PREF, FULLHEADERS_PREF, pref_flagfullheaders ? " checked=\"checked\"":"");
}

Here is the caller graph for this function:

void pref_isoldest1st ( )

Definition at line 427 of file pref.c.

{
       printf("<input type=\"checkbox\" name=\"%s\" id=\"%s\"%s />",
              OLDEST1ST_PREF, OLDEST1ST_PREF, pref_flagisoldest1st ? " checked=\"checked\"":"");
}

Here is the caller graph for this function:

void pref_pagesize ( )

Definition at line 506 of file pref.c.

{
static const char selected[]=" selected='selected'";

       printf("<select name=\"pagesize\">");
       printf("<option value=\"10\"%s>10</option>\n",
              pref_flagpagesize == 10 ? selected:"");
       printf("<option value=\"20\"%s>20</option>\n",
              pref_flagpagesize == 20 ? selected:"");
       printf("<option value=\"50\"%s>50</option>\n",
              pref_flagpagesize == 50 ? selected:"");
       printf("<option value=\"100\"%s>100</option>\n",
              pref_flagpagesize == 100 ? selected:"");
       printf("<option value=\"250\"%s>250</option>\n",
              pref_flagpagesize == 250 ? selected:"");
       printf("</select>\n");
}

Here is the caller graph for this function:

void pref_setdefaultgpgkey ( const char *  )

Definition at line 673 of file pref.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void pref_setfrom ( const char *  p)

Definition at line 302 of file pref.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void pref_setldap ( const char *  p)

Definition at line 310 of file pref.c.

{
       if (pref_ldap && strcmp(p, pref_ldap) == 0)
              return;

       if (pref_ldap)       free(pref_ldap);
       pref_ldap=strdup(p);
       if (!pref_ldap)      enomem();
       pref_update();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pref_setprefs ( )

Definition at line 321 of file pref.c.

{
       if (*cgi("do.changeprefs"))
       {
       char   buf[1000];
       FILE   *fp;
       char   *p;
       char   *q;

              sprintf(buf, SORTORDER "=%c " PAGESIZE "=%s " AUTOPURGE_V "=%s "
                     FLOWEDTEXT "=%s "
                     NOARCHIVE "=%s "
                     NOAUTORENAMESENT "=%s "
                     STARTOFWEEK "=%d",
                     *cgi("sortorder"), cgi("pagesize"), cgi("autopurge"),
                     *cgi(FLOWEDTEXT_PREF) ? "1":"0",
                     *cgi(NOARCHIVE_PREF) ? "1":"0",
                     *cgi(NOAUTORENAMESENT_PREF) ? "1":"0",
                     (int)((unsigned)atoi(cgi(STARTOFWEEK)) % 7)
                     );

              if (*cgi(OLDEST1ST_PREF))
                     strcat(buf, " " OLDEST1ST);
              if (*cgi(FULLHEADERS_PREF))
                     strcat(buf, " " FULLHEADERS);
              if (!*cgi(HTML_PREF))
                     strcat(buf, " " NOHTML);

              p=append_str(buf, FROM, pref_from);
              q=append_str(p, LDAP, pref_ldap);
              write_sqconfig(".", CONFIGFILE, q);
              free(p);
              free(q);
              pref_init();
              if ((fp=fopen(SIGNATURE, "w")) != NULL)
              {
                     char *sig_utf8=
                            libmail_u_convert_toutf8(cgi("signature"),
                                                  sqwebmail_content_charset,
                                                  NULL);

                     if (sig_utf8)
                     {
                            fprintf(fp, "%s", sig_utf8);
                            free(sig_utf8);
                     }
                     fclose(fp);
              }

              savemailinglists(cgi("mailinglists"));

              printf("%s\n", getarg("PREFSOK"));

              rename_sent_folder(0);
       }

       if (*cgi("do.changepwd"))
       {
              int status=1;
              const  char *p=cgi("newpass");
              int has_syspwd=0;

              if ( *p && strcmp(p, cgi("newpass2")) == 0
                     && strlen(p) >= MINPASSLEN)
              {
                     has_syspwd=
                            login_changepwd(sqwebmail_mailboxid,
                                          cgi("oldpass"), p,
                                          &status);
              }

              if (has_syspwd || status)
              {
                     printf("%s\n", getarg("PWDERR"));
              }
              else
              {
                     printf("%s\n", getarg("PWDOK"));
              }
       }

#if 0
       if (*cgi("do.changepwd"))
       {
#if ENABLE_WEBPASS

       const  char *p;

              if (check_sqwebpass(cgi("oldpass")) == 0 &&
                     *(p=cgi("newpass")) &&
                     goodpass(p) &&
                     strcmp(p, cgi("newpass2")) == 0)
              {
                     set_sqwebpass(p);
              }
              else
              {
                     printf("%s\n", getarg("PWDERR"));
              }
#else
              printf("%s\n", getarg("PWDERR"));
#endif
       }
#endif
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pref_signature ( )

Definition at line 568 of file pref.c.

{
       char *p=pref_getsig();

       if (p)
       {
              output_attrencoded_oknl(p);
              free(p);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pref_sortorder ( )

Definition at line 488 of file pref.c.

{
static const char selected[]=" selected='selected'";

       printf("<select name=\"sortorder\">");
       printf("<option value=\"DATE\"%s>%s</option>\n",
              pref_flagsortorder == 'D' ? selected:"",
              getarg("DATE"));

       printf("<option value=\"FROM\"%s>%s</option>\n",
              pref_flagsortorder == 'F' ? selected:"",
              getarg("SENDER"));
       printf("<option value=\"SUBJECT\"%s>%s</option>\n",
              pref_flagsortorder == 'S' ? selected:"",
              getarg("SUBJECT"));
       printf("</select>\n");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pref_update ( )

Definition at line 270 of file pref.c.

{
char   buf[1000];
char   *p;
char   *q;

       sprintf(buf, SORTORDER "=%c " PAGESIZE "=%d " AUTOPURGE_V "=%d "
              FLOWEDTEXT "=%d " NOARCHIVE "=%d " NOAUTORENAMESENT "=%d "
              STARTOFWEEK "=%d",
              pref_flagsortorder, pref_flagpagesize, pref_autopurge,
              pref_noflowedtext, pref_noarchive, pref_noautorenamesent,
              pref_startofweek);

       if (pref_flagisoldest1st)
              strcat(buf, " " OLDEST1ST);

       if (pref_flagfullheaders)
              strcat(buf, " " FULLHEADERS);

       if (!pref_showhtml)
              strcat(buf, " " NOHTML);

       if (pref_wikifmt)
              strcat(buf, " " WIKITEXT);

       p=append_str(buf, FROM, pref_from);
       q=append_str(p, LDAP, pref_ldap);
       write_sqconfig(".", CONFIGFILE, q);
       free(q);
       free(p);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

Definition at line 50 of file pref.c.

Definition at line 46 of file pref.c.

Definition at line 46 of file pref.c.

Definition at line 49 of file pref.c.

Definition at line 48 of file pref.c.

char* pref_from

Definition at line 57 of file pref.c.

char* pref_ldap

Definition at line 58 of file pref.c.

Definition at line 52 of file pref.c.

Definition at line 53 of file pref.c.

Definition at line 51 of file pref.c.

Definition at line 47 of file pref.c.

Definition at line 54 of file pref.c.

Definition at line 55 of file pref.c.