Esempio n. 1
0
/* {{{ proto mixed|NULL SplDoublyLinkedList::current()
   Return current datastructure entry */
SPL_METHOD(SplDoublyLinkedList, current)
{
	spl_dllist_object     *intern  = Z_SPLDLLIST_P(getThis());
	spl_ptr_llist_element *element = intern->traverse_pointer;

	if (zend_parse_parameters_none() == FAILURE) {
		return;
	}

	if (element == NULL || Z_ISUNDEF(element->data)) {
		RETURN_NULL();
	} else {
		zval *value = &element->data;

		ZVAL_DEREF(value);
		ZVAL_COPY(return_value, value);
	}
}
static PHP_METHOD(midgard_connection, get_user)
{
	RETVAL_NULL();
	MidgardConnection *mgd =__midgard_connection_get_ptr(getThis());
	CHECK_MGD(mgd);

	if (zend_parse_parameters_none() == FAILURE)
		return;

	MidgardUser *user = midgard_connection_get_user(mgd);

	if (user == NULL)
		RETURN_NULL();

	g_object_ref(user); // this is a direct-pointer: we need to "ref" it explicitly

	php_midgard_gobject_new_with_gobject(return_value, php_midgard_user_class, G_OBJECT(user), TRUE TSRMLS_CC);
}
PHP_METHOD(DefaultColumn, isStatic)
{
  cassandra_column *self;
  const CassValue  *value;
  const char       *str;
  size_t            str_len;

  if (zend_parse_parameters_none() == FAILURE) {
    return;
  }

  self  = PHP_CASSANDRA_GET_COLUMN(getThis());

  value = cass_column_meta_field_by_name(self->meta, "type");

  ASSERT_SUCCESS_BLOCK(cass_value_get_string(value, &str, &str_len),
    RETURN_FALSE;
  );
Esempio n. 4
0
/* {{{ proto int label.free()
   Free the object */
PHP_METHOD(labelObj, free)
{
  zval *zobj = getThis();
  php_label_object *php_label;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters_none() == FAILURE) {
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    return;
  }
  PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

  php_label = (php_label_object *) zend_object_store_get_object(zobj TSRMLS_CC);

  MAPSCRIPT_DELREF(php_label->color);
  MAPSCRIPT_DELREF(php_label->outlinecolor);
  MAPSCRIPT_DELREF(php_label->shadowcolor);
}
Esempio n. 5
0
/* {{{ proto void __construct()
   Create a new label instance. */
