Subject | UDF's with multiple Parameters |
---|---|
Author | lec_sas |
Post date | 2006-11-21T20:30:50Z |
Hello,
I am having problems accepting parameters writing my udf's with C:
I need to write some udf's for my app and I have been doing some
testing to learn how. My udfs are written in C (not C++) but I am
having problems accessing the parameters. My test function does
nothing but accept 3 strings and print out the length of all 3.
Here the code of the function:
_declspec(dllexport) char* __stdcall Test1 (char *str1, char *str2,
char *str3 ){
char* s;
s = (char*)malloc(sizeof(char) * 256);
sprintf(s, "%d, %d, %d", strlen(str1), strlen(str2), strlen(str3));
return s;
}
The result of my function no matter what the input parameters are is
"768 512 256". I have tried declaring the function the following 2
alternative ways and I get the same incorrect results:
_declspec(dllexport) char* __cdecl Test2 ( char *str1, char *str2,
char *str3 );
_declspec(dllexport) char* Test3 ( char *str1, char *str2, char *str3 );
The following is the statement I used to define the external functions:
DECLARE EXTERNAL FUNCTION TEST1 CHAR(256), CHAR(256), CHAR(256)
RETURNS CSTRING(256) FREE_IT ENTRY_POINT 'Test1' MODULE_NAME
'FireBirdUDFs.dll';
Can someone spot out what I have excluded OR if my explanation was not
clear enough, can someone provide me with a source to some of the
examples?
IMPORTANT NOTE: My functions work if I only have 1 parameter, but not
multiple parameters
Thanks!
-Darin Amos
I am having problems accepting parameters writing my udf's with C:
I need to write some udf's for my app and I have been doing some
testing to learn how. My udfs are written in C (not C++) but I am
having problems accessing the parameters. My test function does
nothing but accept 3 strings and print out the length of all 3.
Here the code of the function:
_declspec(dllexport) char* __stdcall Test1 (char *str1, char *str2,
char *str3 ){
char* s;
s = (char*)malloc(sizeof(char) * 256);
sprintf(s, "%d, %d, %d", strlen(str1), strlen(str2), strlen(str3));
return s;
}
The result of my function no matter what the input parameters are is
"768 512 256". I have tried declaring the function the following 2
alternative ways and I get the same incorrect results:
_declspec(dllexport) char* __cdecl Test2 ( char *str1, char *str2,
char *str3 );
_declspec(dllexport) char* Test3 ( char *str1, char *str2, char *str3 );
The following is the statement I used to define the external functions:
DECLARE EXTERNAL FUNCTION TEST1 CHAR(256), CHAR(256), CHAR(256)
RETURNS CSTRING(256) FREE_IT ENTRY_POINT 'Test1' MODULE_NAME
'FireBirdUDFs.dll';
Can someone spot out what I have excluded OR if my explanation was not
clear enough, can someone provide me with a source to some of the
examples?
IMPORTANT NOTE: My functions work if I only have 1 parameter, but not
multiple parameters
Thanks!
-Darin Amos