Back to index

php5  5.3.10
Classes | Defines | Functions | Variables
com_persist.c File Reference
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "php_com_dotnet.h"
#include "php_com_dotnet_internal.h"
#include "Zend/zend_exceptions.h"

Go to the source code of this file.

Classes

struct  php_istream
struct  php_com_persist_helper

Defines

#define TSRMLS_FIXED()
#define FETCH_STM()
#define CPH_ME(fname, arginfo)   PHP_ME(com_persist, fname, arginfo, ZEND_ACC_PUBLIC)
#define CPH_SME(fname, arginfo)   PHP_ME(com_persist, fname, arginfo, ZEND_ACC_ALLOW_STATIC|ZEND_ACC_PUBLIC)
#define CPH_METHOD(fname)   static PHP_METHOD(com_persist, fname)
#define CPH_FETCH()   php_com_persist_helper *helper = (php_com_persist_helper*)zend_object_store_get_object(getThis() TSRMLS_CC);
#define CPH_NO_OBJ()   if (helper->unk == NULL) { php_com_throw_exception(E_INVALIDARG, "No COM object is associated with this helper instance" TSRMLS_CC); return; }

Functions

static void istream_destructor (php_istream *stm)
static void istream_dtor (zend_rsrc_list_entry *rsrc TSRMLS_DC)
static HRESULT STDMETHODCALLTYPE stm_queryinterface (IStream *This, REFIID riid, void **ppvObject)
static ULONG STDMETHODCALLTYPE stm_addref (IStream *This)
static ULONG STDMETHODCALLTYPE stm_release (IStream *This)
static HRESULT STDMETHODCALLTYPE stm_read (IStream *This, void *pv, ULONG cb, ULONG *pcbRead)
static HRESULT STDMETHODCALLTYPE stm_write (IStream *This, void const *pv, ULONG cb, ULONG *pcbWritten)
static HRESULT STDMETHODCALLTYPE stm_seek (IStream *This, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER *plibNewPosition)
static HRESULT STDMETHODCALLTYPE stm_set_size (IStream *This, ULARGE_INTEGER libNewSize)
static HRESULT STDMETHODCALLTYPE stm_copy_to (IStream *This, IStream *pstm, ULARGE_INTEGER cb, ULARGE_INTEGER *pcbRead, ULARGE_INTEGER *pcbWritten)
static HRESULT STDMETHODCALLTYPE stm_commit (IStream *This, DWORD grfCommitFlags)
static HRESULT STDMETHODCALLTYPE stm_revert (IStream *This)
static HRESULT STDMETHODCALLTYPE stm_lock_region (IStream *This, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD lockType)
static HRESULT STDMETHODCALLTYPE stm_unlock_region (IStream *This, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD lockType)
static HRESULT STDMETHODCALLTYPE stm_stat (IStream *This, STATSTG *pstatstg, DWORD grfStatFlag)
static HRESULT STDMETHODCALLTYPE stm_clone (IStream *This, IStream **ppstm)
PHPAPI IStream * php_com_wrapper_export_stream (php_stream *stream TSRMLS_DC)
static HRESULT get_persist_stream (php_com_persist_helper *helper)
static HRESULT get_persist_stream_init (php_com_persist_helper *helper)
static HRESULT get_persist_file (php_com_persist_helper *helper)
 CPH_METHOD (GetCurFileName)
 CPH_METHOD (SaveToFile)
 CPH_METHOD (LoadFromFile)
 CPH_METHOD (GetMaxStreamSize)
 CPH_METHOD (InitNew)
 CPH_METHOD (LoadFromStream)
 CPH_METHOD (SaveToStream)
 CPH_METHOD (__construct)
static void helper_free_storage (void *obj TSRMLS_DC)
static void helper_clone (void *obj, void **clone_ptr TSRMLS_DC)
static zend_object_value helper_new (zend_class_entry *ce TSRMLS_DC)
int php_com_persist_minit (INIT_FUNC_ARGS)

Variables

static int le_istream
static struct IStreamVtbl
static zend_object_handlers helper_handlers
static zend_class_entry * helper_ce
static const zend_function_entry com_persist_helper_methods []

Class Documentation

struct php_istream

Definition at line 39 of file com_persist.c.

Class Members
DWORD engine_thread
int id
CONST_VTBL struct IStreamVtbl * lpVtbl
LONG refcount
php_stream * stream
struct php_com_persist_helper

Definition at line 301 of file com_persist.c.

Collaboration diagram for php_com_persist_helper:
Class Members
long codepage
IPersistFile * ipf
IPersistStream * ips
IPersistStreamInit * ipsi
zend_object std
IUnknown * unk

Define Documentation

Definition at line 297 of file com_persist.c.

#define CPH_ME (   fname,
  arginfo 
)    PHP_ME(com_persist, fname, arginfo, ZEND_ACC_PUBLIC)

Definition at line 293 of file com_persist.c.

#define CPH_METHOD (   fname)    static PHP_METHOD(com_persist, fname)

Definition at line 295 of file com_persist.c.

#define CPH_NO_OBJ ( )    if (helper->unk == NULL) { php_com_throw_exception(E_INVALIDARG, "No COM object is associated with this helper instance" TSRMLS_CC); return; }

Definition at line 299 of file com_persist.c.

#define CPH_SME (   fname,
  arginfo 
)    PHP_ME(com_persist, fname, arginfo, ZEND_ACC_ALLOW_STATIC|ZEND_ACC_PUBLIC)

Definition at line 294 of file com_persist.c.

#define FETCH_STM ( )
Value:
TSRMLS_FIXED() \
	php_istream *stm = (php_istream*)This; \
       if (GetCurrentThreadId() != stm->engine_thread) \
              return RPC_E_WRONG_THREAD;

Definition at line 62 of file com_persist.c.

#define TSRMLS_FIXED ( )

Definition at line 59 of file com_persist.c.


Function Documentation

CPH_METHOD ( GetCurFileName  )

Definition at line 340 of file com_persist.c.

{
       HRESULT res;
       OLECHAR *olename = NULL;
       CPH_FETCH();

       CPH_NO_OBJ();
       
       res = get_persist_file(helper);
       if (helper->ipf) {
              res = IPersistFile_GetCurFile(helper->ipf, &olename);

              if (res == S_OK) {
                     Z_TYPE_P(return_value) = IS_STRING;
                     Z_STRVAL_P(return_value) = php_com_olestring_to_string(olename,
                               &Z_STRLEN_P(return_value), helper->codepage TSRMLS_CC);
                     CoTaskMemFree(olename);
                     return;
              } else if (res == S_FALSE) {
                     CoTaskMemFree(olename);
                     RETURN_FALSE;
              }
              php_com_throw_exception(res, NULL TSRMLS_CC);
       } else {
              php_com_throw_exception(res, NULL TSRMLS_CC);
       }
}

Here is the call graph for this function:

CPH_METHOD ( SaveToFile  )

Definition at line 372 of file com_persist.c.

