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.


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

ptr ulong
data cstring(1)
ptr = address(data)
data = ‘x’ ! whatever it needs to be

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:

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:


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'

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')

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.



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.


Did you see this link

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.

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.