/*
** Copyright (c) 1999-2002 Proofpoint, Inc. and its suppliers.
** All rights reserved.
**
** By using this file, you agree to the terms and conditions set
** forth in the LICENSE file which can be found at the top level of
** the sendmail distribution.
*/
#include <fcntl.h>
#include <stdlib.h>
#include <unistd.h>
#include <sendmail/sendmail.h>
#ifdef NDBM
struct smdb_dbm_database_struct
{
int smndbm_lock_fd;
bool smndbm_cursor_in_use;
};
struct smdb_dbm_cursor_struct
{
};
/*
** SMDB_PUT_FLAGS_TO_NDBM_FLAGS -- Translates smdb put flags to ndbm put flags.
**
** Parameters:
** flags -- The flags to translate.
**
** Returns:
** The ndbm flags that are equivalent to the smdb flags.
**
** Notes:
** Any invalid flags are ignored.
**
*/
int
{
int return_flags;
return_flags = 0;
else
return return_flags;
}
/*
** Except for smdb_ndbm_open, the rest of these function correspond to the
** interface laid out in smdb.h.
*/
{
{
db->smndbm_cursor_in_use = false;
}
return db;
}
int
{
return SMDBE_OK;
}
int
unsigned int flags;
{
int result;
errno = 0;
if (result != 0)
{
return SMDBE_IO_ERROR;
if (save_errno != 0)
return save_errno;
return SMDBE_NOT_FOUND;
}
return SMDBE_OK;
}
int
int *fd;
{
if (*fd <= 0)
return EINVAL;
return SMDBE_OK;
}
int
{
return db->smndbm_lock_fd;
}
int
unsigned int flags;
{
errno = 0;
{
return SMDBE_IO_ERROR;
if (save_errno != 0)
return save_errno;
return SMDBE_NOT_FOUND;
}
return SMDBE_OK;
}
int
unsigned int flags;
{
int result;
int save_errno;
errno = 0;
switch (result)
{
case 1:
return SMDBE_DUPLICATE;
case 0:
return SMDBE_OK;
default:
save_errno = errno;
return SMDBE_IO_ERROR;
if (save_errno != 0)
return save_errno;
return SMDBE_IO_ERROR;
}
/* NOTREACHED */
}
int
{
# if HASFCHOWN
int fd;
int result;
if (fd <= 0)
return EINVAL;
if (result < 0)
return errno;
if (fd <= 0)
return EINVAL;
if (result < 0)
return errno;
# endif /* HASFCHOWN */
return SMDBE_OK;
}
int
unsigned int flags;
{
return SMDBE_UNSUPPORTED;
}
int
{
if (!db->smndbm_cursor_in_use)
return SMDBE_NOT_A_VALID_CURSOR;
db->smndbm_cursor_in_use = false;
return SMDBE_OK;
}
int
unsigned int flags;
{
int result;
errno = 0;
if (result != 0)
{
return SMDBE_IO_ERROR;
if (save_errno != 0)
return save_errno;
return SMDBE_NOT_FOUND;
}
return SMDBE_OK;
}
int
{
if (flags == SMDB_CURSOR_GET_RANGE)
return SMDBE_UNSUPPORTED;
{
{
return SMDBE_IO_ERROR;
return SMDBE_LAST_ENTRY;
}
}
else
{
{
return SMDBE_IO_ERROR;
return SMDBE_LAST_ENTRY;
}
}
errno = 0;
{
return SMDBE_IO_ERROR;
if (save_errno != 0)
return save_errno;
return SMDBE_NOT_FOUND;
}
return SMDBE_OK;
}
int
{
int result;
int save_errno;
errno = 0;
switch (result)
{
case 1:
return SMDBE_DUPLICATE;
case 0:
return SMDBE_OK;
default:
save_errno = errno;
return SMDBE_IO_ERROR;
if (save_errno != 0)
return save_errno;
return SMDBE_IO_ERROR;
}
/* NOTREACHED */
}
int
{
if (db->smndbm_cursor_in_use)
return SMDBE_ONLY_SUPPORTS_ONE_CURSOR;
db->smndbm_cursor_in_use = true;
if (dbm_cursor == NULL)
return SMDBE_MALLOC;
{
return SMDBE_MALLOC;
}
return SMDBE_OK;
}
/*
** SMDB_NDBM_OPEN -- Opens a ndbm database.
**
** Parameters:
** database -- An unallocated database pointer to a pointer.
** db_name -- The name of the database without extension.
** mode -- File permisions on a created database.
** mode_mask -- Mode bits that much match on an opened database.
** sff -- Flags to safefile.
** type -- The type of database to open.
** Only SMDB_NDBM is supported.
** user_info -- Information on the user to use for file
** permissions.
** db_params -- No params are supported.
**
** Returns:
** SMDBE_OK -- Success, otherwise errno:
** SMDBE_MALLOC -- Cannot allocate memory.
** SMDBE_UNSUPPORTED -- The type is not supported.
** SMDBE_GDBM_IS_BAD -- We have detected GDBM and we don't
** like it.
** SMDBE_BAD_OPEN -- dbm_open failed and errno was not set.
** Anything else: errno
*/
int
char *db_name;
int mode;
int mode_mask;
long sff;
{
bool lockcreated = false;
int result;
int lock_fd;
return SMDBE_UNKNOWN_DB_TYPE;
return result;
return result;
lockcreated = true;
lock_fd = -1;
return result;
if (lockcreated)
{
int pag_fd;
/* Need to pre-open the .pag file as well with O_EXCL */
{
return result;
}
}
db = smdbm_malloc_database();
/* Try to open database */
{
errno = 0;
{
if (errno == 0)
else
}
}
/* Check for GDBM */
{
}
/* Check for filechanged */
{
{
}
}
/* XXX Got to get fchown stuff in here */
/* Setup driver if everything is ok */
{
return SMDBE_OK;
}
/* If we're here, something bad happened, clean up */
return result;
}
#endif /* NDBM */