PHP_METHOD(labelObj, __construct)
{
  php_label_object *php_label;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters_none() == FAILURE) {
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    return;
  }
  PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

  php_label = (php_label_object *)zend_object_store_get_object(getThis() TSRMLS_CC);

  if ((php_label->label = labelObj_new()) == NULL) {
    mapscript_throw_exception("Unable to construct labelObj." TSRMLS_CC);
    return;
  }
}
Esempio n. 6
0
/* {{{ proto bool GmagickDraw::getStrokeAntialias()
        Returns the current stroke antialias setting. Stroked outlines are antialiased by default.  When antialiasing is disabled stroked pixels are thresholded to determine if the stroke color or underlying canvas color should be used.
*/
PHP_METHOD(gmagickdraw, getstrokeantialias)
{
        php_gmagickdraw_object *internd;
        MagickBool status;

        if (zend_parse_parameters_none() == FAILURE) {
                return;
        }
        
        internd = (php_gmagickdraw_object *)zend_object_store_get_object(getThis() TSRMLS_CC);
        status = DrawGetStrokeAntialias(internd->drawing_wand);

        if (status == MagickFalse) {
                RETURN_FALSE;
        } else {
                RETURN_TRUE;
        }
}
Esempio n. 7
0
U_CFUNC PHP_FUNCTION(intlcal_get_available_locales)
{
	intl_error_reset(NULL TSRMLS_CC);

	if (zend_parse_parameters_none() == FAILURE) {
		intl_error_set(NULL, U_ILLEGAL_ARGUMENT_ERROR,
			"intlcal_get_available_locales: bad arguments", 0 TSRMLS_CC);
		RETURN_FALSE;
	}

	int32_t count;
	const Locale *availLocales = Calendar::getAvailableLocales(count);
	array_init(return_value);
	for (int i = 0; i < count; i++) {
		Locale locale = availLocales[i];
		add_next_index_string(return_value, locale.getName());
	}
}
Esempio n. 8
0
PHP_METHOD(DefaultColumn, isStatic)
{
  cassandra_column*          self;
  const CassSchemaMetaField* field;
  const CassValue*           value;
  const char*                str;
  size_t                     str_len;

  if (zend_parse_parameters_none() == FAILURE) {
    return;
  }

  self  = (cassandra_column*) zend_object_store_get_object(getThis() TSRMLS_CC);
  field = cass_schema_meta_get_field(self->meta, "type");
  value = cass_schema_meta_field_value(field);

  ASSERT_SUCCESS_BLOCK(cass_value_get_string(value, &str, &str_len),
    RETURN_FALSE;
  );
Esempio n. 9
0
static PHP_METHOD(midgard_query_builder, execute)
{
	RETVAL_FALSE;
	MidgardConnection *mgd = mgd_handle(TSRMLS_C);
	CHECK_MGD(mgd);

	if (zend_parse_parameters_none() == FAILURE)
		return;

	_GET_BUILDER_OBJECT;
	zend_class_entry *ce = php_gobject->user_ce;

	if (ce == NULL) {
		php_error(E_WARNING, "Query Builder instance not associated with any class");
		return;
	}

	guint i, n_objects;
	GObject **objects = midgard_query_builder_execute(builder, &n_objects);

	array_init(return_value);

	if (!objects)
		return;

	/* TODO: Should use iterator, instead, and create objects lazily */
	/* Initialize zend objects for the same class which was used to initialize Query Builder */
	for (i = 0; i < n_objects; i++) {
		GObject *gobject = objects[i];
		zval *zobject;

		/* TODO: Simplify code below. If possible. */
		MAKE_STD_ZVAL(zobject);
		object_init_ex(zobject, ce); /* Initialize new object for which QB has been created for */
		MGD_PHP_SET_GOBJECT(zobject, gobject); // inject our gobject
		zend_call_method_with_0_params(&zobject, ce, &ce->constructor, "__construct", NULL); /* Call class constructor on given instance */

		zend_hash_next_index_insert(HASH_OF(return_value), &zobject, sizeof(zval *), NULL);
	}

	if (objects)
		g_free(objects);
}
Esempio n. 10
0
static void php_mongo_db_profiling_level(INTERNAL_FUNCTION_PARAMETERS, int get)
{
	long level;
	zval *cmd, *cmd_return;
	zval **ok;
	mongo_db *db;

	if (get) {
		if (zend_parse_parameters_none() == FAILURE) {
			return;
		}
		level = -1;
	} else {
		if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &level) == FAILURE) {
			return;
		}
	}

	PHP_MONGO_GET_DB(getThis());

	MAKE_STD_ZVAL(cmd);
	array_init(cmd);
	add_assoc_long(cmd, "profile", level);

	cmd_return = php_mongo_runcommand(db->link, &db->read_pref, Z_STRVAL_P(db->name), Z_STRLEN_P(db->name), cmd, NULL, 0, NULL TSRMLS_CC);

	zval_ptr_dtor(&cmd);

	if (!cmd_return) {
		return;
	}

	if (
		zend_hash_find(HASH_P(cmd_return), "ok", 3, (void**)&ok) == SUCCESS &&
		((Z_TYPE_PP(ok) == IS_BOOL && Z_BVAL_PP(ok)) || Z_DVAL_PP(ok) == 1)
	) {
		zend_hash_find(HASH_P(cmd_return), "was", 4, (void**)&ok);
		RETVAL_ZVAL(*ok, 1, 0);
	} else {
		RETVAL_NULL();
	}
	zval_ptr_dtor(&cmd_return);
}
Esempio n. 11
0
static PHP_METHOD(midgard_model_reference, get_id)
{
	if (zend_parse_parameters_none() == FAILURE)
		return;

	GError *error = NULL;
	MidgardModelReference *model = MIDGARD_MODEL_REFERENCE(__php_gobject_ptr(getThis()));
	const gchar *id = midgard_model_reference_get_id(model, &error);
	if (error) {
		zend_throw_exception_ex(ce_midgard_error_exception, 0 TSRMLS_CC,
				"Failed to get reference id. %s", error && error->message ? error->message : "Unknown reason");
		return;
	}

	if (id == NULL)
		RETURN_NULL();
		
	RETURN_STRING(id, 1);
}
Esempio n. 12
0
static PHP_METHOD(midgard_model, get_name)
{
	if (zend_parse_parameters_none() == FAILURE)
		return;

	GError *error = NULL;
	MidgardModel *model = MIDGARD_MODEL(__php_gobject_ptr(getThis()));
	const gchar *name = midgard_model_get_name(model, &error);
	if (error) {
		zend_throw_exception_ex(ce_midgard_error_exception, 0 TSRMLS_CC,
				"Failed to get model. %s", error && error->message ? error->message : "Unknown reason");
		return;
	}

	if (name == NULL)
		RETURN_NULL();
		
	RETURN_STRING(name, 1);
}
Esempio n. 13
0
/* proto void free()
   Free the object */
