Back to index

courier  0.68.2
Defines | Functions | Variables
ldapaliasdrc.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <time.h>
#include <sys/socket.h>
#include <sys/un.h>
#include "ldapaliasdrc.h"
#include "sysconfdir.h"
#include "localstatedir.h"

Go to the source code of this file.

Defines

#define syslog(a, b)

Functions

static int readconfigfile ()
void ldapaliasd_configchanged ()
const char * ldapaliasd_config (const char *configname)
FILE * ldapaliasd_connect ()

Variables

static char * ldapauth = 0
static size_t ldapauth_size = 0

Define Documentation

#define syslog (   a,
 
)

Definition at line 36 of file ldapaliasdrc.c.


Function Documentation

const char* ldapaliasd_config ( const char *  configname)

Definition at line 91 of file ldapaliasdrc.c.

{
       size_t i;
       int    l=strlen(configname);
       char   *p=0;

       if (!ldapauth && readconfigfile())
              return ("");

       for (i=0; i<ldapauth_size; )
       {
              p=ldapauth+i;
              if (memcmp(p, configname, l) == 0 &&
                     isspace((int)(unsigned char)p[l]))
              {
                     p += l;
                     while (*p && *p != '\n' &&
                            isspace((int)(unsigned char)*p))
                            ++p;
                     return (p);
              }

              while (i < ldapauth_size)
                     if (ldapauth[i++] == 0)     break;
       }

       return ("");
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 81 of file ldapaliasdrc.c.

{
       if (ldapauth)
       {
              free(ldapauth);
              ldapauth=0;
              ldapauth_size=0;
       }
}

Here is the caller graph for this function:

FILE* ldapaliasd_connect ( )

Definition at line 120 of file ldapaliasdrc.c.

{
       int     fd=socket(PF_UNIX, SOCK_STREAM, 0);
       struct  sockaddr_un skun;
       FILE   *fp;

        if (fd < 0)
       {
              return (NULL);
       }

        skun.sun_family=AF_UNIX;
        strcpy(skun.sun_path, SOCKETFILE);

       if (connect(fd, (const struct sockaddr *)&skun, sizeof(skun)) < 0)
       {
              close(fd);
              return (NULL);
       }

       fp=fdopen(fd, "r+");

       if (!fp)
       {
              close(fd);
              syslog(LOG_DAEMON | LOG_CRIT, "fdopen() failed; %m");
              return (NULL);
       }
       return (fp);
}

Here is the caller graph for this function:

static int readconfigfile ( ) [static]

Definition at line 47 of file ldapaliasdrc.c.

{
       FILE   *f=fopen(LDAPALIASDCONFIGFILE, "r");
       struct stat   buf;
       size_t i;
       if (!f)
       {
              if (errno != ENOENT)
                     perror(LDAPALIASDCONFIGFILE);
              return (-1);
       }

       if (fstat(fileno(f), &buf) ||
           (ldapauth=malloc(buf.st_size+2)) == 0)
       {
              fclose(f);
              return (-1);
       }
       if (fread(ldapauth, buf.st_size, 1, f) != 1)
       {
              free(ldapauth);
              ldapauth=0;
              fclose(f);
              return (-1);
       }
       ldapauth[ldapauth_size=buf.st_size]=0;

       for (i=0; i<ldapauth_size; i++)
              if (ldapauth[i] == '\n')
                     ldapauth[i]=0;
       fclose(f);
       return (0);
}

Here is the caller graph for this function:


Variable Documentation

char* ldapauth = 0 [static]

Definition at line 44 of file ldapaliasdrc.c.

size_t ldapauth_size = 0 [static]

Definition at line 45 of file ldapaliasdrc.c.