# 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/socket.h>
    00035 #include <netinet/in.h>
    00036 #include <arpa/inet.h>
    00037 #include <netdb.h>
    00038 #ifndef CFG_JAVA_SOCKET_INET
    00039 # include <sys/un.h>
    00040 # ifdef HAVE_CONFIG_H
    00041 # if !HAVE_DECL_AF_LOCAL
    00042 #  define AF_LOCAL AF_UNIX
    00043 # endif
    00044 # if !HAVE_DECL_PF_LOCAL
    00045 #  define PF_LOCAL PF_UNIX
    00046 # endif
    00047 # endif
    00048 #endif
    00049 #endif
    00050
    00051 #ifdef ZEND_ENGINE_2
    00052 /* for try/catch emulation */
    00053 #include <setjmp.h>
    00054 #endif
    00055
    00056 extern zend_module_entry EXT_GLOBAL(module_entry);
    00057 extern zend_class_entry *EXT_GLOBAL(class_entry);
    00058 extern zend_class_entry *EXT_GLOBAL(class_class_entry);
    00059 extern zend_class_entry *EXT_GLOBAL(class_class_entry_jsr);
    00060 extern zend_class_entry *EXT_GLOBAL(exception_class_entry);
    00061 extern function_entry EXT_GLOBAL(class_functions[]);
    00062
    00063 #ifdef ZEND_ENGINE_2
    00064 extern zend_object_handlers EXT_GLOBAL(handlers);
    00065 #endif
    00066 extern const char * const EXT_GLOBAL(bridge_version);
    00067
    00068 extern int EXT_GLOBAL(ini_updated), EXT_GLOBAL (ini_user), EXT_GLOBAL (ini_set);
    00069 #define U_LOGFILE (1<<1)
    00070 #define U_LOGLEVEL (1<<2)
    00071 #define U_JAVA_HOME (1<<3)
    00072 #define U_JAVA (1<<4)
    00073 #define U_LIBRARY_PATH (1<<5)
    00074 #define U_CLASSPATH (1<<6)
    00075 #define U_SOCKNAME (1<<7)
    00076 #define U_HOSTS (1<<8)
    00077 #define U_SERVLET (1<<9)
    00078 #define U_WRAPPER (1<<10)
    00079
    00080
    00081 #if EXTENSION == JAVA
    00082 #define phpext_java_ptr &EXT_GLOBAL(module_entry)
    00083 #elif EXTENSION == MONO
    00084 #define phpext_mono_ptr &EXT_GLOBAL(module_entry)
    00085 #else
    00086 # error EXT must be mono or java.
    00087 #endif
    00088
    00089
    00090 PHP_MINIT_FUNCTION(EXT);
    00091 PHP_MSHUTDOWN_FUNCTION(EXT);
    00092 PHP_MINFO_FUNCTION(EXT);
    00093
    00097 struct cfg {
    00098 #ifdef CFG_JAVA_SOCKET_INET
    00099   struct sockaddr_in saddr;
    00100 #else
    00101   struct sockaddr_un saddr;
    00102 #endif
    00103   int cid; // server's process id
    00104   int err; // file descriptor: server's return code
    00105
    00106   char*sockname, *default_sockname;
    00107   char*hosts;
    00108   char*classpath;
    00109   char*ld_library_path;
    00110   char*wrapper;
    00111   char*vm;
    00112   char*vm_home;
    00113   char*logLevel;
    00114   unsigned short logLevel_val;
    00115   char*logFile;
    00116   short can_fork;               /* 0 if user has hard-coded the socketname */
    00117   char* servlet;                /* On or servlet context */
    00118   short is_cgi_servlet;         /* 1: cgi env available */
    00119 };
    00120 extern struct cfg *EXT_GLOBAL(cfg);
    00121
    00125 EXT_BEGIN_MODULE_GLOBALS(EXT)
    00126   proxyenv *jenv;
    00127   short is_closed; /* PR1176522: GC must not re-open the connection */
    00128
    00129   /* local copy of the shared variables above. Needed for channel
    00130      re-directs */
    00131   char *hosts, *servlet;
    00132   int ini_user;
    00133
    00134   /* for user CB's */
    00135   zval*exception;
    00136
    00137   zval **object;
    00138   zval *func;
    00139   zval **retval_ptr;
    00140   zval *func_params;
    00141 EXT_END_MODULE_GLOBALS(EXT)
    00142
    00143
    00144
    00145
    00146 #ifdef ZTS
    00147 # define JG(v) EXT_TSRMG(EXT_GLOBAL(globals_id), EXT_GLOBAL_EX(zend_,, _globals) *, v)
    00148 #else
    00149 # define JG(v) EXT_GLOBAL(globals).v
    00150 #endif
    00151
    00152 extern char* EXT_GLOBAL(get_server_string)(TSRMLS_D);
    00153
    00154 extern proxyenv *EXT_GLOBAL(try_connect_to_server)(TSRMLS_D);
    00155 extern proxyenv *EXT_GLOBAL(connect_to_server)(TSRMLS_D);
    00156 extern void EXT_GLOBAL(start_server)(TSRMLS_D);
    00157
    00158 extern char* EXT_GLOBAL(test_server)(int *socket, short *is_local, struct sockaddr*saddr TSRMLS_DC);
    00159
    00160 /* returns the servlet context or null */
    00161 extern char *EXT_GLOBAL(get_servlet_context)(TSRMLS_D);
    00162
    00163 /* returns the local socketname or the default local socketname*/
    00164 extern char *EXT_GLOBAL(get_sockname)(TSRMLS_D);
    00165
    00166 #endif