Exemplo n.º 1
0
PHP_METHOD(SpotifyPlaylist, __destruct)
{
	spotifyplaylist_object *p = (spotifyplaylist_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
	sp_playlist_release(p->playlist);
}
Exemplo n.º 2
0
/* {{{ proto float ImagickPixel::setColorValue(int color, float value )
	Sets the normalized color of the ImagickPixel.
*/
PHP_METHOD(imagickpixel, setcolorvalue)
{
	php_imagickpixel_object *internp;
	long color;
	double color_value;

	/* Parse parameters given to function */
	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ld", &color, &color_value) == FAILURE) {
		return;
	}
	
	internp = (php_imagickpixel_object *)zend_object_store_get_object(getThis() TSRMLS_CC);

	switch (color) {

		case IMAGICKCOLORBLACK:
			PixelSetBlack(internp->pixel_wand, color_value);
		break;

		case IMAGICKCOLORBLUE:
			PixelSetBlue(internp->pixel_wand, color_value);
		break;

		case IMAGICKCOLORCYAN:
			PixelSetCyan(internp->pixel_wand, color_value);
		break;

		case IMAGICKCOLORGREEN:
			PixelSetGreen(internp->pixel_wand, color_value);
		break;

		case IMAGICKCOLORRED:
			PixelSetRed(internp->pixel_wand, color_value);
		break;

		case IMAGICKCOLORYELLOW:
			PixelSetYellow(internp->pixel_wand, color_value);
		break;

		case IMAGICKCOLORMAGENTA:
			PixelSetMagenta(internp->pixel_wand, color_value);
		break;

		case IMAGICKCOLOROPACITY:
			PixelSetOpacity(internp->pixel_wand, color_value);
		break;

		case IMAGICKCOLORALPHA:
			PixelSetAlpha(internp->pixel_wand, color_value);
		break;

#if MagickLibVersion > 0x628
		case IMAGICKCOLORFUZZ:
			PixelSetFuzz(internp->pixel_wand, color_value);
		break;
#endif

		default:
			php_imagick_throw_exception (IMAGICKPIXEL_CLASS, "Unknown color type" TSRMLS_CC);
			return;
		break;
	}
	RETVAL_TRUE;
}
Exemplo n.º 3
0
	if (!strerror_r(err, buf, 256)) {
		return buf;
	}
	efree(buf);
	return NULL;
#endif
}

PHP_MOSQUITTO_API void php_mosquitto_exit_loop(mosquitto_client_object *object)
{
	object->looping = 0;
}

static inline mosquitto_client_object *mosquitto_client_object_get(zval *zobj TSRMLS_DC)
{
	mosquitto_client_object *pobj = zend_object_store_get_object(zobj TSRMLS_CC);

	if (pobj->client == NULL) {
		php_error(E_ERROR, "Internal surface object missing in %s wrapper, you must call parent::__construct in extended classes", Z_OBJCE_P(zobj)->name);
	}
	return pobj;
}

static void mosquitto_client_object_destroy(void *object TSRMLS_DC)
{
	mosquitto_client_object *client = (mosquitto_client_object *) object;

	/* Disconnect cleanly, but disregard an error if it wasn't connected */
	/* We must loop here so that the disconnect packet is sent and acknowledged */
	mosquitto_disconnect(client->client);
	mosquitto_loop(client->client, 100, 1);
Exemplo n.º 4
0
/**
 * Returns the path this event is watching.
 * 
 * @return string
 * @return false  if object has not been initialized
 */
PHP_METHOD(StatEvent, getPath)
{
	event_object *obj = (event_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
	
	RETURN_STRING(((ev_stat *)obj->watcher)->path, 1);
}
Exemplo n.º 5
0
/**
 * Returns the next to last stat information received about the file,
 * all array elements will be zero if the event has not been added to an EventLoop.
 * 
 * NOTE: If the nlink key is 0, then the file does not exist.
 * 
 * @return array
 * @return false  if object has not been initialized
 */
PHP_METHOD(StatEvent, getPrev)
{
	event_object *obj = (event_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
	
	ev_statdata_to_php_array(((ev_stat *)obj->watcher)->prev, return_value);
}
Exemplo n.º 6
0
/**
 * Returns true if the event watcher is pending (ie. it has outstanding events but
 * the callback has not been called yet).
 * 
 * @return boolean
 * @return null  If object has not been initialized
 */
PHP_METHOD(Event, isPending)
{
	event_object *obj = (event_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
	
	RETURN_BOOL(event_is_pending(obj));
}
Exemplo n.º 7
0
/**
 * When repeating, returns the offset, otherwise it returns the absolute time for
 * the event trigger.
 * 
 * @return double
 * @return false  if object has not been initialized
 */
PHP_METHOD(PeriodicEvent, getOffset)
{
	event_object *obj = (event_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
	
	RETURN_DOUBLE(((ev_periodic *)obj->watcher)->offset);
}
Exemplo n.º 8
0
    RETURN_LONG(projectionObj_getUnits(php_projection->projection));
}
/* }}} */

zend_function_entry projection_functions[] = {
    PHP_ME(projectionObj, __construct, projection___construct_args, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
    PHP_ME(projectionObj, getUnits, NULL, ZEND_ACC_PUBLIC)
    {NULL, NULL, NULL}
};


void mapscript_create_projection(projectionObj *projection, parent_object parent, zval *return_value TSRMLS_DC)
{
    php_projection_object * php_projection;
    object_init_ex(return_value, mapscript_ce_projection); 
    php_projection = (php_projection_object *)zend_object_store_get_object(return_value TSRMLS_CC);
    php_projection->projection = projection;

    if (parent.val)
        php_projection->is_ref = 1;

    php_projection->parent = parent;
    MAPSCRIPT_ADDREF(parent.val);
}

static void mapscript_projection_object_destroy(void *object TSRMLS_DC)
{
    php_projection_object *php_projection = (php_projection_object *)object;

    MAPSCRIPT_FREE_OBJECT(php_projection);
    
Exemplo n.º 9
0
# include "win32/unistd.h"
#else
# include <unistd.h>
#endif

#include "php_amqp.h"


#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3
zend_object_handlers amqp_queue_object_handlers;
HashTable *amqp_queue_object_get_debug_info(zval *object, int *is_temp TSRMLS_DC) {
	zval *value;
	HashTable *debug_info;

	/* Get the envelope object from which to read */
	amqp_queue_object *queue = (amqp_queue_object *)zend_object_store_get_object(object TSRMLS_CC);

	/* Let zend clean up for us: */
	*is_temp = 1;

	/* Keep the # 7 matching the number of entries in this table*/
	ALLOC_HASHTABLE(debug_info);
	ZEND_INIT_SYMTABLE_EX(debug_info, 7 + 1, 0);

	/* Start adding values */
	MAKE_STD_ZVAL(value);
	ZVAL_STRINGL(value, queue->name, strlen(queue->name), 1);
	zend_hash_add(debug_info, "queue_name", sizeof("queue_name"), &value, sizeof(zval *), NULL);

	MAKE_STD_ZVAL(value);
	ZVAL_STRINGL(value, queue->consumer_tag, strlen(queue->consumer_tag), 1);
Exemplo n.º 10
0
{
	mongo_db *db = (mongo_db*)zend_object_store_get_object(getThis() TSRMLS_CC);
	MONGO_CHECK_INITIALIZED_STRING(db->name, MongoDB);
	RETURN_ZVAL(db->name, 1, 0);
}

/* Selects a collection and returns it as zval. If the return value is no, an
 * Exception is set. This only happens if the passed in DB was invalid. */
zval *php_mongodb_selectcollection(zval *this, char *collection, int collection_len TSRMLS_DC)
{
	zval *z_collection;
	zval *return_value;
	zval temp;
	mongo_db *db;

	db = (mongo_db*)zend_object_store_get_object(this TSRMLS_CC);
	if (!(db->name)) {
		zend_throw_exception(mongo_ce_Exception, "The MongoDB object has not been correctly initialized by its constructor", 0 TSRMLS_CC);
		return NULL;
	}

	MAKE_STD_ZVAL(z_collection);
	ZVAL_STRINGL(z_collection, collection, collection_len, 1);

	MAKE_STD_ZVAL(return_value);
	object_init_ex(return_value, mongo_ce_Collection);

	MONGO_METHOD2(MongoCollection, __construct, &temp, return_value, this, z_collection);

	zval_ptr_dtor(&z_collection);
Exemplo n.º 11
0
PHP_METHOD(MongoDB, __toString)
{
	mongo_db *db = (mongo_db*)zend_object_store_get_object(getThis() TSRMLS_CC);
	MONGO_CHECK_INITIALIZED_STRING(db->name, MongoDB);
	RETURN_ZVAL(db->name, 1, 0);
}
Exemplo n.º 12
0
}
/* }}} */

/*
 * Initializes a new mongo_write_batch_object with write options, inherited through
 * MongoCollection and default server options - overwritable by the write_options argument */
void php_mongo_api_batch_ctor(mongo_write_batch_object *intern, zval *zcollection, php_mongo_write_types type, HashTable *write_options TSRMLS_DC) /* {{{ */
{
	mongoclient      *link;
	mongo_collection *collection;

	intern->batch_type = type;
	intern->zcollection_object = zcollection;
	Z_ADDREF_P(zcollection);

	collection = (mongo_collection *)zend_object_store_get_object(zcollection TSRMLS_CC);
	link       = (mongoclient *)zend_object_store_get_object(collection->link TSRMLS_CC);

	mongo_apply_implicit_write_options(&intern->write_options, &link->servers->options, zcollection TSRMLS_CC);
	php_mongo_api_write_options_from_ht(&intern->write_options, write_options TSRMLS_CC);
}

/* }}} */

/*
 * Puts the final touches on a mongo_buffer batch by ending the bulk array and write the
 * write options into the buffer
 *
 * Returns:
 * 0: Failed to wrap up the buffer
 * >0 The full message length */
Exemplo n.º 13
0
    
/**
 *  Function that is called to create space for a cloned object
 *  @param  val                     The object to be cloned
 *  @return zend_obejct_value       The object to be created
 */
zend_object_value ClassBase::cloneObject(zval *val TSRMLS_DC)
{
    // retrieve the class entry linked to this object
    auto *entry = zend_get_class_entry(val);

    // we need the C++ class meta-information object
    ClassBase *meta = cpp_class(entry);

    // retrieve the old object, which we are going to copy
    MixedObject *old_object = (MixedObject *)zend_object_store_get_object(val);

    // create a new base c++ object
    auto *cpp = meta->clone(old_object->cpp);
    
    // report error on failure
    if (!cpp) throw Php::Exception(std::string("Unable to clone ") + entry->name);

    // the thing we're going to return
    zend_object_value result;
    
    // set the handlers
    result.handlers = ClassBase::objectHandlers();
    
    // store the object
    MixedObject *new_object = cpp->store(entry);
Exemplo n.º 14
0
/* {{{ proto string MongoGridFSFile::getBytes()
   Returns this file's contents as a string of bytes */
PHP_METHOD(MongoGridFSFile, getBytes)
{
	zval *file, *gridfs, *chunks, *query, *cursor, *sort, *temp;
	zval **id, **size;
	char *str, *str_ptr;
	int len;
	mongo_cursor *cursorobj;
	zval *flags;

	file = zend_read_property(mongo_ce_GridFSFile, getThis(), "file", strlen("file"), NOISY TSRMLS_CC);
	zend_hash_find(HASH_P(file), "_id", strlen("_id") + 1, (void**)&id);

	if (zend_hash_find(HASH_P(file), "length", strlen("length") + 1, (void**)&size) == FAILURE) {
		zend_throw_exception(mongo_ce_GridFSException, "couldn't find file size", 14 TSRMLS_CC);
		return;
	}

	/* make sure that there's an index on chunks so we can sort by chunk num */
	gridfs = zend_read_property(mongo_ce_GridFSFile, getThis(), "gridfs", strlen("gridfs"), NOISY TSRMLS_CC);
	chunks = zend_read_property(mongo_ce_GridFS, gridfs, "chunks", strlen("chunks"), NOISY TSRMLS_CC);

	MAKE_STD_ZVAL(temp);
	php_mongo_ensure_gridfs_index(temp, chunks TSRMLS_CC);
	zval_dtor(temp);

	/* query for chunks */
	MAKE_STD_ZVAL(query);
	array_init(query);
	zval_add_ref(id);
	add_assoc_zval(query, "files_id", *id);

	MAKE_STD_ZVAL(cursor);
	MONGO_METHOD1(MongoCollection, find, cursor, chunks, query);

	/* Copy the flags from the original cursor and apply it to this one */
	flags = zend_read_property(mongo_ce_GridFSFile, getThis(), "flags", strlen("flags"), NOISY TSRMLS_CC);
	cursorobj = (mongo_cursor*)zend_object_store_get_object(cursor TSRMLS_CC);
	convert_to_long(flags);
	cursorobj->opts = Z_LVAL_P(flags);

	MAKE_STD_ZVAL(sort);
	array_init(sort);
	add_assoc_long(sort, "n", 1);

	MONGO_METHOD1(MongoCursor, sort, temp, cursor, sort);
	zval_ptr_dtor(&temp);

	zval_ptr_dtor(&query);
	zval_ptr_dtor(&sort);

	if (Z_TYPE_PP(size) == IS_DOUBLE) {
		len = (int)Z_DVAL_PP(size);
	} else if (Z_TYPE_PP(size) == IS_LONG) {
		len = Z_LVAL_PP(size);
	} else if (Z_TYPE_PP(size) == IS_OBJECT && (Z_OBJCE_PP(size) == mongo_ce_Int32 || Z_OBJCE_PP(size) == mongo_ce_Int64)) {
		zval *sizet = zend_read_property(mongo_ce_Int64, *size, "value", strlen("value"), NOISY TSRMLS_CC);
		if (Z_TYPE_P(sizet) != IS_STRING) {
			zval_ptr_dtor(&cursor);
			zend_throw_exception(mongo_ce_GridFSException, "couldn't find file size, value object broken", 0 TSRMLS_CC);
			return;
		}
		len = atoi(Z_STRVAL_P(sizet));
	} else {
		zval_ptr_dtor(&cursor);
		zend_throw_exception(mongo_ce_GridFSException, "couldn't find file size, property invalid", 0 TSRMLS_CC);
		return;
	}

	str = (char *)ecalloc(len + 1, 1);
	str_ptr = str;

	if (apply_to_cursor(cursor, copy_bytes, &str, len + 1 TSRMLS_CC) == FAILURE) {
		zval_ptr_dtor(&cursor);
		efree(str_ptr);

		if (EG(exception)) {
			return;
		}
		zend_throw_exception(mongo_ce_GridFSException, "error reading chunk of file", 17 TSRMLS_CC);
		return;
	}

	zval_ptr_dtor(&cursor);

	str_ptr[len] = '\0';

	RETURN_STRINGL(str_ptr, len, 0);
}
Exemplo n.º 15
0
/**
 * Returns true if the event is active, ie. associated with an event loop.
 * 
 * @return boolean
 * @return null  If object has not been initialized
 */
PHP_METHOD(Event, isActive)
{
	event_object *obj = (event_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
	
	RETURN_BOOL(event_is_active(obj));
}
Exemplo n.º 16
0
/* {{{ MongoDBRef::get()
 */
PHP_METHOD(MongoDBRef, get)
{
	zval *db, *ref, *collection, *query;
	zval **ns, **id, **dbname;
	zend_bool alloced_db = 0;

	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Oz", &db, mongo_ce_DB, &ref) == FAILURE) {
		return;
	}

	if (
		IS_SCALAR_P(ref) ||
		zend_hash_find(HASH_P(ref), "$ref", strlen("$ref") + 1, (void**)&ns) == FAILURE ||
		zend_hash_find(HASH_P(ref), "$id", strlen("$id") + 1, (void**)&id) == FAILURE
	) {
		RETURN_NULL();
	}

	if (Z_TYPE_PP(ns) != IS_STRING) {
		zend_throw_exception(mongo_ce_Exception, "MongoDBRef::get: $ref field must be a string", 10 TSRMLS_CC);
		return;
	}

	/* if this reference contains a db name, we have to switch dbs */
	if (zend_hash_find(HASH_P(ref), "$db", strlen("$db") + 1, (void**)&dbname) == SUCCESS) {
		mongo_db *temp_db = (mongo_db*)zend_object_store_get_object(db TSRMLS_CC);

		/* just to be paranoid, make sure dbname is a string */
		if (Z_TYPE_PP(dbname) != IS_STRING) {
			zend_throw_exception(mongo_ce_Exception, "MongoDBRef::get: $db field must be a string", 11 TSRMLS_CC);
			return;
		}

		/* if the name in the $db field doesn't match the current db, make up
		 * a new db */
		if (strcmp(Z_STRVAL_PP(dbname), Z_STRVAL_P(temp_db->name)) != 0) {
			zval *new_db_z;

			MAKE_STD_ZVAL(new_db_z);
			ZVAL_NULL(new_db_z);

			MONGO_METHOD1(MongoClient, selectDB, new_db_z, temp_db->link, *dbname);

			/* make the new db the current one */
			db = new_db_z;

			/* so we can dtor this later */
			alloced_db = 1;
		}
	}

	/* get the collection */
	MAKE_STD_ZVAL(collection);
	MONGO_METHOD1(MongoDB, selectCollection, collection, db, *ns);

	/* query for the $id */
	MAKE_STD_ZVAL(query);
	array_init(query);
	add_assoc_zval(query, "_id", *id);
	zval_add_ref(id);

	/* return whatever's there */
	MONGO_METHOD1(MongoCollection, findOne, return_value, collection, query);

	/* cleanup */
	zval_ptr_dtor(&collection);
	zval_ptr_dtor(&query);
	if (alloced_db) {
		zval_ptr_dtor(&db);
	}
}
Exemplo n.º 17
0
/**
 * Returns the seconds between event triggering.
 * 
 * @return double
 * @return false   If the event has not been initialized
 */
PHP_METHOD(TimerEvent, getRepeat)
{
	event_object *obj = (event_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
	
	RETURN_DOUBLE(((ev_timer *)obj->watcher)->repeat);
}
Exemplo n.º 18
0
/** {{{ proto bool Win\Gdi\Window::endPaint( paint_data );
		Marks the end of painting in the specified window.
*/
PHP_METHOD( WinGdiWindow, endPaint )
{
	wingdi_devicecontext_object * dc_object;
	wingdi_window_object        * window_object = zend_object_store_get_object( getThis() TSRMLS_CC );
	HashTable                   * paint_data;
	PAINTSTRUCT                   paint_struct;

	WINGDI_ERROR_HANDLING();
	if ( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "h", &paint_data ) == FAILURE )
		return;
	WINGDI_RESTORE_ERRORS();

	// Error checking
	// Not sure about the error messages
	if ( ! zend_hash_exists( paint_data, "hdc", strlen( "hdc" ) + 1 ) )
	{
		php_error( E_ERROR, "no 'hdc' element found in array" );
		return;
	}
	else if ( ! zend_hash_exists( paint_data, "erase", strlen( "erase" ) + 1 ) )
	{
		php_error( E_ERROR, "no 'erase' element found in array" );
		return;
	}
	else if ( ! zend_hash_exists( paint_data, "paint", strlen( "paint" ) + 1 ) )
	{
		php_error( E_ERROR, "no 'paint' element found in array" );
		return;
	}
	else
	{
		zval ** hdc_element,
			 ** erase_element,
			 ** paint_element,
			 ** left = NULL, ** top = NULL, ** right = NULL, ** bottom = NULL;
		HashTable * paint_rect;

		zend_hash_find( paint_data, "hdc", strlen( "hdc" ) + 1, ( void ** ) &hdc_element );
		dc_object = ( wingdi_devicecontext_object * ) zend_objects_get_address( * hdc_element TSRMLS_CC );
		paint_struct.hdc = dc_object->hdc;

		zend_hash_find( paint_data, "erase", strlen( "erase" ) + 1, ( void ** ) &erase_element );
		paint_struct.fErase = Z_BVAL_PP( erase_element );

		zend_hash_find( paint_data, "paint", strlen( "paint" ) + 1, ( void ** ) &paint_element );
		if ( Z_TYPE_PP( paint_element ) != IS_ARRAY || zend_hash_num_elements( Z_ARRVAL_PP( paint_element ) ) < 4 )
		{
			php_error( E_ERROR, "expected an array of for elements for 'paint' element of array" );
			return;
		}
		paint_rect = Z_ARRVAL_PP( paint_element );
		// TODO: error checking
		zend_hash_index_find( paint_rect, 0, ( void ** ) &left );
		zend_hash_index_find( paint_rect, 1, ( void ** ) &top );
		zend_hash_index_find( paint_rect, 2, ( void ** ) &right );
		zend_hash_index_find( paint_rect, 3, ( void ** ) &bottom );
		paint_struct.rcPaint.left = Z_LVAL_PP( left );
		paint_struct.rcPaint.top = Z_LVAL_PP( top );
		paint_struct.rcPaint.right = Z_LVAL_PP( right );
		paint_struct.rcPaint.bottom = Z_LVAL_PP( bottom );

		RETURN_BOOL( EndPaint( window_object->window_handle, &paint_struct ) );
	}
}
Exemplo n.º 19
0
/**
 * Returns the time for the next trigger of the event, seconds.
 * 
 * @return double
 * @return false  if object has not been initialized
 */
PHP_METHOD(PeriodicEvent, getTime)
{
	event_object *obj = (event_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
	
	RETURN_DOUBLE(event_periodic_at(obj));
}
Exemplo n.º 20
0
  PHP_ME(lineObj, addXY, line_addXY_args, ZEND_ACC_PUBLIC)
  PHP_ME(lineObj, addXYZ, line_addXYZ_args, ZEND_ACC_PUBLIC)
  PHP_ME(lineObj, project, line_project_args, ZEND_ACC_PUBLIC)
  PHP_ME(lineObj, point, line_point_args, ZEND_ACC_PUBLIC)
  PHP_MALIAS(lineObj, get, point, line_point_args, ZEND_ACC_PUBLIC)
  PHP_ME(lineObj, set, line_set_args, ZEND_ACC_PUBLIC) {
    NULL, NULL, NULL
  }
};


void mapscript_create_line(lineObj *line, parent_object parent, zval *return_value TSRMLS_DC)
{
  php_line_object * php_line;
  object_init_ex(return_value, mapscript_ce_line);
  php_line = (php_line_object *)zend_object_store_get_object(return_value TSRMLS_CC);
  php_line->line = line;

  if (parent.val)
    php_line->is_ref = 1;

  php_line->parent = parent;
  MAPSCRIPT_ADDREF(parent.val);
}

static void mapscript_line_object_destroy(void *object TSRMLS_DC)
{
  php_line_object *php_line = (php_line_object *)object;

  MAPSCRIPT_FREE_OBJECT(php_line);
Exemplo n.º 21
0
/**
 * Returns the exit/trace status (see waitpid and sys/wait.h) caused by the child
 * ChildEvent::getRPid().
 * 
 * @return int
 * @return false  if object has not been initialized
 */
PHP_METHOD(ChildEvent, getRStatus)
{
	event_object *obj = (event_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
	
	RETURN_LONG(((ev_child *)obj->watcher)->rstatus);
}
Exemplo n.º 22
0
int php_amqp_set_read_timeout(amqp_connection_object *connection TSRMLS_DC);
int php_amqp_set_write_timeout(amqp_connection_object *connection TSRMLS_DC);

#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3
zend_object_handlers amqp_connection_object_handlers;
HashTable *amqp_connection_object_get_debug_info(zval *object, int *is_temp TSRMLS_DC) {
	zval *value;
	HashTable *debug_info;
	amqp_connection_object *connection;

	/* Let zend clean up for us: */
	*is_temp = 1;

	/* Get the envelope object from which to read */
	connection = (amqp_connection_object *)zend_object_store_get_object(object TSRMLS_CC);

	/* Keep the first number matching the number of entries in this table*/
	ALLOC_HASHTABLE(debug_info);
	ZEND_INIT_SYMTABLE_EX(debug_info, 6 + 1, 0);

	/* Start adding values */
	MAKE_STD_ZVAL(value);
	ZVAL_STRINGL(value, connection->login, strlen(connection->login), 1);
	zend_hash_add(debug_info, "login", sizeof("login"), &value, sizeof(zval *), NULL);

	MAKE_STD_ZVAL(value);
	ZVAL_STRINGL(value, connection->password, strlen(connection->password), 1);
	zend_hash_add(debug_info, "password", sizeof("password"), &value, sizeof(zval *), NULL);

	MAKE_STD_ZVAL(value);
Exemplo n.º 23
0
/**
 * Returns the interval which libev will check file status with stat().
 * 
 * @return double  seconds
 * @return false  if object has not been initialized
 */
PHP_METHOD(StatEvent, getInterval)
{
	event_object *obj = (event_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
	
	RETURN_DOUBLE(((ev_stat *)obj->watcher)->interval);
}
 * (c) Fabien Potencier <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

#include "event_dispatcher_main.h"
#include "event_dispatcher_internal_API.h"

static int ed_remove_listener_cb(void *, void *);
static void ed_listener_dtor(ed_listener *);
static int ed_sort_listeners(const zend_llist_element **, const zend_llist_element **);

int ed_add_listener(zval* ed_obj, char* eventName, int eventName_len, ed_listener* _listener TSRMLS_DC)
{
	event_dispatcher *ed = zend_object_store_get_object(ed_obj TSRMLS_CC);
	zend_llist **event = NULL;

	if (zend_hash_find(ed->events, eventName, eventName_len + 1, (void **)&event) == FAILURE) {
		event_dispatcher_llist *new_event = NULL;
		new_event = ecalloc(1, sizeof(event_dispatcher_llist));
		new_event->sorted = 0;
		zend_llist_init((zend_llist *)new_event, sizeof(ed_listener), (llist_dtor_func_t)ed_listener_dtor, 0); /* llist duplicates data */
		zend_hash_add(ed->events, eventName, eventName_len + 1, &new_event, sizeof(zend_llist *), NULL);
		event = (zend_llist **)&new_event;
	}

	zend_llist_add_element(*event, _listener);
	Z_ADDREF_P(_listener->zval_listener);

	return SUCCESS;
Exemplo n.º 25
0
#  define PDO_MYSQL_UNIX_ADDR PHP_MYSQL_UNIX_SOCK_ADDR
# else
#  if !PHP_WIN32
#   define PDO_MYSQL_UNIX_ADDR "/tmp/mysql.sock"
#  else
#   define PDO_MYSQL_UNIX_ADDR NULL
#  endif
# endif
#endif

#ifdef PDO_USE_MYSQLND
#include "ext/mysqlnd/mysqlnd_reverse_api.h"
static MYSQLND * pdo_mysql_convert_zv_to_mysqlnd(zval * zv TSRMLS_DC)
{
	if (Z_TYPE_P(zv) == IS_OBJECT && instanceof_function(Z_OBJCE_P(zv), php_pdo_get_dbh_ce() TSRMLS_CC)) {
		pdo_dbh_t * dbh = zend_object_store_get_object(zv TSRMLS_CC);

		if (!dbh || dbh->driver != &pdo_mysql_driver) {
			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Provided PDO instance is not using MySQL but %s", dbh->driver->driver_name);
			return NULL;
		}

		return ((pdo_mysql_db_handle *)dbh->driver_data)->server;
	}
	return NULL;
}

static MYSQLND_REVERSE_API pdo_mysql_reverse_api = {
	&pdo_mysql_module_entry,
	pdo_mysql_convert_zv_to_mysqlnd
};
Exemplo n.º 26
0
  PHP_ME(scalebarObj, __construct, NULL, ZEND_ACC_PUBLIC|ZEND_ACC_CTOR)
  PHP_ME(scalebarObj, __get, scalebar___get_args, ZEND_ACC_PUBLIC)
  PHP_ME(scalebarObj, __set, scalebar___set_args, ZEND_ACC_PUBLIC)
  PHP_MALIAS(scalebarObj, set, __set, NULL, ZEND_ACC_PUBLIC)
  PHP_ME(scalebarObj, updateFromString, scalebar_updateFromString_args, ZEND_ACC_PUBLIC)
  PHP_ME(scalebarObj, setImageColor, scalebar_setImageColor_args, ZEND_ACC_PUBLIC)
  PHP_ME(scalebarObj, free, NULL, ZEND_ACC_PUBLIC) {
    NULL, NULL, NULL
  }
};

void mapscript_create_scalebar(scalebarObj *scalebar, parent_object parent, zval *return_value TSRMLS_DC)
{
  php_scalebar_object * php_scalebar;
  object_init_ex(return_value, mapscript_ce_scalebar);
  php_scalebar = (php_scalebar_object *)zend_object_store_get_object(return_value TSRMLS_CC);
  php_scalebar->scalebar = scalebar;

  php_scalebar->parent = parent;
  MAPSCRIPT_ADDREF(parent.val);
}

static void mapscript_scalebar_object_destroy(void *object TSRMLS_DC)
{
  php_scalebar_object *php_scalebar = (php_scalebar_object *)object;

  MAPSCRIPT_FREE_OBJECT(php_scalebar);

  MAPSCRIPT_FREE_PARENT(php_scalebar->parent);
  MAPSCRIPT_DELREF(php_scalebar->color);
  MAPSCRIPT_DELREF(php_scalebar->backgroundcolor);
Exemplo n.º 27
0
# include "win32/unistd.h"
#else
# include <unistd.h>
#endif

#include "php_amqp.h"
#include "amqp_connection.h"

#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 3
zend_object_handlers amqp_channel_object_handlers;
HashTable *amqp_channel_object_get_debug_info(zval *object, int *is_temp TSRMLS_DC) {
	zval *value;
	HashTable *debug_info;

	/* Get the envelope object from which to read */
	amqp_channel_object *channel = (amqp_channel_object *)zend_object_store_get_object(object TSRMLS_CC);

	/* Let zend clean up for us: */
	*is_temp = 1;

	/* Keep the first number matching the number of entries in this table*/
	ALLOC_HASHTABLE(debug_info);
	ZEND_INIT_SYMTABLE_EX(debug_info, 3 + 1, 0);

	/* Start adding values */
	MAKE_STD_ZVAL(value);
	ZVAL_LONG(value, channel->channel_id);
	zend_hash_add(debug_info, "channel_id", sizeof("channel_id"), &value, sizeof(zval *), NULL);

	MAKE_STD_ZVAL(value);
	ZVAL_LONG(value, channel->prefetch_count);
Exemplo n.º 28
0
PHP_PANGO_API zend_class_entry* php_pango_get_layoutline_ce()
{
	return pango_ce_pangolayoutline;
}

/*  {{{ php_pango_make_layoutline_zval 
	Convenience function to handle setting all the properties etc */
PHP_PANGO_API zval* php_pango_make_layoutline_zval(PangoLayoutLine *line, zval *layout TSRMLS_DC)
{
	zval *return_value, *length, *is_paragraph_start, *resolved_dir;
	pango_layoutline_object *layoutline_object;

	MAKE_STD_ZVAL(return_value);
	object_init_ex(return_value, pango_ce_pangolayoutline);
	layoutline_object = (pango_layoutline_object *)zend_object_store_get_object(return_value TSRMLS_CC);
	layoutline_object->line = line;

	/* Optionally cache the PangoLayout zval for later */
	if(layout != NULL) {
		Z_ADDREF_P(layout);
		layoutline_object->layout_zval = layout;
	}

	MAKE_STD_ZVAL(length);
	ZVAL_LONG(length, line->length);
	zend_hash_update(Z_OBJPROP_P(return_value), "length", sizeof("length"), (void **) &length, sizeof(zval *), NULL);

	MAKE_STD_ZVAL(is_paragraph_start);
	ZVAL_BOOL(is_paragraph_start, line->is_paragraph_start);
	zend_hash_update(Z_OBJPROP_P(return_value), "is_paragraph_start", sizeof("is_paragraph_start"), (void **) &is_paragraph_start, sizeof(zval *), NULL);
Exemplo n.º 29
0
/* {{{ proto void DOMElement::__construct(string name, [string value], [string uri]); */
PHP_METHOD(domelement, __construct)
{

	zval *id;
	xmlNodePtr nodep = NULL, oldnode = NULL;
	dom_object *intern;
	char *name, *value = NULL, *uri = NULL;
	char *localname = NULL, *prefix = NULL;
	int errorcode = 0, uri_len = 0;
	int name_len, value_len = 0, name_valid;
	xmlNsPtr nsptr = NULL;
	zend_error_handling error_handling;

	zend_replace_error_handling(EH_THROW, dom_domexception_class_entry, &error_handling TSRMLS_CC);
	if (zend_parse_method_parameters(ZEND_NUM_ARGS() TSRMLS_CC, getThis(), "Os|s!s", &id, dom_element_class_entry, &name, &name_len, &value, &value_len, &uri, &uri_len) == FAILURE) {
		zend_restore_error_handling(&error_handling TSRMLS_CC);
		return;
	}
	zend_restore_error_handling(&error_handling TSRMLS_CC);

	name_valid = xmlValidateName((xmlChar *) name, 0);
	if (name_valid != 0) {
		php_dom_throw_error(INVALID_CHARACTER_ERR, 1 TSRMLS_CC);
		RETURN_FALSE;
	}

	/* Namespace logic is separate and only when uri passed in to insure no BC breakage */
	if (uri_len > 0) {
		errorcode = dom_check_qname(name, &localname, &prefix, uri_len, name_len);
		if (errorcode == 0) {
			nodep = xmlNewNode (NULL, (xmlChar *)localname);
			if (nodep != NULL && uri != NULL) {
				nsptr = dom_get_ns(nodep, uri, &errorcode, prefix);
				xmlSetNs(nodep, nsptr);
			}
		}
		xmlFree(localname);
		if (prefix != NULL) {
			xmlFree(prefix);
		}
		if (errorcode != 0) {
			if (nodep != NULL) {
				xmlFreeNode(nodep);
			}
			php_dom_throw_error(errorcode, 1 TSRMLS_CC);
			RETURN_FALSE;
		}
	} else {
	    /* If you don't pass a namespace uri, then you can't set a prefix */
	    localname = xmlSplitQName2((xmlChar *)name, (xmlChar **) &prefix);
	    if (prefix != NULL) {
			xmlFree(localname);
			xmlFree(prefix);
	        php_dom_throw_error(NAMESPACE_ERR, 1 TSRMLS_CC);
	        RETURN_FALSE;
	    }
		nodep = xmlNewNode(NULL, (xmlChar *) name);
	}

	if (!nodep) {
		php_dom_throw_error(INVALID_STATE_ERR, 1 TSRMLS_CC);
		RETURN_FALSE;
	}

	if (value_len > 0) {
		xmlNodeSetContentLen(nodep, (xmlChar *) value, value_len);
	}

	intern = (dom_object *)zend_object_store_get_object(id TSRMLS_CC);
	if (intern != NULL) {
		oldnode = dom_object_get_node(intern);
		if (oldnode != NULL) {
			php_libxml_node_free_resource(oldnode  TSRMLS_CC);
		}
		php_libxml_increment_node_ptr((php_libxml_node_object *)intern, nodep, (void *)intern TSRMLS_CC);
	}
}
Exemplo n.º 30
0
PHP_METHOD(SpotifyPlaylist, __toString)
{
	spotifyplaylist_object *p = (spotifyplaylist_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
	RETURN_STRING(sp_playlist_name(p->playlist), 1);
}