Back to index

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

Go to the source code of this file.

Functions

char * getmailinglists ()
void savemailinglists (const char *)

Function Documentation

char* getmailinglists ( )

Definition at line 20 of file mailinglist.c.

{
       FILE *fp=fopen(MAILINGLISTS, "r");
       struct stat stat_buf;
       char *buf;
       int l;

       if (!fp)
              return (0);

       if (fstat(fileno(fp), &stat_buf) != 0 ||
           (buf=malloc(stat_buf.st_size+1)) == NULL)
       {
              fclose(fp);
              return (0);
       }

       l=fread(buf, 1, stat_buf.st_size, fp);
       fclose(fp);

       if (l < 0)
              l=0;
       buf[l]=0;
       return (buf);
}

Here is the caller graph for this function:

void savemailinglists ( const char *  )

Definition at line 46 of file mailinglist.c.

{
       FILE *fp;
       int lastc;

       if ((fp=fopen(MAILINGLISTSTMP, "w")) == NULL)
              return;

       for (lastc='\n'; *p; p++)
       {
              if (isspace((int)(unsigned char)*p) && *p != '\n')
                     continue;

              if (*p == '\n' && lastc == '\n')
                     continue;

              putc(*p, fp);
              lastc=*p;
       }
       
       fprintf(fp, "%s", p);
       fflush(fp);
       if (ferror(fp))
       {
              fclose(fp);
              unlink(MAILINGLISTSTMP);
              return;
       }
       fclose(fp);
       rename (MAILINGLISTSTMP, MAILINGLISTS);
}

Here is the caller graph for this function: