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

From: Date: Sun, 04 Jun 2000 20:24:07 +0000
Subject: cvs: php4 /ext/pgsql/ pgsql.c php_pgsql.h
Groups: php.version4 
Request: Send a blank email to php-version4+get-16134@lists.php.net to get a copy of this message
jah Sun Jun 4 13:24:07 2000 EDT Modified files: /php4/ext/pgsql pgsql.c php_pgsql.h Log: - Added functions pg_loimport(), pg_loexport(). @- Added functions pg_loimport(), pg_loexport(). (Jouni) Index: php4/ext/pgsql/pgsql.c diff -u php4/ext/pgsql/pgsql.c:1.52 php4/ext/pgsql/pgsql.c:1.53 --- php4/ext/pgsql/pgsql.c:1.52 Wed May 31 13:40:28 2000 +++ php4/ext/pgsql/pgsql.c Sun Jun 4 13:24:07 2000 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: pgsql.c,v 1.52 2000/05/31 20:40:28 zeev Exp $ */ +/* $Id: pgsql.c,v 1.53 2000/06/04 20:24:07 jah Exp $ */ #include <stdlib.h> @@ -76,6 +76,8 @@ PHP_FE(pg_loread, NULL) PHP_FE(pg_lowrite, NULL) PHP_FE(pg_loreadall, NULL) + PHP_FE(pg_loimport, NULL) + PHP_FE(pg_loexport, NULL) {NULL, NULL, NULL} }; @@ -1510,6 +1512,95 @@ return_value->type = IS_LONG; } /* }}} */ + +/* {{{ proto int pg_loimport(string filename[, resource connection]) + Import large object direct from filesystem */ +PHP_FUNCTION(pg_loimport) +{ + zval **pgsql_link, **file_in; + int id = -1; + PGconn *pgsql; + Oid oid; + PLS_FETCH(); + PGLS_FETCH(); + + switch (ZEND_NUM_ARGS()) { + case 1: + if (zend_get_parameters_ex(1, &file_in) == FAILURE) { + RETURN_FALSE; + } + id = PGG(default_link); + break; + case 2: + if (zend_get_parameters_ex(2, &file_in, &pgsql_link) == FAILURE) { + RETURN_FALSE; + } + convert_to_string_ex(file_in); + break; + default: + WRONG_PARAM_COUNT; + break; + } + + if (PG(safe_mode) &&(!php_checkuid(Z_STRVAL_PP(file_in), 2))) { + RETURN_FALSE; + } + + ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink); + + oid = lo_import(pgsql, Z_STRVAL_PP(file_in)); + + if (oid > 0) { + RETURN_LONG((int)oid); + } else { + RETURN_FALSE; + } +} +/* }}} */ + +/* {{{ proto int pg_loexport(int objoid, string filename[, resource connection]) + Emport large object direct to filesystem */ +PHP_FUNCTION(pg_loexport) +{ + zval **pgsql_link, **oid_id, **file_out; + int id = -1; + Oid oid; + PGconn *pgsql; + PGLS_FETCH(); + + switch (ZEND_NUM_ARGS()) { + case 2: + if (zend_get_parameters_ex(2, &oid_id, &file_out) == FAILURE) { + RETURN_FALSE; + } + convert_to_long_ex(oid_id); + convert_to_string_ex(file_out); + id = PGG(default_link); + break; + case 3: + if (zend_get_parameters_ex(3, &oid_id, &file_out, &pgsql_link) == FAILURE) { + RETURN_FALSE; + } + convert_to_long_ex(oid_id); + convert_to_string_ex(file_out); + break; + default: + WRONG_PARAM_COUNT; + break; + } + + ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink); + + oid = (Oid) Z_LVAL_PP(oid_id); + + if (lo_export(pgsql, oid, Z_STRVAL_PP(file_out))) { + RETURN_TRUE; + } else { + RETURN_FALSE; + } +} +/* }}} */ + #endif @@ -1519,3 +1610,4 @@ * c-basic-offset: 4 * End: */ + Index: php4/ext/pgsql/php_pgsql.h diff -u php4/ext/pgsql/php_pgsql.h:1.11 php4/ext/pgsql/php_pgsql.h:1.12 --- php4/ext/pgsql/php_pgsql.h:1.11 Wed May 31 13:40:28 2000 +++ php4/ext/pgsql/php_pgsql.h Sun Jun 4 13:24:07 2000 @@ -1,33 +1,23 @@ /* +----------------------------------------------------------------------+ - | PHP HTML Embedded Scripting Language Version 3.0 | + | PHP version 4.0 | +----------------------------------------------------------------------+ - | Copyright (c) 1997,1998 PHP Development Team (See Credits file) | + | Copyright (c) 1997, 1998, 1999, 2000 The PHP Group | +----------------------------------------------------------------------+ - | This program is free software; you can redistribute it and/or modify | - | it under the terms of one of the following licenses: | - | | - | A) the GNU General Public License as published by the Free Software | - | Foundation; either version 2 of the License, or (at your option) | - | any later version. | - | | - | B) the PHP License as published by the PHP Development Team and | - | included in the distribution in the file: LICENSE | - | | - | This program is distributed in the hope that it will be useful, | - | but WITHOUT ANY WARRANTY; without even the implied warranty of | - | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | - | GNU General Public License for more details. | - | | - | You should have received a copy of both licenses referred to here. | - | If you did not, or have any questions about PHP licensing, please | - | contact core@php.net. | + | This source file is subject to version 2.02 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available at through the world-wide-web at | + | http://www.php.net/license/2_02.txt. | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ - | Authors: Jouni Ahto | + | Authors: Zeev Suraski <zeev@zend.com> | + | Jouni Ahto <jah@mork.net> | +----------------------------------------------------------------------+ */ -/* $Id: php_pgsql.h,v 1.11 2000/05/31 20:40:28 zeev Exp $ */ +/* $Id: php_pgsql.h,v 1.12 2000/06/04 20:24:07 jah Exp $ */ #ifndef _PHP_PGSQL_H #define _PHP_PGSQL_H @@ -98,6 +88,8 @@ PHP_FUNCTION(pg_loread); PHP_FUNCTION(pg_lowrite); PHP_FUNCTION(pg_loreadall); +PHP_FUNCTION(pg_loimport); +PHP_FUNCTION(pg_loexport); void php_pgsql_do_connect(INTERNAL_FUNCTION_PARAMETERS,int persistent); int php_pgsql_get_default_link(INTERNAL_FUNCTION_PARAMETERS);

« previous php.version4 (#16134) next »