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