{
       HRESULT res;
       char *filename, *fullpath = NULL;
       int filename_len;
       zend_bool remember = TRUE;
       OLECHAR *olefilename = NULL;
       CPH_FETCH();
       
       CPH_NO_OBJ();

       res = get_persist_file(helper);
       if (helper->ipf) {
              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s!|b",
                                   &filename, &filename_len, &remember)) {
                     php_com_throw_exception(E_INVALIDARG, "Invalid arguments" TSRMLS_CC);
                     return;
              }

              if (filename) {
                     if (strlen(filename) != filename_len) {
                            RETURN_FALSE;
                     }
                     fullpath = expand_filepath(filename, NULL TSRMLS_CC);
                     if (!fullpath) {
                            RETURN_FALSE;
                     }
       
                     if ((PG(safe_mode) && (!php_checkuid(fullpath, NULL, CHECKUID_CHECK_FILE_AND_DIR))) || 
                                   php_check_open_basedir(fullpath TSRMLS_CC)) {
                            efree(fullpath);
                            RETURN_FALSE;
                     }

                     olefilename = php_com_string_to_olestring(filename, strlen(fullpath), helper->codepage TSRMLS_CC);
                     efree(fullpath);
              }
              res = IPersistFile_Save(helper->ipf, olefilename, remember);
              if (SUCCEEDED(res)) {
                     if (!olefilename) {
                            res = IPersistFile_GetCurFile(helper->ipf, &olefilename);
                            if (S_OK == res) {
                                   IPersistFile_SaveCompleted(helper->ipf, olefilename);
                                   CoTaskMemFree(olefilename);
                                   olefilename = NULL;
                            }
                     } else if (remember) {
                            IPersistFile_SaveCompleted(helper->ipf, olefilename);
                     }
              }
                     
              if (olefilename) {
                     efree(olefilename);
              }

              if (FAILED(res)) {
                     php_com_throw_exception(res, NULL TSRMLS_CC);
              }

       } else {
              php_com_throw_exception(res, NULL TSRMLS_CC);
       }
}

Here is the call graph for this function:

CPH_METHOD ( LoadFromFile  )

Definition at line 439 of file com_persist.c.

{
       HRESULT res;
       char *filename, *fullpath;
       int filename_len;
       long flags = 0;
       OLECHAR *olefilename;
       CPH_FETCH();
       
       CPH_NO_OBJ();

       res = get_persist_file(helper);
       if (helper->ipf) {

              if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|l",
                                   &filename, &filename_len, &flags)) {
                     php_com_throw_exception(E_INVALIDARG, "Invalid arguments" TSRMLS_CC);
                     return;
              }

              if (strlen(filename) != filename_len) {
                     RETURN_FALSE;
              }

              if (!(fullpath = expand_filepath(filename, NULL TSRMLS_CC))) {
                     RETURN_FALSE;
              }

              if ((PG(safe_mode) && (!php_checkuid(fullpath, NULL, CHECKUID_CHECK_FILE_AND_DIR))) ||
                            php_check_open_basedir(fullpath TSRMLS_CC)) {
                     efree(fullpath);
                     RETURN_FALSE;
              }

              olefilename = php_com_string_to_olestring(fullpath, strlen(fullpath), helper->codepage TSRMLS_CC);
              efree(fullpath);
                     
              res = IPersistFile_Load(helper->ipf, olefilename, flags);
              efree(olefilename);

              if (FAILED(res)) {
                     php_com_throw_exception(res, NULL TSRMLS_CC);
              }
              
       } else {
              php_com_throw_exception(res, NULL TSRMLS_CC);
       }
}

Here is the call graph for this function:

CPH_METHOD ( GetMaxStreamSize  )

Definition at line 491 of file com_persist.c.

{
       HRESULT res;
       ULARGE_INTEGER size;
       CPH_FETCH();
       
       CPH_NO_OBJ();
       
       res = get_persist_stream_init(helper);
       if (helper->ipsi) {
              res = IPersistStreamInit_GetSizeMax(helper->ipsi, &size);
       } else {
              res = get_persist_stream(helper);
              if (helper->ips) {
                     res = IPersistStream_GetSizeMax(helper->ips, &size);
              } else {
                     php_com_throw_exception(res, NULL TSRMLS_CC);
                     return;
              }
       }

       if (res != S_OK) {
              php_com_throw_exception(res, NULL TSRMLS_CC);
       } else {
              /* TODO: handle 64 bit properly */
              RETURN_LONG((LONG)size.QuadPart);
       }
}

Here is the call graph for this function:

CPH_METHOD ( InitNew  )

Definition at line 523 of file com_persist.c.

{
       HRESULT res;
       CPH_FETCH();
       
       CPH_NO_OBJ();

       res = get_persist_stream_init(helper);
       if (helper->ipsi) {
              res = IPersistStreamInit_InitNew(helper->ipsi);

              if (res != S_OK) {
                     php_com_throw_exception(res, NULL TSRMLS_CC);
              } else {
                     RETURN_TRUE;
              }
       } else {
              php_com_throw_exception(res, NULL TSRMLS_CC);
       }
}

