/* * retrieve a corba object from a php object */ void * orbit_retrieve_data(const zval * php_object, int wanted_type) { void * data = NULL; pval ** orbit_data_handle = NULL; int type = 0; /* get handle to corba data */ zend_hash_index_find( php_object->value.obj.properties, /* hash table */ 0, /* hash??? */ (void **)&orbit_data_handle /* data */ ); if (orbit_data_handle == NULL || *orbit_data_handle == NULL) { return NULL; } /* get corba data */ data = zend_list_find( (*orbit_data_handle)->value.lval, /* id */ &type /* type */ ); /* verify corba object */ if (!data || (type != wanted_type)) { /* TODO: handle error */ return NULL; } return data; }
void create_struct_ex(zval *retval, Any *anyval, char *str, int str_len TSRMLS_DC) { Reference <XIdlReflection> *x_idl_reflec_p; int type; int rsrc_id; try { //restore XIdlReflection resource x_idl_reflec_p = (Reference <XIdlReflection> *) zend_list_find( PUNO_G(x_idl_reflec_rsrc_id),&type); TEST_PTR(x_idl_reflec_p,); Reference <XIdlClass> xIdlClass = (*x_idl_reflec_p)->forName(OUString(str,str_len,RTL_TEXTENCODING_ISO_8859_15,OSTRING_TO_OUSTRING_CVTFLAGS)); TEST_PTR(xIdlClass.is(),); //Reference <XIdlField2> field (xidlfield, UNO_QUERY); Any any_obj; xIdlClass->createObject(any_obj); if(anyval!=NULL) { any_obj.setValue((*anyval).getValue(),(*anyval).getValueType()); } Any *any_obj_p= new Any(any_obj); TEST_PTR(any_obj_p,); //init object object_init_ex (retval, ce_ptr); puno_class_object *new_struct_p; new_struct_p = (puno_class_object *) zend_object_store_get_object(retval TSRMLS_CC); TEST_PTR(new_struct_p,); //type is Structs new_struct_p->type = TypeClass_STRUCT; //register and store the Any object rsrc_id = ZEND_REGISTER_RESOURCE ( NULL, any_obj_p, uno_any_rsrc_dtor); TEST_PTR(rsrc_id,); new_struct_p->this_rsrc_id = rsrc_id; //register and store the XIdlClass Interface Reference <XIdlClass> *x_idl_class_p=new Reference <XIdlClass> (xIdlClass); TEST_PTR(x_idl_class_p,); rsrc_id = ZEND_REGISTER_RESOURCE ( NULL, x_idl_class_p, uno_refer_rsrc_dtor); TEST_PTR(rsrc_id,); new_struct_p->x_idl_class_rsrc_id = rsrc_id; } catch(Exception& e) { //throw PHP EXCEPTION zend_throw_exception(zend_exception_get_default(),(char *)OUStringToOString(e.Message, RTL_TEXTENCODING_ASCII_US).getStr(),0 TSRMLS_CC); } }
static Vresult * birdstep_find_result(HashTable *list,int ind) { Vresult *res; int type; res = zend_list_find(ind,&type); if ( !res || type != php_birdstep_module.le_result ) { return(NULL); } return(res); }
static VConn * birdstep_find_conn(HashTable *list,int ind) { VConn *conn; int type; conn = zend_list_find(ind,&type); if ( !conn || type != php_birdstep_module.le_link ) { return(NULL); } return(conn); }
ZEND_METHOD(YConsistent,add_server){ char *host; int host_len,port,weight; zval *object = getThis(); zval **conhash_prop; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,"sll",&host,&host_len,&port,&weight) == FAILURE){ return; } if(zend_hash_find(Z_OBJPROP_P(object),"conhash",sizeof("conhash"),(void **)&conhash_prop) == FAILURE){ RETURN_NULL(); } conhash *con = zend_list_find(Z_LVAL_PP(conhash_prop),&le_conhash); conhash_add_server(host,port,weight,con); }
ZEND_METHOD(YConsistent,find_server){ char *key; char *return_key; int key_len; zval *object = getThis(); zval **conhash_prop; if(zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC,"s",&key,&key_len) == FAILURE){ return; } if(zend_hash_find(Z_OBJPROP_P(object),"conhash",sizeof("conhash"),(void **)&conhash_prop) == FAILURE){ RETURN_NULL(); } conhash *con = zend_list_find(Z_LVAL_PP(conhash_prop),&le_conhash); cnode *node = conhash_find_server(key,key_len,con); array_init(return_value); add_assoc_string(return_value,"host",node->server.host,1); add_assoc_long(return_value,"port",node->server.port); }
long _php_num_dimension_resource_id(long resource_id) { long ERROR = -1; long result = ERROR; //const char *resource_type_name = zend_rsrc_list_get_rsrc_type(resource_id TSRMLS_CC); int resource_type_id; if (!zend_list_find(resource_id, &resource_type_id)) { /////////// RETURN return ERROR; } //DEBUG //php_printf("RESOURCE ID: %ld \n", resource_id); //php_printf("RESOURCE TYPE NAME: %s \n", resource_type_name); //php_printf("RESOURCE TYPE ID: %d \n", resource_type_id); if ( resource_type_id == le_num_ivec2 ) { result = 2; } else if ( resource_type_id == le_num_ivec3 ) { result = 3; } else if ( resource_type_id == le_num_ivec4 ) { result = 4; } else if ( resource_type_id == le_num_vec2 ) { result = 2; } else if ( resource_type_id == le_num_vec3 ) { result = 3; } else if ( resource_type_id == le_num_vec4 ) { result = 4; } else { /////////// RETURN return ERROR; } /////// RETURN return result; }
PHPAPI void php_pval_to_variant(pval *pval_arg, VARIANT *var_arg, int codepage) { OLECHAR *unicode_str; switch (pval_arg->type) { case IS_NULL: var_arg->vt = VT_EMPTY; break; case IS_BOOL: var_arg->vt = VT_BOOL; var_arg->boolVal = (short)pval_arg->value.lval; break; case IS_OBJECT: if(!strcmp(pval_arg->value.obj.ce->name, "VARIANT")) { int type; pval **var_handle; /* fetch the VARIANT structure */ zend_hash_index_find(pval_arg->value.obj.properties, 0, (void **) &var_handle); var_arg->pvarVal = (VARIANT FAR*) zend_list_find((*var_handle)->value.lval, &type); var_arg->vt = VT_VARIANT|VT_BYREF; } else if(!strcmp(pval_arg->value.obj.ce->name, "COM")) { pval **idispatch_handle; i_dispatch *obj; int type; /* fetch the IDispatch interface */ zend_hash_index_find(pval_arg->value.obj.properties, 0, (void **) &idispatch_handle); obj = (i_dispatch *)zend_list_find((*idispatch_handle)->value.lval, &type); if (!obj || (type != php_COM_get_le_idispatch())) var_arg->vt = VT_EMPTY; else { var_arg->vt = VT_DISPATCH; var_arg->pdispVal = obj->i.dispatch; } } else var_arg->vt = VT_EMPTY; break; case IS_RESOURCE: case IS_CONSTANT: case IS_CONSTANT_ARRAY: case IS_ARRAY: var_arg->vt = VT_EMPTY; break; case IS_LONG: var_arg->vt = VT_I4; /* assuming 32-bit platform */ var_arg->lVal = pval_arg->value.lval; break; case IS_DOUBLE: var_arg->vt = VT_R8; /* assuming 64-bit double precision */ var_arg->dblVal = pval_arg->value.dval; break; case IS_STRING: var_arg->vt = VT_BSTR; unicode_str = php_char_to_OLECHAR(pval_arg->value.str.val, pval_arg->value.str.len, codepage); var_arg->bstrVal = SysAllocString(unicode_str); efree(unicode_str); } }
/* {{{ proto object ffmpeg_movie(string filename) Constructor for ffmpeg_movie objects */ FFMPEG_PHP_CONSTRUCTOR(ffmpeg_movie, __construct) { int hashkey_length = 0, filename_len; char *filename = NULL, *fullpath = NULL, *hashkey = NULL; zend_bool persistent = 0; ff_movie_context *ffmovie_ctx = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &filename, &filename_len, &persistent) != SUCCESS) { return; } if (persistent && !INI_BOOL("ffmpeg.allow_persistent")) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Persistent movies have been disabled in php.ini"); RETURN_FALSE; } if (persistent) { zend_rsrc_list_entry *le; /* resolve the fully-qualified path name to use as the hash key */ fullpath = expand_filepath(filename, NULL TSRMLS_CC); hashkey_length = sizeof("ffmpeg-php_")-1 + filename_len; hashkey = (char *) emalloc(hashkey_length+1); snprintf(hashkey, hashkey_length, "ffmpeg-php_%s", filename); /* do we have an existing persistent movie? */ if (SUCCESS == zend_hash_find(&EG(persistent_list), hashkey, hashkey_length+1, (void**)&le)) { int type; if (Z_TYPE_P(le) != le_ffmpeg_pmovie) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to retrieve persistent resource"); efree(hashkey); RETURN_FALSE; } ffmovie_ctx = (ff_movie_context*)le->ptr; /* sanity check to ensure that the resource is still a valid * regular resource number */ if (zend_list_find(ffmovie_ctx->rsrc_id, &type) == ffmovie_ctx) { /* add a reference to the persistent movie */ zend_list_addref(ffmovie_ctx->rsrc_id); } else { //php_error_docref(NULL TSRMLS_CC, E_ERROR, //"Not a valid persistent movie resource"); ffmovie_ctx->rsrc_id = ZEND_REGISTER_RESOURCE(NULL, ffmovie_ctx, le_ffmpeg_pmovie); } } else { /* no existing persistant movie, create one */ zend_rsrc_list_entry new_le; ffmovie_ctx = _php_alloc_ffmovie_ctx(1); if (_php_open_movie_file(ffmovie_ctx, filename)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't open movie file %s", filename); ZVAL_BOOL(getThis(), 0); RETURN_FALSE; } Z_TYPE(new_le) = le_ffmpeg_pmovie; new_le.ptr = ffmovie_ctx; if (FAILURE == zend_hash_update(&EG(persistent_list), hashkey, hashkey_length+1, (void *)&new_le, sizeof(zend_rsrc_list_entry), NULL)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to register persistent resource"); RETURN_FALSE; } ffmovie_ctx->rsrc_id = ZEND_REGISTER_RESOURCE(NULL, ffmovie_ctx, le_ffmpeg_pmovie); } } else { ffmovie_ctx = _php_alloc_ffmovie_ctx(0); if (_php_open_movie_file(ffmovie_ctx, filename)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Can't open movie file %s", filename); ZVAL_BOOL(getThis(), 0); RETURN_FALSE; } /* pass NULL for resource result since we're not returning the resource directly, but adding it to the returned object. */ ffmovie_ctx->rsrc_id = ZEND_REGISTER_RESOURCE(NULL, ffmovie_ctx, le_ffmpeg_movie); } object_init_ex(getThis(), ffmpeg_movie_class_entry_ptr); add_property_resource(getThis(), "ffmpeg_movie", ffmovie_ctx->rsrc_id); if (fullpath) { efree(fullpath); } if (hashkey) { efree(hashkey); } }
/* {{{ proto object ffmpeg_movie(string filename) Constructor for ffmpeg_movie objects */ FFMPEG_PHP_CONSTRUCTOR(ffmpeg_movie, __construct) { int persistent = 0, hashkey_length = 0; char *filename = NULL, *fullpath = NULL, *hashkey = NULL; zval ***argv; ff_movie_context *ffmovie_ctx = NULL; /* retrieve arguments */ argv = (zval ***) safe_emalloc(sizeof(zval **), ZEND_NUM_ARGS(), 0); if (zend_get_parameters_array_ex(ZEND_NUM_ARGS(), argv) != SUCCESS) { efree(argv); php_error_docref(NULL TSRMLS_CC, E_ERROR, "Error parsing arguments"); } switch (ZEND_NUM_ARGS()) { case 2: convert_to_boolean_ex(argv[1]); if (! INI_BOOL("ffmpeg.allow_persistent") && Z_LVAL_PP(argv[1])) { zend_error(E_WARNING, "Persistent movies have been disabled in php.ini"); break; } persistent = Z_LVAL_PP(argv[1]); /* fallthru */ case 1: convert_to_string_ex(argv[0]); filename = Z_STRVAL_PP(argv[0]); break; default: WRONG_PARAM_COUNT; } if (persistent) { list_entry *le; /* resolve the fully-qualified path name to use as the hash key */ fullpath = expand_filepath(filename, NULL TSRMLS_CC); hashkey_length = sizeof("ffmpeg-php_")-1 + strlen(SAFE_STRING(filename)); hashkey = (char *) emalloc(hashkey_length+1); snprintf(hashkey, hashkey_length, "ffmpeg-php_%s", SAFE_STRING(filename)); /* do we have an existing persistent movie? */ if (SUCCESS == zend_hash_find(&EG(persistent_list), hashkey, hashkey_length+1, (void**)&le)) { int type; if (Z_TYPE_P(le) != le_ffmpeg_pmovie) { php_error_docref(NULL TSRMLS_CC, E_ERROR, "Failed to retrieve persistent resource"); } ffmovie_ctx = (ff_movie_context*)le->ptr; /* sanity check to ensure that the resource is still a valid * regular resource number */ if (zend_list_find(ffmovie_ctx->rsrc_id, &type) == ffmovie_ctx) { /* add a reference to the persistent movie */ zend_list_addref(ffmovie_ctx->rsrc_id); } else { //php_error_docref(NULL TSRMLS_CC, E_ERROR, //"Not a valid persistent movie resource"); ffmovie_ctx->rsrc_id = ZEND_REGISTER_RESOURCE(NULL, ffmovie_ctx, le_ffmpeg_pmovie); } } else { /* no existing persistant movie, create one */ list_entry new_le; ffmovie_ctx = _php_alloc_ffmovie_ctx(1); if (_php_open_movie_file(ffmovie_ctx, filename)) { zend_error(E_WARNING, "Can't open movie file %s", filename); efree(argv); ZVAL_BOOL(getThis(), 0); RETURN_FALSE; } Z_TYPE(new_le) = le_ffmpeg_pmovie; new_le.ptr = ffmovie_ctx; if (FAILURE == zend_hash_update(&EG(persistent_list), hashkey, hashkey_length+1, (void *)&new_le, sizeof(list_entry), NULL)) { php_error_docref(NULL TSRMLS_CC, E_WARNING, "Failed to register persistent resource"); } ffmovie_ctx->rsrc_id = ZEND_REGISTER_RESOURCE(NULL, ffmovie_ctx, le_ffmpeg_pmovie); } } else { ffmovie_ctx = _php_alloc_ffmovie_ctx(0); if (_php_open_movie_file(ffmovie_ctx, Z_STRVAL_PP(argv[0]))) { zend_error(E_WARNING, "Can't open movie file %s", Z_STRVAL_PP(argv[0])); efree(argv); ZVAL_BOOL(getThis(), 0); RETURN_FALSE; } /* pass NULL for resource result since we're not returning the resource directly, but adding it to the returned object. */ ffmovie_ctx->rsrc_id = ZEND_REGISTER_RESOURCE(NULL, ffmovie_ctx, le_ffmpeg_movie); } object_init_ex(getThis(), ffmpeg_movie_class_entry_ptr); add_property_resource(getThis(), "ffmpeg_movie", ffmovie_ctx->rsrc_id); efree(argv); if (fullpath) { efree(fullpath); } if (hashkey) { efree(hashkey); } }