Back to index

courier  0.68.2
Classes | Defines | Functions
pcp.h File Reference
#include "config.h"
#include <time.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  PCP_new_eventid
struct  PCP_event_participant
struct  PCP_save_event
struct  PCP_commit
struct  PCP_delete
struct  PCP_event_time
struct  PCP_uncancel
struct  PCP_list_all
struct  PCP_retr
struct  PCP
struct  pcp_parse_datetime_info

Defines

#define PCP_OK_CONFLICT   1 /* Ok if time conflict with existing events */
#define PCP_OK_PROXY_ERRORS
#define PCP_BYPROXY
#define PCP_ERR_SYSERR   0 /* See errno */
#define PCP_ERR_LOCK   1
#define PCP_ERR_CONFLICT   2
#define PCP_ERR_EVENTNOTFOUND   3
#define PCP_ERR_EVENTLOCKED   4
#define LIST_CANCELLED   1
#define LIST_BOOKED   2
#define LIST_PROXY   4
#define pcp_errmsg(s)   ( (*(s)->errmsg_func)(s))
#define pcp_noop(s)   ( (*(s)->noop_func)(s))
#define pcp_authtoken(s)   ( (*(s)->authtoken_func)(s))
#define pcp_cleanup(s)   ( (*(s)->cleanup_func)(s))
#define pcp_new_eventid(s, e, a)   ( (*(s)->create_new_eventid_func)((s),(e),(a)))
#define pcp_destroy_eventid(s, e)   ( (*(s)->destroy_new_eventid_func)((s),(e)))
#define pcp_commit(s, e, f)   ( (*(s)->commit_func)((s),(e),(f)))
#define pcp_book(s, e, f)   ( (*(s)->book_func)((s),(e),(f)))
#define pcp_list_all(s, f)   ( (*(s)->list_all_func)((s),(f)))
#define pcp_retr(s, f)   ( (*(s)->retr_func)((s),(f)))
#define pcp_cancel(s, n, e)   ( (*(s)->cancel_func)((s), (n), (e)))
#define pcp_uncancel(s, n, f, e)   ( (*(s)->uncancel_func)((s), (n), (f), (e)))
#define pcp_delete(s, p)   ( (*(s)->delete_func)((s), (p)))
#define pcp_close(s)   ((*(s)->close_func)((s)))
#define pcp_acl(s, w, f)   ((*(s)->acl_func)((s), (w), (f)))
#define pcp_list_acl(s, f, v)   ((*(s)->listacl_func)((s), (f), (v)))
#define pcp_has_acl(s)   ((s)->acl_func != 0)
#define PCP_ACL_MODIFY   1
#define PCP_ACL_CONFLICT   2
#define PCP_ACL_LIST   4
#define PCP_ACL_RETR   8
#define PCP_ACL_NONE   16
#define PCP_ERRMSG(s)   (s)
#define PCP_STRERROR_N(n, s)   if (i == n) return (PCP_ERRMSG(s));
#define PCP_STRERROR
#define FMTTIME_DATE   1
#define FMTTIME_TIME   2
#define FMTTIME_TIMEDROP   4
#define PCP_RECURRING_WEEKLY   0
#define PCP_RECURRING_MONTHLY   1
#define PCP_RECURRING_ANNUALLY   2

Functions

struct PCPpcp_open_dir (const char *, const char *)
struct PCPpcp_open_server (const char *, const char *, char **)
struct PCPpcp_reopen_server (const char *, const char *, char **)
struct PCPpcp_find_proxy (const char *, const char *, char **)
int pcp_set_proxy (struct PCP *, const char *)
const char * pcp_strerror (int)
const char * pcp_am ()
const char * pcp_pm ()
const char * pcp_wdayname (unsigned)
const char * pcp_wdayname_long (unsigned)
const char * pcp_monthname (unsigned)
const char * pcp_monthname_long (unsigned)
int pcp_wday (const char *)
int pcp_month (const char *)
int pcp_fmttime (char *, size_t, time_t, int)
int pcp_fmttimerange (char *, size_t, time_t, time_t)
time_t pcp_parse_datetime (int *argn, int argc, char **argv, struct pcp_parse_datetime_info *info)
int pcp_parse_datetime_until (time_t start, time_t end, int *argn, int argc, char **argv, int recurring_time, int(*save_date_time)(time_t, time_t, void *), void *voidfunc)
int pcp_parse_ymd (unsigned, unsigned, unsigned, time_t *, time_t *)
time_t pcp_gmtime (int y, int m, int d, int hh, int mm, int ss)
time_t pcp_gmtime_s (const char *p)
void pcp_gmtimestr (time_t t, char *)
struct PCP_event_time ** pcp_add_sort_times (const struct PCP_event_time *, unsigned)
int pcp_read_saveevent (struct PCP_save_event *, char *, int)
int pcp_mksocket (const char *, const char *)
void pcp_acl_name (int, char *)
int pcp_acl_num (const char *)
const char * pcpuid ()
const char * pcpgid ()

Class Documentation

struct PCP_new_eventid

Definition at line 25 of file pcp.h.

Class Members
char * eventid
struct PCP_event_participant

Definition at line 29 of file pcp.h.

Class Members
const char * address
const char * eventid
struct PCP_event_time

Definition at line 96 of file pcp.h.

Class Members
time_t end
time_t start
struct pcp_parse_datetime_info

Definition at line 339 of file pcp.h.

Class Members
const char * today_name
const char * tomorrow_name

Define Documentation

#define FMTTIME_DATE   1

Definition at line 328 of file pcp.h.

#define FMTTIME_TIME   2

Definition at line 329 of file pcp.h.

#define FMTTIME_TIMEDROP   4

Definition at line 330 of file pcp.h.

#define LIST_BOOKED   2

Definition at line 127 of file pcp.h.

#define LIST_CANCELLED   1

