First of all, there's an issue with how you imported the function. You import it as "unsigned int" when "ssize_t" is the same size as "size_t", but signed instead of unsigned. To map this to the proper type, it depends on the platform. Most POSIX implementations on x86 that I know of make ssize_t and size_t the same size as a pointer, which also happens to be the same as long and unsigned long in these cases. IIRC, there's only one C implementation that I know of that breaks this assumption. Win32 vs Win64. It's only true for Win32. Win64 does not change the size of integer primitives (char, short, int, long) from what they are in Win32. You would have to use long long if you wanted this to work on Win64.
This may be a contributing factor as to why NULL is returned, but it would help if you could define the bson_error_t type and then retrieve the actual error message.
From what I can determine, the type necessary is this:
Code: Select all
This can be converted to the following pack format: "lu lu s504". I would not recommend trying to use struct with this, as that doesn't really handle string arrays well.
So, if you could determine the actual error, that would help you find out what to do next.