00001
00002
00011 #ifndef PHP_JAVA_H
00012 #define PHP_JAVA_H
00013
00014 #ifdef HAVE_CONFIG_H
00015 #include "config.h"
00016 #endif
00017
00018 #include "php_wrapper.h"
00019 #include "php_config.h"
00020 #include "zend_compile.h"
00021 #include "php_ini.h"
00022 #include "php_globals.h"
00023 #include "protocol.h"
00024 #ifdef ZTS
00025 #include "TSRM.h"
00026 #endif
00027
00028 #include <sys/types.h>
00029 #include <sys/stat.h>
00030 #include <fcntl.h>
00031
00032
00033 #ifdef __MINGW32__
00034 # include <winsock2.h>
00035 # define close closesocket
00036 #else
00037 #include <sys/socket.h>
00038 #include <netinet/in.h>
00039 #include <netinet/tcp.h>
00040 #include <arpa/inet.h>
00041 #include <netdb.h>
00042
00043
00044 #ifndef HAVE_JNI
00045 # ifndef CFG_JAVA_SOCKET_INET
00046 # define CFG_JAVA_SOCKET_INET
00047 # endif
00048 #endif
00049 # if defined(CFG_JAVA_SOCKET_INET) && !defined(HAVE_FAST_TCP_SOCKETS)
00050 # warning Local TCP sockets are very slow on this system, the J2EE component will be slower than necessary (see unsupported/TestServ.c). Use unix domain sockets instead (requires JNI).
00051 # endif
00052
00053 #ifndef CFG_JAVA_SOCKET_INET
00054 # include <sys/un.h>
00055 # ifdef HAVE_CONFIG_H
00056 # if !HAVE_DECL_AF_LOCAL
00057 # define AF_LOCAL AF_UNIX
00058 # endif
00059 # if !HAVE_DECL_PF_LOCAL
00060 # define PF_LOCAL PF_UNIX
00061 # endif
00062 # endif
00063 #endif
00064 #endif
00065
00068 #ifndef ZEND_ENGINE_2
00069 #ifndef DISABLE_HEX
00070 #define DISABLE_HEX
00071 #endif
00072 #endif
00073
00074 extern zend_module_entry EXT_GLOBAL(module_entry);
00075 extern zend_class_entry *EXT_GLOBAL(class_entry);
00076 extern zend_class_entry *EXT_GLOBAL(array_entry);
00077 extern zend_class_entry *EXT_GLOBAL(class_class_entry);
00078 extern zend_class_entry *EXT_GLOBAL(class_class_entry_jsr);
00079 extern zend_class_entry *EXT_GLOBAL(exception_class_entry);
00080 extern function_entry EXT_GLOBAL(class_functions[]);
00081
00082 #ifdef ZEND_ENGINE_2
00083 extern zend_object_handlers EXT_GLOBAL(handlers);
00084 #endif
00085 extern const char * const EXT_GLOBAL(bridge_version);
00086
00087 extern int EXT_GLOBAL(ini_updated), EXT_GLOBAL (ini_user),
00088 EXT_GLOBAL (ini_set), EXT_GLOBAL(ini_override);
00089
00090 #define U_LOGFILE (1<<1)
00091 #define U_LOGLEVEL (1<<2)
00092 #define U_JAVA_HOME (1<<3)
00093 #define U_JAVA (1<<4)
00094 #define U_LIBRARY_PATH (1<<5)
00095 #define U_CLASSPATH (1<<6)
00096 #define U_SOCKNAME (1<<7)
00097 #define U_HOSTS (1<<8)
00098 #define U_SERVLET (1<<9)
00099 #define U_WRAPPER (1<<10)
00100 #define U_EXT_JAVA_COMPATIBILITY (1<<11)
00101 #define U_PERSISTENT_CONNECTIONS (1<<12)
00102 #define U_POLICY (1<<13)
00103
00104 #if EXTENSION == JAVA
00105 #define phpext_java_ptr &EXT_GLOBAL(module_entry)
00106 #elif EXTENSION == MONO
00107 #define phpext_mono_ptr &EXT_GLOBAL(module_entry)
00108 #else
00109 # error EXT must be mono or java.
00110 #endif
00111
00112
00113 PHP_MINIT_FUNCTION(EXT);
00114 PHP_MSHUTDOWN_FUNCTION(EXT);
00115 PHP_MINFO_FUNCTION(EXT);
00116
00120 struct cfg {
00121 #ifdef CFG_JAVA_SOCKET_INET
00122 struct sockaddr_in saddr;
00123 #else
00124
00125 struct sockaddr_un saddr;
00126 #endif
00127
00128 int cid;
00130 int err;
00131
00133 char*sockname;
00135 char *default_sockname;
00137 char*hosts;
00139 char*classpath;
00141 char*ld_library_path;
00143 char*wrapper;
00145 char*policy;
00147 char*vm;
00149 char*vm_home;
00151 char*logLevel;
00153 unsigned short logLevel_val;
00155 char*logFile;
00157 short can_fork;
00159 char* servlet;
00160 short servlet_is_default;
00165 short is_cgi_servlet, is_fcgi_servlet;
00167 short socketname_set;
00169 short extJavaCompatibility;
00170 short persistent_connections;
00171 };
00172 extern struct cfg *EXT_GLOBAL(cfg);
00173
00177 EXT_BEGIN_MODULE_GLOBALS(EXT)
00178 proxyenv *jenv;
00179 short is_closed;
00180
00181
00182
00183 char *hosts, *servlet, *redirect_port;
00184 int ini_user;
00185
00186
00187 char*channel, *channel_in, *channel_out;
00188 int lockfile;
00189
00190
00191 zval*exception;
00192
00193 zval **object;
00194 zval *func;
00195 zval **retval_ptr;
00196 zval *func_params;
00197
00198
00199 HashTable connections;
00200 EXT_END_MODULE_GLOBALS(EXT)
00201
00202
00203
00204
00205 #ifdef ZTS
00206 # define JG(v) EXT_TSRMG(EXT_GLOBAL(globals_id), EXT_GLOBAL_EX(zend_,, _globals) *, v)
00207 #else
00208 # define JG(v) EXT_GLOBAL(globals).v
00209 #endif
00210
00211 extern char* EXT_GLOBAL(get_server_string)(TSRMLS_D);
00212 extern void EXT_GLOBAL(override_ini_for_redirect)(TSRMLS_D);
00213 extern proxyenv *EXT_GLOBAL(try_connect_to_server)(TSRMLS_D);
00214 extern proxyenv *EXT_GLOBAL(connect_to_server)(TSRMLS_D);
00215 extern short EXT_GLOBAL(close_connection)(proxyenv*env, short persistent_connection TSRMLS_DC);
00216 extern void EXT_GLOBAL(start_server)(TSRMLS_D);
00217 extern void EXT_GLOBAL(activate_connection)(proxyenv *env TSRMLS_DC);
00218 extern void EXT_GLOBAL(passivate_connection)(proxyenv *env TSRMLS_DC);
00219 extern void EXT_GLOBAL(clone_cfg)(TSRMLS_D);
00220 extern void EXT_GLOBAL(destroy_cloned_cfg)(TSRMLS_D);
00221
00222 extern char* EXT_GLOBAL(test_server)(int *socket, short *is_local, struct sockaddr*saddr TSRMLS_DC);
00223
00224
00225 extern char *EXT_GLOBAL(get_servlet_context)(TSRMLS_D);
00226
00227
00228 extern char *EXT_GLOBAL(get_sockname)(TSRMLS_D);
00229
00230 #endif