00001
00002
00003
00004
00005
00006
00007
00008 #include "config.h"
00009
00010 #ifndef lint
00011 static const char revid[] = "$Id: os__oflags_8c-source.html,v 1.1 2008/06/08 10:21:24 sebdiaz Exp $";
00012 #endif
00013
00014 #ifndef NO_SYSTEM_INCLUDES
00015 #include <sys/types.h>
00016 #include <sys/stat.h>
00017
00018 #include <fcntl.h>
00019 #endif
00020
00021 #include "db_int.h"
00022
00023
00024
00025
00026
00027
00028
00029 u_int32_t
00030 CDB___db_oflags(oflags)
00031 int oflags;
00032 {
00033 u_int32_t dbflags;
00034
00035 dbflags = 0;
00036
00037 if (oflags & O_CREAT)
00038 dbflags |= DB_CREATE;
00039
00040 if (oflags & O_TRUNC)
00041 dbflags |= DB_TRUNCATE;
00042
00043
00044
00045
00046
00047
00048
00049 #ifndef O_ACCMODE
00050 #define O_ACCMODE (O_RDONLY | O_RDWR | O_WRONLY)
00051 #endif
00052 switch (oflags & O_ACCMODE) {
00053 case O_RDWR:
00054 case O_WRONLY:
00055 break;
00056 default:
00057 dbflags |= DB_RDONLY;
00058 break;
00059 }
00060 return (dbflags);
00061 }
00062
00063
00064
00065
00066
00067
00068
00069 int
00070 CDB___db_omode(perm)
00071 const char *perm;
00072 {
00073 int mode;
00074
00075 #ifndef S_IRUSR
00076 #if defined(_WIN32) || defined(WIN16)
00077 #define S_IRUSR S_IREAD
00078 #define S_IWUSR S_IWRITE
00079 #define S_IRGRP 0
00080 #define S_IWGRP 0
00081 #define S_IROTH 0
00082 #define S_IWOTH 0
00083 #else
00084 #define S_IRUSR 0000400
00085 #define S_IWUSR 0000200
00086 #define S_IRGRP 0000040
00087 #define S_IWGRP 0000020
00088 #define S_IROTH 0000004
00089 #define S_IWOTH 0000002
00090 #endif
00091 #endif
00092 mode = 0;
00093 if (perm[0] == 'r')
00094 mode |= S_IRUSR;
00095 if (perm[1] == 'w')
00096 mode |= S_IWUSR;
00097 if (perm[2] == 'r')
00098 mode |= S_IRGRP;
00099 if (perm[3] == 'w')
00100 mode |= S_IWGRP;
00101 if (perm[4] == 'r')
00102 mode |= S_IROTH;
00103 if (perm[5] == 'w')
00104 mode |= S_IWOTH;
00105 return (mode);
00106 }