Definition at line 126 of file pcp.h.

#define LIST_PROXY   4

Definition at line 128 of file pcp.h.

#define pcp_acl (   s,
  w,
  f 
)    ((*(s)->acl_func)((s), (w), (f)))

Definition at line 241 of file pcp.h.

#define PCP_ACL_CONFLICT   2

Definition at line 246 of file pcp.h.

#define PCP_ACL_LIST   4

Definition at line 247 of file pcp.h.

#define PCP_ACL_MODIFY   1

Definition at line 245 of file pcp.h.

#define PCP_ACL_NONE   16

Definition at line 249 of file pcp.h.

#define PCP_ACL_RETR   8

Definition at line 248 of file pcp.h.

#define pcp_authtoken (   s)    ( (*(s)->authtoken_func)(s))

Definition at line 212 of file pcp.h.

#define pcp_book (   s,
  e,
  f 
)    ( (*(s)->book_func)((s),(e),(f)))

Definition at line 226 of file pcp.h.

#define PCP_BYPROXY
Value:
4             /*
                            ** This event is placed on the calendar by
                            ** proxy (basically, this event has the
                            ** LIST_PROXY bit set by pcp_retr.
                            */

Definition at line 57 of file pcp.h.

#define pcp_cancel (   s,
  n,
 
)    ( (*(s)->cancel_func)((s), (n), (e)))

Definition at line 233 of file pcp.h.

#define pcp_cleanup (   s)    ( (*(s)->cleanup_func)(s))

Definition at line 215 of file pcp.h.

#define pcp_close (   s)    ((*(s)->close_func)((s)))

Definition at line 238 of file pcp.h.

#define pcp_commit (   s,
  e,
  f 
)    ( (*(s)->commit_func)((s),(e),(f)))

Definition at line 225 of file pcp.h.

#define pcp_delete (   s,
 
)    ( (*(s)->delete_func)((s), (p)))

Definition at line 235 of file pcp.h.

#define pcp_destroy_eventid (   s,
 
)    ( (*(s)->destroy_new_eventid_func)((s),(e)))

Definition at line 221 of file pcp.h.

#define PCP_ERR_CONFLICT   2

Definition at line 68 of file pcp.h.

#define PCP_ERR_EVENTLOCKED   4

Definition at line 70 of file pcp.h.

#define PCP_ERR_EVENTNOTFOUND   3

Definition at line 69 of file pcp.h.

#define PCP_ERR_LOCK   1

Definition at line 67 of file pcp.h.

#define PCP_ERR_SYSERR   0 /* See errno */

Definition at line 66 of file pcp.h.

#define pcp_errmsg (   s)    ( (*(s)->errmsg_func)(s))

Definition at line 208 of file pcp.h.

#define PCP_ERRMSG (   s)    (s)

Definition at line 298 of file pcp.h.

#define pcp_has_acl (   s)    ((s)->acl_func != 0)

Definition at line 243 of file pcp.h.

#define pcp_list_acl (   s,
  f,
 
)    ((*(s)->listacl_func)((s), (f), (v)))

Definition at line 242 of file pcp.h.

#define pcp_list_all (   s,
  f 
)    ( (*(s)->list_all_func)((s),(f)))

Definition at line 229 of file pcp.h.

#define pcp_new_eventid (   s,
  e,
 
)    ( (*(s)->create_new_eventid_func)((s),(e),(a)))

Definition at line 218 of file pcp.h.

#define pcp_noop (   s)    ( (*(s)->noop_func)(s))

Definition at line 210 of file pcp.h.

#define PCP_OK_CONFLICT   1 /* Ok if time conflict with existing events */

Definition at line 54 of file pcp.h.

Value:
2      /*
                            ** Force through the commit even if there is
                            ** an error from the proxy server.
                            */

Definition at line 55 of file pcp.h.

#define PCP_RECURRING_ANNUALLY   2

Definition at line 370 of file pcp.h.

#define PCP_RECURRING_MONTHLY   1

Definition at line 369 of file pcp.h.

#define PCP_RECURRING_WEEKLY   0

Definition at line 368 of file pcp.h.

#define pcp_retr (   s,
  f 
)    ( (*(s)->retr_func)((s),(f)))

Definition at line 230 of file pcp.h.

#define PCP_STRERROR
Value:
const char *pcp_strerror(int i) { \
       PCP_STRERROR_N(PCP_ERR_LOCK, "Unable to lock the calendar.") \
       PCP_STRERROR_N(PCP_ERR_CONFLICT, "Event conflict.") \
       PCP_STRERROR_N(PCP_ERR_EVENTNOTFOUND, "Event not found.") \
       PCP_STRERROR_N(PCP_ERR_EVENTLOCKED, "Event locked.") \
return (0); }

Definition at line 303 of file pcp.h.

#define PCP_STRERROR_N (   n,
 
)    if (i == n) return (PCP_ERRMSG(s));

Definition at line 301 of file pcp.h.

#define pcp_uncancel (   s,
  n,
  f,
 
)    ( (*(s)->uncancel_func)((s), (n), (f), (e)))

Definition at line 234 of file pcp.h.


Function Documentation

void pcp_acl_name ( int  ,
char *   
)

Definition at line 12 of file pcpacl.c.

{
#define NAME(n,s) if (flags & (n)) {if (*buf) strcat(buf, " "); strcat(buf,s);}

       NAME(PCP_ACL_MODIFY, "MODIFY");
       NAME(PCP_ACL_CONFLICT, "CONFLICT");
       NAME(PCP_ACL_LIST, "LIST");
       NAME(PCP_ACL_RETR, "RETR");
       NAME(PCP_ACL_NONE, "NONE");
#undef NAME
}

Here is the caller graph for this function:

int pcp_acl_num ( const char *  )

Definition at line 24 of file pcpacl.c.

