WvStreams
|
00001 /* -*- Mode: C++ -*- 00002 * Worldvisions Weaver Software: 00003 * Copyright (C) 1997-2002 Net Integration Technologies, Inc. 00004 * 00005 */ 00006 #ifndef __UNIPERMGEN_H 00007 #define __UNIPERMGEN_H 00008 00009 #include "unifiltergen.h" 00010 #include "wvstringtable.h" 00011 00026 class UniPermGen : public UniFilterGen 00027 { 00028 public: 00029 UniPermGen(IUniConfGen *_gen); 00030 UniPermGen(WvStringParm moniker); 00031 00032 enum Level { USER = 0, GROUP, WORLD }; 00033 static WvString level2str(Level l); 00034 00035 enum Type { READ = 0, WRITE, EXEC }; 00036 static WvString type2str(Type t); 00037 00038 struct Credentials 00039 { 00040 WvString user; 00041 mutable WvStringTable groups; 00042 // mutable because stupid WvHashTable has no const lookup methods 00043 00044 Credentials() : groups(7) { } 00045 }; 00046 00048 void setowner(const UniConfKey &path, WvStringParm owner); 00049 WvString getowner(const UniConfKey &path); 00050 00052 void setgroup(const UniConfKey &path, WvStringParm group); 00053 WvString getgroup(const UniConfKey &path); 00054 00059 bool getread(const UniConfKey &path, const Credentials &cred) 00060 { return getperm(path, cred, READ); } 00061 bool getwrite(const UniConfKey &path, const Credentials &cred) 00062 { return getperm(path, cred, WRITE); } 00063 bool getexec(const UniConfKey &path, const Credentials &cred) 00064 { return getperm(path, cred, EXEC); } 00065 00066 bool getperm(const UniConfKey &path, const Credentials &cred, Type type); 00067 00068 void setread(const UniConfKey &path, Level level, bool read) 00069 { setperm(path, level, READ, read); } 00070 void setwrite(const UniConfKey &path, Level level, bool write) 00071 { setperm(path, level, WRITE, write); } 00072 void setexec(const UniConfKey &path, Level level, bool exec) 00073 { setperm(path, level, EXEC, exec); } 00074 00075 void setperm(const UniConfKey &path, Level level, Type type, bool val); 00076 00081 void chmod(const UniConfKey &path, unsigned int owner, unsigned int group, 00082 unsigned int world); 00083 void chmod(const UniConfKey &path, unsigned int mode); 00084 00085 virtual void flush_buffers() { } 00086 00087 private: 00088 bool getoneperm(const UniConfKey &path, Level level, Type type); 00089 }; 00090 00091 00092 #endif // __UNIPERMGEN_H