PHP_METHOD(labelCacheMemberObj, free)
{
    zval *zobj = getThis();
    php_labelcachemember_object *php_labelcachemember;

    PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
    if (zend_parse_parameters_none() == FAILURE) {
        PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
        return;
    }
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    
    php_labelcachemember = (php_labelcachemember_object *) zend_object_store_get_object(zobj TSRMLS_CC);

    MAPSCRIPT_DELREF(php_labelcachemember->point);
    MAPSCRIPT_DELREF(php_labelcachemember->label);
    MAPSCRIPT_DELREF(php_labelcachemember->styles);
    MAPSCRIPT_DELREF(php_labelcachemember->poly);
}
static PHP_METHOD(midgard_config, create_blobdir)
{
	RETVAL_FALSE;
	gboolean rv;
	zval *zval_object = getThis();

	if (zend_parse_parameters_none() == FAILURE)
		return;

	MidgardConfig *config = NULL;

	if (zval_object) {
		config = (MidgardConfig *) __php_gobject_ptr(zval_object);
	}

	rv = midgard_config_create_blobdir(config);

	RETURN_BOOL(rv);
}
Esempio n. 15
0
/* {{{ proto array ImagickPixel::getHSL()
	Returns the normalized HSL color of the pixel wand in an array with the keys "hue", "saturation", and "luminosity".
*/
PHP_METHOD(imagickpixel, gethsl)
{
    php_imagickpixel_object *internp;
    double hue, saturation, luminosity;

    if (zend_parse_parameters_none() == FAILURE) {
        return;
    }

    internp = Z_IMAGICKPIXEL_P(getThis());

    PixelGetHSL(internp->pixel_wand, &hue, &saturation, &luminosity);

    array_init(return_value);
    add_assoc_double(return_value, "hue", hue);
    add_assoc_double(return_value, "saturation", saturation);
    add_assoc_double(return_value, "luminosity", luminosity);
    return;
}
Esempio n. 16
0
/* {{{ Mosquitto\Client::disconnect() */
PHP_METHOD(Mosquitto_Client, disconnect)
{
	mosquitto_client_object *object;
	int retval;

	PHP_MOSQUITTO_ERROR_HANDLING();
	if (zend_parse_parameters_none() == FAILURE) {
		PHP_MOSQUITTO_RESTORE_ERRORS();
		return;
	}
	PHP_MOSQUITTO_RESTORE_ERRORS();

	object = (mosquitto_client_object *) mosquitto_client_object_get(getThis() TSRMLS_CC);

	retval = mosquitto_disconnect(object->client);
	php_mosquitto_exit_loop(object);

	php_mosquitto_handle_errno(retval, errno TSRMLS_CC);
}
Esempio n. 17
0
/* {{{ proto WriteConcernError WriteResult::getWriteConcernError()
   Return any write concern error that occurred */
PHP_METHOD(WriteResult, getWriteConcernError)
{
	bson_iter_t iter, child;
	php_phongo_writeresult_t *intern;
	SUPPRESS_UNUSED_WARNING(return_value_ptr) SUPPRESS_UNUSED_WARNING(return_value_used)


	intern = Z_WRITERESULT_OBJ_P(getThis());

	if (zend_parse_parameters_none() == FAILURE) {
		return;
	}

	if (bson_iter_init_find(&iter, intern->reply, "writeConcernErrors") && BSON_ITER_HOLDS_ARRAY(&iter) && bson_iter_recurse(&iter, &child)) {
		while (bson_iter_next(&child)) {
			bson_t cbson;
			uint32_t len;
			const uint8_t *data;

			if (!BSON_ITER_HOLDS_DOCUMENT(&child)) {
				continue;
			}

			bson_iter_document(&child, &len, &data);

			if (!bson_init_static(&cbson, data, len)) {
				continue;
			}

			object_init_ex(return_value, php_phongo_writeconcernerror_ce);

			if (!phongo_writeconcernerror_init(return_value, &cbson TSRMLS_CC)) {
#if PHP_VERSION_ID >= 70000
				zval_ptr_dtor(return_value);
#else
				zval_ptr_dtor(&return_value);
#endif
			}

			return;
		}
	}
}
Esempio n. 18
0
/* {{{ proto MongoDB\WriteResult WriteException::getWriteResult()
   Returns the WriteResult from the failed write operation. */
PHP_METHOD(WriteException, getWriteResult)
{
	zend_error_handling       error_handling;
	zval *writeresult;


	zend_replace_error_handling(EH_THROW, phongo_exception_from_phongo_domain(PHONGO_ERROR_INVALID_ARGUMENT), &error_handling TSRMLS_CC);

	if (zend_parse_parameters_none() == FAILURE) {
		zend_restore_error_handling(&error_handling TSRMLS_CC);
		return;
	}
	zend_restore_error_handling(&error_handling TSRMLS_CC);


	writeresult = zend_read_property(php_phongo_writeexception_ce, getThis(), ZEND_STRL("writeResult"), 0 TSRMLS_CC);

	RETURN_ZVAL(writeresult, 1, 0);
}
Esempio n. 19
0
/* {{{ proto mixed SplDoublyLinkedList::bottom()
	   Peek at the bottom element of the SplDoublyLinkedList */
SPL_METHOD(SplDoublyLinkedList, bottom)
{
	zval *value;
	spl_dllist_object *intern;

	if (zend_parse_parameters_none() == FAILURE) {
		return;
	}

	intern = Z_SPLDLLIST_P(ZEND_THIS);
	value  = spl_ptr_llist_first(intern->llist);

	if (value == NULL || Z_ISUNDEF_P(value)) {
		zend_throw_exception(spl_ce_RuntimeException, "Can't peek at an empty datastructure", 0);
		return;
	}

	ZVAL_COPY_DEREF(return_value, value);
}
Esempio n. 20
0
/* {{{ proto mixed SplDoublyLinkedList::top()
	   Peek at the top element of the SplDoublyLinkedList */
SPL_METHOD(SplDoublyLinkedList, top)
{
	zval *value;
	spl_dllist_object *intern;

	if (zend_parse_parameters_none() == FAILURE) {
		return;
	}

	intern = Z_SPLDLLIST_P(getThis());
	value = spl_ptr_llist_last(intern->llist);

	if (value == NULL || Z_ISUNDEF_P(value)) {
		zend_throw_exception(spl_ce_RuntimeException, "Can't peek at an empty datastructure", 0);
		return;
	}

	RETURN_ZVAL(value, 1, 0);
}
static PHP_METHOD(midgard_query_result, get_column_names)
{
	if (zend_parse_parameters_none() == FAILURE)
		return;

	guint n_names;
	MidgardQueryResult *result = MIDGARD_QUERY_RESULT(__php_gobject_ptr(getThis()));
	gchar **names = midgard_query_result_get_column_names(result, &n_names, NULL);

	array_init(return_value);
	if (names == NULL)
		return;

	guint i;
	for (i = 0; i < n_names; i++) {
		add_index_string(return_value, i, (gchar *)names[i], 1);
	}
	
	g_free(names);	
}
Esempio n. 22
0
/* {{{ proto int scalebar.free()
   Free the object */
PHP_METHOD(scalebarObj, free)
{
  zval *zobj = getThis();
  php_scalebar_object *php_scalebar;

  PHP_MAPSCRIPT_ERROR_HANDLING(TRUE);
  if (zend_parse_parameters_none() == FAILURE) {
    PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);
    return;
  }
  PHP_MAPSCRIPT_RESTORE_ERRORS(TRUE);

  php_scalebar = (php_scalebar_object *) zend_object_store_get_object(zobj TSRMLS_CC);

  MAPSCRIPT_DELREF(php_scalebar->color);
  MAPSCRIPT_DELREF(php_scalebar->backgroundcolor);
  MAPSCRIPT_DELREF(php_scalebar->outlinecolor);
  MAPSCRIPT_DELREF(php_scalebar->imagecolor);
  MAPSCRIPT_DELREF(php_scalebar->label);
}
Esempio n. 23
0
PHP_METHOD(Rows, first)
{
  HashPointer ptr;
  zval **entry;
  cassandra_rows* self = NULL;

  if (zend_parse_parameters_none() == FAILURE) {
    return;
  }

  self = (cassandra_rows*) zend_object_store_get_object(getThis() TSRMLS_CC);

  zend_hash_get_pointer(Z_ARRVAL_P(self->rows), &ptr);
  zend_hash_internal_pointer_reset(Z_ARRVAL_P(self->rows));

  if (zend_hash_get_current_data(Z_ARRVAL_P(self->rows), (void **) &entry) == SUCCESS)
    RETVAL_ZVAL(*entry, 1, 0);

  zend_hash_set_pointer(Z_ARRVAL_P(self->rows), &ptr);
}
Esempio n. 24
0
static PHP_METHOD(midgard_object_reference, get_workspace)
{
	if (zend_parse_parameters_none() == FAILURE)
		return;

	MidgardObjectReference *reference = MIDGARD_OBJECT_REFERENCE(__php_gobject_ptr(getThis()));
	GError *error = NULL;
	MidgardWorkspace *workspace = midgard_object_reference_get_workspace(reference, &error);
	if (error) {
		zend_throw_exception_ex(ce_midgard_error_exception, 0 TSRMLS_CC,
				"Failed to get workspace. %s", error && error->message ? error->message : "Unknown reason");
		return;
	}

	if (workspace == NULL)
		RETURN_NULL();

	object_init_ex(return_value, php_midgard_workspace_class);
	MGD_PHP_SET_GOBJECT(return_value, G_OBJECT(workspace));
}
Esempio n. 25
0
/* {{{ proto string SplDoublyLinkedList::serialize()
 Serializes storage */
SPL_METHOD(SplDoublyLinkedList, serialize)
{
	spl_dllist_object     *intern   = Z_SPLDLLIST_P(getThis());
	smart_str              buf      = {0};
	spl_ptr_llist_element *current  = intern->llist->head, *next;
	zval                   flags;
	php_serialize_data_t   var_hash;

	if (zend_parse_parameters_none() == FAILURE) {
		return;
	}

	PHP_VAR_SERIALIZE_INIT(var_hash);

	/* flags */
	ZVAL_LONG(&flags, intern->flags);
	php_var_serialize(&buf, &flags, &var_hash);
	zval_ptr_dtor(&flags);

	/* elements */
	while (current) {
		smart_str_appendc(&buf, ':');
		next = current->next;

		php_var_serialize(&buf, &current->data, &var_hash);

		current = next;
	}

	smart_str_0(&buf);

	/* done */
	PHP_VAR_SERIALIZE_DESTROY(var_hash);

	if (buf.s) {
		RETURN_STR(buf.s);
	} else {
		RETURN_NULL();
	}
	
} /* }}} */
Esempio n. 26
0
/* {{{ proto Spoofchecker Spoofchecker::__construct()
 * Spoofchecker object constructor.
 */
PHP_METHOD(Spoofchecker, __construct)
{
	int checks;
	SPOOFCHECKER_METHOD_INIT_VARS;

	if (zend_parse_parameters_none() == FAILURE) {
		return;
	}

	SPOOFCHECKER_METHOD_FETCH_OBJECT_NO_CHECK;

	co->uspoof = uspoof_open(SPOOFCHECKER_ERROR_CODE_P(co));
	INTL_CTOR_CHECK_STATUS(co, "spoofchecker: unable to open ICU Spoof Checker");

	/* Single-script enforcement is on by default. This fails for languages
	 like Japanese that legally use multiple scripts within a single word,
	 so we turn it off.
	*/
	checks = uspoof_getChecks(co->uspoof, SPOOFCHECKER_ERROR_CODE_P(co));
	uspoof_setChecks(co->uspoof, checks & ~USPOOF_SINGLE_SCRIPT, SPOOFCHECKER_ERROR_CODE_P(co));
}
Esempio n. 27
0
/* {{{ proto void accelerator_reset()
   Request that the contents of the opcode cache to be reset */
static ZEND_FUNCTION(opcache_reset)
{
	if (zend_parse_parameters_none() == FAILURE) {
		RETURN_FALSE;
	}

	if (!validate_api_restriction()) {
		RETURN_FALSE;
	}

	if ((!ZCG(enabled) || !accel_startup_ok || !ZCSG(accelerator_enabled))
#if ENABLE_FILE_CACHE_FALLBACK
	&& !fallback_process
#endif
	) {
		RETURN_FALSE;
	}

	zend_accel_schedule_restart(ACCEL_RESTART_USER);
	RETURN_TRUE;
}
Esempio n. 28
0
/* {{{ proto bool SessionHandler::close()
   Wraps the old close handler */
PHP_METHOD(SessionHandler, close)
{
	int ret;

	PS_SANITY_CHECK_IS_OPEN;

	// don't return on failure, since not closing the default handler
	// could result in memory leaks or other nasties
	zend_parse_parameters_none();

	PS(mod_user_is_open) = 0;

	zend_try {
		ret = PS(default_mod)->s_close(&PS(mod_data));
	} zend_catch {
		PS(session_status) = php_session_none;
		zend_bailout();
	} zend_end_try();

	RETVAL_BOOL(SUCCESS == ret);
}
Esempio n. 29
0
static PHP_METHOD(midgard_query_builder, execute)
{
	RETVAL_FALSE;
	MidgardConnection *mgd = mgd_handle(TSRMLS_C);
	CHECK_MGD(mgd);

	if (zend_parse_parameters_none() == FAILURE)
		return;

	_GET_BUILDER_OBJECT;
	zend_class_entry *ce = php_gobject->user_ce;

	if (ce == NULL) {
		php_error(E_WARNING, "Query Builder instance not associated with any class");
		return;
	}

	guint i, n_objects;
	GObject **objects = midgard_query_builder_execute(builder, &n_objects);

	array_init(return_value);

	if (!objects)
		return;

	/* TODO: Should use iterator, instead, and create objects lazily */
	for (i = 0; i < n_objects; i++) {
		GObject *gobject = objects[i];

		zval *zobject;
		MAKE_STD_ZVAL(zobject);

		php_midgard_gobject_new_with_gobject(zobject, ce, gobject, TRUE TSRMLS_CC);

		zend_hash_next_index_insert(HASH_OF(return_value), &zobject, sizeof(zval *), NULL);
	}

	if (objects)
		g_free(objects);
}
static PHP_METHOD(midgard_query_row, get_values)
{
	if (zend_parse_parameters_none() == FAILURE)
		                return;

	MidgardQueryRow *row = MIDGARD_QUERY_ROW(__php_gobject_ptr(getThis()));
	GValueArray *varray = midgard_query_row_get_values(row, NULL); 
	array_init (return_value);
	if (varray == NULL)
		return;

	guint i;
	for (i = 0; i < varray->n_values; i++) {
		GValue *val = g_value_array_get_nth(varray, i);
		zval *z_val;
		MAKE_STD_ZVAL(z_val);
		php_midgard_gvalue2zval(val, z_val TSRMLS_CC);
		add_index_zval(return_value, i, z_val);
	}

	g_value_array_free (varray);
}