#include "db_config.h"
#ifndef lint
static const char revid[] = "$Id: os_oflags.c,v 1.1.1.1 2003/02/15 04:56:09 zarzycki Exp $";
#endif
#ifndef NO_SYSTEM_INCLUDES
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#endif
#include "db_int.h"
u_int32_t
__db_oflags(oflags)
int oflags;
{
u_int32_t dbflags;
dbflags = 0;
if (oflags & O_CREAT)
dbflags |= DB_CREATE;
if (oflags & O_TRUNC)
dbflags |= DB_TRUNCATE;
#ifndef O_ACCMODE
#define O_ACCMODE (O_RDONLY | O_RDWR | O_WRONLY)
#endif
switch (oflags & O_ACCMODE) {
case O_RDWR:
case O_WRONLY:
break;
default:
dbflags |= DB_RDONLY;
break;
}
return (dbflags);
}
int
__db_omode(perm)
const char *perm;
{
int mode;
#ifdef DB_WIN32
#ifndef S_IRUSR
#define S_IRUSR S_IREAD
#endif
#ifndef S_IWUSR
#define S_IWUSR S_IWRITE
#endif
#ifndef S_IRGRP
#define S_IRGRP 0
#endif
#ifndef S_IWGRP
#define S_IWGRP 0
#endif
#ifndef S_IROTH
#define S_IROTH 0
#endif
#ifndef S_IWOTH
#define S_IWOTH 0
#endif
#else
#ifndef S_IRUSR
#define S_IRUSR 0000400
#define S_IWUSR 0000200
#define S_IRGRP 0000040
#define S_IWGRP 0000020
#define S_IROTH 0000004
#define S_IWOTH 0000002
#endif
#endif
mode = 0;
if (perm[0] == 'r')
mode |= S_IRUSR;
if (perm[1] == 'w')
mode |= S_IWUSR;
if (perm[2] == 'r')
mode |= S_IRGRP;
if (perm[3] == 'w')
mode |= S_IWGRP;
if (perm[4] == 'r')
mode |= S_IROTH;
if (perm[5] == 'w')
mode |= S_IWOTH;
return (mode);
}