I was wondering if anyone could help me with calling the Notes C API function ldap_get_dn from LotusScript. It returns a pointer to a null terminated string (LMBCS i assume) if successful, or null if not successful. Also I need the pointer to free up the memory being used by the string using ldap_memfree. I have no idea how long the string is, or what its maximum size could be. This is vaguely how I expect to proceed.
1. Get the pointer, ptr = ldap_get_dn(ld, entry)
2. If ptr = 0 stop and report error
3. Find out the length of the LMBCS string in characters (not bytes) using some function which looks for the null.
4. Allocate a lotusscript string that is big enough to hold it using the value derived in step 3 above.
5. Copy/Translate the LBMCS string to the LotusScript unicode string.
6. Free up the original memory using ldap_memfree(ptr)
I know how to do steps 1, 2, 4, 6, but I need help with steps 3 and 5. Assuming my logic is correct of course.