Here is the call graph for this function:

CPH_METHOD ( LoadFromStream  )

Definition at line 547 of file com_persist.c.

{
       zval *zstm;
       php_stream *stream;
       IStream *stm = NULL;
       HRESULT res;
       CPH_FETCH();
       
       if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstm)) {
              php_com_throw_exception(E_INVALIDARG, "invalid arguments" TSRMLS_CC);
              return;
       }

       php_stream_from_zval_no_verify(stream, &zstm);
       
       if (stream == NULL) {
              php_com_throw_exception(E_INVALIDARG, "expected a stream" TSRMLS_CC);
              return;
       }

       stm = php_com_wrapper_export_stream(stream TSRMLS_CC);
       if (stm == NULL) {
              php_com_throw_exception(E_UNEXPECTED, "failed to wrap stream" TSRMLS_CC);
              return;
       }
       
       res = S_OK;
       RETVAL_TRUE;

       if (helper->unk == NULL) {
              IDispatch *disp = NULL;

              /* we need to create an object and load using OleLoadFromStream */
              res = OleLoadFromStream(stm, &IID_IDispatch, &disp);

              if (SUCCEEDED(res)) {
                     php_com_wrap_dispatch(return_value, disp, COMG(code_page) TSRMLS_CC); 
              }
       } else {
              res = get_persist_stream_init(helper);
              if (helper->ipsi) {
                     res = IPersistStreamInit_Load(helper->ipsi, stm);
              } else {
                     res = get_persist_stream(helper);
                     if (helper->ips) {
                            res = IPersistStreamInit_Load(helper->ipsi, stm);
                     }
              }
       }
       IStream_Release(stm);

       if (FAILED(res)) {
              php_com_throw_exception(res, NULL TSRMLS_CC);
              RETURN_NULL();
       }
}

Here is the call graph for this function:

CPH_METHOD ( SaveToStream  )

Definition at line 607 of file com_persist.c.

{
       zval *zstm;
       php_stream *stream;
       IStream *stm = NULL;
       HRESULT res;
       CPH_FETCH();
       
       CPH_NO_OBJ();
       
       if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &zstm)) {
              php_com_throw_exception(E_INVALIDARG, "invalid arguments" TSRMLS_CC);
              return;
       }

       php_stream_from_zval_no_verify(stream, &zstm);
       
       if (stream == NULL) {
              php_com_throw_exception(E_INVALIDARG, "expected a stream" TSRMLS_CC);
              return;
       }

       stm = php_com_wrapper_export_stream(stream TSRMLS_CC);
       if (stm == NULL) {
              php_com_throw_exception(E_UNEXPECTED, "failed to wrap stream" TSRMLS_CC);
              return;
       }
       
       res = get_persist_stream_init(helper);
       if (helper->ipsi) {
              res = IPersistStreamInit_Save(helper->ipsi, stm, TRUE);
       } else {
              res = get_persist_stream(helper);
              if (helper->ips) {
                     res = IPersistStream_Save(helper->ips, stm, TRUE);
              }
       }
       
       IStream_Release(stm);

       if (FAILED(res)) {
              php_com_throw_exception(res, NULL TSRMLS_CC);
              return;
       }

       RETURN_TRUE;
}

Here is the call graph for this function:

CPH_METHOD ( __construct  )

Definition at line 658 of file com_persist.c.

{
       php_com_dotnet_object *obj = NULL;
       zval *zobj = NULL;
       CPH_FETCH();

       if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|O!",
                            &zobj, php_com_variant_class_entry)) {
              php_com_throw_exception(E_INVALIDARG, "invalid arguments" TSRMLS_CC);
              return;
       }

       if (!zobj) {
              return;
       }
       
       obj = CDNO_FETCH(zobj);

       if (V_VT(&obj->v) != VT_DISPATCH || V_DISPATCH(&obj->v) == NULL) {
              php_com_throw_exception(E_INVALIDARG, "parameter must represent an IDispatch COM object" TSRMLS_CC);
              return;
       }

       /* it is always safe to cast an interface to IUnknown */
       helper->unk = (IUnknown*)V_DISPATCH(&obj->v);
       IUnknown_AddRef(helper->unk);
       helper->codepage = obj->code_page;
}

