Back to index

courier  0.68.2
Functions
autoresponse.h File Reference
#include "config.h"
#include <stdio.h>
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

char ** maildir_autoresponse_list (const char *)
void maildir_autoresponse_list_free (char **)
int maildir_autoresponse_validate (const char *, const char *)
void maildir_autoresponse_delete (const char *, const char *)
FILE * maildir_autoresponse_create (const char *, const char *)
int maildir_autoresponse_create_finish (const char *, const char *, FILE *)
FILE * maildir_autoresponse_open (const char *, const char *)

Function Documentation

FILE* maildir_autoresponse_create ( const char *  ,
const char *   
)

Definition at line 366 of file autoresponse.c.

{
       char *p=afilename(maildir, filename);
       FILE *fp;
       char *q;

       if (!p)
              return (NULL);

       strcat(p, ".tmp");
       fp=fopen(p, "w");

       if (!fp)      /* Perhaps we need to create the autoresponse dir? */
       {
              q=strrchr(p, '/');
              *q=0;
              mkdir(p, 0700);
              *q='/';
              fp=fopen(p, "w");
       }
       free(p);
       return (fp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int maildir_autoresponse_create_finish ( const char *  ,
const char *  ,
FILE *   
)

Definition at line 390 of file autoresponse.c.

{
       char *p, *q;
       struct maildir_autoresponse_quota set_quota, new_quota;

       fclose(fp);
       p=afilename(maildir, filename);

       if (!p)
              return (0);
       q=strdup(p);

       if (q)
       {
              if (get_quota(&set_quota, maildir)
                  || calc_quota(&new_quota, maildir))
              {
                     strcat(p, ".tmp");
                     unlink(p);
                     free(q);
                     free(p);
                     return (-1);
              }

              add_quota(&new_quota, p, -1);
              strcat(p, ".tmp");
              add_quota(&new_quota, p, 1);
              if (check_quota(&set_quota, &new_quota))
              {
                     unlink(p);
                     free(p);
                     free(q);
                     errno=ENOSPC;
                     return (-1);
              }

              rename(p, q);
              free(q);
       }
       free(p);
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void maildir_autoresponse_delete ( const char *  ,
const char *   
)

Definition at line 224 of file autoresponse.c.

{
       char *p=afilename(maildir, filename);

       char *q;

       if (!p)
              return;

       q=strrchr(p, '/');
       *q++=0;

       deletefiles(p, q, 1);
       free(p);
}

Here is the call graph for this function:

Here is the caller graph for this function:

char** maildir_autoresponse_list ( const char *  )

Definition at line 48 of file autoresponse.c.

{
       char *d, **a;
       struct temp_autoresponse_list *list=NULL;
       unsigned list_cnt;
       struct temp_autoresponse_list *p;

       DIR *dirp;

       if (!maildir)
              maildir=".";

       d=malloc(strlen(maildir)+sizeof("/autoresponses"));

       if (!d)
              return (NULL);

       strcat(strcpy(d, maildir), "/autoresponses");

       dirp=opendir(d);
       free(d);

       list_cnt=0;

       if (dirp)
       {
              struct dirent *de;

              while ((de=readdir(dirp)) != NULL)
              {
                     if (strchr(de->d_name, '.'))
                            continue;

                     p=(struct temp_autoresponse_list *)
                            malloc(sizeof(struct temp_autoresponse_list));
                     if (p)
                     {
                            if ((p->filename=strdup(de->d_name)) == NULL)
                            {
                                   free(p);
                                   p=NULL;
                            }
                     }

                     if (!p)
                     {
                            closedir(dirp);

                            while (list)
                            {
                                   p=list;
                                   list=p->next;
                                   free(p->filename);
                                   free(p);
                            }
                            return (NULL);
                     }
                     p->next=list;
                     list=p;
                     ++list_cnt;
              }
              closedir(dirp);
       }

       a=malloc( (list_cnt+1)*sizeof(char *));

       if (!a)
       {
              while (list)
              {
                     p=list;
                     list=p->next;
                     free(p->filename);
                     free(p);
              }
              return (NULL);
       }

       list_cnt=0;

       while (list)
       {
              p=list;
              list=p->next;
              a[list_cnt]=p->filename;
              free(p);
              ++list_cnt;
       }
       a[list_cnt]=0;
       return (a);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void maildir_autoresponse_list_free ( char **  )

Definition at line 140 of file autoresponse.c.

{
       unsigned i;

       for (i=0; a[i]; i++)
              free(a[i]);
       free(a);
}

Here is the caller graph for this function:

FILE* maildir_autoresponse_open ( const char *  ,
const char *   
)

Definition at line 434 of file autoresponse.c.

{
       char *p=afilename(maildir, filename);
       FILE *fp;

       if (!p)
              return (NULL);

       fp=fopen(p, "r");
       free(p);
       return (fp);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int maildir_autoresponse_validate ( const char *  ,
const char *   
)

Definition at line 177 of file autoresponse.c.

{
       char *p=afilename(maildir, filename);

       if (!p)
              return (-1);
       free(p);
       return (0);
}

Here is the call graph for this function:

Here is the caller graph for this function: