Can not login to Interbase database
| From: | Colovic Igor | Date: | Tue, 05 Jan 1999 22:24:09 +0000 |
| Subject: | Can not login to Interbase database | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-3301@lists.php.net to get a copy of this message | ||
I am sending you this code. And anotrer thing. While working with BLOB data
I so that this code is not finished, so I set down and wrote this code. I am
sending this code also. For BLOB I have to change interbase.c and
php3_interbase.h so I am sending the whole code of php3_interbase.h.
php3_interbase.h:
/*
+----------------------------------------------------------------------+
| PHP HTML Embedded Scripting Language Version 3.0 |
+----------------------------------------------------------------------+
| Copyright (c) 1997,1998 PHP Development Team (See Credits file) |
+----------------------------------------------------------------------+
| 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. |
+----------------------------------------------------------------------+
| Authors: Jouni Ahto <jah@cultnet.fi> |
| |
+----------------------------------------------------------------------+
*/
/* $Id: php3_interbase.h,v 1.2 1998/12/19 19:00:04 jah Exp $ */
#ifndef _PHP3_IBASE_H
#define _PHP3_IBASE_H
#if COMPILE_DL
#undef HAVE_IBASE
#define HAVE_IBASE 1
#endif
#if HAVE_IBASE
#include <ibase.h>
extern php3_module_entry ibase_module_entry;
#define php3_ibase_module_ptr &ibase_module_entry
extern int php3_minit_ibase(INIT_FUNC_ARGS);
extern int php3_rinit_ibase(INIT_FUNC_ARGS);
extern int php3_mfinish_ibase(void);
extern void php3_info_ibase(void);
extern void php3_ibase_connect(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_ibase_pconnect(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_ibase_close(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_ibase_query(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_ibase_fetch_row(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_ibase_free_result(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_ibase_prepare(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_ibase_bind(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_ibase_execute(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_ibase_free_query(INTERNAL_FUNCTION_PARAMETERS);
extern void php3_ibase_timefmt(INTERNAL_FUNCTION_PARAMETERS);
typedef struct {
long default_link;
isc_tr_handle trans; /* changed so I could get tr_handle for
isc_open_blob.
long num_links, num_persistent;
long max_links, max_persistent;
long allow_persistent;
int le_link, le_plink, le_result, le_query;
char *default_user, *default_password;
long manualtransactions;
char *timeformat;
} ibase_module;
typedef struct _php3_ibase_result {
isc_stmt_handle result;
isc_tr_handle trans;
XSQLDA *sqlda;
int commitok;
} ibase_result_handle;
typedef struct _php3_ibase_query {
isc_stmt_handle query;
isc_tr_handle trans;
XSQLDA *sqlda;
int alloced;
} ibase_query_handle;
typedef struct _php3_ibase_varchar {
short var_len;
char var_str[1];
} IBASE_VCHAR;
extern ibase_module php3_ibase_module;
#else
#define php3_ibase_module_ptr NULL
#endif /* HAVE_IBASE */
#endif /* _PHP3_IBASE_H */
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
*/
interbase.h: (part for login)
/* {{{ _php_ibase_attach_db() */
static int _php_ibase_attach_db(char *server, char *uname, int uname_len,
char *passwd, int passwd_len, isc_db_handle *db)
{
char dpb_buffer[256], *dpb, *p;
short dpb_length;
ISC_STATUS status[20];
char msg[512];
long *pvector;
dpb = dpb_buffer;
*dpb++ = isc_dpb_version1;
*dpb++ = isc_dpb_user_name;
*dpb++ = strlen(uname);
for (p = uname; *p;)
*dpb++ = *p++;
*dpb++ = isc_dpb_password;
*dpb++ = strlen(passwd);
for (p = passwd; *p;)
*dpb++ = *p++;
dpb_length = dpb - dpb_buffer;
/* This could be wrong but it is written in API guide for Interbase 4.0 */
/* db = NULL; */
isc_attach_database(status,
strlen(server),
server,
db,
dpb_length,
dpb_buffer);
if (status[0] == 1 && status[1])
{
pvector = status;
isc_interprete(msg, &pvector);
php3_error(E_WARNING,"Unable to connect to InterBase server: %s", msg);
return 1;
}
return 0;
}
/* }}} */
interbase.c(part for blob) (this goes in void
php3_ibase_fetch_row(INTERNAL_FUNCTION_PARAMETERS) )
case SQL_BLOB:
case SQL_ARRAY:
{
int id, type;
isc_db_handle db_handle;
isc_tr_handle tr_handle;
isc_blob_handle blob_handle;
ISC_QUAD blob_id;
long status[20];
char segment [1024], string [1025];
unsigned short length;
tr_handle = IBASE_GLOBAL(php3_ibase_module).trans;
blob_handle = NULL;
id = IBASE_GLOBAL(php3_ibase_module).default_link;
db_handle = (isc_db_handle) php3_list_find(id, &type);
blob_id = *(ISC_QUAD ISC_FAR *) var[i].sqldata;
/*isc_start_transaction(NULL, &tr_handle, 1, &db_handle, 0, NULL);*/
isc_open_blob(status, &db_handle, &tr_handle, &blob_handle, &blob_id);
for(;;)
{
status[1] = isc_get_segment(NULL, &blob_handle, &length, sizeof
(segment), segment);
if (status[1] && (status[1] != 335544366L)) break;
strncpy (string, segment, length);
string[length] = 0;
collen = sprintf(string, "%s");
add_get_index_stringl(return_value, i, string, collen, (void **)
&pval_ptr, 1);
_php3_hash_pointer_update(return_value->value.ht, fieldname,
var[i].sqlname_length+1, pval_ptr);
}
isc_close_blob(status, &blob_handle);
}
break;
--
PHP Development Mailing List http://www.php.net/
To unsubscribe send an empty message to php-dev-unsubscribe@lists.php.net
For help: php-dev-help@lists.php.net