Back to index

courier  0.68.2
Functions | Variables
tcpdaccess.c File Reference
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include "dbobj.h"

Go to the source code of this file.

Functions

int openaccess (const char *filename)
void closeaccess ()
char * chkaccess (const char *ip)

Variables

static struct dbobj
static int db_isopen = 0
static int db_isinit = 0

Function Documentation

char* chkaccess ( const char *  ip)

Definition at line 46 of file tcpdaccess.c.

{
size_t l;
char   *p, *q;

       if (!db_isopen)      return (0);


       p=dbobj_fetch(&db, ip, strlen(ip), &l, "");

       if (!p)       return (0);
       q=(char *)malloc(l+1);
       if (!q)
       {
              perror("malloc");
              free(p);
              return (0);
       }
       memcpy(q, p, l);
       q[l]=0;
       free(p);
       return (q);
}

Here is the caller graph for this function:

void closeaccess ( )

Definition at line 39 of file tcpdaccess.c.

{
       if (!db_isopen)      return;
       dbobj_close(&db);
       db_isopen=0;
}

Here is the caller graph for this function:

int openaccess ( const char *  filename)

Definition at line 20 of file tcpdaccess.c.

{
       if (!db_isinit)
       {
              dbobj_init(&db);
              db_isinit=1;
       }
       if (db_isopen)
       {
              dbobj_close(&db);
              db_isopen=0;
       }

       if (dbobj_open(&db, filename, "R"))
              return (-1);
       db_isopen=1;
       return (0);
}

Here is the caller graph for this function:


Variable Documentation

int db_isinit = 0 [static]

Definition at line 18 of file tcpdaccess.c.

int db_isopen = 0 [static]

Definition at line 18 of file tcpdaccess.c.

struct dbobj [static]

Definition at line 17 of file tcpdaccess.c.