Back to index

courier  0.68.2
Defines | Functions
maildirlist.c File Reference
#include <sys/types.h>
#include <sys/stat.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include "maildirmisc.h"

Go to the source code of this file.

Defines

#define dirent   direct
#define NAMLEN(dirent)   (dirent)->d_namlen

Functions

void maildir_list (const char *maildir, void(*func)(const char *, void *), void *voidp)

Define Documentation

#define dirent   direct

Definition at line 15 of file maildirlist.c.

#define NAMLEN (   dirent)    (dirent)->d_namlen

Definition at line 16 of file maildirlist.c.


Function Documentation

void maildir_list ( const char *  maildir,
void(*)(const char *, void *)  func,
void *  voidp 
)

Definition at line 42 of file maildirlist.c.

{
       DIR *dirp=opendir(maildir);
       struct dirent *de;

       while (dirp && (de=readdir(dirp)) != NULL)
       {
              char *p;

              if (strcmp(de->d_name, "..") == 0)
                     continue;

              if (de->d_name[0] != '.')
                     continue;

              if ((p=malloc(strlen(maildir) + strlen(de->d_name)+20))
                  == NULL)
                     continue;

              strcat(strcat(strcat(strcpy(p, maildir), "/"), de->d_name),
                     "/cur/.");

              if (access(p, X_OK))
              {
                     free(p);
                     continue;
              }

              strcpy(p, INBOX);

              if (strcmp(de->d_name, "."))
                     strcat(p, de->d_name);

              (*func)(p, voidp);
              free(p);
       }
       if (dirp)
              closedir(dirp);
}

Here is the caller graph for this function: