Back to index

courier  0.68.2
Classes | Defines | Functions | Variables
pcp.c File Reference
#include "sqwebmail.h"
#include "pcp.h"
#include "pref.h"
#include "htmllibdir.h"
#include "sqconfig.h"
#include "auth.h"
#include "addressbook.h"
#include "pcp/pcp.h"
#include "cgi/cgi.h"
#include "rfc822/rfc822.h"
#include "rfc822/rfc822hdr.h"
#include "rfc822/rfc2047.h"
#include "maildir/maildircreate.h"
#include "maildir/maildirmisc.h"
#include "maildir/maildirquota.h"
#include "maildir/maildirgetquota.h"
#include "numlib/numlib.h"
#include "maildir.h"
#include "newmsg.h"
#include "courierauth.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include <ctype.h>
#include <unistd.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "strftime.h"

Go to the source code of this file.

Classes

struct  cacherecord
struct  cacherecord_list
struct  retr_xinfo
struct  my_participant
struct  conflict_list
struct  participant_list
struct  saveinfo
struct  proxy_list_entry
struct  proxy_update_list
struct  display_retr_time_list
struct  display_retr_participant_list
struct  display_retr
struct  getedit_info
struct  acl_list

Defines

#define WEXITSTATUS(stat_val)   ((unsigned)(stat_val) >> 8)
#define WIFEXITED(stat_val)   (((stat_val) & 255) == 0)
#define CACHE   "calendar.cache"
#define TOKEN   "calendar.authtoken"
#define CHANGEDFILE   "calendar/changed" /* Hack */
#define VIEW_DAILY   0
#define VIEW_WEEKLY   1
#define VIEW_MONTHLY   2

Functions

FILE * open_langform (const char *lang, const char *formname, int print_header)
const char * myhostname ()
void output_attrencoded_oknl_fp (const char *, FILE *)
void output_scriptptrget ()
void output_attrencoded (const char *)
void print_safe (const char *)
void output_form (const char *)
void newmsg_preview (const char *)
void output_urlencoded (const char *)
void attachments_head (const char *, const char *, const char *)
char * newmsg_createsentmsg (const char *, int *)
char * scriptptrget ()
void attach_delete (const char *)
int attach_upload (const char *, const char *, const char *)
void newmsg_showfp (FILE *, int *)
static void refreshcache (struct PCP *)
size_t get_timeoutsoft ()
void sqpcp_init ()
void sqpcp_close ()
static const char * sqpcp_mode ()
static void do_pcplogin (const char *userid, const char *password, int showerr)
void sqpcp_login (const char *userid, const char *password)
int sqpcp_has_calendar ()
int sqpcp_has_groupware ()
static int createcache (struct PCP *, struct cacherecord **, unsigned *, time_t, time_t)
static void destroycache (struct cacherecord *, unsigned)
static int need_refresh ()
int sqpcp_loggedin ()
static const char * parsetimet (const char *buf, time_t *tp)
static int cmp_reclist (const void *a, const void *b)
static int callback_createcache (struct PCP_list_all *, void *)
static int callback_retr_status (struct PCP_retr *, int, void *)
static int callback_retr_headers (struct PCP_retr *, const char *, const char *, void *)
static void destroycache_rec (struct cacherecord *)
static void collapse_subject (char *s)
static void parsecache_rec (char *p, struct cacherecord *cr)
struct PCPsqpcp_calendar ()
static FILE * openoldfp (const char *p, unsigned long *prev_size)
static void add_my_participant (const char *h)
void sqpcp_eventstart ()
void sqpcp_eventend ()
void sqpcp_eventtimes ()
static int save_participant_names (const char *addr, const char *name, void *vp)
void sqpcp_eventparticipants ()
void sqpcp_eventfrom ()
void sqpcp_eventtext ()
void sqpcp_eventattach ()
static void print_event_subject (char *, const char *, unsigned)
static void print_event_link_url (const char *, const char *)
void sqpcp_summary ()
static int addtime (int)
static void addparticipant (int, const char *)
static void init_save_conflict ()
static int save_conflict (const char *event_id, time_t start, time_t end, const char *address, void *dummy)
static int save_conflict_subj (struct PCP_retr *, const char *, const char *, void *)
static void show_conflict_error (struct PCP *pcp)
static void showerror ()
void sqpcp_newevent ()
static char ** mkargv (char *p, int *argc)
static int savetime (time_t, time_t, void *)
static char * savedraft ()
static void previewdraft (char *msg, void(*func)(const char *))
void sqpcp_preview ()
void sqpcp_postpone ()
static void deleteattach (const char *)
void sqpcp_deleteattach ()
static void doupload (const char *)
void sqpcp_uploadattach ()
void sqpcp_attachpubkey ()
void sqpcp_attachprivkey ()
static int init_saveinfo (struct saveinfo *si, FILE *fp)
static void free_saveinfo (struct saveinfo *si)
static void dropquota (const char *filename, int fd)
static int dosave (FILE *, struct saveinfo *)
void sqpcp_save ()
static void saveerror (struct PCP *pcp, const int *xerror)
static void proxy_update_list_save (const char *action, const char *userid, void *voidarg)
static void proxy_update_list_free (struct proxy_update_list *p)
static void proxy_notify_email_msg (FILE *, struct proxy_list_entry *, const char *, const struct PCP_event_time *, unsigned)
static void proxy_notify_email (FILE *f, struct proxy_update_list *pul, const struct PCP_event_time *t, unsigned tn)
static void dosendnotice (FILE *, FILE *, FILE *, struct proxy_list_entry *, const char *, const struct PCP_event_time *, unsigned)
void sqpcp_todays_date ()
void sqpcp_todays_date_verbose ()
void sqpcp_weeklylink ()
void sqpcp_monthlylink ()
static void do_daily_view (struct cacherecord *, unsigned, int, time_t *, time_t *)
static void show_pcp_errmsg (const char *p)
void sqpcp_daily_view ()
static void print_event_link (const char *id, const char *extra, const char *extra2)
void sqpcp_prevday ()
void sqpcp_nextday ()
static void free_display_retr (struct display_retr *r)
static int save_displayed_event (struct PCP_retr *, const char *, int, void *)
static int set_status (struct PCP_retr *, int, void *)
void sqpcp_displayeventinit ()
static int save_displayed_date (struct PCP_retr *r, time_t start, time_t end, void *vp)
static int save_displayed_participants (struct PCP_retr *r, const char *address, const char *dummy, void *vp)
void sqpcp_displayevent ()
static void back_to_summary ()
void sqpcp_eventbacklink ()
void sqpcp_eventeditlink ()
void sqpcp_eventdeletelink ()
void sqpcp_eventcanceluncancellink ()
void sqpcp_eventcanceluncancelimage ()
void sqpcp_eventcanceluncanceltext ()
void sqpcp_deleteeventinit ()
static int save_orig_headers (struct PCP_retr *pcp, const char *h, const char *v, void *vp)
void sqpcp_dodelete ()
static int doeventedit (struct PCP *, int)
int sqpcp_eventedit ()
static int get_date (struct PCP_retr *r, time_t start, time_t end, void *vp)
static int get_participants (struct PCP_retr *r, const char *address, const char *dummy, void *vp)
static int get_msgtext (struct PCP_retr *r, const char *ptr, int n, void *vp)
static void prevday (time_t *tm)
static void nextday (time_t *tm)
static time_t get_start_of_week ()
void sqpcp_show_cal_week ()
void sqpcp_show_cal_nextweek ()
void sqpcp_show_cal_prevweek ()
void sqpcp_displayweek ()
static time_t get_start_of_month ()
void sqpcp_show_cal_month ()
void sqpcp_show_cal_nextmonth ()
void sqpcp_show_cal_prevmonth ()
void sqpcp_displaymonth ()
static void addacl (const char *)
static int listacl (const char *a, int f, void *vp)
static int save_listacl_names (const char *addr, const char *name, void *vp)
void sqpcp_eventacl ()

Variables

const char * sqwebmail_content_charset
const char * sqwebmail_content_language
const char * sqwebmail_mailboxid
static struct PCPcalendar = NULL
static int checked_calendar_mode = 0
static char calendar_mode [24]
static struct PCP_event_timeevent_time_list = 0
static unsigned n_event_time_list = 0
static struct my_participantmy_participant_list = 0
static char * from_buf = 0
static char * subj_buf = 0
static struct conflict_listconflict_list = NULL

Class Documentation

struct cacherecord

Definition at line 215 of file pcp.c.

Class Members
time_t end
char * eventid
char * flags
time_t start
char * subject
struct cacherecord_list

Definition at line 411 of file pcp.c.

Collaboration diagram for cacherecord_list:
Class Members
struct cacherecord_list * next
struct retr_xinfo

Definition at line 435 of file pcp.c.

Collaboration diagram for retr_xinfo:
Class Members
unsigned n_recs
struct cacherecord * recs
struct my_participant

Definition at line 835 of file pcp.c.

Collaboration diagram for my_participant:
Class Members
char * address
char * name
struct my_participant * next
struct conflict_list

Definition at line 1419 of file pcp.c.

Collaboration diagram for conflict_list:
Class Members
char * address
time_t end
char * event_id
struct conflict_list * next
time_t start
char * subject
struct participant_list

Definition at line 125 of file pcp.c.

Collaboration diagram for participant_list:
Class Members
char * address
struct participant_list * next
struct saveinfo

Definition at line 2201 of file pcp.c.

Collaboration diagram for saveinfo:
Class Members
unsigned n_participants
unsigned n_times
char * old_eventid
struct participant_list * participant_list
struct PCP_event_participant * participants
struct PCP_event_time * times
struct proxy_list_entry

Definition at line 2550 of file pcp.c.

Collaboration diagram for proxy_list_entry:
Class Members
struct proxy_list_entry * next
char * userid
struct proxy_update_list

Definition at line 2555 of file pcp.c.

Collaboration diagram for proxy_update_list:
Class Members
struct proxy_list_entry * delete_list
struct proxy_list_entry * new_list
struct display_retr_time_list

Definition at line 3136 of file pcp.c.

Collaboration diagram for display_retr_time_list:
Class Members
time_t end
struct display_retr_time_list * next
time_t start
struct display_retr_participant_list

Definition at line 3142 of file pcp.c.

Collaboration diagram for display_retr_participant_list:
Class Members
struct
display_retr_participant_list *
next
char * participant
struct display_retr

Definition at line 3147 of file pcp.c.

Collaboration diagram for display_retr:
Class Members
FILE * f
struct
display_retr_participant_list *
participant_list
struct display_retr_time_list * time_list
struct getedit_info

Definition at line 3546 of file pcp.c.

Class Members
int fd
int flag
int in_headers
int skiph
int sol
struct acl_list

Definition at line 1406 of file pcpd.c.

Collaboration diagram for acl_list:
Class Members
char * addr
int flags
char * name
struct acl_list * next
char * who

Define Documentation

#define CACHE   "calendar.cache"

Definition at line 53 of file pcp.c.

#define CHANGEDFILE   "calendar/changed" /* Hack */

Definition at line 56 of file pcp.c.

#define TOKEN   "calendar.authtoken"

Definition at line 54 of file pcp.c.

#define VIEW_DAILY   0

Definition at line 2904 of file pcp.c.

#define VIEW_MONTHLY   2

Definition at line 2906 of file pcp.c.

#define VIEW_WEEKLY   1

Definition at line 2905 of file pcp.c.

#define WEXITSTATUS (   stat_val)    ((unsigned)(stat_val) >> 8)

Definition at line 47 of file pcp.c.

#define WIFEXITED (   stat_val)    (((stat_val) & 255) == 0)

Definition at line 50 of file pcp.c.


Function Documentation

static void add_my_participant ( const char *  h) [static]

Definition at line 843 of file pcp.c.

