Upstream tarball 9612
[amule.git] / src / webserver / src / php_core_lib.h
blobf8ab7e402b160baef1cd2dff6142371b3f614d0c
1 //
2 // This file is part of the aMule Project.
4 // Copyright (c) 2003-2008 aMule Team ( admin@amule.org / http://www.amule.org )
5 // Copyright (c) 2005-2008 Froenchenko Leonid ( lfroen@gmail.com / http://www.amule.org )
6 //
7 // Any parts of this program derived from the xMule, lMule or eMule project,
8 // or contributed by third-party developers are copyrighted by their
9 // respective authors.
11 // This program is free software; you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation; either version 2 of the License, or
14 // (at your option) any later version.
16 // This program is distributed in the hope that it will be useful,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 // GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program; if not, write to the Free Software
23 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
25 #ifndef _PHP_CORE_LIB_H_
26 #define _PHP_CORE_LIB_H_
29 * This is interface to CPP parts of amuleweb
31 #ifdef __cplusplus
34 class CWriteStrBuffer {
35 std::list<char *> m_buf_list;
36 int m_total_length;
37 int m_alloc_size;
38 char *m_curr_buf;
39 char *m_buf_ptr;
40 int m_curr_buf_left;
42 void AllocBuf();
43 public:
44 CWriteStrBuffer();
45 ~CWriteStrBuffer();
47 void Write(const char *s, int len = -1);
48 void CopyAll(char *dst_buffer);
49 int Length() { return m_total_length; }
52 class CWebServerBase;
53 class CSession;
55 class CPhPLibContext {
56 PHP_SYN_NODE *m_syn_tree_top;
57 PHP_SCOPE_TABLE m_global_scope;
59 CWriteStrBuffer *m_curr_str_buffer;
61 CWebServerBase *m_server;
62 public:
63 // parse file and take a "snapshot" of global vars
64 CPhPLibContext(CWebServerBase *server, const char *file);
65 CPhPLibContext(CWebServerBase *server, char *php_buf, int len);
66 ~CPhPLibContext();
68 // init global vars, so parser/execution can start
69 void SetContext();
70 void Execute(CWriteStrBuffer *);
72 #if defined(__GNUC__)
73 static void Printf(const char *str, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
74 #else
75 static void Printf(const char *str, ...);
76 #endif
77 static void Print(const char *str);
79 static CPhPLibContext *g_curr_context;
81 #ifndef PHP_STANDALONE_EN
82 CWebServerBase *WebServer() { return m_server; }
83 #endif
86 class CPhpFilter {
87 public:
88 CPhpFilter(CWebServerBase *server, CSession *sess,
89 const char *file, CWriteStrBuffer *buff);
92 #endif // __cplusplus
94 void php_init_core_lib();
95 void php_init_amule_lib();
97 void load_session_vars(const char *target, std::map<std::string, std::string> &varmap);
98 void save_session_vars(std::map<std::string, std::string> &varmap);
100 #endif //_PHP_CORE_LIB_H_
101 // File_checked_for_headers