Newbie need Help with C
Posted: Wed Mar 31, 2004 12:43 pm
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
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