Subject RE: [ib-support] Questions about Firebird's API
Author Tony Mays
Thanks to all for your assistance on isc_free(), I discovered isc_free takes
one parameter - a char * to the dbp. Again, thanks to all.

tony

-----Original Message-----
From: C R Zamana [mailto:zamana@...]
Sent: Thursday, March 14, 2002 9:37 AM
To: ib-support@yahoogroups.com
Subject: RE: [ib-support] Questions about Firebird's API


On Thu, 2002-03-14 at 14:04, Ann W. Harrison wrote:
> At 03:12 AM 3/14/2002 -0800, Tony Mays wrote:
>
> >Any guidance on isc_free() is more than welcome because I can see some
> >obvious uses for isc_expand_dpb().
>
> Don't use isc_expand_dpb. Despite the API Guide, it's not a
> reliable way to build parameter blocks.
>

I use this approach to connect with database passing username
and password and it works fine. Feel free :-)

---- Code ------------------------------------------------------------

#include "rdd_api.h"

ISC_LONG api_connect( char *db, char *user, char *pass, isc_db_handle
*dbhandle ) {

char *dpb;
char *dpb_buffer;
char *p;
short dpb_length;
ISC_STATUS status_vector[20];

dpb_buffer = (char *)malloc(USERNAME_SIZE+PASSWORD_SIZE+3);
if ( dpb_buffer == NULL ) {
return(-1);
}

dpb_length = 0;
dpb = dpb_buffer;

/* Do not use isc_expand_dpb()!!!
*
*/

/*
isc_expand_dpb( &dpb, &dpb_length, isc_dpb_user_name, user,
isc_dpb_password, pass, NULL );
*/

/* manually building the dpb */
*dpb++ = isc_dpb_version1;
*dpb++ = isc_dpb_user_name;
*dpb++ = strlen(user);
for( p = user; *p; )
*dpb++ = *p++;

*dpb++ = isc_dpb_password;
*dpb++ = strlen(pass);
for( p = pass; *p; )
*dpb++ = *p++;

dpb_length = dpb - dpb_buffer;

isc_attach_database( status_vector, 0, db, dbhandle, dpb_length,
dpb_buffer );

if ( status_vector[0] == 1 && status_vector[1] ) {
isc_print_status(status_vector);
}

free(dpb_buffer);

return( isc_sqlcode(status_vector) );
}

--------- Code ------------------------------------------------------



To unsubscribe from this group, send an email to:
ib-support-unsubscribe@egroups.com



Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/