Back to index

courier  0.68.2
Functions
maildirshared2.c File Reference
#include "config.h"
#include "maildirmisc.h"
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>

Go to the source code of this file.

Functions

FILE * maildir_shared_fopen (const char *maildir, const char *mode)
void maildir_shared_fparse (char *p, char **name, char **dir)
char * maildir_shareddir (const char *maildir, const char *sharedname)

Function Documentation

FILE* maildir_shared_fopen ( const char *  maildir,
const char *  mode 
)

Definition at line 15 of file maildirshared2.c.

{
char   *m;
FILE   *fp;

       m=malloc(strlen(maildir)+sizeof("/shared-maildirs"));
       if (!m)
       {
              perror("malloc");
              return (0);
       }
       strcat(strcpy(m, maildir), "/shared-maildirs");

       fp=fopen(m, mode);
       free(m);
       return (fp);
}

Here is the caller graph for this function:

void maildir_shared_fparse ( char *  p,
char **  name,
char **  dir 
)

Definition at line 33 of file maildirshared2.c.

{
char   *q;

       *name=0;
       *dir=0;

       if ((q=strchr(p, '\n')) != 0)      *q=0;
       if ((q=strchr(p, '#')) != 0)       *q=0;

       for (q=p; *q; q++)
              if (isspace((int)(unsigned char)*q))      break;
       if (!*q)      return;
       *q++=0;
       while (*q && isspace((int)(unsigned char)*q))
              ++q;
       if (*q)
       {
              *name=p;
              *dir=q;
       }
}

Here is the caller graph for this function:

char* maildir_shareddir ( const char *  maildir,
const char *  sharedname 
)

Definition at line 56 of file maildirshared2.c.

{
char    *p, *q;
const char *r;

       if (!maildir)   maildir=".";

       if (strchr(sharedname, '.') == 0 || *sharedname == '.' ||
              strchr(sharedname, '/'))
       {
              errno=EINVAL;
              return (0);
       }

       for (r=sharedname; *r; r++)
       {
              if (*r == '.' && (r[1] == '.' || r[1] == '\0'))
              {
                     errno=EINVAL;
                     return (0);
              }
       }

       p=malloc(strlen(maildir)+sizeof("/" SHAREDSUBDIR "/")+strlen(sharedname));
       if (!p)       return (0);

        *p=0;
        if (strcmp(maildir, "."))
              strcat(strcpy(p, maildir), "/");
       strcat(p, SHAREDSUBDIR "/");
       q=p+strlen(p);
       strcpy(q, sharedname);
       *strchr(q, '.')='/';
       return (p);
}

Here is the caller graph for this function: