Back to index

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

Go to the source code of this file.

Classes

struct  sort_file_list

Functions

struct sort_file_listread_dir_sort_filenames (const char *, const char *)
void rmdir_contents (const char *)

Class Documentation

struct sort_file_list

Definition at line 11 of file faxconvert.h.

Collaboration diagram for sort_file_list:
Class Members
char * filename
struct sort_file_list * next

Function Documentation

struct sort_file_list* read_dir_sort_filenames ( const char *  ,
const char *   
) [read]

Definition at line 412 of file faxconvert.c.

{
       struct sort_file_list *l=NULL, **ll, *lll;
       unsigned cnt=0, i;
       DIR *dirp;

       if ((dirp=opendir(dirname)) != NULL)
       {
              struct dirent *de;

              while ((de=readdir(dirp)) != NULL)
              {
                     if (de->d_name[0] == '.')
                            continue;

                     lll=(struct sort_file_list *)
                            courier_malloc(sizeof(struct sort_file_list)
                                          + 1 + strlen(fnpfix)
                                          + strlen(de->d_name));

                     strcat(strcpy(lll->filename=(char *)(lll+1),
                                  fnpfix), de->d_name);
                     lll->next=l;
                     l=lll;
                     ++cnt;
              }
              closedir(dirp);
       }
       if (!cnt)
              return (NULL);

       ll=(struct sort_file_list **)courier_malloc(sizeof(l) * cnt);
       cnt=0;
       for (lll=l; lll; lll=lll->next)
              ll[cnt++]=lll;
       qsort(ll, cnt, sizeof(*ll), cmp_flist);

       l=ll[0];
       l->next=NULL;

       for (i=1; i<cnt; i++)
       {
              ll[i-1]->next=ll[i];
              ll[i]->next=NULL;
       }
       free(ll);
       return (l);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void rmdir_contents ( const char *  )

Definition at line 89 of file faxconvert.c.

{
       DIR *p=opendir(dir);
       struct dirent *de;

       if (!p)
              return;

       while ((de=readdir(p)) != 0)
       {
              char *b;
              const char *c=de->d_name;

              if (strcmp(c, ".") == 0 || strcmp(c, "..") == 0)
                     continue;

              b=courier_malloc(strlen(dir) + strlen(c) + 2);

              strcat(strcat(strcpy(b, dir), "/"), c);
              unlink(b);
              free(b);
       }
       closedir(p);
}

Here is the call graph for this function:

Here is the caller graph for this function: