diff options
author | Harald Radi <phanto@php.net> | 2002-03-15 00:00:34 +0000 |
---|---|---|
committer | Harald Radi <phanto@php.net> | 2002-03-15 00:00:34 +0000 |
commit | ff62e746d2883eae4a41b17ca58c12609ef94e60 (patch) | |
tree | e298b30c06ed354fda889a9fbdc03594fbf608ad | |
parent | 7935e737499718eeaa7e1e6b6114e9fc15c45c61 (diff) | |
download | php-git-ff62e746d2883eae4a41b17ca58c12609ef94e60.tar.gz |
rpc apstraction module
does only work with ZendEngine2
-rw-r--r-- | ext/rpc/com/com.c | 7 | ||||
-rw-r--r-- | ext/rpc/handler.h | 25 | ||||
-rw-r--r-- | ext/rpc/layer.h | 12 | ||||
-rw-r--r-- | ext/rpc/php_rpc.h | 34 | ||||
-rw-r--r-- | ext/rpc/rpc.c | 257 | ||||
-rw-r--r-- | ext/rpc/rpc.dsp | 163 | ||||
-rw-r--r-- | ext/rpc/tests/test1.php | 4 |
7 files changed, 502 insertions, 0 deletions
diff --git a/ext/rpc/com/com.c b/ext/rpc/com/com.c new file mode 100644 index 0000000000..b9b380e5c4 --- /dev/null +++ b/ext/rpc/com/com.c @@ -0,0 +1,7 @@ +#include <stdio.h> +#include "../handler.h" + +RPC_REGISTER_HANDLERS(com); + +RPC_INIT_FUNCTION(com) { +} diff --git a/ext/rpc/handler.h b/ext/rpc/handler.h new file mode 100644 index 0000000000..cb13c90a49 --- /dev/null +++ b/ext/rpc/handler.h @@ -0,0 +1,25 @@ +#ifndef HANDLER_H +#define HANDLER_H + +#include "php.h" + +#define RPC_HANDLER(layer) {#layer, layer##_handler_init, &layer##_object_handlers, &layer##_class_entry} +#define RPC_DECLARE_HANDLER(layer) void layer##_handler_init(); \ + rpc_object_handlers layer##_object_handlers; \ + zend_class_entry layer##_class_entry; +#define RPC_INIT_FUNCTION(layer) void layer##_handler_init() +#define RPC_REGISTER_HANDLERS(layer) zend_class_entry layer##_class_entry; \ + rpc_object_handlers layer##object_handlers; + +typedef struct _rpc_object_handlers { + int i; +} rpc_object_handlers; + +typedef struct _rpc_handler_entry { + char *name; + void (*rpc_handler_init)(); + rpc_object_handlers *handlers; + zend_class_entry *ce; +} rpc_handler_entry; + +#endif /* HANDLER_H */
\ No newline at end of file diff --git a/ext/rpc/layer.h b/ext/rpc/layer.h new file mode 100644 index 0000000000..0d77ae28a3 --- /dev/null +++ b/ext/rpc/layer.h @@ -0,0 +1,12 @@ +#ifndef LAYER_H +#define LAYER_H + +#include "handler.h" + +RPC_DECLARE_HANDLER(com); + +rpc_handler_entry handler_entries[] = { + RPC_HANDLER(com) +}; + +#endif /* LAYER_H */
\ No newline at end of file diff --git a/ext/rpc/php_rpc.h b/ext/rpc/php_rpc.h new file mode 100644 index 0000000000..a989772a4b --- /dev/null +++ b/ext/rpc/php_rpc.h @@ -0,0 +1,34 @@ +#ifndef PHP_RPC_H +#define PHP_RPC_H + +#include "zend.h" + +extern zend_module_entry rpc_module_entry; +#define phpext_rpc_ptr &rpc_module_entry + +#ifdef PHP_WIN32 +#define PHP_RPC_API __declspec(dllexport) +#else +#define PHP_RPC_API +#endif + +#ifdef ZTS +#include "TSRM.h" +#endif + +PHP_MINIT_FUNCTION(rpc); +PHP_MSHUTDOWN_FUNCTION(rpc); +PHP_MINFO_FUNCTION(rpc); + +ZEND_BEGIN_MODULE_GLOBALS(rpc) + zend_object_handle handle; + HashTable *instance; +ZEND_END_MODULE_GLOBALS(rpc) + +#ifdef ZTS +#define RPC_G(v) TSRMG(rpc_globals_id, zend_rpc_globals *, v) +#else +#define RPC_G(v) (rpc_globals.v) +#endif + +#endif /* PHP_RPC_H */
\ No newline at end of file diff --git a/ext/rpc/rpc.c b/ext/rpc/rpc.c new file mode 100644 index 0000000000..2d9c515695 --- /dev/null +++ b/ext/rpc/rpc.c @@ -0,0 +1,257 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include "php.h" +#include "php_ini.h" +#include "ext/standard/info.h" +#include "php_rpc.h" + +#include "layer.h" + +ZEND_DECLARE_MODULE_GLOBALS(rpc) + +static zend_object_value rpc_create_object(zend_class_entry *class_type TSRMLS_DC); + +/* object handler */ +static void rpc_add_ref(zval *object); +static void rpc_del_ref(zval *object); +static void rpc_delete(zval *object); +static zend_object_value rpc_clone(zval *object); +static zval* rpc_read(zval *object, zval *member, int type TSRMLS_DC); +static void rpc_write(zval *object, zval *member, zval *value TSRMLS_DC); +static zval** rpc_get_property(zval *object, zval *member TSRMLS_DC); +static zval** rpc_get_property_zval(zval *object, zval *member TSRMLS_DC); +static zval* rpc_get(zval *property TSRMLS_DC); +static void rpc_set(zval **property, zval *value TSRMLS_DC); +static int rpc_has_property(zval *object, zval *member, int check_empty TSRMLS_DC); +static void rpc_unset_property(zval *object, zval *member TSRMLS_DC); +static HashTable* rpc_get_properties(zval *object TSRMLS_DC); +static union _zend_function* rpc_get_method(zval *object, char *method, int method_len TSRMLS_DC); +static int rpc_call(char *method, INTERNAL_FUNCTION_PARAMETERS); +static union _zend_function* rpc_get_constructor(zval *object TSRMLS_DC); +static int rpc_get_classname(zval *object, char **class_name, zend_uint *class_name_len, int parent TSRMLS_DC); +static int rpc_compare(zval *object1, zval *object2 TSRMLS_DC); +/**/ + +ZEND_FUNCTION(rpc_ctor); + +static int le_rpc; +static zend_object_handlers rpc_handlers = { + rpc_add_ref, + rpc_del_ref, + rpc_delete, + rpc_clone, + rpc_read, + rpc_write, + rpc_get_property, + rpc_get_property_zval, + rpc_get, + rpc_set, + rpc_has_property, + rpc_unset_property, + rpc_get_properties, + rpc_get_method, + rpc_call, + rpc_get_constructor, + rpc_get_classname, + rpc_compare +}; + +/* {{{ rpc_functions[] + */ +function_entry rpc_functions[] = { + {NULL, NULL, NULL} +}; +/* }}} */ + +/* {{{ rpc_module_entry + */ +zend_module_entry rpc_module_entry = { + STANDARD_MODULE_HEADER, + "rpc", + rpc_functions, + PHP_MINIT(rpc), + PHP_MSHUTDOWN(rpc), + NULL, + NULL, + PHP_MINFO(rpc), + "0.1a", + STANDARD_MODULE_PROPERTIES +}; +/* }}} */ + +#ifdef COMPILE_DL_RPC +ZEND_GET_MODULE(rpc) +#endif + +/* {{{ PHP_INI + */ +PHP_INI_BEGIN() +/* TODO: add module specific ini settings here */ +PHP_INI_END() +/* }}} */ + +/* {{{ php_rpc_init_globals + */ +static void php_rpc_init_globals(zend_rpc_globals *rpc_globals) +{ +} +/* }}} */ + +/* {{{ PHP_MINIT_FUNCTION + */ +PHP_MINIT_FUNCTION(rpc) +{ + int i; + + ZEND_INIT_MODULE_GLOBALS(rpc, php_rpc_init_globals, NULL); + REGISTER_INI_ENTRIES(); + + RPC_G(handle) = 0; + ALLOC_HASHTABLE(RPC_G(instance)); + zend_hash_init(RPC_G(instance), 0, NULL, ZVAL_PTR_DTOR, 0); + + for (i=0; i < (sizeof(handler_entries) / sizeof(rpc_handler_entry)); i++) { + handler_entries[i].rpc_handler_init(); + + INIT_OVERLOADED_CLASS_ENTRY((*(handler_entries[i].ce)), + handler_entries[i].name, + NULL, + NULL, + NULL, + NULL); + + handler_entries[i].ce->create_object = rpc_create_object; + + zend_register_internal_class(handler_entries[i].ce TSRMLS_CC); + } + + return SUCCESS; +} +/* }}} */ + +/* {{{ PHP_MSHUTDOWN_FUNCTION + */ +PHP_MSHUTDOWN_FUNCTION(rpc) +{ + UNREGISTER_INI_ENTRIES(); + return SUCCESS; +} +/* }}} */ + +/* {{{ PHP_MINFO_FUNCTION + */ +PHP_MINFO_FUNCTION(rpc) +{ + php_info_print_table_start(); + php_info_print_table_header(2, "rpc support", "enabled"); + php_info_print_table_end(); + + DISPLAY_INI_ENTRIES(); +} +/* }}} */ + +static zend_object_value rpc_create_object(zend_class_entry *class_type TSRMLS_DC) +{ + zend_object_value *zov; + + zov = (zend_object_value*) emalloc(sizeof(zend_object_value)); + zov->handle = RPC_G(handle)++; + zov->handlers = &rpc_handlers; + + zend_hash_index_update_or_next_insert(RPC_G(instance), zov->handle, class_type, sizeof(zend_class_entry),NULL, HASH_ADD); + + return *zov; +} + + +static void rpc_add_ref(zval *object) +{ +} + +static void rpc_del_ref(zval *object) +{ +} + +static void rpc_delete(zval *object) +{ +} + +static zend_object_value rpc_clone(zval *object) +{ +} + +static zval* rpc_read(zval *object, zval *member, int type TSRMLS_DC) +{ +} + +static void rpc_write(zval *object, zval *member, zval *value TSRMLS_DC) +{ +} + +static zval** rpc_get_property(zval *object, zval *member TSRMLS_DC) +{ +} + +static zval **rpc_get_property_zval(zval *object, zval *member TSRMLS_DC) +{ +} + +static zval* rpc_get(zval *property TSRMLS_DC) +{ +} + +static void rpc_set(zval **property, zval *value TSRMLS_DC) +{ +} + +static int rpc_has_property(zval *object, zval *member, int check_empty TSRMLS_DC) +{ +} + +static void rpc_unset_property(zval *object, zval *member TSRMLS_DC) +{ +} + +static HashTable* rpc_get_properties(zval *object TSRMLS_DC) +{ +} + +static union _zend_function* rpc_get_method(zval *object, char *method, int method_len TSRMLS_DC) +{ +} + +static int rpc_call(char *method, INTERNAL_FUNCTION_PARAMETERS) +{ + zval *object = getThis(); +} + +static union _zend_function* rpc_get_constructor(zval *object TSRMLS_DC) +{ + zend_function *rpc_ctor; + + rpc_ctor = (zend_function *) emalloc(sizeof(zend_function)); + + rpc_ctor->common.function_name = "__construct"; + zend_hash_index_find(RPC_G(instance), object->value.obj.handle, &(rpc_ctor->common.scope)); + + return rpc_ctor; +} + +static int rpc_get_classname(zval *object, char **class_name, zend_uint *class_name_len, int parent TSRMLS_DC) +{ +} + +static int rpc_compare(zval *object1, zval *object2 TSRMLS_DC) +{ +} + +/* + * Local variables: + * tab-width: 4 + * c-basic-offset: 4 + * End: + * vim600: noet sw=4 ts=4 fdm=marker + * vim<600: noet sw=4 ts=4 + */ diff --git a/ext/rpc/rpc.dsp b/ext/rpc/rpc.dsp new file mode 100644 index 0000000000..a621c4e515 --- /dev/null +++ b/ext/rpc/rpc.dsp @@ -0,0 +1,163 @@ +# Microsoft Developer Studio Project File - Name="rpc" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=rpc - Win32 Debug_TS
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "rpc.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "rpc.mak" CFG="rpc - Win32 Debug_TS"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "rpc - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "rpc - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "rpc - Win32 Debug_TS" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "rpc - Win32 Release_TS" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "rpc - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "..\..\Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "NDEBUG" /D ZEND_DEBUG=0 /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x40d /d "NDEBUG"
+# ADD RSC /l 0x40d /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /out:"..\..\Release/php_rpc.dll" /libpath:"..\..\Release"
+
+!ELSEIF "$(CFG)" == "rpc - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "..\..\Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "_DEBUG" /D ZEND_DEBUG=1 /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FR /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x40d /d "_DEBUG"
+# ADD RSC /l 0x40d /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug/php_rpc.dll" /pdbtype:sept /libpath:"..\..\Debug"
+
+!ELSEIF "$(CFG)" == "rpc - Win32 Debug_TS"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "..\..\Debug_TS"
+# PROP BASE Intermediate_Dir "Debug_TS"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug_TS"
+# PROP Intermediate_Dir "Debug_TS"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FR /YX /FD /GZ /c
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "_DEBUG" /D ZEND_DEBUG=1 /D "ZTS" /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /FR /YX /FD /D /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x40d /d "_DEBUG"
+# ADD RSC /l 0x40d /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts_debug.lib /nologo /dll /debug /machine:I386 /out:"..\..\Debug_TS/php_rpc.dll" /pdbtype:sept /libpath:"..\..\Debug_TS"
+
+!ELSEIF "$(CFG)" == "rpc - Win32 Release_TS"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "..\..\Release_TS"
+# PROP BASE Intermediate_Dir "Release_TS"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release_TS"
+# PROP Intermediate_Dir "Release_TS"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MD /W3 /GX /O2 /D "NDEBUG" /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
+# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\.." /I "..\..\main" /I "..\..\Zend" /I "..\..\..\bindlib_w32" /I "..\..\TSRM" /D "NDEBUG" /D ZEND_DEBUG=0 /D "ZTS" /D "PHP_WIN32" /D "ZEND_WIN32" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x40d /d "NDEBUG"
+# ADD RSC /l 0x40d /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib php4ts.lib /nologo /dll /machine:I386 /out:"..\..\Release_TS/php_rpc.dll" /libpath:"..\..\Release_TS" /libpath:"..\..\Release_TS_Inline"
+
+!ENDIF
+
+# Begin Target
+
+# Name "rpc - Win32 Release"
+# Name "rpc - Win32 Debug"
+# Name "rpc - Win32 Debug_TS"
+# Name "rpc - Win32 Release_TS"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\rpc.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\php_rpc.h
+# End Source File
+# End Group
+# End Target
+# End Project
diff --git a/ext/rpc/tests/test1.php b/ext/rpc/tests/test1.php new file mode 100644 index 0000000000..7e1b9a5274 --- /dev/null +++ b/ext/rpc/tests/test1.php @@ -0,0 +1,4 @@ +<?php +$rpc = new com(); +delete $rpc; +?>
\ No newline at end of file |