cvs: php4 /ext/pgsql pgsql.c php_pgsql.h

From: Date: Thu, 18 Jan 2001 22:17:05 +0000
Subject: cvs: php4 /ext/pgsql pgsql.c php_pgsql.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-3690@lists.php.net to get a copy of this message
derick Thu Jan 18 14:17:05 2001 EDT Modified files: /php4/ext/pgsql pgsql.c php_pgsql.h Log: - Added the pg_lolseek function, which allows for arbitrary seeking within a large object, and the pg_lotell call, which can be used to find the current file offset for a large object (Submitted by: Adam Haberlach <adam@newsnipple.com>). @- Added the pg_lolseek and pg_lotell functions (Derick) Index: php4/ext/pgsql/pgsql.c diff -u php4/ext/pgsql/pgsql.c:1.82 php4/ext/pgsql/pgsql.c:1.83 --- php4/ext/pgsql/pgsql.c:1.82 Thu Jan 4 03:15:35 2001 +++ php4/ext/pgsql/pgsql.c Thu Jan 18 14:17:05 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pgsql.c,v 1.82 2001/01/04 11:15:35 jah Exp $ */ +/* $Id: pgsql.c,v 1.83 2001/01/18 22:17:05 derick Exp $ */ #include <stdlib.h> @@ -75,6 +75,8 @@ PHP_FE(pg_loreadall, NULL) PHP_FE(pg_loimport, NULL) PHP_FE(pg_loexport, NULL) + PHP_FE(pg_lolseek, NULL) + PHP_FE(pg_lotell, NULL) PHP_FE(pg_put_line, NULL) PHP_FE(pg_end_copy, NULL) #if HAVE_PQCLIENTENCODING @@ -1733,6 +1735,59 @@ } else { RETURN_FALSE; } +} +/* }}} */ + +/* {{{ proto int pg_lolseek(int objoid, int offset, int whence) + Seek into a postgres large object*/ +PHP_FUNCTION(pg_lolseek) { + val **pgsql_lofp, **seek_offset, **seek_whence; + gLofp *pgsql; + + switch(ZEND_NUM_ARGS()) { + case 3: + if (zend_get_parameters_ex(3, &pgsql_lofp, &seek_offset, &seek_whence)==FAILURE) { + RETURN_FALSE; + } + convert_to_long_ex(seek_offset); + convert_to_long_ex(seek_whence); + break; + default: + WRONG_PARAM_COUNT; + break; + } + + ZEND_FETCH_RESOURCE(pgsql, pgLofp *, pgsql_lofp, -1, "PostgreSQL large object", le_lofp); + if (lo_lseek((PGconn *)pgsql->conn, pgsql->lofd, Z_STRVAL_PP(seek_offset), Z_STRVAL_PP(seek_whence))) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } +} +/* }}} */ + +/* {{{ proto int pg_tell(int objoid) + return current offset into large object */ +PHP_FUNCTION(pg_lotell) { + long int offset; + zval **pgsql_lofp; + pgLofp *pgsql; + + switch(ZEND_NUM_ARGS()) { + case 1: + if (zend_get_parameters_ex(1, &pgsql_lofp)==FAILURE) { + RETURN_FALSE; + } + break; + default: + WRONG_PARAM_COUNT; + break; + } + + END_FETCH_RESOURCE(pgsql, pgLofp *, pgsql_lofp, -1, "PostgreSQL large object", le_lofp); + + ffset = lo_tell((PGconn *)pgsql->conn, pgsql->lofd); + ETURN_LONG (offset); } /* }}} */ Index: php4/ext/pgsql/php_pgsql.h diff -u php4/ext/pgsql/php_pgsql.h:1.23 php4/ext/pgsql/php_pgsql.h:1.24 --- php4/ext/pgsql/php_pgsql.h:1.23 Thu Jan 4 03:15:35 2001 +++ php4/ext/pgsql/php_pgsql.h Thu Jan 18 14:17:05 2001 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_pgsql.h,v 1.23 2001/01/04 11:15:35 jah Exp $ */ +/* $Id: php_pgsql.h,v 1.24 2001/01/18 22:17:05 derick Exp $ */ #ifndef PHP_PGSQL_H #define PHP_PGSQL_H @@ -85,6 +85,8 @@ PHP_FUNCTION(pg_loreadall); PHP_FUNCTION(pg_loimport); PHP_FUNCTION(pg_loexport); +PHP_FUNCTION(pg_lolseek); +PHP_FUNCTION(pg_lotell); PHP_FUNCTION(pg_put_line); PHP_FUNCTION(pg_end_copy); #if HAVE_PQCLIENTENCODING

« previous php.cvs (#3690) next »