Commit 1a6af882 1a6af8826202e071e09e3d87e266c7370e37390d by Alain Magloire

* lib/mu_dbm.c: Add <errno.h>.

	Remove trailing spaces.
1 parent feb11247
2001-11-11 Alain Magloire
* lib/mu_dbm.c: Add <errno.h>.
Remove trailing spaces.
2001-11-11 Sergey Poznyakoff
* lib/mu_dbm.c: (new) These functions provide an
......@@ -17,7 +22,7 @@
* pop3d/apop.c: Bunch of changes due to introduction of new
DBM interface.
* pop3d/pop3d.h: Likewise.
* comsat/Makefile.am: Added comsat.h to sources
2001-11-10 Jeff Bailey <jbailey@outpost.dnsalias.org>
......@@ -34,7 +39,7 @@
* doc/man/pop3d.1: New File
* doc/man/imap4d.1: New File
* doc/man/Makefile.am: New File
* pop3d/pop3d.c: Change timeout to unsigned int from size_t.
......
......@@ -29,13 +29,14 @@
#ifdef HAVE_STRINGS_H
# include <strings.h>
#endif
#include <errno.h>
#include <mu_dbm.h>
int
mu_fcheck_perm (int fd, int mode)
{
struct stat st;
if (fstat (fd, &st) == -1)
{
if (errno == ENOENT)
......@@ -47,12 +48,12 @@ mu_fcheck_perm (int fd, int mode)
return 1;
return 0;
}
int
mu_check_perm (char *name, int mode)
{
struct stat st;
if (stat (name, &st) == -1)
{
if (errno == ENOENT)
......@@ -74,7 +75,7 @@ mu_dbm_open(char *name, DBM_FILE *db, int flags, int mode)
{
int f;
char *pfname;
pfname = xmalloc (strlen (name) + sizeof DB_SUFFIX);
strcat (strcpy (pfname, name), DB_SUFFIX);
if (mu_check_perm (pfname, mode))
......@@ -82,7 +83,7 @@ mu_dbm_open(char *name, DBM_FILE *db, int flags, int mode)
free (pfname);
return -1;
}
switch (flags)
{
case MU_STREAM_CREAT:
......@@ -147,7 +148,7 @@ mu_dbm_open(char *name, DBM_FILE *dbm, int flags, int mode)
int f, rc;
DB *db;
char *pfname;
pfname = xmalloc (strlen (name) + sizeof DB_SUFFIX);
strcat (strcpy (pfname, name), DB_SUFFIX);
if (mu_check_perm (pfname, mode))
......@@ -155,7 +156,7 @@ mu_dbm_open(char *name, DBM_FILE *dbm, int flags, int mode)
free (pfname);
return -1;
}
switch (flags)
{
case MU_STREAM_CREAT:
......@@ -177,7 +178,7 @@ mu_dbm_open(char *name, DBM_FILE *dbm, int flags, int mode)
free (pfname);
if (rc)
return -1;
*dbm = malloc (sizeof **dbm);
if (!*dbm)
{
......@@ -225,14 +226,14 @@ mu_dbm_firstkey (DBM_FILE db)
if (db->db->cursor(db->db, NULL, &db->dbc, 0) != 0)
return key;
}
if ((ret = db->dbc->c_get(db->dbc, &key, &data, DB_FIRST)) != 0)
{
key.data = NULL;
key.size = 0;
if (ret == DB_NOTFOUND)
errno = ENOENT;
else
else
errno = ret;
}
return key;
......@@ -246,17 +247,17 @@ mu_dbm_nextkey (DBM_FILE db, DBM_DATUM pkey /*unused*/)
memset(&key, 0, sizeof key);
memset(&data, 0, sizeof data);
if (!db->dbc)
return key;
if ((ret = db->dbc->c_get(db->dbc, &key, &data, DB_NEXT)) != 0)
{
key.data = NULL;
key.size = 0;
if (ret == DB_NOTFOUND)
errno = ENOENT;
else
else
errno = ret;
}
return key;
......@@ -270,7 +271,7 @@ int
mu_dbm_open(char *name, DBM_FILE *db, int flags, int mode)
{
int f;
switch (flags)
{
case MU_STREAM_CREAT:
......@@ -296,7 +297,7 @@ mu_dbm_open(char *name, DBM_FILE *db, int flags, int mode)
dbm_close (*db);
return 1;
}
return 0;
}
......@@ -339,7 +340,7 @@ int
mu_dbm_open(char *name, DBM_FILE *db, int flags, int mode)
{
int f;
switch (flags)
{
case MU_STREAM_CREAT:
......@@ -359,12 +360,12 @@ mu_dbm_open(char *name, DBM_FILE *db, int flags, int mode)
{
char *p;
int fd;
p = xmalloc(strlen(name)+5);
strcat(strcpy(p, name), ".pag");
fd = open(p, f, mode);
free(p);
if (fd < 0)
if (fd < 0)
return -1;
close(fd);
......@@ -372,11 +373,11 @@ mu_dbm_open(char *name, DBM_FILE *db, int flags, int mode)
strcat(strcpy(p, name), ".dir");
fd = open(p, f, mode);
free(p);
if (fd < 0)
if (fd < 0)
return -1;
close(fd);
}
return dbminit(name);
}
......
......@@ -492,7 +492,6 @@ pop_open (mailbox_t mbox, int flags)
{
pop_data_t mpd = mbox->data;
int status;
void *func = (void *)pop_open;
char *host;
size_t hostlen = 0;
long port = 110;
......