# 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 <arpa/inet.h>
    00040 #include <netdb.h>
    00041
    00042 /* disable unix domain sockets if jni is not available */
    00043 #ifndef HAVE_JNI
    00044 # ifndef CFG_JAVA_SOCKET_INET
    00045 #  define CFG_JAVA_SOCKET_INET
    00046 # endif
    00047 #endif
    00048
    00049 #ifndef CFG_JAVA_SOCKET_INET
    00050 # include <sys/un.h>
    00051 # ifdef HAVE_CONFIG_H
    00052 # if !HAVE_DECL_AF_LOCAL
    00053 #  define AF_LOCAL AF_UNIX
    00054 # endif
    00055 # if !HAVE_DECL_PF_LOCAL
    00056 #  define PF_LOCAL PF_UNIX
    00057 # endif
    00058 # endif
    00059 #endif
    00060 #endif
    00061
    00062 #ifdef ZEND_ENGINE_2
    00063 /* for try/catch emulation */
    00064 #include <setjmp.h>
    00065 #endif
    00066
    00067 extern zend_module_entry EXT_GLOBAL(module_entry);
    00068 extern zend_class_entry *EXT_GLOBAL(class_entry);
    00069 extern zend_class_entry *EXT_GLOBAL(array_entry);
    00070 extern zend_class_entry *EXT_GLOBAL(class_class_entry);
    00071 extern zend_class_entry *EXT_GLOBAL(class_class_entry_jsr);
    00072 extern zend_class_entry *EXT_GLOBAL(exception_class_entry);
    00073 extern function_entry EXT_GLOBAL(class_functions[]);
    00074
    00075 #ifdef ZEND_ENGINE_2
    00076 extern zend_object_handlers EXT_GLOBAL(handlers);
    00077 #endif
    00078 extern const char * const EXT_GLOBAL(bridge_version);
    00079
    00080 extern int EXT_GLOBAL(ini_updated), EXT_GLOBAL (ini_user), EXT_GLOBAL (ini_set);
    00081 #define U_LOGFILE (1<<1)
    00082 #define U_LOGLEVEL (1<<2)
    00083 #define U_JAVA_HOME (1<<3)
    00084 #define U_JAVA (1<<4)
    00085 #define U_LIBRARY_PATH (1<<5)
    00086 #define U_CLASSPATH (1<<6)
    00087 #define U_SOCKNAME (1<<7)
    00088 #define U_HOSTS (1<<8)
    00089 #define U_SERVLET (1<<9)
    00090 #define U_WRAPPER (1<<10)
    00091 #define U_EXT_JAVA_COMPATIBILITY  (1<<11)
    00092
    00093 #if EXTENSION == JAVA
    00094 #define phpext_java_ptr &EXT_GLOBAL(module_entry)
    00095 #elif EXTENSION == MONO
    00096 #define phpext_mono_ptr &EXT_GLOBAL(module_entry)
    00097 #else
    00098 # error EXT must be mono or java.
    00099 #endif
    00100
    00101
    00102 PHP_MINIT_FUNCTION(EXT);
    00103 PHP_MSHUTDOWN_FUNCTION(EXT);
    00104 PHP_MINFO_FUNCTION(EXT);
    00105
    00109 struct cfg {
    00110 #ifdef CFG_JAVA_SOCKET_INET
    00111   struct sockaddr_in saddr;
    00112 #else
    00113
    00114   struct sockaddr_un saddr;
    00115 #endif
    00116
    00117   int cid; // server's process id
    00119   int err; // file descriptor: server's return code
    00120
    00122   char*sockname;
    00124   char *default_sockname;
    00126   char*hosts;
    00128   char*classpath;
    00130   char*ld_library_path;
    00132   char*wrapper;
    00134   char*vm;
    00136   char*vm_home;
    00138   char*logLevel;
    00140   unsigned short logLevel_val;
    00142   char*logFile;
    00144   short can_fork;               /* 0 if user has hard-coded the socketname */
    00146   char* servlet;                /* On or servlet context */
    00147   short servlet_is_default;     /* If java.servlet=On */
    00152   short is_cgi_servlet, is_fcgi_servlet; /* 1: cgi env available */
    00154   short socketname_set;
    00156   short extJavaCompatibility;
    00157 };
    00158 extern struct cfg *EXT_GLOBAL(cfg);
    00159
    00163 EXT_BEGIN_MODULE_GLOBALS(EXT)
    00164   proxyenv *jenv;
    00165   short is_closed; /* PR1176522: GC must not re-open the connection */
    00166
    00167   /* local copy of the shared variables above. Needed for channel
    00168      re-directs */
    00169   char *hosts, *servlet, *redirect_port;
    00170   int ini_user;
    00171
    00172   /* the name of the comm. pipe */
    00173   char*channel, *channel_in, *channel_out;
    00174   int lockfile;
    00175
    00176   /* for user CB's */
    00177   zval*exception;
    00178
    00179   zval **object;
    00180   zval *func;
    00181   zval **retval_ptr;
    00182   zval *func_params;
    00183 EXT_END_MODULE_GLOBALS(EXT)
    00184
    00185
    00186
    00187
    00188 #ifdef ZTS
    00189 # define JG(v) EXT_TSRMG(EXT_GLOBAL(globals_id), EXT_GLOBAL_EX(zend_,, _globals) *, v)
    00190 #else
    00191 # define JG(v) EXT_GLOBAL(globals).v
    00192 #endif
    00193
    00194 extern char* EXT_GLOBAL(get_server_string)(TSRMLS_D);
    00195
    00196 extern proxyenv *EXT_GLOBAL(try_connect_to_server)(TSRMLS_D);
    00197 extern proxyenv *EXT_GLOBAL(connect_to_server)(TSRMLS_D);
    00198 extern void EXT_GLOBAL(start_server)(TSRMLS_D);
    00199
    00200 extern char* EXT_GLOBAL(test_server)(int *socket, short *is_local, struct sockaddr*saddr TSRMLS_DC);
    00201
    00202 /* returns the servlet context or null */
    00203 extern char *EXT_GLOBAL(get_servlet_context)(TSRMLS_D);
    00204
    00205 /* returns the local socketname or the default local socketname*/
    00206 extern char *EXT_GLOBAL(get_sockname)(TSRMLS_D);
    00207
    00208 #endif