{
       struct my_participant *m=
              malloc(sizeof(struct my_participant));

       if (!m)
              enomem();

       memset(m, 0, sizeof(*m));
       m->next=my_participant_list;
       my_participant_list=m;

       if ((m->address=strdup(h)) == NULL)
              enomem();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void addacl ( const char *  p) [static]

Definition at line 4245 of file pcp.c.

{
       int flags=0;
       struct PCP *pcp;

       if (strchr(p, '@') == NULL)
       {
              const char *mhn=myhostname();
              char *q=malloc(strlen(p)+strlen(mhn)+2);

              if (!q)
                     enomem();

              strcat(strcat(strcpy(q, p), "@"), mhn);
              addacl(q);
              free(q);
              return;
       }

       if (*cgi("aclMODIFY"))
              flags |= PCP_ACL_MODIFY;

       if (*cgi("aclCONFLICT"))
              flags |= PCP_ACL_CONFLICT;

       if (!flags)
              return;       /* Noop */

       pcp=sqpcp_calendar();

       if (!pcp)
       {
              int xerror=PCP_ERR_SYSERR;

              saveerror(NULL, &xerror);
              showerror();
              return;
       }

       if (!pcp_has_acl(pcp))
       {
              printf("%s\n", getarg("NOACL"));
              return;
       }

       if (pcp_acl(pcp, p, flags))
       {
              saveerror(pcp, NULL);
              showerror();
              return;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void addparticipant ( int  fd,
const char *  n 
) [static]

Definition at line 2036 of file pcp.c.

{
       char *nn, *p, *q;

       const char *domain;

       domain=getenv("AUTHADDR");

       if (domain)
              domain=strrchr(domain, '@');

       if (domain)
              ++domain;
       else
              domain=myhostname();

       while (n && isspace((int)(unsigned char)*n))
              ++n;

       if (!n || !*n)
              return;

       if (strchr(n, '\n') || strchr(n, '\r'))
              return;

       if ((nn=malloc(strlen(n)+strlen(domain)+2)) == NULL)
              enomem();

       strcpy(nn, n);

       for (p=q=nn; *p; p++)
              if (!isspace((int)(unsigned char)*p))
                     q=p+1;
       *q=0;

       if (strchr(nn, '@') == 0)
              strcat(strcat(nn, "@"), domain);


       maildir_writemsgstr(fd, "X-Event-Participant: ");
       maildir_writemsgstr(fd, nn);
       maildir_writemsgstr(fd, "\n");
       add_my_participant(nn);
       free(nn);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int addtime ( int  newdraftfd) [static]

Definition at line 1956 of file pcp.c.

{
       struct pcp_parse_datetime_info pdi;
       char *t_buf;
       char **t_argv;
       time_t starttime, endtime;
       int argn, argc;
       int h, m;

       pdi.today_name=cgi("today");              /* Locale string */
       pdi.tomorrow_name=cgi("tomorrow"); /* Locale string */

       t_buf=strdup(cgi("starttime"));
       if (!t_buf)
              return (-1);
       t_argv=mkargv(t_buf, &argc);
       if (!t_argv)
       {
              free(t_buf);
              return (-1);
       }

       argn=0;
       starttime=pcp_parse_datetime(&argn, argc, t_argv, &pdi);
       free(t_argv);
       free(t_buf);
       if (!starttime)
              return (-1);
       h=atoi(cgi("hours"));
       m=atoi(cgi("mins"));
       if (h < 0 || m < 0 || h > 999 || m > 59)
              return (-1);

       endtime=starttime + h * 60 * 60 + m * 60;

       argn=0;
       t_buf=strdup(cgi("endtime"));
       if (!t_buf)
              return (-1);
       t_argv=mkargv(t_buf, &argc);
       if (!t_argv)
       {
              free(t_buf);
              return (-1);
       }

       if (argc == 0)       /* Not a weekly event */
       {
              savetime(starttime, endtime, &newdraftfd);
       }
       else
       {
              if (pcp_parse_datetime_until(starttime, endtime, &argn, argc,
                                        t_argv,
                                        atoi(cgi("recurring")),
                                        savetime, &newdraftfd))
              {
                     free(t_argv);
                     free(t_buf);
                     return (-1);
              }
       }
       free(t_argv);
       free(t_buf);
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void attach_delete ( const char *  )

Definition at line 446 of file attachments.c.

{
FILE   *fp;
int    fd2;
struct rfc2045 *rfcp;
char   *draftfilename;
int    isok=1;
struct stat   stat_buf;

       attachment_open(draft, &fp, &fd2, &rfcp);
       if (!rfcp->firstpart)
       {
              rfc2045_free(rfcp);
              fclose(fp);
              return;       /* No attachments to delete */
       }

       if (fstat(fileno(fp), &stat_buf))
       {
              fclose(fp);
              enomem();
       }

       newdraftfd=maildir_recreatemsg(INBOX "." DRAFTS, draft, &draftfilename);
       if (newdraftfd < 0)
       {
              fclose(fp);
              enomem();
       }

       if (deleting_all_attachments(rfcp))
       {
              /* Deleting all attachments */

              if (del_final_attachment(fp, rfcp))       isok=0;
       }
       else
       {
              if (del_some_attachments(fp, rfcp))       isok=0;
       }
       fclose(fp);
       rfc2045_free(rfcp);

       if ( maildir_closemsg(newdraftfd, INBOX "." DRAFTS, draftfilename, isok,
              stat_buf.st_size))
       {
              free(draftfilename);
              enomem();
       }
       free(draftfilename);
       maildir_remcache(INBOX "." DRAFTS);       /* Cache file invalid now */
}

Here is the call graph for this function:

Here is the caller graph for this function:

int attach_upload ( const char *  ,
const char *  ,
const char *   
)

Definition at line 655 of file attachments.c.

{
       char   *attachfilename;
       char   *draftfilename;
       FILE   *draftfp;
       char   *boundary;
       FILE   *tempfp;
       struct rfc2045 *rfcp, *q;
       const char *content_type;
       const char *content_transfer_encoding;
       const char *charset;
       off_t  start_pos, end_pos, start_body;
       int    n;
       char   buf[BUFSIZ];
       int    pipefd[2];
       struct stat   stat_buf, attach_stat_buf;
       off_t  dummy;
       int    fd2;
       char   *filenamemime;
       char *argvec[20];
       char   *filenamebuf;
       pid_t pid1, pid2;
       int waitstat;

       /* Open the file containing the draft message */

       draftfilename=maildir_find(INBOX "." DRAFTS, draft);
       if (!draftfilename)  return (0);

       fd2=maildir_safeopen(draftfilename, O_RDONLY, 0);

       draftfp=0;
       if (fd2 >= 0)
       {
              draftfp=fdopen(fd2, "r");
              if (draftfp == NULL)
                     close(fd2);
       }

       if (draftfp == 0)
              enomem();

       free(draftfilename);
       if (fstat(fileno(draftfp), &stat_buf))
       {
              fclose(draftfp);
              enomem();
       }

       /* Create a temporary file in tmp where we'll temporarily store the
       ** attachment
       */

       attachfd=maildir_createmsg(INBOX "." DRAFTS, "temp", &attachfilename);
       if (attachfd < 0)
       {
              fclose(draftfp);
              enomem();
       }

       if ((
            attpubkey ? getkey(attpubkey, 0):
            attprivkey ? getkey(attprivkey, 1):
            cgi_getfiles( &upload_start, &upload_file, &upload_end, 1, NULL))
              || maildir_writemsg_flush(attachfd))
       {
              maildir_closemsg(attachfd, INBOX "." DRAFTS, attachfilename, 0, 0);
              free(attachfilename);
              fclose(draftfp);
              close(attachfd);
              return (0);
       }

       if (fstat(attachfd, &attach_stat_buf) ||
           attach_stat_buf.st_size + stat_buf.st_size > max_attach())
       {
              maildir_closemsg(attachfd, INBOX "." DRAFTS, attachfilename, 0, 0);
              maildir_deletenewmsg(attachfd, INBOX "." DRAFTS, attachfilename);
              free(attachfilename);
              fclose(draftfp);
              close(attachfd);
              return (-2);
       }
              

       /* Calculate new MIME content boundary */

       boundary=0;
       tempfp=0;

       n=dup(attachfd);

       if (n < 0)
       {
              fclose(draftfp);
              enomem();
       }
       tempfp=fdopen(n, "r");
       if (tempfp == 0)
       {
              fclose(draftfp);
              enomem();
       }

       do
       {
              if (boundary) free(boundary);
              boundary=multipart_boundary_create();
       } while ( multipart_boundary_checkf(boundary, draftfp) ||
                multipart_boundary_checkf(boundary, tempfp));

       if (tempfp)   fclose(tempfp);

       /* Parse existing draft for its MIME structure */

       rfcp=rfc2045_fromfp(draftfp);

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

       /* Create a new version of the draft message */

       newdraftfd=maildir_recreatemsg(INBOX "." DRAFTS, draft, &draftfilename);
       if (newdraftfd < 0)
       {
              maildir_closemsg(attachfd, INBOX "." DRAFTS, attachfilename, 0, 0);
              fclose(draftfp);
              close(attachfd);
              enomem();
       }

       if (fseek(draftfp, 0L, SEEK_SET) < 0)
       {
              maildir_closemsg(newdraftfd, INBOX "." DRAFTS, draftfilename, 0, 0);
              maildir_closemsg(attachfd, INBOX "." DRAFTS, attachfilename, 0, 0);
              fclose(draftfp);
              close(attachfd);
              enomem();
       }

       newmsg_copy_nonmime_headers(draftfp);

       /* Create a multipart message, 1st attachment is the existing
       ** contents.
       */

       newmsg_create_multipart(newdraftfd, charset, boundary);
       maildir_writemsgstr(newdraftfd, "--");
       maildir_writemsgstr(newdraftfd, boundary);
       maildir_writemsgstr(newdraftfd, "\n");

       if (rfcp == NULL || strcmp(content_type, "multipart/mixed"))
       {
              int rc;

              /*
              ** The current draft does not have attachments.  Take its
              ** sole contents, and write it as a text/plain attachment.
              */

              if (fseek(draftfp, 0L, SEEK_SET) < 0)
                     rc = -1;
              else
              {
                     newmsg_copy_content_headers(draftfp);
                     maildir_writemsgstr(newdraftfd, "\n");
                     rfc2045_mimepos(rfcp, &start_pos, &end_pos,
                                   &start_body,
                                   &dummy, &dummy);
                     rc=messagecopy(draftfp, start_body, end_pos);
              }

              if (rc)
              {
                     maildir_closemsg(newdraftfd, INBOX "." DRAFTS, draftfilename,
                            0, 0);
                     maildir_closemsg(attachfd, INBOX "." DRAFTS, attachfilename,
                            0, 0);
                     fclose(draftfp);
                     close(newdraftfd);
                     close(attachfd);
                     enomem();
              }

              maildir_writemsgstr(newdraftfd, "\n--");
              maildir_writemsgstr(newdraftfd, boundary);
              maildir_writemsgstr(newdraftfd, "\n");
       }
       else
       {
              /* If the current draft already has MIME attachments,
              ** just copy them over to the new draft message.
              */

              for (q=rfcp->firstpart; q; q=q->next)
              {
                     if (q->isdummy)      continue;
                     rfc2045_mimepos(q, &start_pos, &end_pos, &start_body,
                                   &dummy, &dummy);
                     if (messagecopy(draftfp, start_pos, end_pos))
                     {
                            maildir_closemsg(newdraftfd, INBOX "." DRAFTS,
                                   draftfilename, 0, 0);
                            maildir_closemsg(attachfd, INBOX "." DRAFTS,
                                   attachfilename, 0, 0);
                            fclose(draftfp);
                            close(newdraftfd);
                            close(attachfd);
                            enomem();
                     }
                     maildir_writemsgstr(newdraftfd, "\n--");
                     maildir_writemsgstr(newdraftfd, boundary);
                     maildir_writemsgstr(newdraftfd, "\n");
              }
       }

       {
              const char *cp=strrchr(cgi_attachfilename, '/');
              int len;
              static const char fnStr[]="filename";

              if (cp)
                     ++cp;
              else
                     cp=cgi_attachfilename;

              len=1;
              rfc2231_attrCreate(fnStr, cp,
                               sqwebmail_content_charset,
                               sqwebmail_content_language,
                               &cnt_filename, &len);

              filenamemime=malloc(len);

              if (filenamemime)
              {
                     *filenamemime=0;
                     rfc2231_attrCreate(fnStr, cp,
                                      sqwebmail_content_charset,
                                      sqwebmail_content_language,
                                      save_filename, filenamemime);
              }
       }

       argvec[0]="makemime";
       argvec[1]="-c";

       if (attpubkey || attprivkey)
       {
              argvec[2]="application/pgp-keys";
              argvec[3]="-N";
              argvec[4]="pgpkeys.txt";
              argvec[5]="-a";
              argvec[6]="Content-Disposition: attachment; filename=\"pgpkeys.txt\"";
              n=7;
              filenamebuf=0;
       }
       else
       {
              const char *pp;

              argvec[2]=(char *)calc_mime_type(cgi_attachfilename);
              argvec[3]="-N";
              argvec[4]=cgi_attachfilename ?
                     (char *)cgi_attachfilename:"filename.dat";
              n=5;

              pp=*cgi("attach_inline") ?
                     "Content-Disposition: inline":
                     "Content-Disposition: attachment";

              filenamebuf=malloc(strlen(pp)+strlen(filenamemime ?
                                               filenamemime:"") + 15);

              if (filenamebuf)
              {
                     strcpy(filenamebuf, pp);
                     strcat(filenamebuf, filenamemime ? filenamemime:"");

                     argvec[n++]="-a";
                     argvec[n++]=filenamebuf;
              }
       }

       argvec[n++]="-C";
       argvec[n++]=(char *)sqwebmail_content_charset;

       signal(SIGCHLD, SIG_DFL);

       argvec[n++]="-";
       argvec[n++]=0;

       if (pipe(pipefd) < 0)
       {
              if (filenamemime)
                     free(filenamemime);
              if (filenamebuf)
                     free(filenamebuf);
              maildir_closemsg(newdraftfd, INBOX "." DRAFTS, draftfilename, 0, 0);
              maildir_closemsg(attachfd, INBOX "." DRAFTS, attachfilename, 0, 0);
              fclose(draftfp);
              close(newdraftfd);
              close(attachfd);
              enomem();
       }

       if (lseek(attachfd, 0L, SEEK_SET) < 0 || (pid1=fork()) < 0)
       {
              close(pipefd[0]);
              close(pipefd[1]);
              if (filenamemime)
                     free(filenamemime);
              if (filenamebuf)
                     free(filenamebuf);
              maildir_closemsg(newdraftfd, INBOX "." DRAFTS, draftfilename, 0, 0);
              maildir_closemsg(attachfd, INBOX "." DRAFTS, attachfilename, 0, 0);
              fclose(draftfp);
              close(newdraftfd);
              close(attachfd);
              enomem();
              return (0);
       }

       if (pid1 == 0)
       {
              dup2(attachfd, 0);
              dup2(pipefd[1], 1);
              close(attachfd);
              close(newdraftfd);
              close(pipefd[0]);
              close(pipefd[1]);
              execv(MAKEMIME, argvec);
              fprintf(stderr,
                     "CRIT: exec %s: %s\n", MAKEMIME, strerror(errno));
              exit(1);
       }

       if (filenamemime)
              free(filenamemime);
       if (filenamebuf)
              free(filenamebuf);

       close (pipefd[1]);


       while ((n=read(pipefd[0], buf, sizeof(buf))) > 0)
       {
              maildir_writemsg(newdraftfd, buf, n);
       }
       close(pipefd[0]);

       for (;;)
       {
              pid2=wait(&waitstat);

              if (pid2 == pid1)
              {
                     waitstat= WIFEXITED(waitstat) ? WEXITSTATUS(waitstat)
                            : 1;
                     break;
              }

              if (pid2 == -1)
              {
                     waitstat=1;
                     break;
              }
       }

       if (waitstat > 0 || n < 0)
       {
              maildir_closemsg(newdraftfd, INBOX "." DRAFTS, draftfilename, 0, 0);
              maildir_closemsg(attachfd, INBOX "." DRAFTS, attachfilename, 0, 0);
              fclose(draftfp);
              close(newdraftfd);
              maildir_deletenewmsg(attachfd, INBOX "." DRAFTS, attachfilename);
              close(attachfd);
              return (-3);
       }

       maildir_writemsgstr(newdraftfd, "\n--");
       maildir_writemsgstr(newdraftfd, boundary);
       maildir_writemsgstr(newdraftfd, "--\n");

       /* Finish new draft message, let it replace the current one */

       if (maildir_closemsg(newdraftfd, INBOX "." DRAFTS, draftfilename, 1,
              stat_buf.st_size))
       {
              maildir_closemsg(attachfd, INBOX "." DRAFTS, attachfilename, 0, 0);
              free(draftfilename);
              maildir_deletenewmsg(attachfd, INBOX "." DRAFTS, attachfilename);
              free(attachfilename);
              rfc2045_free(rfcp);
              fclose(draftfp);
              close(attachfd);
              return (-1);
       }
       free(draftfilename);

       fclose(draftfp);

       /* Remove and delete temp attachment file */

       maildir_deletenewmsg(attachfd, INBOX "." DRAFTS, attachfilename);
       free(attachfilename);
       rfc2045_free(rfcp);
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void attachments_head ( const char *  ,
const char *  ,
const char *   
)

Definition at line 92 of file attachments.c.

{
char *filename;
FILE   *fp;
struct rfc2045 *rfcp;
int    cnt=0;
struct rfc2045 *q;
int    foundtextplain=0;
const char    *noattach_lab=getarg("NOATTACH");
const char    *quotaerr=getarg("QUOTAERR");
const char    *limiterr=getarg("LIMITERR");
off_t  dummy;
int    fd2;

       CHECKFILENAME(draft);
       filename=maildir_find(INBOX "." DRAFTS, draft);
       if (!filename)       return;

       fd2=maildir_safeopen(filename, O_RDONLY, 0);

       fp=0;
       if (fd2 >= 0)
       {
              fp=fdopen(fd2, "r");
              if (fp == NULL)
                     close(fd2);
       }

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

       rfcp=rfc2045_fromfp(fp);
       fclose(fp);
       free(filename);

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

       if (strcmp(cgi("error"), "limits") == 0)
       {
              printf(limiterr, (unsigned long)(max_attach() / (1024 * 1024)));
       }

       if (strcmp(cgi("error"), "makemime") == 0)
       {
              printf(getarg("MAKEMIMEERR"), MAKEMIME);
       }
       newmsg_hiddenheader("pos", pos);
       newmsg_hiddenheader("draft", draft);
       tokennew();
       printf("<table width=\"100%%\" border=\"0\">");

       if (rfcp)
       {
              const char *content_type;
              const char *content_transfer_encoding;
              const char *charset;

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

              if (content_type &&
                  strcmp(content_type, "multipart/alternative") == 0)
                     rfcp=NULL;

              /* No attachments here */
       }

       for (q=rfcp ? rfcp->firstpart:0; q; q=q->next)
       {
       const char *content_type;
       const char *content_transfer_encoding;
       const char *charset;
       const char *name;
       const char *cn;
       char *content_name;

       off_t start_pos, end_pos, start_body;

              if (q->isdummy)      continue;

              rfc2045_mimeinfo(q, &content_type,
                     &content_transfer_encoding, &charset);
              if (!foundtextplain && HASTEXTPLAIN(q))
              {
                     foundtextplain=1;
                     continue;
              }
              rfc2045_mimepos(q, &start_pos, &end_pos, &start_body,
                     &dummy, &dummy);

              ++cnt;
              printf("<tr><td align=\"left\"><input type=\"checkbox\" name=\"del%d\" id=\"del%d\" />&nbsp;",
                     cnt, cnt);

              if (rfc2231_udecodeType(q, "name", sqwebmail_content_charset,
                                   &content_name) < 0 ||
                  rfc2231_udecodeDisposition(q, "filename",
                                          sqwebmail_content_charset,
                                          &content_name) < 0)
                     content_name=NULL;

              if (!content_name &&
                  ((cn=rfc2045_getattr(q->content_type_attr, "name")) ||
                   (cn=rfc2045_getattr(q->content_disposition_attr,
                                    "filename"))))
              {
                     content_name =
                            rfc822_display_hdrvalue_tobuf("subject",
                                                       cn,
                                                       sqwebmail_content_charset,
                                                       NULL,
                                                       NULL);
              }

              if ((!content_name || !*content_name) &&
                  strcmp(content_type, "application/pgp-keys") == 0)
                     name=getarg("KEYDESCR");
              else
              {
                     name=content_name;
              }

              attachment_showname(name);
              if (content_name)
                     free(content_name);
              printf("</td><td align=\"left\">&nbsp;&nbsp;<label for=\"del%d\">", cnt);
              output_attrencoded( content_type );
              printf("</label></td><td align=\"right\">%s<br /></td></tr>",
                     showsize(end_pos - start_body));
       }

       if (cnt == 0)
              printf("<tr><td align=\"center\">%s<br /></td></tr>\n",
                     noattach_lab);
       printf("</table>\n");
}
static void back_to_summary ( ) [static]

Definition at line 3371 of file pcp.c.

{
       const char *p;

       if (*(p=cgi("monthof")) != 0)
       {
              printf("&amp;form=eventmonthly&amp;monthof=%s", p);
       }
       else if (*(p=cgi("weekof")) != 0)
       {
              printf("&amp;form=eventweekly&amp;weekof=%s", p);
       }
       else
       {
              p=cgi("date");
              printf("&amp;form=eventdaily&amp;date=%s", p);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int callback_createcache ( struct PCP_list_all a,
void *  vp 
) [static]

Definition at line 565 of file pcp.c.

{
       struct cacherecord_list **listp=(struct cacherecord_list **)vp, *p;

       if ((p=malloc(sizeof(struct cacherecord_list))) == NULL)
              return (-1);

       p->rec.start=a->event_from;
       p->rec.end=a->event_to;

       if ((p->rec.eventid=strdup(a->event_id)) == NULL)
       {
              free(p);
              return (-1);
       }

       /* Initialize the other fields, so all ptrs are live */

       if ((p->rec.flags=strdup("")) == NULL)
       {
              free(p->rec.eventid);
              free(p);
              return (-1);
       }

       if ((p->rec.subject=strdup("")) == NULL)
       {
              free(p->rec.flags);
              free(p->rec.eventid);
              free(p);
              return (-1);
       }

       p->next= *listp;
       *listp=p;
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int callback_retr_headers ( struct PCP_retr r,
const char *  h,
const char *  v,
void *  vp 
) [static]

Definition at line 667 of file pcp.c.

{
       struct cacherecord *recs=( (struct retr_xinfo *)vp)->recs;
       unsigned n_recs=( (struct retr_xinfo *)vp)->n_recs;
       unsigned i;

       if (strcasecmp(h, "Subject") || !v)
              return (0);

       for (i=0; i<n_recs; i++)
       {
              if (strcmp(recs[i].eventid, r->event_id) == 0)
              {
                     char *s;

                     s=strdup(v);

                     if (!s)
                            return (-1);

                     collapse_subject(s);
                     free(recs[i].subject);
                     recs[i].subject=s;
              }
       }

       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int callback_retr_status ( struct PCP_retr r,
int  s,
void *  vp 
) [static]

Definition at line 603 of file pcp.c.

{
       struct cacherecord *recs=( (struct retr_xinfo *)vp)->recs;
       unsigned n_recs=( (struct retr_xinfo *)vp)->n_recs;
       unsigned i;

       char stat_buf[256];
       char *p;

       stat_buf[0]=0;

       if (s & LIST_CANCELLED)
       {
              strcat(stat_buf, " CANCELLED");
       }

       if (s & LIST_BOOKED)
       {
              strcat(stat_buf, " BOOKED");
       }

       p=stat_buf;
       if (*p)
              ++p;

       for (i=0; i<n_recs; i++)
       {
              if (strcmp(recs[i].eventid, r->event_id) == 0)
              {
                     char *s=strdup(p);

                     if (!s)
                            return (-1);
                     free(recs[i].flags);
                     recs[i].flags=s;
                     break;
              }
       }
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int cmp_reclist ( const void *  a,
const void *  b 
) [static]

Definition at line 416 of file pcp.c.

{
       struct cacherecord_list *aa=*(struct cacherecord_list **)a;
       struct cacherecord_list *bb=*(struct cacherecord_list **)b;

       return ( aa->rec.end < bb->rec.end ? -1:
               aa->rec.end > bb->rec.end ? 1:
               aa->rec.start < bb->rec.start ? -1:
               aa->rec.start > bb->rec.start ? 1:
               strcmp(aa->rec.eventid, bb->rec.eventid));
}

Here is the caller graph for this function:

static void collapse_subject ( char *  s) [static]

Definition at line 646 of file pcp.c.

{
       /* Collapse multiline subjects */

       char *t, *u;

       for (t=u=s; *t; )
       {
              if (*t != '\n')
              {
                     *u++=*t++;
                     continue;
              }

              while (*t && isspace((int)(unsigned char)*t))
                     ++t;
              *u++=' ';
       }
       *u=0;
}

Here is the caller graph for this function:

static int createcache ( struct PCP pcp,
struct cacherecord **  recs,
unsigned *  n_recs,
time_t  start,
time_t  end 
) [static]

Definition at line 440 of file pcp.c.

{
       struct cacherecord_list *list=NULL, *p, **a;
       struct PCP_list_all la;
       struct PCP_retr r;
       struct retr_xinfo xr;

       unsigned i,n;
       const char **event_ids;

       *recs=0;
       *n_recs=0;

       memset(&la, 0, sizeof(la));
       la.list_from=start;
       la.list_to=end;
       la.callback_func=callback_createcache;
       la.callback_arg= &list;

       if (pcp_list_all(pcp, &la))
       {
              while ((p=list) != NULL)
              {
                     list=p->next;
                     destroycache_rec(&p->rec);
                     free(p);
              }
              return (0);
       }

       /* Sort the returned event list, in chronological order. */


       /* First, create an array out of the list */

       for (n=0, p=list; p; p=p->next)
              ++n;

       if (!n)
              return (0);   /* Nothing */

       a=malloc(sizeof(struct cacherecord_list *)*n);
       if (!a)
       {
              fprintf(stderr, "NOTICE: malloc failed\n");

              while ((p=list) != NULL)
              {
                     list=p->next;
                     destroycache_rec(&p->rec);
                     free(p);
              }
              return (-1);
       }
       for (n=0, p=list; p; p=p->next)
              a[n++]=p;

       /* Sort it, copy the sorted array to the return ptr */

       qsort(a, n, sizeof(*a), cmp_reclist);

       if ((*recs=malloc(sizeof(struct cacherecord)*n)) == NULL)
       {
              fprintf(stderr, "NOTICE: malloc failed\n");

              while ((p=list) != NULL)
              {
                     list=p->next;
                     destroycache_rec(&p->rec);
                     free(p);
              }
              free(a);
              return (-1);
       }

       for (i=0; i<n; i++)
              (*recs)[i]= a[i]->rec;
       *n_recs=n;
       free(a);
       while ((p=list) != NULL)
       {
              list=p->next;
              free(p);
       }

       /* Get the subject of all the events */

       event_ids=malloc(sizeof(const char *)*(n+1));

       if (!event_ids)
       {
              fprintf(stderr, "NOTICE: malloc failed\n");

              destroycache(*recs, *n_recs);
              return (-1);
       }

       for (i=0; i< *n_recs; i++)
              event_ids[i]= (*recs)[i].eventid;
       event_ids[i]=NULL;

       memset(&r, 0, sizeof(r));
       r.event_id_list=event_ids;
       r.callback_arg=&xr;
       xr.recs= *recs;
       xr.n_recs= *n_recs;

       r.callback_retr_status=callback_retr_status;
       r.callback_headers_func=callback_retr_headers;

       if (pcp_retr(pcp, &r))
       {
              fprintf(stderr, "NOTICE: pcp_retr: error: %s\n", pcp_errmsg(pcp));
              free(event_ids);
              destroycache(*recs, *n_recs);
              return (-1);
       }
       free(event_ids);
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void deleteattach ( const char *  msg) [static]

Definition at line 2152 of file pcp.c.

{
       attach_delete(msg);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void destroycache ( struct cacherecord c,
unsigned  n 
) [static]

Definition at line 697 of file pcp.c.

{
       unsigned i;

       for (i=0; i<n; i++)
       {
              destroycache_rec(c+i);
       }
       if (c)
              free(c);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void destroycache_rec ( struct cacherecord c) [static]

Definition at line 709 of file pcp.c.

{
       free(c->eventid);
       free(c->flags);
       free(c->subject);
}

Here is the caller graph for this function:

static void do_daily_view ( struct cacherecord recs,
unsigned  n_recs,
int  viewtype,
time_t *  start_ptr,
time_t *  end_ptr 
) [static]

Definition at line 2972 of file pcp.c.

{
       unsigned i;
       int printed=0;

       printf("<table width=\"100%%\">");

       for (i=0; i<n_recs; i++)
       {
              char date1[256];
              char date2[256];

              char time1[128];
              char time2[128];

              time_t start=recs[i].start;
              time_t end=recs[i].end;

              if (start_ptr && *start_ptr >= end)
                     continue;

              if (end_ptr && *end_ptr <= start)
                     continue;

              if ( start_ptr && *start_ptr > start)
                     start= *start_ptr;

              if ( end_ptr && *end_ptr < end)
                     end= *end_ptr;

              if (pcp_fmttime(date1, sizeof(date1),
                            start, FMTTIME_DATE))
                     continue;
              if (pcp_fmttime(date2, sizeof(date2),
                            end, FMTTIME_DATE))
                            continue;

              printed=1;

              if (strcmp(date1, date2) && viewtype == VIEW_DAILY)
              {
                     char timerange[512];

                     if (pcp_fmttimerange(timerange, sizeof(timerange),
                                        start, end))
                            continue;

                     printf("<tr><td align=\"left\">");
                     print_event_link(recs[i].eventid, "", "class=\"dailyeventtimes\"");
                     print_safe(timerange);
              }
              else
              {
                     if (pcp_fmttime(time1, sizeof(time1),
                                   start,
                                   FMTTIME_TIME))
                            continue;

                     if (pcp_fmttime(time2,
                                   sizeof(time2),
                                   end,
                                   FMTTIME_TIME))
                            continue;

                     printf("<tr><td align=\"left\">");
                     print_event_link(recs[i].eventid, "", "class=\"dailyeventtimes\"");
                     print_safe(time1);
                     printf("&nbsp;-&nbsp;");
                     print_safe(time2);
              }
              printf("</a>");

              if (viewtype == VIEW_DAILY)
              {
                     printf("</td><td width=\"100%%\">");
              }
              else
                     printf("<br />");

              printf("&nbsp;&nbsp;");
              print_event_link(recs[i].eventid, "", "class=\"dailyeventsubject\"");
              print_event_subject(recs[i].flags, recs[i].subject,
                                viewtype == VIEW_DAILY ? 80:15);
              printf("</a>");
              if (viewtype != VIEW_DAILY)
                     printf("<br />&nbsp;");

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

       if (!printed)
       {
              printf("<tr><td align=\"center\">%s</td></tr>",
                     getarg("NOEVENTS"));
       }

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

Here is the call graph for this function:

Here is the caller graph for this function:

static void do_pcplogin ( const char *  userid,
const char *  password,
int  showerr 
) [static]

Definition at line 154 of file pcp.c.

{
       struct PCP *pcp;

       unlink(TOKEN);
       unlink(CACHE);       /* Rebuild it later*/

       if (!sqpcp_mode())
              return;

       mkdir("calendar", 0700);

       if (sqpcp_has_groupware())  /* Groupware mode, login to server */
       {
              char *errflag=0;

              pcp=pcp_open_server(userid, password, &errflag);

              if (!pcp && errflag && showerr)
              {
                     printf("%s<div class=\"indent\"><pre class=\"small-error\">",
                            getarg("CALENDARLOGINERR"));
                     output_attrencoded_oknl_fp(errflag, stdout);
                     printf("</pre></div>\n");
              }
              if (errflag)
                     free(errflag);
       }
       else
       {
              pcp=sqpcp_calendar();
       }

       if (pcp)
       {
              const char *p=pcp_authtoken(pcp);

              if (p)
              {
                     FILE *f;
                     int u=umask(077);

                     f=fopen(TOKEN, "w");
                     umask(u);
                     if (f)
                     {
                            fprintf(f, "%s\n", p);
                            fclose(f);
                     }
              }
              pcp_cleanup(pcp);
              refreshcache(pcp);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int doeventedit ( struct PCP pcp,
int  fd 
) [static]

Definition at line 3653 of file pcp.c.

{
       const char *p=cgi("eventid");
       struct PCP_retr r;
       struct getedit_info ge;

       const char *eventid[2];

       if (!p || !*p)
              return (-1);

       maildir_writemsgstr(fd, "X-Event: 1\nX-Old-EventId: ");
       maildir_writemsgstr(fd, p);
       maildir_writemsgstr(fd, "\n");

       memset(&r, 0, sizeof(r));
       eventid[0]=p;
       eventid[1]=NULL;

       r.event_id_list=eventid;

       ge.fd=fd;
       ge.flag=0;
       r.callback_arg=&ge;

       r.callback_retr_date=get_date;
       r.callback_retr_participants=get_participants;

       if (pcp_retr(pcp, &r))
       {
              saveerror(pcp, &r.errcode);
              return (-1);
       }

       memset(&r, 0, sizeof(r));
       eventid[0]=p;
       eventid[1]=NULL;

       r.event_id_list=eventid;

       ge.fd=fd;
       ge.flag=0;
       r.callback_arg=&ge;

       ge.in_headers=1;
       ge.sol=1;
       ge.skiph=0;

       r.callback_rfc822_func=get_msgtext;
       if (pcp_retr(pcp, &r))
       {
              saveerror(pcp, &r.errcode);
              return (-1);
       }

       if (!ge.flag)
       {
              cgi_put("error", "notfound");
              return (-1);
       }

       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int dosave ( FILE *  fp,
struct saveinfo si 
) [static]

Definition at line 2793 of file pcp.c.

{
       struct PCP *pcp=sqpcp_calendar();
       struct PCP_save_event se;
       struct PCP_new_eventid *nei;
       struct PCP_commit c;

       struct proxy_update_list pul;

       if (!pcp)
       {
              cgi_put("error", "calendar");      /* TODO: actual error */
              cgi_put("pcperror", "");
              return (-1);
       }

       memset(&se, 0, sizeof(se));
       se.write_event_fd=fileno(fp);
       se.event_participants=si->participants;
       se.n_event_participants=si->n_participants;

       if (*cgi("okconflict"))
              se.flags |= PCP_OK_CONFLICT;
       if (*cgi("okerrors"))
              se.flags |= PCP_OK_PROXY_ERRORS;

       nei=pcp_new_eventid(pcp, si->old_eventid, &se);
       if (!nei)
       {
              saveerror(pcp, NULL);
              return (-1);
       }

       memset(&c, 0, sizeof(c));
       c.event_times=si->times;
       c.n_event_times=si->n_times;
       c.flags=se.flags;

       init_save_conflict();
       c.add_conflict_callback=save_conflict;

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

       c.proxy_callback= &proxy_update_list_save;
       c.proxy_callback_ptr= &pul;

       if (pcp_commit(pcp, nei, &c))
       {
              proxy_update_list_free(&pul);
              saveerror(pcp, &c.errcode);
              pcp_destroy_eventid(pcp, nei);
              return (-1);
       }
       pcp_destroy_eventid(pcp, nei);
       unlink(CACHE);       /* Have it rebuilt */
       proxy_notify_email(fp, &pul, c.event_times, c.n_event_times);
       proxy_update_list_free(&pul);
       refreshcache(pcp);
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void dosendnotice ( FILE *  tofp,
FILE *  tmpfp,
FILE *  eventfp,
struct proxy_list_entry idlist,
const char *  subjectlabel,
const struct PCP_event_time time_list,
unsigned  n_time_list 
) [static]

Definition at line 2732 of file pcp.c.

{
       struct rfc822hdr h;
       const char *p;
       int c;
       unsigned u;

       rfc822hdr_init(&h, 8192);

       while (rfc822hdr_read(&h, eventfp, NULL, 0) == 0)
       {
              if (strcasecmp(h.header, "From") == 0 ||
                  strcasecmp(h.header, "Date") == 0)
              {
                     fprintf(tofp, "%s: %s\n", h.header,
                            h.value ? h.value:"");
              }
              else if (strcasecmp(h.header, "Subject") == 0)
              {
                     fprintf(tofp, "%s: %s %s\n", h.header,
                            subjectlabel,
                            h.value ? h.value:"");
              }
       }
       rfc822hdr_free(&h);

       p="To: ";

       while (idlist)
       {
              fprintf(tofp, "%s%s", p, idlist->userid);
              p=",\n  ";
              idlist=idlist->next;
       }
       fprintf(tofp, "\n");

       while ((c=getc(tmpfp)) != EOF)
              putc(c, tofp);

       for (u=0; u<n_time_list; u++)
       {
              char buffer[200];

              if (pcp_fmttimerange(buffer, sizeof(buffer),
                                 time_list[u].start,
                                 time_list[u].end) == 0)
              {
                     fprintf(tofp, "     %s\n", buffer);
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void doupload ( const char *  msg) [static]

Definition at line 2167 of file pcp.c.

{
       int flag;

       flag=attach_upload(msg, NULL, NULL);

       if (flag)
              cgi_put("error", "quota");
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void dropquota ( const char *  filename,
int  fd 
) [static]

Definition at line 2388 of file pcp.c.

{
       unsigned long filesize=0;

       if (maildir_parsequota(filename, &filesize))
       {
              struct stat stat_buf;

              if (fstat(fd, &stat_buf))
                     stat_buf.st_size=0;
              filesize=stat_buf.st_size;
       }

       maildir_quota_deleted(".", (int64_t)-filesize, -1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void free_display_retr ( struct display_retr r) [static]

Definition at line 3155 of file pcp.c.

{
}

Here is the caller graph for this function:

static void free_saveinfo ( struct saveinfo si) [static]

Definition at line 2368 of file pcp.c.

{
       struct participant_list *l;

       if (si->participants)
              free(si->participants);

       while ((l=si->participant_list) != NULL)
       {
              si->participant_list=l->next;
              free(l->address);
              free(l);
       }

       if (si->times)
              free(si->times);
       if (si->old_eventid)
              free(si->old_eventid);
}

Here is the caller graph for this function:

static int get_date ( struct PCP_retr r,
time_t  start,
time_t  end,
void *  vp 
) [static]

Definition at line 3556 of file pcp.c.

{
       char buf[NUMBUFSIZE];
       struct getedit_info *ge=(struct getedit_info *)vp;

       maildir_writemsgstr(ge->fd, "X-Event-Time: ");
       maildir_writemsgstr(ge->fd, libmail_str_time_t(start, buf));
       maildir_writemsgstr(ge->fd, " ");
       maildir_writemsgstr(ge->fd, libmail_str_time_t(end, buf));
       maildir_writemsgstr(ge->fd, "\n");

       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int get_msgtext ( struct PCP_retr r,
const char *  ptr,
int  n,
void *  vp 
) [static]

Definition at line 3582 of file pcp.c.

{
       struct getedit_info *ge=(struct getedit_info *)vp;

       /* We want to drop all X headers when we read in this event */
       /* Also, drop CRs */

       ge->flag=1;

       while (n)
       {
              int i;

              if (!ge->in_headers) /* Write out msg body */
              {
                     while (n)
                     {
                            if (*ptr == '\r')
                            {
                                   ++ptr;
                                   --n;
                                   continue;
                            }

                            for (i=0; i<n; i++)
                                   if (ptr[i] == '\r')
                                          break;

                            maildir_writemsg(ge->fd, ptr, i);
                            ptr += i;
                            n -= i;
                     }
                     break;
              }

              if (*ptr == '\r')
              {
                     ++ptr;
                     --n;
                     continue;
              }

              if (*ptr == '\n')
              {
                     if (!ge->skiph)
                            maildir_writemsgstr(ge->fd, "\n");

                     ge->skiph=0;
                     if (ge->sol)
                            ge->in_headers=0;    /* End of headers */
                     ge->sol=1;
                     ++ptr;
                     --n;
                     continue;
              }

              if (ge->sol && (*ptr == 'x' || *ptr == 'X'))
                     ge->skiph=1;

              for (i=0; i<n; i++)
                     if (ptr[i] == '\r' || ptr[i] == '\n')
                            break;

              if (!ge->skiph)      /* Skip X- header */
                     maildir_writemsg(ge->fd, ptr, i);
              ptr += i;
              n -= i;
       }
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int get_participants ( struct PCP_retr r,
const char *  address,
const char *  dummy,
void *  vp 
) [static]

Definition at line 3570 of file pcp.c.

{
       struct getedit_info *ge=(struct getedit_info *)vp;

       maildir_writemsgstr(ge->fd, "X-Event-Participant: ");
       maildir_writemsgstr(ge->fd, address);
       maildir_writemsgstr(ge->fd, "\n");

       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static time_t get_start_of_month ( ) [static]

Definition at line 3922 of file pcp.c.

{
       unsigned y, m;
       time_t start;
       time_t end;
       struct tm *tmptr;

       if (sscanf(cgi("monthof"), "%4u%2u", &y, &m) != 2
           || pcp_parse_ymd(y, m, 1, &start, &end))
       {
              time(&start);
              if ((tmptr=localtime(&start)) == NULL)
              {
                     enomem();
                     return (0);
              }
              y=tmptr->tm_year + 1900;
              m=tmptr->tm_mon + 1;

              if (pcp_parse_ymd(y, m, 1, &start, &end))
              {
                     enomem();
                     return (0);
              }
       }

       return (start);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static time_t get_start_of_week ( ) [static]

Definition at line 3755 of file pcp.c.

{
       unsigned y, m, d;
       time_t start;
       time_t end;
       struct tm *tmptr;
       int i;

       if (sscanf(cgi("weekof"), "%4u%2u%2u", &y, &m, &d) != 3
           || pcp_parse_ymd(y, m, d, &start, &end))
       {
              time(&start);
              if ((tmptr=localtime(&start)) == NULL)
              {
                     enomem();
                     return (0);
              }
              y=tmptr->tm_year + 1900;
              m=tmptr->tm_mon + 1;
              d=tmptr->tm_mday;

              if (pcp_parse_ymd(y, m, d, &start, &end))
              {
                     enomem();
                     return (0);
              }
       }

       for (i=0; i<7; i++)
       {
              tmptr=localtime(&start);
              if (!tmptr)
                     enomem();

              if (tmptr->tm_wday == pref_startofweek)
                     break;

              prevday(&start);
       }

       return (start);
}

Here is the call graph for this function:

Here is the caller graph for this function:

size_t get_timeoutsoft ( )

Definition at line 166 of file sqwebmail.c.

{
       time_t n=TIMEOUTSOFT;
       const char *p;

       p=getenv("SQWEBMAIL_TIMEOUTSOFT");

       if (p && *p)
              n=atoi(p);

       return n;
}

Here is the caller graph for this function:

static void init_save_conflict ( ) [static]

Definition at line 1429 of file pcp.c.

{
       while (conflict_list)
       {
              struct conflict_list *p=conflict_list;

              conflict_list=p->next;
              if (p->event_id)
                     free(p->event_id);
              if (p->address)
                     free(p->address);
              if (p->subject)
                     free(p->subject);
              free(p);
       }
}

Here is the caller graph for this function:

static int init_saveinfo ( struct saveinfo si,
FILE *  fp 
) [static]

Definition at line 2211 of file pcp.c.

{
       struct rfc822hdr h;

       struct savetimelist {
              struct savetimelist *next;
              struct PCP_event_time event_time;
       } *tlist=NULL, *p;
       unsigned tcnt=0;
       struct participant_list *l;


       si->times=NULL;
       si->n_times=0;
       si->old_eventid=0;
       si->participants=NULL;
       si->n_participants=0;
       si->participant_list=NULL;

       rfc822hdr_init(&h, BUFSIZ);
       while (rfc822hdr_read(&h, fp, NULL, 0) == 0)
       {
              unsigned long a, b;

              if (strcasecmp(h.header, "X-Event-Participant") == 0 && h.value)
              {
                     l=malloc(sizeof(struct participant_list));
                     if (!l || (l->address=strdup(h.value)) == NULL)
                     {
                            if (l)
                                   free(l);

                            while ((l=si->participant_list) != NULL)
                            {
                                   si->participant_list=l->next;
                                   free(l->address);
                                   free(l);
                            }
                            while (tlist)
                            {
                                   p=tlist;
                                   tlist=p->next;
                                   free(p);
                            }
                            rfc822hdr_free(&h);
                            return (-1);
                     }
                     l->next=si->participant_list;
                     si->participant_list=l;
                     ++si->n_participants;
              }
              else if (strcasecmp(h.header, "X-Event-Time") == 0 &&
                      h.value && sscanf(h.value, "%lu %lu", &a, &b) == 2)
              {
                     if ((p=malloc(sizeof(struct savetimelist))) == NULL)
                     {
                            while ((l=si->participant_list) != NULL)
                            {
                                   si->participant_list=l->next;
                                   free(l->address);
                                   free(l);
                            }
                            while (tlist)
                            {
                                   p=tlist;
                                   tlist=p->next;
                                   free(p);
                            }
                            rfc822hdr_free(&h);
                            return (-1);
                     }
                     p->next=tlist;
                     tlist=p;
                     p->event_time.start=a;
                     p->event_time.end=b;
                     ++tcnt;
              }

              if (strcasecmp(h.header, "X-Old-EventId") == 0 && h.value)
              {
                     if (si->old_eventid)
                            free(si->old_eventid);
                     si->old_eventid=strdup(h.value);
                     if (!si->old_eventid)
                     {
                            rfc822hdr_free(&h);
                            return (-1);
                     }
              }
       }
       rfc822hdr_free(&h);

       if (si->n_participants)
       {
              unsigned n=0;

              if ((si->participants
                   =calloc(sizeof(struct PCP_event_participant),
                          si->n_participants)) == NULL)
              {
                     while ((l=si->participant_list) != NULL)
                     {
                            si->participant_list=l->next;
                            free(l->address);
                            free(l);
                     }
                     while (tlist)
                     {
                            p=tlist;
                            tlist=p->next;
                            free(p);
                     }
                     return (-1);
              }

              for (l=si->participant_list; l; l=l->next)
              {
                     si->participants[n].address=l->address;
                     ++n;
              }
       }

       if (tcnt)
       {
              si->n_times=tcnt;
              if ((si->times=malloc(sizeof(struct PCP_event_time)
                                  *tcnt)) == NULL)
              {
                     while ((l=si->participant_list) != NULL)
                     {
                            si->participant_list=l->next;
                            free(l->address);
                            free(l);
                     }
                     while (tlist)
                     {
                            p=tlist;
                            tlist=p->next;
                            free(p);
                     }
                     if (si->old_eventid)
                            free(si->old_eventid);
                     return (-1);
              }
              tcnt=0;
              while (tlist)
              {
                     p=tlist;
                     tlist=p->next;
                     si->times[tcnt]=p->event_time;
                     free(p);
                     ++tcnt;
              }
       }
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int listacl ( const char *  a,
int  f,
void *  vp 
) [static]

Definition at line 4125 of file pcp.c.

{
       struct acl_list **p=(struct acl_list **)vp, *q;

       if ((q=malloc(sizeof(struct acl_list))) == NULL)
              return (-1);
       memset(q, 0, sizeof(*q));
       if ((q->addr=strdup(a)) == NULL)
       {
              free(q);
              return (-1);
       }

       q->flags=f;

       while (*p)
       {
              if (strcasecmp( (*p)->addr, a) > 0)
                     break;
              p= &(*p)->next;
       }

       q->next= *p;
       *p=q;
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static char** mkargv ( char *  p,
int *  argc 
) [static]

Definition at line 1908 of file pcp.c.

{
       int pass;
       char **argv=0;
       char *q;

       /* Two passes - count words, then make them */

       for (pass=0; pass<2; pass++)
       {
              if (pass)
              {
                     if ((argv=malloc(sizeof(char *)* (*argc+1))) == NULL)
                            return (NULL);
              }
              *argc=0;

              for (q=p; *q; )
              {
                     if (isspace((int)(unsigned char)*q))
                     {
                            ++q;
                            continue;     /* Skip leading space */
                     }

                     if (pass)
                            argv[ *argc ] = q;
                     ++*argc;

                     while (*q)    /* Look for next space */
                     {
                            if (isspace((int)(unsigned char)*q))
                            {
                                   if (pass)
                                          *q=0;
                                   ++q;
                                   break;
                            }
                            ++q;
                     }
              }
       }
       argv[ *argc ] = 0;
       return (argv);
}

Here is the caller graph for this function:

const char* myhostname ( )

Definition at line 44 of file auth.c.

{
char    buf[512];
static char *my_hostname=0;
FILE   *f;

       if (my_hostname == 0)
       {
              buf[0]=0;
              if ((f=fopen(HOSTNAMEFILE, "r")) != 0)
              {
              char *p;

                     if (fgets(buf, sizeof(buf), f) == NULL)
                            buf[0]=0;

                     fclose(f);

                     if ((p=strchr(buf, '\n')) != 0)
                            *p=0;
              }

              if (buf[0] == 0 && gethostname(buf, sizeof(buf)-1))
                     strcpy(buf, "localhost");

              if ((my_hostname=malloc(strlen(buf)+1)) == 0)
                     enomem();
              strcpy(my_hostname, buf);
       }
       return (my_hostname);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int need_refresh ( ) [static]

Definition at line 279 of file pcp.c.

{
       FILE *fp;
       struct stat stat_buf;

       /* Check whether it's time to rebuild the cache */

       fp=fopen(CACHE, "r");

       if (stat(CHANGEDFILE, &stat_buf) == 0)
       {
              if (fp)
                     fclose(fp);
              return (1);
       }

       if (fp)
       {
              struct stat stat_buf;

              char buffer[BUFSIZ];
              const char *p;

              time_t a, b;

              int ch=getc(fp);

              if (ch == EOF)
              {
                     fclose(fp);
                     return (0); /* No events scheduled */
              }

              ungetc(ch, fp);
              if (fgets(buffer, sizeof(buffer), fp) &&
                  (p=parsetimet(buffer, &a)) &&
                  parsetimet(p, &b))
              {
                     time_t now;

                     time(&now);

                     if (now < b)  /* Event expired */
                     {
                            if (fstat(fileno(fp), &stat_buf) == 0)
                            {
                                   /*
                                   ** Check in every TIMEOUTSOFT/2 in
                                   ** any case.
                                   */

                                   if (stat_buf.st_mtime >
                                       now - get_timeoutsoft()/2)
                                   {
                                          fclose(fp);   /* Not yet */
                                          return (0);
                                   }
                            }
                     }
              }
              fclose(fp);
              unlink(CACHE);
              return (1);
       }
       return (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 call graph for this function:

void newmsg_preview ( const char *  )

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 *  ,
int *   
)

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:

static void nextday ( time_t *  tm) [static]

Definition at line 3737 of file pcp.c.

{
       struct tm *tmptr;
       time_t t= *tm + 36 * 60 * 60;

       if ((tmptr=localtime(&t)) == NULL)
       {
              enomem();
              return;
       }

       if (pcp_parse_ymd(tmptr->tm_year + 1900, tmptr->tm_mon + 1,
                       tmptr->tm_mday, tm, &t))
       {
              enomem();
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

FILE* open_langform ( const char *  lang,
const char *  formname,
int  print_header 
)

Definition at line 467 of file sqwebmail.c.

{
char   *formpath;
FILE   *f;
char   *templatedir=get_templatedir();
       
       /* templatedir/lang/formname */

       if (!(formpath=malloc(strlen(templatedir)+3+
              strlen(lang)+strlen(formname))))
              error("Out of memory.");

       strcat(strcat(strcat(strcat(strcpy(formpath, templatedir), "/"),
              lang), "/"), formname);

       f=fopen(formpath, "r");

       free(formpath);
       
       if (f && print_header)
              printf("Content-Language: %s\n", lang);
       if (f)
              fcntl(fileno(f), F_SETFD, FD_CLOEXEC);
       return (f);
}

Here is the call graph for this function:

static FILE * openoldfp ( const char *  p,
unsigned long *  prev_size 
) [static]

Definition at line 1386 of file pcp.c.

{
       struct stat stat_buf;
       char *filename;
       int x;
       FILE *oldfp;

       CHECKFILENAME(p);

       filename=maildir_find(INBOX "." DRAFTS, p);
       if (!filename)
              return (NULL);

       x=maildir_safeopen(filename, O_RDONLY, 0);
       free(filename);
       if (x < 0)
              return (NULL);


       if (fstat(x, &stat_buf) < 0 || (oldfp=fdopen(x, "r")) == NULL)
       {
              close(x);
              return (NULL);
       }

       if (prev_size)
              *prev_size=stat_buf.st_size;
       return (oldfp);
}

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_oknl_fp ( const char *  ,
FILE *   
)

Definition at line 264 of file sqwebmail.c.

{
       print_attrencodedlen(p, strlen(p), 1, fp);
}

Here is the call graph for this function:

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
}

Definition at line 384 of file sqwebmail.c.

{
char   *p=scriptptrget();

       printf("%s", p);
       free(p);
       return;
}

Here is the call graph for this function:

void output_urlencoded ( const char *  )

Definition at line 279 of file sqwebmail.c.

{
char   *q=cgiurlencode(p);

       printf("%s", q);
       free(q);
}

Here is the call graph for this function:

static void parsecache_rec ( char *  p,
struct cacherecord cr 
) [static]

Definition at line 716 of file pcp.c.

{
       unsigned long a;

       memset(cr, 0, sizeof(*cr));
       cr->eventid="";
       cr->flags="";
       cr->subject="";

       if (!p || sscanf(p, "%lu", &a) <= 0)
              return;
       p=strchr(p, '\t');
       cr->start= (time_t)a;
       if (!p || sscanf(p, "%lu", &a) <= 0)
              return;
       cr->end= (time_t)a;
       p=strchr(p+1, '\t');
       if (!p) return;
       ++p;

       cr->eventid=p;
       p=strchr(p, '\t');
       if (!p) return;
       *p++=0;

       cr->flags=p;
       p=strchr(p, '\t');
       if (!p) return;
       *p++=0;

       cr->subject=p;
}

Here is the caller graph for this function:

static const char* parsetimet ( const char *  buf,
time_t *  tp 
) [static]

Definition at line 270 of file pcp.c.

{
       *tp=libmail_strtotime_t(&buf);

       if (*buf == '\t')
              ++buf;
       return buf;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void prevday ( time_t *  tm) [static]

Definition at line 3719 of file pcp.c.

{
       struct tm *tmptr;
       time_t t= *tm - 12 * 60 * 60;

       if ((tmptr=localtime(&t)) == NULL)
       {
              enomem();
              return;
       }

       if (pcp_parse_ymd(tmptr->tm_year + 1900, tmptr->tm_mon + 1,
                       tmptr->tm_mday, tm, &t))
       {
              enomem();
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void previewdraft ( char *  msg,
void(*)(const char *)  func 
) [static]

Definition at line 2105 of file pcp.c.

{
       char *msg2, *msg2p;

       msg2=maildir_find(INBOX "." DRAFTS, msg);
       free(msg);
       if (!msg2)
              enomem();
       if ((msg2p=strrchr(msg2, '/')) != 0)
              ++msg2p;
       else
              msg2p=msg2;

       cgi_put("draftmessage", msg2p);
       if (func)
              (*func)(msg2p);
       output_form("newevent.html");
       free(msg2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void print_event_link ( const char *  id,
const char *  extra,
const char *  extra2 
) [static]

Definition at line 2964 of file pcp.c.

{
       printf("<a href=\"");
       print_event_link_url(id, extra);
       printf("\" %s >", extra2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void print_event_link_url ( const char *  id,
const char *  extra 
) [static]

Definition at line 2951 of file pcp.c.

{
       output_scriptptrget();
       printf("%s&amp;form=eventshow&amp;eventid=", extra);
       output_urlencoded(id);
       if (*cgi("date"))
              printf("&amp;date=%s", cgi("date"));
       if (*cgi("weekof"))
              printf("&amp;weekof=%s", cgi("weekof"));
       if (*cgi("monthof"))
              printf("&amp;monthof=%s", cgi("monthof"));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void print_event_subject ( char *  flags,
const char *  subject,
unsigned  w 
) [static]

Definition at line 1339 of file pcp.c.

{
       unsigned i;
       char *p;

       /* Print event flags first: CANCELLED... */

       for (p=flags; p && (p=strtok(p, " \t\r")) != 0; p=0)
       {
              printf("%s", getarg(p));
       }

       p=rfc822_display_hdrvalue_tobuf("subject",
                                   subject ? subject:"",
                                   sqwebmail_content_charset,
                                   NULL,
                                   NULL);

       if (!p)
              p=strdup(subject ? subject:"");

       if (!p)
              return;

       if (strlen(p) > w)
       {
              /* Truncate long subject lines */
              i=w-5;
              while (i)
              {
                     if (isspace((int)(unsigned char) p[i]))
                     {
                            strcpy(p+i, "...");
                            break;
                     }
                     --i;
              }
       }
       print_safe(p);
       free(p);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void print_safe ( const char *  )

Definition at line 150 of file folder.c.

static void proxy_notify_email ( FILE *  f,
struct proxy_update_list pul,
const struct PCP_event_time t,
unsigned  tn 
) [static]

Definition at line 2615 of file pcp.c.

{
       proxy_notify_email_msg(f, pul->new_list, "eventnotifynew.txt",
                            t, tn);
       proxy_notify_email_msg(f, pul->delete_list, "eventnotifydelete.txt",
                            NULL, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void proxy_notify_email_msg ( FILE *  f,
struct proxy_list_entry l,
const char *  template,
const struct PCP_event_time t,
unsigned  tn 
) [static]

Definition at line 2629 of file pcp.c.

{
       FILE *tmpfp;
       pid_t p, p2;
       int waitstat;
       int pipefd[2];
       FILE *tofp;
       const char *returnaddr=login_returnaddr();
       char subjectlabel[100];

       if (!l)
              return;

       if (fseek(f, 0L, SEEK_SET) < 0
           || lseek(fileno(f), 0L, SEEK_SET) < 0)
       {
              fprintf(stderr, "CRIT: seek failed: %s\n", strerror(errno));
              return;
       }

       subjectlabel[0]=0;

       if ((tmpfp=open_langform(sqwebmail_content_language,
                             "eventnotifysubject.txt", 0)) != NULL)
       {
              if (fgets(subjectlabel, sizeof(subjectlabel), tmpfp) == NULL)
                     subjectlabel[0]=0;
              else
              {
                     char *p=strchr(subjectlabel, '\n');

                     if (p) *p=0;
              }
              fclose(tmpfp);
       }
       if (subjectlabel[0] == 0)
              strcpy(subjectlabel, "[calendar]");

       if ((tmpfp=open_langform(sqwebmail_content_language, template, 0))
           == NULL)
       {
              fprintf(stderr, "CRIT: %s: %s\n", template, strerror(errno));
              return;
       }

       signal(SIGPIPE, SIG_IGN);

       if (pipe(pipefd) < 0)
       {
              fclose(tmpfp);
              fprintf(stderr, "CRIT: pipe: %s\n", strerror(errno));
              return;
       }

       p=fork();

       if (p < 0)
       {
              close(pipefd[0]);
              close(pipefd[1]);
              fclose(tmpfp);
              fprintf(stderr, "CRIT: fork: %s\n", strerror(errno));
              return;
       }

       if (p == 0)
       {
              dup2(pipefd[0], 0);
              close(pipefd[0]);
              close(pipefd[1]);
              execl(SENDITSH, "sendit.sh", returnaddr,
                                sqwebmail_mailboxid, NULL);
              fprintf(stderr, "CRIT: exec " SENDITSH ": %s\n", strerror(errno));
              exit(1);
       }
       close(pipefd[0]);
       if ((tofp=fdopen(pipefd[1], "w")) == NULL)
       {
              fprintf(stderr, "CRIT: exec " SENDITSH ": %s\n", strerror(errno));
       }
       else
       {
              dosendnotice(tofp, tmpfp, f, l, subjectlabel, t, tn);
       }
       fclose(tofp);
       close(pipefd[1]);
       fclose(tmpfp);

       waitstat=256;
       while ((p2=wait(&waitstat)) != p && p2 >= 0)
              ;

       if (!WIFEXITED(waitstat) || WEXITSTATUS(waitstat))
              fprintf(stderr, "CRIT: event notify mail failed\n");
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void proxy_update_list_free ( struct proxy_update_list p) [static]

Definition at line 2591 of file pcp.c.

{
       struct proxy_list_entry *e;

       while ((e=p->new_list) != NULL)
       {
              p->new_list=e->next;
              free(e->userid);
              free(e);
       }

       while ((e=p->delete_list) != NULL)
       {
              p->delete_list=e->next;
              free(e->userid);
              free(e);
       }
}

Here is the caller graph for this function:

static void proxy_update_list_save ( const char *  action,
const char *  userid,
void *  voidarg 
) [static]

Definition at line 2560 of file pcp.c.

{
       struct proxy_update_list *pul=(struct proxy_update_list *)voidarg;

       struct proxy_list_entry **eptr, *e;

       if (strcmp(action, "NEW") == 0)
              eptr= &pul->new_list;
       else if (strcmp(action, "DELETE") == 0)
              eptr= &pul->delete_list;
       else
              return;

       while (*eptr && strcmp( (*eptr)->userid, userid) == 0)
              eptr= &(*eptr)->next;

       if ((e=malloc(sizeof(struct proxy_list_entry))) == NULL ||
           (e->userid=strdup(userid)) == NULL)
       {
              if (e)
                     free(e);
              fprintf(stderr, "CRIT: out of memory.\n");
              return;
       }

       e->next= *eptr;
       *eptr=e;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void refreshcache ( struct PCP pcp) [static]

Definition at line 346 of file pcp.c.

{
       struct cacherecord *recs;
       unsigned n_recs;
       unsigned i;
       char *new_name;
       int new_fd;
       char *p;
       time_t now;
       FILE *new_fp;

       unlink(CHANGEDFILE);
       time(&now);
       if (createcache(pcp, &recs, &n_recs, now, now + 5 * 24 * 60 * 60))
              return;

       new_fd=maildir_createmsg(INBOX, "cache", &new_name);
       if (new_fd < 0 || (new_fp=fdopen(new_fd, "w")) == 0)
       {
              if (new_fd >= 0)        close(new_fd);
              destroycache(recs, n_recs);
              return;
       }

        p=malloc(sizeof("tmp/")+strlen(new_name));
        if (!p)
        {
              fclose(new_fp);
                free(new_name);
              destroycache(recs, n_recs);
                return;
        }
        strcat(strcpy(p, "tmp/"), new_name);
        free(new_name);
        new_name=p;

       /* Save a max of 5 events, for the main page listing */

       for (i=0; i<n_recs && i < 5; i++)
       {
              char buf1[NUMBUFSIZE], buf2[NUMBUFSIZE];

              fprintf(new_fp, "%s\t%s\t%s\t%s\t%s\n",
                     libmail_str_time_t(recs[i].start, buf1),
                     libmail_str_time_t(recs[i].end, buf2),
                     recs[i].eventid,
                     recs[i].flags,
                     recs[i].subject);
       }

       if (fflush(new_fp) || ferror(new_fp))
       {
              fclose(new_fp);
              unlink(new_name);
                free(new_name);
              destroycache(recs, n_recs);
                return;
        }
       fclose(new_fp);
       rename(new_name, CACHE);
       free(new_name);
       destroycache(recs, n_recs);
       return;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int save_conflict ( const char *  event_id,
time_t  start,
time_t  end,
const char *  address,
void *  dummy 
) [static]

Definition at line 1446 of file pcp.c.

{
       struct conflict_list *p, **ptr;

       for (ptr= &conflict_list; *ptr; ptr=&(*ptr)->next)
       {
              if ( (*ptr)->end > end)
                     break;
       }

       if ((p=malloc(sizeof(struct conflict_list))) == NULL)
              return (-1);
       memset(p, 0, sizeof(*p));
       p->next= *ptr;
       *ptr=p;

       p->start=start;
       p->end=end;
       if ((p->event_id=strdup(event_id)) == NULL ||
           (address && (p->address=strdup(address)) == NULL))
              return (-1);

       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int save_conflict_subj ( struct PCP_retr r,
const char *  h,
const char *  v,
void *  dummy 
) [static]

Definition at line 1535 of file pcp.c.

{
       struct conflict_list *p;

       if (strcasecmp(h, "subject") || !v)
              return (0);

       for (p=conflict_list; p; p=p->next)
              if (p->event_id && strcmp(p->event_id, r->event_id) == 0)
              {
                     if (p->subject)
                            free(p->subject);
                     if ((p->subject=strdup(v)) != NULL)
                            collapse_subject(p->subject);
                     break;
              }
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int save_displayed_date ( struct PCP_retr r,
time_t  start,
time_t  end,
void *  vp 
) [static]

Definition at line 3229 of file pcp.c.

{
       struct display_retr *dr=(struct display_retr *)vp;

       struct display_retr_time_list **ptr, *p;

       for (ptr= &dr->time_list; *ptr; ptr=&(*ptr)->next)
              if ((*ptr)->start > start)
                     break;

       if ((p=malloc(sizeof(struct display_retr_time_list))) == NULL)
              return (-1);

       p->next= *ptr;
       *ptr=p;
       p->start=start;
       p->end=end;

       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int save_displayed_event ( struct PCP_retr r,
const char *  buf,
int  cnt,
void *  vp 
) [static]

Definition at line 3360 of file pcp.c.

{
       if (fwrite( buf, cnt, 1, ((struct display_retr *)vp)->f) != 1)
              return (-1);

       return (0);
}

Here is the caller graph for this function:

static int save_displayed_participants ( struct PCP_retr r,
const char *  address,
const char *  dummy,
void *  vp 
) [static]

Definition at line 3251 of file pcp.c.

{
       struct display_retr *dr=(struct display_retr *)vp;

       struct display_retr_participant_list **ptr, *p;

       for (ptr= &dr->participant_list; *ptr; ptr=&(*ptr)->next)
              if (strcasecmp((*ptr)->participant, address) > 0)
                     break;

       if ((p=malloc(sizeof(struct display_retr_participant_list))) == NULL)
              return (-1);

       if ((p->participant=strdup(address)) == NULL)
       {
              free(p);
              return (-1);
       }
       p->next= *ptr;
       *ptr=p;
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int save_listacl_names ( const char *  addr,
const char *  name,
void *  vp 
) [static]

Definition at line 4152 of file pcp.c.

{
       struct acl_list *p=(struct acl_list *)vp;

       for ( ; name && p; p=p->next)
              if (strcasecmp(p->addr, addr) == 0 && p->name == 0)
                     p->name=strdup(name);
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int save_orig_headers ( struct PCP_retr pcp,
const char *  h,
const char *  v,
void *  vp 
) [static]

Definition at line 3444 of file pcp.c.

{
       FILE *fp=(FILE *)vp;

       if (strcasecmp(h, "Date"))
              fprintf(fp, "%s: %s\n", h, v);
       return (0);
}

Here is the caller graph for this function:

static int save_participant_names ( const char *  addr,
const char *  name,
void *  vp 
) [static]

Definition at line 1024 of file pcp.c.

{
       struct my_participant *p=(struct my_participant *)vp;

       for ( ; name && p; p=p->next)
              if (strcasecmp(p->address, addr) == 0 && p->name == 0)
                     p->name=strdup(name);
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static char* savedraft ( ) [static]

Definition at line 2084 of file pcp.c.

{
       const char *p=cgi("draftmessage");
       char *msg, *filename;

       if (p && *p)
       {
              CHECKFILENAME(p);
       }

       filename=p && *p ? maildir_find(INBOX "." DRAFTS, p):NULL;

       msg=newmsg_createdraft_do(filename, cgi("message"), NEWMSG_PCP);
       if (filename)
              free(filename);

       if (!msg)
              enomem();
       return (msg);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void saveerror ( struct PCP pcp,
const int *  xerror 
) [static]

Definition at line 2510 of file pcp.c.

{
       static char *errmsgbuf=0;
       const char *p;

       if (xerror)
              switch (*xerror) {
              case PCP_ERR_SYSERR: /* Can be deliberate, see addacl() */
                     cgi_put("error", "calendar");
                     cgi_put("pcperror", strerror(errno));
                     return;
              case PCP_ERR_LOCK:
                     cgi_put("error", "locked");
                     return;
              case PCP_ERR_CONFLICT:
                     cgi_put("error", "conflict");
                     return;
              case PCP_ERR_EVENTNOTFOUND:
                     cgi_put("error", "notfound");
                     return;
              case PCP_ERR_EVENTLOCKED:
                     cgi_put("error", "eventlocked");
                     return;
              }

       cgi_put("error", "calendar");

       if (errmsgbuf)
              free(errmsgbuf);

       /*
       ** Save err msg into a static buffer, because err msg text memory
       ** may go away after the handle is closed.
       */

       p=pcp_errmsg(pcp);
       errmsgbuf=strdup(p ? p:"");
       cgi_put("pcperror", errmsgbuf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static int savetime ( time_t  from,
time_t  to,
void *  dummy 
) [static]

Definition at line 2023 of file pcp.c.

{
       char buf[NUMBUFSIZE];
       int fd= *(int *)dummy;

       maildir_writemsgstr(fd, "X-Event-Time: ");
       maildir_writemsgstr(fd, libmail_str_time_t(from, buf));
       maildir_writemsgstr(fd, " ");
       maildir_writemsgstr(fd, libmail_str_time_t(to, buf));
       maildir_writemsgstr(fd, "\n");
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* scriptptrget ( )

Definition at line 344 of file sqwebmail.c.

{
char   *q=0;
size_t l=0;
int    i;
char   buf[NUMBUFSIZE];

#define       ADD(s) {const char *zz=(s); if (i) strcat(q, zz); l += strlen(zz);}
#define ADDE(ue) { char *yy=cgiurlencode(ue); ADD(yy); free(yy); }

       for (i=0; i<2; i++)
       {
              if (i && (q=malloc(l+1)) == 0)     enomem();
              if (i) *q=0;
              ADD( nonloginscriptptr() );
              if (!sqwebmail_mailboxid)
              {
                     ADD("?");
                     continue;
              }

              ADD("/login/");
              ADDE(sqwebmail_mailboxid);
              ADD("/");
              ADD(sqwebmail_sessiontoken ? sqwebmail_sessiontoken:" ");
              ADD("/");
              ADD(libmail_str_time_t(login_time, buf));

              ADD( "?" );
              if (sqwebmail_folder)
              {
                     ADD("folder=");
                     ADDE(sqwebmail_folder);
              }
       }
#undef ADD
#undef ADDE
       return (q);
}

Here is the call graph for this function:

static int set_status ( struct PCP_retr pcp,
int  status,
void *  dummy 
) [static]

Definition at line 3221 of file pcp.c.

{
       cgi_put("event_cancelled", status & LIST_CANCELLED ? "1":"");
       cgi_put("event_booked", status & LIST_BOOKED ? "1":"");
       cgi_put("event_proxy", status & LIST_PROXY ? "1":"");
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void show_conflict_error ( struct PCP pcp) [static]

Definition at line 1476 of file pcp.c.

{
       unsigned n;
       struct conflict_list *p;
       const char **l;
       struct PCP_retr r;

       for (n=0, p=conflict_list; p; p=p->next)
              if (p->event_id && (!p->address ||
                                strcmp(p->address, "@") == 0))
                     ++n;

       if ((l=malloc(sizeof(const char *)*(n+1))) == NULL)
              return;

       for (n=0, p=conflict_list; p; p=p->next)
              if (p->event_id && (!p->address ||
                                strcmp(p->address, "@") == 0))
              {
                     l[n]=p->event_id;
                     ++n;
              }

       l[n]=0;
       memset(&r, 0, sizeof(r));
       r.event_id_list=l;
       r.callback_headers_func=save_conflict_subj;

       if (n == 0 || pcp_retr(pcp, &r) == 0)
       {
              printf("<table border=\"0\" width=\"100%%\" class=\"small-error\">");
              for (p=conflict_list; p; p=p->next)
              {
                     char buffer[512];

                     printf("<tr><td width=\"30\">&nbsp;</td><td><span class=\"tt\">");
                     if (pcp_fmttimerange(buffer, sizeof(buffer),
                                        p->start,
                                        p->end) == 0)
                     {
                            print_safe(buffer);
                     }
                     printf("</span></td><td width=\"30\">&nbsp;</td><td width=\"100%%\"><span class=\"tt\">");
                     if (p->address && strcmp(p->address, "@"))
                     {
                            printf(getarg("CONFLICTERR2"));
                            print_safe(p->address);
                     }
                     else
                            print_event_subject("", p->subject
                                              ? p->subject:"", 60);
                     printf("</span></td></tr>\n");
              }
              printf("<tr><td colspan=\"4\"><hr width=\"90%%\" /></td></tr></table>\n");
       }
       free(l);
       init_save_conflict();
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void show_pcp_errmsg ( const char *  p) [static]

Definition at line 2911 of file pcp.c.

{
       printf("<pre class=\"error\">");
       output_attrencoded_oknl_fp(p, stdout);
       printf("</pre>");
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void showerror ( ) [static]

Definition at line 1557 of file pcp.c.

{
       const char *p;

       p=cgi("error");
       if (strcmp(p, "quota") == 0)
              printf("%s", getarg("QUOTAERR"));
       if (strcmp(p, "time") == 0)
              printf("%s", getarg("NOTIMEERR"));
       if (strcmp(p, "conflict") == 0)
       {
              struct PCP *pcp=sqpcp_calendar();

              printf("%s", getarg("CONFLICTERR"));
              if (pcp)
                     show_conflict_error(pcp);
       }
       if (strcmp(p, "calendar") == 0)
       {
              printf(getarg("CALENDARERR"), cgi("pcperror"));
       }
       if (strcmp(p, "locked") == 0)
              printf("%s", getarg("LOCKERR"));
       if (strcmp(p, "notfound") == 0)
              printf("%s", getarg("NOTFOUNDERR"));
       if (strcmp(p, "eventlocked") == 0)
              printf("%s", getarg("EVENTLOCKEDERR"));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2186 of file pcp.c.

{
       char *msg;

       msg=savedraft();
       previewdraft(msg, NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2178 of file pcp.c.

{
       char *msg;

       msg=savedraft();
       previewdraft(msg, NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct PCP* sqpcp_calendar ( ) [read]

Definition at line 749 of file pcp.c.

{
       const char *p;

       if (!sqpcp_mode())
       {
              errno=ENOENT;
              return (NULL);
       }

       if (calendar)
              return (calendar);

       p=getenv("AUTHADDR");

       if (!p)
       {
              errno=ENOENT;
              return (NULL);
       }

       if (sqpcp_has_groupware())
       {
              char token[256];
              char *pp;

              FILE *f=fopen(TOKEN, "r");

              if (!f)
                     return (NULL);

              if (fgets(token, sizeof(token), f) == NULL)
              {
                     fclose(f);
                     return (NULL);
              }

              if ((pp=strchr(token, '\n')) != 0) *pp=0;

              fclose(f);
              if (token[0] == 0)
              {
                     unlink(TOKEN);
                     return (NULL);
              }

              calendar=pcp_reopen_server(p, token, NULL);

              if (calendar)
              {
                     p=pcp_authtoken(calendar);

                     if (p && strcmp(p, token))
                     {
                            int u=umask(077);

                            /* Save new authentication token */

                            f=fopen(TOKEN, "w");
                            umask(u);
                            if (f)
                            {
                                   fprintf(f, "%s\n", token);
                                   fclose(f);
                            }
                     }
              }
              else
              {
                     unlink(TOKEN);
              }
              return (calendar);
       }

       return ((calendar=pcp_open_dir("calendar", p)));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqpcp_close ( )

Definition at line 102 of file pcp.c.

Here is the caller graph for this function:

void sqpcp_daily_view ( )

Definition at line 2918 of file pcp.c.

{
       unsigned y, m, d;
       time_t start;
       time_t end;

       struct PCP *pcp;
       struct cacherecord *recs;
       unsigned n_recs;

       if (*cgi("clearcache"))
              unlink(CACHE);

       if (sscanf(cgi("date"), "%4u%2u%2u", &y, &m, &d) != 3
           || pcp_parse_ymd(y, m, d, &start, &end))
              return;

       if ((pcp=sqpcp_calendar()) == NULL)
       {
              printf("<span class=\"error\">%s</span>", strerror(errno));
              return;
       }

       if (createcache(pcp, &recs, &n_recs, start, end))
       {
              show_pcp_errmsg(pcp_errmsg(pcp));
              return;
       }

       (void)do_daily_view(recs, n_recs, VIEW_DAILY, NULL, NULL);
       destroycache(recs, n_recs);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 2144 of file pcp.c.

{
       char *msg;

       msg=savedraft();
       previewdraft(msg, deleteattach);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3437 of file pcp.c.

{
       sqpcp_displayeventinit();
       if (*cgi("event_proxy"))
              printf("%s", getarg("PROXYWARN"));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3275 of file pcp.c.

{
       struct PCP *pcp=sqpcp_calendar();
       const char *event_id_list[2];
       struct PCP_retr r;
       struct display_retr dr;
       struct maildir_tmpcreate_info createInfo;
       struct display_retr_time_list *tl;
       struct display_retr_participant_list *pl;

       if (!pcp)
              return;

       event_id_list[0]=cgi("eventid");
       event_id_list[1]=0;

       memset(&r, 0, sizeof(r));
       memset(&dr, 0, sizeof(dr));
       r.event_id_list=event_id_list;
       r.callback_arg=&dr;
       r.callback_rfc822_func=save_displayed_event;
       r.callback_retr_date=save_displayed_date;
       r.callback_retr_participants=save_displayed_participants;

       maildir_purgemimegpg(); /* Delete previous :calendar: file */

       maildir_tmpcreate_init(&createInfo);
       createInfo.uniq=":calendar:";
       createInfo.doordie=1;

       if ((dr.f=maildir_tmpcreate_fp(&createInfo)) == NULL)
       {
              error(strerror(errno));
       }

       cgi_put(MIMEGPGFILENAME, strrchr(createInfo.tmpname, '/')+1);

       if (pcp_retr(pcp, &r))
       {
              free_display_retr(&dr);
              fclose(dr.f);
              cgi_put(MIMEGPGFILENAME, "");
              unlink(createInfo.tmpname);
              maildir_tmpcreate_free(&createInfo);
              show_pcp_errmsg(pcp_errmsg(pcp));
              return;
       }
       fclose(dr.f);

       printf("<table class=\"calendarevent\" align=\"center\" border=\"0\"><tr valign=\"top\"><th align=\"left\">%s</th><td>",
              getarg("EVENT"));

       for (tl=dr.time_list; tl; tl=tl->next)
       {
              char buffer[512];

              if (pcp_fmttimerange(buffer, sizeof(buffer),
                                 tl->start, tl->end))
                     continue;

              printf("<span class=\"tt\">");
              print_safe(buffer);
              printf("</span><br />\n");
       }
       printf("</td></tr>\n");

       if (dr.participant_list)
       {
              printf("<tr valign=\"top\"><th align=\"left\">%s</th><td>",
                     getarg("PARTICIPANTS"));
              for (pl=dr.participant_list; pl; pl=pl->next)
              {
                     printf("<span class=\"tt\">&lt;");
                     print_safe(pl->participant);
                     printf("&gt;</span><br />\n");
              }
              printf("</td></tr>");
       }
       printf("</table>\n");
       folder_showmsg(INBOX "." DRAFTS, 0);
       free_display_retr(&dr);
       cgi_put(MIMEGPGFILENAME, "");
       maildir_tmpcreate_free(&createInfo);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3164 of file pcp.c.

{
       struct PCP *pcp;
       const char *event_id_list[2];
       struct PCP_retr r;

       showerror();

       pcp=sqpcp_calendar();

       if (!pcp)
              return;

       event_id_list[0]=cgi("eventid");
       event_id_list[1]=0;

       init_save_conflict();
       if (*cgi("docancel"))
       {
              if (pcp_cancel(pcp, event_id_list[0], NULL))
                     show_pcp_errmsg(pcp_errmsg(pcp));
              unlink(CACHE);
       }

       if (*cgi("douncancel"))
       {
              struct PCP_uncancel u;
              int flags=0;

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

              if (*cgi("okconflict"))
                     flags |= PCP_OK_CONFLICT;

              u.uncancel_conflict_callback=save_conflict;
              if (pcp_uncancel(pcp, event_id_list[0], flags, &u))
              {
                     saveerror(pcp, &u.errcode);
                     showerror();
                     if (u.errcode == PCP_ERR_CONFLICT)
                            cgi_put("okconflict", "1");
              }
              unlink(CACHE);
       }

       memset(&r, 0, sizeof(r));
       r.event_id_list=event_id_list;
       r.callback_retr_status=set_status;

       if (pcp_retr(pcp, &r))
       {
              show_pcp_errmsg(pcp_errmsg(pcp));
              return;
       }

}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 4013 of file pcp.c.

{
       int i, y, m;
       time_t start=get_start_of_month(), save_start;
       time_t end;
       struct PCP *pcp=sqpcp_calendar();
       struct cacherecord *recs;
       unsigned n_recs;
       struct tm *tmptr;

       if (!pcp)
              return;

       if ((tmptr=localtime(&start)) == NULL)
              return;

       y=tmptr->tm_year + 1900;
       m=tmptr->tm_mon + 1;

       if (++m > 12)
       {
              m=1;
              ++y;
       }

       if (pcp_parse_ymd(y, m, 1, &end, &save_start))
              return;

       if (createcache(pcp, &recs, &n_recs, start, end))
       {
              show_pcp_errmsg(pcp_errmsg(pcp));
              return;
       }

       printf("<table align=\"center\" border=\"0\" class=\"monthly-border\""
              " cellpadding=\"0\" cellspacing=\"0\" width=\"100%%\">"
              "<tr><td>\n");
       printf("<table border=\"1\" class=\"monthly-bg\" cellspacing=\"0\" cellpadding=\"10\" width=\"100%%\">"
              "<tr valign=\"top\">");

       for (i=0; i<7; i++)
       {
              printf("<td width=\"14%%\" align=\"center\" class=\"monthly-day\">");
              print_safe(pcp_wdayname((i + pref_startofweek) % 7));
              printf("</td>");
       }
       printf("</tr>\n");

       while (start < end)
       {
              printf("<tr valign=\"top\">\n");

              for (i=0; i<7; i++)
              {
                     struct tm *tmptr;
                     time_t next_day;

                     tmptr=localtime(&start);

                     if (tmptr->tm_wday != (i + pref_startofweek) % 7
                         || start >= end)
                     {
                            printf("<td width=\"14%%\" class=\"monthly-bg-othermonth\">&nbsp;</td>");
                            continue;
                     }

                     printf("<td width=\"14%%\">");


                     printf("<a href=\"");
                     output_scriptptrget();
                     printf("&amp;form=eventdaily&amp;date=");

                     if (tmptr)
                     {
                            printf("%04d%02d%02d", tmptr->tm_year + 1900,
                                   tmptr->tm_mon+1,
                                   tmptr->tm_mday);
                     }
                     printf("\" class=\"monthly-day\">");

                     printf("%2d", tmptr->tm_mday);
                     printf("</a><div align=\"center\"><hr width=\"70%%\" /></div>\n");

                     next_day=start;
                     nextday(&next_day);

                     do_daily_view(recs, n_recs, VIEW_MONTHLY, &start,
                                  &next_day);

                     start=next_day;
                     printf("</td>\n");
              }
              printf("</tr>\n");
       }
       destroycache(recs, n_recs);
       printf("</table>\n");
       printf("</td></tr></table>\n");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3849 of file pcp.c.

{
       int i;
       time_t start=get_start_of_week(), save_start;
       time_t end;
       struct PCP *pcp=sqpcp_calendar();
       struct cacherecord *recs;
       unsigned n_recs;

       if (!pcp)
              return;

       save_start=start;

       for (i=0; i<7; i++)
       {
              nextday(&start);
       }

       if (createcache(pcp, &recs, &n_recs, save_start, start))
       {
              show_pcp_errmsg(pcp_errmsg(pcp));
              return;
       }

       printf("<table align=\"center\" border=\"0\" class=\"weekly-border\""
              " cellpadding=\"0\" cellspacing=\"0\" width=\"100%%\">"
              "<tr><td>\n");
       printf("<table border=\"1\" class=\"weekly-bg\" cellspacing=\"0\" cellpadding=\"10\" width=\"100%%\">"
              "<tr valign=\"top\">");

       start=save_start;
       for (i=0; i<7; i++)
       {
              const char *p;
              struct tm *tmptr;

              printf("<td width=\"14%%\">");
              p=pcp_wdayname((i + pref_startofweek) % 7);
              printf("<div align=\"center\" class=\"weekly-day\">");
              printf("<a href=\"");
              output_scriptptrget();
              printf("&amp;form=eventdaily&amp;date=");

              tmptr=localtime(&start);

              if (tmptr)
              {
                     printf("%04d%02d%02d", tmptr->tm_year + 1900,
                            tmptr->tm_mon+1,
                            tmptr->tm_mday);
              }
              printf("\">");
              print_safe(p);
              printf("</a><hr width=\"70%%\" />");
              printf("</div>\n");

              end=start;
              nextday(&end);


              do_daily_view(recs, n_recs, VIEW_WEEKLY, &start, &end);

              start=end;
              printf("</td>");
       }
       destroycache(recs, n_recs);
       printf("</tr></table>\n");
       printf("</td></tr></table>\n");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqpcp_dodelete ( )

Definition at line 3455 of file pcp.c.

{
       struct PCP *pcp=sqpcp_calendar();
       struct PCP_retr r;
       const char *event_list_ary[2];
       struct PCP_delete del;
       struct proxy_update_list pul;
       FILE *tmpfp;

       if (!pcp)
              return;

       memset(&del, 0, sizeof(del));
       del.id=cgi("eventid");

       memset(&r, 0, sizeof(r));
       event_list_ary[0]=del.id;
       event_list_ary[1]=NULL;
       r.event_id_list=event_list_ary;
       r.callback_headers_func=save_orig_headers;

       tmpfp=tmpfile();
       if (!tmpfp)
              enomem();
       r.callback_arg=tmpfp;
       pcp_retr(pcp, &r);

       {
              time_t t;

              time(&t);

              fprintf(tmpfp, "Date: %s\n\n", rfc822_mkdate(t));
       }

       memset(&pul, 0, sizeof(pul));
       del.proxy_callback=&proxy_update_list_save;
       del.proxy_callback_ptr=&pul;

       if (pcp_delete(pcp, &del))
       {
              saveerror(pcp, &del.errcode);
              output_form("eventdelete.html");
       }
       else
       {
              proxy_notify_email(tmpfp, &pul, NULL, 0);
       }
       fclose(tmpfp);
       proxy_update_list_free(&pul);
       unlink(CACHE);
       output_form("eventdaily.html");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqpcp_eventacl ( )

Definition at line 4163 of file pcp.c.

{
       const char *p;
       struct acl_list *acl_list=NULL;
       struct PCP *pcp;
       struct acl_list *pp;

       if (!sqpcp_has_groupware())
              return;

       p=cgi("addemail");

       while (*p && isspace((int)(unsigned char)*p))
              ++p;

       if (!*p)
              p=cgi("addressbookname");

       if (*p)
              addacl(p);

       pcp=sqpcp_calendar();

       if (!pcp)
              return;

       if (*(p=cgi("remove")))
       {
              if (pcp_acl(pcp, p, 0))
              {
                     saveerror(pcp, NULL);
                     showerror();
              }
       }

       if (pcp_list_acl(pcp, listacl, &acl_list))
       {
              saveerror(pcp, NULL);
              showerror();
       }
       else if (ab_get_nameaddr(save_listacl_names, acl_list))
       {
              int dummy=PCP_ERR_SYSERR;

              saveerror(NULL, &dummy);
              showerror();
       }
       else if (acl_list)
       {
              printf("<table align=\"center\">\n");

              for (pp=acl_list; pp; pp=pp->next)
              {
                     printf("<tr><td align=\"right\"><span class=\"tt\">");
                     if (pp->addr)
                            ab_nameaddr_show(pp->name, pp->addr);

                     printf("</span></td><td>-");
                     if (pp->flags & PCP_ACL_MODIFY)
                            printf("&nbsp;%s", getarg("MODIFY"));
                     if (pp->flags & PCP_ACL_CONFLICT)
                            printf("&nbsp;%s", getarg("CONFLICT"));
                     printf("</td><td><a href=\"");
                     output_scriptptrget();
                     printf("&amp;form=eventacl&amp;remove=");
                     output_urlencoded(pp->addr);
                     printf("\">%s</a></td></tr>\n", getarg("REMOVE"));
              }
              printf("</table>\n");
       }

       while ((pp=acl_list) != NULL)
       {
              acl_list=pp->next;
              if (pp->addr)
                     free(pp->addr);
              if (pp->name)
                     free(pp->name);
              free(pp);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1112 of file pcp.c.

{
       const char *p;

       p=cgi("draftmessage");

       if (p && *p)
       {
              attachments_head(NULL, cgi("pos"), p);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3390 of file pcp.c.

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3425 of file pcp.c.

{
       printf("%s", getarg(*cgi("event_cancelled")
                         ? "UNCANCELIMAGE":"CANCELIMAGE"));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3416 of file pcp.c.

{
       print_event_link_url(cgi("eventid"), *cgi("event_cancelled")
                      ? (*cgi("okconflict") ?
                         "&amp;okconflict=1&amp;douncancel=1"
                         :"&amp;douncancel=1")
                          :"&amp;docancel=1");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3431 of file pcp.c.

{
       printf("%s", getarg(*cgi("event_cancelled")
                         ? "UNCANCELTEXT":"CANCELTEXT"));
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3405 of file pcp.c.

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

       output_scriptptrget();
       printf("&amp;eventid=");

       output_urlencoded(cgi("eventid"));
       printf("&amp;form=eventdelete&amp;date=%s", p);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int sqpcp_eventedit ( )

Definition at line 3513 of file pcp.c.

{
       struct PCP *pcp=sqpcp_calendar();
       int newdraftfd;
       char *draftfilename;

       if (!pcp)
              return (-1);

       newdraftfd=maildir_createmsg(INBOX "." DRAFTS, 0, &draftfilename);
       if (doeventedit(pcp, newdraftfd))
       {
              maildir_deletenewmsg(newdraftfd, INBOX "." DRAFTS, draftfilename);
       }
       else if (maildir_closemsg(newdraftfd, INBOX "." DRAFTS, draftfilename, 1, 0))
       {
              cgi_put("error", "quota");
       }
       else
       {
              static char *filenamebuf=0;

              if (filenamebuf)
                     free(filenamebuf);

              filenamebuf=draftfilename;
              cgi_put("draftmessage", filenamebuf);
              return (0);
       }
       free(draftfilename);
       return (-1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3396 of file pcp.c.

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

       output_scriptptrget();
       printf("&amp;form=event-edit&amp;date=%s&amp;eventid=", p);
       output_urlencoded(cgi("eventid"));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqpcp_eventend ( )

Definition at line 975 of file pcp.c.

{
       struct my_participant *m;

       while ((m=my_participant_list) != NULL)
       {
              my_participant_list=m->next;
              if (m->name)
                     free(m->name);
              if (m->address)
                     free(m->address);
              free(m);
       }

       if (event_time_list)
              free(event_time_list);
       event_time_list=NULL;
       n_event_time_list=0;

}

Here is the caller graph for this function:

void sqpcp_eventfrom ( )

Definition at line 1065 of file pcp.c.

{
       if (auth_getoptionenvint("wbnochangingfrom"))
       {
              printf("<span class=\"tt\">");
              print_safe(login_fromhdr());
              printf("</span>");
       }
       else
       {
              const char *p=cgi("headerfrom");

              if (!p || !*p)
                     p=pref_from;
              if (!p || !*p)
                     p=login_fromhdr();
              if (!p)
                     p="";

              printf("<input type=\"text\" name=\"headerfrom\" size=\"60\" value=\"");
              output_attrencoded(p);
              printf("\" />");
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1035 of file pcp.c.

{
       struct my_participant *m;

       if (!my_participant_list)
              return;

       (void)ab_get_nameaddr(save_participant_names, my_participant_list);

       printf("<table border=\"0\">");

       for (m=my_participant_list; m; m=m->next)
       {
              printf("<tr><td><span class=\"tt\">");
              if (m->address)
                     ab_nameaddr_show(m->name, m->address);

              printf("</span></td><td>&nbsp;&nbsp;<a href=\"");

              output_scriptptrget();
              printf("&amp;form=newevent&amp;draftmessage=");
              output_urlencoded(cgi("draftmessage"));
              printf("&amp;do.delparticipant=");
              output_urlencoded(m->address);
              printf("\"><font size=\"-2\">(%s)</font></a></td></tr>\n",
                     getarg("REMOVE"));
       }
       printf("</table>");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqpcp_eventstart ( )

Definition at line 861 of file pcp.c.

{
       const char *p=cgi("draftmessage");
       FILE *oldfp;
       struct rfc822hdr h;
       struct PCP_event_time_list {
              struct PCP_event_time_list *next;
              struct PCP_event_time t;
       } *event_time_listp=NULL, **lastp= &event_time_listp;
       unsigned event_time_list_cnt=0;

       sqpcp_eventend();

       if (!p || !*p)
              return;

       oldfp=openoldfp(p, NULL);
       if (!oldfp)
              return;

       rfc822hdr_init(&h, 8192);
       while (rfc822hdr_read(&h, oldfp, NULL, 0) == 0)
       {
              if (strcasecmp(h.header, "X-Event-Time") == 0 && h.value)
              {
                     unsigned long n1, n2;

                     if (sscanf(h.value, "%lu %lu", &n1, &n2) == 2)
                     {
                            struct PCP_event_time_list *t=
                                   malloc(sizeof(**lastp));

                            if (!t)
                            {
                                   rfc822hdr_free(&h);
                                   sqpcp_eventend();
                                   enomem();
                                   return;
                            }
                            *lastp=t;
                            t->next=NULL;
                            t->t.start=(time_t)n1;
                            t->t.end=(time_t)n2;
                            ++event_time_list_cnt;
                            lastp=&t->next;
                     }
              }
              else if (strcasecmp(h.header, "X-Event-Participant") == 0 && h.value)
              {
                     add_my_participant(h.value);
              }
              else if (strcasecmp(h.header, "from") == 0 && h.value)
              {
                     rfc822hdr_collapse(&h);
                     if (from_buf)
                            free(from_buf);

                     from_buf=NULL;

                     if ((from_buf=
                          rfc822_display_hdrvalue_tobuf(h.header,
                                                    h.value,
                                                    sqwebmail_content_charset,
                                                    NULL, NULL)) == NULL)
                            from_buf=strdup(h.value);

                     if (from_buf)
                            cgi_put("from", from_buf);
              }
              else if (strcasecmp(h.header, "subject") == 0 && h.value)
              {
                     rfc822hdr_collapse(&h);
                     if (subj_buf)
                            free(subj_buf);

                     subj_buf=rfc822_display_hdrvalue_tobuf(h.header,
                                                        h.value,
                                                        sqwebmail_content_charset,
                                                        NULL, NULL);
                     if (!subj_buf)
                            subj_buf=strdup(subj_buf);

                     if (subj_buf)
                            cgi_put("headersubject", subj_buf);
              }
       }
       rfc822hdr_free(&h);
       if (event_time_list_cnt)
       {
              struct PCP_event_time *list1;
              struct PCP_event_time_list *p;

              list1=malloc(sizeof(struct PCP_event_time_list)
                          *event_time_list_cnt);
              if (!list1)
              {
                     sqpcp_eventend();
                     enomem();
                     return;
              }
              event_time_list_cnt=0;
              while ((p=event_time_listp) != NULL)
              {
                     list1[event_time_list_cnt]=p->t;
                     ++event_time_list_cnt;
                     event_time_listp=p->next;
                     free(p);
              }

              event_time_list=list1;
              n_event_time_list=event_time_list_cnt;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqpcp_eventtext ( )

Definition at line 1090 of file pcp.c.

{
       const char *p;

       printf("<textarea name=\"message\" cols=\"%d\" rows=\"15\" wrap=\"soft\">",
              MYLINESIZE);
       p=cgi("draftmessage");

       if (p && *p)
       {
              FILE *fp=openoldfp(p, NULL);
              int dummy;

              if (fp)
              {
                     newmsg_showfp(fp, &dummy);
              }
              fclose(fp);
       }
       printf("</textarea>\n");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqpcp_eventtimes ( )

Definition at line 996 of file pcp.c.

{
       char buffer[512];
       unsigned i;

       for (i=0; i<n_event_time_list; i++)
       {
              if (i)
                     printf("<br />\n");
              if (pcp_fmttimerange(buffer, sizeof(buffer),
                                 event_time_list[i].start,
                                 event_time_list[i].end))
                     continue;
              printf("<span class=\"tt\">");
              print_safe(buffer);
              printf("&nbsp;&nbsp;</span><a href=\"");
              output_scriptptrget();
              printf("&amp;form=newevent&amp;draftmessage=");
              output_urlencoded(cgi("draftmessage"));
              printf("&amp;do.deleventtime=%s-%s\"><font size=\"-2\">"
                     "(%s)</font></a>",
                     libmail_str_time_t(event_time_list[i].start, buffer),
                     libmail_str_time_t(event_time_list[i].end, buffer+NUMBUFSIZE),
                     getarg("REMOVE")
                     );
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 222 of file pcp.c.

{
       return (sqpcp_mode() ? 1:0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 227 of file pcp.c.

{
       const char *p=sqpcp_mode();

       return (p && strcmp(p, "net") == 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqpcp_init ( )

Definition at line 93 of file pcp.c.

Here is the caller graph for this function:

int sqpcp_loggedin ( )

Definition at line 245 of file pcp.c.

{
       struct PCP *pcp;

       if (!sqpcp_mode())
              return (0);

       if (sqpcp_has_groupware())
       {
              struct stat stat_buf;

              if (stat(TOKEN, &stat_buf))
                     return (0);   /* Login session dropped */
       }

       if (!need_refresh())
              return (1);
       pcp=sqpcp_calendar();
       if (pcp)
              refreshcache(pcp);
       return (1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqpcp_login ( const char *  userid,
const char *  password 
)

Definition at line 149 of file pcp.c.

{
       do_pcplogin(userid, password, 0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static const char* sqpcp_mode ( ) [static]

Definition at line 114 of file pcp.c.

{
       if (!checked_calendar_mode)
       {
              FILE *f;
              char *p;

              calendar_mode[0]=0;

              f=fopen(CALENDARMODE, "r");

              if (f)
              {
                     if (fgets(calendar_mode, sizeof(calendar_mode),
                              f) == NULL)
                     {
                            calendar_mode[0]=0;
                     }
                     fclose(f);
              }

              if ((p=strchr(calendar_mode, '\n')) != 0)
                     *p=0;
              checked_calendar_mode=1;
       }

       return (calendar_mode[0] ? calendar_mode:NULL);
}

Here is the caller graph for this function:

Definition at line 2894 of file pcp.c.

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

       if (!*p)
              p=cgi("weekof");
       output_scriptptrget();
       printf("&amp;form=eventmonthly&amp;monthof=%s", p);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqpcp_newevent ( )

Definition at line 1687 of file pcp.c.

{
       char *draftfilename;
       int newdraftfd;
       const char *p;
       unsigned long prev_size=0;
       FILE *oldfp=NULL;
       int errflag=0;
       int do_newevent= *cgi("do.neweventtime") ? 1:0;
       int do_newparticipant= *cgi("do.addparticipant") ? 1:0;
       int do_delevent=0;
       int do_delparticipant= *cgi("do.delparticipant") ? 1:0;
       time_t delstart=0, delend=0;

       static char *draftmessage_buf=0;

       showerror();

       if (!do_newevent)
       {
              if ((p=cgi("do.deleventtime")) && *p)
              {
                     unsigned long a, b;

                     if (sscanf(p, "%lu-%lu", &a, &b) == 2)
                     {
                            delstart=(time_t)a;
                            delend=(time_t)b;
                            do_delevent=1;
                     }
              }
       }

       p=cgi("draftmessage");

       if (!do_newevent && !do_delevent && !do_newparticipant
           && !do_delparticipant)
       {
              if (*cgi("do.neweventpreview") && p && *p)
              {
                     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");
                     newmsg_preview(p);
                     printf("</td></tr></table>\n");
                     printf("</td></tr></table>\n");
              }
              return;
       }

       if (p && *p)
       {
              oldfp=openoldfp(p, &prev_size);
              if (!oldfp)
                     p="";
       }

       if (p && *p)
       {
              newdraftfd=maildir_recreatemsg(INBOX "." DRAFTS, p, &draftfilename);
       }
       else
       {
              newdraftfd=maildir_createmsg(INBOX "." DRAFTS, 0, &draftfilename);
              maildir_writemsgstr(newdraftfd, "X-Event: 1\n");

              if (draftmessage_buf)
                     free(draftmessage_buf);
              if ((draftmessage_buf=strdup(draftfilename)) != 0)
                     cgi_put("draftmessage", draftmessage_buf);
       }

       if (do_newevent || do_delevent || do_newparticipant
           || do_delparticipant)
       {
              if (oldfp)
              {
                     struct rfc822hdr h;

                     rfc822hdr_init(&h, 8192);
                     while (rfc822hdr_read(&h, oldfp, NULL, 0) == 0)
                     {
                            unsigned long a, b;
                            if (do_delevent && strcasecmp(h.header,
                                                       "X-Event-Time")
                                == 0 && h.value && sscanf(h.value,
                                                       "%lu %lu",
                                                       &a, &b) == 2)

                            {
                                   if ( (time_t)a == delstart &&
                                        (time_t)b == delend)
                                          continue;
                            }

                            if (do_delparticipant
                                && strcasecmp(h.header, "X-Event-Participant")
                                == 0 && h.value)
                            {
                                   if (strcmp(h.value,
                                             cgi("do.delparticipant"))
                                       == 0)
                                          continue;
                            }
                            if (strcasecmp(h.header,
                                          "X-Event-Participant") == 0 &&
                                h.value)
                                   add_my_participant(h.value);

                            if (strcasecmp(h.header, "To") == 0)
                                   continue;
                            /* To: header rebuilt later */

                            maildir_writemsgstr(newdraftfd, h.header);
                            maildir_writemsgstr(newdraftfd, ": ");
                            maildir_writemsgstr(newdraftfd, h.value);
                            maildir_writemsgstr(newdraftfd, "\n");
                     }
                     rfc822hdr_free(&h);

              }

              if (do_newevent && addtime(newdraftfd))
              {
                     errflag=1;
                     printf("%s", getarg("TIMEERR"));
              }

              if (do_newparticipant)
              {
                     const char *p=cgi("addressbookname");

                     if (!*p)
                            p=cgi("participant1");

                     addparticipant(newdraftfd, p);
              }

              (void)ab_get_nameaddr(save_participant_names,
                                  my_participant_list);

#if 0
              {
                     struct rfc822t *t;
                     struct rfc822a *a;
                     char *p;
                     char *tohdr;
                     size_t tohdr_size;

                     mktohdr(NULL, &tohdr_size);

                     tohdr=malloc(tohdr_size);
                     if (!tohdr)
                            enomem();

                     mktohdr(tohdr, &tohdr_size);

                     if ((t=rfc822t_alloc_new(tohdr, NULL, NULL)) == NULL)
                     {
                            free(tohdr);
                            enomem();
                     }

                     if ((a=rfc822a_alloc(t)) == NULL)
                     {
                            rfc822t_free(t);
                            free(tohdr);
                            enomem();
                     }

                     p=rfc2047_encode_header(a,sqwebmail_content_charset);

                     if (!p)
                     {
                            rfc822a_free(a);
                            rfc822t_free(t);
                            free(tohdr);
                            enomem();
                     }
                     free(tohdr);
                     tohdr=p;
                     rfc822a_free(a);
                     rfc822t_free(t);

                     maildir_writemsgstr(newdraftfd, tohdr);
                     maildir_writemsgstr(newdraftfd, "\n");
                     free(tohdr);
              }
#endif

              sqpcp_eventend(); /* Deallocate participant list */

              maildir_writemsgstr(newdraftfd, "\n");
       }

       if (oldfp)
       {
              char buf[BUFSIZ];
              int n;

              while ((n=fread(buf, 1, sizeof(buf), oldfp)) > 0)
                     maildir_writemsg(newdraftfd, buf, n);
       }

       if (oldfp)
              fclose(oldfp);

       if (errflag)
       {
              maildir_deletenewmsg(newdraftfd, INBOX "." DRAFTS, draftfilename);
       }
       else if (maildir_closemsg(newdraftfd, INBOX "." DRAFTS, draftfilename, 1,
                              prev_size))
       {
              printf("%s", getarg("QUOTAERR"));
       }

       free(draftfilename);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqpcp_nextday ( )

Definition at line 3103 of file pcp.c.

{
       unsigned y, m, d;
       time_t start;
       time_t end;
       struct tm *tm;
       char buf[256];

       if (sscanf(cgi("date"), "%4u%2u%2u", &y, &m, &d) != 3
           || pcp_parse_ymd(y, m, d, &start, &end))
              return;

       start=end;

       if ((tm=localtime(&start)) == NULL)
              return;

       y=tm->tm_year + 1900;
       m=tm->tm_mon + 1;
       d=tm->tm_mday;

       if (pcp_parse_ymd(y, m, d, &start, &end)
           || (tm=localtime(&start)) == NULL
           || strftime(buf, sizeof(buf), getarg("NEXTDAY"), tm) == 0)
              return;

       printf("<a class=\"dailynextprev\" href=\"");
       output_scriptptrget();
       printf("&amp;form=eventdaily&amp;date=%04d%02d%02d\">%s</a>", y, m, d, buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqpcp_postpone ( )

Definition at line 2133 of file pcp.c.

{
       char *msg;

       msg=savedraft();
       free(msg);
       output_form("folders.html");
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqpcp_prevday ( )

Definition at line 3072 of file pcp.c.

{
       unsigned y, m, d;
       time_t start;
       time_t end;
       struct tm *tm;
       char buf[256];

       if (sscanf(cgi("date"), "%4u%2u%2u", &y, &m, &d) != 3
           || pcp_parse_ymd(y, m, d, &start, &end))
              return;

       start -= 12 * 60 * 60;

       if ((tm=localtime(&start)) == NULL)
              return;

       y=tm->tm_year + 1900;
       m=tm->tm_mon + 1;
       d=tm->tm_mday;

       if (pcp_parse_ymd(y, m, d, &start, &end)
           || (tm=localtime(&start)) == NULL
           || strftime(buf, sizeof(buf), getarg("PREVDAY"), tm) == 0)
              return;

       printf("<a class=\"dailynextprev\" href=\"");
       output_scriptptrget();
       printf("&amp;form=eventdaily&amp;date=%04d%02d%02d\">%s</a>", y, m, d, buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqpcp_preview ( )

Definition at line 2125 of file pcp.c.

{
       char *msg;

       msg=savedraft();
       previewdraft(msg, NULL);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void sqpcp_save ( )

Definition at line 2411 of file pcp.c.

{
       char *msg, *sentmsg, *p;
       FILE *fp;
       struct saveinfo si;
       int isgpgerr;

       msg=savedraft();
       if (*cgi("error"))   /* Error, go back to the screen */
       {
              previewdraft(msg, NULL);
              return;
       }

       fp=openoldfp(msg, NULL);
       if (!fp)
       {
              free(msg);
              enomem();
       }

       if (init_saveinfo(&si, fp))
       {
              fclose(fp);
              free(msg);
              enomem();
       }

       if (si.times == 0)
       {
              fclose(fp);
              cgi_put("error", "time");
              previewdraft(msg, NULL);
              return;
       }
       fclose(fp);

       sentmsg=newmsg_createsentmsg(msg, &isgpgerr);

       /* Immediately remove the formatted event text from the sent folder */

       if (sentmsg)
       {
              p=maildir_find(INBOX "." SENT, sentmsg);
              free(sentmsg);
              sentmsg=p;
       }

       if (!sentmsg)
       {
              cgi_put("error", "quota");  /* TODO: gpgerr */
              free_saveinfo(&si);
              previewdraft(msg, NULL);
              return;
       }


       fp=fopen(sentmsg, "r");
       if (!fp)
       {
              free(sentmsg);
              free(msg);
              free_saveinfo(&si);
              enomem();
              return;
       }

       fcntl(fileno(fp), F_SETFD, FD_CLOEXEC);

       unlink(sentmsg);
       dropquota(sentmsg, fileno(fp));
       free(sentmsg);

       if (dosave(fp, &si))
       {
              fclose(fp);
              free_saveinfo(&si);
              previewdraft(msg, NULL);
              return;
       }
       fclose(fp);

       p=maildir_find(INBOX "." DRAFTS, msg);
       free(msg);

       fp=p ? fopen(p, "r"):NULL;
       unlink(p);
       if (fp)
       {
              dropquota(p, fileno(fp));
              fclose(fp);
       }
       free(p);
       free_saveinfo(&si);
       output_form("folders.html");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3951 of file pcp.c.

{
       time_t start=get_start_of_month();
       struct tm *tmptr;
       char buf[512];

       if ((tmptr=localtime(&start)) == NULL)
              return;

       if (strftime(buf, sizeof(buf), getarg("DATEFORMAT"), tmptr) == 0)
              return;

       print_safe(buf);

}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3967 of file pcp.c.

{
       time_t start=get_start_of_month();
       struct tm *tmptr;
       int m, y;

       if ((tmptr=localtime(&start)) == NULL)
              return;

       y=tmptr->tm_year + 1900;
       m=tmptr->tm_mon + 1;

       ++m;
       if (m > 12)
       {
              m=1;
              ++y;
       }

       output_scriptptrget();
       printf("&amp;form=eventmonthly&amp;monthof=%04d%02d01", y, m);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 3813 of file pcp.c.

{
       time_t start=get_start_of_week();
       int i;
       struct tm *tmptr;

       for (i=0; i<7; i++)
              nextday(&start);

       if ((tmptr=localtime(&start)) == NULL)
              return;

       output_scriptptrget();
       printf("&amp;form=eventweekly&amp;weekof=%04d%02d%02d",
              tmptr->tm_year + 1900, tmptr->tm_mon+1, tmptr->tm_mday);

}

Here is the call graph for this function:

Here is the caller graph for this function: