make #includes consistent
[hiphop-php.git] / hphp / runtime / base / server / source_root_info.h
blob6c584b40d63e0c5a23df05c5bab1c5423fb30023
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010- Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_SOURCE_ROOT_INFO_H_
18 #define incl_HPHP_SOURCE_ROOT_INFO_H_
20 #include "hphp/runtime/base/complex_types.h"
21 #include "hphp/runtime/eval/debugger/debugger_base.h"
23 namespace HPHP {
24 ///////////////////////////////////////////////////////////////////////////////
26 class Transport;
28 class SourceRootInfo {
29 public:
30 SourceRootInfo(const char *host);
31 SourceRootInfo(const std::string &user, const std::string &sandbox);
32 void createFromUserConfig();
33 void createFromCommonRoot(const String &sandboxName);
35 ~SourceRootInfo();
37 void setServerVariables(Variant &server) const;
38 std::string path() const;
40 bool sandboxOn() const {
41 return m_sandboxCond == SandboxOn;
44 void clear() {
45 m_user.reset();
46 m_sandbox.reset();
47 m_path.reset();
48 m_serverVars.reset();
51 bool error() const {
52 return m_sandboxCond == SandboxError;
54 void handleError(Transport *t);
55 static const std::string &GetCurrentSourceRoot() {
56 return s_path.isNull() ? RuntimeOption::SourceRoot : *s_path;
58 static const std::string &GetCurrentPhpRoot() {
59 return s_phproot.isNull() ? initPhpRoot() : *s_phproot;
62 Eval::DSandboxInfo getSandboxInfo() const;
64 private:
65 String m_user;
66 String m_sandbox;
67 String m_path;
68 enum SandboxCondition {
69 SandboxOn,
70 SandboxError,
71 SandboxOff
72 } m_sandboxCond;
73 Array m_serverVars;
74 static DECLARE_THREAD_LOCAL_NO_CHECK(std::string, s_path);
75 static DECLARE_THREAD_LOCAL_NO_CHECK(std::string, s_phproot);
77 static std::string& initPhpRoot();
78 std::string parseSandboxServerVariable(const std::string &format) const;
81 ///////////////////////////////////////////////////////////////////////////////
84 #endif // incl_HPHP_SOURCE_ROOT_INFO_H_