{
#define NAME(n,s) if (strcasecmp(c, s) == 0) return (n)

       NAME(PCP_ACL_MODIFY, "MODIFY");
       NAME(PCP_ACL_CONFLICT, "CONFLICT");
       NAME(PCP_ACL_LIST, "LIST");
       NAME(PCP_ACL_RETR, "RETR");
       NAME(PCP_ACL_NONE, "NONE");
#undef NAME
       return (0);
}

Here is the caller graph for this function:

struct PCP_event_time** pcp_add_sort_times ( const struct PCP_event_time ,
unsigned   
) [read]

Definition at line 30 of file pcpaddcommon.c.

{
       const struct PCP_event_time **ptr;
       unsigned i;

       if (n == 0)
       {
              errno=EINVAL;
              return (NULL);
       }

       ptr=malloc(n*sizeof(const struct PCP_event_time *));
       if (!ptr)
              return (NULL);

       for (i=0; i<n; i++)
              ptr[i]=t+i;

       if (n)
              qsort(ptr, n, sizeof(*ptr),
                    compar_times);

       for (i=0; i<n; i++)
       {
              if (ptr[i]->start > ptr[i]->end)
              {
                     free(ptr);
                     errno=EINVAL;
                     return (NULL);
              }

              if (i > 0 && ptr[i-1]->end > ptr[i]->start)
              {
                     free(ptr);
                     errno=EINVAL;
                     return (NULL);
              }
       }

       return (ptr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* pcp_am ( )

Definition at line 18 of file pcplocale.c.

{
       char *am_buf=0;
       time_t t;
       struct tm *tmptr;
       char tim_buf[40];
       int n;

       if (am_buf)
              return (am_buf);

       time(&t);
       tmptr=localtime(&t);
       tmptr->tm_hour=6;

       n=strftime(tim_buf, sizeof(tim_buf), "%p", tmptr);
       tim_buf[n]=0;
       am_buf=strdup(tim_buf);
       return (am_buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct PCP* pcp_find_proxy ( const char *  ,
const char *  ,
char **   
) [read]

Definition at line 866 of file pcpnet.c.

{
       struct PCPnet *pcp=mkpcp(username);

       if (errmsg)
              *errmsg=0;
       if (!pcp)
              return (NULL);

       if (strchr(username, '\r') || strchr(username, '\n'))
       {
              errno=EINVAL;
              pcp_close_net(pcp);
              return (NULL);
       }

       if ((pcp->fd=doconnect(pcp, CALENDARDIR "/private", username, NULL,
                            clustername,
                            errmsg)) < 0)
       {
              pcp_close_net(pcp);
              return (NULL);
       }
       return ((struct PCP *)pcp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pcp_fmttime ( char *  ,
size_t  ,
time_t  ,
int   
)

Definition at line 837 of file pcplocale.c.

{
       struct tm *tmptr=localtime(&t);
       char datebuf[100];
       char timebuf[100];
       char buf[201];

       char *p;

       if (!tmptr)
              return (-1);

       if (strftime(datebuf, sizeof(datebuf), "%x", tmptr) <= 0)
              datebuf[0]=0;

       if (strftime(timebuf, sizeof(timebuf), "%X", tmptr) <= 0)
              timebuf[0]=0;

       if (tmptr->tm_hour == 0 && tmptr->tm_min == 0 && tmptr->tm_sec == 0
           && (flags & FMTTIME_TIMEDROP))
              timebuf[0]=0;

       /* Try to drop minutes from timebuf */

       for (p=timebuf; *p; p++)
       {
              if (!isdigit((int)(unsigned char)*p) &&
                  p[1] == '0' && p[2] == '0')
              {
                     char *q;

                     for (q=p+3; *q; q++)
                            if (isdigit((int)(unsigned char)*q))
                                break;

                     if (!*q)
                     {
                            for (q=p+3; (*p=*q) != 0; p++, q++)
                                   ;
                            break;
                     }
              }
       }

       buf[0]=0;
       if (!flags || (flags & FMTTIME_DATE))
       {
              strcpy(buf, datebuf);
       }

       if (!flags || (flags & FMTTIME_TIME))
       {
              if (timebuf[0])
              {
                     if (buf[0])
                            strcat(buf, " ");
                     strcat(buf, timebuf);
              }
       }

       if (strlen(buf)+1 > cnt)
       {
              errno=ENOSPC;
              return (-1);
       }

       strcpy(ubuf, buf);
       return (0);
}

Here is the caller graph for this function:

int pcp_fmttimerange ( char *  ,
size_t  ,
time_t  ,
time_t   
)

Definition at line 907 of file pcplocale.c.

{
       char date1[100];
       char time1[100];
       char date2[100];
       char time2[100];
       char fmtbuf[500];

       if (pcp_fmttime(date1, sizeof(date1), from, FMTTIME_DATE) < 0)
              date1[0]=0;

       if (pcp_fmttime(time1, sizeof(time1), from,
                     FMTTIME_TIME | FMTTIME_TIMEDROP) < 0)
              time1[0]=0;

       if (pcp_fmttime(date2, sizeof(date2), to, FMTTIME_DATE) < 0)
              date2[0]=0;
       if (pcp_fmttime(time2, sizeof(time2), to,
                     FMTTIME_TIME | FMTTIME_TIMEDROP) < 0)
              time2[0]=0;

       if (time1[0] == 0 && time2[0] == 0)
       {
              sprintf(fmtbuf, strcmp(date1, date2)
                     ? "%s-%s":"%s", date1, date2);
       }
       else
       {
              if (!time1[0] && pcp_fmttime(time1, sizeof(time1), from,
                                        FMTTIME_TIME) < 0)
                     time1[0]=0;

              if (!time2[0] && pcp_fmttime(time2, sizeof(time2), to,
                                        FMTTIME_TIME) < 0)
                     time2[0]=0;

              if (strcmp(date1, date2) == 0)
                     sprintf(fmtbuf, "%s %s-%s", date1, time1, time2);
              else
                     sprintf(fmtbuf, "%s %s-%s %s", date1, time1,
                            date2, time2);
       }

       if (strlen(fmtbuf)+1 > cnt)
       {
              errno=ENOSPC;
              return (-1);
       }

       strcpy(ubuf, fmtbuf);
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

time_t pcp_gmtime ( int  y,
int  m,
int  d,
int  hh,
int  mm,
int  ss 
)

Definition at line 45 of file pcpgmtime.c.

{
       time_t t;
       struct tm *tmptr;
       struct tm mytm;
       int n;

       if (y < 1970 || y > 3000 || m < 1 || m > 12 || d < 1 ||
           d > mdays(m, y) || hh < 0 || mm < 0 || ss < 0 || hh > 23 ||
           mm > 59 || ss > 59)
              return (0);

       time(&t);

       tmptr=localtime(&t);
       if (!tmptr)
              return (0);

       mytm= *tmptr;
       mytm.tm_year = y - 1900;
       mytm.tm_mon = m - 1;
       mytm.tm_mday = d;
       mytm.tm_hour=0;
       mytm.tm_min=0;
       mytm.tm_sec=0;

       t=mktime(&mytm);
       if (t == (time_t)-1)
              return (0);

       /* Do it again, due to a potential timezone change */

       tmptr=localtime(&t);
       mytm= *tmptr;
       mytm.tm_year = y - 1900;
       mytm.tm_mon = m - 1;
       mytm.tm_mday = d;
       mytm.tm_hour=0;
       mytm.tm_min=0;
       mytm.tm_sec=0;

       t=mktime(&mytm);
       if (t == (time_t)-1)
              return (0);

       /* Sanity check */

       tmptr=localtime(&t);
       if (tmptr->tm_hour || tmptr->tm_min || tmptr->tm_sec)
       {
              return (0);
       }

       tmptr=gmtime(&t);

       n=tmcmp(tmptr->tm_year + 1900,
              tmptr->tm_mon + 1,
              tmptr->tm_mday,
              y, m, d);
       if (n < 0)
       {
              while (n < 0)
              {
                     t += 24 * 60 * 60;
                     tmptr=gmtime(&t);
                     n=tmcmp(tmptr->tm_year + 1900,
                            tmptr->tm_mon + 1,
                            tmptr->tm_mday,
                            y, m, d);
              }
       }
       else while (n > 0)
       {
              t -= 24 * 60 * 60;
              tmptr=gmtime(&t);
              n=tmcmp(tmptr->tm_year + 1900,
                     tmptr->tm_mon + 1,
                     tmptr->tm_mday,
                     y, m, d);
       }

       t -= tmptr->tm_hour * 60 * 60 + tmptr->tm_min * 60 + tmptr->tm_sec;

       return (t + hh * 60 * 60 + mm * 60 + ss);
}

Here is the call graph for this function:

Here is the caller graph for this function:

time_t pcp_gmtime_s ( const char *  p)

Definition at line 131 of file pcpgmtime.c.

{
       int y, m, d, hh, mm, ss;

       if (sscanf(p, "%4d%2d%2d%2d%2d%2d", &y, &m, &d, &hh, &mm, &ss)
           != 6)
              return (0);
       return (pcp_gmtime(y, m, d, hh, mm, ss));
}

Here is the call graph for this function:

Here is the caller graph for this function:

void pcp_gmtimestr ( time_t  t,
char *   
)

Definition at line 141 of file pcpgmtime.c.

{
       struct tm *tmptr=gmtime(&t);

       sprintf(buf, "%04d%02d%02d%02d%02d%02d",
              tmptr->tm_year + 1900,
              tmptr->tm_mon+1,
              tmptr->tm_mday,
              tmptr->tm_hour,
              tmptr->tm_min,
              tmptr->tm_sec);
}

Here is the caller graph for this function:

int pcp_mksocket ( const char *  ,
const char *   
)

Definition at line 39 of file pcpmksocket.c.

{
       int fd;
       const char *priority;
       DIR *dirp;
       struct dirent *de;
       char *p;
       struct  sockaddr_un skun;

       p=malloc(strlen(sockname)+sizeof("_PRIORITY"));
       if (!p)
       {
              perror("malloc");
              return (-1);
       }

       strcat(strcpy(p, sockname), "_PRIORITY");

       priority=getenv(p);
       free(p);
       if (!priority || !*priority)
              priority="50";

       /* Delete the previous socket */

       dirp=opendir(dir);
       while (dirp && (de=readdir(dirp)))
       {
              const char *n=de->d_name;

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

              if (strcmp(n, sockname))
                     continue;

              p=malloc(strlen(dir)+strlen(de->d_name)+2);
              if (!p)
              {
                     perror("malloc");
                     closedir(dirp);
                     return (-1);
              }
              strcat(strcat(strcpy(p, dir), "/"), de->d_name);
              unlink(p);
              free(p);
       }
       if (dirp)
              closedir(dirp);

       fd=socket(PF_UNIX, SOCK_STREAM, 0);

        if (fd < 0)
       {
              fprintf(stderr, "ALERT: socket failed: %s\n", strerror(errno));
              return (-1);
       }

        skun.sun_family=AF_UNIX;
        strcpy(skun.sun_path, dir);
        strcat(skun.sun_path, "/");
        strcat(skun.sun_path, priority);
        strcat(skun.sun_path, sockname);

        if (bind(fd, (const struct sockaddr *)&skun, sizeof(skun)) ||
           listen(fd, SOMAXCONN) ||
           chmod(skun.sun_path, 0777) ||
           fcntl(fd, F_SETFL, O_NONBLOCK) < 0)
        {
              fprintf(stderr, "ALERT: %s\n", skun.sun_path);
                close(fd);
                return (-1);
        }
        return (fd);
}

Here is the caller graph for this function:

int pcp_month ( const char *  )

Definition at line 158 of file pcplocale.c.

{
       int i;

       for (i=0; i<12; i++)
       {
              const char *q;

              if (strcasecmp(p, pcp_monthname(i)) == 0)
                     return (i);

              q=pcp_monthname_long(i);

              if (strncasecmp(p, q, strlen(q)) == 0)
                     return (i);
       }
       return (-1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* pcp_monthname ( unsigned  )

Definition at line 148 of file pcplocale.c.

{
       return (month_func(n, "%b"));
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* pcp_monthname_long ( unsigned  )

Definition at line 153 of file pcplocale.c.

{
       return (month_func(n, "%B"));
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct PCP* pcp_open_dir ( const char *  ,
const char *   
) [read]

Definition at line 112 of file pcpdir.c.

{
       struct PCPdir *pd=(struct PCPdir *)malloc(sizeof(struct PCPdir));

       if (!pd)
              return (NULL);

       memset(pd, 0, sizeof(*pd));

       pd->username=strdup(username);
       if (!pd->username)
       {
              free(pd);
              return (NULL);
       }

       pd->dirname=strdup(dirname);

       if (!pd->dirname)
       {
              free(pd);
              return (NULL);
       }

       pd->indexname=malloc(strlen(dirname)+sizeof("/index"));
       if (!pd->indexname)
       {
              free(pd->username);
              free(pd->dirname);
              free(pd);
              return (NULL);
       }
       strcat(strcpy(pd->indexname, dirname), "/index");

       pd->newindexname=malloc(strlen(dirname)+sizeof("/.index.tmp"));
       if (!pd->newindexname)
       {
              free(pd->username);
              free(pd->indexname);
              free(pd->dirname);
              free(pd);
              return (NULL);
       }
       strcat(strcpy(pd->newindexname, dirname), "/.index.tmp");

       pd->hostname_buf[sizeof(pd->hostname_buf)-1]=0;
       pd->hostname_buf[0]=0;
       if (gethostname(pd->hostname_buf, sizeof(pd->hostname_buf)-1) < 0
           || pd->hostname_buf[0] == 0)
              strcpy(pd->hostname_buf, "localhost");


       pd->pcp.authtoken_func=getauthtoken;
       pd->pcp.close_func= (void (*)(struct PCP *)) pcp_close_dir;
       pd->pcp.cleanup_func= (int (*)(struct PCP *)) cleanup;

       pd->pcp.create_new_eventid_func=
              (struct PCP_new_eventid *(*)(struct PCP *, const char *,
                                        struct PCP_save_event *))
              neweventid;

       pd->pcp.destroy_new_eventid_func=
              (void (*)(struct PCP *, struct PCP_new_eventid *))
              destroyeventid;

       pd->pcp.commit_func=
              (int (*)(struct PCP *, struct PCP_new_eventid *,
                      struct PCP_commit *))
              commitevent;

       pd->pcp.book_func=
              (int (*)(struct PCP *, struct PCP_new_eventid *,
                      struct PCP_commit *))
              bookevent;

       pd->pcp.list_all_func=
              (int (*)(struct PCP *, struct PCP_list_all *))
              listallevents;

       pd->pcp.cancel_func=
              (int (*)(struct PCP *, const char *, int *))
              cancelevent;

       pd->pcp.uncancel_func=
              (int (*)(struct PCP *, const char *, int,
                      struct PCP_uncancel *))
              uncancelevent;

       pd->pcp.delete_func=
              (int (*)(struct PCP *, struct PCP_delete *))
              deleteevent;

       pd->pcp.retr_func=
              (int (*)(struct PCP *, struct PCP_retr *))
              retrevent;

       pd->pcp.errmsg_func=errmsg;

       pd->pcp.noop_func=noop;

       pd->pcp.acl_func=
              (int (*)(struct PCP *, const char *, int))setacl;
       pd->pcp.listacl_func=
              (int (*)(struct PCP *, int (*)(const char *, int, void *),
                      void *))listacl;

       return ((struct PCP *)pd);
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct PCP* pcp_open_server ( const char *  ,
const char *  ,
char **   
) [read]

Definition at line 742 of file pcpnet.c.

{
       struct PCPnet *pcp=mkpcp(username);

       if (errmsg)
              *errmsg=0;
       if (!pcp)
              return (NULL);

       if (strchr(username, '\r') || strchr(username, '\n'))
       {
              errno=EINVAL;
              pcp_close_net(pcp);
              return (NULL);
       }

       if (strchr(password, '\r') || strchr(password, '\n'))
       {
              errno=EINVAL;
              pcp_close_net(pcp);
              return (NULL);
       }


       if ((pcp->fd=doconnect(pcp, CALENDARDIR "/public", username, NULL,
                            NULL, errmsg)) < 0)
       {
              pcp_close_net(pcp);
              return (NULL);
       }

       if (pcp->authtoken == NULL)
       {
              char *buf;
              int rc;

              if (strchr(password, '\n') || strchr(password, '\r'))
              {
                     errno=EINVAL;
                     pcp_close_net(pcp);
                     return (NULL);
              }

              buf=malloc(strlen(password)+sizeof("PASSWORD \n"));
              if (buf == 0)
              {
                     pcp_close_net(pcp);
                     return (NULL);
              }

              strcat(strcat(strcpy(buf, "PASSWORD "), password), "\n");

              if (docmd(pcp, buf, 0))
              {
                     free(buf);
                     pcp_close_net(pcp);
                     return (NULL);
              }
              free(buf);

              switch ((rc=checkstatus(pcp, NULL)) / 100) {
              case 1:
              case 2:
              case 3:
                     break;
              default:
                     if (errmsg)
                     {
                            if (*errmsg)
                                   free(*errmsg);
                            *errmsg=strdup(pcp->readbuf);
                     }
                     pcp_close_net(pcp);
                     errno=EPERM;
                     return (NULL);
              }

              if (rc == 102)
              {
                     if (parseauthtoken(pcp))
                     {
                            pcp_close_net(pcp);
                            return (NULL);
                     }
              }
       }

       return (setcapabilities(pcp, 1));
}

Here is the call graph for this function:

Here is the caller graph for this function:

time_t pcp_parse_datetime ( int *  argn,
int  argc,
char **  argv,
struct pcp_parse_datetime_info info 
)

Definition at line 254 of file pcplocale.c.

{
       int mon=-1, day=-1, year=0;
       int hour=0, min=0, sec=-1;
       time_t t;
       struct tm *tmptr, tmsave;
       const char *today="today";
       const char *tomorrow="tomorrow";
       int nn;
       int i;

       time(&t);

       if (info && info->today_name)
              today=info->today_name;

       if (info && info->tomorrow_name)
              tomorrow=info->tomorrow_name;

       while (year == 0 || sec < 0 || day < 0)
       {
              const char *p;
              const char *q;

              if (*argn >= argc)
                     break;

              p=argv[*argn];

              if (strcasecmp(p, today) == 0)
              {
                     if (year || day >= 0)
                            return (0);   /* Already specified */

                     tmptr=localtime(&t);

                     mon=tmptr->tm_mon+1;
                     day=tmptr->tm_mday;
                     year=tmptr->tm_year + 1900;
                     ++ *argn;
                     continue;
              }

              if (strcasecmp(p, tomorrow) == 0)
              {
                     time_t t2;

                     if (year || day >= 0)
                            return (0);   /* Already specified */

                     tmptr=localtime(&t);

                     tmptr->tm_hour=12;
                     tmptr->tm_min=0;
                     tmptr->tm_sec=0;

                     t2=mktime(tmptr);
                     if (t2 == (time_t)-1)
                            return (0);

                     t2 += 24 * 60 * 60;

                     tmptr=localtime(&t2);

                     mon=tmptr->tm_mon+1;
                     day=tmptr->tm_mday;
                     year=tmptr->tm_year + 1900;
                     ++ *argn;
                     continue;
              }

              if ((i=pcp_wday(p)) >= 0)
              {
                     time_t t2;

                     if (year || day >= 0)
                            return (0);   /* Already specified */

                     t2=t;

                     do
                     {
                            tmptr=localtime(&t2);

                            tmptr->tm_hour=12;
                            tmptr->tm_min=0;
                            tmptr->tm_sec=0;

                            t2=mktime(tmptr);
                            if (t2 == (time_t)-1)
                                   return (0);

                            t2 += 24 * 60 * 60;

                            tmptr=localtime(&t2);
                     } while (tmptr->tm_wday != i);

                     mon=tmptr->tm_mon+1;
                     day=tmptr->tm_mday;
                     year=tmptr->tm_year + 1900;
                     ++ *argn;
                     continue;
              }

              if ((i=pcp_month(p)) >= 0)
              {
                     if (mon >= 0)
                            return (0);
                     mon=i+1;

                     if (++*argn >= argc)
                            return (0);
                     day=atoi(argv[*argn]);
                     if (day <= 0)
                            return (0);
                     ++*argn;
                     continue;
              }

              if (strchr(p, '/'))
              {
                     if (mon > 0 || day > 0 || year > 0)
                            return (0);

                     if (scan_mdy(sscanf(p, "%d/%d/%d", &mon, &day, &year),
                                 &mon, &day, &year))
                            return (0);
                     ++*argn;
                     continue;
              }

              if (strchr(p, '.'))
              {
                     if (mon > 0 || day > 0 || year > 0)
                            return (0);

                     if (scan_mdy(sscanf(p, "%d.%d.%d", &year, &mon, &day),
                                 &mon, &day, &year))
                            return (0);
                     ++*argn;
                     continue;
              }

              if (is_digit(p) && year == 0 &&
                  mon > 0 && day > 0 && sec < 0)
              {
                     year=atoi(p);
                     year=fix_year(year);
                     ++*argn;
                     continue;
              }

              nn=atoi(p);

              if (is_digit(p))
              {
                     ++*argn;

                     if (*argn >= argc)
                            return (0);

                     p=argv[*argn];

                     for (i=0; i<12; i++)
                            if (strcasecmp(p, pcp_monthname(i)) == 0 ||
                                strcasecmp(p, pcp_monthname_long(i)) == 0)
                                   break;

                     if (i < 12)
                     {
                            if (nn == 0)
                                   return (0);

                            if (mon >= 0)
                                   return (0);
                            mon=i+1;
                            day=nn;
                            ++*argn;
                            continue;
                     }

                     if (strcasecmp(p, pcp_am()) == 0)
                     {
                            if (hour >= 0)
                                   return (0);
                            hour=nn;
                            min=0;
                            sec=0;
                            ++*argn;
                            if (hour == 12)
                                   hour=0;

                            continue;
                     }

                     if (strcasecmp(p, pcp_pm()) == 0)
                     {
                            if (hour >= 0)
                                   return (0);
                            hour=nn+12;
                            min=0;
                            sec=0;
                            ++*argn;
                            if (hour == 24)
                                   hour=12;
                            continue;
                     }

                     if (hour >= 0)
                            return (0);
                     hour=nn;
                     min=0;
                     sec=0;
                     continue;
              }

              if (!isdigit((int)(unsigned char)*p))
                     break;

              if (mon > 0 && day > 0 && year == 0)
              {
                     year=get_year(mon, day);
              }


              switch (sscanf(p, "%d:%d:%d", &hour, &min, &sec)) {
              case 0:
                     return (0);
              case 1:
                     if (sec >= 0)
                            return (0);

                     min=sec=0;
                     break;
              case 2:
                     if (sec >= 0)
                            return (0);

                     sec=0;
                     break;
              default:
                     if (sec >= 0)
                            return (0);
                     break;
              }

              for (q=p; *q; q++)
              {
                     if (!isdigit((int)(unsigned char)*q) && *q != ':')
                            break;
              }

              ++*argn;

              if (*q == 0)
              {
                     q= *argn < argc ? argv[*argn]:"";
                     if (strcasecmp(p, pcp_am()) == 0)
                     {
                            if (hour == 12)
                                   hour=0;
                            ++*argn;
                            continue;
                     }
                     if (strcasecmp(p, pcp_pm()) == 0)
                     {
                            hour += 12;
                            if (hour == 24)
                                   hour=12;
                            ++*argn;
                            continue;
                     }
                     continue;
              }

              if (strcasecmp(q, pcp_am()) == 0)
              {
                     if (hour == 12)
                            hour=0;
                     continue;
              }
              if (strcasecmp(q, pcp_pm()) == 0)
              {
                     hour += 12;
                     if (hour == 24)
                            hour=12;
                     continue;
              }
              return (0);
       }

       if (sec < 0)
       {
              hour=min=sec=0;
       }

       if (day <= 0 && mon < 0 && year <= 0)
       {
              tmptr=localtime(&t);

              mon=tmptr->tm_mon+1;
              day=tmptr->tm_mday;
              year=tmptr->tm_year + 1900;
       }
       if (day < 0)
              return (0);

       tmptr=localtime(&t);
       tmptr->tm_mon=mon-1;
       tmptr->tm_mday=day;
       tmptr->tm_year=year - 1900;
       tmptr->tm_hour=hour;
       tmptr->tm_min=min;
       tmptr->tm_sec=sec;

       tmsave= *tmptr;

       t=mktime(tmptr);
       if (t == (time_t)-1)
              return (0);

       /* Could be different due to altzone change, so we do it again */

       tmptr=localtime(&t);
       tmptr->tm_mon=tmsave.tm_mon;
       tmptr->tm_mday=tmsave.tm_mday;
       tmptr->tm_year=tmsave.tm_year;
       tmptr->tm_hour=tmsave.tm_hour;
       tmptr->tm_min=tmsave.tm_min;
       tmptr->tm_sec=tmsave.tm_sec;
       t=mktime(tmptr);
       if (t == (time_t)-1)
              return (0);
       return (t);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pcp_parse_datetime_until ( time_t  start,
time_t  end,
int *  argn,
int  argc,
char **  argv,
int  recurring_time,
int(*)(time_t, time_t, void *)  save_date_time,
void *  voidfunc 
)

Definition at line 714 of file pcplocale.c.

{
       int month=0, day=0, year=0;
       const char *p;
       struct tm *tmptr;

       time_t new_start, new_end;
       unsigned cnt;

       while (month == 0 || day == 0)
       {
              if (*argn >= argc)
                     return (-1);

              p=argv[ (*argn)++ ];

              if (month == 0 && day == 0 && year == 0)
              {
                     if (strchr(p, '/'))
                     {
                            if (scan_mdy(sscanf(p, "%d/%d/%d",
                                              &month, &day, &year),
                                        &month, &day, &year))
                                   return (-1);
                            continue;
                     }

                     if (strchr(p, '.'))
                     {
                            if (scan_mdy(sscanf(p, "%d.%d.%d",
                                              &year, &month, &day),
                                        &month, &day, &year))
                                   return (-1);
                            continue;
                     }
              }

              if (is_digit(p))
              {
                     if (day > 0)
                            return (-1);
                     day=atoi(p);
                     if (day <= 0)
                            return (-1);
                     continue;
              }

              if (month > 0)
                     return (-1);

              month=pcp_month(p);

              if (month < 0)
                     return (-1);
              ++month;
       }

       if ( year == 0 && *argn < argc && is_digit(argv[*argn]))
       {
              year=atoi(argv[*argn++]);

              year=fix_year(year);
       }
       else
       {
              if (year == 0)
                     year=get_year(month, day);
       }

       for (cnt=0; cnt < 100; cnt++)
       {
              int y, m;

              switch (recurring_type) {
              case PCP_RECURRING_MONTHLY:
                     new_start=add_month(start, cnt);
                     new_end=add_month(end, cnt);
                     break;
              case PCP_RECURRING_ANNUALLY:
                     new_start=add_month(start, cnt*12);
                     new_end=add_month(end, cnt*12);
                     break;
              default:
                     new_start=add_week(start, cnt);
                     new_end=add_week(end, cnt);
              }

              if (!new_start || !new_end)
                     continue;

              tmptr=localtime(&new_start);

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

              if (y > year)
                     break;
              if (y == year)
              {
                     if (m > month)
                            break;
                     if (m == month)
                     {
                            if (tmptr->tm_mday > day)
                                   break;
                     }
              }

              y= (*save_date_time)(new_start, new_end, voidfunc);
              if (y)
                     return (y);
       }
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pcp_parse_ymd ( unsigned  ,
unsigned  ,
unsigned  ,
time_t *  ,
time_t *   
)

Definition at line 61 of file pcpparseymd.c.

{
       time_t tt;
       struct tm *tmptr;

       time(&tt);

       tmptr=localtime(&tt);

       if (!tmptr)
              return (-1);

       if ((tt=sod(tmptr, y, m, d)) == 0)
              return (-1);

       *s=tt;

       tt += 36 * 60 * 60;

       tmptr=localtime(&tt);

       if (!tmptr)
              return (-1);

       if ((tt=sod(tmptr, tmptr->tm_year + 1900, tmptr->tm_mon+1,
                  tmptr->tm_mday)) == 0)
              return (-1);

       *e=tt;
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* pcp_pm ( )

Definition at line 39 of file pcplocale.c.

{
       char *am_buf=0;
       time_t t;
       struct tm *tmptr;
       char tim_buf[40];
       int n;

       if (am_buf)
              return (am_buf);

       time(&t);
       tmptr=localtime(&t);
       tmptr->tm_hour=18;

       n=strftime(tim_buf, sizeof(tim_buf), "%p", tmptr);
       tim_buf[n]=0;
       am_buf=strdup(tim_buf);
       return (am_buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pcp_read_saveevent ( struct PCP_save_event ,
char *  ,
int   
)

Definition at line 73 of file pcpaddcommon.c.

{
       int n;

       if (ae->write_event_func)
              return ( ((*ae->write_event_func)
                       (buf, bufsize, ae->write_event_func_misc_ptr)));

       if (!ae->write_event_buf && ae->write_event_fd >= 0)
              return ( read(ae->write_event_fd, buf, bufsize));

       if (ae->write_event_buf == 0)
       {
              errno=EIO;
              return (-1);
       }

       for (n=0; n<bufsize && *ae->write_event_buf; n++)
              buf[n]= *ae->write_event_buf++;

       return (n);
}

Here is the caller graph for this function:

struct PCP* pcp_reopen_server ( const char *  ,
const char *  ,
char **   
) [read]

Definition at line 936 of file pcpnet.c.

{
       struct PCPnet *pcp=mkpcp(username);
       char *authtoken_cpy;
       char *p, *q;

       if (!pcp)
              return (NULL);

       /* auth token is: sockname/token */

       if ((authtoken_cpy=strdup(authtoken)) == NULL)
       {
              pcp_close_net(pcp);
              return (NULL);
       }

       if ((p=strchr(authtoken_cpy, '/')) == NULL)
       {
              errno=EINVAL;
              free(authtoken_cpy);
              pcp_close_net(pcp);
              return (NULL);
       }

       *p++=0;

       for (q=p; *q; ++q)
              if (isspace((int)(unsigned char)*q))
              {
                     errno=EINVAL;
                     free(authtoken_cpy);
                     pcp_close_net(pcp);
                     return (NULL);
              }

       if ((pcp->fd=doconnect(pcp, CALENDARDIR "/public", username,
                            authtoken_cpy, NULL, errmsg)) < 0)
       {
              free(authtoken_cpy);
              pcp_close_net(pcp);
              return (NULL);
       }

       if (pcp->authtoken == NULL)
       {
              char *buf;
              int rc;

              buf=malloc(strlen(p)+sizeof("RELOGIN \n"));
              if (buf == 0)
              {
                     free(authtoken_cpy);
                     pcp_close_net(pcp);
                     return (NULL);
              }

              strcat(strcat(strcpy(buf, "RELOGIN "), p), "\n");
              free(authtoken_cpy);

              if (docmd(pcp, buf, 0))
              {
                     free(buf);
                     pcp_close_net(pcp);
                     return (NULL);
              }
              free(buf);

              switch ((rc=checkstatus(pcp, NULL)) / 100) {
              case 1:
              case 2:
              case 3:
                     break;
              default:
                     errno=EIO;
                     if (errmsg)
                     {
                            if (*errmsg)
                                   free(*errmsg);
                            *errmsg=strdup(pcp->readbuf);
                     }
                     pcp_close_net(pcp);
                     return (NULL);
              }
              if (rc == 102)
              {
                     if (parseauthtoken(pcp))
                     {
                            pcp_close_net(pcp);
                            return (NULL);
                     }
              }
              else   /* Keeping the same token */
                     if ((pcp->authtoken=strdup(authtoken)) == NULL)
              {
                     pcp_close_net(pcp);
                     return (NULL);
              }
       }
       else
              free(authtoken_cpy);

       return (setcapabilities(pcp, 1));
}

Here is the call graph for this function:

Here is the caller graph for this function:

int pcp_set_proxy ( struct PCP ,
const char *   
)

Definition at line 894 of file pcpnet.c.

{
       struct PCPnet *pcp=(struct PCPnet *)pcp_ptr;
       int rc;
       char *p;

       pcp->haserrmsg=0;

       if (strchr(proxy, '\r') || strchr(proxy, '\n'))
       {
              errno=EINVAL;
              return (-1);
       }

       p=malloc(strlen(proxy)+sizeof("PROXY \n"));

       if (!p)
              return (-1);

       strcat(strcat(strcpy(p, "PROXY "), proxy), "\n");

       if (docmd(pcp, p, 0))
       {
              free(p);
              return (-1);
       }

       free(p);
       switch ((rc=checkstatus(pcp, NULL)) / 100) {
       case 1:
       case 2:
       case 3:
              break;
       default:
              return (-1);
       }

       if (setcapabilities(pcp, 0) == NULL)
              return (-1);
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* pcp_strerror ( int  )

Here is the caller graph for this function:

int pcp_wday ( const char *  )

Definition at line 105 of file pcplocale.c.

{
       int i;

       for (i=0; i<7; i++)
       {
              const char *q;

              if (strcasecmp(p, pcp_wdayname(i)) == 0)
                     return (i);

              q=pcp_wdayname_long(i);

              if (strncasecmp(p, q, strlen(q)) == 0)
                     return (i);
       }
       return (-1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* pcp_wdayname ( unsigned  )

Definition at line 95 of file pcplocale.c.

{
       return (wday_func(n, "%a"));
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* pcp_wdayname_long ( unsigned  )

Definition at line 100 of file pcplocale.c.

{
       return (wday_func(n, "%A"));
}

Here is the call graph for this function:

Here is the caller graph for this function:

const char* pcpgid ( )

Definition at line 16 of file uids.c.

{
       return gid;
}
const char* pcpuid ( )

Definition at line 11 of file uids.c.

{
       return uid;
}

Here is the call graph for this function: