return read;
}
-static STATUS php_pqlob_stream_close(php_stream *stream, int close_handle TSRMLS_DC)
+static ZEND_RESULT_CODE php_pqlob_stream_close(php_stream *stream, int close_handle TSRMLS_DC)
{
return SUCCESS;
}
return SUCCESS;
}
-static STATUS php_pqlob_stream_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC)
+static ZEND_RESULT_CODE php_pqlob_stream_seek(php_stream *stream, off_t offset, int whence, off_t *newoffset TSRMLS_DC)
{
- STATUS rv = FAILURE;
+ ZEND_RESULT_CODE rv = FAILURE;
php_pqlob_object_t *obj = stream->abstract;
if (obj) {
zend_error_handling zeh;
zval *ztxn;
long mode = INV_WRITE|INV_READ, loid = InvalidOid;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|ll", &ztxn, php_pqtxn_class_entry, &loid, &mode);
zend_restore_error_handling(&zeh TSRMLS_CC);
if (SUCCESS == rv) {
+ php_pqlob_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
php_pqtxn_object_t *txn_obj = zend_object_store_get_object(ztxn TSRMLS_CC);
- if (!txn_obj->intern) {
+ if (obj->intern) {
+ throw_exce(EX_BAD_METHODCALL TSRMLS_CC, "pq\\LOB already initialized");
+ } else if (!txn_obj->intern) {
throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Transaction not initialized");
} else if (!txn_obj->intern->open) {
throw_exce(EX_RUNTIME TSRMLS_CC, "pq\\Transation already closed");
}
if (loid == InvalidOid) {
- throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to create large object with mode '%s' (%s)", strmode(mode), PHP_PQerrorMessage(txn_obj->intern->conn->intern->conn));
+ throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to create large object with mode '%s' (%s)", php_pq_strmode(mode), PHP_PQerrorMessage(txn_obj->intern->conn->intern->conn));
} else {
int lofd = lo_open(txn_obj->intern->conn->intern->conn, loid, mode);
if (lofd < 0) {
- throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to open large object with oid=%u with mode '%s' (%s)", loid, strmode(mode), PHP_PQerrorMessage(txn_obj->intern->conn->intern->conn));
+ throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to open large object with oid=%u with mode '%s' (%s)", loid, php_pq_strmode(mode), PHP_PQerrorMessage(txn_obj->intern->conn->intern->conn));
} else {
- php_pqlob_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
-
obj->intern = ecalloc(1, sizeof(*obj->intern));
obj->intern->lofd = lofd;
obj->intern->loid = loid;
zend_error_handling zeh;
char *data_str;
int data_len;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data_str, &data_len);
zend_error_handling zeh;
long length = 0x1000;
zval *zread = NULL;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|lz!", &length, &zread);
static PHP_METHOD(pqlob, seek) {
zend_error_handling zeh;
long offset, whence = SEEK_SET;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l|l", &offset, &whence);
ZEND_END_ARG_INFO();
static PHP_METHOD(pqlob, tell) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
static PHP_METHOD(pqlob, truncate) {
zend_error_handling zeh;
long length = 0;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &length);
{0}
};
+PHP_MSHUTDOWN_FUNCTION(pqlob)
+{
+ zend_hash_destroy(&php_pqlob_object_prophandlers);
+ return SUCCESS;
+}
+
PHP_MINIT_FUNCTION(pqlob)
{
zend_class_entry ce = {0};