# php_java.h

Go to the documentation of this file.

    00001 /*-*- mode: C; tab-width:4 -*-*/
    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 /* socket */
    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 /* disable unix domain sockets if jni is not available */
    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
    00066 #ifdef ZEND_ENGINE_2
    00067 /* for try/catch emulation */
    00068 #include <setjmp.h>
    00069 #endif
    00070
    00071 extern zend_module_entry EXT_GLOBAL(module_entry);
    00072 extern zend_class_entry *EXT_GLOBAL(class_entry);
    00073 extern zend_class_entry *EXT_GLOBAL(array_entry);
    00074 extern zend_class_entry *EXT_GLOBAL(class_class_entry);
    00075 extern zend_class_entry *EXT_GLOBAL(class_class_entry_jsr);
    00076 extern zend_class_entry *EXT_GLOBAL(exception_class_entry);
    00077 extern function_entry EXT_GLOBAL(class_functions[]);
    00078
    00079 #ifdef ZEND_ENGINE_2
    00080 extern zend_object_handlers EXT_GLOBAL(handlers);
    00081 #endif
    00082 extern const char * const EXT_GLOBAL(bridge_version);
    00083
    00084 extern int EXT_GLOBAL(ini_updated), EXT_GLOBAL (ini_user), EXT_GLOBAL (ini_set);
    00085 #define U_LOGFILE (1<<1)
    00086 #define U_LOGLEVEL (1<<2)
    00087 #define U_JAVA_HOME (1<<3)
    00088 #define U_JAVA (1<<4)
    00089 #define U_LIBRARY_PATH (1<<5)
    00090 #define U_CLASSPATH (1<<6)
    00091 #define U_SOCKNAME (1<<7)
    00092 #define U_HOSTS (1<<8)
    00093 #define U_SERVLET (1<<9)
    00094 #define U_WRAPPER (1<<10)
    00095 #define U_EXT_JAVA_COMPATIBILITY  (1<<11)
    00096 #define U_PERSISTENT_CONNECTIONS  (1<<12)
    00097 #define U_POLICY (1<<13)
    00098
    00099 #if EXTENSION == JAVA
    00100 #define phpext_java_ptr &EXT_GLOBAL(module_entry)
    00101 #elif EXTENSION == MONO
    00102 #define phpext_mono_ptr &EXT_GLOBAL(module_entry)
    00103 #else
    00104 # error EXT must be mono or java.
    00105 #endif
    00106
    00107
    00108 PHP_MINIT_FUNCTION(EXT);
    00109 PHP_MSHUTDOWN_FUNCTION(EXT);
    00110 PHP_MINFO_FUNCTION(EXT);
    00111
    00115 struct cfg {
    00116 #ifdef CFG_JAVA_SOCKET_INET
    00117   struct sockaddr_in saddr;
    00118 #else
    00119
    00120   struct sockaddr_un saddr;
    00121 #endif
    00122
    00123   int cid; // server's process id
    00125   int err; // file descriptor: server's return code
    00126
    00128   char*sockname;
    00130   char *default_sockname;
    00132   char*hosts;
    00134   char*classpath;
    00136   char*ld_library_path;
    00138   char*wrapper;
    00140   char*policy;
    00142   char*vm;
    00144   char*vm_home;
    00146   char*logLevel;
    00148   unsigned short logLevel_val;
    00150   char*logFile;
    00152   short can_fork;               /* 0 if user has hard-coded the socketname */
    00154   char* servlet;                /* On or servlet context */
    00155   short servlet_is_default;     /* If java.servlet=On */
    00160   short is_cgi_servlet, is_fcgi_servlet; /* 1: cgi env available */
    00162   short socketname_set;
    00164   short extJavaCompatibility;
    00165   short persistent_connections;
    00166 };
    00167 extern struct cfg *EXT_GLOBAL(cfg);
    00168
    00172 EXT_BEGIN_MODULE_GLOBALS(EXT)
    00173   proxyenv *jenv;
    00174   short is_closed; /* PR1176522: GC must not re-open the connection */
    00175
    00176   /* local copy of the shared variables above. Needed for channel
    00177      re-directs */
    00178   char *hosts, *servlet, *redirect_port;
    00179   int ini_user;
    00180
    00181   /* the name of the comm. pipe */
    00182   char*channel, *channel_in, *channel_out;
    00183   int lockfile;
    00184
    00185   /* for user CB's */
    00186   zval*exception;
    00187
    00188   zval **object;
    00189   zval *func;
    00190   zval **retval_ptr;
    00191   zval *func_params;
    00192
    00193   /* mapping of servlet context strings to persistent connections */
    00194   HashTable connections;
    00195 EXT_END_MODULE_GLOBALS(EXT)
    00196
    00197
    00198
    00199
    00200 #ifdef ZTS
    00201 # define JG(v) EXT_TSRMG(EXT_GLOBAL(globals_id), EXT_GLOBAL_EX(zend_,, _globals) *, v)
    00202 #else
    00203 # define JG(v) EXT_GLOBAL(globals).v
    00204 #endif
    00205
    00206 extern char* EXT_GLOBAL(get_server_string)(TSRMLS_D);
    00207 extern char* EXT_GLOBAL(check_policy)(char*prefix);
    00208 extern proxyenv *EXT_GLOBAL(try_connect_to_server)(TSRMLS_D);
    00209 extern proxyenv *EXT_GLOBAL(connect_to_server)(TSRMLS_D);
    00210 extern short EXT_GLOBAL(close_connection)(proxyenv*env, short persistent_connection TSRMLS_DC);
    00211 extern void EXT_GLOBAL(start_server)(TSRMLS_D);
    00212 extern void EXT_GLOBAL(activate_connection)(proxyenv *env TSRMLS_DC);
    00213 extern void EXT_GLOBAL(passivate_connection)(proxyenv *env TSRMLS_DC);
    00214 extern void EXT_GLOBAL(clone_cfg)(TSRMLS_D);
    00215 extern void EXT_GLOBAL(destroy_cloned_cfg)(TSRMLS_D);
    00216
    00217 extern char* EXT_GLOBAL(test_server)(int *socket, short *is_local, struct sockaddr*saddr TSRMLS_DC);
    00218
    00219 /* returns the servlet context or null */
    00220 extern char *EXT_GLOBAL(get_servlet_context)(TSRMLS_D);
    00221
    00222 /* returns the local socketname or the default local socketname*/
    00223 extern char *EXT_GLOBAL(get_sockname)(TSRMLS_D);
    00224
    00225 #endif