Here is the call graph for this function:

static HRESULT get_persist_file ( php_com_persist_helper helper) [inline, static]

Definition at line 329 of file com_persist.c.

{
       if (!helper->ipf && helper->unk) {
              return IUnknown_QueryInterface(helper->unk, &IID_IPersistFile, &helper->ipf);
       }
       return helper->ipf ? S_OK : E_NOTIMPL;
}

Here is the caller graph for this function:

static HRESULT get_persist_stream ( php_com_persist_helper helper) [inline, static]

Definition at line 313 of file com_persist.c.

{
       if (!helper->ips && helper->unk) {
              return IUnknown_QueryInterface(helper->unk, &IID_IPersistStream, &helper->ips);
       }
       return helper->ips ? S_OK : E_NOTIMPL;
}

Here is the caller graph for this function:

static HRESULT get_persist_stream_init ( php_com_persist_helper helper) [inline, static]

Definition at line 321 of file com_persist.c.

{
       if (!helper->ipsi && helper->unk) {
              return IUnknown_QueryInterface(helper->unk, &IID_IPersistStreamInit, &helper->ipsi);
       }
       return helper->ipsi ? S_OK : E_NOTIMPL;
}

Here is the caller graph for this function:

static void helper_clone ( void *  obj,
void **clone_ptr  TSRMLS_DC 
) [static]

Definition at line 724 of file com_persist.c.

