00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 INLINE bool Base_Expander::isEnv(ConfigString S) {
00020 return (getenv(S.c_str()) != (TYPENAME ConfigString::value_type *)0L);
00021 }
00022
00023 INLINE ConfigString Base_Expander::Env(ConfigString S) {
00024 return isEnv(S)?getenv(S.c_str()):"";
00025 }
00026
00027 INLINE bool Base_Expander::isUser(ConfigString S) {
00028 if (S.find_first_of(VChars) == 0) {
00029 std::auto_ptr<struct passwd> pw(getpwnam(S.c_str()));
00030 return (pw.get() != (struct passwd *)0L);
00031 } else
00032 return false;
00033 }
00034
00035 INLINE ConfigString Base_Expander::GetMyDir() {
00036 std::auto_ptr<struct passwd> pw(getpwuid(geteuid()));
00037 return pw->pw_dir;
00038 }
00039
00040 INLINE ConfigString Base_Expander::GetUserDir(ConfigString S) {
00041 std::auto_ptr<struct passwd> pw(getpwnam(S.c_str()));
00042 return ((pw.get() != (struct passwd *)0L)?pw->pw_dir:"");
00043 }
00044
00045 INLINE ConfigString Base_Expander::operator()(void) {
00046 return _result;
00047 }
00048
00049 INLINE ConfigString Base_Expander::operator()(ConfigString S) {
00050 _result = Base_Expander::Expand(S);
00051 return _result;
00052 }
00053
00054 INLINE Base_Expander::operator ConfigString() {
00055 return _result;
00056 }
00057
00058 INLINE ConfigString Expand(ConfigString S) {
00059 Base_Expander ex(S);
00060 return ex;
00061 }