Firebird services

Hi. Hoping someone is familiar with Firebird and fbclient.dll.

I am attempting to connect to a Firebird service manager using the isc_service_attach function but keep getting caught out on the last parameter, a pointer to a CHAR.

I have tried several approaches, defining it as a CHAR,DIM(128) and as a CSTRING(128) and priming it with the required data and in either case I get an error that it doesn’t start with the correct data; element[1] =2, element[2]=2, element[3]=28 (an identifier for username), etc etc.

The error is: Invalid clumplet buffer structure: spb in service attach should begin with isc_spb_version1 or isc_spb_version

I have posted to the Firebird forum but no-one there has any idea about coding in Clarion, I’m hoping someone here has an idea about Firebird. The only thing they queried was that I started my array at 1, not 0.

AFAICT, I have the preceeding parameters correct, mostly pointers, just the last one, the system parameter buffer I can’t seem to get right.

Apologies if it’s a bit vague, toeing the water to see if anyone might have used fbclient.dll before and steer me in the right direction.

Cheers,
Andrew.

Try prototyping it as a ulong, then using address() to get the ptr to the char variable.

IE
ptr ulong
data cstring(1)
code
ptr = address(data)
data = ‘x’ ! whatever it needs to be
isc_service_attach(x,y,z,ptr)

Thanks again Paul.
I’ll be a little more verbose, was under a bit of time pressure yesterday.

From the API guide, isc_service_attach is defined:
http://www.ibphoenix.com/files/60ApiGuide.zip

ISC_STATUS isc_service_attach(
    ISC_STATUS *status_vector,
    unsigned short service_length,
    char *service,
    isc_svc_handle *svc_handle,
    unsigned short spb_length,
    char *spb);

I have prototyped it:

isc_service_attach(LONG, USHORT, LONG, LONG, USHORT, LONG),ISC_STATUS,RAW,C

I have declared a few EQUATEs and other variables including:

spb_buffer CSTRING(128)

I then proceed to assign values:

spb_buffer[1]   = CHR(2)    !aka isc_spb_version EQUATE(2)    
spb_buffer[2]   = CHR(2)    !aka isc_spb_current_version EQUATE(2)
spb_buffer[3]   = CHR(28)   !28 is the id for username
spb_buffer[4]   = CHR(6)     !the length of the username
spb_buffer[5]   = 'S' 
spb_buffer[6]   = 'Y' 
spb_buffer[7]   = 'S'
etc

and call:

result = isc_service_attach(ADDRESS(status_vector), service_length, ADDRESS(service), ADDRESS(svc_handle), spb_length, ADDRESS(spb_buffer))

I get the error listed in OP. If I declare spb_buffer this way:

spb_buffer BYTE,DIM(128)

and assign it this way:

spb_buffer[1]   = 2 !isc_spb_version
spb_buffer[2]   = 2
spb_buffer[3]   = 28 
spb_buffer[4]   = 6
spb_buffer[5]   = VAL('S')
spb_buffer[6]   = VAL('Y')
spb_buffer[7]   = VAL('S')
etc

I get the same error message.

What is your take, what error have I made? Is my prototype correct, should it be PASCAL instead of C?

I need a fresh set of eyes.

Thanks,

Andrew.

Just wondering why you declare it as CSTRING, why not STRING? You pass buffer length to the api, so trailing <0> char is not required to determine a buffer end.

Good question. I can try it with a STRING data type.
Though I have broken it again, different error message:

Invalid clumplet buffer structure: buffer end before end of clumplet - clumplet too long

which I think is related to the buffer and it’s size and probably the trailing null.

Cheers,

Did you see this link http://www.firebirdfaq.org/faq320/

Yes I did, thanks. Using ISO8859_1 char set.

So no matter how you prototype it, it doesn’t work but it also doesn’t crash/gpf the app?
Without reading the doc it’s possible you have the right attribute on the prototype (,C) but certainly changing to ,PASCAL instead can’t hurt. The worst it’ll do is crash the app, and it’s already not working

Yep, tried changing from C to PASCAL with no difference.
You are correct, the function appears to be working with no crash/GPF.

There’s a section on Calling Conventions in the doc. The 3 functions that have a variable number of arguments use the C calling convention. Everything else is stdcall.

On this page, they #define user name as 100, not 28.

https://www.ibphoenix.com/resources/documents/design/doc_186

Sorry for late reply.

That page might be a bit old.

The values I got were from the include file, ibase.h, that is part of the Firebird installation.

Cheers.