Back to index

courier  0.68.2
Defines | Functions
mailinglist.c File Reference
#include "config.h"
#include "sqwebmail.h"
#include "mailinglist.h"
#include "rfc822/rfc822.h"
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/stat.h>

Go to the source code of this file.

Defines

#define MAILINGLISTS   "sqwebmail-mailinglists"
#define MAILINGLISTSTMP   "sqwebmail-mailinglists.tmp"

Functions

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

Define Documentation

#define MAILINGLISTS   "sqwebmail-mailinglists"

Definition at line 17 of file mailinglist.c.

#define MAILINGLISTSTMP   "sqwebmail-mailinglists.tmp"

Definition at line 18 of file mailinglist.c.


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 *  p)

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: