Back to index

courier  0.68.2
Classes | Functions
imapscanclient.h File Reference
#include "config.h"
#include "maildir/maildirkeywords.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  imapscanmessageinfo
struct  imapscaninfo
struct  uidplus_info

Functions

void imapscan_init (struct imapscaninfo *p)
void imapscan_copy (struct imapscaninfo *a, struct imapscaninfo *b)
int imapscan_maildir (struct imapscaninfo *, const char *, int, int, struct uidplus_info *)
void imapscan_free (struct imapscaninfo *)
int imapscan_openfile (const char *, struct imapscaninfo *, unsigned)
struct libmail_kwMessageimapscan_createKeyword (struct imapscaninfo *, unsigned long n)
int imapscan_updateKeywords (const char *filename, struct libmail_kwMessage *newKeywords)
int imapscan_restoreKeywordSnapshot (FILE *, struct imapscaninfo *)
int imapscan_saveKeywordSnapshot (FILE *fp, struct imapscaninfo *)
int imapmaildirlock (struct imapscaninfo *scaninfo, const char *maildir, int(*func)(void *), void *void_arg)
char * readline (unsigned, FILE *)

Class Documentation

struct imapscanmessageinfo

Definition at line 16 of file imapscanclient.h.

Collaboration diagram for imapscanmessageinfo:
Class Members
char changedflags
char copiedflag
char * filename
struct imapscanmessageinfo * firstBucket
struct libmail_kwMessage * keywordMsg
struct imapscanmessageinfo * nextBucket
char recentflag
char storeflag
unsigned long uid
struct imapscaninfo

Definition at line 36 of file imapscanclient.h.

Collaboration diagram for imapscaninfo:
Class Members
struct libmail_kwHashtable * keywordList
unsigned long left_unseen
struct imapscanmessageinfo * msgs
unsigned long nextuid
unsigned long nmessages
unsigned long uidv
struct maildirwatch * watcher
struct uidplus_info

Definition at line 52 of file imapscanclient.h.

Collaboration diagram for uidplus_info:
Class Members
char * curfilename
time_t mtime
char * newkeywords
struct uidplus_info * next
unsigned long old_uid
char * tmpfilename
char * tmpkeywords
unsigned long uid

Function Documentation

int imapmaildirlock ( struct imapscaninfo scaninfo,
const char *  maildir,
int(*)(void *)  func,
void *  void_arg 
)

Definition at line 136 of file imapscanclient.c.