{
       php_com_persist_helper *clone, *object = (php_com_persist_helper*)obj;

       clone = emalloc(sizeof(*object));
       memcpy(clone, object, sizeof(*object));
       *clone_ptr = clone;

       zend_object_std_init(&clone->std, object->std.ce TSRMLS_CC);

       if (clone->ipf) {
              IPersistFile_AddRef(clone->ipf);
       }
       if (clone->ips) {
              IPersistStream_AddRef(clone->ips);
       }
       if (clone->ipsi) {
              IPersistStreamInit_AddRef(clone->ipsi);
       }
       if (clone->unk) {
              IUnknown_AddRef(clone->unk);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void helper_free_storage ( void *obj  TSRMLS_DC) [static]

Definition at line 703 of file com_persist.c.

{
       php_com_persist_helper *object = (php_com_persist_helper*)obj;

       if (object->ipf) {
              IPersistFile_Release(object->ipf);
       }
       if (object->ips) {
              IPersistStream_Release(object->ips);
       }
       if (object->ipsi) {
              IPersistStreamInit_Release(object->ipsi);
       }
       if (object->unk) {
              IUnknown_Release(object->unk);
       }
       zend_object_std_dtor(&object->std TSRMLS_CC);
       efree(object);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static zend_object_value helper_new ( zend_class_entry *ce  TSRMLS_DC) [static]

Definition at line 748 of file com_persist.c.

{
       php_com_persist_helper *helper;
       zend_object_value retval;

       helper = emalloc(sizeof(*helper));
       memset(helper, 0, sizeof(*helper));

       zend_object_std_init(&helper->std, helper_ce TSRMLS_CC);
       
       retval.handle = zend_objects_store_put(helper, NULL, helper_free_storage, helper_clone TSRMLS_CC);
       retval.handlers = &helper_handlers;

       return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void istream_destructor ( php_istream stm) [static]

Definition at line 253 of file com_persist.c.

{
       TSRMLS_FETCH();

       if (stm->id) {
              int id = stm->id;
              stm->id = 0;
              zend_list_delete(id);
              return;
       }

       if (stm->refcount > 0) {
              CoDisconnectObject((IUnknown*)stm, 0);
       }

       zend_list_delete(stm->stream->rsrc_id);

       CoTaskMemFree(stm);
}

Here is the caller graph for this function:

static void istream_dtor ( zend_rsrc_list_entry *rsrc  TSRMLS_DC) [static]

Definition at line 50 of file com_persist.c.

{
       php_istream *stm = (php_istream *)rsrc->ptr;
       istream_destructor(stm);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 764 of file com_persist.c.

{
       zend_class_entry ce;

       memcpy(&helper_handlers, zend_get_std_object_handlers(), sizeof(helper_handlers));
       helper_handlers.clone_obj = NULL;

       INIT_CLASS_ENTRY(ce, "COMPersistHelper", com_persist_helper_methods);
       ce.create_object = helper_new;
       helper_ce = zend_register_internal_class(&ce TSRMLS_CC);
       helper_ce->ce_flags |= ZEND_ACC_FINAL;

       le_istream = zend_register_list_destructors_ex(istream_dtor,
                     NULL, "com_dotnet_istream_wrapper", module_number);
       
       return SUCCESS;
}

Here is the call graph for this function:

Here is the caller graph for this function:

PHPAPI IStream* php_com_wrapper_export_stream ( php_stream *stream  TSRMLS_DC)

Definition at line 274 of file com_persist.c.

{
       php_istream *stm = (php_istream*)CoTaskMemAlloc(sizeof(*stm));

       if (stm == NULL)
              return NULL;

       memset(stm, 0, sizeof(*stm));
       stm->engine_thread = GetCurrentThreadId();
       stm->lpVtbl = &php_istream_vtbl;
       stm->refcount = 1;
       stm->stream = stream;

       zend_list_addref(stream->rsrc_id);
       stm->id = zend_list_insert(stm, le_istream);

       return (IStream*)stm;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static ULONG STDMETHODCALLTYPE stm_addref ( IStream *  This) [static]

Definition at line 86 of file com_persist.c.

{
       FETCH_STM();

       return InterlockedIncrement(&stm->refcount);
}
static HRESULT STDMETHODCALLTYPE stm_clone ( IStream *  This,
IStream **  ppstm 
) [static]

Definition at line 231 of file com_persist.c.

{
       return STG_E_INVALIDFUNCTION;
}
static HRESULT STDMETHODCALLTYPE stm_commit ( IStream *  This,
DWORD  grfCommitFlags 
) [static]

Definition at line 198 of file com_persist.c.

{
       FETCH_STM();

       php_stream_flush(stm->stream);

       return S_OK;
}
static HRESULT STDMETHODCALLTYPE stm_copy_to ( IStream *  This,
IStream *  pstm,
ULARGE_INTEGER  cb,
ULARGE_INTEGER *  pcbRead,
ULARGE_INTEGER *  pcbWritten 
) [static]

Definition at line 190 of file com_persist.c.

{
       FETCH_STM();

       return E_NOTIMPL;
}
static HRESULT STDMETHODCALLTYPE stm_lock_region ( IStream *  This,
ULARGE_INTEGER  libOffset,
ULARGE_INTEGER  cb,
DWORD  lockType 
) [static]

Definition at line 213 of file com_persist.c.

{
       return STG_E_INVALIDFUNCTION;
}
static HRESULT STDMETHODCALLTYPE stm_queryinterface ( IStream *  This,
REFIID  riid,
void **  ppvObject 
) [static]

Definition at line 68 of file com_persist.c.

{
       FETCH_STM();

       if (IsEqualGUID(&IID_IUnknown, riid) ||
                     IsEqualGUID(&IID_IStream, riid)) {
              *ppvObject = This;
              InterlockedIncrement(&stm->refcount);
              return S_OK;
       }

       *ppvObject = NULL;
       return E_NOINTERFACE;
}
static HRESULT STDMETHODCALLTYPE stm_read ( IStream *  This,
void *  pv,
ULONG  cb,
ULONG *  pcbRead 
) [static]

Definition at line 107 of file com_persist.c.

{
       int nread;
       FETCH_STM();

       nread = php_stream_read(stm->stream, pv, cb);

       if (pcbRead) {
              *pcbRead = nread > 0 ? nread : 0;
       }
       if (nread > 0) {
              return S_OK;
       }
       return S_FALSE;
}
static ULONG STDMETHODCALLTYPE stm_release ( IStream *  This) [static]

Definition at line 93 of file com_persist.c.

{
       ULONG ret;
       FETCH_STM();

       ret = InterlockedDecrement(&stm->refcount);
       if (ret == 0) {
              /* destroy it */
              if (stm->id)
                     zend_list_delete(stm->id);
       }
       return ret;
}
static HRESULT STDMETHODCALLTYPE stm_revert ( IStream *  This) [static]

Definition at line 207 of file com_persist.c.

{
       /* NOP */
       return S_OK;
}
static HRESULT STDMETHODCALLTYPE stm_seek ( IStream *  This,
LARGE_INTEGER  dlibMove,
DWORD  dwOrigin,
ULARGE_INTEGER *  plibNewPosition 
) [static]

Definition at line 139 of file com_persist.c.

{
       off_t offset;
       int whence;
       int ret;
       FETCH_STM();

       switch (dwOrigin) {
              case STREAM_SEEK_SET:       whence = SEEK_SET;   break;
              case STREAM_SEEK_CUR:       whence = SEEK_CUR;   break;
              case STREAM_SEEK_END:       whence = SEEK_END;   break;
              default:
                     return STG_E_INVALIDFUNCTION;
       }
       
       if (dlibMove.HighPart) {
              /* we don't support 64-bit offsets */
              return STG_E_INVALIDFUNCTION;
       }
       
       offset = (off_t) dlibMove.QuadPart;

       ret = php_stream_seek(stm->stream, offset, whence);

       if (plibNewPosition) {
              plibNewPosition->QuadPart = (ULONGLONG)(ret >= 0 ? ret : 0);
       }

       return ret >= 0 ? S_OK : STG_E_INVALIDFUNCTION;
}
static HRESULT STDMETHODCALLTYPE stm_set_size ( IStream *  This,
ULARGE_INTEGER  libNewSize 
) [static]

Definition at line 171 of file com_persist.c.

{
       FETCH_STM();

       if (libNewSize.HighPart) {
              return STG_E_INVALIDFUNCTION;
       }
       
       if (php_stream_truncate_supported(stm->stream)) {
              int ret = php_stream_truncate_set_size(stm->stream, (size_t)libNewSize.QuadPart);

              if (ret == 0) {
                     return S_OK;
              }
       }

       return STG_E_INVALIDFUNCTION;
}
static HRESULT STDMETHODCALLTYPE stm_stat ( IStream *  This,
STATSTG *  pstatstg,
DWORD  grfStatFlag 
) [static]

Definition at line 225 of file com_persist.c.

{
       return STG_E_INVALIDFUNCTION;
}
static HRESULT STDMETHODCALLTYPE stm_unlock_region ( IStream *  This,
ULARGE_INTEGER  libOffset,
ULARGE_INTEGER  cb,
DWORD  lockType 
) [static]

Definition at line 219 of file com_persist.c.

{
       return STG_E_INVALIDFUNCTION;
}
static HRESULT STDMETHODCALLTYPE stm_write ( IStream *  This,
void const *  pv,
ULONG  cb,
ULONG *  pcbWritten 
) [static]

Definition at line 123 of file com_persist.c.

{
       int nwrote;
       FETCH_STM();

       nwrote = php_stream_write(stm->stream, pv, cb);

       if (pcbWritten) {
              *pcbWritten = nwrote > 0 ? nwrote : 0;
       }
       if (nwrote > 0) {
              return S_OK;
       }
       return S_FALSE;
}

Variable Documentation

Initial value:

Definition at line 691 of file com_persist.c.

zend_class_entry* helper_ce [static]

Definition at line 311 of file com_persist.c.

zend_object_handlers helper_handlers [static]

Definition at line 310 of file com_persist.c.

struct IStreamVtbl [static]
int le_istream [static]

Definition at line 47 of file com_persist.c.