09-26-2013 08:41 PM
Hello to everyone.
The question is:
Is there an simple way to form '\0' terminated c-string in basic to pass it as an argument in C library's function?
Library's function notification:
int login(char * login, char * password);
Solved! Go to Solution.
09-26-2013 09:04 PM
So, the simplest way for me is to create wrapping functions over my library function and transfer a pointer to string for a parsing in C.
But it is not neat-looking solution. Furthermore I've not managed to find how to get a pointer in basic yet.
09-26-2013 10:35 PM
09-29-2013 01:07 PM
For sake of completeness...
>> Furthermore I've not managed to find how to get a pointer in basic yet.
Basic has the LOC function to return the address of a variable.
Note: "For dynamic strings, the LOC function returns the address of the descriptor rather than the address of the data."
For a dynamic string you can use LIB$ANALYZE_SDESC to get the actual address, but that gets tedious.
One option is to use a static / fixed string in a MAP, copy in the string , use (left side) MID$ to put a NULL at the desired offset, pass the address of the (fixed) string using LOC.
This may sound like a lot of overhead, but please realize the operations like 'cstr+ "0"c' will also copy the strings around and allocate descriptors and stuff.