{
       char *newname;
       int tryAnyway;
       int rc;

       if (!uselocks())
              return (*func)(void_arg);

       if (scaninfo->watcher == NULL &&
           (scaninfo->watcher=maildirwatch_alloc(maildir)) == NULL)
              imapscanfail("maildirwatch");

       if ((newname=maildir_lock(maildir, scaninfo->watcher, &tryAnyway))
           == NULL)
       {
              if (!tryAnyway)
                     return -1;

              imapscanfail("maildir_lock");
       }

       rc=(*func)(void_arg);

       if (newname)
       {
              unlink(newname);
              free(newname);
              newname=NULL;
       }
       return rc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void imapscan_copy ( struct imapscaninfo a,
struct imapscaninfo b 
)

Definition at line 98 of file imapscanclient.c.

{
       imapscan_free(a);
       *a=*b;
       imapscan_init(b);
}

Here is the call graph for this function:

Here is the caller graph for this function:

struct libmail_kwMessage* imapscan_createKeyword ( struct imapscaninfo ,
unsigned long  n 
) [read]

Definition at line 106 of file imapscanclient.c.

{
       if (n >= a->nmessages)
              return NULL;

       if (a->msgs[n].keywordMsg == NULL)
       {
              struct libmail_kwMessage *m=libmail_kwmCreate();

              if (!m)
                     write_error_exit(0);

              m->u.userNum=n;
              a->msgs[n].keywordMsg=m;
       }

       return a->msgs[n].keywordMsg;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void imapscan_free ( struct imapscaninfo )

Definition at line 933 of file imapscanclient.c.

{
       unsigned      n;

       if (i->watcher)
       {
              maildirwatch_free(i->watcher);
              i->watcher=NULL;
       }

       if (i->msgs)
       {
              for (n=0; n<i->nmessages; n++)
              {
                     if (i->msgs[n].filename)
                            free(i->msgs[n].filename);

                     if (i->msgs[n].keywordMsg)
                            libmail_kwmDestroy(i->msgs[n].keywordMsg);

              }
              free(i->msgs);
              i->msgs=0;
       }

       if (i->keywordList)
       {
              if (libmail_kwhCheck(i->keywordList) < 0)
                     write_error_exit("INTERNAL ERROR: Keyword hashtable "
                                    "memory corruption.");

              free(i->keywordList);
              i->keywordList=NULL;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void imapscan_init ( struct imapscaninfo p)

Definition at line 88 of file imapscanclient.c.

{
       memset(i, 0, sizeof(*i));

       if ((i->keywordList=malloc(sizeof(*i->keywordList))) == NULL)
              write_error_exit(0);

       libmail_kwhInit(i->keywordList);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int imapscan_maildir ( struct imapscaninfo ,
const char *  ,
int  ,
int  ,
struct uidplus_info  
)

Definition at line 184 of file imapscanclient.c.

{
       struct imapscan_info ii;

       ii.scaninfo=scaninfo;
       ii.dir=dir;
       ii.leavenew=leavenew;
       ii.ro=ro;
       ii.uidplus=uidplus;

       return imapmaildirlock(scaninfo, dir, imapscan_maildir_cb, &ii);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int imapscan_openfile ( const char *  ,
struct imapscaninfo ,
unsigned   
)

Definition at line 918 of file imapscanclient.c.

{
struct imapscanmessageinfo *n;

       if (j >= i->nmessages)
       {
              errno=EINVAL;
              return (-1);
       }

       n=i->msgs+j;

       return (try_maildir_open(dir, n));
}

Here is the call graph for this function:

Here is the caller graph for this function:

int imapscan_restoreKeywordSnapshot ( FILE *  ,
struct imapscaninfo  
)

Definition at line 1183 of file imapscanclient.c.

{
       struct imapscanReadKeywordInfo rki;

       initri(&rki);

       rki.messages=scaninfo;
       return maildir_kwImport(fp, &rki.ri);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int imapscan_saveKeywordSnapshot ( FILE *  fp,
struct imapscaninfo  
)

Definition at line 1193 of file imapscanclient.c.

{
       struct imapscanReadKeywordInfo rki;

       initri(&rki);

       rki.messages=scaninfo;
       return maildir_kwExport(fp, &rki.ri);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int imapscan_updateKeywords ( const char *  filename,
struct libmail_kwMessage newKeywords 
)

Definition at line 975 of file imapscanclient.c.

{
       char *tmpname, *newname;
       int rc;

       if (maildir_kwSave(current_mailbox, filename, newKeyword,
                        &tmpname, &newname, 0))
       {
              perror("maildir_kwSave");
              return -1;
       }

       rc=rename(tmpname, newname);

       if (rc)
       {
              perror(tmpname);
              unlink(tmpname);
       }
       free(tmpname);
       free(newname);
       return rc;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* readline ( unsigned  ,
FILE *   
)

Definition at line 325 of file imapscanclient.c.

{
int    c;

       for (;;)
       {
              if (i >= 10000)
                     --i;   /* DOS check */

              if (i >= readbufsize)
              {
              char   *p= readbuf ? realloc(readbuf, readbufsize+256):
                                   malloc(readbufsize+256);

                     if (!p)       write_error_exit(0);
                     readbuf=p;
                     readbufsize += 256;
              }

              c=getc(fp);
              if (c == EOF || c == '\n')
              {
                     readbuf[i]=0;
                     return (c == EOF ? 0:readbuf);
              }
              readbuf[i++]=c;
       }
}