diff --git a/dtool/src/dconfig/Sources.pp b/dtool/src/dconfig/Sources.pp index 0131b90c94..a88688dd69 100644 --- a/dtool/src/dconfig/Sources.pp +++ b/dtool/src/dconfig/Sources.pp @@ -8,7 +8,7 @@ #define SOURCES \ configTable.I configTable.h \ config_dconfig.h config_notify.h config_setup.h \ - dconfig.I dconfig.h expand.I expand.h notify.I \ + dconfig.I dconfig.h notify.I \ notify.h notifyCategory.I \ notifyCategory.h notifyCategoryProxy.I notifyCategoryProxy.h \ notifySeverity.h serialization.I serialization.h \ @@ -22,7 +22,7 @@ #define INSTALL_HEADERS \ configTable.I configTable.h config_dconfig.h config_setup.h \ dconfig.I dconfig.h \ - expand.I expand.h notify.I notify.h notifyCategory.I \ + notify.I notify.h notifyCategory.I \ notifyCategory.h notifyCategoryProxy.I notifyCategoryProxy.h \ notifySeverity.h serialization.I serialization.h symbolEnt.I \ symbolEnt.h diff --git a/dtool/src/dconfig/expand.I b/dtool/src/dconfig/expand.I deleted file mode 100644 index d1b5855473..0000000000 --- a/dtool/src/dconfig/expand.I +++ /dev/null @@ -1,61 +0,0 @@ -// Filename: expand.I -// Created by: cary (20Mar00) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://www.panda3d.org/license.txt . -// -// To contact the maintainers of this program write to -// panda3d@yahoogroups.com . -// -//////////////////////////////////////////////////////////////////// - -INLINE bool Base_Expander::isEnv(ConfigString S) { - return (getenv(S.c_str()) != (TYPENAME ConfigString::value_type *)0L); -} - -INLINE ConfigString Base_Expander::Env(ConfigString S) { - return isEnv(S)?getenv(S.c_str()):""; -} - -INLINE bool Base_Expander::isUser(ConfigString S) { - if (S.find_first_of(VChars) == 0) { - std::auto_ptr pw(getpwnam(S.c_str())); - return (pw.get() != (struct passwd *)0L); - } else - return false; -} - -INLINE ConfigString Base_Expander::GetMyDir() { - std::auto_ptr pw(getpwuid(geteuid())); - return pw->pw_dir; -} - -INLINE ConfigString Base_Expander::GetUserDir(ConfigString S) { - std::auto_ptr pw(getpwnam(S.c_str())); - return ((pw.get() != (struct passwd *)0L)?pw->pw_dir:""); -} - -INLINE ConfigString Base_Expander::operator()(void) { - return _result; -} - -INLINE ConfigString Base_Expander::operator()(ConfigString S) { - _result = Base_Expander::Expand(S); - return _result; -} - -INLINE Base_Expander::operator ConfigString() { - return _result; -} - -INLINE ConfigString Expand(ConfigString S) { - Base_Expander ex(S); - return ex; -} diff --git a/dtool/src/dconfig/expand.h b/dtool/src/dconfig/expand.h deleted file mode 100644 index eb01acdc97..0000000000 --- a/dtool/src/dconfig/expand.h +++ /dev/null @@ -1,65 +0,0 @@ -// Filename: expand.h -// Created by: cary (26Aug98) -// -//////////////////////////////////////////////////////////////////// -// -// PANDA 3D SOFTWARE -// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved -// -// All use of this software is subject to the terms of the Panda 3d -// Software license. You should have received a copy of this license -// along with this source code; you will also find a current copy of -// the license at http://www.panda3d.org/license.txt . -// -// To contact the maintainers of this program write to -// panda3d@yahoogroups.com . -// -//////////////////////////////////////////////////////////////////// - -#ifndef __EXPAND_H__ -#define __EXPAND_H__ - -#include "dtoolbase.h" - -#include "pfstream.h" -#include "config_setup.h" - -#include -#include -#include - -namespace Expand { - -static const ConfigString VChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_."; - -class Base_Expander { - private: - ConfigString _result; - - ConfigString Strip(ConfigString S); - INLINE bool isEnv(ConfigString S); - INLINE ConfigString Env(ConfigString S); - istream& CopyStreamToString(istream& is, ConfigString& S); - INLINE bool isUser(ConfigString S); - INLINE ConfigString GetMyDir(); - INLINE ConfigString GetUserDir(ConfigString S); - ConfigString Expand(ConfigString S); - Base_Expander() {} - public: - Base_Expander(ConfigString S) : _result(Base_Expander::Expand(S)) {} - Base_Expander(const Base_Expander& c) : _result(c._result) {} - ~Base_Expander() {} - INLINE ConfigString operator()(); - INLINE ConfigString operator()(ConfigString); - INLINE operator ConfigString(); -}; - -typedef Base_Expander Expander; - -INLINE ConfigString Expand(ConfigString S); - -#include "expand.I" - -} // Close namespace Expand - -#endif /* __EXPAND_H__ */