Newbie need Help with C

Just starting out? Need help? Post your questions and find answers here.
thomasrueger
New User
New User
Posts: 3
Joined: Wed Mar 24, 2004 4:37 pm
Location: Germany
Contact:

Newbie need Help with C

Post by thomasrueger »

In an Api Guide i found the following:

A Database Parameter Buffer is a char array with the following parts:

1. A byte specifying the version of the parameter buffer, always the compile time constand isc_dpb_version 1, in a separate header file i found that : #define isc_dpb_version1 1

2. An one-byte number parameter type. There are compile-time constants defined for all the parameter types. The header file have f.e.: #define isc_dpb_user 28 or #define isc_dpb_password 29

2. A one - byte number specifying the number of bytes that follow in the remainder of the cluster
3. A variable number of bytes, whose interpretation depens on the parameter type.

The given example:

char dpb_buffer[256], * dpb, *p;
short dpb_length
dpb=dpb_buffer
*dpb++ = isc_dpb_version1
*dpb++ = isc_num_buffers
*dpb++ = 1
*dpb++ = 90
dpb_length = dpb - dpb_buffer

So i tried the following:

*DPB = AllocateMemory(0, 1000, 0)
;for isc_dpb_version1 , thats is define as 1
CopyMemoryString("1", @*DPB)
;for isc_dpb_user
CopyMemoryString("28")
;for len of username
CopyMemoryString("6")
;username
CopyMemoryString("Userna")
;for isc_dpb_password
CopyMemoryString("29")
;for len of password
CopyMemoryString("8")
;password
CopyMemoryString("password")

Len.w = 25
After this i put that in my function

... CallFunction ( ... , Len,@*DPB)

But i always get the error "... bad format" ...

Could somebody help my, how i can make this kind of C Buffer, called Database Parameter Buffer ?

In the api guide the have a second example:

char dpb_buffer[256], * dpb, *p
short dpb_length

dpb = dpb_buffer
*dpb++=isc_dpb_version1
*dpb++=isc_dpb_user_name
*dpb++ = strlen(user_name)
for (p = user_name,*p)
*dpb++= *p++

*dpb++ = isc_dpb_password
*dpb++= strlen(user_password)
for (p = user_password;*p;)
*dpb++ = *p++
dpb_length = dpb - dpb_buffer

and the function in C:

isc_attach_database( ...,db_length,dpb_buffer)

So i really need help, because im just a poor Basic Programmer

Thanks a Lot, Cu

Thomas :(
carolight
User
User
Posts: 41
Joined: Mon Feb 09, 2004 11:08 am
Location: Gold Coast, Australia

Post by carolight »

I'm sure others can answer this better than me, but as it hasn't been answered yet, I'll have a shot. (I haven't used C in a while though....)

C doesn't use @ for addresses, that's a PureBasic thing.

char *a ; //this creates a pointer
char b[256]; // this creates an array of chars

b[0] = 'A';
a = b ; // this points a at b

*a will have the contents "A"

a will be the address of the char array b

&a will be the address of the pointer

Hope this helps in a small way. Hopefully if there's a blinding error someone will correct.
Post Reply